summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Wette <karl.wette@ligo.org>2013-02-18 10:31:23 +0100
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2013-02-18 22:39:39 +0000
commit70cd52f44d4e61460524105dabbe1ac7f29dc6f2 (patch)
tree282ed402c729826dbaad35c24124f0cd8078d60e
parentb80f4dc5e257a343381e3dbeebb206c1376e3ca3 (diff)
downloadswig-70cd52f44d4e61460524105dabbe1ac7f29dc6f2.tar.gz
Use "(void)" instead of "()" when wrapping no-argument extension functions.
-rw-r--r--CHANGES.current39
-rw-r--r--Source/Swig/cwrap.c2
2 files changed, 40 insertions, 1 deletions
diff --git a/CHANGES.current b/CHANGES.current
index a111818d9..4f2477b02 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,6 +5,45 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.10 (in progress)
============================
+2013-02-18: wsfulton
+ Deprecate typedef names used as constructor and destructor names in %extend. The real
+ class/struct name should be used.
+
+ typedef struct tagEStruct {
+ int ivar;
+ } EStruct;
+
+ %extend tagEStruct {
+ EStruct() // illegal name, should be tagEStruct()
+ {
+ EStruct *s = new EStruct();
+ s->ivar = ivar0;
+ return s;
+ }
+ ~EStruct() // illegal name, should be ~tagEStruct()
+ {
+ delete $self;
+ }
+ }
+
+ For now these trigger a warning:
+
+ extend_constructor_destructor.i:107: Warning 522: Use of an illegal constructor name 'EStruct' in
+ %extend is deprecated, the constructor name should be 'tagEStruct'.
+ extend_constructor_destructor.i:111: Warning 523: Use of an illegal destructor name 'EStruct' in
+ %extend is deprecated, the destructor name should be 'tagEStruct'.
+
+ These %extend destructor and constructor names were valid up to swig-2.0.4, however swig-2.0.5 ignored
+ them altogether for C code as reported in SF bug #1306. The old behaviour of using them has been
+ restored for now, but is officially deprecated. This does not apply to anonymously defined typedef
+ classes/structs such as:
+
+ typedef struct {...} X;
+
+2013-02-17: kwwette
+ When generating functions which wrap C extension code, use "(void)" for no-argument functions
+ instead of "()". This prevents warnings when compiling with "gcc -Wstrict-prototypes".
+
2013-02-15: wsfulton
Deprecate typedef names used in %extend that are not the real class/struct name. For example:
diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c
index 8cd48e94e..c7e101842 100644
--- a/Source/Swig/cwrap.c
+++ b/Source/Swig/cwrap.c
@@ -807,7 +807,7 @@ void Swig_replace_special_variables(Node *n, Node *parentnode, String *code) {
* ----------------------------------------------------------------------------- */
static String *extension_code(Node *n, const String *function_name, ParmList *parms, SwigType *return_type, const String *code, int cplusplus, const String *self) {
String *parms_str = cplusplus ? ParmList_str_defaultargs(parms) : ParmList_str(parms);
- String *sig = NewStringf("%s(%s)", function_name, parms_str);
+ String *sig = NewStringf("%s(%s)", function_name, (cplusplus || Len(parms_str)) ? parms_str : "void");
String *rt_sig = SwigType_str(return_type, sig);
String *body = NewStringf("SWIGINTERN %s", rt_sig);
Printv(body, code, "\n", NIL);