PageRenderTime 79ms CodeModel.GetById 7ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/test-suite/java_lib_arrays.i

#
Swig | 69 lines | 57 code | 10 blank | 2 comment | 0 complexity | 6e530fc9997402bd082e7fb3f816030d MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* Testcase for the Java array typemaps which are not used by default. */
  2. %module java_lib_arrays
  3. %include "enumtypeunsafe.swg"
  4. /* Use the Java library typemaps */
  5. %include "arrays_java.i"
  6. JAVA_ARRAYSOFCLASSES(SimpleStruct)
  7. %apply ARRAYSOFENUMS[ANY] { finger[ANY] }
  8. //%apply signed char[ANY] { char array_c2[ANY] }
  9. %include "arrays.i"
  10. // This will test the %typemap(javacode) in the JAVA_ARRAYSOFCLASSES works with C structs amongst other things
  11. JAVA_ARRAYSOFCLASSES(struct AnotherStruct)
  12. %inline %{
  13. struct AnotherStruct {
  14. SimpleStruct simple;
  15. };
  16. double extract(struct AnotherStruct as[], int index) {
  17. return as[index].simple.double_field;
  18. }
  19. double extract2(struct AnotherStruct as[5], int index) {
  20. return as[index].simple.double_field;
  21. }
  22. %}
  23. // Test %apply to pointers
  24. JAVA_ARRAYSOFCLASSES(struct YetAnotherStruct)
  25. %apply struct YetAnotherStruct[] { struct YetAnotherStruct *yas }
  26. //%apply struct YetAnotherStruct[] { struct YetAnotherStruct * } // Note: Does not work unless this is put after the YetAnotherStruct definition
  27. %inline %{
  28. struct YetAnotherStruct {
  29. SimpleStruct simple;
  30. };
  31. double extract_ptr(struct YetAnotherStruct *yas, int index) {
  32. return yas[index].simple.double_field;
  33. }
  34. void modifyYAS(struct YetAnotherStruct yas[], int size) {
  35. int i;
  36. for (i=0; i<size; ++i) {
  37. SimpleStruct ss;
  38. ss.double_field = yas[i].simple.double_field * 10.0;
  39. yas[i].simple = ss;
  40. }
  41. }
  42. %}
  43. %apply ARRAYSOFENUMS[ANY] { toe[ANY] }
  44. %apply ARRAYSOFENUMS[] { toe[] }
  45. %apply ARRAYSOFENUMS[] { toe* }
  46. %inline %{
  47. typedef enum { Big, Little } toe;
  48. void toestest(toe *t, toe tt[], toe ttt[2]) {}
  49. %}
  50. JAVA_ARRAYS_IMPL(char, jbyte, Byte, Char)
  51. JAVA_ARRAYS_TYPEMAPS(char, byte, jbyte, Char, "[B")
  52. %typecheck(SWIG_TYPECHECK_INT8_ARRAY) /* Java byte[] */
  53. signed char[ANY], signed char[]
  54. ""
  55. %inline %{
  56. struct ArrayStructExtra {
  57. char array_c2[ARRAY_LEN];
  58. };
  59. %}