Merge branch 'davedissian-redundant-typedef-fix'
* davedissian-redundant-typedef-fix: Add more runtime typedef_classforward_same_name runtime testing Fixed 'typedef class Foo Foo;' edge case by iterating through linked list. Added test case for a forward declaration in a typedef with the same name
This commit is contained in:
commit
6607acdf3a
6 changed files with 67 additions and 0 deletions
|
|
@ -15,6 +15,11 @@ Version 4.0.0 (in progress)
|
||||||
[Python] Replace pep8 with pycodestyle for checking the Python code style when
|
[Python] Replace pep8 with pycodestyle for checking the Python code style when
|
||||||
running Python tests.
|
running Python tests.
|
||||||
|
|
||||||
|
2017-12-30: davedissian
|
||||||
|
Fixed a symbol lookup issue when encountering a typedef of a symbol from the tag
|
||||||
|
namespace to the global namespace when the names are identical, such as 'typedef
|
||||||
|
struct Foo Foo;'.
|
||||||
|
|
||||||
2017-12-13: wsfulton
|
2017-12-13: wsfulton
|
||||||
[Perl] add missing support for directorfree typemaps.
|
[Perl] add missing support for directorfree typemaps.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -491,6 +491,7 @@ CPP_TEST_CASES += \
|
||||||
throw_exception \
|
throw_exception \
|
||||||
typedef_array_member \
|
typedef_array_member \
|
||||||
typedef_class \
|
typedef_class \
|
||||||
|
typedef_classforward_same_name \
|
||||||
typedef_funcptr \
|
typedef_funcptr \
|
||||||
typedef_inherit \
|
typedef_inherit \
|
||||||
typedef_mptr \
|
typedef_mptr \
|
||||||
|
|
@ -677,6 +678,7 @@ C_TEST_CASES += \
|
||||||
string_simple \
|
string_simple \
|
||||||
struct_rename \
|
struct_rename \
|
||||||
struct_initialization \
|
struct_initialization \
|
||||||
|
typedef_classforward_same_name \
|
||||||
typedef_struct \
|
typedef_struct \
|
||||||
typemap_subst \
|
typemap_subst \
|
||||||
union_parameter \
|
union_parameter \
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
|
||||||
|
import typedef_classforward_same_name.*;
|
||||||
|
|
||||||
|
public class typedef_classforward_same_name_runme {
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("typedef_classforward_same_name");
|
||||||
|
} catch (UnsatisfiedLinkError e) {
|
||||||
|
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String argv[]) {
|
||||||
|
Foo foo = new Foo();
|
||||||
|
foo.setX(5);
|
||||||
|
if (typedef_classforward_same_name.extractFoo(foo) != 5)
|
||||||
|
throw new RuntimeException("unexpected value");
|
||||||
|
|
||||||
|
Boo boo = new Boo();
|
||||||
|
boo.setX(5);
|
||||||
|
if (typedef_classforward_same_name.extractBoo(boo) != 5)
|
||||||
|
throw new RuntimeException("unexpected value");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
from typedef_classforward_same_name import *
|
||||||
|
|
||||||
|
foo = Foo()
|
||||||
|
foo.x = 5
|
||||||
|
if extractFoo(foo) != 5:
|
||||||
|
raise RuntimeError("unexpected value")
|
||||||
|
|
||||||
|
boo = Boo()
|
||||||
|
boo.x = 5
|
||||||
|
if extractBoo(boo) != 5:
|
||||||
|
raise RuntimeError("unexpected value")
|
||||||
15
Examples/test-suite/typedef_classforward_same_name.i
Normal file
15
Examples/test-suite/typedef_classforward_same_name.i
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
%module typedef_classforward_same_name
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
typedef struct Foo Foo;
|
||||||
|
struct Foo {
|
||||||
|
int x;
|
||||||
|
};
|
||||||
|
int extractFoo(Foo* foo) { return foo->x; }
|
||||||
|
|
||||||
|
struct Boo {
|
||||||
|
int x;
|
||||||
|
};
|
||||||
|
typedef struct Boo Boo;
|
||||||
|
int extractBoo(Boo* boo) { return boo->x; }
|
||||||
|
%}
|
||||||
|
|
@ -3296,6 +3296,14 @@ Node *Language::classLookup(const SwigType *s) const {
|
||||||
break;
|
break;
|
||||||
if (Strcmp(nodeType(n), "class") == 0)
|
if (Strcmp(nodeType(n), "class") == 0)
|
||||||
break;
|
break;
|
||||||
|
Node *sibling = n;
|
||||||
|
while (sibling) {
|
||||||
|
sibling = Getattr(sibling, "csym:nextSibling");
|
||||||
|
if (sibling && Strcmp(nodeType(sibling), "class") == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (sibling)
|
||||||
|
break;
|
||||||
n = parentNode(n);
|
n = parentNode(n);
|
||||||
if (!n)
|
if (!n)
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue