Wide range of minor bug fixes and improvements.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@966 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
22ad3083bb
commit
ce983e3203
10 changed files with 132 additions and 28 deletions
|
|
@ -2,9 +2,9 @@
|
|||
/* SWIG version information */
|
||||
|
||||
#ifndef SWIG_VERSION
|
||||
#define SWIG_VERSION "1.3u-20001008-1349"
|
||||
#define SWIG_VERSION "1.3u-20001219-1815"
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_SPIN
|
||||
#define SWIG_SPIN "(Alpha 5)"
|
||||
#define SWIG_SPIN "(Alpha 6)"
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@ static int promote(int t1, int t2) {
|
|||
%type <node> tm_args tm_parm tm_tail tm_list
|
||||
%type <tmname> tm_name
|
||||
%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> variable_decl function_decl enum_decl typedef_decl stail edecl typedeflist
|
||||
%type <nodelist> enumlist interface
|
||||
|
|
@ -345,11 +345,25 @@ swig_directive : MODULE idstring {
|
|||
LParse_set_location($7.filename,$7.line-1);
|
||||
$$ = $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);
|
||||
Setattr($$,ATTR_NAME,$2.text);
|
||||
Setattr($$,ATTR_VALUE,$3.text);
|
||||
switch($3.ivalue) {
|
||||
Setattr($$,ATTR_VALUE,$4.text);
|
||||
switch($4.ivalue) {
|
||||
case LPARSE_T_DOUBLE:
|
||||
Setattr($$,ATTR_TYPE,"double");
|
||||
break;
|
||||
|
|
@ -379,8 +393,8 @@ swig_directive : MODULE idstring {
|
|||
break;
|
||||
case LPARSE_T_CHAR:
|
||||
Setattr($$,ATTR_TYPE,"char");
|
||||
Delitem($3.text,0);
|
||||
Delitem($3.text,DOH_END);
|
||||
Delitem($4.text,0);
|
||||
Delitem($4.text,DOH_END);
|
||||
break;
|
||||
case LPARSE_T_STRING:
|
||||
Setattr($$,ATTR_TYPE,"p.char");
|
||||
|
|
@ -389,14 +403,12 @@ swig_directive : MODULE idstring {
|
|||
break;
|
||||
}
|
||||
}
|
||||
| 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 LPAREN parm RPAREN ID def_args SEMI {
|
||||
$$ = new_node("swig:constant", $5.filename, $5.line);
|
||||
Setattr($$,ATTR_NAME,$5.text);
|
||||
Setattr($$,ATTR_VALUE,$6.text);
|
||||
Setattr($$,ATTR_TYPE,Gettype($3));
|
||||
}
|
||||
;
|
||||
|
||||
scope_directive: SCOPE LBRACE interface RBRACE {
|
||||
|
|
@ -1460,8 +1472,7 @@ pname : ID def_args {
|
|||
|
||||
def_args : EQUAL definetype { $$ = $2; }
|
||||
| EQUAL AND ID {
|
||||
$$.text = NewString("");
|
||||
Printf($$.text,"&%s",$3.text);
|
||||
$$.text = NewStringf("&%s", $3.text);
|
||||
$$.ivalue = LPARSE_T_USER;
|
||||
}
|
||||
| EQUAL LBRACE {
|
||||
|
|
@ -1671,7 +1682,11 @@ definetype : expr {
|
|||
$$.text = $1.text;
|
||||
$$.ivalue = LPARSE_T_STRING;
|
||||
}
|
||||
;
|
||||
| ID {
|
||||
$$.text = $1.text;
|
||||
$$.ivalue = LPARSE_T_ERROR;
|
||||
}
|
||||
;
|
||||
|
||||
expr : NUM_INT {
|
||||
$$.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) {
|
||||
DOH *c;
|
||||
String *name;
|
||||
int oldnative = Native;
|
||||
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_emit_all(c,clientdata);
|
||||
Swig_typemap_pop_scope();
|
||||
|
|
@ -308,6 +317,8 @@ int swig11_pragma(DOH *node, void *clientdata) {
|
|||
ReadOnly = 1;
|
||||
} else if (Cmp(name,"readwrite") == 0) {
|
||||
ReadOnly = 0;
|
||||
} else if (Cmp(name,"name") == 0) {
|
||||
new_name = value;
|
||||
}
|
||||
lang->pragma(node);
|
||||
return 0;
|
||||
|
|
@ -453,7 +464,12 @@ int swig11_function(DOH *node, void *clientdata) {
|
|||
/* Can't wrap a static function. Oh well. */
|
||||
if (is_static) return 0;
|
||||
emit_extern_func(node,f_header);
|
||||
lang->function(node);
|
||||
|
||||
if (Native) {
|
||||
lang->nativefunction(node);
|
||||
} else {
|
||||
lang->function(node);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -471,6 +487,11 @@ int swig11_variable(DOH *node, void *clientdata) {
|
|||
if (WrapExtern) 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);
|
||||
|
||||
is_static = check_static(node);
|
||||
|
|
@ -579,6 +600,11 @@ int swig11_class(DOH *node, void *clientdata) {
|
|||
Setattr(class_hash,name,node);
|
||||
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);
|
||||
class_name = name;
|
||||
|
||||
|
|
|
|||
|
|
@ -992,7 +992,14 @@ PYTHON::nativefunction(DOH *node) {
|
|||
name = GetChar(node,"scriptname");
|
||||
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) {
|
||||
Printv(func, name, " = ", module, ".", name, "\n\n", 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -926,7 +926,17 @@ TCL8::nativefunction(DOH *node) {
|
|||
|
||||
name = GetChar(node,"scriptname");
|
||||
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); */
|
||||
if (!check_id(v1)) {
|
||||
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
|
||||
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--;
|
||||
}
|
||||
Delete(v1);
|
||||
|
|
|
|||
|
|
@ -159,6 +159,39 @@ String *Swig_string_mangle(String *s) {
|
|||
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()
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1056,6 +1056,18 @@ String *SwigType_manglestr(SwigType *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
|
||||
*
|
||||
|
|
@ -1220,7 +1232,7 @@ SwigType *SwigType_typedef_resolve(SwigType *t) {
|
|||
level = scope_level;
|
||||
while (level >= 0) {
|
||||
/* See if we know about this type */
|
||||
type = Getattr(scopes[scope_level],base);
|
||||
type = Getattr(scopes[level],base);
|
||||
if (type) break;
|
||||
level--;
|
||||
}
|
||||
|
|
@ -1264,7 +1276,7 @@ int SwigType_istypedef(SwigType *t) {
|
|||
level = scope_level;
|
||||
while (level >= 0) {
|
||||
/* See if we know about this type */
|
||||
type = Getattr(scopes[scope_level],base);
|
||||
type = Getattr(scopes[level],base);
|
||||
if (type) {
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -208,6 +208,7 @@ extern String *SwigType_default(SwigType *t);
|
|||
extern int SwigType_type(SwigType *t);
|
||||
extern void SwigType_remember(SwigType *t);
|
||||
extern void SwigType_emit_type_table(File *f_headers, File *f_table);
|
||||
extern void SwigType_strip_qualifiers(SwigType *t);
|
||||
|
||||
/* --- Parameters and Parameter Lists --- */
|
||||
|
||||
|
|
@ -301,6 +302,8 @@ extern String *Swig_string_escape(String *s);
|
|||
extern String *Swig_string_mangle(String *s);
|
||||
extern void Swig_init();
|
||||
|
||||
extern int Swig_proto_cmp(const String_or_char *pat, DOH *node);
|
||||
|
||||
/* --- C Wrappers --- */
|
||||
extern String *Swig_clocal(SwigType *t, String_or_char *name, String_or_char *value);
|
||||
extern SwigType *Swig_clocal_type(SwigType *t);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue