add NewStringEmpty, use more StringEuqual and less Strcmp

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7897 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-11-28 17:32:56 +00:00
commit 628dc6b32b
24 changed files with 253 additions and 218 deletions

View file

@ -103,7 +103,7 @@ scanner_locator(String *loc) {
/* Now, parse the new location out of the locator string */
{
String *fn = NewString("");
String *fn = NewStringEmpty();
Putc(c,fn);
while ((c = Getc(loc)) != EOF) {
@ -143,9 +143,9 @@ scanner_locator(String *loc) {
void scanner_init() {
yybuffer = (char *) malloc(YYBSIZE);
scan_init = 1;
header = NewString("");
comment = NewString("");
scanner_ccode = NewString("");
header = NewStringEmpty();
comment = NewStringEmpty();
scanner_ccode = NewStringEmpty();
}
/**************************************************************

View file

@ -508,9 +508,9 @@ static void add_symbols(Node *n) {
if (Getattr(n,"sym:weak")) {
Setattr(n,"sym:name",symname);
} else {
String *e = NewString("");
String *en = NewString("");
String *ec = NewString("");
String *e = NewStringEmpty();
String *en = NewStringEmpty();
String *ec = NewStringEmpty();
int redefined = need_redefined_warn(n,c,inclass);
if (redefined) {
Printf(en,"Identifier '%s' redefined (ignored)",symname);
@ -678,9 +678,9 @@ static void merge_extensions(Node *cls, Node *am) {
csym = Swig_symbol_add(symname,n);
if (csym != n) {
/* Conflict with previous definition. Nuke previous definition */
String *e = NewString("");
String *en = NewString("");
String *ec = NewString("");
String *e = NewStringEmpty();
String *en = NewStringEmpty();
String *ec = NewStringEmpty();
Printf(ec,"Identifier '%s' redefined by %%extend (ignored),",symname);
Printf(en,"%%extend definition of '%s'.",symname);
SWIG_WARN_NODE_BEGIN(n);
@ -1104,7 +1104,7 @@ static void single_new_feature(const char *featurename, String *val, Hash *featu
if (declaratorid) {
fixname = feature_identifier_fix(declaratorid);
} else {
fixname = NewString("");
fixname = NewStringEmpty();
}
if (Namespaceprefix) {
name = NewStringf("%s::%s",Namespaceprefix, fixname);
@ -1899,7 +1899,7 @@ insert_directive : HBLOCK {
Setattr($$,"code",$1);
}
| INSERT LPAREN idstring RPAREN string {
String *code = NewString("");
String *code = NewStringEmpty();
$$ = new_node("insert");
Setattr($$,"section",$3);
Setattr($$,"code",code);
@ -2914,7 +2914,7 @@ c_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end {
Setattr($$,"name",ty);
if ($6.have_parms) {
SwigType *decl = NewString("");
SwigType *decl = NewStringEmpty();
SwigType_add_function(decl,$6.parms);
Setattr($$,"decl",decl);
Setattr($$,"parms",$6.parms);
@ -3154,7 +3154,7 @@ cpp_class_decl :
Swig_symbol_newscope();
cparse_start_line = cparse_line;
inclass = 1;
Classprefix = NewString("");
Classprefix = NewStringEmpty();
Namespaceprefix = Swig_symbol_qualifiedscopename(0);
} cpp_members RBRACE declarator c_decl_tail {
String *unnamed;
@ -3757,7 +3757,7 @@ cpp_member : c_declaration { $$ = $1; }
cpp_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end {
if (Classprefix) {
SwigType *decl = NewString("");
SwigType *decl = NewStringEmpty();
$$ = new_node("constructor");
Setattr($$,"name",$2);
Setattr($$,"parms",$4);
@ -3784,7 +3784,7 @@ cpp_destructor_decl : NOT idtemplate LPAREN parms RPAREN cpp_end {
Setattr($$,"code",Copy(scanner_ccode));
}
{
String *decl = NewString("");
String *decl = NewStringEmpty();
SwigType_add_function(decl,$4);
Setattr($$,"decl",decl);
}
@ -3819,7 +3819,7 @@ cpp_destructor_decl : NOT idtemplate LPAREN parms RPAREN cpp_end {
Setattr($$,"code",Copy(scanner_ccode));
}
{
String *decl = NewString("");
String *decl = NewStringEmpty();
SwigType_add_function(decl,$5);
Setattr($$,"decl",decl);
}
@ -3849,7 +3849,7 @@ cpp_conversion_operator : storage_class COPERATOR type pointer LPAREN parms RPAR
$$ = new_node("cdecl");
Setattr($$,"type",$3);
Setattr($$,"name",$2);
decl = NewString("");
decl = NewStringEmpty();
SwigType_add_reference(decl);
SwigType_add_function(decl,$6);
if ($8.qualifier) {
@ -3862,7 +3862,7 @@ cpp_conversion_operator : storage_class COPERATOR type pointer LPAREN parms RPAR
}
| storage_class COPERATOR type LPAREN parms RPAREN cpp_vend {
String *t = NewString("");
String *t = NewStringEmpty();
$$ = new_node("cdecl");
Setattr($$,"type",$3);
Setattr($$,"name",$2);
@ -3934,13 +3934,13 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line
/* Generate some code for a new class */
} else {
Nested *n = (Nested *) malloc(sizeof(Nested));
n->code = NewString("");
n->code = NewStringEmpty();
Printv(n->code, "typedef ", $2, " ",
Char(scanner_ccode), " $classname_", $6.id, ";\n", NIL);
n->name = Swig_copy_string($6.id);
n->line = cparse_start_line;
n->type = NewString("");
n->type = NewStringEmpty();
n->kind = $2;
SwigType_push(n->type, $6.type);
n->next = 0;
@ -3962,12 +3962,12 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line
} else if ($5.id) {
/* Generate some code for a new class */
Nested *n = (Nested *) malloc(sizeof(Nested));
n->code = NewString("");
n->code = NewStringEmpty();
Printv(n->code, "typedef ", $2, " " ,
Char(scanner_ccode), " $classname_", $5.id, ";\n",NIL);
n->name = Swig_copy_string($5.id);
n->line = cparse_start_line;
n->type = NewString("");
n->type = NewStringEmpty();
n->kind = $2;
SwigType_push(n->type,$5.type);
n->next = 0;
@ -4352,11 +4352,11 @@ declarator : pointer notso_direct_declarator {
}
| direct_declarator {
$$ = $1;
if (!$$.type) $$.type = NewString("");
if (!$$.type) $$.type = NewStringEmpty();
}
| AND notso_direct_declarator {
$$ = $2;
$$.type = NewString("");
$$.type = NewStringEmpty();
SwigType_add_reference($$.type);
if ($2.type) {
SwigType_push($$.type,$2.type);
@ -4364,7 +4364,7 @@ declarator : pointer notso_direct_declarator {
}
}
| idcolon DSTAR notso_direct_declarator {
SwigType *t = NewString("");
SwigType *t = NewStringEmpty();
$$ = $3;
SwigType_add_memberpointer(t,$1);
@ -4375,7 +4375,7 @@ declarator : pointer notso_direct_declarator {
$$.type = t;
}
| pointer idcolon DSTAR notso_direct_declarator {
SwigType *t = NewString("");
SwigType *t = NewStringEmpty();
$$ = $4;
SwigType_add_memberpointer(t,$2);
SwigType_push($1,t);
@ -4397,7 +4397,7 @@ declarator : pointer notso_direct_declarator {
$$.type = $1;
}
| idcolon DSTAR AND notso_direct_declarator {
SwigType *t = NewString("");
SwigType *t = NewStringEmpty();
$$ = $4;
SwigType_add_memberpointer(t,$1);
SwigType_add_reference(t);
@ -4451,7 +4451,7 @@ notso_direct_declarator : idcolon {
| LPAREN idcolon DSTAR notso_direct_declarator RPAREN {
SwigType *t;
$$ = $4;
t = NewString("");
t = NewStringEmpty();
SwigType_add_memberpointer(t,$2);
if ($$.type) {
SwigType_push(t,$$.type);
@ -4462,7 +4462,7 @@ notso_direct_declarator : idcolon {
| notso_direct_declarator LBRACKET RBRACKET {
SwigType *t;
$$ = $1;
t = NewString("");
t = NewStringEmpty();
SwigType_add_array(t,(char*)"");
if ($$.type) {
SwigType_push(t,$$.type);
@ -4473,7 +4473,7 @@ notso_direct_declarator : idcolon {
| notso_direct_declarator LBRACKET expr RBRACKET {
SwigType *t;
$$ = $1;
t = NewString("");
t = NewStringEmpty();
SwigType_add_array(t,$3.val);
if ($$.type) {
SwigType_push(t,$$.type);
@ -4484,7 +4484,7 @@ notso_direct_declarator : idcolon {
| notso_direct_declarator LPAREN parms RPAREN {
SwigType *t;
$$ = $1;
t = NewString("");
t = NewStringEmpty();
SwigType_add_function(t,$3);
if (!$$.have_parms) {
$$.parms = $3;
@ -4536,14 +4536,14 @@ direct_declarator : idcolon {
| LPAREN AND direct_declarator RPAREN {
$$ = $3;
if (!$$.type) {
$$.type = NewString("");
$$.type = NewStringEmpty();
}
SwigType_add_reference($$.type);
}
| LPAREN idcolon DSTAR direct_declarator RPAREN {
SwigType *t;
$$ = $4;
t = NewString("");
t = NewStringEmpty();
SwigType_add_memberpointer(t,$2);
if ($$.type) {
SwigType_push(t,$$.type);
@ -4554,7 +4554,7 @@ direct_declarator : idcolon {
| direct_declarator LBRACKET RBRACKET {
SwigType *t;
$$ = $1;
t = NewString("");
t = NewStringEmpty();
SwigType_add_array(t,(char*)"");
if ($$.type) {
SwigType_push(t,$$.type);
@ -4565,7 +4565,7 @@ direct_declarator : idcolon {
| direct_declarator LBRACKET expr RBRACKET {
SwigType *t;
$$ = $1;
t = NewString("");
t = NewStringEmpty();
SwigType_add_array(t,$3.val);
if ($$.type) {
SwigType_push(t,$$.type);
@ -4576,7 +4576,7 @@ direct_declarator : idcolon {
| direct_declarator LPAREN parms RPAREN {
SwigType *t;
$$ = $1;
t = NewString("");
t = NewStringEmpty();
SwigType_add_function(t,$3);
if (!$$.have_parms) {
$$.parms = $3;
@ -4625,7 +4625,7 @@ abstract_declarator : pointer {
}
| AND direct_abstract_declarator {
$$ = $2;
$$.type = NewString("");
$$.type = NewStringEmpty();
SwigType_add_reference($$.type);
if ($2.type) {
SwigType_push($$.type,$2.type);
@ -4636,18 +4636,18 @@ abstract_declarator : pointer {
$$.id = 0;
$$.parms = 0;
$$.have_parms = 0;
$$.type = NewString("");
$$.type = NewStringEmpty();
SwigType_add_reference($$.type);
}
| idcolon DSTAR {
$$.type = NewString("");
$$.type = NewStringEmpty();
SwigType_add_memberpointer($$.type,$1);
$$.id = 0;
$$.parms = 0;
$$.have_parms = 0;
}
| pointer idcolon DSTAR {
SwigType *t = NewString("");
SwigType *t = NewStringEmpty();
$$.type = $1;
$$.id = 0;
$$.parms = 0;
@ -4670,7 +4670,7 @@ abstract_declarator : pointer {
direct_abstract_declarator : direct_abstract_declarator LBRACKET RBRACKET {
SwigType *t;
$$ = $1;
t = NewString("");
t = NewStringEmpty();
SwigType_add_array(t,(char*)"");
if ($$.type) {
SwigType_push(t,$$.type);
@ -4681,7 +4681,7 @@ direct_abstract_declarator : direct_abstract_declarator LBRACKET RBRACKET {
| direct_abstract_declarator LBRACKET expr RBRACKET {
SwigType *t;
$$ = $1;
t = NewString("");
t = NewStringEmpty();
SwigType_add_array(t,$3.val);
if ($$.type) {
SwigType_push(t,$$.type);
@ -4690,14 +4690,14 @@ direct_abstract_declarator : direct_abstract_declarator LBRACKET RBRACKET {
$$.type = t;
}
| LBRACKET RBRACKET {
$$.type = NewString("");
$$.type = NewStringEmpty();
$$.id = 0;
$$.parms = 0;
$$.have_parms = 0;
SwigType_add_array($$.type,(char*)"");
}
| LBRACKET expr RBRACKET {
$$.type = NewString("");
$$.type = NewStringEmpty();
$$.id = 0;
$$.parms = 0;
$$.have_parms = 0;
@ -4709,7 +4709,7 @@ direct_abstract_declarator : direct_abstract_declarator LBRACKET RBRACKET {
| direct_abstract_declarator LPAREN parms RPAREN {
SwigType *t;
$$ = $1;
t = NewString("");
t = NewStringEmpty();
SwigType_add_function(t,$3);
if (!$$.type) {
$$.type = t;
@ -4724,7 +4724,7 @@ direct_abstract_declarator : direct_abstract_declarator LBRACKET RBRACKET {
}
}
| LPAREN parms RPAREN {
$$.type = NewString("");
$$.type = NewStringEmpty();
SwigType_add_function($$.type,$2);
$$.parms = $2;
$$.have_parms = 1;
@ -4734,31 +4734,31 @@ direct_abstract_declarator : direct_abstract_declarator LBRACKET RBRACKET {
pointer : STAR type_qualifier pointer {
$$ = NewString("");
$$ = NewStringEmpty();
SwigType_add_pointer($$);
SwigType_push($$,$2);
SwigType_push($$,$3);
Delete($3);
}
| STAR pointer {
$$ = NewString("");
$$ = NewStringEmpty();
SwigType_add_pointer($$);
SwigType_push($$,$2);
Delete($2);
}
| STAR type_qualifier {
$$ = NewString("");
$$ = NewStringEmpty();
SwigType_add_pointer($$);
SwigType_push($$,$2);
}
| STAR {
$$ = NewString("");
$$ = NewStringEmpty();
SwigType_add_pointer($$);
}
;
type_qualifier : type_qualifier_raw {
$$ = NewString("");
$$ = NewStringEmpty();
if ($1) SwigType_add_qualifier($$,$1);
}
| type_qualifier_raw type_qualifier {
@ -5361,7 +5361,7 @@ mem_initializer : idcolon LPAREN {
;
template_decl : LESSTHAN valparms GREATERTHAN {
String *s = NewString("");
String *s = NewStringEmpty();
SwigType_add_template(s,$2);
$$ = Char(s);
scanner_last_id(1);

View file

@ -121,7 +121,7 @@ cparse_template_expand(Node *n, String *tname, String *rname, String *templatear
if (!n) return 0;
if (Getattr(n,k_error)) return 0;
if (Strcmp(nodeType,k_template) == 0) {
if (StringEqual(nodeType,k_template)) {
/* Change the node type back to normal */
if (!expanded) {
expanded = 1;
@ -138,7 +138,7 @@ cparse_template_expand(Node *n, String *tname, String *rname, String *templatear
set_nodeType(n,k_template);
return ret;
}
} else if (Strcmp(nodeType,k_cdecl) == 0) {
} else if (StringEqual(nodeType,k_cdecl)) {
/* A simple C declaration */
SwigType *t, *v, *d;
String *code;
@ -163,7 +163,7 @@ cparse_template_expand(Node *n, String *tname, String *rname, String *templatear
add_parms(Getattr(n,k_parms), cpatchlist, typelist);
add_parms(Getattr(n,k_throws), cpatchlist, typelist);
} else if (Strcmp(nodeType,k_class) == 0) {
} else if (StringEqual(nodeType,k_class)) {
/* Patch base classes */
{
int b = 0;
@ -187,7 +187,7 @@ cparse_template_expand(Node *n, String *tname, String *rname, String *templatear
cn = nextSibling(cn);
}
}
} else if (Strcmp(nodeType,k_constructor) == 0) {
} else if (StringEqual(nodeType,k_constructor)) {
String *name = Getattr(n,k_name);
if (!(Getattr(n,k_templatetype))) {
String *symname;
@ -222,7 +222,7 @@ cparse_template_expand(Node *n, String *tname, String *rname, String *templatear
Append(typelist, Getattr(n,k_decl));
add_parms(Getattr(n,k_parms), cpatchlist, typelist);
add_parms(Getattr(n,k_throws), cpatchlist, typelist);
} else if (Strcmp(nodeType,k_destructor) == 0) {
} else if (StringEqual(nodeType,k_destructor)) {
String *name = Getattr(n,k_name);
if (Strstr(name,"<")) {
Append(patchlist,Getattr(n,k_name));
@ -239,7 +239,7 @@ cparse_template_expand(Node *n, String *tname, String *rname, String *templatear
}
Setattr(n,k_symname,name);
Append(cpatchlist,Getattr(n,k_code));
} else if (Strcmp(nodeType,k_using) == 0) {
} else if (StringEqual(nodeType,k_using)) {
String *uname = Getattr(n,k_uname);
if (uname) {
if (Strstr(uname,"<")) {
@ -300,7 +300,7 @@ Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab *ts
typelist = NewList();
{
String *tmp = NewString("");
String *tmp = NewStringEmpty();
if (tparms) {
SwigType_add_template(tmp,tparms);
}
@ -484,7 +484,7 @@ template_locate(String *name, Parm *tparms, Symtab *tscope) {
Parm *parms;
Parm *targs;
tname = NewString(name);
tname = Copy(name);
parms = CopyParmList(tparms);
/* Search for generic template */
@ -526,7 +526,7 @@ template_locate(String *name, Parm *tparms, Symtab *tscope) {
n = Swig_symbol_clookup_local(tname,0);
if (!n) {
SwigType *rname = Swig_symbol_typedef_reduce(tname,tscope);
if (Strcmp(rname,tname)) {
if (!StringEqual(rname,tname)) {
if (template_debug) {
Printf(stdout," searching: '%s' (exact specialization)\n", rname);
}
@ -537,7 +537,7 @@ template_locate(String *name, Parm *tparms, Symtab *tscope) {
if (n) {
Node *tn;
String *nodeType = Getattr(n,k_nodetype);
if (Strcmp(nodeType,k_template) == 0) goto success;
if (StringEqual(nodeType,k_template)) goto success;
tn = Getattr(n,k_template);
if (tn) {
n = tn;
@ -613,7 +613,7 @@ template_locate(String *name, Parm *tparms, Symtab *tscope) {
if (template_debug) {
Printf(stdout," searching: '%s' (partial specialization - %s)\n", ss, pi.item);
}
if ((Strcmp(ss,tname) == 0) || (Strcmp(ss,rname) == 0)) {
if ((StringEqual(ss,tname)) || (StringEqual(ss,rname))) {
Append(mpartials,pi.item);
}
Delete(ss);
@ -647,7 +647,7 @@ template_locate(String *name, Parm *tparms, Symtab *tscope) {
Swig_error(cparse_file, cparse_line, "Template '%s' undefined.\n", name);
} else if (n) {
String *nodeType = Getattr(n,k_nodetype);
if (Strcmp(nodeType,k_template) != 0) {
if (!StringEqual(nodeType,k_template)) {
Swig_error(cparse_file, cparse_line, "'%s' is not defined as a template. (%s)\n", name, nodeType);
n = 0;
}
@ -681,8 +681,8 @@ Swig_cparse_template_locate(String *name, Parm *tparms, Symtab *tscope) {
if (n) {
int isclass = 0;
assert(Strcmp(nodeType,k_template) == 0);
isclass = (Strcmp(Getattr(n,k_templatetype),k_class) == 0);
assert(StringEqual(nodeType,k_template));
isclass = (StringEqual(Getattr(n,k_templatetype),k_class));
if (!isclass) {
/* If not a templated class we must have a templated function.
The template found is not necessarily the one we want when dealing with templated

View file

@ -455,7 +455,7 @@ DohGetVoid(DOH *obj, const DOH *name) {
void
DohSetInt(DOH *obj, const DOH *name, int value) {
DOH *temp;
temp = NewString("");
temp = NewStringEmpty();
Printf(temp,"%d",value);
Setattr(obj,(DOH *) name,temp);
}
@ -467,7 +467,7 @@ DohSetInt(DOH *obj, const DOH *name, int value) {
void
DohSetDouble(DOH *obj, const DOH *name, double value) {
DOH *temp;
temp = NewString("");
temp = NewStringEmpty();
Printf(temp,"%0.17f",value);
Setattr(obj,(DOH *) name,temp);
}

View file

@ -72,6 +72,7 @@
#define DohStringUngetc DOH_NAMESPACE(StringUngetc)
#define DohStringAppend DOH_NAMESPACE(StringAppend)
#define DohStringLen DOH_NAMESPACE(StringLen)
#define DohStringChar DOH_NAMESPACE(StringChar)
#define DohStringEqual DOH_NAMESPACE(StringEqual)
@ -95,6 +96,7 @@
#define DohIsString DOH_NAMESPACE(IsString)
#define DohIsFile DOH_NAMESPACE(IsFile)
#define DohNewString DOH_NAMESPACE(NewString)
#define DohNewStringEmpty DOH_NAMESPACE(NewStringEmpty)
#define DohNewStringWithSize DOH_NAMESPACE(NewStringWithSize)
#define DohNewStringf DOH_NAMESPACE(NewStringf)
#define DohStrcmp DOH_NAMESPACE(Strcmp)
@ -255,6 +257,7 @@ extern int DohString_getc(DOH *so);
extern int DohString_ungetc(DOH *so, int ch);
extern void DohString_append(DOH *so, DOH *str);
extern int DohString_len(DOH *s1);
extern char *DohString_char(DOH *s1);
extern int DohString_equal(DOH *s1, DOH *s2);
#define DohStringPutc(ch,so) DohString_putc(so, ch)
@ -262,6 +265,7 @@ extern int DohString_equal(DOH *s1, DOH *s2);
#define DohStringUngetc(ch,so) DohString_ungetc(so, ch)
#define DohStringAppend(so,str) DohString_append(so, str)
#define DohStringLen(so) DohString_len(so)
#define DohStringChar(so) DohString_char(so)
#define DohStringEqual(s1,s2) DohString_equal(s1,s2)
/* Meta-variables */
@ -291,6 +295,7 @@ extern int DohGetmark(DOH *obj);
* Strings.
* ----------------------------------------------------------------------------- */
extern DOHString *DohNewStringEmpty();
extern DOHString *DohNewString(const DOH *c);
extern DOHString *DohNewStringWithSize(const DOH *c, int len);
extern DOHString *DohNewStringf(const DOH *fmt, ...);
@ -394,6 +399,7 @@ extern void DohMemoryDebug(void);
#define StringUngetc DohStringUngetc
#define StringAppend DohStringAppend
#define StringLen DohStringLen
#define StringChar DohStringChar
#define StringEqual DohStringEqual
#define Close DohClose
@ -419,6 +425,7 @@ extern void DohMemoryDebug(void);
#define Setmeta DohSetmeta
#define Delmeta DohDelmeta
#define NewString DohNewString
#define NewStringEmpty DohNewStringEmpty
#define NewStringWithSize DohNewStringWithSize
#define NewStringf DohNewStringf
#define NewHash DohNewHash

View file

@ -476,7 +476,7 @@ DohSplit(DOH *in, char ch, int nsplits) {
}
while (1) {
str = NewString("");
str = NewStringEmpty();
do {
c = Getc(in);
} while ((c != EOF) && (c == ch));
@ -515,7 +515,7 @@ DohSplitLines(DOH *in) {
}
while (c != EOF) {
str = NewString("");
str = NewStringEmpty();
while ((c = Getc(in)) != '\n' && c != EOF) {
Putc(c, str);
}
@ -536,7 +536,7 @@ DOH *
DohReadline(DOH *in) {
char c;
int n = 0;
DOH *s = NewString("");
DOH *s = NewStringEmpty();
while (1) {
if (Read(in,&c,1) < 0) {
if (n == 0) {

View file

@ -422,7 +422,7 @@ Hash_str(DOH *ho) {
static int indent = 4;
Hash *h = (Hash *) ObjData(ho);
s = NewString("");
s = NewStringEmpty();
if (ObjGetMark(ho)) {
Printf(s,"Hash(0x%x)",ho);
return s;

View file

@ -238,7 +238,7 @@ List_str(DOH *lo) {
DOH *s;
int i;
List *l = (List *) ObjData(lo);
s = NewString("");
s = NewStringEmpty();
if (ObjGetMark(lo)) {
Printf(s,"List(%x)", lo);
return s;

View file

@ -37,6 +37,11 @@ String_data(DOH *so) {
return (void *) s->str;
}
char *
DohString_char(DOH *so) {
return (char *) String_data(so);
}
/* -----------------------------------------------------------------------------
* int String_dump() - Serialize a string onto out
* ----------------------------------------------------------------------------- */
@ -426,7 +431,6 @@ static int
String_seek(DOH *so, long offset, int whence)
{
int pos, nsp, inc;
int prev;
String *s = (String *) ObjData(so);
if (whence == SEEK_SET) pos = 0;
else if (whence == SEEK_CUR) pos = s->sp;
@ -450,7 +454,7 @@ String_seek(DOH *so, long offset, int whence)
register char *tc = s->str;
register int len = s->len;
while (sp != nsp) {
prev = sp + inc;
int prev = sp + inc;
if (prev>=0 && prev<=len && tc[prev] == '\n')
s->line += inc;
sp+=inc;
@ -458,7 +462,6 @@ String_seek(DOH *so, long offset, int whence)
#else
register int sp = s->sp;
register char *tc = s->str;
register int len = s->len;
if (inc > 0) {
while (sp != nsp) {
if (tc[++sp] == '\n')
@ -1008,17 +1011,19 @@ DohNewString(const DOH *so)
int l = 0, max;
String *str;
char *s;
int hashkey = -1;
if (DohCheck(so)) {
str = (String *) ObjData(so);
s = String_data((String *)so);
l = s ? str->len : 0;
hashkey = str->hashkey;
} else {
s = (char *) so;
l = s ? (int) strlen(s) : 0;
}
str = (String *) DohMalloc(sizeof(String));
str->hashkey = -1;
str->hashkey = hashkey;
str->sp = 0;
str->line = 1;
str->file = 0;
@ -1040,6 +1045,26 @@ DohNewString(const DOH *so)
}
/* -----------------------------------------------------------------------------
* NewStringEmpty() - Create a new string
* ----------------------------------------------------------------------------- */
DOHString *
DohNewStringEmpty()
{
int max = INIT_MAXSIZE;
String *str = (String *) DohMalloc(sizeof(String));
str->hashkey = 0;
str->sp = 0;
str->line = 1;
str->file = 0;
str->str = (char *) DohMalloc(max);
str->maxsize = max;
str->str[0] = 0;
str->len = 0;
return DohObjMalloc(&DohStringType,str);
}
/* -----------------------------------------------------------------------------
* NewStringWithSize(const char *c, int len) - Create a new string
* ----------------------------------------------------------------------------- */
@ -1092,7 +1117,7 @@ DohNewStringf(const DOH *fmt, ...)
va_list ap;
DOH *r;
va_start(ap,fmt);
r = NewString("");
r = NewStringEmpty();
DohvPrintf(r,Char(fmt),ap);
va_end(ap);
return (DOHString *) r;

View file

@ -257,10 +257,10 @@ Hash *Preprocessor_define(const String_or_char *_str, int swigmacro)
skip_whitespace(str,0);
/* Now look for a macro name */
macroname = NewString("");
macroname = NewStringEmpty();
while ((c = StringGetc(str)) != EOF) {
if (c == '(') {
argstr = NewString("");
argstr = NewStringEmpty();
copy_location(str,argstr);
/* It is a macro. Go extract it's argument string */
while ((c = StringGetc(str)) != EOF) {
@ -292,7 +292,7 @@ Hash *Preprocessor_define(const String_or_char *_str, int swigmacro)
}
if (!swigmacro)
skip_whitespace(str,0);
macrovalue = NewString("");
macrovalue = NewStringEmpty();
while ((c = StringGetc(str)) != EOF) {
StringPutc(c,macrovalue);
}
@ -302,7 +302,7 @@ Hash *Preprocessor_define(const String_or_char *_str, int swigmacro)
String *argname, *varargname;
arglist = NewList();
Seek(argstr,0,SEEK_SET);
argname = NewString("");
argname = NewStringEmpty();
while ((c = StringGetc(argstr)) != EOF) {
if (c == ',') {
varargname = Macro_vararg_name(argname, str);
@ -312,7 +312,7 @@ Hash *Preprocessor_define(const String_or_char *_str, int swigmacro)
Append(arglist,argname);
}
Delete(argname);
argname = NewString("");
argname = NewStringEmpty();
} else if (isidchar(c) || (c == '.')) {
StringPutc(c,argname);
} else if (!(isspace(c) || (c == '\\'))) {
@ -495,7 +495,7 @@ find_args(String *s)
skip_whitespace(s,0); /* Skip leading whitespace */
c = StringGetc(s);
}
str = NewString("");
str = NewStringEmpty();
copy_location(s,str);
level = 0;
while (c != EOF) {
@ -549,7 +549,7 @@ get_filename(String *str, int* sysfile) {
int c;
skip_whitespace(str,0);
fn = NewString("");
fn = NewStringEmpty();
copy_location(str,fn);
c = StringGetc(str);
*sysfile = 0;
@ -610,7 +610,8 @@ get_options(String *str) {
static String *
expand_macro(String *name, List *args)
{
DOH *symbols, *ns, *macro, *margs, *mvalue, *temp, *tempa, *e;
String *ns;
DOH *symbols, *macro, *margs, *mvalue, *temp, *tempa, *e;
DOH *Preprocessor_replace(DOH *);
int i, l;
int isvarargs = 0;
@ -622,7 +623,7 @@ expand_macro(String *name, List *args)
macro = HashGetAttr(symbols,name);
if (!macro) return 0;
if (HashGetAttr(macro,k_expanded)) {
ns = NewString("");
ns = NewStringEmpty();
StringAppend(ns,name);
if (args) {
if (Len(args))
@ -648,7 +649,7 @@ expand_macro(String *name, List *args)
if (Len(args) >= (Len(margs)-1)) {
int i;
int vi, na;
String *vararg = NewString("");
String *vararg = NewStringEmpty();
vi = Len(margs)-1;
na = Len(args);
for (i = vi; i < na; i++) {
@ -688,8 +689,8 @@ expand_macro(String *name, List *args)
/* Tag the macro as being expanded. This is to avoid recursion in
macro expansion */
temp = NewString("");
tempa = NewString("");
temp = NewStringEmpty();
tempa = NewStringEmpty();
if (args && margs) {
l = Len(margs);
for (i = 0; i < l; i++) {
@ -698,7 +699,7 @@ expand_macro(String *name, List *args)
arg = Getitem(args,i); /* Get an argument value */
reparg = Preprocessor_replace(arg);
aname = Getitem(margs,i); /* Get macro argument name */
if (strstr(Char(ns),"\001")) {
if (strstr(StringChar(ns),"\001")) {
/* Try to replace a quoted version of the argument */
Clear(temp);
Clear(tempa);
@ -706,7 +707,7 @@ expand_macro(String *name, List *args)
Printf(tempa,"\"%s\"",arg);
Replace(ns, temp, tempa, DOH_REPLACE_ID_END);
}
if (strstr(Char(ns),"\002")) {
if (strstr(StringChar(ns),"\002")) {
/* Look for concatenation tokens */
Clear(temp);
Clear(tempa);
@ -724,7 +725,7 @@ expand_macro(String *name, List *args)
version of the argument except that if the argument is already quoted
nothing happens */
if (strstr(Char(ns),"`")) {
if (strstr(StringChar(ns),"`")) {
String *rep;
char *c;
Clear(temp);
@ -742,14 +743,14 @@ expand_macro(String *name, List *args)
/* Non-standard mangle expansions.
The #@Name is replaced by mangle_arg(Name). */
if (strstr(Char(ns),"\004")) {
if (strstr(StringChar(ns),"\004")) {
String* marg = Swig_string_mangle(arg);
Clear(temp);
Printf(temp,"\004%s", aname);
Replace(ns, temp, marg, DOH_REPLACE_ID_END);
Delete(marg);
}
if (strstr(Char(ns),"\005")) {
if (strstr(StringChar(ns),"\005")) {
String* marg = Swig_string_mangle(arg);
Clear(temp);
Clear(tempa);
@ -763,7 +764,7 @@ expand_macro(String *name, List *args)
/* Zero length varargs macro argument. We search for commas that might appear before and nuke them */
char *a, *s, *t, *name;
int namelen;
s = Char(ns);
s = StringChar(ns);
name = Char(aname);
namelen = Len(aname);
a = strstr(s,name);
@ -805,7 +806,7 @@ expand_macro(String *name, List *args)
if (HashGetAttr(macro,k_swigmacro)) {
String *g;
String *f = NewString("");
String *f = NewStringEmpty();
Seek(e,0,SEEK_SET);
copy_location(macro,e);
g = Preprocessor_parse(e);
@ -860,12 +861,12 @@ Preprocessor_replace(DOH *s)
DOH *ns, *symbols, *m;
int c, i, state = 0;
String *id = NewString("");
String *id = NewStringEmpty();
assert(cpp);
symbols = HashGetAttr(cpp,k_symbols);
ns = NewString("");
ns = NewStringEmpty();
copy_location(s,ns);
Seek(s,0,SEEK_SET);
@ -907,7 +908,7 @@ Preprocessor_replace(DOH *s)
StringUngetc(c,s);
args = find_args(s);
} else if (isidchar(c)) {
DOH *arg = NewString("");
DOH *arg = NewStringEmpty();
args = NewList();
StringPutc(c,arg);
while (((c = StringGetc(s)) != EOF)) {
@ -1149,13 +1150,13 @@ Preprocessor_parse(String *s)
/* Blow away all carriage returns */
Replace(s,"\015","",DOH_REPLACE_ANY);
ns = NewString(""); /* Return result */
ns = NewStringEmpty(); /* Return result */
decl = NewString("");
id = NewString("");
value = NewString("");
comment = NewString("");
chunk = NewString("");
decl = NewStringEmpty();
id = NewStringEmpty();
value = NewStringEmpty();
comment = NewStringEmpty();
chunk = NewStringEmpty();
copy_location(s,chunk);
copy_location(s,ns);
symbols = HashGetAttr(cpp,k_symbols);

View file

@ -54,7 +54,7 @@ static String *
Swig_clocal(SwigType *t, const String_or_char *name, const String_or_char *value) {
String *decl;
decl = NewString("");
decl = NewStringEmpty();
switch(SwigType_type(t)) {
case T_REFERENCE:
@ -235,7 +235,7 @@ int Swig_cargs(Wrapper *w, ParmList *p) {
String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_char *decl) {
String *fcall;
fcall = NewString("");
fcall = NewStringEmpty();
switch(SwigType_type(t)) {
case T_VOID:
break;
@ -289,7 +289,7 @@ Swig_cfunction_call(String_or_char *name, ParmList *parms) {
Parm *p = parms;
String *nname;
func = NewString("");
func = NewStringEmpty();
nname = SwigType_namestr(name);
/*
@ -359,7 +359,7 @@ Swig_cmethod_call(String_or_char *name, ParmList *parms, String_or_char *self) {
if (!self) self = (char *) "(this)->";
func = NewString("");
func = NewStringEmpty();
nname = SwigType_namestr(name);
if (!p) return func;
Append(func,self);
@ -420,7 +420,7 @@ String *
Swig_cconstructor_call(String_or_char *name) {
DOH *func;
func = NewString("");
func = NewStringEmpty();
Printf(func,"(%s *) calloc(1, sizeof(%s))", name, name);
return func;
}
@ -449,7 +449,7 @@ Swig_cppconstructor_base_call(String_or_char *name, ParmList *parms, int skip_se
i++;
}
nname = SwigType_namestr(name);
func = NewString("");
func = NewStringEmpty();
Printf(func,"new %s(", nname);
while (p) {
String *pname;
@ -625,7 +625,7 @@ Swig_cppdestructor_call(Node *n) {
String *
Swig_cmemberset_call(String_or_char *name, SwigType *type, String_or_char *self) {
String *func;
func = NewString("");
func = NewStringEmpty();
if (!self) self = NewString("(this)->");
else self = NewString(self);
Replaceall(self,"this",Swig_cparm_name(0,0));
@ -659,7 +659,7 @@ Swig_cmemberget_call(const String_or_char *name, SwigType *t,
if (!self) self = NewString("(this)->");
else self = NewString(self);
Replaceall(self,"this",Swig_cparm_name(0,0));
func = NewString("");
func = NewStringEmpty();
Printf(func,"%s (%s%s)", Swig_wrapped_var_assign(t,""),self, name);
Delete(self);
return func;
@ -976,7 +976,7 @@ Swig_ConstructorToFunction(Node *n, String *classname,
int abstract = Getattr(parent, "abstract") != 0;
String *name = Getattr(parent, "sym:name");
String* directorname = NewStringf("SwigDirector_%s", name);
String* action = NewString("");
String* action = NewStringEmpty();
String* tmp_none_comparison = Copy(none_comparison);
String* director_call;
String* nodirector_call;

View file

@ -71,7 +71,7 @@ Swig_warning(int wnum, const String_or_char *filename, int line, const char *fmt
va_start(ap,fmt);
out = NewString("");
out = NewStringEmpty();
vPrintf(out,fmt,ap);
{
char temp[64], *t;
@ -175,7 +175,7 @@ Swig_warnfilter(const String_or_char *wlist, int add) {
char *c;
String *s;
if (!filter) filter = NewString("");
if (!filter) filter = NewStringEmpty();
s = NewString(wlist);
c = Char(s);
c = strtok(c,", ");

View file

@ -142,7 +142,7 @@ Swig_search_path_any(int syspath) {
llist = 0;
slist = NewList();
assert(slist);
filename = NewString("");
filename = NewStringEmpty();
assert(filename);
#ifdef MACSWIG
Printf(filename,"%s",SWIG_FILE_DELIMETER);
@ -159,7 +159,7 @@ Swig_search_path_any(int syspath) {
for (i = 0; i < Len(directories); i++) {
dirname = Getitem(directories,i);
filename = NewString("");
filename = NewStringEmpty();
assert(filename);
Printf(filename, "%s%s", dirname, SWIG_FILE_DELIMETER);
if (syspath && !Getattr(dirname,"sysdir")) {
@ -244,7 +244,7 @@ Swig_open(const String_or_char *name) {
String *
Swig_read_file(FILE *f) {
char buffer[4096];
String *str = NewString("");
String *str = NewStringEmpty();
assert(str);
while (fgets(buffer,4095,f)) {

View file

@ -63,7 +63,7 @@ Swig_banner(File *f) {
String *Swig_string_escape(String *s) {
String *ns;
int c;
ns = NewString("");
ns = NewStringEmpty();
while ((c = Getc(s)) != EOF) {
if (c == '\n') {
@ -100,7 +100,7 @@ String *Swig_string_escape(String *s) {
String *Swig_string_upper(String *s) {
String *ns;
int c;
ns = NewString("");
ns = NewStringEmpty();
Seek(s,0,SEEK_SET);
while ((c = Getc(s)) != EOF) {
@ -118,7 +118,7 @@ String *Swig_string_upper(String *s) {
String *Swig_string_lower(String *s) {
String *ns;
int c;
ns = NewString("");
ns = NewStringEmpty();
Seek(s,0,SEEK_SET);
while ((c = Getc(s)) != EOF) {
@ -139,7 +139,7 @@ String *Swig_string_title(String *s) {
String *ns;
int first = 1;
int c;
ns = NewString("");
ns = NewStringEmpty();
Seek(s,0,SEEK_SET);
while ((c = Getc(s)) != EOF) {
@ -160,11 +160,11 @@ String *Swig_string_typecode(String *s) {
String *ns;
int c;
String *tc;
ns = NewString("");
ns = NewStringEmpty();
while ((c = Getc(s)) != EOF) {
if (c == '`') {
String *str = 0;
tc = NewString("");
tc = NewStringEmpty();
while ((c = Getc(s)) != EOF) {
if (c == '`') break;
Putc(c,tc);
@ -231,7 +231,7 @@ String *Swig_string_mangle(const String *s) {
}
return t;
#else
String *result = NewString("");
String *result = NewStringEmpty();
int space = 0;
int state = 0;
char *pc, *cb;
@ -245,13 +245,13 @@ String *Swig_string_mangle(const String *s) {
Delete(b);
b = t ;
}
pc = cb = Char(b);
pc = cb = StringChar(b);
while (*pc) {
char c = *pc;
if (isalnum((int)c) || (c == '_')) {
state = 1;
if (space && (space == state)) {
Append(result,"_SS_");
StringAppend(result,"_SS_");
}
space = 0;
Printf(result,"%c",(int)c);
@ -268,7 +268,7 @@ String *Swig_string_mangle(const String *s) {
switch(c) {
case '.':
if ((cb != pc) && (*(pc - 1) == 'p')) {
Append(result,"_");
StringAppend(result,"_");
++pc;
continue;
} else {
@ -277,7 +277,7 @@ String *Swig_string_mangle(const String *s) {
break;
case ':':
if (*(pc + 1) == ':') {
Append(result,"_");
StringAppend(result,"_");
++pc; ++pc;
continue;
}

View file

@ -147,7 +147,7 @@ Swig_name_wrapper(const String_or_char *fname) {
String *r;
String *f;
r = NewString("");
r = NewStringEmpty();
if (!naming_hash) naming_hash = NewHash();
f = Getattr(naming_hash,"wrapper");
if (!f) {
@ -175,7 +175,7 @@ Swig_name_member(const String_or_char *classname, const String_or_char *mname) {
char *cname;
rclassname = SwigType_namestr(classname);
r = NewString("");
r = NewStringEmpty();
if (!naming_hash) naming_hash = NewHash();
f = Getattr(naming_hash,"member");
if (!f) {
@ -211,7 +211,7 @@ Swig_name_get(const String_or_char *vname) {
Printf(stdout,"Swig_name_get: '%s'\n", vname);
#endif
r = NewString("");
r = NewStringEmpty();
if (!naming_hash) naming_hash = NewHash();
f = Getattr(naming_hash,"get");
if (!f) {
@ -235,7 +235,7 @@ Swig_name_set(const String_or_char *vname) {
String *r;
String *f;
r = NewString("");
r = NewStringEmpty();
if (!naming_hash) naming_hash = NewHash();
f = Getattr(naming_hash,"set");
if (!f) {
@ -262,7 +262,7 @@ Swig_name_construct(const String_or_char *classname) {
char *cname;
rclassname = SwigType_namestr(classname);
r = NewString("");
r = NewStringEmpty();
if (!naming_hash) naming_hash = NewHash();
f = Getattr(naming_hash,"construct");
if (!f) {
@ -297,7 +297,7 @@ Swig_name_copyconstructor(const String_or_char *classname) {
char *cname;
rclassname = SwigType_namestr(classname);
r = NewString("");
r = NewStringEmpty();
if (!naming_hash) naming_hash = NewHash();
f = Getattr(naming_hash,"construct");
if (!f) {
@ -330,7 +330,7 @@ String *Swig_name_destroy(const String_or_char *classname) {
String *rclassname;
char *cname;
rclassname = SwigType_namestr(classname);
r = NewString("");
r = NewStringEmpty();
if (!naming_hash) naming_hash = NewHash();
f = Getattr(naming_hash,"destroy");
if (!f) {
@ -363,7 +363,7 @@ String *Swig_name_disown(const String_or_char *classname) {
String *rclassname;
char *cname;
rclassname = SwigType_namestr(classname);
r = NewString("");
r = NewStringEmpty();
if (!naming_hash) naming_hash = NewHash();
f = Getattr(naming_hash,"disown");
if (!f) {

View file

@ -192,7 +192,7 @@ int ParmList_len(ParmList *p) {
* ---------------------------------------------------------------------- */
String *ParmList_str(ParmList *p) {
String *out = NewString("");
String *out = NewStringEmpty();
while(p) {
String *pstr = SwigType_str(Getattr(p,"type"), Getattr(p,"name"));
Append(out,pstr);
@ -212,7 +212,7 @@ String *ParmList_str(ParmList *p) {
* ---------------------------------------------------------------------- */
String *ParmList_str_defaultargs(ParmList *p) {
String *out = NewString("");
String *out = NewStringEmpty();
while(p) {
String *value = Getattr(p,"value");
String *pstr = SwigType_str(Getattr(p,"type"), Getattr(p,"name"));
@ -236,7 +236,7 @@ String *ParmList_str_defaultargs(ParmList *p) {
* ---------------------------------------------------------------------- */
String *ParmList_protostr(ParmList *p) {
String *out = NewString("");
String *out = NewStringEmpty();
while(p) {
if (Getattr(p,"hidden")) {
p = nextSibling(p);

View file

@ -48,7 +48,7 @@ NewSwigScanner() {
s->yylen = 0;
s->idstart = "";
s->scanobjs = NewList();
s->text = NewString("");
s->text = NewStringEmpty();
s->str = 0;
return s;
}

View file

@ -146,7 +146,7 @@ SwigType *NewSwigType(int t) {
default :
break;
}
return NewString("");
return NewStringEmpty();
}
/* -----------------------------------------------------------------------------
@ -357,6 +357,7 @@ void SwigType_add_default(String *def, SwigType *nr)
SwigType *SwigType_default(SwigType *t) {
String *r1, *def;
String *r = 0;
char *cr;
#ifdef SWIG_DEFAULT_CACHE
if (!default_cache) default_cache = NewHash();
@ -388,20 +389,21 @@ SwigType *SwigType_default(SwigType *t) {
}
Delete(q);
}
if (Strcmp(r,"p.SWIGTYPE") == 0) {
cr = Char(r);
if (strcmp(cr,"p.SWIGTYPE") == 0) {
def = NewString("SWIGTYPE");
} else if (SwigType_ispointer(r)) {
#ifdef SWIG_NEW_TYPE_DEFAULT
SwigType *nr = Copy(r);
SwigType_del_pointer(nr);
def = SwigType_isfunction(nr) ?
NewString("") : NewString("p.");
NewStringEmpty() : NewString("p.");
SwigType_add_default(def, nr);
Delete(nr);
#else
def = NewString("p.SWIGTYPE");
#endif
} else if (Strcmp(r,"r.SWIGTYPE") == 0) {
} else if (strcmp(cr,"r.SWIGTYPE") == 0) {
def = NewString("SWIGTYPE");
} else if (SwigType_isreference(r)) {
#ifdef SWIG_NEW_TYPE_DEFAULT
@ -414,9 +416,9 @@ SwigType *SwigType_default(SwigType *t) {
def = NewString("r.SWIGTYPE");
#endif
} else if (SwigType_isarray(r)) {
if (Strcmp(r,"a().SWIGTYPE") == 0) {
if (strcmp(cr,"a().SWIGTYPE") == 0) {
def = NewString("p.SWIGTYPE");
} else if (Strcmp(r,"a(ANY).SWIGTYPE") == 0) {
} else if (strcmp(cr,"a(ANY).SWIGTYPE") == 0) {
def = NewString("a().SWIGTYPE");
} else {
int i, empty = 0;
@ -444,19 +446,19 @@ SwigType *SwigType_default(SwigType *t) {
#endif
}
} else if (SwigType_ismemberpointer(r)) {
if (Strcmp(r,"m(CLASS).SWIGTYPE") == 0) {
if (strcmp(cr,"m(CLASS).SWIGTYPE") == 0) {
def = NewString("p.SWIGTYPE");
} else {
def = NewString("m(CLASS).SWIGTYPE");
}
} else if (SwigType_isenum(r)) {
if (Strcmp(r,"enum SWIGTYPE") == 0) {
if (strcmp(cr,"enum SWIGTYPE") == 0) {
def = NewString("SWIGTYPE");
} else {
def = NewString("enum SWIGTYPE");
}
} else if (SwigType_isfunction(r)) {
if (Strcmp(r,"f(ANY).SWIGTYPE") == 0) {
if (strcmp(cr,"f(ANY).SWIGTYPE") == 0) {
def = NewString("p.SWIGTYPE");
} else {
def = NewString("p.f(ANY).SWIGTYPE");
@ -469,7 +471,7 @@ SwigType *SwigType_default(SwigType *t) {
/* The cache produces strange results, see enum_template.i case */
Setattr(default_cache,t,Copy(def));
#endif
if (Strcmp(def,t) == 0) {
if (StringEqual(def,t)) {
Delete(def);
def = 0;
}
@ -548,7 +550,7 @@ SwigType_str(SwigType *s, const String_or_char *id)
if (id) {
result = NewString(id);
} else {
result = NewString("");
result = NewStringEmpty();
}
elements = SwigType_split(s);
@ -646,7 +648,7 @@ SwigType_ltype(SwigType *s) {
int firstarray = 1;
int notypeconv = 0;
result = NewString("");
result = NewStringEmpty();
tc = Copy(s);
/* Nuke all leading qualifiers */
while (SwigType_isqualifier(tc)) {
@ -756,7 +758,7 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
int isreference = 0;
int isarray = 0;
result = NewString("");
result = NewStringEmpty();
if (SwigType_isconst(s)) {
tc = Copy(s);
@ -858,7 +860,7 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
}
Delete(elements);
if (clear) {
cast = NewString("");
cast = NewStringEmpty();
} else {
cast = NewStringf("(%s)",result);
}
@ -884,7 +886,7 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
String *SwigType_lcaststr(SwigType *s, const String_or_char *name) {
String *result;
result = NewString("");
result = NewStringEmpty();
if (SwigType_isarray(s)) {
Printf(result,"(%s)%s", SwigType_lstr(s,0),name);
@ -981,16 +983,16 @@ SwigType_typename_replace(SwigType *t, String *pat, String *rep) {
if (!Strstr(t,pat)) return;
if (Strcmp(t,pat) == 0) {
if (StringEqual(t,pat)) {
Replace(t,pat,rep,DOH_REPLACE_ANY);
return;
}
nt = NewString("");
nt = NewStringEmpty();
elem = SwigType_split(t);
for (i = 0; i < Len(elem); i++) {
String *e = Getitem(elem,i);
if (SwigType_issimple(e)) {
if (Strcmp(e,pat) == 0) {
if (StringEqual(e,pat)) {
/* Replaces a type of the form 'pat' with 'rep<args>' */
Replace(e,pat,rep,DOH_REPLACE_ANY);
} else if (SwigType_istemplate(e)) {

View file

@ -176,6 +176,7 @@ static Hash *global_scope = 0; /* Global scope */
/* common attribute keys, to avoid calling find_key all the times */
static String *empty_string = 0;
static String *k_allowstypedef = 0;
static String *k_cdecl = 0;
static String *k_coloncolon = 0;
@ -184,7 +185,6 @@ static String *k_csymnextSibling = 0;
static String *k_csympreviousSibling = 0;
static String *k_csymtab = 0;
static String *k_decl = 0;
static String *k_empty = 0;
static String *k_enumitem = 0;
static String *k_inherit = 0;
static String *k_name = 0;
@ -236,6 +236,7 @@ Swig_symbol_dump_symtable() {
void
Swig_symbol_init() {
empty_string = NewStringEmpty();
k_allowstypedef = NewString("allows_typedef");
k_cdecl = NewString("cdecl");
k_coloncolon = NewString("::");
@ -244,7 +245,6 @@ Swig_symbol_init() {
k_csympreviousSibling = NewString("csym:previousSibling");
k_csymtab = NewString("csymtab");
k_decl = NewString("decl");
k_empty = NewString("empty");
k_enumitem = NewString("enumitem");
k_inherit = NewString("inherit");
k_name = NewString("name");
@ -281,7 +281,7 @@ Swig_symbol_init() {
/* Set the global scope */
symtabs = NewHash();
Setattr(symtabs,k_empty,current_symtab);
Setattr(symtabs,empty_string,current_symtab);
global_scope = current_symtab;
}
@ -326,7 +326,7 @@ Swig_symbol_getscopename() {
Symtab *
Swig_symbol_getscope(const String_or_char *name) {
if (!symtabs) return 0;
if (StringEqual(k_coloncolon,(String_or_char *)name)) name = k_empty;
if (StringEqual(k_coloncolon,(String_or_char *)name)) name = empty_string;
return Getattr(symtabs,name);
}
@ -350,7 +350,7 @@ Swig_symbol_qualifiedscopename(Symtab *symtab) {
name = HashGetAttr(symtab,k_name);
if (name) {
if (!result) {
result = NewString("");
result = NewStringEmpty();
}
if (StringLen(result)) {
Printv(result,"::",name, NIL);
@ -1023,7 +1023,7 @@ Swig_symbol_clookup(String_or_char *name, Symtab *n) {
if (Swig_scopename_check(name)) {
char *cname = Char(name);
if (strncmp(cname,"::",2) == 0) {
String *nname = NewString(Char(name)+2);
String *nname = NewString(cname+2);
if (Swig_scopename_check(nname)) {
s = symbol_lookup_qualified(nname,global_scope,0,0,0);
}
@ -1094,7 +1094,7 @@ Swig_symbol_clookup_check(String_or_char *name, Symtab *n, int (*checkfunc)(Node
if (Swig_scopename_check(name)) {
char *cname = Char(name);
if (strncmp(cname,"::",2) == 0) {
String *nname = NewString(Char(name)+2);
String *nname = NewString(cname+2);
if (Swig_scopename_check(nname)) {
s = symbol_lookup_qualified(nname,global_scope,0,0,checkfunc);
}
@ -1157,7 +1157,7 @@ Swig_symbol_clookup_local(String_or_char *name, Symtab *n) {
if (Swig_scopename_check(name)) {
char *cname = Char(name);
if (strncmp(cname,"::",2) == 0) {
String *nname = NewString(Char(name)+2);
String *nname = NewString(cname+2);
if (Swig_scopename_check(nname)) {
s = symbol_lookup_qualified(nname,global_scope,0,0,0);
}
@ -1205,7 +1205,7 @@ Swig_symbol_clookup_local_check(String_or_char *name, Symtab *n, int (*checkfunc
if (Swig_scopename_check(name)) {
char *cname = Char(name);
if (strncmp(cname,"::",2) == 0) {
String *nname = NewString(Char(name)+2);
String *nname = NewString(cname+2);
if (Swig_scopename_check(nname)) {
s = symbol_lookup_qualified(nname,global_scope,0,0,checkfunc);
}
@ -1337,7 +1337,7 @@ Swig_symbol_qualified(Node *n) {
} else {
symtab = HashGetAttr(n,k_symsymtab);
}
if (!symtab) return NewString("");
if (!symtab) return NewStringEmpty();
#ifdef SWIG_DEBUG
Printf(stderr,"symbol_qscope %s %x %s\n", HashGetAttr(n,k_name), symtab,HashGetAttr(symtab,k_name));
#endif
@ -1396,7 +1396,7 @@ Swig_symbol_template_qualify(const SwigType *e, Symtab *st) {
StringAppend(qprefix,vparm);
ti = Next(ti);
if (ti.item) {
Putc(',',qprefix);
StringPutc(',',qprefix);
}
Delete(qparm);
Delete(vparm);
@ -1418,7 +1418,7 @@ Swig_symbol_type_qualify(const SwigType *t, Symtab *st) {
String *result;
int i,len;
result = NewString("");
result = NewStringEmpty();
elements = SwigType_split(t);
len = Len(elements);
@ -1450,7 +1450,7 @@ Swig_symbol_type_qualify(const SwigType *t, Symtab *st) {
StringAppend(e,ty);
Delete(ty);
}
if (strncmp(Char(e),"::",2) == 0) {
if (strncmp(StringChar(e),"::",2) == 0) {
Delitem(e,0);
Delitem(e,0);
}
@ -1589,7 +1589,7 @@ SwigType *Swig_symbol_typedef_reduce(SwigType *ty, Symtab *tab) {
{
const char* dclass[3] = {"struct ", "union ", "class "};
int i;
char * c = Char(nt);
char * c = StringChar(nt);
for (i=0; i<3; i++) {
if (strstr(c, dclass[i]) == c) {
Replace(nt,dclass[i],"", DOH_REPLACE_FIRST);
@ -1638,16 +1638,13 @@ SwigType *Swig_symbol_typedef_reduce(SwigType *ty, Symtab *tab) {
String *
Swig_symbol_string_qualify(String *s, Symtab *st) {
char *c;
String *id, *r;
int have_id = 0;
id = NewString("");
r = NewString("");
c = Char(s);
int have_id = 0;
String *id = NewStringEmpty();
String *r = NewStringEmpty();
char *c = StringChar(s);
while (*c) {
if (isalpha((int)*c) || (*c == '_') || (*c == ':')) {
Putc(*c,id);
StringPutc(*c,id);
have_id = 1;
} else {
if (have_id) {
@ -1657,7 +1654,7 @@ Swig_symbol_string_qualify(String *s, Symtab *st) {
Delete(qid);
have_id = 0;
}
Putc(*c,r);
StringPutc(*c,r);
}
c++;
}
@ -1739,7 +1736,7 @@ Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *t
* ----------------------------------------------------------------------------- */
SwigType*
Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope) {
String *result = NewString("");
String *result = NewStringEmpty();
List *elements = SwigType_split(type);
int len = Len(elements);
int i;
@ -1809,7 +1806,7 @@ Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope) {
}
StringAppend(tprefix,ttq);
p = nextSibling(p);
if (p) Putc(',',tprefix);
if (p) StringPutc(',',tprefix);
Delete(ttf);
Delete(ttq);
}

View file

@ -27,7 +27,7 @@ Swig_print_tags(DOH *obj, DOH *root) {
DOH *croot, *newroot;
DOH *cobj;
if (!root) croot = NewString("");
if (!root) croot = NewStringEmpty();
else croot = root;
while (obj) {

View file

@ -416,8 +416,8 @@ Swig_typemap_apply(ParmList *src, ParmList *dest) {
/* Printf(stdout,"apply : %s --> %s\n", ParmList_str(src), ParmList_str(dest)); */
/* Create type signature of source */
ssig = NewString("");
dsig = NewString("");
ssig = NewStringEmpty();
dsig = NewStringEmpty();
p = src;
dp = dest;
lastp = 0;
@ -536,7 +536,7 @@ Swig_typemap_clear_apply(Parm *parms) {
String *name;
/* Create a type signature of the parameters */
tsig = NewString("");
tsig = NewStringEmpty();
p = parms;
lastp = 0;
while (p) {
@ -822,7 +822,7 @@ void typemap_replace_vars(String *s, ParmList *locals, SwigType *type, SwigType
int i;
if (SwigType_array_ndim(type) != SwigType_array_ndim(ftype)) type = ftype;
ndim = SwigType_array_ndim(type);
size = NewString("");
size = NewStringEmpty();
for (i = 0; i < ndim; i++) {
String *dim = SwigType_array_getdim(type,i);
if (index == 1) {
@ -1098,7 +1098,7 @@ static void typemap_locals(DOHString *s, ParmList *l, Wrapper *f, int argnum) {
String *str;
int isglobal = 0;
str = NewString("");
str = NewStringEmpty();
if (Strncmp(pn,"_global_",8) == 0) {
isglobal = 1;
@ -1392,7 +1392,7 @@ Printf(stdout, "Swig_typemap_lookup %s [%s %s]\n", op, type, pname ? pname : "NO
void
Swig_typemap_attach_kwargs(Hash *tm, const String_or_char *op, Parm *p) {
String *temp = NewString("");
String *temp = NewStringEmpty();
Parm *kw = Getattr(tm,k_kwargs);
while (kw) {
String *value = Copy(Getattr(kw,k_value));

View file

@ -564,7 +564,7 @@ SwigType *
SwigType_pop_arrays(SwigType *t) {
String *ta;
assert(SwigType_isarray(t));
ta = NewString("");
ta = NewStringEmpty();
while (SwigType_isarray(t)) {
SwigType *td = SwigType_pop(t);
Append(ta,td);
@ -825,7 +825,7 @@ SwigType_templatesuffix(const SwigType *t) {
}
c++;
}
return NewString("");
return NewStringEmpty();
}
/* -----------------------------------------------------------------------------
@ -969,7 +969,7 @@ SwigType_prefix(const SwigType *t) {
return r;
}
}
return NewString("");
return NewStringEmpty();
}
/* -----------------------------------------------------------------------------
@ -990,7 +990,7 @@ SwigType_strip_qualifiers(SwigType *t) {
if (r) return Copy(r);
l = SwigType_split(t);
r = NewString("");
r = NewStringEmpty();
for (ei = First(l);ei.item; ei = Next(ei)) {
if (SwigType_isqualifier(ei.item)) continue;

View file

@ -120,6 +120,7 @@ static String *k_typetab = 0;
static String *k_inherit = 0;
static String *k_parent = 0;
static String *k_value = 0;
static String *k_nodetype = 0;
/*
Enable this one if your language fully support SwigValueWrapper<T>.
@ -157,6 +158,7 @@ void SwigType_typesystem_init() {
k_inherit = NewString("inherit");
k_parent = NewString("parent");
k_value = NewString("value");
k_nodetype = NewString("nodeType");
if (global_scope) Delete(global_scope);
if (scopes) Delete(scopes);
@ -563,7 +565,7 @@ SwigType *SwigType_typedef_resolve(SwigType *t) {
/*
if (!noscope) {
noscope = NewString("");
noscope = NewStringEmpty();
}
*/
@ -661,7 +663,7 @@ SwigType *SwigType_typedef_resolve(SwigType *t) {
}
}
if (type && (Strcmp(base,type) == 0)) {
if (type && (StringEqual(base,type))) {
if (newtype) Delete(type);
Delete(base);
Delete(namebase);
@ -862,7 +864,7 @@ SwigType *SwigType_typedef_qualified(SwigType *t)
return rc;
}
result = NewString("");
result = NewStringEmpty();
elements = SwigType_split(t);
len = Len(elements);
for (i = 0; i < len; i++) {
@ -943,7 +945,7 @@ SwigType *SwigType_typedef_qualified(SwigType *t)
pi = First(parms);
while ((p = pi.item)) {
String *qt = SwigType_typedef_qualified(p);
if ((Strcmp(qt,p) == 0)) { /* && (!Swig_scopename_check(qt))) */
if (StringEqual(qt,p)) { /* && (!Swig_scopename_check(qt))) */
/* No change in value. It is entirely possible that the parameter is an integer value.
If there is a symbol table associated with this scope, we're going to check for this */
@ -955,7 +957,8 @@ SwigType *SwigType_typedef_qualified(SwigType *t)
if (n == lastnode) break;
lastnode = n;
if (n) {
if (Strcmp(nodeType(n),"enumitem") == 0) {
char *ntype = Char(Getattr(n,k_nodetype));
if (strcmp(ntype,"enumitem") == 0) {
/* An enum item. Generate a fully qualified name */
String *qn = Swig_symbol_qualified(n);
if (Len(qn)) {
@ -968,7 +971,7 @@ SwigType *SwigType_typedef_qualified(SwigType *t)
Delete(qn);
break;
}
} else if ((Strcmp(nodeType(n),"cdecl") == 0) && (Getattr(n,k_value))) {
} else if ((strcmp(ntype,"cdecl") == 0) && (Getattr(n,k_value))) {
Delete(value);
value = Copy(Getattr(n,k_value));
continue;
@ -1851,10 +1854,10 @@ SwigType_emit_type_table(File *f_forward, File *f_table) {
Printf(stdout,"%s\n", r_clientdata);
#endif
table = NewString("");
types = NewString("");
cast = NewString("");
cast_init = NewString("");
table = NewStringEmpty();
types = NewStringEmpty();
cast = NewStringEmpty();
cast_init = NewStringEmpty();
imported_types = NewHash("");
Printf(table,"static swig_type_info *swig_type_initial[] = {\n");
@ -1873,7 +1876,7 @@ SwigType_emit_type_table(File *f_forward, File *f_table) {
String *rn;
const String *cd;
cast_temp = NewString("");
cast_temp = NewStringEmpty();
Printv(types,"static swig_type_info _swigt_", ki.item, " = {", NIL);
Append(table_list, ki.item);

View file

@ -33,9 +33,9 @@ NewWrapper() {
Wrapper *w;
w = (Wrapper *) malloc(sizeof(Wrapper));
w->localh = NewHash();
w->locals = NewString("");
w->code = NewString("");
w->def = NewString("");
w->locals = NewStringEmpty();
w->code = NewStringEmpty();
w->def = NewStringEmpty();
return w;
}
@ -81,7 +81,7 @@ Wrapper_pretty_print(String *str, File *f) {
int plevel = 0;
int label = 0;
ts = NewString("");
ts = NewStringEmpty();
Seek(str,0, SEEK_SET);
Clear(ts);
while ((c = Getc(str)) != EOF) {
@ -219,8 +219,8 @@ Wrapper_compact_print(String *str, File *f) {
int empty = 1;
int indent = 2;
ts = NewString("");
tf = NewString("");
ts = NewStringEmpty();
tf = NewStringEmpty();
Seek(str,0, SEEK_SET);
Clear(ts);
Clear(tf);
@ -392,7 +392,7 @@ void
Wrapper_print(Wrapper *w, File *f) {
String *str;
str = NewString("");
str = NewStringEmpty();
Printf(str,"%s\n", w->def);
Printf(str,"%s\n", w->locals);
Printf(str,"%s\n", w->code);
@ -434,7 +434,7 @@ Wrapper_add_localv(Wrapper *w, const String_or_char *name, ...) {
int ret;
String *decl;
DOH *obj;
decl = NewString("");
decl = NewStringEmpty();
va_start(ap,name);
obj = va_arg(ap,void *);
@ -509,7 +509,7 @@ Wrapper_new_localv(Wrapper *w, const String_or_char *name, ...) {
char *ret;
String *decl;
DOH *obj;
decl = NewString("");
decl = NewStringEmpty();
va_start(ap,name);
obj = va_arg(ap,void *);