From: Surendra S. <efu...@us...> - 2006-08-13 13:26:40
|
Update of /cvsroot/swig/SWIG/Lib/cffi In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv16678 Modified Files: cffi.swg Log Message: operator overloading support Index: cffi.swg =================================================================== RCS file: /cvsroot/swig/SWIG/Lib/cffi/cffi.swg,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** cffi.swg 14 Apr 2006 10:43:01 -0000 1.7 --- cffi.swg 13 Aug 2006 13:26:37 -0000 1.8 *************** *** 81,85 **** --- 81,123 ---- enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[ANY], SWIGTYPE & "$result = $1;"; + #ifdef __cplusplus %typemap(out) SWIGTYPE "$result = new $1_type($1);"; + #else + %typemap(out) SWIGTYPE { + $result = ($&1_ltype) malloc(sizeof($1_type)); + memmove($result, &$1, sizeof($1_type)); + } + #endif + + %typecheck(SWIG_TYPECHECK_BOOL) bool { $1 = 1; }; + %typecheck(SWIG_TYPECHECK_CHAR) char { $1 = 1; }; + %typecheck(SWIG_TYPECHECK_FLOAT) float { $1 = 1; }; + %typecheck(SWIG_TYPECHECK_DOUBLE) double { $1 = 1; }; + %typecheck(SWIG_TYPECHECK_STRING) char * { $1 = 1; }; + %typecheck(SWIG_TYPECHECK_INTEGER) + unsigned char, signed char, + short, signed short, unsigned short, + int, signed int, unsigned int, + long, signed long, unsigned long, + enum SWIGTYPE { $1 = 1; }; + %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, + SWIGTYPE[ANY], SWIGTYPE { $1 = 1; }; + /* This maps C/C++ types to Lisp classes for overload dispatch */ + + %typemap(lisptype) bool "cl:boolean"; + %typemap(lisptype) char "cl:character"; + %typemap(lisptype) unsigned char "cl:integer"; + %typemap(lisptype) signed char "cl:integer"; + + %typemap(lispclass) bool "t"; + %typemap(lispclass) char "cl:character"; + %typemap(lispclass) unsigned char, signed char, + short, signed short, unsigned short, + int, signed int, unsigned int, + long, signed long, unsigned long, + enum SWIGTYPE "cl:integer"; + %typemap(lispclass) float "cl:single-float"; + %typemap(lispclass) double "cl:double-float"; + %typemap(lispclass) char * "cl:string"; *************** *** 145,146 **** --- 183,276 ---- ;;;SWIG wrapper code ends here %} + + #ifdef __cplusplus + %typemap(out) SWIGTYPE "$result = new $1_type($1);"; + #else + %typemap(out) SWIGTYPE { + $result = ($&1_ltype) malloc(sizeof($1_type)); + memmove($result, &$1, sizeof($1_type)); + } + #endif + + ////////////////////////////////////////////////////////////// + + /* name conversion for overloaded operators. */ + #ifdef __cplusplus + %rename(__add__) *::operator+; + %rename(__pos__) *::operator+(); + %rename(__pos__) *::operator+() const; + + %rename(__sub__) *::operator-; + %rename(__neg__) *::operator-() const; + %rename(__neg__) *::operator-(); + + %rename(__mul__) *::operator*; + %rename(__deref__) *::operator*(); + %rename(__deref__) *::operator*() const; + + %rename(__div__) *::operator/; + %rename(__mod__) *::operator%; + %rename(__logxor__) *::operator^; + %rename(__logand__) *::operator&; + %rename(__logior__) *::operator|; + %rename(__lognot__) *::operator~(); + %rename(__lognot__) *::operator~() const; + + %rename(__not__) *::operator!(); + %rename(__not__) *::operator!() const; + + %rename(__assign__) *::operator=; + + %rename(__add_assign__) *::operator+=; + %rename(__sub_assign__) *::operator-=; + %rename(__mul_assign__) *::operator*=; + %rename(__div_assign__) *::operator/=; + %rename(__mod_assign__) *::operator%=; + %rename(__logxor_assign__) *::operator^=; + %rename(__logand_assign__) *::operator&=; + %rename(__logior_assign__) *::operator|=; + + %rename(__lshift__) *::operator<<; + %rename(__lshift_assign__) *::operator<<=; + %rename(__rshift__) *::operator>>; + %rename(__rshift_assign__) *::operator>>=; + + %rename(__eq__) *::operator==; + %rename(__ne__) *::operator!=; + %rename(__lt__) *::operator<; + %rename(__gt__) *::operator>; + %rename(__lte__) *::operator<=; + %rename(__gte__) *::operator>=; + + %rename(__and__) *::operator&&; + %rename(__or__) *::operator||; + + %rename(__preincr__) *::operator++(); + %rename(__postincr__) *::operator++(int); + %rename(__predecr__) *::operator--(); + %rename(__postdecr__) *::operator--(int); + + %rename(__comma__) *::operator,(); + %rename(__comma__) *::operator,() const; + + %rename(__member_ref__) *::operator->; + %rename(__member_func_ref__) *::operator->*; + + %rename(__funcall__) *::operator(); + %rename(__aref__) *::operator[]; + #endif + + + %{ + + #ifdef __cplusplus + # define EXTERN extern "C" + #else + # define EXTERN extern + #endif + + #define EXPORT EXTERN SWIGEXPORT + + #include <string.h> + #include <stdlib.h> + %} |