Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
September 24, 2006 Return type and arguments template? | ||||
---|---|---|---|---|
| ||||
Can a function pointer or delegates arguments and return type bee determined by a template. I'm trying to create bindings to another language and would love to be able to export a function just by writing registerFunction(&functionName); Similarly can the components of a struct or class bee extracted. (in short i'm trying to build a sort of syntax tree describing the fuctions/delegates) |
September 25, 2006 Re: Return type and arguments template? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johan Granberg | Johan Granberg wrote: > Can a function pointer or delegates arguments and return type bee determined by a template. I'm trying to create bindings to another language and would love to be able to export a function just by writing > registerFunction(&functionName); Yes, it's possible. Depending on what you want to do, you can do it the C++ way, with a series of templates; or for just linking you can use the .mangleof property. Look up 'PyD' for bindings to Python with a syntax like that. > Similarly can the components of a struct or class bee extracted. (in short i'm trying to build a sort of syntax tree describing the fuctions/delegates) No, you can't find the members of a class or struct at compile time. Not yet, anyway. At run time you can use DDL (at dsource). BTW -- You keep making a spelling mistake, it's time someone corrected you. "bee" is an insect that buzzes and makes honey. The word you want is "be". <g> |
September 27, 2006 Re: Return type and arguments template? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don Clugston | Don Clugston wrote: > Johan Granberg wrote: > >> Can a function pointer or delegates arguments and return type bee determined by a template. I'm trying to create bindings to another language and would love to be able to export a function just by writing >> registerFunction(&functionName); > > > Yes, it's possible. Depending on what you want to do, you can do it the C++ way, with a series of templates; or for just linking you can use the .mangleof property. Look up 'PyD' for bindings to Python with a syntax like that. > To be strictly accurate, Pyd takes the functions to be bound as alias template parameters. You wrap a D function with: def!(functionName, "functionName"); The "def" template function has a number of template arguments but no function arguments. The above calls def with D's property syntax. Pyd does not (yet) use .mangleof in any capacity. The function name must be specified explicitly as a string literal template argument. As for deriving the various bits of a function pointer or delegate type, I suggest looking at the FuncMeta module in Tom S's Bind package. It currently lives here: http://www.mat.uni.torun.pl/~h3r3tic/bind.rar I am currently in the midst of thrashing Pyd until it uses that package. -- Kirk McDonald Pyd: Wrapping Python with D http://pyd.dsource.org |
September 27, 2006 Re: Return type and arguments template? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kirk McDonald | Kirk McDonald wrote:
> To be strictly accurate, Pyd takes the functions to be bound as alias template parameters. You wrap a D function with:
>
> def!(functionName, "functionName");
>
> The "def" template function has a number of template arguments but no function arguments. The above calls def with D's property syntax.
>
> Pyd does not (yet) use .mangleof in any capacity. The function name must be specified explicitly as a string literal template argument.
>
> As for deriving the various bits of a function pointer or delegate type, I suggest looking at the FuncMeta module in Tom S's Bind package. It currently lives here:
>
> http://www.mat.uni.torun.pl/~h3r3tic/bind.rar
>
> I am currently in the midst of thrashing Pyd until it uses that package.
Thanks for pointing me to the bind package (I did know about the pyd alias thing) as for the mangleof property is their complete documentation somewhere the d abi page had some TBDs in it.
|
September 27, 2006 Re: Return type and arguments template? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johan Granberg | Johan Granberg wrote:
> Kirk McDonald wrote:
>> To be strictly accurate, Pyd takes the functions to be bound as alias template parameters. You wrap a D function with:
>>
>> def!(functionName, "functionName");
>>
>> The "def" template function has a number of template arguments but no function arguments. The above calls def with D's property syntax.
>>
>> Pyd does not (yet) use .mangleof in any capacity. The function name must be specified explicitly as a string literal template argument.
>>
>> As for deriving the various bits of a function pointer or delegate type, I suggest looking at the FuncMeta module in Tom S's Bind package. It currently lives here:
>>
>> http://www.mat.uni.torun.pl/~h3r3tic/bind.rar
>>
>> I am currently in the midst of thrashing Pyd until it uses that package.
>
> Thanks for pointing me to the bind package (I did know about the pyd alias thing) as for the mangleof property is their complete documentation somewhere the d abi page had some TBDs in it.
There's no documentation, but see my meta.demangle and meta.nameof modules in DDL on dsource; I believe it covers 100% of the cases (std.demangle misses quite a few). If you find something it can't demangle, let me know!
But seriously, you probably don't need anything other than meta.nameof.
|
Copyright © 1999-2021 by the D Language Foundation