FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Just a suggestion

 
Post new topic   Reply to topic     Forum Index -> DDL - D Dynamic Libraries
View previous topic :: View next topic  
Author Message
bobef



Joined: 05 Jun 2005
Posts: 269

PostPosted: Tue Feb 14, 2006 8:46 am    Post subject: Just a suggestion Reply with quote

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
View user's profile Send private message
pragma



Joined: 28 May 2004
Posts: 607
Location: Washington, DC

PostPosted: Tue Feb 14, 2006 1:26 pm    Post subject: Re: Just a suggestion Reply with quote

[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? Smile
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
bobef



Joined: 05 Jun 2005
Posts: 269

PostPosted: Wed Feb 15, 2006 4:46 am    Post subject: Reply with quote

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
View user's profile Send private message
pragma



Joined: 28 May 2004
Posts: 607
Location: Washington, DC

PostPosted: Wed Feb 15, 2006 8:01 am    Post subject: Reply with quote

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! Smile
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
Don Clugston



Joined: 05 Oct 2005
Posts: 91
Location: Germany (expat Australian)

PostPosted: Tue Feb 21, 2006 2:27 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DDL - D Dynamic Libraries All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group