Partial support for %constant and structs
Test case is slightly modified from the test case in issue #250 Use of constant objects does not seem to work in Python - the type is SwigPyObject instead of constant_directive.Type1.
This commit is contained in:
parent
c915583bf9
commit
2e01533b23
7 changed files with 32 additions and 48 deletions
|
|
@ -143,6 +143,7 @@ CPP_TEST_CASES += \
|
||||||
class_scope_weird \
|
class_scope_weird \
|
||||||
compactdefaultargs \
|
compactdefaultargs \
|
||||||
const_const_2 \
|
const_const_2 \
|
||||||
|
constant_directive \
|
||||||
constant_pointers \
|
constant_pointers \
|
||||||
constover \
|
constover \
|
||||||
constructor_copy \
|
constructor_copy \
|
||||||
|
|
|
||||||
22
Examples/test-suite/java/constant_directive_runme.java
Normal file
22
Examples/test-suite/java/constant_directive_runme.java
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
import constant_directive.*;
|
||||||
|
|
||||||
|
public class constant_directive_runme {
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("constant_directive");
|
||||||
|
} catch (UnsatisfiedLinkError e) {
|
||||||
|
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String argv[]) {
|
||||||
|
if (constant_directive.TYPE1_CONSTANT1.getVal() != 1)
|
||||||
|
throw new RuntimeException("fail");
|
||||||
|
if (constant_directive.TYPE1_CONSTANT2.getVal() != 2)
|
||||||
|
throw new RuntimeException("fail");
|
||||||
|
if (constant_directive.TYPE1_CONSTANT3.getVal() != 3)
|
||||||
|
throw new RuntimeException("fail");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -914,21 +914,10 @@ public:
|
||||||
String *null_attribute = 0;
|
String *null_attribute = 0;
|
||||||
// Now write code to make the function call
|
// Now write code to make the function call
|
||||||
if (!native_function_flag) {
|
if (!native_function_flag) {
|
||||||
if (Cmp(nodeType(n), "constant") == 0) {
|
|
||||||
// Wrapping a constant hack
|
|
||||||
Swig_save("functionWrapper", n, "wrap:action", NIL);
|
|
||||||
|
|
||||||
// below based on Swig_VargetToFunction()
|
|
||||||
SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
|
|
||||||
Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
|
|
||||||
}
|
|
||||||
|
|
||||||
Swig_director_emit_dynamic_cast(n, f);
|
Swig_director_emit_dynamic_cast(n, f);
|
||||||
String *actioncode = emit_action(n);
|
String *actioncode = emit_action(n);
|
||||||
|
|
||||||
if (Cmp(nodeType(n), "constant") == 0)
|
|
||||||
Swig_restore(n);
|
|
||||||
|
|
||||||
/* Return value if necessary */
|
/* Return value if necessary */
|
||||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||||
canThrow(n, "out", n);
|
canThrow(n, "out", n);
|
||||||
|
|
|
||||||
|
|
@ -1701,21 +1701,10 @@ public:
|
||||||
String *null_attribute = 0;
|
String *null_attribute = 0;
|
||||||
// Now write code to make the function call
|
// Now write code to make the function call
|
||||||
if (!native_function_flag) {
|
if (!native_function_flag) {
|
||||||
if (Cmp(nodeType(n), "constant") == 0) {
|
|
||||||
// Wrapping a constant hack
|
|
||||||
Swig_save("functionWrapper", n, "wrap:action", NIL);
|
|
||||||
|
|
||||||
// below based on Swig_VargetToFunction()
|
|
||||||
SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
|
|
||||||
Setattr(n, "wrap:action", NewStringf("%s = (%s) %s;", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
|
|
||||||
}
|
|
||||||
|
|
||||||
Swig_director_emit_dynamic_cast(n, f);
|
Swig_director_emit_dynamic_cast(n, f);
|
||||||
String *actioncode = emit_action(n);
|
String *actioncode = emit_action(n);
|
||||||
|
|
||||||
if (Cmp(nodeType(n), "constant") == 0)
|
|
||||||
Swig_restore(n);
|
|
||||||
|
|
||||||
/* Return value if necessary */
|
/* Return value if necessary */
|
||||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||||
canThrow(n, "out", n);
|
canThrow(n, "out", n);
|
||||||
|
|
|
||||||
|
|
@ -1039,26 +1039,15 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now write code to make the function call
|
||||||
if (!native_function_flag) {
|
if (!native_function_flag) {
|
||||||
if (Cmp(nodeType(n), "constant") == 0) {
|
|
||||||
// Wrapping a constant hack
|
|
||||||
Swig_save("functionWrapper", n, "wrap:action", NIL);
|
|
||||||
|
|
||||||
// below based on Swig_VargetToFunction()
|
|
||||||
SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
|
|
||||||
Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now write code to make the function call
|
|
||||||
Swig_director_emit_dynamic_cast(n, f);
|
Swig_director_emit_dynamic_cast(n, f);
|
||||||
String *actioncode = emit_action(n);
|
String *actioncode = emit_action(n);
|
||||||
|
|
||||||
// Handle exception classes specified in the "except" feature's "throws" attribute
|
// Handle exception classes specified in the "except" feature's "throws" attribute
|
||||||
addThrows(n, "feature:except", n);
|
addThrows(n, "feature:except", n);
|
||||||
|
|
||||||
if (Cmp(nodeType(n), "constant") == 0)
|
|
||||||
Swig_restore(n);
|
|
||||||
|
|
||||||
/* Return value if necessary */
|
/* Return value if necessary */
|
||||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||||
addThrows(n, "tmap:out", n);
|
addThrows(n, "tmap:out", n);
|
||||||
|
|
|
||||||
|
|
@ -1407,25 +1407,12 @@ MODULA3():
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Cmp(nodeType(n), "constant") == 0) {
|
|
||||||
// Wrapping a constant hack
|
|
||||||
Swig_save("functionWrapper", n, "wrap:action", NIL);
|
|
||||||
|
|
||||||
// below based on Swig_VargetToFunction()
|
|
||||||
SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
|
|
||||||
Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
|
|
||||||
}
|
|
||||||
|
|
||||||
Setattr(n, "wrap:name", wname);
|
Setattr(n, "wrap:name", wname);
|
||||||
|
|
||||||
// Now write code to make the function call
|
// Now write code to make the function call
|
||||||
if (!native_function_flag) {
|
if (!native_function_flag) {
|
||||||
String *actioncode = emit_action(n);
|
String *actioncode = emit_action(n);
|
||||||
|
|
||||||
if (Cmp(nodeType(n), "constant") == 0) {
|
|
||||||
Swig_restore(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return value if necessary */
|
/* Return value if necessary */
|
||||||
String *tm;
|
String *tm;
|
||||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||||
|
|
|
||||||
|
|
@ -1614,7 +1614,14 @@ int Swig_VargetToFunction(Node *n, int flags) {
|
||||||
Delete(mangled);
|
Delete(mangled);
|
||||||
Delete(sname);
|
Delete(sname);
|
||||||
} else {
|
} else {
|
||||||
String *nname = SwigType_namestr(name);
|
String *nname = 0;
|
||||||
|
if (Equal(nodeType(n), "constant")) {
|
||||||
|
String *rawval = Getattr(n, "rawval");
|
||||||
|
String *value = rawval ? rawval : Getattr(n, "value");
|
||||||
|
nname = NewStringf("(%s)", value);
|
||||||
|
} else {
|
||||||
|
nname = SwigType_namestr(name);
|
||||||
|
}
|
||||||
call = Swig_wrapped_var_assign(type, nname, varcref);
|
call = Swig_wrapped_var_assign(type, nname, varcref);
|
||||||
cres = Swig_cresult(ty, Swig_cresult_name(), call);
|
cres = Swig_cresult(ty, Swig_cresult_name(), call);
|
||||||
Setattr(n, "wrap:action", cres);
|
Setattr(n, "wrap:action", cres);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue