PageRenderTime 38ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 1ms

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

#
Swig | 72 lines | 52 code | 16 blank | 4 comment | 0 complexity | c19565d77bfd0b93f8cecff65284c5a7 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /*
  2. This test case tests that various types of arrays are working.
  3. */
  4. %module arrays
  5. %{
  6. #include <stdlib.h>
  7. %}
  8. %inline %{
  9. #define ARRAY_LEN 2
  10. typedef enum {One, Two, Three, Four, Five} finger;
  11. typedef struct {
  12. double double_field;
  13. } SimpleStruct;
  14. typedef struct {
  15. char array_c [ARRAY_LEN];
  16. signed char array_sc[ARRAY_LEN];
  17. unsigned char array_uc[ARRAY_LEN];
  18. short array_s [ARRAY_LEN];
  19. unsigned short array_us[ARRAY_LEN];
  20. int array_i [ARRAY_LEN];
  21. unsigned int array_ui[ARRAY_LEN];
  22. long array_l [ARRAY_LEN];
  23. unsigned long array_ul[ARRAY_LEN];
  24. long long array_ll[ARRAY_LEN];
  25. float array_f [ARRAY_LEN];
  26. double array_d [ARRAY_LEN];
  27. SimpleStruct array_struct[ARRAY_LEN];
  28. SimpleStruct* array_structpointers[ARRAY_LEN];
  29. int* array_ipointers [ARRAY_LEN];
  30. finger array_enum[ARRAY_LEN];
  31. finger* array_enumpointers[ARRAY_LEN];
  32. const int array_const_i[ARRAY_LEN];
  33. } ArrayStruct;
  34. void fn_taking_arrays(SimpleStruct array_struct[ARRAY_LEN]) {}
  35. /* Pointer helper functions used in the Java run test */
  36. int* newintpointer() {
  37. return (int*)malloc(sizeof(int));
  38. }
  39. void setintfrompointer(int* intptr, int value) {
  40. *intptr = value;
  41. }
  42. int getintfrompointer(int* intptr) {
  43. return *intptr;
  44. }
  45. %}
  46. // This tests wrapping of function that involves pointer to array
  47. %inline %{
  48. void array_pointer_func(int (*x)[10]) {}
  49. %}
  50. %inline %{
  51. typedef float FLOAT;
  52. typedef FLOAT cartPosition_t[3];
  53. typedef struct {
  54. cartPosition_t p;
  55. } CartPoseData_t;
  56. %}