1 /* Define a C preprocessor symbol that can be used in interface files 2 to distinguish between the SWIG language modules. */ 3 4 #define SWIG_CFFI 5 6 /* Typespecs for basic types. */ 7 8 %typemap(cin) void ":void"; 9 10 %typemap(cin) char ":char"; 11 %typemap(cin) char * ":string"; 12 %typemap(cin) unsigned char ":unsigned-char"; 13 %typemap(cin) signed char ":char"; 14 15 %typemap(cin) short ":short"; 16 %typemap(cin) signed short ":short"; 17 %typemap(cin) unsigned short ":unsigned-short"; 18 19 %typemap(cin) int ":int"; 20 %typemap(cin) signed int ":int"; 21 %typemap(cin) unsigned int ":unsigned-int"; 22 23 %typemap(cin) long ":long"; 24 %typemap(cin) signed long ":long"; 25 %typemap(cin) unsigned long ":unsigned-long"; 26 27 %typemap(cin) long long ":long-long"; 28 %typemap(cin) signed long long ":long-long"; 29 %typemap(cin) unsigned long long ":unsigned-long-long"; 30 31 %typemap(cin) float ":float"; 32 %typemap(cin) double ":double"; 33 %typemap(cin) SWIGTYPE ":pointer"; 34 35 %typemap(cout) void ":void"; 36 37 %typemap(cout) char ":char"; 38 %typemap(cout) char * ":string"; 39 %typemap(cout) unsigned char ":unsigned-char"; 40 %typemap(cout) signed char ":char"; 41 42 %typemap(cout) short ":short"; 43 %typemap(cout) signed short ":short"; 44 %typemap(cout) unsigned short ":unsigned-short"; 45 46 %typemap(cout) int ":int"; 47 %typemap(cout) signed int ":int"; 48 %typemap(cout) unsigned int ":unsigned-int"; 49 50 %typemap(cout) long ":long"; 51 %typemap(cout) signed long ":long"; 52 %typemap(cout) unsigned long ":unsigned-long"; 53 54 %typemap(cout) long long ":long-long"; 55 %typemap(cout) signed long long ":long-long"; 56 %typemap(cout) unsigned long long ":unsigned-long-long"; 57 58 %typemap(cout) float ":float"; 59 %typemap(cout) double ":double"; 60 %typemap(cout) SWIGTYPE ":pointer"; 61 62 63 %typemap(ctype) bool "int"; 64 %typemap(ctype) char, unsigned char, signed char, 65 short, signed short, unsigned short, 66 int, signed int, unsigned int, 67 long, signed long, unsigned long, 68 float, double, long double, char *, void *, void, 69 enum SWIGTYPE, SWIGTYPE *, 70 SWIGTYPE[ANY], SWIGTYPE & "$1_ltype"; 71 %typemap(ctype) SWIGTYPE "$&1_type"; 72 73 %typemap(in) bool "$1 = (bool)$input;"; 74 %typemap(in) char, unsigned char, signed char, 75 short, signed short, unsigned short, 76 int, signed int, unsigned int, 77 long, signed long, unsigned long, 78 float, double, long double, char *, void *, void, 79 enum SWIGTYPE, SWIGTYPE *, 80 SWIGTYPE[ANY], SWIGTYPE & "$1 = $input;"; 81 %typemap(in) SWIGTYPE "$1 = *$input;"; 82 83 %typemap(out) void ""; 84 %typemap(out) bool "$result = (int)$1;"; 85 %typemap(out) char, unsigned char, signed char, 86 short, signed short, unsigned short, 87 int, signed int, unsigned int, 88 long, signed long, unsigned long, 89 float, double, long double, char *, void *, 90 enum SWIGTYPE, SWIGTYPE *, 91 SWIGTYPE[ANY], SWIGTYPE & "$result = $1;"; 92 #ifdef __cplusplus 93 %typemap(out) SWIGTYPE "$result = new $1_type($1);"; 94 #else 95 %typemap(out) SWIGTYPE { 96 $result = ($&1_ltype) malloc(sizeof($1_type)); 97 memmove($result, &$1, sizeof($1_type)); 98 } 99 #endif 100 101 %typecheck(SWIG_TYPECHECK_BOOL) bool { $1 = 1; }; 102 %typecheck(SWIG_TYPECHECK_CHAR) char { $1 = 1; }; 103 %typecheck(SWIG_TYPECHECK_FLOAT) float { $1 = 1; }; 104 %typecheck(SWIG_TYPECHECK_DOUBLE) double { $1 = 1; }; 105 %typecheck(SWIG_TYPECHECK_STRING) char * { $1 = 1; }; 106 %typecheck(SWIG_TYPECHECK_INTEGER) 107 unsigned char, signed char, 108 short, signed short, unsigned short, 109 int, signed int, unsigned int, 110 long, signed long, unsigned long, 111 enum SWIGTYPE { $1 = 1; }; 112 %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, 113 SWIGTYPE[ANY], SWIGTYPE { $1 = 1; }; 114 /* This maps C/C++ types to Lisp classes for overload dispatch */ 115 116 %typemap(lisptype) bool "cl:boolean"; 117 %typemap(lisptype) char "cl:character"; 118 %typemap(lisptype) unsigned char "cl:integer"; 119 %typemap(lisptype) signed char "cl:integer"; 120 121 %typemap(lispclass) bool "t"; 122 %typemap(lispclass) char "cl:character"; 123 %typemap(lispclass) unsigned char, signed char, 124 short, signed short, unsigned short, 125 int, signed int, unsigned int, 126 long, signed long, unsigned long, 127 enum SWIGTYPE "cl:integer"; 128 /* CLOS methods can't be specialized on single-float or double-float */ 129 %typemap(lispclass) float "cl:number"; 130 %typemap(lispclass) double "cl:number"; 131 %typemap(lispclass) char * "cl:string"; 132 133 /* Array reference typemaps */ 134 %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } 135 136 /* const pointers */ 137 %apply SWIGTYPE * { SWIGTYPE *const } 138 139 %{ 140 141 #ifdef __cplusplus 142 # define EXTERN extern "C" 143 #else 144 # define EXTERN extern 145 #endif 146 147 #define EXPORT EXTERN SWIGEXPORT 148 149 #include <string.h> 150 %} 151 152 %insert("swiglisp") %{ 153 ;;;SWIG wrapper code starts here 154 155 (cl:defmacro defanonenum (cl:&body enums) 156 "Converts anonymous enums to defconstants." 157 `(cl:progn ,@(cl:loop for value in enums 158 for index = 0 then (cl:1+ index) 159 when (cl:listp value) do (cl:setf index (cl:second value) 160 value (cl:first value)) 161 collect `(cl:defconstant ,value ,index)))) 162 163 (cl:eval-when (:compile-toplevel :load-toplevel) 164 (cl:unless (cl:fboundp 'swig-lispify) 165 (cl:defun swig-lispify (name flag cl:&optional (package cl:*package*)) 166 (cl:labels ((helper (lst last rest cl:&aux (c (cl:car lst))) 167 (cl:cond 168 ((cl:null lst) 169 rest) 170 ((cl:upper-case-p c) 171 (helper (cl:cdr lst) 'upper 172 (cl:case last 173 ((lower digit) (cl:list* c #\- rest)) 174 (cl:t (cl:cons c rest))))) 175 ((cl:lower-case-p c) 176 (helper (cl:cdr lst) 'lower (cl:cons (cl:char-upcase c) rest))) 177 ((cl:digit-char-p c) 178 (helper (cl:cdr lst) 'digit 179 (cl:case last 180 ((upper lower) (cl:list* c #\- rest)) 181 (cl:t (cl:cons c rest))))) 182 ((cl:char-equal c #\_) 183 (helper (cl:cdr lst) '_ (cl:cons #\- rest))) 184 (cl:t 185 (cl:error "Invalid character: ~A" c))))) 186 (cl:let ((fix (cl:case flag 187 ((constant enumvalue) "+") 188 (variable "*") 189 (cl:t "")))) 190 (cl:intern 191 (cl:concatenate 192 'cl:string 193 fix 194 (cl:nreverse (helper (cl:concatenate 'cl:list name) cl:nil cl:nil)) 195 fix) 196 package)))))) 197 198 ;;;SWIG wrapper code ends here 199 %} 200 201 #ifdef __cplusplus 202 %typemap(out) SWIGTYPE "$result = new $1_type($1);"; 203 #else 204 %typemap(out) SWIGTYPE { 205 $result = ($&1_ltype) malloc(sizeof($1_type)); 206 memmove($result, &$1, sizeof($1_type)); 207 } 208 #endif 209 210 ////////////////////////////////////////////////////////////// 211 212 /* name conversion for overloaded operators. */ 213 #ifdef __cplusplus 214 %rename(__add__) *::operator+; 215 %rename(__pos__) *::operator+(); 216 %rename(__pos__) *::operator+() const; 217 218 %rename(__sub__) *::operator-; 219 %rename(__neg__) *::operator-() const; 220 %rename(__neg__) *::operator-(); 221 222 %rename(__mul__) *::operator*; 223 %rename(__deref__) *::operator*(); 224 %rename(__deref__) *::operator*() const; 225 226 %rename(__div__) *::operator/; 227 %rename(__mod__) *::operator%; 228 %rename(__logxor__) *::operator^; 229 %rename(__logand__) *::operator&; 230 %rename(__logior__) *::operator|; 231 %rename(__lognot__) *::operator~(); 232 %rename(__lognot__) *::operator~() const; 233 234 %rename(__not__) *::operator!(); 235 %rename(__not__) *::operator!() const; 236 237 %rename(__assign__) *::operator=; 238 239 %rename(__add_assign__) *::operator+=; 240 %rename(__sub_assign__) *::operator-=; 241 %rename(__mul_assign__) *::operator*=; 242 %rename(__div_assign__) *::operator/=; 243 %rename(__mod_assign__) *::operator%=; 244 %rename(__logxor_assign__) *::operator^=; 245 %rename(__logand_assign__) *::operator&=; 246 %rename(__logior_assign__) *::operator|=; 247 248 %rename(__lshift__) *::operator<<; 249 %rename(__lshift_assign__) *::operator<<=; 250 %rename(__rshift__) *::operator>>; 251 %rename(__rshift_assign__) *::operator>>=; 252 253 %rename(__eq__) *::operator==; 254 %rename(__ne__) *::operator!=; 255 %rename(__lt__) *::operator<; 256 %rename(__gt__) *::operator>; 257 %rename(__lte__) *::operator<=; 258 %rename(__gte__) *::operator>=; 259 260 %rename(__and__) *::operator&&; 261 %rename(__or__) *::operator||; 262 263 %rename(__preincr__) *::operator++(); 264 %rename(__postincr__) *::operator++(int); 265 %rename(__predecr__) *::operator--(); 266 %rename(__postdecr__) *::operator--(int); 267 268 %rename(__comma__) *::operator,(); 269 %rename(__comma__) *::operator,() const; 270 271 %rename(__member_ref__) *::operator->; 272 %rename(__member_func_ref__) *::operator->*; 273 274 %rename(__funcall__) *::operator(); 275 %rename(__aref__) *::operator[]; 276 #endif 277 278 279 %{ 280 281 #ifdef __cplusplus 282 # define EXTERN extern "C" 283 #else 284 # define EXTERN extern 285 #endif 286 287 #define EXPORT EXTERN SWIGEXPORT 288 289 #include <string.h> 290 #include <stdlib.h> 291 %} 292