J
Java and Swing
Hi,
I have been posting about writing a C extension for Python...so far,
so good. At least for the "simple" functions that I need to wrap.
Ok, my c function looks like...
MY_NUM *doNumberStuff(const char *in, const char *x) { ... }
MY_NUM is defined as, typedef unsigned long MY_NUM; (not sure if that
matters, or can i just create a wrapper which handles longs?)
anyhow..for my wrapper I have this..
static PyObject *wrap_doNumberStuff(PyObject *self, PyObject args) {
char *in = 0;
char *x = 0;
long *result = 0;
int ok = PyArg_ParseTuple(args, "ss", &in, &x);
if (!ok) return 0;
result = doNumberStuff(in, x);
return Py_BuildValue("l", result);
}
....my question is...in the c code, result is a pointer to an array of
longs, how can I get the returned result to be a list or something
similar to an array in Python?
....I also have a function which returns a character array (denoted by a
char *)...would it work the same as the previous question?
Thanks!!
I have been posting about writing a C extension for Python...so far,
so good. At least for the "simple" functions that I need to wrap.
Ok, my c function looks like...
MY_NUM *doNumberStuff(const char *in, const char *x) { ... }
MY_NUM is defined as, typedef unsigned long MY_NUM; (not sure if that
matters, or can i just create a wrapper which handles longs?)
anyhow..for my wrapper I have this..
static PyObject *wrap_doNumberStuff(PyObject *self, PyObject args) {
char *in = 0;
char *x = 0;
long *result = 0;
int ok = PyArg_ParseTuple(args, "ss", &in, &x);
if (!ok) return 0;
result = doNumberStuff(in, x);
return Py_BuildValue("l", result);
}
....my question is...in the c code, result is a pointer to an array of
longs, how can I get the returned result to be a list or something
similar to an array in Python?
....I also have a function which returns a character array (denoted by a
char *)...would it work the same as the previous question?
Thanks!!