nspace fixes and adding in missing symbols in language symbol tables for Java and C#
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11937 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
7af8eb954b
commit
7ed1528349
6 changed files with 174 additions and 55 deletions
|
|
@ -22,16 +22,26 @@ public class runme
|
||||||
if (channel != nspaceNamespace.Outer.Inner1.Color.Channel.Transmission)
|
if (channel != nspaceNamespace.Outer.Inner1.Color.Channel.Transmission)
|
||||||
throw new ApplicationException("Transmission wrong");
|
throw new ApplicationException("Transmission wrong");
|
||||||
|
|
||||||
// static member variables
|
// class anonymous enums
|
||||||
nspaceNamespace.Outer.Inner1.Color.staticMemberVariable = 789;
|
int val1 = nspaceNamespace.Outer.Inner1.Color.ColorEnumVal1;
|
||||||
if (nspaceNamespace.Outer.Inner1.Color.staticMemberVariable != 789)
|
int val2 = nspaceNamespace.Outer.Inner1.Color.ColorEnumVal2;
|
||||||
throw new ApplicationException("static member variable failed");
|
if (val1 != 0 || val2 != 0x22)
|
||||||
|
throw new ApplicationException("ColorEnumVal wrong");
|
||||||
|
|
||||||
// instance member variables
|
// instance member variables
|
||||||
color.instanceMemberVariable = 123;
|
color.instanceMemberVariable = 123;
|
||||||
if (color.instanceMemberVariable != 123)
|
if (color.instanceMemberVariable != 123)
|
||||||
throw new ApplicationException("instance member variable failed");
|
throw new ApplicationException("instance member variable failed");
|
||||||
|
|
||||||
|
// static member variables
|
||||||
|
nspaceNamespace.Outer.Inner1.Color.staticMemberVariable = 789;
|
||||||
|
if (nspaceNamespace.Outer.Inner1.Color.staticMemberVariable != 789)
|
||||||
|
throw new ApplicationException("static member variable failed");
|
||||||
|
if (nspaceNamespace.Outer.Inner1.Color.staticConstMemberVariable != 222)
|
||||||
|
throw new ApplicationException("static const member variable failed");
|
||||||
|
if (nspaceNamespace.Outer.Inner1.Color.staticConstEnumMemberVariable != nspaceNamespace.Outer.Inner1.Color.Channel.Transmission)
|
||||||
|
throw new ApplicationException("static const enum member variable failed");
|
||||||
|
|
||||||
// check globals in a namespace don't get mangled with the nspaceNamespace option
|
// check globals in a namespace don't get mangled with the nspaceNamespace option
|
||||||
nspaceNamespace.nspace.namespaceFunction(color);
|
nspaceNamespace.nspace.namespaceFunction(color);
|
||||||
nspaceNamespace.nspace.namespaceVar = 111;
|
nspaceNamespace.nspace.namespaceVar = 111;
|
||||||
|
|
|
||||||
|
|
@ -28,16 +28,26 @@ public class nspace_runme {
|
||||||
if (channel != nspacePackage.Outer.Inner1.Color.Channel.Transmission)
|
if (channel != nspacePackage.Outer.Inner1.Color.Channel.Transmission)
|
||||||
throw new RuntimeException("Transmission wrong");
|
throw new RuntimeException("Transmission wrong");
|
||||||
|
|
||||||
// static member variables
|
// class anonymous enums
|
||||||
nspacePackage.Outer.Inner1.Color.setStaticMemberVariable(789);
|
int val1 = nspacePackage.Outer.Inner1.Color.ColorEnumVal1;
|
||||||
if (nspacePackage.Outer.Inner1.Color.getStaticMemberVariable() != 789)
|
int val2 = nspacePackage.Outer.Inner1.Color.ColorEnumVal2;
|
||||||
throw new RuntimeException("static member variable failed");
|
if (val1 != 0 || val2 != 0x22)
|
||||||
|
throw new RuntimeException("ColorEnumVal wrong");
|
||||||
|
|
||||||
// instance member variables
|
// instance member variables
|
||||||
color.setInstanceMemberVariable(123);
|
color.setInstanceMemberVariable(123);
|
||||||
if (color.getInstanceMemberVariable() != 123)
|
if (color.getInstanceMemberVariable() != 123)
|
||||||
throw new RuntimeException("instance member variable failed");
|
throw new RuntimeException("instance member variable failed");
|
||||||
|
|
||||||
|
// static member variables
|
||||||
|
nspacePackage.Outer.Inner1.Color.setStaticMemberVariable(789);
|
||||||
|
if (nspacePackage.Outer.Inner1.Color.getStaticMemberVariable() != 789)
|
||||||
|
throw new RuntimeException("static member variable failed");
|
||||||
|
if (nspacePackage.Outer.Inner1.Color.staticConstMemberVariable != 222)
|
||||||
|
throw new RuntimeException("static const member variable failed");
|
||||||
|
if (nspacePackage.Outer.Inner1.Color.staticConstEnumMemberVariable != nspacePackage.Outer.Inner1.Color.Channel.Transmission)
|
||||||
|
throw new RuntimeException("static const enum member variable failed");
|
||||||
|
|
||||||
// Same class different namespaces
|
// Same class different namespaces
|
||||||
nspacePackage.Outer.Inner1.Color col1 = new nspacePackage.Outer.Inner1.Color();
|
nspacePackage.Outer.Inner1.Color col1 = new nspacePackage.Outer.Inner1.Color();
|
||||||
nspacePackage.Outer.Inner2.Color col2 = nspacePackage.Outer.Inner2.Color.create();
|
nspacePackage.Outer.Inner2.Color col2 = nspacePackage.Outer.Inner2.Color.create();
|
||||||
|
|
|
||||||
|
|
@ -10,29 +10,27 @@
|
||||||
%copyctor;
|
%copyctor;
|
||||||
%ignore Outer::Inner2::Color::Color();
|
%ignore Outer::Inner2::Color::Color();
|
||||||
|
|
||||||
|
#define CONSTANT100 100
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
|
|
||||||
namespace Outer {
|
namespace Outer {
|
||||||
class nspace {
|
class nspace {
|
||||||
};
|
};
|
||||||
namespace Inner1 {
|
namespace Inner1 {
|
||||||
enum Channel {
|
enum Channel { Diffuse, Specular = 0x10, Transmission1 };
|
||||||
Diffuse,
|
enum { ColorEnumVal1, ColorEnumVal2 = 0x11, ColorEnumVal3 };
|
||||||
Specular = 0x10,
|
|
||||||
Transmission1
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Color {
|
struct Color {
|
||||||
static Color* create() { return new Color(); }
|
static Color* create() { return new Color(); }
|
||||||
|
|
||||||
enum Channel {
|
enum Channel { Diffuse, Specular = 0x20, Transmission };
|
||||||
Diffuse,
|
enum { ColorEnumVal1, ColorEnumVal2 = 0x22, ColorEnumVal3 };
|
||||||
Specular = 0x20,
|
|
||||||
Transmission
|
|
||||||
};
|
|
||||||
|
|
||||||
int instanceMemberVariable;
|
int instanceMemberVariable;
|
||||||
static int staticMemberVariable;
|
static int staticMemberVariable;
|
||||||
|
static const int staticConstMemberVariable = 222;
|
||||||
|
static const Channel staticConstEnumMemberVariable = Transmission;
|
||||||
void colorInstanceMethod(double d) {}
|
void colorInstanceMethod(double d) {}
|
||||||
static void colorStaticMethod(double d) {}
|
static void colorStaticMethod(double d) {}
|
||||||
}; // Color
|
}; // Color
|
||||||
|
|
@ -43,24 +41,19 @@ namespace Outer {
|
||||||
} // Inner1
|
} // Inner1
|
||||||
|
|
||||||
namespace Inner2 {
|
namespace Inner2 {
|
||||||
enum Channel {
|
enum Channel { Diffuse, Specular = 0x30, Transmission2 };
|
||||||
Diffuse,
|
|
||||||
Specular /* = 0x30*/,
|
|
||||||
Transmission2
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Color {
|
struct Color {
|
||||||
Color() : instanceMemberVariable(0) {}
|
Color() : instanceMemberVariable(0) {}
|
||||||
static Color* create() { return new Color(); }
|
static Color* create() { return new Color(); }
|
||||||
|
|
||||||
enum Channel {
|
enum Channel { Diffuse, Specular = 0x40, Transmission };
|
||||||
Diffuse,
|
enum { ColorEnumVal1, ColorEnumVal2 = 0x33, ColorEnumVal3 };
|
||||||
Specular/* = 0x40*/,
|
|
||||||
Transmission
|
|
||||||
};
|
|
||||||
|
|
||||||
int instanceMemberVariable;
|
int instanceMemberVariable;
|
||||||
static int staticMemberVariable;
|
static int staticMemberVariable;
|
||||||
|
static const int staticConstMemberVariable = 333;
|
||||||
|
static const Channel staticConstEnumMemberVariable = Transmission;
|
||||||
void colorInstanceMethod(double d) {}
|
void colorInstanceMethod(double d) {}
|
||||||
static void colorStaticMethod(double d) {}
|
static void colorStaticMethod(double d) {}
|
||||||
void colors(const Inner1::Color& col1a,
|
void colors(const Inner1::Color& col1a,
|
||||||
|
|
@ -85,8 +78,8 @@ namespace Outer {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
class SomeClass {
|
class SomeClass {
|
||||||
public:
|
public:
|
||||||
Inner1::Color::Channel GetInner1ColorChannel() { return Inner1::Color::Transmission; }
|
Inner1::Color::Channel GetInner1ColorChannel() { return Inner1::Color::Transmission; }
|
||||||
Inner2::Color::Channel GetInner2ColorChannel() { return Inner2::Color::Transmission; }
|
Inner2::Color::Channel GetInner2ColorChannel() { return Inner2::Color::Transmission; }
|
||||||
Inner1::Channel GetInner1Channel() { return Inner1::Transmission1; }
|
Inner1::Channel GetInner1Channel() { return Inner1::Transmission1; }
|
||||||
|
|
|
||||||
|
|
@ -1128,9 +1128,9 @@ public:
|
||||||
if (getCurrentClass() && (cplus_mode != PUBLIC))
|
if (getCurrentClass() && (cplus_mode != PUBLIC))
|
||||||
return SWIG_NOWRAP;
|
return SWIG_NOWRAP;
|
||||||
|
|
||||||
|
String *nspace = Getattr(n, "sym:nspace"); // NSpace/getNSpace() only works during Language::enumDeclaration call
|
||||||
if (proxy_flag && !is_wrapping_class()) {
|
if (proxy_flag && !is_wrapping_class()) {
|
||||||
// Global enums / enums in a namespace
|
// Global enums / enums in a namespace
|
||||||
String *nspace = Getattr(n, "sym:nspace");
|
|
||||||
assert(!full_imclass_name);
|
assert(!full_imclass_name);
|
||||||
|
|
||||||
if (!nspace) {
|
if (!nspace) {
|
||||||
|
|
@ -1153,6 +1153,17 @@ public:
|
||||||
if ((enum_feature != SimpleEnum) && symname && typemap_lookup_type) {
|
if ((enum_feature != SimpleEnum) && symname && typemap_lookup_type) {
|
||||||
// Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper C# enum
|
// Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper C# enum
|
||||||
|
|
||||||
|
String *scope = 0;
|
||||||
|
if (nspace || proxy_class_name) {
|
||||||
|
scope = NewString("");
|
||||||
|
if (nspace)
|
||||||
|
Printf(scope, "%s", nspace);
|
||||||
|
if (proxy_class_name)
|
||||||
|
Printv(scope, nspace ? "." : "", proxy_class_name, NIL);
|
||||||
|
}
|
||||||
|
if (!addSymbol(symname, n, scope))
|
||||||
|
return SWIG_ERROR;
|
||||||
|
|
||||||
// Pure C# baseclass and interfaces
|
// Pure C# baseclass and interfaces
|
||||||
const String *pure_baseclass = typemapLookup(n, "csbase", typemap_lookup_type, WARN_NONE);
|
const String *pure_baseclass = typemapLookup(n, "csbase", typemap_lookup_type, WARN_NONE);
|
||||||
const String *pure_interfaces = typemapLookup(n, "csinterfaces", typemap_lookup_type, WARN_NONE);
|
const String *pure_interfaces = typemapLookup(n, "csinterfaces", typemap_lookup_type, WARN_NONE);
|
||||||
|
|
@ -1166,6 +1177,7 @@ public:
|
||||||
Printv(enum_code, typemapLookup(n, "csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers (enum modifiers really)
|
Printv(enum_code, typemapLookup(n, "csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers (enum modifiers really)
|
||||||
" ", symname, (*Char(pure_baseclass) || *Char(pure_interfaces)) ? " : " : "", pure_baseclass, ((*Char(pure_baseclass)) && *Char(pure_interfaces)) ? // Interfaces
|
" ", symname, (*Char(pure_baseclass) || *Char(pure_interfaces)) ? " : " : "", pure_baseclass, ((*Char(pure_baseclass)) && *Char(pure_interfaces)) ? // Interfaces
|
||||||
", " : "", pure_interfaces, " {\n", NIL);
|
", " : "", pure_interfaces, " {\n", NIL);
|
||||||
|
Delete(scope);
|
||||||
} else {
|
} else {
|
||||||
// Wrap C++ enum with integers - just indicate start of enum with a comment, no comment for anonymous enums of any sort
|
// Wrap C++ enum with integers - just indicate start of enum with a comment, no comment for anonymous enums of any sort
|
||||||
if (symname && !Getattr(n, "unnamedinstance"))
|
if (symname && !Getattr(n, "unnamedinstance"))
|
||||||
|
|
@ -1201,7 +1213,6 @@ public:
|
||||||
Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL);
|
Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL);
|
||||||
} else {
|
} else {
|
||||||
// Global enums are defined in their own file
|
// Global enums are defined in their own file
|
||||||
String *nspace = Getattr(n, "sym:nspace");
|
|
||||||
String *output_directory = outputDirectory(nspace);
|
String *output_directory = outputDirectory(nspace);
|
||||||
String *filen = NewStringf("%s%s.cs", output_directory, symname);
|
String *filen = NewStringf("%s%s.cs", output_directory, symname);
|
||||||
File *f_enum = NewFile(filen, "w", SWIG_output_files());
|
File *f_enum = NewFile(filen, "w", SWIG_output_files());
|
||||||
|
|
@ -1260,6 +1271,7 @@ public:
|
||||||
Node *parent = parentNode(n);
|
Node *parent = parentNode(n);
|
||||||
int unnamedinstance = GetFlag(parent, "unnamedinstance");
|
int unnamedinstance = GetFlag(parent, "unnamedinstance");
|
||||||
String *parent_name = Getattr(parent, "name");
|
String *parent_name = Getattr(parent, "name");
|
||||||
|
String *nspace = getNSpace();
|
||||||
String *tmpValue;
|
String *tmpValue;
|
||||||
|
|
||||||
// Strange hack from parent method
|
// Strange hack from parent method
|
||||||
|
|
@ -1272,6 +1284,29 @@ public:
|
||||||
|
|
||||||
{
|
{
|
||||||
EnumFeature enum_feature = decodeEnumFeature(parent);
|
EnumFeature enum_feature = decodeEnumFeature(parent);
|
||||||
|
|
||||||
|
// Add to language symbol table
|
||||||
|
String *scope = 0;
|
||||||
|
if (unnamedinstance || !parent_name || enum_feature == SimpleEnum) {
|
||||||
|
if (proxy_class_name) {
|
||||||
|
scope = NewString("");
|
||||||
|
if (nspace)
|
||||||
|
Printf(scope, "%s.", nspace);
|
||||||
|
Printf(scope, "%s", proxy_class_name);
|
||||||
|
} else {
|
||||||
|
scope = Copy(module_class_name);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
scope = NewString("");
|
||||||
|
if (nspace)
|
||||||
|
Printf(scope, "%s.", nspace);
|
||||||
|
if (proxy_class_name)
|
||||||
|
Printf(scope, "%s.", proxy_class_name);
|
||||||
|
Printf(scope, "%s",Getattr(parent, "sym:name"));
|
||||||
|
}
|
||||||
|
if (!addSymbol(name, n, scope))
|
||||||
|
return SWIG_ERROR;
|
||||||
|
|
||||||
const String *csattributes = Getattr(n, "feature:cs:attributes");
|
const String *csattributes = Getattr(n, "feature:cs:attributes");
|
||||||
|
|
||||||
if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) {
|
if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) {
|
||||||
|
|
@ -1336,6 +1371,7 @@ public:
|
||||||
Setattr(parent, "enumvalues", Copy(symname));
|
Setattr(parent, "enumvalues", Copy(symname));
|
||||||
else
|
else
|
||||||
Printv(enumvalues, ", ", symname, NIL);
|
Printv(enumvalues, ", ", symname, NIL);
|
||||||
|
Delete(scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
Delete(tmpValue);
|
Delete(tmpValue);
|
||||||
|
|
@ -1365,9 +1401,21 @@ public:
|
||||||
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
||||||
|
|
||||||
const String *itemname = (proxy_flag && wrapping_member_flag) ? variable_name : symname;
|
const String *itemname = (proxy_flag && wrapping_member_flag) ? variable_name : symname;
|
||||||
String *scope = proxy_flag && wrapping_member_flag ? proxy_class_name : module_class_name;
|
if (!is_enum_item) {
|
||||||
if (!addSymbol(itemname, n, scope))
|
String *scope = 0;
|
||||||
return SWIG_ERROR;
|
if (proxy_class_name) {
|
||||||
|
String *nspace = getNSpace();
|
||||||
|
scope = NewString("");
|
||||||
|
if (nspace)
|
||||||
|
Printf(scope, "%s.", nspace);
|
||||||
|
Printf(scope, "%s", proxy_class_name);
|
||||||
|
} else {
|
||||||
|
scope = Copy(module_class_name);
|
||||||
|
}
|
||||||
|
if (!addSymbol(itemname, n, scope))
|
||||||
|
return SWIG_ERROR;
|
||||||
|
Delete(scope);
|
||||||
|
}
|
||||||
|
|
||||||
// The %csconst feature determines how the constant value is obtained
|
// The %csconst feature determines how the constant value is obtained
|
||||||
int const_feature_flag = GetFlag(n, "feature:cs:const");
|
int const_feature_flag = GetFlag(n, "feature:cs:const");
|
||||||
|
|
@ -1426,13 +1474,14 @@ public:
|
||||||
if (classname_substituted_flag) {
|
if (classname_substituted_flag) {
|
||||||
if (SwigType_isenum(t)) {
|
if (SwigType_isenum(t)) {
|
||||||
// This handles wrapping of inline initialised const enum static member variables (not when wrapping enum items - ignored later on)
|
// This handles wrapping of inline initialised const enum static member variables (not when wrapping enum items - ignored later on)
|
||||||
Printf(constants_code, "(%s)%s.%s();\n", return_type, imclass_name, Swig_name_get(getNSpace(), symname));
|
Printf(constants_code, "(%s)%s.%s();\n", return_type, full_imclass_name, Swig_name_get(getNSpace(), symname));
|
||||||
} else {
|
} else {
|
||||||
// This handles function pointers using the %constant directive
|
// This handles function pointers using the %constant directive
|
||||||
Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, imclass_name, Swig_name_get(getNSpace(), symname));
|
Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, full_imclass_name, Swig_name_get(getNSpace(), symname));
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
Printf(constants_code, "%s.%s();\n", imclass_name, Swig_name_get(getNSpace(), symname));
|
Printf(constants_code, "%s.%s();\n", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
|
||||||
|
}
|
||||||
|
|
||||||
// Each constant and enum value is wrapped with a separate PInvoke function call
|
// Each constant and enum value is wrapped with a separate PInvoke function call
|
||||||
SetFlag(n, "feature:immutable");
|
SetFlag(n, "feature:immutable");
|
||||||
|
|
@ -2924,7 +2973,7 @@ public:
|
||||||
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
|
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
|
||||||
} else {
|
} else {
|
||||||
memberconstantHandler(n);
|
memberconstantHandler(n);
|
||||||
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(getNSpace(), proxy_class_name, symname)));
|
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(0, proxy_class_name, symname)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1189,9 +1189,9 @@ public:
|
||||||
if (getCurrentClass() && (cplus_mode != PUBLIC))
|
if (getCurrentClass() && (cplus_mode != PUBLIC))
|
||||||
return SWIG_NOWRAP;
|
return SWIG_NOWRAP;
|
||||||
|
|
||||||
|
String *nspace = Getattr(n, "sym:nspace"); // NSpace/getNSpace() only works during Language::enumDeclaration call
|
||||||
if (proxy_flag && !is_wrapping_class()) {
|
if (proxy_flag && !is_wrapping_class()) {
|
||||||
// Global enums / enums in a namespace
|
// Global enums / enums in a namespace
|
||||||
String *nspace = Getattr(n, "sym:nspace");
|
|
||||||
assert(!full_imclass_name);
|
assert(!full_imclass_name);
|
||||||
|
|
||||||
if (!nspace) {
|
if (!nspace) {
|
||||||
|
|
@ -1216,6 +1216,17 @@ public:
|
||||||
if ((enum_feature != SimpleEnum) && symname && typemap_lookup_type) {
|
if ((enum_feature != SimpleEnum) && symname && typemap_lookup_type) {
|
||||||
// Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper Java enum
|
// Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper Java enum
|
||||||
|
|
||||||
|
String *scope = 0;
|
||||||
|
if (nspace || proxy_class_name) {
|
||||||
|
scope = NewString("");
|
||||||
|
if (nspace)
|
||||||
|
Printf(scope, "%s", nspace);
|
||||||
|
if (proxy_class_name)
|
||||||
|
Printv(scope, nspace ? "." : "", proxy_class_name, NIL);
|
||||||
|
}
|
||||||
|
if (!addSymbol(symname, n, scope))
|
||||||
|
return SWIG_ERROR;
|
||||||
|
|
||||||
// Pure Java baseclass and interfaces
|
// Pure Java baseclass and interfaces
|
||||||
const String *pure_baseclass = typemapLookup(n, "javabase", typemap_lookup_type, WARN_NONE);
|
const String *pure_baseclass = typemapLookup(n, "javabase", typemap_lookup_type, WARN_NONE);
|
||||||
const String *pure_interfaces = typemapLookup(n, "javainterfaces", typemap_lookup_type, WARN_NONE);
|
const String *pure_interfaces = typemapLookup(n, "javainterfaces", typemap_lookup_type, WARN_NONE);
|
||||||
|
|
@ -1229,6 +1240,7 @@ public:
|
||||||
Replaceall(enum_code, "$static ", "static ");
|
Replaceall(enum_code, "$static ", "static ");
|
||||||
else
|
else
|
||||||
Replaceall(enum_code, "$static ", "");
|
Replaceall(enum_code, "$static ", "");
|
||||||
|
Delete(scope);
|
||||||
} else {
|
} else {
|
||||||
// Wrap C++ enum with integers - just indicate start of enum with a comment, no comment for anonymous enums of any sort
|
// Wrap C++ enum with integers - just indicate start of enum with a comment, no comment for anonymous enums of any sort
|
||||||
if (symname && !Getattr(n, "unnamedinstance"))
|
if (symname && !Getattr(n, "unnamedinstance"))
|
||||||
|
|
@ -1264,7 +1276,6 @@ public:
|
||||||
Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL);
|
Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL);
|
||||||
} else {
|
} else {
|
||||||
// Global enums are defined in their own file
|
// Global enums are defined in their own file
|
||||||
String *nspace = Getattr(n, "sym:nspace");
|
|
||||||
String *output_directory = outputDirectory(nspace);
|
String *output_directory = outputDirectory(nspace);
|
||||||
String *filen = NewStringf("%s%s.java", output_directory, symname);
|
String *filen = NewStringf("%s%s.java", output_directory, symname);
|
||||||
File *f_enum = NewFile(filen, "w", SWIG_output_files());
|
File *f_enum = NewFile(filen, "w", SWIG_output_files());
|
||||||
|
|
@ -1330,6 +1341,7 @@ public:
|
||||||
Node *parent = parentNode(n);
|
Node *parent = parentNode(n);
|
||||||
int unnamedinstance = GetFlag(parent, "unnamedinstance");
|
int unnamedinstance = GetFlag(parent, "unnamedinstance");
|
||||||
String *parent_name = Getattr(parent, "name");
|
String *parent_name = Getattr(parent, "name");
|
||||||
|
String *nspace = getNSpace();
|
||||||
String *tmpValue;
|
String *tmpValue;
|
||||||
|
|
||||||
// Strange hack from parent method
|
// Strange hack from parent method
|
||||||
|
|
@ -1343,6 +1355,28 @@ public:
|
||||||
{
|
{
|
||||||
EnumFeature enum_feature = decodeEnumFeature(parent);
|
EnumFeature enum_feature = decodeEnumFeature(parent);
|
||||||
|
|
||||||
|
// Add to language symbol table
|
||||||
|
String *scope = 0;
|
||||||
|
if (unnamedinstance || !parent_name || enum_feature == SimpleEnum) {
|
||||||
|
if (proxy_class_name) {
|
||||||
|
scope = NewString("");
|
||||||
|
if (nspace)
|
||||||
|
Printf(scope, "%s.", nspace);
|
||||||
|
Printf(scope, "%s", proxy_class_name);
|
||||||
|
} else {
|
||||||
|
scope = Copy(constants_interface_name);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
scope = NewString("");
|
||||||
|
if (nspace)
|
||||||
|
Printf(scope, "%s.", nspace);
|
||||||
|
if (proxy_class_name)
|
||||||
|
Printf(scope, "%s.", proxy_class_name);
|
||||||
|
Printf(scope, "%s",Getattr(parent, "sym:name"));
|
||||||
|
}
|
||||||
|
if (!addSymbol(name, n, scope))
|
||||||
|
return SWIG_ERROR;
|
||||||
|
|
||||||
if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) {
|
if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) {
|
||||||
// Wrap (non-anonymous) C/C++ enum with a proper Java enum
|
// Wrap (non-anonymous) C/C++ enum with a proper Java enum
|
||||||
// Emit the enum item.
|
// Emit the enum item.
|
||||||
|
|
@ -1389,6 +1423,7 @@ public:
|
||||||
Setattr(parent, "enumvalues", Copy(symname));
|
Setattr(parent, "enumvalues", Copy(symname));
|
||||||
else
|
else
|
||||||
Printv(enumvalues, ", ", symname, NIL);
|
Printv(enumvalues, ", ", symname, NIL);
|
||||||
|
Delete(scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
Delete(tmpValue);
|
Delete(tmpValue);
|
||||||
|
|
@ -1418,9 +1453,21 @@ public:
|
||||||
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
||||||
|
|
||||||
const String *itemname = (proxy_flag && wrapping_member_flag) ? variable_name : symname;
|
const String *itemname = (proxy_flag && wrapping_member_flag) ? variable_name : symname;
|
||||||
String *scope = proxy_flag && wrapping_member_flag ? proxy_class_name : constants_interface_name;
|
if (!is_enum_item) {
|
||||||
if (!addSymbol(itemname, n, scope))
|
String *scope = 0;
|
||||||
return SWIG_ERROR;
|
if (proxy_class_name) {
|
||||||
|
String *nspace = getNSpace();
|
||||||
|
scope = NewString("");
|
||||||
|
if (nspace)
|
||||||
|
Printf(scope, "%s.", nspace);
|
||||||
|
Printf(scope, "%s", proxy_class_name);
|
||||||
|
} else {
|
||||||
|
scope = Copy(constants_interface_name);
|
||||||
|
}
|
||||||
|
if (!addSymbol(itemname, n, scope))
|
||||||
|
return SWIG_ERROR;
|
||||||
|
Delete(scope);
|
||||||
|
}
|
||||||
|
|
||||||
// The %javaconst feature determines how the constant value is obtained
|
// The %javaconst feature determines how the constant value is obtained
|
||||||
int const_feature_flag = GetFlag(n, "feature:java:const");
|
int const_feature_flag = GetFlag(n, "feature:java:const");
|
||||||
|
|
@ -1472,13 +1519,14 @@ public:
|
||||||
if (classname_substituted_flag) {
|
if (classname_substituted_flag) {
|
||||||
if (SwigType_isenum(t)) {
|
if (SwigType_isenum(t)) {
|
||||||
// This handles wrapping of inline initialised const enum static member variables (not when wrapping enum items - ignored later on)
|
// This handles wrapping of inline initialised const enum static member variables (not when wrapping enum items - ignored later on)
|
||||||
Printf(constants_code, "%s.swigToEnum(%s.%s());\n", return_type, imclass_name, Swig_name_get(getNSpace(), symname));
|
Printf(constants_code, "%s.swigToEnum(%s.%s());\n", return_type, full_imclass_name, Swig_name_get(getNSpace(), symname));
|
||||||
} else {
|
} else {
|
||||||
// This handles function pointers using the %constant directive
|
// This handles function pointers using the %constant directive
|
||||||
Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, imclass_name, Swig_name_get(getNSpace(), symname));
|
Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, full_imclass_name, Swig_name_get(getNSpace(), symname));
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
Printf(constants_code, "%s.%s();\n", imclass_name, Swig_name_get(getNSpace(), symname));
|
Printf(constants_code, "%s.%s();\n", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
|
||||||
|
}
|
||||||
|
|
||||||
// Each constant and enum value is wrapped with a separate JNI function call
|
// Each constant and enum value is wrapped with a separate JNI function call
|
||||||
SetFlag(n, "feature:immutable");
|
SetFlag(n, "feature:immutable");
|
||||||
|
|
@ -2772,7 +2820,7 @@ public:
|
||||||
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
|
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
|
||||||
} else {
|
} else {
|
||||||
memberconstantHandler(n);
|
memberconstantHandler(n);
|
||||||
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(getNSpace(), proxy_class_name, symname)));
|
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(0, proxy_class_name, symname)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1612,9 +1612,15 @@ int Language::externDeclaration(Node *n) {
|
||||||
* ---------------------------------------------------------------------- */
|
* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
int Language::enumDeclaration(Node *n) {
|
int Language::enumDeclaration(Node *n) {
|
||||||
|
String *oldNSpace = NSpace;
|
||||||
|
NSpace = Getattr(n, "sym:nspace");
|
||||||
|
|
||||||
if (!ImportMode) {
|
if (!ImportMode) {
|
||||||
emit_children(n);
|
emit_children(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSpace = oldNSpace;
|
||||||
|
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1677,7 +1683,7 @@ int Language::memberconstantHandler(Node *n) {
|
||||||
String *symname = Getattr(n, "sym:name");
|
String *symname = Getattr(n, "sym:name");
|
||||||
String *value = Getattr(n, "value");
|
String *value = Getattr(n, "value");
|
||||||
|
|
||||||
String *mrename = Swig_name_member(NSpace, ClassPrefix, symname);
|
String *mrename = Swig_name_member(0, ClassPrefix, symname);
|
||||||
Setattr(n, "sym:name", mrename);
|
Setattr(n, "sym:name", mrename);
|
||||||
|
|
||||||
String *new_name = 0;
|
String *new_name = 0;
|
||||||
|
|
@ -2316,7 +2322,6 @@ int Language::classDeclaration(Node *n) {
|
||||||
String *name = Getattr(n, "name");
|
String *name = Getattr(n, "name");
|
||||||
String *tdname = Getattr(n, "tdname");
|
String *tdname = Getattr(n, "tdname");
|
||||||
String *symname = Getattr(n, "sym:name");
|
String *symname = Getattr(n, "sym:name");
|
||||||
String *symnspace = Getattr(n, "sym:nspace");
|
|
||||||
|
|
||||||
char *classname = tdname ? Char(tdname) : Char(name);
|
char *classname = tdname ? Char(tdname) : Char(name);
|
||||||
char *iname = Char(symname);
|
char *iname = Char(symname);
|
||||||
|
|
@ -2345,7 +2350,6 @@ int Language::classDeclaration(Node *n) {
|
||||||
|
|
||||||
ClassName = NewString(classname);
|
ClassName = NewString(classname);
|
||||||
ClassPrefix = NewString(iname);
|
ClassPrefix = NewString(iname);
|
||||||
NSpace = symnspace;
|
|
||||||
if (strip) {
|
if (strip) {
|
||||||
ClassType = NewString(classname);
|
ClassType = NewString(classname);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -2357,6 +2361,8 @@ int Language::classDeclaration(Node *n) {
|
||||||
InClass = 1;
|
InClass = 1;
|
||||||
CurrentClass = n;
|
CurrentClass = n;
|
||||||
|
|
||||||
|
String *oldNSpace = NSpace;
|
||||||
|
NSpace = Getattr(n, "sym:nspace");
|
||||||
|
|
||||||
/* Call classHandler() here */
|
/* Call classHandler() here */
|
||||||
if (!ImportMode) {
|
if (!ImportMode) {
|
||||||
|
|
@ -2406,7 +2412,7 @@ int Language::classDeclaration(Node *n) {
|
||||||
Language::classHandler(n);
|
Language::classHandler(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
NSpace = 0;
|
NSpace = oldNSpace;
|
||||||
InClass = 0;
|
InClass = 0;
|
||||||
CurrentClass = 0;
|
CurrentClass = 0;
|
||||||
Delete(ClassType);
|
Delete(ClassType);
|
||||||
|
|
@ -2944,7 +2950,10 @@ int Language::addSymbol(const String *s, const Node *n, const_String_or_char_ptr
|
||||||
} else {
|
} else {
|
||||||
Node *c = Getattr(symbols, s);
|
Node *c = Getattr(symbols, s);
|
||||||
if (c && (c != n)) {
|
if (c && (c != n)) {
|
||||||
Swig_error(input_file, line_number, "'%s' is multiply defined in the generated target language module.\n", s);
|
if (scope)
|
||||||
|
Swig_error(input_file, line_number, "'%s' is multiply defined in the generated target language module in scope %s.\n", s, scope);
|
||||||
|
else
|
||||||
|
Swig_error(input_file, line_number, "'%s' is multiply defined in the generated target language module.\n", s);
|
||||||
Swig_error(Getfile(c), Getline(c), "Previous declaration of '%s'\n", s);
|
Swig_error(Getfile(c), Getline(c), "Previous declaration of '%s'\n", s);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue