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)
|
||||
%{
|
||||
static TYPE *new_##NAME(int nelements) { %}
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
%{ return new TYPE[nelements]; %}
|
||||
#else
|
||||
%{ return (TYPE *) calloc(nelements,sizeof(TYPE)); %}
|
||||
|
|
@ -33,7 +33,7 @@ static TYPE *new_##NAME(int nelements) { %}
|
|||
%{}
|
||||
|
||||
static void delete_##NAME(TYPE *ary) { %}
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
%{ delete [] ary; %}
|
||||
#else
|
||||
%{ free(ary); %}
|
||||
|
|
@ -88,7 +88,7 @@ typedef struct NAME {
|
|||
|
||||
%extend NAME {
|
||||
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
NAME(int nelements) {
|
||||
return new TYPE[nelements];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ typedef struct {
|
|||
} NAME;
|
||||
|
||||
%extend NAME {
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
NAME() {
|
||||
return new TYPE();
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ static NAME * frompointer(TYPE *t) {
|
|||
%define %pointer_functions(TYPE,NAME)
|
||||
%{
|
||||
static TYPE *new_##NAME() { %}
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
%{ return new TYPE(); %}
|
||||
#else
|
||||
%{ return (TYPE *) calloc(1,sizeof(TYPE)); %}
|
||||
|
|
@ -127,7 +127,7 @@ static TYPE *new_##NAME() { %}
|
|||
%{}
|
||||
|
||||
static TYPE *copy_##NAME(TYPE value) { %}
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
%{ return new TYPE(value); %}
|
||||
#else
|
||||
%{ TYPE *self = (TYPE *) calloc(1,sizeof(TYPE));
|
||||
|
|
@ -137,7 +137,7 @@ static TYPE *copy_##NAME(TYPE value) { %}
|
|||
%{}
|
||||
|
||||
static void delete_##NAME(TYPE *self) { %}
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
%{ if (self) delete self; %}
|
||||
#else
|
||||
%{ 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);
|
||||
if (!*jarr)
|
||||
return 0; %}
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
%{ *carr = new CTYPE[sz]; %}
|
||||
#else
|
||||
%{ *carr = (CTYPE*) calloc(sz, sizeof(CTYPE)); %}
|
||||
|
|
@ -230,7 +230,7 @@ JAVA_ARRAYS_IMPL(double, jdouble, Double, Double) /* double[] */
|
|||
%typemap(out) CTYPE[ANY]
|
||||
%{$result = SWIG_JavaArrayOut##JFUNCNAME(jenv, $1, $1_dim0); %}
|
||||
%typemap(freearg) CTYPE[ANY]
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
%{ delete [] $1; %}
|
||||
#else
|
||||
%{ free($1); %}
|
||||
|
|
@ -351,7 +351,7 @@ JAVA_ARRAYS_TYPEMAPS(double, jdouble, Double, "[D") /* double[ANY] */
|
|||
if (!jarr) {
|
||||
return $null;
|
||||
}
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
$1 = new $*1_ltype[sz];
|
||||
#else
|
||||
$1 = ($1_ltype) calloc(sz, sizeof($*1_ltype));
|
||||
|
|
@ -381,7 +381,7 @@ JAVA_ARRAYS_TYPEMAPS(double, jdouble, Double, "[D") /* double[ANY] */
|
|||
if (!jarr) {
|
||||
return $null;
|
||||
}
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
$1 = new $*1_ltype[sz];
|
||||
#else
|
||||
$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]
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
%{ delete [] $1; %}
|
||||
#else
|
||||
%{ free($1); %}
|
||||
|
|
|
|||
|
|
@ -117,13 +117,13 @@
|
|||
int n = string_length($input);
|
||||
$1 = ($1_ltype) t;
|
||||
#if #__VA_ARGS__ == ""
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
$1 = ($1_ltype) new char[n+1];
|
||||
#else
|
||||
$1 = ($1_ltype) malloc(n+1);
|
||||
#endif
|
||||
#else
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
$1 = ($1_ltype) new char[n+1+__VA_ARGS__];
|
||||
#else
|
||||
$1 = ($1_ltype) malloc(n+1+__VA_ARGS__);
|
||||
|
|
@ -135,7 +135,7 @@
|
|||
|
||||
%typemap(argout) TYPEMAP {
|
||||
$result = caml_list_append($result,caml_val_string($1));
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
delete[] $1;
|
||||
#else
|
||||
free($1);
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ strarray_inout(char [ANY])
|
|||
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 */
|
||||
if ((*$input)->type==IS_NULL && PZVAL_IS_REF(*$input)) {
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
ptr=new $*1_ltype;
|
||||
#else
|
||||
ptr=($*1_ltype) calloc(1,sizeof($*1_ltype));
|
||||
|
|
|
|||
|
|
@ -124,13 +124,13 @@
|
|||
if (SWIG_arg_fail($argnum)) SWIG_fail;
|
||||
$1 = ($1_ltype) t;
|
||||
#if #__VA_ARGS__ == ""
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
$1 = ($1_ltype) new char[n+1];
|
||||
#else
|
||||
$1 = ($1_ltype) malloc(n+1);
|
||||
#endif
|
||||
#else
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
$1 = ($1_ltype) new char[n+1+__VA_ARGS__];
|
||||
#else
|
||||
$1 = ($1_ltype) malloc(n+1+__VA_ARGS__);
|
||||
|
|
@ -144,7 +144,7 @@
|
|||
PyObject *o;
|
||||
o = PyString_FromString($1);
|
||||
$result = t_output_helper($result,o);
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
delete[] $1;
|
||||
#else
|
||||
free($1);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
/* include C++ or C value */
|
||||
%define SWIG_cplusplus(cppval, cval)
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
cppval
|
||||
#else
|
||||
cval
|
||||
|
|
|
|||
|
|
@ -121,13 +121,13 @@
|
|||
$1 = ($1_ltype) t;
|
||||
|
||||
#if #__VA_ARGS__ == ""
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
$1 = ($1_ltype) new char[n+1];
|
||||
#else
|
||||
$1 = ($1_ltype) malloc(n+1);
|
||||
#endif
|
||||
#else
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
$1 = ($1_ltype) new char[n+1+__VA_ARGS__];
|
||||
#else
|
||||
$1 = ($1_ltype) malloc(n+1+__VA_ARGS__);
|
||||
|
|
@ -141,7 +141,7 @@
|
|||
Tcl_Obj *o;
|
||||
o = Tcl_NewStringObj($1,-1);
|
||||
Tcl_ListObjAppendElement(interp, Tcl_GetObjResult(interp), o);
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
delete[] $1;
|
||||
#else
|
||||
free($1);
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ void SWIG_getoptions(int argc, char *argv[])
|
|||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i],"-c++") == 0) {
|
||||
CPlusPlus=1;
|
||||
Preprocessor_define((DOH *) "__cplusplus", 0);
|
||||
Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0);
|
||||
Swig_cparse_cplusplus(1);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i],"-fcompact") == 0) {
|
||||
|
|
@ -574,7 +574,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
|
||||
// Define the __cplusplus symbol
|
||||
if (CPlusPlus)
|
||||
Preprocessor_define((DOH *) "__cplusplus", 0);
|
||||
Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0);
|
||||
|
||||
// Parse language dependent options
|
||||
lang->main(argc,argv);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue