You want to pass a Python function, method, or other callable into C as a 
function pointer?  This stack overflow question covers that: 
http://stackoverflow.com/questions/874245/python-ctypes-and-function-pointers

From: users-boun...@lists.ironpython.com 
[mailto:users-boun...@lists.ironpython.com] On Behalf Of Andrew Evans
Sent: Wednesday, February 09, 2011 10:41 AM
To: users@lists.ironpython.com
Subject: [IronPython] Cast to a method pointer using CTYPES

Forgive me if what I ask is a novice question. I have some C code that was 
asked to bring to Python I prefer IronPython and remember seeing that CTYPES 
was implemented into it :-)

I am not really the best C coder and was suggested by C coders that it couldn't 
be done in Python. I aim to prove them wrong

int main(int argc, char **argv)
{
   int (*func)();
   func = (int (*)()) myCode;
   printf("myCode Length is : %d",strlen(myCode));
   (int)(*func)();



}
is it possible to cast to a function pointer in IronPython using CTYPES I was 
looking at the CTYPES docs and from what I understand CTYPES has something 
called callback functions.

Anyway any idea or help

would be very valuable

Thank You
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to