There was a real problem:
Apparently the serializer does two passes: recursive Restore on all the objects and recursive RestoreHandles on all the handles.
Pointers passed to CSerializedValue::Restore must be valid until the RestoreHandles pass.
The scriptarray class allocates once and then restores things in place, so all its pointers to its stored objects will be legit.
Some AATC container's contents cannot be restored in place, for example with associative containers, where the state of the object decides its place in the container. Those container classes require that their contents are restored first, then added to the container once their state is ready for sorting or hashing.
In the previous code I was trying to restore them by passing pointers on the stack to CSerializedValue::Restore and adding them to the container during the restore callbacks, but using that approach the pointers to the restored objects were no longer valid during the RestoreHandles pass.
I solved this problem by restoring all the objects to an array during the restore callbacks, then adding the contents of that array to the actual container in a new pass, after the big call to Serializer::Restore. This approach might cause some problems if the state of the container is important for other objects during the Restore pass, but a bunch of semi-complex tests are working fine.
The arrays that store objects between the passes are currently stored in a global variable, because the CSerializer class has no userdata pointers available for storing things like these.
I did get all the things working mostly perfectly in the end. New experimental branch available here: https://github.com/Sami-Vuorela/aatc/archive/experimental-serializer-support.zip
New readme: https://github.com/Sami-Vuorela/aatc/blob/experimental-serializer-support/EXPERIMENTAL_README.txt
Syntax:
CSerializer* my_serializer = new CSerializer();
aatc_serializer_register(engine, my_serializer);
my_serializer->Store(my_module);
//Do_Things_Requiring_Script_Serialization()
my_serializer->Restore(my_module);
aatc_serializer_cleanup(engine, my_serializer);
delete my_serializer;
You can disable all serializer code in the config if its causing you trouble or if you want faster compilation.
The testing environment for this was quite simple so some problems miiiight have gotten through.
Crazy things like this don't seem to work "vector<vector<SomeObject@>@>".
Do post here and tell me if this thing actually works with whatever you're using it with.