constants and enums are wrapped as C# constants rather than variables now
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4663 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
399e9f5504
commit
89e0c9b214
2 changed files with 12 additions and 10 deletions
|
|
@ -846,14 +846,15 @@ class CSHARP : public Language {
|
||||||
Setattr(n, "value", new_value);
|
Setattr(n, "value", new_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// enums are wrapped using a public final static int in java.
|
|
||||||
// Other constants are wrapped using a public final static [jstype] in Java.
|
|
||||||
Printf(constants_code, " public static %s %s = ", shadowrettype, ((proxy_flag && wrapping_member_flag) ? variable_name : symname));
|
|
||||||
|
|
||||||
// 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");
|
||||||
|
bool javaconst_flag = javaconst && Cmp(javaconst, "0") != 0;
|
||||||
|
|
||||||
if ((is_enum_item && Getattr(n,"enumvalue") == 0) || !javaconst || Cmp(javaconst, "0") == 0) {
|
// enums are wrapped using a public final static int in java.
|
||||||
|
// Other constants are wrapped using a public final static [jstype] in Java.
|
||||||
|
Printf(constants_code, " public %s %s %s = ", (javaconst_flag ? "const" : "static readonly"), shadowrettype, ((proxy_flag && wrapping_member_flag) ? variable_name : symname));
|
||||||
|
|
||||||
|
if ((is_enum_item && Getattr(n,"enumvalue") == 0) || !javaconst_flag) {
|
||||||
// Enums without value and default constant handling will work with any type of C constant and initialises the Java variable from C through a JNI call.
|
// Enums without value and default constant handling will work with any type of C constant and initialises the Java variable from C through a JNI call.
|
||||||
|
|
||||||
if(is_return_type_java_class) // This handles function pointers using the %constant directive
|
if(is_return_type_java_class) // This handles function pointers using the %constant directive
|
||||||
|
|
|
||||||
|
|
@ -248,7 +248,7 @@ class JAVA : public Language {
|
||||||
jniclass_class_modifiers = NewString(""); // package access only to the JNI class by default
|
jniclass_class_modifiers = NewString(""); // package access only to the JNI class by default
|
||||||
module_class_code = NewString("");
|
module_class_code = NewString("");
|
||||||
module_baseclass = NewString("");
|
module_baseclass = NewString("");
|
||||||
module_interfaces = NewStringf("");
|
module_interfaces = NewString("");
|
||||||
module_imports = NewString("");
|
module_imports = NewString("");
|
||||||
module_class_modifiers = NewString("public");
|
module_class_modifiers = NewString("public");
|
||||||
jniclass_imports = NewString("");
|
jniclass_imports = NewString("");
|
||||||
|
|
@ -877,14 +877,15 @@ class JAVA : public Language {
|
||||||
Setattr(n, "value", new_value);
|
Setattr(n, "value", new_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The %javaconst directive determines how the constant value is obtained
|
||||||
|
String *javaconst = Getattr(n,"feature:java:const");
|
||||||
|
bool javaconst_flag = javaconst && Cmp(javaconst, "0") != 0;
|
||||||
|
|
||||||
// enums are wrapped using a public final static int in java.
|
// enums are wrapped using a public final static int in java.
|
||||||
// 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));
|
||||||
|
|
||||||
// The %javaconst directive determines how the constant value is obtained
|
if ((is_enum_item && Getattr(n,"enumvalue") == 0) || !javaconst_flag) {
|
||||||
String *javaconst = Getattr(n,"feature:java:const");
|
|
||||||
|
|
||||||
if ((is_enum_item && Getattr(n,"enumvalue") == 0) || !javaconst || Cmp(javaconst, "0") == 0) {
|
|
||||||
// Enums without value and default constant handling will work with any type of C constant and initialises the Java variable from C through a JNI call.
|
// Enums without value and default constant handling will work with any type of C constant and initialises the Java variable from C through a JNI call.
|
||||||
|
|
||||||
if(is_return_type_java_class) // This handles function pointers using the %constant directive
|
if(is_return_type_java_class) // This handles function pointers using the %constant directive
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue