|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Specific question about C callback with Python handler ...Hi,
I have a C library which generates a Callback that I want to handle in my Python code. My .i file essentially looks like this, where I register my DataCallback via the Start() function: ---------- %module probe %{ #include "cheader.h" %} typedef void (*DataCallBack)(char*, unsigned int, int); int Start(DataCallBack); ---------- My Python code essentially looks like this: ---------- import probe def ProbeCallback(a, b, c): # char*, unsigned int, int print "PYTHON Callback!" probe.Start(ProbeCallback) ---------- But when I run the Python code, it can't coerce ProbeCallback to be a DataCallback. I get the following exception: Traceback (most recent call last): File "TestProbe.py", line ## in <module> probe.Start(ProbeCallback) TypeError: in method 'Start', argument 1 of type 'DataCallBack' Any idea what I'm missing here? Additionally, I've tried wrapping the Start function with my old Callback registration/invocation system. In this case the C callback gets called successfully, I can assemble the argument tuple to call the Python Callback. The Python Callback is considered a proper "callable" object, but it exceptions deep in Swig on invocation. I suspect it's the same reason the above Cast Exception check is being generated. Thanks in advance, Sandy [swalsh.vcf] begin:vcard fn:Alexander "Sandy" Walsh n:Walsh;Alexander "Sandy" org:Impath Networks adr:Suite 100;;42 Payzant Ave;Halifax;NS;B3B 1Z6;Canada email;internet:swalsh@... title:Software Developer tel;work:902-468-1010 x 246 x-mozilla-html:FALSE url:http://www.impathnetworks.com version:2.1 end:vcard ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Swig-user mailing list Swig-user@... https://lists.sourceforge.net/lists/listinfo/swig-user |
|
|
Re: SOLVED: Specific question about C callback with Python handler ...Found the problem. Full writeup of problem and solution can be found here:
http://sandywalsh.blogspot.com/2009/10/interfacing-multi-threaded-c-apis-with.html Cheers, Sandy Sandy Walsh wrote: > Hi, > > I have a C library which generates a Callback that I want to handle in > my Python code. > [swalsh.vcf] begin:vcard fn:Alexander "Sandy" Walsh n:Walsh;Alexander "Sandy" org:Impath Networks adr:Suite 100;;42 Payzant Ave;Halifax;NS;B3B 1Z6;Canada email;internet:swalsh@... title:Software Developer tel;work:902-468-1010 x 246 x-mozilla-html:FALSE url:http://www.impathnetworks.com version:2.1 end:vcard ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Swig-user mailing list Swig-user@... https://lists.sourceforge.net/lists/listinfo/swig-user |
| Free embeddable forum powered by Nabble | Forum Help |