Fix so that enum typemaps are used when wrapping an enum declaration.
[Enum typemaps still not 100% as 'enum' must always be declared with the type for the typemap.] git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4380 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
0a794f4b08
commit
6643be30bc
1 changed files with 15 additions and 2 deletions
|
|
@ -805,14 +805,25 @@ class JAVA : public Language {
|
||||||
String *tm;
|
String *tm;
|
||||||
String *shadowrettype = NewString("");
|
String *shadowrettype = NewString("");
|
||||||
String *constants_code = NewString("");
|
String *constants_code = NewString("");
|
||||||
|
SwigType *original_type = t;
|
||||||
|
|
||||||
if (!addSymbol(symname,n)) return SWIG_ERROR;
|
if (!addSymbol(symname,n)) return SWIG_ERROR;
|
||||||
|
|
||||||
|
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
||||||
|
|
||||||
|
/* Adjust the enum type for the Swig_typemap_lookup. We want the same jstype typemap for all the enum items.
|
||||||
|
* The type of each enum item depends on what value it is assigned, but is usually a C int. */
|
||||||
|
if (is_enum_item) {
|
||||||
|
t = NewStringf("enum %s", Getattr(parentNode(n), "sym:name"));
|
||||||
|
Setattr(n,"type", t);
|
||||||
|
}
|
||||||
|
|
||||||
/* Attach the non-standard typemaps to the parameter list. */
|
/* Attach the non-standard typemaps to the parameter list. */
|
||||||
Swig_typemap_attach_parms("jstype", l, NULL);
|
Swig_typemap_attach_parms("jstype", l, NULL);
|
||||||
|
|
||||||
/* Get Java return types */
|
/* Get Java return types */
|
||||||
bool is_return_type_java_class = false;
|
bool is_return_type_java_class = false;
|
||||||
|
|
||||||
if ((tm = Swig_typemap_lookup_new("jstype",n,"",0))) {
|
if ((tm = Swig_typemap_lookup_new("jstype",n,"",0))) {
|
||||||
is_return_type_java_class = substituteJavaclassname(t, tm);
|
is_return_type_java_class = substituteJavaclassname(t, tm);
|
||||||
Printf(shadowrettype, "%s", tm);
|
Printf(shadowrettype, "%s", tm);
|
||||||
|
|
@ -837,8 +848,6 @@ class JAVA : public Language {
|
||||||
// Other constants are wrapped using a public final static [jstype] in Java.
|
// Other constants are wrapped using a public final static [jstype] in Java.
|
||||||
Printf(constants_code, " public final static %s %s = ", shadowrettype, ((proxy_flag && wrapping_member_flag) ? variable_name : symname));
|
Printf(constants_code, " public final static %s %s = ", shadowrettype, ((proxy_flag && wrapping_member_flag) ? variable_name : symname));
|
||||||
|
|
||||||
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
|
||||||
|
|
||||||
// The %javaconst directive determines how the constant value is obtained
|
// The %javaconst directive determines how the constant value is obtained
|
||||||
String *javaconst = Getattr(n,"feature:java:const");
|
String *javaconst = Getattr(n,"feature:java:const");
|
||||||
|
|
||||||
|
|
@ -868,6 +877,10 @@ class JAVA : public Language {
|
||||||
Printv(module_constants_code, constants_code, NIL);
|
Printv(module_constants_code, constants_code, NIL);
|
||||||
|
|
||||||
Swig_restore(&n);
|
Swig_restore(&n);
|
||||||
|
if (is_enum_item) {
|
||||||
|
Delete(Getattr(n,"type"));
|
||||||
|
Setattr(n,"type", original_type);
|
||||||
|
}
|
||||||
Delete(new_value);
|
Delete(new_value);
|
||||||
Delete(shadowrettype);
|
Delete(shadowrettype);
|
||||||
Delete(constants_code);
|
Delete(constants_code);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue