View previous topic :: View next topic |
Author |
Message |
bobef
Joined: 05 Jun 2005 Posts: 269
|
Posted: Tue Feb 14, 2006 8:46 am Post subject: Just a suggestion |
|
|
Would be nice if there is some kind of funcion which accepts someting like
["mymodule","int","myfunction","int","void*"] and returns the name of the function like _D66mymodulw42389Sadsflkh2398fjlsadflsdjfl etc... And also since all the functions in a .obj are in the same module it could be skipped in some cases... Or maybe there is but I am unaware? |
|
Back to top |
|
|
pragma
Joined: 28 May 2004 Posts: 607 Location: Washington, DC
|
Posted: Tue Feb 14, 2006 1:26 pm Post subject: Re: Just a suggestion |
|
|
[quote="bobef"]Would be nice if there is some kind of funcion which accepts someting like
["mymodule","int","myfunction","int","void*"] and returns the name of the function like _D66mymodulw42389Sadsflkh2398fjlsadflsdjfl etc... [quote]
Well, technically you get that now via the .mangleof property on all D types.
As for a runtime facility, there isn't one yet but I plan on having one at some point.
Quote: | And also since all the functions in a .obj are in the same module it could be skipped in some cases... Or maybe there is but I am unaware? |
I'm sorry, but I have no idea what you mean by this. Could you please reword your question? _________________ -- !Eric.t.Anderton at gmail |
|
Back to top |
|
|
bobef
Joined: 05 Jun 2005 Posts: 269
|
Posted: Wed Feb 15, 2006 4:46 am Post subject: |
|
|
I mean the following thing. First this "Or maybe there is but I am unaware?" sentence should follow the previous not this one.
"And also since all the functions in a .obj are in the same module it could be skipped in some cases..." by this I mean that all the mangled names, or how is this "_d6asdjkasdkajhfkah4873fkadfh2934fhdasklfh3i" thing called, in a single .obj file are prefixed by the same module name i.e. _D6module, so if I have something like
Code: |
typedef void function(int) mytype;
|
and if I am able to say mytype.mangleof and it gives me how the compiler would call this function it still woudn't know the name of the module I am loading it from, but since all the functions there have the same module prefix we can skip it. In simple words what I want to be able to do is something like this.
Code: |
library l=loadddl("myobject.obj");
mytype t=cast(mytype)l.getSymbol(mytype.mangleof);
if(t) t();
|
|
|
Back to top |
|
|
pragma
Joined: 28 May 2004 Posts: 607 Location: Washington, DC
|
Posted: Wed Feb 15, 2006 8:01 am Post subject: |
|
|
bobef wrote: | Code: |
library l=loadddl("myobject.obj");
mytype t=cast(mytype)l.getSymbol(mytype.mangleof);
if(t) t();
|
|
Noted. Honestly, I don't see DDL being useful if the above doesn't become possible. We're already most of the way to doing just this! _________________ -- !Eric.t.Anderton at gmail |
|
Back to top |
|
|
Don Clugston
Joined: 05 Oct 2005 Posts: 91 Location: Germany (expat Australian)
|
Posted: Tue Feb 21, 2006 2:27 am Post subject: |
|
|
Code: |
typedef void function(int) mytype;
library l=loadddl("myobject.obj");
mytype t=cast(mytype)l.getSymbol(mytype.mangleof);
if(t) t();
|
It needs to know the name of the function, somehow. But the good news is, the casting is unnecessary. This is possible:
Code: | mytype t = l.getSymbol!(mytype, "myfunc")();
// or even
auto t2 = l.getSymbol!(mytype, "myfunc")();
|
Which is almost ideal.
Implicit function instantiation could make this situation pretty interesting, eg, in many cases we could hide the fact that templates are being used.
Code: | mytype t;
l.getSymbol(t, "myfunc");
|
[/code] |
|
Back to top |
|
|
|