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
|
|
@ -1189,9 +1189,9 @@ public:
|
|||
if (getCurrentClass() && (cplus_mode != PUBLIC))
|
||||
return SWIG_NOWRAP;
|
||||
|
||||
String *nspace = Getattr(n, "sym:nspace"); // NSpace/getNSpace() only works during Language::enumDeclaration call
|
||||
if (proxy_flag && !is_wrapping_class()) {
|
||||
// Global enums / enums in a namespace
|
||||
String *nspace = Getattr(n, "sym:nspace");
|
||||
assert(!full_imclass_name);
|
||||
|
||||
if (!nspace) {
|
||||
|
|
@ -1216,6 +1216,17 @@ public:
|
|||
if ((enum_feature != SimpleEnum) && symname && typemap_lookup_type) {
|
||||
// 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
|
||||
const String *pure_baseclass = typemapLookup(n, "javabase", 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 ");
|
||||
else
|
||||
Replaceall(enum_code, "$static ", "");
|
||||
Delete(scope);
|
||||
} else {
|
||||
// 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"))
|
||||
|
|
@ -1264,7 +1276,6 @@ public:
|
|||
Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL);
|
||||
} else {
|
||||
// Global enums are defined in their own file
|
||||
String *nspace = Getattr(n, "sym:nspace");
|
||||
String *output_directory = outputDirectory(nspace);
|
||||
String *filen = NewStringf("%s%s.java", output_directory, symname);
|
||||
File *f_enum = NewFile(filen, "w", SWIG_output_files());
|
||||
|
|
@ -1330,6 +1341,7 @@ public:
|
|||
Node *parent = parentNode(n);
|
||||
int unnamedinstance = GetFlag(parent, "unnamedinstance");
|
||||
String *parent_name = Getattr(parent, "name");
|
||||
String *nspace = getNSpace();
|
||||
String *tmpValue;
|
||||
|
||||
// Strange hack from parent method
|
||||
|
|
@ -1343,6 +1355,28 @@ public:
|
|||
{
|
||||
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) {
|
||||
// Wrap (non-anonymous) C/C++ enum with a proper Java enum
|
||||
// Emit the enum item.
|
||||
|
|
@ -1389,6 +1423,7 @@ public:
|
|||
Setattr(parent, "enumvalues", Copy(symname));
|
||||
else
|
||||
Printv(enumvalues, ", ", symname, NIL);
|
||||
Delete(scope);
|
||||
}
|
||||
|
||||
Delete(tmpValue);
|
||||
|
|
@ -1418,9 +1453,21 @@ public:
|
|||
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
||||
|
||||
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 (!addSymbol(itemname, n, scope))
|
||||
return SWIG_ERROR;
|
||||
if (!is_enum_item) {
|
||||
String *scope = 0;
|
||||
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
|
||||
int const_feature_flag = GetFlag(n, "feature:java:const");
|
||||
|
|
@ -1472,13 +1519,14 @@ public:
|
|||
if (classname_substituted_flag) {
|
||||
if (SwigType_isenum(t)) {
|
||||
// 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 {
|
||||
// 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
|
||||
Printf(constants_code, "%s.%s();\n", imclass_name, Swig_name_get(getNSpace(), symname));
|
||||
} else {
|
||||
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
|
||||
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));
|
||||
} else {
|
||||
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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue