Numerous bug fixes. Improvements to C++
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@967 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
ce983e3203
commit
cc46b7bb77
17 changed files with 255 additions and 103 deletions
|
|
@ -321,6 +321,8 @@ yylex1(void) {
|
||||||
}
|
}
|
||||||
if ((l1 == STRING) || (l1 == CHARCONST)) {
|
if ((l1 == STRING) || (l1 == CHARCONST)) {
|
||||||
yylval.tok.text = NewString(yytext+1);
|
yylval.tok.text = NewString(yytext+1);
|
||||||
|
Setfile(yylval.tok.text,yylval.tok.filename);
|
||||||
|
Setline(yylval.tok.text,yylval.tok.line);
|
||||||
Delitem(yylval.tok.text,DOH_END);
|
Delitem(yylval.tok.text,DOH_END);
|
||||||
}
|
}
|
||||||
if ((l1 == HBLOCK) || (l1 == NUM_INT) || (l1 == NUM_FLOAT) || (l1 == NUM_UNSIGNED) || (l1 == NUM_LONG) || (l1 == NUM_ULONG)) {
|
if ((l1 == HBLOCK) || (l1 == NUM_INT) || (l1 == NUM_FLOAT) || (l1 == NUM_UNSIGNED) || (l1 == NUM_LONG) || (l1 == NUM_ULONG)) {
|
||||||
|
|
|
||||||
|
|
@ -149,23 +149,6 @@ static int pure_virtual = 0;
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Take a parameter list and produce a type object */
|
|
||||||
static DOH *parmstotype(DOH *parms) {
|
|
||||||
DOH *p, *r;
|
|
||||||
DOHList *ty;
|
|
||||||
|
|
||||||
ty = NewList();
|
|
||||||
p = parms;
|
|
||||||
while (p) {
|
|
||||||
Append(ty,Getattr(p,ATTR_TYPE));
|
|
||||||
p = Getattr(p,ATTR_NEXT);
|
|
||||||
}
|
|
||||||
r = NewString("");
|
|
||||||
SwigType_add_function(r,ty);
|
|
||||||
Delete(ty);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef NEED_ALLOC
|
#ifdef NEED_ALLOC
|
||||||
void *alloca(unsigned n) {
|
void *alloca(unsigned n) {
|
||||||
return((void *) malloc(n));
|
return((void *) malloc(n));
|
||||||
|
|
@ -428,8 +411,20 @@ scope_directive: SCOPE LBRACE interface RBRACE {
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
echo_directive: ECHO HBLOCK { Printf(stderr,"%s\n", $2.text); }
|
echo_directive: ECHO HBLOCK {
|
||||||
| ECHO STRING { Printf(stderr,"%s\n", $2.text); }
|
char line[32];
|
||||||
|
sprintf(line,"%d",Getline($2.text));
|
||||||
|
Replace($2.text,"$file",Getfile($2.text),DOH_REPLACE_ANY);
|
||||||
|
Replace($2.text,"$line",line, DOH_REPLACE_ANY);
|
||||||
|
Printf(stderr,"%s\n", $2.text);
|
||||||
|
}
|
||||||
|
| ECHO STRING {
|
||||||
|
char line[32];
|
||||||
|
sprintf(line,"%d",Getline($2.text));
|
||||||
|
Replace($2.text,"$file",Getfile($2.text),DOH_REPLACE_ANY);
|
||||||
|
Replace($2.text,"$line",line, DOH_REPLACE_ANY);
|
||||||
|
Printf(stderr,"%s\n", $2.text);
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
/* -- File inclusion directives -- */
|
/* -- File inclusion directives -- */
|
||||||
|
|
@ -1050,7 +1045,7 @@ typedef_decl : TYPEDEF type declaration array2 typedeflist SEMI {
|
||||||
|
|
||||||
| TYPEDEF type LPAREN stars pname RPAREN LPAREN parms RPAREN SEMI {
|
| TYPEDEF type LPAREN stars pname RPAREN LPAREN parms RPAREN SEMI {
|
||||||
$$ = new_node("c:typedef", $1.filename,$1.line);
|
$$ = new_node("c:typedef", $1.filename,$1.line);
|
||||||
SwigType_push($2,parmstotype($8));
|
SwigType_add_function($2,$8);
|
||||||
SwigType_push($2,$4);
|
SwigType_push($2,$4);
|
||||||
if ($5.array)
|
if ($5.array)
|
||||||
SwigType_push($2,$5.array);
|
SwigType_push($2,$5.array);
|
||||||
|
|
@ -1063,7 +1058,7 @@ typedef_decl : TYPEDEF type declaration array2 typedeflist SEMI {
|
||||||
| TYPEDEF type stars LPAREN stars pname RPAREN LPAREN parms RPAREN SEMI {
|
| TYPEDEF type stars LPAREN stars pname RPAREN LPAREN parms RPAREN SEMI {
|
||||||
$$ = new_node("c:typedef", $1.filename,$1.line);
|
$$ = new_node("c:typedef", $1.filename,$1.line);
|
||||||
SwigType_push($2,$3);
|
SwigType_push($2,$3);
|
||||||
SwigType_push($2,parmstotype($9));
|
SwigType_add_function($2,$9);
|
||||||
SwigType_push($2,$5);
|
SwigType_push($2,$5);
|
||||||
if ($6.array)
|
if ($6.array)
|
||||||
SwigType_push($2,$6.array);
|
SwigType_push($2,$6.array);
|
||||||
|
|
@ -1420,7 +1415,7 @@ parm : type pname {
|
||||||
}
|
}
|
||||||
| type LPAREN stars pname RPAREN LPAREN parms RPAREN {
|
| type LPAREN stars pname RPAREN LPAREN parms RPAREN {
|
||||||
$$ = new_node("parm",$2.filename, $2.line);
|
$$ = new_node("parm",$2.filename, $2.line);
|
||||||
SwigType_push($1,parmstotype($7));
|
SwigType_add_function($1,$7);
|
||||||
SwigType_push($1,$3);
|
SwigType_push($1,$3);
|
||||||
if ($4.array)
|
if ($4.array)
|
||||||
SwigType_push($1,$4.array);
|
SwigType_push($1,$4.array);
|
||||||
|
|
@ -1432,7 +1427,7 @@ parm : type pname {
|
||||||
| type stars LPAREN stars pname RPAREN LPAREN parms RPAREN {
|
| type stars LPAREN stars pname RPAREN LPAREN parms RPAREN {
|
||||||
$$ = new_node("parm",$3.filename, $3.line);
|
$$ = new_node("parm",$3.filename, $3.line);
|
||||||
SwigType_push($1,$2);
|
SwigType_push($1,$2);
|
||||||
SwigType_push($1,parmstotype($8));
|
SwigType_add_function($1,$8);
|
||||||
SwigType_push($1,$4);
|
SwigType_push($1,$4);
|
||||||
if ($5.array)
|
if ($5.array)
|
||||||
SwigType_push($1,$5.array);
|
SwigType_push($1,$5.array);
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,8 @@ static DOH *class_types = 0; /* Types defined within this class */
|
||||||
static String *construct_name = 0; /* Expected name of a constructor */
|
static String *construct_name = 0; /* Expected name of a constructor */
|
||||||
int AddMethods = 0; /* Set when in addmethods mode */
|
int AddMethods = 0; /* Set when in addmethods mode */
|
||||||
int Abstract = 0; /* Set when the class is determined to be abstract */
|
int Abstract = 0; /* Set when the class is determined to be abstract */
|
||||||
|
static int have_destructor = 0;
|
||||||
|
static int have_constructor = 0;
|
||||||
|
|
||||||
/* Check for abstract classes */
|
/* Check for abstract classes */
|
||||||
|
|
||||||
|
|
@ -162,10 +164,19 @@ void cplus_build_symbols(DOH *node) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Inherit certain types of declarations from another class */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Add a class type */
|
/* Add a class type */
|
||||||
static void
|
static void
|
||||||
class_addtype(String *name) {
|
class_addtype(String *name, String *cname) {
|
||||||
String *s = NewStringf("%s::%s", class_name, name);
|
String *s;
|
||||||
|
if (!cname)
|
||||||
|
s = NewStringf("%s::%s", class_name, name);
|
||||||
|
else
|
||||||
|
s = NewStringf("%s::%s", cname, name);
|
||||||
|
|
||||||
if (!class_types) class_types = NewHash();
|
if (!class_types) class_types = NewHash();
|
||||||
Setattr(class_types,name,s);
|
Setattr(class_types,name,s);
|
||||||
}
|
}
|
||||||
|
|
@ -174,6 +185,7 @@ class_addtype(String *name) {
|
||||||
static void
|
static void
|
||||||
class_update_type(String *type) {
|
class_update_type(String *type) {
|
||||||
String *base, *rep;
|
String *base, *rep;
|
||||||
|
if (!type) return;
|
||||||
base = SwigType_base(type);
|
base = SwigType_base(type);
|
||||||
if (!class_types) return;
|
if (!class_types) return;
|
||||||
rep = Getattr(class_types,base);
|
rep = Getattr(class_types,base);
|
||||||
|
|
@ -192,6 +204,54 @@ class_update_parms(ParmList *p) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Traverse the inheritance hierarchy of a class */
|
||||||
|
void
|
||||||
|
cplus_walk_inherit(DOH *cls, void (*action)(DOH *base, void *clientdata), void *clientdata) {
|
||||||
|
DOH *base;
|
||||||
|
List *bases;
|
||||||
|
int i, nbase;
|
||||||
|
|
||||||
|
bases = Getattr(cls,"bases");
|
||||||
|
if (bases) {
|
||||||
|
nbase = Len(bases);
|
||||||
|
for (i = 0; i < nbase; i++) {
|
||||||
|
base = Getattr(class_hash, Getitem(bases,i));
|
||||||
|
if (base) {
|
||||||
|
(*action)(base,clientdata);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Action for inheriting type definitions */
|
||||||
|
static void inherit_types(DOH *cls, void *clientdata) {
|
||||||
|
DOH *ty;
|
||||||
|
ty = Getattr(cls,"types");
|
||||||
|
if (ty) {
|
||||||
|
String *key;
|
||||||
|
SwigType_merge_scope(ty,0);
|
||||||
|
for (key = Firstkey(ty); key; key = Nextkey(ty)) {
|
||||||
|
class_addtype(key, Getname(cls));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cplus_walk_inherit(cls,inherit_types,clientdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Action for inheriting typemaps */
|
||||||
|
static void inherit_typemaps(DOH *cls, void *clientdata) {
|
||||||
|
DOH *ty;
|
||||||
|
|
||||||
|
cplus_walk_inherit(cls,inherit_typemaps,clientdata);
|
||||||
|
ty = Getattr(cls,"typemaps");
|
||||||
|
if (ty) {
|
||||||
|
if (!clientdata)
|
||||||
|
Swig_typemap_new_scope(ty);
|
||||||
|
else
|
||||||
|
Swig_typemap_pop_scope();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
int swig11_unknown(DOH *node, void *clientdata) {
|
int swig11_unknown(DOH *node, void *clientdata) {
|
||||||
Printf(stdout,"::: Unknown tag - '%s'\n", Getattr(node,"tag"));
|
Printf(stdout,"::: Unknown tag - '%s'\n", Getattr(node,"tag"));
|
||||||
|
|
@ -241,18 +301,28 @@ int swig11_file(DOH *node, void *clientdata) {
|
||||||
int swig11_scope(DOH *node, void *clientdata) {
|
int swig11_scope(DOH *node, void *clientdata) {
|
||||||
DOH *c;
|
DOH *c;
|
||||||
String *name;
|
String *name;
|
||||||
int oldnative = Native;
|
|
||||||
c = Getchild(node);
|
c = Getchild(node);
|
||||||
name = Getname(node);
|
name = Getname(node);
|
||||||
if (name && (Cmp(name,"native") == 0)) {
|
|
||||||
Native = 1;
|
Swig_typemap_new_scope(0);
|
||||||
Swig_emit_all(c,clientdata);
|
if (name) {
|
||||||
Native = oldnative;
|
if (Cmp(name,"native") == 0) {
|
||||||
return 0;
|
int oldnative = Native;
|
||||||
|
Native = 1;
|
||||||
|
Swig_emit_all(c,clientdata);
|
||||||
|
Native = oldnative;
|
||||||
|
} else if (Cmp(name,"readonly") == 0) {
|
||||||
|
int oldro = ReadOnly;
|
||||||
|
ReadOnly = 1;
|
||||||
|
Swig_emit_all(c,clientdata);
|
||||||
|
ReadOnly = oldro;
|
||||||
|
} else {
|
||||||
|
Swig_emit_all(c,clientdata);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Swig_typemap_new_scope();
|
Hash *scp = Swig_typemap_pop_scope();
|
||||||
Swig_emit_all(c,clientdata);
|
Setattr(node,"typemaps", scp);
|
||||||
Swig_typemap_pop_scope();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -309,10 +379,6 @@ int swig11_pragma(DOH *node, void *clientdata) {
|
||||||
name = Getname(node);
|
name = Getname(node);
|
||||||
value = Getvalue(node);
|
value = Getvalue(node);
|
||||||
|
|
||||||
Printf(stdout,"::: Pragma\n");
|
|
||||||
Printf(stdout," name = '%s'\n", name);
|
|
||||||
Printf(stdout," value = '%s'\n", value);
|
|
||||||
|
|
||||||
if (Cmp(name,"readonly") == 0) {
|
if (Cmp(name,"readonly") == 0) {
|
||||||
ReadOnly = 1;
|
ReadOnly = 1;
|
||||||
} else if (Cmp(name,"readwrite") == 0) {
|
} else if (Cmp(name,"readwrite") == 0) {
|
||||||
|
|
@ -344,6 +410,11 @@ int swig11_typemap(DOH *node, void *clientdata) {
|
||||||
code = Getattr(node,"code");
|
code = Getattr(node,"code");
|
||||||
parms = Getparms(node);
|
parms = Getparms(node);
|
||||||
|
|
||||||
|
if (current_class) {
|
||||||
|
class_update_type(type);
|
||||||
|
class_update_type(parms);
|
||||||
|
}
|
||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
Swig_typemap_register(method,type,name,code,parms);
|
Swig_typemap_register(method,type,name,code,parms);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -451,10 +522,13 @@ int swig11_function(DOH *node, void *clientdata) {
|
||||||
if (current_class) {
|
if (current_class) {
|
||||||
/* Function has been declared inside a class definition. */
|
/* Function has been declared inside a class definition. */
|
||||||
class_update_parms(Getparms(node));
|
class_update_parms(Getparms(node));
|
||||||
|
class_update_type(Gettype(node));
|
||||||
String *name = Getname(node);
|
String *name = Getname(node);
|
||||||
if (Cmp(name,construct_name) == 0) {
|
if (Cmp(name,construct_name) == 0) {
|
||||||
if (!Abstract)
|
have_constructor =1;
|
||||||
|
if (!Abstract) {
|
||||||
lang->cpp_constructor(node);
|
lang->cpp_constructor(node);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (is_static) lang->cpp_staticfunction(node);
|
if (is_static) lang->cpp_staticfunction(node);
|
||||||
else lang->cpp_memberfunction(node);
|
else lang->cpp_memberfunction(node);
|
||||||
|
|
@ -533,8 +607,10 @@ int swig11_typedef(DOH *node, void *clientdata) {
|
||||||
name = Getname(node);
|
name = Getname(node);
|
||||||
SwigType_typedef(type,name);
|
SwigType_typedef(type,name);
|
||||||
|
|
||||||
|
if (current_class) {
|
||||||
|
class_addtype(name,0);
|
||||||
|
}
|
||||||
lang->add_typedef(type, Char(name));
|
lang->add_typedef(type, Char(name));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -555,7 +631,7 @@ int swig11_enum(DOH *node, void *clientdata) {
|
||||||
/* Add a typedef */
|
/* Add a typedef */
|
||||||
String *t = NewStringf("enum %s", name);
|
String *t = NewStringf("enum %s", name);
|
||||||
SwigType_typedef(t,name);
|
SwigType_typedef(t,name);
|
||||||
class_addtype(name);
|
class_addtype(name,0);
|
||||||
Delete(t);
|
Delete(t);
|
||||||
}
|
}
|
||||||
c = Getchild(node);
|
c = Getchild(node);
|
||||||
|
|
@ -594,6 +670,7 @@ int swig11_enumvalue(DOH *node, void *clientdata) {
|
||||||
|
|
||||||
int swig11_class(DOH *node, void *clientdata) {
|
int swig11_class(DOH *node, void *clientdata) {
|
||||||
DOH *c;
|
DOH *c;
|
||||||
|
List *bases;
|
||||||
|
|
||||||
/* Save the class */
|
/* Save the class */
|
||||||
String *name = Getname(node);
|
String *name = Getname(node);
|
||||||
|
|
@ -607,14 +684,27 @@ int swig11_class(DOH *node, void *clientdata) {
|
||||||
|
|
||||||
set_scriptname(node);
|
set_scriptname(node);
|
||||||
class_name = name;
|
class_name = name;
|
||||||
|
class_types = 0;
|
||||||
|
|
||||||
/* Create a new type scope for this class */
|
have_destructor = 0;
|
||||||
|
have_constructor = 0;
|
||||||
SwigType_new_scope();
|
|
||||||
|
/* Need to merge in data from other scopes. For typemaps, can include scopes
|
||||||
|
for each base class one after the other. For types, need to merge type information */
|
||||||
|
|
||||||
|
SwigType_new_scope();
|
||||||
if (name) {
|
if (name) {
|
||||||
SwigType_set_scope_name(name);
|
SwigType_set_scope_name(name);
|
||||||
}
|
}
|
||||||
class_types = 0;
|
|
||||||
|
cplus_walk_inherit(node, inherit_types, 0);
|
||||||
|
|
||||||
|
/* Merge in typemaps */
|
||||||
|
cplus_walk_inherit(node, inherit_typemaps, 0);
|
||||||
|
|
||||||
|
/* Create a typemap scope for this class */
|
||||||
|
Swig_typemap_new_scope(0);
|
||||||
|
|
||||||
cplus_build_symbols(node);
|
cplus_build_symbols(node);
|
||||||
lang->cpp_open_class(node);
|
lang->cpp_open_class(node);
|
||||||
current_class = node;
|
current_class = node;
|
||||||
|
|
@ -629,18 +719,49 @@ int swig11_class(DOH *node, void *clientdata) {
|
||||||
Abstract = cplus_check_abstract(c);
|
Abstract = cplus_check_abstract(c);
|
||||||
|
|
||||||
Swig_emit_all(c,clientdata);
|
Swig_emit_all(c,clientdata);
|
||||||
|
|
||||||
List *bases = Getattr(node,"bases");
|
bases = Getattr(node,"bases");
|
||||||
if (bases) {
|
if (bases) {
|
||||||
lang->cpp_inherit(bases,INHERIT_ALL);
|
String *b;
|
||||||
|
lang->cpp_inherit(bases);
|
||||||
|
b = Firstitem(bases);
|
||||||
|
while (b) {
|
||||||
|
SwigType_inherit(Getname(current_class),b);
|
||||||
|
b = Nextitem(bases);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check for constructors and destructors */
|
||||||
|
|
||||||
|
if (CPlusPlus) {
|
||||||
|
if (!have_constructor && !Abstract) {
|
||||||
|
DOH *cn = NewHash();
|
||||||
|
Setname(cn, Getname(current_class));
|
||||||
|
Setattr(cn,"scriptname", Getname(current_class));
|
||||||
|
lang->cpp_constructor(cn);
|
||||||
|
}
|
||||||
|
if (!have_destructor) {
|
||||||
|
DOH *dn = NewHash();
|
||||||
|
Setname(dn, Getname(current_class));
|
||||||
|
Setattr(dn,"scriptname", Getname(current_class));
|
||||||
|
lang->cpp_destructor(dn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lang->cpp_close_class();
|
lang->cpp_close_class();
|
||||||
|
|
||||||
/* Pop the type scope and save with the class */
|
/* Pop the type scope and save with the class */
|
||||||
Hash *scp = SwigType_pop_scope();
|
|
||||||
Setattr(node,"typescope",scp);
|
|
||||||
|
|
||||||
Setattr(node,"types",class_types);
|
Hash *scp = SwigType_pop_scope();
|
||||||
|
Setattr(node,"types",scp);
|
||||||
|
|
||||||
|
scp = Swig_typemap_pop_scope();
|
||||||
|
Setattr(node,"typemaps",scp);
|
||||||
|
Setattr(node,"classtypes",class_types);
|
||||||
|
|
||||||
|
/* Pop off all of the typemap scopes we added */
|
||||||
|
cplus_walk_inherit(node,inherit_typemaps, (void *) 1);
|
||||||
|
|
||||||
current_class = 0;
|
current_class = 0;
|
||||||
construct_name = 0;
|
construct_name = 0;
|
||||||
class_name = 0;
|
class_name = 0;
|
||||||
|
|
@ -689,6 +810,7 @@ int swig11_destructor(DOH *node, void *clientdata) {
|
||||||
|
|
||||||
set_scriptname(node);
|
set_scriptname(node);
|
||||||
lang->cpp_destructor(node);
|
lang->cpp_destructor(node);
|
||||||
|
have_destructor = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -780,7 +902,8 @@ void generate(DOH *node) {
|
||||||
Swig_emit_all(c,0);
|
Swig_emit_all(c,0);
|
||||||
lang->close();
|
lang->close();
|
||||||
|
|
||||||
Swig_dump_tags(node,0);
|
/* Swig_dump_tags(node,0); */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -242,7 +242,7 @@ void Language::cpp_destructor(DOH *node) {
|
||||||
* Language::cpp_inherit()
|
* Language::cpp_inherit()
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Language::cpp_inherit(List *bases, int mode) {
|
void Language::cpp_inherit(List *bases) {
|
||||||
|
|
||||||
if (!bases) return;
|
if (!bases) return;
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -1811,7 +1811,7 @@ PERL5::cpp_staticfunction(DOH *node) {
|
||||||
* PERL5::cpp_inherit()
|
* PERL5::cpp_inherit()
|
||||||
* ------------------------------------------------------------------------------ */
|
* ------------------------------------------------------------------------------ */
|
||||||
void
|
void
|
||||||
PERL5::cpp_inherit(List *bases, int) {
|
PERL5::cpp_inherit(List *bases) {
|
||||||
String *base;
|
String *base;
|
||||||
char *bc;
|
char *bc;
|
||||||
int have_first = 0;
|
int have_first = 0;
|
||||||
|
|
@ -1823,7 +1823,7 @@ PERL5::cpp_inherit(List *bases, int) {
|
||||||
/* Inherit variables and constants from base classes, but not
|
/* Inherit variables and constants from base classes, but not
|
||||||
functions (since Perl can handle that okay). */
|
functions (since Perl can handle that okay). */
|
||||||
|
|
||||||
this->Language::cpp_inherit(bases, INHERIT_CONST | INHERIT_VAR);
|
this->Language::cpp_inherit(bases);
|
||||||
|
|
||||||
/* Now tell the Perl5 module that we're inheriting from base classes */
|
/* Now tell the Perl5 module that we're inheriting from base classes */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ public :
|
||||||
virtual void cpp_variable(DOH *);
|
virtual void cpp_variable(DOH *);
|
||||||
virtual void cpp_constructor(DOH *);
|
virtual void cpp_constructor(DOH *);
|
||||||
virtual void cpp_destructor(DOH *);
|
virtual void cpp_destructor(DOH *);
|
||||||
virtual void cpp_inherit(List *bases, int mode = INHERIT_ALL);
|
virtual void cpp_inherit(List *bases);
|
||||||
virtual void cpp_constant(DOH *);
|
virtual void cpp_constant(DOH *);
|
||||||
virtual void cpp_class_decl(DOH *);
|
virtual void cpp_class_decl(DOH *);
|
||||||
virtual void add_typedef(SwigType *t, String *name);
|
virtual void add_typedef(SwigType *t, String *name);
|
||||||
|
|
|
||||||
|
|
@ -1443,7 +1443,7 @@ PYTHON::cpp_close_class() {
|
||||||
* PYTHON::cpp_inherit() - Handle inheritance
|
* PYTHON::cpp_inherit() - Handle inheritance
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
void
|
void
|
||||||
PYTHON::cpp_inherit(List *bases,int) {
|
PYTHON::cpp_inherit(List *bases) {
|
||||||
char *bc;
|
char *bc;
|
||||||
String *base;
|
String *base;
|
||||||
int first_base = 0;
|
int first_base = 0;
|
||||||
|
|
@ -1454,7 +1454,7 @@ PYTHON::cpp_inherit(List *bases,int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We'll inherit variables and constants, but not methods */
|
/* We'll inherit variables and constants, but not methods */
|
||||||
this->Language::cpp_inherit(bases, INHERIT_VAR);
|
this->Language::cpp_inherit(bases);
|
||||||
|
|
||||||
if (!bases) return;
|
if (!bases) return;
|
||||||
base_class = NewString("");
|
base_class = NewString("");
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ public :
|
||||||
virtual void initialize(String *);
|
virtual void initialize(String *);
|
||||||
virtual void function(DOH *node);
|
virtual void function(DOH *node);
|
||||||
virtual void variable(DOH *node);
|
virtual void variable(DOH *node);
|
||||||
virtual void constant(DOH *node);
|
virtual void constant(DOH *node);
|
||||||
virtual void nativefunction(DOH *);
|
virtual void nativefunction(DOH *);
|
||||||
virtual void close(void);
|
virtual void close(void);
|
||||||
virtual void create_command(String *, String *);
|
virtual void create_command(String *, String *);
|
||||||
|
|
@ -47,7 +47,7 @@ public :
|
||||||
virtual void cpp_destructor(DOH *);
|
virtual void cpp_destructor(DOH *);
|
||||||
virtual void cpp_open_class(DOH *);
|
virtual void cpp_open_class(DOH *);
|
||||||
virtual void cpp_close_class();
|
virtual void cpp_close_class();
|
||||||
virtual void cpp_inherit(List *bases, int mode = INHERIT_ALL);
|
virtual void cpp_inherit(List *bases);
|
||||||
virtual void cpp_variable(DOH *);
|
virtual void cpp_variable(DOH *);
|
||||||
virtual void cpp_constant(DOH *);
|
virtual void cpp_constant(DOH *);
|
||||||
virtual void cpp_class_decl(DOH *);
|
virtual void cpp_class_decl(DOH *);
|
||||||
|
|
|
||||||
|
|
@ -1220,7 +1220,7 @@ void RUBY::cpp_close_class() {
|
||||||
* --------------------------------------------------------------------- */
|
* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
void RUBY::cpp_inherit(List *bases, int mode) {
|
void RUBY::cpp_inherit(List *bases) {
|
||||||
if (!bases) return;
|
if (!bases) return;
|
||||||
String *base;
|
String *base;
|
||||||
for (base = Firstitem(bases); base; base = Nextitem(bases)) {
|
for (base = Firstitem(bases); base; base = Nextitem(bases)) {
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ class RUBY : public Language {
|
||||||
virtual void cpp_destructor(DOH *);
|
virtual void cpp_destructor(DOH *);
|
||||||
virtual void cpp_open_class(DOH *);
|
virtual void cpp_open_class(DOH *);
|
||||||
virtual void cpp_close_class();
|
virtual void cpp_close_class();
|
||||||
virtual void cpp_inherit(List *bases, int mode = INHERIT_ALL);
|
virtual void cpp_inherit(List *bases);
|
||||||
virtual void cpp_variable(DOH *);
|
virtual void cpp_variable(DOH *);
|
||||||
virtual void cpp_staticfunction(DOH *);
|
virtual void cpp_staticfunction(DOH *);
|
||||||
virtual void cpp_constant(DOH *);
|
virtual void cpp_constant(DOH *);
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ public:
|
||||||
virtual void cpp_close_class();
|
virtual void cpp_close_class();
|
||||||
|
|
||||||
virtual void cpp_class_decl(DOH *node);
|
virtual void cpp_class_decl(DOH *node);
|
||||||
virtual void cpp_inherit(List *bases, int mode = INHERIT_ALL);
|
virtual void cpp_inherit(List *bases);
|
||||||
|
|
||||||
/* Miscellaneous features */
|
/* Miscellaneous features */
|
||||||
|
|
||||||
|
|
@ -106,6 +106,7 @@ extern void SWIG_config_file(const String_or_char *);
|
||||||
|
|
||||||
/* C++ utility functions */
|
/* C++ utility functions */
|
||||||
extern int cplus_check_abstract(DOH *node);
|
extern int cplus_check_abstract(DOH *node);
|
||||||
|
extern void cplus_walk_inherit(DOH *cls, void (*action)(DOH *base, void *clientdata), void *clientdata);
|
||||||
|
|
||||||
extern Language *lang;
|
extern Language *lang;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,8 @@ static int have_destructor;
|
||||||
static String *class_name = 0;
|
static String *class_name = 0;
|
||||||
static String *class_type = 0;
|
static String *class_type = 0;
|
||||||
static String *real_classname = 0;
|
static String *real_classname = 0;
|
||||||
|
static Hash *class_methods = 0;
|
||||||
|
static Hash *class_attributes = 0;
|
||||||
static Hash *repeatcmd = 0;
|
static Hash *repeatcmd = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -97,9 +99,9 @@ TCL8::initialize(String *modname) {
|
||||||
mod_init = NewString("");
|
mod_init = NewString("");
|
||||||
cmd_info = NewString("");
|
cmd_info = NewString("");
|
||||||
var_info = NewString("");
|
var_info = NewString("");
|
||||||
methods = NewString("");
|
|
||||||
attributes = NewString("");
|
|
||||||
repeatcmd = NewHash();
|
repeatcmd = NewHash();
|
||||||
|
class_methods = NewHash();
|
||||||
|
class_attributes = NewHash();
|
||||||
|
|
||||||
Swig_banner(f_runtime);
|
Swig_banner(f_runtime);
|
||||||
|
|
||||||
|
|
@ -962,13 +964,13 @@ TCL8::cpp_open_class(DOH *node) {
|
||||||
included_object = 1;
|
included_object = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Clear(attributes);
|
attributes = NewString("");
|
||||||
Printf(attributes, "static swig_attribute swig_");
|
/* Printf(attributes, "static swig_attribute swig_");
|
||||||
Printv(attributes, classname, "_attributes[] = {\n", 0);
|
Printv(attributes, classname, "_attributes[] = {\n", 0); */
|
||||||
|
|
||||||
Clear(methods);
|
methods = NewString("");
|
||||||
Printf(methods,"static swig_method swig_");
|
/* Printf(methods,"static swig_method swig_");
|
||||||
Printv(methods, classname, "_methods[] = {\n", 0);
|
Printv(methods, classname, "_methods[] = {\n", 0); */
|
||||||
|
|
||||||
have_constructor = 0;
|
have_constructor = 0;
|
||||||
have_destructor = 0;
|
have_destructor = 0;
|
||||||
|
|
@ -1003,12 +1005,18 @@ TCL8::cpp_close_class() {
|
||||||
Printf(code,"}\n");
|
Printf(code,"}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
Printf(methods, " {0,0}\n};\n");
|
Printf(code,"static swig_method swig_");
|
||||||
|
Printv(code, real_classname, "_methods[] = {\n", 0);
|
||||||
Printv(code,methods,0);
|
Printv(code,methods,0);
|
||||||
|
Printf(code, " {0,0}\n};\n");
|
||||||
|
Setattr(class_methods,real_classname,methods);
|
||||||
|
|
||||||
Printf(attributes, " {0,0,0}\n};\n");
|
Printf(code, "static swig_attribute swig_");
|
||||||
|
Printv(code, real_classname, "_attributes[] = {\n", 0);
|
||||||
Printv(code,attributes,0);
|
Printv(code,attributes,0);
|
||||||
|
Printf(code, " {0,0,0}\n};\n");
|
||||||
|
Setattr(class_attributes,real_classname,attributes);
|
||||||
|
|
||||||
Printv(code, "static swig_class _wrap_class_", class_name, " = { \"", class_name,
|
Printv(code, "static swig_class _wrap_class_", class_name, " = { \"", class_name,
|
||||||
"\", &SWIGTYPE", SwigType_manglestr(t), ",",0);
|
"\", &SWIGTYPE", SwigType_manglestr(t), ",",0);
|
||||||
|
|
||||||
|
|
@ -1093,3 +1101,20 @@ TCL8::cpp_destructor(DOH *node) {
|
||||||
this->Language::cpp_destructor(node);
|
this->Language::cpp_destructor(node);
|
||||||
have_destructor = 1;
|
have_destructor = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TCL8::cpp_inherit(List *bases) {
|
||||||
|
String *b;
|
||||||
|
Printf(stdout,"bases = %s\n", bases);
|
||||||
|
for (b = Firstitem(bases); b; b = Nextitem(bases)) {
|
||||||
|
Printf(stdout,"base: %s\n", b);
|
||||||
|
String *s = Getattr(class_methods,b);
|
||||||
|
if (s) {
|
||||||
|
Append(methods,s);
|
||||||
|
}
|
||||||
|
s = Getattr(class_attributes,b);
|
||||||
|
if (s) {
|
||||||
|
Append(attributes,s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,8 @@ public :
|
||||||
virtual void cpp_variable(DOH *);
|
virtual void cpp_variable(DOH *);
|
||||||
virtual void cpp_constructor(DOH *);
|
virtual void cpp_constructor(DOH *);
|
||||||
virtual void cpp_destructor(DOH *);
|
virtual void cpp_destructor(DOH *);
|
||||||
|
virtual void cpp_inherit(List *bases);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -171,23 +171,16 @@ Swig_proto_cmp(const String_or_char *pat, DOH *node) {
|
||||||
SwigType *ty;
|
SwigType *ty;
|
||||||
SwigType *ct;
|
SwigType *ct;
|
||||||
ParmList *p;
|
ParmList *p;
|
||||||
List *tl;
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
ty = Gettype(node);
|
ty = Gettype(node);
|
||||||
p = Getparms(node);
|
p = Getparms(node);
|
||||||
if (!ty || !p) return -1;
|
if (!ty || !p) return -1;
|
||||||
ct = Copy(ty);
|
ct = Copy(ty);
|
||||||
tl = NewList();
|
SwigType_add_function(ct,p);
|
||||||
while (p) {
|
|
||||||
Append(tl,Gettype(p));
|
|
||||||
p = Getnext(p);
|
|
||||||
}
|
|
||||||
SwigType_add_function(ct,tl);
|
|
||||||
SwigType_strip_qualifiers(ct);
|
SwigType_strip_qualifiers(ct);
|
||||||
r = Cmp(pat,ct);
|
r = Cmp(pat,ct);
|
||||||
Delete(ct);
|
Delete(ct);
|
||||||
Delete(tl);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -199,16 +199,16 @@ SwigType_add_qualifier(SwigType *t, String *qual) {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void
|
||||||
SwigType_add_function(SwigType *t, List *parms) {
|
SwigType_add_function(SwigType *t, ParmList *parms) {
|
||||||
String *pstr;
|
String *pstr;
|
||||||
int i,l;
|
|
||||||
|
|
||||||
Insert(t,0,").");
|
Insert(t,0,").");
|
||||||
pstr = NewString("f(");
|
pstr = NewString("f(");
|
||||||
l = Len(parms);
|
|
||||||
for (i = 0; i < l; i++) {
|
while (parms) {
|
||||||
Printf(pstr,"%s",Getitem(parms,i));
|
Printf(pstr,"%s",Gettype(parms));
|
||||||
if (i < (l-1))
|
parms = Getnext(parms);
|
||||||
|
if (parms)
|
||||||
Putc(',',pstr);
|
Putc(',',pstr);
|
||||||
}
|
}
|
||||||
Insert(t,0,pstr);
|
Insert(t,0,pstr);
|
||||||
|
|
@ -1107,7 +1107,7 @@ int SwigType_typedef(SwigType *type, String_or_char *name) {
|
||||||
qname = NewString(name);
|
qname = NewString(name);
|
||||||
while (i >= 0) {
|
while (i >= 0) {
|
||||||
String *sname;
|
String *sname;
|
||||||
Printf(stdout,"Adding typedef [%d] : '%s' -> '%s'\n", i, qname, type);
|
/* Printf(stdout,"Adding typedef [%d] : '%s' -> '%s'\n", i, qname, type); */
|
||||||
Setattr(scopes[i],qname,type);
|
Setattr(scopes[i],qname,type);
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
sname = scopenames[i];
|
sname = scopenames[i];
|
||||||
|
|
@ -1177,7 +1177,7 @@ void SwigType_set_scope_name(String_or_char *name) {
|
||||||
* Merges the contents of one scope into the current scope.
|
* Merges the contents of one scope into the current scope.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void SwigType_merge_scope(Hash *scope, String_or_char *prefix) {
|
void SwigType_merge_scope(Hash *scope, String *prefix) {
|
||||||
String *name;
|
String *name;
|
||||||
String *key;
|
String *key;
|
||||||
String *type;
|
String *type;
|
||||||
|
|
@ -1191,7 +1191,7 @@ void SwigType_merge_scope(Hash *scope, String_or_char *prefix) {
|
||||||
} else {
|
} else {
|
||||||
name = NewString(key);
|
name = NewString(key);
|
||||||
}
|
}
|
||||||
Setattr(scopes[scope_level],name,type);
|
SwigType_typedef(type,name);
|
||||||
key = Nextkey(scope);
|
key = Nextkey(scope);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1209,9 +1209,9 @@ Hash *SwigType_pop_scope() {
|
||||||
if (scope_level == 0) return 0;
|
if (scope_level == 0) return 0;
|
||||||
prefix = scopenames[scope_level];
|
prefix = scopenames[scope_level];
|
||||||
s = scopes[scope_level--];
|
s = scopes[scope_level--];
|
||||||
/* SwigType_merge_scope(s,prefix); */
|
if (Len(s)) return s;
|
||||||
/* Printf(stdout,"****\n%s\n", scopes[scope_level]); */
|
Delete(s);
|
||||||
return s;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@ typedef DOH Hash;
|
||||||
typedef DOH List;
|
typedef DOH List;
|
||||||
typedef DOH String_or_char;
|
typedef DOH String_or_char;
|
||||||
typedef DOH File;
|
typedef DOH File;
|
||||||
|
typedef DOH Parm;
|
||||||
|
typedef DOH ParmList;
|
||||||
|
typedef DOH Node;
|
||||||
|
|
||||||
/* --- Legacy DataType interface. These type codes are provided solely
|
/* --- Legacy DataType interface. These type codes are provided solely
|
||||||
for backwards compatibility with older modules --- */
|
for backwards compatibility with older modules --- */
|
||||||
|
|
@ -167,7 +170,7 @@ extern void SwigType_del_pointer(SwigType *t);
|
||||||
extern void SwigType_add_array(SwigType *t, String_or_char *size);
|
extern void SwigType_add_array(SwigType *t, String_or_char *size);
|
||||||
extern void SwigType_add_reference(SwigType *t);
|
extern void SwigType_add_reference(SwigType *t);
|
||||||
extern void SwigType_add_qualifier(SwigType *t, String_or_char *qual);
|
extern void SwigType_add_qualifier(SwigType *t, String_or_char *qual);
|
||||||
extern void SwigType_add_function(SwigType *t, List *parms);
|
extern void SwigType_add_function(SwigType *t, ParmList *parms);
|
||||||
extern List *SwigType_split(SwigType *t);
|
extern List *SwigType_split(SwigType *t);
|
||||||
extern String *SwigType_pop(SwigType *t);
|
extern String *SwigType_pop(SwigType *t);
|
||||||
extern void SwigType_push(SwigType *t, SwigType *s);
|
extern void SwigType_push(SwigType *t, SwigType *s);
|
||||||
|
|
@ -195,7 +198,7 @@ extern void SwigType_inherit(String *subclass, String *baseclass);
|
||||||
extern void SwigType_new_scope();
|
extern void SwigType_new_scope();
|
||||||
extern void SwigType_reset_scopes();
|
extern void SwigType_reset_scopes();
|
||||||
extern void SwigType_set_scope_name(String_or_char *name);
|
extern void SwigType_set_scope_name(String_or_char *name);
|
||||||
extern void SwigType_merge_scope(Hash *scope, String_or_char *prefix);
|
extern void SwigType_merge_scope(Hash *scope, String *prefix);
|
||||||
extern Hash *SwigType_pop_scope();
|
extern Hash *SwigType_pop_scope();
|
||||||
extern SwigType *SwigType_typedef_resolve(SwigType *t);
|
extern SwigType *SwigType_typedef_resolve(SwigType *t);
|
||||||
extern SwigType *SwigType_typedef_resolve_all(SwigType *t);
|
extern SwigType *SwigType_typedef_resolve_all(SwigType *t);
|
||||||
|
|
@ -215,12 +218,10 @@ extern void SwigType_strip_qualifiers(SwigType *t);
|
||||||
/* Parameters are really just hidden behind a DOH object. The following
|
/* Parameters are really just hidden behind a DOH object. The following
|
||||||
interface will probably be simplified even further. */
|
interface will probably be simplified even further. */
|
||||||
|
|
||||||
typedef DOH Parm;
|
|
||||||
|
|
||||||
extern Parm *NewParm(SwigType *type, String_or_char *n);
|
extern Parm *NewParm(SwigType *type, String_or_char *n);
|
||||||
extern Parm *CopyParm(Parm *p);
|
extern Parm *CopyParm(Parm *p);
|
||||||
|
|
||||||
typedef DOH ParmList;
|
|
||||||
|
|
||||||
extern ParmList *CopyParmList(ParmList *);
|
extern ParmList *CopyParmList(ParmList *);
|
||||||
extern int ParmList_len(ParmList *);
|
extern int ParmList_len(ParmList *);
|
||||||
|
|
@ -391,7 +392,7 @@ extern void Swig_typemap_clear_apply(SwigType *type, String_or_char *pname);
|
||||||
extern void Swig_typemap_debug();
|
extern void Swig_typemap_debug();
|
||||||
extern Hash *Swig_typemap_search(const String_or_char *op, SwigType *type, String_or_char *pname);
|
extern Hash *Swig_typemap_search(const String_or_char *op, SwigType *type, String_or_char *pname);
|
||||||
extern char *Swig_typemap_lookup(const String_or_char *op, SwigType *type, String_or_char *pname, String_or_char *source, String_or_char *target, Wrapper *f);
|
extern char *Swig_typemap_lookup(const String_or_char *op, SwigType *type, String_or_char *pname, String_or_char *source, String_or_char *target, Wrapper *f);
|
||||||
extern void Swig_typemap_new_scope();
|
extern void Swig_typemap_new_scope(Hash *);
|
||||||
extern Hash *Swig_typemap_pop_scope();
|
extern Hash *Swig_typemap_pop_scope();
|
||||||
|
|
||||||
/* --- Legacy %except directive API --- */
|
/* --- Legacy %except directive API --- */
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,14 @@ static char *parm_key(String_or_char *pname) {
|
||||||
* Create a new typemap scope
|
* Create a new typemap scope
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Swig_typemap_new_scope() {
|
void Swig_typemap_new_scope(Hash *oldscope) {
|
||||||
tm_scope++;
|
tm_scope++;
|
||||||
typemaps[tm_scope] = NewHash();
|
if (!oldscope) {
|
||||||
|
typemaps[tm_scope] = NewHash();
|
||||||
|
} else {
|
||||||
|
typemaps[tm_scope] = oldscope;
|
||||||
|
DohIncref(oldscope);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -59,7 +64,12 @@ void Swig_typemap_new_scope() {
|
||||||
Hash *
|
Hash *
|
||||||
Swig_typemap_pop_scope() {
|
Swig_typemap_pop_scope() {
|
||||||
if (tm_scope > 0) {
|
if (tm_scope > 0) {
|
||||||
return Swig_temp_result(typemaps[tm_scope--]);
|
if (Len(typemaps[tm_scope])) {
|
||||||
|
return typemaps[tm_scope--];
|
||||||
|
} else {
|
||||||
|
Delete(typemaps[tm_scope--]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue