September 25, 2017
On Monday, 25 September 2017 at 13:45:05 UTC, Jean-Louis Leroy wrote:
> Thank you all for your input. I will file a bug report.

Just reopen the old one:
https://issues.dlang.org/show_bug.cgi?id=2484

--
  Biotronic
September 25, 2017
On Monday, 25 September 2017 at 13:57:55 UTC, Biotronic wrote:
> On Monday, 25 September 2017 at 13:45:05 UTC, Jean-Louis Leroy wrote:
>> Thank you all for your input. I will file a bug report.
>
> Just reopen the old one:
> https://issues.dlang.org/show_bug.cgi?id=2484
>
> --
>   Biotronic

Done, thanks.
September 25, 2017
On 2017-09-21 22:32, Jean-Louis Leroy wrote:
> It did not take long! Someone tried to create templatized open methods and it didn't work right of the box. I expected that, but in fact there may be a bit of hope. You cannot have virtual function templates in C++ or in D because the layout of the vtables have to be known at compile time - but openmethods creates its method tables at runtime so maybe it can be made to work.
> 
> I stumbled upon a problem very quickly: it seems that classes that come from class template instantiations are not registered in ModuleInfo - see below,
> 
> Ideas?

Not sure exactly what you need get access to. But you could try to inspect the symbol table at runtime, if what you need is available there.

Of course, that's a bit of a PITA, but you would not be dependent on any bugs getting fixed or new features/improvements implemented.

-- 
/Jacob Carlborg
September 25, 2017
On Monday, 25 September 2017 at 14:17:13 UTC, Jacob Carlborg wrote:
> Of course, that's a bit of a PITA, but you would not be dependent on any bugs getting fixed or new features/improvements implemented.

How do you do that?
September 25, 2017
On Monday, 25 September 2017 at 14:06:55 UTC, Jean-Louis Leroy wrote:
>
> Done, thanks.

You might add a link to this thread.
September 26, 2017
On Thursday, 21 September 2017 at 20:32:38 UTC, Jean-Louis Leroy wrote:
> It did not take long! Someone tried to create templatized open methods and it didn't work right of the box. I expected that, but in fact there may be a bit of hope. You cannot have virtual function templates in C++ or in D because the layout of the vtables have to be known at compile time - but openmethods creates its method tables at runtime so maybe it can be made to work.
>
> I stumbled upon a problem very quickly: it seems that classes that come from class template instantiations are not registered in ModuleInfo - see below,
>
> [...]
>
> Neither 'Bar!int' nor 'BarInt' appear in 'localClasses'.
>
> Ideas?

Yeah. You can setup a custom registry that maps names to their TypeInfo_Class.
I do something similar in iz (though the real point in iz is a GC-free factory but the principle of the registry would be the the same for you)

Example:

---
/+ dub.sdl:
   name "dub_script"
   dependency "iz" version="0.6.0"
+/
module dub_script;

import iz.memory, std.stdio;

class Foo(T){this(){writeln("fooDeInt");}}
TypeInfo_Class[string] registry; // you need that...

static this()
{
    registerFactoryClass!(Foo!int)(registry); // ...and that, maybe  with another name
}

void main()
{
    auto fooDeInt = iz.memory.factory(registry, "Foo!int");
    destruct(cast(Object) fooDeInt);
}
---

September 26, 2017
On 2017-09-25 16:24, Jean-Louis Leroy wrote:
> On Monday, 25 September 2017 at 14:17:13 UTC, Jacob Carlborg wrote:
>> Of course, that's a bit of a PITA, but you would not be dependent on any bugs getting fixed or new features/improvements implemented.
> 
> How do you do that?

On Posix you use "dlopen", passing in null as the filename to get a handle to the current executable. Then you iterate the sections until you find the symbol table. For macOS there's this reference for the Mach-O binary format [1]. For Mach-O files there's this helper function as well [3].

[1] https://web.archive.org/web/20090901205800/http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/MachORuntime/Reference/reference.html

[2] getsectbynamefromheader_64

-- 
/Jacob Carlborg
September 26, 2017
On Tuesday, 26 September 2017 at 15:59:01 UTC, Jacob Carlborg wrote:
> On 2017-09-25 16:24, Jean-Louis Leroy wrote:
>> On Monday, 25 September 2017 at 14:17:13 UTC, Jacob Carlborg wrote:
>>> Of course, that's a bit of a PITA, but you would not be dependent on any bugs getting fixed or new features/improvements implemented.
>> 
>> How do you do that?
>
> On Posix you use "dlopen", passing in null as the filename to get a handle to the current executable. Then you iterate the sections until you find the symbol table. For macOS there's this reference for the Mach-O binary format [1]. For Mach-O files there's this helper function as well [3].
>
> [1] https://web.archive.org/web/20090901205800/http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/MachORuntime/Reference/reference.html
>
> [2] getsectbynamefromheader_64

Ah, I suspected that. I don't want to go down that path, what of Windows? But thanks anyway...
September 26, 2017
On Tuesday, 26 September 2017 at 04:55:46 UTC, b4s1L3 wrote:
> On Thursday, 21 September 2017 at 20:32:38 UTC, Jean-Louis Leroy wrote:
>> [...]
>
> Yeah. You can setup a custom registry that maps names to their TypeInfo_Class.
> I do something similar in iz (though the real point in iz is a GC-free factory but the principle of the registry would be the the same for you)
>
> Example:
>
> ---
> /+ dub.sdl:
>    name "dub_script"
>    dependency "iz" version="0.6.0"
> +/
> module dub_script;
>
> import iz.memory, std.stdio;
>
> class Foo(T){this(){writeln("fooDeInt");}}
> TypeInfo_Class[string] registry; // you need that...
>
> static this()
> {
>     registerFactoryClass!(Foo!int)(registry); // ...and that, maybe  with another name
> }
>
> void main()
> {
>     auto fooDeInt = iz.memory.factory(registry, "Foo!int");
>     destruct(cast(Object) fooDeInt);
> }
> ---

Yeah that's what I implemented yesterday (not pushed yet).

I have a prototype of a solution for using open methods and templates together - although the syntax is not light: it requires guidance from the user (a la C++ explicit template instantiation).
September 27, 2017
On 2017-09-26 18:08, Jean-Louis Leroy wrote:

> Ah, I suspected that. I don't want to go down that path, what of Windows? But thanks anyway...

It's possible to do the same on Windows (using LoadLibrary instead of dlopen). You would need to have separate code for each binary format. On Windows there are two, OMF used by DigitalMars and COFF used by Microsoft. DMD can output both. Linux and FreeBSD use ELF.

-- 
/Jacob Carlborg
1 2
Next ›   Last »