Rewrote all of the low-level C/C++ code generators. Continued destruction of old C++ code.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@601 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
ccbe7d8213
commit
91ff20631b
11 changed files with 530 additions and 1154 deletions
|
|
@ -15,11 +15,11 @@ RANLIB = @RANLIB@
|
|||
TARGET = libswig11.a
|
||||
|
||||
OBJS = parser.o main.o scanner.o \
|
||||
emit.o cplus.o lang.o sstring.o typemap.o
|
||||
emit.o cplus.o lang.o typemap.o
|
||||
|
||||
SRCS = main.cxx scanner.cxx \
|
||||
emit.cxx cplus.cxx lang.cxx \
|
||||
sstring.cxx typemap.cxx
|
||||
typemap.cxx
|
||||
|
||||
PARSER = $(srcdir)/parser.yxx
|
||||
INCLUDE = -I$(srcdir)/../Include \
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -19,97 +19,15 @@ extern "C" {
|
|||
|
||||
static char cvsroot[] = "$Header$";
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// emit_extern_var(char *decl, DataType *t, int extern_type, FILE *f)
|
||||
//
|
||||
// Emits an external variables declaration. Extern_type defines the
|
||||
// type of external declaration. Currently, only C/C++ declarations
|
||||
// are allowed, but this might be extended to allow Fortran linkage
|
||||
// someday
|
||||
//
|
||||
// Inputs :
|
||||
// decl = Name of the declaration
|
||||
// t = Datatype
|
||||
// extern_type = Numeric code indicating type of extern
|
||||
// 0 - No "extern"
|
||||
// 1,2 - Normal extern (C/C++)
|
||||
// f = FILE handle
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void emit_extern_var(char *decl, DataType *t, int extern_type, FILE *f) {
|
||||
switch(extern_type) {
|
||||
case 0:
|
||||
// No extern. Just a forward reference
|
||||
fprintf(f,"%s;\n", DataType_str(t, decl));
|
||||
break;
|
||||
case 1: case 2:
|
||||
fprintf(f,"extern %s;\n", DataType_str(t,decl));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// emit_extern_func(char *decl, DataType *t, ParmList *L, int extern_type,
|
||||
// FILE *f)
|
||||
//
|
||||
// Emits an external function declaration (similiar to emit_extern_var).
|
||||
//
|
||||
// Inputs :
|
||||
// decl = Name of declaration
|
||||
// t = Return datatype
|
||||
// L = parameter list
|
||||
// extern_type = Type of extern
|
||||
// 0 - No "extern"
|
||||
// 1 - extern
|
||||
// 2 - extern "C"
|
||||
// 3 - Function declaration (with arg names)
|
||||
// f = FILE Handle
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void emit_extern_func(char *decl, DataType *t, ParmList *L, int extern_type, FILE *f) {
|
||||
|
||||
switch(extern_type) {
|
||||
case 0:
|
||||
fprintf(f,"%s", DataType_str(t,0));
|
||||
fprintf(f,"%s(", decl);
|
||||
ParmList_print_types(L,f);
|
||||
fprintf(f,");\n");
|
||||
break;
|
||||
case 1:
|
||||
fprintf(f,"extern %s", DataType_str(t,0));
|
||||
fprintf(f,"%s(", decl);
|
||||
ParmList_print_types(L,f);
|
||||
fprintf(f,");\n");
|
||||
break;
|
||||
case 2:
|
||||
// A C++ --- > C Extern
|
||||
fprintf(f,"extern \"C\" %s", DataType_str(t,0));
|
||||
fprintf(f,"%s(", decl);
|
||||
ParmList_print_types(L,f);
|
||||
fprintf(f,");\n");
|
||||
break;
|
||||
case 3:
|
||||
fprintf(f,"%s", DataType_str(t,0));
|
||||
fprintf(f,"%s(", decl);
|
||||
ParmList_print_args(L,f);
|
||||
fprintf(f,")\n");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// int emit_args(char *d, DataType *rt, ParmList *l, Wrapper *f)
|
||||
//
|
||||
// Creates a list of variable declarations for both the return value
|
||||
// and function parameters.
|
||||
//
|
||||
// The return value is always called result and arguments arg0, arg1, arg2, etc...
|
||||
// Returns the number of parameters associated with a function.
|
||||
// -----------------------------------------------------------------------------
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int emit_args(char *d, DataType *rt, ParmList *l, Wrapper *f)
|
||||
*
|
||||
* Creates a list of variable declarations for both the return value
|
||||
* and function parameters.
|
||||
*
|
||||
* The return value is always called result and arguments arg0, arg1, arg2, etc...
|
||||
* Returns the number of parameters associated with a function.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int emit_args(DataType *rt, ParmList *l, Wrapper *f) {
|
||||
|
||||
|
|
@ -119,10 +37,9 @@ int emit_args(DataType *rt, ParmList *l, Wrapper *f) {
|
|||
DataType *pt;
|
||||
char *pvalue;
|
||||
char *pname;
|
||||
char *local;
|
||||
char *lname;
|
||||
|
||||
// Emit function arguments
|
||||
/* Emit function arguments */
|
||||
Swig_cargs(f, l);
|
||||
|
||||
i = 0;
|
||||
|
|
@ -145,7 +62,7 @@ int emit_args(DataType *rt, ParmList *l, Wrapper *f) {
|
|||
tm = typemap_lookup((char*)"ignore",typemap_lang,pt,pname,(char*)"",lname,f);
|
||||
if (tm) {
|
||||
Printv(f->code,tm,"\n",0);
|
||||
p->ignore = 1;
|
||||
Parm_Setignore(p,1);
|
||||
}
|
||||
i++;
|
||||
p = ParmList_next(l);
|
||||
|
|
@ -153,23 +70,29 @@ int emit_args(DataType *rt, ParmList *l, Wrapper *f) {
|
|||
return(i);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// int emit_func_call(char *decl, DataType *t, ParmList *l, Wrapper*f)
|
||||
//
|
||||
// Emits code for a function call (new version).
|
||||
//
|
||||
// Exception handling support :
|
||||
//
|
||||
// - This function checks to see if any sort of exception mechanism
|
||||
// has been defined. If so, we emit the function call in an exception
|
||||
// handling block.
|
||||
// -----------------------------------------------------------------------------
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int emit_func_call(char *decl, DataType *t, ParmList *l, Wrapper*f)
|
||||
*
|
||||
* Emits code for a function call (new version).
|
||||
*
|
||||
* Exception handling support :
|
||||
*
|
||||
* - This function checks to see if any sort of exception mechanism
|
||||
* has been defined. If so, we emit the function call in an exception
|
||||
* handling block.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static DOH *fcall = 0;
|
||||
|
||||
void emit_set_action(DOHString_or_char *decl) {
|
||||
if (fcall) Delete (fcall);
|
||||
fcall = NewString(decl);
|
||||
}
|
||||
|
||||
void emit_func_call(char *decl, DataType *t, ParmList *l, Wrapper *f) {
|
||||
char *tm;
|
||||
|
||||
if ((tm = typemap_lookup((char*)"except",typemap_lang,t,decl,(char*)"result",(char*)""))) {
|
||||
// Found a type-specific mapping
|
||||
Printv(f->code,tm,0);
|
||||
Replace(f->code,"$name",decl,DOH_REPLACE_ANY);
|
||||
} else if ((tm = fragment_lookup((char*)"except",typemap_lang, t->id))) {
|
||||
|
|
@ -178,117 +101,88 @@ void emit_func_call(char *decl, DataType *t, ParmList *l, Wrapper *f) {
|
|||
} else {
|
||||
Printv(f->code,"$function",0);
|
||||
}
|
||||
|
||||
if (!fcall) fcall = NewString(Swig_cfunction_call(decl,l));
|
||||
|
||||
if (CPlusPlus) {
|
||||
Swig_cppresult(f, t, "result", Swig_cfunction(decl,l));
|
||||
Swig_cppresult(f, t, "result", Char(fcall));
|
||||
} else {
|
||||
Swig_cresult(f, t, "result", Swig_cfunction(decl,l));
|
||||
Swig_cresult(f, t, "result", Char(fcall));
|
||||
}
|
||||
Delete(fcall);
|
||||
fcall = 0;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// void emit_set_get(char *name, char *iname, DataType *type)
|
||||
//
|
||||
// Emits a pair of functions to set/get the value of a variable.
|
||||
// This should be used as backup in case the target language can't
|
||||
// provide variable linking.
|
||||
//
|
||||
// double foo;
|
||||
//
|
||||
// Gets translated into the following :
|
||||
//
|
||||
// double foo_set(double x) {
|
||||
// return foo = x;
|
||||
// }
|
||||
//
|
||||
// double foo_get() {
|
||||
// return foo;
|
||||
// }
|
||||
//
|
||||
// Need to handle special cases for char * and for user
|
||||
// defined types.
|
||||
//
|
||||
// 1. char *
|
||||
//
|
||||
// Will free previous contents (if any) and allocate
|
||||
// new storage. Could be risky, but it's a reasonably
|
||||
// natural thing to do.
|
||||
//
|
||||
// 2. User_Defined
|
||||
// Will assign value from a pointer.
|
||||
// Will return a pointer to current value.
|
||||
// -----------------------------------------------------------------------------
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void emit_set_get(char *name, char *iname, DataType *type)
|
||||
*
|
||||
* Emits a pair of functions to set/get the value of a variable. This is
|
||||
* only used in the event the target language can't provide variable linking
|
||||
* on its own.
|
||||
*
|
||||
* double foo;
|
||||
*
|
||||
* Gets translated into the following :
|
||||
*
|
||||
* double foo_set(double x) {
|
||||
* return foo = x;
|
||||
* }
|
||||
*
|
||||
* double foo_get() {
|
||||
* return foo;
|
||||
* }
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* How to assign a C allocated string */
|
||||
|
||||
static char *c_str = (char *)" {\n\
|
||||
if ($target) free($target);\n\
|
||||
$target = ($rtype) malloc(strlen($source)+1);\n\
|
||||
strcpy((char *)$target,$source);\n\
|
||||
return $ltype $target;\n\
|
||||
}\n";
|
||||
|
||||
/* How to assign a C allocated string */
|
||||
|
||||
static char *cpp_str = (char *)" {\n\
|
||||
if ($target) delete [] $target;\n\
|
||||
$target = ($rtype) (new char[strlen($source)+1]);\n\
|
||||
strcpy((char *)$target,$source);\n\
|
||||
return ($ltype) $target;\n\
|
||||
}\n";
|
||||
|
||||
void emit_set_get(char *name, char *iname, DataType *t) {
|
||||
|
||||
Parm *p;
|
||||
ParmList *l;
|
||||
char *new_name = 0, *new_iname = 0;
|
||||
Wrapper *w;
|
||||
char new_iname[256];
|
||||
char *code = 0;
|
||||
|
||||
DataType *lt;
|
||||
/* First write a function to set the variable of the variable */
|
||||
if (!(Status & STAT_READONLY)) {
|
||||
|
||||
// Figure out the assignable local type for this variable
|
||||
|
||||
lt = Swig_clocal_type(t);
|
||||
|
||||
// First write a function to set the variable of the variable
|
||||
if (!(Status & STAT_READONLY)) {
|
||||
fprintf(f_header,"static %s %s(%s) {\n",
|
||||
DataType_lstr(lt,0), Swig_name_set(name), DataType_lstr(lt,"val"));
|
||||
if (!t->is_pointer) {
|
||||
fprintf(f_header,"\t %s = %s;\n", name, Swig_clocal_deref(t,"val"));
|
||||
fprintf(f_header,"\t return %s;\n", Swig_clocal_assign(t,name));
|
||||
} else {
|
||||
// Is a pointer type here. If string, we do something
|
||||
// special. Otherwise. No problem.
|
||||
if ((t->type == T_CHAR) && (t->is_pointer == 1)) {
|
||||
if (CPlusPlus) {
|
||||
fprintf(f_header,"\t if (%s) delete %s;\n", name,name);
|
||||
fprintf(f_header,"\t %s = new char[strlen(val)+1];\n",name);
|
||||
fprintf(f_header,"\t strcpy(%s,val);\n", name);
|
||||
fprintf(f_header,"\t return %s;\n", Swig_clocal_assign(t,name));
|
||||
} else {
|
||||
fprintf(f_header,"\t if (%s) free(%s);\n", name,name);
|
||||
fprintf(f_header,"\t %s = (char *) malloc(strlen(val)+1);\n",name);
|
||||
fprintf(f_header,"\t strcpy(%s,val);\n", name);
|
||||
fprintf(f_header,"\t return %s;\n", Swig_clocal_assign(t,name));
|
||||
}
|
||||
} else {
|
||||
fprintf(f_header,"\t %s = %s;\n", name, Swig_clocal_deref(t,"val"));
|
||||
fprintf(f_header,"\t return %s;\n", Swig_clocal_assign(t,name));
|
||||
}
|
||||
}
|
||||
fprintf(f_header,"}\n");
|
||||
|
||||
// Now wrap it.
|
||||
l = NewParmList();
|
||||
p = NewParm(lt,0);
|
||||
Parm_Setname(p,(char*)"");
|
||||
ParmList_append(l,p);
|
||||
|
||||
new_name = copy_string(Swig_name_set(name));
|
||||
new_iname = copy_string(Swig_name_set(iname));
|
||||
lang->create_function(new_name, new_iname, lt, l);
|
||||
DelParmList(l);
|
||||
DelParm(p);
|
||||
if ((t->type == T_CHAR) && (t->is_pointer == 1)) {
|
||||
if (CPlusPlus)
|
||||
code = cpp_str;
|
||||
else
|
||||
code = c_str;
|
||||
|
||||
}
|
||||
w = Swig_cvarset_wrapper(name, t, code);
|
||||
Wrapper_print(w,f_header);
|
||||
strcpy(new_iname, Swig_name_set(iname));
|
||||
lang->create_function(Wrapper_Getname(w), new_iname, Wrapper_Gettype(w), Wrapper_Getparms(w));
|
||||
DelWrapper(w);
|
||||
}
|
||||
|
||||
// Now write a function to get the value of the variable
|
||||
fprintf(f_header,"static %s %s() { \n",
|
||||
DataType_lstr(lt,0), Swig_name_get(name));
|
||||
fprintf(f_header,"\t return %s;\n", Swig_clocal_assign(t,name));
|
||||
fprintf(f_header,"}\n");
|
||||
|
||||
// Wrap this function
|
||||
|
||||
l = NewParmList();
|
||||
if (new_name) delete [] new_name;
|
||||
if (new_iname) delete [] new_iname;
|
||||
|
||||
new_name = copy_string(Swig_name_get(name));
|
||||
new_iname = copy_string(Swig_name_get(iname));
|
||||
lang->create_function(new_name, new_iname, lt, l);
|
||||
DelParmList(l);
|
||||
DelDataType(lt);
|
||||
delete [] new_name;
|
||||
delete [] new_iname;
|
||||
w = Swig_cvarget_wrapper(name,t,0);
|
||||
Wrapper_print(w,f_header);
|
||||
strcpy(new_iname, Swig_name_get(iname));
|
||||
lang->create_function(Wrapper_Getname(w), new_iname, Wrapper_Gettype(w), Wrapper_Getparms(w));
|
||||
DelWrapper(w);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -38,3 +38,4 @@ struct TMParm {
|
|||
/* Number of initialization names that can be used */
|
||||
|
||||
#define NI_NAMES 512
|
||||
|
||||
|
|
|
|||
|
|
@ -81,22 +81,22 @@ void Language::cpp_open_class(char *classname, char *classrename, char *ctype, i
|
|||
|
||||
// Copy the class name
|
||||
|
||||
if (ClassName) delete ClassName;
|
||||
ClassName = copy_string(classname);
|
||||
if (ClassName) free(ClassName);
|
||||
ClassName = Swig_copy_string(classname);
|
||||
|
||||
// Copy the class renaming
|
||||
|
||||
if (ClassRename) delete ClassRename;
|
||||
if (ClassRename) free(ClassRename);
|
||||
if (classrename) {
|
||||
ClassRename = copy_string(classrename);
|
||||
ClassRename = Swig_copy_string(classrename);
|
||||
} else {
|
||||
ClassRename = 0; // No renaming
|
||||
}
|
||||
|
||||
// Make the class type
|
||||
|
||||
if (ClassType) delete ClassType;
|
||||
ClassType = new char[strlen(ctype)+2];
|
||||
if (ClassType) free(ClassType);
|
||||
ClassType = (char *) malloc(strlen(ctype)+2);
|
||||
if (strip) ClassType[0] = 0;
|
||||
else sprintf(ClassType,"%s ",ctype);
|
||||
}
|
||||
|
|
@ -442,7 +442,7 @@ void Language::cpp_declare_const(char *name, char *iname, DataType *type, char *
|
|||
|
||||
// Declare a constant
|
||||
if (!value) {
|
||||
new_value = new char[strlen(ClassName)+strlen(name)+3];
|
||||
new_value = (char *) malloc(strlen(ClassName)+strlen(name)+3);
|
||||
sprintf(new_value,"%s::%s",ClassName,name);
|
||||
} else {
|
||||
new_value = value;
|
||||
|
|
@ -451,7 +451,7 @@ void Language::cpp_declare_const(char *name, char *iname, DataType *type, char *
|
|||
lang->declare_const(cname,cname,type, new_value);
|
||||
|
||||
if (!value) {
|
||||
delete new_value;
|
||||
free(new_value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -143,7 +143,6 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
int checkout = 0;
|
||||
int cpp_only = 0;
|
||||
|
||||
char *typemap_file = 0;
|
||||
char *includefiles[256];
|
||||
int includecount = 0;
|
||||
extern int check_suffix(char *);
|
||||
|
|
@ -189,7 +188,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
strcpy(LibDir,c);
|
||||
}
|
||||
|
||||
SwigLib = copy_string(LibDir); // Make a copy of the real library location
|
||||
SwigLib = Swig_copy_string(LibDir); // Make a copy of the real library location
|
||||
|
||||
sprintf(temp,"%s/config", LibDir);
|
||||
Swig_add_directory((DOH *) temp);
|
||||
|
|
@ -205,7 +204,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
if (argv[i]) {
|
||||
if (strncmp(argv[i],"-I",2) == 0) {
|
||||
// Add a new directory search path
|
||||
includefiles[includecount++] = copy_string(argv[i]+2);
|
||||
includefiles[includecount++] = Swig_copy_string(argv[i]+2);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strncmp(argv[i],"-D",2) == 0) {
|
||||
DOH *d = NewString(argv[i]+2);
|
||||
|
|
@ -238,7 +237,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
} else if (strcmp(argv[i],"-o") == 0) {
|
||||
Swig_mark_arg(i);
|
||||
if (argv[i+1]) {
|
||||
outfile_name = copy_string(argv[i+1]);
|
||||
outfile_name = Swig_copy_string(argv[i+1]);
|
||||
Swig_mark_arg(i+1);
|
||||
i++;
|
||||
} else {
|
||||
|
|
@ -564,9 +563,9 @@ void swig_pragma(char *name, char *value) {
|
|||
GenerateDefault = 0;
|
||||
}
|
||||
if (strcmp(name,"objc_new") == 0) {
|
||||
objc_construct = copy_string(value);
|
||||
objc_construct = Swig_copy_string(value);
|
||||
}
|
||||
if (strcmp(name,"objc_delete") == 0) {
|
||||
objc_destruct = copy_string(value);
|
||||
objc_destruct = Swig_copy_string(value);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ extern void scanner_check_typedef(void);
|
|||
extern void scanner_ignore_typedef(void);
|
||||
extern void scanner_clear_start(void);
|
||||
extern void start_inline(char *, int);
|
||||
extern void format_string(char *);
|
||||
extern void swig_pragma(char *, char *);
|
||||
|
||||
#include "internal.h"
|
||||
|
|
@ -85,7 +84,7 @@ static DOHHash *symbols = 0;
|
|||
/* Some macros for building constants */
|
||||
|
||||
#define E_BINARY(TARGET, SRC1, SRC2, OP) \
|
||||
TARGET = new char[strlen(SRC1) + strlen(SRC2) +strlen(OP)+1];\
|
||||
TARGET = (char *) malloc(strlen(SRC1) + strlen(SRC2) +strlen(OP)+1);\
|
||||
sprintf(TARGET,"%s%s%s",SRC1,OP,SRC2);
|
||||
|
||||
/* C++ modes */
|
||||
|
|
@ -122,6 +121,112 @@ void parser_init() {
|
|||
temp_type = NewDataType(0);
|
||||
}
|
||||
|
||||
static TMParm *NewTMParm() {
|
||||
TMParm *tmp = (TMParm *) malloc(sizeof(TMParm));
|
||||
tmp->next = 0;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// void format_string(char *str)
|
||||
//
|
||||
// Replace all of the escape sequences in the string str. It is
|
||||
// assumed that the new string is smaller than the original!
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
static void format_string(char *str) {
|
||||
char *newstr, *c,*c1;
|
||||
int state;
|
||||
if (!str) return;
|
||||
newstr = Swig_copy_string(str);
|
||||
c = newstr;
|
||||
c1 = str;
|
||||
state = 0;
|
||||
while (*c) {
|
||||
switch(state) {
|
||||
case 0:
|
||||
if (*c == '\\')
|
||||
state = 1;
|
||||
else {
|
||||
*(c1++) = *c;
|
||||
state = 0;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
// We're in a simple escape sequence figure out what to do
|
||||
switch(*c) {
|
||||
case 'n':
|
||||
*(c1++) = '\n';
|
||||
break;
|
||||
case 'f':
|
||||
*(c1++) = '\f';
|
||||
break;
|
||||
case 'r':
|
||||
*(c1++) = '\r';
|
||||
break;
|
||||
case 't':
|
||||
*(c1++) = '\t';
|
||||
break;
|
||||
case '\\':
|
||||
*(c1++) = '\\';
|
||||
break;
|
||||
case '\"':
|
||||
*(c1++) = '\"';
|
||||
break;
|
||||
case '\'':
|
||||
*(c1++) = '\'';
|
||||
break;
|
||||
default:
|
||||
*(c1++) = '\\';
|
||||
*(c1++) = *c;
|
||||
}
|
||||
state = 0;
|
||||
break;
|
||||
default:
|
||||
*(c1++) = *c;
|
||||
state = 0;
|
||||
}
|
||||
c++;
|
||||
}
|
||||
*c1 = 0;
|
||||
free(newstr);
|
||||
}
|
||||
|
||||
// Emit an external function declaration
|
||||
|
||||
static void emit_extern_func(char *decl, DataType *t, ParmList *L, int extern_type, FILE *f) {
|
||||
|
||||
switch(extern_type) {
|
||||
case 0:
|
||||
fprintf(f,"%s", DataType_str(t,0));
|
||||
fprintf(f,"%s(", decl);
|
||||
ParmList_print_types(L,f);
|
||||
fprintf(f,");\n");
|
||||
break;
|
||||
case 1:
|
||||
fprintf(f,"extern %s", DataType_str(t,0));
|
||||
fprintf(f,"%s(", decl);
|
||||
ParmList_print_types(L,f);
|
||||
fprintf(f,");\n");
|
||||
break;
|
||||
case 2:
|
||||
/* A C++ --- > C Extern */
|
||||
fprintf(f,"extern \"C\" %s", DataType_str(t,0));
|
||||
fprintf(f,"%s(", decl);
|
||||
ParmList_print_types(L,f);
|
||||
fprintf(f,");\n");
|
||||
break;
|
||||
case 3:
|
||||
fprintf(f,"%s", DataType_str(t,0));
|
||||
fprintf(f,"%s(", decl);
|
||||
ParmList_print_args(L,f);
|
||||
fprintf(f,")\n");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// static init_language()
|
||||
//
|
||||
|
|
@ -257,10 +362,8 @@ void create_variable(int ext, char *name, DataType *t) {
|
|||
|
||||
// If externed, output an external declaration
|
||||
|
||||
if (ext)
|
||||
emit_extern_var(name, t, ext, f_header);
|
||||
else if (ForceExtern) {
|
||||
emit_extern_var(name, t, 1, f_header);
|
||||
if (ext || ForceExtern) {
|
||||
Printf(f_header,"extern %s;\n", DataType_str(t,name));
|
||||
}
|
||||
|
||||
// If variable datatype is read-only, we'll force it to be readonly
|
||||
|
|
@ -294,7 +397,7 @@ void create_constant(char *name, DataType *type, char *value) {
|
|||
if ((type->type == T_CHAR) && (!type->is_pointer))
|
||||
type->is_pointer++;
|
||||
|
||||
if (!value) value = copy_string(name);
|
||||
if (!value) value = Swig_copy_string(name);
|
||||
sprintf(temp_name,"const:%s", name);
|
||||
if (add_symbol(temp_name)) {
|
||||
fprintf(stderr,"%s : Line %d. Constant %s multiply defined. (2nd definition ignored)\n",
|
||||
|
|
@ -368,7 +471,7 @@ static void dump_nested(char *parent) {
|
|||
|
||||
n1 = n->next;
|
||||
Delete(n->code);
|
||||
delete n;
|
||||
free(n);
|
||||
n = n1;
|
||||
}
|
||||
nested_list = 0;
|
||||
|
|
@ -489,9 +592,9 @@ command : command statement {
|
|||
;
|
||||
|
||||
statement : INCLUDE STRING LBRACE {
|
||||
$1.filename = copy_string(input_file);
|
||||
$1.filename = Swig_copy_string(input_file);
|
||||
$1.line = line_number;
|
||||
input_file = copy_string($2);
|
||||
input_file = Swig_copy_string($2);
|
||||
line_number = 0;
|
||||
} command RBRACE {
|
||||
input_file = $1.filename;
|
||||
|
|
@ -503,9 +606,9 @@ statement : INCLUDE STRING LBRACE {
|
|||
| WEXTERN STRING LBRACE {
|
||||
$1.flag = WrapExtern;
|
||||
WrapExtern = 1;
|
||||
$1.filename = copy_string(input_file);
|
||||
$1.filename = Swig_copy_string(input_file);
|
||||
$1.line = line_number;
|
||||
input_file = copy_string($2);
|
||||
input_file = Swig_copy_string($2);
|
||||
line_number = 0;
|
||||
} command RBRACE {
|
||||
input_file = $1.filename;
|
||||
|
|
@ -518,9 +621,9 @@ statement : INCLUDE STRING LBRACE {
|
|||
| IMPORT STRING LBRACE {
|
||||
$1.flag = WrapExtern;
|
||||
WrapExtern = 1;
|
||||
$1.filename = copy_string(input_file);
|
||||
$1.filename = Swig_copy_string(input_file);
|
||||
$1.line = line_number;
|
||||
input_file = copy_string($2);
|
||||
input_file = Swig_copy_string($2);
|
||||
line_number = 0;
|
||||
lang->import($2);
|
||||
} command RBRACE {
|
||||
|
|
@ -530,9 +633,9 @@ statement : INCLUDE STRING LBRACE {
|
|||
}
|
||||
|
||||
| SWIGMACRO ID COMMA STRING COMMA NUM_INT LBRACE {
|
||||
$1.filename = copy_string(input_file);
|
||||
$1.filename = Swig_copy_string(input_file);
|
||||
$1.line = line_number;
|
||||
input_file = copy_string($4);
|
||||
input_file = Swig_copy_string($4);
|
||||
line_number = atoi($6) - 1;
|
||||
} command RBRACE {
|
||||
input_file = $1.filename;
|
||||
|
|
@ -562,13 +665,15 @@ statement : INCLUDE STRING LBRACE {
|
|||
FatalError();
|
||||
} else {
|
||||
if (DataType_qualifier($2)) {
|
||||
if ((strcmp(DataType_qualifier($2),"const") == 0)) {
|
||||
if ($5.type != T_ERROR)
|
||||
if (!($2->is_pointer) && (strcmp(DataType_qualifier($2),"const") == 0)) {
|
||||
if ($5.type != T_ERROR)
|
||||
create_constant($3.id, $2, $5.id);
|
||||
} else
|
||||
} else {
|
||||
create_variable($1,$3.id,$2);
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
create_variable($1,$3.id,$2);
|
||||
}
|
||||
}
|
||||
DelDataType($2);
|
||||
} stail { }
|
||||
|
|
@ -865,8 +970,8 @@ statement : INCLUDE STRING LBRACE {
|
|||
input_file,line_number);
|
||||
}
|
||||
for (i = 0; i < $3.count; i++)
|
||||
if ($3.names[i]) delete [] $3.names[i];
|
||||
delete [] $3.names;
|
||||
if ($3.names[i]) free($3.names[i]);
|
||||
free($3.names);
|
||||
}
|
||||
/* Module directive */
|
||||
|
||||
|
|
@ -878,8 +983,8 @@ statement : INCLUDE STRING LBRACE {
|
|||
module_init = 1;
|
||||
init_language();
|
||||
for (i = 0; i < $3.count; i++)
|
||||
if ($3.names[i]) delete [] $3.names[i];
|
||||
delete [] $3.names;
|
||||
if ($3.names[i]) free($3.names[i]);
|
||||
free($3.names);
|
||||
}
|
||||
|
||||
/* constant directive */
|
||||
|
|
@ -942,8 +1047,8 @@ statement : INCLUDE STRING LBRACE {
|
|||
typemap_register($5,$3,Parm_Gettype(p->p),Parm_Getname(p->p),Char(CCode),p->args);
|
||||
p = p->next;
|
||||
}
|
||||
delete $3;
|
||||
delete $5;
|
||||
free($3);
|
||||
free($5);
|
||||
}
|
||||
|
||||
/* Create a new typemap in current language */
|
||||
|
|
@ -961,7 +1066,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
p = p->next;
|
||||
}
|
||||
}
|
||||
delete $3;
|
||||
free($3);
|
||||
}
|
||||
|
||||
/* Clear a typemap */
|
||||
|
|
@ -973,8 +1078,8 @@ statement : INCLUDE STRING LBRACE {
|
|||
typemap_clear($5,$3,Parm_Gettype(p->p),Parm_Getname(p->p));
|
||||
p = p->next;
|
||||
}
|
||||
delete $3;
|
||||
delete $5;
|
||||
free($3);
|
||||
free($5);
|
||||
}
|
||||
/* Clear a typemap in current language */
|
||||
|
||||
|
|
@ -991,7 +1096,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
p = p->next;
|
||||
}
|
||||
}
|
||||
delete $3;
|
||||
free($3);
|
||||
}
|
||||
|
||||
/* Copy a typemap */
|
||||
|
|
@ -1003,10 +1108,10 @@ statement : INCLUDE STRING LBRACE {
|
|||
typemap_copy($5,$3,Parm_Gettype($9->p),Parm_Getname($9->p),Parm_Gettype(p->p),Parm_Getname(p->p));
|
||||
p = p->next;
|
||||
}
|
||||
delete $3;
|
||||
delete $5;
|
||||
free($3);
|
||||
free($5);
|
||||
DelParm($9->p);
|
||||
delete $9;
|
||||
free($9);
|
||||
}
|
||||
|
||||
/* Copy typemap in current language */
|
||||
|
|
@ -1024,9 +1129,9 @@ statement : INCLUDE STRING LBRACE {
|
|||
p = p->next;
|
||||
}
|
||||
}
|
||||
delete $3;
|
||||
free($3);
|
||||
DelParm($7->p);
|
||||
delete $7;
|
||||
free($7);
|
||||
}
|
||||
/* -----------------------------------------------------------------
|
||||
apply and clear support (for typemaps)
|
||||
|
|
@ -1039,9 +1144,9 @@ statement : INCLUDE STRING LBRACE {
|
|||
typemap_apply(Parm_Gettype($2->p),Parm_Getname($2->p),Parm_Gettype(p->p),Parm_Getname(p->p));
|
||||
p = p->next;
|
||||
}
|
||||
delete $4;
|
||||
free($4);
|
||||
DelParmList($2->args);
|
||||
delete $2;
|
||||
free($2);
|
||||
}
|
||||
| CLEAR tm_list SEMI {
|
||||
TMParm *p;
|
||||
|
|
@ -1063,7 +1168,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
| EXCEPT LPAREN ID RPAREN LBRACE {
|
||||
skip_brace();
|
||||
fragment_register((char *)"except",$3, Char(CCode));
|
||||
delete $3;
|
||||
free($3);
|
||||
}
|
||||
|
||||
/* A Generic Exception (no language specified */
|
||||
|
|
@ -1169,7 +1274,7 @@ typedef_decl : TYPEDEF type declaration {
|
|||
lang->add_typedef($2,$5);
|
||||
cplus_register_type($5);
|
||||
DelDataType($2);
|
||||
delete $5;
|
||||
free($5);
|
||||
DelParmList($8);
|
||||
}
|
||||
|
||||
|
|
@ -1192,7 +1297,7 @@ typedef_decl : TYPEDEF type declaration {
|
|||
lang->add_typedef($2,$6);
|
||||
cplus_register_type($6);
|
||||
DelDataType($2);
|
||||
delete $6;
|
||||
free($6);
|
||||
DelParmList($9);
|
||||
}
|
||||
|
||||
|
|
@ -1353,7 +1458,7 @@ ptail : COMMA parm ptail {
|
|||
parm : parm_type {
|
||||
$$ = $1;
|
||||
if (typemap_check((char *)"ignore",typemap_lang,Parm_Gettype($$),Parm_Getname($$)))
|
||||
$$->ignore = 1;
|
||||
Parm_Setignore($$,1);
|
||||
}
|
||||
|
||||
parm_type : type pname {
|
||||
|
|
@ -1365,7 +1470,7 @@ parm_type : type pname {
|
|||
$$ = NewParm($1,$2);
|
||||
Parm_Setvalue($$,DefArg);
|
||||
DelDataType($1);
|
||||
delete $2;
|
||||
free($2);
|
||||
}
|
||||
|
||||
| type stars pname {
|
||||
|
|
@ -1378,7 +1483,7 @@ parm_type : type pname {
|
|||
DataType_set_arraystr(Parm_Gettype($$), Char(ArrayString));
|
||||
}
|
||||
DelDataType($1);
|
||||
delete $3;
|
||||
free($3);
|
||||
}
|
||||
|
||||
| type AND pname {
|
||||
|
|
@ -1391,7 +1496,7 @@ parm_type : type pname {
|
|||
fprintf(stderr,"%s : Line %d. Warning. Use of C++ Reference detected. Use the -c++ option.\n", input_file, line_number);
|
||||
}
|
||||
DelDataType($1);
|
||||
delete $3;
|
||||
free($3);
|
||||
}
|
||||
| type LPAREN stars pname RPAREN LPAREN parms RPAREN {
|
||||
fprintf(stderr,"%s : Line %d. Error. Function pointer not allowed (remap with typedef).\n", input_file, line_number);
|
||||
|
|
@ -1402,7 +1507,7 @@ parm_type : type pname {
|
|||
Parm_Setname($$,$4);
|
||||
strcpy(pt->name,"<function ptr>");
|
||||
DelDataType($1);
|
||||
delete $4;
|
||||
free($4);
|
||||
DelParmList($7);
|
||||
}
|
||||
| PERIOD PERIOD PERIOD {
|
||||
|
|
@ -1423,7 +1528,7 @@ pname : ID def_args {
|
|||
DefArg = Swig_copy_string(ConstChar);
|
||||
else
|
||||
DefArg = Swig_copy_string($2.id);
|
||||
if ($2.id) delete $2.id;
|
||||
if ($2.id) free($2.id);
|
||||
}
|
||||
| ID array {
|
||||
$$ = $1;
|
||||
|
|
@ -1431,12 +1536,12 @@ pname : ID def_args {
|
|||
DefArg = 0;
|
||||
}
|
||||
| array {
|
||||
$$ = new char[1];
|
||||
$$ = (char *) malloc(1);
|
||||
$$[0] = 0;
|
||||
InArray = $1;
|
||||
DefArg = 0;
|
||||
}
|
||||
| empty { $$ = new char[1];
|
||||
| empty { $$ = (char *) malloc(1);
|
||||
$$[0] = 0;
|
||||
InArray = 0;
|
||||
DefArg = 0;
|
||||
|
|
@ -1445,7 +1550,7 @@ pname : ID def_args {
|
|||
|
||||
def_args : EQUAL definetype { $$ = $2; }
|
||||
| EQUAL AND ID {
|
||||
$$.id = new char[strlen($3)+2];
|
||||
$$.id = (char *) malloc(strlen($3)+2);
|
||||
$$.id[0] = '&';
|
||||
strcpy(&$$.id[1], $3);
|
||||
$$.type = T_USER;
|
||||
|
|
@ -1715,21 +1820,21 @@ opt_int : TYPE_INT { }
|
|||
definetype : { scanner_check_typedef(); } expr {
|
||||
$$ = $2;
|
||||
scanner_ignore_typedef();
|
||||
if (ConstChar) delete ConstChar;
|
||||
if (ConstChar) free(ConstChar);
|
||||
ConstChar = 0;
|
||||
}
|
||||
| STRING {
|
||||
$$.id = $1;
|
||||
$$.type = T_CHAR;
|
||||
if (ConstChar) delete ConstChar;
|
||||
ConstChar = new char[strlen($1)+3];
|
||||
if (ConstChar) free(ConstChar);
|
||||
ConstChar = (char *) malloc(strlen($1)+3);
|
||||
sprintf(ConstChar,"\"%s\"",$1);
|
||||
}
|
||||
| CHARCONST {
|
||||
$$.id = $1;
|
||||
$$.type = T_CHAR;
|
||||
if (ConstChar) delete ConstChar;
|
||||
ConstChar = new char[strlen($1)+3];
|
||||
if (ConstChar) free(ConstChar);
|
||||
ConstChar = (char *) malloc(strlen($1)+3);
|
||||
sprintf(ConstChar,"'%s'",$1);
|
||||
}
|
||||
;
|
||||
|
|
@ -1739,12 +1844,12 @@ definetype : { scanner_check_typedef(); } expr {
|
|||
|
||||
initlist : initlist COMMA ID {
|
||||
$$ = $1;
|
||||
$$.names[$$.count] = copy_string($3);
|
||||
$$.names[$$.count] = Swig_copy_string($3);
|
||||
$$.count++;
|
||||
$$.names[$$.count] = (char *) 0;
|
||||
}
|
||||
| empty {
|
||||
$$.names = new char *[NI_NAMES];
|
||||
$$.names = (char **) malloc(NI_NAMES*sizeof(char*));
|
||||
$$.count = 0;
|
||||
for (i = 0; i < NI_NAMES; i++)
|
||||
$$.names[i] = (char *) 0;
|
||||
|
|
@ -1828,12 +1933,12 @@ expr : NUM_INT {
|
|||
$$.type = T_ULONG;
|
||||
}
|
||||
| SIZEOF LPAREN type RPAREN {
|
||||
$$.id = new char[strlen($3->name)+9];
|
||||
$$.id = (char *) malloc(strlen($3->name)+9);
|
||||
sprintf($$.id,"sizeof(%s)", $3->name);
|
||||
$$.type = T_INT;
|
||||
}
|
||||
| LPAREN strict_type RPAREN expr %prec UMINUS {
|
||||
$$.id = new char[strlen($4.id)+strlen($2->name)+3];
|
||||
$$.id = (char *) malloc(strlen($4.id)+strlen($2->name)+3);
|
||||
sprintf($$.id,"(%s)%s",$2->name,$4.id);
|
||||
$$.type = $2->type;
|
||||
}
|
||||
|
|
@ -1842,36 +1947,36 @@ expr : NUM_INT {
|
|||
$$.type = T_INT;
|
||||
}
|
||||
| ID DCOLON ID {
|
||||
$$.id = new char[strlen($1)+strlen($3)+3];
|
||||
$$.id = (char *) malloc(strlen($1)+strlen($3)+3);
|
||||
sprintf($$.id,"%s::%s",$1,$3);
|
||||
$$.type = T_INT;
|
||||
delete $1;
|
||||
delete $3;
|
||||
free($1);
|
||||
free($3);
|
||||
}
|
||||
| expr PLUS expr {
|
||||
E_BINARY($$.id,$1.id,$3.id,"+");
|
||||
$$.type = promote($1.type,$3.type);
|
||||
delete $1.id;
|
||||
delete $3.id;
|
||||
free($1.id);
|
||||
free($3.id);
|
||||
}
|
||||
| expr MINUS expr {
|
||||
E_BINARY($$.id,$1.id,$3.id,"-");
|
||||
$$.type = promote($1.type,$3.type);
|
||||
delete $1.id;
|
||||
delete $3.id;
|
||||
free($1.id);
|
||||
free($3.id);
|
||||
}
|
||||
| expr STAR expr {
|
||||
E_BINARY($$.id,$1.id,$3.id,"*");
|
||||
$$.type = promote($1.type,$3.type);
|
||||
delete $1.id;
|
||||
delete $3.id;
|
||||
free($1.id);
|
||||
free($3.id);
|
||||
|
||||
}
|
||||
| expr SLASH expr {
|
||||
E_BINARY($$.id,$1.id,$3.id,"/");
|
||||
$$.type = promote($1.type,$3.type);
|
||||
delete $1.id;
|
||||
delete $3.id;
|
||||
free($1.id);
|
||||
free($3.id);
|
||||
|
||||
}
|
||||
| expr AND expr {
|
||||
|
|
@ -1881,8 +1986,8 @@ expr : NUM_INT {
|
|||
fprintf(stderr,"%s : Line %d. Type error in constant expression (expecting integers).\n", input_file, line_number);
|
||||
FatalError();
|
||||
}
|
||||
delete $1.id;
|
||||
delete $3.id;
|
||||
free($1.id);
|
||||
free($3.id);
|
||||
|
||||
}
|
||||
| expr OR expr {
|
||||
|
|
@ -1893,8 +1998,8 @@ expr : NUM_INT {
|
|||
FatalError();
|
||||
}
|
||||
$$.type = T_INT;
|
||||
delete $1.id;
|
||||
delete $3.id;
|
||||
free($1.id);
|
||||
free($3.id);
|
||||
|
||||
}
|
||||
| expr XOR expr {
|
||||
|
|
@ -1905,8 +2010,8 @@ expr : NUM_INT {
|
|||
FatalError();
|
||||
}
|
||||
$$.type = T_INT;
|
||||
delete $1.id;
|
||||
delete $3.id;
|
||||
free($1.id);
|
||||
free($3.id);
|
||||
|
||||
}
|
||||
| expr LSHIFT expr {
|
||||
|
|
@ -1917,8 +2022,8 @@ expr : NUM_INT {
|
|||
FatalError();
|
||||
}
|
||||
$$.type = T_INT;
|
||||
delete $1.id;
|
||||
delete $3.id;
|
||||
free($1.id);
|
||||
free($3.id);
|
||||
|
||||
}
|
||||
| expr RSHIFT expr {
|
||||
|
|
@ -1929,32 +2034,32 @@ expr : NUM_INT {
|
|||
FatalError();
|
||||
}
|
||||
$$.type = T_INT;
|
||||
delete $1.id;
|
||||
delete $3.id;
|
||||
free($1.id);
|
||||
free($3.id);
|
||||
|
||||
}
|
||||
| MINUS expr %prec UMINUS {
|
||||
$$.id = new char[strlen($2.id)+2];
|
||||
$$.id = (char *) malloc(strlen($2.id)+2);
|
||||
sprintf($$.id,"-%s",$2.id);
|
||||
$$.type = $2.type;
|
||||
delete $2.id;
|
||||
free($2.id);
|
||||
|
||||
}
|
||||
| NOT expr {
|
||||
$$.id = new char[strlen($2.id)+2];
|
||||
$$.id = (char *) malloc(strlen($2.id)+2);
|
||||
sprintf($$.id,"~%s",$2.id);
|
||||
if ($2.type == T_DOUBLE) {
|
||||
fprintf(stderr,"%s : Line %d. Type error in constant expression (expecting integers).\n", input_file, line_number);
|
||||
FatalError();
|
||||
}
|
||||
$$.type = $2.type;
|
||||
delete $2.id;
|
||||
free($2.id);
|
||||
}
|
||||
| LPAREN expr RPAREN {
|
||||
$$.id = new char[strlen($2.id)+3];
|
||||
$$.id = (char *) malloc(strlen($2.id)+3);
|
||||
sprintf($$.id,"(%s)", $2.id);
|
||||
$$.type = $2.type;
|
||||
delete $2.id;
|
||||
free($2.id);
|
||||
}
|
||||
;
|
||||
/****************************************************************/
|
||||
|
|
@ -2007,9 +2112,9 @@ cpp_class :
|
|||
if ($4.names) {
|
||||
int j;
|
||||
for (j = 0; j < $4.count; j++) {
|
||||
if ($4.names[j]) delete [] $4.names[j];
|
||||
if ($4.names[j]) free($4.names[j]);
|
||||
}
|
||||
delete [] $4.names;
|
||||
free($4.names);
|
||||
}
|
||||
|
||||
// Dumped nested declarations (if applicable)
|
||||
|
|
@ -2071,9 +2176,9 @@ cpp_class :
|
|||
if ($4.names) {
|
||||
int j;
|
||||
for (j = 0; j < $4.count; j++) {
|
||||
if ($4.names[j]) delete [] $4.names[j];
|
||||
if ($4.names[j]) free($4.names[j]);
|
||||
}
|
||||
delete [] $4.names;
|
||||
free($4.names);
|
||||
}
|
||||
|
||||
if ($9.is_pointer > 0) {
|
||||
|
|
@ -2558,11 +2663,11 @@ cpp_pragma : PRAGMA ID stylearg {
|
|||
fprintf(stderr,"%s : Line %d. Warning. Nested classes not currently supported (ignored).\n", input_file, line_number);
|
||||
/* Generate some code for a new class */
|
||||
} else {
|
||||
Nested *n = new Nested;
|
||||
Nested *n = (Nested *) malloc(sizeof(Nested));
|
||||
n->code = NewString("");
|
||||
Printv(n->code, "typedef ", $1, " ",
|
||||
Char(CCode), " $classname_", $5.id, ";\n", 0);
|
||||
n->name = copy_string($5.id);
|
||||
n->name = Swig_copy_string($5.id);
|
||||
n->line = start_line;
|
||||
n->type = NewDataType(0);
|
||||
n->type->type = T_USER;
|
||||
|
|
@ -2584,11 +2689,11 @@ cpp_pragma : PRAGMA ID stylearg {
|
|||
} else {
|
||||
/* Generate some code for a new class */
|
||||
|
||||
Nested *n = new Nested;
|
||||
Nested *n = (Nested *) malloc(sizeof(Nested));
|
||||
n->code = NewString("");
|
||||
Printv(n->code, "typedef ", $1, " " ,
|
||||
Char(CCode), " $classname_", $4.id, ";\n",0);
|
||||
n->name = copy_string($4.id);
|
||||
n->name = Swig_copy_string($4.id);
|
||||
n->line = start_line;
|
||||
n->type = NewDataType(0);
|
||||
n->type->type = T_USER;
|
||||
|
|
@ -2739,13 +2844,13 @@ inherit : COLON base_list {
|
|||
|
||||
base_list : base_specifier {
|
||||
int i;
|
||||
$$.names = new char *[NI_NAMES];
|
||||
$$.names = (char **) malloc(NI_NAMES*sizeof(char *));
|
||||
$$.count = 0;
|
||||
for (i = 0; i < NI_NAMES; i++){
|
||||
$$.names[i] = (char *) 0;
|
||||
}
|
||||
if ($1) {
|
||||
$$.names[$$.count] = copy_string($1);
|
||||
$$.names[$$.count] = Swig_copy_string($1);
|
||||
$$.count++;
|
||||
}
|
||||
}
|
||||
|
|
@ -2753,7 +2858,7 @@ base_list : base_specifier {
|
|||
| base_list COMMA base_specifier {
|
||||
$$ = $1;
|
||||
if ($3) {
|
||||
$$.names[$$.count] = copy_string($3);
|
||||
$$.names[$$.count] = Swig_copy_string($3);
|
||||
$$.count++;
|
||||
}
|
||||
}
|
||||
|
|
@ -2864,8 +2969,8 @@ objective_c : OC_INTERFACE ID objc_inherit {
|
|||
cplus_class_close($2);
|
||||
cplus_mode = CPLUS_PUBLIC;
|
||||
ObjCClass = 0;
|
||||
delete $2;
|
||||
delete $3;
|
||||
free($2);
|
||||
free($3);
|
||||
}
|
||||
/* An obj-c category declaration */
|
||||
| OC_INTERFACE ID LPAREN ID RPAREN objc_protolist {
|
||||
|
|
@ -2887,10 +2992,10 @@ objective_c : OC_INTERFACE ID objc_inherit {
|
|||
if ($3.names[i]) {
|
||||
iname = make_name($3.names[i]);
|
||||
lang->cpp_class_decl($3.names[i],iname,(char*)"");
|
||||
delete [] $3.names[i];
|
||||
free($3.names[i]);
|
||||
}
|
||||
}
|
||||
delete [] $3.names;
|
||||
free($3.names);
|
||||
}
|
||||
;
|
||||
|
||||
|
|
@ -3075,7 +3180,7 @@ objc_method : MINUS objc_ret_type ID objc_args objc_end {
|
|||
cplus_member_func($3,iname,$2,$4,0);
|
||||
scanner_clear_start();
|
||||
DelDataType($2);
|
||||
delete $3;
|
||||
free($3);
|
||||
DelParmList($4);
|
||||
}
|
||||
}
|
||||
|
|
@ -3093,7 +3198,7 @@ objc_method : MINUS objc_ret_type ID objc_args objc_end {
|
|||
}
|
||||
scanner_clear_start();
|
||||
DelDataType($2);
|
||||
delete $3;
|
||||
free($3);
|
||||
DelParmList($4);
|
||||
}
|
||||
;
|
||||
|
|
@ -3140,11 +3245,11 @@ objc_args : objc_args objc_separator objc_arg_type ID {
|
|||
}
|
||||
;
|
||||
|
||||
objc_separator : COLON { $$ = copy_string((char*)":"); }
|
||||
| ID COLON { $$ = new char[strlen($1)+2];
|
||||
objc_separator : COLON { $$ = Swig_copy_string((char*)":"); }
|
||||
| ID COLON { $$ = (char *) malloc(strlen($1)+2);
|
||||
strcpy($$,$1);
|
||||
strcat($$,":");
|
||||
delete $1;
|
||||
free($1);
|
||||
}
|
||||
;
|
||||
|
||||
|
|
@ -3154,8 +3259,8 @@ objc_separator : COLON { $$ = copy_string((char*)":"); }
|
|||
|
||||
stylelist : ID stylearg styletail {
|
||||
$$ = $3;
|
||||
$$.names[$$.count] = copy_string($1);
|
||||
$$.values[$$.count] = copy_string($2);
|
||||
$$.names[$$.count] = Swig_copy_string($1);
|
||||
$$.values[$$.count] = Swig_copy_string($2);
|
||||
format_string($$.values[$$.count]);
|
||||
$$.count++;
|
||||
}
|
||||
|
|
@ -3164,14 +3269,14 @@ stylelist : ID stylearg styletail {
|
|||
|
||||
styletail : styletail COMMA ID stylearg {
|
||||
$$ = $1;
|
||||
$$.names[$$.count] = copy_string($3);
|
||||
$$.values[$$.count] = copy_string($4);
|
||||
$$.names[$$.count] = Swig_copy_string($3);
|
||||
$$.values[$$.count] = Swig_copy_string($4);
|
||||
format_string($$.values[$$.count]);
|
||||
$$.count++;
|
||||
}
|
||||
| empty {
|
||||
$$.names = new char *[NI_NAMES];
|
||||
$$.values = new char *[NI_NAMES];
|
||||
$$.names = (char **) malloc(NI_NAMES*sizeof(char *));
|
||||
$$.values = (char **) malloc(NI_NAMES*sizeof(char *));
|
||||
$$.count = 0;
|
||||
}
|
||||
;
|
||||
|
|
@ -3196,7 +3301,7 @@ tm_method : ID {
|
|||
$$ = $1;
|
||||
}
|
||||
| CONST {
|
||||
$$ = copy_string((char*)"const");
|
||||
$$ = Swig_copy_string((char*)"const");
|
||||
}
|
||||
;
|
||||
|
||||
|
|
@ -3218,15 +3323,15 @@ typemap_parm : type typemap_name {
|
|||
$1->is_pointer++;
|
||||
DataType_set_arraystr($1,Char(ArrayString));
|
||||
}
|
||||
$$ = new TMParm;
|
||||
$$ = NewTMParm();
|
||||
$$->p = NewParm($1,$2);
|
||||
$$->args = tm_parm;
|
||||
DelDataType($1);
|
||||
delete $2;
|
||||
free($2);
|
||||
}
|
||||
|
||||
| type stars typemap_name {
|
||||
$$ = new TMParm;
|
||||
$$ = NewTMParm();
|
||||
$$->p = NewParm($1,$3);
|
||||
DataType *pt = Parm_Gettype($$->p);
|
||||
pt->is_pointer += $2;
|
||||
|
|
@ -3236,11 +3341,11 @@ typemap_parm : type typemap_name {
|
|||
}
|
||||
$$->args = tm_parm;
|
||||
DelDataType($1);
|
||||
delete $3;
|
||||
free($3);
|
||||
}
|
||||
|
||||
| type AND typemap_name {
|
||||
$$ = new TMParm;
|
||||
$$ = NewTMParm();
|
||||
$$->p = NewParm($1,$3);
|
||||
DataType *pt = Parm_Gettype($$->p);
|
||||
pt->is_reference = 1;
|
||||
|
|
@ -3250,12 +3355,12 @@ typemap_parm : type typemap_name {
|
|||
}
|
||||
$$->args = tm_parm;
|
||||
DelDataType($1);
|
||||
delete $3;
|
||||
free($3);
|
||||
}
|
||||
| type LPAREN stars typemap_name RPAREN LPAREN parms RPAREN {
|
||||
fprintf(stderr,"%s : Line %d. Error. Function pointer not allowed (remap with typedef).\n", input_file, line_number);
|
||||
FatalError();
|
||||
$$ = new TMParm;
|
||||
$$ = NewTMParm();
|
||||
$$->p = NewParm($1,$4);
|
||||
DataType *pt = Parm_Gettype($$->p);
|
||||
pt->type = T_ERROR;
|
||||
|
|
@ -3263,7 +3368,7 @@ typemap_parm : type typemap_name {
|
|||
strcpy(pt->name,"<function ptr>");
|
||||
$$->args = tm_parm;
|
||||
DelDataType($1);
|
||||
delete $4;
|
||||
free($4);
|
||||
DelParmList($7);
|
||||
}
|
||||
;
|
||||
|
|
@ -3284,14 +3389,14 @@ typemap_name : ID typemap_args {
|
|||
| array {
|
||||
ArrayBackup = Copy(ArrayString);
|
||||
} typemap_args {
|
||||
$$ = new char[1];
|
||||
$$ = (char *) malloc(1);
|
||||
$$[0] = 0;
|
||||
InArray = $1;
|
||||
Clear(ArrayString);
|
||||
Append(ArrayString,ArrayBackup);
|
||||
Delete(ArrayBackup);
|
||||
}
|
||||
| typemap_args { $$ = new char[1];
|
||||
| typemap_args { $$ = (char *) malloc(1);
|
||||
$$[0] = 0;
|
||||
InArray = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ void scanner_init() {
|
|||
void scanner_file(FILE *f) {
|
||||
InFile *in;
|
||||
|
||||
in = new InFile;
|
||||
in = (InFile *) malloc(sizeof(InFile));
|
||||
in->f = f;
|
||||
in->in_file = input_file;
|
||||
in->extern_mode = WrapExtern;
|
||||
|
|
@ -134,7 +134,7 @@ void scanner_close() {
|
|||
} else {
|
||||
LEX_in = NULL;
|
||||
}
|
||||
delete in_head;
|
||||
free(in_head);
|
||||
in_head = p;
|
||||
}
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ char nextchar() {
|
|||
if (inline_lex_pos >= inline_lex_len) {
|
||||
// Done with inlined code. Check to see if we have any
|
||||
// new code fragments. If so, switch to them.
|
||||
delete inline_yybuffer;
|
||||
free(inline_yybuffer);
|
||||
if (fragments) {
|
||||
CodeFragment *f;
|
||||
inline_yybuffer = fragments->text;
|
||||
|
|
@ -162,7 +162,7 @@ char nextchar() {
|
|||
inline_lex_len = strlen(fragments->text);
|
||||
line_number = fragments->line_number;
|
||||
f = fragments->next;
|
||||
delete fragments;
|
||||
free(fragments);
|
||||
fragments = f;
|
||||
c = inline_yybuffer[0];
|
||||
} else {
|
||||
|
|
@ -260,8 +260,8 @@ void start_inline(char *text, int line) {
|
|||
CodeFragment *f,*f1;
|
||||
|
||||
// Add a new code fragment to our list
|
||||
f = new CodeFragment;
|
||||
f->text = copy_string(text);
|
||||
f = (CodeFragment *) malloc(sizeof(CodeFragment));
|
||||
f->text = Swig_copy_string(text);
|
||||
f->line_number = line;
|
||||
f->next = 0;
|
||||
if (!fragments) fragments = f;
|
||||
|
|
@ -275,7 +275,7 @@ void start_inline(char *text, int line) {
|
|||
// Switch our scanner over to process text from a string.
|
||||
// Save current line number and other information however.
|
||||
|
||||
inline_yybuffer = copy_string(text);
|
||||
inline_yybuffer = Swig_copy_string(text);
|
||||
inline_lex_len = strlen(text);
|
||||
inline_lex_pos = 0;
|
||||
inline_line_number = line_number; // Make copy of old line number
|
||||
|
|
@ -476,7 +476,7 @@ int skip_cond(int inthen) {
|
|||
int start_line;
|
||||
char *file;
|
||||
|
||||
file = copy_string(input_file);
|
||||
file = Swig_copy_string(input_file);
|
||||
start_line = line_number;
|
||||
yylen = 0;
|
||||
|
||||
|
|
@ -545,7 +545,7 @@ int skip_cond(int inthen) {
|
|||
state = 0;
|
||||
} else {
|
||||
yylen = 0;
|
||||
delete file;
|
||||
free(file);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -555,7 +555,7 @@ int skip_cond(int inthen) {
|
|||
} else if ((strcmp(yytext,"#endif") == 0) || (strcmp(yytext,"%endif") == 0)) {
|
||||
if (level <= 0) { /* Found matching endif. exit */
|
||||
yylen = 0;
|
||||
delete file;
|
||||
free(file);
|
||||
return 0;
|
||||
} else {
|
||||
state = 0;
|
||||
|
|
@ -566,7 +566,7 @@ int skip_cond(int inthen) {
|
|||
if (level <= 0) {
|
||||
// If we come across this, we pop it back onto the input queue and return
|
||||
retract(6);
|
||||
delete file;
|
||||
free(file);
|
||||
return 0;
|
||||
} else {
|
||||
yylen = 0;
|
||||
|
|
@ -778,7 +778,7 @@ int yylook(void) {
|
|||
}
|
||||
if (c == '\"') {
|
||||
yytext[yylen-1] = 0;
|
||||
yylval.id = copy_string(yytext+1);
|
||||
yylval.id = Swig_copy_string(yytext+1);
|
||||
return(STRING);
|
||||
} else if (c == '\\') {
|
||||
state = 21; /* Possibly an escape sequence. */
|
||||
|
|
@ -902,7 +902,7 @@ int yylook(void) {
|
|||
else if ((c == 'e') || (c == 'E')) {state = 86;}
|
||||
else if ((c == 'f') || (c == 'F')) {
|
||||
yytext[yylen] = 0;
|
||||
yylval.id = copy_string(yytext);
|
||||
yylval.id = Swig_copy_string(yytext);
|
||||
return(NUM_FLOAT);
|
||||
}
|
||||
else if (isdigit(c)) { state = 8;}
|
||||
|
|
@ -913,7 +913,7 @@ int yylook(void) {
|
|||
} else {
|
||||
retract(1);
|
||||
yytext[yylen] = 0;
|
||||
yylval.id = copy_string(yytext);
|
||||
yylval.id = Swig_copy_string(yytext);
|
||||
return(NUM_INT);
|
||||
}
|
||||
break;
|
||||
|
|
@ -923,12 +923,12 @@ int yylook(void) {
|
|||
else if ((c == 'e') || (c == 'E')) state = 82;
|
||||
else if ((c == 'f') || (c == 'F') || (c == 'l') || (c == 'L')) {
|
||||
yytext[yylen] = 0;
|
||||
yylval.id = copy_string(yytext);
|
||||
yylval.id = Swig_copy_string(yytext);
|
||||
return(NUM_FLOAT);
|
||||
} else {
|
||||
retract(1);
|
||||
yytext[yylen] = 0;
|
||||
yylval.id = copy_string(yytext);
|
||||
yylval.id = Swig_copy_string(yytext);
|
||||
return(NUM_FLOAT);
|
||||
}
|
||||
break;
|
||||
|
|
@ -938,7 +938,7 @@ int yylook(void) {
|
|||
else {
|
||||
retract(2);
|
||||
yytext[yylen-1] = 0;
|
||||
yylval.id = copy_string(yytext);
|
||||
yylval.id = Swig_copy_string(yytext);
|
||||
return(NUM_INT);
|
||||
}
|
||||
break;
|
||||
|
|
@ -955,7 +955,7 @@ int yylook(void) {
|
|||
} else {
|
||||
retract(1);
|
||||
yytext[yylen] = 0;
|
||||
yylval.id = copy_string(yytext);
|
||||
yylval.id = Swig_copy_string(yytext);
|
||||
return(NUM_INT);
|
||||
}
|
||||
break;
|
||||
|
|
@ -970,7 +970,7 @@ int yylook(void) {
|
|||
} else {
|
||||
retract(1);
|
||||
yytext[yylen] = 0;
|
||||
yylval.id = copy_string(yytext);
|
||||
yylval.id = Swig_copy_string(yytext);
|
||||
return(NUM_INT);
|
||||
}
|
||||
break;
|
||||
|
|
@ -989,7 +989,7 @@ int yylook(void) {
|
|||
} else {
|
||||
retract(1);
|
||||
yytext[yylen] = 0;
|
||||
yylval.id = copy_string(yytext);
|
||||
yylval.id = Swig_copy_string(yytext);
|
||||
return(NUM_INT);
|
||||
}
|
||||
break;
|
||||
|
|
@ -1001,12 +1001,12 @@ int yylook(void) {
|
|||
if (isdigit(c)) state = 86;
|
||||
else if ((c == 'f') || (c == 'F') || (c == 'l') || (c == 'L')) {
|
||||
yytext[yylen] = 0;
|
||||
yylval.id = copy_string(yytext);
|
||||
yylval.id = Swig_copy_string(yytext);
|
||||
return(NUM_FLOAT);
|
||||
} else {
|
||||
retract(1);
|
||||
yytext[yylen] = 0;
|
||||
yylval.id = copy_string(yytext);
|
||||
yylval.id = Swig_copy_string(yytext);
|
||||
return(NUM_FLOAT);
|
||||
}
|
||||
/* Parse a character constant. ie. 'a' */
|
||||
|
|
@ -1017,12 +1017,12 @@ int yylook(void) {
|
|||
if ((c = nextchar()) == 0) return (0);
|
||||
if ((c == 'u') || (c == 'U')) {
|
||||
yytext[yylen] = 0;
|
||||
yylval.id = copy_string(yytext);
|
||||
yylval.id = Swig_copy_string(yytext);
|
||||
return(NUM_ULONG);
|
||||
} else {
|
||||
retract(1);
|
||||
yytext[yylen] = 0;
|
||||
yylval.id = copy_string(yytext);
|
||||
yylval.id = Swig_copy_string(yytext);
|
||||
return(NUM_LONG);
|
||||
}
|
||||
|
||||
|
|
@ -1031,12 +1031,12 @@ int yylook(void) {
|
|||
if ((c = nextchar()) == 0) return (0);
|
||||
if ((c == 'l') || (c == 'L')) {
|
||||
yytext[yylen] = 0;
|
||||
yylval.id = copy_string(yytext);
|
||||
yylval.id = Swig_copy_string(yytext);
|
||||
return(NUM_ULONG);
|
||||
} else {
|
||||
retract(1);
|
||||
yytext[yylen] = 0;
|
||||
yylval.id = copy_string(yytext);
|
||||
yylval.id = Swig_copy_string(yytext);
|
||||
return(NUM_UNSIGNED);
|
||||
}
|
||||
|
||||
|
|
@ -1045,7 +1045,7 @@ int yylook(void) {
|
|||
if (c == '\\') state = 91;
|
||||
else if (c == '\'') {
|
||||
yytext[yylen-1] = 0;
|
||||
yylval.id = copy_string(yytext+1);
|
||||
yylval.id = Swig_copy_string(yytext+1);
|
||||
return(CHARCONST);
|
||||
}
|
||||
break;
|
||||
|
|
@ -1171,7 +1171,7 @@ extern "C" int yylex(void) {
|
|||
}
|
||||
if (strcmp(yytext,"signed") == 0) {
|
||||
yylval.type = NewDataType(0);
|
||||
yylval.type->type = T_SINT;
|
||||
yylval.type->type = T_INT;
|
||||
strcpy(yylval.type->name,yytext);
|
||||
return(TYPE_SIGNED);
|
||||
}
|
||||
|
|
@ -1308,7 +1308,7 @@ extern "C" int yylex(void) {
|
|||
}
|
||||
}
|
||||
|
||||
yylval.id = copy_string(yytext);
|
||||
yylval.id = Swig_copy_string(yytext);
|
||||
return(ID);
|
||||
default:
|
||||
return(l);
|
||||
|
|
|
|||
|
|
@ -1,106 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* sstring.cxx
|
||||
*
|
||||
* SWIG string object.
|
||||
*
|
||||
* Note: 6/27/2000 - This module is now just a wrapper around a DOHString.
|
||||
*
|
||||
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||
*
|
||||
* Copyright (C) 1998-2000. The University of Chicago
|
||||
* Copyright (C) 1995-1998. The University of Utah and The Regents of the
|
||||
* University of California.
|
||||
*
|
||||
* See the file LICENSE for information on usage and redistribution.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static char cvsroot[] = "$Header$";
|
||||
|
||||
#include "internal.h"
|
||||
#include <ctype.h>
|
||||
extern "C" {
|
||||
#include "doh.h"
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// char *copy_string(char *str)
|
||||
//
|
||||
// Makes a copy of string str. Returns a pointer to it.
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
char *copy_string(char *str) {
|
||||
char *res = 0;
|
||||
if (str) {
|
||||
res = new char[strlen(str)+1];
|
||||
strcpy(res,str);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// void format_string(char *str)
|
||||
//
|
||||
// Replace all of the escape sequences in the string str. It is
|
||||
// assumed that the new string is smaller than the original!
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void format_string(char *str) {
|
||||
char *newstr, *c,*c1;
|
||||
int state;
|
||||
if (!str) return;
|
||||
newstr = copy_string(str);
|
||||
c = newstr;
|
||||
c1 = str;
|
||||
state = 0;
|
||||
while (*c) {
|
||||
switch(state) {
|
||||
case 0:
|
||||
if (*c == '\\')
|
||||
state = 1;
|
||||
else {
|
||||
*(c1++) = *c;
|
||||
state = 0;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
// We're in a simple escape sequence figure out what to do
|
||||
switch(*c) {
|
||||
case 'n':
|
||||
*(c1++) = '\n';
|
||||
break;
|
||||
case 'f':
|
||||
*(c1++) = '\f';
|
||||
break;
|
||||
case 'r':
|
||||
*(c1++) = '\r';
|
||||
break;
|
||||
case 't':
|
||||
*(c1++) = '\t';
|
||||
break;
|
||||
case '\\':
|
||||
*(c1++) = '\\';
|
||||
break;
|
||||
case '\"':
|
||||
*(c1++) = '\"';
|
||||
break;
|
||||
case '\'':
|
||||
*(c1++) = '\'';
|
||||
break;
|
||||
default:
|
||||
*(c1++) = '\\';
|
||||
*(c1++) = *c;
|
||||
}
|
||||
state = 0;
|
||||
break;
|
||||
default:
|
||||
*(c1++) = *c;
|
||||
state = 0;
|
||||
}
|
||||
c++;
|
||||
}
|
||||
*c1 = 0;
|
||||
delete newstr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -55,7 +55,6 @@ extern int Inline; // Inline mode
|
|||
extern int NoInclude; // NoInclude flag
|
||||
extern char *typemap_lang; // Current language name
|
||||
extern int error_count;
|
||||
extern char *copy_string(char *);
|
||||
extern char output_dir[512]; // Output directory
|
||||
extern int Verbose;
|
||||
extern int IsVirtual;
|
||||
|
|
@ -219,10 +218,9 @@ public:
|
|||
|
||||
/* Emit functions */
|
||||
|
||||
extern void emit_extern_var(char *, DataType *, int, FILE *);
|
||||
extern void emit_extern_func(char *, DataType *, ParmList *, int, FILE *);
|
||||
extern void emit_func_call(char *, DataType *, ParmList *, FILE *);
|
||||
extern void emit_set_get(char *, char *, DataType *);
|
||||
extern void emit_set_action(DOHString_or_char *decl);
|
||||
|
||||
extern int SWIG_main(int, char **, Language *);
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ struct TypeMap {
|
|||
ParmList *args; // Local variables (if any)
|
||||
|
||||
TypeMap(char *l, DataType *t, char *c, ParmList *p = 0) {
|
||||
lang = copy_string(l);
|
||||
lang = Swig_copy_string(l);
|
||||
type = CopyDataType(t);
|
||||
code = NewString(c);
|
||||
first = type_id;
|
||||
|
|
@ -90,7 +90,7 @@ struct TypeMap {
|
|||
}
|
||||
}
|
||||
TypeMap(char *l, char *c) {
|
||||
lang = copy_string(l);
|
||||
lang = Swig_copy_string(l);
|
||||
type = 0;
|
||||
code = NewString(c);
|
||||
first = type_id;
|
||||
|
|
@ -100,7 +100,7 @@ struct TypeMap {
|
|||
args = 0;
|
||||
}
|
||||
TypeMap(TypeMap *t) {
|
||||
lang = copy_string(t->lang);
|
||||
lang = Swig_copy_string(t->lang);
|
||||
type = CopyDataType(t->type);
|
||||
code = Copy(t->code);
|
||||
first = type_id;
|
||||
|
|
@ -126,7 +126,7 @@ struct TmMethod {
|
|||
DataType *type; // Typemap type
|
||||
TmMethod *next; // Next method
|
||||
TmMethod(char *n, DataType *t, TmMethod *m = 0) {
|
||||
if (n) name = copy_string(n);
|
||||
if (n) name = Swig_copy_string(n);
|
||||
else name = 0;
|
||||
if (t) {
|
||||
type = CopyDataType(t);
|
||||
|
|
@ -310,7 +310,6 @@ void typemap_register(char *op, char *lang, DataType *type, char *pname,
|
|||
Parm *p;
|
||||
p = ParmList_first(tm->args);
|
||||
while (p) {
|
||||
DataType *pt = Parm_Gettype(p);
|
||||
char *pn = Parm_Getname(p);
|
||||
if (pn) {
|
||||
// printf(" %s %s\n", pt,pn);
|
||||
|
|
@ -711,7 +710,7 @@ char *typemap_lookup(char *op, char *lang, DataType *type, char *pname, char *so
|
|||
// Copy old array string (just in case)
|
||||
|
||||
if (DataType_arraystr(m->type))
|
||||
oldary = copy_string(DataType_arraystr(m->type));
|
||||
oldary = Swig_copy_string(DataType_arraystr(m->type));
|
||||
else
|
||||
oldary = 0;
|
||||
|
||||
|
|
@ -738,7 +737,7 @@ char *typemap_lookup(char *op, char *lang, DataType *type, char *pname, char *so
|
|||
result = typemap_lookup_internal(op,lang,m->type,ppname,source,target,f);
|
||||
DataType_set_arraystr(m->type,oldary);
|
||||
if (oldary)
|
||||
delete oldary;
|
||||
free(oldary);
|
||||
m->type->is_pointer -= drop_pointer;
|
||||
if (result) {
|
||||
type->is_pointer += drop_pointer;
|
||||
|
|
@ -827,7 +826,7 @@ char *typemap_check_internal(char *op, char *lang, DataType *type, char *pname)
|
|||
Printf(str,"%s",tm->code);
|
||||
|
||||
// Return character string
|
||||
Char(str);
|
||||
return Char(str);
|
||||
}
|
||||
|
||||
// Function for checking with applications
|
||||
|
|
@ -871,7 +870,7 @@ char *typemap_check(char *op, char *lang, DataType *type, char *pname) {
|
|||
else ppname = pname;
|
||||
m->type->is_pointer += drop_pointer;
|
||||
if (DataType_arraystr(m->type))
|
||||
oldary = copy_string(DataType_arraystr(m->type));
|
||||
oldary = Swig_copy_string(DataType_arraystr(m->type));
|
||||
else
|
||||
oldary = 0;
|
||||
|
||||
|
|
@ -895,7 +894,7 @@ char *typemap_check(char *op, char *lang, DataType *type, char *pname) {
|
|||
}
|
||||
result = typemap_check_internal(op,lang,m->type,ppname);
|
||||
DataType_set_arraystr(m->type,oldary);
|
||||
if (oldary) delete oldary;
|
||||
if (oldary) free(oldary);
|
||||
m->type->is_pointer -= drop_pointer;
|
||||
if (result) {
|
||||
type->is_pointer += drop_pointer;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue