Wide range of minor bug fixes and improvements.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@966 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
e699ee5a9d
commit
5c13fac1d5
10 changed files with 132 additions and 28 deletions
|
|
@ -2,9 +2,9 @@
|
||||||
/* SWIG version information */
|
/* SWIG version information */
|
||||||
|
|
||||||
#ifndef SWIG_VERSION
|
#ifndef SWIG_VERSION
|
||||||
#define SWIG_VERSION "1.3u-20001008-1349"
|
#define SWIG_VERSION "1.3u-20001219-1815"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SWIG_SPIN
|
#ifndef SWIG_SPIN
|
||||||
#define SWIG_SPIN "(Alpha 5)"
|
#define SWIG_SPIN "(Alpha 6)"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -275,7 +275,7 @@ static int promote(int t1, int t2) {
|
||||||
%type <node> tm_args tm_parm tm_tail tm_list
|
%type <node> tm_args tm_parm tm_tail tm_list
|
||||||
%type <tmname> tm_name
|
%type <tmname> tm_name
|
||||||
%type <tok> tm_method
|
%type <tok> tm_method
|
||||||
%type <node> statement swig_directive c_declaration
|
%type <node> statement swig_directive c_declaration constant_directive
|
||||||
%type <node> file_include code_block except_directive pragma_directive typemap_directive scope_directive type_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 <node> variable_decl function_decl enum_decl typedef_decl stail edecl typedeflist
|
||||||
%type <nodelist> enumlist interface
|
%type <nodelist> enumlist interface
|
||||||
|
|
@ -345,11 +345,25 @@ swig_directive : MODULE idstring {
|
||||||
LParse_set_location($7.filename,$7.line-1);
|
LParse_set_location($7.filename,$7.line-1);
|
||||||
$$ = $9.node;
|
$$ = $9.node;
|
||||||
}
|
}
|
||||||
| CONSTANT ID definetype SEMI {
|
| constant_directive {
|
||||||
|
$$ = $1;
|
||||||
|
}
|
||||||
|
| echo_directive { $$ = 0; }
|
||||||
|
| file_include { $$ = $1; }
|
||||||
|
| code_block { $$ = $1; }
|
||||||
|
| except_directive { $$ = $1; }
|
||||||
|
| pragma_directive { $$ = $1; }
|
||||||
|
| typemap_directive { $$ = $1; }
|
||||||
|
| scope_directive {$$ = $1; }
|
||||||
|
| type_directive { $$ = $1; }
|
||||||
|
;
|
||||||
|
|
||||||
|
constant_directive:
|
||||||
|
CONSTANT ID EQUAL definetype SEMI {
|
||||||
$$ = new_node("swig:constant",$2.filename, $2.line);
|
$$ = new_node("swig:constant",$2.filename, $2.line);
|
||||||
Setattr($$,ATTR_NAME,$2.text);
|
Setattr($$,ATTR_NAME,$2.text);
|
||||||
Setattr($$,ATTR_VALUE,$3.text);
|
Setattr($$,ATTR_VALUE,$4.text);
|
||||||
switch($3.ivalue) {
|
switch($4.ivalue) {
|
||||||
case LPARSE_T_DOUBLE:
|
case LPARSE_T_DOUBLE:
|
||||||
Setattr($$,ATTR_TYPE,"double");
|
Setattr($$,ATTR_TYPE,"double");
|
||||||
break;
|
break;
|
||||||
|
|
@ -379,8 +393,8 @@ swig_directive : MODULE idstring {
|
||||||
break;
|
break;
|
||||||
case LPARSE_T_CHAR:
|
case LPARSE_T_CHAR:
|
||||||
Setattr($$,ATTR_TYPE,"char");
|
Setattr($$,ATTR_TYPE,"char");
|
||||||
Delitem($3.text,0);
|
Delitem($4.text,0);
|
||||||
Delitem($3.text,DOH_END);
|
Delitem($4.text,DOH_END);
|
||||||
break;
|
break;
|
||||||
case LPARSE_T_STRING:
|
case LPARSE_T_STRING:
|
||||||
Setattr($$,ATTR_TYPE,"p.char");
|
Setattr($$,ATTR_TYPE,"p.char");
|
||||||
|
|
@ -389,14 +403,12 @@ swig_directive : MODULE idstring {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
| echo_directive { $$ = 0; }
|
| CONSTANT LPAREN parm RPAREN ID def_args SEMI {
|
||||||
| file_include { $$ = $1; }
|
$$ = new_node("swig:constant", $5.filename, $5.line);
|
||||||
| code_block { $$ = $1; }
|
Setattr($$,ATTR_NAME,$5.text);
|
||||||
| except_directive { $$ = $1; }
|
Setattr($$,ATTR_VALUE,$6.text);
|
||||||
| pragma_directive { $$ = $1; }
|
Setattr($$,ATTR_TYPE,Gettype($3));
|
||||||
| typemap_directive { $$ = $1; }
|
}
|
||||||
| scope_directive {$$ = $1; }
|
|
||||||
| type_directive { $$ = $1; }
|
|
||||||
;
|
;
|
||||||
|
|
||||||
scope_directive: SCOPE LBRACE interface RBRACE {
|
scope_directive: SCOPE LBRACE interface RBRACE {
|
||||||
|
|
@ -1460,8 +1472,7 @@ pname : ID def_args {
|
||||||
|
|
||||||
def_args : EQUAL definetype { $$ = $2; }
|
def_args : EQUAL definetype { $$ = $2; }
|
||||||
| EQUAL AND ID {
|
| EQUAL AND ID {
|
||||||
$$.text = NewString("");
|
$$.text = NewStringf("&%s", $3.text);
|
||||||
Printf($$.text,"&%s",$3.text);
|
|
||||||
$$.ivalue = LPARSE_T_USER;
|
$$.ivalue = LPARSE_T_USER;
|
||||||
}
|
}
|
||||||
| EQUAL LBRACE {
|
| EQUAL LBRACE {
|
||||||
|
|
@ -1671,7 +1682,11 @@ definetype : expr {
|
||||||
$$.text = $1.text;
|
$$.text = $1.text;
|
||||||
$$.ivalue = LPARSE_T_STRING;
|
$$.ivalue = LPARSE_T_STRING;
|
||||||
}
|
}
|
||||||
;
|
| ID {
|
||||||
|
$$.text = $1.text;
|
||||||
|
$$.ivalue = LPARSE_T_ERROR;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
expr : NUM_INT {
|
expr : NUM_INT {
|
||||||
$$.text = $1.text;
|
$$.text = $1.text;
|
||||||
|
|
|
||||||
|
|
@ -250,5 +250,3 @@ int check_numopt(ParmList *p) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -240,7 +240,16 @@ int swig11_file(DOH *node, void *clientdata) {
|
||||||
|
|
||||||
int swig11_scope(DOH *node, void *clientdata) {
|
int swig11_scope(DOH *node, void *clientdata) {
|
||||||
DOH *c;
|
DOH *c;
|
||||||
|
String *name;
|
||||||
|
int oldnative = Native;
|
||||||
c = Getchild(node);
|
c = Getchild(node);
|
||||||
|
name = Getname(node);
|
||||||
|
if (name && (Cmp(name,"native") == 0)) {
|
||||||
|
Native = 1;
|
||||||
|
Swig_emit_all(c,clientdata);
|
||||||
|
Native = oldnative;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Swig_typemap_new_scope();
|
Swig_typemap_new_scope();
|
||||||
Swig_emit_all(c,clientdata);
|
Swig_emit_all(c,clientdata);
|
||||||
Swig_typemap_pop_scope();
|
Swig_typemap_pop_scope();
|
||||||
|
|
@ -308,6 +317,8 @@ int swig11_pragma(DOH *node, void *clientdata) {
|
||||||
ReadOnly = 1;
|
ReadOnly = 1;
|
||||||
} else if (Cmp(name,"readwrite") == 0) {
|
} else if (Cmp(name,"readwrite") == 0) {
|
||||||
ReadOnly = 0;
|
ReadOnly = 0;
|
||||||
|
} else if (Cmp(name,"name") == 0) {
|
||||||
|
new_name = value;
|
||||||
}
|
}
|
||||||
lang->pragma(node);
|
lang->pragma(node);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -453,7 +464,12 @@ int swig11_function(DOH *node, void *clientdata) {
|
||||||
/* Can't wrap a static function. Oh well. */
|
/* Can't wrap a static function. Oh well. */
|
||||||
if (is_static) return 0;
|
if (is_static) return 0;
|
||||||
emit_extern_func(node,f_header);
|
emit_extern_func(node,f_header);
|
||||||
lang->function(node);
|
|
||||||
|
if (Native) {
|
||||||
|
lang->nativefunction(node);
|
||||||
|
} else {
|
||||||
|
lang->function(node);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -471,6 +487,11 @@ int swig11_variable(DOH *node, void *clientdata) {
|
||||||
if (WrapExtern) return 0;
|
if (WrapExtern) return 0;
|
||||||
if (Access != PUBLIC) return 0;
|
if (Access != PUBLIC) return 0;
|
||||||
|
|
||||||
|
if (Native) {
|
||||||
|
Printf(stderr,"%s:%d. Can't wrap variables in %%native mode (ignored).\n", Getfile(node),Getline(node));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
type = Gettype(node);
|
type = Gettype(node);
|
||||||
|
|
||||||
is_static = check_static(node);
|
is_static = check_static(node);
|
||||||
|
|
@ -579,6 +600,11 @@ int swig11_class(DOH *node, void *clientdata) {
|
||||||
Setattr(class_hash,name,node);
|
Setattr(class_hash,name,node);
|
||||||
if (WrapExtern) return 0;
|
if (WrapExtern) return 0;
|
||||||
|
|
||||||
|
if (Native) {
|
||||||
|
Printf(stderr,"%s:%d. Can't wrap structures or classes in %%native mode (ignored).\n", Getfile(node),Getline(node));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
set_scriptname(node);
|
set_scriptname(node);
|
||||||
class_name = name;
|
class_name = name;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -992,7 +992,14 @@ PYTHON::nativefunction(DOH *node) {
|
||||||
name = GetChar(node,"scriptname");
|
name = GetChar(node,"scriptname");
|
||||||
funcname = GetChar(node,"name");
|
funcname = GetChar(node,"name");
|
||||||
|
|
||||||
add_method(name, funcname,0);
|
/* Figure out what kind of function this is */
|
||||||
|
if (Swig_proto_cmp("f(p.PyObject,p.PyObject).p.PyObject",node) == 0) {
|
||||||
|
/* Not with keyword arguments */
|
||||||
|
add_method(name,funcname,0);
|
||||||
|
}
|
||||||
|
if (Swig_proto_cmp("f(p.PyObject,p.PyObject,p.PyObject).p.PyObject",node) == 0) {
|
||||||
|
add_method(name,funcname,1);
|
||||||
|
}
|
||||||
if (shadow) {
|
if (shadow) {
|
||||||
Printv(func, name, " = ", module, ".", name, "\n\n", 0);
|
Printv(func, name, " = ", module, ".", name, "\n\n", 0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -926,7 +926,17 @@ TCL8::nativefunction(DOH *node) {
|
||||||
|
|
||||||
name = GetChar(node,"scriptname");
|
name = GetChar(node,"scriptname");
|
||||||
funcname = GetChar(node,"name");
|
funcname = GetChar(node,"name");
|
||||||
Printf(f_init,"\t Tcl_CreateObjCommand(interp, SWIG_prefix \"%s\", %s, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);\n",name, funcname);
|
|
||||||
|
if ((Swig_proto_cmp("f(ClientData,p.Tcl_Interp,int,p.p.Tcl_Obj).int", node) == 0) ||
|
||||||
|
(Swig_proto_cmp("f(ClientData,p.Tcl_Interp,int,a().p.Tcl_Obj).int", node) == 0)) {
|
||||||
|
Printf(f_init,"\t Tcl_CreateObjCommand(interp, SWIG_prefix \"%s\", %s, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);\n",name, funcname);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((Swig_proto_cmp("f(ClientData,p.Tcl_Interp,int,p.p.char).int", node) == 0) ||
|
||||||
|
(Swig_proto_cmp("f(ClientData,p.Tcl_Interp,int,a().p.char).int", node) == 0)) {
|
||||||
|
Printf(f_init,"\t Tcl_CreateCommand(interp, SWIG_prefix \"%s\", %s, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);\n",name, funcname);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -988,9 +988,9 @@ Preprocessor_parse(DOH *s)
|
||||||
/* Printf(stdout,"checking '%s'\n", v1); */
|
/* Printf(stdout,"checking '%s'\n", v1); */
|
||||||
if (!check_id(v1)) {
|
if (!check_id(v1)) {
|
||||||
if (Len(comment) == 0)
|
if (Len(comment) == 0)
|
||||||
Printf(ns,"%%constant %s %s;\n", Getattr(m,"name"), v1);
|
Printf(ns,"%%constant %s = %s;\n", Getattr(m,"name"), v1);
|
||||||
else
|
else
|
||||||
Printf(ns,"%%constant %s %s; /*%s*/\n", Getattr(m,"name"),v1,comment);
|
Printf(ns,"%%constant %s = %s; /*%s*/\n", Getattr(m,"name"),v1,comment);
|
||||||
cpp_lines--;
|
cpp_lines--;
|
||||||
}
|
}
|
||||||
Delete(v1);
|
Delete(v1);
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,39 @@ String *Swig_string_mangle(String *s) {
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Swig_proto_cmp()
|
||||||
|
*
|
||||||
|
* Compares a function prototype against an expected type-string.
|
||||||
|
* For example, Swig_proto_cmp("f(p.void,p.Tcl_Interp,int,p.p.char).int", node)
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int
|
||||||
|
Swig_proto_cmp(const String_or_char *pat, DOH *node) {
|
||||||
|
SwigType *ty;
|
||||||
|
SwigType *ct;
|
||||||
|
ParmList *p;
|
||||||
|
List *tl;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
ty = Gettype(node);
|
||||||
|
p = Getparms(node);
|
||||||
|
if (!ty || !p) return -1;
|
||||||
|
ct = Copy(ty);
|
||||||
|
tl = NewList();
|
||||||
|
while (p) {
|
||||||
|
Append(tl,Gettype(p));
|
||||||
|
p = Getnext(p);
|
||||||
|
}
|
||||||
|
SwigType_add_function(ct,tl);
|
||||||
|
SwigType_strip_qualifiers(ct);
|
||||||
|
r = Cmp(pat,ct);
|
||||||
|
Delete(ct);
|
||||||
|
Delete(tl);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Swig_init()
|
* Swig_init()
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1056,6 +1056,18 @@ String *SwigType_manglestr(SwigType *s) {
|
||||||
return SwigType_manglestr_default(s);
|
return SwigType_manglestr_default(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* SwigType_strip_qualifiers()
|
||||||
|
*
|
||||||
|
* Rips all qualifiers out of a type.
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void SwigType_strip_qualifiers(SwigType *ty) {
|
||||||
|
/* Sick hack alert */
|
||||||
|
Replace(ty,"q(const).","", DOH_REPLACE_ANY);
|
||||||
|
Replace(ty,"q(volatile).", "", DOH_REPLACE_ANY);
|
||||||
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Scope handling
|
* Scope handling
|
||||||
*
|
*
|
||||||
|
|
@ -1220,7 +1232,7 @@ SwigType *SwigType_typedef_resolve(SwigType *t) {
|
||||||
level = scope_level;
|
level = scope_level;
|
||||||
while (level >= 0) {
|
while (level >= 0) {
|
||||||
/* See if we know about this type */
|
/* See if we know about this type */
|
||||||
type = Getattr(scopes[scope_level],base);
|
type = Getattr(scopes[level],base);
|
||||||
if (type) break;
|
if (type) break;
|
||||||
level--;
|
level--;
|
||||||
}
|
}
|
||||||
|
|
@ -1264,7 +1276,7 @@ int SwigType_istypedef(SwigType *t) {
|
||||||
level = scope_level;
|
level = scope_level;
|
||||||
while (level >= 0) {
|
while (level >= 0) {
|
||||||
/* See if we know about this type */
|
/* See if we know about this type */
|
||||||
type = Getattr(scopes[scope_level],base);
|
type = Getattr(scopes[level],base);
|
||||||
if (type) {
|
if (type) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -208,6 +208,7 @@ extern String *SwigType_default(SwigType *t);
|
||||||
extern int SwigType_type(SwigType *t);
|
extern int SwigType_type(SwigType *t);
|
||||||
extern void SwigType_remember(SwigType *t);
|
extern void SwigType_remember(SwigType *t);
|
||||||
extern void SwigType_emit_type_table(File *f_headers, File *f_table);
|
extern void SwigType_emit_type_table(File *f_headers, File *f_table);
|
||||||
|
extern void SwigType_strip_qualifiers(SwigType *t);
|
||||||
|
|
||||||
/* --- Parameters and Parameter Lists --- */
|
/* --- Parameters and Parameter Lists --- */
|
||||||
|
|
||||||
|
|
@ -301,6 +302,8 @@ extern String *Swig_string_escape(String *s);
|
||||||
extern String *Swig_string_mangle(String *s);
|
extern String *Swig_string_mangle(String *s);
|
||||||
extern void Swig_init();
|
extern void Swig_init();
|
||||||
|
|
||||||
|
extern int Swig_proto_cmp(const String_or_char *pat, DOH *node);
|
||||||
|
|
||||||
/* --- C Wrappers --- */
|
/* --- C Wrappers --- */
|
||||||
extern String *Swig_clocal(SwigType *t, String_or_char *name, String_or_char *value);
|
extern String *Swig_clocal(SwigType *t, String_or_char *name, String_or_char *value);
|
||||||
extern SwigType *Swig_clocal_type(SwigType *t);
|
extern SwigType *Swig_clocal_type(SwigType *t);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue