update to swig 4.0.0 on linux
This commit is contained in:
@@ -1,615 +0,0 @@
|
||||
/* 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";
|
||||
#ifdef __cplusplus
|
||||
%typemap(lout) SWIGTYPE[ANY], SWIGTYPE *, 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))";
|
||||
#else
|
||||
%typemap(lout) SWIGTYPE[ANY], SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE
|
||||
%{ (cl:let* ((address $body)
|
||||
(new-inst (cl:make-instance '$lclass :foreign-address address)))
|
||||
(cl:setq ACL_ffresult new-inst)) %}
|
||||
#endif
|
||||
|
||||
%typemap(lisptype) bool, const bool "cl:boolean";
|
||||
%typemap(lisptype) char, const char "cl:character";
|
||||
%typemap(lisptype) unsigned char, const unsigned char "cl:integer";
|
||||
%typemap(lisptype) signed char, const signed char "cl:integer";
|
||||
|
||||
%typemap(ffitype) bool, const bool ":int";
|
||||
%typemap(ffitype) char, const char,
|
||||
signed char, const signed char ":char";
|
||||
%typemap(ffitype) unsigned char, const unsigned char ":unsigned-char";
|
||||
%typemap(ffitype) short, const short,
|
||||
signed short, const signed short ":short";
|
||||
%typemap(ffitype) unsigned short, const unsigned short ":unsigned-short";
|
||||
%typemap(ffitype) int, const int, signed int, const signed int ":int";
|
||||
%typemap(ffitype) unsigned int, const unsigned int ":unsigned-int";
|
||||
%typemap(ffitype) long, const long, signed long, const signed long ":long";
|
||||
%typemap(ffitype) unsigned long, const unsigned long ":unsigned-long";
|
||||
%typemap(ffitype) float, const float ":float";
|
||||
%typemap(ffitype) double, const double ":double";
|
||||
%typemap(ffitype) char *, const char *, signed char *,
|
||||
const signed char *, signed char &,
|
||||
const signed char & "(* :char)";
|
||||
%typemap(ffitype) unsigned char *, const unsigned char *,
|
||||
unsigned char &, const unsigned char & "(* :unsigned-char)";
|
||||
%typemap(ffitype) short *, const short *, short &,
|
||||
const short & "(* :short)";
|
||||
%typemap(ffitype) unsigned short *, const unsigned short *,
|
||||
unsigned short &, const unsigned short & "(* :unsigned-short)";
|
||||
%typemap(ffitype) int *, const int *, int &, const int & "(* :int)";
|
||||
%typemap(ffitype) unsigned int *, const unsigned int *,
|
||||
unsigned int &, const unsigned int & "(* :unsigned-int)";
|
||||
%typemap(ffitype) void * "(* :void)";
|
||||
%typemap(ffitype) void ":void";
|
||||
%typemap(ffitype) enum SWIGTYPE ":int";
|
||||
%typemap(ffitype) SWIGTYPE & "(* :void)";
|
||||
%typemap(ffitype) SWIGTYPE && "(* :void)";
|
||||
|
||||
/* const typemaps
|
||||
idea: marshall all primitive c types to their respective lisp types
|
||||
to maintain const corretness. For pointers/references, all bets
|
||||
are off if you try to modify them.
|
||||
|
||||
idea: add a constant-p slot to the base foreign-pointer class. For
|
||||
constant pointer/references check this value when setting (around method?)
|
||||
and error if a setf operation is performed on the address of this object.
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
%exception %{
|
||||
try {
|
||||
$action
|
||||
} catch (...) {
|
||||
return $null;
|
||||
}
|
||||
%}
|
||||
|
||||
*/
|
||||
|
||||
// %typemap(throws) SWIGTYPE {
|
||||
// (void)$1;
|
||||
// SWIG_fail;
|
||||
// }
|
||||
|
||||
%typemap(ctype) bool, const 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[],
|
||||
SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE &&, const 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[],
|
||||
SWIGTYPE[ANY], SWIGTYPE &, 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 &&,
|
||||
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) void "";
|
||||
%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 *,
|
||||
enum SWIGTYPE, SWIGTYPE *,
|
||||
SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE && "$result = $1;";
|
||||
#ifdef __cplusplus
|
||||
%typemap(out) SWIGTYPE "$result = new $1_ltype($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";
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
/* Array reference typemaps */
|
||||
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
|
||||
%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
|
||||
|
||||
/* const pointers */
|
||||
%apply SWIGTYPE * { SWIGTYPE *const }
|
||||
%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
|
||||
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
|
||||
|
||||
/* 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[];
|
||||
|
||||
%rename(__bool__) *::operator bool();
|
||||
%rename(__bool__) *::operator bool() const;
|
||||
#endif
|
||||
|
||||
%insert("lisphead") %{
|
||||
(eval-when (:compile-toplevel :load-toplevel :execute)
|
||||
|
||||
;; 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)
|
||||
; We need some kind of a hack here to handle template classes
|
||||
; and other synonym types right. We need the original name.
|
||||
(let*( (sym (read-symbol-from-string
|
||||
(if (eq *swig-identifier-converter* 'identifier-convert-lispify)
|
||||
(string-lispify id)
|
||||
id)))
|
||||
(sym-class (find-class sym nil))
|
||||
(id (cond ( (not sym-class)
|
||||
id )
|
||||
( (and sym-class
|
||||
(not (eq (class-name sym-class)
|
||||
sym)))
|
||||
(class-name sym-class) )
|
||||
( t
|
||||
id ))) )
|
||||
(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 string-lispify (str)
|
||||
(cl::let ( (cname (excl::replace-regexp str "_" "-"))
|
||||
(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::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)))
|
||||
(cl::coerce (cl::nreverse res) 'string)))
|
||||
|
||||
(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)))
|
||||
(read-symbol-from-string (string-lispify cname)))
|
||||
|
||||
(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-toplevel :load-toplevel :execute)
|
||||
(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-toplevel :load-toplevel :execute)
|
||||
(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-toplevel :load-toplevel :execute)
|
||||
(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-toplevel :load-toplevel :execute)
|
||||
(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-toplevel :load-toplevel :execute)
|
||||
(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-toplevel :load-toplevel :execute)
|
||||
(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-toplevel :load-toplevel :execute)
|
||||
(ff:def-foreign-type ,symbol ,@rest))))
|
||||
|
||||
(defswig2 swig-def-synonym-type (synonym of ff-synonym)
|
||||
`(cl::eval-when (:compile-toplevel :load-toplevel :execute)
|
||||
(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-toplevel :load-toplevel :execute)
|
||||
(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-toplevel :load-toplevel :execute)
|
||||
(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-toplevel :load-toplevel :execute)
|
||||
(ff:def-foreign-variable (,symbol ,mangled-name) :type ,ftype))))
|
||||
|
||||
) ;; eval-when
|
||||
|
||||
(cl::eval-when (:compile-toplevel :execute)
|
||||
(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))))
|
||||
|
||||
%}
|
||||
|
||||
typedef void *__SWIGACL_FwdReference;
|
||||
|
||||
%{
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define EXTERN extern "C"
|
||||
#else
|
||||
# define EXTERN extern
|
||||
#endif
|
||||
|
||||
#define EXPORT EXTERN SWIGEXPORT
|
||||
|
||||
typedef void *__SWIGACL_FwdReference;
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
%}
|
||||
@@ -1,111 +0,0 @@
|
||||
/* 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));
|
||||
@@ -1,49 +0,0 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef Acl64Bit
|
||||
%typemap(ctype) long long, unsigned long long "$1_ltype";
|
||||
%typemap(out) long long, unsigned long long "$result = $1;";
|
||||
|
||||
%typemap(ffitype) long long ":nat";
|
||||
%typemap(ffitype) unsigned long long ":unsigned-nat";
|
||||
|
||||
%typemap(lout) long long, unsigned long long " #+64bit (cl::setq ACL_ffresult $body)";
|
||||
|
||||
#else
|
||||
%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
|
||||
" (cl::setq ACL_ffresult (make-instance '#.(swig-insert-id \"longlong\" () :type :class)
|
||||
:foreign-address $body))";
|
||||
|
||||
%typemap(lout) unsigned long long
|
||||
" (cl:setq ACL_ffresult (make-instance '#.(swig-insert-id \"ulonglong\" () :type :class)
|
||||
:foreign-address $body))";
|
||||
|
||||
#endif
|
||||
|
||||
%typemap(in) long long, unsigned long long "$1 = $input;";
|
||||
|
||||
|
||||
%insert("lisphead") %{
|
||||
|
||||
#-64bit
|
||||
(swig-def-foreign-class "longlong"
|
||||
(ff:foreign-pointer)
|
||||
(:struct (l1 :long) (l2 :long)))
|
||||
|
||||
#-64bit
|
||||
(swig-def-foreign-class "ulonglong"
|
||||
(ff:foreign-pointer)
|
||||
(:struct (l1 :unsigned-long) (l2 :unsigned-long)))
|
||||
%}
|
||||
@@ -1,230 +0,0 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* 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();
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,209 +0,0 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* 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 <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 & ($*1_ltype 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 & ($*1_ltype 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 * ($*1_ltype *temp) {
|
||||
// if (caml_ptr_check($input)) {
|
||||
// temp = new $*1_ltype((char *)caml_ptr_val($input,0),
|
||||
// caml_string_len($input));
|
||||
// $1 = temp;
|
||||
// } else {
|
||||
// SWIG_exception(SWIG_TypeError, "string expected");
|
||||
// }
|
||||
// }
|
||||
|
||||
// %typemap(free) string * ($*1_ltype *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
|
||||
@@ -1,4 +0,0 @@
|
||||
/* Unused for Allegro CL module */
|
||||
|
||||
%include "inout_typemaps.i"
|
||||
%include "longlongs.i"
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
*/
|
||||
|
||||
%include <chicken/chickenkw.swg>
|
||||
%include <csharp/csharpkw.swg>
|
||||
%include <d/dkw.swg>
|
||||
%include <go/gokw.swg>
|
||||
@@ -25,7 +24,6 @@
|
||||
%include <ocaml/ocamlkw.swg>
|
||||
%include <perl5/perlkw.swg>
|
||||
%include <php/phpkw.swg>
|
||||
%include <pike/pikekw.swg>
|
||||
%include <python/pythonkw.swg>
|
||||
%include <r/rkw.swg>
|
||||
%include <ruby/rubykw.swg>
|
||||
|
||||
@@ -21,14 +21,6 @@ typedef struct SWIGCDATA {
|
||||
}
|
||||
%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);
|
||||
|
||||
#elif SWIGPHP7
|
||||
|
||||
%typemap(out) SWIGCDATA {
|
||||
|
||||
@@ -1,294 +0,0 @@
|
||||
/* 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 &, 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 &, SWIGTYPE && "$1 = $input;";
|
||||
%typemap(in) SWIGTYPE "$1 = *$input;";
|
||||
|
||||
%typemap(out) void "";
|
||||
%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 *,
|
||||
enum SWIGTYPE, SWIGTYPE *,
|
||||
SWIGTYPE[ANY], SWIGTYPE &, 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 &&,
|
||||
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";
|
||||
/* CLOS methods can't be specialized on single-float or double-float */
|
||||
%typemap(lispclass) float "cl:number";
|
||||
%typemap(lispclass) double "cl:number";
|
||||
%typemap(lispclass) char * "cl:string";
|
||||
|
||||
/* Array reference typemaps */
|
||||
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
|
||||
%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
|
||||
|
||||
/* const pointers */
|
||||
%apply SWIGTYPE * { SWIGTYPE *const }
|
||||
%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
|
||||
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
|
||||
|
||||
%{
|
||||
|
||||
#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 (cl:&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>
|
||||
%}
|
||||
@@ -1,811 +0,0 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* chicken.swg
|
||||
*
|
||||
* CHICKEN configuration module.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* chicken.h has to appear first. */
|
||||
|
||||
%insert(runtime) %{
|
||||
#include <assert.h>
|
||||
#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& };
|
||||
%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 &, 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,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 &&, 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);
|
||||
}
|
||||
|
||||
%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((const $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((const $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 &&, SWIGTYPE []
|
||||
"static const void *$result = (void*) $value;"
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* String & length
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t 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 &&, 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);
|
||||
}
|
||||
}
|
||||
|
||||
%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);
|
||||
}
|
||||
|
||||
%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 };
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Various
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
/* Array reference typemaps */
|
||||
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
|
||||
%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
|
||||
|
||||
/* const pointers */
|
||||
%apply SWIGTYPE * { SWIGTYPE *const }
|
||||
%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
|
||||
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* 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);
|
||||
|
||||
%}
|
||||
@@ -1,31 +0,0 @@
|
||||
#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_
|
||||
@@ -1,374 +0,0 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* chickenrun.swg
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include <chicken.h>
|
||||
#include <assert.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(clientdata)
|
||||
#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(void *SWIGUNUSEDPARM(clientdata)) {
|
||||
swig_module_info *ret = 0;
|
||||
C_word sym;
|
||||
|
||||
/* lookup the type pointer... it is stored in its 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 its 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
|
||||
@@ -1,152 +0,0 @@
|
||||
;; 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 chicken-users@nongnu.org or to
|
||||
;; 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)
|
||||
@@ -1,96 +0,0 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* 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& ($*1_ltype 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());
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
(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)))))
|
||||
@@ -1,150 +0,0 @@
|
||||
# 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 chicken-users@nongnu.org
|
||||
|
||||
# Patch written by John Lenz <lenz@cs.wisc.edu>
|
||||
|
||||
--- 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>))
|
||||
@@ -1,314 +0,0 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* 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);
|
||||
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// 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;
|
||||
@@ -1,32 +0,0 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* 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";
|
||||
@@ -314,7 +314,7 @@
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE {
|
||||
%typemap(csdisposing, methodname="Dispose", methodmodifiers="protected", parameters="bool disposing") TYPE {
|
||||
lock(this) {
|
||||
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
|
||||
if (swigCMemOwnBase) {
|
||||
@@ -323,11 +323,10 @@
|
||||
}
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
global::System.GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE {
|
||||
%typemap(csdisposing_derived, methodname="Dispose", methodmodifiers="protected", parameters="bool disposing") TYPE {
|
||||
lock(this) {
|
||||
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
|
||||
if (swigCMemOwnDerived) {
|
||||
@@ -336,8 +335,7 @@
|
||||
}
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
global::System.GC.SuppressFinalize(this);
|
||||
base.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -473,7 +471,7 @@
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE {
|
||||
%typemap(csdisposing, methodname="Dispose", methodmodifiers="protected", parameters="bool disposing") TYPE {
|
||||
lock(this) {
|
||||
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
|
||||
if (swigCMemOwnBase) {
|
||||
@@ -482,11 +480,10 @@
|
||||
}
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
global::System.GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE {
|
||||
%typemap(csdisposing_derived, methodname="Dispose", methodmodifiers="protected", parameters="bool disposing") TYPE {
|
||||
lock(this) {
|
||||
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
|
||||
if (swigCMemOwnDerived) {
|
||||
@@ -495,8 +492,7 @@
|
||||
}
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
global::System.GC.SuppressFinalize(this);
|
||||
base.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -282,7 +282,7 @@
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE {
|
||||
%typemap(csdisposing, methodname="Dispose", methodmodifiers="protected", parameters="bool disposing") TYPE {
|
||||
lock(this) {
|
||||
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
|
||||
if (swigCMemOwnBase) {
|
||||
@@ -291,11 +291,10 @@
|
||||
}
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
global::System.GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE {
|
||||
%typemap(csdisposing_derived, methodname="Dispose", methodmodifiers="protected", parameters="bool disposing") TYPE {
|
||||
lock(this) {
|
||||
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
|
||||
if (swigCMemOwnDerived) {
|
||||
@@ -304,8 +303,7 @@
|
||||
}
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
global::System.GC.SuppressFinalize(this);
|
||||
base.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -959,17 +959,24 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
||||
SWIG_CSBODY_PROXY(internal, internal, SWIGTYPE)
|
||||
SWIG_CSBODY_TYPEWRAPPER(internal, protected, internal, SWIGTYPE)
|
||||
|
||||
%typemap(csfinalize) SWIGTYPE %{
|
||||
%typemap(csdispose) SWIGTYPE %{
|
||||
~$csclassname() {
|
||||
Dispose();
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
global::System.GC.SuppressFinalize(this);
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(csdispose_derived) SWIGTYPE ""
|
||||
|
||||
%typemap(csconstruct, excode=SWIGEXCODE,directorconnect="\n SwigDirectorConnect();") SWIGTYPE %{: this($imcall, true) {$excode$directorconnect
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") SWIGTYPE {
|
||||
%typemap(csdisposing, methodname="Dispose", methodmodifiers="protected", parameters="bool disposing") SWIGTYPE {
|
||||
lock(this) {
|
||||
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
|
||||
if (swigCMemOwn) {
|
||||
@@ -978,11 +985,10 @@ SWIG_CSBODY_TYPEWRAPPER(internal, protected, internal, SWIGTYPE)
|
||||
}
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
global::System.GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") SWIGTYPE {
|
||||
%typemap(csdisposing_derived, methodname="Dispose", methodmodifiers="protected", parameters="bool disposing") SWIGTYPE {
|
||||
lock(this) {
|
||||
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
|
||||
if (swigCMemOwn) {
|
||||
@@ -991,8 +997,7 @@ SWIG_CSBODY_TYPEWRAPPER(internal, protected, internal, SWIGTYPE)
|
||||
}
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
global::System.GC.SuppressFinalize(this);
|
||||
base.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -244,6 +244,7 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_$module(
|
||||
[global::System.ThreadStatic]
|
||||
private static global::System.Exception pendingException = null;
|
||||
private static int numExceptionsPending = 0;
|
||||
private static global::System.Object exceptionsLock = null;
|
||||
|
||||
public static bool Pending {
|
||||
get {
|
||||
@@ -259,7 +260,7 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_$module(
|
||||
if (pendingException != null)
|
||||
throw new global::System.ApplicationException("FATAL: An earlier pending exception from unmanaged code was missed and thus not thrown (" + pendingException.ToString() + ")", e);
|
||||
pendingException = e;
|
||||
lock(typeof($imclassname)) {
|
||||
lock(exceptionsLock) {
|
||||
numExceptionsPending++;
|
||||
}
|
||||
}
|
||||
@@ -270,13 +271,17 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_$module(
|
||||
if (pendingException != null) {
|
||||
e = pendingException;
|
||||
pendingException = null;
|
||||
lock(typeof($imclassname)) {
|
||||
lock(exceptionsLock) {
|
||||
numExceptionsPending--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
static SWIGPendingException() {
|
||||
exceptionsLock = new global::System.Object();
|
||||
}
|
||||
}
|
||||
%}
|
||||
#endif // SWIG_CSHARP_NO_EXCEPTION_HELPER
|
||||
|
||||
@@ -192,9 +192,9 @@
|
||||
else
|
||||
throw std::out_of_range("index");
|
||||
}
|
||||
void setitem(int index, const_reference value) throw (std::out_of_range) {
|
||||
void setitem(int index, const_reference val) throw (std::out_of_range) {
|
||||
if (index>=0 && index<(int)$self->size())
|
||||
(*$self)[index] = value;
|
||||
(*$self)[index] = val;
|
||||
else
|
||||
throw std::out_of_range("index");
|
||||
}
|
||||
|
||||
519
linx64/bin/swig/share/swig/4.0.0/csharp/std_list.i
Normal file
519
linx64/bin/swig/share/swig/4.0.0/csharp/std_list.i
Normal file
@@ -0,0 +1,519 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* std_list.i
|
||||
*
|
||||
* SWIG typemaps for std::list<T>
|
||||
* C# implementation
|
||||
* The C# wrapper is made to look and feel like a C# System.Collections.Generic.LinkedList<> collection.
|
||||
*
|
||||
* Note that IEnumerable<> is implemented in the proxy class which is useful for using LINQ with
|
||||
* C++ std::list wrappers. The ICollection<> interface is also implemented to provide enhanced functionality
|
||||
* whenever we are confident that the required C++ operator== is available. This is the case for when
|
||||
* T is a primitive type or a pointer. If T does define an operator==, then use the SWIG_STD_LIST_ENHANCED
|
||||
* macro to obtain this enhanced functionality, for example:
|
||||
*
|
||||
* SWIG_STD_LIST_ENHANCED(SomeNamespace::Klass)
|
||||
* %template(ListKlass) std::list<SomeNamespace::Klass>;
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_common.i>
|
||||
|
||||
// MACRO for use within the std::list class body
|
||||
%define SWIG_STD_LIST_MINIMUM_INTERNAL(CSINTERFACE, CTYPE...)
|
||||
%typemap(csinterfaces) std::list< CTYPE > "global::System.IDisposable, global::System.Collections.IEnumerable, global::System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n";
|
||||
|
||||
%apply void *VOID_INT_PTR { std::list< CTYPE >::iterator * };
|
||||
|
||||
%proxycode %{
|
||||
public $csclassname(global::System.Collections.IEnumerable c) : this() {
|
||||
if (c == null)
|
||||
throw new global::System.ArgumentNullException("c");
|
||||
foreach ($typemap(cstype, CTYPE) element in c) {
|
||||
this.AddLast(element);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReadOnly {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int Count {
|
||||
get {
|
||||
return (int)size();
|
||||
}
|
||||
}
|
||||
|
||||
public $csclassnameNode First {
|
||||
get {
|
||||
if (Count == 0)
|
||||
return null;
|
||||
return new $csclassnameNode(getFirstIter(), this);
|
||||
}
|
||||
}
|
||||
|
||||
public $csclassnameNode Last {
|
||||
get {
|
||||
if (Count == 0)
|
||||
return null;
|
||||
return new $csclassnameNode(getLastIter(), this);
|
||||
}
|
||||
}
|
||||
|
||||
public $csclassnameNode AddFirst($typemap(cstype, CTYPE) value) {
|
||||
push_front(value);
|
||||
return new $csclassnameNode(getFirstIter(), this);
|
||||
}
|
||||
|
||||
public void AddFirst($csclassnameNode newNode) {
|
||||
ValidateNewNode(newNode);
|
||||
if (!newNode.inlist) {
|
||||
push_front(newNode.csharpvalue);
|
||||
newNode.iter = getFirstIter();
|
||||
newNode.inlist = true;
|
||||
} else {
|
||||
throw new global::System.InvalidOperationException("The " + newNode.GetType().Name + " node already belongs to a " + this.GetType().Name);
|
||||
}
|
||||
}
|
||||
|
||||
public $csclassnameNode AddLast($typemap(cstype, CTYPE) value) {
|
||||
push_back(value);
|
||||
return new $csclassnameNode(getLastIter(), this);
|
||||
}
|
||||
|
||||
public void AddLast($csclassnameNode newNode) {
|
||||
ValidateNewNode(newNode);
|
||||
if (!newNode.inlist) {
|
||||
push_back(newNode.csharpvalue);
|
||||
newNode.iter = getLastIter();
|
||||
newNode.inlist = true;
|
||||
} else {
|
||||
throw new global::System.InvalidOperationException("The " + newNode.GetType().Name + " node already belongs to a " + this.GetType().Name);
|
||||
}
|
||||
}
|
||||
|
||||
public $csclassnameNode AddBefore($csclassnameNode node, $typemap(cstype, CTYPE) value) {
|
||||
return new $csclassnameNode(insertNode(node.iter, value), this);
|
||||
}
|
||||
|
||||
public void AddBefore($csclassnameNode node, $csclassnameNode newNode) {
|
||||
ValidateNode(node);
|
||||
ValidateNewNode(newNode);
|
||||
if (!newNode.inlist) {
|
||||
newNode.iter = insertNode(node.iter, newNode.csharpvalue);
|
||||
newNode.inlist = true;
|
||||
} else {
|
||||
throw new global::System.InvalidOperationException("The " + newNode.GetType().Name + " node already belongs to a " + this.GetType().Name);
|
||||
}
|
||||
}
|
||||
|
||||
public $csclassnameNode AddAfter($csclassnameNode node, $typemap(cstype, CTYPE) value) {
|
||||
node = node.Next;
|
||||
return new $csclassnameNode(insertNode(node.iter, value), this);
|
||||
}
|
||||
|
||||
public void AddAfter($csclassnameNode node, $csclassnameNode newNode) {
|
||||
ValidateNode(node);
|
||||
ValidateNewNode(newNode);
|
||||
if (!newNode.inlist) {
|
||||
if (node == this.Last)
|
||||
AddLast(newNode);
|
||||
else
|
||||
{
|
||||
node = node.Next;
|
||||
newNode.iter = insertNode(node.iter, newNode.csharpvalue);
|
||||
newNode.inlist = true;
|
||||
}
|
||||
} else {
|
||||
throw new global::System.InvalidOperationException("The " + newNode.GetType().Name + " node already belongs to a " + this.GetType().Name);
|
||||
}
|
||||
}
|
||||
|
||||
public void Add($typemap(cstype, CTYPE) value) {
|
||||
AddLast(value);
|
||||
}
|
||||
|
||||
public void Remove($csclassnameNode node) {
|
||||
ValidateNode(node);
|
||||
eraseIter(node.iter);
|
||||
}
|
||||
|
||||
public void CopyTo($typemap(cstype, CTYPE)[] array, int index) {
|
||||
if (array == null)
|
||||
throw new global::System.ArgumentNullException("array");
|
||||
if (index < 0 || index > array.Length)
|
||||
throw new global::System.ArgumentOutOfRangeException("index", "Value is less than zero");
|
||||
if (array.Rank > 1)
|
||||
throw new global::System.ArgumentException("Multi dimensional array.", "array");
|
||||
$csclassnameNode node = this.First;
|
||||
if (node != null) {
|
||||
do {
|
||||
array[index++] = node.Value;
|
||||
node = node.Next;
|
||||
} while (node != null);
|
||||
}
|
||||
}
|
||||
|
||||
internal void ValidateNode($csclassnameNode node) {
|
||||
if (node == null) {
|
||||
throw new System.ArgumentNullException("node");
|
||||
}
|
||||
if (!node.inlist || node.list != this) {
|
||||
throw new System.InvalidOperationException("node");
|
||||
}
|
||||
}
|
||||
|
||||
internal void ValidateNewNode($csclassnameNode node) {
|
||||
if (node == null) {
|
||||
throw new System.ArgumentNullException("node");
|
||||
}
|
||||
}
|
||||
|
||||
global::System.Collections.Generic.IEnumerator<$typemap(cstype, CTYPE)> global::System.Collections.Generic.IEnumerable<$typemap(cstype, CTYPE)>.GetEnumerator() {
|
||||
return new $csclassnameEnumerator(this);
|
||||
}
|
||||
|
||||
global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() {
|
||||
return new $csclassnameEnumerator(this);
|
||||
}
|
||||
|
||||
public $csclassnameEnumerator GetEnumerator() {
|
||||
return new $csclassnameEnumerator(this);
|
||||
}
|
||||
|
||||
public sealed class $csclassnameEnumerator : global::System.Collections.IEnumerator,
|
||||
global::System.Collections.Generic.IEnumerator<$typemap(cstype, CTYPE)>
|
||||
{
|
||||
private $csclassname collectionRef;
|
||||
private $csclassnameNode currentNode;
|
||||
private int currentIndex;
|
||||
private object currentObject;
|
||||
private int currentSize;
|
||||
|
||||
public $csclassnameEnumerator($csclassname collection) {
|
||||
collectionRef = collection;
|
||||
currentNode = collection.First;
|
||||
currentIndex = 0;
|
||||
currentObject = null;
|
||||
currentSize = collectionRef.Count;
|
||||
}
|
||||
|
||||
// Type-safe iterator Current
|
||||
public $typemap(cstype, CTYPE) Current {
|
||||
get {
|
||||
if (currentIndex == -1)
|
||||
throw new global::System.InvalidOperationException("Enumeration not started.");
|
||||
if (currentIndex > currentSize)
|
||||
throw new global::System.InvalidOperationException("Enumeration finished.");
|
||||
if (currentObject == null)
|
||||
throw new global::System.InvalidOperationException("Collection modified.");
|
||||
return ($typemap(cstype, CTYPE))currentObject;
|
||||
}
|
||||
}
|
||||
|
||||
// Type-unsafe IEnumerator.Current
|
||||
object global::System.Collections.IEnumerator.Current {
|
||||
get {
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
|
||||
public bool MoveNext() {
|
||||
if (currentNode == null) {
|
||||
currentIndex = collectionRef.Count + 1;
|
||||
return false;
|
||||
}
|
||||
++currentIndex;
|
||||
currentObject = currentNode.Value;
|
||||
currentNode = currentNode.Next;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Reset() {
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
if (collectionRef.Count != currentSize) {
|
||||
throw new global::System.InvalidOperationException("Collection modified.");
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class $csclassnameNode {
|
||||
internal $csclassname list;
|
||||
internal System.IntPtr iter;
|
||||
internal $typemap(cstype, CTYPE) csharpvalue;
|
||||
internal bool inlist;
|
||||
|
||||
public $csclassnameNode($typemap(cstype, CTYPE) value) {
|
||||
csharpvalue = value;
|
||||
inlist = false;
|
||||
}
|
||||
|
||||
internal $csclassnameNode(System.IntPtr iter, $csclassname list) {
|
||||
this.list = list;
|
||||
this.iter = iter;
|
||||
inlist = true;
|
||||
}
|
||||
|
||||
public $csclassname List {
|
||||
get {
|
||||
return this.list;
|
||||
}
|
||||
}
|
||||
|
||||
public $csclassnameNode Next {
|
||||
get {
|
||||
if (list.getNextIter(iter) == System.IntPtr.Zero)
|
||||
return null;
|
||||
return new $csclassnameNode(list.getNextIter(iter), list);
|
||||
}
|
||||
}
|
||||
|
||||
public $csclassnameNode Previous {
|
||||
get {
|
||||
if (list.getPrevIter(iter) == System.IntPtr.Zero)
|
||||
return null;
|
||||
return new $csclassnameNode(list.getPrevIter(iter), list);
|
||||
}
|
||||
}
|
||||
|
||||
public $typemap(cstype, CTYPE) Value {
|
||||
get {
|
||||
return list.getItem(this.iter);
|
||||
}
|
||||
set {
|
||||
list.setItem(this.iter, value);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool operator==($csclassnameNode node1, $csclassnameNode node2) {
|
||||
if (object.ReferenceEquals(node1, null) && object.ReferenceEquals(node2, null))
|
||||
return true;
|
||||
if (object.ReferenceEquals(node1, null) || object.ReferenceEquals(node2, null))
|
||||
return false;
|
||||
return node1.Equals(node2);
|
||||
}
|
||||
|
||||
public static bool operator!=($csclassnameNode node1, $csclassnameNode node2) {
|
||||
if (node1 == null && node2 == null)
|
||||
return false;
|
||||
if (node1 == null || node2 == null)
|
||||
return true;
|
||||
return !node1.Equals(node2);
|
||||
}
|
||||
|
||||
public bool Equals($csclassnameNode node) {
|
||||
if (node == null)
|
||||
return false;
|
||||
if (!node.inlist || !this.inlist)
|
||||
return object.ReferenceEquals(this, node);
|
||||
return list.equals(this.iter, node.iter);
|
||||
}
|
||||
|
||||
public override bool Equals(object node) {
|
||||
return Equals(($csclassnameNode)node);
|
||||
}
|
||||
|
||||
public override int GetHashCode() {
|
||||
int hash = 13;
|
||||
if (inlist) {
|
||||
hash = (hash * 7) + this.list.GetHashCode();
|
||||
hash = (hash * 7) + this.Value.GetHashCode();
|
||||
hash = (hash * 7) + this.list.getNextIter(this.iter).GetHashCode();
|
||||
hash = (hash * 7) + this.list.getPrevIter(this.iter).GetHashCode();
|
||||
} else {
|
||||
hash = (hash * 7) + this.csharpvalue.GetHashCode();
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
list.deleteIter(this.iter);
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef CTYPE value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
class iterator;
|
||||
|
||||
void push_front(CTYPE const& x);
|
||||
void push_back(CTYPE const& x);
|
||||
%rename(RemoveFirst) pop_front;
|
||||
void pop_front();
|
||||
%rename(RemoveLast) pop_back;
|
||||
void pop_back();
|
||||
size_type size() const;
|
||||
%rename(Clear) clear;
|
||||
void clear();
|
||||
%extend {
|
||||
const_reference getItem(iterator *iter) {
|
||||
return **iter;
|
||||
}
|
||||
|
||||
void setItem(iterator *iter, CTYPE const& val) {
|
||||
*(*iter) = val;
|
||||
}
|
||||
|
||||
iterator *getFirstIter() {
|
||||
if ($self->size() == 0)
|
||||
return NULL;
|
||||
return new std::list< CTYPE >::iterator($self->begin());
|
||||
}
|
||||
|
||||
iterator *getLastIter() {
|
||||
if ($self->size() == 0)
|
||||
return NULL;
|
||||
return new std::list< CTYPE >::iterator(--$self->end());
|
||||
}
|
||||
|
||||
iterator *getNextIter(iterator *iter) {
|
||||
std::list< CTYPE >::iterator it = *iter;
|
||||
if (std::distance(it, --$self->end()) != 0) {
|
||||
std::list< CTYPE >::iterator* itnext = new std::list< CTYPE >::iterator(++it);
|
||||
return itnext;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
iterator *getPrevIter(iterator *iter) {
|
||||
std::list< CTYPE >::iterator it = *iter;
|
||||
if (std::distance($self->begin(), it) != 0) {
|
||||
std::list< CTYPE >::iterator* itprev = new std::list< CTYPE >::iterator(--it);
|
||||
return itprev;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
iterator *insertNode(iterator *iter, CTYPE const& value) {
|
||||
std::list< CTYPE >::iterator it = $self->insert(*iter, value);
|
||||
return new std::list< CTYPE >::iterator(it);
|
||||
}
|
||||
|
||||
void eraseIter(iterator *iter) {
|
||||
std::list< CTYPE >::iterator it = *iter;
|
||||
$self->erase(it);
|
||||
}
|
||||
|
||||
void deleteIter(iterator *iter) {
|
||||
delete iter;
|
||||
}
|
||||
|
||||
bool equals(iterator *iter1, iterator *iter2) {
|
||||
if (iter1 == NULL && iter2 == NULL)
|
||||
return true;
|
||||
std::list< CTYPE >::iterator it1 = *iter1;
|
||||
std::list< CTYPE >::iterator it2 = *iter2;
|
||||
return it1 == it2;
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
// Extra methods added to the collection class if operator== is defined for the class being wrapped
|
||||
// The class will then implement ICollection<>, which adds extra functionality
|
||||
%define SWIG_STD_LIST_EXTRA_OP_EQUALS_EQUALS(CTYPE...)
|
||||
%extend {
|
||||
bool Contains(CTYPE const& value) {
|
||||
return std::find($self->begin(), $self->end(), value) != $self->end();
|
||||
}
|
||||
|
||||
bool Remove(CTYPE const& value) {
|
||||
std::list< CTYPE >::iterator it = std::find($self->begin(), $self->end(), value);
|
||||
if (it != $self->end()) {
|
||||
$self->erase(it);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
iterator *find(CTYPE const& value) {
|
||||
if (std::find($self->begin(), $self->end(), value) != $self->end()) {
|
||||
return new std::list< CTYPE >::iterator(std::find($self->begin(), $self->end(), value));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
%proxycode %{
|
||||
public $csclassnameNode Find($typemap(cstype, CTYPE) value) {
|
||||
System.IntPtr tmp = find(value);
|
||||
if (tmp != System.IntPtr.Zero) {
|
||||
return new $csclassnameNode(tmp, this);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
%}
|
||||
%enddef
|
||||
|
||||
// Macros for std::list class specializations/enhancements
|
||||
%define SWIG_STD_LIST_ENHANCED(CTYPE...)
|
||||
namespace std {
|
||||
template<> class list< CTYPE > {
|
||||
SWIG_STD_LIST_MINIMUM_INTERNAL(ICollection, %arg(CTYPE));
|
||||
SWIG_STD_LIST_EXTRA_OP_EQUALS_EQUALS(CTYPE)
|
||||
};
|
||||
}
|
||||
%enddef
|
||||
|
||||
|
||||
%{
|
||||
#include <list>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
%csmethodmodifiers std::list::size "private"
|
||||
%csmethodmodifiers std::list::getItem "private"
|
||||
%csmethodmodifiers std::list::setItem "private"
|
||||
%csmethodmodifiers std::list::push_front "private"
|
||||
%csmethodmodifiers std::list::push_back "private"
|
||||
%csmethodmodifiers std::list::getFirstIter "private"
|
||||
%csmethodmodifiers std::list::getNextIter "private"
|
||||
%csmethodmodifiers std::list::getPrevIter "private"
|
||||
%csmethodmodifiers std::list::getLastIter "private"
|
||||
%csmethodmodifiers std::list::find "private"
|
||||
%csmethodmodifiers std::list::deleteIter "private"
|
||||
|
||||
namespace std {
|
||||
// primary (unspecialized) class template for std::list
|
||||
// does not require operator== to be defined
|
||||
template<class T>
|
||||
class list {
|
||||
SWIG_STD_LIST_MINIMUM_INTERNAL(IEnumerable, T)
|
||||
};
|
||||
// specialization for pointers
|
||||
template<class T>
|
||||
class list<T *> {
|
||||
SWIG_STD_LIST_MINIMUM_INTERNAL(ICollection, T *)
|
||||
SWIG_STD_LIST_EXTRA_OP_EQUALS_EQUALS(T *)
|
||||
};
|
||||
}
|
||||
|
||||
// template specializations for std::list
|
||||
// these provide extra collections methods as operator== is defined
|
||||
SWIG_STD_LIST_ENHANCED(char)
|
||||
SWIG_STD_LIST_ENHANCED(signed char)
|
||||
SWIG_STD_LIST_ENHANCED(unsigned char)
|
||||
SWIG_STD_LIST_ENHANCED(short)
|
||||
SWIG_STD_LIST_ENHANCED(unsigned short)
|
||||
SWIG_STD_LIST_ENHANCED(int)
|
||||
SWIG_STD_LIST_ENHANCED(unsigned int)
|
||||
SWIG_STD_LIST_ENHANCED(long)
|
||||
SWIG_STD_LIST_ENHANCED(unsigned long)
|
||||
SWIG_STD_LIST_ENHANCED(long long)
|
||||
SWIG_STD_LIST_ENHANCED(unsigned long long)
|
||||
SWIG_STD_LIST_ENHANCED(float)
|
||||
SWIG_STD_LIST_ENHANCED(double)
|
||||
SWIG_STD_LIST_ENHANCED(std::string) // also requires a %include <std_string.i>
|
||||
SWIG_STD_LIST_ENHANCED(std::wstring) // also requires a %include <std_wstring.i>
|
||||
@@ -214,9 +214,14 @@
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair< const K, T > value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
map();
|
||||
map(const map< K, T, C > &other);
|
||||
map(const map& other);
|
||||
size_type size() const;
|
||||
bool empty() const;
|
||||
%rename(Clear) clear;
|
||||
|
||||
@@ -18,12 +18,14 @@
|
||||
namespace std {
|
||||
|
||||
template<class T, class U> struct pair {
|
||||
typedef T first_type;
|
||||
typedef U second_type;
|
||||
|
||||
pair();
|
||||
pair(T t, U u);
|
||||
pair(const pair& p);
|
||||
pair(T first, U second);
|
||||
pair(const pair& other);
|
||||
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &p);
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &other);
|
||||
|
||||
T first;
|
||||
U second;
|
||||
|
||||
311
linx64/bin/swig/share/swig/4.0.0/csharp/std_set.i
Normal file
311
linx64/bin/swig/share/swig/4.0.0/csharp/std_set.i
Normal file
@@ -0,0 +1,311 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* std_set.i
|
||||
*
|
||||
* SWIG typemaps for std::set<T>.
|
||||
*
|
||||
* Note that ISet<> used here requires .NET 4 or later.
|
||||
*
|
||||
* The C# wrapper implements ISet<> interface and shares performance
|
||||
* characteristics of C# System.Collections.Generic.SortedSet<> class, but
|
||||
* doesn't provide quite all of its methods.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%{
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
%csmethodmodifiers std::set::size "private"
|
||||
%csmethodmodifiers std::set::getitem "private"
|
||||
%csmethodmodifiers std::set::create_iterator_begin "private"
|
||||
%csmethodmodifiers std::set::get_next "private"
|
||||
%csmethodmodifiers std::set::destroy_iterator "private"
|
||||
|
||||
namespace std {
|
||||
|
||||
// TODO: Add support for comparator and allocator template parameters.
|
||||
template <class T>
|
||||
class set {
|
||||
|
||||
%typemap(csinterfaces) std::set<T> "global::System.IDisposable, global::System.Collections.Generic.ISet<$typemap(cstype, T)>\n";
|
||||
%proxycode %{
|
||||
void global::System.Collections.Generic.ICollection<$typemap(cstype, T)>.Add(string item) {
|
||||
((global::System.Collections.Generic.ISet<$typemap(cstype, T)>)this).Add(item);
|
||||
}
|
||||
|
||||
public bool TryGetValue($typemap(cstype, T) equalValue, out $typemap(cstype, T) actualValue) {
|
||||
try {
|
||||
actualValue = getitem(equalValue);
|
||||
return true;
|
||||
} catch {
|
||||
actualValue = default($typemap(cstype, T));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int Count {
|
||||
get {
|
||||
return (int)size();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReadOnly {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyTo($typemap(cstype, T)[] array) {
|
||||
CopyTo(array, 0);
|
||||
}
|
||||
|
||||
public void CopyTo($typemap(cstype, T)[] array, int arrayIndex) {
|
||||
if (array == null)
|
||||
throw new global::System.ArgumentNullException("array");
|
||||
if (arrayIndex < 0)
|
||||
throw new global::System.ArgumentOutOfRangeException("arrayIndex", "Value is less than zero");
|
||||
if (array.Rank > 1)
|
||||
throw new global::System.ArgumentException("Multi dimensional array.", "array");
|
||||
if (arrayIndex+this.Count > array.Length)
|
||||
throw new global::System.ArgumentException("Number of elements to copy is too large.");
|
||||
|
||||
foreach ($typemap(cstype, T) item in this) {
|
||||
array.SetValue(item, arrayIndex++);
|
||||
}
|
||||
}
|
||||
|
||||
public void ExceptWith(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) {
|
||||
foreach ($typemap(cstype, T) item in other) {
|
||||
Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void IntersectWith(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) {
|
||||
$csclassname old = new $csclassname(this);
|
||||
|
||||
Clear();
|
||||
foreach ($typemap(cstype, T) item in other) {
|
||||
if (old.Contains(item))
|
||||
Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
private static int count_enum(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) {
|
||||
int count = 0;
|
||||
foreach ($typemap(cstype, T) item in other) {
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public bool IsProperSubsetOf(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) {
|
||||
return IsSubsetOf(other) && Count < count_enum(other);
|
||||
}
|
||||
|
||||
public bool IsProperSupersetOf(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) {
|
||||
return IsSupersetOf(other) && Count > count_enum(other);
|
||||
}
|
||||
|
||||
public bool IsSubsetOf(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) {
|
||||
int countContained = 0;
|
||||
|
||||
foreach ($typemap(cstype, T) item in other) {
|
||||
if (Contains(item))
|
||||
countContained++;
|
||||
}
|
||||
|
||||
return countContained == Count;
|
||||
}
|
||||
|
||||
public bool IsSupersetOf(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) {
|
||||
foreach ($typemap(cstype, T) item in other) {
|
||||
if (!Contains(item))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Overlaps(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) {
|
||||
foreach ($typemap(cstype, T) item in other) {
|
||||
if (Contains(item))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool SetEquals(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) {
|
||||
return IsSupersetOf(other) && Count == count_enum(other);
|
||||
}
|
||||
|
||||
public void SymmetricExceptWith(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) {
|
||||
foreach ($typemap(cstype, T) item in other) {
|
||||
if (!Remove(item))
|
||||
Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void UnionWith(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) {
|
||||
foreach ($typemap(cstype, T) item in other) {
|
||||
Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
private global::System.Collections.Generic.ICollection<$typemap(cstype, T)> Items {
|
||||
get {
|
||||
global::System.Collections.Generic.ICollection<$typemap(cstype, T)> items = new global::System.Collections.Generic.List<$typemap(cstype, T)>();
|
||||
int size = this.Count;
|
||||
if (size > 0) {
|
||||
global::System.IntPtr iter = create_iterator_begin();
|
||||
for (int i = 0; i < size; i++) {
|
||||
items.Add(get_next(iter));
|
||||
}
|
||||
destroy_iterator(iter);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
global::System.Collections.Generic.IEnumerator<$typemap(cstype, T)> global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)>.GetEnumerator() {
|
||||
return new $csclassnameEnumerator(this);
|
||||
}
|
||||
|
||||
global::System.Collections.IEnumerator global::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 : global::System.Collections.IEnumerator,
|
||||
global::System.Collections.Generic.IEnumerator<$typemap(cstype, T)>
|
||||
{
|
||||
private $csclassname collectionRef;
|
||||
private global::System.Collections.Generic.IList<$typemap(cstype, T)> ItemsCollection;
|
||||
private int currentIndex;
|
||||
private $typemap(cstype, T) currentObject;
|
||||
private int currentSize;
|
||||
|
||||
public $csclassnameEnumerator($csclassname collection) {
|
||||
collectionRef = collection;
|
||||
ItemsCollection = new global::System.Collections.Generic.List<$typemap(cstype, T)>(collection.Items);
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
currentSize = collectionRef.Count;
|
||||
}
|
||||
|
||||
// Type-safe iterator Current
|
||||
public $typemap(cstype, T) Current {
|
||||
get {
|
||||
if (currentIndex == -1)
|
||||
throw new global::System.InvalidOperationException("Enumeration not started.");
|
||||
if (currentIndex > currentSize - 1)
|
||||
throw new global::System.InvalidOperationException("Enumeration finished.");
|
||||
if (currentObject == null)
|
||||
throw new global::System.InvalidOperationException("Collection modified.");
|
||||
return currentObject;
|
||||
}
|
||||
}
|
||||
|
||||
// Type-unsafe IEnumerator.Current
|
||||
object global::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 = ItemsCollection[currentIndex];
|
||||
} else {
|
||||
currentObject = null;
|
||||
}
|
||||
return moveOkay;
|
||||
}
|
||||
|
||||
public void Reset() {
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
if (collectionRef.Count != currentSize) {
|
||||
throw new global::System.InvalidOperationException("Collection modified.");
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
}
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T key_type;
|
||||
typedef T value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
set();
|
||||
set(const set& other);
|
||||
size_type size() const;
|
||||
bool empty() const;
|
||||
%rename(Clear) clear;
|
||||
void clear();
|
||||
%extend {
|
||||
bool Add(const value_type& item) {
|
||||
return $self->insert(item).second;
|
||||
}
|
||||
|
||||
bool Contains(const value_type& item) {
|
||||
return $self->count(item) != 0;
|
||||
}
|
||||
|
||||
bool Remove(const value_type& item) {
|
||||
return $self->erase(item) != 0;
|
||||
}
|
||||
|
||||
const value_type& getitem(const value_type& item) throw (std::out_of_range) {
|
||||
std::set<T>::iterator iter = $self->find(item);
|
||||
if (iter == $self->end())
|
||||
throw std::out_of_range("item not found");
|
||||
|
||||
return *iter;
|
||||
}
|
||||
|
||||
// create_iterator_begin(), get_next() and destroy_iterator work together to provide a collection of items to C#
|
||||
%apply void *VOID_INT_PTR { std::set<T>::iterator *create_iterator_begin }
|
||||
%apply void *VOID_INT_PTR { std::set<T>::iterator *swigiterator }
|
||||
|
||||
std::set<T>::iterator *create_iterator_begin() {
|
||||
return new std::set<T>::iterator($self->begin());
|
||||
}
|
||||
|
||||
const key_type& get_next(std::set<T>::iterator *swigiterator) {
|
||||
std::set<T>::iterator iter = *swigiterator;
|
||||
(*swigiterator)++;
|
||||
return *iter;
|
||||
}
|
||||
|
||||
void destroy_iterator(std::set<T>::iterator *swigiterator) {
|
||||
delete swigiterator;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -13,18 +13,13 @@
|
||||
*
|
||||
* SWIG_STD_VECTOR_ENHANCED(SomeNamespace::Klass)
|
||||
* %template(VectKlass) std::vector<SomeNamespace::Klass>;
|
||||
*
|
||||
* Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents!
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
// 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
|
||||
%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE, CTYPE...)
|
||||
%typemap(csinterfaces) std::vector< CTYPE > "global::System.IDisposable, global::System.Collections.IEnumerable\n , global::System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n";
|
||||
%typemap(csinterfaces) std::vector< CTYPE > "global::System.IDisposable, global::System.Collections.IEnumerable, global::System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n";
|
||||
%proxycode %{
|
||||
public $csclassname(global::System.Collections.IEnumerable c) : this() {
|
||||
if (c == null)
|
||||
@@ -201,8 +196,13 @@
|
||||
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef CTYPE value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef CONST_REFERENCE const_reference;
|
||||
|
||||
%rename(Clear) clear;
|
||||
void clear();
|
||||
%rename(Add) push_back;
|
||||
@@ -212,8 +212,10 @@
|
||||
void reserve(size_type n);
|
||||
%newobject GetRange(int index, int count);
|
||||
%newobject Repeat(CTYPE const& value, int count);
|
||||
|
||||
vector();
|
||||
vector(const vector &other);
|
||||
|
||||
%extend {
|
||||
vector(int capacity) throw (std::out_of_range) {
|
||||
std::vector< CTYPE >* pv = 0;
|
||||
@@ -237,9 +239,9 @@
|
||||
else
|
||||
throw std::out_of_range("index");
|
||||
}
|
||||
void setitem(int index, CTYPE const& value) throw (std::out_of_range) {
|
||||
void setitem(int index, CTYPE const& val) throw (std::out_of_range) {
|
||||
if (index>=0 && index<(int)$self->size())
|
||||
(*$self)[index] = value;
|
||||
(*$self)[index] = val;
|
||||
else
|
||||
throw std::out_of_range("index");
|
||||
}
|
||||
@@ -349,7 +351,7 @@
|
||||
%define SWIG_STD_VECTOR_ENHANCED(CTYPE...)
|
||||
namespace std {
|
||||
template<> class vector< CTYPE > {
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, %arg(CTYPE const&), %arg(CTYPE))
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, %arg(CTYPE))
|
||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE)
|
||||
};
|
||||
}
|
||||
@@ -382,11 +384,11 @@ 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_INTERNAL(IEnumerable, T const&, T)
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, const value_type&, T)
|
||||
};
|
||||
// specialization for pointers
|
||||
template<class T> class vector<T *> {
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, T *const&, T *)
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, T *)
|
||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T *)
|
||||
};
|
||||
// bool is specialized in the C++ standard - const_reference in particular
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* stl.i
|
||||
*
|
||||
* Initial STL definition. extended as needed in each language
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_common.i>
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
// We do not use »override« attribute for generated dispose() methods to stay
|
||||
// somewhat compatible to Phobos and older Tango versions where Object.dispose()
|
||||
// does not exist.
|
||||
%typemap(ddispose, methodname="dispose", methodmodifiers="public") SWIGTYPE {
|
||||
%typemap(ddispose, methodname="dispose", methodmodifiers="public", parameters="") SWIGTYPE {
|
||||
synchronized(this) {
|
||||
if (swigCPtr !is null) {
|
||||
if (swigCMemOwn) {
|
||||
@@ -45,7 +45,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(ddispose_derived, methodname="dispose", methodmodifiers="public") SWIGTYPE {
|
||||
%typemap(ddispose_derived, methodname="dispose", methodmodifiers="public", parameters="") SWIGTYPE {
|
||||
synchronized(this) {
|
||||
if (swigCPtr !is null) {
|
||||
if (swigCMemOwn) {
|
||||
|
||||
@@ -23,8 +23,14 @@ namespace std {
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair< const K, T > value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
map();
|
||||
map(const map< K, T, C > &);
|
||||
map(const map& other);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
|
||||
@@ -18,12 +18,14 @@
|
||||
namespace std {
|
||||
|
||||
template<class T, class U> struct pair {
|
||||
typedef T first_type;
|
||||
typedef U second_type;
|
||||
|
||||
pair();
|
||||
pair(T t, U u);
|
||||
pair(const pair& p);
|
||||
pair(T first, U second);
|
||||
pair(const pair& other);
|
||||
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &p);
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &other);
|
||||
|
||||
T first;
|
||||
U second;
|
||||
|
||||
@@ -104,15 +104,22 @@ public void capacity(size_t value) {
|
||||
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef CTYPE value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef CONST_REFERENCE const_reference;
|
||||
|
||||
void clear();
|
||||
void push_back(CTYPE const& x);
|
||||
size_type size() const;
|
||||
size_type capacity() const;
|
||||
void reserve(size_type n) throw (std::length_error);
|
||||
|
||||
vector();
|
||||
vector(const vector &other);
|
||||
|
||||
%extend {
|
||||
vector(size_type capacity) throw (std::length_error) {
|
||||
std::vector< CTYPE >* pv = 0;
|
||||
@@ -128,7 +135,7 @@ public void capacity(size_t value) {
|
||||
return $self->capacity() - $self->size();
|
||||
}
|
||||
|
||||
CONST_REFERENCE remove() throw (std::out_of_range) {
|
||||
const_reference remove() throw (std::out_of_range) {
|
||||
if ($self->empty()) {
|
||||
throw std::out_of_range("Tried to remove last element from empty vector.");
|
||||
}
|
||||
@@ -138,7 +145,7 @@ public void capacity(size_t value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
CONST_REFERENCE remove(size_type index) throw (std::out_of_range) {
|
||||
const_reference remove(size_type index) throw (std::out_of_range) {
|
||||
if (index >= $self->size()) {
|
||||
throw std::out_of_range("Tried to remove element with invalid index.");
|
||||
}
|
||||
@@ -153,7 +160,7 @@ public void capacity(size_t value) {
|
||||
// Wrappers for setting/getting items with the possibly thrown exception
|
||||
// specified (important for SWIG wrapper generation).
|
||||
%extend {
|
||||
CONST_REFERENCE getElement(size_type index) throw (std::out_of_range) {
|
||||
const_reference getElement(size_type index) throw (std::out_of_range) {
|
||||
if ((index < 0) || ($self->size() <= index)) {
|
||||
throw std::out_of_range("Tried to get value of element with invalid index.");
|
||||
}
|
||||
@@ -165,11 +172,11 @@ public void capacity(size_t value) {
|
||||
// generation issue when using const pointers as vector elements (like
|
||||
// std::vector< const int* >).
|
||||
%extend {
|
||||
void setElement(size_type index, CTYPE const& value) throw (std::out_of_range) {
|
||||
void setElement(size_type index, CTYPE const& val) throw (std::out_of_range) {
|
||||
if ((index < 0) || ($self->size() <= index)) {
|
||||
throw std::out_of_range("Tried to set value of element with invalid index.");
|
||||
}
|
||||
(*$self)[index] = value;
|
||||
(*$self)[index] = val;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,8 +449,13 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg)
|
||||
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef CTYPE value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef CONST_REFERENCE const_reference;
|
||||
|
||||
bool empty() const;
|
||||
void clear();
|
||||
void push_back(CTYPE const& x);
|
||||
@@ -451,8 +463,10 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg)
|
||||
size_type size() const;
|
||||
size_type capacity() const;
|
||||
void reserve(size_type n) throw (std::length_error);
|
||||
|
||||
vector();
|
||||
vector(const vector &other);
|
||||
|
||||
%extend {
|
||||
vector(size_type capacity) throw (std::length_error) {
|
||||
std::vector< CTYPE >* pv = 0;
|
||||
@@ -464,7 +478,7 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg)
|
||||
return pv;
|
||||
}
|
||||
|
||||
CONST_REFERENCE remove() throw (std::out_of_range) {
|
||||
const_reference remove() throw (std::out_of_range) {
|
||||
if ($self->empty()) {
|
||||
throw std::out_of_range("Tried to remove last element from empty vector.");
|
||||
}
|
||||
@@ -474,7 +488,7 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg)
|
||||
return value;
|
||||
}
|
||||
|
||||
CONST_REFERENCE remove(size_type index) throw (std::out_of_range) {
|
||||
const_reference remove(size_type index) throw (std::out_of_range) {
|
||||
if (index >= $self->size()) {
|
||||
throw std::out_of_range("Tried to remove element with invalid index.");
|
||||
}
|
||||
@@ -506,7 +520,7 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg)
|
||||
// Wrappers for setting/getting items with the possibly thrown exception
|
||||
// specified (important for SWIG wrapper generation).
|
||||
%extend {
|
||||
CONST_REFERENCE getElement(size_type index) throw (std::out_of_range) {
|
||||
const_reference getElement(size_type index) throw (std::out_of_range) {
|
||||
if ((index < 0) || ($self->size() <= index)) {
|
||||
throw std::out_of_range("Tried to get value of element with invalid index.");
|
||||
}
|
||||
@@ -517,11 +531,11 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg)
|
||||
// generation issue when using const pointers as vector elements (like
|
||||
// std::vector< const int* >).
|
||||
%extend {
|
||||
void setElement(size_type index, CTYPE const& value) throw (std::out_of_range) {
|
||||
void setElement(size_type index, CTYPE const& val) throw (std::out_of_range) {
|
||||
if ((index < 0) || ($self->size() <= index)) {
|
||||
throw std::out_of_range("Tried to set value of element with invalid index.");
|
||||
}
|
||||
(*$self)[index] = value;
|
||||
(*$self)[index] = val;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -544,7 +558,7 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg)
|
||||
%define SWIG_STD_VECTOR_ENHANCED(CTYPE...)
|
||||
namespace std {
|
||||
template<> class vector<CTYPE > {
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(%arg(CTYPE const&), %arg(CTYPE))
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(const value_type&, %arg(CTYPE))
|
||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE)
|
||||
};
|
||||
}
|
||||
@@ -559,11 +573,11 @@ 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_INTERNAL(T const&, T)
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(const value_type&, T)
|
||||
};
|
||||
// specializations for pointers
|
||||
template<class T> class vector<T *> {
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(T *const&, T *)
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(const value_type&, T *)
|
||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T *)
|
||||
};
|
||||
// bool is a bit different in the C++ standard - const_reference in particular
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* stl.i
|
||||
*
|
||||
* Initial STL definition. extended as needed in each language
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_common.i>
|
||||
|
||||
@@ -127,33 +127,48 @@ SWIGINTERN void SWIG_JavaException(JNIEnv *jenv, int code, const char *msg) {
|
||||
|
||||
#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 );
|
||||
SWIGINTERN void SWIG_OCamlException(int code, const char *msg) {
|
||||
CAMLparam0();
|
||||
|
||||
SWIG_OCamlExceptionCodes exception_code = SWIG_OCamlUnknownError;
|
||||
switch (code) {
|
||||
case SWIG_DivisionByZero:
|
||||
exception_code = SWIG_OCamlArithmeticException;
|
||||
break;
|
||||
case SWIG_IndexError:
|
||||
exception_code = SWIG_OCamlIndexOutOfBoundsException;
|
||||
break;
|
||||
case SWIG_IOError:
|
||||
case SWIG_SystemError:
|
||||
exception_code = SWIG_OCamlSystemException;
|
||||
break;
|
||||
case SWIG_MemoryError:
|
||||
exception_code = SWIG_OCamlOutOfMemoryError;
|
||||
break;
|
||||
case SWIG_OverflowError:
|
||||
exception_code = SWIG_OCamlOverflowException;
|
||||
break;
|
||||
case SWIG_RuntimeError:
|
||||
exception_code = SWIG_OCamlRuntimeException;
|
||||
break;
|
||||
case SWIG_SyntaxError:
|
||||
case SWIG_TypeError:
|
||||
case SWIG_ValueError:
|
||||
exception_code = SWIG_OCamlIllegalArgumentException;
|
||||
break;
|
||||
case SWIG_UnknownError:
|
||||
default:
|
||||
exception_code = SWIG_OCamlUnknownError;
|
||||
break;
|
||||
}
|
||||
SWIG_OCamlThrowException(exception_code, msg);
|
||||
CAMLreturn0;
|
||||
}
|
||||
#define SWIG_exception(a,b) SWIG_exception_((a),(b))
|
||||
#define SWIG_exception(code, msg) SWIG_OCamlException(code, msg)
|
||||
%}
|
||||
#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) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* std_vector.i
|
||||
* std_list.i
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%{
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class T, class Alloc = allocator<T> >
|
||||
template<class T>
|
||||
class list {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
@@ -19,9 +19,10 @@ namespace std {
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef Alloc allocator_type;
|
||||
|
||||
list();
|
||||
list(const list& other);
|
||||
|
||||
size_type size() const;
|
||||
bool empty() const;
|
||||
%rename(isEmpty) empty;
|
||||
|
||||
@@ -27,8 +27,14 @@ namespace std {
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair< const K, T > value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
map();
|
||||
map(const map< K, T, C > &);
|
||||
map(const map& other);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
|
||||
@@ -18,12 +18,14 @@
|
||||
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);
|
||||
pair(const pair& other);
|
||||
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &p);
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &other);
|
||||
|
||||
T first;
|
||||
U second;
|
||||
|
||||
@@ -12,10 +12,17 @@ namespace std {
|
||||
template<class T> class vector {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
vector();
|
||||
vector(size_type n);
|
||||
vector(const vector& other);
|
||||
|
||||
size_type size() const;
|
||||
size_type capacity() const;
|
||||
void reserve(size_type n);
|
||||
@@ -46,10 +53,17 @@ namespace std {
|
||||
template<> class vector<bool> {
|
||||
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 bool const_reference;
|
||||
|
||||
vector();
|
||||
vector(size_type n);
|
||||
vector(const vector& other);
|
||||
|
||||
size_type size() const;
|
||||
size_type capacity() const;
|
||||
void reserve(size_type n);
|
||||
|
||||
@@ -7,3 +7,4 @@
|
||||
%include <std_vector.i>
|
||||
%include <std_map.i>
|
||||
%include <std_pair.i>
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define SWIGGUILE_SCM
|
||||
|
||||
%runtime "swigrun.swg" // Common C API type-checking code
|
||||
%runtime "swigerrors.swg" // SWIG errors
|
||||
|
||||
%runtime "guile_scm_run.swg"
|
||||
%include <guile.i>
|
||||
|
||||
@@ -186,7 +186,7 @@ SWIG_Guile_ConvertPtr(SCM s, void **result, swig_type_info *type, int flags)
|
||||
|
||||
if (SCM_NULLP(smob)) {
|
||||
*result = NULL;
|
||||
return SWIG_OK;
|
||||
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||
#if SCM_MAJOR_VERSION >= 2
|
||||
} else if (SCM_POINTER_P(s)) {
|
||||
*result = SCM_POINTER_VALUE(s);
|
||||
|
||||
@@ -218,8 +218,14 @@ namespace std {
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair< const K, T > value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
map();
|
||||
map(const map< K, T, C> &);
|
||||
map(const map& other);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
@@ -434,8 +440,18 @@ namespace std {
|
||||
%rename("delete!") __delitem__;
|
||||
%rename("has-key?") has_key;
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair< const K, T > value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
map();
|
||||
map(const map< K, T, C > &);
|
||||
map(const map& other);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
@@ -640,8 +656,18 @@ namespace std {
|
||||
%rename("delete!") __delitem__;
|
||||
%rename("has-key?") has_key;
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair< const K, T > value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
map();
|
||||
map(const map< K, T, C > &);
|
||||
map(const map& other);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
@@ -848,8 +874,18 @@ namespace std {
|
||||
%rename("delete!") __delitem__;
|
||||
%rename("has-key?") has_key;
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair< const K, T > value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
map();
|
||||
map(const map< K, T, C> &);
|
||||
map(const map& other);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
|
||||
@@ -113,11 +113,15 @@ namespace std {
|
||||
$1 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
typedef T first_type;
|
||||
typedef U second_type;
|
||||
|
||||
pair();
|
||||
pair(T first, U second);
|
||||
pair(const pair& p);
|
||||
pair(const pair& other);
|
||||
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &p);
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &other);
|
||||
|
||||
T first;
|
||||
U second;
|
||||
@@ -217,9 +221,9 @@ namespace std {
|
||||
}
|
||||
pair();
|
||||
pair(T first, U second);
|
||||
pair(const pair& p);
|
||||
pair(const pair& other);
|
||||
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &p);
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &other);
|
||||
|
||||
T first;
|
||||
U second;
|
||||
@@ -317,9 +321,9 @@ namespace std {
|
||||
}
|
||||
pair();
|
||||
pair(T first, U second);
|
||||
pair(const pair& p);
|
||||
pair(const pair& other);
|
||||
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &p);
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &other);
|
||||
|
||||
T first;
|
||||
U second;
|
||||
@@ -408,9 +412,9 @@ namespace std {
|
||||
}
|
||||
pair();
|
||||
pair(T first, U second);
|
||||
pair(const pair& p);
|
||||
pair(const pair& other);
|
||||
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &p);
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &other);
|
||||
|
||||
T first;
|
||||
U second;
|
||||
|
||||
@@ -187,9 +187,18 @@ namespace std {
|
||||
}
|
||||
}
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
vector(unsigned int size = 0);
|
||||
vector(unsigned int size, const T& value);
|
||||
vector(const vector<T>&);
|
||||
vector(const vector& other);
|
||||
|
||||
%rename(length) size;
|
||||
unsigned int size() const;
|
||||
%rename("empty?") empty;
|
||||
@@ -351,9 +360,18 @@ namespace std {
|
||||
}
|
||||
}
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
vector(unsigned int size = 0);
|
||||
vector(unsigned int size, const T& value);
|
||||
vector(const vector<T>&);
|
||||
vector(const vector& other);
|
||||
|
||||
%rename(length) size;
|
||||
unsigned int size() const;
|
||||
%rename("empty?") empty;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* stl.i
|
||||
*
|
||||
* Initial STL definition. extended as needed in each language
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_common.i>
|
||||
|
||||
@@ -444,15 +444,21 @@ typedef unsigned long SCM;
|
||||
$1 = scm_is_string($input) ? 1 : 0;
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE [] {
|
||||
void *ptr;
|
||||
int res = SWIG_ConvertPtr($input, &ptr, $1_descriptor, 0);
|
||||
$1 = SWIG_CheckState(res);
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE &, SWIGTYPE && {
|
||||
void *ptr;
|
||||
int res = SWIG_ConvertPtr($input, &ptr, $1_descriptor, SWIG_POINTER_NO_NULL);
|
||||
$1 = SWIG_CheckState(res);
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE {
|
||||
void *ptr;
|
||||
int res = SWIG_ConvertPtr($input, &ptr, $&descriptor, 0);
|
||||
int res = SWIG_ConvertPtr($input, &ptr, $&descriptor, SWIG_POINTER_NO_NULL);
|
||||
$1 = SWIG_CheckState(res);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,12 +5,52 @@
|
||||
* methods can be called from C++.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#if defined(DEBUG_DIRECTOR_OWNED) || defined(DEBUG_DIRECTOR_EXCEPTION)
|
||||
#if defined(DEBUG_DIRECTOR_OWNED) || defined(DEBUG_DIRECTOR_EXCEPTION) || defined(DEBUG_DIRECTOR_THREAD_NAME)
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
#include <exception>
|
||||
|
||||
#if defined(SWIG_JAVA_USE_THREAD_NAME)
|
||||
|
||||
#if !defined(SWIG_JAVA_GET_THREAD_NAME)
|
||||
namespace Swig {
|
||||
SWIGINTERN int GetThreadName(char *name, size_t len);
|
||||
}
|
||||
|
||||
#if defined(__linux__)
|
||||
|
||||
#include <sys/prctl.h>
|
||||
SWIGINTERN int Swig::GetThreadName(char *name, size_t len) {
|
||||
(void)len;
|
||||
#if defined(PR_GET_NAME)
|
||||
return prctl(PR_GET_NAME, (unsigned long)name, 0, 0, 0);
|
||||
#else
|
||||
(void)name;
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
#elif defined(__unix__) || defined(__APPLE__)
|
||||
|
||||
#include <pthread.h>
|
||||
SWIGINTERN int Swig::GetThreadName(char *name, size_t len) {
|
||||
return pthread_getname_np(pthread_self(), name, len);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SWIGINTERN int Swig::GetThreadName(char *name, size_t len) {
|
||||
(void)len;
|
||||
(void)name;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
namespace Swig {
|
||||
|
||||
/* Java object wrapper */
|
||||
@@ -139,12 +179,27 @@ namespace Swig {
|
||||
void **jenv = (void **)&jenv_;
|
||||
#endif
|
||||
env_status = director_->swig_jvm_->GetEnv((void **)&jenv_, JNI_VERSION_1_2);
|
||||
JavaVMAttachArgs args;
|
||||
args.version = JNI_VERSION_1_2;
|
||||
args.group = NULL;
|
||||
args.name = NULL;
|
||||
#if defined(SWIG_JAVA_USE_THREAD_NAME)
|
||||
char thread_name[64]; // MAX_TASK_COMM_LEN=16 is hard-coded in the Linux kernel and MacOS has MAXTHREADNAMESIZE=64.
|
||||
if (Swig::GetThreadName(thread_name, sizeof(thread_name)) == 0) {
|
||||
args.name = thread_name;
|
||||
#if defined(DEBUG_DIRECTOR_THREAD_NAME)
|
||||
std::cout << "JNIEnvWrapper: thread name: " << thread_name << std::endl;
|
||||
} else {
|
||||
std::cout << "JNIEnvWrapper: Couldn't set Java thread name" << std::endl;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#if defined(SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON)
|
||||
// Attach a daemon thread to the JVM. Useful when the JVM should not wait for
|
||||
// the thread to exit upon shutdown. Only for jdk-1.4 and later.
|
||||
director_->swig_jvm_->AttachCurrentThreadAsDaemon(jenv, NULL);
|
||||
director_->swig_jvm_->AttachCurrentThreadAsDaemon(jenv, &args);
|
||||
#else
|
||||
director_->swig_jvm_->AttachCurrentThread(jenv, NULL);
|
||||
director_->swig_jvm_->AttachCurrentThread(jenv, &args);
|
||||
#endif
|
||||
}
|
||||
~JNIEnvWrapper() {
|
||||
|
||||
@@ -160,7 +160,7 @@ SWIGINTERN jint SWIG_JavaIntFromSize_t(size_t size) {
|
||||
%typemap(jtype) jfloat "float"
|
||||
%typemap(jtype) jdouble "double"
|
||||
%typemap(jtype) jstring "String"
|
||||
%typemap(jtype) jobject "Object"
|
||||
%typemap(jtype) jobject "java.lang.Object"
|
||||
%typemap(jtype) jbooleanArray "boolean[]"
|
||||
%typemap(jtype) jcharArray "char[]"
|
||||
%typemap(jtype) jbyteArray "byte[]"
|
||||
@@ -169,7 +169,7 @@ SWIGINTERN jint SWIG_JavaIntFromSize_t(size_t size) {
|
||||
%typemap(jtype) jlongArray "long[]"
|
||||
%typemap(jtype) jfloatArray "float[]"
|
||||
%typemap(jtype) jdoubleArray "double[]"
|
||||
%typemap(jtype) jobjectArray "Object[]"
|
||||
%typemap(jtype) jobjectArray "java.lang.Object[]"
|
||||
|
||||
%typemap(jstype) jboolean "boolean"
|
||||
%typemap(jstype) jchar "char"
|
||||
@@ -180,7 +180,7 @@ SWIGINTERN jint SWIG_JavaIntFromSize_t(size_t size) {
|
||||
%typemap(jstype) jfloat "float"
|
||||
%typemap(jstype) jdouble "double"
|
||||
%typemap(jstype) jstring "String"
|
||||
%typemap(jstype) jobject "Object"
|
||||
%typemap(jstype) jobject "java.lang.Object"
|
||||
%typemap(jstype) jbooleanArray "boolean[]"
|
||||
%typemap(jstype) jcharArray "char[]"
|
||||
%typemap(jstype) jbyteArray "byte[]"
|
||||
@@ -189,7 +189,7 @@ SWIGINTERN jint SWIG_JavaIntFromSize_t(size_t size) {
|
||||
%typemap(jstype) jlongArray "long[]"
|
||||
%typemap(jstype) jfloatArray "float[]"
|
||||
%typemap(jstype) jdoubleArray "double[]"
|
||||
%typemap(jstype) jobjectArray "Object[]"
|
||||
%typemap(jstype) jobjectArray "java.lang.Object[]"
|
||||
|
||||
/* Non primitive types */
|
||||
%typemap(jni) SWIGTYPE "jlong"
|
||||
@@ -1273,6 +1273,7 @@ SWIG_JAVABODY_PROXY(protected, protected, SWIGTYPE)
|
||||
SWIG_JAVABODY_TYPEWRAPPER(protected, protected, protected, SWIGTYPE)
|
||||
|
||||
%typemap(javafinalize) SWIGTYPE %{
|
||||
@SuppressWarnings("deprecation")
|
||||
protected void finalize() {
|
||||
delete();
|
||||
}
|
||||
@@ -1312,7 +1313,7 @@ SWIG_PROXY_CONSTRUCTOR(true, false, TYPENAME)
|
||||
// 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 {
|
||||
%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized", parameters="") SWIGTYPE {
|
||||
if (swigCPtr != 0) {
|
||||
if (swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
@@ -1322,7 +1323,7 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") SWIGTYPE {
|
||||
%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized", parameters="") SWIGTYPE {
|
||||
if (swigCPtr != 0) {
|
||||
if (swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
@@ -1382,12 +1383,12 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)
|
||||
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
|
||||
|
||||
/* String & length */
|
||||
%typemap(jni) (char *STRING, size_t LENGTH) "jbyteArray"
|
||||
%typemap(jtype) (char *STRING, size_t LENGTH) "byte[]"
|
||||
%typemap(jstype) (char *STRING, size_t LENGTH) "byte[]"
|
||||
%typemap(javain) (char *STRING, size_t LENGTH) "$javainput"
|
||||
%typemap(freearg) (char *STRING, size_t LENGTH) ""
|
||||
%typemap(in) (char *STRING, size_t LENGTH) {
|
||||
%typemap(jni) (const char *STRING, size_t LENGTH) "jbyteArray"
|
||||
%typemap(jtype) (const char *STRING, size_t LENGTH) "byte[]"
|
||||
%typemap(jstype) (const char *STRING, size_t LENGTH) "byte[]"
|
||||
%typemap(javain) (const char *STRING, size_t LENGTH) "$javainput"
|
||||
%typemap(freearg) (const char *STRING, size_t LENGTH) ""
|
||||
%typemap(in) (const char *STRING, size_t LENGTH) {
|
||||
if ($input) {
|
||||
$1 = ($1_ltype) JCALL2(GetByteArrayElements, jenv, $input, 0);
|
||||
$2 = ($2_type) JCALL1(GetArrayLength, jenv, $input);
|
||||
@@ -1396,10 +1397,10 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)
|
||||
$2 = 0;
|
||||
}
|
||||
}
|
||||
%typemap(argout) (char *STRING, size_t LENGTH) {
|
||||
if ($input) JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
|
||||
%typemap(argout) (const char *STRING, size_t LENGTH) {
|
||||
if ($input) JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, JNI_ABORT);
|
||||
}
|
||||
%typemap(directorin, descriptor="[B", noblock=1) (char *STRING, size_t LENGTH) {
|
||||
%typemap(directorin, descriptor="[B", noblock=1) (const char *STRING, size_t LENGTH) {
|
||||
$input = 0;
|
||||
if ($1) {
|
||||
$input = JCALL1(NewByteArray, jenv, (jsize)$2);
|
||||
@@ -1408,9 +1409,14 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)
|
||||
}
|
||||
Swig::LocalRefGuard $1_refguard(jenv, $input);
|
||||
}
|
||||
%typemap(javadirectorin, descriptor="[B") (const char *STRING, size_t LENGTH) "$jniinput"
|
||||
%apply (const char *STRING, size_t LENGTH) { (char *STRING, size_t LENGTH) }
|
||||
/* Enable write-back for non-const version */
|
||||
%typemap(argout) (char *STRING, size_t LENGTH) {
|
||||
if ($input) JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
|
||||
}
|
||||
%typemap(directorargout, noblock=1) (char *STRING, size_t LENGTH)
|
||||
{ if ($input && $1) JCALL4(GetByteArrayRegion, jenv, $input, 0, (jsize)$2, (jbyte *)$1); }
|
||||
%typemap(javadirectorin, descriptor="[B") (char *STRING, size_t LENGTH) "$jniinput"
|
||||
%apply (char *STRING, size_t LENGTH) { (char *STRING, int LENGTH) }
|
||||
|
||||
/* java keywords */
|
||||
|
||||
@@ -11,12 +11,14 @@ namespace std {
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef T &reference;
|
||||
typedef const T &const_reference;
|
||||
typedef T *pointer;
|
||||
typedef const T *const_pointer;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
array();
|
||||
array(const array& other);
|
||||
|
||||
size_type size() const;
|
||||
%rename(isEmpty) empty;
|
||||
bool empty() const;
|
||||
@@ -29,10 +31,10 @@ namespace std {
|
||||
else
|
||||
throw std::out_of_range("array index out of range");
|
||||
}
|
||||
void set(int i, const value_type& value) throw (std::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] = value;
|
||||
(*self)[i] = val;
|
||||
else
|
||||
throw std::out_of_range("array index out of range");
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace std {
|
||||
this();
|
||||
java.util.ListIterator<$typemap(jboxtype, T)> it = listIterator(0);
|
||||
// Special case the "copy constructor" here to avoid lots of cross-language calls
|
||||
for (Object o : c) {
|
||||
for (java.lang.Object o : c) {
|
||||
it.add(($typemap(jboxtype, T))o);
|
||||
}
|
||||
}
|
||||
@@ -130,8 +130,12 @@ namespace std {
|
||||
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef T &reference;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
/*
|
||||
* We'd actually be better off having the nested class *not* be static in the wrapper
|
||||
@@ -173,7 +177,8 @@ namespace std {
|
||||
};
|
||||
|
||||
list();
|
||||
list(const list &other);
|
||||
list(const list& other);
|
||||
|
||||
%rename(isEmpty) empty;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
@@ -193,11 +198,6 @@ namespace std {
|
||||
|
||||
%extend {
|
||||
%fragment("SWIG_ListSize");
|
||||
list(jint count) throw (std::out_of_range) {
|
||||
if (count < 0)
|
||||
throw std::out_of_range("list count must be positive");
|
||||
return new std::list<T>(static_cast<std::list<T>::size_type>(count));
|
||||
}
|
||||
|
||||
list(jint count, const T &value) throw (std::out_of_range) {
|
||||
if (count < 0)
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
* std_map.i
|
||||
*
|
||||
* SWIG typemaps for std::map
|
||||
* The Java proxy class extends java.util.AbstractMap. The std::map
|
||||
* container looks and feels much like a java.util.HashMap from Java.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_common.i>
|
||||
@@ -12,48 +14,199 @@
|
||||
|
||||
%{
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
%fragment("SWIG_MapSize", "header", fragment="SWIG_JavaIntFromSize_t") {
|
||||
SWIGINTERN jint SWIG_MapSize(size_t size) {
|
||||
jint sz = SWIG_JavaIntFromSize_t(size);
|
||||
if (sz == -1) {
|
||||
throw std::out_of_range("map size is too large to fit into a Java int");
|
||||
}
|
||||
|
||||
return sz;
|
||||
}
|
||||
}
|
||||
|
||||
%javamethodmodifiers std::map::sizeImpl "private";
|
||||
%javamethodmodifiers std::map::containsImpl "private";
|
||||
%javamethodmodifiers std::map::putUnchecked "private";
|
||||
%javamethodmodifiers std::map::removeUnchecked "private";
|
||||
%javamethodmodifiers std::map::find "private";
|
||||
%javamethodmodifiers std::map::begin "private";
|
||||
%javamethodmodifiers std::map::end "private";
|
||||
|
||||
%rename(Iterator) std::map::iterator;
|
||||
%nodefaultctor std::map::iterator;
|
||||
%javamethodmodifiers std::map::iterator::getNextUnchecked "private";
|
||||
%javamethodmodifiers std::map::iterator::isNot "private";
|
||||
%javamethodmodifiers std::map::iterator::getKey "private";
|
||||
%javamethodmodifiers std::map::iterator::getValue "private";
|
||||
%javamethodmodifiers std::map::iterator::setValue "private";
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class K, class T, class C = std::less<K> > class map {
|
||||
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, C > &);
|
||||
template<class K, class T, class C = std::less< K> > class map {
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%typemap(javabase) std::map< K, T, C >
|
||||
"java.util.AbstractMap<$typemap(jboxtype, K), $typemap(jboxtype, T)>"
|
||||
|
||||
%proxycode %{
|
||||
|
||||
public int size() {
|
||||
return sizeImpl();
|
||||
}
|
||||
|
||||
public boolean containsKey(java.lang.Object key) {
|
||||
if (!(key instanceof $typemap(jboxtype, K))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return containsImpl(($typemap(jboxtype, K))key);
|
||||
}
|
||||
|
||||
public $typemap(jboxtype, T) get(java.lang.Object key) {
|
||||
if (!(key instanceof $typemap(jboxtype, K))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Iterator itr = find(($typemap(jboxtype, K)) key);
|
||||
if (itr.isNot(end())) {
|
||||
return itr.getValue();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public $typemap(jboxtype, T) put($typemap(jboxtype, K) key, $typemap(jboxtype, T) value) {
|
||||
Iterator itr = find(($typemap(jboxtype, K)) key);
|
||||
if (itr.isNot(end())) {
|
||||
$typemap(jboxtype, T) oldValue = itr.getValue();
|
||||
itr.setValue(value);
|
||||
return oldValue;
|
||||
} else {
|
||||
putUnchecked(key, value);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public $typemap(jboxtype, T) remove(java.lang.Object key) {
|
||||
if (!(key instanceof $typemap(jboxtype, K))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Iterator itr = find(($typemap(jboxtype, K)) key);
|
||||
if (itr.isNot(end())) {
|
||||
$typemap(jboxtype, T) oldValue = itr.getValue();
|
||||
removeUnchecked(itr);
|
||||
return oldValue;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public java.util.Set<Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)>> entrySet() {
|
||||
java.util.Set<Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)>> setToReturn =
|
||||
new java.util.HashSet<Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)>>();
|
||||
|
||||
Iterator itr = begin();
|
||||
final Iterator end = end();
|
||||
while (itr.isNot(end)) {
|
||||
setToReturn.add(new Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)>() {
|
||||
private Iterator iterator;
|
||||
|
||||
private Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)> init(Iterator iterator) {
|
||||
this.iterator = iterator;
|
||||
return this;
|
||||
}
|
||||
|
||||
public $typemap(jboxtype, K) getKey() {
|
||||
return iterator.getKey();
|
||||
}
|
||||
|
||||
public $typemap(jboxtype, T) getValue() {
|
||||
return iterator.getValue();
|
||||
}
|
||||
|
||||
public $typemap(jboxtype, T) setValue($typemap(jboxtype, T) newValue) {
|
||||
$typemap(jboxtype, T) oldValue = iterator.getValue();
|
||||
iterator.setValue(newValue);
|
||||
return oldValue;
|
||||
}
|
||||
}.init(itr));
|
||||
itr = itr.getNextUnchecked();
|
||||
}
|
||||
|
||||
return setToReturn;
|
||||
}
|
||||
%}
|
||||
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair< const K, T > value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
map();
|
||||
map(const map& other);
|
||||
|
||||
struct iterator {
|
||||
%typemap(javaclassmodifiers) iterator "protected class"
|
||||
%extend {
|
||||
const T& get(const K& key) throw (std::out_of_range) {
|
||||
std::map< K, T, C >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
std::map< K, T, C >::iterator getNextUnchecked() {
|
||||
std::map< K, T, C >::iterator copy = (*$self);
|
||||
return ++copy;
|
||||
}
|
||||
void set(const K& key, const T& x) {
|
||||
(*self)[key] = x;
|
||||
|
||||
bool isNot(iterator other) const {
|
||||
return (*$self != other);
|
||||
}
|
||||
void del(const K& key) throw (std::out_of_range) {
|
||||
std::map< K, T, C >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
self->erase(i);
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
|
||||
K getKey() const {
|
||||
return (*$self)->first;
|
||||
}
|
||||
bool has_key(const K& key) {
|
||||
std::map< K, T, C >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
|
||||
T getValue() const {
|
||||
return (*$self)->second;
|
||||
}
|
||||
|
||||
void setValue(const T& newValue) {
|
||||
(*$self)->second = newValue;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
%rename(isEmpty) empty;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
iterator find(const K& key);
|
||||
iterator begin();
|
||||
iterator end();
|
||||
%extend {
|
||||
%fragment("SWIG_MapSize");
|
||||
|
||||
jint sizeImpl() const throw (std::out_of_range) {
|
||||
return SWIG_MapSize(self->size());
|
||||
}
|
||||
|
||||
bool containsImpl(const K& key) {
|
||||
return (self->count(key) > 0);
|
||||
}
|
||||
|
||||
void putUnchecked(const K& key, const T& value) {
|
||||
(*self)[key] = value;
|
||||
}
|
||||
|
||||
void removeUnchecked(const std::map< K, T, C >::iterator itr) {
|
||||
self->erase(itr);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Legacy macros (deprecated)
|
||||
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
|
||||
@@ -18,12 +18,15 @@
|
||||
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);
|
||||
pair(const pair& other);
|
||||
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &p);
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &other);
|
||||
|
||||
T first;
|
||||
U second;
|
||||
|
||||
199
linx64/bin/swig/share/swig/4.0.0/java/std_set.i
Normal file
199
linx64/bin/swig/share/swig/4.0.0/java/std_set.i
Normal file
@@ -0,0 +1,199 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* std_set.i
|
||||
*
|
||||
* SWIG typemaps for std::set
|
||||
* The Java proxy class extends java.util.AbstractSet. The std::set
|
||||
* container looks and feels much like a java.util.HashSet from Java.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_common.i>
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// std::set
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
%{
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
%fragment("SWIG_SetSize", "header", fragment="SWIG_JavaIntFromSize_t") {
|
||||
SWIGINTERN jint SWIG_SetSize(size_t size) {
|
||||
jint sz = SWIG_JavaIntFromSize_t(size);
|
||||
if (sz == -1) {
|
||||
throw std::out_of_range("set size is too large to fit into a Java int");
|
||||
}
|
||||
|
||||
return sz;
|
||||
}
|
||||
}
|
||||
|
||||
%javamethodmodifiers std::set::sizeImpl "private";
|
||||
%javamethodmodifiers std::set::containsImpl "private";
|
||||
%javamethodmodifiers std::set::removeImpl "private";
|
||||
%javamethodmodifiers std::set::hasNextImpl "private";
|
||||
%javamethodmodifiers std::set::begin "private";
|
||||
%javamethodmodifiers std::set::end "private";
|
||||
|
||||
%rename(Iterator) std::set::iterator;
|
||||
%nodefaultctor std::set::iterator;
|
||||
%javamethodmodifiers std::set::iterator::incrementUnchecked "private";
|
||||
%javamethodmodifiers std::set::iterator::derefUnchecked "private";
|
||||
%javamethodmodifiers std::set::iterator::isNot "private";
|
||||
|
||||
namespace std {
|
||||
|
||||
template <class T>
|
||||
class set {
|
||||
|
||||
%typemap(javabase) std::set<T> "java.util.AbstractSet<$typemap(jboxtype, T)>"
|
||||
%proxycode %{
|
||||
public $javaclassname(java.util.Collection<? extends $typemap(jboxtype, T)> collection) {
|
||||
this();
|
||||
addAll(collection);
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return sizeImpl();
|
||||
}
|
||||
|
||||
public boolean addAll(java.util.Collection<? extends $typemap(jboxtype, T)> collection) {
|
||||
boolean didAddElement = false;
|
||||
for (java.lang.Object object : collection) {
|
||||
didAddElement |= add(($typemap(jboxtype, T))object);
|
||||
}
|
||||
|
||||
return didAddElement;
|
||||
}
|
||||
|
||||
public java.util.Iterator<$typemap(jboxtype, T)> iterator() {
|
||||
return new java.util.Iterator<$typemap(jboxtype, T)>() {
|
||||
private Iterator curr;
|
||||
private Iterator end;
|
||||
|
||||
private java.util.Iterator<$typemap(jboxtype, T)> init() {
|
||||
curr = $javaclassname.this.begin();
|
||||
end = $javaclassname.this.end();
|
||||
return this;
|
||||
}
|
||||
|
||||
public $typemap(jboxtype, T) next() {
|
||||
if (!hasNext()) {
|
||||
throw new java.util.NoSuchElementException();
|
||||
}
|
||||
|
||||
// Save the current position, increment it,
|
||||
// then return the value at the position before the increment.
|
||||
final $typemap(jboxtype, T) currValue = curr.derefUnchecked();
|
||||
curr.incrementUnchecked();
|
||||
return currValue;
|
||||
}
|
||||
|
||||
public boolean hasNext() {
|
||||
return curr.isNot(end);
|
||||
}
|
||||
}.init();
|
||||
}
|
||||
|
||||
public boolean containsAll(java.util.Collection<?> collection) {
|
||||
for (java.lang.Object object : collection) {
|
||||
if (!contains(object)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean contains(java.lang.Object object) {
|
||||
if (!(object instanceof $typemap(jboxtype, T))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return containsImpl(($typemap(jboxtype, T))object);
|
||||
}
|
||||
|
||||
public boolean removeAll(java.util.Collection<?> collection) {
|
||||
boolean didRemoveElement = false;
|
||||
for (java.lang.Object object : collection) {
|
||||
didRemoveElement |= remove(object);
|
||||
}
|
||||
|
||||
return didRemoveElement;
|
||||
}
|
||||
|
||||
public boolean remove(java.lang.Object object) {
|
||||
if (!(object instanceof $typemap(jboxtype, T))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return removeImpl(($typemap(jboxtype, T))object);
|
||||
}
|
||||
%}
|
||||
|
||||
public:
|
||||
|
||||
struct iterator {
|
||||
%typemap(javaclassmodifiers) iterator "protected class"
|
||||
%extend {
|
||||
void incrementUnchecked() {
|
||||
++(*$self);
|
||||
}
|
||||
|
||||
T derefUnchecked() const {
|
||||
return **$self;
|
||||
}
|
||||
|
||||
bool isNot(iterator other) const {
|
||||
return (*$self != other);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T key_type;
|
||||
typedef T value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
set();
|
||||
set(const set& other);
|
||||
|
||||
%rename(isEmpty) empty;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
iterator begin();
|
||||
iterator end();
|
||||
|
||||
%extend {
|
||||
%fragment("SWIG_SetSize");
|
||||
|
||||
// Returns whether item was inserted.
|
||||
bool add(const T& key) {
|
||||
return self->insert(key).second;
|
||||
}
|
||||
|
||||
// Returns whether set contains key.
|
||||
bool containsImpl(const T& key) {
|
||||
return (self->count(key) > 0);
|
||||
}
|
||||
|
||||
// Returns whether the item was erased.
|
||||
bool removeImpl(const T& key) {
|
||||
return (self->erase(key) > 0);
|
||||
}
|
||||
|
||||
jint sizeImpl() const throw (std::out_of_range) {
|
||||
return SWIG_SetSize(self->size());
|
||||
}
|
||||
|
||||
bool hasNextImpl(const iterator& itr) const {
|
||||
return (itr != $self->end());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
211
linx64/bin/swig/share/swig/4.0.0/java/std_unordered_map.i
Normal file
211
linx64/bin/swig/share/swig/4.0.0/java/std_unordered_map.i
Normal file
@@ -0,0 +1,211 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* std_unordered_map.i
|
||||
*
|
||||
* SWIG typemaps for std::unordered_map
|
||||
* The Java proxy class extends java.util.AbstractMap. The std::unordered_map
|
||||
* container looks and feels much like a java.util.HashMap from Java.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_common.i>
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// std::unordered_map
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
%{
|
||||
#include <unordered_map>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
%fragment("SWIG_MapSize", "header", fragment="SWIG_JavaIntFromSize_t") {
|
||||
SWIGINTERN jint SWIG_MapSize(size_t size) {
|
||||
jint sz = SWIG_JavaIntFromSize_t(size);
|
||||
if (sz == -1) {
|
||||
throw std::out_of_range("map size is too large to fit into a Java int");
|
||||
}
|
||||
|
||||
return sz;
|
||||
}
|
||||
}
|
||||
|
||||
%javamethodmodifiers std::unordered_map::sizeImpl "private";
|
||||
%javamethodmodifiers std::unordered_map::containsImpl "private";
|
||||
%javamethodmodifiers std::unordered_map::putUnchecked "private";
|
||||
%javamethodmodifiers std::unordered_map::removeUnchecked "private";
|
||||
%javamethodmodifiers std::unordered_map::find "private";
|
||||
%javamethodmodifiers std::unordered_map::begin "private";
|
||||
%javamethodmodifiers std::unordered_map::end "private";
|
||||
|
||||
%rename(Iterator) std::unordered_map::iterator;
|
||||
%nodefaultctor std::unordered_map::iterator;
|
||||
%javamethodmodifiers std::unordered_map::iterator::getNextUnchecked "private";
|
||||
%javamethodmodifiers std::unordered_map::iterator::isNot "private";
|
||||
%javamethodmodifiers std::unordered_map::iterator::getKey "private";
|
||||
%javamethodmodifiers std::unordered_map::iterator::getValue "private";
|
||||
%javamethodmodifiers std::unordered_map::iterator::setValue "private";
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class K, class T> class unordered_map {
|
||||
|
||||
%typemap(javabase) std::unordered_map<K, T>
|
||||
"java.util.AbstractMap<$typemap(jboxtype, K), $typemap(jboxtype, T)>"
|
||||
|
||||
%proxycode %{
|
||||
|
||||
public int size() {
|
||||
return sizeImpl();
|
||||
}
|
||||
|
||||
public boolean containsKey(java.lang.Object key) {
|
||||
if (!(key instanceof $typemap(jboxtype, K))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return containsImpl(($typemap(jboxtype, K))key);
|
||||
}
|
||||
|
||||
public $typemap(jboxtype, T) get(java.lang.Object key) {
|
||||
if (!(key instanceof $typemap(jboxtype, K))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Iterator itr = find(($typemap(jboxtype, K)) key);
|
||||
if (itr.isNot(end())) {
|
||||
return itr.getValue();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public $typemap(jboxtype, T) put($typemap(jboxtype, K) key, $typemap(jboxtype, T) value) {
|
||||
Iterator itr = find(($typemap(jboxtype, K)) key);
|
||||
if (itr.isNot(end())) {
|
||||
$typemap(jboxtype, T) oldValue = itr.getValue();
|
||||
itr.setValue(value);
|
||||
return oldValue;
|
||||
} else {
|
||||
putUnchecked(key, value);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public $typemap(jboxtype, T) remove(java.lang.Object key) {
|
||||
if (!(key instanceof $typemap(jboxtype, K))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Iterator itr = find(($typemap(jboxtype, K)) key);
|
||||
if (itr.isNot(end())) {
|
||||
$typemap(jboxtype, T) oldValue = itr.getValue();
|
||||
removeUnchecked(itr);
|
||||
return oldValue;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public java.util.Set<Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)>> entrySet() {
|
||||
java.util.Set<Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)>> setToReturn =
|
||||
new java.util.HashSet<Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)>>();
|
||||
|
||||
Iterator itr = begin();
|
||||
final Iterator end = end();
|
||||
while (itr.isNot(end)) {
|
||||
setToReturn.add(new Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)>() {
|
||||
private Iterator iterator;
|
||||
|
||||
private Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)> init(Iterator iterator) {
|
||||
this.iterator = iterator;
|
||||
return this;
|
||||
}
|
||||
|
||||
public $typemap(jboxtype, K) getKey() {
|
||||
return iterator.getKey();
|
||||
}
|
||||
|
||||
public $typemap(jboxtype, T) getValue() {
|
||||
return iterator.getValue();
|
||||
}
|
||||
|
||||
public $typemap(jboxtype, T) setValue($typemap(jboxtype, T) newValue) {
|
||||
$typemap(jboxtype, T) oldValue = iterator.getValue();
|
||||
iterator.setValue(newValue);
|
||||
return oldValue;
|
||||
}
|
||||
}.init(itr));
|
||||
itr = itr.getNextUnchecked();
|
||||
}
|
||||
|
||||
return setToReturn;
|
||||
}
|
||||
%}
|
||||
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair< const K, T > value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
unordered_map();
|
||||
unordered_map(const unordered_map& other);
|
||||
|
||||
struct iterator {
|
||||
%typemap(javaclassmodifiers) iterator "protected class"
|
||||
%extend {
|
||||
std::unordered_map< K, T >::iterator getNextUnchecked() {
|
||||
std::unordered_map< K, T >::iterator copy = (*$self);
|
||||
return ++copy;
|
||||
}
|
||||
|
||||
bool isNot(iterator other) const {
|
||||
return (*$self != other);
|
||||
}
|
||||
|
||||
K getKey() const {
|
||||
return (*$self)->first;
|
||||
}
|
||||
|
||||
T getValue() const {
|
||||
return (*$self)->second;
|
||||
}
|
||||
|
||||
void setValue(const T& newValue) {
|
||||
(*$self)->second = newValue;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
%rename(isEmpty) empty;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
iterator find(const K& key);
|
||||
iterator begin();
|
||||
iterator end();
|
||||
%extend {
|
||||
%fragment("SWIG_MapSize");
|
||||
|
||||
jint sizeImpl() const throw (std::out_of_range) {
|
||||
return SWIG_MapSize(self->size());
|
||||
}
|
||||
|
||||
bool containsImpl(const K& key) {
|
||||
return (self->count(key) > 0);
|
||||
}
|
||||
|
||||
void putUnchecked(const K& key, const T& value) {
|
||||
(*self)[key] = value;
|
||||
}
|
||||
|
||||
void removeUnchecked(const std::unordered_map< K, T >::iterator itr) {
|
||||
self->erase(itr);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
199
linx64/bin/swig/share/swig/4.0.0/java/std_unordered_set.i
Normal file
199
linx64/bin/swig/share/swig/4.0.0/java/std_unordered_set.i
Normal file
@@ -0,0 +1,199 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* std_unordered_set.i
|
||||
*
|
||||
* SWIG typemaps for std::unordered_set
|
||||
* The Java proxy class extends java.util.AbstractSet. The std::unordered_set
|
||||
* container looks and feels much like a java.util.HashSet from Java.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_common.i>
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// std::unordered_set
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
%{
|
||||
#include <unordered_set>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
%fragment("SWIG_UnorderedSetSize", "header", fragment="SWIG_JavaIntFromSize_t") {
|
||||
SWIGINTERN jint SWIG_UnorderedSetSize(size_t size) {
|
||||
jint sz = SWIG_JavaIntFromSize_t(size);
|
||||
if (sz == -1) {
|
||||
throw std::out_of_range("unordered_set size is too large to fit into a Java int");
|
||||
}
|
||||
|
||||
return sz;
|
||||
}
|
||||
}
|
||||
|
||||
%javamethodmodifiers std::unordered_set::sizeImpl "private";
|
||||
%javamethodmodifiers std::unordered_set::containsImpl "private";
|
||||
%javamethodmodifiers std::unordered_set::removeImpl "private";
|
||||
%javamethodmodifiers std::unordered_set::hasNextImpl "private";
|
||||
%javamethodmodifiers std::unordered_set::begin "private";
|
||||
%javamethodmodifiers std::unordered_set::end "private";
|
||||
|
||||
%rename(Iterator) std::unordered_set::iterator;
|
||||
%nodefaultctor std::unordered_set::iterator;
|
||||
%javamethodmodifiers std::unordered_set::iterator::incrementUnchecked "private";
|
||||
%javamethodmodifiers std::unordered_set::iterator::derefUnchecked "private";
|
||||
%javamethodmodifiers std::unordered_set::iterator::isNot "private";
|
||||
|
||||
namespace std {
|
||||
|
||||
template <class Key>
|
||||
class unordered_set {
|
||||
|
||||
%typemap(javabase) std::unordered_set<Key> "java.util.AbstractSet<$typemap(jboxtype, Key)>"
|
||||
%proxycode %{
|
||||
public $javaclassname(java.util.Collection<? extends $typemap(jboxtype, Key)> collection) {
|
||||
this();
|
||||
addAll(collection);
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return sizeImpl();
|
||||
}
|
||||
|
||||
public boolean addAll(java.util.Collection<? extends $typemap(jboxtype, Key)> collection) {
|
||||
boolean didAddElement = false;
|
||||
for (java.lang.Object object : collection) {
|
||||
didAddElement |= add(($typemap(jboxtype, Key))object);
|
||||
}
|
||||
|
||||
return didAddElement;
|
||||
}
|
||||
|
||||
public java.util.Iterator<$typemap(jboxtype, Key)> iterator() {
|
||||
return new java.util.Iterator<$typemap(jboxtype, Key)>() {
|
||||
private Iterator curr;
|
||||
private Iterator end;
|
||||
|
||||
private java.util.Iterator<$typemap(jboxtype, Key)> init() {
|
||||
curr = $javaclassname.this.begin();
|
||||
end = $javaclassname.this.end();
|
||||
return this;
|
||||
}
|
||||
|
||||
public $typemap(jboxtype, Key) next() {
|
||||
if (!hasNext()) {
|
||||
throw new java.util.NoSuchElementException();
|
||||
}
|
||||
|
||||
// Save the current position, increment it,
|
||||
// then return the value at the position before the increment.
|
||||
final $typemap(jboxtype, Key) currValue = curr.derefUnchecked();
|
||||
curr.incrementUnchecked();
|
||||
return currValue;
|
||||
}
|
||||
|
||||
public boolean hasNext() {
|
||||
return curr.isNot(end);
|
||||
}
|
||||
}.init();
|
||||
}
|
||||
|
||||
public boolean containsAll(java.util.Collection<?> collection) {
|
||||
for (java.lang.Object object : collection) {
|
||||
if (!contains(object)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean contains(java.lang.Object object) {
|
||||
if (!(object instanceof $typemap(jboxtype, Key))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return containsImpl(($typemap(jboxtype, Key))object);
|
||||
}
|
||||
|
||||
public boolean removeAll(java.util.Collection<?> collection) {
|
||||
boolean didRemoveElement = false;
|
||||
for (java.lang.Object object : collection) {
|
||||
didRemoveElement |= remove(object);
|
||||
}
|
||||
|
||||
return didRemoveElement;
|
||||
}
|
||||
|
||||
public boolean remove(java.lang.Object object) {
|
||||
if (!(object instanceof $typemap(jboxtype, Key))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return removeImpl(($typemap(jboxtype, Key))object);
|
||||
}
|
||||
%}
|
||||
|
||||
public:
|
||||
|
||||
struct iterator {
|
||||
%typemap(javaclassmodifiers) iterator "protected class"
|
||||
%extend {
|
||||
void incrementUnchecked() {
|
||||
++(*$self);
|
||||
}
|
||||
|
||||
Key derefUnchecked() const {
|
||||
return **$self;
|
||||
}
|
||||
|
||||
bool isNot(iterator other) const {
|
||||
return (*$self != other);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
unordered_set();
|
||||
unordered_set(const unordered_set& other);
|
||||
|
||||
%rename(isEmpty) empty;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
iterator begin();
|
||||
iterator end();
|
||||
|
||||
%extend {
|
||||
%fragment("SWIG_UnorderedSetSize");
|
||||
|
||||
// Returns whether item was inserted.
|
||||
bool add(const Key& key) {
|
||||
return self->insert(key).second;
|
||||
}
|
||||
|
||||
// Returns whether set contains key.
|
||||
bool containsImpl(const Key& key) {
|
||||
return (self->count(key) > 0);
|
||||
}
|
||||
|
||||
// Returns whether the item was erased.
|
||||
bool removeImpl(const Key& key) {
|
||||
return (self->erase(key) > 0);
|
||||
}
|
||||
|
||||
jint sizeImpl() const throw (std::out_of_range) {
|
||||
return SWIG_UnorderedSetSize(self->size());
|
||||
}
|
||||
|
||||
bool hasNextImpl(const iterator& itr) const {
|
||||
return (itr != $self->end());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -23,7 +23,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) {
|
||||
}
|
||||
}
|
||||
|
||||
%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CTYPE, CREF_TYPE)
|
||||
%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CTYPE, CONST_REFERENCE)
|
||||
%typemap(javabase) std::vector< CTYPE > "java.util.AbstractList<$typemap(jboxtype, CTYPE)>"
|
||||
%typemap(javainterfaces) std::vector< CTYPE > "java.util.RandomAccess"
|
||||
%proxycode %{
|
||||
@@ -79,13 +79,14 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) {
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef CTYPE value_type;
|
||||
typedef CTYPE &reference;
|
||||
typedef CREF_TYPE const_reference;
|
||||
typedef CTYPE *pointer;
|
||||
typedef CTYPE const *const_pointer;
|
||||
typedef CTYPE &reference;
|
||||
typedef CONST_REFERENCE const_reference;
|
||||
|
||||
vector();
|
||||
vector(const vector &other);
|
||||
|
||||
size_type capacity() const;
|
||||
void reserve(size_type n) throw (std::length_error);
|
||||
%rename(isEmpty) empty;
|
||||
@@ -93,11 +94,6 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) {
|
||||
void clear();
|
||||
%extend {
|
||||
%fragment("SWIG_VectorSize");
|
||||
vector(jint count) throw (std::out_of_range) {
|
||||
if (count < 0)
|
||||
throw std::out_of_range("vector count must be positive");
|
||||
return new std::vector< CTYPE >(static_cast<std::vector< CTYPE >::size_type>(count));
|
||||
}
|
||||
|
||||
vector(jint count, const CTYPE &value) throw (std::out_of_range) {
|
||||
if (count < 0)
|
||||
@@ -109,14 +105,14 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) {
|
||||
return SWIG_VectorSize(self->size());
|
||||
}
|
||||
|
||||
void doAdd(const value_type& value) {
|
||||
self->push_back(value);
|
||||
void doAdd(const value_type& x) {
|
||||
self->push_back(x);
|
||||
}
|
||||
|
||||
void doAdd(jint index, const value_type& value) throw (std::out_of_range) {
|
||||
void doAdd(jint index, const value_type& x) throw (std::out_of_range) {
|
||||
jint size = static_cast<jint>(self->size());
|
||||
if (0 <= index && index <= size) {
|
||||
self->insert(self->begin() + index, value);
|
||||
self->insert(self->begin() + index, x);
|
||||
} else {
|
||||
throw std::out_of_range("vector index out of range");
|
||||
}
|
||||
@@ -133,7 +129,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) {
|
||||
}
|
||||
}
|
||||
|
||||
CREF_TYPE doGet(jint index) throw (std::out_of_range) {
|
||||
CONST_REFERENCE doGet(jint index) throw (std::out_of_range) {
|
||||
jint size = static_cast<jint>(self->size());
|
||||
if (index >= 0 && index < size)
|
||||
return (*self)[index];
|
||||
@@ -141,11 +137,11 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) {
|
||||
throw std::out_of_range("vector index out of range");
|
||||
}
|
||||
|
||||
value_type doSet(jint index, const value_type& value) throw (std::out_of_range) {
|
||||
value_type doSet(jint index, const value_type& val) throw (std::out_of_range) {
|
||||
jint size = static_cast<jint>(self->size());
|
||||
if (index >= 0 && index < size) {
|
||||
CTYPE const old_value = (*self)[index];
|
||||
(*self)[index] = value;
|
||||
(*self)[index] = val;
|
||||
return old_value;
|
||||
}
|
||||
else
|
||||
@@ -173,7 +169,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) {
|
||||
namespace std {
|
||||
|
||||
template<class T> class vector {
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(T, const T&)
|
||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(T, const value_type&)
|
||||
};
|
||||
|
||||
// bool specialization
|
||||
|
||||
@@ -150,7 +150,7 @@ SWIGRUNTIME int SWIG_JSC_ConvertPtr(JSContextRef context, JSValueRef valRef, voi
|
||||
/* special case: JavaScript null => C NULL pointer */
|
||||
if(JSValueIsNull(context, valRef)) {
|
||||
*ptr=0;
|
||||
return SWIG_OK;
|
||||
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||
}
|
||||
|
||||
if(!JSValueIsObject(context, valRef)) {
|
||||
|
||||
@@ -27,8 +27,15 @@ namespace std {
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair< const K, T > value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
|
||||
map();
|
||||
map(const map< K, T, C > &);
|
||||
map(const map& other);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
|
||||
@@ -18,12 +18,14 @@
|
||||
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);
|
||||
pair(const pair& other);
|
||||
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &p);
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &other);
|
||||
|
||||
T first;
|
||||
U second;
|
||||
|
||||
@@ -14,10 +14,17 @@ namespace std {
|
||||
template<class T> class vector {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
vector();
|
||||
vector(size_type n);
|
||||
vector(const vector& other);
|
||||
|
||||
size_type size() const;
|
||||
size_type capacity() const;
|
||||
void reserve(size_type n);
|
||||
@@ -48,10 +55,17 @@ namespace std {
|
||||
template<> class vector<bool> {
|
||||
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 bool const_reference;
|
||||
|
||||
vector();
|
||||
vector(size_type n);
|
||||
vector(const vector& other);
|
||||
|
||||
size_type size() const;
|
||||
size_type capacity() const;
|
||||
void reserve(size_type n);
|
||||
|
||||
@@ -93,7 +93,7 @@ SWIGRUNTIME void JS_veto_set_variable(v8::Local<v8::Name> property, v8::Local<v8
|
||||
#else
|
||||
v8::Local<v8::String> sproperty;
|
||||
if (property->ToString(SWIGV8_CURRENT_CONTEXT()).ToLocal(&sproperty)) {
|
||||
sproperty->WriteUtf8(buffer, 256);
|
||||
SWIGV8_WRITE_UTF8(sproperty, buffer, 256);
|
||||
res = sprintf(msg, "Tried to write read-only variable: %s.", buffer);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -22,7 +22,7 @@ int SWIG_AsVal_dec(bool)(v8::Handle<v8::Value> obj, bool *val)
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (val) *val = obj->BooleanValue();
|
||||
if (val) *val = SWIGV8_BOOLEAN_VALUE(obj);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ int SWIG_AsVal_dec(int)(v8::Handle<v8::Value> valRef, int* val)
|
||||
if (!valRef->IsNumber()) {
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
if(val) *val = valRef->IntegerValue();
|
||||
if(val) *val = SWIGV8_INTEGER_VALUE(valRef);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ int SWIG_AsVal_dec(long)(v8::Handle<v8::Value> obj, long* val)
|
||||
if (!obj->IsNumber()) {
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
if(val) *val = (long) obj->IntegerValue();
|
||||
if(val) *val = (long) SWIGV8_INTEGER_VALUE(obj);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
@@ -95,7 +95,7 @@ int SWIG_AsVal_dec(unsigned long)(v8::Handle<v8::Value> obj, unsigned long *val)
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
|
||||
long longVal = (long) obj->NumberValue();
|
||||
long longVal = (long) SWIGV8_NUMBER_VALUE(obj);
|
||||
|
||||
if(longVal < 0) {
|
||||
return SWIG_OverflowError;
|
||||
@@ -133,7 +133,7 @@ int SWIG_AsVal_dec(long long)(v8::Handle<v8::Value> obj, long long* val)
|
||||
if (!obj->IsNumber()) {
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
if(val) *val = (long long) obj->IntegerValue();
|
||||
if(val) *val = (long long) SWIGV8_INTEGER_VALUE(obj);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
@@ -168,7 +168,7 @@ int SWIG_AsVal_dec(unsigned long long)(v8::Handle<v8::Value> obj, unsigned long
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
|
||||
long long longVal = (long long) obj->NumberValue();
|
||||
long long longVal = (long long) SWIGV8_NUMBER_VALUE(obj);
|
||||
|
||||
if(longVal < 0) {
|
||||
return SWIG_OverflowError;
|
||||
@@ -198,7 +198,7 @@ int SWIG_AsVal_dec(double)(v8::Handle<v8::Value> obj, double *val)
|
||||
if(!obj->IsNumber()) {
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
if(val) *val = obj->NumberValue();
|
||||
if(val) *val = SWIGV8_NUMBER_VALUE(obj);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
@@ -91,6 +91,32 @@ typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
|
||||
#define SWIGV8_SET_CLASS_TEMPL(class_templ, class) class_templ.Reset(v8::Isolate::GetCurrent(), class);
|
||||
#endif
|
||||
|
||||
#ifdef NODE_VERSION
|
||||
#if NODE_VERSION_AT_LEAST(10, 12, 0)
|
||||
#define SWIG_NODE_AT_LEAST_1012
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Necessary to check Node.js version because V8 API changes are backported in Node.js
|
||||
#if (defined(NODE_VERSION) && !defined(SWIG_NODE_AT_LEAST_1012)) || \
|
||||
(!defined(NODE_VERSION) && (V8_MAJOR_VERSION-0) < 7)
|
||||
#define SWIGV8_TO_OBJECT(handle) (handle)->ToObject()
|
||||
#define SWIGV8_TO_STRING(handle) (handle)->ToString()
|
||||
#define SWIGV8_NUMBER_VALUE(handle) (handle)->NumberValue()
|
||||
#define SWIGV8_INTEGER_VALUE(handle) (handle)->IntegerValue()
|
||||
#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue()
|
||||
#define SWIGV8_WRITE_UTF8(handle, buffer, len) (handle)->WriteUtf8(buffer, len)
|
||||
#define SWIGV8_UTF8_LENGTH(handle) (handle)->Utf8Length()
|
||||
#else
|
||||
#define SWIGV8_TO_OBJECT(handle) (handle)->ToObject(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked()
|
||||
#define SWIGV8_TO_STRING(handle) (handle)->ToString(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked()
|
||||
#define SWIGV8_NUMBER_VALUE(handle) (handle)->NumberValue(SWIGV8_CURRENT_CONTEXT()).ToChecked()
|
||||
#define SWIGV8_INTEGER_VALUE(handle) (handle)->IntegerValue(SWIGV8_CURRENT_CONTEXT()).ToChecked()
|
||||
#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue(SWIGV8_CURRENT_CONTEXT()).ToChecked()
|
||||
#define SWIGV8_WRITE_UTF8(handle, buffer, len) (handle)->WriteUtf8(v8::Isolate::GetCurrent(), buffer, len)
|
||||
#define SWIGV8_UTF8_LENGTH(handle) (handle)->Utf8Length(v8::Isolate::GetCurrent())
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Error handling
|
||||
*
|
||||
@@ -258,7 +284,7 @@ SWIGRUNTIME int SWIG_V8_GetInstancePtr(v8::Handle<v8::Value> valRef, void **ptr)
|
||||
if(!valRef->IsObject()) {
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
v8::Handle<v8::Object> objRef = valRef->ToObject();
|
||||
v8::Handle<v8::Object> objRef = SWIGV8_TO_OBJECT(valRef);
|
||||
|
||||
if(objRef->InternalFieldCount() < 1) return SWIG_ERROR;
|
||||
|
||||
@@ -347,12 +373,12 @@ SWIGRUNTIME int SWIG_V8_ConvertPtr(v8::Handle<v8::Value> valRef, void **ptr, swi
|
||||
/* special case: JavaScript null => C NULL pointer */
|
||||
if(valRef->IsNull()) {
|
||||
*ptr=0;
|
||||
return SWIG_OK;
|
||||
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||
}
|
||||
if(!valRef->IsObject()) {
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
v8::Handle<v8::Object> objRef = valRef->ToObject();
|
||||
v8::Handle<v8::Object> objRef = SWIGV8_TO_OBJECT(valRef);
|
||||
return SWIG_V8_ConvertInstancePtr(objRef, ptr, info, flags);
|
||||
}
|
||||
|
||||
@@ -479,7 +505,7 @@ SWIGRUNTIMEINLINE
|
||||
int SwigV8Packed_Check(v8::Handle<v8::Value> valRef) {
|
||||
SWIGV8_HANDLESCOPE();
|
||||
|
||||
v8::Handle<v8::Object> objRef = valRef->ToObject();
|
||||
v8::Handle<v8::Object> objRef = SWIGV8_TO_OBJECT(valRef);
|
||||
if(objRef->InternalFieldCount() < 1) return false;
|
||||
#if (V8_MAJOR_VERSION-0) < 5
|
||||
v8::Handle<v8::Value> flag = objRef->GetHiddenValue(SWIGV8_STRING_NEW("__swig__packed_data__"));
|
||||
@@ -489,7 +515,7 @@ int SwigV8Packed_Check(v8::Handle<v8::Value> valRef) {
|
||||
if (!objRef->GetPrivate(SWIGV8_CURRENT_CONTEXT(), privateKey).ToLocal(&flag))
|
||||
return false;
|
||||
#endif
|
||||
return (flag->IsBoolean() && flag->BooleanValue());
|
||||
return (flag->IsBoolean() && SWIGV8_BOOLEAN_VALUE(flag));
|
||||
}
|
||||
|
||||
SWIGRUNTIME
|
||||
@@ -499,7 +525,7 @@ swig_type_info *SwigV8Packed_UnpackData(v8::Handle<v8::Value> valRef, void *ptr,
|
||||
|
||||
SwigV8PackedData *sobj;
|
||||
|
||||
v8::Handle<v8::Object> objRef = valRef->ToObject();
|
||||
v8::Handle<v8::Object> objRef = SWIGV8_TO_OBJECT(valRef);
|
||||
|
||||
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511)
|
||||
v8::Handle<v8::Value> cdataRef = objRef->GetInternalField(0);
|
||||
|
||||
@@ -44,6 +44,8 @@
|
||||
#ifdef BUILDING_NODE_EXTENSION
|
||||
%insert("runtime") %{
|
||||
#include <node.h>
|
||||
//Older version of node.h does not include this
|
||||
#include <node_version.h>
|
||||
%}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ SWIGINTERN int
|
||||
SWIG_AsCharPtrAndSize(v8::Handle<v8::Value> valRef, char** cptr, size_t* psize, int *alloc)
|
||||
{
|
||||
if(valRef->IsString()) {
|
||||
v8::Handle<v8::String> js_str = valRef->ToString();
|
||||
v8::Handle<v8::String> js_str = SWIGV8_TO_STRING(valRef);
|
||||
|
||||
size_t len = js_str->Utf8Length() + 1;
|
||||
size_t len = SWIGV8_UTF8_LENGTH(js_str) + 1;
|
||||
char* cstr = new char[len];
|
||||
js_str->WriteUtf8(cstr, len);
|
||||
SWIGV8_WRITE_UTF8(js_str, cstr, len);
|
||||
|
||||
if(alloc) *alloc = SWIG_NEWOBJ;
|
||||
if(psize) *psize = len;
|
||||
@@ -20,7 +20,7 @@ SWIG_AsCharPtrAndSize(v8::Handle<v8::Value> valRef, char** cptr, size_t* psize,
|
||||
return SWIG_OK;
|
||||
} else {
|
||||
if(valRef->IsObject()) {
|
||||
v8::Handle<v8::Object> obj = valRef->ToObject();
|
||||
v8::Handle<v8::Object> obj = SWIGV8_TO_OBJECT(valRef);
|
||||
// try if the object is a wrapped char[]
|
||||
swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
|
||||
if (pchar_descriptor) {
|
||||
|
||||
@@ -27,8 +27,14 @@ namespace std {
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair< const K, T > value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
map();
|
||||
map(const map< K, T, C > &);
|
||||
map(const map& other);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
|
||||
@@ -17,12 +17,14 @@
|
||||
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);
|
||||
pair(const pair& other);
|
||||
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &p);
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &other);
|
||||
|
||||
T first;
|
||||
U second;
|
||||
|
||||
@@ -14,10 +14,17 @@ namespace std {
|
||||
template<class T> class vector {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
vector();
|
||||
vector(size_type n);
|
||||
vector(const vector& other);
|
||||
|
||||
size_type size() const;
|
||||
size_type capacity() const;
|
||||
void reserve(size_type n);
|
||||
@@ -48,10 +55,17 @@ namespace std {
|
||||
template<> class vector<bool> {
|
||||
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 bool const_reference;
|
||||
|
||||
vector();
|
||||
vector(size_type n);
|
||||
vector(const vector& other);
|
||||
|
||||
size_type size() const;
|
||||
size_type capacity() const;
|
||||
void reserve(size_type n);
|
||||
|
||||
@@ -1765,7 +1765,12 @@ SWIGRUNTIME int SWIG_Lua_ConvertPtr(lua_State *L,int index,void **ptr,swig_type
|
||||
{
|
||||
swig_lua_userdata *usr;
|
||||
swig_cast_info *cast;
|
||||
if (lua_isnil(L,index)){*ptr=0; return SWIG_OK;} /* special case: lua nil => NULL pointer */
|
||||
/* special case: lua nil => NULL pointer */
|
||||
if (lua_isnil(L,index))
|
||||
{
|
||||
*ptr=0;
|
||||
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||
}
|
||||
usr=(swig_lua_userdata*)lua_touserdata(L,index); /* get data */
|
||||
if (usr)
|
||||
{
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
* all the runtime code for .
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%runtime "swigrun.swg"; /* Common C API type-checking code */
|
||||
%runtime "luarun.swg"; /* Lua runtime stuff */
|
||||
%runtime "swigrun.swg" /* Common C API type-checking code */
|
||||
%runtime "swigerrors.swg" /* SWIG errors */
|
||||
%runtime "luarun.swg" /* Lua runtime stuff */
|
||||
|
||||
%insert(initbeforefunc) "swiginit.swg"
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ SWIGINTERN int SWIG_lua_isnilstring(lua_State *L, int idx) {
|
||||
// Also needed for object ptrs by const ref
|
||||
// eg A* const& ref_pointer(A* const& a);
|
||||
// found in mixed_types.i
|
||||
%typemap(in,checkfn="lua_isuserdata") SWIGTYPE *const&($*ltype temp)
|
||||
%typemap(in,checkfn="SWIG_isptrtype") SWIGTYPE *const&($*ltype temp)
|
||||
%{temp=($*ltype)SWIG_MustGetPtr(L,$input,$*descriptor,0,$argnum,"$symname");
|
||||
$1=($1_ltype)&temp;%}
|
||||
|
||||
@@ -327,7 +327,7 @@ parameters match which function
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE & {
|
||||
void *ptr;
|
||||
if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $1_descriptor, 0)) {
|
||||
if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $1_descriptor, SWIG_POINTER_NO_NULL)) {
|
||||
$1 = 0;
|
||||
} else {
|
||||
$1 = 1;
|
||||
@@ -336,7 +336,7 @@ parameters match which function
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE && {
|
||||
void *ptr;
|
||||
if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $1_descriptor, 0)) {
|
||||
if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $1_descriptor, SWIG_POINTER_NO_NULL)) {
|
||||
$1 = 0;
|
||||
} else {
|
||||
$1 = 1;
|
||||
@@ -345,7 +345,7 @@ parameters match which function
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE {
|
||||
void *ptr;
|
||||
if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $&1_descriptor, 0)) {
|
||||
if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $&1_descriptor, SWIG_POINTER_NO_NULL)) {
|
||||
$1 = 0;
|
||||
} else {
|
||||
$1 = 1;
|
||||
@@ -367,7 +367,7 @@ parameters match which function
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *const&
|
||||
{
|
||||
void *ptr;
|
||||
if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $*descriptor, 0)) {
|
||||
if (SWIG_isptrtype(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $*descriptor, 0)) {
|
||||
$1 = 0;
|
||||
} else {
|
||||
$1 = 1;
|
||||
|
||||
@@ -27,8 +27,14 @@ namespace std {
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair< const K, T > value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
map();
|
||||
map(const map< K, T, C> &);
|
||||
map(const map& other);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
|
||||
@@ -7,21 +7,6 @@
|
||||
%{
|
||||
#include <utility>
|
||||
%}
|
||||
/*
|
||||
A really cut down version of the pair class.
|
||||
|
||||
this is not useful on its own - 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 {
|
||||
@@ -30,13 +15,12 @@ namespace std {
|
||||
|
||||
pair();
|
||||
pair(T first, U second);
|
||||
pair(const pair& p);
|
||||
pair(const pair& other);
|
||||
|
||||
T first;
|
||||
U second;
|
||||
};
|
||||
|
||||
template <class T, class U >
|
||||
pair<T,U> make_pair(const T&,const U&);
|
||||
|
||||
pair<T,U> make_pair(const T& first, const U& second);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,6 @@ as this is overloaded by the const char* version
|
||||
public:
|
||||
string();
|
||||
string(const char*);
|
||||
//string(const string&);
|
||||
unsigned int size() const;
|
||||
unsigned int length() const;
|
||||
bool empty() const;
|
||||
@@ -119,7 +118,6 @@ as this is overloaded by the const char* version
|
||||
// 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
|
||||
// it's probably better to do it in lua
|
||||
};
|
||||
|
||||
@@ -25,10 +25,19 @@ namespace std {
|
||||
template<class T>
|
||||
class vector {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
vector();
|
||||
vector(unsigned int);
|
||||
vector(const vector&);
|
||||
vector(const vector& other);
|
||||
vector(unsigned int,T);
|
||||
|
||||
unsigned int size() const;
|
||||
unsigned int max_size() const;
|
||||
bool empty() const;
|
||||
|
||||
@@ -1,787 +0,0 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* 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) 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((const $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(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 &&, 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 [],
|
||||
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 [], 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 && %{
|
||||
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 [], 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 && %{
|
||||
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 [], SWIGTYPE (CLASS::*) ""
|
||||
%typemap(m3classmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "public"
|
||||
%typemap(m3code) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
|
||||
%typemap(m3imports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "using System;"
|
||||
%typemap(m3interfaces) SWIGTYPE "IDisposable"
|
||||
%typemap(m3interfaces_derived) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
|
||||
%typemap(m3ptrconstructormodifiers) SWIGTYPE, 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 [], 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 };
|
||||
|
||||
/* Array reference typemaps */
|
||||
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
|
||||
%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
|
||||
|
||||
/* const pointers */
|
||||
%apply SWIGTYPE * { SWIGTYPE *const }
|
||||
%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
|
||||
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* 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
|
||||
@@ -1,74 +0,0 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* 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"
|
||||
|
||||
@@ -158,7 +158,7 @@ SWIG_MzScheme_ConvertPtr(Scheme_Object *s, void **result, swig_type_info *type,
|
||||
|
||||
if (SCHEME_NULLP(s)) {
|
||||
*result = NULL;
|
||||
return 0;
|
||||
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||
} else if (SCHEME_TYPE(s) == swig_type) {
|
||||
struct swig_mz_proxy *proxy = (struct swig_mz_proxy *) s;
|
||||
if (type) {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
/* Include headers */
|
||||
%runtime "swigrun.swg" // Common C API type-checking code
|
||||
%runtime "swigerrors.swg" // SWIG errors
|
||||
%runtime "mzrun.swg"
|
||||
|
||||
%define SWIG_APPEND_VALUE(value)
|
||||
|
||||
@@ -221,8 +221,14 @@ namespace std {
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair< const K, T > value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
map();
|
||||
map(const map< K, T, C > &);
|
||||
map(const map& other);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
@@ -441,8 +447,18 @@ namespace std {
|
||||
%rename("delete!") __delitem__;
|
||||
%rename("has-key?") has_key;
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair< const K, T > value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
map();
|
||||
map(const map< K, T, C > &);
|
||||
map(const map& other);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
@@ -653,8 +669,18 @@ namespace std {
|
||||
%rename("delete!") __delitem__;
|
||||
%rename("has-key?") has_key;
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair< const K, T > value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
map();
|
||||
map(const map< K, T, C > &);
|
||||
map(const map& other);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
@@ -865,8 +891,18 @@ namespace std {
|
||||
%rename("delete!") __delitem__;
|
||||
%rename("has-key?") has_key;
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair< const K, T > value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
map();
|
||||
map(const map< K, T, C > &);
|
||||
map(const map& other);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
|
||||
@@ -115,11 +115,15 @@ namespace std {
|
||||
$1 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
typedef T first_type;
|
||||
typedef U second_type;
|
||||
|
||||
pair();
|
||||
pair(T first, U second);
|
||||
pair(const pair& p);
|
||||
pair(const pair& other);
|
||||
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &p);
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &other);
|
||||
|
||||
T first;
|
||||
U second;
|
||||
@@ -219,9 +223,9 @@ namespace std {
|
||||
}
|
||||
pair();
|
||||
pair(T first, U second);
|
||||
pair(const pair& p);
|
||||
pair(const pair& other);
|
||||
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &p);
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &other);
|
||||
|
||||
T first;
|
||||
U second;
|
||||
@@ -320,9 +324,9 @@ namespace std {
|
||||
}
|
||||
pair();
|
||||
pair(T first, U second);
|
||||
pair(const pair& p);
|
||||
pair(const pair& other);
|
||||
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &p);
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &other);
|
||||
|
||||
T first;
|
||||
U second;
|
||||
@@ -415,9 +419,9 @@ namespace std {
|
||||
}
|
||||
pair();
|
||||
pair(T first, U second);
|
||||
pair(const pair& p);
|
||||
pair(const pair& other);
|
||||
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &p);
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &other);
|
||||
|
||||
T first;
|
||||
U second;
|
||||
|
||||
@@ -189,9 +189,18 @@ namespace std {
|
||||
}
|
||||
}
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
vector(unsigned int size = 0);
|
||||
vector(unsigned int size, const T& value);
|
||||
vector(const vector<T>&);
|
||||
vector(const vector& other);
|
||||
|
||||
%rename(length) size;
|
||||
unsigned int size() const;
|
||||
%rename("empty?") empty;
|
||||
@@ -365,9 +374,18 @@ namespace std {
|
||||
}
|
||||
}
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
vector(unsigned int size = 0);
|
||||
vector(unsigned int size, const T& value);
|
||||
vector(const vector<T>&);
|
||||
vector(const vector& other);
|
||||
|
||||
%rename(length) size;
|
||||
unsigned int size() const;
|
||||
%rename("empty?") empty;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* stl.i
|
||||
*
|
||||
* Initial STL definition. extended as needed in each language
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_common.i>
|
||||
%include <std_string.i>
|
||||
%include <std_vector.i>
|
||||
|
||||
@@ -329,7 +329,7 @@ REF_MAP(double, SCHEME_REALP, scheme_real_to_double,
|
||||
$1 = (SCHEME_STRINGP($input)) ? 1 : 0;
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE [] {
|
||||
void *ptr;
|
||||
if (SWIG_ConvertPtr($input, (void **) &ptr, $1_descriptor, 0)) {
|
||||
$1 = 0;
|
||||
@@ -338,9 +338,18 @@ REF_MAP(double, SCHEME_REALP, scheme_real_to_double,
|
||||
}
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE &, SWIGTYPE && {
|
||||
void *ptr;
|
||||
if (SWIG_ConvertPtr($input, (void **) &ptr, $1_descriptor, SWIG_POINTER_NO_NULL)) {
|
||||
$1 = 0;
|
||||
} else {
|
||||
$1 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE {
|
||||
void *ptr;
|
||||
if (SWIG_ConvertPtr($input, (void **) &ptr, $&1_descriptor, 0)) {
|
||||
if (SWIG_ConvertPtr($input, (void **) &ptr, $&1_descriptor, SWIG_POINTER_NO_NULL)) {
|
||||
$1 = 0;
|
||||
} else {
|
||||
$1 = 1;
|
||||
|
||||
@@ -9,7 +9,6 @@ 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]));
|
||||
@@ -20,7 +19,6 @@ type _value = c_obj
|
||||
%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));
|
||||
@@ -57,7 +55,6 @@ type _value = c_obj
|
||||
%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 *)
|
||||
@@ -69,7 +66,6 @@ type _value = c_obj
|
||||
%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)
|
||||
@@ -89,7 +85,7 @@ type _value = c_obj
|
||||
caml_array_set
|
||||
($result,
|
||||
i,
|
||||
callback(*fromval,caml_val_ptr((void *)&$1[i],$*1_descriptor)));
|
||||
caml_callback(*fromval,caml_val_ptr((void *)&$1[i],$*1_descriptor)));
|
||||
} else {
|
||||
caml_array_set
|
||||
($result,
|
||||
@@ -102,7 +98,6 @@ type _value = c_obj
|
||||
%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)
|
||||
@@ -119,7 +114,7 @@ type _value = c_obj
|
||||
caml_array_set
|
||||
($result,
|
||||
i,
|
||||
callback2(*caml_named_value(SWIG_MODULE "_int_to_enum"),
|
||||
caml_callback2(*caml_named_value(SWIG_MODULE "_int_to_enum"),
|
||||
*caml_named_value("$type_marker"),
|
||||
Val_int($1[i])));
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ begin
|
||||
(fun mth arg -> invoke_inner raw_ptr mth arg)
|
||||
end
|
||||
|
||||
let _ = register_class_byname "$realname" create_$classname_from_ptr
|
||||
let _ = Callback.register
|
||||
"create_$normalized_from_ptr"
|
||||
create_$classname_from_ptr
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
%define %cstring_mutable(TYPEMAP,...)
|
||||
%typemap(in) TYPEMAP {
|
||||
char *t = String_val($input);
|
||||
int n = string_length($input);
|
||||
int n = caml_string_length($input);
|
||||
$1 = ($1_ltype) t;
|
||||
#if #__VA_ARGS__ == ""
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -74,12 +74,12 @@ namespace Swig {
|
||||
public:
|
||||
/* wrap a ocaml object. */
|
||||
Director(CAML_VALUE self) : swig_self(self), swig_disown_flag(false) {
|
||||
register_global_root(&swig_self);
|
||||
caml_register_global_root(&swig_self);
|
||||
}
|
||||
|
||||
/* discard our reference at destruction */
|
||||
virtual ~Director() {
|
||||
remove_global_root(&swig_self);
|
||||
caml_remove_global_root(&swig_self);
|
||||
swig_disown();
|
||||
// Disown is safe here because we're just divorcing a reference that points to us.
|
||||
}
|
||||
@@ -93,7 +93,7 @@ namespace Swig {
|
||||
void swig_disown() const {
|
||||
if (!swig_disown_flag) {
|
||||
swig_disown_flag=true;
|
||||
callback(*caml_named_value("caml_obj_disown"),swig_self);
|
||||
caml_callback(*caml_named_value("caml_obj_disown"),swig_self);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
* SWIG Configuration File for Ocaml
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%runtime %{
|
||||
#define SWIGSTATIC static
|
||||
%}
|
||||
|
||||
/* Insert common stuff */
|
||||
%insert(runtime) "swigrun.swg"
|
||||
|
||||
|
||||
@@ -31,12 +31,12 @@ extern "C" {
|
||||
|
||||
/* Cast a pointer if possible; returns 1 if successful */
|
||||
|
||||
SWIGSTATIC int
|
||||
SWIGINTERN 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...
|
||||
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;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ extern "C" {
|
||||
SWIG_TypeCheckStruct(source_type, dest_type );
|
||||
#ifdef TYPE_CAST_VERBOSE
|
||||
fprintf( stderr, "Typecheck -> %s\n",
|
||||
tc ? tc->str : "<none>" );
|
||||
tc ? tc->type->str : "<none>" );
|
||||
#endif
|
||||
if( tc ) {
|
||||
int newmemory = 0;
|
||||
@@ -79,7 +79,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
/* Return 0 if successful. */
|
||||
SWIGSTATIC int
|
||||
SWIGINTERN int
|
||||
SWIG_GetPtr(void *inptr, void **outptr,
|
||||
swig_type_info *intype, swig_type_info *outtype) {
|
||||
if (intype) {
|
||||
@@ -91,9 +91,9 @@ extern "C" {
|
||||
}
|
||||
}
|
||||
|
||||
SWIGSTATIC void caml_print_list( CAML_VALUE v );
|
||||
SWIGINTERN void caml_print_list( CAML_VALUE v );
|
||||
|
||||
SWIGSTATIC void caml_print_val( CAML_VALUE v ) {
|
||||
SWIGINTERN 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 " );
|
||||
@@ -157,7 +157,7 @@ extern "C" {
|
||||
}
|
||||
}
|
||||
|
||||
SWIGSTATIC void caml_print_list( CAML_VALUE v ) {
|
||||
SWIGINTERN void caml_print_list( CAML_VALUE v ) {
|
||||
CAMLparam1(v);
|
||||
while( v && Is_block(v) ) {
|
||||
fprintf( stderr, "[ " );
|
||||
@@ -168,7 +168,7 @@ extern "C" {
|
||||
CAMLreturn0;
|
||||
}
|
||||
|
||||
SWIGSTATIC CAML_VALUE caml_list_nth( CAML_VALUE lst, int n ) {
|
||||
SWIGINTERN CAML_VALUE caml_list_nth( CAML_VALUE lst, int n ) {
|
||||
CAMLparam1(lst);
|
||||
int i = 0;
|
||||
while( i < n && lst && Is_block(lst) ) {
|
||||
@@ -178,7 +178,7 @@ extern "C" {
|
||||
else CAMLreturn(SWIG_Field(lst,0));
|
||||
}
|
||||
|
||||
SWIGSTATIC CAML_VALUE caml_list_append( CAML_VALUE lst, CAML_VALUE elt ) {
|
||||
SWIGINTERN CAML_VALUE caml_list_append( CAML_VALUE lst, CAML_VALUE elt ) {
|
||||
CAMLparam2(lst,elt);
|
||||
SWIG_CAMLlocal3(v,vt,lh);
|
||||
lh = Val_unit;
|
||||
@@ -189,22 +189,22 @@ extern "C" {
|
||||
|
||||
while( lst && Is_block(lst) ) {
|
||||
if( v && v != Val_unit ) {
|
||||
vt = alloc_tuple(2);
|
||||
vt = caml_alloc_tuple(2);
|
||||
SWIG_Store_field(v,1,vt);
|
||||
v = vt;
|
||||
} else {
|
||||
v = lh = alloc_tuple(2);
|
||||
v = lh = caml_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);
|
||||
vt = caml_alloc_tuple(2);
|
||||
SWIG_Store_field(v,1,vt);
|
||||
v = vt;
|
||||
} else {
|
||||
v = lh = alloc_tuple(2);
|
||||
v = lh = caml_alloc_tuple(2);
|
||||
}
|
||||
SWIG_Store_field(v,0,elt);
|
||||
SWIG_Store_field(v,1,Val_unit);
|
||||
@@ -212,52 +212,52 @@ extern "C" {
|
||||
CAMLreturn(lh);
|
||||
}
|
||||
|
||||
SWIGSTATIC int caml_list_length( CAML_VALUE lst ) {
|
||||
SWIGINTERN 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 ) {
|
||||
SWIGINTERN 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 ) {
|
||||
SWIGINTERN 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");
|
||||
caml_failwith("Need array or list");
|
||||
}
|
||||
|
||||
SWIGSTATIC int caml_array_len( CAML_VALUE arr ) {
|
||||
SWIGINTERN 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");
|
||||
caml_failwith("Need array or list");
|
||||
}
|
||||
|
||||
SWIGSTATIC CAML_VALUE caml_swig_alloc(int x,int y) {
|
||||
SWIGINTERN CAML_VALUE caml_swig_alloc(int x,int y) {
|
||||
return caml_alloc(x,y);
|
||||
}
|
||||
|
||||
SWIGSTATIC value caml_array_new( int n ) {
|
||||
SWIGINTERN 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));
|
||||
SWIG_Store_field(vv,0,caml_alloc_tuple(n));
|
||||
CAMLreturn(vv);
|
||||
}
|
||||
|
||||
SWIGSTATIC CAML_VALUE caml_val_bool( int b ) {
|
||||
SWIGINTERN CAML_VALUE caml_val_bool( int b ) {
|
||||
CAMLparam0();
|
||||
SWIG_CAMLlocal1(bv);
|
||||
bv = caml_swig_alloc(1,C_bool);
|
||||
@@ -265,7 +265,7 @@ extern "C" {
|
||||
CAMLreturn(bv);
|
||||
}
|
||||
|
||||
SWIGSTATIC CAML_VALUE caml_val_char( char c ) {
|
||||
SWIGINTERN CAML_VALUE caml_val_char( char c ) {
|
||||
CAMLparam0();
|
||||
SWIG_CAMLlocal1(cv);
|
||||
cv = caml_swig_alloc(1,C_char);
|
||||
@@ -273,7 +273,7 @@ extern "C" {
|
||||
CAMLreturn(cv);
|
||||
}
|
||||
|
||||
SWIGSTATIC CAML_VALUE caml_val_uchar( unsigned char uc ) {
|
||||
SWIGINTERN CAML_VALUE caml_val_uchar( unsigned char uc ) {
|
||||
CAMLparam0();
|
||||
SWIG_CAMLlocal1(ucv);
|
||||
ucv = caml_swig_alloc(1,C_uchar);
|
||||
@@ -281,7 +281,7 @@ extern "C" {
|
||||
CAMLreturn(ucv);
|
||||
}
|
||||
|
||||
SWIGSTATIC CAML_VALUE caml_val_short( short s ) {
|
||||
SWIGINTERN CAML_VALUE caml_val_short( short s ) {
|
||||
CAMLparam0();
|
||||
SWIG_CAMLlocal1(sv);
|
||||
sv = caml_swig_alloc(1,C_short);
|
||||
@@ -289,7 +289,7 @@ extern "C" {
|
||||
CAMLreturn(sv);
|
||||
}
|
||||
|
||||
SWIGSTATIC CAML_VALUE caml_val_ushort( unsigned short us ) {
|
||||
SWIGINTERN CAML_VALUE caml_val_ushort( unsigned short us ) {
|
||||
CAMLparam0();
|
||||
SWIG_CAMLlocal1(usv);
|
||||
usv = caml_swig_alloc(1,C_ushort);
|
||||
@@ -297,7 +297,7 @@ extern "C" {
|
||||
CAMLreturn(usv);
|
||||
}
|
||||
|
||||
SWIGSTATIC CAML_VALUE caml_val_int( int i ) {
|
||||
SWIGINTERN CAML_VALUE caml_val_int( int i ) {
|
||||
CAMLparam0();
|
||||
SWIG_CAMLlocal1(iv);
|
||||
iv = caml_swig_alloc(1,C_int);
|
||||
@@ -305,7 +305,7 @@ extern "C" {
|
||||
CAMLreturn(iv);
|
||||
}
|
||||
|
||||
SWIGSTATIC CAML_VALUE caml_val_uint( unsigned int ui ) {
|
||||
SWIGINTERN CAML_VALUE caml_val_uint( unsigned int ui ) {
|
||||
CAMLparam0();
|
||||
SWIG_CAMLlocal1(uiv);
|
||||
uiv = caml_swig_alloc(1,C_int);
|
||||
@@ -313,75 +313,75 @@ extern "C" {
|
||||
CAMLreturn(uiv);
|
||||
}
|
||||
|
||||
SWIGSTATIC CAML_VALUE caml_val_long( long l ) {
|
||||
SWIGINTERN 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));
|
||||
SWIG_Store_field(lv,0,caml_copy_int64(l));
|
||||
CAMLreturn(lv);
|
||||
}
|
||||
|
||||
SWIGSTATIC CAML_VALUE caml_val_ulong( unsigned long ul ) {
|
||||
SWIGINTERN 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));
|
||||
SWIG_Store_field(ulv,0,caml_copy_int64(ul));
|
||||
CAMLreturn(ulv);
|
||||
}
|
||||
|
||||
SWIGSTATIC CAML_VALUE caml_val_float( float f ) {
|
||||
SWIGINTERN 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));
|
||||
SWIG_Store_field(fv,0,caml_copy_double((double)f));
|
||||
CAMLreturn(fv);
|
||||
}
|
||||
|
||||
SWIGSTATIC CAML_VALUE caml_val_double( double d ) {
|
||||
SWIGINTERN 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));
|
||||
SWIG_Store_field(fv,0,caml_copy_double(d));
|
||||
CAMLreturn(fv);
|
||||
}
|
||||
|
||||
SWIGSTATIC CAML_VALUE caml_val_ptr( void *p, swig_type_info *info ) {
|
||||
SWIGINTERN 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));
|
||||
SWIG_Store_field(vv,0,caml_copy_int64((long)p));
|
||||
SWIG_Store_field(vv,1,caml_copy_int64((long)info));
|
||||
CAMLreturn(vv);
|
||||
}
|
||||
|
||||
SWIGSTATIC CAML_VALUE caml_val_string( const char *p ) {
|
||||
SWIGINTERN 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));
|
||||
SWIG_Store_field(vv,0,caml_copy_string(p));
|
||||
CAMLreturn(vv);
|
||||
}
|
||||
|
||||
SWIGSTATIC CAML_VALUE caml_val_string_len( const char *p, int len ) {
|
||||
SWIGINTERN 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));
|
||||
SWIG_Store_field(vv,0,caml_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) {
|
||||
SWIGINTERN CAML_VALUE caml_val_obj_helper( void *v, swig_type_info *type, char *name) {
|
||||
CAMLparam0();
|
||||
CAMLreturn(callback2(*caml_named_value("caml_create_object_fn"),
|
||||
CAMLreturn(caml_callback2(*caml_named_value("caml_create_object_fn"),
|
||||
caml_val_ptr(v,type),
|
||||
copy_string(name)));
|
||||
caml_copy_string(name)));
|
||||
}
|
||||
|
||||
SWIGSTATIC long caml_long_val_full( CAML_VALUE v, char *name ) {
|
||||
SWIGINTERN long caml_long_val_full( CAML_VALUE v, const char *name ) {
|
||||
CAMLparam1(v);
|
||||
if( !Is_block(v) ) return 0;
|
||||
|
||||
@@ -408,20 +408,20 @@ extern "C" {
|
||||
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);
|
||||
if( !name ) caml_failwith( "Not an enum conversion" );
|
||||
ret = caml_callback2(*enum_to_int,*caml_named_value(name),v);
|
||||
CAMLreturn(caml_long_val(ret));
|
||||
}
|
||||
default:
|
||||
failwith("No conversion to int");
|
||||
caml_failwith("No conversion to int");
|
||||
}
|
||||
}
|
||||
|
||||
SWIGSTATIC long caml_long_val( CAML_VALUE v ) {
|
||||
SWIGINTERN long caml_long_val( CAML_VALUE v ) {
|
||||
return caml_long_val_full(v,0);
|
||||
}
|
||||
|
||||
SWIGSTATIC double caml_double_val( CAML_VALUE v ) {
|
||||
SWIGINTERN double caml_double_val( CAML_VALUE v ) {
|
||||
CAMLparam1(v);
|
||||
if( !Is_block(v) ) return 0.0;
|
||||
switch( SWIG_Tag_val(v) ) {
|
||||
@@ -442,36 +442,28 @@ extern "C" {
|
||||
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");
|
||||
caml_failwith("No conversion to double");
|
||||
}
|
||||
}
|
||||
|
||||
SWIGSTATIC int caml_ptr_val_internal( CAML_VALUE v, void **out,
|
||||
SWIGINTERN int caml_ptr_val_internal( CAML_VALUE v, void **out,
|
||||
swig_type_info *descriptor ) {
|
||||
CAMLparam1(v);
|
||||
void *outptr = NULL;
|
||||
swig_type_info *outdescr = NULL;
|
||||
static CAML_VALUE *func_val = NULL;
|
||||
|
||||
if( v == Val_unit ) {
|
||||
*out = 0;
|
||||
CAMLreturn(0);
|
||||
CAMLreturn_type(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));
|
||||
if (!func_val) {
|
||||
func_val = caml_named_value("caml_obj_ptr");
|
||||
}
|
||||
CAMLreturn_type(caml_ptr_val_internal(caml_callback(*func_val, v), out, descriptor));
|
||||
case C_string:
|
||||
outptr = (void *)String_val(SWIG_Field(v,0));
|
||||
break;
|
||||
@@ -481,14 +473,14 @@ extern "C" {
|
||||
break;
|
||||
default:
|
||||
*out = 0;
|
||||
CAMLreturn(1);
|
||||
CAMLreturn_type(1);
|
||||
break;
|
||||
}
|
||||
|
||||
CAMLreturn(SWIG_GetPtr(outptr,out,outdescr,descriptor));
|
||||
|
||||
CAMLreturn_type(SWIG_GetPtr(outptr, out, outdescr, descriptor));
|
||||
}
|
||||
|
||||
SWIGSTATIC void *caml_ptr_val( CAML_VALUE v, swig_type_info *descriptor ) {
|
||||
SWIGINTERN void *caml_ptr_val( CAML_VALUE v, swig_type_info *descriptor ) {
|
||||
CAMLparam0();
|
||||
#ifdef TYPE_CAST_VERBOSE
|
||||
caml_print_val( v );
|
||||
@@ -497,23 +489,23 @@ extern "C" {
|
||||
if( !caml_ptr_val_internal( v, &out, descriptor ) )
|
||||
CAMLreturn_type(out);
|
||||
else
|
||||
failwith( "No appropriate conversion found." );
|
||||
caml_failwith( "No appropriate conversion found." );
|
||||
}
|
||||
|
||||
SWIGSTATIC char *caml_string_val( CAML_VALUE v ) {
|
||||
SWIGINTERN char *caml_string_val( CAML_VALUE v ) {
|
||||
return (char *)caml_ptr_val( v, 0 );
|
||||
}
|
||||
|
||||
SWIGSTATIC int caml_string_len( CAML_VALUE v ) {
|
||||
SWIGINTERN int caml_string_len( CAML_VALUE v ) {
|
||||
switch( SWIG_Tag_val(v) ) {
|
||||
case C_string:
|
||||
return string_length(SWIG_Field(v,0));
|
||||
return caml_string_length(SWIG_Field(v,0));
|
||||
default:
|
||||
return strlen((char *)caml_ptr_val(v,0));
|
||||
}
|
||||
}
|
||||
|
||||
SWIGSTATIC int caml_bool_check( CAML_VALUE v ) {
|
||||
SWIGINTERN int caml_bool_check( CAML_VALUE v ) {
|
||||
CAMLparam1(v);
|
||||
|
||||
if( !Is_block(v) ) return 0;
|
||||
@@ -528,7 +520,7 @@ extern "C" {
|
||||
}
|
||||
}
|
||||
|
||||
SWIGSTATIC int caml_int_check( CAML_VALUE v ) {
|
||||
SWIGINTERN int caml_int_check( CAML_VALUE v ) {
|
||||
CAMLparam1(v);
|
||||
|
||||
if( !Is_block(v) ) return 0;
|
||||
@@ -549,7 +541,7 @@ extern "C" {
|
||||
}
|
||||
}
|
||||
|
||||
SWIGSTATIC int caml_float_check( CAML_VALUE v ) {
|
||||
SWIGINTERN int caml_float_check( CAML_VALUE v ) {
|
||||
CAMLparam1(v);
|
||||
if( !Is_block(v) ) return 0;
|
||||
|
||||
@@ -563,7 +555,7 @@ extern "C" {
|
||||
}
|
||||
}
|
||||
|
||||
SWIGSTATIC int caml_ptr_check( CAML_VALUE v ) {
|
||||
SWIGINTERN int caml_ptr_check( CAML_VALUE v ) {
|
||||
CAMLparam1(v);
|
||||
if( !Is_block(v) ) return 0;
|
||||
|
||||
@@ -578,10 +570,23 @@ extern "C" {
|
||||
}
|
||||
}
|
||||
|
||||
SWIGINTERN CAML_VALUE SWIG_Ocaml_ptr_to_val(const char *name, void *ptr, swig_type_info *descriptor) {
|
||||
CAMLparam0();
|
||||
SWIG_CAMLlocal1(result);
|
||||
|
||||
CAML_VALUE *fromval = caml_named_value(name);
|
||||
if (fromval) {
|
||||
result = caml_callback(*fromval, caml_val_ptr(ptr, descriptor));
|
||||
} else {
|
||||
result = caml_val_ptr(ptr, descriptor);
|
||||
}
|
||||
CAMLreturn(result);
|
||||
}
|
||||
|
||||
static swig_module_info *SWIG_Ocaml_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
|
||||
CAML_VALUE pointer;
|
||||
|
||||
pointer = callback(*caml_named_value("swig_find_type_info"), caml_val_int(0));
|
||||
pointer = caml_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));
|
||||
}
|
||||
@@ -592,7 +597,7 @@ extern "C" {
|
||||
CAML_VALUE mod_pointer;
|
||||
|
||||
mod_pointer = caml_val_ptr(pointer, NULL);
|
||||
callback(*caml_named_value("swig_set_type_info"), mod_pointer);
|
||||
caml_callback(*caml_named_value("swig_set_type_info"), mod_pointer);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -16,6 +16,7 @@ SWIGEXT {
|
||||
#endif
|
||||
#define value caml_value_t
|
||||
#define CAML_VALUE caml_value_t
|
||||
#define CAML_NAME_SPACE
|
||||
#include <caml/alloc.h>
|
||||
#include <caml/custom.h>
|
||||
#include <caml/mlvalues.h>
|
||||
@@ -24,9 +25,16 @@ SWIGEXT {
|
||||
#include <caml/fail.h>
|
||||
#include <caml/misc.h>
|
||||
|
||||
#if defined(CAMLassert)
|
||||
/* Both this macro and version.h were introduced in version 4.02.0 */
|
||||
#include <caml/version.h>
|
||||
#else
|
||||
#define OCAML_VERSION 0 /* Unknown, but < 40200 */
|
||||
#endif
|
||||
|
||||
#define caml_array_set swig_caml_array_set
|
||||
|
||||
// Adapted from memory.h and mlvalues.h
|
||||
/* Adapted from memory.h and mlvalues.h */
|
||||
|
||||
#define SWIG_CAMLlocal1(x) \
|
||||
caml_value_t x = 0; \
|
||||
@@ -56,7 +64,7 @@ SWIGEXT {
|
||||
#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); \
|
||||
caml_modify (&SWIG_Field ((block), caml__temp_offset), caml__temp_val); \
|
||||
}while(0)
|
||||
|
||||
#define SWIG_Data_custom_val(v) ((void *) &SWIG_Field((v), 1))
|
||||
@@ -101,9 +109,17 @@ SWIGEXT {
|
||||
|
||||
|
||||
#ifndef ARCH_ALIGN_INT64
|
||||
#if OCAML_VERSION >= 40300
|
||||
#define SWIG_Int64_val(v) (*((int64_t *) SWIG_Data_custom_val(v)))
|
||||
#else
|
||||
#define SWIG_Int64_val(v) (*((int64 *) SWIG_Data_custom_val(v)))
|
||||
#endif
|
||||
#else
|
||||
#if OCAML_VERSION >= 40300
|
||||
CAMLextern int64_t Int64_val(caml_value_t v);
|
||||
#else
|
||||
CAMLextern int64 Int64_val(caml_value_t v);
|
||||
#endif
|
||||
#define SWIG_Int64_val(v) Int64_val(v)
|
||||
#endif
|
||||
|
||||
@@ -111,56 +127,85 @@ CAMLextern int64 Int64_val(caml_value_t v);
|
||||
#define SWIG_GetModule(clientdata) SWIG_Ocaml_GetModule(clientdata)
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Ocaml_SetModule(pointer)
|
||||
|
||||
#define SWIG_contract_assert(expr, msg) if(!(expr)) {failwith(msg);} else
|
||||
typedef enum {
|
||||
SWIG_OCamlArithmeticException,
|
||||
SWIG_OCamlDirectorPureVirtual,
|
||||
SWIG_OCamlOutOfMemoryError,
|
||||
SWIG_OCamlOverflowException,
|
||||
SWIG_OCamlIllegalArgumentException,
|
||||
SWIG_OCamlIndexOutOfBoundsException,
|
||||
SWIG_OCamlRuntimeException,
|
||||
SWIG_OCamlSystemException,
|
||||
SWIG_OCamlUnknownError
|
||||
} SWIG_OCamlExceptionCodes;
|
||||
|
||||
SWIGSTATIC int
|
||||
SWIGINTERN void SWIG_OCamlThrowException(SWIG_OCamlExceptionCodes code, const char *msg) {
|
||||
CAMLparam0();
|
||||
SWIG_CAMLlocal1(str);
|
||||
|
||||
switch (code) {
|
||||
case SWIG_OCamlIllegalArgumentException:
|
||||
caml_invalid_argument(msg);
|
||||
break;
|
||||
case SWIG_OCamlSystemException:
|
||||
str = caml_copy_string(msg);
|
||||
caml_raise_sys_error(str);
|
||||
break;
|
||||
case SWIG_OCamlArithmeticException:
|
||||
case SWIG_OCamlIndexOutOfBoundsException:
|
||||
case SWIG_OCamlOutOfMemoryError:
|
||||
case SWIG_OCamlOverflowException:
|
||||
case SWIG_OCamlRuntimeException:
|
||||
case SWIG_OCamlUnknownError:
|
||||
default:
|
||||
caml_failwith(msg);
|
||||
break;
|
||||
}
|
||||
CAMLreturn0;
|
||||
}
|
||||
|
||||
#define SWIG_contract_assert(expr, msg) if(!(expr)) {SWIG_OCamlThrowException(SWIG_OCamlRuntimeException, msg);}
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_GetPtr(void *source, void **result, swig_type_info *type, swig_type_info *result_type);
|
||||
|
||||
SWIGINTERN CAML_VALUE caml_list_nth( CAML_VALUE lst, int n );
|
||||
SWIGINTERN CAML_VALUE caml_list_append( CAML_VALUE lst, CAML_VALUE elt );
|
||||
SWIGINTERN int caml_list_length( CAML_VALUE lst );
|
||||
SWIGINTERN CAML_VALUE caml_array_new( int n );
|
||||
SWIGINTERN void caml_array_set( CAML_VALUE arr, int n, CAML_VALUE item );
|
||||
SWIGINTERN CAML_VALUE caml_array_nth( CAML_VALUE arr, int n );
|
||||
SWIGINTERN int caml_array_len( CAML_VALUE arr );
|
||||
|
||||
SWIGINTERN CAML_VALUE caml_val_char( char c );
|
||||
SWIGINTERN CAML_VALUE caml_val_uchar( unsigned char c );
|
||||
|
||||
SWIGINTERN CAML_VALUE caml_val_short( short s );
|
||||
SWIGINTERN CAML_VALUE caml_val_ushort( unsigned short s );
|
||||
|
||||
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 );
|
||||
SWIGINTERN CAML_VALUE caml_val_int( int x );
|
||||
SWIGINTERN CAML_VALUE caml_val_uint( unsigned int x );
|
||||
|
||||
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_len( CAML_VALUE arr );
|
||||
SWIGINTERN CAML_VALUE caml_val_long( long x );
|
||||
SWIGINTERN CAML_VALUE caml_val_ulong( unsigned long x );
|
||||
|
||||
SWIGSTATIC CAML_VALUE caml_val_char( char c );
|
||||
SWIGSTATIC CAML_VALUE caml_val_uchar( unsigned char c );
|
||||
SWIGINTERN CAML_VALUE caml_val_float( float f );
|
||||
SWIGINTERN CAML_VALUE caml_val_double( double d );
|
||||
|
||||
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 );
|
||||
SWIGINTERN CAML_VALUE caml_val_ptr( void *p, swig_type_info *descriptor );
|
||||
|
||||
SWIGSTATIC CAML_VALUE caml_val_long( long x );
|
||||
SWIGSTATIC CAML_VALUE caml_val_ulong( unsigned long x );
|
||||
SWIGINTERN CAML_VALUE caml_val_string( const char *str );
|
||||
SWIGINTERN CAML_VALUE caml_val_string_len( const char *str, int len );
|
||||
|
||||
SWIGSTATIC CAML_VALUE caml_val_float( float f );
|
||||
SWIGSTATIC CAML_VALUE caml_val_double( double d );
|
||||
SWIGINTERN long caml_long_val( CAML_VALUE v );
|
||||
SWIGINTERN double caml_double_val( CAML_VALUE v );
|
||||
|
||||
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,
|
||||
SWIGINTERN 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 );
|
||||
SWIGINTERN 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 );
|
||||
SWIGINTERN char *caml_string_val( CAML_VALUE v );
|
||||
SWIGINTERN int caml_string_len( CAML_VALUE v );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -6,12 +6,13 @@
|
||||
|
||||
/*
|
||||
from
|
||||
http://caml.inria.fr/ocaml/htmlman/manual044.html
|
||||
https://caml.inria.fr/pub/docs/manual-ocaml/lex.html
|
||||
*/
|
||||
|
||||
|
||||
OCAMLKW(and);
|
||||
OCAMLKW(as);
|
||||
OCAMLKW(asr);
|
||||
OCAMLKW(assert);
|
||||
OCAMLKW(begin);
|
||||
OCAMLKW(class);
|
||||
@@ -33,13 +34,20 @@ OCAMLKW(in);
|
||||
OCAMLKW(include);
|
||||
OCAMLKW(inherit);
|
||||
OCAMLKW(initializer);
|
||||
OCAMLKW(land);
|
||||
OCAMLKW(lazy);
|
||||
OCAMLKW(let);
|
||||
OCAMLKW(lor);
|
||||
OCAMLKW(lsl);
|
||||
OCAMLKW(lsr);
|
||||
OCAMLKW(lxor);
|
||||
OCAMLKW(match);
|
||||
OCAMLKW(method);
|
||||
OCAMLKW(mod);
|
||||
OCAMLKW(module);
|
||||
OCAMLKW(mutable);
|
||||
OCAMLKW(new);
|
||||
OCAMLKW(nonrec);
|
||||
OCAMLKW(object);
|
||||
OCAMLKW(of);
|
||||
OCAMLKW(open);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
%include <std/std_except.i>
|
||||
|
||||
%apply size_t { std::size_t };
|
||||
%apply const size_t& { const std::size_t& };
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
|
||||
23
linx64/bin/swig/share/swig/4.0.0/ocaml/std_except.i
Normal file
23
linx64/bin/swig/share/swig/4.0.0/ocaml/std_except.i
Normal file
@@ -0,0 +1,23 @@
|
||||
%{
|
||||
#include <typeinfo>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
namespace std
|
||||
{
|
||||
%ignore exception;
|
||||
struct exception {};
|
||||
}
|
||||
|
||||
%typemap(throws) std::bad_cast "SWIG_OCamlThrowException(SWIG_OCamlRuntimeException, $1.what());"
|
||||
%typemap(throws) std::bad_exception "SWIG_OCamlThrowException(SWIG_OCamlRuntimeException, $1.what());"
|
||||
%typemap(throws) std::domain_error "SWIG_OCamlThrowException(SWIG_OCamlRuntimeException, $1.what());"
|
||||
%typemap(throws) std::exception "SWIG_OCamlThrowException(SWIG_OCamlRuntimeException, $1.what());"
|
||||
%typemap(throws) std::invalid_argument "SWIG_OCamlThrowException(SWIG_OCamlIllegalArgumentException, $1.what());"
|
||||
%typemap(throws) std::length_error "SWIG_OCamlThrowException(SWIG_OCamlIndexOutOfBoundsException, $1.what());"
|
||||
%typemap(throws) std::logic_error "SWIG_OCamlThrowException(SWIG_OCamlRuntimeException, $1.what());"
|
||||
%typemap(throws) std::out_of_range "SWIG_OCamlThrowException(SWIG_OCamlIndexOutOfBoundsException, $1.what());"
|
||||
%typemap(throws) std::overflow_error "SWIG_OCamlThrowException(SWIG_OCamlArithmeticException, $1.what());"
|
||||
%typemap(throws) std::range_error "SWIG_OCamlThrowException(SWIG_OCamlIndexOutOfBoundsException, $1.what());"
|
||||
%typemap(throws) std::runtime_error "SWIG_OCamlThrowException(SWIG_OCamlRuntimeException, $1.what());"
|
||||
%typemap(throws) std::underflow_error "SWIG_OCamlThrowException(SWIG_OCamlArithmeticException, $1.what());"
|
||||
@@ -13,21 +13,24 @@
|
||||
%}
|
||||
|
||||
|
||||
namespace std{
|
||||
namespace std {
|
||||
template<class T> class list
|
||||
{
|
||||
public:
|
||||
|
||||
typedef T &reference;
|
||||
typedef const T& const_reference;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef T &iterator;
|
||||
typedef const T& const_iterator;
|
||||
|
||||
|
||||
list();
|
||||
list(unsigned int size, const T& value = T());
|
||||
list(const list<T> &);
|
||||
list(const list& other);
|
||||
|
||||
~list();
|
||||
void assign(unsigned int n, const T& value);
|
||||
void swap(list<T> &x);
|
||||
|
||||
@@ -35,28 +38,25 @@ namespace std{
|
||||
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)
|
||||
@@ -206,9 +206,7 @@ namespace std{
|
||||
{
|
||||
self->pop_back();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,14 @@ namespace std {
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair< const K, T > value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
map();
|
||||
map(const map< K, T, C > &);
|
||||
map(const map& other);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
|
||||
@@ -18,12 +18,14 @@
|
||||
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);
|
||||
pair(const pair& other);
|
||||
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &p);
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &other);
|
||||
|
||||
T first;
|
||||
U second;
|
||||
|
||||
@@ -29,7 +29,6 @@ class wstring;
|
||||
|
||||
/* Overloading check */
|
||||
%typemap(in) string {
|
||||
/* %typemap(in) string */
|
||||
if (caml_ptr_check($input))
|
||||
$1.assign((char *)caml_ptr_val($input,0), caml_string_len($input));
|
||||
else
|
||||
@@ -37,7 +36,6 @@ class wstring;
|
||||
}
|
||||
|
||||
%typemap(in) const string & ($*1_ltype temp) {
|
||||
/* %typemap(in) const string & */
|
||||
if (caml_ptr_check($input)) {
|
||||
temp.assign((char *)caml_ptr_val($input,0), caml_string_len($input));
|
||||
$1 = &temp;
|
||||
@@ -47,7 +45,6 @@ class wstring;
|
||||
}
|
||||
|
||||
%typemap(in) string & ($*1_ltype temp) {
|
||||
/* %typemap(in) string & */
|
||||
if (caml_ptr_check($input)) {
|
||||
temp.assign((char *)caml_ptr_val($input,0), caml_string_len($input));
|
||||
$1 = &temp;
|
||||
@@ -57,7 +54,6 @@ class wstring;
|
||||
}
|
||||
|
||||
%typemap(in) string * ($*1_ltype *temp) {
|
||||
/* %typemap(in) string * */
|
||||
if (caml_ptr_check($input)) {
|
||||
temp = new $*1_ltype((char *)caml_ptr_val($input,0), caml_string_len($input));
|
||||
$1 = temp;
|
||||
@@ -71,24 +67,26 @@ class wstring;
|
||||
}
|
||||
|
||||
%typemap(argout) string & {
|
||||
/* %typemap(argout) string & */
|
||||
swig_result = caml_list_append(swig_result,caml_val_string_len((*$1).c_str(), (*$1).size()));
|
||||
}
|
||||
|
||||
%typemap(directorin) string {
|
||||
swig_result = caml_val_string_len($1.c_str(), $1.size());
|
||||
args = caml_list_append(args, swig_result);
|
||||
}
|
||||
|
||||
%typemap(directorout) string {
|
||||
/* %typemap(directorout) string */
|
||||
$result.assign((char *)caml_ptr_val($input,0), caml_string_len($input));
|
||||
}
|
||||
|
||||
%typemap(out) string {
|
||||
/* %typemap(out) string */
|
||||
$result = caml_val_string_len($1.c_str(),$1.size());
|
||||
}
|
||||
|
||||
%typemap(out) string * {
|
||||
/* %typemap(out) string * */
|
||||
$result = caml_val_string_len((*$1).c_str(),(*$1).size());
|
||||
}
|
||||
%typemap(typecheck) string, const string & = char *;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_CHARPTR_ARRAY
|
||||
@@ -114,7 +112,7 @@ char **c_charptr_array( const std::vector <std::string > &str_v );
|
||||
|
||||
let string_array_to_vector sa =
|
||||
let nv = _new_StringVector C_void in
|
||||
array_to_vector nv (fun x -> C_string x) sa ; nv
|
||||
ignore (array_to_vector nv (fun x -> C_string x) sa) ; nv
|
||||
|
||||
let c_string_array ar =
|
||||
_c_charptr_array (string_array_to_vector ar)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user