Re: [ctypes-users] Implementing DLL entry points in python: cplugins
Brought to you by:
theller
From: bifferos <bif...@ya...> - 2007-09-18 19:19:44
|
--- Thomas Heller <th...@ct...> wrote: > bifferos schrieb: > > I am implementing an add-on to ctypes which allows the implementation > > of C DLLs in Python. > > For general remarks see the comments that I already posted to the wiki page: > http://starship.python.net/crew/theller/wiki/Implementing_dynamic_DLLs_in_Python Yes thanks, I read that shortly after you wrote it, and decided to try to implement something. I cut some corners by using tcc to generate the plugin dll, so I should be able to port the idea easily enough from Windows -> Linux without understanding ELF/PE formats. > > class MyPlugin(cplugins.PLUGIN): > > def MyEntryPoint(self, first, second): > > "c_int MyEntryPoint( c_int, c_int )" > > return c_int(42) > > This looks like a perfect usecase for a decorator: > > class MyPlugin(cplugins.PLUGIN): > > @exported(name = "MyEntryPoint", restype = c_int, argtypes = (c_int, c_int)) > def MyEntryPoint(self, first, second): > return c_int(42) I'm glad you suggested this. I looked into decorators but all I found was PEPs, so assumed they weren't already implemented in 2.4! Now found the docs at: http://www.python.org/doc/2.4/whatsnew/node6.html I'll do it like that once I get my head round decorators. regards, -biff. ___________________________________________________________ Yahoo! Answers - Got a question? Someone out there knows the answer. Try it now. http://uk.answers.yahoo.com/ |