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).