~ubuntu-branches/ubuntu/edgy/swig1.3/edgy

« back to all changes in this revision

Viewing changes to Examples/test-suite/li_cwstring.i

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:16:04 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205011604-ygx904it6413k3go
Tags: 1.3.27-1ubuntu1
Resynchronise with Debian again, for the new subversion packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%module li_cwstring
 
2
 
 
3
%include "cwstring.i"
 
4
 
 
5
#ifndef _CSTRING_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
 
 
25
int 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
 
 
37
void test1(wchar_t *out1) {
 
38
   wcscpy(out1,L"Hello World");
 
39
}
 
40
 
 
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
 
 
49
void test3(wchar_t *out3) {
 
50
   wcscat(out3,L"-suffix");
 
51
}
 
52
 
 
53
void test4(wchar_t *out4) {
 
54
   wcscat(out4,L"-suffix");
 
55
}
 
56
 
 
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
 
 
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
 
 
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
 
 
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