mirror of https://github.com/swig/swig
make %callback more uniform and usable
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6435 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
76f0a08ebf
commit
c7982bbdc8
|
@ -8,11 +8,11 @@
|
|||
extern int do_op(int a, int b, int (*op)(int, int));
|
||||
|
||||
/* Now install a bunch of "ops" as constants */
|
||||
%callback("%(upper)s")
|
||||
%callback("%(upper)s");
|
||||
int add(int, int);
|
||||
int sub(int, int);
|
||||
int mul(int, int);
|
||||
%nocallback
|
||||
%nocallback;
|
||||
|
||||
extern int (*funcvar)(int,int);
|
||||
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
extern int do_op(int a, int b, int (*op)(int, int));
|
||||
|
||||
/* Now install a bunch of "ops" as constants */
|
||||
%callback("%(upper)s")
|
||||
%callback("%(upper)s");
|
||||
int add(int, int);
|
||||
int sub(int, int);
|
||||
int mul(int, int);
|
||||
%nocallback
|
||||
%nocallback;
|
||||
|
||||
extern int (*funcvar)(int,int);
|
||||
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
%module callback
|
||||
|
||||
%pythoncallback(1);
|
||||
%pythoncallback(1) foo;
|
||||
%pythoncallback(1) A::bar;
|
||||
%pythoncallback(1) A::foom;
|
||||
%pythoncallback(1) foo_T;
|
||||
%callback(1) foo;
|
||||
%callback(1) foof;
|
||||
%callback(1) A::bar;
|
||||
%callback(1) A::foom;
|
||||
%callback("%s_Cb_Ptr") foo_T; // old style, still works.
|
||||
|
||||
%inline %{
|
||||
|
||||
|
||||
int foo(int a) {
|
||||
return a;
|
||||
}
|
||||
|
|
|
@ -108,6 +108,17 @@ These methods "may be called" if needed.
|
|||
|
||||
*/
|
||||
|
||||
%define %pythoncallback(FLAG) %feature("python:callback",#FLAG) %enddef
|
||||
%define %nopythoncallback %feature("python:callback","") %enddef
|
||||
#define %pythoncallback(x) %feature("python:callback",`x`)
|
||||
#define %nopythoncallback %feature("python:callback","")
|
||||
|
||||
/* Support for the old %callback directive name */
|
||||
#ifdef %callback
|
||||
#undef %callback
|
||||
#endif
|
||||
#define %callback(x) %pythoncallback(x)
|
||||
|
||||
#ifdef %nocallback
|
||||
#undef %nocallback
|
||||
#endif
|
||||
#define %nocallback %nopythoncallback; %feature("callback","")
|
||||
|
||||
|
|
|
@ -44,8 +44,8 @@
|
|||
|
||||
/* Experimental */
|
||||
|
||||
#define %callback(x) %feature("callback") `x`;
|
||||
#define %nocallback %feature("callback","");
|
||||
#define %callback(x) %feature("callback",`x`)
|
||||
#define %nocallback %feature("callback","")
|
||||
|
||||
/* Directives for attribute functions */
|
||||
|
||||
|
|
|
@ -502,8 +502,17 @@ public:
|
|||
|
||||
|
||||
int functionHandler(Node *n) {
|
||||
if (Getattr(n,"feature:python:callback")) {
|
||||
Setattr(n,"feature:callback","%s_cb_ptr");
|
||||
String *pcb = Getattr(n,"feature:python:callback");
|
||||
if (pcb && (Strcmp(pcb,"0") == 0)) {
|
||||
Setattr(n,"feature:python:callback","");
|
||||
pcb = 0;
|
||||
}
|
||||
if (pcb) {
|
||||
if (Strcmp(pcb,"1") == 0) {
|
||||
Setattr(n,"feature:callback","%s_cb_ptr");
|
||||
} else {
|
||||
Setattr(n,"feature:callback",pcb);
|
||||
}
|
||||
autodoc_l dlevel = autodoc_level(Getattr(n, "feature:autodoc"));
|
||||
if (dlevel != NO_AUTODOC && dlevel > TYPES_AUTODOC) {
|
||||
Setattr(n,"feature:autodoc","1");
|
||||
|
|
Loading…
Reference in New Issue