remove old patch for features + def arg, but save the ignore/rename part. Now everything seems to be working.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6668 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2004-11-04 23:18:01 +00:00
commit 9d3cce855e
3 changed files with 47 additions and 32 deletions

View file

@ -74,7 +74,9 @@
// Rename a class member
%rename(bar2) Foo::bar;
%rename(newname) Foo::oldname;
%rename(newname) Foo::oldname(int x);
%ignore Foo::Foo(int x, int y = 0, int z = 0);
%inline %{
// Define a class
@ -83,6 +85,10 @@
static int bar;
static int spam;
Foo(){}
Foo(int x, int y = 0, int z = 0){}
// Use a renamed member as a default argument. SWIG has to resolve
// bar to Foo::bar and not Foo::spam. SWIG-1.3.11 got this wrong.
// (Different default parameter wrapping in SWIG-1.3.23 ensures SWIG doesn't have to resolve these symbols).

View file

@ -14,4 +14,30 @@ if default_args.cfunc3(1) != 4:
raise RuntimeError
f = default_args.Foo()
f.newname()
f.newname(1)
try:
f = default_args.Foo(1)
error = 1
except:
error = 0
if error: raise RuntimeError,"ignore is not working"
try:
f = default_args.Foo(1,2)
error = 1
except:
error = 0
if error: raise RuntimeError,"ignore is not working"
try:
f = default_args.Foo(1,2,3)
error = 1
except:
error = 0
if error: raise RuntimeError,"ignore is not working"

View file

@ -1088,12 +1088,7 @@ static int is_cfunction(Node *n) {
* The additional functions form a linked list of nodes with the head being the original Node n. */
static void default_arguments(Node *n) {
Node *function = n;
#ifdef MARCELO
String *fname = 0;
String *oname = 0;
SwigType *fdecl = 0;
int ignore = 0;
#endif
SwigType *fdecl = Getattr(function,"decl");
/* Do not add in functions if kwargs is being used or if user wants old default argument wrapping
(one wrapped method per function irrespective of number of default arguments) */
@ -1109,20 +1104,17 @@ static void default_arguments(Node *n) {
}
}
#ifdef MARCELO
if (function) {
fdecl = Getattr(function,"decl");
/* try to see if we need to ignore this method */
fname = Getattr(function,"name");
oname = make_name(fname,fdecl);
if (strncmp(Char(oname),"$ignore",7) == 0) {
ignore = 1;
}
}
#endif
while (function) {
ParmList *parms = Getattr(function,"parms");
/* try to see if we need to ignore this method */
int ignore = 0;
String *oname = make_name(Getattr(function,"name"), fdecl);
if (strncmp(Char(oname),"$ignore",7) == 0) {
ignore = 1;
oname = 0;
}
if (ParmList_has_defaultargs(parms)) {
/* Create a parameter list for the new function by copying all
@ -1132,11 +1124,7 @@ static void default_arguments(Node *n) {
/* Create new function and add to symbol table */
{
Node *new_function = new_node(Copy(nodeType(function)));
#ifdef MARCELO
SwigType *decl = Copy(fdecl);
#else
SwigType *decl = Copy(Getattr(function,"decl"));
#endif
int constqualifier = SwigType_isconst(decl);
Delete(SwigType_pop_function(decl)); /* remove the old parameter list from decl */
@ -1144,11 +1132,7 @@ static void default_arguments(Node *n) {
if (constqualifier)
SwigType_add_qualifier(decl,"const");
#ifdef MARCELO
Setattr(new_function,"name",fname);
#else
Setattr(new_function,"name",Getattr(function,"name"));
#endif
Setattr(new_function,"code",Copy(Getattr(function,"code")));
Setattr(new_function,"decl", decl);
Setattr(new_function,"parms",newparms);
@ -1171,13 +1155,12 @@ static void default_arguments(Node *n) {
if (templateparms) Setattr(new_function,"templateparms",CopyParmList(templateparms));
}
#ifdef MARCELO
/* apply the original function features */
Swig_features_get(Swig_cparse_features(),Namespaceprefix,fname,fdecl,new_function);
if (ignore) Setattr(new_function,"feature:ignore","1");
#endif
add_symbols(new_function);
yyrename = oname;
add_symbols(new_function);
yyrename = 0;
/* mark added functions as ones with overloaded parameters and point to the parsed method */
Setattr(new_function,"defaultargs", n);