Object.factory
Max Samukha
samukha at voliacable.com.removethis
Tue Sep 25 23:22:00 PDT 2007
On Wed, 26 Sep 2007 01:42:30 -0400, DanO
<dsstruthers at nospamplease.yahoo.com> 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??
>
>=DanO
>
I guess the reason for the naming is that
class MyDict(T)
{
}
is a shorthand for
template MyDict(T)
{
class MyDict
{
}
}
More information about the Digitalmars-d
mailing list