diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2023-05-06 11:36:30 +0100 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2023-05-06 11:36:30 +0100 |
commit | e0c7f81ba58489f25764e7b52884c81758c4a41c (patch) | |
tree | c41961e19486668ada1db23c5e94ad40fd8e6357 | |
parent | 87690113cd3883e25a8d7040054d008fccf9b5c2 (diff) | |
parent | 65be8812959aa0d2e9805e31549bbeac0cc89691 (diff) | |
download | swig-e0c7f81ba58489f25764e7b52884c81758c4a41c.tar.gz |
Merge branch 'typedef-namespace'
* typedef-namespace:
Partial revert of previous commit for typedefs
add an unit test
tentative fix for typedef/using declaration to struct typedef
Conflicts:
CHANGES.current
-rw-r--r-- | CHANGES.current | 3 | ||||
-rw-r--r-- | Examples/test-suite/common.mk | 1 | ||||
-rw-r--r-- | Examples/test-suite/cpp11_using_typedef_struct.i | 21 | ||||
-rw-r--r-- | Examples/test-suite/javascript/cpp11_using_typedef_struct_runme.js | 13 | ||||
-rw-r--r-- | Source/Swig/symbol.c | 6 |
5 files changed, 41 insertions, 3 deletions
diff --git a/CHANGES.current b/CHANGES.current index 0fd067f06..f76519d31 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.2.0 (in progress) =========================== +2023-05-06: mmomtchev, wsfulton + #2550 Fix typedef/using declarations to a typedef struct/class. + 2023-05-04: erezgeva [D] #2538 Drop support for D1/Tango, which was discontinued in 2012. Wrappers for D2/Phobos are now generated by default, though diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index eb80977f7..c781bd930 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -636,6 +636,7 @@ CPP11_TEST_CASES += \ cpp11_uniform_initialization \ cpp11_unrestricted_unions \ cpp11_userdefined_literals \ + cpp11_using_typedef_struct \ cpp11_variadic_function_templates \ cpp11_variadic_templates \ diff --git a/Examples/test-suite/cpp11_using_typedef_struct.i b/Examples/test-suite/cpp11_using_typedef_struct.i new file mode 100644 index 000000000..81efdc310 --- /dev/null +++ b/Examples/test-suite/cpp11_using_typedef_struct.i @@ -0,0 +1,21 @@ +%module cpp11_using_typedef_struct + +%inline +%{ +namespace nspace1 { + typedef struct _xAffineMatrix { + int x, y, z; + } AffineMatrix; + + struct _xCacheView { + int x; + }; + typedef struct _xCacheView CacheView; +} + +using nspace1::AffineMatrix; +using nspace1::CacheView; + +int fn1(AffineMatrix a) { return a.x; }; +int fn2(CacheView a) { return a.x; }; +%} diff --git a/Examples/test-suite/javascript/cpp11_using_typedef_struct_runme.js b/Examples/test-suite/javascript/cpp11_using_typedef_struct_runme.js new file mode 100644 index 000000000..43a26ddcd --- /dev/null +++ b/Examples/test-suite/javascript/cpp11_using_typedef_struct_runme.js @@ -0,0 +1,13 @@ +var cpp11_using_typedef_struct = require("cpp11_using_typedef_struct"); + +var b = new cpp11_using_typedef_struct.AffineMatrix(); +b.x = b.y = b.z = 1; + +if (cpp11_using_typedef_struct.fn1(b) != b.x) + throw new Error('failed'); + +var bb = new cpp11_using_typedef_struct._xCacheView(); +bb.x = 123; + +if (cpp11_using_typedef_struct.fn2(bb) != 123) + throw new Error('failed'); diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c index 7c7c4d100..8e24c9ec7 100644 --- a/Source/Swig/symbol.c +++ b/Source/Swig/symbol.c @@ -839,10 +839,10 @@ Node *Swig_symbol_add(const_String_or_char_ptr symname, Node *n) { /* Hmmm. This appears to be okay. Make sure the symbol table refers to the allow_type node */ - if (td != c) { + Setattr(n, "sym:symtab", current_symtab); + Setattr(n, "sym:name", symname); + if (td == n) { Setattr(current, symname, td); - Setattr(td, "sym:symtab", current_symtab); - Setattr(td, "sym:name", symname); } return n; } |