jaeandersson / swig

SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages.
http://www.swig.org
Other
23 stars 19 forks source link

Explicitly print a warning about missing support for save/load #59

Open traversaro opened 9 years ago

traversaro commented 9 years ago

I got some feedback from confused users of my SWIG-wrapped library that saved (with "save") and loaded back (with "load") their workspace containing SWIG Classes.

Clearly the "save" and "load" are not supported out-of-the-box by the SWIG Classes. The main source of confusion is that the class are saved and loaded without any warning, and then they fail with an error message when the user interacts with the loaded classes.

To have a clearer error message, I tried to implement a saveobj method in SwigRef that just print a warning as soon as the user try to save a SWIG class, but I don't know if it could make sense to have this in the SwigRef.m generated by SWIG.

jaeandersson commented 9 years ago

Good point. It makes sense to implement this method only to ensure that an error is being thrown.

traversaro commented 6 years ago

Fixed by https://github.com/jaeandersson/swig/commit/76e657b8630ba800a3b9ee19d62b5839b7415447 ?

jaeandersson commented 6 years ago

@jgillis ?

KrisThielemans commented 2 years ago

we currently have this https://github.com/KrisThielemans/swig/blob/cecdea3f44837ce95bdf1fef809312f2e786c08b/Source/Modules/matlab.cxx#L2748-L2751 This gives however

warning: Serializing SWIG objects not supported.
warning: called from
    saveobj at line 16 column 7

error: saveobj: not defined for class "char"
error: called from
    saveobj at line 51 column 3
    saveobj at line 17 column 11

which isn't great either. I think better to call error directly