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

« back to all changes in this revision

Viewing changes to Lib/python/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
/*
 
2
 * cstring.i
 
3
 * $Header: /cvsroot/swig/SWIG/Lib/python/cwstring.i,v 1.1 2005/09/06 06:22:10 marcelomatus Exp $
 
4
 *
 
5
 
 
6
 * This file provides typemaps and macros for dealing with various forms
 
7
 * of C character string handling.   The primary use of this module
 
8
 * is in returning character data that has been allocated or changed in
 
9
 * some way.
 
10
 */
 
11
 
 
12
/*
 
13
 * %cwstring_input_binary(TYPEMAP, SIZE)
 
14
 * 
 
15
 * Macro makes a function accept binary string data along with
 
16
 * a size.
 
17
 */
 
18
 
 
19
/*
 
20
 * %cwstring_bounded_output(TYPEMAP, MAX)
 
21
 *
 
22
 * This macro is used to return a NULL-terminated output string of
 
23
 * some maximum length.  For example:
 
24
 *
 
25
 *     %cwstring_bounded_output(wchar_t *outx, 512);
 
26
 *     void foo(wchar_t *outx) {
 
27
 *         sprintf(outx,"blah blah\n");
 
28
 *     }
 
29
 *
 
30
 */
 
31
 
 
32
/*
 
33
 * %cwstring_chunk_output(TYPEMAP, SIZE)
 
34
 *
 
35
 * This macro is used to return a chunk of binary string data.
 
36
 * Embedded NULLs are okay.  For example:
 
37
 *
 
38
 *     %cwstring_chunk_output(wchar_t *outx, 512);
 
39
 *     void foo(wchar_t *outx) {
 
40
 *         memmove(outx, somedata, 512);
 
41
 *     }
 
42
 *
 
43
 */
 
44
 
 
45
/*
 
46
 * %cwstring_bounded_mutable(TYPEMAP, SIZE)
 
47
 *
 
48
 * This macro is used to wrap a string that's going to mutate.
 
49
 *
 
50
 *     %cwstring_bounded_mutable(wchar_t *in, 512);
 
51
 *     void foo(in *x) {
 
52
 *         while (*x) {
 
53
 *            *x = toupper(*x);
 
54
 *            x++;
 
55
 *         }
 
56
 *     }
 
57
 *
 
58
 */
 
59
 
 
60
/*
 
61
 * %cwstring_mutable(TYPEMAP [, expansion])
 
62
 *
 
63
 * This macro is used to wrap a string that will mutate in place.
 
64
 * It may change size up to a user-defined expansion. 
 
65
 *
 
66
 *     %cwstring_mutable(wchar_t *in);
 
67
 *     void foo(in *x) {
 
68
 *         while (*x) {
 
69
 *            *x = toupper(*x);
 
70
 *            x++;
 
71
 *         }
 
72
 *     }
 
73
 *
 
74
 */
 
75
 
 
76
/*
 
77
 * %cwstring_output_maxsize(TYPEMAP, SIZE)
 
78
 *
 
79
 * This macro returns data in a string of some user-defined size.
 
80
 *
 
81
 *     %cwstring_output_maxsize(wchar_t *outx, int max) {
 
82
 *     void foo(wchar_t *outx, int max) {
 
83
 *         sprintf(outx,"blah blah\n");
 
84
 *     }
 
85
 */
 
86
 
 
87
/*
 
88
 * %cwstring_output_withsize(TYPEMAP, SIZE)
 
89
 *
 
90
 * This macro is used to return wchar_tacter data along with a size
 
91
 * parameter.
 
92
 *
 
93
 *     %cwstring_output_maxsize(wchar_t *outx, int *max) {
 
94
 *     void foo(wchar_t *outx, int *max) {
 
95
 *         sprintf(outx,"blah blah\n");
 
96
 *         *max = strlen(outx);  
 
97
 *     }
 
98
 */
 
99
 
 
100
/*
 
101
 * %cwstring_output_allocate(TYPEMAP, RELEASE)
 
102
 *
 
103
 * This macro is used to return wchar_tacter data that was
 
104
 * allocated with new or malloc.
 
105
 *
 
106
 *     %cwstring_output_allocated(wchar_t **outx, free($1));
 
107
 *     void foo(wchar_t **outx) {
 
108
 *         *outx = (wchar_t *) malloc(512);
 
109
 *         sprintf(outx,"blah blah\n");
 
110
 *     }
 
111
 */
 
112
 
 
113
/*
 
114
 * %cwstring_output_allocate_size(TYPEMAP, SIZE, RELEASE)
 
115
 *
 
116
 * This macro is used to return wchar_tacter data that was
 
117
 * allocated with new or malloc.
 
118
 *
 
119
 *     %cwstring_output_allocated(wchar_t **outx, int *sz, free($1));
 
120
 *     void foo(wchar_t **outx, int *sz) {
 
121
 *         *outx = (wchar_t *) malloc(512);
 
122
 *         sprintf(outx,"blah blah\n");
 
123
 *         *sz = strlen(outx);
 
124
 *     }
 
125
 */
 
126
 
 
127
 
 
128
%include <pywstrings.swg>
 
129
%include <cstrbase.swg>
 
130
 
 
131
%typemap_cstrings(%cwstring,
 
132
                  wchar_t,
 
133
                  SWIG_AsWCharPtr,
 
134
                  SWIG_AsWCharPtrAndSize,
 
135
                  SWIG_FromWCharPtr,
 
136
                  SWIG_FromWCharArray);
 
137