Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Side by Side Diff: swig/Lib/python/typemaps.i

Issue 553095: Checkin swig binaries for win, linux and Mac... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/
Patch Set: '' Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « swig/Lib/python/stl.i ('k') | swig/Lib/python/wchar.i » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* -----------------------------------------------------------------------------
2 * See the LICENSE file for information on copyright, usage and redistribution
3 * of SWIG, and the README file for authors - http://www.swig.org/release.html.
4 *
5 * typemaps.i
6 *
7 * Pointer handling
8 * These mappings provide support for input/output arguments and common
9 * uses for C/C++ pointers.
10 * ----------------------------------------------------------------------------- */
11
12 // INPUT typemaps.
13 // These remap a C pointer to be an "INPUT" value which is passed by value
14 // instead of reference.
15
16 /*
17 The following methods can be applied to turn a pointer into a simple
18 "input" value. That is, instead of passing a pointer to an object,
19 you would use a real value instead.
20
21 int *INPUT
22 short *INPUT
23 long *INPUT
24 long long *INPUT
25 unsigned int *INPUT
26 unsigned short *INPUT
27 unsigned long *INPUT
28 unsigned long long *INPUT
29 unsigned char *INPUT
30 bool *INPUT
31 float *INPUT
32 double *INPUT
33
34 To use these, suppose you had a C function like this :
35
36 double fadd(double *a, double *b) {
37 return *a+*b;
38 }
39
40 You could wrap it with SWIG as follows :
41
42 %include <typemaps.i>
43 double fadd(double *INPUT, double *INPUT);
44
45 or you can use the %apply directive :
46
47 %include <typemaps.i>
48 %apply double *INPUT { double *a, double *b };
49 double fadd(double *a, double *b);
50
51 */
52
53 // OUTPUT typemaps. These typemaps are used for parameters that
54 // are output only. The output value is appended to the result as
55 // a list element.
56
57 /*
58 The following methods can be applied to turn a pointer into an "output"
59 value. When calling a function, no input value would be given for
60 a parameter, but an output value would be returned. In the case of
61 multiple output values, they are returned in the form of a Python tuple.
62
63 int *OUTPUT
64 short *OUTPUT
65 long *OUTPUT
66 long long *OUTPUT
67 unsigned int *OUTPUT
68 unsigned short *OUTPUT
69 unsigned long *OUTPUT
70 unsigned long long *OUTPUT
71 unsigned char *OUTPUT
72 bool *OUTPUT
73 float *OUTPUT
74 double *OUTPUT
75
76 For example, suppose you were trying to wrap the modf() function in the
77 C math library which splits x into integral and fractional parts (and
78 returns the integer part in one of its parameters).K:
79
80 double modf(double x, double *ip);
81
82 You could wrap it with SWIG as follows :
83
84 %include <typemaps.i>
85 double modf(double x, double *OUTPUT);
86
87 or you can use the %apply directive :
88
89 %include <typemaps.i>
90 %apply double *OUTPUT { double *ip };
91 double modf(double x, double *ip);
92
93 The Python output of the function would be a tuple containing both
94 output values.
95
96 */
97
98 // INOUT
99 // Mappings for an argument that is both an input and output
100 // parameter
101
102 /*
103 The following methods can be applied to make a function parameter both
104 an input and output value. This combines the behavior of both the
105 "INPUT" and "OUTPUT" methods described earlier. Output values are
106 returned in the form of a Python tuple.
107
108 int *INOUT
109 short *INOUT
110 long *INOUT
111 long long *INOUT
112 unsigned int *INOUT
113 unsigned short *INOUT
114 unsigned long *INOUT
115 unsigned long long *INOUT
116 unsigned char *INOUT
117 bool *INOUT
118 float *INOUT
119 double *INOUT
120
121 For example, suppose you were trying to wrap the following function :
122
123 void neg(double *x) {
124 *x = -(*x);
125 }
126
127 You could wrap it with SWIG as follows :
128
129 %include <typemaps.i>
130 void neg(double *INOUT);
131
132 or you can use the %apply directive :
133
134 %include <typemaps.i>
135 %apply double *INOUT { double *x };
136 void neg(double *x);
137
138 Unlike C, this mapping does not directly modify the input value (since
139 this makes no sense in Python). Rather, the modified input value shows
140 up as the return value of the function. Thus, to apply this function
141 to a Python variable you might do this :
142
143 x = neg(x)
144
145 Note : previous versions of SWIG used the symbol 'BOTH' to mark
146 input/output arguments. This is still supported, but will be slowly
147 phased out in future releases.
148
149 */
150
151 %include <typemaps/typemaps.swg>
OLDNEW
« no previous file with comments | « swig/Lib/python/stl.i ('k') | swig/Lib/python/wchar.i » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698