/tags/rel-1-3-29/SWIG/Examples/test-suite/li_cwstring.i
Swig | 98 lines | 82 code | 16 blank | 0 comment | 0 complexity | bc97dbca127356527f216ac12c24cabf MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
1%module li_cwstring 2 3%include "cwstring.i" 4 5#ifndef SWIG_CWSTRING_UNIMPL 6 7%cwstring_input_binary(wchar_t *in, int n); 8%cwstring_bounded_output(wchar_t *out1, 512); 9%cwstring_chunk_output(wchar_t *out2, 64); 10%cwstring_bounded_mutable(wchar_t *out3, 512); 11%cwstring_mutable(wchar_t *out4, 32); 12%cwstring_output_maxsize(wchar_t *out5, int max); 13%cwstring_output_withsize(wchar_t *out6, int *size); 14 15#ifdef __cplusplus 16%cwstring_output_allocate(wchar_t **out7, delete [] *$1); 17%cwstring_output_allocate_size(wchar_t **out8, int *size, delete [] *$1); 18#else 19%cwstring_output_allocate(wchar_t **out7, free(*$1)); 20%cwstring_output_allocate_size(wchar_t **out8, int *size, free(*$1)); 21#endif 22 23%inline %{ 24 25int count(wchar_t *in, int n, wchar_t c) { 26 int r = 0; 27 while (n > 0) { 28 if (*in == c) { 29 r++; 30 } 31 in++; 32 --n; 33 } 34 return r; 35} 36 37void test1(wchar_t *out1) { 38 wcscpy(out1,L"Hello World"); 39} 40 41void test2(wchar_t *out2) { 42 int i; 43 for (i = 0; i < 64; i++) { 44 *out2 = (wchar_t) i + 32; 45 out2++; 46 } 47} 48 49void test3(wchar_t *out3) { 50 wcscat(out3,L"-suffix"); 51} 52 53void test4(wchar_t *out4) { 54 wcscat(out4,L"-suffix"); 55} 56 57void test5(wchar_t *out5, int max) { 58 int i; 59 for (i = 0; i < max; i++) { 60 out5[i] = 'x'; 61 } 62 out5[max]='\0'; 63} 64 65void test6(wchar_t *out6, int *size) { 66 int i; 67 for (i = 0; i < (*size/2); i++) { 68 out6[i] = 'x'; 69 } 70 *size = (*size/2); 71} 72 73void test7(wchar_t **out7) { 74#ifdef __cplusplus 75 *out7 = new wchar_t[64]; 76#else 77 *out7 = malloc(64*sizeof(wchar_t)); 78#endif 79 (*out7)[0] = 0; 80 wcscat(*out7,L"Hello world!"); 81} 82 83void test8(wchar_t **out8, int *size) { 84 int i; 85#ifdef __cplusplus 86 *out8 = new wchar_t[64]; 87#else 88 *out8 = malloc(64*sizeof(wchar_t)); 89#endif 90 for (i = 0; i < 64; i++) { 91 (*out8)[i] = (wchar_t) i + 32; 92 } 93 *size = 64; 94} 95 96%} 97 98#endif