diff --git a/Source/SWIG1.1/cplus.cxx b/Source/SWIG1.1/cplus.cxx index 7bcb81dfc..52b4fcd43 100644 --- a/Source/SWIG1.1/cplus.cxx +++ b/Source/SWIG1.1/cplus.cxx @@ -2061,7 +2061,7 @@ void cplus_emit_constructor(char *classname, char *classtype, char *classrename, if (p->call_type & CALL_REFERENCE) { pt->is_pointer--; } - Printf(wrap, DataType_print_real(pt,Parm_Getname(p))); + Printf(wrap, DataType_str(pt,Parm_Getname(p))); if (p->call_type & CALL_REFERENCE) { pt->is_pointer++; } @@ -2399,7 +2399,7 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename } Printv(wrap, "static ", DataType_print_type(type), " ", cname, "(", - classtype, classname, " *obj, ", DataType_print_real(type,(char*)"val"), ") {\n", + classtype, classname, " *obj, ", DataType_str(type,(char*)"val"), ") {\n", 0); if (is_user) { type->is_pointer--; @@ -2432,7 +2432,7 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename char temp[512]; Printv(wrap, "static ", DataType_print_type(type), " ", cname, "(", - classtype, classname, " *obj, ", DataType_print_real(type,(char*)"val"), ") {\n", + classtype, classname, " *obj, ", DataType_str(type,(char*)"val"), ") {\n", 0); sprintf(temp,"obj->%s",mname); if (CPlusPlus) { diff --git a/Source/Swig/oldparms.c b/Source/Swig/oldparms.c index 3f8bb3d5d..a170ceaf9 100644 --- a/Source/Swig/oldparms.c +++ b/Source/Swig/oldparms.c @@ -291,20 +291,20 @@ void ParmList_print_types(ParmList *l, DOHFile *f) { while(pn < l->nparms) { t = Parm_Gettype(l->parms[pn]); is_pointer = t->is_pointer; - if (t->is_reference) { + /* if (t->is_reference) { if (t->is_pointer) { t->is_pointer--; - Printf(f,"%s&", DataType_print_real(t,0)); + Printf(f,"%s&", DataType_str(t,0)); t->is_pointer++; } else { - Printf(f,"%s&", DataType_print_real(t,0)); + Printf(f,"%s&", DataType_str(t,0)); } - } else { + } else { */ if (l->parms[pn]->call_type & CALL_VALUE) t->is_pointer++; if (l->parms[pn]->call_type & CALL_REFERENCE) t->is_pointer--; - Printf(f,"%s", DataType_print_real(t,0)); + Printf(f,"%s", DataType_str(t,0)); t->is_pointer = is_pointer; - } + /* }*/ pn++; if (pn < l->nparms) Printf(f,","); @@ -326,7 +326,7 @@ void ParmList_print_args(ParmList *l, DOHFile *f) { while(pn < l->nparms) { t = Parm_Gettype(l->parms[pn]); is_pointer = t->is_pointer; - if (t->is_reference) { + /* if (t->is_reference) { if (t->is_pointer) { t->is_pointer--; Printf(f,"%s&", DataType_print_full(t)); @@ -335,11 +335,16 @@ void ParmList_print_args(ParmList *l, DOHFile *f) { Printf(f,"%s&", DataType_print_full(t)); } } else { + */ + if (l->parms[pn]->call_type & CALL_VALUE) t->is_pointer++; if (l->parms[pn]->call_type & CALL_REFERENCE) t->is_pointer--; - Printf(f,"%s", DataType_print_full(t)); + Printf(f,"%s", DataType_str(t,0)); + t->is_pointer = is_pointer; + /* } + */ Printf(f,"%s",Parm_Getname(l->parms[pn])); pn++; if (pn < l->nparms) diff --git a/Source/Swig/oldtypes.c b/Source/Swig/oldtypes.c index a74977c3f..10eb0aa70 100644 --- a/Source/Swig/oldtypes.c +++ b/Source/Swig/oldtypes.c @@ -234,30 +234,6 @@ char *DataType_print_full(DataType *t) { } } -/* -------------------------------------------------------------------- - * char *print_real() - * - * Prints real type, with qualifiers and arrays if necessary. - * -------------------------------------------------------------------- */ -char *DataType_print_real(DataType *t, char *local) { - static char result[8][256]; - static int ri = 0; - int oldstatus; - - oldstatus = t->status; - t->status = t->status & (~STAT_REPLACETYPE); - ri = ri % 8; - if (t->_arraystr) t->is_pointer--; - strcpy(result[ri], DataType_print_full(t)); - if (local) strcat(result[ri],local); - if (t->_arraystr) { - strcat(result[ri],t->_arraystr); - t->is_pointer++; - } - t->status = oldstatus; - return result[ri++]; -} - /* -------------------------------------------------------------------- * char *print_cast() * @@ -377,6 +353,40 @@ void DataType_set_mangle(char *(*m)(DataType *t)) { mangler = m; } +/* ----------------------------------------------------------------------------- + * char *DataType_str() + * + * Produces an exact string representation of the datatype along with an optional + * variable name. + * ----------------------------------------------------------------------------- */ + +char *DataType_str(DataType *t, char *name) { + static char result[8][256]; + static int ri = 0; + int i; + + ri = ri % 8; + if (t->_arraystr) t->is_pointer--; + if (t->is_reference) t->is_pointer--; + if (t->_qualifier) { + sprintf(result[ri],"%s %s", t->_qualifier, t->name); + } else { + sprintf(result[ri],"%s ", t->name); + } + + for (i = 0; i < (t->is_pointer-t->implicit_ptr); i++) { + strcat(result[ri],"*"); + } + if (t->is_reference) strcat(result[ri],"&"); + if (name) strcat(result[ri],name); + if (t->_arraystr) { + strcat(result[ri],t->_arraystr); + t->is_pointer++; + } + if (t->is_reference) t->is_pointer++; + return result[ri++]; +} + /* -------------------------------------------------------------------- * int DataType_array_dimensions() * diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 6e57f7677..59e885a73 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -235,10 +235,10 @@ extern void Swig_banner(DOHFile *f); typedef struct DataType { int type; /* SWIG Type code */ char name[MAX_NAME]; /* Name of type */ - char is_pointer; /* Is this a pointer */ - char implicit_ptr; /* Implicit ptr */ - char is_reference; /* A C++ reference type */ - char status; /* Is this datatype read-only? */ + int is_pointer; /* Is this a pointer */ + int implicit_ptr; /* Implicit ptr */ + int is_reference; /* A C++ reference type */ + int status; /* Is this datatype read-only? */ char *_qualifier; /* A qualifier string (ie. const). */ char *_arraystr; /* String containing array part */ int id; /* type identifier (unique for every type). */ @@ -248,6 +248,12 @@ extern DataType *NewDataType(int type); extern DataType *CopyDataType(DataType *type); extern void DelDataType(DataType *type); +/* -- New type interface -- */ + +extern char *DataType_str(DataType *, char *name); /* Exact datatype */ + +/* -- Old type interface -- */ + extern char *DataType_qualifier(DataType *); extern void DataType_set_qualifier(DataType *, char *q); extern char *DataType_arraystr(DataType *); @@ -258,7 +264,6 @@ extern char *DataType_print_type(DataType *); extern char *DataType_print_full(DataType *); extern char *DataType_print_cast(DataType *); extern char *DataType_print_mangle(DataType *); -extern char *DataType_print_real(DataType *, char *local); extern char *DataType_print_arraycast(DataType *); extern char *DataType_print_mangle_default(DataType *); extern void DataType_set_mangle(char *(*m)(DataType *));