Bug fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@958 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
be178afd80
commit
c15d662964
12 changed files with 217 additions and 55 deletions
|
|
@ -319,7 +319,7 @@ yylex1(void) {
|
|||
LParse_error(0,0,"Illegal character '%s'\n", text);
|
||||
return yylex1();
|
||||
}
|
||||
if (l1 == STRING) {
|
||||
if ((l1 == STRING) || (l1 == CHARCONST)) {
|
||||
yylval.tok.text = NewString(yytext+1);
|
||||
Delitem(yylval.tok.text,DOH_END);
|
||||
}
|
||||
|
|
@ -404,10 +404,14 @@ yylex1(void) {
|
|||
if (strcmp(yytext,"%apply") == 0) return(APPLY);
|
||||
if (strcmp(yytext,"%clear") == 0) return(CLEAR);
|
||||
if (strcmp(yytext,"%scope") == 0) return(SCOPE);
|
||||
if (strcmp(yytext,"%types") == 0) return(TYPES);
|
||||
}
|
||||
/* Have an unknown identifier, as a last step, we'll */
|
||||
/* do a typedef lookup on it. */
|
||||
yylval.tok.text = NewString(yytext);
|
||||
Setfile(yylval.tok.text, yylval.tok.filename);
|
||||
Setline(yylval.tok.text, yylval.tok.line);
|
||||
|
||||
/* if (strict_type && LParse_typedef_check(yylval.tok.text)) {
|
||||
return TYPE_TYPEDEF;
|
||||
}*/
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ void yyerror (char *s);
|
|||
#include "preprocessor.h"
|
||||
|
||||
static DOH *top = 0;
|
||||
static Hash *class_hash = 0;
|
||||
|
||||
/* Pre-created attribute name objects. Used to improve parsing performance */
|
||||
|
||||
|
|
@ -47,6 +48,8 @@ static DOH *TAG_ENUMVALUE = 0;
|
|||
static DOH *TAG_FUNCTION = 0;
|
||||
static DOH *TAG_VARIABLE = 0;
|
||||
|
||||
static int pure_virtual = 0;
|
||||
|
||||
/* Set parent node of a collection of children */
|
||||
static void setparent(DOH *parent, DOH *child) {
|
||||
DOH *o;
|
||||
|
|
@ -112,6 +115,7 @@ static DOH *TAG_VARIABLE = 0;
|
|||
}
|
||||
LParse_push(str);
|
||||
top = 0;
|
||||
class_hash = NewHash();
|
||||
tp = NewHash();
|
||||
Setattr(tp, "tag", "swig:top");
|
||||
Setattr(tp, ATTR_NAME, Getfile(str));
|
||||
|
|
@ -119,6 +123,20 @@ static DOH *TAG_VARIABLE = 0;
|
|||
Setattr(tp, ATTR_CHILD, top);
|
||||
setparent(tp,top);
|
||||
create_backlinks(tp);
|
||||
|
||||
{
|
||||
DOH *key;
|
||||
key = Firstkey(class_hash);
|
||||
while (key) {
|
||||
DOH *node, *tag;
|
||||
node = Getattr(class_hash,key);
|
||||
tag = Gettag(node);
|
||||
if (Cmp(tag,"swig:addmethods") == 0) {
|
||||
Printf(stderr,"%s:%d. Warning. Added methods for '%s' ignored.\n", Getfile(node),Getline(node),Getname(node));
|
||||
}
|
||||
key = Nextkey(class_hash);
|
||||
}
|
||||
}
|
||||
return tp;
|
||||
}
|
||||
|
||||
|
|
@ -233,7 +251,7 @@ static int promote(int t1, int t2) {
|
|||
/* SWIG directives */
|
||||
%token <tok> ADDMETHODS APPLY CLEAR CONSTANT ECHO EXCEPT SCOPE
|
||||
%token <tok> ILLEGAL FILEDIRECTIVE INLINE MACRO MODULE NAME PRAGMA INSERT
|
||||
%token <tok> TYPEMAP
|
||||
%token <tok> TYPEMAP TYPES
|
||||
|
||||
/* Operators */
|
||||
%left <tok> LOR
|
||||
|
|
@ -258,7 +276,7 @@ static int promote(int t1, int t2) {
|
|||
%type <tmname> tm_name
|
||||
%type <tok> tm_method
|
||||
%type <node> statement swig_directive c_declaration
|
||||
%type <node> file_include code_block except_directive pragma_directive typemap_directive scope_directive
|
||||
%type <node> file_include code_block except_directive pragma_directive typemap_directive scope_directive type_directive
|
||||
%type <node> variable_decl function_decl enum_decl typedef_decl stail edecl typedeflist
|
||||
%type <nodelist> enumlist interface
|
||||
%type <node> inherit base_list
|
||||
|
|
@ -361,9 +379,11 @@ swig_directive : MODULE idstring {
|
|||
break;
|
||||
case LPARSE_T_CHAR:
|
||||
Setattr($$,ATTR_TYPE,"char");
|
||||
Delitem($3.text,0);
|
||||
Delitem($3.text,DOH_END);
|
||||
break;
|
||||
case LPARSE_T_STRING:
|
||||
Setattr($$,ATTR_TYPE,"*.char");
|
||||
Setattr($$,ATTR_TYPE,"p.char");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -376,6 +396,7 @@ swig_directive : MODULE idstring {
|
|||
| pragma_directive { $$ = $1; }
|
||||
| typemap_directive { $$ = $1; }
|
||||
| scope_directive {$$ = $1; }
|
||||
| type_directive { $$ = $1; }
|
||||
;
|
||||
|
||||
scope_directive: SCOPE LBRACE interface RBRACE {
|
||||
|
|
@ -385,12 +406,12 @@ scope_directive: SCOPE LBRACE interface RBRACE {
|
|||
setparent($$,$3.node);
|
||||
}
|
||||
}
|
||||
| SCOPE LPAREN idstring RPAREN interface RBRACE {
|
||||
| SCOPE LPAREN idstring RPAREN LBRACE interface RBRACE {
|
||||
$$ = new_node("swig:scope",$1.filename,$1.line);
|
||||
if ($5.node) {
|
||||
Setattr($$,ATTR_CHILD,$5.node);
|
||||
if ($6.node) {
|
||||
Setattr($$,ATTR_CHILD,$6.node);
|
||||
Setattr($$,ATTR_NAME,$3.text);
|
||||
setparent($$,$5.node);
|
||||
setparent($$,$6.node);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
|
@ -742,6 +763,11 @@ tm_args : LPAREN parms RPAREN {
|
|||
}
|
||||
;
|
||||
|
||||
type_directive : TYPES LPAREN parms RPAREN SEMI {
|
||||
$$ = new_node("swig:types",$1.filename,$1.line);
|
||||
Setattr($$,"parms",$3);
|
||||
}
|
||||
;
|
||||
/* =============================================================================
|
||||
* -- C Declarations --
|
||||
* ============================================================================= */
|
||||
|
|
@ -835,6 +861,10 @@ function_decl : storage_spec type declaration LPAREN parms RPAREN cpp_const sta
|
|||
}
|
||||
if ($7.text)
|
||||
Setattr($$,"code",$7.text);
|
||||
if (pure_virtual) {
|
||||
SetInt($$,"abstract",1);
|
||||
pure_virtual = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Possibly a constructor */
|
||||
|
|
@ -859,12 +889,15 @@ function_decl : storage_spec type declaration LPAREN parms RPAREN cpp_const sta
|
|||
if ($6.text) {
|
||||
Setattr($$,"code",$6.text);
|
||||
}
|
||||
if (pure_virtual) {
|
||||
SetInt($$,"abstract",1);
|
||||
pure_virtual = 0;
|
||||
}
|
||||
}
|
||||
| NOT ID LPAREN parms RPAREN cpp_const SEMI {
|
||||
$$ = new_node("c:destructor",$2.filename,$2.line);
|
||||
Setattr($$,ATTR_NAME,$2.text);
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
/* Allow lists of variables and functions to be built up */
|
||||
|
|
@ -922,7 +955,7 @@ cpp_const : CONST {}
|
|||
|
||||
enum_decl : storage_spec ENUM ename LBRACE enumlist RBRACE SEMI {
|
||||
$$ = new_node("c:enum", $2.filename,$2.line);
|
||||
Setattr($$,ATTR_NAME,$2.text);
|
||||
Setattr($$,ATTR_NAME,$3.text);
|
||||
Setattr($$,ATTR_CHILD,$5.node);
|
||||
setparent($$,$5.node);
|
||||
/* Add typename */
|
||||
|
|
@ -1055,7 +1088,34 @@ typedeflist : COMMA declaration typedeflist {
|
|||
* -- Feeble C++ (yuck) Parsing --
|
||||
* ============================================================================= */
|
||||
|
||||
cpp_decl : cpp_class { $$ = $1; }
|
||||
cpp_decl : cpp_class {
|
||||
String *name;
|
||||
DOH *cls;
|
||||
$$ = $1;
|
||||
/* Save a copy of the class */
|
||||
name = Getattr($$,"altname");
|
||||
if (!name) {
|
||||
name = Getname($$);
|
||||
}
|
||||
cls = Getattr(class_hash,name);
|
||||
if (cls) {
|
||||
/* We already saw this class. If the previous class really was a class,
|
||||
we'll generate an error. If the class was an added method instead,
|
||||
we'll add those methods to our class */
|
||||
String *tag = Gettag(cls);
|
||||
if (Cmp(tag,"c:class") == 0) {
|
||||
/* Already saw this */
|
||||
Printf(stderr,"%s:%d. Class '%s' previously defined.\n", Getfile($$),Getline($$),name);
|
||||
$$ = 0;
|
||||
} else {
|
||||
/* Hmmm. Must have been an added method. Attach to the end of my children */
|
||||
Swig_node_append_child($$,cls);
|
||||
Setattr(class_hash,name,$$);
|
||||
}
|
||||
} else {
|
||||
Setattr(class_hash,name,$$);
|
||||
}
|
||||
}
|
||||
| cpp_other { $$ = $1; }
|
||||
;
|
||||
|
||||
|
|
@ -1180,12 +1240,15 @@ access_specifier : PUBLIC { $$.text = NewString("public"); }
|
|||
|
||||
cpp_end : cpp_const LBRACE {
|
||||
$$.text = LParse_skip_balanced('{','}');
|
||||
pure_virtual = 0;
|
||||
}
|
||||
| EQUAL definetype SEMI {
|
||||
$$.text = 0;
|
||||
pure_virtual = 1;
|
||||
}
|
||||
/* | cpp_const {
|
||||
$$.text = 0;
|
||||
pure_virtual = 0;
|
||||
}
|
||||
*/
|
||||
;
|
||||
|
|
@ -1224,11 +1287,11 @@ cpp_other :/* A dummy class name */
|
|||
}
|
||||
| PRIVATE COLON {
|
||||
$$ = new_node("c:access",$1.filename,$1.line);
|
||||
Setattr($$,ATTR_NAME,"public");
|
||||
Setattr($$,ATTR_NAME,"private");
|
||||
}
|
||||
| PROTECTED COLON {
|
||||
$$ = new_node("c:access",$1.filename,$1.line);
|
||||
Setattr($$,ATTR_NAME,"public");
|
||||
Setattr($$,ATTR_NAME,"protected");
|
||||
}
|
||||
|
||||
| FRIEND {
|
||||
|
|
@ -1254,13 +1317,36 @@ cpp_other :/* A dummy class name */
|
|||
|
||||
| ADDMETHODS opt_id LBRACE interface RBRACE {
|
||||
$$ = new_node("swig:addmethods",$1.filename,$1.line);
|
||||
if ($1.text)
|
||||
Setattr($$,ATTR_NAME,$1.text);
|
||||
if ($4.node) {
|
||||
Setattr($$,ATTR_CHILD,$4.node);
|
||||
setparent($$,$4.node);
|
||||
}
|
||||
}
|
||||
if ($2.text) {
|
||||
DOH *cls;
|
||||
Setattr($$,ATTR_NAME,$2.text);
|
||||
/* A named addmethods directive. If not in a class. We have to save */
|
||||
cls = Getattr(class_hash,$2.text);
|
||||
if (cls) {
|
||||
/* Hmmm. A class or addmethods directive was already found */
|
||||
String *tag = Gettag(cls);
|
||||
if (Cmp(tag,"swig:addmethods") == 0) {
|
||||
/* We need to append our methods to previous methods */
|
||||
Swig_node_append_child(cls,$4.node);
|
||||
setparent(cls,$4.node);
|
||||
$$ = 0;
|
||||
} else {
|
||||
/* No. This must be a class. We'll add ourselves to it */
|
||||
Swig_node_append_child(cls,$$);
|
||||
$$ = 0;
|
||||
}
|
||||
} else {
|
||||
/* Nothing previously defined. Save ourselves */
|
||||
Setattr(class_hash,$2.text,$$);
|
||||
$$ = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
opt_id : ID { $$ = $1; }
|
||||
| empty { $$.text = 0; }
|
||||
|
|
@ -1475,7 +1561,7 @@ type : TYPE_INT { $$ = NewString("int"); }
|
|||
$$ = NewStringf("%s %s", $1.text, $2.text);
|
||||
}
|
||||
| ID DCOLON ID {
|
||||
$$ = NewStringf("%s::%s",$1.text,$2.text);
|
||||
$$ = NewStringf("%s::%s",$1.text,$3.text);
|
||||
}
|
||||
/* This declaration causes a shift-reduce conflict. Unresolved for now */
|
||||
| DCOLON ID {
|
||||
|
|
@ -1706,12 +1792,12 @@ expr : NUM_INT {
|
|||
}
|
||||
$$.ivalue = LPARSE_T_INT;
|
||||
}
|
||||
| MINUS expr %prec UMINUS {
|
||||
| MINUS expr %prec UMINUS {
|
||||
$$.text = NewString("");
|
||||
Printf($$.text,"-%s", $2.text);
|
||||
$$.ivalue = $2.ivalue;
|
||||
}
|
||||
| NOT expr {
|
||||
| NOT expr {
|
||||
$$.text = NewString("");
|
||||
Printf($$.text,"~%s", $2.text);
|
||||
if ($2.ivalue == LPARSE_T_DOUBLE) {
|
||||
|
|
|
|||
|
|
@ -12,9 +12,11 @@
|
|||
#include "swig.h"
|
||||
|
||||
extern void testmodule();
|
||||
extern void pythonmodule();
|
||||
|
||||
static void (*modules[])(void) = {
|
||||
testmodule,
|
||||
pythonmodule,
|
||||
0
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -524,7 +524,6 @@ Swig_cfunction_wrapper(String_or_char *funcname,
|
|||
l = CopyParmList(parms);
|
||||
fix_parm_names(l);
|
||||
Printf(w,"%s %s(%s) {\n", SwigType_str(rtype,0), funcname, ParmList_str(l));
|
||||
Printf(w,"$locals\n");
|
||||
if (code) {
|
||||
Printv(w, code, "\n", 0);
|
||||
}
|
||||
|
|
@ -571,7 +570,6 @@ Swig_cmethod_wrapper(String_or_char *classname,
|
|||
fix_parm_names(l);
|
||||
|
||||
Printf(w,"%s %s(%s) {\n", SwigType_str(rtype,0), Swig_name_member(classname, methodname), ParmList_str(l));
|
||||
Printf(w,"$locals\n");
|
||||
|
||||
if (!code) {
|
||||
/* No code supplied. Write a function manually */
|
||||
|
|
@ -628,7 +626,6 @@ Swig_cconstructor_wrapper(String_or_char *classname,
|
|||
fix_parm_names(l);
|
||||
|
||||
Printf(w,"%s %s(%s) {\n", SwigType_str(t,0), Swig_name_construct(classname), ParmList_str(l));
|
||||
Printf(w,"$locals\n");
|
||||
|
||||
if (!code) {
|
||||
/* No code supplied. Write a function manually */
|
||||
|
|
@ -673,7 +670,6 @@ Swig_cppconstructor_wrapper(String_or_char *classname,
|
|||
fix_parm_names(l);
|
||||
|
||||
Printf(w,"%s %s(%s) {\n", SwigType_str(t,0), Swig_name_construct(classname), ParmList_str(l));
|
||||
Printf(w,"$locals\n");
|
||||
|
||||
if (!code) {
|
||||
/* No code supplied. Write a function manually */
|
||||
|
|
@ -731,7 +727,6 @@ Swig_cdestructor_wrapper(String_or_char *classname,
|
|||
t = NewString("void");
|
||||
|
||||
Printf(w,"%s %s(%s) {\n", SwigType_str(t,0), Swig_name_destroy(classname), ParmList_str(l));
|
||||
Printf(w,"$locals\n");
|
||||
|
||||
if (!code) {
|
||||
/* No code supplied. Write a function manually */
|
||||
|
|
@ -778,7 +773,6 @@ Swig_cppdestructor_wrapper(String_or_char *classname,
|
|||
t = NewString("void");
|
||||
|
||||
Printf(w,"%s %s(%s) {\n", SwigType_str(t,0), Swig_name_destroy(classname), ParmList_str(l));
|
||||
Printf(w,"$locals\n");
|
||||
|
||||
if (!code) {
|
||||
/* No code supplied. Write a function manually */
|
||||
|
|
@ -828,7 +822,6 @@ Swig_cmemberset_wrapper(String_or_char *classname,
|
|||
Setnext(l,p);
|
||||
|
||||
Printf(w,"void %s(%s) {\n", Getname(w), ParmList_str(l));
|
||||
Printf(w,"$locals\n");
|
||||
|
||||
if (!code) {
|
||||
/* No code supplied. Write a function manually */
|
||||
|
|
@ -878,7 +871,6 @@ Swig_cmemberget_wrapper(String_or_char *classname,
|
|||
|
||||
lt = Swig_clocal_type(type);
|
||||
Printf(w,"%s %s(%s) {\n", SwigType_str(lt,0), Getname(w), ParmList_str(l));
|
||||
Printf(w,"$locals\n");
|
||||
|
||||
if (!code) {
|
||||
/* No code supplied. Write a function manually */
|
||||
|
|
@ -920,7 +912,6 @@ Swig_cvarset_wrapper(String_or_char *varname,
|
|||
l = p;
|
||||
|
||||
Printf(w,"%s %s(%s) {\n", SwigType_str(lt,0), Getname(w), ParmList_str(l));
|
||||
Printf(w,"$locals");
|
||||
|
||||
if (!code) {
|
||||
/* No code supplied. Write a function manually */
|
||||
|
|
@ -964,7 +955,6 @@ Swig_cvarget_wrapper(String_or_char *varname,
|
|||
lt = Swig_clocal_type(type);
|
||||
|
||||
Printf(w,"%s %s(%s) {\n", SwigType_str(lt,0), Getname(w), ParmList_str(l));
|
||||
Printf(w,"$locals");
|
||||
|
||||
if (!code) {
|
||||
/* No code supplied. Write a function manually */
|
||||
|
|
|
|||
|
|
@ -21,6 +21,18 @@ static List *directories = 0; /* List of include directories */
|
|||
static String *lastpath = 0; /* Last file that was included */
|
||||
static int bytes_read = 0; /* Bytes read */
|
||||
static String *swiglib = 0; /* Location of SWIG library */
|
||||
static String *lang_config = 0; /* Language configuration file */
|
||||
|
||||
/* This function sets the name of the configuration file */
|
||||
|
||||
void Swig_set_config_file(const String_or_char *filename) {
|
||||
lang_config = NewString(filename);
|
||||
}
|
||||
|
||||
String *Swig_get_config_file() {
|
||||
return lang_config;
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_swiglib_set()
|
||||
|
|
|
|||
|
|
@ -107,7 +107,6 @@ Swig_map_add_typerule(Hash *ruleset, DOH *type, String_or_char *name, DOH *obj)
|
|||
Delete(p);
|
||||
}
|
||||
|
||||
|
||||
typedef struct MatchObject {
|
||||
Hash *ruleset; /* Hash table of rules */
|
||||
Hash *p; /* Parameter on which checking starts */
|
||||
|
|
|
|||
|
|
@ -52,6 +52,18 @@ Swig_banner(File *f) {
|
|||
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_section()
|
||||
*
|
||||
* Print a comment denoting a section of wrapper code
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_section(File *f, const String_or_char *name) {
|
||||
Printf(f,"/* -----------------------------------------------------------------------------\n");
|
||||
Printf(f," * %s\n", name);
|
||||
Printf(f," * ----------------------------------------------------------------------------- */\n");
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_temp_result()
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1084,14 +1084,32 @@ static void init_scopes() {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int SwigType_typedef(SwigType *type, String_or_char *name) {
|
||||
int i;
|
||||
String *qname;
|
||||
init_scopes();
|
||||
if (Getattr(scopes[scope_level],name)) return -1;
|
||||
if (Cmp(type,name) == 0) {
|
||||
return 0;
|
||||
}
|
||||
i = scope_level;
|
||||
qname = NewString(name);
|
||||
while (i >= 0) {
|
||||
String *sname;
|
||||
Printf(stdout,"Adding typedef [%d] : '%s' -> '%s'\n", i, qname, type);
|
||||
Setattr(scopes[i],qname,type);
|
||||
if (i > 0) {
|
||||
sname = scopenames[i];
|
||||
if (sname) {
|
||||
qname = NewStringf("%s::%s",sname,qname);
|
||||
}
|
||||
}
|
||||
i--;
|
||||
}
|
||||
|
||||
Setattr(scopes[scope_level],name,type);
|
||||
if (default_cache)
|
||||
/* Setattr(scopes[scope_level],name,type); */
|
||||
/* Need to modify this to include all scopes */
|
||||
|
||||
if (default_cache)
|
||||
Delattr(default_cache,type);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1169,8 +1187,7 @@ void SwigType_merge_scope(Hash *scope, String_or_char *prefix) {
|
|||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_pop_scope()
|
||||
*
|
||||
* Pop off the last scope and perform a merge operation. Returns the hash
|
||||
* table for the scope that was popped off.
|
||||
* Pop off the last scope. Returns the hash table for the scope that was popped off.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
Hash *SwigType_pop_scope() {
|
||||
|
|
@ -1180,7 +1197,8 @@ Hash *SwigType_pop_scope() {
|
|||
if (scope_level == 0) return 0;
|
||||
prefix = scopenames[scope_level];
|
||||
s = scopes[scope_level--];
|
||||
SwigType_merge_scope(s,prefix);
|
||||
/* SwigType_merge_scope(s,prefix); */
|
||||
/* Printf(stdout,"****\n%s\n", scopes[scope_level]); */
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
@ -1199,7 +1217,6 @@ SwigType *SwigType_typedef_resolve(SwigType *t) {
|
|||
|
||||
init_scopes();
|
||||
base = SwigType_base(t);
|
||||
|
||||
level = scope_level;
|
||||
while (level >= 0) {
|
||||
/* See if we know about this type */
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@ extern void Swig_register_filebyname(const String_or_char *name, File *outfi
|
|||
extern File *Swig_filebyname(const String_or_char *name);
|
||||
extern void Swig_swiglib_set(const String_or_char *name);
|
||||
extern String *Swig_swiglib_get();
|
||||
extern void Swig_set_config_file(const String_or_char *name);
|
||||
extern String *Swig_get_config_file();
|
||||
|
||||
#define OUTFILE(x) Swig_filebyname(x)
|
||||
|
||||
|
|
@ -250,6 +252,7 @@ extern void Swig_node_cut(DOH *obj);
|
|||
extern void Swig_node_insert(DOH *node, DOH *newnode);
|
||||
extern void Swig_node_temporary(DOH *node);
|
||||
extern void Swig_node_ignore(DOH *node);
|
||||
extern void Swig_node_append_child(DOH *node, DOH *cld);
|
||||
extern int Swig_count_nodes(DOH *node);
|
||||
|
||||
extern DOH *Swig_next(DOH *obj);
|
||||
|
|
@ -292,6 +295,7 @@ extern DOH *Swig_map_match(Hash *ruleset, Hash *parms, int *nmatch);
|
|||
/* --- Misc --- */
|
||||
extern char *Swig_copy_string(const char *c);
|
||||
extern void Swig_banner(File *f);
|
||||
extern void Swig_section(File *f, const String_or_char *s);
|
||||
extern DOH *Swig_temp_result(DOH *x);
|
||||
extern String *Swig_string_escape(String *s);
|
||||
extern String *Swig_string_mangle(String *s);
|
||||
|
|
@ -375,15 +379,15 @@ extern DOH *Swig_run_modules(DOH *node);
|
|||
/* --- Legacy Typemap API (somewhat simplified) --- */
|
||||
|
||||
extern void Swig_typemap_init();
|
||||
extern void Swig_typemap_register(char *op, SwigType *type, String_or_char *name, String_or_char *code, ParmList *locals);
|
||||
extern void Swig_typemap_copy(char *op, SwigType *stype, String_or_char *sname,
|
||||
extern void Swig_typemap_register(const String_or_char *op, SwigType *type, String_or_char *name, String_or_char *code, ParmList *locals);
|
||||
extern void Swig_typemap_copy(const String_or_char *op, SwigType *stype, String_or_char *sname,
|
||||
SwigType *ttype, String_or_char *tname);
|
||||
extern void Swig_typemap_clear(char *op, SwigType *type, String_or_char *name);
|
||||
extern void Swig_typemap_clear(const String_or_char *op, SwigType *type, String_or_char *name);
|
||||
extern void Swig_typemap_apply(SwigType *tm_type, String_or_char *tmname, SwigType *type, String_or_char *pname);
|
||||
extern void Swig_typemap_clear_apply(SwigType *type, String_or_char *pname);
|
||||
extern void Swig_typemap_debug();
|
||||
extern Hash *Swig_typemap_search(char *op, SwigType *type, String_or_char *pname);
|
||||
extern char *Swig_typemap_lookup(char *op, SwigType *type, String_or_char *pname, String_or_char *source, String_or_char *target, Wrapper *f);
|
||||
extern Hash *Swig_typemap_search(const String_or_char *op, SwigType *type, String_or_char *pname);
|
||||
extern char *Swig_typemap_lookup(const String_or_char *op, SwigType *type, String_or_char *pname, String_or_char *source, String_or_char *target, Wrapper *f);
|
||||
extern void Swig_typemap_new_scope();
|
||||
extern Hash *Swig_typemap_pop_scope();
|
||||
|
||||
|
|
@ -400,16 +404,25 @@ extern void Swig_except_clear();
|
|||
#define Getlname(x) Getattr(x,"lname")
|
||||
#define Getignore(x) GetInt(x,"ignore")
|
||||
#define Getparms(x) Getattr(x,"parms")
|
||||
#define Gettag(x) Getattr(x,"tag")
|
||||
#define Getparent(x) Getattr(x,"parent")
|
||||
|
||||
#define Settype(x,v) Setattr(x,"type",x)
|
||||
#define Settype(x,v) Setattr(x,"type",v)
|
||||
#define Setname(x,v) Setattr(x,"name",v)
|
||||
#define Setlname(x,v) Setattr(x,"lname",v)
|
||||
#define Setvalue(x,v) Setattr(x,"value", v)
|
||||
#define Setignore(x,v) SetInt(x,"ignore",v)
|
||||
#define Settag(x,v) Setattr(x,"tag",v)
|
||||
#define Setparms(x,v) Setattr(x,"parms", v)
|
||||
#define Setparent(x,p) Setattr(x,"parent",p)
|
||||
|
||||
#define Getnext(x) Getattr(x,"next")
|
||||
#define Setnext(x,n) Setattr(x,"next",n)
|
||||
#define Getprev(x) Getattr(x,"prev")
|
||||
#define Setprev(x,n) Setattr(x,"prev",n)
|
||||
|
||||
#define Getchild(x) Getattr(x,"child")
|
||||
#define Setchild(x,c) Setattr(x,"child",c)
|
||||
|
||||
extern int Swig_main(int argc, char *argv[]);
|
||||
|
||||
|
|
|
|||
|
|
@ -26,11 +26,11 @@ static int debug_emit = 0;
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
DOH *Swig_next(DOH *obj) {
|
||||
return Getattr(obj,"next");
|
||||
return Getnext(obj);
|
||||
}
|
||||
|
||||
DOH *Swig_prev(DOH *obj) {
|
||||
return Getattr(obj,"prev");
|
||||
return Getprev(obj);
|
||||
}
|
||||
|
||||
void Swig_debug_emit(int n) {
|
||||
|
|
@ -52,7 +52,7 @@ Swig_dump_tags(DOH *obj, DOH *root) {
|
|||
else croot = root;
|
||||
|
||||
while (obj) {
|
||||
Printf(stdout,"%s . %s\n", croot, Getattr(obj,"tag"));
|
||||
Printf(stdout,"%s . %s (%s:%d)\n", croot, Getattr(obj,"tag"), Getfile(obj), Getline(obj));
|
||||
cobj = Getattr(obj,"child");
|
||||
if (cobj) {
|
||||
newroot = NewStringf("%s . %s",croot,Getattr(obj,"tag"));
|
||||
|
|
@ -221,8 +221,8 @@ Swig_tag_check(DOH *obj, String_or_char *tagname) {
|
|||
tag = Getattr(obj,"tag");
|
||||
assert(tag);
|
||||
|
||||
tc = Char(tag);
|
||||
tnc = Char(tagname);
|
||||
tnc = Char(tag);
|
||||
tc = Char(tagname);
|
||||
|
||||
while (tnc) {
|
||||
if (strcmp(tc,tnc) == 0) return 1;
|
||||
|
|
@ -467,6 +467,31 @@ Swig_node_insert(DOH *node, DOH *newnode) {
|
|||
Setattr(newnode,"parent", Getattr(node,"parent"));
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_node_append_child()
|
||||
*
|
||||
* Appends a new child to a node
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
Swig_node_append_child(DOH *node, DOH *chd) {
|
||||
DOH *c;
|
||||
DOH *pc;
|
||||
c = Getattr(node,"child");
|
||||
if (!c) {
|
||||
Setattr(node,"child",chd);
|
||||
Setattr(chd,"parent",node);
|
||||
return;
|
||||
}
|
||||
while (c) {
|
||||
pc = c;
|
||||
c = Getnext(c);
|
||||
}
|
||||
Setattr(pc,"next",chd);
|
||||
Setattr(chd,"prev",pc);
|
||||
Setattr(chd,"parent",node);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_count_nodes()
|
||||
*
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ Swig_typemap_pop_scope() {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
Swig_typemap_register(char *op, SwigType *type, String_or_char *pname, String_or_char *code, ParmList *locals) {
|
||||
Swig_typemap_register(const String_or_char *op, SwigType *type, String_or_char *pname, String_or_char *code, ParmList *locals) {
|
||||
char *key;
|
||||
Hash *tm;
|
||||
Hash *tm1;
|
||||
|
|
@ -148,7 +148,7 @@ Swig_typemap_get(SwigType *type, String_or_char *name, int scope) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
Swig_typemap_copy(char *op, SwigType *stype, String_or_char *sname,
|
||||
Swig_typemap_copy(const String_or_char *op, SwigType *stype, String_or_char *sname,
|
||||
SwigType *ttype, String_or_char *tname) {
|
||||
|
||||
Hash *tm=0, *tm1;
|
||||
|
|
@ -173,7 +173,7 @@ Swig_typemap_copy(char *op, SwigType *stype, String_or_char *sname,
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
Swig_typemap_clear(char *op, SwigType *type, String_or_char *name) {
|
||||
Swig_typemap_clear(const String_or_char *op, SwigType *type, String_or_char *name) {
|
||||
Hash *tm;
|
||||
|
||||
tm = Swig_typemap_get(type,name,tm_scope);
|
||||
|
|
@ -269,7 +269,7 @@ static SwigType *strip_arrays(SwigType *type) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
Hash *
|
||||
Swig_typemap_search(char *op, SwigType *type, String_or_char *name) {
|
||||
Swig_typemap_search(const String_or_char *op, SwigType *type, String_or_char *name) {
|
||||
Hash *result = 0, *tm, *tm1, *tma;
|
||||
SwigType *noarrays = 0;
|
||||
SwigType *primitive = 0;
|
||||
|
|
@ -397,7 +397,7 @@ static void typemap_locals(SwigType *t, String_or_char *pname, DOHString *s, Par
|
|||
* Perform a typemap lookup (ala SWIG1.1)
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char *Swig_typemap_lookup(char *op, SwigType *type, String_or_char *pname, String_or_char *source,
|
||||
char *Swig_typemap_lookup(const String_or_char *op, SwigType *type, String_or_char *pname, String_or_char *source,
|
||||
String_or_char *target, Wrapper *f)
|
||||
{
|
||||
Hash *tm;
|
||||
|
|
|
|||
|
|
@ -133,7 +133,9 @@ Wrapper_str(DOH *wo) {
|
|||
WrapObj *w = (WrapObj *) ObjData(wo);
|
||||
s = NewString(w->code);
|
||||
s1 = NewString("");
|
||||
Replace(s,"$locals", Getattr(w->attr,"locals"), DOH_REPLACE_ANY);
|
||||
|
||||
/* Replace the first '{' with a brace followed by local variable definitions */
|
||||
Replace(s,"{", Getattr(w->attr,"locals"), DOH_REPLACE_FIRST);
|
||||
Wrapper_pretty_print(s,s1);
|
||||
Delete(s);
|
||||
return s1;
|
||||
|
|
@ -236,7 +238,7 @@ Wrapper_new_local(Wrapper *wo, const String_or_char *name, const String_or_char
|
|||
WrapObj *w = (WrapObj *) ObjData(wo);
|
||||
i = 0;
|
||||
|
||||
while (Wrapper_check_local(w,nname)) {
|
||||
while (Wrapper_check_local(wo,nname)) {
|
||||
Clear(nname);
|
||||
Printf(nname,"%s%d",name,i);
|
||||
i++;
|
||||
|
|
@ -455,7 +457,7 @@ NewWrapper() {
|
|||
w->localh = NewHash();
|
||||
w->code = NewString("");
|
||||
w->attr= NewHash();
|
||||
Setattr(w->attr,"locals","");
|
||||
Setattr(w->attr,"locals","{\n");
|
||||
Setattr(w->attr,"wrapcode", w->code);
|
||||
return DohObjMalloc(DOHTYPE_WRAPPER, w);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue