Re: Is it possible to dynamically load a @safe function from a shared library ?

2020-03-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/13/20 5:06 PM, H. S. Teoh wrote: On Fri, Mar 13, 2020 at 04:31:16PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: [...] I would expect that something could be written to turn a signature string into a mangling and also provide the correct type upon return. Something like:

Re: Is it possible to dynamically load a @safe function from a shared library ?

2020-03-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/14/20 6:06 AM, wjoe wrote: On Friday, 13 March 2020 at 20:31:16 UTC, Steven Schveighoffer wrote: On 3/13/20 4:22 PM, wjoe wrote: I would expect that something could be written to turn a signature string into a mangling and also provide the correct type upon return. Something like: auto

Re: Is it possible to dynamically load a @safe function from a shared library ?

2020-03-14 Thread wjoe via Digitalmars-d-learn
On Friday, 13 March 2020 at 20:31:16 UTC, Steven Schveighoffer wrote: On 3/13/20 4:22 PM, wjoe wrote: I would expect that something could be written to turn a signature string into a mangling and also provide the correct type upon return. Something like: auto f = getFunction!(@safe void

Re: Is it possible to dynamically load a @safe function from a shared library ?

2020-03-13 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Mar 13, 2020 at 04:31:16PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: [...] > I would expect that something could be written to turn a signature > string into a mangling and also provide the correct type upon return. > Something like: > > auto f = getFunction!(@safe void

Re: Is it possible to dynamically load a @safe function from a shared library ?

2020-03-13 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Mar 13, 2020 at 08:22:53PM +, wjoe via Digitalmars-d-learn wrote: [...] > So from what I understand, because, at least on Posix, since there's > only a symbol name there's nothing I can do in my loader to verify > that a function is or does what it claim to be/do. [...] As far as I

Re: Is it possible to dynamically load a @safe function from a shared library ?

2020-03-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/13/20 4:22 PM, wjoe wrote: I wasn't aware that pragma(mangle, ..) can practically name any function anything. So from what I understand, because, at least on Posix, since there's only a symbol name there's nothing I can do in my loader to verify that a function is or does what it claim

Re: Is it possible to dynamically load a @safe function from a shared library ?

2020-03-13 Thread wjoe via Digitalmars-d-learn
On Friday, 13 March 2020 at 18:30:51 UTC, H. S. Teoh wrote: On Fri, Mar 13, 2020 at 06:11:01PM +, wjoe via Digitalmars-d-learn wrote: On Friday, 13 March 2020 at 17:05:32 UTC, Mike Parker wrote: > On Friday, 13 March 2020 at 16:11:53 UTC, wjoe wrote: > > On Friday, 13 March 2020 at 16:04:06

Re: Is it possible to dynamically load a @safe function from a shared library ?

2020-03-13 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Mar 13, 2020 at 06:11:01PM +, wjoe via Digitalmars-d-learn wrote: > On Friday, 13 March 2020 at 17:05:32 UTC, Mike Parker wrote: > > On Friday, 13 March 2020 at 16:11:53 UTC, wjoe wrote: > > > On Friday, 13 March 2020 at 16:04:06 UTC, Mike Parker wrote: [...] > > > >

Re: Is it possible to dynamically load a @safe function from a shared library ?

2020-03-13 Thread wjoe via Digitalmars-d-learn
On Friday, 13 March 2020 at 17:05:32 UTC, Mike Parker wrote: On Friday, 13 March 2020 at 16:11:53 UTC, wjoe wrote: On Friday, 13 March 2020 at 16:04:06 UTC, Mike Parker wrote: On Friday, 13 March 2020 at 15:16:06 UTC, wjoe wrote: bindSymbol(, "VersionOfAPI"); } Is it possible to

Re: Is it possible to dynamically load a @safe function from a shared library ?

2020-03-13 Thread Mike Parker via Digitalmars-d-learn
On Friday, 13 March 2020 at 16:11:53 UTC, wjoe wrote: On Friday, 13 March 2020 at 16:04:06 UTC, Mike Parker wrote: On Friday, 13 March 2020 at 15:16:06 UTC, wjoe wrote: bindSymbol(, "VersionOfAPI"); } Is it possible to convince the compiler to look the other way while binding @safe

Re: Is it possible to dynamically load a @safe function from a shared library ?

2020-03-13 Thread wjoe via Digitalmars-d-learn
On Friday, 13 March 2020 at 16:04:06 UTC, Mike Parker wrote: On Friday, 13 March 2020 at 15:16:06 UTC, wjoe wrote: bindSymbol(, "VersionOfAPI"); } Is it possible to convince the compiler to look the other way while binding @safe functions from the plugin ? It probably has nothing to

Re: Is it possible to dynamically load a @safe function from a shared library ?

2020-03-13 Thread Mike Parker via Digitalmars-d-learn
On Friday, 13 March 2020 at 15:16:06 UTC, wjoe wrote: bindSymbol(, "VersionOfAPI"); } Is it possible to convince the compiler to look the other way while binding @safe functions from the plugin ? It probably has nothing to do with @safe, but is because of the void**.

Is it possible to dynamically load a @safe function from a shared library ?

2020-03-13 Thread wjoe via Digitalmars-d-learn
I've got a plug-in which is a shared library. Like this module plugin; @safe int VersionOfAPI() { return 1; } this is builds to plugin.so in main.d I'm loading the plugin and bind the those functions like so: module app; @safe: alias apiverfn = int function(); apiverfn apiVersion;