Fix classLookup and enumLookup when the global scope operator is used on objects passed by value
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11092 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
6d2aef67d9
commit
22e4cb8e52
6 changed files with 103 additions and 5 deletions
|
|
@ -1,6 +1,10 @@
|
|||
Version 1.3.38 (in progress)
|
||||
================================
|
||||
|
||||
2008-01-28: wsfulton
|
||||
[Java, C#] Fix proxy class not being used when the global scope operator
|
||||
was used for parameters passed by value. Reported by David Piepgrass.
|
||||
|
||||
2008-01-15: wsfulton
|
||||
[Perl] Fix seg fault when running with -v option, reported by John Ky.
|
||||
|
||||
|
|
|
|||
|
|
@ -194,6 +194,7 @@ CPP_TEST_CASES += \
|
|||
fragments \
|
||||
friends \
|
||||
fvirtual \
|
||||
global_namespace \
|
||||
global_ns_arg \
|
||||
global_vars \
|
||||
grouping \
|
||||
|
|
|
|||
60
Examples/test-suite/global_namespace.i
Normal file
60
Examples/test-suite/global_namespace.i
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
%module global_namespace
|
||||
|
||||
// classes
|
||||
%inline %{
|
||||
class Klass1 {};
|
||||
class Klass2 {};
|
||||
class Klass3 {};
|
||||
class Klass4 {};
|
||||
class Klass5 {};
|
||||
class Klass6 {};
|
||||
class Klass7 {};
|
||||
|
||||
struct KlassMethods {
|
||||
static void methodA(::Klass1 v, const ::Klass2 cv, const ::Klass3 *cp, ::Klass4 *p, const ::Klass5 &cr, ::Klass6 &r, Klass7*& pr) {}
|
||||
static void methodB( Klass1 v, const Klass2 cv, const Klass3 *cp, Klass4 *p, const Klass5 &cr, Klass6 &r, Klass7*& pr) {}
|
||||
};
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
namespace Space {
|
||||
class XYZ1 {};
|
||||
class XYZ2 {};
|
||||
class XYZ3 {};
|
||||
class XYZ4 {};
|
||||
class XYZ5 {};
|
||||
class XYZ6 {};
|
||||
class XYZ7 {};
|
||||
}
|
||||
|
||||
struct XYZMethods {
|
||||
static void methodA(::Space::XYZ1 v, const ::Space::XYZ2 cv, const ::Space::XYZ3 *cp, ::Space::XYZ4 *p, const ::Space::XYZ5 &cr, ::Space::XYZ6 &r, Space::XYZ7*& pr) {}
|
||||
static void methodB( Space::XYZ1 v, const Space::XYZ2 cv, const Space::XYZ3 *cp, Space::XYZ4 *p, const Space::XYZ5 &cr, Space::XYZ6 &r, Space::XYZ7*& pr) {}
|
||||
};
|
||||
%}
|
||||
|
||||
//enums
|
||||
%inline %{
|
||||
enum AnEnum1 { anenum1 };
|
||||
enum AnEnum2 { anenum2 };
|
||||
enum AnEnum3 { anenum3 };
|
||||
|
||||
struct AnEnumMethods {
|
||||
static void methodA(::AnEnum1 v, const ::AnEnum2 cv, const ::AnEnum3 &cr) {}
|
||||
static void methodB( AnEnum1 v, const AnEnum2 cv, const AnEnum3 &cr) {}
|
||||
};
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
namespace Space {
|
||||
enum TheEnum1 { theenum1 };
|
||||
enum TheEnum2 { theenum2 };
|
||||
enum TheEnum3 { theenum3 };
|
||||
|
||||
struct TheEnumMethods {
|
||||
static void methodA(::Space::TheEnum1 v, const ::Space::TheEnum2 cv, const ::Space::TheEnum3 &cr) {}
|
||||
static void methodB( Space::TheEnum1 v, const Space::TheEnum2 cv, const Space::TheEnum3 &cr) {}
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
25
Examples/test-suite/java/global_namespace_runme.java
Normal file
25
Examples/test-suite/java/global_namespace_runme.java
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import global_namespace.*;
|
||||
|
||||
public class global_namespace_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("global_namespace");
|
||||
} 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[]) {
|
||||
|
||||
KlassMethods.methodA(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7());
|
||||
KlassMethods.methodB(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7());
|
||||
|
||||
XYZMethods.methodA(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7());
|
||||
XYZMethods.methodB(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7());
|
||||
|
||||
TheEnumMethods.methodA(TheEnum1.theenum1, TheEnum2.theenum2, TheEnum3.theenum3);
|
||||
TheEnumMethods.methodA(TheEnum1.theenum1, TheEnum2.theenum2, TheEnum3.theenum3);
|
||||
}
|
||||
}
|
||||
|
|
@ -2960,14 +2960,9 @@ Node *Language::classLookup(SwigType *s) {
|
|||
n = Getattr(classtypes, s);
|
||||
if (!n) {
|
||||
Symtab *stab = 0;
|
||||
// SwigType *lt = SwigType_ltype(s);
|
||||
// SwigType *ty1 = SwigType_typedef_resolve_all(lt);
|
||||
SwigType *ty1 = SwigType_typedef_resolve_all(s);
|
||||
SwigType *ty2 = SwigType_strip_qualifiers(ty1);
|
||||
// Printf(stdout, " stages... ty1: %s ty2: %s\n", ty1, ty2);
|
||||
// Delete(lt);
|
||||
Delete(ty1);
|
||||
// lt = 0;
|
||||
ty1 = 0;
|
||||
|
||||
String *base = SwigType_base(ty2);
|
||||
|
|
@ -2976,6 +2971,12 @@ Node *Language::classLookup(SwigType *s) {
|
|||
Replaceall(base, "struct ", "");
|
||||
Replaceall(base, "union ", "");
|
||||
|
||||
if (strncmp(Char(base), "::", 2) == 0) {
|
||||
String *oldbase = base;
|
||||
base = NewString(Char(base) + 2);
|
||||
Delete(oldbase);
|
||||
}
|
||||
|
||||
String *prefix = SwigType_prefix(ty2);
|
||||
|
||||
/* Do a symbol table search on the base type */
|
||||
|
|
@ -3049,6 +3050,12 @@ Node *Language::enumLookup(SwigType *s) {
|
|||
Replaceall(base, "enum ", "");
|
||||
String *prefix = SwigType_prefix(ty2);
|
||||
|
||||
if (strncmp(Char(base), "::", 2) == 0) {
|
||||
String *oldbase = base;
|
||||
base = NewString(Char(base) + 2);
|
||||
Delete(oldbase);
|
||||
}
|
||||
|
||||
/* Look for type in symbol table */
|
||||
while (!n) {
|
||||
Hash *nstab;
|
||||
|
|
|
|||
|
|
@ -840,6 +840,7 @@ SwigType *SwigType_typedef_resolve_all(SwigType *t) {
|
|||
*
|
||||
* Given a type declaration, this function tries to fully qualify it according to
|
||||
* typedef scope rules.
|
||||
* Inconsistency to be fixed: ::Foo returns ::Foo, whereas ::Foo * returns Foo *
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_typedef_qualified(SwigType *t) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue