Object.factory

DanO dsstruthers at nospamplease.yahoo.com
Tue Sep 25 22:42:14 PDT 2007


BCS Wrote:

> pickling?
> 
> MyTreeType BuildTree(char[] name)
> {
>    auto parseTree = parse(std.file.read(name));
> 
>    auto ret = cast(MyTreeType)Object.create(parseTree.type);
>    ret.Stuff(parseTree.data)
> 
>    return ret;
> }
> 
> 

Yes, pickling it is.  I call it serialization, but having just started learning Python, pickling works, too.  As I stated earlier, standard objects work just fine when using Object.factory() or ClassInfo.find().create().  It's template  classes that are the issue.  Either method returns null.  I think it has something to do with the ClassInfo.name for the templated class.

class MyDict(T) : ISerial
{
    T[char[]] dict;
    void load(InStream s);
    void save(OutStream s);
}

MyDict!(int).classinfo.name == "MyDict!(int).MyDict"; // Why the extra .MyDict appended to the end??

=DanO





More information about the Digitalmars-d mailing list