/* -----------------------------------------------------------------------------
* Special user directives
* ----------------------------------------------------------------------------- */
#define %shadow %insert("shadow")
#define %pythoncode %insert("python")
Use the "nondynamic" feature to make a wrapped class behaves as a "nondynamic"
one, ie, a python class that doesn't dynamically add new attributes.
For example, for the class
Since nondynamic is a feature, if you use it like
it will make all the wrapped classes nondynamic ones.
The implementation is based on the recipe:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252158
and works for modern (-modern) and plain python. We don not use __slots__,
so, it works with old python versions.
#define %pythonnondynamic %feature("python:nondynamic", "1")
#define %nopythonnondynamic %feature("python:nondynamic", "0")
#define %clearpythonnondynamic %feature("python:nondynamic", "")
#define %pythondynamic %nopythonnondynamic
Use %pythonmaybecall to flag a method like __add__ or __radd__, which
don't produce an error when called, they just return NotImplemented.
These methods "may be called" if needed.
#define %pythonmaybecall %feature("python:maybecall", "1")
#define %nopythonmaybecall %feature("python:maybecall", "0")
#define %clearpythonmaybecall %feature("python:maybecall", "")
The %pythoncallback feature produce a more natural callback wrap
than the %callback mechanism, ie, it use the original name for
the callback and callable objects.
%pythoncallback(1) A::foo;
int bar(int, int (*pf)(int));
If you use it with a member method
%pythoncallback(1) A::foom;
r = a.foom(3) # eval the method
mptr = A.foom_cb_ptr # returns the callback pointer
where the '_cb_ptr' termination is added for the callback pointer.
#define %pythoncallback %feature("python:callback")
#define %nopythoncallback %feature("python:callback","0")
#define %clearpythoncallback %feature("python:callback","")
/* Support for the old %callback directive name */
#define %callback(x) %feature("python:callback",`x`)
#define %nocallback %nopythoncallback
#define %clearcallback %clearpythoncallback