fix #if __cplusplus problem
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6347 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
41851255fc
commit
c1ed709013
9 changed files with 25 additions and 25 deletions
|
|
@ -25,7 +25,7 @@
|
||||||
%define %array_functions(TYPE,NAME)
|
%define %array_functions(TYPE,NAME)
|
||||||
%{
|
%{
|
||||||
static TYPE *new_##NAME(int nelements) { %}
|
static TYPE *new_##NAME(int nelements) { %}
|
||||||
#if __cplusplus
|
#ifdef __cplusplus
|
||||||
%{ return new TYPE[nelements]; %}
|
%{ return new TYPE[nelements]; %}
|
||||||
#else
|
#else
|
||||||
%{ return (TYPE *) calloc(nelements,sizeof(TYPE)); %}
|
%{ return (TYPE *) calloc(nelements,sizeof(TYPE)); %}
|
||||||
|
|
@ -33,7 +33,7 @@ static TYPE *new_##NAME(int nelements) { %}
|
||||||
%{}
|
%{}
|
||||||
|
|
||||||
static void delete_##NAME(TYPE *ary) { %}
|
static void delete_##NAME(TYPE *ary) { %}
|
||||||
#if __cplusplus
|
#ifdef __cplusplus
|
||||||
%{ delete [] ary; %}
|
%{ delete [] ary; %}
|
||||||
#else
|
#else
|
||||||
%{ free(ary); %}
|
%{ free(ary); %}
|
||||||
|
|
@ -88,7 +88,7 @@ typedef struct NAME {
|
||||||
|
|
||||||
%extend NAME {
|
%extend NAME {
|
||||||
|
|
||||||
#if __cplusplus
|
#ifdef __cplusplus
|
||||||
NAME(int nelements) {
|
NAME(int nelements) {
|
||||||
return new TYPE[nelements];
|
return new TYPE[nelements];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ typedef struct {
|
||||||
} NAME;
|
} NAME;
|
||||||
|
|
||||||
%extend NAME {
|
%extend NAME {
|
||||||
#if __cplusplus
|
#ifdef __cplusplus
|
||||||
NAME() {
|
NAME() {
|
||||||
return new TYPE();
|
return new TYPE();
|
||||||
}
|
}
|
||||||
|
|
@ -119,7 +119,7 @@ static NAME * frompointer(TYPE *t) {
|
||||||
%define %pointer_functions(TYPE,NAME)
|
%define %pointer_functions(TYPE,NAME)
|
||||||
%{
|
%{
|
||||||
static TYPE *new_##NAME() { %}
|
static TYPE *new_##NAME() { %}
|
||||||
#if __cplusplus
|
#ifdef __cplusplus
|
||||||
%{ return new TYPE(); %}
|
%{ return new TYPE(); %}
|
||||||
#else
|
#else
|
||||||
%{ return (TYPE *) calloc(1,sizeof(TYPE)); %}
|
%{ return (TYPE *) calloc(1,sizeof(TYPE)); %}
|
||||||
|
|
@ -127,7 +127,7 @@ static TYPE *new_##NAME() { %}
|
||||||
%{}
|
%{}
|
||||||
|
|
||||||
static TYPE *copy_##NAME(TYPE value) { %}
|
static TYPE *copy_##NAME(TYPE value) { %}
|
||||||
#if __cplusplus
|
#ifdef __cplusplus
|
||||||
%{ return new TYPE(value); %}
|
%{ return new TYPE(value); %}
|
||||||
#else
|
#else
|
||||||
%{ TYPE *self = (TYPE *) calloc(1,sizeof(TYPE));
|
%{ TYPE *self = (TYPE *) calloc(1,sizeof(TYPE));
|
||||||
|
|
@ -137,7 +137,7 @@ static TYPE *copy_##NAME(TYPE value) { %}
|
||||||
%{}
|
%{}
|
||||||
|
|
||||||
static void delete_##NAME(TYPE *self) { %}
|
static void delete_##NAME(TYPE *self) { %}
|
||||||
#if __cplusplus
|
#ifdef __cplusplus
|
||||||
%{ if (self) delete self; %}
|
%{ if (self) delete self; %}
|
||||||
#else
|
#else
|
||||||
%{ if (self) free(self); %}
|
%{ if (self) free(self); %}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ int SWIG_JavaArrayIn##JFUNCNAME (JNIEnv *jenv, JNITYPE **jarr, CTYPE **carr, JNI
|
||||||
*jarr = JCALL2(Get##JAVATYPE##ArrayElements, jenv, input, 0);
|
*jarr = JCALL2(Get##JAVATYPE##ArrayElements, jenv, input, 0);
|
||||||
if (!*jarr)
|
if (!*jarr)
|
||||||
return 0; %}
|
return 0; %}
|
||||||
#if __cplusplus
|
#ifdef __cplusplus
|
||||||
%{ *carr = new CTYPE[sz]; %}
|
%{ *carr = new CTYPE[sz]; %}
|
||||||
#else
|
#else
|
||||||
%{ *carr = (CTYPE*) calloc(sz, sizeof(CTYPE)); %}
|
%{ *carr = (CTYPE*) calloc(sz, sizeof(CTYPE)); %}
|
||||||
|
|
@ -230,7 +230,7 @@ JAVA_ARRAYS_IMPL(double, jdouble, Double, Double) /* double[] */
|
||||||
%typemap(out) CTYPE[ANY]
|
%typemap(out) CTYPE[ANY]
|
||||||
%{$result = SWIG_JavaArrayOut##JFUNCNAME(jenv, $1, $1_dim0); %}
|
%{$result = SWIG_JavaArrayOut##JFUNCNAME(jenv, $1, $1_dim0); %}
|
||||||
%typemap(freearg) CTYPE[ANY]
|
%typemap(freearg) CTYPE[ANY]
|
||||||
#if __cplusplus
|
#ifdef __cplusplus
|
||||||
%{ delete [] $1; %}
|
%{ delete [] $1; %}
|
||||||
#else
|
#else
|
||||||
%{ free($1); %}
|
%{ free($1); %}
|
||||||
|
|
@ -351,7 +351,7 @@ JAVA_ARRAYS_TYPEMAPS(double, jdouble, Double, "[D") /* double[ANY] */
|
||||||
if (!jarr) {
|
if (!jarr) {
|
||||||
return $null;
|
return $null;
|
||||||
}
|
}
|
||||||
#if __cplusplus
|
#ifdef __cplusplus
|
||||||
$1 = new $*1_ltype[sz];
|
$1 = new $*1_ltype[sz];
|
||||||
#else
|
#else
|
||||||
$1 = ($1_ltype) calloc(sz, sizeof($*1_ltype));
|
$1 = ($1_ltype) calloc(sz, sizeof($*1_ltype));
|
||||||
|
|
@ -381,7 +381,7 @@ JAVA_ARRAYS_TYPEMAPS(double, jdouble, Double, "[D") /* double[ANY] */
|
||||||
if (!jarr) {
|
if (!jarr) {
|
||||||
return $null;
|
return $null;
|
||||||
}
|
}
|
||||||
#if __cplusplus
|
#ifdef __cplusplus
|
||||||
$1 = new $*1_ltype[sz];
|
$1 = new $*1_ltype[sz];
|
||||||
#else
|
#else
|
||||||
$1 = ($1_ltype) calloc(sz, sizeof($*1_ltype));
|
$1 = ($1_ltype) calloc(sz, sizeof($*1_ltype));
|
||||||
|
|
@ -425,7 +425,7 @@ JAVA_ARRAYS_TYPEMAPS(double, jdouble, Double, "[D") /* double[ANY] */
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(freearg) ARRAYSOFCLASSES[ANY]
|
%typemap(freearg) ARRAYSOFCLASSES[ANY]
|
||||||
#if __cplusplus
|
#ifdef __cplusplus
|
||||||
%{ delete [] $1; %}
|
%{ delete [] $1; %}
|
||||||
#else
|
#else
|
||||||
%{ free($1); %}
|
%{ free($1); %}
|
||||||
|
|
|
||||||
|
|
@ -117,13 +117,13 @@
|
||||||
int n = string_length($input);
|
int n = string_length($input);
|
||||||
$1 = ($1_ltype) t;
|
$1 = ($1_ltype) t;
|
||||||
#if #__VA_ARGS__ == ""
|
#if #__VA_ARGS__ == ""
|
||||||
#if __cplusplus
|
#ifdef __cplusplus
|
||||||
$1 = ($1_ltype) new char[n+1];
|
$1 = ($1_ltype) new char[n+1];
|
||||||
#else
|
#else
|
||||||
$1 = ($1_ltype) malloc(n+1);
|
$1 = ($1_ltype) malloc(n+1);
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#if __cplusplus
|
#ifdef __cplusplus
|
||||||
$1 = ($1_ltype) new char[n+1+__VA_ARGS__];
|
$1 = ($1_ltype) new char[n+1+__VA_ARGS__];
|
||||||
#else
|
#else
|
||||||
$1 = ($1_ltype) malloc(n+1+__VA_ARGS__);
|
$1 = ($1_ltype) malloc(n+1+__VA_ARGS__);
|
||||||
|
|
@ -135,7 +135,7 @@
|
||||||
|
|
||||||
%typemap(argout) TYPEMAP {
|
%typemap(argout) TYPEMAP {
|
||||||
$result = caml_list_append($result,caml_val_string($1));
|
$result = caml_list_append($result,caml_val_string($1));
|
||||||
#if __cplusplus
|
#ifdef __cplusplus
|
||||||
delete[] $1;
|
delete[] $1;
|
||||||
#else
|
#else
|
||||||
free($1);
|
free($1);
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ strarray_inout(char [ANY])
|
||||||
if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor) < 0) {
|
if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor) < 0) {
|
||||||
/* So... we didn't get a ref or ptr, but we'll accept NULL by reference */
|
/* So... we didn't get a ref or ptr, but we'll accept NULL by reference */
|
||||||
if ((*$input)->type==IS_NULL && PZVAL_IS_REF(*$input)) {
|
if ((*$input)->type==IS_NULL && PZVAL_IS_REF(*$input)) {
|
||||||
#if __cplusplus
|
#ifdef __cplusplus
|
||||||
ptr=new $*1_ltype;
|
ptr=new $*1_ltype;
|
||||||
#else
|
#else
|
||||||
ptr=($*1_ltype) calloc(1,sizeof($*1_ltype));
|
ptr=($*1_ltype) calloc(1,sizeof($*1_ltype));
|
||||||
|
|
|
||||||
|
|
@ -124,13 +124,13 @@
|
||||||
if (SWIG_arg_fail($argnum)) SWIG_fail;
|
if (SWIG_arg_fail($argnum)) SWIG_fail;
|
||||||
$1 = ($1_ltype) t;
|
$1 = ($1_ltype) t;
|
||||||
#if #__VA_ARGS__ == ""
|
#if #__VA_ARGS__ == ""
|
||||||
#if __cplusplus
|
#ifdef __cplusplus
|
||||||
$1 = ($1_ltype) new char[n+1];
|
$1 = ($1_ltype) new char[n+1];
|
||||||
#else
|
#else
|
||||||
$1 = ($1_ltype) malloc(n+1);
|
$1 = ($1_ltype) malloc(n+1);
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#if __cplusplus
|
#ifdef __cplusplus
|
||||||
$1 = ($1_ltype) new char[n+1+__VA_ARGS__];
|
$1 = ($1_ltype) new char[n+1+__VA_ARGS__];
|
||||||
#else
|
#else
|
||||||
$1 = ($1_ltype) malloc(n+1+__VA_ARGS__);
|
$1 = ($1_ltype) malloc(n+1+__VA_ARGS__);
|
||||||
|
|
@ -144,7 +144,7 @@
|
||||||
PyObject *o;
|
PyObject *o;
|
||||||
o = PyString_FromString($1);
|
o = PyString_FromString($1);
|
||||||
$result = t_output_helper($result,o);
|
$result = t_output_helper($result,o);
|
||||||
#if __cplusplus
|
#ifdef __cplusplus
|
||||||
delete[] $1;
|
delete[] $1;
|
||||||
#else
|
#else
|
||||||
free($1);
|
free($1);
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
/* include C++ or C value */
|
/* include C++ or C value */
|
||||||
%define SWIG_cplusplus(cppval, cval)
|
%define SWIG_cplusplus(cppval, cval)
|
||||||
#if __cplusplus
|
#ifdef __cplusplus
|
||||||
cppval
|
cppval
|
||||||
#else
|
#else
|
||||||
cval
|
cval
|
||||||
|
|
|
||||||
|
|
@ -121,13 +121,13 @@
|
||||||
$1 = ($1_ltype) t;
|
$1 = ($1_ltype) t;
|
||||||
|
|
||||||
#if #__VA_ARGS__ == ""
|
#if #__VA_ARGS__ == ""
|
||||||
#if __cplusplus
|
#ifdef __cplusplus
|
||||||
$1 = ($1_ltype) new char[n+1];
|
$1 = ($1_ltype) new char[n+1];
|
||||||
#else
|
#else
|
||||||
$1 = ($1_ltype) malloc(n+1);
|
$1 = ($1_ltype) malloc(n+1);
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#if __cplusplus
|
#ifdef __cplusplus
|
||||||
$1 = ($1_ltype) new char[n+1+__VA_ARGS__];
|
$1 = ($1_ltype) new char[n+1+__VA_ARGS__];
|
||||||
#else
|
#else
|
||||||
$1 = ($1_ltype) malloc(n+1+__VA_ARGS__);
|
$1 = ($1_ltype) malloc(n+1+__VA_ARGS__);
|
||||||
|
|
@ -141,7 +141,7 @@
|
||||||
Tcl_Obj *o;
|
Tcl_Obj *o;
|
||||||
o = Tcl_NewStringObj($1,-1);
|
o = Tcl_NewStringObj($1,-1);
|
||||||
Tcl_ListObjAppendElement(interp, Tcl_GetObjResult(interp), o);
|
Tcl_ListObjAppendElement(interp, Tcl_GetObjResult(interp), o);
|
||||||
#if __cplusplus
|
#ifdef __cplusplus
|
||||||
delete[] $1;
|
delete[] $1;
|
||||||
#else
|
#else
|
||||||
free($1);
|
free($1);
|
||||||
|
|
|
||||||
|
|
@ -289,7 +289,7 @@ void SWIG_getoptions(int argc, char *argv[])
|
||||||
Swig_mark_arg(i);
|
Swig_mark_arg(i);
|
||||||
} else if (strcmp(argv[i],"-c++") == 0) {
|
} else if (strcmp(argv[i],"-c++") == 0) {
|
||||||
CPlusPlus=1;
|
CPlusPlus=1;
|
||||||
Preprocessor_define((DOH *) "__cplusplus", 0);
|
Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0);
|
||||||
Swig_cparse_cplusplus(1);
|
Swig_cparse_cplusplus(1);
|
||||||
Swig_mark_arg(i);
|
Swig_mark_arg(i);
|
||||||
} else if (strcmp(argv[i],"-fcompact") == 0) {
|
} else if (strcmp(argv[i],"-fcompact") == 0) {
|
||||||
|
|
@ -574,7 +574,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
||||||
|
|
||||||
// Define the __cplusplus symbol
|
// Define the __cplusplus symbol
|
||||||
if (CPlusPlus)
|
if (CPlusPlus)
|
||||||
Preprocessor_define((DOH *) "__cplusplus", 0);
|
Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0);
|
||||||
|
|
||||||
// Parse language dependent options
|
// Parse language dependent options
|
||||||
lang->main(argc,argv);
|
lang->main(argc,argv);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue