Cleanup of DataType class
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@572 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
c047f50eb7
commit
133ee98f62
10 changed files with 261 additions and 256 deletions
|
|
@ -176,14 +176,15 @@ void RUBY::parse() {
|
|||
headers();
|
||||
|
||||
// typedef void *VALUE
|
||||
DataType value;
|
||||
strcpy(value.name, "void");
|
||||
value.type = T_VOID;
|
||||
value.is_pointer = 1;
|
||||
value.implicit_ptr = 0;
|
||||
DataType_typedef_add(&value,(char*)"VALUE",0);
|
||||
DataType *value = NewDataType(0);
|
||||
strcpy(value->name, "void");
|
||||
value->type = T_VOID;
|
||||
value->is_pointer = 1;
|
||||
value->implicit_ptr = 0;
|
||||
DataType_typedef_add(value,(char*)"VALUE",0);
|
||||
|
||||
yyparse(); // Run the SWIG parser
|
||||
DelDataType(value);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -1022,10 +1022,10 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
|
|||
|
||||
Printf(f_init,"\t sprintf(%s_char,\"%%ld\", (long) %s);\n", var_name, var_name);
|
||||
sprintf(var_name,"%s_char",var_name);
|
||||
t = new DataType(T_CHAR);
|
||||
t = NewDataType(T_CHAR);
|
||||
t->is_pointer = 1;
|
||||
link_variable(var_name,name,t);
|
||||
delete t;
|
||||
DelDataType(t);
|
||||
break;
|
||||
case T_UINT:
|
||||
case T_USHORT:
|
||||
|
|
@ -1040,10 +1040,10 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
|
|||
|
||||
Printf(f_init,"\t sprintf(%s_char,\"%%lu\", (unsigned long) %s);\n", var_name, var_name);
|
||||
sprintf(var_name,"%s_char",var_name);
|
||||
t = new DataType(T_CHAR);
|
||||
t = NewDataType(T_CHAR);
|
||||
t->is_pointer = 1;
|
||||
link_variable(var_name,name,t);
|
||||
delete t;
|
||||
DelDataType(t);
|
||||
break;
|
||||
case T_FLOAT:
|
||||
type->type = T_DOUBLE;
|
||||
|
|
@ -1077,14 +1077,14 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
|
|||
else
|
||||
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 = NewDataType(T_CHAR);
|
||||
t->is_pointer = 1;
|
||||
DataType_remember(type);
|
||||
Printf(f_init,"\t SWIG_MakePtr(%s_char, (void *) %s, SWIGTYPE%s);\n",
|
||||
var_name, var_name, DataType_print_mangle(type));
|
||||
sprintf(var_name,"%s_char",var_name);
|
||||
link_variable(var_name,name,t);
|
||||
delete t;
|
||||
DelDataType(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1284,7 +1284,7 @@ void TCL8::cpp_close_class() {
|
|||
this->Language::cpp_close_class();
|
||||
if (shadow) {
|
||||
|
||||
t = new DataType;
|
||||
t = NewDataType(0);
|
||||
sprintf(t->name,"%s%s", class_type, real_classname);
|
||||
t->type = T_USER;
|
||||
t->is_pointer = 1;
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ public:
|
|||
CPP_function(char *n, char *i, DataType *t, ParmList *l, int s, int v = 0) {
|
||||
name = copy_string(n);
|
||||
iname = copy_string(i);
|
||||
ret_type = new DataType(t);
|
||||
ret_type = CopyDataType(t);
|
||||
parms = CopyParmList(l);
|
||||
is_static = s;
|
||||
is_virtual = v;
|
||||
|
|
@ -266,7 +266,7 @@ public:
|
|||
// Make a copy of the parameter list and upgrade its types
|
||||
|
||||
l = CopyParmList(parms);
|
||||
t = new DataType(ret_type);
|
||||
t = CopyDataType(ret_type);
|
||||
update_parms(l);
|
||||
update_local_type(t);
|
||||
if (is_static) {
|
||||
|
|
@ -275,7 +275,7 @@ public:
|
|||
lang->cpp_member_func(name, iname, t, l);
|
||||
}
|
||||
DelParmList(l);
|
||||
delete t;
|
||||
DelDataType(t);
|
||||
IsVirtual = 0;
|
||||
}
|
||||
};
|
||||
|
|
@ -377,7 +377,7 @@ public:
|
|||
CPP_variable(char *n, char *i, DataType *t, int s) {
|
||||
name = copy_string(n);
|
||||
iname = copy_string(i);
|
||||
type = new DataType(t);
|
||||
type = CopyDataType(t);
|
||||
is_static = s;
|
||||
status = Status;
|
||||
next = 0;
|
||||
|
|
@ -404,7 +404,7 @@ public:
|
|||
input_file = file;
|
||||
ccode = code;
|
||||
|
||||
t = new DataType(type);
|
||||
t = CopyDataType(type);
|
||||
if (t->qualifier) {
|
||||
// if (strcmp(t->qualifier,"const") == 0) Status = Status | STAT_READONLY;
|
||||
}
|
||||
|
|
@ -415,7 +415,7 @@ public:
|
|||
lang->cpp_static_var(name,iname,t);
|
||||
}
|
||||
Status = old_status;
|
||||
delete t;
|
||||
DelDataType(t);
|
||||
}
|
||||
|
||||
// Inherit into another class
|
||||
|
|
@ -453,7 +453,7 @@ public:
|
|||
CPP_constant(char *n, char *i, DataType *t, char *v) {
|
||||
name = copy_string(n);
|
||||
iname = copy_string(i);
|
||||
type = new DataType(t);
|
||||
type = CopyDataType(t);
|
||||
value = copy_string(v);
|
||||
new_method = AddMethods;
|
||||
next = 0;
|
||||
|
|
@ -1621,7 +1621,7 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
|
|||
|
||||
newparms = CopyParmList(l);
|
||||
p = NewParm(0,0);
|
||||
p->t = new DataType;
|
||||
p->t = NewDataType(0);
|
||||
p->t->type = T_USER;
|
||||
p->t->is_pointer = 1;
|
||||
p->t->id = cpp_id;
|
||||
|
|
@ -1917,7 +1917,7 @@ void cplus_emit_destructor(char *classname, char *classtype, char *classrename,
|
|||
|
||||
l = NewParmList();
|
||||
p = NewParm(0,0);
|
||||
p->t = new DataType;
|
||||
p->t = NewDataType(0);
|
||||
p->t->type = T_USER;
|
||||
p->t->is_pointer = 1;
|
||||
p->t->id = cpp_id;
|
||||
|
|
@ -1926,7 +1926,7 @@ void cplus_emit_destructor(char *classname, char *classtype, char *classrename,
|
|||
p->name = (char*)"self";
|
||||
ParmList_insert(l,p,0);
|
||||
|
||||
type = new DataType;
|
||||
type = NewDataType(0);
|
||||
type->type = T_VOID;
|
||||
sprintf(type->name,"void");
|
||||
type->is_pointer = 0;
|
||||
|
|
@ -1936,7 +1936,7 @@ void cplus_emit_destructor(char *classname, char *classtype, char *classrename,
|
|||
|
||||
lang->create_function(cname,iname,type,l);
|
||||
|
||||
delete type;
|
||||
DelDataType(type);
|
||||
DelParmList(l);
|
||||
Delete(wrap);
|
||||
}
|
||||
|
|
@ -1990,7 +1990,7 @@ void cplus_emit_constructor(char *classname, char *classtype, char *classrename,
|
|||
|
||||
// Create a return type
|
||||
|
||||
type = new DataType;
|
||||
type = NewDataType(0);
|
||||
type->type = T_USER;
|
||||
sprintf(type->name,"%s%s", classtype,classname);
|
||||
type->is_pointer = 1;
|
||||
|
|
@ -2078,7 +2078,7 @@ void cplus_emit_constructor(char *classname, char *classtype, char *classrename,
|
|||
// We've now created a C wrapper. We're going to add it to the interpreter
|
||||
|
||||
lang->create_function(cname, iname, type, l);
|
||||
delete type;
|
||||
DelDataType(type);
|
||||
Delete(wrap);
|
||||
Delete(fcall);
|
||||
}
|
||||
|
|
@ -2229,7 +2229,7 @@ void cplus_emit_variable_get(char *classname, char *classtype, char *classrename
|
|||
|
||||
l = NewParmList();
|
||||
p = NewParm(0,0);
|
||||
p->t = new DataType;
|
||||
p->t = NewDataType(0);
|
||||
p->t->type = T_USER;
|
||||
p->t->is_pointer = 1;
|
||||
p->t->id = cpp_id;
|
||||
|
|
@ -2449,7 +2449,7 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
|
|||
|
||||
l = NewParmList();
|
||||
p = NewParm(0,0);
|
||||
p->t = new DataType(type);
|
||||
p->t = CopyDataType(type);
|
||||
p->t->is_reference = 0;
|
||||
p->call_type = 0;
|
||||
p->t->id = cpp_id;
|
||||
|
|
@ -2460,7 +2460,7 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
|
|||
p->name = mname;
|
||||
ParmList_insert(l,p,0);
|
||||
p = NewParm(0,0);
|
||||
p->t = new DataType;
|
||||
p->t = NewDataType(0);
|
||||
p->t->type = T_USER;
|
||||
p->call_type = 0;
|
||||
p->t->is_pointer = 1;
|
||||
|
|
|
|||
|
|
@ -457,14 +457,14 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
|
||||
// Set up the typemap for handling new return strings
|
||||
{
|
||||
DataType *temp_t = new DataType(T_CHAR);
|
||||
DataType *temp_t = NewDataType(T_CHAR);
|
||||
temp_t->is_pointer++;
|
||||
if (CPlusPlus)
|
||||
typemap_register((char*)"newfree",typemap_lang,temp_t,(char*)"",(char*)"delete [] $source;\n",0);
|
||||
else
|
||||
typemap_register((char*)"newfree",typemap_lang,temp_t,(char*)"",(char*)"free($source);\n",0);
|
||||
|
||||
delete temp_t;
|
||||
DelDataType(temp_t);
|
||||
}
|
||||
|
||||
// If in Objective-C mode. Load in a configuration file
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ extern "C" {
|
|||
Parm *NewParm(DataType *type, char *n) {
|
||||
Parm *p = (Parm *) malloc(sizeof(Parm));
|
||||
if (type) {
|
||||
p->t = new DataType(type);
|
||||
p->t = CopyDataType(type);
|
||||
} else {
|
||||
p->t = 0;
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ Parm *NewParm(DataType *type, char *n) {
|
|||
|
||||
Parm *CopyParm(Parm *p) {
|
||||
Parm *np = (Parm *) malloc(sizeof(Parm));
|
||||
if (p->t) np->t = new DataType(p->t);
|
||||
if (p->t) np->t = CopyDataType(p->t);
|
||||
np->name = copy_string(p->name);
|
||||
np->call_type = p->call_type;
|
||||
np->defvalue = copy_string(p->defvalue);
|
||||
|
|
@ -66,7 +66,7 @@ Parm *CopyParm(Parm *p) {
|
|||
// ------------------------------------------------------------------------
|
||||
|
||||
void DelParm(Parm *p) {
|
||||
if (p->t) delete p->t;
|
||||
if (p->t) DelDataType(p->t);
|
||||
if (p->name) delete p->name;
|
||||
if (p->defvalue) delete p->defvalue;
|
||||
if (p->objc_separator) delete p->objc_separator;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ static int lang_init = 0; /* Indicates if the language has been initial
|
|||
static int i;
|
||||
int Error = 0;
|
||||
static char temp_name[128];
|
||||
static DataType *temp_typeptr, temp_type;
|
||||
static DataType *temp_typeptr, *temp_type = 0;
|
||||
static char yy_rename[256];
|
||||
static int Rename_true = 0;
|
||||
static DataType *Active_type = 0; // Used to support variable lists
|
||||
|
|
@ -119,6 +119,7 @@ extern void cplus_abort();
|
|||
|
||||
void parser_init() {
|
||||
ArrayString = NewString("");
|
||||
temp_type = NewDataType(0);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
@ -547,8 +548,8 @@ statement : INCLUDE STRING LBRACE {
|
|||
|
||||
| extern type declaration array2 def_args {
|
||||
init_language();
|
||||
if (Active_type) delete Active_type;
|
||||
Active_type = new DataType($2);
|
||||
if (Active_type) DelDataType(Active_type);
|
||||
Active_type = CopyDataType($2);
|
||||
Active_extern = $1;
|
||||
$2->is_pointer += $3.is_pointer;
|
||||
if ($4 > 0) {
|
||||
|
|
@ -569,7 +570,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
} else
|
||||
create_variable($1,$3.id,$2);
|
||||
}
|
||||
delete $2;
|
||||
DelDataType($2);
|
||||
} stail { }
|
||||
|
||||
/* Global variable that smells like a function pointer */
|
||||
|
|
@ -584,7 +585,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
|
||||
| STATIC type declaration array2 def_args {
|
||||
Active_static = 1;
|
||||
delete $2;
|
||||
DelDataType($2);
|
||||
} stail {
|
||||
Active_static = 0;
|
||||
}
|
||||
|
|
@ -602,13 +603,13 @@ statement : INCLUDE STRING LBRACE {
|
|||
|
||||
| extern type declaration LPAREN parms RPAREN cpp_const {
|
||||
init_language();
|
||||
if (Active_type) delete Active_type;
|
||||
Active_type = new DataType($2);
|
||||
if (Active_type) DelDataType(Active_type);
|
||||
Active_type = CopyDataType($2);
|
||||
Active_extern = $1;
|
||||
$2->is_pointer += $3.is_pointer;
|
||||
$2->is_reference = $3.is_reference;
|
||||
create_function($1, $3.id, $2, $5);
|
||||
delete $2;
|
||||
DelDataType($2);
|
||||
DelParmList($5);
|
||||
} stail { }
|
||||
|
||||
|
|
@ -619,7 +620,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
$2->is_pointer += $3.is_pointer;
|
||||
$2->is_reference = $3.is_reference;
|
||||
create_function($1, $3.id, $2, $5);
|
||||
delete $2;
|
||||
DelDataType($2);
|
||||
DelParmList($5);
|
||||
};
|
||||
|
||||
|
|
@ -627,11 +628,11 @@ statement : INCLUDE STRING LBRACE {
|
|||
|
||||
| extern declaration LPAREN parms RPAREN cpp_const {
|
||||
init_language();
|
||||
DataType *t = new DataType(T_INT);
|
||||
DataType *t = NewDataType(T_INT);
|
||||
t->is_pointer += $2.is_pointer;
|
||||
t->is_reference = $2.is_reference;
|
||||
create_function($1,$2.id,t,$4);
|
||||
delete t;
|
||||
DelDataType(t);
|
||||
} stail { };
|
||||
|
||||
/* A static function declaration code after it */
|
||||
|
|
@ -645,7 +646,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
create_function(0, $3.id, $2, $5);
|
||||
}
|
||||
}
|
||||
delete $2;
|
||||
DelDataType($2);
|
||||
DelParmList($5);
|
||||
};
|
||||
|
||||
|
|
@ -666,15 +667,15 @@ statement : INCLUDE STRING LBRACE {
|
|||
}
|
||||
create_function(0, $3.id, $2, $5);
|
||||
}
|
||||
delete $2;
|
||||
DelParmList($5);
|
||||
DelDataType($2);
|
||||
DelParmList($5);
|
||||
};
|
||||
|
||||
/* A static function declaration (ignored) */
|
||||
|
||||
| STATIC type declaration LPAREN parms RPAREN cpp_const {
|
||||
Active_static = 1;
|
||||
delete $2;
|
||||
DelDataType($2);
|
||||
DelParmList($5);
|
||||
} stail {
|
||||
Active_static = 0;
|
||||
|
|
@ -749,7 +750,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
lang->add_native($3,$7.id,$6,$9);
|
||||
}
|
||||
}
|
||||
delete $6;
|
||||
DelDataType($6);
|
||||
DelParmList($9);
|
||||
}
|
||||
|
||||
|
|
@ -886,9 +887,9 @@ statement : INCLUDE STRING LBRACE {
|
|||
| CONSTANT ID definetype SEMI {
|
||||
if (($3.type != T_ERROR) && ($3.type != T_SYMBOL)) {
|
||||
init_language();
|
||||
temp_typeptr = new DataType($3.type);
|
||||
temp_typeptr = NewDataType($3.type);
|
||||
create_constant($2, temp_typeptr, $3.id);
|
||||
delete temp_typeptr;
|
||||
DelDataType(temp_typeptr);
|
||||
} else if ($3.type == T_SYMBOL) {
|
||||
// Add a symbol to the SWIG symbol table
|
||||
if (add_symbol($2)) {
|
||||
|
|
@ -903,11 +904,11 @@ statement : INCLUDE STRING LBRACE {
|
|||
| extern ENUM ename LBRACE { scanner_clear_start(); } enumlist RBRACE SEMI {
|
||||
init_language();
|
||||
if ($3) {
|
||||
temp_type.type = T_INT;
|
||||
temp_type.is_pointer = 0;
|
||||
temp_type.implicit_ptr = 0;
|
||||
sprintf(temp_type.name,"int");
|
||||
DataType_typedef_add(&temp_type,$3,1);
|
||||
temp_type->type = T_INT;
|
||||
temp_type->is_pointer = 0;
|
||||
temp_type->implicit_ptr = 0;
|
||||
sprintf(temp_type->name,"int");
|
||||
DataType_typedef_add(temp_type,$3,1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -915,12 +916,12 @@ statement : INCLUDE STRING LBRACE {
|
|||
|
||||
| TYPEDEF ENUM ename LBRACE { scanner_clear_start(); } enumlist RBRACE ID {
|
||||
init_language();
|
||||
temp_type.type = T_INT;
|
||||
temp_type.is_pointer = 0;
|
||||
temp_type.implicit_ptr = 0;
|
||||
sprintf(temp_type.name,"int");
|
||||
Active_typedef = new DataType(&temp_type);
|
||||
DataType_typedef_add(&temp_type,$8,1);
|
||||
temp_type->type = T_INT;
|
||||
temp_type->is_pointer = 0;
|
||||
temp_type->implicit_ptr = 0;
|
||||
sprintf(temp_type->name,"int");
|
||||
Active_typedef = CopyDataType(temp_type);
|
||||
DataType_typedef_add(temp_type,$8,1);
|
||||
} typedeflist { }
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
|
|
@ -1139,7 +1140,7 @@ doc_enable : DOC_DISABLE {
|
|||
typedef_decl : TYPEDEF type declaration {
|
||||
init_language();
|
||||
/* Add a new typedef */
|
||||
Active_typedef = new DataType($2);
|
||||
Active_typedef = CopyDataType($2);
|
||||
$2->is_pointer += $3.is_pointer;
|
||||
DataType_typedef_add($2, $3.id,0);
|
||||
/* If this is %typedef, add it to the header */
|
||||
|
|
@ -1163,7 +1164,7 @@ typedef_decl : TYPEDEF type declaration {
|
|||
$2->is_pointer = 1;
|
||||
DataType_typedef_add($2,$5,1);
|
||||
cplus_register_type($5);
|
||||
delete $2;
|
||||
DelDataType($2);
|
||||
delete $5;
|
||||
DelParmList($8);
|
||||
}
|
||||
|
|
@ -1185,7 +1186,7 @@ typedef_decl : TYPEDEF type declaration {
|
|||
$2->is_pointer = 1;
|
||||
DataType_typedef_add($2,$6,1);
|
||||
cplus_register_type($6);
|
||||
delete $2;
|
||||
DelDataType($2);
|
||||
delete $6;
|
||||
DelParmList($9);
|
||||
}
|
||||
|
|
@ -1194,7 +1195,7 @@ typedef_decl : TYPEDEF type declaration {
|
|||
|
||||
| TYPEDEF type declaration array {
|
||||
init_language();
|
||||
Active_typedef = new DataType($2);
|
||||
Active_typedef = CopyDataType($2);
|
||||
// This datatype is going to be readonly
|
||||
|
||||
$2->status = STAT_READONLY | STAT_REPLACETYPE;
|
||||
|
|
@ -1222,22 +1223,22 @@ typedef_decl : TYPEDEF type declaration {
|
|||
typedeflist : COMMA declaration typedeflist {
|
||||
if (Active_typedef) {
|
||||
DataType *t;
|
||||
t = new DataType(Active_typedef);
|
||||
t = CopyDataType(Active_typedef);
|
||||
t->is_pointer += $2.is_pointer;
|
||||
DataType_typedef_add(t,$2.id,0);
|
||||
cplus_register_type($2.id);
|
||||
delete t;
|
||||
DelDataType(t);
|
||||
}
|
||||
}
|
||||
| COMMA declaration array {
|
||||
DataType *t;
|
||||
t = new DataType(Active_typedef);
|
||||
t = CopyDataType(Active_typedef);
|
||||
t->status = STAT_READONLY | STAT_REPLACETYPE;
|
||||
t->is_pointer += $2.is_pointer + 1;
|
||||
t->arraystr = copy_string(Char(ArrayString));
|
||||
DataType_typedef_add(t,$2.id,0);
|
||||
cplus_register_type($2.id);
|
||||
delete t;
|
||||
DelDataType(t);
|
||||
fprintf(stderr,"%s : Line %d. Warning. Array type %s will be read-only without a typemap.\n",input_file,line_number, $2.id);
|
||||
}
|
||||
| empty { }
|
||||
|
|
@ -1266,7 +1267,7 @@ pragma : PRAGMA LPAREN ID COMMA ID stylearg RPAREN {
|
|||
stail : SEMI { }
|
||||
| COMMA declaration array2 def_args {
|
||||
init_language();
|
||||
temp_typeptr = new DataType(Active_type);
|
||||
temp_typeptr = CopyDataType(Active_type);
|
||||
temp_typeptr->is_pointer += $2.is_pointer;
|
||||
if ($3 > 0) {
|
||||
temp_typeptr->is_pointer++;
|
||||
|
|
@ -1287,15 +1288,15 @@ stail : SEMI { }
|
|||
} else
|
||||
create_variable(Active_extern, $2.id, temp_typeptr);
|
||||
}
|
||||
delete temp_typeptr;
|
||||
DelDataType(temp_typeptr);
|
||||
} stail { }
|
||||
| COMMA declaration LPAREN parms RPAREN cpp_const {
|
||||
init_language();
|
||||
temp_typeptr = new DataType(Active_type);
|
||||
temp_typeptr = CopyDataType(Active_type);
|
||||
temp_typeptr->is_pointer += $2.is_pointer;
|
||||
temp_typeptr->is_reference = $2.is_reference;
|
||||
create_function(Active_extern, $2.id, temp_typeptr, $4);
|
||||
delete temp_typeptr;
|
||||
DelDataType(temp_typeptr);
|
||||
DelParmList($4);
|
||||
} stail { }
|
||||
;
|
||||
|
|
@ -1373,7 +1374,7 @@ parm_type : type pname {
|
|||
$$->call_type = CALL_REFERENCE;
|
||||
$$->t->is_pointer++;
|
||||
}
|
||||
delete $1;
|
||||
DelDataType($1);
|
||||
delete $2;
|
||||
}
|
||||
|
||||
|
|
@ -1387,7 +1388,7 @@ parm_type : type pname {
|
|||
// Add array string to the type
|
||||
$$->t->arraystr = copy_string(Char(ArrayString));
|
||||
}
|
||||
delete $1;
|
||||
DelDataType($1);
|
||||
delete $3;
|
||||
}
|
||||
|
||||
|
|
@ -1400,7 +1401,7 @@ parm_type : type pname {
|
|||
if (!CPlusPlus) {
|
||||
fprintf(stderr,"%s : Line %d. Warning. Use of C++ Reference detected. Use the -c++ option.\n", input_file, line_number);
|
||||
}
|
||||
delete $1;
|
||||
DelDataType($1);
|
||||
delete $3;
|
||||
}
|
||||
| type LPAREN stars pname RPAREN LPAREN parms RPAREN {
|
||||
|
|
@ -1410,13 +1411,13 @@ parm_type : type pname {
|
|||
$$->t->type = T_ERROR;
|
||||
$$->name = copy_string($4);
|
||||
strcpy($$->t->name,"<function ptr>");
|
||||
delete $1;
|
||||
DelDataType($1);
|
||||
delete $4;
|
||||
DelParmList($7);
|
||||
}
|
||||
| PERIOD PERIOD PERIOD {
|
||||
fprintf(stderr,"%s : Line %d. Variable length arguments not supported (ignored).\n", input_file, line_number);
|
||||
$$ = NewParm(new DataType(T_INT),(char *) "varargs");
|
||||
$$ = NewParm(NewDataType(T_INT),(char *) "varargs");
|
||||
$$->t->type = T_ERROR;
|
||||
$$->name = copy_string((char*)"varargs");
|
||||
strcpy($$->t->name,"<varargs>");
|
||||
|
|
@ -1571,7 +1572,7 @@ type : TYPE_INT {
|
|||
}
|
||||
}
|
||||
| ID objc_protolist {
|
||||
$$ = new DataType;
|
||||
$$ = NewDataType(0);
|
||||
strcpy($$->name,$1);
|
||||
$$->type = T_USER;
|
||||
/* Do a typedef lookup */
|
||||
|
|
@ -1591,12 +1592,12 @@ type : TYPE_INT {
|
|||
strcpy($$->qualifier,"const");
|
||||
}
|
||||
| cpptype ID {
|
||||
$$ = new DataType;
|
||||
$$ = NewDataType(0);
|
||||
sprintf($$->name,"%s %s",$1, $2);
|
||||
$$->type = T_USER;
|
||||
}
|
||||
| ID DCOLON ID {
|
||||
$$ = new DataType;
|
||||
$$ = NewDataType(0);
|
||||
sprintf($$->name,"%s::%s",$1,$3);
|
||||
$$->type = T_USER;
|
||||
DataType_typedef_resolve($$,0);
|
||||
|
|
@ -1605,13 +1606,13 @@ type : TYPE_INT {
|
|||
|
||||
|
||||
| DCOLON ID {
|
||||
$$ = new DataType;
|
||||
$$ = NewDataType(0);
|
||||
sprintf($$->name,"%s", $2);
|
||||
$$->type = T_USER;
|
||||
DataType_typedef_resolve($$,1);
|
||||
}
|
||||
| ENUM ID {
|
||||
$$ = new DataType;
|
||||
$$ = NewDataType(0);
|
||||
sprintf($$->name,"enum %s", $2);
|
||||
$$->type = T_INT;
|
||||
DataType_typedef_resolve($$,1);
|
||||
|
|
@ -1662,7 +1663,7 @@ strict_type : TYPE_INT {
|
|||
strcpy($$->qualifier,"const");
|
||||
}
|
||||
| cpptype ID {
|
||||
$$ = new DataType;
|
||||
$$ = NewDataType(0);
|
||||
sprintf($$->name,"%s %s",$1, $2);
|
||||
$$->type = T_USER;
|
||||
}
|
||||
|
|
@ -1788,19 +1789,19 @@ enumlist : enumlist COMMA edecl {}
|
|||
|
||||
|
||||
edecl : ID {
|
||||
temp_typeptr = new DataType(T_INT);
|
||||
temp_typeptr = NewDataType(T_INT);
|
||||
create_constant($1, temp_typeptr, $1);
|
||||
delete temp_typeptr;
|
||||
DelDataType(temp_typeptr);
|
||||
}
|
||||
| ID EQUAL { scanner_check_typedef();} etype {
|
||||
temp_typeptr = new DataType($4.type);
|
||||
temp_typeptr = NewDataType($4.type);
|
||||
// Use enum name instead of value
|
||||
// OLD create_constant($1, temp_typeptr, $4.id);
|
||||
if ($4.type == T_CHAR)
|
||||
create_constant($1,temp_typeptr, $4.id);
|
||||
else
|
||||
create_constant($1, temp_typeptr, $1);
|
||||
delete temp_typeptr;
|
||||
DelDataType(temp_typeptr);
|
||||
scanner_ignore_typedef();
|
||||
}
|
||||
| empty { }
|
||||
|
|
@ -2083,7 +2084,7 @@ cpp_class :
|
|||
}
|
||||
}
|
||||
// Create a datatype for correctly processing the typedef
|
||||
Active_typedef = new DataType();
|
||||
Active_typedef = NewDataType(0);
|
||||
Active_typedef->type = T_USER;
|
||||
sprintf(Active_typedef->name,"%s %s", $2,$3);
|
||||
Active_typedef->is_pointer = 0;
|
||||
|
|
@ -2121,11 +2122,11 @@ cpp_class :
|
|||
if ($9.is_pointer == 0)
|
||||
DataType_typedef_add(Active_typedef,$9.id,0);
|
||||
else {
|
||||
DataType *t = new DataType(Active_typedef);
|
||||
DataType *t = CopyDataType(Active_typedef);
|
||||
t->is_pointer += $9.is_pointer;
|
||||
DataType_typedef_add(t,$9.id,0);
|
||||
cplus_register_type($9.id);
|
||||
delete t;
|
||||
DelDataType(t);
|
||||
}
|
||||
cplus_mode = CPLUS_PUBLIC;
|
||||
} typedeflist { };
|
||||
|
|
@ -2162,7 +2163,7 @@ cpp_class :
|
|||
}
|
||||
}
|
||||
// Create a datatype for correctly processing the typedef
|
||||
Active_typedef = new DataType();
|
||||
Active_typedef = NewDataType(0);
|
||||
Active_typedef->type = T_USER;
|
||||
sprintf(Active_typedef->name,"%s",$7.id);
|
||||
Active_typedef->is_pointer = 0;
|
||||
|
|
@ -2206,7 +2207,7 @@ cpp_other :/* A dummy class name */
|
|||
sprintf(yy_rename,"%s_%s",$3.id,$5);
|
||||
}
|
||||
create_function($1, temp_name, $2, $7);
|
||||
delete $2;
|
||||
DelDataType($2);
|
||||
DelParmList($7);
|
||||
}
|
||||
|
||||
|
|
@ -2224,7 +2225,7 @@ cpp_other :/* A dummy class name */
|
|||
sprintf(yy_rename,"%s_%s",$3.id,$5);
|
||||
}
|
||||
create_variable($1,temp_name, $2);
|
||||
delete $2;
|
||||
DelDataType($2);
|
||||
}
|
||||
|
||||
/* Operator overloading catch */
|
||||
|
|
@ -2232,7 +2233,7 @@ cpp_other :/* A dummy class name */
|
|||
| extern type declaration DCOLON OPERATOR {
|
||||
fprintf(stderr,"%s : Line %d. Operator overloading not supported (ignored).\n", input_file, line_number);
|
||||
skip_decl();
|
||||
delete $2;
|
||||
DelDataType($2);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2292,7 +2293,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
|
|||
cplus_member_func($2.id, iname, $1,$4,0);
|
||||
}
|
||||
scanner_clear_start();
|
||||
delete $1;
|
||||
DelDataType($1);
|
||||
DelParmList($4);
|
||||
}
|
||||
|
||||
|
|
@ -2309,7 +2310,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
|
|||
cplus_member_func($3.id,iname,$2,$5,1);
|
||||
}
|
||||
scanner_clear_start();
|
||||
delete $2;
|
||||
DelDataType($2);
|
||||
DelParmList($5);
|
||||
}
|
||||
|
||||
|
|
@ -2359,8 +2360,8 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
|
|||
char *iname;
|
||||
init_language();
|
||||
if (cplus_mode == CPLUS_PUBLIC) {
|
||||
if (Active_type) delete Active_type;
|
||||
Active_type = new DataType($1);
|
||||
if (Active_type) DelDataType(Active_type);
|
||||
Active_type = CopyDataType($1);
|
||||
$1->is_pointer += $2.is_pointer;
|
||||
$1->is_reference = $2.is_reference;
|
||||
if ($1->qualifier) {
|
||||
|
|
@ -2397,7 +2398,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
|
|||
}
|
||||
}
|
||||
scanner_clear_start();
|
||||
delete $1;
|
||||
DelDataType($1);
|
||||
} cpp_tail { }
|
||||
|
||||
| type declaration array def_args {
|
||||
|
|
@ -2406,8 +2407,8 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
|
|||
char *tm = 0;
|
||||
init_language();
|
||||
if (cplus_mode == CPLUS_PUBLIC) {
|
||||
if (Active_type) delete Active_type;
|
||||
Active_type = new DataType($1);
|
||||
if (Active_type) DelDataType(Active_type);
|
||||
Active_type = CopyDataType($1);
|
||||
$1->is_pointer += $2.is_pointer + 1;
|
||||
$1->is_reference = $2.is_reference;
|
||||
$1->arraystr = copy_string(Char(ArrayString));
|
||||
|
|
@ -2422,7 +2423,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
|
|||
fprintf(stderr,"%s : Line %d. Warning. Array member will be read-only.\n",input_file,line_number);
|
||||
}
|
||||
scanner_clear_start();
|
||||
delete $1;
|
||||
DelDataType($1);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2436,11 +2437,11 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
|
|||
iname = make_name($3.id);
|
||||
if (iname == $3.id) iname = 0;
|
||||
cplus_static_var($3.id,iname,$2);
|
||||
if (Active_type) delete Active_type;
|
||||
Active_type = new DataType($2);
|
||||
if (Active_type) DelDataType(Active_type);
|
||||
Active_type = CopyDataType($2);
|
||||
}
|
||||
scanner_clear_start();
|
||||
delete $2;
|
||||
DelDataType($2);
|
||||
} cpp_tail { }
|
||||
|
||||
/* Static member function */
|
||||
|
|
@ -2455,7 +2456,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
|
|||
cplus_static_func($3.id, iname, $2, $5);
|
||||
}
|
||||
scanner_clear_start();
|
||||
delete $2;
|
||||
DelDataType($2);
|
||||
DelParmList($5);
|
||||
}
|
||||
/* Turn on public: mode */
|
||||
|
|
@ -2501,11 +2502,11 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
|
|||
if (cplus_mode == CPLUS_PUBLIC) {
|
||||
if ($2) {
|
||||
cplus_register_type($2);
|
||||
temp_type.type = T_INT;
|
||||
temp_type.is_pointer = 0;
|
||||
temp_type.implicit_ptr = 0;
|
||||
sprintf(temp_type.name,"int");
|
||||
DataType_typedef_add(&temp_type,$2,1);
|
||||
temp_type->type = T_INT;
|
||||
temp_type->is_pointer = 0;
|
||||
temp_type->implicit_ptr = 0;
|
||||
sprintf(temp_type->name,"int");
|
||||
DataType_typedef_add(temp_type,$2,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2583,7 +2584,7 @@ cpp_pragma : PRAGMA ID stylearg {
|
|||
Char(CCode), " $classname_", $5.id, ";\n", 0);
|
||||
n->name = copy_string($5.id);
|
||||
n->line = start_line;
|
||||
n->type = new DataType;
|
||||
n->type = NewDataType(0);
|
||||
n->type->type = T_USER;
|
||||
n->type->is_pointer = $5.is_pointer;
|
||||
n->type->is_reference = $5.is_reference;
|
||||
|
|
@ -2609,7 +2610,7 @@ cpp_pragma : PRAGMA ID stylearg {
|
|||
Char(CCode), " $classname_", $4.id, ";\n",0);
|
||||
n->name = copy_string($4.id);
|
||||
n->line = start_line;
|
||||
n->type = new DataType;
|
||||
n->type = NewDataType(0);
|
||||
n->type->type = T_USER;
|
||||
n->type->is_pointer = $4.is_pointer;
|
||||
n->type->is_reference = $4.is_reference;
|
||||
|
|
@ -2662,7 +2663,7 @@ cpp_tail : SEMI { }
|
|||
|
||||
init_language();
|
||||
if (cplus_mode == CPLUS_PUBLIC) {
|
||||
temp_typeptr = new DataType(Active_type);
|
||||
temp_typeptr = CopyDataType(Active_type);
|
||||
temp_typeptr->is_pointer += $2.is_pointer;
|
||||
if (temp_typeptr->status & STAT_READONLY) {
|
||||
if (!(tm = typemap_lookup((char*)"memberin",typemap_lang,temp_typeptr,$2.id,(char*)"",(char*)"")))
|
||||
|
|
@ -2670,7 +2671,7 @@ cpp_tail : SEMI { }
|
|||
}
|
||||
cplus_variable($2.id,(char *) 0,temp_typeptr);
|
||||
Status = oldstatus;
|
||||
delete temp_typeptr;
|
||||
DelDataType(temp_typeptr);
|
||||
}
|
||||
scanner_clear_start();
|
||||
} cpp_tail { }
|
||||
|
|
@ -2680,7 +2681,7 @@ cpp_tail : SEMI { }
|
|||
|
||||
init_language();
|
||||
if (cplus_mode == CPLUS_PUBLIC) {
|
||||
temp_typeptr = new DataType(Active_type);
|
||||
temp_typeptr = CopyDataType(Active_type);
|
||||
temp_typeptr->is_pointer += $2.is_pointer;
|
||||
if (!(tm = typemap_lookup((char*)"memberin",typemap_lang,temp_typeptr,$2.id,(char*)"",(char*)"")))
|
||||
Status = Status | STAT_READONLY;
|
||||
|
|
@ -2689,7 +2690,7 @@ cpp_tail : SEMI { }
|
|||
Status = oldstatus;
|
||||
if (!tm)
|
||||
fprintf(stderr,"%s : Line %d. Warning. Array member will be read-only.\n",input_file,line_number);
|
||||
delete temp_typeptr;
|
||||
DelDataType(temp_typeptr);
|
||||
}
|
||||
scanner_clear_start();
|
||||
} cpp_tail { }
|
||||
|
|
@ -2712,35 +2713,35 @@ cpp_enumlist : cpp_enumlist COMMA cpp_edecl {}
|
|||
|
||||
cpp_edecl : ID {
|
||||
if (cplus_mode == CPLUS_PUBLIC) {
|
||||
temp_typeptr = new DataType(T_INT);
|
||||
temp_typeptr = NewDataType(T_INT);
|
||||
cplus_declare_const($1, (char *) 0, temp_typeptr, (char *) 0);
|
||||
delete temp_typeptr;
|
||||
DelDataType(temp_typeptr);
|
||||
scanner_clear_start();
|
||||
}
|
||||
}
|
||||
| ID EQUAL etype {
|
||||
if (cplus_mode == CPLUS_PUBLIC) {
|
||||
temp_typeptr = new DataType(T_INT);
|
||||
temp_typeptr = NewDataType(T_INT);
|
||||
cplus_declare_const($1,(char *) 0, temp_typeptr,(char *) 0);
|
||||
// OLD : Bug with value cplus_declare_const($1,(char *) 0, temp_typeptr,$3.id);
|
||||
delete temp_typeptr;
|
||||
DelDataType(temp_typeptr);
|
||||
scanner_clear_start();
|
||||
}
|
||||
}
|
||||
| NAME LPAREN ID RPAREN ID {
|
||||
if (cplus_mode == CPLUS_PUBLIC) {
|
||||
temp_typeptr = new DataType(T_INT);
|
||||
temp_typeptr = NewDataType(T_INT);
|
||||
cplus_declare_const($5, $3, temp_typeptr, (char *) 0);
|
||||
delete temp_typeptr;
|
||||
DelDataType(temp_typeptr);
|
||||
scanner_clear_start();
|
||||
}
|
||||
}
|
||||
| NAME LPAREN ID RPAREN ID EQUAL etype {
|
||||
if (cplus_mode == CPLUS_PUBLIC) {
|
||||
temp_typeptr = new DataType(T_INT);
|
||||
temp_typeptr = NewDataType(T_INT);
|
||||
cplus_declare_const($5,$3, temp_typeptr, (char *) 0);
|
||||
// Old : bug with value cplus_declare_const($5,$3, temp_typeptr,$7.id);
|
||||
delete temp_typeptr;
|
||||
DelDataType(temp_typeptr);
|
||||
scanner_clear_start();
|
||||
}
|
||||
}
|
||||
|
|
@ -2968,8 +2969,8 @@ objc_var : type declaration {
|
|||
int oldstatus = Status;
|
||||
char *tm;
|
||||
char *iname;
|
||||
if (Active_type) delete Active_type;
|
||||
Active_type = new DataType($1);
|
||||
if (Active_type) DelDataType(Active_type);
|
||||
Active_type = CopyDataType($1);
|
||||
$1->is_pointer += $2.is_pointer;
|
||||
$1->is_reference = $2.is_reference;
|
||||
if ($1->status & STAT_READONLY) {
|
||||
|
|
@ -2982,14 +2983,14 @@ objc_var : type declaration {
|
|||
Status = oldstatus;
|
||||
}
|
||||
scanner_clear_start();
|
||||
delete $1;
|
||||
DelDataType($1);
|
||||
}
|
||||
| type declaration array {
|
||||
if (cplus_mode == CPLUS_PUBLIC) {
|
||||
int oldstatus = Status;
|
||||
char *tm, *iname;
|
||||
if (Active_type) delete Active_type;
|
||||
Active_type = new DataType($1);
|
||||
if (Active_type) DelDataType(Active_type);
|
||||
Active_type = CopyDataType($1);
|
||||
$1->is_pointer += $2.is_pointer;
|
||||
$1->is_reference = $2.is_reference;
|
||||
$1->arraystr = copy_string(Char(ArrayString));
|
||||
|
|
@ -3003,7 +3004,7 @@ objc_var : type declaration {
|
|||
Status = oldstatus;
|
||||
}
|
||||
scanner_clear_start();
|
||||
delete $1;
|
||||
DelDataType($1);
|
||||
}
|
||||
| NAME LPAREN ID RPAREN {
|
||||
strcpy(yy_rename,$3);
|
||||
|
|
@ -3014,7 +3015,7 @@ objc_vartail : COMMA declaration objc_vartail {
|
|||
if (cplus_mode == CPLUS_PUBLIC) {
|
||||
int oldstatus = Status;
|
||||
char *tm, *iname;
|
||||
DataType *t = new DataType (Active_type);
|
||||
DataType *t = CopyDataType (Active_type);
|
||||
t->is_pointer += $2.is_pointer;
|
||||
t->is_reference = $2.is_reference;
|
||||
if (t->status & STAT_READONLY) {
|
||||
|
|
@ -3025,7 +3026,7 @@ objc_vartail : COMMA declaration objc_vartail {
|
|||
if (iname == $2.id) iname = 0;
|
||||
cplus_variable($2.id,iname,t);
|
||||
Status = oldstatus;
|
||||
delete t;
|
||||
DelDataType(t);
|
||||
}
|
||||
scanner_clear_start();
|
||||
}
|
||||
|
|
@ -3034,7 +3035,7 @@ objc_vartail : COMMA declaration objc_vartail {
|
|||
if (cplus_mode == CPLUS_PUBLIC) {
|
||||
int oldstatus = Status;
|
||||
char *tm;
|
||||
DataType *t = new DataType (Active_type);
|
||||
DataType *t = CopyDataType (Active_type);
|
||||
t->is_pointer += $2.is_pointer;
|
||||
t->is_reference = $2.is_reference;
|
||||
t->arraystr = copy_string(Char(ArrayString));
|
||||
|
|
@ -3046,7 +3047,7 @@ objc_vartail : COMMA declaration objc_vartail {
|
|||
if (iname == $2.id) iname = 0;
|
||||
cplus_variable($2.id,iname,t);
|
||||
Status = oldstatus;
|
||||
delete t;
|
||||
DelDataType(t);
|
||||
}
|
||||
scanner_clear_start();
|
||||
}
|
||||
|
|
@ -3093,7 +3094,7 @@ objc_method : MINUS objc_ret_type ID objc_args objc_end {
|
|||
if (iname == $3) iname = 0;
|
||||
cplus_member_func($3,iname,$2,$4,0);
|
||||
scanner_clear_start();
|
||||
delete $2;
|
||||
DelDataType($2);
|
||||
delete $3;
|
||||
DelParmList($4);
|
||||
}
|
||||
|
|
@ -3111,7 +3112,7 @@ objc_method : MINUS objc_ret_type ID objc_args objc_end {
|
|||
cplus_static_func($3,iname,$2,$4);
|
||||
}
|
||||
scanner_clear_start();
|
||||
delete $2;
|
||||
DelDataType($2);
|
||||
delete $3;
|
||||
DelParmList($4);
|
||||
}
|
||||
|
|
@ -3129,7 +3130,7 @@ objc_ret_type : LPAREN type RPAREN {
|
|||
$$->is_pointer += $3;
|
||||
}
|
||||
| empty { /* Empty type means "id" type */
|
||||
$$ = new DataType(T_VOID);
|
||||
$$ = NewDataType(T_VOID);
|
||||
sprintf($$->name,"id");
|
||||
$$->is_pointer = 1;
|
||||
$$->implicit_ptr = 1;
|
||||
|
|
@ -3137,11 +3138,11 @@ objc_ret_type : LPAREN type RPAREN {
|
|||
;
|
||||
|
||||
objc_arg_type : LPAREN parm RPAREN {
|
||||
$$ = new DataType($2->t);
|
||||
$$ = CopyDataType($2->t);
|
||||
DelParm($2);
|
||||
}
|
||||
| empty {
|
||||
$$ = new DataType(T_VOID);
|
||||
$$ = NewDataType(T_VOID);
|
||||
sprintf($$->name,"id");
|
||||
$$->is_pointer = 1;
|
||||
$$->implicit_ptr = 1;
|
||||
|
|
@ -3241,7 +3242,7 @@ typemap_parm : type typemap_name {
|
|||
$$->p = NewParm($1,$2);
|
||||
$$->p->call_type = 0;
|
||||
$$->args = tm_parm;
|
||||
delete $1;
|
||||
DelDataType($1);
|
||||
delete $2;
|
||||
}
|
||||
|
||||
|
|
@ -3255,7 +3256,7 @@ typemap_parm : type typemap_name {
|
|||
$$->p->t->arraystr = copy_string(Char(ArrayString));
|
||||
}
|
||||
$$->args = tm_parm;
|
||||
delete $1;
|
||||
DelDataType($1);
|
||||
delete $3;
|
||||
}
|
||||
|
||||
|
|
@ -3269,7 +3270,7 @@ typemap_parm : type typemap_name {
|
|||
fprintf(stderr,"%s : Line %d. Warning. Use of C++ Reference detected. Use the -c++ option.\n", input_file, line_number);
|
||||
}
|
||||
$$->args = tm_parm;
|
||||
delete $1;
|
||||
DelDataType($1);
|
||||
delete $3;
|
||||
}
|
||||
| type LPAREN stars typemap_name RPAREN LPAREN parms RPAREN {
|
||||
|
|
@ -3281,7 +3282,7 @@ typemap_parm : type typemap_name {
|
|||
$$->p->name = copy_string($4);
|
||||
strcpy($$->p->t->name,"<function ptr>");
|
||||
$$->args = tm_parm;
|
||||
delete $1;
|
||||
DelDataType($1);
|
||||
delete $4;
|
||||
DelParmList($7);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1128,61 +1128,61 @@ extern "C" int yylex(void) {
|
|||
/* Look for keywords now */
|
||||
|
||||
if (strcmp(yytext,"int") == 0) {
|
||||
yylval.type = new DataType;
|
||||
yylval.type = NewDataType(0);
|
||||
yylval.type->type = T_INT;
|
||||
strcpy(yylval.type->name,yytext);
|
||||
return(TYPE_INT);
|
||||
}
|
||||
if (strcmp(yytext,"double") == 0) {
|
||||
yylval.type = new DataType;
|
||||
yylval.type = NewDataType(0);
|
||||
yylval.type->type = T_DOUBLE;
|
||||
strcpy(yylval.type->name,yytext);
|
||||
return(TYPE_DOUBLE);
|
||||
}
|
||||
if (strcmp(yytext,"void") == 0) {
|
||||
yylval.type = new DataType;
|
||||
yylval.type = NewDataType(0);
|
||||
yylval.type->type = T_VOID;
|
||||
strcpy(yylval.type->name,yytext);
|
||||
return(TYPE_VOID);
|
||||
}
|
||||
if (strcmp(yytext,"char") == 0) {
|
||||
yylval.type = new DataType;
|
||||
yylval.type = NewDataType(0);
|
||||
yylval.type->type = T_CHAR;
|
||||
strcpy(yylval.type->name,yytext);
|
||||
return(TYPE_CHAR);
|
||||
}
|
||||
if (strcmp(yytext,"short") == 0) {
|
||||
yylval.type = new DataType;
|
||||
yylval.type = NewDataType(0);
|
||||
yylval.type->type = T_SHORT;
|
||||
strcpy(yylval.type->name,yytext);
|
||||
return(TYPE_SHORT);
|
||||
}
|
||||
if (strcmp(yytext,"long") == 0) {
|
||||
yylval.type = new DataType;
|
||||
yylval.type = NewDataType(0);
|
||||
yylval.type->type = T_LONG;
|
||||
strcpy(yylval.type->name,yytext);
|
||||
return(TYPE_LONG);
|
||||
}
|
||||
if (strcmp(yytext,"float") == 0) {
|
||||
yylval.type = new DataType;
|
||||
yylval.type = NewDataType(0);
|
||||
yylval.type->type = T_FLOAT;
|
||||
strcpy(yylval.type->name,yytext);
|
||||
return(TYPE_FLOAT);
|
||||
}
|
||||
if (strcmp(yytext,"signed") == 0) {
|
||||
yylval.type = new DataType;
|
||||
yylval.type = NewDataType(0);
|
||||
yylval.type->type = T_SINT;
|
||||
strcpy(yylval.type->name,yytext);
|
||||
return(TYPE_SIGNED);
|
||||
}
|
||||
if (strcmp(yytext,"unsigned") == 0) {
|
||||
yylval.type = new DataType;
|
||||
yylval.type = NewDataType(0);
|
||||
yylval.type->type = T_UINT;
|
||||
strcpy(yylval.type->name,yytext);
|
||||
return(TYPE_UNSIGNED);
|
||||
}
|
||||
if (strcmp(yytext,"bool") == 0) {
|
||||
yylval.type = new DataType;
|
||||
yylval.type = NewDataType(0);
|
||||
yylval.type->type = T_BOOL;
|
||||
strcpy(yylval.type->name,yytext);
|
||||
return(TYPE_BOOL);
|
||||
|
|
@ -1294,7 +1294,7 @@ extern "C" int yylex(void) {
|
|||
|
||||
if (check_typedef) {
|
||||
if (DataType_is_typedef(yytext)) {
|
||||
yylval.type = new DataType;
|
||||
yylval.type = NewDataType(0);
|
||||
yylval.type->type = T_USER;
|
||||
strcpy(yylval.type->name,yytext);
|
||||
DataType_typedef_resolve(yylval.type,0);
|
||||
|
|
|
|||
|
|
@ -105,8 +105,7 @@ extern int IsVirtual;
|
|||
|
||||
#define MAX_NAME 96
|
||||
|
||||
class DataType {
|
||||
public:
|
||||
typedef struct DataType {
|
||||
int type; // SWIG Type code
|
||||
char name[MAX_NAME]; // Name of type
|
||||
char is_pointer; // Is this a pointer?
|
||||
|
|
@ -116,12 +115,13 @@ public:
|
|||
char *qualifier; // A qualifier string (ie. const).
|
||||
char *arraystr; // String containing array part
|
||||
int id; // type identifier (unique for every type).
|
||||
DataType();
|
||||
DataType(DataType *);
|
||||
DataType(int type);
|
||||
~DataType();
|
||||
};
|
||||
|
||||
// Temporary: catches accidental use.
|
||||
DataType() { abort(); }
|
||||
DataType(DataType *) { abort(); }
|
||||
DataType(int type) { abort();}
|
||||
~DataType() { abort(); }
|
||||
} DataType;
|
||||
|
||||
extern DataType *NewDataType(int type);
|
||||
extern DataType *CopyDataType(DataType *type);
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ struct TypeMap {
|
|||
|
||||
TypeMap(char *l, DataType *t, char *c, ParmList *p = 0) {
|
||||
lang = copy_string(l);
|
||||
type = new DataType(t);
|
||||
type = CopyDataType(t);
|
||||
code = NewString(c);
|
||||
first = type_id;
|
||||
last = INT_MAX;
|
||||
|
|
@ -101,7 +101,7 @@ struct TypeMap {
|
|||
}
|
||||
TypeMap(TypeMap *t) {
|
||||
lang = copy_string(t->lang);
|
||||
type = new DataType(t->type);
|
||||
type = CopyDataType(t->type);
|
||||
code = Copy(t->code);
|
||||
first = type_id;
|
||||
last = INT_MAX;
|
||||
|
|
@ -129,7 +129,7 @@ struct TmMethod {
|
|||
if (n) name = copy_string(n);
|
||||
else name = 0;
|
||||
if (t) {
|
||||
type = new DataType(t);
|
||||
type = CopyDataType(t);
|
||||
} else {
|
||||
type = 0;
|
||||
}
|
||||
|
|
@ -336,11 +336,13 @@ void typemap_register(char *op, char *lang, DataType *type, char *pname,
|
|||
|
||||
void typemap_register(char *op, char *lang, char *type, char *pname,
|
||||
char *getcode, ParmList *args) {
|
||||
DataType temp;
|
||||
strcpy(temp.name,type);
|
||||
temp.is_pointer = 0;
|
||||
temp.type = T_USER;
|
||||
typemap_register(op,lang,&temp,pname,getcode,args);
|
||||
DataType *temp;
|
||||
temp = NewDataType(0);
|
||||
strcpy(temp->name,type);
|
||||
temp->is_pointer = 0;
|
||||
temp->type = T_USER;
|
||||
typemap_register(op,lang,temp,pname,getcode,args);
|
||||
DelDataType(temp);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -355,7 +357,7 @@ void typemap_register(char *op, char *lang, char *type, char *pname,
|
|||
void typemap_register_default(char *op, char *lang, int type, int ptr, char *arraystr,
|
||||
char *code, ParmList *args) {
|
||||
|
||||
DataType *t = new DataType(type);
|
||||
DataType *t = NewDataType(type);
|
||||
|
||||
// Create a raw datatype from the arguments
|
||||
|
||||
|
|
@ -365,7 +367,7 @@ void typemap_register_default(char *op, char *lang, int type, int ptr, char *arr
|
|||
// Now, go register this as a default type
|
||||
|
||||
typemap_register(op,lang,t,(char*)"SWIG_DEFAULT_TYPE",code,args);
|
||||
delete t;
|
||||
DelDataType(t);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -747,11 +749,11 @@ char *typemap_lookup(char *op, char *lang, DataType *type, char *pname, char *so
|
|||
// Still no idea, try to find a default typemap
|
||||
|
||||
if (!result) {
|
||||
DataType *t = new DataType(type);
|
||||
DataType *t = CopyDataType(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);
|
||||
if (result) {
|
||||
delete t;
|
||||
DelDataType(t);
|
||||
return result;
|
||||
}
|
||||
if ((t->type == T_USER) || (t->is_pointer)) {
|
||||
|
|
@ -765,7 +767,7 @@ char *typemap_lookup(char *op, char *lang, DataType *type, char *pname, char *so
|
|||
DataType_primitive(t);
|
||||
result = typemap_lookup_internal(op,lang,t,(char*)"SWIG_DEFAULT_TYPE",source,target,f);
|
||||
}
|
||||
delete t;
|
||||
DelDataType(t);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -902,11 +904,11 @@ char *typemap_check(char *op, char *lang, DataType *type, char *pname) {
|
|||
|
||||
// If still no result, might have a default typemap
|
||||
if (!result) {
|
||||
DataType *t = new DataType(type);
|
||||
DataType *t = CopyDataType(type);
|
||||
DataType_primitive(t); // Knock it down to its basic type
|
||||
result = typemap_check_internal(op,lang,t,(char*)"SWIG_DEFAULT_TYPE");
|
||||
if (result) {
|
||||
delete t;
|
||||
DelDataType(t);
|
||||
return result;
|
||||
}
|
||||
if ((t->type == T_USER) || (t->is_pointer)) {
|
||||
|
|
@ -919,7 +921,7 @@ char *typemap_check(char *op, char *lang, DataType *type, char *pname) {
|
|||
DataType_primitive(t);
|
||||
result = typemap_check_internal(op,lang,t,(char*)"SWIG_DEFAULT_TYPE");
|
||||
}
|
||||
delete t;
|
||||
DelDataType(t);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,90 +24,83 @@ extern "C" {
|
|||
// class DataType member functions.
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
DataType::DataType() {
|
||||
type = 1;
|
||||
name[0] = 0;
|
||||
is_pointer = 0;
|
||||
implicit_ptr = 0;
|
||||
qualifier = 0;
|
||||
is_reference = 0;
|
||||
status = 0;
|
||||
arraystr = 0;
|
||||
id = type_id++;
|
||||
}
|
||||
|
||||
// Create a data type only from the type code (used to form constants)
|
||||
|
||||
DataType::DataType(int t) {
|
||||
DataType *NewDataType(int t) {
|
||||
DataType *ty = (DataType *) malloc(sizeof(DataType));
|
||||
switch(t) {
|
||||
case T_BOOL:
|
||||
strcpy(name,"bool");
|
||||
strcpy(ty->name,"bool");
|
||||
break;
|
||||
case T_INT: case T_SINT:
|
||||
strcpy(name,"int");
|
||||
strcpy(ty->name,"int");
|
||||
break;
|
||||
case T_UINT:
|
||||
strcpy(name,"unsigned int");
|
||||
strcpy(ty->name,"unsigned int");
|
||||
break;
|
||||
case T_SHORT: case T_SSHORT:
|
||||
strcpy(name,"short");
|
||||
strcpy(ty->name,"short");
|
||||
break;
|
||||
case T_USHORT:
|
||||
strcpy(name,"unsigned short");
|
||||
strcpy(ty->name,"unsigned short");
|
||||
break;
|
||||
case T_LONG: case T_SLONG:
|
||||
strcpy(name,"long");
|
||||
strcpy(ty->name,"long");
|
||||
break;
|
||||
case T_ULONG:
|
||||
strcpy(name,"unsigned long");
|
||||
strcpy(ty->name,"unsigned long");
|
||||
break;
|
||||
case T_FLOAT:
|
||||
strcpy(name, "float");
|
||||
strcpy(ty->name, "float");
|
||||
break;
|
||||
case T_DOUBLE:
|
||||
strcpy(name, "double");
|
||||
strcpy(ty->name, "double");
|
||||
break;
|
||||
case T_CHAR: case T_SCHAR:
|
||||
strcpy(name, "char");
|
||||
strcpy(ty->name, "char");
|
||||
break;
|
||||
case T_UCHAR:
|
||||
strcpy(name,"unsigned char");
|
||||
strcpy(ty->name,"unsigned char");
|
||||
break;
|
||||
case T_VOID:
|
||||
strcpy(name,"void");
|
||||
strcpy(ty->name,"void");
|
||||
break;
|
||||
case T_USER:
|
||||
strcpy(name,"USER");
|
||||
strcpy(ty->name,"USER");
|
||||
break;
|
||||
default :
|
||||
strcpy(name,"UNKNOWN");
|
||||
strcpy(ty->name,"");
|
||||
break;
|
||||
}
|
||||
type = t;
|
||||
is_pointer = 0;
|
||||
implicit_ptr = 0;
|
||||
qualifier = 0;
|
||||
is_reference = 0;
|
||||
status = 0;
|
||||
arraystr = 0;
|
||||
id = type_id++;
|
||||
ty->type = t;
|
||||
ty->is_pointer = 0;
|
||||
ty->implicit_ptr = 0;
|
||||
ty->qualifier = 0;
|
||||
ty->is_reference = 0;
|
||||
ty->status = 0;
|
||||
ty->arraystr = 0;
|
||||
ty->id = type_id++;
|
||||
return ty;
|
||||
}
|
||||
|
||||
DataType::DataType(DataType *t) {
|
||||
type = t->type;
|
||||
strcpy(name,t->name);
|
||||
is_pointer = t->is_pointer;
|
||||
implicit_ptr = t->implicit_ptr;
|
||||
qualifier = copy_string(t->qualifier);
|
||||
is_reference = t->is_reference;
|
||||
status = t->status;
|
||||
arraystr = copy_string(t->arraystr);
|
||||
id = t->id;
|
||||
DataType *CopyDataType(DataType *t) {
|
||||
DataType *ty = (DataType *) malloc(sizeof(DataType));
|
||||
ty->type = t->type;
|
||||
strcpy(ty->name,t->name);
|
||||
ty->is_pointer = t->is_pointer;
|
||||
ty->implicit_ptr = t->implicit_ptr;
|
||||
ty->qualifier = copy_string(t->qualifier);
|
||||
ty->is_reference = t->is_reference;
|
||||
ty->status = t->status;
|
||||
ty->arraystr = copy_string(t->arraystr);
|
||||
ty->id = t->id;
|
||||
return ty;
|
||||
}
|
||||
|
||||
DataType::~DataType() {
|
||||
if (qualifier) delete qualifier;
|
||||
if (arraystr) delete arraystr;
|
||||
void DelDataType(DataType *t) {
|
||||
if (t->qualifier) delete t->qualifier;
|
||||
if (t->arraystr) delete t->arraystr;
|
||||
free(t);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
|
@ -194,7 +187,7 @@ char *DataType_print_type(DataType *ty) {
|
|||
DataType *t = ty;
|
||||
|
||||
if (ty->status & STAT_REPLACETYPE) {
|
||||
t = new DataType(ty);
|
||||
t = CopyDataType(ty);
|
||||
DataType_typedef_replace(t); // Upgrade type
|
||||
}
|
||||
ri = ri % 8;
|
||||
|
|
@ -203,7 +196,7 @@ char *DataType_print_type(DataType *ty) {
|
|||
strcat(result[ri],"*");
|
||||
|
||||
if (ty->status & STAT_REPLACETYPE) {
|
||||
delete t;
|
||||
DelDataType(t);
|
||||
};
|
||||
return result[ri++];
|
||||
}
|
||||
|
|
@ -281,7 +274,7 @@ char *DataType_print_arraycast(DataType *ty) {
|
|||
|
||||
t = ty;
|
||||
if (ty->status & STAT_REPLACETYPE) {
|
||||
t = new DataType(ty);
|
||||
t = CopyDataType(ty);
|
||||
DataType_typedef_replace(t); // Upgrade type
|
||||
}
|
||||
|
||||
|
|
@ -313,7 +306,7 @@ char *DataType_print_arraycast(DataType *ty) {
|
|||
}
|
||||
}
|
||||
if (ty->status & STAT_REPLACETYPE) {
|
||||
delete t;
|
||||
DelDataType(t);
|
||||
}
|
||||
return result[ri++];
|
||||
}
|
||||
|
|
@ -470,7 +463,7 @@ void DataType_typedef_add(DataType *t,char *tname, int mode) {
|
|||
|
||||
// Make a new datatype that we will place in our hash table
|
||||
|
||||
nt = new DataType(t);
|
||||
nt = CopyDataType(t);
|
||||
nt->implicit_ptr = (t->is_pointer-t->implicit_ptr); // Record if mapped type is a pointer
|
||||
nt->is_pointer = (t->is_pointer-t->implicit_ptr); // Adjust pointer value to be correct
|
||||
DataType_typedef_resolve(nt,0); // Resolve any other mappings of this type
|
||||
|
|
@ -482,13 +475,13 @@ void DataType_typedef_add(DataType *t,char *tname, int mode) {
|
|||
|
||||
if (mode == 0) {
|
||||
if ((t->type != T_VOID) && (strcmp(t->name,tname) != 0)) {
|
||||
t1 = new DataType();
|
||||
t1 = NewDataType(0);
|
||||
strcpy(t1->name,tname);
|
||||
name2 = DataType_print_mangle(t1);
|
||||
name1 = DataType_print_mangle(t);
|
||||
typeeq_addtypedef(name1,name2,t1);
|
||||
typeeq_addtypedef(name2,name1,t);
|
||||
delete t1;
|
||||
DelDataType(t1);
|
||||
}
|
||||
}
|
||||
// Call into the target language with this typedef
|
||||
|
|
@ -636,7 +629,7 @@ void DataType_merge_scope(void *ho) {
|
|||
while (key) {
|
||||
// printf("%s\n", key);
|
||||
t = (DataType *) GetVoid(h,key);
|
||||
nt = new DataType(t);
|
||||
nt = CopyDataType(t);
|
||||
SetVoid(typedef_hash[scope],key,(void *) nt);
|
||||
key = Nextkey(h);
|
||||
}
|
||||
|
|
@ -697,7 +690,7 @@ void *DataType_collapse_scope(char *prefix) {
|
|||
key = Firstkey(typedef_hash[scope]);
|
||||
while (key) {
|
||||
t = (DataType *) GetVoid(typedef_hash[scope],key);
|
||||
nt = new DataType(t);
|
||||
nt = CopyDataType(t);
|
||||
temp = new char[strlen(prefix)+strlen(Char(key))+4];
|
||||
sprintf(temp,"%s::%s",prefix,Char(key));
|
||||
SetVoid(typedef_hash[scope-1],temp, (void *)nt);
|
||||
|
|
@ -788,7 +781,7 @@ void typeeq_add(char *name, char *eqname, char *cast = 0, DataType *type = 0) {
|
|||
e2->name = copy_string(eqname);
|
||||
e2->cast = copy_string(cast);
|
||||
if (type)
|
||||
e2->type = new DataType(type);
|
||||
e2->type = CopyDataType(type);
|
||||
else
|
||||
e2->type = 0;
|
||||
e2->next = e1->next; // Add onto the linked list for name
|
||||
|
|
@ -808,7 +801,7 @@ void typeeq_addtypedef(char *name, char *eqname, DataType *t) {
|
|||
if (!te_init) typeeq_init();
|
||||
|
||||
if (!t) {
|
||||
t = new DataType(T_USER);
|
||||
t = NewDataType(T_USER);
|
||||
strcpy(t->name, eqname);
|
||||
}
|
||||
|
||||
|
|
@ -898,18 +891,22 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
|
|||
// ------------------------------------------------------------------------------
|
||||
|
||||
void typeeq_derived(char *n1, char *n2, char *cast=0) {
|
||||
DataType t,t1;
|
||||
DataType *t,*t1;
|
||||
char *name, *name2;
|
||||
|
||||
t = NewDataType(0);
|
||||
t1 = NewDataType(0);
|
||||
if (!te_init) typeeq_init();
|
||||
|
||||
t.type = T_USER;
|
||||
t1.type = T_USER;
|
||||
strcpy(t.name,n1);
|
||||
strcpy(t1.name,n2);
|
||||
name = DataType_print_mangle(&t);
|
||||
name2 = DataType_print_mangle(&t1);
|
||||
typeeq_add(name,name2, cast, &t1);
|
||||
t->type = T_USER;
|
||||
t1->type = T_USER;
|
||||
strcpy(t->name,n1);
|
||||
strcpy(t1->name,n2);
|
||||
name = DataType_print_mangle(t);
|
||||
name2 = DataType_print_mangle(t1);
|
||||
typeeq_add(name,name2, cast, t1);
|
||||
DelDataType(t);
|
||||
DelDataType(t1);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
|
|
@ -919,16 +916,20 @@ void typeeq_derived(char *n1, char *n2, char *cast=0) {
|
|||
// ------------------------------------------------------------------------------
|
||||
|
||||
void typeeq_mangle(char *n1, char *n2, char *cast=0) {
|
||||
DataType t,t1;
|
||||
DataType *t,*t1;
|
||||
char *name, *name2;
|
||||
|
||||
t = NewDataType(0);
|
||||
t1 = NewDataType(0);
|
||||
if (!te_init) typeeq_init();
|
||||
|
||||
strcpy(t.name,n1);
|
||||
strcpy(t1.name,n2);
|
||||
name = DataType_print_mangle(&t);
|
||||
name2 = DataType_print_mangle(&t1);
|
||||
strcpy(t->name,n1);
|
||||
strcpy(t1->name,n2);
|
||||
name = DataType_print_mangle(t);
|
||||
name2 = DataType_print_mangle(t1);
|
||||
typeeq_add(name,name2,cast);
|
||||
DelDataType(t);
|
||||
DelDataType(t1);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
|
|
@ -1041,7 +1042,7 @@ static DOHHash *remembered = 0;
|
|||
|
||||
void DataType_remember(DataType *ty) {
|
||||
DOHHash *h;
|
||||
DataType *t = new DataType(ty);
|
||||
DataType *t = CopyDataType(ty);
|
||||
|
||||
if (!remembered) remembered = NewHash();
|
||||
SetVoid(remembered, DataType_print_mangle(t), t);
|
||||
|
|
@ -1053,11 +1054,11 @@ void DataType_remember(DataType *ty) {
|
|||
DOH *key;
|
||||
key = Firstkey(h);
|
||||
while (key) {
|
||||
DataType *nt = new DataType(t);
|
||||
DataType *nt = CopyDataType(t);
|
||||
strcpy(nt->name,Char(key));
|
||||
if (!Getattr(remembered,DataType_print_mangle(nt)))
|
||||
DataType_remember(nt);
|
||||
delete nt;
|
||||
DelDataType(nt);
|
||||
key = Nextkey(h);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue