On 11/16/18 9:51 AM, Aditya wrote:
On Friday, 16 November 2018 at 14:28:22 UTC, Adam D. Ruppe wrote:
On Friday, 16 November 2018 at 14:24:10 UTC, Aditya wrote:
./ss/Stat.d  (defines interface named 'Stat')
./ss/Min.d   (defines class named 'Min' that implements Stat)

Did you put a module declaration at the top of those files? Like

module ss.Stat;


That ought to be required; the compiler lets you skip it, but it doesn't work reliably without it once you start importing the module or other similar things.



But once you have that, the name of your class will be the full name with module, so like if min has

module ss.Min;

class Min {}


the full class name will be

ss.Min.Min

the full module name dot the full class name.

Module Names were not added. But after adding the same, still same result.

// Following still doesn't work
ss.Min.Min
ss.ss.Min
ss.ss.Min.Min
stats.ss.Min.Min
stats.Min

So to let you know, Object.factory is not a maintained function. The ability to instantiate classes based on the ModuleInfo was overruled by the fact that we don't want to generate ModuleInfo if we don't have to, and it should be as small as possible. Therefore, you need some triggers to make sure the module info is included, and even then, I think, it's not guaranteed to include the classinfo in that moduleinfo.

The better path is to use a registration system to add the desired classes for reflection. Not a trivial thing, but that's probably the path you want. I'd suggest looking at serialization libraries like orange (http://code.dlang.org/packages/orange) or cereald (http://code.dlang.org/packages/cerealed) for ideas, or maybe just use one of them.

-Steve

Reply via email to