Dag Sverre Seljebotn, 27.05.2010 10:08: > cdef persist_struct_to_xml(void* data, object typeinfo, object > filename): ... > > cdef StructA a > a.b = 2 > a.c = 4 > persist_struct_to_xml(&a, typeof(StructA), 'a.dat') > > cdef StructB b > b.foo = 2 > b.bar = 4.5 > persist_struct_to_xml(&b, typeof(StructB), 'b.dat') > > Basically, the type information for structs should be a tree, containing > names and *offsets* and types. persist_struct_to_xml needs to have > special-case if-tests on all the primitive types, but structs can be > dealt with through pointer manipulation and offsets. > > Offsets can trivially be resolved by the C compiler during C compilation > and put into the type information then (in fact, I already do in the > buffer RTTI, which is used for validating buffer data format strings). > > Of course, it's just a convenience, but if you need this, a very big one.
I think overriding type() for C types can still provide what you want, but that's a different feature. Stefan _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
