summaryrefslogtreecommitdiff
path: root/share/swig/2.0.11/typemaps/swigtypemaps.swg
blob: 0e39afe4c087543d757aed2058879da5a79a2337 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/* -----------------------------------------------------------------------------
 * swigtypemaps.swg
 *
 * Unified Typemap Library frontend
 * ----------------------------------------------------------------------------- */

/*
  This file provides the frontend to the Unified Typemap Library.

  When using this library in a SWIG target language, you need to
  define a minimum set of fragments, specialize a couple of macros,
  and then include this file.

  Typically you will create a 'mytypemaps.swg' file in each target
  languge, where you will have the following sections:

    === mytypemaps.swg ===

    //  Fragment section 
    %include <typemaps/fragments.swg>
    <include target language fragments>

    // Unified typemap section 
    <specialized the typemap library macros>
    %include <typemaps/swigtypemaps.swg>

    // Local typemap section 
    <add/replace extra target language typemaps>

    === mytypemaps.swg ===

  While we add more docs, please take a look at the following cases
  to see how you specialized the unified typemap library for a new
  target language:

      Lib/python/pytypemaps.swg
      Lib/tcl/tcltypemaps.swg
      Lib/ruby/rubytypemaps.swg
      Lib/perl5/perltypemaps.swg
    
*/

#define SWIGUTL SWIGUTL

/* -----------------------------------------------------------------------------
 *   Language specialization section. 
 *
 *   Tune these macros for each language as needed.
 * ----------------------------------------------------------------------------- */

/*
  The SWIG target language object must be provided.
  For example in python you define:

    #define SWIG_Object PyObject *
*/

#if !defined(SWIG_Object) 
#error "SWIG_Object must be defined as the SWIG target language object"
#endif

/*==== flags for new/convert methods ====*/


#ifndef %convertptr_flags
%define %convertptr_flags  0 %enddef
#endif

#ifndef %newpointer_flags
%define %newpointer_flags  0 %enddef
#endif

#ifndef %newinstance_flags
%define %newinstance_flags 0 %enddef
#endif

/*==== set output ====*/

#ifndef %set_output
/* simple set output operation */
#define %set_output(obj)                  $result = obj
#endif

/*==== set variable output  ====*/

#ifndef %set_varoutput
/* simple set varoutput operation */
#define %set_varoutput(obj)               $result = obj
#endif

/*==== append output ====*/

#ifndef %append_output
#if defined(SWIG_AppendOutput)
/* simple append operation */
#define %append_output(obj)               $result = SWIG_AppendOutput($result,obj) 
#else
#error "Language must define SWIG_AppendOutput or %append_output"
#endif
#endif

/*==== set constant ====*/

#ifndef %set_constant
#if defined(SWIG_SetConstant)
/* simple set constant operation */
#define %set_constant(name,value)         SWIG_SetConstant(name,value)
#else
#error "Language must define SWIG_SetConstant or %set_constant"
#endif
#endif

/*==== raise an exception ====*/

#ifndef %raise
#if defined(SWIG_Raise)
/* simple raise operation */
#define %raise(obj, type, desc)           SWIG_Raise(obj, type, desc); SWIG_fail
#else
#error "Language must define SWIG_Raise or %raise"
#endif
#endif

/*==== director output exception ====*/

#if defined(SWIG_DIRECTOR_TYPEMAPS)
#ifndef SWIG_DirOutFail
#define SWIG_DirOutFail(code, msg)        Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(code), msg)
#endif
#endif


/* -----------------------------------------------------------------------------
 *  Language independent definitions
 * ----------------------------------------------------------------------------- */

#define %error_block(Block...)                 %block(Block)
#define %default_code(code)                    SWIG_ArgError(code)  
#define %argument_fail(code, type, name, argn) SWIG_exception_fail(%default_code(code), %argfail_fmt(type, name, argn))
#define %argument_nullref(type, name, argn)    SWIG_exception_fail(SWIG_ValueError, %argnullref_fmt(type, name, argn))
#define %variable_fail(code, type, name)       SWIG_exception_fail(%default_code(code), %varfail_fmt(type, name))
#define %variable_nullref(type, name)          SWIG_exception_fail(SWIG_ValueError, %varnullref_fmt(type, name))

#if defined(SWIG_DIRECTOR_TYPEMAPS)
#define %dirout_fail(code, type)          SWIG_DirOutFail(%default_code(code), %outfail_fmt(type))
#define %dirout_nullref(type)             SWIG_DirOutFail(SWIG_ValueError, %outnullref_fmt(type))
#endif

/* -----------------------------------------------------------------------------
 *  All the typemaps
 * ----------------------------------------------------------------------------- */


%include <typemaps/fragments.swg>
%include <typemaps/exception.swg>
%include <typemaps/swigtype.swg>
%include <typemaps/void.swg>
%include <typemaps/swigobject.swg>
%include <typemaps/valtypes.swg>
%include <typemaps/ptrtypes.swg>
%include <typemaps/inoutlist.swg>
%include <typemaps/primtypes.swg>
%include <typemaps/string.swg>
%include <typemaps/misctypes.swg>
%include <typemaps/enumint.swg>