Skip to content

Commit ef11208

Browse files
committed
Add test of callback with enum argument
This is an odd use case often with numerical solver flags that's not covered in the existing test suite.
1 parent 77cdba8 commit ef11208

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Examples/test-suite/callback.i

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
%callback("%s") A::foom;
1414
#endif
1515
%callback("%(uppercase)s_Cb_Ptr") foo_T; // this works in Python too
16+
%callback("%s_cb") identity_finger;
1617

1718
%inline %{
1819

@@ -85,6 +86,15 @@
8586
const T& ident(const T& x) {
8687
return x;
8788
}
89+
90+
// Test callbacks for enum types
91+
typedef enum {One, Two, Three, Four, Five} finger;
92+
typedef finger (*finger_finger)(finger);
93+
finger identity_finger(finger f) { return f; }
94+
finger apply_finger_cb(finger f, finger_finger cb) {
95+
return cb(f);
96+
}
97+
8898
%}
8999

90100
%template(foo_i) foo_T<int>;

0 commit comments

Comments
 (0)