Skip to main content

Posts

Showing posts from April, 2011

Polymorphic C# and Java Using SWIG

By default SWIG generates C# and Java code that does not support downcast for polymorphic return types.  I found a straightforward way to solve this, provided your C++ code has a way to identify the concrete class of the C++ instances that are returned .  That is, this technique will work only if the C++ API you are wrapping with SWIG has something similar to C# object.GetType() or Java Object.getClass() .