add naming init and other string cosmetics
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8148 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
a961a7d5f2
commit
cd0b345ebd
6 changed files with 208 additions and 111 deletions
|
|
@ -12,9 +12,11 @@
|
|||
char cvsroot_misc_c[] = "$Header$";
|
||||
|
||||
#include "swig.h"
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_copy_string()
|
||||
*
|
||||
|
|
@ -355,6 +357,11 @@ String *Swig_string_mangle(const String *s) {
|
|||
#endif
|
||||
}
|
||||
|
||||
String *Swig_string_emangle(String *s) {
|
||||
return Swig_string_mangle(s);
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_scopename_prefix()
|
||||
*
|
||||
|
|
@ -614,6 +621,36 @@ int Swig_scopename_check(String *s) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_string_command()
|
||||
*
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#if defined(HAVE_POPEN)
|
||||
extern FILE *popen(const char *command, const char *type);
|
||||
extern int pclose(FILE *stream);
|
||||
|
||||
String *Swig_string_command(String *s) {
|
||||
String *res = NewStringEmpty();
|
||||
if (Len(s)) {
|
||||
char *command = Char(s);
|
||||
FILE *fp = popen(command,"r");
|
||||
if (fp) {
|
||||
char buffer[1025];
|
||||
while(fscanf(fp,"%1024s",buffer) != EOF) {
|
||||
Append(res,buffer);
|
||||
}
|
||||
pclose(fp);
|
||||
}
|
||||
if (!fp || (errno) || (StringLen(res) == 0)) {
|
||||
Swig_error("SWIG",Getline(s), "Command encoder fails attempting '%s'.\n", s);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_init()
|
||||
|
|
@ -629,6 +666,10 @@ Swig_init() {
|
|||
DohEncoding("lower", Swig_string_lower);
|
||||
DohEncoding("title", Swig_string_title);
|
||||
DohEncoding("typecode",Swig_string_typecode);
|
||||
DohEncoding("mangle",Swig_string_emangle);
|
||||
#if defined(HAVE_POPEN)
|
||||
DohEncoding("command",Swig_string_command);
|
||||
#endif
|
||||
|
||||
/* Initialize typemaps */
|
||||
Swig_typemap_init();
|
||||
|
|
@ -636,10 +677,12 @@ Swig_init() {
|
|||
/* Initialize symbol table */
|
||||
Swig_symbol_init();
|
||||
|
||||
/* Initialize naming system */
|
||||
Swig_naming_init();
|
||||
|
||||
/* Initialize type system */
|
||||
SwigType_typesystem_init();
|
||||
|
||||
/* Initialize template system */
|
||||
SwigType_template_init();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,44 @@ char cvsroot_naming_c[] = "$Header$";
|
|||
static Hash *naming_hash = 0;
|
||||
|
||||
/* #define SWIG_DEBUG */
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_naming_init()
|
||||
*
|
||||
* Init the naming system
|
||||
* ----------------------------------------------------------------------------- */
|
||||
static String *k_construct = 0;
|
||||
static String *k_constructor = 0;
|
||||
static String *k_destroy= 0;
|
||||
static String *k_destructor = 0;
|
||||
static String *k_disown = 0;
|
||||
static String *k_name = 0;
|
||||
static String *k_start = 0;
|
||||
static String *k_value = 0;
|
||||
static String *k_wrapper = 0;
|
||||
static String *k_nodetype = 0;
|
||||
static String *k_member = 0;
|
||||
static String *k_get = 0;
|
||||
static String *k_set = 0;
|
||||
|
||||
void
|
||||
Swig_naming_init() {
|
||||
k_construct = NewString("construct");
|
||||
k_constructor = NewString("constructor");
|
||||
k_destroy = NewString("destroy");
|
||||
k_destructor = NewString("destructor");
|
||||
k_disown = NewString("disown");
|
||||
k_name = NewString("name");
|
||||
k_nodetype = NewString("nodeType");
|
||||
k_start = NewString("*");
|
||||
k_value = NewString("value");
|
||||
k_wrapper = NewString("wrapper");
|
||||
k_member = NewString("member");
|
||||
k_set = NewString("set");
|
||||
k_get = NewString("get");
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_name_register()
|
||||
*
|
||||
|
|
@ -149,7 +187,7 @@ Swig_name_wrapper(const String_or_char *fname) {
|
|||
|
||||
r = NewStringEmpty();
|
||||
if (!naming_hash) naming_hash = NewHash();
|
||||
f = Getattr(naming_hash,"wrapper");
|
||||
f = Getattr(naming_hash,k_wrapper);
|
||||
if (!f) {
|
||||
Append(r,"_wrap_%f");
|
||||
} else {
|
||||
|
|
@ -177,7 +215,7 @@ Swig_name_member(const String_or_char *classname, const String_or_char *mname) {
|
|||
rclassname = SwigType_namestr(classname);
|
||||
r = NewStringEmpty();
|
||||
if (!naming_hash) naming_hash = NewHash();
|
||||
f = Getattr(naming_hash,"member");
|
||||
f = Getattr(naming_hash,k_member);
|
||||
if (!f) {
|
||||
Append(r,"%c_%m");
|
||||
} else {
|
||||
|
|
@ -213,7 +251,7 @@ Swig_name_get(const String_or_char *vname) {
|
|||
|
||||
r = NewStringEmpty();
|
||||
if (!naming_hash) naming_hash = NewHash();
|
||||
f = Getattr(naming_hash,"get");
|
||||
f = Getattr(naming_hash,k_get);
|
||||
if (!f) {
|
||||
Append(r,"%v_get");
|
||||
} else {
|
||||
|
|
@ -237,7 +275,7 @@ Swig_name_set(const String_or_char *vname) {
|
|||
|
||||
r = NewStringEmpty();
|
||||
if (!naming_hash) naming_hash = NewHash();
|
||||
f = Getattr(naming_hash,"set");
|
||||
f = Getattr(naming_hash,k_set);
|
||||
if (!f) {
|
||||
Append(r,"%v_set");
|
||||
} else {
|
||||
|
|
@ -264,7 +302,7 @@ Swig_name_construct(const String_or_char *classname) {
|
|||
rclassname = SwigType_namestr(classname);
|
||||
r = NewStringEmpty();
|
||||
if (!naming_hash) naming_hash = NewHash();
|
||||
f = Getattr(naming_hash,"construct");
|
||||
f = Getattr(naming_hash,k_construct);
|
||||
if (!f) {
|
||||
Append(r,"new_%c");
|
||||
} else {
|
||||
|
|
@ -299,7 +337,7 @@ Swig_name_copyconstructor(const String_or_char *classname) {
|
|||
rclassname = SwigType_namestr(classname);
|
||||
r = NewStringEmpty();
|
||||
if (!naming_hash) naming_hash = NewHash();
|
||||
f = Getattr(naming_hash,"construct");
|
||||
f = Getattr(naming_hash,k_construct);
|
||||
if (!f) {
|
||||
Append(r,"copy_%c");
|
||||
} else {
|
||||
|
|
@ -332,7 +370,7 @@ String *Swig_name_destroy(const String_or_char *classname) {
|
|||
rclassname = SwigType_namestr(classname);
|
||||
r = NewStringEmpty();
|
||||
if (!naming_hash) naming_hash = NewHash();
|
||||
f = Getattr(naming_hash,"destroy");
|
||||
f = Getattr(naming_hash,k_destroy);
|
||||
if (!f) {
|
||||
Append(r,"delete_%c");
|
||||
} else {
|
||||
|
|
@ -365,7 +403,7 @@ String *Swig_name_disown(const String_or_char *classname) {
|
|||
rclassname = SwigType_namestr(classname);
|
||||
r = NewStringEmpty();
|
||||
if (!naming_hash) naming_hash = NewHash();
|
||||
f = Getattr(naming_hash,"disown");
|
||||
f = Getattr(naming_hash,k_disown);
|
||||
if (!f) {
|
||||
Append(r,"disown_%c");
|
||||
} else {
|
||||
|
|
@ -405,7 +443,7 @@ Swig_name_object_set(Hash *namehash, String *name, SwigType *decl, DOH *object)
|
|||
}
|
||||
/* Add an object based on the declarator value */
|
||||
if (!decl) {
|
||||
Setattr(n,"*",object);
|
||||
Setattr(n,k_start,object);
|
||||
} else {
|
||||
SwigType *cd = Copy(decl);
|
||||
Setattr(n,cd,object);
|
||||
|
|
@ -427,7 +465,7 @@ static DOH *get_object(Hash *n, String *decl) {
|
|||
if (decl) {
|
||||
rn = Getattr(n,decl);
|
||||
} else {
|
||||
rn = Getattr(n,"*");
|
||||
rn = Getattr(n,k_start);
|
||||
}
|
||||
return rn;
|
||||
}
|
||||
|
|
@ -447,7 +485,7 @@ name_object_get(Hash *namehash, String *tname, SwigType *decl, SwigType *ncdecl)
|
|||
|
||||
DOH *
|
||||
Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType *decl) {
|
||||
String *tname;
|
||||
String *tname = NewStringEmpty();
|
||||
DOH *rn = 0;
|
||||
char *ncdecl = 0;
|
||||
|
||||
|
|
@ -463,53 +501,61 @@ Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType *dec
|
|||
/* Perform a class-based lookup (if class prefix supplied) */
|
||||
if (prefix) {
|
||||
if (Len(prefix)) {
|
||||
tname = NewStringf("%s::%s",prefix,name);
|
||||
Printf(tname,"%s::%s", prefix, name);
|
||||
rn = name_object_get(namehash, tname, decl, ncdecl);
|
||||
Delete(tname);
|
||||
if (!rn) {
|
||||
String *cls = Swig_scopename_last(prefix);
|
||||
if (Strcmp(cls,prefix)!= 0) {
|
||||
tname = NewStringf("*::%s::%s",cls,name);
|
||||
if (!Equal(cls,prefix)) {
|
||||
Clear(tname);
|
||||
Printf(tname,"*::%s::%s",cls,name);
|
||||
rn = name_object_get(namehash, tname, decl, ncdecl);
|
||||
Delete(tname);
|
||||
}
|
||||
Delete(cls);
|
||||
}
|
||||
}
|
||||
/* A template-based class lookup, check name first */
|
||||
if (!rn && SwigType_istemplate(name)) {
|
||||
String *tname = SwigType_templateprefix(name);
|
||||
if (Strcmp(tname,name) != 0) {
|
||||
rn = Swig_name_object_get(namehash, prefix, tname, decl);
|
||||
String *t_name = SwigType_templateprefix(name);
|
||||
if (!Equal(t_name,name)) {
|
||||
rn = Swig_name_object_get(namehash, prefix, t_name, decl);
|
||||
}
|
||||
Delete(tname);
|
||||
Delete(t_name);
|
||||
}
|
||||
/* A template-based class lookup */
|
||||
if (!rn && SwigType_istemplate(prefix)) {
|
||||
String *tprefix = SwigType_templateprefix(prefix);
|
||||
if (Strcmp(tprefix,prefix) != 0) {
|
||||
String *tname = SwigType_templateprefix(name);
|
||||
rn = Swig_name_object_get(namehash, tprefix, tname, decl);
|
||||
Delete(tname);
|
||||
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) {
|
||||
if (!Equal(name,k_start)) {
|
||||
rn = Swig_name_object_get(namehash, prefix, k_start, decl);
|
||||
}
|
||||
Delete(tprefix);
|
||||
}
|
||||
}
|
||||
/* A wildcard-based class lookup */
|
||||
if (!rn) {
|
||||
tname = NewStringf("*::%s",name);
|
||||
Clear(tname);
|
||||
Printf(tname,"*::%s",name);
|
||||
rn = name_object_get(namehash, tname, decl, ncdecl);
|
||||
Delete(tname);
|
||||
}
|
||||
} else {
|
||||
/* Lookup in the global namespace only */
|
||||
tname = NewStringf("::%s",name);
|
||||
Clear(tname);
|
||||
Printf(tname,"::%s",name);
|
||||
rn = name_object_get(namehash, tname, decl, ncdecl);
|
||||
Delete(tname);
|
||||
}
|
||||
/* Catch-all */
|
||||
if (!rn) {
|
||||
rn = name_object_get(namehash, name, decl, ncdecl);
|
||||
}
|
||||
if (!rn) {
|
||||
rn = name_object_get(namehash, k_start, decl, ncdecl);
|
||||
}
|
||||
Delete(tname);
|
||||
return rn;
|
||||
}
|
||||
|
||||
|
|
@ -536,13 +582,10 @@ Swig_name_object_inherit(Hash *namehash, String *base, String *derived) {
|
|||
for (ki = First(namehash); ki.key; ki = Next(ki)) {
|
||||
char *k = Char(ki.key);
|
||||
if (strncmp(k,cbprefix,plen) == 0) {
|
||||
Hash *n, *newh;
|
||||
String *nkey;
|
||||
Iterator oi;
|
||||
|
||||
nkey = NewStringf("%s%s",dprefix,k+plen);
|
||||
n = ki.item;
|
||||
newh = Getattr(namehash,nkey);
|
||||
String *nkey = NewStringf("%s%s",dprefix,k+plen);
|
||||
Hash *n = ki.item;
|
||||
Hash *newh = Getattr(namehash,nkey);
|
||||
if (!newh) {
|
||||
newh = NewHash();
|
||||
Setattr(namehash,nkey,newh);
|
||||
|
|
@ -555,8 +598,11 @@ Swig_name_object_inherit(Hash *namehash, String *base, String *derived) {
|
|||
Delete(ci);
|
||||
}
|
||||
}
|
||||
Delete(nkey);
|
||||
}
|
||||
}
|
||||
Delete(bprefix);
|
||||
Delete(dprefix);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -599,7 +645,6 @@ void features_get(Hash *features, String *tname, SwigType *decl, SwigType *ncdec
|
|||
|
||||
void
|
||||
Swig_features_get(Hash *features, String *prefix, String *name, SwigType *decl, Node *node) {
|
||||
String *tname;
|
||||
char *ncdecl = 0;
|
||||
String *rdecl = 0;
|
||||
SwigType *rname = 0;
|
||||
|
|
@ -615,22 +660,22 @@ Swig_features_get(Hash *features, String *prefix, String *name, SwigType *decl,
|
|||
|
||||
/* very specific hack for template constructors/destructors */
|
||||
if (name && SwigType_istemplate(name) &&
|
||||
((Strcmp(nodeType(node),"constructor") == 0)
|
||||
|| (Strcmp(nodeType(node),"destructor") == 0))) {
|
||||
String *prefix = NewStringEmpty();
|
||||
String *last = NewStringEmpty();
|
||||
(HashCheckAttr(node,k_nodetype,k_constructor)
|
||||
|| HashCheckAttr(node, k_nodetype,k_destructor))) {
|
||||
String *nprefix = NewStringEmpty();
|
||||
String *nlast = NewStringEmpty();
|
||||
String *tprefix;
|
||||
Swig_scopename_split(name, &prefix, &last);
|
||||
tprefix = SwigType_templateprefix(last);
|
||||
Delete(last);
|
||||
if (Len(prefix)) {
|
||||
Append(prefix,"::");
|
||||
Append(prefix,tprefix);
|
||||
Swig_scopename_split(name, &nprefix, &nlast);
|
||||
tprefix = SwigType_templateprefix(nlast);
|
||||
Delete(nlast);
|
||||
if (Len(nprefix)) {
|
||||
Append(nprefix,"::");
|
||||
Append(nprefix,tprefix);
|
||||
Delete(tprefix);
|
||||
rname = prefix;
|
||||
rname = nprefix;
|
||||
} else {
|
||||
rname = tprefix;
|
||||
Delete(prefix);
|
||||
Delete(nprefix);
|
||||
}
|
||||
rdecl = Copy(decl);
|
||||
Replaceall(rdecl,name,rname);
|
||||
|
|
@ -645,40 +690,41 @@ Swig_features_get(Hash *features, String *prefix, String *name, SwigType *decl,
|
|||
/* Global features */
|
||||
features_get(features, "", 0, 0, node);
|
||||
if (name) {
|
||||
String *tname = NewStringEmpty();
|
||||
/* Catch-all */
|
||||
features_get(features, name, decl, ncdecl, node);
|
||||
/* Perform a class-based lookup (if class prefix supplied) */
|
||||
if (prefix) {
|
||||
/* A class-generic feature */
|
||||
if (Len(prefix)) {
|
||||
tname = NewStringf("%s::",prefix);
|
||||
Printf(tname,"%s::",prefix);
|
||||
features_get(features, tname, decl, ncdecl, node);
|
||||
Delete(tname);
|
||||
}
|
||||
/* A wildcard-based class lookup */
|
||||
tname = NewStringf("*::%s",name);
|
||||
Clear(tname);
|
||||
Printf(tname,"*::%s",name);
|
||||
features_get(features, tname, decl, ncdecl, node);
|
||||
Delete(tname);
|
||||
/* A specific class lookup */
|
||||
if (Len(prefix)) {
|
||||
/* A template-based class lookup */
|
||||
if (SwigType_istemplate(prefix)) {
|
||||
String *tprefix = SwigType_templateprefix(prefix);
|
||||
tname = NewStringf("%s::%s",tprefix,name);
|
||||
Clear(tname);
|
||||
Printf(tname,"%s::%s",tprefix,name);
|
||||
features_get(features, tname, decl, ncdecl, node);
|
||||
Delete(tname);
|
||||
Delete(tprefix);
|
||||
}
|
||||
tname = NewStringf("%s::%s",prefix,name);
|
||||
Clear(tname);
|
||||
Printf(tname,"%s::%s",prefix,name);
|
||||
features_get(features, tname, decl, ncdecl, node);
|
||||
Delete(tname);
|
||||
}
|
||||
} else {
|
||||
/* Lookup in the global namespace only */
|
||||
tname = NewStringf("::%s",name);
|
||||
Clear(tname);
|
||||
Printf(tname,"::%s",name);
|
||||
features_get(features, tname, decl, ncdecl, node);
|
||||
Delete(tname);
|
||||
}
|
||||
Delete(tname);
|
||||
}
|
||||
if (name && SwigType_istemplate(name)) {
|
||||
String *dname = Swig_symbol_template_deftype(name,0);
|
||||
|
|
@ -717,10 +763,10 @@ Swig_feature_set(Hash *features, const String_or_char *name, SwigType *decl, con
|
|||
Delete(n);
|
||||
}
|
||||
if (!decl) {
|
||||
fhash = Getattr(n,"*");
|
||||
fhash = Getattr(n,k_start);
|
||||
if (!fhash) {
|
||||
fhash = NewHash();
|
||||
Setattr(n,"*",fhash);
|
||||
Setattr(n,k_start,fhash);
|
||||
Delete(fhash);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -743,15 +789,16 @@ Swig_feature_set(Hash *features, const String_or_char *name, SwigType *decl, con
|
|||
/* Add in the optional feature attributes */
|
||||
Hash *attribs = featureattribs;
|
||||
while(attribs) {
|
||||
String *attribname = Getattr(attribs,"name");
|
||||
String *attribname = Getattr(attribs,k_name);
|
||||
String *featureattribname = NewStringf("%s:%s", featurename, attribname);
|
||||
if (value) {
|
||||
String *attribvalue = Getattr(attribs,"value");
|
||||
String *attribvalue = Getattr(attribs,k_value);
|
||||
Setattr(fhash,featureattribname,attribvalue);
|
||||
} else {
|
||||
Delattr(fhash,featureattribname);
|
||||
}
|
||||
attribs = nextSibling(attribs);
|
||||
Delete(featureattribname);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -325,11 +325,11 @@ static
|
|||
void SwigType_add_default(String *def, SwigType *nr)
|
||||
{
|
||||
if (Strcmp(nr,"SWIGTYPE") == 0) {
|
||||
Append(def,"SWIGTYPE");
|
||||
StringAppend(def,"SWIGTYPE");
|
||||
} else {
|
||||
String *q = SwigType_isqualifier(nr) ? SwigType_pop(nr) : 0;
|
||||
if (q && strstr(Char(nr),"SWIGTYPE")) {
|
||||
Append(def, nr);
|
||||
StringAppend(def, nr);
|
||||
} else {
|
||||
String *nd = SwigType_default(nr);
|
||||
if (nd) {
|
||||
|
|
@ -343,10 +343,10 @@ void SwigType_add_default(String *def, SwigType *nr)
|
|||
Delete(nd);
|
||||
}
|
||||
}
|
||||
Append(def,bdef);
|
||||
StringAppend(def,bdef);
|
||||
Delete(bdef);
|
||||
} else {
|
||||
Append(def,nr);
|
||||
StringAppend(def,nr);
|
||||
}
|
||||
}
|
||||
Delete(q);
|
||||
|
|
@ -440,7 +440,7 @@ SwigType *SwigType_default(SwigType *t) {
|
|||
SwigType_del_array(nr);
|
||||
SwigType_add_default(def, nr);
|
||||
#else
|
||||
Append(def,"SWIGTYPE");
|
||||
StringAppend(def,"SWIGTYPE");
|
||||
#endif
|
||||
Delete(nr);
|
||||
}
|
||||
|
|
@ -517,14 +517,14 @@ SwigType_namestr(const SwigType *t) {
|
|||
sz = Len(p);
|
||||
for (i = 0; i < sz; i++) {
|
||||
String *str = SwigType_str(Getitem(p,i),0);
|
||||
Append(r,str);
|
||||
StringAppend(r,str);
|
||||
if ((i+1) < sz) Putc(',',r);
|
||||
Delete(str);
|
||||
}
|
||||
Putc(' ',r);
|
||||
Putc('>',r);
|
||||
suffix = SwigType_templatesuffix(t);
|
||||
Append(r,suffix);
|
||||
StringAppend(r,suffix);
|
||||
Delete(suffix);
|
||||
Delete(p);
|
||||
#if 0
|
||||
|
|
@ -580,7 +580,7 @@ SwigType_str(SwigType *s, const String_or_char *id)
|
|||
Insert(result,0,"*");
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
Insert(result,0,"(");
|
||||
Append(result,")");
|
||||
StringAppend(result,")");
|
||||
}
|
||||
} else if (SwigType_ismemberpointer(element)) {
|
||||
String *q;
|
||||
|
|
@ -589,7 +589,7 @@ SwigType_str(SwigType *s, const String_or_char *id)
|
|||
Insert(result,0,q);
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
Insert(result,0,"(");
|
||||
Append(result,")");
|
||||
StringAppend(result,")");
|
||||
}
|
||||
Delete(q);
|
||||
}
|
||||
|
|
@ -597,27 +597,27 @@ SwigType_str(SwigType *s, const String_or_char *id)
|
|||
Insert(result,0,"&");
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
Insert(result,0,"(");
|
||||
Append(result,")");
|
||||
StringAppend(result,")");
|
||||
}
|
||||
} else if (SwigType_isarray(element)) {
|
||||
DOH *size;
|
||||
Append(result,"[");
|
||||
StringAppend(result,"[");
|
||||
size = SwigType_parm(element);
|
||||
Append(result,size);
|
||||
Append(result,"]");
|
||||
StringAppend(result,size);
|
||||
StringAppend(result,"]");
|
||||
Delete(size);
|
||||
} else if (SwigType_isfunction(element)) {
|
||||
DOH *parms, *p;
|
||||
int j, plen;
|
||||
Append(result,"(");
|
||||
StringAppend(result,"(");
|
||||
parms = SwigType_parmlist(element);
|
||||
plen = Len(parms);
|
||||
for (j = 0; j < plen; j++) {
|
||||
p = SwigType_str(Getitem(parms,j),0);
|
||||
Append(result,p);
|
||||
if (j < (plen-1)) Append(result,",");
|
||||
StringAppend(result,p);
|
||||
if (j < (plen-1)) StringAppend(result,",");
|
||||
}
|
||||
Append(result,")");
|
||||
StringAppend(result,")");
|
||||
Delete(parms);
|
||||
} else {
|
||||
if (strcmp(Char(element),"v(...)") == 0) {
|
||||
|
|
@ -682,34 +682,34 @@ SwigType_ltype(SwigType *s) {
|
|||
if (SwigType_isqualifier(element)) {
|
||||
/* Do nothing. Ignore */
|
||||
} else if (SwigType_ispointer(element)) {
|
||||
Append(result,element);
|
||||
StringAppend(result,element);
|
||||
firstarray = 0;
|
||||
} else if (SwigType_ismemberpointer(element)) {
|
||||
Append(result,element);
|
||||
StringAppend(result,element);
|
||||
firstarray = 0;
|
||||
} else if (SwigType_isreference(element)) {
|
||||
if (notypeconv) {
|
||||
Append(result,element);
|
||||
StringAppend(result,element);
|
||||
} else {
|
||||
Append(result,"p.");
|
||||
StringAppend(result,"p.");
|
||||
}
|
||||
firstarray = 0;
|
||||
} else if (SwigType_isarray(element) && firstarray) {
|
||||
if (notypeconv) {
|
||||
Append(result,element);
|
||||
StringAppend(result,element);
|
||||
} else {
|
||||
Append(result,"p.");
|
||||
StringAppend(result,"p.");
|
||||
}
|
||||
firstarray = 0;
|
||||
} else if (SwigType_isenum(element)) {
|
||||
int anonymous_enum = (Cmp(element,"enum ") == 0);
|
||||
if (notypeconv || !anonymous_enum) {
|
||||
Append(result,element);
|
||||
StringAppend(result,element);
|
||||
} else {
|
||||
Append(result,"int");
|
||||
StringAppend(result,"int");
|
||||
}
|
||||
} else {
|
||||
Append(result,element);
|
||||
StringAppend(result,element);
|
||||
}
|
||||
}
|
||||
Delete(elements);
|
||||
|
|
@ -805,7 +805,7 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
|
|||
Insert(result,0,"*");
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
Insert(result,0,"(");
|
||||
Append(result,")");
|
||||
StringAppend(result,")");
|
||||
}
|
||||
firstarray = 0;
|
||||
} else if (SwigType_ismemberpointer(element)) {
|
||||
|
|
@ -816,26 +816,26 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
|
|||
Delete(q);
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
Insert(result,0,"(");
|
||||
Append(result,")");
|
||||
StringAppend(result,")");
|
||||
}
|
||||
firstarray = 0;
|
||||
} else if (SwigType_isreference(element)) {
|
||||
Insert(result,0,"&");
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
Insert(result,0,"(");
|
||||
Append(result,")");
|
||||
StringAppend(result,")");
|
||||
}
|
||||
isreference = 1;
|
||||
} else if (SwigType_isarray(element)) {
|
||||
DOH *size;
|
||||
if (firstarray && !isreference) {
|
||||
Append(result,"(*)");
|
||||
StringAppend(result,"(*)");
|
||||
firstarray = 0;
|
||||
} else {
|
||||
Append(result,"[");
|
||||
StringAppend(result,"[");
|
||||
size = SwigType_parm(element);
|
||||
Append(result,size);
|
||||
Append(result,"]");
|
||||
StringAppend(result,size);
|
||||
StringAppend(result,"]");
|
||||
Delete(size);
|
||||
clear = 0;
|
||||
}
|
||||
|
|
@ -843,16 +843,16 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
|
|||
} else if (SwigType_isfunction(element)) {
|
||||
DOH *parms, *p;
|
||||
int j, plen;
|
||||
Append(result,"(");
|
||||
StringAppend(result,"(");
|
||||
parms = SwigType_parmlist(element);
|
||||
plen = Len(parms);
|
||||
for (j = 0; j < plen; j++) {
|
||||
p = SwigType_str(Getitem(parms,j),0);
|
||||
Append(result,p);
|
||||
StringAppend(result,p);
|
||||
Delete(p);
|
||||
if (j < (plen-1)) Append(result,",");
|
||||
if (j < (plen-1)) StringAppend(result,",");
|
||||
}
|
||||
Append(result,")");
|
||||
StringAppend(result,")");
|
||||
Delete(parms);
|
||||
} else {
|
||||
String *bs = SwigType_namestr(element);
|
||||
|
|
@ -871,9 +871,9 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
|
|||
if (name) {
|
||||
if (isreference) {
|
||||
if (isarray) Clear(cast);
|
||||
Append(cast,"*");
|
||||
StringAppend(cast,"*");
|
||||
}
|
||||
Append(cast,name);
|
||||
StringAppend(cast,name);
|
||||
}
|
||||
Delete(result);
|
||||
Delete(tc);
|
||||
|
|
@ -917,7 +917,8 @@ String *SwigType_lcaststr(SwigType *s, const String_or_char *name) {
|
|||
/* keep old mangling since Java codes need it */
|
||||
String *SwigType_manglestr_default(SwigType *s) {
|
||||
char *c;
|
||||
String *result,*base;
|
||||
String *result = 0;
|
||||
String *base = 0;
|
||||
SwigType *lt;
|
||||
SwigType *sr = SwigType_typedef_qualified(s);
|
||||
SwigType *ss = SwigType_typedef_resolve_all(sr);
|
||||
|
|
@ -965,7 +966,7 @@ String *SwigType_manglestr_default(SwigType *s) {
|
|||
else if (!isalnum((int)*c)) *c = '_';
|
||||
c++;
|
||||
}
|
||||
Append(result,base);
|
||||
StringAppend(result,base);
|
||||
Insert(result,0,"_");
|
||||
Delete(lt);
|
||||
Delete(base);
|
||||
|
|
@ -1058,7 +1059,7 @@ SwigType_typename_replace(SwigType *t, String *pat, String *rep) {
|
|||
StringAppend(nt,e);
|
||||
}
|
||||
Clear(t);
|
||||
Append(t,nt);
|
||||
StringAppend(t,nt);
|
||||
Delete(nt);
|
||||
Delete(elem);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -544,6 +544,10 @@ extern int Swig_director_mode();
|
|||
extern void SwigType_template_init();
|
||||
|
||||
|
||||
/* -- naming init -- */
|
||||
extern void Swig_naming_init();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ Swig_symbol_dump_symtable() {
|
|||
#endif
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_symbol_new()
|
||||
* Swig_symbol_init()
|
||||
*
|
||||
* Create a new symbol table object
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@ static String *k_inherit = 0;
|
|||
static String *k_parent = 0;
|
||||
static String *k_value = 0;
|
||||
static String *k_nodetype = 0;
|
||||
static String *k_class = 0;
|
||||
|
||||
/*
|
||||
Enable this one if your language fully support SwigValueWrapper<T>.
|
||||
|
|
@ -159,6 +160,7 @@ void SwigType_typesystem_init() {
|
|||
k_parent = NewString("parent");
|
||||
k_value = NewString("value");
|
||||
k_nodetype = NewString("nodeType");
|
||||
k_class = NewString("class");
|
||||
|
||||
if (global_scope) Delete(global_scope);
|
||||
if (scopes) Delete(scopes);
|
||||
|
|
@ -1284,7 +1286,7 @@ SwigType *SwigType_alttype(SwigType *t, int local_tmap) {
|
|||
if (GetFlag(n,"feature:valuewrapper")) {
|
||||
use_wrapper = 1;
|
||||
} else {
|
||||
if ((Strcmp(nodeType(n),"class") == 0)
|
||||
if (HashCheckAttr(n,k_nodetype,k_class)
|
||||
&& (!Getattr(n,"allocate:default_constructor")
|
||||
|| (Getattr(n,"allocate:noassign")))) {
|
||||
use_wrapper = !GetFlag(n,"feature:novaluewrapper") || GetFlag(n,"feature:nodefault");
|
||||
|
|
@ -1313,7 +1315,7 @@ SwigType *SwigType_alttype(SwigType *t, int local_tmap) {
|
|||
SwigType *td = SwigType_strip_qualifiers(ftd);
|
||||
if (SwigType_type(td) == T_USER) {
|
||||
if ((n = Swig_symbol_clookup(td,0))) {
|
||||
if (((Strcmp(nodeType(n),"class") == 0)
|
||||
if ((HashCheckAttr(n,k_nodetype,k_class)
|
||||
&& !Getattr(n,"allocate:noassign")
|
||||
&& (Getattr(n,"allocate:default_constructor")))
|
||||
|| (GetFlag(n,"feature:novaluewrapper"))) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue