support C/C++ cases, using __cplusplus
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6345 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
11a45c751d
commit
1db15cece4
1 changed files with 28 additions and 0 deletions
|
|
@ -5,16 +5,44 @@
|
|||
int test() { return 0; }
|
||||
int test(int x) { x = 0; return 1; }
|
||||
int test(char *s) { s = 0; return 2; }
|
||||
#ifdef __cplusplus
|
||||
int test(double x, double y = 0) { x = 0; y = 0; return 3; }
|
||||
#else
|
||||
int test(double x, double y) { x = 0; y = 0; return 3; }
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
%inline %{
|
||||
struct Foo {
|
||||
#ifdef __cplusplus
|
||||
int test() { return -1; }
|
||||
#endif
|
||||
};
|
||||
%}
|
||||
|
||||
|
||||
%extend Bar {
|
||||
#ifdef __cplusplus
|
||||
Bar() {
|
||||
return new Bar();
|
||||
}
|
||||
~Bar() {
|
||||
if (self) delete self;
|
||||
}
|
||||
#else
|
||||
Bar() {
|
||||
return (Bar *) malloc(sizeof(Bar));
|
||||
}
|
||||
~Bar() {
|
||||
if (self) free(self);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
%inline %{
|
||||
typedef struct {
|
||||
} Bar;
|
||||
%}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue