Skip to content Skip to sidebar Skip to footer

Add Hand-wrapped Method To Swig Output

I have a SWIG module where I want to add a hand-rolled method. %module frob %inline %{ int Foo(int x, int y) { return x+y; } PyObject* Bar(PyObject* self, PyObject* args

Solution 1:

To exclude a function from being wrapped, use the %native directive.

%module "test"

/* Prototype */    
%native(DontWrapMeBro)
PyObject* DontWrapMeBro(PyObject* self, PyObject* args);

%{
  PyObject* DontWrapMeBro(PyObject* self, PyObject* args)
  {
    return PyString_AsString("Don't wrap me");
  }
%}

Post a Comment for "Add Hand-wrapped Method To Swig Output"