Class interface to DataType is gone.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@570 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2000-07-12 04:40:12 +00:00
commit 20fa159d56
16 changed files with 424 additions and 431 deletions

View file

@ -354,7 +354,7 @@ GUILE::get_pointer (char *iname, int parm, DataType *t,
if (t->type == T_VOID) if (t->type == T_VOID)
Printf(f->code, ", (char *) 0)) {\n"); Printf(f->code, ", (char *) 0)) {\n");
else else
Printv(f->code, ", \"", t->print_mangle(), "\")) {\n", 0); Printv(f->code, ", \"", DataType_print_mangle(t), "\")) {\n", 0);
/* Raise exception */ /* Raise exception */
Printv(f->code, Printv(f->code,
tab8, tab8,
@ -529,8 +529,8 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
Printv(f->code, tab4, Printv(f->code, tab4,
"gswig_result = SWIG_Guile_MakePtr_Str (", "gswig_result = SWIG_Guile_MakePtr_Str (",
"_result, ", "_result, ",
"\"", d->print_mangle(), "\", ", "\"", DataType_print_mangle(d), "\", ",
"\"", d->print_type(), "\"", "\"", DataType_print_type(d), "\"",
");\n", ");\n",
0); 0);
} }
@ -659,7 +659,7 @@ GUILE::link_variable (char *name, char *iname, DataType *t)
if (t->type == T_VOID) if (t->type == T_VOID)
Printf (f_wrappers, "(char *) 0)) {\n"); Printf (f_wrappers, "(char *) 0)) {\n");
else else
Printf (f_wrappers, "\"%s\")) {\n", t->print_mangle()); Printf (f_wrappers, "\"%s\")) {\n", DataType_print_mangle(t));
/* Raise exception */ /* Raise exception */
Printf(f_wrappers, "\tscm_wrong_type_arg(\"%s\", " Printf(f_wrappers, "\tscm_wrong_type_arg(\"%s\", "
"%d, s_0);\n", proc_name, 1); "%d, s_0);\n", proc_name, 1);
@ -686,8 +686,8 @@ GUILE::link_variable (char *name, char *iname, DataType *t)
/* MK: I would like to use SWIG_Guile_MakePtr here to save one type /* MK: I would like to use SWIG_Guile_MakePtr here to save one type
look-up. */ look-up. */
Printf (f_wrappers, "\t gswig_result = SWIG_Guile_MakePtr_Str (" Printf (f_wrappers, "\t gswig_result = SWIG_Guile_MakePtr_Str ("
"%s, \"%s\", \"%s\");\n", name, t->print_mangle(), "%s, \"%s\", \"%s\");\n", name, DataType_print_mangle(t),
t->print_type()); DataType_print_type(t));
} }
} }
else { else {
@ -704,7 +704,7 @@ GUILE::link_variable (char *name, char *iname, DataType *t)
} else { } else {
Printf (stderr, "%s : Line %d. ** Warning. Unable to link with " Printf (stderr, "%s : Line %d. ** Warning. Unable to link with "
" type %s (ignored).\n", " type %s (ignored).\n",
input_file, line_number, t->print_type()); input_file, line_number, DataType_print_type(t));
} }
Delete(proc_name); Delete(proc_name);
} }
@ -756,7 +756,7 @@ GUILE::declare_const (char *name, char *, DataType *type, char *value)
} else { } else {
// Create variable and assign it a value // Create variable and assign it a value
Printf (f_header, "static %s %s = ", type->print_type(), var_name); Printf (f_header, "static %s %s = ", DataType_print_type(type), var_name);
if ((type->type == T_CHAR) && (type->is_pointer <= 1)) { if ((type->type == T_CHAR) && (type->is_pointer <= 1)) {
Printf (f_header, "\"%s\";\n", value); Printf (f_header, "\"%s\";\n", value);
} else { } else {
@ -881,7 +881,7 @@ GUILE::usage_returns (char *iname, DataType *d, ParmList *l, DOHString *usage)
Insert(param,0," unspecified "); Insert(param,0," unspecified ");
else { else {
Insert(param,0,"# "); Insert(param,0,"# ");
Insert(param,0, d->print_type()); Insert(param,0, DataType_print_type(d));
Insert(param,0," $"); Insert(param,0," $");
} }
} }

View file

@ -630,21 +630,21 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
Replace(f->code,"$arg",source, DOH_REPLACE_ANY); Replace(f->code,"$arg",source, DOH_REPLACE_ANY);
} else { } else {
if(!p->t->is_pointer) if(!p->t->is_pointer)
Printv(f->code, tab4, target, " = ", p->t->print_cast(), source, ";\n", 0); Printv(f->code, tab4, target, " = ", DataType_print_cast(p->t), source, ";\n", 0);
else if((p->t->type == T_VOID && p->t->is_pointer == 1) || else if((p->t->type == T_VOID && p->t->is_pointer == 1) ||
(p->t->type == T_USER && p->t->is_pointer == 1)) { (p->t->type == T_USER && p->t->is_pointer == 1)) {
p->t->is_pointer++; p->t->is_pointer++;
Printv(f->code, tab4, target, " = *", p->t->print_cast(), "&", source, ";\n", 0); Printv(f->code, tab4, target, " = *", DataType_print_cast(p->t), "&", source, ";\n", 0);
p->t->is_pointer--; p->t->is_pointer--;
} else { } else {
if(p->t->type == T_CHAR && p->t->is_pointer == 1) { if(p->t->type == T_CHAR && p->t->is_pointer == 1) {
Printv(f->code, tab4, target, " = (", source, ") ? (char *)", JNICALL((char*)"GetStringUTFChars"), source, ", 0) : NULL;\n", 0); Printv(f->code, tab4, target, " = (", source, ") ? (char *)", JNICALL((char*)"GetStringUTFChars"), source, ", 0) : NULL;\n", 0);
} else { } else {
char *scalarType = SwigTcToJniScalarType(p->t); char *scalarType = SwigTcToJniScalarType(p->t);
char *cptrtype = p->t->print_type(); char *cptrtype = DataType_print_type(p->t);
p->t->is_pointer--; p->t->is_pointer--;
const char *basic_jnitype = (p->t->is_pointer > 0) ? "jlong" : SwigTcToJniType(p->t, 0); const char *basic_jnitype = (p->t->is_pointer > 0) ? "jlong" : SwigTcToJniType(p->t, 0);
char *ctype = p->t->print_type(); char *ctype = DataType_print_type(p->t);
if(scalarType == NULL || basic_jnitype == NULL) { if(scalarType == NULL || basic_jnitype == NULL) {
Printf(stderr, "\'%s\' does not have a in/jni typemap, and is not a basic type.\n", ctype); Printf(stderr, "\'%s\' does not have a in/jni typemap, and is not a basic type.\n", ctype);
SWIG_exit(1); SWIG_exit(1);
@ -661,13 +661,13 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
DOHString *scalarFunc = NewStringf("Get%sArrayElements",scalarType); DOHString *scalarFunc = NewStringf("Get%sArrayElements",scalarType);
Printv(f->code, tab4, target_copy, " = ", JNICALL(scalarFunc), source, ", 0);\n", 0); Printv(f->code, tab4, target_copy, " = ", JNICALL(scalarFunc), source, ", 0);\n", 0);
Printv(f->code, tab4, target, " = ", p->t->print_cast(), " malloc(", target_length, " * sizeof(", ctype, "));\n", 0); Printv(f->code, tab4, target, " = ", DataType_print_cast(p->t), " malloc(", target_length, " * sizeof(", ctype, "));\n", 0);
Printv(f->code, tab4, "for(i=0; i<", target_length, "; i++)\n", 0); Printv(f->code, tab4, "for(i=0; i<", target_length, "; i++)\n", 0);
if(p->t->is_pointer > 1) { if(p->t->is_pointer > 1) {
Printv(f->code, tab8, target, "[i] = *", p->t->print_cast(), "&", target_copy, "[i];\n", 0); Printv(f->code, tab8, target, "[i] = *", DataType_print_cast(p->t), "&", target_copy, "[i];\n", 0);
} else { } else {
p->t->is_pointer--; p->t->is_pointer--;
Printv(f->code, tab8, target, "[i] = ", p->t->print_cast(), target_copy, "[i];\n", 0); Printv(f->code, tab8, target, "[i] = ", DataType_print_cast(p->t), target_copy, "[i];\n", 0);
p->t->is_pointer++; p->t->is_pointer++;
} }
Delete(scalarFunc); Delete(scalarFunc);
@ -705,10 +705,10 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
// nothing to do // nothing to do
} else { } else {
char *scalarType = SwigTcToJniScalarType(p->t); char *scalarType = SwigTcToJniScalarType(p->t);
char *cptrtype = p->t->print_type(); char *cptrtype = DataType_print_type(p->t);
p->t->is_pointer--; p->t->is_pointer--;
const char *basic_jnitype = (p->t->is_pointer > 0) ? "jlong" : SwigTcToJniType(p->t, 0); const char *basic_jnitype = (p->t->is_pointer > 0) ? "jlong" : SwigTcToJniType(p->t, 0);
char *ctype = p->t->print_type(); char *ctype = DataType_print_type(p->t);
if(scalarType == NULL || basic_jnitype == NULL) { if(scalarType == NULL || basic_jnitype == NULL) {
Printf(stderr, "\'%s\' does not have a argout/jni typemap, and is not a basic type.\n", ctype); Printf(stderr, "\'%s\' does not have a argout/jni typemap, and is not a basic type.\n", ctype);
SWIG_exit(1); SWIG_exit(1);
@ -716,7 +716,7 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
p->t->is_pointer++; p->t->is_pointer++;
Printf(outarg, " for(i=0; i< %d; i++)\n", target_length); Printf(outarg, " for(i=0; i< %d; i++)\n", target_length);
if(p->t->is_pointer > 1) { if(p->t->is_pointer > 1) {
Printv(outarg, tab8, "*", p->t->print_cast(), "&", target_copy, "[i] = ", target, "[i];\n", 0); Printv(outarg, tab8, "*", DataType_print_cast(p->t), "&", target_copy, "[i] = ", target, "[i];\n", 0);
} else { } else {
Printv(outarg, tab8, target_copy, "[i] = (", basic_jnitype, ") ", target, "[i];\n", 0); Printv(outarg, tab8, target_copy, "[i] = (", basic_jnitype, ") ", target, "[i];\n", 0);
} }
@ -753,23 +753,23 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
} else { } else {
if(t->is_pointer == 0 && t->type == T_USER) { /* return by value */ if(t->is_pointer == 0 && t->type == T_USER) { /* return by value */
t->is_pointer=2; t->is_pointer=2;
Printv(f->code, tab4, "*", t->print_cast(), "&_jresult = _result;\n", 0); Printv(f->code, tab4, "*", DataType_print_cast(t), "&_jresult = _result;\n", 0);
t->is_pointer=0; t->is_pointer=0;
} else if(t->is_pointer == 0 && t->type != T_USER) { } else if(t->is_pointer == 0 && t->type != T_USER) {
Printv(f->code, tab4, "_jresult = (", jnirettype, ") _result;\n", 0); Printv(f->code, tab4, "_jresult = (", jnirettype, ") _result;\n", 0);
} else if((t->type == T_VOID && t->is_pointer == 1) || } else if((t->type == T_VOID && t->is_pointer == 1) ||
(t->type == T_USER && t->is_pointer == 1)) { (t->type == T_USER && t->is_pointer == 1)) {
t->is_pointer++; t->is_pointer++;
Printv(f->code, tab4, "*", t->print_cast(), "&_jresult = _result;\n", 0); Printv(f->code, tab4, "*", DataType_print_cast(t), "&_jresult = _result;\n", 0);
t->is_pointer--; t->is_pointer--;
} else { } else {
if(t->type == T_CHAR && t->is_pointer == 1) { if(t->type == T_CHAR && t->is_pointer == 1) {
Printv(f->code, tab4, "if(_result != NULL)\n", 0); Printv(f->code, tab4, "if(_result != NULL)\n", 0);
Printv(f->code, tab8, "_jresult = (jstring)", JNICALL((char*)"NewStringUTF"), "_result);\n", 0); Printv(f->code, tab8, "_jresult = (jstring)", JNICALL((char*)"NewStringUTF"), "_result);\n", 0);
} else { } else {
Printf(stderr,"%s : Line %d. Warning: no return typemap for datatype %s\n", input_file,line_number,t->print_type()); Printf(stderr,"%s : Line %d. Warning: no return typemap for datatype %s\n", input_file,line_number,DataType_print_type(t));
t->is_pointer++; t->is_pointer++;
Printv(f->code, tab4, "*", t->print_cast(), "&_jresult = _result;\n", 0); Printv(f->code, tab4, "*", DataType_print_cast(t), "&_jresult = _result;\n", 0);
t->is_pointer--; t->is_pointer--;
} }
} }

View file

@ -248,8 +248,8 @@ void
MZSCHEME::get_pointer (DOHString_or_char *name, int parm, DataType *t, MZSCHEME::get_pointer (DOHString_or_char *name, int parm, DataType *t,
Wrapper *f) Wrapper *f)
{ {
Printf(f->code," if (!swig_get_c_pointer(argv[%d],\"%s\", (void **) &_arg%d))\n", parm, t->print_mangle(), parm); Printf(f->code," if (!swig_get_c_pointer(argv[%d],\"%s\", (void **) &_arg%d))\n", parm, DataType_print_mangle(t), parm);
Printf(f->code," scheme_wrong_type(\"%s\", \"%s\", %d, argc, argv);\n", name, t->print_mangle(), parm); Printf(f->code," scheme_wrong_type(\"%s\", \"%s\", %d, argc, argv);\n", name, DataType_print_mangle(t), parm);
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -416,7 +416,7 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
tab4, tab4,
"swig_result = swig_make_c_pointer(", "swig_result = swig_make_c_pointer(",
"_result, \"", "_result, \"",
d->print_mangle(), DataType_print_mangle(d),
"\");\n", "\");\n",
0); 0);
} }
@ -558,9 +558,9 @@ MZSCHEME::link_variable (char *name, char *iname, DataType *t)
} else { } else {
// Set the value of a pointer // Set the value of a pointer
Printf(f_wrappers, "\t\tif (!swig_get_c_pointer(argv[0], \"%s\", (void **) &_arg0))\n", Printf(f_wrappers, "\t\tif (!swig_get_c_pointer(argv[0], \"%s\", (void **) &_arg0))\n",
t->print_mangle()); DataType_print_mangle(t));
Printf(f_wrappers, "\t\t\tscheme_wrong_type(\"%s\", %s, 0, argc, argv", \ Printf(f_wrappers, "\t\t\tscheme_wrong_type(\"%s\", %s, 0, argc, argv", \
var_name, t->print_mangle()); var_name, DataType_print_mangle(t));
} }
} }
else { else {
@ -581,7 +581,7 @@ MZSCHEME::link_variable (char *name, char *iname, DataType *t)
} else { } else {
// Is an ordinary pointer type. // Is an ordinary pointer type.
Printf(f_wrappers, "\tswig_result = swig_make_c_pointer(%s, \"%s\");\n", Printf(f_wrappers, "\tswig_result = swig_make_c_pointer(%s, \"%s\");\n",
name, t->print_mangle()); name, DataType_print_mangle(t));
} }
} }
else { else {
@ -601,7 +601,7 @@ MZSCHEME::link_variable (char *name, char *iname, DataType *t)
} else { } else {
Printf (stderr, "%s : Line %d. ** Warning. Unable to link with " Printf (stderr, "%s : Line %d. ** Warning. Unable to link with "
" type %s (ignored).\n", " type %s (ignored).\n",
input_file, line_number, t->print_type()); input_file, line_number, DataType_print_type(t));
} }
Delete(proc_name); Delete(proc_name);
} }
@ -654,7 +654,7 @@ MZSCHEME::declare_const (char *name, char *, DataType *type, char *value)
} else { } else {
// Create variable and assign it a value // Create variable and assign it a value
Printf (f_header, "static %s %s = ", type->print_type(), var_name); Printf (f_header, "static %s %s = ", DataType_print_type(type), var_name);
if ((type->type == T_CHAR) && (type->is_pointer <= 1)) { if ((type->type == T_CHAR) && (type->is_pointer <= 1)) {
Printf (f_header, "\"%s\";\n", value); Printf (f_header, "\"%s\";\n", value);
} else { } else {
@ -777,7 +777,7 @@ MZSCHEME::usage_returns (char *iname, DataType *d, ParmList *l, DOHString *usage
Insert(param,0," unspecified"); Insert(param,0," unspecified");
else { else {
Insert(param,0,"# "); Insert(param,0,"# ");
Insert(param,0,d->print_type()); Insert(param,0,DataType_print_type(d));
Insert(param,0," $"); Insert(param,0," $");
} }
} }

View file

@ -706,12 +706,12 @@ void PERL5::get_pointer(char *iname, char *srcname, char *src, char *dest,
if (t->type == T_VOID) Printf(f, "(char *) 0 )) {\n"); if (t->type == T_VOID) Printf(f, "(char *) 0 )) {\n");
else else
Printv(f, "\"", (hidden ? realpackage : ""), (hidden ? "::" : ""), t->print_mangle(), "\")) {\n", 0); Printv(f, "\"", (hidden ? realpackage : ""), (hidden ? "::" : ""), DataType_print_mangle(t), "\")) {\n", 0);
// Change this part to return an error. // Change this part to return an error.
Printv(f, Printv(f,
tab8, "croak(\"Type error in ", srcname, tab8, "croak(\"Type error in ", srcname,
" of ", iname, ". Expected ", (hidden ? realpackage : ""), (hidden ? "::" : ""), t->print_mangle(), ".\");\n", " of ", iname, ". Expected ", (hidden ? realpackage : ""), (hidden ? "::" : ""), DataType_print_mangle(t), ".\");\n",
tab8, ret, ";\n", tab8, ret, ";\n",
tab4, "}\n", tab4, "}\n",
0); 0);
@ -823,7 +823,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
case T_USHORT: case T_USHORT:
case T_ULONG: case T_ULONG:
case T_UCHAR: case T_UCHAR:
Printf(f->code," _arg%d = %sSvIV(ST(%d));\n", i, p->t->print_cast(),j); Printf(f->code," _arg%d = %sSvIV(ST(%d));\n", i, DataType_print_cast(p->t),j);
break; break;
case T_CHAR : case T_CHAR :
@ -835,7 +835,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
case T_DOUBLE : case T_DOUBLE :
case T_FLOAT : case T_FLOAT :
Printf(f->code," _arg%d = %s SvNV(ST(%d));\n", i, p->t->print_cast(), j); Printf(f->code," _arg%d = %s SvNV(ST(%d));\n", i, DataType_print_cast(p->t), j);
break; break;
// Void.. Do nothing. // Void.. Do nothing.
@ -851,7 +851,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
// Unsupported data type // Unsupported data type
default : default :
Printf(stderr,"%s : Line %d. Unable to use type %s as a function argument.\n",input_file, line_number, p->t->print_type()); Printf(stderr,"%s : Line %d. Unable to use type %s as a function argument.\n",input_file, line_number, DataType_print_type(p->t));
break; break;
} }
} else { } else {
@ -958,13 +958,13 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
case T_USER: case T_USER:
d->is_pointer++; d->is_pointer++;
Printv(f->code, Printv(f->code,
tab4, "sv_setref_pv(ST(argvi++),\"",(hidden ? realpackage : ""), (hidden ? "::" : ""), d->print_mangle(), tab4, "sv_setref_pv(ST(argvi++),\"",(hidden ? realpackage : ""), (hidden ? "::" : ""), DataType_print_mangle(d),
"\", (void *) _result);\n", 0); "\", (void *) _result);\n", 0);
d->is_pointer--; d->is_pointer--;
break; break;
default : default :
Printf(stderr,"%s: Line %d. Unable to use return type %s in function %s.\n", input_file, line_number, d->print_type(), name); Printf(stderr,"%s: Line %d. Unable to use return type %s in function %s.\n", input_file, line_number, DataType_print_type(d), name);
break; break;
} }
} else { } else {
@ -978,7 +978,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
} else { } else {
// Is an ordinary pointer type. // Is an ordinary pointer type.
Printv(f->code, tab4, "sv_setref_pv(ST(argvi++),\"", (hidden ? realpackage : ""), (hidden ? "::" : ""), d->print_mangle(), Printv(f->code, tab4, "sv_setref_pv(ST(argvi++),\"", (hidden ? realpackage : ""), (hidden ? "::" : ""), DataType_print_mangle(d),
"\", (void *) _result);\n", 0); "\", (void *) _result);\n", 0);
} }
} }
@ -1185,11 +1185,11 @@ void PERL5::link_variable(char *name, char *iname, DataType *t)
case T_SHORT : case T_SSHORT : case T_USHORT: case T_SHORT : case T_SSHORT : case T_USHORT:
case T_LONG : case T_SLONG : case T_ULONG: case T_LONG : case T_SLONG : case T_ULONG:
case T_UCHAR: case T_SCHAR: case T_UCHAR: case T_SCHAR:
Printv(setf->code,tab4, name, " = ", t->print_cast(), " SvIV(sv);\n", 0); Printv(setf->code,tab4, name, " = ", DataType_print_cast(t), " SvIV(sv);\n", 0);
break; break;
case T_DOUBLE : case T_DOUBLE :
case T_FLOAT : case T_FLOAT :
Printv(setf->code, tab4, name, " = ", t->print_cast(), " SvNV(sv);\n", 0); Printv(setf->code, tab4, name, " = ", DataType_print_cast(t), " SvNV(sv);\n", 0);
break; break;
case T_CHAR : case T_CHAR :
Printv(setf->code, tab4, name, " = (char) *SvPV(sv,PL_na);\n", 0); Printv(setf->code, tab4, name, " = (char) *SvPV(sv,PL_na);\n", 0);
@ -1203,12 +1203,12 @@ void PERL5::link_variable(char *name, char *iname, DataType *t)
t->is_pointer++; t->is_pointer++;
Wrapper_add_local(setf,"_temp", "void *_temp"); Wrapper_add_local(setf,"_temp", "void *_temp");
get_pointer(iname,(char*)"value",(char*)"sv",(char*)"_temp", t, setf->code, (char*)"return(1)"); get_pointer(iname,(char*)"value",(char*)"sv",(char*)"_temp", t, setf->code, (char*)"return(1)");
Printv(setf->code, tab4, name, " = *(", t->print_cast(), " _temp);\n", 0); Printv(setf->code, tab4, name, " = *(", DataType_print_cast(t), " _temp);\n", 0);
t->is_pointer--; t->is_pointer--;
break; break;
default : default :
Printf(stderr,"%s : Line %d. Unable to link with datatype %s (ignored).\n", input_file, line_number, t->print_type()); Printf(stderr,"%s : Line %d. Unable to link with datatype %s (ignored).\n", input_file, line_number, DataType_print_type(t));
return; return;
} }
} else { } else {
@ -1233,7 +1233,7 @@ void PERL5::link_variable(char *name, char *iname, DataType *t)
Wrapper_add_local(setf,"_temp","void *_temp"); Wrapper_add_local(setf,"_temp","void *_temp");
get_pointer(iname,(char*)"value",(char*)"sv",(char*)"_temp", t, setf->code, (char*)"return(1)"); get_pointer(iname,(char*)"value",(char*)"sv",(char*)"_temp", t, setf->code, (char*)"return(1)");
Printv(setf->code,tab4, name, " = ", t->print_cast(), " _temp;\n", 0); Printv(setf->code,tab4, name, " = ", DataType_print_cast(t), " _temp;\n", 0);
} }
} }
} }
@ -1288,7 +1288,7 @@ void PERL5::link_variable(char *name, char *iname, DataType *t)
0); 0);
Wrapper_add_local(getf,"rsv","SV *rsv"); Wrapper_add_local(getf,"rsv","SV *rsv");
Printv(vinit, tab4, "sv_setref_pv(sv,\"", t->print_mangle(), "\",(void *) &", name, ");\n",0); Printv(vinit, tab4, "sv_setref_pv(sv,\"", DataType_print_mangle(t), "\",(void *) &", name, ");\n",0);
t->is_pointer--; t->is_pointer--;
break; break;
@ -1308,7 +1308,7 @@ void PERL5::link_variable(char *name, char *iname, DataType *t)
0); 0);
Wrapper_add_local(getf,"rsv","SV *rsv"); Wrapper_add_local(getf,"rsv","SV *rsv");
Printv(vinit, tab4, "sv_setref_pv(sv,\"", t->print_mangle(), "\",(void *) 1);\n",0); Printv(vinit, tab4, "sv_setref_pv(sv,\"", DataType_print_mangle(t), "\",(void *) 1);\n",0);
} }
} }
} }
@ -1472,7 +1472,7 @@ PERL5::declare_const(char *name, char *, DataType *type, char *value)
have_ref_func = 1; have_ref_func = 1;
} }
Printv(vinit, tab4, "swig_setrv(\"", package, "::", name, "\", (void *) ", value, ", \"", Printv(vinit, tab4, "swig_setrv(\"", package, "::", name, "\", (void *) ", value, ", \"",
type->print_mangle(), "\");\n", 0); DataType_print_mangle(type), "\");\n", 0);
} }
} }
} }
@ -1539,7 +1539,7 @@ char *PERL5::usage_func(char *iname, DataType *, ParmList *l) {
if (strlen(p->name) > 0) { if (strlen(p->name) > 0) {
Printf(temp,"%s",p->name); Printf(temp,"%s",p->name);
} else { } else {
Printf(temp,"%s",p->t->print_type()); Printf(temp,"%s",DataType_print_type(p->t));
} }
} }
i++; i++;

View file

@ -518,7 +518,7 @@ void
PYTHON::get_pointer(char *iname, char *srcname, char *src, char *dest, PYTHON::get_pointer(char *iname, char *srcname, char *src, char *dest,
DataType *t, DOHString *f, char *ret) DataType *t, DOHString *f, char *ret)
{ {
t->remember(); DataType_remember(t);
// Now get the pointer value from the string and save in dest // Now get the pointer value from the string and save in dest
@ -529,7 +529,7 @@ PYTHON::get_pointer(char *iname, char *srcname, char *src, char *dest,
if (t->type == T_VOID) Printv(f, "0,1)) == -1) return ", ret, ";\n", 0); if (t->type == T_VOID) Printv(f, "0,1)) == -1) return ", ret, ";\n", 0);
else else
Printv(f,"SWIGTYPE", t->print_mangle(), ",1)) == -1) return ", ret, ";\n", 0); Printv(f,"SWIGTYPE", DataType_print_mangle(t), ",1)) == -1) return ", ret, ";\n", 0);
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -768,7 +768,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
Wrapper_add_localv(f,tempb,"int",tempb,0); Wrapper_add_localv(f,tempb,"int",tempb,0);
else else
Wrapper_add_localv(f,tempb,"int",tempb, "=",tempval,0); Wrapper_add_localv(f,tempb,"int",tempb, "=",tempval,0);
Printv(get_pointers, tab4, target, " = ", p->t->print_cast(), " ", tempb, ";\n", 0); Printv(get_pointers, tab4, target, " = ", DataType_print_cast(p->t), " ", tempb, ";\n", 0);
Printf(arglist,"&%s",tempb); Printf(arglist,"&%s",tempb);
} }
break; break;
@ -787,7 +787,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
// Unsupported data type // Unsupported data type
default : default :
Printf(stderr,"%s : Line %d. Unable to use type %s as a function argument.\n",input_file, line_number, p->t->print_type()); Printf(stderr,"%s : Line %d. Unable to use type %s as a function argument.\n",input_file, line_number, DataType_print_type(p->t));
break; break;
} }
@ -914,12 +914,12 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
case T_USER : case T_USER :
d->is_pointer++; d->is_pointer++;
d->remember(); DataType_remember(d);
Printv(f->code,tab4, "_resultobj = SWIG_NewPointerObj((void *)_result, SWIGTYPE", d->print_mangle(), ");\n",0); Printv(f->code,tab4, "_resultobj = SWIG_NewPointerObj((void *)_result, SWIGTYPE", DataType_print_mangle(d), ");\n",0);
d->is_pointer--; d->is_pointer--;
break; break;
default : default :
Printf(stderr,"%s: Line %d. Unable to use return type %s in function %s.\n", input_file, line_number, d->print_type(), name); Printf(stderr,"%s: Line %d. Unable to use return type %s in function %s.\n", input_file, line_number, DataType_print_type(d), name);
break; break;
} }
} else { } else {
@ -937,8 +937,8 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
} else { } else {
// Build a SWIG pointer. // Build a SWIG pointer.
d->remember(); DataType_remember(d);
Printv(f->code, tab4, "_resultobj = SWIG_NewPointerObj((void *) _result, SWIGTYPE", d->print_mangle(), ");\n", 0); Printv(f->code, tab4, "_resultobj = SWIG_NewPointerObj((void *) _result, SWIGTYPE", DataType_print_mangle(d), ");\n", 0);
} }
} }
} else { } else {
@ -1112,12 +1112,12 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
case T_SINT: case T_SSHORT: case T_SLONG: case T_SINT: case T_SSHORT: case T_SLONG:
case T_SCHAR: case T_UCHAR: case T_BOOL: case T_SCHAR: case T_UCHAR: case T_BOOL:
// Get an integer value // Get an integer value
Wrapper_add_localv(setf,"tval",t->print_type(),"tval",0); Wrapper_add_localv(setf,"tval",DataType_print_type(t),"tval",0);
Printv(setf->code, Printv(setf->code,
tab4, "tval = ", t->print_cast(), "PyInt_AsLong(val);\n", tab4, "tval = ", DataType_print_cast(t), "PyInt_AsLong(val);\n",
tab4, "if (PyErr_Occurred()) {\n", tab4, "if (PyErr_Occurred()) {\n",
tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '", tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '",
iname, "'(", t->print_type(), ")\");\n", iname, "'(", DataType_print_type(t), ")\");\n",
tab8, "return 1; \n", tab8, "return 1; \n",
tab4, "}\n", tab4, "}\n",
tab4, name, " = tval;\n", tab4, name, " = tval;\n",
@ -1126,12 +1126,12 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
case T_FLOAT: case T_DOUBLE: case T_FLOAT: case T_DOUBLE:
// Get a floating point value // Get a floating point value
Wrapper_add_localv(setf,"tval",t->print_type(), "tval",0); Wrapper_add_localv(setf,"tval",DataType_print_type(t), "tval",0);
Printv(setf->code, Printv(setf->code,
tab4, "tval = ", t->print_cast(), "PyFloat_AsDouble(val);\n", tab4, "tval = ", DataType_print_cast(t), "PyFloat_AsDouble(val);\n",
tab4, "if (PyErr_Occurred()) {\n", tab4, "if (PyErr_Occurred()) {\n",
tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '", tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '",
iname, "'(", t->print_type(), ")\");\n", iname, "'(", DataType_print_type(t), ")\");\n",
tab8, "return 1; \n", tab8, "return 1; \n",
tab4, "}\n", tab4, "}\n",
tab4, name, " = tval;\n", tab4, name, " = tval;\n",
@ -1146,7 +1146,7 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
tab4, "tval = (char *) PyString_AsString(val);\n", tab4, "tval = (char *) PyString_AsString(val);\n",
tab4, "if (PyErr_Occurred()) {\n", tab4, "if (PyErr_Occurred()) {\n",
tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '", tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '",
iname, "'(", t->print_type(), ")\");\n", iname, "'(", DataType_print_type(t), ")\");\n",
tab8, "return 1; \n", tab8, "return 1; \n",
tab4, "}\n", tab4, "}\n",
tab4, name, " = *tval;\n", tab4, name, " = *tval;\n",
@ -1154,13 +1154,13 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
break; break;
case T_USER: case T_USER:
t->is_pointer++; t->is_pointer++;
Wrapper_add_localv(setf,"temp",t->print_type(),"temp",0); Wrapper_add_localv(setf,"temp",DataType_print_type(t),"temp",0);
get_pointer(iname,(char*)"value",(char*)"val",(char*)"temp",t,setf->code,(char*)"1"); get_pointer(iname,(char*)"value",(char*)"val",(char*)"temp",t,setf->code,(char*)"1");
Printv(setf->code, tab4, name, " = *temp;\n", 0); Printv(setf->code, tab4, name, " = *temp;\n", 0);
t->is_pointer--; t->is_pointer--;
break; break;
default: default:
Printf(stderr,"%s : Line %d. Unable to link with type %s.\n", input_file, line_number, t->print_type()); Printf(stderr,"%s : Line %d. Unable to link with type %s.\n", input_file, line_number, DataType_print_type(t));
} }
} else { } else {
@ -1172,7 +1172,7 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
tab4, "tval = (char *) PyString_AsString(val);\n", tab4, "tval = (char *) PyString_AsString(val);\n",
tab4, "if (PyErr_Occurred()) {\n", tab4, "if (PyErr_Occurred()) {\n",
tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '", tab8, "PyErr_SetString(PyExc_TypeError,\"C variable '",
iname, "'(", t->print_type(), ")\");\n", iname, "'(", DataType_print_type(t), ")\");\n",
tab8, "return 1; \n", tab8, "return 1; \n",
tab4, "}\n", tab4, "}\n",
0); 0);
@ -1194,7 +1194,7 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
// Is a generic pointer value. // Is a generic pointer value.
Wrapper_add_localv(setf,"temp", t->print_type(), "temp",0); Wrapper_add_localv(setf,"temp", DataType_print_type(t), "temp",0);
get_pointer(iname,(char*)"value",(char*)"val",(char*)"temp",t,setf->code,(char*)"1"); get_pointer(iname,(char*)"value",(char*)"val",(char*)"temp",t,setf->code,(char*)"1");
Printv(setf->code,tab4, name, " = temp;\n", 0); Printv(setf->code,tab4, name, " = temp;\n", 0);
} }
@ -1255,15 +1255,15 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
case T_USER: case T_USER:
// Hack this into a pointer // Hack this into a pointer
t->is_pointer++; t->is_pointer++;
t->remember(); DataType_remember(t);
Printv(getf->code, Printv(getf->code,
tab4, "pyobj = SWIG_NewPointerObj((void *) &", name , tab4, "pyobj = SWIG_NewPointerObj((void *) &", name ,
", SWIGTYPE", t->print_mangle(), ");\n", ", SWIGTYPE", DataType_print_mangle(t), ");\n",
0); 0);
t->is_pointer--; t->is_pointer--;
break; break;
default: default:
Printf(stderr,"Unable to link with type %s\n", t->print_type()); Printf(stderr,"Unable to link with type %s\n", DataType_print_type(t));
break; break;
} }
} else { } else {
@ -1276,10 +1276,10 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
tab4, "else pyobj = PyString_FromString(\"(NULL)\");\n", tab4, "else pyobj = PyString_FromString(\"(NULL)\");\n",
0); 0);
} else { } else {
t->remember(); DataType_remember(t);
Printv(getf->code, Printv(getf->code,
tab4, "pyobj = SWIG_NewPointerObj((void *)", name, tab4, "pyobj = SWIG_NewPointerObj((void *)", name,
", SWIGTYPE", t->print_mangle(), ");\n", ", SWIGTYPE", DataType_print_mangle(t), ");\n",
0); 0);
} }
} }
@ -1357,8 +1357,8 @@ void PYTHON::declare_const(char *name, char *, DataType *type, char *value) {
Printv(const_code,tab4, "{ SWIG_PY_STRING, \"", name, "\", 0, 0, (void *) \"", value, "\", 0},\n", 0); Printv(const_code,tab4, "{ SWIG_PY_STRING, \"", name, "\", 0, 0, (void *) \"", value, "\", 0},\n", 0);
} else { } else {
// A funky user-defined type. We're going to munge it into a string pointer value // A funky user-defined type. We're going to munge it into a string pointer value
type->remember(); DataType_remember(type);
Printv(const_code, tab4, "{ SWIG_PY_POINTER, \"", name, "\", 0, 0, (void *) ", value, ", &SWIGTYPE", type->print_mangle(), "}, \n", 0); Printv(const_code, tab4, "{ SWIG_PY_POINTER, \"", name, "\", 0, 0, (void *) ", value, ", &SWIGTYPE", DataType_print_mangle(type), "}, \n", 0);
} }
} }
@ -1421,7 +1421,7 @@ char *PYTHON::usage_func(char *iname, DataType *, ParmList *l) {
if (strlen(p->name) > 0) { if (strlen(p->name) > 0) {
Printf(temp,"%s",p->name); Printf(temp,"%s",p->name);
} else { } else {
Printf(temp,"%s", p->t->print_type()); Printf(temp,"%s", DataType_print_type(p->t));
} }
} }
p = ParmList_next(l); p = ParmList_next(l);

View file

@ -181,7 +181,7 @@ void RUBY::parse() {
value.type = T_VOID; value.type = T_VOID;
value.is_pointer = 1; value.is_pointer = 1;
value.implicit_ptr = 0; value.implicit_ptr = 0;
value.typedef_add((char*)"VALUE"); DataType_typedef_add(&value,(char*)"VALUE",0);
yyparse(); // Run the SWIG parser yyparse(); // Run the SWIG parser
} }
@ -537,7 +537,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
Delete(s); Delete(s);
} else { } else {
Printf(stderr,"%s : Line %d. No typemapping for datatype %s\n", Printf(stderr,"%s : Line %d. No typemapping for datatype %s\n",
input_file,line_number, p->t->print_type()); input_file,line_number, DataType_print_type(p->t));
} }
if (j >= (pcount-numopt)) if (j >= (pcount-numopt))
Printv(f->code, tab4, "} \n"); Printv(f->code, tab4, "} \n");
@ -590,7 +590,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
Delete(s); Delete(s);
} else { } else {
Printf(stderr,"%s : Line %d. No return typemap for datatype %s\n", Printf(stderr,"%s : Line %d. No return typemap for datatype %s\n",
input_file,line_number,t->print_type()); input_file,line_number,DataType_print_type(t));
} }
} }
} }
@ -681,13 +681,13 @@ void RUBY::link_variable(char *name, char *iname, DataType *t) {
} else if (!t->is_pointer && t->type == T_USER) { } else if (!t->is_pointer && t->type == T_USER) {
// Hack this into a pointer // Hack this into a pointer
t->is_pointer++; t->is_pointer++;
t->remember(); DataType_remember(t);
Printv(getf->code, tab4, "_val = SWIG_NewPointerObj((void *)&", name, Printv(getf->code, tab4, "_val = SWIG_NewPointerObj((void *)&", name,
", \"", t->print_mangle(), "\");\n", 0); ", \"", DataType_print_mangle(t), "\");\n", 0);
t->is_pointer--; t->is_pointer--;
} else { } else {
Printf(stderr,"%s: Line %d. Unable to link with variable type %s\n", Printf(stderr,"%s: Line %d. Unable to link with variable type %s\n",
input_file,line_number,t->print_type()); input_file,line_number,DataType_print_type(t));
} }
Printv(getf->code, tab4, "return _val;\n}\n", 0); Printv(getf->code, tab4, "return _val;\n}\n", 0);
Wrapper_print(getf,f_wrappers); Wrapper_print(getf,f_wrappers);
@ -713,15 +713,15 @@ void RUBY::link_variable(char *name, char *iname, DataType *t) {
Delete(s); Delete(s);
} else if (!t->is_pointer && t->type == T_USER) { } else if (!t->is_pointer && t->type == T_USER) {
t->is_pointer++; t->is_pointer++;
Wrapper_add_localv(setf,"temp",t->print_type(), "temp",0); Wrapper_add_localv(setf,"temp",DataType_print_type(t), "temp",0);
Printv(setf->code, tab4, "temp = (", t->print_type(), ")", Printv(setf->code, tab4, "temp = (", DataType_print_type(t), ")",
"SWIG_ConvertPtr(_val, \"", t->print_mangle(), "\");\n", "SWIG_ConvertPtr(_val, \"", DataType_print_mangle(t), "\");\n",
0); 0);
Printv(setf->code, tab4, name, " = *temp;\n",0); Printv(setf->code, tab4, name, " = *temp;\n",0);
t->is_pointer--; t->is_pointer--;
} else { } else {
Printf(stderr,"%s: Line %d. Unable to link with variable type %s\n", Printf(stderr,"%s: Line %d. Unable to link with variable type %s\n",
input_file,line_number,t->print_type()); input_file,line_number,DataType_print_type(t));
} }
if (mod_attr) if (mod_attr)
Printv(setf->code, tab4, "return _val;\n",0); Printv(setf->code, tab4, "return _val;\n",0);
@ -843,7 +843,7 @@ void RUBY::declare_const(char *name, char *iname, DataType *type, char *value) {
Delete(str); Delete(str);
} else { } else {
Printf(stderr,"%s : Line %d. Unable to create constant %s = %s\n", Printf(stderr,"%s : Line %d. Unable to create constant %s = %s\n",
input_file, line_number, type->print_type(), value); input_file, line_number, DataType_print_type(type), value);
} }
} }
@ -913,7 +913,7 @@ char *RUBY::ruby_typemap_lookup(char *op, DataType *type, char *pname, char *sou
Replace(s,"$source",source, DOH_REPLACE_ANY); Replace(s,"$source",source, DOH_REPLACE_ANY);
if (target && strlen(target) > 0) if (target && strlen(target) > 0)
Replace(s,"$target",target, DOH_REPLACE_ANY); Replace(s,"$target",target, DOH_REPLACE_ANY);
Replace(s,"$type", type->print_type(), DOH_REPLACE_ANY); Replace(s,"$type", DataType_print_type(type), DOH_REPLACE_ANY);
return Char(s); return Char(s);
} }
@ -961,7 +961,7 @@ int RUBY::to_VALUE(DataType *type, char *value, DOHString *str, int raw) {
else else
Printv(str, "rb_str_new2(", value, ")", 0); Printv(str, "rb_str_new2(", value, ")", 0);
} else { } else {
Printv(str, "SWIG_NewPointerObj((void *)", value, ", \"", type->print_mangle(), "\")", 0); Printv(str, "SWIG_NewPointerObj((void *)", value, ", \"", DataType_print_mangle(type), "\")", 0);
} }
if (Len(str) == 0) if (Len(str) == 0)
@ -1015,7 +1015,7 @@ int RUBY::from_VALUE(DataType *type, char *value, DOHString *str) {
} else if ((type->type == T_CHAR) && (type->is_pointer == 1)) { } else if ((type->type == T_CHAR) && (type->is_pointer == 1)) {
Printv(str, "STR2CSTR(", value, ")", 0); Printv(str, "STR2CSTR(", value, ")", 0);
} else { } else {
Printv(str, "SWIG_ConvertPtr(", value, ", \"", type->print_mangle(), "\")", 0); Printv(str, "SWIG_ConvertPtr(", value, ", \"", DataType_print_mangle(type), "\")", 0);
} }
if (Len(str) == 0) return 0; if (Len(str) == 0) return 0;

View file

@ -429,12 +429,12 @@ void TCL8::get_pointer(char *iname, char *srcname, char *src, char *dest,
// Pointers are read as hex-strings with encoded type information // Pointers are read as hex-strings with encoded type information
t->remember(); DataType_remember(t);
Printv(f, tab4, "if ((SWIG_ConvertPtr(interp,", src, ",(void **) &", dest, ",",0); Printv(f, tab4, "if ((SWIG_ConvertPtr(interp,", src, ",(void **) &", dest, ",",0);
if (t->type == T_VOID) Printf(f, "0)) == TCL_ERROR) { return TCL_ERROR; }\n"); if (t->type == T_VOID) Printf(f, "0)) == TCL_ERROR) { return TCL_ERROR; }\n");
else else
Printv(f, "SWIGTYPE", t->print_mangle(), ")) == TCL_ERROR) { return TCL_ERROR; }\n", 0); Printv(f, "SWIGTYPE", DataType_print_mangle(t), ")) == TCL_ERROR) { return TCL_ERROR; }\n", 0);
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -600,7 +600,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
default : default :
Printf(stderr,"%s : Line %d: Unable to use type %s as a function argument.\n", Printf(stderr,"%s : Line %d: Unable to use type %s as a function argument.\n",
input_file, line_number, p->t->print_type()); input_file, line_number, DataType_print_type(p->t));
break; break;
} }
} else { } else {
@ -612,9 +612,9 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
Putc('s',argstr); Putc('s',argstr);
Printf(args,",&%s",target); Printf(args,",&%s",target);
} else { } else {
p->t->remember(); DataType_remember(p->t);
Putc('p',argstr); Putc('p',argstr);
Printv(args, ",&", target, ", SWIGTYPE", p->t->print_mangle(), 0); Printv(args, ",&", target, ", SWIGTYPE", DataType_print_mangle(p->t), 0);
} }
} }
} }
@ -701,9 +701,9 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
// Probably dangerous, but who said safety was a good thing? // Probably dangerous, but who said safety was a good thing?
d->is_pointer++; d->is_pointer++;
d->remember(); DataType_remember(d);
Printv(f->code, tab4, "Tcl_SetObjResult(interp,SWIG_NewPointerObj((void *) _result,SWIGTYPE", Printv(f->code, tab4, "Tcl_SetObjResult(interp,SWIG_NewPointerObj((void *) _result,SWIGTYPE",
d->print_mangle(), "));\n", 0); DataType_print_mangle(d), "));\n", 0);
d->is_pointer--; d->is_pointer--;
break; break;
@ -711,7 +711,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
// Unknown type // Unknown type
default : default :
Printf(stderr,"%s : Line %d: Unable to use return type %s in function %s.\n", Printf(stderr,"%s : Line %d: Unable to use return type %s in function %s.\n",
input_file, line_number, d->print_type(), name); input_file, line_number, DataType_print_type(d), name);
break; break;
} }
} else { } else {
@ -722,9 +722,9 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
// Return a character string // Return a character string
Printv(f->code, tab4, "Tcl_SetObjResult(interp,Tcl_NewStringObj(_result,-1));\n",0); Printv(f->code, tab4, "Tcl_SetObjResult(interp,Tcl_NewStringObj(_result,-1));\n",0);
} else { } else {
d->remember(); DataType_remember(d);
Printv(f->code, tab4, "Tcl_SetObjResult(interp,SWIG_NewPointerObj((void *) _result,SWIGTYPE", Printv(f->code, tab4, "Tcl_SetObjResult(interp,SWIG_NewPointerObj((void *) _result,SWIGTYPE",
d->print_mangle(), "));\n", DataType_print_mangle(d), "));\n",
0); 0);
} }
} }
@ -790,19 +790,19 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
} }
// Dump a collection of set/get functions suitable for variable tracing // Dump a collection of set/get functions suitable for variable tracing
if (!Getattr(setget,t->print_type())) { if (!Getattr(setget,DataType_print_type(t))) {
Setattr(setget,t->print_type(),"1"); Setattr(setget,DataType_print_type(t),"1");
Wrapper *get, *set; Wrapper *get, *set;
get = NewWrapper(); get = NewWrapper();
set = NewWrapper(); set = NewWrapper();
Printv(set->def, "static char *_swig_", t->print_mangle(), "_set(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {",0); Printv(set->def, "static char *_swig_", DataType_print_mangle(t), "_set(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {",0);
Printv(get->def, "static char *_swig_", t->print_mangle(), "_get(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {",0); Printv(get->def, "static char *_swig_", DataType_print_mangle(t), "_get(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {",0);
t->is_pointer++; t->is_pointer++;
Wrapper_add_localv(get,"addr",t->print_type(),"addr",0); Wrapper_add_localv(get,"addr",DataType_print_type(t),"addr",0);
Wrapper_add_localv(set,"addr",t->print_type(),"addr",0); Wrapper_add_localv(set,"addr",DataType_print_type(t),"addr",0);
Printv(set->code, tab4, "addr = ", t->print_cast(), " clientData;\n", 0); Printv(set->code, tab4, "addr = ", DataType_print_cast(t), " clientData;\n", 0);
Printv(get->code, tab4, "addr = ", t->print_cast(), " clientData;\n", 0); Printv(get->code, tab4, "addr = ", DataType_print_cast(t), " clientData;\n", 0);
t->is_pointer--; t->is_pointer--;
Wrapper_add_local(set, "value", "char *value"); Wrapper_add_local(set, "value", "char *value");
Wrapper_add_local(get, "value", "Tcl_Obj *value"); Wrapper_add_local(get, "value", "Tcl_Obj *value");
@ -822,15 +822,15 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
case T_UCHAR: case T_UCHAR:
case T_SCHAR: case T_SCHAR:
case T_BOOL: case T_BOOL:
Printv(set->code, tab4, "*(addr) = ", t->print_cast(), "atol(value);\n", 0); Printv(set->code, tab4, "*(addr) = ", DataType_print_cast(t), "atol(value);\n", 0);
break; break;
case T_UINT: case T_UINT:
case T_ULONG: case T_ULONG:
Printv(set->code, tab4, "*(addr) = ", t->print_cast(), "strtoul(value,0,0);\n",0); Printv(set->code, tab4, "*(addr) = ", DataType_print_cast(t), "strtoul(value,0,0);\n",0);
break; break;
case T_FLOAT: case T_FLOAT:
case T_DOUBLE: case T_DOUBLE:
Printv(set->code, tab4, "*(addr) = ", t->print_cast(), "atof(value);\n",0); Printv(set->code, tab4, "*(addr) = ", DataType_print_cast(t), "atof(value);\n",0);
break; break;
case T_CHAR: /* Single character. */ case T_CHAR: /* Single character. */
Printv(set->code, tab4, "*(addr) = *value;\n",0); Printv(set->code, tab4, "*(addr) = *value;\n",0);
@ -838,13 +838,13 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
case T_USER: case T_USER:
// User defined type. We return it as a pointer // User defined type. We return it as a pointer
t->is_pointer++; t->is_pointer++;
t->remember(); DataType_remember(t);
Printv(set->code, tab4, "{\n", Printv(set->code, tab4, "{\n",
tab8, "void *ptr;\n", tab8, "void *ptr;\n",
tab8, "if (SWIG_ConvertPtrFromString(interp,value,&ptr,SWIGTYPE", t->print_mangle(), ") != TCL_OK) {\n", tab8, "if (SWIG_ConvertPtrFromString(interp,value,&ptr,SWIGTYPE", DataType_print_mangle(t), ") != TCL_OK) {\n",
tab8, tab4, "return \"Type Error\";\n", tab8, tab4, "return \"Type Error\";\n",
tab8, "}\n", tab8, "}\n",
tab8, "*(addr) = *(", t->print_cast(), " ptr);\n", tab8, "*(addr) = *(", DataType_print_cast(t), " ptr);\n",
tab4, "}\n", tab4, "}\n",
0); 0);
@ -862,13 +862,13 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
0); 0);
} else { } else {
// User defined type. We return it as a pointer // User defined type. We return it as a pointer
t->remember(); DataType_remember(t);
Printv(set->code, tab4, "{\n", Printv(set->code, tab4, "{\n",
tab8, "void *ptr;\n", tab8, "void *ptr;\n",
tab8, "if (SWIG_ConvertPtrFromString(interp,value,&ptr,SWIGTYPE", t->print_mangle(), ") != TCL_OK) {\n", tab8, "if (SWIG_ConvertPtrFromString(interp,value,&ptr,SWIGTYPE", DataType_print_mangle(t), ") != TCL_OK) {\n",
tab8, tab4, "return \"Type Error\";\n", tab8, tab4, "return \"Type Error\";\n",
tab8, "}\n", tab8, "}\n",
tab8, "*(addr) = ", t->print_cast(), " ptr;\n", tab8, "*(addr) = ", DataType_print_cast(t), " ptr;\n",
tab4, "}\n", tab4, "}\n",
0); 0);
@ -918,8 +918,8 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
case T_USER: case T_USER:
Wrapper_add_local(get,"value", "Tcl_Obj *value"); Wrapper_add_local(get,"value", "Tcl_Obj *value");
t->is_pointer++; t->is_pointer++;
t->remember(); DataType_remember(t);
Printv(get->code, tab4, "value = SWIG_NewPointerObj(addr, SWIGTYPE", t->print_mangle(), ");\n", Printv(get->code, tab4, "value = SWIG_NewPointerObj(addr, SWIGTYPE", DataType_print_mangle(t), ");\n",
tab4, "Tcl_SetVar2(interp,name1,name2,Tcl_GetStringFromObj(value,NULL), flags);\n", tab4, "Tcl_SetVar2(interp,name1,name2,Tcl_GetStringFromObj(value,NULL), flags);\n",
tab4, "Tcl_DecrRefCount(value);\n",0); tab4, "Tcl_DecrRefCount(value);\n",0);
t->is_pointer--; t->is_pointer--;
@ -933,9 +933,9 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
Printv(get->code, tab4, "Tcl_SetVar2(interp,name1,name2,*addr, flags);\n",0); Printv(get->code, tab4, "Tcl_SetVar2(interp,name1,name2,*addr, flags);\n",0);
} else { } else {
Wrapper_add_local(get,"value","Tcl_Obj *value"); Wrapper_add_local(get,"value","Tcl_Obj *value");
t->remember(); DataType_remember(t);
Printv(get->code, Printv(get->code,
tab4, "value = SWIG_NewPointerObj(*addr, SWIGTYPE", t->print_mangle(), ");\n", tab4, "value = SWIG_NewPointerObj(*addr, SWIGTYPE", DataType_print_mangle(t), ");\n",
tab4, "Tcl_SetVar2(interp,name1,name2,Tcl_GetStringFromObj(value,NULL), flags);\n", tab4, "Tcl_SetVar2(interp,name1,name2,Tcl_GetStringFromObj(value,NULL), flags);\n",
tab4, "Tcl_DecrRefCount(value);\n", tab4, "Tcl_DecrRefCount(value);\n",
0); 0);
@ -948,7 +948,7 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
DelWrapper(get); DelWrapper(get);
DelWrapper(set); DelWrapper(set);
} }
Printv(var_info, tab4,"{ SWIG_prefix \"", iname, "\", (void *) &", name, ", _swig_", t->print_mangle(), "_get,", 0); Printv(var_info, tab4,"{ SWIG_prefix \"", iname, "\", (void *) &", name, ", _swig_", DataType_print_mangle(t), "_get,", 0);
if (Status & STAT_READONLY) { if (Status & STAT_READONLY) {
static int readonly = 0; static int readonly = 0;
@ -962,7 +962,7 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
} }
Printf(var_info, "_swig_readonly},\n"); Printf(var_info, "_swig_readonly},\n");
} else { } else {
Printv(var_info, "_swig_", t->print_mangle(), "_set},\n",0); Printv(var_info, "_swig_", DataType_print_mangle(t), "_set},\n",0);
} }
} }
@ -1005,7 +1005,7 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
if (type->is_pointer == 0) { if (type->is_pointer == 0) {
switch(type->type) { switch(type->type) {
case T_BOOL: case T_INT: case T_SINT: case T_DOUBLE: case T_BOOL: case T_INT: case T_SINT: case T_DOUBLE:
Printf(f_header,"static %s %s = %s;\n", type->print_type(), var_name, value); Printf(f_header,"static %s %s = %s;\n", DataType_print_type(type), var_name, value);
link_variable(var_name,name,type); link_variable(var_name,name,type);
break; break;
case T_SHORT: case T_SHORT:
@ -1013,7 +1013,7 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
case T_SSHORT: case T_SSHORT:
case T_SCHAR: case T_SCHAR:
case T_SLONG: case T_SLONG:
Printf(f_header,"static %s %s = %s;\n", type->print_type(), var_name, value); Printf(f_header,"static %s %s = %s;\n", DataType_print_type(type), var_name, value);
Printf(f_header,"static char *%s_char;\n", var_name); Printf(f_header,"static char *%s_char;\n", var_name);
if (CPlusPlus) if (CPlusPlus)
Printf(f_init,"\t %s_char = new char[32];\n",var_name); Printf(f_init,"\t %s_char = new char[32];\n",var_name);
@ -1031,7 +1031,7 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
case T_USHORT: case T_USHORT:
case T_ULONG: case T_ULONG:
case T_UCHAR: case T_UCHAR:
Printf(f_header,"static %s %s = %s;\n", type->print_type(), var_name, value); Printf(f_header,"static %s %s = %s;\n", DataType_print_type(type), var_name, value);
Printf(f_header,"static char *%s_char;\n", var_name); Printf(f_header,"static char *%s_char;\n", var_name);
if (CPlusPlus) if (CPlusPlus)
Printf(f_init,"\t %s_char = new char[32];\n",var_name); Printf(f_init,"\t %s_char = new char[32];\n",var_name);
@ -1048,13 +1048,13 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
case T_FLOAT: case T_FLOAT:
type->type = T_DOUBLE; type->type = T_DOUBLE;
strcpy(type->name,"double"); strcpy(type->name,"double");
Printf(f_header,"static %s %s = %s (%s);\n", type->print_type(), var_name, type->print_cast(), value); Printf(f_header,"static %s %s = %s (%s);\n", DataType_print_type(type), var_name, DataType_print_cast(type), value);
link_variable(var_name,name,type); link_variable(var_name,name,type);
break; break;
case T_CHAR: case T_CHAR:
type->is_pointer++; type->is_pointer++;
Printf(f_header,"static %s %s = \"%s\";\n", type->print_type(), var_name, value); Printf(f_header,"static %s %s = \"%s\";\n", DataType_print_type(type), var_name, value);
link_variable(var_name,name,type); link_variable(var_name,name,type);
type->is_pointer--; type->is_pointer--;
break; break;
@ -1066,22 +1066,22 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
// Have some sort of pointer value here // Have some sort of pointer value here
if ((type->type == T_CHAR) && (type->is_pointer == 1)) { if ((type->type == T_CHAR) && (type->is_pointer == 1)) {
// Character string // Character string
Printf(f_header,"static %s %s = \"%s\";\n", type->print_type(), var_name, value); Printf(f_header,"static %s %s = \"%s\";\n", DataType_print_type(type), var_name, value);
link_variable(var_name,name,type); link_variable(var_name,name,type);
} else { } else {
// Something else. Some sort of pointer value // Something else. Some sort of pointer value
Printf(f_header,"static %s %s = %s;\n", type->print_type(), var_name, value); Printf(f_header,"static %s %s = %s;\n", DataType_print_type(type), var_name, value);
Printf(f_header,"static char *%s_char;\n", var_name); Printf(f_header,"static char *%s_char;\n", var_name);
if (CPlusPlus) if (CPlusPlus)
Printf(f_init,"\t %s_char = new char[%d];\n",var_name,(int) strlen(type->print_mangle())+ 20); Printf(f_init,"\t %s_char = new char[%d];\n",var_name,(int) strlen(DataType_print_mangle(type))+ 20);
else else
Printf(f_init,"\t %s_char = (char *) malloc(%d);\n",var_name, (int) strlen(type->print_mangle())+ 20); Printf(f_init,"\t %s_char = (char *) malloc(%d);\n",var_name, (int) strlen(DataType_print_mangle(type))+ 20);
t = new DataType(T_CHAR); t = new DataType(T_CHAR);
t->is_pointer = 1; t->is_pointer = 1;
type->remember(); DataType_remember(type);
Printf(f_init,"\t SWIG_MakePtr(%s_char, (void *) %s, SWIGTYPE%s);\n", Printf(f_init,"\t SWIG_MakePtr(%s_char, (void *) %s, SWIGTYPE%s);\n",
var_name, var_name, type->print_mangle()); var_name, var_name, DataType_print_mangle(type));
sprintf(var_name,"%s_char",var_name); sprintf(var_name,"%s_char",var_name);
link_variable(var_name,name,t); link_variable(var_name,name,t);
delete t; delete t;
@ -1156,7 +1156,7 @@ char * TCL8::usage_string(char *iname, DataType *, ParmList *l) {
Printf(temp,p->name); Printf(temp,p->name);
} }
else { else {
Printf(temp,"{ %s }", p->t->print_type()); Printf(temp,"{ %s }", DataType_print_type(p->t));
} }
} }
if (i >= (pcount-numopt)) if (i >= (pcount-numopt))
@ -1291,7 +1291,7 @@ void TCL8::cpp_close_class() {
if (have_destructor) { if (have_destructor) {
Printv(code, "static void _swig_delete_", class_name, "(void *obj) {\n", Printv(code, "static void _swig_delete_", class_name, "(void *obj) {\n",
tab4, Swig_name_destroy(real_classname), "((", t->print_type(), ") obj);\n", tab4, Swig_name_destroy(real_classname), "((", DataType_print_type(t), ") obj);\n",
"}\n",0); "}\n",0);
} }
@ -1302,7 +1302,7 @@ void TCL8::cpp_close_class() {
Printv(code,attributes,0); Printv(code,attributes,0);
Printv(code, "static _swig_class _wrap_class_", class_name, " = { \"", class_name, Printv(code, "static _swig_class _wrap_class_", class_name, " = { \"", class_name,
"\", &SWIGTYPE", t->print_mangle(), ",",0); "\", &SWIGTYPE", DataType_print_mangle(t), ",",0);
if (have_constructor) { if (have_constructor) {
Printf(code, Swig_name_wrapper(Swig_name_construct(class_name))); Printf(code, Swig_name_wrapper(Swig_name_construct(class_name)));

View file

@ -1016,7 +1016,7 @@ void cplus_generate_types(char **baseclass) {
} else { } else {
typeeq_derived(bc->classname, current_class->classname,Char(temp3)); typeeq_derived(bc->classname, current_class->classname,Char(temp3));
} }
DataType::record_base(current_class->classname, bc->classname); DataType_record_base(current_class->classname, bc->classname);
// Now traverse the hierarchy some more // Now traverse the hierarchy some more
cplus_generate_types(bc->baseclass); cplus_generate_types(bc->baseclass);
} }
@ -1585,7 +1585,7 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
if (type->is_reference) { if (type->is_reference) {
type->is_pointer--; type->is_pointer--;
} }
Printf(wrap,"%s", type->print_full()); Printf(wrap,"%s", DataType_print_full(type));
if (type->is_reference) { if (type->is_reference) {
Printf(wrap,"&"); Printf(wrap,"&");
type->is_pointer++; type->is_pointer++;
@ -1601,7 +1601,7 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
if ((p->call_type & CALL_REFERENCE) || (p->t->is_reference)) { if ((p->call_type & CALL_REFERENCE) || (p->t->is_reference)) {
p->t->is_pointer--; p->t->is_pointer--;
} }
Printf(wrap, p->t->print_full()); Printf(wrap, DataType_print_full(p->t));
if ((p->call_type & CALL_REFERENCE) || (p->t->is_reference)) { if ((p->call_type & CALL_REFERENCE) || (p->t->is_reference)) {
p->t->is_pointer++; p->t->is_pointer++;
if (p->t->is_reference) if (p->t->is_reference)
@ -1760,7 +1760,7 @@ void cplus_emit_static_func(char *classname, char *, char *classrename,
// Otherwise, assume the function has been written already and // Otherwise, assume the function has been written already and
// wrap it. // wrap it.
Printv(wrap,"static ", type->print_full(), " ", cname, "(", 0); Printv(wrap,"static ", DataType_print_full(type), " ", cname, "(", 0);
// Walk down the parameter list and Spit out arguments // Walk down the parameter list and Spit out arguments
p = ParmList_first(l); p = ParmList_first(l);
@ -1769,7 +1769,7 @@ void cplus_emit_static_func(char *classname, char *, char *classrename,
if (p->t->is_reference) { if (p->t->is_reference) {
p->t->is_pointer--; p->t->is_pointer--;
} }
Printf(wrap, p->t->print_full()); Printf(wrap, DataType_print_full(p->t));
if (p->t->is_reference) { if (p->t->is_reference) {
p->t->is_pointer++; p->t->is_pointer++;
Printf(wrap, "&"); Printf(wrap, "&");
@ -1793,10 +1793,10 @@ void cplus_emit_static_func(char *classname, char *, char *classrename,
if (type->is_reference) { if (type->is_reference) {
type->is_pointer--; type->is_pointer--;
Printv(wrap, tab4, type->print_full(), "& _result = ",0); Printv(wrap, tab4, DataType_print_full(type), "& _result = ",0);
type->is_pointer++; type->is_pointer++;
} else { } else {
Printv(wrap, tab4, type->print_type(), " _result = ", type->print_cast(), 0); Printv(wrap, tab4, DataType_print_type(type), " _result = ", DataType_print_cast(type), 0);
} }
} else { } else {
Printf(wrap,tab4); Printf(wrap,tab4);
@ -1819,7 +1819,7 @@ void cplus_emit_static_func(char *classname, char *, char *classrename,
if ((type->type != T_VOID) || (type->is_pointer)) { if ((type->type != T_VOID) || (type->is_pointer)) {
if (type->is_reference) { if (type->is_reference) {
Printv(wrap, tab4, "return ", type->print_cast(), " &_result;\n",0); Printv(wrap, tab4, "return ", DataType_print_cast(type), " &_result;\n",0);
} else { } else {
Printv(wrap, tab4, "return _result;\n",0); Printv(wrap, tab4, "return _result;\n",0);
} }
@ -2000,11 +2000,11 @@ void cplus_emit_constructor(char *classname, char *classtype, char *classrename,
Printv(wrap, "#define ", iname, "(", 0); Printv(wrap, "#define ", iname, "(", 0);
strcpy(cname,iname); strcpy(cname,iname);
if (ObjCClass) { if (ObjCClass) {
Printv(fcall, type->print_cast(), "[", classname, " ", mname,0); Printv(fcall, DataType_print_cast(type), "[", classname, " ", mname,0);
} else if (CPlusPlus) { } else if (CPlusPlus) {
Printv(fcall, "new ", classname, "(", 0); Printv(fcall, "new ", classname, "(", 0);
} else { } else {
Printv(fcall, type->print_cast(), " calloc(1,sizeof(", classtype, classname, "))", 0); Printv(fcall, DataType_print_cast(type), " calloc(1,sizeof(", classtype, classname, "))", 0);
} }
// Walk down the parameter list and spit out arguments // Walk down the parameter list and spit out arguments
@ -2048,7 +2048,7 @@ void cplus_emit_constructor(char *classname, char *classtype, char *classrename,
if (p->call_type & CALL_REFERENCE) { if (p->call_type & CALL_REFERENCE) {
p->t->is_pointer--; p->t->is_pointer--;
} }
Printf(wrap, p->t->print_real(p->name)); Printf(wrap, DataType_print_real(p->t,p->name));
if (p->call_type & CALL_REFERENCE) { if (p->call_type & CALL_REFERENCE) {
p->t->is_pointer++; p->t->is_pointer++;
} }
@ -2192,9 +2192,9 @@ void cplus_emit_variable_get(char *classname, char *classtype, char *classrename
if ((type->type == T_USER) && (!type->is_pointer)) { if ((type->type == T_USER) && (!type->is_pointer)) {
type->is_pointer++; type->is_pointer++;
if (tm) { if (tm) {
Printv(wrap, "static ", type->print_type(), " ", cname, "(", Printv(wrap, "static ", DataType_print_type(type), " ", cname, "(",
classtype, classname, " *obj) {\n", classtype, classname, " *obj) {\n",
tab4, type->print_type(), " result;\n", tab4, DataType_print_type(type), " result;\n",
tm, "\n", tm, "\n",
tab4, "return result;\n", tab4, "return result;\n",
"}\n", "}\n",
@ -2207,16 +2207,16 @@ void cplus_emit_variable_get(char *classname, char *classtype, char *classrename
type->is_pointer--; type->is_pointer--;
} else { } else {
if (tm) { if (tm) {
Printv(wrap, "static ", type->print_type(), " ", cname, "(", Printv(wrap, "static ", DataType_print_type(type), " ", cname, "(",
classtype, classname, " *obj) {\n", classtype, classname, " *obj) {\n",
tab4, type->print_type(), " result;\n", tab4, DataType_print_type(type), " result;\n",
tm, "\n", tm, "\n",
tab4, "return result;\n", tab4, "return result;\n",
"}\n", "}\n",
0); 0);
} else { } else {
Printv(wrap, "#define ", cname, "(_swigobj) (",0); Printv(wrap, "#define ", cname, "(_swigobj) (",0);
if (!type->is_reference) Printf(wrap,type->print_cast()); if (!type->is_reference) Printf(wrap,DataType_print_cast(type));
else else
Printf(wrap,"&"); Printf(wrap,"&");
Printv(wrap, " _swigobj->", mname, ")\n",0); Printv(wrap, " _swigobj->", mname, ")\n",0);
@ -2380,8 +2380,8 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
is_user = 1; is_user = 1;
} }
Printv(wrap, Printv(wrap,
"static ", type->print_type(), " ", cname, "(", "static ", DataType_print_type(type), " ", cname, "(",
classtype, classname, " *obj, ", type->print_real((char*)"val"), ") {\n", classtype, classname, " *obj, ", DataType_print_real(type,(char*)"val"), ") {\n",
0); 0);
if (is_user) { if (is_user) {
type->is_pointer--; type->is_pointer--;
@ -2389,7 +2389,7 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
Printv(wrap,tm,"\n",0); Printv(wrap,tm,"\n",0);
// Return the member // Return the member
if (is_user) type->is_pointer++; if (is_user) type->is_pointer++;
Printv(wrap, tab4, "return ", type->print_cast(), " val;\n",0); Printv(wrap, tab4, "return ", DataType_print_cast(type), " val;\n",0);
if (is_user) type->is_pointer--; if (is_user) type->is_pointer--;
Printf(wrap,"}\n"); Printf(wrap,"}\n");
} else { } else {
@ -2413,8 +2413,8 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
if ((type->type == T_CHAR) && (type->is_pointer == 1)) { if ((type->type == T_CHAR) && (type->is_pointer == 1)) {
char temp[512]; char temp[512];
Printv(wrap, Printv(wrap,
"static ", type->print_type(), " ", cname, "(", "static ", DataType_print_type(type), " ", cname, "(",
classtype, classname, " *obj, ", type->print_real((char*)"val"), ") {\n", classtype, classname, " *obj, ", DataType_print_real(type,(char*)"val"), ") {\n",
0); 0);
sprintf(temp,"obj->%s",mname); sprintf(temp,"obj->%s",mname);
if (CPlusPlus) { if (CPlusPlus) {
@ -2562,7 +2562,7 @@ void cplus_inherit_scope(int count, char **baseclass) {
bc = CPP_class::search(baseclass[i]); bc = CPP_class::search(baseclass[i]);
if (bc) { if (bc) {
if (bc->scope) if (bc->scope)
DataType::merge_scope(bc->scope); DataType_merge_scope(bc->scope);
if (bc->local) { if (bc->local) {
// Copy local symbol table // Copy local symbol table

View file

@ -51,10 +51,10 @@ void emit_extern_var(char *decl, DataType *t, int extern_type, FILE *f) {
if (t->is_reference) { if (t->is_reference) {
t->is_pointer--; t->is_pointer--;
fprintf(f,"%s& %s%s; \n", t->print_full(), decl, arr); fprintf(f,"%s& %s%s; \n", DataType_print_full(t), decl, arr);
t->is_pointer++; t->is_pointer++;
} else { } else {
fprintf(f,"%s %s%s; \n", t->print_full(), decl,arr); fprintf(f,"%s %s%s; \n", DataType_print_full(t), decl,arr);
} }
if (t->arraystr) if (t->arraystr)
t->is_pointer++; t->is_pointer++;
@ -67,10 +67,10 @@ void emit_extern_var(char *decl, DataType *t, int extern_type, FILE *f) {
// fprintf(f,"#line %d \"%s\"\n", line_number, input_file); // fprintf(f,"#line %d \"%s\"\n", line_number, input_file);
if (t->is_reference) { if (t->is_reference) {
t->is_pointer--; t->is_pointer--;
fprintf(f,"extern %s& %s%s; \n", t->print_full(), decl,arr); fprintf(f,"extern %s& %s%s; \n", DataType_print_full(t), decl,arr);
t->is_pointer++; t->is_pointer++;
} else { } else {
fprintf(f,"extern %s %s%s; \n", t->print_full(), decl,arr); fprintf(f,"extern %s %s%s; \n", DataType_print_full(t), decl,arr);
} }
if (t->arraystr) if (t->arraystr)
t->is_pointer++; t->is_pointer++;
@ -104,10 +104,10 @@ void emit_extern_func(char *decl, DataType *t, ParmList *L, int extern_type, FIL
case 0: case 0:
if (t->is_reference) { if (t->is_reference) {
t->is_pointer--; t->is_pointer--;
fprintf(f,"%s&", t->print_full()); fprintf(f,"%s&", DataType_print_full(t));
t->is_pointer++; t->is_pointer++;
} else { } else {
fprintf(f,"%s", t->print_full()); fprintf(f,"%s", DataType_print_full(t));
} }
fprintf(f,"%s(", decl); fprintf(f,"%s(", decl);
@ -119,10 +119,10 @@ void emit_extern_func(char *decl, DataType *t, ParmList *L, int extern_type, FIL
// fprintf(f,"#line %d \"%s\"\n", line_number, input_file); // fprintf(f,"#line %d \"%s\"\n", line_number, input_file);
if (t->is_reference) { if (t->is_reference) {
t->is_pointer--; t->is_pointer--;
fprintf(f,"extern %s&", t->print_full()); fprintf(f,"extern %s&", DataType_print_full(t));
t->is_pointer++; t->is_pointer++;
} else { } else {
fprintf(f,"extern %s", t->print_full()); fprintf(f,"extern %s", DataType_print_full(t));
} }
fprintf(f,"%s(", decl); fprintf(f,"%s(", decl);
ParmList_print_types(L,f); ParmList_print_types(L,f);
@ -133,10 +133,10 @@ void emit_extern_func(char *decl, DataType *t, ParmList *L, int extern_type, FIL
// fprintf(f,"#line %d \"%s\"\n", line_number, input_file); // fprintf(f,"#line %d \"%s\"\n", line_number, input_file);
if (t->is_reference) { if (t->is_reference) {
t->is_pointer--; t->is_pointer--;
fprintf(f,"extern \"C\" %s&", t->print_full()); fprintf(f,"extern \"C\" %s&", DataType_print_full(t));
t->is_pointer++; t->is_pointer++;
} else { } else {
fprintf(f,"extern \"C\" %s", t->print_full()); fprintf(f,"extern \"C\" %s", DataType_print_full(t));
} }
fprintf(f,"%s(", decl); fprintf(f,"%s(", decl);
ParmList_print_types(L,f); ParmList_print_types(L,f);
@ -146,10 +146,10 @@ void emit_extern_func(char *decl, DataType *t, ParmList *L, int extern_type, FIL
// A function declaration (for inlining ) // A function declaration (for inlining )
if (t->is_reference) { if (t->is_reference) {
t->is_pointer--; t->is_pointer--;
fprintf(f,"%s&", t->print_full()); fprintf(f,"%s&", DataType_print_full(t));
t->is_pointer++; t->is_pointer++;
} else { } else {
fprintf(f,"%s", t->print_full()); fprintf(f,"%s", DataType_print_full(t));
} }
fprintf(f,"%s(", decl); fprintf(f,"%s(", decl);
@ -199,12 +199,12 @@ int emit_args(DataType *rt, ParmList *l, Wrapper *f) {
// Special case for return by "value" // Special case for return by "value"
rt->is_pointer++; rt->is_pointer++;
Wrapper_add_localv(f, "_result", rt->print_type(), "_result",0); Wrapper_add_localv(f, "_result", DataType_print_type(rt), "_result",0);
rt->is_pointer--; rt->is_pointer--;
} else { } else {
// Normal return value // Normal return value
Wrapper_add_localv(f, "_result", rt->print_type(), "_result",0); Wrapper_add_localv(f, "_result", DataType_print_type(rt), "_result",0);
} }
} }
@ -218,13 +218,13 @@ int emit_args(DataType *rt, ParmList *l, Wrapper *f) {
// Figure out default values // Figure out default values
if (((p->t->is_reference) && (p->defvalue)) || if (((p->t->is_reference) && (p->defvalue)) ||
((p->t->type == T_USER) && (p->call_type == CALL_REFERENCE) && (p->defvalue))) { ((p->t->type == T_USER) && (p->call_type == CALL_REFERENCE) && (p->defvalue))) {
Wrapper_add_localv(f,temp, p->t->print_type(), temp," = (", p->t->print_type(), ") &", p->defvalue,0); Wrapper_add_localv(f,temp, DataType_print_type(p->t), temp," = (", DataType_print_type(p->t), ") &", p->defvalue,0);
} else { } else {
char deftmp[1024]; char deftmp[1024];
if (p->defvalue) { if (p->defvalue) {
Wrapper_add_localv(f,temp, p->t->print_type(), temp, " = (", p->t->print_type(), ") ", p->defvalue, 0); Wrapper_add_localv(f,temp, DataType_print_type(p->t), temp, " = (", DataType_print_type(p->t), ") ", p->defvalue, 0);
} else { } else {
Wrapper_add_localv(f,temp, p->t->print_type(), temp, 0); Wrapper_add_localv(f,temp, DataType_print_type(p->t), temp, 0);
} }
tm = typemap_lookup((char*)"arginit", typemap_lang, p->t,p->name,(char*)"",temp,f); tm = typemap_lookup((char*)"arginit", typemap_lang, p->t,p->name,(char*)"",temp,f);
@ -288,24 +288,24 @@ void emit_func_call(char *decl, DataType *t, ParmList *l, Wrapper *f) {
// used properly. // used properly.
if (CPlusPlus) { if (CPlusPlus) {
Printv(fcall, "_result = new ", t->print_type(), "(", 0); Printv(fcall, "_result = new ", DataType_print_type(t), "(", 0);
} else { } else {
t->is_pointer++; t->is_pointer++;
Printv(fcall, "_result = ", t->print_cast(), " malloc(sizeof(", 0); Printv(fcall, "_result = ", DataType_print_cast(t), " malloc(sizeof(", 0);
t->is_pointer--; t->is_pointer--;
Printv(fcall, t->print_type(), "));\n", 0); Printv(fcall, DataType_print_type(t), "));\n", 0);
Printv(fcall, tab4, "*(_result) = ", 0); Printv(fcall, tab4, "*(_result) = ", 0);
} }
} else { } else {
// Check if this is a C++ reference // Check if this is a C++ reference
if (t->is_reference) { if (t->is_reference) {
t->is_pointer--; t->is_pointer--;
Printv(fcall, t->print_full(), "& _result_ref = ", 0); Printv(fcall, DataType_print_full(t), "& _result_ref = ", 0);
t->is_pointer++; t->is_pointer++;
} else { } else {
// Normal return value // Normal return value
Printv(fcall, "_result = ", t->print_cast(), 0); Printv(fcall, "_result = ", DataType_print_cast(t), 0);
} }
} }
} }
@ -317,7 +317,7 @@ void emit_func_call(char *decl, DataType *t, ParmList *l, Wrapper *f) {
p = ParmList_first(l); p = ParmList_first(l);
while(p != 0) { while(p != 0) {
if ((p->t->type != T_VOID) || (p->t->is_pointer)){ if ((p->t->type != T_VOID) || (p->t->is_pointer)){
Printf(fcall,p->t->print_arraycast()); Printf(fcall,DataType_print_arraycast(p->t));
if ((!p->t->is_reference) && (p->call_type & CALL_VALUE)) if ((!p->t->is_reference) && (p->call_type & CALL_VALUE))
Printf(fcall, "&"); Printf(fcall, "&");
if ((!(p->call_type & CALL_VALUE)) && if ((!(p->call_type & CALL_VALUE)) &&
@ -340,7 +340,7 @@ void emit_func_call(char *decl, DataType *t, ParmList *l, Wrapper *f) {
Printf(fcall,";\n"); Printf(fcall,";\n");
if (t->is_reference) { if (t->is_reference) {
Printv(fcall, tab4, "_result = ", t->print_cast(), " &_result_ref;\n", 0); Printv(fcall, tab4, "_result = ", DataType_print_cast(t), " &_result_ref;\n", 0);
} }
// Check for exception handling // Check for exception handling
@ -407,11 +407,11 @@ void emit_set_get(char *name, char *iname, DataType *t) {
if ((t->type == T_USER) && (!t->is_pointer)) { if ((t->type == T_USER) && (!t->is_pointer)) {
t->is_pointer++; t->is_pointer++;
fprintf(f_header,"static %s %s(%s val) {\n", fprintf(f_header,"static %s %s(%s val) {\n",
t->print_type(), Swig_name_set(name), t->print_type()); DataType_print_type(t), Swig_name_set(name), DataType_print_type(t));
t->is_pointer--; t->is_pointer--;
} else { } else {
fprintf(f_header,"static %s %s(%s val) {\n", fprintf(f_header,"static %s %s(%s val) {\n",
t->print_type(), Swig_name_set(name), t->print_type()); DataType_print_type(t), Swig_name_set(name), DataType_print_type(t));
} }
if ((t->type != T_VOID) || (t->is_pointer)) { if ((t->type != T_VOID) || (t->is_pointer)) {
@ -422,11 +422,11 @@ void emit_set_get(char *name, char *iname, DataType *t) {
// Otherwise, just assign it. // Otherwise, just assign it.
if (t->type != T_USER) { if (t->type != T_USER) {
fprintf(f_header,"\t return (%s) (%s = val);\n", t->print_type(), name); fprintf(f_header,"\t return (%s) (%s = val);\n", DataType_print_type(t), name);
} else { } else {
fprintf(f_header,"\t %s = *(val);\n", name); fprintf(f_header,"\t %s = *(val);\n", name);
t->is_pointer++; t->is_pointer++;
fprintf(f_header,"\t return (%s) &%s;\n", t->print_type(),name); fprintf(f_header,"\t return (%s) &%s;\n", DataType_print_type(t),name);
t->is_pointer--; t->is_pointer--;
} }
} else { } else {
@ -447,7 +447,7 @@ void emit_set_get(char *name, char *iname, DataType *t) {
fprintf(f_header,"\t return %s;\n", name); fprintf(f_header,"\t return %s;\n", name);
} }
} else { } else {
fprintf(f_header,"\t return (%s) (%s = val);\n", t->print_type(), name); fprintf(f_header,"\t return (%s) (%s = val);\n", DataType_print_type(t), name);
} }
} }
} }
@ -482,13 +482,13 @@ void emit_set_get(char *name, char *iname, DataType *t) {
if ((t->type == T_USER) && (!t->is_pointer)) { if ((t->type == T_USER) && (!t->is_pointer)) {
t->is_pointer++; t->is_pointer++;
fprintf(f_header,"static %s %s() { \n", fprintf(f_header,"static %s %s() { \n",
t->print_type(), Swig_name_get(name)); DataType_print_type(t), Swig_name_get(name));
fprintf(f_header,"\t return (%s) &%s;\n", t->print_type(), name); fprintf(f_header,"\t return (%s) &%s;\n", DataType_print_type(t), name);
t->is_pointer--; t->is_pointer--;
} else { } else {
fprintf(f_header,"static %s %s() { \n", fprintf(f_header,"static %s %s() { \n",
t->print_type(), Swig_name_get(name)); DataType_print_type(t), Swig_name_get(name));
fprintf(f_header,"\t return (%s) %s;\n", t->print_type(), name); fprintf(f_header,"\t return (%s) %s;\n", DataType_print_type(t), name);
} }
fprintf(f_header,"}\n"); fprintf(f_header,"}\n");

View file

@ -168,7 +168,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
lang = l; lang = l;
Status = 0; Status = 0;
DataType::init_typedef(); // Initialize the type handler DataType_init_typedef(); // Initialize the type handler
// Set up some default symbols (available in both SWIG interface files // Set up some default symbols (available in both SWIG interface files
// and C files) // and C files)

View file

@ -327,15 +327,15 @@ void ParmList_print_types(ParmList *l, DOHFile *f) {
if (l->parms[pn]->t->is_reference) { if (l->parms[pn]->t->is_reference) {
if (l->parms[pn]->t->is_pointer) { if (l->parms[pn]->t->is_pointer) {
l->parms[pn]->t->is_pointer--; l->parms[pn]->t->is_pointer--;
Printf(f,"%s&", l->parms[pn]->t->print_real()); Printf(f,"%s&", DataType_print_real(l->parms[pn]->t,0));
l->parms[pn]->t->is_pointer++; l->parms[pn]->t->is_pointer++;
} else { } else {
Printf(f,"%s&", l->parms[pn]->t->print_real()); Printf(f,"%s&", DataType_print_real(l->parms[pn]->t,0));
} }
} else { } else {
if (l->parms[pn]->call_type & CALL_VALUE) l->parms[pn]->t->is_pointer++; if (l->parms[pn]->call_type & CALL_VALUE) l->parms[pn]->t->is_pointer++;
if (l->parms[pn]->call_type & CALL_REFERENCE) l->parms[pn]->t->is_pointer--; if (l->parms[pn]->call_type & CALL_REFERENCE) l->parms[pn]->t->is_pointer--;
Printf(f,"%s", l->parms[pn]->t->print_real()); Printf(f,"%s", DataType_print_real(l->parms[pn]->t,0));
l->parms[pn]->t->is_pointer = is_pointer; l->parms[pn]->t->is_pointer = is_pointer;
} }
pn++; pn++;
@ -360,15 +360,15 @@ void ParmList_print_args(ParmList *l, DOHFile *f) {
if (l->parms[pn]->t->is_reference) { if (l->parms[pn]->t->is_reference) {
if (l->parms[pn]->t->is_pointer) { if (l->parms[pn]->t->is_pointer) {
l->parms[pn]->t->is_pointer--; l->parms[pn]->t->is_pointer--;
Printf(f,"%s&", l->parms[pn]->t->print_full()); Printf(f,"%s&", DataType_print_full(l->parms[pn]->t));
l->parms[pn]->t->is_pointer++; l->parms[pn]->t->is_pointer++;
} else { } else {
Printf(f,"%s&", l->parms[pn]->t->print_full()); Printf(f,"%s&", DataType_print_full(l->parms[pn]->t));
} }
} else { } else {
if (l->parms[pn]->call_type & CALL_VALUE) l->parms[pn]->t->is_pointer++; if (l->parms[pn]->call_type & CALL_VALUE) l->parms[pn]->t->is_pointer++;
if (l->parms[pn]->call_type & CALL_REFERENCE) l->parms[pn]->t->is_pointer--; if (l->parms[pn]->call_type & CALL_REFERENCE) l->parms[pn]->t->is_pointer--;
Printf(f,"%s", l->parms[pn]->t->print_full()); Printf(f,"%s", DataType_print_full(l->parms[pn]->t));
l->parms[pn]->t->is_pointer = is_pointer; l->parms[pn]->t->is_pointer = is_pointer;
} }
Printf(f,"%s",l->parms[pn]->name); Printf(f,"%s",l->parms[pn]->name);

View file

@ -907,7 +907,7 @@ statement : INCLUDE STRING LBRACE {
temp_type.is_pointer = 0; temp_type.is_pointer = 0;
temp_type.implicit_ptr = 0; temp_type.implicit_ptr = 0;
sprintf(temp_type.name,"int"); sprintf(temp_type.name,"int");
temp_type.typedef_add($3,1); DataType_typedef_add(&temp_type,$3,1);
} }
} }
@ -920,7 +920,7 @@ statement : INCLUDE STRING LBRACE {
temp_type.implicit_ptr = 0; temp_type.implicit_ptr = 0;
sprintf(temp_type.name,"int"); sprintf(temp_type.name,"int");
Active_typedef = new DataType(&temp_type); Active_typedef = new DataType(&temp_type);
temp_type.typedef_add($8,1); DataType_typedef_add(&temp_type,$8,1);
} typedeflist { } } typedeflist { }
/* ----------------------------------------------------------------- /* -----------------------------------------------------------------
@ -1141,10 +1141,10 @@ typedef_decl : TYPEDEF type declaration {
/* Add a new typedef */ /* Add a new typedef */
Active_typedef = new DataType($2); Active_typedef = new DataType($2);
$2->is_pointer += $3.is_pointer; $2->is_pointer += $3.is_pointer;
$2->typedef_add($3.id); DataType_typedef_add($2, $3.id,0);
/* If this is %typedef, add it to the header */ /* If this is %typedef, add it to the header */
if ($1) if ($1)
fprintf(f_header,"typedef %s %s;\n", $2->print_full(), $3.id); fprintf(f_header,"typedef %s %s;\n", DataType_print_full($2), $3.id);
cplus_register_type($3.id); cplus_register_type($3.id);
} typedeflist { }; } typedeflist { };
@ -1161,7 +1161,7 @@ typedef_decl : TYPEDEF type declaration {
strcpy($2->name,"<function ptr>"); strcpy($2->name,"<function ptr>");
$2->type = T_USER; $2->type = T_USER;
$2->is_pointer = 1; $2->is_pointer = 1;
$2->typedef_add($5,1); DataType_typedef_add($2,$5,1);
cplus_register_type($5); cplus_register_type($5);
delete $2; delete $2;
delete $5; delete $5;
@ -1183,7 +1183,7 @@ typedef_decl : TYPEDEF type declaration {
strcpy($2->name,"<function ptr>"); strcpy($2->name,"<function ptr>");
$2->type = T_USER; $2->type = T_USER;
$2->is_pointer = 1; $2->is_pointer = 1;
$2->typedef_add($6,1); DataType_typedef_add($2,$6,1);
cplus_register_type($6); cplus_register_type($6);
delete $2; delete $2;
delete $6; delete $6;
@ -1202,7 +1202,7 @@ typedef_decl : TYPEDEF type declaration {
// Turn this into a "pointer" corresponding to the array // Turn this into a "pointer" corresponding to the array
$2->is_pointer++; $2->is_pointer++;
$2->arraystr = copy_string(Char(ArrayString)); $2->arraystr = copy_string(Char(ArrayString));
$2->typedef_add($3.id); DataType_typedef_add($2,$3.id,0);
fprintf(stderr,"%s : Line %d. Warning. Array type %s will be read-only without a typemap\n",input_file,line_number, $3.id); fprintf(stderr,"%s : Line %d. Warning. Array type %s will be read-only without a typemap\n",input_file,line_number, $3.id);
cplus_register_type($3.id); cplus_register_type($3.id);
@ -1224,7 +1224,7 @@ typedeflist : COMMA declaration typedeflist {
DataType *t; DataType *t;
t = new DataType(Active_typedef); t = new DataType(Active_typedef);
t->is_pointer += $2.is_pointer; t->is_pointer += $2.is_pointer;
t->typedef_add($2.id); DataType_typedef_add(t,$2.id,0);
cplus_register_type($2.id); cplus_register_type($2.id);
delete t; delete t;
} }
@ -1235,7 +1235,7 @@ typedeflist : COMMA declaration typedeflist {
t->status = STAT_READONLY | STAT_REPLACETYPE; t->status = STAT_READONLY | STAT_REPLACETYPE;
t->is_pointer += $2.is_pointer + 1; t->is_pointer += $2.is_pointer + 1;
t->arraystr = copy_string(Char(ArrayString)); t->arraystr = copy_string(Char(ArrayString));
t->typedef_add($2.id); DataType_typedef_add(t,$2.id,0);
cplus_register_type($2.id); cplus_register_type($2.id);
delete t; delete t;
fprintf(stderr,"%s : Line %d. Warning. Array type %s will be read-only without a typemap.\n",input_file,line_number, $2.id); fprintf(stderr,"%s : Line %d. Warning. Array type %s will be read-only without a typemap.\n",input_file,line_number, $2.id);
@ -1575,7 +1575,7 @@ type : TYPE_INT {
strcpy($$->name,$1); strcpy($$->name,$1);
$$->type = T_USER; $$->type = T_USER;
/* Do a typedef lookup */ /* Do a typedef lookup */
$$->typedef_resolve(); DataType_typedef_resolve($$,0);
if (strlen($2) > 0) { if (strlen($2) > 0) {
if ((strlen($2) + strlen($$->name)) >= MAX_NAME) { if ((strlen($2) + strlen($$->name)) >= MAX_NAME) {
fprintf(stderr,"%s : Line %d. Fatal error. Type-name is too long!\n", fprintf(stderr,"%s : Line %d. Fatal error. Type-name is too long!\n",
@ -1599,7 +1599,7 @@ type : TYPE_INT {
$$ = new DataType; $$ = new DataType;
sprintf($$->name,"%s::%s",$1,$3); sprintf($$->name,"%s::%s",$1,$3);
$$->type = T_USER; $$->type = T_USER;
$$->typedef_resolve(); DataType_typedef_resolve($$,0);
} }
/* This declaration causes a shift-reduce conflict. Unresolved for now */ /* This declaration causes a shift-reduce conflict. Unresolved for now */
@ -1608,13 +1608,13 @@ type : TYPE_INT {
$$ = new DataType; $$ = new DataType;
sprintf($$->name,"%s", $2); sprintf($$->name,"%s", $2);
$$->type = T_USER; $$->type = T_USER;
$$->typedef_resolve(1); DataType_typedef_resolve($$,1);
} }
| ENUM ID { | ENUM ID {
$$ = new DataType; $$ = new DataType;
sprintf($$->name,"enum %s", $2); sprintf($$->name,"enum %s", $2);
$$->type = T_INT; $$->type = T_INT;
$$->typedef_resolve(1); DataType_typedef_resolve($$,1);
} }
; ;
@ -1993,7 +1993,7 @@ cpp_class :
extern cpptype ID inherit LBRACE { extern cpptype ID inherit LBRACE {
char *iname; char *iname;
init_language(); init_language();
DataType::new_scope(); DataType_new_scope(0);
sprintf(temp_name,"CPP_CLASS:%s\n",$3); sprintf(temp_name,"CPP_CLASS:%s\n",$3);
if (add_symbol(temp_name)) { if (add_symbol(temp_name)) {
@ -2038,7 +2038,7 @@ cpp_class :
dump_nested($3); dump_nested($3);
// Save and collapse current scope // Save and collapse current scope
cplus_register_scope(DataType::collapse_scope($3)); cplus_register_scope(DataType_collapse_scope($3));
cplus_class_close((char *) 0); cplus_class_close((char *) 0);
cplus_mode = CPLUS_PUBLIC; cplus_mode = CPLUS_PUBLIC;
} }
@ -2048,7 +2048,7 @@ cpp_class :
| TYPEDEF cpptype ID inherit LBRACE { | TYPEDEF cpptype ID inherit LBRACE {
char *iname; char *iname;
init_language(); init_language();
DataType::new_scope(); DataType_new_scope(0);
sprintf(temp_name,"CPP_CLASS:%s\n",$3); sprintf(temp_name,"CPP_CLASS:%s\n",$3);
if (add_symbol(temp_name)) { if (add_symbol(temp_name)) {
@ -2111,7 +2111,7 @@ cpp_class :
// Collapse any datatypes created in the the class // Collapse any datatypes created in the the class
cplus_register_scope(DataType::collapse_scope($3)); cplus_register_scope(DataType_collapse_scope($3));
if ($9.is_pointer > 0) { if ($9.is_pointer > 0) {
cplus_class_close($3); cplus_class_close($3);
} else { } else {
@ -2119,11 +2119,11 @@ cpp_class :
} }
// Create a typedef in global scope // Create a typedef in global scope
if ($9.is_pointer == 0) if ($9.is_pointer == 0)
Active_typedef->typedef_add($9.id); DataType_typedef_add(Active_typedef,$9.id,0);
else { else {
DataType *t = new DataType(Active_typedef); DataType *t = new DataType(Active_typedef);
t->is_pointer += $9.is_pointer; t->is_pointer += $9.is_pointer;
t->typedef_add($9.id); DataType_typedef_add(t,$9.id,0);
cplus_register_type($9.id); cplus_register_type($9.id);
delete t; delete t;
} }
@ -2135,7 +2135,7 @@ cpp_class :
| TYPEDEF cpptype LBRACE { | TYPEDEF cpptype LBRACE {
char *iname; char *iname;
init_language(); init_language();
DataType::new_scope(); DataType_new_scope(0);
if ((!CPlusPlus) && (strcmp($2,"class") == 0)) if ((!CPlusPlus) && (strcmp($2,"class") == 0))
fprintf(stderr,"%s : Line %d. *** WARNING ***. C++ mode is disabled (enable using -c++)\n", input_file, line_number); fprintf(stderr,"%s : Line %d. *** WARNING ***. C++ mode is disabled (enable using -c++)\n", input_file, line_number);
@ -2174,7 +2174,7 @@ cpp_class :
// Go back to previous scope // Go back to previous scope
cplus_register_scope(DataType::collapse_scope((char *) 0)); cplus_register_scope(DataType_collapse_scope((char *) 0));
if ($7.is_pointer == 0) if ($7.is_pointer == 0)
cplus_class_close($7.id); cplus_class_close($7.id);
cplus_mode = CPLUS_PUBLIC; cplus_mode = CPLUS_PUBLIC;
@ -2505,7 +2505,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
temp_type.is_pointer = 0; temp_type.is_pointer = 0;
temp_type.implicit_ptr = 0; temp_type.implicit_ptr = 0;
sprintf(temp_type.name,"int"); sprintf(temp_type.name,"int");
temp_type.typedef_add($2,1); DataType_typedef_add(&temp_type,$2,1);
} }
} }
} }

View file

@ -1293,11 +1293,11 @@ extern "C" int yylex(void) {
// do a typedef lookup on it. // do a typedef lookup on it.
if (check_typedef) { if (check_typedef) {
if (DataType::is_typedef(yytext)) { if (DataType_is_typedef(yytext)) {
yylval.type = new DataType; yylval.type = new DataType;
yylval.type->type = T_USER; yylval.type->type = T_USER;
strcpy(yylval.type->name,yytext); strcpy(yylval.type->name,yytext);
yylval.type->typedef_resolve(); DataType_typedef_resolve(yylval.type,0);
return(TYPE_TYPEDEF); return(TYPE_TYPEDEF);
} }
} }

View file

@ -120,35 +120,38 @@ public:
DataType(DataType *); DataType(DataType *);
DataType(int type); DataType(int type);
~DataType(); ~DataType();
void primitive(); // Turn a datatype into its primitive type
char *print_type(); // Return string containing datatype
char *print_full(); // Return string with full datatype
char *print_cast(); // Return string for type casting
char *print_mangle();// Return mangled version of type
char *print_real(char *local=0); // Print the real datatype (as far as we can determine)
char *print_arraycast(); // Prints an array cast
char *print_mangle_default(); // Default mangling scheme
// Array query functions
int array_dimensions(); // Return number of array dimensions (if any)
char *get_dimension(int); // Return string containing a particular dimension
char *get_array(); // Returns the array string for a datatype
// typedef support
void typedef_add(char *name, int mode = 0); // Add this type to typedef list
void typedef_resolve(int level = 0); // See if this type has been typedef'd
void typedef_replace(); // Replace this type with it's original type
static int is_typedef(char *name); // See if this is a typedef
void typedef_updatestatus(int newstatus); // Change status of a typedef
static void init_typedef(void); // Initialize typedef manager
static void merge_scope(void *h); // Functions for managing scoping of datatypes
static void new_scope(void *h = 0);
static void *collapse_scope(char *);
void remember();
static void record_base(char *derived, char *base);
}; };
extern DataType *NewDataType(int type);
extern DataType *CopyDataType(DataType *type);
extern void DelDataType(DataType *type);
extern void DataType_primitive(DataType *);
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 int DataType_array_dimensions(DataType *);
extern char *DataType_get_dimension(DataType *, int);
/* Typedef support */
extern void DataType_typedef_add(DataType *, char *name, int mode);
extern void DataType_typedef_resolve(DataType *, int level);
extern void DataType_typedef_replace(DataType *);
extern int DataType_is_typedef(char *name);
extern void DataType_updatestatus(DataType *, int newstatus);
extern void DataType_init_typedef();
extern void DataType_merge_scope(DOHHash *h);
extern void DataType_new_scope(DOHHash *h);
extern void *DataType_collapse_scope(char *name);
extern void DataType_remember(DataType *);
extern void DataType_record_base(char *derived, char *base);
#define STAT_REPLACETYPE 2 #define STAT_REPLACETYPE 2
/************************************************************************ /************************************************************************
@ -336,7 +339,7 @@ public:
virtual void set_init(char *init_name); virtual void set_init(char *init_name);
virtual void add_native(char *name, char *iname, DataType *t, ParmList *l); virtual void add_native(char *name, char *iname, DataType *t, ParmList *l);
virtual char *type_mangle(DataType *t) { virtual char *type_mangle(DataType *t) {
return t->print_mangle_default(); return DataType_print_mangle_default(t);
} }
virtual void add_typedef(DataType *t, char *name); virtual void add_typedef(DataType *t, char *name);
virtual void create_command(char *cname, char *iname); virtual void create_command(char *cname, char *iname);

View file

@ -154,7 +154,7 @@ void typemap_apply(DataType *tm_type, char *tm_name, DataType *type, char *pname
// Form the application name // Form the application name
if (!pname) pname = (char*)""; if (!pname) pname = (char*)"";
sprintf(temp,"%s$%s",type->print_type(),pname); sprintf(temp,"%s$%s",DataType_print_type(type),pname);
// See if there is a method already defined // See if there is a method already defined
@ -177,13 +177,13 @@ void typemap_apply(DataType *tm_type, char *tm_name, DataType *type, char *pname
if ((tm_type->arraystr) && (type->arraystr)) { if ((tm_type->arraystr) && (type->arraystr)) {
char s[128],*t; char s[128],*t;
if (tm_type->array_dimensions() != type->array_dimensions()) { if (DataType_array_dimensions(tm_type) != DataType_array_dimensions(type)) {
fprintf(stderr,"%s:%d: Warning. Array types have different number of dimensions.\n", fprintf(stderr,"%s:%d: Warning. Array types have different number of dimensions.\n",
input_file,line_number); input_file,line_number);
} else { } else {
for (int i = 0; i < tm_type->array_dimensions(); i++) { for (int i = 0; i < DataType_array_dimensions(tm_type); i++) {
strcpy(s,tm_type->get_dimension(i)); strcpy(s,DataType_get_dimension(tm_type,i));
t = type->get_dimension(i); t = DataType_get_dimension(type,i);
if (strcmp(s,"ANY") != 0) { if (strcmp(s,"ANY") != 0) {
if (strcmp(s,t)) if (strcmp(s,t))
fprintf(stderr,"%s:%d: Warning. Array typemap applied to an array of different size.\n", fprintf(stderr,"%s:%d: Warning. Array typemap applied to an array of different size.\n",
@ -209,7 +209,7 @@ void typemap_apply(DataType *tm_type, char *tm_name, DataType *type, char *pname
void typemap_clear_apply(DataType *type, char *pname) { void typemap_clear_apply(DataType *type, char *pname) {
char temp[512]; char temp[512];
if (!pname) pname = (char*)""; if (!pname) pname = (char*)"";
sprintf(temp,"%s$%s", type->print_type(), pname); sprintf(temp,"%s$%s", DataType_print_type(type), pname);
if (!application_hash) application_hash = NewHash(); if (!application_hash) application_hash = NewHash();
Delattr(application_hash,temp); Delattr(application_hash,temp);
} }
@ -231,9 +231,9 @@ static char *typemap_string(char *lang, DataType *type, char *pname, char *ary,
Clear(str); Clear(str);
if (ary) if (ary)
Printv(str, lang, type->print_type(), pname, ary, suffix, 0); Printv(str, lang, DataType_print_type(type), pname, ary, suffix, 0);
else else
Printv(str, lang, type->print_type(), pname, suffix,0); Printv(str, lang, DataType_print_type(type), pname, suffix,0);
type->status = old_status; type->status = old_status;
return Char(str); return Char(str);
@ -254,7 +254,7 @@ void typemap_register(char *op, char *lang, DataType *type, char *pname,
char temp[256]; char temp[256];
int is_default = 0; int is_default = 0;
// printf("Registering : %s %s %s %s\n%s\n", op, lang, type->print_type(), pname, getcode); // printf("Registering : %s %s %s %s\n%s\n", op, lang, DataType_print_type(type), pname, getcode);
if (!typemap_hash) typemap_hash = NewHash(); if (!typemap_hash) typemap_hash = NewHash();
@ -262,7 +262,7 @@ void typemap_register(char *op, char *lang, DataType *type, char *pname,
// If this is a default typemap, downgrade the type! // If this is a default typemap, downgrade the type!
if (strcmp(pname,"SWIG_DEFAULT_TYPE") == 0) { if (strcmp(pname,"SWIG_DEFAULT_TYPE") == 0) {
tm->type->primitive(); DataType_primitive(tm->type);
is_default = 1; is_default = 1;
} }
@ -425,7 +425,7 @@ TypeMap *typemap_search_array(char *op, char *lang, DataType *type, char *pname,
if (!tm) { if (!tm) {
// We're going to go search for matches with the ANY tag // We're going to go search for matches with the ANY tag
DOHString *tempastr = NewString(""); DOHString *tempastr = NewString("");
ndim = type->array_dimensions(); // Get number of dimensions ndim = DataType_array_dimensions(type); // Get number of dimensions
j = (1 << ndim) - 1; // Status bits j = (1 << ndim) - 1; // Status bits
for (i = 0; i < (1 << ndim); i++) { for (i = 0; i < (1 << ndim); i++) {
// Form an array string // Form an array string
@ -433,7 +433,7 @@ TypeMap *typemap_search_array(char *op, char *lang, DataType *type, char *pname,
k = j; k = j;
for (n = 0; n < ndim; n++) { for (n = 0; n < ndim; n++) {
if (k & 1) { if (k & 1) {
Printf(tempastr,"[%s]",type->get_dimension(n)); Printf(tempastr,"[%s]",DataType_get_dimension(type,n));
} else { } else {
Printf(tempastr,"[ANY]"); Printf(tempastr,"[ANY]");
} }
@ -458,12 +458,12 @@ TypeMap *typemap_search_array(char *op, char *lang, DataType *type, char *pname,
if (tm) { if (tm) {
Printf(str,"%s",tm->code); Printf(str,"%s",tm->code);
ndim = type->array_dimensions(); ndim = DataType_array_dimensions(type);
sprintf(temp,"%d",ndim); sprintf(temp,"%d",ndim);
Replace(str,"$ndim",temp, DOH_REPLACE_ANY); Replace(str,"$ndim",temp, DOH_REPLACE_ANY);
for (i = 0; i < ndim; i++) { for (i = 0; i < ndim; i++) {
sprintf(temp,"$dim%d",i); sprintf(temp,"$dim%d",i);
Replace(str,temp,type->get_dimension(i), DOH_REPLACE_ANY); Replace(str,temp,DataType_get_dimension(type,i), DOH_REPLACE_ANY);
} }
} }
return tm; return tm;
@ -516,12 +516,12 @@ static void typemap_locals(DataType *t, char *pname, DOHString *s, ParmList *l,
char temp_ip1 = tt->implicit_ptr; char temp_ip1 = tt->implicit_ptr;
tt->is_pointer = 0; tt->is_pointer = 0;
tt->implicit_ptr = 0; tt->implicit_ptr = 0;
new_name = Wrapper_new_localv(f,str, tt->print_type(), str, 0); new_name = Wrapper_new_localv(f,str, DataType_print_type(tt), str, 0);
tt->is_pointer = temp_ip; tt->is_pointer = temp_ip;
tt->implicit_ptr = temp_ip1; tt->implicit_ptr = temp_ip1;
} }
else else
new_name = Wrapper_new_localv(f,str, tt->print_full(), str, 0); new_name = Wrapper_new_localv(f,str, DataType_print_full(tt), str, 0);
if (tt->arraystr) tt->is_pointer++; if (tt->arraystr) tt->is_pointer++;
// Substitute // Substitute
@ -535,9 +535,9 @@ static void typemap_locals(DataType *t, char *pname, DOHString *s, ParmList *l,
if (t->arraystr) { if (t->arraystr) {
char temp[10]; char temp[10];
for (int i = 0; i < t->array_dimensions(); i++) { for (int i = 0; i < DataType_array_dimensions(t); i++) {
sprintf(temp,"$dim%d",i); sprintf(temp,"$dim%d",i);
Replace(f->locals,temp,t->get_dimension(i), DOH_REPLACE_ANY); Replace(f->locals,temp,DataType_get_dimension(t,i), DOH_REPLACE_ANY);
} }
} }
@ -616,7 +616,7 @@ char *typemap_lookup_internal(char *op, char *lang, DataType *type, char *pname,
Replace(str,"$source",source,DOH_REPLACE_ANY); Replace(str,"$source",source,DOH_REPLACE_ANY);
Replace(str,"$target",target,DOH_REPLACE_ANY); Replace(str,"$target",target,DOH_REPLACE_ANY);
Replace(str,"$type",realtype->print_type(),DOH_REPLACE_ANY); Replace(str,"$type",DataType_print_type(realtype),DOH_REPLACE_ANY);
if (realname) { if (realname) {
Replace(str,"$parmname",realname,DOH_REPLACE_ANY); Replace(str,"$parmname",realname,DOH_REPLACE_ANY);
} else { } else {
@ -628,16 +628,16 @@ char *typemap_lookup_internal(char *op, char *lang, DataType *type, char *pname,
char temp_ip1 = realtype->implicit_ptr; char temp_ip1 = realtype->implicit_ptr;
realtype->is_pointer = 0; realtype->is_pointer = 0;
realtype->implicit_ptr = 0; realtype->implicit_ptr = 0;
char *bt = realtype->print_type(); char *bt = DataType_print_type(realtype);
if (bt[strlen(bt)-1] == ' ') if (bt[strlen(bt)-1] == ' ')
bt[strlen(bt)-1] = 0; bt[strlen(bt)-1] = 0;
Replace(str,"$basetype",bt,DOH_REPLACE_ANY); Replace(str,"$basetype",bt,DOH_REPLACE_ANY);
Replace(str,"$basemangle",realtype->print_mangle(), DOH_REPLACE_ANY); Replace(str,"$basemangle",DataType_print_mangle(realtype), DOH_REPLACE_ANY);
realtype->is_pointer = temp_ip; realtype->is_pointer = temp_ip;
realtype->implicit_ptr = temp_ip1; realtype->implicit_ptr = temp_ip1;
} }
Replace(str,"$mangle",realtype->print_mangle(), DOH_REPLACE_ANY); Replace(str,"$mangle",DataType_print_mangle(realtype), DOH_REPLACE_ANY);
// If there were locals and a wrapper function, replace // If there were locals and a wrapper function, replace
if ((tm->args) && f) { if ((tm->args) && f) {
@ -648,7 +648,7 @@ char *typemap_lookup_internal(char *op, char *lang, DataType *type, char *pname,
if ((tm->args) && !f) { if ((tm->args) && !f) {
if (!pname) pname = (char*)""; if (!pname) pname = (char*)"";
fprintf(stderr,"%s:%d: Warning. '%%typemap(%s,%s) %s %s' being applied with ignored locals.\n", fprintf(stderr,"%s:%d: Warning. '%%typemap(%s,%s) %s %s' being applied with ignored locals.\n",
input_file, line_number, lang,op, type->print_type(), pname); input_file, line_number, lang,op, DataType_print_type(type), pname);
} }
// Return character string // Return character string
@ -688,7 +688,7 @@ char *typemap_lookup(char *op, char *lang, DataType *type, char *pname, char *so
while (drop_pointer <= (type->is_pointer - type->implicit_ptr)) { while (drop_pointer <= (type->is_pointer - type->implicit_ptr)) {
type->is_pointer -= drop_pointer; type->is_pointer -= drop_pointer;
tstr = type->print_type(); tstr = DataType_print_type(type);
sprintf(temp,"%s$%s",tstr,ppname); sprintf(temp,"%s$%s",tstr,ppname);
// No mapping was found. See if the name has been mapped with %apply // No mapping was found. See if the name has been mapped with %apply
m = (TmMethod *) GetVoid(application_hash,temp); m = (TmMethod *) GetVoid(application_hash,temp);
@ -716,10 +716,10 @@ char *typemap_lookup(char *op, char *lang, DataType *type, char *pname, char *so
if ((m->type->arraystr) && (type->arraystr)) { if ((m->type->arraystr) && (type->arraystr)) {
// Build up the new array string // Build up the new array string
Clear(newarray); Clear(newarray);
for (int n = 0; n < m->type->array_dimensions(); n++) { for (int n = 0; n < DataType_array_dimensions(m->type); n++) {
char *d = m->type->get_dimension(n); char *d = DataType_get_dimension(m->type,n);
if (strcmp(d,"ANY") == 0) { if (strcmp(d,"ANY") == 0) {
Printf(newarray,"[%s]", type->get_dimension(n)); Printf(newarray,"[%s]", DataType_get_dimension(type,n));
} else { } else {
Printf(newarray,"[%s]", d); Printf(newarray,"[%s]", d);
} }
@ -748,7 +748,7 @@ char *typemap_lookup(char *op, char *lang, DataType *type, char *pname, char *so
if (!result) { if (!result) {
DataType *t = new DataType(type); DataType *t = new DataType(type);
t->primitive(); // Knock it down to its basic type DataType_primitive(t); // Knock it down to its basic type
result = typemap_lookup_internal(op,lang,t,(char*)"SWIG_DEFAULT_TYPE",source,target,f); result = typemap_lookup_internal(op,lang,t,(char*)"SWIG_DEFAULT_TYPE",source,target,f);
if (result) { if (result) {
delete t; delete t;
@ -762,7 +762,7 @@ char *typemap_lookup(char *op, char *lang, DataType *type, char *pname, char *so
t->is_pointer = 1; t->is_pointer = 1;
if (t->arraystr) delete [] t->arraystr; if (t->arraystr) delete [] t->arraystr;
t->arraystr = 0; t->arraystr = 0;
t->primitive(); DataType_primitive(t);
result = typemap_lookup_internal(op,lang,t,(char*)"SWIG_DEFAULT_TYPE",source,target,f); result = typemap_lookup_internal(op,lang,t,(char*)"SWIG_DEFAULT_TYPE",source,target,f);
} }
delete t; delete t;
@ -846,7 +846,7 @@ char *typemap_check(char *op, char *lang, DataType *type, char *pname) {
while (drop_pointer <= (type->is_pointer - type->implicit_ptr)) { while (drop_pointer <= (type->is_pointer - type->implicit_ptr)) {
type->is_pointer -= drop_pointer; type->is_pointer -= drop_pointer;
tstr = type->print_type(); tstr = DataType_print_type(type);
sprintf(temp,"%s$%s",tstr,ppname); sprintf(temp,"%s$%s",tstr,ppname);
// No mapping was found. See if the name has been mapped with %apply // No mapping was found. See if the name has been mapped with %apply
if (!application_hash) application_hash = NewHash(); if (!application_hash) application_hash = NewHash();
@ -872,10 +872,10 @@ char *typemap_check(char *op, char *lang, DataType *type, char *pname) {
if ((m->type->arraystr) && (type->arraystr)) { if ((m->type->arraystr) && (type->arraystr)) {
// Build up the new array string // Build up the new array string
Clear(newarray); Clear(newarray);
for (int n = 0; n < m->type->array_dimensions(); n++) { for (int n = 0; n < DataType_array_dimensions(m->type); n++) {
char *d = m->type->get_dimension(n); char *d = DataType_get_dimension(m->type,n);
if (strcmp(d,"ANY") == 0) { if (strcmp(d,"ANY") == 0) {
Printf(newarray,"[%s]", type->get_dimension(n)); Printf(newarray,"[%s]", DataType_get_dimension(type,n));
} else { } else {
Printf(newarray,"[%s]", d); Printf(newarray,"[%s]", d);
} }
@ -903,7 +903,7 @@ char *typemap_check(char *op, char *lang, DataType *type, char *pname) {
// If still no result, might have a default typemap // If still no result, might have a default typemap
if (!result) { if (!result) {
DataType *t = new DataType(type); DataType *t = new DataType(type);
t->primitive(); // Knock it down to its basic type DataType_primitive(t); // Knock it down to its basic type
result = typemap_check_internal(op,lang,t,(char*)"SWIG_DEFAULT_TYPE"); result = typemap_check_internal(op,lang,t,(char*)"SWIG_DEFAULT_TYPE");
if (result) { if (result) {
delete t; delete t;
@ -916,7 +916,7 @@ char *typemap_check(char *op, char *lang, DataType *type, char *pname) {
t->is_pointer = 1; t->is_pointer = 1;
if (t->arraystr) delete [] t->arraystr; if (t->arraystr) delete [] t->arraystr;
t->arraystr = 0; t->arraystr = 0;
t->primitive(); DataType_primitive(t);
result = typemap_check_internal(op,lang,t,(char*)"SWIG_DEFAULT_TYPE"); result = typemap_check_internal(op,lang,t,(char*)"SWIG_DEFAULT_TYPE");
} }
delete t; delete t;

View file

@ -111,67 +111,67 @@ DataType::~DataType() {
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// DataType::primitive() // DataType_primitive()
// //
// Turns a datatype into its bare-bones primitive type. Rarely used, // Turns a datatype into its bare-bones primitive type. Rarely used,
// but sometimes used for typemaps. Permanently alters the datatype! // but sometimes used for typemaps. Permanently alters the datatype!
// -------------------------------------------------------------------- // --------------------------------------------------------------------
void DataType::primitive() { void DataType_primitive(DataType *t) {
switch(type) { switch(t->type) {
case T_BOOL: case T_BOOL:
strcpy(name,"bool"); strcpy(t->name,"bool");
break; break;
case T_INT: case T_SINT: case T_INT: case T_SINT:
strcpy(name,"int"); strcpy(t->name,"int");
break; break;
case T_SHORT: case T_SSHORT: case T_SHORT: case T_SSHORT:
strcpy(name,"short"); strcpy(t->name,"short");
break; break;
case T_LONG: case T_SLONG: case T_LONG: case T_SLONG:
strcpy(name,"long"); strcpy(t->name,"long");
break; break;
case T_CHAR: case T_CHAR:
strcpy(name,"char"); strcpy(t->name,"char");
break; break;
case T_SCHAR: case T_SCHAR:
strcpy(name,"signed char"); strcpy(t->name,"signed char");
break; break;
case T_UINT: case T_UINT:
strcpy(name,"unsigned int"); strcpy(t->name,"unsigned int");
break; break;
case T_USHORT: case T_USHORT:
strcpy(name,"unsigned short"); strcpy(t->name,"unsigned short");
break; break;
case T_ULONG: case T_ULONG:
strcpy(name,"unsigned long"); strcpy(t->name,"unsigned long");
break; break;
case T_UCHAR: case T_UCHAR:
strcpy(name,"unsigned char"); strcpy(t->name,"unsigned char");
break; break;
case T_FLOAT: case T_FLOAT:
strcpy(name,"float"); strcpy(t->name,"float");
break; break;
case T_DOUBLE: case T_DOUBLE:
strcpy(name,"double"); strcpy(t->name,"double");
break; break;
case T_VOID: case T_VOID:
strcpy(name,"void"); strcpy(t->name,"void");
break; break;
case T_USER: case T_USER:
strcpy(name,"USER"); strcpy(t->name,"USER");
break; break;
default: default:
strcpy(name,"UNKNOWN"); strcpy(t->name,"UNKNOWN");
break; break;
} }
implicit_ptr = 0; // Gets rid of typedef'd pointers t->implicit_ptr = 0; // Gets rid of typedef'd pointers
if (qualifier) { if (t->qualifier) {
delete qualifier; delete t->qualifier;
qualifier = 0; t->qualifier = 0;
} }
qualifier = 0; t->qualifier = 0;
status = 0; t->status = 0;
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
@ -187,22 +187,22 @@ void DataType::primitive() {
// use this type as a valid type. We'll substitute it's old name in. // use this type as a valid type. We'll substitute it's old name in.
// -------------------------------------------------------------------- // --------------------------------------------------------------------
char *DataType::print_type() { char *DataType_print_type(DataType *ty) {
static char result[8][256]; static char result[8][256];
static int ri = 0; static int ri = 0;
DataType *t = this; DataType *t = ty;
if (status & STAT_REPLACETYPE) { if (ty->status & STAT_REPLACETYPE) {
t = new DataType(this); t = new DataType(ty);
t->typedef_replace(); // Upgrade type DataType_typedef_replace(t); // Upgrade type
} }
ri = ri % 8; ri = ri % 8;
sprintf(result[ri],"%s ", t->name); sprintf(result[ri],"%s ", t->name);
for (int i = 0; i < (t->is_pointer-t->implicit_ptr); i++) for (int i = 0; i < (t->is_pointer-t->implicit_ptr); i++)
strcat(result[ri],"*"); strcat(result[ri],"*");
if (status & STAT_REPLACETYPE) { if (ty->status & STAT_REPLACETYPE) {
delete t; delete t;
}; };
return result[ri++]; return result[ri++];
@ -213,16 +213,16 @@ char *DataType::print_type() {
// //
// Prints full type, with qualifiers. // Prints full type, with qualifiers.
// -------------------------------------------------------------------- // --------------------------------------------------------------------
char *DataType::print_full() { char *DataType_print_full(DataType *t) {
static char result[8][256]; static char result[8][256];
static int ri = 0; static int ri = 0;
ri = ri % 8; ri = ri % 8;
if (qualifier) { if (t->qualifier) {
sprintf(result[ri],"%s %s", qualifier, print_type()); sprintf(result[ri],"%s %s", t->qualifier, DataType_print_type(t));
return result[ri++]; return result[ri++];
} else { } else {
return print_type(); return DataType_print_type(t);
} }
} }
@ -231,22 +231,22 @@ char *DataType::print_full() {
// //
// Prints real type, with qualifiers and arrays if necessary. // Prints real type, with qualifiers and arrays if necessary.
// -------------------------------------------------------------------- // --------------------------------------------------------------------
char *DataType::print_real(char *local) { char *DataType_print_real(DataType *t, char *local) {
static char result[8][256]; static char result[8][256];
static int ri = 0; static int ri = 0;
int oldstatus; int oldstatus;
oldstatus = status; oldstatus = t->status;
status = status & (~STAT_REPLACETYPE); t->status = t->status & (~STAT_REPLACETYPE);
ri = ri % 8; ri = ri % 8;
if (arraystr) is_pointer--; if (t->arraystr) t->is_pointer--;
strcpy(result[ri], print_full()); strcpy(result[ri], DataType_print_full(t));
if (local) strcat(result[ri],local); if (local) strcat(result[ri],local);
if (arraystr) { if (t->arraystr) {
strcat(result[ri],arraystr); strcat(result[ri],t->arraystr);
is_pointer++; t->is_pointer++;
} }
status = oldstatus; t->status = oldstatus;
return result[ri++]; return result[ri++];
} }
@ -256,12 +256,12 @@ char *DataType::print_real(char *local) {
// Prints a cast. (Basically just a type but with parens added). // Prints a cast. (Basically just a type but with parens added).
// -------------------------------------------------------------------- // --------------------------------------------------------------------
char *DataType::print_cast() { char *DataType_print_cast(DataType *t) {
static char result[8][256]; static char result[8][256];
static int ri = 0; static int ri = 0;
ri = ri % 8; ri = ri % 8;
sprintf(result[ri],"(%s)", print_type()); sprintf(result[ri],"(%s)", DataType_print_type(t));
return result[ri++]; return result[ri++];
} }
@ -272,17 +272,17 @@ char *DataType::print_cast() {
// for multidimensional arrays. // for multidimensional arrays.
// -------------------------------------------------------------------- // --------------------------------------------------------------------
char *DataType::print_arraycast() { char *DataType_print_arraycast(DataType *ty) {
static char result[8][256]; static char result[8][256];
static int ri = 0; static int ri = 0;
int ndim; int ndim;
char *c; char *c;
DataType *t; DataType *t;
t = this; t = ty;
if (status & STAT_REPLACETYPE) { if (ty->status & STAT_REPLACETYPE) {
t = new DataType(this); t = new DataType(ty);
t->typedef_replace(); // Upgrade type DataType_typedef_replace(t); // Upgrade type
} }
ri = ri % 8; ri = ri % 8;
@ -295,10 +295,10 @@ char *DataType::print_arraycast() {
} }
if (ndim > 1) { if (ndim > 1) {
// a Multidimensional array. Provide a special cast for it // a Multidimensional array. Provide a special cast for it
int oldstatus = status; int oldstatus = ty->status;
t->status = t->status & (~STAT_REPLACETYPE); t->status = t->status & (~STAT_REPLACETYPE);
t->is_pointer--; t->is_pointer--;
sprintf(result[ri],"(%s", t->print_type()); sprintf(result[ri],"(%s", DataType_print_type(t));
t->is_pointer++; t->is_pointer++;
t->status = oldstatus; t->status = oldstatus;
strcat(result[ri]," (*)"); strcat(result[ri]," (*)");
@ -312,7 +312,7 @@ char *DataType::print_arraycast() {
strcat(result[ri],")"); strcat(result[ri],")");
} }
} }
if (status & STAT_REPLACETYPE) { if (ty->status & STAT_REPLACETYPE) {
delete t; delete t;
} }
return result[ri++]; return result[ri++];
@ -326,7 +326,7 @@ char *DataType::print_arraycast() {
// spaces and no weird characters). // spaces and no weird characters).
// -------------------------------------------------------------------- // --------------------------------------------------------------------
char *DataType::print_mangle_default() { char *DataType_print_mangle_default(DataType *t) {
static char result[8][256]; static char result[8][256];
static int ri = 0; static int ri = 0;
int i; int i;
@ -334,7 +334,7 @@ char *DataType::print_mangle_default() {
char *d; char *d;
ri = ri % 8; ri = ri % 8;
c = name; c = t->name;
result[ri][0] = '_'; result[ri][0] = '_';
@ -347,8 +347,8 @@ char *DataType::print_mangle_default() {
if ((*c == ' ') || (*c == ':') || (*c == '<') || (*c == '>')) *(d++) = '_'; if ((*c == ' ') || (*c == ':') || (*c == '<') || (*c == '>')) *(d++) = '_';
else *(d++) = *c; else *(d++) = *c;
} }
if ((is_pointer-implicit_ptr)) *(d++) = '_'; if ((t->is_pointer-t->implicit_ptr)) *(d++) = '_';
for (i = 0; i < (is_pointer-implicit_ptr); i++) for (i = 0; i < (t->is_pointer-t->implicit_ptr); i++)
*(d++) = 'p'; *(d++) = 'p';
*d = 0; *d = 0;
@ -358,22 +358,22 @@ char *DataType::print_mangle_default() {
// This is kind of ugly but needed for each language to support a // This is kind of ugly but needed for each language to support a
// custom name mangling mechanism. (ie. Perl5). // custom name mangling mechanism. (ie. Perl5).
char *DataType::print_mangle() { char *DataType_print_mangle(DataType *t) {
// Call into target language for name mangling. // Call into target language for name mangling.
return lang->type_mangle(this); return lang->type_mangle(t);
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// int DataType::array_dimensions() // int DataType_array_dimensions()
// //
// Returns the number of dimensions in an array or 0 if not an array. // Returns the number of dimensions in an array or 0 if not an array.
// -------------------------------------------------------------------- // --------------------------------------------------------------------
int DataType::array_dimensions() { int DataType_array_dimensions(DataType *t) {
char *c; char *c;
int ndim = 0; int ndim = 0;
if (!arraystr) return 0; if (!t->arraystr) return 0;
c = arraystr; c = t->arraystr;
while (*c) { while (*c) {
if (*c == '[') { if (*c == '[') {
ndim++; ndim++;
@ -384,24 +384,24 @@ int DataType::array_dimensions() {
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// char *DataType::get_dimension(int n) // char *DataType_get_dimension(int n)
// //
// Returns a string containing the value specified for dimension n. // Returns a string containing the value specified for dimension n.
// -------------------------------------------------------------------- // --------------------------------------------------------------------
char *DataType::get_dimension(int n) { char *DataType_get_dimension(DataType *t, int n) {
static char dim[256]; static char dim[256];
char *c; char *c;
char *d = dim; char *d = dim;
if (n >= array_dimensions()) { if (n >= DataType_array_dimensions(t)) {
*d = 0; *d = 0;
return dim; return dim;
} }
// Attemp to locate the right dimension // Attemp to locate the right dimension
c = arraystr; c = t->arraystr;
while ((*c) && (n >= 0)) { while ((*c) && (n >= 0)) {
if (*c == '[') n--; if (*c == '[') n--;
c++; c++;
@ -417,16 +417,6 @@ char *DataType::get_dimension(int n) {
return dim; return dim;
} }
// --------------------------------------------------------------------
// char *DataType::get_array()
//
// Returns the array string for a datatype.
// --------------------------------------------------------------------
char *DataType::get_array() {
return arraystr;
}
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// typedef support. This needs to be scoped. // typedef support. This needs to be scoped.
// -------------------------------------------------------------------- // --------------------------------------------------------------------
@ -435,7 +425,7 @@ static DOHHash *typedef_hash[MAXSCOPE];
static int scope = 0; // Current scope static int scope = 0; // Current scope
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// void DataType::init_typedef() // void DataType_init_typedef()
// //
// Inputs : None // Inputs : None
// //
@ -444,7 +434,7 @@ static int scope = 0; // Current scope
// Side Effects : Initializes the typedef hash tables // Side Effects : Initializes the typedef hash tables
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void DataType::init_typedef() { void DataType_init_typedef() {
int i; int i;
for (i = 0; i < MAXSCOPE; i++) for (i = 0; i < MAXSCOPE; i++)
typedef_hash[i] = 0; typedef_hash[i] = 0;
@ -454,7 +444,7 @@ void DataType::init_typedef() {
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// void DataType::typedef_add(char *typename, int mode = 0) // void DataType_typedef_add()
// //
// Adds this datatype to the typedef hash table. mode is an optional // Adds this datatype to the typedef hash table. mode is an optional
// flag that can be used to only add the symbol as a typedef, but not // flag that can be used to only add the symbol as a typedef, but not
@ -463,9 +453,9 @@ void DataType::init_typedef() {
// arrays, and enums. // arrays, and enums.
// -------------------------------------------------------------------- // --------------------------------------------------------------------
void DataType::typedef_add(char *tname, int mode) { void DataType_typedef_add(DataType *t,char *tname, int mode) {
char *name1, *name2; char *name1, *name2;
DataType *nt, t1; DataType *nt, *t1;
void typeeq_addtypedef(char *name, char *eqname, DataType *); void typeeq_addtypedef(char *name, char *eqname, DataType *);
// Check to see if this typedef already defined // Check to see if this typedef already defined
@ -480,11 +470,10 @@ void DataType::typedef_add(char *tname, int mode) {
// Make a new datatype that we will place in our hash table // Make a new datatype that we will place in our hash table
nt = new DataType(this); nt = new DataType(t);
nt->implicit_ptr = (is_pointer-implicit_ptr); // Record if mapped type is a pointer nt->implicit_ptr = (t->is_pointer-t->implicit_ptr); // Record if mapped type is a pointer
nt->is_pointer = (is_pointer-implicit_ptr); // Adjust pointer value to be correct nt->is_pointer = (t->is_pointer-t->implicit_ptr); // Adjust pointer value to be correct
nt->typedef_resolve(); // Resolve any other mappings of this type DataType_typedef_resolve(nt,0); // Resolve any other mappings of this type
// strcpy(nt->name,tname); // Copy over the new name
// Add this type to our hash table // Add this type to our hash table
SetVoid(typedef_hash[scope],tname, (void *) nt); SetVoid(typedef_hash[scope],tname, (void *) nt);
@ -492,20 +481,22 @@ void DataType::typedef_add(char *tname, int mode) {
// Now add this type mapping to our type-equivalence table // Now add this type mapping to our type-equivalence table
if (mode == 0) { if (mode == 0) {
if ((type != T_VOID) && (strcmp(name,tname) != 0)) { if ((t->type != T_VOID) && (strcmp(t->name,tname) != 0)) {
strcpy(t1.name,tname); t1 = new DataType();
name2 = t1.print_mangle(); strcpy(t1->name,tname);
name1 = print_mangle(); name2 = DataType_print_mangle(t1);
typeeq_addtypedef(name1,name2,&t1); name1 = DataType_print_mangle(t);
typeeq_addtypedef(name2,name1,this); typeeq_addtypedef(name1,name2,t1);
typeeq_addtypedef(name2,name1,t);
delete t1;
} }
} }
// Call into the target language with this typedef // Call into the target language with this typedef
lang->add_typedef(this,tname); lang->add_typedef(t,tname);
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// void DataType::typedef_resolve(int level = 0) // void DataType_typedef_resolve(int level = 0)
// //
// Checks to see if this datatype is in the typedef hash and // Checks to see if this datatype is in the typedef hash and
// resolves it if necessary. This will check all of the typedef // resolves it if necessary. This will check all of the typedef
@ -529,25 +520,25 @@ void DataType::typedef_add(char *tname, int mode) {
// all future occurrences of "String" will really be "const char *". // all future occurrences of "String" will really be "const char *".
// -------------------------------------------------------------------- // --------------------------------------------------------------------
void DataType::typedef_resolve(int level) { void DataType_typedef_resolve(DataType *t, int level) {
DataType *td; DataType *td;
int s = scope - level; int s = scope - level;
while (s >= 0) { while (s >= 0) {
if ((td = (DataType *) GetVoid(typedef_hash[s],name))) { if ((td = (DataType *) GetVoid(typedef_hash[s],t->name))) {
type = td->type; t->type = td->type;
is_pointer += td->is_pointer; t->is_pointer += td->is_pointer;
implicit_ptr += td->implicit_ptr; t->implicit_ptr += td->implicit_ptr;
status = status | td->status; t->status = t->status | td->status;
// Check for constness, and replace type name if necessary // Check for constness, and replace type name if necessary
if (td->qualifier) { if (td->qualifier) {
if (strcmp(td->qualifier,"const") == 0) { if (strcmp(td->qualifier,"const") == 0) {
strcpy(name,td->name); strcpy(t->name,td->name);
qualifier = copy_string(td->qualifier); t->qualifier = copy_string(td->qualifier);
implicit_ptr -= td->implicit_ptr; t->implicit_ptr -= td->implicit_ptr;
} }
} }
return; return;
@ -559,30 +550,30 @@ void DataType::typedef_resolve(int level) {
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// void DataType::typedef_replace() // void DataType_typedef_replace()
// //
// Checks to see if this datatype is in the typedef hash and // Checks to see if this datatype is in the typedef hash and
// replaces it with the hash entry. Only applies to current scope. // replaces it with the hash entry. Only applies to current scope.
// -------------------------------------------------------------------- // --------------------------------------------------------------------
void DataType::typedef_replace () { void DataType_typedef_replace (DataType *t) {
DataType *td; DataType *td;
char temp[512]; char temp[512];
temp[0] = 0; temp[0] = 0;
if ((td = (DataType *) GetVoid(typedef_hash[scope],name))) { if ((td = (DataType *) GetVoid(typedef_hash[scope],t->name))) {
type = td->type; t->type = td->type;
is_pointer = td->is_pointer; t->is_pointer = td->is_pointer;
implicit_ptr -= td->implicit_ptr; t->implicit_ptr -= td->implicit_ptr;
strcpy(name, td->name); strcpy(t->name, td->name);
if (td->arraystr) { if (td->arraystr) {
if (arraystr) { if (t->arraystr) {
strcat(temp,arraystr); strcat(temp,t->arraystr);
delete arraystr; delete t->arraystr;
} }
strcat(temp,td->arraystr); strcat(temp,td->arraystr);
arraystr = copy_string(temp); t->arraystr = copy_string(temp);
} }
} }
// Not found, do nothing // Not found, do nothing
@ -590,13 +581,13 @@ void DataType::typedef_replace () {
} }
// --------------------------------------------------------------- // ---------------------------------------------------------------
// int DataType::is_typedef(char *t) // int DataType_is_typedef(char *t)
// //
// Checks to see whether t is the name of a datatype we know // Checks to see whether t is the name of a datatype we know
// about. Returns 1 if there's a match, 0 otherwise // about. Returns 1 if there's a match, 0 otherwise
// --------------------------------------------------------------- // ---------------------------------------------------------------
int DataType::is_typedef(char *t) { int DataType_is_typedef(char *t) {
int s = scope; int s = scope;
while (s >= 0) { while (s >= 0) {
if (Getattr(typedef_hash[s],t)) return 1; if (Getattr(typedef_hash[s],t)) return 1;
@ -606,24 +597,23 @@ int DataType::is_typedef(char *t) {
} }
// --------------------------------------------------------------- // ---------------------------------------------------------------
// void DataType::typedef_updatestatus(int newstatus) // void DataType_typedef_updatestatus(int newstatus)
// //
// Checks to see if this datatype is in the hash table. If // Checks to see if this datatype is in the hash table. If
// so, we'll update its status. This is sometimes used with // so, we'll update its status. This is sometimes used with
// typemap handling. Only applies to current scope. // typemap handling. Only applies to current scope.
// --------------------------------------------------------------- // ---------------------------------------------------------------
void DataType::typedef_updatestatus(int newstatus) { void DataType_typedef_updatestatus(DataType *t, int newstatus) {
DataType *t; DataType *nt;
if ((t = (DataType *) GetVoid(typedef_hash[scope],name))) { if ((nt = (DataType *) GetVoid(typedef_hash[scope],t->name))) {
t->status = newstatus; nt->status = newstatus;
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// void DataType::merge_scope(Hash *h) // void DataType_merge_scope(Hash *h)
// //
// Copies all of the entries in scope h into the current scope. This is // Copies all of the entries in scope h into the current scope. This is
// primarily done with C++ inheritance. // primarily done with C++ inheritance.
@ -635,7 +625,7 @@ void DataType::typedef_updatestatus(int newstatus) {
// Side Effects : Copies all of the entries in h to current scope. // Side Effects : Copies all of the entries in h to current scope.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void DataType::merge_scope(void *ho) { void DataType_merge_scope(void *ho) {
DOHString *key; DOHString *key;
DataType *t, *nt; DataType *t, *nt;
DOHHash *h = (DOHHash *) ho; DOHHash *h = (DOHHash *) ho;
@ -654,7 +644,7 @@ void DataType::merge_scope(void *ho) {
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// void DataType::new_scope(Hash *h = 0) // void DataType_new_scope(Hash *h = 0)
// //
// Creates a new scope for handling typedefs. This is used in C++ handling // Creates a new scope for handling typedefs. This is used in C++ handling
// to create typedef local to a class definition. // to create typedef local to a class definition.
@ -666,16 +656,16 @@ void DataType::merge_scope(void *ho) {
// Side Effects : Creates a new hash table and increments the scope counter // Side Effects : Creates a new hash table and increments the scope counter
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void DataType::new_scope(void *ho) { void DataType_new_scope(void *ho) {
scope++; scope++;
typedef_hash[scope] = NewHash(); typedef_hash[scope] = NewHash();
if (ho) { if (ho) {
merge_scope(ho); DataType_merge_scope(ho);
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Hash *DataType::collapse_scope(char *prefix) // Hash *DataType_collapse_scope(char *prefix)
// //
// Collapses the current scope into the previous one, but applies a prefix to // Collapses the current scope into the previous one, but applies a prefix to
// all of the datatypes. This is done in order to properly handle C++ stuff. // all of the datatypes. This is done in order to properly handle C++ stuff.
@ -696,7 +686,7 @@ void DataType::new_scope(void *ho) {
// Side Effects : Returns the hash table corresponding to the current scope // Side Effects : Returns the hash table corresponding to the current scope
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void *DataType::collapse_scope(char *prefix) { void *DataType_collapse_scope(char *prefix) {
DataType *t,*nt; DataType *t,*nt;
DOHString *key; DOHString *key;
char *temp; char *temp;
@ -917,8 +907,8 @@ void typeeq_derived(char *n1, char *n2, char *cast=0) {
t1.type = T_USER; t1.type = T_USER;
strcpy(t.name,n1); strcpy(t.name,n1);
strcpy(t1.name,n2); strcpy(t1.name,n2);
name = t.print_mangle(); name = DataType_print_mangle(&t);
name2 = t1.print_mangle(); name2 = DataType_print_mangle(&t1);
typeeq_add(name,name2, cast, &t1); typeeq_add(name,name2, cast, &t1);
} }
@ -936,8 +926,8 @@ void typeeq_mangle(char *n1, char *n2, char *cast=0) {
strcpy(t.name,n1); strcpy(t.name,n1);
strcpy(t1.name,n2); strcpy(t1.name,n2);
name = t.print_mangle(); name = DataType_print_mangle(&t);
name2 = t1.print_mangle(); name2 = DataType_print_mangle(&t1);
typeeq_add(name,name2,cast); typeeq_add(name,name2,cast);
} }
@ -985,7 +975,7 @@ check_equivalent(DataType *t) {
Clear(out); Clear(out);
while (t->is_pointer >= t->implicit_ptr) { while (t->is_pointer >= t->implicit_ptr) {
m = copy_string(t->print_mangle()); m = copy_string(DataType_print_mangle(t));
if (!te_init) typeeq_init(); if (!te_init) typeeq_init();
@ -997,7 +987,7 @@ check_equivalent(DataType *t) {
while (e2) { while (e2) {
if (e2->type) { if (e2->type) {
e2->type->is_pointer += (npointer - t->is_pointer); e2->type->is_pointer += (npointer - t->is_pointer);
Printf(out,"{ \"%s\",", e2->type->print_mangle()); Printf(out,"{ \"%s\",", DataType_print_mangle(e2->type));
e2->type->is_pointer -= (npointer - t->is_pointer); e2->type->is_pointer -= (npointer - t->is_pointer);
if (e2->cast) if (e2->cast)
Printf(out,"%s}, ", e2->cast); Printf(out,"%s}, ", e2->cast);
@ -1018,7 +1008,7 @@ check_equivalent(DataType *t) {
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// void DataType::record_base(char *derived, char *base) // void DataType_record_base(char *derived, char *base)
// //
// Record base class information. This is a hack to make runtime libraries // Record base class information. This is a hack to make runtime libraries
// work across multiple files. // work across multiple files.
@ -1026,7 +1016,7 @@ check_equivalent(DataType *t) {
static DOHHash *bases = 0; static DOHHash *bases = 0;
void DataType::record_base(char *derived, char *base) void DataType_record_base(char *derived, char *base)
{ {
DOHHash *nh; DOHHash *nh;
if (!bases) bases = NewHash(); if (!bases) bases = NewHash();
@ -1041,7 +1031,7 @@ void DataType::record_base(char *derived, char *base)
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// void DataType::remember() // void DataType_remember()
// //
// Marks a datatype as being used in the interface file. We use this to // Marks a datatype as being used in the interface file. We use this to
// construct a big table of pointer values at the end. // construct a big table of pointer values at the end.
@ -1049,12 +1039,12 @@ void DataType::record_base(char *derived, char *base)
static DOHHash *remembered = 0; static DOHHash *remembered = 0;
void DataType::remember() { void DataType_remember(DataType *ty) {
DOHHash *h; DOHHash *h;
DataType *t = new DataType(this); DataType *t = new DataType(ty);
if (!remembered) remembered = NewHash(); if (!remembered) remembered = NewHash();
SetVoid(remembered, t->print_mangle(), t); SetVoid(remembered, DataType_print_mangle(t), t);
if (!bases) bases = NewHash(); if (!bases) bases = NewHash();
/* Now, do the base-class hack */ /* Now, do the base-class hack */
@ -1065,8 +1055,8 @@ void DataType::remember() {
while (key) { while (key) {
DataType *nt = new DataType(t); DataType *nt = new DataType(t);
strcpy(nt->name,Char(key)); strcpy(nt->name,Char(key));
if (!Getattr(remembered,nt->print_mangle())) if (!Getattr(remembered,DataType_print_mangle(nt)))
nt->remember(); DataType_remember(nt);
delete nt; delete nt;
key = Nextkey(h); key = Nextkey(h);
} }