Object.factory
Sean Kelly
sean at f4.ca
Wed Sep 26 07:40:33 PDT 2007
DanO wrote:
> 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??
Because that's the actual name of the class. The common declaration
format is just short-hand for:
template MyDict(T) {
class MyDict {}
}
Sean
More information about the Digitalmars-d
mailing list