Slight performance tweak for templates
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11834 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
a4d28ba148
commit
160ce6d4a8
4 changed files with 41 additions and 45 deletions
|
|
@ -211,9 +211,9 @@ Hash *Swig_cparse_features(void) {
|
|||
}
|
||||
|
||||
static String *feature_identifier_fix(String *s) {
|
||||
if (SwigType_istemplate(s)) {
|
||||
String *tp, *ts, *ta, *tq;
|
||||
tp = SwigType_templateprefix(s);
|
||||
String *tp = SwigType_istemplate_templateprefix(s);
|
||||
if (tp) {
|
||||
String *ts, *ta, *tq;
|
||||
ts = SwigType_templatesuffix(s);
|
||||
ta = SwigType_templateargs(s);
|
||||
tq = Swig_symbol_type_qualify(ta,0);
|
||||
|
|
@ -756,14 +756,15 @@ static List *pure_abstract(Node *n) {
|
|||
|
||||
static String *make_class_name(String *name) {
|
||||
String *nname = 0;
|
||||
String *prefix;
|
||||
if (Namespaceprefix) {
|
||||
nname= NewStringf("%s::%s", Namespaceprefix, name);
|
||||
} else {
|
||||
nname = NewString(name);
|
||||
}
|
||||
if (SwigType_istemplate(nname)) {
|
||||
String *prefix, *args, *qargs;
|
||||
prefix = SwigType_templateprefix(nname);
|
||||
prefix = SwigType_istemplate_templateprefix(nname);
|
||||
if (prefix) {
|
||||
String *args, *qargs;
|
||||
args = SwigType_templateargs(nname);
|
||||
qargs = Swig_symbol_type_qualify(args,0);
|
||||
Append(prefix,qargs);
|
||||
|
|
@ -3380,6 +3381,7 @@ cpp_declaration : cpp_class_decl { $$ = $1; }
|
|||
/* A simple class/struct/union definition */
|
||||
cpp_class_decl : storage_class cpptype idcolon inherit LBRACE {
|
||||
if (nested_template == 0) {
|
||||
String *prefix;
|
||||
List *bases = 0;
|
||||
Node *scope = 0;
|
||||
$<node>$ = new_node("class");
|
||||
|
|
@ -3428,9 +3430,9 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE {
|
|||
if ($4) {
|
||||
bases = make_inherit_list($3,Getattr($4,"public"));
|
||||
}
|
||||
if (SwigType_istemplate($3)) {
|
||||
String *fbase, *tbase, *prefix;
|
||||
prefix = SwigType_templateprefix($3);
|
||||
prefix = SwigType_istemplate_templateprefix($3);
|
||||
if (prefix) {
|
||||
String *fbase, *tbase;
|
||||
if (Namespaceprefix) {
|
||||
fbase = NewStringf("%s::%s", Namespaceprefix,$3);
|
||||
tbase = NewStringf("%s::%s", Namespaceprefix, prefix);
|
||||
|
|
@ -3441,7 +3443,6 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE {
|
|||
Swig_name_inherit(tbase,fbase);
|
||||
Delete(fbase);
|
||||
Delete(tbase);
|
||||
Delete(prefix);
|
||||
}
|
||||
if (strcmp($2,"class") == 0) {
|
||||
cplus_mode = CPLUS_PRIVATE;
|
||||
|
|
@ -3492,6 +3493,7 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE {
|
|||
}
|
||||
}
|
||||
class_decl[class_level++] = $<node>$;
|
||||
Delete(prefix);
|
||||
inclass = 1;
|
||||
}
|
||||
} cpp_members RBRACE cpp_opt_declarators {
|
||||
|
|
|
|||
|
|
@ -374,9 +374,12 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0,
|
|||
// Swig_print_node(n);
|
||||
}
|
||||
|
||||
if (SwigType_istemplate(name)) {
|
||||
String *temp = strip_namespaces(SwigType_templateprefix(name));
|
||||
String *tname = SwigType_istemplate_templateprefix(name);
|
||||
if (tname) {
|
||||
String *temp = strip_namespaces(tname);
|
||||
name = NewStringf("%s%s%s", temp, SwigType_templateargs(name), SwigType_templatesuffix(name));
|
||||
Delete(temp);
|
||||
Delete(tname);
|
||||
}
|
||||
|
||||
val = lookup_defined_foreign_type(k);
|
||||
|
|
@ -1085,11 +1088,12 @@ void emit_stub_class(Node *n) {
|
|||
if (Getattr(n, "allegrocl:synonym:already-been-stubbed"))
|
||||
return;
|
||||
|
||||
if (SwigType_istemplate(name)) {
|
||||
String *temp = strip_namespaces(SwigType_templateprefix(name));
|
||||
String *tname = SwigType_istemplate_templateprefix(name);
|
||||
if (tname) {
|
||||
String *temp = strip_namespaces(tname);
|
||||
name = NewStringf("%s%s%s", temp, SwigType_templateargs(name), SwigType_templatesuffix(name));
|
||||
|
||||
Delete(temp);
|
||||
Delete(tname);
|
||||
} else {
|
||||
name = strip_namespaces(name);
|
||||
}
|
||||
|
|
@ -1276,11 +1280,12 @@ void emit_class(Node *n) {
|
|||
String *ns_list = listify_namespace(Getattr(n, "allegrocl:namespace"));
|
||||
String *name = Getattr(n, is_tempInst ? "real-name" : "name");
|
||||
|
||||
if (SwigType_istemplate(name)) {
|
||||
String *temp = strip_namespaces(SwigType_templateprefix(name));
|
||||
String *tname = SwigType_istemplate_templateprefix(name);
|
||||
if (tname) {
|
||||
String *temp = strip_namespaces(tname);
|
||||
name = NewStringf("%s%s%s", temp, SwigType_templateargs(name), SwigType_templatesuffix(name));
|
||||
|
||||
Delete(temp);
|
||||
Delete(tname);
|
||||
} else {
|
||||
name = strip_namespaces(name);
|
||||
}
|
||||
|
|
@ -1335,10 +1340,12 @@ void emit_typedef(Node *n) {
|
|||
|
||||
if (in_class) {
|
||||
String *class_name = Getattr(in_class, "name");
|
||||
if (SwigType_istemplate(class_name)) {
|
||||
String *temp = strip_namespaces(SwigType_templateprefix(class_name));
|
||||
String *tname = SwigType_istemplate_templateprefix(class_name);
|
||||
if (tname) {
|
||||
String *temp = strip_namespaces(tname);
|
||||
class_name = NewStringf("%s%s%s", temp, SwigType_templateargs(class_name), SwigType_templatesuffix(class_name));
|
||||
Delete(temp);
|
||||
Delete(tname);
|
||||
}
|
||||
|
||||
name = NewStringf("%s__%s", class_name, sym_name);
|
||||
|
|
|
|||
|
|
@ -474,25 +474,12 @@ DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType
|
|||
Delete(cls);
|
||||
}
|
||||
/* A template-based class lookup, check name first */
|
||||
if (!rn && SwigType_istemplate(name)) {
|
||||
String *t_name = SwigType_templateprefix(name);
|
||||
if (!Equal(t_name, name)) {
|
||||
if (!rn) {
|
||||
String *t_name = SwigType_istemplate_templateprefix(name);
|
||||
if (t_name)
|
||||
rn = Swig_name_object_get(namehash, prefix, t_name, decl);
|
||||
}
|
||||
Delete(t_name);
|
||||
}
|
||||
/* A template-based class lookup */
|
||||
/*
|
||||
if (!rn && SwigType_istemplate(prefix)) {
|
||||
String *t_prefix = SwigType_templateprefix(prefix);
|
||||
if (Strcmp(t_prefix, prefix) != 0) {
|
||||
String *t_name = SwigType_templateprefix(name);
|
||||
rn = Swig_name_object_get(namehash, t_prefix, t_name, decl);
|
||||
Delete(t_name);
|
||||
}
|
||||
Delete(t_prefix);
|
||||
}
|
||||
*/
|
||||
}
|
||||
/* A wildcard-based class lookup */
|
||||
if (!rn) {
|
||||
|
|
@ -663,10 +650,9 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d
|
|||
if (name) {
|
||||
String *tname = NewStringEmpty();
|
||||
/* add features for 'root' template */
|
||||
if (SwigType_istemplate(name)) {
|
||||
String *dname = SwigType_templateprefix(name);
|
||||
String *dname = SwigType_istemplate_templateprefix(name);
|
||||
if (dname) {
|
||||
features_get(features, dname, decl, ncdecl, node);
|
||||
Delete(dname);
|
||||
}
|
||||
/* Catch-all */
|
||||
features_get(features, name, decl, ncdecl, node);
|
||||
|
|
@ -684,16 +670,16 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d
|
|||
/* A specific class lookup */
|
||||
if (Len(prefix)) {
|
||||
/* A template-based class lookup */
|
||||
if (SwigType_istemplate(prefix)) {
|
||||
String *tprefix = SwigType_templateprefix(prefix);
|
||||
String *tprefix = SwigType_istemplate_templateprefix(prefix);
|
||||
if (tprefix) {
|
||||
Clear(tname);
|
||||
Printf(tname, "%s::%s", tprefix, name);
|
||||
features_get(features, tname, decl, ncdecl, node);
|
||||
Delete(tprefix);
|
||||
}
|
||||
Clear(tname);
|
||||
Printf(tname, "%s::%s", prefix, name);
|
||||
features_get(features, tname, decl, ncdecl, node);
|
||||
Delete(tprefix);
|
||||
}
|
||||
} else {
|
||||
/* Lookup in the global namespace only */
|
||||
|
|
@ -702,6 +688,7 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d
|
|||
features_get(features, tname, decl, ncdecl, node);
|
||||
}
|
||||
Delete(tname);
|
||||
Delete(dname);
|
||||
}
|
||||
if (name && SwigType_istemplate(name)) {
|
||||
/* add features for complete template type */
|
||||
|
|
|
|||
|
|
@ -1161,9 +1161,9 @@ int SwigType_isclass(SwigType *t) {
|
|||
isclass = 1;
|
||||
}
|
||||
/* Hmmm. Not a class. If a template, it might be uninstantiated */
|
||||
if (!isclass && SwigType_istemplate(qtys)) {
|
||||
String *tp = SwigType_templateprefix(qtys);
|
||||
if (Strcmp(tp, t) != 0) {
|
||||
if (!isclass) {
|
||||
String *tp = SwigType_istemplate_templateprefix(qtys);
|
||||
if (tp && Strcmp(tp, t) != 0) {
|
||||
isclass = SwigType_isclass(tp);
|
||||
}
|
||||
Delete(tp);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue