diff options
Diffstat (limited to 'devtools/swigwin-1.3.34')
514 files changed, 66168 insertions, 0 deletions
diff --git a/devtools/swigwin-1.3.34/Lib/allegrocl/allegrocl.swg b/devtools/swigwin-1.3.34/Lib/allegrocl/allegrocl.swg new file mode 100644 index 0000000..f656fae --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/allegrocl/allegrocl.swg @@ -0,0 +1,543 @@ +/* Define a C preprocessor symbol that can be used in interface files + to distinguish between the SWIG language modules. */ + +#define SWIG_ALLEGRO_CL + +#define %ffargs(...) %feature("ffargs", "1", ##__VA_ARGS__) +%ffargs(strings_convert="t"); + +/* typemaps for argument and result type conversions. */ +%typemap(lin,numinputs=1) SWIGTYPE "(cl::let (($out $in))\n $body)"; + +%typemap(lout) bool, char, unsigned char, signed char, + short, signed short, unsigned short, + int, signed int, unsigned int, + long, signed long, unsigned long, + float, double, long double, char *, void *, + enum SWIGTYPE "(cl::setq ACL_ffresult $body)"; +%typemap(lout) void "$body"; +%typemap(lout) SWIGTYPE[ANY], SWIGTYPE *, + SWIGTYPE & +%{ (cl:let* ((address $body) + (new-inst (cl:make-instance '$lclass :foreign-address address))) + (cl:when (cl:and $owner (cl:not (cl:zerop address))) + (excl:schedule-finalization new-inst #'$ldestructor)) + (cl:setq ACL_ffresult new-inst)) %} + +%typemap(lout) SWIGTYPE "(cl::let* ((address $body)\n (new-inst (cl::make-instance '$lclass :foreign-address address)))\n (cl::unless (cl::zerop address)\n (excl:schedule-finalization new-inst #'$ldestructor))\n (cl::setq ACL_ffresult new-inst))"; + +%typemap(lisptype) bool "cl:boolean"; +%typemap(lisptype) char "cl:character"; +%typemap(lisptype) unsigned char "cl:integer"; +%typemap(lisptype) signed char "cl:integer"; + +%typemap(ffitype) bool ":int"; +%typemap(ffitype) char ":char"; +%typemap(ffitype) unsigned char ":unsigned-char"; +%typemap(ffitype) signed char ":char"; +%typemap(ffitype) short, signed short ":short"; +%typemap(ffitype) unsigned short ":unsigned-short"; +%typemap(ffitype) int, signed int ":int"; +%typemap(ffitype) unsigned int ":unsigned-int"; +%typemap(ffitype) long, signed long ":long"; +%typemap(ffitype) unsigned long ":unsigned-long"; +%typemap(ffitype) float ":float"; +%typemap(ffitype) double ":double"; +%typemap(ffitype) char * "(* :char)"; +%typemap(ffitype) void * "(* :void)"; +%typemap(ffitype) void ":void"; +%typemap(ffitype) enum SWIGTYPE ":int"; +%typemap(ffitype) SWIGTYPE & "(* :void)"; + +%typemap(ctype) bool "int"; +%typemap(ctype) char, unsigned char, signed char, + short, signed short, unsigned short, + int, signed int, unsigned int, + long, signed long, unsigned long, + float, double, long double, char *, void *, void, + enum SWIGTYPE, SWIGTYPE *, + SWIGTYPE[ANY], SWIGTYPE & "$1_ltype"; +%typemap(ctype) SWIGTYPE "$&1_type"; + +%typemap(in) bool "$1 = (bool)$input;"; +%typemap(in) char, unsigned char, signed char, + short, signed short, unsigned short, + int, signed int, unsigned int, + long, signed long, unsigned long, + float, double, long double, char *, void *, void, + enum SWIGTYPE, SWIGTYPE *, + SWIGTYPE[ANY], SWIGTYPE & "$1 = $input;"; +%typemap(in) SWIGTYPE "$1 = *$input;"; + +/* We don't need to do any actual C-side typechecking, but need to + use the precedence values to choose which overloaded function + interfaces to generate when conflicts arise. */ + +/* predefined precedence values + +Symbolic Name Precedence Value +------------------------------ ------------------ +SWIG_TYPECHECK_POINTER 0 +SWIG_TYPECHECK_VOIDPTR 10 +SWIG_TYPECHECK_BOOL 15 +SWIG_TYPECHECK_UINT8 20 +SWIG_TYPECHECK_INT8 25 +SWIG_TYPECHECK_UINT16 30 +SWIG_TYPECHECK_INT16 35 +SWIG_TYPECHECK_UINT32 40 +SWIG_TYPECHECK_INT32 45 +SWIG_TYPECHECK_UINT64 50 +SWIG_TYPECHECK_INT64 55 +SWIG_TYPECHECK_UINT128 60 +SWIG_TYPECHECK_INT128 65 +SWIG_TYPECHECK_INTEGER 70 +SWIG_TYPECHECK_FLOAT 80 +SWIG_TYPECHECK_DOUBLE 90 +SWIG_TYPECHECK_COMPLEX 100 +SWIG_TYPECHECK_UNICHAR 110 +SWIG_TYPECHECK_UNISTRING 120 +SWIG_TYPECHECK_CHAR 130 +SWIG_TYPECHECK_STRING 140 +SWIG_TYPECHECK_BOOL_ARRAY 1015 +SWIG_TYPECHECK_INT8_ARRAY 1025 +SWIG_TYPECHECK_INT16_ARRAY 1035 +SWIG_TYPECHECK_INT32_ARRAY 1045 +SWIG_TYPECHECK_INT64_ARRAY 1055 +SWIG_TYPECHECK_INT128_ARRAY 1065 +SWIG_TYPECHECK_FLOAT_ARRAY 1080 +SWIG_TYPECHECK_DOUBLE_ARRAY 1090 +SWIG_TYPECHECK_CHAR_ARRAY 1130 +SWIG_TYPECHECK_STRING_ARRAY 1140 +*/ + +%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(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"; + +%typemap(out) bool "$result = (int)$1;"; +%typemap(out) char, unsigned char, signed char, + short, signed short, unsigned short, + int, signed int, unsigned int, + long, signed long, unsigned long, + float, double, long double, char *, void *, void, + 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 + +////////////////////////////////////////////////////////////// +// UCS-2 string conversion + +// should this be SWIG_TYPECHECK_CHAR? +%typecheck(SWIG_TYPECHECK_UNICHAR) wchar_t { $1 = 1; }; + +%typemap(in) wchar_t "$1 = $input;"; +%typemap(lin,numinputs=1) wchar_t "(cl::let (($out (cl:char-code $in)))\n $body)"; +%typemap(lin,numinputs=1) wchar_t* "(excl:with-native-string ($out $in +:external-format #+little-endian :fat-le #-little-endian :fat)\n +$body)" + +%typemap(out) wchar_t "$result = $1;"; +%typemap(lout) wchar_t "(cl::setq ACL_ffresult (cl::code-char $body))"; +%typemap(lout) wchar_t* "(cl::setq ACL_ffresult (excl:native-to-string $body +:external-format #+little-endian :fat-le #-little-endian :fat))"; + +%typemap(ffitype) wchar_t ":unsigned-short"; +%typemap(lisptype) wchar_t ""; +%typemap(ctype) wchar_t "wchar_t"; +%typemap(lispclass) wchar_t "cl:character"; +%typemap(lispclass) wchar_t* "cl:string"; +////////////////////////////////////////////////////////////// + +/* 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 + +%insert("lisphead") %{ +;; $Id: allegrocl.swg 9901 2007-08-16 18:39:50Z mutandiz $ + +(eval-when (compile load eval) + + ;; avoid compiling ef-templates at runtime + (excl:find-external-format :fat) + (excl:find-external-format :fat-le) + +;;; You can define your own identifier converter if you want. +;;; Use the -identifier-converter command line argument to +;;; specify its name. + +(eval-when (:compile-toplevel :load-toplevel :execute) + (cl::defparameter *swig-export-list* nil)) + +(cl::defconstant *void* :..void..) + +;; parsers to aid in finding SWIG definitions in files. +(cl::defun scm-p1 (form) + (let* ((info (cl::second form)) + (id (car info)) + (id-args (if (eq (cl::car form) 'swig-dispatcher) + (cl::cdr info) + (cl::cddr info)))) + (cl::apply *swig-identifier-converter* id + (cl::progn (cl::when (cl::eq (cl::car form) 'swig-dispatcher) + (cl::remf id-args :arities)) + id-args)))) + +(cl::defmacro defswig1 (name (&rest args) &body body) + `(cl::progn (cl::defmacro ,name ,args + ,@body) + (excl::define-simple-parser ,name scm-p1)) ) + +(cl::defmacro defswig2 (name (&rest args) &body body) + `(cl::progn (cl::defmacro ,name ,args + ,@body) + (excl::define-simple-parser ,name second))) + +(defun read-symbol-from-string (string) + (cl::multiple-value-bind (result position) + (cl::read-from-string string nil "eof" :preserve-whitespace t) + (cl::if (cl::and (cl::symbolp result) + (cl::eql position (cl::length string))) + result + (cl::multiple-value-bind (sym) + (cl::intern string) + sym)))) + +(cl::defun full-name (id type arity class) + (cl::case type + (:getter (cl::format nil "~@[~A_~]~A" class id)) + (:constructor (cl::format nil "new_~A~@[~A~]" id arity)) + (:destructor (cl::format nil "delete_~A" id)) + (:type (cl::format nil "ff_~A" id)) + (:slot id) + (:ff-operator (cl::format nil "ffi_~A" id)) + (otherwise (cl::format nil "~@[~A_~]~A~@[~A~]" + class id arity)))) + +(cl::defun identifier-convert-null (id &key type class arity) + (cl::if (cl::eq type :setter) + `(cl::setf ,(identifier-convert-null + id :type :getter :class class :arity arity)) + (read-symbol-from-string (full-name id type arity class)))) + +(cl::defun identifier-convert-lispify (cname &key type class arity) + (cl::assert (cl::stringp cname)) + (cl::when (cl::eq type :setter) + (cl::return-from identifier-convert-lispify + `(cl::setf ,(identifier-convert-lispify + cname :type :getter :class class :arity arity)))) + (cl::setq cname (full-name cname type arity class)) + (cl::if (cl::eq type :constant) + (cl::setf cname (cl::format nil "*~A*" cname))) + (cl::setf cname (excl::replace-regexp cname "_" "-")) + (cl::let ((lastcase :other) + newcase char res) + (cl::dotimes (n (cl::length cname)) + (cl::setf char (cl::schar cname n)) + (excl::if* (cl::alpha-char-p char) + then + (cl::setf newcase (cl::if (cl::upper-case-p char) :upper :lower)) + + (cl::when (cl::or (cl::and (cl::eq lastcase :upper) + (cl::eq newcase :lower)) + (cl::and (cl::eq lastcase :lower) + (cl::eq newcase :upper))) + ;; case change... add a dash + (cl::push #\- res) + (cl::setf newcase :other)) + + (cl::push (cl::char-downcase char) res) + + (cl::setf lastcase newcase) + + else + (cl::push char res) + (cl::setf lastcase :other))) + (read-symbol-from-string (cl::coerce (cl::nreverse res) 'string)))) + +(cl::defun id-convert-and-export (name &rest kwargs) + (cl::multiple-value-bind (symbol package) + (cl::apply *swig-identifier-converter* name kwargs) + (cl::let ((args (cl::list (cl::if (cl::consp symbol) + (cl::cadr symbol) symbol) + (cl::or package cl::*package*)))) + (cl::apply #'cl::export args) + (cl::pushnew args *swig-export-list*)) + symbol)) + +(cl::defmacro swig-insert-id (name namespace &key (type :type) class) + `(cl::let ((cl::*package* (cl::find-package ,(package-name-for-namespace namespace)))) + (id-convert-and-export ,name :type ,type :class ,class))) + +(defswig2 swig-defconstant (string value) + (cl::let ((symbol (id-convert-and-export string :type :constant))) + `(cl::eval-when (compile load eval) + (cl::defconstant ,symbol ,value)))) + +(cl::defun maybe-reorder-args (funcname arglist) + ;; in the foreign setter function the new value will be the last argument + ;; in Lisp it needs to be the first + (cl::if (cl::consp funcname) + (cl::append (cl::last arglist) (cl::butlast arglist)) + arglist)) + +(cl::defun maybe-return-value (funcname arglist) + ;; setf functions should return the new value + (cl::when (cl::consp funcname) + `(,(cl::if (cl::consp (cl::car arglist)) + (cl::caar arglist) + (cl::car arglist))))) + +(cl::defun swig-anyvarargs-p (arglist) + (cl::member :SWIG__varargs_ arglist)) + +(defswig1 swig-defun ((name &optional (mangled-name name) + &key (type :operator) class arity) + arglist kwargs + &body body) + (cl::let* ((symbol (id-convert-and-export name :type type + :arity arity :class class)) + (mangle (excl::if* (cl::string-equal name mangled-name) + then (id-convert-and-export + (cl::cond + ((cl::eq type :setter) (cl::format nil "~A-set" name)) + ((cl::eq type :getter) (cl::format nil "~A-get" name)) + (t name)) + :type :ff-operator :arity arity :class class) + else (cl::intern mangled-name))) + (defun-args (maybe-reorder-args + symbol + (cl::mapcar #'cl::car (cl::and (cl::not (cl::equal arglist '(:void))) + (cl::loop as i in arglist + when (cl::eq (cl::car i) :p+) + collect (cl::cdr i)))))) + (ffargs (cl::if (cl::equal arglist '(:void)) + arglist + (cl::mapcar #'cl::cdr arglist))) + ) + (cl::when (swig-anyvarargs-p ffargs) + (cl::setq ffargs '())) + `(cl::eval-when (compile load eval) + (excl::compiler-let ((*record-xref-info* nil)) + (ff:def-foreign-call (,mangle ,mangled-name) ,ffargs ,@kwargs)) + (cl::macrolet ((swig-ff-call (&rest args) + (cl::cons ',mangle args))) + (cl::defun ,symbol ,defun-args + ,@body + ,@(maybe-return-value symbol defun-args)))))) + +(defswig1 swig-defmethod ((name &optional (mangled-name name) + &key (type :operator) class arity) + ffargs kwargs + &body body) + (cl::let* ((symbol (id-convert-and-export name :type type + :arity arity :class class)) + (mangle (cl::intern mangled-name)) + (defmethod-args (maybe-reorder-args + symbol + (cl::unless (cl::equal ffargs '(:void)) + (cl::loop for (lisparg name dispatch) in ffargs + when (eq lisparg :p+) + collect `(,name ,dispatch))))) + (ffargs (cl::if (cl::equal ffargs '(:void)) + ffargs + (cl::loop for (nil name nil . ffi) in ffargs + collect `(,name ,@ffi))))) + `(cl::eval-when (compile load eval) + (excl::compiler-let ((*record-xref-info* nil)) + (ff:def-foreign-call (,mangle ,mangled-name) ,ffargs ,@kwargs)) + (cl::macrolet ((swig-ff-call (&rest args) + (cl::cons ',mangle args))) + (cl::defmethod ,symbol ,defmethod-args + ,@body + ,@(maybe-return-value symbol defmethod-args)))))) + +(defswig1 swig-dispatcher ((name &key (type :operator) class arities)) + (cl::let ((symbol (id-convert-and-export name + :type type :class class))) + `(cl::eval-when (compile load eval) + (cl::defun ,symbol (&rest args) + (cl::case (cl::length args) + ,@(cl::loop for arity in arities + for symbol-n = (id-convert-and-export name + :type type :class class :arity arity) + collect `(,arity (cl::apply #',symbol-n args))) + (t (cl::error "No applicable wrapper-methods for foreign call ~a with args ~a of classes ~a" ',symbol args (cl::mapcar #'(cl::lambda (x) (cl::class-name (cl::class-of x))) args))) + ))))) + +(defswig2 swig-def-foreign-stub (name) + (cl::let ((lsymbol (id-convert-and-export name :type :class)) + (symbol (id-convert-and-export name :type :type))) + `(cl::eval-when (compile load eval) + (ff:def-foreign-type ,symbol (:class )) + (cl::defclass ,lsymbol (ff:foreign-pointer) ())))) + +(defswig2 swig-def-foreign-class (name supers &rest rest) + (cl::let ((lsymbol (id-convert-and-export name :type :class)) + (symbol (id-convert-and-export name :type :type))) + `(cl::eval-when (compile load eval) + (ff:def-foreign-type ,symbol ,@rest) + (cl::defclass ,lsymbol ,supers + ((foreign-type :initform ',symbol :initarg :foreign-type + :accessor foreign-pointer-type)))))) + +(defswig2 swig-def-foreign-type (name &rest rest) + (cl::let ((symbol (id-convert-and-export name :type :type))) + `(cl::eval-when (compile load eval) + (ff:def-foreign-type ,symbol ,@rest)))) + +(defswig2 swig-def-synonym-type (synonym of ff-synonym) + `(cl::eval-when (compile load eval) + (cl::setf (cl::find-class ',synonym) (cl::find-class ',of)) + (ff:def-foreign-type ,ff-synonym (:struct )))) + +(cl::defun package-name-for-namespace (namespace) + (excl::list-to-delimited-string + (cl::cons *swig-module-name* + (cl::mapcar #'(cl::lambda (name) + (cl::string + (cl::funcall *swig-identifier-converter* + name + :type :namespace))) + namespace)) + ".")) + +(cl::defmacro swig-defpackage (namespace) + (cl::let* ((parent-namespaces (cl::maplist #'cl::reverse (cl::cdr (cl::reverse namespace)))) + (parent-strings (cl::mapcar #'package-name-for-namespace + parent-namespaces)) + (string (package-name-for-namespace namespace))) + `(cl::eval-when (compile load eval) + (cl::defpackage ,string + (:use :swig :ff #+ignore '(:common-lisp :ff :excl) + ,@parent-strings ,*swig-module-name*) + (:import-from :cl :* :nil :t))))) + +(cl::defmacro swig-in-package (namespace) + `(cl::eval-when (compile load eval) + (cl::in-package ,(package-name-for-namespace namespace)))) + +(defswig2 swig-defvar (name mangled-name &key type (ftype :unsigned-natural)) + (cl::let ((symbol (id-convert-and-export name :type type))) + `(cl::eval-when (compile load eval) + (ff:def-foreign-variable (,symbol ,mangled-name) :type ,ftype)))) + +) ;; eval-when + +(cl::eval-when (compile eval) + (cl::flet ((starts-with-p (str prefix) + (cl::and (cl::>= (cl::length str) (cl::length prefix)) + (cl::string= str prefix :end1 (cl::length prefix))))) + (cl::export (cl::loop for sym being each present-symbol of cl::*package* + when (cl::or (starts-with-p (cl::symbol-name sym) (cl::symbol-name :swig-)) + (starts-with-p (cl::symbol-name sym) (cl::symbol-name :identifier-convert-))) + collect sym)))) + +%} + + + +%{ + +#ifdef __cplusplus +# define EXTERN extern "C" +#else +# define EXTERN extern +#endif + +#define EXPORT EXTERN SWIGEXPORT + +#include <string.h> +#include <stdlib.h> +%} diff --git a/devtools/swigwin-1.3.34/Lib/allegrocl/inout_typemaps.i b/devtools/swigwin-1.3.34/Lib/allegrocl/inout_typemaps.i new file mode 100644 index 0000000..d8d61fe --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/allegrocl/inout_typemaps.i @@ -0,0 +1,111 @@ +/* inout_typemaps.i + + Support for INPUT, OUTPUT, and INOUT typemaps. OUTPUT variables are returned + as multiple values. + +*/ + + +/* Note that this macro automatically adds a pointer to the type passed in. + As a result, INOUT typemaps for char are for 'char *'. The definition + of typemaps for 'char' takes advantage of this, believing that it's more + likely to see an INOUT argument for strings, than a single char. */ +%define INOUT_TYPEMAP(type_, OUTresult_, INbind_) +// OUTPUT map. +%typemap(lin,numinputs=0) type_ *OUTPUT, type_ &OUTPUT +%{(cl::let (($out (ff:allocate-fobject '$*in_fftype :c))) + $body + OUTresult_ + (ff:free-fobject $out)) %} + +// INPUT map. +%typemap(in) type_ *INPUT, type_ &INPUT +%{ $1 = &$input; %} + +%typemap(ctype) type_ *INPUT, type_ &INPUT "$*1_ltype"; + + +// INOUT map. +// careful here. the input string is converted to a C string +// with length equal to the input string. This should be large +// enough to contain whatever OUTPUT value will be stored in it. +%typemap(lin,numinputs=1) type_ *INOUT, type_ &INOUT +%{(cl::let (($out (ff:allocate-fobject '$*in_fftype :c))) + INbind_ + $body + OUTresult_ + (ff:free-fobject $out)) %} + +%enddef + +// $in, $out, $lclass, +// $in_fftype, $*in_fftype + +INOUT_TYPEMAP(int, + (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), + (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); +INOUT_TYPEMAP(short, + (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), + (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); +INOUT_TYPEMAP(long, + (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), + (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); +INOUT_TYPEMAP(unsigned int, + (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), + (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); +INOUT_TYPEMAP(unsigned short, + (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), + (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); +INOUT_TYPEMAP(unsigned long, + (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), + (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); +// char * mapping for passing strings. didn't quite work +// INOUT_TYPEMAP(char, +// (cl::push (excl:native-to-string $out) ACL_result), +// (cl::setf (ff:fslot-value-typed (cl::quote $in_fftype) :c $out) +// (excl:string-to-native $in))) +INOUT_TYPEMAP(float, + (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), + (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); +INOUT_TYPEMAP(double, + (cl::push (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) ACL_result), + (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); +INOUT_TYPEMAP(bool, + (cl::push (not (zerop (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out))) + ACL_result), + (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) (if $in 1 0))); + +%typemap(lisptype) bool *INPUT, bool &INPUT "boolean"; + +// long long support not yet complete +// INOUT_TYPEMAP(long long); +// INOUT_TYPEMAP(unsigned long long); + +// char *OUTPUT map. +// for this to work, swig needs to know how large an array to allocate. +// you can fake this by +// %typemap(ffitype) char *myarg "(:array :char 30)"; +// %apply char *OUTPUT { char *myarg }; +%typemap(lin,numinputs=0) char *OUTPUT, char &OUTPUT +%{(cl::let (($out (ff:allocate-fobject '$*in_fftype :c))) + $body + (cl::push (excl:native-to-string $out) ACL_result) + (ff:free-fobject $out)) %} + +// char *INPUT map. +%typemap(in) char *INPUT, char &INPUT +%{ $1 = &$input; %} +%typemap(ctype) char *INPUT, char &INPUT "$*1_ltype"; + +// char *INOUT map. +%typemap(lin,numinputs=1) char *INOUT, char &INOUT +%{(cl::let (($out (excl:string-to-native $in))) + $body + (cl::push (excl:native-to-string $out) ACL_result) + (ff:free-fobject $out)) %} + +// uncomment this if you want INOUT mappings for chars instead of strings. +// INOUT_TYPEMAP(char, +// (cl::push (code-char (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out)) +// ACL_result), +// (cl::setf (ff:fslot-value-typed (cl::quote $*in_fftype) :c $out) $in)); diff --git a/devtools/swigwin-1.3.34/Lib/allegrocl/longlongs.i b/devtools/swigwin-1.3.34/Lib/allegrocl/longlongs.i new file mode 100644 index 0000000..b887a8a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/allegrocl/longlongs.i @@ -0,0 +1,36 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * longlongs.i + * + * Typemap addition for support of 'long long' type and 'unsigned long long + * Makes use of swig-def-foreign-class, so this header should be loaded + * after allegrocl.swg and after any custom user identifier-conversion + * functions have been defined. + * ----------------------------------------------------------------------------- */ + +%typemap(in) long long, unsigned long long "$1 = $input;"; +%typemap(out) long long, unsigned long long "$result = &$1;"; + +%typemap(ffitype) long long "(:struct (l1 :long) (l2 :long))"; +%typemap(ffitype) unsigned long long "(:struct (l1 :unsigned-long) + (l2 :unsigned-long))"; + +%typemap(lout) long long +" (make-instance #.(swig-insert-id \"longlong\" () :type :class) + :foreign-address $body)"; +%typemap(lout) unsigned long long +" (make-instance #.(swig-insert-id \"ulonglong\" () :type :class) + :foreign-address $body)"; + +%insert("lisphead") %{ + +(swig-def-foreign-class "longlong" + (ff:foreign-pointer) + (:struct (:struct (l1 :long) (l2 :long)))) + +(swig-def-foreign-class "ulonglong" + (ff:foreign-pointer) + (:struct (:struct (l1 :unsigned-long) (l2 :unsigned-long)))) +%} diff --git a/devtools/swigwin-1.3.34/Lib/allegrocl/std_list.i b/devtools/swigwin-1.3.34/Lib/allegrocl/std_list.i new file mode 100644 index 0000000..c8ab456 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/allegrocl/std_list.i @@ -0,0 +1,233 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_list.i + * + * SWIG typemaps for std::list types + * + * To use, add: + * + * %include "std_list.i" + * + * to your interface file. You will also need to include a template directive + * for each instance of the list container you want to use in your application. + * e.g. + * + * %template (intlist) std::list<int>; + * %template (floatlist) std::list<float>; + * ----------------------------------------------------------------------------- */ + +%module std_list +%warnfilter(468) std::list; + +%{ +#include <list> +#include <stdexcept> +%} + + +namespace std{ + template<class T> class list + { + public: + + typedef T &reference; + typedef const T& const_reference; + typedef T &iterator; + typedef const T& const_iterator; + + list(); + list(unsigned int size, const T& value = T()); + list(const list<T> &); + + ~list(); + void assign(unsigned int n, const T& value); + void swap(list<T> &x); + + const_reference front(); + const_reference back(); + const_iterator begin(); + const_iterator end(); + + void resize(unsigned int n, T c = T()); + bool empty() const; + + void push_front(const T& INPUT); + void push_back(const T& INPUT); + + + void pop_front(); + void pop_back(); + void clear(); + unsigned int size() const; + unsigned int max_size() const; + void resize(unsigned int n, const T& INPUT); + + void remove(const T& INPUT); + void unique(); + void reverse(); + void sort(); + + %extend + { + %typemap(lout) T &__getitem__ "(cl::setq ACL_ffresult (ff:fslot-value-typed '$*out_fftype :c $body))"; + %typemap(lout) T *__getitem__ "(cl::setq ACL_ffresult (make-instance '$lclass :foreign-address $body))"; + + const_reference __getitem__(int i) throw (std::out_of_range) + { + std::list<T>::iterator first = self->begin(); + int size = int(self->size()); + if (i<0) i += size; + if (i>=0 && i<size) + { + for (int k=0;k<i;k++) + { + first++; + } + return *first; + } + else throw std::out_of_range("list index out of range"); + } + void __setitem__(int i, const T& INPUT) throw (std::out_of_range) + { + std::list<T>::iterator first = self->begin(); + int size = int(self->size()); + if (i<0) i += size; + if (i>=0 && i<size) + { + for (int k=0;k<i;k++) + { + first++; + } + *first = INPUT; + } + else throw std::out_of_range("list index out of range"); + } + void __delitem__(int i) throw (std::out_of_range) + { + std::list<T>::iterator first = self->begin(); + int size = int(self->size()); + if (i<0) i += size; + if (i>=0 && i<size) + { + for (int k=0;k<i;k++) + { + first++; + } + self->erase(first); + } + else throw std::out_of_range("list index out of range"); + } + std::list<T> __getslice__(int i,int j) + { + std::list<T>::iterator first = self->begin(); + std::list<T>::iterator end = self->end(); + + int size = int(self->size()); + if (i<0) i += size; + if (j<0) j += size; + if (i<0) i = 0; + if (j>size) j = size; + if (i>=j) i=j; + if (i>=0 && i<size && j>=0) + { + for (int k=0;k<i;k++) + { + first++; + } + for (int m=0;m<j;m++) + { + end++; + } + std::list<T> tmp(j-i); + if (j>i) std::copy(first,end,tmp.begin()); + return tmp; + } + else throw std::out_of_range("list index out of range"); + } + void __delslice__(int i,int j) + { + std::list<T>::iterator first = self->begin(); + std::list<T>::iterator end = self->end(); + + int size = int(self->size()); + if (i<0) i += size; + if (j<0) j += size; + if (i<0) i = 0; + if (j>size) j = size; + + for (int k=0;k<i;k++) + { + first++; + } + for (int m=0;m<=j;m++) + { + end++; + } + self->erase(first,end); + } + void __setslice__(int i,int j, const std::list<T>& v) + { + std::list<T>::iterator first = self->begin(); + std::list<T>::iterator end = self->end(); + + int size = int(self->size()); + if (i<0) i += size; + if (j<0) j += size; + if (i<0) i = 0; + if (j>size) j = size; + + for (int k=0;k<i;k++) + { + first++; + } + for (int m=0;m<=j;m++) + { + end++; + } + if (int(v.size()) == j-i) + { + std::copy(v.begin(),v.end(),first); + } + else { + self->erase(first,end); + if (i+1 <= int(self->size())) + { + first = self->begin(); + for (int k=0;k<i;k++) + { + first++; + } + self->insert(first,v.begin(),v.end()); + } + else self->insert(self->end(),v.begin(),v.end()); + } + + } + unsigned int __len__() + { + return self->size(); + } + bool __nonzero__() + { + return !(self->empty()); + } + void append(const T& INPUT) + { + self->push_back(INPUT); + } + void pop() + { + self->pop_back(); + } + + }; + }; +} + + + + + + diff --git a/devtools/swigwin-1.3.34/Lib/allegrocl/std_string.i b/devtools/swigwin-1.3.34/Lib/allegrocl/std_string.i new file mode 100644 index 0000000..4da0148 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/allegrocl/std_string.i @@ -0,0 +1,218 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_string.i + * + * SWIG typemaps for std::string + * ----------------------------------------------------------------------------- */ + +// ------------------------------------------------------------------------ +// std::string is typemapped by value +// This can prevent exporting methods which return a string +// in order for the user to modify it. +// However, I think I'll wait until someone asks for it... +// ------------------------------------------------------------------------ + +// %include <exception.i> +%warnfilter(404) std::string; +%warnfilter(404) std::wstring; + +%{ +#include <string> +// #include <vector> +// using std::vector; + +using std::string; + + +%} + +// %include <std_vector.i> + +// %naturalvar std::string; +// %naturalvar std::wstring; + +namespace std { + typedef unsigned long size_t; + typedef signed long ptrdiff_t; + + template <class charT> class basic_string { + public: + typedef charT *pointer; + typedef charT &reference; + typedef const charT &const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + basic_string(); + basic_string( charT *str ); + size_type size(); + charT operator []( int pos ) const; + charT *c_str() const; + basic_string<charT> &operator = ( const basic_string &ws ); + basic_string<charT> &operator = ( const charT *str ); + basic_string<charT> &append( const basic_string<charT> &other ); + basic_string<charT> &append( const charT *str ); + void push_back( charT c ); + void clear(); + void reserve( size_type t ); + void resize( size_type n, charT c = charT() ); + int compare( const basic_string<charT> &other ) const; + int compare( const charT *str ) const; + basic_string<charT> &insert( size_type pos, + const basic_string<charT> &str ); + size_type find( const basic_string<charT> &other, int pos = 0 ) const; + size_type find( charT c, int pos = 0 ) const; + %extend { + bool operator == ( const basic_string<charT> &other ) const { + return self->compare( other ) == 0; + } + bool operator != ( const basic_string<charT> &other ) const { + return self->compare( other ) != 0; + } + bool operator < ( const basic_string<charT> &other ) const { + return self->compare( other ) == -1; + } + bool operator > ( const basic_string<charT> &other ) const { + return self->compare( other ) == 1; + } + bool operator <= ( const basic_string<charT> &other ) const { + return self->compare( other ) != 1; + } + bool operator >= ( const basic_string<charT> &other ) const { + return self->compare( other ) != -1; + } + + } + }; + + %template(string) basic_string<char>; + %template(wstring) basic_string<wchar_t>; + + %apply char * { string }; + %apply wchar_t * { wstring }; + + typedef basic_string<char> string; + typedef basic_string<wchar_t> wstring; + + // automatically convert constant std::strings to cl:strings + %typemap(ctype) string "char *"; + %typemap(in) string "$1.assign($input);"; + %typemap(out) string "$result = (char *)(&$1)->c_str();"; + %typemap(lisptype) string "cl:string"; + %typemap(lout) string "(cl::setq ACL_ffresult $body)"; + + %typemap(ctype) const string *"char *"; + %typemap(in) const string * "$1.assign($input);"; + %typemap(out) const string * "$result = (char *)($1)->c_str();"; + %typemap(lisptype) const string * "cl:string"; + %typemap(lout) const string * "(cl::setq ACL_ffresult $body)"; + + %typemap(ctype) wstring "wchar_t *"; + %typemap(in) wstring "$1.assign($input);"; + %typemap(out) wstring "$result = (wchar_t *)(&$1)->c_str();"; + %typemap(lisptype) wstring "cl:string"; + %typemap(lout) wstring "(cl::setq ACL_ffresult (excl:native-to-string $body +:external-format #+little-endian :fat-le #-little-endian :fat))"; + + %typemap(ctype) const wstring *"char *"; + %typemap(in) const wstring * "$1.assign($input);"; + %typemap(out) const wstring * "$result = (char *)($1)->c_str();"; + %typemap(lisptype) const wstring * "cl:string"; + %typemap(lout) const wstring * "(cl::setq ACL_ffresult $body)"; + + /* Overloading check */ +// %typemap(in) string { +// if (caml_ptr_check($input)) +// $1.assign((char *)caml_ptr_val($input,0), +// caml_string_len($input)); +// else +// SWIG_exception(SWIG_TypeError, "string expected"); +// } + +// %typemap(in) const string & (std::string temp) { +// if (caml_ptr_check($input)) { +// temp.assign((char *)caml_ptr_val($input,0), +// caml_string_len($input)); +// $1 = &temp; +// } else { +// SWIG_exception(SWIG_TypeError, "string expected"); +// } +// } + +// %typemap(in) string & (std::string temp) { +// if (caml_ptr_check($input)) { +// temp.assign((char *)caml_ptr_val($input,0), +// caml_string_len($input)); +// $1 = &temp; +// } else { +// SWIG_exception(SWIG_TypeError, "string expected"); +// } +// } + +// %typemap(in) string * (std::string *temp) { +// if (caml_ptr_check($input)) { +// temp = new std::string((char *)caml_ptr_val($input,0), +// caml_string_len($input)); +// $1 = temp; +// } else { +// SWIG_exception(SWIG_TypeError, "string expected"); +// } +// } + +// %typemap(free) string * (std::string *temp) { +// delete temp; +// } + +// %typemap(argout) string & { +// caml_list_append(swig_result,caml_val_string_len((*$1).c_str(), +// (*$1).size())); +// } + +// %typemap(directorout) string { +// $result.assign((char *)caml_ptr_val($input,0), +// caml_string_len($input)); +// } + +// %typemap(out) string { +// $result = caml_val_string_len($1.c_str(),$1.size()); +// } + +// %typemap(out) string * { +// $result = caml_val_string_len((*$1).c_str(),(*$1).size()); +// } +} + +// #ifdef ENABLE_CHARPTR_ARRAY +// char **c_charptr_array( const std::vector <string > &str_v ); + +// %{ +// SWIGEXT char **c_charptr_array( const std::vector <string > &str_v ) { +// char **out = new char *[str_v.size() + 1]; +// out[str_v.size()] = 0; +// for( int i = 0; i < str_v.size(); i++ ) { +// out[i] = (char *)str_v[i].c_str(); +// } +// return out; +// } +// %} +// #endif + +// #ifdef ENABLE_STRING_VECTOR +// %template (StringVector) std::vector<string >; + +// %insert(ml) %{ +// (* Some STL convenience items *) + +// let string_array_to_vector sa = +// let nv = _new_StringVector C_void in +// array_to_vector nv (fun x -> C_string x) sa ; nv + +// let c_string_array ar = +// _c_charptr_array (string_array_to_vector ar) +// %} + +// %insert(mli) %{ +// val c_string_array: string array -> c_obj +// %} +// #endif diff --git a/devtools/swigwin-1.3.34/Lib/allegrocl/typemaps.i b/devtools/swigwin-1.3.34/Lib/allegrocl/typemaps.i new file mode 100644 index 0000000..293d1cd --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/allegrocl/typemaps.i @@ -0,0 +1,4 @@ +/* Unused for Allegro CL module */ + +%include "inout_typemaps.i" +%include "longlongs.i" diff --git a/devtools/swigwin-1.3.34/Lib/allkw.swg b/devtools/swigwin-1.3.34/Lib/allkw.swg new file mode 100644 index 0000000..dec6c7c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/allkw.swg @@ -0,0 +1,31 @@ +#ifndef __Lib_allkw_swg__ +#define __Lib_allkw_swg__ + + +/* + Include all the known keyword warnings. Very useful for adding test + files to the test-suite, or check if your own library is ok for all + the swig supported languages. + + Use as + + swig -Wallkw ... + + If you add a new language, remember to create a separete languagekw.swg + file, and add it here. + +*/ + +%include <chicken/chickenkw.swg> +%include <csharp/csharpkw.swg> +%include <java/javakw.swg> +%include <php4/php4kw.swg> +%include <pike/pikekw.swg> +%include <python/pythonkw.swg> +%include <ocaml/ocamlkw.swg> +%include <ruby/rubykw.swg> +%include <tcl/tclkw.swg> +%include <perl5/perlkw.swg> + + +#endif //__Lib_allkw_swg__ diff --git a/devtools/swigwin-1.3.34/Lib/attribute.i b/devtools/swigwin-1.3.34/Lib/attribute.i new file mode 100644 index 0000000..45c3c5b --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/attribute.i @@ -0,0 +1,24 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * attribute.i + * + * SWIG library file for implementing attributes. + * ----------------------------------------------------------------------------- */ + +/* we use a simple exception warning here */ +%{ +#include <stdio.h> +%} +#define %attribute_exception(code,msg) printf("%s\n",msg) + +#ifndef %arg +#define %arg(x) x +#endif + +#ifndef %mangle +#define %mangle(Type...) #@Type +#endif + +%include <typemaps/attribute.swg> diff --git a/devtools/swigwin-1.3.34/Lib/carrays.i b/devtools/swigwin-1.3.34/Lib/carrays.i new file mode 100644 index 0000000..738b457 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/carrays.i @@ -0,0 +1,120 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * carrays.i + * + * SWIG library file containing macros that can be used to manipulate simple + * pointers as arrays. + * ----------------------------------------------------------------------------- */ + +/* ----------------------------------------------------------------------------- + * %array_functions(TYPE,NAME) + * + * Generates functions for creating and accessing elements of a C array + * (as pointers). Creates the following functions: + * + * TYPE *new_NAME(int nelements) + * void delete_NAME(TYPE *); + * TYPE NAME_getitem(TYPE *, int index); + * void NAME_setitem(TYPE *, int index, TYPE value); + * + * ----------------------------------------------------------------------------- */ + +%define %array_functions(TYPE,NAME) +%{ +static TYPE *new_##NAME(int nelements) { %} +#ifdef __cplusplus +%{ return new TYPE[nelements]; %} +#else +%{ return (TYPE *) calloc(nelements,sizeof(TYPE)); %} +#endif +%{} + +static void delete_##NAME(TYPE *ary) { %} +#ifdef __cplusplus +%{ delete [] ary; %} +#else +%{ free(ary); %} +#endif +%{} + +static TYPE NAME##_getitem(TYPE *ary, int index) { + return ary[index]; +} +static void NAME##_setitem(TYPE *ary, int index, TYPE value) { + ary[index] = value; +} +%} + +TYPE *new_##NAME(int nelements); +void delete_##NAME(TYPE *ary); +TYPE NAME##_getitem(TYPE *ary, int index); +void NAME##_setitem(TYPE *ary, int index, TYPE value); + +%enddef + + +/* ----------------------------------------------------------------------------- + * %array_class(TYPE,NAME) + * + * Generates a class wrapper around a C array. The class has the following + * interface: + * + * struct NAME { + * NAME(int nelements); + * ~NAME(); + * TYPE getitem(int index); + * void setitem(int index, TYPE value); + * TYPE * cast(); + * static NAME *frompointer(TYPE *t); + * } + * + * ----------------------------------------------------------------------------- */ + +%define %array_class(TYPE,NAME) +%{ +typedef TYPE NAME; +%} +typedef struct NAME { + /* Put language specific enhancements here */ + +} NAME; + +%extend NAME { + +#ifdef __cplusplus +NAME(int nelements) { + return new TYPE[nelements]; +} +~NAME() { + delete [] self; +} +#else +NAME(int nelements) { + return (TYPE *) calloc(nelements,sizeof(TYPE)); +} +~NAME() { + free(self); +} +#endif + +TYPE getitem(int index) { + return self[index]; +} +void setitem(int index, TYPE value) { + self[index] = value; +} +TYPE * cast() { + return self; +} +static NAME *frompointer(TYPE *t) { + return (NAME *) t; +} + +}; + +%types(NAME = TYPE); + +%enddef + diff --git a/devtools/swigwin-1.3.34/Lib/cdata.i b/devtools/swigwin-1.3.34/Lib/cdata.i new file mode 100644 index 0000000..a9e74ed --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/cdata.i @@ -0,0 +1,82 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * cdata.i + * + * SWIG library file containing macros for manipulating raw C data as strings. + * ----------------------------------------------------------------------------- */ + +%{ +typedef struct SWIGCDATA { + char *data; + int len; +} SWIGCDATA; +%} + +/* ----------------------------------------------------------------------------- + * Typemaps for returning binary data + * ----------------------------------------------------------------------------- */ + +#if SWIGGUILE +%typemap(out) SWIGCDATA { + $result = gh_str2scm($1.data,$1.len); +} +%typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH); +#elif SWIGCHICKEN +%typemap(out) SWIGCDATA { + C_word *string_space = C_alloc(C_SIZEOF_STRING($1.len)); + $result = C_string(&string_space, $1.len, $1.data); +} +%typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH); +#else +%echo "cdata.i module not supported." +#endif + + +/* ----------------------------------------------------------------------------- + * %cdata(TYPE [, NAME]) + * + * Convert raw C data to a binary string. + * ----------------------------------------------------------------------------- */ + +%define %cdata(TYPE,NAME...) + +%insert("header") { +#if #NAME == "" +static SWIGCDATA cdata_##TYPE(TYPE *ptr, int nelements) { +#else +static SWIGCDATA cdata_##NAME(TYPE *ptr, int nelements) { +#endif + SWIGCDATA d; + d.data = (char *) ptr; +#if #TYPE != "void" + d.len = nelements*sizeof(TYPE); +#else + d.len = nelements; +#endif + return d; +} +} + +%typemap(default) int nelements "$1 = 1;" + +#if #NAME == "" +SWIGCDATA cdata_##TYPE(TYPE *ptr, int nelements); +#else +SWIGCDATA cdata_##NAME(TYPE *ptr, int nelements); +#endif +%enddef + +%typemap(default) int nelements; + +%rename(cdata) ::cdata_void(void *ptr, int nelements); + +%cdata(void); + +/* Memory move function */ +void memmove(void *data, const void *indata, int inlen); + + + + diff --git a/devtools/swigwin-1.3.34/Lib/cffi/cffi.swg b/devtools/swigwin-1.3.34/Lib/cffi/cffi.swg new file mode 100644 index 0000000..6f5db28 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/cffi/cffi.swg @@ -0,0 +1,284 @@ +/* Define a C preprocessor symbol that can be used in interface files + to distinguish between the SWIG language modules. */ + +#define SWIG_CFFI + +/* Typespecs for basic types. */ + +%typemap(cin) void ":void"; + +%typemap(cin) char ":char"; +%typemap(cin) char * ":string"; +%typemap(cin) unsigned char ":unsigned-char"; +%typemap(cin) signed char ":char"; + +%typemap(cin) short ":short"; +%typemap(cin) signed short ":short"; +%typemap(cin) unsigned short ":unsigned-short"; + +%typemap(cin) int ":int"; +%typemap(cin) signed int ":int"; +%typemap(cin) unsigned int ":unsigned-int"; + +%typemap(cin) long ":long"; +%typemap(cin) signed long ":long"; +%typemap(cin) unsigned long ":unsigned-long"; + +%typemap(cin) long long ":long-long"; +%typemap(cin) signed long long ":long-long"; +%typemap(cin) unsigned long long ":unsigned-long-long"; + +%typemap(cin) float ":float"; +%typemap(cin) double ":double"; +%typemap(cin) SWIGTYPE ":pointer"; + +%typemap(cout) void ":void"; + +%typemap(cout) char ":char"; +%typemap(cout) char * ":string"; +%typemap(cout) unsigned char ":unsigned-char"; +%typemap(cout) signed char ":char"; + +%typemap(cout) short ":short"; +%typemap(cout) signed short ":short"; +%typemap(cout) unsigned short ":unsigned-short"; + +%typemap(cout) int ":int"; +%typemap(cout) signed int ":int"; +%typemap(cout) unsigned int ":unsigned-int"; + +%typemap(cout) long ":long"; +%typemap(cout) signed long ":long"; +%typemap(cout) unsigned long ":unsigned-long"; + +%typemap(cout) long long ":long-long"; +%typemap(cout) signed long long ":long-long"; +%typemap(cout) unsigned long long ":unsigned-long-long"; + +%typemap(cout) float ":float"; +%typemap(cout) double ":double"; +%typemap(cout) SWIGTYPE ":pointer"; + + +%typemap(ctype) bool "int"; +%typemap(ctype) char, unsigned char, signed char, + short, signed short, unsigned short, + int, signed int, unsigned int, + long, signed long, unsigned long, + float, double, long double, char *, void *, void, + enum SWIGTYPE, SWIGTYPE *, + SWIGTYPE[ANY], SWIGTYPE & "$1_ltype"; +%typemap(ctype) SWIGTYPE "$&1_type"; + +%typemap(in) bool "$1 = (bool)$input;"; +%typemap(in) char, unsigned char, signed char, + short, signed short, unsigned short, + int, signed int, unsigned int, + long, signed long, unsigned long, + float, double, long double, char *, void *, void, + enum SWIGTYPE, SWIGTYPE *, + SWIGTYPE[ANY], SWIGTYPE & "$1 = $input;"; +%typemap(in) SWIGTYPE "$1 = *$input;"; + +%typemap(out) bool "$result = (int)$1;"; +%typemap(out) char, unsigned char, signed char, + short, signed short, unsigned short, + int, signed int, unsigned int, + long, signed long, unsigned long, + float, double, long double, char *, void *, void, + 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"; + + +%{ + +#ifdef __cplusplus +# define EXTERN extern "C" +#else +# define EXTERN extern +#endif + +#define EXPORT EXTERN SWIGEXPORT + +#include <string.h> +%} + +%insert("swiglisp") %{ +;;;SWIG wrapper code starts here + +(cl:defmacro defanonenum (&body enums) + "Converts anonymous enums to defconstants." + `(cl:progn ,@(cl:loop for value in enums + for index = 0 then (cl:1+ index) + when (cl:listp value) do (cl:setf index (cl:second value) + value (cl:first value)) + collect `(cl:defconstant ,value ,index)))) + +(cl:eval-when (:compile-toplevel :load-toplevel) + (cl:unless (cl:fboundp 'swig-lispify) + (cl:defun swig-lispify (name flag cl:&optional (package cl:*package*)) + (cl:labels ((helper (lst last rest cl:&aux (c (cl:car lst))) + (cl:cond + ((cl:null lst) + rest) + ((cl:upper-case-p c) + (helper (cl:cdr lst) 'upper + (cl:case last + ((lower digit) (cl:list* c #\- rest)) + (cl:t (cl:cons c rest))))) + ((cl:lower-case-p c) + (helper (cl:cdr lst) 'lower (cl:cons (cl:char-upcase c) rest))) + ((cl:digit-char-p c) + (helper (cl:cdr lst) 'digit + (cl:case last + ((upper lower) (cl:list* c #\- rest)) + (cl:t (cl:cons c rest))))) + ((cl:char-equal c #\_) + (helper (cl:cdr lst) '_ (cl:cons #\- rest))) + (cl:t + (cl:error "Invalid character: ~A" c))))) + (cl:let ((fix (cl:case flag + ((constant enumvalue) "+") + (variable "*") + (cl:t "")))) + (cl:intern + (cl:concatenate + 'cl:string + fix + (cl:nreverse (helper (cl:concatenate 'cl:list name) cl:nil cl:nil)) + fix) + package)))))) + +;;;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> +%} diff --git a/devtools/swigwin-1.3.34/Lib/chicken/chicken.swg b/devtools/swigwin-1.3.34/Lib/chicken/chicken.swg new file mode 100644 index 0000000..00c657b --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/chicken/chicken.swg @@ -0,0 +1,773 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * chicken.swg + * + * CHICKEN configuration module. + * ----------------------------------------------------------------------------- */ + +/* chicken.h has to appear first. */ + +%insert(runtime) %{ +#include <chicken.h> +%} + +%insert(runtime) "swigrun.swg"; // Common C API type-checking code +%insert(runtime) "chickenrun.swg"; // CHICKEN run-time code + +/* ----------------------------------------------------------------------------- + * standard typemaps + * ----------------------------------------------------------------------------- */ + +/* + CHICKEN: C + ---------- + + fixnum: int, short, unsigned int, unsigned short, unsigned char, + signed char + + char: char + + bool: bool + + flonum: float, double, long, long long, unsigned long, unsigned long + long + */ + +/* --- Primitive types --- */ + +%define SIMPLE_TYPEMAP(type_, from_scheme, to_scheme, checker, convtype, storage_) + +%typemap(in) type_ +%{ if (!checker ($input)) { + swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'type_'"); + } + $1 = ($1_ltype) from_scheme ($input); %} + +/* Const primitive references. Passed by value */ + +%typemap(in) const type_ & ($*1_ltype temp) +%{ if (!checker ($input)) { + swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'type_'"); + } + temp = ($*1_ltype) from_scheme ($input); + $1 = &temp; %} + +/* --- Variable input --- */ +%typemap(varin) type_ +%{ if (!checker ($input)) { + swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Cannot use '$1_ltype' for variable '$name' of type 'type_'"); + } + $1 = ($1_ltype) from_scheme ($input); %} + +#if "storage_" == "0" + +%typemap(out) type_ +%{ + $result = to_scheme (convtype ($1)); +%} + +/* References to primitive types. Return by value */ + +%typemap(out) const type_ & +%{ + $result = to_scheme (convtype (*$1)); +%} + +/* --- Variable output --- */ +%typemap(varout) type_ +%{ + $result = to_scheme (convtype ($varname)); +%} + +%typemap(throws) type_ +%{ + SWIG_Chicken_ThrowException(to_scheme ( convtype ($1))); +%} + +#else + +%typemap(out) type_ +%{ + { + C_word *space = C_alloc(storage_); + $result = to_scheme (&space, convtype ($1)); + } +%} + +/* References to primitive types. Return by value */ + +%typemap(out) const type_ & +%{ + { + C_word *space = C_alloc(storage_); + $result = to_scheme (&space, convtype (*$1)); + } +%} + +/* --- Variable output --- */ +%typemap(varout) type_ +%{ + { + C_word *space = C_alloc(storage_); + $result = to_scheme (&space, convtype ($varname)); + } +%} + +%typemap(throws) type_ +%{ + { + C_word *space = C_alloc(storage_); + SWIG_Chicken_ThrowException(to_scheme (&space, convtype ($1))); + } +%} + +#endif + +/* --- Constants --- */ + +%typemap(constcode) type_ +"static const $1_type $result = $value;" + +%enddef + +SIMPLE_TYPEMAP(int, C_num_to_int, C_fix, C_swig_is_number, (int), 0); +//SIMPLE_TYPEMAP(enum SWIGTYPE, C_unfix, C_fix, C_swig_is_fixnum, (int), 0); +SIMPLE_TYPEMAP(short, C_num_to_int, C_fix, C_swig_is_number, (int), 0); +SIMPLE_TYPEMAP(long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM); +SIMPLE_TYPEMAP(long long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM); +SIMPLE_TYPEMAP(unsigned int, C_num_to_unsigned_int, C_unsigned_int_to_num, C_swig_is_number, (unsigned int), C_SIZEOF_FLONUM); +SIMPLE_TYPEMAP(unsigned short, C_num_to_unsigned_int, C_fix, C_swig_is_number, (unsigned int), 0); +SIMPLE_TYPEMAP(unsigned long, C_num_to_unsigned_long, C_unsigned_long_to_num, C_swig_is_long, (unsigned long), C_SIZEOF_FLONUM); +SIMPLE_TYPEMAP(unsigned long long, C_num_to_unsigned_long, C_unsigned_long_to_num, C_swig_is_long, (unsigned long), C_SIZEOF_FLONUM); +SIMPLE_TYPEMAP(unsigned char, C_character_code, C_make_character, C_swig_is_char, (unsigned int), 0); +SIMPLE_TYPEMAP(signed char, C_character_code, C_make_character, C_swig_is_char, (int), 0); +SIMPLE_TYPEMAP(char, C_character_code, C_make_character, C_swig_is_char, (char), 0); +SIMPLE_TYPEMAP(bool, C_truep, C_mk_bool, C_swig_is_bool, (bool), 0); +SIMPLE_TYPEMAP(float, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEOF_FLONUM); +SIMPLE_TYPEMAP(double, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEOF_FLONUM); + +/* enum SWIGTYPE */ +%apply int { enum SWIGTYPE }; +%apply const int& { const enum SWIGTYPE& }; + +%typemap(varin) enum SWIGTYPE +{ + if (!C_swig_is_fixnum($input) && sizeof(int) != sizeof($1)) { + swig_barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, "enum variable '$name' can not be set"); + } + *((int *)(void *)&$1) = C_unfix($input); +} + + +/* --- Input arguments --- */ + +/* Strings */ + +%typemap(in) char * +{ if ($input == C_SCHEME_FALSE) { + $1 = NULL; + } + else { + if (!C_swig_is_string ($input)) { + swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'char *'"); + } + $1 = ($ltype) SWIG_MakeString ($input); + } +} + +%typemap(freearg) char * "if ($1 != NULL) { free ($1); }" + +/* Pointers, references, and arrays */ +%typemap(in,closcode="(slot-ref $input 'swig-this)") SWIGTYPE *, SWIGTYPE [], SWIGTYPE & { + $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, $disown); +} + +%typemap(in,closcode="(slot-ref $input 'swig-this)") SWIGTYPE *DISOWN { + $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, SWIG_POINTER_DISOWN); +} + +/* Void pointer. Accepts any kind of pointer */ +%typemap(in) void * { + $1 = ($1_ltype)SWIG_MustGetPtr($input, NULL, $argnum, 0); +} + +%typemap(varin,closcode="(slot-ref $input 'swig-this)") SWIGTYPE * { + $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, SWIG_POINTER_DISOWN); +} + +%typemap(varin,closcode="(slot-ref $input 'swig-this)") SWIGTYPE & { + $1 = *(($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0)); +} + +%typemap(varin) SWIGTYPE [] { + SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, "Type error"); +} + +%typemap(varin) SWIGTYPE [ANY] { + void *temp; + int ii; + $1_basetype *b = 0; + temp = SWIG_MustGetPtr($input, $1_descriptor, 1, 0); + b = ($1_basetype *) $1; + for (ii = 0; ii < $1_size; ii++) b[ii] = *(($1_basetype *) temp + ii); +} + +%typemap(varin) void * { + $1 = SWIG_MustGetPtr($input, NULL, 1, 0); +} + +%typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] { + C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); + $result = SWIG_NewPointerObj($1, $descriptor, $owner); +} + +%typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { + C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); + swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor,(void **) &$1); + $result = SWIG_NewPointerObj($1, ty, $owner); +} + +%typemap(varout) SWIGTYPE *, SWIGTYPE [] { + C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); + $result = SWIG_NewPointerObj($varname, $descriptor, 0); +} + +%typemap(varout) SWIGTYPE & { + C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); + $result = SWIG_NewPointerObj((void *) &$varname, $1_descriptor, 0); +} + +/* special typemaps for class pointers */ +%typemap(in) SWIGTYPE (CLASS::*) { + char err_msg[256]; + + if (C_swig_is_pair($input)) { + /* try and convert pointer object */ + void *result; + if (!SWIG_ConvertPtr(C_block_item($input,1), &result, $descriptor, 0)) { + C_word ptr = C_block_item($input,0); + if (C_swig_is_string(ptr)) { + SWIG_UnpackData(C_c_string(ptr), (void *) &$1, sizeof($type)); + } else { + snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", $argnum, ($descriptor->str ? $descriptor->str : $descriptor->name)); + SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg); + } + } else { + snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", $argnum, ($descriptor->str ? $descriptor->str : $descriptor->name)); + SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg); + } + } else { + snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", $argnum, ($descriptor->str ? $descriptor->str : $descriptor->name)); + SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg); + } +} + +%typemap(out) SWIGTYPE (CLASS::*) { + size_t ptr_size = sizeof($type); + C_word *known_space = C_alloc(C_SIZEOF_PAIR + C_SIZEOF_STRING(2*ptr_size) + C_SIZEOF_SWIG_POINTER); + char *temp = (char *)malloc(2*ptr_size); + C_word ptr = SWIG_NewPointerObj((void *) known_space, $descriptor, 0); + + SWIG_PackData(temp, (void *) &$1, ptr_size); + $result = C_pair(&known_space, C_string(&known_space, 2*ptr_size, temp), ptr); + free(temp); +} + +%typemap(varin) SWIGTYPE (CLASS::*) { + char err_msg[256]; + + if (C_swig_is_pair($input)) { + /* try and convert pointer object */ + void *result; + if (!SWIG_ConvertPtr(C_block_item($input,1), &result, $descriptor, 0)) { + C_word ptr = C_block_item($input,0); + if (C_swig_is_string(ptr)) { + SWIG_UnpackData(C_c_string(ptr), (void *) &$1, sizeof($type)); + } else { + snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", 1, ($descriptor->str ? $descriptor->str : $descriptor->name)); + SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg); + } + } else { + snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", 1, ($descriptor->str ? $descriptor->str : $descriptor->name)); + SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg); + } + } else { + snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", 1, ($descriptor->str ? $descriptor->str : $descriptor->name)); + SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg); + } +} + +%typemap(varout) SWIGTYPE (CLASS::*) { + size_t ptr_size = sizeof($type); + C_word *known_space = C_alloc(C_SIZEOF_PAIR + C_SIZEOF_STRING(2*ptr_size) + C_SIZEOF_SWIG_POINTER); + char *temp = (char *)malloc(2*ptr_size); + C_word ptr = SWIG_NewPointerObj((void *) known_space, $descriptor, 0); + + SWIG_PackData(temp, (void *) &$varname, ptr_size); + $result = C_pair(&known_space, C_string(&known_space, 2*ptr_size, temp), ptr); + free(temp); +} + + + +/* Pass-by-value */ + +%typemap(in,closcode="(slot-ref $input 'swig-this)") SWIGTYPE($&1_ltype argp) { + argp = ($&1_ltype)SWIG_MustGetPtr($input, $&1_descriptor, $argnum, 0); + $1 = *argp; +} + +%typemap(varin,closcode="(slot-ref $input 'swig-this)") SWIGTYPE { + $&1_ltype argp; + argp = ($&1_ltype)SWIG_MustGetPtr($input, $&1_descriptor, 1, 0); + $1 = *argp; +} + +%typemap(out) SWIGTYPE +#ifdef __cplusplus +{ + $&1_ltype resultptr; + C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); + resultptr = new $1_ltype(($1_ltype &) $1); + $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 1); +} +#else +{ + $&1_ltype resultptr; + C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); + resultptr = ($&1_ltype) malloc(sizeof($1_type)); + memmove(resultptr, &$1, sizeof($1_type)); + $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 1); +} +#endif + +%typemap(varout) SWIGTYPE +#ifdef __cplusplus +{ + $&1_ltype resultptr; + C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); + resultptr = new $1_ltype(($1_ltype&) $1); + $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 0); +} +#else +{ + $&1_ltype resultptr; + C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); + resultptr = ($&1_ltype) malloc(sizeof($1_type)); + memmove(resultptr, &$1, sizeof($1_type)); + $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 0); +} +#endif + +/* --- Output values --- */ + +/* Strings */ + +%typemap(out) + char * +{ char *s = (char*) $1; + if ($1 == NULL) { + $result = C_SCHEME_FALSE; + } + else { + int string_len = strlen ((char *) ($1)); + C_word *string_space = C_alloc (C_SIZEOF_STRING (string_len)); + $result = C_string (&string_space, string_len, s); + } +} + +%typemap(varout) + char * +{ char *s = (char*) $varname; + if ($varname == NULL) { + $result = C_SCHEME_FALSE; + } + else { + int string_len = strlen ($varname); + C_word *string_space = C_alloc (C_SIZEOF_STRING (string_len)); + $result = C_string (&string_space, string_len, s); + } +} + +%typemap(throws) char * +{ + if ($1 == NULL) { + SWIG_Chicken_ThrowException(C_SCHEME_FALSE); + } else { + int string_len = strlen($1); + C_word *string_space = C_alloc(C_SIZEOF_STRING(string_len)); + SWIG_Chicken_ThrowException(C_string(&string_space, string_len, (char *) $1)); + } +} + +/* Void */ +%typemap(out) void +%{ +$result = C_SCHEME_UNDEFINED; +%} + +/* Special typemap for character array return values */ + +%typemap(out) + char [ANY], const char [ANY] +%{ if ($1 == NULL) { + $result = C_SCHEME_FALSE; + } + else { + const int string_len = strlen ($1); + C_word *string_space = C_alloc (C_SIZEOF_STRING (string_len)); + $result = C_string (&string_space, string_len, $1); + } %} + +/* Primitive types--return by value */ + +/* --- Variable input --- */ + +/* A string */ +#ifdef __cplusplus +%typemap(varin) char * { + if ($input == C_SCHEME_FALSE) { + $1 = NULL; + } + else if (!C_swig_is_string ($input)) { + swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'"); + } + else { + char *temp = C_c_string ($input); + int len = C_header_size ($input); + if ($1) delete [] $1; + $1 = ($type) new char[len+1]; + strncpy((char*)$1, temp, len); + ((char*)$1) [len] = 0; + } +} +%typemap(varin,warning="451:Setting const char * variable may leak memory") const char * { + if ($input == C_SCHEME_FALSE) { + $1 = NULL; + } + else if (!C_swig_is_string ($input)) { + swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'"); + } + else { + char *temp = C_c_string ($input); + int len = C_header_size ($input); + $1 = ($type) new char[len+1]; + strncpy((char*)$1,temp,len); + ((char*)$1) [len] = 0; + } +} +#else +%typemap(varin) char * { + if ($input == C_SCHEME_FALSE) { + $1 = NULL; + } + else if (!C_swig_is_string ($input)) { + swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'"); + } + else { + char *temp = C_c_string ($input); + int len = C_header_size ($input); + if ($1) free((char*) $1); + $1 = ($type) malloc(len+1); + strncpy((char*)$1,temp,len); + ((char*)$1) [len] = 0; + } +} +%typemap(varin,warning="451:Setting const char * variable may leak memory") const char * { + if ($input == C_SCHEME_FALSE) { + $1 = NULL; + } + else if (!C_swig_is_string ($input)) { + swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'"); + } + else { + char *temp = C_c_string ($input); + int len = C_header_size ($input); + $1 = ($type) malloc(len+1); + strncpy((char*)$1,temp,len); + ((char*)$1) [len] = 0; + } +} +#endif + +%typemap(varin) char [] { + swig_barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, "C/C++ variable '$name' is read-only"); +} + +/* Special case for string array variables */ +%typemap(varin) char [ANY] { + if ($input == C_SCHEME_FALSE) { + memset($1,0,$1_dim0*sizeof(char)); + } + else if (!C_swig_is_string ($input)) { + swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'"); + } + else { + char *temp = C_c_string ($input); + strncpy($1,temp,$1_dim0*sizeof(char)); + } +} + +/* --- Variable output --- */ + +/* Void */ +%typemap(varout) void "$result = C_SCHEME_UNDEFINED;"; + +/* Special typemap for character array return values */ +%typemap(varout) char [ANY], const char [ANY] +%{ if ($varname == NULL) { + $result = C_SCHEME_FALSE; + } + else { + const int string_len = strlen ($varname); + C_word *string_space = C_alloc (C_SIZEOF_STRING (string_len)); + $result = C_string (&string_space, string_len, (char *) $varname); + } +%} + + +/* --- Constants --- */ + +%typemap(constcode) char * +"static const char *$result = $value;" + +%typemap(constcode) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] +"static const void *$result = (void*) $value;" + +/* ------------------------------------------------------------ + * String & length + * ------------------------------------------------------------ */ + +%typemap(in) (char *STRING, int LENGTH) { + if ($input == C_SCHEME_FALSE) { + swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Cannot use a null/#f string for a char*, int arguments"); + } + else if (C_swig_is_string ($input)) { + $1 = ($1_ltype) C_c_string ($input); + $2 = ($2_ltype) C_header_size ($input); + } + else { + swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'string'"); + } +} + +/* ------------------------------------------------------------ + * CHICKEN types + * ------------------------------------------------------------ */ + +%typemap(in) C_word "$1 = $input;"; +%typemap(out) C_word "$result = $1;"; + +/* ------------------------------------------------------------ + * Typechecking rules + * ------------------------------------------------------------ */ + +%typecheck(SWIG_TYPECHECK_INTEGER) + bool, const bool & +{ + $1 = C_swig_is_bool ($input); +} + +%typecheck(SWIG_TYPECHECK_INTEGER) + int, short, + unsigned int, unsigned short, + signed char, unsigned char, + const int &, const short &, + const unsigned int &, const unsigned short &, + enum SWIGTYPE +{ + $1 = C_swig_is_fixnum ($input); +} + +%typecheck(SWIG_TYPECHECK_INTEGER) + long, + unsigned long, + long long, unsigned long long, + const long &, + const unsigned long &, + const long long &, const unsigned long long & +{ + $1 = (C_swig_is_bool ($input) || + C_swig_is_fixnum ($input) || + C_swig_is_flonum ($input)) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_DOUBLE) + float, double, + const float &, const double & +{ + $1 = C_swig_is_flonum ($input); +} + +%typecheck(SWIG_TYPECHECK_CHAR) char { + $1 = C_swig_is_string ($input); +} + +%typecheck(SWIG_TYPECHECK_STRING) char * { + $1 = C_swig_is_string ($input); +} + +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] { + void *ptr; + $1 = !SWIG_ConvertPtr($input, &ptr, $1_descriptor, 0); +} + +%typecheck(SWIG_TYPECHECK_VOIDPTR) void * { + void *ptr; + $1 = !SWIG_ConvertPtr($input, &ptr, 0, 0); +} + +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE & +{ + void *ptr = 0; + if (SWIG_ConvertPtr($input, &ptr, $descriptor, 0)) { + /* error */ + $1 = 0; + } else { + $1 = (ptr != 0); + } +} + +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE +{ + void *ptr = 0; + if (SWIG_ConvertPtr($input, &ptr, $&descriptor, 0)) { + /* error */ + $1 = 0; + } else { + $1 = (ptr != 0); + } +} + + +/* ------------------------------------------------------------ + * Exception handling + * ------------------------------------------------------------ */ + +/* ------------------------------------------------------------ + * --- Exception handling --- + * ------------------------------------------------------------ */ + +%typemap(throws) SWIGTYPE { + $<ype temp = new $ltype($1); + C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); + C_word ptr = SWIG_NewPointerObj(temp, $&descriptor,1); + SWIG_Chicken_ThrowException(ptr); +} + +%typemap(throws) SWIGTYPE * { + C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); + C_word ptr = SWIG_NewPointerObj((void *) $1, $descriptor, 0); + SWIG_Chicken_ThrowException(ptr); +} + +%typemap(throws) SWIGTYPE [ANY] { + C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); + C_word ptr = SWIG_NewPointerObj((void *) $1, $descriptor, 0); + SWIG_Chicken_ThrowException(ptr); +} + +%typemap(throws) SWIGTYPE & { + C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); + C_word ptr = SWIG_NewPointerObj((void *)&($1),$descriptor,0); + SWIG_Chicken_ThrowException(ptr); +} + +/* ------------------------------------------------------------ + * ANSI C typemaps + * ------------------------------------------------------------ */ + +%apply unsigned long { size_t }; + +/* ------------------------------------------------------------ + * Overloaded operator support + * ------------------------------------------------------------ */ + +#ifdef __cplusplus +%rename(__add__) *::operator+; +%rename(__pos__) *::operator+(); +%rename(__pos__) *::operator+() const; +%rename(__sub__) *::operator-; +%rename(__neg__) *::operator-(); +%rename(__neg__) *::operator-() const; +%rename(__mul__) *::operator*; +%rename(__div__) *::operator/; +%rename(__mod__) *::operator%; +%rename(__lshift__) *::operator<<; +%rename(__rshift__) *::operator>>; +%rename(__and__) *::operator&; +%rename(__or__) *::operator|; +%rename(__xor__) *::operator^; +%rename(__invert__) *::operator~; +%rename(__iadd__) *::operator+=; +%rename(__isub__) *::operator-=; +%rename(__imul__) *::operator*=; +%rename(__idiv__) *::operator/=; +%rename(__imod__) *::operator%=; +%rename(__ilshift__) *::operator<<=; +%rename(__irshift__) *::operator>>=; +%rename(__iand__) *::operator&=; +%rename(__ior__) *::operator|=; +%rename(__ixor__) *::operator^=; +%rename(__lt__) *::operator<; +%rename(__le__) *::operator<=; +%rename(__gt__) *::operator>; +%rename(__ge__) *::operator>=; +%rename(__eq__) *::operator==; +%rename(__ne__) *::operator!=; + +/* Special cases */ +%rename(__call__) *::operator(); + +#endif +/* Warnings for certain CHICKEN keywords */ +%include <chickenkw.swg> + +/* TinyCLOS <--> Low-level CHICKEN */ + +%typemap("clos_in") SIMPLE_CLOS_OBJECT * "(slot-ref $input (quote this))" +%typemap("clos_out") SIMPLE_CLOS_OBJECT * "(make $class (quote this) $1)" + +%insert(header) %{ +#ifdef __cplusplus +extern "C" { +#endif +/* Chicken initialization function */ +SWIGEXPORT void SWIG_init(C_word, C_word, C_word) C_noret; +#ifdef __cplusplus +} +#endif +%} + +%insert(closprefix) "swigclosprefix.scm" + +%insert(init) "swiginit.swg" + +%insert(init) %{ +/* CHICKEN initialization function */ +#ifdef __cplusplus +extern "C" { +#endif +SWIGEXPORT void SWIG_init(C_word argc, C_word closure, C_word continuation) { + int i; + C_word sym; + C_word tmp; + C_word *a; + C_word ret; + C_word *return_vec; + + SWIG_InitializeModule(0); + SWIG_PropagateClientData(); + ret = C_SCHEME_TRUE; + +#if $veclength + return_vec = C_alloc(C_SIZEOF_VECTOR($veclength)); + ret = (C_word) return_vec; + *(return_vec++) = C_VECTOR_TYPE | $veclength; +#endif + + a = C_alloc(2*$nummethods$symsize); + +%} diff --git a/devtools/swigwin-1.3.34/Lib/chicken/chickenkw.swg b/devtools/swigwin-1.3.34/Lib/chicken/chickenkw.swg new file mode 100644 index 0000000..f01faf1 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/chicken/chickenkw.swg @@ -0,0 +1,31 @@ +#ifndef CHICKEN_CHICKENKW_SWG_ +#define CHICKEN_CHICKENKW_SWG_ + +/* Warnings for certain CHICKEN keywords. From Section 7.1.1 of + Revised^5 Report on the Algorithmic Language Scheme */ +#define CHICKENKW(x) %namewarn("314:" #x " is a R^5RS syntatic keyword") #x + +CHICKENKW(else); +CHICKENKW(=>); +CHICKENKW(define); +CHICKENKW(unquote); +CHICKENKW(unquote-splicing); +CHICKENKW(quote); +CHICKENKW(lambda); +CHICKENKW(if); +CHICKENKW(set!); +CHICKENKW(begin); +CHICKENKW(cond); +CHICKENKW(and); +CHICKENKW(or); +CHICKENKW(case); +CHICKENKW(let); +CHICKENKW(let*); +CHICKENKW(letrec); +CHICKENKW(do); +CHICKENKW(delay); +CHICKENKW(quasiquote); + +#undef CHICKENKW + +#endif //CHICKEN_CHICKENKW_SWG_ diff --git a/devtools/swigwin-1.3.34/Lib/chicken/chickenrun.swg b/devtools/swigwin-1.3.34/Lib/chicken/chickenrun.swg new file mode 100644 index 0000000..bd72424 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/chicken/chickenrun.swg @@ -0,0 +1,377 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * chickenrun.swg + * + * ----------------------------------------------------------------------------- */ + +#include <chicken.h> +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +# ifndef snprintf +# define snprintf _snprintf +# endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define SWIG_malloc(size) \ + malloc(size) +#define SWIG_free(mem) \ + free(mem) +#define SWIG_MakeString(c) \ + SWIG_Chicken_MakeString(c) +#define SWIG_ConvertPtr(s, result, type, flags) \ + SWIG_Chicken_ConvertPtr(s, result, type, flags) +#define SWIG_MustGetPtr(s, type, argnum, flags) \ + SWIG_Chicken_MustGetPtr(s, type, argnum, flags) +#define SWIG_NewPointerObj(ptr, type, owner) \ + SWIG_Chicken_NewPointerObj((void*)ptr, type, owner, &known_space) +#define swig_barf SWIG_Chicken_Barf +#define SWIG_ThrowException(val) SWIG_Chicken_ThrowException(val) + +#define SWIG_contract_assert(expr, message) if (!(expr)) { \ + SWIG_Chicken_Barf(SWIG_BARF1_CONTRACT_ASSERT, C_text(message)); } else + +/* Runtime API */ +#define SWIG_GetModule(clientdata) SWIG_Chicken_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Chicken_SetModule(pointer) + +#define C_swig_is_bool(x) C_truep (C_booleanp (x)) +#define C_swig_is_char(x) C_truep (C_charp (x)) +#define C_swig_is_fixnum(x) C_truep (C_fixnump (x)) +#define C_swig_is_flonum(x) (C_truep (C_blockp (x)) && C_truep (C_flonump (x))) +#define C_swig_is_string(x) (C_truep (C_blockp (x)) && C_truep (C_stringp (x))) +#define C_swig_is_vector(x) (C_truep (C_blockp (x)) && C_truep (C_vectorp (x))) +#define C_swig_is_list(x) (C_truep (C_i_listp (x))) +#define C_swig_is_pair(x) (C_truep (C_blockp(x)) && C_truep (C_pairp(x))) +#define C_swig_is_ptr(x) (C_truep (C_blockp (x)) && C_truep (C_pointerp (x))) +#define C_swig_is_swigpointer(x) (C_truep (C_blockp(x)) && C_truep (C_swigpointerp(x))) +#define C_swig_is_closurep(x) (C_truep (C_blockp(x)) && C_truep(C_closurep(x))) +#define C_swig_is_number(x) (C_swig_is_fixnum(x) || C_swig_is_flonum(x)) +#define C_swig_is_long(x) C_swig_is_number(x) + +#define C_swig_sizeof_closure(num) (num+1) + +#define SWIG_Chicken_SetupArgout { \ + C_word *a = C_alloc(C_swig_sizeof_closure(2)); \ + C_word *closure = a; \ + *(a++)=C_CLOSURE_TYPE|2; \ + *(a++)=(C_word)SWIG_Chicken_ApplyResults; \ + *(a++)=continuation; \ + continuation=(C_word)closure; \ +} + +#define SWIG_APPEND_VALUE(obj) { \ + C_word val = (C_word)(obj); \ + if (val != C_SCHEME_UNDEFINED) { \ + C_word *a = C_alloc(C_swig_sizeof_closure(3)); \ + C_word *closure = a; \ + *(a++)=C_CLOSURE_TYPE|3; \ + *(a++)=(C_word)SWIG_Chicken_MultiResultBuild; \ + *(a++)=(C_word)continuation; \ + *(a++)=val; \ + continuation=(C_word)closure; \ + } } + +#define SWIG_Chicken_FindCreateProxy(func,obj) \ + if (C_swig_is_swigpointer(obj)) { \ + swig_type_info *t = (swig_type_info *) C_block_item(obj, 1); \ + if (t && t->clientdata && ((swig_chicken_clientdata *)t->clientdata)->gc_proxy_create) { \ + func = CHICKEN_gc_root_ref( ((swig_chicken_clientdata *)t->clientdata)->gc_proxy_create); \ + } else { \ + func = C_SCHEME_FALSE; \ + } \ + } else { \ + func = C_SCHEME_FALSE; \ + } + + +enum { + SWIG_BARF1_BAD_ARGUMENT_TYPE /* 1 arg */, + SWIG_BARF1_ARGUMENT_NULL /* 1 arg */, + SWIG_BARF1_CONTRACT_ASSERT /* 1 arg */, +}; + +typedef C_word (*swig_chicken_destructor)(C_word,C_word,C_word,C_word); +typedef struct swig_chicken_clientdata { + void *gc_proxy_create; + swig_chicken_destructor destroy; +} swig_chicken_clientdata; + +static char * +SWIG_Chicken_MakeString(C_word str) { + char *ret; + size_t l; + + l = C_header_size(str); + ret = (char *) SWIG_malloc( (l + 1) * sizeof(char)); + if (!ret) return NULL; + + memcpy(ret, C_c_string(str), l); + ret[l] = '\0'; + return ret; +} + +static C_word SWIG_Chicken_LookupSymbol(char *name, C_SYMBOL_TABLE *stable) { + C_word *a = C_alloc(C_SIZEOF_STRING (strlen (name))); + C_word n = C_string2(&a, name); + C_word sym = C_find_symbol(n, stable); + if (C_truep(sym)) { + return C_symbol_value(sym); + } else { + return C_SCHEME_FALSE; + } +} + +/* Just a helper function. Do not export it */ +static void SWIG_Chicken_Panic (C_char *) C_noret; +static void SWIG_Chicken_Panic (C_char *msg) +{ + C_word *a = C_alloc (C_SIZEOF_STRING (strlen (msg))); + C_word scmmsg = C_string2 (&a, msg); + C_halt (scmmsg); + exit (5); /* should never get here */ +} + +static void +SWIG_Chicken_Barf(int code, C_char *msg, ...) C_noret; +static void +SWIG_Chicken_Barf(int code, C_char *msg, ...) +{ + char *errorhook = C_text("\003syserror-hook"); + C_word *a = C_alloc (C_SIZEOF_STRING (strlen (errorhook))); + C_word err = C_intern2 (&a, errorhook); + int c = -1; + int i, barfval; + va_list v; + + + C_temporary_stack = C_temporary_stack_bottom; + err = C_block_item(err, 0); + + if(C_immediatep (err)) + SWIG_Chicken_Panic (C_text ("`##sys#error-hook' is not defined")); + + switch (code) { + case SWIG_BARF1_BAD_ARGUMENT_TYPE: + barfval = C_BAD_ARGUMENT_TYPE_ERROR; + c = 1; + break; + case SWIG_BARF1_ARGUMENT_NULL: + barfval = C_BAD_ARGUMENT_TYPE_ERROR; + c = 1; + break; + case SWIG_BARF1_CONTRACT_ASSERT: + barfval = C_BAD_ARGUMENT_TYPE_ERROR; + c = 1; + break; + default: + SWIG_Chicken_Panic (C_text (msg)); + }; + + if(c > 0 && !C_immediatep (err)) { + C_save (C_fix (barfval)); + + i = c; + if (i) { + C_word *b = C_alloc (C_SIZEOF_STRING (strlen (msg))); + C_word scmmsg = C_string2 (&b, msg); + C_save (scmmsg); + i--; + } + + va_start (v, msg); + + while(i--) + C_save (va_arg (v, C_word)); + + va_end (v); + C_do_apply (c + 1, err, + C_SCHEME_UNDEFINED); /* <- no continuation is passed: + '##sys#error-hook' may not + return! */ + } + else if (msg) { + SWIG_Chicken_Panic (msg); + } + else { + SWIG_Chicken_Panic (C_text ("unspecified panic")); + } +} + +static void SWIG_Chicken_ThrowException(C_word value) C_noret; +static void SWIG_Chicken_ThrowException(C_word value) +{ + char *aborthook = C_text("\003sysabort"); + C_word *a = C_alloc(C_SIZEOF_STRING(strlen(aborthook))); + C_word abort = C_intern2(&a, aborthook); + + abort = C_block_item(abort, 0); + if (C_immediatep(abort)) + SWIG_Chicken_Panic(C_text("`##sys#abort' is not defined")); + + C_save(value); + C_do_apply(1, abort, C_SCHEME_UNDEFINED); +} + +static void +SWIG_Chicken_Finalizer(C_word argc, C_word closure, C_word continuation, C_word s) +{ + swig_type_info *type; + swig_chicken_clientdata *cdata; + + if (argc == 3 && s != C_SCHEME_FALSE && C_swig_is_swigpointer(s)) { + type = (swig_type_info *) C_block_item(s, 1); + if (type) { + cdata = (swig_chicken_clientdata *) type->clientdata; + if (cdata && cdata->destroy) { + /* this will not return, but will continue correctly */ + cdata->destroy(3,closure,continuation,s); + } + } + } + C_kontinue(continuation, C_SCHEME_UNDEFINED); +} +static C_word finalizer_obj[2] = {(C_word) (C_CLOSURE_TYPE|1), (C_word) SWIG_Chicken_Finalizer}; + +static C_word +SWIG_Chicken_NewPointerObj(void *ptr, swig_type_info *type, int owner, C_word **data) +{ + swig_chicken_clientdata *cdata = (swig_chicken_clientdata *) type->clientdata; + + if (ptr == NULL) + return C_SCHEME_FALSE; + else { + C_word cptr = C_swigmpointer(data, ptr, type); + /* add finalizer to object */ + #ifndef SWIG_CHICKEN_NO_COLLECTION + if (owner) + C_do_register_finalizer(cptr, (C_word) finalizer_obj); + #endif + + return cptr; + } +} + +/* Return 0 if successful. */ +static int +SWIG_Chicken_ConvertPtr(C_word s, void **result, swig_type_info *type, int flags) +{ + swig_cast_info *cast; + swig_type_info *from; + + if (s == C_SCHEME_FALSE) { + *result = NULL; + } else if (C_swig_is_swigpointer(s)) { + /* try and convert type */ + from = (swig_type_info *) C_block_item(s, 1); + if (!from) return 1; + if (type) { + cast = SWIG_TypeCheckStruct(from, type); + if (cast) { + int newmemory = 0; + *result = SWIG_TypeCast(cast, (void *) C_block_item(s, 0), &newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + } else { + return 1; + } + } else { + *result = (void *) C_block_item(s, 0); + } + + /* check if we are disowning this object */ + if (flags & SWIG_POINTER_DISOWN) { + C_do_unregister_finalizer(s); + } + } else { + return 1; + } + + return 0; +} + +static SWIGINLINE void * +SWIG_Chicken_MustGetPtr (C_word s, swig_type_info *type, int argnum, int flags) +{ + void *result; + char err_msg[256]; + if (SWIG_Chicken_ConvertPtr(s, &result, type, flags)) { + /* type mismatch */ + snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", argnum, (type->str ? type->str : type->name)); + SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg); + } + return result; +} + +static char *chicken_runtimevar_name = "type_pointer" SWIG_TYPE_TABLE_NAME; + +static swig_module_info * +SWIG_Chicken_GetModule() { + swig_module_info *ret = 0; + C_word sym; + + /* lookup the type pointer... it is stored in it's own symbol table */ + C_SYMBOL_TABLE *stable = C_find_symbol_table("swig_runtime_data" SWIG_RUNTIME_VERSION); + if (stable != NULL) { + sym = SWIG_Chicken_LookupSymbol(chicken_runtimevar_name, stable); + if (C_truep(sym) && C_swig_is_ptr(sym)) { + ret = (swig_module_info *) C_block_item(sym, 0); + } + } + + return ret; +} + +static void +SWIG_Chicken_SetModule(swig_module_info *module) { + C_word *a; + C_SYMBOL_TABLE *stable; + C_word sym; + C_word pointer; + static C_word *space = 0; + + /* type pointer is stored in it's own symbol table */ + stable = C_find_symbol_table("swig_runtime_data" SWIG_RUNTIME_VERSION); + if (stable == NULL) { + stable = C_new_symbol_table("swig_runtime_data" SWIG_RUNTIME_VERSION, 16); + } + + if (!space) { + space = (C_word *) C_malloc((C_SIZEOF_POINTER + C_SIZEOF_INTERNED_SYMBOL(C_strlen(chicken_runtimevar_name))) * sizeof(C_word)); + } + a = space; + pointer = C_mpointer(&a, (void *) module); + sym = C_intern_in(&a, C_strlen(chicken_runtimevar_name), chicken_runtimevar_name, stable); + C_set_block_item(sym, 0, pointer); +} + +static C_word SWIG_Chicken_MultiResultBuild(C_word num, C_word closure, C_word lst) { + C_word cont = C_block_item(closure,1); + C_word obj = C_block_item(closure,2); + C_word func; + + SWIG_Chicken_FindCreateProxy(func,obj); + + if (C_swig_is_closurep(func)) { + ((C_proc4)(void *)C_block_item(func, 0))(4,func,cont,obj,lst); + } else { + C_word *a = C_alloc(C_SIZEOF_PAIR); + C_kontinue(cont,C_pair(&a,obj,lst)); + } + return C_SCHEME_UNDEFINED; /* never reached */ +} + +static C_word SWIG_Chicken_ApplyResults(C_word num, C_word closure, C_word result) { + C_apply_values(3,C_SCHEME_UNDEFINED,C_block_item(closure,1),result); + return C_SCHEME_UNDEFINED; /* never reached */ +} + +#ifdef __cplusplus +} +#endif diff --git a/devtools/swigwin-1.3.34/Lib/chicken/extra-install.list b/devtools/swigwin-1.3.34/Lib/chicken/extra-install.list new file mode 100644 index 0000000..48721ce --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/chicken/extra-install.list @@ -0,0 +1,3 @@ +swigclosprefix.scm +multi-generic.scm +tinyclos-multi-generic.patch diff --git a/devtools/swigwin-1.3.34/Lib/chicken/multi-generic.scm b/devtools/swigwin-1.3.34/Lib/chicken/multi-generic.scm new file mode 100644 index 0000000..ae822f3 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/chicken/multi-generic.scm @@ -0,0 +1,152 @@ +;; This file is no longer necessary with Chicken versions above 1.92 +;; +;; This file overrides two functions inside TinyCLOS to provide support +;; for multi-argument generics. There are many ways of linking this file +;; into your code... all that needs to happen is this file must be +;; executed after loading TinyCLOS but before any SWIG modules are loaded +;; +;; something like the following +;; (require 'tinyclos) +;; (load "multi-generic") +;; (declare (uses swigmod)) +;; +;; An alternative to loading this scheme code directly is to add a +;; (declare (unit multi-generic)) to the top of this file, and then +;; compile this into the final executable or something. Or compile +;; this into an extension. + +;; Lastly, to override TinyCLOS method creation, two functions are +;; overridden: see the end of this file for which two are overridden. +;; You might want to remove those two lines and then exert more control over +;; which functions are used when. + +;; Comments, bugs, suggestions: send either to [email protected] or to +;; Author: John Lenz <[email protected]>, most code copied from TinyCLOS + +(define <multi-generic> (make <entity-class> + 'name "multi-generic" + 'direct-supers (list <generic>) + 'direct-slots '())) + +(letrec ([applicable? + (lambda (c arg) + (memq c (class-cpl (class-of arg))))] + + [more-specific? + (lambda (c1 c2 arg) + (memq c2 (memq c1 (class-cpl (class-of arg)))))] + + [filter-in + (lambda (f l) + (if (null? l) + '() + (let ([h (##sys#slot l 0)] + [r (##sys#slot l 1)] ) + (if (f h) + (cons h (filter-in f r)) + (filter-in f r) ) ) ) )]) + +(add-method compute-apply-generic + (make-method (list <multi-generic>) + (lambda (call-next-method generic) + (lambda args + (let ([cam (let ([x (compute-apply-methods generic)] + [y ((compute-methods generic) args)] ) + (lambda (args) (x y args)) ) ] ) + (cam args) ) ) ) ) ) + + + +(add-method compute-methods + (make-method (list <multi-generic>) + (lambda (call-next-method generic) + (lambda (args) + (let ([applicable + (filter-in (lambda (method) + (let check-applicable ([list1 (method-specializers method)] + [list2 args]) + (cond ((null? list1) #t) + ((null? list2) #f) + (else + (and (applicable? (##sys#slot list1 0) (##sys#slot list2 0)) + (check-applicable (##sys#slot list1 1) (##sys#slot list2 1))))))) + (generic-methods generic) ) ] ) + (if (or (null? applicable) (null? (##sys#slot applicable 1))) + applicable + (let ([cmms (compute-method-more-specific? generic)]) + (sort applicable (lambda (m1 m2) (cmms m1 m2 args))) ) ) ) ) ) ) ) + +(add-method compute-method-more-specific? + (make-method (list <multi-generic>) + (lambda (call-next-method generic) + (lambda (m1 m2 args) + (let loop ((specls1 (method-specializers m1)) + (specls2 (method-specializers m2)) + (args args)) + (cond-expand + [unsafe + (let ((c1 (##sys#slot specls1 0)) + (c2 (##sys#slot specls2 0)) + (arg (##sys#slot args 0))) + (if (eq? c1 c2) + (loop (##sys#slot specls1 1) + (##sys#slot specls2 1) + (##sys#slot args 1)) + (more-specific? c1 c2 arg))) ] + [else + (cond ((and (null? specls1) (null? specls2)) + (##sys#error "two methods are equally specific" generic)) + ;((or (null? specls1) (null? specls2)) + ; (##sys#error "two methods have different number of specializers" generic)) + ((null? specls1) #f) + ((null? specls2) #t) + ((null? args) + (##sys#error "fewer arguments than specializers" generic)) + (else + (let ((c1 (##sys#slot specls1 0)) + (c2 (##sys#slot specls2 0)) + (arg (##sys#slot args 0))) + (if (eq? c1 c2) + (loop (##sys#slot specls1 1) + (##sys#slot specls2 1) + (##sys#slot args 1)) + (more-specific? c1 c2 arg)))) ) ] ) ) ) ) ) ) + +) ;; end of letrec + +(define multi-add-method + (lambda (generic method) + (slot-set! + generic + 'methods + (let filter-in-method ([methods (slot-ref generic 'methods)]) + (if (null? methods) + (list method) + (let ([l1 (length (method-specializers method))] + [l2 (length (method-specializers (##sys#slot methods 0)))]) + (cond ((> l1 l2) + (cons (##sys#slot methods 0) (filter-in-method (##sys#slot methods 1)))) + ((< l1 l2) + (cons method methods)) + (else + (let check-method ([ms1 (method-specializers method)] + [ms2 (method-specializers (##sys#slot methods 0))]) + (cond ((and (null? ms1) (null? ms2)) + (cons method (##sys#slot methods 1))) ;; skip the method already in the generic + ((eq? (##sys#slot ms1 0) (##sys#slot ms2 0)) + (check-method (##sys#slot ms1 1) (##sys#slot ms2 1))) + (else + (cons (##sys#slot methods 0) (filter-in-method (##sys#slot methods 1)))))))))))) + + (##sys#setslot (##sys#slot generic (- (##sys#size generic) 2)) 1 (compute-apply-generic generic)) )) + +(define (multi-add-global-method val sym specializers proc) + (let ((generic (if (procedure? val) val (make <multi-generic> 'name (##sys#symbol->string sym))))) + (multi-add-method generic (make-method specializers proc)) + generic)) + +;; Might want to remove these, or perhaps do something like +;; (define old-add-method ##tinyclos#add-method) +;; and then you can switch between creating multi-generics and TinyCLOS generics. +(set! ##tinyclos#add-method multi-add-method) +(set! ##tinyclos#add-global-method multi-add-global-method) diff --git a/devtools/swigwin-1.3.34/Lib/chicken/std_string.i b/devtools/swigwin-1.3.34/Lib/chicken/std_string.i new file mode 100644 index 0000000..2955d0e --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/chicken/std_string.i @@ -0,0 +1,100 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_string.i + * + * SWIG typemaps for std::string + * ----------------------------------------------------------------------------- */ + +%{ +#include <string> +%} + +namespace std { + %naturalvar string; + + + %insert(closprefix) %{ (declare (hide <std-string>)) %} + %nodefault string; + %rename("std-string") string; + class string { + public: + ~string() {} + }; + %extend string { + char *str; + } + %{ + #define std_string_str_get(s) ((char *)((s)->c_str())) + #define std_string_str_set(s,v) (s->assign((char *)(v))) + %} + + %typemap(typecheck) string = char *; + %typemap(typecheck) const string & = char *; + + %typemap(in) string (char* tempptr) { + if ($input == C_SCHEME_FALSE) { + $1.resize(0); + } else { + if (!C_swig_is_string ($input)) { + swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, + "Argument #$argnum is not a string"); + } + tempptr = SWIG_MakeString($input); + $1.assign(tempptr); + if (tempptr) SWIG_free(tempptr); + } + } + + %typemap(in) const string& (std::string temp, + char* tempptr) { + + if ($input == C_SCHEME_FALSE) { + temp.resize(0); + $1 = &temp; + } else { + if (!C_swig_is_string ($input)) { + swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, + "Argument #$argnum is not a string"); + } + tempptr = SWIG_MakeString($input); + temp.assign(tempptr); + if (tempptr) SWIG_free(tempptr); + $1 = &temp; + } + } + + %typemap(out) string { + int size = $1.size(); + C_word *space = C_alloc (C_SIZEOF_STRING (size)); + $result = C_string (&space, size, (char *) $1.c_str()); + } + + %typemap(out) const string& { + int size = $1->size(); + C_word *space = C_alloc (C_SIZEOF_STRING (size)); + $result = C_string (&space, size, (char *) $1->c_str()); + } + + %typemap(varin) string { + if ($input == C_SCHEME_FALSE) { + $1.resize(0); + } else { + char *tempptr; + if (!C_swig_is_string ($input)) { + swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, + "Argument #$argnum is not a string"); + } + tempptr = SWIG_MakeString($input); + $1.assign(tempptr); + if (tempptr) SWIG_free(tempptr); + } + } + + %typemap(varout) string { + int size = $1.size(); + C_word *space = C_alloc (C_SIZEOF_STRING (size)); + $result = C_string (&space, size, (char *) $1.c_str()); + } +} diff --git a/devtools/swigwin-1.3.34/Lib/chicken/swigclosprefix.scm b/devtools/swigwin-1.3.34/Lib/chicken/swigclosprefix.scm new file mode 100644 index 0000000..e4bd72b --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/chicken/swigclosprefix.scm @@ -0,0 +1,31 @@ +(declare (hide swig-initialize)) + +(define (swig-initialize obj initargs create) + (slot-set! obj 'swig-this + (if (memq 'swig-this initargs) + (cadr initargs) + (let ((ret (apply create initargs))) + (if (instance? ret) + (slot-ref ret 'swig-this) + ret))))) + +(define-class <swig-metaclass-$module> (<class>) (void)) + +(define-method (compute-getter-and-setter (class <swig-metaclass-$module>) slot allocator) + (if (not (memq ':swig-virtual slot)) + (call-next-method) + (let ((getter (let search-get ((lst slot)) + (if (null? lst) + #f + (if (eq? (car lst) ':swig-get) + (cadr lst) + (search-get (cdr lst)))))) + (setter (let search-set ((lst slot)) + (if (null? lst) + #f + (if (eq? (car lst) ':swig-set) + (cadr lst) + (search-set (cdr lst))))))) + (values + (lambda (o) (getter (slot-ref o 'swig-this))) + (lambda (o new) (setter (slot-ref o 'swig-this) new) new))))) diff --git a/devtools/swigwin-1.3.34/Lib/chicken/tinyclos-multi-generic.patch b/devtools/swigwin-1.3.34/Lib/chicken/tinyclos-multi-generic.patch new file mode 100644 index 0000000..2e58596 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/chicken/tinyclos-multi-generic.patch @@ -0,0 +1,150 @@ +# This patch is against chicken 1.92, but it should work just fine +# with older versions of chicken. It adds support for mulit-argument +# generics, that is, generics now correctly handle adding methods +# with different lengths of specializer lists + +# This patch has been committed into the CHICKEN darcs repository, +# so chicken versions above 1.92 work fine. + +# Comments, bugs, suggestions send to [email protected] + +# Patch written by John Lenz <[email protected]> + +--- tinyclos.scm.old 2005-04-05 01:13:56.000000000 -0500 ++++ tinyclos.scm 2005-04-11 16:37:23.746181489 -0500 +@@ -37,8 +37,10 @@ + + (include "parameters") + ++(cond-expand [(not chicken-compile-shared) (declare (unit tinyclos))] ++ [else] ) ++ + (declare +- (unit tinyclos) + (uses extras) + (usual-integrations) + (fixnum) +@@ -234,7 +236,10 @@ + y = C_block_item(y, 1); + } + } +- return(C_block_item(v, i + 1)); ++ if (x == C_SCHEME_END_OF_LIST && y == C_SCHEME_END_OF_LIST) ++ return(C_block_item(v, i + 1)); ++ else ++ goto mismatch; + } + else if(free_index == -1) free_index = i; + mismatch: +@@ -438,7 +443,7 @@ + (define hash-arg-list + (foreign-lambda* unsigned-int ((scheme-object args) (scheme-object svector)) " + C_word tag, h, x; +- int n, i, j; ++ int n, i, j, len = 0; + for(i = 0; args != C_SCHEME_END_OF_LIST; args = C_block_item(args, 1)) { + x = C_block_item(args, 0); + if(C_immediatep(x)) { +@@ -481,8 +486,9 @@ + default: i += 255; + } + } ++ ++len; + } +- return(i & (C_METHOD_CACHE_SIZE - 1));") ) ++ return((i + len) & (C_METHOD_CACHE_SIZE - 1));") ) + + + ; +@@ -868,13 +874,27 @@ + (##tinyclos#slot-set! + generic + 'methods +- (cons method +- (filter-in +- (lambda (m) +- (let ([ms1 (method-specializers m)] +- [ms2 (method-specializers method)] ) +- (not (every2 (lambda (x y) (eq? x y)) ms1 ms2) ) ) ) +- (##tinyclos#slot-ref generic 'methods)))) ++ (let* ([ms1 (method-specializers method)] ++ [l1 (length ms1)] ) ++ (let filter-in-method ([methods (##tinyclos#slot-ref generic 'methods)]) ++ (if (null? methods) ++ (list method) ++ (let* ([mm (##sys#slot methods 0)] ++ [ms2 (method-specializers mm)] ++ [l2 (length ms2)]) ++ (cond ((> l1 l2) ++ (cons mm (filter-in-method (##sys#slot methods 1)))) ++ ((< l1 l2) ++ (cons method methods)) ++ (else ++ (let check-method ([ms1 ms1] ++ [ms2 ms2]) ++ (cond ((and (null? ms1) (null? ms2)) ++ (cons method (##sys#slot methods 1))) ;; skip the method already in the generic ++ ((eq? (##sys#slot ms1 0) (##sys#slot ms2 0)) ++ (check-method (##sys#slot ms1 1) (##sys#slot ms2 1))) ++ (else ++ (cons mm (filter-in-method (##sys#slot methods 1))))))))))))) + (if (memq generic generic-invocation-generics) + (set! method-cache-tag (vector)) + (%entity-cache-set! generic #f) ) +@@ -925,11 +945,13 @@ + (memq (car args) generic-invocation-generics)) + (let ([proc + (method-procedure ++ ; select the first method of one argument + (let lp ([lis (generic-methods generic)]) +- (let ([tail (##sys#slot lis 1)]) +- (if (null? tail) +- (##sys#slot lis 0) +- (lp tail)) ) ) ) ] ) ++ (if (null? lis) ++ (##sys#error "Unable to find original compute-apply-generic") ++ (if (= (length (method-specializers (##sys#slot lis 0))) 1) ++ (##sys#slot lis 0) ++ (lp (##sys#slot lis 1)))))) ] ) + (lambda (args) (apply proc #f args)) ) + (let ([x (compute-apply-methods generic)] + [y ((compute-methods generic) args)] ) +@@ -946,9 +968,13 @@ + (lambda (args) + (let ([applicable + (filter-in (lambda (method) +- (every2 applicable? +- (method-specializers method) +- args)) ++ (let check-applicable ([list1 (method-specializers method)] ++ [list2 args]) ++ (cond ((null? list1) #t) ++ ((null? list2) #f) ++ (else ++ (and (applicable? (##sys#slot list1 0) (##sys#slot list2 0)) ++ (check-applicable (##sys#slot list1 1) (##sys#slot list2 1))))))) + (generic-methods generic) ) ] ) + (if (or (null? applicable) (null? (##sys#slot applicable 1))) + applicable +@@ -975,8 +1001,10 @@ + [else + (cond ((and (null? specls1) (null? specls2)) + (##sys#error "two methods are equally specific" generic)) +- ((or (null? specls1) (null? specls2)) +- (##sys#error "two methods have different number of specializers" generic)) ++ ;((or (null? specls1) (null? specls2)) ++ ; (##sys#error "two methods have different number of specializers" generic)) ++ ((null? specls1) #f) ++ ((null? specls2) #t) + ((null? args) + (##sys#error "fewer arguments than specializers" generic)) + (else +@@ -1210,7 +1238,7 @@ + (define <structure> (make-primitive-class "structure")) + (define <procedure> (make-primitive-class "procedure" <procedure-class>)) + (define <end-of-file> (make-primitive-class "end-of-file")) +-(define <environment> (make-primitive-class "environment" <structure>)) ; (Benedikt insisted on this) ++(define <environment> (make-primitive-class "environment" <structure>)) + (define <hash-table> (make-primitive-class "hash-table" <structure>)) + (define <promise> (make-primitive-class "promise" <structure>)) + (define <queue> (make-primitive-class "queue" <structure>)) diff --git a/devtools/swigwin-1.3.34/Lib/chicken/typemaps.i b/devtools/swigwin-1.3.34/Lib/chicken/typemaps.i new file mode 100644 index 0000000..d79e201 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/chicken/typemaps.i @@ -0,0 +1,318 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * typemaps.i + * + * Pointer handling + * + * These mappings provide support for input/output arguments and + * common uses for C/C++ pointers. INOUT mappings allow for C/C++ + * pointer variables in addition to input/output arguments. + * ----------------------------------------------------------------------------- */ + +// INPUT typemaps. +// These remap a C pointer to be an "INPUT" value which is passed by value +// instead of reference. + +/* +The following methods can be applied to turn a pointer into a simple +"input" value. That is, instead of passing a pointer to an object, +you would use a real value instead. + + int *INPUT + short *INPUT + long *INPUT + long long *INPUT + unsigned int *INPUT + unsigned short *INPUT + unsigned long *INPUT + unsigned long long *INPUT + unsigned char *INPUT + char *INPUT + bool *INPUT + float *INPUT + double *INPUT + +To use these, suppose you had a C function like this : + + double fadd(double *a, double *b) { + return *a+*b; + } + +You could wrap it with SWIG as follows : + + %include <typemaps.i> + double fadd(double *INPUT, double *INPUT); + +or you can use the %apply directive : + + %include <typemaps.i> + %apply double *INPUT { double *a, double *b }; + double fadd(double *a, double *b); + +*/ + +// OUTPUT typemaps. These typemaps are used for parameters that +// are output only. The output value is appended to the result as +// a list element. + +/* +The following methods can be applied to turn a pointer into an "output" +value. When calling a function, no input value would be given for +a parameter, but an output value would be returned. In the case of +multiple output values, they are returned in the form of a Scheme list. + + int *OUTPUT + short *OUTPUT + long *OUTPUT + long long *OUTPUT + unsigned int *OUTPUT + unsigned short *OUTPUT + unsigned long *OUTPUT + unsigned long long *OUTPUT + unsigned char *OUTPUT + char *OUTPUT + bool *OUTPUT + float *OUTPUT + double *OUTPUT + +For example, suppose you were trying to wrap the modf() function in the +C math library which splits x into integral and fractional parts (and +returns the integer part in one of its parameters).K: + + double modf(double x, double *ip); + +You could wrap it with SWIG as follows : + + %include <typemaps.i> + double modf(double x, double *OUTPUT); + +or you can use the %apply directive : + + %include <typemaps.i> + %apply double *OUTPUT { double *ip }; + double modf(double x, double *ip); + +*/ + +// These typemaps contributed by Robin Dunn +//---------------------------------------------------------------------- +// +// T_OUTPUT typemap (and helper function) to return multiple argouts as +// a tuple instead of a list. +// +//---------------------------------------------------------------------- + +// Simple types + +%define INOUT_TYPEMAP(type_, from_scheme, to_scheme, checker, convtype, storage_) + +%typemap(in) type_ *INPUT($*1_ltype temp), type_ &INPUT($*1_ltype temp) +%{ if (!checker ($input)) { + swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'type_'"); + } + temp = ($*1_ltype) from_scheme ($input); + $1 = &temp; %} + +%typemap(typecheck) type_ *INPUT = type_; +%typemap(typecheck) type_ &INPUT = type_; + +%typemap(in, numinputs=0) type_ *OUTPUT($*1_ltype temp), type_ &OUTPUT($*1_ltype temp) +" $1 = &temp;" + +#if "storage_" == "0" + +%typemap(argout) type_ *OUTPUT, type_ &OUTPUT +%{ + if ($1 == NULL) { + swig_barf (SWIG_BARF1_ARGUMENT_NULL, "Argument #$argnum must be non-null"); + } + SWIG_APPEND_VALUE(to_scheme (convtype (*$1))); +%} + +#else + +%typemap(argout) type_ *OUTPUT, type_ &OUTPUT +%{ + { + C_word *known_space = C_alloc(storage_); + if ($1 == NULL) { + swig_barf (SWIG_BARF1_ARGUMENT_NULL, "Variable '$1' must be non-null"); + } + SWIG_APPEND_VALUE(to_scheme (&known_space, convtype (*$1))); + } +%} + +#endif + +%enddef + +INOUT_TYPEMAP(int, C_num_to_int, C_fix, C_swig_is_number, (int), 0); +INOUT_TYPEMAP(enum SWIGTYPE, C_num_to_int, C_fix, C_swig_is_number, (int), 0); +INOUT_TYPEMAP(short, C_num_to_int, C_fix, C_swig_is_number, (int), 0); +INOUT_TYPEMAP(long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM); +INOUT_TYPEMAP(long long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM); +INOUT_TYPEMAP(unsigned int, C_num_to_unsigned_int, C_unsigned_int_to_num, C_swig_is_number, (int), C_SIZEOF_FLONUM); +INOUT_TYPEMAP(unsigned short, C_num_to_unsigned_int, C_fix, C_swig_is_number, (unsigned int), 0); +INOUT_TYPEMAP(unsigned long, C_num_to_unsigned_long, C_unsigned_long_to_num, C_swig_is_long, (unsigned long), C_SIZEOF_FLONUM); +INOUT_TYPEMAP(unsigned long long, C_num_to_unsigned_long, C_unsigned_long_to_num, C_swig_is_long, (unsigned long), C_SIZEOF_FLONUM); +INOUT_TYPEMAP(unsigned char, C_character_code, C_make_character, C_swig_is_char, (unsigned int), 0); +INOUT_TYPEMAP(signed char, C_character_code, C_make_character, C_swig_is_char, (int), 0); +INOUT_TYPEMAP(char, C_character_code, C_make_character, C_swig_is_char, (char), 0); +INOUT_TYPEMAP(bool, C_truep, C_mk_bool, C_swig_is_bool, (bool), 0); +INOUT_TYPEMAP(float, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEOF_FLONUM); +INOUT_TYPEMAP(double, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEOF_FLONUM); + +// INOUT +// Mappings for an argument that is both an input and output +// parameter + +/* +The following methods can be applied to make a function parameter both +an input and output value. This combines the behavior of both the +"INPUT" and "OUTPUT" methods described earlier. Output values are +returned in the form of a CHICKEN tuple. + + int *INOUT + short *INOUT + long *INOUT + long long *INOUT + unsigned int *INOUT + unsigned short *INOUT + unsigned long *INOUT + unsigned long long *INOUT + unsigned char *INOUT + char *INOUT + bool *INOUT + float *INOUT + double *INOUT + +For example, suppose you were trying to wrap the following function : + + void neg(double *x) { + *x = -(*x); + } + +You could wrap it with SWIG as follows : + + %include <typemaps.i> + void neg(double *INOUT); + +or you can use the %apply directive : + + %include <typemaps.i> + %apply double *INOUT { double *x }; + void neg(double *x); + +As well, you can wrap variables with : + + %include <typemaps.i> + %apply double *INOUT { double *y }; + extern double *y; + +Unlike C, this mapping does not directly modify the input value (since +this makes no sense in CHICKEN). Rather, the modified input value shows +up as the return value of the function. Thus, to apply this function +to a CHICKEN variable you might do this : + + x = neg(x) + +Note : previous versions of SWIG used the symbol 'BOTH' to mark +input/output arguments. This is still supported, but will be slowly +phased out in future releases. + +*/ + +%typemap(in) int *INOUT = int *INPUT; +%typemap(in) enum SWIGTYPE *INOUT = enum SWIGTYPE *INPUT; +%typemap(in) short *INOUT = short *INPUT; +%typemap(in) long *INOUT = long *INPUT; +%typemap(in) long long *INOUT = long long *INPUT; +%typemap(in) unsigned *INOUT = unsigned *INPUT; +%typemap(in) unsigned short *INOUT = unsigned short *INPUT; +%typemap(in) unsigned long *INOUT = unsigned long *INPUT; +%typemap(in) unsigned long long *INOUT = unsigned long long *INPUT; +%typemap(in) unsigned char *INOUT = unsigned char *INPUT; +%typemap(in) char *INOUT = char *INPUT; +%typemap(in) bool *INOUT = bool *INPUT; +%typemap(in) float *INOUT = float *INPUT; +%typemap(in) double *INOUT = double *INPUT; + +%typemap(in) int &INOUT = int &INPUT; +%typemap(in) enum SWIGTYPE &INOUT = enum SWIGTYPE &INPUT; +%typemap(in) short &INOUT = short &INPUT; +%typemap(in) long &INOUT = long &INPUT; +%typemap(in) long long &INOUT = long long &INPUT; +%typemap(in) unsigned &INOUT = unsigned &INPUT; +%typemap(in) unsigned short &INOUT = unsigned short &INPUT; +%typemap(in) unsigned long &INOUT = unsigned long &INPUT; +%typemap(in) unsigned long long &INOUT = unsigned long long &INPUT; +%typemap(in) unsigned char &INOUT = unsigned char &INPUT; +%typemap(in) char &INOUT = char &INPUT; +%typemap(in) bool &INOUT = bool &INPUT; +%typemap(in) float &INOUT = float &INPUT; +%typemap(in) double &INOUT = double &INPUT; + +%typemap(argout) int *INOUT = int *OUTPUT; +%typemap(argout) enum SWIGTYPE *INOUT = enum SWIGTYPE *OUTPUT; +%typemap(argout) short *INOUT = short *OUTPUT; +%typemap(argout) long *INOUT = long *OUTPUT; +%typemap(argout) long long *INOUT = long long *OUTPUT; +%typemap(argout) unsigned *INOUT = unsigned *OUTPUT; +%typemap(argout) unsigned short *INOUT = unsigned short *OUTPUT; +%typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT; +%typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT; +%typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT; +%typemap(argout) bool *INOUT = bool *OUTPUT; +%typemap(argout) float *INOUT = float *OUTPUT; +%typemap(argout) double *INOUT = double *OUTPUT; + +%typemap(argout) int &INOUT = int &OUTPUT; +%typemap(argout) enum SWIGTYPE &INOUT = enum SWIGTYPE &OUTPUT; +%typemap(argout) short &INOUT = short &OUTPUT; +%typemap(argout) long &INOUT = long &OUTPUT; +%typemap(argout) long long &INOUT = long long &OUTPUT; +%typemap(argout) unsigned &INOUT = unsigned &OUTPUT; +%typemap(argout) unsigned short &INOUT = unsigned short &OUTPUT; +%typemap(argout) unsigned long &INOUT = unsigned long &OUTPUT; +%typemap(argout) unsigned long long &INOUT = unsigned long long &OUTPUT; +%typemap(argout) unsigned char &INOUT = unsigned char &OUTPUT; +%typemap(argout) char &INOUT = char &OUTPUT; +%typemap(argout) bool &INOUT = bool &OUTPUT; +%typemap(argout) float &INOUT = float &OUTPUT; +%typemap(argout) double &INOUT = double &OUTPUT; + +/* Overloading information */ + +%typemap(typecheck) double *INOUT = double; +%typemap(typecheck) bool *INOUT = bool; +%typemap(typecheck) char *INOUT = char; +%typemap(typecheck) signed char *INOUT = signed char; +%typemap(typecheck) unsigned char *INOUT = unsigned char; +%typemap(typecheck) unsigned long *INOUT = unsigned long; +%typemap(typecheck) unsigned long long *INOUT = unsigned long long; +%typemap(typecheck) unsigned short *INOUT = unsigned short; +%typemap(typecheck) unsigned int *INOUT = unsigned int; +%typemap(typecheck) long *INOUT = long; +%typemap(typecheck) long long *INOUT = long long; +%typemap(typecheck) short *INOUT = short; +%typemap(typecheck) int *INOUT = int; +%typemap(typecheck) enum SWIGTYPE *INOUT = enum SWIGTYPE; +%typemap(typecheck) float *INOUT = float; + +%typemap(typecheck) double &INOUT = double; +%typemap(typecheck) bool &INOUT = bool; +%typemap(typecheck) char &INOUT = char; +%typemap(typecheck) signed char &INOUT = signed char; +%typemap(typecheck) unsigned char &INOUT = unsigned char; +%typemap(typecheck) unsigned long &INOUT = unsigned long; +%typemap(typecheck) unsigned long long &INOUT = unsigned long long; +%typemap(typecheck) unsigned short &INOUT = unsigned short; +%typemap(typecheck) unsigned int &INOUT = unsigned int; +%typemap(typecheck) long &INOUT = long; +%typemap(typecheck) long long &INOUT = long long; +%typemap(typecheck) short &INOUT = short; +%typemap(typecheck) int &INOUT = int; +%typemap(typecheck) enum SWIGTYPE &INOUT = enum SWIGTYPE; +%typemap(typecheck) float &INOUT = float; diff --git a/devtools/swigwin-1.3.34/Lib/clisp/clisp.swg b/devtools/swigwin-1.3.34/Lib/clisp/clisp.swg new file mode 100644 index 0000000..fb6cdbf --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/clisp/clisp.swg @@ -0,0 +1,35 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * clisp.swg + * ----------------------------------------------------------------------------- */ + +/* Define a C preprocessor symbol that can be used in interface files + to distinguish between the SWIG language modules. */ + +#define SWIG_CLISP + +/* Typespecs for basic types. */ + +%typemap(in) void "NIL"; + +%typemap(in) char "character"; +%typemap(in) char * "ffi:c-string"; +%typemap(in) unsigned char "ffi:uchar"; +%typemap(in) signed char "ffi:char"; + +%typemap(in) short "ffi:short"; +%typemap(in) signed short "ffi:short"; +%typemap(in) unsigned short "ffi:ushort"; + +%typemap(in) int "ffi:int"; +%typemap(in) signed int "ffi:int"; +%typemap(in) unsigned int "ffi:uint"; + +%typemap(in) long "ffi:long"; +%typemap(in) signed long "ffi:long"; +%typemap(in) unsigned long "ffi:ulong"; + +%typemap(in) float "SINGLE-FLOAT"; +%typemap(in) double "DOUBLE-FLOAT"; diff --git a/devtools/swigwin-1.3.34/Lib/cmalloc.i b/devtools/swigwin-1.3.34/Lib/cmalloc.i new file mode 100644 index 0000000..03a6135 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/cmalloc.i @@ -0,0 +1,113 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * cmalloc.i + * + * SWIG library file containing macros that can be used to create objects using + * the C malloc function. + * ----------------------------------------------------------------------------- */ + +%{ +#include <stdlib.h> +%} + +/* %malloc(TYPE [, NAME = TYPE]) + %calloc(TYPE [, NAME = TYPE]) + %realloc(TYPE [, NAME = TYPE]) + %free(TYPE [, NAME = TYPE]) + %allocators(TYPE [,NAME = TYPE]) + + Creates functions for allocating/reallocating memory. + + TYPE *malloc_NAME(int nbytes = sizeof(TYPE); + TYPE *calloc_NAME(int nobj=1, int size=sizeof(TYPE)); + TYPE *realloc_NAME(TYPE *ptr, int nbytes); + void free_NAME(TYPE *ptr); + +*/ + +%define %malloc(TYPE,NAME...) +#if #NAME != "" +%rename(malloc_##NAME) ::malloc(int nbytes); +#else +%rename(malloc_##TYPE) ::malloc(int nbytes); +#endif + +#if #TYPE != "void" +%typemap(default) int nbytes "$1 = (int) sizeof(TYPE);" +#endif +TYPE *malloc(int nbytes); +%typemap(default) int nbytes; +%enddef + +%define %calloc(TYPE,NAME...) +#if #NAME != "" +%rename(calloc_##NAME) ::calloc(int nobj, int sz); +#else +%rename(calloc_##TYPE) ::calloc(int nobj, int sz); +#endif +#if #TYPE != "void" +%typemap(default) int sz "$1 = (int) sizeof(TYPE);" +#else +%typemap(default) int sz "$1 = 1;" +#endif +%typemap(default) int nobj "$1 = 1;" +TYPE *calloc(int nobj, int sz); +%typemap(default) int sz; +%typemap(default) int nobj; +%enddef + +%define %realloc(TYPE,NAME...) +%insert("header") { +#if #NAME != "" +TYPE *realloc_##NAME(TYPE *ptr, int nitems) +#else +TYPE *realloc_##TYPE(TYPE *ptr, int nitems) +#endif +{ +#if #TYPE != "void" +return (TYPE *) realloc(ptr, nitems*sizeof(TYPE)); +#else +return (TYPE *) realloc(ptr, nitems); +#endif +} +} +#if #NAME != "" +TYPE *realloc_##NAME(TYPE *ptr, int nitems); +#else +TYPE *realloc_##TYPE(TYPE *ptr, int nitems); +#endif +%enddef + +%define %free(TYPE,NAME...) +#if #NAME != "" +%rename(free_##NAME) ::free(TYPE *ptr); +#else +%rename(free_##TYPE) ::free(TYPE *ptr); +#endif +void free(TYPE *ptr); +%enddef + +%define %sizeof(TYPE,NAME...) +#if #NAME != "" +%constant int sizeof_##NAME = sizeof(TYPE); +#else +%constant int sizeof_##TYPE = sizeof(TYPE); +#endif +%enddef + +%define %allocators(TYPE,NAME...) +%malloc(TYPE,NAME) +%calloc(TYPE,NAME) +%realloc(TYPE,NAME) +%free(TYPE,NAME) +#if #TYPE != "void" +%sizeof(TYPE,NAME) +#endif +%enddef + + + + + diff --git a/devtools/swigwin-1.3.34/Lib/constraints.i b/devtools/swigwin-1.3.34/Lib/constraints.i new file mode 100644 index 0000000..2deb116 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/constraints.i @@ -0,0 +1,227 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * constraints.i + * + * SWIG constraints library. + * + * SWIG library file containing typemaps for implementing various kinds of + * constraints. Depends upon the SWIG exception library for generating + * errors in a language-independent manner. + * ----------------------------------------------------------------------------- */ + +#ifdef AUTODOC +%text %{ +%include <constraints.i> + +This library provides support for applying constraints to function +arguments. Using a constraint, you can restrict arguments to be +positive numbers, non-NULL pointers, and so on. The following +constraints are available : + + Number POSITIVE - Positive number (not zero) + Number NEGATIVE - Negative number (not zero) + Number NONZERO - Nonzero number + Number NONNEGATIVE - Positive number (including zero) + Number NONPOSITIVE - Negative number (including zero) + Pointer NONNULL - Non-NULL pointer + Pointer ALIGN8 - 8-byte aligned pointer + Pointer ALIGN4 - 4-byte aligned pointer + Pointer ALIGN2 - 2-byte aligned pointer + +To use the constraints, you need to "apply" them to specific +function arguments in your code. This is done using the %apply +directive. For example : + + %apply Number NONNEGATIVE { double nonneg }; + double sqrt(double nonneg); // Name of argument must match + + %apply Pointer NONNULL { void *ptr }; + void *malloc(int POSITIVE); // May return a NULL pointer + void free(void *ptr); // May not accept a NULL pointer + +Any function argument of the type you specify with the %apply directive +will be checked with the appropriate constraint. Multiple types may +be specified as follows : + + %apply Pointer NONNULL { void *, Vector *, List *, double *}; + +In this case, all of the types listed would be checked for non-NULL +pointers. + +The common datatypes of int, short, long, unsigned int, unsigned long, +unsigned short, unsigned char, signed char, float, and double can be +checked without using the %apply directive by simply using the +constraint name as the parameter name. For example : + + double sqrt(double NONNEGATIVE); + double log(double POSITIVE); + +If you have used typedef to change type-names, you can also do this : + + %apply double { Real }; // Make everything defined for doubles + // work for Reals. + Real sqrt(Real NONNEGATIVE); + Real log(Real POSITIVE); + +%} +#endif + +%include <exception.i> + +#ifdef SWIGCSHARP +// Required attribute for C# exception handling +#define SWIGCSHARPCANTHROW , canthrow=1 +#else +#define SWIGCSHARPCANTHROW +#endif + + +// Positive numbers + +%typemap(check SWIGCSHARPCANTHROW) + int POSITIVE, + short POSITIVE, + long POSITIVE, + unsigned int POSITIVE, + unsigned short POSITIVE, + unsigned long POSITIVE, + signed char POSITIVE, + unsigned char POSITIVE, + float POSITIVE, + double POSITIVE, + Number POSITIVE +{ + if ($1 <= 0) { + SWIG_exception(SWIG_ValueError,"Expected a positive value."); + } +} + +// Negative numbers + +%typemap(check SWIGCSHARPCANTHROW) + int NEGATIVE, + short NEGATIVE, + long NEGATIVE, + unsigned int NEGATIVE, + unsigned short NEGATIVE, + unsigned long NEGATIVE, + signed char NEGATIVE, + unsigned char NEGATIVE, + float NEGATIVE, + double NEGATIVE, + Number NEGATIVE +{ + if ($1 >= 0) { + SWIG_exception(SWIG_ValueError,"Expected a negative value."); + } +} + +// Nonzero numbers + +%typemap(check SWIGCSHARPCANTHROW) + int NONZERO, + short NONZERO, + long NONZERO, + unsigned int NONZERO, + unsigned short NONZERO, + unsigned long NONZERO, + signed char NONZERO, + unsigned char NONZERO, + float NONZERO, + double NONZERO, + Number NONZERO +{ + if ($1 == 0) { + SWIG_exception(SWIG_ValueError,"Expected a nonzero value."); + } +} + +// Nonnegative numbers + +%typemap(check SWIGCSHARPCANTHROW) + int NONNEGATIVE, + short NONNEGATIVE, + long NONNEGATIVE, + unsigned int NONNEGATIVE, + unsigned short NONNEGATIVE, + unsigned long NONNEGATIVE, + signed char NONNEGATIVE, + unsigned char NONNEGATIVE, + float NONNEGATIVE, + double NONNEGATIVE, + Number NONNEGATIVE +{ + if ($1 < 0) { + SWIG_exception(SWIG_ValueError,"Expected a non-negative value."); + } +} + +// Nonpositive numbers + +%typemap(check SWIGCSHARPCANTHROW) + int NONPOSITIVE, + short NONPOSITIVE, + long NONPOSITIVE, + unsigned int NONPOSITIVE, + unsigned short NONPOSITIVE, + unsigned long NONPOSITIVE, + signed char NONPOSITIVE, + unsigned char NONPOSITIVE, + float NONPOSITIVE, + double NONPOSITIVE, + Number NONPOSITIVE +{ + if ($1 > 0) { + SWIG_exception(SWIG_ValueError,"Expected a non-positive value."); + } +} + +// Non-NULL pointer + +%typemap(check SWIGCSHARPCANTHROW) + void * NONNULL, + Pointer NONNULL +{ + if (!$1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } +} + +// Aligned pointers + +%typemap(check SWIGCSHARPCANTHROW) + void * ALIGN8, + Pointer ALIGN8 +{ + unsigned long long tmp; + tmp = (unsigned long long) $1; + if (tmp & 7) { + SWIG_exception(SWIG_ValueError,"Pointer must be 8-byte aligned."); + } +} + +%typemap(check SWIGCSHARPCANTHROW) + void * ALIGN4, + Pointer ALIGN4 +{ + unsigned long long tmp; + tmp = (unsigned long long) $1; + if (tmp & 3) { + SWIG_exception(SWIG_ValueError,"Pointer must be 4-byte aligned."); + } +} + +%typemap(check SWIGCSHARPCANTHROW) + void * ALIGN2, + Pointer ALIGN2 +{ + unsigned long long tmp; + tmp = (unsigned long long) $1; + if (tmp & 1) { + SWIG_exception(SWIG_ValueError,"Pointer must be 2-byte aligned."); + } +} + + diff --git a/devtools/swigwin-1.3.34/Lib/cpointer.i b/devtools/swigwin-1.3.34/Lib/cpointer.i new file mode 100644 index 0000000..1a6e517 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/cpointer.i @@ -0,0 +1,183 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * cpointer.i + * + * SWIG library file containing macros that can be used to manipulate simple + * pointer objects. + * ----------------------------------------------------------------------------- */ + +/* ----------------------------------------------------------------------------- + * %pointer_class(type,name) + * + * Places a simple proxy around a simple type like 'int', 'float', or whatever. + * The proxy provides this interface: + * + * class type { + * public: + * type(); + * ~type(); + * type value(); + * void assign(type value); + * }; + * + * Example: + * + * %pointer_class(int, intp); + * + * int add(int *x, int *y) { return *x + *y; } + * + * In python (with proxies) + * + * >>> a = intp() + * >>> a.assign(10) + * >>> a.value() + * 10 + * >>> b = intp() + * >>> b.assign(20) + * >>> print add(a,b) + * 30 + * + * As a general rule, this macro should not be used on class/structures that + * are already defined in the interface. + * ----------------------------------------------------------------------------- */ + + +%define %pointer_class(TYPE, NAME) +%{ +typedef TYPE NAME; +%} + +typedef struct { +} NAME; + +%extend NAME { +#ifdef __cplusplus +NAME() { + return new TYPE(); +} +~NAME() { + if (self) delete self; +} +#else +NAME() { + return (TYPE *) calloc(1,sizeof(TYPE)); +} +~NAME() { + if (self) free(self); +} +#endif +} + +%extend NAME { + +void assign(TYPE value) { + *self = value; +} +TYPE value() { + return *self; +} +TYPE * cast() { + return self; +} +static NAME * frompointer(TYPE *t) { + return (NAME *) t; +} + +} + +%types(NAME = TYPE); + +%enddef + +/* ----------------------------------------------------------------------------- + * %pointer_functions(type,name) + * + * Create functions for allocating/deallocating pointers. This can be used + * if you don't want to create a proxy class or if the pointer is complex. + * + * %pointer_functions(int, intp) + * + * int add(int *x, int *y) { return *x + *y; } + * + * In python (with proxies) + * + * >>> a = copy_intp(10) + * >>> intp_value(a) + * 10 + * >>> b = new_intp() + * >>> intp_assign(b,20) + * >>> print add(a,b) + * 30 + * >>> delete_intp(a) + * >>> delete_intp(b) + * + * ----------------------------------------------------------------------------- */ + +%define %pointer_functions(TYPE,NAME) +%{ +static TYPE *new_##NAME() { %} +#ifdef __cplusplus +%{ return new TYPE(); %} +#else +%{ return (TYPE *) calloc(1,sizeof(TYPE)); %} +#endif +%{} + +static TYPE *copy_##NAME(TYPE value) { %} +#ifdef __cplusplus +%{ return new TYPE(value); %} +#else +%{ TYPE *self = (TYPE *) calloc(1,sizeof(TYPE)); + *self = value; + return self; %} +#endif +%{} + +static void delete_##NAME(TYPE *self) { %} +#ifdef __cplusplus +%{ if (self) delete self; %} +#else +%{ if (self) free(self); %} +#endif +%{} + +static void NAME ##_assign(TYPE *self, TYPE value) { + *self = value; +} + +static TYPE NAME ##_value(TYPE *self) { + return *self; +} +%} + +TYPE *new_##NAME(); +TYPE *copy_##NAME(TYPE value); +void delete_##NAME(TYPE *self); +void NAME##_assign(TYPE *self, TYPE value); +TYPE NAME##_value(TYPE *self); + +%enddef + +/* ----------------------------------------------------------------------------- + * %pointer_cast(type1,type2,name) + * + * Generates a pointer casting function. + * ----------------------------------------------------------------------------- */ + +%define %pointer_cast(TYPE1,TYPE2,NAME) +%inline %{ +TYPE2 NAME(TYPE1 x) { + return (TYPE2) x; +} +%} +%enddef + + + + + + + + diff --git a/devtools/swigwin-1.3.34/Lib/csharp/boost_shared_ptr.i b/devtools/swigwin-1.3.34/Lib/csharp/boost_shared_ptr.i new file mode 100644 index 0000000..47fbaba --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/csharp/boost_shared_ptr.i @@ -0,0 +1,229 @@ +%include <shared_ptr.i> + +%define SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...) + +%naturalvar TYPE; +%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; + +// destructor mods +%feature("unref") TYPE +//"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter<SWIG_null_deleter>(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" + "(void)arg1; delete smartarg1;" + + +// plain value +%typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0) %{ + argp = ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0; + if (!argp) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0); + return $null; + } + $1 = *argp; %} +%typemap(out) CONST TYPE +%{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %} + +// plain pointer +%typemap(in, canthrow=1) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ + smartarg = (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input; + $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %} +%typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{ + $result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; +%} + +// plain reference +%typemap(in, canthrow=1) CONST TYPE & %{ + $1 = ($1_ltype)(((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0); + if(!$1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0); + return $null; + } %} +%typemap(out, fragment="SWIG_null_deleter") CONST TYPE & +%{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %} + +// plain pointer by reference +%typemap(in) CONST TYPE *& ($*1_ltype temp = 0) +%{ temp = (((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0); + $1 = &temp; %} +%typemap(out, fragment="SWIG_null_deleter") CONST TYPE *& +%{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %} + +// shared_ptr by value +%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > +%{ if ($input) $1 = *($&1_ltype)$input; %} +%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > +%{ $result = $1 ? new $1_ltype($1) : 0; %} + +// shared_ptr by reference +%typemap(in, canthrow=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & ($*1_ltype tempnull) +%{ $1 = $input ? ($1_ltype)$input : &tempnull; %} +%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & +%{ $result = *$1 ? new $*1_ltype(*$1) : 0; %} + +// shared_ptr by pointer +%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * ($*1_ltype tempnull) +%{ $1 = $input ? ($1_ltype)$input : &tempnull; %} +%typemap(out, fragment="SWIG_null_deleter") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * +%{ $result = ($1 && *$1) ? new $*1_ltype(*($1_ltype)$1) : 0; + if ($owner) delete $1; %} + +// shared_ptr by pointer reference +%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempnull, $*1_ltype temp = 0) +%{ temp = $input ? *($1_ltype)&$input : &tempnull; + $1 = &temp; %} +%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& +%{ *($1_ltype)&$result = (*$1 && **$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; %} + +// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug +%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ +#error "typemaps for $1_type not available" +%} +%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ +#error "typemaps for $1_type not available" +%} + + +%typemap (ctype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "void *" +%typemap (imtype, out="IntPtr") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "HandleRef" +%typemap (cstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "PROXYCLASS" + +%typemap(csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "PROXYCLASS.getCPtr($csinput)" + +%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { + IntPtr cPtr = $imcall; + PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & { + IntPtr cPtr = $imcall; + PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * { + IntPtr cPtr = $imcall; + PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { + IntPtr cPtr = $imcall; + PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode + return ret; + } + + +%typemap(csout, excode=SWIGEXCODE) CONST TYPE { + PROXYCLASS ret = new PROXYCLASS($imcall, true);$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) CONST TYPE & { + PROXYCLASS ret = new PROXYCLASS($imcall, true);$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) CONST TYPE * { + IntPtr cPtr = $imcall; + PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) CONST TYPE *& { + IntPtr cPtr = $imcall; + PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode + return ret; + } + +%typemap(csvarout, excode=SWIGEXCODE2) CONST TYPE & %{ + get { + $csclassname ret = new $csclassname($imcall, true);$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) CONST TYPE * %{ + get { + IntPtr cPtr = $imcall; + $csclassname ret = (cPtr == IntPtr.Zero) ? null : new $csclassname(cPtr, true);$excode + return ret; + } %} + +%typemap(csvarout, excode=SWIGEXCODE2) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ + get { + IntPtr cPtr = $imcall; + PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ + get { + IntPtr cPtr = $imcall; + PROXYCLASS ret = (cPtr == IntPtr.Zero) ? null : new PROXYCLASS(cPtr, true);$excode + return ret; + } %} + + +// Proxy classes (base classes, ie, not derived classes) +%typemap(csbody) TYPE %{ + private HandleRef swigCPtr; + private bool swigCMemOwnBase; + + internal $csclassname(IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwnBase = cMemoryOwn; + swigCPtr = new HandleRef(this, cPtr); + } + + internal static HandleRef getCPtr($csclassname obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +%} + +// Derived proxy classes +%typemap(csbody_derived) TYPE %{ + private HandleRef swigCPtr; + private bool swigCMemOwnDerived; + + internal $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclassname_SWIGSharedPtrUpcast(cPtr), true) { + swigCMemOwnDerived = cMemoryOwn; + swigCPtr = new HandleRef(this, cPtr); + } + + internal static HandleRef getCPtr($csclassname obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +%} + +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE { + lock(this) { + if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwnBase) { + swigCMemOwnBase = false; + $imcall; + } + swigCPtr = new HandleRef(null, IntPtr.Zero); + GC.SuppressFinalize(this); + } + } + +%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE { + lock(this) { + if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwnDerived) { + swigCMemOwnDerived = false; + $imcall; + } + swigCPtr = new HandleRef(null, IntPtr.Zero); + GC.SuppressFinalize(this); + base.Dispose(); + } + } + +%typemap(imtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "IntPtr" +%typemap(csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "PROXYCLASS.getCPtr($csinput).Handle" + + +%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; +%enddef + diff --git a/devtools/swigwin-1.3.34/Lib/csharp/csharp.swg b/devtools/swigwin-1.3.34/Lib/csharp/csharp.swg new file mode 100644 index 0000000..9895bd0 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/csharp/csharp.swg @@ -0,0 +1,971 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * csharp.swg + * + * C# typemaps + * ----------------------------------------------------------------------------- */ + +%include <csharphead.swg> + +/* The ctype, imtype and cstype typemaps work together and so there should be one of each. + * The ctype typemap contains the PInvoke type used in the PInvoke (C/C++) code. + * The imtype typemap contains the C# type used in the intermediary class. + * The cstype typemap contains the C# type used in the C# proxy classes, type wrapper classes and module class. */ + + +/* Fragments */ +%fragment("SWIG_PackData", "header") { +/* Pack binary data into a string */ +SWIGINTERN char * SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} +} + +%fragment("SWIG_UnPackData", "header") { +/* Unpack binary data from a string */ +SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} +} + +/* Primitive types */ +%typemap(ctype) bool, const bool & "unsigned int" +%typemap(ctype) char, const char & "char" +%typemap(ctype) signed char, const signed char & "signed char" +%typemap(ctype) unsigned char, const unsigned char & "unsigned char" +%typemap(ctype) short, const short & "short" +%typemap(ctype) unsigned short, const unsigned short & "unsigned short" +%typemap(ctype) int, const int & "int" +%typemap(ctype) unsigned int, const unsigned int & "unsigned int" +%typemap(ctype) long, const long & "long" +%typemap(ctype) unsigned long, const unsigned long & "unsigned long" +%typemap(ctype) long long, const long long & "long long" +%typemap(ctype) unsigned long long, const unsigned long long & "unsigned long long" +%typemap(ctype) float, const float & "float" +%typemap(ctype) double, const double & "double" +%typemap(ctype) void "void" + +%typemap(imtype) bool, const bool & "bool" +%typemap(imtype) char, const char & "char" +%typemap(imtype) signed char, const signed char & "sbyte" +%typemap(imtype) unsigned char, const unsigned char & "byte" +%typemap(imtype) short, const short & "short" +%typemap(imtype) unsigned short, const unsigned short & "ushort" +%typemap(imtype) int, const int & "int" +%typemap(imtype) unsigned int, const unsigned int & "uint" +%typemap(imtype) long, const long & "int" +%typemap(imtype) unsigned long, const unsigned long & "uint" +%typemap(imtype) long long, const long long & "long" +%typemap(imtype) unsigned long long, const unsigned long long & "ulong" +%typemap(imtype) float, const float & "float" +%typemap(imtype) double, const double & "double" +%typemap(imtype) void "void" + +%typemap(cstype) bool, const bool & "bool" +%typemap(cstype) char, const char & "char" +%typemap(cstype) signed char, const signed char & "sbyte" +%typemap(cstype) unsigned char, const unsigned char & "byte" +%typemap(cstype) short, const short & "short" +%typemap(cstype) unsigned short, const unsigned short & "ushort" +%typemap(cstype) int, const int & "int" +%typemap(cstype) unsigned int, const unsigned int & "uint" +%typemap(cstype) long, const long & "int" +%typemap(cstype) unsigned long, const unsigned long & "uint" +%typemap(cstype) long long, const long long & "long" +%typemap(cstype) unsigned long long, const unsigned long long & "ulong" +%typemap(cstype) float, const float & "float" +%typemap(cstype) double, const double & "double" +%typemap(cstype) void "void" + +%typemap(ctype) char *, char[ANY], char[] "char *" +%typemap(imtype) char *, char[ANY], char[] "string" +%typemap(cstype) char *, char[ANY], char[] "string" + +/* Non primitive types */ +%typemap(ctype) SWIGTYPE "void *" +%typemap(imtype, out="IntPtr") SWIGTYPE "HandleRef" +%typemap(cstype) SWIGTYPE "$&csclassname" + +%typemap(ctype) SWIGTYPE [] "void *" +%typemap(imtype, out="IntPtr") SWIGTYPE [] "HandleRef" +%typemap(cstype) SWIGTYPE [] "$csclassname" + +%typemap(ctype) SWIGTYPE * "void *" +%typemap(imtype, out="IntPtr") SWIGTYPE * "HandleRef" +%typemap(cstype) SWIGTYPE * "$csclassname" + +%typemap(ctype) SWIGTYPE & "void *" +%typemap(imtype, out="IntPtr") SWIGTYPE & "HandleRef" +%typemap(cstype) SWIGTYPE & "$csclassname" + +/* pointer to a class member */ +%typemap(ctype) SWIGTYPE (CLASS::*) "char *" +%typemap(imtype) SWIGTYPE (CLASS::*) "string" +%typemap(cstype) SWIGTYPE (CLASS::*) "$csclassname" + +/* The following are the in and out typemaps. These are the PInvoke code generating typemaps for converting from C# to C and visa versa. */ + +/* primitive types */ +%typemap(in) bool +%{ $1 = $input ? true : false; %} + +%typemap(directorout) bool +%{ $result = $input ? true : false; %} + +%typemap(csdirectorin) bool "$iminput" +%typemap(csdirectorout) bool "$cscall" + +%typemap(in) char, + signed char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + unsigned long long, + float, + double +%{ $1 = ($1_ltype)$input; %} + +%typemap(directorout) char, + signed char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + unsigned long long, + float, + double +%{ $result = ($1_ltype)$input; %} + +%typemap(directorin) bool "$input = $1;" +%typemap(directorin) char "$input = $1;" +%typemap(directorin) signed char "$input = $1;" +%typemap(directorin) unsigned char "$input = $1;" +%typemap(directorin) short "$input = $1;" +%typemap(directorin) unsigned short "$input = $1;" +%typemap(directorin) int "$input = $1;" +%typemap(directorin) unsigned int "$input = $1;" +%typemap(directorin) long "$input = $1;" +%typemap(directorin) unsigned long "$input = $1;" +%typemap(directorin) long long "$input = $1;" +%typemap(directorin) unsigned long long "$input = $1;" +%typemap(directorin) float "$input = $1;" +%typemap(directorin) double "$input = $1;" + +%typemap(csdirectorin) char, + signed char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + unsigned long long, + float, + double + "$iminput" + +%typemap(csdirectorout) char, + signed char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + unsigned long long, + float, + double + "$cscall" + +%typemap(out) bool %{ $result = $1; %} +%typemap(out) char %{ $result = $1; %} +%typemap(out) signed char %{ $result = $1; %} +%typemap(out) unsigned char %{ $result = $1; %} +%typemap(out) short %{ $result = $1; %} +%typemap(out) unsigned short %{ $result = $1; %} +%typemap(out) int %{ $result = $1; %} +%typemap(out) unsigned int %{ $result = $1; %} +%typemap(out) long %{ $result = $1; %} +%typemap(out) unsigned long %{ $result = (unsigned long)$1; %} +%typemap(out) long long %{ $result = $1; %} +%typemap(out) unsigned long long %{ $result = $1; %} +%typemap(out) float %{ $result = $1; %} +%typemap(out) double %{ $result = $1; %} + +/* char * - treat as String */ +%typemap(in) char * %{ $1 = ($1_ltype)$input; %} +%typemap(out) char * %{ $result = SWIG_csharp_string_callback((const char *)$1); %} +%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) char * %{ $result = ($1_ltype)$input; %} +%typemap(directorin) char * %{ $input = SWIG_csharp_string_callback((const char *)$1); %} +%typemap(csdirectorin) char * "$iminput" +%typemap(csdirectorout) char * "$cscall" + +%typemap(out, null="") void "" +%typemap(csdirectorin) void "$iminput" +%typemap(csdirectorout) void "$cscall" +%typemap(directorin) void "" + +/* primitive types by const reference */ +%typemap(in) const bool & ($*1_ltype temp) +%{ temp = $input ? true : false; + $1 = &temp; %} + +%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const bool & +%{ static $*1_ltype temp; + temp = $input ? true : false; + $result = &temp; %} + +%typemap(csdirectorin) const bool & "$iminput" +%typemap(csdirectorout) const bool & "$cscall" + +%typemap(in) const char & ($*1_ltype temp), + const signed char & ($*1_ltype temp), + const unsigned char & ($*1_ltype temp), + const short & ($*1_ltype temp), + const unsigned short & ($*1_ltype temp), + const int & ($*1_ltype temp), + const unsigned int & ($*1_ltype temp), + const long & ($*1_ltype temp), + const unsigned long & ($*1_ltype temp), + const long long & ($*1_ltype temp), + const unsigned long long & ($*1_ltype temp), + const float & ($*1_ltype temp), + const double & ($*1_ltype temp) +%{ temp = ($*1_ltype)$input; + $1 = &temp; %} + +%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const char &, + const signed char &, + const unsigned char &, + const short &, + const unsigned short &, + const int &, + const unsigned int &, + const long &, + const unsigned long &, + const long long &, + const float &, + const double & +%{ static $*1_ltype temp; + temp = ($*1_ltype)$input; + $result = &temp; %} + +%typemap(directorin) const bool & "$input = $1_name;" +%typemap(directorin) const char & "$input = $1_name;" +%typemap(directorin) const signed char & "$input = $1_name;" +%typemap(directorin) const unsigned char & "$input = $1_name;" +%typemap(directorin) const short & "$input = $1_name;" +%typemap(directorin) const unsigned short & "$input = $1_name;" +%typemap(directorin) const int & "$input = $1_name;" +%typemap(directorin) const unsigned int & "$input = $1_name;" +%typemap(directorin) const long & "$input = $1_name;" +%typemap(directorin) const unsigned long & "$input = $1_name;" +%typemap(directorin) const long long & "$input = $1_name;" +%typemap(directorin) const float & "$input = $1_name;" +%typemap(directorin) const double & "$input = $1_name;" + +%typemap(csdirectorin) const char & ($*1_ltype temp), + const signed char & ($*1_ltype temp), + const unsigned char & ($*1_ltype temp), + const short & ($*1_ltype temp), + const unsigned short & ($*1_ltype temp), + const int & ($*1_ltype temp), + const unsigned int & ($*1_ltype temp), + const long & ($*1_ltype temp), + const unsigned long & ($*1_ltype temp), + const long long & ($*1_ltype temp), + const float & ($*1_ltype temp), + const double & ($*1_ltype temp) + "$iminput" + +%typemap(csdirectorout) const char & ($*1_ltype temp), + const signed char & ($*1_ltype temp), + const unsigned char & ($*1_ltype temp), + const short & ($*1_ltype temp), + const unsigned short & ($*1_ltype temp), + const int & ($*1_ltype temp), + const unsigned int & ($*1_ltype temp), + const long & ($*1_ltype temp), + const unsigned long & ($*1_ltype temp), + const long long & ($*1_ltype temp), + const float & ($*1_ltype temp), + const double & ($*1_ltype temp) + "$cscall" + + +%typemap(out) const bool & %{ $result = *$1; %} +%typemap(out) const char & %{ $result = *$1; %} +%typemap(out) const signed char & %{ $result = *$1; %} +%typemap(out) const unsigned char & %{ $result = *$1; %} +%typemap(out) const short & %{ $result = *$1; %} +%typemap(out) const unsigned short & %{ $result = *$1; %} +%typemap(out) const int & %{ $result = *$1; %} +%typemap(out) const unsigned int & %{ $result = *$1; %} +%typemap(out) const long & %{ $result = *$1; %} +%typemap(out) const unsigned long & %{ $result = (unsigned long)*$1; %} +%typemap(out) const long long & %{ $result = *$1; %} +%typemap(out) const unsigned long long & %{ $result = *$1; %} +%typemap(out) const float & %{ $result = *$1; %} +%typemap(out) const double & %{ $result = *$1; %} + +/* Default handling. Object passed by value. Convert to a pointer */ +%typemap(in, canthrow=1) SWIGTYPE ($&1_type argp) +%{ argp = ($&1_ltype)$input; + if (!argp) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0); + return $null; + } + $1 = *argp; %} + +%typemap(directorout) SWIGTYPE +%{ if (!$input) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Unexpected null return for type $1_type", 0); + return $null; + } + $result = *($&1_ltype)$input; %} + +%typemap(out) SWIGTYPE +#ifdef __cplusplus +%{ $result = new $1_ltype(($1_ltype &)$1); %} +#else +{ + $&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype)); + memmove($1ptr, &$1, sizeof($1_type)); + $result = $1ptr; +} +#endif + +%typemap(directorin) SWIGTYPE +%{ $input = (void *)&$1; %} +%typemap(csdirectorin) SWIGTYPE "new $&csclassname($iminput, false)" +%typemap(csdirectorout) SWIGTYPE "$&csclassname.getCPtr($cscall).Handle" + +/* Generic pointers and references */ +%typemap(in) SWIGTYPE * %{ $1 = ($1_ltype)$input; %} +%typemap(in, fragment="SWIG_UnPackData") SWIGTYPE (CLASS::*) %{ + SWIG_UnpackData($input, (void *)&$1, sizeof($1)); +%} +%typemap(in, canthrow=1) SWIGTYPE & %{ $1 = ($1_ltype)$input; + if(!$1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type type is null", 0); + return $null; + } %} +%typemap(out) SWIGTYPE * %{ $result = (void *)$1; %} +%typemap(out, fragment="SWIG_PackData") SWIGTYPE (CLASS::*) %{ + char buf[128]; + char *data = SWIG_PackData(buf, (void *)&$1, sizeof($1)); + *data = '\0'; + $result = SWIG_csharp_string_callback(buf); +%} +%typemap(out) SWIGTYPE & %{ $result = (void *)$1; %} + +%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE * +%{ $result = ($1_ltype)$input; %} +%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE (CLASS::*) +%{ $result = ($1_ltype)$input; %} + +%typemap(directorin) SWIGTYPE * +%{ $input = (void *) $1; %} +%typemap(directorin) SWIGTYPE (CLASS::*) +%{ $input = (void *) $1; %} + +%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE & +%{ if (!$input) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Unexpected null return for type $1_type", 0); + return $null; + } + $result = ($1_ltype)$input; %} +%typemap(directorin) SWIGTYPE & +%{ $input = ($1_ltype) &$1; %} + +%typemap(csdirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "new $csclassname($iminput, false)" +%typemap(csdirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "$csclassname.getCPtr($cscall).Handle" + +/* Default array handling */ +%typemap(in) SWIGTYPE [] %{ $1 = ($1_ltype)$input; %} +%typemap(out) SWIGTYPE [] %{ $result = $1; %} + +/* char arrays - treat as String */ +%typemap(in) char[ANY], char[] %{ $1 = ($1_ltype)$input; %} +%typemap(out) char[ANY], char[] %{ $result = SWIG_csharp_string_callback((const char *)$1); %} + +%typemap(directorout) char[ANY], char[] %{ $result = ($1_ltype)$input; %} +%typemap(directorin) char[ANY], char[] %{ $input = SWIG_csharp_string_callback((const char *)$1); %} + +%typemap(csdirectorin) char[ANY], char[] "$iminput" +%typemap(csdirectorout) char[ANY], char[] "$cscall" + + +/* Typecheck typemaps - The purpose of these is merely to issue a warning for overloaded C++ functions + * that cannot be overloaded in C# as more than one C++ type maps to a single C# type */ + +%typecheck(SWIG_TYPECHECK_BOOL) + bool, + const bool & + "" + +%typecheck(SWIG_TYPECHECK_CHAR) + char, + const char & + "" + +%typecheck(SWIG_TYPECHECK_INT8) + signed char, + const signed char & + "" + +%typecheck(SWIG_TYPECHECK_UINT8) + unsigned char, + const unsigned char & + "" + +%typecheck(SWIG_TYPECHECK_INT16) + short, + const short & + "" + +%typecheck(SWIG_TYPECHECK_UINT16) + unsigned short, + const unsigned short & + "" + +%typecheck(SWIG_TYPECHECK_INT32) + int, + long, + const int &, + const long & + "" + +%typecheck(SWIG_TYPECHECK_UINT32) + unsigned int, + unsigned long, + const unsigned int &, + const unsigned long & + "" + +%typecheck(SWIG_TYPECHECK_INT64) + long long, + const long long & + "" + +%typecheck(SWIG_TYPECHECK_UINT64) + unsigned long long, + const unsigned long long & + "" + +%typecheck(SWIG_TYPECHECK_FLOAT) + float, + const float & + "" + +%typecheck(SWIG_TYPECHECK_DOUBLE) + double, + const double & + "" + +%typecheck(SWIG_TYPECHECK_STRING) + char *, + char[ANY], + char[] + "" + +%typecheck(SWIG_TYPECHECK_POINTER) + SWIGTYPE, + SWIGTYPE *, + SWIGTYPE &, + SWIGTYPE [], + SWIGTYPE (CLASS::*) + "" + +/* Exception handling */ + +%typemap(throws, canthrow=1) int, + long, + short, + unsigned int, + unsigned long, + unsigned short +%{ char error_msg[256]; + sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1); + SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, error_msg); + return $null; %} + +%typemap(throws, canthrow=1) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY] +%{ (void)$1; + SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); + return $null; %} + +%typemap(throws, canthrow=1) char * +%{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1); + return $null; %} + + +/* Typemaps for code generation in proxy classes and C# type wrapper classes */ + +/* The csin typemap is used for converting function parameter types from the type + * used in the proxy, module or type wrapper class to the type used in the PInvoke class. */ +%typemap(csin) bool, const bool &, + char, const char &, + signed char, const signed char &, + unsigned char, const unsigned char &, + short, const short &, + unsigned short, const unsigned short &, + int, const int &, + unsigned int, const unsigned int &, + long, const long &, + unsigned long, const unsigned long &, + long long, const long long &, + unsigned long long, const unsigned long long &, + float, const float &, + double, const double & + "$csinput" +%typemap(csin) char *, char[ANY], char[] "$csinput" +%typemap(csin) SWIGTYPE "$&csclassname.getCPtr($csinput)" +%typemap(csin) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] "$csclassname.getCPtr($csinput)" +%typemap(csin) SWIGTYPE (CLASS::*) "$csclassname.getCMemberPtr($csinput)" + +/* The csout typemap is used for converting function return types from the return type + * used in the PInvoke class to the type returned by the proxy, module or type wrapper class. + * The $excode special variable is replaced by the excode typemap attribute code if the + * method can throw any exceptions from unmanaged code, otherwise replaced by nothing. */ + +// Macro used by the $excode special variable +%define SWIGEXCODE "\n if ($imclassname.SWIGPendingException.Pending) throw $imclassname.SWIGPendingException.Retrieve();" %enddef +%define SWIGEXCODE2 "\n if ($imclassname.SWIGPendingException.Pending) throw $imclassname.SWIGPendingException.Retrieve();" %enddef + +%typemap(csout, excode=SWIGEXCODE) bool, const bool & { + bool ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) char, const char & { + char ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) signed char, const signed char & { + sbyte ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) unsigned char, const unsigned char & { + byte ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) short, const short & { + short ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) unsigned short, const unsigned short & { + ushort ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) int, const int & { + int ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) unsigned int, const unsigned int & { + uint ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) long, const long & { + int ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) unsigned long, const unsigned long & { + uint ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) long long, const long long & { + long ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) unsigned long long, const unsigned long long & { + ulong ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) float, const float & { + float ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) double, const double & { + double ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) char *, char[ANY], char[] { + string ret = $imcall;$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) void { + $imcall;$excode + } +%typemap(csout, excode=SWIGEXCODE) SWIGTYPE { + $&csclassname ret = new $&csclassname($imcall, true);$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) SWIGTYPE & { + $csclassname ret = new $csclassname($imcall, $owner);$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) SWIGTYPE *, SWIGTYPE [] { + IntPtr cPtr = $imcall; + $csclassname ret = (cPtr == IntPtr.Zero) ? null : new $csclassname(cPtr, $owner);$excode + return ret; + } +%typemap(csout, excode=SWIGEXCODE) SWIGTYPE (CLASS::*) { + string cMemberPtr = $imcall; + $csclassname ret = (cMemberPtr == null) ? null : new $csclassname(cMemberPtr, $owner);$excode + return ret; + } + + +/* Properties */ +%typemap(csvarin, excode=SWIGEXCODE2) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{ + set { + $imcall;$excode + } %} + +%typemap(csvarin, excode=SWIGEXCODE2) char *, char[ANY], char[] %{ + set { + $imcall;$excode + } %} + +%typemap(csvarout, excode=SWIGEXCODE2) bool, const bool & %{ + get { + bool ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) char, const char & %{ + get { + char ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) signed char, const signed char & %{ + get { + sbyte ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) unsigned char, const unsigned char & %{ + get { + byte ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) short, const short & %{ + get { + short ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) unsigned short, const unsigned short & %{ + get { + ushort ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) int, const int & %{ + get { + int ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) unsigned int, const unsigned int & %{ + get { + uint ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) long, const long & %{ + get { + int ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) unsigned long, const unsigned long & %{ + get { + uint ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) long long, const long long & %{ + get { + long ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) unsigned long long, const unsigned long long & %{ + get { + ulong ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) float, const float & %{ + get { + float ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) double, const double & %{ + get { + double ret = $imcall;$excode + return ret; + } %} + + +%typemap(csvarout, excode=SWIGEXCODE2) char *, char[ANY], char[] %{ + get { + string ret = $imcall;$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) void %{ + get { + $imcall;$excode + } %} +%typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE %{ + get { + $&csclassname ret = new $&csclassname($imcall, true);$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE & %{ + get { + $csclassname ret = new $csclassname($imcall, $owner);$excode + return ret; + } %} +%typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE *, SWIGTYPE [] %{ + get { + IntPtr cPtr = $imcall; + $csclassname ret = (cPtr == IntPtr.Zero) ? null : new $csclassname(cPtr, $owner);$excode + return ret; + } %} + +%typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE (CLASS::*) %{ + get { + string cMemberPtr = $imcall; + $csclassname ret = (cMemberPtr == null) ? null : new $csclassname(cMemberPtr, $owner);$excode + return ret; + } %} + +/* Pointer reference typemaps */ +%typemap(ctype) SWIGTYPE *& "void *" +%typemap(imtype, out="IntPtr") SWIGTYPE *& "HandleRef" +%typemap(cstype) SWIGTYPE *& "$*csclassname" +%typemap(csin) SWIGTYPE *& "$*csclassname.getCPtr($csinput)" +%typemap(csout, excode=SWIGEXCODE) SWIGTYPE *& { + IntPtr cPtr = $imcall; + $*csclassname ret = (cPtr == IntPtr.Zero) ? null : new $*csclassname(cPtr, $owner);$excode + return ret; + } +%typemap(in) SWIGTYPE *& ($*1_ltype temp = 0) +%{ temp = ($*1_ltype)$input; + $1 = &temp; %} +%typemap(out) SWIGTYPE *& +%{ $result = (void *)*$1; %} + +/* Array reference typemaps */ +%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } + +/* Typemaps used for the generation of proxy and type wrapper class code */ +%typemap(csbase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" +%typemap(csclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class" +%typemap(cscode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" +%typemap(csimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "\nusing System;\nusing System.Runtime.InteropServices;\n" +%typemap(csinterfaces) SWIGTYPE "IDisposable" +%typemap(csinterfaces) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" +%typemap(csinterfaces_derived) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" + +// Proxy classes (base classes, ie, not derived classes) +%typemap(csbody) SWIGTYPE %{ + private HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal $csclassname(IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new HandleRef(this, cPtr); + } + + internal static HandleRef getCPtr($csclassname obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +%} + +// Derived proxy classes +%typemap(csbody_derived) SWIGTYPE %{ + private HandleRef swigCPtr; + + internal $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclassnameUpcast(cPtr), cMemoryOwn) { + swigCPtr = new HandleRef(this, cPtr); + } + + internal static HandleRef getCPtr($csclassname obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +%} + +// Typewrapper classes +%typemap(csbody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] %{ + private HandleRef swigCPtr; + + internal $csclassname(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected $csclassname() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr($csclassname obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +%} + +%typemap(csbody) SWIGTYPE (CLASS::*) %{ + private string swigCMemberPtr; + + internal $csclassname(string cMemberPtr, bool futureUse) { + swigCMemberPtr = cMemberPtr; + } + + protected $csclassname() { + swigCMemberPtr = null; + } + + internal static string getCMemberPtr($csclassname obj) { + return obj.swigCMemberPtr; + } +%} + +%typemap(csfinalize) SWIGTYPE %{ + ~$csclassname() { + Dispose(); + } +%} + +%typemap(csconstruct, excode=SWIGEXCODE,directorconnect="\n SwigDirectorConnect();") SWIGTYPE %{: this($imcall, true) {$excode$directorconnect + } +%} + +%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") SWIGTYPE { + lock(this) { + if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { + swigCMemOwn = false; + $imcall; + } + swigCPtr = new HandleRef(null, IntPtr.Zero); + GC.SuppressFinalize(this); + } + } + +%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") SWIGTYPE { + lock(this) { + if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { + swigCMemOwn = false; + $imcall; + } + swigCPtr = new HandleRef(null, IntPtr.Zero); + GC.SuppressFinalize(this); + base.Dispose(); + } + } + +%typemap(directordisconnect, methodname="swigDirectorDisconnect") SWIGTYPE %{ + protected void $methodname() { + swigCMemOwn = false; + $imcall; + } +%} + +/* C# specific directives */ +#define %csconst(flag) %feature("cs:const","flag") +#define %csconstvalue(value) %feature("cs:constvalue",value) +#define %csenum(wrapapproach) %feature("cs:enum","wrapapproach") +#define %csmethodmodifiers %feature("cs:methodmodifiers") +#define %csnothrowexception %feature("except") +#define %csattributes %feature("cs:attributes") + +%pragma(csharp) imclassclassmodifiers="class" +%pragma(csharp) moduleclassmodifiers="public class" + +%pragma(csharp) moduleimports=%{ +using System; +using System.Runtime.InteropServices; +%} + +%pragma(csharp) imclassimports=%{ +using System; +using System.Runtime.InteropServices; +%} + +/* Some ANSI C typemaps */ + +%apply unsigned long { size_t }; +%apply const unsigned long & { const size_t & }; + +/* csharp keywords */ +%include <csharpkw.swg> + +// Default enum handling +%include <enums.swg> + +/* +// Alternative char * typemaps. +%pragma(csharp) imclasscode=%{ + public class SWIGStringMarshal : IDisposable { + public readonly HandleRef swigCPtr; + public SWIGStringMarshal(string str) { + swigCPtr = new HandleRef(this, System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(str)); + } + public virtual void Dispose() { + System.Runtime.InteropServices.Marshal.FreeHGlobal(swigCPtr.Handle); + GC.SuppressFinalize(this); + } + } +%} + +%typemap(imtype, out="IntPtr") char *, char[ANY], char[] "HandleRef" +%typemap(out) char *, char[ANY], char[] %{ $result = $1; %} +%typemap(csin) char *, char[ANY], char[] "new $imclassname.SWIGStringMarshal($csinput).swigCPtr" +%typemap(csout, excode=SWIGEXCODE) char *, char[ANY], char[] { + string ret = System.Runtime.InteropServices.Marshal.PtrToStringAnsi($imcall);$excode + return ret; + } +%typemap(csvarin, excode=SWIGEXCODE2) char *, char[ANY], char[] %{ + set { + $imcall;$excode + } %} +%typemap(csvarout, excode=SWIGEXCODE2) char *, char[ANY], char[] %{ + get { + string ret = System.Runtime.InteropServices.Marshal.PtrToStringAnsi($imcall);$excode + return ret; + } %} +*/ + diff --git a/devtools/swigwin-1.3.34/Lib/csharp/csharphead.swg b/devtools/swigwin-1.3.34/Lib/csharp/csharphead.swg new file mode 100644 index 0000000..7938dee --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/csharp/csharphead.swg @@ -0,0 +1,329 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * csharphead.swg + * + * Support code for exceptions if the SWIG_CSHARP_NO_EXCEPTION_HELPER is not defined + * Support code for strings if the SWIG_CSHARP_NO_STRING_HELPER is not defined + * ----------------------------------------------------------------------------- */ + +%insert(runtime) %{ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +%} + +#if !defined(SWIG_CSHARP_NO_EXCEPTION_HELPER) +%insert(runtime) %{ +/* Support for throwing C# exceptions from C/C++. There are two types: + * Exceptions that take a message and ArgumentExceptions that take a message and a parameter name. */ +typedef enum { + SWIG_CSharpApplicationException, + SWIG_CSharpArithmeticException, + SWIG_CSharpDivideByZeroException, + SWIG_CSharpIndexOutOfRangeException, + SWIG_CSharpInvalidCastException, + SWIG_CSharpInvalidOperationException, + SWIG_CSharpIOException, + SWIG_CSharpNullReferenceException, + SWIG_CSharpOutOfMemoryException, + SWIG_CSharpOverflowException, + SWIG_CSharpSystemException +} SWIG_CSharpExceptionCodes; + +typedef enum { + SWIG_CSharpArgumentException, + SWIG_CSharpArgumentNullException, + SWIG_CSharpArgumentOutOfRangeException +} SWIG_CSharpExceptionArgumentCodes; + +typedef void (SWIGSTDCALL* SWIG_CSharpExceptionCallback_t)(const char *); +typedef void (SWIGSTDCALL* SWIG_CSharpExceptionArgumentCallback_t)(const char *, const char *); + +typedef struct { + SWIG_CSharpExceptionCodes code; + SWIG_CSharpExceptionCallback_t callback; +} SWIG_CSharpException_t; + +typedef struct { + SWIG_CSharpExceptionArgumentCodes code; + SWIG_CSharpExceptionArgumentCallback_t callback; +} SWIG_CSharpExceptionArgument_t; + +static SWIG_CSharpException_t SWIG_csharp_exceptions[] = { + { SWIG_CSharpApplicationException, NULL }, + { SWIG_CSharpArithmeticException, NULL }, + { SWIG_CSharpDivideByZeroException, NULL }, + { SWIG_CSharpIndexOutOfRangeException, NULL }, + { SWIG_CSharpInvalidCastException, NULL }, + { SWIG_CSharpInvalidOperationException, NULL }, + { SWIG_CSharpIOException, NULL }, + { SWIG_CSharpNullReferenceException, NULL }, + { SWIG_CSharpOutOfMemoryException, NULL }, + { SWIG_CSharpOverflowException, NULL }, + { SWIG_CSharpSystemException, NULL } +}; + +static SWIG_CSharpExceptionArgument_t SWIG_csharp_exceptions_argument[] = { + { SWIG_CSharpArgumentException, NULL }, + { SWIG_CSharpArgumentNullException, NULL }, + { SWIG_CSharpArgumentOutOfRangeException, NULL }, +}; + +static void SWIGUNUSED SWIG_CSharpSetPendingException(SWIG_CSharpExceptionCodes code, const char *msg) { + SWIG_CSharpExceptionCallback_t callback = SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback; + if (code >=0 && (size_t)code < sizeof(SWIG_csharp_exceptions)/sizeof(SWIG_CSharpException_t)) { + callback = SWIG_csharp_exceptions[code].callback; + } + callback(msg); +} + +static void SWIGUNUSED SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpExceptionArgumentCodes code, const char *msg, const char *param_name) { + SWIG_CSharpExceptionArgumentCallback_t callback = SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback; + if (code >=0 && (size_t)code < sizeof(SWIG_csharp_exceptions_argument)/sizeof(SWIG_CSharpExceptionArgument_t)) { + callback = SWIG_csharp_exceptions_argument[code].callback; + } + callback(msg, param_name); +} +%} + +%insert(runtime) %{ +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionCallbacks_$module( + SWIG_CSharpExceptionCallback_t applicationCallback, + SWIG_CSharpExceptionCallback_t arithmeticCallback, + SWIG_CSharpExceptionCallback_t divideByZeroCallback, + SWIG_CSharpExceptionCallback_t indexOutOfRangeCallback, + SWIG_CSharpExceptionCallback_t invalidCastCallback, + SWIG_CSharpExceptionCallback_t invalidOperationCallback, + SWIG_CSharpExceptionCallback_t ioCallback, + SWIG_CSharpExceptionCallback_t nullReferenceCallback, + SWIG_CSharpExceptionCallback_t outOfMemoryCallback, + SWIG_CSharpExceptionCallback_t overflowCallback, + SWIG_CSharpExceptionCallback_t systemCallback) { + SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback = applicationCallback; + SWIG_csharp_exceptions[SWIG_CSharpArithmeticException].callback = arithmeticCallback; + SWIG_csharp_exceptions[SWIG_CSharpDivideByZeroException].callback = divideByZeroCallback; + SWIG_csharp_exceptions[SWIG_CSharpIndexOutOfRangeException].callback = indexOutOfRangeCallback; + SWIG_csharp_exceptions[SWIG_CSharpInvalidCastException].callback = invalidCastCallback; + SWIG_csharp_exceptions[SWIG_CSharpInvalidOperationException].callback = invalidOperationCallback; + SWIG_csharp_exceptions[SWIG_CSharpIOException].callback = ioCallback; + SWIG_csharp_exceptions[SWIG_CSharpNullReferenceException].callback = nullReferenceCallback; + SWIG_csharp_exceptions[SWIG_CSharpOutOfMemoryException].callback = outOfMemoryCallback; + SWIG_csharp_exceptions[SWIG_CSharpOverflowException].callback = overflowCallback; + SWIG_csharp_exceptions[SWIG_CSharpSystemException].callback = systemCallback; +} + +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_$module( + SWIG_CSharpExceptionArgumentCallback_t argumentCallback, + SWIG_CSharpExceptionArgumentCallback_t argumentNullCallback, + SWIG_CSharpExceptionArgumentCallback_t argumentOutOfRangeCallback) { + SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback = argumentCallback; + SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentNullException].callback = argumentNullCallback; + SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentOutOfRangeException].callback = argumentOutOfRangeCallback; +} +%} + +%pragma(csharp) imclasscode=%{ + protected class SWIGExceptionHelper { + + public delegate void ExceptionDelegate(string message); + public delegate void ExceptionArgumentDelegate(string message, string paramName); + + static ExceptionDelegate applicationDelegate = new ExceptionDelegate(SetPendingApplicationException); + static ExceptionDelegate arithmeticDelegate = new ExceptionDelegate(SetPendingArithmeticException); + static ExceptionDelegate divideByZeroDelegate = new ExceptionDelegate(SetPendingDivideByZeroException); + static ExceptionDelegate indexOutOfRangeDelegate = new ExceptionDelegate(SetPendingIndexOutOfRangeException); + static ExceptionDelegate invalidCastDelegate = new ExceptionDelegate(SetPendingInvalidCastException); + static ExceptionDelegate invalidOperationDelegate = new ExceptionDelegate(SetPendingInvalidOperationException); + static ExceptionDelegate ioDelegate = new ExceptionDelegate(SetPendingIOException); + static ExceptionDelegate nullReferenceDelegate = new ExceptionDelegate(SetPendingNullReferenceException); + static ExceptionDelegate outOfMemoryDelegate = new ExceptionDelegate(SetPendingOutOfMemoryException); + static ExceptionDelegate overflowDelegate = new ExceptionDelegate(SetPendingOverflowException); + static ExceptionDelegate systemDelegate = new ExceptionDelegate(SetPendingSystemException); + + static ExceptionArgumentDelegate argumentDelegate = new ExceptionArgumentDelegate(SetPendingArgumentException); + static ExceptionArgumentDelegate argumentNullDelegate = new ExceptionArgumentDelegate(SetPendingArgumentNullException); + static ExceptionArgumentDelegate argumentOutOfRangeDelegate = new ExceptionArgumentDelegate(SetPendingArgumentOutOfRangeException); + + [DllImport("$dllimport", EntryPoint="SWIGRegisterExceptionCallbacks_$module")] + public static extern void SWIGRegisterExceptionCallbacks_$module( + ExceptionDelegate applicationDelegate, + ExceptionDelegate arithmeticDelegate, + ExceptionDelegate divideByZeroDelegate, + ExceptionDelegate indexOutOfRangeDelegate, + ExceptionDelegate invalidCastDelegate, + ExceptionDelegate invalidOperationDelegate, + ExceptionDelegate ioDelegate, + ExceptionDelegate nullReferenceDelegate, + ExceptionDelegate outOfMemoryDelegate, + ExceptionDelegate overflowDelegate, + ExceptionDelegate systemExceptionDelegate); + + [DllImport("$dllimport", EntryPoint="SWIGRegisterExceptionArgumentCallbacks_$module")] + public static extern void SWIGRegisterExceptionCallbacksArgument_$module( + ExceptionArgumentDelegate argumentDelegate, + ExceptionArgumentDelegate argumentNullDelegate, + ExceptionArgumentDelegate argumentOutOfRangeDelegate); + + static void SetPendingApplicationException(string message) { + SWIGPendingException.Set(new System.ApplicationException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingArithmeticException(string message) { + SWIGPendingException.Set(new System.ArithmeticException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingDivideByZeroException(string message) { + SWIGPendingException.Set(new System.DivideByZeroException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingIndexOutOfRangeException(string message) { + SWIGPendingException.Set(new System.IndexOutOfRangeException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingInvalidCastException(string message) { + SWIGPendingException.Set(new System.InvalidCastException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingInvalidOperationException(string message) { + SWIGPendingException.Set(new System.InvalidOperationException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingIOException(string message) { + SWIGPendingException.Set(new System.IO.IOException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingNullReferenceException(string message) { + SWIGPendingException.Set(new System.NullReferenceException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingOutOfMemoryException(string message) { + SWIGPendingException.Set(new System.OutOfMemoryException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingOverflowException(string message) { + SWIGPendingException.Set(new System.OverflowException(message, SWIGPendingException.Retrieve())); + } + static void SetPendingSystemException(string message) { + SWIGPendingException.Set(new System.SystemException(message, SWIGPendingException.Retrieve())); + } + + static void SetPendingArgumentException(string message, string paramName) { + SWIGPendingException.Set(new System.ArgumentException(message, paramName, SWIGPendingException.Retrieve())); + } + static void SetPendingArgumentNullException(string message, string paramName) { + Exception e = SWIGPendingException.Retrieve(); + if (e != null) message = message + " Inner Exception: " + e.Message; + SWIGPendingException.Set(new System.ArgumentNullException(paramName, message)); + } + static void SetPendingArgumentOutOfRangeException(string message, string paramName) { + Exception e = SWIGPendingException.Retrieve(); + if (e != null) message = message + " Inner Exception: " + e.Message; + SWIGPendingException.Set(new System.ArgumentOutOfRangeException(paramName, message)); + } + + static SWIGExceptionHelper() { + SWIGRegisterExceptionCallbacks_$module( + applicationDelegate, + arithmeticDelegate, + divideByZeroDelegate, + indexOutOfRangeDelegate, + invalidCastDelegate, + invalidOperationDelegate, + ioDelegate, + nullReferenceDelegate, + outOfMemoryDelegate, + overflowDelegate, + systemDelegate); + + SWIGRegisterExceptionCallbacksArgument_$module( + argumentDelegate, + argumentNullDelegate, + argumentOutOfRangeDelegate); + } + } + + protected static SWIGExceptionHelper swigExceptionHelper = new SWIGExceptionHelper(); + + public class SWIGPendingException { + [ThreadStatic] + private static Exception pendingException = null; + private static int numExceptionsPending = 0; + + public static bool Pending { + get { + bool pending = false; + if (numExceptionsPending > 0) + if (pendingException != null) + pending = true; + return pending; + } + } + + public static void Set(Exception e) { + if (pendingException != null) + throw new ApplicationException("FATAL: An earlier pending exception from unmanaged code was missed and thus not thrown (" + pendingException.ToString() + ")", e); + pendingException = e; + lock(typeof($imclassname)) { + numExceptionsPending++; + } + } + + public static Exception Retrieve() { + Exception e = null; + if (numExceptionsPending > 0) { + if (pendingException != null) { + e = pendingException; + pendingException = null; + lock(typeof($imclassname)) { + numExceptionsPending--; + } + } + } + return e; + } + } +%} +#endif // SWIG_CSHARP_NO_EXCEPTION_HELPER + +#if !defined(SWIG_CSHARP_NO_STRING_HELPER) +%insert(runtime) %{ +/* Callback for returning strings to C# without leaking memory */ +typedef char * (SWIGSTDCALL* SWIG_CSharpStringHelperCallback)(const char *); +static SWIG_CSharpStringHelperCallback SWIG_csharp_string_callback = NULL; +%} + +%pragma(csharp) imclasscode=%{ + protected class SWIGStringHelper { + + public delegate string SWIGStringDelegate(string message); + static SWIGStringDelegate stringDelegate = new SWIGStringDelegate(CreateString); + + [DllImport("$dllimport", EntryPoint="SWIGRegisterStringCallback_$module")] + public static extern void SWIGRegisterStringCallback_$module(SWIGStringDelegate stringDelegate); + + static string CreateString(string cString) { + return cString; + } + + static SWIGStringHelper() { + SWIGRegisterStringCallback_$module(stringDelegate); + } + } + + static protected SWIGStringHelper swigStringHelper = new SWIGStringHelper(); +%} + +%insert(runtime) %{ +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void SWIGSTDCALL SWIGRegisterStringCallback_$module(SWIG_CSharpStringHelperCallback callback) { + SWIG_csharp_string_callback = callback; +} +%} +#endif // SWIG_CSHARP_NO_STRING_HELPER + +%insert(runtime) %{ +/* Contract support */ + +#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentOutOfRangeException, msg, ""); return nullreturn; } else +%} diff --git a/devtools/swigwin-1.3.34/Lib/csharp/csharpkw.swg b/devtools/swigwin-1.3.34/Lib/csharp/csharpkw.swg new file mode 100644 index 0000000..c96042d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/csharp/csharpkw.swg @@ -0,0 +1,94 @@ +#ifndef CSHARP_CSHARPKW_SWG_ +#define CSHARP_CSHARPKW_SWG_ + +/* Warnings for C# keywords */ +#define CSHARPKW(x) %namewarn("314:" #x " is a csharp keyword") #x + +/* + from + http://www.jaggersoft.com/csharp_grammar.html#1.7%20Keywords + +*/ + +CSHARPKW(abstract); +CSHARPKW(as); +CSHARPKW(base); +CSHARPKW(bool); +CSHARPKW(break); +CSHARPKW(byte); +CSHARPKW(case); +CSHARPKW(catch); +CSHARPKW(char); +CSHARPKW(checked); +CSHARPKW(class); +CSHARPKW(const); +CSHARPKW(continue); +CSHARPKW(decimal); +CSHARPKW(default); +CSHARPKW(delegate); +CSHARPKW(do); +CSHARPKW(double); +CSHARPKW(else); +CSHARPKW(enum); +CSHARPKW(event); +CSHARPKW(explicit); +CSHARPKW(extern); +CSHARPKW(false); +CSHARPKW(finally); +CSHARPKW(fixed); +CSHARPKW(float); +CSHARPKW(for); +CSHARPKW(foreach); +CSHARPKW(goto); +CSHARPKW(if); +CSHARPKW(implicit); +CSHARPKW(in); +CSHARPKW(int); +CSHARPKW(interface); +CSHARPKW(internal); +CSHARPKW(is); +CSHARPKW(lock); +CSHARPKW(long); +CSHARPKW(namespace); +CSHARPKW(new); +CSHARPKW(null); +CSHARPKW(object); +CSHARPKW(operator); +CSHARPKW(out); +CSHARPKW(override); +CSHARPKW(params); +CSHARPKW(private); +CSHARPKW(protected); +CSHARPKW(public); +CSHARPKW(readonly); +CSHARPKW(ref); +CSHARPKW(return); +CSHARPKW(sbyte); +CSHARPKW(sealed); +CSHARPKW(short); +CSHARPKW(sizeof); +CSHARPKW(stackalloc); +CSHARPKW(static); +CSHARPKW(struct); +CSHARPKW(string); +CSHARPKW(switch); +CSHARPKW(this); +CSHARPKW(throw); +CSHARPKW(true); +CSHARPKW(try); +CSHARPKW(typeof); +CSHARPKW(uint); +CSHARPKW(ulong); +CSHARPKW(unchecked); +CSHARPKW(unsafe); +CSHARPKW(ushort); +CSHARPKW(using); +CSHARPKW(virtual); +CSHARPKW(void); +CSHARPKW(volatile); +CSHARPKW(while); + + +#undef CSHARPKW + +#endif //CSHARP_CSHARPKW_SWG_ diff --git a/devtools/swigwin-1.3.34/Lib/csharp/director.swg b/devtools/swigwin-1.3.34/Lib/csharp/director.swg new file mode 100644 index 0000000..8957ecf --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/csharp/director.swg @@ -0,0 +1,50 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * director.swg + * + * This file contains support for director classes so that C# proxy + * methods can be called from C++. + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus + +#if defined(DEBUG_DIRECTOR_OWNED) +#include <iostream> +#endif +#include <string> + +namespace Swig { + /* Director base class - not currently used in C# directors */ + class Director { + }; + + /* Base class for director exceptions */ + class DirectorException { + protected: + std::string swig_msg; + + public: + DirectorException(const char* msg) : swig_msg(msg) { + } + DirectorException(const std::string &msg) : swig_msg(msg) { + } + const std::string& what() const { + return swig_msg; + } + virtual ~DirectorException() { + } + }; + + /* Pure virtual method exception */ + class DirectorPureVirtualException : public Swig::DirectorException { + public: + DirectorPureVirtualException(const char* msg) : DirectorException(std::string("Attempt to invoke pure virtual method ") + msg) { + } + }; +} + +#endif /* __cplusplus */ + + diff --git a/devtools/swigwin-1.3.34/Lib/csharp/enums.swg b/devtools/swigwin-1.3.34/Lib/csharp/enums.swg new file mode 100644 index 0000000..be2a606 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/csharp/enums.swg @@ -0,0 +1,89 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * enums.swg + * + * Include this file in order for C/C++ enums to be wrapped by proper C# enums. + * Note that the PINVOKE layer handles the enum as an int. + * ----------------------------------------------------------------------------- */ + +// const enum SWIGTYPE & typemaps +%typemap(ctype) const enum SWIGTYPE & "int" +%typemap(imtype) const enum SWIGTYPE & "int" +%typemap(cstype) const enum SWIGTYPE & "$*csclassname" + +%typemap(in) const enum SWIGTYPE & ($*1_ltype temp) +%{ temp = ($*1_ltype)$input; + $1 = &temp; %} +%typemap(out) const enum SWIGTYPE & %{ $result = *$1; %} + +%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & +%{ static $*1_ltype temp = ($*1_ltype)$input; + $result = &temp; %} +%typemap(directorin) const enum SWIGTYPE & "$input = $1_name;" +%typemap(csdirectorin) const enum SWIGTYPE & "($*csclassname)$iminput" +%typemap(csdirectorout) const enum SWIGTYPE & "(int)$cscall" + +%typecheck(SWIG_TYPECHECK_POINTER) const enum SWIGTYPE & "" + +%typemap(throws, canthrow=1) const enum SWIGTYPE & +%{ (void)$1; + SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); + return $null; %} + +%typemap(csin) const enum SWIGTYPE & "(int)$csinput" +%typemap(csout, excode=SWIGEXCODE) const enum SWIGTYPE & { + $*csclassname ret = ($*csclassname)$imcall;$excode + return ret; + } + +%typemap(csvarout, excode=SWIGEXCODE2) const enum SWIGTYPE & %{ + get { + $*csclassname ret = ($*csclassname)$imcall;$excode + return ret; + } %} + + +// enum SWIGTYPE typemaps +%typemap(ctype) enum SWIGTYPE "int" +%typemap(imtype) enum SWIGTYPE "int" +%typemap(cstype) enum SWIGTYPE "$csclassname" + +%typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} +%typemap(out) enum SWIGTYPE %{ $result = $1; %} + +%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} +%typemap(directorin) enum SWIGTYPE "$input = $1;" +%typemap(csdirectorin) enum SWIGTYPE "($csclassname)$iminput" +%typemap(csdirectorout) enum SWIGTYPE "(int)$cscall" + +%typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE "" + +%typemap(throws, canthrow=1) enum SWIGTYPE +%{ (void)$1; + SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); + return $null; %} + +%typemap(csin) enum SWIGTYPE "(int)$csinput" +%typemap(csout, excode=SWIGEXCODE) enum SWIGTYPE { + $csclassname ret = ($csclassname)$imcall;$excode + return ret; + } + +%typemap(csvarout, excode=SWIGEXCODE2) enum SWIGTYPE %{ + get { + $csclassname ret = ($csclassname)$imcall;$excode + return ret; + } %} + +%typemap(csbase) enum SWIGTYPE "" +%typemap(csclassmodifiers) enum SWIGTYPE "public enum" +%typemap(cscode) enum SWIGTYPE "" +%typemap(csimports) enum SWIGTYPE "" +%typemap(csinterfaces) enum SWIGTYPE "" + +%typemap(csbody) enum SWIGTYPE "" + +%csenum(proper); + diff --git a/devtools/swigwin-1.3.34/Lib/csharp/enumsimple.swg b/devtools/swigwin-1.3.34/Lib/csharp/enumsimple.swg new file mode 100644 index 0000000..f508498 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/csharp/enumsimple.swg @@ -0,0 +1,91 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * enumsimple.swg + * + * This file provides backwards compatible enum wrapping. SWIG versions 1.3.21 + * and earlier wrapped global enums with constant integers in the module + * class. Enums declared within a C++ class were wrapped by constant integers + * in the C# proxy class. + * ----------------------------------------------------------------------------- */ + +// const enum SWIGTYPE & typemaps +%typemap(ctype) const enum SWIGTYPE & "int" +%typemap(imtype) const enum SWIGTYPE & "int" +%typemap(cstype) const enum SWIGTYPE & "int" + +%typemap(in) const enum SWIGTYPE & ($*1_ltype temp) +%{ temp = ($*1_ltype)$input; + $1 = &temp; %} +%typemap(out) const enum SWIGTYPE & %{ $result = *$1; %} + +%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & +%{ static $*1_ltype temp = ($*1_ltype)$input; + $result = &temp; %} +%typemap(directorin) const enum SWIGTYPE & "$input = $1_name;" +%typemap(csdirectorin) const enum SWIGTYPE & "$iminput" +%typemap(csdirectorout) const enum SWIGTYPE & "$cscall" + +%typecheck(SWIG_TYPECHECK_INT32) const enum SWIGTYPE & "" + +%typemap(throws, canthrow=1) const enum SWIGTYPE & +%{ (void)$1; + SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); + return $null; %} + +%typemap(csin) const enum SWIGTYPE & "$csinput" +%typemap(csout, excode=SWIGEXCODE) const enum SWIGTYPE & { + int ret = $imcall;$excode + return ret; + } + +%typemap(csvarout, excode=SWIGEXCODE2) const enum SWIGTYPE & %{ + get { + int ret = $imcall;$excode + return ret; + } %} + + +// enum SWIGTYPE typemaps +%typemap(ctype) enum SWIGTYPE "int" +%typemap(imtype) enum SWIGTYPE "int" +%typemap(cstype) enum SWIGTYPE "int" + +%typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} +%typemap(out) enum SWIGTYPE %{ $result = $1; %} + +%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} +%typemap(directorin) enum SWIGTYPE "$input = $1;" +%typemap(csdirectorin) enum SWIGTYPE "$iminput" +%typemap(csdirectorout) enum SWIGTYPE "$cscall" + +%typecheck(SWIG_TYPECHECK_INT32) enum SWIGTYPE "" + +%typemap(throws, canthrow=1) enum SWIGTYPE +%{ (void)$1; + SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); + return $null; %} + +%typemap(csin) enum SWIGTYPE "$csinput" +%typemap(csout, excode=SWIGEXCODE) enum SWIGTYPE { + int ret = $imcall;$excode + return ret; + } + +%typemap(csvarout, excode=SWIGEXCODE2) enum SWIGTYPE %{ + get { + int ret = $imcall;$excode + return ret; + } %} + +%typemap(csbase) enum SWIGTYPE "" +%typemap(csclassmodifiers) enum SWIGTYPE "" +%typemap(cscode) enum SWIGTYPE "" +%typemap(csimports) enum SWIGTYPE "" +%typemap(csinterfaces) enum SWIGTYPE "" + +%typemap(csbody) enum SWIGTYPE "" + +%csenum(simple); + diff --git a/devtools/swigwin-1.3.34/Lib/csharp/enumtypesafe.swg b/devtools/swigwin-1.3.34/Lib/csharp/enumtypesafe.swg new file mode 100644 index 0000000..8ba7838 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/csharp/enumtypesafe.swg @@ -0,0 +1,133 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * enumtypesafe.swg + * + * Include this file in order for C/C++ enums to be wrapped by the so called + * typesafe enum pattern. Each enum has an equivalent C# class named after the + * enum and each enum item is a static instance of this class. + * ----------------------------------------------------------------------------- */ + +// const enum SWIGTYPE & typemaps +%typemap(ctype) const enum SWIGTYPE & "int" +%typemap(imtype) const enum SWIGTYPE & "int" +%typemap(cstype) const enum SWIGTYPE & "$*csclassname" + +%typemap(in) const enum SWIGTYPE & ($*1_ltype temp) +%{ temp = ($*1_ltype)$input; + $1 = &temp; %} +%typemap(out) const enum SWIGTYPE & %{ $result = *$1; %} + +%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & +%{ static $*1_ltype temp = ($*1_ltype)$input; + $result = &temp; %} +%typemap(directorin) const enum SWIGTYPE & "$input = $1_name;" +%typemap(csdirectorin) const enum SWIGTYPE & "$*csclassname.swigToEnum($iminput)" +%typemap(csdirectorout) const enum SWIGTYPE & "$cscall.swigValue" + +%typecheck(SWIG_TYPECHECK_POINTER) const enum SWIGTYPE & "" + +%typemap(throws, canthrow=1) const enum SWIGTYPE & +%{ (void)$1; + SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); + return $null; %} + +%typemap(csin) const enum SWIGTYPE & "$csinput.swigValue" +%typemap(csout, excode=SWIGEXCODE) const enum SWIGTYPE & { + $*csclassname ret = $*csclassname.swigToEnum($imcall);$excode + return ret; + } + +%typemap(csvarout, excode=SWIGEXCODE2) const enum SWIGTYPE & %{ + get { + $*csclassname ret = $*csclassname.swigToEnum($imcall);$excode + return ret; + } %} + + +// enum SWIGTYPE typemaps +%typemap(ctype) enum SWIGTYPE "int" +%typemap(imtype) enum SWIGTYPE "int" +%typemap(cstype) enum SWIGTYPE "$csclassname" + +%typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} +%typemap(out) enum SWIGTYPE %{ $result = $1; %} + +%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} +%typemap(directorin) enum SWIGTYPE "$input = $1;" +%typemap(csdirectorin) enum SWIGTYPE "$csclassname.swigToEnum($iminput)" +%typemap(csdirectorout) enum SWIGTYPE "$cscall.swigValue" + +%typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE "" + +%typemap(throws, canthrow=1) enum SWIGTYPE +%{ (void)$1; + SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); + return $null; %} + +%typemap(csin) enum SWIGTYPE "$csinput.swigValue" +%typemap(csout, excode=SWIGEXCODE) enum SWIGTYPE { + $csclassname ret = $csclassname.swigToEnum($imcall);$excode + return ret; + } + +%typemap(csvarout, excode=SWIGEXCODE2) enum SWIGTYPE %{ + get { + $csclassname ret = $csclassname.swigToEnum($imcall);$excode + return ret; + } %} + +%typemap(csbase) enum SWIGTYPE "" +%typemap(csclassmodifiers) enum SWIGTYPE "public sealed class" +%typemap(cscode) enum SWIGTYPE "" +%typemap(csimports) enum SWIGTYPE "" +%typemap(csinterfaces) enum SWIGTYPE "" + +/* + * The swigToEnum method is used to find the C# enum from a C++ enum integer value. The default one here takes + * advantage of the fact that most enums do not have initial values specified, so the lookup is fast. If initial + * values are specified then a lengthy linear search through all possible enums might occur. Specific typemaps could be + * written to possibly optimise this lookup by taking advantage of characteristics peculiar to the targeted enum. + * The special variable, $enumvalues, is replaced with a comma separated list of all the enum values. + */ +%typemap(csbody) enum SWIGTYPE %{ + public readonly int swigValue; + + public static $csclassname swigToEnum(int swigValue) { + if (swigValue < swigValues.Length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue) + return swigValues[swigValue]; + for (int i = 0; i < swigValues.Length; i++) + if (swigValues[i].swigValue == swigValue) + return swigValues[i]; + throw new System.ArgumentOutOfRangeException("No enum $csclassname with value " + swigValue); + } + + public override string ToString() { + return swigName; + } + + private $csclassname(string swigName) { + this.swigName = swigName; + this.swigValue = swigNext++; + } + + private $csclassname(string swigName, int swigValue) { + this.swigName = swigName; + this.swigValue = swigValue; + swigNext = swigValue+1; + } + + private $csclassname(string swigName, $csclassname swigEnum) { + this.swigName = swigName; + this.swigValue = swigEnum.swigValue; + swigNext = this.swigValue+1; + } + + private static $csclassname[] swigValues = { $enumvalues }; + private static int swigNext = 0; + private readonly string swigName; +%} + +%csenum(typesafe); + diff --git a/devtools/swigwin-1.3.34/Lib/csharp/std_common.i b/devtools/swigwin-1.3.34/Lib/csharp/std_common.i new file mode 100644 index 0000000..cee11e8 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/csharp/std_common.i @@ -0,0 +1,5 @@ +%include <std_except.i> + +%apply size_t { std::size_t }; +%apply const size_t& { const std::size_t& }; + diff --git a/devtools/swigwin-1.3.34/Lib/csharp/std_deque.i b/devtools/swigwin-1.3.34/Lib/csharp/std_deque.i new file mode 100644 index 0000000..cb98f6c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/csharp/std_deque.i @@ -0,0 +1 @@ +%include <std/_std_deque.i> diff --git a/devtools/swigwin-1.3.34/Lib/csharp/std_except.i b/devtools/swigwin-1.3.34/Lib/csharp/std_except.i new file mode 100644 index 0000000..c86e97a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/csharp/std_except.i @@ -0,0 +1,33 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_except.i + * + * Typemaps used by the STL wrappers that throw exceptions. These typemaps are + * used when methods are declared with an STL exception specification, such as + * size_t at() const throw (std::out_of_range); + * ----------------------------------------------------------------------------- */ + +%{ +#include <stdexcept> +%} + +namespace std +{ + %ignore exception; + struct exception {}; +} + +%typemap(throws, canthrow=1) std::bad_exception "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;" +%typemap(throws, canthrow=1) std::domain_error "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;" +%typemap(throws, canthrow=1) std::exception "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;" +%typemap(throws, canthrow=1) std::invalid_argument "SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentException, $1.what(), \"\");\n return $null;" +%typemap(throws, canthrow=1) std::length_error "SWIG_CSharpSetPendingException(SWIG_CSharpIndexOutOfRangeException, $1.what());\n return $null;" +%typemap(throws, canthrow=1) std::logic_error "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;" +%typemap(throws, canthrow=1) std::out_of_range "SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentOutOfRangeException, 0, $1.what());\n return $null;" +%typemap(throws, canthrow=1) std::overflow_error "SWIG_CSharpSetPendingException(SWIG_CSharpOverflowException, $1.what());\n return $null;" +%typemap(throws, canthrow=1) std::range_error "SWIG_CSharpSetPendingException(SWIG_CSharpIndexOutOfRangeException, $1.what());\n return $null;" +%typemap(throws, canthrow=1) std::runtime_error "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;" +%typemap(throws, canthrow=1) std::underflow_error "SWIG_CSharpSetPendingException(SWIG_CSharpOverflowException, $1.what());\n return $null;" + diff --git a/devtools/swigwin-1.3.34/Lib/csharp/std_map.i b/devtools/swigwin-1.3.34/Lib/csharp/std_map.i new file mode 100644 index 0000000..c35f21d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/csharp/std_map.i @@ -0,0 +1,175 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_map.i + * + * SWIG typemaps for std::map + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +// ------------------------------------------------------------------------ +// std::map +// ------------------------------------------------------------------------ + +%{ +#include <map> +#include <algorithm> +#include <stdexcept> +%} + +// exported class + +namespace std { + + template<class K, class T> class map { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T& get(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(const K& key, const T& x) { + (*self)[key] = x; + } + void del(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + + + // specializations for built-ins + + %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) + + template<class T> class map<K,T> { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T& get(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(K key, const T& x) { + (*self)[key] = x; + } + void del(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(K key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + %enddef + + %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) + template<class K> class map<K,T> { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T get(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(const K& key, T x) { + (*self)[key] = x; + } + void del(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + %enddef + + %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, + T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) + template<> class map<K,T> { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T get(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(K key, T x) { + (*self)[key] = x; + } + void del(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(K key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + %enddef + + // add specializations here + +} diff --git a/devtools/swigwin-1.3.34/Lib/csharp/std_pair.i b/devtools/swigwin-1.3.34/Lib/csharp/std_pair.i new file mode 100644 index 0000000..78142ff --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/csharp/std_pair.i @@ -0,0 +1,37 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_pair.i + * + * SWIG typemaps for std::pair + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <exception.i> + +// ------------------------------------------------------------------------ +// std::pair +// ------------------------------------------------------------------------ + +%{ +#include <utility> +%} + +namespace std { + + template<class T, class U> struct pair { + + pair(); + pair(T t, U u); + pair(const pair& p); + + template <class U1, class U2> pair(const pair<U1, U2> &p); + + T first; + U second; + }; + + // add specializations here + +} diff --git a/devtools/swigwin-1.3.34/Lib/csharp/std_string.i b/devtools/swigwin-1.3.34/Lib/csharp/std_string.i new file mode 100644 index 0000000..d296927 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/csharp/std_string.i @@ -0,0 +1,114 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_string.i + * + * Typemaps for std::string and const std::string& + * These are mapped to a C# String and are passed around by value. + * + * To use non-const std::string references use the following %apply. Note + * that they are passed by value. + * %apply const std::string & {std::string &}; + * ----------------------------------------------------------------------------- */ + +%{ +#include <string> +%} + +namespace std { + +%naturalvar string; + +class string; + +// string +%typemap(ctype) string "char *" +%typemap(imtype) string "string" +%typemap(cstype) string "string" + +%typemap(csdirectorin) string "$iminput" +%typemap(csdirectorout) string "$cscall" + +%typemap(in, canthrow=1) string +%{ if (!$input) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return $null; + } + $1.assign($input); %} +%typemap(out) string %{ $result = SWIG_csharp_string_callback($1.c_str()); %} + +%typemap(directorout, canthrow=1) string +%{ if (!$input) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return $null; + } + $result.assign($input); %} + +%typemap(directorin) string %{ $input = SWIG_csharp_string_callback($1.c_str()); %} + +%typemap(csin) string "$csinput" +%typemap(csout, excode=SWIGEXCODE) string { + string ret = $imcall;$excode + return ret; + } + +%typemap(typecheck) string = char *; + +%typemap(throws, canthrow=1) string +%{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str()); + return $null; %} + +// const string & +%typemap(ctype) const string & "char *" +%typemap(imtype) const string & "string" +%typemap(cstype) const string & "string" + +%typemap(csdirectorin) const string & "$iminput" +%typemap(csdirectorout) const string & "$cscall" + +%typemap(in, canthrow=1) const string & +%{ if (!$input) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return $null; + } + std::string $1_str($input); + $1 = &$1_str; %} +%typemap(out) const string & %{ $result = SWIG_csharp_string_callback($1->c_str()); %} + +%typemap(csin) const string & "$csinput" +%typemap(csout, excode=SWIGEXCODE) const string & { + string ret = $imcall;$excode + return ret; + } + +%typemap(directorout, canthrow=1, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string & +%{ if (!$input) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return $null; + } + /* possible thread/reentrant code problem */ + static std::string $1_str; + $1_str = $input; + $result = &$1_str; %} + +%typemap(directorin) const string & %{ $input = SWIG_csharp_string_callback($1.c_str()); %} + +%typemap(csvarin, excode=SWIGEXCODE2) const string & %{ + set { + $imcall;$excode + } %} +%typemap(csvarout, excode=SWIGEXCODE2) const string & %{ + get { + string ret = $imcall;$excode + return ret; + } %} + +%typemap(typecheck) const string & = char *; + +%typemap(throws, canthrow=1) const string & +%{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str()); + return $null; %} + +} + diff --git a/devtools/swigwin-1.3.34/Lib/csharp/std_vector.i b/devtools/swigwin-1.3.34/Lib/csharp/std_vector.i new file mode 100644 index 0000000..a04831f --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/csharp/std_vector.i @@ -0,0 +1,384 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_vector.i + * + * SWIG typemaps for std::vector + * C# implementation + * The C# wrapper is made to look and feel like a typesafe C# System.Collections.ArrayList + * All the methods in IList are defined, but we don't derive from IList as this is a typesafe collection. + * Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents! + * + * Very often the C# generated code will not compile as the C++ template type is not the same as the C# + * proxy type, so use the SWIG_STD_VECTOR_SPECIALIZE or SWIG_STD_VECTOR_SPECIALIZE_MINIMUM macro, eg + * + * SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(Klass, SomeNamespace::Klass) + * %template(VectKlass) std::vector<SomeNamespace::Klass>; + * ----------------------------------------------------------------------------- */ + +// Warning: Use the typemaps here in the expectation that the macros they are in will change name. + + +%include <std_common.i> + +// MACRO for use within the std::vector class body +// CSTYPE and CTYPE respectively correspond to the types in the cstype and ctype typemaps +%define SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE...) +%typemap(csinterfaces) std::vector<CTYPE > "IDisposable, System.Collections.IEnumerable"; +%typemap(cscode) std::vector<CTYPE > %{ + public $csclassname(System.Collections.ICollection c) : this() { + if (c == null) + throw new ArgumentNullException("c"); + foreach (CSTYPE element in c) { + this.Add(element); + } + } + + public bool IsFixedSize { + get { + return false; + } + } + + public bool IsReadOnly { + get { + return false; + } + } + + public CSTYPE this[int index] { + get { + return getitem(index); + } + set { + setitem(index, value); + } + } + + public int Capacity { + get { + return (int)capacity(); + } + set { + if (value < size()) + throw new ArgumentOutOfRangeException("Capacity"); + reserve((uint)value); + } + } + + public int Count { + get { + return (int)size(); + } + } + + public bool IsSynchronized { + get { + return false; + } + } + + public void CopyTo(System.Array array) { + CopyTo(0, array, 0, this.Count); + } + + public void CopyTo(System.Array array, int arrayIndex) { + CopyTo(0, array, arrayIndex, this.Count); + } + + public void CopyTo(int index, System.Array array, int arrayIndex, int count) { + if (array == null) + throw new ArgumentNullException("array"); + if (index < 0) + throw new ArgumentOutOfRangeException("index", "Value is less than zero"); + if (arrayIndex < 0) + throw new ArgumentOutOfRangeException("arrayIndex", "Value is less than zero"); + if (count < 0) + throw new ArgumentOutOfRangeException("count", "Value is less than zero"); + if (array.Rank > 1) + throw new ArgumentException("Multi dimensional array."); + if (index+count > this.Count || arrayIndex+count > array.Length) + throw new ArgumentException("Number of elements to copy is too large."); + for (int i=0; i<count; i++) + array.SetValue(getitemcopy(index+i), arrayIndex+i); + } + + // Type-safe version of IEnumerable.GetEnumerator + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { + return new $csclassnameEnumerator(this); + } + + public $csclassnameEnumerator GetEnumerator() { + return new $csclassnameEnumerator(this); + } + + // Type-safe enumerator + /// Note that the IEnumerator documentation requires an InvalidOperationException to be thrown + /// whenever the collection is modified. This has been done for changes in the size of the + /// collection but not when one of the elements of the collection is modified as it is a bit + /// tricky to detect unmanaged code that modifies the collection under our feet. + public sealed class $csclassnameEnumerator : System.Collections.IEnumerator { + private $csclassname collectionRef; + private int currentIndex; + private object currentObject; + private int currentSize; + + public $csclassnameEnumerator($csclassname collection) { + collectionRef = collection; + currentIndex = -1; + currentObject = null; + currentSize = collectionRef.Count; + } + + // Type-safe iterator Current + public CSTYPE Current { + get { + if (currentIndex == -1) + throw new InvalidOperationException("Enumeration not started."); + if (currentIndex > currentSize - 1) + throw new InvalidOperationException("Enumeration finished."); + if (currentObject == null) + throw new InvalidOperationException("Collection modified."); + return (CSTYPE)currentObject; + } + } + + // Type-unsafe IEnumerator.Current + object System.Collections.IEnumerator.Current { + get { + return Current; + } + } + + public bool MoveNext() { + int size = collectionRef.Count; + bool moveOkay = (currentIndex+1 < size) && (size == currentSize); + if (moveOkay) { + currentIndex++; + currentObject = collectionRef[currentIndex]; + } else { + currentObject = null; + } + return moveOkay; + } + + public void Reset() { + currentIndex = -1; + currentObject = null; + if (collectionRef.Count != currentSize) { + throw new InvalidOperationException("Collection modified."); + } + } + } +%} + + public: + typedef size_t size_type; + typedef CTYPE value_type; + typedef const value_type& const_reference; + %rename(Clear) clear; + void clear(); + %rename(Add) push_back; + void push_back(const value_type& x); + size_type size() const; + size_type capacity() const; + void reserve(size_type n); + %newobject GetRange(int index, int count); + %newobject Repeat(const value_type& value, int count); + vector(); + %extend { + vector(int capacity) throw (std::out_of_range) { + std::vector<CTYPE >* pv = 0; + if (capacity >= 0) { + pv = new std::vector<CTYPE >(); + pv->reserve(capacity); + } else { + throw std::out_of_range("capacity"); + } + return pv; + } + CTYPE getitemcopy(int index) throw (std::out_of_range) { + if (index>=0 && index<(int)self->size()) + return (*self)[index]; + else + throw std::out_of_range("index"); + } + const_reference getitem(int index) throw (std::out_of_range) { + if (index>=0 && index<(int)self->size()) + return (*self)[index]; + else + throw std::out_of_range("index"); + } + void setitem(int index, const value_type& val) throw (std::out_of_range) { + if (index>=0 && index<(int)self->size()) + (*self)[index] = val; + else + throw std::out_of_range("index"); + } + // Takes a deep copy of the elements unlike ArrayList.AddRange + void AddRange(const std::vector<CTYPE >& values) { + self->insert(self->end(), values.begin(), values.end()); + } + // Takes a deep copy of the elements unlike ArrayList.GetRange + std::vector<CTYPE > *GetRange(int index, int count) throw (std::out_of_range, std::invalid_argument) { + if (index < 0) + throw std::out_of_range("index"); + if (count < 0) + throw std::out_of_range("count"); + if (index >= (int)self->size()+1 || index+count > (int)self->size()) + throw std::invalid_argument("invalid range"); + return new std::vector<CTYPE >(self->begin()+index, self->begin()+index+count); + } + void Insert(int index, const value_type& x) throw (std::out_of_range) { + if (index>=0 && index<(int)self->size()+1) + self->insert(self->begin()+index, x); + else + throw std::out_of_range("index"); + } + // Takes a deep copy of the elements unlike ArrayList.InsertRange + void InsertRange(int index, const std::vector<CTYPE >& values) throw (std::out_of_range) { + if (index>=0 && index<(int)self->size()+1) + self->insert(self->begin()+index, values.begin(), values.end()); + else + throw std::out_of_range("index"); + } + void RemoveAt(int index) throw (std::out_of_range) { + if (index>=0 && index<(int)self->size()) + self->erase(self->begin() + index); + else + throw std::out_of_range("index"); + } + void RemoveRange(int index, int count) throw (std::out_of_range, std::invalid_argument) { + if (index < 0) + throw std::out_of_range("index"); + if (count < 0) + throw std::out_of_range("count"); + if (index >= (int)self->size()+1 || index+count > (int)self->size()) + throw std::invalid_argument("invalid range"); + self->erase(self->begin()+index, self->begin()+index+count); + } + static std::vector<CTYPE > *Repeat(const value_type& value, int count) throw (std::out_of_range) { + if (count < 0) + throw std::out_of_range("count"); + return new std::vector<CTYPE >(count, value); + } + void Reverse() { + std::reverse(self->begin(), self->end()); + } + void Reverse(int index, int count) throw (std::out_of_range, std::invalid_argument) { + if (index < 0) + throw std::out_of_range("index"); + if (count < 0) + throw std::out_of_range("count"); + if (index >= (int)self->size()+1 || index+count > (int)self->size()) + throw std::invalid_argument("invalid range"); + std::reverse(self->begin()+index, self->begin()+index+count); + } + // Takes a deep copy of the elements unlike ArrayList.SetRange + void SetRange(int index, const std::vector<CTYPE >& values) throw (std::out_of_range) { + if (index < 0) + throw std::out_of_range("index"); + if (index+values.size() > self->size()) + throw std::out_of_range("index"); + std::copy(values.begin(), values.end(), self->begin()+index); + } + } +%enddef + +// Extra methods added to the collection class if operator== is defined for the class being wrapped +// CSTYPE and CTYPE respectively correspond to the types in the cstype and ctype typemaps +%define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CSTYPE, CTYPE...) + %extend { + bool Contains(const value_type& value) { + return std::find(self->begin(), self->end(), value) != self->end(); + } + int IndexOf(const value_type& value) { + int index = -1; + std::vector<CTYPE >::iterator it = std::find(self->begin(), self->end(), value); + if (it != self->end()) + index = (int)(it - self->begin()); + return index; + } + int LastIndexOf(const value_type& value) { + int index = -1; + std::vector<CTYPE >::reverse_iterator rit = std::find(self->rbegin(), self->rend(), value); + if (rit != self->rend()) + index = (int)(self->rend() - 1 - rit); + return index; + } + void Remove(const value_type& value) { + std::vector<CTYPE >::iterator it = std::find(self->begin(), self->end(), value); + if (it != self->end()) + self->erase(it); + } + } +%enddef + +// Macros for std::vector class specializations +// CSTYPE and CTYPE respectively correspond to the types in the cstype and ctype typemaps +%define SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE...) +namespace std { + template<> class vector<CTYPE > { + SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE) + SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CSTYPE, CTYPE) + }; +} +%enddef + +%define SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(CSTYPE, CTYPE...) +namespace std { + template<> class vector<CTYPE > { + SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE) + }; +} +%enddef + + +%{ +#include <vector> +#include <algorithm> +#include <stdexcept> +%} + +%csmethodmodifiers std::vector::getitemcopy "private" +%csmethodmodifiers std::vector::getitem "private" +%csmethodmodifiers std::vector::setitem "private" +%csmethodmodifiers std::vector::size "private" +%csmethodmodifiers std::vector::capacity "private" +%csmethodmodifiers std::vector::reserve "private" + +namespace std { + // primary (unspecialized) class template for std::vector + // does not require operator== to be defined + template<class T> class vector { + SWIG_STD_VECTOR_MINIMUM(T, T) + }; + // specializations for pointers + template<class T> class vector<T*> { + SWIG_STD_VECTOR_MINIMUM(T, T*) + }; + template<class T> class vector<const T*> { + SWIG_STD_VECTOR_MINIMUM(T, const T*) + }; +} + +// template specializations for std::vector +// these provide extra collections methods as operator== is defined +SWIG_STD_VECTOR_SPECIALIZE(bool, bool) +SWIG_STD_VECTOR_SPECIALIZE(char, char) +SWIG_STD_VECTOR_SPECIALIZE(sbyte, signed char) +SWIG_STD_VECTOR_SPECIALIZE(byte, unsigned char) +SWIG_STD_VECTOR_SPECIALIZE(short, short) +SWIG_STD_VECTOR_SPECIALIZE(ushort, unsigned short) +SWIG_STD_VECTOR_SPECIALIZE(int, int) +SWIG_STD_VECTOR_SPECIALIZE(uint, unsigned int) +SWIG_STD_VECTOR_SPECIALIZE(int, long) +SWIG_STD_VECTOR_SPECIALIZE(uint, unsigned long) +SWIG_STD_VECTOR_SPECIALIZE(long, long long) +SWIG_STD_VECTOR_SPECIALIZE(ulong, unsigned long long) +SWIG_STD_VECTOR_SPECIALIZE(float, float) +SWIG_STD_VECTOR_SPECIALIZE(double, double) +SWIG_STD_VECTOR_SPECIALIZE(string, std::string) // also requires a %include <std_string.i> + + diff --git a/devtools/swigwin-1.3.34/Lib/csharp/std_wstring.i b/devtools/swigwin-1.3.34/Lib/csharp/std_wstring.i new file mode 100644 index 0000000..938070e --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/csharp/std_wstring.i @@ -0,0 +1,117 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_wstring.i + * + * Typemaps for std::wstring and const std::wstring& + * These are mapped to a C# String and are passed around by value. + * + * To use non-const std::wstring references use the following %apply. Note + * that they are passed by value. + * %apply const std::wstring & {std::wstring &}; + * ----------------------------------------------------------------------------- */ + +%include <wchar.i> + +%{ +#include <string> +%} + +namespace std { + +%naturalvar wstring; + +class wstring; + +// wstring +%typemap(ctype, out="void *") wstring "wchar_t *" +%typemap(imtype, inattributes="[MarshalAs(UnmanagedType.LPWStr)]") wstring "string" +%typemap(cstype) wstring "string" +%typemap(csdirectorin) wstring "$iminput" +%typemap(csdirectorout) wstring "$cscall" + +%typemap(in, canthrow=1) wstring +%{ if (!$input) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0); + return $null; + } + $1.assign($input); %} +%typemap(out) wstring %{ $result = SWIG_csharp_wstring_callback($1.c_str()); %} + +%typemap(directorout, canthrow=1) wstring +%{ if (!$input) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0); + return $null; + } + $result.assign($input); %} + +%typemap(directorin) wstring %{ $input = SWIG_csharp_wstring_callback($1.c_str()); %} + +%typemap(csin) wstring "$csinput" +%typemap(csout, excode=SWIGEXCODE) wstring { + string ret = $imcall;$excode + return ret; + } + +%typemap(typecheck) wstring = wchar_t *; + +%typemap(throws, canthrow=1) wstring +%{ std::string message($1.begin(), $1.end()); + SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, message.c_str()); + return $null; %} + +// const wstring & +%typemap(ctype, out="void *") const wstring & "wchar_t *" +%typemap(imtype, inattributes="[MarshalAs(UnmanagedType.LPWStr)]") const wstring & "string" +%typemap(cstype) const wstring & "string" + +%typemap(csdirectorin) const wstring & "$iminput" +%typemap(csdirectorout) const wstring & "$cscall" + +%typemap(in, canthrow=1) const wstring & +%{ if (!$input) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0); + return $null; + } + std::wstring $1_str($input); + $1 = &$1_str; %} +%typemap(out) const wstring & %{ $result = SWIG_csharp_wstring_callback($1->c_str()); %} + +%typemap(csin) const wstring & "$csinput" +%typemap(csout, excode=SWIGEXCODE) const wstring & { + string ret = $imcall;$excode + return ret; + } + +%typemap(directorout, canthrow=1, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const wstring & +%{ if (!$input) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0); + return $null; + } + /* possible thread/reentrant code problem */ + static std::wstring $1_str; + $1_str = $input; + $result = &$1_str; %} + +%typemap(directorin) const wstring & %{ $input = SWIG_csharp_wstring_callback($1.c_str()); %} + +%typemap(csvarin, excode=SWIGEXCODE2) const wstring & %{ + set { + $imcall;$excode + } %} +%typemap(csvarout, excode=SWIGEXCODE2) const wstring & %{ + get { + string ret = $imcall;$excode + return ret; + } %} + +%typemap(typecheck) const wstring & = wchar_t *; + +%typemap(throws, canthrow=1) const wstring & +%{ std::string message($1.begin(), $1.end()); + SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, message.c_str()); + return $null; %} + +} + diff --git a/devtools/swigwin-1.3.34/Lib/csharp/stl.i b/devtools/swigwin-1.3.34/Lib/csharp/stl.i new file mode 100644 index 0000000..66b72e0 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/csharp/stl.i @@ -0,0 +1,15 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * stl.i + * + * Initial STL definition. extended as needed in each language + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <std_string.i> +%include <std_vector.i> +%include <std_map.i> +%include <std_pair.i> + diff --git a/devtools/swigwin-1.3.34/Lib/csharp/typemaps.i b/devtools/swigwin-1.3.34/Lib/csharp/typemaps.i new file mode 100644 index 0000000..ddfbd1b --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/csharp/typemaps.i @@ -0,0 +1,291 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * typemaps.i + * + * Pointer and reference handling typemap library + * + * These mappings provide support for input/output arguments and common + * uses for C/C++ pointers and C++ references. + * ----------------------------------------------------------------------------- */ + +/* +INPUT typemaps +-------------- + +These typemaps are used for pointer/reference parameters that are input only +and are mapped to a C# input parameter. + +The following typemaps can be applied to turn a pointer or reference into a simple +input value. That is, instead of passing a pointer or reference to an object, +you would use a real value instead. + + bool *INPUT, bool &INPUT + signed char *INPUT, signed char &INPUT + unsigned char *INPUT, unsigned char &INPUT + short *INPUT, short &INPUT + unsigned short *INPUT, unsigned short &INPUT + int *INPUT, int &INPUT + unsigned int *INPUT, unsigned int &INPUT + long *INPUT, long &INPUT + unsigned long *INPUT, unsigned long &INPUT + long long *INPUT, long long &INPUT + unsigned long long *INPUT, unsigned long long &INPUT + float *INPUT, float &INPUT + double *INPUT, double &INPUT + +To use these, suppose you had a C function like this : + + double fadd(double *a, double *b) { + return *a+*b; + } + +You could wrap it with SWIG as follows : + + %include <typemaps.i> + double fadd(double *INPUT, double *INPUT); + +or you can use the %apply directive : + + %include <typemaps.i> + %apply double *INPUT { double *a, double *b }; + double fadd(double *a, double *b); + +In C# you could then use it like this: + double answer = modulename.fadd(10.0, 20.0); + +*/ + +%define INPUT_TYPEMAP(TYPE, CTYPE, CSTYPE) +%typemap(ctype) TYPE *INPUT, TYPE &INPUT "CTYPE" +%typemap(imtype) TYPE *INPUT, TYPE &INPUT "CSTYPE" +%typemap(cstype) TYPE *INPUT, TYPE &INPUT "CSTYPE" +%typemap(csin) TYPE *INPUT, TYPE &INPUT "$csinput" +%typemap(csdirectorin) TYPE *INPUT, TYPE &INPUT "$iminput" +%typemap(csdirectorout) TYPE *INPUT, TYPE &INPUT "$cscall" + +%typemap(in) TYPE *INPUT, TYPE &INPUT +%{ $1 = ($1_ltype)&$input; %} + +%typemap(directorout) TYPE *INPUT, TYPE &INPUT +%{ $result = ($1_ltype)&$input; %} + +%typemap(directorin) TYPE &INPUT +%{ $input = (CTYPE *)$1; %} + +%typemap(directorin) TYPE *INPUT +%{ $input = (CTYPE *)$1; %} + +%typemap(typecheck) TYPE *INPUT = TYPE; +%typemap(typecheck) TYPE &INPUT = TYPE; +%enddef + +INPUT_TYPEMAP(bool, unsigned int, bool) +//INPUT_TYPEMAP(char, char, char) +INPUT_TYPEMAP(signed char, signed char, sbyte) +INPUT_TYPEMAP(unsigned char, unsigned char, byte) +INPUT_TYPEMAP(short, short, short) +INPUT_TYPEMAP(unsigned short, unsigned short, ushort) +INPUT_TYPEMAP(int, int, int) +INPUT_TYPEMAP(unsigned int, unsigned int, uint) +INPUT_TYPEMAP(long, long, int) +INPUT_TYPEMAP(unsigned long, unsigned long, uint) +INPUT_TYPEMAP(long long, long long, long) +INPUT_TYPEMAP(unsigned long long, unsigned long long, ulong) +INPUT_TYPEMAP(float, float, float) +INPUT_TYPEMAP(double, double, double) + +#undef INPUT_TYPEMAP + +/* +OUTPUT typemaps +--------------- + +These typemaps are used for pointer/reference parameters that are output only and +are mapped to a C# output parameter. + +The following typemaps can be applied to turn a pointer or reference into an "output" +value. When calling a function, no input value would be given for +a parameter, but an output value would be returned. In C#, the 'out' keyword is +used when passing the parameter to a function that takes an output parameter. + + bool *OUTPUT, bool &OUTPUT + signed char *OUTPUT, signed char &OUTPUT + unsigned char *OUTPUT, unsigned char &OUTPUT + short *OUTPUT, short &OUTPUT + unsigned short *OUTPUT, unsigned short &OUTPUT + int *OUTPUT, int &OUTPUT + unsigned int *OUTPUT, unsigned int &OUTPUT + long *OUTPUT, long &OUTPUT + unsigned long *OUTPUT, unsigned long &OUTPUT + long long *OUTPUT, long long &OUTPUT + unsigned long long *OUTPUT, unsigned long long &OUTPUT + float *OUTPUT, float &OUTPUT + double *OUTPUT, double &OUTPUT + +For example, suppose you were trying to wrap the modf() function in the +C math library which splits x into integral and fractional parts (and +returns the integer part in one of its parameters): + + double modf(double x, double *ip); + +You could wrap it with SWIG as follows : + + %include <typemaps.i> + double modf(double x, double *OUTPUT); + +or you can use the %apply directive : + + %include <typemaps.i> + %apply double *OUTPUT { double *ip }; + double modf(double x, double *ip); + +The C# output of the function would be the function return value and the +value returned in the second output parameter. In C# you would use it like this: + + double dptr; + double fraction = modulename.modf(5, out dptr); + +*/ + +%define OUTPUT_TYPEMAP(TYPE, CTYPE, CSTYPE, TYPECHECKPRECEDENCE) +%typemap(ctype) TYPE *OUTPUT, TYPE &OUTPUT "CTYPE *" +%typemap(imtype) TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE" +%typemap(cstype) TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE" +%typemap(csin) TYPE *OUTPUT, TYPE &OUTPUT "out $csinput" +%typemap(csdirectorin) TYPE *OUTPUT, TYPE &OUTPUT "$iminput" +%typemap(csdirectorout) TYPE *OUTPUT, TYPE &OUTPUT "$cscall" + + +%typemap(in) TYPE *OUTPUT, TYPE &OUTPUT +%{ $1 = ($1_ltype)$input; %} + +%typemap(directorout,warning="Need to provide TYPE *OUTPUT directorout typemap") TYPE *OUTPUT, TYPE &OUTPUT { +} + +%typemap(directorin) TYPE &OUTPUT +%{ $input = &$1; %} + +%typemap(directorin,warning="Need to provide TYPE *OUTPUT directorin typemap, TYPE array length is unknown") TYPE *OUTPUT +{ +} + + +%typecheck(SWIG_TYPECHECK_##TYPECHECKPRECEDENCE) TYPE *OUTPUT, TYPE &OUTPUT "" +%enddef + +OUTPUT_TYPEMAP(bool, unsigned int, bool, BOOL_PTR) +//OUTPUT_TYPEMAP(char, char, char, CHAR_PTR) +OUTPUT_TYPEMAP(signed char, signed char, sbyte, INT8_PTR) +OUTPUT_TYPEMAP(unsigned char, unsigned char, byte, UINT8_PTR) +OUTPUT_TYPEMAP(short, short, short, INT16_PTR) +OUTPUT_TYPEMAP(unsigned short, unsigned short, ushort, UINT16_PTR) +OUTPUT_TYPEMAP(int, int, int, INT32_PTR) +OUTPUT_TYPEMAP(unsigned int, unsigned int, uint, UINT32_PTR) +OUTPUT_TYPEMAP(long, long, int, INT32_PTR) +OUTPUT_TYPEMAP(unsigned long, unsigned long, uint, UINT32_PTR) +OUTPUT_TYPEMAP(long long, long long, long, INT64_PTR) +OUTPUT_TYPEMAP(unsigned long long, unsigned long long, ulong, UINT64_PTR) +OUTPUT_TYPEMAP(float, float, float, FLOAT_PTR) +OUTPUT_TYPEMAP(double, double, double, DOUBLE_PTR) + +#undef OUTPUT_TYPEMAP + + +/* +INOUT typemaps +-------------- + +These typemaps are for pointer/reference parameters that are both input and +output and are mapped to a C# reference parameter. + +The following typemaps can be applied to turn a pointer or reference into a +reference parameters, that is the parameter is both an input and an output. +In C#, the 'ref' keyword is used for reference parameters. + + bool *INOUT, bool &INOUT + signed char *INOUT, signed char &INOUT + unsigned char *INOUT, unsigned char &INOUT + short *INOUT, short &INOUT + unsigned short *INOUT, unsigned short &INOUT + int *INOUT, int &INOUT + unsigned int *INOUT, unsigned int &INOUT + long *INOUT, long &INOUT + unsigned long *INOUT, unsigned long &INOUT + long long *INOUT, long long &INOUT + unsigned long long *INOUT, unsigned long long &INOUT + float *INOUT, float &INOUT + double *INOUT, double &INOUT + +For example, suppose you were trying to wrap the following function : + + void neg(double *x) { + *x = -(*x); + } + +You could wrap it with SWIG as follows : + + %include <typemaps.i> + void neg(double *INOUT); + +or you can use the %apply directive : + + %include <typemaps.i> + %apply double *INOUT { double *x }; + void neg(double *x); + +The C# output of the function would be the new value returned by the +reference parameter. In C# you would use it like this: + + + double x = 5.0; + neg(ref x); + +The implementation of the OUTPUT and INOUT typemaps is different to the scripting +languages in that the scripting languages will return the output value as part +of the function return value. + +*/ + +%define INOUT_TYPEMAP(TYPE, CTYPE, CSTYPE, TYPECHECKPRECEDENCE) +%typemap(ctype) TYPE *INOUT, TYPE &INOUT "CTYPE *" +%typemap(imtype) TYPE *INOUT, TYPE &INOUT "ref CSTYPE" +%typemap(cstype) TYPE *INOUT, TYPE &INOUT "ref CSTYPE" +%typemap(csin) TYPE *INOUT, TYPE &INOUT "ref $csinput" +%typemap(csdirectorin) TYPE *INOUT, TYPE &INOUT "$iminput" +%typemap(csdirectorout) TYPE *INOUT, TYPE &INOUT "$cscall" + +%typemap(in) TYPE *INOUT, TYPE &INOUT +%{ $1 = ($1_ltype)$input; %} + +%typemap(directorout,warning="Need to provide TYPE *INOUT directorout typemap") TYPE *INOUT, TYPE &INOUT { +} + +%typemap(directorin) TYPE &INOUT +%{ $input = &$1; %} + +%typemap(directorin,warning="Need to provide TYPE *INOUT directorin typemap, TYPE array length is unknown") TYPE *INOUT, TYPE &INOUT +{ +} + +%typecheck(SWIG_TYPECHECK_##TYPECHECKPRECEDENCE) TYPE *INOUT, TYPE &INOUT "" +%enddef + +INOUT_TYPEMAP(bool, unsigned int, bool, BOOL_PTR) +//INOUT_TYPEMAP(char, char, char, CHAR_PTR) +INOUT_TYPEMAP(signed char, signed char, sbyte, INT8_PTR) +INOUT_TYPEMAP(unsigned char, unsigned char, byte, UINT8_PTR) +INOUT_TYPEMAP(short, short, short, INT16_PTR) +INOUT_TYPEMAP(unsigned short, unsigned short, ushort, UINT16_PTR) +INOUT_TYPEMAP(int, int, int, INT32_PTR) +INOUT_TYPEMAP(unsigned int, unsigned int, uint, UINT32_PTR) +INOUT_TYPEMAP(long, long, int, INT32_PTR) +INOUT_TYPEMAP(unsigned long, unsigned long, uint, UINT32_PTR) +INOUT_TYPEMAP(long long, long long, long, INT64_PTR) +INOUT_TYPEMAP(unsigned long long, unsigned long long, ulong, UINT64_PTR) +INOUT_TYPEMAP(float, float, float, FLOAT_PTR) +INOUT_TYPEMAP(double, double, double, DOUBLE_PTR) + +#undef INOUT_TYPEMAP + diff --git a/devtools/swigwin-1.3.34/Lib/csharp/wchar.i b/devtools/swigwin-1.3.34/Lib/csharp/wchar.i new file mode 100644 index 0000000..5aa20ce --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/csharp/wchar.i @@ -0,0 +1,105 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * wchar.i + * + * Typemaps for the wchar_t type + * These are mapped to a C# String and are passed around by value. + * + * Support code for wide strings can be turned off by defining SWIG_CSHARP_NO_WSTRING_HELPER + * + * ----------------------------------------------------------------------------- */ + +#if !defined(SWIG_CSHARP_NO_WSTRING_HELPER) +#if !defined(SWIG_CSHARP_WSTRING_HELPER_) +#define SWIG_CSHARP_WSTRING_HELPER_ +%insert(runtime) %{ +/* Callback for returning strings to C# without leaking memory */ +typedef void * (SWIGSTDCALL* SWIG_CSharpWStringHelperCallback)(const wchar_t *); +static SWIG_CSharpWStringHelperCallback SWIG_csharp_wstring_callback = NULL; +%} + +%pragma(csharp) imclasscode=%{ + protected class SWIGWStringHelper { + + public delegate string SWIGWStringDelegate(IntPtr message); + static SWIGWStringDelegate wstringDelegate = new SWIGWStringDelegate(CreateWString); + + [DllImport("$dllimport", EntryPoint="SWIGRegisterWStringCallback_$module")] + public static extern void SWIGRegisterWStringCallback_$module(SWIGWStringDelegate wstringDelegate); + + static string CreateWString([MarshalAs(UnmanagedType.LPWStr)]IntPtr cString) { + return System.Runtime.InteropServices.Marshal.PtrToStringUni(cString); + } + + static SWIGWStringHelper() { + SWIGRegisterWStringCallback_$module(wstringDelegate); + } + } + + static protected SWIGWStringHelper swigWStringHelper = new SWIGWStringHelper(); +%} + +%insert(runtime) %{ +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void SWIGSTDCALL SWIGRegisterWStringCallback_$module(SWIG_CSharpWStringHelperCallback callback) { + SWIG_csharp_wstring_callback = callback; +} +%} +#endif // SWIG_CSHARP_WSTRING_HELPER_ +#endif // SWIG_CSHARP_NO_WSTRING_HELPER + + +// wchar_t +%typemap(ctype) wchar_t "wchar_t" +%typemap(imtype) wchar_t "char" +%typemap(cstype) wchar_t "char" + +%typemap(csin) wchar_t "$csinput" +%typemap(csout, excode=SWIGEXCODE) wchar_t { + char ret = $imcall;$excode + return ret; + } +%typemap(csvarin, excode=SWIGEXCODE2) wchar_t %{ + set { + $imcall;$excode + } %} +%typemap(csvarout, excode=SWIGEXCODE2) wchar_t %{ + get { + char ret = $imcall;$excode + return ret; + } %} + +%typemap(in) wchar_t %{ $1 = ($1_ltype)$input; %} +%typemap(out) wchar_t %{ $result = (wchar_t)$1; %} + +%typemap(typecheck) wchar_t = char; + +// wchar_t * +%typemap(ctype) wchar_t * "wchar_t *" +%typemap(imtype, inattributes="[MarshalAs(UnmanagedType.LPWStr)]", out="IntPtr" ) wchar_t * "string" +%typemap(cstype) wchar_t * "string" + +%typemap(csin) wchar_t * "$csinput" +%typemap(csout, excode=SWIGEXCODE) wchar_t * { + string ret = System.Runtime.InteropServices.Marshal.PtrToStringUni($imcall);$excode + return ret; + } +%typemap(csvarin, excode=SWIGEXCODE2) wchar_t * %{ + set { + $imcall;$excode + } %} +%typemap(csvarout, excode=SWIGEXCODE2) wchar_t * %{ + get { + string ret = $imcall;$excode + return ret; + } %} + +%typemap(in) wchar_t * %{ $1 = ($1_ltype)$input; %} +%typemap(out) wchar_t * %{ $result = (wchar_t *)$1; %} + +%typemap(typecheck) wchar_t * = char *; + diff --git a/devtools/swigwin-1.3.34/Lib/cstring.i b/devtools/swigwin-1.3.34/Lib/cstring.i new file mode 100644 index 0000000..4ebdf68 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/cstring.i @@ -0,0 +1,15 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * cstring.i + * ----------------------------------------------------------------------------- */ + +%echo "cstring.i not implemented for this target" +#define SWIG_CSTRING_UNIMPL + +/* old name keep for compatibility */ +#define _CSTRING_UNIMPL + + + diff --git a/devtools/swigwin-1.3.34/Lib/cwstring.i b/devtools/swigwin-1.3.34/Lib/cwstring.i new file mode 100644 index 0000000..a6b08ae --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/cwstring.i @@ -0,0 +1,14 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * cwstring.i + * ----------------------------------------------------------------------------- */ + +%echo "cwstring.i not implemented for this target" +#define SWIG_CWSTRING_UNIMPL + + + + + diff --git a/devtools/swigwin-1.3.34/Lib/exception.i b/devtools/swigwin-1.3.34/Lib/exception.i new file mode 100644 index 0000000..e30ac1a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/exception.i @@ -0,0 +1,271 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * exception.i + * + * SWIG library file providing language independent exception handling + * ----------------------------------------------------------------------------- */ + +#if defined(SWIGUTL) +#error "This version of exception.i should not be used" +#endif + + +%insert("runtime") "swigerrors.swg" + + +#ifdef SWIGPHP +%{ +#if PHP_MAJOR_VERSION < 5 +# define SWIG_exception(code, msg) { zend_error(E_ERROR, msg); } +#else +# include "zend_exceptions.h" +# define SWIG_exception(code, msg) { zend_throw_exception(NULL, (char*)msg, code TSRMLS_CC); } +#endif +%} +#endif + +#ifdef SWIGGUILE +%{ + SWIGINTERN void SWIG_exception_ (int code, const char *msg, + const char *subr) { +#define ERROR(scmerr) \ + scm_error(gh_symbol2scm((char *) (scmerr)), \ + (char *) subr, (char *) msg, \ + SCM_EOL, SCM_BOOL_F) +#define MAP(swigerr, scmerr) \ + case swigerr: \ + ERROR(scmerr); \ + break + switch (code) { + MAP(SWIG_MemoryError, "swig-memory-error"); + MAP(SWIG_IOError, "swig-io-error"); + MAP(SWIG_RuntimeError, "swig-runtime-error"); + MAP(SWIG_IndexError, "swig-index-error"); + MAP(SWIG_TypeError, "swig-type-error"); + MAP(SWIG_DivisionByZero, "swig-division-by-zero"); + MAP(SWIG_OverflowError, "swig-overflow-error"); + MAP(SWIG_SyntaxError, "swig-syntax-error"); + MAP(SWIG_ValueError, "swig-value-error"); + MAP(SWIG_SystemError, "swig-system-error"); + default: + ERROR("swig-error"); + } +#undef ERROR +#undef MAP + } + +#define SWIG_exception(a,b) SWIG_exception_(a, b, FUNC_NAME) +%} +#endif + +#ifdef SWIGMZSCHEME + +%{ +SWIGINTERN void SWIG_exception_ (int code, const char *msg) { +#define ERROR(errname) \ + scheme_signal_error(errname " (%s)", msg); +#define MAP(swigerr, errname) \ + case swigerr: \ + ERROR(errname); \ + break + switch (code) { + MAP(SWIG_MemoryError, "swig-memory-error"); + MAP(SWIG_IOError, "swig-io-error"); + MAP(SWIG_RuntimeError, "swig-runtime-error"); + MAP(SWIG_IndexError, "swig-index-error"); + MAP(SWIG_TypeError, "swig-type-error"); + MAP(SWIG_DivisionByZero, "swig-division-by-zero"); + MAP(SWIG_OverflowError, "swig-overflow-error"); + MAP(SWIG_SyntaxError, "swig-syntax-error"); + MAP(SWIG_ValueError, "swig-value-error"); + MAP(SWIG_SystemError, "swig-system-error"); + default: + ERROR("swig-error"); + } +#undef ERROR +#undef MAP + } + +#define SWIG_exception(a,b) SWIG_exception_(a, b) +%} +#endif + +#ifdef SWIGJAVA +%{ +SWIGINTERN void SWIG_JavaException(JNIEnv *jenv, int code, const char *msg) { + SWIG_JavaExceptionCodes exception_code = SWIG_JavaUnknownError; + switch(code) { + case SWIG_MemoryError: + exception_code = SWIG_JavaOutOfMemoryError; + break; + case SWIG_IOError: + exception_code = SWIG_JavaIOException; + break; + case SWIG_SystemError: + case SWIG_RuntimeError: + exception_code = SWIG_JavaRuntimeException; + break; + case SWIG_OverflowError: + case SWIG_IndexError: + exception_code = SWIG_JavaIndexOutOfBoundsException; + break; + case SWIG_DivisionByZero: + exception_code = SWIG_JavaArithmeticException; + break; + case SWIG_SyntaxError: + case SWIG_ValueError: + case SWIG_TypeError: + exception_code = SWIG_JavaIllegalArgumentException; + break; + case SWIG_UnknownError: + default: + exception_code = SWIG_JavaUnknownError; + break; + } + SWIG_JavaThrowException(jenv, exception_code, msg); +} +%} + +#define SWIG_exception(code, msg)\ +{ SWIG_JavaException(jenv, code, msg); return $null; } +#endif // SWIGJAVA + +#ifdef SWIGOCAML +%{ +#define OCAML_MSG_BUF_LEN 1024 +SWIGINTERN void SWIG_exception_(int code, const char *msg) { + char msg_buf[OCAML_MSG_BUF_LEN]; + sprintf( msg_buf, "Exception(%d): %s\n", code, msg ); + failwith( msg_buf ); +} +#define SWIG_exception(a,b) SWIG_exception_((a),(b)) +%} +#endif + + +#ifdef SWIGCHICKEN +%{ +SWIGINTERN void SWIG_exception_(int code, const char *msg) { + C_word *a; + C_word scmmsg; + C_word list; + + a = C_alloc (C_SIZEOF_STRING (strlen (msg)) + C_SIZEOF_LIST(2)); + scmmsg = C_string2 (&a, (char *) msg); + list = C_list(&a, 2, C_fix(code), scmmsg); + SWIG_ThrowException(list); +} +#define SWIG_exception(a,b) SWIG_exception_((a),(b)) +%} +#endif + +#ifdef SWIGCSHARP +%{ +SWIGINTERN void SWIG_CSharpException(int code, const char *msg) { + if (code == SWIG_ValueError) { + SWIG_CSharpExceptionArgumentCodes exception_code = SWIG_CSharpArgumentOutOfRangeException; + SWIG_CSharpSetPendingExceptionArgument(exception_code, msg, 0); + } else { + SWIG_CSharpExceptionCodes exception_code = SWIG_CSharpApplicationException; + switch(code) { + case SWIG_MemoryError: + exception_code = SWIG_CSharpOutOfMemoryException; + break; + case SWIG_IndexError: + exception_code = SWIG_CSharpIndexOutOfRangeException; + break; + case SWIG_DivisionByZero: + exception_code = SWIG_CSharpDivideByZeroException; + break; + case SWIG_IOError: + exception_code = SWIG_CSharpIOException; + break; + case SWIG_OverflowError: + exception_code = SWIG_CSharpOverflowException; + break; + case SWIG_RuntimeError: + case SWIG_TypeError: + case SWIG_SyntaxError: + case SWIG_SystemError: + case SWIG_UnknownError: + default: + exception_code = SWIG_CSharpApplicationException; + break; + } + SWIG_CSharpSetPendingException(exception_code, msg); + } +} +%} + +#define SWIG_exception(code, msg)\ +{ SWIG_CSharpException(code, msg); return $null; } +#endif // SWIGCSHARP + +#ifdef SWIGLUA + +%{ +#define SWIG_exception(a,b)\ +{ lua_pushfstring(L,"%s:%s",#a,b);SWIG_fail; } +%} + +#endif // SWIGLUA + +#ifdef __cplusplus +/* + You can use the SWIG_CATCH_STDEXCEPT macro with the %exception + directive as follows: + + %exception { + try { + $action + } + catch (my_except& e) { + ... + } + SWIG_CATCH_STDEXCEPT // catch std::exception + catch (...) { + SWIG_exception(SWIG_UnknownError, "Unknown exception"); + } + } +*/ +%{ +#include <stdexcept> +%} +%define SWIG_CATCH_STDEXCEPT + /* catching std::exception */ + catch (std::invalid_argument& e) { + SWIG_exception(SWIG_ValueError, e.what() ); + } catch (std::domain_error& e) { + SWIG_exception(SWIG_ValueError, e.what() ); + } catch (std::overflow_error& e) { + SWIG_exception(SWIG_OverflowError, e.what() ); + } catch (std::out_of_range& e) { + SWIG_exception(SWIG_IndexError, e.what() ); + } catch (std::length_error& e) { + SWIG_exception(SWIG_IndexError, e.what() ); + } catch (std::runtime_error& e) { + SWIG_exception(SWIG_RuntimeError, e.what() ); + } catch (std::exception& e) { + SWIG_exception(SWIG_SystemError, e.what() ); + } +%enddef +%define SWIG_CATCH_UNKNOWN + catch (std::exception& e) { + SWIG_exception(SWIG_SystemError, e.what() ); + } + catch (...) { + SWIG_exception(SWIG_UnknownError, "unknown exception"); + } +%enddef + +/* rethrow the unknown exception */ + +%typemap(throws,noblock=1) (...) { + SWIG_exception(SWIG_RuntimeError,"unknown exception"); +} + +#endif /* __cplusplus */ + +/* exception.i ends here */ diff --git a/devtools/swigwin-1.3.34/Lib/gcj/cni.i b/devtools/swigwin-1.3.34/Lib/gcj/cni.i new file mode 100644 index 0000000..b12148e --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/gcj/cni.i @@ -0,0 +1,43 @@ +%{ +#include <gcj/cni.h> +%} + +%include <gcj/javaprims.i> + +extern jobject JvAllocObject (jclass cls); + +extern jobject JvAllocObject (jclass cls, jsize sz); + +extern void JvInitClass (jclass cls); + +extern jstring JvAllocString (jsize sz); + +extern jstring JvNewString (const jchar *chars, jsize len); + +extern jstring JvNewStringLatin1 (const char *bytes, jsize len); + +extern jstring JvNewStringLatin1 (const char *bytes); + +extern jchar* JvGetStringChars (jstring str); + +extern jsize JvGetStringUTFLength (jstring string); + +extern jsize JvGetStringUTFRegion (jstring str, jsize start, jsize len, char *buf); + +extern jstring JvNewStringUTF (const char *bytes); + +extern void *JvMalloc (jsize size); + +extern void JvFree (void *ptr); + +extern jint JvCreateJavaVM (void* vm_args); + +extern java::lang::Thread* JvAttachCurrentThread (jstring name, java::lang::ThreadGroup* group); + +extern java::lang::Thread* JvAttachCurrentThreadAsDaemon (jstring name, java::lang::ThreadGroup* group); + +extern jint JvDetachCurrentThread (void); + + +%include <gcj/cni.swg> + diff --git a/devtools/swigwin-1.3.34/Lib/gcj/cni.swg b/devtools/swigwin-1.3.34/Lib/gcj/cni.swg new file mode 100644 index 0000000..247909a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/gcj/cni.swg @@ -0,0 +1,17 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * cni.swg + * ----------------------------------------------------------------------------- */ + +#ifdef SWIG + +#define __attribute__(...) +%ignore class$; +#pragma SWIG nowarn=313,402 + +%nodefaultdtor; + +#endif + diff --git a/devtools/swigwin-1.3.34/Lib/gcj/javaprims.i b/devtools/swigwin-1.3.34/Lib/gcj/javaprims.i new file mode 100644 index 0000000..12c92a7 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/gcj/javaprims.i @@ -0,0 +1,422 @@ +%include <stdint.i> + +typedef int8_t jbyte; +typedef int16_t jshort; +typedef int32_t jint; +typedef int64_t jlong; +typedef float jfloat; +typedef double jdouble; +typedef jint jsize; +typedef int8_t jboolean; + +extern "Java" +{ + namespace java + { + namespace io + { + class BufferedInputStream; + class BufferedOutputStream; + class BufferedReader; + class BufferedWriter; + class ByteArrayInputStream; + class ByteArrayOutputStream; + class CharArrayReader; + class CharArrayWriter; + class CharConversionException; + class DataInput; + class DataInputStream; + class DataOutput; + class DataOutputStream; + class EOFException; + class Externalizable; + class File; + class FileDescriptor; + class FileFilter; + class FileInputStream; + class FileNotFoundException; + class FileOutputStream; + class FilePermission; + class FileReader; + class FileWriter; + class FilenameFilter; + class FilterInputStream; + class FilterOutputStream; + class FilterReader; + class FilterWriter; + class IOException; + class InputStream; + class InputStreamReader; + class InterfaceComparator; + class InterruptedIOException; + class InvalidClassException; + class InvalidObjectException; + class LineNumberInputStream; + class LineNumberReader; + class MemberComparator; + class NotActiveException; + class NotSerializableException; + class ObjectInput; + class ObjectInputStream; + class ObjectInputStream$GetField; + class ObjectInputValidation; + class ObjectOutput; + class ObjectOutputStream; + class ObjectOutputStream$PutField; + class ObjectStreamClass; + class ObjectStreamConstants; + class ObjectStreamException; + class ObjectStreamField; + class OptionalDataException; + class OutputStream; + class OutputStreamWriter; + class PipedInputStream; + class PipedOutputStream; + class PipedReader; + class PipedWriter; + class PrintStream; + class PrintWriter; + class PushbackInputStream; + class PushbackReader; + class RandomAccessFile; + class Reader; + class SequenceInputStream; + class Serializable; + class SerializablePermission; + class StreamCorruptedException; + class StreamTokenizer; + class StringBufferInputStream; + class StringReader; + class StringWriter; + class SyncFailedException; + class UTFDataFormatException; + class UnsupportedEncodingException; + class VMObjectStreamClass; + class ValidatorAndPriority; + class WriteAbortedException; + class Writer; + } + + namespace lang + { + class AbstractMethodError; + class ArithmeticException; + class ArrayIndexOutOfBoundsException; + class ArrayStoreException; + class AssertionError; + class Boolean; + class Byte; + class CharSequence; + class Character; + class Character$Subset; + class Character$UnicodeBlock; + class Class; + class ClassCastException; + class ClassCircularityError; + class ClassFormatError; + class ClassLoader; + class ClassNotFoundException; + class CloneNotSupportedException; + class Cloneable; + class Comparable; + class Compiler; + class ConcreteProcess; + class Double; + class Error; + class Exception; + class ExceptionInInitializerError; + class Float; + class IllegalAccessError; + class IllegalAccessException; + class IllegalArgumentException; + class IllegalMonitorStateException; + class IllegalStateException; + class IllegalThreadStateException; + class IncompatibleClassChangeError; + class IndexOutOfBoundsException; + class InheritableThreadLocal; + class InstantiationError; + class InstantiationException; + class Integer; + class InternalError; + class InterruptedException; + class LinkageError; + class Long; + class Math; + class NegativeArraySizeException; + class NoClassDefFoundError; + class NoSuchFieldError; + class NoSuchFieldException; + class NoSuchMethodError; + class NoSuchMethodException; + class NullPointerException; + class Number; + class NumberFormatException; + class Object; + class OutOfMemoryError; + class Package; + class Process; + class Runnable; + class Runtime; + class RuntimeException; + class RuntimePermission; + class SecurityContext; + class SecurityException; + class SecurityManager; + class Short; + class StackOverflowError; + class StackTraceElement; + class StrictMath; + class String; + class String$CaseInsensitiveComparator; + class StringBuffer; + class StringIndexOutOfBoundsException; + class System; + class Thread; + class ThreadDeath; + class ThreadGroup; + class ThreadLocal; + class Throwable; + class UnknownError; + class UnsatisfiedLinkError; + class UnsupportedClassVersionError; + class UnsupportedOperationException; + class VMClassLoader; + class VMSecurityManager; + class VMThrowable; + class VerifyError; + class VirtualMachineError; + class Void; + namespace ref + { + class PhantomReference; + class Reference; + class ReferenceQueue; + class SoftReference; + class WeakReference; + } + + namespace reflect + { + class AccessibleObject; + class Array; + class Constructor; + class Field; + class InvocationHandler; + class InvocationTargetException; + class Member; + class Method; + class Modifier; + class Proxy; + class Proxy$ClassFactory; + class Proxy$ProxyData; + class Proxy$ProxySignature; + class Proxy$ProxyType; + class ReflectPermission; + class UndeclaredThrowableException; + } + } + + namespace util + { + class AbstractCollection; + class AbstractList; + class AbstractMap; + class AbstractMap$BasicMapEntry; + class AbstractSequentialList; + class AbstractSet; + class ArrayList; + class Arrays; + class Arrays$ArrayList; + class BitSet; + class Calendar; + class Collection; + class Collections; + class Collections$CopiesList; + class Collections$EmptyList; + class Collections$EmptyMap; + class Collections$EmptySet; + class Collections$ReverseComparator; + class Collections$SingletonList; + class Collections$SingletonMap; + class Collections$SingletonSet; + class Collections$SynchronizedCollection; + class Collections$SynchronizedIterator; + class Collections$SynchronizedList; + class Collections$SynchronizedListIterator; + class Collections$SynchronizedMap; + class Collections$SynchronizedMapEntry; + class Collections$SynchronizedRandomAccessList; + class Collections$SynchronizedSet; + class Collections$SynchronizedSortedMap; + class Collections$SynchronizedSortedSet; + class Collections$UnmodifiableCollection; + class Collections$UnmodifiableEntrySet; + class Collections$UnmodifiableIterator; + class Collections$UnmodifiableList; + class Collections$UnmodifiableListIterator; + class Collections$UnmodifiableMap; + class Collections$UnmodifiableRandomAccessList; + class Collections$UnmodifiableSet; + class Collections$UnmodifiableSortedMap; + class Collections$UnmodifiableSortedSet; + class Comparator; + class ConcurrentModificationException; + class Currency; + class Date; + class Dictionary; + class EmptyStackException; + class Enumeration; + class EventListener; + class EventListenerProxy; + class EventObject; + class GregorianCalendar; + class HashMap; + class HashMap$HashEntry; + class HashMap$HashIterator; + class HashSet; + class Hashtable; + class Hashtable$Enumerator; + class Hashtable$HashEntry; + class Hashtable$HashIterator; + class IdentityHashMap; + class IdentityHashMap$IdentityEntry; + class IdentityHashMap$IdentityIterator; + class Iterator; + class LinkedHashMap; + class LinkedHashMap$LinkedHashEntry; + class LinkedHashSet; + class LinkedList; + class LinkedList$Entry; + class LinkedList$LinkedListItr; + class List; + class ListIterator; + class ListResourceBundle; + class Locale; + class Map; + class Map$Entry; + class Map$Map; + class MissingResourceException; + class MyResources; + class NoSuchElementException; + class Observable; + class Observer; + class Properties; + class PropertyPermission; + class PropertyPermissionCollection; + class PropertyResourceBundle; + class Random; + class RandomAccess; + class RandomAccessSubList; + class ResourceBundle; + class Set; + class SimpleTimeZone; + class SortedMap; + class SortedSet; + class Stack; + class StringTokenizer; + class SubList; + class TimeZone; + class Timer; + class Timer$Scheduler; + class Timer$TaskQueue; + class TimerTask; + class TooManyListenersException; + class TreeMap; + class TreeMap$Node; + class TreeMap$SubMap; + class TreeMap$TreeIterator; + class TreeSet; + class Vector; + class WeakHashMap; + class WeakHashMap$WeakBucket; + class WeakHashMap$WeakEntry; + class WeakHashMap$WeakEntrySet; + namespace jar + { + class Attributes; + class Attributes$Name; + class JarEntry; + class JarException; + class JarFile; + class JarFile$JarEnumeration; + class JarInputStream; + class JarOutputStream; + class Manifest; + } + + namespace logging + { + class ConsoleHandler; + class ErrorManager; + class FileHandler; + class Filter; + class Formatter; + class Handler; + class Level; + class LogManager; + class LogRecord; + class Logger; + class LoggingPermission; + class MemoryHandler; + class SimpleFormatter; + class SocketHandler; + class StreamHandler; + class XMLFormatter; + } + + namespace prefs + { + class AbstractPreferences; + class BackingStoreException; + class InvalidPreferencesFormatException; + class NodeChangeEvent; + class NodeChangeListener; + class PreferenceChangeEvent; + class PreferenceChangeListener; + class Preferences; + class PreferencesFactory; + } + + namespace regex + { + class Matcher; + class Pattern; + class PatternSyntaxException; + } + + namespace zip + { + class Adler32; + class CRC32; + class CheckedInputStream; + class CheckedOutputStream; + class Checksum; + class DataFormatException; + class Deflater; + class DeflaterOutputStream; + class GZIPInputStream; + class GZIPOutputStream; + class Inflater; + class InflaterInputStream; + class ZipConstants; + class ZipEntry; + class ZipException; + class ZipFile; + class ZipFile$PartialInputStream; + class ZipFile$ZipEntryEnumeration; + class ZipInputStream; + class ZipOutputStream; + } + } + } +} + +typedef class java::lang::Object* jobject; +typedef class java::lang::Class* jclass; +typedef class java::lang::Throwable* jthrowable; +typedef class java::lang::String* jstring; + + +%include <gcj/cni.swg> + diff --git a/devtools/swigwin-1.3.34/Lib/guile/Makefile b/devtools/swigwin-1.3.34/Lib/guile/Makefile new file mode 100644 index 0000000..ff66f9e --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/Makefile @@ -0,0 +1,4 @@ + +co:: + co RCS/*.i* RCS/*.swg* + diff --git a/devtools/swigwin-1.3.34/Lib/guile/common.scm b/devtools/swigwin-1.3.34/Lib/guile/common.scm new file mode 100644 index 0000000..a51d3a7 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/common.scm @@ -0,0 +1,76 @@ +;;;************************************************************************ +;;;*common.scm +;;;* +;;;* This file contains generic SWIG GOOPS classes for generated +;;;* GOOPS file support +;;;* +;;;* Copyright (C) 2003 John Lenz ([email protected]) +;;;* Copyright (C) 2004 Matthias Koeppe ([email protected]) +;;;* +;;;* This file may be freely redistributed without license or fee provided +;;;* this copyright message remains intact. +;;;************************************************************************ + +(define-module (Swig swigrun)) + +(define-module (Swig common) + #:use-module (oop goops) + #:use-module (Swig swigrun)) + +(define-class <swig-metaclass> (<class>) + (new-function #:init-value #f)) + +(define-method (initialize (class <swig-metaclass>) initargs) + (slot-set! class 'new-function (get-keyword #:new-function initargs #f)) + (next-method)) + +(define-class <swig> () + (swig-smob #:init-value #f) + #:metaclass <swig-metaclass> +) + +(define-method (initialize (obj <swig>) initargs) + (next-method) + (slot-set! obj 'swig-smob + (let ((arg (get-keyword #:init-smob initargs #f))) + (if arg + arg + (let ((ret (apply (slot-ref (class-of obj) 'new-function) (get-keyword #:args initargs '())))) + ;; if the class is registered with runtime environment, + ;; new-Function will return a <swig> goops class. In that case, extract the smob + ;; from that goops class and set it as the current smob. + (if (slot-exists? ret 'swig-smob) + (slot-ref ret 'swig-smob) + ret)))))) + +(define (display-address o file) + (display (number->string (object-address o) 16) file)) + +(define (display-pointer-address o file) + ;; Don't fail if the function SWIG-PointerAddress is not present. + (let ((address (false-if-exception (SWIG-PointerAddress o)))) + (if address + (begin + (display " @ " file) + (display (number->string address 16) file))))) + +(define-method (write (o <swig>) file) + ;; We display _two_ addresses to show the object's identity: + ;; * first the address of the GOOPS proxy object, + ;; * second the pointer address. + ;; The reason is that proxy objects are created and discarded on the + ;; fly, so different proxy objects for the same C object will appear. + (let ((class (class-of o))) + (if (slot-bound? class 'name) + (begin + (display "#<" file) + (display (class-name class) file) + (display #\space file) + (display-address o file) + (display-pointer-address o file) + (display ">" file)) + (next-method)))) + +(export <swig-metaclass> <swig>) + +;;; common.scm ends here diff --git a/devtools/swigwin-1.3.34/Lib/guile/cplusplus.i b/devtools/swigwin-1.3.34/Lib/guile/cplusplus.i new file mode 100644 index 0000000..cb4cf74 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/cplusplus.i @@ -0,0 +1,25 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * cplusplus.i + * + * SWIG typemaps for C++ + * ----------------------------------------------------------------------------- */ + +%typemap(guile,out) string, std::string { + $result = gh_str02scm(const_cast<char*>($1.c_str())); +} +%typemap(guile,in) string, std::string { + $1 = SWIG_scm2str($input); +} + +%typemap(guile,out) complex, complex<double>, std::complex<double> { + $result = scm_make_rectangular( gh_double2scm ($1.real ()), + gh_double2scm ($1.imag ()) ); +} +%typemap(guile,in) complex, complex<double>, std::complex<double> { + $1 = std::complex<double>( gh_scm2double (scm_real_part ($input)), + gh_scm2double (scm_imag_part ($input)) ); +} + diff --git a/devtools/swigwin-1.3.34/Lib/guile/extra-install.list b/devtools/swigwin-1.3.34/Lib/guile/extra-install.list new file mode 100644 index 0000000..05d2c0c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/extra-install.list @@ -0,0 +1,2 @@ +# see top-level Makefile.in +common.scm diff --git a/devtools/swigwin-1.3.34/Lib/guile/ghinterface.i b/devtools/swigwin-1.3.34/Lib/guile/ghinterface.i new file mode 100644 index 0000000..c5fda62 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/ghinterface.i @@ -0,0 +1,39 @@ +#define gh_append2(a, b) scm_append(scm_listify(a, b, SCM_UNDEFINED)) +#define gh_apply(a, b) scm_apply(a, b, SCM_EOL) +#define gh_bool2scm SCM_BOOL +#define gh_boolean_p SCM_BOOLP +#define gh_car SCM_CAR +#define gh_cdr SCM_CDR +#define gh_cons scm_cons +#define gh_double2scm scm_make_real +#define gh_int2scm scm_long2num +#define gh_length(lst) scm_num2ulong(scm_length(lst), SCM_ARG1, FUNC_NAME) +#define gh_list scm_listify +#define gh_list_to_vector scm_vector +#define gh_make_vector scm_make_vector +#define gh_null_p SCM_NULLP +#define gh_number_p SCM_NUMBERP +#define gh_pair_p SCM_CONSP +#define gh_scm2bool SCM_NFALSEP +#define gh_scm2char SCM_CHAR +#define gh_scm2double(a) scm_num2dbl(a, FUNC_NAME) +#define gh_scm2int(a) scm_num2int(a, SCM_ARG1, FUNC_NAME) +#define gh_scm2long(a) scm_num2long(a, SCM_ARG1, FUNC_NAME) +#define gh_scm2short(a) scm_num2short(a, SCM_ARG1, FUNC_NAME) +#define gh_scm2newstr SWIG_Guile_scm2newstr +#define gh_scm2ulong(a) scm_num2ulong(a, SCM_ARG1, FUNC_NAME) +#define gh_scm2ushort(a) scm_num2ushort(a, SCM_ARG1, FUNC_NAME) +#define gh_scm2uint(a) scm_num2uint(a, SCM_ARG1, FUNC_NAME) +#define gh_ulong2scm scm_ulong2num +#define gh_long2scm scm_long2num +#define gh_str02scm scm_makfrom0str +#define gh_long_long2scm scm_long_long2num +#define gh_scm2long_long(a) scm_num2long_long(a, SCM_ARG1, FUNC_NAME) +#define gh_ulong_long2scm scm_ulong_long2num +#define gh_scm2ulong_long(a) scm_num2ulong_long(a, SCM_ARG1, FUNC_NAME) +#define gh_string_p SCM_STRINGP +#define gh_vector_length SCM_VECTOR_LENGTH +#define gh_vector_p SCM_VECTORP +#define gh_vector_ref scm_vector_ref +#define gh_vector_set_x scm_vector_set_x +#define gh_char2scm SCM_MAKE_CHAR diff --git a/devtools/swigwin-1.3.34/Lib/guile/guile.i b/devtools/swigwin-1.3.34/Lib/guile/guile.i new file mode 100644 index 0000000..1bf28d6 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/guile.i @@ -0,0 +1,36 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * guile.i + * + * SWIG Configuration File for Guile. + * ----------------------------------------------------------------------------- */ + +/* Macro for inserting Scheme code into the stub */ +#define %scheme %insert("scheme") +#define %goops %insert("goops") + +/* Return-styles */ +%pragma(guile) return_nothing_doc = "Returns unspecified." +%pragma(guile) return_one_doc = "Returns $values." + +%define %values_as_list + %pragma(guile) beforereturn = "" + %pragma(guile) return_multi_doc = "Returns a list of $num_values values: $values." +%enddef +%values_as_list /* the default style */ + +%define %values_as_vector + %pragma(guile) beforereturn = "GUILE_MAYBE_VECTOR" + %pragma(guile) return_multi_doc = "Returns a vector of $num_values values: $values." +%enddef + +%define %multiple_values + %pragma(guile) beforereturn = "GUILE_MAYBE_VALUES" + %pragma(guile) return_multi_doc = "Returns $num_values values: $values." +%enddef + +#define GUILE_APPEND_RESULT SWIG_APPEND_VALUE + +%include <typemaps.i> diff --git a/devtools/swigwin-1.3.34/Lib/guile/guile_gh.swg b/devtools/swigwin-1.3.34/Lib/guile/guile_gh.swg new file mode 100644 index 0000000..6412a4c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/guile_gh.swg @@ -0,0 +1,74 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * guile_gh.swg + * + * This SWIG interface file is processed if the Guile module is run + * with gh_ flavor. + * ----------------------------------------------------------------------------- */ + +#define SWIGGUILE_GH + +%runtime "swigrun.swg" +%runtime "guile_gh_run.swg" + +#define SWIG_convert_short(o) \ + SWIG_convert_integer(o, - (1 << (8 * sizeof(short) - 1)), \ + (1 << (8 * sizeof(short) - 1)) - 1, \ + FUNC_NAME, $argnum) +#define SWIG_convert_unsigned_short(o) \ + SWIG_convert_unsigned_integer(o, 0, \ + (1 << (8 * sizeof(short))) - 1, \ + FUNC_NAME, $argnum) +#define SWIG_convert_unsigned_int(o) \ + SWIG_convert_unsigned_integer(o, 0, UINT_MAX, \ + FUNC_NAME, $argnum) + +#define gh_scm2short(a) SWIG_convert_short(a) +#define gh_scm2ushort(a) SWIG_convert_unsigned_short(a) +#define gh_scm2uint(a) SWIG_convert_unsigned_int(a) + +%include <guile.i> + +%runtime %{ + +/* scm_values was implemented on C level in 1.4.1, and the prototype + is not included in libguile.h, so play safe and lookup `values'... */ +#define GUILE_MAYBE_VALUES \ + if (gswig_list_p) \ + gswig_result = gh_apply(gh_lookup("values"), gswig_result); + +#define GUILE_MAYBE_VECTOR \ + if (gswig_list_p) \ + gswig_result = gh_list_to_vector(gswig_result); + +#define SWIG_APPEND_VALUE(object) \ + if (gswig_result == SCM_UNSPECIFIED) { \ + gswig_result = object; \ + } else { \ + if (!gswig_list_p) { \ + gswig_list_p = 1; \ + gswig_result = gh_list(gswig_result, object, SCM_UNDEFINED); \ + } \ + else \ + gswig_result = gh_append2(gswig_result, \ + gh_list(object, SCM_UNDEFINED)); \ + } + +%} + +%init "swiginit.swg" + +%init %{ +static int _swig_module_smob_tag; + +SWIG_GUILE_INIT_STATIC void +SWIG_init(void) +{ + + SWIG_InitializeModule(0); + swig_module.clientdata = (void *) &_swig_module_smob_tag; + + SWIG_Guile_Init(&swig_module); +%} diff --git a/devtools/swigwin-1.3.34/Lib/guile/guile_gh_run.swg b/devtools/swigwin-1.3.34/Lib/guile/guile_gh_run.swg new file mode 100644 index 0000000..5b1fca0 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/guile_gh_run.swg @@ -0,0 +1,261 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * guile_gh_run.swg + * + * Guile GH runtime file + * ----------------------------------------------------------------------------- */ + +#define SWIGGUILE +#include "guile/gh.h" +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <assert.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef SCM (*swig_guile_proc)(); + +#define SWIG_malloc(size) \ + SCM_MUST_MALLOC(size) +#define SWIG_free(mem) \ + scm_must_free(mem) +#define SWIG_ConvertPtr(s, result, type, flags) \ + SWIG_Guile_ConvertPtr(&swig_module, s, result, type, flags) +#define SWIG_MustGetPtr(s, type, argnum, flags) \ + SWIG_Guile_MustGetPtr(&swig_module, s, type, argnum, flags, FUNC_NAME) +#define SWIG_NewPointerObj(ptr, type, owner) \ + SWIG_Guile_NewPointerObj(&swig_module, (void*)ptr, type, owner) +#define SWIG_GetModule(clientdata) SWIG_Guile_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Guile_SetModule(pointer) + +/* Ignore object-ownership changes in gh mode */ +#define SWIG_Guile_MarkPointerNoncollectable(s) (s) +#define SWIG_Guile_MarkPointerDestroyed(s) (s) + +#define SWIG_contract_assert(expr, msg) \ + if (!(expr)) \ + scm_error(gh_symbol2scm("swig-contract-assertion-failed"), \ + (char *) FUNC_NAME, (char *) msg, \ + SCM_EOL, SCM_BOOL_F); else + +/* SCM_CHAR and SCM_CHARP were introduced in Guile 1.4; the following is for + 1.3.4 compatibility. */ +#ifndef SCM_CHAR +# define SCM_CHAR SCM_ICHR +#endif +#ifndef SCM_CHARP +# define SCM_CHARP SCM_ICHRP +#endif + +/* This function replaces gh_scm2char, which is broken in Guile 1.4 */ +SWIGINTERN char +GSWIG_scm2char (SCM s) +{ + if (SCM_CHARP(s)) return SCM_CHAR(s); + scm_wrong_type_arg(NULL, 0, s); +} +#define gh_scm2char GSWIG_scm2char + +/* Interface function */ +#define SWIG_scm2str(x) gh_scm2newstr(x, NULL) + +/* More 1.3.4 compatibility */ +#ifndef SCM_INPUT_PORT_P +# define SCM_INPUT_PORT_P SCM_INPORTP +# define SCM_OUTPUT_PORT_P SCM_OUTPORTP +#endif + +SWIGINTERN long +SWIG_convert_integer(SCM o, + long lower_bound, long upper_bound, + const char *func_name, int argnum) +{ + long value = gh_scm2long(o); + if (value < lower_bound || value > upper_bound) + scm_wrong_type_arg((char *) func_name, argnum, o); + return value; +} + +SWIGINTERN unsigned long +SWIG_convert_unsigned_integer(SCM o, + unsigned long lower_bound, + unsigned long upper_bound, + const char *func_name, int argnum) +{ + unsigned long value = gh_scm2ulong(o); + if (value < lower_bound || value > upper_bound) + scm_wrong_type_arg((char *) func_name, argnum, o); + return value; +} + +SWIGINTERN swig_type_info * +SWIG_Guile_LookupType(swig_module_info *module, SCM s, int normal) +{ + swig_module_info *iter; + if (!module) return 0; + iter = module; + do { + if ((normal && (unsigned long) SCM_TYP16(s) == *((int *)iter->clientdata))) { + + return iter->types[(long) SCM_CAR(s) >> 16]; + } + iter = iter->next; + } while (iter != module); + return 0; +} + +#ifdef SWIG_GLOBAL +#define SWIG_GUILE_MODULE_STATIC +#elif !defined(SWIG_NOINCLUDE) +#define SWIG_GUILE_MODULE_STATIC static +#endif + +#ifdef SWIG_GUILE_MODULE_STATIC +static swig_module_info *swig_guile_module = 0; +SWIG_GUILE_MODULE_STATIC swig_module_info *SWIG_Guile_GetModule(void) { + return swig_guile_module; +} +SWIG_GUILE_MODULE_STATIC void SWIG_Guile_SetModule(swig_module_info *pointer) { + swig_guile_module = pointer; +} +#else +SWIGEXPORT swig_module_info * SWIG_Guile_GetModule(void); +SWIGEXPORT void SWIG_Guile_SetModule(swig_module_info *pointer); +#endif + +SWIGINTERN SCM +SWIG_Guile_NewPointerObj(swig_module_info *module, void *ptr, + swig_type_info *type, int owner) +{ + unsigned long tag; + if (ptr==NULL) return SCM_EOL; + if (!module) return SCM_EOL; + for (tag = 0; tag < module->size; ++tag) { + if (module->types[tag] == type) + break; + } + if (tag >= module->size) + return SCM_EOL; + + + SCM_RETURN_NEWSMOB( ((tag << 16) | *((int *)module->clientdata)), ptr); +} + +/* Return 0 if successful. */ +SWIGINTERN int +SWIG_Guile_ConvertPtr(swig_module_info *module, SCM s, void **result, + swig_type_info *type, int flags) +{ + swig_cast_info *cast; + swig_type_info *from; + if (SCM_NULLP(s)) { + *result = NULL; + return SWIG_OK; + } else if (SCM_NIMP(s)) { + from = SWIG_Guile_LookupType(module, s, 1); + if (!from) return SWIG_ERROR; + if (type) { + cast = SWIG_TypeCheckStruct(from, type); + if (cast) { + int newmemory = 0; + *result = SWIG_TypeCast(cast, (void *) SCM_CDR(s), &newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + return SWIG_OK; + } else { + return SWIG_ERROR; + } + } else { + *result = (void *) SCM_CDR(s); + return SWIG_OK; + } + } + return SWIG_ERROR; +} + +SWIGINTERN void * +SWIG_Guile_MustGetPtr (swig_module_info *module, SCM s, swig_type_info *type, + int argnum, int flags, const char *func_name) +{ + void *result; + int res = SWIG_Guile_ConvertPtr(module, s, &result, type, flags); + if (!SWIG_IsOK(res)) { + /* type mismatch */ + scm_wrong_type_arg((char *) func_name, argnum, s); + } + return result; +} + +/* Init */ + +SWIGINTERN int +print_swig (SCM swig_smob, SCM port, scm_print_state *pstate) +{ + swig_type_info *type = SWIG_Guile_LookupType(0, swig_smob, 1); + if (type) { + scm_puts((char *) "#<swig ", port); + if (type->str != NULL) + scm_puts((char *) type->str, port); + else + scm_puts((char *) type->name, port); + scm_puts((char *) " ", port); + scm_intprint((long) SCM_CDR(swig_smob), 16, port); + scm_puts((char *) ">", port); + /* non-zero means success */ + return 1; + } else { + return 0; + } +} + +SWIGINTERN SCM +equalp_swig (SCM A, SCM B) +{ + if (SCM_CAR(A) == SCM_CAR(B) + && SCM_CDR(A) == SCM_CDR(B)) + return SCM_BOOL_T; + else return SCM_BOOL_F; +} + +SWIGINTERN void +SWIG_Guile_Init (swig_module_info *module) +{ + *((int *)module->clientdata) = + scm_make_smob_type_mfpe((char *) "swig", 0, NULL, NULL, print_swig, equalp_swig); +} + +SWIGINTERN int +SWIG_Guile_GetArgs (SCM *dest, SCM rest, + int reqargs, int optargs, + const char *procname) +{ + int i; + int num_args_passed = 0; + for (i = 0; i<reqargs; i++) { + if (!SCM_CONSP(rest)) + scm_wrong_num_args(gh_str02scm((char *) procname)); + *dest++ = SCM_CAR(rest); + rest = SCM_CDR(rest); + num_args_passed++; + } + for (i = 0; i<optargs && SCM_CONSP(rest); i++) { + *dest++ = SCM_CAR(rest); + rest = SCM_CDR(rest); + num_args_passed++; + } + for (; i<optargs; i++) + *dest++ = SCM_UNDEFINED; + if (!SCM_NULLP(rest)) + scm_wrong_num_args(gh_str02scm((char *) procname)); + return num_args_passed; +} + +#ifdef __cplusplus +} +#endif + +/* guile.swg ends here */ diff --git a/devtools/swigwin-1.3.34/Lib/guile/guile_scm.swg b/devtools/swigwin-1.3.34/Lib/guile/guile_scm.swg new file mode 100644 index 0000000..caded72 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/guile_scm.swg @@ -0,0 +1,53 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * guile_scm.swg + * + * This SWIG interface file is processed if the Guile module is run + * with SCM_ flavor. + * ----------------------------------------------------------------------------- */ + +#define SWIGGUILE_SCM + +%runtime "swigrun.swg" // Common C API type-checking code + +%runtime "guile_scm_run.swg" +%include <ghinterface.i> +%include <guile.i> + +%runtime %{ + +#define GUILE_MAYBE_VALUES \ + if (gswig_list_p) gswig_result = scm_values(gswig_result); + +#define GUILE_MAYBE_VECTOR \ + if (gswig_list_p) gswig_result = scm_vector(gswig_result); + +#define SWIG_APPEND_VALUE(object) \ + if (gswig_result == SCM_UNSPECIFIED) \ + gswig_result = object; \ + else { \ + if (!gswig_list_p) { \ + gswig_list_p = 1; \ + gswig_result = scm_listify(gswig_result, object, SCM_UNDEFINED); \ + } \ + else \ + gswig_result = scm_append(scm_listify(gswig_result, scm_listify(object, SCM_UNDEFINED), SCM_UNDEFINED)); \ + } + /* used by Lib/exception.i */ + #define gh_symbol2scm scm_str2symbol + /* useb by Lib/cdata.i */ + #define gh_str2scm scm_mem2string + +%} + +%insert(init) "swiginit.swg" + +%init %{ +SWIG_GUILE_INIT_STATIC void +SWIG_init(void) +{ + SWIG_InitializeModule(0); + SWIG_PropagateClientData(); +%} diff --git a/devtools/swigwin-1.3.34/Lib/guile/guile_scm_run.swg b/devtools/swigwin-1.3.34/Lib/guile/guile_scm_run.swg new file mode 100644 index 0000000..5da8558 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/guile_scm_run.swg @@ -0,0 +1,485 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * guile_scm_run.swg + * ----------------------------------------------------------------------------- */ + +#include <libguile.h> +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <assert.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef SCM (*swig_guile_proc)(); +typedef SCM (*guile_destructor)(SCM); + +typedef struct swig_guile_clientdata { + guile_destructor destroy; + SCM goops_class; +} swig_guile_clientdata; + +#define SWIG_scm2str(s) \ + SWIG_Guile_scm2newstr(s, NULL) +#define SWIG_malloc(size) \ + SCM_MUST_MALLOC(size) +#define SWIG_free(mem) \ + scm_must_free(mem) +#define SWIG_ConvertPtr(s, result, type, flags) \ + SWIG_Guile_ConvertPtr(s, result, type, flags) +#define SWIG_MustGetPtr(s, type, argnum, flags) \ + SWIG_Guile_MustGetPtr(s, type, argnum, flags, FUNC_NAME) +#define SWIG_NewPointerObj(ptr, type, owner) \ + SWIG_Guile_NewPointerObj((void*)ptr, type, owner) +#define SWIG_PointerAddress(object) \ + SWIG_Guile_PointerAddress(object) +#define SWIG_PointerType(object) \ + SWIG_Guile_PointerType(object) +#define SWIG_IsPointerOfType(object, type) \ + SWIG_Guile_IsPointerOfType(object, type) +#define SWIG_IsPointer(object) \ + SWIG_Guile_IsPointer(object) +#define SWIG_contract_assert(expr, msg) \ + if (!(expr)) \ + scm_error(scm_str2symbol("swig-contract-assertion-failed"), \ + (char *) FUNC_NAME, (char *) msg, \ + SCM_EOL, SCM_BOOL_F); else + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) \ + SWIG_Guile_ConvertMember(obj, ptr, sz, ty, FUNC_NAME) +#define SWIG_NewMemberObj(ptr, sz, type) \ + SWIG_Guile_NewMemberObj(ptr, sz, type, FUNC_NAME) + +/* Runtime API */ +static swig_module_info *SWIG_Guile_GetModule(void); +#define SWIG_GetModule(clientdata) SWIG_Guile_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Guile_SetModule(pointer) + +SWIGINTERN char * +SWIG_Guile_scm2newstr(SCM str, size_t *len) { +#define FUNC_NAME "SWIG_Guile_scm2newstr" + char *ret; + size_t l; + + SCM_ASSERT (SCM_STRINGP(str), str, 1, FUNC_NAME); + + l = SCM_STRING_LENGTH(str); + ret = (char *) SWIG_malloc( (l + 1) * sizeof(char)); + if (!ret) return NULL; + + memcpy(ret, SCM_STRING_CHARS(str), l); + ret[l] = '\0'; + if (len) *len = l; + return ret; +#undef FUNC_NAME +} + +static int swig_initialized = 0; +static scm_t_bits swig_tag = 0; +static scm_t_bits swig_collectable_tag = 0; +static scm_t_bits swig_destroyed_tag = 0; +static scm_t_bits swig_member_function_tag = 0; +static SCM swig_make_func = SCM_EOL; +static SCM swig_keyword = SCM_EOL; +static SCM swig_symbol = SCM_EOL; + +#define SWIG_Guile_GetSmob(x) \ + ( SCM_NNULLP(x) && SCM_INSTANCEP(x) && SCM_NFALSEP(scm_slot_exists_p(x, swig_symbol)) \ + ? scm_slot_ref(x, swig_symbol) : (x) ) + +SWIGINTERN SCM +SWIG_Guile_NewPointerObj(void *ptr, swig_type_info *type, int owner) +{ + if (ptr == NULL) + return SCM_EOL; + else { + SCM smob; + swig_guile_clientdata *cdata = (swig_guile_clientdata *) type->clientdata; + if (owner) + SCM_NEWSMOB2(smob, swig_collectable_tag, ptr, (void *) type); + else + SCM_NEWSMOB2(smob, swig_tag, ptr, (void *) type); + + if (!cdata || SCM_NULLP(cdata->goops_class) || swig_make_func == SCM_EOL ) { + return smob; + } else { + /* the scm_make() C function only handles the creation of gf, + methods and classes (no instances) the (make ...) function is + later redefined in goops.scm. So we need to call that + Scheme function. */ + return scm_apply(swig_make_func, + scm_list_3(cdata->goops_class, + swig_keyword, + smob), + SCM_EOL); + } + } +} + +SWIGINTERN unsigned long +SWIG_Guile_PointerAddress(SCM object) +{ + SCM smob = SWIG_Guile_GetSmob(object); + if (SCM_NULLP(smob)) return 0; + else if (SCM_SMOB_PREDICATE(swig_tag, smob) + || SCM_SMOB_PREDICATE(swig_collectable_tag, smob) + || SCM_SMOB_PREDICATE(swig_destroyed_tag, smob)) { + return (unsigned long) (void *) SCM_CELL_WORD_1(smob); + } + else scm_wrong_type_arg("SWIG-Guile-PointerAddress", 1, object); +} + +SWIGINTERN swig_type_info * +SWIG_Guile_PointerType(SCM object) +{ + SCM smob = SWIG_Guile_GetSmob(object); + if (SCM_NULLP(smob)) return NULL; + else if (SCM_SMOB_PREDICATE(swig_tag, smob) + || SCM_SMOB_PREDICATE(swig_collectable_tag, smob) + || SCM_SMOB_PREDICATE(swig_destroyed_tag, smob)) { + return (swig_type_info *) SCM_CELL_WORD_2(smob); + } + else scm_wrong_type_arg("SWIG-Guile-PointerType", 1, object); +} + +SWIGINTERN int +SWIG_Guile_ConvertPtr(SCM s, void **result, swig_type_info *type, int flags) +{ + swig_cast_info *cast; + swig_type_info *from; + SCM smob = SWIG_Guile_GetSmob(s); + + if (SCM_NULLP(smob)) { + *result = NULL; + return SWIG_OK; + } else if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)) { + /* we do not accept smobs representing destroyed pointers */ + from = (swig_type_info *) SCM_CELL_WORD_2(smob); + if (!from) return SWIG_ERROR; + if (type) { + cast = SWIG_TypeCheckStruct(from, type); + if (cast) { + int newmemory = 0; + *result = SWIG_TypeCast(cast, (void *) SCM_CELL_WORD_1(smob), &newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + return SWIG_OK; + } else { + return SWIG_ERROR; + } + } else { + *result = (void *) SCM_CELL_WORD_1(smob); + return SWIG_OK; + } + } + return SWIG_ERROR; +} + +SWIGINTERNINLINE void * +SWIG_Guile_MustGetPtr (SCM s, swig_type_info *type, + int argnum, int flags, const char *func_name) +{ + void *result; + int res = SWIG_Guile_ConvertPtr(s, &result, type, flags); + if (!SWIG_IsOK(res)) { + /* type mismatch */ + scm_wrong_type_arg((char *) func_name, argnum, s); + } + return result; +} + +SWIGINTERNINLINE int +SWIG_Guile_IsPointerOfType (SCM s, swig_type_info *type) +{ + void *result; + if (SWIG_Guile_ConvertPtr(s, &result, type, 0)) { + /* type mismatch */ + return 0; + } + else return 1; +} + +SWIGINTERNINLINE int +SWIG_Guile_IsPointer (SCM s) +{ + /* module might not be initialized yet, so initialize it */ + SWIG_Guile_GetModule(); + return SWIG_Guile_IsPointerOfType (s, NULL); +} + +/* Mark a pointer object non-collectable */ +SWIGINTERN void +SWIG_Guile_MarkPointerNoncollectable(SCM s) +{ + SCM smob = SWIG_Guile_GetSmob(s); + if (!SCM_NULLP(smob)) { + if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)) { + SCM_SET_CELL_TYPE(smob, swig_tag); + } + else scm_wrong_type_arg(NULL, 0, s); + } +} + +/* Mark a pointer object destroyed */ +SWIGINTERN void +SWIG_Guile_MarkPointerDestroyed(SCM s) +{ + SCM smob = SWIG_Guile_GetSmob(s); + if (!SCM_NULLP(smob)) { + if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)) { + SCM_SET_CELL_TYPE(smob, swig_destroyed_tag); + } + else scm_wrong_type_arg(NULL, 0, s); + } +} + +/* Member functions */ + +SWIGINTERN SCM +SWIG_Guile_NewMemberObj(void *ptr, size_t sz, swig_type_info *type, + const char *func_name) +{ + SCM smob; + void *copy = malloc(sz); + memcpy(copy, ptr, sz); + SCM_NEWSMOB2(smob, swig_member_function_tag, copy, (void *) type); + return smob; +} + +SWIGINTERN int +SWIG_Guile_ConvertMember(SCM smob, void *ptr, size_t sz, swig_type_info *type, + const char *func_name) +{ + swig_cast_info *cast; + swig_type_info *from; + + if (SCM_SMOB_PREDICATE(swig_member_function_tag, smob)) { + from = (swig_type_info *) SCM_CELL_WORD_2(smob); + if (!from) return SWIG_ERROR; + if (type) { + cast = SWIG_TypeCheckStruct(from, type); + if (!cast) return SWIG_ERROR; + } + memcpy(ptr, (void *) SCM_CELL_WORD_1(smob), sz); + return SWIG_OK; + } + return SWIG_ERROR; +} + + +/* Init */ + +SWIGINTERN int +print_swig_aux (SCM swig_smob, SCM port, scm_print_state *pstate, + const char *attribute) +{ + swig_type_info *type; + + type = (swig_type_info *) SCM_CELL_WORD_2(swig_smob); + if (type) { + scm_puts((char *) "#<", port); + scm_puts((char *) attribute, port); + scm_puts((char *) "swig-pointer ", port); + scm_puts((char *) SWIG_TypePrettyName(type), port); + scm_puts((char *) " ", port); + scm_intprint((long) SCM_CELL_WORD_1(swig_smob), 16, port); + scm_puts((char *) ">", port); + /* non-zero means success */ + return 1; + } else { + return 0; + } +} + + +SWIGINTERN int +print_swig (SCM swig_smob, SCM port, scm_print_state *pstate) +{ + return print_swig_aux(swig_smob, port, pstate, ""); +} + +SWIGINTERN int +print_collectable_swig (SCM swig_smob, SCM port, scm_print_state *pstate) +{ + return print_swig_aux(swig_smob, port, pstate, "collectable-"); +} + +SWIGINTERN int +print_destroyed_swig (SCM swig_smob, SCM port, scm_print_state *pstate) +{ + return print_swig_aux(swig_smob, port, pstate, "destroyed-"); +} + +SWIGINTERN int +print_member_function_swig (SCM swig_smob, SCM port, scm_print_state *pstate) +{ + swig_type_info *type; + type = (swig_type_info *) SCM_CELL_WORD_2(swig_smob); + if (type) { + scm_puts((char *) "#<", port); + scm_puts((char *) "swig-member-function-pointer ", port); + scm_puts((char *) SWIG_TypePrettyName(type), port); + scm_puts((char *) " >", port); + /* non-zero means success */ + return 1; + } else { + return 0; + } +} + +SWIGINTERN SCM +equalp_swig (SCM A, SCM B) +{ + if (SCM_CELL_WORD_0(A) == SCM_CELL_WORD_0(B) && SCM_CELL_WORD_1(A) == SCM_CELL_WORD_1(B) + && SCM_CELL_WORD_2(A) == SCM_CELL_WORD_2(B)) + return SCM_BOOL_T; + else return SCM_BOOL_F; +} + +SWIGINTERN size_t +free_swig(SCM A) +{ + swig_type_info *type = (swig_type_info *) SCM_CELL_WORD_2(A); + if (type) { + if (type->clientdata && ((swig_guile_clientdata *)type->clientdata)->destroy) + ((swig_guile_clientdata *)type->clientdata)->destroy(A); + } + return 0; +} + +SWIGINTERN size_t +free_swig_member_function(SCM A) +{ + free((swig_type_info *) SCM_CELL_WORD_1(A)); + return 0; +} + +SWIGINTERN int +ensure_smob_tag(SCM swig_module, + scm_t_bits *tag_variable, + const char *smob_name, + const char *scheme_variable_name) +{ + SCM variable = scm_sym2var(scm_str2symbol(scheme_variable_name), + scm_module_lookup_closure(swig_module), + SCM_BOOL_T); + if (SCM_UNBNDP(SCM_VARIABLE_REF(variable))) { + *tag_variable = scm_make_smob_type((char*)scheme_variable_name, 0); + SCM_VARIABLE_SET(variable, + scm_ulong2num(*tag_variable)); + return 1; + } + else { + *tag_variable = scm_num2ulong(SCM_VARIABLE_REF(variable), 0, + "SWIG_Guile_Init"); + return 0; + } +} + +SWIGINTERN SCM +SWIG_Guile_Init () +{ + static SCM swig_module; + + if (swig_initialized) return swig_module; + swig_initialized = 1; + + swig_module = scm_c_resolve_module("Swig swigrun"); + if (ensure_smob_tag(swig_module, &swig_tag, + "swig-pointer", "swig-pointer-tag")) { + scm_set_smob_print(swig_tag, print_swig); + scm_set_smob_equalp(swig_tag, equalp_swig); + } + if (ensure_smob_tag(swig_module, &swig_collectable_tag, + "collectable-swig-pointer", "collectable-swig-pointer-tag")) { + scm_set_smob_print(swig_collectable_tag, print_collectable_swig); + scm_set_smob_equalp(swig_collectable_tag, equalp_swig); + scm_set_smob_free(swig_collectable_tag, free_swig); + } + if (ensure_smob_tag(swig_module, &swig_destroyed_tag, + "destroyed-swig-pointer", "destroyed-swig-pointer-tag")) { + scm_set_smob_print(swig_destroyed_tag, print_destroyed_swig); + scm_set_smob_equalp(swig_destroyed_tag, equalp_swig); + } + if (ensure_smob_tag(swig_module, &swig_member_function_tag, + "swig-member-function-pointer", "swig-member-function-pointer-tag")) { + scm_set_smob_print(swig_member_function_tag, print_member_function_swig); + scm_set_smob_free(swig_member_function_tag, free_swig_member_function); + } + swig_make_func = scm_permanent_object( + scm_variable_ref(scm_c_module_lookup(scm_c_resolve_module("oop goops"), "make"))); + swig_keyword = scm_permanent_object(scm_c_make_keyword((char*) "init-smob")); + swig_symbol = scm_permanent_object(scm_str2symbol("swig-smob")); +#ifdef SWIG_INIT_RUNTIME_MODULE + SWIG_INIT_RUNTIME_MODULE +#endif + + return swig_module; +} + +SWIGINTERN swig_module_info * +SWIG_Guile_GetModule(void) +{ + SCM module; + SCM variable; + + module = SWIG_Guile_Init(); + + variable = scm_sym2var(scm_str2symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME), + scm_module_lookup_closure(module), + SCM_BOOL_T); + if (SCM_UNBNDP(SCM_VARIABLE_REF(variable))) { + return NULL; + } else { + return (swig_module_info *) scm_num2ulong(SCM_VARIABLE_REF(variable), 0, "SWIG_Guile_Init"); + } +} + +SWIGINTERN void +SWIG_Guile_SetModule(swig_module_info *swig_module) +{ + SCM module; + SCM variable; + + module = SWIG_Guile_Init(); + + variable = scm_sym2var(scm_str2symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME), + scm_module_lookup_closure(module), + SCM_BOOL_T); + + SCM_VARIABLE_SET(variable, scm_ulong2num((unsigned long) swig_module)); +} + +SWIGINTERN int +SWIG_Guile_GetArgs (SCM *dest, SCM rest, + int reqargs, int optargs, + const char *procname) +{ + int i; + int num_args_passed = 0; + for (i = 0; i<reqargs; i++) { + if (!SCM_CONSP(rest)) + scm_wrong_num_args(scm_makfrom0str((char *) procname)); + *dest++ = SCM_CAR(rest); + rest = SCM_CDR(rest); + num_args_passed++; + } + for (i = 0; i<optargs && SCM_CONSP(rest); i++) { + *dest++ = SCM_CAR(rest); + rest = SCM_CDR(rest); + num_args_passed++; + } + for (; i<optargs; i++) + *dest++ = SCM_UNDEFINED; + if (!SCM_NULLP(rest)) + scm_wrong_num_args(scm_makfrom0str((char *) procname)); + return num_args_passed; +} + +#ifdef __cplusplus +} +#endif diff --git a/devtools/swigwin-1.3.34/Lib/guile/guilemain.i b/devtools/swigwin-1.3.34/Lib/guile/guilemain.i new file mode 100644 index 0000000..6f4e4d9 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/guilemain.i @@ -0,0 +1,47 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * guilemain.i + * + * The main functions for a user augmented guile + * version that can handle wrapped calls as generated by SWIG + * ----------------------------------------------------------------------------- */ + +%{ +#include <libguile.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* Debugger interface (don't change the order of the following lines) */ +#define GDB_TYPE SCM +#include <libguile/gdb_interface.h> +GDB_INTERFACE; + +static void +inner_main(void *closure, int argc, char **argv) +{ +#ifdef SWIGINIT + SWIGINIT +#else + SWIG_init(); /* SWIG init function */ +#endif + scm_shell(argc, argv); /* scheme interpreter */ + /* never reached: scm_shell will perform an exit */ +} + +#ifdef __cplusplus +} +#endif + +int +main(int argc, char **argv) +{ + /* put any default initialisation code here: e.g. exit handlers */ + scm_boot_guile(argc, argv, inner_main, 0); /* make a stack entry for the + garbage collector */ + return 0; /* never reached, but avoids a warning */ +} +%} diff --git a/devtools/swigwin-1.3.34/Lib/guile/interpreter.i b/devtools/swigwin-1.3.34/Lib/guile/interpreter.i new file mode 100644 index 0000000..7e8f077 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/interpreter.i @@ -0,0 +1,62 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * interpreter.i + * + * SWIG file for a simple Guile interpreter + * ----------------------------------------------------------------------------- */ + +%{ + +#include <stdio.h> +GSCM_status guile_init(); + +int main(int argc, char **argv) { + GSCM_status status; + GSCM_top_level toplev; + char *eval_answer; + char input_str[16384]; + int done; + + /* start a scheme interpreter */ + status = gscm_run_scm(argc, argv, 0, stdout, stderr, guile_init, 0, "#t"); + if (status != GSCM_OK) { + fputs(gscm_error_msg(status), stderr); + fputc('\n', stderr); + printf("Error in startup.\n"); + exit(1); + } + + /* create the top level environment */ + status = gscm_create_top_level(&toplev); + if (status != GSCM_OK) { + fputs(gscm_error_msg(status), stderr); + fputc('\n', stderr); + exit(1); + } + + /* now sit in a scheme eval loop: I input the expressions, have guile + * evaluate them, and then get another expression. + */ + done = 0; + fprintf(stdout,"Guile > "); + while (!done) { + if (fgets(input_str,16384,stdin) == NULL) { + exit(1); + } else { + if (strncmp(input_str,"quit",4) == 0) exit(1); + status = gscm_eval_str(&eval_answer, toplev, input_str); + fprintf(stdout,"%s\n", eval_answer); + fprintf(stdout,"Guile > "); + } + } + + /* now clean up and quit */ + gscm_destroy_top_level(toplev); +} + +%} + + + diff --git a/devtools/swigwin-1.3.34/Lib/guile/list-vector.i b/devtools/swigwin-1.3.34/Lib/guile/list-vector.i new file mode 100644 index 0000000..d98cae5 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/list-vector.i @@ -0,0 +1,491 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * list_vector.i + * + * Guile typemaps for converting between arrays and Scheme lists or vectors + * ----------------------------------------------------------------------------- */ + +/* Here is a macro that will define typemaps for converting between C + arrays and Scheme lists or vectors when passing arguments to the C + function. + + TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(C_TYPE, SCM_TO_C, C_TO_SCM, SCM_TYPE) + + Supported calling conventions: + + func(int VECTORLENINPUT, [const] C_TYPE *VECTORINPUT) + + Scheme wrapper will take one argument, a vector. A temporary C + array of elements of type C_TYPE will be allocated and filled + with the elements of the vectors, converted to C with the + SCM_TO_C function. Length and address of the array are passed + to the C function. + + SCM_TYPE is used to describe the Scheme type of the elements in + the Guile procedure documentation. + + func(int LISTLENINPUT, [const] C_TYPE *LISTINPUT) + + Likewise, but the Scheme wrapper will take one argument, a list. + + func(int *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT) + + Scheme wrapper will take no arguments. Addresses of an integer + and a C_TYPE * variable will be passed to the C function. The + C function is expected to return address and length of a + freshly allocated array of elements of type C_TYPE through + these pointers. The elements of this array are converted to + Scheme with the C_TO_SCM function and returned as a Scheme + vector. + + If the function has a void return value, the vector constructed + by this typemap becomes the return value of the Scheme wrapper. + Otherwise, the function returns multiple values. (See + the documentation on how to deal with multiple values.) + + func(int *LISTLENOUTPUT, C_TYPE **LISTOUTPUT) + + Likewise, but the Scheme wrapper will return a list instead of + a vector. + + It is also allowed to use "size_t LISTLENINPUT" rather than "int + LISTLENINPUT". */ + +%define TYPEMAP_LIST_VECTOR_INPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, SCM_TYPE) + + /* input */ + + /* We make use of the new multi-dispatch typemaps here. */ + + %typemap(in, doc="$NAME is a vector of " #SCM_TYPE " values") + (int VECTORLENINPUT, C_TYPE *VECTORINPUT), + (size_t VECTORLENINPUT, C_TYPE *VECTORINPUT) + { + SCM_VALIDATE_VECTOR($argnum, $input); + $1 = gh_vector_length($input); + if ($1 > 0) { + $1_ltype i; + $2 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * $1); + for (i = 0; i<$1; i++) { + SCM swig_scm_value = gh_vector_ref($input, gh_int2scm(i)); + $2[i] = SCM_TO_C_EXPR; + } + } + else $2 = NULL; + } + + %typemap(in, doc="$NAME is a list of " #SCM_TYPE " values") + (int LISTLENINPUT, C_TYPE *LISTINPUT), + (size_t LISTLENINPUT, C_TYPE *LISTINPUT) + { + SCM_VALIDATE_LIST($argnum, $input); + $1 = gh_length($input); + if ($1 > 0) { + $1_ltype i; + SCM rest; + $2 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * $1); + for (i = 0, rest = $input; + i<$1; + i++, rest = gh_cdr(rest)) { + SCM swig_scm_value = gh_car(rest); + $2[i] = SCM_TO_C_EXPR; + } + } + else $2 = NULL; + } + + /* Do not check for NULL pointers (override checks). */ + + %typemap(check) (int VECTORLENINPUT, C_TYPE *VECTORINPUT), + (size_t VECTORLENINPUT, C_TYPE *VECTORINPUT), + (int LISTLENINPUT, C_TYPE *LISTINPUT), + (size_t LISTLENINPUT, C_TYPE *LISTINPUT) + "/* no check for NULL pointer */"; + + /* Discard the temporary array after the call. */ + + %typemap(freearg) (int VECTORLENINPUT, C_TYPE *VECTORINPUT), + (size_t VECTORLENINPUT, C_TYPE *VECTORINPUT), + (int LISTLENINPUT, C_TYPE *LISTINPUT), + (size_t LISTLENINPUT, C_TYPE *LISTINPUT) + {if ($2!=NULL) SWIG_free($2);} + +%enddef + + /* output */ + +%define TYPEMAP_LIST_VECTOR_OUTPUT_WITH_EXPR(C_TYPE, C_TO_SCM_EXPR, SCM_TYPE) + + /* First we make temporary variables ARRAYLENTEMP and ARRAYTEMP, + whose addresses we pass to the C function. We ignore both + arguments for Scheme. */ + + %typemap(in,numinputs=0) (int *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT) + (int arraylentemp, C_TYPE *arraytemp), + (int *LISTLENOUTPUT, C_TYPE **LISTOUTPUT) + (int arraylentemp, C_TYPE *arraytemp), + (size_t *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT) + (size_t arraylentemp, C_TYPE *arraytemp), + (size_t *LISTLENOUTPUT, C_TYPE **LISTOUTPUT) + (size_t arraylentemp, C_TYPE *arraytemp) + %{ + $1 = &arraylentemp; + $2 = &arraytemp; + %} + + /* In the ARGOUT typemaps, we convert the array into a vector or + a list and append it to the results. */ + + %typemap(argout, doc="$NAME (a vector of " #SCM_TYPE " values)") + (int *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT), + (size_t *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT) + { + $*1_ltype i; + SCM res = gh_make_vector(gh_int2scm(*$1), + SCM_BOOL_F); + for (i = 0; i<*$1; i++) { + C_TYPE swig_c_value = (*$2)[i]; + SCM elt = C_TO_SCM_EXPR; + gh_vector_set_x(res, gh_int2scm(i), elt); + } + SWIG_APPEND_VALUE(res); + } + + %typemap(argout, doc="$NAME (a list of " #SCM_TYPE " values)") + (int *LISTLENOUTPUT, C_TYPE **LISTOUTPUT), + (size_t *LISTLENOUTPUT, C_TYPE **LISTOUTPUT) + { + int i; + SCM res = SCM_EOL; + for (i = ((int)(*$1)) - 1; i>=0; i--) { + C_TYPE swig_c_value = (*$2)[i]; + SCM elt = C_TO_SCM_EXPR; + res = gh_cons(elt, res); + } + SWIG_APPEND_VALUE(res); + } + + /* In the FREEARG typemaps, get rid of the C vector. + (This can be overridden if you want to keep the C vector.) */ + + %typemap(freearg) + (int *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT), + (size_t *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT), + (int *LISTLENOUTPUT, C_TYPE **LISTOUTPUT), + (size_t *LISTLENOUTPUT, C_TYPE **LISTOUTPUT) + { + if ((*$2)!=NULL) free(*$2); + } + +%enddef + +%define TYPEMAP_LIST_VECTOR_INPUT_OUTPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, C_TO_SCM_EXPR, SCM_TYPE) + TYPEMAP_LIST_VECTOR_INPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, SCM_TYPE) + TYPEMAP_LIST_VECTOR_OUTPUT_WITH_EXPR(C_TYPE, C_TO_SCM_EXPR, SCM_TYPE) +%enddef + +%define TYPEMAP_LIST_VECTOR_INPUT(C_TYPE, SCM_TO_C, SCM_TYPE) + TYPEMAP_LIST_VECTOR_INPUT_WITH_EXPR + (C_TYPE, SCM_TO_C(swig_scm_value), SCM_TYPE) +%enddef + +%define TYPEMAP_LIST_VECTOR_OUTPUT(C_TYPE, C_TO_SCM, SCM_TYPE) + TYPEMAP_LIST_VECTOR_OUTPUT_WITH_EXPR + (C_TYPE, C_TO_SCM(swig_c_value), SCM_TYPE) +%enddef + +%define TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(C_TYPE, SCM_TO_C, C_TO_SCM, SCM_TYPE) + TYPEMAP_LIST_VECTOR_INPUT_OUTPUT_WITH_EXPR + (C_TYPE, SCM_TO_C(swig_scm_value), C_TO_SCM(swig_c_value), SCM_TYPE) +%enddef + +/* We use the macro to define typemaps for some standard types. */ + +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(bool, gh_scm2bool, gh_bool2scm, boolean); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char, gh_scm2char, gh_char2scm, char); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned char, gh_scm2char, gh_char2scm, char); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(int, gh_scm2int, gh_int2scm, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(short, gh_scm2int, gh_int2scm, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(long, gh_scm2long, gh_long2scm, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, gh_scm2long, gh_long2scm, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned int, gh_scm2ulong, gh_ulong2scm, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned short, gh_scm2ulong, gh_ulong2scm, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned long, gh_scm2ulong, gh_ulong2scm, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(size_t, gh_scm2ulong, gh_ulong2scm, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(float, gh_scm2double, gh_double2scm, real); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(double, gh_scm2double, gh_double2scm, real); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, gh_str02scm, string); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string); + +/* For the char *, free all strings after converting */ + + %typemap(freearg) + (int *VECTORLENOUTPUT, char ***VECTOROUTPUT), + (size_t *VECTORLENOUTPUT, char ***VECTOROUTPUT), + (int *LISTLENOUTPUT, char ***LISTOUTPUT), + (size_t *LISTLENOUTPUT, char ***LISTOUTPUT), + (int *VECTORLENOUTPUT, const char ***VECTOROUTPUT), + (size_t *VECTORLENOUTPUT, const char ***VECTOROUTPUT), + (int *LISTLENOUTPUT, const char ***LISTOUTPUT), + (size_t *LISTLENOUTPUT, const char ***LISTOUTPUT) + { + if ((*$2)!=NULL) { + int i; + for (i = 0; i < *$1; i++) { + if ((*$2)[i] != NULL) free((*$2)[i]); + } + free(*$2); + } + } + +%typemap(freearg) (int VECTORLENINPUT, char **VECTORINPUT), + (size_t VECTORLENINPUT, char **VECTORINPUT), + (int LISTLENINPUT, char **LISTINPUT), + (size_t LISTLENINPUT, char **LISTINPUT), + (int VECTORLENINPUT, const char **VECTORINPUT), + (size_t VECTORLENINPUT, const char **VECTORINPUT), + (int LISTLENINPUT, const char **LISTINPUT), + (size_t LISTLENINPUT, const char **LISTINPUT) +{ + if (($2)!=NULL) { + int i; + for (i = 0; i< $1; i++) + if (($2)[i] != NULL) free(($2)[i]); + free($2); + } +} + + +/* Following is a macro that emits typemaps that are much more + flexible. (They are also messier.) It supports multiple parallel + lists and vectors (sharing one length argument each). + + TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(C_TYPE, SCM_TO_C, C_TO_SCM, SCM_TYPE) + + Supported calling conventions: + + func(int PARALLEL_VECTORLENINPUT, [const] C_TYPE *PARALLEL_VECTORINPUT, ...) or + func([const] C_TYPE *PARALLEL_VECTORINPUT, ..., int PARALLEL_VECTORLENINPUT) + + func(int PARALLEL_LISTLENINPUT, [const] C_TYPE *PARALLEL_LISTINPUT, ...) or + func([const] C_TYPE *PARALLEL_LISTINPUT, ..., int PARALLEL_LISTLENINPUT) + + func(int *PARALLEL_VECTORLENOUTPUT, C_TYPE **PARALLEL_VECTOROUTPUT, ...) or + func(C_TYPE **PARALLEL_VECTOROUTPUT, int *PARALLEL_VECTORLENOUTPUT, ...) + + func(int *PARALLEL_LISTLENOUTPUT, C_TYPE **PARALLEL_LISTOUTPUT) or + func(C_TYPE **PARALLEL_LISTOUTPUT, int *PARALLEL_LISTLENOUTPUT) + + It is also allowed to use "size_t PARALLEL_LISTLENINPUT" rather than "int + PARALLEL_LISTLENINPUT". */ + +%define TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, SCM_TYPE) + + /* input */ + + /* Passing data is a little complicated here; just remember: + IGNORE typemaps come first, then IN, then CHECK. But if + IGNORE is given, IN won't be used for this type. + + We need to "ignore" one of the parameters because there shall + be only one argument on the Scheme side. Here we only + initialize the array length to 0 but save its address for a + later change. */ + + %typemap(in,numinputs=0) int PARALLEL_VECTORLENINPUT (int *_global_vector_length), + size_t PARALLEL_VECTORLENINPUT (size_t *_global_vector_length) + { + $1 = 0; + _global_vector_length = &$1; + } + + %typemap(in,numinputs=0) int PARALLEL_LISTLENINPUT (int *_global_list_length), + size_t PARALLEL_LISTLENINPUT (size_t *_global_list_length) + { + $1 = 0; + _global_list_length = &$1; + } + + /* All the work is done in IN. */ + + %typemap(in, doc="$NAME is a vector of " #SCM_TYPE " values") + C_TYPE *PARALLEL_VECTORINPUT, + const C_TYPE *PARALLEL_VECTORINPUT + { + SCM_VALIDATE_VECTOR($argnum, $input); + *_global_vector_length = gh_vector_length($input); + if (*_global_vector_length > 0) { + int i; + $1 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) + * (*_global_vector_length)); + for (i = 0; i<*_global_vector_length; i++) { + SCM swig_scm_value = gh_vector_ref($input, gh_int2scm(i)); + $1[i] = SCM_TO_C_EXPR; + } + } + else $1 = NULL; + } + + %typemap(in, doc="$NAME is a list of " #SCM_TYPE " values") + C_TYPE *PARALLEL_LISTINPUT, + const C_TYPE *PARALLEL_LISTINPUT + { + SCM_VALIDATE_LIST($argnum, $input); + *_global_list_length = gh_length($input); + if (*_global_list_length > 0) { + int i; + SCM rest; + $1 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) + * (*_global_list_length)); + for (i = 0, rest = $input; + i<*_global_list_length; + i++, rest = gh_cdr(rest)) { + SCM swig_scm_value = gh_car(rest); + $1[i] = SCM_TO_C_EXPR; + } + } + else $1 = NULL; + } + + /* Don't check for NULL pointers (override checks). */ + + %typemap(check) C_TYPE *PARALLEL_VECTORINPUT, + const C_TYPE *PARALLEL_VECTORINPUT, + C_TYPE *PARALLEL_LISTINPUT, + const C_TYPE *PARALLEL_LISTINPUT + "/* no check for NULL pointer */"; + + /* Discard the temporary array after the call. */ + + %typemap(freearg) C_TYPE *PARALLEL_VECTORINPUT, + const C_TYPE *PARALLEL_VECTORINPUT, + C_TYPE *PARALLEL_LISTINPUT, + const C_TYPE *PARALLEL_LISTINPUT + {if ($1!=NULL) SWIG_free($1);} + +%enddef + +%define TYPEMAP_PARALLEL_LIST_VECTOR_OUTPUT_WITH_EXPR(C_TYPE, C_TO_SCM_EXPR, SCM_TYPE) + + /* output */ + + /* First we make a temporary variable ARRAYLENTEMP, use its + address as the ...LENOUTPUT argument for the C function and + "ignore" the ...LENOUTPUT argument for Scheme. */ + + %typemap(in,numinputs=0) int *PARALLEL_VECTORLENOUTPUT (int _global_arraylentemp), + size_t *PARALLEL_VECTORLENOUTPUT (size_t _global_arraylentemp), + int *PARALLEL_LISTLENOUTPUT (int _global_arraylentemp), + size_t *PARALLEL_LISTLENOUTPUT (size_t _global_arraylentemp) + "$1 = &_global_arraylentemp;"; + + /* We also need to ignore the ...OUTPUT argument. */ + + %typemap(in,numinputs=0) C_TYPE **PARALLEL_VECTOROUTPUT (C_TYPE *arraytemp), + C_TYPE **PARALLEL_LISTOUTPUT (C_TYPE *arraytemp) + "$1 = &arraytemp;"; + + /* In the ARGOUT typemaps, we convert the array into a vector or + a list and append it to the results. */ + + %typemap(argout, doc="$NAME (a vector of " #SCM_TYPE " values)") + C_TYPE **PARALLEL_VECTOROUTPUT + { + int i; + SCM res = gh_make_vector(gh_int2scm(_global_arraylentemp), + SCM_BOOL_F); + for (i = 0; i<_global_arraylentemp; i++) { + C_TYPE swig_c_value = (*$1)[i]; + SCM elt = C_TO_SCM_EXPR; + gh_vector_set_x(res, gh_int2scm(i), elt); + } + SWIG_APPEND_VALUE(res); + } + + %typemap(argout, doc="$NAME (a list of " #SCM_TYPE " values)") + C_TYPE **PARALLEL_LISTOUTPUT + { + int i; + SCM res = SCM_EOL; + if (_global_arraylentemp > 0) { + for (i = _global_arraylentemp - 1; i>=0; i--) { + C_TYPE swig_c_value = (*$1)[i]; + SCM elt = C_TO_SCM_EXPR; + res = gh_cons(elt, res); + } + } + SWIG_APPEND_VALUE(res); + } + + /* In the FREEARG typemaps, get rid of the C vector. + (This can be overridden if you want to keep the C vector.) */ + + %typemap(freearg) C_TYPE **PARALLEL_VECTOROUTPUT, + C_TYPE **PARALLEL_LISTOUTPUT + { + if ((*$1)!=NULL) free(*$1); + } + +%enddef + +%define TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, C_TO_SCM_EXPR, SCM_TYPE) + TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, SCM_TYPE) + TYPEMAP_PARALLEL_LIST_VECTOR_OUTPUT_WITH_EXPR(C_TYPE, C_TO_SCM_EXPR, SCM_TYPE) +%enddef + +%define TYPEMAP_PARALLEL_LIST_VECTOR_INPUT(C_TYPE, SCM_TO_C, SCM_TYPE) + TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_WITH_EXPR + (C_TYPE, SCM_TO_C(swig_scm_value), SCM_TYPE) +%enddef + +%define TYPEMAP_PARALLEL_LIST_VECTOR_OUTPUT(C_TYPE, C_TO_SCM, SCM_TYPE) + TYPEMAP_PARALLEL_LIST_VECTOR_OUTPUT_WITH_EXPR + (C_TYPE, C_TO_SCM(swig_c_value), SCM_TYPE) +%enddef + +%define TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(C_TYPE, SCM_TO_C, C_TO_SCM, SCM_TYPE) + TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT_WITH_EXPR + (C_TYPE, SCM_TO_C(swig_scm_value), C_TO_SCM(swig_c_value), SCM_TYPE) +%enddef + +/* We use the macro to define typemaps for some standard types. */ + +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(bool, gh_scm2bool, gh_bool2scm, boolean); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char, gh_scm2char, gh_char2scm, char); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned char, gh_scm2char, gh_char2scm, char); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(int, gh_scm2int, gh_int2scm, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(short, gh_scm2int, gh_int2scm, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(long, gh_scm2long, gh_long2scm, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, gh_scm2long, gh_long2scm, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned int, gh_scm2ulong, gh_ulong2scm, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned short, gh_scm2ulong, gh_ulong2scm, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned long, gh_scm2ulong, gh_ulong2scm, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(size_t, gh_scm2ulong, gh_ulong2scm, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(float, gh_scm2double, gh_double2scm, real); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(double, gh_scm2double, gh_double2scm, real); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, gh_str02scm, string); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string); + +%typemap(freearg) char **PARALLEL_LISTINPUT, char **PARALLEL_VECTORINPUT, + const char **PARALLEL_LISTINPUT, const char **PARALLEL_VECTORINPUT +{ + if (($1)!=NULL) { + int i; + for (i = 0; i<*_global_list_length; i++) + if (($1)[i] != NULL) SWIG_free(($1)[i]); + SWIG_free($1); + } +} + +%typemap(freearg) char ***PARALLEL_LISTOUTPUT, char ***PARALLEL_VECTOROUTPUT, + const char ***PARALLEL_LISTOUTPUT, const char ***PARALLEL_VECTOROUTPUT +{ + if ((*$1)!=NULL) { + int i; + for (i = 0; i<_global_arraylentemp; i++) + if ((*$1)[i] != NULL) free((*$1)[i]); + free(*$1); + } +} diff --git a/devtools/swigwin-1.3.34/Lib/guile/pointer-in-out.i b/devtools/swigwin-1.3.34/Lib/guile/pointer-in-out.i new file mode 100644 index 0000000..bc64387 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/pointer-in-out.i @@ -0,0 +1,105 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * pointer-in-out.i + * + * Guile typemaps for passing pointers indirectly + * ----------------------------------------------------------------------------- */ + +/* Here is a macro that will define typemaps for passing C pointers indirectly. + + TYPEMAP_POINTER_INPUT_OUTPUT(PTRTYPE, SCM_TYPE) + + Supported calling conventions (in this example, PTRTYPE is int *): + + func(int **INPUT) + + Scheme wrapper will take one argument, a wrapped C pointer. + The address of a variable containing this pointer will be + passed to the function. + + func(int **INPUT_CONSUMED) + + Likewise, but mark the pointer object as not garbage + collectable. + + func(int **INPUT_DESTROYED) + + Likewise, but mark the pointer object as destroyed. + + func(int **OUTPUT) + + Scheme wrapper will take no arguments. The address of an int * + variable will be passed to the function. The function is + expected to modify the variable; its value is wrapped and + becomes an extra return value. (See the documentation on how + to deal with multiple values.) + + func(int **OUTPUT_NONCOLLECTABLE) + + Likewise, but make the pointer object not garbage collectable. + + func(int **BOTH) + func(int **INOUT) + + This annotation combines INPUT and OUTPUT. + +*/ + +%define TYPEMAP_POINTER_INPUT_OUTPUT(PTRTYPE, SCM_TYPE) + +%typemap(in, doc="$NAME is of type <" #SCM_TYPE ">") PTRTYPE *INPUT(PTRTYPE temp) +{ + if (SWIG_ConvertPtr($input, (void **) &temp, $*descriptor, 0)) { + scm_wrong_type_arg(FUNC_NAME, $argnum, $input); + } + $1 = &temp; +} + +%typemap(in, doc="$NAME is of type <" #SCM_TYPE "> and is consumed by the function") PTRTYPE *INPUT_CONSUMED(PTRTYPE temp) +{ + if (SWIG_ConvertPtr($input, (void **) &temp, $*descriptor, 0)) { + scm_wrong_type_arg(FUNC_NAME, $argnum, $input); + } + SWIG_Guile_MarkPointerNoncollectable($input); + $1 = &temp; +} + +%typemap(in, doc="$NAME is of type <" #SCM_TYPE "> and is consumed by the function") PTRTYPE *INPUT_DESTROYED(PTRTYPE temp) +{ + if (SWIG_ConvertPtr($input, (void **) &temp, $*descriptor, 0)) { + scm_wrong_type_arg(FUNC_NAME, $argnum, $input); + } + SWIG_Guile_MarkPointerDestroyed($input); + $1 = &temp; +} + +%typemap(in, numinputs=0) PTRTYPE *OUTPUT(PTRTYPE temp), + PTRTYPE *OUTPUT_NONCOLLECTABLE(PTRTYPE temp) + "$1 = &temp;"; + +%typemap(argout, doc="<" #SCM_TYPE ">") PTRTYPE *OUTPUT + "SWIG_APPEND_VALUE(SWIG_NewPointerObj(*$1, $*descriptor, 1));"; + +%typemap(argout, doc="<" #SCM_TYPE ">") PTRTYPE *OUTPUT_NONCOLLECTABLE + "SWIG_APPEND_VALUE(SWIG_NewPointerObj(*$1, $*descriptor, 0));"; + +%typemap(in) PTRTYPE *BOTH = PTRTYPE *INPUT; +%typemap(argout) PTRTYPE *BOTH = PTRTYPE *OUTPUT; +%typemap(in) PTRTYPE *INOUT = PTRTYPE *INPUT; +%typemap(argout) PTRTYPE *INOUT = PTRTYPE *OUTPUT; + +/* As a special convenience measure, also attach docs involving + SCM_TYPE to the standard pointer typemaps */ + +%typemap(in, doc="$NAME is of type <" #SCM_TYPE ">") PTRTYPE { + if (SWIG_ConvertPtr($input, (void **) &$1, $descriptor, 0)) + scm_wrong_type_arg(FUNC_NAME, $argnum, $input); +} + +%typemap(out, doc="<" #SCM_TYPE ">") PTRTYPE { + $result = SWIG_NewPointerObj ($1, $descriptor, $owner); +} + +%enddef diff --git a/devtools/swigwin-1.3.34/Lib/guile/ports.i b/devtools/swigwin-1.3.34/Lib/guile/ports.i new file mode 100644 index 0000000..0d0e142 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/ports.i @@ -0,0 +1,56 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * ports.i + * + * Guile typemaps for handling ports + * ----------------------------------------------------------------------------- */ + +%{ + #ifndef _POSIX_SOURCE + /* This is needed on Solaris for fdopen(). */ + # define _POSIX_SOURCE 199506L + #endif + #include <stdio.h> + #include <errno.h> + #include <unistd.h> +%} + +/* This typemap for FILE * accepts + (1) FILE * pointer objects, + (2) Scheme file ports. In this case, it creates a temporary C stream + which reads or writes from a dup'ed file descriptor. + */ + +%typemap(in, doc="$NAME is a file port or a FILE * pointer") FILE * + ( int closep ) +{ + if (SWIG_ConvertPtr($input, (void**) &($1), $1_descriptor, 0) == 0) { + closep = 0; + } + else if(!(SCM_FPORTP($input))) + scm_wrong_type_arg("$name", $argnum, $input); + else { + int fd; + if (SCM_OUTPUT_PORT_P($input)) + scm_force_output($input); + fd=dup(SCM_FPORT_FDES($input)); + if(fd==-1) + scm_misc_error("$name", strerror(errno), SCM_EOL); + $1=fdopen(fd, + SCM_OUTPUT_PORT_P($input) + ? (SCM_INPUT_PORT_P($input) + ? "r+" : "w") + : "r"); + if($1==NULL) + scm_misc_error("$name", strerror(errno), SCM_EOL); + closep = 1; + } +} + +%typemap(freearg) FILE* { + if (closep$argnum) + fclose($1); +} + diff --git a/devtools/swigwin-1.3.34/Lib/guile/std_common.i b/devtools/swigwin-1.3.34/Lib/guile/std_common.i new file mode 100644 index 0000000..ace5d65 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/std_common.i @@ -0,0 +1,27 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_common.i + * + * SWIG typemaps for STL - common utilities + * ----------------------------------------------------------------------------- */ + +%include <std/std_except.i> + +%apply size_t { std::size_t }; + +#define SWIG_bool2scm(b) gh_bool2scm(b ? 1 : 0) +#define SWIG_string2scm(s) gh_str02scm(s.c_str()) + +%{ +#include <string> + +inline std::string SWIG_scm2string(SCM x) { + char* temp; + temp = SWIG_scm2str(x); + std::string s(temp); + if (temp) SWIG_free(temp); + return s; +} +%} diff --git a/devtools/swigwin-1.3.34/Lib/guile/std_deque.i b/devtools/swigwin-1.3.34/Lib/guile/std_deque.i new file mode 100644 index 0000000..cb98f6c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/std_deque.i @@ -0,0 +1 @@ +%include <std/_std_deque.i> diff --git a/devtools/swigwin-1.3.34/Lib/guile/std_except.i b/devtools/swigwin-1.3.34/Lib/guile/std_except.i new file mode 100644 index 0000000..61bf481 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/std_except.i @@ -0,0 +1,12 @@ +// TODO: STL exception handling +// Note that the generic std_except.i file did not work +%{ +#include <stdexcept> +%} + +namespace std { + %ignore exception; + struct exception { + }; +} + diff --git a/devtools/swigwin-1.3.34/Lib/guile/std_map.i b/devtools/swigwin-1.3.34/Lib/guile/std_map.i new file mode 100644 index 0000000..cc53e15 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/std_map.i @@ -0,0 +1,1351 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_map.i + * + * SWIG typemaps for std::map + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +// ------------------------------------------------------------------------ +// std::map +// +// The aim of all that follows would be to integrate std::map with +// Guile as much as possible, namely, to allow the user to pass and +// be returned Scheme association lists. +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::map<T>), f(const std::map<T>&), f(const std::map<T>*): +// the parameter being read-only, either a Scheme alist or a +// previously wrapped std::map<T> can be passed. +// -- f(std::map<T>&), f(std::map<T>*): +// the parameter must be modified; therefore, only a wrapped std::map +// can be passed. +// -- std::map<T> f(): +// the map is returned by copy; therefore, a Scheme alist +// is returned which is most easily used in other Scheme functions +// -- std::map<T>& f(), std::map<T>* f(), const std::map<T>& f(), +// const std::map<T>* f(): +// the map is returned by reference; therefore, a wrapped std::map +// is returned +// ------------------------------------------------------------------------ + +%{ +#include <map> +#include <algorithm> +#include <stdexcept> +%} + +// exported class + +namespace std { + + template<class K, class T> class map { + %typemap(in) map<K,T> (std::map<K,T>* m) { + if (gh_null_p($input)) { + $1 = std::map<K,T >(); + } else if (gh_pair_p($input)) { + $1 = std::map<K,T >(); + SCM alist = $input; + while (!gh_null_p(alist)) { + K* k; + T* x; + SCM entry, key, val; + entry = gh_car(alist); + if (!gh_pair_p(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = gh_car(entry); + val = gh_cdr(entry); + k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) != 0) { + if (!gh_pair_p(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = gh_car(val); + x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); + } + (($1_type &)$1)[*k] = *x; + alist = gh_cdr(alist); + } + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const map<K,T>& (std::map<K,T> temp, + std::map<K,T>* m), + const map<K,T>* (std::map<K,T> temp, + std::map<K,T>* m) { + if (gh_null_p($input)) { + temp = std::map<K,T >(); + $1 = &temp; + } else if (gh_pair_p($input)) { + temp = std::map<K,T >(); + $1 = &temp; + SCM alist = $input; + while (!gh_null_p(alist)) { + K* k; + T* x; + SCM entry, key, val; + entry = gh_car(alist); + if (!gh_pair_p(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = gh_car(entry); + val = gh_cdr(entry); + k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) != 0) { + if (!gh_pair_p(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = gh_car(val); + x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); + } + temp[*k] = *x; + alist = gh_cdr(alist); + } + } else { + $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) map<K,T> { + SCM alist = SCM_EOL; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + K* key = new K(i->first); + T* val = new T(i->second); + SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); + SCM x = SWIG_NewPointerObj(val,$descriptor(T *), 1); + SCM entry = gh_cons(k,x); + alist = gh_cons(entry,alist); + } + $result = alist; + } + %typecheck(SWIG_TYPECHECK_MAP) map<K,T> { + /* native sequence? */ + if (gh_null_p($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + /* check the first element only */ + K* k; + T* x; + SCM head = gh_car($input); + if (gh_pair_p(head)) { + SCM key = gh_car(head); + SCM val = gh_cdr(head); + if (SWIG_ConvertPtr(key,(void**) &k, + $descriptor(K *), 0) != 0) { + $1 = 0; + } else { + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) == 0) { + $1 = 1; + } else if (gh_pair_p(val)) { + val = gh_car(val); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) == 0) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + /* wrapped map? */ + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_MAP) const map<K,T>&, + const map<K,T>* { + /* native sequence? */ + if (gh_null_p($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + /* check the first element only */ + K* k; + T* x; + SCM head = gh_car($input); + if (gh_pair_p(head)) { + SCM key = gh_car(head); + SCM val = gh_cdr(head); + if (SWIG_ConvertPtr(key,(void**) &k, + $descriptor(K *), 0) != 0) { + $1 = 0; + } else { + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) == 0) { + $1 = 1; + } else if (gh_pair_p(val)) { + val = gh_car(val); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) == 0) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + /* wrapped map? */ + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %rename("length") size; + %rename("null?") empty; + %rename("clear!") clear; + %rename("ref") __getitem__; + %rename("set!") __setitem__; + %rename("delete!") __delitem__; + %rename("has-key?") has_key; + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T& __getitem__(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void __setitem__(const K& key, const T& x) { + (*self)[key] = x; + } + void __delitem__(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + SCM keys() { + SCM result = SCM_EOL; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + K* key = new K(i->first); + SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); + result = gh_cons(k,result); + } + return result; + } + } + }; + + + // specializations for built-ins + + %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) + + template<class T> class map<K,T> { + %typemap(in) map<K,T> (std::map<K,T>* m) { + if (gh_null_p($input)) { + $1 = std::map<K,T >(); + } else if (gh_pair_p($input)) { + $1 = std::map<K,T >(); + SCM alist = $input; + while (!gh_null_p(alist)) { + T* x; + SCM entry, key, val; + entry = gh_car(alist); + if (!gh_pair_p(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = gh_car(entry); + val = gh_cdr(entry); + if (!CHECK(key)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) != 0) { + if (!gh_pair_p(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = gh_car(val); + x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); + } + (($1_type &)$1)[CONVERT_FROM(key)] = *x; + alist = gh_cdr(alist); + } + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const map<K,T>& (std::map<K,T> temp, + std::map<K,T>* m), + const map<K,T>* (std::map<K,T> temp, + std::map<K,T>* m) { + if (gh_null_p($input)) { + temp = std::map<K,T >(); + $1 = &temp; + } else if (gh_pair_p($input)) { + temp = std::map<K,T >(); + $1 = &temp; + SCM alist = $input; + while (!gh_null_p(alist)) { + T* x; + SCM entry, key, val; + entry = gh_car(alist); + if (!gh_pair_p(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = gh_car(entry); + val = gh_cdr(entry); + if (!CHECK(key)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) != 0) { + if (!gh_pair_p(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = gh_car(val); + x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); + } + temp[CONVERT_FROM(key)] = *x; + alist = gh_cdr(alist); + } + } else { + $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) map<K,T> { + SCM alist = SCM_EOL; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + T* val = new T(i->second); + SCM k = CONVERT_TO(i->first); + SCM x = SWIG_NewPointerObj(val,$descriptor(T *), 1); + SCM entry = gh_cons(k,x); + alist = gh_cons(entry,alist); + } + $result = alist; + } + %typecheck(SWIG_TYPECHECK_MAP) map<K,T> { + // native sequence? + if (gh_null_p($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + // check the first element only + T* x; + SCM head = gh_car($input); + if (gh_pair_p(head)) { + SCM key = gh_car(head); + SCM val = gh_cdr(head); + if (!CHECK(key)) { + $1 = 0; + } else { + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) == 0) { + $1 = 1; + } else if (gh_pair_p(val)) { + val = gh_car(val); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) == 0) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + // wrapped map? + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_MAP) const map<K,T>&, + const map<K,T>* { + // native sequence? + if (gh_null_p($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + // check the first element only + T* x; + SCM head = gh_car($input); + if (gh_pair_p(head)) { + SCM key = gh_car(head); + SCM val = gh_cdr(head); + if (!CHECK(key)) { + $1 = 0; + } else { + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) == 0) { + $1 = 1; + } else if (gh_pair_p(val)) { + val = gh_car(val); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) == 0) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + // wrapped map? + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %rename("length") size; + %rename("null?") empty; + %rename("clear!") clear; + %rename("ref") __getitem__; + %rename("set!") __setitem__; + %rename("delete!") __delitem__; + %rename("has-key?") has_key; + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T& __getitem__(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void __setitem__(K key, const T& x) { + (*self)[key] = x; + } + void __delitem__(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(K key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + SCM keys() { + SCM result = SCM_EOL; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + SCM k = CONVERT_TO(i->first); + result = gh_cons(k,result); + } + return result; + } + } + }; + %enddef + + %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) + template<class K> class map<K,T> { + %typemap(in) map<K,T> (std::map<K,T>* m) { + if (gh_null_p($input)) { + $1 = std::map<K,T >(); + } else if (gh_pair_p($input)) { + $1 = std::map<K,T >(); + SCM alist = $input; + while (!gh_null_p(alist)) { + K* k; + SCM entry, key, val; + entry = gh_car(alist); + if (!gh_pair_p(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = gh_car(entry); + val = gh_cdr(entry); + k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); + if (!CHECK(val)) { + if (!gh_pair_p(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = gh_car(val); + if (!CHECK(val)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + } + (($1_type &)$1)[*k] = CONVERT_FROM(val); + alist = gh_cdr(alist); + } + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const map<K,T>& (std::map<K,T> temp, + std::map<K,T>* m), + const map<K,T>* (std::map<K,T> temp, + std::map<K,T>* m) { + if (gh_null_p($input)) { + temp = std::map<K,T >(); + $1 = &temp; + } else if (gh_pair_p($input)) { + temp = std::map<K,T >(); + $1 = &temp; + SCM alist = $input; + while (!gh_null_p(alist)) { + K* k; + SCM entry, key, val; + entry = gh_car(alist); + if (!gh_pair_p(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = gh_car(entry); + val = gh_cdr(entry); + k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); + if (!CHECK(val)) { + if (!gh_pair_p(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = gh_car(val); + if (!CHECK(val)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + } + temp[*k] = CONVERT_FROM(val); + alist = gh_cdr(alist); + } + } else { + $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) map<K,T> { + SCM alist = SCM_EOL; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + K* key = new K(i->first); + SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); + SCM x = CONVERT_TO(i->second); + SCM entry = gh_cons(k,x); + alist = gh_cons(entry,alist); + } + $result = alist; + } + %typecheck(SWIG_TYPECHECK_MAP) map<K,T> { + // native sequence? + if (gh_null_p($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + // check the first element only + K* k; + SCM head = gh_car($input); + if (gh_pair_p(head)) { + SCM key = gh_car(head); + SCM val = gh_cdr(head); + if (SWIG_ConvertPtr(val,(void **) &k, + $descriptor(K *), 0) != 0) { + $1 = 0; + } else { + if (CHECK(val)) { + $1 = 1; + } else if (gh_pair_p(val)) { + val = gh_car(val); + if (CHECK(val)) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + // wrapped map? + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_MAP) const map<K,T>&, + const map<K,T>* { + // native sequence? + if (gh_null_p($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + // check the first element only + K* k; + SCM head = gh_car($input); + if (gh_pair_p(head)) { + SCM key = gh_car(head); + SCM val = gh_cdr(head); + if (SWIG_ConvertPtr(val,(void **) &k, + $descriptor(K *), 0) != 0) { + $1 = 0; + } else { + if (CHECK(val)) { + $1 = 1; + } else if (gh_pair_p(val)) { + val = gh_car(val); + if (CHECK(val)) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + // wrapped map? + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %rename("length") size; + %rename("null?") empty; + %rename("clear!") clear; + %rename("ref") __getitem__; + %rename("set!") __setitem__; + %rename("delete!") __delitem__; + %rename("has-key?") has_key; + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T __getitem__(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void __setitem__(const K& key, T x) { + (*self)[key] = x; + } + void __delitem__(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + SCM keys() { + SCM result = SCM_EOL; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + K* key = new K(i->first); + SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); + result = gh_cons(k,result); + } + return result; + } + } + }; + %enddef + + %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, + T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) + template<> class map<K,T> { + %typemap(in) map<K,T> (std::map<K,T>* m) { + if (gh_null_p($input)) { + $1 = std::map<K,T >(); + } else if (gh_pair_p($input)) { + $1 = std::map<K,T >(); + SCM alist = $input; + while (!gh_null_p(alist)) { + SCM entry, key, val; + entry = gh_car(alist); + if (!gh_pair_p(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = gh_car(entry); + val = gh_cdr(entry); + if (!CHECK_K(key)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + if (!CHECK_T(val)) { + if (!gh_pair_p(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = gh_car(val); + if (!CHECK_T(val)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + } + (($1_type &)$1)[CONVERT_K_FROM(key)] = + CONVERT_T_FROM(val); + alist = gh_cdr(alist); + } + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const map<K,T>& (std::map<K,T> temp, + std::map<K,T>* m), + const map<K,T>* (std::map<K,T> temp, + std::map<K,T>* m) { + if (gh_null_p($input)) { + temp = std::map<K,T >(); + $1 = &temp; + } else if (gh_pair_p($input)) { + temp = std::map<K,T >(); + $1 = &temp; + SCM alist = $input; + while (!gh_null_p(alist)) { + SCM entry, key, val; + entry = gh_car(alist); + if (!gh_pair_p(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = gh_car(entry); + val = gh_cdr(entry); + if (!CHECK_K(key)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + if (!CHECK_T(val)) { + if (!gh_pair_p(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = gh_car(val); + if (!CHECK_T(val)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + } + temp[CONVERT_K_FROM(key)] = CONVERT_T_FROM(val); + alist = gh_cdr(alist); + } + } else { + $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) map<K,T> { + SCM alist = SCM_EOL; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + SCM k = CONVERT_K_TO(i->first); + SCM x = CONVERT_T_TO(i->second); + SCM entry = gh_cons(k,x); + alist = gh_cons(entry,alist); + } + $result = alist; + } + %typecheck(SWIG_TYPECHECK_MAP) map<K,T> { + // native sequence? + if (gh_null_p($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + // check the first element only + SCM head = gh_car($input); + if (gh_pair_p(head)) { + SCM key = gh_car(head); + SCM val = gh_cdr(head); + if (!CHECK_K(key)) { + $1 = 0; + } else { + if (CHECK_T(val)) { + $1 = 1; + } else if (gh_pair_p(val)) { + val = gh_car(val); + if (CHECK_T(val)) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + // wrapped map? + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_MAP) const map<K,T>&, + const map<K,T>* { + // native sequence? + if (gh_null_p($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + // check the first element only + SCM head = gh_car($input); + if (gh_pair_p(head)) { + SCM key = gh_car(head); + SCM val = gh_cdr(head); + if (!CHECK_K(key)) { + $1 = 0; + } else { + if (CHECK_T(val)) { + $1 = 1; + } else if (gh_pair_p(val)) { + val = gh_car(val); + if (CHECK_T(val)) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + // wrapped map? + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %rename("length") size; + %rename("null?") empty; + %rename("clear!") clear; + %rename("ref") __getitem__; + %rename("set!") __setitem__; + %rename("delete!") __delitem__; + %rename("has-key?") has_key; + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T __getitem__(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void __setitem__(K key, T x) { + (*self)[key] = x; + } + void __delitem__(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(K key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + SCM keys() { + SCM result = SCM_EOL; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + SCM k = CONVERT_K_TO(i->first); + result = gh_cons(k,result); + } + return result; + } + } + }; + %enddef + + + specialize_std_map_on_key(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_key(int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_key(short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_key(long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_key(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_key(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_key(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_key(double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_key(float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_key(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + + specialize_std_map_on_value(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_value(int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_value(short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_value(long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_value(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_value(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_value(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_value(double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_value(float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_value(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + + specialize_std_map_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); +} diff --git a/devtools/swigwin-1.3.34/Lib/guile/std_pair.i b/devtools/swigwin-1.3.34/Lib/guile/std_pair.i new file mode 100644 index 0000000..f8c2ea6 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/std_pair.i @@ -0,0 +1,871 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_pair.i + * + * SWIG typemaps for std::pair + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <exception.i> + +// ------------------------------------------------------------------------ +// std::pair +// +// See std_vector.i for the rationale of typemap application +// ------------------------------------------------------------------------ + +%{ +#include <utility> +%} + +// exported class + +namespace std { + + template<class T, class U> struct pair { + %typemap(in) pair<T,U> (std::pair<T,U>* m) { + if (gh_pair_p($input)) { + T* x; + U* y; + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); + $1 = std::make_pair(*x,*y); + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const pair<T,U>& (std::pair<T,U> temp, + std::pair<T,U>* m), + const pair<T,U>* (std::pair<T,U> temp, + std::pair<T,U>* m) { + if (gh_pair_p($input)) { + T* x; + U* y; + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); + temp = std::make_pair(*x,*y); + $1 = &temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) pair<T,U> { + T* x = new T($1.first); + U* y = new U($1.second); + SCM first = SWIG_NewPointerObj(x,$descriptor(T *), 1); + SCM second = SWIG_NewPointerObj(y,$descriptor(U *), 1); + $result = gh_cons(first,second); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair<T,U> { + /* native pair? */ + if (gh_pair_p($input)) { + T* x; + U* y; + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (SWIG_ConvertPtr(first,(void**) &x, + $descriptor(T *), 0) == 0 && + SWIG_ConvertPtr(second,(void**) &y, + $descriptor(U *), 0) == 0) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair<T,U>&, + const pair<T,U>* { + /* native pair? */ + if (gh_pair_p($input)) { + T* x; + U* y; + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (SWIG_ConvertPtr(first,(void**) &x, + $descriptor(T *), 0) == 0 && + SWIG_ConvertPtr(second,(void**) &y, + $descriptor(U *), 0) == 0) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + pair(); + pair(T first, U second); + pair(const pair& p); + + template <class U1, class U2> pair(const pair<U1, U2> &p); + + T first; + U second; + }; + + + // specializations for built-ins + + %define specialize_std_pair_on_first(T,CHECK,CONVERT_FROM,CONVERT_TO) + template<class U> struct pair<T,U> { + %typemap(in) pair<T,U> (std::pair<T,U>* m) { + if (gh_pair_p($input)) { + U* y; + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + if (!CHECK(first)) + SWIG_exception(SWIG_TypeError, + "map<" #T "," #U "> expected"); + y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); + $1 = std::make_pair(CONVERT_FROM(first),*y); + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const pair<T,U>& (std::pair<T,U> temp, + std::pair<T,U>* m), + const pair<T,U>* (std::pair<T,U> temp, + std::pair<T,U>* m) { + if (gh_pair_p($input)) { + U* y; + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + if (!CHECK(first)) + SWIG_exception(SWIG_TypeError, + "map<" #T "," #U "> expected"); + y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); + temp = std::make_pair(CONVERT_FROM(first),*y); + $1 = &temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) pair<T,U> { + U* y = new U($1.second); + SCM second = SWIG_NewPointerObj(y,$descriptor(U *), 1); + $result = gh_cons(CONVERT_TO($1.first),second); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair<T,U> { + /* native pair? */ + if (gh_pair_p($input)) { + U* y; + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (CHECK(first) && + SWIG_ConvertPtr(second,(void**) &y, + $descriptor(U *), 0) == 0) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair<T,U>&, + const pair<T,U>* { + /* native pair? */ + if (gh_pair_p($input)) { + U* y; + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (CHECK(first) && + SWIG_ConvertPtr(second,(void**) &y, + $descriptor(U *), 0) == 0) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + pair(); + pair(T first, U second); + pair(const pair& p); + + template <class U1, class U2> pair(const pair<U1, U2> &p); + + T first; + U second; + }; + %enddef + + %define specialize_std_pair_on_second(U,CHECK,CONVERT_FROM,CONVERT_TO) + template<class T> struct pair<T,U> { + %typemap(in) pair<T,U> (std::pair<T,U>* m) { + if (gh_pair_p($input)) { + T* x; + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + if (!CHECK(second)) + SWIG_exception(SWIG_TypeError, + "map<" #T "," #U "> expected"); + $1 = std::make_pair(*x,CONVERT_FROM(second)); + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const pair<T,U>& (std::pair<T,U> temp, + std::pair<T,U>* m), + const pair<T,U>* (std::pair<T,U> temp, + std::pair<T,U>* m) { + if (gh_pair_p($input)) { + T* x; + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + if (!CHECK(second)) + SWIG_exception(SWIG_TypeError, + "map<" #T "," #U "> expected"); + temp = std::make_pair(*x,CONVERT_FROM(second)); + $1 = &temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) pair<T,U> { + T* x = new T($1.first); + SCM first = SWIG_NewPointerObj(x,$descriptor(T *), 1); + $result = gh_cons(first,CONVERT_TO($1.second)); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair<T,U> { + /* native pair? */ + if (gh_pair_p($input)) { + T* x; + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (SWIG_ConvertPtr(first,(void**) &x, + $descriptor(T *), 0) == 0 && + CHECK(second)) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair<T,U>&, + const pair<T,U>* { + /* native pair? */ + if (gh_pair_p($input)) { + T* x; + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (SWIG_ConvertPtr(first,(void**) &x, + $descriptor(T *), 0) == 0 && + CHECK(second)) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + pair(); + pair(T first, U second); + pair(const pair& p); + + template <class U1, class U2> pair(const pair<U1, U2> &p); + + T first; + U second; + }; + %enddef + + %define specialize_std_pair_on_both(T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO, + U,CHECK_U,CONVERT_U_FROM,CONVERT_U_TO) + template<> struct pair<T,U> { + %typemap(in) pair<T,U> (std::pair<T,U>* m) { + if (gh_pair_p($input)) { + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + if (!CHECK_T(first) || !CHECK_U(second)) + SWIG_exception(SWIG_TypeError, + "map<" #T "," #U "> expected"); + $1 = std::make_pair(CONVERT_T_FROM(first), + CONVERT_U_FROM(second)); + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const pair<T,U>& (std::pair<T,U> temp, + std::pair<T,U>* m), + const pair<T,U>* (std::pair<T,U> temp, + std::pair<T,U>* m) { + if (gh_pair_p($input)) { + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + if (!CHECK_T(first) || !CHECK_U(second)) + SWIG_exception(SWIG_TypeError, + "map<" #T "," #U "> expected"); + temp = std::make_pair(CONVERT_T_FROM(first), + CONVERT_U_FROM(second)); + $1 = &temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) pair<T,U> { + $result = gh_cons(CONVERT_T_TO($1.first), + CONVERT_U_TO($1.second)); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair<T,U> { + /* native pair? */ + if (gh_pair_p($input)) { + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (CHECK_T(first) && CHECK_U(second)) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair<T,U>&, + const pair<T,U>* { + /* native pair? */ + if (gh_pair_p($input)) { + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (CHECK_T(first) && CHECK_U(second)) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + pair(); + pair(T first, U second); + pair(const pair& p); + + template <class U1, class U2> pair(const pair<U1, U2> &p); + + T first; + U second; + }; + %enddef + + + specialize_std_pair_on_first(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_first(int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_first(short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_first(long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_first(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_first(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_first(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_first(double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_first(float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_first(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + + specialize_std_pair_on_second(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_second(int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_second(short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_second(long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_second(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_second(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_second(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_second(double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_second(float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_second(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); +} diff --git a/devtools/swigwin-1.3.34/Lib/guile/std_string.i b/devtools/swigwin-1.3.34/Lib/guile/std_string.i new file mode 100644 index 0000000..f80a65c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/std_string.i @@ -0,0 +1,90 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_string.i + * + * SWIG typemaps for std::string + * ----------------------------------------------------------------------------- */ + +// ------------------------------------------------------------------------ +// std::string is typemapped by value +// This can prevent exporting methods which return a string +// in order for the user to modify it. +// However, I think I'll wait until someone asks for it... +// ------------------------------------------------------------------------ + +%include <exception.i> + +%{ +#include <string> +%} + +namespace std { + + %naturalvar string; + + class string; + + %typemap(typecheck) string = char *; + %typemap(typecheck) const string & = char *; + + %typemap(in) string (char* tempptr) { + if (gh_string_p($input)) { + tempptr = SWIG_scm2str($input); + $1.assign(tempptr); + if (tempptr) SWIG_free(tempptr); + } else { + SWIG_exception(SWIG_TypeError, "string expected"); + } + } + + %typemap(in) const string & (std::string temp, + char* tempptr) { + if (gh_string_p($input)) { + tempptr = SWIG_scm2str($input); + temp.assign(tempptr); + if (tempptr) SWIG_free(tempptr); + $1 = &temp; + } else { + SWIG_exception(SWIG_TypeError, "string expected"); + } + } + + %typemap(in) string * (char* tempptr) { + if (gh_string_p($input)) { + tempptr = SWIG_scm2str($input); + $1 = new std::string(tempptr); + if (tempptr) SWIG_free(tempptr); + } else { + SWIG_exception(SWIG_TypeError, "string expected"); + } + } + + %typemap(out) string { + $result = gh_str02scm($1.c_str()); + } + + %typemap(out) const string & { + $result = gh_str02scm($1->c_str()); + } + + %typemap(out) string * { + $result = gh_str02scm($1->c_str()); + } + + %typemap(varin) string { + if (gh_string_p($input)) { + char *tempptr = SWIG_scm2str($input); + $1.assign(tempptr); + if (tempptr) SWIG_free(tempptr); + } else { + SWIG_exception(SWIG_TypeError, "string expected"); + } + } + + %typemap(varout) string { + $result = gh_str02scm($1.c_str()); + } + +} diff --git a/devtools/swigwin-1.3.34/Lib/guile/std_vector.i b/devtools/swigwin-1.3.34/Lib/guile/std_vector.i new file mode 100644 index 0000000..145db94 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/std_vector.i @@ -0,0 +1,413 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_vector.i + * + * SWIG typemaps for std::vector + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +// ------------------------------------------------------------------------ +// std::vector +// +// The aim of all that follows would be to integrate std::vector with +// Guile as much as possible, namely, to allow the user to pass and +// be returned Guile vectors or lists. +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::vector<T>), f(const std::vector<T>&), f(const std::vector<T>*): +// the parameter being read-only, either a Guile sequence or a +// previously wrapped std::vector<T> can be passed. +// -- f(std::vector<T>&), f(std::vector<T>*): +// the parameter must be modified; therefore, only a wrapped std::vector +// can be passed. +// -- std::vector<T> f(): +// the vector is returned by copy; therefore, a Guile vector of T:s +// is returned which is most easily used in other Guile functions +// -- std::vector<T>& f(), std::vector<T>* f(), const std::vector<T>& f(), +// const std::vector<T>* f(): +// the vector is returned by reference; therefore, a wrapped std::vector +// is returned +// ------------------------------------------------------------------------ + +%{ +#include <vector> +#include <algorithm> +#include <stdexcept> +%} + +// exported class + +namespace std { + + template<class T> class vector { + %typemap(in) vector<T> { + if (gh_vector_p($input)) { + unsigned long size = gh_vector_length($input); + $1 = std::vector<T >(size); + for (unsigned long i=0; i<size; i++) { + SCM o = gh_vector_ref($input,gh_ulong2scm(i)); + (($1_type &)$1)[i] = + *((T*) SWIG_MustGetPtr(o,$descriptor(T *),$argnum, 0)); + } + } else if (gh_null_p($input)) { + $1 = std::vector<T >(); + } else if (gh_pair_p($input)) { + SCM head, tail; + $1 = std::vector<T >(); + tail = $input; + while (!gh_null_p(tail)) { + head = gh_car(tail); + tail = gh_cdr(tail); + $1.push_back(*((T*)SWIG_MustGetPtr(head, + $descriptor(T *), + $argnum, 0))); + } + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const vector<T>& (std::vector<T> temp), + const vector<T>* (std::vector<T> temp) { + if (gh_vector_p($input)) { + unsigned long size = gh_vector_length($input); + temp = std::vector<T >(size); + $1 = &temp; + for (unsigned long i=0; i<size; i++) { + SCM o = gh_vector_ref($input,gh_ulong2scm(i)); + temp[i] = *((T*) SWIG_MustGetPtr(o, + $descriptor(T *), + $argnum, 0)); + } + } else if (gh_null_p($input)) { + temp = std::vector<T >(); + $1 = &temp; + } else if (gh_pair_p($input)) { + temp = std::vector<T >(); + $1 = &temp; + SCM head, tail; + tail = $input; + while (!gh_null_p(tail)) { + head = gh_car(tail); + tail = gh_cdr(tail); + temp.push_back(*((T*) SWIG_MustGetPtr(head, + $descriptor(T *), + $argnum, 0))); + } + } else { + $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) vector<T> { + $result = gh_make_vector(gh_long2scm($1.size()),SCM_UNSPECIFIED); + for (unsigned int i=0; i<$1.size(); i++) { + T* x = new T((($1_type &)$1)[i]); + gh_vector_set_x($result,gh_long2scm(i), + SWIG_NewPointerObj(x, $descriptor(T *), 1)); + } + } + %typecheck(SWIG_TYPECHECK_VECTOR) vector<T> { + /* native sequence? */ + if (gh_vector_p($input)) { + unsigned int size = gh_vector_length($input); + if (size == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + SCM o = gh_vector_ref($input,gh_ulong2scm(0)); + T* x; + if (SWIG_ConvertPtr(o,(void**) &x, + $descriptor(T *), 0) != -1) + $1 = 1; + else + $1 = 0; + } + } else if (gh_null_p($input)) { + /* again, an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + /* check the first element only */ + T* x; + SCM head = gh_car($input); + if (SWIG_ConvertPtr(head,(void**) &x, + $descriptor(T *), 0) != -1) + $1 = 1; + else + $1 = 0; + } else { + /* wrapped vector? */ + std::vector<T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $&1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_VECTOR) const vector<T>&, + const vector<T>* { + /* native sequence? */ + if (gh_vector_p($input)) { + unsigned int size = gh_vector_length($input); + if (size == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + T* x; + SCM o = gh_vector_ref($input,gh_ulong2scm(0)); + if (SWIG_ConvertPtr(o,(void**) &x, + $descriptor(T *), 0) != -1) + $1 = 1; + else + $1 = 0; + } + } else if (gh_null_p($input)) { + /* again, an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + /* check the first element only */ + T* x; + SCM head = gh_car($input); + if (SWIG_ConvertPtr(head,(void**) &x, + $descriptor(T *), 0) != -1) + $1 = 1; + else + $1 = 0; + } else { + /* wrapped vector? */ + std::vector<T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + public: + vector(unsigned int size = 0); + vector(unsigned int size, const T& value); + vector(const vector<T>&); + %rename(length) size; + unsigned int size() const; + %rename("empty?") empty; + bool empty() const; + %rename("clear!") clear; + void clear(); + %rename("set!") set; + %rename("pop!") pop; + %rename("push!") push_back; + void push_back(const T& x); + %extend { + T pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty vector"); + T x = self->back(); + self->pop_back(); + return x; + } + T& ref(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("vector index out of range"); + } + void set(int i, const T& x) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + (*self)[i] = x; + else + throw std::out_of_range("vector index out of range"); + } + } + }; + + + // specializations for built-ins + %define specialize_stl_vector(T,CHECK,CONVERT_FROM,CONVERT_TO) + template<> class vector<T> { + %typemap(in) vector<T> { + if (gh_vector_p($input)) { + unsigned long size = gh_vector_length($input); + $1 = std::vector<T >(size); + for (unsigned long i=0; i<size; i++) { + SCM o = gh_vector_ref($input,gh_ulong2scm(i)); + if (CHECK(o)) + (($1_type &)$1)[i] = (T)(CONVERT_FROM(o)); + else + scm_wrong_type_arg(FUNC_NAME, $argnum, $input); + } + } else if (gh_null_p($input)) { + $1 = std::vector<T >(); + } else if (gh_pair_p($input)) { + SCM v = gh_list_to_vector($input); + unsigned long size = gh_vector_length(v); + $1 = std::vector<T >(size); + for (unsigned long i=0; i<size; i++) { + SCM o = gh_vector_ref(v,gh_ulong2scm(i)); + if (CHECK(o)) + (($1_type &)$1)[i] = (T)(CONVERT_FROM(o)); + else + scm_wrong_type_arg(FUNC_NAME, $argnum, $input); + } + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const vector<T>& (std::vector<T> temp), + const vector<T>* (std::vector<T> temp) { + if (gh_vector_p($input)) { + unsigned long size = gh_vector_length($input); + temp = std::vector<T >(size); + $1 = &temp; + for (unsigned long i=0; i<size; i++) { + SCM o = gh_vector_ref($input,gh_ulong2scm(i)); + if (CHECK(o)) + temp[i] = (T)(CONVERT_FROM(o)); + else + scm_wrong_type_arg(FUNC_NAME, $argnum, $input); + } + } else if (gh_null_p($input)) { + temp = std::vector<T >(); + $1 = &temp; + } else if (gh_pair_p($input)) { + SCM v = gh_list_to_vector($input); + unsigned long size = gh_vector_length(v); + temp = std::vector<T >(size); + $1 = &temp; + for (unsigned long i=0; i<size; i++) { + SCM o = gh_vector_ref(v,gh_ulong2scm(i)); + if (CHECK(o)) + temp[i] = (T)(CONVERT_FROM(o)); + else + scm_wrong_type_arg(FUNC_NAME, $argnum, $input); + } + } else { + $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) vector<T> { + $result = gh_make_vector(gh_long2scm($1.size()),SCM_UNSPECIFIED); + for (unsigned int i=0; i<$1.size(); i++) { + SCM x = CONVERT_TO((($1_type &)$1)[i]); + gh_vector_set_x($result,gh_long2scm(i),x); + } + } + %typecheck(SWIG_TYPECHECK_VECTOR) vector<T> { + /* native sequence? */ + if (gh_vector_p($input)) { + unsigned int size = gh_vector_length($input); + if (size == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + T* x; + SCM o = gh_vector_ref($input,gh_ulong2scm(0)); + $1 = CHECK(o) ? 1 : 0; + } + } else if (gh_null_p($input)) { + /* again, an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + /* check the first element only */ + T* x; + SCM head = gh_car($input); + $1 = CHECK(head) ? 1 : 0; + } else { + /* wrapped vector? */ + std::vector<T >* v; + $1 = (SWIG_ConvertPtr($input,(void **) &v, + $&1_descriptor, 0) != -1) ? 1 : 0; + } + } + %typecheck(SWIG_TYPECHECK_VECTOR) const vector<T>&, + const vector<T>* { + /* native sequence? */ + if (gh_vector_p($input)) { + unsigned int size = gh_vector_length($input); + if (size == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + T* x; + SCM o = gh_vector_ref($input,gh_ulong2scm(0)); + $1 = CHECK(o) ? 1 : 0; + } + } else if (gh_null_p($input)) { + /* again, an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + /* check the first element only */ + T* x; + SCM head = gh_car($input); + $1 = CHECK(head) ? 1 : 0; + } else { + /* wrapped vector? */ + std::vector<T >* v; + $1 = (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor, 0) != -1) ? 1 : 0; + } + } + public: + vector(unsigned int size = 0); + vector(unsigned int size, const T& value); + vector(const vector<T>&); + %rename(length) size; + unsigned int size() const; + %rename("empty?") empty; + bool empty() const; + %rename("clear!") clear; + void clear(); + %rename("set!") set; + %rename("pop!") pop; + %rename("push!") push_back; + void push_back(T x); + %extend { + T pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty vector"); + T x = self->back(); + self->pop_back(); + return x; + } + T ref(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("vector index out of range"); + } + void set(int i, T x) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + (*self)[i] = x; + else + throw std::out_of_range("vector index out of range"); + } + } + }; + %enddef + + specialize_stl_vector(bool,gh_boolean_p,gh_scm2bool,SWIG_bool2scm); + specialize_stl_vector(char,gh_number_p,gh_scm2long,gh_long2scm); + specialize_stl_vector(int,gh_number_p,gh_scm2long,gh_long2scm); + specialize_stl_vector(long,gh_number_p,gh_scm2long,gh_long2scm); + specialize_stl_vector(short,gh_number_p,gh_scm2long,gh_long2scm); + specialize_stl_vector(unsigned char,gh_number_p,gh_scm2ulong,gh_ulong2scm); + specialize_stl_vector(unsigned int,gh_number_p,gh_scm2ulong,gh_ulong2scm); + specialize_stl_vector(unsigned long,gh_number_p,gh_scm2ulong,gh_ulong2scm); + specialize_stl_vector(unsigned short,gh_number_p,gh_scm2ulong,gh_ulong2scm); + specialize_stl_vector(float,gh_number_p,gh_scm2double,gh_double2scm); + specialize_stl_vector(double,gh_number_p,gh_scm2double,gh_double2scm); + specialize_stl_vector(std::string,gh_string_p,SWIG_scm2string,SWIG_string2scm); +} + diff --git a/devtools/swigwin-1.3.34/Lib/guile/stl.i b/devtools/swigwin-1.3.34/Lib/guile/stl.i new file mode 100644 index 0000000..66b72e0 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/stl.i @@ -0,0 +1,15 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * stl.i + * + * Initial STL definition. extended as needed in each language + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <std_string.i> +%include <std_vector.i> +%include <std_map.i> +%include <std_pair.i> + diff --git a/devtools/swigwin-1.3.34/Lib/guile/swigrun.i b/devtools/swigwin-1.3.34/Lib/guile/swigrun.i new file mode 100644 index 0000000..4b9ea2c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/swigrun.i @@ -0,0 +1,49 @@ +/* -*- mode: c -*- */ + +%module swigrun + +#ifdef SWIGGUILE_SCM + +/* Hook the runtime module initialization + into the shared initialization function SWIG_Guile_Init. */ +%runtime %{ +/* Hook the runtime module initialization + into the shared initialization function SWIG_Guile_Init. */ +#include <libguile.h> +#ifdef __cplusplus +extern "C" +#endif +SCM scm_init_Swig_swigrun_module (void); +#define SWIG_INIT_RUNTIME_MODULE scm_init_Swig_swigrun_module(); +%} + +/* The runtime type system from common.swg */ + +typedef struct swig_type_info swig_type_info; + +const char * +SWIG_TypeName(const swig_type_info *type); + +const char * +SWIG_TypePrettyName(const swig_type_info *type); + +swig_type_info * +SWIG_TypeQuery(const char *); + +/* Language-specific stuff */ + +%apply bool { int }; + +int +SWIG_IsPointer(SCM object); + +int +SWIG_IsPointerOfType(SCM object, swig_type_info *type); + +unsigned long +SWIG_PointerAddress(SCM object); + +swig_type_info * +SWIG_PointerType(SCM object); + +#endif diff --git a/devtools/swigwin-1.3.34/Lib/guile/typemaps.i b/devtools/swigwin-1.3.34/Lib/guile/typemaps.i new file mode 100644 index 0000000..c088cca --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/typemaps.i @@ -0,0 +1,454 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * typemaps.i + * + * Guile-specific typemaps + * ----------------------------------------------------------------------------- */ + +/* Pointers */ + +%typemap(in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] { + $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, 0); +} +%typemap(freearg) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] ""; + +%typemap(in) void * { + $1 = ($1_ltype)SWIG_MustGetPtr($input, NULL, $argnum, 0); +} +%typemap(freearg) void * ""; + +%typemap(varin) SWIGTYPE * { + $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0); +} + +%typemap(varin) SWIGTYPE & { + $1 = *(($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0)); +} + +%typemap(varin) SWIGTYPE [] { + scm_wrong_type_arg((char *) FUNC_NAME, 1, $input); +} + +%typemap(varin) SWIGTYPE [ANY] { + void *temp; + int ii; + $1_basetype *b = 0; + temp = SWIG_MustGetPtr($input, $1_descriptor, 1, 0); + b = ($1_basetype *) $1; + for (ii = 0; ii < $1_size; ii++) b[ii] = *(($1_basetype *) temp + ii); +} + +%typemap(varin) void * { + $1 = SWIG_MustGetPtr($input, NULL, 1, 0); +} + +%typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] { + $result = SWIG_NewPointerObj ($1, $descriptor, $owner); +} + +%typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { + swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor,(void **) &$1); + $result = SWIG_NewPointerObj ($1, ty, $owner); +} + +%typemap(varout) SWIGTYPE *, SWIGTYPE [] { + $result = SWIG_NewPointerObj ($1, $descriptor, 0); +} + +%typemap(varout) SWIGTYPE & { + $result = SWIG_NewPointerObj((void *) &$1, $1_descriptor, 0); +} + +%typemap(throws) SWIGTYPE { + $<ype temp = new $ltype($1); + scm_throw(gh_symbol2scm((char *) "swig-exception"), + gh_list(SWIG_NewPointerObj(temp, $&descriptor, 1), + SCM_UNDEFINED)); +} + +%typemap(throws) SWIGTYPE & { + scm_throw(gh_symbol2scm((char *) "swig-exception"), + gh_list(SWIG_NewPointerObj(&$1, $descriptor, 1), + SCM_UNDEFINED)); +} + +%typemap(throws) SWIGTYPE * { + scm_throw(gh_symbol2scm((char *) "swig-exception"), + gh_list(SWIG_NewPointerObj($1, $descriptor, 1), + SCM_UNDEFINED)); +} + +%typemap(throws) SWIGTYPE [] { + scm_throw(gh_symbol2scm((char *) "swig-exception"), + gh_list(SWIG_NewPointerObj($1, $descriptor, 1), + SCM_UNDEFINED)); +} + +/* Change of object ownership, and interaction of destructor-like functions and the + garbage-collector */ + +%typemap(in, doc="$NAME is of type <$type> and gets destroyed by the function") SWIGTYPE *DESTROYED { + $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, 0); +} + +%typemap(freearg) SWIGTYPE *DESTROYED { + SWIG_Guile_MarkPointerDestroyed($input); +} + +%typemap(in, doc="$NAME is of type <$type> and is consumed by the function") SWIGTYPE *CONSUMED { + $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, 0); + SWIG_Guile_MarkPointerNoncollectable($input); +} + +/* Pass-by-value */ + +%typemap(in) SWIGTYPE($&1_ltype argp) { + argp = ($&1_ltype)SWIG_MustGetPtr($input, $&1_descriptor, $argnum, 0); + $1 = *argp; +} + +%typemap(varin) SWIGTYPE { + $&1_ltype argp; + argp = ($&1_ltype)SWIG_MustGetPtr($input, $&1_descriptor, 1, 0); + $1 = *argp; +} + +%typemap(out) SWIGTYPE +#ifdef __cplusplus +{ + $&1_ltype resultptr; + resultptr = new $1_ltype(($1_ltype &) $1); + $result = SWIG_NewPointerObj (resultptr, $&1_descriptor, 1); +} +#else +{ + $&1_ltype resultptr; + resultptr = ($&1_ltype) malloc(sizeof($1_type)); + memmove(resultptr, &$1, sizeof($1_type)); + $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 1); +} +#endif + +%typemap(varout) SWIGTYPE +#ifdef __cplusplus +{ + $&1_ltype resultptr; + resultptr = new $1_ltype(($1_ltype&) $1); + $result = SWIG_NewPointerObj (resultptr, $&1_descriptor, 0); +} +#else +{ + $&1_ltype resultptr; + resultptr = ($&1_ltype) malloc(sizeof($1_type)); + memmove(resultptr, &$1, sizeof($1_type)); + $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 0); +} +#endif + +/* Enums */ + +%typemap(in) enum SWIGTYPE { $1 = ($1_type) gh_scm2int($input); } +/* The complicated construction below needed to deal with anonymous + enums, which cannot be cast to. */ +%typemap(varin) enum SWIGTYPE { + if (sizeof(int) != sizeof($1)) { + scm_error(scm_str2symbol("swig-error"), + (char *) FUNC_NAME, + (char *) "enum variable '$name' cannot be set", + SCM_EOL, SCM_BOOL_F); + } + * (int *) &($1) = gh_scm2int($input); +} +%typemap(out) enum SWIGTYPE { $result = gh_int2scm($1); } +%typemap(varout) enum SWIGTYPE { $result = gh_int2scm($1); } +%typemap(throws) enum SWIGTYPE { + scm_throw(gh_symbol2scm((char *) "swig-exception"), + gh_list(gh_int2scm($1), SCM_UNDEFINED)); +} + +/* The SIMPLE_MAP_WITH_EXPR macro below defines the whole set of + typemaps needed for simple types. + -- SCM_TO_C_EXPR is a C expression that translates the Scheme value + "swig_scm_value" to a C value. + -- C_TO_SCM_EXPR is a C expression that translates the C value + "swig_c_value" to a Scheme value. */ + +%define SIMPLE_MAP_WITH_EXPR(C_NAME, SCM_TO_C_EXPR, C_TO_SCM_EXPR, SCM_NAME) + %typemap (in, doc="$NAME is of type <" #SCM_NAME ">") C_NAME + { SCM swig_scm_value = $input; + $1 = SCM_TO_C_EXPR; } + %typemap (varin, doc="NEW-VALUE is of type <" #SCM_NAME ">") C_NAME + { SCM swig_scm_value = $input; + $1 = SCM_TO_C_EXPR; } + %typemap (out, doc="<" #SCM_NAME ">") C_NAME + { C_NAME swig_c_value = $1; + $result = C_TO_SCM_EXPR; } + %typemap (varout, doc="<" #SCM_NAME ">") C_NAME + { C_NAME swig_c_value = $1; + $result = C_TO_SCM_EXPR; } + /* INPUT and OUTPUT */ + %typemap (in, doc="$NAME is of type <" #SCM_NAME ">)") + C_NAME *INPUT(C_NAME temp) { + SCM swig_scm_value = $input; + temp = (C_NAME) SCM_TO_C_EXPR; $1 = &temp; } + %typemap (in,numinputs=0) C_NAME *OUTPUT (C_NAME temp) + {$1 = &temp;} + %typemap (argout,doc="$name (of type <" #SCM_NAME ">)") C_NAME *OUTPUT + { C_NAME swig_c_value = *$1; + SWIG_APPEND_VALUE(C_TO_SCM_EXPR); } + %typemap (in) C_NAME *BOTH = C_NAME *INPUT; + %typemap (argout) C_NAME *BOTH = C_NAME *OUTPUT; + %typemap (in) C_NAME *INOUT = C_NAME *INPUT; + %typemap (argout) C_NAME *INOUT = C_NAME *OUTPUT; + /* Const primitive references. Passed by value */ + %typemap(in, doc="$NAME is of type <" #SCM_NAME ">") const C_NAME & (C_NAME temp) + { SCM swig_scm_value = $input; + temp = SCM_TO_C_EXPR; + $1 = &temp; } + %typemap(out, doc="<" #SCM_NAME ">") const C_NAME & + { C_NAME swig_c_value = *$1; + $result = C_TO_SCM_EXPR; } + /* Throw typemap */ + %typemap(throws) C_NAME { + C_NAME swig_c_value = $1; + scm_throw(gh_symbol2scm((char *) "swig-exception"), + gh_list(C_TO_SCM_EXPR, SCM_UNDEFINED)); + } +%enddef + +/* The SIMPLE_MAP macro below defines the whole set of typemaps needed + for simple types. It generates slightly simpler code than the + macro above, but it is only suitable for very simple conversion + expressions. */ + +%define SIMPLE_MAP(C_NAME, SCM_TO_C, C_TO_SCM, SCM_NAME) + %typemap (in, doc="$NAME is of type <" #SCM_NAME ">") + C_NAME {$1 = ($1_ltype) SCM_TO_C($input);} + %typemap (varin, doc="NEW-VALUE is of type <" #SCM_NAME ">") + C_NAME {$1 = ($1_ltype) SCM_TO_C($input);} + %typemap (out, doc="<" #SCM_NAME ">") + C_NAME {$result = C_TO_SCM($1);} + %typemap (varout, doc="<" #SCM_NAME ">") + C_NAME {$result = C_TO_SCM($1);} + /* INPUT and OUTPUT */ + %typemap (in, doc="$NAME is of type <" #SCM_NAME ">)") + C_NAME *INPUT(C_NAME temp), C_NAME &INPUT(C_NAME temp) { + temp = (C_NAME) SCM_TO_C($input); $1 = &temp; + } + %typemap (in,numinputs=0) C_NAME *OUTPUT (C_NAME temp), C_NAME &OUTPUT(C_NAME temp) + {$1 = &temp;} + %typemap (argout,doc="$name (of type <" #SCM_NAME ">)") C_NAME *OUTPUT, C_NAME &OUTPUT + {SWIG_APPEND_VALUE(C_TO_SCM(*$1));} + %typemap (in) C_NAME *BOTH = C_NAME *INPUT; + %typemap (argout) C_NAME *BOTH = C_NAME *OUTPUT; + %typemap (in) C_NAME *INOUT = C_NAME *INPUT; + %typemap (argout) C_NAME *INOUT = C_NAME *OUTPUT; + %typemap (in) C_NAME &INOUT = C_NAME &INPUT; + %typemap (argout) C_NAME &INOUT = C_NAME &OUTPUT; + /* Const primitive references. Passed by value */ + %typemap(in, doc="$NAME is of type <" #SCM_NAME ">") const C_NAME & (C_NAME temp) { + temp = SCM_TO_C($input); + $1 = ($1_ltype) &temp; + } + %typemap(out, doc="<" #SCM_NAME ">") const C_NAME & { + $result = C_TO_SCM(*$1); + } + /* Throw typemap */ + %typemap(throws) C_NAME { + scm_throw(gh_symbol2scm((char *) "swig-exception"), + gh_list(C_TO_SCM($1), SCM_UNDEFINED)); + } +%enddef + + SIMPLE_MAP(bool, gh_scm2bool, gh_bool2scm, boolean); + SIMPLE_MAP(char, gh_scm2char, gh_char2scm, char); + SIMPLE_MAP(unsigned char, gh_scm2char, gh_char2scm, char); + SIMPLE_MAP(signed char, gh_scm2char, gh_char2scm, char); + SIMPLE_MAP(int, gh_scm2int, gh_int2scm, integer); + SIMPLE_MAP(short, gh_scm2short, gh_int2scm, integer); + SIMPLE_MAP(long, gh_scm2long, gh_long2scm, integer); + SIMPLE_MAP(ptrdiff_t, gh_scm2long, gh_long2scm, integer); + SIMPLE_MAP(unsigned int, gh_scm2uint, gh_ulong2scm, integer); + SIMPLE_MAP(unsigned short, gh_scm2ushort, gh_ulong2scm, integer); + SIMPLE_MAP(unsigned long, gh_scm2ulong, gh_ulong2scm, integer); + SIMPLE_MAP(size_t, gh_scm2ulong, gh_ulong2scm, integer); + SIMPLE_MAP(float, gh_scm2double, gh_double2scm, real); + SIMPLE_MAP(double, gh_scm2double, gh_double2scm, real); +// SIMPLE_MAP(char *, SWIG_scm2str, gh_str02scm, string); +// SIMPLE_MAP(const char *, SWIG_scm2str, gh_str02scm, string); + +/* Define long long typemaps -- uses functions that are only defined + in recent versions of Guile, availability also depends on Guile's + configuration. */ + +SIMPLE_MAP(long long, gh_scm2long_long, gh_long_long2scm, integer); +SIMPLE_MAP(unsigned long long, gh_scm2ulong_long, gh_ulong_long2scm, integer); + +/* Strings */ + + %typemap (in, doc="$NAME is a string") char *(int must_free = 0) { + $1 = ($1_ltype)SWIG_scm2str($input); + must_free = 1; + } + %typemap (varin, doc="NEW-VALUE is a string") char * {$1 = ($1_ltype)SWIG_scm2str($input);} + %typemap (out, doc="<string>") char * {$result = gh_str02scm((const char *)$1);} + %typemap (varout, doc="<string>") char * {$result = gh_str02scm($1);} + %typemap (in, doc="$NAME is a string") char * *INPUT(char * temp, int must_free = 0) { + temp = (char *) SWIG_scm2str($input); $1 = &temp; + must_free = 1; + } + %typemap (in,numinputs=0) char * *OUTPUT (char * temp) + {$1 = &temp;} + %typemap (argout,doc="$NAME (a string)") char * *OUTPUT + {SWIG_APPEND_VALUE(gh_str02scm(*$1));} + %typemap (in) char * *BOTH = char * *INPUT; + %typemap (argout) char * *BOTH = char * *OUTPUT; + %typemap (in) char * *INOUT = char * *INPUT; + %typemap (argout) char * *INOUT = char * *OUTPUT; + +/* SWIG_scm2str makes a malloc'ed copy of the string, so get rid of it after + the function call. */ + +%typemap (freearg) char * "if (must_free$argnum && $1) SWIG_free($1);"; +%typemap (freearg) char **INPUT, char **BOTH "if (must_free$argnum && (*$1)) SWIG_free(*$1);" +%typemap (freearg) char **OUTPUT "SWIG_free(*$1);" + +/* But this shall not apply if we try to pass a single char by + reference. */ + +%typemap (freearg) char *OUTPUT, char *BOTH ""; + +/* If we set a string variable, delete the old result first, unless const. */ + +%typemap (varin) char * { + if ($1) free($1); + $1 = ($1_ltype) SWIG_scm2str($input); +} + +%typemap (varin) const char * { + $1 = ($1_ltype) SWIG_scm2str($input); +} + +%typemap(throws) char * { + scm_throw(gh_symbol2scm((char *) "swig-exception"), + gh_list(gh_str02scm($1), SCM_UNDEFINED)); +} + +/* Void */ + +%typemap (out,doc="") void "gswig_result = SCM_UNSPECIFIED;"; + +/* SCM is passed through */ + +typedef unsigned long SCM; +%typemap (in) SCM "$1=$input;"; +%typemap (out) SCM "$result=$1;"; +%typecheck(SWIG_TYPECHECK_POINTER) SCM "$1=1;"; + +/* ------------------------------------------------------------ + * String & length + * ------------------------------------------------------------ */ + +%typemap(in) (char *STRING, int LENGTH) { + size_t temp; + $1 = ($1_ltype) gh_scm2newstr($input, &temp); + $2 = ($2_ltype) temp; +} + +/* ------------------------------------------------------------ + * CLASS::* (member function pointer) typemaps + * taken from typemaps/swigtype.swg + * ------------------------------------------------------------ */ + +#define %set_output(obj) $result = obj +#define %set_varoutput(obj) $result = obj +#define %argument_fail(code, type, name, argn) scm_wrong_type_arg((char *) FUNC_NAME, argn, $input); +#define %as_voidptr(ptr) (void*)(ptr) + +%typemap(in) SWIGTYPE (CLASS::*) { + int res = SWIG_ConvertMember($input, %as_voidptr(&$1), sizeof($type),$descriptor); + if (!SWIG_IsOK(res)) { + %argument_fail(res,"$type",$symname, $argnum); + } +} + +%typemap(out,noblock=1) SWIGTYPE (CLASS::*) { + %set_output(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor)); +} + +%typemap(varin) SWIGTYPE (CLASS::*) { + int res = SWIG_ConvertMember($input,%as_voidptr(&$1), sizeof($type), $descriptor); + if (!SWIG_IsOK(res)) { + scm_wrong_type_arg((char *) FUNC_NAME, 1, $input); + } +} + +%typemap(varout,noblock=1) SWIGTYPE (CLASS::*) { + %set_varoutput(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor)); +} + +/* ------------------------------------------------------------ + * Typechecking rules + * ------------------------------------------------------------ */ + +/* adapted from python.swg */ + +%typecheck(SWIG_TYPECHECK_INTEGER) + int, short, long, + unsigned int, unsigned short, unsigned long, + signed char, unsigned char, + long long, unsigned long long, + size_t, ptrdiff_t, + std::size_t, std::ptrdiff_t, + const int &, const short &, const long &, + const unsigned int &, const unsigned short &, const unsigned long &, + const long long &, const unsigned long long &, + const size_t &, const ptrdiff_t &, + const std::size_t &, const std::ptrdiff_t &, + enum SWIGTYPE +{ + $1 = SCM_NFALSEP(scm_integer_p($input)) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_BOOL) + bool, bool&, const bool& +{ + $1 = SCM_BOOLP($input) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_DOUBLE) + float, double, + const float &, const double & +{ + $1 = SCM_NFALSEP(scm_real_p($input)) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_CHAR) char { + $1 = SCM_CHARP($input) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_STRING) char * { + $1 = SCM_STRINGP($input) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] { + void *ptr; + int res = SWIG_ConvertPtr($input, &ptr, $1_descriptor, 0); + $1 = SWIG_CheckState(res); +} + +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { + void *ptr; + int res = SWIG_ConvertPtr($input, &ptr, $&descriptor, 0); + $1 = SWIG_CheckState(res); +} + +%typecheck(SWIG_TYPECHECK_VOIDPTR) void * { + void *ptr; + int res = SWIG_ConvertPtr($input, &ptr, 0, 0); + $1 = SWIG_CheckState(res); +} + +/* typemaps.i ends here */ diff --git a/devtools/swigwin-1.3.34/Lib/inttypes.i b/devtools/swigwin-1.3.34/Lib/inttypes.i new file mode 100644 index 0000000..0cc8194 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/inttypes.i @@ -0,0 +1,94 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * inttypes.i + * + * SWIG library file for ISO C99 types: 7.8 Format conversion of integer types <inttypes.h> + * ----------------------------------------------------------------------------- */ + +%{ +#include <inttypes.h> +%} + +%include <stdint.i> +%include <wchar.i> + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef SWIGWORDSIZE64 + + /* We have to define the `uintmax_t' type using `ldiv_t'. */ + typedef struct + { + long int quot; /* Quotient. */ + long int rem; /* Remainder. */ + } imaxdiv_t; + +#else + + /* We have to define the `uintmax_t' type using `lldiv_t'. */ + typedef struct + { + long long int quot; /* Quotient. */ + long long int rem; /* Remainder. */ + } imaxdiv_t; + +#endif + + /* Compute absolute value of N. */ + extern intmax_t imaxabs (intmax_t n); + + /* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */ + extern imaxdiv_t imaxdiv (intmax_t numer, intmax_t denom); + + /* Like `strtol' but convert to `intmax_t'. */ + extern intmax_t strtoimax (const char *nptr, char **endptr, int base); + + /* Like `strtoul' but convert to `uintmax_t'. */ + extern uintmax_t strtoumax (const char *nptr, char ** endptr, int base); + +#ifdef SWIG_WCHAR + /* Like `wcstol' but convert to `intmax_t'. */ + extern intmax_t wcstoimax (const wchar_t *nptr, wchar_t **endptr, int base); + + /* Like `wcstoul' but convert to `uintmax_t'. */ + extern uintmax_t wcstoumax (const wchar_t *nptr, wchar_t ** endptr, int base); +#endif + +#ifdef SWIGWORDSIZE64 + + /* Like `strtol' but convert to `intmax_t'. */ + extern intmax_t strtoimax (const char *nptr, char **endptr, int base); + + /* Like `strtoul' but convert to `uintmax_t'. */ + extern uintmax_t strtoumax (const char *nptr, char **endptr,int base); + +#ifdef SWIG_WCHAR + /* Like `wcstol' but convert to `intmax_t'. */ + extern intmax_t wcstoimax (const wchar_t *nptr, wchar_t **endptr, int base); + + /* Like `wcstoul' but convert to `uintmax_t'. */ + extern uintmax_t wcstoumax (const wchar_t *nptr, wchar_t **endptr, int base); +#endif + +#else /* SWIGWORDSIZE32 */ + + /* Like `strtol' but convert to `intmax_t'. */ + extern intmax_t strtoimax (const char *nptr, char **endptr, int base); + + /* Like `strtoul' but convert to `uintmax_t'. */ + extern uintmax_t strtoumax (const char *nptr, char **endptr, int base); + +#ifdef SWIG_WCHAR + /* Like `wcstol' but convert to `intmax_t'. */ + extern uintmax_t wcstoumax (const wchar_t *nptr, wchar_t **endptr, int base); +#endif + +#endif /* SWIGWORDSIZE32 */ + +#ifdef __cplusplus +} +#endif diff --git a/devtools/swigwin-1.3.34/Lib/java/arrays_java.i b/devtools/swigwin-1.3.34/Lib/java/arrays_java.i new file mode 100644 index 0000000..95510c3 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/java/arrays_java.i @@ -0,0 +1,391 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * arrays_java.i + * + * These typemaps give more natural support for arrays. The typemaps are not efficient + * as there is a lot of copying of the array values whenever the array is passed to C/C++ + * from Java and vice versa. The Java array is expected to be the same size as the C array. + * An exception is thrown if they are not. + * + * Example usage: + * Wrapping: + * + * %include <arrays_java.i> + * %inline %{ + * short FiddleSticks[3]; + * %} + * + * Use from Java like this: + * + * short[] fs = new short[] {10, 11, 12}; + * example.setFiddleSticks(fs); + * fs = example.getFiddleSticks(); + * ----------------------------------------------------------------------------- */ + +/* Primitive array support is a combination of SWIG macros and functions in order to reduce + * code bloat and aid maintainability. The SWIG preprocessor expands the macros into functions + * for inclusion in the generated code. */ + +/* Array support functions declarations macro */ +%define JAVA_ARRAYS_DECL(CTYPE, JNITYPE, JAVATYPE, JFUNCNAME) +%{ +int SWIG_JavaArrayIn##JFUNCNAME (JNIEnv *jenv, JNITYPE **jarr, CTYPE **carr, JNITYPE##Array input); +void SWIG_JavaArrayArgout##JFUNCNAME (JNIEnv *jenv, JNITYPE *jarr, CTYPE *carr, JNITYPE##Array input); +JNITYPE##Array SWIG_JavaArrayOut##JFUNCNAME (JNIEnv *jenv, CTYPE *result, jsize sz); +%} +%enddef + +/* Array support functions macro */ +%define JAVA_ARRAYS_IMPL(CTYPE, JNITYPE, JAVATYPE, JFUNCNAME) +%{ +/* CTYPE[] support */ +int SWIG_JavaArrayIn##JFUNCNAME (JNIEnv *jenv, JNITYPE **jarr, CTYPE **carr, JNITYPE##Array input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = JCALL1(GetArrayLength, jenv, input); + *jarr = JCALL2(Get##JAVATYPE##ArrayElements, jenv, input, 0); + if (!*jarr) + return 0; %} +#ifdef __cplusplus +%{ *carr = new CTYPE[sz]; %} +#else +%{ *carr = (CTYPE*) calloc(sz, sizeof(CTYPE)); %} +#endif +%{ if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + JAVA_TYPEMAP_ARRAY_ELEMENT_ASSIGN(CTYPE) + return 1; +} + +void SWIG_JavaArrayArgout##JFUNCNAME (JNIEnv *jenv, JNITYPE *jarr, CTYPE *carr, JNITYPE##Array input) { + int i; + jsize sz = JCALL1(GetArrayLength, jenv, input); + for (i=0; i<sz; i++) + jarr[i] = (JNITYPE)carr[i]; + JCALL3(Release##JAVATYPE##ArrayElements, jenv, input, jarr, 0); +} + +JNITYPE##Array SWIG_JavaArrayOut##JFUNCNAME (JNIEnv *jenv, CTYPE *result, jsize sz) { + JNITYPE *arr; + int i; + JNITYPE##Array jresult = JCALL1(New##JAVATYPE##Array, jenv, sz); + if (!jresult) + return NULL; + arr = JCALL2(Get##JAVATYPE##ArrayElements, jenv, jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (JNITYPE)result[i]; + JCALL3(Release##JAVATYPE##ArrayElements, jenv, jresult, arr, 0); + return jresult; +} +%} +%enddef + +%{ +#if defined(SWIG_NOINCLUDE) || defined(SWIG_NOARRAYS) +%} + +#ifdef __cplusplus +JAVA_ARRAYS_DECL(bool, jboolean, Boolean, Bool) /* bool[] */ +#endif + +JAVA_ARRAYS_DECL(signed char, jbyte, Byte, Schar) /* signed char[] */ +JAVA_ARRAYS_DECL(unsigned char, jshort, Short, Uchar) /* unsigned char[] */ +JAVA_ARRAYS_DECL(short, jshort, Short, Short) /* short[] */ +JAVA_ARRAYS_DECL(unsigned short, jint, Int, Ushort) /* unsigned short[] */ +JAVA_ARRAYS_DECL(int, jint, Int, Int) /* int[] */ +JAVA_ARRAYS_DECL(unsigned int, jlong, Long, Uint) /* unsigned int[] */ +JAVA_ARRAYS_DECL(long, jint, Int, Long) /* long[] */ +JAVA_ARRAYS_DECL(unsigned long, jlong, Long, Ulong) /* unsigned long[] */ +JAVA_ARRAYS_DECL(jlong, jlong, Long, Longlong) /* long long[] */ +JAVA_ARRAYS_DECL(float, jfloat, Float, Float) /* float[] */ +JAVA_ARRAYS_DECL(double, jdouble, Double, Double) /* double[] */ + +%{ +#else +%} + +#ifdef __cplusplus +/* Bool array element assignment different to other types to keep Visual C++ quiet */ +#define JAVA_TYPEMAP_ARRAY_ELEMENT_ASSIGN(CTYPE) (*carr)[i] = ((*jarr)[i] != 0); +JAVA_ARRAYS_IMPL(bool, jboolean, Boolean, Bool) /* bool[] */ +#undef JAVA_TYPEMAP_ARRAY_ELEMENT_ASSIGN +#endif + +#define JAVA_TYPEMAP_ARRAY_ELEMENT_ASSIGN(CTYPE) (*carr)[i] = (CTYPE)(*jarr)[i]; +JAVA_ARRAYS_IMPL(signed char, jbyte, Byte, Schar) /* signed char[] */ +JAVA_ARRAYS_IMPL(unsigned char, jshort, Short, Uchar) /* unsigned char[] */ +JAVA_ARRAYS_IMPL(short, jshort, Short, Short) /* short[] */ +JAVA_ARRAYS_IMPL(unsigned short, jint, Int, Ushort) /* unsigned short[] */ +JAVA_ARRAYS_IMPL(int, jint, Int, Int) /* int[] */ +JAVA_ARRAYS_IMPL(unsigned int, jlong, Long, Uint) /* unsigned int[] */ +JAVA_ARRAYS_IMPL(long, jint, Int, Long) /* long[] */ +JAVA_ARRAYS_IMPL(unsigned long, jlong, Long, Ulong) /* unsigned long[] */ +JAVA_ARRAYS_IMPL(jlong, jlong, Long, Longlong) /* long long[] */ +JAVA_ARRAYS_IMPL(float, jfloat, Float, Float) /* float[] */ +JAVA_ARRAYS_IMPL(double, jdouble, Double, Double) /* double[] */ + +%{ +#endif +%} + + +/* The rest of this file has the array typemaps */ + +/* Arrays of primitive types use the following macro. The array typemaps use support functions. */ +%define JAVA_ARRAYS_TYPEMAPS(CTYPE, JTYPE, JNITYPE, JFUNCNAME, JNIDESC) + +%typemap(jni) CTYPE[ANY], CTYPE[] %{JNITYPE##Array%} +%typemap(jtype) CTYPE[ANY], CTYPE[] %{JTYPE[]%} +%typemap(jstype) CTYPE[ANY], CTYPE[] %{JTYPE[]%} + +%typemap(in) CTYPE[] (JNITYPE *jarr) +%{ if (!SWIG_JavaArrayIn##JFUNCNAME(jenv, &jarr, &$1, $input)) return $null; %} +%typemap(in) CTYPE[ANY] (JNITYPE *jarr) +%{ if ($input && JCALL1(GetArrayLength, jenv, $input) != $1_size) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "incorrect array size"); + return $null; + } + if (!SWIG_JavaArrayIn##JFUNCNAME(jenv, &jarr, &$1, $input)) return $null; %} +%typemap(argout) CTYPE[ANY], CTYPE[] +%{ SWIG_JavaArrayArgout##JFUNCNAME(jenv, jarr$argnum, $1, $input); %} +%typemap(out) CTYPE[ANY] +%{$result = SWIG_JavaArrayOut##JFUNCNAME(jenv, $1, $1_dim0); %} +%typemap(out) CTYPE[] +%{$result = SWIG_JavaArrayOut##JFUNCNAME(jenv, $1, FillMeInAsSizeCannotBeDeterminedAutomatically); %} +%typemap(freearg) CTYPE[ANY], CTYPE[] +#ifdef __cplusplus +%{ delete [] $1; %} +#else +%{ free($1); %} +#endif + +%typemap(javain) CTYPE[ANY], CTYPE[] "$javainput" +%typemap(javaout) CTYPE[ANY], CTYPE[] { + return $jnicall; + } + +%enddef + +JAVA_ARRAYS_TYPEMAPS(bool, boolean, jboolean, Bool, "[Z") /* bool[ANY] */ +JAVA_ARRAYS_TYPEMAPS(signed char, byte, jbyte, Schar, "[B") /* signed char[ANY] */ +JAVA_ARRAYS_TYPEMAPS(unsigned char, short, jshort, Uchar, "[S") /* unsigned char[ANY] */ +JAVA_ARRAYS_TYPEMAPS(short, short, jshort, Short, "[S") /* short[ANY] */ +JAVA_ARRAYS_TYPEMAPS(unsigned short, int, jint, Ushort, "[I") /* unsigned short[ANY] */ +JAVA_ARRAYS_TYPEMAPS(int, int, jint, Int, "[I") /* int[ANY] */ +JAVA_ARRAYS_TYPEMAPS(unsigned int, long, jlong, Uint, "[J") /* unsigned int[ANY] */ +JAVA_ARRAYS_TYPEMAPS(long, int, jint, Long, "[I") /* long[ANY] */ +JAVA_ARRAYS_TYPEMAPS(unsigned long, long, jlong, Ulong, "[J") /* unsigned long[ANY] */ +JAVA_ARRAYS_TYPEMAPS(long long, long, jlong, Longlong, "[J") /* long long[ANY] */ +JAVA_ARRAYS_TYPEMAPS(float, float, jfloat, Float, "[F") /* float[ANY] */ +JAVA_ARRAYS_TYPEMAPS(double, double, jdouble, Double, "[D") /* double[ANY] */ + + +%typecheck(SWIG_TYPECHECK_BOOL_ARRAY) /* Java boolean[] */ + bool[ANY], bool[] + "" + +%typecheck(SWIG_TYPECHECK_INT8_ARRAY) /* Java byte[] */ + signed char[ANY], signed char[] + "" + +%typecheck(SWIG_TYPECHECK_INT16_ARRAY) /* Java short[] */ + unsigned char[ANY], unsigned char[], + short[ANY], short[] + "" + +%typecheck(SWIG_TYPECHECK_INT32_ARRAY) /* Java int[] */ + unsigned short[ANY], unsigned short[], + int[ANY], int[], + long[ANY], long[] + "" + +%typecheck(SWIG_TYPECHECK_INT64_ARRAY) /* Java long[] */ + unsigned int[ANY], unsigned int[], + unsigned long[ANY], unsigned long[], + long long[ANY], long long[] + "" + +%typecheck(SWIG_TYPECHECK_INT128_ARRAY) /* Java BigInteger[] */ + unsigned long long[ANY], unsigned long long[] + "" + +%typecheck(SWIG_TYPECHECK_FLOAT_ARRAY) /* Java float[] */ + float[ANY], float[] + "" + +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY) /* Java double[] */ + double[ANY], double[] + "" + + +/* Arrays of proxy classes. The typemaps in this macro make it possible to treat an array of + * class/struct/unions as an array of Java classes. + * Use the following macro to use these typemaps for an array of class/struct/unions called name: + * JAVA_ARRAYSOFCLASSES(name) + * Note that multiple copies of the class/struct is made when using the array as a parameter input. */ +%define JAVA_ARRAYSOFCLASSES(ARRAYSOFCLASSES) + +%typemap(jni) ARRAYSOFCLASSES[ANY], ARRAYSOFCLASSES[] "jlongArray" +%typemap(jtype) ARRAYSOFCLASSES[ANY], ARRAYSOFCLASSES[] "long[]" +%typemap(jstype) ARRAYSOFCLASSES[ANY], ARRAYSOFCLASSES[] "$javaclassname[]" + +%typemap(javain) ARRAYSOFCLASSES[ANY], ARRAYSOFCLASSES[] "$javaclassname.cArrayUnwrap($javainput)" +%typemap(javaout) ARRAYSOFCLASSES[ANY], ARRAYSOFCLASSES[] { + return $javaclassname.cArrayWrap($jnicall, $owner); + } + +%typemap(in) ARRAYSOFCLASSES[] (jlong *jarr, jsize sz) +{ + int i; + if (!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return $null; + } + sz = JCALL1(GetArrayLength, jenv, $input); + jarr = JCALL2(GetLongArrayElements, jenv, $input, 0); + if (!jarr) { + return $null; + } +#ifdef __cplusplus + $1 = new $*1_ltype[sz]; +#else + $1 = ($1_ltype) calloc(sz, sizeof($*1_ltype)); +#endif + if (!$1) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return $null; + } + for (i=0; i<sz; i++) { + $1[i] = **($&1_ltype)&jarr[i]; + } +} + +%typemap(in) ARRAYSOFCLASSES[ANY] (jlong *jarr, jsize sz) +{ + int i; + if (!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return $null; + } + sz = JCALL1(GetArrayLength, jenv, $input); + if (sz != $1_size) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "incorrect array size"); + return $null; + } + jarr = JCALL2(GetLongArrayElements, jenv, $input, 0); + if (!jarr) { + return $null; + } +#ifdef __cplusplus + $1 = new $*1_ltype[sz]; +#else + $1 = ($1_ltype) calloc(sz, sizeof($*1_ltype)); +#endif + if (!$1) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return $null; + } + for (i=0; i<sz; i++) { + $1[i] = **($&1_ltype)&jarr[i]; + } +} + +%typemap(argout) ARRAYSOFCLASSES[ANY], ARRAYSOFCLASSES[] +{ + int i; + for (i=0; i<sz$argnum; i++) { + **($&1_ltype)&jarr$argnum[i] = $1[i]; + } + JCALL3(ReleaseLongArrayElements, jenv, $input, jarr$argnum, 0); +} + +%typemap(out) ARRAYSOFCLASSES[ANY] +{ + jlong *arr; + int i; + $result = JCALL1(NewLongArray, jenv, $1_dim0); + if (!$result) { + return $null; + } + arr = JCALL2(GetLongArrayElements, jenv, $result, 0); + if (!arr) { + return $null; + } + for (i=0; i<$1_dim0; i++) { + arr[i] = 0; + *($&1_ltype)&arr[i] = &$1[i]; + } + JCALL3(ReleaseLongArrayElements, jenv, $result, arr, 0); +} + +%typemap(freearg) ARRAYSOFCLASSES[ANY], ARRAYSOFCLASSES[] +#ifdef __cplusplus +%{ delete [] $1; %} +#else +%{ free($1); %} +#endif + +/* Add some code to the proxy class of the array type for converting between type used in + * JNI class (long[]) and type used in proxy class ( ARRAYSOFCLASSES[] ) */ +%typemap(javacode) ARRAYSOFCLASSES %{ + protected static long[] cArrayUnwrap($javaclassname[] arrayWrapper) { + long[] cArray = new long[arrayWrapper.length]; + for (int i=0; i<arrayWrapper.length; i++) + cArray[i] = $javaclassname.getCPtr(arrayWrapper[i]); + return cArray; + } + + protected static $javaclassname[] cArrayWrap(long[] cArray, boolean cMemoryOwn) { + $javaclassname[] arrayWrapper = new $javaclassname[cArray.length]; + for (int i=0; i<cArray.length; i++) + arrayWrapper[i] = new $javaclassname(cArray[i], cMemoryOwn); + return arrayWrapper; + } +%} + +%enddef /* JAVA_ARRAYSOFCLASSES */ + + +/* Arrays of enums. + * Use the following to use these typemaps for an array of enums called name: + * %apply ARRAYSOFENUMS[ANY] { name[ANY] }; */ +%typemap(jni) ARRAYSOFENUMS[ANY], ARRAYSOFENUMS[] "jintArray" +%typemap(jtype) ARRAYSOFENUMS[ANY], ARRAYSOFENUMS[] "int[]" +%typemap(jstype) ARRAYSOFENUMS[ANY], ARRAYSOFENUMS[] "int[]" + +%typemap(javain) ARRAYSOFENUMS[ANY], ARRAYSOFENUMS[] "$javainput" +%typemap(javaout) ARRAYSOFENUMS[ANY], ARRAYSOFENUMS[] { + return $jnicall; + } + +%typemap(in) ARRAYSOFENUMS[] (jint *jarr) +%{ if (!SWIG_JavaArrayInInt(jenv, &jarr, (int **)&$1, $input)) return $null; %} +%typemap(in) ARRAYSOFENUMS[ANY] (jint *jarr) { + if ($input && JCALL1(GetArrayLength, jenv, $input) != $1_size) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "incorrect array size"); + return $null; + } + if (!SWIG_JavaArrayInInt(jenv, &jarr, (int **)&$1, $input)) return $null; +} +%typemap(argout) ARRAYSOFENUMS[ANY], ARRAYSOFENUMS[] +%{ SWIG_JavaArrayArgoutInt(jenv, jarr$argnum, (int *)$1, $input); %} +%typemap(out) ARRAYSOFENUMS[ANY] +%{$result = SWIG_JavaArrayOutInt(jenv, (int *)$1, $1_dim0); %} +%typemap(freearg) ARRAYSOFENUMS[ANY], ARRAYSOFENUMS[] +#ifdef __cplusplus +%{ delete [] $1; %} +#else +%{ free($1); %} +#endif + diff --git a/devtools/swigwin-1.3.34/Lib/java/boost_shared_ptr.i b/devtools/swigwin-1.3.34/Lib/java/boost_shared_ptr.i new file mode 100644 index 0000000..1f555bf --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/java/boost_shared_ptr.i @@ -0,0 +1,192 @@ +%include <shared_ptr.i> + +%define SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...) + +%naturalvar TYPE; +%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; + +// destructor mods +%feature("unref") TYPE +//"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter<SWIG_null_deleter>(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" + "(void)arg1; delete smartarg1;" + + +// plain value +%typemap(in) CONST TYPE ($&1_type argp = 0) %{ + argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0; + if (!argp) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type"); + return $null; + } + $1 = *argp; %} +%typemap(out) CONST TYPE +%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %} + +// plain pointer +%typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ + smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input; + $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %} +%typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{ + *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; +%} + +// plain reference +%typemap(in) CONST TYPE & %{ + $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); + if(!$1) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); + return $null; + } %} +%typemap(out, fragment="SWIG_null_deleter") CONST TYPE & +%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %} + +// plain pointer by reference +%typemap(in) CONST TYPE *& ($*1_ltype temp = 0) +%{ temp = ((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); + $1 = &temp; %} +%typemap(out, fragment="SWIG_null_deleter") CONST TYPE *& +%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %} + +// shared_ptr by value +%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ($&1_type argp) +%{ argp = *($&1_ltype*)&$input; + if (argp) $1 = *argp; %} +%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > +%{ *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0; %} + +// shared_ptr by reference +%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & ($*1_ltype tempnull) +%{ $1 = $input ? *($&1_ltype)&$input : &tempnull; %} +%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & +%{ *($&1_ltype)&$result = *$1 ? new $*1_ltype(*$1) : 0; %} + +// shared_ptr by pointer +%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * ($*1_ltype tempnull) +%{ $1 = $input ? *($&1_ltype)&$input : &tempnull; %} +%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * +%{ *($&1_ltype)&$result = ($1 && *$1) ? new $*1_ltype(*$1) : 0; + if ($owner) delete $1; %} + +// shared_ptr by pointer reference +%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempnull, $*1_ltype temp = 0) +%{ temp = $input ? *($1_ltype)&$input : &tempnull; + $1 = &temp; %} +%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& +%{ *($1_ltype)&$result = (*$1 && **$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; %} + +// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug +%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ +#error "typemaps for $1_type not available" +%} +%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ +#error "typemaps for $1_type not available" +%} + + +%typemap (jni) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "jlong" +%typemap (jtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "long" +%typemap (jstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "PROXYCLASS" + +%typemap(javain) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "PROXYCLASS.getCPtr($javainput)" + +%typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { + long cPtr = $jnicall; + return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); + } +%typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & { + long cPtr = $jnicall; + return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); + } +%typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * { + long cPtr = $jnicall; + return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); + } +%typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { + long cPtr = $jnicall; + return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); + } + + +%typemap(javaout) CONST TYPE { + return new PROXYCLASS($jnicall, true); + } +%typemap(javaout) CONST TYPE & { + return new PROXYCLASS($jnicall, true); + } +%typemap(javaout) CONST TYPE * { + long cPtr = $jnicall; + return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); + } +%typemap(javaout) CONST TYPE *& { + long cPtr = $jnicall; + return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); + } + +// Base proxy classes +%typemap(javabody) TYPE %{ + private long swigCPtr; + private boolean swigCMemOwnBase; + + protected $javaclassname(long cPtr, boolean cMemoryOwn) { + swigCMemOwnBase = cMemoryOwn; + swigCPtr = cPtr; + } + + protected static long getCPtr($javaclassname obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } +%} + +// Derived proxy classes +%typemap(javabody_derived) TYPE %{ + private long swigCPtr; + private boolean swigCMemOwnDerived; + + protected $javaclassname(long cPtr, boolean cMemoryOwn) { + super($imclassname.$javaclassname_SWIGSharedPtrUpcast(cPtr), true); + swigCMemOwnDerived = cMemoryOwn; + swigCPtr = cPtr; + } + + protected static long getCPtr($javaclassname obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } +%} + +%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE { + if(swigCPtr != 0 && swigCMemOwnBase) { + swigCMemOwnBase = false; + $jnicall; + } + swigCPtr = 0; + } + +%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") TYPE { + if(swigCPtr != 0 && swigCMemOwnDerived) { + swigCMemOwnDerived = false; + $jnicall; + } + swigCPtr = 0; + super.delete(); + } + +// CONST version needed ???? also for C# +%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "long" +%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "long" + + +%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; +%enddef + diff --git a/devtools/swigwin-1.3.34/Lib/java/director.swg b/devtools/swigwin-1.3.34/Lib/java/director.swg new file mode 100644 index 0000000..bade80c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/java/director.swg @@ -0,0 +1,185 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * director.swg + * + * This file contains support for director classes that proxy + * method calls from C++ to Java extensions. + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus + +#if defined(DEBUG_DIRECTOR_OWNED) +#include <iostream> +#endif + +namespace Swig { + /* Java object wrapper */ + class JObjectWrapper { + public: + JObjectWrapper() : jthis_(NULL), weak_global_(true) { + } + + ~JObjectWrapper() { + jthis_ = NULL; + weak_global_ = true; + } + + bool set(JNIEnv *jenv, jobject jobj, bool mem_own, bool weak_global) { + if (!jthis_) { + weak_global_ = weak_global; + if (jobj) + jthis_ = ((weak_global_ || !mem_own) ? jenv->NewWeakGlobalRef(jobj) : jenv->NewGlobalRef(jobj)); +#if defined(DEBUG_DIRECTOR_OWNED) + std::cout << "JObjectWrapper::set(" << jobj << ", " << (weak_global ? "weak_global" : "global_ref") << ") -> " << jthis_ << std::endl; +#endif + return true; + } else { +#if defined(DEBUG_DIRECTOR_OWNED) + std::cout << "JObjectWrapper::set(" << jobj << ", " << (weak_global ? "weak_global" : "global_ref") << ") -> already set" << std::endl; +#endif + return false; + } + } + + jobject get(JNIEnv *jenv) const { +#if defined(DEBUG_DIRECTOR_OWNED) + std::cout << "JObjectWrapper::get("; + if (jthis_) + std::cout << jthis_; + else + std::cout << "null"; + std::cout << ") -> return new local ref" << std::endl; +#endif + return (jthis_ ? jenv->NewLocalRef(jthis_) : jthis_); + } + + void release(JNIEnv *jenv) { +#if defined(DEBUG_DIRECTOR_OWNED) + std::cout << "JObjectWrapper::release(" << jthis_ << "): " << (weak_global_ ? "weak global ref" : "global ref") << std::endl; +#endif + if (jthis_) { + if (weak_global_) { + if (jenv->IsSameObject(jthis_, NULL) == JNI_FALSE) + jenv->DeleteWeakGlobalRef((jweak)jthis_); + } else + jenv->DeleteGlobalRef(jthis_); + } + + jthis_ = NULL; + weak_global_ = true; + } + + jobject peek() { + return jthis_; + } + + /* Java proxy releases ownership of C++ object, C++ object is now + responsible for destruction (creates NewGlobalRef to pin Java + proxy) */ + void java_change_ownership(JNIEnv *jenv, jobject jself, bool take_or_release) { + if (take_or_release) { /* Java takes ownership of C++ object's lifetime. */ + if (!weak_global_) { + jenv->DeleteGlobalRef(jthis_); + jthis_ = jenv->NewWeakGlobalRef(jself); + weak_global_ = true; + } + } else { /* Java releases ownership of C++ object's lifetime */ + if (weak_global_) { + jenv->DeleteWeakGlobalRef((jweak)jthis_); + jthis_ = jenv->NewGlobalRef(jself); + weak_global_ = false; + } + } + } + + private: + /* pointer to Java object */ + jobject jthis_; + /* Local or global reference flag */ + bool weak_global_; + }; + + /* director base class */ + class Director { + /* pointer to Java virtual machine */ + JavaVM *swig_jvm_; + + protected: +#if defined (_MSC_VER) && (_MSC_VER<1300) + class JNIEnvWrapper; + friend class JNIEnvWrapper; +#endif + /* Utility class for managing the JNI environment */ + class JNIEnvWrapper { + const Director *director_; + JNIEnv *jenv_; + public: + JNIEnvWrapper(const Director *director) : director_(director), jenv_(0) { + director_->swig_jvm_->AttachCurrentThread((void **) &jenv_, NULL); + } + ~JNIEnvWrapper() { +// Some JVMs, eg JDK 1.4.2 and lower on Solaris have a bug and crash with the DetachCurrentThread call. +// However, without this call, the JVM hangs on exit when the thread was not created by the JVM and creates a memory leak. +#if !defined(SWIG_JAVA_NO_DETACH_CURRENT_THREAD) + director_->swig_jvm_->DetachCurrentThread(); +#endif + } + JNIEnv *getJNIEnv() const { + return jenv_; + } + }; + + /* Java object wrapper */ + JObjectWrapper swig_self_; + + /* Disconnect director from Java object */ + void swig_disconnect_director_self(const char *disconn_method) { + JNIEnvWrapper jnienv(this) ; + JNIEnv *jenv = jnienv.getJNIEnv() ; + jobject jobj = swig_self_.peek(); +#if defined(DEBUG_DIRECTOR_OWNED) + std::cout << "Swig::Director::disconnect_director_self(" << jobj << ")" << std::endl; +#endif + if (jobj && jenv->IsSameObject(jobj, NULL) == JNI_FALSE) { + jmethodID disconn_meth = jenv->GetMethodID(jenv->GetObjectClass(jobj), disconn_method, "()V"); + if (disconn_meth) { +#if defined(DEBUG_DIRECTOR_OWNED) + std::cout << "Swig::Director::disconnect_director_self upcall to " << disconn_method << std::endl; +#endif + jenv->CallVoidMethod(jobj, disconn_meth); + } + } + } + + public: + Director(JNIEnv *jenv) : swig_jvm_((JavaVM *) NULL), swig_self_() { + /* Acquire the Java VM pointer */ + jenv->GetJavaVM(&swig_jvm_); + } + + virtual ~Director() { + JNIEnvWrapper jnienv(this) ; + JNIEnv *jenv = jnienv.getJNIEnv() ; + swig_self_.release(jenv); + } + + bool swig_set_self(JNIEnv *jenv, jobject jself, bool mem_own, bool weak_global) { + return swig_self_.set(jenv, jself, mem_own, weak_global); + } + + jobject swig_get_self(JNIEnv *jenv) const { + return swig_self_.get(jenv); + } + + // Change C++ object's ownership, relative to Java + void swig_java_change_ownership(JNIEnv *jenv, jobject jself, bool take_or_release) { + swig_self_.java_change_ownership(jenv, jself, take_or_release); + } + }; +} + +#endif /* __cplusplus */ + + diff --git a/devtools/swigwin-1.3.34/Lib/java/enums.swg b/devtools/swigwin-1.3.34/Lib/java/enums.swg new file mode 100644 index 0000000..2ccb954 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/java/enums.swg @@ -0,0 +1,117 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * enums.swg + * + * Include this file in order for C/C++ enums to be wrapped by proper Java enums. + * Note that the JNI layer handles the enum as an int. The Java enum has extra + * code generated to store the C++ int value. This is required for C++ enums that + * specify a value for the enum item, as native Java enums do not support this. + * ----------------------------------------------------------------------------- */ + +// const enum SWIGTYPE & typemaps +%typemap(jni) const enum SWIGTYPE & "jint" +%typemap(jtype) const enum SWIGTYPE & "int" +%typemap(jstype) const enum SWIGTYPE & "$*javaclassname" + +%typemap(in) const enum SWIGTYPE & ($*1_ltype temp) +%{ temp = ($*1_ltype)$input; + $1 = &temp; %} +%typemap(out) const enum SWIGTYPE & %{ $result = (jint)*$1; %} + +%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & +%{ static $*1_ltype temp = ($*1_ltype)$input; + $result = &temp; %} +%typemap(directorin, descriptor="L$packagepath/$*javaclassname;") const enum SWIGTYPE & "$input = (jint)$1_name;" +%typemap(javadirectorin) const enum SWIGTYPE & "$*javaclassname.swigToEnum($jniinput)" +%typemap(javadirectorout) const enum SWIGTYPE & "($javacall).swigValue()" + +%typecheck(SWIG_TYPECHECK_POINTER) const enum SWIGTYPE & "" + +%typemap(throws) const enum SWIGTYPE & +%{ (void)$1; + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} + +%typemap(javain) const enum SWIGTYPE & "$javainput.swigValue()" +%typemap(javaout) const enum SWIGTYPE & { + return $*javaclassname.swigToEnum($jnicall); + } + + +// enum SWIGTYPE typemaps +%typemap(jni) enum SWIGTYPE "jint" +%typemap(jtype) enum SWIGTYPE "int" +%typemap(jstype) enum SWIGTYPE "$javaclassname" + +%typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} +%typemap(out) enum SWIGTYPE %{ $result = (jint)$1; %} + +%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} +%typemap(directorin, descriptor="L$packagepath/$javaclassname;") enum SWIGTYPE "$input = (jint) $1;" +%typemap(javadirectorin) enum SWIGTYPE "$javaclassname.swigToEnum($jniinput)" +%typemap(javadirectorout) enum SWIGTYPE "($javacall).swigValue()" + +%typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE "" + +%typemap(throws) enum SWIGTYPE +%{ (void)$1; + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} + +%typemap(javain) enum SWIGTYPE "$javainput.swigValue()" +%typemap(javaout) enum SWIGTYPE { + return $javaclassname.swigToEnum($jnicall); + } + +%typemap(javaclassmodifiers) enum SWIGTYPE "public enum" +%typemap(javabase) enum SWIGTYPE "" +%typemap(javacode) enum SWIGTYPE "" +%typemap(javaimports) enum SWIGTYPE "" +%typemap(javainterfaces) enum SWIGTYPE "" +%typemap(javabody) enum SWIGTYPE "" + +/* + * SwigNext static inner class used instead of a static int as static fields cannot be accessed from enum initialisers. + * The swigToEnum method is used to find the Java enum from a C++ enum integer value. The default one here takes + * advantage of the fact that most enums do not have initial values specified, so the lookup is fast. If initial + * values are specified then a lengthy linear search through all possible enums might occur. Specific typemaps could be + * written to possibly optimise this lookup by taking advantage of characteristics peculiar to the targeted enum. + */ +%typemap(javabody) enum SWIGTYPE %{ + public final int swigValue() { + return swigValue; + } + + public static $javaclassname swigToEnum(int swigValue) { + $javaclassname[] swigValues = $javaclassname.class.getEnumConstants(); + if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue) + return swigValues[swigValue]; + for ($javaclassname swigEnum : swigValues) + if (swigEnum.swigValue == swigValue) + return swigEnum; + throw new IllegalArgumentException("No enum " + $javaclassname.class + " with value " + swigValue); + } + + private $javaclassname() { + this.swigValue = SwigNext.next++; + } + + private $javaclassname(int swigValue) { + this.swigValue = swigValue; + SwigNext.next = swigValue+1; + } + + private $javaclassname($javaclassname swigEnum) { + this.swigValue = swigEnum.swigValue; + SwigNext.next = this.swigValue+1; + } + + private final int swigValue; + + private static class SwigNext { + private static int next = 0; + } +%} + +%javaenum(proper); + diff --git a/devtools/swigwin-1.3.34/Lib/java/enumsimple.swg b/devtools/swigwin-1.3.34/Lib/java/enumsimple.swg new file mode 100644 index 0000000..f45774d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/java/enumsimple.swg @@ -0,0 +1,74 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * enumsimple.swg + * + * This file provides backwards compatible enum wrapping. SWIG versions 1.3.21 + * and earlier wrapped global enums with constant integers in the module class + * or Constants interface. Enums declared within a C++ class were wrapped by + * constant integers in the Java proxy class. + * ----------------------------------------------------------------------------- */ + +// const enum SWIGTYPE & typemaps +%typemap(jni) const enum SWIGTYPE & "jint" +%typemap(jtype) const enum SWIGTYPE & "int" +%typemap(jstype) const enum SWIGTYPE & "int" + +%typemap(in) const enum SWIGTYPE & ($*1_ltype temp) +%{ temp = ($*1_ltype)$input; + $1 = &temp; %} +%typemap(out) const enum SWIGTYPE & %{ $result = (jint)*$1; %} + +%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & +%{ static $*1_ltype temp = ($*1_ltype)$input; + $result = &temp; %} +%typemap(directorin, descriptor="I") const enum SWIGTYPE & "$input = (jint)$1_name;" +%typemap(javadirectorin) const enum SWIGTYPE & "$jniinput" +%typemap(javadirectorout) const enum SWIGTYPE & "$javacall" + +%typecheck(SWIG_TYPECHECK_INT32) const enum SWIGTYPE & "" + +%typemap(throws) const enum SWIGTYPE & +%{ (void)$1; + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} + +%typemap(javain) const enum SWIGTYPE & "$javainput" +%typemap(javaout) const enum SWIGTYPE & { + return $jnicall; + } + + +// enum SWIGTYPE typemaps +%typemap(jni) enum SWIGTYPE "jint" +%typemap(jtype) enum SWIGTYPE "int" +%typemap(jstype) enum SWIGTYPE "int" + +%typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} +%typemap(out) enum SWIGTYPE %{ $result = (jint)$1; %} + +%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} +%typemap(directorin, descriptor="I") enum SWIGTYPE "$input = (jint) $1;" +%typemap(javadirectorin) enum SWIGTYPE "$jniinput" +%typemap(javadirectorout) enum SWIGTYPE "$javacall" + +%typecheck(SWIG_TYPECHECK_INT32) enum SWIGTYPE "" + +%typemap(throws) enum SWIGTYPE +%{ (void)$1; + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} + +%typemap(javain) enum SWIGTYPE "$javainput" +%typemap(javaout) enum SWIGTYPE { + return $jnicall; + } + +%typemap(javaclassmodifiers) enum SWIGTYPE "" +%typemap(javabase) enum SWIGTYPE "" +%typemap(javacode) enum SWIGTYPE "" +%typemap(javaimports) enum SWIGTYPE "" +%typemap(javainterfaces) enum SWIGTYPE "" +%typemap(javabody) enum SWIGTYPE "" + +%javaenum(simple); + diff --git a/devtools/swigwin-1.3.34/Lib/java/enumtypesafe.swg b/devtools/swigwin-1.3.34/Lib/java/enumtypesafe.swg new file mode 100644 index 0000000..a49a9d1 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/java/enumtypesafe.swg @@ -0,0 +1,121 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * enumtypesafe.swg + * + * Include this file in order for C/C++ enums to be wrapped by the so called + * typesafe enum pattern. Each enum has an equivalent Java class named after the + * enum and each enum item is a static instance of this class. + * ----------------------------------------------------------------------------- */ + +// const enum SWIGTYPE & typemaps +%typemap(jni) const enum SWIGTYPE & "jint" +%typemap(jtype) const enum SWIGTYPE & "int" +%typemap(jstype) const enum SWIGTYPE & "$*javaclassname" + +%typemap(in) const enum SWIGTYPE & ($*1_ltype temp) +%{ temp = ($*1_ltype)$input; + $1 = &temp; %} +%typemap(out) const enum SWIGTYPE & %{ $result = (jint)*$1; %} + +%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & +%{ static $*1_ltype temp = ($*1_ltype)$input; + $result = &temp; %} +%typemap(directorin, descriptor="L$packagepath/$*javaclassname;") const enum SWIGTYPE & "$input = (jint)$1_name;" +%typemap(javadirectorin) const enum SWIGTYPE & "$*javaclassname.swigToEnum($jniinput)" +%typemap(javadirectorout) const enum SWIGTYPE & "($javacall).swigValue()" + +%typecheck(SWIG_TYPECHECK_POINTER) const enum SWIGTYPE & "" + +%typemap(throws) const enum SWIGTYPE & +%{ (void)$1; + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} + +%typemap(javain) const enum SWIGTYPE & "$javainput.swigValue()" +%typemap(javaout) const enum SWIGTYPE & { + return $*javaclassname.swigToEnum($jnicall); + } + +// enum SWIGTYPE typemaps +%typemap(jni) enum SWIGTYPE "jint" +%typemap(jtype) enum SWIGTYPE "int" +%typemap(jstype) enum SWIGTYPE "$javaclassname" + +%typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} +%typemap(out) enum SWIGTYPE %{ $result = (jint)$1; %} + +%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} +%typemap(directorin, descriptor="L$packagepath/$javaclassname;") enum SWIGTYPE "$input = (jint) $1;" +%typemap(javadirectorin) enum SWIGTYPE "$javaclassname.swigToEnum($jniinput)" +%typemap(javadirectorout) enum SWIGTYPE "($javacall).swigValue()" + +%typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE "" + +%typemap(throws) enum SWIGTYPE +%{ (void)$1; + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} + +%typemap(javain) enum SWIGTYPE "$javainput.swigValue()" +%typemap(javaout) enum SWIGTYPE { + return $javaclassname.swigToEnum($jnicall); + } + +// '$static' will be replaced with either 'static' or nothing depending on whether the enum is an inner Java class or not +%typemap(javaclassmodifiers) enum SWIGTYPE "public final $static class" +%typemap(javabase) enum SWIGTYPE "" +%typemap(javacode) enum SWIGTYPE "" +%typemap(javaimports) enum SWIGTYPE "" +%typemap(javainterfaces) enum SWIGTYPE "" +%typemap(javabody) enum SWIGTYPE "" + +/* + * The swigToEnum method is used to find the Java enum from a C++ enum integer value. The default one here takes + * advantage of the fact that most enums do not have initial values specified, so the lookup is fast. If initial + * values are specified then a lengthy linear search through all possible enums might occur. Specific typemaps could be + * written to possibly optimise this lookup by taking advantage of characteristics peculiar to the targeted enum. + * The special variable, $enumvalues, is replaced with a comma separated list of all the enum values. + */ +%typemap(javabody) enum SWIGTYPE %{ + public final int swigValue() { + return swigValue; + } + + public String toString() { + return swigName; + } + + public static $javaclassname swigToEnum(int swigValue) { + if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue) + return swigValues[swigValue]; + for (int i = 0; i < swigValues.length; i++) + if (swigValues[i].swigValue == swigValue) + return swigValues[i]; + throw new IllegalArgumentException("No enum " + $javaclassname.class + " with value " + swigValue); + } + + private $javaclassname(String swigName) { + this.swigName = swigName; + this.swigValue = swigNext++; + } + + private $javaclassname(String swigName, int swigValue) { + this.swigName = swigName; + this.swigValue = swigValue; + swigNext = swigValue+1; + } + + private $javaclassname(String swigName, $javaclassname swigEnum) { + this.swigName = swigName; + this.swigValue = swigEnum.swigValue; + swigNext = this.swigValue+1; + } + + private static $javaclassname[] swigValues = { $enumvalues }; + private static int swigNext = 0; + private final int swigValue; + private final String swigName; +%} + +%javaenum(typesafe); + diff --git a/devtools/swigwin-1.3.34/Lib/java/enumtypeunsafe.swg b/devtools/swigwin-1.3.34/Lib/java/enumtypeunsafe.swg new file mode 100644 index 0000000..bda0551 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/java/enumtypeunsafe.swg @@ -0,0 +1,75 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * enumtypeunsafe.swg + * + * Include this file in order for C/C++ enums to be wrapped by integers values. + * Each enum has an equivalent class named after the enum and the enum items are + * wrapped by constant integers within this class. The enum items are not + * typesafe as they are all integers. + * ----------------------------------------------------------------------------- */ + +// const enum SWIGTYPE & typemaps +%typemap(jni) const enum SWIGTYPE & "jint" +%typemap(jtype) const enum SWIGTYPE & "int" +%typemap(jstype) const enum SWIGTYPE & "int" + +%typemap(in) const enum SWIGTYPE & ($*1_ltype temp) +%{ temp = ($*1_ltype)$input; + $1 = &temp; %} +%typemap(out) const enum SWIGTYPE & %{ $result = (jint)*$1; %} + +%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & +%{ static $*1_ltype temp = ($*1_ltype)$input; + $result = &temp; %} +%typemap(directorin, descriptor="I") const enum SWIGTYPE & "$input = (jint)$1_name;" +%typemap(javadirectorin) const enum SWIGTYPE & "$jniinput" +%typemap(javadirectorout) const enum SWIGTYPE & "$javacall" + +%typecheck(SWIG_TYPECHECK_INT32) const enum SWIGTYPE & "" + +%typemap(throws) const enum SWIGTYPE & +%{ (void)$1; + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} + +%typemap(javain) const enum SWIGTYPE & "$javainput" +%typemap(javaout) const enum SWIGTYPE & { + return $jnicall; + } + + +// enum SWIGTYPE typemaps +%typemap(jni) enum SWIGTYPE "jint" +%typemap(jtype) enum SWIGTYPE "int" +%typemap(jstype) enum SWIGTYPE "int" + +%typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} +%typemap(out) enum SWIGTYPE %{ $result = (jint)$1; %} + +%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} +%typemap(directorin, descriptor="I") enum SWIGTYPE "$input = (jint) $1;" +%typemap(javadirectorin) enum SWIGTYPE "$jniinput" +%typemap(javadirectorout) enum SWIGTYPE "$javacall" + +%typecheck(SWIG_TYPECHECK_INT32) enum SWIGTYPE "" + +%typemap(throws) enum SWIGTYPE +%{ (void)$1; + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} + +%typemap(javain) enum SWIGTYPE "$javainput" +%typemap(javaout) enum SWIGTYPE { + return $jnicall; + } + +// '$static' will be replaced with either 'static' or nothing depending on whether the enum is an inner Java class or not +%typemap(javaclassmodifiers) enum SWIGTYPE "public final $static class" +%typemap(javabase) enum SWIGTYPE "" +%typemap(javacode) enum SWIGTYPE "" +%typemap(javaimports) enum SWIGTYPE "" +%typemap(javainterfaces) enum SWIGTYPE "" +%typemap(javabody) enum SWIGTYPE "" + +%javaenum(typeunsafe); + diff --git a/devtools/swigwin-1.3.34/Lib/java/java.swg b/devtools/swigwin-1.3.34/Lib/java/java.swg new file mode 100644 index 0000000..d743e02 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/java/java.swg @@ -0,0 +1,1195 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * java.swg + * + * Java typemaps + * ----------------------------------------------------------------------------- */ + +%include <javahead.swg> + +/* The jni, jtype and jstype typemaps work together and so there should be one of each. + * The jni typemap contains the JNI type used in the JNI (C/C++) code. + * The jtype typemap contains the Java type used in the JNI intermediary class. + * The jstype typemap contains the Java type used in the Java proxy classes, type wrapper classes and module class. */ + +/* Primitive types */ +%typemap(jni) bool, const bool & "jboolean" +%typemap(jni) char, const char & "jchar" +%typemap(jni) signed char, const signed char & "jbyte" +%typemap(jni) unsigned char, const unsigned char & "jshort" +%typemap(jni) short, const short & "jshort" +%typemap(jni) unsigned short, const unsigned short & "jint" +%typemap(jni) int, const int & "jint" +%typemap(jni) unsigned int, const unsigned int & "jlong" +%typemap(jni) long, const long & "jint" +%typemap(jni) unsigned long, const unsigned long & "jlong" +%typemap(jni) long long, const long long & "jlong" +%typemap(jni) unsigned long long, const unsigned long long & "jobject" +%typemap(jni) float, const float & "jfloat" +%typemap(jni) double, const double & "jdouble" +%typemap(jni) void "void" + +%typemap(jtype) bool, const bool & "boolean" +%typemap(jtype) char, const char & "char" +%typemap(jtype) signed char, const signed char & "byte" +%typemap(jtype) unsigned char, const unsigned char & "short" +%typemap(jtype) short, const short & "short" +%typemap(jtype) unsigned short, const unsigned short & "int" +%typemap(jtype) int, const int & "int" +%typemap(jtype) unsigned int, const unsigned int & "long" +%typemap(jtype) long, const long & "int" +%typemap(jtype) unsigned long, const unsigned long & "long" +%typemap(jtype) long long, const long long & "long" +%typemap(jtype) unsigned long long, const unsigned long long & "java.math.BigInteger" +%typemap(jtype) float, const float & "float" +%typemap(jtype) double, const double & "double" +%typemap(jtype) void "void" + +%typemap(jstype) bool, const bool & "boolean" +%typemap(jstype) char, const char & "char" +%typemap(jstype) signed char, const signed char & "byte" +%typemap(jstype) unsigned char, const unsigned char & "short" +%typemap(jstype) short, const short & "short" +%typemap(jstype) unsigned short, const unsigned short & "int" +%typemap(jstype) int, const int & "int" +%typemap(jstype) unsigned int, const unsigned int & "long" +%typemap(jstype) long, const long & "int" +%typemap(jstype) unsigned long, const unsigned long & "long" +%typemap(jstype) long long, const long long & "long" +%typemap(jstype) unsigned long long, const unsigned long long & "java.math.BigInteger" +%typemap(jstype) float, const float & "float" +%typemap(jstype) double, const double & "double" +%typemap(jstype) void "void" + +%typemap(jni) char *, char[ANY], char[] "jstring" +%typemap(jtype) char *, char[ANY], char[] "String" +%typemap(jstype) char *, char[ANY], char[] "String" + +/* JNI types */ +%typemap(jni) jboolean "jboolean" +%typemap(jni) jchar "jchar" +%typemap(jni) jbyte "jbyte" +%typemap(jni) jshort "jshort" +%typemap(jni) jint "jint" +%typemap(jni) jlong "jlong" +%typemap(jni) jfloat "jfloat" +%typemap(jni) jdouble "jdouble" +%typemap(jni) jstring "jstring" +%typemap(jni) jobject "jobject" +%typemap(jni) jbooleanArray "jbooleanArray" +%typemap(jni) jcharArray "jcharArray" +%typemap(jni) jbyteArray "jbyteArray" +%typemap(jni) jshortArray "jshortArray" +%typemap(jni) jintArray "jintArray" +%typemap(jni) jlongArray "jlongArray" +%typemap(jni) jfloatArray "jfloatArray" +%typemap(jni) jdoubleArray "jdoubleArray" +%typemap(jni) jobjectArray "jobjectArray" + +%typemap(jtype) jboolean "boolean" +%typemap(jtype) jchar "char" +%typemap(jtype) jbyte "byte" +%typemap(jtype) jshort "short" +%typemap(jtype) jint "int" +%typemap(jtype) jlong "long" +%typemap(jtype) jfloat "float" +%typemap(jtype) jdouble "double" +%typemap(jtype) jstring "String" +%typemap(jtype) jobject "Object" +%typemap(jtype) jbooleanArray "boolean[]" +%typemap(jtype) jcharArray "char[]" +%typemap(jtype) jbyteArray "byte[]" +%typemap(jtype) jshortArray "short[]" +%typemap(jtype) jintArray "int[]" +%typemap(jtype) jlongArray "long[]" +%typemap(jtype) jfloatArray "float[]" +%typemap(jtype) jdoubleArray "double[]" +%typemap(jtype) jobjectArray "Object[]" + +%typemap(jstype) jboolean "boolean" +%typemap(jstype) jchar "char" +%typemap(jstype) jbyte "byte" +%typemap(jstype) jshort "short" +%typemap(jstype) jint "int" +%typemap(jstype) jlong "long" +%typemap(jstype) jfloat "float" +%typemap(jstype) jdouble "double" +%typemap(jstype) jstring "String" +%typemap(jstype) jobject "Object" +%typemap(jstype) jbooleanArray "boolean[]" +%typemap(jstype) jcharArray "char[]" +%typemap(jstype) jbyteArray "byte[]" +%typemap(jstype) jshortArray "short[]" +%typemap(jstype) jintArray "int[]" +%typemap(jstype) jlongArray "long[]" +%typemap(jstype) jfloatArray "float[]" +%typemap(jstype) jdoubleArray "double[]" +%typemap(jstype) jobjectArray "Object[]" + +/* Non primitive types */ +%typemap(jni) SWIGTYPE "jlong" +%typemap(jtype) SWIGTYPE "long" +%typemap(jstype) SWIGTYPE "$&javaclassname" + +%typemap(jni) SWIGTYPE [] "jlong" +%typemap(jtype) SWIGTYPE [] "long" +%typemap(jstype) SWIGTYPE [] "$javaclassname" + +%typemap(jni) SWIGTYPE * "jlong" +%typemap(jtype) SWIGTYPE * "long" +%typemap(jstype) SWIGTYPE * "$javaclassname" + +%typemap(jni) SWIGTYPE & "jlong" +%typemap(jtype) SWIGTYPE & "long" +%typemap(jstype) SWIGTYPE & "$javaclassname" + +/* pointer to a class member */ +%typemap(jni) SWIGTYPE (CLASS::*) "jlong" +%typemap(jtype) SWIGTYPE (CLASS::*) "long" +%typemap(jstype) SWIGTYPE (CLASS::*) "$javaclassname" + +/* The following are the in, out, freearg, argout typemaps. These are the JNI code generating typemaps for converting from Java to C and visa versa. */ + +/* primitive types */ +%typemap(in) bool +%{ $1 = $input ? true : false; %} + +%typemap(directorout) bool +%{ $result = $input ? true : false; %} + +%typemap(javadirectorin) bool "$jniinput" +%typemap(javadirectorout) bool "$javacall" + +%typemap(in) char, + signed char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + float, + double +%{ $1 = ($1_ltype)$input; %} + +%typemap(directorout) char, + signed char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + float, + double +%{ $result = ($1_ltype)$input; %} + +%typemap(directorin, descriptor="Z") bool "$input = (jboolean) $1;" +%typemap(directorin, descriptor="C") char "$input = (jint) $1;" +%typemap(directorin, descriptor="B") signed char "$input = (jbyte) $1;" +%typemap(directorin, descriptor="S") unsigned char "$input = (jshort) $1;" +%typemap(directorin, descriptor="S") short "$input = (jshort) $1;" +%typemap(directorin, descriptor="I") unsigned short "$input = (jint) $1;" +%typemap(directorin, descriptor="I") int "$input = (jint) $1;" +%typemap(directorin, descriptor="J") unsigned int "$input = (jlong) $1;" +%typemap(directorin, descriptor="I") long "$input = (jint) $1;" +%typemap(directorin, descriptor="J") unsigned long "$input = (jlong) $1;" +%typemap(directorin, descriptor="J") long long "$input = (jlong) $1;" +%typemap(directorin, descriptor="F") float "$input = (jfloat) $1;" +%typemap(directorin, descriptor="D") double "$input = (jdouble) $1;" + +%typemap(javadirectorin) char, + signed char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + float, + double + "$jniinput" + +%typemap(javadirectorout) char, + signed char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + float, + double + "$javacall" + +%typemap(out) bool %{ $result = (jboolean)$1; %} +%typemap(out) char %{ $result = (jchar)$1; %} +%typemap(out) signed char %{ $result = (jbyte)$1; %} +%typemap(out) unsigned char %{ $result = (jshort)$1; %} +%typemap(out) short %{ $result = (jshort)$1; %} +%typemap(out) unsigned short %{ $result = (jint)$1; %} +%typemap(out) int %{ $result = (jint)$1; %} +%typemap(out) unsigned int %{ $result = (jlong)$1; %} +%typemap(out) long %{ $result = (jint)$1; %} +%typemap(out) unsigned long %{ $result = (jlong)$1; %} +%typemap(out) long long %{ $result = (jlong)$1; %} +%typemap(out) float %{ $result = (jfloat)$1; %} +%typemap(out) double %{ $result = (jdouble)$1; %} + +/* unsigned long long */ +/* Convert from BigInteger using the toByteArray member function */ +%typemap(in) unsigned long long { + jclass clazz; + jmethodID mid; + jbyteArray ba; + jbyte* bae; + jsize sz; + int i; + + if (!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null"); + return $null; + } + clazz = JCALL1(GetObjectClass, jenv, $input); + mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B"); + ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid); + bae = JCALL2(GetByteArrayElements, jenv, ba, 0); + sz = JCALL1(GetArrayLength, jenv, ba); + $1 = 0; + for(i=0; i<sz; i++) { + $1 = ($1 << 8) | ($1_type)(unsigned char)bae[i]; + } + JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); +} + +%typemap(directorout) unsigned long long { + jclass clazz; + jmethodID mid; + jbyteArray ba; + jbyte* bae; + jsize sz; + int i; + + if (!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null"); + return $null; + } + clazz = JCALL1(GetObjectClass, jenv, $input); + mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B"); + ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid); + bae = JCALL2(GetByteArrayElements, jenv, ba, 0); + sz = JCALL1(GetArrayLength, jenv, ba); + $result = 0; + for(i=0; i<sz; i++) { + $result = ($result << 8) | ($1_type)(unsigned char)bae[i]; + } + JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); +} + + +/* Convert to BigInteger - byte array holds number in 2's complement big endian format */ +%typemap(out) unsigned long long { + jbyteArray ba = JCALL1(NewByteArray, jenv, 9); + jbyte* bae = JCALL2(GetByteArrayElements, jenv, ba, 0); + jclass clazz = JCALL1(FindClass, jenv, "java/math/BigInteger"); + jmethodID mid = JCALL3(GetMethodID, jenv, clazz, "<init>", "([B)V"); + jobject bigint; + int i; + + bae[0] = 0; + for(i=1; i<9; i++ ) { + bae[i] = (jbyte)($1>>8*(8-i)); + } + + JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); + bigint = JCALL3(NewObject, jenv, clazz, mid, ba); + $result = bigint; +} + +/* Convert to BigInteger (see out typemap) */ +%typemap(directorin, descriptor="Ljava/math/BigInteger;") unsigned long long, const unsigned long long & { + jbyteArray ba = JCALL1(NewByteArray, jenv, 9); + jbyte* bae = JCALL2(GetByteArrayElements, jenv, ba, 0); + jclass clazz = JCALL1(FindClass, jenv, "java/math/BigInteger"); + jmethodID mid = JCALL3(GetMethodID, jenv, clazz, "<init>", "([B)V"); + jobject bigint; + int swig_i; + + bae[0] = 0; + for(swig_i=1; swig_i<9; swig_i++ ) { + bae[swig_i] = (jbyte)($1>>8*(8-swig_i)); + } + + JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); + bigint = JCALL3(NewObject, jenv, clazz, mid, ba); + $input = bigint; +} + +%typemap(javadirectorin) unsigned long long "$jniinput" +%typemap(javadirectorout) unsigned long long "$javacall" + +/* char * - treat as String */ +%typemap(in, noblock=1) char * { + $1 = 0; + if ($input) { + $1 = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0); + if (!$1) return $null; + } +} + +%typemap(directorout, noblock=1, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) char * { + $1 = 0; + if ($input) { + $result = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0); + if (!$result) return $null; + } +} + +%typemap(directorin, descriptor="Ljava/lang/String;", noblock=1) char * { + $input = 0; + if ($1) { + $input = JCALL1(NewStringUTF, jenv, (const char *)$1); + if (!$input) return $null; + } +} + +%typemap(freearg, noblock=1) char * { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)$1); } +%typemap(out, noblock=1) char * { if($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); } +%typemap(javadirectorin) char * "$jniinput" +%typemap(javadirectorout) char * "$javacall" + +%typemap(out) void "" +%typemap(javadirectorin) void "$jniinput" +%typemap(javadirectorout) void "$javacall" +%typemap(directorin, descriptor="V") void "" + +/* primitive types by reference */ +%typemap(in) const bool & ($*1_ltype temp) +%{ temp = $input ? true : false; + $1 = &temp; %} + +%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const bool & +%{ static $*1_ltype temp; + temp = $input ? true : false; + $result = &temp; %} + +%typemap(javadirectorin) const bool & "$jniinput" +%typemap(javadirectorout) const bool & "$javacall" + +%typemap(in) const char & ($*1_ltype temp), + const signed char & ($*1_ltype temp), + const unsigned char & ($*1_ltype temp), + const short & ($*1_ltype temp), + const unsigned short & ($*1_ltype temp), + const int & ($*1_ltype temp), + const unsigned int & ($*1_ltype temp), + const long & ($*1_ltype temp), + const unsigned long & ($*1_ltype temp), + const long long & ($*1_ltype temp), + const float & ($*1_ltype temp), + const double & ($*1_ltype temp) +%{ temp = ($*1_ltype)$input; + $1 = &temp; %} + +%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const char &, + const signed char &, + const unsigned char &, + const short &, + const unsigned short &, + const int &, + const unsigned int &, + const long &, + const unsigned long &, + const long long &, + const float &, + const double & +%{ static $*1_ltype temp; + temp = ($*1_ltype)$input; + $result = &temp; %} + +%typemap(directorin, descriptor="Z") const bool & "$input = (jboolean)$1_name;" +%typemap(directorin, descriptor="C") const char & "$input = (jchar)$1_name;" +%typemap(directorin, descriptor="B") const signed char & "$input = (jbyte)$1_name;" +%typemap(directorin, descriptor="S") const unsigned char & "$input = (jshort)$1_name;" +%typemap(directorin, descriptor="S") const short & "$input = (jshort)$1_name;" +%typemap(directorin, descriptor="I") const unsigned short & "$input = (jint)$1_name;" +%typemap(directorin, descriptor="I") const int & "$input = (jint)$1_name;" +%typemap(directorin, descriptor="J") const unsigned int & "$input = (jlong)$1_name;" +%typemap(directorin, descriptor="I") const long & "$input = (jint)$1_name;" +%typemap(directorin, descriptor="J") const unsigned long & "$input = (jlong)$1_name;" +%typemap(directorin, descriptor="J") const long long & "$input = (jlong)$1_name;" +%typemap(directorin, descriptor="F") const float & "$input = (jfloat)$1_name;" +%typemap(directorin, descriptor="D") const double & "$input = (jdouble)$1_name;" + +%typemap(javadirectorin) const char & ($*1_ltype temp), + const signed char & ($*1_ltype temp), + const unsigned char & ($*1_ltype temp), + const short & ($*1_ltype temp), + const unsigned short & ($*1_ltype temp), + const int & ($*1_ltype temp), + const unsigned int & ($*1_ltype temp), + const long & ($*1_ltype temp), + const unsigned long & ($*1_ltype temp), + const long long & ($*1_ltype temp), + const float & ($*1_ltype temp), + const double & ($*1_ltype temp) + "$jniinput" + +%typemap(javadirectorout) const char & ($*1_ltype temp), + const signed char & ($*1_ltype temp), + const unsigned char & ($*1_ltype temp), + const short & ($*1_ltype temp), + const unsigned short & ($*1_ltype temp), + const int & ($*1_ltype temp), + const unsigned int & ($*1_ltype temp), + const long & ($*1_ltype temp), + const unsigned long & ($*1_ltype temp), + const long long & ($*1_ltype temp), + const float & ($*1_ltype temp), + const double & ($*1_ltype temp) + "$javacall" + + +%typemap(out) const bool & %{ $result = (jboolean)*$1; %} +%typemap(out) const char & %{ $result = (jchar)*$1; %} +%typemap(out) const signed char & %{ $result = (jbyte)*$1; %} +%typemap(out) const unsigned char & %{ $result = (jshort)*$1; %} +%typemap(out) const short & %{ $result = (jshort)*$1; %} +%typemap(out) const unsigned short & %{ $result = (jint)*$1; %} +%typemap(out) const int & %{ $result = (jint)*$1; %} +%typemap(out) const unsigned int & %{ $result = (jlong)*$1; %} +%typemap(out) const long & %{ $result = (jint)*$1; %} +%typemap(out) const unsigned long & %{ $result = (jlong)*$1; %} +%typemap(out) const long long & %{ $result = (jlong)*$1; %} +%typemap(out) const float & %{ $result = (jfloat)*$1; %} +%typemap(out) const double & %{ $result = (jdouble)*$1; %} + +/* const unsigned long long & */ +/* Similar to unsigned long long */ +%typemap(in) const unsigned long long & ($*1_ltype temp) { + jclass clazz; + jmethodID mid; + jbyteArray ba; + jbyte* bae; + jsize sz; + int i; + + if (!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null"); + return $null; + } + clazz = JCALL1(GetObjectClass, jenv, $input); + mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B"); + ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid); + bae = JCALL2(GetByteArrayElements, jenv, ba, 0); + sz = JCALL1(GetArrayLength, jenv, ba); + $1 = &temp; + temp = 0; + for(i=0; i<sz; i++) { + temp = (temp << 8) | ($*1_ltype)(unsigned char)bae[i]; + } + JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); +} + +%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const unsigned long long & { + static $*1_ltype temp; + jclass clazz; + jmethodID mid; + jbyteArray ba; + jbyte* bae; + jsize sz; + int i; + + if (!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null"); + return $null; + } + clazz = JCALL1(GetObjectClass, jenv, $input); + mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B"); + ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid); + bae = JCALL2(GetByteArrayElements, jenv, ba, 0); + sz = JCALL1(GetArrayLength, jenv, ba); + $result = &temp; + temp = 0; + for(i=0; i<sz; i++) { + temp = (temp << 8) | ($*1_ltype)(unsigned char)bae[i]; + } + JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); +} + +%typemap(out) const unsigned long long & { + jbyteArray ba = JCALL1(NewByteArray, jenv, 9); + jbyte* bae = JCALL2(GetByteArrayElements, jenv, ba, 0); + jclass clazz = JCALL1(FindClass, jenv, "java/math/BigInteger"); + jmethodID mid = JCALL3(GetMethodID, jenv, clazz, "<init>", "([B)V"); + jobject bigint; + int i; + + bae[0] = 0; + for(i=1; i<9; i++ ) { + bae[i] = (jbyte)(*$1>>8*(8-i)); + } + + JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); + bigint = JCALL3(NewObject, jenv, clazz, mid, ba); + $result = bigint; +} + +%typemap(javadirectorin) const unsigned long long & "$jniinput" +%typemap(javadirectorout) const unsigned long long & "$javacall" + +/* Default handling. Object passed by value. Convert to a pointer */ +%typemap(in) SWIGTYPE ($&1_type argp) +%{ argp = *($&1_ltype*)&$input; + if (!argp) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type"); + return $null; + } + $1 = *argp; %} + +%typemap(directorout) SWIGTYPE ($&1_type argp) +%{ argp = *($&1_ltype*)&$input; + if (!argp) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Unexpected null return for type $1_type"); + return $null; + } + $result = *argp; %} + +%typemap(out) SWIGTYPE +#ifdef __cplusplus +%{ *($&1_ltype*)&$result = new $1_ltype(($1_ltype &)$1); %} +#else +{ + $&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype)); + memmove($1ptr, &$1, sizeof($1_type)); + *($&1_ltype*)&$result = $1ptr; +} +#endif + +%typemap(directorin,descriptor="L$packagepath/$&javaclassname;") SWIGTYPE +%{ $input = 0; + *(($&1_ltype*)&$input) = &$1; %} +%typemap(javadirectorin) SWIGTYPE "new $&javaclassname($jniinput, false)" +%typemap(javadirectorout) SWIGTYPE "$&javaclassname.getCPtr($javacall)" + +/* Generic pointers and references */ +%typemap(in) SWIGTYPE *, SWIGTYPE (CLASS::*) %{ $1 = *($&1_ltype)&$input; %} +%typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input; + if(!$1) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); + return $null; + } %} +%typemap(out) SWIGTYPE *, SWIGTYPE (CLASS::*) +%{ *($&1_ltype)&$result = $1; %} +%typemap(out) SWIGTYPE & +%{ *($&1_ltype)&$result = $1; %} + +%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *, SWIGTYPE (CLASS::*) +%{ $result = *($&1_ltype)&$input; %} +%typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE *, SWIGTYPE (CLASS::*) +%{ *(($&1_ltype)&$input) = ($1_ltype) $1; %} + +%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE & +%{ if (!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Unexpected null return for type $1_type"); + return $null; + } + $result = *($&1_ltype)&$input; %} +%typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE & +%{ *($&1_ltype)&$input = ($1_ltype) &$1; %} + +%typemap(javadirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "new $javaclassname($jniinput, false)" +%typemap(javadirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "$javaclassname.getCPtr($javacall)" + +/* Default array handling */ +%typemap(in) SWIGTYPE [] %{ $1 = *($&1_ltype)&$input; %} +%typemap(out) SWIGTYPE [] %{ *($&1_ltype)&$result = $1; %} +%typemap(freearg) SWIGTYPE [ANY], SWIGTYPE [] "" + +/* char arrays - treat as String */ +%typemap(in, noblock=1) char[ANY], char[] { + $1 = 0; + if ($input) { + $1 = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0); + if (!$1) return $null; + } +} + +%typemap(directorout, noblock=1) char[ANY], char[] { + $1 = 0; + if ($input) { + $result = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0); + if (!$result) return $null; + } +} + +%typemap(directorin, descriptor="Ljava/lang/String;", noblock=1) char[ANY], char[] { + $input = 0; + if ($1) { + $input = JCALL1(NewStringUTF, jenv, (const char *)$1); + if (!$input) return $null; + } +} + +%typemap(argout) char[ANY], char[] "" +%typemap(freearg, noblock=1) char[ANY], char[] { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)$1); } +%typemap(out, noblock=1) char[ANY], char[] { if($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); } +%typemap(javadirectorin) char[ANY], char[] "$jniinput" +%typemap(javadirectorout) char[ANY], char[] "$javacall" + +/* JNI types */ +%typemap(in) jboolean, + jchar, + jbyte, + jshort, + jint, + jlong, + jfloat, + jdouble, + jstring, + jobject, + jbooleanArray, + jcharArray, + jbyteArray, + jshortArray, + jintArray, + jlongArray, + jfloatArray, + jdoubleArray, + jobjectArray +%{ $1 = $input; %} + +%typemap(directorout) jboolean, + jchar, + jbyte, + jshort, + jint, + jlong, + jfloat, + jdouble, + jstring, + jobject, + jbooleanArray, + jcharArray, + jbyteArray, + jshortArray, + jintArray, + jlongArray, + jfloatArray, + jdoubleArray, + jobjectArray +%{ $result = $input; %} + +%typemap(out) jboolean, + jchar, + jbyte, + jshort, + jint, + jlong, + jfloat, + jdouble, + jstring, + jobject, + jbooleanArray, + jcharArray, + jbyteArray, + jshortArray, + jintArray, + jlongArray, + jfloatArray, + jdoubleArray, + jobjectArray +%{ $result = $1; %} + +%typemap(directorin,descriptor="Z") jboolean "$input = $1;" +%typemap(directorin,descriptor="C") jchar "$input = $1;" +%typemap(directorin,descriptor="B") jbyte "$input = $1;" +%typemap(directorin,descriptor="S") jshort "$input = $1;" +%typemap(directorin,descriptor="I") jint "$input = $1;" +%typemap(directorin,descriptor="J") jlong "$input = $1;" +%typemap(directorin,descriptor="F") jfloat "$input = $1;" +%typemap(directorin,descriptor="D") jdouble "$input = $1;" +%typemap(directorin,descriptor="Ljava/lang/String;") jstring "$input = $1;" +%typemap(directorin,descriptor="Ljava/lang/Object;",nouse="1") jobject "$input = $1;" +%typemap(directorin,descriptor="[Z") jbooleanArray "$input = $1;" +%typemap(directorin,descriptor="[C") jcharArray "$input = $1;" +%typemap(directorin,descriptor="[B") jbyteArray "$input = $1;" +%typemap(directorin,descriptor="[S") jshortArray "$input = $1;" +%typemap(directorin,descriptor="[I") jintArray "$input = $1;" +%typemap(directorin,descriptor="[J") jlongArray "$input = $1;" +%typemap(directorin,descriptor="[F") jfloatArray "$input = $1;" +%typemap(directorin,descriptor="[D") jdoubleArray "$input = $1;" +%typemap(directorin,descriptor="[Ljava/lang/Object;",nouse="1") jobjectArray "$input = $1;" + +%typemap(javadirectorin) jboolean, + jchar, + jbyte, + jshort, + jint, + jlong, + jfloat, + jdouble, + jstring, + jobject, + jbooleanArray, + jcharArray, + jbyteArray, + jshortArray, + jintArray, + jlongArray, + jfloatArray, + jdoubleArray, + jobjectArray + "$jniinput" + +%typemap(javadirectorout) jboolean, + jchar, + jbyte, + jshort, + jint, + jlong, + jfloat, + jdouble, + jstring, + jobject, + jbooleanArray, + jcharArray, + jbyteArray, + jshortArray, + jintArray, + jlongArray, + jfloatArray, + jdoubleArray, + jobjectArray + "$javacall" + +/* Typecheck typemaps - The purpose of these is merely to issue a warning for overloaded C++ functions + * that cannot be overloaded in Java as more than one C++ type maps to a single Java type */ + +%typecheck(SWIG_TYPECHECK_BOOL) /* Java boolean */ + jboolean, + bool, + const bool & + "" + +%typecheck(SWIG_TYPECHECK_CHAR) /* Java char */ + jchar, + char, + const char & + "" + +%typecheck(SWIG_TYPECHECK_INT8) /* Java byte */ + jbyte, + signed char, + const signed char & + "" + +%typecheck(SWIG_TYPECHECK_INT16) /* Java short */ + jshort, + unsigned char, + short, + const unsigned char &, + const short & + "" + +%typecheck(SWIG_TYPECHECK_INT32) /* Java int */ + jint, + unsigned short, + int, + long, + const unsigned short &, + const int &, + const long & + "" + +%typecheck(SWIG_TYPECHECK_INT64) /* Java long */ + jlong, + unsigned int, + unsigned long, + long long, + const unsigned int &, + const unsigned long &, + const long long & + "" + +%typecheck(SWIG_TYPECHECK_INT128) /* Java BigInteger */ + unsigned long long, + const unsigned long long & + "" + +%typecheck(SWIG_TYPECHECK_FLOAT) /* Java float */ + jfloat, + float, + const float & + "" + +%typecheck(SWIG_TYPECHECK_DOUBLE) /* Java double */ + jdouble, + double, + const double & + "" + +%typecheck(SWIG_TYPECHECK_STRING) /* Java String */ + jstring, + char *, + char[ANY], + char [] + "" + +%typecheck(SWIG_TYPECHECK_BOOL_ARRAY) /* Java boolean[] */ + jbooleanArray + "" + +%typecheck(SWIG_TYPECHECK_CHAR_ARRAY) /* Java char[] */ + jcharArray + "" + +%typecheck(SWIG_TYPECHECK_INT8_ARRAY) /* Java byte[] */ + jbyteArray + "" + +%typecheck(SWIG_TYPECHECK_INT16_ARRAY) /* Java short[] */ + jshortArray + "" + +%typecheck(SWIG_TYPECHECK_INT32_ARRAY) /* Java int[] */ + jintArray + "" + +%typecheck(SWIG_TYPECHECK_INT64_ARRAY) /* Java long[] */ + jlongArray + "" + +%typecheck(SWIG_TYPECHECK_FLOAT_ARRAY) /* Java float[] */ + jfloatArray + "" + +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY) /* Java double[] */ + jdoubleArray + "" + +%typecheck(SWIG_TYPECHECK_OBJECT_ARRAY) /* Java jobject[] */ + jobjectArray + "" + +%typecheck(SWIG_TYPECHECK_POINTER) /* Default */ + SWIGTYPE, + SWIGTYPE *, + SWIGTYPE &, + SWIGTYPE [], + SWIGTYPE (CLASS::*) + "" + + +/* Exception handling */ + +%typemap(throws) int, + long, + short, + unsigned int, + unsigned long, + unsigned short +%{ char error_msg[256]; + sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1); + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, error_msg); + return $null; %} + +%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] +%{ (void)$1; + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); + return $null; %} + +%typemap(throws) char * +%{ SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1); + return $null; %} + + +/* Typemaps for code generation in proxy classes and Java type wrapper classes */ + +/* The javain typemap is used for converting function parameter types from the type + * used in the proxy, module or type wrapper class to the type used in the JNI class. */ +%typemap(javain) bool, const bool &, + char, const char &, + signed char, const signed char &, + unsigned char, const unsigned char &, + short, const short &, + unsigned short, const unsigned short &, + int, const int &, + unsigned int, const unsigned int &, + long, const long &, + unsigned long, const unsigned long &, + long long, const long long &, + unsigned long long, const unsigned long long &, + float, const float &, + double, const double & + "$javainput" +%typemap(javain) char *, char[ANY], char[] "$javainput" +%typemap(javain) jboolean, + jchar, + jbyte, + jshort, + jint, + jlong, + jfloat, + jdouble, + jstring, + jobject, + jbooleanArray, + jcharArray, + jbyteArray, + jshortArray, + jintArray, + jlongArray, + jfloatArray, + jdoubleArray, + jobjectArray + "$javainput" +%typemap(javain) SWIGTYPE "$&javaclassname.getCPtr($javainput)" +%typemap(javain) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "$javaclassname.getCPtr($javainput)" + +/* The javaout typemap is used for converting function return types from the return type + * used in the JNI class to the type returned by the proxy, module or type wrapper class. */ +%typemap(javaout) bool, const bool &, + char, const char &, + signed char, const signed char &, + unsigned char, const unsigned char &, + short, const short &, + unsigned short, const unsigned short &, + int, const int &, + unsigned int, const unsigned int &, + long, const long &, + unsigned long, const unsigned long &, + long long, const long long &, + unsigned long long, const unsigned long long &, + float, const float &, + double, const double & { + return $jnicall; + } +%typemap(javaout) char *, char[ANY], char[] { + return $jnicall; + } +%typemap(javaout) jboolean, + jchar, + jbyte, + jshort, + jint, + jlong, + jfloat, + jdouble, + jstring, + jobject, + jbooleanArray, + jcharArray, + jbyteArray, + jshortArray, + jintArray, + jlongArray, + jfloatArray, + jdoubleArray, + jobjectArray { + return $jnicall; + } +%typemap(javaout) void { + $jnicall; + } +%typemap(javaout) SWIGTYPE { + return new $&javaclassname($jnicall, true); + } +%typemap(javaout) SWIGTYPE & { + return new $javaclassname($jnicall, $owner); + } +%typemap(javaout) SWIGTYPE *, SWIGTYPE [], SWIGTYPE (CLASS::*) { + long cPtr = $jnicall; + return (cPtr == 0) ? null : new $javaclassname(cPtr, $owner); + } + +/* Pointer reference typemaps */ +%typemap(jni) SWIGTYPE *& "jlong" +%typemap(jtype) SWIGTYPE *& "long" +%typemap(jstype) SWIGTYPE *& "$*javaclassname" +%typemap(javain) SWIGTYPE *& "$*javaclassname.getCPtr($javainput)" +%typemap(javaout) SWIGTYPE *& { + long cPtr = $jnicall; + return (cPtr == 0) ? null : new $*javaclassname(cPtr, $owner); + } +%typemap(in) SWIGTYPE *& ($*1_ltype temp = 0) +%{ temp = *($1_ltype)&$input; + $1 = &temp; %} +%typemap(out) SWIGTYPE *& +%{ *($1_ltype)&$result = *$1; %} + +/* Array reference typemaps */ +%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } + +/* Typemaps used for the generation of proxy and type wrapper class code */ +%typemap(javabase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" +%typemap(javaclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class" +%typemap(javacode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" +%typemap(javaimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" +%typemap(javainterfaces) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" + +/* javabody typemaps */ + +%define SWIG_JAVABODY_METHODS(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPENAME...) +// Base proxy classes +%typemap(javabody) TYPENAME %{ + private long swigCPtr; + protected boolean swigCMemOwn; + + PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = cPtr; + } + + CPTR_VISIBILITY static long getCPtr($javaclassname obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } +%} + +// Derived proxy classes +%typemap(javabody_derived) TYPENAME %{ + private long swigCPtr; + + PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { + super($imclassname.SWIG$javaclassnameUpcast(cPtr), cMemoryOwn); + swigCPtr = cPtr; + } + + CPTR_VISIBILITY static long getCPtr($javaclassname obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } +%} +%enddef + +/* Set the default for SWIGTYPE: pointer constructor is protected, + getCPtr is protected. Season to your own taste! */ + +SWIG_JAVABODY_METHODS(protected, protected, SWIGTYPE) + +// Typewrapper classes +%typemap(javabody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{ + private long swigCPtr; + + protected $javaclassname(long cPtr, boolean futureUse) { + swigCPtr = cPtr; + } + + protected $javaclassname() { + swigCPtr = 0; + } + + protected static long getCPtr($javaclassname obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } +%} + +%typemap(javafinalize) SWIGTYPE %{ + protected void finalize() { + delete(); + } +%} + +/* + * Java constructor typemaps: + * + * The javaconstruct typemap is inserted when a proxy class's constructor is generated. + * This typemap allows control over what code is executed in the constructor as + * well as specifying who owns the underlying C/C++ object. Normally, Java has + * ownership and the underlying C/C++ object is deallocated when the Java object + * is finalized (swigCMemOwn is true.) If swigCMemOwn is false, C/C++ is + * ultimately responsible for deallocating the underlying object's memory. + * + * The SWIG_PROXY_CONSTRUCTOR macro defines the javaconstruct typemap for a proxy + * class for a particular TYPENAME. OWNERSHIP is passed as the value of + * swigCMemOwn to the pointer constructor method. WEAKREF determines which kind + * of Java object reference will be used by the C++ director class (WeakGlobalRef + * vs. GlobalRef.) + * + * The SWIG_DIRECTOR_OWNED macro sets the ownership of director-based proxy + * classes and the weak reference flag to false, meaning that the underlying C++ + * object will be reclaimed by C++. + */ + +%define SWIG_PROXY_CONSTRUCTOR(OWNERSHIP, WEAKREF, TYPENAME...) +%typemap(javaconstruct,directorconnect="\n $imclassname.$javaclassname_director_connect(this, swigCPtr, swigCMemOwn, WEAKREF);") TYPENAME { + this($imcall, OWNERSHIP);$directorconnect + } +%enddef + +%define SWIG_DIRECTOR_OWNED(TYPENAME...) +SWIG_PROXY_CONSTRUCTOR(true, false, TYPENAME) +%enddef + +// Set the default for SWIGTYPE: Java owns the C/C++ object. +SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE) + +%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") SWIGTYPE { + if(swigCPtr != 0 && swigCMemOwn) { + swigCMemOwn = false; + $jnicall; + } + swigCPtr = 0; + } + +%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") SWIGTYPE { + if(swigCPtr != 0 && swigCMemOwn) { + swigCMemOwn = false; + $jnicall; + } + swigCPtr = 0; + super.delete(); + } + +%typemap(directordisconnect, methodname="swigDirectorDisconnect") SWIGTYPE %{ + protected void $methodname() { + swigCMemOwn = false; + $jnicall; + } +%} + +%typemap(directorowner_release, methodname="swigReleaseOwnership") SWIGTYPE %{ + public void $methodname() { + swigCMemOwn = false; + $jnicall; + } +%} + +%typemap(directorowner_take, methodname="swigTakeOwnership") SWIGTYPE %{ + public void $methodname() { + swigCMemOwn = true; + $jnicall; + } +%} + +/* Java specific directives */ +#define %javaconst(flag) %feature("java:const","flag") +#define %javaconstvalue(value) %feature("java:constvalue",value) +#define %javaenum(wrapapproach) %feature("java:enum","wrapapproach") +#define %javamethodmodifiers %feature("java:methodmodifiers") +#define %javaexception(exceptionclasses) %feature("except",throws=exceptionclasses) +#define %nojavaexception %feature("except","",throws="") + +%pragma(java) jniclassclassmodifiers="class" +%pragma(java) moduleclassmodifiers="public class" + +/* Some ANSI C typemaps */ + +%apply unsigned long { size_t }; +%apply const unsigned long & { const size_t & }; + +/* java keywords */ +%include <javakw.swg> + +// Default enum handling +%include <enumtypesafe.swg> + diff --git a/devtools/swigwin-1.3.34/Lib/java/javahead.swg b/devtools/swigwin-1.3.34/Lib/java/javahead.swg new file mode 100644 index 0000000..4aa0c84 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/java/javahead.swg @@ -0,0 +1,103 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * javahead.swg + * + * Java support code + * ----------------------------------------------------------------------------- */ + + +/* JNI function calls require different calling conventions for C and C++. These JCALL macros are used so + * that the same typemaps can be used for generating code for both C and C++. The SWIG preprocessor can expand + * the macros thereby generating the correct calling convention. It is thus essential that all typemaps that + * use the macros are not within %{ %} brackets as they won't be run through the SWIG preprocessor. */ +#ifdef __cplusplus +# define JCALL0(func, jenv) jenv->func() +# define JCALL1(func, jenv, ar1) jenv->func(ar1) +# define JCALL2(func, jenv, ar1, ar2) jenv->func(ar1, ar2) +# define JCALL3(func, jenv, ar1, ar2, ar3) jenv->func(ar1, ar2, ar3) +# define JCALL4(func, jenv, ar1, ar2, ar3, ar4) jenv->func(ar1, ar2, ar3, ar4) +# define JCALL5(func, jenv, ar1, ar2, ar3, ar4, ar5) jenv->func(ar1, ar2, ar3, ar4, ar5) +# define JCALL6(func, jenv, ar1, ar2, ar3, ar4, ar5, ar6) jenv->func(ar1, ar2, ar3, ar4, ar5, ar6) +# define JCALL7(func, jenv, ar1, ar2, ar3, ar4, ar5, ar6, ar7) jenv->func(ar1, ar2, ar3, ar4, ar5, ar6, ar7) +#else +# define JCALL0(func, jenv) (*jenv)->func(jenv) +# define JCALL1(func, jenv, ar1) (*jenv)->func(jenv, ar1) +# define JCALL2(func, jenv, ar1, ar2) (*jenv)->func(jenv, ar1, ar2) +# define JCALL3(func, jenv, ar1, ar2, ar3) (*jenv)->func(jenv, ar1, ar2, ar3) +# define JCALL4(func, jenv, ar1, ar2, ar3, ar4) (*jenv)->func(jenv, ar1, ar2, ar3, ar4) +# define JCALL5(func, jenv, ar1, ar2, ar3, ar4, ar5) (*jenv)->func(jenv, ar1, ar2, ar3, ar4, ar5) +# define JCALL6(func, jenv, ar1, ar2, ar3, ar4, ar5, ar6) (*jenv)->func(jenv, ar1, ar2, ar3, ar4, ar5, ar6) +# define JCALL7(func, jenv, ar1, ar2, ar3, ar4, ar5, ar6, ar7) (*jenv)->func(jenv, ar1, ar2, ar3, ar4, ar5, ar6, ar7) +#endif + +%insert(runtime) %{ +/* Fix for jlong on some versions of gcc on Windows */ +#if defined(__GNUC__) && !defined(__INTELC__) + typedef long long __int64; +#endif + +/* Fix for jlong on 64-bit x86 Solaris */ +#if defined(__x86_64) +# ifdef _LP64 +# undef _LP64 +# endif +#endif + +#include <jni.h> +#include <stdlib.h> +#include <string.h> +%} + +%insert(runtime) %{ +/* Support for throwing Java exceptions */ +typedef enum { + SWIG_JavaOutOfMemoryError = 1, + SWIG_JavaIOException, + SWIG_JavaRuntimeException, + SWIG_JavaIndexOutOfBoundsException, + SWIG_JavaArithmeticException, + SWIG_JavaIllegalArgumentException, + SWIG_JavaNullPointerException, + SWIG_JavaDirectorPureVirtual, + SWIG_JavaUnknownError +} SWIG_JavaExceptionCodes; + +typedef struct { + SWIG_JavaExceptionCodes code; + const char *java_exception; +} SWIG_JavaExceptions_t; +%} + +%insert(runtime) { +static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) { + jclass excep; + static const SWIG_JavaExceptions_t java_exceptions[] = { + { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" }, + { SWIG_JavaIOException, "java/io/IOException" }, + { SWIG_JavaRuntimeException, "java/lang/RuntimeException" }, + { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" }, + { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" }, + { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" }, + { SWIG_JavaNullPointerException, "java/lang/NullPointerException" }, + { SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" }, + { SWIG_JavaUnknownError, "java/lang/UnknownError" }, + { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" } }; + const SWIG_JavaExceptions_t *except_ptr = java_exceptions; + + while (except_ptr->code != code && except_ptr->code) + except_ptr++; + + JCALL0(ExceptionClear, jenv); + excep = JCALL1(FindClass, jenv, except_ptr->java_exception); + if (excep) + JCALL2(ThrowNew, jenv, excep, msg); +} +} + +%insert(runtime) %{ +/* Contract support */ + +#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, msg); return nullreturn; } else +%} diff --git a/devtools/swigwin-1.3.34/Lib/java/javakw.swg b/devtools/swigwin-1.3.34/Lib/java/javakw.swg new file mode 100644 index 0000000..9dcd970 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/java/javakw.swg @@ -0,0 +1,70 @@ +#ifndef JAVA_JAVAKW_SWG_ +#define JAVA_JAVAKW_SWG_ + +/* Warnings for Java keywords */ +#define JAVAKW(x) %namewarn("314:" #x " is a java keyword") #x + +/* + from + http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html +*/ + +JAVAKW(abstract); +JAVAKW(double); +JAVAKW(int); +JAVAKW(strictfp); +JAVAKW(boolean); +JAVAKW(else); +JAVAKW(interface); +JAVAKW(super); +JAVAKW(break); +JAVAKW(extends); +JAVAKW(long); +JAVAKW(switch); +JAVAKW(byte); +JAVAKW(final); +JAVAKW(native); +JAVAKW(synchronized); +JAVAKW(case); +JAVAKW(finally); +JAVAKW(new); +JAVAKW(this); +JAVAKW(catch); +JAVAKW(float); +JAVAKW(package); +JAVAKW(throw); +JAVAKW(char); +JAVAKW(for); +JAVAKW(private); +JAVAKW(throws); +JAVAKW(class); +JAVAKW(goto); +JAVAKW(protected); +JAVAKW(transient); +JAVAKW(const); +JAVAKW(if); +JAVAKW(public); +JAVAKW(try); +JAVAKW(continue); +JAVAKW(implements); +JAVAKW(return); +JAVAKW(void); +JAVAKW(default); +JAVAKW(import); +JAVAKW(short); +JAVAKW(volatile); +JAVAKW(do); +JAVAKW(instanceof); +JAVAKW(static); +JAVAKW(while); + + +/* others bad names */ + +/* Note here that only *::clone() is bad, and *::clone(int) is ok */ +%namewarn("321:clone() is a java bad method name") *::clone(); + + +#undef JAVAKW + +#endif //JAVA_JAVAKW_SWG_ diff --git a/devtools/swigwin-1.3.34/Lib/java/std_common.i b/devtools/swigwin-1.3.34/Lib/java/std_common.i new file mode 100644 index 0000000..cee11e8 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/java/std_common.i @@ -0,0 +1,5 @@ +%include <std_except.i> + +%apply size_t { std::size_t }; +%apply const size_t& { const std::size_t& }; + diff --git a/devtools/swigwin-1.3.34/Lib/java/std_deque.i b/devtools/swigwin-1.3.34/Lib/java/std_deque.i new file mode 100644 index 0000000..cb98f6c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/java/std_deque.i @@ -0,0 +1 @@ +%include <std/_std_deque.i> diff --git a/devtools/swigwin-1.3.34/Lib/java/std_except.i b/devtools/swigwin-1.3.34/Lib/java/std_except.i new file mode 100644 index 0000000..15be1de --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/java/std_except.i @@ -0,0 +1,33 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_except.i + * + * Typemaps used by the STL wrappers that throw exceptions. + * These typemaps are used when methods are declared with an STL exception specification, such as + * size_t at() const throw (std::out_of_range); + * ----------------------------------------------------------------------------- */ + +%{ +#include <stdexcept> +%} + +namespace std +{ + %ignore exception; + struct exception {}; +} + +%typemap(throws) std::bad_exception "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;" +%typemap(throws) std::domain_error "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;" +%typemap(throws) std::exception "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;" +%typemap(throws) std::invalid_argument "SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, $1.what());\n return $null;" +%typemap(throws) std::length_error "SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, $1.what());\n return $null;" +%typemap(throws) std::logic_error "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;" +%typemap(throws) std::out_of_range "SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, $1.what());\n return $null;" +%typemap(throws) std::overflow_error "SWIG_JavaThrowException(jenv, SWIG_JavaArithmeticException, $1.what());\n return $null;" +%typemap(throws) std::range_error "SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, $1.what());\n return $null;" +%typemap(throws) std::runtime_error "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;" +%typemap(throws) std::underflow_error "SWIG_JavaThrowException(jenv, SWIG_JavaArithmeticException, $1.what());\n return $null;" + diff --git a/devtools/swigwin-1.3.34/Lib/java/std_map.i b/devtools/swigwin-1.3.34/Lib/java/std_map.i new file mode 100644 index 0000000..00967d3 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/java/std_map.i @@ -0,0 +1,179 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_map.i + * + * SWIG typemaps for std::map + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +// ------------------------------------------------------------------------ +// std::map +// ------------------------------------------------------------------------ + +%{ +#include <map> +#include <algorithm> +#include <stdexcept> +%} + +// exported class + +namespace std { + + template<class K, class T> class map { + // add typemaps here + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef K key_type; + typedef T mapped_type; + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + const T& get(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(const K& key, const T& x) { + (*self)[key] = x; + } + void del(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + + + // specializations for built-ins + + %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) + + template<class T> class map<K,T> { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T& get(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(K key, const T& x) { + (*self)[key] = x; + } + void del(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(K key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + %enddef + + %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) + template<class K> class map<K,T> { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T get(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(const K& key, T x) { + (*self)[key] = x; + } + void del(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + %enddef + + %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, + T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) + template<> class map<K,T> { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T get(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(K key, T x) { + (*self)[key] = x; + } + void del(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(K key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + %enddef + + // add specializations here + +} diff --git a/devtools/swigwin-1.3.34/Lib/java/std_pair.i b/devtools/swigwin-1.3.34/Lib/java/std_pair.i new file mode 100644 index 0000000..dc0604d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/java/std_pair.i @@ -0,0 +1,37 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_pair.i + * + * SWIG typemaps for std::pair + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <exception.i> + +// ------------------------------------------------------------------------ +// std::pair +// ------------------------------------------------------------------------ + +%{ +#include <utility> +%} + +namespace std { + + template<class T, class U> struct pair { + + pair(); + pair(T first, U second); + pair(const pair& p); + + template <class U1, class U2> pair(const pair<U1, U2> &p); + + T first; + U second; + }; + + // add specializations here + +} diff --git a/devtools/swigwin-1.3.34/Lib/java/std_string.i b/devtools/swigwin-1.3.34/Lib/java/std_string.i new file mode 100644 index 0000000..789e17a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/java/std_string.i @@ -0,0 +1,120 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_string.i + * + * Typemaps for std::string and const std::string& + * These are mapped to a Java String and are passed around by value. + * + * To use non-const std::string references use the following %apply. Note + * that they are passed by value. + * %apply const std::string & {std::string &}; + * ----------------------------------------------------------------------------- */ + +%{ +#include <string> +%} + +namespace std { + +%naturalvar string; + +class string; + +// string +%typemap(jni) string "jstring" +%typemap(jtype) string "String" +%typemap(jstype) string "String" +%typemap(javadirectorin) string "$jniinput" +%typemap(javadirectorout) string "$javacall" + +%typemap(in) string +%{ if(!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string"); + return $null; + } + const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0); + if (!$1_pstr) return $null; + $1.assign($1_pstr); + jenv->ReleaseStringUTFChars($input, $1_pstr); %} + +%typemap(directorout) string +%{ if(!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string"); + return $null; + } + const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0); + if (!$1_pstr) return $null; + $result.assign($1_pstr); + jenv->ReleaseStringUTFChars($input, $1_pstr); %} + +%typemap(directorin,descriptor="Ljava/lang/String;") string +%{ $input = jenv->NewStringUTF($1.c_str()); %} + +%typemap(out) string +%{ $result = jenv->NewStringUTF($1.c_str()); %} + +%typemap(javain) string "$javainput" + +%typemap(javaout) string { + return $jnicall; + } + +%typemap(typecheck) string = char *; + +%typemap(throws) string +%{ SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.c_str()); + return $null; %} + +// const string & +%typemap(jni) const string & "jstring" +%typemap(jtype) const string & "String" +%typemap(jstype) const string & "String" +%typemap(javadirectorin) const string & "$jniinput" +%typemap(javadirectorout) const string & "$javacall" + +%typemap(in) const string & +%{ if(!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string"); + return $null; + } + const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0); + if (!$1_pstr) return $null; + std::string $1_str($1_pstr); + $1 = &$1_str; + jenv->ReleaseStringUTFChars($input, $1_pstr); %} + +%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string & +%{ if(!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string"); + return $null; + } + const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0); + if (!$1_pstr) return $null; + /* possible thread/reentrant code problem */ + static std::string $1_str; + $1_str = $1_pstr; + $result = &$1_str; + jenv->ReleaseStringUTFChars($input, $1_pstr); %} + +%typemap(directorin,descriptor="Ljava/lang/String;") const string & +%{ $input = jenv->NewStringUTF($1.c_str()); %} + +%typemap(out) const string & +%{ $result = jenv->NewStringUTF($1->c_str()); %} + +%typemap(javain) const string & "$javainput" + +%typemap(javaout) const string & { + return $jnicall; + } + +%typemap(typecheck) const string & = char *; + +%typemap(throws) const string & +%{ SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.c_str()); + return $null; %} + +} + diff --git a/devtools/swigwin-1.3.34/Lib/java/std_vector.i b/devtools/swigwin-1.3.34/Lib/java/std_vector.i new file mode 100644 index 0000000..92fa25a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/java/std_vector.i @@ -0,0 +1,54 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_vector.i + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +%{ +#include <vector> +#include <stdexcept> +%} + +namespace std { + + template<class T> class vector { + public: + typedef size_t size_type; + typedef T value_type; + typedef const value_type& const_reference; + vector(); + vector(size_type n); + size_type size() const; + size_type capacity() const; + void reserve(size_type n); + %rename(isEmpty) empty; + bool empty() const; + void clear(); + %rename(add) push_back; + void push_back(const value_type& x); + %extend { + const_reference get(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("vector index out of range"); + } + void set(int i, const value_type& val) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + (*self)[i] = val; + else + throw std::out_of_range("vector index out of range"); + } + } + }; +} + +%define specialize_std_vector(T) +#warning "specialize_std_vector - specialization for type T no longer needed" +%enddef + diff --git a/devtools/swigwin-1.3.34/Lib/java/std_wstring.i b/devtools/swigwin-1.3.34/Lib/java/std_wstring.i new file mode 100644 index 0000000..9891765 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/java/std_wstring.i @@ -0,0 +1,175 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_wstring.i + * + * Typemaps for std::wstring and const std::wstring& + * + * These are mapped to a Java String and are passed around by value. + * Warning: Unicode / multibyte characters are handled differently on different + * OSs so the std::wstring typemaps may not always work as intended. + * + * To use non-const std::wstring references use the following %apply. Note + * that they are passed by value. + * %apply const std::wstring & {std::wstring &}; + * ----------------------------------------------------------------------------- */ + +namespace std { + +%naturalvar wstring; + +class wstring; + +// wstring +%typemap(jni) wstring "jstring" +%typemap(jtype) wstring "String" +%typemap(jstype) wstring "String" +%typemap(javadirectorin) wstring "$jniinput" +%typemap(javadirectorout) wstring "$javacall" + +%typemap(in) wstring +%{if(!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::wstring"); + return $null; + } + const jchar *$1_pstr = jenv->GetStringChars($input, 0); + if (!$1_pstr) return $null; + jsize $1_len = jenv->GetStringLength($input); + if ($1_len) { + $1.reserve($1_len); + for (jsize i = 0; i < $1_len; ++i) { + $1.push_back((wchar_t)$1_pstr[i]); + } + } + jenv->ReleaseStringChars($input, $1_pstr); + %} + +%typemap(directorout) wstring +%{if(!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::wstring"); + return $null; + } + const jchar *$1_pstr = jenv->GetStringChars($input, 0); + if (!$1_pstr) return $null; + jsize $1_len = jenv->GetStringLength($input); + if ($1_len) { + $result.reserve($1_len); + for (jsize i = 0; i < $1_len; ++i) { + $result.push_back((wchar_t)$1_pstr[i]); + } + } + jenv->ReleaseStringChars($input, $1_pstr); + %} + +%typemap(directorin,descriptor="Ljava/lang/String;") wstring { + jsize $1_len = $1.length(); + jchar *conv_buf = new jchar[$1_len]; + for (jsize i = 0; i < $1_len; ++i) { + conv_buf[i] = (jchar)$1[i]; + } + $input = jenv->NewString(conv_buf, $1_len); + delete [] conv_buf; +} + +%typemap(out) wstring +%{jsize $1_len = $1.length(); + jchar *conv_buf = new jchar[$1_len]; + for (jsize i = 0; i < $1_len; ++i) { + conv_buf[i] = (jchar)$1[i]; + } + $result = jenv->NewString(conv_buf, $1_len); + delete [] conv_buf; %} + +%typemap(javain) wstring "$javainput" + +%typemap(javaout) wstring { + return $jnicall; + } + +//%typemap(typecheck) wstring = wchar_t *; + +%typemap(throws) wstring +%{ std::string message($1.begin(), $1.end()); + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, message.c_str()); + return $null; %} + +// const wstring & +%typemap(jni) const wstring & "jstring" +%typemap(jtype) const wstring & "String" +%typemap(jstype) const wstring & "String" +%typemap(javadirectorin) const wstring & "$jniinput" +%typemap(javadirectorout) const wstring & "$javacall" + +%typemap(in) const wstring & +%{if(!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::wstring"); + return $null; + } + const jchar *$1_pstr = jenv->GetStringChars($input, 0); + if (!$1_pstr) return $null; + jsize $1_len = jenv->GetStringLength($input); + std::wstring $1_str; + if ($1_len) { + $1_str.reserve($1_len); + for (jsize i = 0; i < $1_len; ++i) { + $1_str.push_back((wchar_t)$1_pstr[i]); + } + } + $1 = &$1_str; + jenv->ReleaseStringChars($input, $1_pstr); + %} + +%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const wstring & +%{if(!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::wstring"); + return $null; + } + const jchar *$1_pstr = jenv->GetStringChars($input, 0); + if (!$1_pstr) return $null; + jsize $1_len = jenv->GetStringLength($input); + /* possible thread/reentrant code problem */ + static std::wstring $1_str; + if ($1_len) { + $1_str.reserve($1_len); + for (jsize i = 0; i < $1_len; ++i) { + $1_str.push_back((wchar_t)$1_pstr[i]); + } + } + $result = &$1_str; + jenv->ReleaseStringChars($input, $1_pstr); %} + +%typemap(directorin,descriptor="Ljava/lang/String;") const wstring & { + jsize $1_len = $1.length(); + jchar *conv_buf = new jchar[$1_len]; + for (jsize i = 0; i < $1_len; ++i) { + conv_buf[i] = (jchar)($1)[i]; + } + $input = jenv->NewString(conv_buf, $1_len); + delete [] conv_buf; +} + +%typemap(out) const wstring & +%{jsize $1_len = $1->length(); + jchar *conv_buf = new jchar[$1_len]; + for (jsize i = 0; i < $1_len; ++i) { + conv_buf[i] = (jchar)(*$1)[i]; + } + $result = jenv->NewString(conv_buf, $1_len); + delete [] conv_buf; %} + +%typemap(javain) const wstring & "$javainput" + +%typemap(javaout) const wstring & { + return $jnicall; + } + +//%typemap(typecheck) const wstring & = wchar_t *; + +%typemap(throws) const wstring & +%{ std::string message($1.begin(), $1.end()); + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, message.c_str()); + return $null; %} + +} + diff --git a/devtools/swigwin-1.3.34/Lib/java/stl.i b/devtools/swigwin-1.3.34/Lib/java/stl.i new file mode 100644 index 0000000..b8d7a65 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/java/stl.i @@ -0,0 +1,13 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * stl.i + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <std_string.i> +%include <std_vector.i> +%include <std_map.i> +%include <std_pair.i> + diff --git a/devtools/swigwin-1.3.34/Lib/java/typemaps.i b/devtools/swigwin-1.3.34/Lib/java/typemaps.i new file mode 100644 index 0000000..59f7af9 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/java/typemaps.i @@ -0,0 +1,449 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * typemaps.i + * + * Pointer and reference handling typemap library + * + * These mappings provide support for input/output arguments and common + * uses for C/C++ pointers and C++ references. + * ----------------------------------------------------------------------------- */ + +/* +INPUT typemaps +-------------- + +These typemaps remap a C pointer or C++ reference to be an "INPUT" value which is +passed by value instead of reference. + +The following typemaps can be applied to turn a pointer or reference into a simple +input value. That is, instead of passing a pointer or reference to an object, +you would use a real value instead. + + bool *INPUT, bool &INPUT + signed char *INPUT, signed char &INPUT + unsigned char *INPUT, unsigned char &INPUT + short *INPUT, short &INPUT + unsigned short *INPUT, unsigned short &INPUT + int *INPUT, int &INPUT + unsigned int *INPUT, unsigned int &INPUT + long *INPUT, long &INPUT + unsigned long *INPUT, unsigned long &INPUT + long long *INPUT, long long &INPUT + unsigned long long *INPUT, unsigned long long &INPUT + float *INPUT, float &INPUT + double *INPUT, double &INPUT + +To use these, suppose you had a C function like this : + + double fadd(double *a, double *b) { + return *a+*b; + } + +You could wrap it with SWIG as follows : + + %include <typemaps.i> + double fadd(double *INPUT, double *INPUT); + +or you can use the %apply directive : + + %include <typemaps.i> + %apply double *INPUT { double *a, double *b }; + double fadd(double *a, double *b); + +In Java you could then use it like this: + double answer = modulename.fadd(10.0, 20.0); + +There are no char *INPUT typemaps, however you can apply the signed char * typemaps instead: + %include <typemaps.i> + %apply signed char *INPUT {char *input}; + void f(char *input); +*/ + +%define INPUT_TYPEMAP(TYPE, JNITYPE, JTYPE, JNIDESC) +%typemap(jni) TYPE *INPUT, TYPE &INPUT "JNITYPE" +%typemap(jtype) TYPE *INPUT, TYPE &INPUT "JTYPE" +%typemap(jstype) TYPE *INPUT, TYPE &INPUT "JTYPE" +%typemap(javain) TYPE *INPUT, TYPE &INPUT "$javainput" +%typemap(javadirectorin) TYPE *INPUT, TYPE &INPUT "$jniinput" +%typemap(javadirectorout) TYPE *INPUT, TYPE &INPUT "$javacall" + +%typemap(in) TYPE *INPUT, TYPE &INPUT +%{ $1 = ($1_ltype)&$input; %} + +%typemap(freearg) TYPE *INPUT, TYPE &INPUT "" + +%typemap(directorout) TYPE *INPUT, TYPE &INPUT +%{ $result = ($1_ltype)&$input; %} + +%typemap(directorin,descriptor=JNIDESC) TYPE &INPUT +%{ *(($&1_ltype) $input) = (JNITYPE *) &$1; %} + +%typemap(directorin,descriptor=JNIDESC) TYPE *INPUT +%{ *(($&1_ltype) $input) = (JNITYPE *) $1; %} + +%typemap(typecheck) TYPE *INPUT = TYPE; +%typemap(typecheck) TYPE &INPUT = TYPE; +%enddef + +INPUT_TYPEMAP(bool, jboolean, boolean, "Z"); +INPUT_TYPEMAP(signed char, jbyte, byte, "B"); +INPUT_TYPEMAP(unsigned char, jshort, short, "S"); +INPUT_TYPEMAP(short, jshort, short, "S"); +INPUT_TYPEMAP(unsigned short, jint, int, "I"); +INPUT_TYPEMAP(int, jint, int, "I"); +INPUT_TYPEMAP(unsigned int, jlong, long, "J"); +INPUT_TYPEMAP(long, jint, int, "I"); +INPUT_TYPEMAP(unsigned long, jlong, long, "J"); +INPUT_TYPEMAP(long long, jlong, long, "J"); +INPUT_TYPEMAP(unsigned long long, jobject, java.math.BigInteger, "Ljava/math/BigInteger;"); +INPUT_TYPEMAP(float, jfloat, float, "F"); +INPUT_TYPEMAP(double, jdouble, double, "D"); + +#undef INPUT_TYPEMAP + +/* Convert from BigInteger using the toByteArray member function */ +/* Overrides the typemap in the INPUT_TYPEMAP macro */ +%typemap(in) unsigned long long *INPUT($*1_ltype temp), unsigned long long &INPUT($*1_ltype temp) { + jclass clazz; + jmethodID mid; + jbyteArray ba; + jbyte* bae; + jsize sz; + int i; + + if (!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null"); + return $null; + } + clazz = JCALL1(GetObjectClass, jenv, $input); + mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B"); + ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid); + bae = JCALL2(GetByteArrayElements, jenv, ba, 0); + sz = JCALL1(GetArrayLength, jenv, ba); + temp = 0; + for(i=0; i<sz; i++) { + temp = (temp << 8) | ($*1_ltype)(unsigned char)bae[i]; + } + JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); + $1 = &temp; +} + +// OUTPUT typemaps. These typemaps are used for parameters that +// are output only. An array replaces the c pointer or reference parameter. +// The output value is returned in this array passed in. + +/* +OUTPUT typemaps +--------------- + +The following typemaps can be applied to turn a pointer or reference into an "output" +value. When calling a function, no input value would be given for +a parameter, but an output value would be returned. This works by a +Java array being passed as a parameter where a c pointer or reference is required. +As with any Java function, the array is passed by reference so that +any modifications to the array will be picked up in the calling function. +Note that the array passed in MUST have at least one element, but as the +c function does not require any input, the value can be set to anything. + + bool *OUTPUT, bool &OUTPUT + signed char *OUTPUT, signed char &OUTPUT + unsigned char *OUTPUT, unsigned char &OUTPUT + short *OUTPUT, short &OUTPUT + unsigned short *OUTPUT, unsigned short &OUTPUT + int *OUTPUT, int &OUTPUT + unsigned int *OUTPUT, unsigned int &OUTPUT + long *OUTPUT, long &OUTPUT + unsigned long *OUTPUT, unsigned long &OUTPUT + long long *OUTPUT, long long &OUTPUT + unsigned long long *OUTPUT, unsigned long long &OUTPUT + float *OUTPUT, float &OUTPUT + double *OUTPUT, double &OUTPUT + +For example, suppose you were trying to wrap the modf() function in the +C math library which splits x into integral and fractional parts (and +returns the integer part in one of its parameters): + + double modf(double x, double *ip); + +You could wrap it with SWIG as follows : + + %include <typemaps.i> + double modf(double x, double *OUTPUT); + +or you can use the %apply directive : + + %include <typemaps.i> + %apply double *OUTPUT { double *ip }; + double modf(double x, double *ip); + +The Java output of the function would be the function return value and the +value in the single element array. In Java you would use it like this: + + double[] ptr = {0.0}; + double fraction = modulename.modf(5.0,ptr); + +There are no char *OUTPUT typemaps, however you can apply the signed char * typemaps instead: + %include <typemaps.i> + %apply signed char *OUTPUT {char *output}; + void f(char *output); +*/ + +/* Java BigInteger[] */ +%typecheck(SWIG_TYPECHECK_INT128_ARRAY) SWIGBIGINTEGERARRAY "" + +%define OUTPUT_TYPEMAP(TYPE, JNITYPE, JTYPE, JAVATYPE, JNIDESC, TYPECHECKTYPE) +%typemap(jni) TYPE *OUTPUT, TYPE &OUTPUT %{JNITYPE##Array%} +%typemap(jtype) TYPE *OUTPUT, TYPE &OUTPUT "JTYPE[]" +%typemap(jstype) TYPE *OUTPUT, TYPE &OUTPUT "JTYPE[]" +%typemap(javain) TYPE *OUTPUT, TYPE &OUTPUT "$javainput" +%typemap(javadirectorin) TYPE *OUTPUT, TYPE &OUTPUT "$jniinput" +%typemap(javadirectorout) TYPE *OUTPUT, TYPE &OUTPUT "$javacall" + +%typemap(in) TYPE *OUTPUT($*1_ltype temp), TYPE &OUTPUT($*1_ltype temp) +{ + if (!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); + return $null; + } + if (JCALL1(GetArrayLength, jenv, $input) == 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); + return $null; + } + $1 = &temp; +} + +%typemap(freearg) TYPE *OUTPUT, TYPE &OUTPUT "" + +%typemap(argout) TYPE *OUTPUT, TYPE &OUTPUT +{ + JNITYPE jvalue = (JNITYPE)temp$argnum; + JCALL4(Set##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &jvalue); +} + +%typemap(directorout,warning="Need to provide TYPE *OUTPUT directorout typemap") TYPE *OUTPUT, TYPE &OUTPUT { +} + +%typemap(directorin,descriptor=JNIDESC) TYPE &OUTPUT +%{ *(($&1_ltype) $input = &$1; %} + +%typemap(directorin,descriptor=JNIDESC,warning="Need to provide TYPE *OUTPUT directorin typemap, TYPE array length is unknown") TYPE *OUTPUT +{ +} + +%typemap(typecheck) TYPE *INOUT = TYPECHECKTYPE; +%typemap(typecheck) TYPE &INOUT = TYPECHECKTYPE; +%enddef + +OUTPUT_TYPEMAP(bool, jboolean, boolean, Boolean, "[Ljava/lang/Boolean;", jbooleanArray); +OUTPUT_TYPEMAP(signed char, jbyte, byte, Byte, "[Ljava/lang/Byte;", jbyteArray); +OUTPUT_TYPEMAP(unsigned char, jshort, short, Short, "[Ljava/lang/Short;", jshortArray); +OUTPUT_TYPEMAP(short, jshort, short, Short, "[Ljava/lang/Short;", jshortArray); +OUTPUT_TYPEMAP(unsigned short, jint, int, Int, "[Ljava/lang/Integer;", jintArray); +OUTPUT_TYPEMAP(int, jint, int, Int, "[Ljava/lang/Integer;", jintArray); +OUTPUT_TYPEMAP(unsigned int, jlong, long, Long, "[Ljava/lang/Long;", jlongArray); +OUTPUT_TYPEMAP(long, jint, int, Int, "[Ljava/lang/Integer;", jintArray); +OUTPUT_TYPEMAP(unsigned long, jlong, long, Long, "[Ljava/lang/Long;", jlongArray); +OUTPUT_TYPEMAP(long long, jlong, long, Long, "[Ljava/lang/Long;", jlongArray); +OUTPUT_TYPEMAP(unsigned long long, jobject, java.math.BigInteger, NOTUSED, "[Ljava/lang/BigInteger;", SWIGBIGINTEGERARRAY); +OUTPUT_TYPEMAP(float, jfloat, float, Float, "[Ljava/lang/Float;", jfloatArray); +OUTPUT_TYPEMAP(double, jdouble, double, Double, "[Ljava/lang/Double;", jdoubleArray); + +#undef OUTPUT_TYPEMAP + +/* Convert to BigInteger - byte array holds number in 2's complement big endian format */ +/* Use first element in BigInteger array for output */ +/* Overrides the typemap in the OUTPUT_TYPEMAP macro */ +%typemap(argout) unsigned long long *OUTPUT, unsigned long long &OUTPUT { + jbyteArray ba = JCALL1(NewByteArray, jenv, 9); + jbyte* bae = JCALL2(GetByteArrayElements, jenv, ba, 0); + jclass clazz = JCALL1(FindClass, jenv, "java/math/BigInteger"); + jmethodID mid = JCALL3(GetMethodID, jenv, clazz, "<init>", "([B)V"); + jobject bigint; + int i; + + bae[0] = 0; + for(i=1; i<9; i++ ) { + bae[i] = (jbyte)(temp$argnum>>8*(8-i)); + } + + JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); + bigint = JCALL3(NewObject, jenv, clazz, mid, ba); + JCALL3(SetObjectArrayElement, jenv, $input, 0, bigint); +} + +/* +INOUT typemaps +-------------- + +Mappings for a parameter that is both an input and an output parameter + +The following typemaps can be applied to make a function parameter both +an input and output value. This combines the behavior of both the +"INPUT" and "OUTPUT" typemaps described earlier. Output values are +returned as an element in a Java array. + + bool *INOUT, bool &INOUT + signed char *INOUT, signed char &INOUT + unsigned char *INOUT, unsigned char &INOUT + short *INOUT, short &INOUT + unsigned short *INOUT, unsigned short &INOUT + int *INOUT, int &INOUT + unsigned int *INOUT, unsigned int &INOUT + long *INOUT, long &INOUT + unsigned long *INOUT, unsigned long &INOUT + long long *INOUT, long long &INOUT + unsigned long long *INOUT, unsigned long long &INOUT + float *INOUT, float &INOUT + double *INOUT, double &INOUT + +For example, suppose you were trying to wrap the following function : + + void neg(double *x) { + *x = -(*x); + } + +You could wrap it with SWIG as follows : + + %include <typemaps.i> + void neg(double *INOUT); + +or you can use the %apply directive : + + %include <typemaps.i> + %apply double *INOUT { double *x }; + void neg(double *x); + +This works similarly to C in that the mapping directly modifies the +input value - the input must be an array with a minimum of one element. +The element in the array is the input and the output is the element in +the array. + + double x[] = {5.0}; + neg(x); + +The implementation of the OUTPUT and INOUT typemaps is different to other +languages in that other languages will return the output value as part +of the function return value. This difference is due to Java being a typed language. + +There are no char *INOUT typemaps, however you can apply the signed char * typemaps instead: + %include <typemaps.i> + %apply signed char *INOUT {char *inout}; + void f(char *inout); +*/ + +%define INOUT_TYPEMAP(TYPE, JNITYPE, JTYPE, JAVATYPE, JNIDESC, TYPECHECKTYPE) +%typemap(jni) TYPE *INOUT, TYPE &INOUT %{JNITYPE##Array%} +%typemap(jtype) TYPE *INOUT, TYPE &INOUT "JTYPE[]" +%typemap(jstype) TYPE *INOUT, TYPE &INOUT "JTYPE[]" +%typemap(javain) TYPE *INOUT, TYPE &INOUT "$javainput" +%typemap(javadirectorin) TYPE *INOUT, TYPE &INOUT "$jniinput" +%typemap(javadirectorout) TYPE *INOUT, TYPE &INOUT "$javacall" + +%typemap(in) TYPE *INOUT, TYPE &INOUT { + if (!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); + return $null; + } + if (JCALL1(GetArrayLength, jenv, $input) == 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); + return $null; + } + $1 = ($1_ltype) JCALL2(Get##JAVATYPE##ArrayElements, jenv, $input, 0); +} + +%typemap(freearg) TYPE *INOUT, TYPE &INOUT "" + +%typemap(argout) TYPE *INOUT, TYPE &INOUT +{ JCALL3(Release##JAVATYPE##ArrayElements, jenv, $input, (JNITYPE *)$1, 0); } + +%typemap(directorout,warning="Need to provide TYPE *INOUT directorout typemap") TYPE *INOUT, TYPE &INOUT { +} + +%typemap(directorin,descriptor=JNIDESC) TYPE &INOUT +%{ *(($&1_ltype)&$input) = &$1; %} + +%typemap(directorin,descriptor=JNIDESC,warning="Need to provide TYPE *INOUT directorin typemap, TYPE array length is unknown") TYPE *INOUT, TYPE &INOUT +{ +} + +%typemap(typecheck) TYPE *INOUT = TYPECHECKTYPE; +%typemap(typecheck) TYPE &INOUT = TYPECHECKTYPE; +%enddef + +INOUT_TYPEMAP(bool, jboolean, boolean, Boolean, "[Ljava/lang/Boolean;", jbooleanArray); +INOUT_TYPEMAP(signed char, jbyte, byte, Byte, "[Ljava/lang/Byte;", jbyteArray); +INOUT_TYPEMAP(unsigned char, jshort, short, Short, "[Ljava/lang/Short;", jshortArray); +INOUT_TYPEMAP(short, jshort, short, Short, "[Ljava/lang/Short;", jshortArray); +INOUT_TYPEMAP(unsigned short, jint, int, Int, "[Ljava/lang/Integer;", jintArray); +INOUT_TYPEMAP(int, jint, int, Int, "[Ljava/lang/Integer;", jintArray); +INOUT_TYPEMAP(unsigned int, jlong, long, Long, "[Ljava/lang/Long;", jlongArray); +INOUT_TYPEMAP(long, jint, int, Int, "[Ljava/lang/Integer;", jintArray); +INOUT_TYPEMAP(unsigned long, jlong, long, Long, "[Ljava/lang/Long;", jlongArray); +INOUT_TYPEMAP(long long, jlong, long, Long, "[Ljava/lang/Long;", jlongArray); +INOUT_TYPEMAP(unsigned long long, jobject, java.math.BigInteger, NOTUSED, "[Ljava.math.BigInteger;", SWIGBIGINTEGERARRAY); +INOUT_TYPEMAP(float, jfloat, float, Float, "[Ljava/lang/Float;", jfloatArray); +INOUT_TYPEMAP(double, jdouble, double, Double, "[Ljava/lang/Double;", jdoubleArray); + +#undef INOUT_TYPEMAP + +/* Override typemaps in the INOUT_TYPEMAP macro for booleans to fix casts + as a jboolean isn't always the same size as a bool */ +%typemap(in) bool *INOUT (bool btemp, jboolean *jbtemp), bool &INOUT (bool btemp, jboolean *jbtemp) { + if (!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); + return $null; + } + if (JCALL1(GetArrayLength, jenv, $input) == 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); + return $null; + } + jbtemp = JCALL2(GetBooleanArrayElements, jenv, $input, 0); + btemp = (*jbtemp) ? true : false; + $1 = &btemp; +} + +%typemap(argout) bool *INOUT, bool &INOUT { + *jbtemp$argnum = btemp$argnum ? (jboolean)1 : (jboolean)0; + JCALL3(ReleaseBooleanArrayElements, jenv, $input , (jboolean *)jbtemp$argnum, 0); +} + +/* Override the typemap in the INOUT_TYPEMAP macro for unsigned long long */ +%typemap(in) unsigned long long *INOUT ($*1_ltype temp), unsigned long long &INOUT ($*1_ltype temp) { + jobject bigint; + jclass clazz; + jmethodID mid; + jbyteArray ba; + jbyte* bae; + jsize sz; + int i; + + if (!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); + return $null; + } + if (JCALL1(GetArrayLength, jenv, $input) == 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); + return $null; + } + bigint = JCALL2(GetObjectArrayElement, jenv, $input, 0); + if (!bigint) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array element null"); + return $null; + } + clazz = JCALL1(GetObjectClass, jenv, bigint); + mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B"); + ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, bigint, mid); + bae = JCALL2(GetByteArrayElements, jenv, ba, 0); + sz = JCALL1(GetArrayLength, jenv, ba); + temp = 0; + for(i=0; i<sz; i++) { + temp = (temp << 8) | ($*1_ltype)(unsigned char)bae[i]; + } + JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); + $1 = &temp; +} + +%typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT; +%typemap(argout) unsigned long long &INOUT = unsigned long long &OUTPUT; diff --git a/devtools/swigwin-1.3.34/Lib/java/various.i b/devtools/swigwin-1.3.34/Lib/java/various.i new file mode 100644 index 0000000..c53f08a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/java/various.i @@ -0,0 +1,151 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * various.i + * + * SWIG Typemap library for Java. + * Various useful typemaps. + * ----------------------------------------------------------------------------- */ + +/* + * char **STRING_ARRAY typemaps. + * These typemaps are for C String arrays which are NULL terminated. + * char *values[] = { "one", "two", "three", NULL }; // note NULL + * char ** is mapped to a Java String[]. + * + * Example usage wrapping: + * %apply char **STRING_ARRAY { char **input }; + * char ** foo(char **input); + * + * Java usage: + * String numbers[] = { "one", "two", "three" }; + * String[] ret = modulename.foo( numbers }; + */ +%typemap(jni) char **STRING_ARRAY "jobjectArray" +%typemap(jtype) char **STRING_ARRAY "String[]" +%typemap(jstype) char **STRING_ARRAY "String[]" +%typemap(in) char **STRING_ARRAY (jint size) { + int i = 0; + size = JCALL1(GetArrayLength, jenv, $input); +#ifdef __cplusplus + $1 = new char*[size+1]; +#else + $1 = (char **)calloc(size+1, sizeof(char *)); +#endif + for (i = 0; i<size; i++) { + jstring j_string = (jstring)JCALL2(GetObjectArrayElement, jenv, $input, i); + const char *c_string = JCALL2(GetStringUTFChars, jenv, j_string, 0); +#ifdef __cplusplus + $1[i] = new char [strlen(c_string)+1]; +#else + $1[i] = (char *)calloc(strlen(c_string)+1, sizeof(const char *)); +#endif + strcpy($1[i], c_string); + JCALL2(ReleaseStringUTFChars, jenv, j_string, c_string); + JCALL1(DeleteLocalRef, jenv, j_string); + } + $1[i] = 0; +} + +%typemap(freearg) char **STRING_ARRAY { + int i; + for (i=0; i<size$argnum-1; i++) +#ifdef __cplusplus + delete[] $1[i]; + delete[] $1; +#else + free($1[i]); + free($1); +#endif +} + +%typemap(out) char **STRING_ARRAY (char *s) { + int i; + int len=0; + jstring temp_string; + const jclass clazz = JCALL1(FindClass, jenv, "java/lang/String"); + + while ($1[len]) len++; + jresult = JCALL3(NewObjectArray, jenv, len, clazz, NULL); + /* exception checking omitted */ + + for (i=0; i<len; i++) { + temp_string = JCALL1(NewStringUTF, jenv, *result++); + JCALL3(SetObjectArrayElement, jenv, jresult, i, temp_string); + JCALL1(DeleteLocalRef, jenv, temp_string); + } +} + +%typemap(javain) char **STRING_ARRAY "$javainput" +%typemap(javaout) char **STRING_ARRAY { + return $jnicall; + } + +/* + * char **STRING_OUT typemaps. + * These are typemaps for returning strings when using a C char ** parameter type. + * The returned string appears in the 1st element of the passed in Java String array. + * + * Example usage wrapping: + * void foo(char **string_out); + * + * Java usage: + * String stringOutArray[] = { "" }; + * modulename.foo(stringOutArray); + * System.out.println( stringOutArray[0] ); + */ +%typemap(jni) char **STRING_OUT "jobjectArray" +%typemap(jtype) char **STRING_OUT "String[]" +%typemap(jstype) char **STRING_OUT "String[]" +%typemap(javain) char **STRING_OUT "$javainput" + +%typemap(in) char **STRING_OUT($*1_ltype temp) { + if (!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); + return $null; + } + if (JCALL1(GetArrayLength, jenv, $input) == 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); + return $null; + } + $1 = &temp; +} + +%typemap(argout) char **STRING_OUT { + jstring jnewstring = NULL; + if($1) { + jnewstring = JCALL1(NewStringUTF, jenv, *$1); + } + JCALL3(SetObjectArrayElement, jenv, $input, 0, jnewstring); +} + +/* + * char *BYTE typemaps. + * These are input typemaps for mapping a Java byte[] array to a C char array. + * Note that as a Java array is used and thus passeed by reference, the C routine + * can return data to Java via the parameter. + * + * Example usage wrapping: + * void foo(char *array); + * + * Java usage: + * byte b[] = new byte[20]; + * modulename.foo(b); + */ +%typemap(jni) char *BYTE "jbyteArray" +%typemap(jtype) char *BYTE "byte[]" +%typemap(jstype) char *BYTE "byte[]" +%typemap(in) char *BYTE { + $1 = (char *) JCALL2(GetByteArrayElements, jenv, $input, 0); +} + +%typemap(argout) char *BYTE { + JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *) $1, 0); +} + +%typemap(javain) char *BYTE "$javainput" + +/* Prevent default freearg typemap from being used */ +%typemap(freearg) char *BYTE "" + diff --git a/devtools/swigwin-1.3.34/Lib/linkruntime.c b/devtools/swigwin-1.3.34/Lib/linkruntime.c new file mode 100644 index 0000000..ddc7812 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/linkruntime.c @@ -0,0 +1,22 @@ +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +static void *ptr = 0; +SWIGEXPORT void * +SWIG_ReturnGlobalTypeList(void *t) { + if (!ptr && !t) ptr = t; + return ptr; +} diff --git a/devtools/swigwin-1.3.34/Lib/lua/_std_common.i b/devtools/swigwin-1.3.34/Lib/lua/_std_common.i new file mode 100644 index 0000000..33cc513 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/lua/_std_common.i @@ -0,0 +1,96 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * _std_common.i + * + * std::helpers for LUA + * ----------------------------------------------------------------------------- */ + +%include <std_except.i> // the general exepctions + +/* +The basic idea here, is instead of trying to feed SWIG all the +horribly templated STL code, to give it a neatened version. + +These %defines cover some of the more common methods +so the class declarations become just a set of %defines + +*/ + +/* #define for basic container features +note: I allow front(), back() & pop_back() to throw execptions +upon empty containers, rather than coredump +(as we have'nt defined the methods, we can use %extend to add with +new features) + +*/ +%define %STD_CONTAINER_METHODS(CLASS,T) +public: + CLASS(); + CLASS(const CLASS&); + unsigned int size() const; + unsigned int max_size() const; + bool empty() const; + void clear(); + %extend { // the extra stuff which must be checked + T front()const throw (std::out_of_range){ // only read front & back + if (self->empty()) + throw std::out_of_range("in "#CLASS"::front()"); + return self->front(); + } + T back()const throw (std::out_of_range){ // not write to them + if (self->empty()) + throw std::out_of_range("in "#CLASS"::back()"); + return self->back(); + } + } +%enddef + +/* push/pop for front/back +also note: front & back are read only methods, not used for writing +*/ +%define %STD_FRONT_ACCESS_METHODS(CLASS,T) +public: + void push_front(const T& val); + %extend { // must check this + void pop_front() throw (std::out_of_range){ + if (self->empty()) + throw std::out_of_range("in "#CLASS"::pop_front()"); + self->pop_back(); + } + } +%enddef + +%define %STD_BACK_ACCESS_METHODS(CLASS,T) +public: + void push_back(const T& val); + %extend { // must check this + void pop_back() throw (std::out_of_range){ + if (self->empty()) + throw std::out_of_range("in "#CLASS"::pop_back()"); + self->pop_back(); + } + } +%enddef + +/* +Random access methods +*/ +%define %STD_RANDOM_ACCESS_METHODS(CLASS,T) + %extend // this is a extra bit of SWIG code + { + // [] is replaced by __getitem__ & __setitem__ + // simply throws a string, which causes a lua error + T __getitem__(unsigned int idx) throw (std::out_of_range){ + if (idx>=self->size()) + throw std::out_of_range("in "#CLASS"::__getitem__()"); + return (*self)[idx]; + } + void __setitem__(unsigned int idx,const T& val) throw (std::out_of_range){ + if (idx>=self->size()) + throw std::out_of_range("in "#CLASS"::__setitem__()"); + (*self)[idx]=val; + } + }; +%enddef diff --git a/devtools/swigwin-1.3.34/Lib/lua/carrays.i b/devtools/swigwin-1.3.34/Lib/lua/carrays.i new file mode 100644 index 0000000..9a210d2 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/lua/carrays.i @@ -0,0 +1,8 @@ +/* Small change to the standard carrays.i +renaming the field to __getitem__ & __setitem__ +for operator[] access +*/ +%rename(__getitem) *::getitem; // the v=X[i] (get operator) +%rename(__setitem) *::setitem; // the X[i]=v (set operator) + +%include <../carrays.i> diff --git a/devtools/swigwin-1.3.34/Lib/lua/lua.swg b/devtools/swigwin-1.3.34/Lib/lua/lua.swg new file mode 100644 index 0000000..59687cc --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/lua/lua.swg @@ -0,0 +1,207 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * lua.swg + * + * SWIG Configuration File for Lua. + * This file is parsed by SWIG before reading any other interface file. + * ----------------------------------------------------------------------------- */ + +/* ----------------------------------------------------------------------------- + * includes + * ----------------------------------------------------------------------------- */ + +%include <luatypemaps.swg> /* The typemaps */ +%include <luaruntime.swg> /* The runtime stuff */ + +/* ----------------------------------------------------------------------------- + * constants typemaps + * ----------------------------------------------------------------------------- */ +// this basically adds to a table of constants +%typemap(consttab) int, unsigned int, short, unsigned short, long, unsigned long, unsigned char, signed char, bool, enum SWIGTYPE + { SWIG_LUA_INT, (char *)"$symname", (long) $value, 0, 0, 0} + +%typemap(consttab) float, double + { SWIG_LUA_FLOAT, (char *)"$symname", 0, (double) $value, 0, 0} + +%typemap(consttab) long long, unsigned long long, signed long long + { SWIG_LUA_FLOAT, (char *)"$symname", 0, (double) $value, 0, 0} + +%typemap(consttab) const long long&, const unsigned long long&, const signed long long& + { SWIG_LUA_FLOAT, (char *)"$symname", 0, (double) *$value, 0, 0} + +%typemap(consttab) char *, const char *, char [], const char [] + { SWIG_LUA_STRING, (char *)"$symname", 0, 0, (void *)$value, 0} + +// note: char is treated as a seperate special type +// signed char & unsigned char are numbers +%typemap(consttab) char + { SWIG_LUA_CHAR, (char *)"$symname", (long)$value, 0, 0, 0} + +%typemap(consttab) long long, unsigned long long + { SWIG_LUA_STRING, (char *) "$symname", 0, 0, (void *)"$value", 0} + +%typemap(consttab) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] + { SWIG_LUA_POINTER, (char *)"$symname", 0, 0, (void *)$value, &$1_descriptor} + +// member function pointers +%typemap(consttab) SWIGTYPE (CLASS::*) + { SWIG_LUA_BINARY, (char *)"$symname", sizeof($type), 0, (void *)&$value, &$1_descriptor} + + +/* ----------------------------------------------------------------------------- + * Overloaded operator support + * ----------------------------------------------------------------------------- */ +// lua calls the + operator '__add' +// python likes to call it '__add__' +// Assuming most SWIGers will probably use the __add__ if they extend their classes +// we have two sets of renames +// one to rename the operator+() to __add() +// (this lets SWIG rename the operator overloads) +// another is to rename __add__() to __add() +// (this means that people who wrote SWIG code to do that add will also work) + +#ifdef __cplusplus +// this is extra renaming for lua +// not all operators are supported, so only those that are, are listed +%rename(__add) *::operator+; +%rename(__sub) *::operator-; +%rename(__mul) *::operator*; +%rename(__div) *::operator/; +%rename(__unm) *::operator-(); +%rename(__unm) *::operator-() const; + +%rename(__eq) *::operator==; +%ignore *::operator!=; // note: Lua does not have a notequal operator + // it just uses 'not (a==b)' +%rename(__lt) *::operator<; +%ignore *::operator>; // ditto less than vs greater than +%rename(__le) *::operator<=; +%ignore *::operator>=; // ditto less than vs greater than +%ignore *::operator!; // does not support not + +%rename(__call) *::operator(); // the fn call operator + +// lua does not support overloading of: +// logical/bitwise operators +// assign operator +// +=,-=,*=, etc +// therefore ignoring them for now +// it also doesn't support non class operators +// eg friends or XX operator+(XX,XX) +// also ignoring +// note: some of these might be better to rename, but not doing that for now +%ignore *::operator&&; %ignore operator&&; +%ignore *::operator||; %ignore operator||; +%ignore *::operator+=; +%ignore *::operator-=; +%ignore *::operator*=; +%ignore *::operator/=; +%ignore *::operator%=; +%ignore *::operator++; %ignore *::operator--; + +%ignore *::operator=; // note: this might be better to rename to assign() or similar + +%ignore operator+; +%ignore operator-; +%ignore operator*; +%ignore operator/; +%ignore operator%; +%ignore operator[]; +%ignore operator>; %ignore operator>=; +%ignore operator<; %ignore operator<=; +%ignore operator==; %ignore operator!=; + + +// renaming the python operators to be compatible with lua +// this means that if a developer has written a fn __add__() +// it will be used for the lua + +%rename(__add) *::__add__; +%rename(__sub) *::__sub__; +%rename(__mul) *::__mul__; +%rename(__div) *::__div__; +%rename(__unm) *::__neg__; // lua calls unary minus,'unm' not 'neg' +%rename(__tostring) *::__str__; // both map to __tostring +%rename(__tostring) *::__repr__; // both map to __tostring + + +%rename(__pow) *::__pow__; // lua power '^' operator +%rename(__concat) *::__concat__; // lua concat '..' operator +%rename(__eq) *::__eq__; +%rename(__lt) *::__lt__; +%rename(__le) *::__le__; +%rename(__call) *::__call__; // the fn call operator() + +// the [] operator has two parts, the get & the set +%rename(__getitem) *::__getitem__; // the v=X[i] (get operator) +%rename(__setitem) *::__setitem__; // the X[i]=v (set operator) + + +#endif + + +/* ------------------------------------------------------------ + * Exceptions + * ------------------------------------------------------------ */ +/* Confession: I dont really like C++ exceptions +The python/lua ones are great, but C++ ones I dont like +(mainly because I cannot get the stack trace out of it) +Therefore I have not bothered to try doing much in this + +Therefore currently its just enough to get a few test cases running ok + +note: if you wish to throw anything related to std::exception +use %include <std_except.i> instead +*/ +%typemap(throws) int,unsigned int,signed int, + long,unsigned long,signed long, + short,unsigned short,signed short, + bool,float,double, + long long,unsigned long long, + char, unsigned char, signed char, + enum SWIGTYPE +%{lua_pushfstring(L,"numeric exception:%f",(double)$1);SWIG_fail; %} + +// strings are just sent as errors +%typemap(throws) char*, const char* +%{lua_pushstring(L,$1);SWIG_fail;%} + +/* +Throwing object is a serious problem: +Assuming some code throws a 'FooBar' +There are a few options: +- return a pointer to it: but its unclear how long this will last for. +- return a copy of it: but not all objects are copyable + (see exception_partial_info in the test suite for a case where you cannot) +- convert to a string & throw that + its not so useful, but it works (this is more lua like). +The third option (though not nice) is used +For a more useful solution: see std_except for more details +*/ +%typemap(throws) SWIGTYPE +{ + (void)$1; + lua_pushfstring(L,"object exception:%s",SWIG_TypePrettyName($1_descriptor)); + SWIG_fail; +} + +// old code: fails under exception_partial_info +// if you have a function which throws a FooBar & you want SWIG to throw the actual object +// then use +// %apply SWIGTYPE BY_VAL {FooBar}; +%typemap(throws) SWIGTYPE BY_VAL +{ + SWIG_NewPointerObj(L,(void *)new $1_ltype(($1_ltype &) $1),$&1_descriptor,1); + SWIG_fail; +} + + + + + +/* ----------------------------------------------------------------------------- + * extras + * ----------------------------------------------------------------------------- */ + +/* ------------------------------ end lua.swg ------------------------------ */ diff --git a/devtools/swigwin-1.3.34/Lib/lua/lua_fnptr.i b/devtools/swigwin-1.3.34/Lib/lua/lua_fnptr.i new file mode 100644 index 0000000..c7df6f5 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/lua/lua_fnptr.i @@ -0,0 +1,128 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * lua_fnptr.i + * + * SWIG Library file containing the main typemap code to support Lua modules. + * ----------------------------------------------------------------------------- */ + +/* ----------------------------------------------------------------------------- + * Basic function pointer support + * ----------------------------------------------------------------------------- */ +/* +The structure: SWIGLUA_FN provides a simple (local only) wrappering for a function. + +For example if you wanted to have a C/C++ function take a lua function as a parameter. +You could declare it as: + int my_func(int a, int b, SWIGLUA_FN fn); +note: it should be passed by value, not byref or as a pointer. + +The SWIGLUA_FN holds a pointer to the lua_State, and the stack index where the function is held. +The macro SWIGLUA_FN_GET() will put a copy of the lua function at the top of the stack. +After that its fairly simple to write the rest of the code (assuming know how to use lua), +just push the parameters, call the function and return the result. + + int my_func(int a, int b, SWIGLUA_FN fn) + { + SWIGLUA_FN_GET(fn); + lua_pushnumber(fn.L,a); + lua_pushnumber(fn.L,b); + lua_call(fn.L,2,1); // 2 in, 1 out + return luaL_checknumber(fn.L,-1); + } + +SWIG will automatically performs the wrappering of the arguments in and out. + +However: if you wish to store the function between calls, look to the SWIGLUA_REF below. + +*/ +// this is for the C code only, we don't want SWIG to wrapper it for us. +%{ +typedef struct{ + lua_State* L; /* the state */ + int idx; /* the index on the stack */ +}SWIGLUA_FN; + +#define SWIGLUA_FN_GET(fn) {lua_pushvalue(fn.L,fn.idx);} +%} + +// the actual typemap +%typemap(in,checkfn="lua_isfunction") SWIGLUA_FN +%{ $1.L=L; $1.idx=$input; %} + +/* ----------------------------------------------------------------------------- + * Storing lua object support + * ----------------------------------------------------------------------------- */ +/* +The structure: SWIGLUA_REF provides a mechanism to store object (usually functions) +between calls to the interpreter. + +For example if you wanted to have a C/C++ function take a lua function as a parameter. +Then call it later, You could declare it as: + SWIGLUA_REF myref; + void set_func(SWIGLUA_REF ref); + SWIGLUA_REF get_func(); + void call_func(int val); +note: it should be passed by value, not byref or as a pointer. + +The SWIGLUA_REF holds a pointer to the lua_State, and an integer reference to the object. +Because it holds a permenet ref to an object, the SWIGLUA_REF must be handled with a bit more care. +It should be initalised to {0,0}. The function swiglua_ref_set() should be used to set it. +swiglua_ref_clear() should be used to clear it when not in use, and swiglua_ref_get() to get the +data back. + +Note: the typemap does not check that the object is in fact a function, +if you need that you must add it yourself. + + + int my_func(int a, int b, SWIGLUA_FN fn) + { + SWIGLUA_FN_GET(fn); + lua_pushnumber(fn.L,a); + lua_pushnumber(fn.L,b); + lua_call(fn.L,2,1); // 2 in, 1 out + return luaL_checknumber(fn.L,-1); + } + +SWIG will automatically performs the wrappering of the arguments in and out. + +However: if you wish to store the function between calls, look to the SWIGLUA_REF below. + +*/ + +%{ +typedef struct{ + lua_State* L; /* the state */ + int ref; /* a ref in the lua global index */ +}SWIGLUA_REF; + + +void swiglua_ref_clear(SWIGLUA_REF* pref){ + if (pref->L!=0 && pref->ref!=LUA_NOREF && pref->ref!=LUA_REFNIL){ + luaL_unref(pref->L,LUA_REGISTRYINDEX,pref->ref); + } + pref->L=0; pref->ref=0; +} + +void swiglua_ref_set(SWIGLUA_REF* pref,lua_State* L,int idx){ +// swiglua_ref_clear(pref); /* just in case */ + pref->L=L; + lua_pushvalue(L,idx); /* copy obj to top */ + pref->ref=luaL_ref(L,LUA_REGISTRYINDEX); /* remove obj from top & put into registry */ +} + +void swiglua_ref_get(SWIGLUA_REF* pref){ + if (pref->L!=0) + lua_rawgeti(pref->L,LUA_REGISTRYINDEX,pref->ref); +} + +%} + +%typemap(in) SWIGLUA_REF +%{ swiglua_ref_set(&$1,L,$input); %} + +%typemap(out) SWIGLUA_REF +%{ if ($1.L!=0) {swiglua_ref_get(&$1);} else {lua_pushnil(L);} + SWIG_arg++; %} + diff --git a/devtools/swigwin-1.3.34/Lib/lua/luarun.swg b/devtools/swigwin-1.3.34/Lib/lua/luarun.swg new file mode 100644 index 0000000..751e062 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/lua/luarun.swg @@ -0,0 +1,754 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * luarun.swg + * + * This file contains the runtime support for Lua modules + * and includes code for managing global variables and pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "lua.h" +#include "lauxlib.h" +#include <stdlib.h> /* for malloc */ +#include <assert.h> /* for a few sanity tests */ + +/* ----------------------------------------------------------------------------- + * global swig types + * ----------------------------------------------------------------------------- */ +/* Constant table */ +#define SWIG_LUA_INT 1 +#define SWIG_LUA_FLOAT 2 +#define SWIG_LUA_STRING 3 +#define SWIG_LUA_POINTER 4 +#define SWIG_LUA_BINARY 5 +#define SWIG_LUA_CHAR 6 + +/* Structure for variable linking table */ +typedef struct { + const char *name; + lua_CFunction get; + lua_CFunction set; +} swig_lua_var_info; + +/* Constant information structure */ +typedef struct { + int type; + char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_lua_const_info; + +typedef struct { + const char *name; + lua_CFunction method; +} swig_lua_method; + +typedef struct { + const char *name; + lua_CFunction getmethod; + lua_CFunction setmethod; +} swig_lua_attribute; + +typedef struct swig_lua_class { + const char *name; + swig_type_info **type; + lua_CFunction constructor; + void (*destructor)(void *); + swig_lua_method *methods; + swig_lua_attribute *attributes; + struct swig_lua_class **bases; + const char **base_names; +} swig_lua_class; + +/* this is the struct for wrappering all pointers in SwigLua +*/ +typedef struct { + swig_type_info *type; + int own; /* 1 if owned & must be destroyed */ + void *ptr; +} swig_lua_userdata; + +/* this is the struct for wrapping arbitary packed binary data +(currently it is only used for member function pointers) +the data ordering is similar to swig_lua_userdata, but it is currently not possible +to tell the two structures apart within Swig, other than by looking at the type +*/ +typedef struct { + swig_type_info *type; + int own; /* 1 if owned & must be destroyed */ + char data[1]; /* arbitary amount of data */ +} swig_lua_rawdata; + +/* Common SWIG API */ +#define SWIG_NewPointerObj(L, ptr, type, owner) SWIG_Lua_NewPointerObj(L, (void *)ptr, type, owner) +#define SWIG_ConvertPtr(L,idx, ptr, type, flags) SWIG_Lua_ConvertPtr(L,idx,ptr,type,flags) +#define SWIG_MustGetPtr(L,idx, type,flags, argnum,fnname) SWIG_Lua_MustGetPtr(L,idx, type,flags, argnum,fnname) +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(L, idx, ptr, sz, ty) SWIG_Lua_ConvertPacked(L, idx, ptr, sz, ty) +#define SWIG_NewMemberObj(L, ptr, sz, type) SWIG_Lua_NewPackedObj(L, ptr, sz, type) + +/* Runtime API */ +#define SWIG_GetModule(clientdata) SWIG_Lua_GetModule((lua_State*)(clientdata)) +#define SWIG_SetModule(clientdata, pointer) SWIG_Lua_SetModule((lua_State*) (clientdata), pointer) +#define SWIG_MODULE_CLIENTDATA_TYPE lua_State* + +/* Contract support */ +#define SWIG_contract_assert(expr, msg) \ + if (!(expr)) { lua_pushstring(L, (char *) msg); goto fail; } else + +/* helper #defines */ +#define SWIG_fail {goto fail;} +#define SWIG_fail_arg(func_name,argnum,type) \ + {lua_pushfstring(L,"Error in %s (arg %d), expected '%s' got '%s'",\ + func_name,argnum,type,SWIG_Lua_typename(L,argnum));\ + goto fail;} +#define SWIG_fail_ptr(func_name,argnum,type) \ + SWIG_fail_arg(func_name,argnum,(type && type->str)?type->str:"void*") +#define SWIG_check_num_args(func_name,a,b) \ + if (lua_gettop(L)<a || lua_gettop(L)>b) \ + {lua_pushfstring(L,"Error in %s expected %d..%d args, got %d",func_name,a,b,lua_gettop(L));\ + goto fail;} + + +#define SWIG_Lua_get_table(L,n) \ + (lua_pushstring(L, n), lua_rawget(L,-2)) + +#define SWIG_Lua_add_function(L,n,f) \ + (lua_pushstring(L, n), \ + lua_pushcfunction(L, f), \ + lua_rawset(L,-3)) + +/* special helper for allowing 'nil' for usertypes */ +#define SWIG_isptrtype(L,I) (lua_isuserdata(L,I) || lua_isnil(L,I)) + +#ifdef __cplusplus +/* Special helper for member function pointers +it gets the address, casts it, then dereferences it */ +//#define SWIG_mem_fn_as_voidptr(a) (*((char**)&(a))) +#endif + +/* storing/access of swig_module_info */ +SWIGRUNTIME swig_module_info * +SWIG_Lua_GetModule(lua_State* L) { + swig_module_info *ret = 0; + lua_pushstring(L,"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); + lua_rawget(L,LUA_REGISTRYINDEX); + if (lua_islightuserdata(L,-1)) + ret=(swig_module_info*)lua_touserdata(L,-1); + lua_pop(L,1); /* tidy */ + return ret; +} + +SWIGRUNTIME void +SWIG_Lua_SetModule(lua_State* L, swig_module_info *module) { + /* add this all into the Lua registry: */ + lua_pushstring(L,"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); + lua_pushlightuserdata(L,(void*)module); + lua_rawset(L,LUA_REGISTRYINDEX); +} + +/* ----------------------------------------------------------------------------- + * global variable support code: modules + * ----------------------------------------------------------------------------- */ + +/* this function is called when trying to set an immutable. +default value is to print an error. +This can removed with a compile flag SWIGLUA_IGNORE_SET_IMMUTABLE */ +SWIGINTERN int SWIG_Lua_set_immutable(lua_State* L) +{ +/* there should be 1 param passed in: the new value */ +#ifndef SWIGLUA_IGNORE_SET_IMMUTABLE + lua_pop(L,1); /* remove it */ + lua_pushstring(L,"This variable is immutable"); + lua_error(L); +#endif + return 0; /* should not return anything */ +} + +/* the module.get method used for getting linked data */ +SWIGINTERN int SWIG_Lua_module_get(lua_State* L) +{ +/* there should be 2 params passed in + (1) table (not the meta table) + (2) string name of the attribute + printf("SWIG_Lua_module_get %p(%s) '%s'\n", + lua_topointer(L,1),lua_typename(L,lua_type(L,1)), + lua_tostring(L,2)); +*/ + /* get the metatable */ + assert(lua_istable(L,1)); /* just in case */ + lua_getmetatable(L,1); /* get the metatable */ + assert(lua_istable(L,-1)); /* just in case */ + SWIG_Lua_get_table(L,".get"); /* get the .get table */ + lua_remove(L,3); /* remove metatable */ + if (lua_istable(L,-1)) + { + /* look for the key in the .get table */ + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); + lua_remove(L,3); /* remove .get */ + if (lua_iscfunction(L,-1)) + { /* found it so call the fn & return its value */ + lua_call(L,0,1); + return 1; + } + lua_pop(L,1); /* remove the top */ + } + lua_pop(L,1); /* remove the .get */ + lua_pushnil(L); /* return a nil */ + return 1; +} + +/* the module.set method used for setting linked data */ +SWIGINTERN int SWIG_Lua_module_set(lua_State* L) +{ +/* there should be 3 params passed in + (1) table (not the meta table) + (2) string name of the attribute + (3) any for the new value +*/ + /* get the metatable */ + assert(lua_istable(L,1)); /* just in case */ + lua_getmetatable(L,1); /* get the metatable */ + assert(lua_istable(L,-1)); /* just in case */ + SWIG_Lua_get_table(L,".set"); /* get the .set table */ + lua_remove(L,4); /* remove metatable */ + if (lua_istable(L,-1)) + { + /* look for the key in the .set table */ + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); + lua_remove(L,4); /* remove .set */ + if (lua_iscfunction(L,-1)) + { /* found it so call the fn & return its value */ + lua_pushvalue(L,3); /* value */ + lua_call(L,1,0); + return 0; + } + } + lua_settop(L,3); /* reset back to start */ + /* we now have the table, key & new value, so just set directly */ + lua_rawset(L,1); /* add direct */ + return 0; +} + +/* registering a module in lua */ +SWIGINTERN void SWIG_Lua_module_begin(lua_State* L,const char* name) +{ + assert(lua_istable(L,-1)); /* just in case */ + lua_pushstring(L,name); + lua_newtable(L); /* the table */ + /* add meta table */ + lua_newtable(L); /* the meta table */ + SWIG_Lua_add_function(L,"__index",SWIG_Lua_module_get); + SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_module_set); + lua_pushstring(L,".get"); + lua_newtable(L); /* the .get table */ + lua_rawset(L,-3); /* add .get into metatable */ + lua_pushstring(L,".set"); + lua_newtable(L); /* the .set table */ + lua_rawset(L,-3); /* add .set into metatable */ + lua_setmetatable(L,-2); /* sets meta table in module */ + lua_rawset(L,-3); /* add module into parent */ + SWIG_Lua_get_table(L,name); /* get the table back out */ +} + +/* ending the register */ +SWIGINTERN void SWIG_Lua_module_end(lua_State* L) +{ + lua_pop(L,1); /* tidy stack (remove module) */ +} + +/* adding a linked variable to the module */ +SWIGINTERN void SWIG_Lua_module_add_variable(lua_State* L,const char* name,lua_CFunction getFn,lua_CFunction setFn) +{ + assert(lua_istable(L,-1)); /* just in case */ + lua_getmetatable(L,-1); /* get the metatable */ + assert(lua_istable(L,-1)); /* just in case */ + SWIG_Lua_get_table(L,".get"); /* find the .get table */ + assert(lua_istable(L,-1)); /* should be a table: */ + SWIG_Lua_add_function(L,name,getFn); + lua_pop(L,1); /* tidy stack (remove table) */ + if (setFn) /* if there is a set fn */ + { + SWIG_Lua_get_table(L,".set"); /* find the .set table */ + assert(lua_istable(L,-1)); /* should be a table: */ + SWIG_Lua_add_function(L,name,setFn); + lua_pop(L,1); /* tidy stack (remove table) */ + } + lua_pop(L,1); /* tidy stack (remove meta) */ +} + +/* adding a function module */ +SWIGINTERN void SWIG_Lua_module_add_function(lua_State* L,const char* name,lua_CFunction fn) +{ + SWIG_Lua_add_function(L,name,fn); +} + +/* ----------------------------------------------------------------------------- + * global variable support code: classes + * ----------------------------------------------------------------------------- */ + +/* the class.get method, performs the lookup of class attributes */ +SWIGINTERN int SWIG_Lua_class_get(lua_State* L) +{ +/* there should be 2 params passed in + (1) userdata (not the meta table) + (2) string name of the attribute +*/ + assert(lua_isuserdata(L,-2)); /* just in case */ + lua_getmetatable(L,-2); /* get the meta table */ + assert(lua_istable(L,-1)); /* just in case */ + SWIG_Lua_get_table(L,".get"); /* find the .get table */ + assert(lua_istable(L,-1)); /* just in case */ + /* look for the key in the .get table */ + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); + lua_remove(L,-2); /* stack tidy, remove .get table */ + if (lua_iscfunction(L,-1)) + { /* found it so call the fn & return its value */ + lua_pushvalue(L,1); /* the userdata */ + lua_call(L,1,1); /* 1 value in (userdata),1 out (result) */ + lua_remove(L,-2); /* stack tidy, remove metatable */ + return 1; + } + lua_pop(L,1); /* remove whatever was there */ + /* ok, so try the .fn table */ + SWIG_Lua_get_table(L,".fn"); /* find the .get table */ + assert(lua_istable(L,-1)); /* just in case */ + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); /* look for the fn */ + lua_remove(L,-2); /* stack tidy, remove .fn table */ + if (lua_isfunction(L,-1)) /* note: if its a C function or lua function */ + { /* found it so return the fn & let lua call it */ + lua_remove(L,-2); /* stack tidy, remove metatable */ + return 1; + } + lua_pop(L,1); /* remove whatever was there */ + /* NEW: looks for the __getitem() fn + this is a user provided get fn */ + SWIG_Lua_get_table(L,"__getitem"); /* find the __getitem fn */ + if (lua_iscfunction(L,-1)) /* if its there */ + { /* found it so call the fn & return its value */ + lua_pushvalue(L,1); /* the userdata */ + lua_pushvalue(L,2); /* the parameter */ + lua_call(L,2,1); /* 2 value in (userdata),1 out (result) */ + lua_remove(L,-2); /* stack tidy, remove metatable */ + return 1; + } + return 0; /* sorry not known */ +} + +/* the class.set method, performs the lookup of class attributes */ +SWIGINTERN int SWIG_Lua_class_set(lua_State* L) +{ +/* there should be 3 params passed in + (1) table (not the meta table) + (2) string name of the attribute + (3) any for the new value +printf("SWIG_Lua_class_set %p(%s) '%s' %p(%s)\n", + lua_topointer(L,1),lua_typename(L,lua_type(L,1)), + lua_tostring(L,2), + lua_topointer(L,3),lua_typename(L,lua_type(L,3)));*/ + + assert(lua_isuserdata(L,1)); /* just in case */ + lua_getmetatable(L,1); /* get the meta table */ + assert(lua_istable(L,-1)); /* just in case */ + + SWIG_Lua_get_table(L,".set"); /* find the .set table */ + if (lua_istable(L,-1)) + { + /* look for the key in the .set table */ + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); + if (lua_iscfunction(L,-1)) + { /* found it so call the fn & return its value */ + lua_pushvalue(L,1); /* userdata */ + lua_pushvalue(L,3); /* value */ + lua_call(L,2,0); + return 0; + } + lua_pop(L,1); /* remove the value */ + } + lua_pop(L,1); /* remove the value .set table */ + /* NEW: looks for the __setitem() fn + this is a user provided set fn */ + SWIG_Lua_get_table(L,"__setitem"); /* find the fn */ + if (lua_iscfunction(L,-1)) /* if its there */ + { /* found it so call the fn & return its value */ + lua_pushvalue(L,1); /* the userdata */ + lua_pushvalue(L,2); /* the parameter */ + lua_pushvalue(L,3); /* the value */ + lua_call(L,3,0); /* 3 values in ,0 out */ + lua_remove(L,-2); /* stack tidy, remove metatable */ + return 1; + } + return 0; +} + +/* the class.destruct method called by the interpreter */ +SWIGINTERN int SWIG_Lua_class_destruct(lua_State* L) +{ +/* there should be 1 params passed in + (1) userdata (not the meta table) */ + swig_lua_userdata* usr; + swig_lua_class* clss; + assert(lua_isuserdata(L,-1)); /* just in case */ + usr=(swig_lua_userdata*)lua_touserdata(L,-1); /* get it */ + /* if must be destroyed & has a destructor */ + if (usr->own) /* if must be destroyed */ + { + clss=(swig_lua_class*)usr->type->clientdata; /* get the class */ + if (clss && clss->destructor) /* there is a destroy fn */ + { + clss->destructor(usr->ptr); /* bye bye */ + } + } + return 0; +} + +/* gets the swig class registry (or creates it) */ +SWIGINTERN void SWIG_Lua_get_class_registry(lua_State* L) +{ + /* add this all into the swig registry: */ + lua_pushstring(L,"SWIG"); + lua_rawget(L,LUA_REGISTRYINDEX); /* get the registry */ + if (!lua_istable(L,-1)) /* not there */ + { /* must be first time, so add it */ + lua_pop(L,1); /* remove the result */ + lua_pushstring(L,"SWIG"); + lua_newtable(L); + lua_rawset(L,LUA_REGISTRYINDEX); + /* then get it */ + lua_pushstring(L,"SWIG"); + lua_rawget(L,LUA_REGISTRYINDEX); + } +} + +/* helper fn to get the classes metatable from the register */ +SWIGINTERN void SWIG_Lua_get_class_metatable(lua_State* L,const char* cname) +{ + SWIG_Lua_get_class_registry(L); /* get the registry */ + lua_pushstring(L,cname); /* get the name */ + lua_rawget(L,-2); /* get it */ + lua_remove(L,-2); /* tidy up (remove registry) */ +} + +/* helper add a variable to a registered class */ +SWIGINTERN void SWIG_Lua_add_class_variable(lua_State* L,const char* name,lua_CFunction getFn,lua_CFunction setFn) +{ + assert(lua_istable(L,-1)); /* just in case */ + SWIG_Lua_get_table(L,".get"); /* find the .get table */ + assert(lua_istable(L,-1)); /* just in case */ + SWIG_Lua_add_function(L,name,getFn); + lua_pop(L,1); /* tidy stack (remove table) */ + if (setFn) + { + SWIG_Lua_get_table(L,".set"); /* find the .set table */ + assert(lua_istable(L,-1)); /* just in case */ + SWIG_Lua_add_function(L,name,setFn); + lua_pop(L,1); /* tidy stack (remove table) */ + } +} + +/* helper to recursively add class details (attributes & operations) */ +SWIGINTERN void SWIG_Lua_add_class_details(lua_State* L,swig_lua_class* clss) +{ + int i; + /* call all the base classes first: we can then override these later: */ + for(i=0;clss->bases[i];i++) + { + SWIG_Lua_add_class_details(L,clss->bases[i]); + } + /* add fns */ + for(i=0;clss->attributes[i].name;i++){ + SWIG_Lua_add_class_variable(L,clss->attributes[i].name,clss->attributes[i].getmethod,clss->attributes[i].setmethod); + } + /* add methods to the metatable */ + SWIG_Lua_get_table(L,".fn"); /* find the .fn table */ + assert(lua_istable(L,-1)); /* just in case */ + for(i=0;clss->methods[i].name;i++){ + SWIG_Lua_add_function(L,clss->methods[i].name,clss->methods[i].method); + } + lua_pop(L,1); /* tidy stack (remove table) */ + /* add operator overloads + these look ANY method which start with "__" and assume they + are operator overloads & add them to the metatable + (this might mess up is someone defines a method __gc (the destructor)*/ + for(i=0;clss->methods[i].name;i++){ + if (clss->methods[i].name[0]=='_' && clss->methods[i].name[1]=='_'){ + SWIG_Lua_add_function(L,clss->methods[i].name,clss->methods[i].method); + } + } +} + +/* set up the base classes pointers. +Each class structure has a list of pointers to the base class structures. +This function fills them. +It cannot be done at compile time, as this will not work with hireachies +spread over more than one swig file. +Therefore it must be done at runtime, querying the SWIG type system. +*/ +SWIGINTERN void SWIG_Lua_init_base_class(lua_State* L,swig_lua_class* clss) +{ + int i=0; + swig_module_info* module=SWIG_GetModule(L); + for(i=0;clss->base_names[i];i++) + { + if (clss->bases[i]==0) /* not found yet */ + { + /* lookup and cache the base class */ + swig_type_info *info = SWIG_TypeQueryModule(module,module,clss->base_names[i]); + if (info) clss->bases[i] = (swig_lua_class *) info->clientdata; + } + } +} + +/* performs the entire class registration process */ +SWIGINTERN void SWIG_Lua_class_register(lua_State* L,swig_lua_class* clss) +{ + /* add its constructor to module with the name of the class + so you can do MyClass(...) as well as new_MyClass(...) + BUT only if a constructor is defined + (this overcomes the problem of pure virtual classes without constructors)*/ + if (clss->constructor) + SWIG_Lua_add_function(L,clss->name,clss->constructor); + + SWIG_Lua_get_class_registry(L); /* get the registry */ + lua_pushstring(L,clss->name); /* get the name */ + lua_newtable(L); /* create the metatable */ + /* add string of class name called ".type" */ + lua_pushstring(L,".type"); + lua_pushstring(L,clss->name); + lua_rawset(L,-3); + /* add a table called ".get" */ + lua_pushstring(L,".get"); + lua_newtable(L); + lua_rawset(L,-3); + /* add a table called ".set" */ + lua_pushstring(L,".set"); + lua_newtable(L); + lua_rawset(L,-3); + /* add a table called ".fn" */ + lua_pushstring(L,".fn"); + lua_newtable(L); + lua_rawset(L,-3); + /* add accessor fns for using the .get,.set&.fn */ + SWIG_Lua_add_function(L,"__index",SWIG_Lua_class_get); + SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_class_set); + SWIG_Lua_add_function(L,"__gc",SWIG_Lua_class_destruct); + /* add it */ + lua_rawset(L,-3); /* metatable into registry */ + lua_pop(L,1); /* tidy stack (remove registry) */ + + SWIG_Lua_get_class_metatable(L,clss->name); + SWIG_Lua_add_class_details(L,clss); /* recursive adding of details (atts & ops) */ + lua_pop(L,1); /* tidy stack (remove class metatable) */ +} + +/* ----------------------------------------------------------------------------- + * Class/structure conversion fns + * ----------------------------------------------------------------------------- */ + +/* helper to add metatable to new lua object */ +SWIGINTERN void _SWIG_Lua_AddMetatable(lua_State* L,swig_type_info *type) +{ + if (type->clientdata) /* there is clientdata: so add the metatable */ + { + SWIG_Lua_get_class_metatable(L,((swig_lua_class*)(type->clientdata))->name); + if (lua_istable(L,-1)) + { + lua_setmetatable(L,-2); + } + else + { + lua_pop(L,1); + } + } +} + +/* pushes a new object into the lua stack */ +SWIGRUNTIME void SWIG_Lua_NewPointerObj(lua_State* L,void* ptr,swig_type_info *type, int own) +{ + swig_lua_userdata* usr; + if (!ptr){ + lua_pushnil(L); + return; + } + usr=(swig_lua_userdata*)lua_newuserdata(L,sizeof(swig_lua_userdata)); /* get data */ + usr->ptr=ptr; /* set the ptr */ + usr->type=type; + usr->own=own; + _SWIG_Lua_AddMetatable(L,type); /* add metatable */ +} + +/* takes a object from the lua stack & converts it into an object of the correct type + (if possible) */ +SWIGRUNTIME int SWIG_Lua_ConvertPtr(lua_State* L,int index,void** ptr,swig_type_info *type,int flags) +{ + swig_lua_userdata* usr; + swig_cast_info *cast; + if (lua_isnil(L,index)){*ptr=0; return SWIG_OK;} /* special case: lua nil => NULL pointer */ + usr=(swig_lua_userdata*)lua_touserdata(L,index); /* get data */ + if (usr) + { + if (!type) /* special cast void*, no casting fn */ + { + *ptr=usr->ptr; + return SWIG_OK; /* ok */ + } + cast=SWIG_TypeCheckStruct(usr->type,type); /* performs normal type checking */ + if (cast) + { + int newmemory = 0; + *ptr=SWIG_TypeCast(cast,usr->ptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + return SWIG_OK; /* ok */ + } + } + return SWIG_ERROR; /* error */ +} + +SWIGRUNTIME void* SWIG_Lua_MustGetPtr(lua_State* L,int index,swig_type_info *type,int flags, + int argnum,const char* func_name){ + void* result; + if (!SWIG_IsOK(SWIG_ConvertPtr(L,index,&result,type,flags))){ + lua_pushfstring(L,"Error in %s, expected a %s at argument number %d\n", + func_name,(type && type->str)?type->str:"void*",argnum); + lua_error(L); + } + return result; +} + +/* pushes a packed userdata. user for member fn pointers only */ +SWIGRUNTIME void SWIG_Lua_NewPackedObj(lua_State* L,void* ptr,size_t size,swig_type_info *type) +{ + swig_lua_rawdata* raw; + assert(ptr); /* not acceptable to pass in a NULL value */ + raw=(swig_lua_rawdata*)lua_newuserdata(L,sizeof(swig_lua_rawdata)-1+size); /* alloc data */ + raw->type=type; + raw->own=0; + memcpy(raw->data,ptr,size); /* copy the data */ + _SWIG_Lua_AddMetatable(L,type); /* add metatable */ +} + +/* converts a packed userdata. user for member fn pointers only */ +SWIGRUNTIME int SWIG_Lua_ConvertPacked(lua_State* L,int index,void* ptr,size_t size,swig_type_info *type) +{ + swig_lua_rawdata* raw; + raw=(swig_lua_rawdata*)lua_touserdata(L,index); /* get data */ + if (!raw) return SWIG_ERROR; /* error */ + if (type==0 || type==raw->type) /* void* or identical type */ + { + memcpy(ptr,raw->data,size); /* copy it */ + return SWIG_OK; /* ok */ + } + return SWIG_ERROR; /* error */ +} + +/* a function to get the typestring of a piece of data */ +SWIGRUNTIME const char *SWIG_Lua_typename(lua_State *L, int tp) +{ + swig_lua_userdata* usr; + if (lua_isuserdata(L,tp)) + { + usr=(swig_lua_userdata*)lua_touserdata(L,1); /* get data */ + if (usr && usr->type && usr->type->str) + return usr->type->str; + return "userdata (unknown type)"; + } + return lua_typename(L,lua_type(L,tp)); +} + +/* lua callable function to get the userdata's type */ +SWIGRUNTIME int SWIG_Lua_type(lua_State* L) +{ +/* swig_lua_userdata* usr; + if (!lua_isuserdata(L,1)) /* just in case */ + /* return 0; /* nil reply */ + /*usr=(swig_lua_userdata*)lua_touserdata(L,1); /* get data */ + /*lua_pushstring(L,usr->type->name); + return 1;*/ + lua_pushstring(L,SWIG_Lua_typename(L,1)); + return 1; +} + +/* lua callable function to compare userdata's value +the issue is that two userdata may point to the same thing +but to lua, they are different objects */ +SWIGRUNTIME int SWIG_Lua_equal(lua_State* L) +{ + int result; + swig_lua_userdata *usr1,*usr2; + if (!lua_isuserdata(L,1) || !lua_isuserdata(L,2)) /* just in case */ + return 0; /* nil reply */ + usr1=(swig_lua_userdata*)lua_touserdata(L,1); /* get data */ + usr2=(swig_lua_userdata*)lua_touserdata(L,2); /* get data */ + /*result=(usr1->ptr==usr2->ptr && usr1->type==usr2->type); only works if type is the same*/ + result=(usr1->ptr==usr2->ptr); + lua_pushboolean(L,result); + return 1; +} + + + + +/* ----------------------------------------------------------------------------- + * global variable support code: class/struct typemap functions + * ----------------------------------------------------------------------------- */ + +/* Install Constants */ +SWIGINTERN void +SWIG_Lua_InstallConstants(lua_State* L, swig_lua_const_info constants[]) { + int i; + for (i = 0; constants[i].type; i++) { + switch(constants[i].type) { + case SWIG_LUA_INT: + lua_pushstring(L,constants[i].name); + lua_pushnumber(L,(lua_Number)constants[i].lvalue); + lua_rawset(L,-3); + break; + case SWIG_LUA_FLOAT: + lua_pushstring(L,constants[i].name); + lua_pushnumber(L,(lua_Number)constants[i].dvalue); + lua_rawset(L,-3); + break; + case SWIG_LUA_CHAR: + lua_pushstring(L,constants[i].name); + lua_pushfstring(L,"%c",(char)constants[i].lvalue); + lua_rawset(L,-3); + break; + case SWIG_LUA_STRING: + lua_pushstring(L,constants[i].name); + lua_pushstring(L,(char *) constants[i].pvalue); + lua_rawset(L,-3); + break; + case SWIG_LUA_POINTER: + lua_pushstring(L,constants[i].name); + SWIG_NewPointerObj(L,constants[i].pvalue, *(constants[i]).ptype,0); + lua_rawset(L,-3); + break; + case SWIG_LUA_BINARY: + lua_pushstring(L,constants[i].name); + SWIG_NewMemberObj(L,constants[i].pvalue,constants[i].lvalue,*(constants[i]).ptype); + lua_rawset(L,-3); + break; + default: + break; + } + } +} + +#ifdef __cplusplus +} +#endif + +/* ------------------------------ end luarun.swg ------------------------------ */ diff --git a/devtools/swigwin-1.3.34/Lib/lua/luaruntime.swg b/devtools/swigwin-1.3.34/Lib/lua/luaruntime.swg new file mode 100644 index 0000000..04f1adf --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/lua/luaruntime.swg @@ -0,0 +1,77 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * luaruntime.swg + * + * all the runtime code for . + * ----------------------------------------------------------------------------- */ + +%runtime "swigrun.swg"; /* Common C API type-checking code */ +%runtime "luarun.swg"; /* Lua runtime stuff */ + +%insert(initbeforefunc) "swiginit.swg" + +%insert(initbeforefunc) %{ + +/* Forward declaration of where the user's %init{} gets inserted */ +void SWIG_init_user(lua_State* L ); + +#ifdef __cplusplus +extern "C" { +#endif +/* this is the initialization function + added at the very end of the code + the function is always called SWIG_init, but an eariler #define will rename it +*/ +SWIGEXPORT int SWIG_init(lua_State* L) +{ + int i; + /* start with global table */ + lua_pushvalue(L,LUA_GLOBALSINDEX); + /* SWIG's internal initalisation */ + SWIG_InitializeModule((void*)L); + SWIG_PropagateClientData(); + /* add a global fn */ + SWIG_Lua_add_function(L,"swig_type",SWIG_Lua_type); + SWIG_Lua_add_function(L,"swig_equals",SWIG_Lua_equal); + /* begin the module (its a table with the same name as the module) */ + SWIG_Lua_module_begin(L,SWIG_name); + /* add commands/functions */ + for (i = 0; swig_commands[i].name; i++){ + SWIG_Lua_module_add_function(L,swig_commands[i].name,swig_commands[i].func); + } + /* add variables */ + for (i = 0; swig_variables[i].name; i++){ + SWIG_Lua_module_add_variable(L,swig_variables[i].name,swig_variables[i].get,swig_variables[i].set); + } + /* set up base class pointers (the hierachy) */ + for (i = 0; swig_types[i]; i++){ + if (swig_types[i]->clientdata){ + SWIG_Lua_init_base_class(L,(swig_lua_class*)(swig_types[i]->clientdata)); + } + } + /* additional registration structs & classes in lua */ + for (i = 0; swig_types[i]; i++){ + if (swig_types[i]->clientdata){ + SWIG_Lua_class_register(L,(swig_lua_class*)(swig_types[i]->clientdata)); + } + } + /* constants */ + SWIG_Lua_InstallConstants(L,swig_constants); + /* invoke user-specific initialization */ + SWIG_init_user(L); + /* end module */ + lua_pop(L,1); /* tidy stack (remove module table)*/ + lua_pop(L,1); /* tidy stack (remove global table)*/ + return 1; +} + +#ifdef __cplusplus +} +#endif + +%} + +/* Note: the initialization function is closed after all code is generated */ + diff --git a/devtools/swigwin-1.3.34/Lib/lua/luatypemaps.swg b/devtools/swigwin-1.3.34/Lib/lua/luatypemaps.swg new file mode 100644 index 0000000..51f96b0 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/lua/luatypemaps.swg @@ -0,0 +1,353 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * luatypemaps.swg + * + * basic typemaps for Lua. + * ----------------------------------------------------------------------------- */ + +/* ----------------------------------------------------------------------------- + * standard typemaps + * ----------------------------------------------------------------------------- */ +/* NEW LANGUAGE NOTE: + the 'checkfn' param is something that I added for typemap(in) + it is an optional fn call to check the type of the lua object + the fn call must be of the form + int checkfn(lua_State *L, int index); + and return 1/0 depending upon if this is the correct type + For the typemap(out), an additional SWIG_arg parmeter must be incremented + to reflect the number of values returned (normally SWIG_arg++; will do) +*/ +// numbers +%typemap(in,checkfn="lua_isnumber") int,short,long, + unsigned int,unsigned short,unsigned long, + signed char,unsigned char, + float,double +%{$1 = ($type)lua_tonumber(L, $input);%} + +%typemap(out) int,short,long, + unsigned int,unsigned short,unsigned long, + signed char,unsigned char, + float,double +%{ lua_pushnumber(L, (lua_Number) $1); SWIG_arg++;%} + +// we must also provide typemaps for privitives by const reference: +// given a function: +// int intbyref(const int& i); +// SWIG assumes that this code will need a pointer to int to be passed in +// (this might be ok for objects by const ref, but not for numeric primitives) +// therefore we add a set of typemaps to fix this (for both in & out) +%typemap(in,checkfn="lua_isnumber") const int&($basetype temp) +%{ temp=($basetype)lua_tonumber(L,$input); $1=&temp;%} + +%typemap(out) const int& +%{ lua_pushnumber(L, (lua_Number) *$1); SWIG_arg++;%} + +// for the other numbers we can just use an apply statement to cover them +%apply const int & {const short&,const long&, + const unsigned int&,const unsigned short&,const unsigned long&, + const signed char&,const unsigned char&, + const float&,const double&}; + +/* enums have to be handled slightly differently + VC++ .net will not allow a cast from lua_Number(double) to enum directly. +*/ +%typemap(in,checkfn="lua_isnumber") enum SWIGTYPE +%{$1 = ($type)(int)lua_tonumber(L, $input);%} + +%typemap(out) enum SWIGTYPE +%{ lua_pushnumber(L, (lua_Number)(int)($1)); SWIG_arg++;%} + +// and const refs +%typemap(in,checkfn="lua_isnumber") const enum SWIGTYPE &($basetype temp) +%{ temp=($basetype)(int)lua_tonumber(L,$input); $1=&temp;%} +%typemap(out) const enum SWIGTYPE & +%{ lua_pushnumber(L, (lua_Number) *$1); SWIG_arg++;%} + + +// boolean (which is a special type in lua) +// note: lua_toboolean() returns 1 or 0 +// note: 1 & 0 are not booleans in lua, only true & false +%typemap(in,checkfn="lua_isboolean") bool +%{$1 = (lua_toboolean(L, $input)!=0);%} + +%typemap(out) bool +%{ lua_pushboolean(L,(int)$1); SWIG_arg++;%} + +// for const bool&, SWIG treats this as a const bool* so we must dereference it +%typemap(in,checkfn="lua_isboolean") const bool& (bool temp) +%{temp=lua_toboolean(L, $input) ? true : false; + $1=&temp;%} + +%typemap(out) const bool& +%{ lua_pushboolean(L,(int)*$1); SWIG_arg++;%} + +// strings (char* and char[]) +%typemap(in,checkfn="lua_isstring") const char*, char* +%{$1 = ($ltype)lua_tostring(L, $input);%} + +%typemap(in,checkfn="lua_isstring") const char[ANY], char[ANY] +%{$1 = ($ltype)lua_tostring(L, $input);%} + +%typemap(out) const char*, char* +%{ lua_pushstring(L,(const char*)$1); SWIG_arg++;%} + +%typemap(out) const char[ANY], char[ANY] +%{ lua_pushstring(L,(const char*)$1); SWIG_arg++;%} + +// char's +// currently treating chars as small strings, not as numbers +// (however signed & unsigned char's are numbers...) +%typemap(in,checkfn="lua_isstring") char +%{$1 = (lua_tostring(L, $input))[0];%} + +%typemap(out) char +%{ lua_pushfstring(L,"%c",$1); SWIG_arg++;%} + +// by const ref +%typemap(in,checkfn="lua_isstring") const char& (char temp) +%{temp = (lua_tostring(L, $input))[0]; $1=&temp;%} + +%typemap(out) const char& +%{ lua_pushfstring(L,"%c",*$1); SWIG_arg++;%} + +// pointers and references +// under SWIG rules, it is ok, to have a pass in a lua nil, +// it should be converted to a SWIG NULL. +// This will only be allowed for pointers & arrays, not refs or by value +// the checkfn lua_isuserdata will only work for userdata +// the checkfn SWIG_isptrtype will work for both userdata and nil's +%typemap(in,checkfn="SWIG_isptrtype") SWIGTYPE*,SWIGTYPE[] +%{ + if (!SWIG_IsOK(SWIG_ConvertPtr(L,$input,(void**)&$1,$descriptor,0))){ + SWIG_fail_ptr("$symname",$argnum,$descriptor); + } +%} + +%typemap(in,checkfn="lua_isuserdata") SWIGTYPE& +%{ + if (!SWIG_IsOK(SWIG_ConvertPtr(L,$input,(void**)&$1,$descriptor,0))){ + SWIG_fail_ptr("$symname",$argnum,$descriptor); + } +%} + +// out is simple +%typemap(out) SWIGTYPE*,SWIGTYPE& +%{SWIG_NewPointerObj(L,$1,$descriptor,$owner); SWIG_arg++; %} + +// dynamic casts +// this uses the SWIG_TypeDynamicCast() which relies on RTTI to find out what the pointer really is +// the we return it as the correct type +%typemap(out) SWIGTYPE *DYNAMIC, + SWIGTYPE &DYNAMIC +{ + swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1); + SWIG_NewPointerObj(L,(void*)$1,ty,$owner); SWIG_arg++; +} + + +// passing objects by value +// SWIG_ConvertPtr wants an object pointer (the $<ype argp) +// then dereferences it to get the object +%typemap(in,checkfn="lua_isuserdata") SWIGTYPE ($<ype argp) +%{ + if (!SWIG_IsOK(SWIG_ConvertPtr(L,$input,(void**)&argp,$&descriptor,0))){ + SWIG_fail_ptr("$symname",$argnum,$&descriptor); + } + $1 = *argp; +%} + +// Also needed for object ptrs by const ref +// eg const A* ref_pointer(A* const& a); +// found in mixed_types.i +%typemap(in,checkfn="lua_isuserdata") SWIGTYPE* const &($*ltype temp) +%{temp=($*ltype)SWIG_MustGetPtr(L,$input,$*descriptor,0,$argnum,"$symname"); +$1=&temp;%} + + +// Primitive types--return by value +// must make a new object, copy the data & return the new object +// Note: the brackets are {...} and not %{..%}, because we want them to be included in the wrapper +// this is because typemap(out) does not support local variables, like in typemap(in) does +// and we need the $&1_ltype resultptr; to be declared +#ifdef __cplusplus +%typemap(out) SWIGTYPE +{ + $&1_ltype resultptr = new $1_ltype(($1_ltype &) $1); + SWIG_NewPointerObj(L,(void *) resultptr,$&1_descriptor,1); SWIG_arg++; +} +#else +%typemap(out) SWIGTYPE +{ + $&1_ltype resultptr; + resultptr = ($&1_ltype) malloc(sizeof($1_type)); + memmove(resultptr, &$1, sizeof($1_type)); + SWIG_NewPointerObj(L,(void *) resultptr,$&1_descriptor,1); SWIG_arg++; +} +#endif + +// member function pointer +// a member fn ptr is not 4 bytes like a normal pointer, but 8 bytes (at least on mingw) +// so the standard wrappering cannot be done +// nor can you cast a member function pointer to a void* (obviously) +// therefore a special wrappering functions SWIG_ConvertMember() & SWIG_NewMemberObj() were written +#ifdef __cplusplus +%typemap(in,checkfn="lua_isuserdata") SWIGTYPE (CLASS::*) +%{ + if (!SWIG_IsOK(SWIG_ConvertMember(L,$input,(void*)(&$1),sizeof($type),$descriptor))) + SWIG_fail_ptr("$symname",$argnum,$descriptor); +%} + +%typemap(out) SWIGTYPE (CLASS::*) +%{ + SWIG_NewMemberObj(L,(void*)(&$1),sizeof($type),$descriptor); SWIG_arg++; +%} +#endif + + +// void (must be empty without the SWIG_arg++) +%typemap(out) void ""; + +/* void* is a special case +A function void fn(void*) should take any kind of pointer as a parameter (just like C/C++ does) +but if its an output, then it should be wrappered like any other SWIG object (using default typemap) +*/ +%typemap(in,checkfn="SWIG_isptrtype") void* +%{$1=($1_ltype)SWIG_MustGetPtr(L,$input,0,0,$argnum,"$symname");%} + +/* long long is another special case: +as lua only supports one numeric type (lua_Number), we will just +cast it to that & accept the loss of precision. +An alternative solution would be a long long struct or class +with the relevant operators. +*/ +%apply long {long long, signed long long, unsigned long long}; +%apply const long& {const long long&, const signed long long&, const unsigned long long&}; + +/* It is possible to also pass a lua_State* into a function, so +void fn(int a, float b, lua_State* s) is wrappable as +> fn(1,4.3) -- note: the state is implicitly passed in +*/ +%typemap(in, numinputs=0) lua_State* +%{$1 = L;%} + + + +/* ----------------------------------------------------------------------------- + * typecheck rules + * ----------------------------------------------------------------------------- */ +/* These are needed for the overloaded functions +These define the detection routines which will spot what +parmeters match which function +*/ + +// unfortunately lua only considers one type of number +// so all numbers (int,float,double) match +// you could add an advanced fn to get type & check if its integral +%typecheck(SWIG_TYPECHECK_INTEGER) + int, short, long, + unsigned int, unsigned short, unsigned long, + signed char, unsigned char, + long long, unsigned long long, signed long long, + const int &, const short &, const long &, + const unsigned int &, const unsigned short &, const unsigned long &, + const signed char&, const unsigned char&, + const long long &, const unsigned long long &, + enum SWIGTYPE, const enum SWIGTYPE&, + float, double, const float &, const double& +{ + $1 = lua_isnumber(L,$input); +} + +%typecheck(SWIG_TYPECHECK_BOOL) + bool, const bool & +{ + $1 = lua_isboolean(L,$input); +} + +// special check for a char (string of length 1) +%typecheck(SWIG_TYPECHECK_CHAR) char, const char& { + $1 = lua_isstring(L,$input) && (lua_strlen(L,$input)==1); +} + +%typecheck(SWIG_TYPECHECK_STRING) char *, char[] { + $1 = lua_isstring(L,$input); +} + +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE [] { + void *ptr; + if (SWIG_isptrtype(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $1_descriptor, 0)) { + $1 = 0; + } else { + $1 = 1; + } +} + +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE & { + void *ptr; + if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $1_descriptor, 0)) { + $1 = 0; + } else { + $1 = 1; + } +} + +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { + void *ptr; + if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $&1_descriptor, 0)) { + $1 = 0; + } else { + $1 = 1; + } +} + +%typecheck(SWIG_TYPECHECK_VOIDPTR) void * { + void *ptr; + if (SWIG_isptrtype(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, 0, 0)) { + $1 = 0; + } else { + $1 = 1; + } +} + +// Also needed for object ptrs by const ref +// eg const A* ref_pointer(A* const& a); +// found in mixed_types.i +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE* const & +{ + void *ptr; + if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $*descriptor, 0)) { + $1 = 0; + } else { + $1 = 1; + } +} + +/* ----------------------------------------------------------------------------- + * Others + * ----------------------------------------------------------------------------- */ + +// size_t (which is just a unsigned long) +%apply unsigned long { size_t }; +%apply const unsigned long & { const size_t & }; + + +/* ----------------------------------------------------------------------------- + * Specials + * ----------------------------------------------------------------------------- */ +// swig::LANGUAGE_OBJ was added to allow containers of native objects +// however its rather difficult to do this in lua, as you cannot hold pointers +// to native objects (they are held in the interpreter) +// therefore for now: just ignoring this feature +#ifdef __cplusplus +%ignore swig::LANGUAGE_OBJ; + +//%inline %{ +%{ +namespace swig { +typedef struct{} LANGUAGE_OBJ; +} +%} + +#endif // __cplusplus diff --git a/devtools/swigwin-1.3.34/Lib/lua/std_common.i b/devtools/swigwin-1.3.34/Lib/lua/std_common.i new file mode 100644 index 0000000..cee11e8 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/lua/std_common.i @@ -0,0 +1,5 @@ +%include <std_except.i> + +%apply size_t { std::size_t }; +%apply const size_t& { const std::size_t& }; + diff --git a/devtools/swigwin-1.3.34/Lib/lua/std_deque.i b/devtools/swigwin-1.3.34/Lib/lua/std_deque.i new file mode 100644 index 0000000..cb98f6c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/lua/std_deque.i @@ -0,0 +1 @@ +%include <std/_std_deque.i> diff --git a/devtools/swigwin-1.3.34/Lib/lua/std_except.i b/devtools/swigwin-1.3.34/Lib/lua/std_except.i new file mode 100644 index 0000000..95cbe8e --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/lua/std_except.i @@ -0,0 +1,43 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * Typemaps used by the STL wrappers that throw exceptions. + * These typemaps are used when methods are declared with an STL exception + * specification, such as: + * size_t at() const throw (std::out_of_range); + * + * std_except.i + * ----------------------------------------------------------------------------- */ + +%{ +#include <stdexcept> +%} +%include <exception.i> + +namespace std +{ + %ignore exception; // not sure if I should ignore this... + class exception + { + public: + exception() throw() { } + virtual ~exception() throw(); + virtual const char* what() const throw(); + }; +} + +// normally object whihc are thrown are returned to interpreter as errors +// (which potentally may have problems if they are not copied) +// therefore all classes based upon std::exception are converted to their strings & returned as errors +%typemap(throws) std::bad_exception "SWIG_exception(SWIG_RuntimeError, $1.what());" +%typemap(throws) std::domain_error "SWIG_exception(SWIG_ValueError, $1.what());" +%typemap(throws) std::exception "SWIG_exception(SWIG_SystemError, $1.what());" +%typemap(throws) std::invalid_argument "SWIG_exception(SWIG_ValueError, $1.what());" +%typemap(throws) std::length_error "SWIG_exception(SWIG_IndexError, $1.what());" +%typemap(throws) std::logic_error "SWIG_exception(SWIG_RuntimeError, $1.what());" +%typemap(throws) std::out_of_range "SWIG_exception(SWIG_IndexError, $1.what());" +%typemap(throws) std::overflow_error "SWIG_exception(SWIG_OverflowError, $1.what());" +%typemap(throws) std::range_error "SWIG_exception(SWIG_IndexError, $1.what());" +%typemap(throws) std::runtime_error "SWIG_exception(SWIG_RuntimeError, $1.what());" +%typemap(throws) std::underflow_error "SWIG_exception(SWIG_RuntimeError, $1.what());" diff --git a/devtools/swigwin-1.3.34/Lib/lua/std_map.i b/devtools/swigwin-1.3.34/Lib/lua/std_map.i new file mode 100644 index 0000000..dd22443 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/lua/std_map.i @@ -0,0 +1,63 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_map.i + * + * SWIG typemaps for std::map + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +// ------------------------------------------------------------------------ +// std::map +// ------------------------------------------------------------------------ + +%{ +#include <map> +#include <algorithm> +#include <stdexcept> +%} + +// exported class + +namespace std { + + template<class K, class T> class map { + // add typemaps here + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef K key_type; + typedef T mapped_type; + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + const T& get(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(const K& key, const T& x) { + (*self)[key] = x; + } + void del(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; +} diff --git a/devtools/swigwin-1.3.34/Lib/lua/std_pair.i b/devtools/swigwin-1.3.34/Lib/lua/std_pair.i new file mode 100644 index 0000000..1b20f74 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/lua/std_pair.i @@ -0,0 +1,45 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_pair.i + * + * std::pair typemaps for LUA + * ----------------------------------------------------------------------------- */ + +%{ +#include <utility> +%} +/* +A really cut down version of the pair class. + +this is not useful on its owns is it needs a %template definition with it + +eg. +namespace std { + %template(IntPair) pair<int, int>; + %template(make_IntPair) make_pair<int, int>; +} + + +*/ + + + +namespace std { + template <class T, class U > struct pair { + typedef T first_type; + typedef U second_type; + + pair(); + pair(T first, U second); + pair(const pair& p); + + T first; + U second; + }; + + template <class T, class U > + pair<T,U> make_pair(const T&,const U&); + +} diff --git a/devtools/swigwin-1.3.34/Lib/lua/std_string.i b/devtools/swigwin-1.3.34/Lib/lua/std_string.i new file mode 100644 index 0000000..50e7dae --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/lua/std_string.i @@ -0,0 +1,155 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_string.i + * + * std::string typemaps for LUA + * ----------------------------------------------------------------------------- */ + +%{ + #include <string> +%} +/* +Only std::string and const std::string& are typemaped +they are converted to the Lua strings automatically + +std::string& and std::string* are not +they must be explicitly managed (see below) + +eg. + +std::string test_value(std::string x) { + return x; +} + +can be used as + +s="hello world" +s2=test_value(s) +assert(s==s2) + +*/ + +%naturalvar std::string; + +/* +Bug report #1526022 by neomantra +Lua strings and std::string can contain embeded zero's +Therefore a standard out typemap should not be: + lua_pushstring(L,$1.c_str()); +but + lua_pushlstring(L,$1.data(),$1.size()); + +Similarly for getting the string + $1 = (char*)lua_tostring(L, $input); +becomes + $1.assign(lua_tostring(L,$input),lua_strlen(L,$input)); + +Not using: lua_tolstring() as this is only found in Lua 5.1 & not 5.0.2 +*/ + +%typemap(in,checkfn="lua_isstring") std::string +%{$1.assign(lua_tostring(L,$input),lua_strlen(L,$input));%} +%typemap(out) std::string +%{ lua_pushlstring(L,$1.data(),$1.size()); SWIG_arg++;%} + +%typemap(in,checkfn="lua_isstring") const std::string& (std::string temp) +%{temp.assign(lua_tostring(L,$input),lua_strlen(L,$input)); $1=&temp;%} + +%typemap(out) const std::string& +%{ lua_pushlstring(L,$1->data(),$1->size()); SWIG_arg++;%} + +// for throwing of any kind of string, string ref's and string pointers +// we convert all to lua strings +%typemap(throws) std::string,const std::string& +%{ lua_pushlstring(L,$1.data(),$1.size()); SWIG_fail;%} +%typemap(throws) std::string*,const std::string* +%{ lua_pushlstring(L,$1->data(),$1->size()); SWIG_fail;%} + +// and the typechecks +%typecheck(SWIG_TYPECHECK_STRING) std::string,const std::string& { + $1 = lua_isstring(L,$input); +} + +/* +std::string& can be wrappered, but you must inform SWIG if it is in or out + +eg: +void fn(std::string& str); +Is this an in/out/inout value? + +Therefore you need the usual +%apply (std::string& INOUT) {(std::string& str)}; +or +%apply std::string& INOUT {std::string& str}; +typemaps to tell SWIG what to do. +*/ + +%typemap(in) std::string &INPUT=const std::string &; +%typemap(in, numinputs=0) std::string &OUTPUT (std::string temp) +%{ $1 = &temp; %} +%typemap(argout) std::string &OUTPUT +%{ lua_pushlstring(L,$1->data(),$1->size()); SWIG_arg++;%} +%typemap(in) std::string &INOUT =const std::string &; +%typemap(argout) std::string &INOUT = std::string &OUTPUT; + +/* +For const std::string* and std::string* is not clear +is this a pointer or an array? + +Therefore just leaving it as is +(there is some rough code below which could be used if needed + +// SWIG wraps const ref's as pointer +// typemaps to deal with this and const ptrs +%typemap(in,checkfn="lua_isstring") + const std::string& INPUT(std::string temp), + const std::string* INPUT(std::string temp) +%{temp=(char*)lua_tostring(L, $input); $1=&temp;%} +%typemap(out) const std::string&, const std::string* +%{ lua_pushstring(L,$1->c_str()); SWIG_arg++;%} + +// the non-const pointer version +%typemap(in) std::string *INPUT=const std::string *INPUT; +%typemap(in, numinputs=0) std::string *OUTPUT (std::string temp) +%{ $1 = &temp; %} +%typemap(argout) std::string *OUTPUT +%{ lua_pushstring(L,$1->c_str()); SWIG_arg++;%} +%typemap(in) std::string *INOUT = std::string *INPUT; +%typemap(argout) std::string *INOUT = std::string *OUTPUT; + +*/ + +/* +A really cut down version of the string class + +This provides basic mapping of lua strings <-> std::string +and little else +(the std::string has a lot of unneeded functions anyway) + +note: no fn's taking the const string& +as this is overloaded by the const char* version +*/ +namespace std { + + class string { + public: + string(); + string(const char*); + //string(const string&); + unsigned int size() const; + unsigned int length() const; + bool empty() const; + // no support for operator[] + const char* c_str()const; + const char* data()const; + // assign does not return a copy of this object + // (no point in a scripting language) + void assign(const char*); + //void assign(const string&); + // no support for all the other features + // its probably better to do it in lua + }; +} + diff --git a/devtools/swigwin-1.3.34/Lib/lua/std_vector.i b/devtools/swigwin-1.3.34/Lib/lua/std_vector.i new file mode 100644 index 0000000..c677808 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/lua/std_vector.i @@ -0,0 +1,134 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_vector.i + * + * std::vector typemaps for LUA + * ----------------------------------------------------------------------------- */ + +%{ +#include <vector> +%} +%include <std_except.i> // the general exepctions +/* +A really cut down version of the vector class. + +Note: this does not match the true std::vector class +but instead is an approximate, so that SWIG knows how to wrapper it. +(Eg, all access is by value, not ref, as SWIG turns refs to pointers) + +And no support for iterators & insert/erase + +It would be useful to have a vector<->Lua table conversion routine + +*/ +namespace std { + + template<class T> + class vector { + public: + vector(); + vector(unsigned int); + vector(const vector&); + vector(unsigned int,T); + unsigned int size() const; + unsigned int max_size() const; + bool empty() const; + void clear(); + void push_back(T val); + void pop_back(); + T front()const; // only read front & back + T back()const; // not write to them + // operator [] given later: + + %extend // this is a extra bit of SWIG code + { + // [] is replaced by __getitem__ & __setitem__ + // simply throws a string, which causes a lua error + T __getitem__(unsigned int idx) throw (std::out_of_range) + { + if (idx>=self->size()) + throw std::out_of_range("in vector::__getitem__()"); + return (*self)[idx]; + } + void __setitem__(unsigned int idx,T val) throw (std::out_of_range) + { + if (idx>=self->size()) + throw std::out_of_range("in vector::__setitem__()"); + (*self)[idx]=val; + } + }; + }; + +} + +/* +Vector<->LuaTable fns +These look a bit like the array<->LuaTable fns +but are templated, not %defined +(you must have template support for STL) + +*/ +/* +%{ +// reads a table into a vector of numbers +// lua numbers will be cast into the type required (rounding may occur) +// return 0 if non numbers found in the table +// returns new'ed ptr if ok +template<class T> +std::vector<T>* SWIG_read_number_vector(lua_State* L,int index) +{ + int i=0; + std::vector<T>* vec=new std::vector<T>(); + while(1) + { + lua_rawgeti(L,index,i+1); + if (!lua_isnil(L,-1)) + { + lua_pop(L,1); + break; // finished + } + if (!lua_isnumber(L,-1)) + { + lua_pop(L,1); + delete vec; + return 0; // error + } + vec->push_back((T)lua_tonumber(L,-1)); + lua_pop(L,1); + ++i; + } + return vec; // ok +} +// writes a vector of numbers out as a lua table +template<class T> +int SWIG_write_number_vector(lua_State* L,std::vector<T> *vec) +{ + lua_newtable(L); + for(int i=0;i<vec->size();++i) + { + lua_pushnumber(L,(double)((*vec)[i])); + lua_rawseti(L,-2,i+1);// -1 is the number, -2 is the table + } +} +%} + +// then the typemaps + +%define SWIG_TYPEMAP_NUM_VECTOR(T) + +// in +%typemap(in) std::vector<T> *INPUT +%{ $1 = SWIG_read_number_vector<T>(L,$input); + if (!$1) SWIG_fail;%} + +%typemap(freearg) std::vector<T> *INPUT +%{ delete $1;%} + +// out +%typemap(argout) std::vector<T> *OUTPUT +%{ SWIG_write_number_vector(L,$1); SWIG_arg++; %} + +%enddef +*/ diff --git a/devtools/swigwin-1.3.34/Lib/lua/stl.i b/devtools/swigwin-1.3.34/Lib/lua/stl.i new file mode 100644 index 0000000..b8d7a65 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/lua/stl.i @@ -0,0 +1,13 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * stl.i + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <std_string.i> +%include <std_vector.i> +%include <std_map.i> +%include <std_pair.i> + diff --git a/devtools/swigwin-1.3.34/Lib/lua/typemaps.i b/devtools/swigwin-1.3.34/Lib/lua/typemaps.i new file mode 100644 index 0000000..2840780 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/lua/typemaps.i @@ -0,0 +1,541 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * typemaps.swg + * + * SWIG Library file containing the main typemap code to support Lua modules. + * ----------------------------------------------------------------------------- */ + +/* ----------------------------------------------------------------------------- + * Basic inout typemaps + * ----------------------------------------------------------------------------- */ +/* +These provide the basic ability for passing in & out of standard numeric data types +(int,long,float,double, etc) + +The basic code looks like this: + +%typemap(in,checkfn="lua_isnumber") int *INPUT(int temp), int &INPUT(int temp) +%{ temp = (int)lua_tonumber(L,$input); + $1 = &temp; %} + +%typemap(in, numinputs=0) int *OUTPUT (int temp) +%{ $1 = &temp; %} + +%typemap(argout) int *OUTPUT +%{ lua_pushnumber(L, (double) *$1); SWIG_arg++;%} + +%typemap(in) int *INOUT = int *INPUT; +%typemap(argout) int *INOUT = int *OUTPUT; + +However the code below is a mixture of #defines & such, so nowhere as easy to read + +To make you code work correctly its not just a matter of %including this file +You also have to give SWIG the hints on which to use where + +eg +extern int add_pointer(int* a1,int* a2); // a1 & a2 are pointer values to be added +extern void swap(int* s1, int* s2); // does the swap + +You will need to either change the argument names +extern int add_pointer(int* INPUT,int* INPUT); + +or provide a %apply statement + +%apply int* INOUT{ int *s1, int *s2 }; + // if SWIG sees int* s1, int* s2, assume they are inout params +*/ + + +%define SWIG_NUMBER_TYPEMAP(TYPE) +%typemap(in,checkfn="lua_isnumber") TYPE *INPUT($*ltype temp), TYPE &INPUT($*ltype temp) +%{ temp = ($*ltype)lua_tonumber(L,$input); + $1 = &temp; %} +%typemap(in, numinputs=0) TYPE *OUTPUT ($*ltype temp) +%{ $1 = &temp; %} +%typemap(argout) TYPE *OUTPUT +%{ lua_pushnumber(L, (lua_Number) *$1); SWIG_arg++;%} +%typemap(in) TYPE *INOUT = TYPE *INPUT; +%typemap(argout) TYPE *INOUT = TYPE *OUTPUT; +%typemap(in) TYPE &OUTPUT = TYPE *OUTPUT; +%typemap(argout) TYPE &OUTPUT = TYPE *OUTPUT; +%typemap(in) TYPE &INOUT = TYPE *INPUT; +%typemap(argout) TYPE &INOUT = TYPE *OUTPUT; +// const version (the $*ltype is the basic number without ptr or const's) +%typemap(in,checkfn="lua_isnumber") const TYPE *INPUT($*ltype temp) +%{ temp = ($*ltype)lua_tonumber(L,$input); + $1 = &temp; %} +%enddef + +// now the code +SWIG_NUMBER_TYPEMAP(int); SWIG_NUMBER_TYPEMAP(unsigned int); SWIG_NUMBER_TYPEMAP(signed int); +SWIG_NUMBER_TYPEMAP(short); SWIG_NUMBER_TYPEMAP(unsigned short); SWIG_NUMBER_TYPEMAP(signed short); +SWIG_NUMBER_TYPEMAP(long); SWIG_NUMBER_TYPEMAP(unsigned long); SWIG_NUMBER_TYPEMAP(signed long); +SWIG_NUMBER_TYPEMAP(float); +SWIG_NUMBER_TYPEMAP(double); +SWIG_NUMBER_TYPEMAP(enum SWIGTYPE); +// also for long longs's +SWIG_NUMBER_TYPEMAP(long long); SWIG_NUMBER_TYPEMAP(unsigned long long); SWIG_NUMBER_TYPEMAP(signed long long); + +// note we dont do char, as a char* is probably a string not a ptr to a single char + +/* ----------------------------------------------------------------------------- + * Basic Array typemaps + * ----------------------------------------------------------------------------- */ +/* +I have no idea why this kind of code does not exist in SWIG as standard, +but here is it. +This code will convert to/from 1D numeric arrays. +In order to reduce code bloat, there are a few macros +and quite a few functions defined +(unfortunately this makes it a lot less clear) + +assuming we have functions +void process_array(int arr[3]); // nice fixed size array +void process_var_array(float arr[],int len); // variable sized array +void process_var_array_inout(double arr*,int len); // variable sized array + // data passed in & out +void process_enum_inout_array_var(enum Days *arrinout, int len); // using enums +void return_array_5(int arrout[5]); // out array only + +in order to wrap them correctly requires a typemap + +// inform SWIG of the correct typemap +// For fixed length, you must specify it as <type> INPUT[ANY] +%apply (int INPUT[ANY]) {(int arr[3])}; +// variable length arrays are just the same +%apply (float INPUT[],int) {(float arr[],int len)}; +// it is also ok, to map the TYPE* instead of a TYPE[] +%apply (double *INOUT,int) {(double arr*,int len)}; +// for the enum's you must use enum SWIGTYPE +%apply (enum SWIGTYPE *INOUT,int) {(enum Days *arrinout, int len)}; +// fixed length out if also fine +%apply (int OUTPUT[ANY]) {(int arrout[5])}; + +Generally, you could use %typemap(...)=... +but the %apply is neater & easier + +a few things of note: +* all Lua tables are indexed from 1, all C/C++ arrays are indexed from 0 + therefore t={6,5,3} -- t[1]==6, t[2]==5, t[3]==3 + when passed to process_array(int arr[3]) becomes + arr[0]==6, arr[1]==5, arr[2]==3 +* for OUTPUT arrays, no array need be passed in, the fn will return a Lua table + so for the above mentioned return_array_5() would look like + arr=return_array_5() -- no parameters passed in +* for INOUT arrays, a table must be passed in, and a new table will be returned + (this is consistant with the way that numbers are processed) + if you want just use + arr={...} + arr=process_var_array_inout(arr) -- arr is replaced by the new version + +The following are not yet supported: +* variable length output only array (inout's work ok) +* multidimentional arrays +* arrays of objects/structs +* arrays of pointers + +*/ + +/* +The internals of the array managment stuff +helper fns/macros +SWIG_ALLOC_ARRAY(TYPE,LEN) // returns a typed array TYPE[LEN] +SWIG_FREE_ARRAY(PTR) // delete the ptr (if not zero) + +// counts the specified table & gets the size +// integer version +int SWIG_itable_size(lua_State* L, int index); +// other version +int SWIG_table_size(lua_State* L, int index); + +SWIG_DECLARE_TYPEMAP_ARR_FN(NAME,TYPE) +// this fn declares up 4 functions for helping to read/write tables +// these can then be called by the macros ... +// all assume the table is an integer indexes from 1 +// but the C array is a indexed from 0 + // created a fixed size array, reads the specified table + // and then fills the array with numbers + // returns ptr to the array if ok, or 0 for error + // (also pushes a error message to the stack) +TYPE* SWIG_get_NAME_num_array_fixed(lua_State* L, int index, int size); + // as per SWIG_get_NAME_num_array_fixed() + // but reads the entire table & creates an array of the correct size + // (if the table is empty, it returns an error rather than a zero length array) +TYPE* SWIG_get_NAME_num_array_var(lua_State* L, int index, int* size); + // writes a table to Lua with all the specified numbers +void SWIG_write_NAME_num_array(lua_State* L,TYPE *array,int size); + // read the specified table, and fills the array with numbers + // returns 1 of ok (only fails if it doesnt find numbers) + // helper fn (called by SWIG_get_NAME_num_array_*() fns) +int SWIG_read_NAME_num_array(lua_State* L,int index,TYPE *array,int size); + +*/ + +/* Reported that you don't need to check for NULL for delete & free +There probably is some compiler that its not true for, so the code is left here just in case. +#ifdef __cplusplus +#define SWIG_ALLOC_ARRAY(TYPE,LEN) new TYPE[LEN] +#define SWIG_FREE_ARRAY(PTR) if(PTR){delete[] PTR;} +#else +#define SWIG_ALLOC_ARRAY(TYPE,LEN) (TYPE *)malloc(LEN*sizeof(TYPE)) +#define SWIG_FREE_ARRAY(PTR) if(PTR){free(PTR);} +#endif +*/ +%{ +#ifdef __cplusplus /* generic alloc/dealloc fns*/ +#define SWIG_ALLOC_ARRAY(TYPE,LEN) new TYPE[LEN] +#define SWIG_FREE_ARRAY(PTR) delete[] PTR; +#else +#define SWIG_ALLOC_ARRAY(TYPE,LEN) (TYPE *)malloc(LEN*sizeof(TYPE)) +#define SWIG_FREE_ARRAY(PTR) free(PTR); +#endif +/* counting the size of arrays:*/ +int SWIG_itable_size(lua_State* L, int index) +{ + int n=0; + while(1){ + lua_rawgeti(L,index,n+1); + if (lua_isnil(L,-1))break; + ++n; + lua_pop(L,1); + } + lua_pop(L,1); + return n; +} + +int SWIG_table_size(lua_State* L, int index) +{ + int n=0; + lua_pushnil(L); /* first key*/ + while (lua_next(L, index) != 0) { + ++n; + lua_pop(L, 1); /* removes `value'; keeps `key' for next iteration*/ + } + return n; +} + +/* super macro to declare array typemap helper fns */ +#define SWIG_DECLARE_TYPEMAP_ARR_FN(NAME,TYPE)\ + int SWIG_read_##NAME##_num_array(lua_State* L,int index,TYPE *array,int size){\ + int i;\ + for (i = 0; i < size; i++) {\ + lua_rawgeti(L,index,i+1);\ + if (lua_isnumber(L,-1)){\ + array[i] = (TYPE)lua_tonumber(L,-1);\ + } else {\ + lua_pop(L,1);\ + return 0;\ + }\ + lua_pop(L,1);\ + }\ + return 1;\ + }\ + static TYPE* SWIG_get_##NAME##_num_array_fixed(lua_State* L, int index, int size){\ + TYPE *array;\ + if (!lua_istable(L,index) || SWIG_itable_size(L,index) != size) {\ + lua_pushfstring(L,"expected a table of size %d",size);\ + return 0;\ + }\ + array=SWIG_ALLOC_ARRAY(TYPE,size);\ + if (!SWIG_read_##NAME##_num_array(L,index,array,size)){\ + lua_pushstring(L,"table must contain numbers");\ + SWIG_FREE_ARRAY(array);\ + return 0;\ + }\ + return array;\ + }\ + static TYPE* SWIG_get_##NAME##_num_array_var(lua_State* L, int index, int* size)\ + {\ + TYPE *array;\ + if (!lua_istable(L,index)) {\ + lua_pushstring(L,"expected a table");\ + return 0;\ + }\ + *size=SWIG_itable_size(L,index);\ + if (*size<1){\ + lua_pushstring(L,"table appears to be empty");\ + return 0;\ + }\ + array=SWIG_ALLOC_ARRAY(TYPE,*size);\ + if (!SWIG_read_##NAME##_num_array(L,index,array,*size)){\ + lua_pushstring(L,"table must contain numbers");\ + SWIG_FREE_ARRAY(array);\ + return 0;\ + }\ + return array;\ + }\ + void SWIG_write_##NAME##_num_array(lua_State* L,TYPE *array,int size){\ + int i;\ + lua_newtable(L);\ + for (i = 0; i < size; i++){\ + lua_pushnumber(L,(lua_Number)array[i]);\ + lua_rawseti(L,-2,i+1);/* -1 is the number, -2 is the table*/ \ + }\ + } +%} + +/* +This is one giant macro to define the typemaps & the helpers +for array handling +*/ +%define SWIG_TYPEMAP_NUM_ARR(NAME,TYPE) +%{SWIG_DECLARE_TYPEMAP_ARR_FN(NAME,TYPE);%} + +// fixed size array's +%typemap(in) TYPE INPUT[ANY] +%{ $1 = SWIG_get_##NAME##_num_array_fixed(L,$input,$1_dim0); + if (!$1) SWIG_fail;%} + +%typemap(freearg) TYPE INPUT[ANY] +%{ SWIG_FREE_ARRAY($1);%} + +// variable size array's +%typemap(in) (TYPE *INPUT,int) +%{ $1 = SWIG_get_##NAME##_num_array_var(L,$input,&$2); + if (!$1) SWIG_fail;%} + +%typemap(freearg) (TYPE *INPUT,int) +%{ SWIG_FREE_ARRAY($1);%} + +// out fixed arrays +%typemap(in,numinputs=0) TYPE OUTPUT[ANY] +%{ $1 = SWIG_ALLOC_ARRAY(TYPE,$1_dim0); %} + +%typemap(argout) TYPE OUTPUT[ANY] +%{ SWIG_write_##NAME##_num_array(L,$1,$1_dim0); SWIG_arg++; %} + +%typemap(freearg) TYPE OUTPUT[ANY] +%{ SWIG_FREE_ARRAY($1); %} + +// inout fixed arrays +%typemap(in) TYPE INOUT[ANY]=TYPE INPUT[ANY]; +%typemap(argout) TYPE INOUT[ANY]=TYPE OUTPUT[ANY]; +%typemap(freearg) TYPE INOUT[ANY]=TYPE INPUT[ANY]; +// inout variable arrays +%typemap(in) (TYPE *INOUT,int)=(TYPE *INPUT,int); +%typemap(argout) (TYPE *INOUT,int) +%{ SWIG_write_##NAME##_num_array(L,$1,$2); SWIG_arg++; %} +%typemap(freearg) (TYPE *INOUT,int)=(TYPE *INPUT,int); + +// TODO out variable arrays (is there a standard form for such things?) +%enddef + +// the following line of code +// declares the C helper fns for the array typemaps +// as well as defining typemaps for +// fixed len arrays in & out, & variable length arrays in + +SWIG_TYPEMAP_NUM_ARR(int,int); +SWIG_TYPEMAP_NUM_ARR(uint,unsigned int); +SWIG_TYPEMAP_NUM_ARR(short,short); +SWIG_TYPEMAP_NUM_ARR(ushort,unsigned short); +SWIG_TYPEMAP_NUM_ARR(long,long); +SWIG_TYPEMAP_NUM_ARR(ulong,unsigned long); +SWIG_TYPEMAP_NUM_ARR(float,float); +SWIG_TYPEMAP_NUM_ARR(double,double); + +// again enums are a problem so they need their own type +// we use the int conversion routine & recast it +%typemap(in) enum SWIGTYPE INPUT[ANY] +%{ $1 = ($ltype)SWIG_get_int_num_array_fixed(L,$input,$1_dim0); + if (!$1) SWIG_fail;%} + +%typemap(freearg) enum SWIGTYPE INPUT[ANY] +%{ SWIG_FREE_ARRAY($1);%} + +// variable size array's +%typemap(in) (enum SWIGTYPE *INPUT,int) +%{ $1 = ($ltype)SWIG_get_int_num_array_var(L,$input,&$2); + if (!$1) SWIG_fail;%} + +%typemap(freearg) (enum SWIGTYPE *INPUT,int) +%{ SWIG_FREE_ARRAY($1);%} + +// out fixed arrays +%typemap(in,numinputs=0) enum SWIGTYPE OUTPUT[ANY] +%{ $1 = SWIG_ALLOC_ARRAY(enum SWIGTYPE,$1_dim0); %} + +%typemap(argout) enum SWIGTYPE OUTPUT[ANY] +%{ SWIG_write_int_num_array(L,(int*)$1,$1_dim0); SWIG_arg++; %} + +%typemap(freearg) enum SWIGTYPE OUTPUT[ANY] +%{ SWIG_FREE_ARRAY($1); %} + +// inout fixed arrays +%typemap(in) enum SWIGTYPE INOUT[ANY]=enum SWIGTYPE INPUT[ANY]; +%typemap(argout) enum SWIGTYPE INOUT[ANY]=enum SWIGTYPE OUTPUT[ANY]; +%typemap(freearg) enum SWIGTYPE INOUT[ANY]=enum SWIGTYPE INPUT[ANY]; +// inout variable arrays +%typemap(in) (enum SWIGTYPE *INOUT,int)=(enum SWIGTYPE *INPUT,int); +%typemap(argout) (enum SWIGTYPE *INOUT,int) +%{ SWIG_write_int_num_array(L,(int*)$1,$2); SWIG_arg++; %} +%typemap(freearg) (enum SWIGTYPE *INOUT,int)=(enum SWIGTYPE *INPUT,int); + + +/* Surprisingly pointer arrays are easier: +this is because all ptr arrays become void** +so only a few fns are needed & a few casts + +The function defined are + // created a fixed size array, reads the specified table + // and then fills the array with pointers (checking the type) + // returns ptr to the array if ok, or 0 for error + // (also pushes a error message to the stack) +void** SWIG_get_ptr_array_fixed(lua_State* L, int index, int size,swig_type_info *type); + // as per SWIG_get_ptr_array_fixed() + // but reads the entire table & creates an array of the correct size + // (if the table is empty, it returns an error rather than a zero length array) +void** SWIG_get_ptr_array_var(lua_State* L, int index, int* size,swig_type_info *type); + // writes a table to Lua with all the specified pointers + // all pointers have the ownership value 'own' (normally 0) +void SWIG_write_ptr_array(lua_State* L,void **array,int size,int own); + // read the specified table, and fills the array with ptrs + // returns 1 of ok (only fails if it doesnt find correct type of ptrs) + // helper fn (called by SWIG_get_ptr_array_*() fns) +int SWIG_read_ptr_array(lua_State* L,int index,void **array,int size,swig_type_info *type); + +The key thing to remember is that it is assumed that there is no +modification of pointers ownership in the arrays + +eg A fn: +void pointers_in(TYPE* arr[],int len); +will make copies of the pointer into a temp array and then pass it into the fn +Lua does not remeber that this fn held the pointers, so it is not safe to keep +these pointers until later + +eg A fn: +void pointers_out(TYPE* arr[3]); +will return a table containing three pointers +however these pointers are NOT owned by Lua, merely borrowed +so if the C/C++ frees then Lua is not aware + +*/ + +%{ +int SWIG_read_ptr_array(lua_State* L,int index,void **array,int size,swig_type_info *type){ + int i; + for (i = 0; i < size; i++) { + lua_rawgeti(L,index,i+1); + if (!lua_isuserdata(L,-1) || SWIG_ConvertPtr(L,-1,&array[i],type,0)==-1){ + lua_pop(L,1); + return 0; + } + lua_pop(L,1); + } + return 1; +} +static void** SWIG_get_ptr_array_fixed(lua_State* L, int index, int size,swig_type_info *type){ + void **array; + if (!lua_istable(L,index) || SWIG_itable_size(L,index) != size) { + lua_pushfstring(L,"expected a table of size %d",size); + return 0; + } + array=SWIG_ALLOC_ARRAY(void*,size); + if (!SWIG_read_ptr_array(L,index,array,size,type)){ + lua_pushfstring(L,"table must contain pointers of type %s",type->name); + SWIG_FREE_ARRAY(array); + return 0; + } + return array; +} +static void** SWIG_get_ptr_array_var(lua_State* L, int index, int* size,swig_type_info *type){ + void **array; + if (!lua_istable(L,index)) { + lua_pushstring(L,"expected a table"); + return 0; + } + *size=SWIG_itable_size(L,index); + if (*size<1){ + lua_pushstring(L,"table appears to be empty"); + return 0; + } + array=SWIG_ALLOC_ARRAY(void*,*size); + if (!SWIG_read_ptr_array(L,index,array,*size,type)){ + lua_pushfstring(L,"table must contain pointers of type %s",type->name); + SWIG_FREE_ARRAY(array); + return 0; + } + return array; +} +void SWIG_write_ptr_array(lua_State* L,void **array,int size,swig_type_info *type,int own){ + int i; + lua_newtable(L); + for (i = 0; i < size; i++){ + SWIG_NewPointerObj(L,array[i],type,own); + lua_rawseti(L,-2,i+1);/* -1 is the number, -2 is the table*/ + } +} +%} + +// fixed size array's +%typemap(in) SWIGTYPE* INPUT[ANY] +%{ $1 = ($ltype)SWIG_get_ptr_array_fixed(L,$input,$1_dim0,$*1_descriptor); + if (!$1) SWIG_fail;%} + +%typemap(freearg) SWIGTYPE* INPUT[ANY] +%{ SWIG_FREE_ARRAY($1);%} + +// variable size array's +%typemap(in) (SWIGTYPE **INPUT,int) +%{ $1 = ($ltype)SWIG_get_ptr_array_var(L,$input,&$2,$*1_descriptor); + if (!$1) SWIG_fail;%} + +%typemap(freearg) (SWIGTYPE **INPUT,int) +%{ SWIG_FREE_ARRAY($1);%} + +// out fixed arrays +%typemap(in,numinputs=0) SWIGTYPE* OUTPUT[ANY] +%{ $1 = SWIG_ALLOC_ARRAY($*1_type,$1_dim0); %} + +%typemap(argout) SWIGTYPE* OUTPUT[ANY] +%{ SWIG_write_ptr_array(L,(void**)$1,$1_dim0,$*1_descriptor,0); SWIG_arg++; %} + +%typemap(freearg) SWIGTYPE* OUTPUT[ANY] +%{ SWIG_FREE_ARRAY($1); %} + +// inout fixed arrays +%typemap(in) SWIGTYPE* INOUT[ANY]=SWIGTYPE* INPUT[ANY]; +%typemap(argout) SWIGTYPE* INOUT[ANY]=SWIGTYPE* OUTPUT[ANY]; +%typemap(freearg) SWIGTYPE* INOUT[ANY]=SWIGTYPE* INPUT[ANY]; +// inout variable arrays +%typemap(in) (SWIGTYPE** INOUT,int)=(SWIGTYPE** INPUT,int); +%typemap(argout) (SWIGTYPE** INOUT,int) +%{ SWIG_write_ptr_array(L,(void**)$1,$2,$*1_descriptor,0); SWIG_arg++; %} +%typemap(freearg) (SWIGTYPE**INOUT,int)=(SWIGTYPE**INPUT,int); + +/* ----------------------------------------------------------------------------- + * Pointer-Pointer typemaps + * ----------------------------------------------------------------------------- */ +/* +This code is to deal with the issue for pointer-pointer's +In particular for factory methods. + +for example take the following code segment: + +struct iMath; // some structure +int Create_Math(iMath** pptr); // its factory (assume it mallocs) + +to use it you might have the following C code: + +iMath* ptr; +int ok; +ok=Create_Math(&ptr); +// do things with ptr +//... +free(ptr); + +With the following SWIG code +%apply SWIGTYPE** OUTPUT{iMath **pptr }; + +You can get natural wrappering in Lua as follows: +ok,ptr=Create_Math() -- ptr is a iMath* which is returned with the int +ptr=nil -- the iMath* will be GC'ed as normal +*/ + +%typemap(in,numinputs=0) SWIGTYPE** OUTPUT ($*ltype temp) +%{ $1 = &temp; %} +%typemap(argout) SWIGTYPE** OUTPUT +%{SWIG_NewPointerObj(L,*$1,$*descriptor,1); SWIG_arg++; %} + diff --git a/devtools/swigwin-1.3.34/Lib/lua/wchar.i b/devtools/swigwin-1.3.34/Lib/lua/wchar.i new file mode 100644 index 0000000..5b206eb --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/lua/wchar.i @@ -0,0 +1,46 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * wchar.i + * + * Typemaps for the wchar_t type + * These are mapped to a Lua string and are passed around by value. + * + * ----------------------------------------------------------------------------- */ + +// note: only support for pointer right now, not fixed length strings +// TODO: determine how long a const wchar_t* is so we can write wstr2str() +// & do the output typemap + +%{ +#include <stdlib.h> + +wchar_t* str2wstr(const char* str, int len) +{ + wchar_t* p; + if (str==0 || len<1) return 0; + p=(wchar*)malloc((len+1)*sizeof(wchar_t)); + if (p==0) return 0; + if (mbstowcs(p, str, len)==-1) + { + free(p); + return 0; + } + p[len]=0; + return p; +} +%} + +%typemap( in, checkfn="lua_isstring" ) wchar_t* +%{ +$1 = str2wstr(lua_tostring( L, $input ),lua_strlen( L, $input )); +if ($1==0) {lua_pushfstring(L,"Error in converting to wchar (arg %d)",$input);goto fail;} +%} + +%typemap( freearg ) wchar_t* +%{ +free($1); +%} + +%typemap(typecheck) wchar_t * = char *;
\ No newline at end of file diff --git a/devtools/swigwin-1.3.34/Lib/math.i b/devtools/swigwin-1.3.34/Lib/math.i new file mode 100644 index 0000000..be931d7 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/math.i @@ -0,0 +1,85 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * math.i + * + * SWIG library file for floating point operations. + * ----------------------------------------------------------------------------- */ + +%module math +%{ +#include <math.h> +%} + +extern double cos(double x); +/* Cosine of x */ + +extern double sin(double x); +/* Sine of x */ + +extern double tan(double x); +/* Tangent of x */ + +extern double acos(double x); +/* Inverse cosine in range [-PI/2,PI/2], x in [-1,1]. */ + +extern double asin(double x); +/* Inverse sine in range [0,PI], x in [-1,1]. */ + +extern double atan(double x); +/* Inverse tangent in range [-PI/2,PI/2]. */ + +extern double atan2(double y, double x); +/* Inverse tangent of y/x in range [-PI,PI]. */ + +extern double cosh(double x); +/* Hyperbolic cosine of x */ + +extern double sinh(double x); +/* Hyperbolic sine of x */ + +extern double tanh(double x); +/* Hyperbolic tangent of x */ + +extern double exp(double x); +/* Natural exponential function e^x */ + +extern double log(double x); +/* Natural logarithm ln(x), x > 0 */ + +extern double log10(double x); +/* Base 10 logarithm, x > 0 */ + +extern double pow(double x, double y); +/* Power function x^y. */ + +extern double sqrt(double x); +/* Square root. x >= 0 */ + +extern double fabs(double x); +/* Absolute value of x */ + +extern double ceil(double x); +/* Smallest integer not less than x, as a double */ + +extern double floor(double x); +/* Largest integer not greater than x, as a double */ + +extern double fmod(double x, double y); +/* Floating-point remainder of x/y, with the same sign as x. */ + +#define M_E 2.7182818284590452354 +#define M_LOG2E 1.4426950408889634074 +#define M_LOG10E 0.43429448190325182765 +#define M_LN2 0.69314718055994530942 +#define M_LN10 2.30258509299404568402 +#define M_PI 3.14159265358979323846 +#define M_PI_2 1.57079632679489661923 +#define M_PI_4 0.78539816339744830962 +#define M_1_PI 0.31830988618379067154 +#define M_2_PI 0.63661977236758134308 +#define M_2_SQRTPI 1.12837916709551257390 +#define M_SQRT2 1.41421356237309504880 +#define M_SQRT1_2 0.70710678118654752440 + diff --git a/devtools/swigwin-1.3.34/Lib/modula3/modula3.swg b/devtools/swigwin-1.3.34/Lib/modula3/modula3.swg new file mode 100644 index 0000000..683b721 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/modula3/modula3.swg @@ -0,0 +1,750 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * modula3.swg + * + * Modula3 typemaps + * ----------------------------------------------------------------------------- */ + +%include <modula3head.swg> + +/* The ctype, m3rawtype and m3wraptype typemaps work together and so there should be one of each. + * The ctype typemap contains the C type used in the signature of C wrappers for C++ functions. + * The m3rawtype typemap contains the M3 type used in the raw interface. + * The m3rawintype typemap contains the M3 type used as function argument. + * The m3rawrettype typemap contains the M3 type used as return value. + * The m3wraptype typemap contains the M3 type used in the M3 type wrapper classes and module class. */ + +/* Primitive types */ +%typemap(ctype) bool, const bool & "bool" +%typemap(ctype) char, const char & "char" +%typemap(ctype) signed char, const signed char & "signed char" +%typemap(ctype) unsigned char, const unsigned char & "unsigned short" +%typemap(ctype) short, const short & "short" +%typemap(ctype) unsigned short, const unsigned short & "unsigned short" +%typemap(ctype) int, const int & "int" +%typemap(ctype) unsigned int, const unsigned int & "unsigned int" +%typemap(ctype) long, const long & "long" +%typemap(ctype) unsigned long, const unsigned long & "unsigned long" +%typemap(ctype) long long, const long long & "long long" +%typemap(ctype) unsigned long long, const unsigned long long & "unsigned long long" +%typemap(ctype) float, const float & "float" +%typemap(ctype) double, const double & "double" +%typemap(ctype) char * "char *" +%typemap(ctype) void "void" + +%typemap(m3rawtype) bool, const bool & "BOOLEAN" +%typemap(m3rawtype) char, const char & "C.char" +%typemap(m3rawtype) signed char, const signed char & "C.signed_char" +%typemap(m3rawtype) unsigned char, const unsigned char & "C.unsigned_char" +%typemap(m3rawtype) short, const short & "C.short" +%typemap(m3rawtype) unsigned short, const unsigned short & "C.unsigned_short" +%typemap(m3rawtype) int, const int & "C.int" +%typemap(m3rawtype) unsigned int, const unsigned int & "C.unsigned_int" +%typemap(m3rawtype) long, const long & "C.long" +%typemap(m3rawtype) unsigned long, const unsigned long & "C.unsigned_long" +%typemap(m3rawtype) long long, const long long & "C.long_long" +%typemap(m3rawtype) unsigned long long, const unsigned long long & "C.unsigned_long_long" +%typemap(m3rawtype) float, const float & "C.float" +%typemap(m3rawtype) double, const double & "C.double" +%typemap(m3rawtype) long double, const long double & "C.long_double" +%typemap(m3rawtype) char * "C.char_star" +%typemap(m3rawtype) void "" +%typemap(m3rawtype) FILE "Cstdio.FILE"; +%typemap(m3rawtype) FILE * "Cstdio.FILE_star"; + + +%typemap(m3rawintype) bool *, bool &, bool "BOOLEAN" +%typemap(m3rawintype) char *, char &, char "C.char" +%typemap(m3rawintype) signed char *, signed char &, signed char "C.signed_char" +%typemap(m3rawintype) unsigned char *, unsigned char &, unsigned char "C.unsigned_char" +%typemap(m3rawintype) short *, short &, short "C.short" +%typemap(m3rawintype) unsigned short *, unsigned short &, unsigned short "C.unsigned_short" +%typemap(m3rawintype) int *, int &, int "C.int" +%typemap(m3rawintype) unsigned int *, unsigned int &, unsigned int "C.unsigned_int" +%typemap(m3rawintype) long *, long &, long "C.long" +%typemap(m3rawintype) unsigned long *, unsigned long &, unsigned long "C.unsigned_long" +%typemap(m3rawintype) long long *, long long &, long long "C.long_long" +%typemap(m3rawintype) unsigned long long *, unsigned long long &, unsigned long long "C.unsigned_long_long" +%typemap(m3rawintype) float *, float &, float "C.float" +%typemap(m3rawintype) double *, double &, double "C.double" +%typemap(m3rawintype) long double *, long double &, long double "C.long_double" +%typemap(m3rawintype) char * "C.char_star" +%typemap(m3rawintype) void "" +%typemap(m3rawintype) void * "ADDRESS" +%typemap(m3rawintype) FILE "Cstdio.FILE"; +%typemap(m3rawintype) FILE * "Cstdio.FILE_star"; + +%typemap(m3rawinmode) char *, void *, FILE * "" + + +%typemap(m3rawrettype) bool, const bool & "BOOLEAN" +%typemap(m3rawrettype) char, const char & "C.char" +%typemap(m3rawrettype) signed char, const signed char & "C.signed_char" +%typemap(m3rawrettype) unsigned char, const unsigned char & "C.unsigned_char" +%typemap(m3rawrettype) short, const short & "C.short" +%typemap(m3rawrettype) unsigned short, const unsigned short & "C.unsigned_short" +%typemap(m3rawrettype) int, const int & "C.int" +%typemap(m3rawrettype) unsigned int, const unsigned int & "C.unsigned_int" +%typemap(m3rawrettype) long, const long & "C.long" +%typemap(m3rawrettype) unsigned long, const unsigned long & "C.unsigned_long" +%typemap(m3rawrettype) long long, const long long & "C.long_long" +%typemap(m3rawrettype) unsigned long long, const unsigned long long & "C.unsigned_long_long" +%typemap(m3rawrettype) float, const float & "C.float" +%typemap(m3rawrettype) double, const double & "C.double" +%typemap(m3rawrettype) long double, const long double & "C.long_double" +%typemap(m3rawrettype) char * "C.char_star" +%typemap(m3rawrettype) void "" +%typemap(m3rawrettype) void * "ADDRESS" +%typemap(m3rawrettype) FILE "Cstdio.FILE"; +%typemap(m3rawrettype) FILE * "Cstdio.FILE_star"; + + +%typemap("m3rawtype:import") + char, const char &, + signed char, const signed char &, + unsigned char, const unsigned char &, + short, const short &, + unsigned short, const unsigned short &, + int, const int &, + unsigned int, const unsigned int &, + long, const long &, + unsigned long, const unsigned long &, + long long, const long long &, + unsigned long long, const unsigned long long &, + float, const float &, + double, const double &, + long double, const long double &, + char * + "Ctypes AS C" + +%typemap("m3rawintype:import") + char, const char &, + signed char, const signed char &, + unsigned char, const unsigned char &, + short, const short &, + unsigned short, const unsigned short &, + int, const int &, + unsigned int, const unsigned int &, + long, const long &, + unsigned long, const unsigned long &, + long long, const long long &, + unsigned long long, const unsigned long long &, + float, const float &, + double, const double &, + long double, const long double &, + char * + "Ctypes AS C" + +%typemap("m3rawrettype:import") + char, const char &, + signed char, const signed char &, + unsigned char, const unsigned char &, + short, const short &, + unsigned short, const unsigned short &, + int, const int &, + unsigned int, const unsigned int &, + long, const long &, + unsigned long, const unsigned long &, + long long, const long long &, + unsigned long long, const unsigned long long &, + float, const float &, + double, const double &, + long double, const long double &, + char * + "Ctypes AS C" + +%typemap("m3rawtype:import") + FILE, FILE * + "Cstdio"; + +%typemap("m3rawintype:import") + FILE, FILE * + "Cstdio"; + +%typemap("m3rawrettype:import") + FILE, FILE * + "Cstdio"; + +%typemap(m3wraptype) bool, const bool & "BOOLEAN" +%typemap(m3wraptype) char, const char & "CHAR" +%typemap(m3wraptype) signed char, const signed char & "CHAR" +%typemap(m3wraptype) unsigned char, const unsigned char & "CHAR" +%typemap(m3wraptype) short, const short & "Integer16.T" +%typemap(m3wraptype) unsigned short, const unsigned short & "Cardinal16.T" +%typemap(m3wraptype) int, const int & "INTEGER" +%typemap(m3wraptype) unsigned int, const unsigned int & "CARDINAL" +%typemap(m3wraptype) long, const long & "Integer32.T" +%typemap(m3wraptype) unsigned long, const unsigned long & "Cardinal32.T" +%typemap(m3wraptype) long long, const long long & "Integer64.T" +%typemap(m3wraptype) unsigned long long, const unsigned long long & "Cardinal64.T" +%typemap(m3wraptype) float, const float & "REAL" +%typemap(m3wraptype) double, const double & "LONGREAL" +%typemap(m3wraptype) long double, const long double & "EXTENDED" +%typemap(m3wraptype) char * "TEXT" +%typemap(m3wraptype) void "" +%typemap(m3wraptype) FILE "Cstdio.FILE"; +%typemap(m3wraptype) FILE * "Cstdio.FILE_star"; + +%typemap(m3wrapintype) bool, const bool *, const bool & "BOOLEAN" +%typemap(m3wrapintype) char, const char *, const char & "CHAR" +%typemap(m3wrapintype) signed char, const signed char *, const signed char & "CHAR" +%typemap(m3wrapintype) unsigned char, const unsigned char *, const unsigned char & "CHAR" +%typemap(m3wrapintype) short, const short *, const short & "INTEGER" +%typemap(m3wrapintype) unsigned short, const unsigned short *, const unsigned short & "CARDINAL" +%typemap(m3wrapintype) int, const int *, const int & "INTEGER" +%typemap(m3wrapintype) unsigned int, const unsigned int *, const unsigned int & "CARDINAL" +%typemap(m3wrapintype) long, const long *, const long & "INTEGER" +%typemap(m3wrapintype) unsigned long, const unsigned long *, const unsigned long & "CARDINAL" +%typemap(m3wrapintype) long long, const long long *, const long long & "INTEGER" +%typemap(m3wrapintype) unsigned long long, const unsigned long long *, const unsigned long long & "CARDINAL" +%typemap(m3wrapintype) float, const float *, const float & "REAL" +%typemap(m3wrapintype) double, const double *, const double & "LONGREAL" +%typemap(m3wrapintype) long double, const long double *, const long double & "EXTENDED" +%typemap(m3wrapintype) const char *, const char [] "TEXT" +%typemap(m3wrapintype,numinputs=0) void "" +%typemap(m3wrapintype) FILE "Cstdio.FILE"; +%typemap(m3wrapintype) FILE * "Cstdio.FILE_star"; + + +%typemap(m3wrapouttype) bool, bool *, bool & "BOOLEAN" +%typemap(m3wrapouttype) char, char *, char & "CHAR" +%typemap(m3wrapouttype) signed char, signed char *, signed char & "CHAR" +%typemap(m3wrapouttype) unsigned char, unsigned char *, unsigned char & "CHAR" +%typemap(m3wrapouttype) short, short *, short & "INTEGER" +%typemap(m3wrapouttype) unsigned short, unsigned short *, unsigned short & "CARDINAL" +%typemap(m3wrapouttype) int, int *, int & "INTEGER" +%typemap(m3wrapouttype) unsigned int, unsigned int *, unsigned int & "CARDINAL" +%typemap(m3wrapouttype) long, long *, long & "INTEGER" +%typemap(m3wrapouttype) unsigned long, unsigned long *, unsigned long & "CARDINAL" +%typemap(m3wrapouttype) long long, long long *, long long & "INTEGER" +%typemap(m3wrapouttype) unsigned long long, unsigned long long *, unsigned long long & "CARDINAL" +%typemap(m3wrapouttype) float, float *, float & "REAL" +%typemap(m3wrapouttype) double, double *, double & "LONGREAL" +%typemap(m3wrapouttype) long double, long double *, long double & "EXTENDED" +%typemap(m3wrapouttype) char *, char [] "TEXT" +%typemap(m3wrapouttype,numinputs=0) void "" + +%typemap(m3wraprettype) bool, const bool & "BOOLEAN" +%typemap(m3wraprettype) char, const char & "CHAR" +%typemap(m3wraprettype) signed char, const signed char & "CHAR" +%typemap(m3wraprettype) unsigned char, const unsigned char & "CHAR" +%typemap(m3wraprettype) short, const short & "INTEGER" +%typemap(m3wraprettype) unsigned short, const unsigned short & "CARDINAL" +%typemap(m3wraprettype) int, const int & "INTEGER" +%typemap(m3wraprettype) unsigned int, const unsigned int & "CARDINAL" +%typemap(m3wraprettype) long, const long & "INTEGER" +%typemap(m3wraprettype) unsigned long, const unsigned long & "CARDINAL" +%typemap(m3wraprettype) long long, const long long & "INTEGER" +%typemap(m3wraprettype) unsigned long long, const unsigned long long & "CARDINAL" +%typemap(m3wraprettype) float, const float & "REAL" +%typemap(m3wraprettype) double, const double & "LONGREAL" +%typemap(m3wraprettype) long double, const long double & "EXTENDED" +%typemap(m3wraprettype) char * "TEXT" +%typemap(m3wraprettype) void "" +%typemap(m3wraprettype) FILE "Cstdio.FILE"; +%typemap(m3wraprettype) FILE * "Cstdio.FILE_star"; + + +%typemap(ctype) char[ANY] "char *" +%typemap(m3rawtype) char[ANY] "C.char_star" +%typemap(m3rawintype) char[ANY] "C.char_star" +%typemap(m3rawrettype) char[ANY] "C.char_star" +%typemap(m3wraptype) char[ANY] "TEXT" +%typemap(m3wrapintype) char[ANY] "TEXT" +%typemap(m3wrapouttype) char[ANY] "TEXT" +%typemap(m3wraprettype) char[ANY] "TEXT" + +%typemap(m3wrapinmode) const char * %{%} +%typemap(m3wrapargvar) const char * %{$1 : C.char_star;%} +%typemap(m3wrapinconv) const char * %{$1 := M3toC.SharedTtoS($1_name);%} +%typemap(m3wrapfreearg) const char * %{M3toC.FreeSharedS($1_name,$1);%} +%typemap(m3wrapargraw) const char * %{$1%} +%typemap("m3wrapargvar:import") const char * "Ctypes AS C" +%typemap("m3wrapinconv:import") const char * "M3toC" +%typemap("m3wrapfreearg:import") const char * "M3toC" + +%typemap(m3wrapretvar) char * %{result : C.char_star;%} +%typemap(m3wrapretraw) char * %{result%} +%typemap(m3wrapretconv) char * %{M3toC.CopyStoT(result)%} +%typemap("m3wrapretvar:import") char * "Ctypes AS C" +%typemap("m3wrapretconv:import") char * "M3toC" + +%typemap(m3wrapinmode) FILE * %{%} + + +%typemap("m3wraptype:import") + FILE, FILE * + "Cstdio"; + +%typemap("m3wrapintype:import") + FILE, FILE * + "Cstdio"; + +%typemap("m3wraprettype:import") + FILE, FILE * + "Cstdio"; + + +/* Composed types */ +%typemap(ctype) SWIGTYPE "$1_type" +%typemap(m3rawtype) SWIGTYPE "$1_basetype" +%typemap(m3rawrettype) SWIGTYPE "UNTRACED REF $1_basetype" +%typemap(m3wraptype) SWIGTYPE "$1_basetype" +%typemap(m3wrapintype) SWIGTYPE "$1_basetype" +%typemap(m3wrapouttype) SWIGTYPE "$1_basetype" +%typemap(m3wraprettype) SWIGTYPE "$1_basetype" + +%typemap(ctype) SWIGTYPE [] "$1_type" +%typemap(m3rawtype) const SWIGTYPE [] "UNTRACED REF ARRAY INTEGER OF $1_basetype" +%typemap(m3rawtype) SWIGTYPE [] "UNTRACED REF ARRAY INTEGER OF $1_basetype" +%typemap(m3rawintype) const SWIGTYPE [] "(*ARRAY OF*) $1_basetype" +%typemap(m3rawinmode) const SWIGTYPE [] "READONLY" +%typemap(m3rawintype) SWIGTYPE [] "(*ARRAY OF*) $1_basetype" +%typemap(m3rawinmode) SWIGTYPE [] "VAR" +%typemap(m3rawrettype) const SWIGTYPE [] "UNTRACED REF ARRAY INTEGER OF $1_basetype" +%typemap(m3rawrettype) SWIGTYPE [] "UNTRACED REF ARRAY INTEGER OF $1_basetype" +%typemap(m3wraptype) SWIGTYPE [] "$1_basetype" +%typemap(m3wrapintype) const SWIGTYPE [] "ARRAY OF $1_basetype" +%typemap(m3wrapinmode) const SWIGTYPE [] "READONLY" +%typemap(m3wrapintype) SWIGTYPE [] "ARRAY OF $1_basetype" +%typemap(m3wrapinmode) SWIGTYPE [] "VAR" +%typemap(m3wrapouttype) SWIGTYPE [] "ARRAY OF $1_basetype" +%typemap(m3wraprettype) SWIGTYPE [] "REF ARRAY OF $1_basetype" + +%typemap(ctype) SWIGTYPE * "$1_type" +%typemap(m3rawtype) const SWIGTYPE * "UNTRACED REF $1_basetype" +%typemap(m3rawtype) SWIGTYPE * "UNTRACED REF $1_basetype" +%typemap(m3rawintype) const SWIGTYPE * "$1_basetype" +%typemap(m3rawinmode) const SWIGTYPE * "READONLY" +%typemap(m3rawintype) SWIGTYPE * "$1_basetype" +%typemap(m3rawinmode) SWIGTYPE * "VAR" +%typemap(m3rawrettype) const SWIGTYPE * "UNTRACED REF $1_basetype" +%typemap(m3rawrettype) SWIGTYPE * "UNTRACED REF $1_basetype" +%typemap(m3wraptype) SWIGTYPE * "$1_basetype" +%typemap(m3wrapintype) const SWIGTYPE * "$1_basetype" +%typemap(m3wrapinmode) const SWIGTYPE * "READONLY" +%typemap(m3wrapintype) SWIGTYPE * "$1_basetype" +%typemap(m3wrapinmode) SWIGTYPE * "VAR" +%typemap(m3wrapouttype) SWIGTYPE * "$1_basetype" +%typemap(m3wraprettype) SWIGTYPE * "UNTRACED REF $1_basetype" + +%typemap(ctype) SWIGTYPE & "$1_type" +%typemap(m3rawtype) const SWIGTYPE & "UNTRACED REF $1_basetype" +%typemap(m3rawtype) SWIGTYPE & "UNTRACED REF $1_basetype" +%typemap(m3rawintype) const SWIGTYPE & "$1_basetype" +%typemap(m3rawinmode) const SWIGTYPE & "READONLY" +%typemap(m3rawintype) SWIGTYPE & "$1_basetype" +%typemap(m3rawinmode) SWIGTYPE & "VAR" +%typemap(m3rawrettype) const SWIGTYPE & "UNTRACED REF $1_basetype" +%typemap(m3rawrettype) SWIGTYPE & "UNTRACED REF $1_basetype" +%typemap(m3wraptype) SWIGTYPE & "$1_basetype" +%typemap(m3wrapintype) const SWIGTYPE & "$1_basetype" +%typemap(m3wrapinmode) const SWIGTYPE & "READONLY" +%typemap(m3wrapintype) SWIGTYPE & "$1_basetype" +%typemap(m3wrapinmode) SWIGTYPE & "VAR" +%typemap(m3wrapouttype) SWIGTYPE & "$1_basetype" +%typemap(m3wraprettype) SWIGTYPE & "UNTRACED REF $1_basetype" + +%typemap(ctype) enum SWIGTYPE "$1_type" +%typemap(m3rawtype) enum SWIGTYPE "C.int" +%typemap(m3rawintype) enum SWIGTYPE "C.int (* $1_type *)" +%typemap(m3rawrettype) enum SWIGTYPE "C.int" +%typemap(m3wraptype) enum SWIGTYPE "$*1_type" +%typemap(m3wrapintype) enum SWIGTYPE "$1_type" +%typemap(m3wrapouttype) enum SWIGTYPE "$1_type" +%typemap(m3wraprettype) enum SWIGTYPE "$*1_type" + +/* pointer to a class member */ +%typemap(ctype) SWIGTYPE (CLASS::*) "$1_type" +%typemap(m3rawtype) SWIGTYPE (CLASS::*) "REFANY" +%typemap(m3wraptype) SWIGTYPE (CLASS::*) "$1_basetype" + +/* The following are the in, out, freearg, argout typemaps. + These are the PInvoke code generating typemaps for converting from C# to C and visa versa. */ + +/* primitive types */ +%typemap(in) bool +%{ $1 = $input ? true : false; %} + +%typemap(in) char, + signed char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + unsigned long long, + float, + double, + enum SWIGTYPE +%{ $1 = ($1_ltype)$input; %} + +%typemap(out) bool %{ $result = $1; %} +%typemap(out) char %{ $result = $1; %} +%typemap(out) signed char %{ $result = $1; %} +%typemap(out) unsigned char %{ $result = $1; %} +%typemap(out) short %{ $result = $1; %} +%typemap(out) unsigned short %{ $result = $1; %} +%typemap(out) int %{ $result = $1; %} +%typemap(out) unsigned int %{ $result = $1; %} +%typemap(out) long %{ $result = $1; %} +%typemap(out) unsigned long %{ $result = $1; %} +%typemap(out) long long %{ $result = $1; %} +%typemap(out) unsigned long long %{ $result = $1; %} +%typemap(out) float %{ $result = $1; %} +%typemap(out) double %{ $result = $1; %} +%typemap(out) enum SWIGTYPE %{ $result = $1; %} + +/* char * - treat as String */ +%typemap(in) char * { + $1 = $input; +} +//%typemap(freearg) char * { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, $1); } +//%typemap(out) char * { if($1) $result = JCALL1(NewStringUTF, jenv, $1); } + +%typemap(out) void "" + +/* primitive types by const reference */ +%typemap(in) const bool & (bool temp) +%{ temp = $input ? true : false; + $1 = &temp; %} + +%typemap(in) const char & (char temp), + const signed char & (signed char temp), + const unsigned char & (unsigned char temp), + const short & (short temp), + const unsigned short & (unsigned short temp), + const int & (int temp), + const unsigned int & (unsigned int temp), + const long & (long temp), + const unsigned long & (unsigned long temp), + const long long & ($*1_ltype temp), + const unsigned long long & ($*1_ltype temp), + const float & (float temp), + const double & (double temp) +%{ temp = ($*1_ltype)$input; +$1 = &temp; %} + +%typemap(out) const bool & %{ $result = *$1; %} +%typemap(out) const char & %{ $result = *$1; %} +%typemap(out) const signed char & %{ $result = *$1; %} +%typemap(out) const unsigned char & %{ $result = *$1; %} +%typemap(out) const short & %{ $result = *$1; %} +%typemap(out) const unsigned short & %{ $result = *$1; %} +%typemap(out) const int & %{ $result = *$1; %} +%typemap(out) const unsigned int & %{ $result = *$1; %} +%typemap(out) const long & %{ $result = *$1; %} +%typemap(out) const unsigned long & %{ $result = *$1; %} +%typemap(out) const long long & %{ $result = *$1; %} +%typemap(out) const unsigned long long & %{ $result = *$1; %} +%typemap(out) const float & %{ $result = *$1; %} +%typemap(out) const double & %{ $result = *$1; %} + +/* Default handling. Object passed by value. Convert to a pointer */ +%typemap(in) SWIGTYPE ($&1_type argp) +%{ argp = *($&1_ltype*)&$input; + if (!argp) { +// SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type"); + RETURN $null; + } + $1 = *argp; %} +%typemap(out) SWIGTYPE +#ifdef __cplusplus +%{*($&1_ltype*)&$result = new $1_ltype(($1_ltype &)$1); %} +#else +{ + $&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype)); + memmove($1ptr, &$1, sizeof($1_type)); + *($&1_ltype*)&$result = $1ptr; +} +#endif + +/* Generic pointers and references */ +%typemap(in) SWIGTYPE *, SWIGTYPE (CLASS::*) %{ $1 = *($&1_ltype)&$input; %} +%typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input; + if(!$1) { + //SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); + RETURN $null; + } %} +%typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE (CLASS::*) %{ *($&1_ltype)&$result = $1; %} + + +/* Default array handling */ +%typemap(in) SWIGTYPE [] %{ $1 = *($&1_ltype)&$input; %} +%typemap(out) SWIGTYPE [] %{ *($&1_ltype)&$result = $1; %} + +/* char[ANY] - treat as String */ +%typemap(in) char[ANY] { + $1 = $input; +} + +%typemap(argout) char[ANY] "" +%typemap(freearg) char[ANY] ""//{ if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, $1); } +%typemap(out) char[ANY] { if($1) $result = $1; } + + +/* Typecheck typemaps - The purpose of these is merely to issue a warning for overloaded C++ functions + * that cannot be overloaded in C# as more than one C++ type maps to a single C# type */ + +%typecheck(SWIG_TYPECHECK_BOOL) /* Java boolean */ + bool, + const bool & + "" + +%typecheck(SWIG_TYPECHECK_CHAR) /* Java char */ + char, + const char & + "" + +%typecheck(SWIG_TYPECHECK_INT8) /* Java byte */ + signed char, + const signed char & + "" + +%typecheck(SWIG_TYPECHECK_INT16) /* Java short */ + unsigned char, + short, + const unsigned char &, + const short & + "" + +%typecheck(SWIG_TYPECHECK_INT32) /* Java int */ + unsigned short, + int, + long, + const unsigned short &, + const int &, + const long &, + enum SWIGTYPE + "" + +%typecheck(SWIG_TYPECHECK_INT64) /* Java long */ + unsigned int, + unsigned long, + long long, + const unsigned int &, + const unsigned long &, + const long long & + "" + +%typecheck(SWIG_TYPECHECK_INT128) /* Java BigInteger */ + unsigned long long + "" + +%typecheck(SWIG_TYPECHECK_FLOAT) /* Java float */ + float, + const float & + "" + +%typecheck(SWIG_TYPECHECK_DOUBLE) /* Java double */ + double, + const double & + "" + +%typecheck(SWIG_TYPECHECK_STRING) /* Java String */ + char *, + char[ANY] + "" + +%typecheck(SWIG_TYPECHECK_POINTER) /* Default */ + SWIGTYPE, + SWIGTYPE *, + SWIGTYPE &, + SWIGTYPE [], + SWIGTYPE (CLASS::*) + "" + +/* Exception handling */ + +%typemap(throws) int, + long, + short, + unsigned int, + unsigned long, + unsigned short { + char error_msg[256]; + sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1); + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, error_msg); + RETURN $null; +} + +%typemap(throws) SWIGTYPE { + (void)$1; + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); + RETURN $null; +} + +%typemap(throws) char * { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1); + RETURN $null; +} + + +/* Typemaps for code generation in proxy classes and C# type wrapper classes */ + +/* The in typemap is used for converting function parameter types from the type + * used in the proxy, module or type wrapper class to the type used in the PInvoke class. */ +%typemap(m3in) bool, const bool &, + char, const char &, + signed char, const signed char &, + unsigned char, const unsigned char &, + short, const short &, + unsigned short, const unsigned short &, + int, const int &, + unsigned int, const unsigned int &, + long, const long &, + unsigned long, const unsigned long &, + long long, const long long &, + unsigned long long, const unsigned long long &, + float, const float &, + double, const double &, + char *, + char[ANY], + enum SWIGTYPE + "$input" +%typemap(m3in) SWIGTYPE "$&*1_type.getCPtr($input)" +%typemap(m3in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "$1_basetype.getCPtr($input)" + +/* The m3out typemap is used for converting function return types from the return type + * used in the PInvoke class to the type returned by the proxy, module or type wrapper class. */ +%typemap(m3out) bool, const bool &, + char, const char &, + signed char, const signed char &, + unsigned char, const unsigned char &, + short, const short &, + unsigned short, const unsigned short &, + int, const int &, + unsigned int, const unsigned int &, + long, const long &, + unsigned long, const unsigned long &, + long long, const long long &, + unsigned long long, const unsigned long long &, + float, const float &, + double, const double &, + char *, + char[ANY], + enum SWIGTYPE +%{$imcall%} + +%typemap(m3out) void %{$imcall%} + +%typemap(m3out) SWIGTYPE %{ + RETURN NEW(REF $1_basetype, $imcall); +%} +%typemap(m3out) SWIGTYPE & %{ + RETURN NEW($1_basetype, $imcall, $owner); +%} +%typemap(m3out) SWIGTYPE *, SWIGTYPE [], SWIGTYPE (CLASS::*) %{ + cPtr := $imcall; + RETURN (cPtr = IntPtr.Zero) ? null : NEW($1_basetype, cPtr, $owner); +%} + +/* Properties */ +%typemap(m3varin) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{ +PROCEDURE Set$var (value: $vartype) = + BEGIN + $imcall; + END Set$var; +%} + +%typemap(m3varout) bool, const bool &, + char, const char &, + signed char, const signed char &, + unsigned char, const unsigned char &, + short, const short &, + unsigned short, const unsigned short &, + int, const int &, + unsigned int, const unsigned int &, + long, const long &, + unsigned long, const unsigned long &, + long long, const long long &, + unsigned long long, const unsigned long long &, + float, const float &, + double, const double &, + char *, + char[ANY], + enum SWIGTYPE %{ +PROCEDURE Get$var (): $vartype = + BEGIN + RETURN $imcall; + END Get$var; +%} + +%typemap(m3varout) void %{ + get { + $imcall; + } %} +%typemap(m3varout) SWIGTYPE %{ + get { + RETURN new $&*1_mangle($imcall, true); + } %} +%typemap(m3varout) SWIGTYPE & %{ + get { + RETURN new $1_basetype($imcall, $owner); + } %} +%typemap(m3varout) SWIGTYPE *, SWIGTYPE [], SWIGTYPE (CLASS::*) %{ + get { + IntPtr cPtr = $imcall; + RETURN (cPtr == IntPtr.Zero) ? null : new $1_basetype(cPtr, $owner); + } %} + +/* Typemaps used for the generation of proxy and type wrapper class code */ +%typemap(m3base) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" +%typemap(m3classmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "public" +%typemap(m3code) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" +%typemap(m3imports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "using System;" +%typemap(m3interfaces) SWIGTYPE "IDisposable" +%typemap(m3interfaces_derived) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" +%typemap(m3ptrconstructormodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "internal" + +%typemap(m3finalize) SWIGTYPE %{ + ~$1_basetype() { + Dispose(); + } +%} + +%typemap(m3destruct, methodname="Dispose") SWIGTYPE { + if(swigCPtr != IntPtr.Zero && swigCMemOwn) { + $imcall; + swigCMemOwn = false; + } + swigCPtr = IntPtr.Zero; + GC.SuppressFinalize(this); + } + +%typemap(m3destruct_derived, methodname="Dispose") SWIGTYPE { + if(swigCPtr != IntPtr.Zero && swigCMemOwn) { + $imcall; + swigCMemOwn = false; + } + swigCPtr = IntPtr.Zero; + GC.SuppressFinalize(this); + base.Dispose(); + } + +%typemap(m3getcptr) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{ + internal static IntPtr getCPtr($1_basetype obj) { + RETURN (obj == null) ? IntPtr.Zero : obj.swigCPtr; + } +%} + +/* M3 specific directives */ +#define %m3multiretval %feature("modula3:multiretval") +#define %constnumeric(num) %feature("constnumeric","num") + +%pragma(modula3) moduleimports=%{ +IMPORT BlaBla; +%} + +%pragma(modula3) imclassimports=%{ +FROM BlaBla IMPORT Bla; +%} + +/* Some ANSI C typemaps */ + +%apply unsigned long { size_t }; diff --git a/devtools/swigwin-1.3.34/Lib/modula3/modula3head.swg b/devtools/swigwin-1.3.34/Lib/modula3/modula3head.swg new file mode 100644 index 0000000..b2426be --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/modula3/modula3head.swg @@ -0,0 +1,67 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * modula3head.swg + * + * Modula3 support code + * ----------------------------------------------------------------------------- */ + +%insert(runtime) %{ + +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +%} + +#if 0 +%insert(runtime) %{ +/* Support for throwing Modula3 exceptions */ +typedef enum { + SWIG_JavaOutOfMemoryError = 1, + SWIG_JavaIOException, + SWIG_JavaRuntimeException, + SWIG_JavaIndexOutOfBoundsException, + SWIG_JavaArithmeticException, + SWIG_JavaIllegalArgumentException, + SWIG_JavaNullPointerException, + SWIG_JavaUnknownError +} SWIG_JavaExceptionCodes; + +typedef struct { + SWIG_JavaExceptionCodes code; + const char *java_exception; +} SWIG_JavaExceptions_t; + +#if defined(SWIG_NOINCLUDE) +void SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg); +#else +%} +%insert(runtime) { +void SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) { + jclass excep; + static const SWIG_JavaExceptions_t java_exceptions[] = { + { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" }, + { SWIG_JavaIOException, "java/io/IOException" }, + { SWIG_JavaRuntimeException, "java/lang/RuntimeException" }, + { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" }, + { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" }, + { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" }, + { SWIG_JavaNullPointerException, "java/lang/NullPointerException" }, + { SWIG_JavaUnknownError, "java/lang/UnknownError" }, + { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" } }; + const SWIG_JavaExceptions_t *except_ptr = java_exceptions; + + while (except_ptr->code != code && except_ptr->code) + except_ptr++; + + JCALL0(ExceptionClear, jenv); + excep = JCALL1(FindClass, jenv, except_ptr->java_exception); + if (excep) + JCALL2(ThrowNew, jenv, excep, msg); +} +} +%insert(runtime) %{ +#endif +%} +#endif diff --git a/devtools/swigwin-1.3.34/Lib/modula3/typemaps.i b/devtools/swigwin-1.3.34/Lib/modula3/typemaps.i new file mode 100644 index 0000000..79ddfda --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/modula3/typemaps.i @@ -0,0 +1,77 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * typemaps.i + * + * Pointer and reference handling typemap library + * + * These mappings provide support for input/output arguments and common + * uses for C/C++ pointers and C++ references. + * ----------------------------------------------------------------------------- */ + +/* These typemaps will eventually probably maybe make their way into named typemaps + * OUTPUT * and OUTPUT & as they currently break functions that return a pointer or + * reference. */ + +%typemap(ctype) bool *, bool & "bool *" +%typemap(ctype) char & "char *" +%typemap(ctype) signed char *, signed char & "signed char *" +%typemap(ctype) unsigned char *, unsigned char & "unsigned short *" +%typemap(ctype) short *, short & "short *" +%typemap(ctype) unsigned short *, unsigned short & "unsigned short *" +%typemap(ctype) int *, int & "int *" +%typemap(ctype) unsigned int *, unsigned int & "unsigned int *" +%typemap(ctype) long *, long & "long *" +%typemap(ctype) unsigned long *, unsigned long & "unsigned long *" +%typemap(ctype) long long *, long long & "long long *" +%typemap(ctype) unsigned long long *, unsigned long long & "unsigned long long *" +%typemap(ctype) float *, float & "float *" +%typemap(ctype) double *, double & "double *" + +%typemap(imtype) bool *, bool & "ref bool" +%typemap(imtype) char & "ref char" +%typemap(imtype) signed char *, signed char & "ref sbyte" +%typemap(imtype) unsigned char *, unsigned char & "ref byte" +%typemap(imtype) short *, short & "ref short" +%typemap(imtype) unsigned short *, unsigned short & "ref ushort" +%typemap(imtype) int *, int & "ref int" +%typemap(imtype) unsigned int *, unsigned int & "ref uint" +%typemap(imtype) long *, long & "ref int" +%typemap(imtype) unsigned long *, unsigned long & "ref uint" +%typemap(imtype) long long *, long long & "ref long" +%typemap(imtype) unsigned long long *, unsigned long long & "ref ulong" +%typemap(imtype) float *, float & "ref float" +%typemap(imtype) double *, double & "ref double" + +%typemap(cstype) bool *, bool & "ref bool" +%typemap(cstype) char & "ref char" +%typemap(cstype) signed char *, signed char & "ref sbyte" +%typemap(cstype) unsigned char *, unsigned char & "ref byte" +%typemap(cstype) short *, short & "ref short" +%typemap(cstype) unsigned short *, unsigned short & "ref ushort" +%typemap(cstype) int *, int & "ref int" +%typemap(cstype) unsigned int *, unsigned int & "ref uint" +%typemap(cstype) long *, long & "ref int" +%typemap(cstype) unsigned long *, unsigned long & "ref uint" +%typemap(cstype) long long *, long long & "ref long" +%typemap(cstype) unsigned long long *, unsigned long long & "ref ulong" +%typemap(cstype) float *, float & "ref float" +%typemap(cstype) double *, double & "ref double" + +%typemap(csin) bool *, bool &, + char &, + signed char *, signed char &, + unsigned char *, unsigned char &, + short *, short &, + unsigned short *, unsigned short &, + int *, int &, + unsigned int *, unsigned int &, + long *, long &, + unsigned long *, unsigned long &, + long long *, long long &, + unsigned long long *, unsigned long long &, + float *, float &, + double *, double & + "ref $csinput" + diff --git a/devtools/swigwin-1.3.34/Lib/mzscheme/Makefile b/devtools/swigwin-1.3.34/Lib/mzscheme/Makefile new file mode 100644 index 0000000..ff66f9e --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/mzscheme/Makefile @@ -0,0 +1,4 @@ + +co:: + co RCS/*.i* RCS/*.swg* + diff --git a/devtools/swigwin-1.3.34/Lib/mzscheme/mzrun.swg b/devtools/swigwin-1.3.34/Lib/mzscheme/mzrun.swg new file mode 100644 index 0000000..3b05d24 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/mzscheme/mzrun.swg @@ -0,0 +1,511 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * mzrun.swg + * ----------------------------------------------------------------------------- */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <limits.h> +#include <escheme.h> +#include <assert.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* Common SWIG API */ + +#define SWIG_ConvertPtr(s, result, type, flags) \ + SWIG_MzScheme_ConvertPtr(s, result, type, flags) +#define SWIG_NewPointerObj(ptr, type, owner) \ + SWIG_MzScheme_NewPointerObj((void *)ptr, type, owner) +#define SWIG_MustGetPtr(s, type, argnum, flags) \ + SWIG_MzScheme_MustGetPtr(s, type, argnum, flags, FUNC_NAME, argc, argv) + +#define SWIG_contract_assert(expr,msg) \ + if (!(expr)) { \ + char *m=(char *) scheme_malloc(strlen(msg)+1000); \ + sprintf(m,"SWIG contract, assertion failed: function=%s, message=%s", \ + (char *) FUNC_NAME,(char *) msg); \ + scheme_signal_error(m); \ + } + +/* Runtime API */ +#define SWIG_GetModule(clientdata) SWIG_MzScheme_GetModule((Scheme_Env *)(clientdata)) +#define SWIG_SetModule(clientdata, pointer) SWIG_MzScheme_SetModule((Scheme_Env *) (clientdata), pointer) +#define SWIG_MODULE_CLIENTDATA_TYPE Scheme_Env * + +/* MzScheme-specific SWIG API */ + +#define SWIG_malloc(size) SWIG_MzScheme_Malloc(size, FUNC_NAME) +#define SWIG_free(mem) free(mem) +#define SWIG_NewStructFromPtr(ptr,type) \ + _swig_convert_struct_##type##(ptr) + +#define MAXVALUES 6 +#define swig_make_boolean(b) (b ? scheme_true : scheme_false) + +static long +SWIG_convert_integer(Scheme_Object *o, + long lower_bound, long upper_bound, + const char *func_name, int argnum, int argc, + Scheme_Object **argv) +{ + long value; + int status = scheme_get_int_val(o, &value); + if (!status) + scheme_wrong_type(func_name, "integer", argnum, argc, argv); + if (value < lower_bound || value > upper_bound) + scheme_wrong_type(func_name, "integer", argnum, argc, argv); + return value; +} + +static int +SWIG_is_integer(Scheme_Object *o) +{ + long value; + return scheme_get_int_val(o, &value); +} + +static unsigned long +SWIG_convert_unsigned_integer(Scheme_Object *o, + unsigned long lower_bound, unsigned long upper_bound, + const char *func_name, int argnum, int argc, + Scheme_Object **argv) +{ + unsigned long value; + int status = scheme_get_unsigned_int_val(o, &value); + if (!status) + scheme_wrong_type(func_name, "integer", argnum, argc, argv); + if (value < lower_bound || value > upper_bound) + scheme_wrong_type(func_name, "integer", argnum, argc, argv); + return value; +} + +static int +SWIG_is_unsigned_integer(Scheme_Object *o) +{ + unsigned long value; + return scheme_get_unsigned_int_val(o, &value); +} + +/* ----------------------------------------------------------------------- + * mzscheme 30X support code + * Contributed by Hans Oesterholt + * ----------------------------------------------------------------------- */ + +#ifndef SCHEME_STR_VAL +#define MZSCHEME30X 1 +#endif + +#ifdef MZSCHEME30X +/* + * This is MZSCHEME 299.100 or higher (30x). From version 299.100 of + * mzscheme upwards, strings are in unicode. These functions convert + * to and from utf8 encodings of these strings. NB! strlen(s) will be + * the size in bytes of the string, not the actual length. + */ +#define SCHEME_STR_VAL(obj) SCHEME_BYTE_STR_VAL(scheme_char_string_to_byte_string(obj)) +#define SCHEME_STRLEN_VAL(obj) SCHEME_BYTE_STRLEN_VAL(scheme_char_string_to_byte_string(obj)) +#define SCHEME_STRINGP(obj) SCHEME_CHAR_STRINGP(obj) +#define scheme_make_string(s) scheme_make_utf8_string(s) +#define scheme_make_sized_string(s,l) scheme_make_sized_utf8_string(s,l) +#define scheme_make_sized_offset_string(s,d,l) \ + scheme_make_sized_offset_utf8_string(s,d,l) +#define SCHEME_MAKE_STRING(s) scheme_make_utf8_string(s) +#else +#define SCHEME_MAKE_STRING(s) scheme_make_string_without_copying(s) +#endif +/* ----------------------------------------------------------------------- + * End of mzscheme 30X support code + * ----------------------------------------------------------------------- */ + +struct swig_mz_proxy { + Scheme_Type mztype; + swig_type_info *type; + void *object; +}; + +static Scheme_Type swig_type; + +static void +mz_free_swig(void *p, void *data) { + struct swig_mz_proxy *proxy = (struct swig_mz_proxy *) p; + if (SCHEME_NULLP((Scheme_Object*)p) || SCHEME_TYPE((Scheme_Object*)p) != swig_type) + return; + if (proxy->type) { + if (proxy->type->clientdata) { + ((Scheme_Prim *)proxy->type->clientdata)(1, (Scheme_Object **)&proxy); + } + } +} + +static Scheme_Object * +SWIG_MzScheme_NewPointerObj(void *ptr, swig_type_info *type, int owner) { + struct swig_mz_proxy *new_proxy; + new_proxy = (struct swig_mz_proxy *) scheme_malloc(sizeof(struct swig_mz_proxy)); + new_proxy->mztype = swig_type; + new_proxy->type = type; + new_proxy->object = ptr; + if (owner) { + scheme_add_finalizer(new_proxy, mz_free_swig, NULL); + } + return (Scheme_Object *) new_proxy; +} + +static int +SWIG_MzScheme_ConvertPtr(Scheme_Object *s, void **result, swig_type_info *type, int flags) { + swig_cast_info *cast; + + if (SCHEME_NULLP(s)) { + *result = NULL; + return 0; + } else if (SCHEME_TYPE(s) == swig_type) { + struct swig_mz_proxy *proxy = (struct swig_mz_proxy *) s; + if (type) { + cast = SWIG_TypeCheckStruct(proxy->type, type); + if (cast) { + int newmemory = 0; + *result = SWIG_TypeCast(cast, proxy->object, &newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + return 0; + } else { + return 1; + } + } else { + *result = proxy->object; + return 0; + } + } + return 1; +} + +static SWIGINLINE void * +SWIG_MzScheme_MustGetPtr(Scheme_Object *s, swig_type_info *type, + int argnum, int flags, const char *func_name, + int argc, Scheme_Object **argv) { + void *result; + if (SWIG_MzScheme_ConvertPtr(s, &result, type, flags)) { + scheme_wrong_type(func_name, type->str ? type->str : "void *", argnum - 1, argc, argv); + } + return result; +} + +static SWIGINLINE void * +SWIG_MzScheme_Malloc(size_t size, const char *func_name) { + void *p = malloc(size); + if (p == NULL) { + scheme_signal_error("swig-memory-error"); + } else return p; +} + +static Scheme_Object * +SWIG_MzScheme_PackageValues(int num, Scheme_Object **values) { + /* ignore first value if void */ + if (num > 0 && SCHEME_VOIDP(values[0])) + num--, values++; + if (num == 0) return scheme_void; + else if (num == 1) return values[0]; + else return scheme_values(num, values); +} + +#ifndef scheme_make_inspector +#define scheme_make_inspector(x,y) \ + _scheme_apply(scheme_builtin_value("make-inspector"), x, y) +#endif + +/* Function to create a new struct. */ +static Scheme_Object * +SWIG_MzScheme_new_scheme_struct (Scheme_Env* env, const char* basename, + int num_fields, char** field_names) +{ + Scheme_Object *new_type; + int count_out, i; + Scheme_Object **struct_names; + Scheme_Object **vals; + Scheme_Object **a = (Scheme_Object**) \ + scheme_malloc(num_fields*sizeof(Scheme_Object*)); + + for (i=0; i<num_fields; ++i) { + a[i] = (Scheme_Object*) scheme_intern_symbol(field_names[i]); + } + + new_type = scheme_make_struct_type(scheme_intern_symbol(basename), + NULL /*super_type*/, + scheme_make_inspector(0, NULL), + num_fields, + 0 /* auto_fields */, + NULL /* auto_val */, + NULL /* properties */ +#ifdef MZSCHEME30X + ,NULL /* Guard */ +#endif + ); + struct_names = scheme_make_struct_names(scheme_intern_symbol(basename), + scheme_build_list(num_fields,a), + 0 /*flags*/, &count_out); + vals = scheme_make_struct_values(new_type, struct_names, count_out, 0); + + for (i = 0; i < count_out; i++) + scheme_add_global_symbol(struct_names[i], vals[i],env); + + return new_type; +} + +/*** DLOPEN PATCH ****************************************************** + * Contributed by Hans Oesterholt-Dijkema (jan. 2006) + ***********************************************************************/ + +#if defined(_WIN32) || defined(__WIN32__) +#define __OS_WIN32 +#endif + +#ifdef __OS_WIN32 +#include <windows.h> +#else +#include <dlfcn.h> +#endif + + static char **mz_dlopen_libraries=NULL; + static void **mz_libraries=NULL; + static char **mz_dynload_libpaths=NULL; + + static void mz_set_dlopen_libraries(const char *_libs) + { + int i,k,n; + int mz_dynload_debug=(1==0); + char *extra_paths[1000]; + char *EP; + + { + char *dbg=getenv("MZ_DYNLOAD_DEBUG"); + if (dbg!=NULL) { + mz_dynload_debug=atoi(dbg); + } + } + + { + char *ep=getenv("MZ_DYNLOAD_LIBPATH"); + int i,k,j; + k=0; + if (ep!=NULL) { + EP=strdup(ep); + for(i=0,j=0;EP[i]!='\0';i++) { + if (EP[i]==':') { + EP[i]='\0'; + extra_paths[k++]=&EP[j]; + j=i+1; + } + } + if (j!=i) { + extra_paths[k++]=&EP[j]; + } + } + else { + EP=strdup(""); + } + extra_paths[k]=NULL; + k+=1; + + if (mz_dynload_debug) { + fprintf(stderr,"SWIG:mzscheme:MZ_DYNLOAD_LIBPATH=%s\n",(ep==NULL) ? "(null)" : ep); + fprintf(stderr,"SWIG:mzscheme:extra_paths[%d]\n",k-1); + for(i=0;i<k-1;i++) { + fprintf(stderr,"SWIG:mzscheme:extra_paths[%d]=%s\n",i,extra_paths[i]); + } + } + + mz_dynload_libpaths=(char **) malloc(sizeof(char *)*k); + for(i=0;i<k;i++) { + if (extra_paths[i]!=NULL) { + mz_dynload_libpaths[i]=strdup(extra_paths[i]); + } + else { + mz_dynload_libpaths[i]=NULL; + } + } + + if (mz_dynload_debug) { + int i; + for(i=0;extra_paths[i]!=NULL;i++) { + fprintf(stderr,"SWIG:mzscheme:%s\n",extra_paths[i]); + } + } + } + + { +#ifdef MZ_DYNLOAD_LIBS + char *libs=(char *) malloc((strlen(MZ_DYNLOAD_LIBS)+1)*sizeof(char)); + strcpy(libs,MZ_DYNLOAD_LIBS); +#else + char *libs=(char *) malloc((strlen(_libs)+1)*sizeof(char)); + strcpy(libs,_libs); +#endif + + for(i=0,n=strlen(libs),k=0;i<n;i++) { + if (libs[i]==',') { k+=1; } + } + k+=1; + mz_dlopen_libraries=(char **) malloc(sizeof(char *)*(k+1)); + mz_dlopen_libraries[0]=libs; + for(i=0,k=1,n=strlen(libs);i<n;i++) { + if (libs[i]==',') { + libs[i]='\0'; + mz_dlopen_libraries[k++]=&libs[i+1]; + i+=1; + } + } + + if (mz_dynload_debug) { + fprintf(stderr,"k=%d\n",k); + } + mz_dlopen_libraries[k]=NULL; + + free(EP); + } + } + + static void *mz_load_function(char *function) + { + int mz_dynload_debug=(1==0); + + { + char *dbg=getenv("MZ_DYNLOAD_DEBUG"); + if (dbg!=NULL) { + mz_dynload_debug=atoi(dbg); + } + } + + if (mz_dlopen_libraries==NULL) { + return NULL; + } + else { + if (mz_libraries==NULL) { + int i,n; + for(n=0;mz_dlopen_libraries[n]!=NULL;n++); + if (mz_dynload_debug) { + fprintf(stderr,"SWIG:mzscheme:n=%d\n",n); + } + mz_libraries=(void **) malloc(sizeof(void*)*n); + for(i=0;i<n;i++) { + if (mz_dynload_debug) { + fprintf(stderr,"SWIG:mzscheme:loading %s\n",mz_dlopen_libraries[i]); + } +#ifdef __OS_WIN32 + mz_libraries[i]=(void *) LoadLibrary(mz_dlopen_libraries[i]); +#else + mz_libraries[i]=(void *) dlopen(mz_dlopen_libraries[i],RTLD_LAZY); +#endif + if (mz_libraries[i]==NULL) { + int k; + char *libp; + for(k=0;mz_dynload_libpaths[k]!=NULL && mz_libraries[i]==NULL;k++) { + int L=strlen(mz_dynload_libpaths[k])+strlen("\\")+strlen(mz_dlopen_libraries[i])+1; + libp=(char *) malloc(L*sizeof(char)); +#ifdef __OS_WIN32 + sprintf(libp,"%s\\%s",mz_dynload_libpaths[k],mz_dlopen_libraries[i]); + mz_libraries[i]=(void *) LoadLibrary(libp); +#else + sprintf(libp,"%s/%s",mz_dynload_libpaths[k],mz_dlopen_libraries[i]); + mz_libraries[i]=(void *) dlopen(libp,RTLD_LAZY); +#endif + if (mz_dynload_debug) { + fprintf(stderr,"SWIG:mzscheme:trying %s --> %p\n",libp,mz_libraries[i]); + } + free(libp); + } + } + } + } + { + int i; + void *func=NULL; + + for(i=0;mz_dlopen_libraries[i]!=NULL && func==NULL;i++) { + if (mz_libraries[i]!=NULL) { +#ifdef __OS_WIN32 + func=GetProcAddress(mz_libraries[i],function); +#else + func=dlsym(mz_libraries[i],function); +#endif + } + if (mz_dynload_debug) { + fprintf(stderr, + "SWIG:mzscheme:library:%s;dlopen=%p,function=%s,func=%p\n", + mz_dlopen_libraries[i],mz_libraries[i],function,func + ); + } + } + + return func; + } + } + } + +/*** DLOPEN PATCH ****************************************************** + * Contributed by Hans Oesterholt-Dijkema (jan. 2006) + ***********************************************************************/ + +/* The interpreter will store a pointer to this structure in a global + variable called swig-runtime-data-type-pointer. The instance of this + struct is only used if no other module has yet been loaded */ +struct swig_mzscheme_runtime_data { + swig_module_info *module_head; + Scheme_Type type; +}; +static struct swig_mzscheme_runtime_data swig_mzscheme_runtime_data; + + +static swig_module_info * +SWIG_MzScheme_GetModule(Scheme_Env *env) { + Scheme_Object *pointer, *symbol; + struct swig_mzscheme_runtime_data *data; + + /* first check if pointer already created */ + symbol = scheme_intern_symbol("swig-runtime-data-type-pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); + pointer = scheme_lookup_global(symbol, env); + if (pointer && SCHEME_CPTRP(pointer)) { + data = (struct swig_mzscheme_runtime_data *) SCHEME_CPTR_VAL(pointer); + swig_type = data->type; + return data->module_head; + } else { + return NULL; + } +} + +static void +SWIG_MzScheme_SetModule(Scheme_Env *env, swig_module_info *module) { + Scheme_Object *pointer, *symbol; + struct swig_mzscheme_runtime_data *data; + + /* first check if pointer already created */ + symbol = scheme_intern_symbol("swig-runtime-data-type-pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); + pointer = scheme_lookup_global(symbol, env); + if (pointer && SCHEME_CPTRP(pointer)) { + data = (struct swig_mzscheme_runtime_data *) SCHEME_CPTR_VAL(pointer); + swig_type = data->type; + data->module_head = module; + } else { + /* create a new type for wrapped pointer values */ + swig_type = scheme_make_type((char *)"swig"); + swig_mzscheme_runtime_data.module_head = module; + swig_mzscheme_runtime_data.type = swig_type; + + /* create a new pointer */ +#ifndef MZSCHEME30X + pointer = scheme_make_cptr((void *) &swig_mzscheme_runtime_data, "swig_mzscheme_runtime_data"); +#else + pointer = scheme_make_cptr((void *) &swig_mzscheme_runtime_data, + scheme_make_byte_string("swig_mzscheme_runtime_data")); +#endif + scheme_add_global_symbol(symbol, pointer, env); + } +} + +#ifdef __cplusplus +} +#endif + diff --git a/devtools/swigwin-1.3.34/Lib/mzscheme/mzscheme.swg b/devtools/swigwin-1.3.34/Lib/mzscheme/mzscheme.swg new file mode 100644 index 0000000..ed4b2ec --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/mzscheme/mzscheme.swg @@ -0,0 +1,58 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * mzscheme.swg + * + * SWIG Configuration File for MzScheme. + * This file is parsed by SWIG before reading any other interface file. + * ----------------------------------------------------------------------------- */ + +/* Include headers */ +%runtime "swigrun.swg" // Common C API type-checking code +%runtime "mzrun.swg" + +%define SWIG_APPEND_VALUE(value) + values[lenv++] = value +%enddef + +/* Definitions */ +#define SWIG_malloc(size) swig_malloc(size, FUNC_NAME) +#define SWIG_free(mem) free(mem) + +#define SWIG_convert_short(o) \ + SWIG_convert_integer(o, - (1 << (8 * sizeof(short) - 1)), \ + (1 << (8 * sizeof(short) - 1)) - 1, \ + FUNC_NAME, $argnum-1, argc, argv) +#define SWIG_convert_int(o) \ + SWIG_convert_integer(o, INT_MIN, INT_MAX, \ + FUNC_NAME, $argnum-1, argc, argv) +#define SWIG_convert_long(o) \ + SWIG_convert_integer(o, LONG_MIN, LONG_MAX, \ + FUNC_NAME, $argnum-1, argc, argv) +#define SWIG_convert_unsigned_short(o) \ + SWIG_convert_unsigned_integer(o, 0, \ + (1 << (8 * sizeof(short))) - 1, \ + FUNC_NAME, $argnum-1, argc, argv) +#define SWIG_convert_unsigned_int(o) \ + SWIG_convert_unsigned_integer(o, 0, UINT_MAX, \ + FUNC_NAME, $argnum-1, argc, argv) +#define SWIG_convert_unsigned_long(o) \ + SWIG_convert_unsigned_integer(o, 0, ULONG_MAX, \ + FUNC_NAME, $argnum-1, argc, argv) + +/* Guile compatibility kludges */ +#define SCM_VALIDATE_VECTOR(argnum, value) (void)0 +#define SCM_VALIDATE_LIST(argnum, value) (void)0 + +/* Read in standard typemaps. */ +%include <typemaps.i> + +%insert(init) "swiginit.swg" + +%init %{ +Scheme_Object *scheme_reload(Scheme_Env *env) { + Scheme_Env *menv = SWIG_MZSCHEME_CREATE_MENV(env); + + SWIG_InitializeModule((void *) env); +%} diff --git a/devtools/swigwin-1.3.34/Lib/mzscheme/std_common.i b/devtools/swigwin-1.3.34/Lib/mzscheme/std_common.i new file mode 100644 index 0000000..8732f81 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/mzscheme/std_common.i @@ -0,0 +1,23 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_common.i + * + * SWIG typemaps for STL - common utilities + * ----------------------------------------------------------------------------- */ + +%include <std/std_except.i> + +%apply size_t { std::size_t }; + +%{ +#include <string> + +std::string swig_scm_to_string(Scheme_Object* x) { + return std::string(SCHEME_STR_VAL(x)); +} +Scheme_Object* swig_make_string(const std::string& s) { + return scheme_make_string(s.c_str()); +} +%} diff --git a/devtools/swigwin-1.3.34/Lib/mzscheme/std_deque.i b/devtools/swigwin-1.3.34/Lib/mzscheme/std_deque.i new file mode 100644 index 0000000..cb98f6c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/mzscheme/std_deque.i @@ -0,0 +1 @@ +%include <std/_std_deque.i> diff --git a/devtools/swigwin-1.3.34/Lib/mzscheme/std_map.i b/devtools/swigwin-1.3.34/Lib/mzscheme/std_map.i new file mode 100644 index 0000000..aff720d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/mzscheme/std_map.i @@ -0,0 +1,1351 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_map.i + * + * SWIG typemaps for std::map + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +// ------------------------------------------------------------------------ +// std::map +// +// The aim of all that follows would be to integrate std::map with +// MzScheme as much as possible, namely, to allow the user to pass and +// be returned Scheme association lists. +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::map<T>), f(const std::map<T>&), f(const std::map<T>*): +// the parameter being read-only, either a Scheme alist or a +// previously wrapped std::map<T> can be passed. +// -- f(std::map<T>&), f(std::map<T>*): +// the parameter must be modified; therefore, only a wrapped std::map +// can be passed. +// -- std::map<T> f(): +// the map is returned by copy; therefore, a Scheme alist +// is returned which is most easily used in other Scheme functions +// -- std::map<T>& f(), std::map<T>* f(), const std::map<T>& f(), +// const std::map<T>* f(): +// the map is returned by reference; therefore, a wrapped std::map +// is returned +// ------------------------------------------------------------------------ + +%{ +#include <map> +#include <algorithm> +#include <stdexcept> +%} + +// exported class + +namespace std { + + template<class K, class T> class map { + %typemap(in) map<K,T> (std::map<K,T>* m) { + if (SCHEME_NULLP($input)) { + $1 = std::map<K,T >(); + } else if (SCHEME_PAIRP($input)) { + $1 = std::map<K,T >(); + Scheme_Object* alist = $input; + while (!SCHEME_NULLP(alist)) { + K* k; + T* x; + Scheme_Object *entry, *key, *val; + entry = scheme_car(alist); + if (!SCHEME_PAIRP(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = scheme_car(entry); + val = scheme_cdr(entry); + k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) == -1) { + if (!SCHEME_PAIRP(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = scheme_car(val); + x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); + } + (($1_type &)$1)[*k] = *x; + alist = scheme_cdr(alist); + } + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const map<K,T>& (std::map<K,T> temp, + std::map<K,T>* m), + const map<K,T>* (std::map<K,T> temp, + std::map<K,T>* m) { + if (SCHEME_NULLP($input)) { + temp = std::map<K,T >(); + $1 = &temp; + } else if (SCHEME_PAIRP($input)) { + temp = std::map<K,T >(); + $1 = &temp; + Scheme_Object* alist = $input; + while (!SCHEME_NULLP(alist)) { + K* k; + T* x; + Scheme_Object *entry, *key, *val; + entry = scheme_car(alist); + if (!SCHEME_PAIRP(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = scheme_car(entry); + val = scheme_cdr(entry); + k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) == -1) { + if (!SCHEME_PAIRP(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = scheme_car(val); + x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); + } + temp[*k] = *x; + alist = scheme_cdr(alist); + } + } else { + $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) map<K,T> { + Scheme_Object* alist = scheme_null; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + K* key = new K(i->first); + T* val = new T(i->second); + Scheme_Object* k = SWIG_NewPointerObj(key,$descriptor(K *), 1); + Scheme_Object* x = SWIG_NewPointerObj(val,$descriptor(T *), 1); + Scheme_Object* entry = scheme_make_pair(k,x); + alist = scheme_make_pair(entry,alist); + } + $result = alist; + } + %typecheck(SWIG_TYPECHECK_MAP) map<K,T> { + /* native sequence? */ + if (SCHEME_NULLP($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (SCHEME_PAIRP($input)) { + /* check the first element only */ + K* k; + T* x; + Scheme_Object* head = scheme_car($input); + if (SCHEME_PAIRP(head)) { + Scheme_Object* key = scheme_car(head); + Scheme_Object* val = scheme_cdr(head); + if (SWIG_ConvertPtr(key,(void**) &k, + $descriptor(K *), 0) == -1) { + $1 = 0; + } else { + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) != -1) { + $1 = 1; + } else if (SCHEME_PAIRP(val)) { + val = scheme_car(val); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) != -1) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + /* wrapped map? */ + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_MAP) const map<K,T>&, + const map<K,T>* { + /* native sequence? */ + if (SCHEME_NULLP($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (SCHEME_PAIRP($input)) { + /* check the first element only */ + K* k; + T* x; + Scheme_Object* head = scheme_car($input); + if (SCHEME_PAIRP(head)) { + Scheme_Object* key = scheme_car(head); + Scheme_Object* val = scheme_cdr(head); + if (SWIG_ConvertPtr(key,(void**) &k, + $descriptor(K *), 0) == -1) { + $1 = 0; + } else { + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) != -1) { + $1 = 1; + } else if (SCHEME_PAIRP(val)) { + val = scheme_car(val); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) != -1) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + /* wrapped map? */ + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %rename("length") size; + %rename("null?") empty; + %rename("clear!") clear; + %rename("ref") __getitem__; + %rename("set!") __setitem__; + %rename("delete!") __delitem__; + %rename("has-key?") has_key; + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T& __getitem__(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void __setitem__(const K& key, const T& x) { + (*self)[key] = x; + } + void __delitem__(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + Scheme_Object* keys() { + Scheme_Object* result = scheme_null; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + K* key = new K(i->first); + Scheme_Object* k = SWIG_NewPointerObj(key,$descriptor(K *), 1); + result = scheme_make_pair(k,result); + } + return result; + } + } + }; + + + // specializations for built-ins + + %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) + + template<class T> class map<K,T> { + %typemap(in) map<K,T> (std::map<K,T>* m) { + if (SCHEME_NULLP($input)) { + $1 = std::map<K,T >(); + } else if (SCHEME_PAIRP($input)) { + $1 = std::map<K,T >(); + Scheme_Object* alist = $input; + while (!SCHEME_NULLP(alist)) { + T* x; + Scheme_Object *entry, *key, *val; + entry = scheme_car(alist); + if (!SCHEME_PAIRP(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = scheme_car(entry); + val = scheme_cdr(entry); + if (!CHECK(key)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) == -1) { + if (!SCHEME_PAIRP(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = scheme_car(val); + x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); + } + (($1_type &)$1)[CONVERT_FROM(key)] = *x; + alist = scheme_cdr(alist); + } + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const map<K,T>& (std::map<K,T> temp, + std::map<K,T>* m), + const map<K,T>* (std::map<K,T> temp, + std::map<K,T>* m) { + if (SCHEME_NULLP($input)) { + temp = std::map<K,T >(); + $1 = &temp; + } else if (SCHEME_PAIRP($input)) { + temp = std::map<K,T >(); + $1 = &temp; + Scheme_Object* alist = $input; + while (!SCHEME_NULLP(alist)) { + T* x; + Scheme_Object *entry, *key, *val; + entry = scheme_car(alist); + if (!SCHEME_PAIRP(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = scheme_car(entry); + val = scheme_cdr(entry); + if (!CHECK(key)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) == -1) { + if (!SCHEME_PAIRP(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = scheme_car(val); + x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); + } + temp[CONVERT_FROM(key)] = *x; + alist = scheme_cdr(alist); + } + } else { + $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) map<K,T> { + Scheme_Object* alist = scheme_null; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + T* val = new T(i->second); + Scheme_Object* k = CONVERT_TO(i->first); + Scheme_Object* x = SWIG_NewPointerObj(val,$descriptor(T *), 1); + Scheme_Object* entry = scheme_make_pair(k,x); + alist = scheme_make_pair(entry,alist); + } + $result = alist; + } + %typecheck(SWIG_TYPECHECK_MAP) map<K,T> { + // native sequence? + if (SCHEME_NULLP($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (SCHEME_PAIRP($input)) { + // check the first element only + T* x; + Scheme_Object* head = scheme_car($input); + if (SCHEME_PAIRP(head)) { + Scheme_Object* key = scheme_car(head); + Scheme_Object* val = scheme_cdr(head); + if (!CHECK(key)) { + $1 = 0; + } else { + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) != -1) { + $1 = 1; + } else if (SCHEME_PAIRP(val)) { + val = scheme_car(val); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) != -1) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + // wrapped map? + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_MAP) const map<K,T>&, + const map<K,T>* { + // native sequence? + if (SCHEME_NULLP($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (SCHEME_PAIRP($input)) { + // check the first element only + T* x; + Scheme_Object* head = scheme_car($input); + if (SCHEME_PAIRP(head)) { + Scheme_Object* key = scheme_car(head); + Scheme_Object* val = scheme_cdr(head); + if (!CHECK(key)) { + $1 = 0; + } else { + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) != -1) { + $1 = 1; + } else if (SCHEME_PAIRP(val)) { + val = scheme_car(val); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) != -1) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + // wrapped map? + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %rename("length") size; + %rename("null?") empty; + %rename("clear!") clear; + %rename("ref") __getitem__; + %rename("set!") __setitem__; + %rename("delete!") __delitem__; + %rename("has-key?") has_key; + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T& __getitem__(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void __setitem__(K key, const T& x) { + (*self)[key] = x; + } + void __delitem__(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(K key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + Scheme_Object* keys() { + Scheme_Object* result = scheme_null; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + Scheme_Object* k = CONVERT_TO(i->first); + result = scheme_make_pair(k,result); + } + return result; + } + } + }; + %enddef + + %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) + template<class K> class map<K,T> { + %typemap(in) map<K,T> (std::map<K,T>* m) { + if (SCHEME_NULLP($input)) { + $1 = std::map<K,T >(); + } else if (SCHEME_PAIRP($input)) { + $1 = std::map<K,T >(); + Scheme_Object* alist = $input; + while (!SCHEME_NULLP(alist)) { + K* k; + Scheme_Object *entry, *key, *val; + entry = scheme_car(alist); + if (!SCHEME_PAIRP(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = scheme_car(entry); + val = scheme_cdr(entry); + k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); + if (!CHECK(val)) { + if (!SCHEME_PAIRP(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = scheme_car(val); + if (!CHECK(val)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + } + (($1_type &)$1)[*k] = CONVERT_FROM(val); + alist = scheme_cdr(alist); + } + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const map<K,T>& (std::map<K,T> temp, + std::map<K,T>* m), + const map<K,T>* (std::map<K,T> temp, + std::map<K,T>* m) { + if (SCHEME_NULLP($input)) { + temp = std::map<K,T >(); + $1 = &temp; + } else if (SCHEME_PAIRP($input)) { + temp = std::map<K,T >(); + $1 = &temp; + Scheme_Object* alist = $input; + while (!SCHEME_NULLP(alist)) { + K* k; + Scheme_Object *entry, *key, *val; + entry = scheme_car(alist); + if (!SCHEME_PAIRP(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = scheme_car(entry); + val = scheme_cdr(entry); + k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); + if (!CHECK(val)) { + if (!SCHEME_PAIRP(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = scheme_car(val); + if (!CHECK(val)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + } + temp[*k] = CONVERT_FROM(val); + alist = scheme_cdr(alist); + } + } else { + $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) map<K,T> { + Scheme_Object* alist = scheme_null; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + K* key = new K(i->first); + Scheme_Object* k = SWIG_NewPointerObj(key,$descriptor(K *), 1); + Scheme_Object* x = CONVERT_TO(i->second); + Scheme_Object* entry = scheme_make_pair(k,x); + alist = scheme_make_pair(entry,alist); + } + $result = alist; + } + %typecheck(SWIG_TYPECHECK_MAP) map<K,T> { + // native sequence? + if (SCHEME_NULLP($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (SCHEME_PAIRP($input)) { + // check the first element only + K* k; + Scheme_Object* head = scheme_car($input); + if (SCHEME_PAIRP(head)) { + Scheme_Object* key = scheme_car(head); + Scheme_Object* val = scheme_cdr(head); + if (SWIG_ConvertPtr(val,(void **) &k, + $descriptor(K *), 0) == -1) { + $1 = 0; + } else { + if (CHECK(val)) { + $1 = 1; + } else if (SCHEME_PAIRP(val)) { + val = scheme_car(val); + if (CHECK(val)) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + // wrapped map? + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_MAP) const map<K,T>&, + const map<K,T>* { + // native sequence? + if (SCHEME_NULLP($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (SCHEME_PAIRP($input)) { + // check the first element only + K* k; + Scheme_Object* head = scheme_car($input); + if (SCHEME_PAIRP(head)) { + Scheme_Object* key = scheme_car(head); + Scheme_Object* val = scheme_cdr(head); + if (SWIG_ConvertPtr(val,(void **) &k, + $descriptor(K *), 0) == -1) { + $1 = 0; + } else { + if (CHECK(val)) { + $1 = 1; + } else if (SCHEME_PAIRP(val)) { + val = scheme_car(val); + if (CHECK(val)) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + // wrapped map? + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %rename("length") size; + %rename("null?") empty; + %rename("clear!") clear; + %rename("ref") __getitem__; + %rename("set!") __setitem__; + %rename("delete!") __delitem__; + %rename("has-key?") has_key; + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T __getitem__(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void __setitem__(const K& key, T x) { + (*self)[key] = x; + } + void __delitem__(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + Scheme_Object* keys() { + Scheme_Object* result = scheme_null; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + K* key = new K(i->first); + Scheme_Object* k = SWIG_NewPointerObj(key,$descriptor(K *), 1); + result = scheme_make_pair(k,result); + } + return result; + } + } + }; + %enddef + + %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, + T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) + template<> class map<K,T> { + %typemap(in) map<K,T> (std::map<K,T>* m) { + if (SCHEME_NULLP($input)) { + $1 = std::map<K,T >(); + } else if (SCHEME_PAIRP($input)) { + $1 = std::map<K,T >(); + Scheme_Object* alist = $input; + while (!SCHEME_NULLP(alist)) { + Scheme_Object *entry, *key, *val; + entry = scheme_car(alist); + if (!SCHEME_PAIRP(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = scheme_car(entry); + val = scheme_cdr(entry); + if (!CHECK_K(key)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + if (!CHECK_T(val)) { + if (!SCHEME_PAIRP(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = scheme_car(val); + if (!CHECK_T(val)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + } + (($1_type &)$1)[CONVERT_K_FROM(key)] = + CONVERT_T_FROM(val); + alist = scheme_cdr(alist); + } + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const map<K,T>& (std::map<K,T> temp, + std::map<K,T>* m), + const map<K,T>* (std::map<K,T> temp, + std::map<K,T>* m) { + if (SCHEME_NULLP($input)) { + temp = std::map<K,T >(); + $1 = &temp; + } else if (SCHEME_PAIRP($input)) { + temp = std::map<K,T >(); + $1 = &temp; + Scheme_Object* alist = $input; + while (!SCHEME_NULLP(alist)) { + Scheme_Object *entry, *key, *val; + entry = scheme_car(alist); + if (!SCHEME_PAIRP(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = scheme_car(entry); + val = scheme_cdr(entry); + if (!CHECK_K(key)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + if (!CHECK_T(val)) { + if (!SCHEME_PAIRP(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = scheme_car(val); + if (!CHECK_T(val)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + } + temp[CONVERT_K_FROM(key)] = CONVERT_T_FROM(val); + alist = scheme_cdr(alist); + } + } else { + $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) map<K,T> { + Scheme_Object* alist = scheme_null; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + Scheme_Object* k = CONVERT_K_TO(i->first); + Scheme_Object* x = CONVERT_T_TO(i->second); + Scheme_Object* entry = scheme_make_pair(k,x); + alist = scheme_make_pair(entry,alist); + } + $result = alist; + } + %typecheck(SWIG_TYPECHECK_MAP) map<K,T> { + // native sequence? + if (SCHEME_NULLP($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (SCHEME_PAIRP($input)) { + // check the first element only + Scheme_Object* head = scheme_car($input); + if (SCHEME_PAIRP(head)) { + Scheme_Object* key = scheme_car(head); + Scheme_Object* val = scheme_cdr(head); + if (!CHECK_K(key)) { + $1 = 0; + } else { + if (CHECK_T(val)) { + $1 = 1; + } else if (SCHEME_PAIRP(val)) { + val = scheme_car(val); + if (CHECK_T(val)) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + // wrapped map? + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_MAP) const map<K,T>&, + const map<K,T>* { + // native sequence? + if (SCHEME_NULLP($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (SCHEME_PAIRP($input)) { + // check the first element only + Scheme_Object* head = scheme_car($input); + if (SCHEME_PAIRP(head)) { + Scheme_Object* key = scheme_car(head); + Scheme_Object* val = scheme_cdr(head); + if (!CHECK_K(key)) { + $1 = 0; + } else { + if (CHECK_T(val)) { + $1 = 1; + } else if (SCHEME_PAIRP(val)) { + val = scheme_car(val); + if (CHECK_T(val)) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + // wrapped map? + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %rename("length") size; + %rename("null?") empty; + %rename("clear!") clear; + %rename("ref") __getitem__; + %rename("set!") __setitem__; + %rename("delete!") __delitem__; + %rename("has-key?") has_key; + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T __getitem__(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void __setitem__(K key, T x) { + (*self)[key] = x; + } + void __delitem__(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(K key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + Scheme_Object* keys() { + Scheme_Object* result = scheme_null; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + Scheme_Object* k = CONVERT_K_TO(i->first); + result = scheme_make_pair(k,result); + } + return result; + } + } + }; + %enddef + + + specialize_std_map_on_key(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_map_on_key(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_key(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_key(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_key(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_key(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_key(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_key(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_key(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_key(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + + specialize_std_map_on_value(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_map_on_value(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_value(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_value(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_value(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_value(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_value(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_value(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_value(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_value(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + + specialize_std_map_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_map_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_map_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_map_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_map_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_map_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_map_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_map_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_map_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_map_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_map_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_map_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_map_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_map_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_map_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_map_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_map_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_map_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_map_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_map_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_map_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_map_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); +} diff --git a/devtools/swigwin-1.3.34/Lib/mzscheme/std_pair.i b/devtools/swigwin-1.3.34/Lib/mzscheme/std_pair.i new file mode 100644 index 0000000..2ac331e --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/mzscheme/std_pair.i @@ -0,0 +1,873 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_pair.i + * + * SWIG typemaps for std::pair + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <exception.i> + + +// ------------------------------------------------------------------------ +// std::pair +// +// See std_vector.i for the rationale of typemap application +// ------------------------------------------------------------------------ + +%{ +#include <utility> +%} + +// exported class + +namespace std { + + template<class T, class U> struct pair { + %typemap(in) pair<T,U> (std::pair<T,U>* m) { + if (SCHEME_PAIRP($input)) { + T* x; + U* y; + Scheme_Object *first, *second; + first = scheme_car($input); + second = scheme_cdr($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); + $1 = std::make_pair(*x,*y); + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const pair<T,U>& (std::pair<T,U> temp, + std::pair<T,U>* m), + const pair<T,U>* (std::pair<T,U> temp, + std::pair<T,U>* m) { + if (SCHEME_PAIRP($input)) { + T* x; + U* y; + Scheme_Object *first, *second; + first = scheme_car($input); + second = scheme_cdr($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); + temp = std::make_pair(*x,*y); + $1 = &temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) pair<T,U> { + T* x = new T($1.first); + U* y = new U($1.second); + Scheme_Object* first = SWIG_NewPointerObj(x,$descriptor(T *), 1); + Scheme_Object* second = SWIG_NewPointerObj(y,$descriptor(U *), 1); + $result = scheme_make_pair(first,second); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair<T,U> { + /* native pair? */ + if (SCHEME_PAIRP($input)) { + T* x; + U* y; + Scheme_Object* first = scheme_car($input); + Scheme_Object* second = scheme_cdr($input); + if (SWIG_ConvertPtr(first,(void**) &x, + $descriptor(T *), 0) != -1 && + SWIG_ConvertPtr(second,(void**) &y, + $descriptor(U *), 0) != -1) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $&1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair<T,U>&, + const pair<T,U>* { + /* native pair? */ + if (SCHEME_PAIRP($input)) { + T* x; + U* y; + Scheme_Object* first = scheme_car($input); + Scheme_Object* second = scheme_cdr($input); + if (SWIG_ConvertPtr(first,(void**) &x, + $descriptor(T *), 0) != -1 && + SWIG_ConvertPtr(second,(void**) &y, + $descriptor(U *), 0) != -1) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + pair(); + pair(T first, U second); + pair(const pair& p); + + template <class U1, class U2> pair(const pair<U1, U2> &p); + + T first; + U second; + }; + + // specializations for built-ins + + %define specialize_std_pair_on_first(T,CHECK,CONVERT_FROM,CONVERT_TO) + template<class U> struct pair<T,U> { + %typemap(in) pair<T,U> (std::pair<T,U>* m) { + if (SCHEME_PAIRP($input)) { + U* y; + Scheme_Object *first, *second; + first = scheme_car($input); + second = scheme_cdr($input); + if (!CHECK(first)) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); + $1 = std::make_pair(CONVERT_FROM(first),*y); + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const pair<T,U>& (std::pair<T,U> temp, + std::pair<T,U>* m), + const pair<T,U>* (std::pair<T,U> temp, + std::pair<T,U>* m) { + if (SCHEME_PAIRP($input)) { + U* y; + Scheme_Object *first, *second; + first = scheme_car($input); + second = scheme_cdr($input); + if (!CHECK(first)) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); + temp = std::make_pair(CONVERT_FROM(first),*y); + $1 = &temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) pair<T,U> { + U* y = new U($1.second); + Scheme_Object* second = SWIG_NewPointerObj(y,$descriptor(U *), 1); + $result = scheme_make_pair(CONVERT_TO($1.first),second); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair<T,U> { + /* native pair? */ + if (SCHEME_PAIRP($input)) { + U* y; + Scheme_Object* first = scheme_car($input); + Scheme_Object* second = scheme_cdr($input); + if (CHECK(first) && + SWIG_ConvertPtr(second,(void**) &y, + $descriptor(U *), 0) != -1) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $&1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair<T,U>&, + const pair<T,U>* { + /* native pair? */ + if (SCHEME_PAIRP($input)) { + U* y; + Scheme_Object* first = scheme_car($input); + Scheme_Object* second = scheme_cdr($input); + if (CHECK(first) && + SWIG_ConvertPtr(second,(void**) &y, + $descriptor(U *), 0) != -1) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + pair(); + pair(T first, U second); + pair(const pair& p); + + template <class U1, class U2> pair(const pair<U1, U2> &p); + + T first; + U second; + }; + %enddef + + %define specialize_std_pair_on_second(U,CHECK,CONVERT_FROM,CONVERT_TO) + template<class T> struct pair<T,U> { + %typemap(in) pair<T,U> (std::pair<T,U>* m) { + if (SCHEME_PAIRP($input)) { + T* x; + Scheme_Object *first, *second; + first = scheme_car($input); + second = scheme_cdr($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + if (!CHECK(second)) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + $1 = std::make_pair(*x,CONVERT_FROM(second)); + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const pair<T,U>& (std::pair<T,U> temp, + std::pair<T,U>* m), + const pair<T,U>* (std::pair<T,U> temp, + std::pair<T,U>* m) { + if (SCHEME_PAIRP($input)) { + T* x; + Scheme_Object *first, *second; + first = scheme_car($input); + second = scheme_cdr($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + if (!CHECK(second)) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + temp = std::make_pair(*x,CONVERT_FROM(second)); + $1 = &temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) pair<T,U> { + T* x = new T($1.first); + Scheme_Object* first = SWIG_NewPointerObj(x,$descriptor(T *), 1); + $result = scheme_make_pair(first,CONVERT_TO($1.second)); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair<T,U> { + /* native pair? */ + if (SCHEME_PAIRP($input)) { + T* x; + Scheme_Object* first = scheme_car($input); + Scheme_Object* second = scheme_cdr($input); + if (SWIG_ConvertPtr(first,(void**) &x, + $descriptor(T *), 0) != -1 && + CHECK(second)) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $&1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair<T,U>&, + const pair<T,U>* { + /* native pair? */ + if (SCHEME_PAIRP($input)) { + T* x; + Scheme_Object* first = scheme_car($input); + Scheme_Object* second = scheme_cdr($input); + if (SWIG_ConvertPtr(first,(void**) &x, + $descriptor(T *), 0) != -1 && + CHECK(second)) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + pair(); + pair(T first, U second); + pair(const pair& p); + + template <class U1, class U2> pair(const pair<U1, U2> &p); + + T first; + U second; + }; + %enddef + + %define specialize_std_pair_on_both(T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO, + U,CHECK_U,CONVERT_U_FROM,CONVERT_U_TO) + template<> struct pair<T,U> { + %typemap(in) pair<T,U> (std::pair<T,U>* m) { + if (SCHEME_PAIRP($input)) { + Scheme_Object *first, *second; + first = scheme_car($input); + second = scheme_cdr($input); + if (!CHECK_T(first) || !CHECK_U(second)) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + $1 = make_pair(CONVERT_T_FROM(first), + CONVERT_U_FROM(second)); + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const pair<T,U>& (std::pair<T,U> temp, + std::pair<T,U>* m), + const pair<T,U>* (std::pair<T,U> temp, + std::pair<T,U>* m) { + if (SCHEME_PAIRP($input)) { + Scheme_Object *first, *second; + T *x; + first = scheme_car($input); + second = scheme_cdr($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + if (!CHECK_T(first) || !CHECK_U(second)) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + temp = make_pair(CONVERT_T_FROM(first), + CONVERT_U_FROM(second)); + $1 = &temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) pair<T,U> { + $result = scheme_make_pair(CONVERT_T_TO($1.first), + CONVERT_U_TO($1.second)); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair<T,U> { + /* native pair? */ + if (SCHEME_PAIRP($input)) { + Scheme_Object* first = scheme_car($input); + Scheme_Object* second = scheme_cdr($input); + if (CHECK_T(first) && CHECK_U(second)) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $&1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair<T,U>&, + const pair<T,U>* { + /* native pair? */ + if (SCHEME_PAIRP($input)) { + Scheme_Object* first = scheme_car($input); + Scheme_Object* second = scheme_cdr($input); + if (CHECK_T(first) && CHECK_U(second)) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + pair(); + pair(T first, U second); + pair(const pair& p); + + template <class U1, class U2> pair(const pair<U1, U2> &p); + + T first; + U second; + }; + %enddef + + + specialize_std_pair_on_first(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_first(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_first(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_first(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_first(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_first(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_first(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_first(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_first(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_first(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + + specialize_std_pair_on_second(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_second(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_second(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_second(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_second(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_second(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_second(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_second(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_second(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_second(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + + specialize_std_pair_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_pair_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_pair_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_pair_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_pair_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_pair_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_pair_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_pair_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_pair_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_pair_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); +} diff --git a/devtools/swigwin-1.3.34/Lib/mzscheme/std_string.i b/devtools/swigwin-1.3.34/Lib/mzscheme/std_string.i new file mode 100644 index 0000000..c9a82ef --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/mzscheme/std_string.i @@ -0,0 +1,60 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_string.i + * + * SWIG typemaps for std::string types + * ----------------------------------------------------------------------------- */ + +// ------------------------------------------------------------------------ +// std::string is typemapped by value +// This can prevent exporting methods which return a string +// in order for the user to modify it. +// However, I think I'll wait until someone asks for it... +// ------------------------------------------------------------------------ + +%include <exception.i> + +%{ +#include <string> +%} + +namespace std { + + %naturalvar string; + + class string; + + /* Overloading check */ + + %typemap(typecheck) string = char *; + %typemap(typecheck) const string & = char *; + + %typemap(in) string { + if (SCHEME_STRINGP($input)) + $1.assign(SCHEME_STR_VAL($input)); + else + SWIG_exception(SWIG_TypeError, "string expected"); + } + + %typemap(in) const string & (std::string temp) { + if (SCHEME_STRINGP($input)) { + temp.assign(SCHEME_STR_VAL($input)); + $1 = &temp; + } else { + SWIG_exception(SWIG_TypeError, "string expected"); + } + } + + %typemap(out) string { + $result = scheme_make_string($1.c_str()); + } + + %typemap(out) const string & { + $result = scheme_make_string($1->c_str()); + } + +} + + diff --git a/devtools/swigwin-1.3.34/Lib/mzscheme/std_vector.i b/devtools/swigwin-1.3.34/Lib/mzscheme/std_vector.i new file mode 100644 index 0000000..90a52fc --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/mzscheme/std_vector.i @@ -0,0 +1,436 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_vector.i + * + * SWIG typemaps for std::vector + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +// ------------------------------------------------------------------------ +// std::vector +// +// The aim of all that follows would be to integrate std::vector with +// MzScheme as much as possible, namely, to allow the user to pass and +// be returned MzScheme vectors or lists. +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::vector<T>), f(const std::vector<T>&), f(const std::vector<T>*): +// the parameter being read-only, either a MzScheme sequence or a +// previously wrapped std::vector<T> can be passed. +// -- f(std::vector<T>&), f(std::vector<T>*): +// the parameter must be modified; therefore, only a wrapped std::vector +// can be passed. +// -- std::vector<T> f(): +// the vector is returned by copy; therefore, a MzScheme vector of T:s +// is returned which is most easily used in other MzScheme functions +// -- std::vector<T>& f(), std::vector<T>* f(), const std::vector<T>& f(), +// const std::vector<T>* f(): +// the vector is returned by reference; therefore, a wrapped std::vector +// is returned +// ------------------------------------------------------------------------ + +%{ +#include <vector> +#include <algorithm> +#include <stdexcept> +%} + +// exported class + +namespace std { + + template<class T> class vector { + %typemap(in) vector<T> { + if (SCHEME_VECTORP($input)) { + unsigned int size = SCHEME_VEC_SIZE($input); + $1 = std::vector<T >(size); + Scheme_Object** items = SCHEME_VEC_ELS($input); + for (unsigned int i=0; i<size; i++) { + (($1_type &)$1)[i] = + *((T*) SWIG_MustGetPtr(items[i], + $descriptor(T *), + $argnum, 0)); + } + } else if (SCHEME_NULLP($input)) { + $1 = std::vector<T >(); + } else if (SCHEME_PAIRP($input)) { + Scheme_Object *head, *tail; + $1 = std::vector<T >(); + tail = $input; + while (!SCHEME_NULLP(tail)) { + head = scheme_car(tail); + tail = scheme_cdr(tail); + $1.push_back(*((T*)SWIG_MustGetPtr(head, + $descriptor(T *), + $argnum, 0))); + } + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const vector<T>& (std::vector<T> temp), + const vector<T>* (std::vector<T> temp) { + if (SCHEME_VECTORP($input)) { + unsigned int size = SCHEME_VEC_SIZE($input); + temp = std::vector<T >(size); + $1 = &temp; + Scheme_Object** items = SCHEME_VEC_ELS($input); + for (unsigned int i=0; i<size; i++) { + temp[i] = *((T*) SWIG_MustGetPtr(items[i], + $descriptor(T *), + $argnum, 0)); + } + } else if (SCHEME_NULLP($input)) { + temp = std::vector<T >(); + $1 = &temp; + } else if (SCHEME_PAIRP($input)) { + temp = std::vector<T >(); + $1 = &temp; + Scheme_Object *head, *tail; + tail = $input; + while (!SCHEME_NULLP(tail)) { + head = scheme_car(tail); + tail = scheme_cdr(tail); + temp.push_back(*((T*) SWIG_MustGetPtr(head, + $descriptor(T *), + $argnum, 0))); + } + } else { + $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) vector<T> { + $result = scheme_make_vector($1.size(),scheme_undefined); + Scheme_Object** els = SCHEME_VEC_ELS($result); + for (unsigned int i=0; i<$1.size(); i++) { + T* x = new T((($1_type &)$1)[i]); + els[i] = SWIG_NewPointerObj(x,$descriptor(T *), 1); + } + } + %typecheck(SWIG_TYPECHECK_VECTOR) vector<T> { + /* native sequence? */ + if (SCHEME_VECTORP($input)) { + unsigned int size = SCHEME_VEC_SIZE($input); + if (size == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + T* x; + Scheme_Object** items = SCHEME_VEC_ELS($input); + if (SWIG_ConvertPtr(items[0],(void**) &x, + $descriptor(T *), 0) != -1) + $1 = 1; + else + $1 = 0; + } + } else if (SCHEME_NULLP($input)) { + /* again, an empty sequence can be of any type */ + $1 = 1; + } else if (SCHEME_PAIRP($input)) { + /* check the first element only */ + T* x; + Scheme_Object *head = scheme_car($input); + if (SWIG_ConvertPtr(head,(void**) &x, + $descriptor(T *), 0) != -1) + $1 = 1; + else + $1 = 0; + } else { + /* wrapped vector? */ + std::vector<T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $&1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_VECTOR) const vector<T>&, + const vector<T>* { + /* native sequence? */ + if (SCHEME_VECTORP($input)) { + unsigned int size = SCHEME_VEC_SIZE($input); + if (size == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + T* x; + Scheme_Object** items = SCHEME_VEC_ELS($input); + if (SWIG_ConvertPtr(items[0],(void**) &x, + $descriptor(T *), 0) != -1) + $1 = 1; + else + $1 = 0; + } + } else if (SCHEME_NULLP($input)) { + /* again, an empty sequence can be of any type */ + $1 = 1; + } else if (SCHEME_PAIRP($input)) { + /* check the first element only */ + T* x; + Scheme_Object *head = scheme_car($input); + if (SWIG_ConvertPtr(head,(void**) &x, + $descriptor(T *), 0) != -1) + $1 = 1; + else + $1 = 0; + } else { + /* wrapped vector? */ + std::vector<T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + public: + vector(unsigned int size = 0); + vector(unsigned int size, const T& value); + vector(const vector<T>&); + %rename(length) size; + unsigned int size() const; + %rename("empty?") empty; + bool empty() const; + %rename("clear!") clear; + void clear(); + %rename("set!") set; + %rename("pop!") pop; + %rename("push!") push_back; + void push_back(const T& x); + %extend { + T pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty vector"); + T x = self->back(); + self->pop_back(); + return x; + } + T& ref(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("vector index out of range"); + } + void set(int i, const T& x) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + (*self)[i] = x; + else + throw std::out_of_range("vector index out of range"); + } + } + }; + + + // specializations for built-ins + + %define specialize_std_vector(T,CHECK,CONVERT_FROM,CONVERT_TO) + template<> class vector<T> { + %typemap(in) vector<T> { + if (SCHEME_VECTORP($input)) { + unsigned int size = SCHEME_VEC_SIZE($input); + $1 = std::vector<T >(size); + Scheme_Object** items = SCHEME_VEC_ELS($input); + for (unsigned int i=0; i<size; i++) { + Scheme_Object* o = items[i]; + if (CHECK(o)) + (($1_type &)$1)[i] = (T)(CONVERT_FROM(o)); + else + scheme_wrong_type(FUNC_NAME, "vector<" #T ">", + $argnum - 1, argc, argv); + } + } else if (SCHEME_NULLP($input)) { + $1 = std::vector<T >(); + } else if (SCHEME_PAIRP($input)) { + Scheme_Object *head, *tail; + $1 = std::vector<T >(); + tail = $input; + while (!SCHEME_NULLP(tail)) { + head = scheme_car(tail); + tail = scheme_cdr(tail); + if (CHECK(head)) + $1.push_back((T)(CONVERT_FROM(head))); + else + scheme_wrong_type(FUNC_NAME, "vector<" #T ">", + $argnum - 1, argc, argv); + } + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const vector<T>& (std::vector<T> temp), + const vector<T>* (std::vector<T> temp) { + if (SCHEME_VECTORP($input)) { + unsigned int size = SCHEME_VEC_SIZE($input); + temp = std::vector<T >(size); + $1 = &temp; + Scheme_Object** items = SCHEME_VEC_ELS($input); + for (unsigned int i=0; i<size; i++) { + Scheme_Object* o = items[i]; + if (CHECK(o)) + temp[i] = (T)(CONVERT_FROM(o)); + else + scheme_wrong_type(FUNC_NAME, "vector<" #T ">", + $argnum - 1, argc, argv); + } + } else if (SCHEME_NULLP($input)) { + temp = std::vector<T >(); + $1 = &temp; + } else if (SCHEME_PAIRP($input)) { + temp = std::vector<T >(); + $1 = &temp; + Scheme_Object *head, *tail; + tail = $input; + while (!SCHEME_NULLP(tail)) { + head = scheme_car(tail); + tail = scheme_cdr(tail); + if (CHECK(head)) + temp.push_back((T)(CONVERT_FROM(head))); + else + scheme_wrong_type(FUNC_NAME, "vector<" #T ">", + $argnum - 1, argc, argv); + } + } else { + $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum - 1, 0); + } + } + %typemap(out) vector<T> { + $result = scheme_make_vector($1.size(),scheme_undefined); + Scheme_Object** els = SCHEME_VEC_ELS($result); + for (unsigned int i=0; i<$1.size(); i++) + els[i] = CONVERT_TO((($1_type &)$1)[i]); + } + %typecheck(SWIG_TYPECHECK_VECTOR) vector<T> { + /* native sequence? */ + if (SCHEME_VECTORP($input)) { + unsigned int size = SCHEME_VEC_SIZE($input); + if (size == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + T* x; + Scheme_Object** items = SCHEME_VEC_ELS($input); + $1 = CHECK(items[0]) ? 1 : 0; + } + } else if (SCHEME_NULLP($input)) { + /* again, an empty sequence can be of any type */ + $1 = 1; + } else if (SCHEME_PAIRP($input)) { + /* check the first element only */ + T* x; + Scheme_Object *head = scheme_car($input); + $1 = CHECK(head) ? 1 : 0; + } else { + /* wrapped vector? */ + std::vector<T >* v; + $1 = (SWIG_ConvertPtr($input,(void **) &v, + $&1_descriptor, 0) != -1) ? 1 : 0; + } + } + %typecheck(SWIG_TYPECHECK_VECTOR) const vector<T>&, + const vector<T>* { + /* native sequence? */ + if (SCHEME_VECTORP($input)) { + unsigned int size = SCHEME_VEC_SIZE($input); + if (size == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + T* x; + Scheme_Object** items = SCHEME_VEC_ELS($input); + $1 = CHECK(items[0]) ? 1 : 0; + } + } else if (SCHEME_NULLP($input)) { + /* again, an empty sequence can be of any type */ + $1 = 1; + } else if (SCHEME_PAIRP($input)) { + /* check the first element only */ + T* x; + Scheme_Object *head = scheme_car($input); + $1 = CHECK(head) ? 1 : 0; + } else { + /* wrapped vector? */ + std::vector<T >* v; + $1 = (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor, 0) != -1) ? 1 : 0; + } + } + public: + vector(unsigned int size = 0); + vector(unsigned int size, const T& value); + vector(const vector<T>&); + %rename(length) size; + unsigned int size() const; + %rename("empty?") empty; + bool empty() const; + %rename("clear!") clear; + void clear(); + %rename("set!") set; + %rename("pop!") pop; + %rename("push!") push_back; + void push_back(T x); + %extend { + T pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty vector"); + T x = self->back(); + self->pop_back(); + return x; + } + T ref(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("vector index out of range"); + } + void set(int i, T x) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + (*self)[i] = x; + else + throw std::out_of_range("vector index out of range"); + } + } + }; + %enddef + + specialize_std_vector(bool,SCHEME_BOOLP,SCHEME_TRUEP,\ + swig_make_boolean); + specialize_std_vector(char,SCHEME_INTP,SCHEME_INT_VAL,\ + scheme_make_integer_value); + specialize_std_vector(int,SCHEME_INTP,SCHEME_INT_VAL,\ + scheme_make_integer_value); + specialize_std_vector(short,SCHEME_INTP,SCHEME_INT_VAL,\ + scheme_make_integer_value); + specialize_std_vector(long,SCHEME_INTP,SCHEME_INT_VAL,\ + scheme_make_integer_value); + specialize_std_vector(unsigned char,SCHEME_INTP,SCHEME_INT_VAL,\ + scheme_make_integer_value); + specialize_std_vector(unsigned int,SCHEME_INTP,SCHEME_INT_VAL,\ + scheme_make_integer_value); + specialize_std_vector(unsigned short,SCHEME_INTP,SCHEME_INT_VAL,\ + scheme_make_integer_value); + specialize_std_vector(unsigned long,SCHEME_INTP,SCHEME_INT_VAL,\ + scheme_make_integer_value); + specialize_std_vector(float,SCHEME_REALP,scheme_real_to_double,\ + scheme_make_double); + specialize_std_vector(double,SCHEME_REALP,scheme_real_to_double,\ + scheme_make_double); + specialize_std_vector(std::string,SCHEME_STRINGP,swig_scm_to_string,\ + swig_make_string); + +} + diff --git a/devtools/swigwin-1.3.34/Lib/mzscheme/stl.i b/devtools/swigwin-1.3.34/Lib/mzscheme/stl.i new file mode 100644 index 0000000..946e4b7 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/mzscheme/stl.i @@ -0,0 +1,14 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * stl.i + * + * Initial STL definition. extended as needed in each language + * ----------------------------------------------------------------------------- */ +%include <std_common.i> +%include <std_string.i> +%include <std_vector.i> +%include <std_map.i> +%include <std_pair.i> + diff --git a/devtools/swigwin-1.3.34/Lib/mzscheme/typemaps.i b/devtools/swigwin-1.3.34/Lib/mzscheme/typemaps.i new file mode 100644 index 0000000..3348932 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/mzscheme/typemaps.i @@ -0,0 +1,354 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * typemaps.i + * ----------------------------------------------------------------------------- */ + +/* The MzScheme module handles all types uniformly via typemaps. Here + are the definitions. */ + +/* Pointers */ + +%typemap(in) SWIGTYPE * { + $1 = ($ltype) SWIG_MustGetPtr($input, $descriptor, $argnum, 0); +} + +%typemap(in) void * { + $1 = SWIG_MustGetPtr($input, NULL, $argnum, 0); +} + +%typemap(varin) SWIGTYPE * { + $1 = ($ltype) SWIG_MustGetPtr($input, $descriptor, 1, 0); +} + +%typemap(varin) SWIGTYPE & { + $1 = *(($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0)); +} + +%typemap(varin) SWIGTYPE [ANY] { + void *temp; + int ii; + $1_basetype *b = 0; + temp = SWIG_MustGetPtr($input, $1_descriptor, 1, 0); + b = ($1_basetype *) $1; + for (ii = 0; ii < $1_size; ii++) b[ii] = *(($1_basetype *) temp + ii); +} + + +%typemap(varin) void * { + $1 = SWIG_MustGetPtr($input, NULL, 1, 0); +} + +%typemap(out) SWIGTYPE * { + $result = SWIG_NewPointerObj ($1, $descriptor, $owner); +} + +%typemap(out) SWIGTYPE *DYNAMIC { + swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor,(void **) &$1); + $result = SWIG_NewPointerObj ($1, ty, $owner); +} + +%typemap(varout) SWIGTYPE *, SWIGTYPE [] { + $result = SWIG_NewPointerObj ($1, $descriptor, 0); +} + +%typemap(varout) SWIGTYPE & { + $result = SWIG_NewPointerObj((void *) &$1, $1_descriptor, 0); +} + +/* C++ References */ + +#ifdef __cplusplus + +%typemap(in) SWIGTYPE &, const SWIGTYPE & { + $1 = ($ltype) SWIG_MustGetPtr($input, $descriptor, $argnum, 0); + if ($1 == NULL) scheme_signal_error("swig-type-error (null reference)"); +} + +%typemap(out) SWIGTYPE &, const SWIGTYPE & { + $result = SWIG_NewPointerObj ($1, $descriptor, $owner); +} + +%typemap(out) SWIGTYPE &DYNAMIC { + swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor,(void **) &$1); + $result = SWIG_NewPointerObj ($1, ty, $owner); +} + +#endif + +/* Arrays */ + +%typemap(in) SWIGTYPE[] { + $1 = ($ltype) SWIG_MustGetPtr($input, $descriptor, $argnum, 0); +} + +%typemap(out) SWIGTYPE[] { + $result = SWIG_NewPointerObj ($1, $descriptor, $owner); +} + +/* Enums */ +%typemap(in) enum SWIGTYPE { + if (!SWIG_is_integer($input)) + scheme_wrong_type(FUNC_NAME, "integer", $argnum - 1, argc, argv); + $1 = ($1_type) SWIG_convert_int($input); +} + +%typemap(varin) enum SWIGTYPE { + if (!SWIG_is_integer($input)) + scheme_wrong_type(FUNC_NAME, "integer", 0, argc, argv); + $1 = ($1_type) SWIG_convert_int($input); +} + +%typemap(out) enum SWIGTYPE "$result = scheme_make_integer_value($1);"; +%typemap(varout) enum SWIGTYPE "$result = scheme_make_integer_value($1);"; + + +/* Pass-by-value */ + +%typemap(in) SWIGTYPE($&1_ltype argp) { + argp = ($&1_ltype) SWIG_MustGetPtr($input, $&1_descriptor, $argnum, 0); + $1 = *argp; +} + +%typemap(varin) SWIGTYPE { + $&1_ltype argp; + argp = ($&1_ltype) SWIG_MustGetPtr($input, $&1_descriptor, 1, 0); + $1 = *argp; +} + + +%typemap(out) SWIGTYPE +#ifdef __cplusplus +{ + $&1_ltype resultptr; + resultptr = new $1_ltype(($1_ltype &) $1); + $result = SWIG_NewPointerObj (resultptr, $&1_descriptor, 1); +} +#else +{ + $&1_ltype resultptr; + resultptr = ($&1_ltype) malloc(sizeof($1_type)); + memmove(resultptr, &$1, sizeof($1_type)); + $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 1); +} +#endif + +%typemap(varout) SWIGTYPE +#ifdef __cplusplus +{ + $&1_ltype resultptr; + resultptr = new $1_ltype(($1_ltype &) $1); + $result = SWIG_NewPointerObj (resultptr, $&1_descriptor, 0); +} +#else +{ + $&1_ltype resultptr; + resultptr = ($&1_ltype) malloc(sizeof($1_type)); + memmove(resultptr, &$1, sizeof($1_type)); + $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 0); +} +#endif + +/* The SIMPLE_MAP macro below defines the whole set of typemaps needed + for simple types. */ + +%define SIMPLE_MAP(C_NAME, MZ_PREDICATE, MZ_TO_C, C_TO_MZ, MZ_NAME) +%typemap(in) C_NAME { + if (!MZ_PREDICATE($input)) + scheme_wrong_type(FUNC_NAME, #MZ_NAME, $argnum - 1, argc, argv); + $1 = MZ_TO_C($input); +} +%typemap(varin) C_NAME { + if (!MZ_PREDICATE($input)) + scheme_wrong_type(FUNC_NAME, #MZ_NAME, 0, argc, argv); + $1 = MZ_TO_C($input); +} +%typemap(out) C_NAME { + $result = C_TO_MZ($1); +} +%typemap(varout) C_NAME { + $result = C_TO_MZ($1); +} +%typemap(in) C_NAME *INPUT (C_NAME temp) { + temp = (C_NAME) MZ_TO_C($input); + $1 = &temp; +} +%typemap(in,numinputs=0) C_NAME *OUTPUT (C_NAME temp) { + $1 = &temp; +} +%typemap(argout) C_NAME *OUTPUT { + Scheme_Object *s; + s = C_TO_MZ(*$1); + SWIG_APPEND_VALUE(s); +} +%typemap(in) C_NAME *BOTH = C_NAME *INPUT; +%typemap(argout) C_NAME *BOTH = C_NAME *OUTPUT; +%typemap(in) C_NAME *INOUT = C_NAME *INPUT; +%typemap(argout) C_NAME *INOUT = C_NAME *OUTPUT; +%enddef + +SIMPLE_MAP(bool, SCHEME_BOOLP, SCHEME_TRUEP, + swig_make_boolean, boolean); +SIMPLE_MAP(char, SCHEME_CHARP, SCHEME_CHAR_VAL, + scheme_make_character, character); +SIMPLE_MAP(unsigned char, SCHEME_CHARP, SCHEME_CHAR_VAL, + scheme_make_character, character); +SIMPLE_MAP(int, SWIG_is_integer, SWIG_convert_int, + scheme_make_integer_value, integer); +SIMPLE_MAP(short, SWIG_is_integer, SWIG_convert_short, + scheme_make_integer_value, integer); +SIMPLE_MAP(long, SWIG_is_integer, SWIG_convert_long, + scheme_make_integer_value, integer); +SIMPLE_MAP(ptrdiff_t, SWIG_is_integer, SWIG_convert_long, + scheme_make_integer_value, integer); +SIMPLE_MAP(unsigned int, SWIG_is_unsigned_integer, SWIG_convert_unsigned_int, + scheme_make_integer_value_from_unsigned, integer); +SIMPLE_MAP(unsigned short, SWIG_is_unsigned_integer, SWIG_convert_unsigned_short, + scheme_make_integer_value_from_unsigned, integer); +SIMPLE_MAP(unsigned long, SWIG_is_unsigned_integer, SWIG_convert_unsigned_long, + scheme_make_integer_value_from_unsigned, integer); +SIMPLE_MAP(size_t, SWIG_is_unsigned_integer, SWIG_convert_unsigned_long, + scheme_make_integer_value_from_unsigned, integer); +SIMPLE_MAP(float, SCHEME_REALP, scheme_real_to_double, + scheme_make_double, real); +SIMPLE_MAP(double, SCHEME_REALP, scheme_real_to_double, + scheme_make_double, real); + +SIMPLE_MAP(char *, SCHEME_STRINGP, SCHEME_STR_VAL, + SCHEME_MAKE_STRING, string); +SIMPLE_MAP(const char *, SCHEME_STRINGP, SCHEME_STR_VAL, + SCHEME_MAKE_STRING, string); + +/* For MzScheme 30x: Use these typemaps if you are not going to use + UTF8 encodings in your C code. + SIMPLE_MAP(char *,SCHEME_BYTE_STRINGP, SCHEME_BYTE_STR_VAL, + scheme_make_byte_string_without_copying,bytestring); + SIMPLE_MAP(const char *,SCHEME_BYTE_STRINGP, SCHEME_BYTE_STR_VAL, + scheme_make_byte_string_without_copying,bytestring); +*/ + +/* Const primitive references. Passed by value */ + +%define REF_MAP(C_NAME, MZ_PREDICATE, MZ_TO_C, C_TO_MZ, MZ_NAME) + %typemap(in) const C_NAME & (C_NAME temp) { + if (!MZ_PREDICATE($input)) + scheme_wrong_type(FUNC_NAME, #MZ_NAME, $argnum - 1, argc, argv); + temp = MZ_TO_C($input); + $1 = &temp; + } + %typemap(out) const C_NAME & { + $result = C_TO_MZ(*$1); + } +%enddef + +REF_MAP(bool, SCHEME_BOOLP, SCHEME_TRUEP, + swig_make_boolean, boolean); +REF_MAP(char, SCHEME_CHARP, SCHEME_CHAR_VAL, + scheme_make_character, character); +REF_MAP(unsigned char, SCHEME_CHARP, SCHEME_CHAR_VAL, + scheme_make_character, character); +REF_MAP(int, SWIG_is_integer, SWIG_convert_int, + scheme_make_integer_value, integer); +REF_MAP(short, SWIG_is_integer, SWIG_convert_short, + scheme_make_integer_value, integer); +REF_MAP(long, SWIG_is_integer, SWIG_convert_long, + scheme_make_integer_value, integer); +REF_MAP(unsigned int, SWIG_is_unsigned_integer, SWIG_convert_unsigned_int, + scheme_make_integer_value_from_unsigned, integer); +REF_MAP(unsigned short, SWIG_is_unsigned_integer, SWIG_convert_unsigned_short, + scheme_make_integer_value_from_unsigned, integer); +REF_MAP(unsigned long, SWIG_is_unsigned_integer, SWIG_convert_unsigned_long, + scheme_make_integer_value_from_unsigned, integer); +REF_MAP(float, SCHEME_REALP, scheme_real_to_double, + scheme_make_double, real); +REF_MAP(double, SCHEME_REALP, scheme_real_to_double, + scheme_make_double, real); + +/* Void */ + +%typemap(out) void "$result = scheme_void;"; + +/* Pass through Scheme_Object * */ + +%typemap (in) Scheme_Object * "$1=$input;"; +%typemap (out) Scheme_Object * "$result=$1;"; +%typecheck(SWIG_TYPECHECK_POINTER) Scheme_Object * "$1=1;"; + + +/* ------------------------------------------------------------ + * String & length + * ------------------------------------------------------------ */ + +//%typemap(in) (char *STRING, int LENGTH) { +// int temp; +// $1 = ($1_ltype) gh_scm2newstr($input, &temp); +// $2 = ($2_ltype) temp; +//} + + +/* ------------------------------------------------------------ + * Typechecking rules + * ------------------------------------------------------------ */ + +%typecheck(SWIG_TYPECHECK_INTEGER) + int, short, long, + unsigned int, unsigned short, unsigned long, + signed char, unsigned char, + long long, unsigned long long, + const int &, const short &, const long &, + const unsigned int &, const unsigned short &, const unsigned long &, + const long long &, const unsigned long long &, + enum SWIGTYPE +{ + $1 = (SWIG_is_integer($input)) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_BOOL) bool, bool &, const bool & +{ + $1 = (SCHEME_BOOLP($input)) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_DOUBLE) + float, double, + const float &, const double & +{ + $1 = (SCHEME_REALP($input)) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_STRING) char { + $1 = (SCHEME_STRINGP($input)) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_STRING) char * { + $1 = (SCHEME_STRINGP($input)) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] { + void *ptr; + if (SWIG_ConvertPtr($input, (void **) &ptr, $1_descriptor, 0)) { + $1 = 0; + } else { + $1 = 1; + } +} + +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { + void *ptr; + if (SWIG_ConvertPtr($input, (void **) &ptr, $&1_descriptor, 0)) { + $1 = 0; + } else { + $1 = 1; + } +} + +%typecheck(SWIG_TYPECHECK_VOIDPTR) void * { + void *ptr; + if (SWIG_ConvertPtr($input, (void **) &ptr, 0, 0)) { + $1 = 0; + } else { + $1 = 1; + } +} + + diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/carray.i b/devtools/swigwin-1.3.34/Lib/ocaml/carray.i new file mode 100644 index 0000000..bbf1ddd --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/carray.i @@ -0,0 +1,136 @@ +%insert(mli) %{ +type _value = c_obj +%} + +%insert(ml) %{ +type _value = c_obj +%} + +%define %array_tmap_out(type,what,out_f) +%typemap(type) what [ANY] { + int i; + /* $*1_type */ + $result = caml_array_new($1_dim0); + for( i = 0; i < $1_dim0; i++ ) { + caml_array_set($result,i,out_f($1[i])); + } +} +%enddef + +%define %array_tmap_in(type,what,in_f) +%typemap(type) what [ANY] { + int i; + /* $*1_type */ + $1 = ($*1_type *)malloc( $1_size ); + for( i = 0; i < $1_dim0 && i < caml_array_len($input); i++ ) { + $1[i] = in_f(caml_array_nth($input,i)); + } +} + +%typemap(free) what [ANY] { + free( (void *)$1 ); +} +%enddef + +%define %make_simple_array_typemap(type,out_f,in_f) +%array_tmap_out(out,type,out_f); +%array_tmap_out(varout,type,out_f); +%array_tmap_out(directorin,type,out_f); + +%array_tmap_in(in,type,in_f); +%array_tmap_in(varin,type,in_f); +%array_tmap_in(directorout,type,in_f); +%enddef + +%make_simple_array_typemap(bool,caml_val_bool,caml_long_val); +%make_simple_array_typemap(short,caml_val_short,caml_long_val); +%make_simple_array_typemap(unsigned short,caml_val_ushort,caml_long_val); +%make_simple_array_typemap(int,caml_val_int,caml_long_val); +%make_simple_array_typemap(unsigned int,caml_val_uint,caml_long_val); +%make_simple_array_typemap(long,caml_val_long,caml_long_val); +%make_simple_array_typemap(unsigned long,caml_val_ulong,caml_long_val); +%make_simple_array_typemap(size_t,caml_val_int,caml_long_val); +%make_simple_array_typemap(float,caml_val_float,caml_double_val); +%make_simple_array_typemap(double,caml_val_double,caml_double_val); + +#ifdef __cplusplus +%typemap(in) SWIGTYPE [] { + int i; + + /* $*1_type */ + $1 = new $*1_type [$1_dim0]; + for( i = 0; i < $1_dim0 && i < caml_array_len($input); i++ ) { + $1[i] = *(($*1_ltype *) + caml_ptr_val(caml_array_nth($input,i), + $*1_descriptor)) ; + } +} +#else +%typemap(in) SWIGTYPE [] { + int i; + + /* $*1_type */ + $1 = ($*1_type *)malloc( $1_size ); + for( i = 0; i < $1_dim0 && i < caml_array_len($input); i++ ) { + $1[i] = *(($*1_ltype) + caml_ptr_val(caml_array_nth($input), + $*1_descriptor)); + } +} +#endif + +%typemap(out) SWIGTYPE [] { + int i; + CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); + $result = caml_array_new($1_dim0); + + for( i = 0; i < $1_dim0; i++ ) { + if( fromval ) { + caml_array_set + ($result, + i, + callback(*fromval,caml_val_ptr((void *)&$1[i],$*1_descriptor))); + } else { + caml_array_set + ($result, + i, + caml_val_ptr ((void *)&$1[i],$&1_descriptor)); + } + } +} + +%typemap(in) enum SWIGTYPE [] { + int i; + + /* $*1_type */ + $1 = ($*1_type *)malloc( $1_size ); + for( i = 0; i < $1_dim0 && i < caml_array_len($input); i++ ) { + $1[i] = ($type) + caml_long_val_full(caml_array_nth($input), + "$type_marker"); + } +} + +%typemap(out) enum SWIGTYPE [] { + int i; + $result = caml_array_new($1_dim0); + + for( i = 0; i < $1_dim0; i++ ) { + caml_array_set + ($result, + i, + callback2(*caml_named_value(SWIG_MODULE "_int_to_enum"), + *caml_named_value("$type_marker"), + Val_int($1[i]))); + } +} + +#ifdef __cplusplus +%typemap(freearg) SWIGTYPE [ANY] { + delete [] $1; +} +#else +%typemap(freearg) SWIGTYPE [ANY] { + free( (void *)$1 ); +} +#endif diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/class.swg b/devtools/swigwin-1.3.34/Lib/ocaml/class.swg new file mode 100644 index 0000000..0ee304c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/class.swg @@ -0,0 +1,66 @@ +(*Stream:class_ctors*) +let create_$classname_from_ptr raw_ptr = + C_obj +begin + let h = Hashtbl.create 20 in + List.iter (fun (nm,fn) -> Hashtbl.replace h nm fn) + [ "nop", (fun args -> C_void) ; + $classbody + "&", (fun args -> raw_ptr) ; + ":parents", + (fun args -> + C_list + (let out = ref [] in + Hashtbl.iter (fun x y -> out := (x,y) :: !out) h ; + (List.map + (fun (x,y) -> + C_string (String.sub x 2 ((String.length x) - 2))) + (List.filter + (fun (x,y) -> + ((String.length x) > 2) + && x.[0] == ':' && x.[1] == ':') !out)))) ; + ":classof", (fun args -> C_string "$realname") ; + ":methods", (fun args -> + C_list (let out = ref [] in + Hashtbl.iter (fun x y -> out := (C_string x) :: !out) h ; !out)) + ] ; + let rec invoke_inner raw_ptr mth arg = + begin + try + let application = Hashtbl.find h mth in + application + (match arg with + C_list l -> (C_list (raw_ptr :: l)) + | C_void -> (C_list [ raw_ptr ]) + | v -> (C_list [ raw_ptr ; v ])) + with Not_found -> + (* Try parent classes *) + begin + let parent_classes = [ + $baselist + ] in + let rec try_parent plist raw_ptr = + match plist with + p :: tl -> + begin + try + (invoke (p raw_ptr)) mth arg + with (BadMethodName (p,m,s)) -> + try_parent tl raw_ptr + end + | [] -> + raise (BadMethodName (raw_ptr,mth,"$realname")) + in try_parent parent_classes raw_ptr + end + end in + (fun mth arg -> invoke_inner raw_ptr mth arg) +end + +let _ = Callback.register + "create_$normalized_from_ptr" + create_$classname_from_ptr + + +(*Stream:mli*) +val create_$classname_from_ptr : c_obj -> c_obj + diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/cstring.i b/devtools/swigwin-1.3.34/Lib/ocaml/cstring.i new file mode 100644 index 0000000..e562582 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/cstring.i @@ -0,0 +1,271 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * cstring.i + * + * This file provides typemaps and macros for dealing with various forms + * of C character string handling. The primary use of this module + * is in returning character data that has been allocated or changed in + * some way. + * ----------------------------------------------------------------------------- */ + +/* %cstring_input_binary(TYPEMAP, SIZE) + * + * Macro makes a function accept binary string data along with + * a size. + */ + +%define %cstring_input_binary(TYPEMAP, SIZE) +%apply (char *STRING, int LENGTH) { (TYPEMAP, SIZE) }; +%enddef + +/* + * %cstring_bounded_output(TYPEMAP, MAX) + * + * This macro is used to return a NULL-terminated output string of + * some maximum length. For example: + * + * %cstring_bounded_output(char *outx, 512); + * void foo(char *outx) { + * sprintf(outx,"blah blah\n"); + * } + * + */ + +%define %cstring_bounded_output(TYPEMAP,MAX) +%typemap(ignore) TYPEMAP(char temp[MAX+1]) { + $1 = ($1_ltype) temp; +} +%typemap(argout) TYPEMAP { + $1[MAX] = 0; + $result = caml_list_append($result,caml_val_string(str)); +} +%enddef + +/* + * %cstring_chunk_output(TYPEMAP, SIZE) + * + * This macro is used to return a chunk of binary string data. + * Embedded NULLs are okay. For example: + * + * %cstring_chunk_output(char *outx, 512); + * void foo(char *outx) { + * memmove(outx, somedata, 512); + * } + * + */ + +%define %cstring_chunk_output(TYPEMAP,SIZE) +%typemap(ignore) TYPEMAP(char temp[SIZE]) { + $1 = ($1_ltype) temp; +} +%typemap(argout) TYPEMAP { + $result = caml_list_append($result,caml_val_string_len($1,SIZE)); +} +%enddef + +/* + * %cstring_bounded_mutable(TYPEMAP, SIZE) + * + * This macro is used to wrap a string that's going to mutate. + * + * %cstring_bounded_mutable(char *in, 512); + * void foo(in *x) { + * while (*x) { + * *x = toupper(*x); + * x++; + * } + * } + * + */ + + +%define %cstring_bounded_mutable(TYPEMAP,MAX) +%typemap(in) TYPEMAP(char temp[MAX+1]) { + char *t = (char *)caml_ptr_val($input); + strncpy(temp,t,MAX); + $1 = ($1_ltype) temp; +} +%typemap(argout) TYPEMAP { + $result = caml_list_append($result,caml_val_string_len($1,MAX)); +} +%enddef + +/* + * %cstring_mutable(TYPEMAP [, expansion]) + * + * This macro is used to wrap a string that will mutate in place. + * It may change size up to a user-defined expansion. + * + * %cstring_mutable(char *in); + * void foo(in *x) { + * while (*x) { + * *x = toupper(*x); + * x++; + * } + * } + * + */ + +%define %cstring_mutable(TYPEMAP,...) +%typemap(in) TYPEMAP { + char *t = String_val($input); + int n = string_length($input); + $1 = ($1_ltype) t; +#if #__VA_ARGS__ == "" +#ifdef __cplusplus + $1 = ($1_ltype) new char[n+1]; +#else + $1 = ($1_ltype) malloc(n+1); +#endif +#else +#ifdef __cplusplus + $1 = ($1_ltype) new char[n+1+__VA_ARGS__]; +#else + $1 = ($1_ltype) malloc(n+1+__VA_ARGS__); +#endif +#endif + memmove($1,t,n); + $1[n] = 0; +} + +%typemap(argout) TYPEMAP { + $result = caml_list_append($result,caml_val_string($1)); +#ifdef __cplusplus + delete[] $1; +#else + free($1); +#endif +} +%enddef + +/* + * %cstring_output_maxsize(TYPEMAP, SIZE) + * + * This macro returns data in a string of some user-defined size. + * + * %cstring_output_maxsize(char *outx, int max) { + * void foo(char *outx, int max) { + * sprintf(outx,"blah blah\n"); + * } + */ + +%define %cstring_output_maxsize(TYPEMAP, SIZE) +%typemap(in) (TYPEMAP, SIZE) { + $2 = caml_val_long($input); +#ifdef __cplusplus + $1 = ($1_ltype) new char[$2+1]; +#else + $1 = ($1_ltype) malloc($2+1); +#endif +} +%typemap(argout) (TYPEMAP,SIZE) { + $result = caml_list_append($result,caml_val_string($1)); +#ifdef __cplusplus + delete [] $1; +#else + free($1); +#endif +} +%enddef + +/* + * %cstring_output_withsize(TYPEMAP, SIZE) + * + * This macro is used to return character data along with a size + * parameter. + * + * %cstring_output_maxsize(char *outx, int *max) { + * void foo(char *outx, int *max) { + * sprintf(outx,"blah blah\n"); + * *max = strlen(outx); + * } + */ + +%define %cstring_output_withsize(TYPEMAP, SIZE) +%typemap(in) (TYPEMAP, SIZE) { + int n = caml_val_long($input); +#ifdef __cplusplus + $1 = ($1_ltype) new char[n+1]; + $2 = ($2_ltype) new $*1_ltype; +#else + $1 = ($1_ltype) malloc(n+1); + $2 = ($2_ltype) malloc(sizeof($*1_ltype)); +#endif + *$2 = n; +} +%typemap(argout) (TYPEMAP,SIZE) { + $result = caml_list_append($result,caml_val_string_len($1,$2)); +#ifdef __cplusplus + delete [] $1; + delete $2; +#else + free($1); + free($2); +#endif +} +%enddef + +/* + * %cstring_output_allocate(TYPEMAP, RELEASE) + * + * This macro is used to return character data that was + * allocated with new or malloc. + * + * %cstring_output_allocated(char **outx, free($1)); + * void foo(char **outx) { + * *outx = (char *) malloc(512); + * sprintf(outx,"blah blah\n"); + * } + */ + +%define %cstring_output_allocate(TYPEMAP, RELEASE) +%typemap(ignore) TYPEMAP($*1_ltype temp = 0) { + $1 = &temp; +} + +%typemap(argout) TYPEMAP { + if (*$1) { + $result = caml_list_append($result,caml_val_string($1)); + RELEASE; + } else { + $result = caml_list_append($result,caml_val_ptr($1)); + } +} +%enddef + +/* + * %cstring_output_allocate_size(TYPEMAP, SIZE, RELEASE) + * + * This macro is used to return character data that was + * allocated with new or malloc. + * + * %cstring_output_allocated(char **outx, int *sz, free($1)); + * void foo(char **outx, int *sz) { + * *outx = (char *) malloc(512); + * sprintf(outx,"blah blah\n"); + * *sz = strlen(outx); + * } + */ + +%define %cstring_output_allocate_size(TYPEMAP, SIZE, RELEASE) +%typemap(ignore) (TYPEMAP, SIZE) ($*1_ltype temp = 0, $*2_ltype tempn) { + $1 = &temp; + $2 = &tempn; +} + +%typemap(argout)(TYPEMAP,SIZE) { + if (*$1) { + $result = caml_list_append($result,caml_val_string_len($1,$2)); + RELEASE; + } else + $result = caml_list_append($result,caml_val_ptr($1)); +} +%enddef + + + + + + diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/director.swg b/devtools/swigwin-1.3.34/Lib/ocaml/director.swg new file mode 100644 index 0000000..8733316 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/director.swg @@ -0,0 +1,103 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * director.swg + * + * This file contains support for director classes that proxy + * method calls from C++ to Ocaml extensions. + * + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus + +#include <string> + +namespace Swig { + /* base class for director exceptions */ + class DirectorException { + protected: + std::string swig_msg; + public: + DirectorException(const char* msg="") { + } + const char *getMessage() const { + return swig_msg.c_str(); + } + virtual ~DirectorException() {} + }; + + /* type mismatch in the return value from a python method call */ + class DirectorTypeMismatchException : public Swig::DirectorException { + public: + DirectorTypeMismatchException(const char* msg="") { + } + }; + + /* any python exception that occurs during a director method call */ + class DirectorMethodException : public Swig::DirectorException {}; + + /* attempt to call a pure virtual method via a director method */ + class DirectorPureVirtualException : public Swig::DirectorException { + public: + DirectorPureVirtualException(const char* msg="") { + } + + static void raise(const char *msg) { + throw DirectorPureVirtualException(msg); + } + }; + + /* simple thread abstraction for pthreads on win32 */ +#ifdef __THREAD__ +#define __PTHREAD__ +#if defined(_WIN32) || defined(__WIN32__) +#define pthread_mutex_lock EnterCriticalSection +#define pthread_mutex_unlock LeaveCriticalSection +#define pthread_mutex_t CRITICAL_SECTION +#define MUTEX_INIT(var) CRITICAL_SECTION var +#else +#include <pthread.h> +#define MUTEX_INIT(var) pthread_mutex_t var = PTHREAD_MUTEX_INITIALIZER +#endif +#endif + + /* director base class */ + class Director { + private: + /* pointer to the wrapped ocaml object */ + CAML_VALUE swig_self; + /* flag indicating whether the object is owned by ocaml or c++ */ + mutable bool swig_disown_flag; + + public: + /* wrap a ocaml object, optionally taking ownership */ + Director(CAML_VALUE self) : swig_self(self), swig_disown_flag(false) { + register_global_root(&swig_self); + } + + /* discard our reference at destruction */ + virtual ~Director() { + remove_global_root(&swig_self); + swig_disown(); + // Disown is safe here because we're just divorcing a reference that + // points to us. + } + + /* return a pointer to the wrapped ocaml object */ + CAML_VALUE swig_get_self() const { + return swig_self; + } + + /* acquire ownership of the wrapped ocaml object (the sense of "disown" + * is from ocaml) */ + void swig_disown() const { + if (!swig_disown_flag) { + swig_disown_flag=true; + callback(*caml_named_value("caml_obj_disown"),swig_self); + } + } + }; +} + +#endif /* __cplusplus */ diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/extra-install.list b/devtools/swigwin-1.3.34/Lib/ocaml/extra-install.list new file mode 100644 index 0000000..a63c7fc --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/extra-install.list @@ -0,0 +1,5 @@ +# see top-level Makefile.in +# libswigocaml is not needed anymore. +swigp4.ml +swig.mli +swig.ml diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/libswigocaml.h b/devtools/swigwin-1.3.34/Lib/ocaml/libswigocaml.h new file mode 100644 index 0000000..e752540 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/libswigocaml.h @@ -0,0 +1,20 @@ +/* Ocaml runtime support */ + +#ifdef __cplusplus +extern "C" { +#endif + + typedef int oc_bool; + extern void *nullptr; + + extern oc_bool isnull( void *v ); + + extern void *get_char_ptr( char *str ); + extern void *make_ptr_array( int size ); + extern void *get_ptr( void *arrayptr, int elt ); + extern void set_ptr( void *arrayptr, int elt, void *elt_v ); + extern void *offset_ptr( void *ptr, int n ); + +#ifdef __cplusplus +}; +#endif diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/ocaml.i b/devtools/swigwin-1.3.34/Lib/ocaml/ocaml.i new file mode 100644 index 0000000..a46e239 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/ocaml.i @@ -0,0 +1,61 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * ocaml.i + * + * SWIG Configuration File for Ocaml + * ----------------------------------------------------------------------------- */ + +%runtime %{ +#define SWIGSTATIC static +%} + +/* Insert common stuff */ +%insert(runtime) "swigrun.swg" + +/* Include headers */ +%insert(runtime) "ocamldec.swg" + +/* Type registration */ +%insert(init) "swiginit.swg" +%insert(init) "typeregister.swg" + +%insert(mlitail) %{ + val swig_val : c_enum_type -> c_obj -> Swig.c_obj +%} + +%insert(mltail) %{ + let rec swig_val t v = + match v with + C_enum e -> enum_to_int t v + | C_list l -> Swig.C_list (List.map (swig_val t) l) + | C_array a -> Swig.C_array (Array.map (swig_val t) a) + | _ -> Obj.magic v +%} + +/*#ifndef SWIG_NOINCLUDE*/ +%insert(runtime) "ocaml.swg" +/*#endif*/ + +%insert(classtemplate) "class.swg" + +/* Definitions */ +#define SWIG_malloc(size) swig_malloc(size, FUNC_NAME) +#define SWIG_free(mem) free(mem) + +/* Read in standard typemaps. */ +%include <swig.swg> +%include <typemaps.i> +%include <typecheck.i> +%include <exception.i> +%include <preamble.swg> + +/* ocaml keywords */ +/* There's no need to use this, because of my rewriting machinery. C++ + * words never collide with ocaml keywords */ + +/* still we include the file, but the warning says that the offending + name will be properly renamed. Just to let the user to know about + it. */ +%include <ocamlkw.swg> diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/ocaml.swg b/devtools/swigwin-1.3.34/Lib/ocaml/ocaml.swg new file mode 100644 index 0000000..5f8f929 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/ocaml.swg @@ -0,0 +1,602 @@ +/* -*-c-*- */ + +/* SWIG pointer structure */ + +#include <string.h> +#include <assert.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define C_bool 0 +#define C_char 1 +#define C_uchar 2 +#define C_short 3 +#define C_ushort 4 +#define C_int 5 +#define C_uint 6 +#define C_int32 7 +#define C_int64 8 +#define C_float 9 +#define C_double 10 +#define C_ptr 11 +#define C_array 12 +#define C_list 13 +#define C_obj 14 +#define C_string 15 +#define C_enum 16 +#define C_director_core 17 + + +/* Cast a pointer if possible; returns 1 if successful */ + + SWIGSTATIC int + SWIG_Cast (void *source, swig_type_info *source_type, + void **ptr, swig_type_info *dest_type) + { + if( !source ) { // Special case for NULL. This is a popular question + // for other modules on the list, so I want an easy way out... + *ptr = 0; + return 0; + } + +#ifdef TYPE_CAST_VERBOSE + fprintf( stderr, "Trying to cast %s to %s\n", + source_type ? source_type->str : "<none>", + dest_type ? dest_type->str : "<none>" ); +#endif + if (dest_type != source_type) { + /* We have a type mismatch. Will have to look through our type + mapping table to figure out whether or not we can accept this + datatype. + -- + Ignore typechecks for void *. Allow any conversion. */ + if( !dest_type || !source_type || + !strcmp(dest_type->name,"_p_void") || + !strcmp(source_type->name,"_p_void") ) { + *ptr = source; + return 0; + } else { + swig_cast_info *tc = + SWIG_TypeCheckStruct(source_type, dest_type ); +#ifdef TYPE_CAST_VERBOSE + fprintf( stderr, "Typecheck -> %s\n", + tc ? tc->str : "<none>" ); +#endif + if( tc ) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc, source, &newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + return 0; + } else + return -1; + } + } else { + *ptr = source; + return 0; + } + } + +/* Return 0 if successful. */ + SWIGSTATIC int + SWIG_GetPtr(void *inptr, void **outptr, + swig_type_info *intype, swig_type_info *outtype) { + if (intype) { + return SWIG_Cast(inptr, intype, + outptr, outtype) == -1; + } else { + *outptr = inptr; + return 0; + } + } + + SWIGSTATIC void caml_print_list( CAML_VALUE v ); + + SWIGSTATIC void caml_print_val( CAML_VALUE v ) { + switch( SWIG_Tag_val(v) ) { + case C_bool: + if( Bool_val(SWIG_Field(v,0)) ) fprintf( stderr, "true " ); + else fprintf( stderr, "false " ); + break; + case C_char: + case C_uchar: + fprintf( stderr, "'%c' (\\%03d) ", + (Int_val(SWIG_Field(v,0)) >= ' ' && + Int_val(SWIG_Field(v,0)) < 127) ? Int_val(SWIG_Field(v,0)) : '.', + Int_val(SWIG_Field(v,0)) ); + break; + case C_short: + case C_ushort: + case C_int: + fprintf( stderr, "%d ", (int)caml_long_val(v) ); + break; + + case C_uint: + case C_int32: + fprintf( stderr, "%ud ", (unsigned int)caml_long_val(v) ); + break; + case C_int64: + fprintf( stderr, "%ld ", caml_long_val(v) ); + break; + case C_float: + case C_double: + fprintf( stderr, "%f ", caml_double_val(v) ); + break; + + case C_ptr: + { + void *vout = 0; + swig_type_info *ty = (swig_type_info *)(long)SWIG_Int64_val(SWIG_Field(v,1)); + caml_ptr_val_internal(v,&vout,0); + fprintf( stderr, "PTR(%p,%s) ", + vout, + ty ? ty->name : "(null)" ); + } + break; + case C_array: + { + unsigned int i; + for( i = 0; i < Wosize_val( SWIG_Field(v,0) ); i++ ) + caml_print_val( SWIG_Field(SWIG_Field(v,0),i) ); + } + break; + case C_list: + caml_print_list( SWIG_Field(v,0) ); + break; + case C_obj: + fprintf( stderr, "OBJ(%p) ", (void *)SWIG_Field(v,0) ); + break; + case C_string: + { + void *cout; + caml_ptr_val_internal(v,&cout,0); + fprintf( stderr, "'%s' ", (char *)cout ); + } + break; + } + } + + SWIGSTATIC void caml_print_list( CAML_VALUE v ) { + CAMLparam1(v); + while( v && Is_block(v) ) { + fprintf( stderr, "[ " ); + caml_print_val( SWIG_Field(v,0) ); + fprintf( stderr, "]\n" ); + v = SWIG_Field(v,1); + } + CAMLreturn0; + } + + SWIGSTATIC CAML_VALUE caml_list_nth( CAML_VALUE lst, int n ) { + CAMLparam1(lst); + int i = 0; + while( i < n && lst && Is_block(lst) ) { + i++; lst = SWIG_Field(lst,1); + } + if( lst == Val_unit ) CAMLreturn(Val_unit); + else CAMLreturn(SWIG_Field(lst,0)); + } + + SWIGSTATIC CAML_VALUE caml_list_append( CAML_VALUE lst, CAML_VALUE elt ) { + CAMLparam2(lst,elt); + SWIG_CAMLlocal3(v,vt,lh); + lh = Val_unit; + v = Val_unit; + + /* Appending C_void should have no effect */ + if( !Is_block(elt) ) return lst; + + while( lst && Is_block(lst) ) { + if( v && v != Val_unit ) { + vt = alloc_tuple(2); + SWIG_Store_field(v,1,vt); + v = vt; + } else { + v = lh = alloc_tuple(2); + } + SWIG_Store_field(v,0,SWIG_Field(lst,0)); + lst = SWIG_Field(lst,1); + } + + if( v && Is_block(v) ) { + vt = alloc_tuple(2); + SWIG_Store_field(v,1,vt); + v = vt; + } else { + v = lh = alloc_tuple(2); + } + SWIG_Store_field(v,0,elt); + SWIG_Store_field(v,1,Val_unit); + + CAMLreturn(lh); + } + + SWIGSTATIC int caml_list_length( CAML_VALUE lst ) { + CAMLparam1(lst); + int i = 0; + while( lst && Is_block(lst) ) { i++; lst = SWIG_Field(lst,1); } + CAMLreturn(i); + } + + SWIGSTATIC void caml_array_set( CAML_VALUE arr, int n, CAML_VALUE item ) { + CAMLparam2(arr,item); + SWIG_Store_field(SWIG_Field(arr,0),n,item); + CAMLreturn0; + } + + SWIGSTATIC value caml_array_nth( CAML_VALUE arr, int n ) { + CAMLparam1(arr); + if( SWIG_Tag_val(arr) == C_array ) + CAMLreturn(SWIG_Field(SWIG_Field(arr,0),n)); + else if( SWIG_Tag_val(arr) == C_list ) + CAMLreturn(caml_list_nth(arr,0)); + else + failwith("Need array or list"); + } + + SWIGSTATIC int caml_array_len( CAML_VALUE arr ) { + CAMLparam1(arr); + if( SWIG_Tag_val(arr) == C_array ) + CAMLreturn(Wosize_val(SWIG_Field(arr,0))); + else if( SWIG_Tag_val(arr) == C_list ) + CAMLreturn(caml_list_length(arr)); + else + failwith("Need array or list"); + } + + SWIGSTATIC CAML_VALUE caml_swig_alloc(int x,int y) { + return caml_alloc(x,y); + } + + SWIGSTATIC value caml_array_new( int n ) { + CAMLparam0(); + SWIG_CAMLlocal1(vv); + vv = caml_swig_alloc(1,C_array); + SWIG_Store_field(vv,0,alloc_tuple(n)); + CAMLreturn(vv); + } + + SWIGSTATIC CAML_VALUE caml_val_bool( int b ) { + CAMLparam0(); + SWIG_CAMLlocal1(bv); + bv = caml_swig_alloc(1,C_bool); + SWIG_Store_field(bv,0,Val_bool(b)); + CAMLreturn(bv); + } + + SWIGSTATIC CAML_VALUE caml_val_char( char c ) { + CAMLparam0(); + SWIG_CAMLlocal1(cv); + cv = caml_swig_alloc(1,C_char); + SWIG_Store_field(cv,0,Val_int(c)); + CAMLreturn(cv); + } + + SWIGSTATIC CAML_VALUE caml_val_uchar( unsigned char uc ) { + CAMLparam0(); + SWIG_CAMLlocal1(ucv); + ucv = caml_swig_alloc(1,C_uchar); + SWIG_Store_field(ucv,0,Val_int(uc)); + CAMLreturn(ucv); + } + + SWIGSTATIC CAML_VALUE caml_val_short( short s ) { + CAMLparam0(); + SWIG_CAMLlocal1(sv); + sv = caml_swig_alloc(1,C_short); + SWIG_Store_field(sv,0,Val_int(s)); + CAMLreturn(sv); + } + + SWIGSTATIC CAML_VALUE caml_val_ushort( unsigned short us ) { + CAMLparam0(); + SWIG_CAMLlocal1(usv); + usv = caml_swig_alloc(1,C_ushort); + SWIG_Store_field(usv,0,Val_int(us)); + CAMLreturn(usv); + } + + SWIGSTATIC CAML_VALUE caml_val_int( int i ) { + CAMLparam0(); + SWIG_CAMLlocal1(iv); + iv = caml_swig_alloc(1,C_int); + SWIG_Store_field(iv,0,Val_int(i)); + CAMLreturn(iv); + } + + SWIGSTATIC CAML_VALUE caml_val_uint( unsigned int ui ) { + CAMLparam0(); + SWIG_CAMLlocal1(uiv); + uiv = caml_swig_alloc(1,C_int); + SWIG_Store_field(uiv,0,Val_int(ui)); + CAMLreturn(uiv); + } + + SWIGSTATIC CAML_VALUE caml_val_long( long l ) { + CAMLparam0(); + SWIG_CAMLlocal1(lv); + lv = caml_swig_alloc(1,C_int64); + SWIG_Store_field(lv,0,copy_int64(l)); + CAMLreturn(lv); + } + + SWIGSTATIC CAML_VALUE caml_val_ulong( unsigned long ul ) { + CAMLparam0(); + SWIG_CAMLlocal1(ulv); + ulv = caml_swig_alloc(1,C_int64); + SWIG_Store_field(ulv,0,copy_int64(ul)); + CAMLreturn(ulv); + } + + SWIGSTATIC CAML_VALUE caml_val_float( float f ) { + CAMLparam0(); + SWIG_CAMLlocal1(fv); + fv = caml_swig_alloc(1,C_float); + SWIG_Store_field(fv,0,copy_double((double)f)); + CAMLreturn(fv); + } + + SWIGSTATIC CAML_VALUE caml_val_double( double d ) { + CAMLparam0(); + SWIG_CAMLlocal1(fv); + fv = caml_swig_alloc(1,C_double); + SWIG_Store_field(fv,0,copy_double(d)); + CAMLreturn(fv); + } + + SWIGSTATIC CAML_VALUE caml_val_ptr( void *p, swig_type_info *info ) { + CAMLparam0(); + SWIG_CAMLlocal1(vv); + vv = caml_swig_alloc(2,C_ptr); + SWIG_Store_field(vv,0,copy_int64((long)p)); + SWIG_Store_field(vv,1,copy_int64((long)info)); + CAMLreturn(vv); + } + + SWIGSTATIC CAML_VALUE caml_val_string( const char *p ) { + CAMLparam0(); + SWIG_CAMLlocal1(vv); + if( !p ) CAMLreturn(caml_val_ptr( (void *)p, 0 )); + vv = caml_swig_alloc(1,C_string); + SWIG_Store_field(vv,0,copy_string(p)); + CAMLreturn(vv); + } + + SWIGSTATIC CAML_VALUE caml_val_string_len( const char *p, int len ) { + CAMLparam0(); + SWIG_CAMLlocal1(vv); + if( !p || len < 0 ) CAMLreturn(caml_val_ptr( (void *)p, 0 )); + vv = caml_swig_alloc(1,C_string); + SWIG_Store_field(vv,0,alloc_string(len)); + memcpy(String_val(SWIG_Field(vv,0)),p,len); + CAMLreturn(vv); + } + + #define caml_val_obj(v, name) caml_val_obj_helper(v, SWIG_TypeQuery((name)), name) + SWIGSTATIC CAML_VALUE caml_val_obj_helper( void *v, swig_type_info *type, char *name) { + CAMLparam0(); + CAMLreturn(callback2(*caml_named_value("caml_create_object_fn"), + caml_val_ptr(v,type), + copy_string(name))); + } + + SWIGSTATIC long caml_long_val_full( CAML_VALUE v, char *name ) { + CAMLparam1(v); + if( !Is_block(v) ) return 0; + + switch( SWIG_Tag_val(v) ) { + case C_bool: + case C_char: + case C_uchar: + case C_short: + case C_ushort: + case C_int: + CAMLreturn(Int_val(SWIG_Field(v,0))); + case C_uint: + case C_int32: + CAMLreturn(Int32_val(SWIG_Field(v,0))); + case C_int64: + CAMLreturn((long)SWIG_Int64_val(SWIG_Field(v,0))); + case C_float: + case C_double: + CAMLreturn((long)Double_val(SWIG_Field(v,0))); + case C_string: + CAMLreturn((long)String_val(SWIG_Field(v,0))); + case C_ptr: + CAMLreturn((long)SWIG_Int64_val(SWIG_Field(SWIG_Field(v,0),0))); + case C_enum: { + SWIG_CAMLlocal1(ret); + CAML_VALUE *enum_to_int = caml_named_value(SWIG_MODULE "_enum_to_int"); + if( !name ) failwith( "Not an enum conversion" ); + ret = callback2(*enum_to_int,*caml_named_value(name),v); + CAMLreturn(caml_long_val(ret)); + } + default: + failwith("No conversion to int"); + } + } + + SWIGSTATIC long caml_long_val( CAML_VALUE v ) { + return caml_long_val_full(v,0); + } + + SWIGSTATIC double caml_double_val( CAML_VALUE v ) { + CAMLparam1(v); + if( !Is_block(v) ) return 0.0; + switch( SWIG_Tag_val(v) ) { + case C_bool: + case C_char: + case C_uchar: + case C_short: + case C_ushort: + case C_int: + CAMLreturn_type(Int_val(SWIG_Field(v,0))); + case C_uint: + case C_int32: + CAMLreturn_type(Int32_val(SWIG_Field(v,0))); + case C_int64: + CAMLreturn_type(SWIG_Int64_val(SWIG_Field(v,0))); + case C_float: + case C_double: + CAMLreturn_type(Double_val(SWIG_Field(v,0))); + default: + fprintf( stderr, "Unknown block tag %d\n", SWIG_Tag_val(v) ); + failwith("No conversion to double"); + } + } + + SWIGSTATIC int caml_ptr_val_internal( CAML_VALUE v, void **out, + swig_type_info *descriptor ) { + CAMLparam1(v); + void *outptr = NULL; + swig_type_info *outdescr = NULL; + + if( v == Val_unit ) { + *out = 0; + CAMLreturn(0); + } + if( !Is_block(v) ) return -1; + switch( SWIG_Tag_val(v) ) { + case C_int: + if( !caml_long_val( v ) ) { + *out = 0; + CAMLreturn(0); + } else { + *out = 0; + CAMLreturn(1); + } + break; + case C_obj: + CAMLreturn + (caml_ptr_val_internal + (callback(*caml_named_value("caml_obj_ptr"),v), + out,descriptor)); + case C_string: + outptr = (void *)String_val(SWIG_Field(v,0)); + break; + case C_ptr: + outptr = (void *)(long)SWIG_Int64_val(SWIG_Field(v,0)); + outdescr = (swig_type_info *)(long)SWIG_Int64_val(SWIG_Field(v,1)); + break; + default: + *out = 0; + CAMLreturn(1); + break; + } + + CAMLreturn(SWIG_GetPtr(outptr,out,outdescr,descriptor)); + } + + SWIGSTATIC void *caml_ptr_val( CAML_VALUE v, swig_type_info *descriptor ) { + CAMLparam0(); +#ifdef TYPE_CAST_VERBOSE + caml_print_val( v ); +#endif + void *out = NULL; + if( !caml_ptr_val_internal( v, &out, descriptor ) ) + CAMLreturn_type(out); + else + failwith( "No appropriate conversion found." ); + } + + SWIGSTATIC char *caml_string_val( CAML_VALUE v ) { + return (char *)caml_ptr_val( v, 0 ); + } + + SWIGSTATIC int caml_string_len( CAML_VALUE v ) { + switch( SWIG_Tag_val(v) ) { + case C_string: + return string_length(SWIG_Field(v,0)); + default: + return strlen((char *)caml_ptr_val(v,0)); + } + } + + SWIGSTATIC int caml_bool_check( CAML_VALUE v ) { + CAMLparam1(v); + + if( !Is_block(v) ) return 0; + + switch( SWIG_Tag_val(v) ) { + case C_bool: + case C_ptr: + case C_string: + CAMLreturn(1); + default: + CAMLreturn(0); + } + } + + SWIGSTATIC int caml_int_check( CAML_VALUE v ) { + CAMLparam1(v); + + if( !Is_block(v) ) return 0; + + switch( SWIG_Tag_val(v) ) { + case C_char: + case C_uchar: + case C_short: + case C_ushort: + case C_int: + case C_uint: + case C_int32: + case C_int64: + CAMLreturn(1); + + default: + CAMLreturn(0); + } + } + + SWIGSTATIC int caml_float_check( CAML_VALUE v ) { + CAMLparam1(v); + if( !Is_block(v) ) return 0; + + switch( SWIG_Tag_val(v) ) { + case C_float: + case C_double: + CAMLreturn(1); + + default: + CAMLreturn(0); + } + } + + SWIGSTATIC int caml_ptr_check( CAML_VALUE v ) { + CAMLparam1(v); + if( !Is_block(v) ) return 0; + + switch( SWIG_Tag_val(v) ) { + case C_string: + case C_ptr: + case C_int64: + CAMLreturn(1); + + default: + CAMLreturn(0); + } + } + + static swig_module_info *SWIG_Ocaml_GetModule() { + CAML_VALUE pointer; + + pointer = callback(*caml_named_value("swig_find_type_info"), caml_val_int(0)); + if (Is_block(pointer) && SWIG_Tag_val(pointer) == C_ptr) { + return (swig_module_info *)(void *)(long)SWIG_Int64_val(SWIG_Field(pointer,0)); + } + return 0; + } + + static void SWIG_Ocaml_SetModule(swig_module_info *pointer) { + CAML_VALUE mod_pointer; + + mod_pointer = caml_val_ptr(pointer, NULL); + callback(*caml_named_value("swig_set_type_info"), mod_pointer); + } + +#ifdef __cplusplus +} +#endif +#undef value + diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/ocamldec.swg b/devtools/swigwin-1.3.34/Lib/ocaml/ocamldec.swg new file mode 100644 index 0000000..3b5290f --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/ocamldec.swg @@ -0,0 +1,172 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * ocamldec.swg + * + * Ocaml runtime code -- declarations + * ----------------------------------------------------------------------------- */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#ifdef __cplusplus +#define SWIGEXT extern "C" +SWIGEXT { +#else +#define SWIGEXT +#endif +#define value caml_value_t +#define CAML_VALUE caml_value_t +#include <caml/alloc.h> +#include <caml/custom.h> +#include <caml/mlvalues.h> +#include <caml/memory.h> +#include <caml/callback.h> +#include <caml/fail.h> +#include <caml/misc.h> + +#define caml_array_set swig_caml_array_set + +// Adapted from memory.h and mlvalues.h + +#define SWIG_CAMLlocal1(x) \ + caml_value_t x = 0; \ + CAMLxparam1 (x) + +#define SWIG_CAMLlocal2(x, y) \ + caml_value_t x = 0, y = 0; \ + CAMLxparam2 (x, y) + +#define SWIG_CAMLlocal3(x, y, z) \ + caml_value_t x = 0, y = 0, z = 0; \ + CAMLxparam3 (x, y, z) + +#define SWIG_CAMLlocal4(x, y, z, t) \ + caml_value_t x = 0, y = 0, z = 0, t = 0; \ + CAMLxparam4 (x, y, z, t) + +#define SWIG_CAMLlocal5(x, y, z, t, u) \ + caml_value_t x = 0, y = 0, z = 0, t = 0, u = 0; \ + CAMLxparam5 (x, y, z, t, u) + +#define SWIG_CAMLlocalN(x, size) \ + caml_value_t x [(size)] = { 0, /* 0, 0, ... */ }; \ + CAMLxparamN (x, (size)) + +#define SWIG_Field(x, i) (((caml_value_t *)(x)) [i]) /* Also an l-value. */ +#define SWIG_Store_field(block, offset, val) do{ \ + mlsize_t caml__temp_offset = (offset); \ + caml_value_t caml__temp_val = (val); \ + modify (&SWIG_Field ((block), caml__temp_offset), caml__temp_val); \ +}while(0) + +#define SWIG_Data_custom_val(v) ((void *) &SWIG_Field((v), 1)) +#ifdef ARCH_BIG_ENDIAN +#define SWIG_Tag_val(val) (((unsigned char *) (val)) [-1]) + /* Also an l-value. */ +#define SWIG_Tag_hp(hp) (((unsigned char *) (hp)) [sizeof(caml_value_t)-1]) + /* Also an l-value. */ +#else +#define SWIG_Tag_val(val) (((unsigned char *) (val)) [-sizeof(caml_value_t)]) + /* Also an l-value. */ +#define SWIG_Tag_hp(hp) (((unsigned char *) (hp)) [0]) + /* Also an l-value. */ +#endif + +#ifdef CAMLreturn0 +#undef CAMLreturn0 +#endif +#define CAMLreturn0 do{ \ + caml_local_roots = caml__frame; \ + return; \ +}while (0) + +#ifdef CAMLreturn +#undef CAMLreturn +#endif +#define CAMLreturn(result) do{ \ + caml_value_t caml__temp_result = (result); \ + caml_local_roots = caml__frame; \ + return (caml__temp_result); \ +}while(0) + +#define CAMLreturn_type(result) do{ \ + caml_local_roots = caml__frame; \ + return result; \ +}while(0) + +#ifdef CAMLnoreturn +#undef CAMLnoreturn +#endif +#define CAMLnoreturn ((void) caml__frame) + + +#ifndef ARCH_ALIGN_INT64 +#define SWIG_Int64_val(v) (*((int64 *) SWIG_Data_custom_val(v))) +#else +CAMLextern int64 Int64_val(caml_value_t v); +#define SWIG_Int64_val(v) Int64_val(v) +#endif + +#define SWIG_NewPointerObj(p,type,flags) caml_val_ptr(p,type) +#define SWIG_GetModule(clientdata) SWIG_Ocaml_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Ocaml_SetModule(pointer) + +#define SWIG_contract_assert(expr, msg) if(!(expr)) {failwith(msg);} else + + SWIGSTATIC int + SWIG_GetPtr(void *source, void **result, swig_type_info *type, swig_type_info *result_type); + + SWIGSTATIC void * + SWIG_MustGetPtr (CAML_VALUE v, swig_type_info *type); + + SWIGSTATIC CAML_VALUE _wrap_delete_void( CAML_VALUE ); + + SWIGSTATIC int enum_to_int( char *name, CAML_VALUE v ); + SWIGSTATIC CAML_VALUE int_to_enum( char *name, int v ); + + SWIGSTATIC CAML_VALUE caml_list_nth( CAML_VALUE lst, int n ); + SWIGSTATIC CAML_VALUE caml_list_append( CAML_VALUE lst, CAML_VALUE elt ); + SWIGSTATIC int caml_list_length( CAML_VALUE lst ); + SWIGSTATIC CAML_VALUE caml_array_new( int n ); + SWIGSTATIC void caml_array_set( CAML_VALUE arr, int n, CAML_VALUE item ); + SWIGSTATIC CAML_VALUE caml_array_nth( CAML_VALUE arr, int n ); + SWIGSTATIC int caml_array_length( CAML_VALUE arr ); + + SWIGSTATIC CAML_VALUE caml_val_char( char c ); + SWIGSTATIC CAML_VALUE caml_val_uchar( unsigned char c ); + + SWIGSTATIC CAML_VALUE caml_val_short( short s ); + SWIGSTATIC CAML_VALUE caml_val_ushort( unsigned short s ); + + SWIGSTATIC CAML_VALUE caml_val_int( int x ); + SWIGSTATIC CAML_VALUE caml_val_uint( unsigned int x ); + + SWIGSTATIC CAML_VALUE caml_val_long( long x ); + SWIGSTATIC CAML_VALUE caml_val_ulong( unsigned long x ); + + SWIGSTATIC CAML_VALUE caml_val_float( float f ); + SWIGSTATIC CAML_VALUE caml_val_double( double d ); + + SWIGSTATIC CAML_VALUE caml_val_ptr( void *p, swig_type_info *descriptor ); + + SWIGSTATIC CAML_VALUE caml_val_string( const char *str ); + SWIGSTATIC CAML_VALUE caml_val_string_len( const char *str, int len ); + + SWIGSTATIC long caml_long_val( CAML_VALUE v ); + SWIGSTATIC double caml_double_val( CAML_VALUE v ); + + SWIGSTATIC int caml_ptr_val_internal( CAML_VALUE v, void **out, + swig_type_info *descriptor ); + SWIGSTATIC void *caml_ptr_val( CAML_VALUE v, swig_type_info *descriptor ); + + SWIGSTATIC char *caml_string_val( CAML_VALUE v ); + SWIGSTATIC int caml_string_len( CAML_VALUE v ); + +#ifdef __cplusplus +} +#endif + +/* mzschemedec.swg ends here */ diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/ocamlkw.swg b/devtools/swigwin-1.3.34/Lib/ocaml/ocamlkw.swg new file mode 100644 index 0000000..ba06f23 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/ocamlkw.swg @@ -0,0 +1,64 @@ +#ifndef OCAML_OCAMLKW_SWG_ +#define OCAML_OCAMLKW_SWG_ + +/* Warnings for Ocaml keywords */ +#define OCAMLKW(x) %namewarn("314:" #x " is a ocaml keyword and it will properly renamed") #x + +/* + from + http://caml.inria.fr/ocaml/htmlman/manual044.html +*/ + + +OCAMLKW(and); +OCAMLKW(as); +OCAMLKW(assert); +OCAMLKW(begin); +OCAMLKW(class); +OCAMLKW(constraint); +OCAMLKW(do); +OCAMLKW(done); +OCAMLKW(downto); +OCAMLKW(else); +OCAMLKW(end); +OCAMLKW(exception); +OCAMLKW(external); +OCAMLKW(false); +OCAMLKW(for); +OCAMLKW(fun); +OCAMLKW(function); +OCAMLKW(functor); +OCAMLKW(if); +OCAMLKW(in); +OCAMLKW(include); +OCAMLKW(inherit); +OCAMLKW(initializer); +OCAMLKW(lazy); +OCAMLKW(let); +OCAMLKW(match); +OCAMLKW(method); +OCAMLKW(module); +OCAMLKW(mutable); +OCAMLKW(new); +OCAMLKW(object); +OCAMLKW(of); +OCAMLKW(open); +OCAMLKW(or); +OCAMLKW(private); +OCAMLKW(rec); +OCAMLKW(sig); +OCAMLKW(struct); +OCAMLKW(then); +OCAMLKW(to); +OCAMLKW(true); +OCAMLKW(try); +OCAMLKW(type); +OCAMLKW(val); +OCAMLKW(virtual); +OCAMLKW(when); +OCAMLKW(while); +OCAMLKW(with); + +#undef OCAMLKW + +#endif //OCAML_OCAMLKW_SWG_ diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/preamble.swg b/devtools/swigwin-1.3.34/Lib/ocaml/preamble.swg new file mode 100644 index 0000000..39374ce --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/preamble.swg @@ -0,0 +1,17 @@ +%insert(mli) %{ +exception BadArgs of string +exception BadMethodName of c_obj * string * string +exception NotObject of c_obj +exception NotEnumType of c_obj +exception LabelNotFromThisEnum of c_obj +exception InvalidDirectorCall of c_obj +%} + +%insert(ml) %{ +exception BadArgs of string +exception BadMethodName of c_obj * string * string +exception NotObject of c_obj +exception NotEnumType of c_obj +exception LabelNotFromThisEnum of c_obj +exception InvalidDirectorCall of c_obj +%}
\ No newline at end of file diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/std_common.i b/devtools/swigwin-1.3.34/Lib/ocaml/std_common.i new file mode 100644 index 0000000..b2dff61 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/std_common.i @@ -0,0 +1,22 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_common.i + * + * SWIG typemaps for STL - common utilities + * ----------------------------------------------------------------------------- */ + +%include <std/std_except.i> + +%apply size_t { std::size_t }; + +%{ +#include <string> + CAML_VALUE SwigString_FromString(const std::string& s) { + return caml_val_string((char *)s.c_str()); + } + std::string SwigString_AsString(CAML_VALUE o) { + return std::string((char *)caml_ptr_val(o,0)); + } +%} diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/std_complex.i b/devtools/swigwin-1.3.34/Lib/ocaml/std_complex.i new file mode 100644 index 0000000..5192261 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/std_complex.i @@ -0,0 +1,65 @@ +// -*- C++ -*- +#ifndef SWIG_STD_COMPLEX_I_ +#define SWIG_STD_COMPLEX_I_ + +#ifdef SWIG + +%{ +#include <complex> +%} + +namespace std +{ + template <class T> class complex; + + %define specialize_std_complex(T) + + %typemap(in) complex<T> { + if (PyComplex_Check($input)) { + $1 = std::complex<T>(PyComplex_RealAsDouble($input), + PyComplex_ImagAsDouble($input)); + } else if (PyFloat_Check($input)) { + $1 = std::complex<T>(PyFloat_AsDouble($input), 0); + } else if (PyInt_Check($input)) { + $1 = std::complex<T>(PyInt_AsLong($input), 0); + } + else { + PyErr_SetString(PyExc_TypeError,"Expected a complex"); + SWIG_fail; + } + } + + %typemap(in) const complex<T>& (std::complex<T> temp) { + if (PyComplex_Check($input)) { + temp = std::complex<T>(PyComplex_RealAsDouble($input), + PyComplex_ImagAsDouble($input)); + $1 = &temp; + } else if (PyFloat_Check($input)) { + temp = std::complex<T>(PyFloat_AsDouble($input), 0); + $1 = &temp; + } else if (PyInt_Check($input)) { + temp = std::complex<T>(PyInt_AsLong($input), 0); + $1 = &temp; + } else { + PyErr_SetString(PyExc_TypeError,"Expected a complex"); + SWIG_fail; + } + } + + %typemap(out) complex<T> { + $result = PyComplex_FromDoubles($1.real(), $1.imag()); + } + + %typemap(out) const complex<T> & { + $result = PyComplex_FromDoubles($1->real(), $1->imag()); + } + + %enddef + + specialize_std_complex(double); + specialize_std_complex(float); +} + +#endif // SWIG + +#endif //SWIG_STD_COMPLEX_I_ diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/std_deque.i b/devtools/swigwin-1.3.34/Lib/ocaml/std_deque.i new file mode 100644 index 0000000..44815eb --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/std_deque.i @@ -0,0 +1,31 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_deque.i + * + * Default std_deque wrapper + * ----------------------------------------------------------------------------- */ + +%module std_deque + +%rename(__getitem__) std::deque::getitem; +%rename(__setitem__) std::deque::setitem; +%rename(__delitem__) std::deque::delitem; +%rename(__getslice__) std::deque::getslice; +%rename(__setslice__) std::deque::setslice; +%rename(__delslice__) std::deque::delslice; + +%extend std::deque { + int __len__() { + return (int) self->size(); + } + int __nonzero__() { + return ! self->empty(); + } + void append(const T &x) { + self->push_back(x); + } +}; + +%include <_std_deque.i> diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/std_list.i b/devtools/swigwin-1.3.34/Lib/ocaml/std_list.i new file mode 100644 index 0000000..0aea907 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/std_list.i @@ -0,0 +1,222 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_list.i + * + * SWIG typemaps for std::list types + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +%module std_list +%{ +#include <list> +#include <stdexcept> +%} + + +namespace std{ + template<class T> class list + { + public: + + typedef T &reference; + typedef const T& const_reference; + typedef T &iterator; + typedef const T& const_iterator; + + list(); + list(unsigned int size, const T& value = T()); + list(const list<T> &); + + ~list(); + void assign(unsigned int n, const T& value); + void swap(list<T> &x); + + const_reference front(); + const_reference back(); + const_iterator begin(); + const_iterator end(); + + void resize(unsigned int n, T c = T()); + bool empty() const; + + void push_front(const T& x); + void push_back(const T& x); + + + void pop_front(); + void pop_back(); + void clear(); + unsigned int size() const; + unsigned int max_size() const; + void resize(unsigned int n, const T& value); + + void remove(const T& value); + void unique(); + void reverse(); + void sort(); + + + + %extend + { + const_reference __getitem__(int i) throw (std::out_of_range) + { + std::list<T>::iterator first = self->begin(); + int size = int(self->size()); + if (i<0) i += size; + if (i>=0 && i<size) + { + for (int k=0;k<i;k++) + { + first++; + } + return *first; + } + else throw std::out_of_range("list index out of range"); + } + void __setitem__(int i, const T& x) throw (std::out_of_range) + { + std::list<T>::iterator first = self->begin(); + int size = int(self->size()); + if (i<0) i += size; + if (i>=0 && i<size) + { + for (int k=0;k<i;k++) + { + first++; + } + *first = x; + } + else throw std::out_of_range("list index out of range"); + } + void __delitem__(int i) throw (std::out_of_range) + { + std::list<T>::iterator first = self->begin(); + int size = int(self->size()); + if (i<0) i += size; + if (i>=0 && i<size) + { + for (int k=0;k<i;k++) + { + first++; + } + self->erase(first); + } + else throw std::out_of_range("list index out of range"); + } + std::list<T> __getslice__(int i,int j) + { + std::list<T>::iterator first = self->begin(); + std::list<T>::iterator end = self->end(); + + int size = int(self->size()); + if (i<0) i += size; + if (j<0) j += size; + if (i<0) i = 0; + if (j>size) j = size; + if (i>=j) i=j; + if (i>=0 && i<size && j>=0) + { + for (int k=0;k<i;k++) + { + first++; + } + for (int m=0;m<j;m++) + { + end++; + } + std::list<T> tmp(j-i); + if (j>i) std::copy(first,end,tmp.begin()); + return tmp; + } + else throw std::out_of_range("list index out of range"); + } + void __delslice__(int i,int j) + { + std::list<T>::iterator first = self->begin(); + std::list<T>::iterator end = self->end(); + + int size = int(self->size()); + if (i<0) i += size; + if (j<0) j += size; + if (i<0) i = 0; + if (j>size) j = size; + + for (int k=0;k<i;k++) + { + first++; + } + for (int m=0;m<=j;m++) + { + end++; + } + self->erase(first,end); + } + void __setslice__(int i,int j, const std::list<T>& v) + { + std::list<T>::iterator first = self->begin(); + std::list<T>::iterator end = self->end(); + + int size = int(self->size()); + if (i<0) i += size; + if (j<0) j += size; + if (i<0) i = 0; + if (j>size) j = size; + + for (int k=0;k<i;k++) + { + first++; + } + for (int m=0;m<=j;m++) + { + end++; + } + if (int(v.size()) == j-i) + { + std::copy(v.begin(),v.end(),first); + } + else { + self->erase(first,end); + if (i+1 <= int(self->size())) + { + first = self->begin(); + for (int k=0;k<i;k++) + { + first++; + } + self->insert(first,v.begin(),v.end()); + } + else self->insert(self->end(),v.begin(),v.end()); + } + + } + unsigned int __len__() + { + return self->size(); + } + bool __nonzero__() + { + return !(self->empty()); + } + void append(const T& x) + { + self->push_back(x); + } + void pop() + { + self->pop_back(); + } + + }; + + }; +} + + + + + + diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/std_map.i b/devtools/swigwin-1.3.34/Lib/ocaml/std_map.i new file mode 100644 index 0000000..f174f28 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/std_map.i @@ -0,0 +1,173 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_map.i + * + * SWIG typemaps for std::map + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +// ------------------------------------------------------------------------ +// std::map +// ------------------------------------------------------------------------ + +%{ +#include <map> +#include <algorithm> +#include <stdexcept> +%} + +// exported class + +namespace std { + template<class K, class T> class map { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T& get(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(const K& key, const T& x) { + (*self)[key] = x; + } + void del(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + + + // specializations for built-ins + + %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) + + template<class T> class map<K,T> { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T& get(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(K key, const T& x) { + (*self)[key] = x; + } + void del(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(K key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + %enddef + + %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) + template<class K> class map<K,T> { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T get(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(const K& key, T x) { + (*self)[key] = x; + } + void del(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + %enddef + + %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, + T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) + template<> class map<K,T> { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T get(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(K key, T x) { + (*self)[key] = x; + } + void del(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(K key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + %enddef + + // add specializations here +} diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/std_pair.i b/devtools/swigwin-1.3.34/Lib/ocaml/std_pair.i new file mode 100644 index 0000000..dc0604d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/std_pair.i @@ -0,0 +1,37 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_pair.i + * + * SWIG typemaps for std::pair + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <exception.i> + +// ------------------------------------------------------------------------ +// std::pair +// ------------------------------------------------------------------------ + +%{ +#include <utility> +%} + +namespace std { + + template<class T, class U> struct pair { + + pair(); + pair(T first, U second); + pair(const pair& p); + + template <class U1, class U2> pair(const pair<U1, U2> &p); + + T first; + U second; + }; + + // add specializations here + +} diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/std_string.i b/devtools/swigwin-1.3.34/Lib/ocaml/std_string.i new file mode 100644 index 0000000..7add3a0 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/std_string.i @@ -0,0 +1,179 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_string.i + * + * SWIG typemaps for std::string + * ----------------------------------------------------------------------------- */ + +// ------------------------------------------------------------------------ +// std::string is typemapped by value +// This can prevent exporting methods which return a string +// in order for the user to modify it. +// However, I think I'll wait until someone asks for it... +// ------------------------------------------------------------------------ + +%include <exception.i> + +%{ +#include <string> +#include <vector> + using std::string; + using std::vector; +%} + +%include <std_vector.i> + +%naturalvar std::string; +%naturalvar std::wstring; + +namespace std { + template <class charT> class basic_string { + public: + typedef charT *pointer; + typedef charT &reference; + typedef const charT &const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + basic_string(); + basic_string( charT *str ); + size_t size(); + charT operator []( int pos ) const; + charT *c_str() const; + basic_string<charT> &operator = ( const basic_string &ws ); + basic_string<charT> &operator = ( const charT *str ); + basic_string<charT> &append( const basic_string<charT> &other ); + basic_string<charT> &append( const charT *str ); + void push_back( charT c ); + void clear(); + void reserve( size_type t ); + void resize( size_type n, charT c = charT() ); + int compare( const basic_string<charT> &other ) const; + int compare( const charT *str ) const; + basic_string<charT> &insert( size_type pos, + const basic_string<charT> &str ); + size_type find( const basic_string<charT> &other, int pos = 0 ) const; + size_type find( charT c, int pos = 0 ) const; + %extend { + bool operator == ( const basic_string<charT> &other ) const { + return self->compare( other ) == 0; + } + bool operator != ( const basic_string<charT> &other ) const { + return self->compare( other ) != 0; + } + bool operator < ( const basic_string<charT> &other ) const { + return self->compare( other ) == -1; + } + bool operator > ( const basic_string<charT> &other ) const { + return self->compare( other ) == 1; + } + bool operator <= ( const basic_string<charT> &other ) const { + return self->compare( other ) != 1; + } + bool operator >= ( const basic_string<charT> &other ) const { + return self->compare( other ) != -1; + } + } + }; + + %template(string) basic_string<char>; + %template(wstring) basic_string<wchar_t>; + typedef basic_string<char> string; + typedef basic_string<wchar_t> wstring; + + /* Overloading check */ + %typemap(in) string { + if (caml_ptr_check($input)) + $1.assign((char *)caml_ptr_val($input,0), + caml_string_len($input)); + else + SWIG_exception(SWIG_TypeError, "string expected"); + } + + %typemap(in) const string & (std::string temp) { + if (caml_ptr_check($input)) { + temp.assign((char *)caml_ptr_val($input,0), + caml_string_len($input)); + $1 = &temp; + } else { + SWIG_exception(SWIG_TypeError, "string expected"); + } + } + + %typemap(in) string & (std::string temp) { + if (caml_ptr_check($input)) { + temp.assign((char *)caml_ptr_val($input,0), + caml_string_len($input)); + $1 = &temp; + } else { + SWIG_exception(SWIG_TypeError, "string expected"); + } + } + + %typemap(in) string * (std::string *temp) { + if (caml_ptr_check($input)) { + temp = new std::string((char *)caml_ptr_val($input,0), + caml_string_len($input)); + $1 = temp; + } else { + SWIG_exception(SWIG_TypeError, "string expected"); + } + } + + %typemap(free) string * (std::string *temp) { + delete temp; + } + + %typemap(argout) string & { + caml_list_append(swig_result,caml_val_string_len((*$1).c_str(), + (*$1).size())); + } + + %typemap(directorout) string { + $result.assign((char *)caml_ptr_val($input,0), + caml_string_len($input)); + } + + %typemap(out) string { + $result = caml_val_string_len($1.c_str(),$1.size()); + } + + %typemap(out) string * { + $result = caml_val_string_len((*$1).c_str(),(*$1).size()); + } +} + +#ifdef ENABLE_CHARPTR_ARRAY +char **c_charptr_array( const std::vector <string > &str_v ); + +%{ + SWIGEXT char **c_charptr_array( const std::vector <string > &str_v ) { + char **out = new char *[str_v.size() + 1]; + out[str_v.size()] = 0; + for( int i = 0; i < str_v.size(); i++ ) { + out[i] = (char *)str_v[i].c_str(); + } + return out; + } +%} +#endif + +#ifdef ENABLE_STRING_VECTOR +%template (StringVector) std::vector<string >; + +%insert(ml) %{ + (* Some STL convenience items *) + + let string_array_to_vector sa = + let nv = _new_StringVector C_void in + array_to_vector nv (fun x -> C_string x) sa ; nv + + let c_string_array ar = + _c_charptr_array (string_array_to_vector ar) +%} + +%insert(mli) %{ + val c_string_array: string array -> c_obj +%} +#endif diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/std_vector.i b/devtools/swigwin-1.3.34/Lib/ocaml/std_vector.i new file mode 100644 index 0000000..91c3355 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/std_vector.i @@ -0,0 +1,92 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_vector.i + * + * SWIG typemaps for std::vector types + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +// ------------------------------------------------------------------------ +// std::vector +// +// The aim of all that follows would be to integrate std::vector with +// Python as much as possible, namely, to allow the user to pass and +// be returned Python tuples or lists. +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::vector<T>), f(const std::vector<T>&), f(const std::vector<T>*): +// the parameter being read-only, either a Python sequence or a +// previously wrapped std::vector<T> can be passed. +// -- f(std::vector<T>&), f(std::vector<T>*): +// the parameter must be modified; therefore, only a wrapped std::vector +// can be passed. +// -- std::vector<T> f(): +// the vector is returned by copy; therefore, a Python sequence of T:s +// is returned which is most easily used in other Python functions +// -- std::vector<T>& f(), std::vector<T>* f(), const std::vector<T>& f(), +// const std::vector<T>* f(): +// the vector is returned by reference; therefore, a wrapped std::vector +// is returned +// ------------------------------------------------------------------------ + +%{ +#include <vector> +#include <algorithm> +#include <stdexcept> +%} + +// exported class + +namespace std { + template <class T> class vector { + public: + vector(unsigned int size = 0); + vector(unsigned int size, const T& value); + vector(const vector<T>&); + unsigned int size() const; + bool empty() const; + void clear(); + void push_back(const T& x); + T operator [] ( int f ); + vector <T> &operator = ( vector <T> &other ); + %extend { + void set( int i, const T &x ) { + self->resize(i+1); + (*self)[i] = x; + } + }; + %extend { + T *to_array() { + T *array = new T[self->size() + 1]; + for( int i = 0; i < self->size(); i++ ) + array[i] = (*self)[i]; + return array; + } + }; + }; +}; + +%insert(ml) %{ + + let array_to_vector v argcons array = + for i = 0 to (Array.length array) - 1 do + (invoke v) "set" (C_list [ C_int i ; (argcons array.(i)) ]) + done ; + v + + let vector_to_array v argcons array = + for i = 0; to (get_int ((invoke v) "size" C_void)) - 1 do + array.(i) <- argcons ((invoke v) "[]" (C_int i)) + done ; + v + +%} + +%insert(mli) %{ + val array_to_vector : c_obj -> ('a -> c_obj) -> 'a array -> c_obj + val vector_to_array : c_obj -> (c_obj -> 'a) -> 'a array -> c_obj +%} diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/stl.i b/devtools/swigwin-1.3.34/Lib/ocaml/stl.i new file mode 100644 index 0000000..66b72e0 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/stl.i @@ -0,0 +1,15 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * stl.i + * + * Initial STL definition. extended as needed in each language + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <std_string.i> +%include <std_vector.i> +%include <std_map.i> +%include <std_pair.i> + diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/swig.ml b/devtools/swigwin-1.3.34/Lib/ocaml/swig.ml new file mode 100644 index 0000000..5dc2de7 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/swig.ml @@ -0,0 +1,159 @@ +(* -*- tuareg -*- *) +open Int32 +open Int64 + +type enum = [ `Int of int ] + +type 'a c_obj_t = + C_void + | C_bool of bool + | C_char of char + | C_uchar of char + | C_short of int + | C_ushort of int + | C_int of int + | C_uint of int32 + | C_int32 of int32 + | C_int64 of int64 + | C_float of float + | C_double of float + | C_ptr of int64 * int64 + | C_array of 'a c_obj_t array + | C_list of 'a c_obj_t list + | C_obj of (string -> 'a c_obj_t -> 'a c_obj_t) + | C_string of string + | C_enum of 'a + | C_director_core of 'a c_obj_t * 'a c_obj_t option ref + +type c_obj = enum c_obj_t + +exception BadArgs of string +exception BadMethodName of string * string +exception NotObject of c_obj +exception NotEnumType of c_obj +exception LabelNotFromThisEnum of c_obj +exception InvalidDirectorCall of c_obj +exception NoSuchClass of string +let rec invoke obj = + match obj with + C_obj o -> o + | C_director_core (o,r) -> invoke o + | _ -> raise (NotObject (Obj.magic obj)) +let _ = Callback.register "swig_runmethod" invoke + +let fnhelper arg = + match arg with C_list l -> l | C_void -> [] | _ -> [ arg ] + +let rec get_int x = + match x with + C_bool b -> if b then 1 else 0 + | C_char c + | C_uchar c -> (int_of_char c) + | C_short s + | C_ushort s + | C_int s -> s + | C_uint u + | C_int32 u -> (Int32.to_int u) + | C_int64 u -> (Int64.to_int u) + | C_float f -> (int_of_float f) + | C_double d -> (int_of_float d) + | C_ptr (p,q) -> (Int64.to_int p) + | C_obj o -> (try (get_int (o "int" C_void)) + with _ -> (get_int (o "&" C_void))) + | _ -> raise (Failure "Can't convert to int") + +let rec get_float x = + match x with + C_char c + | C_uchar c -> (float_of_int (int_of_char c)) + | C_short s -> (float_of_int s) + | C_ushort s -> (float_of_int s) + | C_int s -> (float_of_int s) + | C_uint u + | C_int32 u -> (float_of_int (Int32.to_int u)) + | C_int64 u -> (float_of_int (Int64.to_int u)) + | C_float f -> f + | C_double d -> d + | C_obj o -> (try (get_float (o "float" C_void)) + with _ -> (get_float (o "double" C_void))) + | _ -> raise (Failure "Can't convert to float") + +let rec get_char x = + (char_of_int (get_int x)) + +let rec get_string x = + match x with + C_string str -> str + | _ -> raise (Failure "Can't convert to string") + +let rec get_bool x = + match x with + C_bool b -> b + | _ -> + (try if get_int x != 0 then true else false + with _ -> raise (Failure "Can't convert to bool")) + +let disown_object obj = + match obj with + C_director_core (o,r) -> r := None + | _ -> raise (Failure "Not a director core object") +let _ = Callback.register "caml_obj_disown" disown_object +let addr_of obj = + match obj with + C_obj _ -> (invoke obj) "&" C_void + | C_director_core (self,r) -> (invoke self) "&" C_void + | C_ptr _ -> obj + | _ -> raise (Failure "Not a pointer.") +let _ = Callback.register "caml_obj_ptr" addr_of + +let make_float f = C_float f +let make_double f = C_double f +let make_string s = C_string s +let make_bool b = C_bool b +let make_char c = C_char c +let make_char_i c = C_char (char_of_int c) +let make_uchar c = C_uchar c +let make_uchar_i c = C_uchar (char_of_int c) +let make_short i = C_short i +let make_ushort i = C_ushort i +let make_int i = C_int i +let make_uint i = C_uint (Int32.of_int i) +let make_int32 i = C_int32 (Int32.of_int i) +let make_int64 i = C_int64 (Int64.of_int i) + +let new_derived_object cfun x_class args = + begin + let get_object ob = + match !ob with + None -> + raise (NotObject C_void) + | Some o -> o in + let ob_ref = ref None in + let class_fun class_f ob_r = + (fun meth args -> class_f (get_object ob_r) meth args) in + let new_class = class_fun x_class ob_ref in + let dircore = C_director_core (C_obj new_class,ob_ref) in + let obj = + cfun (match args with + C_list argl -> (C_list ((dircore :: argl))) + | C_void -> (C_list [ dircore ]) + | a -> (C_list [ dircore ; a ])) in + ob_ref := Some obj ; + obj + end + +let swig_current_type_info = ref C_void +let find_type_info obj = !swig_current_type_info +let _ = Callback.register "swig_find_type_info" find_type_info +let set_type_info obj = + match obj with + C_ptr _ -> swig_current_type_info := obj ; + obj + | _ -> raise (Failure "Internal error: passed non pointer to set_type_info") +let _ = Callback.register "swig_set_type_info" set_type_info + +let class_master_list = Hashtbl.create 20 +let register_class_byname nm co = + Hashtbl.replace class_master_list nm (Obj.magic co) +let create_class nm arg = + try (Obj.magic (Hashtbl.find class_master_list nm)) arg with _ -> raise (NoSuchClass nm) diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/swig.mli b/devtools/swigwin-1.3.34/Lib/ocaml/swig.mli new file mode 100644 index 0000000..3207b9e --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/swig.mli @@ -0,0 +1,61 @@ +(* -*- tuareg -*- *) + +type enum = [ `Int of int ] + +type 'a c_obj_t = + C_void + | C_bool of bool + | C_char of char + | C_uchar of char + | C_short of int + | C_ushort of int + | C_int of int + | C_uint of int32 + | C_int32 of int32 + | C_int64 of int64 + | C_float of float + | C_double of float + | C_ptr of int64 * int64 + | C_array of 'a c_obj_t array + | C_list of 'a c_obj_t list + | C_obj of (string -> 'a c_obj_t -> 'a c_obj_t) + | C_string of string + | C_enum of 'a + | C_director_core of 'a c_obj_t * 'a c_obj_t option ref + +type c_obj = enum c_obj_t + +exception InvalidDirectorCall of c_obj +exception NoSuchClass of string + +val invoke : ('a c_obj_t) -> (string -> 'a c_obj_t -> 'a c_obj_t) +val fnhelper : 'a c_obj_t -> 'a c_obj_t list + +val get_int : 'a c_obj_t -> int +val get_float : 'a c_obj_t -> float +val get_string : 'a c_obj_t -> string +val get_char : 'a c_obj_t -> char +val get_bool : 'a c_obj_t -> bool + +val make_float : float -> 'a c_obj_t +val make_double : float -> 'a c_obj_t +val make_string : string -> 'a c_obj_t +val make_bool : bool -> 'a c_obj_t +val make_char : char -> 'a c_obj_t +val make_char_i : int -> 'a c_obj_t +val make_uchar : char -> 'a c_obj_t +val make_uchar_i : int -> 'a c_obj_t +val make_short : int -> 'a c_obj_t +val make_ushort : int -> 'a c_obj_t +val make_int : int -> 'a c_obj_t +val make_uint : int -> 'a c_obj_t +val make_int32 : int -> 'a c_obj_t +val make_int64 : int -> 'a c_obj_t + +val new_derived_object: + ('a c_obj_t -> 'a c_obj_t) -> + ('a c_obj_t -> string -> 'a c_obj_t -> 'a c_obj_t) -> + 'a c_obj_t -> 'a c_obj_t + +val register_class_byname : string -> ('a c_obj_t -> 'a c_obj_t) -> unit +val create_class : string -> 'a c_obj_t -> 'a c_obj_t diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/swigp4.ml.in b/devtools/swigwin-1.3.34/Lib/ocaml/swigp4.ml.in new file mode 100644 index 0000000..0387c0a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/swigp4.ml.in @@ -0,0 +1,118 @@ +open Pcaml ;; + +let lap x y = x :: y +let c_ify e @OCAMLLOC@ = + match e with + <:expr< $int:_$ >> -> <:expr< (C_int $e$) >> + | <:expr< $str:_$ >> -> <:expr< (C_string $e$) >> + | <:expr< $chr:_$ >> -> <:expr< (C_char $e$) >> + | <:expr< $flo:_$ >> -> <:expr< (C_double $e$) >> + | <:expr< True >> -> <:expr< (C_bool $e$) >> + | <:expr< False >> -> <:expr< (C_bool $e$) >> + | _ -> <:expr< $e$ >> +let mk_list args @OCAMLLOC@ f = + let rec mk_list_inner args @OCAMLLOC@ f = + match args with + [] -> <:expr< [] >> + | x :: xs -> + (let @OCAMLLOC@ = MLast.loc_of_expr x in + <:expr< [ ($f x @OCAMLLOC@$) ] @ ($mk_list_inner xs @OCAMLLOC@ f$) >>) in + match args with + [] -> <:expr< (Obj.magic C_void) >> + | [ a ] -> <:expr< (Obj.magic $f a @OCAMLLOC@$) >> + | _ -> <:expr< (Obj.magic (C_list ($mk_list_inner args @OCAMLLOC@ f$))) >> + +EXTEND + expr: + [ [ e1 = expr ; "'" ; "[" ; e2 = expr ; "]" -> + <:expr< (invoke $e1$) "[]" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "->" ; l = LIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> + <:expr< (invoke $e1$) $str:l$ ($mk_list args @OCAMLLOC@ c_ify$) >> + | e1 = expr ; "->" ; u = UIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> + <:expr< (invoke $e1$) $str:u$ ($mk_list args @OCAMLLOC@ c_ify$) >> + | e1 = expr ; "->" ; s = expr LEVEL "simple" ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> + <:expr< (invoke $e1$) $s$ ($mk_list args @OCAMLLOC@ c_ify$) >> + | e1 = expr ; "'" ; "." ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> + <:expr< (invoke $e1$) "()" ($mk_list args @OCAMLLOC@ c_ify$) >> + | e1 = expr ; "'" ; "->" ; l = LIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> + <:expr< (invoke ((invoke $e1$) "->" C_void)) $str:l$ ($mk_list args @OCAMLLOC@ c_ify$) >> + | e1 = expr ; "'" ; "->" ; u = UIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> + <:expr< (invoke ((invoke $e1$) "->" C_void)) $str:u$ ($mk_list args @OCAMLLOC@ c_ify$) >> + | e1 = expr ; "'" ; "->" ; s = expr LEVEL "simple" ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> + <:expr< (invoke ((invoke $e1$) "->" C_void)) $s$ ($mk_list args @OCAMLLOC@ c_ify$) >> + | e1 = expr ; "'" ; "++" -> + <:expr< (invoke $e1$) "++" C_void >> + | e1 = expr ; "'" ; "--" -> + <:expr< (invoke $e1$) "--" C_void >> + | e1 = expr ; "'" ; "-" ; e2 = expr -> + <:expr< (invoke $e1$) "-" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "+" ; e2 = expr -> <:expr< (invoke $e1$) "+" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "*" ; e2 = expr -> <:expr< (invoke $e1$) "*" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | "'" ; "&" ; e1 = expr -> + <:expr< (invoke $e1$) "&" C_void >> + | "'" ; "!" ; e1 = expr -> + <:expr< (invoke $e1$) "!" C_void >> + | "'" ; "~" ; e1 = expr -> + <:expr< (invoke $e1$) "~" C_void >> + | e1 = expr ; "'" ; "/" ; e2 = expr -> + <:expr< (invoke $e1$) "/" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "%" ; e2 = expr -> + <:expr< (invoke $e1$) "%" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "lsl" ; e2 = expr -> + <:expr< (invoke $e1$) ("<" ^ "<") (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "lsr" ; e2 = expr -> + <:expr< (invoke $e1$) (">" ^ ">") (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "<" ; e2 = expr -> + <:expr< (invoke $e1$) "<" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "<=" ; e2 = expr -> + <:expr< (invoke $e1$) "<=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; ">" ; e2 = expr -> + <:expr< (invoke $e1$) ">" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; ">=" ; e2 = expr -> + <:expr< (invoke $e1$) ">=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "==" ; e2 = expr -> + <:expr< (invoke $e1$) "==" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "!=" ; e2 = expr -> + <:expr< (invoke $e1$) "!=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "&" ; e2 = expr -> + <:expr< (invoke $e1$) "&" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "^" ; e2 = expr -> + <:expr< (invoke $e1$) "^" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "|" ; e2 = expr -> + <:expr< (invoke $e1$) "|" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "&&" ; e2 = expr -> + <:expr< (invoke $e1$) "&&" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "||" ; e2 = expr -> + <:expr< (invoke $e1$) "||" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "=" ; e2 = expr -> + <:expr< (invoke $e1$) "=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "+=" ; e2 = expr -> + <:expr< (invoke $e1$) "+=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "-=" ; e2 = expr -> + <:expr< (invoke $e1$) "-=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "*=" ; e2 = expr -> + <:expr< (invoke $e1$) "*=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "/=" ; e2 = expr -> + <:expr< (invoke $e1$) "/=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "%=" ; e2 = expr -> + <:expr< (invoke $e1$) "%=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "lsl" ; "=" ; e2 = expr -> + <:expr< (invoke $e1$) ("<" ^ "<=") (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "lsr" ; "=" ; e2 = expr -> + <:expr< (invoke $e1$) (">" ^ ">=") (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "&=" ; e2 = expr -> + <:expr< (invoke $e1$) "&=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "^=" ; e2 = expr -> + <:expr< (invoke $e1$) "^=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "|=" ; e2 = expr -> + <:expr< (invoke $e1$) "|=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | "'" ; e = expr -> c_ify e @OCAMLLOC@ + | c = expr ; "as" ; id = LIDENT -> <:expr< $lid:"get_" ^ id$ $c$ >> + | c = expr ; "to" ; id = LIDENT -> <:expr< $uid:"C_" ^ id$ $c$ >> + | "`" ; "`" ; l = LIDENT -> <:expr< C_enum `$lid:l$ >> + | "`" ; "`" ; u = UIDENT -> <:expr< C_enum `$uid:u$ >> + | f = expr ; "'" ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> + <:expr< $f$ ($mk_list args @OCAMLLOC@ c_ify$) >> + ] ] ; +END ;; + diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/typecheck.i b/devtools/swigwin-1.3.34/Lib/ocaml/typecheck.i new file mode 100644 index 0000000..51e6606 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/typecheck.i @@ -0,0 +1,179 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * typecheck.i + * + * Typechecking rules + * ----------------------------------------------------------------------------- */ + +%typecheck(SWIG_TYPECHECK_INTEGER) char, signed char, const char &, const signed char & { + if( !Is_block($input) ) $1 = 0; + else { + switch( SWIG_Tag_val($input) ) { + case C_char: $1 = 1; break; + default: $1 = 0; break; + } + } +} + +%typecheck(SWIG_TYPECHECK_INTEGER) unsigned char, const unsigned char & { + if( !Is_block($input) ) $1 = 0; + else { + switch( SWIG_Tag_val($input) ) { + case C_uchar: $1 = 1; break; + default: $1 = 0; break; + } + } +} + +%typecheck(SWIG_TYPECHECK_INTEGER) short, signed short, const short &, const signed short &, wchar_t { + if( !Is_block($input) ) $1 = 0; + else { + switch( SWIG_Tag_val($input) ) { + case C_short: $1 = 1; break; + default: $1 = 0; break; + } + } +} + +%typecheck(SWIG_TYPECHECK_INTEGER) unsigned short, const unsigned short & { + if( !Is_block($input) ) $1 = 0; + else { + switch( SWIG_Tag_val($input) ) { + case C_ushort: $1 = 1; break; + default: $1 = 0; break; + } + } +} + +// XXX arty +// Will move enum SWIGTYPE later when I figure out what to do with it... + +%typecheck(SWIG_TYPECHECK_INTEGER) int, signed int, const int &, const signed int &, enum SWIGTYPE { + if( !Is_block($input) ) $1 = 0; + else { + switch( SWIG_Tag_val($input) ) { + case C_int: $1 = 1; break; + default: $1 = 0; break; + } + } +} + +%typecheck(SWIG_TYPECHECK_INTEGER) unsigned int, const unsigned int & { + if( !Is_block($input) ) $1 = 0; + else { + switch( SWIG_Tag_val($input) ) { + case C_uint: $1 = 1; break; + case C_int32: $1 = 1; break; + default: $1 = 0; break; + } + } +} + +%typecheck(SWIG_TYPECHECK_INTEGER) long, signed long, unsigned long, long long, signed long long, unsigned long long, const long &, const signed long &, const unsigned long &, const long long &, const signed long long &, const unsigned long long & { + if( !Is_block($input) ) $1 = 0; + else { + switch( SWIG_Tag_val($input) ) { + case C_int64: $1 = 1; break; + default: $1 = 0; break; + } + } +} + +%typecheck(SWIG_TYPECHECK_INTEGER) bool, oc_bool, BOOL, const bool &, const oc_bool &, const BOOL & { + if( !Is_block($input) ) $1 = 0; + else { + switch( SWIG_Tag_val($input) ) { + case C_bool: $1 = 1; break; + default: $1 = 0; break; + } + } +} + +%typecheck(SWIG_TYPECHECK_DOUBLE) float, const float & { + if( !Is_block($input) ) $1 = 0; + else { + switch( SWIG_Tag_val($input) ) { + case C_float: $1 = 1; break; + default: $1 = 0; break; + } + } +} + +%typecheck(SWIG_TYPECHECK_DOUBLE) double, const double & { + if( !Is_block($input) ) $1 = 0; + else { + switch( SWIG_Tag_val($input) ) { + case C_double: $1 = 1; break; + default: $1 = 0; break; + } + } +} + +%typecheck(SWIG_TYPECHECK_STRING) char * { + if( !Is_block($input) ) $1 = 0; + else { + switch( SWIG_Tag_val($input) ) { + case C_string: $1 = 1; break; + case C_ptr: { + swig_type_info *typeinfo = + (swig_type_info *)(long)SWIG_Int64_val(SWIG_Field($input,1)); + $1 = SWIG_TypeCheck("char *",typeinfo) || + SWIG_TypeCheck("signed char *",typeinfo) || + SWIG_TypeCheck("unsigned char *",typeinfo) || + SWIG_TypeCheck("const char *",typeinfo) || + SWIG_TypeCheck("const signed char *",typeinfo) || + SWIG_TypeCheck("const unsigned char *",typeinfo) || + SWIG_TypeCheck("std::string",typeinfo); + } break; + default: $1 = 0; break; + } + } +} + +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] { + void *ptr; + $1 = !caml_ptr_val_internal($input, &ptr,$descriptor); +} + +#if 0 + +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { + void *ptr; + $1 = !caml_ptr_val_internal($input, &ptr, $&1_descriptor); +} + +#endif + +%typecheck(SWIG_TYPECHECK_VOIDPTR) void * { + void *ptr; + $1 = !caml_ptr_val_internal($input, &ptr, 0); +} + +/* ------------------------------------------------------------ + * Exception handling + * ------------------------------------------------------------ */ + +%typemap(throws) int, + long, + short, + unsigned int, + unsigned long, + unsigned short { + SWIG_exception($1,"Thrown exception from C++ (int)"); +} + +%typemap(throws) SWIGTYPE CLASS { + $&1_ltype temp = new $1_ltype($1); + SWIG_exception((int)temp,"Thrown exception from C++ (object)"); +} + +%typemap(throws) SWIGTYPE { + (void)$1; + SWIG_exception(0,"Thrown exception from C++ (unknown)"); +} + +%typemap(throws) char * { + SWIG_exception(0,$1); +} diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/typemaps.i b/devtools/swigwin-1.3.34/Lib/ocaml/typemaps.i new file mode 100644 index 0000000..b082d06 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/typemaps.i @@ -0,0 +1,319 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * typemaps.i + * + * The Ocaml module handles all types uniformly via typemaps. Here + * are the definitions. + * ----------------------------------------------------------------------------- */ + +/* Pointers */ + +%typemap(in) void "" + +%typemap(out) void "$result = Val_int(0);" + +%typemap(in) void * { + $1 = caml_ptr_val($input,$descriptor); +} + +%typemap(varin) void * { + $1 = ($ltype)caml_ptr_val($input,$descriptor); +} + +%typemap(out) void * { + $result = caml_val_ptr($1,$descriptor); +} + +%typemap(varout) void * { + $result = caml_val_ptr($1,$descriptor); +} + +#ifdef __cplusplus + +%typemap(in) SWIGTYPE & { + /* %typemap(in) SWIGTYPE & */ + $1 = ($ltype) caml_ptr_val($input,$1_descriptor); +} + +%typemap(varin) SWIGTYPE & { + /* %typemap(varin) SWIGTYPE & */ + $1 = *(($ltype) caml_ptr_val($input,$1_descriptor)); +} + +%typemap(out) SWIGTYPE & { + /* %typemap(out) SWIGTYPE & */ + CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); + if( fromval ) { + $result = callback(*fromval,caml_val_ptr((void *) &$1,$1_descriptor)); + } else { + $result = caml_val_ptr ((void *) &$1,$1_descriptor); + } +} + +#if 0 +%typemap(argout) SWIGTYPE & { + CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); + if( fromval ) { + swig_result = + caml_list_append(swig_result, + callback(*fromval,caml_val_ptr((void *) $1, + $1_descriptor))); + } else { + swig_result = + caml_list_append(swig_result, + caml_val_ptr ((void *) $1,$1_descriptor)); + } +} +#endif + +%typemap(argout) const SWIGTYPE & { } + +%typemap(in) SWIGTYPE { + $1 = *(($&1_ltype) caml_ptr_val($input,$&1_descriptor)) ; +} + +%typemap(out) SWIGTYPE { + /* %typemap(out) SWIGTYPE */ + $&1_ltype temp = new $ltype(($1_ltype &) $1); + CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); + if( fromval ) { + $result = callback(*fromval,caml_val_ptr((void *)temp,$&1_descriptor)); + } else { + $result = caml_val_ptr ((void *)temp,$&1_descriptor); + } +} + +#else + +%typemap(in) SWIGTYPE { + $1 = *(($&1_ltype) caml_ptr_val($input,$&1_descriptor)) ; +} + +%typemap(out) SWIGTYPE { + /* %typemap(out) SWIGTYPE */ + void *temp = calloc(1,sizeof($ltype)); + CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); + memmove( temp, &$1, sizeof( $1_type ) ); + if( fromval ) { + $result = callback(*fromval,caml_val_ptr((void *)temp,$&1_descriptor)); + } else { + $result = caml_val_ptr ((void *)temp,$&1_descriptor); + } +} + +%apply SWIGTYPE { const SWIGTYPE & }; + +#endif + +/* The SIMPLE_MAP macro below defines the whole set of typemaps needed + for simple types. */ + +%define SIMPLE_MAP(C_NAME, C_TO_MZ, MZ_TO_C) +/* In */ +%typemap(in) C_NAME { + $1 = MZ_TO_C($input); +} +%typemap(varin) C_NAME { + $1 = MZ_TO_C($input); +} +%typemap(in) C_NAME & ($*1_ltype temp) { + temp = ($*1_ltype) MZ_TO_C($input); + $1 = &temp; +} +%typemap(varin) C_NAME & { + $1 = MZ_TO_C($input); +} +%typemap(directorout) C_NAME { + $1 = MZ_TO_C($input); +} +%typemap(in) C_NAME *INPUT ($*1_ltype temp) { + temp = ($*1_ltype) MZ_TO_C($input); + $1 = &temp; +} +%typemap(in,numinputs=0) C_NAME *OUTPUT ($*1_ltype temp) { + $1 = &temp; +} +/* Out */ +%typemap(out) C_NAME { + $result = C_TO_MZ($1); +} +%typemap(varout) C_NAME { + $result = C_TO_MZ($1); +} +%typemap(varout) C_NAME & { + /* %typemap(varout) C_NAME & (generic) */ + $result = C_TO_MZ($1); +} +%typemap(argout) C_NAME *OUTPUT { + swig_result = caml_list_append(swig_result,C_TO_MZ((long)*$1)); +} +%typemap(out) C_NAME & { + /* %typemap(out) C_NAME & (generic) */ + $result = C_TO_MZ(*$1); +} +%typemap(argout) C_NAME & { + swig_result = caml_list_append(swig_result,C_TO_MZ((long)*$1)); +} +%typemap(directorin) C_NAME { + args = caml_list_append(args,C_TO_MZ($1_name)); +} +%enddef + +SIMPLE_MAP(bool, caml_val_bool, caml_long_val); +SIMPLE_MAP(oc_bool, caml_val_bool, caml_long_val); +SIMPLE_MAP(char, caml_val_char, caml_long_val); +SIMPLE_MAP(signed char, caml_val_char, caml_long_val); +SIMPLE_MAP(unsigned char, caml_val_uchar, caml_long_val); +SIMPLE_MAP(int, caml_val_int, caml_long_val); +SIMPLE_MAP(short, caml_val_short, caml_long_val); +SIMPLE_MAP(wchar_t, caml_val_short, caml_long_val); +SIMPLE_MAP(long, caml_val_long, caml_long_val); +SIMPLE_MAP(ptrdiff_t, caml_val_int, caml_long_val); +SIMPLE_MAP(unsigned int, caml_val_uint, caml_long_val); +SIMPLE_MAP(unsigned short, caml_val_ushort, caml_long_val); +SIMPLE_MAP(unsigned long, caml_val_ulong, caml_long_val); +SIMPLE_MAP(size_t, caml_val_int, caml_long_val); +SIMPLE_MAP(float, caml_val_float, caml_double_val); +SIMPLE_MAP(double, caml_val_double, caml_double_val); +SIMPLE_MAP(long long,caml_val_ulong,caml_long_val); +SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val); + +/* Void */ + +%typemap(out) void "$result = Val_unit;"; + +/* Pass through value */ + +%typemap (in) value,caml::value,CAML_VALUE "$1=$input;"; +%typemap (out) value,caml::value,CAML_VALUE "$result=$1;"; + +/* Arrays */ + +%typemap(in) ArrayCarrier * { + $1 = ($ltype)caml_ptr_val($input,$1_descriptor); +} + +%typemap(out) ArrayCarrier * { + CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); + if( fromval ) { + $result = callback(*fromval,caml_val_ptr((void *)$1,$1_descriptor)); + } else { + $result = caml_val_ptr ((void *)$1,$1_descriptor); + } +} + +#if 0 +%include <carray.i> +#endif + +/* Handle char arrays as strings */ + +%define %char_ptr_in(how) +%typemap(how) char *, signed char *, unsigned char * { + /* %typemap(how) char * ... */ + $1 = ($ltype)caml_string_val($input); +} +/* Again work around the empty array bound bug */ +%typemap(how) char [ANY], signed char [ANY], unsigned char [ANY] { + /* %typemap(how) char [ANY] ... */ + char *temp = caml_string_val($input); + strcpy((char *)$1,temp); + /* strncpy would be better but we might not have an array size */ +} +%enddef + +%char_ptr_in(in); +%char_ptr_in(varin); +%char_ptr_in(directorout); + +%define %char_ptr_out(how) +%typemap(how) + char *, signed char *, unsigned char *, + const char *, const signed char *, const unsigned char * { + $result = caml_val_string((char *)$1); +} +/* I'd like to use the length here but can't because it might be empty */ +%typemap(how) + char [ANY], signed char [ANY], unsigned char [ANY], + const char [ANY], const signed char [ANY], const unsigned char [ANY] { + $result = caml_val_string((char *)$1); +} +%enddef + +%char_ptr_out(out); +%char_ptr_out(varout); +%char_ptr_out(directorin); + +%define %swigtype_ptr_in(how) +%typemap(how) SWIGTYPE * { + /* %typemap(how) SWIGTYPE * */ + $1 = ($ltype)caml_ptr_val($input,$1_descriptor); +} +%typemap(how) SWIGTYPE (CLASS::*) { + /* %typemap(how) SWIGTYPE (CLASS::*) */ + void *v = caml_ptr_val($input,$1_descriptor); + memcpy(& $1, &v, sizeof(v)); +} +%enddef + +%define %swigtype_ptr_out(how) +%typemap(out) SWIGTYPE * { + /* %typemap(how) SWIGTYPE *, SWIGTYPE (CLASS::*) */ + CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); + if( fromval ) { + $result = callback(*fromval,caml_val_ptr((void *)$1,$1_descriptor)); + } else { + $result = caml_val_ptr ((void *)$1,$1_descriptor); + } +} +%typemap(how) SWIGTYPE (CLASS::*) { + /* %typemap(how) SWIGTYPE *, SWIGTYPE (CLASS::*) */ + void *v; + memcpy(&v,& $1, sizeof(void *)); + $result = caml_val_ptr (v,$1_descriptor); +} +%enddef + +%swigtype_ptr_in(in); +%swigtype_ptr_in(varin); +%swigtype_ptr_in(directorout); +%swigtype_ptr_out(out); +%swigtype_ptr_out(varout); +%swigtype_ptr_out(directorin); + +%define %swigtype_array_fail(how,msg) +%typemap(how) SWIGTYPE [] { + failwith(msg); +} +%enddef + +%swigtype_array_fail(in,"Array arguments for arbitrary types need a typemap"); +%swigtype_array_fail(varin,"Assignment to global arrays for arbitrary types need a typemap"); +%swigtype_array_fail(out,"Array arguments for arbitrary types need a typemap"); +%swigtype_array_fail(varout,"Array variables need a typemap"); +%swigtype_array_fail(directorin,"Array results with arbitrary types need a typemap"); +%swigtype_array_fail(directorout,"Array arguments with arbitrary types need a typemap"); + +/* C++ References */ + +/* Enums */ +%define %swig_enum_in(how) +%typemap(how) enum SWIGTYPE { + $1 = ($type)caml_long_val_full($input,"$type_marker"); +} +%enddef + +%define %swig_enum_out(how) +%typemap(how) enum SWIGTYPE { + $result = callback2(*caml_named_value(SWIG_MODULE "_int_to_enum"),*caml_named_value("$type_marker"),Val_int((int)$1)); +} +%enddef + +%swig_enum_in(in) +%swig_enum_in(varin) +%swig_enum_in(directorout) +%swig_enum_out(out) +%swig_enum_out(varout) +%swig_enum_out(directorin) diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/typeregister.swg b/devtools/swigwin-1.3.34/Lib/ocaml/typeregister.swg new file mode 100644 index 0000000..c3ba904 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/typeregister.swg @@ -0,0 +1,2 @@ +SWIGEXT void SWIG_init() { + SWIG_InitializeModule(0); diff --git a/devtools/swigwin-1.3.34/Lib/perl5/Makefile.in b/devtools/swigwin-1.3.34/Lib/perl5/Makefile.in new file mode 100644 index 0000000..dde0189 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/Makefile.in @@ -0,0 +1,138 @@ +# --------------------------------------------------------------- +# SWIG Perl5 Makefile +# +# This file can be used to build various Perl5 extensions with SWIG. +# By default this file is set up for dynamic loading, but it can +# be easily customized for static extensions by modifying various +# portions of the file. +# +# SRCS = C source files +# CXXSRCS = C++ source files +# OBJCSRCS = Objective-C source files +# OBJS = Additional .o files (compiled previously) +# INTERFACE = SWIG interface file +# TARGET = Name of target module or executable +# +# Many portions of this file were created by the SWIG configure +# script and should already reflect your machine. +#---------------------------------------------------------------- + +SRCS = +CXXSRCS = +OBJCSRCS = +OBJS = +INTERFACE = +WRAPFILE = $(INTERFACE:.i=_wrap.c) +WRAPOBJ = $(INTERFACE:.i=_wrap.o) +TARGET = module@SO@ # Use this kind of target for dynamic loading +#TARGET = myperl # Use this target for static linking + +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +CC = @CC@ +CXX = @CXX@ +OBJC = @CC@ -Wno-import # -Wno-import needed for gcc +CFLAGS = +INCLUDES = +LIBS = + +# SWIG Options +# SWIG = location of the SWIG executable +# SWIGOPT = SWIG compiler options +# SWIGCC = Compiler used to compile the wrapper file + +SWIG = $(exec_prefix)/bin/swig +SWIGOPT = -perl5 +SWIGCC = $(CC) + +# SWIG Library files. Uncomment this to staticly rebuild Perl +#SWIGLIB = -static -lperlmain.i + +# Rules for creating .o files from source. + +COBJS = $(SRCS:.c=.o) +CXXOBJS = $(CXXSRCS:.cxx=.o) +OBJCOBJS = $(OBJCSRCS:.m=.o) +ALLOBJS = $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(OBJS) + +# Command that will be used to build the final extension. +BUILD = $(SWIGCC) + +# Uncomment the following if you are using dynamic loading +CCSHARED = @CCSHARED@ +BUILD = @LDSHARED@ + +# Uncomment the following if you are using dynamic loading with C++ and +# need to provide additional link libraries (this is not always required). + +#DLL_LIBS = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \ + -L/usr/local/lib -lg++ -lstdc++ -lgcc + +# X11 installation (possibly needed if using Perl-Tk) + +XLIB = @XLIBSW@ +XINCLUDE = @XINCLUDES@ + +# Perl installation + +PERL_INCLUDE = -I@PERL5EXT@ +PERL_LIB = -L@PERL5EXT@ -lperl +PERL_FLAGS = -Dbool=char -Dexplicit= + +# Tcl installation. If using Tk you might need this + +TCL_INCLUDE = @TCLINCLUDE@ +TCL_LIB = @TCLLIB@ + +# Build libraries (needed for static builds) + +LIBM = @LIBM@ +LIBC = @LIBC@ +SYSLIBS = $(LIBM) $(LIBC) @LIBS@ + +# Build options (uncomment only one these) + +#TK_LIB = $(TCL_LIB) -ltcl -ltk $(XLIB) +BUILD_LIBS = $(LIBS) # Dynamic loading +#BUILD_LIBS = $(PERL_LIB) $(TK_LIB) $(LIBS) $(SYSLIBS) # Static linking + +# Compilation rules for non-SWIG components + +.SUFFIXES: .c .cxx .m + +.c.o: + $(CC) $(CCSHARED) $(CFLAGS) $(INCLUDES) -c $< + +.cxx.o: + $(CXX) $(CCSHARED) $(CXXFLAGS) $(INCLUDES) -c $< + +.m.o: + $(OBJC) $(CCSHARED) $(CFLAGS) $(INCLUDES) -c $< + + +# ---------------------------------------------------------------------- +# Rules for building the extension +# ---------------------------------------------------------------------- + +all: $(TARGET) + +# Convert the wrapper file into an object file + +$(WRAPOBJ) : $(WRAPFILE) + $(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(PERL_INCLUDE) $(PERL_FLAGS) $(WRAPFILE) + +$(WRAPFILE) : $(INTERFACE) + $(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIB) $(INTERFACE) + +$(TARGET): $(WRAPOBJ) $(ALLOBJS) + $(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET) + +clean: + rm -f $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(WRAPOBJ) $(WRAPFILE) $(TARGET) + + + + + + diff --git a/devtools/swigwin-1.3.34/Lib/perl5/Makefile.pl b/devtools/swigwin-1.3.34/Lib/perl5/Makefile.pl new file mode 100644 index 0000000..05240f1 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/Makefile.pl @@ -0,0 +1,21 @@ +# File : Makefile.pl +# MakeMaker file for a SWIG module. Use this file if you are +# producing a module for general use or distribution. +# +# 1. Modify the file as appropriate. Replace $module with the +# real name of your module and wrapper file. +# 2. Run perl as 'perl Makefile.pl' +# 3. Type 'make' to build your module +# 4. Type 'make install' to install your module. +# +# See "Programming Perl", 2nd. Ed, for more gory details than +# you ever wanted to know. + +use ExtUtils::MakeMaker; +WriteMakefile( + 'NAME' => '$module', # Name of your module + 'LIBS' => [''], # Custom libraries (if any) + 'OBJECT' => '$module_wrap.o' # Object files +); + + diff --git a/devtools/swigwin-1.3.34/Lib/perl5/attribute.i b/devtools/swigwin-1.3.34/Lib/perl5/attribute.i new file mode 100644 index 0000000..779716c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/attribute.i @@ -0,0 +1 @@ +%include <typemaps/attribute.swg> diff --git a/devtools/swigwin-1.3.34/Lib/perl5/carrays.i b/devtools/swigwin-1.3.34/Lib/perl5/carrays.i new file mode 100644 index 0000000..8be67ab --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/carrays.i @@ -0,0 +1,2 @@ +%include <typemaps/carrays.swg> + diff --git a/devtools/swigwin-1.3.34/Lib/perl5/cdata.i b/devtools/swigwin-1.3.34/Lib/perl5/cdata.i new file mode 100644 index 0000000..3679659 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/cdata.i @@ -0,0 +1 @@ +%include <typemaps/cdata.swg> diff --git a/devtools/swigwin-1.3.34/Lib/perl5/cmalloc.i b/devtools/swigwin-1.3.34/Lib/perl5/cmalloc.i new file mode 100644 index 0000000..248f06b --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/cmalloc.i @@ -0,0 +1 @@ +%include <typemaps/cmalloc.swg> diff --git a/devtools/swigwin-1.3.34/Lib/perl5/cni.i b/devtools/swigwin-1.3.34/Lib/perl5/cni.i new file mode 100644 index 0000000..c4d4eaf --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/cni.i @@ -0,0 +1,12 @@ +%warnfilter(SWIGWARN_PARSE_KEYWORD) java::lang::ref; + +%{ +#undef STATIC +%} +%include <gcj/cni.i> +%{ +#undef TRUE +#define TRUE 1 +%} + +%include <jstring.i> diff --git a/devtools/swigwin-1.3.34/Lib/perl5/cpointer.i b/devtools/swigwin-1.3.34/Lib/perl5/cpointer.i new file mode 100644 index 0000000..d824792 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/cpointer.i @@ -0,0 +1 @@ +%include <typemaps/cpointer.swg> diff --git a/devtools/swigwin-1.3.34/Lib/perl5/cstring.i b/devtools/swigwin-1.3.34/Lib/perl5/cstring.i new file mode 100644 index 0000000..ede9c59 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/cstring.i @@ -0,0 +1 @@ +%include <typemaps/cstring.swg> diff --git a/devtools/swigwin-1.3.34/Lib/perl5/exception.i b/devtools/swigwin-1.3.34/Lib/perl5/exception.i new file mode 100644 index 0000000..b786f25 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/exception.i @@ -0,0 +1,5 @@ +%include <typemaps/exception.swg> + +%insert("runtime") { + %define_as(SWIG_exception(code, msg), %block(%error(code, msg); SWIG_fail; )) +} diff --git a/devtools/swigwin-1.3.34/Lib/perl5/extra-install.list b/devtools/swigwin-1.3.34/Lib/perl5/extra-install.list new file mode 100644 index 0000000..db93830 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/extra-install.list @@ -0,0 +1,2 @@ +# see top-level Makefile.in +Makefile.pl noembed.h diff --git a/devtools/swigwin-1.3.34/Lib/perl5/factory.i b/devtools/swigwin-1.3.34/Lib/perl5/factory.i new file mode 100644 index 0000000..46a0a87 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/factory.i @@ -0,0 +1 @@ +%include <typemaps/factory.swg> diff --git a/devtools/swigwin-1.3.34/Lib/perl5/jstring.i b/devtools/swigwin-1.3.34/Lib/perl5/jstring.i new file mode 100644 index 0000000..1c179b7 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/jstring.i @@ -0,0 +1,48 @@ +%include <typemaps/valtypes.swg> + +%fragment(SWIG_AsVal_frag(jstring),"header") { +SWIGINTERN int +SWIG_AsVal_dec(jstring)(SV *obj, jstring *val) +{ + if (SvPOK(obj)) { + if (val) { + STRLEN len = 0; + char *cstr = SvPV(obj, len); + *val = JvNewStringLatin1(cstr, len); + } + return SWIG_OK; + } + return SWIG_ERROR; +} +} + +%fragment(SWIG_From_frag(jstring),"header") { +SWIGINTERNINLINE SV * +SWIG_From_dec(jstring)(jstring val) +{ + SV *obj = sv_newmortal(); + if (!val) { + sv_setsv(obj, &PL_sv_undef); + } else { + jsize len = JvGetStringUTFLength(val); + if (!len) { + sv_setsv(obj, &PL_sv_undef); + } else { + char *tmp = %new_array(len, char); + JvGetStringUTFRegion(val, 0, len, tmp); + sv_setpvn(obj, tmp, len); + SvUTF8_on(obj); + %delete_array(tmp); + } + } + return obj; +} +} + +%typemaps_asvalfrom(%checkcode(STRING), + %arg(SWIG_AsVal(jstring)), + %arg(SWIG_From(jstring)), + %arg(SWIG_AsVal_frag(jstring)), + %arg(SWIG_From_frag(jstring)), + java::lang::String *); + diff --git a/devtools/swigwin-1.3.34/Lib/perl5/noembed.h b/devtools/swigwin-1.3.34/Lib/perl5/noembed.h new file mode 100644 index 0000000..a29de61 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/noembed.h @@ -0,0 +1,93 @@ +/* Workaround perl5 global namespace pollution. Note that undefining library + * functions like fopen will not solve the problem on all platforms as fopen + * might be a macro on Windows but not necessarily on other operating systems. */ +#ifdef do_open + #undef do_open +#endif +#ifdef do_close + #undef do_close +#endif +#ifdef scalar + #undef scalar +#endif +#ifdef list + #undef list +#endif +#ifdef apply + #undef apply +#endif +#ifdef convert + #undef convert +#endif +#ifdef Error + #undef Error +#endif +#ifdef form + #undef form +#endif +#ifdef vform + #undef vform +#endif +#ifdef LABEL + #undef LABEL +#endif +#ifdef METHOD + #undef METHOD +#endif +#ifdef Move + #undef Move +#endif +#ifdef yylex + #undef yylex +#endif +#ifdef yyparse + #undef yyparse +#endif +#ifdef yyerror + #undef yyerror +#endif +#ifdef invert + #undef invert +#endif +#ifdef ref + #undef ref +#endif +#ifdef read + #undef read +#endif +#ifdef write + #undef write +#endif +#ifdef eof + #undef eof +#endif +#ifdef bool + #undef bool +#endif +#ifdef close + #undef close +#endif +#ifdef rewind + #undef rewind +#endif +#ifdef free + #undef free +#endif +#ifdef malloc + #undef malloc +#endif +#ifdef calloc + #undef calloc +#endif +#ifdef Stat + #undef Stat +#endif +#ifdef check + #undef check +#endif +#ifdef seekdir + #undef seekdir +#endif +#ifdef open + #undef open +#endif diff --git a/devtools/swigwin-1.3.34/Lib/perl5/perl5.swg b/devtools/swigwin-1.3.34/Lib/perl5/perl5.swg new file mode 100644 index 0000000..693c2b9 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/perl5.swg @@ -0,0 +1,42 @@ +/* ------------------------------------------------------------ + * perl.swg + * + * Perl configuration module. + * ------------------------------------------------------------ */ + +/* ------------------------------------------------------------ + * Inner macros + * ------------------------------------------------------------ */ +%include <perlmacros.swg> + +/* ------------------------------------------------------------ + * The runtime part + * ------------------------------------------------------------ */ +%include <perlruntime.swg> + +/* ------------------------------------------------------------ + * Special user directives + * ------------------------------------------------------------ */ +%include <perluserdir.swg> + +/* ------------------------------------------------------------ + * Typemap specializations + * ------------------------------------------------------------ */ +%include <perltypemaps.swg> + +/* ------------------------------------------------------------ + * Overloaded operator support + * ------------------------------------------------------------ */ +%include <perlopers.swg> + +/* ------------------------------------------------------------ + * Warnings for Perl keywords + * ------------------------------------------------------------ */ +%include <perlkw.swg> + +/* ------------------------------------------------------------ + * The Perl initialization function + * ------------------------------------------------------------ */ +%include <perlinit.swg> + + diff --git a/devtools/swigwin-1.3.34/Lib/perl5/perlerrors.swg b/devtools/swigwin-1.3.34/Lib/perl5/perlerrors.swg new file mode 100644 index 0000000..024f037 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/perlerrors.swg @@ -0,0 +1,49 @@ +/* ----------------------------------------------------------------------------- + * error manipulation + * ----------------------------------------------------------------------------- */ + +SWIGINTERN const char* +SWIG_Perl_ErrorType(int code) { + const char* type = 0; + switch(code) { + case SWIG_MemoryError: + type = "MemoryError"; + break; + case SWIG_IOError: + type = "IOError"; + break; + case SWIG_RuntimeError: + type = "RuntimeError"; + break; + case SWIG_IndexError: + type = "IndexError"; + break; + case SWIG_TypeError: + type = "TypeError"; + break; + case SWIG_DivisionByZero: + type = "ZeroDivisionError"; + break; + case SWIG_OverflowError: + type = "OverflowError"; + break; + case SWIG_SyntaxError: + type = "SyntaxError"; + break; + case SWIG_ValueError: + type = "ValueError"; + break; + case SWIG_SystemError: + type = "SystemError"; + break; + case SWIG_AttributeError: + type = "AttributeError"; + break; + default: + type = "RuntimeError"; + } + return type; +} + + + diff --git a/devtools/swigwin-1.3.34/Lib/perl5/perlfragments.swg b/devtools/swigwin-1.3.34/Lib/perl5/perlfragments.swg new file mode 100644 index 0000000..45d25d1 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/perlfragments.swg @@ -0,0 +1,23 @@ +/* + + Create a file with this name, 'perlfragments.swg', in your working + directory and add all the %fragments you want to take precedence + over the ones defined by default by swig. + + For example, if you add: + + %fragment(SWIG_AsVal_frag(int),"header") { + SWIGINTERNINLINE int + SWIG_AsVal(int)(PyObject *obj, int *val) + { + <your code here>; + } + } + + this will replace the code used to retrieve an integer value for all + the typemaps that need it, including: + + int, std::vector<int>, std::list<std::pair<int,int> >, etc. + + +*/ diff --git a/devtools/swigwin-1.3.34/Lib/perl5/perlhead.swg b/devtools/swigwin-1.3.34/Lib/perl5/perlhead.swg new file mode 100644 index 0000000..5437af5 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/perlhead.swg @@ -0,0 +1,102 @@ +#ifdef __cplusplus +/* Needed on some windows machines---since MS plays funny games with the header files under C++ */ +#include <math.h> +#include <stdlib.h> +extern "C" { +#endif +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +/* Add in functionality missing in older versions of Perl. Much of this is based on Devel-PPPort on cpan. */ + +/* Add PERL_REVISION, PERL_VERSION, PERL_SUBVERSION if missing */ +#ifndef PERL_REVISION +# if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION)) +# define PERL_PATCHLEVEL_H_IMPLICIT +# include <patchlevel.h> +# endif +# if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL))) +# include <could_not_find_Perl_patchlevel.h> +# endif +# ifndef PERL_REVISION +# define PERL_REVISION (5) +# define PERL_VERSION PATCHLEVEL +# define PERL_SUBVERSION SUBVERSION +# endif +#endif + +#if defined(WIN32) && defined(PERL_OBJECT) && !defined(PerlIO_exportFILE) +#define PerlIO_exportFILE(fh,fl) (FILE*)(fh) +#endif + +#ifndef SvIOK_UV +# define SvIOK_UV(sv) (SvIOK(sv) && (SvUVX(sv) == SvIVX(sv))) +#endif + +#ifndef SvUOK +# define SvUOK(sv) SvIOK_UV(sv) +#endif + +#if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5))) +# define PL_sv_undef sv_undef +# define PL_na na +# define PL_errgv errgv +# define PL_sv_no sv_no +# define PL_sv_yes sv_yes +# define PL_markstack_ptr markstack_ptr +#endif + +#ifndef IVSIZE +# ifdef LONGSIZE +# define IVSIZE LONGSIZE +# else +# define IVSIZE 4 /* A bold guess, but the best we can make. */ +# endif +#endif + +#ifndef INT2PTR +# if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE) +# define PTRV UV +# define INT2PTR(any,d) (any)(d) +# else +# if PTRSIZE == LONGSIZE +# define PTRV unsigned long +# else +# define PTRV unsigned +# endif +# define INT2PTR(any,d) (any)(PTRV)(d) +# endif + +# define NUM2PTR(any,d) (any)(PTRV)(d) +# define PTR2IV(p) INT2PTR(IV,p) +# define PTR2UV(p) INT2PTR(UV,p) +# define PTR2NV(p) NUM2PTR(NV,p) + +# if PTRSIZE == LONGSIZE +# define PTR2ul(p) (unsigned long)(p) +# else +# define PTR2ul(p) INT2PTR(unsigned long,p) +# endif +#endif /* !INT2PTR */ + +#ifndef SvPV_nolen +# define SvPV_nolen(x) SvPV(x,PL_na) +#endif + +#ifndef get_sv +# define get_sv perl_get_sv +#endif + +#ifndef ERRSV +# define ERRSV get_sv("@",FALSE) +#endif + +#ifndef pTHX_ +#define pTHX_ +#endif + +#include <string.h> +#ifdef __cplusplus +} +#endif diff --git a/devtools/swigwin-1.3.34/Lib/perl5/perlinit.swg b/devtools/swigwin-1.3.34/Lib/perl5/perlinit.swg new file mode 100644 index 0000000..68bf6d8 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/perlinit.swg @@ -0,0 +1,76 @@ + +/* Export the SWIG initialization function */ +%header %{ +#ifdef __cplusplus +extern "C" +#endif +#ifndef PERL_OBJECT +#ifndef MULTIPLICITY +SWIGEXPORT void SWIG_init (CV* cv); +#else +SWIGEXPORT void SWIG_init (pTHXo_ CV* cv); +#endif +#else +SWIGEXPORT void SWIG_init (CV *cv, CPerlObj *); +#endif +%} + +/* Module initialization function */ + +%insert(init) "swiginit.swg" + +%init %{ + +#ifdef __cplusplus +extern "C" +#endif + +XS(SWIG_init) { + dXSARGS; + int i; + + SWIG_InitializeModule(0); + + /* Install commands */ + for (i = 0; swig_commands[i].name; i++) { + newXS((char*) swig_commands[i].name,swig_commands[i].wrapper, (char*)__FILE__); + } + + /* Install variables */ + for (i = 0; swig_variables[i].name; i++) { + SV *sv; + sv = get_sv((char*) swig_variables[i].name, TRUE | 0x2); + if (swig_variables[i].type) { + SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0); + } else { + sv_setiv(sv,(IV) 0); + } + swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get); + } + + /* Install constant */ + for (i = 0; swig_constants[i].type; i++) { + SV *sv; + sv = get_sv((char*)swig_constants[i].name, TRUE | 0x2); + switch(swig_constants[i].type) { + case SWIG_INT: + sv_setiv(sv, (IV) swig_constants[i].lvalue); + break; + case SWIG_FLOAT: + sv_setnv(sv, (double) swig_constants[i].dvalue); + break; + case SWIG_STRING: + sv_setpv(sv, (char *) swig_constants[i].pvalue); + break; + case SWIG_POINTER: + SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0); + break; + case SWIG_BINARY: + SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype)); + break; + default: + break; + } + SvREADONLY_on(sv); + } +%} diff --git a/devtools/swigwin-1.3.34/Lib/perl5/perlkw.swg b/devtools/swigwin-1.3.34/Lib/perl5/perlkw.swg new file mode 100644 index 0000000..71a229c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/perlkw.swg @@ -0,0 +1,251 @@ +/* Warnings for Perl keywords */ +#define PERLKW(x) %keywordwarn(`x` " is a perl keyword") `x` +#define PERLBN(x) %builtinwarn(`x` " conflicts with a built-in name in perl") "::" `x` + + +/* + + From http://www.rocketaware.com/perl/perlfunc/ + +*/ + +/* Functions for SCALARs or strings*/ +PERLBN(chomp); +PERLBN(chop); +PERLBN(chr); +PERLBN(crypt); +PERLBN(hex); +PERLBN(index); +PERLBN(lc); +PERLBN(lcfirst); +PERLBN(length); +PERLBN(oct); +PERLBN(ord); +PERLBN(pack); +PERLBN(reverse); +PERLBN(rindex); +PERLBN(sprintf); +PERLBN(substr); +PERLBN(uc); +PERLBN(ucfirst); + +/* Regular expressions and pattern matching */ +PERLBN(m); +PERLBN(pos); +PERLBN(quotemeta); +PERLBN(split); +PERLBN(study); + +/* Numeric functions */ +PERLBN(abs); +PERLBN(atan2); +PERLBN(cos); +PERLBN(exp); +PERLBN(hex); +PERLBN(int); +PERLBN(log); +PERLBN(oct); +PERLBN(rand); +PERLBN(sin); +PERLBN(sqrt); +PERLBN(srand); + + +/* Functions for real @ARRAYs*/ +PERLBN(pop); +PERLBN(push); +PERLBN(shift); +PERLBN(splice); +PERLBN(unshift); + +/* Functions for list data*/ +PERLBN(grep); +PERLBN(join); +PERLBN(map); +PERLBN(qw); +PERLBN(reverse); +PERLBN(sort); +PERLBN(unpack); + + +/* Functions for real %HASHes*/ +PERLBN(delete); +PERLBN(each); +PERLBN(exists); +PERLBN(keys); +PERLBN(values); + + +/* Input and output functions*/ + +PERLBN(binmode); +PERLBN(close); +PERLBN(closedir); +PERLBN(dbmclose); +PERLBN(dbmopen); +PERLBN(die); +PERLBN(eof); +PERLBN(fileno); +PERLBN(flock); +PERLBN(format); +PERLBN(getc); +PERLBN(print); +PERLBN(printf); +PERLBN(read); +PERLBN(readdir); +PERLBN(rewinddir); +PERLBN(seek); +PERLBN(seekdir); +PERLBN(select); +PERLBN(syscall); +PERLBN(sysread); +PERLBN(sysseek); +PERLBN(syswrite); +PERLBN(tell); +PERLBN(telldir); +PERLBN(truncate); +PERLBN(warn); +PERLBN(write); + + +/* Functions for fixed length data or records*/ +PERLBN(pack); +PERLBN(read); +PERLBN(syscall); +PERLBN(sysread); +PERLBN(syswrite); +PERLBN(unpack); +PERLBN(vec); + + +/* Functions for filehandles, files, or directories */ +PERLBN(chdir); +PERLBN(chmod); +PERLBN(chown); +PERLBN(chroot); +PERLBN(fcntl); +PERLBN(glob); +PERLBN(ioctl); +PERLBN(link); +PERLBN(lstat); +PERLBN(mkdir); +PERLBN(open); +PERLBN(opendir); +PERLBN(readlink); +PERLBN(rename); +PERLBN(rmdir); +PERLBN(stat); +PERLBN(symlink); +PERLBN(umask); +PERLBN(unlink); +PERLBN(utime); + + +/* Keywords related to the control flow of your perl program */ +PERLKW(caller); +PERLKW(continue); +PERLKW(die); +PERLKW(do); +PERLKW(dump); +PERLKW(eval); +PERLKW(exit); +PERLKW(goto); +PERLKW(last); +PERLKW(next); +PERLKW(redo); +PERLKW(return); +PERLKW(sub); +PERLKW(wantarray); + + +/* Keywords related to scoping */ +PERLKW(caller); +PERLKW(import); +PERLKW(local); +PERLKW(my); +PERLKW(package); +PERLKW(use); + + +/* Miscellaneous functions */ +PERLBN("defined"); +PERLBN(dump); +PERLBN(eval); +PERLBN(formline); +PERLBN(local); +PERLBN(my); +PERLBN(reset); +PERLBN(scalar); +PERLBN(undef); +PERLBN(wantarray); + + +/* Functions for processes and process groups */ +PERLBN(alarm); +PERLBN(exec); +PERLBN(fork); +PERLBN(getpgrp); +PERLBN(getppid); +PERLBN(getpriority); +PERLBN(kill); +PERLBN(pipe); +PERLBN(setpgrp); +PERLBN(setpriority); +PERLBN(sleep); +PERLBN(system); +PERLBN(times); +PERLBN(wait); +PERLBN(waitpid); + + +/* Keywords related to perl modules */ +PERLKW(do); +PERLKW(import); +PERLKW(no); +PERLKW(package); +PERLKW(require); +PERLKW(use); + + +/* Keywords related to classes and object-orientedness */ +PERLKW(bless); +PERLKW(dbmclose); +PERLKW(dbmopen); +PERLKW(package); +PERLKW(ref); +PERLKW(tie); +PERLKW(tied); +PERLKW(untie); +PERLKW(use); + +/* Functions new in perl5 */ +PERLBN(abs); +PERLBN(bless); +PERLBN(chomp); +PERLBN(chr); +PERLBN(exists); +PERLBN(formline); +PERLBN(glob); +PERLBN(import); +PERLBN(lc); +PERLBN(lcfirst); +PERLBN(map); +PERLBN(my); +PERLBN(no); +PERLBN(prototype); +PERLBN(qx); +PERLBN(qw); +PERLBN(readline); +PERLBN(readpipe); +PERLBN(ref); +PERLBN(sub); +PERLBN(sysopen); +PERLBN(tie); +PERLBN(tied); +PERLBN(uc); +PERLBN(ucfirst); +PERLBN(untie); +PERLBN(use); + +#undef PERLKW +#undef PERLBN diff --git a/devtools/swigwin-1.3.34/Lib/perl5/perlmacros.swg b/devtools/swigwin-1.3.34/Lib/perl5/perlmacros.swg new file mode 100644 index 0000000..4917f6e --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/perlmacros.swg @@ -0,0 +1,2 @@ +%include <typemaps/swigmacros.swg> + diff --git a/devtools/swigwin-1.3.34/Lib/perl5/perlmain.i b/devtools/swigwin-1.3.34/Lib/perl5/perlmain.i new file mode 100644 index 0000000..f224b9c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/perlmain.i @@ -0,0 +1,85 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * perlmain.i + * + * Code to statically rebuild perl5. + * ----------------------------------------------------------------------------- */ + +#ifdef AUTODOC +%subsection "perlmain.i" +%text %{ +This module provides support for building a new version of the +Perl executable. This will be necessary on systems that do +not support shared libraries and may be necessary with C++ +extensions. + +This module may only build a stripped down version of the +Perl executable. Thus, it may be necessary (or desirable) +to hand-edit this file for your particular application. To +do this, simply copy this file from swig_lib/perl5/perlmain.i +to your working directory and make the appropriate modifications. + +This library file works with Perl 5.003. It may work with earlier +versions, but it hasn't been tested. As far as I know, this +library is C++ safe. +%} +#endif + +%{ + +static void xs_init _((pTHX)); +static PerlInterpreter *my_perl; + +int perl_eval(char *string) { + char *argv[2]; + argv[0] = string; + argv[1] = (char *) 0; + return perl_call_argv("eval",0,argv); +} + +int +main(int argc, char **argv, char **env) +{ + int exitstatus; + + my_perl = perl_alloc(); + if (!my_perl) + exit(1); + perl_construct( my_perl ); + + exitstatus = perl_parse( my_perl, xs_init, argc, argv, (char **) NULL ); + if (exitstatus) + exit( exitstatus ); + + /* Initialize all of the module variables */ + + exitstatus = perl_run( my_perl ); + + perl_destruct( my_perl ); + perl_free( my_perl ); + + exit( exitstatus ); +} + +/* Register any extra external extensions */ + +/* Do not delete this line--writemain depends on it */ +/* EXTERN_C void boot_DynaLoader _((CV* cv)); */ + +static void +xs_init(pTHX) +{ +/* dXSUB_SYS; */ + char *file = __FILE__; + { + /* newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); */ + newXS(SWIG_name, SWIG_init, file); +#ifdef SWIGMODINIT + SWIGMODINIT +#endif + } +} + +%} diff --git a/devtools/swigwin-1.3.34/Lib/perl5/perlopers.swg b/devtools/swigwin-1.3.34/Lib/perl5/perlopers.swg new file mode 100644 index 0000000..106b00e --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/perlopers.swg @@ -0,0 +1,56 @@ +/* ------------------------------------------------------------ + * Overloaded operator support + * ------------------------------------------------------------ */ + +#ifdef __cplusplus + +// These are auto-supported by the Perl-module +%rename(__plusplus__) *::operator++; +%rename(__minmin__) *::operator--; +%rename(__add__) *::operator+; +%rename(__sub__) *::operator-; +%rename(__neg__) *::operator-(); +%rename(__neg__) *::operator-() const; +%rename(__mul__) *::operator*; +%rename(__div__) *::operator/; +%rename(__eq__) *::operator==; +%rename(__ne__) *::operator!=; +%rename(__mod__) *::operator%; +%rename(__gt__) *::operator>; +%rename(__lt__) *::operator<; +%rename(__not__) *::operator!; + +// These are renamed, but no 'use overload...' is added +%rename(__lshift__) *::operator<<; +%rename(__rshift__) *::operator>>; +%rename(__and__) *::operator&; +%rename(__or__) *::operator|; +%rename(__xor__) *::operator^; +%rename(__invert__) *::operator~; +%rename(__le__) *::operator<=; +%rename(__ge__) *::operator>=; +%rename(__call__) *::operator(); + +/* Ignored operators */ +%ignoreoperator(LAND) operator&&; +%ignoreoperator(LOR) operator||; +%ignoreoperator(PLUS) operator+(); +%ignoreoperator(PLUS) operator+() const; +%ignoreoperator(PLUSEQ) operator+=; +%ignoreoperator(MINUSEQ) operator-=; +%ignoreoperator(MULEQ) operator*=; +%ignoreoperator(DIVEQ) operator/=; +%ignoreoperator(MODEQ) operator%=; +%ignoreoperator(LSHIFTEQ) operator<<=; +%ignoreoperator(RSHIFTEQ) operator>>=; +%ignoreoperator(ANDEQ) operator&=; +%ignoreoperator(OREQ) operator|=; +%ignoreoperator(XOREQ) operator^=; +%ignoreoperator(EQ) operator=; +%ignoreoperator(PLUSPLUS) operator++; +%ignoreoperator(MINUSMINUS) operator--; +%ignoreoperator(ARROWSTAR) operator->*; +%ignoreoperator(INDEX) operator[]; + + +#endif /* __cplusplus */ diff --git a/devtools/swigwin-1.3.34/Lib/perl5/perlprimtypes.swg b/devtools/swigwin-1.3.34/Lib/perl5/perlprimtypes.swg new file mode 100644 index 0000000..ae7bb38 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/perlprimtypes.swg @@ -0,0 +1,328 @@ +/* ------------------------------------------------------------ + * Primitive Types + * ------------------------------------------------------------ */ + +/* bool */ + +%fragment(SWIG_From_frag(bool),"header") { +SWIGINTERNINLINE SV * +SWIG_From_dec(bool)(bool value) +{ + SV *obj = sv_newmortal(); + if (value) { + sv_setsv(obj, &PL_sv_yes); + } else { + sv_setsv(obj, &PL_sv_no); + } + return obj; +} +} + +%fragment(SWIG_AsVal_frag(bool),"header", + fragment="SWIG_CanCastAsInteger") { +SWIGINTERN int +SWIG_AsVal_dec(bool)(SV *obj, bool* val) +{ + if (obj == &PL_sv_yes) { + if (val) *val = true; + return SWIG_OK; + } else if (obj == &PL_sv_no) { + if (val) *val = false; + return SWIG_OK; + } else { + if (val) *val = SvTRUE(obj) ? true: false; + return SWIG_AddCast(SWIG_OK); + } + return SWIG_TypeError; +} +} + + +/* long */ + +%fragment(SWIG_From_frag(long),"header") { +SWIGINTERNINLINE SV * +SWIG_From_dec(long)(long value) +{ + SV *obj = sv_newmortal(); + sv_setiv(obj, (IV) value); + return obj; +} +} + +%fragment(SWIG_AsVal_frag(long),"header", + fragment="SWIG_CanCastAsInteger") { +SWIGINTERN int +SWIG_AsVal_dec(long)(SV *obj, long* val) +{ + if (SvIOK(obj)) { + if (val) *val = SvIV(obj); + return SWIG_OK; + } else { + int dispatch = 0; + const char *nptr = SvPV_nolen(obj); + if (nptr) { + char *endptr; + long v; + errno = 0; + v = strtol(nptr, &endptr,0); + if (errno == ERANGE) { + errno = 0; + return SWIG_OverflowError; + } else { + if (*endptr == '\0') { + if (val) *val = v; + return SWIG_Str2NumCast(SWIG_OK); + } + } + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { + if (val) *val = (long)(d); + return res; + } + } + } + return SWIG_TypeError; +} +} + +/* unsigned long */ + +%fragment(SWIG_From_frag(unsigned long),"header", + fragment=SWIG_AsVal_frag(double)) { +SWIGINTERNINLINE SV * +SWIG_From_dec(unsigned long)(unsigned long value) +{ + SV *obj = sv_newmortal(); + sv_setuv(obj, (UV) value); + return obj; +} +} + +%fragment(SWIG_AsVal_frag(unsigned long),"header", + fragment="SWIG_CanCastAsInteger") { +SWIGINTERN int +SWIG_AsVal_dec(unsigned long)(SV *obj, unsigned long *val) +{ + if (SvUOK(obj)) { + if (val) *val = SvUV(obj); + return SWIG_OK; + } else if (SvIOK(obj)) { + long v = SvIV(obj); + if (v >= 0) { + if (val) *val = v; + return SWIG_OK; + } else { + return SWIG_OverflowError; + } + } else { + int dispatch = 0; + const char *nptr = SvPV_nolen(obj); + if (nptr) { + char *endptr; + unsigned long v; + errno = 0; + v = strtoul(nptr, &endptr,0); + if (errno == ERANGE) { + errno = 0; + return SWIG_OverflowError; + } else { + if (*endptr == '\0') { + if (val) *val = v; + return SWIG_Str2NumCast(SWIG_OK); + } + } + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { + if (val) *val = (unsigned long)(d); + return res; + } + } + } + return SWIG_TypeError; +} +} + +/* long long */ + +%fragment(SWIG_From_frag(long long),"header", + fragment=SWIG_From_frag(long), + fragment="<limits.h>", + fragment="<stdio.h>") { +SWIGINTERNINLINE SV * +SWIG_From_dec(long long)(long long value) +{ + if (((long long) LONG_MIN <= value) && (value <= (long long) LONG_MAX)) { + return SWIG_From(long)(%numeric_cast(value,long)); + } else { + char temp[256]; + SV *obj = sv_newmortal(); + sprintf(temp, "%lld", value); + sv_setpv(obj, temp); + return obj; + } +} +} + +%fragment(SWIG_AsVal_frag(long long),"header", + fragment="<limits.h>", + fragment="<stdlib.h>", + fragment="SWIG_CanCastAsInteger") { + +SWIGINTERN int +SWIG_AsVal_dec(long long)(SV *obj, long long *val) +{ + if (SvIOK(obj)) { + if (val) *val = SvIV(obj); + return SWIG_OK; + } else { + int dispatch = 0; + const char *nptr = SvPV_nolen(obj); + if (nptr) { + char *endptr; + long long v; + errno = 0; + v = strtoll(nptr, &endptr,0); + if (errno == ERANGE) { + errno = 0; + return SWIG_OverflowError; + } else { + if (*endptr == '\0') { + if (val) *val = v; + return SWIG_Str2NumCast(SWIG_OK); + } + } + } + if (!dispatch) { + const double mant_max = 1LL << DBL_MANT_DIG; + const double mant_min = -mant_max; + double d; + int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, mant_min, mant_max)) { + if (val) *val = (long long)(d); + return res; + } + } + } + return SWIG_TypeError; +} +} + +/* unsigned long long */ + +%fragment(SWIG_From_frag(unsigned long long),"header", + fragment=SWIG_From_frag(long long), + fragment="<limits.h>", + fragment="<stdio.h>") { +SWIGINTERNINLINE SV * +SWIG_From_dec(unsigned long long)(unsigned long long value) +{ + if (value < (unsigned long long) LONG_MAX) { + return SWIG_From(long long)(%numeric_cast(value, long long)); + } else { + char temp[256]; + SV *obj = sv_newmortal(); + sprintf(temp, "%llu", value); + sv_setpv(obj, temp); + return obj; + } +} +} + +%fragment(SWIG_AsVal_frag(unsigned long long),"header", + fragment="<limits.h>", + fragment="<stdlib.h>", + fragment="SWIG_CanCastAsInteger") { +SWIGINTERN int +SWIG_AsVal_dec(unsigned long long)(SV *obj, unsigned long long *val) +{ + if (SvUOK(obj)) { + if (val) *val = SvUV(obj); + return SWIG_OK; + } else if (SvIOK(obj)) { + long v = SvIV(obj); + if (v >= 0) { + if (val) *val = v; + return SWIG_OK; + } else { + return SWIG_OverflowError; + } + } else { + int dispatch = 0; + const char *nptr = SvPV_nolen(obj); + if (nptr) { + char *endptr; + unsigned long long v; + errno = 0; + v = strtoull(nptr, &endptr,0); + if (errno == ERANGE) { + errno = 0; + return SWIG_OverflowError; + } else { + if (*endptr == '\0') { + if (val) *val = v; + return SWIG_Str2NumCast(SWIG_OK); + } + } + } + if (!dispatch) { + const double mant_max = 1LL << DBL_MANT_DIG; + double d; + int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) { + if (val) *val = (unsigned long long)(d); + return res; + } + } + } + return SWIG_TypeError; +} +} + +/* double */ + +%fragment(SWIG_From_frag(double),"header") { +SWIGINTERNINLINE SV * +SWIG_From_dec(double)(double value) +{ + SV *obj = sv_newmortal(); + sv_setnv(obj, value); + return obj; +} +} + +%fragment(SWIG_AsVal_frag(double),"header") { +SWIGINTERN int +SWIG_AsVal_dec(double)(SV *obj, double *val) +{ + if (SvNIOK(obj)) { + if (val) *val = SvNV(obj); + return SWIG_OK; + } else if (SvIOK(obj)) { + if (val) *val = (double) SvIV(obj); + return SWIG_AddCast(SWIG_OK); + } else { + const char *nptr = SvPV_nolen(obj); + if (nptr) { + char *endptr; + double v = strtod(nptr, &endptr); + if (errno == ERANGE) { + errno = 0; + return SWIG_OverflowError; + } else { + if (*endptr == '\0') { + if (val) *val = v; + return SWIG_Str2NumCast(SWIG_OK); + } + } + } + } + return SWIG_TypeError; +} +} diff --git a/devtools/swigwin-1.3.34/Lib/perl5/perlrun.swg b/devtools/swigwin-1.3.34/Lib/perl5/perlrun.swg new file mode 100644 index 0000000..6a0bc41 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/perlrun.swg @@ -0,0 +1,467 @@ +/* ----------------------------------------------------------------------------- + * perlrun.swg + * + * This file contains the runtime support for Perl modules + * and includes code for managing global variables and pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +#ifdef PERL_OBJECT +#define SWIG_PERL_OBJECT_DECL CPerlObj *SWIGUNUSEDPARM(pPerl), +#define SWIG_PERL_OBJECT_CALL pPerl, +#else +#define SWIG_PERL_OBJECT_DECL +#define SWIG_PERL_OBJECT_CALL +#endif + +/* Common SWIG API */ + +/* for raw pointers */ +#define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Perl_ConvertPtr(SWIG_PERL_OBJECT_CALL obj, pp, type, flags) +#define SWIG_NewPointerObj(p, type, flags) SWIG_Perl_NewPointerObj(SWIG_PERL_OBJECT_CALL p, type, flags) + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, p, s, type) SWIG_Perl_ConvertPacked(SWIG_PERL_OBJECT_CALL obj, p, s, type) +#define SWIG_NewPackedObj(p, s, type) SWIG_Perl_NewPackedObj(SWIG_PERL_OBJECT_CALL p, s, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Perl_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Perl_SetModule(pointer) + + +/* Error manipulation */ + +#define SWIG_ErrorType(code) SWIG_Perl_ErrorType(code) +#define SWIG_Error(code, msg) sv_setpvf(GvSV(PL_errgv),"%s %s\n", SWIG_ErrorType(code), msg) +#define SWIG_fail goto fail + +/* Perl-specific SWIG API */ + +#define SWIG_MakePtr(sv, ptr, type, flags) SWIG_Perl_MakePtr(SWIG_PERL_OBJECT_CALL sv, ptr, type, flags) +#define SWIG_MakePackedObj(sv, p, s, type) SWIG_Perl_MakePackedObj(SWIG_PERL_OBJECT_CALL sv, p, s, type) +#define SWIG_SetError(str) SWIG_Error(SWIG_RuntimeError, str) + + +#define SWIG_PERL_DECL_ARGS_1(arg1) (SWIG_PERL_OBJECT_DECL arg1) +#define SWIG_PERL_CALL_ARGS_1(arg1) (SWIG_PERL_OBJECT_CALL arg1) +#define SWIG_PERL_DECL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_DECL arg1, arg2) +#define SWIG_PERL_CALL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_CALL arg1, arg2) + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +/* For backward compatibility only */ +#define SWIG_POINTER_EXCEPTION 0 + +#ifdef __cplusplus +extern "C" { +#endif + +#define SWIG_OWNER SWIG_POINTER_OWN +#define SWIG_SHADOW SWIG_OWNER << 1 + +#define SWIG_MAYBE_PERL_OBJECT SWIG_PERL_OBJECT_DECL + +/* SWIG Perl macros */ + +/* Macro to declare an XS function */ +#ifndef XSPROTO +# define XSPROTO(name) void name(pTHX_ CV* cv) +#endif + +/* Macro to call an XS function */ +#ifdef PERL_OBJECT +# define SWIG_CALLXS(_name) _name(cv,pPerl) +#else +# ifndef MULTIPLICITY +# define SWIG_CALLXS(_name) _name(cv) +# else +# define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv) +# endif +#endif + +#ifdef PERL_OBJECT +#define MAGIC_PPERL CPerlObj *pPerl = (CPerlObj *) this; + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (CPerlObj::*SwigMagicFunc)(SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + +#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) +#define SWIGCLASS_STATIC + +#else /* PERL_OBJECT */ + +#define MAGIC_PPERL +#define SWIGCLASS_STATIC static SWIGUNUSED + +#ifndef MULTIPLICITY +#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (*SwigMagicFunc)(SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + +#else /* MULTIPLICITY */ + +#define SWIG_MAGIC(a,b) (struct interpreter *interp, SV *a, MAGIC *b) + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + +#endif /* MULTIPLICITY */ +#endif /* PERL_OBJECT */ + +/* Workaround for bug in perl 5.6.x croak and earlier */ +#if (PERL_VERSION < 8) +# ifdef PERL_OBJECT +# define SWIG_croak_null() SWIG_Perl_croak_null(pPerl) +static void SWIG_Perl_croak_null(CPerlObj *pPerl) +# else +static void SWIG_croak_null() +# endif +{ + SV *err=ERRSV; +# if (PERL_VERSION < 6) + croak("%_", err); +# else + if (SvOK(err) && !SvROK(err)) croak("%_", err); + croak(Nullch); +# endif +} +#else +# define SWIG_croak_null() croak(Nullch) +#endif + + +/* + Define how strict is the cast between strings and integers/doubles + when overloading between these types occurs. + + The default is making it as strict as possible by using SWIG_AddCast + when needed. + + You can use -DSWIG_PERL_NO_STRICT_STR2NUM at compilation time to + disable the SWIG_AddCast, making the casting between string and + numbers less strict. + + In the end, we try to solve the overloading between strings and + numerical types in the more natural way, but if you can avoid it, + well, avoid it using %rename, for example. +*/ +#ifndef SWIG_PERL_NO_STRICT_STR2NUM +# ifndef SWIG_PERL_STRICT_STR2NUM +# define SWIG_PERL_STRICT_STR2NUM +# endif +#endif +#ifdef SWIG_PERL_STRICT_STR2NUM +/* string takes precedence */ +#define SWIG_Str2NumCast(x) SWIG_AddCast(x) +#else +/* number takes precedence */ +#define SWIG_Str2NumCast(x) x +#endif + + + +#include <stdlib.h> + +SWIGRUNTIME const char * +SWIG_Perl_TypeProxyName(const swig_type_info *type) { + if (!type) return NULL; + if (type->clientdata != NULL) { + return (const char*) type->clientdata; + } + else { + return type->name; + } +} + +SWIGRUNTIME swig_cast_info * +SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(( (!iter->type->clientdata && (strcmp((char*)iter->type->name, c) == 0)) + || (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0))), ty); +} + + +/* Function for getting a pointer value */ + +SWIGRUNTIME int +SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags) { + swig_cast_info *tc; + void *voidptr = (void *)0; + SV *tsv = 0; + /* If magical, apply more magic */ + if (SvGMAGICAL(sv)) + mg_get(sv); + + /* Check to see if this is an object */ + if (sv_isobject(sv)) { + IV tmp = 0; + tsv = (SV*) SvRV(sv); + if ((SvTYPE(tsv) == SVt_PVHV)) { + MAGIC *mg; + if (SvMAGICAL(tsv)) { + mg = mg_find(tsv,'P'); + if (mg) { + sv = mg->mg_obj; + if (sv_isobject(sv)) { + tsv = (SV*)SvRV(sv); + tmp = SvIV(tsv); + } + } + } else { + return SWIG_ERROR; + } + } else { + tmp = SvIV(tsv); + } + voidptr = INT2PTR(void *,tmp); + } else if (! SvOK(sv)) { /* Check for undef */ + *(ptr) = (void *) 0; + return SWIG_OK; + } else if (SvTYPE(sv) == SVt_RV) { /* Check for NULL pointer */ + if (!SvROK(sv)) { + *(ptr) = (void *) 0; + return SWIG_OK; + } else { + return SWIG_ERROR; + } + } else { /* Don't know what it is */ + return SWIG_ERROR; + } + if (_t) { + /* Now see if the types match */ + char *_c = HvNAME(SvSTASH(SvRV(sv))); + tc = SWIG_TypeProxyCheck(_c,_t); + if (!tc) { + return SWIG_ERROR; + } + { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,voidptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + } + } else { + *ptr = voidptr; + } + + /* + * DISOWN implementation: we need a perl guru to check this one. + */ + if (tsv && (flags & SWIG_POINTER_DISOWN)) { + /* + * almost copy paste code from below SWIG_POINTER_OWN setting + */ + SV *obj = sv; + HV *stash = SvSTASH(SvRV(obj)); + GV *gv = *(GV**) hv_fetch(stash, "OWNER", 5, TRUE); + if (isGV(gv)) { + HV *hv = GvHVn(gv); + /* + * To set ownership (see below), a newSViv(1) entry is added. + * Hence, to remove ownership, we delete the entry. + */ + if (hv_exists_ent(hv, obj, 0)) { + hv_delete_ent(hv, obj, 0, 0); + } + } + } + return SWIG_OK; +} + +SWIGRUNTIME void +SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, int flags) { + if (ptr && (flags & SWIG_SHADOW)) { + SV *self; + SV *obj=newSV(0); + HV *hash=newHV(); + HV *stash; + sv_setref_pv(obj, (char *) SWIG_Perl_TypeProxyName(t), ptr); + stash=SvSTASH(SvRV(obj)); + if (flags & SWIG_POINTER_OWN) { + HV *hv; + GV *gv=*(GV**)hv_fetch(stash, "OWNER", 5, TRUE); + if (!isGV(gv)) + gv_init(gv, stash, "OWNER", 5, FALSE); + hv=GvHVn(gv); + hv_store_ent(hv, obj, newSViv(1), 0); + } + sv_magic((SV *)hash, (SV *)obj, 'P', Nullch, 0); + SvREFCNT_dec(obj); + self=newRV_noinc((SV *)hash); + sv_setsv(sv, self); + SvREFCNT_dec((SV *)self); + sv_bless(sv, stash); + } + else { + sv_setref_pv(sv, (char *) SWIG_Perl_TypeProxyName(t), ptr); + } +} + +SWIGRUNTIMEINLINE SV * +SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *ptr, swig_type_info *t, int flags) { + SV *result = sv_newmortal(); + SWIG_MakePtr(result, ptr, t, flags); + return result; +} + +SWIGRUNTIME void +SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, int sz, swig_type_info *type) { + char result[1024]; + char *r = result; + if ((2*sz + 1 + strlen(SWIG_Perl_TypeProxyName(type))) > 1000) return; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + strcpy(r,SWIG_Perl_TypeProxyName(type)); + sv_setpv(sv, result); +} + +SWIGRUNTIME SV * +SWIG_Perl_NewPackedObj(SWIG_MAYBE_PERL_OBJECT void *ptr, int sz, swig_type_info *type) { + SV *result = sv_newmortal(); + SWIG_Perl_MakePackedObj(result, ptr, sz, type); + return result; +} + +/* Convert a packed value value */ +SWIGRUNTIME int +SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty) { + swig_cast_info *tc; + const char *c = 0; + + if ((!obj) || (!SvOK(obj))) return SWIG_ERROR; + c = SvPV_nolen(obj); + /* Pointer values must start with leading underscore */ + if (*c != '_') return SWIG_ERROR; + c++; + c = SWIG_UnpackData(c,ptr,sz); + if (ty) { + tc = SWIG_TypeCheck(c,ty); + if (!tc) return SWIG_ERROR; + } + return SWIG_OK; +} + + +/* Macros for low-level exception handling */ +#define SWIG_croak(x) { SWIG_Error(SWIG_RuntimeError, x); SWIG_fail; } + + +typedef XSPROTO(SwigPerlWrapper); +typedef SwigPerlWrapper *SwigPerlWrapperPtr; + +/* Structure for command table */ +typedef struct { + const char *name; + SwigPerlWrapperPtr wrapper; +} swig_command_info; + +/* Information for constant table */ + +#define SWIG_INT 1 +#define SWIG_FLOAT 2 +#define SWIG_STRING 3 +#define SWIG_POINTER 4 +#define SWIG_BINARY 5 + +/* Constant information structure */ +typedef struct swig_constant_info { + int type; + const char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_constant_info; + + +/* Structure for variable table */ +typedef struct { + const char *name; + SwigMagicFunc set; + SwigMagicFunc get; + swig_type_info **type; +} swig_variable_info; + +/* Magic variable code */ +#ifndef PERL_OBJECT +#define swig_create_magic(s,a,b,c) _swig_create_magic(s,a,b,c) + #ifndef MULTIPLICITY + SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) + #else + SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) + #endif +#else +# define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c) +SWIGRUNTIME void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) +#endif +{ + MAGIC *mg; + sv_magic(sv,sv,'U',(char *) name,strlen(name)); + mg = mg_find(sv,'U'); + mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL)); + mg->mg_virtual->svt_get = (SwigMagicFunc) get; + mg->mg_virtual->svt_set = (SwigMagicFunc) set; + mg->mg_virtual->svt_len = 0; + mg->mg_virtual->svt_clear = 0; + mg->mg_virtual->svt_free = 0; +} + + +SWIGRUNTIME swig_module_info * +SWIG_Perl_GetModule(void) { + static void *type_pointer = (void *)0; + SV *pointer; + + /* first check if pointer already created */ + if (!type_pointer) { + pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, FALSE); + if (pointer && SvOK(pointer)) { + type_pointer = INT2PTR(swig_type_info **, SvIV(pointer)); + } + } + + return (swig_module_info *) type_pointer; +} + +SWIGRUNTIME void +SWIG_Perl_SetModule(swig_module_info *module) { + SV *pointer; + + /* create a new pointer */ + pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TRUE); + sv_setiv(pointer, PTR2IV(module)); +} + +#ifdef __cplusplus +} +#endif diff --git a/devtools/swigwin-1.3.34/Lib/perl5/perlruntime.swg b/devtools/swigwin-1.3.34/Lib/perl5/perlruntime.swg new file mode 100644 index 0000000..f948023 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/perlruntime.swg @@ -0,0 +1,8 @@ + +%runtime "swigrun.swg" // Common C API type-checking code +%runtime "swigerrors.swg" // SWIG errors +%runtime "perlhead.swg" // Perl includes and fixes +%runtime "perlerrors.swg" // Perl errors +%runtime "perlrun.swg" // Perl runtime functions +%runtime "noembed.h" // undefine Perl5 macros + diff --git a/devtools/swigwin-1.3.34/Lib/perl5/perlstrings.swg b/devtools/swigwin-1.3.34/Lib/perl5/perlstrings.swg new file mode 100644 index 0000000..2083f0b --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/perlstrings.swg @@ -0,0 +1,54 @@ +/* ------------------------------------------------------------ + * utility methods for char strings + * ------------------------------------------------------------ */ + +%fragment("SWIG_AsCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { +SWIGINTERN int +SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc) +{ + if (SvPOK(obj)) { + STRLEN len = 0; + char *cstr = SvPV(obj, len); + size_t size = len + 1; + if (cptr) { + if (alloc) { + if (*alloc == SWIG_NEWOBJ) { + *cptr = %new_copy_array(cstr, size, char); + } else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } + } + } + if (psize) *psize = size; + return SWIG_OK; + } else { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + char* vptr = 0; + if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = vptr; + if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} +} + +%fragment("SWIG_FromCharPtrAndSize","header") { +SWIGINTERNINLINE SV * +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + SV *obj = sv_newmortal(); + if (carray) { + sv_setpvn(obj, carray, size); + } else { + sv_setsv(obj, &PL_sv_undef); + } + return obj; +} +} + diff --git a/devtools/swigwin-1.3.34/Lib/perl5/perltypemaps.swg b/devtools/swigwin-1.3.34/Lib/perl5/perltypemaps.swg new file mode 100644 index 0000000..0261493 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/perltypemaps.swg @@ -0,0 +1,91 @@ +/* ------------------------------------------------------------ + * Typemap specializations for Perl + * ------------------------------------------------------------ */ + +/* ------------------------------------------------------------ + * Fragment section + * ------------------------------------------------------------ */ + +/* + in Perl we need to pass the CPerlObj value, sometimes, so, we define + the decl/call macros as needed. +*/ + +#define SWIG_AS_DECL_ARGS SWIG_PERL_DECL_ARGS_2 +#define SWIG_AS_CALL_ARGS SWIG_PERL_CALL_ARGS_2 + +#define SWIG_FROM_DECL_ARGS SWIG_PERL_DECL_ARGS_1 +#define SWIG_FROM_CALL_ARGS SWIG_PERL_CALL_ARGS_1 + + +/* Include fundamental fragemt definitions */ +%include <typemaps/fragments.swg> + +/* Look for user fragments file. */ +%include <perlfragments.swg> + +/* Perl fragments for primitive types */ +%include <perlprimtypes.swg> + +/* Perl fragments for char* strings */ +%include <perlstrings.swg> + + +/* ------------------------------------------------------------ + * Unified typemap section + * ------------------------------------------------------------ */ + +/* No director supported in Perl */ +#ifdef SWIG_DIRECTOR_TYPEMAPS +#undef SWIG_DIRECTOR_TYPEMAPS +#endif + + +/* Perl types */ +#define SWIG_Object SV * + +/* Perl $shadow flag */ +#define %newpointer_flags $shadow +#define %newinstance_flags $shadow + + +/* Complete overload of the output/constant/exception macros */ + +/* output */ +%define %set_output(obj) $result = obj; argvi++ %enddef + +/* append output */ +%define %append_output(obj) if (argvi >= items) EXTEND(sp,1); %set_output(obj) %enddef + +/* variable output */ +%define %set_varoutput(obj) sv_setsv($result,obj) %enddef + +/* constant */ +%define %set_constant(name, obj) %begin_block + SV *sv = get_sv((char*) SWIG_prefix name, TRUE | 0x2); + sv_setsv(sv, obj); + SvREADONLY_on(sv); +%end_block %enddef + +/* raise exception */ +%define %raise(obj, type, desc) sv_setsv(GvSV(PL_errgv), obj); SWIG_fail %enddef + +/* Include the unified typemap library */ +%include <typemaps/swigtypemaps.swg> + +/* ------------------------------------------------------------ + * Perl extra typemaps + * ------------------------------------------------------------ */ + +%typemap(varout,type="$1_descriptor") SWIGTYPE *, SWIGTYPE [] + "sv_setiv(SvRV($result),PTR2IV($1));"; + +%typemap(varout,type="$1_descriptor") SWIGTYPE & + "sv_setiv(SvRV($result),PTR2IV(&$1));"; + +%typemap(varout,type="$&1_descriptor") SWIGTYPE + "sv_setiv(SvRV($result), PTR2IV(&$1));"; + +%typemap(varout,type="$1_descriptor") SWIGTYPE (CLASS::*) { + SWIG_MakePackedObj($result, (void *) &$1, sizeof($1_type), $1_descriptor); +} diff --git a/devtools/swigwin-1.3.34/Lib/perl5/perluserdir.swg b/devtools/swigwin-1.3.34/Lib/perl5/perluserdir.swg new file mode 100644 index 0000000..718440e --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/perluserdir.swg @@ -0,0 +1,2 @@ +#define %perlcode %insert("perl") + diff --git a/devtools/swigwin-1.3.34/Lib/perl5/reference.i b/devtools/swigwin-1.3.34/Lib/perl5/reference.i new file mode 100644 index 0000000..d3d745c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/reference.i @@ -0,0 +1,235 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * reference.i + * + * Accept Perl references as pointers + * ----------------------------------------------------------------------------- */ + +/* +The following methods make Perl references work like simple C +pointers. References can only be used for simple input/output +values, not C arrays however. It should also be noted that +REFERENCES are specific to Perl and not supported in other +scripting languages at this time. + + int *REFERENCE + short *REFERENCE + long *REFERENCE + unsigned int *REFERENCE + unsigned short *REFERENCE + unsigned long *REFERENCE + unsigned char *REFERENCE + float *REFERENCE + double *REFERENCE + +For example, suppose you were trying to wrap the following function : + + void neg(double *x) { + *x = -(*x); + } + +You could wrap it with SWIG as follows : + + %include reference.i + void neg(double *REFERENCE); + +or you can use the %apply directive : + + %include reference.i + %apply double *REFERENCE { double *x }; + void neg(double *x); + +Unlike the INOUT mapping described in typemaps.i, this approach directly +modifies the value of a Perl reference. Thus, you could use it +as follows : + + $x = 3; + neg(\$x); + print "$x\n"; # Should print out -3. + +*/ + +%typemap(in) double *REFERENCE (double dvalue), double &REFERENCE(double dvalue) +{ + SV *tempsv; + if (!SvROK($input)) { + SWIG_croak("expected a reference"); + } + tempsv = SvRV($input); + if ((!SvNOK(tempsv)) && (!SvIOK(tempsv))) { + printf("Received %d\n", SvTYPE(tempsv)); + SWIG_croak("Expected a double reference."); + } + dvalue = SvNV(tempsv); + $1 = &dvalue; +} + +%typemap(in) float *REFERENCE (float dvalue), float &REFERENCE(float dvalue) +{ + SV *tempsv; + if (!SvROK($input)) { + SWIG_croak("expected a reference"); + } + tempsv = SvRV($input); + if ((!SvNOK(tempsv)) && (!SvIOK(tempsv))) { + SWIG_croak("expected a double reference"); + } + dvalue = (float) SvNV(tempsv); + $1 = &dvalue; +} + +%typemap(in) int *REFERENCE (int dvalue), int &REFERENCE (int dvalue) +{ + SV *tempsv; + if (!SvROK($input)) { + SWIG_croak("expected a reference"); + } + tempsv = SvRV($input); + if (!SvIOK(tempsv)) { + SWIG_croak("expected a integer reference"); + } + dvalue = SvIV(tempsv); + $1 = &dvalue; +} + +%typemap(in) short *REFERENCE (short dvalue), short &REFERENCE(short dvalue) +{ + SV *tempsv; + if (!SvROK($input)) { + SWIG_croak("expected a reference"); + } + tempsv = SvRV($input); + if (!SvIOK(tempsv)) { + SWIG_croak("expected a integer reference"); + } + dvalue = (short) SvIV(tempsv); + $1 = &dvalue; +} +%typemap(in) long *REFERENCE (long dvalue), long &REFERENCE(long dvalue) +{ + SV *tempsv; + if (!SvROK($input)) { + SWIG_croak("expected a reference"); + } + tempsv = SvRV($input); + if (!SvIOK(tempsv)) { + SWIG_croak("expected a integer reference"); + } + dvalue = (long) SvIV(tempsv); + $1 = &dvalue; +} +%typemap(in) unsigned int *REFERENCE (unsigned int dvalue), unsigned int &REFERENCE(unsigned int dvalue) +{ + SV *tempsv; + if (!SvROK($input)) { + SWIG_croak("expected a reference"); + } + tempsv = SvRV($input); + if (!SvIOK(tempsv)) { + SWIG_croak("expected a integer reference"); + } + dvalue = (unsigned int) SvUV(tempsv); + $1 = &dvalue; +} +%typemap(in) unsigned short *REFERENCE (unsigned short dvalue), unsigned short &REFERENCE(unsigned short dvalue) +{ + SV *tempsv; + if (!SvROK($input)) { + SWIG_croak("expected a reference"); + } + tempsv = SvRV($input); + if (!SvIOK(tempsv)) { + SWIG_croak("expected a integer reference"); + } + dvalue = (unsigned short) SvUV(tempsv); + $1 = &dvalue; +} +%typemap(in) unsigned long *REFERENCE (unsigned long dvalue), unsigned long &REFERENCE(unsigned long dvalue) +{ + SV *tempsv; + if (!SvROK($input)) { + SWIG_croak("expected a reference"); + } + tempsv = SvRV($input); + if (!SvIOK(tempsv)) { + SWIG_croak("expected a integer reference"); + } + dvalue = (unsigned long) SvUV(tempsv); + $1 = &dvalue; +} + +%typemap(in) unsigned char *REFERENCE (unsigned char dvalue), unsigned char &REFERENCE(unsigned char dvalue) +{ + SV *tempsv; + if (!SvROK($input)) { + SWIG_croak("expected a reference"); + } + tempsv = SvRV($input); + if (!SvIOK(tempsv)) { + SWIG_croak("expected a integer reference"); + } + dvalue = (unsigned char) SvUV(tempsv); + $1 = &dvalue; +} + +%typemap(in) signed char *REFERENCE (signed char dvalue), signed char &REFERENCE(signed char dvalue) +{ + SV *tempsv; + if (!SvROK($input)) { + SWIG_croak("expected a reference"); + } + tempsv = SvRV($input); + if (!SvIOK(tempsv)) { + SWIG_croak("expected a integer reference"); + } + dvalue = (signed char) SvIV(tempsv); + $1 = &dvalue; +} + +%typemap(in) bool *REFERENCE (bool dvalue), bool &REFERENCE(bool dvalue) +{ + SV *tempsv; + if (!SvROK($input)) { + SWIG_croak("expected a reference"); + } + tempsv = SvRV($input); + if (!SvIOK(tempsv)) { + SWIG_croak("expected a integer reference"); + } + dvalue = (bool) SvIV(tempsv); + $1 = &dvalue; +} + +%typemap(argout) double *REFERENCE, double &REFERENCE, + float *REFERENCE, float &REFERENCE +{ + SV *tempsv; + tempsv = SvRV($arg); + if (!$1) SWIG_croak("expected a reference"); + sv_setnv(tempsv, (double) *$1); +} + +%typemap(argout) int *REFERENCE, int &REFERENCE, + short *REFERENCE, short &REFERENCE, + long *REFERENCE, long &REFERENCE, + signed char *REFERENCE, unsigned char &REFERENCE, + bool *REFERENCE, bool &REFERENCE +{ + SV *tempsv; + tempsv = SvRV($input); + if (!$1) SWIG_croak("expected a reference"); + sv_setiv(tempsv, (IV) *$1); +} + +%typemap(argout) unsigned int *REFERENCE, unsigned int &REFERENCE, + unsigned short *REFERENCE, unsigned short &REFERENCE, + unsigned long *REFERENCE, unsigned long &REFERENCE, + unsigned char *REFERENCE, unsigned char &REFERENCE +{ + SV *tempsv; + tempsv = SvRV($input); + if (!$1) SWIG_croak("expected a reference"); + sv_setuv(tempsv, (UV) *$1); +} diff --git a/devtools/swigwin-1.3.34/Lib/perl5/std_common.i b/devtools/swigwin-1.3.34/Lib/perl5/std_common.i new file mode 100644 index 0000000..bc25b35 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/std_common.i @@ -0,0 +1,29 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_common.i + * + * SWIG typemaps for STL - common utilities + * ----------------------------------------------------------------------------- */ + +%include <std/std_except.i> + +%apply size_t { std::size_t }; + +%{ +#include <string> + +double SwigSvToNumber(SV* sv) { + return SvIOK(sv) ? double(SvIVX(sv)) : SvNVX(sv); +} +std::string SwigSvToString(SV* sv) { + STRLEN len; + char *ptr = SvPV(sv, len); + return std::string(ptr, len); +} +void SwigSvFromString(SV* sv, const std::string& s) { + sv_setpvn(sv,s.data(),s.size()); +} +%} + diff --git a/devtools/swigwin-1.3.34/Lib/perl5/std_deque.i b/devtools/swigwin-1.3.34/Lib/perl5/std_deque.i new file mode 100644 index 0000000..cb98f6c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/std_deque.i @@ -0,0 +1 @@ +%include <std/_std_deque.i> diff --git a/devtools/swigwin-1.3.34/Lib/perl5/std_except.i b/devtools/swigwin-1.3.34/Lib/perl5/std_except.i new file mode 100644 index 0000000..af98428 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/std_except.i @@ -0,0 +1 @@ +%include <typemaps/std_except.swg> diff --git a/devtools/swigwin-1.3.34/Lib/perl5/std_list.i b/devtools/swigwin-1.3.34/Lib/perl5/std_list.i new file mode 100644 index 0000000..633e40d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/std_list.i @@ -0,0 +1,368 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_list.i + * + * SWIG typemaps for std::list types + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <exception.i> + +// containers + + +// ------------------------------------------------------------------------ +// std::list +// +// The aim of all that follows would be to integrate std::list with +// Perl as much as possible, namely, to allow the user to pass and +// be returned Perl arrays. +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::list<T>), f(const std::list<T>&), f(const std::list<T>*): +// the parameter being read-only, either a Perl sequence or a +// previously wrapped std::list<T> can be passed. +// -- f(std::list<T>&), f(std::list<T>*): +// the parameter must be modified; therefore, only a wrapped std::list +// can be passed. +// -- std::list<T> f(): +// the list is returned by copy; therefore, a Perl sequence of T:s +// is returned which is most easily used in other Perl functions +// -- std::list<T>& f(), std::list<T>* f(), const std::list<T>& f(), +// const std::list<T>* f(): +// the list is returned by reference; therefore, a wrapped std::list +// is returned +// ------------------------------------------------------------------------ + +%{ +#include <list> +#include <algorithm> +#include <stdexcept> +%} + +// exported class + +namespace std { + + template<class T> class list { + %typemap(in) list<T> (std::list<T>* v) { + if (SWIG_ConvertPtr($input,(void **) &v, + $&1_descriptor,1) != -1) { + $1 = *v; + } else if (SvROK($input)) { + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) != SVt_PVAV) + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + SV **tv; + I32 len = av_len(av) + 1; + T* obj; + for (int i=0; i<len; i++) { + tv = av_fetch(av, i, 0); + if (SWIG_ConvertPtr(*tv, (void **)&obj, + $descriptor(T *),0) != -1) { + $1.push_back(*obj); + } else { + SWIG_croak("Type error in argument $argnum of " + "$symname. " + "Expected an array of " #T); + } + } + } else { + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + } + } + %typemap(in) const list<T>& (std::list<T> temp, + std::list<T>* v), + const list<T>* (std::list<T> temp, + std::list<T>* v) { + if (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor,1) != -1) { + $1 = v; + } else if (SvROK($input)) { + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) != SVt_PVAV) + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + SV **tv; + I32 len = av_len(av) + 1; + T* obj; + for (int i=0; i<len; i++) { + tv = av_fetch(av, i, 0); + if (SWIG_ConvertPtr(*tv, (void **)&obj, + $descriptor(T *),0) != -1) { + temp.push_back(*obj); + } else { + SWIG_croak("Type error in argument $argnum of " + "$symname. " + "Expected an array of " #T); + } + } + $1 = &temp; + } else { + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + } + } + %typemap(out) list<T> { + std::list<T>::const_iterator i; + unsigned int j; + int len = $1.size(); + SV **svs = new SV*[len]; + for (i=$1.begin(), j=0; i!=$1.end(); i++, j++) { + T* ptr = new T(*i); + svs[j] = sv_newmortal(); + SWIG_MakePtr(svs[j], (void*) ptr, + $descriptor(T *), $shadow|$owner); + } + AV *myav = av_make(len, svs); + delete[] svs; + $result = newRV_noinc((SV*) myav); + sv_2mortal($result); + argvi++; + } + %typecheck(SWIG_TYPECHECK_LIST) list<T> { + { + /* wrapped list? */ + std::list<T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $1_&descriptor,0) != -1) { + $1 = 1; + } else if (SvROK($input)) { + /* native sequence? */ + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) == SVt_PVAV) { + SV **tv; + I32 len = av_len(av) + 1; + if (len == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + T* obj; + tv = av_fetch(av, 0, 0); + if (SWIG_ConvertPtr(*tv, (void **)&obj, + $descriptor(T *),0) != -1) + $1 = 1; + else + $1 = 0; + } + } + } else { + $1 = 0; + } + } + } + %typecheck(SWIG_TYPECHECK_LIST) const list<T>&, + const list<T>* { + { + /* wrapped list? */ + std::list<T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor,0) != -1) { + $1 = 1; + } else if (SvROK($input)) { + /* native sequence? */ + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) == SVt_PVAV) { + SV **tv; + I32 len = av_len(av) + 1; + if (len == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + T* obj; + tv = av_fetch(av, 0, 0); + if (SWIG_ConvertPtr(*tv, (void **)&obj, + $descriptor(T *),0) != -1) + $1 = 1; + else + $1 = 0; + } + } + } else { + $1 = 0; + } + } + } + public: + list(); + list(const list<T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %rename(push) push_back; + void push_back(const T& x); + }; + + + // specializations for built-ins + + %define specialize_std_list(T,CHECK_T,TO_T,FROM_T) + template<> class list<T> { + %typemap(in) list<T> (std::list<T>* v) { + if (SWIG_ConvertPtr($input,(void **) &v, + $&1_descriptor,1) != -1){ + $1 = *v; + } else if (SvROK($input)) { + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) != SVt_PVAV) + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + SV **tv; + I32 len = av_len(av) + 1; + for (int i=0; i<len; i++) { + tv = av_fetch(av, i, 0); + if (CHECK_T(*tv)) { + $1.push_back(TO_T(*tv)); + } else { + SWIG_croak("Type error in argument $argnum of " + "$symname. " + "Expected an array of " #T); + } + } + } else { + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + } + } + %typemap(in) const list<T>& (std::list<T> temp, + std::list<T>* v), + const list<T>* (std::list<T> temp, + std::list<T>* v) { + if (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor,1) != -1) { + $1 = v; + } else if (SvROK($input)) { + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) != SVt_PVAV) + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + SV **tv; + I32 len = av_len(av) + 1; + T* obj; + for (int i=0; i<len; i++) { + tv = av_fetch(av, i, 0); + if (CHECK_T(*tv)) { + temp.push_back(TO_T(*tv)); + } else { + SWIG_croak("Type error in argument $argnum of " + "$symname. " + "Expected an array of " #T); + } + } + $1 = &temp; + } else { + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + } + } + %typemap(out) list<T> { + std::list<T>::const_iterator i; + unsigned int j; + int len = $1.size(); + SV **svs = new SV*[len]; + for (i=$1.begin(), j=0; i!=$1.end(); i++, j++) { + svs[j] = sv_newmortal(); + FROM_T(svs[j], *i); + } + AV *myav = av_make(len, svs); + delete[] svs; + $result = newRV_noinc((SV*) myav); + sv_2mortal($result); + argvi++; + } + %typecheck(SWIG_TYPECHECK_LIST) list<T> { + { + /* wrapped list? */ + std::list<T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $1_&descriptor,0) != -1) { + $1 = 1; + } else if (SvROK($input)) { + /* native sequence? */ + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) == SVt_PVAV) { + SV **tv; + I32 len = av_len(av) + 1; + if (len == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + tv = av_fetch(av, 0, 0); + if (CHECK_T(*tv)) + $1 = 1; + else + $1 = 0; + } + } + } else { + $1 = 0; + } + } + } + %typecheck(SWIG_TYPECHECK_LIST) const list<T>&, + const list<T>* { + { + /* wrapped list? */ + std::list<T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor,0) != -1) { + $1 = 1; + } else if (SvROK($input)) { + /* native sequence? */ + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) == SVt_PVAV) { + SV **tv; + I32 len = av_len(av) + 1; + if (len == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + tv = av_fetch(av, 0, 0); + if (CHECK_T(*tv)) + $1 = 1; + else + $1 = 0; + } + } + } else { + $1 = 0; + } + } + } + public: + list(); + list(const list<T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %rename(push) push_back; + void push_back(T x); + }; + %enddef + + specialize_std_list(bool,SvIOK,SvIVX,sv_setiv); + specialize_std_list(char,SvIOK,SvIVX,sv_setiv); + specialize_std_list(int,SvIOK,SvIVX,sv_setiv); + specialize_std_list(short,SvIOK,SvIVX,sv_setiv); + specialize_std_list(long,SvIOK,SvIVX,sv_setiv); + specialize_std_list(unsigned char,SvIOK,SvIVX,sv_setiv); + specialize_std_list(unsigned int,SvIOK,SvIVX,sv_setiv); + specialize_std_list(unsigned short,SvIOK,SvIVX,sv_setiv); + specialize_std_list(unsigned long,SvIOK,SvIVX,sv_setiv); + specialize_std_list(float,SvNIOK,SwigSvToNumber,sv_setnv); + specialize_std_list(double,SvNIOK,SwigSvToNumber,sv_setnv); + specialize_std_list(std::string,SvPOK,SvPVX,SwigSvFromString); + +} + diff --git a/devtools/swigwin-1.3.34/Lib/perl5/std_map.i b/devtools/swigwin-1.3.34/Lib/perl5/std_map.i new file mode 100644 index 0000000..c35f21d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/std_map.i @@ -0,0 +1,175 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_map.i + * + * SWIG typemaps for std::map + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +// ------------------------------------------------------------------------ +// std::map +// ------------------------------------------------------------------------ + +%{ +#include <map> +#include <algorithm> +#include <stdexcept> +%} + +// exported class + +namespace std { + + template<class K, class T> class map { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T& get(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(const K& key, const T& x) { + (*self)[key] = x; + } + void del(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + + + // specializations for built-ins + + %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) + + template<class T> class map<K,T> { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T& get(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(K key, const T& x) { + (*self)[key] = x; + } + void del(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(K key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + %enddef + + %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) + template<class K> class map<K,T> { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T get(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(const K& key, T x) { + (*self)[key] = x; + } + void del(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + %enddef + + %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, + T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) + template<> class map<K,T> { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T get(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(K key, T x) { + (*self)[key] = x; + } + void del(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(K key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + %enddef + + // add specializations here + +} diff --git a/devtools/swigwin-1.3.34/Lib/perl5/std_pair.i b/devtools/swigwin-1.3.34/Lib/perl5/std_pair.i new file mode 100644 index 0000000..78142ff --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/std_pair.i @@ -0,0 +1,37 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_pair.i + * + * SWIG typemaps for std::pair + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <exception.i> + +// ------------------------------------------------------------------------ +// std::pair +// ------------------------------------------------------------------------ + +%{ +#include <utility> +%} + +namespace std { + + template<class T, class U> struct pair { + + pair(); + pair(T t, U u); + pair(const pair& p); + + template <class U1, class U2> pair(const pair<U1, U2> &p); + + T first; + U second; + }; + + // add specializations here + +} diff --git a/devtools/swigwin-1.3.34/Lib/perl5/std_string.i b/devtools/swigwin-1.3.34/Lib/perl5/std_string.i new file mode 100644 index 0000000..6f34f18 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/std_string.i @@ -0,0 +1,2 @@ +%include <perlstrings.swg> +%include <typemaps/std_string.swg> diff --git a/devtools/swigwin-1.3.34/Lib/perl5/std_vector.i b/devtools/swigwin-1.3.34/Lib/perl5/std_vector.i new file mode 100644 index 0000000..b1f722d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/std_vector.i @@ -0,0 +1,571 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_vector.i + * + * SWIG typemaps for std::vector types + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +// ------------------------------------------------------------------------ +// std::vector +// +// The aim of all that follows would be to integrate std::vector with +// Perl as much as possible, namely, to allow the user to pass and +// be returned Perl arrays. +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::vector<T>), f(const std::vector<T>&), f(const std::vector<T>*): +// the parameter being read-only, either a Perl sequence or a +// previously wrapped std::vector<T> can be passed. +// -- f(std::vector<T>&), f(std::vector<T>*): +// the parameter must be modified; therefore, only a wrapped std::vector +// can be passed. +// -- std::vector<T> f(): +// the vector is returned by copy; therefore, a Perl sequence of T:s +// is returned which is most easily used in other Perl functions +// -- std::vector<T>& f(), std::vector<T>* f(), const std::vector<T>& f(), +// const std::vector<T>* f(): +// the vector is returned by reference; therefore, a wrapped std::vector +// is returned +// ------------------------------------------------------------------------ + +%{ +#include <vector> +#include <algorithm> +#include <stdexcept> +%} + +// exported class + +namespace std { + + template<class T> class vector { + %typemap(in) vector<T> (std::vector<T>* v) { + if (SWIG_ConvertPtr($input,(void **) &v, + $&1_descriptor,1) != -1) { + $1 = *v; + } else if (SvROK($input)) { + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) != SVt_PVAV) + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + SV **tv; + I32 len = av_len(av) + 1; + T* obj; + for (int i=0; i<len; i++) { + tv = av_fetch(av, i, 0); + if (SWIG_ConvertPtr(*tv, (void **)&obj, + $descriptor(T *),0) != -1) { + $1.push_back(*obj); + } else { + SWIG_croak("Type error in argument $argnum of " + "$symname. " + "Expected an array of " #T); + } + } + } else { + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + } + } + %typemap(in) const vector<T>& (std::vector<T> temp, + std::vector<T>* v), + const vector<T>* (std::vector<T> temp, + std::vector<T>* v) { + if (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor,1) != -1) { + $1 = v; + } else if (SvROK($input)) { + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) != SVt_PVAV) + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + SV **tv; + I32 len = av_len(av) + 1; + T* obj; + for (int i=0; i<len; i++) { + tv = av_fetch(av, i, 0); + if (SWIG_ConvertPtr(*tv, (void **)&obj, + $descriptor(T *),0) != -1) { + temp.push_back(*obj); + } else { + SWIG_croak("Type error in argument $argnum of " + "$symname. " + "Expected an array of " #T); + } + } + $1 = &temp; + } else { + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + } + } + %typemap(out) vector<T> { + int len = $1.size(); + SV **svs = new SV*[len]; + for (unsigned int i=0; i<len; i++) { + T* ptr = new T($1[i]); + svs[i] = sv_newmortal(); + SWIG_MakePtr(svs[i], (void*) ptr, + $descriptor(T *), $shadow|$owner); + } + AV *myav = av_make(len, svs); + delete[] svs; + $result = newRV_noinc((SV*) myav); + sv_2mortal($result); + argvi++; + } + %typecheck(SWIG_TYPECHECK_VECTOR) vector<T> { + { + /* wrapped vector? */ + std::vector<T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $&1_descriptor,0) != -1) { + $1 = 1; + } else if (SvROK($input)) { + /* native sequence? */ + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) == SVt_PVAV) { + I32 len = av_len(av) + 1; + if (len == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + T* obj; + SV **tv = av_fetch(av, 0, 0); + if (SWIG_ConvertPtr(*tv, (void **)&obj, + $descriptor(T *),0) != -1) + $1 = 1; + else + $1 = 0; + } + } + } else { + $1 = 0; + } + } + } + %typecheck(SWIG_TYPECHECK_VECTOR) const vector<T>&, + const vector<T>* { + { + /* wrapped vector? */ + std::vector<T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor,0) != -1) { + $1 = 1; + } else if (SvROK($input)) { + /* native sequence? */ + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) == SVt_PVAV) { + I32 len = av_len(av) + 1; + if (len == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + T* obj; + SV **tv = av_fetch(av, 0, 0); + if (SWIG_ConvertPtr(*tv, (void **)&obj, + $descriptor(T *),0) != -1) + $1 = 1; + else + $1 = 0; + } + } + } else { + $1 = 0; + } + } + } + public: + vector(unsigned int size = 0); + vector(unsigned int size, const T& value); + vector(const vector<T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %rename(push) push_back; + void push_back(const T& x); + %extend { + T pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty vector"); + T x = self->back(); + self->pop_back(); + return x; + } + T& get(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("vector index out of range"); + } + void set(int i, const T& x) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + (*self)[i] = x; + else + throw std::out_of_range("vector index out of range"); + } + } + }; + + // specializations for pointers + template<class T> class vector<T*> { + %typemap(in) vector<T*> (std::vector<T*>* v) { + int res = SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor,0); + if (SWIG_IsOK(res)){ + $1 = *v; + } else if (SvROK($input)) { + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) != SVt_PVAV) + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + I32 len = av_len(av) + 1; + for (int i=0; i<len; i++) { + void *v; + SV **tv = av_fetch(av, i, 0); + int res = SWIG_ConvertPtr(*tv, &v, $descriptor(T *),0); + if (SWIG_IsOK(res)) { + $1.push_back(%static_cast(v, T *)); + } else { + SWIG_croak("Type error in argument $argnum of " + "$symname. " + "Expected an array of " #T); + } + } + } else { + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + } + } + %typemap(in) const vector<T *>& (std::vector<T *> temp,std::vector<T *>* v), + const vector<T *>* (std::vector<T *> temp,std::vector<T *>* v) { + int res = SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,0); + if (SWIG_IsOK(res)) { + $1 = v; + } else if (SvROK($input)) { + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) != SVt_PVAV) + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + I32 len = av_len(av) + 1; + for (int i=0; i<len; i++) { + void *v; + SV **tv = av_fetch(av, i, 0); + int res = SWIG_ConvertPtr(*tv, &v, $descriptor(T *),0); + if (SWIG_IsOK(res)) { + temp.push_back(%static_cast(v, T *)); + } else { + SWIG_croak("Type error in argument $argnum of " + "$symname. " + "Expected an array of " #T); + } + } + $1 = &temp; + } else { + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + } + } + %typemap(out) vector<T *> { + size_t len = $1.size(); + SV **svs = new SV*[len]; + for (size_t i=0; i<len; i++) { + T *x = (($1_type &)$1)[i]; + svs[i] = sv_newmortal(); + sv_setsv(svs[i], SWIG_NewPointerObj(x, $descriptor(T *), 0)); + } + AV *myav = av_make(len, svs); + delete[] svs; + $result = newRV_noinc((SV*) myav); + sv_2mortal($result); + argvi++; + } + %typecheck(SWIG_TYPECHECK_VECTOR) vector<T *> { + { + /* wrapped vector? */ + std::vector<T *>* v; + int res = SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor,0); + if (SWIG_IsOK(res)) { + $1 = 1; + } else if (SvROK($input)) { + /* native sequence? */ + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) == SVt_PVAV) { + I32 len = av_len(av) + 1; + if (len == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + void *v; + SV **tv = av_fetch(av, 0, 0); + int res = SWIG_ConvertPtr(*tv, &v, $descriptor(T *),0); + if (SWIG_IsOK(res)) + $1 = 1; + else + $1 = 0; + } + } + } else { + $1 = 0; + } + } + } + %typecheck(SWIG_TYPECHECK_VECTOR) const vector<T *>&,const vector<T *>* { + { + /* wrapped vector? */ + std::vector<T *> *v; + int res = SWIG_ConvertPtr($input,%as_voidptrptr(&v), $1_descriptor,0); + if (SWIG_IsOK(res)) { + $1 = 1; + } else if (SvROK($input)) { + /* native sequence? */ + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) == SVt_PVAV) { + I32 len = av_len(av) + 1; + if (len == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + void *v; + SV **tv = av_fetch(av, 0, 0); + int res = SWIG_ConvertPtr(*tv, &v, $descriptor(T *),0); + if (SWIG_IsOK(res)) + $1 = 1; + else + $1 = 0; + } + } + } else { + $1 = 0; + } + } + } + public: + vector(unsigned int size = 0); + vector(unsigned int size, T *value); + vector(const vector<T *> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %rename(push) push_back; + void push_back(T *x); + %extend { + T *pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty vector"); + T *x = self->back(); + self->pop_back(); + return x; + } + T *get(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("vector index out of range"); + } + void set(int i, T *x) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + (*self)[i] = x; + else + throw std::out_of_range("vector index out of range"); + } + } + }; + + + // specializations for built-ins + + %define specialize_std_vector(T,CHECK_T,TO_T,FROM_T) + template<> class vector<T> { + %typemap(in) vector<T> (std::vector<T>* v) { + if (SWIG_ConvertPtr($input,(void **) &v, + $&1_descriptor,1) != -1){ + $1 = *v; + } else if (SvROK($input)) { + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) != SVt_PVAV) + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + SV **tv; + I32 len = av_len(av) + 1; + for (int i=0; i<len; i++) { + tv = av_fetch(av, i, 0); + if (CHECK_T(*tv)) { + $1.push_back((T)TO_T(*tv)); + } else { + SWIG_croak("Type error in argument $argnum of " + "$symname. " + "Expected an array of " #T); + } + } + } else { + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + } + } + %typemap(in) const vector<T>& (std::vector<T> temp, + std::vector<T>* v), + const vector<T>* (std::vector<T> temp, + std::vector<T>* v) { + if (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor,1) != -1) { + $1 = v; + } else if (SvROK($input)) { + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) != SVt_PVAV) + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + SV **tv; + I32 len = av_len(av) + 1; + for (int i=0; i<len; i++) { + tv = av_fetch(av, i, 0); + if (CHECK_T(*tv)) { + temp.push_back((T)TO_T(*tv)); + } else { + SWIG_croak("Type error in argument $argnum of " + "$symname. " + "Expected an array of " #T); + } + } + $1 = &temp; + } else { + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + } + } + %typemap(out) vector<T> { + size_t len = $1.size(); + SV **svs = new SV*[len]; + for (size_t i=0; i<len; i++) { + svs[i] = sv_newmortal(); + FROM_T(svs[i], $1[i]); + } + AV *myav = av_make(len, svs); + delete[] svs; + $result = newRV_noinc((SV*) myav); + sv_2mortal($result); + argvi++; + } + %typecheck(SWIG_TYPECHECK_VECTOR) vector<T> { + { + /* wrapped vector? */ + std::vector<T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $&1_descriptor,0) != -1) { + $1 = 1; + } else if (SvROK($input)) { + /* native sequence? */ + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) == SVt_PVAV) { + I32 len = av_len(av) + 1; + if (len == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + SV **tv = av_fetch(av, 0, 0); + if (CHECK_T(*tv)) + $1 = 1; + else + $1 = 0; + } + } + } else { + $1 = 0; + } + } + } + %typecheck(SWIG_TYPECHECK_VECTOR) const vector<T>&, + const vector<T>* { + { + /* wrapped vector? */ + std::vector<T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor,0) != -1) { + $1 = 1; + } else if (SvROK($input)) { + /* native sequence? */ + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) == SVt_PVAV) { + I32 len = av_len(av) + 1; + if (len == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + SV **tv = av_fetch(av, 0, 0); + if (CHECK_T(*tv)) + $1 = 1; + else + $1 = 0; + } + } + } else { + $1 = 0; + } + } + } + public: + vector(unsigned int size = 0); + vector(unsigned int size, T value); + vector(const vector<T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %rename(push) push_back; + void push_back(T x); + %extend { + T pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty vector"); + T x = self->back(); + self->pop_back(); + return x; + } + T get(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("vector index out of range"); + } + void set(int i, T x) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + (*self)[i] = x; + else + throw std::out_of_range("vector index out of range"); + } + } + }; + %enddef + + specialize_std_vector(bool,SvIOK,SvIVX,sv_setiv); + specialize_std_vector(char,SvIOK,SvIVX,sv_setiv); + specialize_std_vector(int,SvIOK,SvIVX,sv_setiv); + specialize_std_vector(short,SvIOK,SvIVX,sv_setiv); + specialize_std_vector(long,SvIOK,SvIVX,sv_setiv); + specialize_std_vector(unsigned char,SvIOK,SvIVX,sv_setiv); + specialize_std_vector(unsigned int,SvIOK,SvIVX,sv_setiv); + specialize_std_vector(unsigned short,SvIOK,SvIVX,sv_setiv); + specialize_std_vector(unsigned long,SvIOK,SvIVX,sv_setiv); + specialize_std_vector(float,SvNIOK,SwigSvToNumber,sv_setnv); + specialize_std_vector(double,SvNIOK,SwigSvToNumber,sv_setnv); + specialize_std_vector(std::string,SvPOK,SwigSvToString,SwigSvFromString); +} + diff --git a/devtools/swigwin-1.3.34/Lib/perl5/stl.i b/devtools/swigwin-1.3.34/Lib/perl5/stl.i new file mode 100644 index 0000000..946e4b7 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/stl.i @@ -0,0 +1,14 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * stl.i + * + * Initial STL definition. extended as needed in each language + * ----------------------------------------------------------------------------- */ +%include <std_common.i> +%include <std_string.i> +%include <std_vector.i> +%include <std_map.i> +%include <std_pair.i> + diff --git a/devtools/swigwin-1.3.34/Lib/perl5/typemaps.i b/devtools/swigwin-1.3.34/Lib/perl5/typemaps.i new file mode 100644 index 0000000..fc6d8f8 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/perl5/typemaps.i @@ -0,0 +1,374 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * typemaps.i + * + * The SWIG typemap library provides a language independent mechanism for + * supporting output arguments, input values, and other C function + * calling mechanisms. The primary use of the library is to provide a + * better interface to certain C function--especially those involving + * pointers. + * ----------------------------------------------------------------------------- */ + +#if !defined(SWIG_USE_OLD_TYPEMAPS) +%include <typemaps/typemaps.swg> +#else + + +// INPUT typemaps. +// These remap a C pointer to be an "INPUT" value which is passed by value +// instead of reference. + + +/* +The following methods can be applied to turn a pointer into a simple +"input" value. That is, instead of passing a pointer to an object, +you would use a real value instead. + + int *INPUT + short *INPUT + long *INPUT + long long *INPUT + unsigned int *INPUT + unsigned short *INPUT + unsigned long *INPUT + unsigned long long *INPUT + unsigned char *INPUT + bool *INPUT + float *INPUT + double *INPUT + +To use these, suppose you had a C function like this : + + double fadd(double *a, double *b) { + return *a+*b; + } + +You could wrap it with SWIG as follows : + + %include typemaps.i + double fadd(double *INPUT, double *INPUT); + +or you can use the %apply directive : + + %include typemaps.i + %apply double *INPUT { double *a, double *b }; + double fadd(double *a, double *b); + +*/ + +%define INPUT_TYPEMAP(type, converter) +%typemap(in) type *INPUT(type temp), type &INPUT(type temp) { + temp = (type) converter($input); + $1 = &temp; +} +%typemap(typecheck) type *INPUT = type; +%typemap(typecheck) type &INPUT = type; +%enddef + +INPUT_TYPEMAP(float, SvNV); +INPUT_TYPEMAP(double, SvNV); +INPUT_TYPEMAP(int, SvIV); +INPUT_TYPEMAP(long, SvIV); +INPUT_TYPEMAP(short, SvIV); +INPUT_TYPEMAP(signed char, SvIV); +INPUT_TYPEMAP(unsigned int, SvUV); +INPUT_TYPEMAP(unsigned long, SvUV); +INPUT_TYPEMAP(unsigned short, SvUV); +INPUT_TYPEMAP(unsigned char, SvUV); + +%typemap(in) bool *INPUT(bool temp), bool &INPUT(bool temp) { + temp = SvIV($input) ? true : false; + $1 = &temp; +} +%typemap(typecheck) bool *INPUT = bool; +%typemap(typecheck) bool &INPUT = bool; + +%typemap(in) long long *INPUT($*1_ltype temp), long long &INPUT($*1_ltype temp) { + temp = strtoll(SvPV_nolen($input), 0, 0); + $1 = &temp; +} +%typemap(typecheck) long long *INPUT = long long; +%typemap(typecheck) long long &INPUT = long long; + +%typemap(in) unsigned long long *INPUT($*1_ltype temp), unsigned long long &INPUT($*1_ltype temp) { + temp = strtoull(SvPV_nolen($input), 0, 0); + $1 = &temp; +} +%typemap(typecheck) unsigned long long *INPUT = unsigned long long; +%typemap(typecheck) unsigned long long &INPUT = unsigned long long; + + +#undef INPUT_TYPEMAP + +// OUTPUT typemaps. These typemaps are used for parameters that +// are output only. The output value is appended to the result as +// a list element. + +/* +The following methods can be applied to turn a pointer into an "output" +value. When calling a function, no input value would be given for +a parameter, but an output value would be returned. In the case of +multiple output values, functions will return a Perl array. + + int *OUTPUT + short *OUTPUT + long *OUTPUT + long long *OUTPUT + unsigned int *OUTPUT + unsigned short *OUTPUT + unsigned long *OUTPUT + unsigned long long *OUTPUT + unsigned char *OUTPUT + bool *OUTPUT + float *OUTPUT + double *OUTPUT + +For example, suppose you were trying to wrap the modf() function in the +C math library which splits x into integral and fractional parts (and +returns the integer part in one of its parameters).: + + double modf(double x, double *ip); + +You could wrap it with SWIG as follows : + + %include typemaps.i + double modf(double x, double *OUTPUT); + +or you can use the %apply directive : + + %include typemaps.i + %apply double *OUTPUT { double *ip }; + double modf(double x, double *ip); + +The Perl output of the function would be an array containing both +output values. + +*/ + +// Force the argument to be ignored. + +%typemap(in,numinputs=0) int *OUTPUT(int temp), int &OUTPUT(int temp), + short *OUTPUT(short temp), short &OUTPUT(short temp), + long *OUTPUT(long temp), long &OUTPUT(long temp), + unsigned int *OUTPUT(unsigned int temp), unsigned int &OUTPUT(unsigned int temp), + unsigned short *OUTPUT(unsigned short temp), unsigned short &OUTPUT(unsigned short temp), + unsigned long *OUTPUT(unsigned long temp), unsigned long &OUTPUT(unsigned long temp), + unsigned char *OUTPUT(unsigned char temp), unsigned char &OUTPUT(unsigned char temp), + signed char *OUTPUT(signed char temp), signed char &OUTPUT(signed char temp), + bool *OUTPUT(bool temp), bool &OUTPUT(bool temp), + float *OUTPUT(float temp), float &OUTPUT(float temp), + double *OUTPUT(double temp), double &OUTPUT(double temp), + long long *OUTPUT($*1_ltype temp), long long &OUTPUT($*1_ltype temp), + unsigned long long *OUTPUT($*1_ltype temp), unsigned long long &OUTPUT($*1_ltype temp) +"$1 = &temp;"; + +%typemap(argout) int *OUTPUT, int &OUTPUT, + short *OUTPUT, short &OUTPUT, + long *OUTPUT, long &OUTPUT, + signed char *OUTPUT, signed char &OUTPUT, + bool *OUTPUT, bool &OUTPUT +{ + if (argvi >= items) { + EXTEND(sp,1); + } + $result = sv_newmortal(); + sv_setiv($result,(IV) *($1)); + argvi++; +} + +%typemap(argout) unsigned int *OUTPUT, unsigned int &OUTPUT, + unsigned short *OUTPUT, unsigned short &OUTPUT, + unsigned long *OUTPUT, unsigned long &OUTPUT, + unsigned char *OUTPUT, unsigned char &OUTPUT +{ + if (argvi >= items) { + EXTEND(sp,1); + } + $result = sv_newmortal(); + sv_setuv($result,(UV) *($1)); + argvi++; +} + + + +%typemap(argout) float *OUTPUT, float &OUTPUT, + double *OUTPUT, double &OUTPUT +{ + if (argvi >= items) { + EXTEND(sp,1); + } + $result = sv_newmortal(); + sv_setnv($result,(double) *($1)); + argvi++; +} + +%typemap(argout) long long *OUTPUT, long long &OUTPUT { + char temp[256]; + if (argvi >= items) { + EXTEND(sp,1); + } + sprintf(temp,"%lld", (long long)*($1)); + $result = sv_newmortal(); + sv_setpv($result,temp); + argvi++; +} + +%typemap(argout) unsigned long long *OUTPUT, unsigned long long &OUTPUT { + char temp[256]; + if (argvi >= items) { + EXTEND(sp,1); + } + sprintf(temp,"%llu", (unsigned long long)*($1)); + $result = sv_newmortal(); + sv_setpv($result,temp); + argvi++; +} + +// INOUT +// Mappings for an argument that is both an input and output +// parameter + +/* +The following methods can be applied to make a function parameter both +an input and output value. This combines the behavior of both the +"INPUT" and "OUTPUT" methods described earlier. Output values are +returned in the form of a Perl array. + + int *INOUT + short *INOUT + long *INOUT + long long *INOUT + unsigned int *INOUT + unsigned short *INOUT + unsigned long *INOUT + unsigned long long *INOUT + unsigned char *INOUT + bool *INOUT + float *INOUT + double *INOUT + +For example, suppose you were trying to wrap the following function : + + void neg(double *x) { + *x = -(*x); + } + +You could wrap it with SWIG as follows : + + %include typemaps.i + void neg(double *INOUT); + +or you can use the %apply directive : + + %include typemaps.i + %apply double *INOUT { double *x }; + void neg(double *x); + +Unlike C, this mapping does not directly modify the input value. +Rather, the modified input value shows up as the return value of the +function. Thus, to apply this function to a Perl variable you might +do this : + + $x = neg($x); + +*/ + +%typemap(in) int *INOUT = int *INPUT; +%typemap(in) short *INOUT = short *INPUT; +%typemap(in) long *INOUT = long *INPUT; +%typemap(in) unsigned *INOUT = unsigned *INPUT; +%typemap(in) unsigned short *INOUT = unsigned short *INPUT; +%typemap(in) unsigned long *INOUT = unsigned long *INPUT; +%typemap(in) unsigned char *INOUT = unsigned char *INPUT; +%typemap(in) signed char *INOUT = signed char *INPUT; +%typemap(in) bool *INOUT = bool *INPUT; +%typemap(in) float *INOUT = float *INPUT; +%typemap(in) double *INOUT = double *INPUT; +%typemap(in) long long *INOUT = long long *INPUT; +%typemap(in) unsigned long long *INOUT = unsigned long long *INPUT; + +%typemap(in) int &INOUT = int &INPUT; +%typemap(in) short &INOUT = short &INPUT; +%typemap(in) long &INOUT = long &INPUT; +%typemap(in) unsigned &INOUT = unsigned &INPUT; +%typemap(in) unsigned short &INOUT = unsigned short &INPUT; +%typemap(in) unsigned long &INOUT = unsigned long &INPUT; +%typemap(in) unsigned char &INOUT = unsigned char &INPUT; +%typemap(in) signed char &INOUT = signed char &INPUT; +%typemap(in) bool &INOUT = bool &INPUT; +%typemap(in) float &INOUT = float &INPUT; +%typemap(in) double &INOUT = double &INPUT; +%typemap(in) long long &INOUT = long long &INPUT; +%typemap(in) unsigned long long &INOUT = unsigned long long &INPUT; + + +%typemap(argout) int *INOUT = int *OUTPUT; +%typemap(argout) short *INOUT = short *OUTPUT; +%typemap(argout) long *INOUT = long *OUTPUT; +%typemap(argout) unsigned *INOUT = unsigned *OUTPUT; +%typemap(argout) unsigned short *INOUT = unsigned short *OUTPUT; +%typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT; +%typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT; +%typemap(argout) signed char *INOUT = signed char *OUTPUT; +%typemap(argout) bool *INOUT = bool *OUTPUT; +%typemap(argout) float *INOUT = float *OUTPUT; +%typemap(argout) double *INOUT = double *OUTPUT; +%typemap(argout) long long *INOUT = long long *OUTPUT; +%typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT; + + +%typemap(argout) int &INOUT = int &OUTPUT; +%typemap(argout) short &INOUT = short &OUTPUT; +%typemap(argout) long &INOUT = long &OUTPUT; +%typemap(argout) unsigned &INOUT = unsigned &OUTPUT; +%typemap(argout) unsigned short &INOUT = unsigned short &OUTPUT; +%typemap(argout) unsigned long &INOUT = unsigned long &OUTPUT; +%typemap(argout) unsigned char &INOUT = unsigned char &OUTPUT; +%typemap(argout) signed char &INOUT = signed char &OUTPUT; +%typemap(argout) bool &INOUT = bool &OUTPUT; +%typemap(argout) float &INOUT = float &OUTPUT; +%typemap(argout) double &INOUT = double &OUTPUT; +%typemap(argout) long long &INOUT = long long &OUTPUT; +%typemap(argout) unsigned long long &INOUT = unsigned long long &OUTPUT; + + +/* Overloading information */ + +%typemap(typecheck) double *INOUT = double; +%typemap(typecheck) bool *INOUT = bool; +%typemap(typecheck) signed char *INOUT = signed char; +%typemap(typecheck) unsigned char *INOUT = unsigned char; +%typemap(typecheck) unsigned long *INOUT = unsigned long; +%typemap(typecheck) unsigned short *INOUT = unsigned short; +%typemap(typecheck) unsigned int *INOUT = unsigned int; +%typemap(typecheck) long *INOUT = long; +%typemap(typecheck) short *INOUT = short; +%typemap(typecheck) int *INOUT = int; +%typemap(typecheck) float *INOUT = float; +%typemap(typecheck) long long *INOUT = long long; +%typemap(typecheck) unsigned long long *INOUT = unsigned long long; + +%typemap(typecheck) double &INOUT = double; +%typemap(typecheck) bool &INOUT = bool; +%typemap(typecheck) signed char &INOUT = signed char; +%typemap(typecheck) unsigned char &INOUT = unsigned char; +%typemap(typecheck) unsigned long &INOUT = unsigned long; +%typemap(typecheck) unsigned short &INOUT = unsigned short; +%typemap(typecheck) unsigned int &INOUT = unsigned int; +%typemap(typecheck) long &INOUT = long; +%typemap(typecheck) short &INOUT = short; +%typemap(typecheck) int &INOUT = int; +%typemap(typecheck) float &INOUT = float; +%typemap(typecheck) long long &INOUT = long long; +%typemap(typecheck) unsigned long long &INOUT = unsigned long long; + +#endif + +// -------------------------------------------------------------------- +// Special types +// -------------------------------------------------------------------- + + +%include <reference.i> diff --git a/devtools/swigwin-1.3.34/Lib/php4/const.i b/devtools/swigwin-1.3.34/Lib/php4/const.i new file mode 100644 index 0000000..6ddd403 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/php4/const.i @@ -0,0 +1,53 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * const.i + * + * Typemaps for constants + * ----------------------------------------------------------------------------- */ + +%typemap(consttab) int, + unsigned int, + short, + unsigned short, + long, + unsigned long, + unsigned char, + signed char, + bool, + enum SWIGTYPE + "SWIG_LONG_CONSTANT($symname, $value);"; + +%typemap(consttab) float, + double + "SWIG_DOUBLE_CONSTANT($symname, $value);"; + +%typemap(consttab) char + "SWIG_CHAR_CONSTANT($symname, $value);"; + +%typemap(consttab) char *, + const char *, + char [], + const char [] + "SWIG_STRING_CONSTANT($symname, $value);"; + +%typemap(consttab) SWIGTYPE *, + SWIGTYPE &, + SWIGTYPE [] { + /* This actually registers it as a global variable and constant. I don't + * like it, but I can't figure out the zend_constant code... */ + zval *z_var; + MAKE_STD_ZVAL(z_var); + SWIG_SetPointerZval(z_var, (void*)$value, $1_descriptor, 0); + /* zend_hash_add(&EG(symbol_table), "$1", sizeof("$1"), (void *)&z_var,sizeof(zval *), NULL); */ + zend_constant c; + c.value = *z_var; + zval_copy_ctor(&c.value); + size_t len = sizeof("$1") - 1; + c.name = zend_strndup("$1", len); + c.name_len = len+1; + c.flags = CONST_CS | CONST_PERSISTENT; + c.module_number = module_number; + zend_register_constant( &c TSRMLS_CC ); +} diff --git a/devtools/swigwin-1.3.34/Lib/php4/globalvar.i b/devtools/swigwin-1.3.34/Lib/php4/globalvar.i new file mode 100644 index 0000000..3162de2 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/php4/globalvar.i @@ -0,0 +1,332 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * globalvar.i + * + * Global variables - add the variable to PHP + * ----------------------------------------------------------------------------- */ + +%typemap(varinit) char *, + char [] +{ + zval *z_var; + MAKE_STD_ZVAL(z_var); + z_var->type = IS_STRING; + if($1) { + z_var->value.str.val = estrdup($1); + z_var->value.str.len = strlen($1); + } else { + z_var->value.str.val = 0; + z_var->value.str.len = 0; + } + zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, sizeof(zval *), NULL); +} + +%typemap(varinit) int, + unsigned int, + unsigned short, + short, + unsigned short, + long, + unsigned long, + signed char, + unsigned char, + enum SWIGTYPE +{ + zval *z_var; + MAKE_STD_ZVAL(z_var); + z_var->type = IS_LONG; + z_var->value.lval = $1; + zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, sizeof(zval *), NULL); +} + +%typemap(varinit) bool +{ + zval *z_var; + MAKE_STD_ZVAL(z_var); + z_var->type = IS_BOOL; + z_var->value.lval = ($1)?1:0; + zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, sizeof(zval *), NULL); +} + +%typemap(varinit) float, double +{ + zval *z_var; + MAKE_STD_ZVAL(z_var); + z_var->type = IS_DOUBLE; + z_var->value.dval = $1; + zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, + sizeof(zval *), NULL); +} + +%typemap(varinit) char +{ + zval *z_var; + char c[2]; + MAKE_STD_ZVAL(z_var); + c[0] = $1; + c[1] = 0; + z_var->type = IS_STRING; + z_var->value.str.val = estrndup(c, 1); + z_var->value.str.len = 1; + zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, + sizeof(zval *), NULL); +} + +%typemap(varinit) SWIGTYPE *, SWIGTYPE [] +{ + zval *z_var; + MAKE_STD_ZVAL(z_var); + SWIG_SetPointerZval(z_var, (void*)$1, $1_descriptor, 0); + zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, + sizeof(zval *), NULL); +} + +%typemap(varinit) SWIGTYPE, SWIGTYPE & +{ + $&1_ltype argp; + zval *z_var; + + MAKE_STD_ZVAL(z_var); + SWIG_SetPointerZval(z_var, (void*)&$1, $&1_descriptor, 0); + zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&z_var, + sizeof(zval *), NULL); +} + +%typemap(varinit) char [ANY] +{ + zval *z_var; + MAKE_STD_ZVAL(z_var); + z_var->type = IS_STRING; + if ($1) { + // varinit char [ANY] + ZVAL_STRINGL(z_var,(char*)$1, $1_dim0, 1); + } + zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&z_var, sizeof(zval *), NULL); +} + +%typemap(varin) int, unsigned int, short, unsigned short, long, unsigned long, signed char, unsigned char, enum SWIGTYPE +{ + zval **z_var; + + zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); + convert_to_long_ex(z_var); + if ($1 != ($1_ltype)((*z_var)->value.lval)) { + $1 = Z_LVAL_PP(z_var); + } +} + +%typemap(varin) bool +{ + zval **z_var; + + zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); + convert_to_boolean_ex(z_var); + if ($1 != ($1_ltype)((*z_var)->value.lval)) { + $1 = Z_LVAL_PP(z_var); + } +} + +%typemap(varin) double,float +{ + zval **z_var; + + zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); + convert_to_double_ex(z_var); + if ($1 != ($1_ltype)((*z_var)->value.dval)) { + $1 = Z_DVAL_PP(z_var); + } +} + +%typemap(varin) char +{ + zval **z_var; + + zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); + convert_to_string_ex(z_var); + if ($1 != *((*z_var)->value.str.val)) { + $1 = *((*z_var)->value.str.val); + } +} + +%typemap(varin) char * +{ + zval **z_var; + char *s1; + + zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); + convert_to_string_ex(z_var); + s1 = Z_STRVAL_PP(z_var); + if ((s1 == NULL) || ($1 == NULL) || zend_binary_strcmp(s1, strlen(s1), $1, strlen($1))) { + if (s1) + $1 = estrdup(s1); + else + $1 = NULL; + } +} + + +%typemap(varin) SWIGTYPE [] +{ + zval **z_var; + + zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); + if($1) { + SWIG_SetPointerZval(*z_var, (void*)$1, $1_descriptor, $owner); + } +} + +%typemap(varin) char [ANY] +{ + zval **z_var; + char *s1; + + zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); + s1 = Z_STRVAL_PP(z_var); + if((s1 == NULL) || ($1 == NULL) || zend_binary_strcmp(s1, strlen(s1), $1, strlen($1))) { + if(s1) + strncpy($1, s1, $1_dim0); + } +} + +%typemap(varin) SWIGTYPE +{ + zval **z_var; + $&1_ltype _temp; + + zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); + if (SWIG_ConvertPtr(*z_var, (void**)&_temp, $&1_descriptor, 0) < 0) { + SWIG_PHP_Error(E_ERROR,"Type error in value of $symname. Expected $&1_descriptor"); + } + + $1 = *($&1_ltype)_temp; + +} + +%typemap(varin) SWIGTYPE *, SWIGTYPE & +{ + zval **z_var; + $1_ltype _temp; + + zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); + if (SWIG_ConvertPtr(*z_var, (void **)&_temp, $1_descriptor, 0) < 0) { + SWIG_PHP_Error(E_ERROR,"Type error in value of $symname. Expected $&1_descriptor"); + } + + $1 = ($1_ltype)_temp; +} + +%typemap(varout) int, + unsigned int, + unsigned short, + short, + long, + unsigned long, + signed char, + unsigned char, + enum SWIGTYPE +{ + zval **z_var; + zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); + if($1 != ($1_ltype)((*z_var)->value.lval)) { + (*z_var)->value.lval = (long)$1; + } +} + +//SAMFIX need to cast zval->type, what if zend-hash_find fails? etc? +%typemap(varout) bool +{ + zval **z_var; + zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); + if($1 != ($1_ltype)((*z_var)->value.lval)) { + (*z_var)->value.lval = (long)$1; + } +} + +%typemap(varout) double, float +{ + zval **z_var; + zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); + if($1 != ($1_ltype)((*z_var)->value.dval)) { + (*z_var)->value.dval = (double)$1; + } +} + +%typemap(varout) char +{ + zval **z_var; + zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); + if($1 != *((*z_var)->value.str.val)) { + char c[2]; + efree((*z_var)->value.str.val); + c[0] = $1; + c[1] = 0; + (*z_var)->value.str.val = estrdup(c); + } +} + +%typemap(varout) char * +{ + zval **z_var; + char *s1; + + zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); + s1 = Z_STRVAL_PP(z_var); + if((s1 == NULL) || ($1 == NULL) || zend_binary_strcmp(s1, strlen(s1), $1, strlen($1) )) { + if(s1) + efree(s1); + if($1) { + (*z_var)->value.str.val = estrdup($1); + (*z_var)->value.str.len = strlen($1) +1; + } else { + (*z_var)->value.str.val = 0; + (*z_var)->value.str.len = 0; + } + } +} + +%typemap(varout) SWIGTYPE +{ + zval **z_var; + + zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); + SWIG_SetPointerZval(*z_var, (void*)&$1, $&1_descriptor, 0); +} + +%typemap(varout) SWIGTYPE [] +{ + zval **z_var; + + zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); + if($1) + SWIG_SetPointerZval(*z_var, (void*)$1, $1_descriptor, 0); +} + +%typemap(varout) char [ANY] +{ + zval **z_var; + char *s1; +deliberate error cos this code looks bogus to me + zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); + s1 = Z_STRVAL_PP(z_var); + if((s1 == NULL) || zend_binary_strcmp(s1, strlen(s1), $1, strlen($1))) { + if($1) { + (*z_var)->value.str.val = estrdup($1); + (*z_var)->value.str.len = strlen($1)+1; + } else { + (*z_var)->value.str.val = 0; + (*z_var)->value.str.len = 0; + } + } +} + +%typemap(varout) SWIGTYPE *, SWIGTYPE & +{ + zval **z_var; + + zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); + SWIG_SetPointerZval(*z_var, (void*)$1, $1_descriptor, 0); +} + + diff --git a/devtools/swigwin-1.3.34/Lib/php4/php4.swg b/devtools/swigwin-1.3.34/Lib/php4/php4.swg new file mode 100644 index 0000000..c8dded2 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/php4/php4.swg @@ -0,0 +1,298 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * php4.swg + * + * PHP4 configuration file + * ----------------------------------------------------------------------------- */ + +%runtime "swigrun.swg" // Common C API type-checking code +%runtime "php4run.swg" // Php4 runtime functions + +%include <php4init.swg> // Php4 initialization routine. + +%include <globalvar.i> // Global variables. +%include <const.i> + +// use %init %{ "/*code goes here*/ " %} +// or %minit %{ "/* code goes here*/ " %} to +// insert code in the PHP_MINIT_FUNCTION +#define %minit %insert("init") + +// use %rinit %{ "/* code goes here*/ " %} to +// insert code in the PHP_RINIT_FUNCTION +#define %rinit %insert("rinit") + +// use %shutdown %{ " /*code goes here*/ " %} to +// insert code in the PHP_MSHUTDOWN_FUNCTION +#define %shutdown %insert("shutdown") +#define %mshutdown %insert("shutdown") + +// use %rshutdown %{ " /*code goes here*/" %} to +// insert code in the PHP_RSHUTDOWN_FUNCTION +#define %rshutdown %insert("rshutdown") + +/* Typemaps for input parameters by value */ + +%include <utils.i> + +%pass_by_val(bool,CONVERT_BOOL_IN); + +%pass_by_val(size_t, CONVERT_INT_IN); + +%pass_by_val(enum SWIGTYPE, CONVERT_INT_IN); + +%pass_by_val(signed int, CONVERT_INT_IN); +%pass_by_val(int,CONVERT_INT_IN); +%pass_by_val(unsigned int,CONVERT_INT_IN); + +%pass_by_val(signed short, CONVERT_INT_IN); +%pass_by_val(short,CONVERT_INT_IN); +%pass_by_val(unsigned short, CONVERT_INT_IN); + +%pass_by_val(signed long, CONVERT_INT_IN); +%pass_by_val(long, CONVERT_INT_IN); +%pass_by_val(unsigned long, CONVERT_INT_IN); + +%pass_by_val(signed char, CONVERT_INT_IN); +%pass_by_val(char, CONVERT_CHAR_IN); +%pass_by_val(unsigned char, CONVERT_INT_IN); + +%pass_by_val(float, CONVERT_FLOAT_IN); + +%pass_by_val(double, CONVERT_FLOAT_IN); + +%pass_by_val(char *, CONVERT_STRING_IN); + +// char array can be in/out, though the passed string may not be big enough... +// so we have to size it +%typemap(in) char[ANY] +{ + convert_to_string_ex($input); + $1 = ($1_ltype) Z_STRVAL_PP($input); +} + +/* Object passed by value. Convert to a pointer */ +%typemap(in) SWIGTYPE ($&1_ltype tmp) +{ + if(SWIG_ConvertPtr(*$input, (void **) &tmp, $&1_descriptor, 0) < 0 || tmp == NULL) { + SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor"); + } + $1 = *tmp; +} + +%typemap(in) SWIGTYPE *, + SWIGTYPE [] +{ + if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor"); + } +} + +%typemap(in) SWIGTYPE & +{ + if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0 || $1 == NULL) { + SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor"); + } +} + +%typemap(in) SWIGTYPE *DISOWN +{ + if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, SWIG_POINTER_DISOWN ) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor"); + } +} +%typemap(argout) SWIGTYPE *, + SWIGTYPE [], + SWIGTYPE&; + +%typemap(in) void * +{ + if(SWIG_ConvertPtr(*$input, (void **) &$1, 0, 0) < 0) { + /* Allow NULL from php for void* */ + if ((*$input)->type==IS_NULL) $1=0; + else + SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor"); + } +} + +/* Special case when void* is passed by reference so it can be made to point + to opaque api structs */ +%typemap(in) void ** ($*1_ltype ptr, int force), + void *& ($*1_ltype ptr, int force) +{ + /* If they pass NULL by reference, make it into a void* + This bit should go in arginit if arginit support init-ing scripting args */ + if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0) { + /* So... we didn't get a ref or ptr, but we'll accept NULL by reference */ + if (!((*$input)->type==IS_NULL && PZVAL_IS_REF(*$input))) { + /* wasn't a pre/ref/thing, OR anything like an int thing */ + SWIG_PHP_Error(E_ERROR, "Type error in argument $arg of $symname."); + } + } + force=0; + if (arg1==NULL) { +#ifdef __cplusplus + ptr=new $*1_ltype; +#else + ptr=($*1_ltype) calloc(1,sizeof($*1_ltype)); +#endif + $1=&ptr; + /* have to passback arg$arg too */ + force=1; + } +} +%typemap(argout) void **, + void *& +{ + if (force$argnum) { + SWIG_SetPointerZval( *$input, (void*) ptr$argnum, $*1_descriptor, 1); + } +} + +/* Typemap for output values */ + +%typemap(out) int, + unsigned int, + short, + unsigned short, + long, + unsigned long, + signed char, + unsigned char, + bool, + size_t, + enum SWIGTYPE +{ + ZVAL_LONG(return_value,$1); +} + +%typemap(out) bool +{ + ZVAL_BOOL(return_value,($1)?1:0); +} + +%typemap(out) float, + double +{ + ZVAL_DOUBLE(return_value,$1); +} + +%typemap(out) char +{ + ZVAL_STRINGL(return_value,&$1, 1, 1); +} + +%typemap(out) char *, + char [] +{ + if(!$1) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,$1, 1); + } +} + +%typemap(out) SWIGTYPE *, + SWIGTYPE [], + SWIGTYPE & +{ + SWIG_SetPointerZval(return_value, (void *)$1, $1_descriptor, $owner); +} + +%typemap(out) SWIGTYPE *DYNAMIC, + SWIGTYPE &DYNAMIC +{ + swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1); + SWIG_SetPointerZval(return_value, (void *)$1, ty, $owner); +} + +%typemap(out) SWIGTYPE +#ifdef __cplusplus +{ + $&1_ltype resultobj = new $1_ltype(($1_ltype &) $1); + SWIG_SetPointerZval(return_value, (void *)resultobj, $&1_descriptor, 1); +} +#else +{ + $&1_ltype resultobj = ($&1_ltype) emalloc(sizeof($1_type)); + memmove(resultobj, &$1, sizeof($1_type)); + SWIG_SetPointerZval(return_value, (void *)resultobj, $&1_descriptor, 1); +} +#endif + +%typemap(out) void ""; + +%typemap(out) char [ANY] +{ + RETVAL_STRINGL($1,$1_dim0,1); +} + +// This typecheck does hard checking for proper argument type. If you want +// an argument to be converted from a different PHP type, you must convert +// it yourself before passing it (e.g. (string)4.7 or (int)"6"). +%define %php_typecheck(_type,_prec,is) +%typemap(typecheck,precedence=_prec) _type + " $1 = (Z_TYPE_PP($input) == is); " +%enddef + +%php_typecheck(int,SWIG_TYPECHECK_INTEGER,IS_LONG) +%php_typecheck(unsigned int,SWIG_TYPECHECK_UINT32,IS_LONG) +%php_typecheck(short,SWIG_TYPECHECK_INT16,IS_LONG) +%php_typecheck(unsigned short,SWIG_TYPECHECK_UINT16,IS_LONG) +%php_typecheck(long,SWIG_TYPECHECK_INT64,IS_LONG) +%php_typecheck(unsigned long,SWIG_TYPECHECK_UINT64,IS_LONG) +%php_typecheck(signed char,SWIG_TYPECHECK_INT8,IS_LONG) +%php_typecheck(unsigned char,SWIG_TYPECHECK_UINT8,IS_LONG) +%php_typecheck(size_t,SWIG_TYPECHECK_INT16,IS_LONG) +%php_typecheck(enum SWIGTYPE,SWIG_TYPECHECK_INT8,IS_LONG) +%php_typecheck(bool,SWIG_TYPECHECK_BOOL,IS_BOOL) + +%php_typecheck(char,SWIG_TYPECHECK_CHAR,IS_STRING) +%php_typecheck(char *,SWIG_TYPECHECK_STRING,IS_STRING) +%php_typecheck(char [],SWIG_TYPECHECK_STRING,IS_STRING) + +%php_typecheck(float,SWIG_TYPECHECK_FLOAT,IS_DOUBLE) +%php_typecheck(double,SWIG_TYPECHECK_BOOL,IS_DOUBLE) + +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE + " /* typecheck SWIGTYPE */ " + +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, + SWIGTYPE [], + SWIGTYPE & +{ + void *tmp; + _v = (SWIG_ConvertPtr( *$input, (void**)&tmp, $1_descriptor, 0) >= 0); +} + +%typecheck(SWIG_TYPECHECK_VOIDPTR) void * + " /* typecheck void * */ " + + +/* Exception handling */ + +%typemap(throws) int, + long, + short, + unsigned int, + unsigned long, + unsigned short { + char error_msg[256]; + sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1); + SWIG_PHP_Error(E_ERROR, error_msg); +} + +%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] %{ + (void)$1; + SWIG_PHP_Error(E_ERROR, "C++ $1_type exception thrown"); +%} + +%typemap(throws) char * %{ + SWIG_PHP_Error(E_ERROR, (char *)$1); +%} + + +/* php keywords */ +%include <php4kw.swg> diff --git a/devtools/swigwin-1.3.34/Lib/php4/php4init.swg b/devtools/swigwin-1.3.34/Lib/php4/php4init.swg new file mode 100644 index 0000000..b7a0fc9 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/php4/php4init.swg @@ -0,0 +1,12 @@ + +/* ------------------------------------------------------------ + * The start of the PHP initialization function + * ------------------------------------------------------------ */ + +%insert(init) "swiginit.swg" + +%init %{ + SWIG_php_minit { + SWIG_InitializeModule(0); +%} + diff --git a/devtools/swigwin-1.3.34/Lib/php4/php4kw.swg b/devtools/swigwin-1.3.34/Lib/php4/php4kw.swg new file mode 100644 index 0000000..0d28994 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/php4/php4kw.swg @@ -0,0 +1,461 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * php4kw.swg + * + * The 'keywords' in PHP are global, ie, the following names are fine + * when used as class methods. + * ----------------------------------------------------------------------------- */ + +#define PHPKW(x) %keywordwarn(`x` " is a php keyword, renamed as c_"`x`,sourcefmt="%(lower)s", rename="c_%s",fullname=1) `x` + +%define PHPCN(x) +%keywordwarn(`x` " is a php reserved class name, class renamed as c_"`x`,%$isclass,rename="c_%s") `x`; +%keywordwarn(`x` " is a php reserved class name, constructor renamed as c_"`x`,%$isconstructor,rename="c_%s") `x`; +%enddef + +#define PHPBN1(x) %builtinwarn(`x` " conflicts with a built-in name in php",sourcefmt="%(lower)s",fullname=1) `x` +#define PHPBN2(x) %builtinwarn(`x` " conflicts with a built-in name in php") "::" `x` + + +/* + From + + http://aspn.activestate.com/ASPN/docs/PHP/reserved.html + + and reviewed by Olly Betts. + + Further updates from the PHP manual on php.net. +*/ + +/* We classify these as kw since PHP will not run if used globally. */ +/* case insensitive */ +PHPKW(and); +PHPKW(array); +PHPKW(as); +PHPKW(break); +PHPKW(case); +PHPKW(cfunction); /* No longer reserved in PHP5 */ +PHPKW(class); +PHPKW(const); +PHPKW(continue); +PHPKW(declare); +PHPKW(default); +PHPKW(die); +PHPKW(do); +PHPKW(echo); +PHPKW(else); +PHPKW(elseif); +PHPKW(empty); +PHPKW(enddeclare); +PHPKW(endfor); +PHPKW(endforeach); +PHPKW(endif); +PHPKW(endswitch); +PHPKW(endwhile); +PHPKW(eval); +PHPKW(exit); +PHPKW(extends); +PHPKW(for); +PHPKW(foreach); +PHPKW(function); +PHPKW(global); +PHPKW(if); +PHPKW(include); +PHPKW(include_once); +PHPKW(isset); +PHPKW(list); +PHPKW(new); +PHPKW(old_function); /* No longer reserved in PHP5 */ +PHPKW(or); +PHPKW(print); +PHPKW(require); +PHPKW(require_once); +PHPKW(return); +PHPKW(static); +PHPKW(switch); +PHPKW(unset); +PHPKW(use); +PHPKW(var); +PHPKW(while); +PHPKW(xor); +PHPKW(__FILE__); +PHPKW(__LINE__); +PHPKW(__FUNCTION__); +PHPKW(__CLASS__); + +/* Added in PHP5 */ +PHPKW(__halt_compiler); +PHPKW(abstract); +PHPKW(catch); +PHPKW(clone); +PHPKW(final); +PHPKW(implements); +PHPKW(instanceof); +PHPKW(interface); +PHPKW(private); +PHPKW(protected); +PHPKW(public); +PHPKW(throw); +PHPKW(try); +PHPKW(__METHOD__); + +/* We classify these as built-in names since they conflict, but PHP still runs */ + +/* Type 1: case insensitive */ +PHPBN1(__sleep); +PHPBN1(__wakeup); +PHPBN1(not); +PHPBN1(parent); +PHPBN1(virtual); +PHPBN1(NULL); +PHPBN1(TRUE); +PHPBN1(FALSE); + +/* Type 2: case sensitive */ +/* "Core Predefined Constants" from http://uk2.php.net/manual/en/reserved.constants.php */ +PHPBN2(E_ALL); +PHPBN2(E_ERROR); +PHPBN2(E_PARSE); +PHPBN2(E_WARNING); +PHPBN2(E_NOTICE); +PHPBN2(E_CORE_ERROR); +PHPBN2(E_CORE_WARNING); +PHPBN2(E_COMPILE_ERROR); +PHPBN2(E_COMPILE_WARNING); +PHPBN2(E_USER_ERROR); +PHPBN2(E_USER_WARNING); +PHPBN2(E_USER_NOTICE); +PHPBN2(PHP_OS); +PHPBN2(PHP_VERSION); +PHPBN2(PHP_SAPI); +PHPBN2(PHP_EOL); +PHPBN2(PHP_INT_MAX); +PHPBN2(PHP_INT_SIZE); +PHPBN2(DEFAULT_INCLUDE_PATH); +PHPBN2(PEAR_INSTALL_DIR); +PHPBN2(PEAR_EXTENSION_DIR); +PHPBN2(PHP_EXTENSION_DIR); +PHPBN2(PHP_PREFIX); +PHPBN2(PHP_BINDIR); +PHPBN2(PHP_LIBDIR); +PHPBN2(PHP_DATADIR); +PHPBN2(PHP_SYSCONFDIR); +PHPBN2(PHP_LOCALSTATEDIR); +PHPBN2(PHP_CONFIG_FILE_PATH); +PHPBN2(PHP_CONFIG_FILE_SCAN_DIR); +PHPBN2(PHP_SHLIB_SUFFIX); +PHPBN2(PHP_OUTPUT_HANDLER_START); +PHPBN2(PHP_OUTPUT_HANDLER_CONT); +PHPBN2(PHP_OUTPUT_HANDLER_END); +/* "Standard Predefined Constants" from http://uk2.php.net/manual/en/reserved.constants.php */ +PHPBN2(EXTR_OVERWRITE); +PHPBN2(EXTR_SKIP); +PHPBN2(EXTR_PREFIX_SAME); +PHPBN2(EXTR_PREFIX_ALL); +PHPBN2(EXTR_PREFIX_INVALID); +PHPBN2(EXTR_PREFIX_IF_EXISTS); +PHPBN2(EXTR_IF_EXISTS); +PHPBN2(SORT_ASC); +PHPBN2(SORT_DESC); +PHPBN2(SORT_REGULAR); +PHPBN2(SORT_NUMERIC); +PHPBN2(SORT_STRING); +PHPBN2(CASE_LOWER); +PHPBN2(CASE_UPPER); +PHPBN2(COUNT_NORMAL); +PHPBN2(COUNT_RECURSIVE); +PHPBN2(ASSERT_ACTIVE); +PHPBN2(ASSERT_CALLBACK); +PHPBN2(ASSERT_BAIL); +PHPBN2(ASSERT_WARNING); +PHPBN2(ASSERT_QUIET_EVAL); +PHPBN2(CONNECTION_ABORTED); +PHPBN2(CONNECTION_NORMAL); +PHPBN2(CONNECTION_TIMEOUT); +PHPBN2(INI_USER); +PHPBN2(INI_PERDIR); +PHPBN2(INI_SYSTEM); +PHPBN2(INI_ALL); +PHPBN2(M_E); +PHPBN2(M_LOG2E); +PHPBN2(M_LOG10E); +PHPBN2(M_LN2); +PHPBN2(M_LN10); +PHPBN2(M_PI); +PHPBN2(M_PI_2); +PHPBN2(M_PI_4); +PHPBN2(M_1_PI); +PHPBN2(M_2_PI); +PHPBN2(M_2_SQRTPI); +PHPBN2(M_SQRT2); +PHPBN2(M_SQRT1_2); +PHPBN2(CRYPT_SALT_LENGTH); +PHPBN2(CRYPT_STD_DES); +PHPBN2(CRYPT_EXT_DES); +PHPBN2(CRYPT_MD5); +PHPBN2(CRYPT_BLOWFISH); +PHPBN2(DIRECTORY_SEPARATOR); +PHPBN2(SEEK_SET); +PHPBN2(SEEK_CUR); +PHPBN2(SEEK_END); +PHPBN2(LOCK_SH); +PHPBN2(LOCK_EX); +PHPBN2(LOCK_UN); +PHPBN2(LOCK_NB); +PHPBN2(HTML_SPECIALCHARS); +PHPBN2(HTML_ENTITIES); +PHPBN2(ENT_COMPAT); +PHPBN2(ENT_QUOTES); +PHPBN2(ENT_NOQUOTES); +PHPBN2(INFO_GENERAL); +PHPBN2(INFO_CREDITS); +PHPBN2(INFO_CONFIGURATION); +PHPBN2(INFO_MODULES); +PHPBN2(INFO_ENVIRONMENT); +PHPBN2(INFO_VARIABLES); +PHPBN2(INFO_LICENSE); +PHPBN2(INFO_ALL); +PHPBN2(CREDITS_GROUP); +PHPBN2(CREDITS_GENERAL); +PHPBN2(CREDITS_SAPI); +PHPBN2(CREDITS_MODULES); +PHPBN2(CREDITS_DOCS); +PHPBN2(CREDITS_FULLPAGE); +PHPBN2(CREDITS_QA); +PHPBN2(CREDITS_ALL); +PHPBN2(STR_PAD_LEFT); +PHPBN2(STR_PAD_RIGHT); +PHPBN2(STR_PAD_BOTH); +PHPBN2(PATHINFO_DIRNAME); +PHPBN2(PATHINFO_BASENAME); +PHPBN2(PATHINFO_EXTENSION); +PHPBN2(PATH_SEPARATOR); +PHPBN2(CHAR_MAX); +PHPBN2(LC_CTYPE); +PHPBN2(LC_NUMERIC); +PHPBN2(LC_TIME); +PHPBN2(LC_COLLATE); +PHPBN2(LC_MONETARY); +PHPBN2(LC_ALL); +PHPBN2(LC_MESSAGES); +PHPBN2(ABDAY_1); +PHPBN2(ABDAY_2); +PHPBN2(ABDAY_3); +PHPBN2(ABDAY_4); +PHPBN2(ABDAY_5); +PHPBN2(ABDAY_6); +PHPBN2(ABDAY_7); +PHPBN2(DAY_1); +PHPBN2(DAY_2); +PHPBN2(DAY_3); +PHPBN2(DAY_4); +PHPBN2(DAY_5); +PHPBN2(DAY_6); +PHPBN2(DAY_7); +PHPBN2(ABMON_1); +PHPBN2(ABMON_2); +PHPBN2(ABMON_3); +PHPBN2(ABMON_4); +PHPBN2(ABMON_5); +PHPBN2(ABMON_6); +PHPBN2(ABMON_7); +PHPBN2(ABMON_8); +PHPBN2(ABMON_9); +PHPBN2(ABMON_10); +PHPBN2(ABMON_11); +PHPBN2(ABMON_12); +PHPBN2(MON_1); +PHPBN2(MON_2); +PHPBN2(MON_3); +PHPBN2(MON_4); +PHPBN2(MON_5); +PHPBN2(MON_6); +PHPBN2(MON_7); +PHPBN2(MON_8); +PHPBN2(MON_9); +PHPBN2(MON_10); +PHPBN2(MON_11); +PHPBN2(MON_12); +PHPBN2(AM_STR); +PHPBN2(PM_STR); +PHPBN2(D_T_FMT); +PHPBN2(D_FMT); +PHPBN2(T_FMT); +PHPBN2(T_FMT_AMPM); +PHPBN2(ERA); +PHPBN2(ERA_YEAR); +PHPBN2(ERA_D_T_FMT); +PHPBN2(ERA_D_FMT); +PHPBN2(ERA_T_FMT); +PHPBN2(ALT_DIGITS); +PHPBN2(INT_CURR_SYMBOL); +PHPBN2(CURRENCY_SYMBOL); +PHPBN2(CRNCYSTR); +PHPBN2(MON_DECIMAL_POINT); +PHPBN2(MON_THOUSANDS_SEP); +PHPBN2(MON_GROUPING); +PHPBN2(POSITIVE_SIGN); +PHPBN2(NEGATIVE_SIGN); +PHPBN2(INT_FRAC_DIGITS); +PHPBN2(FRAC_DIGITS); +PHPBN2(P_CS_PRECEDES); +PHPBN2(P_SEP_BY_SPACE); +PHPBN2(N_CS_PRECEDES); +PHPBN2(N_SEP_BY_SPACE); +PHPBN2(P_SIGN_POSN); +PHPBN2(N_SIGN_POSN); +PHPBN2(DECIMAL_POINT); +PHPBN2(RADIXCHAR); +PHPBN2(THOUSANDS_SEP); +PHPBN2(THOUSEP); +PHPBN2(GROUPING); +PHPBN2(YESEXPR); +PHPBN2(NOEXPR); +PHPBN2(YESSTR); +PHPBN2(NOSTR); +PHPBN2(CODESET); +PHPBN2(LOG_EMERG); +PHPBN2(LOG_ALERT); +PHPBN2(LOG_CRIT); +PHPBN2(LOG_ERR); +PHPBN2(LOG_WARNING); +PHPBN2(LOG_NOTICE); +PHPBN2(LOG_INFO); +PHPBN2(LOG_DEBUG); +PHPBN2(LOG_KERN); +PHPBN2(LOG_USER); +PHPBN2(LOG_MAIL); +PHPBN2(LOG_DAEMON); +PHPBN2(LOG_AUTH); +PHPBN2(LOG_SYSLOG); +PHPBN2(LOG_LPR); +PHPBN2(LOG_NEWS); +PHPBN2(LOG_UUCP); +PHPBN2(LOG_CRON); +PHPBN2(LOG_AUTHPRIV); +PHPBN2(LOG_LOCAL0); +PHPBN2(LOG_LOCAL1); +PHPBN2(LOG_LOCAL2); +PHPBN2(LOG_LOCAL3); +PHPBN2(LOG_LOCAL4); +PHPBN2(LOG_LOCAL5); +PHPBN2(LOG_LOCAL6); +PHPBN2(LOG_LOCAL7); +PHPBN2(LOG_PID); +PHPBN2(LOG_CONS); +PHPBN2(LOG_ODELAY); +PHPBN2(LOG_NDELAY); +PHPBN2(LOG_NOWAIT); +PHPBN2(LOG_PERROR); + +/* Added in PHP5 */ +PHPBN2(E_STRICT); +PHPBN2(__COMPILER_HALT_OFFSET__); + +/* Class names reserved by PHP */ +PHPCN(stdClass); +PHPCN(__PHP_Incomplete_Class); +PHPCN(Directory); + +/* Added in PHP5 (this list apparently depends which extensions you load by default). */ +PHPCN(parent); +PHPCN(self); +PHPCN(Exception); +PHPCN(php_user_filter); +PHPCN(ErrorException); +PHPCN(XMLWriter); +PHPCN(LibXMLError); +PHPCN(SimpleXMLElement); +PHPCN(SoapClient); +PHPCN(SoapVar); +PHPCN(SoapServer); +PHPCN(SoapFault); +PHPCN(SoapParam); +PHPCN(SoapHeader); +PHPCN(RecursiveIteratorIterator); +PHPCN(FilterIterator); +PHPCN(RecursiveFilterIterator); +PHPCN(ParentIterator); +PHPCN(LimitIterator); +PHPCN(CachingIterator); +PHPCN(RecursiveCachingIterator); +PHPCN(IteratorIterator); +PHPCN(NoRewindIterator); +PHPCN(AppendIterator); +PHPCN(InfiniteIterator); +PHPCN(EmptyIterator); +PHPCN(ArrayObject); +PHPCN(ArrayIterator); +PHPCN(RecursiveArrayIterator); +PHPCN(SplFileInfo); +PHPCN(DirectoryIterator); +PHPCN(RecursiveDirectoryIterator); +PHPCN(SplFileObject); +PHPCN(SplTempFileObject); +PHPCN(SimpleXMLIterator); +PHPCN(LogicException); +PHPCN(BadFunctionCallException); +PHPCN(BadMethodCallException); +PHPCN(DomainException); +PHPCN(InvalidArgumentException); +PHPCN(LengthException); +PHPCN(OutOfRangeException); +PHPCN(RuntimeException); +PHPCN(OutOfBoundsException); +PHPCN(OverflowException); +PHPCN(RangeException); +PHPCN(UnderflowException); +PHPCN(UnexpectedValueException); +PHPCN(SplObjectStorage); +PHPCN(ReflectionException); +PHPCN(Reflection); +PHPCN(ReflectionFunction); +PHPCN(ReflectionParameter); +PHPCN(ReflectionMethod); +PHPCN(ReflectionClass); +PHPCN(ReflectionObject); +PHPCN(ReflectionProperty); +PHPCN(ReflectionExtension); +PHPCN(DOMException); +PHPCN(DOMStringList); +PHPCN(DOMNameList); +PHPCN(DOMImplementationList); +PHPCN(DOMImplementationSource); +PHPCN(DOMImplementation); +PHPCN(DOMNode); +PHPCN(DOMNameSpaceNode); +PHPCN(DOMDocumentFragment); +PHPCN(DOMDocument); +PHPCN(DOMNodeList); +PHPCN(DOMNamedNodeMap); +PHPCN(DOMCharacterData); +PHPCN(DOMAttr); +PHPCN(DOMElement); +PHPCN(DOMText); +PHPCN(DOMComment); +PHPCN(DOMTypeinfo); +PHPCN(DOMUserDataHandler); +PHPCN(DOMDomError); +PHPCN(DOMErrorHandler); +PHPCN(DOMLocator); +PHPCN(DOMConfiguration); +PHPCN(DOMCdataSection); +PHPCN(DOMDocumentType); +PHPCN(DOMNotation); +PHPCN(DOMEntity); +PHPCN(DOMEntityReference); +PHPCN(DOMProcessingInstruction); +PHPCN(DOMStringExtend); +PHPCN(DOMXPath); +PHPCN(XMLReader); +PHPCN(SQLiteDatabase); +PHPCN(SQLiteResult); +PHPCN(SQLiteUnbuffered); +PHPCN(SQLiteException); + +#undef PHPKW +#undef PHPBN1 +#undef PHPBN2 +#undef PHPCN diff --git a/devtools/swigwin-1.3.34/Lib/php4/php4run.swg b/devtools/swigwin-1.3.34/Lib/php4/php4run.swg new file mode 100644 index 0000000..d384527 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/php4/php4run.swg @@ -0,0 +1,222 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * php4run.swg + * + * PHP4 runtime library + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#endif +#include "zend.h" +#include "zend_API.h" +#include "php.h" + +#ifdef ZEND_RAW_FENTRY +/* ZEND_RAW_FENTRY was added somewhere between 5.2.0 and 5.2.3 */ +# define SWIG_ZEND_NAMED_FE(ZN, N, A) ZEND_RAW_FENTRY((char*)#ZN, N, A, 0) +#else +/* This causes warnings from GCC >= 4.2 (assigning a string literal to char*). + * But this seems to be unavoidable without directly assuming knowledge of + * the structure, which changed between PHP4 and PHP5. */ +# define SWIG_ZEND_NAMED_FE(ZN, N, A) ZEND_NAMED_FE(ZN, N, A) +#endif + +#define SWIG_LONG_CONSTANT(N, V) zend_register_long_constant((char*)#N, sizeof(#N), V, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) +#define SWIG_DOUBLE_CONSTANT(N, V) zend_register_double_constant((char*)#N, sizeof(#N), V, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) +#define SWIG_STRING_CONSTANT(N, V) zend_register_stringl_constant((char*)#N, sizeof(#N), V, strlen(V), CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) +#define SWIG_CHAR_CONSTANT(N, V) do {\ + static char swig_char = (V);\ + zend_register_stringl_constant((char*)#N, sizeof(#N), &swig_char, 1, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);\ +} while (0) + +/* These TSRMLS_ stuff should already be defined now, but with older php under + redhat are not... */ +#ifndef TSRMLS_D +#define TSRMLS_D +#endif +#ifndef TSRMLS_DC +#define TSRMLS_DC +#endif +#ifndef TSRMLS_C +#define TSRMLS_C +#endif +#ifndef TSRMLS_CC +#define TSRMLS_CC +#endif + +#ifdef __cplusplus +} +#endif + +/* But in fact SWIG_ConvertPtr is the native interface for getting typed + pointer values out of zvals. We need the TSRMLS_ macros for when we + make PHP type calls later as we handle php resources */ +#define SWIG_ConvertPtr(obj,pp,type,flags) SWIG_ZTS_ConvertPtr(obj,pp,type,flags TSRMLS_CC) + + +#define SWIG_fail goto fail + +static const char *default_error_msg = "Unknown error occurred"; +static int default_error_code = E_ERROR; + +#define SWIG_PHP_Arg_Error_Msg(argnum,extramsg) "Error in argument " #argnum " "#extramsg + +#define SWIG_PHP_Error(code,msg) do { SWIG_ErrorCode() = code; SWIG_ErrorMsg() = msg; SWIG_fail; } while (0) + +#define SWIG_contract_assert(expr,msg) \ + if (!(expr) ) { zend_printf("Contract Assert Failed %s\n",msg ); } else + +/* Standard SWIG API */ +#define SWIG_GetModule(clientdata) SWIG_Php4_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Php4_SetModule(pointer) + +/* used to wrap returned objects in so we know whether they are newobject + and need freeing, or not */ +typedef struct _swig_object_wrapper { + void * ptr; + int newobject; +} swig_object_wrapper; + +/* empty zend destructor for types without one */ +static ZEND_RSRC_DTOR_FUNC(SWIG_landfill) { (void)rsrc; } + +#define SWIG_SetPointerZval(a,b,c,d) SWIG_ZTS_SetPointerZval(a,b,c,d TSRMLS_CC) + +static void +SWIG_ZTS_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject TSRMLS_DC) { + swig_object_wrapper *value=NULL; + /* + * First test for Null pointers. Return those as PHP native NULL + */ + if (!ptr ) { + ZVAL_NULL(z); + return; + } + if (type->clientdata) { + if (! (*(int *)(type->clientdata))) + zend_error(E_ERROR, "Type: %s failed to register with zend",type->name); + value=(swig_object_wrapper *)emalloc(sizeof(swig_object_wrapper)); + value->ptr=ptr; + value->newobject=newobject; + ZEND_REGISTER_RESOURCE(z, value, *(int *)(type->clientdata)); + return; + } + zend_error(E_ERROR, "Type: %s not registered with zend",type->name); +} + +/* This pointer conversion routine takes the native pointer p (along with + its type name) and converts it by calling appropriate casting functions + according to ty. The resultant pointer is returned, or NULL is returned + if the pointer can't be cast. + + Sadly PHP has no API to find a type name from a type id, only from an + instance of a resource of the type id, so we have to pass type_name as well. + + The two functions which might call this are: + SWIG_ZTS_ConvertResourcePtr which gets the type name from the resource + and the registered zend destructors for which we have one per type each + with the type name hard wired in. */ +static void * +SWIG_ZTS_ConvertResourceData(void * p, const char *type_name, swig_type_info *ty TSRMLS_DC) { + swig_cast_info *tc; + void *result = 0; + + if (!ty) { + /* They don't care about the target type, so just pass on the pointer! */ + return p; + } + + if (! type_name) { + /* can't convert p to ptr type ty if we don't know what type p is */ + return NULL; + } + + /* convert and cast p from type_name to ptr as ty. */ + tc = SWIG_TypeCheck(type_name, ty); + if (tc) { + int newmemory = 0; + result = SWIG_TypeCast(tc, p, &newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + } + return result; +} + +/* This function returns a pointer of type ty by extracting the pointer + and type info from the resource in z. z must be a resource. + If it fails, NULL is returned. + It uses SWIG_ZTS_ConvertResourceData to do the real work. */ +static void * +SWIG_ZTS_ConvertResourcePtr(zval *z, swig_type_info *ty, int flags TSRMLS_DC) { + swig_object_wrapper *value; + void *p; + int type; + char *type_name; + + value = (swig_object_wrapper *) zend_list_find(z->value.lval, &type); + if ( flags && SWIG_POINTER_DISOWN ) { + value->newobject = 0; + } + p = value->ptr; + if (type==-1) return NULL; + + type_name=zend_rsrc_list_get_rsrc_type(z->value.lval TSRMLS_CC); + + return SWIG_ZTS_ConvertResourceData(p, type_name, ty TSRMLS_CC); +} + +/* We allow passing of a RESOURCE pointing to the object or an OBJECT whose + _cPtr is a resource pointing to the object */ +static int +SWIG_ZTS_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags TSRMLS_DC) { + if (z == NULL) { + *ptr = 0; + return 0; + } + + switch (z->type) { + case IS_OBJECT: { + zval ** _cPtr; + if (zend_hash_find(HASH_OF(z),(char*)"_cPtr",sizeof("_cPtr"),(void**)&_cPtr)==SUCCESS) { + if ((*_cPtr)->type==IS_RESOURCE) { + *ptr = SWIG_ZTS_ConvertResourcePtr(*_cPtr, ty, flags TSRMLS_CC); + return (*ptr == NULL ? -1 : 0); + } + } + break; + } + case IS_RESOURCE: + *ptr = SWIG_ZTS_ConvertResourcePtr(z, ty, flags TSRMLS_CC); + return (*ptr == NULL ? -1 : 0); + case IS_NULL: + *ptr = 0; + return 0; + } + + return -1; +} + +static char const_name[] = "swig_runtime_data_type_pointer"; +static swig_module_info *SWIG_Php4_GetModule() { + zval *pointer; + swig_module_info *ret = 0; + + MAKE_STD_ZVAL(pointer); + + TSRMLS_FETCH(); + + if (zend_get_constant(const_name, sizeof(const_name), pointer TSRMLS_CC)) { + if (pointer->type == IS_LONG) { + ret = (swig_module_info *) pointer->value.lval; + } + } + FREE_ZVAL(pointer); + return ret; +} + +static void SWIG_Php4_SetModule(swig_module_info *pointer) { + TSRMLS_FETCH(); + REGISTER_MAIN_LONG_CONSTANT(const_name, (long) pointer, 0); +} diff --git a/devtools/swigwin-1.3.34/Lib/php4/phppointers.i b/devtools/swigwin-1.3.34/Lib/php4/phppointers.i new file mode 100644 index 0000000..91b2c6d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/php4/phppointers.i @@ -0,0 +1,42 @@ +%define %pass_by_ref( TYPE, CONVERT_IN, CONVERT_OUT ) +%typemap(in) TYPE *REF ($*1_ltype tmp), + TYPE &REF ($*1_ltype tmp) +%{ + /* First Check for SWIG wrapped type */ + if ( ZVAL_IS_NULL( *$input ) ) { + $1 = 0; + } else if ( PZVAL_IS_REF( *$input ) ) { + /* Not swig wrapped type, so we check if it's a PHP reference type */ + CONVERT_IN( tmp, $*1_ltype, $input ); + $1 = &tmp; + } else { + SWIG_PHP_Error( E_ERROR, SWIG_PHP_Arg_Error_Msg($argnum, Expected a reference) ); + } +%} +%typemap(argout) TYPE *REF, + TYPE &REF + "CONVERT_OUT(*$input, tmp$argnum );"; +%enddef + +%pass_by_ref( size_t, CONVERT_INT_IN, ZVAL_LONG ); + +%pass_by_ref( signed int, CONVERT_INT_IN, ZVAL_LONG ); +%pass_by_ref( int, CONVERT_INT_IN, ZVAL_LONG ); +%pass_by_ref( unsigned int, CONVERT_INT_IN, ZVAL_LONG ); + +%pass_by_ref( signed short, CONVERT_INT_IN, ZVAL_LONG ); +%pass_by_ref( short, CONVERT_INT_IN, ZVAL_LONG ); +%pass_by_ref( unsigned short, CONVERT_INT_IN, ZVAL_LONG ); + +%pass_by_ref( signed long, CONVERT_INT_IN, ZVAL_LONG ); +%pass_by_ref( long, CONVERT_INT_IN, ZVAL_LONG ); +%pass_by_ref( unsigned long, CONVERT_INT_IN, ZVAL_LONG ); + +%pass_by_ref( signed char, CONVERT_INT_IN, ZVAL_LONG ); +%pass_by_ref( char, CONVERT_CHAR_IN, ZVAL_STRING ); +%pass_by_ref( unsigned char, CONVERT_INT_IN, ZVAL_LONG ); + +%pass_by_ref( float, CONVERT_FLOAT_IN, ZVAL_DOUBLE ); +%pass_by_ref( double, CONVERT_FLOAT_IN, ZVAL_DOUBLE ); + +%pass_by_ref( char *, CONVERT_CHAR_IN, ZVAL_STRING ); diff --git a/devtools/swigwin-1.3.34/Lib/php4/std_common.i b/devtools/swigwin-1.3.34/Lib/php4/std_common.i new file mode 100644 index 0000000..a779649 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/php4/std_common.i @@ -0,0 +1,13 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_common.i + * + * SWIG typemaps for STL - common utilities + * ----------------------------------------------------------------------------- */ + +%include <std/std_except.i> + +%apply size_t { std::size_t }; + diff --git a/devtools/swigwin-1.3.34/Lib/php4/std_deque.i b/devtools/swigwin-1.3.34/Lib/php4/std_deque.i new file mode 100644 index 0000000..cb98f6c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/php4/std_deque.i @@ -0,0 +1 @@ +%include <std/_std_deque.i> diff --git a/devtools/swigwin-1.3.34/Lib/php4/std_map.i b/devtools/swigwin-1.3.34/Lib/php4/std_map.i new file mode 100644 index 0000000..c35f21d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/php4/std_map.i @@ -0,0 +1,175 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_map.i + * + * SWIG typemaps for std::map + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +// ------------------------------------------------------------------------ +// std::map +// ------------------------------------------------------------------------ + +%{ +#include <map> +#include <algorithm> +#include <stdexcept> +%} + +// exported class + +namespace std { + + template<class K, class T> class map { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T& get(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(const K& key, const T& x) { + (*self)[key] = x; + } + void del(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + + + // specializations for built-ins + + %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) + + template<class T> class map<K,T> { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T& get(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(K key, const T& x) { + (*self)[key] = x; + } + void del(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(K key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + %enddef + + %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) + template<class K> class map<K,T> { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T get(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(const K& key, T x) { + (*self)[key] = x; + } + void del(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + %enddef + + %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, + T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) + template<> class map<K,T> { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T get(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(K key, T x) { + (*self)[key] = x; + } + void del(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(K key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + %enddef + + // add specializations here + +} diff --git a/devtools/swigwin-1.3.34/Lib/php4/std_pair.i b/devtools/swigwin-1.3.34/Lib/php4/std_pair.i new file mode 100644 index 0000000..dc0604d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/php4/std_pair.i @@ -0,0 +1,37 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_pair.i + * + * SWIG typemaps for std::pair + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <exception.i> + +// ------------------------------------------------------------------------ +// std::pair +// ------------------------------------------------------------------------ + +%{ +#include <utility> +%} + +namespace std { + + template<class T, class U> struct pair { + + pair(); + pair(T first, U second); + pair(const pair& p); + + template <class U1, class U2> pair(const pair<U1, U2> &p); + + T first; + U second; + }; + + // add specializations here + +} diff --git a/devtools/swigwin-1.3.34/Lib/php4/std_string.i b/devtools/swigwin-1.3.34/Lib/php4/std_string.i new file mode 100644 index 0000000..08a7cda --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/php4/std_string.i @@ -0,0 +1,73 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_string.i + * + * SWIG typemaps for std::string types + * ----------------------------------------------------------------------------- */ + +// ------------------------------------------------------------------------ +// std::string is typemapped by value +// This can prevent exporting methods which return a string +// in order for the user to modify it. +// However, I think I'll wait until someone asks for it... +// ------------------------------------------------------------------------ + +%include <exception.i> + +%{ +#include <string> +%} + +namespace std { + + %naturalvar string; + + class string; + + %typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) string %{ + $1 = ( Z_TYPE_PP($input) == IS_STRING ) ? 1 : 0; + %} + + %typemap(in) string %{ + convert_to_string_ex($input); + $1.assign(Z_STRVAL_PP($input), Z_STRLEN_PP($input)); + %} + + %typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) const string& %{ + $1 = ( Z_TYPE_PP($input) == IS_STRING ) ? 1 : 0; + %} + + %typemap(out) string %{ + ZVAL_STRINGL($result, const_cast<char*>($1.data()), $1.size(), 1); + %} + + %typemap(out) const string & %{ + ZVAL_STRINGL($result, const_cast<char*>($1->data()), $1->size(), 1); + %} + + %typemap(throws) string %{ + SWIG_PHP_Error(E_ERROR, (char *)$1.c_str()); + %} + + %typemap(throws) const string& %{ + SWIG_PHP_Error(E_ERROR, (char *)$1.c_str()); + %} + + /* These next two handle a function which takes a non-const reference to + * a std::string and modifies the string. */ + %typemap(in) string & (std::string temp) %{ + convert_to_string_ex($input); + temp.assign(Z_STRVAL_PP($input), Z_STRLEN_PP($input)); + $1 = &temp; + %} + + %typemap(argout) string & %{ + ZVAL_STRINGL(*($input), const_cast<char*>($1->data()), $1->size(), 1); + %} + + /* SWIG will apply the non-const typemap above to const string& without + * this more specific typemap. */ + %typemap(argout) const string & ""; +} diff --git a/devtools/swigwin-1.3.34/Lib/php4/std_vector.i b/devtools/swigwin-1.3.34/Lib/php4/std_vector.i new file mode 100644 index 0000000..fe084ac --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/php4/std_vector.i @@ -0,0 +1,132 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_vector.i + * + * SWIG typemaps for std::vector types + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +// ------------------------------------------------------------------------ +// std::vector +// +// The aim of all that follows would be to integrate std::vector with +// PHP as much as possible, namely, to allow the user to pass and +// be returned PHP lists. +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::vector<T>), f(const std::vector<T>&), f(const std::vector<T>*): +// the parameter being read-only, either a PHP sequence or a +// previously wrapped std::vector<T> can be passed. +// -- f(std::vector<T>&), f(std::vector<T>*): +// the parameter must be modified; therefore, only a wrapped std::vector +// can be passed. +// -- std::vector<T> f(): +// the vector is returned by copy; therefore, a PHP sequence of T:s +// is returned which is most easily used in other PHP functions +// -- std::vector<T>& f(), std::vector<T>* f(), const std::vector<T>& f(), +// const std::vector<T>* f(): +// the vector is returned by reference; therefore, a wrapped std::vector +// is returned +// ------------------------------------------------------------------------ + +%{ +#include <vector> +#include <algorithm> +#include <stdexcept> +%} + +// exported class + +namespace std { + + template<class T> class vector { + // add generic typemaps here + public: + vector(unsigned int size = 0); + unsigned int size() const; + bool empty() const; + void clear(); + %rename(push) push_back; + void push_back(const T& x); + %extend { + T pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty vector"); + T x = self->back(); + self->pop_back(); + return x; + } + T& get(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("vector index out of range"); + } + void set(int i, const T& x) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + (*self)[i] = x; + else + throw std::out_of_range("vector index out of range"); + } + } + }; + + + // specializations for built-ins + + %define specialize_std_vector(T) + template<> class vector<T> { + // add specialized typemaps here + public: + vector(unsigned int size = 0); + unsigned int size() const; + bool empty() const; + void clear(); + %rename(push) push_back; + void push_back(T x); + %extend { + T pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty vector"); + T x = self->back(); + self->pop_back(); + return x; + } + T get(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("vector index out of range"); + } + void set(int i, T x) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + (*self)[i] = x; + else + throw std::out_of_range("vector index out of range"); + } + } + }; + %enddef + + specialize_std_vector(bool); + specialize_std_vector(char); + specialize_std_vector(int); + specialize_std_vector(short); + specialize_std_vector(long); + specialize_std_vector(unsigned char); + specialize_std_vector(unsigned int); + specialize_std_vector(unsigned short); + specialize_std_vector(unsigned long); + specialize_std_vector(float); + specialize_std_vector(double); + +} + diff --git a/devtools/swigwin-1.3.34/Lib/php4/stl.i b/devtools/swigwin-1.3.34/Lib/php4/stl.i new file mode 100644 index 0000000..66b72e0 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/php4/stl.i @@ -0,0 +1,15 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * stl.i + * + * Initial STL definition. extended as needed in each language + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <std_string.i> +%include <std_vector.i> +%include <std_map.i> +%include <std_pair.i> + diff --git a/devtools/swigwin-1.3.34/Lib/php4/typemaps.i b/devtools/swigwin-1.3.34/Lib/php4/typemaps.i new file mode 100644 index 0000000..c388fdf --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/php4/typemaps.i @@ -0,0 +1,171 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * typemaps.i. + * + * SWIG Typemap library for PHP4. + * + * This library provides standard typemaps for modifying SWIG's behavior. + * With enough entries in this file, I hope that very few people actually + * ever need to write a typemap. + * + * Define macros to define the following typemaps: + * + * TYPE *INPUT. Argument is passed in as native variable by value. + * TYPE *OUTPUT. Argument is returned as an array from the function call. + * TYPE *INOUT. Argument is passed in by value, and out as part of returned list + * TYPE *REFERENCE. Argument is passed in as native variable with value + * semantics. Variable value is changed with result. + * Use like this: + * int foo(int *REFERENCE); + * + * $a = 0; + * $rc = foo($a); + * + * Even though $a looks like it's passed by value, + * its value can be changed by foo(). + * ----------------------------------------------------------------------------- */ + +%define double_typemap(TYPE) +%typemap(in) TYPE *INPUT(TYPE temp) +%{ + convert_to_double_ex($input); + temp = (TYPE) Z_DVAL_PP($input); + $1 = &temp; +%} +%typemap(argout) TYPE *INPUT ""; +%typemap(in,numinputs=0) TYPE *OUTPUT(TYPE temp) "$1 = &temp;"; +%typemap(argout,fragment="t_output_helper") TYPE *OUTPUT +{ + zval *o; + MAKE_STD_ZVAL(o); + ZVAL_DOUBLE(o,temp$argnum); + t_output_helper( &$result, o ); +} +%typemap(in) TYPE *REFERENCE (TYPE dvalue) +%{ + convert_to_double_ex($input); + dvalue = (TYPE) (*$input)->value.dval; + $1 = &dvalue; +%} +%typemap(argout) TYPE *REFERENCE +%{ + $1->value.dval = (double)(lvalue$argnum); + $1->type = IS_DOUBLE; +%} +%enddef + +%define int_typemap(TYPE) +%typemap(in) TYPE *INPUT(TYPE temp) +%{ + convert_to_long_ex($input); + temp = (TYPE) Z_LVAL_PP($input); + $1 = &temp; +%} +%typemap(argout) TYPE *INPUT ""; +%typemap(in,numinputs=0) TYPE *OUTPUT(TYPE temp) "$1 = &temp;"; +%typemap(argout,fragment="t_output_helper") TYPE *OUTPUT +{ + zval *o; + MAKE_STD_ZVAL(o); + ZVAL_LONG(o,temp$argnum); + t_output_helper( &$result, o ); +} +%typemap(in) TYPE *REFERENCE (TYPE lvalue) +%{ + convert_to_long_ex($input); + lvalue = (TYPE) (*$input)->value.lval; + $1 = &lvalue; +%} +%typemap(argout) TYPE *REFERENCE +%{ + (*$arg)->value.lval = (long)(lvalue$argnum); + (*$arg)->type = IS_LONG; +%} +%enddef + +double_typemap(float); +double_typemap(double); + +int_typemap(int); +int_typemap(short); +int_typemap(long); +int_typemap(unsigned int); +int_typemap(unsigned short); +int_typemap(unsigned long); +int_typemap(unsigned char); + +%typemap(in) float *INOUT = float *INPUT; +%typemap(in) double *INOUT = double *INPUT; + +%typemap(in) int *INOUT = int *INPUT; +%typemap(in) short *INOUT = short *INPUT; +%typemap(in) long *INOUT = long *INPUT; +%typemap(in) unsigned *INOUT = unsigned *INPUT; +%typemap(in) unsigned short *INOUT = unsigned short *INPUT; +%typemap(in) unsigned long *INOUT = unsigned long *INPUT; +%typemap(in) unsigned char *INOUT = unsigned char *INPUT; + +%typemap(argout) float *INOUT = float *OUTPUT; +%typemap(argout) double *INOUT= double *OUTPUT; + +%typemap(argout) int *INOUT = int *OUTPUT; +%typemap(argout) short *INOUT = short *OUTPUT; +%typemap(argout) long *INOUT= long *OUTPUT; +%typemap(argout) unsigned short *INOUT= unsigned short *OUTPUT; +%typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT; +%typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT; + +%typemap(in) char INPUT[ANY] ( char temp[$1_dim0] ) +%{ + convert_to_string_ex($input); + strncpy(temp,Z_LVAL_PP($input),$1_dim0); + $1 = temp; +%} +%typemap(in,numinputs=0) char OUTPUT[ANY] ( char temp[$1_dim0] ) + "$1 = temp;"; +%typemap(argout) char OUTPUT[ANY] +{ + zval *o; + MAKE_STD_ZVAL(o); + ZVAL_STRINGL(o,temp$argnum,$1_dim0); + t_output_helper( &$result, o ); +} + +%typemap(in,numinputs=0) void **OUTPUT (int force), + void *&OUTPUT (int force) +%{ + /* If they pass NULL by reference, make it into a void* + This bit should go in arginit if arginit support init-ing scripting args */ + if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0) { + /* So... we didn't get a ref or ptr, but we'll accept NULL by reference */ + if (!((*$input)->type==IS_NULL && PZVAL_IS_REF(*$input))) { + /* wasn't a pre/ref/thing, OR anything like an int thing */ + SWIG_PHP_Error(E_ERROR, "Type error in argument $arg of $symname."); + } + } + force=0; + if (arg1==NULL) { +#ifdef __cplusplus + ptr=new $*1_ltype; +#else + ptr=($*1_ltype) calloc(1,sizeof($*1_ltype)); +#endif + $1=&ptr; + /* have to passback arg$arg too */ + force=1; + } +%} + +%typemap(argout) void **OUTPUT, + void *&OUTPUT +%{ + if (force$argnum) { /* pass back arg$argnum through params ($arg) if we can */ + if (!PZVAL_IS_REF(*$arg)) { + SWIG_PHP_Error(E_WARNING, "Parameter $argnum of $symname wasn't passed by reference"); + } else { + SWIG_SetPointerZval(*$arg, (void *) ptr$argnum, $*1_descriptor, 1); + } + } +%} diff --git a/devtools/swigwin-1.3.34/Lib/php4/utils.i b/devtools/swigwin-1.3.34/Lib/php4/utils.i new file mode 100644 index 0000000..f724118 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/php4/utils.i @@ -0,0 +1,59 @@ + +%define CONVERT_BOOL_IN(lvar,t,invar) + convert_to_boolean_ex(invar); + lvar = (t) Z_LVAL_PP(invar); +%enddef + +%define CONVERT_INT_IN(lvar,t,invar) + convert_to_long_ex(invar); + lvar = (t) Z_LVAL_PP(invar); +%enddef + +%define CONVERT_INT_OUT(lvar,invar) + lvar = (t) Z_LVAL_PP(invar); +%enddef + +%define CONVERT_FLOAT_IN(lvar,t,invar) + convert_to_double_ex(invar); + lvar = (t) Z_DVAL_PP(invar); +%enddef + +%define CONVERT_CHAR_IN(lvar,t,invar) + convert_to_string_ex(invar); + lvar = (t) *Z_STRVAL_PP(invar); +%enddef + +%define CONVERT_STRING_IN(lvar,t,invar) + convert_to_string_ex(invar); + lvar = (t) Z_STRVAL_PP(invar); +%enddef + +%define %pass_by_val( TYPE, CONVERT_IN ) +%typemap(in) TYPE +%{ + CONVERT_IN($1,$1_ltype,$input); +%} +%enddef + +%fragment("t_output_helper","header") %{ +void +t_output_helper( zval **target, zval *o) { + if ( (*target)->type == IS_ARRAY ) { + /* it's already an array, just append */ + add_next_index_zval( *target, o ); + return; + } + if ( (*target)->type == IS_NULL ) { + REPLACE_ZVAL_VALUE(target,o,1); + return; + } + zval *tmp; + ALLOC_INIT_ZVAL(tmp); + *tmp = **target; + zval_copy_ctor(tmp); + array_init(*target); + add_next_index_zval( *target, tmp); + add_next_index_zval( *target, o); + +} +%} diff --git a/devtools/swigwin-1.3.34/Lib/pike/pike.swg b/devtools/swigwin-1.3.34/Lib/pike/pike.swg new file mode 100644 index 0000000..483ba76 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/pike/pike.swg @@ -0,0 +1,317 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * pike.swg + * + * Pike configuration module. + * ----------------------------------------------------------------------------- */ + +%insert(runtime) "swigrun.swg"; // Common C API type-checking code +%insert(runtime) "pikerun.swg"; // Pike run-time code + +%insert(runtime) %{ +#ifdef __cplusplus +extern "C" { +#endif +#include <global.h> +#include <module.h> +#include <interpret.h> +#ifdef __cplusplus +} +#endif +%} + +/* ----------------------------------------------------------------------------- + * standard typemaps + * ----------------------------------------------------------------------------- */ + +/* --- Input arguments --- */ + +/* Primitive datatypes. */ + +%typemap(in, pikedesc="tInt") + int, unsigned int, short, unsigned short, + long, unsigned long, char, signed char, unsigned char, + bool, enum SWIGTYPE, long long, unsigned long long +{ + if ($input.type != T_INT) + Pike_error("Bad argument: Expected an integer.\n"); + $1 = ($1_ltype) $input.u.integer; +} + +%typemap(in, pikedesc="tFloat") float, double { + if ($input.type != T_FLOAT) + Pike_error("Bad argument: Expected a float.\n"); + $1 = ($1_ltype) $input.u.float_number; +} + +%typemap(in, pikedesc="tStr") char *, char [ANY] { + if ($input.type != T_STRING) + Pike_error("Bad argument: Expected a string.\n"); + $1 = ($1_ltype) STR0($input.u.string); +} + +/* Pointers, references and arrays */ + +%typemap(in) SWIGTYPE *, + SWIGTYPE &, + SWIGTYPE [] + "SWIG_ConvertPtr($input.u.object, (void **) &$1, $1_descriptor, 1);" + +/* Void pointer. Accepts any kind of pointer */ +%typemap(in) void * "/* FIXME */"; + +/* Object passed by value. Convert to a pointer */ +%typemap(in) SWIGTYPE ($&1_ltype argp) "/* FIXME */"; + +/* Pointer to a class member */ +%typemap(in) SWIGTYPE (CLASS::*) "/* FIXME */"; + +/* Const primitive references. Passed by value */ + +%typemap(in, pikedesc="tInt") const int & (int temp), + const short & (short temp), + const long & (long temp), + const unsigned int & (unsigned int temp), + const unsigned short & (unsigned short temp), + const unsigned long & (unsigned long temp), + const char & (char temp), + const signed char & (signed char temp), + const unsigned char & (unsigned char temp), + const bool & (bool temp), + const long long & ($*1_ltype temp), + const unsigned long long & ($*1_ltype temp), + const enum SWIGTYPE & ($*1_ltype temp) +{ + if ($input.type != T_INT) + Pike_error("Bad argument: Expected an integer.\n"); + temp = ($*1_ltype) $input.u.integer; + $1 = &temp; +} + +%typemap(in, pikedesc="tFloat") const float & (float temp), + const double & (double temp) +{ + if ($input.type != T_FLOAT) + Pike_error("Bad argument: Expected a float.\n"); + temp = ($*1_ltype) $input.u.float_number; + $1 = &temp; +} + +/* ----------------------------------------------------------------------------- + * Output Typemaps + * ----------------------------------------------------------------------------- */ +%typemap(out, pikedesc="tInt") + int, unsigned int, + short, unsigned short, + long, unsigned long, + char, signed char, unsigned char, + bool, enum SWIGTYPE + "push_int($1);"; + +%typemap(out, pikedesc="tInt") long long "push_int64($1);"; +%typemap(out, pikedesc="tInt") unsigned long long "push_int64($1);"; +%typemap(out, pikedesc="tFloat") float, double "push_float($1);"; +%typemap(out, pikedesc="tStr") char * "push_text($1);"; + +/* Pointers, references, and arrays */ +%typemap(out, pikedesc="tObj") SWIGTYPE*, SWIGTYPE &, SWIGTYPE [] "push_object(SWIG_NewPointerObj((void *) $1, $1_descriptor, $owner));"; + +/* Void return value; don't push anything */ +%typemap(out, pikedesc="tVoid") void ""; + +/* Dynamic casts */ + +%typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC "/* FIXME */"; + +/* Member pointer */ +%typemap(out) SWIGTYPE (CLASS::*) "/* FIXME */"; + +/* Special typemap for character array return values */ +%typemap(out, pikedesc="tStr") char [ANY], const char [ANY] "push_text($1);"; + +/* Primitive types--return by value */ +%typemap(out, pikedesc="tObj") SWIGTYPE +#ifdef __cplusplus +{ + $&1_ltype resultptr; + resultptr = new $1_ltype(($1_ltype &) $1); + push_object(SWIG_NewPointerObj((void *) resultptr, $&1_descriptor, 1)); +} +#else +{ + $&1_ltype resultptr; + resultptr = ($&1_ltype) malloc(sizeof($1_type)); + memmove(resultptr, &$1, sizeof($1_type)); + push_object(SWIG_NewPointerObj((void *) resultptr, $&1_descriptor, 1)); +} +#endif + +/* References to primitive types. Return by value */ + +%typemap(out, pikedesc="tInt") const int &, const unsigned int &, + const short &, const unsigned short &, + const long &, const unsigned long &, + const char &, const signed char &, const unsigned char &, + const bool &, + const long long &, const unsigned long long &, + const enum SWIGTYPE & ($*1_ltype temp) + "push_int(*($1));"; + +%typemap(out, pikedesc="tFloat") const float &, const double & "push_float(*($1));"; + +/************************ Constant Typemaps *****************************/ + +%typemap(constant) + int, unsigned int, + short, unsigned short, + long, unsigned long, + signed char, unsigned char, + bool, enum SWIGTYPE, + long long, unsigned long long + "add_integer_constant(\"$symname\", $1, 0);"; + +%typemap(constant) char + "add_integer_constant(\"$symname\", '$1', 0);"; + +%typemap(constant) long long, unsigned long long + "add_integer_constant(\"$symname\", $1, 0);"; + +%typemap(constant) float, double + "add_float_constant(\"$symname\", $1, 0);"; + +%typemap(constant) char * + "add_string_constant(\"$symname\", \"$1\", 0);"; + +/* ------------------------------------------------------------ + * String & length + * ------------------------------------------------------------ */ + +%typemap(in, pikedesc="tStr") (char *STRING, int LENGTH) { + if ($input.type != T_STRING) + Pike_error("Bad argument: Expected a string.\n"); + $1 = ($1_ltype) STR0($input.u.string); + $2 = ($2_ltype) $input.u.string->length; +} + +/* ------------------------------------------------------------ + * ANSI C typemaps + * ------------------------------------------------------------ */ + +%typemap(in, pikedesc="tInt") size_t { + if ($input.type != T_INT) + Pike_error("Bad argument: Expected an integer.\n"); + $1 = ($1_ltype) $input.u.integer; +} + +%typemap(out) size_t = long; + +/* ------------------------------------------------------------ + * Typechecking rules + * ------------------------------------------------------------ */ + +%typecheck(SWIG_TYPECHECK_INTEGER) + int, short, long, + unsigned int, unsigned short, unsigned long, + signed char, unsigned char, + long long, unsigned long long, + const int &, const short &, const long &, + const unsigned int &, const unsigned short &, const unsigned long &, + const long long &, const unsigned long long &, + enum SWIGTYPE, enum SWIGTYPE &, + bool, const bool & +{ + $1 = ($input.type == T_INT) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_DOUBLE) + float, double, + const float &, const double & +{ + $1 = (($input.type == T_FLOAT) || ($input.type == T_INT)) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_CHAR) char { + $1 = ($input.type == T_INT) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_STRING) char * { + $1 = ($input.type == T_STRING) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] { + void *ptr; + if (SWIG_ConvertPtr($input.u.object, (void **) &ptr, $1_descriptor, 0) == -1) { + $1 = 0; + } else { + $1 = 1; + } +} + +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { + void *ptr; + if (SWIG_ConvertPtr($input.u.object, (void **) &ptr, $&1_descriptor, 0) == -1) { + $1 = 0; + } else { + $1 = 1; + } +} + +%typecheck(SWIG_TYPECHECK_VOIDPTR) void * { + void *ptr; + if (SWIG_ConvertPtr($input.u.object, (void **) &ptr, 0, 0) == -1) { + $1 = 0; + } else { + $1 = 1; + } +} + +/* ------------------------------------------------------------ + * Overloaded operator support + * ------------------------------------------------------------ */ + +#ifdef __cplusplus +%rename("`+") *::operator+; +%rename("`-") *::operator-; +%rename("`*") *::operator*; +%rename("`/") *::operator/; +%rename("`%") *::operator%; +%rename("`<<") *::operator<<; +%rename("`>>") *::operator>>; +%rename("`&") *::operator&; +%rename("`|") *::operator|; +%rename("`^") *::operator^; +%rename("`~") *::operator~; +%rename("`<") *::operator<; +%rename("`>") *::operator>; +%rename("`==") *::operator==; + +/* Special cases */ +%rename("`()") *::operator(); + +#endif + +/* ------------------------------------------------------------ + * The start of the Pike initialization function + * ------------------------------------------------------------ */ + +%init "swiginit.swg" + +%init %{ +#ifdef __cplusplus +extern "C" +#endif +PIKE_MODULE_EXIT {} + +#ifdef __cplusplus +extern "C" +#endif +PIKE_MODULE_INIT +{ + struct program *pr; + SWIG_InitializeModule(0); +%} + +/* pike keywords */ +%include <pikekw.swg> diff --git a/devtools/swigwin-1.3.34/Lib/pike/pikekw.swg b/devtools/swigwin-1.3.34/Lib/pike/pikekw.swg new file mode 100644 index 0000000..85fd091 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/pike/pikekw.swg @@ -0,0 +1,55 @@ +#ifndef PIKE_PIKEKW_SWG_ +#define PIKE_PIKEKW_SWG_ + +/* Warnings for Pike keywords */ +#define PIKEKW(x) %namewarn("314:" #x " is a pike keyword") #x + +/* + from + http://www.http://docs.linux.cz/pike/tutorial_C.html + +*/ + + +PIKEKW(array); +PIKEKW(break); +PIKEKW(case); +PIKEKW(catch); +PIKEKW(continue); +PIKEKW(default); +PIKEKW(do); +PIKEKW(else); +PIKEKW(float); +PIKEKW(for); +PIKEKW(foreach); +PIKEKW(function); +PIKEKW(gauge); +PIKEKW(if); +PIKEKW(inherit); +PIKEKW(inline); +PIKEKW(int); +PIKEKW(lambda); +PIKEKW(mapping); +PIKEKW(mixed); +PIKEKW(multiset); +PIKEKW(nomask); +PIKEKW(object); +PIKEKW(predef); +PIKEKW(private); +PIKEKW(program); +PIKEKW(protected); +PIKEKW(public); +PIKEKW(return); +PIKEKW(sscanf); +PIKEKW(static); +PIKEKW(string); +PIKEKW(switch); +PIKEKW(typeof); +PIKEKW(varargs); +PIKEKW(void); +PIKEKW(while); + + +#undef PIKEKW + +#endif //PIKE_PIKEKW_SWG_ diff --git a/devtools/swigwin-1.3.34/Lib/pike/pikerun.swg b/devtools/swigwin-1.3.34/Lib/pike/pikerun.swg new file mode 100644 index 0000000..875fcf4 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/pike/pikerun.swg @@ -0,0 +1,73 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * pikerun.swg + * + * This file contains the runtime support for Pike modules + * and includes code for managing global variables and pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#endif +#include "object.h" +#include "program.h" +#ifdef __cplusplus +} +#endif + +/* Stores information about a wrapped object */ +typedef struct swig_object_wrapper { + void *self; + swig_type_info *type; +} swig_object_wrapper; + +#ifdef THIS +#undef THIS +#endif +#define THIS (((swig_object_wrapper *) Pike_fp->current_storage)->self) + +#define SWIG_ConvertPtr SWIG_Pike_ConvertPtr +#define SWIG_NewPointerObj SWIG_Pike_NewPointerObj +#define SWIG_GetModule(clientdata) SWIG_Pike_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Pike_SetModule(pointer) + +/* These need to be filled in before type sharing between modules will work */ +static swig_module_info *SWIG_Pike_GetModule() { + return 0; +} + +static void SWIG_Pike_SetModule(swig_module_info *pointer) { + +} + +/* Convert a pointer value */ +static int +SWIG_Pike_ConvertPtr(struct object *obj, void **ptr, swig_type_info *ty, int flags) { + struct program *pr; + swig_cast_info *tc; + swig_object_wrapper *obj_wrapper; + + if (ty) { + pr = (struct program *) ty->clientdata; + obj_wrapper = (swig_object_wrapper *) get_storage(obj, pr); + if (obj_wrapper && obj_wrapper->type) { + tc = SWIG_TypeCheckStruct(obj_wrapper->type, ty); + if (tc) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc, obj_wrapper->self, &newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + return 0; + } + } + } + return -1; +} + +/* Create a new pointer object */ +static struct object * +SWIG_Pike_NewPointerObj(void *ptr, swig_type_info *type, int own) { + return 0; +} diff --git a/devtools/swigwin-1.3.34/Lib/pike/std_string.i b/devtools/swigwin-1.3.34/Lib/pike/std_string.i new file mode 100644 index 0000000..ca1fad8 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/pike/std_string.i @@ -0,0 +1,63 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_string.i + * + * SWIG typemaps for std::string + * ----------------------------------------------------------------------------- */ + +%{ +#include <string> +%} + +namespace std { + + %naturalvar string; + + class string; + + /* Overloading check */ + + %typemap(typecheck) string = char *; + %typemap(typecheck) const string & = char *; + + %typemap(in, pikedesc="tStr") string { + if ($input.type != T_STRING) + Pike_error("Bad argument: Expected a string.\n"); + $1.assign(STR0($input.u.string)); + } + + %typemap(in, pikedesc="tStr") const string & (std::string temp) { + if ($input.type != T_STRING) + Pike_error("Bad argument: Expected a string.\n"); + temp.assign(STR0($input.u.string)); + $1 = &temp; + } + + %typemap(out, pikedesc="tStr") string "push_text($1.c_str());"; + + %typemap(out, pikedesc="tStr") const string & "push_text($1->c_str());"; + + %typemap(directorin) string, const string &, string & "$1_name.c_str()"; + + %typemap(directorin) string *, const string * "$1_name->c_str()"; + + %typemap(directorout) string { + if ($input.type == T_STRING) + $result.assign(STR0($input.u.string)); + else + throw Swig::DirectorTypeMismatchException("string expected"); + } + + %typemap(directorout) const string & (std::string temp) { + if ($input.type == T_STRING) { + temp.assign(STR0($input.u.string)); + $result = &temp; + } else { + throw Swig::DirectorTypeMismatchException("string expected"); + } + } + +} + diff --git a/devtools/swigwin-1.3.34/Lib/pointer.i b/devtools/swigwin-1.3.34/Lib/pointer.i new file mode 100644 index 0000000..16e11b7 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/pointer.i @@ -0,0 +1,14 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * pointer.i + * ----------------------------------------------------------------------------- */ + + +%echo "pointer.i is deprecated. Use cpointer.i instead." +%echo "See http://www.swig.org/Doc1.3/Library.html" + + + + diff --git a/devtools/swigwin-1.3.34/Lib/python/Makefile.in b/devtools/swigwin-1.3.34/Lib/python/Makefile.in new file mode 100644 index 0000000..3243b3d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/Makefile.in @@ -0,0 +1,135 @@ +# --------------------------------------------------------------- +# SWIG Python Makefile +# +# This file can be used to build various Python extensions with SWIG. +# By default this file is set up for dynamic loading, but it can +# be easily customized for static extensions by modifying various +# portions of the file. +# +# SRCS = C source files +# CXXSRCS = C++ source files +# OBJCSRCS = Objective-C source files +# OBJS = Additional .o files (compiled previously) +# INTERFACE = SWIG interface file +# TARGET = Name of target module or executable +# +# Many portions of this file were created by the SWIG configure +# script and should already reflect your machine. +#---------------------------------------------------------------- + +SRCS = +CXXSRCS = +OBJCSRCS = +OBJS = +INTERFACE = +WRAPFILE = $(INTERFACE:.i=_wrap.c) +WRAPOBJ = $(INTERFACE:.i=_wrap.o) +TARGET = module@SO@ # Use this kind of target for dynamic loading +#TARGET = mypython # Use this target for static linking + +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +CC = @CC@ +CXX = @CXX@ +OBJC = @CC@ -Wno-import # -Wno-import needed for gcc +CFLAGS = +INCLUDES = +LIBS = + +# SWIG Options +# SWIG = location of the SWIG executable +# SWIGOPT = SWIG compiler options +# SWIGCC = Compiler used to compile the wrapper file + +SWIG = $(exec_prefix)/bin/swig +SWIGOPT = -python +SWIGCC = $(CC) + +# SWIG Library files. Uncomment if rebuilding the Python interpreter +#SWIGLIB = -lembed.i + +# Rules for creating .o files from source. + +COBJS = $(SRCS:.c=.o) +CXXOBJS = $(CXXSRCS:.cxx=.o) +OBJCOBJS = $(OBJCSRCS:.m=.o) +ALLOBJS = $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(OBJS) + +# Command that will be used to build the final extension. +BUILD = $(SWIGCC) + +# Uncomment the following if you are using dynamic loading +CCSHARED = @CCSHARED@ +BUILD = @LDSHARED@ + +# Uncomment the following if you are using dynamic loading with C++ and +# need to provide additional link libraries (this is not always required). + +#DLL_LIBS = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \ + -L/usr/local/lib -lg++ -lstdc++ -lgcc + +# X11 installation (needed if rebuilding Python + tkinter) + +XLIB = @XLIBSW@ +XINCLUDE = @XINCLUDES@ + +# Python installation + +PY_INCLUDE = -DHAVE_CONFIG_H @PYINCLUDE@ +PY_LIB = @PYLIB@ + +# Tcl installation. Needed if rebuilding Python with tkinter. + +TCL_INCLUDE = @TCLINCLUDE@ +TCL_LIB = @TCLLIB@ + +# Build libraries (needed for static builds) + +LIBM = @LIBM@ +LIBC = @LIBC@ +SYSLIBS = $(LIBM) $(LIBC) @LIBS@ + +# Build options (uncomment only one these) + +#TKINTER = $(TCL_LIB) -ltk -ltcl $(XLIB) +BUILD_LIBS = $(LIBS) # Dynamic loading +#BUILD_LIBS = $(PY_LIB) @PYLINK@ $(TKINTER) $(LIBS) $(SYSLIBS) + +# Compilation rules for non-SWIG components + +.SUFFIXES: .c .cxx .m + +.c.o: + $(CC) $(CCSHARED) $(CFLAGS) $(INCLUDES) -c $< + +.cxx.o: + $(CXX) $(CCSHARED) $(CXXFLAGS) $(INCLUDES) -c $< + +.m.o: + $(OBJC) $(CCSHARED) $(CFLAGS) $(INCLUDES) -c $< + + +# ---------------------------------------------------------------------- +# Rules for building the extension +# ---------------------------------------------------------------------- + +all: $(TARGET) + +# Convert the wrapper file into an object file + +$(WRAPOBJ) : $(WRAPFILE) + $(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(WRAPFILE) $(INCLUDES) $(PY_INCLUDE) + +$(WRAPFILE) : $(INTERFACE) + $(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIB) $(INTERFACE) + +$(TARGET): $(WRAPOBJ) $(ALLOBJS) + $(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET) + +clean: + rm -f $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(WRAPOBJ) $(WRAPFILE) $(TARGET) + + + + diff --git a/devtools/swigwin-1.3.34/Lib/python/README b/devtools/swigwin-1.3.34/Lib/python/README new file mode 100644 index 0000000..70fca47 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/README @@ -0,0 +1,105 @@ +/* ----------------------------------------------------------------------------- + * + * User interfaces: include these ones as needed + * + * ----------------------------------------------------------------------------- */ + +/* ----------------------------------------------------------------------------- + * Special types and user helpers + * ----------------------------------------------------------------------------- */ + +argcargv.i Handler for (int argc, char **argv) +attribute.i Convert a pair of set/get methods into a "native" python attribute +ccomplex.i C99 complex type +complex.i C99 or C++ complex type +cstring.i Various forms of C character string handling +cwstring.i Various forms of C wchar_t string handling +embed.i embedding the Python interpreter in something else +embed15.i embedding the Python interpreter in something else +file.i FILE C type +implicit.i Allow the use of implicit C++ constructors +wchar.i wchar_t C type + +/* ----------------------------------------------------------------------------- + * C++ STD + STL + * ----------------------------------------------------------------------------- */ + +std_alloc.i allocator +std_basic_string.i basic string +std_char_traits.i char traits +std_complex.i complex +std_deque.i deque +std_except.i exceptions +std_ios.i ios +std_iostream.i istream/ostream +std_list.i list +std_map.i map +std_multimap.i multimap +std_multiset.i multiset +std_pair.i pair +std_set.i set +std_sstream.i string stream +std_streambuf.i streambuf +std_string.i string +std_vector.i vector +std_wios.i wios +std_wiostream.i wistream/wostream +std_wsstream.i wstring stream +std_wstreambuf.i wstreambuf +std_wstring.i wstring + + + +/* ----------------------------------------------------------------------------- +/* + * Implementation files: don't look at them unless you are realy drunk + * + * ----------------------------------------------------------------------------- */ + +/* ----------------------------------------------------------------------------- + * Basic files + * ----------------------------------------------------------------------------- */ + +python.swg Main language file, it just includes what is needed. +pyuserdir.swg User visible directives (%pythonnondynamic, etc) +pymacros.swg Internal macros used for typemaps +pyfragments.swg Allow the user to overload the default fragments +pyopers.swg Python operations (+=, *=, etc) +pythonkw.swg Python keywords and special names +pyinit.swg Python Init method + +/* ----------------------------------------------------------------------------- + * The runtime part + * ----------------------------------------------------------------------------- */ + +pyruntime.swg Main runtime file definition +pyapi.swg SWIG/Pyton API declarations +pyrun.swg Python run-time code + +/* ----------------------------------------------------------------------------- + * Internal typemap specializations + * ----------------------------------------------------------------------------- */ + +pyswigtype.swg SWIGTYPE +pystrings.swg Char strings (char *) +pywstrings.swg Wchar Strings (wchar_t *) +pyprimtypes.swg Primitive types (shot,int,double,etc) +pycomplex.swg PyComplex and helper for C/C++ complex types +pydocs.swg Typemaps documentation + +/* ----------------------------------------------------------------------------- + * C++ STD + STL + * ----------------------------------------------------------------------------- */ + +pycontainer.swg python container iterators +std_common.i general common code for the STD/STL implementation +std_container.i general common code for the STD/STL containers + + +/*----------------------------------------------------------------------------- + * Backward compatibility and deprecated + * ----------------------------------------------------------------------------- */ + +std_vectora.i vector + allocator (allocators are now supported in STD/STL) +typemaps.i old in/out typemaps (doen't need to be included) +defarg.swg for processing default arguments with shadow classes diff --git a/devtools/swigwin-1.3.34/Lib/python/argcargv.i b/devtools/swigwin-1.3.34/Lib/python/argcargv.i new file mode 100644 index 0000000..d5d008a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/argcargv.i @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------ + * --- Argc & Argv --- + * ------------------------------------------------------------ */ + +%fragment("SWIG_AsArgcArgv","header",fragment="SWIG_AsCharPtrAndSize") { +SWIGINTERN int +SWIG_AsArgcArgv(PyObject *input, + swig_type_info *ppchar_info, + size_t *argc, char ***argv, int *owner) +{ + void *vptr; + int res = SWIG_ConvertPtr(input, &vptr, ppchar_info, 0); + if (!SWIG_IsOK(res)) { + int list = 0; + PyErr_Clear(); + list = PyList_Check(input); + if (list || PyTuple_Check(input)) { + size_t i = 0; + size_t size = list ? PyList_Size(input) : PyTuple_Size(input); + if (argc) *argc = size; + if (argv) { + *argv = %new_array(size + 1, char*); + for (; i < size; ++i) { + PyObject *obj = list ? PyList_GetItem(input,i) : PyTuple_GetItem(input,i); + char *cptr = 0; size_t sz = 0; int alloc = 0; + res = SWIG_AsCharPtrAndSize(obj, &cptr, &sz, &alloc); + if (SWIG_IsOK(res)) { + if (cptr && sz) { + (*argv)[i] = (alloc == SWIG_NEWOBJ) ? cptr : %new_copy_array(cptr, sz, char); + } else { + (*argv)[i] = 0; + } + } else { + return SWIG_TypeError; + } + } + (*argv)[i] = 0; + if (owner) *owner = 1; + } else { + for (; i < size; ++i) { + PyObject *obj = list ? PyList_GetItem(input,i) : PyTuple_GetItem(input,i); + res = SWIG_AsCharPtrAndSize(obj, 0, 0, 0); + if (!SWIG_IsOK(res)) return SWIG_TypeError; + } + if (owner) *owner = 0; + } + return SWIG_OK; + } else { + return SWIG_TypeError; + } + } else { + /* seems dangerous, but the user asked for it... */ + size_t i = 0; + if (argv) { while (*argv[i] != 0) ++i;} + if (argc) *argc = i; + if (owner) *owner = 0; + return SWIG_OK; + } +} +} + +/* + This typemap works with either a char**, a python list or a python + tuple + */ + +%typemap(in,noblock=0,fragment="SWIG_AsArgcArgv") (int ARGC, char **ARGV) (int res,char **argv = 0, size_t argc = 0, int owner= 0) { + res = SWIG_AsArgcArgv($input, $descriptor(char**), &argc, &argv, &owner); + if (!SWIG_IsOK(res)) { + $1 = 0; $2 = 0; + %argument_fail(SWIG_TypeError, "int ARGC, char **ARGV", $symname, $argnum); + } else { + $1 = %static_cast(argc,$1_ltype); + $2 = %static_cast(argv, $2_ltype); + } +} + +%typemap(typecheck, precedence=SWIG_TYPECHECK_STRING_ARRAY) (int ARGC, char **ARGV) { + int res = SWIG_AsArgcArgv($input, $descriptor(char**), 0, 0, 0); + $1 = SWIG_IsOK(res); +} + +%typemap(freearg,noblock=1) (int ARGC, char **ARGV) { + if (owner$argnum) { + size_t i = argc$argnum; + while (i) { + %delete_array(argv$argnum[--i]); + } + %delete_array(argv$argnum); + } +} + diff --git a/devtools/swigwin-1.3.34/Lib/python/attribute.i b/devtools/swigwin-1.3.34/Lib/python/attribute.i new file mode 100644 index 0000000..779716c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/attribute.i @@ -0,0 +1 @@ +%include <typemaps/attribute.swg> diff --git a/devtools/swigwin-1.3.34/Lib/python/boost_shared_ptr.i b/devtools/swigwin-1.3.34/Lib/python/boost_shared_ptr.i new file mode 100644 index 0000000..c56196f --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/boost_shared_ptr.i @@ -0,0 +1,207 @@ +%include <shared_ptr.i> + +%define SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...) + +%naturalvar TYPE; +%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; + +// destructor mods +%feature("unref") TYPE +"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter<SWIG_null_deleter>(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" + "(void)arg1; delete smartarg1;" + +%feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > } + +// TODO: +// varout varin typemaps + +// plain value +%typemap(in) CONST TYPE (void *argp, int res = 0) { + int newmem = 0; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (!argp) { + %argument_nullref("$type", $symname, $argnum); + } else { + $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); + if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + } +} +%typemap(out) CONST TYPE { + %set_output(SWIG_NewPointerObj(new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +// plain pointer +%typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) { + int newmem = 0; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (newmem & SWIG_CAST_NEW_MEMORY) { + tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + $1 = %const_cast(tempshared.get(), $1_ltype); + } else { + smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); + } +} + +%typemap(out, fragment="SWIG_null_deleter") CONST TYPE * { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >* smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; + %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +// plain reference +%typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { + int newmem = 0; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (!argp) { %argument_nullref("$type", $symname, $argnum); } + if (newmem & SWIG_CAST_NEW_MEMORY) { + tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + $1 = %const_cast(tempshared.get(), $1_ltype); + } else { + $1 = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype); + } +} +%typemap(out, fragment="SWIG_null_deleter") CONST TYPE & { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >* smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); + %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +// plain pointer by reference +%typemap(in) CONST TYPE *& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { + int newmem = 0; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (newmem & SWIG_CAST_NEW_MEMORY) { + tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + temp = %const_cast(tempshared.get(), $*1_ltype); + } else { + temp = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $*1_ltype); + } + $1 = &temp; +} +%typemap(out, fragment="SWIG_null_deleter") CONST TYPE *& { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >* smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); + %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +// shared_ptr by value +%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) { + int newmem = 0; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (argp) $1 = *(%reinterpret_cast(argp, $<ype)); + if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); +} + +%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >* smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; + %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +// shared_ptr by reference +%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) { + int newmem = 0; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } +/* + if (argp) tempshared = *%reinterpret_cast(argp, $ltype); + if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $ltype); + $1 = &tempshared; +*/ + if (newmem & SWIG_CAST_NEW_MEMORY) { + if (argp) tempshared = *%reinterpret_cast(argp, $ltype); + delete %reinterpret_cast(argp, $ltype); + $1 = &tempshared; + } else { + $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; + } +} +%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >* smartresult = *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; + %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +// shared_ptr by pointer +%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) { + int newmem = 0; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (newmem & SWIG_CAST_NEW_MEMORY) { + if (argp) tempshared = *%reinterpret_cast(argp, $ltype); + delete %reinterpret_cast(argp, $ltype); + $1 = &tempshared; + } else { + $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; + } +} +%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >* smartresult = $1 && *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; + %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); + if ($owner) delete $1; +} + +// shared_ptr by pointer reference +%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (void *argp, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, $*1_ltype temp = 0) { + int newmem = 0; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (argp) tempshared = *%reinterpret_cast(argp, $*ltype); + if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype); + temp = &tempshared; + $1 = &temp; +} +%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >* smartresult = *$1 && **$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; + %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); +} + +// Typecheck typemaps +// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting +// function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain. +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) + CONST TYPE, + CONST TYPE &, + CONST TYPE *, + CONST TYPE *&, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { + int res = SWIG_ConvertPtr($input, 0, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), 0); + $1 = SWIG_CheckState(res); +} + + +// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug +%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ +#error "typemaps for $1_type not available" +%} +%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ +#error "typemaps for $1_type not available" +%} + + +%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; +%enddef + diff --git a/devtools/swigwin-1.3.34/Lib/python/carrays.i b/devtools/swigwin-1.3.34/Lib/python/carrays.i new file mode 100644 index 0000000..8d6d440 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/carrays.i @@ -0,0 +1,9 @@ +%define %array_class(TYPE,NAME) + %array_class_wrap(TYPE,NAME,__getitem__,__setitem__) +%enddef + +%include <typemaps/carrays.swg> + + + + diff --git a/devtools/swigwin-1.3.34/Lib/python/ccomplex.i b/devtools/swigwin-1.3.34/Lib/python/ccomplex.i new file mode 100644 index 0000000..30f797d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/ccomplex.i @@ -0,0 +1,29 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * ccomplex.i + * + * C complex typemaps + * ISO C99: 7.3 Complex arithmetic <complex.h> + * ----------------------------------------------------------------------------- */ + + +%include <pycomplex.swg> + +%{ +#include <complex.h> +%} + + +/* C complex constructor */ +#define CCplxConst(r, i) ((r) + I*(i)) + +%swig_cplxflt_convn(float complex, CCplxConst, creal, cimag); +%swig_cplxdbl_convn(double complex, CCplxConst, creal, cimag); +%swig_cplxdbl_convn(complex, CCplxConst, creal, cimag); + +/* declaring the typemaps */ +%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float complex); +%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double complex); +%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex); diff --git a/devtools/swigwin-1.3.34/Lib/python/cdata.i b/devtools/swigwin-1.3.34/Lib/python/cdata.i new file mode 100644 index 0000000..3679659 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/cdata.i @@ -0,0 +1 @@ +%include <typemaps/cdata.swg> diff --git a/devtools/swigwin-1.3.34/Lib/python/cmalloc.i b/devtools/swigwin-1.3.34/Lib/python/cmalloc.i new file mode 100644 index 0000000..248f06b --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/cmalloc.i @@ -0,0 +1 @@ +%include <typemaps/cmalloc.swg> diff --git a/devtools/swigwin-1.3.34/Lib/python/cni.i b/devtools/swigwin-1.3.34/Lib/python/cni.i new file mode 100644 index 0000000..10a1403 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/cni.i @@ -0,0 +1,2 @@ +%include <gcj/cni.i> +%include <jstring.i> diff --git a/devtools/swigwin-1.3.34/Lib/python/complex.i b/devtools/swigwin-1.3.34/Lib/python/complex.i new file mode 100644 index 0000000..4c3b3c5 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/complex.i @@ -0,0 +1,6 @@ +#ifdef __cplusplus +%include <std_complex.i> +#else +%include <ccomplex.i> +#endif + diff --git a/devtools/swigwin-1.3.34/Lib/python/cpointer.i b/devtools/swigwin-1.3.34/Lib/python/cpointer.i new file mode 100644 index 0000000..d824792 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/cpointer.i @@ -0,0 +1 @@ +%include <typemaps/cpointer.swg> diff --git a/devtools/swigwin-1.3.34/Lib/python/cstring.i b/devtools/swigwin-1.3.34/Lib/python/cstring.i new file mode 100644 index 0000000..ede9c59 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/cstring.i @@ -0,0 +1 @@ +%include <typemaps/cstring.swg> diff --git a/devtools/swigwin-1.3.34/Lib/python/cwstring.i b/devtools/swigwin-1.3.34/Lib/python/cwstring.i new file mode 100644 index 0000000..2824d9c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/cwstring.i @@ -0,0 +1,3 @@ +%include <pywstrings.swg> +%include <typemaps/cwstring.swg> + diff --git a/devtools/swigwin-1.3.34/Lib/python/defarg.swg b/devtools/swigwin-1.3.34/Lib/python/defarg.swg new file mode 100644 index 0000000..10c9916 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/defarg.swg @@ -0,0 +1,37 @@ +/* This file defines an internal function for processing default arguments + with proxy classes. + + There seems to be no straightforward way to write proxy functions + involving default arguments. For example : + + def foo(arg1,arg2,*args): + proxyc.foo(arg1,arg2,args) + + This fails because args is now a tuple and SWIG doesn't know what to + do with it. + + This file allows a different approach : + + def foo(arg1,arg2,*args): + proxyc.__call_defarg(proxyc.foo,(arg1,arg2,)+args) + + Basically, we form a new tuple from the object, call this special + __call_defarg method and it passes control to the real wrapper function. + An ugly hack, but it works. +*/ + +SWIGINTERN PyObject *swig_call_defargs(PyObject *self, PyObject *args) { + PyObject *func; + PyObject *parms; + + if (!PyArg_ParseTuple(args,"OO",&func,&parms)) + return NULL; + + if (!PyCallable_Check(func)) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(PyExc_TypeError, "__call_defarg : Need a callable object!"); + SWIG_PYTHON_THREAD_END_BLOCK; + return NULL; + } + return PyEval_CallObject(func,parms); +} diff --git a/devtools/swigwin-1.3.34/Lib/python/director.swg b/devtools/swigwin-1.3.34/Lib/python/director.swg new file mode 100644 index 0000000..176ee33 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/director.swg @@ -0,0 +1,482 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * director.swg + * + * This file contains support for director classes that proxy + * method calls from C++ to Python extensions. + * ----------------------------------------------------------------------------- */ + +#ifndef SWIG_DIRECTOR_PYTHON_HEADER_ +#define SWIG_DIRECTOR_PYTHON_HEADER_ + +#ifdef __cplusplus + +#include <string> +#include <iostream> +#include <exception> +#include <vector> +#include <map> + + +/* + Use -DSWIG_PYTHON_DIRECTOR_NO_VTABLE if you don't want to generate a 'virtual + table', and avoid multiple GetAttr calls to retrieve the python + methods. +*/ + +#ifndef SWIG_PYTHON_DIRECTOR_NO_VTABLE +#ifndef SWIG_PYTHON_DIRECTOR_VTABLE +#define SWIG_PYTHON_DIRECTOR_VTABLE +#endif +#endif + + + +/* + Use -DSWIG_DIRECTOR_NO_UEH if you prefer to avoid the use of the + Undefined Exception Handler provided by swift +*/ +#ifndef SWIG_DIRECTOR_NO_UEH +#ifndef SWIG_DIRECTOR_UEH +#define SWIG_DIRECTOR_UEH +#endif +#endif + + +/* + Use -DSWIG_DIRECTOR_STATIC if you prefer to avoid the use of the + 'Swig' namespace. This could be usefull for multi-modules projects. +*/ +#ifdef SWIG_DIRECTOR_STATIC +/* Force anonymous (static) namespace */ +#define Swig +#endif + + +/* + Use -DSWIG_DIRECTOR_NORTTI if you prefer to avoid the use of the + native C++ RTTI and dynamic_cast<>. But be aware that directors + could stop working when using this option. +*/ +#ifdef SWIG_DIRECTOR_NORTTI +/* + When we don't use the native C++ RTTI, we implement a minimal one + only for Directors. +*/ +# ifndef SWIG_DIRECTOR_RTDIR +# define SWIG_DIRECTOR_RTDIR +#include <map> + +namespace Swig { + class Director; + SWIGINTERN std::map<void*,Director*>& get_rtdir_map() { + static std::map<void*,Director*> rtdir_map; + return rtdir_map; + } + + SWIGINTERNINLINE void set_rtdir(void *vptr, Director *rtdir) { + get_rtdir_map()[vptr] = rtdir; + } + + SWIGINTERNINLINE Director *get_rtdir(void *vptr) { + std::map<void*,Director*>::const_iterator pos = get_rtdir_map().find(vptr); + Director *rtdir = (pos != get_rtdir_map().end()) ? pos->second : 0; + return rtdir; + } +} +# endif /* SWIG_DIRECTOR_RTDIR */ + +# define SWIG_DIRECTOR_CAST(Arg) Swig::get_rtdir(static_cast<void*>(Arg)) +# define SWIG_DIRECTOR_RGTR(Arg1, Arg2) Swig::set_rtdir(static_cast<void*>(Arg1), Arg2) + +#else + +# define SWIG_DIRECTOR_CAST(Arg) dynamic_cast<Swig::Director*>(Arg) +# define SWIG_DIRECTOR_RGTR(Arg1, Arg2) + +#endif /* SWIG_DIRECTOR_NORTTI */ + +extern "C" { + struct swig_type_info; +} + +namespace Swig { + + /* memory handler */ + struct GCItem + { + virtual ~GCItem() = 0; + + virtual int get_own() const + { + return 0; + } + }; + + GCItem::~GCItem() + { + } + + struct GCItem_var + { + GCItem_var(GCItem *item = 0) : _item(item) + { + } + + GCItem_var& operator=(GCItem *item) + { + GCItem *tmp = _item; + _item = item; + delete tmp; + return *this; + } + + ~GCItem_var() + { + delete _item; + } + + GCItem * operator->() const + { + return _item; + } + + private: + GCItem *_item; + }; + + struct GCItem_Object : GCItem + { + GCItem_Object(int own) : _own(own) + { + } + + virtual ~GCItem_Object() + { + } + + int get_own() const + { + return _own; + } + + private: + int _own; + }; + + template <typename Type> + struct GCItem_T : GCItem + { + GCItem_T(Type *ptr) : _ptr(ptr) + { + } + + virtual ~GCItem_T() + { + delete _ptr; + } + + private: + Type *_ptr; + }; + + template <typename Type> + struct GCArray_T : GCItem + { + GCArray_T(Type *ptr) : _ptr(ptr) + { + } + + virtual ~GCArray_T() + { + delete[] _ptr; + } + + private: + Type *_ptr; + }; + + /* base class for director exceptions */ + class DirectorException { + protected: + std::string swig_msg; + public: + DirectorException(PyObject *error, const char* hdr ="", const char* msg ="") + : swig_msg(hdr) + { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + if (strlen(msg)) { + swig_msg += " "; + swig_msg += msg; + } + if (!PyErr_Occurred()) { + swig_msg.insert(0, ": "); + PyErr_SetString(error, getMessage()); + } else { + SWIG_Python_AddErrorMsg(getMessage()); + } + SWIG_PYTHON_THREAD_END_BLOCK; + } + + const char *getMessage() const + { + return swig_msg.c_str(); + } + + static void raise(PyObject *error, const char *msg) + { + throw DirectorException(error, msg); + } + + static void raise(const char *msg) + { + raise(PyExc_RuntimeError, msg); + } + }; + + /* unknown exception handler */ + class UnknownExceptionHandler + { +#ifdef SWIG_DIRECTOR_UEH + static void handler() { + try { + throw; + } catch (DirectorException& e) { + std::cerr << "Swig Director exception caught:" << std::endl + << e.getMessage() << std::endl; + } catch (std::exception& e) { + std::cerr << "std::exception caught: "<< e.what() << std::endl; + } catch (...) { + std::cerr << "Unknown exception caught." << std::endl; + } + + std::cerr << std::endl + << "Python interpreter traceback:" << std::endl; + PyErr_Print(); + std::cerr << std::endl; + + std::cerr << "This exception was caught by the SWIG unexpected exception handler." << std::endl + << "Try using %feature(\"director:except\") to avoid reaching this point." << std::endl + << std::endl + << "Exception is being re-thrown, program will like abort/terminate." << std::endl; + throw; + } + + public: + + std::unexpected_handler old; + UnknownExceptionHandler(std::unexpected_handler nh = handler) + { + old = std::set_unexpected(nh); + } + + ~UnknownExceptionHandler() + { + std::set_unexpected(old); + } +#endif + }; + + /* type mismatch in the return value from a python method call */ + class DirectorTypeMismatchException : public Swig::DirectorException { + public: + DirectorTypeMismatchException(PyObject *error, const char* msg="") + : Swig::DirectorException(error, "Swig director type mismatch", msg) + { + } + + DirectorTypeMismatchException(const char* msg="") + : Swig::DirectorException(PyExc_TypeError, "Swig director type mismatch", msg) + { + } + + static void raise(PyObject *error, const char *msg) + { + throw DirectorTypeMismatchException(error, msg); + } + + static void raise(const char *msg) + { + throw DirectorTypeMismatchException(msg); + } + }; + + /* any python exception that occurs during a director method call */ + class DirectorMethodException : public Swig::DirectorException { + public: + DirectorMethodException(const char* msg = "") + : DirectorException(PyExc_RuntimeError, "Swig director method error.", msg) + { + } + + static void raise(const char *msg) + { + throw DirectorMethodException(msg); + } + }; + + /* attempt to call a pure virtual method via a director method */ + class DirectorPureVirtualException : public Swig::DirectorException + { + public: + DirectorPureVirtualException(const char* msg = "") + : DirectorException(PyExc_RuntimeError, "Swig director pure virtual method called", msg) + { + } + + static void raise(const char *msg) + { + throw DirectorPureVirtualException(msg); + } + }; + + +#if defined(SWIG_PYTHON_THREADS) +/* __THREAD__ is the old macro to activate some thread support */ +# if !defined(__THREAD__) +# define __THREAD__ 1 +# endif +#endif + +#ifdef __THREAD__ +# include "pythread.h" + class Guard + { + PyThread_type_lock & mutex_; + + public: + Guard(PyThread_type_lock & mutex) : mutex_(mutex) + { + PyThread_acquire_lock(mutex_, WAIT_LOCK); + } + + ~Guard() + { + PyThread_release_lock(mutex_); + } + }; +# define SWIG_GUARD(mutex) Guard _guard(mutex) +#else +# define SWIG_GUARD(mutex) +#endif + + /* director base class */ + class Director { + private: + /* pointer to the wrapped python object */ + PyObject* swig_self; + /* flag indicating whether the object is owned by python or c++ */ + mutable bool swig_disown_flag; + + /* decrement the reference count of the wrapped python object */ + void swig_decref() const { + if (swig_disown_flag) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + Py_DECREF(swig_self); + SWIG_PYTHON_THREAD_END_BLOCK; + } + } + + public: + /* wrap a python object, optionally taking ownership */ + Director(PyObject* self) : swig_self(self), swig_disown_flag(false) { + swig_incref(); + } + + + /* discard our reference at destruction */ + virtual ~Director() { + swig_decref(); + } + + + /* return a pointer to the wrapped python object */ + PyObject *swig_get_self() const { + return swig_self; + } + + /* acquire ownership of the wrapped python object (the sense of "disown" + * is from python) */ + void swig_disown() const { + if (!swig_disown_flag) { + swig_disown_flag=true; + swig_incref(); + } + } + + /* increase the reference count of the wrapped python object */ + void swig_incref() const { + if (swig_disown_flag) { + Py_INCREF(swig_self); + } + } + + /* methods to implement pseudo protected director members */ + virtual bool swig_get_inner(const char* /* name */) const { + return true; + } + + virtual void swig_set_inner(const char* /* name */, bool /* val */) const { + } + + /* ownership management */ + private: + typedef std::map<void*, GCItem_var> ownership_map; + mutable ownership_map owner; +#ifdef __THREAD__ + static PyThread_type_lock swig_mutex_own; +#endif + + public: + template <typename Type> + void swig_acquire_ownership_array(Type *vptr) const + { + if (vptr) { + SWIG_GUARD(swig_mutex_own); + owner[vptr] = new GCArray_T<Type>(vptr); + } + } + + template <typename Type> + void swig_acquire_ownership(Type *vptr) const + { + if (vptr) { + SWIG_GUARD(swig_mutex_own); + owner[vptr] = new GCItem_T<Type>(vptr); + } + } + + void swig_acquire_ownership_obj(void *vptr, int own) const + { + if (vptr && own) { + SWIG_GUARD(swig_mutex_own); + owner[vptr] = new GCItem_Object(own); + } + } + + int swig_release_ownership(void *vptr) const + { + int own = 0; + if (vptr) { + SWIG_GUARD(swig_mutex_own); + ownership_map::iterator iter = owner.find(vptr); + if (iter != owner.end()) { + own = iter->second->get_own(); + owner.erase(iter); + } + } + return own; + } + }; + +#ifdef __THREAD__ + PyThread_type_lock Director::swig_mutex_own = PyThread_allocate_lock(); +#endif +} + +#endif /* __cplusplus */ + + +#endif diff --git a/devtools/swigwin-1.3.34/Lib/python/embed.i b/devtools/swigwin-1.3.34/Lib/python/embed.i new file mode 100644 index 0000000..4855e3d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/embed.i @@ -0,0 +1,115 @@ +// +// embed15.i +// SWIG file embedding the Python interpreter in something else. +// This file is based on Python-1.5. It will not work with +// earlier versions. +// +// This file makes it possible to extend Python and all of its +// built-in functions without having to hack it's setup script. +// + + +#ifdef AUTODOC +%subsection "embed.i" +%text %{ +This module provides support for building a new version of the +Python executable. This will be necessary on systems that do +not support shared libraries and may be necessary with C++ +extensions. This file contains everything you need to build +a new version of Python from include files and libraries normally +installed with the Python language. + +This module will automatically grab all of the Python modules +present in your current Python executable (including any special +purpose modules you have enabled such as Tkinter). Thus, you +may need to provide additional link libraries when compiling. + +This library file only works with Python 1.5. A version +compatible with Python 1.4 is available as embed14.i and +a Python1.3 version is available as embed13.i. As far as +I know, this module is C++ safe. +%} +#else +%echo "embed.i : Using Python 1.5" +#endif + +%wrapper %{ + +#include <Python.h> + +#ifdef __cplusplus +extern "C" +#endif +void SWIG_init(); /* Forward reference */ + +#define _PyImport_Inittab swig_inittab + +/* Grab Python's inittab[] structure */ + +#ifdef __cplusplus +extern "C" { +#endif +#include <config.c> + +#undef _PyImport_Inittab + +/* Now define our own version of it. + Hopefully someone does not have more than 1000 built-in modules */ + +struct _inittab SWIG_Import_Inittab[1000]; + +static int swig_num_modules = 0; + +/* Function for adding modules to Python */ + +static void swig_add_module(char *name, void (*initfunc)()) { + SWIG_Import_Inittab[swig_num_modules].name = name; + SWIG_Import_Inittab[swig_num_modules].initfunc = initfunc; + swig_num_modules++; + SWIG_Import_Inittab[swig_num_modules].name = (char *) 0; + SWIG_Import_Inittab[swig_num_modules].initfunc = 0; +} + +/* Function to add all of Python's build in modules to our interpreter */ + +static void swig_add_builtin() { + int i = 0; + while (swig_inittab[i].name) { + swig_add_module(swig_inittab[i].name, swig_inittab[i].initfunc); + i++; + } +#ifdef SWIGMODINIT + SWIGMODINIT +#endif + /* Add SWIG builtin function */ + swig_add_module(SWIG_name, SWIG_init); +} + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +extern int Py_Main(int, char **); + +#ifdef __cplusplus +} +#endif + +extern struct _inittab *PyImport_Inittab; + +int +main(int argc, char **argv) { + swig_add_builtin(); + PyImport_Inittab = SWIG_Import_Inittab; + return Py_Main(argc,argv); +} + +%} + + + + diff --git a/devtools/swigwin-1.3.34/Lib/python/embed15.i b/devtools/swigwin-1.3.34/Lib/python/embed15.i new file mode 100644 index 0000000..f677d16 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/embed15.i @@ -0,0 +1,118 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * embed15.i + * + * SWIG file embedding the Python interpreter in something else. + * This file is based on Python-1.5. It will not work with + * earlier versions. + * + * This file makes it possible to extend Python and all of its + * built-in functions without having to hack it's setup script. + * ----------------------------------------------------------------------------- */ + +#ifdef AUTODOC +%subsection "embed.i" +%text %{ +This module provides support for building a new version of the +Python executable. This will be necessary on systems that do +not support shared libraries and may be necessary with C++ +extensions. This file contains everything you need to build +a new version of Python from include files and libraries normally +installed with the Python language. + +This module will automatically grab all of the Python modules +present in your current Python executable (including any special +purpose modules you have enabled such as Tkinter). Thus, you +may need to provide additional link libraries when compiling. + +This library file only works with Python 1.5. A version +compatible with Python 1.4 is available as embed14.i and +a Python1.3 version is available as embed13.i. As far as +I know, this module is C++ safe. +%} +#else +%echo "embed.i : Using Python 1.5" +#endif + +%wrapper %{ + +#include <Python.h> + +#ifdef __cplusplus +extern "C" +#endif +void SWIG_init(); /* Forward reference */ + +#define _PyImport_Inittab swig_inittab + +/* Grab Python's inittab[] structure */ + +#ifdef __cplusplus +extern "C" { +#endif +#include <config.c> + +#undef _PyImport_Inittab + +/* Now define our own version of it. + Hopefully someone does not have more than 1000 built-in modules */ + +struct _inittab SWIG_Import_Inittab[1000]; + +static int swig_num_modules = 0; + +/* Function for adding modules to Python */ + +static void swig_add_module(char *name, void (*initfunc)()) { + SWIG_Import_Inittab[swig_num_modules].name = name; + SWIG_Import_Inittab[swig_num_modules].initfunc = initfunc; + swig_num_modules++; + SWIG_Import_Inittab[swig_num_modules].name = (char *) 0; + SWIG_Import_Inittab[swig_num_modules].initfunc = 0; +} + +/* Function to add all of Python's build in modules to our interpreter */ + +static void swig_add_builtin() { + int i = 0; + while (swig_inittab[i].name) { + swig_add_module(swig_inittab[i].name, swig_inittab[i].initfunc); + i++; + } +#ifdef SWIGMODINIT + SWIGMODINIT +#endif + /* Add SWIG builtin function */ + swig_add_module(SWIG_name, SWIG_init); +} + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +extern int Py_Main(int, char **); + +#ifdef __cplusplus +} +#endif + +extern struct _inittab *PyImport_Inittab; + +int +main(int argc, char **argv) { + swig_add_builtin(); + PyImport_Inittab = SWIG_Import_Inittab; + return Py_Main(argc,argv); +} + +%} + + + + diff --git a/devtools/swigwin-1.3.34/Lib/python/exception.i b/devtools/swigwin-1.3.34/Lib/python/exception.i new file mode 100644 index 0000000..bb0b15c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/exception.i @@ -0,0 +1,6 @@ +%include <typemaps/exception.swg> + + +%insert("runtime") { + %define_as(SWIG_exception(code, msg), %block(%error(code, msg); SWIG_fail; )) +} diff --git a/devtools/swigwin-1.3.34/Lib/python/factory.i b/devtools/swigwin-1.3.34/Lib/python/factory.i new file mode 100644 index 0000000..46a0a87 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/factory.i @@ -0,0 +1 @@ +%include <typemaps/factory.swg> diff --git a/devtools/swigwin-1.3.34/Lib/python/file.i b/devtools/swigwin-1.3.34/Lib/python/file.i new file mode 100644 index 0000000..c0e7d5e --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/file.i @@ -0,0 +1,43 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * file.i + * + * Typemaps for FILE* + * From the ideas of Luigi Ballabio + * ----------------------------------------------------------------------------- */ + +%types(FILE *); + +/* defining basic methods */ +%fragment("SWIG_AsValFilePtr","header") { +SWIGINTERN int +SWIG_AsValFilePtr(PyObject *obj, FILE **val) { + static swig_type_info* desc = 0; + void *vptr = 0; + if (!desc) desc = SWIG_TypeQuery("FILE *"); + if ((SWIG_ConvertPtr(obj, &vptr, desc, 0)) == SWIG_OK) { + if (val) *val = (FILE *)vptr; + return SWIG_OK; + } + if (PyFile_Check(obj)) { + if (val) *val = PyFile_AsFile(obj); + return SWIG_OK; + } + return SWIG_TypeError; +} +} + + +%fragment("SWIG_AsFilePtr","header",fragment="SWIG_AsValFilePtr") { +SWIGINTERNINLINE FILE* +SWIG_AsFilePtr(PyObject *obj) { + FILE *val = 0; + SWIG_AsValFilePtr(obj, &val); + return val; +} +} + +/* defining the typemaps */ +%typemaps_asval(%checkcode(POINTER), SWIG_AsValFilePtr, "SWIG_AsValFilePtr", FILE*); diff --git a/devtools/swigwin-1.3.34/Lib/python/implicit.i b/devtools/swigwin-1.3.34/Lib/python/implicit.i new file mode 100644 index 0000000..152c2b0 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/implicit.i @@ -0,0 +1,7 @@ +%include <std_common.i> +%include <typemaps/implicit.swg> + +#warning "This file provides the %implicit directive, which is an old and fragile" +#warning "way to implement the C++ implicit conversion mechanism." +#warning "Try using the more robust '%implicitconv Type;' directive instead." + diff --git a/devtools/swigwin-1.3.34/Lib/python/jstring.i b/devtools/swigwin-1.3.34/Lib/python/jstring.i new file mode 100644 index 0000000..bda9523 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/jstring.i @@ -0,0 +1,72 @@ +%include <typemaps/valtypes.swg> + +%fragment(SWIG_AsVal_frag(jstring),"header") { +SWIGINTERN int +SWIG_AsVal(jstring)(PyObject *obj, jstring *val) +{ + if (obj == Py_None) { + if (val) *val = 0; + return SWIG_OK; + } + + PyObject *tmp = 0; + int isunicode = PyUnicode_Check(obj); + if (!isunicode && PyString_Check(obj)) { + if (val) { + obj = tmp = PyUnicode_FromObject(obj); + } + isunicode = 1; + } + if (isunicode) { + if (val) { + if (sizeof(Py_UNICODE) == sizeof(jchar)) { + *val = JvNewString((const jchar *) PyUnicode_AS_UNICODE(obj),PyUnicode_GET_SIZE(obj)); + return SWIG_NEWOBJ; + } else { + int len = PyUnicode_GET_SIZE(obj); + Py_UNICODE *pchars = PyUnicode_AS_UNICODE(obj); + *val = JvAllocString (len); + jchar *jchars = JvGetStringChars (*val); + for (int i = 0; i < len; ++i) { + jchars[i] = pchars[i]; + } + return SWIG_NEWOBJ; + } + } + Py_XDECREF(tmp); + return SWIG_OK; + } + return SWIG_TypeError; +} +} + +%fragment(SWIG_From_frag(jstring),"header") { +SWIGINTERNINLINE PyObject * +SWIG_From(jstring)(jstring val) +{ + if (!val) { + return SWIG_Py_Void(); + } + if (sizeof(Py_UNICODE) == sizeof(jchar)) { + return PyUnicode_FromUnicode((const Py_UNICODE *) JvGetStringChars(val), + JvGetStringUTFLength(val)); + } else { + int len = JvGetStringUTFLength(val); + Py_UNICODE pchars[len]; + jchar *jchars = JvGetStringChars(val); + + for (int i = 0; i < len; i++) { + pchars[i] = jchars[i]; + } + return PyUnicode_FromUnicode((const Py_UNICODE *) pchars, len); + } +} +} + +%typemaps_asvalfrom(%checkcode(STRING), + %arg(SWIG_AsVal(jstring)), + %arg(SWIG_From(jstring)), + %arg(SWIG_AsVal_frag(jstring)), + %arg(SWIG_From_frag(jstring)), + java::lang::String *); + diff --git a/devtools/swigwin-1.3.34/Lib/python/pyapi.swg b/devtools/swigwin-1.3.34/Lib/python/pyapi.swg new file mode 100644 index 0000000..1d5148d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pyapi.swg @@ -0,0 +1,36 @@ +/* ----------------------------------------------------------------------------- + * Python API portion that goes into the runtime + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* cc-mode */ +#endif +#endif + +/* ----------------------------------------------------------------------------- + * Constant declarations + * ----------------------------------------------------------------------------- */ + +/* Constant Types */ +#define SWIG_PY_POINTER 4 +#define SWIG_PY_BINARY 5 + +/* Constant information structure */ +typedef struct swig_const_info { + int type; + char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_const_info; + +#ifdef __cplusplus +#if 0 +{ /* cc-mode */ +#endif +} +#endif + diff --git a/devtools/swigwin-1.3.34/Lib/python/pybackward.swg b/devtools/swigwin-1.3.34/Lib/python/pybackward.swg new file mode 100644 index 0000000..8305fc7 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pybackward.swg @@ -0,0 +1,45 @@ +/* + adding backward compatibility macros +*/ + +#define SWIG_arg(x...) %arg(x) +#define SWIG_Mangle(x...) %mangle(x) + +#define SWIG_As_frag(Type...) %fragment_name(As, Type) +#define SWIG_As_name(Type...) %symbol_name(As, Type) +#define SWIG_As(Type...) SWIG_As_name(Type) SWIG_AS_CALL_ARGS + +#define SWIG_Check_frag(Type...) %fragment_name(Check, Type) +#define SWIG_Check_name(Type...) %symbol_name(Check, Type) +#define SWIG_Check(Type...) SWIG_Check_name(Type) SWIG_AS_CALL_ARGS + +%define %ascheck_methods(Code, Type...) +%fragment(SWIG_As_frag(Type),"header", fragment=SWIG_AsVal_frag(Type)) { +SWIGINTERNINLINE Type +SWIG_As(Type)(PyObject* obj) +{ + Type v; + int res = SWIG_AsVal(Type)(obj, &v); + if (!SWIG_IsOK(res)) { + /* + this is needed to make valgrind/purify happier. + */ + memset((void*)&v, 0, sizeof(Type)); + SWIG_Error(res, ""); + } + return v; +} +} + +%fragment(SWIG_Check_frag(Type),"header",fragment=SWIG_AsVal_frag(Type)) { +SWIGINTERNINLINE int +SWIG_Check(Type)(PyObject* obj) +{ + int res = SWIG_AsVal(Type)(obj, (Type*)0); + return SWIG_IsOK(res); +} +} +%enddef + +%apply_checkctypes(%ascheck_methods) + diff --git a/devtools/swigwin-1.3.34/Lib/python/pyclasses.swg b/devtools/swigwin-1.3.34/Lib/python/pyclasses.swg new file mode 100644 index 0000000..122025c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pyclasses.swg @@ -0,0 +1,144 @@ +#ifdef __cplusplus + +/* + PyObject_ptr is used as a replacement of PyObject *, where + the INCREF/DECREF are applied as needed. + + You can use PyObject_ptr in a container, such as + + std::vector<PyObject_ptr>; + + or as a member variable: + + struct A { + PyObject_ptr obj; + A(PyObject *o) : _obj(o) { + } + }; + + or as a input/output value + + PyObject_ptr func(PyObject_ptr obj) { + PyObject_ptr out = PyString_FromFormat("hello %s", PyObject_AsString(obj)); + Py_DECREF(out); + return out; + } + + just remember to pair the object creation with the proper DECREF, + the same as with plain PyObject *ptr, since PyObject_ptr always add + one reference at construction. + + PyObject_ptr is 'visible' at the wrapped side, so you can do: + + + %template(pyvector) std::vector<swig::PyObject_ptr>; + + and all the proper typemaps will be used. + +*/ + +namespace swig { + %ignore PyObject_ptr; + struct PyObject_ptr {}; + %apply PyObject * {PyObject_ptr}; + %apply PyObject * const& {PyObject_ptr const&}; + + /* For output */ + %typemap(out,noblock=1) PyObject_ptr { + $result = (PyObject *)$1; + Py_INCREF($result); + } + + %typemap(out,noblock=1) PyObject_ptr const & { + $result = (PyObject *)*$1; + Py_INCREF($result); + } + +} + +%{ +namespace swig { + class PyObject_ptr { + protected: + PyObject *_obj; + + public: + PyObject_ptr() :_obj(0) + { + } + + PyObject_ptr(const PyObject_ptr& item) : _obj(item._obj) + { + Py_XINCREF(_obj); + } + + PyObject_ptr(PyObject *obj, bool initial_ref = true) :_obj(obj) + { + if (initial_ref) Py_XINCREF(_obj); + } + + PyObject_ptr & operator=(const PyObject_ptr& item) + { + Py_XINCREF(item._obj); + Py_XDECREF(_obj); + _obj = item._obj; + return *this; + } + + ~PyObject_ptr() + { + Py_XDECREF(_obj); + } + + operator PyObject *() const + { + return _obj; + } + + PyObject *operator->() const + { + return _obj; + } + }; +} +%} + +/* + PyObject_var is used to manage 'in the scope' PyObject * variables, + as in + + int func () { + PyObject_var obj = PyString_FromString("hello"); + } + + ie, 'obj' is created and destructed in the same scope from + a python object that carries at least one reference value. + + PyObject_var just take care of applying the proper Py_DECREF. + + Hence, this class is purely internal and not visible at the wrapped side. + */ +namespace swig { + %ignore PyObject_var; + struct PyObject_var {}; + %apply PyObject * {PyObject_var}; + %apply PyObject * const& {PyObject_var const&}; +} + +%{ +namespace swig { + struct PyObject_var : PyObject_ptr { + PyObject_var(PyObject* obj = 0) : PyObject_ptr(obj, false) { } + + PyObject_var & operator = (PyObject* obj) + { + Py_XDECREF(_obj); + _obj = obj; + return *this; + } + }; +} +%} + + +#endif diff --git a/devtools/swigwin-1.3.34/Lib/python/pycomplex.swg b/devtools/swigwin-1.3.34/Lib/python/pycomplex.swg new file mode 100644 index 0000000..7914b0e --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pycomplex.swg @@ -0,0 +1,86 @@ +/* + Defines the As/From conversors for double/float complex, you need to + provide complex Type, the Name you want to use in the conversors, + the complex Constructor method, and the Real and Imag complex + accesor methods. + + See the std_complex.i and ccomplex.i for concret examples. +*/ + +/* the common from conversor */ +%define %swig_fromcplx_conv(Type, Real, Imag) +%fragment(SWIG_From_frag(Type),"header") +{ +SWIGINTERNINLINE PyObject* +SWIG_From(Type)(%ifcplusplus(const Type&, Type) c) +{ + return PyComplex_FromDoubles(Real(c), Imag(c)); +} +} +%enddef + +/* the double case */ +%define %swig_cplxdbl_conv(Type, Constructor, Real, Imag) +%fragment(SWIG_AsVal_frag(Type),"header", + fragment=SWIG_AsVal_frag(double)) +{ +SWIGINTERN int +SWIG_AsVal(Type) (PyObject *o, Type* val) +{ + if (PyComplex_Check(o)) { + if (val) *val = Constructor(PyComplex_RealAsDouble(o), PyComplex_ImagAsDouble(o)); + return SWIG_OK; + } else { + double d; + int res = SWIG_AddCast(SWIG_AsVal(double)(o, &d)); + if (SWIG_IsOK(res)) { + if (val) *val = Constructor(d, 0.0); + return res; + } + } + return SWIG_TypeError; +} +} +%swig_fromcplx_conv(Type, Real, Imag); +%enddef + +/* the float case */ +%define %swig_cplxflt_conv(Type, Constructor, Real, Imag) +%fragment(SWIG_AsVal_frag(Type),"header", + fragment=SWIG_AsVal_frag(float)) { +SWIGINTERN int +SWIG_AsVal(Type)(PyObject *o, Type *val) +{ + if (PyComplex_Check(o)) { + double re = PyComplex_RealAsDouble(o); + double im = PyComplex_ImagAsDouble(o); + if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) { + if (val) *val = Constructor(%numeric_cast(re, float), + %numeric_cast(im, float)); + return SWIG_OK; + } else { + return SWIG_OverflowError; + } + } else { + float re; + int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re)); + if (SWIG_IsOK(res)) { + if (val) *val = Constructor(re, 0.0); + return res; + } + } + return SWIG_TypeError; +} +} + +%swig_fromcplx_conv(Type, Real, Imag); +%enddef + +#define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \ +%swig_cplxflt_conv(Type, Constructor, Real, Imag) + + +#define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \ +%swig_cplxdbl_conv(Type, Constructor, Real, Imag) + + diff --git a/devtools/swigwin-1.3.34/Lib/python/pycontainer.swg b/devtools/swigwin-1.3.34/Lib/python/pycontainer.swg new file mode 100644 index 0000000..b68a11f --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pycontainer.swg @@ -0,0 +1,766 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * pycontainer.swg + * + * Python sequence <-> C++ container wrapper + * + * This wrapper, and its iterator, allows a general use (and reuse) of + * the the mapping between C++ and Python, thanks to the C++ + * templates. + * + * Of course, it needs the C++ compiler to support templates, but + * since we will use this wrapper with the STL containers, that should + * be the case. + * ----------------------------------------------------------------------------- */ + +%{ +#include <iostream> +%} + + +#if !defined(SWIG_NO_EXPORT_ITERATOR_METHODS) +# if !defined(SWIG_EXPORT_ITERATOR_METHODS) +# define SWIG_EXPORT_ITERATOR_METHODS SWIG_EXPORT_ITERATOR_METHODS +# endif +#endif + +%include <pyiterators.swg> + +/**** The PySequence C++ Wrap ***/ + +%insert(header) %{ +#include <stdexcept> +%} + +%include <std_except.i> + +%fragment(SWIG_Traits_frag(swig::PyObject_ptr),"header",fragment="StdTraits") { +namespace swig { + template <> struct traits<PyObject_ptr > { + typedef value_category category; + static const char* type_name() { return "PyObject_ptr"; } + }; + + template <> struct traits_from<PyObject_ptr> { + typedef PyObject_ptr value_type; + static PyObject *from(const value_type& val) { + PyObject *obj = static_cast<PyObject *>(val); + Py_XINCREF(obj); + return obj; + } + }; + + template <> + struct traits_check<PyObject_ptr, value_category> { + static bool check(PyObject_ptr) { + return true; + } + }; + + template <> struct traits_asval<PyObject_ptr > { + typedef PyObject_ptr value_type; + static int asval(PyObject *obj, value_type *val) { + if (val) *val = obj; + return SWIG_OK; + } + }; +} +} + +%fragment(SWIG_Traits_frag(swig::PyObject_var),"header",fragment="StdTraits") { +namespace swig { + template <> struct traits<PyObject_var > { + typedef value_category category; + static const char* type_name() { return "PyObject_var"; } + }; + + template <> struct traits_from<PyObject_var> { + typedef PyObject_var value_type; + static PyObject *from(const value_type& val) { + PyObject *obj = static_cast<PyObject *>(val); + Py_XINCREF(obj); + return obj; + } + }; + + template <> + struct traits_check<PyObject_var, value_category> { + static bool check(PyObject_var) { + return true; + } + }; + + template <> struct traits_asval<PyObject_var > { + typedef PyObject_var value_type; + static int asval(PyObject *obj, value_type *val) { + if (val) *val = obj; + return SWIG_OK; + } + }; +} +} + +%fragment("PySequence_Base","header") +{ +%#include <functional> + +namespace std { + template <> + struct less <PyObject *>: public binary_function<PyObject *, PyObject *, bool> + { + bool + operator()(PyObject * v, PyObject *w) const + { + bool res; + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + res = PyObject_Compare(v, w) < 0; + SWIG_PYTHON_THREAD_END_BLOCK; + return res; + } + }; + + template <> + struct less <swig::PyObject_ptr>: public binary_function<swig::PyObject_ptr, swig::PyObject_ptr, bool> + { + bool + operator()(const swig::PyObject_ptr& v, const swig::PyObject_ptr& w) const + { + return std::less<PyObject *>()(v, w); + } + }; + + template <> + struct less <swig::PyObject_var>: public binary_function<swig::PyObject_var, swig::PyObject_var, bool> + { + bool + operator()(const swig::PyObject_var& v, const swig::PyObject_var& w) const + { + return std::less<PyObject *>()(v, w); + } + }; + +} + +namespace swig { + template <> struct traits<PyObject *> { + typedef value_category category; + static const char* type_name() { return "PyObject *"; } + }; + + template <> struct traits_asval<PyObject * > { + typedef PyObject * value_type; + static int asval(PyObject *obj, value_type *val) { + if (val) *val = obj; + return SWIG_OK; + } + }; + + template <> + struct traits_check<PyObject *, value_category> { + static bool check(PyObject *) { + return true; + } + }; + + template <> struct traits_from<PyObject *> { + typedef PyObject * value_type; + static PyObject *from(const value_type& val) { + Py_XINCREF(val); + return val; + } + }; + +} + +namespace swig { + inline size_t + check_index(ptrdiff_t i, size_t size, bool insert = false) { + if ( i < 0 ) { + if ((size_t) (-i) <= size) + return (size_t) (i + size); + } else if ( (size_t) i < size ) { + return (size_t) i; + } else if (insert && ((size_t) i == size)) { + return size; + } + + throw std::out_of_range("index out of range"); + } + + inline size_t + slice_index(ptrdiff_t i, size_t size) { + if ( i < 0 ) { + if ((size_t) (-i) <= size) { + return (size_t) (i + size); + } else { + throw std::out_of_range("index out of range"); + } + } else { + return ( (size_t) i < size ) ? ((size_t) i) : size; + } + } + + template <class Sequence, class Difference> + inline typename Sequence::iterator + getpos(Sequence* self, Difference i) { + typename Sequence::iterator pos = self->begin(); + std::advance(pos, check_index(i,self->size())); + return pos; + } + + template <class Sequence, class Difference> + inline typename Sequence::const_iterator + cgetpos(const Sequence* self, Difference i) { + typename Sequence::const_iterator pos = self->begin(); + std::advance(pos, check_index(i,self->size())); + return pos; + } + + template <class Sequence, class Difference> + inline Sequence* + getslice(const Sequence* self, Difference i, Difference j) { + typename Sequence::size_type size = self->size(); + typename Sequence::size_type ii = swig::check_index(i, size); + typename Sequence::size_type jj = swig::slice_index(j, size); + + if (jj > ii) { + typename Sequence::const_iterator vb = self->begin(); + typename Sequence::const_iterator ve = self->begin(); + std::advance(vb,ii); + std::advance(ve,jj); + return new Sequence(vb, ve); + } else { + return new Sequence(); + } + } + + template <class Sequence, class Difference, class InputSeq> + inline void + setslice(Sequence* self, Difference i, Difference j, const InputSeq& v) { + typename Sequence::size_type size = self->size(); + typename Sequence::size_type ii = swig::check_index(i, size, true); + typename Sequence::size_type jj = swig::slice_index(j, size); + if (jj < ii) jj = ii; + size_t ssize = jj - ii; + if (ssize <= v.size()) { + typename Sequence::iterator sb = self->begin(); + typename InputSeq::const_iterator vmid = v.begin(); + std::advance(sb,ii); + std::advance(vmid, jj - ii); + self->insert(std::copy(v.begin(), vmid, sb), vmid, v.end()); + } else { + typename Sequence::iterator sb = self->begin(); + typename Sequence::iterator se = self->begin(); + std::advance(sb,ii); + std::advance(se,jj); + self->erase(sb,se); + self->insert(sb, v.begin(), v.end()); + } + } + + template <class Sequence, class Difference> + inline void + delslice(Sequence* self, Difference i, Difference j) { + typename Sequence::size_type size = self->size(); + typename Sequence::size_type ii = swig::check_index(i, size, true); + typename Sequence::size_type jj = swig::slice_index(j, size); + if (jj > ii) { + typename Sequence::iterator sb = self->begin(); + typename Sequence::iterator se = self->begin(); + std::advance(sb,ii); + std::advance(se,jj); + self->erase(sb,se); + } + } +} +} + +%fragment("PySequence_Cont","header", + fragment="StdTraits", + fragment="PySequence_Base", + fragment="PySwigIterator_T") +{ +namespace swig +{ + template <class T> + struct PySequence_Ref + { + PySequence_Ref(PyObject* seq, int index) + : _seq(seq), _index(index) + { + } + + operator T () const + { + swig::PyObject_var item = PySequence_GetItem(_seq, _index); + try { + return swig::as<T>(item, true); + } catch (std::exception& e) { + char msg[1024]; + sprintf(msg, "in sequence element %d ", _index); + if (!PyErr_Occurred()) { + %type_error(swig::type_name<T>()); + } + SWIG_Python_AddErrorMsg(msg); + SWIG_Python_AddErrorMsg(e.what()); + throw; + } + } + + PySequence_Ref& operator=(const T& v) + { + PySequence_SetItem(_seq, _index, swig::from<T>(v)); + return *this; + } + + private: + PyObject* _seq; + int _index; + }; + + template <class T> + struct PySequence_ArrowProxy + { + PySequence_ArrowProxy(const T& x): m_value(x) {} + const T* operator->() const { return &m_value; } + operator const T*() const { return &m_value; } + T m_value; + }; + + template <class T, class Reference > + struct PySequence_InputIterator + { + typedef PySequence_InputIterator<T, Reference > self; + + typedef std::random_access_iterator_tag iterator_category; + typedef Reference reference; + typedef T value_type; + typedef T* pointer; + typedef int difference_type; + + PySequence_InputIterator() + { + } + + PySequence_InputIterator(PyObject* seq, int index) + : _seq(seq), _index(index) + { + } + + reference operator*() const + { + return reference(_seq, _index); + } + + PySequence_ArrowProxy<T> + operator->() const { + return PySequence_ArrowProxy<T>(operator*()); + } + + bool operator==(const self& ri) const + { + return (_index == ri._index) && (_seq == ri._seq); + } + + bool operator!=(const self& ri) const + { + return !(operator==(ri)); + } + + self& operator ++ () + { + ++_index; + return *this; + } + + self& operator -- () + { + --_index; + return *this; + } + + self& operator += (difference_type n) + { + _index += n; + return *this; + } + + self operator +(difference_type n) const + { + return self(_seq, _index + n); + } + + self& operator -= (difference_type n) + { + _index -= n; + return *this; + } + + self operator -(difference_type n) const + { + return self(_seq, _index - n); + } + + difference_type operator - (const self& ri) const + { + return _index - ri._index; + } + + bool operator < (const self& ri) const + { + return _index < ri._index; + } + + reference + operator[](difference_type n) const + { + return reference(_seq, _index + n); + } + + private: + PyObject* _seq; + difference_type _index; + }; + + template <class T> + struct PySequence_Cont + { + typedef PySequence_Ref<T> reference; + typedef const PySequence_Ref<T> const_reference; + typedef T value_type; + typedef T* pointer; + typedef int difference_type; + typedef int size_type; + typedef const pointer const_pointer; + typedef PySequence_InputIterator<T, reference> iterator; + typedef PySequence_InputIterator<T, const_reference> const_iterator; + + PySequence_Cont(PyObject* seq) : _seq(0) + { + if (!PySequence_Check(seq)) { + throw std::invalid_argument("a sequence is expected"); + } + _seq = seq; + Py_INCREF(_seq); + } + + ~PySequence_Cont() + { + if (_seq) Py_DECREF(_seq); + } + + size_type size() const + { + return static_cast<size_type>(PySequence_Size(_seq)); + } + + bool empty() const + { + return size() == 0; + } + + iterator begin() + { + return iterator(_seq, 0); + } + + const_iterator begin() const + { + return const_iterator(_seq, 0); + } + + iterator end() + { + return iterator(_seq, size()); + } + + const_iterator end() const + { + return const_iterator(_seq, size()); + } + + reference operator[](difference_type n) + { + return reference(_seq, n); + } + + const_reference operator[](difference_type n) const + { + return const_reference(_seq, n); + } + + bool check(bool set_err = true) const + { + int s = size(); + for (int i = 0; i < s; ++i) { + swig::PyObject_var item = PySequence_GetItem(_seq, i); + if (!swig::check<value_type>(item)) { + if (set_err) { + char msg[1024]; + sprintf(msg, "in sequence element %d", i); + SWIG_Error(SWIG_RuntimeError, msg); + } + return false; + } + } + return true; + } + + private: + PyObject* _seq; + }; + +} +} + +%define %swig_sequence_iterator(Sequence...) +#if defined(SWIG_EXPORT_ITERATOR_METHODS) + class iterator; + class reverse_iterator; + class const_iterator; + class const_reverse_iterator; + + %typemap(out,noblock=1,fragment="PySequence_Cont") + iterator, reverse_iterator, const_iterator, const_reverse_iterator { + $result = SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &)), + swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN); + } + %typemap(out,noblock=1,fragment="PySequence_Cont") + std::pair<iterator, iterator>, std::pair<const_iterator, const_iterator> { + $result = PyTuple_New(2); + PyTuple_SetItem($result,0,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first), + swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN)); + PyTuple_SetItem($result,1,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).second), + swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN)); + } + + %fragment("PyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="PySequence_Cont") {} + + %typemap(out,noblock=1,fragment="PyPairBoolOutputIterator") + std::pair<iterator, bool>, std::pair<const_iterator, bool> { + $result = PyTuple_New(2); + PyTuple_SetItem($result,0,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first), + swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN)); + PyTuple_SetItem($result,1,SWIG_From(bool)(%static_cast($1,const $type &).second)); + } + + %typemap(in,noblock=1,fragment="PySequence_Cont") + iterator(swig::PySwigIterator *iter = 0, int res), + reverse_iterator(swig::PySwigIterator *iter = 0, int res), + const_iterator(swig::PySwigIterator *iter = 0, int res), + const_reverse_iterator(swig::PySwigIterator *iter = 0, int res) { + res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0); + if (!SWIG_IsOK(res) || !iter) { + %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); + } else { + swig::PySwigIterator_T<$type > *iter_t = dynamic_cast<swig::PySwigIterator_T<$type > *>(iter); + if (iter_t) { + $1 = iter_t->get_current(); + } else { + %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); + } + } + } + + %typecheck(%checkcode(ITERATOR),noblock=1,fragment="PySequence_Cont") + iterator, reverse_iterator, const_iterator, const_reverse_iterator { + swig::PySwigIterator *iter = 0; + int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0); + $1 = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<$type > *>(iter) != 0)); + } + + %fragment("PySequence_Cont"); + + %newobject iterator(PyObject **PYTHON_SELF); + %extend { + swig::PySwigIterator* iterator(PyObject **PYTHON_SELF) { + return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); + } + + %pythoncode {def __iter__(self): return self.iterator()} + } +#endif //SWIG_EXPORT_ITERATOR_METHODS +%enddef + + +/**** The python container methods ****/ + + +%define %swig_container_methods(Container...) + + %newobject __getslice__; + + %extend { + bool __nonzero__() const { + return !(self->empty()); + } + + size_type __len__() const { + return self->size(); + } + } +%enddef + +%define %swig_sequence_methods_common(Sequence...) + %swig_sequence_iterator(%arg(Sequence)) + %swig_container_methods(%arg(Sequence)) + + %fragment("PySequence_Base"); + + %extend { + value_type pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty container"); + Sequence::value_type x = self->back(); + self->pop_back(); + return x; + } + + Sequence* __getslice__(difference_type i, difference_type j) throw (std::out_of_range) { + return swig::getslice(self, i, j); + } + + void __setslice__(difference_type i, difference_type j, const Sequence& v) + throw (std::out_of_range, std::invalid_argument) { + swig::setslice(self, i, j, v); + } + + void __delslice__(difference_type i, difference_type j) throw (std::out_of_range) { + swig::delslice(self, i, j); + } + + void __delitem__(difference_type i) throw (std::out_of_range) { + self->erase(swig::getpos(self,i)); + } + } +%enddef + +%define %swig_sequence_methods(Sequence...) + %swig_sequence_methods_common(%arg(Sequence)) + %extend { + const value_type& __getitem__(difference_type i) const throw (std::out_of_range) { + return *(swig::cgetpos(self, i)); + } + + void __setitem__(difference_type i, const value_type& x) throw (std::out_of_range) { + *(swig::getpos(self,i)) = x; + } + + void append(const value_type& x) { + self->push_back(x); + } + } +%enddef + +%define %swig_sequence_methods_val(Sequence...) + %swig_sequence_methods_common(%arg(Sequence)) + %extend { + value_type __getitem__(difference_type i) throw (std::out_of_range) { + return *(swig::cgetpos(self, i)); + } + + void __setitem__(difference_type i, value_type x) throw (std::out_of_range) { + *(swig::getpos(self,i)) = x; + } + + void append(value_type x) { + self->push_back(x); + } + } +%enddef + + + +// +// Common fragments +// + +%fragment("StdSequenceTraits","header", + fragment="StdTraits", + fragment="PySequence_Cont") +{ +namespace swig { + template <class PySeq, class Seq> + inline void + assign(const PySeq& pyseq, Seq* seq) { +%#ifdef SWIG_STD_NOASSIGN_STL + typedef typename PySeq::value_type value_type; + typename PySeq::const_iterator it = pyseq.begin(); + for (;it != pyseq.end(); ++it) { + seq->insert(seq->end(),(value_type)(*it)); + } +%#else + seq->assign(pyseq.begin(), pyseq.end()); +%#endif + } + + template <class Seq, class T = typename Seq::value_type > + struct traits_asptr_stdseq { + typedef Seq sequence; + typedef T value_type; + + static int asptr(PyObject *obj, sequence **seq) { + if (obj == Py_None || SWIG_Python_GetSwigThis(obj)) { + sequence *p; + if (SWIG_ConvertPtr(obj,(void**)&p, + swig::type_info<sequence>(),0) == SWIG_OK) { + if (seq) *seq = p; + return SWIG_OLDOBJ; + } + } else if (PySequence_Check(obj)) { + try { + PySequence_Cont<value_type> pyseq(obj); + if (seq) { + sequence *pseq = new sequence(); + assign(pyseq, pseq); + *seq = pseq; + return SWIG_NEWOBJ; + } else { + return pyseq.check() ? SWIG_OK : SWIG_ERROR; + } + } catch (std::exception& e) { + if (seq) { + if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, e.what()); + } + } + return SWIG_ERROR; + } + } + return SWIG_ERROR; + } + }; + + template <class Seq, class T = typename Seq::value_type > + struct traits_from_stdseq { + typedef Seq sequence; + typedef T value_type; + typedef typename Seq::size_type size_type; + typedef typename sequence::const_iterator const_iterator; + + static PyObject *from(const sequence& seq) { +#ifdef SWIG_PYTHON_EXTRA_NATIVE_CONTAINERS + swig_type_info *desc = swig::type_info<sequence>(); + if (desc && desc->clientdata) { + return SWIG_NewPointerObj(new sequence(seq), desc, SWIG_POINTER_OWN); + } +#endif + size_type size = seq.size(); + if (size <= (size_type)INT_MAX) { + PyObject *obj = PyTuple_New((int)size); + int i = 0; + for (const_iterator it = seq.begin(); + it != seq.end(); ++it, ++i) { + PyTuple_SetItem(obj,i,swig::from<value_type>(*it)); + } + return obj; + } else { + PyErr_SetString(PyExc_OverflowError,"sequence size not valid in python"); + return NULL; + } + } + }; +} +} diff --git a/devtools/swigwin-1.3.34/Lib/python/pydocs.swg b/devtools/swigwin-1.3.34/Lib/python/pydocs.swg new file mode 100644 index 0000000..0091a30 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pydocs.swg @@ -0,0 +1,18 @@ + +// basic doc for primitive types.... + +#ifdef SWIG_DOC_DOXYGEN_STYLE +%typemap(doc) SWIGTYPE "@param $1_name $1_type value"; +%typemap(doc) SWIGTYPE* "@param $1_name $1_type value"; +%typemap(doc) const SWIGTYPE& "@param $1_name $1_type value"; +%typemap(doc) enum SWIGTYPE "@param $1_name enum $1_type value"; +#else +%typemap(doc) SWIGTYPE "$1_name: $1_type value"; +%typemap(doc) SWIGTYPE* "$1_name: $1_type value"; +%typemap(doc) const SWIGTYPE& "$1_name: $1_type value"; +%typemap(doc) enum SWIGTYPE "$1_name: enum $1_type value"; + +%typemap(doc) SWIGTYPE *INOUT "$1_name: $1_type input/ouput value"; +%typemap(doc) SWIGTYPE *INPUT "$1_name: $1_type input value"; +%typemap(doc) SWIGTYPE *OUTPUT "$1_name: $1_type output value"; +#endif diff --git a/devtools/swigwin-1.3.34/Lib/python/pyerrors.swg b/devtools/swigwin-1.3.34/Lib/python/pyerrors.swg new file mode 100644 index 0000000..e287e2f --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pyerrors.swg @@ -0,0 +1,69 @@ +/* ----------------------------------------------------------------------------- + * error manipulation + * ----------------------------------------------------------------------------- */ + +SWIGRUNTIME PyObject* +SWIG_Python_ErrorType(int code) { + PyObject* type = 0; + switch(code) { + case SWIG_MemoryError: + type = PyExc_MemoryError; + break; + case SWIG_IOError: + type = PyExc_IOError; + break; + case SWIG_RuntimeError: + type = PyExc_RuntimeError; + break; + case SWIG_IndexError: + type = PyExc_IndexError; + break; + case SWIG_TypeError: + type = PyExc_TypeError; + break; + case SWIG_DivisionByZero: + type = PyExc_ZeroDivisionError; + break; + case SWIG_OverflowError: + type = PyExc_OverflowError; + break; + case SWIG_SyntaxError: + type = PyExc_SyntaxError; + break; + case SWIG_ValueError: + type = PyExc_ValueError; + break; + case SWIG_SystemError: + type = PyExc_SystemError; + break; + case SWIG_AttributeError: + type = PyExc_AttributeError; + break; + default: + type = PyExc_RuntimeError; + } + return type; +} + + +SWIGRUNTIME void +SWIG_Python_AddErrorMsg(const char* mesg) +{ + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + + if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); + if (value) { + PyObject *old_str = PyObject_Str(value); + PyErr_Clear(); + Py_XINCREF(type); + PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); + Py_DECREF(old_str); + Py_DECREF(value); + } else { + PyErr_SetString(PyExc_RuntimeError, mesg); + } +} + + diff --git a/devtools/swigwin-1.3.34/Lib/python/pyfragments.swg b/devtools/swigwin-1.3.34/Lib/python/pyfragments.swg new file mode 100644 index 0000000..535a45b --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pyfragments.swg @@ -0,0 +1,23 @@ +/* + + Create a file with this name, 'pyfragments.swg', in your working + directory and add all the %fragments you want to take precedence + over the default ones defined by swig. + + For example, if you add: + + %fragment(SWIG_AsVal_frag(int),"header") { + SWIGINTERNINLINE int + SWIG_AsVal(int)(PyObject *obj, int *val) + { + <your code here>; + } + } + + this will replace the code used to retrieve an integer value for all + the typemaps that need it, including: + + int, std::vector<int>, std::list<std::pair<int,int> >, etc. + + +*/ diff --git a/devtools/swigwin-1.3.34/Lib/python/pyhead.swg b/devtools/swigwin-1.3.34/Lib/python/pyhead.swg new file mode 100644 index 0000000..7839511 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pyhead.swg @@ -0,0 +1,88 @@ + +/* Add PyOS_snprintf for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +# define PyOS_snprintf _snprintf +# else +# define PyOS_snprintf snprintf +# endif +#endif + +/* A crude PyString_FromFormat implementation for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 + +#ifndef SWIG_PYBUFFER_SIZE +# define SWIG_PYBUFFER_SIZE 1024 +#endif + +static PyObject * +PyString_FromFormat(const char *fmt, ...) { + va_list ap; + char buf[SWIG_PYBUFFER_SIZE * 2]; + int res; + va_start(ap, fmt); + res = vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); +} +#endif + +/* Add PyObject_Del for old Pythons */ +#if PY_VERSION_HEX < 0x01060000 +# define PyObject_Del(op) PyMem_DEL((op)) +#endif +#ifndef PyObject_DEL +# define PyObject_DEL PyObject_Del +#endif + +/* A crude PyExc_StopIteration exception for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +# ifndef PyExc_StopIteration +# define PyExc_StopIteration PyExc_RuntimeError +# endif +# ifndef PyObject_GenericGetAttr +# define PyObject_GenericGetAttr 0 +# endif +#endif +/* Py_NotImplemented is defined in 2.1 and up. */ +#if PY_VERSION_HEX < 0x02010000 +# ifndef Py_NotImplemented +# define Py_NotImplemented PyExc_RuntimeError +# endif +#endif + + +/* A crude PyString_AsStringAndSize implementation for old Pythons */ +#if PY_VERSION_HEX < 0x02010000 +# ifndef PyString_AsStringAndSize +# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} +# endif +#endif + +/* PySequence_Size for old Pythons */ +#if PY_VERSION_HEX < 0x02000000 +# ifndef PySequence_Size +# define PySequence_Size PySequence_Length +# endif +#endif + + +/* PyBool_FromLong for old Pythons */ +#if PY_VERSION_HEX < 0x02030000 +static +PyObject *PyBool_FromLong(long ok) +{ + PyObject *result = ok ? Py_True : Py_False; + Py_INCREF(result); + return result; +} +#endif + +/* Py_ssize_t for old Pythons */ +/* This code is as recommended by: */ +/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ +#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) +typedef int Py_ssize_t; +# define PY_SSIZE_T_MAX INT_MAX +# define PY_SSIZE_T_MIN INT_MIN +#endif diff --git a/devtools/swigwin-1.3.34/Lib/python/pyinit.swg b/devtools/swigwin-1.3.34/Lib/python/pyinit.swg new file mode 100644 index 0000000..e6109b7 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pyinit.swg @@ -0,0 +1,288 @@ +/* ------------------------------------------------------------ + * The start of the Python initialization function + * ------------------------------------------------------------ */ + +%insert(init) "swiginit.swg" + +%init %{ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Python-specific SWIG API */ +#define SWIG_newvarlink() SWIG_Python_newvarlink() +#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) +#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) + +/* ----------------------------------------------------------------------------- + * global variable support code. + * ----------------------------------------------------------------------------- */ + +typedef struct swig_globalvar { + char *name; /* Name of global variable */ + PyObject *(*get_attr)(void); /* Return the current value */ + int (*set_attr)(PyObject *); /* Set the value */ + struct swig_globalvar *next; +} swig_globalvar; + +typedef struct swig_varlinkobject { + PyObject_HEAD + swig_globalvar *vars; +} swig_varlinkobject; + +SWIGINTERN PyObject * +swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { + return PyString_FromString("<Swig global variables>"); +} + +SWIGINTERN PyObject * +swig_varlink_str(swig_varlinkobject *v) { + PyObject *str = PyString_FromString("("); + swig_globalvar *var; + for (var = v->vars; var; var=var->next) { + PyString_ConcatAndDel(&str,PyString_FromString(var->name)); + if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); + } + PyString_ConcatAndDel(&str,PyString_FromString(")")); + return str; +} + +SWIGINTERN int +swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { + PyObject *str = swig_varlink_str(v); + fprintf(fp,"Swig global variables "); + fprintf(fp,"%s\n", PyString_AsString(str)); + Py_DECREF(str); + return 0; +} + +SWIGINTERN void +swig_varlink_dealloc(swig_varlinkobject *v) { + swig_globalvar *var = v->vars; + while (var) { + swig_globalvar *n = var->next; + free(var->name); + free(var); + var = n; + } +} + +SWIGINTERN PyObject * +swig_varlink_getattr(swig_varlinkobject *v, char *n) { + PyObject *res = NULL; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->get_attr)(); + break; + } + var = var->next; + } + if (res == NULL && !PyErr_Occurred()) { + PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + } + return res; +} + +SWIGINTERN int +swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { + int res = 1; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->set_attr)(p); + break; + } + var = var->next; + } + if (res == 1 && !PyErr_Occurred()) { + PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + } + return res; +} + +SWIGINTERN PyTypeObject* +swig_varlink_type(void) { + static char varlink__doc__[] = "Swig var link object"; + static PyTypeObject varlink_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp + = { + PyObject_HEAD_INIT(NULL) + 0, /* Number of items in variable part (ob_size) */ + (char *)"swigvarlink", /* Type name (tp_name) */ + sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */ + 0, /* Itemsize (tp_itemsize) */ + (destructor) swig_varlink_dealloc, /* Deallocator (tp_dealloc) */ + (printfunc) swig_varlink_print, /* Print (tp_print) */ + (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */ + (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */ + 0, /* tp_compare */ + (reprfunc) swig_varlink_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc)swig_varlink_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + 0, /* tp_flags */ + varlink__doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; + varlink_type = tmp; + varlink_type.ob_type = &PyType_Type; + type_init = 1; + } + return &varlink_type; +} + +/* Create a variable linking object for use later */ +SWIGINTERN PyObject * +SWIG_Python_newvarlink(void) { + swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); + if (result) { + result->vars = 0; + } + return ((PyObject*) result); +} + +SWIGINTERN void +SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { + swig_varlinkobject *v = (swig_varlinkobject *) p; + swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); + if (gv) { + size_t size = strlen(name)+1; + gv->name = (char *)malloc(size); + if (gv->name) { + strncpy(gv->name,name,size); + gv->get_attr = get_attr; + gv->set_attr = set_attr; + gv->next = v->vars; + } + } + v->vars = gv; +} + +SWIGINTERN PyObject * +SWIG_globals(void) { + static PyObject *_SWIG_globals = 0; + if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); + return _SWIG_globals; +} + +/* ----------------------------------------------------------------------------- + * constants/methods manipulation + * ----------------------------------------------------------------------------- */ + +/* Install Constants */ +SWIGINTERN void +SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { + PyObject *obj = 0; + size_t i; + for (i = 0; constants[i].type; ++i) { + switch(constants[i].type) { + case SWIG_PY_POINTER: + obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); + break; + case SWIG_PY_BINARY: + obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); + break; + default: + obj = 0; + break; + } + if (obj) { + PyDict_SetItemString(d, constants[i].name, obj); + Py_DECREF(obj); + } + } +} + +/* -----------------------------------------------------------------------------*/ +/* Fix SwigMethods to carry the callback ptrs when needed */ +/* -----------------------------------------------------------------------------*/ + +SWIGINTERN void +SWIG_Python_FixMethods(PyMethodDef *methods, + swig_const_info *const_table, + swig_type_info **types, + swig_type_info **types_initial) { + size_t i; + for (i = 0; methods[i].ml_name; ++i) { + const char *c = methods[i].ml_doc; + if (c && (c = strstr(c, "swig_ptr: "))) { + int j; + swig_const_info *ci = 0; + const char *name = c + 10; + for (j = 0; const_table[j].type; ++j) { + if (strncmp(const_table[j].name, name, + strlen(const_table[j].name)) == 0) { + ci = &(const_table[j]); + break; + } + } + if (ci) { + size_t shift = (ci->ptype) - types; + swig_type_info *ty = types_initial[shift]; + size_t ldoc = (c - methods[i].ml_doc); + size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; + char *ndoc = (char*)malloc(ldoc + lptr + 10); + if (ndoc) { + char *buff = ndoc; + void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; + if (ptr) { + strncpy(buff, methods[i].ml_doc, ldoc); + buff += ldoc; + strncpy(buff, "swig_ptr: ", 10); + buff += 10; + SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); + methods[i].ml_doc = ndoc; + } + } + } + } + } +} + +#ifdef __cplusplus +} +#endif + +/* -----------------------------------------------------------------------------* + * Partial Init method + * -----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void SWIG_init(void) { + PyObject *m, *d; + + /* Fix SwigMethods to carry the callback ptrs when needed */ + SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); + + m = Py_InitModule((char *) SWIG_name, SwigMethods); + d = PyModule_GetDict(m); + + SWIG_InitializeModule(0); + SWIG_InstallConstants(d,swig_const_table); + +%} + diff --git a/devtools/swigwin-1.3.34/Lib/python/pyiterators.swg b/devtools/swigwin-1.3.34/Lib/python/pyiterators.swg new file mode 100644 index 0000000..980103e --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pyiterators.swg @@ -0,0 +1,380 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * pyiterators.swg + * + * Implement a python 'output' iterator for Python 2.2 or higher. + * + * Users can derive form the PySwigIterator to implemet their + * own iterators. As an example (real one since we use it for STL/STD + * containers), the template PySwigIterator_T does the + * implementation for genereic C++ iterators. + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +%fragment("PySwigIterator","header") { +namespace swig { + struct stop_iteration { + }; + + struct PySwigIterator { + private: + PyObject_ptr _seq; + + protected: + PySwigIterator(PyObject *seq) : _seq(seq) + { + } + + public: + virtual ~PySwigIterator() {} + + // Access iterator method, required by Python + virtual PyObject *value() const = 0; + + // Forward iterator method, required by Python + virtual PySwigIterator *incr(size_t n = 1) = 0; + + // Backward iterator method, very common in C++, but not required in Python + virtual PySwigIterator *decr(size_t n = 1) + { + throw stop_iteration(); + } + + // Random access iterator methods, but not required in Python + virtual ptrdiff_t distance(const PySwigIterator &x) const + { + throw std::invalid_argument("operation not supported"); + } + + virtual bool equal (const PySwigIterator &x) const + { + throw std::invalid_argument("operation not supported"); + } + + // C++ common/needed methods + virtual PySwigIterator *copy() const = 0; + + PyObject *next() + { + PyObject *obj = value(); + incr(); + return obj; + } + + PyObject *previous() + { + decr(); + return value(); + } + + PySwigIterator *advance(ptrdiff_t n) + { + return (n > 0) ? incr(n) : decr(-n); + } + + bool operator == (const PySwigIterator& x) const + { + return equal(x); + } + + bool operator != (const PySwigIterator& x) const + { + return ! operator==(x); + } + + PySwigIterator& operator += (ptrdiff_t n) + { + return *advance(n); + } + + PySwigIterator& operator -= (ptrdiff_t n) + { + return *advance(-n); + } + + PySwigIterator* operator + (ptrdiff_t n) const + { + return copy()->advance(n); + } + + PySwigIterator* operator - (ptrdiff_t n) const + { + return copy()->advance(-n); + } + + ptrdiff_t operator - (const PySwigIterator& x) const + { + return x.distance(*this); + } + + static swig_type_info* descriptor() { + static int init = 0; + static swig_type_info* desc = 0; + if (!init) { + desc = SWIG_TypeQuery("swig::PySwigIterator *"); + init = 1; + } + return desc; + } + }; +} +} + +%fragment("PySwigIterator_T","header",fragment="PySwigIterator",fragment="StdTraits",fragment="StdIteratorTraits") { +namespace swig { + template<typename OutIterator> + class PySwigIterator_T : public PySwigIterator + { + public: + typedef OutIterator out_iterator; + typedef typename std::iterator_traits<out_iterator>::value_type value_type; + typedef PySwigIterator_T<out_iterator> self_type; + + PySwigIterator_T(out_iterator curr, PyObject *seq) + : PySwigIterator(seq), current(curr) + { + } + + const out_iterator& get_current() const + { + return current; + } + + + bool equal (const PySwigIterator &iter) const + { + const self_type *iters = dynamic_cast<const self_type *>(&iter); + if (iters) { + return (current == iters->get_current()); + } else { + throw std::invalid_argument("bad iterator type"); + } + } + + ptrdiff_t distance(const PySwigIterator &iter) const + { + const self_type *iters = dynamic_cast<const self_type *>(&iter); + if (iters) { + return std::distance(current, iters->get_current()); + } else { + throw std::invalid_argument("bad iterator type"); + } + } + + protected: + out_iterator current; + }; + + template <class ValueType> + struct from_oper + { + typedef const ValueType& argument_type; + typedef PyObject *result_type; + result_type operator()(argument_type v) const + { + return swig::from(v); + } + }; + + template<typename OutIterator, + typename ValueType = typename std::iterator_traits<OutIterator>::value_type, + typename FromOper = from_oper<ValueType> > + class PySwigIteratorOpen_T : public PySwigIterator_T<OutIterator> + { + public: + FromOper from; + typedef OutIterator out_iterator; + typedef ValueType value_type; + typedef PySwigIterator_T<out_iterator> base; + typedef PySwigIteratorOpen_T<OutIterator, ValueType, FromOper> self_type; + + PySwigIteratorOpen_T(out_iterator curr, PyObject *seq) + : PySwigIterator_T<OutIterator>(curr, seq) + { + } + + PyObject *value() const { + return from(static_cast<const value_type&>(*(base::current))); + } + + PySwigIterator *copy() const + { + return new self_type(*this); + } + + PySwigIterator *incr(size_t n = 1) + { + while (n--) { + ++base::current; + } + return this; + } + + PySwigIterator *decr(size_t n = 1) + { + while (n--) { + --base::current; + } + return this; + } + }; + + template<typename OutIterator, + typename ValueType = typename std::iterator_traits<OutIterator>::value_type, + typename FromOper = from_oper<ValueType> > + class PySwigIteratorClosed_T : public PySwigIterator_T<OutIterator> + { + public: + FromOper from; + typedef OutIterator out_iterator; + typedef ValueType value_type; + typedef PySwigIterator_T<out_iterator> base; + typedef PySwigIteratorClosed_T<OutIterator, ValueType, FromOper> self_type; + + PySwigIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, PyObject *seq) + : PySwigIterator_T<OutIterator>(curr, seq), begin(first), end(last) + { + } + + PyObject *value() const { + if (base::current == end) { + throw stop_iteration(); + } else { + return from(static_cast<const value_type&>(*(base::current))); + } + } + + PySwigIterator *copy() const + { + return new self_type(*this); + } + + PySwigIterator *incr(size_t n = 1) + { + while (n--) { + if (base::current == end) { + throw stop_iteration(); + } else { + ++base::current; + } + } + return this; + } + + PySwigIterator *decr(size_t n = 1) + { + while (n--) { + if (base::current == begin) { + throw stop_iteration(); + } else { + --base::current; + } + } + return this; + } + + private: + out_iterator begin; + out_iterator end; + }; + + template<typename OutIter> + inline PySwigIterator* + make_output_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, PyObject *seq = 0) + { + return new PySwigIteratorClosed_T<OutIter>(current, begin, end, seq); + } + + template<typename OutIter> + inline PySwigIterator* + make_output_iterator(const OutIter& current, PyObject *seq = 0) + { + return new PySwigIteratorOpen_T<OutIter>(current, seq); + } +} +} + + +%fragment("PySwigIterator"); +namespace swig +{ + /* + Throw a StopIteration exception + */ + %ignore stop_iteration; + struct stop_iteration {}; + + %typemap(throws) stop_iteration { + (void)$1; + SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void()); + SWIG_fail; + } + + /* + Mark methods that return new objects + */ + %newobject PySwigIterator::copy; + %newobject PySwigIterator::operator + (ptrdiff_t n) const; + %newobject PySwigIterator::operator - (ptrdiff_t n) const; + + %nodirector PySwigIterator; + %extend PySwigIterator { + %pythoncode {def __iter__(self): return self} + } + + %catches(swig::stop_iteration) PySwigIterator::value() const; + %catches(swig::stop_iteration) PySwigIterator::incr(size_t n = 1); + %catches(swig::stop_iteration) PySwigIterator::decr(size_t n = 1); + %catches(std::invalid_argument) PySwigIterator::distance(const PySwigIterator &x) const; + %catches(std::invalid_argument) PySwigIterator::equal (const PySwigIterator &x) const; + %catches(swig::stop_iteration) PySwigIterator::next(); + %catches(swig::stop_iteration) PySwigIterator::previous(); + %catches(swig::stop_iteration) PySwigIterator::advance(ptrdiff_t n); + %catches(swig::stop_iteration) PySwigIterator::operator += (ptrdiff_t n); + %catches(swig::stop_iteration) PySwigIterator::operator -= (ptrdiff_t n); + %catches(swig::stop_iteration) PySwigIterator::operator + (ptrdiff_t n) const; + %catches(swig::stop_iteration) PySwigIterator::operator - (ptrdiff_t n) const; + + + struct PySwigIterator + { + protected: + PySwigIterator(PyObject *seq); + + public: + virtual ~PySwigIterator(); + + // Access iterator method, required by Python + virtual PyObject *value() const = 0; + + // Forward iterator method, required by Python + virtual PySwigIterator *incr(size_t n = 1) = 0; + + // Backward iterator method, very common in C++, but not required in Python + virtual PySwigIterator *decr(size_t n = 1); + + // Random access iterator methods, but not required in Python + virtual ptrdiff_t distance(const PySwigIterator &x) const; + + virtual bool equal (const PySwigIterator &x) const; + + // C++ common/needed methods + virtual PySwigIterator *copy() const = 0; + + PyObject *next(); + PyObject *previous(); + PySwigIterator *advance(ptrdiff_t n); + + bool operator == (const PySwigIterator& x) const; + bool operator != (const PySwigIterator& x) const; + PySwigIterator& operator += (ptrdiff_t n); + PySwigIterator& operator -= (ptrdiff_t n); + PySwigIterator* operator + (ptrdiff_t n) const; + PySwigIterator* operator - (ptrdiff_t n) const; + ptrdiff_t operator - (const PySwigIterator& x) const; + }; +} + diff --git a/devtools/swigwin-1.3.34/Lib/python/pymacros.swg b/devtools/swigwin-1.3.34/Lib/python/pymacros.swg new file mode 100644 index 0000000..ab7bace --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pymacros.swg @@ -0,0 +1,4 @@ +%include <typemaps/swigmacros.swg> + + + diff --git a/devtools/swigwin-1.3.34/Lib/python/pyopers.swg b/devtools/swigwin-1.3.34/Lib/python/pyopers.swg new file mode 100644 index 0000000..442515d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pyopers.swg @@ -0,0 +1,129 @@ +/* ------------------------------------------------------------ + * Overloaded operator support + * ------------------------------------------------------------ */ + + +#ifdef __cplusplus + +#define %pybinoperator(pyname,oper) %rename(pyname) oper; %pythonmaybecall oper + +%pybinoperator(__add__, *::operator+); +%pybinoperator(__pos__, *::operator+()); +%pybinoperator(__pos__, *::operator+() const); +%pybinoperator(__sub__, *::operator-); +%pybinoperator(__neg__, *::operator-()); +%pybinoperator(__neg__, *::operator-() const); +%pybinoperator(__mul__, *::operator*); +%pybinoperator(__div__, *::operator/); +%pybinoperator(__mod__, *::operator%); +%pybinoperator(__lshift__, *::operator<<); +%pybinoperator(__rshift__, *::operator>>); +%pybinoperator(__and__, *::operator&); +%pybinoperator(__or__, *::operator|); +%pybinoperator(__xor__, *::operator^); +%pybinoperator(__lt__, *::operator<); +%pybinoperator(__le__, *::operator<=); +%pybinoperator(__gt__, *::operator>); +%pybinoperator(__ge__, *::operator>=); +%pybinoperator(__eq__, *::operator==); +%pybinoperator(__ne__, *::operator!=); + + + +/* Special cases */ +%rename(__invert__) *::operator~; +%rename(__call__) *::operator(); + +/* Ignored operators */ +%ignoreoperator(LNOT) operator!; +%ignoreoperator(LAND) operator&&; +%ignoreoperator(LOR) operator||; +%ignoreoperator(EQ) *::operator=; +%ignoreoperator(PLUSPLUS) *::operator++; +%ignoreoperator(MINUSMINUS) *::operator--; +%ignoreoperator(ARROWSTAR) *::operator->*; +%ignoreoperator(INDEX) *::operator[]; + +/* + Inplace operator declarations. + + They translate the inplace C++ operators (+=, -=, ...) into the + corresponding python equivalents(__iadd__,__isub__), etc, + disabling the ownership of the input 'self' pointer, and assigning + it to the returning object: + + %feature("del") *::Operator; + %feature("new") *::Operator; + + This makes the most common case safe, ie: + + A& A::operator+=(int i) { ...; return *this; } + ^^^^ ^^^^^^ + + will work fine, even when the resulting python object shares the + 'this' pointer with the input one. The input object is usually + deleted after the operation, including the shared 'this' pointer, + producing 'strange' seg faults, as reported by Lucriz + ([email protected]). + + If you have an interface that already takes care of that, ie, you + already are using inplace operators and you are not getting + seg. faults, with the new scheme you could end with 'free' elements + that never get deleted (maybe, not sure, it depends). But if that is + the case, you could recover the old behaviour using + + %feature("del","") A::operator+=; + %feature("new","") A::operator+=; + + which recovers the old behaviour for the class 'A', or if you are + 100% sure your entire system works fine in the old way, use: + + %feature("del","") *::operator+=; + %feature("new","") *::operator+=; + +*/ + +#define %pyinplaceoper(PyOper, Oper) %delobject Oper; %newobject Oper; %rename(PyOper) Oper + +%pyinplaceoper(__iadd__ , *::operator +=); +%pyinplaceoper(__isub__ , *::operator -=); +%pyinplaceoper(__imul__ , *::operator *=); +%pyinplaceoper(__idiv__ , *::operator /=); +%pyinplaceoper(__imod__ , *::operator %=); +%pyinplaceoper(__iand__ , *::operator &=); +%pyinplaceoper(__ior__ , *::operator |=); +%pyinplaceoper(__ixor__ , *::operator ^=); +%pyinplaceoper(__ilshift__, *::operator <<=); +%pyinplaceoper(__irshift__, *::operator >>=); + + +/* Finally, in python we need to mark the binary operations to fail as + 'maybecall' methods */ + +#define %pybinopermaybecall(oper) %pythonmaybecall __ ## oper ## __; %pythonmaybecall __r ## oper ## __ + +%pybinopermaybecall(add); +%pybinopermaybecall(pos); +%pybinopermaybecall(pos); +%pybinopermaybecall(sub); +%pybinopermaybecall(neg); +%pybinopermaybecall(neg); +%pybinopermaybecall(mul); +%pybinopermaybecall(div); +%pybinopermaybecall(mod); +%pybinopermaybecall(lshift); +%pybinopermaybecall(rshift); +%pybinopermaybecall(and); +%pybinopermaybecall(or); +%pybinopermaybecall(xor); +%pybinopermaybecall(lt); +%pybinopermaybecall(le); +%pybinopermaybecall(gt); +%pybinopermaybecall(ge); +%pybinopermaybecall(eq); +%pybinopermaybecall(ne); + +#endif + + + diff --git a/devtools/swigwin-1.3.34/Lib/python/pyprimtypes.swg b/devtools/swigwin-1.3.34/Lib/python/pyprimtypes.swg new file mode 100644 index 0000000..63435ee --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pyprimtypes.swg @@ -0,0 +1,292 @@ +/* ------------------------------------------------------------ + * Primitive Types + * ------------------------------------------------------------ */ + +/* boolean */ + +%fragment(SWIG_From_frag(bool),"header") { +SWIGINTERNINLINE PyObject* + SWIG_From_dec(bool)(bool value) +{ + return PyBool_FromLong(value ? 1 : 0); +} +} + +%fragment(SWIG_AsVal_frag(bool),"header", + fragment=SWIG_AsVal_frag(long)) { +SWIGINTERN int +SWIG_AsVal_dec(bool)(PyObject *obj, bool *val) +{ + int r = PyObject_IsTrue(obj); + if (r == -1) + return SWIG_ERROR; + if (val) *val = r ? true : false; + return SWIG_OK; +} +} + +/* long */ + +%fragment(SWIG_From_frag(long),"header") { + %define_as(SWIG_From_dec(long), PyInt_FromLong) +} + +%fragment(SWIG_AsVal_frag(long),"header", + fragment="SWIG_CanCastAsInteger") { +SWIGINTERN int +SWIG_AsVal_dec(long)(PyObject *obj, long* val) +{ + if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return SWIG_OK; + } else if (PyLong_Check(obj)) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } +%#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + long v = PyInt_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { + if (val) *val = (long)(d); + return res; + } + } + } +%#endif + return SWIG_TypeError; +} +} + +/* unsigned long */ + +%fragment(SWIG_From_frag(unsigned long),"header", + fragment=SWIG_From_frag(long)) { +SWIGINTERNINLINE PyObject* +SWIG_From_dec(unsigned long)(unsigned long value) +{ + return (value > LONG_MAX) ? + PyLong_FromUnsignedLong(value) : PyInt_FromLong(%numeric_cast(value,long)); +} +} + +%fragment(SWIG_AsVal_frag(unsigned long),"header", + fragment="SWIG_CanCastAsInteger") { +SWIGINTERN int +SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val) +{ + if (PyInt_Check(obj)) { + long v = PyInt_AsLong(obj); + if (v >= 0) { + if (val) *val = v; + return SWIG_OK; + } else { + return SWIG_OverflowError; + } + } else if (PyLong_Check(obj)) { + unsigned long v = PyLong_AsUnsignedLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } +%#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + unsigned long v = PyLong_AsUnsignedLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { + if (val) *val = (unsigned long)(d); + return res; + } + } + } +%#endif + return SWIG_TypeError; +} +} + +/* long long */ + +%fragment(SWIG_From_frag(long long),"header", + fragment=SWIG_From_frag(long), + fragment="<limits.h>") { +SWIGINTERNINLINE PyObject* +SWIG_From_dec(long long)(long long value) +{ + return ((value < LONG_MIN) || (value > LONG_MAX)) ? + PyLong_FromLongLong(value) : PyInt_FromLong(%numeric_cast(value,long)); +} +} + +%fragment(SWIG_AsVal_frag(long long),"header", + fragment=SWIG_AsVal_frag(long), + fragment="SWIG_CanCastAsInteger", + fragment="<limits.h>") { +SWIGINTERN int +SWIG_AsVal_dec(long long)(PyObject *obj, long long *val) +{ + int res = SWIG_TypeError; + if (PyLong_Check(obj)) { + long long v = PyLong_AsLongLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } else { + long v; + res = SWIG_AsVal(long)(obj,&v); + if (SWIG_IsOK(res)) { + if (val) *val = v; + return res; + } + } +%#ifdef SWIG_PYTHON_CAST_MODE + { + const double mant_max = 1LL << DBL_MANT_DIG; + const double mant_min = -mant_max; + double d; + res = SWIG_AsVal(double)(obj,&d); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, mant_min, mant_max)) { + if (val) *val = (long long)(d); + return SWIG_AddCast(res); + } + res = SWIG_TypeError; + } +%#endif + return res; +} +} + +/* unsigned long long */ + +%fragment(SWIG_From_frag(unsigned long long),"header", + fragment=SWIG_From_frag(long long), + fragment="<limits.h>") { +SWIGINTERNINLINE PyObject* +SWIG_From_dec(unsigned long long)(unsigned long long value) +{ + return (value > LONG_MAX) ? + PyLong_FromUnsignedLongLong(value) : PyInt_FromLong(%numeric_cast(value,long)); +} +} + +%fragment(SWIG_AsVal_frag(unsigned long long),"header", + fragment=SWIG_AsVal_frag(unsigned long), + fragment="SWIG_CanCastAsInteger", + fragment="<limits.h>") { +SWIGINTERN int +SWIG_AsVal_dec(unsigned long long)(PyObject *obj, unsigned long long *val) +{ + int res = SWIG_TypeError; + if (PyLong_Check(obj)) { + unsigned long long v = PyLong_AsUnsignedLongLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } else { + unsigned long v; + res = SWIG_AsVal(unsigned long)(obj,&v); + if (SWIG_IsOK(res)) { + if (val) *val = v; + return res; + } + } +%#ifdef SWIG_PYTHON_CAST_MODE + { + const double mant_max = 1LL << DBL_MANT_DIG; + double d; + res = SWIG_AsVal(double)(obj,&d); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) { + if (val) *val = (unsigned long long)(d); + return SWIG_AddCast(res); + } + res = SWIG_TypeError; + } +%#endif + return res; +} +} + +/* double */ + +%fragment(SWIG_From_frag(double),"header") { + %define_as(SWIG_From_dec(double), PyFloat_FromDouble) +} + +%fragment(SWIG_AsVal_frag(double),"header") { +SWIGINTERN int +SWIG_AsVal_dec(double)(PyObject *obj, double *val) +{ + int res = SWIG_TypeError; + if (PyFloat_Check(obj)) { + if (val) *val = PyFloat_AsDouble(obj); + return SWIG_OK; + } else if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return SWIG_OK; + } else if (PyLong_Check(obj)) { + double v = PyLong_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } +%#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + double d = PyFloat_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = d; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); + } else { + PyErr_Clear(); + } + } + } +%#endif + return res; +} +} + + + diff --git a/devtools/swigwin-1.3.34/Lib/python/pyrun.swg b/devtools/swigwin-1.3.34/Lib/python/pyrun.swg new file mode 100644 index 0000000..3a6d6ed --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pyrun.swg @@ -0,0 +1,1496 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * pyrun.swg + * + * This file contains the runtime support for Python modules + * and includes code for managing global variables and pointer + * type checking. + * + * ----------------------------------------------------------------------------- */ + +/* Common SWIG API */ + +/* for raw pointers */ +#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) +#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) +#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags) +#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) +#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) +#define swig_owntype int + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Python_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) +#define SWIG_NewClientData(obj) PySwigClientData_New(obj) + +#define SWIG_SetErrorObj SWIG_Python_SetErrorObj +#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg +#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) +#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) +#define SWIG_fail goto fail + + +/* Runtime API implementation */ + +/* Error manipulation */ + +SWIGINTERN void +SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetObject(errtype, obj); + Py_DECREF(obj); + SWIG_PYTHON_THREAD_END_BLOCK; +} + +SWIGINTERN void +SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(errtype, (char *) msg); + SWIG_PYTHON_THREAD_END_BLOCK; +} + +#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) + +/* Set a constant value */ + +SWIGINTERN void +SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { + PyDict_SetItemString(d, (char*) name, obj); + Py_DECREF(obj); +} + +/* Append a value to the result obj */ + +SWIGINTERN PyObject* +SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { +#if !defined(SWIG_PYTHON_OUTPUT_TUPLE) + if (!result) { + result = obj; + } else if (result == Py_None) { + Py_DECREF(result); + result = obj; + } else { + if (!PyList_Check(result)) { + PyObject *o2 = result; + result = PyList_New(1); + PyList_SetItem(result, 0, o2); + } + PyList_Append(result,obj); + Py_DECREF(obj); + } + return result; +#else + PyObject* o2; + PyObject* o3; + if (!result) { + result = obj; + } else if (result == Py_None) { + Py_DECREF(result); + result = obj; + } else { + if (!PyTuple_Check(result)) { + o2 = result; + result = PyTuple_New(1); + PyTuple_SET_ITEM(result, 0, o2); + } + o3 = PyTuple_New(1); + PyTuple_SET_ITEM(o3, 0, obj); + o2 = result; + result = PySequence_Concat(o2, o3); + Py_DECREF(o2); + Py_DECREF(o3); + } + return result; +#endif +} + +/* Unpack the argument tuple */ + +SWIGINTERN int +SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) +{ + if (!args) { + if (!min && !max) { + return 1; + } else { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", + name, (min == max ? "" : "at least "), (int)min); + return 0; + } + } + if (!PyTuple_Check(args)) { + PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); + return 0; + } else { + register Py_ssize_t l = PyTuple_GET_SIZE(args); + if (l < min) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at least "), (int)min, (int)l); + return 0; + } else if (l > max) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at most "), (int)max, (int)l); + return 0; + } else { + register int i; + for (i = 0; i < l; ++i) { + objs[i] = PyTuple_GET_ITEM(args, i); + } + for (; l < max; ++l) { + objs[l] = 0; + } + return i + 1; + } + } +} + +/* A functor is a function object with one single object argument */ +#if PY_VERSION_HEX >= 0x02020000 +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); +#else +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); +#endif + +/* + Helper for static pointer initialization for both C and C++ code, for example + static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); +*/ +#ifdef __cplusplus +#define SWIG_STATIC_POINTER(var) var +#else +#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var +#endif + +/* ----------------------------------------------------------------------------- + * Pointer declarations + * ----------------------------------------------------------------------------- */ + +/* Flags for new pointer objects */ +#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) +#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) + +#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* cc-mode */ +#endif +#endif + +/* How to access Py_None */ +#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# ifndef SWIG_PYTHON_NO_BUILD_NONE +# ifndef SWIG_PYTHON_BUILD_NONE +# define SWIG_PYTHON_BUILD_NONE +# endif +# endif +#endif + +#ifdef SWIG_PYTHON_BUILD_NONE +# ifdef Py_None +# undef Py_None +# define Py_None SWIG_Py_None() +# endif +SWIGRUNTIMEINLINE PyObject * +_SWIG_Py_None(void) +{ + PyObject *none = Py_BuildValue((char*)""); + Py_DECREF(none); + return none; +} +SWIGRUNTIME PyObject * +SWIG_Py_None(void) +{ + static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); + return none; +} +#endif + +/* The python void return value */ + +SWIGRUNTIMEINLINE PyObject * +SWIG_Py_Void(void) +{ + PyObject *none = Py_None; + Py_INCREF(none); + return none; +} + +/* PySwigClientData */ + +typedef struct { + PyObject *klass; + PyObject *newraw; + PyObject *newargs; + PyObject *destroy; + int delargs; + int implicitconv; +} PySwigClientData; + +SWIGRUNTIMEINLINE int +SWIG_Python_CheckImplicit(swig_type_info *ty) +{ + PySwigClientData *data = (PySwigClientData *)ty->clientdata; + return data ? data->implicitconv : 0; +} + +SWIGRUNTIMEINLINE PyObject * +SWIG_Python_ExceptionType(swig_type_info *desc) { + PySwigClientData *data = desc ? (PySwigClientData *) desc->clientdata : 0; + PyObject *klass = data ? data->klass : 0; + return (klass ? klass : PyExc_RuntimeError); +} + + +SWIGRUNTIME PySwigClientData * +PySwigClientData_New(PyObject* obj) +{ + if (!obj) { + return 0; + } else { + PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData)); + /* the klass element */ + data->klass = obj; + Py_INCREF(data->klass); + /* the newraw method and newargs arguments used to create a new raw instance */ + if (PyClass_Check(obj)) { + data->newraw = 0; + data->newargs = obj; + Py_INCREF(obj); + } else { +#if (PY_VERSION_HEX < 0x02020000) + data->newraw = 0; +#else + data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); +#endif + if (data->newraw) { + Py_INCREF(data->newraw); + data->newargs = PyTuple_New(1); + PyTuple_SetItem(data->newargs, 0, obj); + } else { + data->newargs = obj; + } + Py_INCREF(data->newargs); + } + /* the destroy method, aka as the C++ delete method */ + data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); + if (PyErr_Occurred()) { + PyErr_Clear(); + data->destroy = 0; + } + if (data->destroy) { + int flags; + Py_INCREF(data->destroy); + flags = PyCFunction_GET_FLAGS(data->destroy); +#ifdef METH_O + data->delargs = !(flags & (METH_O)); +#else + data->delargs = 0; +#endif + } else { + data->delargs = 0; + } + data->implicitconv = 0; + return data; + } +} + +SWIGRUNTIME void +PySwigClientData_Del(PySwigClientData* data) +{ + Py_XDECREF(data->newraw); + Py_XDECREF(data->newargs); + Py_XDECREF(data->destroy); +} + +/* =============== PySwigObject =====================*/ + +typedef struct { + PyObject_HEAD + void *ptr; + swig_type_info *ty; + int own; + PyObject *next; +} PySwigObject; + +SWIGRUNTIME PyObject * +PySwigObject_long(PySwigObject *v) +{ + return PyLong_FromVoidPtr(v->ptr); +} + +SWIGRUNTIME PyObject * +PySwigObject_format(const char* fmt, PySwigObject *v) +{ + PyObject *res = NULL; + PyObject *args = PyTuple_New(1); + if (args) { + if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) { + PyObject *ofmt = PyString_FromString(fmt); + if (ofmt) { + res = PyString_Format(ofmt,args); + Py_DECREF(ofmt); + } + Py_DECREF(args); + } + } + return res; +} + +SWIGRUNTIME PyObject * +PySwigObject_oct(PySwigObject *v) +{ + return PySwigObject_format("%o",v); +} + +SWIGRUNTIME PyObject * +PySwigObject_hex(PySwigObject *v) +{ + return PySwigObject_format("%x",v); +} + +SWIGRUNTIME PyObject * +#ifdef METH_NOARGS +PySwigObject_repr(PySwigObject *v) +#else +PySwigObject_repr(PySwigObject *v, PyObject *args) +#endif +{ + const char *name = SWIG_TypePrettyName(v->ty); + PyObject *hex = PySwigObject_hex(v); + PyObject *repr = PyString_FromFormat("<Swig Object of type '%s' at 0x%s>", name, PyString_AsString(hex)); + Py_DECREF(hex); + if (v->next) { +#ifdef METH_NOARGS + PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next); +#else + PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args); +#endif + PyString_ConcatAndDel(&repr,nrep); + } + return repr; +} + +SWIGRUNTIME int +PySwigObject_print(PySwigObject *v, FILE *, int SWIGUNUSEDPARM(flags)) +{ +#ifdef METH_NOARGS + PyObject *repr = PySwigObject_repr(v); +#else + PyObject *repr = PySwigObject_repr(v, NULL); +#endif + if (repr) { + printf(PyString_AsString(repr)); + Py_DECREF(repr); + return 0; + } else { + return 1; + } +} + +SWIGRUNTIME PyObject * +PySwigObject_str(PySwigObject *v) +{ + char result[SWIG_BUFFER_SIZE]; + return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? + PyString_FromString(result) : 0; +} + +SWIGRUNTIME int +PySwigObject_compare(PySwigObject *v, PySwigObject *w) +{ + void *i = v->ptr; + void *j = w->ptr; + return (i < j) ? -1 : ((i > j) ? 1 : 0); +} + +SWIGRUNTIME PyTypeObject* _PySwigObject_type(void); + +SWIGRUNTIME PyTypeObject* +PySwigObject_type(void) { + static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type(); + return type; +} + +SWIGRUNTIMEINLINE int +PySwigObject_Check(PyObject *op) { + return ((op)->ob_type == PySwigObject_type()) + || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0); +} + +SWIGRUNTIME PyObject * +PySwigObject_New(void *ptr, swig_type_info *ty, int own); + +SWIGRUNTIME void +PySwigObject_dealloc(PyObject *v) +{ + PySwigObject *sobj = (PySwigObject *) v; + PyObject *next = sobj->next; + if (sobj->own == SWIG_POINTER_OWN) { + swig_type_info *ty = sobj->ty; + PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; + PyObject *destroy = data ? data->destroy : 0; + if (destroy) { + /* destroy is always a VARARGS method */ + PyObject *res; + if (data->delargs) { + /* we need to create a temporal object to carry the destroy operation */ + PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0); + res = SWIG_Python_CallFunctor(destroy, tmp); + Py_DECREF(tmp); + } else { + PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); + PyObject *mself = PyCFunction_GET_SELF(destroy); + res = ((*meth)(mself, v)); + } + Py_XDECREF(res); + } +#if !defined(SWIG_PYTHON_SILENT_MEMLEAK) + else { + const char *name = SWIG_TypePrettyName(ty); + printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); + } +#endif + } + Py_XDECREF(next); + PyObject_DEL(v); +} + +SWIGRUNTIME PyObject* +PySwigObject_append(PyObject* v, PyObject* next) +{ + PySwigObject *sobj = (PySwigObject *) v; +#ifndef METH_O + PyObject *tmp = 0; + if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; + next = tmp; +#endif + if (!PySwigObject_Check(next)) { + return NULL; + } + sobj->next = next; + Py_INCREF(next); + return SWIG_Py_Void(); +} + +SWIGRUNTIME PyObject* +#ifdef METH_NOARGS +PySwigObject_next(PyObject* v) +#else +PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif +{ + PySwigObject *sobj = (PySwigObject *) v; + if (sobj->next) { + Py_INCREF(sobj->next); + return sobj->next; + } else { + return SWIG_Py_Void(); + } +} + +SWIGINTERN PyObject* +#ifdef METH_NOARGS +PySwigObject_disown(PyObject *v) +#else +PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif +{ + PySwigObject *sobj = (PySwigObject *)v; + sobj->own = 0; + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject* +#ifdef METH_NOARGS +PySwigObject_acquire(PyObject *v) +#else +PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif +{ + PySwigObject *sobj = (PySwigObject *)v; + sobj->own = SWIG_POINTER_OWN; + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject* +PySwigObject_own(PyObject *v, PyObject *args) +{ + PyObject *val = 0; +#if (PY_VERSION_HEX < 0x02020000) + if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) +#else + if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) +#endif + { + return NULL; + } + else + { + PySwigObject *sobj = (PySwigObject *)v; + PyObject *obj = PyBool_FromLong(sobj->own); + if (val) { +#ifdef METH_NOARGS + if (PyObject_IsTrue(val)) { + PySwigObject_acquire(v); + } else { + PySwigObject_disown(v); + } +#else + if (PyObject_IsTrue(val)) { + PySwigObject_acquire(v,args); + } else { + PySwigObject_disown(v,args); + } +#endif + } + return obj; + } +} + +#ifdef METH_O +static PyMethodDef +swigobject_methods[] = { + {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"}, + {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, + {(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"}, + {(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_NOARGS, (char *)"returns object representation"}, + {0, 0, 0, 0} +}; +#else +static PyMethodDef +swigobject_methods[] = { + {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, + {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, + {(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, + {(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_VARARGS, (char *)"returns object representation"}, + {0, 0, 0, 0} +}; +#endif + +#if PY_VERSION_HEX < 0x02020000 +SWIGINTERN PyObject * +PySwigObject_getattr(PySwigObject *sobj,char *name) +{ + return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); +} +#endif + +SWIGRUNTIME PyTypeObject* +_PySwigObject_type(void) { + static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; + + static PyNumberMethods PySwigObject_as_number = { + (binaryfunc)0, /*nb_add*/ + (binaryfunc)0, /*nb_subtract*/ + (binaryfunc)0, /*nb_multiply*/ + (binaryfunc)0, /*nb_divide*/ + (binaryfunc)0, /*nb_remainder*/ + (binaryfunc)0, /*nb_divmod*/ + (ternaryfunc)0,/*nb_power*/ + (unaryfunc)0, /*nb_negative*/ + (unaryfunc)0, /*nb_positive*/ + (unaryfunc)0, /*nb_absolute*/ + (inquiry)0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + (coercion)0, /*nb_coerce*/ + (unaryfunc)PySwigObject_long, /*nb_int*/ + (unaryfunc)PySwigObject_long, /*nb_long*/ + (unaryfunc)0, /*nb_float*/ + (unaryfunc)PySwigObject_oct, /*nb_oct*/ + (unaryfunc)PySwigObject_hex, /*nb_hex*/ +#if PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ +#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ +#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ + 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ +#endif + }; + + static PyTypeObject pyswigobject_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp + = { + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ + (char *)"PySwigObject", /* tp_name */ + sizeof(PySwigObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)PySwigObject_dealloc, /* tp_dealloc */ + (printfunc)PySwigObject_print, /* tp_print */ +#if PY_VERSION_HEX < 0x02020000 + (getattrfunc)PySwigObject_getattr, /* tp_getattr */ +#else + (getattrfunc)0, /* tp_getattr */ +#endif + (setattrfunc)0, /* tp_setattr */ + (cmpfunc)PySwigObject_compare, /* tp_compare */ + (reprfunc)PySwigObject_repr, /* tp_repr */ + &PySwigObject_as_number, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + (reprfunc)PySwigObject_str, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + swigobject_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#if PY_VERSION_HEX >= 0x02020000 + 0, /* tp_iter */ + 0, /* tp_iternext */ + swigobject_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; + pyswigobject_type = tmp; + pyswigobject_type.ob_type = &PyType_Type; + type_init = 1; + } + return &pyswigobject_type; +} + +SWIGRUNTIME PyObject * +PySwigObject_New(void *ptr, swig_type_info *ty, int own) +{ + PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type()); + if (sobj) { + sobj->ptr = ptr; + sobj->ty = ty; + sobj->own = own; + sobj->next = 0; + } + return (PyObject *)sobj; +} + +/* ----------------------------------------------------------------------------- + * Implements a simple Swig Packed type, and use it instead of string + * ----------------------------------------------------------------------------- */ + +typedef struct { + PyObject_HEAD + void *pack; + swig_type_info *ty; + size_t size; +} PySwigPacked; + +SWIGRUNTIME int +PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) +{ + char result[SWIG_BUFFER_SIZE]; + fputs("<Swig Packed ", fp); + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { + fputs("at ", fp); + fputs(result, fp); + } + fputs(v->ty->name,fp); + fputs(">", fp); + return 0; +} + +SWIGRUNTIME PyObject * +PySwigPacked_repr(PySwigPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { + return PyString_FromFormat("<Swig Packed at %s%s>", result, v->ty->name); + } else { + return PyString_FromFormat("<Swig Packed %s>", v->ty->name); + } +} + +SWIGRUNTIME PyObject * +PySwigPacked_str(PySwigPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ + return PyString_FromFormat("%s%s", result, v->ty->name); + } else { + return PyString_FromString(v->ty->name); + } +} + +SWIGRUNTIME int +PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w) +{ + size_t i = v->size; + size_t j = w->size; + int s = (i < j) ? -1 : ((i > j) ? 1 : 0); + return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); +} + +SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void); + +SWIGRUNTIME PyTypeObject* +PySwigPacked_type(void) { + static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type(); + return type; +} + +SWIGRUNTIMEINLINE int +PySwigPacked_Check(PyObject *op) { + return ((op)->ob_type == _PySwigPacked_type()) + || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0); +} + +SWIGRUNTIME void +PySwigPacked_dealloc(PyObject *v) +{ + if (PySwigPacked_Check(v)) { + PySwigPacked *sobj = (PySwigPacked *) v; + free(sobj->pack); + } + PyObject_DEL(v); +} + +SWIGRUNTIME PyTypeObject* +_PySwigPacked_type(void) { + static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; + static PyTypeObject pyswigpacked_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp + = { + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ + (char *)"PySwigPacked", /* tp_name */ + sizeof(PySwigPacked), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)PySwigPacked_dealloc, /* tp_dealloc */ + (printfunc)PySwigPacked_print, /* tp_print */ + (getattrfunc)0, /* tp_getattr */ + (setattrfunc)0, /* tp_setattr */ + (cmpfunc)PySwigPacked_compare, /* tp_compare */ + (reprfunc)PySwigPacked_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + (reprfunc)PySwigPacked_str, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + swigpacked_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#if PY_VERSION_HEX >= 0x02020000 + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; + pyswigpacked_type = tmp; + pyswigpacked_type.ob_type = &PyType_Type; + type_init = 1; + } + return &pyswigpacked_type; +} + +SWIGRUNTIME PyObject * +PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty) +{ + PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type()); + if (sobj) { + void *pack = malloc(size); + if (pack) { + memcpy(pack, ptr, size); + sobj->pack = pack; + sobj->ty = ty; + sobj->size = size; + } else { + PyObject_DEL((PyObject *) sobj); + sobj = 0; + } + } + return (PyObject *) sobj; +} + +SWIGRUNTIME swig_type_info * +PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size) +{ + if (PySwigPacked_Check(obj)) { + PySwigPacked *sobj = (PySwigPacked *)obj; + if (sobj->size != size) return 0; + memcpy(ptr, sobj->pack, size); + return sobj->ty; + } else { + return 0; + } +} + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +SWIGRUNTIMEINLINE PyObject * +_SWIG_This(void) +{ + return PyString_FromString("this"); +} + +SWIGRUNTIME PyObject * +SWIG_This(void) +{ + static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This(); + return swig_this; +} + +/* #define SWIG_PYTHON_SLOW_GETSET_THIS */ + +SWIGRUNTIME PySwigObject * +SWIG_Python_GetSwigThis(PyObject *pyobj) +{ + if (PySwigObject_Check(pyobj)) { + return (PySwigObject *) pyobj; + } else { + PyObject *obj = 0; +#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) + if (PyInstance_Check(pyobj)) { + obj = _PyInstance_Lookup(pyobj, SWIG_This()); + } else { + PyObject **dictptr = _PyObject_GetDictPtr(pyobj); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; + } else { +#ifdef PyWeakref_CheckProxy + if (PyWeakref_CheckProxy(pyobj)) { + PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); + return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; + } +#endif + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } + } + } +#else + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } +#endif + if (obj && !PySwigObject_Check(obj)) { + /* a PyObject is called 'this', try to get the 'real this' + PySwigObject from it */ + return SWIG_Python_GetSwigThis(obj); + } + return (PySwigObject *)obj; + } +} + +/* Acquire a pointer value */ + +SWIGRUNTIME int +SWIG_Python_AcquirePtr(PyObject *obj, int own) { + if (own == SWIG_POINTER_OWN) { + PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); + if (sobj) { + int oldown = sobj->own; + sobj->own = own; + return oldown; + } + } + return 0; +} + +/* Convert a pointer value */ + +SWIGRUNTIME int +SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { + if (!obj) return SWIG_ERROR; + if (obj == Py_None) { + if (ptr) *ptr = 0; + return SWIG_OK; + } else { + PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); + if (own) + *own = 0; + while (sobj) { + void *vptr = sobj->ptr; + if (ty) { + swig_type_info *to = sobj->ty; + if (to == ty) { + /* no type cast needed */ + if (ptr) *ptr = vptr; + break; + } else { + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) { + sobj = (PySwigObject *)sobj->next; + } else { + if (ptr) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); + if (own) + *own = *own | SWIG_CAST_NEW_MEMORY; + } + } + break; + } + } + } else { + if (ptr) *ptr = vptr; + break; + } + } + if (sobj) { + if (own) + *own = *own | sobj->own; + if (flags & SWIG_POINTER_DISOWN) { + sobj->own = 0; + } + return SWIG_OK; + } else { + int res = SWIG_ERROR; + if (flags & SWIG_POINTER_IMPLICIT_CONV) { + PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; + if (data && !data->implicitconv) { + PyObject *klass = data->klass; + if (klass) { + PyObject *impconv; + data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ + impconv = SWIG_Python_CallFunctor(klass, obj); + data->implicitconv = 0; + if (PyErr_Occurred()) { + PyErr_Clear(); + impconv = 0; + } + if (impconv) { + PySwigObject *iobj = SWIG_Python_GetSwigThis(impconv); + if (iobj) { + void *vptr; + res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); + if (SWIG_IsOK(res)) { + if (ptr) { + *ptr = vptr; + /* transfer the ownership to 'ptr' */ + iobj->own = 0; + res = SWIG_AddCast(res); + res = SWIG_AddNewMask(res); + } else { + res = SWIG_AddCast(res); + } + } + } + Py_DECREF(impconv); + } + } + } + } + return res; + } + } +} + +/* Convert a function ptr value */ + +SWIGRUNTIME int +SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { + if (!PyCFunction_Check(obj)) { + return SWIG_ConvertPtr(obj, ptr, ty, 0); + } else { + void *vptr = 0; + + /* here we get the method pointer for callbacks */ + const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); + const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; + if (desc) { + desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; + if (!desc) return SWIG_ERROR; + } + if (ty) { + swig_cast_info *tc = SWIG_TypeCheck(desc,ty); + if (tc) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + } else { + return SWIG_ERROR; + } + } else { + *ptr = vptr; + } + return SWIG_OK; + } +} + +/* Convert a packed value value */ + +SWIGRUNTIME int +SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { + swig_type_info *to = PySwigPacked_UnpackData(obj, ptr, sz); + if (!to) return SWIG_ERROR; + if (ty) { + if (to != ty) { + /* check type cast? */ + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) return SWIG_ERROR; + } + } + return SWIG_OK; +} + +/* ----------------------------------------------------------------------------- + * Create a new pointer object + * ----------------------------------------------------------------------------- */ + +/* + Create a new instance object, whitout calling __init__, and set the + 'this' attribute. +*/ + +SWIGRUNTIME PyObject* +SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this) +{ +#if (PY_VERSION_HEX >= 0x02020000) + PyObject *inst = 0; + PyObject *newraw = data->newraw; + if (newraw) { + inst = PyObject_Call(newraw, data->newargs, NULL); + if (inst) { +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + PyDict_SetItem(dict, SWIG_This(), swig_this); + } + } +#else + PyObject *key = SWIG_This(); + PyObject_SetAttr(inst, key, swig_this); +#endif + } + } else { + PyObject *dict = PyDict_New(); + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); + } + return inst; +#else +#if (PY_VERSION_HEX >= 0x02010000) + PyObject *inst; + PyObject *dict = PyDict_New(); + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); + return (PyObject *) inst; +#else + PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); + if (inst == NULL) { + return NULL; + } + inst->in_class = (PyClassObject *)data->newargs; + Py_INCREF(inst->in_class); + inst->in_dict = PyDict_New(); + if (inst->in_dict == NULL) { + Py_DECREF(inst); + return NULL; + } +#ifdef Py_TPFLAGS_HAVE_WEAKREFS + inst->in_weakreflist = NULL; +#endif +#ifdef Py_TPFLAGS_GC + PyObject_GC_Init(inst); +#endif + PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); + return (PyObject *) inst; +#endif +#endif +} + +SWIGRUNTIME void +SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) +{ + PyObject *dict; +#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + } + PyDict_SetItem(dict, SWIG_This(), swig_this); + return; + } +#endif + dict = PyObject_GetAttrString(inst, (char*)"__dict__"); + PyDict_SetItem(dict, SWIG_This(), swig_this); + Py_DECREF(dict); +} + + +SWIGINTERN PyObject * +SWIG_Python_InitShadowInstance(PyObject *args) { + PyObject *obj[2]; + if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) { + return NULL; + } else { + PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]); + if (sthis) { + PySwigObject_append((PyObject*) sthis, obj[1]); + } else { + SWIG_Python_SetSwigThis(obj[0], obj[1]); + } + return SWIG_Py_Void(); + } +} + +/* Create a new pointer object */ + +SWIGRUNTIME PyObject * +SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) { + if (!ptr) { + return SWIG_Py_Void(); + } else { + int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; + PyObject *robj = PySwigObject_New(ptr, type, own); + PySwigClientData *clientdata = type ? (PySwigClientData *)(type->clientdata) : 0; + if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { + PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); + if (inst) { + Py_DECREF(robj); + robj = inst; + } + } + return robj; + } +} + +/* Create a new packed object */ + +SWIGRUNTIMEINLINE PyObject * +SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { + return ptr ? PySwigPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); +} + +/* -----------------------------------------------------------------------------* + * Get type list + * -----------------------------------------------------------------------------*/ + +#ifdef SWIG_LINK_RUNTIME +void *SWIG_ReturnGlobalTypeList(void *); +#endif + +SWIGRUNTIME swig_module_info * +SWIG_Python_GetModule(void) { + static void *type_pointer = (void *)0; + /* first check if module already created */ + if (!type_pointer) { +#ifdef SWIG_LINK_RUNTIME + type_pointer = SWIG_ReturnGlobalTypeList((void *)0); +#else + type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, + (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); + if (PyErr_Occurred()) { + PyErr_Clear(); + type_pointer = (void *)0; + } +#endif + } + return (swig_module_info *) type_pointer; +} + +#if PY_MAJOR_VERSION < 2 +/* PyModule_AddObject function was introduced in Python 2.0. The following function + is copied out of Python/modsupport.c in python version 2.3.4 */ +SWIGINTERN int +PyModule_AddObject(PyObject *m, char *name, PyObject *o) +{ + PyObject *dict; + if (!PyModule_Check(m)) { + PyErr_SetString(PyExc_TypeError, + "PyModule_AddObject() needs module as first arg"); + return SWIG_ERROR; + } + if (!o) { + PyErr_SetString(PyExc_TypeError, + "PyModule_AddObject() needs non-NULL value"); + return SWIG_ERROR; + } + + dict = PyModule_GetDict(m); + if (dict == NULL) { + /* Internal error -- modules must have a dict! */ + PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", + PyModule_GetName(m)); + return SWIG_ERROR; + } + if (PyDict_SetItemString(dict, name, o)) + return SWIG_ERROR; + Py_DECREF(o); + return SWIG_OK; +} +#endif + +SWIGRUNTIME void +SWIG_Python_DestroyModule(void *vptr) +{ + swig_module_info *swig_module = (swig_module_info *) vptr; + swig_type_info **types = swig_module->types; + size_t i; + for (i =0; i < swig_module->size; ++i) { + swig_type_info *ty = types[i]; + if (ty->owndata) { + PySwigClientData *data = (PySwigClientData *) ty->clientdata; + if (data) PySwigClientData_Del(data); + } + } + Py_DECREF(SWIG_This()); +} + +SWIGRUNTIME void +SWIG_Python_SetModule(swig_module_info *swig_module) { + static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */ + + PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, + swig_empty_runtime_method_table); + PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); + if (pointer && module) { + PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); + } else { + Py_XDECREF(pointer); + } +} + +/* The python cached type query */ +SWIGRUNTIME PyObject * +SWIG_Python_TypeCache(void) { + static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); + return cache; +} + +SWIGRUNTIME swig_type_info * +SWIG_Python_TypeQuery(const char *type) +{ + PyObject *cache = SWIG_Python_TypeCache(); + PyObject *key = PyString_FromString(type); + PyObject *obj = PyDict_GetItem(cache, key); + swig_type_info *descriptor; + if (obj) { + descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); + } else { + swig_module_info *swig_module = SWIG_Python_GetModule(); + descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); + if (descriptor) { + obj = PyCObject_FromVoidPtr(descriptor, NULL); + PyDict_SetItem(cache, key, obj); + Py_DECREF(obj); + } + } + Py_DECREF(key); + return descriptor; +} + +/* + For backward compatibility only +*/ +#define SWIG_POINTER_EXCEPTION 0 +#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) +#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) + +SWIGRUNTIME int +SWIG_Python_AddErrMesg(const char* mesg, int infront) +{ + if (PyErr_Occurred()) { + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + PyErr_Fetch(&type, &value, &traceback); + if (value) { + PyObject *old_str = PyObject_Str(value); + Py_XINCREF(type); + PyErr_Clear(); + if (infront) { + PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str)); + } else { + PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); + } + Py_DECREF(old_str); + } + return 1; + } else { + return 0; + } +} + +SWIGRUNTIME int +SWIG_Python_ArgFail(int argnum) +{ + if (PyErr_Occurred()) { + /* add information about failing argument */ + char mesg[256]; + PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); + return SWIG_Python_AddErrMesg(mesg, 1); + } else { + return 0; + } +} + +SWIGRUNTIMEINLINE const char * +PySwigObject_GetDesc(PyObject *self) +{ + PySwigObject *v = (PySwigObject *)self; + swig_type_info *ty = v ? v->ty : 0; + return ty ? ty->str : (char*)""; +} + +SWIGRUNTIME void +SWIG_Python_TypeError(const char *type, PyObject *obj) +{ + if (type) { +#if defined(SWIG_COBJECT_TYPES) + if (obj && PySwigObject_Check(obj)) { + const char *otype = (const char *) PySwigObject_GetDesc(obj); + if (otype) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received", + type, otype); + return; + } + } else +#endif + { + const char *otype = (obj ? obj->ob_type->tp_name : 0); + if (otype) { + PyObject *str = PyObject_Str(obj); + const char *cstr = str ? PyString_AsString(str) : 0; + if (cstr) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", + type, otype, cstr); + } else { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", + type, otype); + } + Py_XDECREF(str); + return; + } + } + PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); + } else { + PyErr_Format(PyExc_TypeError, "unexpected type is received"); + } +} + + +/* Convert a pointer value, signal an exception on a type mismatch */ +SWIGRUNTIME void * +SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) { + void *result; + if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { + PyErr_Clear(); + if (flags & SWIG_POINTER_EXCEPTION) { + SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); + SWIG_Python_ArgFail(argnum); + } + } + return result; +} + + +#ifdef __cplusplus +#if 0 +{ /* cc-mode */ +#endif +} +#endif diff --git a/devtools/swigwin-1.3.34/Lib/python/pyruntime.swg b/devtools/swigwin-1.3.34/Lib/python/pyruntime.swg new file mode 100644 index 0000000..4294747 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pyruntime.swg @@ -0,0 +1,13 @@ +%insert(runtime) %{ +/* Python.h has to appear first */ +#include <Python.h> +%} + +%insert(runtime) "swigrun.swg"; /* SWIG API */ +%insert(runtime) "swigerrors.swg"; /* SWIG errors */ +%insert(runtime) "pyhead.swg"; /* Python includes and fixes */ +%insert(runtime) "pyerrors.swg"; /* Python errors */ +%insert(runtime) "pythreads.swg"; /* Python thread code */ +%insert(runtime) "pyapi.swg"; /* Pyton API */ +%insert(runtime) "pyrun.swg"; /* Python run-time code */ + diff --git a/devtools/swigwin-1.3.34/Lib/python/pystdcommon.swg b/devtools/swigwin-1.3.34/Lib/python/pystdcommon.swg new file mode 100644 index 0000000..c9e869f --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pystdcommon.swg @@ -0,0 +1,259 @@ +%fragment("StdTraits","header",fragment="StdTraitsCommon") +{ +namespace swig { + /* + Traits that provides the from method + */ + template <class Type> struct traits_from_ptr { + static PyObject *from(Type *val, int owner = 0) { + return SWIG_NewPointerObj(val, type_info<Type>(), owner); + } + }; + + template <class Type> struct traits_from { + static PyObject *from(const Type& val) { + return traits_from_ptr<Type>::from(new Type(val), 1); + } + }; + + template <class Type> struct traits_from<Type *> { + static PyObject *from(Type* val) { + return traits_from_ptr<Type>::from(val, 0); + } + }; + + template <class Type> struct traits_from<const Type *> { + static PyObject *from(const Type* val) { + return traits_from_ptr<Type>::from(const_cast<Type*>(val), 0); + } + }; + + + template <class Type> + inline PyObject *from(const Type& val) { + return traits_from<Type>::from(val); + } + + template <class Type> + inline PyObject *from_ptr(Type* val, int owner) { + return traits_from_ptr<Type>::from(val, owner); + } + + /* + Traits that provides the asval/as/check method + */ + template <class Type> + struct traits_asptr { + static int asptr(PyObject *obj, Type **val) { + Type *p; + int res = (SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0) == SWIG_OK) ? SWIG_OLDOBJ : 0; + if (SWIG_IsOK(res)) { + if (val) *val = p; + } + return res; + } + }; + + template <class Type> + inline int asptr(PyObject *obj, Type **vptr) { + return traits_asptr<Type>::asptr(obj, vptr); + } + + template <class Type> + struct traits_asval { + static int asval(PyObject *obj, Type *val) { + if (val) { + Type *p = 0; + int res = traits_asptr<Type>::asptr(obj, &p); + if (!SWIG_IsOK(res)) return res; + if (p) { + typedef typename noconst_traits<Type>::noconst_type noconst_type; + *(const_cast<noconst_type*>(val)) = *p; + if (SWIG_IsNewObj(res)){ + %delete(p); + res = SWIG_DelNewMask(res); + } + return res; + } else { + return SWIG_ERROR; + } + } else { + return traits_asptr<Type>::asptr(obj, (Type **)(0)); + } + } + }; + + template <class Type> struct traits_asval<Type*> { + static int asval(PyObject *obj, Type **val) { + if (val) { + typedef typename noconst_traits<Type>::noconst_type noconst_type; + noconst_type *p = 0; + int res = traits_asptr<noconst_type>::asptr(obj, &p); + if (SWIG_IsOK(res)) { + *(const_cast<noconst_type**>(val)) = p; + } + return res; + } else { + return traits_asptr<Type>::asptr(obj, (Type **)(0)); + } + } + }; + + template <class Type> + inline int asval(PyObject *obj, Type *val) { + return traits_asval<Type>::asval(obj, val); + } + + template <class Type> + struct traits_as<Type, value_category> { + static Type as(PyObject *obj, bool throw_error) { + Type v; + int res = asval(obj, &v); + if (!obj || !SWIG_IsOK(res)) { + if (!PyErr_Occurred()) { + %type_error(swig::type_name<Type>()); + } + if (throw_error) throw std::invalid_argument("bad type"); + } + return v; + } + }; + + template <class Type> + struct traits_as<Type, pointer_category> { + static Type as(PyObject *obj, bool throw_error) { + Type *v = 0; + int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : SWIG_ERROR); + if (SWIG_IsOK(res) && v) { + if (SWIG_IsNewObj(res)) { + Type r(*v); + %delete(v); + return r; + } else { + return *v; + } + } else { + // Uninitialized return value, no Type() constructor required. + static Type *v_def = (Type*) malloc(sizeof(Type)); + if (!PyErr_Occurred()) { + %type_error(swig::type_name<Type>()); + } + if (throw_error) throw std::invalid_argument("bad type"); + memset(v_def,0,sizeof(Type)); + return *v_def; + } + } + }; + + template <class Type> + struct traits_as<Type*, pointer_category> { + static Type* as(PyObject *obj, bool throw_error) { + Type *v = 0; + int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : SWIG_ERROR); + if (SWIG_IsOK(res)) { + return v; + } else { + if (!PyErr_Occurred()) { + %type_error(swig::type_name<Type>()); + } + if (throw_error) throw std::invalid_argument("bad type"); + return 0; + } + } + }; + + template <class Type> + inline Type as(PyObject *obj, bool te = false) { + return traits_as<Type, typename traits<Type>::category>::as(obj, te); + } + + template <class Type> + struct traits_check<Type, value_category> { + static bool check(PyObject *obj) { + int res = obj ? asval(obj, (Type *)(0)) : SWIG_ERROR; + return SWIG_IsOK(res) ? true : false; + } + }; + + template <class Type> + struct traits_check<Type, pointer_category> { + static bool check(PyObject *obj) { + int res = obj ? asptr(obj, (Type **)(0)) : SWIG_ERROR; + return SWIG_IsOK(res) ? true : false; + } + }; + + template <class Type> + inline bool check(PyObject *obj) { + return traits_check<Type, typename traits<Type>::category>::check(obj); + } +} +} + +// +// Backward compatibility +// + +#ifdef SWIG_PYTHON_BACKWARD_COMP +%{ +#include <string> + +PyObject* SwigInt_FromBool(bool b) { + return PyInt_FromLong(b ? 1L : 0L); +} +double SwigNumber_Check(PyObject* o) { + return PyFloat_Check(o) || PyInt_Check(o) || PyLong_Check(o); +} +double SwigNumber_AsDouble(PyObject* o) { + return PyFloat_Check(o) ? PyFloat_AsDouble(o) + : (PyInt_Check(o) ? double(PyInt_AsLong(o)) + : double(PyLong_AsLong(o))); +} +PyObject* SwigString_FromString(const std::string& s) { + return PyString_FromStringAndSize(s.data(),s.size()); +} +std::string SwigString_AsString(PyObject* o) { + return std::string(PyString_AsString(o)); +} +%} + +#endif + + +%define %specialize_std_container(Type,Check,As,From) +%{ +namespace swig { + template <> struct traits_asval<Type > { + typedef Type value_type; + static int asval(PyObject *obj, value_type *val) { + if (Check(obj)) { + if (val) *val = As(obj); + return SWIG_OK; + } + return SWIG_ERROR; + } + }; + template <> struct traits_from<Type > { + typedef Type value_type; + static PyObject *from(const value_type& val) { + return From(val); + } + }; + + template <> + struct traits_check<Type, value_category> { + static int check(PyObject *obj) { + int res = Check(obj); + return obj && res ? res : 0; + } + }; +} +%} +%enddef + + +#define specialize_std_vector(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) +#define specialize_std_list(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) +#define specialize_std_deque(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) +#define specialize_std_set(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) +#define specialize_std_multiset(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) diff --git a/devtools/swigwin-1.3.34/Lib/python/pystrings.swg b/devtools/swigwin-1.3.34/Lib/python/pystrings.swg new file mode 100644 index 0000000..a6d4193 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pystrings.swg @@ -0,0 +1,75 @@ +/* ------------------------------------------------------------ + * utility methods for char strings + * ------------------------------------------------------------ */ +%fragment("SWIG_AsCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { +SWIGINTERN int +SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) +{ + if (PyString_Check(obj) || PyUnicode_Check(obj) ) { + char *cstr; Py_ssize_t len; + PyString_AsStringAndSize(obj, &cstr, &len); + if (cptr) { + if (alloc) { + /* + In python the user should not be able to modify the inner + string representation. To warranty that, if you define + SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string + buffer is always returned. + + The default behavior is just to return the pointer value, + so, be careful. + */ +%#if defined(SWIG_PYTHON_SAFE_CSTRINGS) + if (*alloc != SWIG_OLDOBJ) +%#else + if (*alloc == SWIG_NEWOBJ) +%#endif + { + *cptr = %new_copy_array(cstr, len + 1, char); + *alloc = SWIG_NEWOBJ; + } + else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } + } else { + *cptr = PyString_AsString(obj); + } + } + if (psize) *psize = len + 1; + return SWIG_OK; + } else { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + void* vptr = 0; + if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = (char *) vptr; + if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} +} + +%fragment("SWIG_FromCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { +SWIGINTERNINLINE PyObject * +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + if (carray) { + if (size > INT_MAX) { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + return pchar_descriptor ? + SWIG_NewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : SWIG_Py_Void(); + } else { + return PyString_FromStringAndSize(carray, %numeric_cast(size,int)); + } + } else { + return SWIG_Py_Void(); + } +} +} + + diff --git a/devtools/swigwin-1.3.34/Lib/python/python.swg b/devtools/swigwin-1.3.34/Lib/python/python.swg new file mode 100644 index 0000000..769d9e1 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/python.swg @@ -0,0 +1,59 @@ +/* ------------------------------------------------------------ + * python.swg + * + * Python configuration module. + * ------------------------------------------------------------ */ + +/* ------------------------------------------------------------ + * Inner macros + * ------------------------------------------------------------ */ +%include <pymacros.swg> + + +/* ------------------------------------------------------------ + * The runtime part + * ------------------------------------------------------------ */ +%include <pyruntime.swg> + +/* ------------------------------------------------------------ + * Special user directives + * ------------------------------------------------------------ */ +%include <pyuserdir.swg> + +/* ------------------------------------------------------------ + * Typemap specializations + * ------------------------------------------------------------ */ +%include <pytypemaps.swg> + +/* ------------------------------------------------------------ + * Overloaded operator support + * ------------------------------------------------------------ */ +%include <pyopers.swg> + +/* ------------------------------------------------------------ + * Warnings for Python keywords + * ------------------------------------------------------------ */ +%include <pythonkw.swg> + +/* ------------------------------------------------------------ + * The Python autodoc support + * ------------------------------------------------------------ */ +%include <pydocs.swg> + +/* ------------------------------------------------------------ + * The Python classes, for C++ + * ------------------------------------------------------------ */ +%include <pyclasses.swg> + +/* ------------------------------------------------------------ + * The Python initialization function + * ------------------------------------------------------------ */ +%include <pyinit.swg> + + +/* ------------------------------------------------------------ + * For backward compatibility + * ------------------------------------------------------------ */ +%include <pybackward.swg> + + diff --git a/devtools/swigwin-1.3.34/Lib/python/pythonkw.swg b/devtools/swigwin-1.3.34/Lib/python/pythonkw.swg new file mode 100644 index 0000000..f57d34c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pythonkw.swg @@ -0,0 +1,136 @@ +/* + Warnings for Python keywords, built-in names and bad names. +*/ + +#define PYTHONKW(x) %keywordwarn(`x` " is a python keyword, symbol will be renamed as '_" `x`"'", rename="_%s") `x` +#define PYTHONBN(x) %builtinwarn(`x` " conflicts with a built-in name in python") "::"`x` + + +/* + Warnings for Python keywords + http://www.fnorb.org/docs/1.2/Fnorb-Guide/node62.html +*/ + +PYTHONKW(and); +PYTHONKW(assert); +PYTHONKW(break); +PYTHONKW(class); +PYTHONKW(continue); +PYTHONKW(def); +PYTHONKW(del); +PYTHONKW(elif); +PYTHONKW(else); +PYTHONKW(except); +PYTHONKW(exec); +PYTHONKW(finally); +PYTHONKW(for); +PYTHONKW(from); +PYTHONKW(global); +PYTHONKW(if); +PYTHONKW(import); +PYTHONKW(in); +PYTHONKW(is); +PYTHONKW(lambda); +PYTHONKW(not); +PYTHONKW(or); +PYTHONKW(pass); +PYTHONKW(print); +PYTHONKW(raise); +PYTHONKW(return); +PYTHONKW(try); +PYTHONKW(while); +PYTHONKW(yield); + +/* + built-in functions + http://www.zvon.org/other/python/doc21/lib/built-in-funcs.html + */ + +PYTHONBN(abs); +PYTHONBN(apply); +PYTHONBN(bool); +PYTHONBN(buffer); +PYTHONBN(callable); +PYTHONBN(chr); +PYTHONBN(classmethod); +PYTHONBN(cmp); +PYTHONBN(coerce); +PYTHONBN(compile); +PYTHONBN(complex); +PYTHONBN(delattr); +PYTHONBN(dict); +PYTHONBN(dir); +PYTHONBN(divmod); +PYTHONBN(enumerate); +PYTHONBN(eval); +PYTHONBN(execfile); +PYTHONBN(file); +PYTHONBN(filter); +PYTHONBN(float); +PYTHONBN(frozenset); +PYTHONBN(getattr); +PYTHONBN(globals); +PYTHONBN(hasattr); +PYTHONBN(hash); +PYTHONBN(hex); +PYTHONBN(id); +PYTHONBN(input); +PYTHONBN(int); +PYTHONBN(intern); +PYTHONBN(isinstance); +PYTHONBN(issubclass); +PYTHONBN(iter); +PYTHONBN(len); +PYTHONBN(list); +PYTHONBN(locals); +PYTHONBN(long); +PYTHONBN(map); +PYTHONBN(max); +PYTHONBN(min); +PYTHONBN(object); +PYTHONBN(oct); +PYTHONBN(open); +PYTHONBN(ord); +PYTHONBN(pow); +PYTHONBN(property); +PYTHONBN(range); +PYTHONBN(raw_input); +PYTHONBN(reduce); +PYTHONBN(reload); +PYTHONBN(repr); +PYTHONBN(reversed); +PYTHONBN(round); +PYTHONBN(set); +PYTHONBN(setattr); +PYTHONBN(slice); +PYTHONBN(sorted); +PYTHONBN(staticmethod); +PYTHONBN(staticmethod); +PYTHONBN(str); +PYTHONBN(sum); +PYTHONBN(super); +PYTHONBN(tuple); +PYTHONBN(type); +PYTHONBN(unichr); +PYTHONBN(unicode); +PYTHONBN(vars); +PYTHONBN(xrange); +PYTHONBN(zip); + + +/* + built-in names + boolean type and None +*/ +PYTHONBN(True); +PYTHONBN(False); +PYTHONBN(None); + + +/* + 'self' is also a bad Name +*/ +PYTHONBN(self); + +#undef PYTHONBN +#undef PYTHONKW diff --git a/devtools/swigwin-1.3.34/Lib/python/pythreads.swg b/devtools/swigwin-1.3.34/Lib/python/pythreads.swg new file mode 100644 index 0000000..a7552f1 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pythreads.swg @@ -0,0 +1,66 @@ +#if defined(SWIG_PYTHON_NO_THREADS) +# if defined(SWIG_PYTHON_THREADS) +# undef SWIG_PYTHON_THREADS +# endif +#endif +#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ +# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) +# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ +# define SWIG_PYTHON_USE_GIL +# endif +# endif +# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ +# ifndef SWIG_PYTHON_INITIALIZE_THREADS +# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() +# endif +# ifdef __cplusplus /* C++ code */ + class SWIG_Python_Thread_Block { + bool status; + PyGILState_STATE state; + public: + void end() { if (status) { PyGILState_Release(state); status = false;} } + SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} + ~SWIG_Python_Thread_Block() { end(); } + }; + class SWIG_Python_Thread_Allow { + bool status; + PyThreadState *save; + public: + void end() { if (status) { PyEval_RestoreThread(save); status = false; }} + SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} + ~SWIG_Python_Thread_Allow() { end(); } + }; +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block +# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow +# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() +# else /* C code */ +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() +# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() +# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) +# endif +# else /* Old thread way, not implemented, user must provide it */ +# if !defined(SWIG_PYTHON_INITIALIZE_THREADS) +# define SWIG_PYTHON_INITIALIZE_THREADS +# endif +# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK +# endif +# if !defined(SWIG_PYTHON_THREAD_END_BLOCK) +# define SWIG_PYTHON_THREAD_END_BLOCK +# endif +# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW +# endif +# if !defined(SWIG_PYTHON_THREAD_END_ALLOW) +# define SWIG_PYTHON_THREAD_END_ALLOW +# endif +# endif +#else /* No thread support */ +# define SWIG_PYTHON_INITIALIZE_THREADS +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK +# define SWIG_PYTHON_THREAD_END_BLOCK +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW +# define SWIG_PYTHON_THREAD_END_ALLOW +#endif diff --git a/devtools/swigwin-1.3.34/Lib/python/pytuplehlp.swg b/devtools/swigwin-1.3.34/Lib/python/pytuplehlp.swg new file mode 100644 index 0000000..32e1580 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pytuplehlp.swg @@ -0,0 +1,8 @@ +/* + Helper function to return output types, now we need to use a list + instead of a tuple since all the other types + (std::pair,std::vector,std::list,etc) return tuples. +*/ + +#warning "Deprecated file: Don't use t_output_helper anymore," +#warning "use SWIG_Python_AppendOutput or %append_output instead." diff --git a/devtools/swigwin-1.3.34/Lib/python/pytypemaps.swg b/devtools/swigwin-1.3.34/Lib/python/pytypemaps.swg new file mode 100644 index 0000000..2d0aa57 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pytypemaps.swg @@ -0,0 +1,98 @@ +/* ------------------------------------------------------------ + * Typemap specializations for Python + * ------------------------------------------------------------ */ + +/* ------------------------------------------------------------ + * Fragment section + * ------------------------------------------------------------ */ +/* bool is dangerous in Python, change precedence */ +#undef SWIG_TYPECHECK_BOOL +%define SWIG_TYPECHECK_BOOL 10000 %enddef + +/* Include fundamental fragemt definitions */ +%include <typemaps/fragments.swg> + +/* Look for user fragments file. */ +%include <pyfragments.swg> + +/* Python fragments for fundamental types */ +%include <pyprimtypes.swg> + +/* Python fragments for char* strings */ +%include <pystrings.swg> + +/* Backward compatibility output helper */ +%fragment("t_output_helper","header") %{ +#define t_output_helper SWIG_Python_AppendOutput +%} + + +/* ------------------------------------------------------------ + * Unified typemap section + * ------------------------------------------------------------ */ + +/* directors are supported in Python */ +#ifndef SWIG_DIRECTOR_TYPEMAPS +#define SWIG_DIRECTOR_TYPEMAPS +#endif + + +/* Python types */ +#define SWIG_Object PyObject * +#define VOID_Object SWIG_Py_Void() + +/* Python allows implicit conversion */ +#define %implicitconv_flag $implicitconv + + +/* Overload of the output/constant/exception/dirout handling */ + +/* append output */ +#define SWIG_AppendOutput(result, obj) SWIG_Python_AppendOutput(result, obj) + +/* set constant */ +#define SWIG_SetConstant(name, obj) SWIG_Python_SetConstant(d, name,obj) + +/* raise */ +#define SWIG_Raise(obj, type, desc) SWIG_Python_Raise(obj, type, desc) + +/* Include the unified typemap library */ +%include <typemaps/swigtypemaps.swg> + + +/* ------------------------------------------------------------ + * Python extra typemaps + * ------------------------------------------------------------ */ + +/* Get the address of the 'python self' object */ + +%typemap(in,numinputs=0,noblock=1) PyObject **PYTHON_SELF { + $1 = &$self; +} + + +/* Consttab, needed for callbacks, it should be removed later */ + +%typemap(consttab) SWIGTYPE ((*)(ANY)) +{ SWIG_PY_POINTER, (char*)"$symname", 0, 0, (void *)($value), &$descriptor } + +%typemap(constcode) SWIGTYPE ((*)(ANY)) ""; + + +/* Smart Pointers */ +%typemap(out,noblock=1) const SWIGTYPE & SMARTPOINTER { + $result = SWIG_NewPointerObj(%new_copy(*$1, $*ltype), $descriptor, SWIG_POINTER_OWN | %newpointer_flags); +} + +%typemap(ret,noblock=1) const SWIGTYPE & SMARTPOINTER, SWIGTYPE SMARTPOINTER { + if ($result) { + PyObject *robj = PyObject_CallMethod($result, (char *)"__deref__", NULL); + if (robj && !PyErr_Occurred()) { + PySwigObject_append((PyObject *) SWIG_Python_GetSwigThis($result), + (PyObject *) SWIG_Python_GetSwigThis(robj)); + Py_DECREF(robj); + } + } +} + + diff --git a/devtools/swigwin-1.3.34/Lib/python/pyuserdir.swg b/devtools/swigwin-1.3.34/Lib/python/pyuserdir.swg new file mode 100644 index 0000000..5247ee6 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pyuserdir.swg @@ -0,0 +1,245 @@ +/* ------------------------------------------------------------------------- + * Special user directives + * ------------------------------------------------------------------------- */ + +/* ------------------------------------------------------------------------- */ + +/* shadow code */ +#define %shadow %insert("shadow") +#define %pythoncode %insert("python") + + +/* ------------------------------------------------------------------------- */ +/* +Use the "nondynamic" feature to make a wrapped class behave as a "nondynamic" +one, ie, a python class that doesn't dynamically add new attributes. + +For example, for the class + +%pythonnondynamic A; +struct A +{ + int a; + int b; +}; + +you will get: + + aa = A() + aa.a = 1 # Ok + aa.b = 1 # Ok + aa.c = 3 # error + +Since nondynamic is a feature, if you use it like + + %pythonnondynamic; + +it will make all the wrapped classes nondynamic ones. + +The implementation is based on this recipe: + + http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252158 + +and works for modern (-modern) and plain python. We do not use __slots__, +so, it works with old python versions. + +*/ + +#define %pythonnondynamic %feature("python:nondynamic", "1") +#define %nopythonnondynamic %feature("python:nondynamic", "0") +#define %clearpythonnondynamic %feature("python:nondynamic", "") +#define %pythondynamic %nopythonnondynamic + + +/* ------------------------------------------------------------------------- */ +/* + +Use %pythonmaybecall to flag a method like __add__ or __radd__. These +don't produce an error when called, they just return NotImplemented. + +These methods "may be called" if needed. + +*/ + +#define %pythonmaybecall %feature("python:maybecall", "1") +#define %nopythonmaybecall %feature("python:maybecall", "0") +#define %clearpythonmaybecall %feature("python:maybecall", "") + +/* ------------------------------------------------------------------------- */ +/* + The %pythoncallback feature produce a more natural callback wrapper + than the %callback mechanism, ie, it uses the original name for + the callback and callable objects. + + Just use it as + + %pythoncallback(1) foo; + int foo(int a); + + %pythoncallback(1) A::foo; + struct A { + static int foo(int a); + }; + + int bar(int, int (*pf)(int)); + + then, you can use it as: + + a = foo(1) + b = bar(2, foo) + + c = A.foo(3) + d = bar(4, A.foo) + + + If you use it with a member method + %pythoncallback(1) A::foom; + struct A { + int foom(int a); + }; + + then you can use it as + + r = a.foom(3) # eval the method + mptr = A.foom_cb_ptr # returns the callback pointer + + where the '_cb_ptr' suffix is added for the callback pointer. + +*/ + +#define %pythoncallback %feature("python:callback") +#define %nopythoncallback %feature("python:callback","0") +#define %clearpythoncallback %feature("python:callback","") + +/* ------------------------------------------------------------------------- */ +/* + Support for the old %callback directive name +*/ +#ifdef %callback +#undef %callback +#endif + +#ifdef %nocallback +#undef %nocallback +#endif + +#ifdef %clearcallback +#undef %clearcallback +#endif + +#define %callback(x) %feature("python:callback",`x`) +#define %nocallback %nopythoncallback +#define %clearcallback %clearpythoncallback + +/* ------------------------------------------------------------------------- */ +/* + Thread support - Advance control + +*/ + +#define %nothread %feature("nothread") +#define %thread %feature("nothread","0") +#define %clearnothread %feature("nothread","") + +#define %nothreadblock %feature("nothreadblock") +#define %threadblock %feature("nothreadblock","0") +#define %clearnothreadblock %feature("nothreadblock","") + +#define %nothreadallow %feature("nothreadallow") +#define %threadallow %feature("nothreadallow","0") +#define %clearnothreadallow %feature("nothreadallow","") + + +/* ------------------------------------------------------------------------- */ +/* + Implicit Conversion using the C++ constructor mechanism +*/ + +#define %implicitconv %feature("implicitconv") +#define %noimplicitconv %feature("implicitconv", "0") +#define %clearimplicitconv %feature("implicitconv", "") + + +/* ------------------------------------------------------------------------- */ +/* + Enable keywords paramaters +*/ + +#define %kwargs %feature("kwargs") +#define %nokwargs %feature("kwargs", "0") +#define %clearkwargs %feature("kwargs", "") + +/* ------------------------------------------------------------------------- */ +/* + Add python code to the proxy/shadow code + + %pythonprepend - Add code before the C++ function is called + %pythonappend - Add code after the C++ function is called +*/ + +#define %pythonprepend %feature("pythonprepend") +#define %clearpythonprepend %feature("pythonprepend","") + +#define %pythonappend %feature("pythonappend") +#define %clearpythonappend %feature("pythonappend","") + + + +/* ------------------------------------------------------------------------- */ +/* + %extend_smart_pointer extend the smart pointer support. + + For example, if you have a smart pointer as: + + template <class Type> class RCPtr { + public: + ... + RCPtr(Type *p); + Type * operator->() const; + ... + }; + + you use the %extend_smart_pointer directive as: + + %extend_smart_pointer(RCPtr<A>); + %template(RCPtr_A) RCPtr<A>; + + then, if you have something like: + + RCPtr<A> make_ptr(); + int foo(A *); + + you can do the following: + + a = make_ptr(); + b = foo(a); + + ie, swig will accept a RCPtr<A> object where a 'A *' is + expected. + + Also, when using vectors + + %extend_smart_pointer(RCPtr<A>); + %template(RCPtr_A) RCPtr<A>; + %template(vector_A) std::vector<RCPtr<A> >; + + you can type + + a = A(); + v = vector_A(2) + v[0] = a + + ie, an 'A *' object is accepted, via implicit conversion, + where a RCPtr<A> object is expected. Additionally + + x = v[0] + + returns (and sets 'x' as) a copy of v[0], making reference + counting possible and consistent. +*/ + +%define %extend_smart_pointer(Type...) +%implicitconv Type; +%apply const SWIGTYPE& SMARTPOINTER { const Type& }; +%apply SWIGTYPE SMARTPOINTER { Type }; +%enddef diff --git a/devtools/swigwin-1.3.34/Lib/python/pywstrings.swg b/devtools/swigwin-1.3.34/Lib/python/pywstrings.swg new file mode 100644 index 0000000..8254bf8 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/pywstrings.swg @@ -0,0 +1,61 @@ +/* ------------------------------------------------------------ + * utility methods for wchar_t strings + * ------------------------------------------------------------ */ + +%fragment("SWIG_AsWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWIG_pwchar_descriptor") { +SWIGINTERN int +SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc) +{ + PyObject *tmp = 0; + int isunicode = PyUnicode_Check(obj); + if (!isunicode && PyString_Check(obj)) { + if (cptr) { + obj = tmp = PyUnicode_FromObject(obj); + } + isunicode = 1; + } + if (isunicode) { + int len = PyUnicode_GetSize(obj); + if (cptr) { + *cptr = %new_array(len + 1, wchar_t); + PyUnicode_AsWideChar((PyUnicodeObject *)obj, *cptr, len); + (*cptr)[len] = 0; + } + if (psize) *psize = (size_t) len + 1; + if (alloc) *alloc = cptr ? SWIG_NEWOBJ : 0; + Py_XDECREF(tmp); + return SWIG_OK; + } else { + swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor(); + if (pwchar_descriptor) { + void * vptr = 0; + if (SWIG_ConvertPtr(obj, &vptr, pwchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = (wchar_t *)vptr; + if (psize) *psize = vptr ? (wcslen((wchar_t *)vptr) + 1) : 0; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} +} + +%fragment("SWIG_FromWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWIG_pwchar_descriptor") { +SWIGINTERNINLINE PyObject * +SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size) +{ + if (carray) { + if (size > INT_MAX) { + swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor(); + return pwchar_descriptor ? + SWIG_NewPointerObj(%const_cast(carray,wchar_t *), pwchar_descriptor, 0) : SWIG_Py_Void(); + } else { + return PyUnicode_FromWideChar(carray, %numeric_cast(size,int)); + } + } else { + return SWIG_Py_Void(); + } +} +} + + diff --git a/devtools/swigwin-1.3.34/Lib/python/std_alloc.i b/devtools/swigwin-1.3.34/Lib/python/std_alloc.i new file mode 100644 index 0000000..35dc051 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_alloc.i @@ -0,0 +1 @@ +%include <std/std_alloc.i> diff --git a/devtools/swigwin-1.3.34/Lib/python/std_basic_string.i b/devtools/swigwin-1.3.34/Lib/python/std_basic_string.i new file mode 100644 index 0000000..7d3366d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_basic_string.i @@ -0,0 +1,103 @@ +#if !defined(SWIG_STD_STRING) +#define SWIG_STD_BASIC_STRING + +%include <pycontainer.swg> + +#define %swig_basic_string(Type...) %swig_sequence_methods_val(Type) + + +%fragment(SWIG_AsPtr_frag(std::basic_string<char>),"header", + fragment="SWIG_AsCharPtrAndSize") { +SWIGINTERN int +SWIG_AsPtr(std::basic_string<char>)(PyObject* obj, std::string **val) +{ + static swig_type_info* string_info = + SWIG_TypeQuery("std::basic_string<char> *"); + std::string *vptr; + if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) { + if (val) *val = vptr; + return SWIG_OLDOBJ; + } else { + PyErr_Clear(); + char* buf = 0 ; size_t size = 0; int alloc = 0; + if (SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) { + if (buf) { + if (val) *val = new std::string(buf, size - 1); + if (alloc == SWIG_NEWOBJ) %delete_array(buf); + return SWIG_NEWOBJ; + } + } else { + PyErr_Clear(); + } + if (val) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(PyExc_TypeError,"a string is expected"); + SWIG_PYTHON_THREAD_END_BLOCK; + } + return 0; + } +} +} + +%fragment(SWIG_From_frag(std::basic_string<char>),"header", + fragment="SWIG_FromCharPtrAndSize") { +SWIGINTERNINLINE PyObject* + SWIG_From(std::basic_string<char>)(const std::string& s) + { + return SWIG_FromCharPtrAndSize(s.data(), s.size()); + } +} + +%include <std/std_basic_string.i> +%typemaps_asptrfromn(%checkcode(STRING), std::basic_string<char>); + +#endif + + +#if !defined(SWIG_STD_WSTRING) + +%fragment(SWIG_AsPtr_frag(std::basic_string<wchar_t>),"header", + fragment="SWIG_AsWCharPtrAndSize") { +SWIGINTERN int + SWIG_AsPtr(std::basic_string<wchar_t>)(PyObject* obj, std::wstring **val) + { + static swig_type_info* string_info = + SWIG_TypeQuery("std::basic_string<wchar_t> *"); + std::wstring *vptr; + if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) { + if (val) *val = vptr; + return SWIG_OLDOBJ; + } else { + PyErr_Clear(); + wchar_t *buf = 0 ; size_t size = 0; int alloc = 0; + if (SWIG_AsWCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) { + if (buf) { + if (val) *val = new std::wstring(buf, size - 1); + if (alloc == SWIG_NEWOBJ) %delete_array(buf); + return SWIG_NEWOBJ; + } + } else { + PyErr_Clear(); + } + if (val) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(PyExc_TypeError,"a wstring is expected"); + SWIG_PYTHON_THREAD_END_BLOCK; + } + return 0; + } + } +} + +%fragment(SWIG_From_frag(std::basic_string<wchar_t>),"header", + fragment="SWIG_FromWCharPtrAndSize") { +SWIGINTERNINLINE PyObject* + SWIG_From(std::basic_string<wchar_t>)(const std::wstring& s) + { + return SWIG_FromWCharPtrAndSize(s.data(), s.size()); + } +} + +%typemaps_asptrfromn(%checkcode(UNISTRING), std::basic_string<wchar_t>); + +#endif diff --git a/devtools/swigwin-1.3.34/Lib/python/std_carray.i b/devtools/swigwin-1.3.34/Lib/python/std_carray.i new file mode 100644 index 0000000..2e40757 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_carray.i @@ -0,0 +1,54 @@ +%include <pycontainer.swg> + + +%fragment("StdCarrayTraits","header",fragment="StdSequenceTraits") +{ +namespace swig { + template <class T, size_t S> + struct traits_asptr<std::carray<T, S> > { + static int asptr(PyObject *obj, std::carray<T, S> **array) { + return traits_asptr_stdseq<std::carray<T, S> >::asptr(obj, array); + } + }; +} +} + +%warnfilter(SWIGWARN_IGNORE_OPERATOR_INDEX) std::carray::operator[]; + +%extend std::carray { + %fragment(SWIG_Traits_frag(std::carray<_Type, _Size >), "header", + fragment="PySwigIterator_T", + fragment=SWIG_Traits_frag(_Type), + fragment="StdCarrayTraits") { + namespace swig { + template <> struct traits<std::carray<_Type, _Size > > { + typedef pointer_category category; + static const char* type_name() { + return "std::carray<" #_Type "," #_Size " >"; + } + }; + } + } + + %typemaps_asptr(SWIG_TYPECHECK_VECTOR, swig::asptr, + SWIG_Traits_frag(std::carray<_Type, _Size >), + std::carray<_Type, _Size >); + + %typemap(out,noblock=1) iterator, const_iterator { + $result = SWIG_NewPointerObj(swig::make_output_iterator((const $type &)$1), + swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN); + } + + inline size_t __len__() const { return self->size(); } + + inline const _Type& __getitem__(size_t i) const { return (*self)[i]; } + + inline void __setitem__(size_t i, const _Type& v) { (*self)[i] = v; } + + + swig::PySwigIterator* __iter__(PyObject **PYTHON_SELF) { + return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); + } +} + +%include <std/std_carray.swg> diff --git a/devtools/swigwin-1.3.34/Lib/python/std_char_traits.i b/devtools/swigwin-1.3.34/Lib/python/std_char_traits.i new file mode 100644 index 0000000..bf4e6c4 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_char_traits.i @@ -0,0 +1 @@ +%include <std/std_char_traits.i> diff --git a/devtools/swigwin-1.3.34/Lib/python/std_common.i b/devtools/swigwin-1.3.34/Lib/python/std_common.i new file mode 100644 index 0000000..3290e21 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_common.i @@ -0,0 +1,44 @@ +%include <std/std_except.i> +%include <pystdcommon.swg> + + +/* + Generate the traits for a 'primitive' type, such as 'double', + for which the SWIG_AsVal and SWIG_From methods are already defined. +*/ + +%define %traits_ptypen(Type...) + %fragment(SWIG_Traits_frag(Type),"header", + fragment=SWIG_AsVal_frag(Type), + fragment=SWIG_From_frag(Type), + fragment="StdTraits") { +namespace swig { + template <> struct traits<Type > { + typedef value_category category; + static const char* type_name() { return #Type; } + }; + template <> struct traits_asval<Type > { + typedef Type value_type; + static int asval(PyObject *obj, value_type *val) { + return SWIG_AsVal(Type)(obj, val); + } + }; + template <> struct traits_from<Type > { + typedef Type value_type; + static PyObject *from(const value_type& val) { + return SWIG_From(Type)(val); + } + }; +} +} +%enddef + + +%include <std/std_common.i> + +// +// Generates the traits for all the known primitive +// C++ types (int, double, ...) +// +%apply_cpptypes(%traits_ptypen); + diff --git a/devtools/swigwin-1.3.34/Lib/python/std_complex.i b/devtools/swigwin-1.3.34/Lib/python/std_complex.i new file mode 100644 index 0000000..4e8fed3 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_complex.i @@ -0,0 +1,22 @@ +/* + * STD C++ complex typemaps + */ + +%include <pycomplex.swg> + +%{ +#include <complex> +%} + +/* defining the complex as/from converters */ + +%swig_cplxdbl_convn(std::complex<double>, std::complex<double>, std::real, std::imag) +%swig_cplxflt_convn(std::complex<float>, std::complex<float>, std::real, std::imag) + +/* defining the typemaps */ + +%typemaps_primitive(%checkcode(CPLXDBL), std::complex<double>); +%typemaps_primitive(%checkcode(CPLXFLT), std::complex<float>); + + + diff --git a/devtools/swigwin-1.3.34/Lib/python/std_container.i b/devtools/swigwin-1.3.34/Lib/python/std_container.i new file mode 100644 index 0000000..d24c157 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_container.i @@ -0,0 +1,2 @@ +%include <pycontainer.swg> +%include <std/std_container.i> diff --git a/devtools/swigwin-1.3.34/Lib/python/std_deque.i b/devtools/swigwin-1.3.34/Lib/python/std_deque.i new file mode 100644 index 0000000..b193756 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_deque.i @@ -0,0 +1,27 @@ +/* + Deques +*/ + +%fragment("StdDequeTraits","header",fragment="StdSequenceTraits") +%{ + namespace swig { + template <class T> + struct traits_asptr<std::deque<T> > { + static int asptr(PyObject *obj, std::deque<T> **vec) { + return traits_asptr_stdseq<std::deque<T> >::asptr(obj, vec); + } + }; + + template <class T> + struct traits_from<std::deque<T> > { + static PyObject *from(const std::deque<T> & vec) { + return traits_from_stdseq<std::deque<T> >::from(vec); + } + }; + } +%} + +#define %swig_deque_methods(Type...) %swig_sequence_methods(Type) +#define %swig_deque_methods_val(Type...) %swig_sequence_methods_val(Type); + +%include <std/std_deque.i> diff --git a/devtools/swigwin-1.3.34/Lib/python/std_except.i b/devtools/swigwin-1.3.34/Lib/python/std_except.i new file mode 100644 index 0000000..af98428 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_except.i @@ -0,0 +1 @@ +%include <typemaps/std_except.swg> diff --git a/devtools/swigwin-1.3.34/Lib/python/std_ios.i b/devtools/swigwin-1.3.34/Lib/python/std_ios.i new file mode 100644 index 0000000..aa6f099 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_ios.i @@ -0,0 +1,3 @@ +%rename(ios_base_in) std::ios_base::in; + +%include <std/std_ios.i> diff --git a/devtools/swigwin-1.3.34/Lib/python/std_iostream.i b/devtools/swigwin-1.3.34/Lib/python/std_iostream.i new file mode 100644 index 0000000..43d6b0c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_iostream.i @@ -0,0 +1,8 @@ +namespace std +{ +%callback(1) endl; +%callback(1) ends; +%callback(1) flush; +} + +%include <std/std_iostream.i> diff --git a/devtools/swigwin-1.3.34/Lib/python/std_list.i b/devtools/swigwin-1.3.34/Lib/python/std_list.i new file mode 100644 index 0000000..baf66d9 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_list.i @@ -0,0 +1,28 @@ +/* + Lists +*/ + +%fragment("StdListTraits","header",fragment="StdSequenceTraits") +%{ + namespace swig { + template <class T > + struct traits_asptr<std::list<T> > { + static int asptr(PyObject *obj, std::list<T> **lis) { + return traits_asptr_stdseq<std::list<T> >::asptr(obj, lis); + } + }; + + template <class T> + struct traits_from<std::list<T> > { + static PyObject *from(const std::list<T> & vec) { + return traits_from_stdseq<std::list<T> >::from(vec); + } + }; + } +%} + +#define %swig_list_methods(Type...) %swig_sequence_methods(Type) +#define %swig_list_methods_val(Type...) %swig_sequence_methods_val(Type); + +%include <std/std_list.i> + diff --git a/devtools/swigwin-1.3.34/Lib/python/std_map.i b/devtools/swigwin-1.3.34/Lib/python/std_map.i new file mode 100644 index 0000000..12dc23c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_map.i @@ -0,0 +1,247 @@ +/* + Maps +*/ + +%fragment("StdMapTraits","header",fragment="StdSequenceTraits") +{ + namespace swig { + template <class PySeq, class K, class T > + inline void + assign(const PySeq& pyseq, std::map<K,T > *map) { + typedef typename std::map<K,T>::value_type value_type; + typename PySeq::const_iterator it = pyseq.begin(); + for (;it != pyseq.end(); ++it) { + map->insert(value_type(it->first, it->second)); + } + } + + template <class K, class T> + struct traits_asptr<std::map<K,T> > { + typedef std::map<K,T> map_type; + static int asptr(PyObject *obj, map_type **val) { + int res = SWIG_ERROR; + if (PyDict_Check(obj)) { + PyObject_var items = PyObject_CallMethod(obj,(char *)"items",NULL); + res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val); + } else { + map_type *p; + res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0); + if (SWIG_IsOK(res) && val) *val = p; + } + return res; + } + }; + + template <class K, class T > + struct traits_from<std::map<K,T> > { + typedef std::map<K,T> map_type; + typedef typename map_type::const_iterator const_iterator; + typedef typename map_type::size_type size_type; + + static PyObject *from(const map_type& map) { + swig_type_info *desc = swig::type_info<map_type>(); + if (desc && desc->clientdata) { + return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN); + } else { + size_type size = map.size(); + int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1; + if (pysize < 0) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(PyExc_OverflowError, + "map size not valid in python"); + SWIG_PYTHON_THREAD_END_BLOCK; + return NULL; + } + PyObject *obj = PyDict_New(); + for (const_iterator i= map.begin(); i!= map.end(); ++i) { + swig::PyObject_var key = swig::from(i->first); + swig::PyObject_var val = swig::from(i->second); + PyDict_SetItem(obj, key, val); + } + return obj; + } + } + }; + + template <class ValueType> + struct from_key_oper + { + typedef const ValueType& argument_type; + typedef PyObject *result_type; + result_type operator()(argument_type v) const + { + return swig::from(v.first); + } + }; + + template <class ValueType> + struct from_value_oper + { + typedef const ValueType& argument_type; + typedef PyObject *result_type; + result_type operator()(argument_type v) const + { + return swig::from(v.second); + } + }; + + template<class OutIterator, class FromOper, class ValueType = typename OutIterator::value_type> + struct PyMapIterator_T : PySwigIteratorClosed_T<OutIterator, ValueType, FromOper> + { + PyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : PySwigIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq) + { + } + }; + + + template<class OutIterator, + class FromOper = from_key_oper<typename OutIterator::value_type> > + struct PyMapKeyIterator_T : PyMapIterator_T<OutIterator, FromOper> + { + PyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : PyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq) + { + } + }; + + template<typename OutIter> + inline PySwigIterator* + make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) + { + return new PyMapKeyIterator_T<OutIter>(current, begin, end, seq); + } + + template<class OutIterator, + class FromOper = from_value_oper<typename OutIterator::value_type> > + struct PyMapValueIterator_T : PyMapIterator_T<OutIterator, FromOper> + { + PyMapValueIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : PyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq) + { + } + }; + + + template<typename OutIter> + inline PySwigIterator* + make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) + { + return new PyMapValueIterator_T<OutIter>(current, begin, end, seq); + } + } +} + +%define %swig_map_common(Map...) + %swig_sequence_iterator(Map); + %swig_container_methods(Map) + + %extend { + mapped_type __getitem__(const key_type& key) const throw (std::out_of_range) { + Map::const_iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + + void __delitem__(const key_type& key) throw (std::out_of_range) { + Map::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + + bool has_key(const key_type& key) const { + Map::const_iterator i = self->find(key); + return i != self->end(); + } + + PyObject* keys() { + Map::size_type size = self->size(); + int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; + if (pysize < 0) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(PyExc_OverflowError, + "map size not valid in python"); + SWIG_PYTHON_THREAD_END_BLOCK; + return NULL; + } + PyObject* keyList = PyList_New(pysize); + Map::const_iterator i = self->begin(); + for (int j = 0; j < pysize; ++i, ++j) { + PyList_SET_ITEM(keyList, j, swig::from(i->first)); + } + return keyList; + } + + PyObject* values() { + Map::size_type size = self->size(); + int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; + if (pysize < 0) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(PyExc_OverflowError, + "map size not valid in python"); + SWIG_PYTHON_THREAD_END_BLOCK; + return NULL; + } + PyObject* valList = PyList_New(pysize); + Map::const_iterator i = self->begin(); + for (int j = 0; j < pysize; ++i, ++j) { + PyList_SET_ITEM(valList, j, swig::from(i->second)); + } + return valList; + } + + PyObject* items() { + Map::size_type size = self->size(); + int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; + if (pysize < 0) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(PyExc_OverflowError, + "map size not valid in python"); + SWIG_PYTHON_THREAD_END_BLOCK; + return NULL; + } + PyObject* itemList = PyList_New(pysize); + Map::const_iterator i = self->begin(); + for (int j = 0; j < pysize; ++i, ++j) { + PyList_SET_ITEM(itemList, j, swig::from(*i)); + } + return itemList; + } + + // Python 2.2 methods + bool __contains__(const key_type& key) { + return self->find(key) != self->end(); + } + + %newobject key_iterator(PyObject **PYTHON_SELF); + swig::PySwigIterator* key_iterator(PyObject **PYTHON_SELF) { + return swig::make_output_key_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); + } + + %newobject value_iterator(PyObject **PYTHON_SELF); + swig::PySwigIterator* value_iterator(PyObject **PYTHON_SELF) { + return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); + } + + %pythoncode {def __iter__(self): return self.key_iterator()} + %pythoncode {def iterkeys(self): return self.key_iterator()} + %pythoncode {def itervalues(self): return self.value_iterator()} + %pythoncode {def iteritems(self): return self.iterator()} + } +%enddef + +%define %swig_map_methods(Map...) + %swig_map_common(Map) + %extend { + void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { + (*self)[key] = x; + } + } +%enddef + + +%include <std/std_map.i> diff --git a/devtools/swigwin-1.3.34/Lib/python/std_multimap.i b/devtools/swigwin-1.3.34/Lib/python/std_multimap.i new file mode 100644 index 0000000..f923af0 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_multimap.i @@ -0,0 +1,79 @@ +/* + Multimaps +*/ +%include <std_map.i> + +%fragment("StdMultimapTraits","header",fragment="StdSequenceTraits") +{ + namespace swig { + template <class PySeq, class K, class T > + inline void + assign(const PySeq& pyseq, std::multimap<K,T > *multimap) { + typedef typename std::multimap<K,T>::value_type value_type; + typename PySeq::const_iterator it = pyseq.begin(); + for (;it != pyseq.end(); ++it) { + multimap->insert(value_type(it->first, it->second)); + } + } + + template <class K, class T> + struct traits_asptr<std::multimap<K,T> > { + typedef std::multimap<K,T> multimap_type; + static int asptr(PyObject *obj, std::multimap<K,T> **val) { + int res = SWIG_ERROR; + if (PyDict_Check(obj)) { + PyObject_var items = PyObject_CallMethod(obj,(char *)"items",NULL); + return traits_asptr_stdseq<std::multimap<K,T>, std::pair<K, T> >::asptr(items, val); + } else { + multimap_type *p; + res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<multimap_type>(),0); + if (SWIG_IsOK(res) && val) *val = p; + } + return res; + } + }; + + template <class K, class T > + struct traits_from<std::multimap<K,T> > { + typedef std::multimap<K,T> multimap_type; + typedef typename multimap_type::const_iterator const_iterator; + typedef typename multimap_type::size_type size_type; + + static PyObject *from(const multimap_type& multimap) { + swig_type_info *desc = swig::type_info<multimap_type>(); + if (desc && desc->clientdata) { + return SWIG_NewPointerObj(new multimap_type(multimap), desc, SWIG_POINTER_OWN); + } else { + size_type size = multimap.size(); + int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1; + if (pysize < 0) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(PyExc_OverflowError, + "multimap size not valid in python"); + SWIG_PYTHON_THREAD_END_BLOCK; + return NULL; + } + PyObject *obj = PyDict_New(); + for (const_iterator i= multimap.begin(); i!= multimap.end(); ++i) { + swig::PyObject_var key = swig::from(i->first); + swig::PyObject_var val = swig::from(i->second); + PyDict_SetItem(obj, key, val); + } + return obj; + } + } + }; + } +} + +%define %swig_multimap_methods(Type...) + %swig_map_common(Type); + %extend { + void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { + self->insert(Type::value_type(key,x)); + } + } +%enddef + +%include <std/std_multimap.i> + diff --git a/devtools/swigwin-1.3.34/Lib/python/std_multiset.i b/devtools/swigwin-1.3.34/Lib/python/std_multiset.i new file mode 100644 index 0000000..70f01f5 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_multiset.i @@ -0,0 +1,44 @@ +/* + Multisets +*/ + +%include <std_set.i> + +%fragment("StdMultisetTraits","header",fragment="StdSequenceTraits") +%{ + namespace swig { + template <class PySeq, class T> + inline void + assign(const PySeq& pyseq, std::multiset<T>* seq) { +#ifdef SWIG_STD_NOINSERT_TEMPLATE_STL + typedef typename PySeq::value_type value_type; + typename PySeq::const_iterator it = pyseq.begin(); + for (;it != pyseq.end(); ++it) { + seq->insert(seq->end(),(value_type)(*it)); + } +#else + seq->insert(pyseq.begin(), pyseq.end()); +#endif + } + + template <class T> + struct traits_asptr<std::multiset<T> > { + static int asptr(PyObject *obj, std::multiset<T> **m) { + return traits_asptr_stdseq<std::multiset<T> >::asptr(obj, m); + } + }; + + template <class T> + struct traits_from<std::multiset<T> > { + static PyObject *from(const std::multiset<T>& vec) { + return traits_from_stdseq<std::multiset<T> >::from(vec); + } + }; + } +%} + +#define %swig_multiset_methods(Set...) %swig_set_methods(Set) + + + +%include <std/std_multiset.i> diff --git a/devtools/swigwin-1.3.34/Lib/python/std_pair.i b/devtools/swigwin-1.3.34/Lib/python/std_pair.i new file mode 100644 index 0000000..673e85e --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_pair.i @@ -0,0 +1,139 @@ +/* + Pairs +*/ +%include <pystdcommon.swg> + +//#define SWIG_STD_PAIR_ASVAL + +%fragment("StdPairTraits","header",fragment="StdTraits") { + namespace swig { +#ifdef SWIG_STD_PAIR_ASVAL + template <class T, class U > + struct traits_asval<std::pair<T,U> > { + typedef std::pair<T,U> value_type; + + static int get_pair(PyObject* first, PyObject* second, + std::pair<T,U> *val) + { + if (val) { + T *pfirst = &(val->first); + int res1 = swig::asval((PyObject*)first, pfirst); + if (!SWIG_IsOK(res1)) return res1; + U *psecond = &(val->second); + int res2 = swig::asval((PyObject*)second, psecond); + if (!SWIG_IsOK(res2)) return res2; + return res1 > res2 ? res1 : res2; + } else { + T *pfirst = 0; + int res1 = swig::asval((PyObject*)first, 0); + if (!SWIG_IsOK(res1)) return res1; + U *psecond = 0; + int res2 = swig::asval((PyObject*)second, psecond); + if (!SWIG_IsOK(res2)) return res2; + return res1 > res2 ? res1 : res2; + } + } + + static int asval(PyObject *obj, std::pair<T,U> *val) { + int res = SWIG_ERROR; + if (PyTuple_Check(obj)) { + if (PyTuple_GET_SIZE(obj) == 2) { + res = get_pair(PyTuple_GET_ITEM(obj,0),PyTuple_GET_ITEM(obj,1), val); + } + } else if (PySequence_Check(obj)) { + if (PySequence_Size(obj) == 2) { + swig::PyObject_var first = PySequence_GetItem(obj,0); + swig::PyObject_var second = PySequence_GetItem(obj,1); + res = get_pair(first, second, val); + } + } else { + value_type *p; + res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<value_type>(),0); + if (SWIG_IsOK(res) && val) *val = *p; + } + return res; + } + }; + +#else + template <class T, class U > + struct traits_asptr<std::pair<T,U> > { + typedef std::pair<T,U> value_type; + + static int get_pair(PyObject* first, PyObject* second, + std::pair<T,U> **val) + { + if (val) { + value_type *vp = %new_instance(std::pair<T,U>); + T *pfirst = &(vp->first); + int res1 = swig::asval((PyObject*)first, pfirst); + if (!SWIG_IsOK(res1)) return res1; + U *psecond = &(vp->second); + int res2 = swig::asval((PyObject*)second, psecond); + if (!SWIG_IsOK(res2)) return res2; + *val = vp; + return SWIG_AddNewMask(res1 > res2 ? res1 : res2); + } else { + T *pfirst = 0; + int res1 = swig::asval((PyObject*)first, pfirst); + if (!SWIG_IsOK(res1)) return res1; + U *psecond = 0; + int res2 = swig::asval((PyObject*)second, psecond); + if (!SWIG_IsOK(res2)) return res2; + return res1 > res2 ? res1 : res2; + } + } + + static int asptr(PyObject *obj, std::pair<T,U> **val) { + int res = SWIG_ERROR; + if (PyTuple_Check(obj)) { + if (PyTuple_GET_SIZE(obj) == 2) { + res = get_pair(PyTuple_GET_ITEM(obj,0),PyTuple_GET_ITEM(obj,1), val); + } + } else if (PySequence_Check(obj)) { + if (PySequence_Size(obj) == 2) { + swig::PyObject_var first = PySequence_GetItem(obj,0); + swig::PyObject_var second = PySequence_GetItem(obj,1); + res = get_pair(first, second, val); + } + } else { + value_type *p; + res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<value_type>(),0); + if (SWIG_IsOK(res) && val) *val = p; + } + return res; + } + }; + +#endif + template <class T, class U > + struct traits_from<std::pair<T,U> > { + static PyObject *from(const std::pair<T,U>& val) { + PyObject* obj = PyTuple_New(2); + PyTuple_SetItem(obj,0,swig::from(val.first)); + PyTuple_SetItem(obj,1,swig::from(val.second)); + return obj; + } + }; + } +} + +%define %swig_pair_methods(pair...) +%extend { +%pythoncode {def __len__(self): return 2 +def __repr__(self): return str((self.first, self.second)) +def __getitem__(self, index): + if not (index % 2): + return self.first + else: + return self.second +def __setitem__(self, index, val): + if not (index % 2): + self.first = val + else: + self.second = val} +} +%enddef + +%include <std/std_pair.i> + diff --git a/devtools/swigwin-1.3.34/Lib/python/std_set.i b/devtools/swigwin-1.3.34/Lib/python/std_set.i new file mode 100644 index 0000000..0643b6c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_set.i @@ -0,0 +1,58 @@ +/* + Sets +*/ + +%fragment("StdSetTraits","header",fragment="StdSequenceTraits") +%{ + namespace swig { + template <class PySeq, class T> + inline void + assign(const PySeq& pyseq, std::set<T>* seq) { +#ifdef SWIG_STD_NOINSERT_TEMPLATE_STL + typedef typename PySeq::value_type value_type; + typename PySeq::const_iterator it = pyseq.begin(); + for (;it != pyseq.end(); ++it) { + seq->insert(seq->end(),(value_type)(*it)); + } +#else + seq->insert(pyseq.begin(), pyseq.end()); +#endif + } + + template <class T> + struct traits_asptr<std::set<T> > { + static int asptr(PyObject *obj, std::set<T> **s) { + return traits_asptr_stdseq<std::set<T> >::asptr(obj, s); + } + }; + + template <class T> + struct traits_from<std::set<T> > { + static PyObject *from(const std::set<T>& vec) { + return traits_from_stdseq<std::set<T> >::from(vec); + } + }; + } +%} + +%define %swig_set_methods(set...) + %swig_sequence_iterator(set); + %swig_container_methods(set); + + %extend { + void append(value_type x) { + self->insert(x); + } + + bool __contains__(value_type x) { + return self->find(x) != self->end(); + } + + value_type __getitem__(difference_type i) const throw (std::out_of_range) { + return *(swig::cgetpos(self, i)); + } + + }; +%enddef + +%include <std/std_set.i> diff --git a/devtools/swigwin-1.3.34/Lib/python/std_sstream.i b/devtools/swigwin-1.3.34/Lib/python/std_sstream.i new file mode 100644 index 0000000..6647df8 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_sstream.i @@ -0,0 +1 @@ +%include <std/std_sstream.i> diff --git a/devtools/swigwin-1.3.34/Lib/python/std_streambuf.i b/devtools/swigwin-1.3.34/Lib/python/std_streambuf.i new file mode 100644 index 0000000..44b9bb4 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_streambuf.i @@ -0,0 +1 @@ +%include <std/std_streambuf.i> diff --git a/devtools/swigwin-1.3.34/Lib/python/std_string.i b/devtools/swigwin-1.3.34/Lib/python/std_string.i new file mode 100644 index 0000000..dc1378a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_string.i @@ -0,0 +1 @@ +%include <typemaps/std_string.swg> diff --git a/devtools/swigwin-1.3.34/Lib/python/std_vector.i b/devtools/swigwin-1.3.34/Lib/python/std_vector.i new file mode 100644 index 0000000..3f04a30 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_vector.i @@ -0,0 +1,27 @@ +/* + Vectors +*/ + +%fragment("StdVectorTraits","header",fragment="StdSequenceTraits") +%{ + namespace swig { + template <class T> + struct traits_asptr<std::vector<T> > { + static int asptr(PyObject *obj, std::vector<T> **vec) { + return traits_asptr_stdseq<std::vector<T> >::asptr(obj, vec); + } + }; + + template <class T> + struct traits_from<std::vector<T> > { + static PyObject *from(const std::vector<T>& vec) { + return traits_from_stdseq<std::vector<T> >::from(vec); + } + }; + } +%} + +#define %swig_vector_methods(Type...) %swig_sequence_methods(Type) +#define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type); + +%include <std/std_vector.i> diff --git a/devtools/swigwin-1.3.34/Lib/python/std_vectora.i b/devtools/swigwin-1.3.34/Lib/python/std_vectora.i new file mode 100644 index 0000000..3f084bd --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_vectora.i @@ -0,0 +1,31 @@ +/* + Vectors + allocators +*/ + +%fragment("StdVectorATraits","header",fragment="StdSequenceTraits") +%{ + namespace swig { + template <class T, class A> + struct traits_asptr<std::vector<T,A> > { + typedef std::vector<T,A> vector_type; + typedef T value_type; + static int asptr(PyObject *obj, vector_type **vec) { + return traits_asptr_stdseq<vector_type>::asptr(obj, vec); + } + }; + + template <class T, class A> + struct traits_from<std::vector<T,A> > { + typedef std::vector<T,A> vector_type; + static PyObject *from(const vector_type& vec) { + return traits_from_stdseq<vector_type>::from(vec); + } + }; + } +%} + + +#define %swig_vector_methods(Type...) %swig_sequence_methods(Type) +#define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type); + +%include <std/std_vectora.i> diff --git a/devtools/swigwin-1.3.34/Lib/python/std_wios.i b/devtools/swigwin-1.3.34/Lib/python/std_wios.i new file mode 100644 index 0000000..930a57d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_wios.i @@ -0,0 +1 @@ +%include <std/std_wios.i> diff --git a/devtools/swigwin-1.3.34/Lib/python/std_wiostream.i b/devtools/swigwin-1.3.34/Lib/python/std_wiostream.i new file mode 100644 index 0000000..d3a5ee7 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_wiostream.i @@ -0,0 +1,10 @@ +namespace std +{ +%callback(1) wendl; +%callback(1) wends; +%callback(1) wflush; +} + +%include <std_basic_string.i> +%include <std_wstring.i> +%include <std/std_wiostream.i> diff --git a/devtools/swigwin-1.3.34/Lib/python/std_wsstream.i b/devtools/swigwin-1.3.34/Lib/python/std_wsstream.i new file mode 100644 index 0000000..8843f56 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_wsstream.i @@ -0,0 +1 @@ +%include <std/std_wsstream.i> diff --git a/devtools/swigwin-1.3.34/Lib/python/std_wstreambuf.i b/devtools/swigwin-1.3.34/Lib/python/std_wstreambuf.i new file mode 100644 index 0000000..c0f0920 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_wstreambuf.i @@ -0,0 +1 @@ +%include <std/std_wstreambuf.i> diff --git a/devtools/swigwin-1.3.34/Lib/python/std_wstring.i b/devtools/swigwin-1.3.34/Lib/python/std_wstring.i new file mode 100644 index 0000000..ef86281 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/std_wstring.i @@ -0,0 +1,3 @@ +%include <pywstrings.swg> +%include <typemaps/std_wstring.swg> + diff --git a/devtools/swigwin-1.3.34/Lib/python/stl.i b/devtools/swigwin-1.3.34/Lib/python/stl.i new file mode 100644 index 0000000..a3566db --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/stl.i @@ -0,0 +1,7 @@ +/* initial STL definition. extended as needed in each language */ +%include <std_common.i> +%include <std_string.i> +%include <std_vector.i> +%include <std_map.i> +%include <std_pair.i> + diff --git a/devtools/swigwin-1.3.34/Lib/python/typemaps.i b/devtools/swigwin-1.3.34/Lib/python/typemaps.i new file mode 100644 index 0000000..1c87de6 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/typemaps.i @@ -0,0 +1,151 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * typemaps.i + * + * Pointer handling + * These mappings provide support for input/output arguments and common + * uses for C/C++ pointers. + * ----------------------------------------------------------------------------- */ + +// INPUT typemaps. +// These remap a C pointer to be an "INPUT" value which is passed by value +// instead of reference. + +/* +The following methods can be applied to turn a pointer into a simple +"input" value. That is, instead of passing a pointer to an object, +you would use a real value instead. + + int *INPUT + short *INPUT + long *INPUT + long long *INPUT + unsigned int *INPUT + unsigned short *INPUT + unsigned long *INPUT + unsigned long long *INPUT + unsigned char *INPUT + bool *INPUT + float *INPUT + double *INPUT + +To use these, suppose you had a C function like this : + + double fadd(double *a, double *b) { + return *a+*b; + } + +You could wrap it with SWIG as follows : + + %include <typemaps.i> + double fadd(double *INPUT, double *INPUT); + +or you can use the %apply directive : + + %include <typemaps.i> + %apply double *INPUT { double *a, double *b }; + double fadd(double *a, double *b); + +*/ + +// OUTPUT typemaps. These typemaps are used for parameters that +// are output only. The output value is appended to the result as +// a list element. + +/* +The following methods can be applied to turn a pointer into an "output" +value. When calling a function, no input value would be given for +a parameter, but an output value would be returned. In the case of +multiple output values, they are returned in the form of a Python tuple. + + int *OUTPUT + short *OUTPUT + long *OUTPUT + long long *OUTPUT + unsigned int *OUTPUT + unsigned short *OUTPUT + unsigned long *OUTPUT + unsigned long long *OUTPUT + unsigned char *OUTPUT + bool *OUTPUT + float *OUTPUT + double *OUTPUT + +For example, suppose you were trying to wrap the modf() function in the +C math library which splits x into integral and fractional parts (and +returns the integer part in one of its parameters).K: + + double modf(double x, double *ip); + +You could wrap it with SWIG as follows : + + %include <typemaps.i> + double modf(double x, double *OUTPUT); + +or you can use the %apply directive : + + %include <typemaps.i> + %apply double *OUTPUT { double *ip }; + double modf(double x, double *ip); + +The Python output of the function would be a tuple containing both +output values. + +*/ + +// INOUT +// Mappings for an argument that is both an input and output +// parameter + +/* +The following methods can be applied to make a function parameter both +an input and output value. This combines the behavior of both the +"INPUT" and "OUTPUT" methods described earlier. Output values are +returned in the form of a Python tuple. + + int *INOUT + short *INOUT + long *INOUT + long long *INOUT + unsigned int *INOUT + unsigned short *INOUT + unsigned long *INOUT + unsigned long long *INOUT + unsigned char *INOUT + bool *INOUT + float *INOUT + double *INOUT + +For example, suppose you were trying to wrap the following function : + + void neg(double *x) { + *x = -(*x); + } + +You could wrap it with SWIG as follows : + + %include <typemaps.i> + void neg(double *INOUT); + +or you can use the %apply directive : + + %include <typemaps.i> + %apply double *INOUT { double *x }; + void neg(double *x); + +Unlike C, this mapping does not directly modify the input value (since +this makes no sense in Python). Rather, the modified input value shows +up as the return value of the function. Thus, to apply this function +to a Python variable you might do this : + + x = neg(x) + +Note : previous versions of SWIG used the symbol 'BOTH' to mark +input/output arguments. This is still supported, but will be slowly +phased out in future releases. + +*/ + +%include <typemaps/typemaps.swg> diff --git a/devtools/swigwin-1.3.34/Lib/python/wchar.i b/devtools/swigwin-1.3.34/Lib/python/wchar.i new file mode 100644 index 0000000..308139a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/python/wchar.i @@ -0,0 +1,21 @@ +#ifdef __cplusplus + +%{ +#include <cwchar> +%} + +#else + +%{ +#include <wchar.h> +%} + +#endif + +%types(wchar_t *); +%include <pywstrings.swg> + +/* + Enable swig wchar support. +*/ +#define SWIG_WCHAR diff --git a/devtools/swigwin-1.3.34/Lib/r/cdata.i b/devtools/swigwin-1.3.34/Lib/r/cdata.i new file mode 100644 index 0000000..3679659 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/r/cdata.i @@ -0,0 +1 @@ +%include <typemaps/cdata.swg> diff --git a/devtools/swigwin-1.3.34/Lib/r/exception.i b/devtools/swigwin-1.3.34/Lib/r/exception.i new file mode 100644 index 0000000..39cb095 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/r/exception.i @@ -0,0 +1,8 @@ +%include <typemaps/exception.swg> + + +%insert("runtime") { + %define_as(SWIG_exception(code, msg), +%block(switch (code) {case SWIG_IndexError: return Rf_ScalarLogical(NA_LOGICAL); default: %error(code, msg); SWIG_fail;} )) +} + diff --git a/devtools/swigwin-1.3.34/Lib/r/r.swg b/devtools/swigwin-1.3.34/Lib/r/r.swg new file mode 100644 index 0000000..3095529 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/r/r.swg @@ -0,0 +1,208 @@ +/* */ + + +%insert("header") "swiglabels.swg" + +%insert("header") "swigerrors.swg" +%insert("init") "swiginit.swg" +%insert("runtime") "swigrun.swg" +%insert("runtime") "rrun.swg" + +%init %{ +SWIGEXPORT void SWIG_init(void) { +%} + +#define %Rruntime %insert("s") + +#define SWIG_Object SEXP +#define VOID_Object R_NilValue + +#define %append_output(obj) SET_VECTOR_ELT($result, $n, obj) + +%define %set_constant(name, obj) %begin_block + SEXP _obj = obj; + assign(name, _obj); +%end_block %enddef + +%define %raise(obj,type,desc) +return R_NilValue; +%enddef + +%insert("sinit") "srun.swg" + +%insert("sinitroutine") %{ +SWIG_init(); +SWIG_InitializeModule(0); +%} + +%include <typemaps/swigmacros.swg> +%typemap(in) (double *x, int len) %{ + $1 = REAL(x); + $2 = Rf_length(x); +%} + +/* XXX + Need to worry about inheritance, e.g. if B extends A + and we are looking for an A[], then B elements are okay. +*/ +%typemap(scheck) SWIGTYPE[ANY] + %{ +# assert(length($input) > $1_dim0) + assert(all(sapply($input, class) == "$R_class")) + %} + +%typemap(out) void ""; + +%typemap(in) int *, int[ANY] %{ + $1 = INTEGER($input); +%} + +%typemap(in) double *, double[ANY] %{ + $1 = REAL($input); +%} + +/* Shoul dwe recycle to make the length correct. + And warn if length() > the dimension. +*/ +%typemap(scheck) SWIGTYPE [ANY] %{ +# assert(length($input) >= $1_dim0) +%} + +/* Handling vector case to avoid warnings, + although we just use the first one. */ +%typemap(scheck) unsigned int %{ + assert(length($input) == 1 && $input >= 0, "All values must be non-negative") +%} + + +%typemap(scheck) int %{ + if(length($input) > 1) { + Rf_warning("using only the first element of $input") + } +%} + + +%include <typemaps/swigmacros.swg> +%include <typemaps/fragments.swg> +%include <rfragments.swg> +%include <ropers.swg> +%include <typemaps/swigtypemaps.swg> +%include <rtype.swg> + +%apply int[ANY] { enum SWIGTYPE[ANY] }; + +%typemap(in,noblock=1) enum SWIGTYPE[ANY] { + $1 = %reinterpret_cast(INTEGER($input), $1_ltype); +} + +%typemap(in,noblock=1,fragment="SWIG_strdup") char* { + $1 = %reinterpret_cast(SWIG_strdup(CHAR(STRING_ELT($input, 0))), $1_ltype); +} + +%typemap(freearg,noblock=1) char* { + free($1); +} + +%typemap(in,noblock=1,fragment="SWIG_strdup") char *[ANY] { + $1 = %reinterpret_cast(SWIG_strdup(CHAR(STRING_ELT($input, 0))), $1_ltype); +} + +%typemap(freearg,noblock=1) char *[ANY] { + free($1); +} + +%typemap(in,noblock=1,fragment="SWIG_strdup") char[ANY] { + $1 = SWIG_strdup(CHAR(STRING_ELT($input, 0))); +} + +%typemap(freearg,noblock=1) char[ANY] { + free($1); +} + +%typemap(in,noblock=1,fragment="SWIG_strdup") char[] { + $1 = SWIG_strdup(CHAR(STRING_ELT($input, 0))); +} + +%typemap(freearg,noblock=1) char[] { + free($1); +} + + +%typemap(memberin) char[] %{ +if ($input) strcpy($1, $input); +else +strcpy($1, ""); +%} + +%typemap(globalin) char[] %{ +if ($input) strcpy($1, $input); +else +strcpy($1, ""); +%} + +%typemap(out,noblock=1) char* + { $result = $1 ? Rf_mkString(%reinterpret_cast($1,char *)) : R_NilValue; } + +%typemap(in,noblock=1) char { +$1 = %static_cast(CHAR(STRING_ELT($input, 0))[0],$1_ltype); +} + +%typemap(out) char + { + char tmp[2] = "x"; + tmp[0] = $1; + $result = Rf_mkString(tmp); + } + + +%typemap(in,noblock=1) int { + $1 = %static_cast(INTEGER($input)[0], $1_ltype); +} + +%typemap(out,noblock=1) int + "$result = Rf_ScalarInteger($1);"; + + +%typemap(in,noblock=1) bool + "$1 = LOGICAL($input)[0] ? true : false;"; + + +%typemap(out,noblock=1) bool + "$result = Rf_ScalarLogical($1);"; + +%typemap(in,noblock=1) unsigned int, + unsigned long, + float, + double, + long +{ + $1 = %static_cast(REAL($input)[0], $1_ltype); +} + + +%typemap(out,noblock=1) unsigned int * + "$result = ScalarReal(*($1));"; + +%Rruntime %{ +setMethod('[', "ExternalReference", +function(x,i,j, ..., drop=TRUE) +if (!is.null(x$"__getitem__")) +sapply(i, function(n) x$"__getitem__"(i=as.integer(n-1)))) + +setMethod('[<-' , "ExternalReference", +function(x,i,j, ..., value) +if (!is.null(x$"__setitem__")) { +sapply(1:length(i), function(n) +x$"__setitem__"(i=as.integer(i[n]-1), x=value[n])) +x +}) + +setAs('ExternalReference', 'character', +function(from) {if (!is.null(from$"__str__")) from$"__str__"()}) + +setMethod('print', 'ExternalReference', +function(x) {print(as(x, "character"))}) +%} + + + diff --git a/devtools/swigwin-1.3.34/Lib/r/rcontainer.swg b/devtools/swigwin-1.3.34/Lib/r/rcontainer.swg new file mode 100644 index 0000000..d6d54d7 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/r/rcontainer.swg @@ -0,0 +1,198 @@ + +// +// Common fragments +// + + +/**** The python container methods ****/ + + + +%fragment("RSequence_Base","header") +{ +%#include <functional> +namespace swig { + inline size_t + check_index(ptrdiff_t i, size_t size, bool insert = false) { + if ( i < 0 ) { + if ((size_t) (-i) <= size) + return (size_t) (i + size); + } else if ( (size_t) i < size ) { + return (size_t) i; + } else if (insert && ((size_t) i == size)) { + return size; + } + + throw std::out_of_range("index out of range"); + } + + inline size_t + slice_index(ptrdiff_t i, size_t size) { + if ( i < 0 ) { + if ((size_t) (-i) <= size) { + return (size_t) (i + size); + } else { + throw std::out_of_range("index out of range"); + } + } else { + return ( (size_t) i < size ) ? ((size_t) i) : size; + } + } + + template <class Sequence, class Difference> + inline typename Sequence::iterator + getpos(Sequence* self, Difference i) { + typename Sequence::iterator pos = self->begin(); + std::advance(pos, check_index(i,self->size())); + return pos; + } + + template <class Sequence, class Difference> + inline typename Sequence::const_iterator + cgetpos(const Sequence* self, Difference i) { + typename Sequence::const_iterator pos = self->begin(); + std::advance(pos, check_index(i,self->size())); + return pos; + } + + template <class Sequence, class Difference> + inline Sequence* + getslice(const Sequence* self, Difference i, Difference j) { + typename Sequence::size_type size = self->size(); + typename Sequence::size_type ii = swig::check_index(i, size); + typename Sequence::size_type jj = swig::slice_index(j, size); + + if (jj > ii) { + typename Sequence::const_iterator vb = self->begin(); + typename Sequence::const_iterator ve = self->begin(); + std::advance(vb,ii); + std::advance(ve,jj); + return new Sequence(vb, ve); + } else { + return new Sequence(); + } + } + + template <class Sequence, class Difference, class InputSeq> + inline void + setslice(Sequence* self, Difference i, Difference j, const InputSeq& v) { + typename Sequence::size_type size = self->size(); + typename Sequence::size_type ii = swig::check_index(i, size, true); + typename Sequence::size_type jj = swig::slice_index(j, size); + if (jj < ii) jj = ii; + size_t ssize = jj - ii; + if (ssize <= v.size()) { + typename Sequence::iterator sb = self->begin(); + typename InputSeq::const_iterator vmid = v.begin(); + std::advance(sb,ii); + std::advance(vmid, jj - ii); + self->insert(std::copy(v.begin(), vmid, sb), vmid, v.end()); + } else { + typename Sequence::iterator sb = self->begin(); + typename Sequence::iterator se = self->begin(); + std::advance(sb,ii); + std::advance(se,jj); + self->erase(sb,se); + self->insert(sb, v.begin(), v.end()); + } + } + + template <class Sequence, class Difference> + inline void + delslice(Sequence* self, Difference i, Difference j) { + typename Sequence::size_type size = self->size(); + typename Sequence::size_type ii = swig::check_index(i, size, true); + typename Sequence::size_type jj = swig::slice_index(j, size); + if (jj > ii) { + typename Sequence::iterator sb = self->begin(); + typename Sequence::iterator se = self->begin(); + std::advance(sb,ii); + std::advance(se,jj); + self->erase(sb,se); + } + } +} +} + +%define %swig_container_methods(Container...) + + %newobject __getslice__; + + %extend { + bool __nonzero__() const { + return !(self->empty()); + } + + size_type __len__() const { + return self->size(); + } + } +%enddef + +%define %swig_sequence_methods_common(Sequence...) +// %swig_sequence_iterator(%arg(Sequence)) + %swig_container_methods(%arg(Sequence)) + + %fragment("RSequence_Base"); + + %extend { + value_type pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty container"); + Sequence::value_type x = self->back(); + self->pop_back(); + return x; + } + + Sequence* __getslice__(difference_type i, difference_type j) throw (std::out_of_range) { + return swig::getslice(self, i, j); + } + + void __setslice__(difference_type i, difference_type j, const Sequence& v) + throw (std::out_of_range, std::invalid_argument) { + swig::setslice(self, i, j, v); + } + + void __delslice__(difference_type i, difference_type j) throw (std::out_of_range) { + swig::delslice(self, i, j); + } + + void __delitem__(difference_type i) throw (std::out_of_range) { + self->erase(swig::getpos(self,i)); + } + } +%enddef + +%define %swig_sequence_methods(Sequence...) + %swig_sequence_methods_common(%arg(Sequence)) + %extend { + const value_type& __getitem__(difference_type i) const throw (std::out_of_range) { + return *(swig::cgetpos(self, i)); + } + + void __setitem__(difference_type i, const value_type& x) throw (std::out_of_range) { + *(swig::getpos(self,i)) = x; + } + + void append(const value_type& x) { + self->push_back(x); + } + } +%enddef + +%define %swig_sequence_methods_val(Sequence...) + %swig_sequence_methods_common(%arg(Sequence)) + %extend { + value_type __getitem__(difference_type i) throw (std::out_of_range) { + return *(swig::cgetpos(self, i)); + } + + void __setitem__(difference_type i, value_type x) throw (std::out_of_range) { + *(swig::getpos(self,i)) = x; + } + + void append(value_type x) { + self->push_back(x); + } + } +%enddef diff --git a/devtools/swigwin-1.3.34/Lib/r/rfragments.swg b/devtools/swigwin-1.3.34/Lib/r/rfragments.swg new file mode 100644 index 0000000..67944b2 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/r/rfragments.swg @@ -0,0 +1,177 @@ +#define SWIG_Error(code, msg) Rf_warning(msg); return Rf_ScalarLogical(NA_LOGICAL) + +#define SWIG_fail return Rf_ScalarLogical(NA_LOGICAL) + +/* for raw pointers */ +#define SWIG_ConvertPtr(oc, ptr, ty, flags) SWIG_R_ConvertPtr(oc, ptr, ty, flags) +#define SWIG_ConvertFunctionPtr(oc, ptr, ty) SWIG_R_ConvertPtr(oc, ptr, ty, 0) +#define SWIG_NewPointerObj(ptr, ty, flags) SWIG_R_NewPointerObj(ptr, ty, flags) +#define SWIG_NewFunctionPtrObj(ptr, ty) SWIG_R_NewPointerObj(ptr, ty, 0) + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_R_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewPackedObj(ptr, sz, ty) SWIG_R_NewPackedObj(ptr, sz, ty) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, ty, flags) SWIG_ConvertPtr(obj, pptr, ty, flags) +#define SWIG_NewInstanceObj(ptr, ty, flags) SWIG_NewPointerObj(ptr, ty, flags) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_R_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, ty) SWIG_R_NewPackedObj(ptr, sz, ty) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_R_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_R_SetModule(pointer) + +%fragment(SWIG_From_frag(long),"header") { +SWIGINTERNINLINE SEXP +SWIG_From_dec(long)(long value) +{ + return Rf_ScalarInteger((int)value); +} +} + +%fragment(SWIG_AsVal_frag(long),"header") { +SWIGINTERNINLINE int +SWIG_AsVal_dec(long)(SEXP obj, long *val) +{ + if (val) *val = Rf_asInteger(obj); + return SWIG_OK; +} +} + + +%fragment(SWIG_From_frag(long long),"header") { +SWIGINTERNINLINE SEXP +SWIG_From_dec(long long)(long long value) +{ + return Rf_ScalarInteger((int)value); +} +} + +%fragment(SWIG_AsVal_frag(long long),"header") { +SWIGINTERNINLINE int +SWIG_AsVal_dec(long long)(SEXP obj, long long *val) +{ + if (val) *val = Rf_asInteger(obj); + return SWIG_OK; +} +} + +%fragment(SWIG_From_frag(unsigned long),"header") { +SWIGINTERNINLINE SEXP +SWIG_From_dec(unsigned long)(unsigned long value) +{ + return Rf_ScalarInteger((int)value); +} +} + + +%fragment(SWIG_AsVal_frag(unsigned long),"header") { +SWIGINTERNINLINE int +SWIG_AsVal_dec(unsigned long)(SEXP obj, unsigned long *val) +{ + if (val) *val = Rf_asInteger(obj); + return SWIG_OK; +} +} + + +%fragment(SWIG_From_frag(unsigned long long),"header") { +SWIGINTERNINLINE SEXP +SWIG_From_dec(unsigned long long)(unsigned long long value) +{ + return Rf_ScalarInteger((int)value); +} +} + + +%fragment(SWIG_AsVal_frag(unsigned long long),"header") { +SWIGINTERNINLINE int +SWIG_AsVal_dec(unsigned long long)(SEXP obj, unsigned long long *val) +{ + if (val) *val = Rf_asInteger(obj); + return SWIG_OK; +} +} + +%fragment(SWIG_From_frag(double),"header") { +SWIGINTERNINLINE SEXP +SWIG_From_dec(double)(double value) +{ + return Rf_ScalarReal(value); +} +} + + +%fragment(SWIG_AsVal_frag(double),"header") { +SWIGINTERNINLINE int +SWIG_AsVal_dec(double)(SEXP obj, double *val) +{ + if (val) *val = Rf_asReal(obj); + return SWIG_OK; +} +} + +%fragment("SWIG_AsCharPtrAndSize", "header") +{ +SWIGINTERN int +SWIG_AsCharPtrAndSize(SEXP obj, char** cptr, size_t* psize, int *alloc) +{ + if (cptr && Rf_isString(obj)) { + const char *cstr = CHAR(STRING_ELT(obj, 0)); + int len = strlen(cstr); + + if (alloc) { + if (*alloc == SWIG_NEWOBJ) { + *cptr = %new_copy_array(cstr, len + 1, char); + *alloc = SWIG_NEWOBJ; + } else { + *cptr = %reinterpret_cast(malloc(len + 1), char *); + *cptr = strcpy(*cptr, cstr); + *alloc = SWIG_OLDOBJ; + } + } else { + *cptr = %reinterpret_cast(malloc(len + 1), char *); + *cptr = strcpy(*cptr, cstr); + } + if (psize) *psize = len + 1; + return SWIG_OK; + } + return SWIG_TypeError; +} +} + +%fragment("SWIG_strdup","header") +{ +SWIGINTERN char * +SWIG_strdup(const char *str) +{ + char *newstr = %reinterpret_cast(malloc(strlen(str) + 1), char *); + return strcpy(newstr, str); +} +} + +# This is modified from the R header files + +%fragment("SWIG_FromCharPtrAndSize","header") +{ +SWIGINTERN SEXP +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + SEXP t, c; + if (!carray) return R_NilValue; + RVERSION26(return Rf_mkCharEnc(carray, size)); + RVERSIONPRE26( + Rf_protect(t = Rf_allocVector(STRSXP, 1)); + c = allocString(size); + strncpy(CHAR(c), carray, size); + SET_STRING_ELT(t, 0, c); + Rf_unprotect(1);) + return t; +} +} + diff --git a/devtools/swigwin-1.3.34/Lib/r/ropers.swg b/devtools/swigwin-1.3.34/Lib/r/ropers.swg new file mode 100644 index 0000000..c02f7b2 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/r/ropers.swg @@ -0,0 +1,70 @@ +#ifdef __cplusplus + +// These are auto-supported by the Perl-module +%rename(__plusplus__) *::operator++; +%rename(__minmin__) *::operator--; +%rename(__add__) *::operator+; +%rename(__sub__) *::operator-; +%rename(__neg__) *::operator-(); +%rename(__neg__) *::operator-() const; +%rename(__mul__) *::operator*; +%rename(__div__) *::operator/; +%rename(__eq__) *::operator==; +%rename(__ne__) *::operator!=; +%rename(__mod__) *::operator%; +%rename(__gt__) *::operator>; +%rename(__lt__) *::operator<; +%rename(__not__) *::operator!; + +// These are renamed, but no 'use overload...' is added +%rename(__lshift__) *::operator<<; +%rename(__rshift__) *::operator>>; +%rename(__and__) *::operator&; +%rename(__or__) *::operator|; +%rename(__xor__) *::operator^; +%rename(__invert__) *::operator~; +%rename(__le__) *::operator<=; +%rename(__ge__) *::operator>=; +%rename(__call__) *::operator(); +%rename(__getitem__) *::operator[]; + +%rename(__seteq__) *::operator=; + + +%rename(__land__) operator&&; +%rename(__lor__) operator||; +%rename(__plusplus__) *::operator++; +%rename(__minusminus__) *::operator--; +%rename(__arrowstar__) *::operator->*; +%rename(__index__) *::operator[]; + +%rename(Equal) operator =; +%rename(PlusEqual) operator +=; +%rename(MinusEqual) operator -=; +%rename(MultiplyEqual) operator *=; +%rename(DivideEqual) operator /=; +%rename(PercentEqual) operator %=; +%rename(Plus) operator +; +%rename(Minus) operator -; +%rename(Multiply) operator *; +%rename(Divide) operator /; +%rename(Percent) operator %; +%rename(Not) operator !; +%rename(IndexIntoConst) operator[](unsigned idx) const; +%rename(IndexInto) operator[](unsigned idx); +%rename(Functor) operator (); +%rename(EqualEqual) operator ==; +%rename(NotEqual) operator !=; +%rename(LessThan) operator <; +%rename(LessThanEqual) operator <=; +%rename(GreaterThan) operator >; +%rename(GreaterThanEqual) operator >=; +%rename(And) operator &&; +%rename(Or) operator ||; +%rename(PlusPlusPrefix) operator++(); +%rename(PlusPlusPostfix) operator++(int); +%rename(MinusMinusPrefix) operator--(); +%rename(MinusMinusPostfix) operator--(int); + + +#endif diff --git a/devtools/swigwin-1.3.34/Lib/r/rrun.swg b/devtools/swigwin-1.3.34/Lib/r/rrun.swg new file mode 100644 index 0000000..6159ed6 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/r/rrun.swg @@ -0,0 +1,373 @@ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Remove global namespace pollution */ +#if !defined(SWIG_NO_R_NO_REMAP) +# define R_NO_REMAP +#endif +#if !defined(SWIG_NO_STRICT_R_HEADERS) +# define STRICT_R_HEADERS +#endif + +#include <Rdefines.h> +#include <Rversion.h> +#include <stdlib.h> +#include <assert.h> + +#define SWIGR 1 + +#if R_VERSION >= R_Version(2,6,0) +#define VMAXTYPE void * +#define RVERSION26(x) x +#define RVERSIONPRE26(x) +#else +#define VMAXTYPE char * +#define RVERSION26(x) +#define RVERSIONPRE26(x) x +#endif + +/* + This is mainly a way to avoid having lots of local variables that may + conflict with those in the routine. + + Change name to R_SWIG_Callb.... +*/ +typedef struct RCallbackFunctionData { + + SEXP fun; + SEXP userData; + + + SEXP expr; + SEXP retValue; + int errorOccurred; + + SEXP el; /* Temporary pointer used in the construction of the expression to call the R function. */ + + struct RCallbackFunctionData *previous; /* Stack */ + +} RCallbackFunctionData; + +static RCallbackFunctionData *callbackFunctionDataStack; + + +SWIGRUNTIME SEXP +R_SWIG_debug_getCallbackFunctionData() +{ + int n, i; + SEXP ans; + RCallbackFunctionData *p = callbackFunctionDataStack; + + n = 0; + while(p) { + n++; + p = p->previous; + } + + Rf_protect(ans = Rf_allocVector(VECSXP, n)); + for(p = callbackFunctionDataStack, i = 0; i < n; p = p->previous, i++) + SET_VECTOR_ELT(ans, i, p->fun); + + Rf_unprotect(1); + + return(ans); +} + + + +SWIGRUNTIME RCallbackFunctionData * +R_SWIG_pushCallbackFunctionData(SEXP fun, SEXP userData) +{ + RCallbackFunctionData *el; + el = (RCallbackFunctionData *) calloc(1, sizeof(RCallbackFunctionData)); + el->fun = fun; + el->userData = userData; + el->previous = callbackFunctionDataStack; + + callbackFunctionDataStack = el; + + return(el); +} + + +SWIGRUNTIME SEXP +R_SWIG_R_pushCallbackFunctionData(SEXP fun, SEXP userData) +{ + R_SWIG_pushCallbackFunctionData(fun, userData); + return R_NilValue; +} + +SWIGRUNTIME RCallbackFunctionData * +R_SWIG_getCallbackFunctionData() +{ + if(!callbackFunctionDataStack) { + Rf_error("Supposedly impossible error occurred in the SWIG callback mechanism." + " No callback function data set."); + } + + return callbackFunctionDataStack; +} + +SWIGRUNTIME void +R_SWIG_popCallbackFunctionData(int doFree) +{ + RCallbackFunctionData *el = NULL; + if(!callbackFunctionDataStack) + return ; /* Error !!! */ + + el = callbackFunctionDataStack ; + callbackFunctionDataStack = callbackFunctionDataStack->previous; + + if(doFree) + free(el); +} + + +/* + Interface to S function + is(obj, type) + which is to be used to determine if an + external pointer inherits from the right class. + + Ideally, we would like to be able to do this without an explicit call to the is() function. + When the S4 class system uses its own SEXP types, then we will hopefully be able to do this + in the C code. + + Should we make the expression static and preserve it to avoid the overhead of + allocating each time. +*/ +SWIGRUNTIME int +R_SWIG_checkInherits(SEXP obj, SEXP tag, const char *type) +{ + SEXP e, val; + int check_err = 0; + + Rf_protect(e = Rf_allocVector(LANGSXP, 3)); + SETCAR(e, Rf_install("extends")); + + SETCAR(CDR(e), Rf_mkString(CHAR(PRINTNAME(tag)))); + SETCAR(CDR(CDR(e)), Rf_mkString(type)); + + val = R_tryEval(e, R_GlobalEnv, &check_err); + Rf_unprotect(1); + if(check_err) + return(0); + + + return(LOGICAL(val)[0]); +} + + +SWIGRUNTIME void * +R_SWIG_resolveExternalRef(SEXP arg, const char * const type, const char * const argName, Rboolean nullOk) +{ + void *ptr; + SEXP orig = arg; + + if(TYPEOF(arg) != EXTPTRSXP) + arg = GET_SLOT(arg, Rf_mkString("ref")); + + + if(TYPEOF(arg) != EXTPTRSXP) { + Rf_error("argument %s must be an external pointer (from an ExternalReference)", argName); + } + + + ptr = R_ExternalPtrAddr(arg); + + if(ptr == NULL && nullOk == (Rboolean) FALSE) { + Rf_error("the external pointer (of type %s) for argument %s has value NULL", argName, type); + } + + if(type[0] && R_ExternalPtrTag(arg) != Rf_install(type) && strcmp(type, "voidRef") + && !R_SWIG_checkInherits(orig, R_ExternalPtrTag(arg), type)) { + Rf_error("the external pointer for argument %s has tag %s, not the expected value %s", + argName, CHAR(PRINTNAME(R_ExternalPtrTag(arg))), type); + } + + + return(ptr); +} + +SWIGRUNTIME void +R_SWIG_ReferenceFinalizer(SEXP el) +{ + void *ptr = R_SWIG_resolveExternalRef(el, "", "<finalizer>", (Rboolean) 1); + fprintf(stderr, "In R_SWIG_ReferenceFinalizer for %p\n", ptr); + Rf_PrintValue(el); + + if(ptr) { + if(TYPEOF(el) != EXTPTRSXP) + el = GET_SLOT(el, Rf_mkString("ref")); + + if(TYPEOF(el) == EXTPTRSXP) + R_ClearExternalPtr(el); + + free(ptr); + } + + return; +} + +typedef enum {R_SWIG_EXTERNAL, R_SWIG_OWNER } R_SWIG_Owner; + +SWIGRUNTIME SEXP +SWIG_MakePtr(void *ptr, const char *typeName, R_SWIG_Owner owner) +{ + SEXP external, r_obj; + const char *p = typeName; + + if(typeName[0] == '_') + p = typeName + 1; + + Rf_protect(external = R_MakeExternalPtr(ptr, Rf_install(typeName), R_NilValue)); + Rf_protect(r_obj = NEW_OBJECT(MAKE_CLASS((char *) typeName))); + + if(owner) + R_RegisterCFinalizer(external, R_SWIG_ReferenceFinalizer); + + r_obj = SET_SLOT(r_obj, Rf_mkString((char *) "ref"), external); + SET_S4_OBJECT(r_obj); + Rf_unprotect(2); + + return(r_obj); +} + + +SWIGRUNTIME SEXP +R_SWIG_create_SWIG_R_Array(const char *typeName, SEXP ref, int len) +{ + SEXP arr; + +/*XXX remove the char * cast when we can. MAKE_CLASS should be declared appropriately. */ + Rf_protect(arr = NEW_OBJECT(MAKE_CLASS((char *) typeName))); + Rf_protect(arr = R_do_slot_assign(arr, Rf_mkString("ref"), ref)); + Rf_protect(arr = R_do_slot_assign(arr, Rf_mkString("dims"), Rf_ScalarInteger(len))); + + Rf_unprotect(3); + SET_S4_OBJECT(arr); + return arr; +} + +#define ADD_OUTPUT_ARG(result, pos, value, name) r_ans = AddOutputArgToReturn(pos, value, name, OutputValues); + +SWIGRUNTIME SEXP +AddOutputArgToReturn(int pos, SEXP value, const char *name, SEXP output) +{ + SET_VECTOR_ELT(output, pos, value); + + return(output); +} + +/* Create a new pointer object */ +SWIGRUNTIMEINLINE SEXP +SWIG_R_NewPointerObj(void *ptr, swig_type_info *type, int flags) { + SEXP rptr = R_MakeExternalPtr(ptr, + R_MakeExternalPtr(type, R_NilValue, R_NilValue), R_NilValue); + SET_S4_OBJECT(rptr); +// rptr = Rf_setAttrib(rptr, R_ClassSymbol, mkChar(SWIG_TypeName(type))); + return rptr; +} + +/* Convert a pointer value */ +SWIGRUNTIMEINLINE int +SWIG_R_ConvertPtr(SEXP obj, void **ptr, swig_type_info *ty, int flags) { + void *vptr; + if (!obj) return SWIG_ERROR; + if (obj == R_NilValue) { + if (ptr) *ptr = NULL; + return SWIG_OK; + } + + vptr = R_ExternalPtrAddr(obj); + if (ty) { + swig_type_info *to = (swig_type_info*) + R_ExternalPtrAddr(R_ExternalPtrTag(obj)); + if (to == ty) { + if (ptr) *ptr = vptr; + } else { + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + int newmemory = 0; + if (ptr) *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + } + } else { + if (ptr) *ptr = vptr; + } + return SWIG_OK; +} + +SWIGRUNTIME swig_module_info * +SWIG_GetModule(void *v) { + static void *type_pointer = (void *)0; + return (swig_module_info *) type_pointer; +} + +SWIGRUNTIME void +SWIG_SetModule(void *v, swig_module_info *swig_module) { +} + +typedef struct { + void *pack; + swig_type_info *ty; + size_t size; +} RSwigPacked; + +/* Create a new packed object */ + +SWIGRUNTIMEINLINE SEXP RSwigPacked_New(void *ptr, size_t sz, + swig_type_info *ty) { + SEXP rptr; + RSwigPacked *sobj = + (RSwigPacked*) malloc(sizeof(RSwigPacked)); + if (sobj) { + void *pack = malloc(sz); + if (pack) { + memcpy(pack, ptr, sz); + sobj->pack = pack; + sobj->ty = ty; + sobj->size = sz; + } else { + sobj = 0; + } + } + rptr = R_MakeExternalPtr(sobj, R_NilValue, R_NilValue); + return rptr; +} + +SWIGRUNTIME swig_type_info * +RSwigPacked_UnpackData(SEXP obj, void *ptr, size_t size) +{ + RSwigPacked *sobj = + (RSwigPacked *)R_ExternalPtrAddr(obj); + if (sobj->size != size) return 0; + memcpy(ptr, sobj->pack, size); + return sobj->ty; +} + +SWIGRUNTIMEINLINE SEXP +SWIG_R_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { + return ptr ? RSwigPacked_New((void *) ptr, sz, type) : R_NilValue; +} + +/* Convert a packed value value */ + +SWIGRUNTIME int +SWIG_R_ConvertPacked(SEXP obj, void *ptr, size_t sz, swig_type_info *ty) { + swig_type_info *to = RSwigPacked_UnpackData(obj, ptr, sz); + if (!to) return SWIG_ERROR; + if (ty) { + if (to != ty) { + /* check type cast? */ + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) return SWIG_ERROR; + } + } + return SWIG_OK; +} + +#ifdef __cplusplus +} +#endif diff --git a/devtools/swigwin-1.3.34/Lib/r/rstdcommon.swg b/devtools/swigwin-1.3.34/Lib/r/rstdcommon.swg new file mode 100644 index 0000000..2232037 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/r/rstdcommon.swg @@ -0,0 +1,216 @@ +%fragment("StdTraits","header",fragment="StdTraitsCommon") +{ +namespace swig { + /* + Traits that provides the from method + */ + + template <class Type> struct traits_from_ptr { + static SWIG_Object from(Type *val, int owner = 0) { + return SWIG_NewPointerObj(val, type_info<Type>(), owner); + } + }; + + template <class Type> struct traits_from { + static SWIG_Object from(const Type& val) { + return traits_from_ptr<Type>::from(new Type(val), 1); + } + }; + + template <class Type> struct traits_from<Type *> { + static SWIG_Object from(Type* val) { + return traits_from_ptr<Type>::from(val, 0); + } + }; + + template <class Type> + inline SWIG_Object from(const Type& val) { + return traits_from<Type>::from(val); + } + + template <class Type> + inline SWIG_Object from_ptr(Type* val, int owner) { + return traits_from_ptr<Type>::from(val, owner); + } + + /* + Traits that provides the asval/as/check method + */ + template <class Type> + struct traits_asptr { + static int asptr(SWIG_Object obj, Type **val) { + Type *p; + int res = (SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0) == SWIG_OK) ? SWIG_OLDOBJ : 0; + if (SWIG_IsOK(res)) { + if (val) *val = p; + } + return res; + } + }; + + template <class Type> + inline int asptr(SWIG_Object obj, Type **vptr) { + return traits_asptr<Type>::asptr(obj, vptr); + } + + template <class Type> + struct traits_asval { + static int asval(SWIG_Object obj, Type *val) { + if (val) { + Type *p = 0; + int res = traits_asptr<Type>::asptr(obj, &p); + if (!SWIG_IsOK(res)) return res; + if (p) { + typedef typename noconst_traits<Type>::noconst_type noconst_type; + *(const_cast<noconst_type*>(val)) = *p; + if (SWIG_IsNewObj(res)){ + %delete(p); + res = SWIG_DelNewMask(res); + } + return res; + } else { + return SWIG_ERROR; + } + } else { + return traits_asptr<Type>::asptr(obj, (Type **)(0)); + } + } + }; + + template <class Type> struct traits_asval<Type*> { + static int asval(SWIG_Object obj, Type **val) { + if (val) { + typedef typename noconst_traits<Type>::noconst_type noconst_type; + noconst_type *p = 0; + int res = traits_asptr<noconst_type>::asptr(obj, &p); + if (SWIG_IsOK(res)) { + *(const_cast<noconst_type**>(val)) = p; + } + return res; + } else { + return traits_asptr<Type>::asptr(obj, (Type **)(0)); + } + } + }; + + template <class Type> + inline int asval(SWIG_Object obj, Type *val) { + return traits_asval<Type>::asval(obj, val); + } + + template <class Type> + struct traits_as<Type, value_category> { + static Type as(SWIG_Object obj, bool throw_error) { + Type v; + int res = asval(obj, &v); + if (!obj || !SWIG_IsOK(res)) { +// if (!PyErr_Occurred()) { +// %type_error(swig::type_name<Type>()); +// } + if (throw_error) throw std::invalid_argument("bad type"); + } + return v; + } + }; + + template <class Type> + struct traits_as<Type, pointer_category> { + static Type as(SWIG_Object obj, bool throw_error) { + Type *v = 0; + int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : SWIG_ERROR); + if (SWIG_IsOK(res) && v) { + if (SWIG_IsNewObj(res)) { + Type r(*v); + %delete(v); + return r; + } else { + return *v; + } + } else { + // Uninitialized return value, no Type() constructor required. + static Type *v_def = (Type*) malloc(sizeof(Type)); +// if (!PyErr_Occurred()) { +// %type_error(swig::type_name<Type>()); +// } + if (throw_error) throw std::invalid_argument("bad type"); + memset(v_def,0,sizeof(Type)); + return *v_def; + } + } + }; + + template <class Type> + struct traits_as<Type*, pointer_category> { + static Type* as(SWIG_Object obj, bool throw_error) { + Type *v = 0; + int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : SWIG_ERROR); + if (SWIG_IsOK(res)) { + return v; + } else { +// if (!PyErr_Occurred()) { +// %type_error(swig::type_name<Type>()); +// } + if (throw_error) throw std::invalid_argument("bad type"); + return 0; + } + } + }; + + template <class Type> + inline Type as(SWIG_Object obj, bool te = false) { + return traits_as<Type, typename traits<Type>::category>::as(obj, te); + } + + template <class Type> + struct traits_check<Type, value_category> { + static bool check(SWIG_Object obj) { + int res = obj ? asval(obj, (Type *)(0)) : SWIG_ERROR; + return SWIG_IsOK(res) ? true : false; + } + }; + + template <class Type> + struct traits_check<Type, pointer_category> { + static bool check(SWIG_Object obj) { + int res = obj ? asptr(obj, (Type **)(0)) : SWIG_ERROR; + return SWIG_IsOK(res) ? true : false; + } + }; + + template <class Type> + inline bool check(SWIG_Object obj) { + return traits_check<Type, typename traits<Type>::category>::check(obj); + } +} +} + +%define %specialize_std_container(Type,Check,As,From) +%{ +namespace swig { + template <> struct traits_asval<Type > { + typedef Type value_type; + static int asval(SWIG_Object obj, value_type *val) { + if (Check(obj)) { + if (val) *val = As(obj); + return SWIG_OK; + } + return SWIG_ERROR; + } + }; + template <> struct traits_from<Type > { + typedef Type value_type; + static SWIG_Object from(const value_type& val) { + return From(val); + } + }; + + template <> + struct traits_check<Type, value_category> { + static int check(SWIG_Object obj) { + int res = Check(obj); + return obj && res ? res : 0; + } + }; +} +%} +%enddef diff --git a/devtools/swigwin-1.3.34/Lib/r/rtype.swg b/devtools/swigwin-1.3.34/Lib/r/rtype.swg new file mode 100644 index 0000000..6479a0d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/r/rtype.swg @@ -0,0 +1,200 @@ + +/* These map the primitive C types to the appropriate R type + for use in class representations. + */ + +%typemap("rtype") int, int *, int & "numeric"; +%apply int {size_t} +%apply int {std::size_t} +%apply int {ptrdiff_t} +%apply int {std::ptrdiff_t} + +%typemap("rtype") long, long * "numeric"; +%typemap("rtype") unsigned long, + unsigned long * "numeric"; +%typemap("rtype") unsigned int, + unsigned int * "numeric"; +%typemap("rtype") double, double*, double & "numeric"; +%typemap("rtype") float, float *, float & "numeric"; +%typemap("rtype") char *, char ** "character"; +%typemap("rtype") char "character"; +%typemap("rtype") string, string *, string & "character"; +%typemap("rtype") std::string, std::string *, std::string & "character"; +%typemap("rtype") bool, bool * "logical"; +%typemap("rtype") enum SWIGTYPE "character"; +%typemap("rtype") enum SWIGTYPE * "character"; +%typemap("rtype") enum SWIGTYPE & "character"; +%typemap("rtype") SWIGTYPE * "$R_class"; +%typemap("rtype") SWIGTYPE & "$R_class"; +%typemap("rtype") SWIGTYPE "$&R_class"; + + + +/* Have to be careful that as(x, "numeric") is different from as.numeric(x). + The latter makes a REALSXP, whereas the former leaves an INTSXP as an + INTSXP. +*/ + + +%typemap(scoercein) int, int *, int & + %{ $input = as($input, "integer"); %} +%typemap(scoercein) ptrdiff_t, ptrdiff_t *, ptrdiff_t & + %{ $input = as($input, "integer"); %} +%typemap(scoercein) unsigned long, unsigned long *, unsigned long & + %{ $input = as($input, "integer"); %} +%typemap(scoercein) unsigned int, unsigned int *, unsigned int & + %{ $input = as($input, "integer"); %} +%typemap(scoercein) double, double *, double & + %{ $input = as($input, "numeric"); %} +%typemap(scoercein) float, float *, float & + %{ $input = as($input, "numeric"); %} +%typemap(scoercein) char, char *, char & + %{ $input = as($input, "character"); %} +%typemap(scoercein) string, string *, string & + %{ $input = as($input, "character"); %} +%typemap(scoercein) std::string, std::string *, std::string & + %{ $input = as($input, "character"); %} +%typemap(scoercein) enum SWIGTYPE + %{ $input = enumToInteger($input, "$R_class") %} +%typemap(scoercein) enum SWIGTYPE & + %{ $input = enumToInteger($input, "$R_class") %} +%typemap(scoercein) enum SWIGTYPE * + %{ $input = enumToInteger($input, "$R_class") %} + +%typemap(scoercein) SWIGTYPE * + %{ $input = coerceIfNotSubclass($input, "$R_class") %} + +%typemap(scoercein) SWIGTYPE & + %{ $input = coerceIfNotSubclass($input, "$R_class") %} + +%typemap(scoercein) SWIGTYPE + %{ $input = coerceIfNotSubclass($input, "$&R_class") %} + + +%typemap(scoercein) SWIGTYPE[ANY] + %{ + if(is.list($input)) + assert(all(sapply($input, class) == "$R_class")) + %} + + +/* **************************************************************** */ + +%typemap(scoercein) bool, bool *, bool & + "$input = as.logical($input) "; + +%typemap(scoercein) int, + int *, + int &, + int[ANY], + size_t, + std::size_t, + size_t &, + std::size_t & + "$input = as.integer($input) "; + + +%typemap(scoercein) unsigned int, + unsigned long, + double, + float, + long, + long long, + unsigned int[], + unsigned long[], + double[], + float[], + long[], + long long[], + unsigned int[ANY], + unsigned long[ANY], + double[ANY], + float[ANY], + long[ANY], + long long[ANY], + unsigned int *, + unsigned long *, + double*, + float*, + long*, + long long * +%{ $input = as.numeric($input) %} + + +%typemap(scoercein) char *, string, std::string, +string &, std::string & +%{ $input = as($input, "character") %} + +%typemap(scoerceout) enum SWIGTYPE + %{ $result = enumFromInteger($result, "$R_class") %} + +%typemap(scoerceout) enum SWIGTYPE & + %{ $result = enumFromInteger($result, "$R_class") %} + +%typemap(scoerceout) enum SWIGTYPE * + %{ $result = enumToInteger($result, "$R_class") %} + + +%typemap(scoerceout) SWIGTYPE + %{ class($result) <- "$&R_class" %} + +%typemap(scoerceout) SWIGTYPE & + %{ class($result) <- "$R_class" %} + +%typemap(scoerceout) SWIGTYPE * + %{ class($result) <- "$R_class" %} + +/* Override the SWIGTYPE * above. */ +%typemap(scoerceout) char, + char *, + char &, + unsigned int, + unsigned int &, + unsigned long, + unsigned long &, + double, + double &, + float, + float &, + long, + long &, + long long, + long long &, + int, + int &, + bool, + bool &, + string, + std::string, + string &, + std::string &, + size_t, + std::size_t, + size_t &, + std::size_t &, + void + %{ %} + + +#if 0 + Just examining the values for a SWIGTYPE. + +%typemap(scoerceout) SWIGTYPE %{ + + name = $1_name + type = $1_type + ltype = $1_ltype + + mangle = $1_mangle + descriptor = $1_descriptor + + pointer type = $*1_type + pointer ltype = $*1_ltype + + pointer descriptor = $*1_descriptor + basetype = $*_basetype + +%} +#endif + + diff --git a/devtools/swigwin-1.3.34/Lib/r/srun.swg b/devtools/swigwin-1.3.34/Lib/r/srun.swg new file mode 100644 index 0000000..71a508d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/r/srun.swg @@ -0,0 +1,150 @@ +# srun.swg # +# +# This is the basic code that is needed at run time within R to +# provide and define the relevant classes. It is included +# automatically in the generated code by copying the contents of +# srun.swg into the newly created binding code. + + +# This could be provided as a separate run-time library but this +# approach allows the code to to be included directly into the +# generated bindings and so removes the need to have and install an +# additional library. We may however end up with multiple copies of +# this and some confusion at run-time as to which class to use. This +# is an issue when we use NAMESPACES as we may need to export certain +# classes. + +###################################################################### + +if(length(getClassDef("RSWIGStruct")) == 0) + setClass("RSWIGStruct", representation("VIRTUAL")) + + + +if(length(getClassDef("ExternalReference")) == 0) +# Should be virtual but this means it loses its slots currently +#representation("VIRTUAL") + setClass("ExternalReference", representation( ref = "externalptr")) + + + +if(length(getClassDef("NativeRoutinePointer")) == 0) + setClass("NativeRoutinePointer", + representation(parameterTypes = "character", + returnType = "character", + "VIRTUAL"), + contains = "ExternalReference") + +if(length(getClassDef("CRoutinePointer")) == 0) + setClass("CRoutinePointer", contains = "NativeRoutinePointer") + + +if(length(getClassDef("EnumerationValue")) == 0) + setClass("EnumerationValue", contains = "integer") + + +if(!isGeneric("copyToR")) + setGeneric("copyToR", + function(value, obj = new(gsub("Ref$", "", class(value)))) + standardGeneric("copyToR" + )) + +setGeneric("delete", function(obj) standardGeneric("delete")) + + +SWIG_createNewRef = +function(className, ..., append = TRUE) +{ + f = get(paste("new", className, sep = "_"), mode = "function") + + f(...) +} + +if(!isGeneric("copyToC")) + setGeneric("copyToC", + function(value, obj = RSWIG_createNewRef(class(value))) + standardGeneric("copyToC" + )) + + +# +defineEnumeration = +function(name, .values, where = topenv(parent.frame()), suffix = "Value") +{ + # Mirror the class definitions via the E analogous to .__C__ + defName = paste(".__E__", name, sep = "") + assign(defName, .values, envir = where) + + if(nchar(suffix)) + name = paste(name, suffix, sep = "") + + setClass(name, contains = "EnumerationValue", where = where) +} + +enumToInteger <- function(name,type) +{ + if (is.character(name)) { + ans <- as.integer(get(paste(".__E__", type, sep = ""))[name]) + if (is.na(ans)) {warning("enum not found ", name, " ", type)} + ans + } +} + +enumFromInteger = +function(i,type) +{ + itemlist <- get(paste(".__E__", type, sep="")) + names(itemlist)[match(i, itemlist)] +} + +coerceIfNotSubclass = +function(obj, type) +{ + if(!is(obj, type)) {as(obj, type)} else obj +} + + +setClass("SWIGArray", representation(dims = "integer"), contains = "ExternalReference") + +setMethod("length", "SWIGArray", function(x) x@dims[1]) + + +defineEnumeration("SCopyReferences", + .values = c( "FALSE" = 0, "TRUE" = 1, "DEEP" = 2)) + +assert = +function(condition, message = "") +{ + if(!condition) + stop(message) + + TRUE +} + + +if(FALSE) { +print.SWIGFunction = +function(x, ...) + { + } +} + + +####################################################################### + +R_SWIG_getCallbackFunctionStack = +function() +{ + # No PACKAGE argument as we don't know what the DLL is. + .Call("R_SWIG_debug_getCallbackFunctionData") +} + +R_SWIG_addCallbackFunctionStack = +function(fun, userData = NULL) +{ + # No PACKAGE argument as we don't know what the DLL is. + .Call("R_SWIG_R_pushCallbackFunctionData", fun, userData) +} + + +#######################################################################
\ No newline at end of file diff --git a/devtools/swigwin-1.3.34/Lib/r/std_alloc.i b/devtools/swigwin-1.3.34/Lib/r/std_alloc.i new file mode 100644 index 0000000..87fa8d4 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/r/std_alloc.i @@ -0,0 +1 @@ +%include <std/std_alloc.i>
\ No newline at end of file diff --git a/devtools/swigwin-1.3.34/Lib/r/std_common.i b/devtools/swigwin-1.3.34/Lib/r/std_common.i new file mode 100644 index 0000000..fec0efe --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/r/std_common.i @@ -0,0 +1,2 @@ +%include <rstdcommon.swg> +%include <std/std_common.i> diff --git a/devtools/swigwin-1.3.34/Lib/r/std_container.i b/devtools/swigwin-1.3.34/Lib/r/std_container.i new file mode 100644 index 0000000..076c1c6 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/r/std_container.i @@ -0,0 +1,2 @@ +%include <rcontainer.swg> +%include <std/std_container.i> diff --git a/devtools/swigwin-1.3.34/Lib/r/std_deque.i b/devtools/swigwin-1.3.34/Lib/r/std_deque.i new file mode 100644 index 0000000..0c757ab --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/r/std_deque.i @@ -0,0 +1 @@ +%include<std/std_deque.i>
\ No newline at end of file diff --git a/devtools/swigwin-1.3.34/Lib/r/std_except.i b/devtools/swigwin-1.3.34/Lib/r/std_except.i new file mode 100644 index 0000000..af98428 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/r/std_except.i @@ -0,0 +1 @@ +%include <typemaps/std_except.swg> diff --git a/devtools/swigwin-1.3.34/Lib/r/std_pair.i b/devtools/swigwin-1.3.34/Lib/r/std_pair.i new file mode 100644 index 0000000..3ac7957 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/r/std_pair.i @@ -0,0 +1 @@ +%include<std/std_pair.i>
\ No newline at end of file diff --git a/devtools/swigwin-1.3.34/Lib/r/std_string.i b/devtools/swigwin-1.3.34/Lib/r/std_string.i new file mode 100644 index 0000000..dc1378a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/r/std_string.i @@ -0,0 +1 @@ +%include <typemaps/std_string.swg> diff --git a/devtools/swigwin-1.3.34/Lib/r/std_vector.i b/devtools/swigwin-1.3.34/Lib/r/std_vector.i new file mode 100644 index 0000000..0336482 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/r/std_vector.i @@ -0,0 +1,10 @@ +%fragment("StdVectorTraits","header") +%{ +%} + +#define %swig_vector_methods(Type...) %swig_sequence_methods(Type) +#define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type); + + + +%include <std/std_vector.i>
\ No newline at end of file diff --git a/devtools/swigwin-1.3.34/Lib/r/stl.i b/devtools/swigwin-1.3.34/Lib/r/stl.i new file mode 100644 index 0000000..9656ee6 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/r/stl.i @@ -0,0 +1,8 @@ +/* initial STL definition. extended as needed in each language */ +%include std_common.i +%include std_vector.i +%include std_string.i + + + + diff --git a/devtools/swigwin-1.3.34/Lib/r/typemaps.i b/devtools/swigwin-1.3.34/Lib/r/typemaps.i new file mode 100644 index 0000000..1f9b9c4 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/r/typemaps.i @@ -0,0 +1 @@ +%include <typemaps/typemaps.swg> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/Makefile.swig b/devtools/swigwin-1.3.34/Lib/ruby/Makefile.swig new file mode 100644 index 0000000..a7f3ae3 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/Makefile.swig @@ -0,0 +1,42 @@ +# File : Makefile.swig +# Makefile for a SWIG module. Use this file if you are +# producing a Ruby extension for general use or distribution. +# +# 1. Prepare extconf.rb. +# 2. Modify this file as appropriate. +# 3. Type 'make -f Makefile.swig' to generate wrapper code and Makefile. +# 4. Type 'make' to build your extension. +# 5. Type 'make install' to install your extension. +# + +MODULE = yourmodule +FEATURE = $(MODULE) +INTERFACE = $(MODULE).i +RUBY = ruby +SWIG = swig + +# for C extension +SWIGOPT = -ruby +WRAPPER = $(MODULE)_wrap.c + +## for C++ extension +#SWIGOPT = -ruby -c++ +#WRAPPER = $(MODULE)_wrap.cc + + +swigall: $(WRAPPER) Makefile + +$(WRAPPER): $(INTERFACE) + $(SWIG) $(SWIGOPT) -o $@ $(INTERFACE) + +Makefile: extconf.rb + $(RUBY) extconf.rb + @if [ -f Makefile ] ; then\ + echo "include Makefile.swig" >> Makefile;\ + fi + +swigclean: + @if [ -f Makefile ] ; then\ + make -f Makefile clean;\ + fi + rm -f Makefile $(WRAPPER) diff --git a/devtools/swigwin-1.3.34/Lib/ruby/argcargv.i b/devtools/swigwin-1.3.34/Lib/ruby/argcargv.i new file mode 100644 index 0000000..ae1f6bb --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/argcargv.i @@ -0,0 +1,48 @@ +/* ------------------------------------------------------------ + * --- Argc & Argv --- + * ------------------------------------------------------------ */ + +/* ------------------------------------------------------------ + + Use it as follow: + + %apply (int ARGC, char **ARGV) { (size_t argc, const char **argv) } + + %inline %{ + + int mainApp(size_t argc, const char **argv) + { + return argc; + } + + then in the ruby side: + + args = ["asdf", "asdf2"] + mainApp(args); + + * ------------------------------------------------------------ */ + +%typemap(in) (int ARGC, char **ARGV) { + if (rb_obj_is_kind_of($input,rb_cArray)) { + int i; + int size = RARRAY_LEN($input); + $1 = ($1_ltype) size; + $2 = (char **) malloc((size+1)*sizeof(char *)); + VALUE *ptr = RARRAY_PTR($input); + for (i=0; i < size; i++, ptr++) { + $2[i]= STR2CSTR(*ptr); + } + $2[i]=NULL; + } else { + $1 = 0; $2 = 0; + %argument_fail(SWIG_TypeError, "int ARGC, char **ARGV", $symname, $argnum); + } +} + +%typemap(typecheck, precedence=SWIG_TYPECHECK_STRING_ARRAY) (int ARGC, char **ARGV) { + $1 = rb_obj_is_kind_of($input,rb_cArray); +} + +%typemap(freearg) (int ARGC, char **ARGV) { + free((char *) $2); +} diff --git a/devtools/swigwin-1.3.34/Lib/ruby/attribute.i b/devtools/swigwin-1.3.34/Lib/ruby/attribute.i new file mode 100644 index 0000000..779716c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/attribute.i @@ -0,0 +1 @@ +%include <typemaps/attribute.swg> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/carrays.i b/devtools/swigwin-1.3.34/Lib/ruby/carrays.i new file mode 100644 index 0000000..8f74cd9 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/carrays.i @@ -0,0 +1,6 @@ +%define %array_class(TYPE,NAME) + %array_class_wrap(TYPE,NAME,__getitem__,__setitem__) +%enddef + +%include <typemaps/carrays.swg> + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/cdata.i b/devtools/swigwin-1.3.34/Lib/ruby/cdata.i new file mode 100644 index 0000000..3679659 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/cdata.i @@ -0,0 +1 @@ +%include <typemaps/cdata.swg> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/cmalloc.i b/devtools/swigwin-1.3.34/Lib/ruby/cmalloc.i new file mode 100644 index 0000000..248f06b --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/cmalloc.i @@ -0,0 +1 @@ +%include <typemaps/cmalloc.swg> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/cni.i b/devtools/swigwin-1.3.34/Lib/ruby/cni.i new file mode 100644 index 0000000..10a1403 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/cni.i @@ -0,0 +1,2 @@ +%include <gcj/cni.i> +%include <jstring.i> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/cpointer.i b/devtools/swigwin-1.3.34/Lib/ruby/cpointer.i new file mode 100644 index 0000000..d824792 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/cpointer.i @@ -0,0 +1 @@ +%include <typemaps/cpointer.swg> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/cstring.i b/devtools/swigwin-1.3.34/Lib/ruby/cstring.i new file mode 100644 index 0000000..ede9c59 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/cstring.i @@ -0,0 +1 @@ +%include <typemaps/cstring.swg> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/director.swg b/devtools/swigwin-1.3.34/Lib/ruby/director.swg new file mode 100644 index 0000000..9a6371a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/director.swg @@ -0,0 +1,382 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * director.swg + * + * This file contains support for director classes that proxy + * method calls from C++ to Ruby extensions. + * ----------------------------------------------------------------------------- */ + +/* + Use -DSWIG_DIRECTOR_NOUEH if you prefer to avoid the use of the + Undefined Exception Handler provided by swift +*/ +#ifndef SWIG_DIRECTOR_NOUEH +#ifndef SWIG_DIRECTOR_UEH +#define SWIG_DIRECTOR_UEH +#endif +#endif + +#ifdef __cplusplus + +#include <string> +#include <iostream> +#include <map> + +namespace Swig { + /* memory handler */ + struct GCItem + { + virtual ~GCItem() + { + } + + virtual ruby_owntype get_own() const + { + return 0; + } + }; + + struct GCItem_var + { + GCItem_var(GCItem *item = 0) : _item(item) + { + } + + GCItem_var& operator=(GCItem *item) + { + GCItem *tmp = _item; + _item = item; + delete tmp; + return *this; + } + + ~GCItem_var() + { + delete _item; + } + + GCItem * operator->() const + { + return _item; + } + + private: + GCItem *_item; + }; + + + template <typename Type> + struct GCItem_T : GCItem + { + GCItem_T(Type *ptr) : _ptr(ptr) + { + } + + virtual ~GCItem_T() + { + delete _ptr; + } + + private: + Type *_ptr; + }; + + struct GCItem_Object : GCItem + { + GCItem_Object(ruby_owntype own) : _own(own) + { + } + + virtual ~GCItem_Object() + { + } + + ruby_owntype get_own() const + { + return _own; + } + + private: + ruby_owntype _own; + }; + + + template <typename Type> + struct GCArray_T : GCItem + { + GCArray_T(Type *ptr) : _ptr(ptr) + { + } + + virtual ~GCArray_T() + { + delete[] _ptr; + } + + private: + Type *_ptr; + }; + + + /* body args */ + struct body_args { + VALUE recv; + ID id; + int argc; + VALUE *argv; + }; + + /* Base class for director exceptions */ + class DirectorException { + protected: + VALUE swig_error; + std::string swig_msg; + protected: + DirectorException(VALUE error) + : swig_error(error) + { + } + + DirectorException(VALUE error, const char* hdr, const char* msg ="") + : swig_error(error), swig_msg(hdr) { + if (strlen(msg)) { + swig_msg += " "; + swig_msg += msg; + } + if (swig_msg.size()) { + VALUE str = rb_str_new(swig_msg.data(), swig_msg.size()); + swig_error = rb_exc_new3(error, str); + } else { + swig_error = error; + } + } + public: + VALUE getType() const { + return CLASS_OF(swig_error); + } + VALUE getError() const { + return swig_error; + } + const std::string& getMessage() const + { + return swig_msg; + } + + virtual ~DirectorException() {} + }; + + /* unknown exception handler */ + + class UnknownExceptionHandler + { +#ifdef SWIG_DIRECTOR_UEH + static void handler() { + try { + throw; + } catch (DirectorException& e) { + std::cerr << "Swig Director exception caught:" << std::endl + << e.getMessage() << std::endl; + } catch (std::exception& e) { + std::cerr << "std::exception caught: "<< e.what() << std::endl; + } catch (...) { + std::cerr << "Unknown exception caught." << std::endl; + } + std::cerr << std::endl + << "Ruby interpreter traceback:" << std::endl; + std::cerr << std::endl; + std::cerr << "This exception was caught by the SWIG unexpected exception handler." << std::endl + << "Try using %feature(\"director:except\") to avoid reaching this point." << std::endl + << std::endl + << "Exception is being re-thrown, program will like abort/terminate." << std::endl; + throw; + } + + public: + std::unexpected_handler old; + UnknownExceptionHandler(std::unexpected_handler nh = handler) + { + old = std::set_unexpected(nh); + } + + ~UnknownExceptionHandler() + { + std::set_unexpected(old); + } +#endif + }; + + + /* Type mismatch in the return value from a Ruby method call */ + class DirectorTypeMismatchException : public Swig::DirectorException { + public: + DirectorTypeMismatchException(VALUE error, const char *msg="") + : Swig::DirectorException(error, "Swig director type mismatch", msg) + { + } + + DirectorTypeMismatchException(const char *msg="") + : Swig::DirectorException(rb_eTypeError, "Swig director type mismatch", msg) + { + } + + static void raise(VALUE error, const char *msg) { + throw DirectorTypeMismatchException(error, msg); + } + + static void raise(const char *msg) { + throw DirectorTypeMismatchException(msg); + } + }; + + /* Any Ruby exception that occurs during a director method call */ + class DirectorMethodException : public Swig::DirectorException { + public: + DirectorMethodException(VALUE error) + : Swig::DirectorException(error) { + } + + DirectorMethodException(const char* msg = "") + : Swig::DirectorException(rb_eRuntimeError, "Swig director method error.", msg) { + } + + static void raise(VALUE error) + { + throw DirectorMethodException(error); + } + }; + + /* Attempted to call a pure virtual method via a director method */ + class DirectorPureVirtualException : public Swig::DirectorException + { + public: + DirectorPureVirtualException(const char* msg = "") + : DirectorException(rb_eRuntimeError, "Swig director pure virtual method called", msg) + { + } + + static void raise(const char *msg) + { + throw DirectorPureVirtualException(msg); + } + }; + + /* Simple thread abstraction for pthreads on win32 */ +#ifdef __THREAD__ +# define __PTHREAD__ +# if defined(_WIN32) || defined(__WIN32__) +# define pthread_mutex_lock EnterCriticalSection +# define pthread_mutex_unlock LeaveCriticalSection +# define pthread_mutex_t CRITICAL_SECTION +# define SWIG_MUTEX_INIT(var) var +# else +# include <pthread.h> +# define SWIG_MUTEX_INIT(var) var = PTHREAD_MUTEX_INITIALIZER +# endif +#endif + +#ifdef __PTHREAD__ + struct Guard + { + pthread_mutex_t *_mutex; + + Guard(pthread_mutex_t &mutex) : _mutex(&mutex) + { + pthread_mutex_lock(_mutex); + } + + ~Guard() + { + pthread_mutex_unlock(_mutex); + } + }; +# define SWIG_GUARD(mutex) Guard _guard(mutex) +#else +# define SWIG_GUARD(mutex) +#endif + + /* director base class */ + class Director { + private: + /* pointer to the wrapped Ruby object */ + VALUE swig_self; + /* flag indicating whether the object is owned by Ruby or c++ */ + mutable bool swig_disown_flag; + + public: + /* wrap a Ruby object, optionally taking ownership */ + Director(VALUE self) : swig_self(self), swig_disown_flag(false) { + } + + /* discard our reference at destruction */ + virtual ~Director() { + } + + /* return a pointer to the wrapped Ruby object */ + VALUE swig_get_self() const { + return swig_self; + } + + /* acquire ownership of the wrapped Ruby object (the sense of "disown" + * is from Ruby) */ + void swig_disown() const { + if (!swig_disown_flag) { + swig_disown_flag = true; + } + } + + /* ownership management */ + private: + typedef std::map<void*, GCItem_var> ownership_map; + mutable ownership_map owner; +#ifdef __PTHREAD__ + static pthread_mutex_t swig_mutex_own; +#endif + + public: + template <typename Type> + void swig_acquire_ownership_array(Type *vptr) const + { + if (vptr) { + SWIG_GUARD(swig_mutex_own); + owner[vptr] = new GCArray_T<Type>(vptr); + } + } + + template <typename Type> + void swig_acquire_ownership(Type *vptr) const + { + if (vptr) { + SWIG_GUARD(swig_mutex_own); + owner[vptr] = new GCItem_T<Type>(vptr); + } + } + + void swig_acquire_ownership_obj(void *vptr, ruby_owntype own) const + { + if (vptr && own) { + SWIG_GUARD(swig_mutex_own); + owner[vptr] = new GCItem_Object(own); + } + } + + ruby_owntype swig_release_ownership(void *vptr) const + { + ruby_owntype own = 0; + if (vptr) { + SWIG_GUARD(swig_mutex_own); + ownership_map::iterator iter = owner.find(vptr); + if (iter != owner.end()) { + own = iter->second->get_own(); + owner.erase(iter); + } + } + return own; + } + }; +} + +#endif /* __cplusplus */ + + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/embed.i b/devtools/swigwin-1.3.34/Lib/ruby/embed.i new file mode 100644 index 0000000..ad38190 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/embed.i @@ -0,0 +1,16 @@ +%wrapper %{ + +#include "ruby.h" + +int +main(argc, argv) + int argc; + char **argv; +{ + ruby_init(); + ruby_options(argc, argv); + ruby_run(); + return 0; +} + +%} diff --git a/devtools/swigwin-1.3.34/Lib/ruby/exception.i b/devtools/swigwin-1.3.34/Lib/ruby/exception.i new file mode 100644 index 0000000..1e80d96 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/exception.i @@ -0,0 +1,5 @@ +%include <typemaps/exception.swg> + +%insert("runtime") { + %define_as(SWIG_exception(code, msg), %block(%error(code, msg);)) +} diff --git a/devtools/swigwin-1.3.34/Lib/ruby/extconf.rb b/devtools/swigwin-1.3.34/Lib/ruby/extconf.rb new file mode 100644 index 0000000..3bac8cc --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/extconf.rb @@ -0,0 +1,9 @@ +require 'mkmf' + +dir_config('yourlib') + +if have_header('yourlib.h') and have_library('yourlib', 'yourlib_init') + # If you use swig -c option, you may have to link libswigrb. + # have_library('swigrb') + create_makefile('yourlib') +end diff --git a/devtools/swigwin-1.3.34/Lib/ruby/extra-install.list b/devtools/swigwin-1.3.34/Lib/ruby/extra-install.list new file mode 100644 index 0000000..4610fa8 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/extra-install.list @@ -0,0 +1,3 @@ +# see top-level Makefile.in +Makefile.swig +extconf.rb diff --git a/devtools/swigwin-1.3.34/Lib/ruby/factory.i b/devtools/swigwin-1.3.34/Lib/ruby/factory.i new file mode 100644 index 0000000..46a0a87 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/factory.i @@ -0,0 +1 @@ +%include <typemaps/factory.swg> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/file.i b/devtools/swigwin-1.3.34/Lib/ruby/file.i new file mode 100644 index 0000000..54ed0a6 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/file.i @@ -0,0 +1,32 @@ +// FILE * +%{ +#ifdef __cplusplus +extern "C" { +#endif +#include "rubyio.h" +#ifdef __cplusplus +} +#endif +%} + +%typemap(in) FILE *READ { + OpenFile *of; + GetOpenFile($input, of); + rb_io_check_readable(of); + $1 = GetReadFile(of); + rb_read_check($1); +} + +%typemap(in) FILE *READ_NOCHECK { + OpenFile *of; + GetOpenFile($input, of); + rb_io_check_readable(of); + $1 = GetReadFile(of); +} + +%typemap(in) FILE *WRITE { + OpenFile *of; + GetOpenFile($input, of); + rb_io_check_writable(of); + $1 = GetWriteFile(of); +} diff --git a/devtools/swigwin-1.3.34/Lib/ruby/jstring.i b/devtools/swigwin-1.3.34/Lib/ruby/jstring.i new file mode 100644 index 0000000..17efa97 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/jstring.i @@ -0,0 +1,44 @@ +%include <typemaps/valtypes.swg> + +%fragment(SWIG_AsVal_frag(jstring),"header") { +SWIGINTERN int +SWIG_AsVal(jstring)(VALUE obj, jstring *val) +{ + if (NIL_P(obj)){ + if (val) *val = 0; + return SWIG_OK; + } + if (TYPE(obj) == T_STRING) { + if (val) { + char *cstr = rb_string_value_ptr(&(obj)); + jsize len = RSTRING_LEN(obj); + *val = JvNewStringLatin1(cstr, len); + } + return SWIG_NEWOBJ; + } + return SWIG_TypeError; +} +} + +%fragment(SWIG_From_frag(jstring),"header") { +SWIGINTERNINLINE VALUE +SWIG_From(jstring)(jstring val) +{ + if (!val) { + return Qnil; + } else { + jint len = JvGetStringUTFLength(val); + char buf[len]; + JvGetStringUTFRegion(val, 0, len, buf); + return rb_str_new(buf,len); + } +} +} + +%typemaps_asvalfrom(%checkcode(STRING), + %arg(SWIG_AsVal(jstring)), + %arg(SWIG_From(jstring)), + %arg(SWIG_AsVal_frag(jstring)), + %arg(SWIG_From_frag(jstring)), + java::lang::String *); + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/progargcargv.i b/devtools/swigwin-1.3.34/Lib/ruby/progargcargv.i new file mode 100644 index 0000000..a2843c3 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/progargcargv.i @@ -0,0 +1,34 @@ +/* +int PROG_ARGC +char **PROG_ARGV + + Some C function receive argc and argv from C main function. + This typemap provides ignore typemap which pass Ruby ARGV contents + as argc and argv to C function. +*/ + + + +// argc and argv +%typemap(in,numinputs=0) int PROG_ARGC { + $1 = RARRAY_LEN(rb_argv) + 1; +} + +%typemap(in,numinputs=0) char **PROG_ARGV { + int i, n; + VALUE ary = rb_eval_string("[$0] + ARGV"); + n = RARRAY_LEN(ary); + $1 = (char **)malloc(n + 1); + for (i = 0; i < n; i++) { + VALUE v = rb_obj_as_string(RARRAY_PTR(ary)[i]); + $1[i] = (char *)malloc(RSTRING_LEN(v) + 1); + strcpy($1[i], RSTRING_PTR(v)); + } +} + +%typemap(freearg) char **PROG_ARGV { + int i, n = RARRAY_LEN(rb_argv) + 1; + for (i = 0; i < n; i++) free($1[i]); + free($1); +} + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/ruby.swg b/devtools/swigwin-1.3.34/Lib/ruby/ruby.swg new file mode 100644 index 0000000..efa8ec2 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/ruby.swg @@ -0,0 +1,72 @@ +/* ------------------------------------------------------------ + * ruby.swg + * + * Ruby configuration module. + * ------------------------------------------------------------ */ + +/* ------------------------------------------------------------ + * The Ruby auto rename rules + * ------------------------------------------------------------ */ +#if defined(SWIG_RUBY_AUTORENAME) +/* Class names are CamelCase */ +%rename("%(camelcase)s", %$isclass) ""; + +/* Constants created by %constant or #define are UPPER_CASE */ +%rename("%(uppercase)s", %$isconstant) ""; + +/* SWIG only considers static class members with inline intializers + to be constants. For examples of what is and isn't considered + a constant by SWIG see naming.i in the Ruby test suite. */ +%rename("%(uppercase)s", %$ismember, %$isvariable,%$isimmutable,%$isstatic,%$hasvalue,%$hasconsttype) ""; + +/* Enums are mapped to constants but all we do is make sure the + first letter is uppercase */ +%rename("%(firstuppercase)s", %$isenumitem) ""; + +/* Method names should be lower_case_with_underscores */ +%rename("%(undercase)s", %$isfunction, %$not %$ismemberget, %$not %$ismemberset) ""; +#endif + +/* ------------------------------------------------------------ + * Inner macros + * ------------------------------------------------------------ */ +%include <rubymacros.swg> + + +/* ------------------------------------------------------------ + * The runtime part + * ------------------------------------------------------------ */ +%include <rubyruntime.swg> + +/* ------------------------------------------------------------ + * Special user directives + * ------------------------------------------------------------ */ +%include <rubyuserdir.swg> + +/* ------------------------------------------------------------ + * Typemap specializations + * ------------------------------------------------------------ */ +%include <rubytypemaps.swg> + +/* ------------------------------------------------------------ + * Overloaded operator support + * ------------------------------------------------------------ */ +%include <rubyopers.swg> + +/* ------------------------------------------------------------ + * Warnings for Ruby keywords + * ------------------------------------------------------------ */ +%include <rubykw.swg> + +/* ------------------------------------------------------------ + * Documentation for common Ruby methods + * ------------------------------------------------------------ */ +%include <rubyautodoc.swg> + +/* ------------------------------------------------------------ + * The Ruby initialization function + * ------------------------------------------------------------ */ +%include <rubyinit.swg> + + + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubyapi.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubyapi.swg new file mode 100644 index 0000000..e007757 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubyapi.swg @@ -0,0 +1,36 @@ +/* ----------------------------------------------------------------------------- + * Ruby API portion that goes into the runtime + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#endif + +SWIGINTERN VALUE +SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { + if (NIL_P(target)) { + target = o; + } else { + if (TYPE(target) != T_ARRAY) { + VALUE o2 = target; + target = rb_ary_new(); + rb_ary_push(target, o2); + } + rb_ary_push(target, o); + } + return target; +} + +/* For ruby1.8.4 and earlier. */ +#ifndef RUBY_INIT_STACK + RUBY_EXTERN void Init_stack(VALUE* addr); +# define RUBY_INIT_STACK \ + VALUE variable_in_this_stack_frame; \ + Init_stack(&variable_in_this_stack_frame); +#endif + + +#ifdef __cplusplus +} +#endif + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubyautodoc.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubyautodoc.swg new file mode 100644 index 0000000..ade4bde --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubyautodoc.swg @@ -0,0 +1,110 @@ +/** + * @file rubyautodoc.swg + * @author gga + * @date Wed May 2 16:41:59 2007 + * + * @brief This file implements autodoc typemaps for some common + * ruby methods. + * + * + */ + +%define AUTODOC(func, str) + %feature("autodoc", str) func; +%enddef + + +AUTODOC(to_i, "Convert $class to an Integer"); +AUTODOC(to_f, "Convert $class to a Float"); +AUTODOC(coerce, "Coerce class to a number"); +AUTODOC(to_a, "Convert $class to an Array"); +AUTODOC(to_s, "Convert class to a String representation"); +AUTODOC(inspect, "Inspect class and its contents"); + +AUTODOC(at, "Return element at a certain index"); +AUTODOC(__getitem__, "Element accessor/slicing"); +AUTODOC(__setitem__, "Element setter/slicing"); +AUTODOC(slice, "Return a slice (portion of) the $class"); + +AUTODOC(push, "Add an element at the end of the $class"); +AUTODOC(pop, "Remove and return element at the end of the $class"); +AUTODOC(shift, "Remove and return element at the beginning of the $class"); +AUTODOC(unshift, "Add one or more elements at the beginning of the $class"); +AUTODOC(first, "Return the first element in $class"); +AUTODOC(last, "Return the last element in $class"); + + +// +// Common Object methods +// +AUTODOC(hash, "Hashing function for class"); +AUTODOC(dup, "Create a duplicate of the class and unfreeze it if needed"); +AUTODOC(clone, "Create a duplicate of the class"); + +// +// Container methods +// +AUTODOC(empty, "Check if $class is empty"); +AUTODOC(size, "Size or Length of the $class"); +AUTODOC(insert, "Insert one or more new elements in the $class"); + +// +// Iterator methods (block) +// +AUTODOC(each, "Iterate thru each element in the $class. A block must be provided"); +AUTODOC(find, "Find an element in the class"); +AUTODOC(each_key, "Iterate thru each key element in the $class. A block must be provided"); +AUTODOC(each_value, "Iterate thru each key element in the $class. A block must be provided"); +AUTODOC(reject, "Iterate thru each element in the $class and reject those that fail a condition returning a new $class. A block must be provided"); +AUTODOC(reject_bang, "Iterate thru each element in the $class and reject those that fail a condition. A block must be provided. $class is modified in place"); +AUTODOC(select, "Iterate thru each element in the $class and select those that match a condition. A block must be provided"); +AUTODOC(delete_at, "Delete an element at a certain index"); +AUTODOC(__delete__, "Delete a matching element"); + + +// +// Hash methods +// +AUTODOC(keys, "Return an Array of key elements"); +AUTODOC(values, "Return an Array of value elements"); +AUTODOC(values_at, "Return an Array of value elements matching the conditions"); + + +// +// Operators +// +#ifdef __cplusplus +AUTODOC(operator==, "Equality comparison operator"); +AUTODOC(operator<=, "Lower or equal comparison operator"); +AUTODOC(operator>=, "Higher or equal comparison operator"); +AUTODOC(operator<, "Lower than comparison operator"); +AUTODOC(operator>, "Higher than comparison operator"); +AUTODOC(operator<<, "Left shifting or appending operator"); +AUTODOC(operator>>, "Right shifting operator or extracting operator"); +AUTODOC(operator+, "Add operator"); +AUTODOC(operator-, "Substraction operator"); +AUTODOC(operator+(), "Positive operator"); +AUTODOC(operator-(), "Negation operator"); +AUTODOC(operator&, "AND operator"); +AUTODOC(operator|, "OR operator"); +AUTODOC(operator^, "XOR operator"); +AUTODOC(operator~, "Invert operator"); +#endif +AUTODOC(__eq__, "Equality comparison operator"); +AUTODOC(__le__, "Lower or equal comparison operator"); +AUTODOC(__ge__, "Higher or equal comparison operator"); +AUTODOC(__lt__, "Lower than comparison operator"); +AUTODOC(__gt__, "Higher than comparison operator"); +AUTODOC(__lshift__, "Left shifting or appending operator"); +AUTODOC(__rshift__, "Right shifting operator or extracting operator"); +AUTODOC(__add___, "Add operator"); +AUTODOC(__sub__, "Substraction operator"); +AUTODOC(__pos__, "Positive operator"); +AUTODOC(__neg__, "Negation operator"); +AUTODOC(__and__, "AND operator"); +AUTODOC(__or__, "OR operator"); +AUTODOC(__xor__, "XOR operator"); +AUTODOC(__negate__, "Invert operator"); +AUTODOC(__pow__, "Exponential operator"); +AUTODOC(__divmod__, "Modulo of division"); +AUTODOC(__cmp__, "Comparison operator. Returns < 0 for less than, 0 for equal or > 1 for higher than."); diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubyclasses.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubyclasses.swg new file mode 100644 index 0000000..db54826 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubyclasses.swg @@ -0,0 +1,395 @@ +#ifdef __cplusplus + +/* + GC_VALUE is used as a replacement of Ruby's VALUE. + GC_VALUE automatically handles registering and unregistering + of the underlying Ruby object with the GC. + + It can be used if you want to create STL containers of VALUEs, such as: + + std::vector< GC_VALUE >; + + or as a member variable: + + struct A { + GC_VALUE _obj; + A(VALUE o) : _obj(o) { + } + }; + + or as a input/output value (not much use for this, as VALUE works just as + well here, thou): + + GC_VALUE func(GC_VALUE obj) { + GC_VALUE out = rb_obj_classname(obj); + return out; + } + + + GC_VALUE is 'visible' at the wrapped side, so you can do: + + %template(RubyVector) std::vector<swig::GC_VALUE>; + + and all the proper typemaps will be used. + +*/ + +namespace swig { + + %nodirector GC_VALUE; + + // We ignore the constructor so that user can never create a GC_VALUE + // manually + %ignore GC_VALUE::GC_VALUE; + + struct GC_VALUE { + VALUE inspect() const; + VALUE to_s() const; + GC_VALUE(); + protected: + GC_VALUE( const GC_VALUE& ); + ~GC_VALUE(); + }; + + %exception GC_VALUE {}; + + + %apply VALUE {GC_VALUE}; + + // Make sure this is the last typecheck done + %typecheck(999999,noblock=1) GC_VALUE, GC_VALUE&, + const GC_VALUE& { $1 = 1; }; + + /* For input */ + %typemap(in,noblock=1) GC_VALUE* (GC_VALUE r), GC_VALUE& (GC_VALUE r) { + r = $input; $1 = &r; + } + + /* For output */ + %typemap(out,noblock=1) GC_VALUE { + $result = (VALUE)$1; + } + + %typemap(out,noblock=1) GC_VALUE*, GC_VALUE const & { + $result = (VALUE)*$1; + } + + %ignore LANGUAGE_OBJ; + typedef GC_VALUE LANGUAGE_OBJ; +} + + +%{ +namespace swig { + class GC_VALUE { + protected: + // Hash of all GC_VALUE's currently in use + static VALUE _hash; + + VALUE _obj; + + static ID hash_id; + static ID lt_id; + static ID gt_id; + static ID eq_id; + static ID le_id; + static ID ge_id; + + static ID pos_id; + static ID neg_id; + static ID inv_id; + + static ID add_id; + static ID sub_id; + static ID mul_id; + static ID div_id; + static ID mod_id; + + static ID and_id; + static ID or_id; + static ID xor_id; + + static ID lshift_id; + static ID rshift_id; + + struct OpArgs + { + VALUE src; + ID id; + int nargs; + VALUE target; + }; + + + public: + static void initialize() + { + if ( _hash == Qnil ) + { + _hash = rb_hash_new(); + rb_gc_register_address( &_hash ); + } + } + + // this function is never called. Provided for symmetry only. + static void cleanup() + { + rb_gc_unregister_address( &_hash ); + } + + GC_VALUE() : _obj( Qnil ) + { + } + + GC_VALUE(const GC_VALUE& item) : _obj(item._obj) + { + GC_register(); + } + + GC_VALUE(VALUE obj) :_obj(obj) + { + GC_register(); + } + + ~GC_VALUE() + { + GC_unregister(); + } + + GC_VALUE & operator=(const GC_VALUE& item) + { + GC_unregister(); + _obj = item._obj; + GC_register(); + return *this; + } + + void GC_register() + { + if ( FIXNUM_P(_obj) || SPECIAL_CONST_P(_obj) || SYMBOL_P(_obj) ) + return; + VALUE val = rb_hash_aref( _hash, _obj ); + unsigned n = FIXNUM_P(val) ? NUM2UINT(val) : 0; + ++n; + rb_hash_aset( _hash, _obj, INT2NUM(n) ); + } + + void GC_unregister() + { + if ( FIXNUM_P(_obj) || SPECIAL_CONST_P(_obj) || SYMBOL_P(_obj) ) + return; + // this test should not be needed but I've noticed some very erratic + // behavior of none being unregistered in some very rare situations. + if ( BUILTIN_TYPE(_obj) == T_NONE ) return; + + VALUE val = rb_hash_aref( _hash, _obj ); + unsigned n = FIXNUM_P(val) ? NUM2UINT(val) : 1; + --n; + if ( n ) + rb_hash_aset( _hash, _obj, INT2NUM(n) ); + else + rb_hash_delete( _hash, _obj ); + } + + operator VALUE() const + { + return _obj; + } + + VALUE inspect() const + { + return rb_inspect(_obj); + } + + VALUE to_s() const + { + return rb_inspect(_obj); + } + + static VALUE swig_protect_funcall( VALUE p ) + { + OpArgs* args = (OpArgs*) p; + return rb_funcall( args->src, args->id, args->nargs, args->target ); + } + + +#define GC_VALUE_CMP( op_id, op, cmp, cmpval ) \ + bool op( const GC_VALUE& other ) const \ + { \ + if ( FIXNUM_P(_obj) && FIXNUM_P(other._obj) ) \ + { \ + return _obj cmp other._obj; \ + } \ + bool res = false; \ + VALUE ret = Qnil; \ + SWIG_RUBY_THREAD_BEGIN_BLOCK; \ + if ( rb_respond_to( _obj, op_id ) == Qtrue ) \ + { \ + int status; \ + OpArgs args; \ + args.src = _obj; \ + args.id = op_id; \ + args.nargs = 1; \ + args.target = VALUE(other); \ + ret = rb_protect( PROTECTFUNC(swig_protect_funcall), \ + VALUE(&args), &status ); \ + } \ + if ( ret == Qnil ) { \ + VALUE a = rb_funcall( _obj, hash_id, 0 ); \ + VALUE b = rb_funcall( VALUE(other), hash_id, 0 ); \ + res = a cmp b; \ + } \ + else \ + { \ + res = RTEST( ret ); \ + } \ + SWIG_RUBY_THREAD_END_BLOCK; \ + return res; \ + } + + + GC_VALUE_CMP( eq_id, operator==, ==, == 0 ) + GC_VALUE_CMP( lt_id, operator<, < , < 0 ) + GC_VALUE_CMP( le_id, operator<=, <=, <= 0 ) + GC_VALUE_CMP( gt_id, operator>, > , > 0 ) + GC_VALUE_CMP( ge_id, operator>=, >=, >= 0 ) +#undef GC_VALUE_CMP + + bool operator!=( const GC_VALUE& other ) + { + return !(this->operator==(other)); + } + +#define GC_VALUE_UNARY( proc_id, op ) \ + GC_VALUE op() const \ + { \ + VALUE ret = Qnil; \ + SWIG_RUBY_THREAD_BEGIN_BLOCK; \ + int status; \ + OpArgs args; \ + args.src = _obj; \ + args.id = proc_id; \ + args.nargs = 0; \ + args.target = Qnil; \ + ret = rb_protect( PROTECTFUNC(swig_protect_funcall), VALUE(&args), \ + &status ); \ + SWIG_RUBY_THREAD_END_BLOCK; \ + return ret; \ + } + + GC_VALUE_UNARY( pos_id, operator+ ) + GC_VALUE_UNARY( neg_id, operator- ) + GC_VALUE_UNARY( inv_id, operator~ ) +#undef GC_VALUE_BINARY + +#define GC_VALUE_BINARY( proc_id, op ) \ + GC_VALUE op( const GC_VALUE& other ) const \ + { \ + VALUE ret = Qnil; \ + SWIG_RUBY_THREAD_BEGIN_BLOCK; \ + int status; \ + OpArgs args; \ + args.src = _obj; \ + args.id = proc_id; \ + args.nargs = 1; \ + args.target = VALUE(other); \ + ret = rb_protect( PROTECTFUNC(swig_protect_funcall), VALUE(&args), \ + &status ); \ + SWIG_RUBY_THREAD_END_BLOCK; \ + return GC_VALUE(ret); \ + } + + GC_VALUE_BINARY( add_id, operator+ ); + GC_VALUE_BINARY( sub_id, operator- ); + GC_VALUE_BINARY( mul_id, operator* ); + GC_VALUE_BINARY( div_id, operator/ ); + GC_VALUE_BINARY( mod_id, operator% ); + + GC_VALUE_BINARY( and_id, operator& ); + GC_VALUE_BINARY( xor_id, operator^ ); + GC_VALUE_BINARY( or_id, operator| ); + + GC_VALUE_BINARY( lshift_id, operator<< ); + GC_VALUE_BINARY( rshift_id, operator>> ); +#undef GC_VALUE_BINARY + + }; + + ID GC_VALUE::hash_id = rb_intern("hash"); + ID GC_VALUE::lt_id = rb_intern("<"); + ID GC_VALUE::gt_id = rb_intern(">"); + ID GC_VALUE::eq_id = rb_intern("=="); + ID GC_VALUE::le_id = rb_intern("<="); + ID GC_VALUE::ge_id = rb_intern(">="); + + ID GC_VALUE::pos_id = rb_intern("+@"); + ID GC_VALUE::neg_id = rb_intern("-@"); + ID GC_VALUE::inv_id = rb_intern("~"); + + ID GC_VALUE::add_id = rb_intern("+"); + ID GC_VALUE::sub_id = rb_intern("-"); + ID GC_VALUE::mul_id = rb_intern("*"); + ID GC_VALUE::div_id = rb_intern("/"); + ID GC_VALUE::mod_id = rb_intern("%"); + + ID GC_VALUE::and_id = rb_intern("&"); + ID GC_VALUE::or_id = rb_intern("|"); + ID GC_VALUE::xor_id = rb_intern("^"); + + ID GC_VALUE::lshift_id = rb_intern("<<"); + ID GC_VALUE::rshift_id = rb_intern(">>"); + + VALUE GC_VALUE::_hash = Qnil; + + typedef GC_VALUE LANGUAGE_OBJ; + +} // namespace swig + +%} + + +%init { + swig::GC_VALUE::initialize(); +} + + + +// +// Fragment that contains traits to properly deal with GC_VALUE. +// These functions may be invoked as a need of the from(), asval(), +// asptr() and as() template functors, usually used in %typemaps. +// +%fragment(SWIG_Traits_frag(swig::GC_VALUE),"header",fragment="StdTraits") { +namespace swig { + template <> struct traits<GC_VALUE > { + typedef value_category category; + static const char* type_name() { return "GC_VALUE"; } + }; + + template <> struct traits_from<GC_VALUE> { + typedef GC_VALUE value_type; + static VALUE from(const value_type& val) { + return static_cast<VALUE>(val); + } + }; + + template <> + struct traits_check<GC_VALUE, value_category> { + static bool check(GC_VALUE) { + return true; + } + }; + + template <> struct traits_asval<GC_VALUE > { + typedef GC_VALUE value_type; + static int asval(VALUE obj, value_type *val) { + if (val) *val = obj; + return SWIG_OK; + } + }; +} // swig +} // %fragment(traits for swig::GC_VALUE) + + +#endif // __cplusplus + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubycomplex.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubycomplex.swg new file mode 100644 index 0000000..afdb15e --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubycomplex.swg @@ -0,0 +1,129 @@ +/* + Defines the As/From conversors for double/float complex, you need to + provide complex Type, the Name you want to use in the conversors, + the complex Constructor method, and the Real and Imag complex + accesor methods. + + See the std_complex.i and ccomplex.i for concrete examples. +*/ + +/* + Ruby does not have native complex numbers. They are an extension in the + STD library. +*/ +%{ + static VALUE swig_rb_cComplex = Qnil; + static ID swig_real_id = 0; + static ID swig_imag_id = 0; + + int Ruby_Is_Complex( VALUE obj ) + { + return ( (rb_respond_to( obj, swig_real_id ) == Qtrue) && + (rb_respond_to( obj, swig_imag_id ) == Qtrue) ); + } +%} + +%init { + rb_require("complex"); + swig_rb_cComplex = rb_const_get( rb_cObject, rb_intern("Complex") ); + if( swig_rb_cComplex == Qnil ) + rb_warn("Ruby's complex.so not found"); + swig_real_id = rb_intern("real"); + swig_imag_id = rb_intern("imag"); +} + +/* the common from conversor */ +%define %swig_fromcplx_conv(Type, Real, Imag) +%fragment(SWIG_From_frag(Type),"header") +{ +SWIGINTERNINLINE VALUE +SWIG_From(Type)(%ifcplusplus(const Type&, Type) c) +{ + VALUE args[] = { + rb_float_new(Real(c)), + rb_float_new(Imag(c)) + }; + return rb_class_new_instance(2, args, swig_rb_cComplex); +} +} +%enddef + +/* the double case */ +%define %swig_cplxdbl_conv(Type, Constructor, Real, Imag) +%fragment(SWIG_AsVal_frag(Type),"header", + fragment=SWIG_AsVal_frag(double)) +{ +SWIGINTERN int +SWIG_AsVal(Type) (VALUE o, Type* val) +{ + if ( Ruby_Is_Complex( o ) ) { + if (val) { + VALUE real = rb_funcall(o, swig_real_id, 0 ); + VALUE imag = rb_funcall(o, swig_imag_id, 0 ); + double re = 0; + SWIG_AsVal_double( real, &re ); + double im = 0; + SWIG_AsVal_double( imag, &im ); + *val = Constructor(re, im); + } + return SWIG_OK; + } else { + double d; + int res = SWIG_AddCast(SWIG_AsVal(double)(o, &d)); + if (SWIG_IsOK(res)) { + if (val) *val = Constructor(d, 0.0); + return res; + } + } + return SWIG_TypeError; +} +} +%swig_fromcplx_conv(Type, Real, Imag); +%enddef + +/* the float case */ +%define %swig_cplxflt_conv(Type, Constructor, Real, Imag) +%fragment(SWIG_AsVal_frag(Type),"header", + fragment=SWIG_AsVal_frag(float), + fragment=SWIG_AsVal_frag(double)) { +SWIGINTERN int +SWIG_AsVal(Type)(VALUE o, Type *val) +{ + if ( Ruby_Is_Complex( o ) ) { + VALUE real = rb_funcall(o, swig_real_id, 0 ); + VALUE imag = rb_funcall(o, swig_imag_id, 0 ); + double re = 0; + SWIG_AsVal_double( real, &re ); + double im = 0; + SWIG_AsVal_double( imag, &im ); + if ((-FLT_MAX <= re && re <= FLT_MAX) && + (-FLT_MAX <= im && im <= FLT_MAX)) { + if (val) *val = Constructor(%numeric_cast(re, float), + %numeric_cast(im, float)); + return SWIG_OK; + } else { + return SWIG_OverflowError; + } + } else { + float re; + int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re)); + if (SWIG_IsOK(res)) { + if (val) *val = Constructor(re, 0.0); + return res; + } + } + return SWIG_TypeError; +} +} + +%swig_fromcplx_conv(Type, Real, Imag); +%enddef + +#define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \ +%swig_cplxflt_conv(Type, Constructor, Real, Imag) + + +#define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \ +%swig_cplxdbl_conv(Type, Constructor, Real, Imag) + + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubycontainer.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubycontainer.swg new file mode 100644 index 0000000..fe762d7 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubycontainer.swg @@ -0,0 +1,1131 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * rubycontainer.swg + * + * Ruby sequence <-> C++ container wrapper + * + * This wrapper, and its iterator, allows a general use (and reuse) of + * the the mapping between C++ and Ruby, thanks to the C++ + * templates. + * + * Of course, it needs the C++ compiler to support templates, but + * since we will use this wrapper with the STL containers, that should + * be the case. + * ----------------------------------------------------------------------------- */ + +%{ +#include <iostream> +%} + + +#if !defined(SWIG_NO_EXPORT_ITERATOR_METHODS) +# if !defined(SWIG_EXPORT_ITERATOR_METHODS) +# define SWIG_EXPORT_ITERATOR_METHODS SWIG_EXPORT_ITERATOR_METHODS +# endif +#endif + +%include <rubyiterators.swg> + +/**** The RubySequence C++ Wrap ***/ + +%insert(header) %{ +#include <stdexcept> +%} + +%include <std_except.i> + + +%fragment("RubySequence_Base","header") +{ +%#include <functional> + + +namespace swig { + template < class T > + struct yield : public std::unary_function< T, bool > + { + bool + operator()( const T& v ) const + { + return RTEST( rb_yield( swig::from< T >(v) ) ); + } + }; + + + inline size_t + check_index(ptrdiff_t i, size_t size, bool insert = false) { + if ( i < 0 ) { + if ((size_t) (-i) <= size) + return (size_t) (i + size); + } else if ( (size_t) i < size ) { + return (size_t) i; + } else if (insert && ((size_t) i == size)) { + return size; + } + + throw std::out_of_range("index out of range"); + } + + inline size_t + slice_index(ptrdiff_t i, size_t size) { + if ( i < 0 ) { + if ((size_t) (-i) <= size) { + return (size_t) (i + size); + } else { + throw std::out_of_range("index out of range"); + } + } else { + return ( (size_t) i < size ) ? ((size_t) i) : size; + } + } + + template <class Sequence, class Difference> + inline typename Sequence::iterator + getpos(Sequence* self, Difference i) { + typename Sequence::iterator pos = self->begin(); + std::advance(pos, check_index(i,self->size())); + return pos; + } + + template <class Sequence, class Difference> + inline typename Sequence::const_iterator + cgetpos(const Sequence* self, Difference i) { + typename Sequence::const_iterator pos = self->begin(); + std::advance(pos, check_index(i,self->size())); + return pos; + } + + template <class Sequence, class Difference> + inline Sequence* + getslice(const Sequence* self, Difference i, Difference j) { + typename Sequence::size_type size = self->size(); + typename Sequence::size_type ii = swig::check_index(i, size); + typename Sequence::size_type jj = swig::slice_index(j, size); + + if (jj > ii) { + typename Sequence::const_iterator vb = self->begin(); + typename Sequence::const_iterator ve = self->begin(); + std::advance(vb,ii); + std::advance(ve,jj); + return new Sequence(vb, ve); + } else { + return new Sequence(); + } + } + + template <class Sequence, class Difference, class InputSeq> + inline void + setslice(Sequence* self, Difference i, Difference j, const InputSeq& v) { + typename Sequence::size_type size = self->size(); + typename Sequence::size_type ii = swig::check_index(i, size, true); + typename Sequence::size_type jj = swig::slice_index(j, size); + if (jj < ii) jj = ii; + size_t ssize = jj - ii; + if (ssize <= v.size()) { + typename Sequence::iterator sb = self->begin(); + typename InputSeq::const_iterator vmid = v.begin(); + std::advance(sb,ii); + std::advance(vmid, jj - ii); + self->insert(std::copy(v.begin(), vmid, sb), vmid, v.end()); + } else { + typename Sequence::iterator sb = self->begin(); + typename Sequence::iterator se = self->begin(); + std::advance(sb,ii); + std::advance(se,jj); + self->erase(sb,se); + self->insert(sb, v.begin(), v.end()); + } + } + + template <class Sequence, class Difference> + inline void + delslice(Sequence* self, Difference i, Difference j) { + typename Sequence::size_type size = self->size(); + typename Sequence::size_type ii = swig::check_index(i, size, true); + typename Sequence::size_type jj = swig::slice_index(j, size); + if (jj > ii) { + typename Sequence::iterator sb = self->begin(); + typename Sequence::iterator se = self->begin(); + std::advance(sb,ii); + std::advance(se,jj); + self->erase(sb,se); + } + } +} +} + +%fragment("RubySequence_Cont","header", + fragment="StdTraits", + fragment="RubySequence_Base", + fragment="ConstIterator_T") +{ +namespace swig +{ + + /** + * This class is a proxy class for references, used to return and set values + * of an element of a Ruby Array of stuff. + * It can be used by RubySequence_InputIterator to make it work with STL + * algorithms. + * + */ + template <class T> + struct RubySequence_Ref + { + RubySequence_Ref(VALUE seq, int index) + : _seq(seq), _index(index) + { + } + + operator T () const + { + VALUE item = rb_ary_entry(_seq, _index ); + try { + return swig::as<T>(item, true); + } catch (std::exception& e) { + char msg[1024]; + sprintf(msg, "in sequence element %d ", _index); + VALUE lastErr = rb_gv_get("$!"); + if ( lastErr == Qnil ) { + %type_error(swig::type_name<T>()); + } + VALUE str = rb_str_new2(msg); + str = rb_str_cat2( str, e.what() ); + SWIG_Ruby_ExceptionType( NULL, str ); + throw; + } + } + + RubySequence_Ref& operator=(const T& v) + { + rb_ary_set(_seq, _index, swig::from< T >(v)); + return *this; + } + + private: + VALUE _seq; + int _index; + }; + + + /** + * This class is a proxy to return a pointer to a class, usually + * RubySequence_Ref. + * It can be used by RubySequence_InputIterator to make it work with STL + * algorithms. + * + */ + template <class T> + struct RubySequence_ArrowProxy + { + RubySequence_ArrowProxy(const T& x): m_value(x) {} + const T* operator->() const { return &m_value; } + operator const T*() const { return &m_value; } + T m_value; + }; + + + /** + * Input Iterator. This adapator class is a random access iterator that + * allows you to use STL algorithms with a Ruby class (a Ruby Array by default). + * + */ + template <class T, class Reference = RubySequence_Ref< T > > + struct RubySequence_InputIterator + { + typedef RubySequence_InputIterator<T, Reference > self; + + typedef std::random_access_iterator_tag iterator_category; + typedef Reference reference; + typedef T value_type; + typedef T* pointer; + typedef ptrdiff_t difference_type; + + RubySequence_InputIterator() + { + } + + RubySequence_InputIterator(VALUE seq, int index) + : _seq(seq), _index(index) + { + } + + reference operator*() const + { + return reference(_seq, _index); + } + + RubySequence_ArrowProxy<T> + operator->() const { + return RubySequence_ArrowProxy<T>(operator*()); + } + + bool operator==(const self& ri) const + { + return (_index == ri._index) && (_seq == ri._seq); + } + + bool operator!=(const self& ri) const + { + return !(operator==(ri)); + } + + self& operator ++ () + { + ++_index; + return *this; + } + + self& operator -- () + { + --_index; + return *this; + } + + self& operator += (difference_type n) + { + _index += n; + return *this; + } + + self operator +(difference_type n) const + { + return self(_seq, _index + n); + } + + self& operator -= (difference_type n) + { + _index -= n; + return *this; + } + + self operator -(difference_type n) const + { + return self(_seq, _index - n); + } + + difference_type operator - (const self& ri) const + { + return _index - ri._index; + } + + bool operator < (const self& ri) const + { + return _index < ri._index; + } + + reference + operator[](difference_type n) const + { + return reference(_seq, _index + n); + } + + private: + VALUE _seq; + difference_type _index; + }; + + + /** + * This adaptor class allows you to use a Ruby Array as if it was an STL + * container, giving it begin(), end(), and iterators. + * + */ + template <class T> + struct RubySequence_Cont + { + typedef RubySequence_Ref<T> reference; + typedef const RubySequence_Ref<T> const_reference; + typedef T value_type; + typedef T* pointer; + typedef int difference_type; + typedef int size_type; + typedef const pointer const_pointer; + typedef RubySequence_InputIterator<T, reference> iterator; + typedef RubySequence_InputIterator<T, const_reference> const_iterator; + + RubySequence_Cont(VALUE seq) : _seq(0) + { + if (!rb_obj_is_kind_of(seq, rb_cArray)) { + throw std::invalid_argument("an Array is expected"); + } + _seq = seq; + } + + ~RubySequence_Cont() + { + } + + size_type size() const + { + return RARRAY_LEN(_seq); + } + + bool empty() const + { + return size() == 0; + } + + iterator begin() + { + return iterator(_seq, 0); + } + + const_iterator begin() const + { + return const_iterator(_seq, 0); + } + + iterator end() + { + return iterator(_seq, size()); + } + + const_iterator end() const + { + return const_iterator(_seq, size()); + } + + reference operator[](difference_type n) + { + return reference(_seq, n); + } + + const_reference operator[](difference_type n) const + { + return const_reference(_seq, n); + } + + bool check(bool set_err = false) const + { + int s = (int) size(); + for (int i = 0; i < s; ++i) { + VALUE item = rb_ary_entry(_seq, i ); + if (!swig::check<value_type>(item)) { + if (set_err) { + char msg[1024]; + sprintf(msg, "in sequence element %d", i); + SWIG_Error(SWIG_RuntimeError, msg); + } + return false; + } + } + return true; + } + + private: + VALUE _seq; + }; + +} +} + +/** + * Macros used to typemap an STL iterator -> SWIGIterator conversion. + * + */ +%define %swig_sequence_iterator(Sequence...) +#if defined(SWIG_EXPORT_ITERATOR_METHODS) + + %typemap(out,noblock=1,fragment="RubySequence_Cont") + const_iterator, const_reverse_iterator { + $result = SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &), + self), + swig::ConstIterator::descriptor(),SWIG_POINTER_OWN); + } + + %typemap(out,noblock=1,fragment="RubySequence_Cont") + iterator, reverse_iterator { + $result = SWIG_NewPointerObj(swig::make_nonconst_iterator(%static_cast($1,const $type &), + self), + swig::Iterator::descriptor(),SWIG_POINTER_OWN); + } + + %typemap(out,noblock=1,fragment="RubySequence_Cont") + std::pair<const_iterator, const_iterator> { + $result = rb_ary_new2(2); + RARRAY_PTR($result)[0] = SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).first), + swig::ConstIterator::descriptor(),SWIG_POINTER_OWN); + RARRAY_PTR($result)[1] = SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).second), + swig::ConstIterator::descriptor(),SWIG_POINTER_OWN); + RARRAY_LEN($result) = 2; + } + + // std::map/multimap/set allow returning std::pair< iterator, iterator > from + // equal_range, but we cannot still modify the key, so the iterator is + // const. + %typemap(out,noblock=1,fragment="RubySequence_Cont") + std::pair<iterator, iterator> { + $result = rb_ary_new2(2); + RARRAY_PTR($result)[0] = SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).first), + swig::ConstIterator::descriptor(),SWIG_POINTER_OWN); + RARRAY_PTR($result)[1] = SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).second), + swig::ConstIterator::descriptor(),SWIG_POINTER_OWN); + RARRAY_LEN($result) = 2; + } + + + %typemap(in,noblock=1,fragment="RubySequence_Cont") + const_iterator(swig::ConstIterator *iter = 0, int res), + const_reverse_iterator(swig::ConstIterator *iter = 0, int res) { + res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), + swig::ConstIterator::descriptor(), 0); + if (!SWIG_IsOK(res) || !iter) { + %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); + } else { + swig::ConstIterator_T<$type > *iter_t = dynamic_cast<swig::ConstIterator_T<$type > *>(iter); + if (iter_t) { + $1 = iter_t->get_current(); + } else { + %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); + } + } + } + + %typemap(in,noblock=1,fragment="RubySequence_Cont") + iterator(swig::Iterator *iter = 0, int res), + reverse_iterator(swig::Iterator *iter = 0, int res) { + res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::Iterator::descriptor(), 0); + if (!SWIG_IsOK(res) || !iter) { + %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); + } else { + swig::Iterator_T<$type > *iter_t = dynamic_cast<swig::Iterator_T<$type > *>(iter); + if (iter_t) { + $1 = iter_t->get_current(); + } else { + %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); + } + } + } + + %typecheck(%checkcode(ITERATOR),noblock=1,fragment="RubySequence_Cont") + const_iterator, const_reverse_iterator { + swig::ConstIterator *iter = 0; + int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), + swig::ConstIterator::descriptor(), 0); + $1 = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::ConstIterator_T<$type > *>(iter) != 0)); + } + + %typecheck(%checkcode(ITERATOR),noblock=1,fragment="RubySequence_Cont") + iterator, reverse_iterator { + swig::ConstIterator *iter = 0; + int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), + swig::Iterator::descriptor(), 0); + $1 = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::Iterator_T<$type > *>(iter) != 0)); + } + + %fragment("RubySequence_Cont"); + +// %newobject iterator; +// %newobject const_iterator; +// %extend { +// swig::Iterator* iterator(VALUE* RUBY_SELF) { +// return swig::make_nonconst_iterator($self->begin(), $self->begin(), +// $self->end(), *RUBY_SELF); +// } + +// swig::ConstIterator* const_iterator(VALUE* RUBY_SELF) { +// return swig::make_const_iterator($self->begin(), $self->begin(), +// $self->end(), *RUBY_SELF); +// } +// } +#endif //SWIG_EXPORT_ITERATOR_METHODS +%enddef + + +/**** The Ruby container methods ****/ + + + +%define %swig_container_methods(Container...) + + %extend { + + %newobject dup; + Container* dup() + { + return new Container(*$self); + } + + } + +%enddef + + +/** + * Macro used to define common Ruby printing methods for STL container + * + */ +%define %swig_sequence_printing_methods(Sequence...) + + %extend { + + VALUE inspect() + { + Sequence::const_iterator i = $self->begin(); + Sequence::const_iterator e = $self->end(); + VALUE str = rb_str_new2( swig::type_name< Sequence >() ); + str = rb_str_cat2( str, " [" ); + bool comma = false; + VALUE tmp; + for ( ; i != e; ++i, comma = true ) + { + if (comma) str = rb_str_cat2( str, "," ); + tmp = swig::from< Sequence::value_type >( *i ); + tmp = rb_inspect( tmp ); + str = rb_str_buf_append( str, tmp ); + } + str = rb_str_cat2( str, "]" ); + return str; + } + + VALUE to_a() + { + Sequence::const_iterator i = $self->begin(); + Sequence::const_iterator e = $self->end(); + VALUE ary = rb_ary_new2( std::distance( i, e ) ); + VALUE tmp; + for ( ; i != e; ++i ) + { + tmp = swig::from< Sequence::value_type >( *i ); + rb_ary_push( ary, tmp ); + } + return ary; + } + + VALUE to_s() + { + Sequence::iterator i = $self->begin(); + Sequence::iterator e = $self->end(); + VALUE str = rb_str_new2( "" ); + VALUE tmp; + for ( ; i != e; ++i ) + { + tmp = swig::from< Sequence::value_type >( *i ); + tmp = rb_obj_as_string( tmp ); + str = rb_str_buf_append( str, tmp ); + } + return str; + } +} +%enddef + + +/** + * Macro used to add common methods to all STL sequence-type containers + * + */ +%define %swig_sequence_methods_common(Sequence...) + %swig_container_methods(%arg(Sequence)) + %swig_sequence_iterator(%arg(Sequence)) + %swig_sequence_printing_methods(%arg(Sequence)) + + %fragment("RubySequence_Base"); + + %extend { + + + VALUE slice( difference_type i, difference_type j ) + { + if ( j <= 0 ) return Qnil; + std::size_t len = $self->size(); + if ( i < 0 ) i = len - i; + j += i; + if ( static_cast<std::size_t>(j) >= len ) j = len-1; + + VALUE r = Qnil; + try { + r = swig::from< const Sequence* >( swig::getslice(self, i, j) ); + } + catch( std::out_of_range ) + { + } + return r; + } + + + Sequence* each() + { + if ( !rb_block_given_p() ) + rb_raise( rb_eArgError, "no block given"); + + VALUE r; + Sequence::const_iterator i = self->begin(); + Sequence::const_iterator e = self->end(); + for ( ; i != e; ++i ) + { + r = swig::from< Sequence::value_type >(*i); + rb_yield(r); + } + + return self; + } + + %newobject select; + Sequence* select() { + if ( !rb_block_given_p() ) + rb_raise( rb_eArgError, "no block given" ); + + Sequence* r = new Sequence; + Sequence::const_iterator i = $self->begin(); + Sequence::const_iterator e = $self->end(); + for ( ; i != e; ++i ) + { + VALUE v = swig::from< Sequence::value_type >(*i); + if ( RTEST( rb_yield(v) ) ) + $self->insert( r->end(), *i); + } + + return r; + } + + %alias reject_bang "delete_if"; + Sequence* reject_bang() { + if ( !rb_block_given_p() ) + rb_raise( rb_eArgError, "no block given" ); + + Sequence::iterator i = self->begin(); + Sequence::iterator e = self->end(); + for ( ; i != e; ) + { + VALUE r = swig::from< Sequence::value_type >(*i); + if ( RTEST( rb_yield(r) ) ) + $self->erase(i++); + else + ++i; + } + + return self; + } + + VALUE delete_at(difference_type i) { + VALUE r = Qnil; + try { + Sequence::iterator at = swig::getpos(self, i); + r = swig::from< Sequence::value_type >( *(at) ); + $self->erase(at); + } + catch (std::out_of_range) + { + } + return r; + } + + + VALUE __delete2__(const value_type& i) { + VALUE r = Qnil; + return r; + } + + } +%enddef + + +/** + * Macro used to add functions for back insertion of values in + * STL Sequence containers + * + */ +%define %swig_sequence_back_inserters( Sequence... ) + %extend { + + VALUE pop() { + if ($self->empty()) return Qnil; + Sequence::value_type x = self->back(); + $self->pop_back(); + return swig::from< Sequence::value_type >( x ); + } + + %alias push "<<"; + const value_type push( const value_type& e ) { + $self->push_back( e ); + return e; + } + + %newobject reject; + Sequence* reject() { + if ( !rb_block_given_p() ) + rb_raise( rb_eArgError, "no block given" ); + + Sequence* r = new Sequence; + std::remove_copy_if( $self->begin(), $self->end(), + std::back_inserter(*r), + swig::yield< Sequence::value_type >() ); + return r; + } + + } +%enddef + + +/** + * Macro used to add functions for Sequences + * + */ +%define %swig_sequence_methods(Sequence...) + %swig_sequence_methods_common(%arg(Sequence)); + %swig_sequence_back_inserters(%arg(Sequence)); + + %extend { + + VALUE at(difference_type i) const { + VALUE r = Qnil; + try { + r = swig::from< Sequence::value_type >( *(swig::cgetpos(self, i)) ); + } + catch( std::out_of_range ) + { + } + return r; + } + + VALUE __getitem__(difference_type i, difference_type j) const { + if ( j <= 0 ) return Qnil; + std::size_t len = $self->size(); + if ( i < 0 ) i = len - i; + j += i; if ( static_cast<std::size_t>(j) >= len ) j = len-1; + + VALUE r = Qnil; + try { + r = swig::from< const Sequence* >( swig::getslice(self, i, j) ); + } + catch( std::out_of_range ) + { + } + return r; + } + + VALUE __getitem__(difference_type i) const { + VALUE r = Qnil; + try { + r = swig::from< Sequence::value_type >( *(swig::cgetpos(self, i)) ); + } + catch( std::out_of_range ) + { + } + return r; + } + + VALUE __getitem__(VALUE i) const { + if ( rb_obj_is_kind_of( i, rb_cRange ) == Qfalse ) + { + rb_raise( rb_eTypeError, "not a valid index or range" ); + } + + VALUE r = Qnil; + static ID id_end = rb_intern("end"); + static ID id_start = rb_intern("begin"); + static ID id_noend = rb_intern("exclude_end?"); + + VALUE start = rb_funcall( i, id_start, 0 ); + VALUE end = rb_funcall( i, id_end, 0 ); + bool noend = ( rb_funcall( i, id_noend, 0 ) == Qtrue ); + + int len = $self->size(); + + int s = NUM2INT( start ); + if ( s < 0 ) s = len + s; + else if ( s >= len ) return Qnil; + + int e = NUM2INT( end ); + if ( e < 0 ) e = len + e; + + if ( e < s ) return Qnil; //std::swap( s, e ); + + if ( noend ) e -= 1; + if ( e >= len ) e = len - 1; + + return swig::from< Sequence* >( swig::getslice(self, s, e+1) ); + } + + VALUE __setitem__(difference_type i, const value_type& x) + { + std::size_t len = $self->size(); + if ( i < 0 ) i = len - i; + else if ( static_cast<std::size_t>(i) >= len ) + $self->resize( i+1, x ); + else + *(swig::getpos(self,i)) = x; + + return swig::from< Sequence::value_type >( x ); + } + + VALUE __setitem__(difference_type i, difference_type j, const Sequence& v) + throw (std::invalid_argument) { + + if ( j <= 0 ) return Qnil; + std::size_t len = $self->size(); + if ( i < 0 ) i = len - i; + j += i; + if ( static_cast<std::size_t>(j) >= len ) { + $self->resize( j+1, *(v.begin()) ); + j = len-1; + } + + VALUE r = Qnil; + swig::setslice(self, i, j, v); + r = swig::from< const Sequence* >( &v ); + return r; + } + + } +%enddef + +// ..I don't think %swig_sequence_methods_val are really used at all anymore... +%define %swig_sequence_methods_val(Sequence...) + %swig_sequence_methods_common(%arg(Sequence)) + %extend { + + VALUE __getitem__(difference_type i) { + VALUE r = Qnil; + try { + r = swig::from< Sequence::value_type >( *(swig::cgetpos(self, i)) ); + } + catch( std::out_of_range ) + { + } + return r; + } + + VALUE __setitem__(difference_type i, value_type x) { + std::size_t len = $self->size(); + if ( i < 0 ) i = len - i; + else if ( static_cast<std::size_t>(i) >= len ) + $self->resize( i+1, x ); + else *(swig::getpos(self,i)) = x; + return swig::from< Sequence::value_type >( x ); + } + } +%enddef + + +/** + * Macro used to add functions for front insertion of + * elements in STL sequence containers that support it. + * + */ +%define %swig_sequence_front_inserters( Sequence... ) + +%extend { + + VALUE shift() + { + if ($self->empty()) return Qnil; + Sequence::value_type x = self->front(); + $self->erase( $self->begin() ); + return swig::from< Sequence::value_type >( x ); + } + + %typemap(in) (int argc, VALUE* argv) { + $1 = argc - 1; + $2 = argv + 1; + } + + Sequence* insert( difference_type pos, int argc, VALUE* argv, ... ) + { + std::size_t len = $self->size(); + std::size_t i = swig::check_index( pos, len, true ); + Sequence::iterator start; + + VALUE elem = argv[0]; + int idx = 0; + try { + Sequence::value_type val = swig::as<Sequence::value_type>( elem, true ); + if ( i >= len ) { + $self->resize(i-1, val); + return $self; + } + start = $self->begin(); + std::advance( start, i ); + $self->insert( start++, val ); + + for ( ++idx; idx < argc; ++idx ) + { + elem = argv[idx]; + val = swig::as<Sequence::value_type>( elem ); + $self->insert( start++, val ); + } + + } + catch( std::invalid_argument ) + { + rb_raise( rb_eArgError, + Ruby_Format_TypeError( "", + swig::type_name<Sequence::value_type>(), + __FUNCTION__, idx+2, elem )); + } + + + return $self; + } + + %typemap(in) (int argc, VALUE* argv) { + $1 = argc; + $2 = argv; + } + + Sequence* unshift( int argc, VALUE* argv, ... ) + { + for ( int idx = argc-1; idx >= 0; --idx ) + { + Sequence::iterator start = $self->begin(); + VALUE elem = argv[idx]; + try { + Sequence::value_type val = swig::as<Sequence::value_type>( elem, true ); + $self->insert( start, val ); + } + catch( std::invalid_argument ) + { + rb_raise( rb_eArgError, + Ruby_Format_TypeError( "", + swig::type_name<Sequence::value_type>(), + __FUNCTION__, idx+2, elem )); + } + } + + return $self; + } + +} +%enddef + + +// +// Common fragments +// + +%fragment("StdSequenceTraits","header", + fragment="StdTraits", + fragment="RubySequence_Cont") +{ +namespace swig { + template <class RubySeq, class Seq> + inline void + assign(const RubySeq& rubyseq, Seq* seq) { +%#ifdef SWIG_STD_NOASSIGN_STL + typedef typename RubySeq::value_type value_type; + typename RubySeq::const_iterator it = rubyseq.begin(); + for (;it != rubyseq.end(); ++it) { + seq->insert(seq->end(),(value_type)(*it)); + } +%#else + seq->assign(rubyseq.begin(), rubyseq.end()); +%#endif + } + + template <class Seq, class T = typename Seq::value_type > + struct traits_asptr_stdseq { + typedef Seq sequence; + typedef T value_type; + + static int asptr(VALUE obj, sequence **seq) { + if (rb_obj_is_kind_of(obj, rb_cArray) == Qtrue) { + try { + RubySequence_Cont<value_type> rubyseq(obj); + if (seq) { + sequence *pseq = new sequence(); + assign(rubyseq, pseq); + *seq = pseq; + return SWIG_NEWOBJ; + } else { + return rubyseq.check() ? SWIG_OK : SWIG_ERROR; + } + } catch (std::exception& e) { + if (seq) { + VALUE lastErr = rb_gv_get("$!"); + if (lastErr == Qnil) { + rb_raise(rb_eTypeError, e.what()); + } + } + return SWIG_ERROR; + } + } else { + sequence *p; + if (SWIG_ConvertPtr(obj,(void**)&p, + swig::type_info<sequence>(),0) == SWIG_OK) { + if (seq) *seq = p; + return SWIG_OLDOBJ; + } + } + return SWIG_ERROR; + } + }; + + // Partial specialization for GC_VALUE's. No need to typecheck each + // element. + template< class Seq > + struct traits_asptr_stdseq< Seq, swig::GC_VALUE > { + typedef Seq sequence; + typedef swig::GC_VALUE value_type; + + static int asptr(VALUE obj, sequence **seq) { + if (rb_obj_is_kind_of(obj, rb_cArray) == Qtrue) { + try { + if (seq) { + RubySequence_Cont<value_type> rubyseq(obj); + sequence *pseq = new sequence(); + assign(rubyseq, pseq); + *seq = pseq; + return SWIG_NEWOBJ; + } else { + return true; + } + } catch (std::exception& e) { + if (seq) { + VALUE lastErr = rb_gv_get("$!"); + if (lastErr == Qnil) { + rb_raise(rb_eTypeError, e.what()); + } + } + return SWIG_ERROR; + } + } else { + sequence *p; + if (SWIG_ConvertPtr(obj,(void**)&p, + swig::type_info<sequence>(),0) == SWIG_OK) { + if (seq) *seq = p; + return SWIG_OLDOBJ; + } + } + return SWIG_ERROR; + } + }; + + template <class Seq, class T = typename Seq::value_type > + struct traits_from_stdseq { + typedef Seq sequence; + typedef T value_type; + typedef typename Seq::size_type size_type; + typedef typename sequence::const_iterator const_iterator; + + static VALUE from(const sequence& seq) { +#ifdef SWIG_RUBY_EXTRA_NATIVE_CONTAINERS + swig_type_info *desc = swig::type_info<sequence>(); + if (desc && desc->clientdata) { + return SWIG_NewPointerObj(new sequence(seq), desc, SWIG_POINTER_OWN); + } +#endif + size_type size = seq.size(); + if (size <= (size_type)INT_MAX) { + VALUE obj = rb_ary_new2((int)size); + int i = 0; + for (const_iterator it = seq.begin(); + it != seq.end(); ++it, ++i) { + RARRAY_PTR(obj)[i] = swig::from< value_type >(*it); + } + RARRAY_LEN(obj) = size; + rb_obj_freeze(obj); // treat as immutable result + return obj; + } else { + rb_raise(rb_eRangeError,"sequence size not valid in ruby"); + return Qnil; + } + } + }; +} +} + + +%include <rubycontainer_extended.swg> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubycontainer_extended.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubycontainer_extended.swg new file mode 100644 index 0000000..360e399 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubycontainer_extended.swg @@ -0,0 +1,139 @@ +/** + * @file rubycontainer_extended.swg + * @author gga + * @date Sat May 5 05:36:01 2007 + * + * @brief This file contains additional functions that make containers + * behave closer to ruby primitive types. + * However, some of these functions place some restrictions on + * the underlying object inside of the container and the iterator + * (that it has to have an == comparison function, that it has to have + * an = assignment operator, etc). + * + */ + + +/** + * Macro used to add extend functions that require operator== in object. + * + * @param Container STL container + * @param Type class inside container + * + */ +%define %swig_container_with_equal_operator( Container, Type ) + + VALUE __delete__( const Type& val ) { + VALUE r = Qnil; + Container<Type >::iterator e = $self->end(); + Container<Type >::iterator i = std::remove( $self->begin(), e, val ); + // remove dangling elements now + $self->erase( i, e ); + + if ( i != e ) + r = swig::from< Type >( val ); + else if ( rb_block_given_p() ) + r = rb_yield(Qnil); + return r; + } + +%enddef // end of %swig_container_with_equal_operator + + + + +/** + * Macro used to add extend functions that require the assignment + * operator (ie. = ) of contained class + * + * @param Container STL container + * @param Type class inside container + * + */ + +%define %swig_container_with_assignment( Container, Type ) + + + // + // map! -- the equivalent of std::transform + // + Container< Type >* map_bang() { + + if ( !rb_block_given_p() ) + rb_raise( rb_eArgError, "No block given" ); + + VALUE r = Qnil; + Container< Type >::iterator i = $self->begin(); + Container< Type >::iterator e = $self->end(); + + try { + for ( ; i != e; ++i ) + { + r = swig::from< Type >( *i ); + r = rb_yield( r ); + *i = swig::as< Type >( r ); + } + } + catch ( const std::invalid_argument& ) + { + rb_raise(rb_eTypeError, + "Yield block did not return a valid element for " #Container); + } + + return $self; + } + + +%enddef // end of %swig_container_with_assignment + + + + + +/** + * Macro used to add all extended functions to a container + * + * @param Container STL container + * @param Type class inside container + * + */ +%define %swig_container_extend( Container, Type ) + +%extend Container< Type > { + + %swig_container_with_assignment( %arg(Container), Type ); + %swig_container_with_equal_operator( %arg(Container), Type ); + +} + +%enddef + + +/** + * Private macro used to add all extended functions to C/C++ + * primitive types + * + * @param Container an STL container, like std::vector (with no class template) + * + */ +%define %__swig_container_extend_primtypes( Container ) + +%swig_container_extend( %arg( Container ), bool ); +%swig_container_extend( %arg( Container ), char ); +%swig_container_extend( %arg( Container ), short ); +%swig_container_extend( %arg( Container ), int ); +%swig_container_extend( %arg( Container ), unsigned short ); +%swig_container_extend( %arg( Container ), unsigned int ); +%swig_container_extend( %arg( Container ), float ); +%swig_container_extend( %arg( Container ), double ); +%swig_container_extend( %arg( Container ), std::complex ); +%swig_container_extend( %arg( Container ), std::string ); +%swig_container_extend( %arg( Container ), swig::GC_VALUE ); +%swig_container_extend( %arg( Container ), swig::GC_VALUE ); + +%enddef + + +%__swig_container_extend_primtypes( std::vector ); +%__swig_container_extend_primtypes( std::deque ); +%__swig_container_extend_primtypes( std::list ); + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubydef.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubydef.swg new file mode 100644 index 0000000..956aaee --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubydef.swg @@ -0,0 +1 @@ +/* empty file added for backward comp. */ diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubyerrors.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubyerrors.swg new file mode 100644 index 0000000..e256498 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubyerrors.swg @@ -0,0 +1,154 @@ +/* ----------------------------------------------------------------------------- + * error manipulation + * ----------------------------------------------------------------------------- */ + + +/* Define some additional error types */ +#define SWIG_ObjectPreviouslyDeletedError -100 + + +/* Define custom exceptions for errors that do not map to existing Ruby + exceptions. Note this only works for C++ since a global cannot be + initialized by a funtion in C. For C, fallback to rb_eRuntimeError.*/ + +SWIGINTERN VALUE +getNullReferenceError(void) { + static int init = 0; + static VALUE rb_eNullReferenceError ; + if (!init) { + init = 1; + rb_eNullReferenceError = rb_define_class("NullReferenceError", rb_eRuntimeError); + } + return rb_eNullReferenceError; +} + +SWIGINTERN VALUE +getObjectPreviouslyDeletedError(void) { + static int init = 0; + static VALUE rb_eObjectPreviouslyDeleted ; + if (!init) { + init = 1; + rb_eObjectPreviouslyDeleted = rb_define_class("ObjectPreviouslyDeleted", rb_eRuntimeError); + } + return rb_eObjectPreviouslyDeleted; +} + + +SWIGINTERN VALUE +SWIG_Ruby_ErrorType(int SWIG_code) { + VALUE type; + switch (SWIG_code) { + case SWIG_MemoryError: + type = rb_eNoMemError; + break; + case SWIG_IOError: + type = rb_eIOError; + break; + case SWIG_RuntimeError: + type = rb_eRuntimeError; + break; + case SWIG_IndexError: + type = rb_eIndexError; + break; + case SWIG_TypeError: + type = rb_eTypeError; + break; + case SWIG_DivisionByZero: + type = rb_eZeroDivError; + break; + case SWIG_OverflowError: + type = rb_eRangeError; + break; + case SWIG_SyntaxError: + type = rb_eSyntaxError; + break; + case SWIG_ValueError: + type = rb_eArgError; + break; + case SWIG_SystemError: + type = rb_eFatal; + break; + case SWIG_AttributeError: + type = rb_eRuntimeError; + break; + case SWIG_NullReferenceError: + type = getNullReferenceError(); + break; + case SWIG_ObjectPreviouslyDeletedError: + type = getObjectPreviouslyDeletedError(); + break; + case SWIG_UnknownError: + type = rb_eRuntimeError; + break; + default: + type = rb_eRuntimeError; + } + return type; +} + + +/* This function is called when a user inputs a wrong argument to + a method. + */ +SWIGINTERN +const char* Ruby_Format_TypeError( const char* msg, + const char* type, + const char* name, + const int argn, + VALUE input ) +{ + char buf[128]; + VALUE str; + VALUE asStr; + if ( msg && *msg ) + { + str = rb_str_new2(msg); + } + else + { + str = rb_str_new(NULL, 0); + } + + str = rb_str_cat2( str, "Expected argument " ); + sprintf( buf, "%d of type ", argn-1 ); + str = rb_str_cat2( str, buf ); + str = rb_str_cat2( str, type ); + str = rb_str_cat2( str, ", but got " ); + str = rb_str_cat2( str, rb_obj_classname(input) ); + str = rb_str_cat2( str, " " ); + asStr = rb_inspect(input); + if ( RSTRING_LEN(asStr) > 30 ) + { + str = rb_str_cat( str, StringValuePtr(asStr), 30 ); + str = rb_str_cat2( str, "..." ); + } + else + { + str = rb_str_append( str, asStr ); + } + + if ( name ) + { + str = rb_str_cat2( str, "\n\tin SWIG method '" ); + str = rb_str_cat2( str, name ); + str = rb_str_cat2( str, "'" ); + } + + return StringValuePtr( str ); +} + +/* This function is called when an overloaded method fails */ +SWIGINTERN +void Ruby_Format_OverloadedError( + const int argc, + const int maxargs, + const char* method, + const char* prototypes + ) +{ + const char* msg = "Wrong # of arguments"; + if ( argc <= maxargs ) msg = "Wrong arguments"; + rb_raise(rb_eArgError,"%s for overloaded method '%s'.\n" + "Possible C/C++ prototypes are:\n%s", + msg, method, prototypes); +} diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubyfragments.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubyfragments.swg new file mode 100644 index 0000000..3c3b658 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubyfragments.swg @@ -0,0 +1,23 @@ +/* + + Create a file with this name, 'rubyfragments.swg', in your working + directory and add all the %fragments you want to take precedence + over the ones defined by default by swig. + + For example, if you add: + + %fragment(SWIG_AsVal_frag(int),"header") { + SWIGINTERNINLINE int + SWIG_AsVal(int)(VALUE obj, int *val) + { + <your code here>; + } + } + + this will replace the code used to retrieve an integer value for all + the typemaps that need it, including: + + int, std::vector<int>, std::list<std::pair<int,int> >, etc. + + +*/ diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubyhead.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubyhead.swg new file mode 100644 index 0000000..8e6e2e7 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubyhead.swg @@ -0,0 +1,139 @@ +#include <ruby.h> + +/* Remove global macros defined in Ruby's win32.h */ +#ifdef write +# undef write +#endif +#ifdef read +# undef read +#endif + + +/* Ruby 1.7 defines NUM2LL(), LL2NUM() and ULL2NUM() macros */ +#ifndef NUM2LL +#define NUM2LL(x) NUM2LONG((x)) +#endif +#ifndef LL2NUM +#define LL2NUM(x) INT2NUM((long) (x)) +#endif +#ifndef ULL2NUM +#define ULL2NUM(x) UINT2NUM((unsigned long) (x)) +#endif + +/* Ruby 1.7 doesn't (yet) define NUM2ULL() */ +#ifndef NUM2ULL +#ifdef HAVE_LONG_LONG +#define NUM2ULL(x) rb_num2ull((x)) +#else +#define NUM2ULL(x) NUM2ULONG(x) +#endif +#endif + +/* RSTRING_LEN, etc are new in Ruby 1.9, but ->ptr and ->len no longer work */ +/* Define these for older versions so we can just write code the new way */ +#ifndef RSTRING_LEN +# define RSTRING_LEN(x) RSTRING(x)->len +#endif +#ifndef RSTRING_PTR +# define RSTRING_PTR(x) RSTRING(x)->ptr +#endif +#ifndef RSTRING_END +# define RSTRING_END(x) (RSTRING_PTR(x) + RSTRING_LEN(x)) +#endif +#ifndef RARRAY_LEN +# define RARRAY_LEN(x) RARRAY(x)->len +#endif +#ifndef RARRAY_PTR +# define RARRAY_PTR(x) RARRAY(x)->ptr +#endif +#ifndef RFLOAT_VALUE +# define RFLOAT_VALUE(x) RFLOAT(x)->value +#endif +#ifndef DOUBLE2NUM +# define DOUBLE2NUM(x) rb_float_new(x) +#endif +#ifndef RHASH_TBL +# define RHASH_TBL(x) (RHASH(x)->tbl) +#endif +#ifndef RHASH_ITER_LEV +# define RHASH_ITER_LEV(x) (RHASH(x)->iter_lev) +#endif +#ifndef RHASH_IFNONE +# define RHASH_IFNONE(x) (RHASH(x)->ifnone) +#endif +#ifndef RHASH_SIZE +# define RHASH_SIZE(x) (RHASH(x)->tbl->num_entries) +#endif +#ifndef RHASH_EMPTY_P +# define RHASH_EMPTY_P(x) (RHASH_SIZE(x) == 0) +#endif +#ifndef RSTRUCT_LEN +# define RSTRUCT_LEN(x) RSTRUCT(x)->len +#endif +#ifndef RSTRUCT_PTR +# define RSTRUCT_PTR(x) RSTRUCT(x)->ptr +#endif + + + +/* + * Need to be very careful about how these macros are defined, especially + * when compiling C++ code or C code with an ANSI C compiler. + * + * VALUEFUNC(f) is a macro used to typecast a C function that implements + * a Ruby method so that it can be passed as an argument to API functions + * like rb_define_method() and rb_define_singleton_method(). + * + * VOIDFUNC(f) is a macro used to typecast a C function that implements + * either the "mark" or "free" stuff for a Ruby Data object, so that it + * can be passed as an argument to API functions like Data_Wrap_Struct() + * and Data_Make_Struct(). + */ + +#ifdef __cplusplus +# ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */ +# define PROTECTFUNC(f) ((VALUE (*)()) f) +# define VALUEFUNC(f) ((VALUE (*)()) f) +# define VOIDFUNC(f) ((void (*)()) f) +# else +# ifndef ANYARGS /* These definitions should work for Ruby 1.6 */ +# define PROTECTFUNC(f) ((VALUE (*)()) f) +# define VALUEFUNC(f) ((VALUE (*)()) f) +# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) +# else /* These definitions should work for Ruby 1.7+ */ +# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) +# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) +# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) +# endif +# endif +#else +# define VALUEFUNC(f) (f) +# define VOIDFUNC(f) (f) +#endif + +/* Don't use for expressions have side effect */ +#ifndef RB_STRING_VALUE +#define RB_STRING_VALUE(s) (TYPE(s) == T_STRING ? (s) : (*(volatile VALUE *)&(s) = rb_str_to_str(s))) +#endif +#ifndef StringValue +#define StringValue(s) RB_STRING_VALUE(s) +#endif +#ifndef StringValuePtr +#define StringValuePtr(s) RSTRING_PTR(RB_STRING_VALUE(s)) +#endif +#ifndef StringValueLen +#define StringValueLen(s) RSTRING_LEN(RB_STRING_VALUE(s)) +#endif +#ifndef SafeStringValue +#define SafeStringValue(v) do {\ + StringValue(v);\ + rb_check_safe_str(v);\ +} while (0) +#endif + +#ifndef HAVE_RB_DEFINE_ALLOC_FUNC +#define rb_define_alloc_func(klass, func) rb_define_singleton_method((klass), "new", VALUEFUNC((func)), -1) +#define rb_undef_alloc_func(klass) rb_undef_method(CLASS_OF((klass)), "new") +#endif + +static VALUE _mSWIG = Qnil; diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubyinit.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubyinit.swg new file mode 100644 index 0000000..fc6e039 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubyinit.swg @@ -0,0 +1 @@ +%insert(initbeforefunc) "swiginit.swg" diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubyiterators.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubyiterators.swg new file mode 100644 index 0000000..466ae22 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubyiterators.swg @@ -0,0 +1,935 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * rubyiterators.swg + * + * Implement a C++ 'output' iterator for Ruby. + * + * Users can derive form the Iterator to implemet their + * own iterators. As an example (real one since we use it for STL/STD + * containers), the template Iterator_T does the + * implementation for generic C++ iterators. + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + + +%fragment("ConstIterator","header") { +namespace swig { + struct stop_iteration { + }; + + /** + * Abstract base class used to represent all iterators of STL containers. + */ + struct ConstIterator { + public: + typedef ConstIterator self_type; + + protected: + GC_VALUE _seq; + + protected: + ConstIterator(VALUE seq) : _seq(seq) + { + } + + // Random access iterator methods, but not required in Ruby + virtual ptrdiff_t distance(const ConstIterator &x) const + { + throw std::invalid_argument("distance not supported"); + } + + virtual bool equal (const ConstIterator &x) const + { + throw std::invalid_argument("equal not supported"); + } + + virtual self_type* advance(ptrdiff_t n) + { + throw std::invalid_argument("advance not supported"); + } + + public: + virtual ~ConstIterator() {} + + // Access iterator method, required by Ruby + virtual VALUE value() const { + throw std::invalid_argument("value not supported"); + return Qnil; + }; + + virtual VALUE setValue( const VALUE& v ) { + throw std::invalid_argument("value= not supported"); + return Qnil; + } + + virtual self_type* next( size_t n = 1 ) + { + return this->advance( n ); + } + + virtual self_type* previous( size_t n = 1 ) + { + ptrdiff_t nn = n; + return this->advance( -nn ); + } + + virtual VALUE to_s() const { + throw std::invalid_argument("to_s not supported"); + return Qnil; + } + + virtual VALUE inspect() const { + throw std::invalid_argument("inspect not supported"); + return Qnil; + } + + virtual ConstIterator *dup() const + { + throw std::invalid_argument("dup not supported"); + return NULL; + } + + // + // C++ common/needed methods. We emulate a bidirectional + // operator, to be compatible with all the STL. + // The iterator traits will then tell the STL what type of + // iterator we really are. + // + ConstIterator() : _seq( Qnil ) + { + } + + ConstIterator( const self_type& b ) : _seq( b._seq ) + { + } + + self_type& operator=( const self_type& b ) + { + _seq = b._seq; + return *this; + } + + bool operator == (const ConstIterator& x) const + { + return equal(x); + } + + bool operator != (const ConstIterator& x) const + { + return ! operator==(x); + } + + // Pre-decrement operator + self_type& operator--() + { + return *previous(); + } + + // Pre-increment operator + self_type& operator++() + { + return *next(); + } + + // Post-decrement operator + self_type operator--(int) + { + self_type r = *this; + previous(); + return r; + } + + // Post-increment operator + self_type operator++(int) + { + self_type r = *this; + next(); + return r; + } + + ConstIterator& operator += (ptrdiff_t n) + { + return *advance(n); + } + + ConstIterator& operator -= (ptrdiff_t n) + { + return *advance(-n); + } + + ConstIterator* operator + (ptrdiff_t n) const + { + return dup()->advance(n); + } + + ConstIterator* operator - (ptrdiff_t n) const + { + return dup()->advance(-n); + } + + ptrdiff_t operator - (const ConstIterator& x) const + { + return x.distance(*this); + } + + static swig_type_info* descriptor() { + static int init = 0; + static swig_type_info* desc = 0; + if (!init) { + desc = SWIG_TypeQuery("swig::ConstIterator *"); + init = 1; + } + return desc; + } + }; + + + /** + * Abstract base class used to represent all non-const iterators of STL containers. + * + */ + struct Iterator : public ConstIterator { + public: + typedef Iterator self_type; + + protected: + Iterator(VALUE seq) : ConstIterator(seq) + { + } + + virtual self_type* advance(ptrdiff_t n) + { + throw std::invalid_argument("operation not supported"); + } + + public: + static swig_type_info* descriptor() { + static int init = 0; + static swig_type_info* desc = 0; + if (!init) { + desc = SWIG_TypeQuery("swig::Iterator *"); + init = 1; + } + return desc; + } + + virtual Iterator *dup() const + { + throw std::invalid_argument("dup not supported"); + return NULL; + } + + virtual self_type* next( size_t n = 1 ) + { + return this->advance( n ); + } + + virtual self_type* previous( size_t n = 1 ) + { + ptrdiff_t nn = n; + return this->advance( -nn ); + } + + bool operator == (const ConstIterator& x) const + { + return equal(x); + } + + bool operator != (const Iterator& x) const + { + return ! operator==(x); + } + + Iterator& operator += (ptrdiff_t n) + { + return *advance(n); + } + + Iterator& operator -= (ptrdiff_t n) + { + return *advance(-n); + } + + Iterator* operator + (ptrdiff_t n) const + { + return dup()->advance(n); + } + + Iterator* operator - (ptrdiff_t n) const + { + return dup()->advance(-n); + } + + ptrdiff_t operator - (const Iterator& x) const + { + return x.distance(*this); + } + }; + +} +} + + +%fragment("ConstIterator_T","header",fragment="ConstIterator",fragment="StdTraits",fragment="StdIteratorTraits") { +namespace swig { + + /** + * Templated base classes for all custom const_iterators. + * + */ + template<typename OutConstIterator> + class ConstIterator_T : public ConstIterator + { + public: + typedef OutConstIterator const_iter; + typedef typename std::iterator_traits<const_iter>::value_type value_type; + typedef ConstIterator_T<const_iter> self_type; + + protected: + + + virtual bool equal (const ConstIterator &iter) const + { + const self_type *iters = dynamic_cast<const self_type *>(&iter); + if (iters) { + return (current == iters->get_current()); + } else { + throw std::invalid_argument("bad iterator type"); + } + } + + virtual ptrdiff_t distance(const ConstIterator &iter) const + { + const self_type *iters = dynamic_cast<const self_type *>(&iter); + if (iters) { + return std::distance(current, iters->get_current()); + } else { + throw std::invalid_argument("bad iterator type"); + } + } + + virtual ConstIterator* advance(ptrdiff_t n) + { + std::advance( current, n ); + return this; + } + + public: + ConstIterator_T() : ConstIterator(Qnil) + { + } + + ConstIterator_T(const_iter curr, VALUE seq = Qnil) + : ConstIterator(seq), current(curr) + { + } + + const const_iter& get_current() const + { + return current; + } + + const value_type& operator*() const + { + return *current; + } + + virtual VALUE inspect() const + { + VALUE ret = rb_str_new2("#<"); + ret = rb_str_cat2( ret, rb_obj_classname(_seq) ); + ret = rb_str_cat2( ret, "::const_iterator " ); + VALUE cur = value(); + ret = rb_str_concat( ret, rb_inspect(cur) ); + ret = rb_str_cat2( ret, ">" ); + return ret; + } + + virtual VALUE to_s() const + { + VALUE ret = rb_str_new2( rb_obj_classname(_seq) ); + ret = rb_str_cat2( ret, "::const_iterator " ); + VALUE cur = value(); + ret = rb_str_concat( ret, rb_obj_as_string(cur) ); + return ret; + } + + protected: + const_iter current; + }; + + + /** + * Templated base classes for all custom non-const iterators. + * + */ + template<typename InOutIterator> + class Iterator_T : public Iterator + { + public: + typedef InOutIterator nonconst_iter; + + // Make this class iterator STL compatible, by using iterator_traits + typedef typename std::iterator_traits<nonconst_iter >::iterator_category iterator_category; + typedef typename std::iterator_traits<nonconst_iter >::value_type value_type; + typedef typename std::iterator_traits<nonconst_iter >::difference_type difference_type; + typedef typename std::iterator_traits<nonconst_iter >::pointer pointer; + typedef typename std::iterator_traits<nonconst_iter >::reference reference; + + typedef Iterator base; + typedef Iterator_T< nonconst_iter > self_type; + + protected: + + virtual bool equal (const ConstIterator &iter) const + { + const self_type *iters = dynamic_cast<const self_type *>(&iter); + if (iters) { + return (current == iters->get_current()); + } else { + throw std::invalid_argument("bad iterator type"); + } + } + + virtual ptrdiff_t distance(const ConstIterator &iter) const + { + const self_type *iters = dynamic_cast<const self_type *>(&iter); + if (iters) { + return std::distance(current, iters->get_current()); + } else { + throw std::invalid_argument("bad iterator type"); + } + } + + virtual Iterator* advance(ptrdiff_t n) + { + std::advance( current, n ); + return this; + } + + public: + + Iterator_T(nonconst_iter curr, VALUE seq = Qnil) + : Iterator(seq), current(curr) + { + } + + const nonconst_iter& get_current() const + { + return current; + } + + self_type& operator=( const self_type& b ) + { + base::operator=( b ); + return *this; + } + + self_type& operator=( const value_type& b ) + { + *current = b; + return *this; + } + + const value_type& operator*() const + { + return *current; + } + + value_type& operator*() + { + return *current; + } + + virtual VALUE inspect() const + { + VALUE ret = rb_str_new2("#<"); + ret = rb_str_cat2( ret, rb_obj_classname(_seq) ); + ret = rb_str_cat2( ret, "::iterator " ); + VALUE cur = value(); + ret = rb_str_concat( ret, rb_inspect(cur) ); + ret = rb_str_cat2( ret, ">" ); + return ret; + } + + virtual VALUE to_s() const + { + VALUE ret = rb_str_new2( rb_obj_classname(_seq) ); + ret = rb_str_cat2( ret, "::iterator " ); + VALUE cur = value(); + ret = rb_str_concat( ret, rb_obj_as_string(cur) ); + return ret; + } + + protected: + nonconst_iter current; + }; + + + /** + * Auxiliary functor to store the value of a ruby object inside + * a reference of a compatible C++ type. ie: Ruby -> C++ + * + */ + template <class ValueType> + struct asval_oper + { + typedef ValueType value_type; + typedef bool result_type; + bool operator()(VALUE obj, value_type& v) const + { + return ( swig::asval< value_type >(obj, &v) == SWIG_OK ); + } + }; + + /** + * Auxiliary functor to return a ruby object from a C++ type. + * ie: C++ -> Ruby + * + */ + template <class ValueType> + struct from_oper + { + typedef const ValueType& argument_type; + typedef VALUE result_type; + result_type operator()(argument_type v) const + { + return swig::from(v); + } + }; + + + /** + * ConstIterator class for a const_iterator with no end() boundaries. + * + */ + template<typename OutConstIterator, + typename ValueType = typename std::iterator_traits<OutConstIterator>::value_type, + typename FromOper = from_oper<ValueType> > + class ConstIteratorOpen_T : public ConstIterator_T<OutConstIterator> + { + public: + FromOper from; + typedef OutConstIterator const_iter; + typedef ValueType value_type; + typedef ConstIterator_T<const_iter> base; + typedef ConstIteratorOpen_T<OutConstIterator, ValueType, FromOper> self_type; + + ConstIteratorOpen_T(const_iter curr, VALUE seq = Qnil) + : ConstIterator_T<OutConstIterator>(curr, seq) + { + } + + virtual VALUE value() const { + return from(static_cast<const value_type&>(*(base::current))); + } + + ConstIterator *dup() const + { + return new self_type(*this); + } + }; + + /** + * Iterator class for an iterator with no end() boundaries. + * + */ + template<typename InOutIterator, + typename ValueType = typename std::iterator_traits<InOutIterator>::value_type, + typename FromOper = from_oper<ValueType>, + typename AsvalOper = asval_oper<ValueType> > + class IteratorOpen_T : public Iterator_T<InOutIterator> + { + public: + FromOper from; + AsvalOper asval; + typedef InOutIterator nonconst_iter; + typedef ValueType value_type; + typedef Iterator_T<nonconst_iter> base; + typedef IteratorOpen_T<InOutIterator, ValueType, FromOper, AsvalOper> self_type; + + public: + IteratorOpen_T(nonconst_iter curr, VALUE seq = Qnil) + : Iterator_T<InOutIterator>(curr, seq) + { + } + + virtual VALUE value() const { + return from(static_cast<const value_type&>(*(base::current))); + } + + virtual VALUE setValue( const VALUE& v ) + { + value_type& dst = *base::current; + if ( asval(v, dst) ) return v; + return Qnil; + } + + Iterator *dup() const + { + return new self_type(*this); + } + }; + + /** + * ConstIterator class for a const_iterator where begin() and end() boundaries are known. + * + */ + template<typename OutConstIterator, + typename ValueType = typename std::iterator_traits<OutConstIterator>::value_type, + typename FromOper = from_oper<ValueType> > + class ConstIteratorClosed_T : public ConstIterator_T<OutConstIterator> + { + public: + FromOper from; + typedef OutConstIterator const_iter; + typedef ValueType value_type; + typedef ConstIterator_T<const_iter> base; + typedef ConstIteratorClosed_T<OutConstIterator, ValueType, FromOper> self_type; + + protected: + virtual ConstIterator* advance(ptrdiff_t n) + { + std::advance( base::current, n ); + if ( base::current == end ) + throw stop_iteration(); + return this; + } + + public: + ConstIteratorClosed_T(const_iter curr, const_iter first, + const_iter last, VALUE seq = Qnil) + : ConstIterator_T<OutConstIterator>(curr, seq), begin(first), end(last) + { + } + + virtual VALUE value() const { + if (base::current == end) { + throw stop_iteration(); + } else { + return from(static_cast<const value_type&>(*(base::current))); + } + } + + ConstIterator *dup() const + { + return new self_type(*this); + } + + + private: + const_iter begin; + const_iter end; + }; + + /** + * Iterator class for a iterator where begin() and end() boundaries are known. + * + */ + template<typename InOutIterator, + typename ValueType = typename std::iterator_traits<InOutIterator>::value_type, + typename FromOper = from_oper<ValueType>, + typename AsvalOper = asval_oper<ValueType> > + class IteratorClosed_T : public Iterator_T<InOutIterator> + { + public: + FromOper from; + AsvalOper asval; + typedef InOutIterator nonconst_iter; + typedef ValueType value_type; + typedef Iterator_T<nonconst_iter> base; + typedef IteratorClosed_T<InOutIterator, ValueType, FromOper, AsvalOper> self_type; + + protected: + virtual Iterator* advance(ptrdiff_t n) + { + std::advance( base::current, n ); + if ( base::current == end ) + throw stop_iteration(); + return this; + } + + public: + IteratorClosed_T(nonconst_iter curr, nonconst_iter first, + nonconst_iter last, VALUE seq = Qnil) + : Iterator_T<InOutIterator>(curr, seq), begin(first), end(last) + { + } + + virtual VALUE value() const { + if (base::current == end) { + throw stop_iteration(); + } else { + return from(static_cast<const value_type&>(*(base::current))); + } + } + + // Iterator setter method, required by Ruby + virtual VALUE setValue( const VALUE& v ) + { + if (base::current == end) + throw stop_iteration(); + + value_type& dst = *base::current; + if ( asval( v, dst ) ) return v; + return Qnil; + } + + Iterator *dup() const + { + return new self_type(*this); + } + + private: + nonconst_iter begin; + nonconst_iter end; + }; + + /* Partial specialization for bools which don't allow de-referencing */ + template< typename InOutIterator, typename FromOper, typename AsvalOper > + class IteratorOpen_T< InOutIterator, bool, FromOper, AsvalOper > : + public Iterator_T<InOutIterator> + { + public: + FromOper from; + AsvalOper asval; + typedef InOutIterator nonconst_iter; + typedef bool value_type; + typedef Iterator_T<nonconst_iter> base; + typedef IteratorOpen_T<InOutIterator, bool, FromOper, AsvalOper> self_type; + + IteratorOpen_T(nonconst_iter curr, VALUE seq = Qnil) + : Iterator_T<InOutIterator>(curr, seq) + { + } + + virtual VALUE value() const { + return from(static_cast<const value_type&>(*(base::current))); + } + + virtual VALUE setValue( const VALUE& v ) + { + bool tmp = *base::current; + if ( asval( v, tmp ) ) + { + *base::current = tmp; + return v; + } + return Qnil; + } + + Iterator *dup() const + { + return new self_type(*this); + } + + }; + + /* Partial specialization for bools which don't allow de-referencing */ + template< typename InOutIterator, typename FromOper, typename AsvalOper > + class IteratorClosed_T< InOutIterator, bool, FromOper, AsvalOper > : + public Iterator_T<InOutIterator> + { + public: + FromOper from; + AsvalOper asval; + typedef InOutIterator nonconst_iter; + typedef bool value_type; + typedef Iterator_T<nonconst_iter> base; + typedef IteratorClosed_T<InOutIterator, bool, FromOper, AsvalOper> self_type; + + protected: + virtual Iterator* advance(ptrdiff_t n) + { + std::advance( base::current, n ); + if ( base::current == end ) + throw stop_iteration(); + return this; + } + + public: + IteratorClosed_T(nonconst_iter curr, nonconst_iter first, + nonconst_iter last, VALUE seq = Qnil) + : Iterator_T<InOutIterator>(curr, seq), begin(first), end(last) + { + } + + virtual VALUE value() const { + if (base::current == end) { + throw stop_iteration(); + } else { + return from(static_cast<const value_type&>(*(base::current))); + } + } + + virtual VALUE setValue( const VALUE& v ) + { + if (base::current == end) + throw stop_iteration(); + + bool tmp = *base::current; + if ( asval( v, tmp ) ) + { + *base::current = tmp; + return v; + } + return Qnil; + } + + Iterator *dup() const + { + return new self_type(*this); + } + + private: + nonconst_iter begin; + nonconst_iter end; + }; + + + /** + * Helper function used to wrap a bounded const_iterator. This is to be used in + * a %typemap(out), for example. + * + */ + template<typename InOutIter> + inline Iterator* + make_nonconst_iterator(const InOutIter& current, const InOutIter& begin, + const InOutIter& end, VALUE seq = Qnil) + { + return new IteratorClosed_T<InOutIter>(current, begin, end, seq); + } + + /** + * Helper function used to wrap an unbounded const_iterator. This is to be used in + * a %typemap(out), for example. + * + */ + template<typename InOutIter> + inline Iterator* + make_nonconst_iterator(const InOutIter& current, VALUE seq = Qnil) + { + return new IteratorOpen_T<InOutIter>(current, seq); + } + + /** + * Helper function used to wrap a bounded const_iterator. This is to be used in + * a %typemap(out), for example. + * + */ + template<typename OutIter> + inline ConstIterator* + make_const_iterator(const OutIter& current, const OutIter& begin, + const OutIter& end, VALUE seq = Qnil) + { + return new ConstIteratorClosed_T<OutIter>(current, begin, end, seq); + } + + /** + * Helper function used to wrap an unbounded const_iterator. This is to be used in + * a %typemap(out), for example. + * + */ + template<typename OutIter> + inline ConstIterator* + make_const_iterator(const OutIter& current, VALUE seq = Qnil) + { + return new ConstIteratorOpen_T<OutIter>(current, seq); + } +} +} + + +%fragment("ConstIterator"); + + +// +// This part is just so SWIG is aware of the base abstract iterator class. +// +namespace swig +{ + /* + Throw a StopIteration exception + */ + %ignore stop_iteration; + struct stop_iteration {}; + + %typemap(throws) stop_iteration { + (void)$1; + SWIG_Ruby_ExceptionType(NULL, Qnil); + SWIG_fail; + } + + /* + Mark methods that return new objects + */ + %newobject ConstIterator::dup; + %newobject ConstIterator::operator + (ptrdiff_t n) const; + %newobject ConstIterator::operator - (ptrdiff_t n) const; + + %nodirector ConstIterator; + + %catches(swig::stop_iteration) ConstIterator::value() const; + %catches(swig::stop_iteration) ConstIterator::incr(size_t n = 1); + %catches(swig::stop_iteration) ConstIterator::decr(size_t n = 1); + %catches(std::invalid_argument) ConstIterator::distance(const ConstIterator &x) const; + %catches(std::invalid_argument) ConstIterator::equal (const ConstIterator &x) const; + %catches(swig::stop_iteration) ConstIterator::next(); + %catches(swig::stop_iteration) ConstIterator::previous(); + %catches(swig::stop_iteration) ConstIterator::advance(ptrdiff_t n); + %catches(swig::stop_iteration) ConstIterator::operator += (ptrdiff_t n); + %catches(swig::stop_iteration) ConstIterator::operator -= (ptrdiff_t n); + %catches(swig::stop_iteration) ConstIterator::operator + (ptrdiff_t n) const; + %catches(swig::stop_iteration) ConstIterator::operator - (ptrdiff_t n) const; + + + struct ConstIterator + { + protected: + ConstIterator(VALUE seq); + + public: + virtual ~ConstIterator(); + + // Access iterator method, required by Ruby + virtual VALUE value() const; + + // C++ common/needed methods + virtual ConstIterator *dup() const; + + virtual VALUE inspect() const; + virtual VALUE to_s() const; + + virtual ConstIterator* next(size_t n = 1); + virtual ConstIterator* previous(size_t n = 1); + + bool operator == (const ConstIterator& x) const; + ConstIterator* operator + (ptrdiff_t n) const; + ConstIterator* operator - (ptrdiff_t n) const; + ptrdiff_t operator - (const ConstIterator& x) const; + }; + + struct Iterator : public ConstIterator + { + %rename("value=") setValue( const VALUE& v ); + virtual VALUE setValue( const VALUE& v ); + + virtual Iterator *dup() const; + + virtual Iterator* next(size_t n = 1); + virtual Iterator* previous(size_t n = 1); + + virtual VALUE inspect() const; + virtual VALUE to_s() const; + + bool operator == (const Iterator& x) const; + Iterator* operator + (ptrdiff_t n) const; + Iterator* operator - (ptrdiff_t n) const; + ptrdiff_t operator - (const Iterator& x) const; + }; + +} + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubykw.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubykw.swg new file mode 100644 index 0000000..fec47ba --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubykw.swg @@ -0,0 +1,72 @@ +#ifndef RUBY_RUBYKW_SWG_ +#define RUBY_RUBYKW_SWG_ + +/* Warnings for Ruby keywords */ +#define RUBYKW(x) %keywordwarn("'" `x` "' is a ruby keyword, and it will renamed as 'C_"`x`"'",rename="C_%s",fullname=1) `x` + +/* + + from http://www.rubycentral.com/book/language.html + +*/ + +RUBYKW(BEGIN); +RUBYKW(END); +RUBYKW(alias); +RUBYKW(and); +RUBYKW(begin); +RUBYKW(break); +RUBYKW(case); +RUBYKW(class); +RUBYKW(def); +RUBYKW("defined"); +RUBYKW(do); +RUBYKW(else); +RUBYKW(elsif); +RUBYKW(end); +RUBYKW(ensure); +RUBYKW(false); +RUBYKW(fatal); +RUBYKW(for); +RUBYKW(if); +RUBYKW(in); +RUBYKW(module); +RUBYKW(next); +RUBYKW(nil); +RUBYKW(not); +RUBYKW(or); +RUBYKW(redo); +RUBYKW(rescue); +RUBYKW(retry); +RUBYKW(return); +RUBYKW(self); +RUBYKW(super); +RUBYKW(then); +RUBYKW(true); +RUBYKW(undef); +RUBYKW(unless); +RUBYKW(until); +RUBYKW(when); +RUBYKW(while); +RUBYKW(yield); + +// RUBYKW(FalseClass); +// RUBYKW(TrueClass); +// RUBYKW(Numeric); +// RUBYKW(Integer); +// RUBYKW(Fixnum); +// RUBYKW(Float); +// RUBYKW(Range); +// RUBYKW(Array); +// RUBYKW(String); +// RUBYKW(IO); +// RUBYKW(File); +// RUBYKW(FileUtils); +// RUBYKW(Find); +// RUBYKW(Struct); +// RUBYKW(OpenStruct); +// RUBYKW(Regexp); + +#undef RUBYKW + +#endif //RUBY_RUBYKW_SWG_ diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubymacros.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubymacros.swg new file mode 100644 index 0000000..de2a52b --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubymacros.swg @@ -0,0 +1,13 @@ + +// Redefine these macros so argument index for ruby is done properly, +// ignoring self and we get some more info about the input. +#define %argfail_fmt(_type,_name,_argn) Ruby_Format_TypeError( "", _type, #_name, _argn, $input ) + +#define %argnullref_fmt(_type,_name,_argn) Ruby_Format_TypeError(%nullref_fmt(), _type, #_name, _argn, $input) + +%{ +#define SWIG_RUBY_THREAD_BEGIN_BLOCK +#define SWIG_RUBY_THREAD_END_BLOCK +%} + +%include <typemaps/swigmacros.swg> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubyopers.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubyopers.swg new file mode 100644 index 0000000..d1ac8bf --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubyopers.swg @@ -0,0 +1,55 @@ +/* ------------------------------------------------------------ + * Overloaded operator support + * ------------------------------------------------------------ */ + +#ifdef __cplusplus + +%rename(__add__) *::operator+; +%rename(__pos__) *::operator+(); +%rename(__pos__) *::operator+() const; +%rename(__sub__) *::operator-; +%rename(__neg__) *::operator-(); +%rename(__neg__) *::operator-() const; +%rename(__mul__) *::operator*; +%rename(__div__) *::operator/; +%rename(__mod__) *::operator%; +%rename(__lshift__) *::operator<<; +%rename(__rshift__) *::operator>>; +%rename(__and__) *::operator&; +%rename(__or__) *::operator|; +%rename(__xor__) *::operator^; +%rename(__invert__) *::operator~; +%rename(__lt__) *::operator<; +%rename(__le__) *::operator<=; +%rename(__gt__) *::operator>; +%rename(__ge__) *::operator>=; +%rename(__eq__) *::operator==; + +/* Special cases */ +%rename(__call__) *::operator(); + +/* Ignored inplace operators */ +%ignoreoperator(NOTEQUAL) operator!=; +%ignoreoperator(PLUSEQ) operator+=; +%ignoreoperator(MINUSEQ) operator-=; +%ignoreoperator(MULEQ) operator*=; +%ignoreoperator(DIVEQ) operator/=; +%ignoreoperator(MODEQ) operator%=; +%ignoreoperator(LSHIFTEQ) operator<<=; +%ignoreoperator(RSHIFTEQ) operator>>=; +%ignoreoperator(ANDEQ) operator&=; +%ignoreoperator(OREQ) operator|=; +%ignoreoperator(XOREQ) operator^=; + +/* Ignored operators */ +%ignoreoperator(LNOT) operator!; +%ignoreoperator(LAND) operator&&; +%ignoreoperator(LOR) operator||; +%ignoreoperator(EQ) operator=; +%ignoreoperator(PLUSPLUS) operator++; +%ignoreoperator(MINUSMINUS) operator--; +%ignoreoperator(ARROWSTAR) operator->*; +%ignoreoperator(INDEX) operator[]; + + +#endif /* __cplusplus */ diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubyprimtypes.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubyprimtypes.swg new file mode 100644 index 0000000..c2d5779 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubyprimtypes.swg @@ -0,0 +1,220 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * rubyprimtypes.swg + * + * ----------------------------------------------------------------------------- */ +/* ------------------------------------------------------------ + * Primitive Types + * ------------------------------------------------------------ */ + +/* auxiliary ruby fail method */ + +%fragment("SWIG_ruby_failed","header") +{ +SWIGINTERN VALUE +SWIG_ruby_failed(void) +{ + return Qnil; +} +} + +%define %ruby_aux_method(Type, Method, Action) +SWIGINTERN VALUE SWIG_AUX_##Method##(VALUE *args) +{ + VALUE obj = args[0]; + VALUE type = TYPE(obj); + Type *res = (Type *)(args[1]); + *res = Action; + return obj; +} +%enddef + + +/* boolean */ + +%fragment(SWIG_From_frag(bool),"header") { +SWIGINTERNINLINE VALUE +SWIG_From_dec(bool)(bool value) +{ + return value ? Qtrue : Qfalse; +} +} + +%fragment(SWIG_AsVal_frag(bool),"header", + fragment=SWIG_AsVal_frag(int)) { +SWIGINTERN int +SWIG_AsVal_dec(bool)(VALUE obj, bool *val) +{ + if (obj == Qtrue) { + if (val) *val = true; + return SWIG_OK; + } else if (obj == Qfalse) { + if (val) *val = false; + return SWIG_OK; + } else { + int res = 0; + if (SWIG_AsVal(int)(obj, &res) == SWIG_OK) { + if (val) *val = res ? true : false; + return SWIG_OK; + } + } + return SWIG_TypeError; +} +} + +/* long */ + +%fragment(SWIG_From_frag(long),"header", + fragment="<limits.h>") { + %define_as(SWIG_From_dec(long), LONG2NUM) +} + +%fragment(SWIG_AsVal_frag(long),"header",fragment="SWIG_ruby_failed") { +%ruby_aux_method(long, NUM2LONG, type == T_FIXNUM ? NUM2LONG(obj) : rb_big2long(obj)) + +SWIGINTERN int +SWIG_AsVal_dec(long)(VALUE obj, long* val) +{ + VALUE type = TYPE(obj); + if ((type == T_FIXNUM) || (type == T_BIGNUM)) { + long v; + VALUE a[2]; + a[0] = obj; + a[1] = (VALUE)(&v); + if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (val) *val = v; + return SWIG_OK; + } + } + return SWIG_TypeError; +} +} + +/* unsigned long */ + +%fragment(SWIG_From_frag(unsigned long),"header", + fragment=SWIG_From_frag(long)) { +SWIGINTERNINLINE VALUE +SWIG_From_dec(unsigned long)(unsigned long value) +{ + return ULONG2NUM(value); +} +} + +%fragment(SWIG_AsVal_frag(unsigned long),"header",fragment="SWIG_ruby_failed") { +%ruby_aux_method(unsigned long, NUM2ULONG, type == T_FIXNUM ? NUM2ULONG(obj) : rb_big2ulong(obj)) + +SWIGINTERN int +SWIG_AsVal_dec(unsigned long)(VALUE obj, unsigned long *val) +{ + VALUE type = TYPE(obj); + if ((type == T_FIXNUM) || (type == T_BIGNUM)) { + unsigned long v; + VALUE a[2]; + a[0] = obj; + a[1] = (VALUE)(&v); + if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (val) *val = v; + return SWIG_OK; + } + } + return SWIG_TypeError; +} +} + +/* long long */ + +%fragment(SWIG_From_frag(long long),"header", + fragment=SWIG_From_frag(long), + fragment="<limits.h>") { +SWIGINTERNINLINE VALUE +SWIG_From_dec(long long)(long long value) +{ + return LL2NUM(value); +} +} + +%fragment(SWIG_AsVal_frag(long long),"header",fragment="SWIG_ruby_failed") { +%ruby_aux_method(long long, NUM2LL, type == T_FIXNUM ? NUM2LL(obj) : rb_big2ll(obj)) + +SWIGINTERN int +SWIG_AsVal_dec(long long)(VALUE obj, long long *val) +{ + VALUE type = TYPE(obj); + if ((type == T_FIXNUM) || (type == T_BIGNUM)) { + long long v; + VALUE a[2]; + a[0] = obj; + a[1] = (VALUE)(&v); + if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (val) *val = v; + return SWIG_OK; + } + } + return SWIG_TypeError; +} +} + +/* unsigned long long */ + +%fragment(SWIG_From_frag(unsigned long long),"header", + fragment=SWIG_From_frag(long long), + fragment="<limits.h>") { +SWIGINTERNINLINE VALUE +SWIG_From_dec(unsigned long long)(unsigned long long value) +{ + return ULL2NUM(value); +} +} + +%fragment(SWIG_AsVal_frag(unsigned long long),"header",fragment="SWIG_ruby_failed") { +%ruby_aux_method(long long, NUM2ULL, type == T_FIXNUM ? NUM2ULL(obj) : rb_big2ull(obj)) + +SWIGINTERN int +SWIG_AsVal_dec(unsigned long long)(VALUE obj, unsigned long long *val) +{ + VALUE type = TYPE(obj); + if ((type == T_FIXNUM) || (type == T_BIGNUM)) { + unsigned long long v; + VALUE a[2]; + a[0] = obj; + a[1] = (VALUE)(&v); + if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2ULL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (val) *val = v; + return SWIG_OK; + } + } + return SWIG_TypeError; +} +} + +/* double */ + +%fragment(SWIG_From_frag(double),"header") { + %define_as(SWIG_From_dec(double), rb_float_new) +} + +%fragment(SWIG_AsVal_frag(double),"header",fragment="SWIG_ruby_failed") { +%ruby_aux_method(double, NUM2DBL, (type == T_FLOAT ? NUM2DBL(obj) : (type == T_FIXNUM ? (double) FIX2INT(obj) : rb_big2dbl(obj)))) + +SWIGINTERN int +SWIG_AsVal_dec(double)(VALUE obj, double *val) +{ + VALUE type = TYPE(obj); + if ((type == T_FLOAT) || (type == T_FIXNUM) || (type == T_BIGNUM)) { + double v; + VALUE a[2]; + a[0] = obj; + a[1] = (VALUE)(&v); + if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2DBL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (val) *val = v; + return SWIG_OK; + } + } + return SWIG_TypeError; +} +} + + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubyrun.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubyrun.swg new file mode 100644 index 0000000..24d861d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubyrun.swg @@ -0,0 +1,444 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * rubyrun.swg + * + * This file contains the runtime support for Ruby modules + * and includes code for managing global variables and pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +/* For backward compatibility only */ +#define SWIG_POINTER_EXCEPTION 0 + +/* for raw pointers */ +#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, 0) +#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own) +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags) +#define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own) +#define swig_owntype ruby_owntype + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags) +#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Ruby_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Ruby_SetModule(pointer) + + +/* Error manipulation */ + +#define SWIG_ErrorType(code) SWIG_Ruby_ErrorType(code) +#define SWIG_Error(code, msg) rb_raise(SWIG_Ruby_ErrorType(code), msg) +#define SWIG_fail goto fail + + +/* Ruby-specific SWIG API */ + +#define SWIG_InitRuntime() SWIG_Ruby_InitRuntime() +#define SWIG_define_class(ty) SWIG_Ruby_define_class(ty) +#define SWIG_NewClassInstance(value, ty) SWIG_Ruby_NewClassInstance(value, ty) +#define SWIG_MangleStr(value) SWIG_Ruby_MangleStr(value) +#define SWIG_CheckConvert(value, ty) SWIG_Ruby_CheckConvert(value, ty) + +#include "assert.h" + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + VALUE klass; + VALUE mImpl; + void (*mark)(void *); + void (*destroy)(void *); + int trackObjects; +} swig_class; + + +/* Global pointer used to keep some internal SWIG stuff */ +static VALUE _cSWIG_Pointer = Qnil; +static VALUE swig_runtime_data_type_pointer = Qnil; + +/* Global IDs used to keep some internal SWIG stuff */ +static ID swig_arity_id = 0; +static ID swig_call_id = 0; + +/* + If your swig extension is to be run within an embedded ruby and has + director callbacks, you should set -DRUBY_EMBEDDED during compilation. + This will reset ruby's stack frame on each entry point from the main + program the first time a virtual director function is invoked (in a + non-recursive way). + If this is not done, you run the risk of Ruby trashing the stack. +*/ + +#ifdef RUBY_EMBEDDED + +# define SWIG_INIT_STACK \ + if ( !swig_virtual_calls ) { RUBY_INIT_STACK } \ + ++swig_virtual_calls; +# define SWIG_RELEASE_STACK --swig_virtual_calls; +# define Ruby_DirectorTypeMismatchException(x) \ + rb_raise( rb_eTypeError, x ); return c_result; + + static unsigned int swig_virtual_calls = 0; + +#else /* normal non-embedded extension */ + +# define SWIG_INIT_STACK +# define SWIG_RELEASE_STACK +# define Ruby_DirectorTypeMismatchException(x) \ + throw Swig::DirectorTypeMismatchException( x ); + +#endif /* RUBY_EMBEDDED */ + + +SWIGRUNTIME VALUE +getExceptionClass(void) { + static int init = 0; + static VALUE rubyExceptionClass ; + if (!init) { + init = 1; + rubyExceptionClass = rb_const_get(_mSWIG, rb_intern("Exception")); + } + return rubyExceptionClass; +} + +/* This code checks to see if the Ruby object being raised as part + of an exception inherits from the Ruby class Exception. If so, + the object is simply returned. If not, then a new Ruby exception + object is created and that will be returned to Ruby.*/ +SWIGRUNTIME VALUE +SWIG_Ruby_ExceptionType(swig_type_info *desc, VALUE obj) { + VALUE exceptionClass = getExceptionClass(); + if (rb_obj_is_kind_of(obj, exceptionClass)) { + return obj; + } else { + return rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj)); + } +} + +/* Initialize Ruby runtime support */ +SWIGRUNTIME void +SWIG_Ruby_InitRuntime(void) +{ + if (_mSWIG == Qnil) { + _mSWIG = rb_define_module("SWIG"); + swig_call_id = rb_intern("call"); + swig_arity_id = rb_intern("arity"); + } +} + +/* Define Ruby class for C type */ +SWIGRUNTIME void +SWIG_Ruby_define_class(swig_type_info *type) +{ + VALUE klass; + char *klass_name = (char *) malloc(4 + strlen(type->name) + 1); + sprintf(klass_name, "TYPE%s", type->name); + if (NIL_P(_cSWIG_Pointer)) { + _cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject); + rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new"); + } + klass = rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer); + free((void *) klass_name); +} + +/* Create a new pointer object */ +SWIGRUNTIME VALUE +SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) +{ + int own = flags & SWIG_POINTER_OWN; + int track; + char *klass_name; + swig_class *sklass; + VALUE klass; + VALUE obj; + + if (!ptr) + return Qnil; + + if (type->clientdata) { + sklass = (swig_class *) type->clientdata; + + /* Are we tracking this class and have we already returned this Ruby object? */ + track = sklass->trackObjects; + if (track) { + obj = SWIG_RubyInstanceFor(ptr); + + /* Check the object's type and make sure it has the correct type. + It might not in cases where methods do things like + downcast methods. */ + if (obj != Qnil) { + VALUE value = rb_iv_get(obj, "@__swigtype__"); + char* type_name = RSTRING_PTR(value); + + if (strcmp(type->name, type_name) == 0) { + return obj; + } + } + } + + /* Create a new Ruby object */ + obj = Data_Wrap_Struct(sklass->klass, VOIDFUNC(sklass->mark), + ( own ? VOIDFUNC(sklass->destroy) : + (track ? VOIDFUNC(SWIG_RubyRemoveTracking) : 0 ) + ), ptr); + + /* If tracking is on for this class then track this object. */ + if (track) { + SWIG_RubyAddTracking(ptr, obj); + } + } else { + klass_name = (char *) malloc(4 + strlen(type->name) + 1); + sprintf(klass_name, "TYPE%s", type->name); + klass = rb_const_get(_mSWIG, rb_intern(klass_name)); + free((void *) klass_name); + obj = Data_Wrap_Struct(klass, 0, 0, ptr); + } + rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name)); + + return obj; +} + +/* Create a new class instance (always owned) */ +SWIGRUNTIME VALUE +SWIG_Ruby_NewClassInstance(VALUE klass, swig_type_info *type) +{ + VALUE obj; + swig_class *sklass = (swig_class *) type->clientdata; + obj = Data_Wrap_Struct(klass, VOIDFUNC(sklass->mark), VOIDFUNC(sklass->destroy), 0); + rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name)); + return obj; +} + +/* Get type mangle from class name */ +SWIGRUNTIMEINLINE char * +SWIG_Ruby_MangleStr(VALUE obj) +{ + VALUE stype = rb_iv_get(obj, "@__swigtype__"); + return StringValuePtr(stype); +} + +/* Acquire a pointer value */ +typedef void (*ruby_owntype)(void*); + +SWIGRUNTIME ruby_owntype +SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) { + if (obj) { + ruby_owntype oldown = RDATA(obj)->dfree; + RDATA(obj)->dfree = own; + return oldown; + } else { + return 0; + } +} + +/* Convert a pointer value */ +SWIGRUNTIME int +SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own) +{ + char *c; + swig_cast_info *tc; + void *vptr = 0; + + /* Grab the pointer */ + if (NIL_P(obj)) { + *ptr = 0; + return SWIG_OK; + } else { + if (TYPE(obj) != T_DATA) { + return SWIG_ERROR; + } + Data_Get_Struct(obj, void, vptr); + } + + if (own) *own = RDATA(obj)->dfree; + + /* Check to see if the input object is giving up ownership + of the underlying C struct or C++ object. If so then we + need to reset the destructor since the Ruby object no + longer owns the underlying C++ object.*/ + if (flags & SWIG_POINTER_DISOWN) { + /* Is tracking on for this class? */ + int track = 0; + if (ty && ty->clientdata) { + swig_class *sklass = (swig_class *) ty->clientdata; + track = sklass->trackObjects; + } + + if (track) { + /* We are tracking objects for this class. Thus we change the destructor + * to SWIG_RubyRemoveTracking. This allows us to + * remove the mapping from the C++ to Ruby object + * when the Ruby object is garbage collected. If we don't + * do this, then it is possible we will return a reference + * to a Ruby object that no longer exists thereby crashing Ruby. */ + RDATA(obj)->dfree = SWIG_RubyRemoveTracking; + } else { + RDATA(obj)->dfree = 0; + } + } + + /* Do type-checking if type info was provided */ + if (ty) { + if (ty->clientdata) { + if (rb_obj_is_kind_of(obj, ((swig_class *) (ty->clientdata))->klass)) { + if (vptr == 0) { + /* The object has already been deleted */ + return SWIG_ObjectPreviouslyDeletedError; + } + *ptr = vptr; + return SWIG_OK; + } + } + if ((c = SWIG_MangleStr(obj)) == NULL) { + return SWIG_ERROR; + } + tc = SWIG_TypeCheck(c, ty); + if (!tc) { + return SWIG_ERROR; + } else { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc, vptr, &newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + } + } else { + *ptr = vptr; + } + + return SWIG_OK; +} + +/* Check convert */ +SWIGRUNTIMEINLINE int +SWIG_Ruby_CheckConvert(VALUE obj, swig_type_info *ty) +{ + char *c = SWIG_MangleStr(obj); + if (!c) return 0; + return SWIG_TypeCheck(c,ty) != 0; +} + +SWIGRUNTIME VALUE +SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) { + char result[1024]; + char *r = result; + if ((2*sz + 1 + strlen(type->name)) > 1000) return 0; + *(r++) = '_'; + r = SWIG_PackData(r, ptr, sz); + strcpy(r, type->name); + return rb_str_new2(result); +} + +/* Convert a packed value value */ +SWIGRUNTIME int +SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) { + swig_cast_info *tc; + const char *c; + + if (TYPE(obj) != T_STRING) goto type_error; + c = StringValuePtr(obj); + /* Pointer values must start with leading underscore */ + if (*c != '_') goto type_error; + c++; + c = SWIG_UnpackData(c, ptr, sz); + if (ty) { + tc = SWIG_TypeCheck(c, ty); + if (!tc) goto type_error; + } + return SWIG_OK; + + type_error: + return SWIG_ERROR; +} + +SWIGRUNTIME swig_module_info * +SWIG_Ruby_GetModule(void) +{ + VALUE pointer; + swig_module_info *ret = 0; + VALUE verbose = rb_gv_get("VERBOSE"); + + /* temporarily disable warnings, since the pointer check causes warnings with 'ruby -w' */ + rb_gv_set("VERBOSE", Qfalse); + + /* first check if pointer already created */ + pointer = rb_gv_get("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); + if (pointer != Qnil) { + Data_Get_Struct(pointer, swig_module_info, ret); + } + + /* reinstate warnings */ + rb_gv_set("VERBOSE", verbose); + return ret; +} + +SWIGRUNTIME void +SWIG_Ruby_SetModule(swig_module_info *pointer) +{ + /* register a new class */ + VALUE cl = rb_define_class("swig_runtime_data", rb_cObject); + /* create and store the structure pointer to a global variable */ + swig_runtime_data_type_pointer = Data_Wrap_Struct(cl, 0, 0, pointer); + rb_define_readonly_variable("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, &swig_runtime_data_type_pointer); +} + +/* This function can be used to check whether a proc or method or similarly + callable function has been passed. Usually used in a %typecheck, like: + + %typecheck(c_callback_t, precedence=SWIG_TYPECHECK_POINTER) { + $result = SWIG_Ruby_isCallable( $input ); + } + */ +SWIGINTERN +int SWIG_Ruby_isCallable( VALUE proc ) +{ + if ( rb_respond_to( proc, swig_call_id ) == Qtrue ) + return 1; + return 0; +} + +/* This function can be used to check the arity (number of arguments) + a proc or method can take. Usually used in a %typecheck. + Valid arities will be that equal to minimal or those < 0 + which indicate a variable number of parameters at the end. + */ +SWIGINTERN +int SWIG_Ruby_arity( VALUE proc, int minimal ) +{ + if ( rb_respond_to( proc, swig_arity_id ) == Qtrue ) + { + VALUE num = rb_funcall( proc, swig_arity_id, 0 ); + int arity = NUM2INT(num); + if ( arity < 0 && (arity+1) < -minimal ) return 1; + if ( arity == minimal ) return 1; + return 1; + } + return 0; +} + + +#ifdef __cplusplus +} +#endif diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubyruntime.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubyruntime.swg new file mode 100644 index 0000000..4121561 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubyruntime.swg @@ -0,0 +1,9 @@ + +%runtime "swiglabels.swg" /* Common C API type-checking code */ +%runtime "swigrun.swg" /* Common C API type-checking code */ +%runtime "swigerrors.swg" /* SWIG errors */ +%runtime "rubyhead.swg" /* Ruby includes and fixes */ +%runtime "rubyerrors.swg" /* Ruby errors */ +%runtime "rubytracking.swg" /* API for tracking C++ classes to Ruby objects */ +%runtime "rubyapi.swg" +%runtime "rubyrun.swg" diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubystdautodoc.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubystdautodoc.swg new file mode 100644 index 0000000..ad70f7f --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubystdautodoc.swg @@ -0,0 +1,37 @@ +/** + * @file rubystdautodoc.swg + * @author gga + * @date Wed May 2 17:20:39 2007 + * + * @brief This file contains autodocs for standard STL functions. + * + * + */ + +// +// For STL autodocumentation +// +AUTODOC(c_str, "Convert class to a String representation"); +AUTODOC(begin, "Return an iterator to the beginning of the $class"); +AUTODOC(end, "Return an iterator to past the end of the $class"); +AUTODOC(rbegin, "Return a reverse iterator to the beginning (the end) of the $class"); +AUTODOC(rend, "Return a reverse iterator to past the end (past the beginning) of the $class"); +AUTODOC(length, "Size or Length of the $class"); +AUTODOC(replace, "Replace all or a portion of the $class"); +AUTODOC(resize, "Resize the size of the $class"); +AUTODOC(capacity, "Reserved capacity of the $class"); +AUTODOC(reserve, "Reserve memory in the $class for a number of elements"); +AUTODOC(erase, "Delete a portion of the $class"); +AUTODOC(max_size, "Maximum size of elements allowed in the $class"); +AUTODOC(iterator, "Return an iterator to the $class"); +AUTODOC(empty, "Check if the $class is empty or not"); +AUTODOC(rfind, "Find an element in reverse usually starting from the end of the $class"); +AUTODOC(assign, "Assign a new $class or portion of it"); +AUTODOC(front, "Return the first element in $class"); +AUTODOC(back, "Return the last element in $class"); +AUTODOC(second, "Return the second element in $class"); +AUTODOC(push_front, "Add an element at the beginning of the $class"); +AUTODOC(push_back, "Add an element at the end of the $class"); +AUTODOC(pop_front, "Remove and return element at the beginning of the $class"); +AUTODOC(pop_back, "Remove and return an element at the end of the $class"); +AUTODOC(clear, "Clear $class contents"); diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubystdcommon.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubystdcommon.swg new file mode 100644 index 0000000..4e1b9d9 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubystdcommon.swg @@ -0,0 +1,265 @@ + +/* ------------------------------------------------------------ + * The Ruby classes, for C++ + * ------------------------------------------------------------ */ +%include <rubyclasses.swg> + +%fragment("StdTraits","header",fragment="StdTraitsCommon") +{ + +namespace swig { + /* + Traits that provides the from method + */ + template <class Type> struct traits_from_ptr { + static VALUE from(Type *val, int owner = 0) { + return SWIG_NewPointerObj(val, type_info<Type>(), owner); + } + }; + + template <class Type> struct traits_from { + static VALUE from(const Type& val) { + return traits_from_ptr<Type>::from(new Type(val), 1); + } + }; + + template <class Type> struct traits_from<Type *> { + static VALUE from(Type* val) { + return traits_from_ptr<Type>::from(val, 0); + } + }; + + template <class Type> struct traits_from<const Type *> { + static VALUE from(const Type* val) { + return traits_from_ptr<Type>::from(const_cast<Type*>(val), 0); + } + }; + + + template <class Type> + inline VALUE from(const Type& val) { + return traits_from<Type>::from(val); + } + + template <class Type> + inline VALUE from_ptr(Type* val, int owner) { + return traits_from_ptr<Type>::from(val, owner); + } + + /* + Traits that provides the asval/as/check method + */ + template <class Type> + struct traits_asptr { + static int asptr(VALUE obj, Type **val) { + Type *p; + int res = SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0); + if (SWIG_IsOK(res)) { + if (val) *val = p; + } + return res; + } + }; + + template <class Type> + inline int asptr(VALUE obj, Type **vptr) { + return traits_asptr<Type>::asptr(obj, vptr); + } + + template <class Type> + struct traits_asval { + static int asval(VALUE obj, Type *val) { + if (val) { + Type *p = 0; + int res = traits_asptr<Type>::asptr(obj, &p); + if (!SWIG_IsOK(res)) return res; + if (p) { + typedef typename noconst_traits<Type>::noconst_type noconst_type; + *(const_cast<noconst_type*>(val)) = *p; + if (SWIG_IsNewObj(res)){ + %delete(p); + res = SWIG_DelNewMask(res); + } + return res; + } else { + return SWIG_ERROR; + } + } else { + return traits_asptr<Type>::asptr(obj, (Type **)(0)); + } + } + }; + + template <class Type> struct traits_asval<Type*> { + static int asval(VALUE obj, Type **val) { + if (val) { + typedef typename noconst_traits<Type>::noconst_type noconst_type; + noconst_type *p = 0; + int res = traits_asptr<noconst_type>::asptr(obj, &p); + if (SWIG_IsOK(res)) { + *(const_cast<noconst_type**>(val)) = p; + } + return res; + } else { + return traits_asptr<Type>::asptr(obj, (Type **)(0)); + } + } + }; + + template <class Type> + inline int asval(VALUE obj, Type *val) { + return traits_asval<Type>::asval(obj, val); + } + + template <class Type> + struct traits_as<Type, value_category> { + static Type as(VALUE obj, bool throw_error) { + Type v; + int res = asval(obj, &v); + if (!obj || !SWIG_IsOK(res)) { + if (throw_error) throw std::invalid_argument("bad type"); + VALUE lastErr = rb_gv_get("$!"); + if (lastErr == Qnil) { + %type_error(swig::type_name<Type>()); + } + } + return v; + } + }; + + template <class Type> + struct traits_as<Type, pointer_category> { + static Type as(VALUE obj, bool throw_error) { + Type *v = 0; + int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : SWIG_ERROR); + if (SWIG_IsOK(res) && v) { + if (SWIG_IsNewObj(res)) { + Type r(*v); + %delete(v); + return r; + } else { + return *v; + } + } else { + // Uninitialized return value, no Type() constructor required. + if (throw_error) throw std::invalid_argument("bad type"); + VALUE lastErr = rb_gv_get("$!"); + if (lastErr == Qnil) { + %type_error(swig::type_name<Type>()); + } + static Type *v_def = (Type*) malloc(sizeof(Type)); + memset(v_def,0,sizeof(Type)); + return *v_def; + } + } + }; + + template <class Type> + struct traits_as<Type*, pointer_category> { + static Type* as(VALUE obj, bool throw_error) { + Type *v = 0; + int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : SWIG_ERROR); + if (SWIG_IsOK(res)) { + return v; + } else { + if (throw_error) throw std::invalid_argument("bad type"); + VALUE lastErr = rb_gv_get("$!"); + if (lastErr == Qnil) { + %type_error(swig::type_name<Type>()); + } + return 0; + } + } + }; + + template <class Type> + inline Type as(VALUE obj, bool te = false) { + return traits_as< Type, typename traits< Type >::category >::as(obj, te); + } + + template <class Type> + struct traits_check<Type, value_category> { + static bool check(VALUE obj) { + int res = obj ? asval(obj, (Type *)(0)) : SWIG_ERROR; + return SWIG_IsOK(res) ? true : false; + } + }; + + template <class Type> + struct traits_check<Type, pointer_category> { + static bool check(VALUE obj) { + int res = obj ? asptr(obj, (Type **)(0)) : SWIG_ERROR; + return SWIG_IsOK(res) ? true : false; + } + }; + + template <class Type> + inline bool check(VALUE obj) { + return traits_check<Type, typename traits<Type>::category>::check(obj); + } +} +} + + +// Define GC marking template traits for a container type +%define %create_mark_traits(Type) +%{ + namespace swig { + template <class T> + struct mark_traits { + typedef typename Type<T >::const_iterator const_iterator; + + inline void operator()(const Type<T >& c ) const + { + const_iterator i = c.begin(); + const_iterator e = c.end(); + for ( ; i != e; ++i ) + { + rb_gc_mark( swig::from( &(*i) ) ); + } + } + }; + + // Partial specializations for classes that requires no GC marking + // or a special GC marking algorithm. + template< > + struct mark_traits<bool> { + inline void operator()(const Type<bool >& c ) const {} + }; + + template< > + struct mark_traits<char> { + inline void operator()(const Type<char >& c ) const {} + }; + + template< > + struct mark_traits<int> { + inline void operator()(const Type<int >& c ) const {} + }; + + template< > + struct mark_traits<unsigned> { + inline void operator()(const Type<unsigned >& c ) const {} + }; + + template< > + struct mark_traits<GC_VALUE> { + typedef Type<GC_VALUE >::const_iterator const_iterator; + + inline void operator()(const Type<GC_VALUE >& c ) const { + const_iterator i = c.begin(); + const_iterator e = c.end(); + for ( ; i != e; ++i ) + { + VALUE v = *i; + if ( FIXNUM_P(v) || SPECIAL_CONST_P(v) || SYMBOL_P(v) || + ( BUILTIN_TYPE(v) == T_NONE ) ) continue; + + rb_gc_mark( v ); + } + } + }; + + } +%} +%enddef diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubystdfunctors.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubystdfunctors.swg new file mode 100644 index 0000000..8209382 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubystdfunctors.swg @@ -0,0 +1,162 @@ +/** + * @file rubystdfunctors.swg + * @date Sun May 6 00:44:33 2007 + * + * @brief This file provides unary and binary functors for STL + * containers, that will invoke a Ruby proc or method to do + * their operation. + * + * You can use them in a swig file like: + * + * %include <std_set.i> + * %include <std_functors.i> + * + * %template< IntSet > std::set< int, swig::BinaryPredicate<> >; + * + * + * which will then allow calling them from Ruby either like: + * + * # order of set is defined by C++ default + * a = IntSet.new + * + * # sort order defined by Ruby proc + * b = IntSet.new( proc { |a,b| a > b } ) + * + */ + +%include rubyclasses.swg + + +namespace swig { + + %apply GC_VALUE { UnaryPredicate, BinaryPredicate, UnaryFunction, + BinaryFunction }; + + %typecheck(SWIG_TYPECHECK_POINTER,noblock=1) + UnaryPredicate, UnaryPredicate&, UnaryFunction, UnaryFunction& + { + $1 = SWIG_Ruby_isCallable($input) && SWIG_Ruby_arity($input, 1); + } + + %typecheck(SWIG_TYPECHECK_POINTER,noblock=1) + BinaryPredicate, BinaryPredicate&, BinaryFunction, BinaryFunction& { + $1 = SWIG_Ruby_isCallable($input) && SWIG_Ruby_arity($input, 2); + } + + %typemap(in,noblock=1) BinaryFunction&, BinaryFunction { + $1 = new swig::BinaryFunction< >($input); + } + %typemap(in,noblock=1) UnaryFunction&, UnaryFunction { + $1 = new swig::UnaryFunction< >($input); + } + + %typemap(in,noblock=1) BinaryPredicate&, BinaryPredicate { + $1 = new swig::BinaryPredicate<>($input); + } + + %typemap(in,noblock=1) UnaryPredicate&, UnaryPredicate { + $1 = new swig::UnaryPredicate< >($input); + } + + + %ignore BinaryFunction; + template< class _T = GC_VALUE > + struct BinaryFunction { + }; + + %ignore UnaryFunction; + template< class _T = GC_VALUE > + struct UnaryFunction { + }; + + %ignore BinaryPredicate; + template< class _T = GC_VALUE > + struct BinaryPredicate { + }; + + %ignore UnaryPredicate; + template< class _T = GC_VALUE > + struct UnaryPredicate { + + }; + +} + + +%fragment("StdFunctors","header",fragment="StdTraits") +{ +namespace swig { + + static ID call_id = rb_intern("call"); + + template <class _T = GC_VALUE, class _DefaultFunc = std::less<GC_VALUE> > + struct BinaryPredicate : GC_VALUE, std::binary_function< _T, _T, bool > + { + BinaryPredicate(VALUE obj = Qnil) : GC_VALUE(obj) { } + bool operator()(_T a, _T b) const + { + if (_obj != Qnil) { + SWIG_RUBY_THREAD_BEGIN_BLOCK; + VALUE arg1 = swig::from(a); + VALUE arg2 = swig::from(b); + VALUE res = rb_funcall( _obj, swig::call_id, 2, arg1, arg2); + SWIG_RUBY_THREAD_END_BLOCK; + return RTEST(res); + } else { + return _DefaultFunc()(a, b); + } + } + }; + + template <class _T = GC_VALUE, class _DefaultFunc = std::less< _T > > + struct BinaryFunction : GC_VALUE, std::binary_function< _T, _T, _T > + { + BinaryFunction(VALUE obj = Qnil) : GC_VALUE(obj) { } + _T operator()(_T a, _T b) const + { + if (_obj != Qnil) { + SWIG_RUBY_THREAD_BEGIN_BLOCK; + VALUE arg1 = swig::from(a); + VALUE arg2 = swig::from(b); + VALUE res = rb_funcall( _obj, swig::call_id, 2, arg1, arg2); + SWIG_RUBY_THREAD_END_BLOCK; + return swig::as<_T >(res); + } else { + return _DefaultFunc()(a, b); + } + } + }; + + template< class _T = GC_VALUE > + struct UnaryPredicate : GC_VALUE, std::unary_function< _T, bool > + { + UnaryPredicate(VALUE obj = Qnil) : GC_VALUE(obj) { } + bool operator()(_T a) const + { + SWIG_RUBY_THREAD_BEGIN_BLOCK; + VALUE arg1 = swig::from<_T >(a); + VALUE res = rb_funcall( _obj, swig::call_id, 1, arg1); + SWIG_RUBY_THREAD_END_BLOCK; + return RTEST(res); + } + }; + + template< class _T = GC_VALUE > + struct UnaryFunction : GC_VALUE, std::unary_function< _T, _T > + { + UnaryFunction(VALUE obj = Qnil) : GC_VALUE(obj) { } + _T operator()(_T a) const + { + SWIG_RUBY_THREAD_BEGIN_BLOCK; + VALUE arg1 = swig::from(a); + VALUE res = rb_funcall( _obj, swig::call_id, 1, VALUE(arg1)); + SWIG_RUBY_THREAD_END_BLOCK; + return swig::as< _T >(res); + } + }; + +} // namespace swig + +} + + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubystrings.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubystrings.swg new file mode 100644 index 0000000..e6b92ef --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubystrings.swg @@ -0,0 +1,61 @@ +/* ------------------------------------------------------------ + * utility methods for char strings + * ------------------------------------------------------------ */ + +%fragment("SWIG_AsCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { +SWIGINTERN int +SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc) +{ + if (TYPE(obj) == T_STRING) { + %#if defined(StringValuePtr) + char *cstr = StringValuePtr(obj); + %#else + char *cstr = STR2CSTR(obj); + %#endif + size_t size = RSTRING_LEN(obj) + 1; + if (cptr) { + if (alloc) { + if (*alloc == SWIG_NEWOBJ) { + *cptr = %new_copy_array(cstr, size, char); + } else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } + } + } + if (psize) *psize = size; + return SWIG_OK; + } else { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + void* vptr = 0; + if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = (char *)vptr; + if (psize) *psize = vptr ? (strlen((char*)vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} +} + +%fragment("SWIG_FromCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { +SWIGINTERNINLINE VALUE +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + if (carray) { + if (size > LONG_MAX) { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + return pchar_descriptor ? + SWIG_NewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : Qnil; + } else { + return rb_str_new(carray, %numeric_cast(size,long)); + } + } else { + return Qnil; + } +} +} + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubytracking.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubytracking.swg new file mode 100644 index 0000000..959d208 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubytracking.swg @@ -0,0 +1,160 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * rubytracking.swg + * + * This file contains support for tracking mappings from + * Ruby objects to C++ objects. This functionality is needed + * to implement mark functions for Ruby's mark and sweep + * garbage collector. + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Ruby 1.8 actually assumes the first case. */ +#if SIZEOF_VOIDP == SIZEOF_LONG +# define SWIG2NUM(v) LONG2NUM((unsigned long)v) +# define NUM2SWIG(x) (unsigned long)NUM2LONG(x) +#elif SIZEOF_VOIDP == SIZEOF_LONG_LONG +# define SWIG2NUM(v) LL2NUM((unsigned long long)v) +# define NUM2SWIG(x) (unsigned long long)NUM2LL(x) +#else +# error sizeof(void*) is not the same as long or long long +#endif + + +/* Global Ruby hash table to store Trackings from C/C++ + structs to Ruby Objects. +*/ +static VALUE swig_ruby_trackings = Qnil; + +/* Global variable that stores a reference to the ruby + hash table delete function. */ +static ID swig_ruby_hash_delete; + +/* Setup a Ruby hash table to store Trackings */ +SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { + /* Create a ruby hash table to store Trackings from C++ + objects to Ruby objects. */ + + /* Try to see if some other .so has already created a + tracking hash table, which we keep hidden in an instance var + in the SWIG module. + This is done to allow multiple DSOs to share the same + tracking table. + */ + ID trackings_id = rb_intern( "@__trackings__" ); + VALUE verbose = rb_gv_get("VERBOSE"); + rb_gv_set("VERBOSE", Qfalse); + swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id ); + rb_gv_set("VERBOSE", verbose); + + /* No, it hasn't. Create one ourselves */ + if ( swig_ruby_trackings == Qnil ) + { + swig_ruby_trackings = rb_hash_new(); + rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings ); + } + + /* Now store a reference to the hash table delete function + so that we only have to look it up once.*/ + swig_ruby_hash_delete = rb_intern("delete"); +} + +/* Get a Ruby number to reference a pointer */ +SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) { + /* We cast the pointer to an unsigned long + and then store a reference to it using + a Ruby number object. */ + + /* Convert the pointer to a Ruby number */ + return SWIG2NUM(ptr); +} + +/* Get a Ruby number to reference an object */ +SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) { + /* We cast the object to an unsigned long + and then store a reference to it using + a Ruby number object. */ + + /* Convert the Object to a Ruby number */ + return SWIG2NUM(object); +} + +/* Get a Ruby object from a previously stored reference */ +SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) { + /* The provided Ruby number object is a reference + to the Ruby object we want.*/ + + /* Convert the Ruby number to a Ruby object */ + return NUM2SWIG(reference); +} + +/* Add a Tracking from a C/C++ struct to a Ruby object */ +SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) { + /* In a Ruby hash table we store the pointer and + the associated Ruby object. The trick here is + that we cannot store the Ruby object directly - if + we do then it cannot be garbage collected. So + instead we typecast it as a unsigned long and + convert it to a Ruby number object.*/ + + /* Get a reference to the pointer as a Ruby number */ + VALUE key = SWIG_RubyPtrToReference(ptr); + + /* Get a reference to the Ruby object as a Ruby number */ + VALUE value = SWIG_RubyObjectToReference(object); + + /* Store the mapping to the global hash table. */ + rb_hash_aset(swig_ruby_trackings, key, value); +} + +/* Get the Ruby object that owns the specified C/C++ struct */ +SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { + /* Get a reference to the pointer as a Ruby number */ + VALUE key = SWIG_RubyPtrToReference(ptr); + + /* Now lookup the value stored in the global hash table */ + VALUE value = rb_hash_aref(swig_ruby_trackings, key); + + if (value == Qnil) { + /* No object exists - return nil. */ + return Qnil; + } + else { + /* Convert this value to Ruby object */ + return SWIG_RubyReferenceToObject(value); + } +} + +/* Remove a Tracking from a C/C++ struct to a Ruby object. It + is very important to remove objects once they are destroyed + since the same memory address may be reused later to create + a new object. */ +SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { + /* Get a reference to the pointer as a Ruby number */ + VALUE key = SWIG_RubyPtrToReference(ptr); + + /* Delete the object from the hash table by calling Ruby's + do this we need to call the Hash.delete method.*/ + rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key); +} + +/* This is a helper method that unlinks a Ruby object from its + underlying C++ object. This is needed if the lifetime of the + Ruby object is longer than the C++ object */ +SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { + VALUE object = SWIG_RubyInstanceFor(ptr); + + if (object != Qnil) { + DATA_PTR(object) = 0; + } +} + + +#ifdef __cplusplus +} +#endif diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubytypemaps.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubytypemaps.swg new file mode 100644 index 0000000..336ee97 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubytypemaps.swg @@ -0,0 +1,62 @@ +/* ------------------------------------------------------------ + * Typemap specializations for Ruby + * ------------------------------------------------------------ */ +/* ------------------------------------------------------------ + * Fragment section + * ------------------------------------------------------------ */ +/* bool is dangerous in Ruby, change precedence */ +#undef SWIG_TYPECHECK_BOOL +%define SWIG_TYPECHECK_BOOL 10000 %enddef + +/* Include fundamental fragemt definitions */ +%include <typemaps/fragments.swg> + +/* Look for user fragments file. */ +%include <rubyfragments.swg> + +/* Ruby fragments for primitive types */ +%include <rubyprimtypes.swg> + +/* Ruby fragments for char* strings */ +%include <rubystrings.swg> + +/* Backward compatibility output helper */ +%fragment("output_helper","header") %{ +#define output_helper SWIG_Ruby_AppendOutput +%} + +/* ------------------------------------------------------------ + * Unified typemap section + * ------------------------------------------------------------ */ + +/* Directors are supported in Ruby */ +#ifndef SWIG_DIRECTOR_TYPEMAPS +#define SWIG_DIRECTOR_TYPEMAPS +#endif + + +/* Ruby types */ +#define SWIG_Object VALUE +#define VOID_Object Qnil + +/* Overload of the output/constant/exception handling */ + +/* append output */ +#define SWIG_AppendOutput(result,obj) SWIG_Ruby_AppendOutput(result, obj) + +/* set constant */ +#define SWIG_SetConstant(name, obj) rb_define_const($module, name, obj) + +/* raise */ +#define SWIG_Raise(obj, type, desc) rb_exc_raise(SWIG_Ruby_ExceptionType(desc, obj)) + +/* Get the address of the 'Ruby self' object */ + +%typemap(in,numinputs=0,noblock=1) VALUE* RUBY_SELF { + $1 = &self; +} + +/* Include the unified typemap library */ +%include <typemaps/swigtypemaps.swg> + + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubyuserdir.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubyuserdir.swg new file mode 100644 index 0000000..2f67c9e --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubyuserdir.swg @@ -0,0 +1,10 @@ +#define %alias %feature("alias") +#define %freefunc %feature("freefunc") +#define %markfunc %feature("markfunc") +#define %mixin %feature("mixin") +#define %predicate %feature("predicate", "1") +#define %bang %feature("bang", "1") +#define %trackobjects %feature("trackobjects") +#define %nooutput %feature("outputs","0") +#define %initstack %feature("initstack", "1") +#define %ignorestack %feature("initstack", "0") diff --git a/devtools/swigwin-1.3.34/Lib/ruby/rubywstrings.swg b/devtools/swigwin-1.3.34/Lib/ruby/rubywstrings.swg new file mode 100644 index 0000000..0cf9d7e --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/rubywstrings.swg @@ -0,0 +1,76 @@ +/** + * @file rubywstrings.swg + * @author + * @date Fri May 4 17:49:40 2007 + * + * @brief Currently, Ruby does not support Unicode or WChar properly, so these + * are still treated as char arrays for now. + * There are other libraries available that add support to this in + * ruby including WString, FXString, etc. + * + * + */ + +/* ------------------------------------------------------------ + * utility methods for wchar_t strings + * ------------------------------------------------------------ */ + +%fragment("SWIG_AsWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWIG_pwchar_descriptor") { +SWIGINTERN int +SWIG_AsWCharPtrAndSize(VALUE obj, wchar_t **cptr, size_t *psize, int *alloc) +{ + return SWIG_AsCharPtrAndSize( obj, (char**)cptr, psize, alloc); +// VALUE tmp = 0; +// bool ok = false; +// if ( TYPE(obj) == T_STRING ) { +// if (cptr) { +// obj = tmp = SWIG_Unicode_FromObject(obj); +// ok = true; +// } +// } +// if (ok) { +// int len = PyUnicode_GetSize(obj); +// rb_notimplement(); +// if (cptr) { +// *cptr = %new_array(len + 1, wchar_t); +// SWIG_Unicode_AsWideChar((PyUnicodeObject *)obj, *cptr, len); +// (*cptr)[len] = 0; +// } +// if (psize) *psize = (size_t) len + 1; +// if (alloc) *alloc = cptr ? SWIG_NEWOBJ : 0; +// return SWIG_OK; +// } else { +// swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor(); +// if (pwchar_descriptor) { +// void * vptr = 0; +// if (SWIG_ConvertPtr(obj, &vptr, pwchar_descriptor, 0) == SWIG_OK) { +// if (cptr) *cptr = (wchar_t *)vptr; +// if (psize) *psize = vptr ? (wcslen((wchar_t *)vptr) + 1) : 0; +// return SWIG_OK; +// } +// } +// } +// return SWIG_TypeError; +} +} + +%fragment("SWIG_FromWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWIG_pwchar_descriptor") { +SWIGINTERNINLINE VALUE +SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size) +{ + return SWIG_FromCharPtrAndSize( (const char*)carray, size); +// if (carray) { +// if (size > INT_MAX) { +// swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor(); +// return pwchar_descriptor ? +// SWIG_NewPointerObj(%const_cast(carray,wchar_t *), pwchar_descriptor, 0) : Qnil; +// } else { +// return SWIG_Unicode_FromWideChar(carray, %numeric_cast(size,int)); +// } +// } else { +// return Qnil; +// } +} +} + + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_alloc.i b/devtools/swigwin-1.3.34/Lib/ruby/std_alloc.i new file mode 100644 index 0000000..35dc051 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_alloc.i @@ -0,0 +1 @@ +%include <std/std_alloc.i> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_basic_string.i b/devtools/swigwin-1.3.34/Lib/ruby/std_basic_string.i new file mode 100644 index 0000000..1351177 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_basic_string.i @@ -0,0 +1,97 @@ +#if !defined(SWIG_STD_STRING) +#define SWIG_STD_BASIC_STRING + +%include <rubycontainer.swg> + +#define %swig_basic_string(Type...) %swig_sequence_methods_val(Type) + + +%traits_swigtype(std::basic_string<char>); +%fragment(SWIG_Traits_frag(std::basic_string<char>)); + + +%fragment(SWIG_AsPtr_frag(std::basic_string<char>),"header", + fragment="SWIG_AsCharPtrAndSize") { +SWIGINTERN int +SWIG_AsPtr(std::basic_string<char>)(VALUE obj, std::string **val) +{ + static swig_type_info* string_info = + SWIG_TypeQuery("std::basic_string<char> *"); + std::string *vptr; + if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) { + if (val) *val = vptr; + return SWIG_OLDOBJ; + } else { + char* buf = 0 ; size_t size = 0; int alloc = 0; + if (SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) { + if (buf) { + if (val) *val = new std::string(buf, size - 1); + if (alloc == SWIG_NEWOBJ) %delete_array(buf); + return SWIG_NEWOBJ; + } + } + if (val) { + rb_raise( rb_eTypeError, "a string is expected"); + } + return 0; + } +} +} + +%fragment(SWIG_From_frag(std::basic_string<char>),"header", + fragment="SWIG_FromCharPtrAndSize") { +SWIGINTERNINLINE VALUE + SWIG_From(std::basic_string<char>)(const std::string& s) + { + return SWIG_FromCharPtrAndSize(s.data(), s.size()); + } +} + +%include <std/std_basic_string.i> +%typemaps_asptrfromn(%checkcode(STRING), std::basic_string<char>); + +#endif + + +#if !defined(SWIG_STD_WSTRING) + +%fragment(SWIG_AsPtr_frag(std::basic_string<wchar_t>),"header", + fragment="SWIG_AsWCharPtrAndSize") { +SWIGINTERN int + SWIG_AsPtr(std::basic_string<wchar_t>)(VALUE obj, std::wstring **val) + { + static swig_type_info* string_info = + SWIG_TypeQuery("std::basic_string<wchar_t> *"); + std::wstring *vptr; + if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) { + if (val) *val = vptr; + return SWIG_OLDOBJ; + } else { + wchar_t *buf = 0 ; size_t size = 0; int alloc = 0; + if (SWIG_AsWCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) { + if (buf) { + if (val) *val = new std::wstring(buf, size - 1); + if (alloc == SWIG_NEWOBJ) %delete_array(buf); + return SWIG_NEWOBJ; + } + } + if (val) { + rb_raise( rb_eTypeError, "a string is expected"); + } + return 0; + } + } +} + +%fragment(SWIG_From_frag(std::basic_string<wchar_t>),"header", + fragment="SWIG_FromWCharPtrAndSize") { +SWIGINTERNINLINE VALUE + SWIG_From(std::basic_string<wchar_t>)(const std::wstring& s) + { + return SWIG_FromWCharPtrAndSize(s.data(), s.size()); + } +} + +%typemaps_asptrfromn(%checkcode(UNISTRING), std::basic_string<wchar_t>); + +#endif diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_char_traits.i b/devtools/swigwin-1.3.34/Lib/ruby/std_char_traits.i new file mode 100644 index 0000000..bf4e6c4 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_char_traits.i @@ -0,0 +1 @@ +%include <std/std_char_traits.i> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_common.i b/devtools/swigwin-1.3.34/Lib/ruby/std_common.i new file mode 100644 index 0000000..16365a4 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_common.i @@ -0,0 +1,44 @@ +%include <std/std_except.i> +%include <rubystdcommon.swg> +%include <rubystdautodoc.swg> + + +/* + Generate the traits for a 'primitive' type, such as 'double', + for which the SWIG_AsVal and SWIG_From methods are already defined. +*/ + +%define %traits_ptypen(Type...) + %fragment(SWIG_Traits_frag(Type),"header", + fragment=SWIG_AsVal_frag(Type), + fragment=SWIG_From_frag(Type), + fragment="StdTraits") { +namespace swig { + template <> struct traits<Type > { + typedef value_category category; + static const char* type_name() { return #Type; } + }; + template <> struct traits_asval<Type > { + typedef Type value_type; + static int asval(VALUE obj, value_type *val) { + return SWIG_AsVal(Type)(obj, val); + } + }; + template <> struct traits_from<Type > { + typedef Type value_type; + static VALUE from(const value_type& val) { + return SWIG_From(Type)(val); + } + }; +} +} +%enddef + + +%include <std/std_common.i> + +// +// Generates the traits for all the known primitive +// C++ types (int, double, ...) +// +%apply_cpptypes(%traits_ptypen); diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_complex.i b/devtools/swigwin-1.3.34/Lib/ruby/std_complex.i new file mode 100644 index 0000000..dacbea2 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_complex.i @@ -0,0 +1,22 @@ +/* + * STD C++ complex typemaps + */ + +%include <rubycomplex.swg> + +%{ +#include <complex> +%} + +/* defining the complex as/from converters */ + +%swig_cplxdbl_convn(std::complex<double>, std::complex<double>, std::real, std::imag) +%swig_cplxflt_convn(std::complex<float>, std::complex<float>, std::real, std::imag) + +/* defining the typemaps */ + +%typemaps_primitive(%checkcode(CPLXDBL), std::complex<double>); +%typemaps_primitive(%checkcode(CPLXFLT), std::complex<float>); + + + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_container.i b/devtools/swigwin-1.3.34/Lib/ruby/std_container.i new file mode 100644 index 0000000..8537950 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_container.i @@ -0,0 +1,2 @@ +%include <rubycontainer.swg> +%include <std/std_container.i> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_deque.i b/devtools/swigwin-1.3.34/Lib/ruby/std_deque.i new file mode 100644 index 0000000..38048af --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_deque.i @@ -0,0 +1,30 @@ +/* + Deques +*/ + +%fragment("StdDequeTraits","header",fragment="StdSequenceTraits") +%{ + namespace swig { + template <class T> + struct traits_asptr<std::deque<T> > { + static int asptr(VALUE obj, std::deque<T> **vec) { + return traits_asptr_stdseq<std::deque<T> >::asptr(obj, vec); + } + }; + + template <class T> + struct traits_from<std::deque<T> > { + static VALUE from(const std::deque<T> & vec) { + return traits_from_stdseq<std::deque<T> >::from(vec); + } + }; + } +%} + +%ignore std::deque::push_back; +%ignore std::deque::pop_back; + +#define %swig_deque_methods(Type...) %swig_sequence_methods(Type) +#define %swig_deque_methods_val(Type...) %swig_sequence_methods_val(Type); + +%include <std/std_deque.i> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_except.i b/devtools/swigwin-1.3.34/Lib/ruby/std_except.i new file mode 100644 index 0000000..af98428 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_except.i @@ -0,0 +1 @@ +%include <typemaps/std_except.swg> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_functors.i b/devtools/swigwin-1.3.34/Lib/ruby/std_functors.i new file mode 100644 index 0000000..54ee97b --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_functors.i @@ -0,0 +1,29 @@ +/** + * @file std_functors.i + * @date Sun May 6 00:44:33 2007 + * + * @brief This file provides unary and binary functors for STL + * containers, that will invoke a Ruby proc or method to do + * their operation. + * + * You can use them in a swig file like: + * + * %include <std_set.i> + * %include <std_functors.i> + * + * %template< IntSet > std::set< int, swig::BinaryPredicate<int> >; + * + * + * which will then allow calling them from Ruby either like: + * + * # order of set is defined by C++ default + * a = IntSet.new + * + * # sort order defined by Ruby proc + * b = IntSet.new( proc { |a,b| a > b } ) + * + */ + +%include <rubystdfunctors.swg> + +%fragment("StdFunctors"); diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_ios.i b/devtools/swigwin-1.3.34/Lib/ruby/std_ios.i new file mode 100644 index 0000000..7aafae2 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_ios.i @@ -0,0 +1,14 @@ + +#pragma SWIG nowarn=801 + +%rename(ios_base_in) std::ios_base::in; + +AUTODOC(cerr, "Standard C++ error stream"); +AUTODOC(cout, "Standard C++ output stream"); +AUTODOC(cin, "Standard C++ input stream"); +AUTODOC(clog, "Standard C++ logging stream"); +AUTODOC(endl, "Add an end line to stream"); +AUTODOC(ends, "Ends stream"); +AUTODOC(flush, "Flush stream"); + +%include <std/std_ios.i> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_iostream.i b/devtools/swigwin-1.3.34/Lib/ruby/std_iostream.i new file mode 100644 index 0000000..ee36bec --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_iostream.i @@ -0,0 +1,12 @@ +namespace std +{ +%callback("%s") endl; +%callback("%s") ends; +%callback("%s") flush; +} + +%warnfilter(365) operator+=; +%warnfilter(802) std::basic_iostream; // turn off multiple inheritance warning + +%include <std/std_iostream.i> + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_list.i b/devtools/swigwin-1.3.34/Lib/ruby/std_list.i new file mode 100644 index 0000000..8d4284b --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_list.i @@ -0,0 +1,41 @@ +/* + Lists +*/ + +%fragment("StdListTraits","header",fragment="StdSequenceTraits") +%{ + namespace swig { + template <class T > + struct traits_asptr<std::list<T> > { + static int asptr(VALUE obj, std::list<T> **lis) { + return traits_asptr_stdseq<std::list<T> >::asptr(obj, lis); + } + }; + + template <class T> + struct traits_from<std::list<T> > { + static VALUE from(const std::list<T> & vec) { + return traits_from_stdseq<std::list<T> >::from(vec); + } + }; + } +%} + +%ignore std::list::push_back; +%ignore std::list::pop_back; + +#define %swig_list_methods(Type...) %swig_sequence_methods(Type) +#define %swig_list_methods_val(Type...) %swig_sequence_methods_val(Type); + + +%rename("delete") std::list::__delete__; +%rename("reject!") std::list::reject_bang; +%rename("map!") std::list::map_bang; +%rename("empty?") std::list::empty; +%rename("include?" ) std::list::__contains__ const; +%rename("has_key?" ) std::list::has_key const; + +%alias std::list::push "<<"; + +%include <std/std_list.i> + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_map.i b/devtools/swigwin-1.3.34/Lib/ruby/std_map.i new file mode 100644 index 0000000..cc22fef --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_map.i @@ -0,0 +1,417 @@ +// +// Maps +// +%fragment("StdMapTraits","header",fragment="StdSequenceTraits") +{ + namespace swig { + template <class RubySeq, class K, class T > + inline void + assign(const RubySeq& rubyseq, std::map<K,T > *map) { + typedef typename std::map<K,T>::value_type value_type; + typename RubySeq::const_iterator it = rubyseq.begin(); + for (;it != rubyseq.end(); ++it) { + map->insert(value_type(it->first, it->second)); + } + } + + template <class K, class T> + struct traits_asptr<std::map<K,T> > { + typedef std::map<K,T> map_type; + static int asptr(VALUE obj, map_type **val) { + int res = SWIG_ERROR; + if ( TYPE(obj) == T_HASH ) { + static ID id_to_a = rb_intern("to_a"); + VALUE items = rb_funcall(obj, id_to_a, 0); + res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val); + } else { + map_type *p; + res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0); + if (SWIG_IsOK(res) && val) *val = p; + } + return res; + } + }; + + template <class K, class T > + struct traits_from<std::map<K,T> > { + typedef std::map<K,T> map_type; + typedef typename map_type::const_iterator const_iterator; + typedef typename map_type::size_type size_type; + + static VALUE from(const map_type& map) { + swig_type_info *desc = swig::type_info<map_type>(); + if (desc && desc->clientdata) { + return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN); + } else { + size_type size = map.size(); + int rubysize = (size <= (size_type) INT_MAX) ? (int) size : -1; + if (rubysize < 0) { + SWIG_RUBY_THREAD_BEGIN_BLOCK; + rb_raise( rb_eRuntimeError, "map size not valid in Ruby"); + SWIG_RUBY_THREAD_END_BLOCK; + return Qnil; + } + VALUE obj = rb_hash_new(); + for (const_iterator i= map.begin(); i!= map.end(); ++i) { + VALUE key = swig::from(i->first); + VALUE val = swig::from(i->second); + rb_hash_aset(obj, key, val); + } + return obj; + } + } + }; + + template <class ValueType> + struct from_key_oper + { + typedef const ValueType& argument_type; + typedef VALUE result_type; + result_type operator()(argument_type v) const + { + return swig::from(v.first); + } + }; + + template <class ValueType> + struct from_value_oper + { + typedef const ValueType& argument_type; + typedef VALUE result_type; + result_type operator()(argument_type v) const + { + return swig::from(v.second); + } + }; + + template<class OutIterator, class FromOper, + class ValueType = typename OutIterator::value_type> + struct MapIterator_T : ConstIteratorClosed_T<OutIterator, ValueType, FromOper> + { + MapIterator_T(OutIterator curr, OutIterator first, OutIterator last, VALUE seq) + : ConstIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq) + { + } + }; + + + template<class OutIterator, + class FromOper = from_key_oper<typename OutIterator::value_type> > + struct MapKeyIterator_T : MapIterator_T<OutIterator, FromOper> + { + MapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, VALUE seq) + : MapIterator_T<OutIterator, FromOper>(curr, first, last, seq) + { + } + }; + + template<typename OutIter> + inline ConstIterator* + make_output_key_iterator(const OutIter& current, const OutIter& begin, + const OutIter& end, VALUE seq = 0) + { + return new MapKeyIterator_T<OutIter>(current, begin, end, seq); + } + + template<class OutIterator, + class FromOper = from_value_oper<typename OutIterator::value_type> > + struct MapValueIterator_T : MapIterator_T<OutIterator, FromOper> + { + MapValueIterator_T(OutIterator curr, OutIterator first, OutIterator last, VALUE seq) + : MapIterator_T<OutIterator, FromOper>(curr, first, last, seq) + { + } + }; + + + template<typename OutIter> + inline ConstIterator* + make_output_value_iterator(const OutIter& current, const OutIter& begin, + const OutIter& end, VALUE seq = 0) + { + return new MapValueIterator_T<OutIter>(current, begin, end, seq); + } + } +} + +%define %swig_map_common(Map...) + %swig_container_methods(%arg(Map)); + // %swig_sequence_iterator(%arg(Map)); + + %extend { + + VALUE __delete__(const key_type& key) { + Map::iterator i = self->find(key); + if (i != self->end()) { + self->erase(i); + return swig::from( key ); + } + else { + return Qnil; + } + } + + bool has_key(const key_type& key) const { + Map::const_iterator i = self->find(key); + return i != self->end(); + } + + VALUE keys() { + Map::size_type size = self->size(); + int rubysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; + if (rubysize < 0) { + SWIG_RUBY_THREAD_BEGIN_BLOCK; + rb_raise(rb_eRuntimeError, "map size not valid in Ruby"); + SWIG_RUBY_THREAD_END_BLOCK; + return Qnil; + } + VALUE ary = rb_ary_new2(rubysize); + Map::const_iterator i = self->begin(); + Map::const_iterator e = self->end(); + for ( ; i != e; ++i ) { + rb_ary_push( ary, swig::from(i->first) ); + } + return ary; + } + + Map* each() + { + if ( !rb_block_given_p() ) + rb_raise( rb_eArgError, "no block given"); + + VALUE k, v; + Map::iterator i = self->begin(); + Map::iterator e = self->end(); + for ( ; i != e; ++i ) + { + const Map::key_type& key = i->first; + const Map::mapped_type& val = i->second; + + k = swig::from<Map::key_type>(key); + v = swig::from<Map::mapped_type>(val); + rb_yield_values(2, k, v); + } + + return self; + } + + %newobject select; + Map* select() { + if ( !rb_block_given_p() ) + rb_raise( rb_eArgError, "no block given" ); + + Map* r = new Map; + Map::iterator i = $self->begin(); + Map::iterator e = $self->end(); + for ( ; i != e; ++i ) + { + VALUE k = swig::from<Map::key_type>(i->first); + VALUE v = swig::from<Map::mapped_type>(i->second); + if ( RTEST( rb_yield_values(2, k, v) ) ) + $self->insert(r->end(), *i); + } + + return r; + } + + %typemap(in) (int argc, VALUE* argv) { + $1 = argc; + $2 = argv; + } + + VALUE values_at(int argc, VALUE* argv, ...) { + + VALUE r = rb_ary_new(); + ID id = rb_intern("[]"); + swig_type_info* type = swig::type_info< Map >(); + VALUE me = SWIG_NewPointerObj( $self, type, 0 ); + for ( int i = 0; i < argc; ++i ) + { + VALUE key = argv[i]; + VALUE tmp = rb_funcall( me, id, 1, key ); + rb_ary_push( r, tmp ); + } + + return r; + } + + + Map* each_key() + { + if ( !rb_block_given_p() ) + rb_raise( rb_eArgError, "no block given"); + + VALUE r; + Map::iterator i = self->begin(); + Map::iterator e = self->end(); + for ( ; i != e; ++i ) + { + r = swig::from( i->first ); + rb_yield(r); + } + + return self; + } + + VALUE values() { + Map::size_type size = self->size(); + int rubysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; + if (rubysize < 0) { + SWIG_RUBY_THREAD_BEGIN_BLOCK; + rb_raise(rb_eRuntimeError, "map size not valid in Ruby"); + SWIG_RUBY_THREAD_END_BLOCK; + return Qnil; + } + VALUE ary = rb_ary_new2(rubysize); + Map::const_iterator i = self->begin(); + Map::const_iterator e = self->end(); + for ( ; i != e; ++i ) { + rb_ary_push( ary, swig::from(i->second) ); + } + return ary; + } + + Map* each_value() + { + if ( !rb_block_given_p() ) + rb_raise( rb_eArgError, "no block given"); + + VALUE r; + Map::iterator i = self->begin(); + Map::iterator e = self->end(); + for ( ; i != e; ++i ) + { + r = swig::from( i->second ); + rb_yield(r); + } + + return self; + } + + VALUE entries() { + Map::size_type size = self->size(); + int rubysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; + if (rubysize < 0) { + SWIG_RUBY_THREAD_BEGIN_BLOCK; + rb_raise(rb_eRuntimeError, "map size not valid in Ruby"); + SWIG_RUBY_THREAD_END_BLOCK; + return Qnil; + } + VALUE ary = rb_ary_new2(rubysize); + Map::const_iterator i = self->begin(); + Map::const_iterator e = self->end(); + for ( ; i != e; ++i ) { + rb_ary_push( ary, swig::from<std::pair<Map::key_type, + Map::mapped_type> >(*i) ); + } + return ary; + } + + bool __contains__(const key_type& key) { + return self->find(key) != self->end(); + } + + %newobject key_iterator(VALUE *RUBY_SELF); + swig::ConstIterator* key_iterator(VALUE *RUBY_SELF) { + return swig::make_output_key_iterator($self->begin(), $self->begin(), + $self->end(), *RUBY_SELF); + } + + %newobject value_iterator(VALUE *RUBY_SELF); + swig::ConstIterator* value_iterator(VALUE *RUBY_SELF) { + return swig::make_output_value_iterator($self->begin(), $self->begin(), + $self->end(), *RUBY_SELF); + } + + } +%enddef + +%define %swig_map_methods(Map...) + %swig_map_common(Map) + %extend { + VALUE __getitem__(const key_type& key) const { + Map::const_iterator i = self->find(key); + if ( i != self->end() ) + return swig::from<Map::mapped_type>( i->second ); + else + return Qnil; + } + + void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { + (*self)[key] = x; + } + + VALUE inspect() + { + Map::const_iterator i = $self->begin(); + Map::const_iterator e = $self->end(); + VALUE str = rb_str_new2( swig::type_name< Map >() ); + str = rb_str_cat2( str, " {" ); + bool comma = false; + VALUE tmp; + for ( ; i != e; ++i, comma = true ) + { + if (comma) str = rb_str_cat2( str, "," ); + tmp = swig::from< Map::key_type >( i->first ); + tmp = rb_inspect( tmp ); + str = rb_str_buf_append( str, tmp ); + str = rb_str_cat2( str, "=>" ); + tmp = swig::from< Map::mapped_type >( i->second ); + tmp = rb_inspect( tmp ); + str = rb_str_buf_append( str, tmp ); + } + str = rb_str_cat2( str, "}" ); + return str; + } + + VALUE to_a() + { + Map::const_iterator i = $self->begin(); + Map::const_iterator e = $self->end(); + VALUE ary = rb_ary_new2( std::distance( i, e ) ); + VALUE tmp; + for ( ; i != e; ++i ) + { + // @todo: improve -- this should just be swig::from(*i) + tmp = swig::from< std::pair<Map::key_type, + Map::mapped_type> >( *i ); + rb_ary_push( ary, tmp ); + } + return ary; + } + + VALUE to_s() + { + Map::iterator i = $self->begin(); + Map::iterator e = $self->end(); + VALUE str = rb_str_new2( "" ); + VALUE tmp; + for ( ; i != e; ++i ) + { + // @todo: improve -- this should just be swig::from(*i) + tmp = swig::from< std::pair<Map::key_type, + Map::mapped_type> >( *i ); + tmp = rb_obj_as_string( tmp ); + str = rb_str_buf_append( str, tmp ); + } + return str; + } + + } +%enddef + + +%mixin std::map "Enumerable"; + + +%rename("delete") std::map::__delete__; +%rename("reject!") std::map::reject_bang; +%rename("map!") std::map::map_bang; +%rename("empty?") std::map::empty; +%rename("include?" ) std::map::__contains__ const; +%rename("has_key?" ) std::map::has_key const; + +%alias std::map::push "<<"; + + +%include <std/std_map.i> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_multimap.i b/devtools/swigwin-1.3.34/Lib/ruby/std_multimap.i new file mode 100644 index 0000000..7fec50d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_multimap.i @@ -0,0 +1,226 @@ +/* + Multimaps +*/ +%include <std_map.i> + +%fragment("StdMultimapTraits","header",fragment="StdSequenceTraits") +{ + namespace swig { + template <class RubySeq, class K, class T > + inline void + assign(const RubySeq& rubyseq, std::multimap<K,T > *multimap) { + typedef typename std::multimap<K,T>::value_type value_type; + typename RubySeq::const_iterator it = rubyseq.begin(); + for (;it != rubyseq.end(); ++it) { + multimap->insert(value_type(it->first, it->second)); + } + } + + template <class K, class T> + struct traits_asptr<std::multimap<K,T> > { + typedef std::multimap<K,T> multimap_type; + static int asptr(VALUE obj, std::multimap<K,T> **val) { + int res = SWIG_ERROR; + if ( TYPE(obj) == T_HASH ) { + static ID id_to_a = rb_intern("to_a"); + VALUE items = rb_funcall(obj, id_to_a, 0); + return traits_asptr_stdseq<std::multimap<K,T>, std::pair<K, T> >::asptr(items, val); + } else { + multimap_type *p; + res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<multimap_type>(),0); + if (SWIG_IsOK(res) && val) *val = p; + } + return res; + } + }; + + template <class K, class T > + struct traits_from<std::multimap<K,T> > { + typedef std::multimap<K,T> multimap_type; + typedef typename multimap_type::const_iterator const_iterator; + typedef typename multimap_type::size_type size_type; + + static VALUE from(const multimap_type& multimap) { + swig_type_info *desc = swig::type_info<multimap_type>(); + if (desc && desc->clientdata) { + return SWIG_NewPointerObj(new multimap_type(multimap), desc, SWIG_POINTER_OWN); + } else { + size_type size = multimap.size(); + int rubysize = (size <= (size_type) INT_MAX) ? (int) size : -1; + if (rubysize < 0) { + SWIG_RUBY_THREAD_BEGIN_BLOCK; + rb_raise(rb_eRuntimeError, + "multimap size not valid in Ruby"); + SWIG_RUBY_THREAD_END_BLOCK; + return Qnil; + } + VALUE obj = rb_hash_new(); + for (const_iterator i= multimap.begin(); i!= multimap.end(); ++i) { + VALUE key = swig::from(i->first); + VALUE val = swig::from(i->second); + + VALUE oldval = rb_hash_aref( obj, key ); + if ( oldval == Qnil ) + rb_hash_aset(obj, key, val); + else { + // Multiple values for this key, create array if needed + // and add a new element to it. + VALUE ary; + if ( TYPE(oldval) == T_ARRAY ) + ary = oldval; + else + { + ary = rb_ary_new2(2); + rb_ary_push( ary, oldval ); + rb_hash_aset( obj, key, ary ); + } + rb_ary_push( ary, val ); + } + + } + return obj; + } + } + }; + } +} + +%define %swig_multimap_methods(MultiMap...) + %swig_map_common(%arg(MultiMap)); + + %extend { + VALUE __getitem__(const key_type& key) const { + MultiMap::const_iterator i = self->find(key); + if ( i != self->end() ) + { + MultiMap::const_iterator e = $self->upper_bound(key); + VALUE ary = rb_ary_new(); + for ( ; i != e; ++i ) + { + rb_ary_push( ary, swig::from<MultiMap::mapped_type>( i->second ) ); + } + if ( RARRAY_LEN(ary) == 1 ) + return RARRAY_PTR(ary)[0]; + return ary; + } + else + return Qnil; + } + + void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { + self->insert(MultiMap::value_type(key,x)); + } + + VALUE inspect() + { + MultiMap::iterator i = $self->begin(); + MultiMap::iterator e = $self->end(); + VALUE str = rb_str_new2( swig::type_name< MultiMap >() ); + str = rb_str_cat2( str, " {" ); + VALUE tmp; + while ( i != e ) + { + const MultiMap::key_type& key = i->first; + const MultiMap::key_type& oldkey = key; + tmp = swig::from( key ); + str = rb_str_buf_append( str, rb_inspect(tmp) ); + str = rb_str_cat2( str, "=>" ); + + VALUE vals = rb_ary_new(); + for ( ; i != e && key == oldkey; ++i ) + { + const MultiMap::mapped_type& val = i->second; + tmp = swig::from( val ); + rb_ary_push( vals, tmp ); + } + + if ( RARRAY_LEN(vals) == 1 ) + { + str = rb_str_buf_append( str, rb_inspect(tmp) ); + } + else + { + str = rb_str_buf_append( str, rb_inspect(vals) ); + } + } + str = rb_str_cat2( str, "}" ); + return str; + } + + VALUE to_a() + { + MultiMap::const_iterator i = $self->begin(); + MultiMap::const_iterator e = $self->end(); + VALUE ary = rb_ary_new2( std::distance( i, e ) ); + VALUE tmp; + while ( i != e ) + { + const MultiMap::key_type& key = i->first; + const MultiMap::key_type& oldkey = key; + tmp = swig::from( key ); + rb_ary_push( ary, tmp ); + + VALUE vals = rb_ary_new(); + for ( ; i != e && key == oldkey; ++i ) + { + const MultiMap::mapped_type& val = i->second; + tmp = swig::from( val ); + rb_ary_push( vals, tmp ); + } + + if ( RARRAY_LEN(vals) == 1 ) + { + rb_ary_push( ary, tmp ); + } + else + { + rb_ary_push( ary, vals ); + } + } + return ary; + } + + VALUE to_s() + { + MultiMap::iterator i = $self->begin(); + MultiMap::iterator e = $self->end(); + VALUE str = rb_str_new2( "" ); + VALUE tmp; + while ( i != e ) + { + const MultiMap::key_type& key = i->first; + const MultiMap::key_type& oldkey = key; + tmp = swig::from( key ); + tmp = rb_obj_as_string( tmp ); + str = rb_str_buf_append( str, tmp ); + + VALUE vals = rb_ary_new(); + for ( ; i != e && key == oldkey; ++i ) + { + const MultiMap::mapped_type& val = i->second; + tmp = swig::from( val ); + rb_ary_push( vals, tmp ); + } + + tmp = rb_obj_as_string( vals ); + str = rb_str_buf_append( str, tmp ); + } + return str; + } + } +%enddef + + +%mixin std::multimap "Enumerable"; + +%rename("delete") std::multimap::__delete__; +%rename("reject!") std::multimap::reject_bang; +%rename("map!") std::multimap::map_bang; +%rename("empty?") std::multimap::empty; +%rename("include?" ) std::multimap::__contains__ const; +%rename("has_key?" ) std::multimap::has_key const; + +%alias std::multimap::push "<<"; + +%include <std/std_multimap.i> + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_multiset.i b/devtools/swigwin-1.3.34/Lib/ruby/std_multiset.i new file mode 100644 index 0000000..01aca0a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_multiset.i @@ -0,0 +1,53 @@ +/* + Multisets +*/ + +%include <std_set.i> + +%fragment("StdMultisetTraits","header",fragment="StdSequenceTraits") +%{ + namespace swig { + template <class RubySeq, class T> + inline void + assign(const RubySeq& rubyseq, std::multiset<T>* seq) { +#ifdef SWIG_STD_NOINSERT_TEMPLATE_STL + typedef typename RubySeq::value_type value_type; + typename RubySeq::const_iterator it = rubyseq.begin(); + for (;it != rubyseq.end(); ++it) { + seq->insert(seq->end(),(value_type)(*it)); + } +#else + seq->insert(rubyseq.begin(), rubyseq.end()); +#endif + } + + template <class T> + struct traits_asptr<std::multiset<T> > { + static int asptr(VALUE obj, std::multiset<T> **m) { + return traits_asptr_stdseq<std::multiset<T> >::asptr(obj, m); + } + }; + + template <class T> + struct traits_from<std::multiset<T> > { + static VALUE from(const std::multiset<T>& vec) { + return traits_from_stdseq<std::multiset<T> >::from(vec); + } + }; + } +%} + +#define %swig_multiset_methods(Set...) %swig_set_methods(Set) + + + +%rename("delete") std::multiset::__delete__; +%rename("reject!") std::multiset::reject_bang; +%rename("map!") std::multiset::map_bang; +%rename("empty?") std::multiset::empty; +%rename("include?" ) std::multiset::__contains__ const; +%rename("has_key?" ) std::multiset::has_key const; + +%alias std::multiset::push "<<"; + +%include <std/std_multiset.i> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_pair.i b/devtools/swigwin-1.3.34/Lib/ruby/std_pair.i new file mode 100644 index 0000000..cb714e4 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_pair.i @@ -0,0 +1,207 @@ +/* + Pairs +*/ +%include <rubystdcommon.swg> + +//#define SWIG_STD_PAIR_ASVAL + +%fragment("StdPairTraits","header",fragment="StdTraits") { + namespace swig { + + template <class T, class U > + struct traits_asval<std::pair<T,U> > { + typedef std::pair<T,U> value_type; + + static int get_pair(VALUE first, VALUE second, + std::pair<T,U> *val) + { + if (val) { + T *pfirst = &(val->first); + int res1 = swig::asval((VALUE)first, pfirst); + if (!SWIG_IsOK(res1)) return res1; + U *psecond = &(val->second); + int res2 = swig::asval((VALUE)second, psecond); + if (!SWIG_IsOK(res2)) return res2; + return res1 > res2 ? res1 : res2; + } else { + T *pfirst = 0; + int res1 = swig::asval((VALUE)first, pfirst); + if (!SWIG_IsOK(res1)) return res1; + U *psecond = 0; + int res2 = swig::asval((VALUE)second, psecond); + if (!SWIG_IsOK(res2)) return res2; + return res1 > res2 ? res1 : res2; + } + } + + static int asval(VALUE obj, std::pair<T,U> *val) { + int res = SWIG_ERROR; + if ( TYPE(obj) == T_ARRAY ) { + if (RARRAY_LEN(obj) == 2) { + VALUE first = rb_ary_entry(obj,0); + VALUE second = rb_ary_entry(obj,1); + res = get_pair(first, second, val); + } + } else { + value_type *p; + res = SWIG_ConvertPtr(obj,(void**)&p, + swig::type_info<value_type>(),0); + if (SWIG_IsOK(res) && val) *val = *p; + } + return res; + } + }; + + template <class T, class U > + struct traits_asptr<std::pair<T,U> > { + typedef std::pair<T,U> value_type; + + static int get_pair(VALUE first, VALUE second, + std::pair<T,U> **val) + { + if (val) { + value_type *vp = %new_instance(std::pair<T,U>); + T *pfirst = &(vp->first); + int res1 = swig::asval((VALUE)first, pfirst); + if (!SWIG_IsOK(res1)) return res1; + U *psecond = &(vp->second); + int res2 = swig::asval((VALUE)second, psecond); + if (!SWIG_IsOK(res2)) return res2; + *val = vp; + return SWIG_AddNewMask(res1 > res2 ? res1 : res2); + } else { + T *pfirst = 0; + int res1 = swig::asval((VALUE)first, pfirst); + if (!SWIG_IsOK(res1)) return res1; + U *psecond = 0; + int res2 = swig::asval((VALUE)second, psecond); + if (!SWIG_IsOK(res2)) return res2; + return res1 > res2 ? res1 : res2; + } + } + + static int asptr(VALUE obj, std::pair<T,U> **val) { + int res = SWIG_ERROR; + if ( TYPE(obj) == T_ARRAY ) { + if ( RARRAY_LEN(obj) == 2) { + VALUE first = rb_ary_entry(obj,0); + VALUE second = rb_ary_entry(obj,1); + res = get_pair(first, second, val); + } + } else { + value_type *p; + res = SWIG_ConvertPtr(obj,(void**)&p, + swig::type_info<value_type>(),0); + if (SWIG_IsOK(res) && val) *val = p; + } + return res; + } + }; + + + + template <class T, class U > + struct traits_from<std::pair<T,U> > { + static VALUE _wrap_pair_second( VALUE self ) + { + std::pair< typename swig::noconst_traits<T >::noconst_type,U>* p = NULL; + swig::asptr( self, &p ); + return swig::from( p->second ); + } + + static VALUE _wrap_pair_second_eq( VALUE self, VALUE arg ) + { + std::pair< typename swig::noconst_traits<T >::noconst_type,U>* p = NULL; + swig::asptr( self, &p ); + return swig::from( p->second ); + } + + static VALUE from(const std::pair<T,U>& val) { + VALUE obj = rb_ary_new2(2); + RARRAY_PTR(obj)[0] = swig::from< + typename swig::noconst_traits<T >::noconst_type>(val.first); + RARRAY_PTR(obj)[1] = swig::from(val.second); + RARRAY_LEN(obj) = 2; + rb_define_singleton_method(obj, "second", + VALUEFUNC(_wrap_pair_second), 0 ); + rb_define_singleton_method(obj, "second=", + VALUEFUNC(_wrap_pair_second_eq), 1 ); + rb_obj_freeze(obj); // treat as immutable tuple + return obj; + } + }; + + } +} + +// Missing typemap +%typemap(in) std::pair* (int res) { + res = swig::asptr( $input, &$1 ); + if (!SWIG_IsOK(res)) + %argument_fail(res, "$1_type", $symname, $argnum); +} + + +%define %swig_pair_methods(pair...) + +%extend { + VALUE inspect() const + { + VALUE tmp; + VALUE str = rb_str_new2( swig::type_name< pair >() ); + str = rb_str_cat2( str, " (" ); + tmp = swig::from( $self->first ); + tmp = rb_obj_as_string( tmp ); + str = rb_str_buf_append( str, tmp ); + str = rb_str_cat2( str, "," ); + tmp = swig::from( $self->second ); + tmp = rb_obj_as_string( tmp ); + str = rb_str_buf_append( str, tmp ); + str = rb_str_cat2( str, ")" ); + return str; + } + + VALUE to_s() const + { + VALUE tmp; + VALUE str = rb_str_new2( "(" ); + tmp = swig::from( $self->first ); + tmp = rb_obj_as_string( tmp ); + str = rb_str_buf_append( str, tmp ); + str = rb_str_cat2( str, "," ); + tmp = swig::from( $self->second ); + tmp = rb_obj_as_string( tmp ); + str = rb_str_buf_append( str, tmp ); + str = rb_str_cat2( str, ")" ); + return str; + } + + VALUE __getitem__( int index ) + { + if (( index % 2 ) == 0 ) + return swig::from( $self->first ); + else + return swig::from( $self->second ); + } + + VALUE __setitem__( int index, VALUE obj ) + { + int res; + if (( index % 2 ) == 0 ) + { + res = swig::asval( obj, &($self->first) ); + } + else + { + res = swig::asval(obj, &($self->second) ); + } + if (!SWIG_IsOK(res)) + rb_raise( rb_eArgError, "invalid item for " #pair ); + return obj; + } + + } // extend + +%enddef + +%include <std/std_pair.i> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_queue.i b/devtools/swigwin-1.3.34/Lib/ruby/std_queue.i new file mode 100644 index 0000000..a129367 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_queue.i @@ -0,0 +1,33 @@ +/* + Queues +*/ + +%fragment("StdQueueTraits","header",fragment="StdSequenceTraits") +%{ + namespace swig { + template <class T> + struct traits_asptr<std::queue<T> > { + static int asptr(VALUE obj, std::queue<T> **vec) { + return traits_asptr_stdseq<std::queue<T> >::asptr(obj, vec); + } + }; + + template <class T> + struct traits_from<std::queue<T> > { + static VALUE from(const std::queue<T> & vec) { + return traits_from_stdseq<std::queue<T> >::from(vec); + } + }; + } +%} + +%rename("delete") std::queue::__delete__; +%rename("reject!") std::queue::reject_bang; +%rename("map!") std::queue::map_bang; +%rename("empty?") std::queue::empty; +%rename("include?" ) std::queue::__contains__ const; +%rename("has_key?" ) std::queue::has_key const; + +%alias std::queue::push "<<"; + +%include <std/std_queue.i> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_set.i b/devtools/swigwin-1.3.34/Lib/ruby/std_set.i new file mode 100644 index 0000000..32df256 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_set.i @@ -0,0 +1,216 @@ +/* + Sets +*/ + +%fragment("StdSetTraits","header",fragment="StdSequenceTraits") +%{ + namespace swig { + template <class RubySeq, class T> + inline void + assign(const RubySeq& rubyseq, std::set<T>* seq) { +#ifdef SWIG_STD_NOINSERT_TEMPLATE_STL + typedef typename RubySeq::value_type value_type; + typename RubySeq::const_iterator it = rubyseq.begin(); + for (;it != rubyseq.end(); ++it) { + seq->insert(seq->end(),(value_type)(*it)); + } +#else + seq->insert(rubyseq.begin(), rubyseq.end()); +#endif + } + + template <class T> + struct traits_asptr<std::set<T> > { + static int asptr(VALUE obj, std::set<T> **s) { + return traits_asptr_stdseq<std::set<T> >::asptr(obj, s); + } + }; + + template <class T> + struct traits_from<std::set<T> > { + static VALUE from(const std::set<T>& vec) { + return traits_from_stdseq<std::set<T> >::from(vec); + } + }; + + + /** + * Set Iterator class for an iterator with no end() boundaries. + * + */ + template<typename InOutIterator, + typename ValueType = typename std::iterator_traits<InOutIterator>::value_type, + typename FromOper = from_oper<ValueType>, + typename AsvalOper = asval_oper<ValueType> > + class SetIteratorOpen_T : public Iterator_T<InOutIterator> + { + public: + FromOper from; + AsvalOper asval; + typedef InOutIterator nonconst_iter; + typedef ValueType value_type; + typedef Iterator_T<nonconst_iter> base; + typedef SetIteratorOpen_T<InOutIterator, ValueType, FromOper, AsvalOper> self_type; + + public: + SetIteratorOpen_T(nonconst_iter curr, VALUE seq = Qnil) + : Iterator_T<InOutIterator>(curr, seq) + { + } + + virtual VALUE value() const { + return from(static_cast<const value_type&>(*(base::current))); + } + + // no setValue allowed + + Iterator *dup() const + { + return new self_type(*this); + } + }; + + + /** + * Set Iterator class for a iterator where begin() and end() boundaries + are known. + * + */ + template<typename InOutIterator, + typename ValueType = typename std::iterator_traits<InOutIterator>::value_type, + typename FromOper = from_oper<ValueType>, + typename AsvalOper = asval_oper<ValueType> > + class SetIteratorClosed_T : public Iterator_T<InOutIterator> + { + public: + FromOper from; + AsvalOper asval; + typedef InOutIterator nonconst_iter; + typedef ValueType value_type; + typedef Iterator_T<nonconst_iter> base; + typedef SetIteratorClosed_T<InOutIterator, ValueType, FromOper, AsvalOper> self_type; + + protected: + virtual Iterator* advance(ptrdiff_t n) + { + std::advance( base::current, n ); + if ( base::current == end ) + throw stop_iteration(); + return this; + } + + public: + SetIteratorClosed_T(nonconst_iter curr, nonconst_iter first, + nonconst_iter last, VALUE seq = Qnil) + : Iterator_T<InOutIterator>(curr, seq), begin(first), end(last) + { + } + + virtual VALUE value() const { + if (base::current == end) { + throw stop_iteration(); + } else { + return from(static_cast<const value_type&>(*(base::current))); + } + } + + // no setValue allowed + + + Iterator *dup() const + { + return new self_type(*this); + } + + private: + nonconst_iter begin; + nonconst_iter end; + }; + + // Template specialization to construct a closed iterator for sets + // this turns a nonconst iterator into a const one for ruby to avoid + // allowing the user to change the value + template< typename InOutIter > + inline Iterator* + make_set_nonconst_iterator(const InOutIter& current, + const InOutIter& begin, + const InOutIter& end, + VALUE seq = Qnil) + { + return new SetIteratorClosed_T< InOutIter >(current, + begin, end, seq); + } + + // Template specialization to construct an open iterator for sets + // this turns a nonconst iterator into a const one for ruby to avoid + // allowing the user to change the value + template< typename InOutIter > + inline Iterator* + make_set_nonconst_iterator(const InOutIter& current, + VALUE seq = Qnil) + { + return new SetIteratorOpen_T< InOutIter >(current, seq); + } + + } +%} + + +%define %swig_set_methods(set...) + + %swig_sequence_methods_common(%arg(set)); + + %fragment("RubyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="RubySequence_Cont") {} + +// Redefine std::set iterator/reverse_iterator typemap +%typemap(out,noblock=1) iterator, reverse_iterator { + $result = SWIG_NewPointerObj(swig::make_set_nonconst_iterator(%static_cast($1,const $type &), + self), + swig::Iterator::descriptor(),SWIG_POINTER_OWN); + } + +// Redefine std::set std::pair<iterator, bool> typemap + %typemap(out,noblock=1,fragment="RubyPairBoolOutputIterator") + std::pair<iterator, bool> { + $result = rb_ary_new2(2); + RARRAY_PTR($result)[0] = SWIG_NewPointerObj(swig::make_set_nonconst_iterator(%static_cast($1,$type &).first), + swig::Iterator::descriptor(),SWIG_POINTER_OWN); + RARRAY_PTR($result)[1] = SWIG_From(bool)(%static_cast($1,const $type &).second); + RARRAY_LEN($result) = 2; + } + + %extend { + %alias push "<<"; + value_type push(const value_type& x) { + self->insert(x); + return x; + } + + bool __contains__(const value_type& x) { + return self->find(x) != self->end(); + } + + value_type __getitem__(difference_type i) const throw (std::out_of_range) { + return *(swig::cgetpos(self, i)); + } + + }; +%enddef + + +%mixin std::set "Enumerable"; + + + +%rename("delete") std::set::__delete__; +%rename("reject!") std::set::reject_bang; +%rename("map!") std::set::map_bang; +%rename("empty?") std::set::empty; +%rename("include?" ) std::set::__contains__ const; +%rename("has_key?" ) std::set::has_key const; + +%alias std::set::push "<<"; + + +%include <std/std_set.i> + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_sstream.i b/devtools/swigwin-1.3.34/Lib/ruby/std_sstream.i new file mode 100644 index 0000000..537a3ae --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_sstream.i @@ -0,0 +1,2 @@ + +%include <std/std_sstream.i> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_stack.i b/devtools/swigwin-1.3.34/Lib/ruby/std_stack.i new file mode 100644 index 0000000..600c81c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_stack.i @@ -0,0 +1,35 @@ +/* + Stacks +*/ + +%fragment("StdStackTraits","header",fragment="StdSequenceTraits") +%{ + namespace swig { + template <class T> + struct traits_asptr<std::stack<T> > { + static int asptr(VALUE obj, std::stack<T> **vec) { + return traits_asptr_stdseq<std::stack<T> >::asptr(obj, vec); + } + }; + + template <class T> + struct traits_from<std::stack<T> > { + static VALUE from(const std::stack<T> & vec) { + return traits_from_stdseq<std::stack<T> >::from(vec); + } + }; + } +%} + + +%rename("delete") std::stack::__delete__; +%rename("reject!") std::stack::reject_bang; +%rename("map!") std::stack::map_bang; +%rename("empty?") std::stack::empty; +%rename("include?" ) std::stack::__contains__ const; +%rename("has_key?" ) std::stack::has_key const; + +%alias std::stack::push "<<"; + + +%include <std/std_stack.i> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_streambuf.i b/devtools/swigwin-1.3.34/Lib/ruby/std_streambuf.i new file mode 100644 index 0000000..44b9bb4 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_streambuf.i @@ -0,0 +1 @@ +%include <std/std_streambuf.i> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_string.i b/devtools/swigwin-1.3.34/Lib/ruby/std_string.i new file mode 100644 index 0000000..cac4324 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_string.i @@ -0,0 +1,9 @@ + +%warnfilter(801) std::string; // wrong class name +%warnfilter(378) std::basic_string::operator!=; + + +AUTODOC(substr, "Return a portion of the String"); + +%include <typemaps/std_string.swg> + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_vector.i b/devtools/swigwin-1.3.34/Lib/ruby/std_vector.i new file mode 100644 index 0000000..67fdcd1 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_vector.i @@ -0,0 +1,52 @@ +/* + Vectors +*/ + +%fragment("StdVectorTraits","header",fragment="StdSequenceTraits") +%{ + namespace swig { + template <class T> + struct traits_asptr<std::vector<T> > { + static int asptr(VALUE obj, std::vector<T> **vec) { + return traits_asptr_stdseq<std::vector<T> >::asptr(obj, vec); + } + }; + + template <class T> + struct traits_from<std::vector<T> > { + static VALUE from(const std::vector<T>& vec) { + return traits_from_stdseq<std::vector<T> >::from(vec); + } + }; + } +%} + + + +%define %swig_vector_methods(Type...) + %swig_sequence_methods(Type) + %swig_sequence_front_inserters(Type); +%enddef + +%define %swig_vector_methods_val(Type...) + %swig_sequence_methods_val(Type); + %swig_sequence_front_inserters(Type); +%enddef + + +%mixin std::vector "Enumerable"; +%ignore std::vector::push_back; +%ignore std::vector::pop_back; + + +%rename("delete") std::vector::__delete__; +%rename("reject!") std::vector::reject_bang; +%rename("map!") std::vector::map_bang; +%rename("empty?") std::vector::empty; +%rename("include?" ) std::vector::__contains__ const; +%rename("has_key?" ) std::vector::has_key const; + +%alias std::vector::push "<<"; + +%include <std/std_vector.i> + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_vectora.i b/devtools/swigwin-1.3.34/Lib/ruby/std_vectora.i new file mode 100644 index 0000000..1708361 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_vectora.i @@ -0,0 +1,36 @@ +/* + Vectors + allocators +*/ + +%fragment("StdVectorATraits","header",fragment="StdSequenceTraits") +%{ + namespace swig { + template <class T, class A> + struct traits_asptr<std::vector<T,A> > { + typedef std::vector<T,A> vector_type; + typedef T value_type; + static int asptr(VALUE obj, vector_type **vec) { + return traits_asptr_stdseq<vector_type>::asptr(obj, vec); + } + }; + + template <class T, class A> + struct traits_from<std::vector<T,A> > { + typedef std::vector<T,A> vector_type; + static VALUE from(const vector_type& vec) { + return traits_from_stdseq<vector_type>::from(vec); + } + }; + } +%} + + +#define %swig_vector_methods(Type...) %swig_sequence_methods(Type) +#define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type); + +%mixin std::vector "Enumerable"; +%ignore std::vector::push_back; +%ignore std::vector::pop_back; +%alias std::vector::push "<<"; + +%include <std/std_vectora.i> diff --git a/devtools/swigwin-1.3.34/Lib/ruby/std_wstring.i b/devtools/swigwin-1.3.34/Lib/ruby/std_wstring.i new file mode 100644 index 0000000..5ca77c0 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/std_wstring.i @@ -0,0 +1,3 @@ +%include <rubywstrings.swg> +%include <typemaps/std_wstring.swg> + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/stl.i b/devtools/swigwin-1.3.34/Lib/ruby/stl.i new file mode 100644 index 0000000..66b72e0 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/stl.i @@ -0,0 +1,15 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * stl.i + * + * Initial STL definition. extended as needed in each language + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <std_string.i> +%include <std_vector.i> +%include <std_map.i> +%include <std_pair.i> + diff --git a/devtools/swigwin-1.3.34/Lib/ruby/timeval.i b/devtools/swigwin-1.3.34/Lib/ruby/timeval.i new file mode 100644 index 0000000..91b5691 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/timeval.i @@ -0,0 +1,64 @@ +/* + struct timeval * + time_t + + Ruby has builtin class Time. INPUT/OUTPUT typemap for timeval and + time_t is provided. + +*/ +%{ +#ifdef __cplusplus +extern "C" { +#endif +#ifdef HAVE_SYS_TIME_H +# include <sys/time.h> +struct timeval rb_time_timeval(VALUE); +#endif +#ifdef __cplusplus +} +#endif +%} + +%typemap(in) struct timeval *INPUT (struct timeval temp) +{ + if (NIL_P($input)) + $1 = NULL; + else { + temp = rb_time_timeval($input); + $1 = &temp; + } +} + +%typemap(in,numinputs=0) struct timeval *OUTPUT(struct timeval temp) +{ + $1 = &temp; +} + +%typemap(argout) struct timeval *OUTPUT +{ + $result = rb_time_new($1->tv_sec, $1->tv_usec); +} + +%typemap(out) struct timeval * +{ + $result = rb_time_new($1->tv_sec, $1->tv_usec); +} + +%typemap(out) struct timespec * +{ + $result = rb_time_new($1->tv_sec, $1->tv_nsec / 1000); +} + +// time_t +%typemap(in) time_t +{ + if (NIL_P($input)) + $1 = (time_t)-1; + else + $1 = NUM2LONG(rb_funcall($input, rb_intern("tv_sec"), 0)); +} + +%typemap(out) time_t +{ + $result = rb_time_new($1, 0); +} diff --git a/devtools/swigwin-1.3.34/Lib/ruby/typemaps.i b/devtools/swigwin-1.3.34/Lib/ruby/typemaps.i new file mode 100644 index 0000000..2492e2e --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ruby/typemaps.i @@ -0,0 +1,317 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * typemaps.i + * + * Pointer handling + * + * These mappings provide support for input/output arguments and + * common uses for C/C++ pointers. INOUT mappings allow for C/C++ + * pointer variables in addition to input/output arguments. + * ----------------------------------------------------------------------------- */ + +#if !defined(SWIG_USE_OLD_TYPEMAPS) +%include <typemaps/typemaps.swg> +#else + +/* +The SWIG typemap library provides a language independent mechanism for +supporting output arguments, input values, and other C function +calling mechanisms. The primary use of the library is to provide a +better interface to certain C function--especially those involving +pointers. +*/ + +// ------------------------------------------------------------------------ +// Pointer handling +// +// These mappings provide support for input/output arguments and common +// uses for C/C++ pointers. +// ------------------------------------------------------------------------ + +// INPUT typemaps. +// These remap a C pointer to be an "INPUT" value which is passed by value +// instead of reference. + +/* +The following methods can be applied to turn a pointer into a simple +"input" value. That is, instead of passing a pointer to an object, +you would use a real value instead. + + int *INPUT + short *INPUT + long *INPUT + long long *INPUT + unsigned int *INPUT + unsigned short *INPUT + unsigned long *INPUT + unsigned long long *INPUT + unsigned char *INPUT + bool *INPUT + float *INPUT + double *INPUT + +To use these, suppose you had a C function like this : + + double fadd(double *a, double *b) { + return *a+*b; + } + +You could wrap it with SWIG as follows : + + %include typemaps.i + double fadd(double *INPUT, double *INPUT); + +or you can use the %apply directive : + + %include typemaps.i + %apply double *INPUT { double *a, double *b }; + double fadd(double *a, double *b); + +*/ + +%define INPUT_TYPEMAP(type, converter) +%typemap(in) type *INPUT($*1_ltype temp), type &INPUT($*1_ltype temp) +{ + temp = ($*1_ltype) converter($input); + $1 = &temp; +} +%typemap(typecheck) type *INPUT = type; +%typemap(typecheck) type &INPUT = type; +%enddef + +INPUT_TYPEMAP(float, NUM2DBL); +INPUT_TYPEMAP(double, NUM2DBL); +INPUT_TYPEMAP(int, NUM2INT); +INPUT_TYPEMAP(short, NUM2SHRT); +INPUT_TYPEMAP(long, NUM2LONG); +INPUT_TYPEMAP(long long, NUM2LL); +INPUT_TYPEMAP(unsigned int, NUM2UINT); +INPUT_TYPEMAP(unsigned short, NUM2USHRT); +INPUT_TYPEMAP(unsigned long, NUM2ULONG); +INPUT_TYPEMAP(unsigned long long, NUM2ULL); +INPUT_TYPEMAP(unsigned char, NUM2UINT); +INPUT_TYPEMAP(signed char, NUM2INT); +INPUT_TYPEMAP(bool, RTEST); + +#undef INPUT_TYPEMAP + +// OUTPUT typemaps. These typemaps are used for parameters that +// are output only. The output value is appended to the result as +// a array element. + +/* +The following methods can be applied to turn a pointer into an "output" +value. When calling a function, no input value would be given for +a parameter, but an output value would be returned. In the case of +multiple output values, they are returned in the form of a Ruby Array. + + int *OUTPUT + short *OUTPUT + long *OUTPUT + long long *OUTPUT + unsigned int *OUTPUT + unsigned short *OUTPUT + unsigned long *OUTPUT + unsigned long long *OUTPUT + unsigned char *OUTPUT + bool *OUTPUT + float *OUTPUT + double *OUTPUT + +For example, suppose you were trying to wrap the modf() function in the +C math library which splits x into integral and fractional parts (and +returns the integer part in one of its parameters).K: + + double modf(double x, double *ip); + +You could wrap it with SWIG as follows : + + %include typemaps.i + double modf(double x, double *OUTPUT); + +or you can use the %apply directive : + + %include typemaps.i + %apply double *OUTPUT { double *ip }; + double modf(double x, double *ip); + +The Ruby output of the function would be a Array containing both +output values. +*/ + +%define OUTPUT_TYPEMAP(type, converter, convtype) +%typemap(in,numinputs=0) type *OUTPUT($*1_ltype temp), type &OUTPUT($*1_ltype temp) "$1 = &temp;"; +%typemap(argout, fragment="output_helper") type *OUTPUT, type &OUTPUT { + VALUE o = converter(convtype (*$1)); + $result = output_helper($result, o); +} +%enddef + +OUTPUT_TYPEMAP(int, INT2NUM, (int)); +OUTPUT_TYPEMAP(short, INT2NUM, (int)); +OUTPUT_TYPEMAP(long, INT2NUM, (long)); +OUTPUT_TYPEMAP(long long, LL2NUM, (long long)); +OUTPUT_TYPEMAP(unsigned int, UINT2NUM, (unsigned int)); +OUTPUT_TYPEMAP(unsigned short, UINT2NUM, (unsigned int)); +OUTPUT_TYPEMAP(unsigned long, UINT2NUM, (unsigned long)); +OUTPUT_TYPEMAP(unsigned long long, ULL2NUM, (unsigned long long)); +OUTPUT_TYPEMAP(unsigned char, UINT2NUM, (unsigned int)); +OUTPUT_TYPEMAP(signed char, INT2NUM, (int)); +OUTPUT_TYPEMAP(float, rb_float_new, (double)); +OUTPUT_TYPEMAP(double, rb_float_new, (double)); + +#undef OUTPUT_TYPEMAP + +%typemap(in,numinputs=0) bool *OUTPUT(bool temp), bool &OUTPUT(bool temp) "$1 = &temp;"; +%typemap(argout, fragment="output_helper") bool *OUTPUT, bool &OUTPUT { + VALUE o = (*$1) ? Qtrue : Qfalse; + $result = output_helper($result, o); +} + +// INOUT +// Mappings for an argument that is both an input and output +// parameter + +/* +The following methods can be applied to make a function parameter both +an input and output value. This combines the behavior of both the +"INPUT" and "OUTPUT" methods described earlier. Output values are +returned in the form of a Ruby array. + + int *INOUT + short *INOUT + long *INOUT + long long *INOUT + unsigned int *INOUT + unsigned short *INOUT + unsigned long *INOUT + unsigned long long *INOUT + unsigned char *INOUT + bool *INOUT + float *INOUT + double *INOUT + +For example, suppose you were trying to wrap the following function : + + void neg(double *x) { + *x = -(*x); + } + +You could wrap it with SWIG as follows : + + %include typemaps.i + void neg(double *INOUT); + +or you can use the %apply directive : + + %include typemaps.i + %apply double *INOUT { double *x }; + void neg(double *x); + +Unlike C, this mapping does not directly modify the input value (since +this makes no sense in Ruby). Rather, the modified input value shows +up as the return value of the function. Thus, to apply this function +to a Ruby variable you might do this : + + x = neg(x) + +Note : previous versions of SWIG used the symbol 'BOTH' to mark +input/output arguments. This is still supported, but will be slowly +phased out in future releases. + +*/ + +%typemap(in) int *INOUT = int *INPUT; +%typemap(in) short *INOUT = short *INPUT; +%typemap(in) long *INOUT = long *INPUT; +%typemap(in) long long *INOUT = long long *INPUT; +%typemap(in) unsigned *INOUT = unsigned *INPUT; +%typemap(in) unsigned short *INOUT = unsigned short *INPUT; +%typemap(in) unsigned long *INOUT = unsigned long *INPUT; +%typemap(in) unsigned long long *INOUT = unsigned long long *INPUT; +%typemap(in) unsigned char *INOUT = unsigned char *INPUT; +%typemap(in) signed char *INOUT = signed char *INPUT; +%typemap(in) bool *INOUT = bool *INPUT; +%typemap(in) float *INOUT = float *INPUT; +%typemap(in) double *INOUT = double *INPUT; + +%typemap(in) int &INOUT = int &INPUT; +%typemap(in) short &INOUT = short &INPUT; +%typemap(in) long &INOUT = long &INPUT; +%typemap(in) long long &INOUT = long long &INPUT; +%typemap(in) unsigned &INOUT = unsigned &INPUT; +%typemap(in) unsigned short &INOUT = unsigned short &INPUT; +%typemap(in) unsigned long &INOUT = unsigned long &INPUT; +%typemap(in) unsigned long long &INOUT = unsigned long long &INPUT; +%typemap(in) unsigned char &INOUT = unsigned char &INPUT; +%typemap(in) signed char &INOUT = signed char &INPUT; +%typemap(in) bool &INOUT = bool &INPUT; +%typemap(in) float &INOUT = float &INPUT; +%typemap(in) double &INOUT = double &INPUT; + +%typemap(argout) int *INOUT = int *OUTPUT; +%typemap(argout) short *INOUT = short *OUTPUT; +%typemap(argout) long *INOUT = long *OUTPUT; +%typemap(argout) long long *INOUT = long long *OUTPUT; +%typemap(argout) unsigned *INOUT = unsigned *OUTPUT; +%typemap(argout) unsigned short *INOUT = unsigned short *OUTPUT; +%typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT; +%typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT; +%typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT; +%typemap(argout) signed char *INOUT = signed char *OUTPUT; +%typemap(argout) bool *INOUT = bool *OUTPUT; +%typemap(argout) float *INOUT = float *OUTPUT; +%typemap(argout) double *INOUT = double *OUTPUT; + +%typemap(argout) int &INOUT = int &OUTPUT; +%typemap(argout) short &INOUT = short &OUTPUT; +%typemap(argout) long &INOUT = long &OUTPUT; +%typemap(argout) long long &INOUT = long long &OUTPUT; +%typemap(argout) unsigned &INOUT = unsigned &OUTPUT; +%typemap(argout) unsigned short &INOUT = unsigned short &OUTPUT; +%typemap(argout) unsigned long &INOUT = unsigned long &OUTPUT; +%typemap(argout) unsigned long long &INOUT = unsigned long long &OUTPUT; +%typemap(argout) unsigned char &INOUT = unsigned char &OUTPUT; +%typemap(argout) signed char &INOUT = signed char &OUTPUT; +%typemap(argout) bool &INOUT = bool &OUTPUT; +%typemap(argout) float &INOUT = float &OUTPUT; +%typemap(argout) double &INOUT = double &OUTPUT; + +/* Overloading information */ + +%typemap(typecheck) double *INOUT = double; +%typemap(typecheck) signed char *INOUT = signed char; +%typemap(typecheck) unsigned char *INOUT = unsigned char; +%typemap(typecheck) unsigned long *INOUT = unsigned long; +%typemap(typecheck) unsigned long long *INOUT = unsigned long long; +%typemap(typecheck) unsigned short *INOUT = unsigned short; +%typemap(typecheck) unsigned int *INOUT = unsigned int; +%typemap(typecheck) long *INOUT = long; +%typemap(typecheck) long long *INOUT = long long; +%typemap(typecheck) short *INOUT = short; +%typemap(typecheck) int *INOUT = int; +%typemap(typecheck) float *INOUT = float; + +%typemap(typecheck) double &INOUT = double; +%typemap(typecheck) signed char &INOUT = signed char; +%typemap(typecheck) unsigned char &INOUT = unsigned char; +%typemap(typecheck) unsigned long &INOUT = unsigned long; +%typemap(typecheck) unsigned long long &INOUT = unsigned long long; +%typemap(typecheck) unsigned short &INOUT = unsigned short; +%typemap(typecheck) unsigned int &INOUT = unsigned int; +%typemap(typecheck) long &INOUT = long; +%typemap(typecheck) long long &INOUT = long long; +%typemap(typecheck) short &INOUT = short; +%typemap(typecheck) int &INOUT = int; +%typemap(typecheck) float &INOUT = float; + +#endif + +// -------------------------------------------------------------------- +// Special types +// -------------------------------------------------------------------- +%include <progargcargv.i> +%include <file.i> +%include <timeval.i> diff --git a/devtools/swigwin-1.3.34/Lib/runtime.swg b/devtools/swigwin-1.3.34/Lib/runtime.swg new file mode 100644 index 0000000..1528a52 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/runtime.swg @@ -0,0 +1,38 @@ +/* -----------------------------------------------------------------------------* + Standard SWIG API for use inside user code. + + Don't include this file directly, run the command + swig -python -external-runtime + Also, read the Modules chapter of the SWIG Manual. + + * -----------------------------------------------------------------------------*/ + +#ifdef SWIG_MODULE_CLIENTDATA_TYPE + +SWIGRUNTIMEINLINE swig_type_info * +SWIG_TypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) { + swig_module_info *module = SWIG_GetModule(clientdata); + return SWIG_TypeQueryModule(module, module, name); +} + +SWIGRUNTIMEINLINE swig_type_info * +SWIG_MangledTypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) { + swig_module_info *module = SWIG_GetModule(clientdata); + return SWIG_MangledTypeQueryModule(module, module, name); +} + +#else + +SWIGRUNTIMEINLINE swig_type_info * +SWIG_TypeQuery(const char *name) { + swig_module_info *module = SWIG_GetModule(NULL); + return SWIG_TypeQueryModule(module, module, name); +} + +SWIGRUNTIMEINLINE swig_type_info * +SWIG_MangledTypeQuery(const char *name) { + swig_module_info *module = SWIG_GetModule(NULL); + return SWIG_MangledTypeQueryModule(module, module, name); +} + +#endif diff --git a/devtools/swigwin-1.3.34/Lib/shared_ptr.i b/devtools/swigwin-1.3.34/Lib/shared_ptr.i new file mode 100644 index 0000000..0ccce64 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/shared_ptr.i @@ -0,0 +1,57 @@ +// shared_ptr namespaces could be boost or std or std::tr1 +#if !defined(SWIG_SHARED_PTR_NAMESPACE) +# define SWIG_SHARED_PTR_NAMESPACE boost +#endif + +#if defined(SWIG_SHARED_PTR_SUBNAMESPACE) +# define SWIG_SHARED_PTR_QNAMESPACE SWIG_SHARED_PTR_NAMESPACE::SWIG_SHARED_PTR_SUBNAMESPACE +#else +# define SWIG_SHARED_PTR_QNAMESPACE SWIG_SHARED_PTR_NAMESPACE +#endif + +namespace SWIG_SHARED_PTR_NAMESPACE { +#if defined(SWIG_SHARED_PTR_SUBNAMESPACE) + namespace SWIG_SHARED_PTR_SUBNAMESPACE { +#endif + template <class T> class shared_ptr { + }; +#if defined(SWIG_SHARED_PTR_SUBNAMESPACE) + } +#endif +} + +%fragment("SWIG_null_deleter", "header") { +struct SWIG_null_deleter { + void operator() (void const *) const { + } +}; +%#define SWIG_NO_NULL_DELETER_0 , SWIG_null_deleter() +%#define SWIG_NO_NULL_DELETER_1 +%#define SWIG_NO_NULL_DELETER_SWIG_POINTER_NEW +%#define SWIG_NO_NULL_DELETER_SWIG_POINTER_OWN +} + + +// Main user macro for defining shared_ptr typemaps for both const and non-const pointer types +// For plain classes, do not use for derived classes +%define SWIG_SHARED_PTR(PROXYCLASS, TYPE...) +SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, , TYPE) +SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, const, TYPE) +%enddef + +// Main user macro for defining shared_ptr typemaps for both const and non-const pointer types +// For derived classes +%define SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...) +SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, , TYPE) +SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, const, TYPE) +%types(SWIG_SHARED_PTR_NAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE >) %{ + *newmemory = SWIG_CAST_NEW_MEMORY; + return (void *) new SWIG_SHARED_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_NAMESPACE::shared_ptr< TYPE > *)$from); + %} +%extend TYPE { + static SWIG_SHARED_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_NAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) { + return swigSharedPtrUpcast; + } +} +%enddef + diff --git a/devtools/swigwin-1.3.34/Lib/std/README b/devtools/swigwin-1.3.34/Lib/std/README new file mode 100644 index 0000000..5cd759d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/README @@ -0,0 +1,22 @@ +/* ----------------------------------------------------------------------------- + * C++ STD + STL + * ----------------------------------------------------------------------------- */ + +std_common.i general common code +std_container.i general container code +std_basic_string.i basic string +std_char_traits.i char traits +std_complex.i complex +std_deque.i deque +std_except.i exceptions +std_ios.i ios +std_iostream.i istream/ostream +std_list.i list +std_map.i map +std_multimap.i multimap +std_multiset.i multiset +std_pair.i pair +std_set.i set +std_streambuf.i streambuf +std_vector.i vector +std_vectora.i vector + allocator diff --git a/devtools/swigwin-1.3.34/Lib/std/_std_deque.i b/devtools/swigwin-1.3.34/Lib/std/_std_deque.i new file mode 100644 index 0000000..026f373 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/_std_deque.i @@ -0,0 +1,126 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * _std_deque.i + * + * This file contains a generic definition of std::deque along with + * some helper functions. Specific language modules should include + * this file to generate wrappers. + * ----------------------------------------------------------------------------- */ + +%include <std_except.i> + +%{ +#include <deque> +#include <stdexcept> +%} + + +/* This macro defines all of the standard methods for a deque. This + is defined as a macro to simplify the task of specialization. For + example, + + template<> class deque<int> { + public: + %std_deque_methods(int); + }; +*/ + +%define %std_deque_methods(T) + typedef T &reference; + typedef const T& const_reference; + + deque(); + deque(unsigned int size, const T& value=T()); + deque(const deque<T> &); + ~deque(); + + void assign(unsigned int n, const T& value); + void swap(deque<T> &x); + unsigned int size() const; + unsigned int max_size() const; + void resize(unsigned int n, T c = T()); + bool empty() const; + const_reference front(); + const_reference back(); + void push_front(const T& x); + void push_back(const T& x); + void pop_front(); + void pop_back(); + void clear(); + + /* Some useful extensions */ + %extend { + const_reference getitem(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i<0) i += size; + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("deque index out of range"); + } + void setitem(int i, const T& x) throw (std::out_of_range) { + int size = int(self->size()); + if (i<0) i+= size; + if (i>=0 && i<size) + (*self)[i] = x; + else + throw std::out_of_range("deque index out of range"); + } + void delitem(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i<0) i+= size; + if (i>=0 && i<size) { + self->erase(self->begin()+i); + } else { + throw std::out_of_range("deque index out of range"); + } + } + std::deque<T> getslice(int i, int j) { + int size = int(self->size()); + if (i<0) i = size+i; + if (j<0) j = size+j; + if (i<0) i = 0; + if (j>size) j = size; + std::deque<T > tmp(j-i); + std::copy(self->begin()+i,self->begin()+j,tmp.begin()); + return tmp; + } + void setslice(int i, int j, const std::deque<T>& v) { + int size = int(self->size()); + if (i<0) i = size+i; + if (j<0) j = size+j; + if (i<0) i = 0; + if (j>size) j = size; + if (int(v.size()) == j-i) { + std::copy(v.begin(),v.end(),self->begin()+i); + } else { + self->erase(self->begin()+i,self->begin()+j); + if (i+1 <= size) + self->insert(self->begin()+i+1,v.begin(),v.end()); + else + self->insert(self->end(),v.begin(),v.end()); + } + } + void delslice(int i, int j) { + int size = int(self->size()); + if (i<0) i = size+i; + if (j<0) j = size+j; + if (i<0) i = 0; + if (j>size) j = size; + self->erase(self->begin()+i,self->begin()+j); + } + }; + +%enddef + +namespace std { + template<class T> class deque { + public: + %std_deque_methods(T); + }; +} + + + diff --git a/devtools/swigwin-1.3.34/Lib/std/std_alloc.i b/devtools/swigwin-1.3.34/Lib/std/std_alloc.i new file mode 100644 index 0000000..44dc8dc --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_alloc.i @@ -0,0 +1,77 @@ +namespace std +{ + /** + * @brief The "standard" allocator, as per [20.4]. + * + * The private _Alloc is "SGI" style. (See comments at the top + * of stl_alloc.h.) + * + * The underlying allocator behaves as follows. + * - __default_alloc_template is used via two typedefs + * - "__single_client_alloc" typedef does no locking for threads + * - "__alloc" typedef is threadsafe via the locks + * - __new_alloc is used for memory requests + * + * (See @link Allocators allocators info @endlink for more.) + */ + template<typename _Tp> + class allocator + { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Tp* pointer; + typedef const _Tp* const_pointer; + typedef _Tp& reference; + typedef const _Tp& const_reference; + typedef _Tp value_type; + + template<typename _Tp1> + struct rebind; + + allocator() throw(); + + allocator(const allocator&) throw(); + template<typename _Tp1> + allocator(const allocator<_Tp1>&) throw(); + ~allocator() throw(); + + + pointer + address(reference __x) const; + + + const_pointer + address(const_reference __x) const; + + + // NB: __n is permitted to be 0. The C++ standard says nothing + // about what the return value is when __n == 0. + _Tp* + allocate(size_type __n, const void* = 0); + + // __p is not permitted to be a null pointer. + void + deallocate(pointer __p, size_type __n); + + size_type + max_size() const throw(); + + void construct(pointer __p, const _Tp& __val); + void destroy(pointer __p); + }; + + template<> + class allocator<void> + { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef void* pointer; + typedef const void* const_pointer; + typedef void value_type; + + template<typename _Tp1> + struct rebind; + }; +} // namespace std diff --git a/devtools/swigwin-1.3.34/Lib/std/std_basic_string.i b/devtools/swigwin-1.3.34/Lib/std/std_basic_string.i new file mode 100644 index 0000000..7b0898a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_basic_string.i @@ -0,0 +1,270 @@ +%include <exception.i> +%include <std_container.i> +%include <std_alloc.i> +%include <std_char_traits.i> + + +%{ +#include <string> +%} + +namespace std +{ + %naturalvar basic_string; +} + + +namespace std { + + template <class _CharT, class _Traits = char_traits<_CharT>, typename _Alloc = allocator<_CharT> > + class basic_string + { +#if !defined(SWIG_STD_MODERN_STL) || defined(SWIG_STD_NOMODERN_STL) + %ignore push_back; + %ignore clear; + %ignore compare; + %ignore append; +#endif + + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _CharT value_type; + typedef value_type reference; + typedef value_type const_reference; + typedef _Alloc allocator_type; + + static const size_type npos; + +#ifdef SWIG_EXPORT_ITERATOR_METHODS + class iterator; + class reverse_iterator; + class const_iterator; + class const_reverse_iterator; +#endif + + + %traits_swigtype(_CharT); + %fragment(SWIG_Traits_frag(_CharT)); + + + basic_string(const _CharT* __s, size_type __n); + + // Capacity: + + size_type length() const; + + size_type max_size() const; + + size_type capacity() const; + + void reserve(size_type __res_arg = 0); + + + // Modifiers: + + basic_string& + append(const basic_string& __str); + + basic_string& + append(const basic_string& __str, size_type __pos, size_type __n); + + basic_string& + append(const _CharT* __s, size_type __n); + + basic_string& + append(size_type __n, _CharT __c); + + basic_string& + assign(const basic_string& __str); + + basic_string& + assign(const basic_string& __str, size_type __pos, size_type __n); + + basic_string& + assign(const _CharT* __s, size_type __n); + + basic_string& + insert(size_type __pos1, const basic_string& __str); + + basic_string& + insert(size_type __pos1, const basic_string& __str, + size_type __pos2, size_type __n); + + basic_string& + insert(size_type __pos, const _CharT* __s, size_type __n); + + basic_string& + insert(size_type __pos, size_type __n, _CharT __c); + + basic_string& + erase(size_type __pos = 0, size_type __n = npos); + + basic_string& + replace(size_type __pos, size_type __n, const basic_string& __str); + + basic_string& + replace(size_type __pos1, size_type __n1, const basic_string& __str, + size_type __pos2, size_type __n2); + + basic_string& + replace(size_type __pos, size_type __n1, const _CharT* __s, + size_type __n2); + + basic_string& + replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c); + + + size_type + copy(_CharT* __s, size_type __n, size_type __pos = 0) const; + + // String operations: + const _CharT* c_str() const; + + size_type + find(const _CharT* __s, size_type __pos, size_type __n) const; + + size_type + find(const basic_string& __str, size_type __pos = 0) const; + + size_type + find(_CharT __c, size_type __pos = 0) const; + + size_type + rfind(const basic_string& __str, size_type __pos = npos) const; + + size_type + rfind(const _CharT* __s, size_type __pos, size_type __n) const; + + size_type + rfind(_CharT __c, size_type __pos = npos) const; + + size_type + find_first_of(const basic_string& __str, size_type __pos = 0) const; + + size_type + find_first_of(const _CharT* __s, size_type __pos, size_type __n) const; + + size_type + find_first_of(_CharT __c, size_type __pos = 0) const; + + size_type + find_last_of(const basic_string& __str, size_type __pos = npos) const; + + size_type + find_last_of(const _CharT* __s, size_type __pos, size_type __n) const; + + size_type + find_last_of(_CharT __c, size_type __pos = npos) const; + + size_type + find_first_not_of(const basic_string& __str, size_type __pos = 0) const; + + size_type + find_first_not_of(const _CharT* __s, size_type __pos, + size_type __n) const; + + size_type + find_first_not_of(_CharT __c, size_type __pos = 0) const; + + size_type + find_last_not_of(const basic_string& __str, size_type __pos = npos) const; + + size_type + find_last_not_of(const _CharT* __s, size_type __pos, + size_type __n) const; + + size_type + find_last_not_of(_CharT __c, size_type __pos = npos) const; + + basic_string + substr(size_type __pos = 0, size_type __n = npos) const; + + int + compare(const basic_string& __str) const; + + int + compare(size_type __pos, size_type __n, const basic_string& __str) const; + + int + compare(size_type __pos1, size_type __n1, const basic_string& __str, + size_type __pos2, size_type __n2) const; + + + %ignore pop_back(); + %ignore front() const; + %ignore back() const; + %ignore basic_string(size_type n); + %std_sequence_methods_val(basic_string); + + + %ignore pop(); + + +#ifdef %swig_basic_string + // Add swig/language extra methods + %swig_basic_string(std::basic_string<_CharT, _Traits, _Alloc >); +#endif + +#ifdef SWIG_EXPORT_ITERATOR_METHODS + + + class iterator; + class reverse_iterator; + class const_iterator; + class const_reverse_iterator; + + + void + insert(iterator __p, size_type __n, _CharT __c); + + basic_string& + replace(iterator __i1, iterator __i2, const basic_string& __str); + + basic_string& + replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n); + + basic_string& + replace(iterator __i1, iterator __i2, size_type __n, _CharT __c); + + + basic_string& + replace(iterator __i1, iterator __i2, const _CharT* __k1, const _CharT* __k2); + + basic_string& + replace(iterator __i1, iterator __i2, const_iterator __k1, const_iterator __k2); +#endif + + basic_string& operator +=(const basic_string& v); + + %newobject __add__; + %newobject __radd__; + %extend { + + std::basic_string<_CharT,_Traits,_Alloc >* __add__(const basic_string& v) { + std::basic_string<_CharT,_Traits,_Alloc >* res = new std::basic_string<_CharT,_Traits,_Alloc >(*self); + *res += v; + return res; + } + + std::basic_string<_CharT,_Traits,_Alloc >* __radd__(const basic_string& v) { + std::basic_string<_CharT,_Traits,_Alloc >* res = new std::basic_string<_CharT,_Traits,_Alloc >(v); + *res += *self; + return res; + } + + std::basic_string<_CharT,_Traits,_Alloc > __str__() { + return *self; + } + + std::basic_ostream<_CharT, std::char_traits<_CharT> >& + __rlshift__(std::basic_ostream<_CharT, std::char_traits<_CharT> >& out) { + out << *self; + return out; + } + } + + }; +} + + diff --git a/devtools/swigwin-1.3.34/Lib/std/std_carray.swg b/devtools/swigwin-1.3.34/Lib/std/std_carray.swg new file mode 100644 index 0000000..ebb20ce --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_carray.swg @@ -0,0 +1,64 @@ +%{ +#include <algorithm> +%} + +// +// std::carray - is really an extension to the 'std' namespace. +// +// A simple fix C array wrapper, more or less as presented in +// +// "The C++ Standarf Library", by Nicolai M. Josuttis +// +// which is also derived from the example in +// +// "The C++ Programming Language", by Bjarne Stroustup. +// + +%inline %{ +namespace std { + template <class _Type, size_t _Size> + class carray + { + public: + typedef _Type value_type; + typedef size_t size_type; + + typedef _Type * iterator; + typedef const _Type * const_iterator; + + carray() { } + + carray(const carray& c) { + std::copy(c.v, c.v + size(), v); + } + + template <class _Iterator> + carray(_Iterator first, _Iterator last) { + assign(first, last); + } + + iterator begin() { return v; } + iterator end() { return v + _Size; } + + const_iterator begin() const { return v; } + const_iterator end() const { return v + _Size; } + + _Type& operator[](size_t i) { return v[i]; } + const _Type& operator[](size_t i) const { return v[i]; } + + static size_t size() { return _Size; } + + template <class _Iterator> + void assign(_Iterator first, _Iterator last) { + if (std::distance(first,last) == size()) { + std::copy(first, last, v); + } else { + throw std::length_error("bad range length"); + } + } + + private: + _Type v[_Size]; + }; +} +%} diff --git a/devtools/swigwin-1.3.34/Lib/std/std_char_traits.i b/devtools/swigwin-1.3.34/Lib/std/std_char_traits.i new file mode 100644 index 0000000..b9b4def --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_char_traits.i @@ -0,0 +1,140 @@ +%include <std_common.i> +#if defined(SWIG_WCHAR) +%include <wchar.i> +#endif + +namespace std +{ + + /// 21.1.2 Basis for explicit _Traits specialization + /// NB: That for any given actual character type this definition is + /// probably wrong. + template<class _CharT> + struct char_traits + { + }; + + + /// 21.1.4 char_traits specializations + template<> + struct char_traits<char> { + typedef char char_type; + typedef int int_type; + typedef streampos pos_type; + typedef streamoff off_type; + typedef mbstate_t state_type; + + static void + assign(char_type& __c1, const char_type& __c2); + + static bool + eq(const char_type& __c1, const char_type& __c2); + + static bool + lt(const char_type& __c1, const char_type& __c2); + + static int + compare(const char_type* __s1, const char_type* __s2, size_t __n); + + static size_t + length(const char_type* __s); + + static const char_type* + find(const char_type* __s, size_t __n, const char_type& __a); + + static char_type* + move(char_type* __s1, const char_type* __s2, size_t __n); + + static char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n); + + static char_type* + assign(char_type* __s, size_t __n, char_type __a); + + static char_type + to_char_type(const int_type& __c); + + // To keep both the byte 0xff and the eof symbol 0xffffffff + // from ending up as 0xffffffff. + static int_type + to_int_type(const char_type& __c); + + static bool + eq_int_type(const int_type& __c1, const int_type& __c2); + + static int_type + eof() ; + + static int_type + not_eof(const int_type& __c); + }; + + +#if defined(SWIG_WCHAR) + template<> + struct char_traits<wchar_t> + { + typedef wchar_t char_type; + typedef wint_t int_type; + typedef streamoff off_type; + typedef wstreampos pos_type; + typedef mbstate_t state_type; + + static void + assign(char_type& __c1, const char_type& __c2); + + static bool + eq(const char_type& __c1, const char_type& __c2); + + static bool + lt(const char_type& __c1, const char_type& __c2); + + static int + compare(const char_type* __s1, const char_type* __s2, size_t __n); + + static size_t + length(const char_type* __s); + + static const char_type* + find(const char_type* __s, size_t __n, const char_type& __a); + + static char_type* + move(char_type* __s1, const char_type* __s2, int_type __n); + + static char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n); + + static char_type* + assign(char_type* __s, size_t __n, char_type __a); + + static char_type + to_char_type(const int_type& __c) ; + + static int_type + to_int_type(const char_type& __c) ; + + static bool + eq_int_type(const int_type& __c1, const int_type& __c2); + + static int_type + eof() ; + + static int_type + not_eof(const int_type& __c); + }; +#endif +} + +namespace std { +#ifndef SWIG_STL_WRAP_TRAITS +%template() char_traits<char>; +#if defined(SWIG_WCHAR) +%template() char_traits<wchar_t>; +#endif +#else +%template(char_traits_c) char_traits<char>; +#if defined(SWIG_WCHAR) +%template(char_traits_w) char_traits<wchar_t>; +#endif +#endif +} diff --git a/devtools/swigwin-1.3.34/Lib/std/std_common.i b/devtools/swigwin-1.3.34/Lib/std/std_common.i new file mode 100644 index 0000000..1a8618a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_common.i @@ -0,0 +1,244 @@ +%include <std/std_except.i> + +// +// Use the following macro with modern STL implementations +// +//#define SWIG_STD_MODERN_STL +// +// Use this to deactive the previous definition, when using gcc-2.95 +// or similar old compilers. +// +//#define SWIG_STD_NOMODERN_STL + +// Here, we identify compilers we now have problems with STL. +%{ + +#if defined(__SUNPRO_CC) && defined(_RWSTD_VER) +# define SWIG_STD_NOASSIGN_STL +# define SWIG_STD_NOINSERT_TEMPLATE_STL +# define SWIG_STD_NOITERATOR_TRAITS_STL +#endif + +#if defined(__GNUC__) +# if __GNUC__ == 2 && __GNUC_MINOR <= 96 +# define SWIG_STD_NOMODERN_STL +# endif +#endif + + +%} + +// +// Common code for supporting the STD C++ namespace +// + +%{ +#include <string> +#include <stdexcept> +%} + + +%fragment("StdIteratorTraits","header") %{ +#if !defined(SWIG_STD_NOITERATOR_TRAITS_STL) +#include <iterator> +#else +namespace std { + template <class Iterator> + struct iterator_traits { + typedef ptrdiff_t difference_type; + typedef typename Iterator::value_type value_type; + }; + +#if defined(__SUNPRO_CC) && defined(_RWSTD_VER) + template <class Iterator, class Category,class T, class Reference, class Pointer, class Distance> + struct iterator_traits<__reverse_bi_iterator<Iterator,Category,T,Reference,Pointer,Distance> > { + typedef Distance difference_type; + typedef T value_type; + }; +#endif + + template <class T> + struct iterator_traits<T*> { + typedef T value_type; + typedef ptrdiff_t difference_type; + }; + + template<typename _InputIterator> + inline typename iterator_traits<_InputIterator>::difference_type + distance(_InputIterator __first, _InputIterator __last) + { + typename iterator_traits<_InputIterator>::difference_type __n = 0; + while (__first != __last) { + ++__first; ++__n; + } + return __n; + } + +} +#endif +%} + +%fragment("StdTraitsCommon","header") %{ +namespace swig { + template <class Type> + struct noconst_traits { + typedef Type noconst_type; + }; + + template <class Type> + struct noconst_traits<const Type> { + typedef Type noconst_type; + }; + + /* + type categories + */ + struct pointer_category { }; + struct value_category { }; + + /* + General traits that provides type_name and type_info + */ + template <class Type> struct traits { }; + + template <class Type> + inline const char* type_name() { + return traits<typename noconst_traits<Type >::noconst_type >::type_name(); + } + + template <class Type> + struct traits_info { + static swig_type_info *type_query(std::string name) { + name += " *"; + return SWIG_TypeQuery(name.c_str()); + } + static swig_type_info *type_info() { + static swig_type_info *info = type_query(type_name<Type>()); + return info; + } + }; + + template <class Type> + inline swig_type_info *type_info() { + return traits_info<Type>::type_info(); + } + + /* + Partial specialization for pointers + */ + template <class Type> struct traits <Type *> { + typedef pointer_category category; + static std::string make_ptr_name(const char* name) { + std::string ptrname = name; + ptrname += " *"; + return ptrname; + } + static const char* type_name() { + static std::string name = make_ptr_name(swig::type_name<Type>()); + return name.c_str(); + } + }; + + template <class Type, class Category> + struct traits_as { }; + + template <class Type, class Category> + struct traits_check { }; + +} +%} + +/* + Generate the traits for a swigtype +*/ + +%define %traits_swigtype(Type...) +%fragment(SWIG_Traits_frag(Type),"header",fragment="StdTraits") { + namespace swig { + template <> struct traits<Type > { + typedef pointer_category category; + static const char* type_name() { return #Type; } + }; + } +} +%enddef + + + +/* + Generate the typemaps for a class that has 'value' traits +*/ + +%define %typemap_traits(Code,Type...) + %typemaps_asvalfrom(%arg(Code), + %arg(swig::asval<Type >), + %arg(swig::from), + %arg(SWIG_Traits_frag(Type)), + %arg(SWIG_Traits_frag(Type)), + Type); +%enddef + +/* + Generate the typemaps for a class that behaves more like a 'pointer' or + plain wrapped Swigtype. +*/ + +%define %typemap_traits_ptr(Code,Type...) + %typemaps_asptrfrom(%arg(Code), + %arg(swig::asptr), + %arg(swig::from), + %arg(SWIG_Traits_frag(Type)), + %arg(SWIG_Traits_frag(Type)), + Type); +%enddef + + +/* + Equality methods +*/ +%define %std_equal_methods(Type...) +%extend Type { + bool operator == (const Type& v) { + return *self == v; + } + + bool operator != (const Type& v) { + return *self != v; + } +} + +%enddef + +/* + Order methods +*/ + +%define %std_order_methods(Type...) +%extend Type { + bool operator > (const Type& v) { + return *self > v; + } + + bool operator < (const Type& v) { + return *self < v; + } + + bool operator >= (const Type& v) { + return *self >= v; + } + + bool operator <= (const Type& v) { + return *self <= v; + } +} +%enddef + +/* + Comparison methods +*/ + +%define %std_comp_methods(Type...) +%std_equal_methods(Type ) +%std_order_methods(Type ) +%enddef + diff --git a/devtools/swigwin-1.3.34/Lib/std/std_container.i b/devtools/swigwin-1.3.34/Lib/std/std_container.i new file mode 100644 index 0000000..80fb7fe --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_container.i @@ -0,0 +1,113 @@ +%include <std_common.i> +%include <exception.i> +%include <std_alloc.i> + +%{ +#include <algorithm> +%} + +// Common container methods + +%define %std_container_methods(container...) + container(); + container(const container&); + + bool empty() const; + size_type size() const; + void clear(); + + void swap(container& v); + + allocator_type get_allocator() const; + + #ifdef SWIG_EXPORT_ITERATOR_METHODS + class iterator; + class reverse_iterator; + class const_iterator; + class const_reverse_iterator; + + iterator begin(); + const_iterator begin() const; + iterator end(); + const_iterator end() const; + reverse_iterator rbegin(); + const_reverse_iterator rbegin() const; + reverse_iterator rend(); + const_reverse_iterator rend() const; + #endif + +%enddef + +// Common sequence + +%define %std_sequence_methods_common(sequence) + + %std_container_methods(%arg(sequence)); + + sequence(size_type size); + void pop_back(); + + void resize(size_type new_size); + + #ifdef SWIG_EXPORT_ITERATOR_METHODS + iterator erase(iterator pos); + iterator erase(iterator first, iterator last); + #endif + +%enddef + + +%define %std_sequence_methods(sequence) + + %std_sequence_methods_common(%arg(sequence)); + + sequence(size_type size, const value_type& value); + void push_back(const value_type& x); + + const value_type& front() const; + const value_type& back() const; + + void assign(size_type n, const value_type& x); + + void resize(size_type new_size, const value_type& x); + + #ifdef SWIG_EXPORT_ITERATOR_METHODS + iterator insert(iterator pos, const value_type& x); + void insert(iterator pos, size_type n, const value_type& x); + #endif + +%enddef + +%define %std_sequence_methods_val(sequence...) + + %std_sequence_methods_common(%arg(sequence)); + + sequence(size_type size, value_type value); + void push_back(value_type x); + + value_type front() const; + value_type back() const; + + void assign(size_type n, value_type x); + + void resize(size_type new_size, value_type x); + + #ifdef SWIG_EXPORT_ITERATOR_METHODS + iterator insert(iterator pos, value_type x); + void insert(iterator pos, size_type n, value_type x); + #endif + +%enddef + + +// +// Ignore member methods for Type with no default constructor +// +%define %std_nodefconst_type(Type...) +%feature("ignore") std::vector<Type >::vector(size_type size); +%feature("ignore") std::vector<Type >::resize(size_type size); +%feature("ignore") std::deque<Type >::deque(size_type size); +%feature("ignore") std::deque<Type >::resize(size_type size); +%feature("ignore") std::list<Type >::list(size_type size); +%feature("ignore") std::list<Type >::resize(size_type size); +%enddef diff --git a/devtools/swigwin-1.3.34/Lib/std/std_deque.i b/devtools/swigwin-1.3.34/Lib/std/std_deque.i new file mode 100644 index 0000000..a99763b --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_deque.i @@ -0,0 +1,127 @@ +// +// std::deque + +%include <std_container.i> + +// Deque + +%define %std_deque_methods(deque...) + %std_sequence_methods(deque) + + void pop_front(); + void push_front(const value_type& x); +%enddef + +%define %std_deque_methods_val(deque...) + %std_sequence_methods_val(deque) + + void pop_front(); + void push_front(value_type x); +%enddef + +// ------------------------------------------------------------------------ +// std::deque +// +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::deque<T>), f(const std::deque<T>&): +// the parameter being read-only, either a sequence or a +// previously wrapped std::deque<T> can be passed. +// -- f(std::deque<T>&), f(std::deque<T>*): +// the parameter may be modified; therefore, only a wrapped std::deque +// can be passed. +// -- std::deque<T> f(), const std::deque<T>& f(): +// the deque is returned by copy; therefore, a sequence of T:s +// is returned which is most easily used in other functions +// -- std::deque<T>& f(), std::deque<T>* f(): +// the deque is returned by reference; therefore, a wrapped std::deque +// is returned +// -- const std::deque<T>* f(), f(const std::deque<T>*): +// for consistency, they expect and return a plain deque pointer. +// ------------------------------------------------------------------------ + +%{ +#include <deque> +%} + +// exported classes + +namespace std { + + template<class _Tp, class _Alloc = allocator<_Tp> > + class deque { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Tp value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef _Alloc allocator_type; + + %traits_swigtype(_Tp); + + %fragment(SWIG_Traits_frag(std::deque<_Tp, _Alloc >), "header", + fragment=SWIG_Traits_frag(_Tp), + fragment="StdDequeTraits") { + namespace swig { + template <> struct traits<std::deque<_Tp, _Alloc > > { + typedef pointer_category category; + static const char* type_name() { + return "std::deque<" #_Tp " >"; + } + }; + } + } + + %typemap_traits_ptr(SWIG_TYPECHECK_DEQUE, std::deque<_Tp, _Alloc >); + +#ifdef %swig_deque_methods + // Add swig/language extra methods + %swig_deque_methods(std::deque<_Tp, _Alloc >); +#endif + + %std_deque_methods(deque); + }; + + template<class _Tp, class _Alloc > + class deque<_Tp*, _Alloc > { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Tp* value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type reference; + typedef value_type const_reference; + typedef _Alloc allocator_type; + + %traits_swigtype(_Tp); + + %fragment(SWIG_Traits_frag(std::deque<_Tp*, _Alloc >), "header", + fragment=SWIG_Traits_frag(_Tp), + fragment="StdDequeTraits") { + namespace swig { + template <> struct traits<std::deque<_Tp*, _Alloc > > { + typedef value_category category; + static const char* type_name() { + return "std::deque<" #_Tp " * >"; + } + }; + } + } + + %typemap_traits_ptr(SWIG_TYPECHECK_DEQUE, std::deque<_Tp*, _Alloc >); + +#ifdef %swig_deque_methods_val + // Add swig/language extra methods + %swig_deque_methods_val(std::deque<_Tp*, _Alloc >); +#endif + + %std_deque_methods_val(std::deque<_Tp*, _Alloc >); + }; + +} + diff --git a/devtools/swigwin-1.3.34/Lib/std/std_except.i b/devtools/swigwin-1.3.34/Lib/std/std_except.i new file mode 100644 index 0000000..75b8d0f --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_except.i @@ -0,0 +1,68 @@ +#if defined(SWIGJAVA) || defined(SWIGCSHARP) +#error "do not use this version of std_except.i" +#endif + +%{ +#include <stdexcept> +%} + +#if defined(SWIG_STD_EXCEPTIONS_AS_CLASSES) + +namespace std { + struct exception + { + virtual ~exception() throw(); + virtual const char* what() const throw(); + }; + + struct bad_exception : exception + { + }; + + struct logic_error : exception + { + logic_error(const string& msg); + }; + + struct domain_error : logic_error + { + domain_error(const string& msg); + }; + + struct invalid_argument : logic_error + { + invalid_argument(const string& msg); + }; + + struct length_error : logic_error + { + length_error(const string& msg); + }; + + struct out_of_range : logic_error + { + out_of_range(const string& msg); + }; + + struct runtime_error : exception + { + runtime_error(const string& msg); + }; + + struct range_error : runtime_error + { + range_error(const string& msg); + }; + + struct overflow_error : runtime_error + { + overflow_error(const string& msg); + }; + + struct underflow_error : runtime_error + { + underflow_error(const string& msg); + }; +} + +#endif diff --git a/devtools/swigwin-1.3.34/Lib/std/std_ios.i b/devtools/swigwin-1.3.34/Lib/std/std_ios.i new file mode 100644 index 0000000..75484f3 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_ios.i @@ -0,0 +1,260 @@ +%include <std_char_traits.i> +%include <std_basic_string.i> +%include <std_except.i> +%{ +#ifndef SWIG_STD_NOMODERN_STL +# include <ios> +#else +# include <streambuf.h> +#endif +%} + +namespace std { + + template<typename _CharT, typename _Traits = char_traits<_CharT> > + class basic_streambuf; + + template<typename _CharT, typename _Traits = char_traits<_CharT> > + class basic_istream; + + template<typename _CharT, typename _Traits = char_traits<_CharT> > + class basic_ostream; + + // 27.4.2 Class ios_base + typedef size_t streamsize; + + class locale; + + + class ios_base + { + public: + +#ifdef SWIG_NESTED_CLASSES + // 27.4.2.1.1 Class ios_base::failure + class failure : public exception + { + public: + explicit failure(const string& __str) throw(); + }; +#endif + + // 27.4.2.1.2 Type ios_base::fmtflags + typedef int fmtflags; + // 27.4.2.1.2 Type fmtflags + static const fmtflags boolalpha ; + static const fmtflags dec ; + static const fmtflags fixed ; + static const fmtflags hex ; + static const fmtflags internal ; + static const fmtflags left ; + static const fmtflags oct ; + static const fmtflags right ; + static const fmtflags scientific ; + static const fmtflags showbase ; + static const fmtflags showpoint ; + static const fmtflags showpos ; + static const fmtflags skipws ; + static const fmtflags unitbuf ; + static const fmtflags uppercase ; + static const fmtflags adjustfield ; + static const fmtflags basefield ; + static const fmtflags floatfield ; + + // 27.4.2.1.3 Type ios_base::iostate + typedef int iostate; + static const iostate badbit ; + static const iostate eofbit ; + static const iostate failbit ; + static const iostate goodbit ; + + // 27.4.2.1.4 Type openmode + typedef int openmode; + static const openmode app ; + static const openmode ate ; + static const openmode binary ; + static const openmode in ; + static const openmode out ; + static const openmode trunc ; + + // 27.4.2.1.5 Type seekdir + typedef int seekdir; + static const seekdir beg ; + static const seekdir cur ; + static const seekdir end ; + + + // Callbacks; + enum event + { + erase_event, + imbue_event, + copyfmt_event + }; + + typedef void (*event_callback) (event, ios_base&, int); + + void + register_callback(event_callback __fn, int __index); + + // Fmtflags state: + inline fmtflags + flags() const ; + + inline fmtflags + flags(fmtflags __fmtfl); + + inline fmtflags + setf(fmtflags __fmtfl); + + inline fmtflags + setf(fmtflags __fmtfl, fmtflags __mask); + + inline void + unsetf(fmtflags __mask) ; + + inline streamsize + precision() const ; + + inline streamsize + precision(streamsize __prec); + + inline streamsize + width() const ; + + inline streamsize + width(streamsize __wide); + + static bool + sync_with_stdio(bool __sync = true); + + // Locales: + locale + imbue(const locale& __loc); + + inline locale + getloc() const { return _M_ios_locale; } + + // Storage: + static int + xalloc() throw(); + + inline long& + iword(int __ix); + + inline void*& + pword(int __ix); + + // Destructor + ~ios_base(); + + protected: + ios_base(); + + //50. Copy constructor and assignment operator of ios_base + private: + ios_base(const ios_base&); + + ios_base& + operator=(const ios_base&); + }; + + template<typename _CharT, typename _Traits = char_traits<_CharT> > + class basic_ios : public ios_base + { + public: + // Types: + typedef _CharT char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + + public: + + iostate + rdstate() const; + + void + clear(iostate __state = goodbit); + + void + setstate(iostate __state); + + bool + good() const; + + bool + eof() const; + + bool + fail() const; + + bool + bad() const; + + iostate + exceptions() const; + + void + exceptions(iostate __except); + + // Constructor/destructor: + explicit + basic_ios(basic_streambuf<_CharT, _Traits>* __sb) : ios_base(); + + virtual + ~basic_ios() ; + + // Members: + basic_ostream<_CharT, _Traits>* + tie() const; + + basic_ostream<_CharT, _Traits>* + tie(basic_ostream<_CharT, _Traits>* __tiestr); + + basic_streambuf<_CharT, _Traits>* + rdbuf() const; + + basic_streambuf<_CharT, _Traits>* + rdbuf(basic_streambuf<_CharT, _Traits>* __sb); + + basic_ios& + copyfmt(const basic_ios& __rhs); + + char_type + fill() const; + + char_type + fill(char_type __ch); + + // Locales: + locale + imbue(const locale& __loc); + + char + narrow(char_type __c, char __dfault) const; + + char_type + widen(char __c) const; + + protected: + // 27.4.5.1 basic_ios constructors + basic_ios(); + private: + ios_base(const ios_base&); + + ios_base& + operator=(const ios_base&); + }; + +} + +namespace std { + %template(ios) basic_ios<char>; +#if defined(SWIG_WCHAR) + %template(wios) basic_ios<wchar_t>; +#endif +} + + diff --git a/devtools/swigwin-1.3.34/Lib/std/std_iostream.i b/devtools/swigwin-1.3.34/Lib/std/std_iostream.i new file mode 100644 index 0000000..7a33afe --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_iostream.i @@ -0,0 +1,339 @@ +/* + For wchar support, you need to include the wchar.i file + before this file, ie: + + %include <wchar.i> + %include <std_iostream.i> + + or equivalently, just include + + %include <std_wiostream.i> +*/ + +%include <std_ios.i> +%include <std_basic_string.i> +%include <std_string.i> +#if defined(SWIG_WCHAR) +%include <std_wstring.i> +#endif + +%{ +#include <iostream> +%} + + +namespace std +{ + // 27.6.2.1 Template class basic_ostream + template<typename _CharT, typename _Traits = char_traits<_CharT> > + class basic_ostream : virtual public basic_ios<_CharT, _Traits> + { + public: + // Types (inherited from basic_ios (27.4.4)): + typedef _CharT char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + + // 27.6.2.2 Constructor/destructor: + explicit + basic_ostream(basic_streambuf<_CharT, _Traits>* __sb); + + virtual + ~basic_ostream(); + + // 27.6.2.5 Formatted output: + // 27.6.2.5.3 basic_ostream::operator<< + basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& (*__pf)(basic_ostream<_CharT, _Traits>&)); + + + basic_ostream<_CharT, _Traits>& + operator<<(basic_ios<_CharT, _Traits>& (*__pf)(basic_ios<_CharT, _Traits>&)); + + + basic_ostream<_CharT, _Traits>& + operator<<(ios_base& (*__pf) (ios_base&)); + + // 27.6.2.5.2 Arithmetic Inserters + + basic_ostream<_CharT, _Traits>& + operator<<(long __n); + + basic_ostream<_CharT, _Traits>& + operator<<(unsigned long __n); + + basic_ostream<_CharT, _Traits>& + operator<<(bool __n); + + basic_ostream<_CharT, _Traits>& + operator<<(short __n); + + basic_ostream<_CharT, _Traits>& + operator<<(unsigned short __n); + + basic_ostream<_CharT, _Traits>& + operator<<(int __n); + + basic_ostream<_CharT, _Traits>& + operator<<(unsigned int __n); + + basic_ostream<_CharT, _Traits>& + operator<<(long long __n); + + basic_ostream<_CharT, _Traits>& + operator<<(unsigned long long __n); + + basic_ostream<_CharT, _Traits>& + operator<<(double __f); + + basic_ostream<_CharT, _Traits>& + operator<<(float __f); + + basic_ostream<_CharT, _Traits>& + operator<<(long double __f); + + basic_ostream<_CharT, _Traits>& + operator<<(const void* __p); + + basic_ostream<_CharT, _Traits>& + operator<<(basic_streambuf<_CharT, _Traits>* __sb); + + %extend { + std::basic_ostream<_CharT, _Traits >& + operator<<(const std::basic_string<_CharT,_Traits, std::allocator<_CharT> >& s) + { + *self << s; + return *self; + } + } + + // Unformatted output: + basic_ostream<_CharT, _Traits>& + put(char_type __c); + + basic_ostream<_CharT, _Traits>& + write(const char_type* __s, streamsize __n); + + basic_ostream<_CharT, _Traits>& + flush(); + + // Seeks: + pos_type + tellp(); + + basic_ostream<_CharT, _Traits>& + seekp(pos_type); + + basic_ostream<_CharT, _Traits>& + seekp(off_type, ios_base::seekdir); + + }; + + // 27.6.1.1 Template class basic_istream + template<typename _CharT, typename _Traits = char_traits<_CharT> > + class basic_istream : virtual public basic_ios<_CharT, _Traits> + { + public: + // Types (inherited from basic_ios (27.4.4)): + typedef _CharT char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + + + public: + // 27.6.1.1.1 Constructor/destructor: + explicit + basic_istream(basic_streambuf<_CharT, _Traits>* __sb); + + virtual + ~basic_istream(); + + // 27.6.1.2.3 basic_istream::operator>> + basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& (*__pf)(basic_istream<_CharT, _Traits>&)); + + basic_istream<_CharT, _Traits>& + operator>>(basic_ios<_CharT, _Traits>& (*__pf)(basic_ios<_CharT, _Traits>&)); + + basic_istream<_CharT, _Traits>& + operator>>(ios_base& (*__pf)(ios_base&)); + + // 27.6.1.2.2 Arithmetic Extractors + basic_istream<_CharT, _Traits>& + operator>>(bool& __n); + + basic_istream<_CharT, _Traits>& + operator>>(short& __n); + + basic_istream<_CharT, _Traits>& + operator>>(unsigned short& __n); + + basic_istream<_CharT, _Traits>& + operator>>(int& __n); + + basic_istream<_CharT, _Traits>& + operator>>(unsigned int& __n); + + basic_istream<_CharT, _Traits>& + operator>>(long& __n); + + basic_istream<_CharT, _Traits>& + operator>>(unsigned long& __n); + + basic_istream<_CharT, _Traits>& + operator>>(long long& __n); + + basic_istream<_CharT, _Traits>& + operator>>(unsigned long long& __n); + + basic_istream<_CharT, _Traits>& + operator>>(float& __f); + + basic_istream<_CharT, _Traits>& + operator>>(double& __f); + + basic_istream<_CharT, _Traits>& + operator>>(long double& __f); + + basic_istream<_CharT, _Traits>& + operator>>(void*& __p); + + basic_istream<_CharT, _Traits>& + operator>>(basic_streambuf<_CharT, _Traits>* __sb); + + // 27.6.1.3 Unformatted input: + inline streamsize + gcount(void) const; + + int_type + get(void); + + basic_istream<_CharT, _Traits>& + get(char_type& __c); + + basic_istream<_CharT, _Traits>& + get(char_type* __s, streamsize __n, char_type __delim); + + inline basic_istream<_CharT, _Traits>& + get(char_type* __s, streamsize __n); + + basic_istream<_CharT, _Traits>& + get(basic_streambuf<_CharT, _Traits>& __sb, char_type __delim); + + inline basic_istream<_CharT, _Traits>& + get(basic_streambuf<_CharT, _Traits>& __sb); + + basic_istream<_CharT, _Traits>& + getline(char_type* __s, streamsize __n, char_type __delim); + + inline basic_istream<_CharT, _Traits>& + getline(char_type* __s, streamsize __n); + + basic_istream<_CharT, _Traits>& + ignore(streamsize __n = 1, int_type __delim = _Traits::eof()); + + int_type + peek(void); + + basic_istream<_CharT, _Traits>& + read(char_type* __s, streamsize __n); + + streamsize + readsome(char_type* __s, streamsize __n); + + basic_istream<_CharT, _Traits>& + putback(char_type __c); + + basic_istream<_CharT, _Traits>& + unget(void); + + int + sync(void); + + pos_type + tellg(void); + + basic_istream<_CharT, _Traits>& + seekg(pos_type); + + basic_istream<_CharT, _Traits>& + seekg(off_type, ios_base::seekdir); + }; + + // 27.6.1.5 Template class basic_iostream + template<typename _CharT, typename _Traits = char_traits<_CharT> > + class basic_iostream + : public basic_istream<_CharT, _Traits>, + public basic_ostream<_CharT, _Traits> + { + public: + typedef _CharT char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + + explicit + basic_iostream(basic_streambuf<_CharT, _Traits>* __sb); + + virtual + ~basic_iostream(); + }; + + typedef basic_ostream<char> ostream ; + typedef basic_istream<char> istream; + typedef basic_iostream<char> iostream; + + extern istream cin; + extern ostream cout; + extern ostream cerr; + extern ostream clog; + +#if defined(SWIG_WCHAR) + typedef basic_ostream<wchar_t> wostream; + typedef basic_istream<wchar_t> wistream; + typedef basic_iostream<wchar_t> wiostream; + + extern wistream wcin; + extern wostream wcout; + extern wostream wcerr; + extern wostream wclog; +#endif + + template<typename _CharT, typename _Traits = char_traits<_CharT> > + std::basic_ostream<_CharT, _Traits>& + endl(std::basic_ostream<_CharT, _Traits>&); + + template<typename _CharT, typename _Traits = char_traits<_CharT> > + std::basic_ostream<_CharT, _Traits>& + ends(std::basic_ostream<_CharT, _Traits>&); + + template<typename _CharT, typename _Traits = char_traits<_CharT> > + std::basic_ostream<_CharT, _Traits>& + flush(std::basic_ostream<_CharT, _Traits>&); +} + +namespace std { + %template(ostream) basic_ostream<char>; + %template(istream) basic_istream<char>; + %template(iostream) basic_iostream<char>; + + %template(endl) endl<char, std::char_traits<char> >; + %template(ends) ends<char, std::char_traits<char> >; + %template(flush) flush<char, std::char_traits<char> >; + +#if defined(SWIG_WCHAR) + %template(wostream) basic_ostream<wchar_t>; + %template(wistream) basic_istream<wchar_t>; + %template(wiostream) basic_iostream<wchar_t>; + + %template(wendl) endl<wchar_t, std::char_traits<wchar_t> >; + %template(wends) ends<wchar_t, std::char_traits<wchar_t> >; + %template(wflush) flush<wchar_t, std::char_traits<wchar_t> >; +#endif +} + diff --git a/devtools/swigwin-1.3.34/Lib/std/std_list.i b/devtools/swigwin-1.3.34/Lib/std/std_list.i new file mode 100644 index 0000000..e089351 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_list.i @@ -0,0 +1,148 @@ +// +// std::list +// + +%include <std_container.i> + +// List + +%define %std_list_methods(list) + %std_sequence_methods(list) + + void pop_front(); + void push_front(const value_type& x); + + void reverse(); + +%enddef + + +%define %std_list_methods_val(list) + %std_sequence_methods_val(list) + + void pop_front(); + void push_front(value_type x); + + void remove(value_type x); + void unique(); + void reverse(); + void sort(); + + void merge(list& x); +%enddef + +// ------------------------------------------------------------------------ +// std::list +// +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::list<T>), f(const std::list<T>&): +// the parameter being read-only, either a sequence or a +// previously wrapped std::list<T> can be passed. +// -- f(std::list<T>&), f(std::list<T>*): +// the parameter may be modified; therefore, only a wrapped std::list +// can be passed. +// -- std::list<T> f(), const std::list<T>& f(): +// the list is returned by copy; therefore, a sequence of T:s +// is returned which is most easily used in other functions +// -- std::list<T>& f(), std::list<T>* f(): +// the list is returned by reference; therefore, a wrapped std::list +// is returned +// -- const std::list<T>* f(), f(const std::list<T>*): +// for consistency, they expect and return a plain list pointer. +// ------------------------------------------------------------------------ + +%{ +#include <list> +%} + +// exported classes + +namespace std { + + template<class _Tp, class _Alloc = allocator<_Tp> > + class list { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Tp value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef _Alloc allocator_type; + + %traits_swigtype(_Tp); + + %fragment(SWIG_Traits_frag(std::list<_Tp, _Alloc >), "header", + fragment=SWIG_Traits_frag(_Tp), + fragment="StdListTraits") { + namespace swig { + template <> struct traits<std::list<_Tp, _Alloc > > { + typedef pointer_category category; + static const char* type_name() { + return "std::list<" #_Tp ", " #_Alloc " >"; + } + }; + } + } + + %typemap_traits_ptr(SWIG_TYPECHECK_LIST, std::list<_Tp, _Alloc >); + +#ifdef %swig_list_methods + // Add swig/language extra methods + %swig_list_methods(std::list<_Tp, _Alloc >); +#endif + + %std_list_methods(list); + }; + + template<class _Tp, class _Alloc > + class list<_Tp*, _Alloc> { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Tp* value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type reference; + typedef value_type const_reference; + typedef _Alloc allocator_type; + + %traits_swigtype(_Tp); + + %fragment(SWIG_Traits_frag(std::list<_Tp*, _Alloc >), "header", + fragment=SWIG_Traits_frag(_Tp), + fragment="StdListTraits") { + namespace swig { + template <> struct traits<std::list<_Tp*, _Alloc > > { + typedef value_category category; + static const char* type_name() { + return "std::list<" #_Tp " *," #_Alloc " >"; + } + }; + } + } + + %typemap_traits_ptr(SWIG_TYPECHECK_LIST, std::list<_Tp*, _Alloc >); + +#ifdef %swig_list_methods_val + // Add swig/language extra methods + %swig_list_methods_val(std::list<_Tp*, _Alloc >); +#endif + + %std_list_methods_val(list); + }; + +} + +%define %std_extequal_list(...) +%extend std::list<__VA_ARGS__ > { + void remove(const value_type& x) { self->remove(x); } + void merge(std::list<__VA_ARGS__ >& x){ self->merge(x); } + void unique() { self->unique(); } + void sort() { self->sort(); } +} +%enddef + diff --git a/devtools/swigwin-1.3.34/Lib/std/std_map.i b/devtools/swigwin-1.3.34/Lib/std/std_map.i new file mode 100644 index 0000000..0520841 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_map.i @@ -0,0 +1,124 @@ +// +// std::map +// + +%include <std_pair.i> +%include <std_container.i> + +%define %std_map_methods_common(map...) + %std_container_methods(map); + + size_type erase(const key_type& x); + size_type count(const key_type& x) const; + +#ifdef SWIG_EXPORT_ITERATOR_METHODS +// iterator insert(iterator position, const value_type& x); + void erase(iterator position); + void erase(iterator first, iterator last); + + iterator find(const key_type& x); + iterator lower_bound(const key_type& x); + iterator upper_bound(const key_type& x); +#endif +%enddef + +%define %std_map_methods(map...) + %std_map_methods_common(map); + + #ifdef SWIG_EXPORT_ITERATOR_METHODS +// iterator insert(const value_type& x); + #endif +%enddef + + +// ------------------------------------------------------------------------ +// std::map +// +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::map<T>), f(const std::map<T>&): +// the parameter being read-only, either a sequence or a +// previously wrapped std::map<T> can be passed. +// -- f(std::map<T>&), f(std::map<T>*): +// the parameter may be modified; therefore, only a wrapped std::map +// can be passed. +// -- std::map<T> f(), const std::map<T>& f(): +// the map is returned by copy; therefore, a sequence of T:s +// is returned which is most easily used in other functions +// -- std::map<T>& f(), std::map<T>* f(): +// the map is returned by reference; therefore, a wrapped std::map +// is returned +// -- const std::map<T>* f(), f(const std::map<T>*): +// for consistency, they expect and return a plain map pointer. +// ------------------------------------------------------------------------ + +%{ +#include <map> +#include <algorithm> +#include <stdexcept> +%} + +// exported class + +namespace std { + + template<class _Key, class _Tp, class _Compare = std::less<_Key >, + class _Alloc = allocator<std::pair<const _Key, _Tp > > > + class map { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Key key_type; + typedef _Tp mapped_type; + typedef std::pair<const _Key, _Tp> value_type; + + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef _Alloc allocator_type; + + %traits_swigtype(_Key); + %traits_swigtype(_Tp); + + %fragment(SWIG_Traits_frag(std::pair< _Key, _Tp >), "header", + fragment=SWIG_Traits_frag(_Key), + fragment=SWIG_Traits_frag(_Tp), + fragment="StdPairTraits") { + namespace swig { + template <> struct traits<std::pair< _Key, _Tp > > { + typedef pointer_category category; + static const char* type_name() { + return "std::pair<" #_Key "," #_Tp " >"; + } + }; + } + } + + %fragment(SWIG_Traits_frag(std::map<_Key, _Tp, _Compare, _Alloc >), "header", + fragment=SWIG_Traits_frag(std::pair<_Key, _Tp >), + fragment="StdMapTraits") { + namespace swig { + template <> struct traits<std::map<_Key, _Tp, _Compare, _Alloc > > { + typedef pointer_category category; + static const char* type_name() { + return "std::map<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >"; + } + }; + } + } + + %typemap_traits_ptr(SWIG_TYPECHECK_MAP, std::map<_Key, _Tp, _Compare, _Alloc >); + + map( const _Compare& ); + +#ifdef %swig_map_methods + // Add swig/language extra methods + %swig_map_methods(std::map<_Key, _Tp, _Compare, _Alloc >); +#endif + + %std_map_methods(map); + }; + +} diff --git a/devtools/swigwin-1.3.34/Lib/std/std_multimap.i b/devtools/swigwin-1.3.34/Lib/std/std_multimap.i new file mode 100644 index 0000000..f165e5f --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_multimap.i @@ -0,0 +1,87 @@ +// +// std::map +// + +%include <std_map.i> + + +%define %std_multimap_methods(mmap...) + %std_map_methods_common(mmap); + +#ifdef SWIG_EXPORT_ITERATOR_METHODS + std::pair<iterator,iterator> equal_range(const key_type& x); + std::pair<const_iterator,const_iterator> equal_range(const key_type& x) const; +#endif +%enddef + +// ------------------------------------------------------------------------ +// std::multimap +// +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::multimap<T>), f(const std::multimap<T>&): +// the parameter being read-only, either a sequence or a +// previously wrapped std::multimap<T> can be passed. +// -- f(std::multimap<T>&), f(std::multimap<T>*): +// the parameter may be modified; therefore, only a wrapped std::multimap +// can be passed. +// -- std::multimap<T> f(), const std::multimap<T>& f(): +// the map is returned by copy; therefore, a sequence of T:s +// is returned which is most easily used in other functions +// -- std::multimap<T>& f(), std::multimap<T>* f(): +// the map is returned by reference; therefore, a wrapped std::multimap +// is returned +// -- const std::multimap<T>* f(), f(const std::multimap<T>*): +// for consistency, they expect and return a plain map pointer. +// ------------------------------------------------------------------------ + + +// exported class + + +namespace std { + template<class _Key, class _Tp, class _Compare = std::less<_Key >, + class _Alloc = allocator<std::pair<const _Key, _Tp > > > + class multimap { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Key key_type; + typedef _Tp mapped_type; + typedef std::pair<const _Key, _Tp> value_type; + + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef _Alloc allocator_type; + + %traits_swigtype(_Key); + %traits_swigtype(_Tp); + + %fragment(SWIG_Traits_frag(std::multimap<_Key, _Tp, _Compare, _Alloc >), "header", + fragment=SWIG_Traits_frag(std::pair<_Key, _Tp >), + fragment="StdMultimapTraits") { + namespace swig { + template <> struct traits<std::multimap<_Key, _Tp, _Compare, _Alloc > > { + typedef pointer_category category; + static const char* type_name() { + return "std::multimap<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >"; + } + }; + } + } + + %typemap_traits_ptr(SWIG_TYPECHECK_MULTIMAP, std::multimap<_Key, _Tp, _Compare, _Alloc >); + + multimap( const _Compare& ); + +#ifdef %swig_multimap_methods + // Add swig/language extra methods + %swig_multimap_methods(std::multimap<_Key, _Tp, _Compare, _Alloc >); +#endif + + %std_multimap_methods(multimap); + }; +} diff --git a/devtools/swigwin-1.3.34/Lib/std/std_multiset.i b/devtools/swigwin-1.3.34/Lib/std/std_multiset.i new file mode 100644 index 0000000..98a7fb9 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_multiset.i @@ -0,0 +1,83 @@ +// +// std::set +// + +%include <std_set.i> + +// Multiset + +%define %std_multiset_methods(multiset...) + %std_set_methods_common(multiset); +%enddef + + +// ------------------------------------------------------------------------ +// std::multiset +// +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::multiset<T>), f(const std::multiset<T>&): +// the parameter being read-only, either a sequence or a +// previously wrapped std::multiset<T> can be passed. +// -- f(std::multiset<T>&), f(std::multiset<T>*): +// the parameter may be modified; therefore, only a wrapped std::multiset +// can be passed. +// -- std::multiset<T> f(), const std::multiset<T>& f(): +// the set is returned by copy; therefore, a sequence of T:s +// is returned which is most easily used in other functions +// -- std::multiset<T>& f(), std::multiset<T>* f(): +// the set is returned by reference; therefore, a wrapped std::multiset +// is returned +// -- const std::multiset<T>* f(), f(const std::multiset<T>*): +// for consistency, they expect and return a plain set pointer. +// ------------------------------------------------------------------------ + + +// exported classes + +namespace std { + + //multiset + + template <class _Key, class _Compare = std::less<_Key>, + class _Alloc = allocator<_Key> > + class multiset { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Key value_type; + typedef _Key key_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef _Alloc allocator_type; + + %traits_swigtype(_Key); + + %fragment(SWIG_Traits_frag(std::multiset<_Key, _Compare, _Alloc >), "header", + fragment=SWIG_Traits_frag(_Key), + fragment="StdMultisetTraits") { + namespace swig { + template <> struct traits<std::multiset<_Key, _Compare, _Alloc > > { + typedef pointer_category category; + static const char* type_name() { + return "std::multiset<" #_Key "," #_Compare "," #_Alloc " >"; + } + }; + } + } + + %typemap_traits_ptr(SWIG_TYPECHECK_MULTISET, std::multiset<_Key, _Compare, _Alloc >); + + multiset( const _Compare& ); + +#ifdef %swig_multiset_methods + // Add swig/language extra methods + %swig_multiset_methods(std::multiset<_Key, _Compare, _Alloc >); +#endif + + %std_multiset_methods(multiset); + }; +} diff --git a/devtools/swigwin-1.3.34/Lib/std/std_pair.i b/devtools/swigwin-1.3.34/Lib/std/std_pair.i new file mode 100644 index 0000000..7c83277 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_pair.i @@ -0,0 +1,163 @@ +%include <std_common.i> + +%{ +#include <utility> +%} + + +namespace std { + template <class T, class U > struct pair { + typedef T first_type; + typedef U second_type; + + %traits_swigtype(T); + %traits_swigtype(U); + + %fragment(SWIG_Traits_frag(std::pair<T,U >), "header", + fragment=SWIG_Traits_frag(T), + fragment=SWIG_Traits_frag(U), + fragment="StdPairTraits") { + namespace swig { + template <> struct traits<std::pair<T,U > > { + typedef pointer_category category; + static const char* type_name() { + return "std::pair<" #T "," #U " >"; + } + }; + } + } + +#ifndef SWIG_STD_PAIR_ASVAL + %typemap_traits_ptr(SWIG_TYPECHECK_PAIR, std::pair<T,U >); +#else + %typemap_traits(SWIG_TYPECHECK_PAIR, std::pair<T,U >); +#endif + + pair(); + pair(T first, U second); + pair(const pair& p); + + template <class U1, class U2> pair(const pair<U1, U2> &p); + + T first; + U second; + +#ifdef %swig_pair_methods + // Add swig/language extra methods + %swig_pair_methods(std::pair<T,U >) +#endif + }; + + // *** + // The following specializations should dissapear or get + // simplified when a 'const SWIGTYPE*&' can be defined + // *** + template <class T, class U > struct pair<T, U*> { + typedef T first_type; + typedef U* second_type; + + %traits_swigtype(T); + %traits_swigtype(U); + + %fragment(SWIG_Traits_frag(std::pair<T,U* >), "header", + fragment=SWIG_Traits_frag(T), + fragment=SWIG_Traits_frag(U), + fragment="StdPairTraits") { + namespace swig { + template <> struct traits<std::pair<T,U* > > { + typedef pointer_category category; + static const char* type_name() { + return "std::pair<" #T "," #U " * >"; + } + }; + } + } + + %typemap_traits_ptr(SWIG_TYPECHECK_PAIR, std::pair<T,U* >); + + pair(); + pair(T __a, U* __b); + pair(const pair& __p); + + T first; + U* second; + +#ifdef %swig_pair_methods + // Add swig/language extra methods + %swig_pair_methods(std::pair<T,U*>) +#endif + }; + + template <class T, class U > struct pair<T*, U> { + typedef T* first_type; + typedef U second_type; + + %traits_swigtype(T); + %traits_swigtype(U); + + %fragment(SWIG_Traits_frag(std::pair<T*,U >), "header", + fragment=SWIG_Traits_frag(T), + fragment=SWIG_Traits_frag(U), + fragment="StdPairTraits") { + namespace swig { + template <> struct traits<std::pair<T*,U > > { + typedef pointer_category category; + static const char* type_name() { + return "std::pair<" #T " *," #U " >"; + } + }; + } + } + + %typemap_traits_ptr(SWIG_TYPECHECK_PAIR, std::pair<T*,U >); + + pair(); + pair(T* __a, U __b); + pair(const pair& __p); + + T* first; + U second; + +#ifdef %swig_pair_methods + // Add swig/language extra methods + %swig_pair_methods(std::pair<T*,U >) +#endif + }; + + template <class T, class U > struct pair<T*, U*> { + typedef T* first_type; + typedef U* second_type; + + %traits_swigtype(T); + %traits_swigtype(U); + + %fragment(SWIG_Traits_frag(std::pair<T*,U* >), "header", + fragment=SWIG_Traits_frag(T), + fragment=SWIG_Traits_frag(U), + fragment="StdPairTraits") { + namespace swig { + template <> struct traits<std::pair<T*,U* > > { + typedef pointer_category category; + static const char* type_name() { + return "std::pair<" #T " *," #U " * >"; + } + }; + } + } + + %typemap_traits(SWIG_TYPECHECK_PAIR, std::pair<T*,U* >); + + pair(); + pair(T* __a, U* __b); + pair(const pair& __p); + + T* first; + U* second; + +#ifdef %swig_pair_methods + // Add swig/language extra methods + %swig_pair_methods(std::pair<T*,U*>) +#endif + }; + +} diff --git a/devtools/swigwin-1.3.34/Lib/std/std_queue.i b/devtools/swigwin-1.3.34/Lib/std/std_queue.i new file mode 100644 index 0000000..42273ee --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_queue.i @@ -0,0 +1,129 @@ +/** + * @file std_queue.i + * @date Sun May 6 01:48:07 2007 + * + * @brief A wrapping of std::queue for Ruby. + * + * + */ + +%include <std_container.i> + +// Queue + +%define %std_queue_methods(queue...) + queue(); + queue( const _Sequence& ); + + bool empty() const; + size_type size() const; + const value_type& front() const; + const value_type& back() const; + void pop(); + void push( const value_type& ); +%enddef + +%define %std_queue_methods_val(queue...) + %std_queue_methods(queue) +%enddef + +// ------------------------------------------------------------------------ +// std::queue +// +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::queue<T>), f(const std::queue<T>&): +// the parameter being read-only, either a sequence or a +// previously wrapped std::queue<T> can be passed. +// -- f(std::queue<T>&), f(std::queue<T>*): +// the parameter may be modified; therefore, only a wrapped std::queue +// can be passed. +// -- std::queue<T> f(), const std::queue<T>& f(): +// the queue is returned by copy; therefore, a sequence of T:s +// is returned which is most easily used in other functions +// -- std::queue<T>& f(), std::queue<T>* f(): +// the queue is returned by reference; therefore, a wrapped std::queue +// is returned +// -- const std::queue<T>* f(), f(const std::queue<T>*): +// for consistency, they expect and return a plain queue pointer. +// ------------------------------------------------------------------------ + +%{ +#include <queue> +%} + +// exported classes + +namespace std { + + template<class _Tp, class _Sequence = std::deque<_Tp> > + class queue { + public: + typedef size_t size_type; + typedef _Tp value_type; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef _Sequence container_type; + + %traits_swigtype(_Tp); + + %fragment(SWIG_Traits_frag(std::queue<_Tp, _Sequence >), "header", + fragment=SWIG_Traits_frag(_Tp), + fragment="StdQueueTraits") { + namespace swig { + template <> struct traits<std::queue<_Tp, _Sequence > > { + typedef pointer_category category; + static const char* type_name() { + return "std::queue<" #_Tp "," #_Sequence " >"; + } + }; + } + } + + %typemap_traits_ptr(SWIG_TYPECHECK_QUEUE, std::queue<_Tp, _Sequence >); + +#ifdef %swig_queue_methods + // Add swig/language extra methods + %swig_queue_methods(std::queue<_Tp, _Sequence >); +#endif + + %std_queue_methods(queue); + }; + + template<class _Tp, class _Sequence > + class queue<_Tp*, _Sequence > { + public: + typedef size_t size_type; + typedef _Tp value_type; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef _Sequence container_type; + + %traits_swigtype(_Tp); + + %fragment(SWIG_Traits_frag(std::queue<_Tp*, _Sequence >), "header", + fragment=SWIG_Traits_frag(_Tp), + fragment="StdQueueTraits") { + namespace swig { + template <> struct traits<std::queue<_Tp*, _Sequence > > { + typedef value_category category; + static const char* type_name() { + return "std::queue<" #_Tp "," #_Sequence " * >"; + } + }; + } + } + + %typemap_traits_ptr(SWIG_TYPECHECK_QUEUE, std::queue<_Tp*, _Sequence >); + +#ifdef %swig_queue_methods_val + // Add swig/language extra methods + %swig_queue_methods_val(std::queue<_Tp*, _Sequence >); +#endif + + %std_queue_methods_val(std::queue<_Tp*, _Sequence >); + }; + +} + diff --git a/devtools/swigwin-1.3.34/Lib/std/std_set.i b/devtools/swigwin-1.3.34/Lib/std/std_set.i new file mode 100644 index 0000000..16f0f14 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_set.i @@ -0,0 +1,119 @@ +// +// std::set +// + +%include <std_container.i> +%include <std_pair.i> + +// Set +%define %std_set_methods_common(set...) + set(); + set( const set& ); + + bool empty() const; + size_type size() const; + void clear(); + + void swap(set& v); + + + size_type erase(const key_type& x); + size_type count(const key_type& x) const; + +#ifdef SWIG_EXPORT_ITERATOR_METHODS + class iterator; + class reverse_iterator; + + iterator begin(); + iterator end(); + reverse_iterator rbegin(); + reverse_iterator rend(); + + void erase(iterator pos); + void erase(iterator first, iterator last); + + iterator find(const key_type& x); + iterator lower_bound(const key_type& x); + iterator upper_bound(const key_type& x); + std::pair<iterator,iterator> equal_range(const key_type& x); +#endif +%enddef + +%define %std_set_methods(set...) + %std_set_methods_common(set); +#ifdef SWIG_EXPORT_ITERATOR_METHODS + std::pair<iterator,bool> insert(const value_type& __x); +#endif +%enddef + +// ------------------------------------------------------------------------ +// std::set +// +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::set<T>), f(const std::set<T>&): +// the parameter being read-only, either a sequence or a +// previously wrapped std::set<T> can be passed. +// -- f(std::set<T>&), f(std::set<T>*): +// the parameter may be modified; therefore, only a wrapped std::set +// can be passed. +// -- std::set<T> f(), const std::set<T>& f(): +// the set is returned by copy; therefore, a sequence of T:s +// is returned which is most easily used in other functions +// -- std::set<T>& f(), std::set<T>* f(): +// the set is returned by reference; therefore, a wrapped std::set +// is returned +// -- const std::set<T>* f(), f(const std::set<T>*): +// for consistency, they expect and return a plain set pointer. +// ------------------------------------------------------------------------ + +%{ +#include <set> +%} + +// exported classes + +namespace std { + + template <class _Key, class _Compare = std::less<_Key>, + class _Alloc = allocator<_Key> > + class set { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Key value_type; + typedef _Key key_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef _Alloc allocator_type; + + %traits_swigtype(_Key); + + %fragment(SWIG_Traits_frag(std::set<_Key, _Compare, _Alloc >), "header", + fragment=SWIG_Traits_frag(_Key), + fragment="StdSetTraits") { + namespace swig { + template <> struct traits<std::set<_Key, _Compare, _Alloc > > { + typedef pointer_category category; + static const char* type_name() { + return "std::set<" #_Key "," #_Compare "," #_Alloc " >"; + } + }; + } + } + + %typemap_traits_ptr(SWIG_TYPECHECK_SET, std::set<_Key, _Compare, _Alloc >); + + set( const _Compare& ); + +#ifdef %swig_set_methods + // Add swig/language extra methods + %swig_set_methods(std::set<_Key, _Compare, _Alloc >); +#endif + + %std_set_methods(set); + }; +} diff --git a/devtools/swigwin-1.3.34/Lib/std/std_sstream.i b/devtools/swigwin-1.3.34/Lib/std/std_sstream.i new file mode 100644 index 0000000..12bccef --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_sstream.i @@ -0,0 +1,195 @@ +/* + For wchar support, you need to include the wchar.i file + before this file, ie: + + %include <wchar.i> + %include <std_sstream.i> + + or equivalently, just include + + %include <std_wsstream.i> +*/ + +%include <std_alloc.i> +%include <std_basic_string.i> +%include <std_string.i> +%include <std_ios.i> +#if defined(SWIG_WCHAR) +%include <std_wstring.i> +#endif +%include <std_streambuf.i> +%include <std_iostream.i> + +%{ +#include <sstream> +%} + + +namespace std +{ + template<typename _CharT, typename _Traits = char_traits<_CharT>, + typename _Alloc = allocator<_CharT> > + class basic_stringbuf : public basic_streambuf<_CharT, _Traits> + { + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; +// 251. basic_stringbuf missing allocator_type + typedef _Alloc allocator_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + public: + // Constructors: + explicit + basic_stringbuf(ios_base::openmode __mode = ios_base::in | ios_base::out); + + explicit + basic_stringbuf(const basic_string<_CharT, _Traits, _Alloc>& __str, + ios_base::openmode __mode = ios_base::in | ios_base::out); + + // Get and set: + basic_string<_CharT, _Traits, _Alloc> + str() const; + + void + str(const basic_string<_CharT, _Traits, _Alloc>& __s); + + }; + + + // 27.7.2 Template class basic_istringstream + template<typename _CharT, typename _Traits = char_traits<_CharT>, + typename _Alloc = allocator<_CharT> > + class basic_istringstream : public basic_istream<_CharT, _Traits> + { + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; +// 251. basic_stringbuf missing allocator_type + typedef _Alloc allocator_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + + public: + // Constructors: + explicit + basic_istringstream(ios_base::openmode __mode = ios_base::in); + + explicit + basic_istringstream(const basic_string<_CharT, _Traits, _Alloc>& __str, + ios_base::openmode __mode = ios_base::in); + + ~basic_istringstream(); + + // Members: + basic_stringbuf<_CharT, _Traits, _Alloc>* + rdbuf() const; + + basic_string<_CharT, _Traits, _Alloc> + str() const; + + void + str(const basic_string<_CharT, _Traits, _Alloc>& __s); + }; + + + // 27.7.3 Template class basic_ostringstream + template<typename _CharT, typename _Traits = char_traits<_CharT>, + typename _Alloc = allocator<_CharT> > + class basic_ostringstream : public basic_ostream<_CharT, _Traits> + { + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; +// 251. basic_stringbuf missing allocator_type + typedef _Alloc allocator_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + + public: + // Constructors/destructor: + explicit + basic_ostringstream(ios_base::openmode __mode = ios_base::out); + + explicit + basic_ostringstream(const basic_string<_CharT, _Traits, _Alloc>& __str, + ios_base::openmode __mode = ios_base::out); + + ~basic_ostringstream(); + + // Members: + basic_stringbuf<_CharT, _Traits, _Alloc>* + rdbuf() const; + + basic_string<_CharT, _Traits, _Alloc> + str() const; + +#if 0 + void + str(const basic_string<_CharT, _Traits, _Alloc>& __s); +#endif + }; + + + // 27.7.4 Template class basic_stringstream + template<typename _CharT, typename _Traits = char_traits<_CharT>, + typename _Alloc = allocator<_CharT> > + class basic_stringstream : public basic_iostream<_CharT, _Traits> + { + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; +// 251. basic_stringbuf missing allocator_type + typedef _Alloc allocator_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + public: + // Constructors/destructors + explicit + basic_stringstream(ios_base::openmode __m = ios_base::out | ios_base::in); + + explicit + basic_stringstream(const basic_string<_CharT, _Traits, _Alloc>& __str, + ios_base::openmode __m = ios_base::out | ios_base::in); + + ~basic_stringstream(); + + // Members: + basic_stringbuf<_CharT, _Traits, _Alloc>* + rdbuf() const; + + basic_string<_CharT, _Traits, _Alloc> + str() const; + + void + str(const basic_string<_CharT, _Traits, _Alloc>& __s); + }; + + +} // namespace std + + +namespace std { + %template(istringstream) basic_istringstream<char>; + %template(ostringstream) basic_ostringstream<char>; + %template(stringstream) basic_stringstream<char>; + + +#if defined(SWIG_WCHAR) + %template(wistringstream) basic_istringstream<wchar_t>; + %template(wostringstream) basic_ostringstream<wchar_t>; + %template(wstringstream) basic_stringstream<wchar_t>; +#endif +} diff --git a/devtools/swigwin-1.3.34/Lib/std/std_stack.i b/devtools/swigwin-1.3.34/Lib/std/std_stack.i new file mode 100644 index 0000000..fb900a5 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_stack.i @@ -0,0 +1,128 @@ +/** + * @file std_stack.i + * @date Sun May 6 01:48:07 2007 + * + * @brief A wrapping of std::stack for Ruby. + * + * + */ + +%include <std_container.i> + +// Stack + +%define %std_stack_methods(stack...) + stack(); + stack( const _Sequence& ); + + bool empty() const; + size_type size() const; + const value_type& top() const; + void pop(); + void push( const value_type& ); +%enddef + +%define %std_stack_methods_val(stack...) + %std_stack_methods(stack) +%enddef + +// ------------------------------------------------------------------------ +// std::stack +// +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::stack<T>), f(const std::stack<T>&): +// the parameter being read-only, either a sequence or a +// previously wrapped std::stack<T> can be passed. +// -- f(std::stack<T>&), f(std::stack<T>*): +// the parameter may be modified; therefore, only a wrapped std::stack +// can be passed. +// -- std::stack<T> f(), const std::stack<T>& f(): +// the stack is returned by copy; therefore, a sequence of T:s +// is returned which is most easily used in other functions +// -- std::stack<T>& f(), std::stack<T>* f(): +// the stack is returned by reference; therefore, a wrapped std::stack +// is returned +// -- const std::stack<T>* f(), f(const std::stack<T>*): +// for consistency, they expect and return a plain stack pointer. +// ------------------------------------------------------------------------ + +%{ +#include <stack> +%} + +// exported classes + +namespace std { + + template<class _Tp, class _Sequence = std::deque<_Tp> > + class stack { + public: + typedef size_t size_type; + typedef _Tp value_type; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef _Sequence container_type; + + %traits_swigtype(_Tp); + + %fragment(SWIG_Traits_frag(std::stack<_Tp, _Sequence >), "header", + fragment=SWIG_Traits_frag(_Tp), + fragment="StdStackTraits") { + namespace swig { + template <> struct traits<std::stack<_Tp, _Sequence > > { + typedef pointer_category category; + static const char* type_name() { + return "std::stack<" #_Tp "," #_Sequence " >"; + } + }; + } + } + + %typemap_traits_ptr(SWIG_TYPECHECK_STACK, std::stack<_Tp, _Sequence >); + +#ifdef %swig_stack_methods + // Add swig/language extra methods + %swig_stack_methods(std::stack<_Tp, _Sequence >); +#endif + + %std_stack_methods(stack); + }; + + template<class _Tp, class _Sequence > + class stack<_Tp*, _Sequence > { + public: + typedef size_t size_type; + typedef _Sequence::value_type value_type; + typedef value_type reference; + typedef value_type const_reference; + typedef _Sequence container_type; + + %traits_swigtype(_Tp); + + %fragment(SWIG_Traits_frag(std::stack<_Tp*, _Sequence >), "header", + fragment=SWIG_Traits_frag(_Tp), + fragment="StdStackTraits") { + namespace swig { + template <> struct traits<std::stack<_Tp*, _Sequence > > { + typedef value_category category; + static const char* type_name() { + return "std::stack<" #_Tp "," #_Sequence " * >"; + } + }; + } + } + + %typemap_traits_ptr(SWIG_TYPECHECK_STACK, std::stack<_Tp*, _Sequence >); + +#ifdef %swig_stack_methods_val + // Add swig/language extra methods + %swig_stack_methods_val(std::stack<_Tp*, _Sequence >); +#endif + + %std_stack_methods_val(std::stack<_Tp*, _Sequence >); + }; + +} + diff --git a/devtools/swigwin-1.3.34/Lib/std/std_streambuf.i b/devtools/swigwin-1.3.34/Lib/std/std_streambuf.i new file mode 100644 index 0000000..7efb19c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_streambuf.i @@ -0,0 +1,94 @@ +%include <std_ios.i> +%{ +#ifndef SWIG_STD_NOMODERN_STL +#include <streambuf> +#else +#include <streambuf.h> +#endif +%} + +namespace std { + + template<typename _CharT, typename _Traits = char_traits<_CharT> > + class basic_streambuf + { + public: + // Types: + typedef _CharT char_type; + typedef _Traits traits_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + + public: + virtual + ~basic_streambuf(); + + // Locales: + locale + pubimbue(const locale &__loc); + + locale + getloc() const; + + // Buffer and positioning: + basic_streambuf<_CharT, _Traits>* + pubsetbuf(char_type* __s, streamsize __n); + + pos_type + pubseekoff(off_type __off, ios_base::seekdir __way, + ios_base::openmode __mode = std::ios_base::in | std::ios_base::out); + + pos_type + pubseekpos(pos_type __sp, + ios_base::openmode __mode = std::ios_base::in | std::ios_base::out); + + int + pubsync() ; + + // Get and put areas: + // Get area: + streamsize + in_avail(); + + int_type + snextc(); + + int_type + sbumpc(); + + int_type + sgetc(); + + streamsize + sgetn(char_type* __s, streamsize __n); + + // Putback: + int_type + sputbackc(char_type __c); + + int_type + sungetc(); + + // Put area: + int_type + sputc(char_type __c); + + streamsize + sputn(const char_type* __s, streamsize __n); + + protected: + basic_streambuf(); + + private: + basic_streambuf(const basic_streambuf&); + + }; +} + +namespace std { + %template(streambuf) basic_streambuf<char>; +#if defined(SWIG_WCHAR) + %template(wstreambuf) basic_streambuf<wchar_t>; +#endif +} diff --git a/devtools/swigwin-1.3.34/Lib/std/std_string.i b/devtools/swigwin-1.3.34/Lib/std/std_string.i new file mode 100644 index 0000000..35fcdd1 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_string.i @@ -0,0 +1,13 @@ +%include <std/std_basic_string.i> + +/* plain strings */ + +namespace std +{ + %std_comp_methods(basic_string<char>); + %naturalvar string; + typedef basic_string<char> string; +} + + +%template(string) std::basic_string<char>; diff --git a/devtools/swigwin-1.3.34/Lib/std/std_vector.i b/devtools/swigwin-1.3.34/Lib/std/std_vector.i new file mode 100644 index 0000000..ab1435b --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_vector.i @@ -0,0 +1,184 @@ +// +// std::vector +// + +%include <std_container.i> + +// Vector + +%define %std_vector_methods(vector...) + %std_sequence_methods(vector) + + void reserve(size_type n); + size_type capacity() const; +%enddef + + +%define %std_vector_methods_val(vector...) + %std_sequence_methods_val(vector) + + void reserve(size_type n); + size_type capacity() const; +%enddef + + +// ------------------------------------------------------------------------ +// std::vector +// +// The aim of all that follows would be to integrate std::vector with +// as much as possible, namely, to allow the user to pass and +// be returned tuples or lists. +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::vector<T>), f(const std::vector<T>&): +// the parameter being read-only, either a sequence or a +// previously wrapped std::vector<T> can be passed. +// -- f(std::vector<T>&), f(std::vector<T>*): +// the parameter may be modified; therefore, only a wrapped std::vector +// can be passed. +// -- std::vector<T> f(), const std::vector<T>& f(): +// the vector is returned by copy; therefore, a sequence of T:s +// is returned which is most easily used in other functions +// -- std::vector<T>& f(), std::vector<T>* f(): +// the vector is returned by reference; therefore, a wrapped std::vector +// is returned +// -- const std::vector<T>* f(), f(const std::vector<T>*): +// for consistency, they expect and return a plain vector pointer. +// ------------------------------------------------------------------------ + +%{ +#include <vector> +%} + +// exported classes + + +namespace std { + + template<class _Tp, class _Alloc = allocator< _Tp > > + class vector { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Tp value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef _Tp& reference; + typedef const _Tp& const_reference; + typedef _Alloc allocator_type; + + %traits_swigtype(_Tp); + + %fragment(SWIG_Traits_frag(std::vector<_Tp, _Alloc >), "header", + fragment=SWIG_Traits_frag(_Tp), + fragment="StdVectorTraits") { + namespace swig { + template <> struct traits<std::vector<_Tp, _Alloc > > { + typedef pointer_category category; + static const char* type_name() { + return "std::vector<" #_Tp "," #_Alloc " >"; + } + }; + } + } + + %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<_Tp, _Alloc >); + +#ifdef %swig_vector_methods + // Add swig/language extra methods + %swig_vector_methods(std::vector<_Tp, _Alloc >); +#endif + + %std_vector_methods(vector); + }; + + // *** + // This specialization should dissapear or get simplified when + // a 'const SWIGTYPE*&' can be defined + // *** + template<class _Tp, class _Alloc > + class vector<_Tp*, _Alloc > { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Tp* value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type reference; + typedef value_type const_reference; + typedef _Alloc allocator_type; + + %traits_swigtype(_Tp); + + %fragment(SWIG_Traits_frag(std::vector<_Tp*, _Alloc >), "header", + fragment=SWIG_Traits_frag(_Tp), + fragment="StdVectorTraits") { + namespace swig { + template <> struct traits<std::vector<_Tp*, _Alloc > > { + typedef value_category category; + static const char* type_name() { + return "std::vector<" #_Tp " *," #_Alloc " >"; + } + }; + } + } + + %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<_Tp*, _Alloc >); + +#ifdef %swig_vector_methods_val + // Add swig/language extra methods + %swig_vector_methods_val(std::vector<_Tp*, _Alloc >); +#endif + + %std_vector_methods_val(vector); + }; + + // *** + // *** + // bool specialization + + template<class _Alloc > + class vector<bool,_Alloc > { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef bool value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type reference; + typedef value_type const_reference; + typedef _Alloc allocator_type; + + %traits_swigtype(bool); + + %fragment(SWIG_Traits_frag(std::vector<bool, _Alloc >), "header", + fragment=SWIG_Traits_frag(bool), + fragment="StdVectorTraits") { + namespace swig { + template <> struct traits<std::vector<bool, _Alloc > > { + typedef value_category category; + static const char* type_name() { + return "std::vector<bool, _Alloc >"; + } + }; + } + } + + %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<bool, _Alloc >); + + +#ifdef %swig_vector_methods_val + // Add swig/language extra methods + %swig_vector_methods_val(std::vector<bool, _Alloc >); +#endif + + %std_vector_methods_val(vector); + +#if defined(SWIG_STD_MODERN_STL) && !defined(SWIG_STD_NOMODERN_STL) + void flip(); +#endif + + }; + +} diff --git a/devtools/swigwin-1.3.34/Lib/std/std_vectora.i b/devtools/swigwin-1.3.34/Lib/std/std_vectora.i new file mode 100644 index 0000000..0e83dc9 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_vectora.i @@ -0,0 +1,7 @@ +// +// We keep this file only for backward compatibility, since std_vector.i +// now uses the std::allocator parameter. +// + +%include <std_vector.i> + diff --git a/devtools/swigwin-1.3.34/Lib/std/std_wios.i b/devtools/swigwin-1.3.34/Lib/std/std_wios.i new file mode 100644 index 0000000..e9c5dd4 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_wios.i @@ -0,0 +1,7 @@ +/* + Provide 'std_ios.i' with wchar support. +*/ + +%include <wchar.i> +%include <std_ios.i> + diff --git a/devtools/swigwin-1.3.34/Lib/std/std_wiostream.i b/devtools/swigwin-1.3.34/Lib/std/std_wiostream.i new file mode 100644 index 0000000..b9bef90 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_wiostream.i @@ -0,0 +1,7 @@ +/* + Provide 'std_iostream.i' with wchar support. +*/ + +%include <wchar.i> +%include <std_iostream.i> + diff --git a/devtools/swigwin-1.3.34/Lib/std/std_wsstream.i b/devtools/swigwin-1.3.34/Lib/std/std_wsstream.i new file mode 100644 index 0000000..4c663fc --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_wsstream.i @@ -0,0 +1,7 @@ +/* + Provide 'std_sstream.i' with wchar support. +*/ + +%include <wchar.i> +%include <std_sstream.i> + diff --git a/devtools/swigwin-1.3.34/Lib/std/std_wstreambuf.i b/devtools/swigwin-1.3.34/Lib/std/std_wstreambuf.i new file mode 100644 index 0000000..86ac6af --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_wstreambuf.i @@ -0,0 +1,7 @@ +/* + Provide 'std_streambuf.i' with wchar support. +*/ + +%include <wchar.i> +%include <std_streambuf.i> + diff --git a/devtools/swigwin-1.3.34/Lib/std/std_wstring.i b/devtools/swigwin-1.3.34/Lib/std/std_wstring.i new file mode 100644 index 0000000..e54d212 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std/std_wstring.i @@ -0,0 +1,14 @@ +%include <wchar.i> +%include <std/std_basic_string.i> + +/* wide strings */ + +namespace std +{ + %std_comp_methods(basic_string<wchar_t>); + %naturalvar wstring; + typedef basic_string<wchar_t> wstring; +} + +%template(wstring) std::basic_string<wchar_t>; + diff --git a/devtools/swigwin-1.3.34/Lib/std_except.i b/devtools/swigwin-1.3.34/Lib/std_except.i new file mode 100644 index 0000000..af9803a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/std_except.i @@ -0,0 +1,58 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_except.i + * + * SWIG library file with typemaps to handle and throw STD exceptions in a + * language and STL independent way, i.e., the target language doesn't + * require to support STL but only the 'exception.i' mechanism. + * + * These typemaps are used when methods are declared with an STD + * exception specification, such as + * + * size_t at() const throw (std::out_of_range); + * + * The typemaps here are based on the language independent + * 'exception.i' library. If that is working in your target language, + * this file will work. + * + * If the target language doesn't implement a robust 'exception.i' + * mechanism, or you prefer other ways to map the STD exceptions, write + * a new std_except.i file in the target library directory. + * ----------------------------------------------------------------------------- */ + +#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGGUILE) || defined(SWIGUTL) +#error "This version of std_except.i should not be used" +#endif + +%{ +#include <stdexcept> +%} + +%include <exception.i> + + +%define %std_exception_map(Exception, Code) + %typemap(throws,noblock=1) Exception { + SWIG_exception(Code, $1.what()); + } + %ignore Exception; + struct Exception { + }; +%enddef + +namespace std { + %std_exception_map(bad_exception, SWIG_SystemError); + %std_exception_map(domain_error, SWIG_ValueError); + %std_exception_map(exception, SWIG_SystemError); + %std_exception_map(invalid_argument, SWIG_ValueError); + %std_exception_map(length_error, SWIG_IndexError); + %std_exception_map(logic_error, SWIG_RuntimeError); + %std_exception_map(out_of_range, SWIG_IndexError); + %std_exception_map(overflow_error, SWIG_OverflowError); + %std_exception_map(range_error, SWIG_OverflowError); + %std_exception_map(runtime_error, SWIG_RuntimeError); + %std_exception_map(underflow_error, SWIG_OverflowError); +} + diff --git a/devtools/swigwin-1.3.34/Lib/stdint.i b/devtools/swigwin-1.3.34/Lib/stdint.i new file mode 100644 index 0000000..7b48ca3 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/stdint.i @@ -0,0 +1,109 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * stdint.i + * + * SWIG library file for ISO C99 types: 7.18 Integer types <stdint.h> + * ----------------------------------------------------------------------------- */ + +%{ +#include <stdint.h> // Use the C99 official header +%} + +%include <swigarch.i> + +/* Exact integral types. */ + +/* Signed. */ + +typedef signed char int8_t; +typedef short int int16_t; +typedef int int32_t; +#if defined(SWIGWORDSIZE64) +typedef long int int64_t; +#else +typedef long long int int64_t; +#endif + +/* Unsigned. */ +typedef unsigned char uint8_t; +typedef unsigned short int uint16_t; +typedef unsigned int uint32_t; +#if defined(SWIGWORDSIZE64) +typedef unsigned long int uint64_t; +#else +typedef unsigned long long int uint64_t; +#endif + + +/* Small types. */ + +/* Signed. */ +typedef signed char int_least8_t; +typedef short int int_least16_t; +typedef int int_least32_t; +#if defined(SWIGWORDSIZE64) +typedef long int int_least64_t; +#else +typedef long long int int_least64_t; +#endif + +/* Unsigned. */ +typedef unsigned char uint_least8_t; +typedef unsigned short int uint_least16_t; +typedef unsigned int uint_least32_t; +#if defined(SWIGWORDSIZE64) +typedef unsigned long int uint_least64_t; +#else +typedef unsigned long long int uint_least64_t; +#endif + + +/* Fast types. */ + +/* Signed. */ +typedef signed char int_fast8_t; +#if defined(SWIGWORDSIZE64) +typedef long int int_fast16_t; +typedef long int int_fast32_t; +typedef long int int_fast64_t; +#else +typedef int int_fast16_t; +typedef int int_fast32_t; +typedef long long int int_fast64_t; +#endif + +/* Unsigned. */ +typedef unsigned char uint_fast8_t; +#if defined(SWIGWORDSIZE64) +typedef unsigned long int uint_fast16_t; +typedef unsigned long int uint_fast32_t; +typedef unsigned long int uint_fast64_t; +#else +typedef unsigned int uint_fast16_t; +typedef unsigned int uint_fast32_t; +typedef unsigned long long int uint_fast64_t; +#endif + + +/* Types for `void *' pointers. */ +#if defined(SWIGWORDSIZE64) +typedef long int intptr_t; +typedef unsigned long int uintptr_t; +#else +typedef int intptr_t; +typedef unsigned int uintptr_t; +#endif + + +/* Largest integral types. */ +#if defined(SWIGWORDSIZE64) +typedef long int intmax_t; +typedef unsigned long int uintmax_t; +#else +typedef long long int intmax_t; +typedef unsigned long long int uintmax_t; +#endif + + diff --git a/devtools/swigwin-1.3.34/Lib/stl.i b/devtools/swigwin-1.3.34/Lib/stl.i new file mode 100644 index 0000000..c3ade01 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/stl.i @@ -0,0 +1,10 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * stl.i + * ----------------------------------------------------------------------------- */ + +#warning "stl.i not implemented for this target" +#define SWIG_STL_UNIMPL + diff --git a/devtools/swigwin-1.3.34/Lib/swig.swg b/devtools/swigwin-1.3.34/Lib/swig.swg new file mode 100644 index 0000000..6f40a8f --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/swig.swg @@ -0,0 +1,670 @@ +/* ----------------------------------------------------------------------------- + * swig.swg + * + * Common macro definitions for various SWIG directives. This file is always + * included at the top of each input file. + * ----------------------------------------------------------------------------- */ + +/* ----------------------------------------------------------------------------- + * User Directives + * ----------------------------------------------------------------------------- */ + +/* Deprecated SWIG directives */ + +#define %disabledoc %warn "104:%disabledoc is deprecated" +#define %enabledoc %warn "105:%enabledoc is deprecated" +#define %doconly %warn "106:%doconly is deprecated" +#define %style %warn "107:%style is deprecated" /##/ +#define %localstyle %warn "108:%localstyle is deprecated" /##/ +#define %title %warn "109:%title is deprecated" /##/ +#define %section %warn "110:%section is deprecated" /##/ +#define %subsection %warn "111:%subsection is deprecated" /##/ +#define %subsubsection %warn "112:%subsubsection is deprecated" /##/ +#define %new %warn "117:%new is deprecated. Use %newobject" +#define %text %insert("null") + +/* Code insertion directives such as %wrapper %{ ... %} */ + +#define %init %insert("init") +#define %wrapper %insert("wrapper") +#define %header %insert("header") +#define %runtime %insert("runtime") + +/* Class extension */ + +#define %addmethods %warn "113:%addmethods is now %extend" %extend + +/* %ignore directive */ + +#define %ignore %rename($ignore) +#define %ignorewarn(x) %rename("$ignore:" x) + +/* Access control directives */ + +#define %readonly %warn "114:%readonly is deprecated. Use %immutable; " %feature("immutable"); +#define %readwrite %warn "115:%readwrite is deprecated. Use %mutable; " %feature("immutable",""); + +#define %immutable %feature("immutable") +#define %noimmutable %feature("immutable","0") +#define %clearimmutable %feature("immutable","") +#define %mutable %clearimmutable + +/* Generation of default constructors/destructors (old form, don't use) */ +#define %nodefault %feature("nodefault","1") +#define %default %feature("nodefault","0") +#define %clearnodefault %feature("nodefault","") +#define %makedefault %clearnodefault + +/* Disable the generation of implicit default constructor */ +#define %nodefaultctor %feature("nodefaultctor","1") +#define %defaultctor %feature("nodefaultctor","0") +#define %clearnodefaultctor %feature("nodefaultctor","") + +/* Disable the generation of implicit default destructor (dangerous) */ +#define %nodefaultdtor %feature("nodefaultdtor","1") +#define %defaultdtor %feature("nodefaultdtor","0") +#define %clearnodefaultdtor %feature("nodefaultdtor","") + +/* Enable the generation of copy constructor */ +#define %copyctor %feature("copyctor","1") +#define %nocopyctor %feature("copyctor","0") +#define %clearcopyctor %feature("copyctor","") + +/* Force the old nodefault behavior, ie disable both constructor and destructor */ +#define %oldnodefault %feature("oldnodefault","1") +#define %nooldnodefault %feature("oldnodefault","0") +#define %clearoldnodefault %feature("oldnodefault","") + +/* the %exception directive */ +#ifdef SWIGCSHARP +#define %exception %feature("except", canthrow=1) +#else +#define %exception %feature("except") +#endif +#define %noexception %feature("except","0") +#define %clearexception %feature("except","") + +/* the %allowexception directive allows the %exception feature to + be applied to set/get variable methods */ +#define %allowexception %feature("allowexcept") +#define %noallowexception %feature("allowexcept","0") +#define %clearallowexception %feature("allowexcept","") + +/* the %exceptionvar directive, as %exception but it is only applied + to set/get variable methods. You don't need to use the + %allowexception directive when using %exceptionvar. +*/ +#ifdef SWIGCSHARP +#define %exceptionvar %feature("exceptvar", canthrow=1) +#else +#define %exceptionvar %feature("exceptvar") +#endif +#define %noexceptionvar %feature("exceptvar","0") +#define %clearexceptionvar %feature("exceptvar","") + +/* the %catches directive */ +#define %catches(tlist...) %feature("catches","("`tlist`")") +#define %clearcatches %feature("catches","") + +/* the %exceptionclass directive */ +#define %exceptionclass %feature("exceptionclass") +#define %noexceptionclass %feature("exceptionclass","0") +#define %clearexceptionclass %feature("exceptionclass","") + +/* the %newobject directive */ +#define %newobject %feature("new") +#define %nonewobject %feature("new","0") +#define %clearnewobject %feature("new","") + +/* the %delobject directive */ +#define %delobject %feature("del") +#define %nodelobject %feature("del","0") +#define %cleardelobject %feature("del","") + +/* the %refobject/%unrefobject directives */ +#define %refobject %feature("ref") +#define %norefobject %feature("ref","0") +#define %clearrefobject %feature("ref","") + +#define %unrefobject %feature("unref") +#define %nounrefobject %feature("unref","0") +#define %clearunrefobject %feature("unref","") + +/* Directives for callback functions (experimental) */ +#define %callback(x) %feature("callback",`x`) +#define %nocallback %feature("callback","0") +#define %clearcallback %feature("callback","") + +/* the %fastdispatch directive */ +#define %fastdispatch %feature("fastdispatch") +#define %nofastdispatch %feature("fastdispatch","0") +#define %clearfastdispatch %feature("fastdispatch","") + +/* directors directives */ +#define %director %feature("director") +#define %nodirector %feature("director","0") +#define %cleardirector %feature("director","") + +/* naturalvar directives */ +#define %naturalvar %feature("naturalvar") +#define %nonaturalvar %feature("naturalvar","0") +#define %clearnaturalvar %feature("naturalvar","") + +/* valuewrapper directives */ +#define %valuewrapper %feature("valuewrapper",) +#define %clearvaluewrapper %feature("valuewrapper","") +#define %novaluewrapper %feature("novaluewrapper") +#define %clearnovaluewrapper %feature("novaluewrapper","") + +/* Contract support - Experimental and undocumented */ +#define %contract %feature("contract") +#define %nocontract %feature("contract","0") +#define %clearcontract %feature("contract","") + +/* Macro for setting a dynamic cast function */ +%define DYNAMIC_CAST(mangle,func) +%init %{ + mangle->dcast = (swig_dycast_func) func; +%} +%enddef + +/* aggregation support */ +/* + This macro performs constant aggregation. Basically the idea of + constant aggregation is that you can group a collection of constants + together. For example, suppose you have some code like this: + + #define UP 1 + #define DOWN 2 + #define LEFT 3 + #define RIGHT 4 + + Now, suppose you had a function like this: + + int move(int direction) + + In this case, you might want to restrict the direction argument to + one of the supplied constant names. To do this, you could write some + typemap code by hand. Alternatively, you can use the + %aggregate_check macro defined here to create a simple check + function for you. Here is an example: + + %aggregate_check(int, check_direction, UP, DOWN, LEFT, RIGHT); + + Now, using a typemap + + %typemap(check) int direction { + if (!check_direction($1)) SWIG_exception(SWIG_ValueError,"Bad direction."); + } + + or a contract (better) + + %contract move(int x) { + require: + check_direction(x); + } + +*/ + +%define %aggregate_check(TYPE, NAME, FIRST, ...) +%wrapper %{ +static int NAME(TYPE x) { + static TYPE values[] = { FIRST, ##__VA_ARGS__ }; + static int size = sizeof(values); + int i,j; + for (i = 0, j = 0; i < size; i+=sizeof(TYPE),j++) { + if (x == values[j]) return 1; + } + return 0; +} +%} +%enddef + + +/* ----------------------------------------------------------------------------- + * %rename predicates + * ----------------------------------------------------------------------------- */ +/* + Predicates to be used with %rename, for example: + + - to rename all the functions: + + %rename("%(utitle)s", %$isfunction) ""; + + - to rename only the member methods: + + %rename("m_%(utitle)s", %$isfunction, %$ismember) ""; + + - to rename only the global functions: + + %rename("m_%(utitle)s", %$isfunction, %$not %$ismember) ""; + + or + + %rename("g_%(utitle)s", %$isfunction, %$isglobal) ""; + + - to ignore the enumitems in a given class: + + %rename("$ignore", %$isenumitem, %$classname="MyClass") ""; + + we use the prefix '%$' to avoid clashings with other swig + macros/directives. + +*/ + +%define %$not "not" %enddef +%define %$isenum "match"="enum" %enddef +%define %$isenumitem "match"="enumitem" %enddef +%define %$isaccess "match"="access" %enddef +%define %$isclass "match"="class","notmatch$template$templatetype"="class" %enddef +%define %$isextend "match"="extend" %enddef +%define %$isextend "match"="extend" %enddef +%define %$isconstructor "match"="constructor" %enddef +%define %$isdestructor "match"="destructor" %enddef +%define %$isnamespace "match"="namespace" %enddef +%define %$istemplate "match"="template" %enddef +%define %$isconstant "match"="constant" %enddef /* %constant definition */ + +%define %$isunion "match$kind"="union" %enddef +%define %$isfunction "match$kind"="function" %enddef +%define %$isvariable "match$kind"="variable" %enddef +%define %$isimmutable "match$feature:immutable"="1" %enddef +%define %$hasconsttype "match$hasconsttype"="1" %enddef +%define %$hasvalue "match$hasvalue"="1" %enddef +%define %$isextension "match$isextension"="1" %enddef + +%define %$isstatic "match$storage"="static" %enddef +%define %$isfriend "match$storage"="friend" %enddef +%define %$istypedef "match$storage"="typedef" %enddef +%define %$isvirtual "match$storage"="virtual" %enddef +%define %$isexplicit "match$storage"="explicit" %enddef +%define %$isextern "match$storage"="extern" %enddef + +%define %$ismember "match$ismember"="1" %enddef +%define %$isglobal %not %ismember %enddef +%define %$innamespace "match$parentNode$nodeType"="namespace" %enddef + +%define %$ispublic "match$access"="public" %enddef +%define %$isprotected "match$access"="protected" %enddef +%define %$isprivate "match$access"="private" %enddef + +%define %$ismemberget "match$memberget"="1" %enddef +%define %$ismemberset "match$memberset"="1" %enddef + +%define %$classname %ismember,match$parentNode$name %enddef + +/* ----------------------------------------------------------------------------- + * Include all the warnings labels and macros + * ----------------------------------------------------------------------------- */ + +%include <swigwarnings.swg> + +/* ----------------------------------------------------------------------------- + * Default handling of certain overloaded operators + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +%ignoreoperator(NEW) operator new; +%ignoreoperator(DELETE) operator delete; +%ignoreoperator(NEWARR) operator new[]; +%ignoreoperator(DELARR) operator delete[]; + +/* add C++ operator aliases */ +%rename("operator &&") operator and; // `and' `&&' +%rename("operator ||") operator or; // `or' `||' +%rename("operator !") operator not; // `not' `!' +%rename("operator &=") operator and_eq; // `and_eq' `&=' +%rename("operator &") operator bitand; // `bitand' `&' +%rename("operator |") operator bitor; // `bitor' `|' +%rename("operator ~") operator compl; // `compl' `~' +%rename("operator !=") operator not_eq; // `not_eq' `!=' +%rename("operator |=") operator or_eq; // `or_eq' `|=' +%rename("operator ^") operator xor; // `xor' `^' +%rename("operator ^=") operator xor_eq; // `xor_eq' `^=' + +/* Smart pointer handling */ + +%rename(__deref__) *::operator->; +%rename(__ref__) *::operator*(); +%rename(__ref__) *::operator*() const; + +/* Define std namespace */ +namespace std { +} +#endif + +/* ----------------------------------------------------------------------------- + * Default char * and C array typemaps + * ----------------------------------------------------------------------------- */ + +/* Set up the typemap for handling new return strings */ + +#ifdef __cplusplus +%typemap(newfree) char * "delete [] $1;"; +#else +%typemap(newfree) char * "free($1);"; +#endif + +/* Default typemap for handling char * members */ + +#ifdef __cplusplus +%typemap(memberin) char * { + if ($1) delete [] $1; + if ($input) { + $1 = ($1_type) (new char[strlen((const char *)$input)+1]); + strcpy((char *)$1, (const char *)$input); + } else { + $1 = 0; + } +} +%typemap(memberin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * { + if ($input) { + $1 = ($1_type) (new char[strlen((const char *)$input)+1]); + strcpy((char *)$1, (const char *)$input); + } else { + $1 = 0; + } +} +%typemap(globalin) char * { + if ($1) delete [] $1; + if ($input) { + $1 = ($1_type) (new char[strlen((const char *)$input)+1]); + strcpy((char *)$1, (const char *)$input); + } else { + $1 = 0; + } +} +%typemap(globalin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * { + if ($input) { + $1 = ($1_type) (new char[strlen((const char *)$input)+1]); + strcpy((char *)$1, (const char *)$input); + } else { + $1 = 0; + } +} +#else +%typemap(memberin) char * { + if ($1) free((char *)$1); + if ($input) { + $1 = ($1_type) malloc(strlen((const char *)$input)+1); + strcpy((char *)$1, (const char *)$input); + } else { + $1 = 0; + } +} +%typemap(memberin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * { + if ($input) { + $1 = ($1_type) malloc(strlen((const char *)$input)+1); + strcpy((char *)$1, (const char *)$input); + } else { + $1 = 0; + } +} +%typemap(globalin) char * { + if ($1) free((char *)$1); + if ($input) { + $1 = ($1_type) malloc(strlen((const char *)$input)+1); + strcpy((char *)$1, (const char *)$input); + } else { + $1 = 0; + } +} +%typemap(globalin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * { + if ($input) { + $1 = ($1_type) malloc(strlen((const char *)$input)+1); + strcpy((char *)$1, (const char *)$input); + } else { + $1 = 0; + } +} + +#endif + +/* Character array handling */ + +%typemap(memberin) char [ANY] { + if ($input) strncpy((char *)$1, (const char *)$input, $1_dim0); + else $1[0] = 0; +} + +%typemap(globalin) char [ANY] { + if ($input) strncpy((char *)$1, (const char *)$input, $1_dim0); + else $1[0] = 0; +} + +%typemap(memberin) char [] { + if ($input) strcpy((char *)$1, (const char *)$input); + else $1[0] = 0; +} + +%typemap(globalin) char [] { + if ($input) strcpy((char *)$1, (const char *)$input); + else $1[0] = 0; +} + +/* memberin/globalin typemap for arrays. */ + +%typemap(memberin) SWIGTYPE [ANY] { + size_t ii; + $1_basetype *b = ($1_basetype *) $1; + for (ii = 0; ii < (size_t)$1_size; ii++) b[ii] = *(($1_basetype *) $input + ii); +} + +%typemap(globalin) SWIGTYPE [ANY] { + size_t ii; + $1_basetype *b = ($1_basetype *) $1; + for (ii = 0; ii < (size_t)$1_size; ii++) b[ii] = *(($1_basetype *) $input + ii); +} + +/* memberin/globalin typemap for double arrays. */ + +%typemap(memberin) SWIGTYPE [ANY][ANY] { + $basetype (*inp)[$dim1] = ($basetype (*)[$dim1])($input); + $basetype (*dest)[$dim1] = ($basetype (*)[$dim1])($1); + size_t ii = 0; + for (; ii < $dim0; ++ii) { + $basetype *ip = inp[ii]; + $basetype *dp = dest[ii]; + size_t jj = 0; + for (; jj < $dim1; ++jj) dp[jj] = ip[jj]; + } +} + +%typemap(globalin) SWIGTYPE [ANY][ANY] { + $basetype (*inp)[$dim1] = ($basetype (*)[$dim1])($input); + $basetype (*dest)[$dim1] = ($basetype (*)[$dim1])($1); + size_t ii = 0; + for (; ii < $dim0; ++ii) { + $basetype *ip = inp[ii]; + $basetype *dp = dest[ii]; + size_t jj = 0; + for (; jj < $dim1; ++jj) dp[jj] = ip[jj]; + } +} + +/* Typemap for variable length arguments sentinel value. Used + by the %varargs directive. */ + +%typemap(in,numinputs=0) SWIGTYPE *VARARGS_SENTINEL, SWIGTYPE VARARGS_SENTINEL ""; + + +/* ----------------------------------------------------------------------------- + * Overloading support + * ----------------------------------------------------------------------------- */ + +/* + * Function/method overloading support. This is done through typemaps, + * but also involve a precedence level. + */ + +/* Macro for overload resolution */ + +%define %typecheck(_x...) %typemap(typecheck, precedence=_x) %enddef + +/* Macros for precedence levels */ + +%define SWIG_TYPECHECK_POINTER 0 %enddef +%define SWIG_TYPECHECK_ITERATOR 5 %enddef +%define SWIG_TYPECHECK_VOIDPTR 10 %enddef +%define SWIG_TYPECHECK_BOOL 15 %enddef +%define SWIG_TYPECHECK_UINT8 20 %enddef +%define SWIG_TYPECHECK_INT8 25 %enddef +%define SWIG_TYPECHECK_UINT16 30 %enddef +%define SWIG_TYPECHECK_INT16 35 %enddef +%define SWIG_TYPECHECK_UINT32 40 %enddef +%define SWIG_TYPECHECK_INT32 45 %enddef +%define SWIG_TYPECHECK_SIZE 47 %enddef +%define SWIG_TYPECHECK_PTRDIFF 48 %enddef +%define SWIG_TYPECHECK_UINT64 50 %enddef +%define SWIG_TYPECHECK_INT64 55 %enddef +%define SWIG_TYPECHECK_UINT128 60 %enddef +%define SWIG_TYPECHECK_INT128 65 %enddef +%define SWIG_TYPECHECK_INTEGER 70 %enddef +%define SWIG_TYPECHECK_FLOAT 80 %enddef +%define SWIG_TYPECHECK_DOUBLE 90 %enddef +%define SWIG_TYPECHECK_CPLXFLT 95 %enddef +%define SWIG_TYPECHECK_CPLXDBL 100 %enddef +%define SWIG_TYPECHECK_COMPLEX 105 %enddef +%define SWIG_TYPECHECK_UNICHAR 110 %enddef +%define SWIG_TYPECHECK_STDUNISTRING 115 %enddef +%define SWIG_TYPECHECK_UNISTRING 120 %enddef +%define SWIG_TYPECHECK_CHAR 130 %enddef +%define SWIG_TYPECHECK_STDSTRING 135 %enddef +%define SWIG_TYPECHECK_STRING 140 %enddef +%define SWIG_TYPECHECK_PAIR 150 %enddef +%define SWIG_TYPECHECK_VECTOR 160 %enddef +%define SWIG_TYPECHECK_DEQUE 170 %enddef +%define SWIG_TYPECHECK_LIST 180 %enddef +%define SWIG_TYPECHECK_SET 190 %enddef +%define SWIG_TYPECHECK_MULTISET 200 %enddef +%define SWIG_TYPECHECK_MAP 210 %enddef +%define SWIG_TYPECHECK_MULTIMAP 220 %enddef +%define SWIG_TYPECHECK_STACK 230 %enddef +%define SWIG_TYPECHECK_QUEUE 240 %enddef + +%define SWIG_TYPECHECK_BOOL_ARRAY 1015 %enddef +%define SWIG_TYPECHECK_INT8_ARRAY 1025 %enddef +%define SWIG_TYPECHECK_INT16_ARRAY 1035 %enddef +%define SWIG_TYPECHECK_INT32_ARRAY 1045 %enddef +%define SWIG_TYPECHECK_INT64_ARRAY 1055 %enddef +%define SWIG_TYPECHECK_INT128_ARRAY 1065 %enddef +%define SWIG_TYPECHECK_FLOAT_ARRAY 1080 %enddef +%define SWIG_TYPECHECK_DOUBLE_ARRAY 1090 %enddef +%define SWIG_TYPECHECK_CHAR_ARRAY 1130 %enddef +%define SWIG_TYPECHECK_STRING_ARRAY 1140 %enddef +%define SWIG_TYPECHECK_OBJECT_ARRAY 1150 %enddef + +%define SWIG_TYPECHECK_BOOL_PTR 2015 %enddef +%define SWIG_TYPECHECK_UINT8_PTR 2020 %enddef +%define SWIG_TYPECHECK_INT8_PTR 2025 %enddef +%define SWIG_TYPECHECK_UINT16_PTR 2030 %enddef +%define SWIG_TYPECHECK_INT16_PTR 2035 %enddef +%define SWIG_TYPECHECK_UINT32_PTR 2040 %enddef +%define SWIG_TYPECHECK_INT32_PTR 2045 %enddef +%define SWIG_TYPECHECK_UINT64_PTR 2050 %enddef +%define SWIG_TYPECHECK_INT64_PTR 2055 %enddef +%define SWIG_TYPECHECK_FLOAT_PTR 2080 %enddef +%define SWIG_TYPECHECK_DOUBLE_PTR 2090 %enddef +%define SWIG_TYPECHECK_CHAR_PTR 2130 %enddef + + +%define SWIG_TYPECHECK_SWIGOBJECT 5000 %enddef + + +/* ----------------------------------------------------------------------------- + * Runtime code + * ----------------------------------------------------------------------------- */ + +/* The SwigValueWrapper class */ + +/* + * This template wrapper is used to handle C++ objects that are passed or + * returned by value. This is necessary to handle objects that define + * no default-constructor (making it difficult for SWIG to properly declare + * local variables). + * + * The wrapper is used as follows. First consider a function like this: + * + * Vector cross_product(Vector a, Vector b) + * + * Now, if Vector is defined as a C++ class with no default constructor, + * code is generated as follows: + * + * Vector *wrap_cross_product(Vector *inarg1, Vector *inarg2) { + * SwigValueWrapper<Vector> arg1; + * SwigValueWrapper<Vector> arg2; + * SwigValueWrapper<Vector> result; + * + * arg1 = *inarg1; + * arg2 = *inarg2; + * ... + * result = cross_product(arg1,arg2); + * ... + * return new Vector(result); + * } + * + * In the wrappers, the template SwigValueWrapper simply provides a thin + * layer around a Vector *. However, it does this in a way that allows + * the object to be bound after the variable declaration (which is not possible + * with the bare object when it lacks a default constructor). + * + * An observant reader will notice that the code after the variable declarations + * is *identical* to the code used for classes that do define default constructors. + * Thus, this neat trick allows us to fix this special case without having to + * make massive changes to typemaps and other parts of the SWIG code generator. + * + * Note: this code is not included when SWIG runs in C-mode, when classes + * define default constructors, or when pointers and references are used. + * SWIG tries to avoid doing this except in very special circumstances. + * + * Note: This solution suffers from making a large number of copies + * of the underlying object. However, this is needed in the interest of + * safety and in order to cover all of the possible ways in which a value + * might be assigned. For example: + * + * arg1 = *inarg1; // Assignment from a pointer + * arg1 = Vector(1,2,3); // Assignment from a value + * + * This wrapping technique was suggested by William Fulton and is henceforth + * known as the "Fulton Transform" :-). + */ + +#ifdef __cplusplus +%insert("runtime") %{ +#ifdef __cplusplus +template<typename T> class SwigValueWrapper { + T *tt; +public: + SwigValueWrapper() : tt(0) { } + SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { } + SwigValueWrapper(const T& t) : tt(new T(t)) { } + ~SwigValueWrapper() { delete tt; } + SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } + operator T&() const { return *tt; } + T *operator&() { return tt; } +private: + SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs); +};%} + +/* + * SwigValueInit() is a generic initialisation solution as the following approach: + * + * T c_result = T(); + * + * doesn't compile for all types for example: + * + * unsigned int c_result = unsigned int(); + */ +%insert("runtime") %{ +template <typename T> T SwigValueInit() { + return T(); +} +#endif +%} +#endif + +/* The swiglabels */ + +%insert("runtime") "swiglabels.swg" + + diff --git a/devtools/swigwin-1.3.34/Lib/swigarch.i b/devtools/swigwin-1.3.34/Lib/swigarch.i new file mode 100644 index 0000000..260b608 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/swigarch.i @@ -0,0 +1,65 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * swigarch.i + * + * SWIG library file for 32bit/64bit code specialization and checking. + * + * Use only in extreme cases, when no arch. independent code can be + * generated + * + * To activate architecture specific code, use + * + * swig -DSWIGWORDSIZE32 + * + * or + * + * swig -DSWIGWORDSIZE64 + * + * Note that extra checking code will be added to the wrapped code, + * which will prevent the compilation in a different architecture. + * + * If you don't specify the SWIGWORDSIZE (the default case), swig will + * generate architecture independent and/or 32bits code, with no extra + * checking code added. + * ----------------------------------------------------------------------------- */ + +#if !defined(SWIGWORDSIZE32) && !defined(SWIGWORDSIZE64) +# if (__WORDSIZE == 32) +# define SWIGWORDSIZE32 +# endif +#endif + +#if !defined(SWIGWORDSIZE64) && !defined(SWIGWORDSIZE32) +# if defined(__x86_64) || defined(__x86_64__) || (__WORDSIZE == 64) +# define SWIGWORDSIZE64 +# endif +#endif + + +#ifdef SWIGWORDSIZE32 +%{ +#define SWIGWORDSIZE32 +#ifndef LONG_MAX +#include <limits.h> +#endif +#if (__WORDSIZE == 64) || (LONG_MAX != INT_MAX) +# error "SWIG wrapped code invalid in 64 bit architecture, regenarete code using -DSWIGWORDSIZE64" +#endif +%} +#endif + +#ifdef SWIGWORDSIZE64 +%{ +#define SWIGWORDSIZE64 +#ifndef LONG_MAX +#include <limits.h> +#endif +#if (__WORDSIZE == 32) || (LONG_MAX == INT_MAX) +# error "SWIG wrapped code invalid in 32 bit architecture, regenarete code using -DSWIGWORDSIZE32" +#endif +%} +#endif + + diff --git a/devtools/swigwin-1.3.34/Lib/swigerrors.swg b/devtools/swigwin-1.3.34/Lib/swigerrors.swg new file mode 100644 index 0000000..32857c4 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/swigerrors.swg @@ -0,0 +1,16 @@ +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + diff --git a/devtools/swigwin-1.3.34/Lib/swiginit.swg b/devtools/swigwin-1.3.34/Lib/swiginit.swg new file mode 100644 index 0000000..903ac54 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/swiginit.swg @@ -0,0 +1,236 @@ +/* ----------------------------------------------------------------------------- + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + * + * The generated swig_type_info structures are assigned staticly to an initial + * array. We just loop through that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + * + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* c-mode */ +#endif +#endif + +#if 0 +#define SWIGRUNTIME_DEBUG +#endif + + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + size_t i; + swig_module_info *module_head, *iter; + int found, init; + + clientdata = clientdata; + + /* check to see if the circular list has been setup, if not, set it up */ + if (swig_module.next==0) { + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + swig_module.next = &swig_module; + init = 1; + } else { + init = 0; + } + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (!module_head) { + /* This is the first module loaded for this interpreter */ + /* so set the swig module into the interpreter */ + SWIG_SetModule(clientdata, &swig_module); + module_head = &swig_module; + } else { + /* the interpreter has loaded a SWIG module, but has it loaded this one? */ + found=0; + iter=module_head; + do { + if (iter==&swig_module) { + found=1; + break; + } + iter=iter->next; + } while (iter!= module_head); + + /* if the is found in the list, then all is done and we may leave */ + if (found) return; + /* otherwise we must add out module into the list */ + swig_module.next = module_head->next; + module_head->next = &swig_module; + } + + /* When multiple interpeters are used, a module could have already been initialized in + a different interpreter, but not yet have a pointer in this interpreter. + In this case, we do not want to continue adding types... everything should be + set up already */ + if (init == 0) return; + + /* Now work on filling in swig_module.types */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: size %d\n", swig_module.size); +#endif + for (i = 0; i < swig_module.size; ++i) { + swig_type_info *type = 0; + swig_type_info *ret; + swig_cast_info *cast; + +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); +#endif + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found type %s\n", type->name); +#endif + if (swig_module.type_initial[i]->clientdata) { + type->clientdata = swig_module.type_initial[i]->clientdata; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); +#endif + } + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + + /* Don't need to add information already in the list */ + ret = 0; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); +#endif + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); +#ifdef SWIGRUNTIME_DEBUG + if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); +#endif + } + if (ret) { + if (type == swig_module.type_initial[i]) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: skip old type %s\n", ret->name); +#endif + cast->type = ret; + ret = 0; + } else { + /* Check for casting already in the list */ + swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); +#ifdef SWIGRUNTIME_DEBUG + if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); +#endif + if (!ocast) ret = 0; + } + } + + if (!ret) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); +#endif + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + cast++; + } + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; + +#ifdef SWIGRUNTIME_DEBUG + printf("**** SWIG_InitializeModule: Cast List ******\n"); + for (i = 0; i < swig_module.size; ++i) { + int j = 0; + swig_cast_info *cast = swig_module.cast_initial[i]; + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + while (cast->type) { + printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); + cast++; + ++j; + } + printf("---- Total casts: %d\n",j); + } + printf("**** SWIG_InitializeModule: Cast List ******\n"); +#endif +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +#if 0 +{ /* c-mode */ +#endif +} +#endif diff --git a/devtools/swigwin-1.3.34/Lib/swiglabels.swg b/devtools/swigwin-1.3.34/Lib/swiglabels.swg new file mode 100644 index 0000000..09de6c9 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/swiglabels.swg @@ -0,0 +1,102 @@ +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods */ +#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + diff --git a/devtools/swigwin-1.3.34/Lib/swigrun.i b/devtools/swigwin-1.3.34/Lib/swigrun.i new file mode 100644 index 0000000..17a1409 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/swigrun.i @@ -0,0 +1,11 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * swigrun.i + * + * Empty module (for now). Placeholder for runtime libs + * ----------------------------------------------------------------------------- */ + +%module swigrun + diff --git a/devtools/swigwin-1.3.34/Lib/swigrun.swg b/devtools/swigwin-1.3.34/Lib/swigrun.swg new file mode 100644 index 0000000..9ee676a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/swigrun.swg @@ -0,0 +1,569 @@ +/* ----------------------------------------------------------------------------- + * swigrun.swg + * + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "4" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the swig runtime code. + In 99.9% of the cases, swig just needs to declare them as 'static'. + + But only do this if is strictly necessary, ie, if you have problems + with your compiler or so. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +/* Generic buffer size */ +#ifndef SWIG_BUFFER_SIZE +# define SWIG_BUFFER_SIZE 1024 +#endif + +/* Flags for pointer conversions */ +#define SWIG_POINTER_DISOWN 0x1 +#define SWIG_CAST_NEW_MEMORY 0x2 + +/* Flags for new pointer objects */ +#define SWIG_POINTER_OWN 0x1 + + +/* + Flags/methods for returning states. + + The swig conversion methods, as ConvertPtr, return and integer + that tells if the conversion was successful or not. And if not, + an error code can be returned (see swigerrors.swg for the codes). + + Use the following macros/flags to set or process the returning + states. + + In old swig versions, you usually write code as: + + if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { + // success code + } else { + //fail code + } + + Now you can be more explicit as: + + int res = SWIG_ConvertPtr(obj,vptr,ty.flags); + if (SWIG_IsOK(res)) { + // success code + } else { + // fail code + } + + that seems to be the same, but now you can also do + + Type *ptr; + int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); + if (SWIG_IsOK(res)) { + // success code + if (SWIG_IsNewObj(res) { + ... + delete *ptr; + } else { + ... + } + } else { + // fail code + } + + I.e., now SWIG_ConvertPtr can return new objects and you can + identify the case and take care of the deallocation. Of course that + requires also to SWIG_ConvertPtr to return new result values, as + + int SWIG_ConvertPtr(obj, ptr,...) { + if (<obj is ok>) { + if (<need new object>) { + *ptr = <ptr to new allocated object>; + return SWIG_NEWOBJ; + } else { + *ptr = <ptr to old object>; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } + } + + Of course, returning the plain '0(success)/-1(fail)' still works, but you can be + more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the + swig errors code. + + Finally, if the SWIG_CASTRANK_MODE is enabled, the result code + allows to return the 'cast rank', for example, if you have this + + int food(double) + int fooi(int); + + and you call + + food(1) // cast rank '1' (1 -> 1.0) + fooi(1) // cast rank '0' + + just use the SWIG_AddCast()/SWIG_CheckState() + + + */ +#define SWIG_OK (0) +#define SWIG_ERROR (-1) +#define SWIG_IsOK(r) (r >= 0) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) + +/* The CastRankLimit says how many bits are used for the cast rank */ +#define SWIG_CASTRANKLIMIT (1 << 8) +/* The NewMask denotes the object was created (using new/malloc) */ +#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) +/* The TmpMask is for in/out typemaps that use temporal objects */ +#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) +/* Simple returning values */ +#define SWIG_BADOBJ (SWIG_ERROR) +#define SWIG_OLDOBJ (SWIG_OK) +#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) +#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) +/* Check, add and del mask methods */ +#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) +#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) +#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) +#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) +#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) +#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) + + +/* Cast-Rank Mode */ +#if defined(SWIG_CASTRANK_MODE) +# ifndef SWIG_TypeRank +# define SWIG_TypeRank unsigned long +# endif +# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ +# define SWIG_MAXCASTRANK (2) +# endif +# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) +# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) +SWIGINTERNINLINE int SWIG_AddCast(int r) { + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; +} +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +} +#else /* no cast-rank mode */ +# define SWIG_AddCast +# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) +#endif + + + + +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *, int *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store information on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class<int>" == "Class<int >", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; + } + return (int)((l1 - f1) - (l2 - f2)); +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCompare(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + + +/* think of this as a c++ template<> or a scheme macro */ +#define SWIG_TypeCheck_Template(comparison, ty) \ + if (ty) { \ + swig_cast_info *iter = ty->cast; \ + while (iter) { \ + if (comparison) { \ + if (iter == ty->cast) return iter; \ + /* Move iter to the top of the linked list */ \ + iter->prev->next = iter->next; \ + if (iter->next) \ + iter->next->prev = iter->prev; \ + iter->next = ty->cast; \ + iter->prev = 0; \ + if (ty->cast) ty->cast->prev = iter; \ + ty->cast = iter; \ + return iter; \ + } \ + iter = iter->next; \ + } \ + } \ + return 0 + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); +} + +/* Same as previous function, except strcmp is replaced with a pointer comparison */ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { + SWIG_TypeCheck_Template(iter->type == from, into); +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (!type) return NULL; + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} +SWIGRUNTIME void +SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { + SWIG_TypeClientData(ti, clientdata); + ti->owndata = 1; +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + register size_t l = 0; + register size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + register size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif diff --git a/devtools/swigwin-1.3.34/Lib/swigwarn.swg b/devtools/swigwin-1.3.34/Lib/swigwarn.swg new file mode 100644 index 0000000..dd7d22b --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/swigwarn.swg @@ -0,0 +1,258 @@ +/* Automatically generated file containing all the swig warning codes. */ +/* Do not modify this file by hand, change 'Source/Include/swigwarn.h' */ +/* and use the command 'make Lib/swigwarn.swg' instead. */ + + +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * swigwarn.h + * + * SWIG warning message numbers + * This file serves as the main registry of warning message numbers. Some of these + * numbers are used internally in the C/C++ source code of SWIG. However, some + * of the numbers are used in SWIG configuration files (swig.swg and others). + * + * The numbers are roughly organized into a few different classes by functionality. + * + * Even though symbolic constants are used in the SWIG source, this is + * not always the case in SWIG interface files. Do not change the + * numbers in this file. + * ----------------------------------------------------------------------------- */ + +/* $Id: swigwarn.h 9906 2007-08-17 20:42:19Z wsfulton $ */ + + +%define SWIGWARN_NONE 0 %enddef + +/* -- Deprecated features -- */ + +%define SWIGWARN_DEPRECATED_EXTERN 101 %enddef +%define SWIGWARN_DEPRECATED_VAL 102 %enddef +%define SWIGWARN_DEPRECATED_OUT 103 %enddef +%define SWIGWARN_DEPRECATED_DISABLEDOC 104 %enddef +%define SWIGWARN_DEPRECATED_ENABLEDOC 105 %enddef +%define SWIGWARN_DEPRECATED_DOCONLY 106 %enddef +%define SWIGWARN_DEPRECATED_STYLE 107 %enddef +%define SWIGWARN_DEPRECATED_LOCALSTYLE 108 %enddef +%define SWIGWARN_DEPRECATED_TITLE 109 %enddef +%define SWIGWARN_DEPRECATED_SECTION 110 %enddef +%define SWIGWARN_DEPRECATED_SUBSECTION 111 %enddef +%define SWIGWARN_DEPRECATED_SUBSUBSECTION 112 %enddef +%define SWIGWARN_DEPRECATED_ADDMETHODS 113 %enddef +%define SWIGWARN_DEPRECATED_READONLY 114 %enddef +%define SWIGWARN_DEPRECATED_READWRITE 115 %enddef +%define SWIGWARN_DEPRECATED_EXCEPT 116 %enddef +%define SWIGWARN_DEPRECATED_NEW 117 %enddef +%define SWIGWARN_DEPRECATED_EXCEPT_TM 118 %enddef +%define SWIGWARN_DEPRECATED_IGNORE_TM 119 %enddef +%define SWIGWARN_DEPRECATED_OPTC 120 %enddef +%define SWIGWARN_DEPRECATED_NAME 121 %enddef +%define SWIGWARN_DEPRECATED_NOEXTERN 122 %enddef +%define SWIGWARN_DEPRECATED_NODEFAULT 123 %enddef +%define SWIGWARN_DEPRECATED_TYPEMAP_LANG 124 %enddef + +/* -- Preprocessor -- */ + +%define SWIGWARN_PP_MISSING_FILE 201 %enddef +%define SWIGWARN_PP_EVALUATION 202 %enddef +%define SWIGWARN_PP_INCLUDEALL_IMPORTALL 203 %enddef +%define SWIGWARN_PP_CPP_WARNING 204 %enddef +%define SWIGWARN_PP_CPP_ERROR 205 %enddef + +/* -- C/C++ Parser -- */ + +%define SWIGWARN_PARSE_CLASS_KEYWORD 301 %enddef +%define SWIGWARN_PARSE_REDEFINED 302 %enddef +%define SWIGWARN_PARSE_EXTEND_UNDEF 303 %enddef +%define SWIGWARN_PARSE_UNSUPPORTED_VALUE 304 %enddef +%define SWIGWARN_PARSE_BAD_VALUE 305 %enddef +%define SWIGWARN_PARSE_PRIVATE 306 %enddef +%define SWIGWARN_PARSE_BAD_DEFAULT 307 %enddef +%define SWIGWARN_PARSE_NAMESPACE_ALIAS 308 %enddef +%define SWIGWARN_PARSE_PRIVATE_INHERIT 309 %enddef +%define SWIGWARN_PARSE_TEMPLATE_REPEAT 310 %enddef +%define SWIGWARN_PARSE_TEMPLATE_PARTIAL 311 %enddef +%define SWIGWARN_PARSE_NESTED_CLASS 312 %enddef +%define SWIGWARN_PARSE_UNDEFINED_EXTERN 313 %enddef +%define SWIGWARN_PARSE_KEYWORD 314 %enddef +%define SWIGWARN_PARSE_USING_UNDEF 315 %enddef +%define SWIGWARN_PARSE_MODULE_REPEAT 316 %enddef +%define SWIGWARN_PARSE_TEMPLATE_SP_UNDEF 317 %enddef +%define SWIGWARN_PARSE_TEMPLATE_AMBIG 318 %enddef +%define SWIGWARN_PARSE_NO_ACCESS 319 %enddef +%define SWIGWARN_PARSE_EXPLICIT_TEMPLATE 320 %enddef +%define SWIGWARN_PARSE_BUILTIN_NAME 321 %enddef +%define SWIGWARN_PARSE_REDUNDANT 322 %enddef +%define SWIGWARN_PARSE_REC_INHERITANCE 323 %enddef + +%define SWIGWARN_IGNORE_OPERATOR_NEW 350 %enddef /* new */ +%define SWIGWARN_IGNORE_OPERATOR_DELETE 351 %enddef /* delete */ +%define SWIGWARN_IGNORE_OPERATOR_PLUS 352 %enddef /* + */ +%define SWIGWARN_IGNORE_OPERATOR_MINUS 353 %enddef /* - */ +%define SWIGWARN_IGNORE_OPERATOR_MUL 354 %enddef /* * */ +%define SWIGWARN_IGNORE_OPERATOR_DIV 355 %enddef /* / */ +%define SWIGWARN_IGNORE_OPERATOR_MOD 356 %enddef /* % */ +%define SWIGWARN_IGNORE_OPERATOR_XOR 357 %enddef /* ^ */ +%define SWIGWARN_IGNORE_OPERATOR_AND 358 %enddef /* & */ +%define SWIGWARN_IGNORE_OPERATOR_OR 359 %enddef /* | */ +%define SWIGWARN_IGNORE_OPERATOR_NOT 360 %enddef /* ~ */ +%define SWIGWARN_IGNORE_OPERATOR_LNOT 361 %enddef /* ! */ +%define SWIGWARN_IGNORE_OPERATOR_EQ 362 %enddef /* = */ +%define SWIGWARN_IGNORE_OPERATOR_LT 363 %enddef /* < */ +%define SWIGWARN_IGNORE_OPERATOR_GT 364 %enddef /* > */ +%define SWIGWARN_IGNORE_OPERATOR_PLUSEQ 365 %enddef /* += */ +%define SWIGWARN_IGNORE_OPERATOR_MINUSEQ 366 %enddef /* -= */ +%define SWIGWARN_IGNORE_OPERATOR_MULEQ 367 %enddef /* *= */ +%define SWIGWARN_IGNORE_OPERATOR_DIVEQ 368 %enddef /* /= */ +%define SWIGWARN_IGNORE_OPERATOR_MODEQ 369 %enddef /* %= */ +%define SWIGWARN_IGNORE_OPERATOR_XOREQ 370 %enddef /* ^= */ +%define SWIGWARN_IGNORE_OPERATOR_ANDEQ 371 %enddef /* &= */ +%define SWIGWARN_IGNORE_OPERATOR_OREQ 372 %enddef /* |= */ +%define SWIGWARN_IGNORE_OPERATOR_LSHIFT 373 %enddef /* << */ +%define SWIGWARN_IGNORE_OPERATOR_RSHIFT 374 %enddef /* >> */ +%define SWIGWARN_IGNORE_OPERATOR_LSHIFTEQ 375 %enddef /* <<= */ +%define SWIGWARN_IGNORE_OPERATOR_RSHIFTEQ 376 %enddef /* >>= */ +%define SWIGWARN_IGNORE_OPERATOR_EQUALTO 377 %enddef /* == */ +%define SWIGWARN_IGNORE_OPERATOR_NOTEQUAL 378 %enddef /* != */ +%define SWIGWARN_IGNORE_OPERATOR_LTEQUAL 379 %enddef /* <= */ +%define SWIGWARN_IGNORE_OPERATOR_GTEQUAL 380 %enddef /* >= */ +%define SWIGWARN_IGNORE_OPERATOR_LAND 381 %enddef /* && */ +%define SWIGWARN_IGNORE_OPERATOR_LOR 382 %enddef /* || */ +%define SWIGWARN_IGNORE_OPERATOR_PLUSPLUS 383 %enddef /* ++ */ +%define SWIGWARN_IGNORE_OPERATOR_MINUSMINUS 384 %enddef /* -- */ +%define SWIGWARN_IGNORE_OPERATOR_COMMA 385 %enddef /* , */ +%define SWIGWARN_IGNORE_OPERATOR_ARROWSTAR 386 %enddef /* ->* */ +%define SWIGWARN_IGNORE_OPERATOR_ARROW 387 %enddef /* -> */ +%define SWIGWARN_IGNORE_OPERATOR_CALL 388 %enddef /* () */ +%define SWIGWARN_IGNORE_OPERATOR_INDEX 389 %enddef /* [] */ +%define SWIGWARN_IGNORE_OPERATOR_UPLUS 390 %enddef /* + */ +%define SWIGWARN_IGNORE_OPERATOR_UMINUS 391 %enddef /* - */ +%define SWIGWARN_IGNORE_OPERATOR_UMUL 392 %enddef /* * */ +%define SWIGWARN_IGNORE_OPERATOR_UAND 393 %enddef /* & */ +%define SWIGWARN_IGNORE_OPERATOR_NEWARR 394 %enddef /* new [] */ +%define SWIGWARN_IGNORE_OPERATOR_DELARR 395 %enddef /* delete [] */ +%define SWIGWARN_IGNORE_OPERATOR_REF 396 %enddef /* operator *() */ + +/* 394-399 are reserved */ + +/* -- Type system and typemaps -- */ + +%define SWIGWARN_TYPE_UNDEFINED_CLASS 401 %enddef +%define SWIGWARN_TYPE_INCOMPLETE 402 %enddef +%define SWIGWARN_TYPE_ABSTRACT 403 %enddef +%define SWIGWARN_TYPE_REDEFINED 404 %enddef + +%define SWIGWARN_TYPEMAP_SOURCETARGET 450 %enddef +%define SWIGWARN_TYPEMAP_CHARLEAK 451 %enddef +%define SWIGWARN_TYPEMAP_SWIGTYPE 452 %enddef +%define SWIGWARN_TYPEMAP_APPLY_UNDEF 453 %enddef +%define SWIGWARN_TYPEMAP_SWIGTYPELEAK 454 %enddef + +%define SWIGWARN_TYPEMAP_IN_UNDEF 460 %enddef +%define SWIGWARN_TYPEMAP_OUT_UNDEF 461 %enddef +%define SWIGWARN_TYPEMAP_VARIN_UNDEF 462 %enddef +%define SWIGWARN_TYPEMAP_VAROUT_UNDEF 463 %enddef +%define SWIGWARN_TYPEMAP_CONST_UNDEF 464 %enddef +%define SWIGWARN_TYPEMAP_UNDEF 465 %enddef +%define SWIGWARN_TYPEMAP_VAR_UNDEF 466 %enddef +%define SWIGWARN_TYPEMAP_TYPECHECK 467 %enddef +%define SWIGWARN_TYPEMAP_THROW 468 %enddef +%define SWIGWARN_TYPEMAP_DIRECTORIN_UNDEF 469 %enddef +%define SWIGWARN_TYPEMAP_THREAD_UNSAFE 470 %enddef /* mostly used in directorout typemaps */ +%define SWIGWARN_TYPEMAP_DIRECTOROUT_UNDEF 471 %enddef +%define SWIGWARN_TYPEMAP_TYPECHECK_UNDEF 472 %enddef +%define SWIGWARN_TYPEMAP_DIRECTOROUT_PTR 473 %enddef + +/* -- Fragments -- */ +%define SWIGWARN_FRAGMENT_NOT_FOUND 490 %enddef + +/* -- General code generation -- */ + +%define SWIGWARN_LANG_OVERLOAD_DECL 501 %enddef +%define SWIGWARN_LANG_OVERLOAD_CONSTRUCT 502 %enddef +%define SWIGWARN_LANG_IDENTIFIER 503 %enddef +%define SWIGWARN_LANG_RETURN_TYPE 504 %enddef +%define SWIGWARN_LANG_VARARGS 505 %enddef +%define SWIGWARN_LANG_VARARGS_KEYWORD 506 %enddef +%define SWIGWARN_LANG_NATIVE_UNIMPL 507 %enddef +%define SWIGWARN_LANG_DEREF_SHADOW 508 %enddef +%define SWIGWARN_LANG_OVERLOAD_SHADOW 509 %enddef +%define SWIGWARN_LANG_FRIEND_IGNORE 510 %enddef +%define SWIGWARN_LANG_OVERLOAD_KEYWORD 511 %enddef +%define SWIGWARN_LANG_OVERLOAD_CONST 512 %enddef +%define SWIGWARN_LANG_CLASS_UNNAMED 513 %enddef +%define SWIGWARN_LANG_DIRECTOR_VDESTRUCT 514 %enddef +%define SWIGWARN_LANG_DISCARD_CONST 515 %enddef +%define SWIGWARN_LANG_OVERLOAD_IGNORED 516 %enddef +%define SWIGWARN_LANG_DIRECTOR_ABSTRACT 517 %enddef +%define SWIGWARN_LANG_PORTABILITY_FILENAME 518 %enddef +%define SWIGWARN_LANG_TEMPLATE_METHOD_IGNORE 519 %enddef + +/* -- Reserved (600-799) -- */ + +/* -- Language module specific warnings (800 - 999) -- */ + +%define SWIGWARN_RUBY_WRONG_NAME 801 %enddef +%define SWIGWARN_RUBY_MULTIPLE_INHERITANCE 802 %enddef + +%define SWIGWARN_JAVA_TYPEMAP_JNI_UNDEF 810 %enddef +%define SWIGWARN_JAVA_TYPEMAP_JTYPE_UNDEF 811 %enddef +%define SWIGWARN_JAVA_TYPEMAP_JSTYPE_UNDEF 812 %enddef +%define SWIGWARN_JAVA_MULTIPLE_INHERITANCE 813 %enddef +%define SWIGWARN_JAVA_TYPEMAP_GETCPTR_UNDEF 814 %enddef +%define SWIGWARN_JAVA_TYPEMAP_CLASSMOD_UNDEF 815 %enddef +%define SWIGWARN_JAVA_TYPEMAP_JAVABODY_UNDEF 816 %enddef +%define SWIGWARN_JAVA_TYPEMAP_JAVAOUT_UNDEF 817 %enddef +%define SWIGWARN_JAVA_TYPEMAP_JAVAIN_UNDEF 818 %enddef +%define SWIGWARN_JAVA_TYPEMAP_JAVADIRECTORIN_UNDEF 819 %enddef +%define SWIGWARN_JAVA_TYPEMAP_JAVADIRECTOROUT_UNDEF 820 %enddef +%define SWIGWARN_JAVA_COVARIANT_RET 822 %enddef +%define SWIGWARN_JAVA_TYPEMAP_JAVACONSTRUCT_UNDEF 823 %enddef +%define SWIGWARN_JAVA_TYPEMAP_DIRECTORIN_NODESC 824 %enddef +%define SWIGWARN_JAVA_NO_DIRECTORCONNECT_ATTR 825 %enddef + +/* please leave 810-829 free for Java */ + +%define SWIGWARN_CSHARP_TYPEMAP_CTYPE_UNDEF 830 %enddef +%define SWIGWARN_CSHARP_TYPEMAP_CSTYPE_UNDEF 831 %enddef +%define SWIGWARN_CSHARP_TYPEMAP_CSWTYPE_UNDEF 832 %enddef +%define SWIGWARN_CSHARP_MULTIPLE_INHERITANCE 833 %enddef +%define SWIGWARN_CSHARP_TYPEMAP_GETCPTR_UNDEF 834 %enddef +%define SWIGWARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF 835 %enddef +%define SWIGWARN_CSHARP_TYPEMAP_CSBODY_UNDEF 836 %enddef +%define SWIGWARN_CSHARP_TYPEMAP_CSOUT_UNDEF 837 %enddef +%define SWIGWARN_CSHARP_TYPEMAP_CSIN_UNDEF 838 %enddef +%define SWIGWARN_CSHARP_TYPEMAP_CSDIRECTORIN_UNDEF 839 %enddef +%define SWIGWARN_CSHARP_TYPEMAP_CSDIRECTOROUT_UNDEF 840 %enddef +%define SWIGWARN_CSHARP_COVARIANT_RET 842 %enddef +%define SWIGWARN_CSHARP_TYPEMAP_CSCONSTRUCT_UNDEF 843 %enddef +%define SWIGWARN_CSHARP_EXCODE 844 %enddef +%define SWIGWARN_CSHARP_CANTHROW 845 %enddef +%define SWIGWARN_CSHARP_NO_DIRECTORCONNECT_ATTR 846 %enddef + + +%define SWIGWARN_MODULA3_TYPEMAP_TYPE_UNDEF 850 %enddef +%define SWIGWARN_MODULA3_TYPEMAP_GETCPTR_UNDEF 851 %enddef +%define SWIGWARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF 852 %enddef +%define SWIGWARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF 853 %enddef +%define SWIGWARN_MODULA3_TYPEMAP_MULTIPLE_RETURN 854 %enddef +%define SWIGWARN_MODULA3_MULTIPLE_INHERITANCE 855 %enddef +%define SWIGWARN_MODULA3_TYPECONSTRUCTOR_UNKNOWN 856 %enddef +%define SWIGWARN_MODULA3_UNKNOWN_PRAGMA 857 %enddef +%define SWIGWARN_MODULA3_BAD_ENUMERATION 858 %enddef +%define SWIGWARN_MODULA3_DOUBLE_ID 859 %enddef +%define SWIGWARN_MODULA3_BAD_IMPORT 860 %enddef + +/* please leave 850-869 free for Modula 3 */ + +%define SWIGWARN_PHP4_MULTIPLE_INHERITANCE 870 %enddef +%define SWIGWARN_PHP4_UNKNOWN_PRAGMA 871 %enddef + +/* please leave 870-889 free for Php */ + + +/* Feel free to claim any number in this space that's not currently being used. Just make sure you + add an entry here */ + diff --git a/devtools/swigwin-1.3.34/Lib/swigwarnings.swg b/devtools/swigwin-1.3.34/Lib/swigwarnings.swg new file mode 100644 index 0000000..d5af08b --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/swigwarnings.swg @@ -0,0 +1,128 @@ +/* + Include the internal swig macro codes. These macros correspond to + the one found in Source/Include/swigwarn.h plus the 'SWIG'prefix. + + For example, in the include file 'swigwarn.h' you will find + + #define WARN_TYPEMAP_CHARLEAK ... + + and in the 'swigwarn.swg' interface, you will see + + %define SWIGWARN_TYPEMAP_CHARLEAK ... + + This code can be used in warning filters as follows: + + %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK); + + Warnings messages used in typemaps. Message names will be the same + as those in Lib/swigwarn.swg but with the suffix _MSG. + + For example, for the code SWIGWARN_TYPEMAP_CHARLEAK, once you use + + %typemapmsg(CHARLEAK,<msg>); + + you use the message in your typemap as + + %typemap(varin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) char * + + while you suppress the warning using + + %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK); + + as described above. +*/ + +/* ----------------------------------------------------------------------------- + * SWIG warning codes + * ----------------------------------------------------------------------------- */ + +%include <swigwarn.swg> + +/* ----------------------------------------------------------------------------- + * Auxiliar macros + * ----------------------------------------------------------------------------- */ + +/* Macro to define warning messages */ +#define %_warningmsg(Val, Msg...) `Val`":"Msg +#define %warningmsg(Val, Msg...) %_warningmsg(Val, Msg) + +/* ----------------------------------------------------------------------------- + * Typemap related warning messages + * ----------------------------------------------------------------------------- */ + +%define SWIGWARN_TYPEMAP_CHARLEAK_MSG "451:Setting a const char * variable may leak memory." %enddef +%define SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG "454:Setting a pointer/reference variable may leak memory." %enddef +%define SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG "470:Thread/reentrant unsafe wrapping, consider returning by value instead." %enddef +%define SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG "473:Returning a pointer or reference in a director method is not recommended." %enddef + +/* ----------------------------------------------------------------------------- + * Operator related warning messages + * ----------------------------------------------------------------------------- */ + +%define SWIGWARN_IGNORE_OPERATOR_NEW_MSG "350:operator new ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_DELETE_MSG "351:operator delete ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_PLUS_MSG "352:operator+ ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_MINUS_MSG "353:operator- ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_MUL_MSG "354:operator* ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_DIV_MSG "355:operator/ ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_MOD_MSG "356:operator% ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_XOR_MSG "357:operator^ ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_AND_MSG "358:operator& ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_OR_MSG "359:operator| ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_NOT_MSG "360:operator~ ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_LNOT_MSG "361:operator! ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_EQ_MSG "362:operator= ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_LT_MSG "363:operator< ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_GT_MSG "364:operator> ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_PLUSEQ_MSG "365:operator+= ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_MINUSEQ_MSG "366:operator-= ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_MULEQ_MSG "367:operator*= ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_DIVEQ_MSG "368:operator/= ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_MODEQ_MSG "369:operator%= ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_XOREQ_MSG "370:operator^= ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_ANDEQ_MSG "371:operator&= ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_OREQ_MSG "372:operator|= ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_LSHIFT_MSG "373:operator<< ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_RSHIFT_MSG "374:operator>> ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_LSHIFTEQ_MSG "375:operator<<= ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_RSHIFTEQ_MSG "376:operator>>= ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_EQUALTO_MSG "377:operator== ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_NOTEQUAL_MSG "378:operator!= ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_LTEQUAL_MSG "379:operator<= ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_GTEQUAL_MSG "380:operator>= ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_LAND_MSG "381:operator&& ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_LOR_MSG "382:operator|| ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_PLUSPLUS_MSG "383:operator++ ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_MINUSMINUS_MSG "384:operator-- ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_COMMA_MSG "385:operator-- ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_ARROWSTAR_MSG "386:operator->* ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_ARROW_MSG "387:operator-> ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_CALL_MSG "388:operator() ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_INDEX_MSG "389:operator[] ignored (consider using %%extend)" %enddef +%define SWIGWARN_IGNORE_OPERATOR_UPLUS_MSG "390:operator+ ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_UMINUS_MSG "391:operator- ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_UMUL_MSG "392:operator* ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_UAND_MSG "393:operator& ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_NEWARR_MSG "394:operator new[] ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_DELARR_MSG "395:operator delete[] ignored" %enddef +%define SWIGWARN_IGNORE_OPERATOR_REF_MSG "396:operator*() ignored" %enddef + +#define %ignoreoperator(Oper) %ignorewarn(SWIGWARN_IGNORE_OPERATOR_##Oper##_MSG) + +/* ----------------------------------------------------------------------------- + * Macros for keyword and built-in names + * ----------------------------------------------------------------------------- */ + +#define %keywordwarn(msg...) %namewarn(%warningmsg(SWIGWARN_PARSE_KEYWORD, msg)) +#define %builtinwarn(msg...) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, msg), %$isfunction) + + +/* ----------------------------------------------------------------------------- + * Warning filter feature + * ----------------------------------------------------------------------------- */ + +#define %_warnfilter(filter...) %feature("warnfilter",`filter`) +#define %warnfilter(filter...) %_warnfilter(filter) + + + diff --git a/devtools/swigwin-1.3.34/Lib/tcl/Makefile.in b/devtools/swigwin-1.3.34/Lib/tcl/Makefile.in new file mode 100644 index 0000000..523349b --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/Makefile.in @@ -0,0 +1,133 @@ +# --------------------------------------------------------------- +# SWIG Tcl/Tk Makefile +# +# This file can be used to build various Tcl extensions with SWIG. +# By default this file is set up for dynamic loading, but it can +# be easily customized for static extensions by modifying various +# portions of the file. +# +# SRCS = C source files +# CXXSRCS = C++ source files +# OBJCSRCS = Objective-C source files +# OBJS = Additional .o files (compiled previously) +# INTERFACE = SWIG interface file +# TARGET = Name of target module or executable +# +# Many portions of this file were created by the SWIG configure +# script and should already reflect your machine. However, you +# may need to modify the Makefile to reflect your specific +# application. +#---------------------------------------------------------------- + +SRCS = +CXXSRCS = +OBJCSRCS = +OBJS = +INTERFACE = +WRAPFILE = $(INTERFACE:.i=_wrap.c) +WRAPOBJ = $(INTERFACE:.i=_wrap.o) +TARGET = module@SO@ # Use this kind of target for dynamic loading +#TARGET = my_tclsh # Use this target for static linking + +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +CC = @CC@ +CXX = @CXX@ +OBJC = @CC@ -Wno-import # -Wno-import needed for gcc +CFLAGS = +INCLUDES = +LIBS = + +# SWIG Options +# SWIG = location of the SWIG executable +# SWIGOPT = SWIG compiler options +# SWIGCC = Compiler used to compile the wrapper file + +SWIG = $(exec_prefix)/bin/swig +SWIGOPT = -tcl # use -tcl8 for Tcl 8.0 +SWIGCC = $(CC) + +# SWIG Library files. Uncomment one of these for rebuilding tclsh or wish +#SWIGLIB = -ltclsh.i +#SWIGLIB = -lwish.i + +# Rules for creating .o files from source. + +COBJS = $(SRCS:.c=.o) +CXXOBJS = $(CXXSRCS:.cxx=.o) +OBJCOBJS = $(OBJCSRCS:.m=.o) +ALLOBJS = $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(OBJS) + +# Command that will be used to build the final extension. +BUILD = $(SWIGCC) + +# Uncomment the following if you are using dynamic loading +CCSHARED = @CCSHARED@ +BUILD = @LDSHARED@ + +# Uncomment the following if you are using dynamic loading with C++ and +# need to provide additional link libraries (this is not always required). + +#DLL_LIBS = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \ + -L/usr/local/lib -lg++ -lstdc++ -lgcc + +# X11 installation (needed to rebuild Tk extensions) + +XLIB = @XLIBSW@ +XINCLUDE = @XINCLUDES@ + +# Tcl installation (where is Tcl/Tk located) + +TCL_INCLUDE = @TCLINCLUDE@ +TCL_LIB = @TCLLIB@ + +# Build libraries (needed for static builds) + +LIBM = @LIBM@ +LIBC = @LIBC@ +SYSLIBS = $(LIBM) $(LIBC) @LIBS@ + +# Build options (uncomment only one these) + +BUILD_LIBS = $(LIBS) # Dynamic loading +#BUILD_LIBS = $(TCL_LIB) -ltcl $(LIBS) $(SYSLIBS) # tclsh +#BUILD_LIBS = $(TCL_LIB) -ltk -ltcl $(XLIB) $(LIBS) $(SYSLIBS) # wish + +# Compilation rules for non-SWIG components + +.SUFFIXES: .c .cxx .m + +.c.o: + $(CC) $(CCSHARED) $(CFLAGS) $(INCLUDES) -c $< + +.cxx.o: + $(CXX) $(CCSHARED) $(CXXFLAGS) $(INCLUDES) -c $< + +.m.o: + $(OBJC) $(CCSHARED) $(CFLAGS) $(INCLUDES) -c $< + + +# ---------------------------------------------------------------------- +# Rules for building the extension +# ---------------------------------------------------------------------- + +all: $(TARGET) + +# Convert the wrapper file into an object file + +$(WRAPOBJ) : $(WRAPFILE) + $(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(WRAPFILE) $(INCLUDES) $(TCL_INCLUDE) + +$(WRAPFILE) : $(INTERFACE) + $(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIB) $(INTERFACE) + +$(TARGET): $(WRAPOBJ) $(ALLOBJS) + $(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET) + +clean: + rm -f $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(WRAPOBJ) $(WRAPFILE) $(TARGET) + + + + diff --git a/devtools/swigwin-1.3.34/Lib/tcl/attribute.i b/devtools/swigwin-1.3.34/Lib/tcl/attribute.i new file mode 100644 index 0000000..779716c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/attribute.i @@ -0,0 +1 @@ +%include <typemaps/attribute.swg> diff --git a/devtools/swigwin-1.3.34/Lib/tcl/carrays.i b/devtools/swigwin-1.3.34/Lib/tcl/carrays.i new file mode 100644 index 0000000..0236672 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/carrays.i @@ -0,0 +1,4 @@ +%include <typemaps/carrays.swg> + + + diff --git a/devtools/swigwin-1.3.34/Lib/tcl/cdata.i b/devtools/swigwin-1.3.34/Lib/tcl/cdata.i new file mode 100644 index 0000000..3679659 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/cdata.i @@ -0,0 +1 @@ +%include <typemaps/cdata.swg> diff --git a/devtools/swigwin-1.3.34/Lib/tcl/cmalloc.i b/devtools/swigwin-1.3.34/Lib/tcl/cmalloc.i new file mode 100644 index 0000000..248f06b --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/cmalloc.i @@ -0,0 +1 @@ +%include <typemaps/cmalloc.swg> diff --git a/devtools/swigwin-1.3.34/Lib/tcl/cni.i b/devtools/swigwin-1.3.34/Lib/tcl/cni.i new file mode 100644 index 0000000..10a1403 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/cni.i @@ -0,0 +1,2 @@ +%include <gcj/cni.i> +%include <jstring.i> diff --git a/devtools/swigwin-1.3.34/Lib/tcl/cpointer.i b/devtools/swigwin-1.3.34/Lib/tcl/cpointer.i new file mode 100644 index 0000000..d824792 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/cpointer.i @@ -0,0 +1 @@ +%include <typemaps/cpointer.swg> diff --git a/devtools/swigwin-1.3.34/Lib/tcl/cstring.i b/devtools/swigwin-1.3.34/Lib/tcl/cstring.i new file mode 100644 index 0000000..ede9c59 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/cstring.i @@ -0,0 +1 @@ +%include <typemaps/cstring.swg> diff --git a/devtools/swigwin-1.3.34/Lib/tcl/cwstring.i b/devtools/swigwin-1.3.34/Lib/tcl/cwstring.i new file mode 100644 index 0000000..b17ca76 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/cwstring.i @@ -0,0 +1,2 @@ +%include <tclwstrings.swg> +%include <typemaps/cwstring.swg> diff --git a/devtools/swigwin-1.3.34/Lib/tcl/exception.i b/devtools/swigwin-1.3.34/Lib/tcl/exception.i new file mode 100644 index 0000000..4d22797 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/exception.i @@ -0,0 +1,6 @@ +%include <typemaps/exception.swg> + + +%insert("runtime") { + %define_as(SWIG_exception(code, msg), %block(%error(code, msg); return TCL_ERROR;)) +} diff --git a/devtools/swigwin-1.3.34/Lib/tcl/factory.i b/devtools/swigwin-1.3.34/Lib/tcl/factory.i new file mode 100644 index 0000000..46a0a87 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/factory.i @@ -0,0 +1 @@ +%include <typemaps/factory.swg> diff --git a/devtools/swigwin-1.3.34/Lib/tcl/jstring.i b/devtools/swigwin-1.3.34/Lib/tcl/jstring.i new file mode 100644 index 0000000..7fb7b89 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/jstring.i @@ -0,0 +1,42 @@ +%include <typemaps/valtypes.swg> + +%fragment(SWIG_AsVal_frag(jstring),"header") { +SWIGINTERN int +SWIG_AsVal_dec(jstring)(Tcl_Obj * obj, jstring *val) +{ + int len = 0; + const char *cstr = Tcl_GetStringFromObj(obj, &len); + if (!cstr || (strcmp(cstr,"NULL") == 0)) { + if (val) *val = 0; + return SWIG_OK; + } else { + int len = 0; + const Tcl_UniChar *ucstr = Tcl_GetUnicodeFromObj(obj,&len); + if (val) { + *val = JvNewString((const jchar*)ucstr, len); + } + } + + return SWIG_NEWOBJ; +} +} + +%fragment(SWIG_From_frag(jstring),"header") { +SWIGINTERNINLINE Tcl_Obj * +SWIG_From_dec(jstring)(jstring val) +{ + if (!val) { + return Tcl_NewStringObj("NULL",-1); + } else { + return Tcl_NewUnicodeObj((Tcl_UniChar *)JvGetStringChars(val),JvGetStringUTFLength(val)); + } +} +} + +%typemaps_asvalfrom(%checkcode(STRING), + %arg(SWIG_AsVal(jstring)), + %arg(SWIG_From(jstring)), + %arg(SWIG_AsVal_frag(jstring)), + %arg(SWIG_From_frag(jstring)), + java::lang::String *); + diff --git a/devtools/swigwin-1.3.34/Lib/tcl/mactclinit.c b/devtools/swigwin-1.3.34/Lib/tcl/mactclinit.c new file mode 100644 index 0000000..5dcf8e7 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/mactclinit.c @@ -0,0 +1,93 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * mactclinit.c + * ----------------------------------------------------------------------------- */ + +/* + * tclMacAppInit.c -- + * + * Provides a version of the Tcl_AppInit procedure for the example shell. + * + * Copyright (c) 1993-1994 Lockheed Missle & Space Company, AI Center + * Copyright (c) 1995-1997 Sun Microsystems, Inc. + * + * See the file "license.terms" for information on usage and redistribution + * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * + * SCCS: @(#) tclMacAppInit.c 1.17 97/01/21 18:13:34 + */ + +#include "tcl.h" +#include "tclInt.h" +#include "tclMacInt.h" + +#if defined(THINK_C) +# include <console.h> +#elif defined(__MWERKS__) +# include <SIOUX.h> +short InstallConsole _ANSI_ARGS_((short fd)); +#endif + + + +/* + *---------------------------------------------------------------------- + * + * MacintoshInit -- + * + * This procedure calls initalization routines to set up a simple + * console on a Macintosh. This is necessary as the Mac doesn't + * have a stdout & stderr by default. + * + * Results: + * Returns TCL_OK if everything went fine. If it didn't the + * application should probably fail. + * + * Side effects: + * Inits the appropiate console package. + * + *---------------------------------------------------------------------- + */ + +#ifdef __cplusplus +extern "C" +#endif +extern int +MacintoshInit() +{ +#if defined(THINK_C) + + /* Set options for Think C console package */ + /* The console package calls the Mac init calls */ + console_options.pause_atexit = 0; + console_options.title = "\pTcl Interpreter"; + +#elif defined(__MWERKS__) + + /* Set options for CodeWarrior SIOUX package */ + SIOUXSettings.autocloseonquit = true; + SIOUXSettings.showstatusline = true; + SIOUXSettings.asktosaveonclose = false; + InstallConsole(0); + SIOUXSetTitle("\pTcl Interpreter"); + +#elif defined(applec) + + /* Init packages used by MPW SIOW package */ + InitGraf((Ptr)&qd.thePort); + InitFonts(); + InitWindows(); + InitMenus(); + TEInit(); + InitDialogs(nil); + InitCursor(); + +#endif + + TclMacSetEventProc((TclMacConvertEventPtr) SIOUXHandleOneEvent); + + /* No problems with initialization */ + return TCL_OK; +} diff --git a/devtools/swigwin-1.3.34/Lib/tcl/mactkinit.c b/devtools/swigwin-1.3.34/Lib/tcl/mactkinit.c new file mode 100644 index 0000000..bfe7402 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/mactkinit.c @@ -0,0 +1,236 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * mactkinit.c + * + * This is a support file needed to build a new version of Wish. + * Normally, this capability is found in TkAppInit.c, but this creates + * tons of namespace problems for many applications. + * ----------------------------------------------------------------------------- */ + +#include <Gestalt.h> +#include <ToolUtils.h> +#include <Fonts.h> +#include <Dialogs.h> +#include <SegLoad.h> +#include <Traps.h> + +#include "tk.h" +#include "tkInt.h" +#include "tkMacInt.h" + +typedef int (*TclMacConvertEventPtr) _ANSI_ARGS_((EventRecord *eventPtr)); +Tcl_Interp *gStdoutInterp = NULL; + +void TclMacSetEventProc _ANSI_ARGS_((TclMacConvertEventPtr procPtr)); +int TkMacConvertEvent _ANSI_ARGS_((EventRecord *eventPtr)); + +/* + * Prototypes for functions the ANSI library needs to link against. + */ +short InstallConsole _ANSI_ARGS_((short fd)); +void RemoveConsole _ANSI_ARGS_((void)); +long WriteCharsToConsole _ANSI_ARGS_((char *buff, long n)); +long ReadCharsFromConsole _ANSI_ARGS_((char *buff, long n)); +char * __ttyname _ANSI_ARGS_((long fildes)); +short SIOUXHandleOneEvent _ANSI_ARGS_((EventRecord *event)); + +/* + * Forward declarations for procedures defined later in this file: + */ + +/* + *---------------------------------------------------------------------- + * + * MacintoshInit -- + * + * This procedure calls Mac specific initilization calls. Most of + * these calls must be made as soon as possible in the startup + * process. + * + * Results: + * Returns TCL_OK if everything went fine. If it didn't the + * application should probably fail. + * + * Side effects: + * Inits the application. + * + *---------------------------------------------------------------------- + */ + +int +MacintoshInit() +{ + int i; + long result, mask = 0x0700; /* mask = system 7.x */ + + /* + * Tk needs us to set the qd pointer it uses. This is needed + * so Tk doesn't have to assume the availablity of the qd global + * variable. Which in turn allows Tk to be used in code resources. + */ + tcl_macQdPtr = &qd; + + InitGraf(&tcl_macQdPtr->thePort); + InitFonts(); + InitWindows(); + InitMenus(); + InitDialogs((long) NULL); + InitCursor(); + + /* + * Make sure we are running on system 7 or higher + */ + + if ((NGetTrapAddress(_Gestalt, ToolTrap) == + NGetTrapAddress(_Unimplemented, ToolTrap)) + || (((Gestalt(gestaltSystemVersion, &result) != noErr) + || (mask != (result & mask))))) { + panic("Tcl/Tk requires System 7 or higher."); + } + + /* + * Make sure we have color quick draw + * (this means we can't run on 68000 macs) + */ + + if (((Gestalt(gestaltQuickdrawVersion, &result) != noErr) + || (result < gestalt32BitQD13))) { + panic("Tk requires Color QuickDraw."); + } + + + FlushEvents(everyEvent, 0); + SetEventMask(everyEvent); + + /* + * Set up stack & heap sizes + */ + /* TODO: stack size + size = StackSpace(); + SetAppLimit(GetAppLimit() - 8192); + */ + MaxApplZone(); + for (i = 0; i < 4; i++) { + (void) MoreMasters(); + } + + TclMacSetEventProc(TkMacConvertEvent); + TkConsoleCreate(); + + return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * + * SetupMainInterp -- + * + * This procedure calls initalization routines require a Tcl + * interp as an argument. This call effectively makes the passed + * iterpreter the "main" interpreter for the application. + * + * Results: + * Returns TCL_OK if everything went fine. If it didn't the + * application should probably fail. + * + * Side effects: + * More initilization. + * + *---------------------------------------------------------------------- + */ + +int +SetupMainInterp( + Tcl_Interp *interp) +{ + /* + * Initialize the console only if we are running as an interactive + * application. + */ + + TkMacInitAppleEvents(interp); + TkMacInitMenus(interp); + + if (strcmp(Tcl_GetVar(interp, "tcl_interactive", TCL_GLOBAL_ONLY), "1") + == 0) { + if (TkConsoleInit(interp) == TCL_ERROR) { + goto error; + } + } + + /* + * Attach the global interpreter to tk's expected global console + */ + + gStdoutInterp = interp; + + return TCL_OK; + +error: + panic(interp->result); + return TCL_ERROR; +} + +/* + *---------------------------------------------------------------------- + * + * InstallConsole, RemoveConsole, etc. -- + * + * The following functions provide the UI for the console package. + * Users wishing to replace SIOUX with their own console package + * need only provide the four functions below in a library. + * + * Results: + * See SIOUX documentation for details. + * + * Side effects: + * See SIOUX documentation for details. + * + *---------------------------------------------------------------------- + */ + +short +InstallConsole(short fd) +{ +#pragma unused (fd) + + return 0; +} + +void +RemoveConsole(void) +{ +} + +long +WriteCharsToConsole(char *buffer, long n) +{ + TkConsolePrint(gStdoutInterp, TCL_STDOUT, buffer, n); + return n; +} + +long +ReadCharsFromConsole(char *buffer, long n) +{ + return 0; +} + +extern char * +__ttyname(long fildes) +{ + static char *devicename = "null device"; + + if (fildes >= 0 && fildes <= 2) { + return (devicename); + } + + return (0L); +} + +short +SIOUXHandleOneEvent(EventRecord *event) +{ + return 0; +} diff --git a/devtools/swigwin-1.3.34/Lib/tcl/std_common.i b/devtools/swigwin-1.3.34/Lib/tcl/std_common.i new file mode 100644 index 0000000..3a6f470 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/std_common.i @@ -0,0 +1,20 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_common.i + * + * SWIG typemaps for STL - common utilities + * ----------------------------------------------------------------------------- */ + +%include <std/std_except.i> + +%types(std::size_t); +%apply size_t { std::size_t }; +%apply const unsigned long& { const std::size_t& }; + +%types(std::ptrdiff_t); +%apply long { std::ptrdiff_t }; +%apply const long& { const std::ptrdiff_t& }; + + diff --git a/devtools/swigwin-1.3.34/Lib/tcl/std_deque.i b/devtools/swigwin-1.3.34/Lib/tcl/std_deque.i new file mode 100644 index 0000000..cb98f6c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/std_deque.i @@ -0,0 +1 @@ +%include <std/_std_deque.i> diff --git a/devtools/swigwin-1.3.34/Lib/tcl/std_except.i b/devtools/swigwin-1.3.34/Lib/tcl/std_except.i new file mode 100644 index 0000000..af98428 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/std_except.i @@ -0,0 +1 @@ +%include <typemaps/std_except.swg> diff --git a/devtools/swigwin-1.3.34/Lib/tcl/std_map.i b/devtools/swigwin-1.3.34/Lib/tcl/std_map.i new file mode 100644 index 0000000..006a62e --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/std_map.i @@ -0,0 +1,173 @@ +// +// SWIG typemaps for std::map +// Luigi Ballabio +// Jan. 2003 +// +// Common implementation + +%include <std_common.i> + +// ------------------------------------------------------------------------ +// std::map +// ------------------------------------------------------------------------ + +%{ +#include <map> +#include <algorithm> +#include <stdexcept> +%} + +// exported class + +namespace std { + + template<class K, class T> class map { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T& get(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(const K& key, const T& x) { + (*self)[key] = x; + } + void del(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + + + // specializations for built-ins + + %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) + + template<class T> class map<K,T> { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T& get(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(K key, const T& x) { + (*self)[key] = x; + } + void del(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(K key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + %enddef + + %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) + template<class K> class map<K,T> { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T get(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(const K& key, T x) { + (*self)[key] = x; + } + void del(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + %enddef + + %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, + T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) + template<> class map<K,T> { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T get(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(K key, T x) { + (*self)[key] = x; + } + void del(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(K key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + %enddef + + // add specializations here + +} diff --git a/devtools/swigwin-1.3.34/Lib/tcl/std_pair.i b/devtools/swigwin-1.3.34/Lib/tcl/std_pair.i new file mode 100644 index 0000000..52e9667 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/std_pair.i @@ -0,0 +1,37 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_pair.i + * + * Typemaps for std::pair + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <exception.i> + +// ------------------------------------------------------------------------ +// std::pair +// ------------------------------------------------------------------------ + +%{ +#include <utility> +%} + +namespace std { + + template<class T, class U> struct pair { + + pair(); + pair(T first, U second); + pair(const pair& p); + + template <class U1, class U2> pair(const pair<U1, U2> &p); + + T first; + U second; + }; + + // add specializations here + +} diff --git a/devtools/swigwin-1.3.34/Lib/tcl/std_string.i b/devtools/swigwin-1.3.34/Lib/tcl/std_string.i new file mode 100644 index 0000000..5b31b28 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/std_string.i @@ -0,0 +1,2 @@ +%include <typemaps/std_string.swg> + diff --git a/devtools/swigwin-1.3.34/Lib/tcl/std_vector.i b/devtools/swigwin-1.3.34/Lib/tcl/std_vector.i new file mode 100644 index 0000000..d913f00 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/std_vector.i @@ -0,0 +1,422 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_vector.i + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +// ------------------------------------------------------------------------ +// std::vector +// +// The aim of all that follows would be to integrate std::vector with +// Tcl as much as possible, namely, to allow the user to pass and +// be returned Tcl lists. +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::vector<T>), f(const std::vector<T>&), f(const std::vector<T>*): +// the parameter being read-only, either a Tcl list or a +// previously wrapped std::vector<T> can be passed. +// -- f(std::vector<T>&), f(std::vector<T>*): +// the parameter must be modified; therefore, only a wrapped std::vector +// can be passed. +// -- std::vector<T> f(): +// the vector is returned by copy; therefore, a Tcl list of T:s +// is returned which is most easily used in other Tcl functions procs +// -- std::vector<T>& f(), std::vector<T>* f(), const std::vector<T>& f(), +// const std::vector<T>* f(): +// the vector is returned by reference; therefore, a wrapped std::vector +// is returned +// ------------------------------------------------------------------------ + +%{ +#include <vector> +#include <algorithm> +#include <stdexcept> +#include <string> + +Tcl_Obj* SwigString_FromString(const std::string &s) { + return Tcl_NewStringObj(s.data(), (int)s.length()); +} + +int Tcl_GetBoolFromObj(Tcl_Interp *interp, Tcl_Obj *o, bool *val) { + int v; + int res = Tcl_GetBooleanFromObj(interp, o, &v); + if (res == TCL_OK) { + *val = v ? true : false; + } + return res; +} + +int SwigString_AsString(Tcl_Interp *interp, Tcl_Obj *o, std::string *val) { + int len; + const char* temp = Tcl_GetStringFromObj(o, &len); + if (temp == NULL) + return TCL_ERROR; + val->assign(temp, len); + return TCL_OK; +} + +// behaviour of this is such as the real Tcl_GetIntFromObj +template <typename Type> +int SwigInt_As(Tcl_Interp *interp, Tcl_Obj *o, Type *val) { + int temp_val, return_val; + return_val = Tcl_GetIntFromObj(interp, o, &temp_val); + *val = (Type) temp_val; + return return_val; +} + +// behaviour of this is such as the real Tcl_GetDoubleFromObj +template <typename Type> +int SwigDouble_As(Tcl_Interp *interp, Tcl_Obj *o, Type *val) { + int return_val; + double temp_val; + return_val = Tcl_GetDoubleFromObj(interp, o, &temp_val); + *val = (Type) temp_val; + return return_val; +} + +%} + +// exported class + +namespace std { + + template<class T> class vector { + %typemap(in) vector<T> (std::vector<T> *v) { + Tcl_Obj **listobjv; + int nitems; + int i; + T* temp; + + if (SWIG_ConvertPtr($input, (void **) &v, \ + $&1_descriptor, 0) == 0){ + $1 = *v; + } else { + // It isn't a vector<T> so it should be a list of T's + if(Tcl_ListObjGetElements(interp, $input, \ + &nitems, &listobjv) == TCL_ERROR) + return TCL_ERROR; + $1 = std::vector<T>(); + for (i = 0; i < nitems; i++) { + if ((SWIG_ConvertPtr(listobjv[i],(void **) &temp, + $descriptor(T *),0)) != 0) { + char message[] = + "list of " #T " expected"; + Tcl_SetResult(interp, message, TCL_VOLATILE); + return TCL_ERROR; + } + $1.push_back(*temp); + } + } + } + + %typemap(in) const vector<T>* (std::vector<T> *v, std::vector<T> w), + const vector<T>& (std::vector<T> *v, std::vector<T> w) { + Tcl_Obj **listobjv; + int nitems; + int i; + T* temp; + + if(SWIG_ConvertPtr($input, (void **) &v, \ + $&1_descriptor, 0) == 0) { + $1 = v; + } else { + // It isn't a vector<T> so it should be a list of T's + if(Tcl_ListObjGetElements(interp, $input, + &nitems, &listobjv) == TCL_ERROR) + return TCL_ERROR; + w = std::vector<T>(); + for (i = 0; i < nitems; i++) { + if ((SWIG_ConvertPtr(listobjv[i],(void **) &temp, + $descriptor(T *),0)) != 0) { + char message[] = + "list of " #T " expected"; + Tcl_SetResult(interp, message, TCL_VOLATILE); + return TCL_ERROR; + } + w.push_back(*temp); + } + $1 = &w; + } + } + + %typemap(out) vector<T> { + for (unsigned int i=0; i<$1.size(); i++) { + T* ptr = new T((($1_type &)$1)[i]); + Tcl_ListObjAppendElement(interp, $result, \ + SWIG_NewInstanceObj(ptr, + $descriptor(T *), + 0)); + } + } + + %typecheck(SWIG_TYPECHECK_VECTOR) vector<T> { + Tcl_Obj **listobjv; + int nitems; + T* temp; + std::vector<T> *v; + + if(SWIG_ConvertPtr($input, (void **) &v, \ + $&1_descriptor, 0) == 0) { + /* wrapped vector */ + $1 = 1; + } else { + // It isn't a vector<T> so it should be a list of T's + if(Tcl_ListObjGetElements(interp, $input, + &nitems, &listobjv) == TCL_ERROR) + $1 = 0; + else + if (nitems == 0) + $1 = 1; + //check the first value to see if it is of correct type + else if ((SWIG_ConvertPtr(listobjv[0], + (void **) &temp, + $descriptor(T *),0)) != 0) + $1 = 0; + else + $1 = 1; + } + } + + %typecheck(SWIG_TYPECHECK_VECTOR) const vector<T>&, + const vector<T>* { + Tcl_Obj **listobjv; + int nitems; + T* temp; + std::vector<T> *v; + + if(SWIG_ConvertPtr($input, (void **) &v, \ + $1_descriptor, 0) == 0){ + /* wrapped vector */ + $1 = 1; + } else { + // It isn't a vector<T> so it should be a list of T's + if(Tcl_ListObjGetElements(interp, $input, + &nitems, &listobjv) == TCL_ERROR) + $1 = 0; + else + if (nitems == 0) + $1 = 1; + //check the first value to see if it is of correct type + else if ((SWIG_ConvertPtr(listobjv[0], + (void **) &temp, + $descriptor(T *),0)) != 0) + $1 = 0; + else + $1 = 1; + } + } + + public: + vector(unsigned int size = 0); + vector(unsigned int size, const T& value); + vector(const vector<T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %rename(push) push_back; + void push_back(const T& x); + %extend { + T pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty vector"); + T x = self->back(); + self->pop_back(); + return x; + } + T& get(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i<0) i += size; + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("vector index out of range"); + } + void set(int i, const T& x) throw (std::out_of_range) { + int size = int(self->size()); + if (i<0) i+= size; + if (i>=0 && i<size) + (*self)[i] = x; + else + throw std::out_of_range("vector index out of range"); + } + } + }; + + + // specializations for built-ins + + %define specialize_std_vector(T, CONVERT_FROM, CONVERT_TO) + template<> class vector<T> { + + %typemap(in) vector<T> (std::vector<T> *v){ + Tcl_Obj **listobjv; + int nitems; + int i; + T temp; + + if(SWIG_ConvertPtr($input, (void **) &v, \ + $&1_descriptor, 0) == 0) { + $1 = *v; + } else { + // It isn't a vector<T> so it should be a list of T's + if(Tcl_ListObjGetElements(interp, $input, + &nitems, &listobjv) == TCL_ERROR) + return TCL_ERROR; + $1 = std::vector<T>(); + for (i = 0; i < nitems; i++) { + if (CONVERT_FROM(interp, listobjv[i], &temp) == TCL_ERROR) + return TCL_ERROR; + $1.push_back(temp); + } + } + } + + %typemap(in) const vector<T>& (std::vector<T> *v,std::vector<T> w), + const vector<T>* (std::vector<T> *v,std::vector<T> w) { + Tcl_Obj **listobjv; + int nitems; + int i; + T temp; + + if(SWIG_ConvertPtr($input, (void **) &v, \ + $1_descriptor, 0) == 0) { + $1 = v; + } else { + // It isn't a vector<T> so it should be a list of T's + if(Tcl_ListObjGetElements(interp, $input, + &nitems, &listobjv) == TCL_ERROR) + return TCL_ERROR; + w = std::vector<T>(); + for (i = 0; i < nitems; i++) { + if (CONVERT_FROM(interp, listobjv[i], &temp) == TCL_ERROR) + return TCL_ERROR; + w.push_back(temp); + } + $1 = &w; + } + } + + %typemap(out) vector<T> { + for (unsigned int i=0; i<$1.size(); i++) { + Tcl_ListObjAppendElement(interp, $result, \ + CONVERT_TO((($1_type &)$1)[i])); + } + } + + %typecheck(SWIG_TYPECHECK_VECTOR) vector<T> { + Tcl_Obj **listobjv; + int nitems; + T temp; + std::vector<T> *v; + + if(SWIG_ConvertPtr($input, (void **) &v, \ + $&1_descriptor, 0) == 0){ + /* wrapped vector */ + $1 = 1; + } else { + // It isn't a vector<T> so it should be a list of T's + if(Tcl_ListObjGetElements(interp, $input, + &nitems, &listobjv) == TCL_ERROR) + $1 = 0; + else + if (nitems == 0) + $1 = 1; + //check the first value to see if it is of correct type + if (CONVERT_FROM(interp, listobjv[0], &temp) == TCL_ERROR) + $1 = 0; + else + $1 = 1; + } + } + + %typecheck(SWIG_TYPECHECK_VECTOR) const vector<T>&, + const vector<T>*{ + Tcl_Obj **listobjv; + int nitems; + T temp; + std::vector<T> *v; + + if(SWIG_ConvertPtr($input, (void **) &v, \ + $1_descriptor, 0) == 0){ + /* wrapped vector */ + $1 = 1; + } else { + // It isn't a vector<T> so it should be a list of T's + if(Tcl_ListObjGetElements(interp, $input, + &nitems, &listobjv) == TCL_ERROR) + $1 = 0; + else + if (nitems == 0) + $1 = 1; + //check the first value to see if it is of correct type + if (CONVERT_FROM(interp, listobjv[0], &temp) == TCL_ERROR) + $1 = 0; + else + $1 = 1; + } + } + + public: + vector(unsigned int size = 0); + vector(unsigned int size, const T& value); + vector(const vector<T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %rename(push) push_back; + void push_back(T x); + %extend { + T pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty vector"); + T x = self->back(); + self->pop_back(); + return x; + } + T get(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i<0) i += size; + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("vector index out of range"); + } + void set(int i, T x) throw (std::out_of_range) { + int size = int(self->size()); + if (i<0) i+= size; + if (i>=0 && i<size) + (*self)[i] = x; + else + throw std::out_of_range("vector index out of range"); + } + } + }; + %enddef + + specialize_std_vector(bool, Tcl_GetBoolFromObj, Tcl_NewBooleanObj); + specialize_std_vector(char, SwigInt_As<char>,Tcl_NewIntObj); + specialize_std_vector(int, Tcl_GetIntFromObj,Tcl_NewIntObj); + specialize_std_vector(short, SwigInt_As<short>, Tcl_NewIntObj); + specialize_std_vector(long, SwigInt_As<long>, Tcl_NewIntObj); + specialize_std_vector(unsigned char, + SwigInt_As<unsigned char>, Tcl_NewIntObj); + specialize_std_vector(unsigned int, + SwigInt_As<unsigned int>, Tcl_NewIntObj); + specialize_std_vector(unsigned short, + SwigInt_As<unsigned short>, Tcl_NewIntObj); + specialize_std_vector(unsigned long, + SwigInt_As<unsigned long>, Tcl_NewIntObj); + specialize_std_vector(double, Tcl_GetDoubleFromObj, Tcl_NewDoubleObj); + specialize_std_vector(float, SwigDouble_As<float>, Tcl_NewDoubleObj); + specialize_std_vector(std::string, + SwigString_AsString, SwigString_FromString); + +} + + diff --git a/devtools/swigwin-1.3.34/Lib/tcl/std_wstring.i b/devtools/swigwin-1.3.34/Lib/tcl/std_wstring.i new file mode 100644 index 0000000..f132614 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/std_wstring.i @@ -0,0 +1,2 @@ +%include <tclwstrings.swg> +%include <typemaps/std_wstring.swg> diff --git a/devtools/swigwin-1.3.34/Lib/tcl/stl.i b/devtools/swigwin-1.3.34/Lib/tcl/stl.i new file mode 100644 index 0000000..afd1213 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/stl.i @@ -0,0 +1,14 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * stl.i + * ----------------------------------------------------------------------------- */ + +/* initial STL definition. extended as needed in each language */ +%include <std_common.i> +%include <std_string.i> +%include <std_vector.i> +%include <std_map.i> +%include <std_pair.i> + diff --git a/devtools/swigwin-1.3.34/Lib/tcl/tcl8.swg b/devtools/swigwin-1.3.34/Lib/tcl/tcl8.swg new file mode 100644 index 0000000..c33cc76 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/tcl8.swg @@ -0,0 +1,45 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * tcl8.swg + * + * Tcl configuration module. + * ----------------------------------------------------------------------------- */ + +/* ------------------------------------------------------------ + * Inner macros + * ------------------------------------------------------------ */ +%include <tclmacros.swg> + +/* ------------------------------------------------------------ + * The runtime part + * ------------------------------------------------------------ */ +%include <tclruntime.swg> + +/* ------------------------------------------------------------ + * Special user directives + * ------------------------------------------------------------ */ +%include <tcluserdir.swg> + +/* ------------------------------------------------------------ + * Typemap specializations + * ------------------------------------------------------------ */ +%include <tcltypemaps.swg> + +/* ------------------------------------------------------------ + * Overloaded operator support + * ------------------------------------------------------------ */ +%include <tclopers.swg> + +/* ------------------------------------------------------------ + * Warnings for Tcl keywords + * ------------------------------------------------------------ */ +%include <tclkw.swg> + +/* ------------------------------------------------------------ + * The Tcl initialization function + * ------------------------------------------------------------ */ +%include <tclinit.swg> + + diff --git a/devtools/swigwin-1.3.34/Lib/tcl/tclapi.swg b/devtools/swigwin-1.3.34/Lib/tcl/tclapi.swg new file mode 100644 index 0000000..6b67327 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/tclapi.swg @@ -0,0 +1,107 @@ +/* ----------------------------------------------------------------------------- + * SWIG API. Portion that goes into the runtime + * ----------------------------------------------------------------------------- */ +#ifdef __cplusplus +extern "C" { +#endif + +/* ----------------------------------------------------------------------------- + * Constant declarations + * ----------------------------------------------------------------------------- */ + +/* Constant Types */ +#define SWIG_TCL_POINTER 4 +#define SWIG_TCL_BINARY 5 + +/* Constant information structure */ +typedef struct swig_const_info { + int type; + char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_const_info; + +typedef int (*swig_wrapper)(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST []); +typedef int (*swig_wrapper_func)(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST []); +typedef char *(*swig_variable_func)(ClientData, Tcl_Interp *, char *, char *, int); +typedef void (*swig_delete_func)(ClientData); + +typedef struct swig_method { + const char *name; + swig_wrapper method; +} swig_method; + +typedef struct swig_attribute { + const char *name; + swig_wrapper getmethod; + swig_wrapper setmethod; +} swig_attribute; + +typedef struct swig_class { + const char *name; + swig_type_info **type; + swig_wrapper constructor; + void (*destructor)(void *); + swig_method *methods; + swig_attribute *attributes; + struct swig_class **bases; + const char **base_names; + swig_module_info *module; +} swig_class; + +typedef struct swig_instance { + Tcl_Obj *thisptr; + void *thisvalue; + swig_class *classptr; + int destroy; + Tcl_Command cmdtok; +} swig_instance; + +/* Structure for command table */ +typedef struct { + const char *name; + int (*wrapper)(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST []); + ClientData clientdata; +} swig_command_info; + +/* Structure for variable linking table */ +typedef struct { + const char *name; + void *addr; + char * (*get)(ClientData, Tcl_Interp *, char *, char *, int); + char * (*set)(ClientData, Tcl_Interp *, char *, char *, int); +} swig_var_info; + + +/* -----------------------------------------------------------------------------* + * Install a constant object + * -----------------------------------------------------------------------------*/ + +static Tcl_HashTable swigconstTable; +static int swigconstTableinit = 0; + +SWIGINTERN void +SWIG_Tcl_SetConstantObj(Tcl_Interp *interp, const char* name, Tcl_Obj *obj) { + int newobj; + Tcl_ObjSetVar2(interp,Tcl_NewStringObj(name,-1), NULL, obj, TCL_GLOBAL_ONLY); + Tcl_SetHashValue(Tcl_CreateHashEntry(&swigconstTable, name, &newobj), (ClientData) obj); +} + +SWIGINTERN Tcl_Obj * +SWIG_Tcl_GetConstantObj(const char *key) { + Tcl_HashEntry *entryPtr; + if (!swigconstTableinit) return 0; + entryPtr = Tcl_FindHashEntry(&swigconstTable, key); + if (entryPtr) { + return (Tcl_Obj *) Tcl_GetHashValue(entryPtr); + } + return 0; +} + +#ifdef __cplusplus +} +#endif + + diff --git a/devtools/swigwin-1.3.34/Lib/tcl/tclerrors.swg b/devtools/swigwin-1.3.34/Lib/tcl/tclerrors.swg new file mode 100644 index 0000000..889d3ad --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/tclerrors.swg @@ -0,0 +1,76 @@ +/* ----------------------------------------------------------------------------- + * error manipulation + * ----------------------------------------------------------------------------- */ + +SWIGINTERN const char* +SWIG_Tcl_ErrorType(int code) { + const char* type = 0; + switch(code) { + case SWIG_MemoryError: + type = "MemoryError"; + break; + case SWIG_IOError: + type = "IOError"; + break; + case SWIG_RuntimeError: + type = "RuntimeError"; + break; + case SWIG_IndexError: + type = "IndexError"; + break; + case SWIG_TypeError: + type = "TypeError"; + break; + case SWIG_DivisionByZero: + type = "ZeroDivisionError"; + break; + case SWIG_OverflowError: + type = "OverflowError"; + break; + case SWIG_SyntaxError: + type = "SyntaxError"; + break; + case SWIG_ValueError: + type = "ValueError"; + break; + case SWIG_SystemError: + type = "SystemError"; + break; + case SWIG_AttributeError: + type = "AttributeError"; + break; + default: + type = "RuntimeError"; + } + return type; +} + + +SWIGINTERN void +SWIG_Tcl_SetErrorObj(Tcl_Interp *interp, const char *ctype, Tcl_Obj *obj) +{ + Tcl_ResetResult(interp); + Tcl_SetObjResult(interp, obj); + Tcl_SetErrorCode(interp, "SWIG", ctype, NULL); +} + +SWIGINTERN void +SWIG_Tcl_SetErrorMsg(Tcl_Interp *interp, const char *ctype, const char *mesg) +{ + Tcl_ResetResult(interp); + Tcl_SetErrorCode(interp, "SWIG", ctype, NULL); + Tcl_AppendResult(interp, ctype, " ", mesg, NULL); + /* + Tcl_AddErrorInfo(interp, ctype); + Tcl_AddErrorInfo(interp, " "); + Tcl_AddErrorInfo(interp, mesg); + */ +} + +SWIGINTERNINLINE void +SWIG_Tcl_AddErrorMsg(Tcl_Interp *interp, const char* mesg) +{ + Tcl_AddErrorInfo(interp, mesg); +} + + diff --git a/devtools/swigwin-1.3.34/Lib/tcl/tclfragments.swg b/devtools/swigwin-1.3.34/Lib/tcl/tclfragments.swg new file mode 100644 index 0000000..ba6398c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/tclfragments.swg @@ -0,0 +1,22 @@ +/* + + Create a file with this name, 'tclfragments.swg', in your working + directory and add all the %fragments you want to take precedence + over the ones defined by default by swig. + + For example, if you add: + + %fragment(SWIG_AsVal_frag(int),"header") { + SWIGINTERNINLINE int + SWIG_AsVal_dec(int)(TclObject *obj, int *val) + { + <your code here>; + } + } + + this will replace the code used to retrieve an integer value for all + the typemaps that need it, including: + + int, std::vector<int>, std::list<std::pair<int,int> >, etc. + +*/ diff --git a/devtools/swigwin-1.3.34/Lib/tcl/tclinit.swg b/devtools/swigwin-1.3.34/Lib/tcl/tclinit.swg new file mode 100644 index 0000000..93d984a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/tclinit.swg @@ -0,0 +1,106 @@ +/* ------------------------------------------------------------ + * The start of the Tcl initialization function + * ------------------------------------------------------------ */ + +%insert(init) "swiginit.swg" + +/* This initialization code exports the module initialization function */ + +%header %{ + +#ifdef __cplusplus +extern "C" { +#endif +#ifdef MAC_TCL +#pragma export on +#endif +SWIGEXPORT int SWIG_init(Tcl_Interp *); +#ifdef MAC_TCL +#pragma export off +#endif +#ifdef __cplusplus +} +#endif + +%} + +%init %{ +#ifdef __cplusplus +extern "C" { +#endif + +/* ----------------------------------------------------------------------------- + * constants/methods manipulation + * ----------------------------------------------------------------------------- */ + +/* Install Constants */ + +SWIGINTERN void +SWIG_Tcl_InstallConstants(Tcl_Interp *interp, swig_const_info constants[]) { + int i; + Tcl_Obj *obj; + + if (!swigconstTableinit) { + Tcl_InitHashTable(&swigconstTable, TCL_STRING_KEYS); + swigconstTableinit = 1; + } + for (i = 0; constants[i].type; i++) { + switch(constants[i].type) { + case SWIG_TCL_POINTER: + obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); + break; + case SWIG_TCL_BINARY: + obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); + break; + default: + obj = 0; + break; + } + if (obj) { + SWIG_Tcl_SetConstantObj(interp, constants[i].name, obj); + } + } +} + +#ifdef __cplusplus +} +#endif + +/* -----------------------------------------------------------------------------* + * Partial Init method + * -----------------------------------------------------------------------------*/ + +SWIGEXPORT int SWIG_init(Tcl_Interp *interp) { + int i; + if (interp == 0) return TCL_ERROR; +#ifdef USE_TCL_STUBS + if (Tcl_InitStubs(interp, (char*)"8.1", 0) == NULL) { + return TCL_ERROR; + } +#endif + Tcl_PkgProvide(interp, (char*)SWIG_name, (char*)SWIG_version); + +#ifdef SWIG_namespace + Tcl_Eval(interp, "namespace eval " SWIG_namespace " { }"); +#endif + + SWIG_InitializeModule((void *) interp); + SWIG_PropagateClientData(); + + for (i = 0; swig_commands[i].name; i++) { + Tcl_CreateObjCommand(interp, (char *) swig_commands[i].name, (swig_wrapper_func) swig_commands[i].wrapper, + swig_commands[i].clientdata, NULL); + } + for (i = 0; swig_variables[i].name; i++) { + Tcl_SetVar(interp, (char *) swig_variables[i].name, (char *) "", TCL_GLOBAL_ONLY); + Tcl_TraceVar(interp, (char *) swig_variables[i].name, TCL_TRACE_READS | TCL_GLOBAL_ONLY, + (Tcl_VarTraceProc *) swig_variables[i].get, (ClientData) swig_variables[i].addr); + Tcl_TraceVar(interp, (char *) swig_variables[i].name, TCL_TRACE_WRITES | TCL_GLOBAL_ONLY, + (Tcl_VarTraceProc *) swig_variables[i].set, (ClientData) swig_variables[i].addr); + } + + SWIG_Tcl_InstallConstants(interp, swig_constants); + +%} + +/* Note: the initialization function is closed after all code is generated */ diff --git a/devtools/swigwin-1.3.34/Lib/tcl/tclinterp.i b/devtools/swigwin-1.3.34/Lib/tcl/tclinterp.i new file mode 100644 index 0000000..48cdb60 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/tclinterp.i @@ -0,0 +1,20 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * tclinterp.i + * + * Tcl_Interp *interp + * + * Passes the current Tcl_Interp value directly to a C function. + * This can be used to work with existing wrapper functions or + * if you just need the interp value for some reason. When used, + * the 'interp' parameter becomes hidden in the Tcl interface--that + * is, you don't specify it explicitly. SWIG fills in its value + * automatically. + * ----------------------------------------------------------------------------- */ + +%typemap(in,numinputs=0) Tcl_Interp *interp { + $1 = interp; +} + diff --git a/devtools/swigwin-1.3.34/Lib/tcl/tclkw.swg b/devtools/swigwin-1.3.34/Lib/tcl/tclkw.swg new file mode 100644 index 0000000..e96e885 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/tclkw.swg @@ -0,0 +1,10 @@ +#ifndef TCL_TCLKW_SWG_ +#define TCL_TCLKW_SWG_ + +// Some special reserved words in classes + +%keywordwarn("cget is a tcl reserved method name") *::cget; +%keywordwarn("configure is a tcl reserved method name") *::configure; + + +#endif //_TCL_TCLKW_SWG_ diff --git a/devtools/swigwin-1.3.34/Lib/tcl/tclmacros.swg b/devtools/swigwin-1.3.34/Lib/tcl/tclmacros.swg new file mode 100644 index 0000000..ab7bace --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/tclmacros.swg @@ -0,0 +1,4 @@ +%include <typemaps/swigmacros.swg> + + + diff --git a/devtools/swigwin-1.3.34/Lib/tcl/tclopers.swg b/devtools/swigwin-1.3.34/Lib/tcl/tclopers.swg new file mode 100644 index 0000000..26b7420 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/tclopers.swg @@ -0,0 +1,46 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * tclopers.swg + * + * C++ overloaded operators. + * + * These declarations define how SWIG is going to rename C++ + * overloaded operators in Tcl. Since Tcl allows identifiers + * to be essentially any valid string, we'll just use the + * normal operator names. + * ----------------------------------------------------------------------------- */ + + +#ifdef __cplusplus +%rename("+") *::operator+; +//%rename("u+") *::operator+(); // Unary + +//%rename("u+") *::operator+() const; // Unary + +%rename("-") *::operator-; +//%rename("u-") *::operator-(); // Unary - +//%rename("u-") *::operator-() const; // Unary - +%rename("*") *::operator*; +%rename("/") *::operator/; +%rename("<<") *::operator<<; +%rename(">>") *::operator>>; +%rename("&") *::operator&; +%rename("|") *::operator|; +%rename("^") *::operator^; +%rename("%") *::operator%; +%rename("=") *::operator=; + +/* Ignored operators */ +%ignoreoperator(NOTEQUAL) operator!=; +%ignoreoperator(PLUSEQ) operator+=; +%ignoreoperator(MINUSEQ) operator-=; +%ignoreoperator(MULEQ) operator*=; +%ignoreoperator(DIVEQ) operator/=; +%ignoreoperator(MODEQ) operator%=; +%ignoreoperator(LSHIFTEQ) operator<<=; +%ignoreoperator(RSHIFTEQ) operator>>=; +%ignoreoperator(ANDEQ) operator&=; +%ignoreoperator(OREQ) operator|=; +%ignoreoperator(XOREQ) operator^=; + +#endif diff --git a/devtools/swigwin-1.3.34/Lib/tcl/tclprimtypes.swg b/devtools/swigwin-1.3.34/Lib/tcl/tclprimtypes.swg new file mode 100644 index 0000000..e781798 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/tclprimtypes.swg @@ -0,0 +1,239 @@ +/* ------------------------------------------------------------ + * Primitive Types + * ------------------------------------------------------------ */ + +/* boolean */ + +%fragment(SWIG_From_frag(bool),"header") { + %define_as(SWIG_From_dec(bool), Tcl_NewBooleanObj) +} + +%fragment(SWIG_AsVal_frag(bool),"header") { +SWIGINTERN int +SWIG_AsVal_dec(bool)(Tcl_Obj *obj, bool *val) +{ + int v; + if (Tcl_GetBooleanFromObj(0, obj, &v) == TCL_OK) { + if (val) *val = v ? true : false; + return SWIG_OK; + } + return SWIG_TypeError; +} +} + +/* long */ + +%fragment(SWIG_From_frag(long),"header", + fragment="<limits.h>") { +SWIGINTERNINLINE Tcl_Obj* +SWIG_From_dec(long)(long value) +{ + if (((long) INT_MIN <= value) && (value <= (long) INT_MAX)) { + return Tcl_NewIntObj(%numeric_cast(value,int)); + } else { + return Tcl_NewLongObj(value); + } +} +} + +%fragment(SWIG_AsVal_frag(long),"header") { +SWIGINTERN int +SWIG_AsVal_dec(long)(Tcl_Obj *obj, long* val) +{ + long v; + if (Tcl_GetLongFromObj(0,obj, &v) == TCL_OK) { + if (val) *val = (long) v; + return SWIG_OK; + } + return SWIG_TypeError; +} +} + +/* unsigned long */ + +%fragment(SWIG_From_frag(unsigned long),"header", + fragment=SWIG_From_frag(long), + fragment="<stdio.h>") { +SWIGINTERNINLINE Tcl_Obj* +SWIG_From_dec(unsigned long)(unsigned long value) +{ + if (value < (unsigned long) LONG_MAX) { + return SWIG_From(long)(%numeric_cast(value, long)); + } else { + char temp[256]; + sprintf(temp, "%lu", value); + return Tcl_NewStringObj(temp,-1); + } +} +} + +%fragment(SWIG_AsVal_frag(unsigned long),"header", + fragment="<limits.h>") { +SWIGINTERN int +SWIG_AsVal_dec(unsigned long)(Tcl_Obj *obj, unsigned long *val) { + long v; + if (Tcl_GetLongFromObj(0,obj, &v) == TCL_OK) { + if (v >= 0) { + if (val) *val = (unsigned long) v; + return SWIG_OK; + } + /* If v is negative, then this could be a negative number, or an + unsigned value which doesn't fit in a signed long, so try to + get it as a string so we can distinguish these cases. */ + } + { + int len = 0; + const char *nptr = Tcl_GetStringFromObj(obj, &len); + if (nptr && len > 0) { + char *endptr; + unsigned long v; + if (*nptr == '-') return SWIG_OverflowError; + errno = 0; + v = strtoul(nptr, &endptr,0); + if (nptr[0] == '\0' || *endptr != '\0') + return SWIG_TypeError; + if (v == ULONG_MAX && errno == ERANGE) { + errno = 0; + return SWIG_OverflowError; + } else { + if (*endptr == '\0') { + if (val) *val = v; + return SWIG_OK; + } + } + } + } + + return SWIG_TypeError; +} +} + +/* long long */ + +%fragment(SWIG_From_frag(long long),"header", + fragment=SWIG_From_frag(long), + fragment="<limits.h>", + fragment="<stdio.h>") { +SWIGINTERNINLINE Tcl_Obj* +SWIG_From_dec(long long)(long long value) +{ + if (((long long) LONG_MIN <= value) && (value <= (long long) LONG_MAX)) { + return SWIG_From(long)(%numeric_cast(value,long)); + } else { + char temp[256]; + sprintf(temp, "%lld", value); + return Tcl_NewStringObj(temp,-1); + } +} +} + +%fragment(SWIG_AsVal_frag(long long),"header", + fragment="<limits.h>", + fragment="<stdlib.h>") { +SWIGINTERN int +SWIG_AsVal_dec(long long)(Tcl_Obj *obj, long long *val) +{ + long v; + if (Tcl_GetLongFromObj(0,obj, &v) == TCL_OK) { + if (val) *val = v; + return SWIG_OK; + } else { + int len = 0; + const char *nptr = Tcl_GetStringFromObj(obj, &len); + if (nptr && len > 0) { + char *endptr; + long long v; + errno = 0; + v = strtoll(nptr, &endptr,0); + if (nptr[0] == '\0' || *endptr != '\0') + return SWIG_TypeError; + if ((v == LLONG_MAX || v == LLONG_MIN) && errno == ERANGE) { + errno = 0; + return SWIG_OverflowError; + } else { + if (*endptr == '\0') { + if (val) *val = v; + return SWIG_OK; + } + } + } + } + return SWIG_TypeError; +} +} + +/* unsigned long long */ + +%fragment(SWIG_From_frag(unsigned long long),"header", + fragment=SWIG_From_frag(long long), + fragment="<limits.h>", + fragment="<stdio.h>") { +SWIGINTERNINLINE Tcl_Obj* +SWIG_From_dec(unsigned long long)(unsigned long long value) +{ + if (value < (unsigned long long) LONG_MAX) { + return SWIG_From(long long)(%numeric_cast(value, long long)); + } else { + char temp[256]; + sprintf(temp, "%llu", value); + return Tcl_NewStringObj(temp,-1); + } +} +} + +%fragment(SWIG_AsVal_frag(unsigned long long),"header", + fragment=SWIG_AsVal_frag(unsigned long), + fragment="<limits.h>", + fragment="<stdlib.h>") { +SWIGINTERN int +SWIG_AsVal_dec(unsigned long long)(Tcl_Obj *obj, unsigned long long *val) +{ + long v; + if (Tcl_GetLongFromObj(0,obj, &v) == TCL_OK) { + if (val) *val = (unsigned long) v; + return SWIG_OK; + } else { + int len = 0; + const char *nptr = Tcl_GetStringFromObj(obj, &len); + if (nptr && len > 0) { + char *endptr; + unsigned long long v; + if (*nptr == '-') return SWIG_OverflowError; + errno = 0; + v = strtoull(nptr, &endptr,0); + if (nptr[0] == '\0' || *endptr != '\0') + return SWIG_TypeError; + if (v == ULLONG_MAX && errno == ERANGE) { + errno = 0; + return SWIG_OverflowError; + } else { + if (*endptr == '\0') { + if (val) *val = v; + return SWIG_OK; + } + } + } + } + return SWIG_TypeError; +} +} + +/* double */ + +%fragment(SWIG_From_frag(double),"header") { + %define_as(SWIG_From(double), Tcl_NewDoubleObj) +} + +%fragment(SWIG_AsVal_frag(double),"header") { +SWIGINTERN int +SWIG_AsVal_dec(double)(Tcl_Obj *obj, double *val) +{ + double v; + if (Tcl_GetDoubleFromObj(0, obj, &v) == TCL_OK) { + if (val) *val = v; + return SWIG_OK; + } + return SWIG_TypeError; +} +} + diff --git a/devtools/swigwin-1.3.34/Lib/tcl/tclresult.i b/devtools/swigwin-1.3.34/Lib/tcl/tclresult.i new file mode 100644 index 0000000..ca01064 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/tclresult.i @@ -0,0 +1,30 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * tclresult.i + * ----------------------------------------------------------------------------- */ + +/* +int Tcl_Result + + Makes the integer return code of a function the return value + of a SWIG generated wrapper function. For example : + + int foo() { + ... do stuff ... + return TCL_OK; + } + + could be wrapped as follows : + + %include typemaps.i + %apply int Tcl_Result { int foo }; + int foo(); +*/ + +// If return code is a Tcl_Result, simply pass it on + +%typemap(out) int Tcl_Result { + return $1; +} diff --git a/devtools/swigwin-1.3.34/Lib/tcl/tclrun.swg b/devtools/swigwin-1.3.34/Lib/tcl/tclrun.swg new file mode 100644 index 0000000..6387fb0 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/tclrun.swg @@ -0,0 +1,695 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * tclrun.swg + * + * This file contains the runtime support for Tcl modules and includes + * code for managing global variables and pointer type checking. + * ----------------------------------------------------------------------------- */ + +/* Common SWIG API */ + +/* for raw pointers */ +#define SWIG_ConvertPtr(oc, ptr, ty, flags) SWIG_Tcl_ConvertPtr(interp, oc, ptr, ty, flags) +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Tcl_NewPointerObj(ptr, type, flags) + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Tcl_ConvertPacked(interp, obj, ptr, sz, ty) +#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Tcl_NewPackedObj(ptr, sz, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_Tcl_ConvertPtr(interp, obj, pptr, type, flags) +#define SWIG_NewInstanceObj(thisvalue, type, flags) SWIG_Tcl_NewInstanceObj(interp, thisvalue, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Tcl_ConvertPtr(interp, obj, pptr, type, 0) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Tcl_NewPointerObj(ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Tcl_ConvertPacked(interp,obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Tcl_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Tcl_GetModule((Tcl_Interp *) (clientdata)) +#define SWIG_SetModule(clientdata, pointer) SWIG_Tcl_SetModule((Tcl_Interp *) (clientdata), pointer) + + +/* Error manipulation */ + +#define SWIG_ErrorType(code) SWIG_Tcl_ErrorType(code) +#define SWIG_Error(code, msg) SWIG_Tcl_SetErrorMsg(interp, SWIG_Tcl_ErrorType(code), msg) +#define SWIG_fail goto fail + + +/* Tcl-specific SWIG API */ + +#define SWIG_Acquire(ptr) SWIG_Tcl_Acquire(ptr) +#define SWIG_MethodCommand SWIG_Tcl_MethodCommand +#define SWIG_Disown(ptr) SWIG_Tcl_Disown(ptr) +#define SWIG_ConvertPtrFromString(c, ptr, ty, flags) SWIG_Tcl_ConvertPtrFromString(interp, c, ptr, ty, flags) +#define SWIG_MakePtr(c, ptr, ty, flags) SWIG_Tcl_MakePtr(c, ptr, ty, flags) +#define SWIG_PointerTypeFromString(c) SWIG_Tcl_PointerTypeFromString(c) +#define SWIG_GetArgs SWIG_Tcl_GetArgs +#define SWIG_GetConstantObj(key) SWIG_Tcl_GetConstantObj(key) +#define SWIG_ObjectConstructor SWIG_Tcl_ObjectConstructor +#define SWIG_Thisown(ptr) SWIG_Tcl_Thisown(ptr) +#define SWIG_ObjectDelete SWIG_Tcl_ObjectDelete + + +#define SWIG_TCL_DECL_ARGS_2(arg1, arg2) (Tcl_Interp *interp SWIGUNUSED, arg1, arg2) +#define SWIG_TCL_CALL_ARGS_2(arg1, arg2) (interp, arg1, arg2) +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +/* For backward compatibility only */ +#define SWIG_POINTER_EXCEPTION 0 +#define SWIG_GetConstant SWIG_GetConstantObj +#define SWIG_Tcl_GetConstant SWIG_Tcl_GetConstantObj + +#include "assert.h" + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* cc-mode */ +#endif +#endif + +/* Object support */ + +SWIGRUNTIME Tcl_HashTable* +SWIG_Tcl_ObjectTable(void) { + static Tcl_HashTable swigobjectTable; + static int swigobjectTableinit = 0; + if (!swigobjectTableinit) { + Tcl_InitHashTable(&swigobjectTable, TCL_ONE_WORD_KEYS); + swigobjectTableinit = 1; + } + return &swigobjectTable; +} + +/* Acquire ownership of a pointer */ +SWIGRUNTIME void +SWIG_Tcl_Acquire(void *ptr) { + int newobj; + Tcl_CreateHashEntry(SWIG_Tcl_ObjectTable(), (char *) ptr, &newobj); +} + +SWIGRUNTIME int +SWIG_Tcl_Thisown(void *ptr) { + if (Tcl_FindHashEntry(SWIG_Tcl_ObjectTable(), (char *) ptr)) { + return 1; + } + return 0; +} + +/* Disown a pointer. Returns 1 if we owned it to begin with */ +SWIGRUNTIME int +SWIG_Tcl_Disown(void *ptr) { + Tcl_HashEntry *entryPtr = Tcl_FindHashEntry(SWIG_Tcl_ObjectTable(), (char *) ptr); + if (entryPtr) { + Tcl_DeleteHashEntry(entryPtr); + return 1; + } + return 0; +} + +/* Convert a pointer value */ +SWIGRUNTIME int +SWIG_Tcl_ConvertPtrFromString(Tcl_Interp *interp, const char *c, void **ptr, swig_type_info *ty, int flags) { + swig_cast_info *tc; + /* Pointer values must start with leading underscore */ + while (*c != '_') { + *ptr = (void *) 0; + if (strcmp(c,"NULL") == 0) return SWIG_OK; + + /* Empty string: not a pointer */ + if (*c == 0) return SWIG_ERROR; + + /* Hmmm. It could be an object name. */ + + /* Check if this is a command at all. Prevents <c> cget -this */ + /* from being called when c is not a command, firing the unknown proc */ + if (Tcl_VarEval(interp,"info commands ", c, (char *) NULL) == TCL_OK) { + Tcl_Obj *result = Tcl_GetObjResult(interp); + if (*(Tcl_GetStringFromObj(result, NULL)) == 0) { + /* It's not a command, so it can't be a pointer */ + Tcl_ResetResult(interp); + return SWIG_ERROR; + } + } else { + /* This will only fail if the argument is multiple words. */ + /* Multiple words are also not commands. */ + Tcl_ResetResult(interp); + return SWIG_ERROR; + } + + /* Check if this is really a SWIG pointer */ + if (Tcl_VarEval(interp,c," cget -this", (char *) NULL) != TCL_OK) { + Tcl_ResetResult(interp); + return SWIG_ERROR; + } + + c = Tcl_GetStringFromObj(Tcl_GetObjResult(interp), NULL); + } + + c++; + c = SWIG_UnpackData(c,ptr,sizeof(void *)); + if (ty) { + tc = c ? SWIG_TypeCheck(c,ty) : 0; + if (!tc) { + return SWIG_ERROR; + } + if (flags & SWIG_POINTER_DISOWN) { + SWIG_Disown((void *) *ptr); + } + { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,(void *) *ptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + } + } + return SWIG_OK; +} + +/* Convert a pointer value */ +SWIGRUNTIMEINLINE int +SWIG_Tcl_ConvertPtr(Tcl_Interp *interp, Tcl_Obj *oc, void **ptr, swig_type_info *ty, int flags) { + return SWIG_Tcl_ConvertPtrFromString(interp, Tcl_GetStringFromObj(oc,NULL), ptr, ty, flags); +} + +/* Convert a pointer value */ +SWIGRUNTIME char * +SWIG_Tcl_PointerTypeFromString(char *c) { + char d; + /* Pointer values must start with leading underscore. NULL has no type */ + if (*c != '_') { + return 0; + } + c++; + /* Extract hex value from pointer */ + while ((d = *c)) { + if (!(((d >= '0') && (d <= '9')) || ((d >= 'a') && (d <= 'f')))) break; + c++; + } + return c; +} + +/* Convert a packed value value */ +SWIGRUNTIME int +SWIG_Tcl_ConvertPacked(Tcl_Interp *SWIGUNUSEDPARM(interp) , Tcl_Obj *obj, void *ptr, int sz, swig_type_info *ty) { + swig_cast_info *tc; + const char *c; + + if (!obj) goto type_error; + c = Tcl_GetStringFromObj(obj,NULL); + /* Pointer values must start with leading underscore */ + if (*c != '_') goto type_error; + c++; + c = SWIG_UnpackData(c,ptr,sz); + if (ty) { + tc = SWIG_TypeCheck(c,ty); + if (!tc) goto type_error; + } + return SWIG_OK; + + type_error: + + return SWIG_ERROR; +} + + +/* Take a pointer and convert it to a string */ +SWIGRUNTIME void +SWIG_Tcl_MakePtr(char *c, void *ptr, swig_type_info *ty, int flags) { + if (ptr) { + *(c++) = '_'; + c = SWIG_PackData(c,&ptr,sizeof(void *)); + strcpy(c,ty->name); + } else { + strcpy(c,(char *)"NULL"); + } + flags = 0; +} + +/* Create a new pointer object */ +SWIGRUNTIMEINLINE Tcl_Obj * +SWIG_Tcl_NewPointerObj(void *ptr, swig_type_info *type, int flags) { + Tcl_Obj *robj; + char result[SWIG_BUFFER_SIZE]; + SWIG_MakePtr(result,ptr,type,flags); + robj = Tcl_NewStringObj(result,-1); + return robj; +} + +SWIGRUNTIME Tcl_Obj * +SWIG_Tcl_NewPackedObj(void *ptr, int sz, swig_type_info *type) { + char result[1024]; + char *r = result; + if ((2*sz + 1 + strlen(type->name)) > 1000) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + strcpy(r,type->name); + return Tcl_NewStringObj(result,-1); +} + +/* -----------------------------------------------------------------------------* + * Get type list + * -----------------------------------------------------------------------------*/ + +SWIGRUNTIME swig_module_info * +SWIG_Tcl_GetModule(Tcl_Interp *interp) { + const char *data; + swig_module_info *ret = 0; + + /* first check if pointer already created */ + data = Tcl_GetVar(interp, (char *)"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TCL_GLOBAL_ONLY); + if (data) { + SWIG_UnpackData(data, &ret, sizeof(swig_type_info **)); + } + + return ret; +} + +SWIGRUNTIME void +SWIG_Tcl_SetModule(Tcl_Interp *interp, swig_module_info *module) { + char buf[SWIG_BUFFER_SIZE]; + char *data; + + /* create a new pointer */ + data = SWIG_PackData(buf, &module, sizeof(swig_type_info **)); + *data = 0; + Tcl_SetVar(interp, (char *)"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, buf, 0); +} + +/* -----------------------------------------------------------------------------* + * Object auxiliars + * -----------------------------------------------------------------------------*/ + + +SWIGRUNTIME void +SWIG_Tcl_ObjectDelete(ClientData clientData) { + swig_instance *si = (swig_instance *) clientData; + if ((si) && (si->destroy) && (SWIG_Disown(si->thisvalue))) { + if (si->classptr->destructor) { + (si->classptr->destructor)(si->thisvalue); + } + } + Tcl_DecrRefCount(si->thisptr); + free(si); +} + +/* Function to invoke object methods given an instance */ +SWIGRUNTIME int +SWIG_Tcl_MethodCommand(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST _objv[]) { + char *method, *attrname; + swig_instance *inst = (swig_instance *) clientData; + swig_method *meth; + swig_attribute *attr; + Tcl_Obj *oldarg; + Tcl_Obj **objv; + int rcode; + swig_class *cls; + swig_class *cls_stack[64]; + int cls_stack_bi[64]; + int cls_stack_top = 0; + int numconf = 2; + int bi; + + objv = (Tcl_Obj **) _objv; + if (objc < 2) { + Tcl_SetResult(interp, (char *) "wrong # args.", TCL_STATIC); + return TCL_ERROR; + } + method = Tcl_GetStringFromObj(objv[1],NULL); + if (strcmp(method,"-acquire") == 0) { + inst->destroy = 1; + SWIG_Acquire(inst->thisvalue); + return TCL_OK; + } + if (strcmp(method,"-disown") == 0) { + if (inst->destroy) { + SWIG_Disown(inst->thisvalue); + } + inst->destroy = 0; + return TCL_OK; + } + if (strcmp(method,"-delete") == 0) { + Tcl_DeleteCommandFromToken(interp,inst->cmdtok); + return TCL_OK; + } + cls_stack[cls_stack_top] = inst->classptr; + cls_stack_bi[cls_stack_top] = -1; + cls = inst->classptr; + while (1) { + bi = cls_stack_bi[cls_stack_top]; + cls = cls_stack[cls_stack_top]; + if (bi != -1) { + if (!cls->bases[bi] && cls->base_names[bi]) { + /* lookup and cache the base class */ + swig_type_info *info = SWIG_TypeQueryModule(cls->module, cls->module, cls->base_names[bi]); + if (info) cls->bases[bi] = (swig_class *) info->clientdata; + } + cls = cls->bases[bi]; + if (cls) { + cls_stack_bi[cls_stack_top]++; + cls_stack_top++; + cls_stack[cls_stack_top] = cls; + cls_stack_bi[cls_stack_top] = -1; + continue; + } + } + if (!cls) { + cls_stack_top--; + if (cls_stack_top < 0) break; + else continue; + } + cls_stack_bi[cls_stack_top]++; + + meth = cls->methods; + /* Check for methods */ + while (meth && meth->name) { + if (strcmp(meth->name,method) == 0) { + oldarg = objv[1]; + objv[1] = inst->thisptr; + Tcl_IncrRefCount(inst->thisptr); + rcode = (*meth->method)(clientData,interp,objc,objv); + objv[1] = oldarg; + Tcl_DecrRefCount(inst->thisptr); + return rcode; + } + meth++; + } + /* Check class methods for a match */ + if (strcmp(method,"cget") == 0) { + if (objc < 3) { + Tcl_SetResult(interp, (char *) "wrong # args.", TCL_STATIC); + return TCL_ERROR; + } + attrname = Tcl_GetStringFromObj(objv[2],NULL); + attr = cls->attributes; + while (attr && attr->name) { + if ((strcmp(attr->name, attrname) == 0) && (attr->getmethod)) { + oldarg = objv[1]; + objv[1] = inst->thisptr; + Tcl_IncrRefCount(inst->thisptr); + rcode = (*attr->getmethod)(clientData,interp,2, objv); + objv[1] = oldarg; + Tcl_DecrRefCount(inst->thisptr); + return rcode; + } + attr++; + } + if (strcmp(attrname, "-this") == 0) { + Tcl_SetObjResult(interp, Tcl_DuplicateObj(inst->thisptr)); + return TCL_OK; + } + if (strcmp(attrname, "-thisown") == 0) { + if (SWIG_Thisown(inst->thisvalue)) { + Tcl_SetResult(interp,(char*)"1",TCL_STATIC); + } else { + Tcl_SetResult(interp,(char*)"0",TCL_STATIC); + } + return TCL_OK; + } + } else if (strcmp(method, "configure") == 0) { + int i; + if (objc < 4) { + Tcl_SetResult(interp, (char *) "wrong # args.", TCL_STATIC); + return TCL_ERROR; + } + i = 2; + while (i < objc) { + attrname = Tcl_GetStringFromObj(objv[i],NULL); + attr = cls->attributes; + while (attr && attr->name) { + if ((strcmp(attr->name, attrname) == 0) && (attr->setmethod)) { + oldarg = objv[i]; + objv[i] = inst->thisptr; + Tcl_IncrRefCount(inst->thisptr); + rcode = (*attr->setmethod)(clientData,interp,3, &objv[i-1]); + objv[i] = oldarg; + Tcl_DecrRefCount(inst->thisptr); + if (rcode != TCL_OK) return rcode; + numconf += 2; + } + attr++; + } + i+=2; + } + } + } + if (strcmp(method,"configure") == 0) { + if (numconf >= objc) { + return TCL_OK; + } else { + Tcl_SetResult(interp,(char *) "Invalid attribute name.", TCL_STATIC); + return TCL_ERROR; + } + } + if (strcmp(method,"cget") == 0) { + Tcl_SetResult(interp,(char *) "Invalid attribute name.", TCL_STATIC); + return TCL_ERROR; + } + Tcl_SetResult(interp, (char *) "Invalid method. Must be one of: configure cget -acquire -disown -delete", TCL_STATIC); + cls = inst->classptr; + bi = 0; + while (cls) { + meth = cls->methods; + while (meth && meth->name) { + char *cr = (char *) Tcl_GetStringResult(interp); + size_t meth_len = strlen(meth->name); + char* where = strchr(cr,':'); + while(where) { + where = strstr(where, meth->name); + if(where) { + if(where[-1] == ' ' && (where[meth_len] == ' ' || where[meth_len]==0)) { + break; + } else { + where++; + } + } + } + + if (!where) + Tcl_AppendElement(interp, (char *) meth->name); + meth++; + } + cls = inst->classptr->bases[bi++]; + } + return TCL_ERROR; +} + +/* This function takes the current result and turns it into an object command */ +SWIGRUNTIME Tcl_Obj * +SWIG_Tcl_NewInstanceObj(Tcl_Interp *interp, void *thisvalue, swig_type_info *type, int flags) { + Tcl_Obj *robj = SWIG_NewPointerObj(thisvalue, type,0); + /* Check to see if this pointer belongs to a class or not */ + if ((type->clientdata) && (interp)) { + Tcl_CmdInfo ci; + char *name; + name = Tcl_GetStringFromObj(robj,NULL); + if (!Tcl_GetCommandInfo(interp,name, &ci) || (flags)) { + swig_instance *newinst = (swig_instance *) malloc(sizeof(swig_instance)); + newinst->thisptr = Tcl_DuplicateObj(robj); + Tcl_IncrRefCount(newinst->thisptr); + newinst->thisvalue = thisvalue; + newinst->classptr = (swig_class *) type->clientdata; + newinst->destroy = flags; + newinst->cmdtok = Tcl_CreateObjCommand(interp, Tcl_GetStringFromObj(robj,NULL), (swig_wrapper_func) SWIG_MethodCommand, (ClientData) newinst, (swig_delete_func) SWIG_ObjectDelete); + if (flags) { + SWIG_Acquire(thisvalue); + } + } + } + return robj; +} + +/* Function to create objects */ +SWIGRUNTIME int +SWIG_Tcl_ObjectConstructor(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + Tcl_Obj *newObj = 0; + void *thisvalue = 0; + swig_instance *newinst = 0; + swig_class *classptr = (swig_class *) clientData; + swig_wrapper cons = 0; + char *name = 0; + int firstarg = 0; + int thisarg = 0; + int destroy = 1; + + if (!classptr) { + Tcl_SetResult(interp, (char *) "swig: internal runtime error. No class object defined.", TCL_STATIC); + return TCL_ERROR; + } + cons = classptr->constructor; + if (objc > 1) { + char *s = Tcl_GetStringFromObj(objv[1],NULL); + if (strcmp(s,"-this") == 0) { + thisarg = 2; + cons = 0; + } else if (strcmp(s,"-args") == 0) { + firstarg = 1; + } else if (objc == 2) { + firstarg = 1; + name = s; + } else if (objc >= 3) { + char *s1; + name = s; + s1 = Tcl_GetStringFromObj(objv[2],NULL); + if (strcmp(s1,"-this") == 0) { + thisarg = 3; + cons = 0; + } else { + firstarg = 1; + } + } + } + if (cons) { + int result; + result = (*cons)(0, interp, objc-firstarg, &objv[firstarg]); + if (result != TCL_OK) { + return result; + } + newObj = Tcl_DuplicateObj(Tcl_GetObjResult(interp)); + if (!name) name = Tcl_GetStringFromObj(newObj,NULL); + } else if (thisarg > 0) { + if (thisarg < objc) { + destroy = 0; + newObj = Tcl_DuplicateObj(objv[thisarg]); + if (!name) name = Tcl_GetStringFromObj(newObj,NULL); + } else { + Tcl_SetResult(interp, (char *) "wrong # args.", TCL_STATIC); + return TCL_ERROR; + } + } else { + Tcl_SetResult(interp, (char *) "No constructor available.", TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_Tcl_ConvertPtr(interp,newObj, (void **) &thisvalue, *(classptr->type), 0) != SWIG_OK) { + Tcl_DecrRefCount(newObj); + return TCL_ERROR; + } + newinst = (swig_instance *) malloc(sizeof(swig_instance)); + newinst->thisptr = newObj; + Tcl_IncrRefCount(newObj); + newinst->thisvalue = thisvalue; + newinst->classptr = classptr; + newinst->destroy = destroy; + if (destroy) { + SWIG_Acquire(thisvalue); + } + newinst->cmdtok = Tcl_CreateObjCommand(interp,name, (swig_wrapper) SWIG_MethodCommand, (ClientData) newinst, (swig_delete_func) SWIG_ObjectDelete); + return TCL_OK; +} + +/* -----------------------------------------------------------------------------* + * Get arguments + * -----------------------------------------------------------------------------*/ +SWIGRUNTIME int +SWIG_Tcl_GetArgs(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], const char *fmt, ...) { + int argno = 0, opt = 0; + long tempi; + double tempd; + const char *c; + va_list ap; + void *vptr; + Tcl_Obj *obj = 0; + swig_type_info *ty; + + va_start(ap,fmt); + for (c = fmt; (*c && (*c != ':') && (*c != ';')); c++,argno++) { + if (*c == '|') { + opt = 1; + c++; + } + if (argno >= (objc-1)) { + if (!opt) { + Tcl_SetResult(interp, (char *) "Wrong number of arguments ", TCL_STATIC); + goto argerror; + } else { + va_end(ap); + return TCL_OK; + } + } + + vptr = va_arg(ap,void *); + if (vptr) { + if (isupper(*c)) { + obj = SWIG_Tcl_GetConstantObj(Tcl_GetStringFromObj(objv[argno+1],0)); + if (!obj) obj = objv[argno+1]; + } else { + obj = objv[argno+1]; + } + switch(*c) { + case 'i': case 'I': + case 'l': case 'L': + case 'h': case 'H': + case 'b': case 'B': + if (Tcl_GetLongFromObj(interp,obj,&tempi) != TCL_OK) goto argerror; + if ((*c == 'i') || (*c == 'I')) *((int *)vptr) = (int)tempi; + else if ((*c == 'l') || (*c == 'L')) *((long *)vptr) = (long)tempi; + else if ((*c == 'h') || (*c == 'H')) *((short*)vptr) = (short)tempi; + else if ((*c == 'b') || (*c == 'B')) *((unsigned char *)vptr) = (unsigned char)tempi; + break; + case 'f': case 'F': + case 'd': case 'D': + if (Tcl_GetDoubleFromObj(interp,obj,&tempd) != TCL_OK) goto argerror; + if ((*c == 'f') || (*c == 'F')) *((float *) vptr) = (float)tempd; + else if ((*c == 'd') || (*c == 'D')) *((double*) vptr) = tempd; + break; + case 's': case 'S': + if (*(c+1) == '#') { + int *vlptr = (int *) va_arg(ap, void *); + *((char **) vptr) = Tcl_GetStringFromObj(obj, vlptr); + c++; + } else { + *((char **)vptr) = Tcl_GetStringFromObj(obj,NULL); + } + break; + case 'c': case 'C': + *((char *)vptr) = *(Tcl_GetStringFromObj(obj,NULL)); + break; + case 'p': case 'P': + ty = (swig_type_info *) va_arg(ap, void *); + if (SWIG_Tcl_ConvertPtr(interp, obj, (void **) vptr, ty, 0) != SWIG_OK) goto argerror; + break; + case 'o': case 'O': + *((Tcl_Obj **)vptr) = objv[argno+1]; + break; + default: + break; + } + } + } + + if ((*c != ';') && ((objc-1) > argno)) { + Tcl_SetResult(interp, (char *) "Wrong # args.", TCL_STATIC); + goto argerror; + } + va_end(ap); + return TCL_OK; + + argerror: + { + char temp[32]; + sprintf(temp,"%d", argno+1); + c = strchr(fmt,':'); + if (!c) c = strchr(fmt,';'); + if (!c) c = (char *)""; + Tcl_AppendResult(interp,c," argument ", temp, NULL); + va_end(ap); + return TCL_ERROR; + } +} + +#ifdef __cplusplus +#if 0 +{ /* cc-mode */ +#endif +} +#endif diff --git a/devtools/swigwin-1.3.34/Lib/tcl/tclruntime.swg b/devtools/swigwin-1.3.34/Lib/tcl/tclruntime.swg new file mode 100644 index 0000000..bb4edd7 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/tclruntime.swg @@ -0,0 +1,15 @@ +/* tcl.h has to appear first */ +%insert(runtime) %{ +#include <stdio.h> +#include <tcl.h> +#include <errno.h> +#include <stdlib.h> +#include <stdarg.h> +#include <ctype.h> +%} + +%insert(runtime) "swigrun.swg"; /* Common C API type-checking code */ +%insert(runtime) "swigerrors.swg" /* SWIG errors */ +%insert(runtime) "tclerrors.swg"; /* Tcl Errors */ +%insert(runtime) "tclapi.swg"; /* Tcl API */ +%insert(runtime) "tclrun.swg"; /* Tcl run-time code */ diff --git a/devtools/swigwin-1.3.34/Lib/tcl/tclsh.i b/devtools/swigwin-1.3.34/Lib/tcl/tclsh.i new file mode 100644 index 0000000..2e8ed33 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/tclsh.i @@ -0,0 +1,88 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * tclsh.i + * + * SWIG File for building new tclsh program + * ----------------------------------------------------------------------------- */ + +#ifdef AUTODOC +%subsection "tclsh.i" +%text %{ +This module provides the Tcl_AppInit() function needed to build a +new version of the tclsh executable. This file should not be used +when using dynamic loading. To make an interface file work with +both static and dynamic loading, put something like this in your +interface file : + + #ifdef STATIC + %include <tclsh.i> + #endif +%} +#endif + +%{ + +/* A TCL_AppInit() function that lets you build a new copy + * of tclsh. + * + * The macro SWIG_init contains the name of the initialization + * function in the wrapper file. + */ + +#ifndef SWIG_RcFileName +char *SWIG_RcFileName = "~/.myapprc"; +#endif + + +#ifdef MAC_TCL +extern int MacintoshInit _ANSI_ARGS_((void)); +#endif + +int Tcl_AppInit(Tcl_Interp *interp){ + + if (Tcl_Init(interp) == TCL_ERROR) + return TCL_ERROR; + + /* Now initialize our functions */ + + if (SWIG_init(interp) == TCL_ERROR) + return TCL_ERROR; +#if TCL_MAJOR_VERSION > 7 || TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION >= 5 + Tcl_SetVar(interp, (char *) "tcl_rcFileName",SWIG_RcFileName,TCL_GLOBAL_ONLY); +#else + tcl_RcFileName = SWIG_RcFileName; +#endif +#ifdef SWIG_RcRsrcName + Tcl_SetVar(interp, (char *) "tcl_rcRsrcName",SWIG_RcRsrcName,TCL_GLOBAL); +#endif + + return TCL_OK; +} + +#if TCL_MAJOR_VERSION > 7 || TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION >= 4 +int main(int argc, char **argv) { +#ifdef MAC_TCL + char *newArgv[2]; + + if (MacintoshInit() != TCL_OK) { + Tcl_Exit(1); + } + + argc = 1; + newArgv[0] = "tclsh"; + newArgv[1] = NULL; + argv = newArgv; +#endif + + Tcl_Main(argc, argv, Tcl_AppInit); + return(0); + +} +#else +extern int main(); +#endif + +%} + diff --git a/devtools/swigwin-1.3.34/Lib/tcl/tclstrings.swg b/devtools/swigwin-1.3.34/Lib/tcl/tclstrings.swg new file mode 100644 index 0000000..540d627 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/tclstrings.swg @@ -0,0 +1,31 @@ +/* ------------------------------------------------------------ + * utility methods for char strings + * ------------------------------------------------------------ */ + +%fragment("SWIG_AsCharPtrAndSize","header") { +SWIGINTERN int +SWIG_AsCharPtrAndSize(Tcl_Obj *obj, char** cptr, size_t* psize, int *alloc) +{ + int len = 0; + char *cstr = Tcl_GetStringFromObj(obj, &len); + if (cstr) { + if (cptr) *cptr = cstr; + if (psize) *psize = len + 1; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + return SWIG_TypeError; +} +} + + +%fragment("SWIG_FromCharPtrAndSize","header", + fragment="<limits.h>") { +SWIGINTERNINLINE Tcl_Obj * +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + return (size < INT_MAX) ? Tcl_NewStringObj(carray, %numeric_cast(size,int)) : NULL; +} +} + + diff --git a/devtools/swigwin-1.3.34/Lib/tcl/tcltypemaps.swg b/devtools/swigwin-1.3.34/Lib/tcl/tcltypemaps.swg new file mode 100644 index 0000000..7199e67 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/tcltypemaps.swg @@ -0,0 +1,89 @@ +/* ------------------------------------------------------------ + * Typemap specializations for Tcl + * ------------------------------------------------------------ */ + +/* ------------------------------------------------------------ + * Fragment section + * ------------------------------------------------------------ */ + +/* + in Tcl we need to pass the interp value, so, we define the decl/call + macros as needed. +*/ + +#define SWIG_AS_DECL_ARGS SWIG_TCL_DECL_ARGS_2 +#define SWIG_AS_CALL_ARGS SWIG_TCL_CALL_ARGS_2 + + +/* Include fundamental fragemt definitions */ +%include <typemaps/fragments.swg> + +/* Look for user fragments file. */ +%include <tclfragments.swg> + +/* Tcl fragments for primitve types */ +%include <tclprimtypes.swg> + +/* Tcl fragments for char* strings */ +%include <tclstrings.swg> + + +/* ------------------------------------------------------------ + * Unified typemap section + * ------------------------------------------------------------ */ + +/* No director supported in Tcl */ +#ifdef SWIG_DIRECTOR_TYPEMAPS +#undef SWIG_DIRECTOR_TYPEMAPS +#endif + + +/* Tcl types */ +#define SWIG_Object Tcl_Obj * + +/* Overload of the output/constant/exception handling */ + +/* output */ +#define %set_output(obj) Tcl_SetObjResult(interp,obj) + +/* append output */ +#define %append_output(obj) Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),obj) + +/* set constant */ +#define SWIG_SetConstant(name, obj) SWIG_Tcl_SetConstantObj(interp, name, obj) + +/* raise */ +#define SWIG_Raise(obj,type,desc) SWIG_Tcl_SetErrorObj(interp,type,obj) + + +/* Include the unified typemap library */ +%include <typemaps/swigtypemaps.swg> + + +/* ------------------------------------------------------------ + * Tcl extra typemaps + * ------------------------------------------------------------ */ + +#if 1 +// Old 1.3.25 typemaps needed to avoid premature object deletion +%typemap(out,noblock=1) SWIGTYPE *INSTANCE, SWIGTYPE &INSTANCE, SWIGTYPE INSTANCE[] { + Tcl_SetObjResult(interp, SWIG_NewInstanceObj( %as_voidptr($1), $1_descriptor,0)); +} + +%typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { + swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor,%as_voidptrptr(&$1)); + Tcl_SetObjResult(interp,SWIG_NewInstanceObj(%as_voidptr($1), ty,0)); +} + +#endif + +%typemap(throws,noblock=1) SWIGTYPE CLASS { + SWIG_set_result(SWIG_NewInstanceObj(%as_voidptr(SWIG_new_copy($1, $1_ltype)), $&1_descriptor, 1)); + SWIG_fail; +} + +%typemap(out) SWIGTYPE = SWIGTYPE INSTANCE; +%typemap(out) SWIGTYPE * = SWIGTYPE *INSTANCE; +%typemap(out) SWIGTYPE & = SWIGTYPE &INSTANCE; +%typemap(out) SWIGTYPE [] = SWIGTYPE INSTANCE[]; +%typemap(varout) SWIGTYPE = SWIGTYPE INSTANCE; diff --git a/devtools/swigwin-1.3.34/Lib/tcl/tcluserdir.swg b/devtools/swigwin-1.3.34/Lib/tcl/tcluserdir.swg new file mode 100644 index 0000000..d5b41fb --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/tcluserdir.swg @@ -0,0 +1,5 @@ +/* ----------------------------------------------------------------------------- + * Special user directives + * ----------------------------------------------------------------------------- */ + + diff --git a/devtools/swigwin-1.3.34/Lib/tcl/tclwstrings.swg b/devtools/swigwin-1.3.34/Lib/tcl/tclwstrings.swg new file mode 100644 index 0000000..2d344c2 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/tclwstrings.swg @@ -0,0 +1,70 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * tclwstrings.wg + * + * Utility methods for wchar strings + * ----------------------------------------------------------------------------- */ + +%{ +#include <wchar.h> +%} + +%fragment("SWIG_AsWCharPtrAndSize","header") { +SWIGINTERN int +SWIG_AsWCharPtrAndSize(Tcl_Obj *obj, wchar_t** cptr, size_t* psize, int *alloc) +{ + int len = 0; + Tcl_UniChar *ustr = Tcl_GetUnicodeFromObj(obj, &len); + if (ustr) { + if (cptr) { + Tcl_Encoding encoding = NULL; + char *src = (char *) ustr; + int srcLen = (len)*sizeof(Tcl_UniChar); + int dstLen = sizeof(wchar_t)*(len + 1); + char *dst = %new_array(dstLen, char); + int flags = 0; + Tcl_EncodingState *statePtr = 0; + int srcRead = 0; + int dstWrote = 0; + int dstChars = 0; + Tcl_UtfToExternal(0, encoding, src, srcLen, flags, statePtr, dst, + dstLen, &srcRead, &dstWrote, &dstChars); + + if (alloc) *alloc = SWIG_NEWOBJ; + } + if (psize) *psize = len + 1; + return SWIG_OK; + } + return SWIG_TypeError; +} +} + +%fragment("SWIG_FromWCharPtrAndSize","header") { +SWIGINTERNINLINE Tcl_Obj * +SWIG_FromWCharPtrAndSize(const wchar_t* carray, size_t size) +{ + Tcl_Obj *res = NULL; + if (size < INT_MAX) { + Tcl_Encoding encoding = NULL; + char *src = (char *) carray; + int srcLen = (int)(size*sizeof(wchar_t)); + int dstLen = (int)(size*sizeof(Tcl_UniChar)); + char *dst = %new_array(dstLen, char); + int flags = 0; + Tcl_EncodingState *statePtr = 0; + int srcRead = 0; + int dstWrote = 0; + int dstChars = 0; + + Tcl_ExternalToUtf(0, encoding, src, srcLen, flags, statePtr, dst, + dstLen, &srcRead, &dstWrote, &dstChars); + + res = Tcl_NewUnicodeObj((Tcl_UniChar*)dst, (int)size); + %delete_array(dst); + } + return res; +} +} + diff --git a/devtools/swigwin-1.3.34/Lib/tcl/typemaps.i b/devtools/swigwin-1.3.34/Lib/tcl/typemaps.i new file mode 100644 index 0000000..7c9e04a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/typemaps.i @@ -0,0 +1,467 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * typemaps.i + * + * Swig typemap library for Tcl8. This file contains various sorts + * of typemaps for modifying Swig's code generation. + * ----------------------------------------------------------------------------- */ + +#if !defined(SWIG_USE_OLD_TYPEMAPS) +%include <typemaps/typemaps.swg> +#else + +/* +The SWIG typemap library provides a language independent mechanism for +supporting output arguments, input values, and other C function +calling mechanisms. The primary use of the library is to provide a +better interface to certain C function--especially those involving +pointers. +*/ + +// INPUT typemaps. +// These remap a C pointer to be an "INPUT" value which is passed by value +// instead of reference. + +/* +The following methods can be applied to turn a pointer into a simple +"input" value. That is, instead of passing a pointer to an object, +you would use a real value instead. + + int *INPUT + short *INPUT + long *INPUT + long long *INPUT + unsigned int *INPUT + unsigned short *INPUT + unsigned long *INPUT + unsigned long long *INPUT + unsigned char *INPUT + bool *INPUT + float *INPUT + double *INPUT + +To use these, suppose you had a C function like this : + + double fadd(double *a, double *b) { + return *a+*b; + } + +You could wrap it with SWIG as follows : + + %include typemaps.i + double fadd(double *INPUT, double *INPUT); + +or you can use the %apply directive : + + %include typemaps.i + %apply double *INPUT { double *a, double *b }; + double fadd(double *a, double *b); + +*/ + +%typemap(in) double *INPUT(double temp), double &INPUT(double temp) +{ + if (Tcl_GetDoubleFromObj(interp,$input,&temp) == TCL_ERROR) { + SWIG_fail; + } + $1 = &temp; +} + +%typemap(in) float *INPUT(double dvalue, float temp), float &INPUT(double dvalue, float temp) +{ + if (Tcl_GetDoubleFromObj(interp,$input,&dvalue) == TCL_ERROR) { + SWIG_fail; + } + temp = (float) dvalue; + $1 = &temp; +} + +%typemap(in) int *INPUT(int temp), int &INPUT(int temp) +{ + if (Tcl_GetIntFromObj(interp,$input,&temp) == TCL_ERROR) { + SWIG_fail; + } + $1 = &temp; +} + +%typemap(in) short *INPUT(int ivalue, short temp), short &INPUT(int ivalue, short temp) +{ + if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { + SWIG_fail; + } + temp = (short) ivalue; + $1 = &temp; +} + +%typemap(in) long *INPUT(int ivalue, long temp), long &INPUT(int ivalue, long temp) +{ + if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { + SWIG_fail; + } + temp = (long) ivalue; + $1 = &temp; +} + +%typemap(in) unsigned int *INPUT(int ivalue, unsigned int temp), + unsigned int &INPUT(int ivalue, unsigned int temp) +{ + if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { + SWIG_fail; + } + temp = (unsigned int) ivalue; + $1 = &temp; +} + +%typemap(in) unsigned short *INPUT(int ivalue, unsigned short temp), + unsigned short &INPUT(int ivalue, unsigned short temp) +{ + if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { + SWIG_fail; + } + temp = (unsigned short) ivalue; + $1 = &temp; +} + +%typemap(in) unsigned long *INPUT(int ivalue, unsigned long temp), + unsigned long &INPUT(int ivalue, unsigned long temp) +{ + if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { + SWIG_fail; + } + temp = (unsigned long) ivalue; + $1 = &temp; +} + +%typemap(in) unsigned char *INPUT(int ivalue, unsigned char temp), + unsigned char &INPUT(int ivalue, unsigned char temp) +{ + if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { + SWIG_fail; + } + temp = (unsigned char) ivalue; + $1 = &temp; +} + +%typemap(in) signed char *INPUT(int ivalue, signed char temp), + signed char &INPUT(int ivalue, signed char temp) +{ + if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { + SWIG_fail; + } + temp = (signed char) ivalue; + $1 = &temp; +} + +%typemap(in) bool *INPUT(int ivalue, bool temp), + bool &INPUT(int ivalue, bool temp) +{ + if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) { + SWIG_fail; + } + temp = ivalue ? true : false; + $1 = &temp; +} + +%typemap(in) long long *INPUT($*1_ltype temp), + long long &INPUT($*1_ltype temp) +{ + temp = ($*1_ltype) strtoll(Tcl_GetStringFromObj($input,NULL),0,0); + $1 = &temp; +} + +%typemap(in) unsigned long long *INPUT($*1_ltype temp), + unsigned long long &INPUT($*1_ltype temp) +{ + temp = ($*1_ltype) strtoull(Tcl_GetStringFromObj($input,NULL),0,0); + $1 = &temp; +} + +// OUTPUT typemaps. These typemaps are used for parameters that +// are output only. The output value is appended to the result as +// a list element. + +/* +The following methods can be applied to turn a pointer into an "output" +value. When calling a function, no input value would be given for +a parameter, but an output value would be returned. In the case of +multiple output values, they are returned in the form of a Tcl list. + + int *OUTPUT + short *OUTPUT + long *OUTPUT + long long *OUTPUT + unsigned int *OUTPUT + unsigned short *OUTPUT + unsigned long *OUTPUT + unsigned long long *OUTPUT + unsigned char *OUTPUT + bool *OUTPUT + float *OUTPUT + double *OUTPUT + +For example, suppose you were trying to wrap the modf() function in the +C math library which splits x into integral and fractional parts (and +returns the integer part in one of its parameters).K: + + double modf(double x, double *ip); + +You could wrap it with SWIG as follows : + + %include typemaps.i + double modf(double x, double *OUTPUT); + +or you can use the %apply directive : + + %include typemaps.i + %apply double *OUTPUT { double *ip }; + double modf(double x, double *ip); + +The Tcl output of the function would be a list containing both +output values. + +*/ + +%typemap(in,numinputs=0) int *OUTPUT(int temp), + short *OUTPUT(short temp), + long *OUTPUT(long temp), + unsigned int *OUTPUT(unsigned int temp), + unsigned short *OUTPUT(unsigned short temp), + unsigned long *OUTPUT(unsigned long temp), + unsigned char *OUTPUT(unsigned char temp), + signed char *OUTPUT(signed char temp), + bool *OUTPUT(bool temp), + float *OUTPUT(float temp), + double *OUTPUT(double temp), + long long *OUTPUT($*1_ltype temp), + unsigned long long *OUTPUT($*1_ltype temp), + int &OUTPUT(int temp), + short &OUTPUT(short temp), + long &OUTPUT(long temp), + unsigned int &OUTPUT(unsigned int temp), + unsigned short &OUTPUT(unsigned short temp), + unsigned long &OUTPUT(unsigned long temp), + signed char &OUTPUT(signed char temp), + bool &OUTPUT(bool temp), + unsigned char &OUTPUT(unsigned char temp), + float &OUTPUT(float temp), + double &OUTPUT(double temp), + long long &OUTPUT($*1_ltype temp), + unsigned long long &OUTPUT($*1_ltype temp) +"$1 = &temp;"; + +%typemap(argout) int *OUTPUT, int &OUTPUT, + short *OUTPUT, short &OUTPUT, + long *OUTPUT, long &OUTPUT, + unsigned int *OUTPUT, unsigned int &OUTPUT, + unsigned short *OUTPUT, unsigned short &OUTPUT, + unsigned long *OUTPUT, unsigned long &OUTPUT, + unsigned char *OUTPUT, unsigned char &OUTPUT, + signed char *OUTPUT, signed char &OUTPUT, + bool *OUTPUT, bool &OUTPUT +{ + Tcl_Obj *o; + o = Tcl_NewIntObj((int) *($1)); + Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),o); +} + +%typemap(argout) float *OUTPUT, float &OUTPUT, + double *OUTPUT, double &OUTPUT +{ + Tcl_Obj *o; + o = Tcl_NewDoubleObj((double) *($1)); + Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),o); +} + +%typemap(argout) long long *OUTPUT, long long &OUTPUT +{ + char temp[256]; + Tcl_Obj *o; + sprintf(temp,"%lld",(long long)*($1)); + o = Tcl_NewStringObj(temp,-1); + Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),o); +} + +%typemap(argout) unsigned long long *OUTPUT, unsigned long long &OUTPUT +{ + char temp[256]; + Tcl_Obj *o; + sprintf(temp,"%llu",(unsigned long long)*($1)); + o = Tcl_NewStringObj(temp,-1); + Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),o); +} + +// INOUT +// Mappings for an argument that is both an input and output +// parameter + +/* +The following methods can be applied to make a function parameter both +an input and output value. This combines the behavior of both the +"INPUT" and "OUTPUT" methods described earlier. Output values are +returned in the form of a Tcl list. + + int *INOUT + short *INOUT + long *INOUT + long long *INOUT + unsigned int *INOUT + unsigned short *INOUT + unsigned long *INOUT + unsigned long long *INOUT + unsigned char *INOUT + bool *INOUT + float *INOUT + double *INOUT + +For example, suppose you were trying to wrap the following function : + + void neg(double *x) { + *x = -(*x); + } + +You could wrap it with SWIG as follows : + + %include typemaps.i + void neg(double *INOUT); + +or you can use the %apply directive : + + %include typemaps.i + %apply double *INOUT { double *x }; + void neg(double *x); + +Unlike C, this mapping does not directly modify the input value (since +this makes no sense in Tcl). Rather, the modified input value shows +up as the return value of the function. Thus, to apply this function +to a Tcl variable you might do this : + + set x [neg $x] + +*/ + + +%typemap(in) int *INOUT = int *INPUT; +%typemap(in) short *INOUT = short *INPUT; +%typemap(in) long *INOUT = long *INPUT; +%typemap(in) unsigned int *INOUT = unsigned int *INPUT; +%typemap(in) unsigned short *INOUT = unsigned short *INPUT; +%typemap(in) unsigned long *INOUT = unsigned long *INPUT; +%typemap(in) unsigned char *INOUT = unsigned char *INPUT; +%typemap(in) signed char *INOUT = signed char *INPUT; +%typemap(in) bool *INOUT = bool *INPUT; +%typemap(in) float *INOUT = float *INPUT; +%typemap(in) double *INOUT = double *INPUT; +%typemap(in) long long *INOUT = long long *INPUT; +%typemap(in) unsigned long long *INOUT = unsigned long long *INPUT; + +%typemap(in) int &INOUT = int &INPUT; +%typemap(in) short &INOUT = short &INPUT; +%typemap(in) long &INOUT = long &INPUT; +%typemap(in) unsigned int &INOUT = unsigned int &INPUT; +%typemap(in) unsigned short &INOUT = unsigned short &INPUT; +%typemap(in) unsigned long &INOUT = unsigned long &INPUT; +%typemap(in) unsigned char &INOUT = unsigned char &INPUT; +%typemap(in) signed char &INOUT = signed char &INPUT; +%typemap(in) bool &INOUT = bool &INPUT; +%typemap(in) float &INOUT = float &INPUT; +%typemap(in) double &INOUT = double &INPUT; +%typemap(in) long long &INOUT = long long &INPUT; +%typemap(in) unsigned long long &INOUT = unsigned long long &INPUT; + +%typemap(argout) int *INOUT = int *OUTPUT; +%typemap(argout) short *INOUT = short *OUTPUT; +%typemap(argout) long *INOUT = long *OUTPUT; +%typemap(argout) unsigned int *INOUT = unsigned int *OUTPUT; +%typemap(argout) unsigned short *INOUT = unsigned short *OUTPUT; +%typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT; +%typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT; +%typemap(argout) signed char *INOUT = signed char *OUTPUT; +%typemap(argout) bool *INOUT = bool *OUTPUT; +%typemap(argout) float *INOUT = float *OUTPUT; +%typemap(argout) double *INOUT = double *OUTPUT; +%typemap(argout) long long *INOUT = long long *OUTPUT; +%typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT; + +%typemap(argout) int &INOUT = int &OUTPUT; +%typemap(argout) short &INOUT = short &OUTPUT; +%typemap(argout) long &INOUT = long &OUTPUT; +%typemap(argout) unsigned int &INOUT = unsigned int &OUTPUT; +%typemap(argout) unsigned short &INOUT = unsigned short &OUTPUT; +%typemap(argout) unsigned long &INOUT = unsigned long &OUTPUT; +%typemap(argout) unsigned char &INOUT = unsigned char &OUTPUT; +%typemap(argout) signed char &INOUT = signed char &OUTPUT; +%typemap(argout) bool &INOUT = bool &OUTPUT; +%typemap(argout) float &INOUT = float &OUTPUT; +%typemap(argout) double &INOUT = double &OUTPUT; +%typemap(argout) long long &INOUT = long long &OUTPUT; +%typemap(argout) unsigned long long &INOUT = unsigned long long &OUTPUT; + + +/* Overloading information */ + +%typemap(typecheck) double *INPUT = double; +%typemap(typecheck) bool *INPUT = bool; +%typemap(typecheck) signed char *INPUT = signed char; +%typemap(typecheck) unsigned char *INPUT = unsigned char; +%typemap(typecheck) unsigned long *INPUT = unsigned long; +%typemap(typecheck) unsigned short *INPUT = unsigned short; +%typemap(typecheck) unsigned int *INPUT = unsigned int; +%typemap(typecheck) long *INPUT = long; +%typemap(typecheck) short *INPUT = short; +%typemap(typecheck) int *INPUT = int; +%typemap(typecheck) float *INPUT = float; +%typemap(typecheck) long long *INPUT = long long; +%typemap(typecheck) unsigned long long *INPUT = unsigned long long; + +%typemap(typecheck) double &INPUT = double; +%typemap(typecheck) bool &INPUT = bool; +%typemap(typecheck) signed char &INPUT = signed char; +%typemap(typecheck) unsigned char &INPUT = unsigned char; +%typemap(typecheck) unsigned long &INPUT = unsigned long; +%typemap(typecheck) unsigned short &INPUT = unsigned short; +%typemap(typecheck) unsigned int &INPUT = unsigned int; +%typemap(typecheck) long &INPUT = long; +%typemap(typecheck) short &INPUT = short; +%typemap(typecheck) int &INPUT = int; +%typemap(typecheck) float &INPUT = float; +%typemap(typecheck) long long &INPUT = long long; +%typemap(typecheck) unsigned long long &INPUT = unsigned long long; + +%typemap(typecheck) double *INOUT = double; +%typemap(typecheck) bool *INOUT = bool; +%typemap(typecheck) signed char *INOUT = signed char; +%typemap(typecheck) unsigned char *INOUT = unsigned char; +%typemap(typecheck) unsigned long *INOUT = unsigned long; +%typemap(typecheck) unsigned short *INOUT = unsigned short; +%typemap(typecheck) unsigned int *INOUT = unsigned int; +%typemap(typecheck) long *INOUT = long; +%typemap(typecheck) short *INOUT = short; +%typemap(typecheck) int *INOUT = int; +%typemap(typecheck) float *INOUT = float; +%typemap(typecheck) long long *INOUT = long long; +%typemap(typecheck) unsigned long long *INOUT = unsigned long long; + +%typemap(typecheck) double &INOUT = double; +%typemap(typecheck) bool &INOUT = bool; +%typemap(typecheck) signed char &INOUT = signed char; +%typemap(typecheck) unsigned char &INOUT = unsigned char; +%typemap(typecheck) unsigned long &INOUT = unsigned long; +%typemap(typecheck) unsigned short &INOUT = unsigned short; +%typemap(typecheck) unsigned int &INOUT = unsigned int; +%typemap(typecheck) long &INOUT = long; +%typemap(typecheck) short &INOUT = short; +%typemap(typecheck) int &INOUT = int; +%typemap(typecheck) float &INOUT = float; +%typemap(typecheck) long long &INOUT = long long; +%typemap(typecheck) unsigned long long &INOUT = unsigned long long; + +#endif + +// -------------------------------------------------------------------- +// Special types +// -------------------------------------------------------------------- + +%include <tclinterp.i> +%include <tclresult.i> diff --git a/devtools/swigwin-1.3.34/Lib/tcl/wish.i b/devtools/swigwin-1.3.34/Lib/tcl/wish.i new file mode 100644 index 0000000..077ded6 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/tcl/wish.i @@ -0,0 +1,149 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * wish.i + * + * SWIG File for making wish + * ----------------------------------------------------------------------------- */ + +#ifdef AUTODOC +%subsection "wish.i" +%text %{ +This module provides the Tk_AppInit() function needed to build a +new version of the wish executable. Like tclsh.i, this file should +not be used with dynamic loading. To make an interface file work with +both static and dynamic loading, put something like this in your +interface file : + + #ifdef STATIC + %include <wish.i> + #endif + +A startup file may be specified by defining the symbol SWIG_RcFileName +as follows (this should be included in a code-block) : + + #define SWIG_RcFileName "~/.mywishrc" +%} +#endif + +%{ + + +/* Initialization code for wish */ + +#include <tk.h> + +#ifndef SWIG_RcFileName +char *SWIG_RcFileName = "~/.wishrc"; +#endif + +#ifdef MAC_TCL +extern int MacintoshInit _ANSI_ARGS_((void)); +extern int SetupMainInterp _ANSI_ARGS_((Tcl_Interp *interp)); +#endif + +/* + *---------------------------------------------------------------------- + * + * Tcl_AppInit -- + * + * This procedure performs application-specific initialization. + * Most applications, especially those that incorporate additional + * packages, will have their own version of this procedure. + * + * Results: + * Returns a standard Tcl completion code, and leaves an error + * message in interp->result if an error occurs. + * + * Side effects: + * Depends on the startup script. + * + *---------------------------------------------------------------------- + */ + +int Tcl_AppInit(Tcl_Interp *interp) +{ +#ifndef MAC_TCL + Tk_Window main; + main = Tk_MainWindow(interp); +#endif + /* + * Call the init procedures for included packages. Each call should + * look like this: + * + * if (Mod_Init(interp) == TCL_ERROR) { + * return TCL_ERROR; + * } + * + * where "Mod" is the name of the module. + */ + + if (Tcl_Init(interp) == TCL_ERROR) { + return TCL_ERROR; + } + + if (Tk_Init(interp) == TCL_ERROR) { + return TCL_ERROR; + } + + /* + * Call Tcl_CreateCommand for application-specific commands, if + * they weren't already created by the init procedures called above. + */ + + if (SWIG_init(interp) == TCL_ERROR) { + return TCL_ERROR; + } + +#ifdef MAC_TCL + SetupMainInterp(interp); +#endif + + /* + * Specify a user-specific startup file to invoke if the application + * is run interactively. Typically the startup file is "~/.apprc" + * where "app" is the name of the application. If this line is deleted + * then no user-specific startup file will be run under any conditions. + */ + +#if TCL_MAJOR_VERSION >= 8 || TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION >= 5 + Tcl_SetVar(interp, (char *) "tcl_rcFileName",SWIG_RcFileName,TCL_GLOBAL_ONLY); +#else + tcl_RcFileName = SWIG_RcFileName; +#endif + +/* For Macintosh might also want this */ + +#ifdef MAC_TCL +#ifdef SWIG_RcRsrcName + Tcl_SetVar(interp, (char *) "tcl_rcRsrcName",SWIG_RcRsrcName,TCL_GLOBAL_ONLY); +#endif +#endif + return TCL_OK; +} + +#if TK_MAJOR_VERSION >= 4 +int main(int argc, char **argv) { + +#ifdef MAC_TCL + char *newArgv[2]; + if (MacintoshInit() != TCL_OK) { + Tcl_Exit(1); + } + argc = 1; + newArgv[0] = "Wish"; + newArgv[1] = NULL; + argv = newArgv; +#endif + Tk_Main(argc, argv, Tcl_AppInit); + return(0); +} +#else +extern int main(); +#endif + +%} + + + diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/README b/devtools/swigwin-1.3.34/Lib/typemaps/README new file mode 100644 index 0000000..6513457 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/README @@ -0,0 +1,54 @@ +Still in development, but if you are interested into looking around, +start with + + + swigtypemaps.swg + +which is the head file. Also read the docs for %fragments in + + fragments.swg + +and follow the definitions in one of the supported languages: + + python, perl, ruby, tcl + + + + +/* ----------------------------------------------------------------------------- + * Internal typemap specializations + * ----------------------------------------------------------------------------- */ + + +carrays.swg Implement the carrays.i library +cdata.swg Implement the cdata.i library +cmalloc.swg Implement the cmalloc.i library +cpointer.swg Implement the cpointer.i library +cstring.swg Implement the cstring.i library typemaps for char * +cwstring.swg Implement the cstring.i library typemaps for wchar_t * +exception.swg Implement the exception.i library +implicit.swg Allow the use of implicit C++ constructors + +string.swg Typemaps for char * string +wstring.swg Typemaps for wchar_t * string +std_string.swg Typemaps for std::string +std_wstring.swg Typemaps for std::wstring +swigtype.swg Typemaps for the SWIGTYPE type +void.swg Typemaps for the 'void' type +enumint.swg Typemaps for enums treated as 'int' +swigobject.swg Typemaps for the SWIG_Object as in PyObject, Tcl_Obj, etc. +misctypes.swg Typemaps for miscellaneos types (size_t, ptrdiff_t, etc) +ptrtypes.swg Typemaps for types with a 'ptr' behavior +valtypes.swg Typemaps for 'by value' types +inoutlist.swg IN/OUTPUT/INOUT typemaps, where the OUTPUT values are returned in a list +primtypes.swg Common macros to manage primitive types (short,int,double,etc) + +cstrings.swg Common macros to implemented the cstring/cwstring libraries +std_strings.swg Common macros to implemented the std::string/std::wstring typemaps +strings.swg Common macros and typemaps for string and wstring (char *, wchar_t *) + +swigmacros.swg Basic macros +fragments.swg Macros for fragment manipulations + + +typemaps.swg The old typemaps.i library, not needed anymore diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/attribute.swg b/devtools/swigwin-1.3.34/Lib/typemaps/attribute.swg new file mode 100644 index 0000000..f6335be --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/attribute.swg @@ -0,0 +1,205 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * attribute.swg + * + * Attribute implementation + * ----------------------------------------------------------------------------- */ + +/* + The following macros convert a pair of set/get methods + into a "native" attribute. + + Use %attribute when you have a pair of get/set methods + like in: + + %attribute(A, int, a, get_a, set_a); + + struct A + { + int get_a() const; + void set_a(int aa); + }; + + If you don't provide a 'set' method, a 'read-only' attribute + is generated, ie, like in: + + %attribute(A, int, c, get_c); + + Use %attributeref when you have const/non-const reference + access methods, like in: + + %attributeref(A, int, b); + + struct A + { + const int& b() const; + int& b(); + }; + + %attributeref(B, int, c); + + struct B + { + int& c(); + }; + + You can also use + + %attributeref(Class, AttributeType, AttributeName, AccessorMethod) + + if the internal C++ reference methods have a different name from the + attribute you want, so + + %attributeref(B, int, d, c); + + is the same as the last example, but instead of the attribute 'c' being + called 'c', it is called 'd'. + + Now you can use the attributes like so: + + x = A() + x.a = 3 # calls A::set_a + print x.a # calls A::get_a + + x.b = 3 # calls A::b() + print x.b # calls A::b() const + + Use %attribute2 instead of %attribute to indicate that reference-pointer + translation is required. You use %attribute2 instead of %attribute in + cases like this: + + %attribute2(MyClass, MyFoo, Foo, GetFoo, SetFoo); + %inline %{ + struct MyFoo { + int x; + }; + class MyClass { + MyFoo foo; + public: + MyFoo& GetFoo() { return foo; } + void SetFoo(const MyFoo& other) { foo = other; } + }; + %} + + Here, the data type of the property is a wrapped type (MyFoo) and on the + C++ side it is passed by reference. The problem is that the SWIG wrapper will + pass around a pointer (MyFoo *) which is not compatible with the reference + type of the accessors (MyFoo &). Therefore, if you use %attribute, you'll get + an error from your C/C++ compiler. %attribute2 translates between a pointer + and a reference to eliminate the error. In case you're confused, let's make it + simple: just use %attribute at first, but if the C/C++ compiler gives an error + while compiling the wrapper, try %attribute2 instead. + + NOTE: remember that if the type contains commas, such as 'std::pair<int,int>', + you need to use the macro like: + + %attributeref(A, %arg(std::pair<int,int>), pval); + + where %arg() 'normalizes' the type to be understood as a single + argument, otherwise the macro will get confused by the comma. +*/ + +// +// Define SWIG_ATTRIBUTE_TEMPLATE if you want to use templates instead of macros for the C++ get and set wrapper methods +// Does not always generate compileable code, use at your peril! +// +//#define SWIG_ATTRIBUTE_TEMPLATE + +%define %attribute_custom(Class, AttributeType, AttributeName, GetMethod, SetMethod, GetMethodCall, SetMethodCall) + %ignore Class::GetMethod(); + %ignore Class::GetMethod() const; + #if #SetMethod != #AttributeName + %ignore Class::SetMethod; + #endif + %extend Class { + AttributeType AttributeName; + } +#if defined(__cplusplus) && defined(SWIG_ATTRIBUTE_TEMPLATE) + %{ + template < class C > inline AttributeType %mangle(Class) ##_## AttributeName ## _get(const C* self_) { + return GetMethodCall; + } + template < class C > inline AttributeType %mangle(Class) ##_## AttributeName ## _get(C* self_) { + return GetMethodCall; + } + template < class C > inline void %mangle(Class) ##_## AttributeName ## _set(C* self_, AttributeType val_) { + SetMethodCall; + } + %} +#else + %{ + #define %mangle(Class) ##_## AttributeName ## _get(self_) GetMethodCall + #define %mangle(Class) ##_## AttributeName ## _set(self_, val_) SetMethodCall + %} +#endif +%enddef + +%define %attribute_readonly(Class, AttributeType, AttributeName, GetMethod, GetMethodCall) + %ignore Class::GetMethod(); + %ignore Class::GetMethod() const; + %immutable Class::AttributeName; + %extend Class { + AttributeType AttributeName; + } +#if defined(__cplusplus) && defined(SWIG_ATTRIBUTE_TEMPLATE) + %{ + template < class C > inline AttributeType %mangle(Class) ##_## AttributeName ## _get(const C* self_) { + return GetMethodCall; + } + template < class C > inline AttributeType %mangle(Class) ##_## AttributeName ## _get(C* self_) { + return GetMethodCall; + } + %} +#else + %{ + #define %mangle(Class) ##_## AttributeName ## _get(self_) GetMethodCall + %} +#endif +%enddef + + +// User macros + +%define %attribute(Class, AttributeType, AttributeName, GetMethod, SetMethod...) + #if #SetMethod != "" + %attribute_custom(Class, AttributeType, AttributeName, GetMethod, SetMethod, self_->GetMethod(), self_->SetMethod(val_)) + #else + %attribute_readonly(Class, AttributeType, AttributeName, GetMethod, self_->GetMethod()) + #endif +%enddef + +%define %attribute2(Class, AttributeType, AttributeName, GetMethod, SetMethod...) + #if #SetMethod != "" + %attribute_custom(Class, AttributeType, AttributeName, GetMethod, SetMethod, &self_->GetMethod(), self_->SetMethod(*val_)) + #else + %attribute_readonly(Class, AttributeType, AttributeName, GetMethod, &self_->GetMethod()) + #endif +%enddef + +%define %attributeref(Class, AttributeType, AttributeName, AccessorMethod...) + #if #AccessorMethod != "" + %attribute_custom(Class, AttributeType, AttributeName, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) + #else + %attribute_custom(Class, AttributeType, AttributeName, AttributeName, AttributeName, self_->AttributeName(), self_->AttributeName() = val_) + #endif +%enddef + +%define %attribute2ref(Class, AttributeType, AttributeName, AccessorMethod...) + #if #AccessorMethod != "" + %attribute_custom(Class, AttributeType, AttributeName, AccessorMethod, AccessorMethod, &self_->AccessorMethod(), self_->AccessorMethod() = *val_) + #else + %attribute_custom(Class, AttributeType, AccessorMethod, AccessorMethod, AccessorMethod, &self_->AccessorMethod(), self_->AccessorMethod() = *val_) + #endif +%enddef + +// deprecated (same as %attributeref, but there is an argument order inconsistency) +%define %attribute_ref(Class, AttributeType, AccessorMethod, AttributeName...) + #if #AttributeName != "" + %attribute_custom(Class, AttributeType, AttributeName, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) + #else + %attribute_custom(Class, AttributeType, AccessorMethod, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) + #endif +%enddef + diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/carrays.swg b/devtools/swigwin-1.3.34/Lib/typemaps/carrays.swg new file mode 100644 index 0000000..27ca117 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/carrays.swg @@ -0,0 +1,117 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * carrays.swg + * + * This library file contains macros that can be used to manipulate simple + * pointers as arrays. + * ----------------------------------------------------------------------------- */ + +/* ----------------------------------------------------------------------------- + * %array_functions(TYPE,NAME) + * + * Generates functions for creating and accessing elements of a C array + * (as pointers). Creates the following functions: + * + * TYPE *new_NAME(int nelements) + * void delete_NAME(TYPE *); + * TYPE NAME_getitem(TYPE *, int index); + * void NAME_setitem(TYPE *, int index, TYPE value); + * + * ----------------------------------------------------------------------------- */ + +%define %array_functions(TYPE,NAME) +%{ + static TYPE *new_##NAME(size_t nelements) { + return %new_array(nelements, TYPE); + } + + static void delete_##NAME(TYPE *ary) { + %delete_array(ary); + } + + static TYPE NAME##_getitem(TYPE *ary, size_t index) { + return ary[index]; + } + static void NAME##_setitem(TYPE *ary, size_t index, TYPE value) { + ary[index] = value; + } +%} + +TYPE *new_##NAME(size_t nelements); +void delete_##NAME(TYPE *ary); +TYPE NAME##_getitem(TYPE *ary, size_t index); +void NAME##_setitem(TYPE *ary, size_t index, TYPE value); + +%enddef + + +/* ----------------------------------------------------------------------------- + * %array_class(TYPE,NAME) + * + * Generates a class wrapper around a C array. The class has the following + * interface: + * + * struct NAME { + * NAME(int nelements); + * ~NAME(); + * TYPE getitem(int index); + * void setitem(int index, TYPE value); + * TYPE * cast(); + * static NAME *frompointer(TYPE *t); + * } + * + * Use + * + * %array_class_wrap(TYPE,NAME,GET,SET) + * + * if you want different names for the get/set methods. + * ----------------------------------------------------------------------------- */ + +%define %array_class_wrap(TYPE,NAME,getitem,setitem) +%{ +typedef TYPE NAME; +%} + + +typedef struct NAME { +} NAME; + +%extend NAME { + + NAME(size_t nelements) { + return %new_array(nelements, TYPE); + } + + ~NAME() { + %delete_array(self); + } + + TYPE getitem(size_t index) { + return self[index]; + } + + void setitem(size_t index, TYPE value) { + self[index] = value; + } + + TYPE * cast() { + return self; + } + + static NAME *frompointer(TYPE *t) { + return %static_cast(t, NAME *); + } +}; + +%types(NAME = TYPE); + +%enddef + + +#ifndef %array_class +%define %array_class(TYPE,NAME) + %array_class_wrap(TYPE,NAME,getitem,setitem) +%enddef +#endif diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/cdata.swg b/devtools/swigwin-1.3.34/Lib/typemaps/cdata.swg new file mode 100644 index 0000000..32b3f5a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/cdata.swg @@ -0,0 +1,78 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * cdata.swg + * + * This library file contains macros for manipulating raw C data as strings. + * ----------------------------------------------------------------------------- */ + +%{ +typedef struct SWIGCDATA { + char *data; + size_t len; +} SWIGCDATA; +%} + +/* ----------------------------------------------------------------------------- + * Typemaps for returning binary data + * ----------------------------------------------------------------------------- */ + +%typemap(out,noblock=1,fragment="SWIG_FromCharPtrAndSize") SWIGCDATA { + %set_output(SWIG_FromCharPtrAndSize($1.data,$1.len)); +} +%typemap(in) (const void *indata, int inlen) = (char *STRING, int SIZE); + + +/* ----------------------------------------------------------------------------- + * %cdata(TYPE [, NAME]) + * + * Convert raw C data to a binary string. + * ----------------------------------------------------------------------------- */ + +%define %cdata(TYPE,NAME...) + +%insert("header") { +#ifdef __cplusplus +extern "C" { +#endif +#if #NAME == "" +static SWIGCDATA cdata_##TYPE(TYPE *ptr, size_t nelements) +#else +static SWIGCDATA cdata_##NAME(TYPE *ptr, size_t nelements) +#endif +{ + SWIGCDATA d; + d.data = (char *) ptr; +#if #TYPE != "void" + d.len = nelements*sizeof(TYPE); +#else + d.len = nelements; +#endif + return d; +} +#ifdef __cplusplus +} +#endif +} + +#ifdef __cplusplus +extern "C" +#endif +#if #NAME == "" +SWIGCDATA cdata_##TYPE(TYPE *ptr, size_t nelements = 1); +#else +SWIGCDATA cdata_##NAME(TYPE *ptr, size_t nelements = 1); +#endif +%enddef + +%rename(cdata) ::cdata_void(void *ptr, size_t nelements = 1); + +%cdata(void); + +/* Memory move function */ +void memmove(void *data, const void *indata, size_t inlen); + + + + diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/cmalloc.swg b/devtools/swigwin-1.3.34/Lib/typemaps/cmalloc.swg new file mode 100644 index 0000000..15f9629 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/cmalloc.swg @@ -0,0 +1,113 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * cmalloc.swg + * + * This library file contains macros that can be used to create objects using + * the C malloc function. + * ----------------------------------------------------------------------------- */ + +%{ +#include <stdlib.h> +%} + +/* %malloc(TYPE [, NAME = TYPE]) + %calloc(TYPE [, NAME = TYPE]) + %realloc(TYPE [, NAME = TYPE]) + %free(TYPE [, NAME = TYPE]) + %allocators(TYPE [,NAME = TYPE]) + + Creates functions for allocating/reallocating memory. + + TYPE *malloc_NAME(size_t nbytes = sizeof(TYPE); + TYPE *calloc_NAME(size_t nobj=1, size_t size=sizeof(TYPE)); + TYPE *realloc_NAME(TYPE *ptr, size_t nbytes); + void free_NAME(TYPE *ptr); + +*/ + +%define %malloc(TYPE,NAME...) +#if #NAME != "" +%rename(malloc_##NAME) ::malloc(size_t nbytes); +#else +%rename(malloc_##TYPE) ::malloc(size_t nbytes); +#endif + +#if #TYPE != "void" +%typemap(default) size_t nbytes "$1 = (size_t) sizeof(TYPE);" +#endif +TYPE *malloc(size_t nbytes); +%typemap(default) size_t nbytes; +%enddef + +%define %calloc(TYPE,NAME...) +#if #NAME != "" +%rename(calloc_##NAME) ::calloc(size_t nobj, size_t sz); +#else +%rename(calloc_##TYPE) ::calloc(size_t nobj, size_t sz); +#endif +#if #TYPE != "void" +%typemap(default) size_t sz "$1 = (size_t) sizeof(TYPE);" +#else +%typemap(default) size_t sz "$1 = 1;" +#endif +%typemap(default) size_t nobj "$1 = 1;" +TYPE *calloc(size_t nobj, size_t sz); +%typemap(default) size_t sz; +%typemap(default) size_t nobj; +%enddef + +%define %realloc(TYPE,NAME...) +%insert("header") { +#if #NAME != "" +TYPE *realloc_##NAME(TYPE *ptr, size_t nitems) +#else +TYPE *realloc_##TYPE(TYPE *ptr, size_t nitems) +#endif +{ +#if #TYPE != "void" +return (TYPE *) realloc(ptr, nitems*sizeof(TYPE)); +#else +return (TYPE *) realloc(ptr, nitems); +#endif +} +} +#if #NAME != "" +TYPE *realloc_##NAME(TYPE *ptr, size_t nitems); +#else +TYPE *realloc_##TYPE(TYPE *ptr, size_t nitems); +#endif +%enddef + +%define %free(TYPE,NAME...) +#if #NAME != "" +%rename(free_##NAME) ::free(TYPE *ptr); +#else +%rename(free_##TYPE) ::free(TYPE *ptr); +#endif +void free(TYPE *ptr); +%enddef + +%define %sizeof(TYPE,NAME...) +#if #NAME != "" +%constant size_t sizeof_##NAME = sizeof(TYPE); +#else +%constant size_t sizeof_##TYPE = sizeof(TYPE); +#endif +%enddef + +%define %allocators(TYPE,NAME...) +%malloc(TYPE,NAME) +%calloc(TYPE,NAME) +%realloc(TYPE,NAME) +%free(TYPE,NAME) +#if #TYPE != "void" +%sizeof(TYPE,NAME) +#endif +%enddef + + + + + diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/cpointer.swg b/devtools/swigwin-1.3.34/Lib/typemaps/cpointer.swg new file mode 100644 index 0000000..ce1af16 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/cpointer.swg @@ -0,0 +1,160 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * cpointer.swg + * + * This library file contains macros that can be used to manipulate simple + * pointer objects. + * + * ----------------------------------------------------------------------------- */ + +/* ----------------------------------------------------------------------------- + * %pointer_class(type,name) + * + * Places a simple proxy around a simple type like 'int', 'float', or whatever. + * The proxy provides this interface: + * + * class type { + * public: + * type(); + * ~type(); + * type value(); + * void assign(type value); + * }; + * + * Example: + * + * %pointer_class(int, intp); + * + * int add(int *x, int *y) { return *x + *y; } + * + * In python (with proxies) + * + * >>> a = intp() + * >>> a.assign(10) + * >>> a.value() + * 10 + * >>> b = intp() + * >>> b.assign(20) + * >>> print add(a,b) + * 30 + * + * As a general rule, this macro should not be used on class/structures that + * are already defined in the interface. + * ----------------------------------------------------------------------------- */ + + +%define %pointer_class(TYPE, NAME) +%{ +typedef TYPE NAME; +%} + +typedef struct { +} NAME; + +%extend NAME { + NAME() { + return %new_instance(TYPE); + } + ~NAME() { + if (self) %delete(self); + } +} + +%extend NAME { + + void assign(TYPE value) { + *self = value; + } + TYPE value() { + return *self; + } + TYPE * cast() { + return self; + } + static NAME * frompointer(TYPE *t) { + return (NAME *) t; + } +} + +%types(NAME = TYPE); + +%enddef + +/* ----------------------------------------------------------------------------- + * %pointer_functions(type,name) + * + * Create functions for allocating/deallocating pointers. This can be used + * if you don't want to create a proxy class or if the pointer is complex. + * + * %pointer_functions(int, intp) + * + * int add(int *x, int *y) { return *x + *y; } + * + * In python (with proxies) + * + * >>> a = copy_intp(10) + * >>> intp_value(a) + * 10 + * >>> b = new_intp() + * >>> intp_assign(b,20) + * >>> print add(a,b) + * 30 + * >>> delete_intp(a) + * >>> delete_intp(b) + * + * ----------------------------------------------------------------------------- */ + +%define %pointer_functions(TYPE,NAME) +%{ + static TYPE *new_##NAME() { + return %new_instance(TYPE); + } + + static TYPE *copy_##NAME(TYPE value) { + return %new_copy(value, TYPE); + } + + static void delete_##NAME(TYPE *self) { + if (self) %delete(self); + } + + static void NAME ##_assign(TYPE *self, TYPE value) { + *self = value; + } + + static TYPE NAME ##_value(TYPE *self) { + return *self; + } +%} + +TYPE *new_##NAME(); +TYPE *copy_##NAME(TYPE value); +void delete_##NAME(TYPE *self); +void NAME##_assign(TYPE *self, TYPE value); +TYPE NAME##_value(TYPE *self); + +%enddef + +/* ----------------------------------------------------------------------------- + * %pointer_cast(type1,type2,name) + * + * Generates a pointer casting function. + * ----------------------------------------------------------------------------- */ + +%define %pointer_cast(TYPE1,TYPE2,NAME) +%inline %{ +TYPE2 NAME(TYPE1 x) { + return %static_cast(x, TYPE2); +} +%} +%enddef + + + + + + + + diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/cstring.swg b/devtools/swigwin-1.3.34/Lib/typemaps/cstring.swg new file mode 100644 index 0000000..e774c43 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/cstring.swg @@ -0,0 +1,9 @@ +%include <typemaps/cstrings.swg> + +%typemaps_cstring(%cstring, + char, + SWIG_AsCharPtr, + SWIG_AsCharPtrAndSize, + SWIG_FromCharPtr, + SWIG_FromCharPtrAndSize); + diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/cstrings.swg b/devtools/swigwin-1.3.34/Lib/typemaps/cstrings.swg new file mode 100644 index 0000000..9144da7 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/cstrings.swg @@ -0,0 +1,292 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * cstrings.swg + * + * This file provides typemaps and macros for dealing with various forms + * of C character string handling. The primary use of this module + * is in returning character data that has been allocated or changed in + * some way. + * ----------------------------------------------------------------------------- */ + +%define %typemaps_cstring(Name, Char, + SWIG_AsCharPtr, + SWIG_AsCharPtrAndSize, + SWIG_FromCharPtr, + SWIG_FromCharPtrAndSize) + + +/* %cstring_input_binary(TYPEMAP, SIZE) + * + * Macro makes a function accept binary string data along with + * a size. For example: + * + * %cstring_input_binary(Char *buff, int size); + * void foo(Char *buff, int size) { + * } + * + */ + +%define Name ## _input_binary(TYPEMAP, SIZE) +%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) (TYPEMAP, SIZE) + (int res, Char *buf = 0, size_t size = 0, int alloc = 0) { + res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); + } + $1 = ($1_ltype) buf; + $2 = ($2_ltype) size - 1; +} +%typemap(freearg,noblock=1,match="in") (TYPEMAP, SIZE) { + if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum); +} +%enddef + + + +/* + * %cstring_bounded_output(TYPEMAP, MAX) + * + * This macro is used to return a NULL-terminated output string of + * some maximum length. For example: + * + * %cstring_bounded_output(Char *outx, 512); + * void foo(Char *outx) { + * sprintf(outx,"blah blah\n"); + * } + * + */ + +%define Name ## _bounded_output(TYPEMAP,MAX) +%typemap(in,noblock=1,numinputs=0) TYPEMAP (Char temp[MAX+1]) { + $1 = ($1_ltype) temp; +} +%typemap(freearg,match="in") TYPEMAP ""; +%typemap(argout,noblock=1,fragment= #SWIG_FromCharPtr ) TYPEMAP { + $1[MAX] = 0; + %append_output(SWIG_FromCharPtr($1)); +} +%enddef + + + +/* + * %cstring_chunk_output(TYPEMAP, SIZE) + * + * This macro is used to return a chunk of binary string data. + * Embedded NULLs are okay. For example: + * + * %cstring_chunk_output(Char *outx, 512); + * void foo(Char *outx) { + * memmove(outx, somedata, 512); + * } + * + */ + +%define Name ## _chunk_output(TYPEMAP,SIZE) +%typemap(in,noblock=1,numinputs=0) TYPEMAP(Char temp[SIZE]) { + $1 = ($1_ltype) temp; +} +%typemap(freearg,match="in") TYPEMAP ""; +%typemap(argout,noblock=1,fragment= #SWIG_FromCharPtrAndSize) TYPEMAP { + %append_output(SWIG_FromCharPtrAndSize($1,SIZE)); +} +%enddef + + + +/* + * %cstring_bounded_mutable(TYPEMAP, SIZE) + * + * This macro is used to wrap a string that's going to mutate. + * + * %cstring_bounded_mutable(Char *in, 512); + * void foo(in *x) { + * while (*x) { + * *x = toupper(*x); + * x++; + * } + * } + * + */ + + +%define Name ## _bounded_mutable(TYPEMAP,MAX) +%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP + (int res,Char temp[MAX+1], Char *t = 0, size_t n = 0, int alloc = 0) { + res = SWIG_AsCharPtrAndSize($input, &t, &n, &alloc); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "TYPEMAP", $symname, $argnum); + } + if ( n > (size_t) MAX ) n = (size_t) MAX; + memcpy(temp, t, sizeof(Char)*n); + if (alloc == SWIG_NEWOBJ) %delete_array(t); + temp[n - 1] = 0; + $1 = ($1_ltype) temp; +} +%typemap(freearg,match="in") TYPEMAP ""; +%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP { + $1[MAX] = 0; + %append_output(SWIG_FromCharPtr($1)); +} +%enddef + + +/* + * %cstring_mutable(TYPEMAP [, expansion]) + * + * This macro is used to wrap a string that will mutate in place. + * It may change size up to a user-defined expansion. + * + * %cstring_mutable(Char *in); + * void foo(in *x) { + * while (*x) { + * *x = toupper(*x); + * x++; + * } + * } + * + */ + +%define Name ## _mutable(TYPEMAP,EXP...) +%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) TYPEMAP + (int res, Char* t = 0, size_t n = 0, int alloc = 0, size_t expansion = 0) { +#if #EXP != "" + expansion += EXP; +#endif + res = SWIG_AsCharPtrAndSize($input, &t, &n, &alloc); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "TYPEMAP", $symname, $argnum); + } + $1 = %new_array(n+expansion, $*1_ltype); + memcpy($1,t,sizeof(Char)*n); + if (alloc == SWIG_NEWOBJ) %delete_array(t); + $1[n-1] = 0; +} +%typemap(freearg,match="in") TYPEMAP ""; +%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP { + %append_output(SWIG_FromCharPtr($1)); + %delete_array($1); +} +%enddef + + +/* + * %cstring_output_maxsize(TYPEMAP, SIZE) + * + * This macro returns data in a string of some user-defined size. + * + * %cstring_output_maxsize(Char *outx, int max) { + * void foo(Char *outx, int max) { + * sprintf(outx,"blah blah\n"); + * } + */ + +%define Name ## _output_maxsize(TYPEMAP, SIZE) +%typemap(in,noblock=1,fragment=SWIG_AsVal_frag(size_t)) (TYPEMAP, SIZE) (int res, size_t size, Char *buff = 0) { + res = SWIG_AsVal(size_t)($input, &size); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); + } + buff= %new_array(size+1, Char); + $2 = %numeric_cast(size, $2_ltype); + $1 = %static_cast(buff, $1_ltype); +} +%typemap(freearg,noblock=1,match="in") (TYPEMAP,SIZE) { + if (buff$argnum) %delete_array(buff$argnum); +} +%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) (TYPEMAP,SIZE) { + %append_output(SWIG_FromCharPtr($1)); +} +%enddef + +/* + * %cstring_output_withsize(TYPEMAP, SIZE) + * + * This macro is used to return Character data along with a size + * parameter. + * + * %cstring_output_maxsize(Char *outx, int *max) { + * void foo(Char *outx, int *max) { + * sprintf(outx,"blah blah\n"); + * *max = strlen(outx); + * } + */ + +%define Name ## _output_withsize(TYPEMAP, SIZE) +%typemap(in,noblock=1,fragment=SWIG_AsVal_frag(size_t)) (TYPEMAP, SIZE) (int res, size_t n, Char *buff = 0, $*2_ltype size) { + res = SWIG_AsVal(size_t)($input, &n); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); + } + buff= %new_array(n+1, Char); + $1 = %static_cast(buff, $1_ltype); + size = %numeric_cast(n,$*2_ltype); + $2 = &size; +} +%typemap(freearg,noblock=1,match="in")(TYPEMAP,SIZE) { + if (buff$argnum) %delete_array(buff$argnum); +} +%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize) (TYPEMAP,SIZE) { + %append_output(SWIG_FromCharPtrAndSize($1,*$2)); +} +%enddef + + +/* + * %cstring_output_allocate(TYPEMAP, RELEASE) + * + * This macro is used to return Character data that was + * allocated with new or malloc. + * + * %cstring_output_allocated(Char **outx, free($1)); + * void foo(Char **outx) { + * *outx = (Char *) malloc(512); + * sprintf(outx,"blah blah\n"); + * } + */ + +%define Name ## _output_allocate(TYPEMAP, RELEASE) +%typemap(in,noblock=1,numinputs=0) TYPEMAP($*1_ltype temp = 0) { + $1 = &temp; +} +%typemap(freearg,match="in") TYPEMAP ""; +%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtr) TYPEMAP { + if (*$1) { + %append_output(SWIG_FromCharPtr(*$1)); + RELEASE; + } +} +%enddef + + +/* + * %cstring_output_allocate_size(TYPEMAP, SIZE, RELEASE) + * + * This macro is used to return Character data that was + * allocated with new or malloc. + * + * %cstring_output_allocated(Char **outx, int *sz, free($1)); + * void foo(Char **outx, int *sz) { + * *outx = (Char *) malloc(512); + * sprintf(outx,"blah blah\n"); + * *sz = strlen(outx); + * } + */ + +%define Name ## _output_allocate_size(TYPEMAP, SIZE, RELEASE) +%typemap(in,noblock=1,numinputs=0) (TYPEMAP, SIZE) ($*1_ltype temp = 0, $*2_ltype tempn) { + $1 = &temp; $2 = &tempn; +} +%typemap(freearg,match="in") (TYPEMAP,SIZE) ""; +%typemap(argout,noblock=1,fragment=#SWIG_FromCharPtrAndSize)(TYPEMAP,SIZE) { + if (*$1) { + %append_output(SWIG_FromCharPtrAndSize(*$1,*$2)); + RELEASE; + } +} +%enddef + +%enddef + diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/cwstring.swg b/devtools/swigwin-1.3.34/Lib/typemaps/cwstring.swg new file mode 100644 index 0000000..933f9a3 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/cwstring.swg @@ -0,0 +1,10 @@ +%include <typemaps/cstrings.swg> +%include <typemaps/wstring.swg> + +%typemaps_cstring(%cwstring, + wchar_t, + SWIG_AsWCharPtr, + SWIG_AsWCharPtrAndSize, + SWIG_FromWCharPtr, + SWIG_FromWCharPtrAndSize); + diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/enumint.swg b/devtools/swigwin-1.3.34/Lib/typemaps/enumint.swg new file mode 100644 index 0000000..854d6f3 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/enumint.swg @@ -0,0 +1,28 @@ +/* ------------------------------------------------------------ + * Enums mapped as integer values + * ------------------------------------------------------------ */ + +%apply int { enum SWIGTYPE }; +%apply const int& { const enum SWIGTYPE& }; + +%typemap(in,fragment=SWIG_AsVal_frag(int),noblock=1) const enum SWIGTYPE& (int val, int ecode, $basetype temp) { + ecode = SWIG_AsVal(int)($input, &val); + if (!SWIG_IsOK(ecode)) { + %argument_fail(ecode, "$type", $symname, $argnum); + } else { + temp = %static_cast(val,$basetype); + $1 = &temp; + } +} + +%typemap(varin,fragment=SWIG_AsVal_frag(int),noblock=1) enum SWIGTYPE { + if (sizeof(int) != sizeof($1)) { + %variable_fail(SWIG_AttributeError,"$type", "arch, read-only $name"); + } else { + int ecode = SWIG_AsVal(int)($input, %reinterpret_cast(&$1,int*)); + if (!SWIG_IsOK(ecode)) { + %variable_fail(ecode, "$type", "$name"); + } + } +} + diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/exception.swg b/devtools/swigwin-1.3.34/Lib/typemaps/exception.swg new file mode 100644 index 0000000..17a819c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/exception.swg @@ -0,0 +1,89 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * exceptions.swg + * + * This SWIG library file provides language independent exception handling + * ----------------------------------------------------------------------------- */ + +%include <typemaps/swigmacros.swg> + + +/* macros for error manipulation */ +#define %nullref_fmt() "invalid null reference " +#define %varfail_fmt(_type,_name) "in variable '"`_name`"' of type '"`_type`"'" +#ifndef %argfail_fmt +#define %argfail_fmt(_type,_name,_argn) "in method '" `_name` "', argument " `_argn`" of type '" `_type`"'" +#endif +#define %outfail_fmt(_type) "in output value of type '"_type"'" +#ifndef %argnullref_fmt +#define %argnullref_fmt(_type,_name,_argn) %nullref_fmt() %argfail_fmt(_type, _name, _argn) +#endif +#define %varnullref_fmt(_type,_name) %nullref_fmt() %varfail_fmt(_type, _name) +#define %outnullref_fmt(_type) %nullref_fmt() %outfail_fmt(_type) + +/* setting an error */ +#define %error(code,msg...) SWIG_Error(code, msg) +#define %type_error(msg...) SWIG_Error(SWIG_TypeError, msg) + + + +%insert("runtime") { + +%define_as(SWIG_exception_fail(code, msg), %block(%error(code, msg); SWIG_fail)) + +%define_as(SWIG_contract_assert(expr, msg), if (!(expr)) { %error(SWIG_RuntimeError, msg); SWIG_fail; } else) + +} + +#ifdef __cplusplus +/* + You can use the SWIG_CATCH_STDEXCEPT macro with the %exception + directive as follows: + + %exception { + try { + $action + } + catch (my_except& e) { + ... + } + SWIG_CATCH_STDEXCEPT // catch std::exception + catch (...) { + SWIG_exception_fail(SWIG_UnknownError, "Unknown exception"); + } + } +*/ +%{ +#include <stdexcept> +%} +%define SWIG_CATCH_STDEXCEPT + /* catching std::exception */ + catch (std::invalid_argument& e) { + SWIG_exception_fail(SWIG_ValueError, e.what() ); + } catch (std::domain_error& e) { + SWIG_exception_fail(SWIG_ValueError, e.what() ); + } catch (std::overflow_error& e) { + SWIG_exception_fail(SWIG_OverflowError, e.what() ); + } catch (std::out_of_range& e) { + SWIG_exception_fail(SWIG_IndexError, e.what() ); + } catch (std::length_error& e) { + SWIG_exception_fail(SWIG_IndexError, e.what() ); + } catch (std::runtime_error& e) { + SWIG_exception_fail(SWIG_RuntimeError, e.what() ); + } catch (std::exception& e) { + SWIG_exception_fail(SWIG_SystemError, e.what() ); + } +%enddef +%define SWIG_CATCH_UNKNOWN + catch (std::exception& e) { + SWIG_exception_fail(SWIG_SystemError, e.what() ); + } + catch (...) { + SWIG_exception_fail(SWIG_UnknownError, "unknown exception"); + } +%enddef + + +#endif /* __cplusplus */ diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/factory.swg b/devtools/swigwin-1.3.34/Lib/typemaps/factory.swg new file mode 100644 index 0000000..bccceb1 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/factory.swg @@ -0,0 +1,88 @@ +/* + Implement a more natural wrap for factory methods, for example, if + you have: + + ---- geometry.h -------- + struct Geometry { + enum GeomType{ + POINT, + CIRCLE + }; + + virtual ~Geometry() {} + virtual int draw() = 0; + + // + // Factory method for all the Geometry objects + // + static Geometry *create(GeomType i); + }; + + struct Point : Geometry { + int draw() { return 1; } + double width() { return 1.0; } + }; + + struct Circle : Geometry { + int draw() { return 2; } + double radius() { return 1.5; } + }; + + // + // Factory method for all the Geometry objects + // + Geometry *Geometry::create(GeomType type) { + switch (type) { + case POINT: return new Point(); + case CIRCLE: return new Circle(); + default: return 0; + } + } + ---- geometry.h -------- + + + You can use the %factory with the Geometry::create method as follows: + + %newobject Geometry::create; + %factory(Geometry *Geometry::create, Point, Circle); + %include "geometry.h" + + and Geometry::create will return a 'Point' or 'Circle' instance + instead of the plain 'Geometry' type. For example, in python: + + circle = Geometry.create(Geometry.CIRCLE) + r = circle.radius() + + where circle is a Circle proxy instance. + + NOTES: remember to fully qualify all the type names and don't + use %factory inside a namespace declaration, ie, instead of + + namespace Foo { + %factory(Geometry *Geometry::create, Point, Circle); + } + + use + + %factory(Foo::Geometry *Foo::Geometry::create, Foo::Point, Foo::Circle); + + +*/ + +%define %_factory_dispatch(Type) +if (!dcast) { + Type *dobj = dynamic_cast<Type *>($1); + if (dobj) { + dcast = 1; + %set_output(SWIG_NewPointerObj(%as_voidptr(dobj),$descriptor(Type *), $owner | %newpointer_flags)); + } +}%enddef + +%define %factory(Method,Types...) +%typemap(out) Method { + int dcast = 0; + %formacro(%_factory_dispatch, Types) + if (!dcast) { + %set_output(SWIG_NewPointerObj(%as_voidptr($1),$descriptor, $owner | %newpointer_flags)); + } +}%enddef diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/fragments.swg b/devtools/swigwin-1.3.34/Lib/typemaps/fragments.swg new file mode 100644 index 0000000..6d3e202 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/fragments.swg @@ -0,0 +1,458 @@ +/* + Fragments: + ========== + + Second to typemaps, fragments are one the most powerful and + dangerous swig features. So, if you are starting to read about them, + make sure you read all of this document. + + Basics: + ======= + + Fragments provide a way to include or generate code into "on-demand" + as the typemaps could require. + + For example, if you have a very long typemap + + %typemap(in) MyClass * { + MyClass *value = 0; + + <very long typemap> + .... + value = somewhere_converted_from_input_object_here($input); + ... + <very long typemap> + + $result = value; + } + + very soon you will discover yourself copying the same long + conversion code in several typemaps, such as varin, directorout, + etc. Also, you will discover that swig copes verbatim the same very + long conversion code for every argument that requires it, making the + code very large too. + + To eliminate this automatic or manual code copying, we define a + fragment that includes the common conversion code: + + %fragment("AsMyClass","header") { + MyClass *AsMyClass(PyObject *obj) { + MyClass *value = 0; + <very long conversion> + .... + value = somewhere_converted_from_input_object_here(obj); + ... + <very long conversion> + + return value; + } + } + + %typemap(in,fragment="AsMyClass") MyClass * { + $result = AsMyClass($input); + } + + %typemap(varin,fragment="AsMyClass") MyClass * { + $result = AsMyClass($input); + } + + When the 'in' or 'varin' typemaps for MyClass are invoked, the + fragment "AsMyClass" is added to the "header" section, and then the + typemap code is emitted. Hence, the method AsMyClass will be + included in the wrapping code and it will be available at the time + the typemap is applied. + + To define a fragment then you need a name, a section where it goes, + and the code. Usually the section refers to the "header" part, and + both string and braces forms are accepted, ie: + + %fragment("my_name","header") { ... } + %fragment("my_name","header") "..."; + + To ensure all the fragment/typemap engine works as expected, there + are some rules that fragments follow: + + 1.- A fragment is added to the wrapping code only once, ie, for the + method: + + int foo(MyClass *a, MyClass *b); + + the wrapped code will look as much as: + + MyClass *AsMyClass(PyObject *obj) { + ..... + } + + int _wrap_foo(...) { + .... + arg1 = AsMyClass(obj1); + arg2 = AsMyClass(obj2); + ... + result = foo(arg1, arg2); + } + + + even when there will be duplicated typemap to process 'a' and + 'b', the 'AsMyClass' method will be defined only once. + + + 2.- A fragment can only defined once, and the first definition + is the only one taking in account. All other definitions of the + same fragments are silently ignored. For example, you can have + + + %fragment("AsMyClass","header") { <definition 1> } + .... + %fragment("AsMyClass","header") { <definition 2> } + + and then only the first definition is considered. In this way + you can change the 'system' fragments by including yours first. + + Note that this behavior is opposite to the typemaps, where the + last typemap applied or defined prevails. Fragment follows the + first-in-first-out convention since they are intended to be + "global", while typemaps intend to be "locally" specialized. + + 3.- Fragments names can not contain commas. + + + A fragment can include one or more additional fragments, for example: + + %fragment("<limits.h>", "header") { + #include <limits.h> + } + + + %fragment("AsMyClass", "header", fragment="<limits.h>") { + MyClass *AsMyClass(PyObject *obj) { + MyClass *value = 0; + int ival = somewhere_converted_from_input_object_here(obj) + ... + if (ival < CHAR_MIN) { + value = something_from_ival(ival); + } else { + ... + } + ... + return value; + } + } + + in this case, when the "AsMyClass" fragment is emitted, it also + trigger the inclusion of the "<limits.h>" fragment. + + You can add as many fragments as you want, for example + + %fragment("bigfragment","header", fragment="frag1", fragment="frag2", fragment="frag3") ""; + + here, when the "bigfragment" is included, the three fragments "frag1", + "frag2" and "frag3" are included. Note that as "bigframent" is defined + empty, "", it does not add any code by itself, buy only trigger the + inclusion of the other fragments. + + In a typemap you can also include more than one fragment, but since the + syntax is different, you need to specify them in a 'comma separated' + list, for example, considering the previous example: + + %typemap(in,fragment="frag1,frag2,frag3") {...} + + is equivalent to + + %typemap(in,fragment="bigfragment") {...} + + + Finally, you can force the inclusion of a fragment at any moment as follow: + + %fragment("bigfragment"); + + which is very useful inside a template class, for example. + + + Fragment type specialization + ============================ + + Fragments can be "type specialized". The syntax is as follows + + %fragment("name","header") { a type independent fragment } + %fragment("name" {Type}, "header") { a type dependent fragment } + + and they can also, as typemaps, be used inside templates, for exampe: + + template <class T> + struct A { + %fragment("incode"{A<T>},"header") { + 'incode' specialized fragment + } + + %typemap(in,fragment="incode"{A<T>}) { + here we use the 'type specialized' + fragment "incode"{A<T>} + } + }; + + which could seems a not much interesting feature, but is + fundamental for automatic typemap and template specialization. + + + Fragments and automatic typemap specialization: + =============================================== + + Since fragments can be type specialized, they can be elegantly used + to specialized typemaps . + + For example, if you have something like: + + %fragment("incode"{float}, "header") { + float in_method_float(PyObject *obj) { + ... + } + } + + %fragment("incode"{long}, "header") { + float in_method_long(PyObject *obj) { + ... + } + } + + %define %my_typemaps(Type) + %typemaps(in,fragment="incode"{Type}) { + value = in_method_##Type(obj); + } + %enddef + + %my_typemaps(float); + %my_typemaps(long); + + then the proper "incode"{float,double} fragment will be included, + and the proper in_method_{float,double} will be called. + + Since this is a recurrent fragment use, we provide a couple of + macros that make the automatic generation of typemaps easier: + + + Consider for example the following code: + + %fragment(SWIG_From_frag(bool),"header") { + static PyObject* + SWIG_From_dec(bool)(bool value) + { + PyObject *obj = value ? Py_True : Py_False; + Py_INCREF(obj); + return obj; + } + } + + %typemap(out,fragment=SWIG_From_frag(bool)) bool { + $result = SWIG_From(bool)($1)); + } + + Here the macros + + SWIG_From_frag => fragment + SWIG_From_dec => declaration + SWIG_From => call + + allow you to define/include a fragment, and declare and call the + 'from-bool' method as needed. In the simpler case, these macros + just return something like + + SWIG_From_frag(bool) => "SWIG_From_bool" + SWIG_From_dec(bool) => SWIG_From_bool + SWIG_From(bool) => SWIG_From_bool + + But they are specialized for the different languages requirements, + such as perl or tcl that requires passing the interpreter pointer, + and also they can manage C++ ugly types, for example: + + SWIG_From_frag(std::complex<double>) => "SWIG_From_std_complex_Sl_double_Sg_" + SWIG_From_dec(std::complex<double>) => SWIG_From_std_complex_Sl_double_Sg_ + SWIG_From(std::complex<double>) => SWIG_From_std_complex_Sl_double_Sg_ + + + Hence, to declare methods to use with typemaps, always use the + SWIG_From* macros. In the same way, the SWIG_AsVal* and SWIG_AsPtr* + set of macros are provided. + +*/ + + +/* ----------------------------------------------------------------------------- + * Define the basic macros to 'normalize' the type fragments + * ----------------------------------------------------------------------------- */ + +#ifndef SWIG_AS_DECL_ARGS +#define SWIG_AS_DECL_ARGS +#endif + +#ifndef SWIG_FROM_DECL_ARGS +#define SWIG_FROM_DECL_ARGS +#endif + +#ifndef SWIG_AS_CALL_ARGS +#define SWIG_AS_CALL_ARGS +#endif + +#ifndef SWIG_FROM_CALL_ARGS +#define SWIG_FROM_CALL_ARGS +#endif + +#define %fragment_name(Name, Type...) %string_name(Name) "_" {Type} + +#define SWIG_Traits_frag(Type...) %fragment_name(Traits, Type) +#define SWIG_AsPtr_frag(Type...) %fragment_name(AsPtr, Type) +#define SWIG_AsVal_frag(Type...) %fragment_name(AsVal, Type) +#define SWIG_From_frag(Type...) %fragment_name(From, Type) + +#define SWIG_AsVal_name(Type...) %symbol_name(AsVal, Type) +#define SWIG_AsPtr_name(Type...) %symbol_name(AsPtr, Type) +#define SWIG_From_name(Type...) %symbol_name(From, Type) + +#define SWIG_AsVal_dec(Type...) SWIG_AsVal_name(Type) SWIG_AS_DECL_ARGS +#define SWIG_AsPtr_dec(Type...) SWIG_AsPtr_name(Type) SWIG_AS_DECL_ARGS +#define SWIG_From_dec(Type...) SWIG_From_name(Type) SWIG_FROM_DECL_ARGS + +#define SWIG_AsVal(Type...) SWIG_AsVal_name(Type) SWIG_AS_CALL_ARGS +#define SWIG_AsPtr(Type...) SWIG_AsPtr_name(Type) SWIG_AS_CALL_ARGS +#define SWIG_From(Type...) SWIG_From_name(Type) SWIG_FROM_CALL_ARGS + +/* ------------------------------------------------------------ + * common fragments + * ------------------------------------------------------------ */ + +/* Default compiler options for gcc allow long_long but not LLONG_MAX. + * Define SWIG_NO_LLONG_MAX if this added limits support is not wanted. */ +%fragment("<limits.h>","header") %{ +#include <limits.h> +#if !defined(SWIG_NO_LLONG_MAX) +# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) +# define LLONG_MAX __LONG_LONG_MAX__ +# define LLONG_MIN (-LLONG_MAX - 1LL) +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) +# endif +#endif +%} + +%fragment("<math.h>","header") %{ +#include <math.h> +%} + +%fragment("<wchar.h>","header") %{ +#include <wchar.h> +#include <limits.h> +#ifndef WCHAR_MIN +# define WCHAR_MIN 0 +#endif +#ifndef WCHAR_MAX +# define WCHAR_MAX 65535 +#endif +%} + +%fragment("<float.h>","header") %{ +#include <float.h> +%} + +%fragment("<stdio.h>","header") %{ +#include <stdio.h> +#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +# ifndef snprintf +# define snprintf _snprintf +# endif +#endif +%} + +%fragment("<stdlib.h>","header") %{ +#include <stdlib.h> +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif +%} + +/* ----------------------------------------------------------------------------- + * special macros for fragments + * ----------------------------------------------------------------------------- */ + +/* Macros to derive numeric types */ + +%define %numeric_type_from(Type, Base) +%fragment(SWIG_From_frag(Type),"header", + fragment=SWIG_From_frag(Base)) { +SWIGINTERNINLINE SWIG_Object +SWIG_From_dec(Type)(Type value) +{ + return SWIG_From(Base)(value); +} +} +%enddef + +%define %numeric_type_asval(Type, Base, Frag, OverflowCond) +%fragment(SWIG_AsVal_frag(Type),"header", + fragment=Frag, + fragment=SWIG_AsVal_frag(Base)) { +SWIGINTERN int +SWIG_AsVal_dec(Type)(SWIG_Object obj, Type *val) +{ + Base v; + int res = SWIG_AsVal(Base)(obj, &v); + if (SWIG_IsOK(res)) { + if (OverflowCond) { + return SWIG_OverflowError; + } else { + if (val) *val = %numeric_cast(v, Type); + } + } + return res; +} +} +%enddef + +#define %numeric_signed_type_asval(Type, Base, Frag, Min, Max) \ +%numeric_type_asval(Type, Base, Frag, (v < Min || v > Max)) + +#define %numeric_unsigned_type_asval(Type, Base, Frag, Max) \ +%numeric_type_asval(Type, Base, Frag, (v > Max)) + + +/* Macro for 'signed long' derived types */ + +%define %numeric_slong(Type, Frag, Min, Max) +%numeric_type_from(Type, long) +%numeric_signed_type_asval(Type, long, Frag , Min, Max) +%enddef + +/* Macro for 'unsigned long' derived types */ + +%define %numeric_ulong(Type, Frag, Max) +%numeric_type_from(Type, unsigned long) +%numeric_unsigned_type_asval(Type, unsigned long, Frag, Max) +%enddef + + +/* Macro for 'double' derived types */ + +%define %numeric_double(Type, Frag, Min, Max) +%numeric_type_from(Type, double) +%numeric_signed_type_asval(Type, double, Frag , Min, Max) +%enddef + + +/* Macros for missing fragments */ + +%define %ensure_fragment(Fragment) +%fragment(`Fragment`,"header") { +%#error "Swig language implementation must provide the Fragment fragment" +} +%enddef + +%define %ensure_type_fragments(Type) +%fragment(SWIG_From_frag(Type),"header") { +%#error "Swig language implementation must provide a SWIG_From_frag(Type) fragment" +} +%fragment(SWIG_AsVal_frag(Type),"header") { +%#error "Swig language implementation must provide a SWIG_AsVal_frag(Type) fragment" +} +%enddef diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/implicit.swg b/devtools/swigwin-1.3.34/Lib/typemaps/implicit.swg new file mode 100644 index 0000000..24bb3dc --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/implicit.swg @@ -0,0 +1,208 @@ +/* + The %implict macro allows a SwigType (Class) to be accepted + as an input parameter and use its implicit constructors when needed. + + For example: + + + %implicit(A, int, double, B); + + %inline + { + struct B { }; + struct A + { + int ii; + A(int i) { ii = 1; } + A(double d) { ii = 2; } + A(const B& b) { ii = 3; } + }; + + int get(A a) { return a.ii; } + } + + Here, you can call 'get' as + + get(1) ==> get(A(1)) + get(2.0) ==> get(A(2.0)) + get(B()) ==> get(A(B())) + + and swig will construct an 'A' temporal variable using the + corresponding implicit constructor. + + + The plain implicit macro takes care of simple type list. If it doesn't + work because you are passing template types with commas, then use + the %implicit_{1,2,3} versions and/or the %arg macro. + +*/ + +%define %implicit_type(Type...) +%traits_swigtype(Type); +%enddef + +%define %implicit_frag(Type...) ,fragment=SWIG_Traits_frag(Type) %enddef + +%define %implicit_code(Type...) +{ + Type _v; + int res = swig::asval<Type >(obj, &_v); + if (SWIG_IsOK(res)) { + if (val) *val = new value_type(static_cast<const Type& >(_v)); + return SWIG_AddNewMask(res); + } +} +%enddef + +/* implicit */ + +%define %implicit(Type, ...) + +%formacro_1(%implicit_type,__VA_ARGS__); + +%fragment(SWIG_Traits_frag(Type),"header", + fragment="StdTraits" + %formacro_1(%implicit_frag,__VA_ARGS__)) %{ +namespace swig { + template <> struct traits<Type > { + typedef pointer_category category; + static const char* type_name() { return "Type"; } + }; + + template <> struct traits_asptr< Type > { + typedef Type value_type; + static int asptr(SWIG_Object obj, value_type **val) { + Type *vptr; + static swig_type_info* desc = SWIG_TypeQuery("Type *"); + int res = SWIG_ConvertPtr(obj, (void **)&vptr, desc, 0); + if (SWIG_IsOK(res)) { + if (val) *val = vptr; + return res; + } else { + %formacro_1(%implicit_code,__VA_ARGS__) + } + return SWIG_TypeError; + } + }; +} +%} + +%typemap_traits_ptr(%checkcode(POINTER),Type); +%enddef + +/* implicit_1 */ + + +%define %implicit_1(Type, Imp1) +%traits_swigtype(Imp1); + +%fragment(SWIG_Traits_frag(Type),"header", + fragment="StdTraits", + fragment=SWIG_Traits_frag(Imp1)) %{ +namespace swig { + template <> struct traits< Type > { + typedef pointer_category category; + static const char* type_name() { return "Type"; } + }; + + template <> struct traits_asptr< Type > { + typedef Type value_type; + static int asptr(SWIG_Object obj, value_type **val) { + Type *vptr; + static swig_type_info* desc = SWIG_TypeQuery("Type *"); + int res = SWIG_ConvertPtr(obj, (void **)&vptr, desc, 0); + if (SWIG_IsOK(res)) { + if (val) *val = vptr; + return res; + } else { + %implicit_code(Imp1); + } + return SWIG_TypeError; + } + }; +} +%} + +%typemap_traits_ptr(%checkcode(POINTER),Type); + +%enddef + +/* implicit_2 */ + +%define %implicit_2(Type, Imp1, Imp2) +%traits_swigtype(Imp1); +%traits_swigtype(Imp2); + +%fragment(SWIG_Traits_frag(Type),"header", + fragment="StdTraits", + fragment=SWIG_Traits_frag(Imp1), + fragment=SWIG_Traits_frag(Imp2)) %{ +namespace swig { + template <> struct traits< Type > { + typedef pointer_category category; + static const char* type_name() { return "Type"; } + }; + + template <> struct traits_asptr< Type > { + typedef Type value_type; + static int asptr(SWIG_Object obj, value_type **val) { + Type *vptr; + static swig_type_info* desc = SWIG_TypeQuery("Type *"); + int res = SWIG_ConvertPtr(obj, (void **)&vptr, desc, 0); + if (SWIG_IsOK(res)) { + if (val) *val = vptr; + return SWIG_OLDOBJ; + } else { + %implicit_code(Imp1); + %implicit_code(Imp2); + } + return SWIG_TypeError; + } + }; +} +%} + +%typemap_traits_ptr(%checkcode(POINTER),Type); +%enddef + + +/* implicit_3 */ + +%define %implicit_3(Type, Imp1, Imp2, Imp3) +%traits_swigtype(Imp1); +%traits_swigtype(Imp2); +%traits_swigtype(Imp3); + +%fragment(SWIG_Traits_frag(Type),"header", + fragment="StdTraits", + fragment=SWIG_Traits_frag(Imp1), + fragment=SWIG_Traits_frag(Imp2), + fragment=SWIG_Traits_frag(Imp3)) %{ +namespace swig { + template <> struct traits< Type > { + typedef pointer_category category; + static const char* type_name() { return "Type"; } + }; + + template <> struct traits_asptr< Type > { + typedef Type value_type; + static int asptr(SWIG_Object obj, value_type **val) { + Type *vptr; + static swig_type_info* desc = SWIG_TypeQuery("Type *"); + int res = SWIG_ConvertPtr(obj, (void **)&vptr, desc, 0); + if (SWIG_IsOK(res)) { + if (val) *val = vptr; + return res; + } else { + %implicit_code(Imp1); + %implicit_code(Imp2); + %implicit_code(Imp3); + } + return SWIG_TypeError; + } + }; +} +%} + +%typemap_traits_ptr(%checkcode(POINTER),Type); +%enddef diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/inoutlist.swg b/devtools/swigwin-1.3.34/Lib/typemaps/inoutlist.swg new file mode 100644 index 0000000..23fda85 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/inoutlist.swg @@ -0,0 +1,296 @@ +/* ------------------------------------------------------------ + * + * Define the IN/OUTPUT typemaps assuming the output parameters are + * returned in a list, i.e., they are not directly modified. + * + * The user should provide the %append_output(result, obj) method, + * via a macro, which append a particular object to the result. + * + * + * In Tcl, for example, the file is used as: + * + * #define %append_output(obj) Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),obj); + * %include <typemaps/inoutlist.swg> + * + * while in Python it is used as: + * + * #define %append_output(obj) $result = SWIG_Python_AppendResult($result, obj) + * %include <typemaps/inoutlist.swg> + * + * where the method SWIG_Python_AppendResult is defined inside the + * %append_output fragment. + * + * If you forget to define %append_output, this file will generate + * an error. + * + * ------------------------------------------------------------ */ + + +// +// Uncomment the following definition if you don't want the in/out +// typemaps by default, ie, you prefer to use typemaps.i. +// +//#define SWIG_INOUT_NODEF + +// +// Use the following definition to enable the INPUT parameters to +// accept both 'by value' and 'pointer' objects. +// +#define SWIG_INPUT_ACCEPT_PTRS + +// ------------------------------------------------------------------------ +// Pointer handling +// +// These mappings provide support for input/output arguments and common +// uses for C/C++ pointers. +// ------------------------------------------------------------------------ + +// INPUT typemaps. +// These remap a C pointer to be an "INPUT" value which is passed by value +// instead of reference. + +/* +The following methods can be applied to turn a pointer into a simple +"input" value. That is, instead of passing a pointer to an object, +you would use a real value instead. + +To use these, suppose you had a C function like this : + + double fadd(double *a, double *b) { + return *a+*b; + } + +You could wrap it with SWIG as follows : + + double fadd(double *INPUT, double *INPUT); + +or you can use the %apply directive : + + %apply double *INPUT { double *a, double *b }; + double fadd(double *a, double *b); + +*/ +#if defined(SWIG_INPUT_ACCEPT_PTRS) +#define %check_input_ptr(input,arg,desc,disown) (SWIG_IsOK((res = SWIG_ConvertPtr(input,%as_voidptrptr(arg),desc,disown)))) +#else +#define %check_input_ptr(input,arg,desc,disown) (SWIG_IsOK((res = SWIG_ERROR))) +#endif + +%define %_value_input_typemap(code, asval_meth, asval_frag, Type) + %typemap(in,noblock=1,fragment=asval_frag) Type *INPUT ($*ltype temp, int res = 0) { + if (!%check_input_ptr($input,&$1,$descriptor,$disown)) { + Type val; + int ecode = asval_meth($input, &val); + if (!SWIG_IsOK(ecode)) { + %argument_fail(ecode, "$*ltype",$symname, $argnum); + } + temp = %static_cast(val, $*ltype); + $1 = &temp; + res = SWIG_AddTmpMask(ecode); + } + } + %typemap(in,noblock=1,fragment=asval_frag) Type &INPUT($*ltype temp, int res = 0) { + if (!%check_input_ptr($input,&$1,$descriptor,$disown)) { + Type val; + int ecode = asval_meth($input, &val); + if (!SWIG_IsOK(ecode)) { + %argument_fail(ecode, "$*ltype",$symname, $argnum); + } + temp = %static_cast(val, $*ltype); + $1 = &temp; + res = SWIG_AddTmpMask(ecode); + } + } + %typemap(freearg,noblock=1,match="in") Type *INPUT, Type &INPUT { + if (SWIG_IsNewObj(res$argnum)) %delete($1); + } + %typemap(typecheck,noblock=1,precedence=code,fragment=asval_frag) Type *INPUT, Type &INPUT { + void *ptr = 0; + int res = asval_meth($input, 0); + $1 = SWIG_CheckState(res); + if (!$1) { + $1 = %check_input_ptr($input,&ptr,$1_descriptor,0); + } + } +%enddef + +%define %_ptr_input_typemap(code,asptr_meth,asptr_frag,Type) + %typemap(in,noblock=1,fragment=asptr_frag) Type *INPUT(int res = 0) { + res = asptr_meth($input, &$1); + if (!SWIG_IsOK(res)) { + %argument_fail(res,"$type",$symname, $argnum); + } + res = SWIG_AddTmpMask(res); + } + %typemap(in,noblock=1,fragment=asptr_frag) Type &INPUT(int res = 0) { + res = asptr_meth($input, &$1); + if (!SWIG_IsOK(res)) { + %argument_fail(res,"$type",$symname, $argnum); + } + if (!$1) { + %argument_nullref("$type",$symname, $argnum); + } + res = SWIG_AddTmpMask(res); + } + %typemap(freearg,noblock=1,match="in") Type *INPUT, Type &INPUT { + if (SWIG_IsNewObj(res$argnum)) %delete($1); + } + %typemap(typecheck,noblock=1,precedence=code,fragment=asptr_frag) Type *INPUT, Type &INPUT { + int res = asptr_meth($input, (Type**)0); + $1 = SWIG_CheckState(res); + } +%enddef + +// OUTPUT typemaps. These typemaps are used for parameters that +// are output only. The output value is appended to the result as +// a list element. + +/* +The following methods can be applied to turn a pointer into an "output" +value. When calling a function, no input value would be given for +a parameter, but an output value would be returned. In the case of +multiple output values, they are returned in the form of a list. + + +For example, suppose you were trying to wrap the modf() function in the +C math library which splits x into integral and fractional parts (and +returns the integer part in one of its parameters): + + double modf(double x, double *ip); + +You could wrap it with SWIG as follows : + + double modf(double x, double *OUTPUT); + +or you can use the %apply directive : + + %apply double *OUTPUT { double *ip }; + double modf(double x, double *ip); + +The output of the function would be a list containing both output +values. + +*/ + +%define %_value_output_typemap(from_meth, from_frag, Type) + %typemap(in,numinputs=0,noblock=1) + Type *OUTPUT ($*1_ltype temp, int res = SWIG_TMPOBJ), + Type &OUTPUT ($*1_ltype temp, int res = SWIG_TMPOBJ) { + $1 = &temp; + } + %typemap(argout,noblock=1,fragment=from_frag) Type *OUTPUT, Type &OUTPUT { + if (SWIG_IsTmpObj(res$argnum)) { + %append_output(from_meth((*$1))); + } else { + int new_flags = SWIG_IsNewObj(res$argnum) ? (SWIG_POINTER_OWN | %newpointer_flags) : %newpointer_flags; + %append_output(SWIG_NewPointerObj((void*)($1), $1_descriptor, new_flags)); + } + } +%enddef + + +// INOUT +// Mappings for an argument that is both an input and output +// parameter + +/* +The following methods can be applied to make a function parameter both +an input and output value. This combines the behavior of both the +"INPUT" and "OUTPUT" methods described earlier. Output values are +returned in the form of a list. + +For example, suppose you were trying to wrap the following function : + + void neg(double *x) { + *x = -(*x); + } + +You could wrap it with SWIG as follows : + + void neg(double *INOUT); + +or you can use the %apply directive : + + %apply double *INOUT { double *x }; + void neg(double *x); + +Unlike C, this mapping does not directly modify the input value. +Rather, the modified input value shows up as the return value of the +function. Thus, to apply this function to a variable you might do +this : + + x = neg(x) + +Note : previous versions of SWIG used the symbol 'BOTH' to mark +input/output arguments. This is still supported, but will be slowly +phased out in future releases. + +*/ + +%define %_value_inout_typemap(Type) + %typemap(in) Type *INOUT = Type *INPUT; + %typemap(in) Type &INOUT = Type &INPUT; + %typemap(typecheck) Type *INOUT = Type *INPUT; + %typemap(typecheck) Type &INOUT = Type &INPUT; + %typemap(argout) Type *INOUT = Type *OUTPUT; + %typemap(argout) Type &INOUT = Type &OUTPUT; +%enddef + + +%define %_ptr_inout_typemap(Type) + %_value_inout_typemap(%arg(Type)) + %typemap(typecheck) Type *INOUT = Type *INPUT; + %typemap(typecheck) Type &INOUT = Type &INPUT; + %typemap(freearg) Type *INOUT = Type *INPUT; + %typemap(freearg) Type &INOUT = Type &INPUT; +%enddef + +#ifndef SWIG_INOUT_NODEF + +%define %value_input_typemap(code,asval_meth, asval_frag, Type...) + %_value_input_typemap(%arg(code),%arg(asval_meth),%arg(asval_frag),%arg(Type)) +%enddef + +%define %ptr_input_typemap(code,asval_meth,asval_frag,Type...) + %_ptr_input_typemap(%arg(code),%arg(asval_meth),%arg(asval_frag),%arg(Type)) +%enddef + +%define %value_output_typemap(from_meth,from_frag,Type...) + %_value_output_typemap(%arg(from_meth),%arg(from_frag),%arg(Type)) +%enddef + +#define %value_inout_typemap(Type...) %_value_inout_typemap(%arg(Type)) +#define %ptr_inout_typemap(Type...) %_ptr_inout_typemap(%arg(Type)) + +#else /* You need to include typemaps.i */ + + +#define %value_output_typemap(Type...) +#define %value_input_typemap(Type...) +#define %value_inout_typemap(Type...) +#define %ptr_input_typemap(Type...) +#define %ptr_inout_typemap(Type...) + +#endif /* SWIG_INOUT_DEFAULT */ + +/*---------------------------------------------------------------------- + Front ends. + + use the following macros to define your own IN/OUTPUT/INOUT typemaps + + ------------------------------------------------------------------------*/ +%define %typemaps_inout(Code, AsValMeth, FromMeth, AsValFrag, FromFrag, Type...) + %_value_input_typemap(%arg(Code), %arg(AsValMeth), + %arg(AsValFrag), %arg(Type)); + %_value_output_typemap(%arg(FromMeth), %arg(FromFrag), %arg(Type)); + %_value_inout_typemap(%arg(Type)); +%enddef + +%define %typemaps_inoutn(Code,Type...) + %typemaps_inout(%arg(Code), + %arg(SWIG_AsVal(Type)), + %arg(SWIG_From(Type)), + %arg(SWIG_AsVal_frag(Type)), + %arg(SWIG_From_frag(Type)), + %arg(Type)); +%enddef diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/misctypes.swg b/devtools/swigwin-1.3.34/Lib/typemaps/misctypes.swg new file mode 100644 index 0000000..09c81d7 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/misctypes.swg @@ -0,0 +1,21 @@ + +/* ------------------------------------------------------------ + * --- ANSI/Posix C/C++ types --- + * ------------------------------------------------------------ */ + + +#ifdef __cplusplus + +%apply size_t { std::size_t }; +%apply const size_t& { const std::size_t& }; + +%apply ptrdiff_t { std::ptrdiff_t }; +%apply const ptrdiff_t& { const std::ptrdiff_t& }; + +#ifndef SWIG_INOUT_NODEF +%apply size_t& { std::size_t& }; +%apply ptrdiff_t& { std::ptrdiff_t& }; +#endif + +#endif + diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/primtypes.swg b/devtools/swigwin-1.3.34/Lib/typemaps/primtypes.swg new file mode 100644 index 0000000..4901ff6 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/primtypes.swg @@ -0,0 +1,320 @@ +/* ------------------------------------------------------------ + * Primitive type fragments and macros + * ------------------------------------------------------------ */ + +/* + This file provide fragments and macros for the C/C++ primitive types. + + The file defines default fragments for the following types: + + bool + signed char + unsigned char + signed wchar_t // in C++ + unsigned wchar_t // in C++ + short + unsigned short + int + unsigned int + float + size_t + ptrdiff_t + + which can always be redefined in the swig target languge if needed. + + The fragments for the following types, however, need to be defined + in the target language always: + + long + unsigned long + long long + unsigned long long + double + + If they are not provided, an #error directive will appear in the + wrapped code. + + -------------------------------------------------------------------- + + This file provides the macro + + %typemaps_primitive(CheckCode, Type) + + which generate the typemaps for a primitive type with a given + checkcode. It is assumed the the primitive type is 'normalized' and + the corresponding SWIG_AsVal(Type) and SWIG_From(Type) methods are + provided via fragments. + + + The following auxiliar macros (explained with bash pseudo code) are + also defined: + + %apply_ctypes(Macro) + for i in C Type + do + Macro($i) + done + + %apply_cpptypes(Macro) + for i in C++ Type + do + Macro($i) + done + + %apply_ctypes_2(Macro2) + for i in C Type + do + for j in C Type + do + Macro_2($i, $j) + done + done + + %apply_cpptypes_2(Macro2) + for i in C++ Type + do + for j in C++ Type + do + Macro_2($i, $j) + done + done + + %apply_checkctypes(Macro2) + for i in Check Type + do + Macro2(%checkcode($i), $i) + done + +*/ + + +/* ------------------------------------------------------------ + * Primitive type fragments + * ------------------------------------------------------------ */ +/* boolean */ + +%fragment(SWIG_From_frag(bool),"header",fragment=SWIG_From_frag(long)) { +SWIGINTERN SWIG_Object +SWIG_From_dec(bool)(bool value) +{ + return SWIG_From(long)(value ? 1 : 0); +} +} + +%fragment(SWIG_AsVal_frag(bool),"header",fragment=SWIG_AsVal_frag(long)) { +SWIGINTERN int +SWIG_AsVal_dec(bool)(SWIG_Object obj, bool *val) +{ + long v; + int res = SWIG_AsVal(long)(obj, val ? &v : 0); + if (SWIG_IsOK(res)) { + if (val) *val = v ? true : false; + return res; + } + return SWIG_TypeError; +} +} + +/* signed/unsigned char */ + +%numeric_slong(signed char, "<limits.h>", SCHAR_MIN, SCHAR_MAX) +%numeric_ulong(unsigned char, "<limits.h>", UCHAR_MAX) + +/* short/unsigned short */ + +%numeric_slong(short, "<limits.h>", SHRT_MIN, SHRT_MAX) +%numeric_ulong(unsigned short, "<limits.h>", USHRT_MAX) + +/* int/unsigned int */ + +%numeric_slong(int, "<limits.h>", INT_MIN, INT_MAX) +%numeric_ulong(unsigned int, "<limits.h>", UINT_MAX) + +/* signed/unsigned wchar_t */ + +#ifdef __cplusplus +%numeric_slong(signed wchar_t, "<wchar.h>", WCHAR_MIN, WCHAR_MAX) +%numeric_ulong(unsigned wchar_t, "<wchar.h>", UWCHAR_MAX) +#endif + +/* float */ + +%numeric_double(float, "<float.h>", -FLT_MAX, FLT_MAX) + +/* long/unsgined long */ + +%ensure_type_fragments(long) +%ensure_type_fragments(unsigned long) + +/* long long/unsigned long long */ + +%ensure_type_fragments(long long) +%ensure_type_fragments(unsigned long long) + +/* double */ + +%ensure_type_fragments(double) + +/* size_t */ + +%fragment(SWIG_From_frag(size_t),"header",fragment=SWIG_From_frag(unsigned long)) { +SWIGINTERNINLINE SWIG_Object +SWIG_From_dec(size_t)(size_t value) +{ + return SWIG_From(unsigned long)(%numeric_cast(value, unsigned long)); +} +} + +%fragment(SWIG_AsVal_frag(size_t),"header",fragment=SWIG_AsVal_frag(unsigned long)) { +SWIGINTERNINLINE int +SWIG_AsVal_dec(size_t)(SWIG_Object obj, size_t *val) +{ + unsigned long v; + int res = SWIG_AsVal(unsigned long)(obj, val ? &v : 0); + if (SWIG_IsOK(res) && val) *val = %numeric_cast(v, size_t); + return res; +} +} + +/* ptrdiff_t */ + +%fragment(SWIG_From_frag(ptrdiff_t),"header",fragment=SWIG_From_frag(long)) { +SWIGINTERNINLINE SWIG_Object +SWIG_From_dec(ptrdiff_t)(ptrdiff_t value) +{ + return SWIG_From(long)(%numeric_cast(value,long)); +} +} + +%fragment(SWIG_AsVal_frag(ptrdiff_t),"header",fragment=SWIG_AsVal_frag(long)) { +SWIGINTERNINLINE int +SWIG_AsVal_dec(ptrdiff_t)(SWIG_Object obj, ptrdiff_t *val) +{ + long v; + int res = SWIG_AsVal(long)(obj, val ? &v : 0); + if (SWIG_IsOK(res) && val) *val = %numeric_cast(v, ptrdiff_t); + return res; +} +} + + +%fragment("SWIG_CanCastAsInteger","header", + fragment=SWIG_AsVal_frag(double), + fragment="<float.h>", + fragment="<math.h>") { +SWIGINTERNINLINE int +SWIG_CanCastAsInteger(double *d, double min, double max) { + double x = *d; + if ((min <= x && x <= max)) { + double fx = floor(x); + double cx = ceil(x); + double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ + if ((errno == EDOM) || (errno == ERANGE)) { + errno = 0; + } else { + double summ, reps, diff; + if (rd < x) { + diff = x - rd; + } else if (rd > x) { + diff = rd - x; + } else { + return 1; + } + summ = rd + x; + reps = diff/summ; + if (reps < 8*DBL_EPSILON) { + *d = rd; + return 1; + } + } + } + return 0; +} +} + +/* ------------------------------------------------------------ + * Generate the typemaps for primitive type + * ------------------------------------------------------------ */ + +#define %typemaps_primitive(Code, Type) %typemaps_asvalfromn(%arg(Code), Type) + +/* ------------------------------------------------------------ + * Primitive Type Macros + * ------------------------------------------------------------ */ + +/* useful macros to derive typemap declarations from primitive types */ + +%define _apply_macro(macro, arg2, arg1...) +#if #arg1 != "" +macro(%arg(arg1),arg2); +#else +macro(arg2); +#endif +%enddef + +/* Apply macro to the C-types */ +%define %apply_ctypes(Macro, Arg2...) +_apply_macro(Macro, bool , Arg2); +_apply_macro(Macro, signed char , Arg2); +_apply_macro(Macro, unsigned char , Arg2); +_apply_macro(Macro, short , Arg2); +_apply_macro(Macro, unsigned short , Arg2); +_apply_macro(Macro, int , Arg2); +_apply_macro(Macro, unsigned int , Arg2); +_apply_macro(Macro, long , Arg2); +_apply_macro(Macro, unsigned long , Arg2); +_apply_macro(Macro, long long , Arg2); +_apply_macro(Macro, unsigned long long , Arg2); +_apply_macro(Macro, float , Arg2); +_apply_macro(Macro, double , Arg2); +_apply_macro(Macro, char , Arg2); +_apply_macro(Macro, wchar_t , Arg2); +_apply_macro(Macro, size_t , Arg2); +_apply_macro(Macro, ptrdiff_t , Arg2); +%enddef + +/* apply the Macro2(Type1, Type2) to all C types */ +#define %apply_ctypes_2(Macro2) %apply_ctypes(%apply_ctypes, Macro2) + + +/* apply the Macro(Type) to all C++ types */ +%define %apply_cpptypes(Macro, Arg2...) +%apply_ctypes(Macro, Arg2) +_apply_macro(Macro, std::size_t, Arg2); +_apply_macro(Macro, std::ptrdiff_t, Arg2); +_apply_macro(Macro, std::string, Arg2); +_apply_macro(Macro, std::complex<float>, Arg2); +_apply_macro(Macro, std::complex<double>, Arg2); +%enddef + +/* apply the Macro2(Type1, Type2) to all C++ types */ +#define %apply_cpptypes_2(Macro2) %apply_cpptypes(%apply_cpptypes, Macro2) + +/* apply the Macro2(CheckCode,Type) to all Checked Types */ +%define %apply_checkctypes(Macro2) +Macro2(%checkcode(BOOL), bool); +Macro2(%checkcode(INT8), signed char); +Macro2(%checkcode(UINT8), unsigned char); +Macro2(%checkcode(INT16), short); +Macro2(%checkcode(UINT16), unsigned short); +Macro2(%checkcode(INT32), int); +Macro2(%checkcode(UINT32), unsigned int); +Macro2(%checkcode(INT64), long); +Macro2(%checkcode(UINT64), unsigned long); +Macro2(%checkcode(INT128), long long); +Macro2(%checkcode(UINT128), unsigned long long); +Macro2(%checkcode(FLOAT), float); +Macro2(%checkcode(DOUBLE), double); +Macro2(%checkcode(CHAR), char); +Macro2(%checkcode(UNICHAR), wchar_t); +Macro2(%checkcode(SIZE), size_t); +Macro2(%checkcode(PTRDIFF), ptrdiff_t); +%enddef + + +/* ------------------------------------------------------------ + * Generate the typemaps for all the primitive types with checkcode + * ------------------------------------------------------------ */ + +%apply_checkctypes(%typemaps_primitive); + diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/ptrtypes.swg b/devtools/swigwin-1.3.34/Lib/typemaps/ptrtypes.swg new file mode 100644 index 0000000..803377a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/ptrtypes.swg @@ -0,0 +1,211 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * ptrtypes.swg + * + * Value typemaps (Type, const Type&) for "Ptr" types, such as swig + * wrapped classes, that define the AsPtr/From methods + * + * To apply them, just use one of the following macros: + * + * %typemaps_asptr(CheckCode, AsPtrMeth, AsPtrFrag, Type) + * %typemaps_asptrfrom(CheckCode, AsPtrMeth, FromMeth, AsPtrFrag, FromFrag, Type) + * + * or the simpler and normalize form: + * + * %typemaps_asptrfromn(CheckCode, Type) + * + * Also, you can use the individual typemap definitions: + * + * %ptr_in_typemap(asptr_meth,frag,Type) + * %ptr_varin_typemap(asptr_meth,frag,Type) + * %ptr_typecheck_typemap(check,asptr_meth,frag,Type) + * %ptr_directorout_typemap(asptr_meth,frag,Type) + * ----------------------------------------------------------------------------- */ + +%include <typemaps/valtypes.swg> + +/* in */ + +%define %ptr_in_typemap(asptr_meth,frag,Type...) + %typemap(in,fragment=frag) Type { + Type *ptr = (Type *)0; + int res = asptr_meth($input, &ptr); + if (!SWIG_IsOK(res) || !ptr) { + %argument_fail((ptr ? res : SWIG_TypeError), "$type", $symname, $argnum); + } + $1 = *ptr; + if (SWIG_IsNewObj(res)) %delete(ptr); + } + %typemap(freearg) Type ""; + %typemap(in,fragment=frag) const Type & (int res = SWIG_OLDOBJ) { + Type *ptr = (Type *)0; + res = asptr_meth($input, &ptr); + if (!SWIG_IsOK(res)) { %argument_fail(res,"$type",$symname, $argnum); } + if (!ptr) { %argument_nullref("$type",$symname, $argnum); } + $1 = ptr; + } + %typemap(freearg,noblock=1) const Type & { + if (SWIG_IsNewObj(res$argnum)) %delete($1); + } +%enddef + +/* varin */ + +%define %ptr_varin_typemap(asptr_meth,frag,Type...) + %typemap(varin,fragment=frag) Type { + Type *ptr = (Type *)0; + int res = asptr_meth($input, &ptr); + if (!SWIG_IsOK(res) || !ptr) { + %variable_fail((ptr ? res : SWIG_TypeError), "$type", "$name"); + } + $1 = *ptr; + if (SWIG_IsNewObj(res)) %delete(ptr); + } +%enddef + +#if defined(SWIG_DIRECTOR_TYPEMAPS) +/* directorout */ + +%define %ptr_directorout_typemap(asptr_meth,frag,Type...) + %typemap(directorargout,noblock=1,fragment=frag) Type *DIRECTOROUT ($*ltype temp) { + Type *swig_optr = 0; + int swig_ores = $input ? asptr_meth($input, &swig_optr) : 0; + if (!SWIG_IsOK(swig_ores) || !swig_optr) { + %dirout_fail((swig_optr ? swig_ores : SWIG_TypeError),"$type"); + } + temp = *swig_optr; + $result = &temp; + if (SWIG_IsNewObj(swig_ores)) %delete(swig_optr); + } + + %typemap(directorout,noblock=1,fragment=frag) Type { + Type *swig_optr = 0; + int swig_ores = asptr_meth($input, &swig_optr); + if (!SWIG_IsOK(swig_ores) || !swig_optr) { + %dirout_fail((swig_optr ? swig_ores : SWIG_TypeError),"$type"); + } + $result = *swig_optr; + if (SWIG_IsNewObj(swig_ores)) %delete(swig_optr); + } + + %typemap(directorout,noblock=1,fragment=frag,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) Type* { + Type *swig_optr = 0; + int swig_ores = asptr_meth($input, &swig_optr); + if (!SWIG_IsOK(swig_ores)) { + %dirout_fail(swig_ores,"$type"); + } + $result = swig_optr; + if (SWIG_IsNewObj(swig_ores)) { + swig_acquire_ownership(swig_optr); + } + } + %typemap(directorfree,noblock=1) Type* + { + if (director) { + director->swig_release_ownership(%as_voidptr($input)); + } + } + + %typemap(directorout,noblock=1,fragment=frag,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) Type& { + Type *swig_optr = 0; + int swig_ores = asptr_meth($input, &swig_optr); + if (!SWIG_IsOK(swig_ores)) { + %dirout_fail(swig_ores,"$type"); + } else { + if (!swig_optr) { + %dirout_nullref("$type"); + } + } + $result = swig_optr; + if (SWIG_IsNewObj(swig_ores)) { + swig_acquire_ownership(swig_optr); + } + } + %typemap(directorfree,noblock=1) Type& + { + if (director) { + director->swig_release_ownership(%as_voidptr($input)); + } + } + + + %typemap(directorout,fragment=frag) Type &DIRECTOROUT = Type + +%enddef + +#else + +#define %ptr_directorout_typemap(asptr_meth,frag,Type...) + +#endif /* SWIG_DIRECTOR_TYPEMAPS */ + +/* typecheck */ + +%define %ptr_typecheck_typemap(check,asptr_meth,frag,Type...) +%typemap(typecheck,noblock=1,precedence=check,fragment=frag) Type * { + int res = asptr_meth($input, (Type**)(0)); + $1 = SWIG_CheckState(res); +} + +%typemap(typecheck,noblock=1,precedence=check,fragment=frag) Type, const Type& { + int res = asptr_meth($input, (Type**)(0)); + $1 = SWIG_CheckState(res); +} +%enddef + + +/*--------------------------------------------------------------------- + * typemap definition for types with asptr method + *---------------------------------------------------------------------*/ + +%define %typemaps_asptr(CheckCode, AsPtrMeth, AsPtrFrag, Type...) + %fragment(SWIG_AsVal_frag(Type),"header",fragment=SWIG_AsPtr_frag(Type)) { + SWIGINTERNINLINE int + SWIG_AsVal(Type)(SWIG_Object obj, Type *val) + { + Type *v = (Type *)0; + int res = SWIG_AsPtr(Type)(obj, &v); + if (!SWIG_IsOK(res)) return res; + if (v) { + if (val) *val = *v; + if (SWIG_IsNewObj(res)) { + %delete(v); + res = SWIG_DelNewMask(res); + } + return res; + } + return SWIG_ERROR; + } + } + %ptr_in_typemap(%arg(AsPtrMeth), %arg(AsPtrFrag), Type); + %ptr_varin_typemap(%arg(AsPtrMeth), %arg(AsPtrFrag), Type); + %ptr_directorout_typemap(%arg(AsPtrMeth), %arg(AsPtrFrag), Type); + %ptr_typecheck_typemap(%arg(CheckCode), %arg(AsPtrMeth),%arg(AsPtrFrag), Type); + %ptr_input_typemap(%arg(CheckCode),%arg(AsPtrMeth),%arg(AsPtrFrag),Type); +%enddef + +/*--------------------------------------------------------------------- + * typemap definition for types with asptr/from methods + *---------------------------------------------------------------------*/ + +%define %typemaps_asptrfrom(CheckCode, AsPtrMeth, FromMeth, AsPtrFrag, FromFrag, Type...) + %typemaps_asptr(%arg(CheckCode), %arg(AsPtrMeth), %arg(AsPtrFrag), Type) + %typemaps_from(%arg(FromMeth), %arg(FromFrag), Type); + %value_output_typemap(%arg(FromMeth), %arg(FromFrag), Type); + %ptr_inout_typemap(Type); +%enddef + +/*--------------------------------------------------------------------- + * typemap definition for types with for 'normalized' asptr/from methods + *---------------------------------------------------------------------*/ + +%define %typemaps_asptrfromn(CheckCode, Type...) +%typemaps_asptrfrom(%arg(CheckCode), + %arg(SWIG_AsPtr(Type)), + %arg(SWIG_From(Type)), + %arg(SWIG_AsPtr_frag(Type)), + %arg(SWIG_From_frag(Type)), + Type); +%enddef diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/std_except.swg b/devtools/swigwin-1.3.34/Lib/typemaps/std_except.swg new file mode 100644 index 0000000..3ce479a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/std_except.swg @@ -0,0 +1,96 @@ +%include <typemaps/exception.swg> +%include <std/std_except.i> + +/* + Mark all of std exception classes as "exception classes" via + the "exceptionclass" feature. + + If needed, you can disable it by using %noexceptionclass. +*/ + +%define %std_exception_map(Exception, Code) + %exceptionclass Exception; +#if !defined(SWIG_STD_EXCEPTIONS_AS_CLASSES) + %typemap(throws,noblock=1) Exception { + SWIG_exception_fail(Code, $1.what()); + } + %ignore Exception; + struct Exception { + }; +#endif +%enddef + +namespace std { + %std_exception_map(bad_exception, SWIG_SystemError); + %std_exception_map(domain_error, SWIG_ValueError); + %std_exception_map(exception, SWIG_SystemError); + %std_exception_map(invalid_argument, SWIG_ValueError); + %std_exception_map(length_error, SWIG_IndexError); + %std_exception_map(logic_error, SWIG_RuntimeError); + %std_exception_map(out_of_range, SWIG_IndexError); + %std_exception_map(overflow_error, SWIG_OverflowError); + %std_exception_map(range_error, SWIG_OverflowError); + %std_exception_map(runtime_error, SWIG_RuntimeError); + %std_exception_map(underflow_error, SWIG_OverflowError); +} + +#if defined(SWIG_STD_EXCEPTIONS_AS_CLASSES) + +namespace std { + struct exception + { + virtual ~exception() throw(); + virtual const char* what() const throw(); + }; + + struct bad_exception : exception + { + }; + + struct logic_error : exception + { + logic_error(const string& msg); + }; + + struct domain_error : logic_error + { + domain_error(const string& msg); + }; + + struct invalid_argument : logic_error + { + invalid_argument(const string& msg); + }; + + struct length_error : logic_error + { + length_error(const string& msg); + }; + + struct out_of_range : logic_error + { + out_of_range(const string& msg); + }; + + struct runtime_error : exception + { + runtime_error(const string& msg); + }; + + struct range_error : runtime_error + { + range_error(const string& msg); + }; + + struct overflow_error : runtime_error + { + overflow_error(const string& msg); + }; + + struct underflow_error : runtime_error + { + underflow_error(const string& msg); + }; +} + +#endif diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/std_string.swg b/devtools/swigwin-1.3.34/Lib/typemaps/std_string.swg new file mode 100644 index 0000000..691bf2c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/std_string.swg @@ -0,0 +1,27 @@ +// +// String +// + + +#ifndef SWIG_STD_BASIC_STRING +#define SWIG_STD_STRING + +%include <typemaps/std_strings.swg> + +%{ +#include <string> +%} + +namespace std +{ + %naturalvar string; + class string; +} + +%typemaps_std_string(std::string, char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, %checkcode(STDSTRING)); + +#else + +%include <std/std_string.i> + +#endif diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/std_strings.swg b/devtools/swigwin-1.3.34/Lib/typemaps/std_strings.swg new file mode 100644 index 0000000..b7e8f6d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/std_strings.swg @@ -0,0 +1,82 @@ + +/* defining the String asptr/from methods */ + +%define %std_string_asptr(String, Char, SWIG_AsCharPtrAndSize, Frag) +%fragment(SWIG_AsPtr_frag(String),"header",fragment=Frag) { +SWIGINTERN int +SWIG_AsPtr_dec(String)(SWIG_Object obj, String **val) +{ + Char* buf = 0 ; size_t size = 0; int alloc = SWIG_OLDOBJ; + if (SWIG_IsOK((SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc)))) { + if (buf) { + if (val) *val = new String(buf, size - 1); + if (alloc == SWIG_NEWOBJ) %delete_array(buf); + return SWIG_NEWOBJ; + } else { + if (val) *val = 0; + return SWIG_OLDOBJ; + } + } else { + static int init = 0; + static swig_type_info* descriptor = 0; + if (!init) { + descriptor = SWIG_TypeQuery(#String " *"); + init = 1; + } + if (descriptor) { + String *vptr; + int res = SWIG_ConvertPtr(obj, (void**)&vptr, descriptor, 0); + if (SWIG_IsOK(res) && val) *val = vptr; + return res; + } + } + return SWIG_ERROR; +} +} +%enddef + +%define %std_string_from(String, SWIG_FromCharPtrAndSize, Frag) +%fragment(SWIG_From_frag(String),"header",fragment=Frag) { +SWIGINTERNINLINE SWIG_Object +SWIG_From_dec(String)(const String& s) +{ + if (s.size()) { + return SWIG_FromCharPtrAndSize(s.data(), s.size()); + } else { + return SWIG_FromCharPtrAndSize(s.c_str(), 0); + } +} +} +%enddef + +%define %std_string_asval(String) +%fragment(SWIG_AsVal_frag(String),"header", fragment=SWIG_AsPtr_frag(String)) { +SWIGINTERN int +SWIG_AsVal_dec(String)(SWIG_Object obj, String *val) +{ + String* v = (String *) 0; + int res = SWIG_AsPtr(String)(obj, &v); + if (!SWIG_IsOK(res)) return res; + if (v) { + if (val) *val = *v; + if (SWIG_IsNewObj(res)) { + %delete(v); + res = SWIG_DelNewMask(res); + } + return res; + } + return SWIG_ERROR; +} +} +%enddef + + +%define %typemaps_std_string(String, Char, AsPtrMethod, FromMethod, CheckCode) + +%std_string_asptr(String, Char, AsPtrMethod, #AsPtrMethod) +%std_string_asval(String) +%std_string_from(String, FromMethod, #FromMethod) + +%typemaps_asptrfromn(%arg(CheckCode), String); + +%enddef diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/std_wstring.swg b/devtools/swigwin-1.3.34/Lib/typemaps/std_wstring.swg new file mode 100644 index 0000000..670685f --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/std_wstring.swg @@ -0,0 +1,26 @@ +%include <typemaps/wstring.swg> + +#ifndef SWIG_STD_BASIC_STRING +#define SWIG_STD_WSTRING + +%include <typemaps/std_strings.swg> + +%{ +#include <cwchar> +#include <string> +%} + +namespace std +{ + %naturalvar wstring; + class wstring; +} + +%typemaps_std_string(std::wstring, wchar_t, SWIG_AsWCharPtrAndSize, SWIG_FromWCharPtrAndSize, %checkcode(STDUNISTRING)); + + +#else + +%include <std/std_wstring.i> + +#endif diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/string.swg b/devtools/swigwin-1.3.34/Lib/typemaps/string.swg new file mode 100644 index 0000000..279ee2a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/string.swg @@ -0,0 +1,24 @@ +%ensure_fragment(SWIG_AsCharPtrAndSize) +%ensure_fragment(SWIG_FromCharPtrAndSize) + +%types(char *); + +%fragment("SWIG_pchar_descriptor","header") { +SWIGINTERN swig_type_info* +SWIG_pchar_descriptor(void) +{ + static int init = 0; + static swig_type_info* info = 0; + if (!init) { + info = SWIG_TypeQuery("_p_char"); + init = 1; + } + return info; +} +} + + +%include <typemaps/strings.swg> +%typemaps_string(%checkcode(STRING), %checkcode(CHAR), + char, Char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, strlen, + "<limits.h>", CHAR_MIN, CHAR_MAX) diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/strings.swg b/devtools/swigwin-1.3.34/Lib/typemaps/strings.swg new file mode 100644 index 0000000..04fa28f --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/strings.swg @@ -0,0 +1,594 @@ +// +// Use the macro SWIG_PRESERVE_CARRAY_SIZE if you prefer to preserve +// the size of char arrays, ie +// ------------------------------------------ +// C Side => Language Side +// ------------------------------------------ +// char name[5] = "hola" => 'hola\0' +// +// the default behaviour is +// +// char name[5] = "hola" => 'hola' +// +// +//#define SWIG_PRESERVE_CARRAY_SIZE + +/* ------------------------------------------------------------ + * String typemaps for type Char (char or wchar_t) + * ------------------------------------------------------------ */ + +%define %_typemap_string(StringCode, + Char, + SWIG_AsCharPtrAndSize, + SWIG_FromCharPtrAndSize, + SWIG_CharPtrLen, + SWIG_AsCharPtr, + SWIG_FromCharPtr, + SWIG_AsCharArray) + +/* in */ + +%typemap(in,noblock=1,fragment=#SWIG_AsCharPtr) + Char * (int res, Char *buf = 0, int alloc = 0), + const Char * (int res, Char *buf = 0, int alloc = 0) { + res = SWIG_AsCharPtr($input, &buf, &alloc); + if (!SWIG_IsOK(res)) { + %argument_fail(res,"$type",$symname, $argnum); + } + $1 = %reinterpret_cast(buf, $1_ltype); +} +%typemap(freearg,noblock=1,match="in") Char *, const Char * { + if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum); +} + +%typemap(in,noblock=1,fragment=#SWIG_AsCharPtr) Char const*& (int res, Char *buf = 0, int alloc = 0) { + res = SWIG_AsCharPtr($input, &buf, &alloc); + if (!SWIG_IsOK(res)) { + %argument_fail(res,"$type",$symname, $argnum); + } + $1 = &buf; +} +%typemap(freearg, noblock=1,match="in") Char const*& { + if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum); +} + +/* out */ + +%typemap(out,noblock=1,fragment=#SWIG_FromCharPtr) Char *, const Char* { + %set_output(SWIG_FromCharPtr((const Char *)$1)); +} + + +%typemap(out,noblock=1,fragment=#SWIG_FromCharPtr) Char const*& { + %set_output(SWIG_FromCharPtr(*$1)); +} + +%typemap(newfree,noblock=1) Char * { + %delete_array($1); +} + +/* varin */ + +%typemap(varin,fragment=#SWIG_AsCharPtrAndSize) Char * { + Char *cptr = 0; size_t csize = 0; int alloc = SWIG_NEWOBJ; + int res = SWIG_AsCharPtrAndSize($input, &cptr, &csize, &alloc); + if (!SWIG_IsOK(res)) { + %variable_fail(res,"$type","$name"); + } + if ($1) %delete_array($1); + if (alloc == SWIG_NEWOBJ) { + $1 = cptr; + } else { + $1 = csize ? ($1_type)%new_copy_array(cptr, csize, Char) : 0; + } +} + +%typemap(varin,fragment=#SWIG_AsCharPtrAndSize,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const Char * { + Char *cptr = 0; size_t csize = 0; int alloc = SWIG_NEWOBJ; + int res = SWIG_AsCharPtrAndSize($input, &cptr, &csize, &alloc); + if (!SWIG_IsOK(res)) { + %variable_fail(res, "$type", "$name"); + } + if (alloc == SWIG_NEWOBJ) { + $1 = cptr; + } else { + $1 = csize ? ($1_type)%new_copy_array(cptr, csize, Char) : 0; + } +} + +/* varout */ + +%typemap(varout,noblock=1,fragment=#SWIG_FromCharPtr) Char*, const Char* { + %set_varoutput(SWIG_FromCharPtr($1)); +} + +/* memberin */ + +%typemap(memberin,noblock=1) Char * { + if ($1) %delete_array($1); + if ($input) { + size_t size = SWIG_CharPtrLen(%reinterpret_cast($input, const Char *)) + 1; + $1 = ($1_type)%new_copy_array(%reinterpret_cast($input, const Char *), size, Char); + } else { + $1 = 0; + } +} + +%typemap(memberin,noblock=1,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const Char * { + if ($input) { + size_t size = SWIG_CharPtrLen(%reinterpret_cast(%reinterpret_cast($input, const Char *), const Char *)) + 1; + $1 = ($1_type)%new_copy_array($input, size, Char); + } else { + $1 = 0; + } +} + +/* globalin */ + +%typemap(globalin,noblock=1) Char * { + if ($1) %delete_array($1); + if ($input) { + size_t size = SWIG_CharPtrLen(%reinterpret_cast(%reinterpret_cast($input, const Char *), const Char *)) + 1; + $1 = ($1_type)%new_copy_array($input, size, Char); + } else { + $1 = 0; + } +} + +%typemap(globalin,noblock=1,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const Char * { + if ($input) { + size_t size = SWIG_CharPtrLen($input) + 1; + $1 = ($1_type)%new_copy_array($input, size, Char); + } else { + $1 = 0; + } +} + +/* constant */ + +%typemap(constcode,noblock=1,fragment=#SWIG_FromCharPtr) + Char *, Char const*, Char * const, Char const* const { + %set_constant("$symname", SWIG_FromCharPtr($value)); +} + + +#if defined(SWIG_DIRECTOR_TYPEMAPS) + +/* directorin */ + +%typemap(directorin,noblock=1,fragment=#SWIG_FromCharPtr) + Char *, Char const*, Char *const, Char const *const, + Char const *&, Char *const &, Char const *const & { + $input = SWIG_FromCharPtr((const Char *)$1_name); +} + + +/* directorout */ + +%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) + Char * (int res, Char* buf = 0, int alloc = SWIG_NEWOBJ) { + res = SWIG_AsCharPtr($input, &buf, &alloc); + if (!SWIG_IsOK(res)) { + %dirout_fail(res, "$type"); + } + if (alloc == SWIG_NEWOBJ) { + swig_acquire_ownership_array(buf); + } + $result = %reinterpret_cast(buf, $1_ltype); +} +%typemap(directorfree,noblock=1) Char * +{ + if (director) { + director->swig_release_ownership(%as_voidptr($input)); + } +} + + +%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) + Char * const& (int res, Char* buf = 0, int alloc = SWIG_NEWOBJ), + Char const* const& (int res, Char* buf = 0, int alloc = SWIG_NEWOBJ) { + res = SWIG_AsCharPtr($input, &buf, &alloc); + if (!SWIG_IsOK(res)) { + %dirout_fail(res, "$type"); + } + static $*1_ltype tmp = buf; + $result = &tmp; + if (alloc == SWIG_NEWOBJ) { + swig_acquire_ownership_array(buf); + } +} +%typemap(directorfree,noblock=1) + Char * const&, Char const* const& { + if (director) { + director->swig_release_ownership(%as_voidptr(*$input)); + } +} + +#endif /* SWIG_DIRECTOR_TYPEMAPS */ + +/* typecheck */ + +%typemap(typecheck,noblock=1,precedence=StringCode, + fragment=#SWIG_AsCharPtr) Char *, Char const*& { + int res = SWIG_AsCharPtr($input, 0, 0); + $1 = SWIG_CheckState(res); +} + + +/* throws */ + +%typemap(throws,noblock=1,fragment=#SWIG_FromCharPtr) Char * { + %raise(SWIG_FromCharPtr($1), "$type", 0); +} + + +/* ------------------------------------------------------------ + * Unknown size const Character array Char[ANY] handling + * ------------------------------------------------------------ */ + +%apply Char* { Char [] }; +%apply const Char* { const Char [] }; + +%typemap(varin,noblock=1,warning="462:Unable to set variable of type Char []") Char [] +{ + %variable_fail(SWIG_AttributeError, "$type", "read-only $name"); +} + + +/* ------------------------------------------------------------ + * Fixed size Character array Char[ANY] handling + * ------------------------------------------------------------ */ + +/* memberin and globalin typemaps */ + +%typemap(memberin,noblock=1) Char [ANY] +{ + if ($input) memcpy($1,$input,$1_dim0*sizeof(Char)); + else memset($1,0,$1_dim0*sizeof(Char)); +} + +%typemap(globalin,noblock=1) Char [ANY] +{ + if ($input) memcpy($1,$input,$1_dim0*sizeof(Char)); + else memset($1,0,$1_dim0*sizeof(Char)); +} + +/* in */ + +%typemap(in,noblock=1,fragment=#SWIG_AsCharArray) + Char [ANY] (Char temp[$1_dim0], int res), + const Char [ANY](Char temp[$1_dim0], int res) +{ + res = SWIG_AsCharArray($input, temp, $1_dim0); + if (!SWIG_IsOK(res)) { + %argument_fail(res,"$type",$symname, $argnum); + } + $1 = %reinterpret_cast(temp, $1_ltype); +} +%typemap(freearg) Char [ANY], const Char [ANY] ""; + +%typemap(in,noblock=1,fragment=#SWIG_AsCharArray) const Char (&)[ANY] (Char temp[$1_dim0], int res) +{ + res = SWIG_AsCharArray($input, temp, $1_dim0); + if (!SWIG_IsOK(res)) { + %argument_fail(res,"$type",$symname, $argnum); + } + $1 = &temp; +} +%typemap(freearg) const Char (&)[ANY] ""; + +%typemap(out,fragment=#SWIG_FromCharPtrAndSize) + Char [ANY], const Char[ANY] +{ + size_t size = $1_dim0; +%#ifndef SWIG_PRESERVE_CARRAY_SIZE + while (size && ($1[size - 1] == '\0')) --size; +%#endif + %set_output(SWIG_FromCharPtrAndSize($1, size)); +} + +/* varin */ + +%typemap(varin,fragment=#SWIG_AsCharArray) Char [ANY] +{ + int res = SWIG_AsCharArray($input, $1, $1_dim0); + if (!SWIG_IsOK(res)) { + %variable_fail(res, "$type", "$name"); + } +} + +/* varout */ + +%typemap(varout,noblock=1,fragment=#SWIG_FromCharPtrAndSize) + Char [ANY], const Char [ANY] { + size_t size = $1_dim0; +%#ifndef SWIG_PRESERVE_CARRAY_SIZE + while (size && ($1[size - 1] == '\0')) --size; +%#endif + %set_varoutput(SWIG_FromCharPtrAndSize($1, size)); +} + +/* constant */ + +%typemap(constcode,fragment=#SWIG_FromCharPtrAndSize) + Char [ANY], const Char [ANY] +{ + size_t size = $value_dim0; +%#ifndef SWIG_PRESERVE_CARRAY_SIZE + while (size && ($value[size - 1] == '\0')) --size; +%#endif + %set_constant("$symname", SWIG_FromCharPtrAndSize($value,size)); +} + + +#if defined(SWIG_DIRECTOR_TYPEMAPS) + +/* directorin */ +%typemap(directorin,fragment=#SWIG_FromCharPtrAndSize) + Char [ANY], const Char [ANY] +{ + size_t size = $1_dim0; +%#ifndef SWIG_PRESERVE_CARRAY_SIZE + while (size && ($1_name[size - 1] == '\0')) --size; +%#endif + $input = SWIG_FromCharPtrAndSize($1_name, size); +} + +/* directorout */ + +%typemap(directorout,noblock=1,fragment=#SWIG_AsCharArray) + Char [ANY] (Char temp[$result_dim0]), + const Char [ANY] (Char temp[$result_dim0], int res) +{ + res = SWIG_AsCharArray($input, temp, $result_dim0); + if (!SWIG_IsOK(res)) { + %dirout_fail(res, "$type"); + } + $result = temp; +} + +#endif /* SWIG_DIRECTOR_TYPEMAPS */ + +/* typecheck */ + +%typemap(typecheck,noblock=1,precedence=StringCode, + fragment=#SWIG_AsCharArray) + Char [ANY], const Char[ANY] { + int res = SWIG_AsCharArray($input, (Char *)0, 0); + $1 = SWIG_CheckState(res); +} + + +/* throws */ + +%typemap(throws,fragment=#SWIG_FromCharPtrAndSize) + Char [ANY], const Char[ANY] +{ + size_t size = $1_dim0; +%#ifndef SWIG_PRESERVE_CARRAY_SIZE + while (size && ($1[size - 1] == '\0')) --size; +%#endif + %raise(SWIG_FromCharPtrAndSize($1, size), "$type", 0); +} + +/* ------------------------------------------------------------------- + * --- Really fix size Char arrays, including '\0'chars at the end --- + * ------------------------------------------------------------------- */ + +%typemap(varout,noblock=1,fragment=#SWIG_FromCharPtrAndSize) + Char FIXSIZE[ANY], const Char FIXSIZE[ANY] +{ + %set_varoutput(SWIG_FromCharPtrAndSize($1, $1_dim0)); +} + +%typemap(out,noblock=1,fragment=#SWIG_FromCharPtrAndSize) + Char FIXSIZE[ANY], const Char FIXSIZE[ANY] +{ + %set_output(SWIG_FromCharPtrAndSize($1, $1_dim0)); +} + +#if defined(SWIG_DIRECTOR_TYPEMAPS) + +%typemap(directorin,noblock=1,fragment=#SWIG_FromCharPtrAndSize) + Char FIXSIZE[ANY], const Char FIXSIZE[ANY] +{ + $input = SWIG_FromCharPtrAndSize($1_name, $1_dim0); +} + +#endif /* SWIG_DIRECTOR_TYPEMAPS */ + +%typemap(throws,noblock=1,fragment=#SWIG_FromCharPtrAndSize) + Char FIXSIZE[ANY], const Char FIXSIZE[ANY] { + %raise(SWIG_FromCharPtrAndSize($1, $1_dim0), "$type", 0); +} + +/* ------------------------------------------------------------ + * --- String & length --- + * ------------------------------------------------------------ */ + +/* Here len doesn't include the '0' terminator */ +%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) + (Char *STRING, size_t LENGTH) (int res, Char *buf = 0, size_t size = 0, int alloc = 0), + (const Char *STRING, size_t LENGTH) (int res, Char *buf = 0, size_t size = 0, int alloc = 0) +{ + res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc); + if (!SWIG_IsOK(res)) { + %argument_fail(res,"$type",$symname, $argnum); + } + $1 = %reinterpret_cast(buf, $1_ltype); + $2 = %numeric_cast(size - 1, $2_ltype); +} +%typemap(freearg,noblock=1,match="in") (Char *STRING, size_t LENGTH) { + if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum); +} +/* old 'int' form */ +%typemap(in) (Char *STRING, int LENGTH) = (Char *STRING, size_t LENGTH); +%typemap(freearg) (Char *STRING, int LENGTH) = (Char *STRING, size_t LENGTH); + + +/* Here size includes the '0' terminator */ +%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) + (Char *STRING, size_t SIZE) (int res, Char *buf = 0, size_t size = 0, int alloc = 0), + (const Char *STRING, size_t SIZE) (int res, Char *buf = 0, size_t size = 0, int alloc = 0) +{ + res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc); + if (!SWIG_IsOK(res)) { + %argument_fail(res,"$type",$symname, $argnum); + } + $1 = %reinterpret_cast(buf, $1_ltype); + $2 = %numeric_cast(size, $2_ltype); +} +%typemap(freearg,noblock=1,match="in") (Char *STRING, size_t SIZE) { + if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum); +} +/* old 'int' form */ +%typemap(in) (Char *STRING, int SIZE) = (Char *STRING, size_t SIZE); +%typemap(freearg) (Char *STRING, int SIZE) = (Char *STRING, size_t SIZE); + + +/* reverse order versions */ + +/* Here len doesn't include the '0' terminator */ +%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) + (size_t LENGTH, Char *STRING) (int res, Char *buf = 0, size_t size = 0, int alloc = 0), + (size_t LENGHT, const Char *STRING) (int res, Char *buf = 0, size_t size = 0, int alloc = 0) +{ + res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc); + if (!SWIG_IsOK(res)) { + %argument_fail(res,"$type",$symname, $argnum); + } + $2 = %reinterpret_cast(buf, $2_ltype) ; + $1 = %numeric_cast(size - 1, $1_ltype) ; +} +%typemap(freearg, noblock=1, match="in") (size_t LENGTH, Char *STRING) { + if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum); +} +/* old 'int' form */ +%typemap(in) (int LENGTH, Char *STRING) = (size_t LENGTH, Char *STRING); +%typemap(freearg) (int LENGTH, Char *STRING) = (size_t LENGTH, Char *STRING); + +/* Here size includes the '0' terminator */ +%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize) + (size_t SIZE, Char *STRING) (int res, Char *buf = 0, size_t size = 0, int alloc = 0), + (size_t SIZE, const Char *STRING) (int res, Char *buf = 0, size_t size = 0, int alloc = 0) +{ + res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type",$symname, $argnum); + } + $2 = %reinterpret_cast(buf, $2_ltype) ; + $1 = %numeric_cast(size, $1_ltype) ; +} +%typemap(freearg, noblock=1, match="in") (size_t SIZE, Char *STRING) { + if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum); +} +/* old 'int' form */ +%typemap(in) (int SIZE, Char *STRING) = (size_t SIZE, Char *STRING); +%typemap(freearg) (int SIZE, Char *STRING) = (size_t SIZE, Char *STRING); + + +%enddef + + +/* ------------------------------------------------------------ + * --- String fragment methods --- + * ------------------------------------------------------------ */ + + +%define %typemaps_string(StringCode, CharCode, + Char, CharName, + SWIG_AsCharPtrAndSize, + SWIG_FromCharPtrAndSize, + SWIG_CharPtrLen, + FragLimits, CHAR_MIN, CHAR_MAX) + +%fragment("SWIG_From"#CharName"Ptr","header",fragment=#SWIG_FromCharPtrAndSize) { +SWIGINTERNINLINE SWIG_Object +SWIG_From##CharName##Ptr(const Char *cptr) +{ + return SWIG_FromCharPtrAndSize(cptr, (cptr ? SWIG_CharPtrLen(cptr) : 0)); +} +} + +%fragment("SWIG_From"#CharName"Array","header",fragment=#SWIG_FromCharPtrAndSize) { +SWIGINTERNINLINE SWIG_Object +SWIG_From##CharName##Array(const Char *cptr, size_t size) +{ + return SWIG_FromCharPtrAndSize(cptr, size); +} +} + +%fragment("SWIG_As" #CharName "Ptr","header",fragment=#SWIG_AsCharPtrAndSize) { +%define_as(SWIG_As##CharName##Ptr(obj, val, alloc), SWIG_AsCharPtrAndSize(obj, val, NULL, alloc)) +} + +%fragment("SWIG_As" #CharName "Array","header",fragment=#SWIG_AsCharPtrAndSize) { +SWIGINTERN int +SWIG_As##CharName##Array(SWIG_Object obj, Char *val, size_t size) +{ + Char* cptr = 0; size_t csize = 0; int alloc = SWIG_OLDOBJ; + int res = SWIG_AsCharPtrAndSize(obj, &cptr, &csize, &alloc); + if (SWIG_IsOK(res)) { + if ((csize == size + 1) && cptr && !(cptr[csize-1])) --csize; + if (csize <= size) { + if (val) { + if (csize) memcpy(val, cptr, csize*sizeof(Char)); + if (csize < size) memset(val + csize, 0, (size - csize)*sizeof(Char)); + } + if (alloc == SWIG_NEWOBJ) { + %delete_array(cptr); + res = SWIG_DelNewMask(res); + } + return res; + } + if (alloc == SWIG_NEWOBJ) %delete_array(cptr); + } + return SWIG_TypeError; +} +} + +/* Char */ + +%fragment(SWIG_From_frag(Char),"header",fragment=#SWIG_FromCharPtrAndSize) { +SWIGINTERNINLINE SWIG_Object +SWIG_From_dec(Char)(Char c) +{ + return SWIG_FromCharPtrAndSize(&c,1); +} +} + +%fragment(SWIG_AsVal_frag(Char),"header", + fragment="SWIG_As"#CharName"Array", + fragment=FragLimits, + fragment=SWIG_AsVal_frag(long)) { +SWIGINTERN int +SWIG_AsVal_dec(Char)(SWIG_Object obj, Char *val) +{ + int res = SWIG_As##CharName##Array(obj, val, 1); + if (!SWIG_IsOK(res)) { + long v; + res = SWIG_AddCast(SWIG_AsVal(long)(obj, &v)); + if (SWIG_IsOK(res)) { + if ((CHAR_MIN <= v) && (v <= CHAR_MAX)) { + if (val) *val = %numeric_cast(v, Char); + } else { + res = SWIG_OverflowError; + } + } + } + return res; +} +} + +%typemaps_asvalfromn(CharCode, Char); + +%_typemap_string(StringCode, + Char, + SWIG_AsCharPtrAndSize, + SWIG_FromCharPtrAndSize, + SWIG_CharPtrLen, + SWIG_As##CharName##Ptr, + SWIG_From##CharName##Ptr, + SWIG_As##CharName##Array) + +%enddef diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/swigmacros.swg b/devtools/swigwin-1.3.34/Lib/typemaps/swigmacros.swg new file mode 100644 index 0000000..e00a69b --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/swigmacros.swg @@ -0,0 +1,245 @@ +/* ----------------------------------------------------------------------------- + * SWIG API. Portion only visible from SWIG + * ----------------------------------------------------------------------------- */ +/* + This file implements the internal macros of the 'SWIG API', which + are useful to implement all the SWIG target languges. + + Basic preprocessor macros: + -------------------------- + + %arg(Arg) Safe argument wrap + %str(Arg) Stringtify the argument + %begin_block Begin a execution block + %end_block End a execution block + %block(Block) Execute Block as a excecution block + %define_as(Def, Val) Define 'Def' as 'Val', expanding Def and Val first + %ifcplusplus(V1, V2) if C++ Mode; then V1; else V2; fi + + + Casting Operations: + ------------------- + + Swig provides the following casting macros, which implement the + corresponding C++ casting operations: + + %const_cast(a, Type) const_cast<Type >(a) + %static_cast(a, Type) static_cast<Type >(a) + %reinterpret_cast(a, Type) reinterpret_cast<Type >(a) + %numeric_cast(a, Type) static_cast<Type >(a) + %as_voidptr(a) const_cast<void *>(static_cast<const void *>(a)) + %as_voidptrptr(a) reinterpret_cast<void **>(a) + + or their C unsafe versions. In C++ we use the safe version unless + SWIG_NO_CPLUSPLUS_CAST is defined (usually via the -nocppcast swig flag). + + + Memory allocation: + ------------------ + + These allocation/freeing macros are safe to use in C or C++ and + dispatch the proper new/delete/delete[] or free/malloc calls as + needed. + + %new_instance(Type) Allocate a new instance of given Type + %new_copy(value,Type) Allocate and initialize a new instance with 'value' + %new_array(size,Type) Allocate a new array with given size and Type + %new_copy_array(cptr,size,Type) Allocate and initialize a new array from 'cptr' + %delete(cptr) Delete an instance + %delete_array(cptr) Delete an array + + + Auxiliary loop macros: + ---------------------- + + %formacro(Macro, Args...) or %formacro_1(Macro, Args...) + for i in Args + do + Macro($i) + done + + %formacro_2(Macro2, Args...) + for i,j in Args + do + Macro2($i, $j) + done + + + Flags and conditional macros: + ----------------------------- + + %mark_flag(flag) + flag := True + + %evalif(flag,expr) + if flag; then + expr + fi + + %evalif_2(flag1 flag2,expr) + if flag1 and flag2; then + expr + fi + + +*/ +/* ----------------------------------------------------------------------------- + * Basic preprocessor macros + * ----------------------------------------------------------------------------- */ + +#define %arg(Arg...) Arg +#define %str(Arg) `Arg` +#ifndef %begin_block +# define %begin_block do { +#endif +#ifndef %end_block +# define %end_block } while(0) +#endif +#define %block(Block...) %begin_block Block; %end_block + +/* define a new macro */ +%define %define_as(Def, Val...)%#define Def Val %enddef + +/* include C++ or else value */ +%define %ifcplusplus(cppval, nocppval) +#ifdef __cplusplus +cppval +#else +nocppval +#endif +%enddef + +/* insert the SWIGVERSION in the interface and the wrapper code */ +#if SWIG_VERSION +%insert("header") { +%define_as(SWIGVERSION, SWIG_VERSION) +%#define SWIG_VERSION SWIGVERSION +} +#endif + + + +/* ----------------------------------------------------------------------------- + * Casting operators + * ----------------------------------------------------------------------------- */ + +#if defined(SWIG_NO_CPLUSPLUS_CAST) +/* Disable 'modern' cplusplus casting operators */ +# if defined(SWIG_CPLUSPLUS_CAST) +# undef SWIG_CPLUSPLUS_CAST +# endif +#endif + +#if defined(__cplusplus) && defined(SWIG_CPLUSPLUS_CAST) +# define %const_cast(a,Type...) const_cast< Type >(a) +# define %static_cast(a,Type...) static_cast< Type >(a) +# define %reinterpret_cast(a,Type...) reinterpret_cast< Type >(a) +# define %numeric_cast(a,Type...) static_cast< Type >(a) +#else /* C case */ +# define %const_cast(a,Type...) (Type)(a) +# define %static_cast(a,Type...) (Type)(a) +# define %reinterpret_cast(a,Type...) (Type)(a) +# define %numeric_cast(a,Type...) (Type)(a) +#endif /* __cplusplus */ + + +#define %as_voidptr(a) SWIG_as_voidptr(a) +#define %as_voidptrptr(a) SWIG_as_voidptrptr(a) + +%insert("header") { +%define_as(SWIG_as_voidptr(a), %const_cast(%static_cast(a,const void *), void *)) +%define_as(SWIG_as_voidptrptr(a), ((void)%as_voidptr(*a),%reinterpret_cast(a, void**))) +} + + +/* ----------------------------------------------------------------------------- + * Allocating/freeing elements + * ----------------------------------------------------------------------------- */ + +#if defined(__cplusplus) +# define %new_instance(Type...) (new Type) +# define %new_copy(val,Type...) (new Type(%static_cast(val, const Type&))) +# define %new_array(size,Type...) (new Type[size]) +# define %new_copy_array(ptr,size,Type...) %reinterpret_cast(memcpy(%new_array(size,Type), ptr, sizeof(Type)*(size)), Type*) +# define %delete(cptr) delete cptr +# define %delete_array(cptr) delete[] cptr +#else /* C case */ +# define %new_instance(Type...) (Type *)malloc(sizeof(Type)) +# define %new_copy(val,Type...) (Type *)memcpy(%new_instance(Type),&val,sizeof(Type)) +# define %new_array(size,Type...) (Type *)malloc((size)*sizeof(Type)) +# define %new_copy_array(ptr,size,Type...) (Type *)memcpy(%new_array(size,Type), ptr, sizeof(Type)*(size)) +# define %delete(cptr) free((char*)cptr) +# define %delete_array(cptr) free((char*)cptr) +#endif /* __cplusplus */ + +/* ----------------------------------------------------------------------------- + * Swig names and mangling + * ----------------------------------------------------------------------------- */ + +#define %mangle(Type...) #@Type +#define %descriptor(Type...) SWIGTYPE_ ## #@Type +#define %string_name(Name) "SWIG_" %str(Name) +#define %symbol_name(Name, Type...) SWIG_ ## Name ## _ #@Type +#define %checkcode(Code) SWIG_TYPECHECK_ ## Code + + +/* ----------------------------------------------------------------------------- + * Auxiliar loop macros + * ----------------------------------------------------------------------------- */ + + +/* for loop for macro with one argument */ +%define %_formacro_1(macro, arg1,...)macro(arg1) +#if #__VA_ARGS__ != "__fordone__" +%_formacro_1(macro, __VA_ARGS__) +#endif +%enddef + +/* for loop for macro with one argument */ +%define %formacro_1(macro,...)%_formacro_1(macro,__VA_ARGS__,__fordone__)%enddef +%define %formacro(macro,...)%_formacro_1(macro,__VA_ARGS__,__fordone__)%enddef + +/* for loop for macro with two arguments */ +%define %_formacro_2(macro, arg1, arg2, ...)macro(arg1, arg2) +#if #__VA_ARGS__ != "__fordone__" +%_formacro_2(macro, __VA_ARGS__) +#endif +%enddef + +/* for loop for macro with two arguments */ +%define %formacro_2(macro,...)%_formacro_2(macro, __VA_ARGS__, __fordone__)%enddef + +/* ----------------------------------------------------------------------------- + * Swig flags + * ----------------------------------------------------------------------------- */ + +/* + mark a flag, ie, define a macro name but ignore it in + the interface. + + the flag can be later used with %evalif +*/ + +%define %mark_flag(x) %define x 1 %enddef %enddef + + +/* + %evalif and %evalif_2 are use to evaluate or process + an expression if the given predicate is 'true' (1). +*/ +%define %_evalif(_x,_expr) +#if _x == 1 +_expr +#endif +%enddef + +%define %_evalif_2(_x,_y,_expr) +#if _x == 1 && _y == 1 +_expr +#endif +%enddef + +%define %evalif(_x,_expr...) %_evalif(%arg(_x),%arg(_expr)) %enddef + +%define %evalif_2(_x,_y,_expr...) %_evalif_2(%arg(_x),%arg(_y),%arg(_expr)) %enddef + diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/swigobject.swg b/devtools/swigwin-1.3.34/Lib/typemaps/swigobject.swg new file mode 100644 index 0000000..e89b630 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/swigobject.swg @@ -0,0 +1,37 @@ +/* ------------------------------------------------------------ + * Language Object * - Just pass straight through unmodified + * ------------------------------------------------------------ */ + +%typemap(in) SWIG_Object "$1 = $input;"; + +%typemap(in,noblock=1) SWIG_Object const & ($*ltype temp) +{ + temp = %static_cast($input, $*ltype); + $1 = &temp; +} + +%typemap(out,noblock=1) SWIG_Object { + %set_output($1); +} + +%typemap(out,noblock=1) SWIG_Object const & { + %set_output(*$1); +} + +%typecheck(SWIG_TYPECHECK_SWIGOBJECT) SWIG_Object "$1 = ($input != 0);"; + +%typemap(throws,noblock=1) SWIG_Object { + %raise($1, "$type", 0); +} + +%typemap(constcode,noblock=1) SWIG_Object { + %set_constant("$symname", $value); +} + +#if defined(SWIG_DIRECTOR_TYPEMAPS) + +%typemap(directorin) SWIG_Object "$input = $1_name"; +%typemap(directorout) SWIG_Object "$result = $input;"; + +#endif /* SWIG_DIRECTOR_TYPEMAPS */ + diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/swigtype.swg b/devtools/swigwin-1.3.34/Lib/typemaps/swigtype.swg new file mode 100644 index 0000000..4d3718b --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/swigtype.swg @@ -0,0 +1,604 @@ +/* ----------------------------------------------------------------------------- + * --- Input arguments --- + * ----------------------------------------------------------------------------- */ +/* Pointers and arrays */ +%typemap(in, noblock=1) SWIGTYPE *(void *argp = 0, int res = 0) { + res = SWIG_ConvertPtr($input, &argp,$descriptor, $disown | %convertptr_flags); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + $1 = %reinterpret_cast(argp, $ltype); +} +%typemap(freearg) SWIGTYPE * ""; + +%typemap(in, noblock=1) SWIGTYPE [] (void *argp = 0, int res = 0) { + res = SWIG_ConvertPtr($input, &argp,$descriptor, $disown | %convertptr_flags); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + $1 = %reinterpret_cast(argp, $ltype); +} +%typemap(freearg) SWIGTYPE [] ""; + + +%typemap(in, noblock=1) SWIGTYPE* const& (void *argp = 0, int res = 0, $*ltype temp) { + res = SWIG_ConvertPtr($input, &argp, $*descriptor, $disown | %convertptr_flags); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$*ltype", $symname, $argnum); + } + temp = %reinterpret_cast(argp, $*ltype); + $1 = &temp; +} +%typemap(freearg) SWIGTYPE* const& ""; + + +/* Reference */ +%typemap(in, noblock=1) SWIGTYPE & (void *argp = 0, int res = 0) { + res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (!argp) { %argument_nullref("$type", $symname, $argnum); } + $1 = %reinterpret_cast(argp, $ltype); +} +%typemap(freearg) SWIGTYPE & ""; + +#if defined(__cplusplus) && defined(%implicitconv_flag) +%typemap(in,noblock=1,implicitconv=1) const SWIGTYPE & (void *argp = 0, int res = 0) { + res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags | %implicitconv_flag); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (!argp) { %argument_nullref("$type", $symname, $argnum); } + $1 = %reinterpret_cast(argp, $ltype); +} +%typemap(freearg,noblock=1,match="in",implicitconv=1) const SWIGTYPE & +{ + if (SWIG_IsNewObj(res$argnum)) %delete($1); +} +#else +%typemap(in,noblock=1) const SWIGTYPE & (void *argp, int res = 0) { + res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (!argp) { %argument_nullref("$type", $symname, $argnum); } + $1 = %reinterpret_cast(argp, $ltype); +} +#endif + +/* By value */ +#if defined(__cplusplus) && defined(%implicitconv_flag) +%typemap(in,implicitconv=1) SWIGTYPE (void *argp, int res = 0) { + res = SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags | %implicitconv_flag); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (!argp) { + %argument_nullref("$type", $symname, $argnum); + } else { + $<ype temp = %reinterpret_cast(argp, $<ype); + $1 = *temp; + if (SWIG_IsNewObj(res)) %delete(temp); + } +} +#else +%typemap(in) SWIGTYPE (void *argp, int res = 0) { + res = SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } + if (!argp) { + %argument_nullref("$type", $symname, $argnum); + } else { + $1 = *(%reinterpret_cast(argp, $<ype)); + } +} +#endif + + +/* ----------------------------------------------------------------------------- + * --- Output arguments --- + * ----------------------------------------------------------------------------- */ + +/* Pointers, references */ +%typemap(out,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE[] { + %set_output(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, $owner | %newpointer_flags)); +} + +%typemap(out, noblock=1) SWIGTYPE* const& { + %set_output(SWIG_NewPointerObj(%as_voidptr(*$1), $*descriptor, $owner | %newpointer_flags)); +} + +/* Return by value */ +%typemap(out, noblock=1) SWIGTYPE { + %set_output(SWIG_NewPointerObj(%new_copy($1, $ltype), $&descriptor, SWIG_POINTER_OWN | %newpointer_flags)); +} + +/* ----------------------------------------------------------------------------- + * --- Variable input --- + * ----------------------------------------------------------------------------- */ + +/* memberin/globalin/varin, for fix arrays. */ + +%typemap(memberin) SWIGTYPE [ANY] { + if ($input) { + size_t ii = 0; + for (; ii < (size_t)$dim0; ++ii) $1[ii] = $input[ii]; + } else { + %variable_nullref("$type","$name"); + } +} + +%typemap(globalin) SWIGTYPE [ANY] { + if ($input) { + size_t ii = 0; + for (; ii < (size_t)$dim0; ++ii) $1[ii] = $input[ii]; + } else { + %variable_nullref("$type","$name"); + } +} + +%typemap(varin) SWIGTYPE [ANY] { + $basetype *inp = 0; + int res = SWIG_ConvertPtr($input, %as_voidptrptr(&inp), $descriptor, %convertptr_flags); + if (!SWIG_IsOK(res)) { + %variable_fail(res, "$type", "$name"); + } else if (inp) { + size_t ii = 0; + for (; ii < (size_t)$dim0; ++ii) $1[ii] = inp[ii]; + } else { + %variable_nullref("$type", "$name"); + } +} + + +/* memberin/globalin/varin, for fix double arrays. */ + +%typemap(memberin) SWIGTYPE [ANY][ANY] { + if ($input) { + size_t ii = 0; + for (; ii < (size_t)$dim0; ++ii) { + if ($input[ii]) { + size_t jj = 0; + for (; jj < (size_t)$dim1; ++jj) $1[ii][jj] = $input[ii][jj]; + } else { + %variable_nullref("$type","$name"); + } + } + } else { + %variable_nullref("$type","$name"); + } +} + +%typemap(globalin) SWIGTYPE [ANY][ANY] { + if ($input) { + size_t ii = 0; + for (; ii < (size_t)$dim0; ++ii) { + if ($input[ii]) { + size_t jj = 0; + for (; jj < (size_t)$dim1; ++jj) $1[ii][jj] = $input[ii][jj]; + } else { + %variable_nullref("$type","$name"); + } + } + } else { + %variable_nullref("$type","$name"); + } +} + +%typemap(varin) SWIGTYPE [ANY][ANY] { + $basetype (*inp)[$dim1] = 0; + int res = SWIG_ConvertPtr($input, %as_voidptrptr(&inp), $descriptor, %convertptr_flags); + if (!SWIG_IsOK(res)) { + %variable_fail(res, "$type", "$name"); + } else if (inp) { + size_t ii = 0; + for (; ii < (size_t)$dim0; ++ii) { + if (inp[ii]) { + size_t jj = 0; + for (; jj < (size_t)$dim1; ++jj) $1[ii][jj] = inp[ii][jj]; + } else { + %variable_nullref("$type", "$name"); + } + } + } else { + %variable_nullref("$type", "$name"); + } +} + +/* Pointers, references, and variable size arrays */ + +%typemap(varin,warning=SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) SWIGTYPE * { + void *argp = 0; + int res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags); + if (!SWIG_IsOK(res)) { + %variable_fail(res, "$type", "$name"); + } + $1 = %reinterpret_cast(argp, $ltype); +} + +%typemap(varin,noblock=1,warning="462:Unable to set dimensionless array variable") SWIGTYPE [] +{ + %variable_fail(SWIG_AttributeError, "$type", "read-only $name"); +} + +%typemap(varin,warning=SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) SWIGTYPE & { + void *argp = 0; + int res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags); + if (!SWIG_IsOK(res)) { + %variable_fail(res, "$type", "$name"); + } + if (!argp) { + %variable_nullref("$type", "$name"); + } + $1 = *(%reinterpret_cast(argp, $ltype)); +} + +#if defined(__cplusplus) && defined(%implicitconv_flag) +%typemap(varin,implicitconv=1) SWIGTYPE { + void *argp = 0; + int res = SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags | %implicitconv_flag); + if (!SWIG_IsOK(res)) { + %variable_fail(res, "$type", "$name"); + } + if (!argp) { + %variable_nullref("$type", "$name"); + } else { + $&type temp; + temp = %reinterpret_cast(argp, $&type); + $1 = *temp; + if (SWIG_IsNewObj(res)) %delete(temp); + } +} +#else +%typemap(varin) SWIGTYPE { + void *argp = 0; + int res = SWIG_ConvertPtr($input, &argp, $&descriptor, %convertptr_flags); + if (!SWIG_IsOK(res)) { + %variable_fail(res, "$type", "$name"); + } + if (!argp) { + %variable_nullref("$type", "$name"); + } else { + $1 = *(%reinterpret_cast(argp, $&type)); + } +} +#endif + +/* ----------------------------------------------------------------------------- + * --- Variable output --- + * ----------------------------------------------------------------------------- */ + +/* Pointers and arrays */ +%typemap(varout, noblock=1) SWIGTYPE * { + %set_varoutput(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, %newpointer_flags)); +} + +%typemap(varout, noblock=1) SWIGTYPE [] { + %set_varoutput(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, %newpointer_flags)); +} + +/* References */ +%typemap(varout, noblock=1) SWIGTYPE & { + %set_varoutput(SWIG_NewPointerObj(%as_voidptr(&$1), $descriptor, %newpointer_flags)); +} + +/* Value */ +%typemap(varout, noblock=1) SWIGTYPE { + %set_varoutput(SWIG_NewPointerObj(%as_voidptr(&$1), $&descriptor, %newpointer_flags)); +} + +/* ------------------------------------------------------------ + * --- Typechecking rules --- + * ------------------------------------------------------------ */ + +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE * { + void *vptr = 0; + int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0); + $1 = SWIG_CheckState(res); +} + +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE & { + void *vptr = 0; + int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0); + $1 = SWIG_CheckState(res); +} + +#if defined(__cplusplus) && defined(%implicitconv_flag) +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1,implicitconv=1) const SWIGTYPE & { + int res = SWIG_ConvertPtr($input, 0, $descriptor, %implicitconv_flag); + $1 = SWIG_CheckState(res); +} + +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1,implicitconv=1) SWIGTYPE { + int res = SWIG_ConvertPtr($input, 0, $&descriptor, %implicitconv_flag); + $1 = SWIG_CheckState(res); +} +#else +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) const SWIGTYPE & { + void *vptr = 0; + int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0); + $1 = SWIG_CheckState(res); +} + +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE { + void *vptr = 0; + int res = SWIG_ConvertPtr($input, &vptr, $&descriptor, 0); + $1 = SWIG_CheckState(res); +} +#endif + +/* ----------------------------------------------------------------------------- + * --- Director typemaps --- * + * ----------------------------------------------------------------------------- */ + +#if defined(SWIG_DIRECTOR_TYPEMAPS) + +/* directorin */ + +%typemap(directorin,noblock=1) SWIGTYPE*, SWIGTYPE* const& { + $input = SWIG_NewPointerObj(%as_voidptr($1_name), $descriptor, %newpointer_flags); +} + +%typemap(directorin,noblock=1) SWIGTYPE { + $input = SWIG_NewPointerObj(%as_voidptr(&$1_name), $&descriptor, %newpointer_flags); +} + +%typemap(directorin,noblock=1) SWIGTYPE& { + $input = SWIG_NewPointerObj(%as_voidptr(&$1_name), $descriptor, %newpointer_flags); +} + +/* directorout */ +#if defined(__cplusplus) && defined(%implicitconv_flag) +%typemap(directorout,noblock=1,implicitconv=1) SWIGTYPE (void * swig_argp, int swig_res = 0) { + swig_res = SWIG_ConvertPtr($input,&swig_argp,$&descriptor, %convertptr_flags | %implicitconv_flag); + if (!SWIG_IsOK(swig_res)) { + %dirout_fail(swig_res,"$type"); + } + $result = *(%reinterpret_cast(swig_argp, $<ype)); + if (SWIG_IsNewObj(swig_res)) %delete(%reinterpret_cast(swig_argp, $<ype)); +} +#else +%typemap(directorout,noblock=1) SWIGTYPE (void * swig_argp, int swig_res = 0) { + swig_res = SWIG_ConvertPtr($input,&swig_argp,$&descriptor, %convertptr_flags); + if (!SWIG_IsOK(swig_res)) { + %dirout_fail(swig_res,"$type"); + } + $result = *(%reinterpret_cast(swig_argp, $<ype)); +} +#endif + +%typemap(directorout,noblock=1,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) + SWIGTYPE *(void *swig_argp, int swig_res, swig_owntype own) { + swig_res = SWIG_ConvertPtrAndOwn($input, &swig_argp, $descriptor, %convertptr_flags | SWIG_POINTER_DISOWN, &own); + if (!SWIG_IsOK(swig_res)) { + %dirout_fail(swig_res,"$type"); + } + $result = %reinterpret_cast(swig_argp, $ltype); + swig_acquire_ownership_obj(%as_voidptr($result), own); +} +%typemap(directorfree,noblock=1,match="directorout") SWIGTYPE * { + if (director) { + SWIG_AcquirePtr($result, director->swig_release_ownership(%as_voidptr($input))); + } +} + +%typemap(directorout,noblock=1,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) + SWIGTYPE &(void *swig_argp, int swig_res, swig_owntype own) { + swig_res = SWIG_ConvertPtrAndOwn($input, &swig_argp, $descriptor, %convertptr_flags | SWIG_POINTER_DISOWN, &own); + if (!SWIG_IsOK(swig_res)) { + %dirout_fail(swig_res,"$type"); + } + if (!swig_argp) { %dirout_nullref("$type"); } + $result = %reinterpret_cast(swig_argp, $ltype); + swig_acquire_ownership_obj(%as_voidptr($result), own); +} +%typemap(directorfree,noblock=1,match="directorout") SWIGTYPE & { + if (director) { + SWIG_AcquirePtr($result, director->swig_release_ownership(%as_voidptr($input))); + } +} + +#endif /* SWIG_DIRECTOR_TYPEMAPS */ + + +/* ------------------------------------------------------------ + * --- Constants --- + * ------------------------------------------------------------ */ + +%typemap(constcode,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE []{ + %set_constant("$symname", SWIG_NewPointerObj(%as_voidptr($value),$descriptor,%newpointer_flags)); +} + +%typemap(constcode,noblock=1) SWIGTYPE { + %set_constant("$symname", SWIG_NewPointerObj(%as_voidptr(&$value),$&descriptor,%newpointer_flags)); +} + +/* ------------------------------------------------------------ + * --- Exception handling --- + * ------------------------------------------------------------ */ + +%typemap(throws,noblock=1) SWIGTYPE { + %raise(SWIG_NewPointerObj(%new_copy($1, $ltype),$&descriptor,SWIG_POINTER_OWN), "$type", $&descriptor); +} + +%typemap(throws,noblock=1) SWIGTYPE * { + %raise(SWIG_NewPointerObj(%as_voidptr($1),$descriptor,0), "$type", $descriptor); +} + +%typemap(throws,noblock=1) SWIGTYPE [ANY] { + %raise(SWIG_NewPointerObj(%as_voidptr($1),$descriptor,0), "$type", $descriptor); +} + +%typemap(throws,noblock=1) SWIGTYPE & { + %raise(SWIG_NewPointerObj(%as_voidptr(&$1),$descriptor,0), "$type", $descriptor); +} + +%typemap(throws,noblock=1) (...) { + SWIG_exception_fail(SWIG_RuntimeError,"unknown exception"); +} + +/* ------------------------------------------------------------ + * --- CLASS::* typemaps --- + * ------------------------------------------------------------ */ + +%typemap(in) SWIGTYPE (CLASS::*) { + int res = SWIG_ConvertMember($input, %as_voidptr(&$1), sizeof($type),$descriptor); + if (!SWIG_IsOK(res)) { + %argument_fail(res,"$type",$symname, $argnum); + } +} + +%typemap(out,noblock=1) SWIGTYPE (CLASS::*) { + %set_output(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor)); +} + +%typemap(varin) SWIGTYPE (CLASS::*) { + int res = SWIG_ConvertMember($input,%as_voidptr(&$1), sizeof($type), $descriptor); + if (!SWIG_IsOK(res)) { + %variable_fail(res, "$type", "$name"); + } +} + +%typemap(varout,noblock=1) SWIGTYPE (CLASS::*) { + %set_varoutput(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor)); +} + +%typemap(constcode,noblock=1) SWIGTYPE (CLASS::*) { + %set_constant("$symname", SWIG_NewMemberObj(%as_voidptr(&$value), sizeof($type), $descriptor)); +} + +#if defined(SWIG_DIRECTOR_TYPEMAPS) + +/* directorin */ + +%typemap(directorin,noblock=1) SWIGTYPE (CLASS::*) { + $input = SWIG_NewMemberObj(%as_voidptr(&$1_name), sizeof($type), $descriptor); +} + +/* directorout */ + +%typemap(directorout) SWIGTYPE (CLASS::*) { + int swig_res = SWIG_ConvertMember($input,%as_voidptr(&$result), sizeof($type), $descriptor); + if (!SWIG_IsOK(swig_res)) { + %dirout_fail(swig_res,"$type"); + } +} +#endif + +/* ------------------------------------------------------------ + * --- function ptr typemaps --- + * ------------------------------------------------------------ */ + +/* + ISO C++ doesn't allow direct casting of a function ptr to a object + ptr. So, maybe the ptr sizes are not the same, and we need to take + some providences. + */ +%typemap(in) SWIGTYPE ((*)(ANY)) { + int res = SWIG_ConvertFunctionPtr($input, (void**)(&$1), $descriptor); + if (!SWIG_IsOK(res)) { + %argument_fail(res,"$type",$symname, $argnum); + } +} + +%typecheck(SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE ((*)(ANY)) { + void *ptr = 0; + int res = SWIG_ConvertFunctionPtr($input, &ptr, $descriptor); + $1 = SWIG_CheckState(res); +} + + +%typemap(out, noblock=1) SWIGTYPE ((*)(ANY)) { + %set_output(SWIG_NewFunctionPtrObj((void *)($1), $descriptor)); +} + +%typemap(varin) SWIGTYPE ((*)(ANY)) { + int res = SWIG_ConvertFunctionPtr($input, (void**)(&$1), $descriptor); + if (!SWIG_IsOK(res)) { + %variable_fail(res, "$type", "$name"); + } +} + +%typemap(varout,noblock=1) SWIGTYPE ((*)(ANY)) { + %set_varoutput(SWIG_NewFunctionPtrObj((void *)($1), $descriptor)); +} + +%typemap(constcode, noblock=1) SWIGTYPE ((*)(ANY)){ + %set_constant("$symname", SWIG_NewFunctionPtrObj((void *)$value, $descriptor)); +} + +#if defined(SWIG_DIRECTOR_TYPEMAPS) + +/* directorin */ + +%typemap(directorin,noblock=1) SWIGTYPE ((*)(ANY)) { + $input = SWIG_NewFunctionPtrObj((void*)($1_name), $descriptor); +} + +/* directorout */ + +%typemap(directorout) SWIGTYPE ((*)(ANY)) { + int swig_res = SWIG_ConvertFunctionPtr($input,(void**)(&$result),$descriptor); + if (!SWIG_IsOK(swig_res)) { + %dirout_fail(swig_res,"$type"); + } +} +#endif + + +/* ------------------------------------------------------------ + * --- Special typemaps --- + * ------------------------------------------------------------ */ + +/* VARARGS_SENTINEL typemap. Used by the %varargs directive. */ + +%typemap(in,numinputs=0) SWIGTYPE *VARARGS_SENTINEL, SWIGTYPE VARARGS_SENTINEL ""; + + +/* DISOWN typemap */ + +%typemap(in, noblock=1) SWIGTYPE *DISOWN (int res = 0) { + res = SWIG_ConvertPtr($input, %as_voidptrptr(&$1), $descriptor, SWIG_POINTER_DISOWN | %convertptr_flags); + if (!SWIG_IsOK(res)) { + %argument_fail(res,"$type", $symname, $argnum); + } +} + +%typemap(varin) SWIGTYPE *DISOWN { + void *temp = 0; + int res = SWIG_ConvertPtr($input, &temp, $descriptor, SWIG_POINTER_DISOWN | %convertptr_flags); + if (!SWIG_IsOK(res)) { + %variable_fail(res, "$type", "$name"); + } + $1 = ($ltype) temp; +} + +/* DYNAMIC typemap */ + +%typemap(out,noblock=1) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { + %set_output(SWIG_NewPointerObj(%as_voidptr($1), SWIG_TypeDynamicCast($descriptor, %as_voidptrptr(&$1)), $owner | %newpointer_flags)); +} + +/* INSTANCE typemap */ + +%typemap(out,noblock=1) SWIGTYPE INSTANCE { + %set_output(SWIG_NewInstanceObj(%new_copy($1, $1_ltype), $&1_descriptor, SWIG_POINTER_OWN | %newinstance_flags)); +} + +%typemap(out,noblock=1) SWIGTYPE *INSTANCE, SWIGTYPE &INSTANCE, SWIGTYPE INSTANCE[] { + %set_output(SWIG_NewInstanceObj(%as_voidptr($1), $1_descriptor, $owner | %newinstance_flags)); +} + +%typemap(varout,noblock=1) SWIGTYPE *INSTANCE, SWIGTYPE INSTANCE[] { + %set_varoutput(SWIG_NewInstanceObj(%as_voidptr($1), $1_descriptor, %newinstance_flags)); +} + +%typemap(varout,noblock=1) SWIGTYPE &INSTANCE { + %set_varoutput(SWIG_NewInstanceObj(%as_voidptr($1), $1_descriptor, %newinstance_flags)); +} + +%typemap(varout,noblock=1) SWIGTYPE INSTANCE { + %set_varoutput(SWIG_NewInstanceObj(%as_voidptr(&$1), $&1_descriptor, %newinstance_flags)); +} diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/swigtypemaps.swg b/devtools/swigwin-1.3.34/Lib/typemaps/swigtypemaps.swg new file mode 100644 index 0000000..08abab0 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/swigtypemaps.swg @@ -0,0 +1,170 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * 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> + + diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/traits.swg b/devtools/swigwin-1.3.34/Lib/typemaps/traits.swg new file mode 100644 index 0000000..37c09c0 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/traits.swg @@ -0,0 +1,316 @@ +// +// Use the following macro with modern STL implementations +// +//#define SWIG_STD_MODERN_STL +// +// Use this to deactive the previous definition, when using gcc-2.95 +// or similar old compilers. +// +//#define SWIG_STD_NOMODERN_STL + +// Here, we identify compilers we now have problems with STL. +%{ + +#if defined(__SUNPRO_CC) +#define SWIG_STD_NOASSIGN_STL +#define SWIG_STD_NOINSERT_TEMPLATE_STL +#endif + + +#if defined(__GNUC__) +# if __GNUC__ == 2 && __GNUC_MINOR <= 96 +# define SWIG_STD_NOMODERN_STL +# endif +#endif + + +%} + +// +// Common code for supporting the STD C++ namespace +// + +%{ +#include <string> +#include <stdexcept> +%} + +%fragment("Traits","header") +{ +namespace swig { + /* + type categories + */ + struct pointer_category { }; + struct value_category { }; + + /* + General traits that provides type_name and type_info + */ + template <class Type> struct traits { }; + + template <class Type> + inline const char* type_name() { + return traits<Type>::type_name(); + } + + template <class Type> + struct traits_info { + static swig_type_info *type_query(std::string name) { + name += " *"; + return SWIG_TypeQuery(name.c_str()); + } + static swig_type_info *type_info() { + static swig_type_info *info = type_query(type_name<Type>()); + return info; + } + }; + + template <class Type> + inline swig_type_info *type_info() { + return traits_info<Type>::type_info(); + } + + /* + Partial specialization for pointers + */ + template <class Type> struct traits <Type *> { + typedef pointer_category category; + static std::string make_ptr_name(const char* name) { + std::string ptrname = name; + ptrname += " *"; + return ptrname; + } + static const char* type_name() { + static std::string name = make_ptr_name(swig::type_name<Type>()); + return name.c_str(); + } + }; + + + template <class Type, class Category = typename traits<Type>::category > + struct traits_check { }; + + /* + Traits that provides the from method for an unknown type + */ + template <int flags, class Type> struct traits_from_ptr { + static SWIG_Object from SWIG_FROM_DECL_ARGS(Type *val) { + return SWIG_NewPointerObj(val, type_info<Type>(), flags); + } + }; + + template <class Type> struct traits_from { + static SWIG_Object from SWIG_FROM_DECL_ARGS(const Type& val) { + return traits_from_ptr<SWIG_POINTER_OWN, Type>::from(new Type(val)); + } + }; + + template <class Type> struct traits_from<Type *> { + static SWIG_Object from SWIG_FROM_DECL_ARGS(Type* val) { + return traits_from_ptr<0, Type>::from(val); + } + }; + + template <class Type> + inline SWIG_Object from SWIG_FROM_DECL_ARGS(const Type& val) { + return traits_from<Type>::from(val); + } + + /* + Traits that provides the asptr/asval method for an unknown type + */ + template <class Type> + struct traits_asptr { + static int asptr SWIG_AS_DECL_ARGS (SWIG_Object obj, Type **val) { + Type *p; + int res = SWIG_ConvertPtr(obj, %as_voidptrptr(&p), type_info<Type>(), 0); + if (SWIG_IsOK(res) && val) *val = p; + return res; + } + }; + + template <class Type> + inline int asptr SWIG_AS_DECL_ARGS(SWIG_Object obj, Type **vptr) { + return traits_asptr<Type>::asptr SWIG_AS_CALL_ARGS(obj, vptr); + } + + template <class Type> + struct traits_asval { + static int asval SWIG_AS_DECL_ARGS(SWIG_Object obj, Type *val) { + if (val) { + Type *p = 0; + int res = traits_asptr<Type>::asptr SWIG_AS_CALL_ARGS(obj, &p); + if (SWIG_IsOK(res) && p) { + *val = *p; + if (SWIG_IsNewObj(res)) { + %delete(p); + res = SWIG_DelNewMask(res); + } + } + return res; + } else { + return traits_asptr<Type>::asptr SWIG_AS_CALL_ARGS(obj, (Type **)(0)); + } + } + }; + + template <class Type> + inline int asval SWIG_AS_DECL_ARGS (SWIG_Object obj, Type *val) { + return traits_asval<Type>::asval SWIG_AS_CALL_ARGS(obj, val); + } + + /* + Traits that provides the check method for an unknown type + */ +#define SWIG_CHECK_DECL_ARGS(obj) SWIG_AS_DECL_ARGS(obj, void * = 0) +#define SWIG_CHECK_CALL_ARGS(obj) SWIG_AS_CALL_ARGS(obj, 0) + + template <class Type> + struct traits_checkval { + static int check SWIG_CHECK_DECL_ARGS(SWIG_Object obj) { + if (obj) { + int res = asval SWIG_AS_CALL_ARGS(obj, (Type *)(0)); + return SWIG_CheckState(res); + } else { + return 0; + } + } + }; + + template <class Type> + struct traits_checkptr { + static int check SWIG_CHECK_DECL_ARGS(SWIG_Object obj) { + if (obj) { + int res = asptr SWIG_AS_CALL_ARGS(obj, (Type **)(0)); + return SWIG_CheckState(res); + } else { + return 0; + } + } + }; + + template <class Type> + struct traits_check<Type, value_category> : traits_checkval<Type> { + }; + + template <class Type> + struct traits_check<Type, pointer_category> : traits_checkptr<Type> { + }; + + template <class Type> + inline int check SWIG_CHECK_DECL_ARGS(SWIG_Object obj) { + return traits_check<Type>::check SWIG_CHECK_CALL_ARGS(obj); + } + +} +} + +/* + Generate the traits for an unknown SWIGTYPE +*/ + +%define %traits_swigtype(Type...) +%fragment(SWIG_Traits_frag(Type),"header",fragment="Traits") { + namespace swig { + template <> struct traits<Type > { + typedef pointer_category category; + static const char* type_name() { return #Type; } + }; + } +} +%enddef + + +/* + Generate the traits for a 'value' type, such as 'double', + for which the SWIG_AsVal and SWIG_From methods are already defined. +*/ + +%define %traits_value(Type...) +%fragment(SWIG_Traits_frag(Type),"header", + fragment=SWIG_AsVal_frag(Type), + fragment=SWIG_From_frag(Type), + fragment="Traits") { +namespace swig { + template <> struct traits<Type > { + typedef value_category category; + static const char* type_name() { return #Type; } + }; + + template <> struct traits_asval<Type > { + typedef Type value_type; + static int asval SWIG_AS_DECL_ARGS (SWIG_Object obj, value_type *val) { + return SWIG_AsVal(Type)(obj, val); + } + }; + + template <> struct traits_from<Type > { + typedef Type value_type; + static SWIG_Object from SWIG_FROM_DECL_ARGS (const value_type& val) { + return SWIG_From(Type)(val); + } + }; +} +} +%enddef + +/* + Generate the traits for a 'pointer' type, such as 'std::string', + for which the SWIG_AsPtr and SWIG_From methods are already defined. +*/ + +%define %traits_pointer(Type...) +%fragment(SWIG_Traits_frag(Type),"header", + fragment=SWIG_AsVal_frag(Type), + fragment=SWIG_From_frag(Type), + fragment="Traits") { +namespace swig { + template <> struct traits<Type > { + typedef pointer_category category; + static const char* type_name() { return #Type; } + }; + + template <> struct traits_asptr<Type > { + typedef Type value_type; + static int asptr SWIG_AS_DECL_ARGS (SWIG_Object obj, value_type **val) { + return SWIG_AsPtr(Type)(obj, val); + } + }; + + template <> struct traits_from<Type > { + typedef Type value_type; + static SWIG_Object from SWIG_FROM_DECL_ARGS (const value_type& val) { + return SWIG_From(Type)(val); + } + }; +} +} +%enddef + +/* + Generate the typemaps for a class that has 'value' traits +*/ + +%define %typemap_traits_value(Code,Type...) + %typemaps_asvalfrom(%arg(Code), + %arg(swig::asval), + %arg(swig::from), + %arg(SWIG_Traits_frag(Type)), + %arg(SWIG_Traits_frag(Type)), + Type); +%enddef + +/* + Generate the typemaps for a class that has 'pointer' traits +*/ + +%define %typemap_traits_pointer(Code,Type...) + %typemaps_asptrfrom(%arg(Code), + %arg(swig::asptr), + %arg(swig::from), + %arg(SWIG_Traits_frag(Type)), + %arg(SWIG_Traits_frag(Type)), + Type); +%enddef + diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/typemaps.swg b/devtools/swigwin-1.3.34/Lib/typemaps/typemaps.swg new file mode 100644 index 0000000..6e75057 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/typemaps.swg @@ -0,0 +1,160 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * typemaps.swg + * + * Tcl Pointer handling + * + * These mappings provide support for input/output arguments and common + * uses for C/C++ pointers. + * ----------------------------------------------------------------------------- */ + +// INPUT typemaps. +// These remap a C pointer to be an "INPUT" value which is passed by value +// instead of reference. + +/* +The following methods can be applied to turn a pointer into a simple +"input" value. That is, instead of passing a pointer to an object, +you would use a real value instead. + + int *INPUT + short *INPUT + long *INPUT + long long *INPUT + unsigned int *INPUT + unsigned short *INPUT + unsigned long *INPUT + unsigned long long *INPUT + unsigned char *INPUT + bool *INPUT + float *INPUT + double *INPUT + +To use these, suppose you had a C function like this : + + double fadd(double *a, double *b) { + return *a+*b; + } + +You could wrap it with SWIG as follows : + + %include <typemaps.i> + double fadd(double *INPUT, double *INPUT); + +or you can use the %apply directive : + + %include <typemaps.i> + %apply double *INPUT { double *a, double *b }; + double fadd(double *a, double *b); + +*/ + +// OUTPUT typemaps. These typemaps are used for parameters that +// are output only. The output value is appended to the result as +// a list element. + +/* +The following methods can be applied to turn a pointer into an "output" +value. When calling a function, no input value would be given for +a parameter, but an output value would be returned. In the case of +multiple output values, they are returned in the form of a Tcl tuple. + + int *OUTPUT + short *OUTPUT + long *OUTPUT + long long *OUTPUT + unsigned int *OUTPUT + unsigned short *OUTPUT + unsigned long *OUTPUT + unsigned long long *OUTPUT + unsigned char *OUTPUT + bool *OUTPUT + float *OUTPUT + double *OUTPUT + +For example, suppose you were trying to wrap the modf() function in the +C math library which splits x into integral and fractional parts (and +returns the integer part in one of its parameters).K: + + double modf(double x, double *ip); + +You could wrap it with SWIG as follows : + + %include <typemaps.i> + double modf(double x, double *OUTPUT); + +or you can use the %apply directive : + + %include <typemaps.i> + %apply double *OUTPUT { double *ip }; + double modf(double x, double *ip); + +The Tcl output of the function would be a tuple containing both +output values. + +*/ + +// INOUT +// Mappings for an argument that is both an input and output +// parameter + +/* +The following methods can be applied to make a function parameter both +an input and output value. This combines the behavior of both the +"INPUT" and "OUTPUT" methods described earlier. Output values are +returned in the form of a Tcl tuple. + + int *INOUT + short *INOUT + long *INOUT + long long *INOUT + unsigned int *INOUT + unsigned short *INOUT + unsigned long *INOUT + unsigned long long *INOUT + unsigned char *INOUT + bool *INOUT + float *INOUT + double *INOUT + +For example, suppose you were trying to wrap the following function : + + void neg(double *x) { + *x = -(*x); + } + +You could wrap it with SWIG as follows : + + %include <typemaps.i> + void neg(double *INOUT); + +or you can use the %apply directive : + + %include <typemaps.i> + %apply double *INOUT { double *x }; + void neg(double *x); + +Unlike C, this mapping does not directly modify the input value (since +this makes no sense in Tcl). Rather, the modified input value shows +up as the return value of the function. Thus, to apply this function +to a Tcl variable you might do this : + + x = neg(x) + +Note : previous versions of SWIG used the symbol 'BOTH' to mark +input/output arguments. This is still supported, but will be slowly +phased out in future releases. + +*/ + + +#if defined(SWIG_INOUT_NODEF) + +%apply_checkctypes(%typemaps_inoutn) + +%apply size_t& { std::size_t& }; +%apply ptrdiff_t& { std::ptrdiff_t& }; + +#endif diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/valtypes.swg b/devtools/swigwin-1.3.34/Lib/typemaps/valtypes.swg new file mode 100644 index 0000000..cd11430 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/valtypes.swg @@ -0,0 +1,216 @@ +/*--------------------------------------------------------------------- + * Value typemaps (Type, const Type&) for value types, such as + * fundamental types (int, double), that define the AsVal/From + * methods. + * + * To apply them, just use one of the following macros: + * + * %typemaps_from(FromMeth, FromFrag, Type) + * %typemaps_asval(CheckCode, AsValMeth, AsValFrag, Type) + * %typemaps_asvalfrom(CheckCode, AsValMeth, FromMeth, AsValFrag, FromFrag, Type) + * + * or the simpler and normalize form: + * + * %typemaps_asvalfromn(CheckCode, Type) + * + * Also, you can use the individual typemap definitions: + * + * %value_in_typemap(asval_meth,frag,Type) + * %value_varin_typemap(asval_meth,frag,Type) + * %value_typecheck_typemap(checkcode,asval_meth,frag,Type) + * %value_directorout_typemap(asval_meth,frag,Type) + * + * %value_out_typemap(from_meth,frag,Type) + * %value_varout_typemap(from_meth,frag,Type) + * %value_constcode_typemap(from_meth,frag,Type) + * %value_directorin_typemap(from_meth,frag,Type) + * %value_throws_typemap(from_meth,frag,Type) + * + *---------------------------------------------------------------------*/ + +/* in */ + +%define %value_in_typemap(asval_meth,frag,Type...) + %typemap(in,noblock=1,fragment=frag) Type (Type val, int ecode = 0) { + ecode = asval_meth($input, &val); + if (!SWIG_IsOK(ecode)) { + %argument_fail(ecode, "$ltype", $symname, $argnum); + } + $1 = %static_cast(val,$ltype); + } + %typemap(freearg) Type ""; + %typemap(in,noblock=1,fragment=frag) const Type & ($*ltype temp, Type val, int ecode = 0) { + ecode = asval_meth($input, &val); + if (!SWIG_IsOK(ecode)) { + %argument_fail(ecode, "$*ltype", $symname, $argnum); + } + temp = %static_cast(val, $*ltype); + $1 = &temp; + } + %typemap(freearg) const Type& ""; +%enddef + +/* out */ + +%define %value_out_typemap(from_meth,frag,Type...) + %typemap(out,noblock=1,fragment=frag) Type, const Type { + %set_output(from_meth(%static_cast($1,Type))); + } + %typemap(out,noblock=1,fragment=frag) const Type& { + %set_output(from_meth(%static_cast(*$1,Type))); + } +%enddef + +/* varin */ + +%define %value_varin_typemap(asval_meth,frag,Type...) + %typemap(varin,fragment=frag) Type { + Type val; + int res = asval_meth($input, &val); + if (!SWIG_IsOK(res)) { + %variable_fail(res, "$type", "$name"); + } + $1 = %static_cast(val,$ltype); + } +%enddef + +/* varout */ + +%define %value_varout_typemap(from_meth,frag,Type...) + %typemap(varout,noblock=1,fragment=frag) Type, const Type& { + %set_varoutput(from_meth(%static_cast($1,Type))); + } +%enddef + +/* constant installation code */ + +%define %value_constcode_typemap(from_meth,frag,Type...) + %typemap(constcode,noblock=1,fragment=frag) Type { + %set_constant("$symname", from_meth(%static_cast($value,Type))); + } +%enddef + + +#if defined(SWIG_DIRECTOR_TYPEMAPS) + +/* directorin */ + +%define %value_directorin_typemap(from_meth,frag,Type...) + %typemap(directorin,noblock=1,fragment=frag) Type *DIRECTORIN { + $input = from_meth(%static_cast(*$1_name,Type)); + } + %typemap(directorin,noblock=1,fragment=frag) Type, const Type& { + $input = from_meth(%static_cast($1_name,Type)); + } +%enddef + +/* directorout */ + +%define %value_directorout_typemap(asval_meth,frag,Type...) + %typemap(directorargout,noblock=1,fragment=frag) Type *DIRECTOROUT { + Type swig_val; + int swig_res = asval_meth($input, &swig_val); + if (!SWIG_IsOK(swig_res)) { + %dirout_fail(swig_res, "$type"); + } + *$result = %static_cast(swig_val, $type); + } + %typemap(directorout,noblock=1,fragment=frag) Type { + Type swig_val; + int swig_res = asval_meth($input, &swig_val); + if (!SWIG_IsOK(swig_res)) { + %dirout_fail(swig_res, "$type"); + } + $result = %static_cast(swig_val,$type); + } + %typemap(directorout,noblock=1,fragment=frag,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) const Type& { + Type swig_val; + int swig_res = asval_meth($input, &swig_val); + if (!SWIG_IsOK(swig_res)) { + %dirout_fail(swig_res, "$type"); + } + $basetype *temp = new $basetype(($basetype)swig_val); + swig_acquire_ownership(temp); + $result = temp; + } + %typemap(directorfree,noblock=1) const Type & { + if (director) { + director->swig_release_ownership(%as_voidptr($input)); + } + } + %typemap(directorout,fragment=frag) Type &DIRECTOROUT = Type +%enddef + +#else + +#define %value_directorin_typemap(from_meth,frag,Type...) +#define %value_directorout_typemap(asval_meth,frag,Type...) + +#endif /* SWIG_DIRECTOR_TYPEMAPS */ + + +/* throws */ + +%define %value_throws_typemap(from_meth,frag,Type...) + %typemap(throws,noblock=1,fragment=frag) Type { + %raise(from_meth(%static_cast($1,Type)), "$type", 0); + } +%enddef + +/* typecheck */ + +%define %value_typecheck_typemap(check,asval_meth,frag,Type...) + %typemap(typecheck,precedence=check,fragment=frag) Type, const Type& { + int res = asval_meth($input, NULL); + $1 = SWIG_CheckState(res); + } +%enddef + +/*--------------------------------------------------------------------- + * typemap definition for types with AsVal methods + *---------------------------------------------------------------------*/ +%define %typemaps_asval(CheckCode, AsValMeth, AsValFrag, Type...) + %value_in_typemap(%arg(AsValMeth), %arg(AsValFrag), Type); + %value_varin_typemap(%arg(AsValMeth), %arg(AsValFrag), Type); + %value_directorout_typemap(%arg(AsValMeth), %arg(AsValFrag), Type); + %value_typecheck_typemap(%arg(CheckCode), %arg(AsValMeth), %arg(AsValFrag), Type); + %value_input_typemap(%arg(CheckCode), %arg(AsValMeth), %arg(AsValFrag), Type); +%enddef + + +/*--------------------------------------------------------------------- + * typemap definition for types with from method + *---------------------------------------------------------------------*/ +%define %typemaps_from(FromMeth, FromFrag, Type...) + %value_out_typemap(%arg(FromMeth), %arg(FromFrag), Type); + %value_varout_typemap(%arg(FromMeth), %arg(FromFrag), Type); + %value_constcode_typemap(%arg(FromMeth), %arg(FromFrag), Type); + %value_directorin_typemap(%arg(FromMeth), %arg(FromFrag), Type); + %value_throws_typemap(%arg(FromMeth), %arg(FromFrag), Type); + %value_output_typemap(%arg(FromMeth), %arg(FromFrag), Type); +%enddef + + +/*--------------------------------------------------------------------- + * typemap definition for types with alval/from method + *---------------------------------------------------------------------*/ + +%define %typemaps_asvalfrom(CheckCode, AsValMeth, FromMeth, + AsValFrag, FromFrag, Type...) + %typemaps_asval(%arg(CheckCode), %arg(AsValMeth), %arg(AsValFrag), Type); + %typemaps_from(%arg(FromMeth), %arg(FromFrag), Type); + %value_inout_typemap(Type); +%enddef + + +/*--------------------------------------------------------------------- + * typemap definition for types with for 'normalized' asval/from methods + *---------------------------------------------------------------------*/ +%define %typemaps_asvalfromn(CheckCode, Type...) + %typemaps_asvalfrom(%arg(CheckCode), + SWIG_AsVal(Type), + SWIG_From(Type), + %arg(SWIG_AsVal_frag(Type)), + %arg(SWIG_From_frag(Type)), + Type); +%enddef diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/void.swg b/devtools/swigwin-1.3.34/Lib/typemaps/void.swg new file mode 100644 index 0000000..aa12583 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/void.swg @@ -0,0 +1,84 @@ +/* ------------------------------------------------------------ + * Void * - Accepts any kind of pointer + * ------------------------------------------------------------ */ + +/* in */ + +%typemap(in,noblock=1) void * (int res) { + res = SWIG_ConvertPtr($input,%as_voidptrptr(&$1), 0, $disown); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "$type", $symname, $argnum); + } +} +%typemap(freearg) void * ""; + +%typemap(in,noblock=1) void * const& ($*ltype temp = 0, int res) { + res = SWIG_ConvertPtr($input, %as_voidptrptr(&temp), 0, $disown); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "Stype", $symname, $argnum); + } + $1 = &temp; +} +%typemap(freearg) void * const& ""; + + +/* out */ + +#if defined(VOID_Object) +%typemap(out,noblock=1) void { $result = VOID_Object; } +#else +%typemap(out,noblock=1) void {} +#endif + +/* varin */ + +%typemap(varin) void * { + void *temp = 0; + int res = SWIG_ConvertPtr($input, &temp, 0, SWIG_POINTER_DISOWN); + if (!SWIG_IsOK(res)) { + %variable_fail(res, "$type", "$name"); + } + $1 = ($1_ltype) temp; +} + +/* typecheck */ + +%typecheck(SWIG_TYPECHECK_VOIDPTR, noblock=1) void * +{ + void *ptr = 0; + int res = SWIG_ConvertPtr($input, &ptr, 0, 0); + $1 = SWIG_CheckState(res); +} + +#if defined(SWIG_DIRECTOR_TYPEMAPS) + +/* directorin */ + +%typemap(directorin,noblock=1) void *, void const*, void *const, void const *const, + void const *&, void *const &, void const *const & { + $input = SWIG_NewPointerObj(%as_voidptr($1_name), $descriptor, %newpointer_flags); +} + +/* directorout */ + +%typemap(directorout,noblock=1) void * (void *argp, int res) { + res = SWIG_ConvertPtr($input, &argp, 0, 0); + if (!SWIG_IsOK(res)) { + %dirout_fail(res,"$type"); + } + $result = %reinterpret_cast(argp, $ltype); +} + +%typemap(directorout,noblock=1,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) void * const& (void *argp, int res) { + res = SWIG_ConvertPtr($input, &argp, 0, $disown); + if (!SWIG_IsOK(res)) { + %dirout_fail(res,"$type"); + } + static $*ltype temp = %reinterpret_cast(argp, $*ltype); + $result = &temp; +} + + + +#endif /* SWIG_DIRECTOR_TYPEMAPS */ + diff --git a/devtools/swigwin-1.3.34/Lib/typemaps/wstring.swg b/devtools/swigwin-1.3.34/Lib/typemaps/wstring.swg new file mode 100644 index 0000000..2567dc7 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/typemaps/wstring.swg @@ -0,0 +1,25 @@ +%ensure_fragment(SWIG_AsWCharPtrAndSize) +%ensure_fragment(SWIG_FromWCharPtrAndSize) + + +%types(wchar_t *); + +%fragment("SWIG_pwchar_descriptor","header") { +SWIGINTERN swig_type_info* +SWIG_pwchar_descriptor() +{ + static int init = 0; + static swig_type_info* info = 0; + if (!init) { + info = SWIG_TypeQuery("_p_wchar_t"); + init = 1; + } + return info; +} +} + +%include <typemaps/strings.swg> +%typemaps_string(%checkcode(UNISTRING), %checkcode(UNICHAR), + wchar_t, WChar, SWIG_AsWCharPtrAndSize, SWIG_FromWCharPtrAndSize, wcslen, + "<wchar.h>", WCHAR_MIN, WCHAR_MAX) + diff --git a/devtools/swigwin-1.3.34/Lib/uffi/uffi.swg b/devtools/swigwin-1.3.34/Lib/uffi/uffi.swg new file mode 100644 index 0000000..8100b75 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/uffi/uffi.swg @@ -0,0 +1,103 @@ +/* Define a C preprocessor symbol that can be used in interface files + to distinguish between the SWIG language modules. */ + +#define SWIG_UFFI + +/* Typespecs for basic types. */ + +%typemap(ffitype) char ":char"; +%typemap(ffitype) unsigned char ":unsigned-char"; +%typemap(ffitype) signed char ":char"; +%typemap(ffitype) short ":short"; +%typemap(ffitype) signed short ":short"; +%typemap(ffitype) unsigned short ":unsigned-short"; +%typemap(ffitype) int ":int"; +%typemap(ffitype) signed int ":int"; +%typemap(ffitype) unsigned int ":unsigned-int"; +%typemap(ffitype) long ":long"; +%typemap(ffitype) signed long ":long"; +%typemap(ffitype) unsigned long ":unsigned-long"; +%typemap(ffitype) float ":float"; +%typemap(ffitype) double ":double"; +%typemap(ffitype) char * ":cstring"; +%typemap(ffitype) void * ":pointer-void"; +%typemap(ffitype) void ":void"; + +// FIXME: This is guesswork +typedef long size_t; + +%wrapper %{ +;; $Id: uffi.swg 7358 2005-08-09 15:09:15Z mkoeppe $ + +(eval-when (compile eval) + +;;; You can define your own identifier converter if you want. +;;; Use the -identifier-converter command line argument to +;;; specify its name. + +(defun identifier-convert-null (id &key type) + (declare (ignore type)) + (read-from-string id)) + +(defun identifier-convert-lispify (cname &key type) + (assert (stringp cname)) + (if (eq type :constant) + (setf cname (format nil "*~A*" cname))) + (setf cname (replace-regexp cname "_" "-")) + (let ((lastcase :other) + newcase char res) + (dotimes (n (length cname)) + (setf char (schar cname n)) + (if* (alpha-char-p char) + then + (setf newcase (if (upper-case-p char) :upper :lower)) + + (when (or (and (eq lastcase :upper) (eq newcase :lower)) + (and (eq lastcase :lower) (eq newcase :upper))) + ;; case change... add a dash + (push #\- res) + (setf newcase :other)) + + (push (char-downcase char) res) + + (setf lastcase newcase) + + else + (push char res) + (setf lastcase :other))) + (read-from-string (coerce (nreverse res) 'string)))) + +(defun identifier-convert-low-level (cname &key type) + (assert (stringp cname)) + (if (eq type :constant) + (setf cname (format nil "+~A+" cname))) + (setf cname (substitute #\- #\_ cname)) + (if (eq type :operator) + (setf cname (format nil "%~A" cname))) + (if (eq type :constant-function) + nil) + (read-from-string cname)) + + + +(defmacro swig-defconstant (string value &key (export T)) + (let ((symbol (funcall *swig-identifier-converter* string :type :constant))) + `(eval-when (compile load eval) + (uffi:def-constant ,symbol ,value ,export)))) + +(defmacro swig-defun (name &rest rest) + (let ((symbol (funcall *swig-identifier-converter* name :type :operator))) + `(eval-when (compile load eval) + (uffi:def-function (,name ,symbol) ,@rest) + (export (quote ,symbol))))) + +(defmacro swig-def-struct (name &rest fields) + "Declare a struct object" + (let ((symbol (funcall *swig-identifier-converter* name :type :type))) + `(eval-when (compile load eval) + (uffi:def-struct ,symbol ,@fields) + (export (quote ,symbol))))) + + +) ;; eval-when +%} diff --git a/devtools/swigwin-1.3.34/Lib/wchar.i b/devtools/swigwin-1.3.34/Lib/wchar.i new file mode 100644 index 0000000..f106a35 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/wchar.i @@ -0,0 +1,14 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * wchar.i + * ----------------------------------------------------------------------------- */ + +/* + wchar_t not supported, unless otherwise specified in the target language. +*/ + +#if defined(SWIG_WCHAR) +#undef SWIG_WCHAR +#endif diff --git a/devtools/swigwin-1.3.34/Lib/windows.i b/devtools/swigwin-1.3.34/Lib/windows.i new file mode 100644 index 0000000..08ddc2b --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/windows.i @@ -0,0 +1,152 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * windows.i + * + * SWIG library file to support types found in windows.h as well as Microsoft + * integral type extensions. The types are set for 32 bit Windows. + * ----------------------------------------------------------------------------- */ + +// Support for non ISO (Windows) integral types +%apply unsigned char { unsigned __int8 }; +%apply const unsigned char& { const unsigned __int8& }; + +%apply signed char { __int8 }; +%apply const signed char& { const __int8& }; + +%apply unsigned short { unsigned __int16 }; +%apply const unsigned short& { const unsigned __int16& }; + +%apply short { __int16 }; +%apply const short& { const __int16& }; + +%apply unsigned int { unsigned __int32 }; +%apply const unsigned int& { const unsigned __int32& }; + +%apply int { __int32 }; +%apply const int& { const __int32& }; + +%apply unsigned long long { unsigned __int64 }; +%apply const unsigned long long& { const unsigned __int64& }; + +%apply long long { __int64 }; +%apply const long long& { const __int64& }; + + +// Workaround Microsoft calling conventions +#define __cdecl +#define __fastcall +#define __far +#define __forceinline +#define __fortran +#define __inline +#define __pascal +#define __stdcall +#define __syscall +#define _cdecl +#define _fastcall +#define _inline +#define _pascal +#define _stdcall +#define WINAPI +#define __declspec(WINDOWS_EXTENDED_ATTRIBUTE) + +#define __w64 + +// Types from windef.h +typedef unsigned long ULONG; +typedef ULONG *PULONG; +typedef unsigned short USHORT; +typedef USHORT *PUSHORT; +typedef unsigned char UCHAR; +typedef UCHAR *PUCHAR; +typedef char *PSZ; +typedef unsigned long DWORD; +typedef int BOOL; +typedef unsigned char BYTE; +typedef unsigned short WORD; +typedef float FLOAT; +typedef FLOAT *PFLOAT; +typedef BOOL *PBOOL; +typedef BOOL *LPBOOL; +typedef BYTE *PBYTE; +typedef BYTE *LPBYTE; +typedef int *PINT; +typedef int *LPINT; +typedef WORD *PWORD; +typedef WORD *LPWORD; +typedef long *LPLONG; +typedef DWORD *PDWORD; +typedef DWORD *LPDWORD; +typedef void *LPVOID; +typedef const void *LPCVOID; +typedef int INT; +typedef unsigned int UINT; +typedef unsigned int *PUINT; + +// Types from basetsd.h +typedef signed char INT8, *PINT8; +typedef signed short INT16, *PINT16; +typedef signed int INT32, *PINT32; +typedef signed __int64 INT64, *PINT64; +typedef unsigned char UINT8, *PUINT8; +typedef unsigned short UINT16, *PUINT16; +typedef unsigned int UINT32, *PUINT32; +typedef unsigned __int64 UINT64, *PUINT64; +typedef signed int LONG32, *PLONG32; +typedef unsigned int ULONG32, *PULONG32; +typedef unsigned int DWORD32, *PDWORD32; +typedef __w64 int INT_PTR, *PINT_PTR; +typedef __w64 unsigned int UINT_PTR, *PUINT_PTR; +typedef __w64 long LONG_PTR, *PLONG_PTR; +typedef __w64 unsigned long ULONG_PTR, *PULONG_PTR; +typedef unsigned short UHALF_PTR, *PUHALF_PTR; +typedef short HALF_PTR, *PHALF_PTR; +typedef __w64 long SHANDLE_PTR; +typedef __w64 unsigned long HANDLE_PTR; +typedef ULONG_PTR SIZE_T, *PSIZE_T; +typedef LONG_PTR SSIZE_T, *PSSIZE_T; +typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR; +typedef __int64 LONG64, *PLONG64; +typedef unsigned __int64 ULONG64, *PULONG64; +typedef unsigned __int64 DWORD64, *PDWORD64; + +// Types from winnt.h +typedef void *PVOID; +typedef void *PVOID64; +typedef char CHAR; +typedef short SHORT; +typedef long LONG; +typedef CHAR *PCHAR; +typedef CHAR *LPCH, *PCH; +typedef const CHAR *LPCCH, *PCCH; +typedef CHAR *NPSTR; +typedef CHAR *LPSTR, *PSTR; +typedef const CHAR *LPCSTR, *PCSTR; +typedef char TCHAR, *PTCHAR; +typedef unsigned char TBYTE , *PTBYTE ; +typedef LPSTR LPTCH, PTCH; +typedef LPSTR PTSTR, LPTSTR, PUTSTR, LPUTSTR; +typedef LPCSTR PCTSTR, LPCTSTR, PCUTSTR, LPCUTSTR; +typedef SHORT *PSHORT; +typedef LONG *PLONG; +typedef void *HANDLE; +typedef HANDLE *PHANDLE; +typedef BYTE FCHAR; +typedef WORD FSHORT; +typedef DWORD FLONG; +typedef LONG HRESULT; +typedef char CCHAR; +typedef DWORD LCID; +typedef PDWORD PLCID; +typedef WORD LANGID; +typedef __int64 LONGLONG; +typedef unsigned __int64 ULONGLONG; +typedef LONGLONG *PLONGLONG; +typedef ULONGLONG *PULONGLONG; +typedef ULONGLONG DWORDLONG; +typedef DWORDLONG *PDWORDLONG; +typedef BYTE BOOLEAN; +typedef BOOLEAN *PBOOLEAN; + diff --git a/devtools/swigwin-1.3.34/Lib/xml/typemaps.i b/devtools/swigwin-1.3.34/Lib/xml/typemaps.i new file mode 100644 index 0000000..2973613 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/xml/typemaps.i @@ -0,0 +1,3 @@ +// -------------------------------------------------------------------- +// Empty file for %include to work +// -------------------------------------------------------------------- diff --git a/devtools/swigwin-1.3.34/Lib/xml/xml.swg b/devtools/swigwin-1.3.34/Lib/xml/xml.swg new file mode 100644 index 0000000..c7bdbad --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/xml/xml.swg @@ -0,0 +1 @@ +/* nothing special */
\ No newline at end of file diff --git a/devtools/swigwin-1.3.34/foo.bat b/devtools/swigwin-1.3.34/foo.bat new file mode 100644 index 0000000..3e74843 --- /dev/null +++ b/devtools/swigwin-1.3.34/foo.bat @@ -0,0 +1,514 @@ +p4 add ./foo.bat +p4 add ./Lib/allegrocl/allegrocl.swg +p4 add ./Lib/allegrocl/inout_typemaps.i +p4 add ./Lib/allegrocl/longlongs.i +p4 add ./Lib/allegrocl/std_list.i +p4 add ./Lib/allegrocl/std_string.i +p4 add ./Lib/allegrocl/typemaps.i +p4 add ./Lib/allkw.swg +p4 add ./Lib/attribute.i +p4 add ./Lib/carrays.i +p4 add ./Lib/cdata.i +p4 add ./Lib/cffi/cffi.swg +p4 add ./Lib/chicken/chicken.swg +p4 add ./Lib/chicken/chickenkw.swg +p4 add ./Lib/chicken/chickenrun.swg +p4 add ./Lib/chicken/extra-install.list +p4 add ./Lib/chicken/multi-generic.scm +p4 add ./Lib/chicken/std_string.i +p4 add ./Lib/chicken/swigclosprefix.scm +p4 add ./Lib/chicken/tinyclos-multi-generic.patch +p4 add ./Lib/chicken/typemaps.i +p4 add ./Lib/clisp/clisp.swg +p4 add ./Lib/cmalloc.i +p4 add ./Lib/constraints.i +p4 add ./Lib/cpointer.i +p4 add ./Lib/csharp/boost_shared_ptr.i +p4 add ./Lib/csharp/csharp.swg +p4 add ./Lib/csharp/csharphead.swg +p4 add ./Lib/csharp/csharpkw.swg +p4 add ./Lib/csharp/director.swg +p4 add ./Lib/csharp/enums.swg +p4 add ./Lib/csharp/enumsimple.swg +p4 add ./Lib/csharp/enumtypesafe.swg +p4 add ./Lib/csharp/std_common.i +p4 add ./Lib/csharp/std_deque.i +p4 add ./Lib/csharp/std_except.i +p4 add ./Lib/csharp/std_map.i +p4 add ./Lib/csharp/std_pair.i +p4 add ./Lib/csharp/std_string.i +p4 add ./Lib/csharp/std_vector.i +p4 add ./Lib/csharp/std_wstring.i +p4 add ./Lib/csharp/stl.i +p4 add ./Lib/csharp/typemaps.i +p4 add ./Lib/csharp/wchar.i +p4 add ./Lib/cstring.i +p4 add ./Lib/cwstring.i +p4 add ./Lib/exception.i +p4 add ./Lib/gcj/cni.i +p4 add ./Lib/gcj/cni.swg +p4 add ./Lib/gcj/javaprims.i +p4 add ./Lib/guile/common.scm +p4 add ./Lib/guile/cplusplus.i +p4 add ./Lib/guile/extra-install.list +p4 add ./Lib/guile/ghinterface.i +p4 add ./Lib/guile/guile.i +p4 add ./Lib/guile/guilemain.i +p4 add ./Lib/guile/guile_gh.swg +p4 add ./Lib/guile/guile_gh_run.swg +p4 add ./Lib/guile/guile_scm.swg +p4 add ./Lib/guile/guile_scm_run.swg +p4 add ./Lib/guile/interpreter.i +p4 add ./Lib/guile/list-vector.i +p4 add ./Lib/guile/Makefile +p4 add ./Lib/guile/pointer-in-out.i +p4 add ./Lib/guile/ports.i +p4 add ./Lib/guile/std_common.i +p4 add ./Lib/guile/std_deque.i +p4 add ./Lib/guile/std_except.i +p4 add ./Lib/guile/std_map.i +p4 add ./Lib/guile/std_pair.i +p4 add ./Lib/guile/std_string.i +p4 add ./Lib/guile/std_vector.i +p4 add ./Lib/guile/stl.i +p4 add ./Lib/guile/swigrun.i +p4 add ./Lib/guile/typemaps.i +p4 add ./Lib/inttypes.i +p4 add ./Lib/java/arrays_java.i +p4 add ./Lib/java/boost_shared_ptr.i +p4 add ./Lib/java/director.swg +p4 add ./Lib/java/enums.swg +p4 add ./Lib/java/enumsimple.swg +p4 add ./Lib/java/enumtypesafe.swg +p4 add ./Lib/java/enumtypeunsafe.swg +p4 add ./Lib/java/java.swg +p4 add ./Lib/java/javahead.swg +p4 add ./Lib/java/javakw.swg +p4 add ./Lib/java/std_common.i +p4 add ./Lib/java/std_deque.i +p4 add ./Lib/java/std_except.i +p4 add ./Lib/java/std_map.i +p4 add ./Lib/java/std_pair.i +p4 add ./Lib/java/std_string.i +p4 add ./Lib/java/std_vector.i +p4 add ./Lib/java/std_wstring.i +p4 add ./Lib/java/stl.i +p4 add ./Lib/java/typemaps.i +p4 add ./Lib/java/various.i +p4 add ./Lib/linkruntime.c +p4 add ./Lib/lua/carrays.i +p4 add ./Lib/lua/lua.swg +p4 add ./Lib/lua/luarun.swg +p4 add ./Lib/lua/luaruntime.swg +p4 add ./Lib/lua/luatypemaps.swg +p4 add ./Lib/lua/lua_fnptr.i +p4 add ./Lib/lua/std_common.i +p4 add ./Lib/lua/std_deque.i +p4 add ./Lib/lua/std_except.i +p4 add ./Lib/lua/std_map.i +p4 add ./Lib/lua/std_pair.i +p4 add ./Lib/lua/std_string.i +p4 add ./Lib/lua/std_vector.i +p4 add ./Lib/lua/stl.i +p4 add ./Lib/lua/typemaps.i +p4 add ./Lib/lua/wchar.i +p4 add ./Lib/lua/_std_common.i +p4 add ./Lib/math.i +p4 add ./Lib/modula3/modula3.swg +p4 add ./Lib/modula3/modula3head.swg +p4 add ./Lib/modula3/typemaps.i +p4 add ./Lib/mzscheme/Makefile +p4 add ./Lib/mzscheme/mzrun.swg +p4 add ./Lib/mzscheme/mzscheme.swg +p4 add ./Lib/mzscheme/std_common.i +p4 add ./Lib/mzscheme/std_deque.i +p4 add ./Lib/mzscheme/std_map.i +p4 add ./Lib/mzscheme/std_pair.i +p4 add ./Lib/mzscheme/std_string.i +p4 add ./Lib/mzscheme/std_vector.i +p4 add ./Lib/mzscheme/stl.i +p4 add ./Lib/mzscheme/typemaps.i +p4 add ./Lib/ocaml/carray.i +p4 add ./Lib/ocaml/class.swg +p4 add ./Lib/ocaml/cstring.i +p4 add ./Lib/ocaml/director.swg +p4 add ./Lib/ocaml/extra-install.list +p4 add ./Lib/ocaml/libswigocaml.h +p4 add ./Lib/ocaml/ocaml.i +p4 add ./Lib/ocaml/ocaml.swg +p4 add ./Lib/ocaml/ocamldec.swg +p4 add ./Lib/ocaml/ocamlkw.swg +p4 add ./Lib/ocaml/preamble.swg +p4 add ./Lib/ocaml/std_common.i +p4 add ./Lib/ocaml/std_complex.i +p4 add ./Lib/ocaml/std_deque.i +p4 add ./Lib/ocaml/std_list.i +p4 add ./Lib/ocaml/std_map.i +p4 add ./Lib/ocaml/std_pair.i +p4 add ./Lib/ocaml/std_string.i +p4 add ./Lib/ocaml/std_vector.i +p4 add ./Lib/ocaml/stl.i +p4 add ./Lib/ocaml/swig.ml +p4 add ./Lib/ocaml/swig.mli +p4 add ./Lib/ocaml/swigp4.ml.in +p4 add ./Lib/ocaml/typecheck.i +p4 add ./Lib/ocaml/typemaps.i +p4 add ./Lib/ocaml/typeregister.swg +p4 add ./Lib/perl5/attribute.i +p4 add ./Lib/perl5/carrays.i +p4 add ./Lib/perl5/cdata.i +p4 add ./Lib/perl5/cmalloc.i +p4 add ./Lib/perl5/cni.i +p4 add ./Lib/perl5/cpointer.i +p4 add ./Lib/perl5/cstring.i +p4 add ./Lib/perl5/exception.i +p4 add ./Lib/perl5/extra-install.list +p4 add ./Lib/perl5/factory.i +p4 add ./Lib/perl5/jstring.i +p4 add ./Lib/perl5/Makefile.in +p4 add ./Lib/perl5/Makefile.pl +p4 add ./Lib/perl5/noembed.h +p4 add ./Lib/perl5/perl5.swg +p4 add ./Lib/perl5/perlerrors.swg +p4 add ./Lib/perl5/perlfragments.swg +p4 add ./Lib/perl5/perlhead.swg +p4 add ./Lib/perl5/perlinit.swg +p4 add ./Lib/perl5/perlkw.swg +p4 add ./Lib/perl5/perlmacros.swg +p4 add ./Lib/perl5/perlmain.i +p4 add ./Lib/perl5/perlopers.swg +p4 add ./Lib/perl5/perlprimtypes.swg +p4 add ./Lib/perl5/perlrun.swg +p4 add ./Lib/perl5/perlruntime.swg +p4 add ./Lib/perl5/perlstrings.swg +p4 add ./Lib/perl5/perltypemaps.swg +p4 add ./Lib/perl5/perluserdir.swg +p4 add ./Lib/perl5/reference.i +p4 add ./Lib/perl5/std_common.i +p4 add ./Lib/perl5/std_deque.i +p4 add ./Lib/perl5/std_except.i +p4 add ./Lib/perl5/std_list.i +p4 add ./Lib/perl5/std_map.i +p4 add ./Lib/perl5/std_pair.i +p4 add ./Lib/perl5/std_string.i +p4 add ./Lib/perl5/std_vector.i +p4 add ./Lib/perl5/stl.i +p4 add ./Lib/perl5/typemaps.i +p4 add ./Lib/php4/const.i +p4 add ./Lib/php4/globalvar.i +p4 add ./Lib/php4/php4.swg +p4 add ./Lib/php4/php4init.swg +p4 add ./Lib/php4/php4kw.swg +p4 add ./Lib/php4/php4run.swg +p4 add ./Lib/php4/phppointers.i +p4 add ./Lib/php4/std_common.i +p4 add ./Lib/php4/std_deque.i +p4 add ./Lib/php4/std_map.i +p4 add ./Lib/php4/std_pair.i +p4 add ./Lib/php4/std_string.i +p4 add ./Lib/php4/std_vector.i +p4 add ./Lib/php4/stl.i +p4 add ./Lib/php4/typemaps.i +p4 add ./Lib/php4/utils.i +p4 add ./Lib/pike/pike.swg +p4 add ./Lib/pike/pikekw.swg +p4 add ./Lib/pike/pikerun.swg +p4 add ./Lib/pike/std_string.i +p4 add ./Lib/pointer.i +p4 add ./Lib/python/argcargv.i +p4 add ./Lib/python/attribute.i +p4 add ./Lib/python/boost_shared_ptr.i +p4 add ./Lib/python/carrays.i +p4 add ./Lib/python/ccomplex.i +p4 add ./Lib/python/cdata.i +p4 add ./Lib/python/cmalloc.i +p4 add ./Lib/python/cni.i +p4 add ./Lib/python/complex.i +p4 add ./Lib/python/cpointer.i +p4 add ./Lib/python/cstring.i +p4 add ./Lib/python/cwstring.i +p4 add ./Lib/python/defarg.swg +p4 add ./Lib/python/director.swg +p4 add ./Lib/python/embed.i +p4 add ./Lib/python/embed15.i +p4 add ./Lib/python/exception.i +p4 add ./Lib/python/factory.i +p4 add ./Lib/python/file.i +p4 add ./Lib/python/implicit.i +p4 add ./Lib/python/jstring.i +p4 add ./Lib/python/Makefile.in +p4 add ./Lib/python/pyapi.swg +p4 add ./Lib/python/pybackward.swg +p4 add ./Lib/python/pyclasses.swg +p4 add ./Lib/python/pycomplex.swg +p4 add ./Lib/python/pycontainer.swg +p4 add ./Lib/python/pydocs.swg +p4 add ./Lib/python/pyerrors.swg +p4 add ./Lib/python/pyfragments.swg +p4 add ./Lib/python/pyhead.swg +p4 add ./Lib/python/pyinit.swg +p4 add ./Lib/python/pyiterators.swg +p4 add ./Lib/python/pymacros.swg +p4 add ./Lib/python/pyopers.swg +p4 add ./Lib/python/pyprimtypes.swg +p4 add ./Lib/python/pyrun.swg +p4 add ./Lib/python/pyruntime.swg +p4 add ./Lib/python/pystdcommon.swg +p4 add ./Lib/python/pystrings.swg +p4 add ./Lib/python/python.swg +p4 add ./Lib/python/pythonkw.swg +p4 add ./Lib/python/pythreads.swg +p4 add ./Lib/python/pytuplehlp.swg +p4 add ./Lib/python/pytypemaps.swg +p4 add ./Lib/python/pyuserdir.swg +p4 add ./Lib/python/pywstrings.swg +p4 add ./Lib/python/README +p4 add ./Lib/python/std_alloc.i +p4 add ./Lib/python/std_basic_string.i +p4 add ./Lib/python/std_carray.i +p4 add ./Lib/python/std_char_traits.i +p4 add ./Lib/python/std_common.i +p4 add ./Lib/python/std_complex.i +p4 add ./Lib/python/std_container.i +p4 add ./Lib/python/std_deque.i +p4 add ./Lib/python/std_except.i +p4 add ./Lib/python/std_ios.i +p4 add ./Lib/python/std_iostream.i +p4 add ./Lib/python/std_list.i +p4 add ./Lib/python/std_map.i +p4 add ./Lib/python/std_multimap.i +p4 add ./Lib/python/std_multiset.i +p4 add ./Lib/python/std_pair.i +p4 add ./Lib/python/std_set.i +p4 add ./Lib/python/std_sstream.i +p4 add ./Lib/python/std_streambuf.i +p4 add ./Lib/python/std_string.i +p4 add ./Lib/python/std_vector.i +p4 add ./Lib/python/std_vectora.i +p4 add ./Lib/python/std_wios.i +p4 add ./Lib/python/std_wiostream.i +p4 add ./Lib/python/std_wsstream.i +p4 add ./Lib/python/std_wstreambuf.i +p4 add ./Lib/python/std_wstring.i +p4 add ./Lib/python/stl.i +p4 add ./Lib/python/typemaps.i +p4 add ./Lib/python/wchar.i +p4 add ./Lib/r/cdata.i +p4 add ./Lib/r/exception.i +p4 add ./Lib/r/r.swg +p4 add ./Lib/r/rcontainer.swg +p4 add ./Lib/r/rfragments.swg +p4 add ./Lib/r/ropers.swg +p4 add ./Lib/r/rrun.swg +p4 add ./Lib/r/rstdcommon.swg +p4 add ./Lib/r/rtype.swg +p4 add ./Lib/r/srun.swg +p4 add ./Lib/r/std_alloc.i +p4 add ./Lib/r/std_common.i +p4 add ./Lib/r/std_container.i +p4 add ./Lib/r/std_deque.i +p4 add ./Lib/r/std_except.i +p4 add ./Lib/r/std_pair.i +p4 add ./Lib/r/std_string.i +p4 add ./Lib/r/std_vector.i +p4 add ./Lib/r/stl.i +p4 add ./Lib/r/typemaps.i +p4 add ./Lib/ruby/argcargv.i +p4 add ./Lib/ruby/attribute.i +p4 add ./Lib/ruby/carrays.i +p4 add ./Lib/ruby/cdata.i +p4 add ./Lib/ruby/cmalloc.i +p4 add ./Lib/ruby/cni.i +p4 add ./Lib/ruby/cpointer.i +p4 add ./Lib/ruby/cstring.i +p4 add ./Lib/ruby/director.swg +p4 add ./Lib/ruby/embed.i +p4 add ./Lib/ruby/exception.i +p4 add ./Lib/ruby/extconf.rb +p4 add ./Lib/ruby/extra-install.list +p4 add ./Lib/ruby/factory.i +p4 add ./Lib/ruby/file.i +p4 add ./Lib/ruby/jstring.i +p4 add ./Lib/ruby/Makefile.swig +p4 add ./Lib/ruby/progargcargv.i +p4 add ./Lib/ruby/ruby.swg +p4 add ./Lib/ruby/rubyapi.swg +p4 add ./Lib/ruby/rubyautodoc.swg +p4 add ./Lib/ruby/rubyclasses.swg +p4 add ./Lib/ruby/rubycomplex.swg +p4 add ./Lib/ruby/rubycontainer.swg +p4 add ./Lib/ruby/rubycontainer_extended.swg +p4 add ./Lib/ruby/rubydef.swg +p4 add ./Lib/ruby/rubyerrors.swg +p4 add ./Lib/ruby/rubyfragments.swg +p4 add ./Lib/ruby/rubyhead.swg +p4 add ./Lib/ruby/rubyinit.swg +p4 add ./Lib/ruby/rubyiterators.swg +p4 add ./Lib/ruby/rubykw.swg +p4 add ./Lib/ruby/rubymacros.swg +p4 add ./Lib/ruby/rubyopers.swg +p4 add ./Lib/ruby/rubyprimtypes.swg +p4 add ./Lib/ruby/rubyrun.swg +p4 add ./Lib/ruby/rubyruntime.swg +p4 add ./Lib/ruby/rubystdautodoc.swg +p4 add ./Lib/ruby/rubystdcommon.swg +p4 add ./Lib/ruby/rubystdfunctors.swg +p4 add ./Lib/ruby/rubystrings.swg +p4 add ./Lib/ruby/rubytracking.swg +p4 add ./Lib/ruby/rubytypemaps.swg +p4 add ./Lib/ruby/rubyuserdir.swg +p4 add ./Lib/ruby/rubywstrings.swg +p4 add ./Lib/ruby/std_alloc.i +p4 add ./Lib/ruby/std_basic_string.i +p4 add ./Lib/ruby/std_char_traits.i +p4 add ./Lib/ruby/std_common.i +p4 add ./Lib/ruby/std_complex.i +p4 add ./Lib/ruby/std_container.i +p4 add ./Lib/ruby/std_deque.i +p4 add ./Lib/ruby/std_except.i +p4 add ./Lib/ruby/std_functors.i +p4 add ./Lib/ruby/std_ios.i +p4 add ./Lib/ruby/std_iostream.i +p4 add ./Lib/ruby/std_list.i +p4 add ./Lib/ruby/std_map.i +p4 add ./Lib/ruby/std_multimap.i +p4 add ./Lib/ruby/std_multiset.i +p4 add ./Lib/ruby/std_pair.i +p4 add ./Lib/ruby/std_queue.i +p4 add ./Lib/ruby/std_set.i +p4 add ./Lib/ruby/std_sstream.i +p4 add ./Lib/ruby/std_stack.i +p4 add ./Lib/ruby/std_streambuf.i +p4 add ./Lib/ruby/std_string.i +p4 add ./Lib/ruby/std_vector.i +p4 add ./Lib/ruby/std_vectora.i +p4 add ./Lib/ruby/std_wstring.i +p4 add ./Lib/ruby/stl.i +p4 add ./Lib/ruby/timeval.i +p4 add ./Lib/ruby/typemaps.i +p4 add ./Lib/runtime.swg +p4 add ./Lib/shared_ptr.i +p4 add ./Lib/std/README +p4 add ./Lib/std/std_alloc.i +p4 add ./Lib/std/std_basic_string.i +p4 add ./Lib/std/std_carray.swg +p4 add ./Lib/std/std_char_traits.i +p4 add ./Lib/std/std_common.i +p4 add ./Lib/std/std_container.i +p4 add ./Lib/std/std_deque.i +p4 add ./Lib/std/std_except.i +p4 add ./Lib/std/std_ios.i +p4 add ./Lib/std/std_iostream.i +p4 add ./Lib/std/std_list.i +p4 add ./Lib/std/std_map.i +p4 add ./Lib/std/std_multimap.i +p4 add ./Lib/std/std_multiset.i +p4 add ./Lib/std/std_pair.i +p4 add ./Lib/std/std_queue.i +p4 add ./Lib/std/std_set.i +p4 add ./Lib/std/std_sstream.i +p4 add ./Lib/std/std_stack.i +p4 add ./Lib/std/std_streambuf.i +p4 add ./Lib/std/std_string.i +p4 add ./Lib/std/std_vector.i +p4 add ./Lib/std/std_vectora.i +p4 add ./Lib/std/std_wios.i +p4 add ./Lib/std/std_wiostream.i +p4 add ./Lib/std/std_wsstream.i +p4 add ./Lib/std/std_wstreambuf.i +p4 add ./Lib/std/std_wstring.i +p4 add ./Lib/std/_std_deque.i +p4 add ./Lib/stdint.i +p4 add ./Lib/std_except.i +p4 add ./Lib/stl.i +p4 add ./Lib/swig.swg +p4 add ./Lib/swigarch.i +p4 add ./Lib/swigerrors.swg +p4 add ./Lib/swiginit.swg +p4 add ./Lib/swiglabels.swg +p4 add ./Lib/swigrun.i +p4 add ./Lib/swigrun.swg +p4 add ./Lib/swigwarn.swg +p4 add ./Lib/swigwarnings.swg +p4 add ./Lib/tcl/attribute.i +p4 add ./Lib/tcl/carrays.i +p4 add ./Lib/tcl/cdata.i +p4 add ./Lib/tcl/cmalloc.i +p4 add ./Lib/tcl/cni.i +p4 add ./Lib/tcl/cpointer.i +p4 add ./Lib/tcl/cstring.i +p4 add ./Lib/tcl/cwstring.i +p4 add ./Lib/tcl/exception.i +p4 add ./Lib/tcl/factory.i +p4 add ./Lib/tcl/jstring.i +p4 add ./Lib/tcl/mactclinit.c +p4 add ./Lib/tcl/mactkinit.c +p4 add ./Lib/tcl/Makefile.in +p4 add ./Lib/tcl/std_common.i +p4 add ./Lib/tcl/std_deque.i +p4 add ./Lib/tcl/std_except.i +p4 add ./Lib/tcl/std_map.i +p4 add ./Lib/tcl/std_pair.i +p4 add ./Lib/tcl/std_string.i +p4 add ./Lib/tcl/std_vector.i +p4 add ./Lib/tcl/std_wstring.i +p4 add ./Lib/tcl/stl.i +p4 add ./Lib/tcl/tcl8.swg +p4 add ./Lib/tcl/tclapi.swg +p4 add ./Lib/tcl/tclerrors.swg +p4 add ./Lib/tcl/tclfragments.swg +p4 add ./Lib/tcl/tclinit.swg +p4 add ./Lib/tcl/tclinterp.i +p4 add ./Lib/tcl/tclkw.swg +p4 add ./Lib/tcl/tclmacros.swg +p4 add ./Lib/tcl/tclopers.swg +p4 add ./Lib/tcl/tclprimtypes.swg +p4 add ./Lib/tcl/tclresult.i +p4 add ./Lib/tcl/tclrun.swg +p4 add ./Lib/tcl/tclruntime.swg +p4 add ./Lib/tcl/tclsh.i +p4 add ./Lib/tcl/tclstrings.swg +p4 add ./Lib/tcl/tcltypemaps.swg +p4 add ./Lib/tcl/tcluserdir.swg +p4 add ./Lib/tcl/tclwstrings.swg +p4 add ./Lib/tcl/typemaps.i +p4 add ./Lib/tcl/wish.i +p4 add ./Lib/typemaps/attribute.swg +p4 add ./Lib/typemaps/carrays.swg +p4 add ./Lib/typemaps/cdata.swg +p4 add ./Lib/typemaps/cmalloc.swg +p4 add ./Lib/typemaps/cpointer.swg +p4 add ./Lib/typemaps/cstring.swg +p4 add ./Lib/typemaps/cstrings.swg +p4 add ./Lib/typemaps/cwstring.swg +p4 add ./Lib/typemaps/enumint.swg +p4 add ./Lib/typemaps/exception.swg +p4 add ./Lib/typemaps/factory.swg +p4 add ./Lib/typemaps/fragments.swg +p4 add ./Lib/typemaps/implicit.swg +p4 add ./Lib/typemaps/inoutlist.swg +p4 add ./Lib/typemaps/misctypes.swg +p4 add ./Lib/typemaps/primtypes.swg +p4 add ./Lib/typemaps/ptrtypes.swg +p4 add ./Lib/typemaps/README +p4 add ./Lib/typemaps/std_except.swg +p4 add ./Lib/typemaps/std_string.swg +p4 add ./Lib/typemaps/std_strings.swg +p4 add ./Lib/typemaps/std_wstring.swg +p4 add ./Lib/typemaps/string.swg +p4 add ./Lib/typemaps/strings.swg +p4 add ./Lib/typemaps/swigmacros.swg +p4 add ./Lib/typemaps/swigobject.swg +p4 add ./Lib/typemaps/swigtype.swg +p4 add ./Lib/typemaps/swigtypemaps.swg +p4 add ./Lib/typemaps/traits.swg +p4 add ./Lib/typemaps/typemaps.swg +p4 add ./Lib/typemaps/valtypes.swg +p4 add ./Lib/typemaps/void.swg +p4 add ./Lib/typemaps/wstring.swg +p4 add ./Lib/uffi/uffi.swg +p4 add ./Lib/wchar.i +p4 add ./Lib/windows.i +p4 add ./Lib/xml/typemaps.i +p4 add ./Lib/xml/xml.swg +p4 add ./swig.exe diff --git a/devtools/swigwin-1.3.34/swig.exe b/devtools/swigwin-1.3.34/swig.exe Binary files differnew file mode 100644 index 0000000..0d9e091 --- /dev/null +++ b/devtools/swigwin-1.3.34/swig.exe |