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:
Dave Beazley 2000-12-18 02:56:05 +00:00
commit c15d662964
12 changed files with 217 additions and 55 deletions

View file

@ -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 */

View file

@ -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()

View file

@ -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 */

View file

@ -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()
*

View file

@ -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 */

View file

@ -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[]);

View file

@ -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()
*

View file

@ -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;

View file

@ -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);
}