add NewStringEmpty, use more StringEuqual and less Strcmp

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7897 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-11-28 17:32:56 +00:00
commit cf1585fef7
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 */ /* Now, parse the new location out of the locator string */
{ {
String *fn = NewString(""); String *fn = NewStringEmpty();
Putc(c,fn); Putc(c,fn);
while ((c = Getc(loc)) != EOF) { while ((c = Getc(loc)) != EOF) {
@ -143,9 +143,9 @@ scanner_locator(String *loc) {
void scanner_init() { void scanner_init() {
yybuffer = (char *) malloc(YYBSIZE); yybuffer = (char *) malloc(YYBSIZE);
scan_init = 1; scan_init = 1;
header = NewString(""); header = NewStringEmpty();
comment = NewString(""); comment = NewStringEmpty();
scanner_ccode = NewString(""); scanner_ccode = NewStringEmpty();
} }
/************************************************************** /**************************************************************

View file

@ -508,9 +508,9 @@ static void add_symbols(Node *n) {
if (Getattr(n,"sym:weak")) { if (Getattr(n,"sym:weak")) {
Setattr(n,"sym:name",symname); Setattr(n,"sym:name",symname);
} else { } else {
String *e = NewString(""); String *e = NewStringEmpty();
String *en = NewString(""); String *en = NewStringEmpty();
String *ec = NewString(""); String *ec = NewStringEmpty();
int redefined = need_redefined_warn(n,c,inclass); int redefined = need_redefined_warn(n,c,inclass);
if (redefined) { if (redefined) {
Printf(en,"Identifier '%s' redefined (ignored)",symname); 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); csym = Swig_symbol_add(symname,n);
if (csym != n) { if (csym != n) {
/* Conflict with previous definition. Nuke previous definition */ /* Conflict with previous definition. Nuke previous definition */
String *e = NewString(""); String *e = NewStringEmpty();
String *en = NewString(""); String *en = NewStringEmpty();
String *ec = NewString(""); String *ec = NewStringEmpty();
Printf(ec,"Identifier '%s' redefined by %%extend (ignored),",symname); Printf(ec,"Identifier '%s' redefined by %%extend (ignored),",symname);
Printf(en,"%%extend definition of '%s'.",symname); Printf(en,"%%extend definition of '%s'.",symname);
SWIG_WARN_NODE_BEGIN(n); SWIG_WARN_NODE_BEGIN(n);
@ -1104,7 +1104,7 @@ static void single_new_feature(const char *featurename, String *val, Hash *featu
if (declaratorid) { if (declaratorid) {
fixname = feature_identifier_fix(declaratorid); fixname = feature_identifier_fix(declaratorid);
} else { } else {
fixname = NewString(""); fixname = NewStringEmpty();
} }
if (Namespaceprefix) { if (Namespaceprefix) {
name = NewStringf("%s::%s",Namespaceprefix, fixname); name = NewStringf("%s::%s",Namespaceprefix, fixname);
@ -1899,7 +1899,7 @@ insert_directive : HBLOCK {
Setattr($$,"code",$1); Setattr($$,"code",$1);
} }
| INSERT LPAREN idstring RPAREN string { | INSERT LPAREN idstring RPAREN string {
String *code = NewString(""); String *code = NewStringEmpty();
$$ = new_node("insert"); $$ = new_node("insert");
Setattr($$,"section",$3); Setattr($$,"section",$3);
Setattr($$,"code",code); Setattr($$,"code",code);
@ -2914,7 +2914,7 @@ c_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end {
Setattr($$,"name",ty); Setattr($$,"name",ty);
if ($6.have_parms) { if ($6.have_parms) {
SwigType *decl = NewString(""); SwigType *decl = NewStringEmpty();
SwigType_add_function(decl,$6.parms); SwigType_add_function(decl,$6.parms);
Setattr($$,"decl",decl); Setattr($$,"decl",decl);
Setattr($$,"parms",$6.parms); Setattr($$,"parms",$6.parms);
@ -3154,7 +3154,7 @@ cpp_class_decl :
Swig_symbol_newscope(); Swig_symbol_newscope();
cparse_start_line = cparse_line; cparse_start_line = cparse_line;
inclass = 1; inclass = 1;
Classprefix = NewString(""); Classprefix = NewStringEmpty();
Namespaceprefix = Swig_symbol_qualifiedscopename(0); Namespaceprefix = Swig_symbol_qualifiedscopename(0);
} cpp_members RBRACE declarator c_decl_tail { } cpp_members RBRACE declarator c_decl_tail {
String *unnamed; String *unnamed;
@ -3757,7 +3757,7 @@ cpp_member : c_declaration { $$ = $1; }
cpp_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end { cpp_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end {
if (Classprefix) { if (Classprefix) {
SwigType *decl = NewString(""); SwigType *decl = NewStringEmpty();
$$ = new_node("constructor"); $$ = new_node("constructor");
Setattr($$,"name",$2); Setattr($$,"name",$2);
Setattr($$,"parms",$4); Setattr($$,"parms",$4);
@ -3784,7 +3784,7 @@ cpp_destructor_decl : NOT idtemplate LPAREN parms RPAREN cpp_end {
Setattr($$,"code",Copy(scanner_ccode)); Setattr($$,"code",Copy(scanner_ccode));
} }
{ {
String *decl = NewString(""); String *decl = NewStringEmpty();
SwigType_add_function(decl,$4); SwigType_add_function(decl,$4);
Setattr($$,"decl",decl); Setattr($$,"decl",decl);
} }
@ -3819,7 +3819,7 @@ cpp_destructor_decl : NOT idtemplate LPAREN parms RPAREN cpp_end {
Setattr($$,"code",Copy(scanner_ccode)); Setattr($$,"code",Copy(scanner_ccode));
} }
{ {
String *decl = NewString(""); String *decl = NewStringEmpty();
SwigType_add_function(decl,$5); SwigType_add_function(decl,$5);
Setattr($$,"decl",decl); Setattr($$,"decl",decl);
} }
@ -3849,7 +3849,7 @@ cpp_conversion_operator : storage_class COPERATOR type pointer LPAREN parms RPAR
$$ = new_node("cdecl"); $$ = new_node("cdecl");
Setattr($$,"type",$3); Setattr($$,"type",$3);
Setattr($$,"name",$2); Setattr($$,"name",$2);
decl = NewString(""); decl = NewStringEmpty();
SwigType_add_reference(decl); SwigType_add_reference(decl);
SwigType_add_function(decl,$6); SwigType_add_function(decl,$6);
if ($8.qualifier) { 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 { | storage_class COPERATOR type LPAREN parms RPAREN cpp_vend {
String *t = NewString(""); String *t = NewStringEmpty();
$$ = new_node("cdecl"); $$ = new_node("cdecl");
Setattr($$,"type",$3); Setattr($$,"type",$3);
Setattr($$,"name",$2); 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 */ /* Generate some code for a new class */
} else { } else {
Nested *n = (Nested *) malloc(sizeof(Nested)); Nested *n = (Nested *) malloc(sizeof(Nested));
n->code = NewString(""); n->code = NewStringEmpty();
Printv(n->code, "typedef ", $2, " ", Printv(n->code, "typedef ", $2, " ",
Char(scanner_ccode), " $classname_", $6.id, ";\n", NIL); Char(scanner_ccode), " $classname_", $6.id, ";\n", NIL);
n->name = Swig_copy_string($6.id); n->name = Swig_copy_string($6.id);
n->line = cparse_start_line; n->line = cparse_start_line;
n->type = NewString(""); n->type = NewStringEmpty();
n->kind = $2; n->kind = $2;
SwigType_push(n->type, $6.type); SwigType_push(n->type, $6.type);
n->next = 0; n->next = 0;
@ -3962,12 +3962,12 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line
} else if ($5.id) { } else if ($5.id) {
/* Generate some code for a new class */ /* Generate some code for a new class */
Nested *n = (Nested *) malloc(sizeof(Nested)); Nested *n = (Nested *) malloc(sizeof(Nested));
n->code = NewString(""); n->code = NewStringEmpty();
Printv(n->code, "typedef ", $2, " " , Printv(n->code, "typedef ", $2, " " ,
Char(scanner_ccode), " $classname_", $5.id, ";\n",NIL); Char(scanner_ccode), " $classname_", $5.id, ";\n",NIL);
n->name = Swig_copy_string($5.id); n->name = Swig_copy_string($5.id);
n->line = cparse_start_line; n->line = cparse_start_line;
n->type = NewString(""); n->type = NewStringEmpty();
n->kind = $2; n->kind = $2;
SwigType_push(n->type,$5.type); SwigType_push(n->type,$5.type);
n->next = 0; n->next = 0;
@ -4352,11 +4352,11 @@ declarator : pointer notso_direct_declarator {
} }
| direct_declarator { | direct_declarator {
$$ = $1; $$ = $1;
if (!$$.type) $$.type = NewString(""); if (!$$.type) $$.type = NewStringEmpty();
} }
| AND notso_direct_declarator { | AND notso_direct_declarator {
$$ = $2; $$ = $2;
$$.type = NewString(""); $$.type = NewStringEmpty();
SwigType_add_reference($$.type); SwigType_add_reference($$.type);
if ($2.type) { if ($2.type) {
SwigType_push($$.type,$2.type); SwigType_push($$.type,$2.type);
@ -4364,7 +4364,7 @@ declarator : pointer notso_direct_declarator {
} }
} }
| idcolon DSTAR notso_direct_declarator { | idcolon DSTAR notso_direct_declarator {
SwigType *t = NewString(""); SwigType *t = NewStringEmpty();
$$ = $3; $$ = $3;
SwigType_add_memberpointer(t,$1); SwigType_add_memberpointer(t,$1);
@ -4375,7 +4375,7 @@ declarator : pointer notso_direct_declarator {
$$.type = t; $$.type = t;
} }
| pointer idcolon DSTAR notso_direct_declarator { | pointer idcolon DSTAR notso_direct_declarator {
SwigType *t = NewString(""); SwigType *t = NewStringEmpty();
$$ = $4; $$ = $4;
SwigType_add_memberpointer(t,$2); SwigType_add_memberpointer(t,$2);
SwigType_push($1,t); SwigType_push($1,t);
@ -4397,7 +4397,7 @@ declarator : pointer notso_direct_declarator {
$$.type = $1; $$.type = $1;
} }
| idcolon DSTAR AND notso_direct_declarator { | idcolon DSTAR AND notso_direct_declarator {
SwigType *t = NewString(""); SwigType *t = NewStringEmpty();
$$ = $4; $$ = $4;
SwigType_add_memberpointer(t,$1); SwigType_add_memberpointer(t,$1);
SwigType_add_reference(t); SwigType_add_reference(t);
@ -4451,7 +4451,7 @@ notso_direct_declarator : idcolon {
| LPAREN idcolon DSTAR notso_direct_declarator RPAREN { | LPAREN idcolon DSTAR notso_direct_declarator RPAREN {
SwigType *t; SwigType *t;
$$ = $4; $$ = $4;
t = NewString(""); t = NewStringEmpty();
SwigType_add_memberpointer(t,$2); SwigType_add_memberpointer(t,$2);
if ($$.type) { if ($$.type) {
SwigType_push(t,$$.type); SwigType_push(t,$$.type);
@ -4462,7 +4462,7 @@ notso_direct_declarator : idcolon {
| notso_direct_declarator LBRACKET RBRACKET { | notso_direct_declarator LBRACKET RBRACKET {
SwigType *t; SwigType *t;
$$ = $1; $$ = $1;
t = NewString(""); t = NewStringEmpty();
SwigType_add_array(t,(char*)""); SwigType_add_array(t,(char*)"");
if ($$.type) { if ($$.type) {
SwigType_push(t,$$.type); SwigType_push(t,$$.type);
@ -4473,7 +4473,7 @@ notso_direct_declarator : idcolon {
| notso_direct_declarator LBRACKET expr RBRACKET { | notso_direct_declarator LBRACKET expr RBRACKET {
SwigType *t; SwigType *t;
$$ = $1; $$ = $1;
t = NewString(""); t = NewStringEmpty();
SwigType_add_array(t,$3.val); SwigType_add_array(t,$3.val);
if ($$.type) { if ($$.type) {
SwigType_push(t,$$.type); SwigType_push(t,$$.type);
@ -4484,7 +4484,7 @@ notso_direct_declarator : idcolon {
| notso_direct_declarator LPAREN parms RPAREN { | notso_direct_declarator LPAREN parms RPAREN {
SwigType *t; SwigType *t;
$$ = $1; $$ = $1;
t = NewString(""); t = NewStringEmpty();
SwigType_add_function(t,$3); SwigType_add_function(t,$3);
if (!$$.have_parms) { if (!$$.have_parms) {
$$.parms = $3; $$.parms = $3;
@ -4536,14 +4536,14 @@ direct_declarator : idcolon {
| LPAREN AND direct_declarator RPAREN { | LPAREN AND direct_declarator RPAREN {
$$ = $3; $$ = $3;
if (!$$.type) { if (!$$.type) {
$$.type = NewString(""); $$.type = NewStringEmpty();
} }
SwigType_add_reference($$.type); SwigType_add_reference($$.type);
} }
| LPAREN idcolon DSTAR direct_declarator RPAREN { | LPAREN idcolon DSTAR direct_declarator RPAREN {
SwigType *t; SwigType *t;
$$ = $4; $$ = $4;
t = NewString(""); t = NewStringEmpty();
SwigType_add_memberpointer(t,$2); SwigType_add_memberpointer(t,$2);
if ($$.type) { if ($$.type) {
SwigType_push(t,$$.type); SwigType_push(t,$$.type);
@ -4554,7 +4554,7 @@ direct_declarator : idcolon {
| direct_declarator LBRACKET RBRACKET { | direct_declarator LBRACKET RBRACKET {
SwigType *t; SwigType *t;
$$ = $1; $$ = $1;
t = NewString(""); t = NewStringEmpty();
SwigType_add_array(t,(char*)""); SwigType_add_array(t,(char*)"");
if ($$.type) { if ($$.type) {
SwigType_push(t,$$.type); SwigType_push(t,$$.type);
@ -4565,7 +4565,7 @@ direct_declarator : idcolon {
| direct_declarator LBRACKET expr RBRACKET { | direct_declarator LBRACKET expr RBRACKET {
SwigType *t; SwigType *t;
$$ = $1; $$ = $1;
t = NewString(""); t = NewStringEmpty();
SwigType_add_array(t,$3.val); SwigType_add_array(t,$3.val);
if ($$.type) { if ($$.type) {
SwigType_push(t,$$.type); SwigType_push(t,$$.type);
@ -4576,7 +4576,7 @@ direct_declarator : idcolon {
| direct_declarator LPAREN parms RPAREN { | direct_declarator LPAREN parms RPAREN {
SwigType *t; SwigType *t;
$$ = $1; $$ = $1;
t = NewString(""); t = NewStringEmpty();
SwigType_add_function(t,$3); SwigType_add_function(t,$3);
if (!$$.have_parms) { if (!$$.have_parms) {
$$.parms = $3; $$.parms = $3;
@ -4625,7 +4625,7 @@ abstract_declarator : pointer {
} }
| AND direct_abstract_declarator { | AND direct_abstract_declarator {
$$ = $2; $$ = $2;
$$.type = NewString(""); $$.type = NewStringEmpty();
SwigType_add_reference($$.type); SwigType_add_reference($$.type);
if ($2.type) { if ($2.type) {
SwigType_push($$.type,$2.type); SwigType_push($$.type,$2.type);
@ -4636,18 +4636,18 @@ abstract_declarator : pointer {
$$.id = 0; $$.id = 0;
$$.parms = 0; $$.parms = 0;
$$.have_parms = 0; $$.have_parms = 0;
$$.type = NewString(""); $$.type = NewStringEmpty();
SwigType_add_reference($$.type); SwigType_add_reference($$.type);
} }
| idcolon DSTAR { | idcolon DSTAR {
$$.type = NewString(""); $$.type = NewStringEmpty();
SwigType_add_memberpointer($$.type,$1); SwigType_add_memberpointer($$.type,$1);
$$.id = 0; $$.id = 0;
$$.parms = 0; $$.parms = 0;
$$.have_parms = 0; $$.have_parms = 0;
} }
| pointer idcolon DSTAR { | pointer idcolon DSTAR {
SwigType *t = NewString(""); SwigType *t = NewStringEmpty();
$$.type = $1; $$.type = $1;
$$.id = 0; $$.id = 0;
$$.parms = 0; $$.parms = 0;
@ -4670,7 +4670,7 @@ abstract_declarator : pointer {
direct_abstract_declarator : direct_abstract_declarator LBRACKET RBRACKET { direct_abstract_declarator : direct_abstract_declarator LBRACKET RBRACKET {
SwigType *t; SwigType *t;
$$ = $1; $$ = $1;
t = NewString(""); t = NewStringEmpty();
SwigType_add_array(t,(char*)""); SwigType_add_array(t,(char*)"");
if ($$.type) { if ($$.type) {
SwigType_push(t,$$.type); SwigType_push(t,$$.type);
@ -4681,7 +4681,7 @@ direct_abstract_declarator : direct_abstract_declarator LBRACKET RBRACKET {
| direct_abstract_declarator LBRACKET expr RBRACKET { | direct_abstract_declarator LBRACKET expr RBRACKET {
SwigType *t; SwigType *t;
$$ = $1; $$ = $1;
t = NewString(""); t = NewStringEmpty();
SwigType_add_array(t,$3.val); SwigType_add_array(t,$3.val);
if ($$.type) { if ($$.type) {
SwigType_push(t,$$.type); SwigType_push(t,$$.type);
@ -4690,14 +4690,14 @@ direct_abstract_declarator : direct_abstract_declarator LBRACKET RBRACKET {
$$.type = t; $$.type = t;
} }
| LBRACKET RBRACKET { | LBRACKET RBRACKET {
$$.type = NewString(""); $$.type = NewStringEmpty();
$$.id = 0; $$.id = 0;
$$.parms = 0; $$.parms = 0;
$$.have_parms = 0; $$.have_parms = 0;
SwigType_add_array($$.type,(char*)""); SwigType_add_array($$.type,(char*)"");
} }
| LBRACKET expr RBRACKET { | LBRACKET expr RBRACKET {
$$.type = NewString(""); $$.type = NewStringEmpty();
$$.id = 0; $$.id = 0;
$$.parms = 0; $$.parms = 0;
$$.have_parms = 0; $$.have_parms = 0;
@ -4709,7 +4709,7 @@ direct_abstract_declarator : direct_abstract_declarator LBRACKET RBRACKET {
| direct_abstract_declarator LPAREN parms RPAREN { | direct_abstract_declarator LPAREN parms RPAREN {
SwigType *t; SwigType *t;
$$ = $1; $$ = $1;
t = NewString(""); t = NewStringEmpty();
SwigType_add_function(t,$3); SwigType_add_function(t,$3);
if (!$$.type) { if (!$$.type) {
$$.type = t; $$.type = t;
@ -4724,7 +4724,7 @@ direct_abstract_declarator : direct_abstract_declarator LBRACKET RBRACKET {
} }
} }
| LPAREN parms RPAREN { | LPAREN parms RPAREN {
$$.type = NewString(""); $$.type = NewStringEmpty();
SwigType_add_function($$.type,$2); SwigType_add_function($$.type,$2);
$$.parms = $2; $$.parms = $2;
$$.have_parms = 1; $$.have_parms = 1;
@ -4734,31 +4734,31 @@ direct_abstract_declarator : direct_abstract_declarator LBRACKET RBRACKET {
pointer : STAR type_qualifier pointer { pointer : STAR type_qualifier pointer {
$$ = NewString(""); $$ = NewStringEmpty();
SwigType_add_pointer($$); SwigType_add_pointer($$);
SwigType_push($$,$2); SwigType_push($$,$2);
SwigType_push($$,$3); SwigType_push($$,$3);
Delete($3); Delete($3);
} }
| STAR pointer { | STAR pointer {
$$ = NewString(""); $$ = NewStringEmpty();
SwigType_add_pointer($$); SwigType_add_pointer($$);
SwigType_push($$,$2); SwigType_push($$,$2);
Delete($2); Delete($2);
} }
| STAR type_qualifier { | STAR type_qualifier {
$$ = NewString(""); $$ = NewStringEmpty();
SwigType_add_pointer($$); SwigType_add_pointer($$);
SwigType_push($$,$2); SwigType_push($$,$2);
} }
| STAR { | STAR {
$$ = NewString(""); $$ = NewStringEmpty();
SwigType_add_pointer($$); SwigType_add_pointer($$);
} }
; ;
type_qualifier : type_qualifier_raw { type_qualifier : type_qualifier_raw {
$$ = NewString(""); $$ = NewStringEmpty();
if ($1) SwigType_add_qualifier($$,$1); if ($1) SwigType_add_qualifier($$,$1);
} }
| type_qualifier_raw type_qualifier { | type_qualifier_raw type_qualifier {
@ -5361,7 +5361,7 @@ mem_initializer : idcolon LPAREN {
; ;
template_decl : LESSTHAN valparms GREATERTHAN { template_decl : LESSTHAN valparms GREATERTHAN {
String *s = NewString(""); String *s = NewStringEmpty();
SwigType_add_template(s,$2); SwigType_add_template(s,$2);
$$ = Char(s); $$ = Char(s);
scanner_last_id(1); 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 (!n) return 0;
if (Getattr(n,k_error)) 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 */ /* Change the node type back to normal */
if (!expanded) { if (!expanded) {
expanded = 1; expanded = 1;
@ -138,7 +138,7 @@ cparse_template_expand(Node *n, String *tname, String *rname, String *templatear
set_nodeType(n,k_template); set_nodeType(n,k_template);
return ret; return ret;
} }
} else if (Strcmp(nodeType,k_cdecl) == 0) { } else if (StringEqual(nodeType,k_cdecl)) {
/* A simple C declaration */ /* A simple C declaration */
SwigType *t, *v, *d; SwigType *t, *v, *d;
String *code; 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_parms), cpatchlist, typelist);
add_parms(Getattr(n,k_throws), 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 */ /* Patch base classes */
{ {
int b = 0; int b = 0;
@ -187,7 +187,7 @@ cparse_template_expand(Node *n, String *tname, String *rname, String *templatear
cn = nextSibling(cn); cn = nextSibling(cn);
} }
} }
} else if (Strcmp(nodeType,k_constructor) == 0) { } else if (StringEqual(nodeType,k_constructor)) {
String *name = Getattr(n,k_name); String *name = Getattr(n,k_name);
if (!(Getattr(n,k_templatetype))) { if (!(Getattr(n,k_templatetype))) {
String *symname; String *symname;
@ -222,7 +222,7 @@ cparse_template_expand(Node *n, String *tname, String *rname, String *templatear
Append(typelist, Getattr(n,k_decl)); Append(typelist, Getattr(n,k_decl));
add_parms(Getattr(n,k_parms), cpatchlist, typelist); add_parms(Getattr(n,k_parms), cpatchlist, typelist);
add_parms(Getattr(n,k_throws), 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); String *name = Getattr(n,k_name);
if (Strstr(name,"<")) { if (Strstr(name,"<")) {
Append(patchlist,Getattr(n,k_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); Setattr(n,k_symname,name);
Append(cpatchlist,Getattr(n,k_code)); 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); String *uname = Getattr(n,k_uname);
if (uname) { if (uname) {
if (Strstr(uname,"<")) { if (Strstr(uname,"<")) {
@ -300,7 +300,7 @@ Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab *ts
typelist = NewList(); typelist = NewList();
{ {
String *tmp = NewString(""); String *tmp = NewStringEmpty();
if (tparms) { if (tparms) {
SwigType_add_template(tmp,tparms); SwigType_add_template(tmp,tparms);
} }
@ -484,7 +484,7 @@ template_locate(String *name, Parm *tparms, Symtab *tscope) {
Parm *parms; Parm *parms;
Parm *targs; Parm *targs;
tname = NewString(name); tname = Copy(name);
parms = CopyParmList(tparms); parms = CopyParmList(tparms);
/* Search for generic template */ /* Search for generic template */
@ -526,7 +526,7 @@ template_locate(String *name, Parm *tparms, Symtab *tscope) {
n = Swig_symbol_clookup_local(tname,0); n = Swig_symbol_clookup_local(tname,0);
if (!n) { if (!n) {
SwigType *rname = Swig_symbol_typedef_reduce(tname,tscope); SwigType *rname = Swig_symbol_typedef_reduce(tname,tscope);
if (Strcmp(rname,tname)) { if (!StringEqual(rname,tname)) {
if (template_debug) { if (template_debug) {
Printf(stdout," searching: '%s' (exact specialization)\n", rname); Printf(stdout," searching: '%s' (exact specialization)\n", rname);
} }
@ -537,7 +537,7 @@ template_locate(String *name, Parm *tparms, Symtab *tscope) {
if (n) { if (n) {
Node *tn; Node *tn;
String *nodeType = Getattr(n,k_nodetype); 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); tn = Getattr(n,k_template);
if (tn) { if (tn) {
n = tn; n = tn;
@ -613,7 +613,7 @@ template_locate(String *name, Parm *tparms, Symtab *tscope) {
if (template_debug) { if (template_debug) {
Printf(stdout," searching: '%s' (partial specialization - %s)\n", ss, pi.item); 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); Append(mpartials,pi.item);
} }
Delete(ss); 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); Swig_error(cparse_file, cparse_line, "Template '%s' undefined.\n", name);
} else if (n) { } else if (n) {
String *nodeType = Getattr(n,k_nodetype); 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); Swig_error(cparse_file, cparse_line, "'%s' is not defined as a template. (%s)\n", name, nodeType);
n = 0; n = 0;
} }
@ -681,8 +681,8 @@ Swig_cparse_template_locate(String *name, Parm *tparms, Symtab *tscope) {
if (n) { if (n) {
int isclass = 0; int isclass = 0;
assert(Strcmp(nodeType,k_template) == 0); assert(StringEqual(nodeType,k_template));
isclass = (Strcmp(Getattr(n,k_templatetype),k_class) == 0); isclass = (StringEqual(Getattr(n,k_templatetype),k_class));
if (!isclass) { if (!isclass) {
/* If not a templated class we must have a templated function. /* 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 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 void
DohSetInt(DOH *obj, const DOH *name, int value) { DohSetInt(DOH *obj, const DOH *name, int value) {
DOH *temp; DOH *temp;
temp = NewString(""); temp = NewStringEmpty();
Printf(temp,"%d",value); Printf(temp,"%d",value);
Setattr(obj,(DOH *) name,temp); Setattr(obj,(DOH *) name,temp);
} }
@ -467,7 +467,7 @@ DohSetInt(DOH *obj, const DOH *name, int value) {
void void
DohSetDouble(DOH *obj, const DOH *name, double value) { DohSetDouble(DOH *obj, const DOH *name, double value) {
DOH *temp; DOH *temp;
temp = NewString(""); temp = NewStringEmpty();
Printf(temp,"%0.17f",value); Printf(temp,"%0.17f",value);
Setattr(obj,(DOH *) name,temp); Setattr(obj,(DOH *) name,temp);
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -257,10 +257,10 @@ Hash *Preprocessor_define(const String_or_char *_str, int swigmacro)
skip_whitespace(str,0); skip_whitespace(str,0);
/* Now look for a macro name */ /* Now look for a macro name */
macroname = NewString(""); macroname = NewStringEmpty();
while ((c = StringGetc(str)) != EOF) { while ((c = StringGetc(str)) != EOF) {
if (c == '(') { if (c == '(') {
argstr = NewString(""); argstr = NewStringEmpty();
copy_location(str,argstr); copy_location(str,argstr);
/* It is a macro. Go extract it's argument string */ /* It is a macro. Go extract it's argument string */
while ((c = StringGetc(str)) != EOF) { while ((c = StringGetc(str)) != EOF) {
@ -292,7 +292,7 @@ Hash *Preprocessor_define(const String_or_char *_str, int swigmacro)
} }
if (!swigmacro) if (!swigmacro)
skip_whitespace(str,0); skip_whitespace(str,0);
macrovalue = NewString(""); macrovalue = NewStringEmpty();
while ((c = StringGetc(str)) != EOF) { while ((c = StringGetc(str)) != EOF) {
StringPutc(c,macrovalue); StringPutc(c,macrovalue);
} }
@ -302,7 +302,7 @@ Hash *Preprocessor_define(const String_or_char *_str, int swigmacro)
String *argname, *varargname; String *argname, *varargname;
arglist = NewList(); arglist = NewList();
Seek(argstr,0,SEEK_SET); Seek(argstr,0,SEEK_SET);
argname = NewString(""); argname = NewStringEmpty();
while ((c = StringGetc(argstr)) != EOF) { while ((c = StringGetc(argstr)) != EOF) {
if (c == ',') { if (c == ',') {
varargname = Macro_vararg_name(argname, str); varargname = Macro_vararg_name(argname, str);
@ -312,7 +312,7 @@ Hash *Preprocessor_define(const String_or_char *_str, int swigmacro)
Append(arglist,argname); Append(arglist,argname);
} }
Delete(argname); Delete(argname);
argname = NewString(""); argname = NewStringEmpty();
} else if (isidchar(c) || (c == '.')) { } else if (isidchar(c) || (c == '.')) {
StringPutc(c,argname); StringPutc(c,argname);
} else if (!(isspace(c) || (c == '\\'))) { } else if (!(isspace(c) || (c == '\\'))) {
@ -495,7 +495,7 @@ find_args(String *s)
skip_whitespace(s,0); /* Skip leading whitespace */ skip_whitespace(s,0); /* Skip leading whitespace */
c = StringGetc(s); c = StringGetc(s);
} }
str = NewString(""); str = NewStringEmpty();
copy_location(s,str); copy_location(s,str);
level = 0; level = 0;
while (c != EOF) { while (c != EOF) {
@ -549,7 +549,7 @@ get_filename(String *str, int* sysfile) {
int c; int c;
skip_whitespace(str,0); skip_whitespace(str,0);
fn = NewString(""); fn = NewStringEmpty();
copy_location(str,fn); copy_location(str,fn);
c = StringGetc(str); c = StringGetc(str);
*sysfile = 0; *sysfile = 0;
@ -610,7 +610,8 @@ get_options(String *str) {
static String * static String *
expand_macro(String *name, List *args) 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 *); DOH *Preprocessor_replace(DOH *);
int i, l; int i, l;
int isvarargs = 0; int isvarargs = 0;
@ -622,7 +623,7 @@ expand_macro(String *name, List *args)
macro = HashGetAttr(symbols,name); macro = HashGetAttr(symbols,name);
if (!macro) return 0; if (!macro) return 0;
if (HashGetAttr(macro,k_expanded)) { if (HashGetAttr(macro,k_expanded)) {
ns = NewString(""); ns = NewStringEmpty();
StringAppend(ns,name); StringAppend(ns,name);
if (args) { if (args) {
if (Len(args)) if (Len(args))
@ -648,7 +649,7 @@ expand_macro(String *name, List *args)
if (Len(args) >= (Len(margs)-1)) { if (Len(args) >= (Len(margs)-1)) {
int i; int i;
int vi, na; int vi, na;
String *vararg = NewString(""); String *vararg = NewStringEmpty();
vi = Len(margs)-1; vi = Len(margs)-1;
na = Len(args); na = Len(args);
for (i = vi; i < na; i++) { 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 /* Tag the macro as being expanded. This is to avoid recursion in
macro expansion */ macro expansion */
temp = NewString(""); temp = NewStringEmpty();
tempa = NewString(""); tempa = NewStringEmpty();
if (args && margs) { if (args && margs) {
l = Len(margs); l = Len(margs);
for (i = 0; i < l; i++) { for (i = 0; i < l; i++) {
@ -698,7 +699,7 @@ expand_macro(String *name, List *args)
arg = Getitem(args,i); /* Get an argument value */ arg = Getitem(args,i); /* Get an argument value */
reparg = Preprocessor_replace(arg); reparg = Preprocessor_replace(arg);
aname = Getitem(margs,i); /* Get macro argument name */ 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 */ /* Try to replace a quoted version of the argument */
Clear(temp); Clear(temp);
Clear(tempa); Clear(tempa);
@ -706,7 +707,7 @@ expand_macro(String *name, List *args)
Printf(tempa,"\"%s\"",arg); Printf(tempa,"\"%s\"",arg);
Replace(ns, temp, tempa, DOH_REPLACE_ID_END); Replace(ns, temp, tempa, DOH_REPLACE_ID_END);
} }
if (strstr(Char(ns),"\002")) { if (strstr(StringChar(ns),"\002")) {
/* Look for concatenation tokens */ /* Look for concatenation tokens */
Clear(temp); Clear(temp);
Clear(tempa); Clear(tempa);
@ -724,7 +725,7 @@ expand_macro(String *name, List *args)
version of the argument except that if the argument is already quoted version of the argument except that if the argument is already quoted
nothing happens */ nothing happens */
if (strstr(Char(ns),"`")) { if (strstr(StringChar(ns),"`")) {
String *rep; String *rep;
char *c; char *c;
Clear(temp); Clear(temp);
@ -742,14 +743,14 @@ expand_macro(String *name, List *args)
/* Non-standard mangle expansions. /* Non-standard mangle expansions.
The #@Name is replaced by mangle_arg(Name). */ The #@Name is replaced by mangle_arg(Name). */
if (strstr(Char(ns),"\004")) { if (strstr(StringChar(ns),"\004")) {
String* marg = Swig_string_mangle(arg); String* marg = Swig_string_mangle(arg);
Clear(temp); Clear(temp);
Printf(temp,"\004%s", aname); Printf(temp,"\004%s", aname);
Replace(ns, temp, marg, DOH_REPLACE_ID_END); Replace(ns, temp, marg, DOH_REPLACE_ID_END);
Delete(marg); Delete(marg);
} }
if (strstr(Char(ns),"\005")) { if (strstr(StringChar(ns),"\005")) {
String* marg = Swig_string_mangle(arg); String* marg = Swig_string_mangle(arg);
Clear(temp); Clear(temp);
Clear(tempa); 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 */ /* Zero length varargs macro argument. We search for commas that might appear before and nuke them */
char *a, *s, *t, *name; char *a, *s, *t, *name;
int namelen; int namelen;
s = Char(ns); s = StringChar(ns);
name = Char(aname); name = Char(aname);
namelen = Len(aname); namelen = Len(aname);
a = strstr(s,name); a = strstr(s,name);
@ -805,7 +806,7 @@ expand_macro(String *name, List *args)
if (HashGetAttr(macro,k_swigmacro)) { if (HashGetAttr(macro,k_swigmacro)) {
String *g; String *g;
String *f = NewString(""); String *f = NewStringEmpty();
Seek(e,0,SEEK_SET); Seek(e,0,SEEK_SET);
copy_location(macro,e); copy_location(macro,e);
g = Preprocessor_parse(e); g = Preprocessor_parse(e);
@ -860,12 +861,12 @@ Preprocessor_replace(DOH *s)
DOH *ns, *symbols, *m; DOH *ns, *symbols, *m;
int c, i, state = 0; int c, i, state = 0;
String *id = NewString(""); String *id = NewStringEmpty();
assert(cpp); assert(cpp);
symbols = HashGetAttr(cpp,k_symbols); symbols = HashGetAttr(cpp,k_symbols);
ns = NewString(""); ns = NewStringEmpty();
copy_location(s,ns); copy_location(s,ns);
Seek(s,0,SEEK_SET); Seek(s,0,SEEK_SET);
@ -907,7 +908,7 @@ Preprocessor_replace(DOH *s)
StringUngetc(c,s); StringUngetc(c,s);
args = find_args(s); args = find_args(s);
} else if (isidchar(c)) { } else if (isidchar(c)) {
DOH *arg = NewString(""); DOH *arg = NewStringEmpty();
args = NewList(); args = NewList();
StringPutc(c,arg); StringPutc(c,arg);
while (((c = StringGetc(s)) != EOF)) { while (((c = StringGetc(s)) != EOF)) {
@ -1149,13 +1150,13 @@ Preprocessor_parse(String *s)
/* Blow away all carriage returns */ /* Blow away all carriage returns */
Replace(s,"\015","",DOH_REPLACE_ANY); Replace(s,"\015","",DOH_REPLACE_ANY);
ns = NewString(""); /* Return result */ ns = NewStringEmpty(); /* Return result */
decl = NewString(""); decl = NewStringEmpty();
id = NewString(""); id = NewStringEmpty();
value = NewString(""); value = NewStringEmpty();
comment = NewString(""); comment = NewStringEmpty();
chunk = NewString(""); chunk = NewStringEmpty();
copy_location(s,chunk); copy_location(s,chunk);
copy_location(s,ns); copy_location(s,ns);
symbols = HashGetAttr(cpp,k_symbols); 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) { Swig_clocal(SwigType *t, const String_or_char *name, const String_or_char *value) {
String *decl; String *decl;
decl = NewString(""); decl = NewStringEmpty();
switch(SwigType_type(t)) { switch(SwigType_type(t)) {
case T_REFERENCE: 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 *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_char *decl) {
String *fcall; String *fcall;
fcall = NewString(""); fcall = NewStringEmpty();
switch(SwigType_type(t)) { switch(SwigType_type(t)) {
case T_VOID: case T_VOID:
break; break;
@ -289,7 +289,7 @@ Swig_cfunction_call(String_or_char *name, ParmList *parms) {
Parm *p = parms; Parm *p = parms;
String *nname; String *nname;
func = NewString(""); func = NewStringEmpty();
nname = SwigType_namestr(name); 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)->"; if (!self) self = (char *) "(this)->";
func = NewString(""); func = NewStringEmpty();
nname = SwigType_namestr(name); nname = SwigType_namestr(name);
if (!p) return func; if (!p) return func;
Append(func,self); Append(func,self);
@ -420,7 +420,7 @@ String *
Swig_cconstructor_call(String_or_char *name) { Swig_cconstructor_call(String_or_char *name) {
DOH *func; DOH *func;
func = NewString(""); func = NewStringEmpty();
Printf(func,"(%s *) calloc(1, sizeof(%s))", name, name); Printf(func,"(%s *) calloc(1, sizeof(%s))", name, name);
return func; return func;
} }
@ -449,7 +449,7 @@ Swig_cppconstructor_base_call(String_or_char *name, ParmList *parms, int skip_se
i++; i++;
} }
nname = SwigType_namestr(name); nname = SwigType_namestr(name);
func = NewString(""); func = NewStringEmpty();
Printf(func,"new %s(", nname); Printf(func,"new %s(", nname);
while (p) { while (p) {
String *pname; String *pname;
@ -625,7 +625,7 @@ Swig_cppdestructor_call(Node *n) {
String * String *
Swig_cmemberset_call(String_or_char *name, SwigType *type, String_or_char *self) { Swig_cmemberset_call(String_or_char *name, SwigType *type, String_or_char *self) {
String *func; String *func;
func = NewString(""); func = NewStringEmpty();
if (!self) self = NewString("(this)->"); if (!self) self = NewString("(this)->");
else self = NewString(self); else self = NewString(self);
Replaceall(self,"this",Swig_cparm_name(0,0)); 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)->"); if (!self) self = NewString("(this)->");
else self = NewString(self); else self = NewString(self);
Replaceall(self,"this",Swig_cparm_name(0,0)); Replaceall(self,"this",Swig_cparm_name(0,0));
func = NewString(""); func = NewStringEmpty();
Printf(func,"%s (%s%s)", Swig_wrapped_var_assign(t,""),self, name); Printf(func,"%s (%s%s)", Swig_wrapped_var_assign(t,""),self, name);
Delete(self); Delete(self);
return func; return func;
@ -976,7 +976,7 @@ Swig_ConstructorToFunction(Node *n, String *classname,
int abstract = Getattr(parent, "abstract") != 0; int abstract = Getattr(parent, "abstract") != 0;
String *name = Getattr(parent, "sym:name"); String *name = Getattr(parent, "sym:name");
String* directorname = NewStringf("SwigDirector_%s", name); String* directorname = NewStringf("SwigDirector_%s", name);
String* action = NewString(""); String* action = NewStringEmpty();
String* tmp_none_comparison = Copy(none_comparison); String* tmp_none_comparison = Copy(none_comparison);
String* director_call; String* director_call;
String* nodirector_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); va_start(ap,fmt);
out = NewString(""); out = NewStringEmpty();
vPrintf(out,fmt,ap); vPrintf(out,fmt,ap);
{ {
char temp[64], *t; char temp[64], *t;
@ -175,7 +175,7 @@ Swig_warnfilter(const String_or_char *wlist, int add) {
char *c; char *c;
String *s; String *s;
if (!filter) filter = NewString(""); if (!filter) filter = NewStringEmpty();
s = NewString(wlist); s = NewString(wlist);
c = Char(s); c = Char(s);
c = strtok(c,", "); c = strtok(c,", ");

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -146,7 +146,7 @@ SwigType *NewSwigType(int t) {
default : default :
break; break;
} }
return NewString(""); return NewStringEmpty();
} }
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
@ -357,6 +357,7 @@ void SwigType_add_default(String *def, SwigType *nr)
SwigType *SwigType_default(SwigType *t) { SwigType *SwigType_default(SwigType *t) {
String *r1, *def; String *r1, *def;
String *r = 0; String *r = 0;
char *cr;
#ifdef SWIG_DEFAULT_CACHE #ifdef SWIG_DEFAULT_CACHE
if (!default_cache) default_cache = NewHash(); if (!default_cache) default_cache = NewHash();
@ -388,20 +389,21 @@ SwigType *SwigType_default(SwigType *t) {
} }
Delete(q); Delete(q);
} }
if (Strcmp(r,"p.SWIGTYPE") == 0) { cr = Char(r);
if (strcmp(cr,"p.SWIGTYPE") == 0) {
def = NewString("SWIGTYPE"); def = NewString("SWIGTYPE");
} else if (SwigType_ispointer(r)) { } else if (SwigType_ispointer(r)) {
#ifdef SWIG_NEW_TYPE_DEFAULT #ifdef SWIG_NEW_TYPE_DEFAULT
SwigType *nr = Copy(r); SwigType *nr = Copy(r);
SwigType_del_pointer(nr); SwigType_del_pointer(nr);
def = SwigType_isfunction(nr) ? def = SwigType_isfunction(nr) ?
NewString("") : NewString("p."); NewStringEmpty() : NewString("p.");
SwigType_add_default(def, nr); SwigType_add_default(def, nr);
Delete(nr); Delete(nr);
#else #else
def = NewString("p.SWIGTYPE"); def = NewString("p.SWIGTYPE");
#endif #endif
} else if (Strcmp(r,"r.SWIGTYPE") == 0) { } else if (strcmp(cr,"r.SWIGTYPE") == 0) {
def = NewString("SWIGTYPE"); def = NewString("SWIGTYPE");
} else if (SwigType_isreference(r)) { } else if (SwigType_isreference(r)) {
#ifdef SWIG_NEW_TYPE_DEFAULT #ifdef SWIG_NEW_TYPE_DEFAULT
@ -414,9 +416,9 @@ SwigType *SwigType_default(SwigType *t) {
def = NewString("r.SWIGTYPE"); def = NewString("r.SWIGTYPE");
#endif #endif
} else if (SwigType_isarray(r)) { } else if (SwigType_isarray(r)) {
if (Strcmp(r,"a().SWIGTYPE") == 0) { if (strcmp(cr,"a().SWIGTYPE") == 0) {
def = NewString("p.SWIGTYPE"); def = NewString("p.SWIGTYPE");
} else if (Strcmp(r,"a(ANY).SWIGTYPE") == 0) { } else if (strcmp(cr,"a(ANY).SWIGTYPE") == 0) {
def = NewString("a().SWIGTYPE"); def = NewString("a().SWIGTYPE");
} else { } else {
int i, empty = 0; int i, empty = 0;
@ -444,19 +446,19 @@ SwigType *SwigType_default(SwigType *t) {
#endif #endif
} }
} else if (SwigType_ismemberpointer(r)) { } else if (SwigType_ismemberpointer(r)) {
if (Strcmp(r,"m(CLASS).SWIGTYPE") == 0) { if (strcmp(cr,"m(CLASS).SWIGTYPE") == 0) {
def = NewString("p.SWIGTYPE"); def = NewString("p.SWIGTYPE");
} else { } else {
def = NewString("m(CLASS).SWIGTYPE"); def = NewString("m(CLASS).SWIGTYPE");
} }
} else if (SwigType_isenum(r)) { } else if (SwigType_isenum(r)) {
if (Strcmp(r,"enum SWIGTYPE") == 0) { if (strcmp(cr,"enum SWIGTYPE") == 0) {
def = NewString("SWIGTYPE"); def = NewString("SWIGTYPE");
} else { } else {
def = NewString("enum SWIGTYPE"); def = NewString("enum SWIGTYPE");
} }
} else if (SwigType_isfunction(r)) { } else if (SwigType_isfunction(r)) {
if (Strcmp(r,"f(ANY).SWIGTYPE") == 0) { if (strcmp(cr,"f(ANY).SWIGTYPE") == 0) {
def = NewString("p.SWIGTYPE"); def = NewString("p.SWIGTYPE");
} else { } else {
def = NewString("p.f(ANY).SWIGTYPE"); 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 */ /* The cache produces strange results, see enum_template.i case */
Setattr(default_cache,t,Copy(def)); Setattr(default_cache,t,Copy(def));
#endif #endif
if (Strcmp(def,t) == 0) { if (StringEqual(def,t)) {
Delete(def); Delete(def);
def = 0; def = 0;
} }
@ -548,7 +550,7 @@ SwigType_str(SwigType *s, const String_or_char *id)
if (id) { if (id) {
result = NewString(id); result = NewString(id);
} else { } else {
result = NewString(""); result = NewStringEmpty();
} }
elements = SwigType_split(s); elements = SwigType_split(s);
@ -646,7 +648,7 @@ SwigType_ltype(SwigType *s) {
int firstarray = 1; int firstarray = 1;
int notypeconv = 0; int notypeconv = 0;
result = NewString(""); result = NewStringEmpty();
tc = Copy(s); tc = Copy(s);
/* Nuke all leading qualifiers */ /* Nuke all leading qualifiers */
while (SwigType_isqualifier(tc)) { while (SwigType_isqualifier(tc)) {
@ -756,7 +758,7 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
int isreference = 0; int isreference = 0;
int isarray = 0; int isarray = 0;
result = NewString(""); result = NewStringEmpty();
if (SwigType_isconst(s)) { if (SwigType_isconst(s)) {
tc = Copy(s); tc = Copy(s);
@ -858,7 +860,7 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
} }
Delete(elements); Delete(elements);
if (clear) { if (clear) {
cast = NewString(""); cast = NewStringEmpty();
} else { } else {
cast = NewStringf("(%s)",result); 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 *SwigType_lcaststr(SwigType *s, const String_or_char *name) {
String *result; String *result;
result = NewString(""); result = NewStringEmpty();
if (SwigType_isarray(s)) { if (SwigType_isarray(s)) {
Printf(result,"(%s)%s", SwigType_lstr(s,0),name); 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 (!Strstr(t,pat)) return;
if (Strcmp(t,pat) == 0) { if (StringEqual(t,pat)) {
Replace(t,pat,rep,DOH_REPLACE_ANY); Replace(t,pat,rep,DOH_REPLACE_ANY);
return; return;
} }
nt = NewString(""); nt = NewStringEmpty();
elem = SwigType_split(t); elem = SwigType_split(t);
for (i = 0; i < Len(elem); i++) { for (i = 0; i < Len(elem); i++) {
String *e = Getitem(elem,i); String *e = Getitem(elem,i);
if (SwigType_issimple(e)) { if (SwigType_issimple(e)) {
if (Strcmp(e,pat) == 0) { if (StringEqual(e,pat)) {
/* Replaces a type of the form 'pat' with 'rep<args>' */ /* Replaces a type of the form 'pat' with 'rep<args>' */
Replace(e,pat,rep,DOH_REPLACE_ANY); Replace(e,pat,rep,DOH_REPLACE_ANY);
} else if (SwigType_istemplate(e)) { } 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 */ /* common attribute keys, to avoid calling find_key all the times */
static String *empty_string = 0;
static String *k_allowstypedef = 0; static String *k_allowstypedef = 0;
static String *k_cdecl = 0; static String *k_cdecl = 0;
static String *k_coloncolon = 0; static String *k_coloncolon = 0;
@ -184,7 +185,6 @@ static String *k_csymnextSibling = 0;
static String *k_csympreviousSibling = 0; static String *k_csympreviousSibling = 0;
static String *k_csymtab = 0; static String *k_csymtab = 0;
static String *k_decl = 0; static String *k_decl = 0;
static String *k_empty = 0;
static String *k_enumitem = 0; static String *k_enumitem = 0;
static String *k_inherit = 0; static String *k_inherit = 0;
static String *k_name = 0; static String *k_name = 0;
@ -236,6 +236,7 @@ Swig_symbol_dump_symtable() {
void void
Swig_symbol_init() { Swig_symbol_init() {
empty_string = NewStringEmpty();
k_allowstypedef = NewString("allows_typedef"); k_allowstypedef = NewString("allows_typedef");
k_cdecl = NewString("cdecl"); k_cdecl = NewString("cdecl");
k_coloncolon = NewString("::"); k_coloncolon = NewString("::");
@ -244,7 +245,6 @@ Swig_symbol_init() {
k_csympreviousSibling = NewString("csym:previousSibling"); k_csympreviousSibling = NewString("csym:previousSibling");
k_csymtab = NewString("csymtab"); k_csymtab = NewString("csymtab");
k_decl = NewString("decl"); k_decl = NewString("decl");
k_empty = NewString("empty");
k_enumitem = NewString("enumitem"); k_enumitem = NewString("enumitem");
k_inherit = NewString("inherit"); k_inherit = NewString("inherit");
k_name = NewString("name"); k_name = NewString("name");
@ -281,7 +281,7 @@ Swig_symbol_init() {
/* Set the global scope */ /* Set the global scope */
symtabs = NewHash(); symtabs = NewHash();
Setattr(symtabs,k_empty,current_symtab); Setattr(symtabs,empty_string,current_symtab);
global_scope = current_symtab; global_scope = current_symtab;
} }
@ -326,7 +326,7 @@ Swig_symbol_getscopename() {
Symtab * Symtab *
Swig_symbol_getscope(const String_or_char *name) { Swig_symbol_getscope(const String_or_char *name) {
if (!symtabs) return 0; 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); return Getattr(symtabs,name);
} }
@ -350,7 +350,7 @@ Swig_symbol_qualifiedscopename(Symtab *symtab) {
name = HashGetAttr(symtab,k_name); name = HashGetAttr(symtab,k_name);
if (name) { if (name) {
if (!result) { if (!result) {
result = NewString(""); result = NewStringEmpty();
} }
if (StringLen(result)) { if (StringLen(result)) {
Printv(result,"::",name, NIL); Printv(result,"::",name, NIL);
@ -1023,7 +1023,7 @@ Swig_symbol_clookup(String_or_char *name, Symtab *n) {
if (Swig_scopename_check(name)) { if (Swig_scopename_check(name)) {
char *cname = Char(name); char *cname = Char(name);
if (strncmp(cname,"::",2) == 0) { if (strncmp(cname,"::",2) == 0) {
String *nname = NewString(Char(name)+2); String *nname = NewString(cname+2);
if (Swig_scopename_check(nname)) { if (Swig_scopename_check(nname)) {
s = symbol_lookup_qualified(nname,global_scope,0,0,0); 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)) { if (Swig_scopename_check(name)) {
char *cname = Char(name); char *cname = Char(name);
if (strncmp(cname,"::",2) == 0) { if (strncmp(cname,"::",2) == 0) {
String *nname = NewString(Char(name)+2); String *nname = NewString(cname+2);
if (Swig_scopename_check(nname)) { if (Swig_scopename_check(nname)) {
s = symbol_lookup_qualified(nname,global_scope,0,0,checkfunc); 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)) { if (Swig_scopename_check(name)) {
char *cname = Char(name); char *cname = Char(name);
if (strncmp(cname,"::",2) == 0) { if (strncmp(cname,"::",2) == 0) {
String *nname = NewString(Char(name)+2); String *nname = NewString(cname+2);
if (Swig_scopename_check(nname)) { if (Swig_scopename_check(nname)) {
s = symbol_lookup_qualified(nname,global_scope,0,0,0); 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)) { if (Swig_scopename_check(name)) {
char *cname = Char(name); char *cname = Char(name);
if (strncmp(cname,"::",2) == 0) { if (strncmp(cname,"::",2) == 0) {
String *nname = NewString(Char(name)+2); String *nname = NewString(cname+2);
if (Swig_scopename_check(nname)) { if (Swig_scopename_check(nname)) {
s = symbol_lookup_qualified(nname,global_scope,0,0,checkfunc); s = symbol_lookup_qualified(nname,global_scope,0,0,checkfunc);
} }
@ -1337,7 +1337,7 @@ Swig_symbol_qualified(Node *n) {
} else { } else {
symtab = HashGetAttr(n,k_symsymtab); symtab = HashGetAttr(n,k_symsymtab);
} }
if (!symtab) return NewString(""); if (!symtab) return NewStringEmpty();
#ifdef SWIG_DEBUG #ifdef SWIG_DEBUG
Printf(stderr,"symbol_qscope %s %x %s\n", HashGetAttr(n,k_name), symtab,HashGetAttr(symtab,k_name)); Printf(stderr,"symbol_qscope %s %x %s\n", HashGetAttr(n,k_name), symtab,HashGetAttr(symtab,k_name));
#endif #endif
@ -1396,7 +1396,7 @@ Swig_symbol_template_qualify(const SwigType *e, Symtab *st) {
StringAppend(qprefix,vparm); StringAppend(qprefix,vparm);
ti = Next(ti); ti = Next(ti);
if (ti.item) { if (ti.item) {
Putc(',',qprefix); StringPutc(',',qprefix);
} }
Delete(qparm); Delete(qparm);
Delete(vparm); Delete(vparm);
@ -1418,7 +1418,7 @@ Swig_symbol_type_qualify(const SwigType *t, Symtab *st) {
String *result; String *result;
int i,len; int i,len;
result = NewString(""); result = NewStringEmpty();
elements = SwigType_split(t); elements = SwigType_split(t);
len = Len(elements); len = Len(elements);
@ -1450,7 +1450,7 @@ Swig_symbol_type_qualify(const SwigType *t, Symtab *st) {
StringAppend(e,ty); StringAppend(e,ty);
Delete(ty); Delete(ty);
} }
if (strncmp(Char(e),"::",2) == 0) { if (strncmp(StringChar(e),"::",2) == 0) {
Delitem(e,0); Delitem(e,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 "}; const char* dclass[3] = {"struct ", "union ", "class "};
int i; int i;
char * c = Char(nt); char * c = StringChar(nt);
for (i=0; i<3; i++) { for (i=0; i<3; i++) {
if (strstr(c, dclass[i]) == c) { if (strstr(c, dclass[i]) == c) {
Replace(nt,dclass[i],"", DOH_REPLACE_FIRST); Replace(nt,dclass[i],"", DOH_REPLACE_FIRST);
@ -1638,16 +1638,13 @@ SwigType *Swig_symbol_typedef_reduce(SwigType *ty, Symtab *tab) {
String * String *
Swig_symbol_string_qualify(String *s, Symtab *st) { Swig_symbol_string_qualify(String *s, Symtab *st) {
char *c; int have_id = 0;
String *id, *r; String *id = NewStringEmpty();
int have_id = 0; String *r = NewStringEmpty();
char *c = StringChar(s);
id = NewString("");
r = NewString("");
c = Char(s);
while (*c) { while (*c) {
if (isalpha((int)*c) || (*c == '_') || (*c == ':')) { if (isalpha((int)*c) || (*c == '_') || (*c == ':')) {
Putc(*c,id); StringPutc(*c,id);
have_id = 1; have_id = 1;
} else { } else {
if (have_id) { if (have_id) {
@ -1657,7 +1654,7 @@ Swig_symbol_string_qualify(String *s, Symtab *st) {
Delete(qid); Delete(qid);
have_id = 0; have_id = 0;
} }
Putc(*c,r); StringPutc(*c,r);
} }
c++; c++;
} }
@ -1739,7 +1736,7 @@ Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *t
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
SwigType* SwigType*
Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope) { Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope) {
String *result = NewString(""); String *result = NewStringEmpty();
List *elements = SwigType_split(type); List *elements = SwigType_split(type);
int len = Len(elements); int len = Len(elements);
int i; int i;
@ -1809,7 +1806,7 @@ Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope) {
} }
StringAppend(tprefix,ttq); StringAppend(tprefix,ttq);
p = nextSibling(p); p = nextSibling(p);
if (p) Putc(',',tprefix); if (p) StringPutc(',',tprefix);
Delete(ttf); Delete(ttf);
Delete(ttq); Delete(ttq);
} }

View file

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

View file

@ -564,7 +564,7 @@ SwigType *
SwigType_pop_arrays(SwigType *t) { SwigType_pop_arrays(SwigType *t) {
String *ta; String *ta;
assert(SwigType_isarray(t)); assert(SwigType_isarray(t));
ta = NewString(""); ta = NewStringEmpty();
while (SwigType_isarray(t)) { while (SwigType_isarray(t)) {
SwigType *td = SwigType_pop(t); SwigType *td = SwigType_pop(t);
Append(ta,td); Append(ta,td);
@ -825,7 +825,7 @@ SwigType_templatesuffix(const SwigType *t) {
} }
c++; c++;
} }
return NewString(""); return NewStringEmpty();
} }
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
@ -969,7 +969,7 @@ SwigType_prefix(const SwigType *t) {
return r; return r;
} }
} }
return NewString(""); return NewStringEmpty();
} }
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
@ -990,7 +990,7 @@ SwigType_strip_qualifiers(SwigType *t) {
if (r) return Copy(r); if (r) return Copy(r);
l = SwigType_split(t); l = SwigType_split(t);
r = NewString(""); r = NewStringEmpty();
for (ei = First(l);ei.item; ei = Next(ei)) { for (ei = First(l);ei.item; ei = Next(ei)) {
if (SwigType_isqualifier(ei.item)) continue; 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_inherit = 0;
static String *k_parent = 0; static String *k_parent = 0;
static String *k_value = 0; static String *k_value = 0;
static String *k_nodetype = 0;
/* /*
Enable this one if your language fully support SwigValueWrapper<T>. Enable this one if your language fully support SwigValueWrapper<T>.
@ -157,6 +158,7 @@ void SwigType_typesystem_init() {
k_inherit = NewString("inherit"); k_inherit = NewString("inherit");
k_parent = NewString("parent"); k_parent = NewString("parent");
k_value = NewString("value"); k_value = NewString("value");
k_nodetype = NewString("nodeType");
if (global_scope) Delete(global_scope); if (global_scope) Delete(global_scope);
if (scopes) Delete(scopes); if (scopes) Delete(scopes);
@ -563,7 +565,7 @@ SwigType *SwigType_typedef_resolve(SwigType *t) {
/* /*
if (!noscope) { 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); if (newtype) Delete(type);
Delete(base); Delete(base);
Delete(namebase); Delete(namebase);
@ -862,7 +864,7 @@ SwigType *SwigType_typedef_qualified(SwigType *t)
return rc; return rc;
} }
result = NewString(""); result = NewStringEmpty();
elements = SwigType_split(t); elements = SwigType_split(t);
len = Len(elements); len = Len(elements);
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
@ -943,7 +945,7 @@ SwigType *SwigType_typedef_qualified(SwigType *t)
pi = First(parms); pi = First(parms);
while ((p = pi.item)) { while ((p = pi.item)) {
String *qt = SwigType_typedef_qualified(p); 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. /* 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 */ 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; if (n == lastnode) break;
lastnode = n; lastnode = n;
if (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 */ /* An enum item. Generate a fully qualified name */
String *qn = Swig_symbol_qualified(n); String *qn = Swig_symbol_qualified(n);
if (Len(qn)) { if (Len(qn)) {
@ -968,7 +971,7 @@ SwigType *SwigType_typedef_qualified(SwigType *t)
Delete(qn); Delete(qn);
break; break;
} }
} else if ((Strcmp(nodeType(n),"cdecl") == 0) && (Getattr(n,k_value))) { } else if ((strcmp(ntype,"cdecl") == 0) && (Getattr(n,k_value))) {
Delete(value); Delete(value);
value = Copy(Getattr(n,k_value)); value = Copy(Getattr(n,k_value));
continue; continue;
@ -1851,10 +1854,10 @@ SwigType_emit_type_table(File *f_forward, File *f_table) {
Printf(stdout,"%s\n", r_clientdata); Printf(stdout,"%s\n", r_clientdata);
#endif #endif
table = NewString(""); table = NewStringEmpty();
types = NewString(""); types = NewStringEmpty();
cast = NewString(""); cast = NewStringEmpty();
cast_init = NewString(""); cast_init = NewStringEmpty();
imported_types = NewHash(""); imported_types = NewHash("");
Printf(table,"static swig_type_info *swig_type_initial[] = {\n"); 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; String *rn;
const String *cd; const String *cd;
cast_temp = NewString(""); cast_temp = NewStringEmpty();
Printv(types,"static swig_type_info _swigt_", ki.item, " = {", NIL); Printv(types,"static swig_type_info _swigt_", ki.item, " = {", NIL);
Append(table_list, ki.item); Append(table_list, ki.item);

View file

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