Pyrex char *x[]

2007-05-15 Thread Georg Grabler
Hello everybody.

I finally decided to use pyrex for my tasks wrapping and creating new python
objects.

Anyway, i ran into struggles.
I want an array to be passed to a function, so basically i started the
function as follows:

def addToList (self, char *array[]):
  

This throws an error compiling:
"Cannot convert Python object argument to type 'char(*(*))'"

So, what i want:
Basically, it's a function called by python. This function shall step trough
the elements of the array, and call another function:
def addList(self, char *str):
  ...

Calling the addList function directly works properly, the function extends a
C list for the object. Now i want a function adding the whole array to a
the list, using the 2nd function.

Does anyone of you have an idea how to archive this?

Thank you,
Georg
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Binding

2007-05-12 Thread Georg Grabler
You are completely right wihtin this. It's some time i didn't reply, but
i've taken a look on pyrex and swig now which did cost me some time, and
they really make it easier. SWIG provides more possibilities and bindings
for other languages too, though - i must say i've been faster with pyrex,
for some reason it fits me better.

I'd like to use swig, but for some reason i've troubles defining a
completely new type, so a type which is not a wrapper type, but a type
provided to python.

Kind regards,
Georg

Stefan Behnel wrote:

> STiAT wrote:
>> Why do you all suggest other things than the way suggested by python?
> 
> Because going to Paris is not the only way to get french bread?
> 
> Why would you want to write all that ugly glue code by hand that Pyrex
> generates for free? Module descriptors? Class descriptors? Method
> descriptors? Reference counting? That's what Pyrex saves you from.
> Honestly.
> 
> From what I read in your mail, that's exactly the kind of thing you're
> having trouble with. Wouldn't you prefer concentrating on your real code
> instead?
> 
> 
>> I havn't got a real problem writing the code in C, actually, it looked
>> as if it would give me several possibilities i wouldn't have with
>> pyrex (like binding more library functions to one provided python
>> function and so on).
> 
> No idea what you mean in your parentheses, but I don't think there are
> many "possibilities" you "wouldn't have with Pyrex".
> 
> We used Pyrex to write lxml, a wrapper around the huge API of libxml2 and
> libxslt. It's some 11000 lines of Pyrex code by now, but the generated C
> code is some 67000 lines in total. Even if it's somewhat verbose and
> generic in places, I wouldn't have wanted to write that by hand.
> 
> Stefan

-- 
http://mail.python.org/mailman/listinfo/python-list


Python Binding

2007-05-05 Thread Georg Grabler
Hello everybody.

There's a C library which i'd like to have python bindings for. I havn't
known anything before about how to write python bindings for a C library.

I succeeded now by using distutils to write the first bindings for functions
and similar.

Now, it seems as something is blocking my brain. For the library, i
need "custom" types, so types defined in this library (structures),
including pointers and similar.

I've been thinking about what i will need to represent this lists in python.
I thought about creating an external python object, providing "information"
i get from the list in C structures which can be converted.

Basically, it are list of packages, which have several attributes (next,
prev, etc). But i don't know how to supply a proper list from the binding /
object written in C.

Any suggestions or hints about this?

Thank you,
Georg
-- 
http://mail.python.org/mailman/listinfo/python-list