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