BCS wrote:
Reply to grauzone,
BCS wrote:
The demarshaller function is indexed via a string derived from the
original object. What would the marshaller function key on? The best
I can think of right now is the typeinfo and as of now, that's broken
under DLLs
DLLs are broken in general. There are many more problems associated
with them, and you won't be happy with them. I write all my code with
the assumption in mind, that TypeInfos/ClassInfos for the same type
always are the same instance.
On second pass, even putting DLLs aside, I can't count on typeinfo being
the same in both sides because I can't even count on them being in the
same process, exe or even under the same compiler, OS or CPU.
For that, you had to write the TypeInfo pointer into the serialized data
stream, which obviously is not going to work. Obviously, you need some
type identification, which is independent from the compiled program binary.
But in-memory, using TypeInfo/ClassInfo as unique identifier is no
problem. Except if you somehow got 2 or more D runtimes in your process.
That's only possible when using the broken DLL support. Use DDL instead.
Can you get the mangled name of an object instance at runtime via typeinfo?
Not that I know of. IMHO, ClassInfo.name() is good enough.
But if you don't like it, just keep using mangleof. You obviously have
compile time access to the serializeable type, e.g.:
char[][ClassInfo] TypeMangledNames;
template SerializeMixin() {
static this() {
TypeMangledNames[typeof(this).classinfo] = typeof(this).mangleof;
}
}