Merge branch 'diorcety-typedef-prefix'
* diorcety-typedef-prefix: Modify typedef_typedef testcase to work for all languages Add test for checking prefix resolving in typedef Typedef typedef prefix test for templates Resolve prefix when resolving typedef Conflicts: CHANGES.current
This commit is contained in:
commit
9033b2de47
7 changed files with 175 additions and 43 deletions
|
|
@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release.
|
||||||
Version 3.0.0 (in progress)
|
Version 3.0.0 (in progress)
|
||||||
============================
|
============================
|
||||||
|
|
||||||
|
2014-01-14: diorcety
|
||||||
|
Patch #112 - Fix symbol resolution involving scopes that have multiple levels
|
||||||
|
of typedefs - fixes some template resolutions as well as some typemap searches.
|
||||||
|
|
||||||
2014-01-13: kwwette
|
2014-01-13: kwwette
|
||||||
[Octave] update support to Octave version 3.8.0
|
[Octave] update support to Octave version 3.8.0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -424,6 +424,7 @@ CPP_TEST_CASES += \
|
||||||
template_typedef_ns \
|
template_typedef_ns \
|
||||||
template_typedef_ptr \
|
template_typedef_ptr \
|
||||||
template_typedef_rec \
|
template_typedef_rec \
|
||||||
|
template_typedef_typedef \
|
||||||
template_typemaps \
|
template_typemaps \
|
||||||
template_typemaps_typedef \
|
template_typemaps_typedef \
|
||||||
template_typemaps_typedef2 \
|
template_typemaps_typedef2 \
|
||||||
|
|
@ -442,6 +443,7 @@ CPP_TEST_CASES += \
|
||||||
typedef_scope \
|
typedef_scope \
|
||||||
typedef_sizet \
|
typedef_sizet \
|
||||||
typedef_struct \
|
typedef_struct \
|
||||||
|
typedef_typedef \
|
||||||
typemap_arrays \
|
typemap_arrays \
|
||||||
typemap_array_qualifiers \
|
typemap_array_qualifiers \
|
||||||
typemap_delete \
|
typemap_delete \
|
||||||
|
|
|
||||||
26
Examples/test-suite/java/template_typedef_typedef_runme.java
Normal file
26
Examples/test-suite/java/template_typedef_typedef_runme.java
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
import template_typedef_typedef.*;
|
||||||
|
|
||||||
|
public class template_typedef_typedef_runme {
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("template_typedef_typedef");
|
||||||
|
} 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[]) {
|
||||||
|
ObjectBase ob1 = new ObjectBase();
|
||||||
|
ob1.getBlabla1(new ObjectBase());
|
||||||
|
Object2Base ob2 = new Object2Base();
|
||||||
|
ob2.getBlabla2(new Object2Base());
|
||||||
|
|
||||||
|
Factory factory = new Factory();
|
||||||
|
factory.getBlabla3(new ObjectBase());
|
||||||
|
factory.getBlabla4(new Object2Base());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
5
Examples/test-suite/python/typedef_typedef_runme.py
Normal file
5
Examples/test-suite/python/typedef_typedef_runme.py
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
import typedef_typedef
|
||||||
|
|
||||||
|
b = typedef_typedef.B()
|
||||||
|
if b.getValue(123) == 1234:
|
||||||
|
print "Failed !!!"
|
||||||
43
Examples/test-suite/template_typedef_typedef.i
Normal file
43
Examples/test-suite/template_typedef_typedef.i
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
%module template_typedef_typedef
|
||||||
|
|
||||||
|
// Github issue #50
|
||||||
|
// The Object2::getBlabla2 and Object::getBlabla1 functions were not resolving to the correct template types
|
||||||
|
|
||||||
|
%inline%{
|
||||||
|
|
||||||
|
class Factory;
|
||||||
|
class Base {
|
||||||
|
public:
|
||||||
|
typedef Factory ABCD;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace TT{
|
||||||
|
template <typename T>
|
||||||
|
class Object2:public T {
|
||||||
|
public:
|
||||||
|
void getBlabla2(typename T::ABCD::CC2 c) {
|
||||||
|
};
|
||||||
|
};
|
||||||
|
template <typename T>
|
||||||
|
class Object:public T {
|
||||||
|
public:
|
||||||
|
void getBlabla1(typename T::ABCD::CC1 c) {
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class Factory {
|
||||||
|
public:
|
||||||
|
typedef TT::Object<Base> CC1;
|
||||||
|
typedef TT::Object2<Base> CC2;
|
||||||
|
void getBlabla4(CC2 c) {
|
||||||
|
};
|
||||||
|
void getBlabla3(CC1 c) {
|
||||||
|
};
|
||||||
|
};
|
||||||
|
%}
|
||||||
|
|
||||||
|
%template(ObjectBase) TT::Object<Base>;
|
||||||
|
%template(Object2Base) TT::Object2<Base>;
|
||||||
|
|
||||||
37
Examples/test-suite/typedef_typedef.i
Normal file
37
Examples/test-suite/typedef_typedef.i
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
%module typedef_typedef
|
||||||
|
|
||||||
|
// Check C::Bar::Foo resolves to A::Foo in typemap search
|
||||||
|
|
||||||
|
%typemap(in) SWIGTYPE, int "__wrong_in_typemap__will_not_compile__"
|
||||||
|
|
||||||
|
%typemap(in) A::Foo {
|
||||||
|
$1 = 1234; /* A::Foo in typemap */
|
||||||
|
}
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
struct A
|
||||||
|
{
|
||||||
|
typedef int Foo;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct C
|
||||||
|
{
|
||||||
|
typedef A Bar;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct B
|
||||||
|
{
|
||||||
|
C::Bar::Foo getValue(C::Bar::Foo intvalue) {
|
||||||
|
return intvalue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
%}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
An issue can be the steps resolution.
|
||||||
|
1) C::Bar is A. So C::Bar::Foo should be first resolved as A::Foo.
|
||||||
|
2) Then A::Foo should be resolved int.
|
||||||
|
If the first step is skipped the typemap is not applied.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
@ -602,7 +602,7 @@ SwigType *SwigType_typedef_resolve(const SwigType *t) {
|
||||||
Typetab *s;
|
Typetab *s;
|
||||||
Hash *ttab;
|
Hash *ttab;
|
||||||
String *namebase = 0;
|
String *namebase = 0;
|
||||||
String *nameprefix = 0;
|
String *nameprefix = 0, *rnameprefix = 0;
|
||||||
int newtype = 0;
|
int newtype = 0;
|
||||||
|
|
||||||
resolved_scope = 0;
|
resolved_scope = 0;
|
||||||
|
|
@ -647,51 +647,66 @@ SwigType *SwigType_typedef_resolve(const SwigType *t) {
|
||||||
Printf(stdout, "nameprefix = '%s'\n", nameprefix);
|
Printf(stdout, "nameprefix = '%s'\n", nameprefix);
|
||||||
#endif
|
#endif
|
||||||
if (nameprefix) {
|
if (nameprefix) {
|
||||||
/* Name had a prefix on it. See if we can locate the proper scope for it */
|
rnameprefix = SwigType_typedef_resolve(nameprefix);
|
||||||
String *rnameprefix = template_parameters_resolve(nameprefix);
|
if(rnameprefix != NULL) {
|
||||||
nameprefix = rnameprefix ? Copy(rnameprefix) : nameprefix;
|
|
||||||
Delete(rnameprefix);
|
|
||||||
s = SwigType_find_scope(s, nameprefix);
|
|
||||||
|
|
||||||
/* Couldn't locate a scope for the type. */
|
|
||||||
if (!s) {
|
|
||||||
Delete(base);
|
|
||||||
Delete(namebase);
|
|
||||||
Delete(nameprefix);
|
|
||||||
r = 0;
|
|
||||||
goto return_result;
|
|
||||||
}
|
|
||||||
/* Try to locate the name starting in the scope */
|
|
||||||
#ifdef SWIG_DEBUG
|
#ifdef SWIG_DEBUG
|
||||||
Printf(stdout, "namebase = '%s'\n", namebase);
|
Printf(stdout, "nameprefix '%s' is a typedef to '%s'\n", nameprefix, rnameprefix);
|
||||||
#endif
|
#endif
|
||||||
type = typedef_resolve(s, namebase);
|
type = Copy(namebase);
|
||||||
if (type && resolved_scope) {
|
Insert(type, 0, "::");
|
||||||
/* we need to look for the resolved type, this will also
|
Insert(type, 0, rnameprefix);
|
||||||
fix the resolved_scope if 'type' and 'namebase' are
|
if (strncmp(Char(type), "::", 2) == 0) {
|
||||||
declared in different scopes */
|
Delitem(type, 0);
|
||||||
String *rtype = 0;
|
Delitem(type, 0);
|
||||||
rtype = typedef_resolve(resolved_scope, type);
|
}
|
||||||
if (rtype)
|
newtype = 1;
|
||||||
type = rtype;
|
} else {
|
||||||
}
|
/* Name had a prefix on it. See if we can locate the proper scope for it */
|
||||||
#ifdef SWIG_DEBUG
|
String *rnameprefix = template_parameters_resolve(nameprefix);
|
||||||
Printf(stdout, "%s type = '%s'\n", Getattr(s, "name"), type);
|
nameprefix = rnameprefix ? Copy(rnameprefix) : nameprefix;
|
||||||
#endif
|
Delete(rnameprefix);
|
||||||
if (type && (!Swig_scopename_check(type)) && resolved_scope) {
|
s = SwigType_find_scope(s, nameprefix);
|
||||||
Typetab *rtab = resolved_scope;
|
|
||||||
String *qname = Getattr(resolved_scope, "qname");
|
/* Couldn't locate a scope for the type. */
|
||||||
/* If qualified *and* the typename is defined from the resolved scope, we qualify */
|
if (!s) {
|
||||||
if ((qname) && typedef_resolve(resolved_scope, type)) {
|
Delete(base);
|
||||||
type = Copy(type);
|
Delete(namebase);
|
||||||
Insert(type, 0, "::");
|
Delete(nameprefix);
|
||||||
Insert(type, 0, qname);
|
r = 0;
|
||||||
#ifdef SWIG_DEBUG
|
goto return_result;
|
||||||
Printf(stdout, "qual %s \n", type);
|
}
|
||||||
#endif
|
/* Try to locate the name starting in the scope */
|
||||||
newtype = 1;
|
#ifdef SWIG_DEBUG
|
||||||
|
Printf(stdout, "namebase = '%s'\n", namebase);
|
||||||
|
#endif
|
||||||
|
type = typedef_resolve(s, namebase);
|
||||||
|
if (type && resolved_scope) {
|
||||||
|
/* we need to look for the resolved type, this will also
|
||||||
|
fix the resolved_scope if 'type' and 'namebase' are
|
||||||
|
declared in different scopes */
|
||||||
|
String *rtype = 0;
|
||||||
|
rtype = typedef_resolve(resolved_scope, type);
|
||||||
|
if (rtype)
|
||||||
|
type = rtype;
|
||||||
|
}
|
||||||
|
#ifdef SWIG_DEBUG
|
||||||
|
Printf(stdout, "%s type = '%s'\n", Getattr(s, "name"), type);
|
||||||
|
#endif
|
||||||
|
if ((type) && (!Swig_scopename_check(type)) && resolved_scope) {
|
||||||
|
Typetab *rtab = resolved_scope;
|
||||||
|
String *qname = Getattr(resolved_scope, "qname");
|
||||||
|
/* If qualified *and* the typename is defined from the resolved scope, we qualify */
|
||||||
|
if ((qname) && typedef_resolve(resolved_scope, type)) {
|
||||||
|
type = Copy(type);
|
||||||
|
Insert(type, 0, "::");
|
||||||
|
Insert(type, 0, qname);
|
||||||
|
#ifdef SWIG_DEBUG
|
||||||
|
Printf(stdout, "qual %s \n", type);
|
||||||
|
#endif
|
||||||
|
newtype = 1;
|
||||||
|
}
|
||||||
|
resolved_scope = rtab;
|
||||||
}
|
}
|
||||||
resolved_scope = rtab;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Name is unqualified. */
|
/* Name is unqualified. */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue