several fixes, see CHANGES.current 10/04/2004

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6317 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2004-10-05 00:19:26 +00:00
commit 2792ac8752
17 changed files with 216 additions and 97 deletions

View file

@ -43,6 +43,7 @@ extern int yylex();
/* parser.y */
extern SwigType *Swig_cparse_type(String *);
extern Node *Swig_cparse(File *);
extern Hash *Swig_cparse_features();
/* util.c */
extern void Swig_cparse_replace_descriptor(String *s);

View file

@ -171,6 +171,11 @@ static Hash *rename_hash = 0;
static Hash *namewarn_hash = 0;
static Hash *features_hash = 0;
Hash *Swig_cparse_features() {
if (!features_hash) features_hash = NewHash();
return features_hash;
}
static String *feature_identifier_fix(String *s) {
if (SwigType_istemplate(s)) {
String *tp, *ts, *ta, *tq;
@ -4620,6 +4625,7 @@ exprcompound : expr PLUS expr {
}
| type LPAREN {
skip_balanced('(',')');
$1 = Swig_symbol_type_qualify($1,0);
if (SwigType_istemplate($1)) {
$1 = SwigType_namestr($1);
}

View file

@ -21,6 +21,7 @@ static void add_parms(ParmList *p, List *patchlist, List *typelist) {
SwigType *ty = Getattr(p,"type");
SwigType *val = Getattr(p,"value");
Append(typelist,ty);
Append(typelist,val);
Append(patchlist,val);
p = nextSibling(p);
}

View file

@ -1853,6 +1853,51 @@ int Language::classDeclaration(Node *n) {
/* ----------------------------------------------------------------------
* Language::classHandler()
* ---------------------------------------------------------------------- */
static Node *makeConstructor(Node *n)
{
Node *cn = Copy(n);
String *name = Getattr(n,"name");
String *rname = 0;
String *dname = NewStringf("%s::",name);
if (SwigType_istemplate(name)) {
rname = SwigType_templateprefix(name);
name = rname;
}
String *lname = Swig_scopename_last(name);
Append(dname,lname);
Setattr(cn,"feature:new","1");
Setattr(cn,"decl","f().");
Swig_features_get(Swig_cparse_features(), 0, dname, Getattr(cn,"decl"), cn);
Delete(rname);
Delete(dname);
Delete(lname);
return cn;
}
static Node *makeDestructor(Node *n)
{
Node *cn = Copy(n);
String *name = Getattr(n,"name");
String *rname = 0;
String *dname = NewStringf("%s::~",name);
if (SwigType_istemplate(name)) {
rname = SwigType_templateprefix(name);
name = rname;
}
String *lname = Swig_scopename_last(name);
Append(dname,lname);
Setattr(cn,"decl","f().");
Swig_features_get(Swig_cparse_features(), 0, dname, Getattr(cn,"decl"), cn);
Delete(rname);
Delete(dname);
Delete(lname);
return cn;
}
int Language::classHandler(Node *n) {
@ -1879,13 +1924,15 @@ int Language::classHandler(Node *n) {
if (!Getattr(n,"has_constructor") && !Getattr(n,"allocate:has_constructor") && (Getattr(n,"allocate:default_constructor"))) {
/* Note: will need to change this to support different kinds of classes */
if (!Abstract || hasDirector) {
Setattr(CurrentClass,"feature:new","1");
constructorHandler(CurrentClass);
Delattr(CurrentClass,"feature:new");
Node *cn = makeConstructor(CurrentClass);
constructorHandler(cn);
Delete(cn);
}
}
if (!Getattr(n,"has_destructor") && (!Getattr(n,"allocate:has_destructor")) && (Getattr(n,"allocate:default_destructor"))) {
destructorHandler(CurrentClass);
Node *cn = makeDestructor(CurrentClass);
destructorHandler(cn);
Delete(cn);
}
}

View file

@ -162,10 +162,12 @@ int Swig_cargs(Wrapper *w, ParmList *p) {
tycode = SwigType_type(type);
if (tycode == T_REFERENCE) {
if (pvalue) {
String *defname, *defvalue;
String *defname, *defvalue, *rvalue;
rvalue = SwigType_typedef_resolve_all(pvalue);
defname = NewStringf("%s_defvalue", lname);
defvalue = NewStringf("%s = %s", SwigType_str(type,defname), pvalue);
defvalue = NewStringf("%s = %s", SwigType_str(type,defname), rvalue);
Wrapper_add_localv(w,defname, defvalue, NIL);
Delete(rvalue);
Delete(defname);
Delete(defvalue);
}

View file

@ -389,7 +389,7 @@ void
Swig_name_object_set(Hash *namehash, String *name, SwigType *decl, DOH *object) {
DOH *n;
/* Printf(stdout,"name: '%s', '%s'\n", name, decl);*/
/* Printf(stdout,"name: '%s', '%s'\n", name, decl); */
n = Getattr(namehash,name);
if (!n) {
n = NewHash();
@ -530,9 +530,11 @@ static void merge_features(Hash *features, Node *n) {
if (!features) return;
for (ki = First(features); ki.key; ki = Next(ki)) {
/*
if (Getattr(n,ki.key)) {
continue;
}
*/
Setattr(n,ki.key,Copy(ki.item));
}
}
@ -550,9 +552,11 @@ Swig_features_get(Hash *features, String *prefix, String *name, SwigType *decl,
DOH *rn = 0;
Hash *n;
char *ncdecl = 0;
String *rdecl = 0;
SwigType *rname = 0;
if (!features) return;
if ((decl) && (SwigType_isqualifier(decl))) {
ncdecl = strchr(Char(decl),'.');
ncdecl++;
@ -563,38 +567,32 @@ Swig_features_get(Hash *features, String *prefix, String *name, SwigType *decl,
((Strcmp(nodeType(node),"constructor") == 0)
|| (Strcmp(nodeType(node),"destructor") == 0))) {
rname = SwigType_templateprefix(name);
rdecl = Copy(decl);
Replaceall(rdecl,name,rname);
decl = rdecl;
name = rname;
}
/* Printf(stdout,"feature_get: %s %s %s\n", prefix, name, decl); */
/* Global features */
n = Getattr(features,"");
rn = get_object(n,0);
merge_features(rn,node);
if (name) {
/* Catch-all */
n = Getattr(features,name);
rn = get_object(n,0);
merge_features(rn,node);
if (ncdecl) {
rn = get_object(n,ncdecl);
merge_features(rn,node);
}
rn = get_object(n,decl);
merge_features(rn,node);
/* Perform a class-based lookup (if class prefix supplied) */
if (prefix) {
if (Len(prefix)) {
tname = NewStringf("%s::%s",prefix,name);
n = Getattr(features,tname);
rn = get_object(n,decl);
merge_features(rn,node);
if (ncdecl) {
rn = get_object(n,ncdecl);
merge_features(rn,node);
}
rn = get_object(n,0);
merge_features(rn,node);
Delete(tname);
}
/* A wildcard-based class lookup */
tname = NewStringf("*::%s",name);
n = Getattr(features,tname);
rn = get_object(n,decl);
merge_features(rn,node);
if (ncdecl) {
rn = get_object(n,ncdecl);
merge_features(rn,node);
}
rn = get_object(n,0);
merge_features(rn,node);
Delete(tname);
/* A class-generic feature */
if (Len(prefix)) {
tname = NewStringf("%s::",prefix);
@ -603,38 +601,50 @@ Swig_features_get(Hash *features, String *prefix, String *name, SwigType *decl,
merge_features(rn,node);
Delete(tname);
}
} else {
/* Lookup in the global namespace only */
tname = NewStringf("::%s",name);
/* A wildcard-based class lookup */
tname = NewStringf("*::%s",name);
n = Getattr(features,tname);
rn = get_object(n,decl);
rn = get_object(n,0);
merge_features(rn,node);
if (ncdecl) {
rn = get_object(n,ncdecl);
merge_features(rn,node);
}
rn = get_object(n,decl);
merge_features(rn,node);
Delete(tname);
/* A specific class lookup */
if (Len(prefix)) {
tname = NewStringf("%s::%s",prefix,name);
n = Getattr(features,tname);
rn = get_object(n,0);
merge_features(rn,node);
if (ncdecl) {
rn = get_object(n,ncdecl);
merge_features(rn,node);
}
rn = get_object(n,decl);
merge_features(rn,node);
Delete(tname);
}
} else {
/* Lookup in the global namespace only */
tname = NewStringf("::%s",name);
n = Getattr(features,tname);
rn = get_object(n,0);
merge_features(rn,node);
if (ncdecl) {
rn = get_object(n,ncdecl);
merge_features(rn,node);
}
rn = get_object(n,decl);
merge_features(rn,node);
Delete(tname);
}
/* Catch-all */
n = Getattr(features,name);
rn = get_object(n,decl);
merge_features(rn,node);
if (ncdecl) {
rn = get_object(n,ncdecl);
merge_features(rn,node);
}
rn = get_object(n,0);
merge_features(rn,node);
}
/* Global features */
n = Getattr(features,"");
rn = get_object(n,0);
merge_features(rn,node);
Delete(rname);
Delete(rdecl);
}
@ -650,7 +660,8 @@ void
Swig_feature_set(Hash *features, const String_or_char *name, SwigType *decl, const String_or_char *featurename, String *value, Hash *featureattribs) {
Hash *n;
Hash *fhash;
/* Printf(stdout,"feature: %s %s %s %s\n", name, decl, featurename, value);*/
/* Printf(stdout,"feature_set: %s %s %s %s\n", name, decl, featurename, value); */
n = Getattr(features,name);
if (!n) {