How can I get Swig generate Python code as a class instead of free functions?
%module SimulatorAppWrapper
%{
#define SWIG_FILE_WITH_INIT
#include "SimulatorAppWrapper.hpp"
%}
%include "SimulatorAppWrapper.hpp"
My wrapper source is fairly trivial:
class SimulatorAppWrapper
{
public:
typedef std::map<const char*, const char*> ConfigSettings;
SimulatorAppWrapper();
~SimulatorAppWrapper();
void AddConfigKey(const char* k, const char* v);
int Run();
};
From here I generate Swig source and link against it using: swig -python -c++ SimulatorAppWrapper.i
However I check the build module I get the following where I have free functions instead of something like a class:
>>> import SimulatorAppWrapper
>>> dir(_SimulatorAppWrapper)
['SWIG_PyInstanceMethod_New', 'SimulatorAppWrapper_AddConfigKey', 'SimulatorAppWrapper_Run', 'SimulatorAppWrapper_swigregister', '__doc__', '__file__', '__name__', '__package__', 'delete_SimulatorAppWrapper', 'new_SimulatorAppWrapper']
I would like to be able to do something like the following:
simApp = SimulatorAppWrapper
simApp.Run()