fix for member enums in director methods (for typesafe enums and proper enums)
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6826 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
f9f4c3ff9c
commit
f7e8a925dd
1 changed files with 16 additions and 11 deletions
|
|
@ -2375,9 +2375,11 @@ class JAVA : public Language {
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* getEnumName()
|
* getEnumName()
|
||||||
|
*
|
||||||
|
* If jnidescriptor is set, inner class names are separated with '$' otherwise a '.'
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
String *getEnumName(SwigType *t) {
|
String *getEnumName(SwigType *t, bool jnidescriptor) {
|
||||||
Node *enum_name = NULL;
|
Node *enum_name = NULL;
|
||||||
Node *n = enumLookup(t);
|
Node *n = enumLookup(t);
|
||||||
if (n) {
|
if (n) {
|
||||||
|
|
@ -2389,10 +2391,12 @@ class JAVA : public Language {
|
||||||
if (scopename_prefix) {
|
if (scopename_prefix) {
|
||||||
proxyname = getProxyName(scopename_prefix);
|
proxyname = getProxyName(scopename_prefix);
|
||||||
}
|
}
|
||||||
if (proxyname)
|
if (proxyname) {
|
||||||
enum_name = NewStringf("%s.%s", proxyname, symname);
|
const char *class_separator = jnidescriptor ? "$" : ".";
|
||||||
else
|
enum_name = NewStringf("%s%s%s", proxyname, class_separator, symname);
|
||||||
|
} else {
|
||||||
enum_name = NewStringf("%s", symname);
|
enum_name = NewStringf("%s", symname);
|
||||||
|
}
|
||||||
Delete(scopename_prefix);
|
Delete(scopename_prefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2410,34 +2414,35 @@ class JAVA : public Language {
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* pt - parameter type
|
* pt - parameter type
|
||||||
* tm - jstype typemap
|
* tm - jstype typemap
|
||||||
|
* jnidescriptor - if set, inner class names are separated with '$' otherwise a '.'
|
||||||
* Outputs:
|
* Outputs:
|
||||||
* tm - jstype typemap with $javaclassname substitution
|
* tm - jstype typemap with $javaclassname substitution
|
||||||
* Return:
|
* Return:
|
||||||
* substitution_performed - flag indicating if a substitution was performed
|
* substitution_performed - flag indicating if a substitution was performed
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
bool substituteClassname(SwigType *pt, String *tm) {
|
bool substituteClassname(SwigType *pt, String *tm, bool jnidescriptor = false) {
|
||||||
bool substitution_performed = false;
|
bool substitution_performed = false;
|
||||||
SwigType *type = Copy(SwigType_typedef_resolve_all(pt));
|
SwigType *type = Copy(SwigType_typedef_resolve_all(pt));
|
||||||
SwigType *strippedtype = SwigType_strip_qualifiers(type);
|
SwigType *strippedtype = SwigType_strip_qualifiers(type);
|
||||||
|
|
||||||
if (Strstr(tm, "$javaclassname")) {
|
if (Strstr(tm, "$javaclassname")) {
|
||||||
SwigType *classnametype = Copy(strippedtype);
|
SwigType *classnametype = Copy(strippedtype);
|
||||||
substituteClassnameSpecialVariable(classnametype, tm, "$javaclassname");
|
substituteClassnameSpecialVariable(classnametype, tm, "$javaclassname", jnidescriptor);
|
||||||
substitution_performed = true;
|
substitution_performed = true;
|
||||||
Delete(classnametype);
|
Delete(classnametype);
|
||||||
}
|
}
|
||||||
if (Strstr(tm, "$*javaclassname")) {
|
if (Strstr(tm, "$*javaclassname")) {
|
||||||
SwigType *classnametype = Copy(strippedtype);
|
SwigType *classnametype = Copy(strippedtype);
|
||||||
Delete(SwigType_pop(classnametype));
|
Delete(SwigType_pop(classnametype));
|
||||||
substituteClassnameSpecialVariable(classnametype, tm, "$*javaclassname");
|
substituteClassnameSpecialVariable(classnametype, tm, "$*javaclassname", jnidescriptor);
|
||||||
substitution_performed = true;
|
substitution_performed = true;
|
||||||
Delete(classnametype);
|
Delete(classnametype);
|
||||||
}
|
}
|
||||||
if (Strstr(tm, "$&javaclassname")) {
|
if (Strstr(tm, "$&javaclassname")) {
|
||||||
SwigType *classnametype = Copy(strippedtype);
|
SwigType *classnametype = Copy(strippedtype);
|
||||||
SwigType_add_pointer(classnametype);
|
SwigType_add_pointer(classnametype);
|
||||||
substituteClassnameSpecialVariable(classnametype, tm, "$&javaclassname");
|
substituteClassnameSpecialVariable(classnametype, tm, "$&javaclassname", jnidescriptor);
|
||||||
substitution_performed = true;
|
substitution_performed = true;
|
||||||
Delete(classnametype);
|
Delete(classnametype);
|
||||||
}
|
}
|
||||||
|
|
@ -2452,9 +2457,9 @@ class JAVA : public Language {
|
||||||
* substituteClassnameSpecialVariable()
|
* substituteClassnameSpecialVariable()
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void substituteClassnameSpecialVariable(SwigType *classnametype, String *tm, const char *classnamespecialvariable) {
|
void substituteClassnameSpecialVariable(SwigType *classnametype, String *tm, const char *classnamespecialvariable, bool jnidescriptor) {
|
||||||
if (SwigType_isenum(classnametype)) {
|
if (SwigType_isenum(classnametype)) {
|
||||||
String *enumname = getEnumName(classnametype);
|
String *enumname = getEnumName(classnametype, jnidescriptor);
|
||||||
if (enumname)
|
if (enumname)
|
||||||
Replaceall(tm, classnamespecialvariable, enumname);
|
Replaceall(tm, classnamespecialvariable, enumname);
|
||||||
else
|
else
|
||||||
|
|
@ -2769,7 +2774,7 @@ class JAVA : public Language {
|
||||||
Replaceall(descriptor_out, "$packagepath", empty_string);
|
Replaceall(descriptor_out, "$packagepath", empty_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
substituteClassname(type, descriptor_out);
|
substituteClassname(type, descriptor_out, true);
|
||||||
|
|
||||||
if (pkg_path != package_path)
|
if (pkg_path != package_path)
|
||||||
Delete(pkg_path);
|
Delete(pkg_path);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue