/tags/rel-1.3.35/Lib/csharp/csharp.swg
Unknown | 979 lines | 863 code | 116 blank | 0 comment | 0 complexity | 39cf0c2d64756f60bf202fe27e857189 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
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 * csharp.swg
6 *
7 * C# typemaps
8 * ----------------------------------------------------------------------------- */
9
10%include <csharphead.swg>
11
12/* The ctype, imtype and cstype typemaps work together and so there should be one of each.
13 * The ctype typemap contains the PInvoke type used in the PInvoke (C/C++) code.
14 * The imtype typemap contains the C# type used in the intermediary class.
15 * The cstype typemap contains the C# type used in the C# proxy classes, type wrapper classes and module class. */
16
17
18/* Fragments */
19%fragment("SWIG_PackData", "header") {
20/* Pack binary data into a string */
21SWIGINTERN char * SWIG_PackData(char *c, void *ptr, size_t sz) {
22 static const char hex[17] = "0123456789abcdef";
23 register const unsigned char *u = (unsigned char *) ptr;
24 register const unsigned char *eu = u + sz;
25 for (; u != eu; ++u) {
26 register unsigned char uu = *u;
27 *(c++) = hex[(uu & 0xf0) >> 4];
28 *(c++) = hex[uu & 0xf];
29 }
30 return c;
31}
32}
33
34%fragment("SWIG_UnPackData", "header") {
35/* Unpack binary data from a string */
36SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
37 register unsigned char *u = (unsigned char *) ptr;
38 register const unsigned char *eu = u + sz;
39 for (; u != eu; ++u) {
40 register char d = *(c++);
41 register unsigned char uu;
42 if ((d >= '0') && (d <= '9'))
43 uu = ((d - '0') << 4);
44 else if ((d >= 'a') && (d <= 'f'))
45 uu = ((d - ('a'-10)) << 4);
46 else
47 return (char *) 0;
48 d = *(c++);
49 if ((d >= '0') && (d <= '9'))
50 uu |= (d - '0');
51 else if ((d >= 'a') && (d <= 'f'))
52 uu |= (d - ('a'-10));
53 else
54 return (char *) 0;
55 *u = uu;
56 }
57 return c;
58}
59}
60
61/* Primitive types */
62%typemap(ctype) bool, const bool & "unsigned int"
63%typemap(ctype) char, const char & "char"
64%typemap(ctype) signed char, const signed char & "signed char"
65%typemap(ctype) unsigned char, const unsigned char & "unsigned char"
66%typemap(ctype) short, const short & "short"
67%typemap(ctype) unsigned short, const unsigned short & "unsigned short"
68%typemap(ctype) int, const int & "int"
69%typemap(ctype) unsigned int, const unsigned int & "unsigned int"
70%typemap(ctype) long, const long & "long"
71%typemap(ctype) unsigned long, const unsigned long & "unsigned long"
72%typemap(ctype) long long, const long long & "long long"
73%typemap(ctype) unsigned long long, const unsigned long long & "unsigned long long"
74%typemap(ctype) float, const float & "float"
75%typemap(ctype) double, const double & "double"
76%typemap(ctype) void "void"
77
78%typemap(imtype) bool, const bool & "bool"
79%typemap(imtype) char, const char & "char"
80%typemap(imtype) signed char, const signed char & "sbyte"
81%typemap(imtype) unsigned char, const unsigned char & "byte"
82%typemap(imtype) short, const short & "short"
83%typemap(imtype) unsigned short, const unsigned short & "ushort"
84%typemap(imtype) int, const int & "int"
85%typemap(imtype) unsigned int, const unsigned int & "uint"
86%typemap(imtype) long, const long & "int"
87%typemap(imtype) unsigned long, const unsigned long & "uint"
88%typemap(imtype) long long, const long long & "long"
89%typemap(imtype) unsigned long long, const unsigned long long & "ulong"
90%typemap(imtype) float, const float & "float"
91%typemap(imtype) double, const double & "double"
92%typemap(imtype) void "void"
93
94%typemap(cstype) bool, const bool & "bool"
95%typemap(cstype) char, const char & "char"
96%typemap(cstype) signed char, const signed char & "sbyte"
97%typemap(cstype) unsigned char, const unsigned char & "byte"
98%typemap(cstype) short, const short & "short"
99%typemap(cstype) unsigned short, const unsigned short & "ushort"
100%typemap(cstype) int, const int & "int"
101%typemap(cstype) unsigned int, const unsigned int & "uint"
102%typemap(cstype) long, const long & "int"
103%typemap(cstype) unsigned long, const unsigned long & "uint"
104%typemap(cstype) long long, const long long & "long"
105%typemap(cstype) unsigned long long, const unsigned long long & "ulong"
106%typemap(cstype) float, const float & "float"
107%typemap(cstype) double, const double & "double"
108%typemap(cstype) void "void"
109
110%typemap(ctype) char *, char *&, char[ANY], char[] "char *"
111%typemap(imtype) char *, char *&, char[ANY], char[] "string"
112%typemap(cstype) char *, char *&, char[ANY], char[] "string"
113
114/* Non primitive types */
115%typemap(ctype) SWIGTYPE "void *"
116%typemap(imtype, out="IntPtr") SWIGTYPE "HandleRef"
117%typemap(cstype) SWIGTYPE "$&csclassname"
118
119%typemap(ctype) SWIGTYPE [] "void *"
120%typemap(imtype, out="IntPtr") SWIGTYPE [] "HandleRef"
121%typemap(cstype) SWIGTYPE [] "$csclassname"
122
123%typemap(ctype) SWIGTYPE * "void *"
124%typemap(imtype, out="IntPtr") SWIGTYPE * "HandleRef"
125%typemap(cstype) SWIGTYPE * "$csclassname"
126
127%typemap(ctype) SWIGTYPE & "void *"
128%typemap(imtype, out="IntPtr") SWIGTYPE & "HandleRef"
129%typemap(cstype) SWIGTYPE & "$csclassname"
130
131/* pointer to a class member */
132%typemap(ctype) SWIGTYPE (CLASS::*) "char *"
133%typemap(imtype) SWIGTYPE (CLASS::*) "string"
134%typemap(cstype) SWIGTYPE (CLASS::*) "$csclassname"
135
136/* The following are the in and out typemaps. These are the PInvoke code generating typemaps for converting from C# to C and visa versa. */
137
138/* primitive types */
139%typemap(in) bool
140%{ $1 = $input ? true : false; %}
141
142%typemap(directorout) bool
143%{ $result = $input ? true : false; %}
144
145%typemap(csdirectorin) bool "$iminput"
146%typemap(csdirectorout) bool "$cscall"
147
148%typemap(in) char,
149 signed char,
150 unsigned char,
151 short,
152 unsigned short,
153 int,
154 unsigned int,
155 long,
156 unsigned long,
157 long long,
158 unsigned long long,
159 float,
160 double
161%{ $1 = ($1_ltype)$input; %}
162
163%typemap(directorout) char,
164 signed char,
165 unsigned char,
166 short,
167 unsigned short,
168 int,
169 unsigned int,
170 long,
171 unsigned long,
172 long long,
173 unsigned long long,
174 float,
175 double
176%{ $result = ($1_ltype)$input; %}
177
178%typemap(directorin) bool "$input = $1;"
179%typemap(directorin) char "$input = $1;"
180%typemap(directorin) signed char "$input = $1;"
181%typemap(directorin) unsigned char "$input = $1;"
182%typemap(directorin) short "$input = $1;"
183%typemap(directorin) unsigned short "$input = $1;"
184%typemap(directorin) int "$input = $1;"
185%typemap(directorin) unsigned int "$input = $1;"
186%typemap(directorin) long "$input = $1;"
187%typemap(directorin) unsigned long "$input = $1;"
188%typemap(directorin) long long "$input = $1;"
189%typemap(directorin) unsigned long long "$input = $1;"
190%typemap(directorin) float "$input = $1;"
191%typemap(directorin) double "$input = $1;"
192
193%typemap(csdirectorin) char,
194 signed char,
195 unsigned char,
196 short,
197 unsigned short,
198 int,
199 unsigned int,
200 long,
201 unsigned long,
202 long long,
203 unsigned long long,
204 float,
205 double
206 "$iminput"
207
208%typemap(csdirectorout) char,
209 signed char,
210 unsigned char,
211 short,
212 unsigned short,
213 int,
214 unsigned int,
215 long,
216 unsigned long,
217 long long,
218 unsigned long long,
219 float,
220 double
221 "$cscall"
222
223%typemap(out) bool %{ $result = $1; %}
224%typemap(out) char %{ $result = $1; %}
225%typemap(out) signed char %{ $result = $1; %}
226%typemap(out) unsigned char %{ $result = $1; %}
227%typemap(out) short %{ $result = $1; %}
228%typemap(out) unsigned short %{ $result = $1; %}
229%typemap(out) int %{ $result = $1; %}
230%typemap(out) unsigned int %{ $result = $1; %}
231%typemap(out) long %{ $result = $1; %}
232%typemap(out) unsigned long %{ $result = (unsigned long)$1; %}
233%typemap(out) long long %{ $result = $1; %}
234%typemap(out) unsigned long long %{ $result = $1; %}
235%typemap(out) float %{ $result = $1; %}
236%typemap(out) double %{ $result = $1; %}
237
238/* char * - treat as String */
239%typemap(in) char * %{ $1 = ($1_ltype)$input; %}
240%typemap(out) char * %{ $result = SWIG_csharp_string_callback((const char *)$1); %}
241%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) char * %{ $result = ($1_ltype)$input; %}
242%typemap(directorin) char * %{ $input = SWIG_csharp_string_callback((const char *)$1); %}
243%typemap(csdirectorin) char * "$iminput"
244%typemap(csdirectorout) char * "$cscall"
245
246/* char *& - treat as String */
247%typemap(in) char *& ($*1_ltype temp = 0) %{
248 temp = ($*1_ltype)$input;
249 $1 = &temp;
250%}
251%typemap(out) char *& %{ if ($1) $result = SWIG_csharp_string_callback((const char *)*$1); %}
252
253%typemap(out, null="") void ""
254%typemap(csdirectorin) void "$iminput"
255%typemap(csdirectorout) void "$cscall"
256%typemap(directorin) void ""
257
258/* primitive types by const reference */
259%typemap(in) const bool & ($*1_ltype temp)
260%{ temp = $input ? true : false;
261 $1 = &temp; %}
262
263%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const bool &
264%{ static $*1_ltype temp;
265 temp = $input ? true : false;
266 $result = &temp; %}
267
268%typemap(csdirectorin) const bool & "$iminput"
269%typemap(csdirectorout) const bool & "$cscall"
270
271%typemap(in) const char & ($*1_ltype temp),
272 const signed char & ($*1_ltype temp),
273 const unsigned char & ($*1_ltype temp),
274 const short & ($*1_ltype temp),
275 const unsigned short & ($*1_ltype temp),
276 const int & ($*1_ltype temp),
277 const unsigned int & ($*1_ltype temp),
278 const long & ($*1_ltype temp),
279 const unsigned long & ($*1_ltype temp),
280 const long long & ($*1_ltype temp),
281 const unsigned long long & ($*1_ltype temp),
282 const float & ($*1_ltype temp),
283 const double & ($*1_ltype temp)
284%{ temp = ($*1_ltype)$input;
285 $1 = &temp; %}
286
287%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const char &,
288 const signed char &,
289 const unsigned char &,
290 const short &,
291 const unsigned short &,
292 const int &,
293 const unsigned int &,
294 const long &,
295 const unsigned long &,
296 const long long &,
297 const float &,
298 const double &
299%{ static $*1_ltype temp;
300 temp = ($*1_ltype)$input;
301 $result = &temp; %}
302
303%typemap(directorin) const bool & "$input = $1_name;"
304%typemap(directorin) const char & "$input = $1_name;"
305%typemap(directorin) const signed char & "$input = $1_name;"
306%typemap(directorin) const unsigned char & "$input = $1_name;"
307%typemap(directorin) const short & "$input = $1_name;"
308%typemap(directorin) const unsigned short & "$input = $1_name;"
309%typemap(directorin) const int & "$input = $1_name;"
310%typemap(directorin) const unsigned int & "$input = $1_name;"
311%typemap(directorin) const long & "$input = $1_name;"
312%typemap(directorin) const unsigned long & "$input = $1_name;"
313%typemap(directorin) const long long & "$input = $1_name;"
314%typemap(directorin) const float & "$input = $1_name;"
315%typemap(directorin) const double & "$input = $1_name;"
316
317%typemap(csdirectorin) const char & ($*1_ltype temp),
318 const signed char & ($*1_ltype temp),
319 const unsigned char & ($*1_ltype temp),
320 const short & ($*1_ltype temp),
321 const unsigned short & ($*1_ltype temp),
322 const int & ($*1_ltype temp),
323 const unsigned int & ($*1_ltype temp),
324 const long & ($*1_ltype temp),
325 const unsigned long & ($*1_ltype temp),
326 const long long & ($*1_ltype temp),
327 const float & ($*1_ltype temp),
328 const double & ($*1_ltype temp)
329 "$iminput"
330
331%typemap(csdirectorout) const char & ($*1_ltype temp),
332 const signed char & ($*1_ltype temp),
333 const unsigned char & ($*1_ltype temp),
334 const short & ($*1_ltype temp),
335 const unsigned short & ($*1_ltype temp),
336 const int & ($*1_ltype temp),
337 const unsigned int & ($*1_ltype temp),
338 const long & ($*1_ltype temp),
339 const unsigned long & ($*1_ltype temp),
340 const long long & ($*1_ltype temp),
341 const float & ($*1_ltype temp),
342 const double & ($*1_ltype temp)
343 "$cscall"
344
345
346%typemap(out) const bool & %{ $result = *$1; %}
347%typemap(out) const char & %{ $result = *$1; %}
348%typemap(out) const signed char & %{ $result = *$1; %}
349%typemap(out) const unsigned char & %{ $result = *$1; %}
350%typemap(out) const short & %{ $result = *$1; %}
351%typemap(out) const unsigned short & %{ $result = *$1; %}
352%typemap(out) const int & %{ $result = *$1; %}
353%typemap(out) const unsigned int & %{ $result = *$1; %}
354%typemap(out) const long & %{ $result = *$1; %}
355%typemap(out) const unsigned long & %{ $result = (unsigned long)*$1; %}
356%typemap(out) const long long & %{ $result = *$1; %}
357%typemap(out) const unsigned long long & %{ $result = *$1; %}
358%typemap(out) const float & %{ $result = *$1; %}
359%typemap(out) const double & %{ $result = *$1; %}
360
361/* Default handling. Object passed by value. Convert to a pointer */
362%typemap(in, canthrow=1) SWIGTYPE ($&1_type argp)
363%{ argp = ($&1_ltype)$input;
364 if (!argp) {
365 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0);
366 return $null;
367 }
368 $1 = *argp; %}
369
370%typemap(directorout) SWIGTYPE
371%{ if (!$input) {
372 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Unexpected null return for type $1_type", 0);
373 return $null;
374 }
375 $result = *($&1_ltype)$input; %}
376
377%typemap(out) SWIGTYPE
378#ifdef __cplusplus
379%{ $result = new $1_ltype(($1_ltype &)$1); %}
380#else
381{
382 $&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype));
383 memmove($1ptr, &$1, sizeof($1_type));
384 $result = $1ptr;
385}
386#endif
387
388%typemap(directorin) SWIGTYPE
389%{ $input = (void *)&$1; %}
390%typemap(csdirectorin) SWIGTYPE "new $&csclassname($iminput, false)"
391%typemap(csdirectorout) SWIGTYPE "$&csclassname.getCPtr($cscall).Handle"
392
393/* Generic pointers and references */
394%typemap(in) SWIGTYPE * %{ $1 = ($1_ltype)$input; %}
395%typemap(in, fragment="SWIG_UnPackData") SWIGTYPE (CLASS::*) %{
396 SWIG_UnpackData($input, (void *)&$1, sizeof($1));
397%}
398%typemap(in, canthrow=1) SWIGTYPE & %{ $1 = ($1_ltype)$input;
399 if(!$1) {
400 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type type is null", 0);
401 return $null;
402 } %}
403%typemap(out) SWIGTYPE * %{ $result = (void *)$1; %}
404%typemap(out, fragment="SWIG_PackData") SWIGTYPE (CLASS::*) %{
405 char buf[128];
406 char *data = SWIG_PackData(buf, (void *)&$1, sizeof($1));
407 *data = '\0';
408 $result = SWIG_csharp_string_callback(buf);
409%}
410%typemap(out) SWIGTYPE & %{ $result = (void *)$1; %}
411
412%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *
413%{ $result = ($1_ltype)$input; %}
414%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE (CLASS::*)
415%{ $result = ($1_ltype)$input; %}
416
417%typemap(directorin) SWIGTYPE *
418%{ $input = (void *) $1; %}
419%typemap(directorin) SWIGTYPE (CLASS::*)
420%{ $input = (void *) $1; %}
421
422%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &
423%{ if (!$input) {
424 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Unexpected null return for type $1_type", 0);
425 return $null;
426 }
427 $result = ($1_ltype)$input; %}
428%typemap(directorin) SWIGTYPE &
429%{ $input = ($1_ltype) &$1; %}
430
431%typemap(csdirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "new $csclassname($iminput, false)"
432%typemap(csdirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "$csclassname.getCPtr($cscall).Handle"
433
434/* Default array handling */
435%typemap(in) SWIGTYPE [] %{ $1 = ($1_ltype)$input; %}
436%typemap(out) SWIGTYPE [] %{ $result = $1; %}
437
438/* char arrays - treat as String */
439%typemap(in) char[ANY], char[] %{ $1 = ($1_ltype)$input; %}
440%typemap(out) char[ANY], char[] %{ $result = SWIG_csharp_string_callback((const char *)$1); %}
441
442%typemap(directorout) char[ANY], char[] %{ $result = ($1_ltype)$input; %}
443%typemap(directorin) char[ANY], char[] %{ $input = SWIG_csharp_string_callback((const char *)$1); %}
444
445%typemap(csdirectorin) char[ANY], char[] "$iminput"
446%typemap(csdirectorout) char[ANY], char[] "$cscall"
447
448
449/* Typecheck typemaps - The purpose of these is merely to issue a warning for overloaded C++ functions
450 * that cannot be overloaded in C# as more than one C++ type maps to a single C# type */
451
452%typecheck(SWIG_TYPECHECK_BOOL)
453 bool,
454 const bool &
455 ""
456
457%typecheck(SWIG_TYPECHECK_CHAR)
458 char,
459 const char &
460 ""
461
462%typecheck(SWIG_TYPECHECK_INT8)
463 signed char,
464 const signed char &
465 ""
466
467%typecheck(SWIG_TYPECHECK_UINT8)
468 unsigned char,
469 const unsigned char &
470 ""
471
472%typecheck(SWIG_TYPECHECK_INT16)
473 short,
474 const short &
475 ""
476
477%typecheck(SWIG_TYPECHECK_UINT16)
478 unsigned short,
479 const unsigned short &
480 ""
481
482%typecheck(SWIG_TYPECHECK_INT32)
483 int,
484 long,
485 const int &,
486 const long &
487 ""
488
489%typecheck(SWIG_TYPECHECK_UINT32)
490 unsigned int,
491 unsigned long,
492 const unsigned int &,
493 const unsigned long &
494 ""
495
496%typecheck(SWIG_TYPECHECK_INT64)
497 long long,
498 const long long &
499 ""
500
501%typecheck(SWIG_TYPECHECK_UINT64)
502 unsigned long long,
503 const unsigned long long &
504 ""
505
506%typecheck(SWIG_TYPECHECK_FLOAT)
507 float,
508 const float &
509 ""
510
511%typecheck(SWIG_TYPECHECK_DOUBLE)
512 double,
513 const double &
514 ""
515
516%typecheck(SWIG_TYPECHECK_STRING)
517 char *,
518 char *&,
519 char[ANY],
520 char[]
521 ""
522
523%typecheck(SWIG_TYPECHECK_POINTER)
524 SWIGTYPE,
525 SWIGTYPE *,
526 SWIGTYPE &,
527 SWIGTYPE [],
528 SWIGTYPE (CLASS::*)
529 ""
530
531/* Exception handling */
532
533%typemap(throws, canthrow=1) int,
534 long,
535 short,
536 unsigned int,
537 unsigned long,
538 unsigned short
539%{ char error_msg[256];
540 sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1);
541 SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, error_msg);
542 return $null; %}
543
544%typemap(throws, canthrow=1) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY]
545%{ (void)$1;
546 SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown");
547 return $null; %}
548
549%typemap(throws, canthrow=1) char *
550%{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1);
551 return $null; %}
552
553
554/* Typemaps for code generation in proxy classes and C# type wrapper classes */
555
556/* The csin typemap is used for converting function parameter types from the type
557 * used in the proxy, module or type wrapper class to the type used in the PInvoke class. */
558%typemap(csin) bool, const bool &,
559 char, const char &,
560 signed char, const signed char &,
561 unsigned char, const unsigned char &,
562 short, const short &,
563 unsigned short, const unsigned short &,
564 int, const int &,
565 unsigned int, const unsigned int &,
566 long, const long &,
567 unsigned long, const unsigned long &,
568 long long, const long long &,
569 unsigned long long, const unsigned long long &,
570 float, const float &,
571 double, const double &
572 "$csinput"
573%typemap(csin) char *, char *&, char[ANY], char[] "$csinput"
574%typemap(csin) SWIGTYPE "$&csclassname.getCPtr($csinput)"
575%typemap(csin) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] "$csclassname.getCPtr($csinput)"
576%typemap(csin) SWIGTYPE (CLASS::*) "$csclassname.getCMemberPtr($csinput)"
577
578/* The csout typemap is used for converting function return types from the return type
579 * used in the PInvoke class to the type returned by the proxy, module or type wrapper class.
580 * The $excode special variable is replaced by the excode typemap attribute code if the
581 * method can throw any exceptions from unmanaged code, otherwise replaced by nothing. */
582
583// Macro used by the $excode special variable
584%define SWIGEXCODE "\n if ($imclassname.SWIGPendingException.Pending) throw $imclassname.SWIGPendingException.Retrieve();" %enddef
585%define SWIGEXCODE2 "\n if ($imclassname.SWIGPendingException.Pending) throw $imclassname.SWIGPendingException.Retrieve();" %enddef
586
587%typemap(csout, excode=SWIGEXCODE) bool, const bool & {
588 bool ret = $imcall;$excode
589 return ret;
590 }
591%typemap(csout, excode=SWIGEXCODE) char, const char & {
592 char ret = $imcall;$excode
593 return ret;
594 }
595%typemap(csout, excode=SWIGEXCODE) signed char, const signed char & {
596 sbyte ret = $imcall;$excode
597 return ret;
598 }
599%typemap(csout, excode=SWIGEXCODE) unsigned char, const unsigned char & {
600 byte ret = $imcall;$excode
601 return ret;
602 }
603%typemap(csout, excode=SWIGEXCODE) short, const short & {
604 short ret = $imcall;$excode
605 return ret;
606 }
607%typemap(csout, excode=SWIGEXCODE) unsigned short, const unsigned short & {
608 ushort ret = $imcall;$excode
609 return ret;
610 }
611%typemap(csout, excode=SWIGEXCODE) int, const int & {
612 int ret = $imcall;$excode
613 return ret;
614 }
615%typemap(csout, excode=SWIGEXCODE) unsigned int, const unsigned int & {
616 uint ret = $imcall;$excode
617 return ret;
618 }
619%typemap(csout, excode=SWIGEXCODE) long, const long & {
620 int ret = $imcall;$excode
621 return ret;
622 }
623%typemap(csout, excode=SWIGEXCODE) unsigned long, const unsigned long & {
624 uint ret = $imcall;$excode
625 return ret;
626 }
627%typemap(csout, excode=SWIGEXCODE) long long, const long long & {
628 long ret = $imcall;$excode
629 return ret;
630 }
631%typemap(csout, excode=SWIGEXCODE) unsigned long long, const unsigned long long & {
632 ulong ret = $imcall;$excode
633 return ret;
634 }
635%typemap(csout, excode=SWIGEXCODE) float, const float & {
636 float ret = $imcall;$excode
637 return ret;
638 }
639%typemap(csout, excode=SWIGEXCODE) double, const double & {
640 double ret = $imcall;$excode
641 return ret;
642 }
643%typemap(csout, excode=SWIGEXCODE) char *, char *&, char[ANY], char[] {
644 string ret = $imcall;$excode
645 return ret;
646 }
647%typemap(csout, excode=SWIGEXCODE) void {
648 $imcall;$excode
649 }
650%typemap(csout, excode=SWIGEXCODE) SWIGTYPE {
651 $&csclassname ret = new $&csclassname($imcall, true);$excode
652 return ret;
653 }
654%typemap(csout, excode=SWIGEXCODE) SWIGTYPE & {
655 $csclassname ret = new $csclassname($imcall, $owner);$excode
656 return ret;
657 }
658%typemap(csout, excode=SWIGEXCODE) SWIGTYPE *, SWIGTYPE [] {
659 IntPtr cPtr = $imcall;
660 $csclassname ret = (cPtr == IntPtr.Zero) ? null : new $csclassname(cPtr, $owner);$excode
661 return ret;
662 }
663%typemap(csout, excode=SWIGEXCODE) SWIGTYPE (CLASS::*) {
664 string cMemberPtr = $imcall;
665 $csclassname ret = (cMemberPtr == null) ? null : new $csclassname(cMemberPtr, $owner);$excode
666 return ret;
667 }
668
669
670/* Properties */
671%typemap(csvarin, excode=SWIGEXCODE2) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
672 set {
673 $imcall;$excode
674 } %}
675
676%typemap(csvarin, excode=SWIGEXCODE2) char *, char *&, char[ANY], char[] %{
677 set {
678 $imcall;$excode
679 } %}
680
681%typemap(csvarout, excode=SWIGEXCODE2) bool, const bool & %{
682 get {
683 bool ret = $imcall;$excode
684 return ret;
685 } %}
686%typemap(csvarout, excode=SWIGEXCODE2) char, const char & %{
687 get {
688 char ret = $imcall;$excode
689 return ret;
690 } %}
691%typemap(csvarout, excode=SWIGEXCODE2) signed char, const signed char & %{
692 get {
693 sbyte ret = $imcall;$excode
694 return ret;
695 } %}
696%typemap(csvarout, excode=SWIGEXCODE2) unsigned char, const unsigned char & %{
697 get {
698 byte ret = $imcall;$excode
699 return ret;
700 } %}
701%typemap(csvarout, excode=SWIGEXCODE2) short, const short & %{
702 get {
703 short ret = $imcall;$excode
704 return ret;
705 } %}
706%typemap(csvarout, excode=SWIGEXCODE2) unsigned short, const unsigned short & %{
707 get {
708 ushort ret = $imcall;$excode
709 return ret;
710 } %}
711%typemap(csvarout, excode=SWIGEXCODE2) int, const int & %{
712 get {
713 int ret = $imcall;$excode
714 return ret;
715 } %}
716%typemap(csvarout, excode=SWIGEXCODE2) unsigned int, const unsigned int & %{
717 get {
718 uint ret = $imcall;$excode
719 return ret;
720 } %}
721%typemap(csvarout, excode=SWIGEXCODE2) long, const long & %{
722 get {
723 int ret = $imcall;$excode
724 return ret;
725 } %}
726%typemap(csvarout, excode=SWIGEXCODE2) unsigned long, const unsigned long & %{
727 get {
728 uint ret = $imcall;$excode
729 return ret;
730 } %}
731%typemap(csvarout, excode=SWIGEXCODE2) long long, const long long & %{
732 get {
733 long ret = $imcall;$excode
734 return ret;
735 } %}
736%typemap(csvarout, excode=SWIGEXCODE2) unsigned long long, const unsigned long long & %{
737 get {
738 ulong ret = $imcall;$excode
739 return ret;
740 } %}
741%typemap(csvarout, excode=SWIGEXCODE2) float, const float & %{
742 get {
743 float ret = $imcall;$excode
744 return ret;
745 } %}
746%typemap(csvarout, excode=SWIGEXCODE2) double, const double & %{
747 get {
748 double ret = $imcall;$excode
749 return ret;
750 } %}
751
752
753%typemap(csvarout, excode=SWIGEXCODE2) char *, char *&, char[ANY], char[] %{
754 get {
755 string ret = $imcall;$excode
756 return ret;
757 } %}
758%typemap(csvarout, excode=SWIGEXCODE2) void %{
759 get {
760 $imcall;$excode
761 } %}
762%typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE %{
763 get {
764 $&csclassname ret = new $&csclassname($imcall, true);$excode
765 return ret;
766 } %}
767%typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE & %{
768 get {
769 $csclassname ret = new $csclassname($imcall, $owner);$excode
770 return ret;
771 } %}
772%typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE *, SWIGTYPE [] %{
773 get {
774 IntPtr cPtr = $imcall;
775 $csclassname ret = (cPtr == IntPtr.Zero) ? null : new $csclassname(cPtr, $owner);$excode
776 return ret;
777 } %}
778
779%typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE (CLASS::*) %{
780 get {
781 string cMemberPtr = $imcall;
782 $csclassname ret = (cMemberPtr == null) ? null : new $csclassname(cMemberPtr, $owner);$excode
783 return ret;
784 } %}
785
786/* Pointer reference typemaps */
787%typemap(ctype) SWIGTYPE *& "void *"
788%typemap(imtype, out="IntPtr") SWIGTYPE *& "HandleRef"
789%typemap(cstype) SWIGTYPE *& "$*csclassname"
790%typemap(csin) SWIGTYPE *& "$*csclassname.getCPtr($csinput)"
791%typemap(csout, excode=SWIGEXCODE) SWIGTYPE *& {
792 IntPtr cPtr = $imcall;
793 $*csclassname ret = (cPtr == IntPtr.Zero) ? null : new $*csclassname(cPtr, $owner);$excode
794 return ret;
795 }
796%typemap(in) SWIGTYPE *& ($*1_ltype temp = 0)
797%{ temp = ($*1_ltype)$input;
798 $1 = &temp; %}
799%typemap(out) SWIGTYPE *&
800%{ $result = (void *)*$1; %}
801
802/* Array reference typemaps */
803%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
804
805/* Typemaps used for the generation of proxy and type wrapper class code */
806%typemap(csbase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
807%typemap(csclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class"
808%typemap(cscode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
809%typemap(csimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "\nusing System;\nusing System.Runtime.InteropServices;\n"
810%typemap(csinterfaces) SWIGTYPE "IDisposable"
811%typemap(csinterfaces) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
812%typemap(csinterfaces_derived) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
813
814// Proxy classes (base classes, ie, not derived classes)
815%typemap(csbody) SWIGTYPE %{
816 private HandleRef swigCPtr;
817 protected bool swigCMemOwn;
818
819 internal $csclassname(IntPtr cPtr, bool cMemoryOwn) {
820 swigCMemOwn = cMemoryOwn;
821 swigCPtr = new HandleRef(this, cPtr);
822 }
823
824 internal static HandleRef getCPtr($csclassname obj) {
825 return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
826 }
827%}
828
829// Derived proxy classes
830%typemap(csbody_derived) SWIGTYPE %{
831 private HandleRef swigCPtr;
832
833 internal $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclassnameUpcast(cPtr), cMemoryOwn) {
834 swigCPtr = new HandleRef(this, cPtr);
835 }
836
837 internal static HandleRef getCPtr($csclassname obj) {
838 return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
839 }
840%}
841
842// Typewrapper classes
843%typemap(csbody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] %{
844 private HandleRef swigCPtr;
845
846 internal $csclassname(IntPtr cPtr, bool futureUse) {
847 swigCPtr = new HandleRef(this, cPtr);
848 }
849
850 protected $csclassname() {
851 swigCPtr = new HandleRef(null, IntPtr.Zero);
852 }
853
854 internal static HandleRef getCPtr($csclassname obj) {
855 return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
856 }
857%}
858
859%typemap(csbody) SWIGTYPE (CLASS::*) %{
860 private string swigCMemberPtr;
861
862 internal $csclassname(string cMemberPtr, bool futureUse) {
863 swigCMemberPtr = cMemberPtr;
864 }
865
866 protected $csclassname() {
867 swigCMemberPtr = null;
868 }
869
870 internal static string getCMemberPtr($csclassname obj) {
871 return obj.swigCMemberPtr;
872 }
873%}
874
875%typemap(csfinalize) SWIGTYPE %{
876 ~$csclassname() {
877 Dispose();
878 }
879%}
880
881%typemap(csconstruct, excode=SWIGEXCODE,directorconnect="\n SwigDirectorConnect();") SWIGTYPE %{: this($imcall, true) {$excode$directorconnect
882 }
883%}
884
885%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") SWIGTYPE {
886 lock(this) {
887 if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
888 swigCMemOwn = false;
889 $imcall;
890 }
891 swigCPtr = new HandleRef(null, IntPtr.Zero);
892 GC.SuppressFinalize(this);
893 }
894 }
895
896%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") SWIGTYPE {
897 lock(this) {
898 if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
899 swigCMemOwn = false;
900 $imcall;
901 }
902 swigCPtr = new HandleRef(null, IntPtr.Zero);
903 GC.SuppressFinalize(this);
904 base.Dispose();
905 }
906 }
907
908%typemap(directordisconnect, methodname="swigDirectorDisconnect") SWIGTYPE %{
909 protected void $methodname() {
910 swigCMemOwn = false;
911 $imcall;
912 }
913%}
914
915/* C# specific directives */
916#define %csconst(flag) %feature("cs:const","flag")
917#define %csconstvalue(value) %feature("cs:constvalue",value)
918#define %csenum(wrapapproach) %feature("cs:enum","wrapapproach")
919#define %csmethodmodifiers %feature("cs:methodmodifiers")
920#define %csnothrowexception %feature("except")
921#define %csattributes %feature("cs:attributes")
922
923%pragma(csharp) imclassclassmodifiers="class"
924%pragma(csharp) moduleclassmodifiers="public class"
925
926%pragma(csharp) moduleimports=%{
927using System;
928using System.Runtime.InteropServices;
929%}
930
931%pragma(csharp) imclassimports=%{
932using System;
933using System.Runtime.InteropServices;
934%}
935
936/* Some ANSI C typemaps */
937
938%apply unsigned long { size_t };
939%apply const unsigned long & { const size_t & };
940
941/* csharp keywords */
942%include <csharpkw.swg>
943
944// Default enum handling
945%include <enums.swg>
946
947/*
948// Alternative char * typemaps.
949%pragma(csharp) imclasscode=%{
950 public class SWIGStringMarshal : IDisposable {
951 public readonly HandleRef swigCPtr;
952 public SWIGStringMarshal(string str) {
953 swigCPtr = new HandleRef(this, System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(str));
954 }
955 public virtual void Dispose() {
956 System.Runtime.InteropServices.Marshal.FreeHGlobal(swigCPtr.Handle);
957 GC.SuppressFinalize(this);
958 }
959 }
960%}
961
962%typemap(imtype, out="IntPtr") char *, char[ANY], char[] "HandleRef"
963%typemap(out) char *, char[ANY], char[] %{ $result = $1; %}
964%typemap(csin) char *, char[ANY], char[] "new $imclassname.SWIGStringMarshal($csinput).swigCPtr"
965%typemap(csout, excode=SWIGEXCODE) char *, char[ANY], char[] {
966 string ret = System.Runtime.InteropServices.Marshal.PtrToStringAnsi($imcall);$excode
967 return ret;
968 }
969%typemap(csvarin, excode=SWIGEXCODE2) char *, char[ANY], char[] %{
970 set {
971 $imcall;$excode
972 } %}
973%typemap(csvarout, excode=SWIGEXCODE2) char *, char[ANY], char[] %{
974 get {
975 string ret = System.Runtime.InteropServices.Marshal.PtrToStringAnsi($imcall);$excode
976 return ret;
977 } %}
978*/
979