On Tue, Sep 1, 2009 at 3:19 PM, Frederik<scumm_fredo gmx net> wrote:
ecir hana wrote: Yes, except that PyMethodDef is a type, not a function. I have translated this example to Vala (see attachment). I have put the bindings into a separate 'python.vapi' file. You can compile with:
Thank you! This is very useful for me. It already does more than I wanted. I tried to modify your code so I can call Vala function with string argument from within Python (attached bellow). However, I'm slowly getting lost: - during compiling, valac says: pythondemo3.vala.c:43: warning: passing arg 2 of `Py_InitModule4' discards qualifiers from pointer target type Is this what you said below about 'emb_methods' being constant? (it might just be the case that I have weird python installation, though...) - looking in your .vapi, what does it mean "..."? Variable number of arguments? - and what does it mean, that class Object is empty? Doesn't it matter? Or better yet, what should be inside? - arg_parse_tuple(), when converting Python strings to C strings expects char pointer, is it ok to write &s in Vala? http://docs.python.org/extending/extending.html#extracting-parameters-in-extension-functions http://docs.python.org/c-api/arg.htm (the very first format string "s") PS: I'm sorry if I bother you guys....
$ valac pythondemo.vala -X -lpython2.6 --pkg python --vapidir . The C compiler emits a warning about 'emb_methods' being constant, but Vala currently allows short array initialization with structs only for const arrays.
Attachment:
pythondemo3.vala
Description: Text Data