1 %module li_cwstring
2
3 %include "cwstring.i"
4
5 #ifndef SWIG_CWSTRING_UNIMPL
6
7 %cwstring_input_binary(wchar_t *str_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
count(wchar_t * str_in,int n,wchar_t c)25 int count(wchar_t *str_in, int n, wchar_t c) {
26 int r = 0;
27 while (n > 0) {
28 if (*str_in == c) {
29 r++;
30 }
31 str_in++;
32 --n;
33 }
34 return r;
35 }
36
test1(wchar_t * out1)37 void test1(wchar_t *out1) {
38 wcscpy(out1,L"Hello World");
39 }
40
test2(wchar_t * out2)41 void 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
test3(wchar_t * out3)49 void test3(wchar_t *out3) {
50 wcscat(out3,L"-suffix");
51 }
52
test4(wchar_t * out4)53 void test4(wchar_t *out4) {
54 wcscat(out4,L"-suffix");
55 }
56
test5(wchar_t * out5,int max)57 void 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
test6(wchar_t * out6,int * size)65 void 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
test7(wchar_t ** out7)73 void 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
test8(wchar_t ** out8,int * size)83 void 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
99