Wrapping Python - A function wrapping template
Daniel Keep
daniel.keep.lists at gmail.com
Sun Jun 18 01:50:16 PDT 2006
Kirk McDonald wrote:
> Kirk McDonald wrote:
>> In wrapping Python with D, I have just made a large step:
>>
>
> The testdll.d file now looks like this:
>
> [testdll.d]
> module testdll;
>
> import pyd.pyd;
>
> char[] foo(int i) {
> if (i > 10) {
> return "It's greater than 10!";
> } else {
> return "It's less than 10!";
> }
> }
>
> extern (C)
> export void inittestdll() {
> def!("foo", foo);
>
> module_init("testdll");
> }
VERY nice.
> // EOF
>
> Quite a lot of things remain to be done, but at least the API looks nice
> and clean.
>
> -Kirk McDonald
Indeed it does. It's somewhat hard to tell that Python's even involved
anymore :) The only other two things I can think of are:
1. Being able to use def!(foo), then just parse out foo's original name
would be cool :)
2. I wonder if you can somehow pinch the current module's name for the
module_init() call.
Not criticisms by any stretch of the imagination; just curious if it'd
be possible. Can't wait to get my grubby mits on your code :)
-- Daniel
--
Unlike Knuth, I have neither proven or tried the above; it may not even
make sense.
v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D
i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP http://hackerkey.com/
More information about the Digitalmars-d
mailing list