Fix C code where a typedef name was used for constructor and destructor names in %extend. Deprecate use of typedef names for constructor and destructor names going forwards.

This commit is contained in:
William S Fulton 2013-02-18 08:40:20 +00:00
commit d1b40b468b
6 changed files with 65 additions and 2 deletions

View file

@ -190,7 +190,13 @@ swig_apply_nargs.i:6: Error: Can't apply (char *str,int len) to (int x). Number
:::::::::::::::::::::::::::::::: swig_extend.i :::::::::::::::::::::::::::::::::::
swig_extend.i:19: Warning 326: Deprecated %extend name used - the struct name 'StructBName' should be used instead of the typedef name 'StructB'.
swig_extend.i:45: Warning 326: Deprecated %extend name used - the struct name 'stru_struct' should be used instead of the typedef name 'stru'.
swig_extend.i:56: Warning 326: Deprecated %extend name used - the union name 'uni_union' should be used instead of the typedef name 'uni'.
swig_extend.i:34: Warning 303: %extend defined for an undeclared class StructDName.
swig_extend.i:50: Warning 522: Use of an illegal constructor name 'stru' in %extend is deprecated, the constructor name should be 'stru_struct'.
swig_extend.i:53: Warning 523: Use of an illegal destructor name 'stru' in %extend is deprecated, the destructor name should be 'stru_struct'.
swig_extend.i:57: Warning 522: Use of an illegal constructor name 'uni' in %extend is deprecated, the constructor name should be 'uni_union'.
swig_extend.i:58: Warning 523: Use of an illegal destructor name 'uni' in %extend is deprecated, the destructor name should be 'uni_union'.
:::::::::::::::::::::::::::::::: swig_identifier.i :::::::::::::::::::::::::::::::::::
swig_identifier.i:5: Warning 503: Can't wrap 'foo bar' unless renamed to a valid identifier.

View file

@ -33,3 +33,28 @@ typedef struct StructD StructDName;
void method() {}
}
typedef struct stru_struct {
int bar;
} stru;
typedef union uni_union {
int un1;
double un2;
} uni;
%extend stru {
stru() {
stru* s = (stru*)malloc(sizeof(stru));
s->bar = 11;
return s;
}
~stru() {
free($self);
}
}
%extend uni {
uni() { return 0; }
~uni() { free($self); }
}

View file

@ -2,6 +2,10 @@
%warnfilter(SWIGWARN_PARSE_EXTEND_NAME) Space::tagCStruct;
%warnfilter(SWIGWARN_PARSE_EXTEND_NAME) tagEStruct;
%warnfilter(SWIGWARN_LANG_EXTEND_CONSTRUCTOR) Space::tagCStruct::CStruct;
%warnfilter(SWIGWARN_LANG_EXTEND_DESTRUCTOR) Space::tagCStruct::~CStruct;
%warnfilter(SWIGWARN_LANG_EXTEND_CONSTRUCTOR) tagEStruct::EStruct;
%warnfilter(SWIGWARN_LANG_EXTEND_DESTRUCTOR) tagEStruct::~EStruct;
%inline %{
int globalVar = 0;