Merge remote-tracking branch 'origin/master' into HEAD

This commit is contained in:
Markus Friedrich 2022-01-16 09:57:22 +01:00
commit be0b975e6b
977 changed files with 15369 additions and 35050 deletions

View file

@ -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>
%}

View file

@ -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));

View file

@ -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)))
%}

View file

@ -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 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& other);
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();
}
}
};
}

View file

@ -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

View file

@ -1,4 +0,0 @@
/* Unused for Allegro CL module */
%include "inout_typemaps.i"
%include "longlongs.i"

View file

@ -21,7 +21,7 @@ typedef struct SWIGCDATA {
}
%typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH);
#elif SWIGPHP7
#elif SWIGPHP
%typemap(out) SWIGCDATA {
ZVAL_STRINGL($result, $1.data, $1.len);

View file

@ -1,809 +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) "swigerrors.swg" // SWIG errors
%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 [] {
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, SWIG_POINTER_NO_NULL)) {
$1 = 0;
} else {
$1 = 1;
}
}
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE &&
{
void *ptr = 0;
if (SWIG_ConvertPtr($input, &ptr, $descriptor, SWIG_POINTER_NO_NULL)) {
$1 = 0;
} else {
$1 = 1;
}
}
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE
{
void *ptr = 0;
if (SWIG_ConvertPtr($input, &ptr, $&descriptor, SWIG_POINTER_NO_NULL)) {
$1 = 0;
} else {
$1 = 1;
}
}
/* ------------------------------------------------------------
* Exception handling
* ------------------------------------------------------------ */
/* ------------------------------------------------------------
* --- Exception handling ---
* ------------------------------------------------------------ */
%typemap(throws) SWIGTYPE {
$&ltype 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);
%}

View file

@ -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_

View file

@ -1,375 +0,0 @@
/* -----------------------------------------------------------------------------
* chickenrun.swg
* ----------------------------------------------------------------------------- */
#include <chicken.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#if (defined(_MSC_VER) && (_MSC_VER < 1900)) || 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;
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
} 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

View file

@ -1,3 +0,0 @@
swigclosprefix.scm
multi-generic.scm
tinyclos-multi-generic.patch

View file

@ -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)

View file

@ -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());
}
}

View file

@ -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)))))

View file

@ -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>))

View file

@ -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;

View file

@ -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";

View file

@ -875,6 +875,15 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
global::System.IntPtr ret = $imcall;$excode
return ret;
}
%typemap(csvarin, excode=SWIGEXCODE2) void *VOID_INT_PTR %{
set {
$imcall;$excode
} %}
%typemap(csvarout, excode=SWIGEXCODE2) void *VOID_INT_PTR %{
get {
global::System.IntPtr ret = $imcall;$excode
return ret;
} %}
%typemap(csdirectorin) void *VOID_INT_PTR "$iminput"
%typemap(csdirectorout) void *VOID_INT_PTR "$cscall"
@ -885,6 +894,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%typemap(csinterfaces) SWIGTYPE "global::System.IDisposable"
%typemap(csinterfaces) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(csinterfaces_derived) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(csinterfacemodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "public interface"
// csbody typemaps... these are in macros so that the visibility of the methods can be easily changed by users.

View file

@ -1,5 +1,5 @@
/*
The typemaps here allow to handle functions returning std::auto_ptr<>,
The typemaps here allow handling functions returning std::auto_ptr<>,
which is the most common use of this type. If you have functions taking it
as parameter, these typemaps can't be used for them and you need to do
something else (e.g. use shared_ptr<> which SWIG supports fully).

View file

@ -92,7 +92,7 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterWStringCallback_$module(SWIG_CSharpWStri
} %}
%typemap(csvarout, excode=SWIGEXCODE2) wchar_t * %{
get {
string ret = $imcall;$excode
string ret = global::System.Runtime.InteropServices.Marshal.PtrToStringUni($imcall);$excode
return ret;
} %}

View file

@ -58,7 +58,7 @@ template SwigOperatorDefinitions() {
%rename(opCall) *::operator();
// !a is not overrideable in D1.
// !a is not overridable in D1.
%ignoreoperator(LNOT) operator!;
// opCmp is used in D.
@ -71,7 +71,7 @@ template SwigOperatorDefinitions() {
// a != b is rewritten as !a.opEquals(b) in D.
%ignoreoperator(NOTEQUAL) operator!=;
// The logic operators are not overrideable in D.
// The logic operators are not overridable in D.
%ignoreoperator(LAND) operator&&;
%ignoreoperator(LOR) operator||;
@ -198,7 +198,7 @@ mixin template SwigOperatorDefinitions() {
// a != b is rewritten as !a.opEquals(b) in D.
%ignoreoperator(NOTEQUAL) operator!=;
// The logic operators are not overrideable in D.
// The logic operators are not overridable in D.
%ignoreoperator(LAND) operator&&;
%ignoreoperator(LOR) operator||;

View file

@ -40,9 +40,10 @@ private {
} else {
version(D_Version2) {
static import std.conv;
} else {
static import std.c.string;
}
static import std.string;
static import std.c.string;
}
version(D_Version2) {
@ -112,7 +113,7 @@ private {
version(Tango) {
import tango.sys.Common;
} else version(linux) {
import std.c.linux.linux;
import core.sys.posix.dlfcn;
} else {
extern(C) {
const RTLD_NOW = 2;

View file

@ -12,10 +12,20 @@
%insert("runtime") "swigerrors.swg"
#ifdef SWIGPHP7
#ifdef SWIGPHP
%{
#include "zend_exceptions.h"
#define SWIG_exception(code, msg) do { zend_throw_exception(NULL, (char*)msg, code); goto thrown; } while (0)
#if PHP_MAJOR_VERSION >= 8
# define SWIG_HANDLE_VALUE_ERROR_FOR_PHP8(code) code == SWIG_ValueError ? zend_ce_value_error :
#else
# define SWIG_HANDLE_VALUE_ERROR_FOR_PHP8(code)
#endif
#define SWIG_exception(code, msg) do { zend_throw_exception( \
code == SWIG_TypeError ? zend_ce_type_error : \
SWIG_HANDLE_VALUE_ERROR_FOR_PHP8(code) \
code == SWIG_DivisionByZero ? zend_ce_division_by_zero_error : \
code == SWIG_SyntaxError ? zend_ce_parse_error : \
code == SWIG_OverflowError ? zend_ce_arithmetic_error : \
NULL, msg, code); SWIG_fail; } while (0)
%}
#endif

View file

@ -23,46 +23,38 @@ static void* Swig_malloc(int c) {
%}
#if SWIGGO_CGO
%insert(cgo_comment_typedefs) %{
#include <stdint.h>
%}
#endif
#if SWIGGO_INTGO_SIZE == 32
%insert(runtime) %{
typedef int intgo;
typedef unsigned int uintgo;
%}
#if SWIGGO_CGO
%insert(cgo_comment_typedefs) %{
typedef int intgo;
typedef unsigned int uintgo;
%}
#endif
#elif SWIGGO_INTGO_SIZE == 64
%insert(runtime) %{
typedef long long intgo;
typedef unsigned long long uintgo;
%}
#if SWIGGO_CGO
%insert(cgo_comment_typedefs) %{
typedef long long intgo;
typedef unsigned long long uintgo;
%}
#endif
#else
%insert(runtime) %{
typedef ptrdiff_t intgo;
typedef size_t uintgo;
%}
#if SWIGGO_CGO
%insert(cgo_comment_typedefs) %{
typedef ptrdiff_t intgo;
typedef size_t uintgo;
%}
#endif
#endif
#ifndef SWIGGO_GCCGO
// Set the host compiler struct attribute that will be
@ -89,8 +81,6 @@ typedef struct { void* array; intgo len; intgo cap; } _goslice_;
%}
#ifdef SWIGGO_CGO
%insert(cgo_comment_typedefs) %{
typedef struct { char *p; intgo n; } _gostring_;
@ -98,91 +88,7 @@ typedef struct { void* array; intgo len; intgo cap; } _goslice_;
%}
#endif
#ifndef SWIGGO_GCCGO
/* Boilerplate for C/C++ code when using 6g/8g. This code is compiled
with gcc. */
%insert(runtime) %{
#define swiggo_size_assert_eq(x, y, name) typedef char name[(x-y)*(x-y)*-2+1];
#define swiggo_size_assert(t, n) swiggo_size_assert_eq(sizeof(t), n, swiggo_sizeof_##t##_is_not_##n)
swiggo_size_assert(char, 1)
swiggo_size_assert(short, 2)
swiggo_size_assert(int, 4)
typedef long long swiggo_long_long;
swiggo_size_assert(swiggo_long_long, 8)
swiggo_size_assert(float, 4)
swiggo_size_assert(double, 8)
#ifdef __cplusplus
extern "C" {
#endif
extern void crosscall2(void (*fn)(void *, int), void *, int);
extern char* _cgo_topofstack(void) __attribute__ ((weak));
extern void _cgo_allocate(void *, int);
extern void _cgo_panic(void *, int);
#ifdef __cplusplus
}
#endif
static char *_swig_topofstack() {
if (_cgo_topofstack) {
return _cgo_topofstack();
} else {
return 0;
}
}
static void _swig_gopanic(const char *p) {
struct {
const char *p;
} SWIGSTRUCTPACKED a;
a.p = p;
crosscall2(_cgo_panic, &a, (int) sizeof a);
}
%}
#if !SWIGGO_CGO
/* This is here for backward compatibility, but it will not work
with Go 1.5 or later. Do not use it in new code. */
%insert(runtime) %{
static void *_swig_goallocate(size_t len) {
struct {
size_t len;
void *ret;
} SWIGSTRUCTPACKED a;
a.len = len;
crosscall2(_cgo_allocate, &a, (int) sizeof a);
return a.ret;
}
%}
#endif
#if !SWIGGO_CGO
/* Boilerplate for C code when using 6g/8g. This code is compiled
with 6c/8c. */
%insert(gc_header) %{
#include "runtime.h"
#include "cgocall.h"
#pragma dataflag 16
static void *cgocall = runtime·cgocall;
#pragma dataflag 16
void *·_cgo_runtime_cgocall = &cgocall;
%}
#endif
#else
#ifdef SWIGGO_GCCGO
/* Boilerplate for C/C++ code when using gccgo. */
%insert(runtime) %{
@ -201,115 +107,12 @@ extern void _cgo_panic(const char *);
#define _swig_gopanic _cgo_panic
%}
#if !SWIGGO_CGO
%insert(runtime) %{
/* Implementations of SwigCgocall and friends for different versions
of gccgo. The Go code will call these functions using C names with
a prefix of the module name. The implementations here call the
routine in libgo. The routines to call vary depending on the gccgo
version. We assume that the version of gcc used to compile this
file is the same as the version of gccgo. */
#ifdef __cplusplus
extern "C" {
#endif
#define SWIG_GCC_VERSION \
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#if SWIG_GCC_VERSION < 40700
#define SwigDoCgocall()
#define SwigDoCgocallDone()
#define SwigDoCgocallBack()
#define SwigDoCgocallBackDone()
#elif SWIG_GCC_VERSION == 40700
void SwigDoCgocall(void) __asm__("libgo_syscall.syscall.Entersyscall");
void SwigDoCgocallDone(void) __asm__("libgo_syscall.syscall.Exitsyscall");
void SwigDoCgocallBack(void) __asm__("libgo_syscall.syscall.Exitsyscall");
void SwigDoCgocallBackDone(void) __asm__("libgo_syscall.syscall.Entersyscall");
#else
void SwigDoCgocall(void) __asm__("syscall.Cgocall");
void SwigDoCgocallDone(void) __asm__("syscall.CgocallDone");
void SwigDoCgocallBack(void) __asm__("syscall.CgocallBack");
void SwigDoCgocallBackDone(void) __asm__("syscall.CgocallBackDone");
#endif
#define SWIGSTRINGIFY2(s) #s
#define SWIGSTRINGIFY(s) SWIGSTRINGIFY2(s)
void SwigCgocall()
__asm__(SWIGSTRINGIFY(SWIGGO_PREFIX) ".SwigCgocall");
void SwigCgocall() {
SwigDoCgocall();
}
void SwigCgocallDone()
__asm__(SWIGSTRINGIFY(SWIGGO_PREFIX) ".SwigCgocallDone");
void SwigCgocallDone() {
SwigDoCgocallDone();
}
void SwigCgocallBack()
__asm__(SWIGSTRINGIFY(SWIGGO_PREFIX) ".SwigCgocallBack");
void SwigCgocallBack() {
SwigDoCgocallBack();
}
void SwigCgocallBackDone()
__asm__(SWIGSTRINGIFY(SWIGGO_PREFIX) ".SwigCgocallBackDone");
void SwigCgocallBackDone() {
SwigDoCgocallBackDone();
}
#undef SWIGSTRINGIFY
#undef SWIGSTRINGIFY2
#ifdef __cplusplus
}
#endif
%}
#endif
#endif
#if !SWIGGO_CGO
%insert(runtime) %{
/* This is here for backward compatibility, but it will not work
with Go 1.5 or later. Do not use it in new code. */
static _gostring_ _swig_makegostring(const char *p, size_t l) {
_gostring_ ret;
ret.p = (char*)_swig_goallocate(l + 1);
memcpy(ret.p, p, l);
ret.n = l;
return ret;
}
%}
#endif
%insert(runtime) %{
#define SWIG_contract_assert(expr, msg) \
if (!(expr)) { _swig_gopanic(msg); } else
%}
#ifndef SWIGGO_GCCGO
%go_import("unsafe", _ "runtime/cgo")
#if !SWIGGO_CGO
%insert(go_header) %{
var _cgo_runtime_cgocall func(unsafe.Pointer, uintptr)
%}
#endif
#else
%go_import("syscall", "unsafe")

43
Lib/go/std_array.i Normal file
View file

@ -0,0 +1,43 @@
/* -----------------------------------------------------------------------------
* std_array.i
* ----------------------------------------------------------------------------- */
%include <std_common.i>
namespace std {
template<class T, size_t N> class array {
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;
array();
array(const array& other);
size_type size() const;
%rename(isEmpty) empty;
bool empty() const;
void fill(const T& u);
%extend {
const_reference get(int i) throw (std::out_of_range) {
int size = int(self->size());
if (i>=0 && i<size)
return (*self)[i];
else
throw std::out_of_range("array index out of range");
}
void set(int i, const value_type& val) throw (std::out_of_range) {
int size = int(self->size());
if (i>=0 && i<size)
(*self)[i] = val;
else
throw std::out_of_range("array index out of range");
}
}
};
}

View file

@ -378,26 +378,26 @@ typedef unsigned long SCM;
#define %argument_fail(code, type, name, argn) scm_wrong_type_arg((char *) FUNC_NAME, argn, $input);
#define %as_voidptr(ptr) (void*)(ptr)
%typemap(in) SWIGTYPE (CLASS::*) {
int res = SWIG_ConvertMember($input, %as_voidptr(&$1), sizeof($type),$descriptor);
%typemap(in) SWIGTYPE (CLASS::*) {
int res = SWIG_ConvertMember($input, %as_voidptr(&$1), sizeof($1), $descriptor);
if (!SWIG_IsOK(res)) {
%argument_fail(res,"$type",$symname, $argnum);
%argument_fail(res,"$type",$symname, $argnum);
}
}
%typemap(out,noblock=1) SWIGTYPE (CLASS::*) {
%set_output(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor));
%set_output(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($1), $descriptor));
}
%typemap(varin) SWIGTYPE (CLASS::*) {
int res = SWIG_ConvertMember($input,%as_voidptr(&$1), sizeof($type), $descriptor);
int res = SWIG_ConvertMember($input,%as_voidptr(&$1), sizeof($1), $descriptor);
if (!SWIG_IsOK(res)) {
scm_wrong_type_arg((char *) FUNC_NAME, 1, $input);
}
}
%typemap(varout,noblock=1) SWIGTYPE (CLASS::*) {
%set_varoutput(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor));
%set_varoutput(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($1), $descriptor));
}
/* ------------------------------------------------------------

View file

@ -104,7 +104,7 @@ JAVA_ARRAYS_DECL(int, jint, Int, Int) /* int[] */
JAVA_ARRAYS_DECL(unsigned int, jlong, Long, Uint) /* unsigned int[] */
JAVA_ARRAYS_DECL(long, jint, Int, Long) /* long[] */
JAVA_ARRAYS_DECL(unsigned long, jlong, Long, Ulong) /* unsigned long[] */
JAVA_ARRAYS_DECL(jlong, jlong, Long, Longlong) /* long long[] */
JAVA_ARRAYS_DECL(long long, jlong, Long, Longlong) /* long long[] */
JAVA_ARRAYS_DECL(float, jfloat, Float, Float) /* float[] */
JAVA_ARRAYS_DECL(double, jdouble, Double, Double) /* double[] */
@ -128,7 +128,7 @@ JAVA_ARRAYS_IMPL(int, jint, Int, Int) /* int[] */
JAVA_ARRAYS_IMPL(unsigned int, jlong, Long, Uint) /* unsigned int[] */
JAVA_ARRAYS_IMPL(long, jint, Int, Long) /* long[] */
JAVA_ARRAYS_IMPL(unsigned long, jlong, Long, Ulong) /* unsigned long[] */
JAVA_ARRAYS_IMPL(jlong, jlong, Long, Longlong) /* long long[] */
JAVA_ARRAYS_IMPL(long long, jlong, Long, Longlong) /* long long[] */
JAVA_ARRAYS_IMPL(float, jfloat, Float, Float) /* float[] */
JAVA_ARRAYS_IMPL(double, jdouble, Double, Double) /* double[] */

View file

@ -215,6 +215,15 @@ namespace Swig {
}
};
struct SwigDirectorMethod {
const char *name;
const char *desc;
jmethodID methid;
SwigDirectorMethod(JNIEnv *jenv, jclass baseclass, const char *name, const char *desc) : name(name), desc(desc) {
methid = jenv->GetMethodID(baseclass, name, desc);
}
};
/* Java object wrapper */
JObjectWrapper swig_self_;
@ -238,6 +247,11 @@ namespace Swig {
}
}
jclass swig_new_global_ref(JNIEnv *jenv, const char *classname) {
jclass clz = jenv->FindClass(classname);
return clz ? (jclass)jenv->NewGlobalRef(clz) : 0;
}
public:
Director(JNIEnv *jenv) : swig_jvm_((JavaVM *) NULL), swig_self_() {
/* Acquire the Java VM pointer */

View file

@ -1196,6 +1196,7 @@ Swig::LocalRefGuard $1_refguard(jenv, $input); }
%typemap(javacode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(javaimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(javainterfaces) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(javainterfacemodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "public interface"
/* javabody typemaps */

View file

@ -30,18 +30,6 @@
#endif
%insert(runtime) %{
/* Fix for jlong on some versions of gcc on Windows */
#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
typedef long long __int64;
#endif
/* Fix for jlong on 64-bit x86 Solaris */
#if defined(__x86_64)
# ifdef _LP64
# undef _LP64
# endif
#endif
#include <jni.h>
#include <stdlib.h>
#include <string.h>

View file

@ -1,5 +1,5 @@
/*
The typemaps here allow to handle functions returning std::auto_ptr<>,
The typemaps here allow handling functions returning std::auto_ptr<>,
which is the most common use of this type. If you have functions taking it
as parameter, these typemaps can't be used for them and you need to do
something else (e.g. use shared_ptr<> which SWIG supports fully).

View file

@ -28,7 +28,7 @@
}
%typemap(javaout) CTYPE *const& {
long cPtr = $jnicall;
return (cPtr == 0) ? null : ($javainterfacename)new $javaclassname(cPtr, $owner);
return (cPtr == 0) ? null : ($*javainterfacename)new $*javaclassname(cPtr, $owner);
}
%typemap(javadirectorin) CTYPE "($&javainterfacename)new $&javaclassname($jniinput, true)"

View file

@ -21,34 +21,39 @@
* fs = example.FiddleSticks;
* ----------------------------------------------------------------------------- */
%fragment("SWIG_JSCGetIntProperty", "header", fragment=SWIG_AsVal_frag(int)) {}
%fragment("SWIG_JSCGetIntProperty", "header", fragment=SWIG_AsVal_frag(int)) {}
%fragment("SWIG_JSCGetNumberProperty", "header", fragment=SWIG_AsVal_frag(double)) {}
%fragment("SWIG_JSCOutInt", "header", fragment=SWIG_From_frag(int)) {}
%fragment("SWIG_JSCOutNumber", "header", fragment=SWIG_From_frag(double)) {}
%typemap(in, fragment="SWIG_JSCGetIntProperty") int[], int[ANY]
(int length = 0, JSObjectRef array, JSValueRef jsvalue, int i = 0, int res = 0, $*1_ltype temp) {
%define JAVASCRIPT_ARRAYS_IN_DECL(NAME, CTYPE, ANY, ANYLENGTH)
%typemap(in, fragment=NAME) CTYPE[ANY] {
if (JSValueIsObject(context, $input))
{
int i;
// Convert into Array
array = JSValueToObject(context, $input, NULL);
JSObjectRef array = JSValueToObject(context, $input, NULL);
length = $1_dim0;
int length = ANYLENGTH;
$1 = ($*1_ltype *)malloc(sizeof($*1_ltype) * length);
// Get each element from array
for (i = 0; i < length; i++)
{
jsvalue = JSObjectGetPropertyAtIndex(context, array, i, NULL);
JSValueRef jsvalue = JSObjectGetPropertyAtIndex(context, array, i, NULL);
$*1_ltype temp;
// Get primitive value from JSObject
res = SWIG_AsVal(int)(jsvalue, &temp);
int res = SWIG_AsVal(CTYPE)(jsvalue, &temp);
if (!SWIG_IsOK(res))
{
SWIG_exception_fail(SWIG_ERROR, "Failed to convert $input to double");
}
arg$argnum[i] = temp;
}
}
else
{
@ -56,68 +61,34 @@
}
}
%typemap(freearg) int[], int[ANY] {
%typemap(freearg) CTYPE[ANY] {
free($1);
}
%typemap(out, fragment=SWIG_From_frag(int)) int[], int[ANY] (int length = 0, int i = 0)
{
length = $1_dim0;
%enddef
%define JAVASCRIPT_ARRAYS_OUT_DECL(NAME, CTYPE)
%typemap(out, fragment=NAME) CTYPE[ANY] {
int length = $1_dim0;
JSValueRef values[length];
int i;
for (i = 0; i < length; i++)
{
values[i] = SWIG_From(int)($1[i]);
values[i] = SWIG_From(CTYPE)($1[i]);
}
$result = JSObjectMakeArray(context, length, values, NULL);
}
%typemap(in, fragment="SWIG_JSCGetNumberProperty") double[], double[ANY]
(int length = 0, JSObjectRef array, JSValueRef jsvalue, int i = 0, int res = 0, $*1_ltype temp) {
if (JSValueIsObject(context, $input))
{
// Convert into Array
array = JSValueToObject(context, $input, NULL);
%enddef
length = $1_dim0;
JAVASCRIPT_ARRAYS_IN_DECL("SWIG_JSCGetIntProperty", int, , SWIGJSC_ArrayLength(context, array))
JAVASCRIPT_ARRAYS_IN_DECL("SWIG_JSCGetIntProperty", int, ANY, $1_dim0)
JAVASCRIPT_ARRAYS_IN_DECL("SWIG_JSCGetNumberProperty", double, , SWIGJSC_ArrayLength(context, array))
JAVASCRIPT_ARRAYS_IN_DECL("SWIG_JSCGetNumberProperty", double, ANY, $1_dim0)
$1 = ($*1_ltype *)malloc(sizeof($*1_ltype) * length);
JAVASCRIPT_ARRAYS_OUT_DECL("SWIG_JSCOutInt", int)
JAVASCRIPT_ARRAYS_OUT_DECL("SWIG_JSCOutNumber", double)
// Get each element from array
for (i = 0; i < length; i++)
{
jsvalue = JSObjectGetPropertyAtIndex(context, array, i, NULL);
// Get primitive value from JSObject
res = SWIG_AsVal(double)(jsvalue, &temp);
if (!SWIG_IsOK(res))
{
SWIG_exception_fail(SWIG_ERROR, "Failed to convert $input to double");
}
arg$argnum[i] = temp;
}
}
else
{
SWIG_exception_fail(SWIG_ERROR, "$input is not JSObjectRef");
}
}
%typemap(freearg) double[], double[ANY] {
free($1);
}
%typemap(out, fragment=SWIG_From_frag(double)) double[], double[ANY] (int length = 0, int i = 0)
{
length = $1_dim0;
JSValueRef values[length];
for (i = 0; i < length; i++)
{
values[i] = SWIG_From(double)($1[i]);
}
$result = JSObjectMakeArray(context, length, values, NULL);
}

View file

@ -12,15 +12,16 @@
#include <complex.h>
%}
#define complex _Complex
/* C complex constructor */
#define CCplxConst(r, i) ((r) + I*(i))
%swig_cplxflt_convn(float complex, CCplxConst, creal, cimag);
%swig_cplxdbl_convn(double complex, CCplxConst, creal, cimag);
%swig_cplxdbl_convn(complex, CCplxConst, creal, cimag);
%swig_cplxflt_convn(float _Complex, CCplxConst, creal, cimag);
%swig_cplxdbl_convn(double _Complex, CCplxConst, creal, cimag);
%swig_cplxdbl_convn(_Complex, CCplxConst, creal, cimag);
/* declaring the typemaps */
%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float complex);
%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double complex);
%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex);
%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float _Complex);
%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double _Complex);
%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, _Complex);

View file

@ -127,7 +127,7 @@ SWIG_AsVal_dec(Type)(JSValueRef o, Type *val)
float re;
int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re));
if (SWIG_IsOK(res)) {
if (val) *val = Constructor(re, 0.0);
if (val) *val = Constructor(re, 0.0f);
return res;
}
}

View file

@ -1,14 +1,59 @@
%insert(init) %{
SWIGRUNTIME void
SWIG_JSC_SetModule(swig_module_info *swig_module) {}
SWIG_JSC_SetModule(JSGlobalContextRef context, swig_module_info *swig_module) {
JSObjectRef globalObject;
JSStringRef moduleName;
JSClassDefinition classDef;
JSClassRef classRef;
JSObjectRef object;
if(context == 0){
return;
}
globalObject = JSContextGetGlobalObject(context);
moduleName = JSStringCreateWithUTF8CString("swig_module_info_data");
classDef = kJSClassDefinitionEmpty;
classRef = JSClassCreate(&classDef);
object = JSObjectMake(context, classRef, NULL);
JSObjectSetPrivate(object, (void*)swig_module);
JSObjectSetProperty(context, globalObject, moduleName, object, kJSPropertyAttributeNone, NULL);
JSClassRelease(classRef);
JSStringRelease(moduleName);
}
SWIGRUNTIME swig_module_info *
SWIG_JSC_GetModule(void) {
return 0;
SWIG_JSC_GetModule(JSGlobalContextRef context) {
JSObjectRef globalObject;
JSStringRef moduleName;
JSValueRef value;
JSObjectRef object;
if(context == 0){
return 0;
}
globalObject = JSContextGetGlobalObject(context);
moduleName = JSStringCreateWithUTF8CString("swig_module_info_data");
if(JSObjectHasProperty(context, globalObject, moduleName) == false) {
JSStringRelease(moduleName);
return 0;
}
value = JSObjectGetProperty(context, globalObject, moduleName, NULL);
object = JSValueToObject(context, value, NULL);
JSStringRelease(moduleName);
return (swig_module_info*)JSObjectGetPrivate(object);
}
#define SWIG_GetModule(clientdata) SWIG_JSC_GetModule()
#define SWIG_SetModule(clientdata, pointer) SWIG_JSC_SetModule(pointer)
#define SWIG_GetModule(clientdata) SWIG_JSC_GetModule(clientdata)
#define SWIG_SetModule(clientdata, pointer) SWIG_JSC_SetModule(clientdata, pointer)
#define SWIG_INIT_CLIENT_DATA_TYPE JSGlobalContextRef
%}
%insert(init) "swiginit.swg"
@ -26,7 +71,7 @@ extern "C" {
#endif
bool SWIGJSC_INIT (JSGlobalContextRef context, JSObjectRef *exports) {
SWIG_InitializeModule(0);
SWIG_InitializeModule(context);
%}
/* -----------------------------------------------------------------------------

View file

@ -117,27 +117,25 @@ SWIGRUNTIME int SWIG_JSC_ConvertInstancePtr(JSContextRef context, JSObjectRef ob
SwigPrivData *cdata;
cdata = (SwigPrivData *) JSObjectGetPrivate(objRef);
if(cdata == NULL) {
if (cdata == NULL) {
return SWIG_ERROR;
}
if(cdata->info != info) {
bool type_valid = false;
swig_cast_info *t = info->cast;
while(t != NULL) {
if(t->type == cdata->info) {
type_valid = true;
break;
}
t = t->next;
}
if(!type_valid) {
return SWIG_TypeError;
assert(ptr);
*ptr = NULL;
if (cdata->info == info) {
*ptr = cdata->swigCObject;
} else {
swig_cast_info *tc = SWIG_TypeCheckStruct(cdata->info, info);
if (tc) {
int newmemory = 0;
*ptr = SWIG_TypeCast(tc, cdata->swigCObject, &newmemory);
assert(!newmemory); /* newmemory handling not yet implemented */
} else {
return SWIG_ERROR;
}
}
*ptr = cdata->swigCObject;
if(flags & SWIG_POINTER_DISOWN) {
if (flags & SWIG_POINTER_DISOWN) {
cdata->swigCMemOwn = false;
}
@ -317,6 +315,30 @@ unsigned int SWIGJSC_ArrayLength(JSContextRef context, JSObjectRef arr) {
}
}
SWIGRUNTIME
bool SWIGJSC_ValueIsArray(JSContextRef context, JSValueRef value) {
if (JSValueIsObject(context, value)) {
static JSStringRef ArrayString = NULL;
static JSStringRef isArrayString = NULL;
JSObjectRef array = NULL;
JSObjectRef isArray = NULL;
JSValueRef retval = NULL;
if (!ArrayString)
ArrayString = JSStringCreateWithUTF8CString("Array");
if (!isArrayString)
isArrayString = JSStringCreateWithUTF8CString("isArray");
array = (JSObjectRef)JSObjectGetProperty(context, JSContextGetGlobalObject(context), ArrayString, NULL);
isArray = (JSObjectRef)JSObjectGetProperty(context, array, isArrayString, NULL);
retval = JSObjectCallAsFunction(context, isArray, NULL, 1, &value, NULL);
if (JSValueIsBoolean(context, retval))
return JSValueToBoolean(context, retval);
}
return false;
}
SWIGRUNTIME
JSValueRef SWIGJSC_AppendOutput(JSContextRef context, JSValueRef value, JSValueRef obj) {
JSObjectRef arr;
@ -324,6 +346,8 @@ JSValueRef SWIGJSC_AppendOutput(JSContextRef context, JSValueRef value, JSValueR
if (JSValueIsUndefined(context, value)) {
arr = JSObjectMakeArray(context, 0, 0, 0);
} else if (!SWIGJSC_ValueIsArray(context, value)) {
arr = JSObjectMakeArray(context, 1, &value, 0);
} else {
arr = JSValueToObject(context, value, 0);
}

View file

@ -11,6 +11,7 @@
#include <string.h>
#include <errno.h>
#include <limits.h>
#include <assert.h>
%}
%insert(runtime) "swigrun.swg"; /* SWIG API */

View file

@ -21,105 +21,66 @@
* fs = example.FiddleSticks;
* ----------------------------------------------------------------------------- */
%fragment("SWIG_JSCGetIntProperty", "header", fragment=SWIG_AsVal_frag(int)) {}
%fragment("SWIG_JSCGetIntProperty", "header", fragment=SWIG_AsVal_frag(int)) {}
%fragment("SWIG_JSCGetNumberProperty", "header", fragment=SWIG_AsVal_frag(double)) {}
%fragment("SWIG_JSCOutInt", "header", fragment=SWIG_From_frag(int)) {}
%fragment("SWIG_JSCOutNumber", "header", fragment=SWIG_From_frag(double)) {}
%typemap(in, fragment="SWIG_JSCGetIntProperty") int[], int[ANY]
(int length = 0, v8::Local<v8::Array> array, v8::Local<v8::Value> jsvalue, int i = 0, int res = 0, $*1_ltype temp) {
if ($input->IsArray())
{
%define JAVASCRIPT_ARRAYS_IN_DECL(NAME, CTYPE, ANY, ANYLENGTH)
%typemap(in, fragment=NAME) CTYPE[ANY] {
if ($input->IsArray()) {
// Convert into Array
array = v8::Local<v8::Array>::Cast($input);
v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast($input);
length = $1_dim0;
int length = ANYLENGTH;
$1 = ($*1_ltype *)malloc(sizeof($*1_ltype) * length);
$1 = ($*1_ltype *)malloc(sizeof($*1_ltype) * length);
// Get each element from array
for (i = 0; i < length; i++)
{
jsvalue = array->Get(i);
for (int i = 0; i < length; i++) {
v8::Local<v8::Value> jsvalue = SWIGV8_ARRAY_GET(array, i);
$*1_ltype temp;
// Get primitive value from JSObject
res = SWIG_AsVal(int)(jsvalue, &temp);
if (!SWIG_IsOK(res))
{
int res = SWIG_AsVal(CTYPE)(jsvalue, &temp);
if (!SWIG_IsOK(res)) {
SWIG_exception_fail(SWIG_ERROR, "Failed to convert $input to double");
}
arg$argnum[i] = temp;
}
}
else
{
SWIG_exception_fail(SWIG_ERROR, "$input is not JSObjectRef");
} else {
SWIG_exception_fail(SWIG_ERROR, "$input is not an array");
}
}
%typemap(freearg) int[], int[ANY] {
free($1);
%typemap(freearg) CTYPE[ANY] {
free($1);
}
%typemap(out, fragment=SWIG_From_frag(int)) int[], int[ANY] (int length = 0, int i = 0)
{
length = $1_dim0;
v8::Local<v8::Array> array = v8::Array::New(length);
%enddef
for (i = 0; i < length; i++)
{
array->Set(i, SWIG_From(int)($1[i]));
%define JAVASCRIPT_ARRAYS_OUT_DECL(NAME, CTYPE)
%typemap(out, fragment=NAME) CTYPE[ANY] {
int length = $1_dim0;
v8::Local<v8::Array> array = SWIGV8_ARRAY_NEW(length);
for (int i = 0; i < length; i++) {
SWIGV8_ARRAY_SET(array, i, SWIG_From(CTYPE)($1[i]));
}
$result = array;
}
%typemap(in, fragment="SWIG_JSCGetNumberProperty") double[], double[ANY]
(int length = 0, v8::Local<v8::Array> array, v8::Local<v8::Value> jsvalue, int i = 0, int res = 0, $*1_ltype temp) {
if ($input->IsArray())
{
// Convert into Array
array = v8::Local<v8::Array>::Cast($input);
%enddef
length = $1_dim0;
JAVASCRIPT_ARRAYS_IN_DECL("SWIG_JSCGetIntProperty", int, , array->Length())
JAVASCRIPT_ARRAYS_IN_DECL("SWIG_JSCGetIntProperty", int, ANY, $1_dim0)
JAVASCRIPT_ARRAYS_IN_DECL("SWIG_JSCGetNumberProperty", double, , array->Length())
JAVASCRIPT_ARRAYS_IN_DECL("SWIG_JSCGetNumberProperty", double, ANY, $1_dim0)
$1 = ($*1_ltype *)malloc(sizeof($*1_ltype) * length);
JAVASCRIPT_ARRAYS_OUT_DECL("SWIG_JSCOutInt", int)
JAVASCRIPT_ARRAYS_OUT_DECL("SWIG_JSCOutNumber", double)
// Get each element from array
for (i = 0; i < length; i++)
{
jsvalue = array->Get(i);
// Get primitive value from JSObject
res = SWIG_AsVal(double)(jsvalue, &temp);
if (!SWIG_IsOK(res))
{
SWIG_exception_fail(SWIG_ERROR, "Failed to convert $input to double");
}
arg$argnum[i] = temp;
}
}
else
{
SWIG_exception_fail(SWIG_ERROR, "$input is not JSObjectRef");
}
}
%typemap(freearg) double[], double[ANY] {
free($1);
}
%typemap(out, fragment=SWIG_From_frag(double)) double[], double[ANY] (int length = 0, int i = 0)
{
length = $1_dim0;
v8::Local<v8::Array> array = v8::Array::New(length);
for (i = 0; i < length; i++)
{
array->Set(i, SWIG_From(double)($1[i]));
}
$result = array;
}

View file

@ -6,21 +6,22 @@
* ----------------------------------------------------------------------------- */
%include <javscriptcomplex.swg>
%include <javascriptcomplex.swg>
%{
#include <complex.h>
%}
#define complex _Complex
/* C complex constructor */
#define CCplxConst(r, i) ((r) + I*(i))
%swig_cplxflt_convn(float complex, CCplxConst, creal, cimag);
%swig_cplxdbl_convn(double complex, CCplxConst, creal, cimag);
%swig_cplxdbl_convn(complex, CCplxConst, creal, cimag);
%swig_cplxflt_convn(float _Complex, CCplxConst, creal, cimag);
%swig_cplxdbl_convn(double _Complex, CCplxConst, creal, cimag);
%swig_cplxdbl_convn(_Complex, CCplxConst, creal, cimag);
/* declaring the typemaps */
%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float complex);
%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double complex);
%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex);
%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float _Complex);
%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double _Complex);
%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, _Complex);

View file

@ -10,9 +10,10 @@
%fragment("js_ctor", "templates") %{
static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) {
SWIGV8_HANDLESCOPE();
v8::Handle<v8::Object> self = args.Holder();
SWIGV8_OBJECT self = args.Holder();
$jslocals
if(self->InternalFieldCount() < 1) SWIG_exception_fail(SWIG_ERROR, "Illegal call of constructor $jswrapper.");
if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
$jscode
@ -53,7 +54,7 @@ static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) {
SWIGV8_HANDLESCOPE();
OverloadErrorHandler errorHandler;
v8::Handle<v8::Value> self;
SWIGV8_VALUE self;
// switch all cases by means of series of if-returns.
$jsdispatchcases
@ -77,9 +78,10 @@ fail:
%fragment("js_overloaded_ctor", "templates") %{
static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args, V8ErrorHandler &SWIGV8_ErrorHandler) {
SWIGV8_HANDLESCOPE();
v8::Handle<v8::Object> self = args.Holder();
SWIGV8_OBJECT self = args.Holder();
$jslocals
if(self->InternalFieldCount() < 1) SWIG_exception_fail(SWIG_ERROR, "Illegal call of constructor $jswrapper.");
if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
$jscode
@ -103,17 +105,10 @@ fail:
%{
if(args.Length() == $jsargcount) {
errorHandler.err.Clear();
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
self = $jswrapper(args, errorHandler);
if(errorHandler.err.IsEmpty()) {
SWIGV8_ESCAPE(self);
}
#else
$jswrapper(args, errorHandler);
if(errorHandler.err.IsEmpty()) {
return;
}
#endif
}
%}
@ -125,22 +120,8 @@ fail:
%fragment ("js_dtor", "templates")
%{
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
static void $jswrapper(v8::Persistent< v8::Value > object, void *parameter) {
SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
static void $jswrapper(v8::Isolate *isolate, v8::Persistent<v8::Value> object, void *parameter) {
SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
static void $jswrapper(v8::Isolate *isolate, v8::Persistent<v8::Object> *object, SWIGV8_Proxy *proxy) {
#elif (V8_MAJOR_VERSION-0) < 5
static void $jswrapper(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &data) {
v8::Local<v8::Object> object = data.GetValue();
static void $jswrapper(const v8::WeakCallbackInfo<SWIGV8_Proxy> &data) {
SWIGV8_Proxy *proxy = data.GetParameter();
#else
static void $jswrapper(const v8::WeakCallbackInfo<SWIGV8_Proxy> &data) {
SWIGV8_Proxy *proxy = data.GetParameter();
#endif
if(proxy->swigCMemOwn && proxy->swigCObject) {
#ifdef SWIGRUNTIME_DEBUG
@ -149,20 +130,6 @@ static void $jswrapper(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &dat
$jsfree proxy->swigCObject;
}
delete proxy;
#if (V8_MAJOR_VERSION-0) < 5
object.Clear();
#endif
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
object.Dispose();
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
object.Dispose(isolate);
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100)
object->Dispose(isolate);
#elif (V8_MAJOR_VERSION-0) < 5
object->Dispose();
#endif
}
%}
@ -174,40 +141,14 @@ static void $jswrapper(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &dat
* ----------------------------------------------------------------------------- */
%fragment ("js_dtoroverride", "templates")
%{
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
static void $jswrapper(v8::Persistent<v8::Value> object, void *parameter) {
SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
static void $jswrapper(v8::Isolate *isolate, v8::Persistent<v8::Value> object, void *parameter) {
SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
static void $jswrapper(v8::Isolate *isolate, v8::Persistent< v8::Object> *object, SWIGV8_Proxy *proxy) {
#elif (V8_MAJOR_VERSION-0) < 5
static void $jswrapper(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &data) {
v8::Local<v8::Object> object = data.GetValue();
SWIGV8_Proxy *proxy = data.GetParameter();
#else
static void $jswrapper(const v8::WeakCallbackInfo<SWIGV8_Proxy> &data) {
SWIGV8_Proxy *proxy = data.GetParameter();
#endif
if(proxy->swigCMemOwn && proxy->swigCObject) {
$jstype arg1 = ($jstype)proxy->swigCObject;
${destructor_action}
}
delete proxy;
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
object.Dispose();
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
object.Dispose(isolate);
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100)
object->Dispose(isolate);
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
object->Dispose();
#elif (V8_MAJOR_VERSION-0) < 5
object.Clear();
#endif
}
%}
@ -219,14 +160,10 @@ static void $jswrapper(const v8::WeakCallbackInfo<SWIGV8_Proxy> &data) {
* ----------------------------------------------------------------------------- */
%fragment("js_getter", "templates")
%{
#if (V8_MAJOR_VERSION-0) < 5
static SwigV8ReturnValue $jswrapper(v8::Local<v8::String> property, const SwigV8PropertyCallbackInfo &info) {
#else
static SwigV8ReturnValue $jswrapper(v8::Local<v8::Name> property, const SwigV8PropertyCallbackInfo &info) {
#endif
SWIGV8_HANDLESCOPE();
v8::Handle<v8::Value> jsresult;
SWIGV8_VALUE jsresult;
$jslocals
$jscode
SWIGV8_RETURN_INFO(jsresult, info);
@ -245,11 +182,7 @@ fail:
* ----------------------------------------------------------------------------- */
%fragment("js_setter", "templates")
%{
#if (V8_MAJOR_VERSION-0) < 5
static void $jswrapper(v8::Local<v8::String> property, v8::Local<v8::Value> value, const SwigV8PropertyCallbackInfoVoid &info) {
#else
static void $jswrapper(v8::Local<v8::Name> property, v8::Local<v8::Value> value, const SwigV8PropertyCallbackInfoVoid &info) {
#endif
SWIGV8_HANDLESCOPE();
$jslocals
@ -271,7 +204,7 @@ fail:
static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) {
SWIGV8_HANDLESCOPE();
v8::Handle<v8::Value> jsresult;
SWIGV8_VALUE jsresult;
$jslocals
if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
@ -296,7 +229,7 @@ fail:
static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) {
SWIGV8_HANDLESCOPE();
v8::Handle<v8::Value> jsresult;
SWIGV8_VALUE jsresult;
OverloadErrorHandler errorHandler;
$jscode
@ -320,7 +253,7 @@ static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args, V8ErrorHandler
{
SWIGV8_HANDLESCOPE();
v8::Handle<v8::Value> jsresult;
SWIGV8_VALUE jsresult;
$jslocals
$jscode
SWIGV8_RETURN(jsresult);
@ -342,17 +275,10 @@ fail:
if(args.Length() == $jsargcount) {
errorHandler.err.Clear();
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
jsresult = $jswrapper(args, errorHandler);
if(errorHandler.err.IsEmpty()) {
SWIGV8_ESCAPE(jsresult);
}
#else
$jswrapper(args, errorHandler);
if(errorHandler.err.IsEmpty()) {
return;
}
#endif
}
%}
@ -374,7 +300,7 @@ fail:
%fragment("jsv8_define_class_template", "templates")
%{
/* Name: $jsmangledname, Type: $jsmangledtype, Dtor: $jsdtor */
v8::Handle<v8::FunctionTemplate> $jsmangledname_class = SWIGV8_CreateClassTemplate("$jsmangledname");
SWIGV8_FUNCTION_TEMPLATE $jsmangledname_class = SWIGV8_CreateClassTemplate("$jsmangledname");
SWIGV8_SET_CLASS_TEMPL($jsmangledname_clientData.class_templ, $jsmangledname_class);
$jsmangledname_clientData.dtor = $jsdtor;
if (SWIGTYPE_$jsmangledtype->clientdata == 0) {
@ -392,15 +318,11 @@ fail:
%{
if (SWIGTYPE_p$jsbaseclass->clientdata && !(static_cast<SWIGV8_ClientData *>(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ.IsEmpty()))
{
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
$jsmangledname_class->Inherit(static_cast<SWIGV8_ClientData *>(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ);
#else
$jsmangledname_class->Inherit(
v8::Local<v8::FunctionTemplate>::New(
v8::Isolate::GetCurrent(),
static_cast<SWIGV8_ClientData *>(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ)
);
#endif
#ifdef SWIGRUNTIME_DEBUG
printf("Inheritance successful $jsmangledname $jsbaseclass\n");
@ -420,11 +342,15 @@ fail:
%fragment("jsv8_create_class_instance", "templates")
%{
/* Class: $jsname ($jsmangledname) */
v8::Handle<v8::FunctionTemplate> $jsmangledname_class_0 = SWIGV8_CreateClassTemplate("$jsname");
SWIGV8_FUNCTION_TEMPLATE $jsmangledname_class_0 = SWIGV8_CreateClassTemplate("$jsname");
$jsmangledname_class_0->SetCallHandler($jsctor);
$jsmangledname_class_0->Inherit($jsmangledname_class);
#if (SWIG_V8_VERSION < 0x0704)
$jsmangledname_class_0->SetHiddenPrototype(true);
v8::Handle<v8::Object> $jsmangledname_obj = $jsmangledname_class_0->GetFunction();
v8::Local<v8::Object> $jsmangledname_obj = $jsmangledname_class_0->GetFunction();
#else
v8::Local<v8::Object> $jsmangledname_obj = $jsmangledname_class_0->GetFunction(context).ToLocalChecked();
#endif
%}
/* -----------------------------------------------------------------------------
@ -435,7 +361,7 @@ fail:
* ----------------------------------------------------------------------------- */
%fragment("jsv8_register_class", "templates")
%{
$jsparent_obj->Set(SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj);
SWIGV8_MAYBE_CHECK($jsparent_obj->Set(context, SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj));
%}
/* -----------------------------------------------------------------------------
@ -444,7 +370,7 @@ fail:
* ----------------------------------------------------------------------------- */
%fragment("jsv8_create_namespace", "templates")
%{
v8::Handle<v8::Object> $jsmangledname_obj = SWIGV8_OBJECT_NEW();
SWIGV8_OBJECT $jsmangledname_obj = SWIGV8_OBJECT_NEW();
%}
/* -----------------------------------------------------------------------------
@ -455,7 +381,7 @@ fail:
* ----------------------------------------------------------------------------- */
%fragment("jsv8_register_namespace", "templates")
%{
$jsparent_obj->Set(SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj);
SWIGV8_MAYBE_CHECK($jsparent_obj->Set(context, SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj));
%}
/* -----------------------------------------------------------------------------
@ -491,7 +417,7 @@ fail:
* ----------------------------------------------------------------------------- */
%fragment("jsv8_register_static_function", "templates")
%{
SWIGV8_AddStaticFunction($jsparent_obj, "$jsname", $jswrapper);
SWIGV8_AddStaticFunction($jsparent_obj, "$jsname", $jswrapper, context);
%}
/* -----------------------------------------------------------------------------
@ -505,5 +431,5 @@ fail:
* ----------------------------------------------------------------------------- */
%fragment("jsv8_register_static_variable", "templates")
%{
SWIGV8_AddStaticVariable($jsparent_obj, "$jsname", $jsgetter, $jssetter);
SWIGV8_AddStaticVariable($jsparent_obj, "$jsname", $jsgetter, $jssetter, context);
%}

View file

@ -12,15 +12,15 @@
%fragment(SWIG_From_frag(Type),"header",
fragment=SWIG_From_frag(double))
{
SWIGINTERNINLINE v8::Handle<v8::Value>
SWIGINTERNINLINE SWIGV8_VALUE
SWIG_From_dec(Type)(%ifcplusplus(const Type&, Type) c)
{
SWIGV8_HANDLESCOPE_ESC();
v8::Local<v8::Array> vals = SWIGV8_ARRAY_NEW();
v8::Local<v8::Array> vals = SWIGV8_ARRAY_NEW(0);
vals->Set(0, SWIG_From(double)(Real(c)));
vals->Set(1, SWIG_From(double)(Imag(c)));
SWIGV8_ARRAY_SET(vals, 0, SWIG_From(double)(Real(c)));
SWIGV8_ARRAY_SET(vals, 1, SWIG_From(double)(Imag(c)));
SWIGV8_ESCAPE(vals);
}
}
@ -32,30 +32,30 @@ SWIG_From_dec(Type)(%ifcplusplus(const Type&, Type) c)
fragment=SWIG_AsVal_frag(double))
{
SWIGINTERN int
SWIG_AsVal_dec(Type) (v8::Handle<v8::Value> o, Type* val)
SWIG_AsVal_dec(Type) (SWIGV8_VALUE o, Type* val)
{
SWIGV8_HANDLESCOPE();
if (o->IsArray()) {
v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(o);
SWIGV8_ARRAY array = SWIGV8_ARRAY::Cast(o);
if(array->Length() != 2) SWIG_Error(SWIG_TypeError, "Illegal argument for complex: must be array[2].");
if (array->Length() != 2) SWIG_Error(SWIG_TypeError, "Illegal argument for complex: must be array[2].");
double re, im;
int res;
res = SWIG_AsVal(double)(array->Get(0), &re);
if(!SWIG_IsOK(res)) {
res = SWIG_AsVal(double)(SWIGV8_ARRAY_GET(array, 0), &re);
if (!SWIG_IsOK(res)) {
return SWIG_TypeError;
}
res = SWIG_AsVal(double)(array->Get(1), &im);
if(!SWIG_IsOK(res)) {
res = SWIG_AsVal(double)(SWIGV8_ARRAY_GET(array, 1), &im);
if (!SWIG_IsOK(res)) {
return SWIG_TypeError;
}
if (val) *val = Constructor(re, im);
return SWIG_OK;
} else if(o->IsNumber()){
} else if (o->IsNumber()) {
double d;
int res = SWIG_AddCast(SWIG_AsVal(double)(o, &d));
if (SWIG_IsOK(res)) {
@ -74,24 +74,24 @@ SWIG_AsVal_dec(Type) (v8::Handle<v8::Value> o, Type* val)
%fragment(SWIG_AsVal_frag(Type),"header",
fragment=SWIG_AsVal_frag(float)) {
SWIGINTERN int
SWIG_AsVal_dec(Type) (v8::Handle<v8::Value> o, Type* val)
SWIG_AsVal_dec(Type) (SWIGV8_VALUE o, Type* val)
{
SWIGV8_HANDLESCOPE();
if (o->IsArray()) {
v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(o);
SWIGV8_ARRAY array = SWIGV8_ARRAY::Cast(o);
if(array->Length() != 2) SWIG_Error(SWIG_TypeError, "Illegal argument for complex: must be array[2].");
if (array->Length() != 2) SWIG_Error(SWIG_TypeError, "Illegal argument for complex: must be array[2].");
double re, im;
int res;
res = SWIG_AsVal(double)(array->Get(0), &re);
if(!SWIG_IsOK(res)) {
res = SWIG_AsVal(double)(SWIGV8_ARRAY_GET(array, 0), &re);
if (!SWIG_IsOK(res)) {
return SWIG_TypeError;
}
res = SWIG_AsVal(double)(array->Get(1), &im);
if(!SWIG_IsOK(res)) {
res = SWIG_AsVal(double)(SWIGV8_ARRAY_GET(array, 1), &im);
if (!SWIG_IsOK(res)) {
return SWIG_TypeError;
}
@ -102,7 +102,7 @@ SWIG_AsVal_dec(Type) (v8::Handle<v8::Value> o, Type* val)
} else {
return SWIG_OverflowError;
}
} else if(o->IsNumber()){
} else if (o->IsNumber()) {
float re;
int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re));
if (SWIG_IsOK(res)) {

View file

@ -1,39 +1,26 @@
%insert(runtime) %{
// Note: since 3.19 there are new CallBack types, since 03.21.9 the old ones have been removed
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
typedef v8::InvocationCallback SwigV8FunctionCallback;
typedef v8::AccessorGetter SwigV8AccessorGetterCallback;
typedef v8::AccessorSetter SwigV8AccessorSetterCallback;
typedef v8::AccessorInfo SwigV8PropertyCallbackInfoVoid;
#elif (V8_MAJOR_VERSION-0) < 5
typedef v8::FunctionCallback SwigV8FunctionCallback;
typedef v8::AccessorGetterCallback SwigV8AccessorGetterCallback;
typedef v8::AccessorSetterCallback SwigV8AccessorSetterCallback;
typedef v8::PropertyCallbackInfo<void> SwigV8PropertyCallbackInfoVoid;
#else
typedef v8::FunctionCallback SwigV8FunctionCallback;
typedef v8::AccessorNameGetterCallback SwigV8AccessorGetterCallback;
typedef v8::AccessorNameSetterCallback SwigV8AccessorSetterCallback;
typedef v8::PropertyCallbackInfo<void> SwigV8PropertyCallbackInfoVoid;
#endif
/**
* Creates a class template for a class with specified initialization function.
*/
SWIGRUNTIME v8::Handle<v8::FunctionTemplate> SWIGV8_CreateClassTemplate(const char* symbol) {
SWIGRUNTIME SWIGV8_FUNCTION_TEMPLATE SWIGV8_CreateClassTemplate(const char* symbol) {
SWIGV8_HANDLESCOPE_ESC();
v8::Local<v8::FunctionTemplate> class_templ = SWIGV8_FUNCTEMPLATE_NEW_VOID();
class_templ->SetClassName(SWIGV8_SYMBOL_NEW(symbol));
v8::Handle<v8::ObjectTemplate> inst_templ = class_templ->InstanceTemplate();
SWIGV8_OBJECT_TEMPLATE inst_templ = class_templ->InstanceTemplate();
inst_templ->SetInternalFieldCount(1);
v8::Handle<v8::ObjectTemplate> equals_templ = class_templ->PrototypeTemplate();
SWIGV8_OBJECT_TEMPLATE equals_templ = class_templ->PrototypeTemplate();
equals_templ->Set(SWIGV8_SYMBOL_NEW("equals"), SWIGV8_FUNCTEMPLATE_NEW(_SWIGV8_wrap_equals));
v8::Handle<v8::ObjectTemplate> cptr_templ = class_templ->PrototypeTemplate();
SWIGV8_OBJECT_TEMPLATE cptr_templ = class_templ->PrototypeTemplate();
cptr_templ->Set(SWIGV8_SYMBOL_NEW("getCPtr"), SWIGV8_FUNCTEMPLATE_NEW(_wrap_getCPtr));
SWIGV8_ESCAPE(class_templ);
@ -42,55 +29,44 @@ SWIGRUNTIME v8::Handle<v8::FunctionTemplate> SWIGV8_CreateClassTemplate(const ch
/**
* Registers a class method with given name for a given class template.
*/
SWIGRUNTIME void SWIGV8_AddMemberFunction(v8::Handle<v8::FunctionTemplate> class_templ, const char* symbol,
SWIGRUNTIME void SWIGV8_AddMemberFunction(SWIGV8_FUNCTION_TEMPLATE class_templ, const char* symbol,
SwigV8FunctionCallback _func) {
v8::Handle<v8::ObjectTemplate> proto_templ = class_templ->PrototypeTemplate();
SWIGV8_OBJECT_TEMPLATE proto_templ = class_templ->PrototypeTemplate();
proto_templ->Set(SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func));
}
/**
* Registers a class property with given name for a given class template.
*/
SWIGRUNTIME void SWIGV8_AddMemberVariable(v8::Handle<v8::FunctionTemplate> class_templ, const char* symbol,
SWIGRUNTIME void SWIGV8_AddMemberVariable(SWIGV8_FUNCTION_TEMPLATE class_templ, const char* symbol,
SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback setter) {
v8::Handle<v8::ObjectTemplate> proto_templ = class_templ->InstanceTemplate();
SWIGV8_OBJECT_TEMPLATE proto_templ = class_templ->InstanceTemplate();
proto_templ->SetAccessor(SWIGV8_SYMBOL_NEW(symbol), getter, setter);
}
/**
* Registers a class method with given name for a given object.
*/
SWIGRUNTIME void SWIGV8_AddStaticFunction(v8::Handle<v8::Object> obj, const char* symbol,
const SwigV8FunctionCallback& _func) {
obj->Set(SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction());
SWIGRUNTIME void SWIGV8_AddStaticFunction(SWIGV8_OBJECT obj, const char* symbol,
const SwigV8FunctionCallback& _func, v8::Local<v8::Context> context) {
SWIGV8_MAYBE_CHECK(obj->Set(context, SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction(context).ToLocalChecked()));
}
/**
* Registers a class method with given name for a given object.
*/
SWIGRUNTIME void SWIGV8_AddStaticVariable(v8::Handle<v8::Object> obj, const char* symbol,
SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback setter) {
#if (V8_MAJOR_VERSION-0) < 5
obj->SetAccessor(SWIGV8_SYMBOL_NEW(symbol), getter, setter);
#else
obj->SetAccessor(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW(symbol), getter, setter);
#endif
SWIGRUNTIME void SWIGV8_AddStaticVariable(SWIGV8_OBJECT obj, const char* symbol,
SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback setter,
v8::Local<v8::Context> context) {
SWIGV8_MAYBE_CHECK(obj->SetAccessor(context, SWIGV8_SYMBOL_NEW(symbol), getter, setter));
}
#if (V8_MAJOR_VERSION-0) < 5
SWIGRUNTIME void JS_veto_set_variable(v8::Local<v8::String> property, v8::Local<v8::Value> value, const SwigV8PropertyCallbackInfoVoid& info)
#else
SWIGRUNTIME void JS_veto_set_variable(v8::Local<v8::Name> property, v8::Local<v8::Value> value, const SwigV8PropertyCallbackInfoVoid& info)
#endif
{
char buffer[256];
char msg[512];
int res;
#if (V8_MAJOR_VERSION-0) < 5
property->WriteUtf8(buffer, 256);
res = sprintf(msg, "Tried to write read-only variable: %s.", buffer);
#else
v8::Local<v8::String> sproperty;
if (property->ToString(SWIGV8_CURRENT_CONTEXT()).ToLocal(&sproperty)) {
SWIGV8_WRITE_UTF8(sproperty, buffer, 256);
@ -99,7 +75,6 @@ SWIGRUNTIME void JS_veto_set_variable(v8::Local<v8::Name> property, v8::Local<v8
else {
res = -1;
}
#endif
if(res<0) {
SWIG_exception(SWIG_ERROR, "Tried to write read-only variable.");

View file

@ -5,29 +5,21 @@
%insert(init) %{
SWIGRUNTIME void
SWIG_V8_SetModule(void *, swig_module_info *swig_module) {
v8::Local<v8::Object> global_obj = SWIGV8_CURRENT_CONTEXT()->Global();
SWIG_V8_SetModule(v8::Local<v8::Context> context, swig_module_info *swig_module) {
v8::Local<v8::Object> global_obj = context->Global();
v8::Local<v8::External> mod = SWIGV8_EXTERNAL_NEW(swig_module);
assert(!mod.IsEmpty());
#if (V8_MAJOR_VERSION-0) < 5
global_obj->SetHiddenValue(SWIGV8_STRING_NEW("swig_module_info_data"), mod);
#else
v8::Local<v8::Private> privateKey = v8::Private::ForApi(v8::Isolate::GetCurrent(), SWIGV8_STRING_NEW("swig_module_info_data"));
global_obj->SetPrivate(SWIGV8_CURRENT_CONTEXT(), privateKey, mod);
#endif
global_obj->SetPrivate(context, privateKey, mod);
}
SWIGRUNTIME swig_module_info *
SWIG_V8_GetModule(void *) {
v8::Local<v8::Object> global_obj = SWIGV8_CURRENT_CONTEXT()->Global();
#if (V8_MAJOR_VERSION-0) < 5
v8::Local<v8::Value> moduleinfo = global_obj->GetHiddenValue(SWIGV8_STRING_NEW("swig_module_info_data"));
#else
SWIG_V8_GetModule(v8::Local<v8::Context> context) {
v8::Local<v8::Object> global_obj = context->Global();
v8::Local<v8::Private> privateKey = v8::Private::ForApi(v8::Isolate::GetCurrent(), SWIGV8_STRING_NEW("swig_module_info_data"));
v8::Local<v8::Value> moduleinfo;
if (!global_obj->GetPrivate(SWIGV8_CURRENT_CONTEXT(), privateKey).ToLocal(&moduleinfo))
if (!global_obj->GetPrivate(context, privateKey).ToLocal(&moduleinfo))
return 0;
#endif
if (moduleinfo.IsEmpty() || moduleinfo->IsNull() || moduleinfo->IsUndefined())
{
@ -52,6 +44,7 @@ SWIG_V8_GetModule(void *) {
#define SWIG_GetModule(clientdata) SWIG_V8_GetModule(clientdata)
#define SWIG_SetModule(clientdata, pointer) SWIG_V8_SetModule(clientdata, pointer)
#define SWIG_INIT_CLIENT_DATA_TYPE v8::Local<v8::Context>
%}
@ -64,20 +57,20 @@ SWIG_V8_GetModule(void *) {
%}
%insert(init) %{
#if !defined(NODE_MODULE_VERSION) || (NODE_MODULE_VERSION < 12)
// Note: 'extern "C"'' disables name mangling which makes it easier to load the symbol manually
// TODO: is it ok to do that?
extern "C"
#if (NODE_MODULE_VERSION < 0x000C)
void SWIGV8_INIT (v8::Handle<v8::Object> exports)
extern "C" void SWIGV8_INIT (SWIGV8_OBJECT exports_obj)
#elif (NODE_MODULE_VERSION < 64)
void SWIGV8_INIT (SWIGV8_OBJECT exports_obj, SWIGV8_VALUE /*module*/, void*)
#else
void SWIGV8_INIT (v8::Handle<v8::Object> exports, v8::Handle<v8::Object> /*module*/)
void SWIGV8_INIT (SWIGV8_OBJECT exports_obj, SWIGV8_VALUE /*module*/, v8::Local<v8::Context> context, void*)
#endif
{
SWIG_InitializeModule(static_cast<void *>(&exports));
#if !defined(NODE_MODULE_VERSION) || NODE_MODULE_VERSION < 64
v8::Local<v8::Context> context = SWIGV8_CURRENT_CONTEXT();
#endif
SWIGV8_HANDLESCOPE();
v8::Handle<v8::Object> exports_obj = exports;
SWIG_InitializeModule(context);
%}
@ -124,6 +117,10 @@ void SWIGV8_INIT (v8::Handle<v8::Object> exports, v8::Handle<v8::Object> /*modul
}
#if defined(BUILDING_NODE_EXTENSION)
#if (NODE_MODULE_VERSION < 64)
NODE_MODULE($jsname, $jsname_initialize)
#else
NODE_MODULE_CONTEXT_AWARE($jsname, $jsname_initialize)
#endif
#endif
%}

View file

@ -6,7 +6,7 @@
%fragment(SWIG_From_frag(bool),"header") {
SWIGINTERNINLINE
v8::Handle<v8::Value>
SWIGV8_VALUE
SWIG_From_dec(bool)(bool value)
{
return SWIGV8_BOOLEAN_NEW(value);
@ -16,7 +16,7 @@ SWIG_From_dec(bool)(bool value)
%fragment(SWIG_AsVal_frag(bool),"header",
fragment=SWIG_AsVal_frag(long)) {
SWIGINTERN
int SWIG_AsVal_dec(bool)(v8::Handle<v8::Value> obj, bool *val)
int SWIG_AsVal_dec(bool)(SWIGV8_VALUE obj, bool *val)
{
if(!obj->IsBoolean()) {
return SWIG_ERROR;
@ -31,7 +31,7 @@ int SWIG_AsVal_dec(bool)(v8::Handle<v8::Value> obj, bool *val)
%fragment(SWIG_From_frag(int),"header") {
SWIGINTERNINLINE
v8::Handle<v8::Value> SWIG_From_dec(int)(int value)
SWIGV8_VALUE SWIG_From_dec(int)(int value)
{
return SWIGV8_INT32_NEW(value);
}
@ -39,7 +39,7 @@ v8::Handle<v8::Value> SWIG_From_dec(int)(int value)
%fragment(SWIG_AsVal_frag(int),"header") {
SWIGINTERN
int SWIG_AsVal_dec(int)(v8::Handle<v8::Value> valRef, int* val)
int SWIG_AsVal_dec(int)(SWIGV8_VALUE valRef, int* val)
{
if (!valRef->IsNumber()) {
return SWIG_TypeError;
@ -54,7 +54,7 @@ int SWIG_AsVal_dec(int)(v8::Handle<v8::Value> valRef, int* val)
%fragment(SWIG_From_frag(long),"header") {
SWIGINTERNINLINE
v8::Handle<v8::Value> SWIG_From_dec(long)(long value)
SWIGV8_VALUE SWIG_From_dec(long)(long value)
{
return SWIGV8_NUMBER_NEW(value);
}
@ -63,7 +63,7 @@ v8::Handle<v8::Value> SWIG_From_dec(long)(long value)
%fragment(SWIG_AsVal_frag(long),"header",
fragment="SWIG_CanCastAsInteger") {
SWIGINTERN
int SWIG_AsVal_dec(long)(v8::Handle<v8::Value> obj, long* val)
int SWIG_AsVal_dec(long)(SWIGV8_VALUE obj, long* val)
{
if (!obj->IsNumber()) {
return SWIG_TypeError;
@ -79,17 +79,16 @@ int SWIG_AsVal_dec(long)(v8::Handle<v8::Value> obj, long* val)
%fragment(SWIG_From_frag(unsigned long),"header",
fragment=SWIG_From_frag(long)) {
SWIGINTERNINLINE
v8::Handle<v8::Value> SWIG_From_dec(unsigned long)(unsigned long value)
SWIGV8_VALUE SWIG_From_dec(unsigned long)(unsigned long value)
{
return (value > LONG_MAX) ?
SWIGV8_INTEGER_NEW_UNS(value) : SWIGV8_INTEGER_NEW(%numeric_cast(value,long));
return SWIGV8_INTEGER_NEW_UNS(value);
}
}
%fragment(SWIG_AsVal_frag(unsigned long),"header",
fragment="SWIG_CanCastAsInteger") {
SWIGINTERN
int SWIG_AsVal_dec(unsigned long)(v8::Handle<v8::Value> obj, unsigned long *val)
int SWIG_AsVal_dec(unsigned long)(SWIGV8_VALUE obj, unsigned long *val)
{
if(!obj->IsNumber()) {
return SWIG_TypeError;
@ -115,7 +114,7 @@ int SWIG_AsVal_dec(unsigned long)(v8::Handle<v8::Value> obj, unsigned long *val)
fragment="SWIG_LongLongAvailable") {
%#ifdef SWIG_LONG_LONG_AVAILABLE
SWIGINTERNINLINE
v8::Handle<v8::Value> SWIG_From_dec(long long)(long long value)
SWIGV8_VALUE SWIG_From_dec(long long)(long long value)
{
return SWIGV8_NUMBER_NEW(value);
}
@ -128,7 +127,7 @@ v8::Handle<v8::Value> SWIG_From_dec(long long)(long long value)
fragment="SWIG_LongLongAvailable") {
%#ifdef SWIG_LONG_LONG_AVAILABLE
SWIGINTERN
int SWIG_AsVal_dec(long long)(v8::Handle<v8::Value> obj, long long* val)
int SWIG_AsVal_dec(long long)(SWIGV8_VALUE obj, long long* val)
{
if (!obj->IsNumber()) {
return SWIG_TypeError;
@ -148,10 +147,9 @@ int SWIG_AsVal_dec(long long)(v8::Handle<v8::Value> obj, long long* val)
fragment="SWIG_LongLongAvailable") {
%#ifdef SWIG_LONG_LONG_AVAILABLE
SWIGINTERNINLINE
v8::Handle<v8::Value> SWIG_From_dec(unsigned long long)(unsigned long long value)
SWIGV8_VALUE SWIG_From_dec(unsigned long long)(unsigned long long value)
{
return (value > LONG_MAX) ?
SWIGV8_INTEGER_NEW_UNS(value) : SWIGV8_INTEGER_NEW(%numeric_cast(value,long));
return SWIGV8_INTEGER_NEW_UNS(value);
}
%#endif
}
@ -162,7 +160,7 @@ v8::Handle<v8::Value> SWIG_From_dec(unsigned long long)(unsigned long long value
fragment="SWIG_LongLongAvailable") {
%#ifdef SWIG_LONG_LONG_AVAILABLE
SWIGINTERN
int SWIG_AsVal_dec(unsigned long long)(v8::Handle<v8::Value> obj, unsigned long long *val)
int SWIG_AsVal_dec(unsigned long long)(SWIGV8_VALUE obj, unsigned long long *val)
{
if(!obj->IsNumber()) {
return SWIG_TypeError;
@ -185,7 +183,7 @@ int SWIG_AsVal_dec(unsigned long long)(v8::Handle<v8::Value> obj, unsigned long
%fragment(SWIG_From_frag(double),"header") {
SWIGINTERN
v8::Handle<v8::Value> SWIG_From_dec(double) (double val)
SWIGV8_VALUE SWIG_From_dec(double) (double val)
{
return SWIGV8_NUMBER_NEW(val);
}
@ -193,7 +191,7 @@ v8::Handle<v8::Value> SWIG_From_dec(double) (double val)
%fragment(SWIG_AsVal_frag(double),"header") {
SWIGINTERN
int SWIG_AsVal_dec(double)(v8::Handle<v8::Value> obj, double *val)
int SWIG_AsVal_dec(double)(SWIGV8_VALUE obj, double *val)
{
if(!obj->IsNumber()) {
return SWIG_TypeError;
@ -203,4 +201,3 @@ int SWIG_AsVal_dec(double)(v8::Handle<v8::Value> obj, double *val)
return SWIG_OK;
}
}

View file

@ -1,75 +1,44 @@
/* ---------------------------------------------------------------------------
* These typedefs and defines are used to deal with v8 API changes
*
* Useful table of versions: https://nodejs.org/en/download/releases/
* ---------------------------------------------------------------------------*/
// First v8 version that uses "SetWeak" and not "MakeWeak"
#define SWIGV8_SETWEAK_VERSION 0x032224
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031803)
#define SWIGV8_STRING_NEW2(cstr, len) v8::String::New(cstr, len)
#else
#if (SWIG_V8_VERSION < 0x0704)
#define SWIGV8_STRING_NEW2(cstr, len) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), cstr, v8::String::kNormalString, len)
#else
#define SWIGV8_STRING_NEW2(cstr, len) (v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), cstr, v8::NewStringType::kNormal, len)).ToLocalChecked()
#endif
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
typedef v8::Handle<v8::Value> SwigV8ReturnValue;
typedef v8::Arguments SwigV8Arguments;
typedef v8::AccessorInfo SwigV8PropertyCallbackInfo;
#define SWIGV8_RETURN(val) return scope.Close(val)
#define SWIGV8_RETURN_INFO(val, info) return scope.Close(val)
#else
typedef void SwigV8ReturnValue;
typedef v8::FunctionCallbackInfo<v8::Value> SwigV8Arguments;
typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
#define SWIGV8_RETURN(val) args.GetReturnValue().Set(val); return
#define SWIGV8_RETURN_INFO(val, info) info.GetReturnValue().Set(val); return
#endif
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032117)
#define SWIGV8_HANDLESCOPE() v8::HandleScope scope
#define SWIGV8_HANDLESCOPE_ESC() v8::HandleScope scope
#define SWIGV8_ESCAPE(val) return scope.Close(val)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032224)
#define SWIGV8_HANDLESCOPE() v8::HandleScope scope(v8::Isolate::GetCurrent());
#define SWIGV8_HANDLESCOPE_ESC() v8::HandleScope scope(v8::Isolate::GetCurrent());
#define SWIGV8_ESCAPE(val) return scope.Close(val)
#else
#define SWIGV8_HANDLESCOPE() v8::HandleScope scope(v8::Isolate::GetCurrent());
#define SWIGV8_HANDLESCOPE_ESC() v8::EscapableHandleScope scope(v8::Isolate::GetCurrent());
#define SWIGV8_ESCAPE(val) return scope.Escape(val)
#endif
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032224)
#define SWIGV8_ADJUST_MEMORY(size) v8::V8::AdjustAmountOfExternalAllocatedMemory(size)
#define SWIGV8_CURRENT_CONTEXT() v8::Context::GetCurrent()
#define SWIGV8_THROW_EXCEPTION(err) v8::ThrowException(err)
#define SWIGV8_STRING_NEW(str) v8::String::New(str)
#define SWIGV8_SYMBOL_NEW(sym) v8::String::NewSymbol(sym)
#else
#define SWIGV8_ADJUST_MEMORY(size) v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(size)
#define SWIGV8_CURRENT_CONTEXT() v8::Isolate::GetCurrent()->GetCurrentContext()
#define SWIGV8_THROW_EXCEPTION(err) v8::Isolate::GetCurrent()->ThrowException(err)
#define SWIGV8_STRING_NEW(str) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), str)
#define SWIGV8_SYMBOL_NEW(sym) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sym)
#if (SWIG_V8_VERSION < 0x0704)
#define SWIGV8_STRING_NEW(str) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), str, v8::String::kNormalString)
#define SWIGV8_SYMBOL_NEW(sym) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sym, v8::String::kNormalString)
#else
#define SWIGV8_STRING_NEW(str) (v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), str, v8::NewStringType::kNormal)).ToLocalChecked()
#define SWIGV8_SYMBOL_NEW(sym) (v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sym, v8::NewStringType::kNormal)).ToLocalChecked()
#endif
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032318)
#define SWIGV8_ARRAY_NEW() v8::Array::New()
#define SWIGV8_BOOLEAN_NEW(bool) v8::Boolean::New(bool)
#define SWIGV8_EXTERNAL_NEW(val) v8::External::New(val)
#define SWIGV8_FUNCTEMPLATE_NEW(func) v8::FunctionTemplate::New(func)
#define SWIGV8_FUNCTEMPLATE_NEW_VOID() v8::FunctionTemplate::New()
#define SWIGV8_INT32_NEW(num) v8::Int32::New(num)
#define SWIGV8_INTEGER_NEW(num) v8::Integer::New(num)
#define SWIGV8_INTEGER_NEW_UNS(num) v8::Integer::NewFromUnsigned(num)
#define SWIGV8_NUMBER_NEW(num) v8::Number::New(num)
#define SWIGV8_OBJECT_NEW() v8::Object::New()
#define SWIGV8_UNDEFINED() v8::Undefined()
#define SWIGV8_NULL() v8::Null()
#if (SWIG_V8_VERSION < 0x0704)
#define SWIGV8_MAYBE_CHECK(maybe) maybe.FromJust()
#else
#define SWIGV8_ARRAY_NEW() v8::Array::New(v8::Isolate::GetCurrent())
#define SWIGV8_MAYBE_CHECK(maybe) maybe.Check()
#endif
#define SWIGV8_ARRAY_NEW(size) v8::Array::New(v8::Isolate::GetCurrent(), size)
#define SWIGV8_BOOLEAN_NEW(bool) v8::Boolean::New(v8::Isolate::GetCurrent(), bool)
#define SWIGV8_EXTERNAL_NEW(val) v8::External::New(v8::Isolate::GetCurrent(), val)
#define SWIGV8_FUNCTEMPLATE_NEW(func) v8::FunctionTemplate::New(v8::Isolate::GetCurrent(), func)
@ -80,26 +49,18 @@ typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
#define SWIGV8_NUMBER_NEW(num) v8::Number::New(v8::Isolate::GetCurrent(), num)
#define SWIGV8_OBJECT_NEW() v8::Object::New(v8::Isolate::GetCurrent())
#define SWIGV8_UNDEFINED() v8::Undefined(v8::Isolate::GetCurrent())
#define SWIGV8_ARRAY v8::Local<v8::Array>
#define SWIGV8_FUNCTION_TEMPLATE v8::Local<v8::FunctionTemplate>
#define SWIGV8_OBJECT v8::Local<v8::Object>
#define SWIGV8_OBJECT_TEMPLATE v8::Local<v8::ObjectTemplate>
#define SWIGV8_VALUE v8::Local<v8::Value>
#define SWIGV8_NULL() v8::Null(v8::Isolate::GetCurrent())
#endif
#define SWIGV8_ARRAY_GET(array, index) (array)->Get(SWIGV8_CURRENT_CONTEXT(), index).ToLocalChecked()
#define SWIGV8_ARRAY_SET(array, index, value) SWIGV8_MAYBE_CHECK((array)->Set(SWIGV8_CURRENT_CONTEXT(), index, value))
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
#define SWIGV8_SET_CLASS_TEMPL(class_templ, class) class_templ = v8::Persistent<v8::FunctionTemplate>::New(class);
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
#define SWIGV8_SET_CLASS_TEMPL(class_templ, class) class_templ = v8::Persistent<v8::FunctionTemplate>::New(v8::Isolate::GetCurrent(), class);
#else
#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)
#if SWIG_V8_VERSION < 0x0608
#define SWIGV8_TO_OBJECT(handle) (handle)->ToObject()
#define SWIGV8_TO_STRING(handle) (handle)->ToString()
#define SWIGV8_NUMBER_VALUE(handle) (handle)->NumberValue()
@ -112,9 +73,13 @@ typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
#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())
#if (SWIG_V8_VERSION < 0x0704)
#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue(SWIGV8_CURRENT_CONTEXT()).ToChecked()
#else
#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue(v8::Isolate::GetCurrent())
#endif
#endif
/* ---------------------------------------------------------------------------
@ -163,7 +128,7 @@ public:
SWIGV8_THROW_EXCEPTION(err);
}
}
v8::Handle<v8::Value> err;
SWIGV8_VALUE err;
};
/* ---------------------------------------------------------------------------
@ -182,23 +147,8 @@ public:
};
~SWIGV8_Proxy() {
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
handle.ClearWeak();
handle.Dispose();
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100)
handle.ClearWeak(v8::Isolate::GetCurrent());
handle.Dispose(v8::Isolate::GetCurrent());
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
handle.ClearWeak();
handle.Dispose();
#else
handle.ClearWeak();
handle.Reset();
#endif
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
handle.Clear();
#endif
SWIGV8_ADJUST_MEMORY(-SWIGV8_AVG_OBJ_SIZE);
}
@ -213,32 +163,17 @@ class SWIGV8_ClientData {
public:
v8::Persistent<v8::FunctionTemplate> class_templ;
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
void (*dtor) (v8::Persistent< v8::Value> object, void *parameter);
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
void (*dtor) (v8::Isolate *isolate, v8::Persistent< v8::Value> object, void *parameter);
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
void (*dtor) (v8::Isolate *isolate, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy);
#elif (V8_MAJOR_VERSION-0) < 5
void (*dtor) (const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &data);
#else
void (*dtor) (const v8::WeakCallbackInfo<SWIGV8_Proxy> &data);
#endif
};
SWIGRUNTIME v8::Persistent<v8::FunctionTemplate> SWIGV8_SWIGTYPE_Proxy_class_templ;
SWIGRUNTIME int SWIG_V8_ConvertInstancePtr(v8::Handle<v8::Object> objRef, void **ptr, swig_type_info *info, int flags) {
SWIGRUNTIME int SWIG_V8_ConvertInstancePtr(SWIGV8_OBJECT objRef, void **ptr, swig_type_info *info, int flags) {
SWIGV8_HANDLESCOPE();
if(objRef->InternalFieldCount() < 1) return SWIG_ERROR;
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511)
v8::Handle<v8::Value> cdataRef = objRef->GetInternalField(0);
SWIGV8_Proxy *cdata = static_cast<SWIGV8_Proxy *>(v8::External::Unwrap(cdataRef));
#else
SWIGV8_Proxy *cdata = static_cast<SWIGV8_Proxy *>(objRef->GetAlignedPointerFromInternalField(0));
#endif
if(cdata == NULL) {
return SWIG_ERROR;
@ -252,8 +187,13 @@ SWIGRUNTIME int SWIG_V8_ConvertInstancePtr(v8::Handle<v8::Object> objRef, void *
if(!type_valid) {
return SWIG_TypeError;
}
int newmemory = 0;
*ptr = SWIG_TypeCast(tc, cdata->swigCObject, &newmemory);
assert(!newmemory); /* newmemory handling not yet implemented */
} else {
*ptr = cdata->swigCObject;
}
*ptr = cdata->swigCObject;
if(flags & SWIG_POINTER_DISOWN) {
cdata->swigCMemOwn = false;
}
@ -261,39 +201,20 @@ SWIGRUNTIME int SWIG_V8_ConvertInstancePtr(v8::Handle<v8::Object> objRef, void *
}
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(v8::Persistent< v8::Value > object, void *parameter) {
SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Value > object, void *parameter) {
SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy) {
#elif (V8_MAJOR_VERSION-0) < 5
SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &data) {
SWIGV8_Proxy *proxy = data.GetParameter();
#else
SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(const v8::WeakCallbackInfo<SWIGV8_Proxy> &data) {
SWIGV8_Proxy *proxy = data.GetParameter();
#endif
delete proxy;
}
SWIGRUNTIME int SWIG_V8_GetInstancePtr(v8::Handle<v8::Value> valRef, void **ptr) {
SWIGRUNTIME int SWIG_V8_GetInstancePtr(SWIGV8_VALUE valRef, void **ptr) {
if(!valRef->IsObject()) {
return SWIG_TypeError;
}
v8::Handle<v8::Object> objRef = SWIGV8_TO_OBJECT(valRef);
SWIGV8_OBJECT objRef = SWIGV8_OBJECT::Cast(valRef);
if(objRef->InternalFieldCount() < 1) return SWIG_ERROR;
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511)
v8::Handle<v8::Value> cdataRef = objRef->GetInternalField(0);
SWIGV8_Proxy *cdata = static_cast<SWIGV8_Proxy *>(v8::External::Unwrap(cdataRef));
#else
SWIGV8_Proxy *cdata = static_cast<SWIGV8_Proxy *>(objRef->GetAlignedPointerFromInternalField(0));
#endif
if(cdata == NULL) {
return SWIG_ERROR;
@ -304,70 +225,30 @@ SWIGRUNTIME int SWIG_V8_GetInstancePtr(v8::Handle<v8::Value> valRef, void **ptr)
return SWIG_OK;
}
SWIGRUNTIME void SWIGV8_SetPrivateData(v8::Handle<v8::Object> obj, void *ptr, swig_type_info *info, int flags) {
SWIGRUNTIME void SWIGV8_SetPrivateData(SWIGV8_OBJECT obj, void *ptr, swig_type_info *info, int flags) {
SWIGV8_Proxy *cdata = new SWIGV8_Proxy();
cdata->swigCObject = ptr;
cdata->swigCMemOwn = (flags & SWIG_POINTER_OWN) ? 1 : 0;
cdata->info = info;
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511)
obj->SetPointerInInternalField(0, cdata);
#else
obj->SetAlignedPointerInInternalField(0, cdata);
#endif
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
cdata->handle = v8::Persistent<v8::Object>::New(obj);
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
cdata->handle = v8::Persistent<v8::Object>::New(v8::Isolate::GetCurrent(), obj);
#else
cdata->handle.Reset(v8::Isolate::GetCurrent(), obj);
#endif
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
// clientdata must be set for owned data as we need to register the dtor
if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) {
cdata->handle.MakeWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor);
} else {
cdata->handle.MakeWeak(cdata, SWIGV8_Proxy_DefaultDtor);
}
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031918)
if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) {
cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor);
} else {
cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, SWIGV8_Proxy_DefaultDtor);
}
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) {
cdata->handle.MakeWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor);
} else {
cdata->handle.MakeWeak(cdata, SWIGV8_Proxy_DefaultDtor);
}
#elif (V8_MAJOR_VERSION-0) < 5
if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) {
cdata->handle.SetWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor);
} else {
cdata->handle.SetWeak(cdata, SWIGV8_Proxy_DefaultDtor);
}
#else
if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) {
cdata->handle.SetWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor, v8::WeakCallbackType::kParameter);
} else {
cdata->handle.SetWeak(cdata, SWIGV8_Proxy_DefaultDtor, v8::WeakCallbackType::kParameter);
}
#endif
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
cdata->handle.MarkIndependent();
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100)
cdata->handle.MarkIndependent(v8::Isolate::GetCurrent());
#else
#if (SWIG_V8_VERSION < 0x0704)
cdata->handle.MarkIndependent();
// Looks like future versions do not require that anymore:
// https://monorail-prod.appspot.com/p/chromium/issues/detail?id=923361#c11
#endif
}
SWIGRUNTIME int SWIG_V8_ConvertPtr(v8::Handle<v8::Value> valRef, void **ptr, swig_type_info *info, int flags) {
SWIGRUNTIME int SWIG_V8_ConvertPtr(SWIGV8_VALUE valRef, void **ptr, swig_type_info *info, int flags) {
SWIGV8_HANDLESCOPE();
/* special case: JavaScript null => C NULL pointer */
@ -378,31 +259,20 @@ SWIGRUNTIME int SWIG_V8_ConvertPtr(v8::Handle<v8::Value> valRef, void **ptr, swi
if(!valRef->IsObject()) {
return SWIG_TypeError;
}
v8::Handle<v8::Object> objRef = SWIGV8_TO_OBJECT(valRef);
SWIGV8_OBJECT objRef = SWIGV8_OBJECT::Cast(valRef);
return SWIG_V8_ConvertInstancePtr(objRef, ptr, info, flags);
}
SWIGRUNTIME v8::Handle<v8::Value> SWIG_V8_NewPointerObj(void *ptr, swig_type_info *info, int flags) {
SWIGRUNTIME SWIGV8_VALUE SWIG_V8_NewPointerObj(void *ptr, swig_type_info *info, int flags) {
SWIGV8_HANDLESCOPE_ESC();
v8::Handle<v8::FunctionTemplate> class_templ;
SWIGV8_FUNCTION_TEMPLATE class_templ;
if (ptr == NULL) {
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
SWIGV8_ESCAPE(SWIGV8_NULL());
#else
v8::Local<v8::Primitive> result = SWIGV8_NULL();
SWIGV8_ESCAPE(result);
#endif
}
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
if(info->clientdata != 0) {
class_templ = ((SWIGV8_ClientData*) info->clientdata)->class_templ;
} else {
class_templ = SWIGV8_SWIGTYPE_Proxy_class_templ;
}
#else
v8::Isolate *isolate = v8::Isolate::GetCurrent();
if(info->clientdata != 0) {
@ -410,10 +280,9 @@ SWIGRUNTIME v8::Handle<v8::Value> SWIG_V8_NewPointerObj(void *ptr, swig_type_inf
} else {
class_templ = v8::Local<v8::FunctionTemplate>::New(isolate, SWIGV8_SWIGTYPE_Proxy_class_templ);
}
#endif
// v8::Handle<v8::Object> result = class_templ->InstanceTemplate()->NewInstance();
v8::Local<v8::Object> result = class_templ->InstanceTemplate()->NewInstance();
v8::Local<v8::Object> result = class_templ->InstanceTemplate()->NewInstance(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked();
SWIGV8_SetPrivateData(result, ptr, info, flags);
SWIGV8_ESCAPE(result);
@ -433,7 +302,7 @@ SWIGRUNTIME v8::Handle<v8::Value> SWIG_V8_NewPointerObj(void *ptr, swig_type_inf
SWIGRUNTIME SwigV8ReturnValue _SWIGV8_wrap_equals(const SwigV8Arguments &args) {
SWIGV8_HANDLESCOPE();
v8::Handle<v8::Value> jsresult;
SWIGV8_VALUE jsresult;
void *arg1 = (void *) 0 ;
void *arg2 = (void *) 0 ;
bool result;
@ -463,7 +332,7 @@ fail:
SWIGRUNTIME SwigV8ReturnValue _wrap_getCPtr(const SwigV8Arguments &args) {
SWIGV8_HANDLESCOPE();
v8::Handle<v8::Value> jsresult;
SWIGV8_VALUE jsresult;
void *arg1 = (void *) 0 ;
long result;
int res1;
@ -502,37 +371,28 @@ public:
};
SWIGRUNTIMEINLINE
int SwigV8Packed_Check(v8::Handle<v8::Value> valRef) {
int SwigV8Packed_Check(SWIGV8_VALUE valRef) {
SWIGV8_HANDLESCOPE();
v8::Handle<v8::Object> objRef = SWIGV8_TO_OBJECT(valRef);
SWIGV8_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__"));
#else
v8::Local<v8::Private> privateKey = v8::Private::ForApi(v8::Isolate::GetCurrent(), SWIGV8_STRING_NEW("__swig__packed_data__"));
v8::Local<v8::Value> flag;
if (!objRef->GetPrivate(SWIGV8_CURRENT_CONTEXT(), privateKey).ToLocal(&flag))
return false;
#endif
return (flag->IsBoolean() && SWIGV8_BOOLEAN_VALUE(flag));
}
SWIGRUNTIME
swig_type_info *SwigV8Packed_UnpackData(v8::Handle<v8::Value> valRef, void *ptr, size_t size) {
swig_type_info *SwigV8Packed_UnpackData(SWIGV8_VALUE valRef, void *ptr, size_t size) {
if (SwigV8Packed_Check(valRef)) {
SWIGV8_HANDLESCOPE();
SwigV8PackedData *sobj;
v8::Handle<v8::Object> objRef = SWIGV8_TO_OBJECT(valRef);
SWIGV8_OBJECT objRef = SWIGV8_TO_OBJECT(valRef);
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511)
v8::Handle<v8::Value> cdataRef = objRef->GetInternalField(0);
sobj = static_cast<SwigV8PackedData*>(v8::External::Unwrap(cdataRef));
#else
sobj = static_cast<SwigV8PackedData*>(objRef->GetAlignedPointerFromInternalField(0));
#endif
if (sobj == NULL || sobj->size != size) return 0;
memcpy(ptr, sobj->data, size);
return sobj->type;
@ -542,7 +402,7 @@ swig_type_info *SwigV8Packed_UnpackData(v8::Handle<v8::Value> valRef, void *ptr,
}
SWIGRUNTIME
int SWIGV8_ConvertPacked(v8::Handle<v8::Value> valRef, void *ptr, size_t sz, swig_type_info *ty) {
int SWIGV8_ConvertPacked(SWIGV8_VALUE valRef, void *ptr, size_t sz, swig_type_info *ty) {
swig_type_info *to = SwigV8Packed_UnpackData(valRef, ptr, sz);
if (!to) return SWIG_ERROR;
if (ty) {
@ -555,92 +415,36 @@ int SWIGV8_ConvertPacked(v8::Handle<v8::Value> valRef, void *ptr, size_t sz, swi
return SWIG_OK;
}
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
SWIGRUNTIME void _wrap_SwigV8PackedData_delete(v8::Persistent< v8::Value > object, void *parameter) {
SwigV8PackedData *cdata = static_cast<SwigV8PackedData *>(parameter);
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
SWIGRUNTIME void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persistent<v8::Value> object, void *parameter) {
SwigV8PackedData *cdata = static_cast<SwigV8PackedData *>(parameter);
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
SWIGRUNTIME void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persistent<v8::Object> *object, SwigV8PackedData *cdata) {
#elif (V8_MAJOR_VERSION-0) < 5
SWIGRUNTIME void _wrap_SwigV8PackedData_delete(const v8::WeakCallbackData<v8::Object, SwigV8PackedData> &data) {
v8::Local<v8::Object> object = data.GetValue();
SwigV8PackedData *cdata = data.GetParameter();
#else
SWIGRUNTIME void _wrap_SwigV8PackedData_delete(const v8::WeakCallbackInfo<SwigV8PackedData> &data) {
SwigV8PackedData *cdata = data.GetParameter();
#endif
delete cdata;
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
object.Clear();
object.Dispose();
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
object.Clear();
object.Dispose(isolate);
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100)
object->Dispose(isolate);
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
object->Dispose();
#elif (V8_MAJOR_VERSION-0) < 5
object.Clear();
#endif
}
SWIGRUNTIME
v8::Handle<v8::Value> SWIGV8_NewPackedObj(void *data, size_t size, swig_type_info *type) {
SWIGV8_VALUE SWIGV8_NewPackedObj(void *data, size_t size, swig_type_info *type) {
SWIGV8_HANDLESCOPE_ESC();
SwigV8PackedData *cdata = new SwigV8PackedData(data, size, type);
// v8::Handle<v8::Object> obj = SWIGV8_OBJECT_NEW();
v8::Local<v8::Object> obj = SWIGV8_OBJECT_NEW();
#if (V8_MAJOR_VERSION-0) < 5
obj->SetHiddenValue(SWIGV8_STRING_NEW("__swig__packed_data__"), SWIGV8_BOOLEAN_NEW(true));
#else
v8::Local<v8::Private> privateKey = v8::Private::ForApi(v8::Isolate::GetCurrent(), SWIGV8_STRING_NEW("__swig__packed_data__"));
obj->SetPrivate(SWIGV8_CURRENT_CONTEXT(), privateKey, SWIGV8_BOOLEAN_NEW(true));
#endif
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511)
obj->SetPointerInInternalField(0, cdata);
#else
obj->SetAlignedPointerInInternalField(0, cdata);
#endif
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
cdata->handle = v8::Persistent<v8::Object>::New(obj);
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
cdata->handle = v8::Persistent<v8::Object>::New(v8::Isolate::GetCurrent(), obj);
#else
cdata->handle.Reset(v8::Isolate::GetCurrent(), obj);
#endif
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
cdata->handle.MakeWeak(cdata, _wrap_SwigV8PackedData_delete);
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031918)
cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, _wrap_SwigV8PackedData_delete);
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
cdata->handle.MakeWeak(cdata, _wrap_SwigV8PackedData_delete);
#elif (V8_MAJOR_VERSION-0) < 5
cdata->handle.SetWeak(cdata, _wrap_SwigV8PackedData_delete);
// v8::V8::SetWeak(&cdata->handle, cdata, _wrap_SwigV8PackedData_delete);
#else
cdata->handle.SetWeak(cdata, _wrap_SwigV8PackedData_delete, v8::WeakCallbackType::kParameter);
#endif
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
cdata->handle.MarkIndependent();
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100)
cdata->handle.MarkIndependent(v8::Isolate::GetCurrent());
#else
#if (SWIG_V8_VERSION < 0x0704)
cdata->handle.MarkIndependent();
// Looks like future versions do not require that anymore:
// https://monorail-prod.appspot.com/p/chromium/issues/detail?id=923361#c11
#endif
SWIGV8_ESCAPE(obj);
}
#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIGV8_ConvertPacked(obj, ptr, sz, ty)
@ -654,22 +458,18 @@ v8::Handle<v8::Value> SWIGV8_NewPackedObj(void *data, size_t size, swig_type_inf
SWIGRUNTIME
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
v8::Handle<v8::Value> SWIGV8_AppendOutput(v8::Handle<v8::Value> result, v8::Handle<v8::Value> obj) {
#else
v8::Handle<v8::Value> SWIGV8_AppendOutput(v8::Local<v8::Value> result, v8::Handle<v8::Value> obj) {
#endif
SWIGV8_VALUE SWIGV8_AppendOutput(SWIGV8_VALUE result, SWIGV8_VALUE obj) {
SWIGV8_HANDLESCOPE_ESC();
if (result->IsUndefined()) {
result = SWIGV8_ARRAY_NEW();
result = SWIGV8_ARRAY_NEW(0);
} else if (!result->IsArray()) {
SWIGV8_ARRAY tmparr = SWIGV8_ARRAY_NEW(0);
SWIGV8_ARRAY_SET(tmparr, 0, result);
result = tmparr;
}
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
v8::Handle<v8::Array> arr = v8::Handle<v8::Array>::Cast(result);
#else
v8::Local<v8::Array> arr = v8::Local<v8::Array>::Cast(result);
#endif
arr->Set(arr->Length(), obj);
SWIGV8_ARRAY arr = SWIGV8_ARRAY::Cast(result);
SWIGV8_ARRAY_SET(arr, arr->Length(), obj);
SWIGV8_ESCAPE(arr);
}

View file

@ -7,36 +7,8 @@
// ----------------
//
// v8 added version macros V8_MAJOR_VERSION, V8_MINOR_VERSION, V8_BUILD_NUMBER
// and V8_PATCH_LEVEL in version 4.3.0. SWIG generated code uses these if
// they are defined - to support earlier versions you can specify the V8 version
// in use via the command line when you run SWIG:
//
// swig -c++ -javascript -v8 -DV8_VERSION=0x032530 example.i
//
// Or code in the interface file using SWIG_V8_VERSION:
//
// %begin %{#define SWIG_V8_VERSION 0x031110%}
//
// This is specified as a hex constant, but the constant is read as pairs of
// decimal digits, so for V8 3.25.30 use constant 0x032530. This scheme can't
// represent components > 99, but this constant is only useful for V8 < 4.3.0,
// and no V8 versions from that era had a component > 99.
%define %swig_v8_define_version(version)
%insert("runtime") %{
#ifndef SWIG_V8_VERSION
#define SWIG_V8_VERSION version
#endif
%}
%enddef
#ifdef V8_VERSION
%swig_v8_define_version(V8_VERSION)
#else
// HACK: defining a default version
%swig_v8_define_version(0x031110)
#endif
// and V8_PATCH_LEVEL in version 4.3.0. SWIG doesn't support anything that
// old so SWIG generated code can rely on these.
// Node support
// ------------
@ -56,9 +28,16 @@
%insert(runtime) %{
#include <v8.h>
#undef SWIG_V8_VERSION
#define SWIG_V8_VERSION ((V8_MAJOR_VERSION / 10) * 4096 + \
(V8_MAJOR_VERSION % 10) * 256 + \
(V8_MINOR_VERSION / 10) * 16 + \
(V8_MINOR_VERSION % 10))
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <assert.h>
%}
%insert(runtime) "swigrun.swg"; /* SWIG API */

View file

@ -4,13 +4,13 @@
* ------------------------------------------------------------ */
%fragment("SWIG_AsCharPtrAndSize", "header", fragment="SWIG_pchar_descriptor") {
SWIGINTERN int
SWIG_AsCharPtrAndSize(v8::Handle<v8::Value> valRef, char** cptr, size_t* psize, int *alloc)
SWIG_AsCharPtrAndSize(SWIGV8_VALUE valRef, char** cptr, size_t* psize, int *alloc)
{
if(valRef->IsString()) {
v8::Handle<v8::String> js_str = SWIGV8_TO_STRING(valRef);
v8::Local<v8::String> js_str = v8::Local<v8::String>::Cast(valRef);
size_t len = SWIGV8_UTF8_LENGTH(js_str) + 1;
char* cstr = new char[len];
char* cstr = (char*) %new_array(len, char);
SWIGV8_WRITE_UTF8(js_str, cstr, len);
if(alloc) *alloc = SWIG_NEWOBJ;
@ -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 = SWIGV8_TO_OBJECT(valRef);
SWIGV8_OBJECT obj = SWIGV8_OBJECT::Cast(valRef);
// try if the object is a wrapped char[]
swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
if (pchar_descriptor) {
@ -41,7 +41,7 @@ SWIG_AsCharPtrAndSize(v8::Handle<v8::Value> valRef, char** cptr, size_t* psize,
}
%fragment("SWIG_FromCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") {
SWIGINTERNINLINE v8::Handle<v8::Value>
SWIGINTERNINLINE SWIGV8_VALUE
SWIG_FromCharPtrAndSize(const char* carray, size_t size)
{
if (carray) {
@ -49,7 +49,7 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
// TODO: handle extra long strings
return SWIGV8_UNDEFINED();
} else {
v8::Handle<v8::String> js_str = SWIGV8_STRING_NEW2(carray, size);
v8::Local<v8::String> js_str = SWIGV8_STRING_NEW2(carray, size);
return js_str;
}
} else {

View file

@ -25,7 +25,7 @@
/* Javascript types */
#define SWIG_Object v8::Handle<v8::Value>
#define SWIG_Object SWIGV8_VALUE
#define VOID_Object SWIGV8_UNDEFINED()
/* Overload of the output/constant/exception/dirout handling */

View file

@ -18,7 +18,7 @@ you would use a real value instead.
int *INPUT
short *INPUT
long *INPUT
long long *INPUT
long long *INPUT
unsigned int *INPUT
unsigned short *INPUT
unsigned long *INPUT

View file

@ -1344,14 +1344,14 @@ SWIGRUNTIME int SWIG_Lua_resolve_metamethod(lua_State *L); /*forward declaration
/* The real function that resolves a metamethod.
* Function searches given class and all it's bases(recursively) for first instance of something that is
* not equal to SWIG_Lua_resolve_metatmethod. (Almost always this 'something' is actual metamethod implementation
* not equal to SWIG_Lua_resolve_metamethod. (Almost always this 'something' is actual metamethod implementation
* and it is a SWIG-generated C function.). It returns value on the top of the L and there is no garbage below the
* answer.
* Returns 1 if found, 0 otherwise.
* clss is class which metatable we will search for method
* metamethod_name_idx is index in L where metamethod name (as string) lies
* skip_check allows to skip searching metamethod in givel clss and immideatelly go to searching in bases. skip_check
* is not caried to subsequent recursive calls - false is always passed. It is set to true only at first call from
* skip_check allows skipping searching metamethod in the given class and immediately going to searching in bases. skip_check
* is not carried to subsequent recursive calls - false is always passed. It is set to true only at first call from
* SWIG_Lua_resolve_metamethod
* */
SWIGINTERN int SWIG_Lua_do_resolve_metamethod(lua_State *L, const swig_lua_class *clss, int metamethod_name_idx,
@ -1497,7 +1497,7 @@ SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class
}
}
lua_pop(L,1); /* remove inheritable metatmethods table */
lua_pop(L,1); /* remove inheritable metamethods table */
/* Special handling for __tostring method */
lua_pushstring(L, "__tostring");
@ -1765,6 +1765,11 @@ SWIGRUNTIME int SWIG_Lua_ConvertPtr(lua_State *L,int index,void **ptr,swig_type
*ptr=0;
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
}
if (lua_islightuserdata(L,index))
{
*ptr=lua_touserdata(L,index);
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
}
usr=(swig_lua_userdata*)lua_touserdata(L,index); /* get data */
if (usr)
{
@ -1791,7 +1796,7 @@ SWIGRUNTIME int SWIG_Lua_ConvertPtr(lua_State *L,int index,void **ptr,swig_type
SWIGRUNTIME void* SWIG_Lua_MustGetPtr(lua_State *L,int index,swig_type_info *type,int flags,
int argnum,const char *func_name){
void *result;
void *result = 0;
if (!SWIG_IsOK(SWIG_ConvertPtr(L,index,&result,type,flags))){
luaL_error (L,"Error in %s, expected a %s at argument number %d\n",
func_name,(type && type->str)?type->str:"void*",argnum);

View file

@ -39,12 +39,12 @@ $1 = ($type)lua_tonumber(L, $input);%}
// SWIG assumes that this code will need a pointer to int to be passed in
// (this might be ok for objects by const ref, but not for numeric primitives)
// therefore we add a set of typemaps to fix this (for both in & out)
%typemap(in,checkfn="lua_isnumber") const int&($basetype temp)
%{ temp=($basetype)lua_tonumber(L,$input); $1=&temp;%}
%typemap(in,checkfn="lua_isnumber") const int&($*1_ltype temp)
%{ temp=($*1_ltype)lua_tonumber(L,$input); $1=&temp;%}
%typemap(in,checkfn="lua_isnumber") const unsigned int&($basetype temp)
%typemap(in,checkfn="lua_isnumber") const unsigned int&($*1_ltype temp)
%{SWIG_contract_assert((lua_tonumber(L,$input)>=0),"number must not be negative")
temp=($basetype)lua_tonumber(L,$input); $1=&temp;%}
temp=($*1_ltype)lua_tonumber(L,$input); $1=&temp;%}
%typemap(out) const int&, const unsigned int&
%{ lua_pushnumber(L, (lua_Number) *$1); SWIG_arg++;%}
@ -237,13 +237,13 @@ $1=($1_ltype)&temp;%}
// therefore a special wrapping functions SWIG_ConvertMember() & SWIG_NewMemberObj() were written
%typemap(in,checkfn="lua_isuserdata") SWIGTYPE (CLASS::*)
%{
if (!SWIG_IsOK(SWIG_ConvertMember(L,$input,(void*)(&$1),sizeof($type),$descriptor)))
if (!SWIG_IsOK(SWIG_ConvertMember(L,$input,(void*)(&$1),sizeof($1),$descriptor)))
SWIG_fail_ptr("$symname",$argnum,$descriptor);
%}
%typemap(out) SWIGTYPE (CLASS::*)
%{
SWIG_NewMemberObj(L,(void*)(&$1),sizeof($type),$descriptor); SWIG_arg++;
%{
SWIG_NewMemberObj(L,(void*)(&$1),sizeof($1),$descriptor); SWIG_arg++;
%}

View file

@ -9,6 +9,8 @@
#include <math.h>
%}
#ifndef SWIGPHP /* PHP already provides all these functions except fabs() */
extern double cos(double x);
/* Cosine of x */
@ -54,9 +56,6 @@ extern double pow(double x, double y);
extern double sqrt(double x);
/* Square root. x >= 0 */
extern double fabs(double x);
/* Absolute value of x */
extern double ceil(double x);
/* Smallest integer not less than x, as a double */
@ -66,6 +65,13 @@ extern double floor(double x);
extern double fmod(double x, double y);
/* Floating-point remainder of x/y, with the same sign as x. */
#endif
extern double fabs(double x);
/* Absolute value of x */
#ifndef SWIGPHP /* PHP already provides these constants and it's an error to redefine them */
#define M_E 2.7182818284590452354
#define M_LOG2E 1.4426950408889634074
#define M_LOG10E 0.43429448190325182765
@ -80,3 +86,4 @@ extern double fmod(double x, double y);
#define M_SQRT2 1.41421356237309504880
#define M_SQRT1_2 0.70710678118654752440
#endif

View file

@ -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&) }

View file

@ -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

View file

@ -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"

View file

@ -77,7 +77,7 @@ type _value = c_obj
%typemap(out) SWIGTYPE [] {
int i;
CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr");
const CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr");
$result = caml_array_new($1_dim0);
for( i = 0; i < $1_dim0; i++ ) {

View file

@ -62,7 +62,7 @@
#if 0
%typemap(argout) SWIGTYPE & {
CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr");
const CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr");
if( fromval ) {
swig_result =
caml_list_append(swig_result,
@ -75,7 +75,7 @@
}
}
%typemap(argout) SWIGTYPE && {
CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr");
const CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr");
if( fromval ) {
swig_result =
caml_list_append(swig_result,

View file

@ -407,7 +407,7 @@ extern "C" {
CAMLreturn((long)SWIG_Int64_val(SWIG_Field(SWIG_Field(v,0),0)));
case C_enum: {
SWIG_CAMLlocal1(ret);
CAML_VALUE *enum_to_int = caml_named_value(SWIG_MODULE "_enum_to_int");
const CAML_VALUE *enum_to_int = caml_named_value(SWIG_MODULE "_enum_to_int");
if( !name ) caml_failwith( "Not an enum conversion" );
ret = caml_callback2(*enum_to_int,*caml_named_value(name),v);
CAMLreturn(caml_long_val(ret));
@ -451,7 +451,7 @@ extern "C" {
CAMLparam1(v);
void *outptr = NULL;
swig_type_info *outdescr = NULL;
static CAML_VALUE *func_val = NULL;
static const CAML_VALUE *func_val = NULL;
if( v == Val_unit ) {
*out = 0;
@ -574,7 +574,7 @@ extern "C" {
CAMLparam0();
SWIG_CAMLlocal1(result);
CAML_VALUE *fromval = caml_named_value(name);
const CAML_VALUE *fromval = caml_named_value(name);
if (fromval) {
result = caml_callback(*fromval, caml_val_ptr(ptr, descriptor));
} else {

View file

@ -7,8 +7,6 @@
# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG)
#include <exception>
namespace Swig {
class Director {

View file

@ -0,0 +1,2 @@
# see top-level Makefile.in
octheaders.hpp

View file

@ -2,7 +2,7 @@
Defines the As/From conversors for double/float complex, you need to
provide complex Type, the Name you want to use in the conversors,
the complex Constructor method, and the Real and Imag complex
accesor methods.
accessor methods.
See the std_complex.i and ccomplex.i for concrete examples.
*/
@ -73,7 +73,7 @@
int res = SWIG_AddCast(SWIG_AsVal(float)(ov, &d));
if (SWIG_IsOK(res)) {
if (val)
*val = Constructor(d, 0.0);
*val = Constructor(d, 0.0f);
return res;
}
}

View file

@ -11,12 +11,6 @@
* be the case.
* ----------------------------------------------------------------------------- */
%{
#include <climits>
#include <iostream>
%}
#if !defined(SWIG_NO_EXPORT_ITERATOR_METHODS)
# if !defined(SWIG_EXPORT_ITERATOR_METHODS)
# define SWIG_EXPORT_ITERATOR_METHODS SWIG_EXPORT_ITERATOR_METHODS
@ -64,7 +58,6 @@ namespace swig {
%fragment("OctSequence_Base","header",fragment="<stddef.h>")
{
%#include <functional>
namespace std {
template <>
@ -576,8 +569,17 @@ namespace swig {
} else {
return octseq.check() ? SWIG_OK : SWIG_ERROR;
}
} catch (std::exception& e) {
}
%#if SWIG_OCTAVE_PREREQ(6,0,0)
catch (octave::execution_exception& exec) {
}
%#endif
catch (std::exception& e) {
%#if SWIG_OCTAVE_PREREQ(6,0,0)
if (seq) // Know that octave is not in an error state
%#else
if (seq&&!error_state)
%#endif
error("swig type error: %s",e.what());
return SWIG_ERROR;
}

130
Lib/octave/octheaders.hpp Normal file
View file

@ -0,0 +1,130 @@
//
// This header includes all C++ headers required for generated Octave wrapper code.
// Using a single header file allows pre-compilation of Octave headers, as follows:
// * Check out this header file:
// swig -octave -co octheaders.hpp
// * Pre-compile header file into octheaders.hpp.gch:
// g++ -c ... octheaders.hpp
// * Use pre-compiled header file:
// g++ -c -include octheaders.hpp ...
//
#if !defined(_SWIG_OCTAVE_OCTHEADERS_HPP)
#define _SWIG_OCTAVE_OCTHEADERS_HPP
// Required C++ headers
#include <cstdlib>
#include <climits>
#include <iostream>
#include <exception>
#include <functional>
#include <complex>
#include <string>
#include <vector>
#include <map>
// Minimal headers to define Octave version
#include <octave/oct.h>
#include <octave/version.h>
// Macro for enabling features which require Octave version >= major.minor.patch
// - Use (OCTAVE_PATCH_VERSION + 0) to handle both '<digit>' (released) and '<digit>+' (in development) patch numbers
#define SWIG_OCTAVE_PREREQ(major, minor, patch) \
( (OCTAVE_MAJOR_VERSION<<16) + (OCTAVE_MINOR_VERSION<<8) + (OCTAVE_PATCH_VERSION + 0) >= ((major)<<16) + ((minor)<<8) + (patch) )
// Reconstruct Octave major, minor, and patch versions for releases prior to 3.8.1
#if !defined(OCTAVE_MAJOR_VERSION)
# if !defined(OCTAVE_API_VERSION_NUMBER)
// Hack to distinguish between Octave 3.8.0, which removed OCTAVE_API_VERSION_NUMBER but did not yet
// introduce OCTAVE_MAJOR_VERSION, and Octave <= 3.2, which did not define OCTAVE_API_VERSION_NUMBER
# include <octave/ov.h>
# if defined(octave_ov_h)
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 8
# define OCTAVE_PATCH_VERSION 0
# else
// Hack to distinguish between Octave 3.2 and earlier versions, before OCTAVE_API_VERSION_NUMBER existed
# define ComplexLU __ignore
# include <octave/CmplxLU.h>
# undef ComplexLU
# if defined(octave_Complex_LU_h)
// We know only that this version is prior to Octave 3.2, i.e. OCTAVE_API_VERSION_NUMBER < 37
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 1
# define OCTAVE_PATCH_VERSION 99
# else
// OCTAVE_API_VERSION_NUMBER == 37
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 2
# define OCTAVE_PATCH_VERSION 0
# endif // defined(octave_Complex_LU_h)
# endif // defined(octave_ov_h)
// Correlation between Octave API and version numbers extracted from Octave's
// ChangeLogs; version is the *earliest* released Octave with that API number
# elif OCTAVE_API_VERSION_NUMBER >= 48
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 6
# define OCTAVE_PATCH_VERSION 0
# elif OCTAVE_API_VERSION_NUMBER >= 45
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 4
# define OCTAVE_PATCH_VERSION 1
# elif OCTAVE_API_VERSION_NUMBER >= 42
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 3
# define OCTAVE_PATCH_VERSION 54
# elif OCTAVE_API_VERSION_NUMBER >= 41
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 3
# define OCTAVE_PATCH_VERSION 53
# elif OCTAVE_API_VERSION_NUMBER >= 40
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 3
# define OCTAVE_PATCH_VERSION 52
# elif OCTAVE_API_VERSION_NUMBER >= 39
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 3
# define OCTAVE_PATCH_VERSION 51
# else // OCTAVE_API_VERSION_NUMBER == 38
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 3
# define OCTAVE_PATCH_VERSION 50
# endif // !defined(OCTAVE_API_VERSION_NUMBER)
#endif // !defined(OCTAVE_MAJOR_VERSION)
// Required Octave headers
#include <octave/Cell.h>
#include <octave/dynamic-ld.h>
#include <octave/oct-env.h>
#include <octave/oct-map.h>
#include <octave/ov-scalar.h>
#include <octave/ov-fcn-handle.h>
#include <octave/parse.h>
#if SWIG_OCTAVE_PREREQ(4,2,0)
#include <octave/interpreter.h>
#else
#include <octave/toplev.h>
#endif
#include <octave/unwind-prot.h>
#if SWIG_OCTAVE_PREREQ(4,2,0)
#include <octave/call-stack.h>
#endif
#endif // !defined(_SWIG_OCTAVE_OCTHEADERS_HPP)

View file

@ -89,10 +89,6 @@ SWIGRUNTIME void SWIG_Octave_SetModule(void *clientdata, swig_module_info *point
// Runtime API implementation
#include <map>
#include <vector>
#include <string>
typedef octave_value_list(*octave_func) (const octave_value_list &, int);
class octave_swig_type;
@ -175,7 +171,16 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
octave_function* function_value(bool = false) { return this; }
#if SWIG_OCTAVE_PREREQ(6,0,0)
octave_value_list call(octave::tree_evaluator& tw, int nargout = 0, const octave_value_list& args = octave_value_list()) {
return execute(tw,nargout,args);
}
#endif
#if SWIG_OCTAVE_PREREQ(6,0,0)
octave_value_list execute(octave::tree_evaluator& tw, int nargout = 0, const octave_value_list& args = octave_value_list()) {
#else
octave_value_list call(octave::tree_evaluator& tw, int nargout = 0, const octave_value_list& args = octave_value_list()) {
#endif
octave_value_list all_args;
all_args.append(first_args);
all_args.append(args);
@ -203,11 +208,7 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
std::set<std::string> dispatch_classes;
private:
DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
};
DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_swig_bound_func, "octave_swig_bound_func", "octave_swig_bound_func");
#else
#define SWIG_OCTAVE_BOUND_FUNC(func, args) octave_value(func)
#endif
@ -464,10 +465,20 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
// Fill in dim_vector
for (int k=0;k<ndim;k++) {
const octave_value& obj = c(k);
#if SWIG_OCTAVE_PREREQ(6,0,0)
try {
d.elem(k) = obj.int_value();
}
catch (octave::execution_exception& oee) {
// __dims__ should return a cell filled with integers
return dim_vector(1,1);
}
#else
d.elem(k) = obj.int_value();
// __dims__ should return a cell filled with integers
if (error_state) return dim_vector(1,1);
#endif
}
return d;
#if SWIG_OCTAVE_PREREQ(4,4,0)
@ -476,8 +487,18 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
} else if (out.is_matrix_type() || out.is_numeric_type() ) {
#endif
if (out.rows()==1 || out.columns()==1) {
#if SWIG_OCTAVE_PREREQ(6,0,0)
Array<int> a;
try {
a = out.int_vector_value();
}
catch (octave::execution_exception& oee) {
return dim_vector(1,1);
}
#else
Array<int> a = out.int_vector_value();
if (error_state) return dim_vector(1,1);
#endif
dim_vector d;
d.resize(a.numel() < 2 ? 2 : a.numel());
d(0) = d(1) = 1;
@ -507,10 +528,10 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
delete this;
}
long swig_this() const {
size_t swig_this() const {
if (!types.size())
return (long) this;
return (long) types[0].second.ptr;
return (size_t) this;
return (size_t) types[0].second.ptr;
}
const char* help_text() const {
if (!types.size())
@ -639,7 +660,11 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
return true;
}
#if SWIG_OCTAVE_PREREQ(6,0,0)
virtual bool isstruct() const {
#else
virtual bool is_map() const {
#endif
return true;
}
@ -787,7 +812,11 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
return as_value();
}
#if SWIG_OCTAVE_PREREQ(6,0,0)
virtual bool isobject() const {
#else
virtual bool is_object() const {
#endif
return true;
}
@ -882,7 +911,11 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
}
virtual bool load_binary (std::istream& is, bool swap,
oct_mach_info::float_format fmt) {
#if SWIG_OCTAVE_PREREQ(6,0,0)
octave::mach_info::float_format fmt) {
#else
oct_mach_info::float_format fmt) {
#endif
return true;
}
@ -1066,7 +1099,13 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
octave_swig_type *ptr;
public:
octave_swig_ref(octave_swig_type *_ptr = 0)
:ptr(_ptr) { }
:ptr(_ptr)
{
// Ensure type_id() is set correctly
if (t_id == -1) {
t_id = octave_swig_ref::static_type_id();
}
}
~octave_swig_ref()
{ if (ptr) ptr->decref(); }
@ -1086,8 +1125,13 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
bool is_defined() const
{ return ptr->is_defined(); }
#if SWIG_OCTAVE_PREREQ(6,0,0)
virtual bool isstruct() const
{ return ptr->isstruct(); }
#else
virtual bool is_map() const
{ return ptr->is_map(); }
#endif
virtual octave_value subsref(const std::string &ops, const std::list < octave_value_list > &idx)
{ return ptr->subsref(ops, idx); }
@ -1098,9 +1142,9 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
octave_value subsasgn(const std::string &ops, const std::list < octave_value_list > &idx, const octave_value &rhs)
{ return ptr->subsasgn(ops, idx, rhs); }
#if SWIG_OCTAVE_PREREQ(4,2,0)
virtual bool isobject() const
{ return ptr->is_object(); }
#if SWIG_OCTAVE_PREREQ(4,4,0)
virtual bool isobject() const
{ return ptr->isobject(); }
#else
virtual bool is_object() const
{ return ptr->is_object(); }
@ -1149,7 +1193,11 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
{ return ptr->save_binary(os, save_as_floats); }
virtual bool load_binary (std::istream& is, bool swap,
oct_mach_info::float_format fmt)
#if SWIG_OCTAVE_PREREQ(6,0,0)
octave::mach_info::float_format fmt)
#else
oct_mach_info::float_format fmt)
#endif
{ return ptr->load_binary(is, swap, fmt); }
#if defined (HAVE_HDF5)
@ -1185,6 +1233,10 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
#endif
{ return ptr->print(os, pr_as_read_syntax); }
#if SWIG_OCTAVE_PREREQ(4,4,0)
static void set_type_id(int type_id) { t_id=type_id; }
#endif
virtual type_conv_info numeric_conversion_function(void) const {
return octave_base_value::type_conv_info (default_numeric_conversion_function,
octave_scalar::static_type_id ());
@ -1212,8 +1264,13 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
public:
octave_swig_packed(swig_type_info *_type = 0, const void *_buf = 0, size_t _buf_len = 0)
: type(_type), buf((const char*)_buf, (const char*)_buf + _buf_len) {
}
: type(_type), buf((const char*)_buf, (const char*)_buf + _buf_len)
{
// Ensure type_id() is set correctly
if (t_id == -1) {
t_id = octave_swig_packed::static_type_id();
}
}
bool copy(swig_type_info *outtype, void *ptr, size_t sz) const {
if (outtype && outtype != type)
@ -1259,7 +1316,11 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
}
virtual bool load_binary (std::istream& is, bool swap,
oct_mach_info::float_format fmt) {
#if SWIG_OCTAVE_PREREQ(6,0,0)
octave::mach_info::float_format fmt) {
#else
oct_mach_info::float_format fmt) {
#endif
return true;
}
@ -1287,6 +1348,10 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
# endif
#endif
#if SWIG_OCTAVE_PREREQ(4,4,0)
static void set_type_id(int type_id) { t_id=type_id; }
#endif
private:
#if !SWIG_OCTAVE_PREREQ(4,0,0)
DECLARE_OCTAVE_ALLOCATOR;
@ -1509,16 +1574,24 @@ SWIGRUNTIMEINLINE void SWIG_Octave_SetConstant(octave_swig_type *module_ns, cons
}
SWIGRUNTIMEINLINE octave_value SWIG_Octave_GetGlobalValue(std::string name) {
#if SWIG_OCTAVE_PREREQ(6,0,0)
octave::interpreter *interp = octave::interpreter::the_interpreter ();
return interp->global_varval(name);
#else
#if SWIG_OCTAVE_PREREQ(4,4,0)
octave::symbol_table& symtab = octave::interpreter::the_interpreter()->get_symbol_table();
return symtab.global_varval(name);
#else
return get_global_value(name, true);
#endif
#endif
}
SWIGRUNTIME void SWIG_Octave_SetGlobalValue(std::string name, const octave_value& value) {
#if SWIG_OCTAVE_PREREQ(4,4,0)
#if SWIG_OCTAVE_PREREQ(6,0,0)
octave::interpreter *interp = octave::interpreter::the_interpreter ();
interp->global_assign(name, value);
#elif SWIG_OCTAVE_PREREQ(4,4,0)
octave::symbol_table& symtab = octave::interpreter::the_interpreter()->get_symbol_table();
symtab.global_assign(name, value);
#else
@ -1528,10 +1601,20 @@ SWIGRUNTIME void SWIG_Octave_SetGlobalValue(std::string name, const octave_value
SWIGRUNTIME void SWIG_Octave_LinkGlobalValue(std::string name) {
#if SWIG_OCTAVE_PREREQ(4,4,0)
octave::symbol_table& symtab = octave::interpreter::the_interpreter()->get_symbol_table();
octave::symbol_scope symscope = octave::interpreter::the_interpreter()->get_current_scope();
#if SWIG_OCTAVE_PREREQ(6,0,0)
octave::interpreter *interp = octave::interpreter::the_interpreter ();
interp->assign(name, interp->global_varval(name));
octave::tree_evaluator& tree_eval = interp->get_evaluator();
octave::call_stack& callStack = tree_eval.get_call_stack();
std::shared_ptr<octave::stack_frame> stackFrame = callStack.get_current_stack_frame();
octave::symbol_record sym=symscope.lookup_symbol(name);
stackFrame->mark_global(sym);
#else
octave::symbol_table& symtab = octave::interpreter::the_interpreter()->get_symbol_table();
symscope.assign(name, symtab.global_varval(name));
symscope.mark_global(name);
#endif
#else
#if !SWIG_OCTAVE_PREREQ(3,2,0)
link_to_global_variable(curr_sym_tab->lookup(name, true));

View file

@ -1,111 +1,10 @@
#ifdef SWIG_OCTAVE_EXTERNAL_OCTHEADERS
%insert(runtime) %{
#include <cstdlib>
#include <iostream>
#include <octave/oct.h>
#include <octave/version.h>
// Macro for enabling features which require Octave version >= major.minor.patch
// - Use (OCTAVE_PATCH_VERSION + 0) to handle both '<digit>' (released) and '<digit>+' (in development) patch numbers
#define SWIG_OCTAVE_PREREQ(major, minor, patch) \
( (OCTAVE_MAJOR_VERSION<<16) + (OCTAVE_MINOR_VERSION<<8) + (OCTAVE_PATCH_VERSION + 0) >= ((major)<<16) + ((minor)<<8) + (patch) )
// Reconstruct Octave major, minor, and patch versions for releases prior to 3.8.1
#if !defined(OCTAVE_MAJOR_VERSION)
# if !defined(OCTAVE_API_VERSION_NUMBER)
// Hack to distinguish between Octave 3.8.0, which removed OCTAVE_API_VERSION_NUMBER but did not yet
// introduce OCTAVE_MAJOR_VERSION, and Octave <= 3.2, which did not define OCTAVE_API_VERSION_NUMBER
# include <octave/ov.h>
# if defined(octave_ov_h)
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 8
# define OCTAVE_PATCH_VERSION 0
# else
// Hack to distinguish between Octave 3.2 and earlier versions, before OCTAVE_API_VERSION_NUMBER existed
# define ComplexLU __ignore
# include <octave/CmplxLU.h>
# undef ComplexLU
# if defined(octave_Complex_LU_h)
// We know only that this version is prior to Octave 3.2, i.e. OCTAVE_API_VERSION_NUMBER < 37
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 1
# define OCTAVE_PATCH_VERSION 99
# else
// OCTAVE_API_VERSION_NUMBER == 37
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 2
# define OCTAVE_PATCH_VERSION 0
# endif // defined(octave_Complex_LU_h)
# endif // defined(octave_ov_h)
// Correlation between Octave API and version numbers extracted from Octave's
// ChangeLogs; version is the *earliest* released Octave with that API number
# elif OCTAVE_API_VERSION_NUMBER >= 48
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 6
# define OCTAVE_PATCH_VERSION 0
# elif OCTAVE_API_VERSION_NUMBER >= 45
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 4
# define OCTAVE_PATCH_VERSION 1
# elif OCTAVE_API_VERSION_NUMBER >= 42
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 3
# define OCTAVE_PATCH_VERSION 54
# elif OCTAVE_API_VERSION_NUMBER >= 41
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 3
# define OCTAVE_PATCH_VERSION 53
# elif OCTAVE_API_VERSION_NUMBER >= 40
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 3
# define OCTAVE_PATCH_VERSION 52
# elif OCTAVE_API_VERSION_NUMBER >= 39
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 3
# define OCTAVE_PATCH_VERSION 51
# else // OCTAVE_API_VERSION_NUMBER == 38
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 3
# define OCTAVE_PATCH_VERSION 50
# endif // !defined(OCTAVE_API_VERSION_NUMBER)
#endif // !defined(OCTAVE_MAJOR_VERSION)
#include <octave/Cell.h>
#include <octave/dynamic-ld.h>
#include <octave/oct-env.h>
#include <octave/oct-map.h>
#include <octave/ov-scalar.h>
#include <octave/ov-fcn-handle.h>
#include <octave/parse.h>
#if SWIG_OCTAVE_PREREQ(4,2,0)
#include <octave/interpreter.h>
#else
#include <octave/toplev.h>
#endif
#include <octave/unwind-prot.h>
#if SWIG_OCTAVE_PREREQ(4,2,0)
#include <octave/call-stack.h>
#endif
#include "octheaders.hpp"
%}
#else
%insert(runtime) "octheaders.hpp";
#endif
%insert(runtime) "swigrun.swg";
%insert(runtime) "swigerrors.swg";
@ -120,7 +19,8 @@ static bool SWIG_init_user(octave_swig_type* module_ns);
SWIGINTERN bool SWIG_Octave_LoadModule(std::string name) {
bool retn = false;
{
#if SWIG_OCTAVE_PREREQ(4,2,0)
#if SWIG_OCTAVE_PREREQ(6,0,0)
#elif SWIG_OCTAVE_PREREQ(4,2,0)
octave::unwind_protect frame;
frame.protect_var(discard_error_messages); discard_error_messages = true;
frame.protect_var(discard_warning_messages); discard_warning_messages = true;
@ -163,7 +63,8 @@ SWIGINTERN bool SWIG_Octave_LoadModule(std::string name) {
SWIGINTERN bool SWIG_Octave_InstallFunction(octave_function *octloadfcn, std::string name) {
bool retn = false;
{
#if SWIG_OCTAVE_PREREQ(4,2,0)
#if SWIG_OCTAVE_PREREQ(6,0,0)
#elif SWIG_OCTAVE_PREREQ(4,2,0)
octave::unwind_protect frame;
frame.protect_var(discard_error_messages); discard_error_messages = true;
frame.protect_var(discard_warning_messages); discard_warning_messages = true;
@ -315,13 +216,29 @@ DEFUN_DLD( swig_octave_prereq, args, nargout, swig_octave_prereq_usage ) {
return octave_value(prereq);
}
static const char *const swig_exit_usage = "-*- texinfo -*- \n\
@deftypefn {Loadable Function} {} swig_exit([@var{exit_status}])\n\
Exit Octave without performing any memory cleanup.\n\
@end deftypefn";
DEFUN_DLD( swig_exit, args, nargout, swig_exit_usage ) {
if (args.length() > 1) {
error("swig_exit: must be called with at most one arguments");
return octave_value_list();
}
int exit_status = 0;
if (args.length() == 1) {
exit_status = args(0).int_value();
}
::_Exit(exit_status);
return octave_value();
}
static const char *const SWIG_name_usage = "-*- texinfo -*- \n\
@deftypefn {Loadable Module} {} " SWIG_name_d "\n\
Loads the SWIG-generated module `" SWIG_name_d "'.\n\
@end deftypefn";
void __swig_atexit__(void) { ::_Exit(0); }
DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) {
static octave_swig_type* module_ns = 0;
@ -329,14 +246,15 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) {
// workaround to prevent octave seg-faulting on exit: set Octave exit function
// octave_exit to _Exit, which exits immediately without trying to cleanup memory.
// definitely affected version 3.2.*, not sure about 3.3.*, seems to be fixed in
// version 3.4.*, but reappeared in 4.2.*, so turn on for all versions after 3.2.*.
// version 3.4.*, reappeared in 4.2.*, hack not possible in 4.4.* or later due to
// removal of octave_exit, so turn on for all versions between 3.2.*. and 4.4.*.
// can be turned off with macro definition.
#ifndef SWIG_OCTAVE_NO_SEGFAULT_HACK
#if SWIG_OCTAVE_PREREQ(4,4,0)
atexit(__swig_atexit__);
#elif SWIG_OCTAVE_PREREQ(3,2,0)
#if !SWIG_OCTAVE_PREREQ(4,4,0)
#if SWIG_OCTAVE_PREREQ(3,2,0)
octave_exit = ::_Exit;
#endif
#endif
#endif
// check for no input and output args
@ -376,16 +294,14 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) {
string_vector types = typeinfo.installed_type_names();
bool register_octave_swig_ref = true;
bool register_octave_swig_packed = true;
bool register_octave_swig_bound_func = true;
for (int i = 0; i < types.numel(); ++i) {
if (types(i) == octave_swig_ref::static_type_name()) {
register_octave_swig_ref = false;
octave_swig_ref::set_type_id(i);
}
if (types(i) == octave_swig_packed::static_type_name()) {
register_octave_swig_packed = false;
}
if (types(i) == octave_swig_bound_func::static_type_name()) {
register_octave_swig_bound_func = false;
octave_swig_packed::set_type_id(i);
}
}
if (register_octave_swig_ref) {
@ -394,9 +310,6 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) {
if (register_octave_swig_packed) {
octave_swig_packed::register_type();
}
if (register_octave_swig_bound_func) {
octave_swig_bound_func::register_type();
}
}
#else
octave_swig_ref::register_type();
@ -405,7 +318,11 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) {
SWIG_InitializeModule(0);
SWIG_PropagateClientData();
#if SWIG_OCTAVE_PREREQ(4,4,0)
#if SWIG_OCTAVE_PREREQ(6,0,0)
octave::tree_evaluator& tree_eval = octave::interpreter::the_interpreter()->get_evaluator();
octave::call_stack& stack = tree_eval.get_call_stack();
octave_function *me = stack.current_function();
#elif SWIG_OCTAVE_PREREQ(4,4,0)
octave::call_stack& stack = octave::interpreter::the_interpreter()->get_call_stack();
octave_function *me = stack.current();
#else
@ -427,6 +344,9 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) {
if (!SWIG_Octave_InstallFunction(me, "swig_octave_prereq")) {
return octave_value_list();
}
if (!SWIG_Octave_InstallFunction(me, "swig_exit")) {
return octave_value_list();
}
octave_swig_type* cvar_ns=0;
if (std::string(SWIG_global_name) != ".") {

View file

@ -4,10 +4,6 @@
%include <octcomplex.swg>
%{
#include <complex>
%}
namespace std {
%naturalvar complex;
template<typename T> class complex;

View file

@ -56,7 +56,9 @@
%define %set_output(obj) $result = obj; argvi++ %enddef
/* append output */
%define %append_output(obj) if (argvi >= items) EXTEND(sp, argvi+1); %set_output(obj) %enddef
%define %append_output(obj)
if (argvi >= items) EXTEND(sp, argvi+1);
%set_output(obj) %enddef
/* variable output */
%define %set_varoutput(obj) sv_setsv($result,obj) %enddef
@ -95,7 +97,7 @@
"sv_setiv(SvRV($result), PTR2IV(&$1));";
%typemap(varout,type="$1_descriptor") SWIGTYPE (CLASS::*) {
SWIG_MakePackedObj($result, (void *) &$1, sizeof($1_type), $1_descriptor);
SWIG_MakePackedObj($result, (void *) &$1, sizeof($1), $1_descriptor);
}
%typemap(varout) SWIGTYPE *const = SWIGTYPE *;

View file

@ -3,6 +3,58 @@
*
* Typemaps for constants
* ----------------------------------------------------------------------------- */
%typemap(classconsttab) int,
unsigned int,
short,
unsigned short,
long,
unsigned long,
unsigned char,
signed char,
enum SWIGTYPE %{
zend_declare_class_constant_long(SWIG_Php_ce_$class, "$const_name", sizeof("$const_name") - 1, ($1_type)$value);
%}
%typemap(classconsttab) bool %{
zend_declare_class_constant_bool(SWIG_Php_ce_$class, "$const_name", sizeof("$const_name") - 1, ($1_type)$value);
%}
%typemap(classconsttab) float,
double %{
zend_declare_class_constant_double(SWIG_Php_ce_$class, "$const_name", sizeof("$const_name") - 1, $value);
%}
%typemap(classconsttab) char %{
{
char swig_char = $value;
zend_declare_class_constant_stringl(SWIG_Php_ce_$class, "$const_name", sizeof("$const_name") - 1, &swig_char, 1);
}
%}
%typemap(classconsttab) char *,
const char *,
char [],
const char [] %{
zend_declare_class_constant_string(SWIG_Php_ce_$class, "$const_name", sizeof("$const_name") - 1, $value);
%}
// This creates a zend_object to wrap the pointer, and we can't do that
// before the Zend runtime has been initialised so we delay it until
// RINIT. The downside is it then happens for every request.
%typemap(classconsttab,rinit=1) SWIGTYPE *,
SWIGTYPE &,
SWIGTYPE &&,
SWIGTYPE [] %{
{
zval z;
ZVAL_UNDEF(&z);
SWIG_SetPointerZval(&z, (void*)$value, $1_descriptor, 0);
zval_copy_ctor(&z);
zend_declare_class_constant(SWIG_Php_ce_$class, "$const_name", sizeof("$const_name") - 1, &z);
}
%}
%typemap(classconsttab) SWIGTYPE (CLASS::*) "";
%typemap(consttab) int,
unsigned int,
@ -31,11 +83,15 @@
const char []
"SWIG_STRING_CONSTANT($symname, $value);";
%typemap(consttab) SWIGTYPE *,
// This creates a zend_object to wrap the pointer, and we can't do that
// before the Zend runtime has been initialised so we delay it until
// RINIT. The downside is it then happens for every request.
%typemap(consttab,rinit=1) SWIGTYPE *,
SWIGTYPE &,
SWIGTYPE &&,
SWIGTYPE [] {
zend_constant c;
ZVAL_UNDEF(&c.value);
SWIG_SetPointerZval(&c.value, (void*)$value, $1_descriptor, 0);
zval_copy_ctor(&c.value);
c.name = zend_string_init("$symname", sizeof("$symname") - 1, 0);

View file

@ -8,6 +8,8 @@
#ifndef SWIG_DIRECTOR_PHP_HEADER_
#define SWIG_DIRECTOR_PHP_HEADER_
#define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG)
#include <string>
#include <exception>
#include <map>
@ -76,31 +78,39 @@ namespace Swig {
};
class Director {
private:
/* flag indicating whether the object is owned by PHP or C++ */
mutable bool swig_disown_flag;
protected:
// "mutable" so we can get a non-const pointer to it in const methods.
mutable zval swig_self;
typedef std::map<void *, GCItem_var> swig_ownership_map;
mutable swig_ownership_map swig_owner;
public:
Director(zval *self) {
Director(zval *self) : swig_disown_flag(false) {
ZVAL_COPY_VALUE(&swig_self, self);
}
static bool swig_is_overridden_method(const char *cname, const char *lc_fname) {
bool result = false;
~Director() {
if (swig_disown_flag) {
Z_DELREF(swig_self);
}
}
void swig_disown() const {
if (!swig_disown_flag) {
swig_disown_flag = true;
Z_ADDREF(swig_self);
}
}
static bool swig_is_overridden_method(const char *cname, zval *z) {
zend_string * cname_str = zend_string_init(cname, strlen(cname), 0);
zend_class_entry *ce = zend_lookup_class(cname_str);
if (ce) {
zval * mptr = zend_hash_str_find(&ce->function_table, lc_fname, strlen(lc_fname));
if (mptr) {
// common.scope points to zend_class_entry for the declaring class,
// and there's only one of those per class, so we can just use a
// pointer compare here.
result = Z_FUNC_P(mptr)->common.scope != ce;
}
}
zend_string_release(cname_str);
return result;
return ce == Z_OBJCE_P(z);
}
template <typename Type>
@ -109,6 +119,12 @@ namespace Swig {
swig_owner[vptr] = new GCItem_T<Type>(vptr);
}
}
void swig_acquire_ownership_obj(void *vptr, int own) const {
if (vptr && own) {
swig_owner[vptr] = new GCItem_Object(own);
}
}
};
/* base class for director exceptions */
@ -121,8 +137,8 @@ namespace Swig {
swig_msg += " ";
swig_msg += msg;
}
SWIG_ErrorCode() = code;
SWIG_ErrorMsg() = swig_msg.c_str();
// Don't replace an already active PHP exception.
if (!EG(exception)) zend_throw_exception(NULL, swig_msg.c_str(), code);
}
virtual ~DirectorException() throw() {
@ -150,8 +166,7 @@ namespace Swig {
};
/* any php exception that occurs during a director method call */
class DirectorMethodException : public DirectorException
{
class DirectorMethodException : public DirectorException {
public:
DirectorMethodException()
: DirectorException(E_ERROR, "SWIG director method error", NULL) {

View file

@ -3,41 +3,41 @@
you have:
---- geometry.h --------
struct Geometry {
enum GeomType{
POINT,
CIRCLE
};
virtual ~Geometry() {}
struct Geometry {
enum GeomType{
POINT,
CIRCLE
};
virtual ~Geometry() {}
virtual int draw() = 0;
//
// Factory method for all the Geometry objects
//
static Geometry *create(GeomType i);
};
struct Point : Geometry {
int draw() { return 1; }
double width() { return 1.0; }
};
struct Circle : Geometry {
int draw() { return 2; }
double radius() { return 1.5; }
};
static Geometry *create(GeomType i);
};
struct Point : Geometry {
int draw() { return 1; }
double width() { return 1.0; }
};
struct Circle : Geometry {
int draw() { return 2; }
double radius() { return 1.5; }
};
//
// Factory method for all the Geometry objects
//
Geometry *Geometry::create(GeomType type) {
switch (type) {
case POINT: return new Point();
case CIRCLE: return new Circle();
default: return 0;
}
}
switch (type) {
case POINT: return new Point();
case CIRCLE: return new Circle();
default: return 0;
}
}
---- geometry.h --------
@ -57,16 +57,16 @@
NOTES: remember to fully qualify all the type names and don't
use %factory inside a namespace declaration, ie, instead of
namespace Foo {
%factory(Geometry *Geometry::create, Point, Circle);
}
use
%factory(Foo::Geometry *Foo::Geometry::create, Foo::Point, Foo::Circle);
%factory(Foo::Geometry *Foo::Geometry::create, Foo::Point, Foo::Circle);
*/
/* for loop for macro with one argument */
@ -90,13 +90,13 @@
/* for loop for macro with two arguments */
%define %formacro_2(macro,...)%_formacro_2(macro, __VA_ARGS__, __fordone__)%enddef
%define %_factory_dispatch(Type)
%define %_factory_dispatch(Type)
if (!dcast) {
Type *dobj = dynamic_cast<Type *>($1);
if (dobj) {
dcast = 1;
SWIG_SetPointerZval(return_value, SWIG_as_voidptr(dobj),$descriptor(Type *), $owner);
}
SWIG_SetPointerZval(return_value, SWIG_as_voidptr(dobj), $descriptor(Type *), $owner);
}
}%enddef
%define %factory(Method,Types...)
@ -104,6 +104,6 @@ if (!dcast) {
int dcast = 0;
%formacro(%_factory_dispatch, Types)
if (!dcast) {
SWIG_SetPointerZval(return_value, SWIG_as_voidptr($1),$descriptor, $owner);
SWIG_SetPointerZval(return_value, SWIG_as_voidptr($1), $descriptor, $owner);
}
}%enddef

View file

@ -1,293 +0,0 @@
/* -----------------------------------------------------------------------------
* globalvar.i
*
* Global variables - add the variable to PHP
* ----------------------------------------------------------------------------- */
%typemap(varinit) char *
{
zval z_var;
if ($1) {
ZVAL_STRING(&z_var, $1);
} else {
ZVAL_STR(&z_var, ZSTR_EMPTY_ALLOC());
}
zend_hash_str_add(&EG(symbol_table), "$1", sizeof("$1") - 1, &z_var);
}
%typemap(varinit) char []
{
zval z_var;
ZVAL_STRING(&z_var, $1);
zend_hash_str_add(&EG(symbol_table), "$1", sizeof("$1") - 1, &z_var);
}
%typemap(varinit) int,
unsigned int,
unsigned short,
short,
unsigned short,
long,
unsigned long,
signed char,
unsigned char,
enum SWIGTYPE
{
zval z_var;
ZVAL_LONG(&z_var, (long)$1);
zend_hash_str_add(&EG(symbol_table), "$1", sizeof("$1") - 1, &z_var);
}
%typemap(varinit) bool
{
zval z_var;
ZVAL_BOOL(&z_var, ($1)?1:0);
zend_hash_str_add(&EG(symbol_table), "$1", sizeof("$1") - 1, &z_var);
}
%typemap(varinit) float, double
{
zval z_var;
ZVAL_DOUBLE(&z_var, (double)$1);
zend_hash_str_add(&EG(symbol_table), "$1", sizeof("$1") - 1, &z_var);
}
%typemap(varinit) char
{
zval z_var;
char c = $1;
ZVAL_STRINGL(&z_var, &c, 1);
zend_hash_str_add(&EG(symbol_table), "$1", sizeof("$1") - 1, &z_var);
}
%typemap(varinit) SWIGTYPE *, SWIGTYPE []
{
zval z_var;
SWIG_SetPointerZval(&z_var, (void*)$1, $1_descriptor, 0);
zend_hash_str_add(&EG(symbol_table), "$1", sizeof("$1") - 1, &z_var);
}
%typemap(varinit) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&
{
zval z_var;
SWIG_SetPointerZval(&z_var, (void*)&$1, $&1_descriptor, 0);
zend_hash_str_add(&EG(symbol_table), "$1", sizeof("$1") - 1, &z_var);
}
%typemap(varinit) char [ANY]
{
zval z_var;
/* varinit char [ANY] */
ZVAL_STRINGL(&z_var, $1, $1_dim0);
zend_hash_str_add(&EG(symbol_table), "$1", sizeof("$1") - 1, &z_var);
}
%typemap(varinit, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*)
{
zval resource;
void * p = emalloc(sizeof($1));
memcpy(p, &$1, sizeof($1));
ZVAL_RES(&resource, zend_register_resource(p, swig_member_ptr));
zend_hash_str_add(&EG(symbol_table), "$1", sizeof("$1") - 1, &resource);
}
%typemap(varin) int, unsigned int, short, unsigned short, long, unsigned long, signed char, unsigned char, enum SWIGTYPE
{
zval *z_var = zend_hash_str_find(&EG(symbol_table), "$1", sizeof("$1") - 1);
$1 = zval_get_long(z_var);
}
%typemap(varin) bool
{
zval *z_var = zend_hash_str_find(&EG(symbol_table), "$1", sizeof("$1") - 1);
convert_to_boolean(z_var);
$1 = (Z_TYPE_P(z_var) == IS_TRUE);
}
%typemap(varin) double,float
{
zval *z_var = zend_hash_str_find(&EG(symbol_table), "$1", sizeof("$1") - 1);
$1 = zval_get_double(z_var);
}
%typemap(varin) char
{
zval *z_var = zend_hash_str_find(&EG(symbol_table), "$1", sizeof("$1") - 1);
convert_to_string(z_var);
if ($1 != Z_STRVAL_P(z_var)[0]) {
$1 = Z_STRVAL_P(z_var)[0];
}
}
%typemap(varin) char *
{
zval *z_var = zend_hash_str_find(&EG(symbol_table), "$1", sizeof("$1") - 1);
char *s1;
convert_to_string(z_var);
s1 = Z_STRVAL_P(z_var);
if ((s1 == NULL) || ($1 == NULL) || strcmp(s1, $1)) {
if (s1)
$1 = estrdup(s1);
else
$1 = NULL;
}
}
%typemap(varin) SWIGTYPE []
{
if ($1) {
zval *z_var = zend_hash_str_find(&EG(symbol_table), "$1", sizeof("$1") - 1);
SWIG_SetPointerZval(z_var, (void*)$1, $1_descriptor, $owner);
}
}
%typemap(varin) char [ANY]
{
zval **z_var;
char *s1;
zend_hash_str_find(&EG(symbol_table), "$1", sizeof("$1") - 1, (void**)&z_var);
s1 = Z_STRVAL_P(z_var);
if ((s1 == NULL) || ($1 == NULL) || strcmp(s1, $1)) {
if (s1)
strncpy($1, s1, $1_dim0);
}
}
%typemap(varin) SWIGTYPE
{
zval *z_var;
$&1_ltype _temp;
z_var = zend_hash_str_find(&EG(symbol_table), "$1", sizeof("$1") - 1);
if (SWIG_ConvertPtr(z_var, (void**)&_temp, $&1_descriptor, 0) < 0) {
SWIG_PHP_Error(E_ERROR,"Type error in value of $symname. Expected $&1_descriptor");
}
$1 = *($&1_ltype)_temp;
}
%typemap(varin) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&
{
zval *z_var;
$1_ltype _temp;
z_var = zend_hash_str_find(&EG(symbol_table), "$1", sizeof("$1") - 1);
if (SWIG_ConvertPtr(z_var, (void **)&_temp, $1_descriptor, 0) < 0) {
SWIG_PHP_Error(E_ERROR,"Type error in value of $symname. Expected $&1_descriptor");
}
$1 = ($1_ltype)_temp;
}
%typemap(varin, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*)
{
zval *z_var = zend_hash_str_find(&EG(symbol_table), "$1", sizeof("$1") - 1);
void * p = (void*)zend_fetch_resource_ex(z_var, SWIG_MEMBER_PTR, swig_member_ptr);
memcpy(&$1, p, sizeof($1));
}
%typemap(varout) int,
unsigned int,
unsigned short,
short,
long,
unsigned long,
signed char,
unsigned char,
enum SWIGTYPE
{
zval *z_var = zend_hash_str_find(&EG(symbol_table), "$1", sizeof("$1") - 1);
if ($1 != ($1_ltype)Z_LVAL_P(z_var)) {
z_var->value.lval = (long)$1;
}
}
//SAMFIX need to cast zval->type, what if zend-hash_find fails? etc?
%typemap(varout) bool
{
zval *z_var = zend_hash_str_find(&EG(symbol_table), "$1", sizeof("$1") - 1);
if ($1 != ($1_ltype)Z_LVAL_P(z_var)) {
z_var->value.lval = (long)$1;
}
}
%typemap(varout) double, float
{
zval *z_var = zend_hash_str_find(&EG(symbol_table), "$1", sizeof("$1") - 1);
if ($1 != ($1_ltype)Z_DVAL_P(z_var)) {
z_var->value.dval = (double)$1;
}
}
%typemap(varout) char
{
zval *z_var = zend_hash_str_find(&EG(symbol_table), "$1", sizeof("$1") - 1);
char c = $1;
if ($1 != Z_STRVAL_P(z_val)[0]) {
ZVAL_STRING(z_var, &c);
}
}
%typemap(varout) char *
{
zval *z_var = zend_hash_str_find(&EG(symbol_table), "$1", sizeof("$1") - 1);
const char *s1 = Z_STRVAL_P(z_var);
if ((s1 == NULL) || ($1 == NULL) || strcmp(s1, $1)) {
if (s1)
efree(s1);
if ($1) {
(z_var)->value.str.val = estrdup($1);
(z_var)->value.str.len = strlen($1) + 1;
} else {
(z_var)->value.str.val = 0;
(z_var)->value.str.len = 0;
}
}
}
%typemap(varout) SWIGTYPE
{
zval *z_var = zend_hash_str_find(&EG(symbol_table), "$1", sizeof("$1") - 1);
SWIG_SetPointerZval(z_var, (void*)&$1, $&1_descriptor, 0);
}
%typemap(varout) SWIGTYPE []
{
if($1) {
zval *z_var = zend_hash_str_find(&EG(symbol_table), "$1", sizeof("$1") - 1);
SWIG_SetPointerZval(z_var, (void*)$1, $1_descriptor, 0);
}
}
%typemap(varout) char [ANY]
{
zval *z_var = zend_hash_str_find(&EG(symbol_table), "$1", sizeof("$1") - 1);
const char *s1 = Z_STRVAL_P(z_var);
deliberate error cos this code looks bogus to me
if ((s1 == NULL) || strcmp(s1, $1)) {
if ($1) {
(z_var)->value.str.val = estrdup($1);
(z_var)->value.str.len = strlen($1) + 1;
} else {
(z_var)->value.str.val = 0;
(z_var)->value.str.len = 0;
}
}
}
%typemap(varout) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&
{
zval *z_var = zend_hash_str_find(&EG(symbol_table), "$1", sizeof("$1") - 1);
SWIG_SetPointerZval(z_var, (void*)$1, $1_descriptor, 0);
}
%typemap(varout, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*)
{
zval resource;
void * p = emalloc(sizeof($1));
memcpy(p, &$1, sizeof($1));
ZVAL_RES(&resource, zend_register_resource(p, swig_member_ptr));
zend_hash_str_add(&EG(symbol_table), "$1", sizeof("$1") - 1, &resource);
}

View file

@ -10,7 +10,6 @@
%include <phpinit.swg> // PHP initialization routine.
%include <globalvar.i> // Global variables.
%include <const.i>
// use %init %{ "/*code goes here*/ " %}
@ -86,56 +85,74 @@
/* Object passed by value. Convert to a pointer */
%typemap(in) SWIGTYPE ($&1_ltype tmp)
%{
if (SWIG_ConvertPtr(&$input, (void **) &tmp, $&1_descriptor, 0) < 0 || tmp == NULL) {
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor");
}
$1 = *tmp;
if (SWIG_ConvertPtr(&$input, (void **) &tmp, $&1_descriptor, 0) < 0 || tmp == NULL) {
zend_type_error("Expected $&1_descriptor for argument $argnum of $symname");
return;
}
$1 = *tmp;
%}
%typemap(directorout) SWIGTYPE ($&1_ltype tmp)
%{
/* If exit was via exception, PHP NULL is returned so skip the conversion. */
if (!EG(exception)) {
if (SWIG_ConvertPtr($input, (void **) &tmp, $&1_descriptor, 0) < 0 || tmp == NULL)
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor");
$result = *tmp;
}
if (SWIG_ConvertPtr($input, (void **) &tmp, $&1_descriptor, 0) < 0 || tmp == NULL) {
zend_type_error("Expected $&1_descriptor for argument $argnum of $symname");
SWIG_fail;
}
$result = *tmp;
%}
%typemap(in) SWIGTYPE *,
SWIGTYPE []
%{
if (SWIG_ConvertPtr(&$input, (void **) &$1, $1_descriptor, 0) < 0) {
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor");
}
if (SWIG_ConvertPtr(&$input, (void **) &$1, $1_descriptor, 0) < 0) {
zend_type_error("Expected $1_descriptor for argument $argnum of $symname");
return;
}
%}
%typemap(in) SWIGTYPE &
%typemap(directorout) SWIGTYPE * (swig_owntype own),
SWIGTYPE [] (swig_owntype own)
%{
if (SWIG_ConvertPtr(&$input, (void **) &$1, $1_descriptor, 0) < 0 || $1 == NULL) {
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor");
}
if (SWIG_ConvertPtrAndOwn($input, (void **)&$result, $1_descriptor, SWIG_POINTER_DISOWN, &own) < 0) {
zend_type_error("Expected $1_descriptor for argument $argnum of $symname");
SWIG_fail;
}
swig_acquire_ownership_obj((void*)$result, own);
%}
%typemap(in) SWIGTYPE &&
%typemap(in) SWIGTYPE &,
SWIGTYPE &&
%{
if (SWIG_ConvertPtr(&$input, (void **) &$1, $1_descriptor, 0) < 0 || $1 == NULL) {
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor");
}
if (SWIG_ConvertPtr(&$input, (void **) &$1, $1_descriptor, 0) < 0 || $1 == NULL) {
zend_type_error("Expected $1_descriptor for argument $argnum of $symname");
return;
}
%}
%typemap(directorout) SWIGTYPE & ($1_ltype tmp),
SWIGTYPE && ($1_ltype tmp)
%{
if (SWIG_ConvertPtr($input, (void **) &tmp, $1_descriptor, 0) < 0 || tmp == NULL) {
zend_type_error("Expected $1_descriptor for argument $argnum of $symname");
SWIG_fail;
}
$result = tmp;
%}
%typemap(in) SWIGTYPE *const& ($*ltype temp)
%{
if (SWIG_ConvertPtr(&$input, (void **) &temp, $*1_descriptor, 0) < 0) {
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $*1_descriptor");
}
$1 = ($1_ltype)&temp;
if (SWIG_ConvertPtr(&$input, (void **) &temp, $*1_descriptor, 0) < 0) {
zend_type_error("Expected $*1_descriptor for argument $argnum of $symname");
return;
}
$1 = ($1_ltype)&temp;
%}
%typemap(in) SWIGTYPE *DISOWN
%{
if (SWIG_ConvertPtr(&$input, (void **) &$1, $1_descriptor, SWIG_POINTER_DISOWN ) < 0) {
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor");
if (SWIG_ConvertPtr(&$input, (void **) &$1, $1_descriptor, SWIG_POINTER_DISOWN) < 0) {
zend_type_error("Expected $1_descriptor for argument $argnum of $symname");
return;
}
%}
@ -146,17 +163,20 @@
%typemap(in) void *
%{
if (SWIG_ConvertPtr(&$input, (void **) &$1, 0, 0) < 0) {
/* Allow NULL from php for void* */
if (Z_ISNULL($input)) $1=0;
else
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor");
}
if (SWIG_ConvertPtr(&$input, (void **) &$1, 0, 0) < 0) {
/* Allow NULL from php for void* */
if (Z_ISNULL($input)) {
$1=0;
} else {
zend_type_error("Expected $1_descriptor for argument $argnum of $symname");
return;
}
}
%}
/* Special case when void* is passed by reference so it can be made to point
to opaque api structs */
%typemap(in) void ** ($*1_ltype ptr, int force),
%typemap(in, byref=1) void ** ($*1_ltype ptr, int force),
void *& ($*1_ltype ptr, int force)
{
/* If they pass NULL by reference, make it into a void*
@ -165,7 +185,8 @@
/* So... we didn't get a ref or ptr, but we'll accept NULL by reference */
if (!(Z_ISREF($input) && Z_ISNULL_P(Z_REFVAL($input)))) {
/* wasn't a pre/ref/thing, OR anything like an int thing */
SWIG_PHP_Error(E_ERROR, "Type error in argument $arg of $symname.");
zend_throw_exception(zend_ce_type_error, "Type error in argument $arg of $symname", 0);
return;
}
}
force=0;
@ -183,8 +204,8 @@
%typemap(argout) void **,
void *&
%{
if (force$argnum) {
SWIG_SetPointerZval(&$input, (void*) ptr$argnum, $*1_descriptor, 1);
if (force$argnum && Z_ISREF($input)) {
SWIG_SetPointerZval(Z_REFVAL($input), (void*) ptr$argnum, $*1_descriptor, 1);
}
%}
@ -198,7 +219,6 @@
unsigned long,
signed char,
unsigned char,
bool,
size_t
%{
RETVAL_LONG($1);
@ -370,12 +390,12 @@
SWIGTYPE &,
SWIGTYPE &&
%{
SWIG_SetPointerZval(return_value, (void *)$1, $1_descriptor, $owner);
SWIG_SetPointerZval($result, (void *)$1, $1_descriptor, $owner);
%}
%typemap(out) SWIGTYPE *const&
%{
SWIG_SetPointerZval(return_value, (void *)*$1, $*1_descriptor, $owner);
SWIG_SetPointerZval($result, (void *)*$1, $*1_descriptor, $owner);
%}
%typemap(directorin) SWIGTYPE *,
@ -383,19 +403,19 @@
SWIGTYPE &,
SWIGTYPE &&
%{
SWIG_SetPointerZval($input, (void *)&$1, $1_descriptor, ($owner)|2);
SWIG_SetPointerZval($input, (void *)&$1, $1_descriptor, $owner);
%}
%typemap(out, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*)
%typemap(out) SWIGTYPE (CLASS::*)
{
void * p = emalloc(sizeof($1));
memcpy(p, &$1, sizeof($1));
RETVAL_RES(zend_register_resource(p, swig_member_ptr));
SWIG_SetPointerZval($result, (void *)p, $&1_descriptor, 1);
}
%typemap(in, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*)
%typemap(in) SWIGTYPE (CLASS::*)
{
void * p = (void*)zend_fetch_resource_ex(&$input, SWIG_MEMBER_PTR, swig_member_ptr);
void * p = SWIG_Z_FETCH_OBJ_P(&$input)->ptr;
memcpy(&$1, p, sizeof($1));
}
@ -403,33 +423,30 @@
SWIGTYPE &DYNAMIC
{
swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1);
SWIG_SetPointerZval(return_value, (void *)$1, ty, $owner);
SWIG_SetPointerZval($result, (void *)$1, ty, $owner);
}
%typemap(out) SWIGTYPE
{
#ifdef __cplusplus
{
$&1_ltype resultobj = new $1_ltype((const $1_ltype &) $1);
SWIG_SetPointerZval(return_value, (void *)resultobj, $&1_descriptor, 1);
}
#else
{
$&1_ltype resultobj = ($&1_ltype) emalloc(sizeof($1_type));
$&1_ltype resultobj = ($&1_ltype) malloc(sizeof($1_type));
memcpy(resultobj, &$1, sizeof($1_type));
SWIG_SetPointerZval(return_value, (void *)resultobj, $&1_descriptor, 1);
}
#endif
SWIG_SetPointerZval($result, (void *)resultobj, $&1_descriptor, 1);
}
%typemap(directorin) SWIGTYPE
%{
SWIG_SetPointerZval($input, SWIG_as_voidptr(new $1_ltype((const $1_ltype &)$1)), $&1_descriptor, 1|2);
SWIG_SetPointerZval($input, SWIG_as_voidptr(new $1_ltype((const $1_ltype &)$1)), $&1_descriptor, 1);
%}
%typemap(out) void "";
%typemap(out) char [ANY]
{
int len = 0;
size_t len = 0;
while (len < $1_dim0 && $1[len]) ++len;
RETVAL_STRINGL($1, len);
}
@ -465,7 +482,10 @@
%php_typecheck(double,SWIG_TYPECHECK_DOUBLE,IS_DOUBLE)
%php_typecheck(char,SWIG_TYPECHECK_CHAR,IS_STRING)
%typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) char *, char *&, char []
%typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) char *, char *&
" $1 = (Z_TYPE($input) == IS_STRING || Z_TYPE($input) == IS_NULL); "
%typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) char []
" $1 = (Z_TYPE($input) == IS_STRING); "
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE
@ -537,3 +557,6 @@
/* php keywords */
%include <phpkw.swg>
/* PHP known interfaces */
%include <phpinterfaces.i>

View file

@ -7,19 +7,6 @@
%init %{
SWIG_php_minit {
zend_class_entry SWIGUNUSED internal_ce;
SWIG_InitializeModule((void*)&module_number);
%}
%fragment("swig_php_init_member_ptr2", "header") %{
#define SWIG_MEMBER_PTR "CLASS::*"
static void swig_member_ptr_dtor(zend_resource *res) {
efree(res->ptr);
}
static int swig_member_ptr = 0;
%}
%fragment("swig_php_init_member_ptr", "init", fragment="swig_php_init_member_ptr2") %{
swig_member_ptr = zend_register_list_destructors_ex(swig_member_ptr_dtor, NULL, SWIG_MEMBER_PTR, module_number);
%}

62
Lib/php/phpinterfaces.i Normal file
View file

@ -0,0 +1,62 @@
/* -----------------------------------------------------------------------------
* phpinterfaces.i
*
* Define "known" PHP interfaces.
*
* These can be added at MINIT time (which is when PHP loads the extension
* module).
*
* Any interface can be added via phpinterfaces, but looking up the
* zend_class_entry by name has to wait until RINIT time, which means it
* happens for every request.
* ----------------------------------------------------------------------------- */
// Note: Abstract interfaces such as "Traversable" can't be used in
// "implements" so are not relevant here.
%insert(header) %{
#define SWIG_PHP_INTERFACE_Iterator_CE zend_ce_iterator
#define SWIG_PHP_INTERFACE_Iterator_HEADER "zend_interfaces.h"
#define SWIG_PHP_INTERFACE_IteratorAggregate_CE zend_ce_aggregate
#define SWIG_PHP_INTERFACE_IteratorAggregate_HEADER "zend_interfaces.h"
#define SWIG_PHP_INTERFACE_ArrayAccess_CE zend_ce_arrayaccess
#define SWIG_PHP_INTERFACE_ArrayAccess_HEADER "zend_interfaces.h"
#define SWIG_PHP_INTERFACE_Serializable_CE zend_ce_serializable
#define SWIG_PHP_INTERFACE_Serializable_HEADER "zend_interfaces.h"
#define SWIG_PHP_INTERFACE_Countable_CE zend_ce_countable
#define SWIG_PHP_INTERFACE_Countable_HEADER "zend_interfaces.h"
#define SWIG_PHP_INTERFACE_OuterIterator_CE spl_ce_OuterIterator
#define SWIG_PHP_INTERFACE_OuterIterator_HEADER "ext/spl/spl_iterators.h"
#define SWIG_PHP_INTERFACE_RecursiveIterator_CE spl_ce_RecursiveIterator
#define SWIG_PHP_INTERFACE_RecursiveIterator_HEADER "ext/spl/spl_iterators.h"
#define SWIG_PHP_INTERFACE_SeekableIterator_CE spl_ce_SeekableIterator
#define SWIG_PHP_INTERFACE_SeekableIterator_HEADER "ext/spl/spl_iterators.h"
#define SWIG_PHP_INTERFACE_SplObserver_CE spl_ce_SplObserver
#define SWIG_PHP_INTERFACE_SplObserver_HEADER "ext/spl/spl_observer.h"
#define SWIG_PHP_INTERFACE_SplSubject_CE spl_ce_SplSubject
#define SWIG_PHP_INTERFACE_SplSubject_HEADER "ext/spl/spl_observer.h"
#define SWIG_PHP_INTERFACE_DateTimeInterface_CE php_date_get_interface_ce()
#define SWIG_PHP_INTERFACE_DateTimeInterface_HEADER "ext/date/php_date.h"
// The "json" extension needs to be loaded earlier that us for this to work.
#define SWIG_PHP_INTERFACE_JsonSerializable_CE php_json_serializable_ce
#define SWIG_PHP_INTERFACE_JsonSerializable_HEADER "ext/json/php_json.h"
// New in PHP 8.0.
#if PHP_MAJOR_VERSION >= 8
# define SWIG_PHP_INTERFACE_Stringable_CE zend_ce_stringable
# define SWIG_PHP_INTERFACE_Stringable_HEADER "zend_interfaces.h"
#endif
%}

View file

@ -5,6 +5,9 @@
/* Keyword (case insensitive) */
#define PHPKW(x) %keywordwarn("'" `x` "' is a PHP keyword, renaming to 'c_" `x` "'",sourcefmt="%(lower)s",rename="c_%s") `x`
/* Keyword, except ok as a function */
#define PHPKW_ok_as_function(x) %keywordwarn("'" `x` "' is a PHP keyword, renaming to 'c_" `x` "'",%$not %$isfunction,sourcefmt="%(lower)s",rename="c_%s") `x`
/* Class (case insensitive) */
#define PHPCN(x) %keywordwarn("'" `x` "' is a PHP reserved class name, renaming to 'c_" `x` "'",%$isclass,sourcefmt="%(lower)s",rename="c_%s") `x`
@ -55,6 +58,7 @@ PHPKW(endwhile);
PHPKW(extends);
PHPKW(final);
PHPKW(finally);
PHPKW(fn); // as of PHP 7.4
PHPKW(for);
PHPKW(foreach);
PHPKW(function);
@ -65,6 +69,7 @@ PHPKW(implements);
PHPKW(instanceof);
PHPKW(insteadof);
PHPKW(interface);
PHPKW(match); // as of PHP 8.0
PHPKW(namespace);
PHPKW(new);
PHPKW(or);
@ -82,6 +87,11 @@ PHPKW(while);
PHPKW(xor);
PHPKW(yield);
/* PHP 8.1 made `readonly` a keyword, but (unlike any other keyword it seems)
* it may still be used as a function name.
*/
PHPKW_ok_as_function(readonly);
// Compile-time "magic" constants
// From: http://php.net/manual/en/reserved.keywords.php
// also at: http://php.net/manual/en/language.constants.predefined.php
@ -119,6 +129,10 @@ PHPBN2(PHP_SAPI);
PHPBN2(PHP_EOL);
PHPBN2(PHP_INT_MAX);
PHPBN2(PHP_INT_SIZE);
PHPBN2(PHP_FLOAT_DIG); // Since 7.2.0
PHPBN2(PHP_FLOAT_EPSILON); // Since 7.2.0
PHPBN2(PHP_FLOAT_MIN); // Since 7.2.0
PHPBN2(PHP_FLOAT_MAX); // Since 7.2.0
PHPBN2(DEFAULT_INCLUDE_PATH);
PHPBN2(PEAR_INSTALL_DIR);
PHPBN2(PEAR_EXTENSION_DIR);
@ -134,6 +148,7 @@ PHPBN2(PHP_LOCALSTATEDIR);
PHPBN2(PHP_CONFIG_FILE_PATH);
PHPBN2(PHP_CONFIG_FILE_SCAN_DIR);
PHPBN2(PHP_SHLIB_SUFFIX);
PHPBN2(PHP_FD_SETSIZE); // Since 7.1.0
PHPBN2(E_ERROR);
PHPBN2(E_WARNING);
PHPBN2(E_PARSE);
@ -145,6 +160,7 @@ PHPBN2(E_COMPILE_WARNING);
PHPBN2(E_USER_ERROR);
PHPBN2(E_USER_WARNING);
PHPBN2(E_USER_NOTICE);
PHPBN2(E_RECOVERABLE_ERROR);
PHPBN2(E_DEPRECATED);
PHPBN2(E_USER_DEPRECATED);
PHPBN2(E_ALL);
@ -156,6 +172,9 @@ PHPBN2(__COMPILER_HALT_OFFSET__);
PHPBN2(PHP_OUTPUT_HANDLER_START);
PHPBN2(PHP_OUTPUT_HANDLER_CONT);
PHPBN2(PHP_OUTPUT_HANDLER_END);
/* Since 7.4.0 (Microsoft Windows only) */
PHPBN2(PHP_WINDOWS_EVENT_CTRL_C);
PHPBN2(PHP_WINDOWS_EVENT_CTRL_BREAK);
/* These don't actually seem to be set (tested on Linux, I guess they're
* Windows only?) */
PHPBN2(PHP_WINDOWS_NT_DOMAIN_CONTROLLER);
@ -402,21 +421,6 @@ PHPBN2(CURLOPT_TCP_NODELAY);
PHPBN2(CURLOPT_TIMEOUT_MS);
PHPBN2(CURLOPT_CONNECTTIMEOUT_MS);
PHPBN2(GMP_VERSION);
PHPBN2(SWFTEXTFIELD_USEFONT);
PHPBN2(SWFTEXTFIELD_AUTOSIZE);
PHPBN2(SWF_SOUND_NOT_COMPRESSED);
PHPBN2(SWF_SOUND_ADPCM_COMPRESSED);
PHPBN2(SWF_SOUND_MP3_COMPRESSED);
PHPBN2(SWF_SOUND_NOT_COMPRESSED_LE);
PHPBN2(SWF_SOUND_NELLY_COMPRESSED);
PHPBN2(SWF_SOUND_5KHZ);
PHPBN2(SWF_SOUND_11KHZ);
PHPBN2(SWF_SOUND_22KHZ);
PHPBN2(SWF_SOUND_44KHZ);
PHPBN2(SWF_SOUND_8BITS);
PHPBN2(SWF_SOUND_16BITS);
PHPBN2(SWF_SOUND_MONO);
PHPBN2(SWF_SOUND_STEREO);
PHPBN2(OPENSSL_VERSION_NUMBER);
PHPBN2(SNMP_OID_OUTPUT_FULL);
PHPBN2(SNMP_OID_OUTPUT_NUMERIC);
@ -627,27 +631,26 @@ PHPBN2(PGSQL_POLLING_OK);
PHPBN2(PGSQL_POLLING_READING);
PHPBN2(PGSQL_POLLING_WRITING);
/* Class names reserved by PHP (case insensitive) */
/* Class names reserved by PHP. */
/* Check is case insensitive - these *MUST* be listed in lower case here. */
PHPCN(directory);
PHPCN(stdclass);
PHPCN(__php_incomplete_class);
/* Added in PHP5. */
PHPCN(exception);
PHPCN(errorexception);
PHPCN(php_user_filter);
PHPCN(closure);
PHPCN(generator);
PHPCN(self);
PHPCN(static);
PHPCN(parent);
/* http://php.net/manual/en/migration70.incompatible.php#migration70.incompatible.other.classes */
PHPCN(bool); // As of PHP 7.0
PHPCN(int); // As of PHP 7.0
PHPCN(float); // As of PHP 7.0
PHPCN(string); // As of PHP 7.0
PHPCN(NULL); // As of PHP 7.0
PHPCN(TRUE); // As of PHP 7.0
PHPCN(FALSE); // As of PHP 7.0
PHPCN(null); // As of PHP 7.0
PHPCN(true); // As of PHP 7.0
PHPCN(false); // As of PHP 7.0
PHPCN(resource); // As of PHP 7.0 (currently works but reserved)
PHPCN(object); // As of PHP 7.0 (currently works but reserved)
PHPCN(mixed); // As of PHP 7.0 (currently works but reserved)
@ -655,6 +658,14 @@ PHPCN(numeric); // As of PHP 7.0 (currently works but reserved)
/* http://php.net/manual/en/migration71.incompatible.php#migration71.incompatible.invalid-class-names */
PHPCN(iterable); // As of PHP 7.1
PHPCN(void); // As of PHP 7.1
/* Predefined interfaces and classes, introduced in PHP 7.0.0 */
PHPCN(arithmeticerror);
PHPCN(assertionerror);
PHPCN(divisionbyzeroerror);
PHPCN(error);
PHPCN(throwable);
PHPCN(parseerror);
PHPCN(typeerror);
/* From extensions (which of these are actually predefined depends which
* extensions are loaded by default). */
PHPCN(xmlwriter);
@ -866,6 +877,7 @@ PHPFN(unset); // "Language construct"
PHPFN(usort);
#undef PHPKW
#undef PHPKW_ok_as_function
#undef PHPBN1a
#undef PHPBN1b
#undef PHPBN1

View file

@ -2,15 +2,11 @@
%typemap(in, byref=1) TYPE *REF ($*1_ltype tmp),
TYPE &REF ($*1_ltype tmp)
%{
/* First Check for SWIG wrapped type */
if (Z_ISNULL($input)) {
$1 = 0;
} else if (Z_ISREF($input)) {
/* Not swig wrapped type, so we check if it's a PHP reference type */
CONVERT_IN(tmp, $*1_ltype, $input);
$1 = &tmp;
if (Z_ISREF($input)) {
CONVERT_IN(tmp, $*1_ltype, $input);
$1 = &tmp;
} else {
SWIG_PHP_Error(E_ERROR, SWIG_PHP_Arg_Error_Msg($argnum, Expected a reference));
zend_type_error(SWIG_PHP_Arg_Error_Msg($argnum, Expected a reference));
}
%}
%typemap(argout) TYPE *REF,

View file

@ -4,24 +4,23 @@
* PHP runtime library
* ----------------------------------------------------------------------------- */
#define swig_owntype int
#ifdef __cplusplus
extern "C" {
#endif
#include "zend.h"
#include "zend_API.h"
#include "zend_exceptions.h"
#include "php.h"
#if PHP_MAJOR_VERSION != 7
# error These bindings need PHP7 - to generate PHP5 bindings use: SWIG < 4.0.0 and swig -php5
#if PHP_MAJOR_VERSION < 7
# error These bindings need PHP 7 or later - to generate PHP5 bindings use: SWIG < 4.0.0 and swig -php5
#endif
#include "ext/standard/php_string.h"
#include <stdlib.h> /* for abort(), used in generated code. */
#include "zend_inheritance.h"
#include "zend_exceptions.h"
#include "zend_inheritance.h"
/* This indirection is to work around const correctness issues in older PHP.
* FIXME: Remove for PHP7? Or might user code be using it? */
#define SWIG_ZEND_NAMED_FE(ZN, N, A) ZEND_NAMED_FE(ZN, N, A)
#include <stdlib.h> /* for abort(), used in generated code. */
#define SWIG_BOOL_CONSTANT(N, V) REGISTER_BOOL_CONSTANT(#N, V, CONST_CS | CONST_PERSISTENT)
#define SWIG_LONG_CONSTANT(N, V) REGISTER_LONG_CONSTANT(#N, V, CONST_CS | CONST_PERSISTENT)
@ -32,13 +31,27 @@ extern "C" {
REGISTER_STRINGL_CONSTANT(#N, &swig_char, 1, CONST_CS | CONST_PERSISTENT);\
} while (0)
/* ZEND_CONSTANT_SET_FLAGS is new in PHP 7.3. */
/* ZEND_CONSTANT_SET_FLAGS was new in PHP 7.3. */
#ifdef ZEND_CONSTANT_SET_FLAGS
# define SWIG_ZEND_CONSTANT_SET_FLAGS ZEND_CONSTANT_SET_FLAGS
#else
# define SWIG_ZEND_CONSTANT_SET_FLAGS(C, F, N) do { (C)->flags = (F); (C)->module_number = (N); } while (0)
#endif
/* zend_object_alloc was new in PHP 7.3. */
#if PHP_MAJOR_VERSION == 7 && PHP_MINOR_VERSION < 3
static zend_always_inline void *zend_object_alloc(size_t obj_size, zend_class_entry *ce) {
void *obj = emalloc(obj_size + zend_object_properties_size(ce));
memset(obj, 0, obj_size - sizeof(zval));
return obj;
}
#endif
/* ZEND_THIS was new in PHP 7.4. */
#ifndef ZEND_THIS
# define ZEND_THIS &EX(This)
#endif
#ifdef __cplusplus
}
#endif
@ -50,10 +63,10 @@ static int default_error_code = E_ERROR;
#define SWIG_PHP_Arg_Error_Msg(argnum,extramsg) "Error in argument " #argnum " "#extramsg
#define SWIG_PHP_Error(code,msg) do { SWIG_ErrorCode() = code; SWIG_ErrorMsg() = msg; SWIG_fail; } while (0)
#define SWIG_PHP_Error(code,msg) do { zend_throw_exception(NULL, msg, code); SWIG_fail; } while (0)
#define SWIG_contract_assert(expr,msg) \
if (!(expr) ) { zend_printf("Contract Assert Failed %s\n",msg ); } else
do { if (!(expr)) zend_printf("Contract Assert Failed %s\n", msg); } while (0)
/* Standard SWIG API */
#define SWIG_GetModule(clientdata) SWIG_Php_GetModule()
@ -64,164 +77,88 @@ static int default_error_code = E_ERROR;
typedef struct {
void * ptr;
int newobject;
const swig_type_info * type;
zend_object std;
} swig_object_wrapper;
#define SWIG_Z_FETCH_OBJ_P(zv) swig_php_fetch_object(Z_OBJ_P(zv))
static inline
swig_object_wrapper * swig_php_fetch_object(zend_object *obj) {
return (swig_object_wrapper *)((char *)obj - XtOffsetOf(swig_object_wrapper, std));
}
#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a))
static void
SWIG_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject) {
/*
* First test for Null pointers. Return those as PHP native NULL
*/
if (!ptr ) {
// Return PHP NULL for a C/C++ NULL pointer.
if (!ptr) {
ZVAL_NULL(z);
return;
}
if (type->clientdata) {
swig_object_wrapper *value;
if (! (*(int *)(type->clientdata)))
zend_error(E_ERROR, "Type: %s failed to register with zend",type->name);
value=(swig_object_wrapper *)emalloc(sizeof(swig_object_wrapper));
value->ptr=ptr;
value->newobject=(newobject & 1);
if ((newobject & 2) == 0) {
/* Just register the pointer as a resource. */
ZVAL_RES(z, zend_register_resource(value, *(int *)(type->clientdata)));
} else {
/*
* Wrap the resource in an object, the resource will be accessible
* via the "_cPtr" member. This is currently only used by
* directorin typemaps.
*/
zval resource;
zend_class_entry *ce = NULL;
const char *type_name = type->name+3; /* +3 so: _p_Foo -> Foo */
size_t type_name_len;
const char * p;
HashTable * ht;
/* Namespace__Foo -> Foo */
/* FIXME: ugly and goes wrong for classes with __ in their names. */
while ((p = strstr(type_name, "__")) != NULL) {
type_name = p + 2;
}
type_name_len = strlen(type_name);
ZVAL_RES(&resource, zend_register_resource(value, *(int *)(type->clientdata)));
if (SWIG_PREFIX_LEN > 0) {
zend_string * classname = zend_string_alloc(SWIG_PREFIX_LEN + type_name_len, 0);
memcpy(classname->val, SWIG_PREFIX, SWIG_PREFIX_LEN);
memcpy(classname->val + SWIG_PREFIX_LEN, type_name, type_name_len);
ce = zend_lookup_class(classname);
zend_string_release(classname);
} else {
zend_string * classname = zend_string_init(type_name, type_name_len, 0);
ce = zend_lookup_class(classname);
zend_string_release(classname);
}
if (ce == NULL) {
/* class does not exist */
ce = zend_standard_class_def;
}
ALLOC_HASHTABLE(ht);
zend_hash_init(ht, 1, NULL, NULL, 0);
zend_hash_str_update(ht, "_cPtr", sizeof("_cPtr") - 1, &resource);
object_and_properties_init(z, ce, ht);
}
if (!type->clientdata) {
zend_type_error("Type: %s not registered with zend", type->name);
return;
}
zend_error(E_ERROR, "Type: %s not registered with zend",type->name);
{
zend_object *obj;
swig_object_wrapper *value;
if (Z_TYPE_P(z) == IS_OBJECT) {
/* The PHP object is already initialised - this is the case when wrapping
* the return value from a PHP constructor. */
obj = Z_OBJ_P(z);
} else {
zend_class_entry *ce = (zend_class_entry*)(type->clientdata);
obj = ce->create_object(ce);
ZVAL_OBJ(z, obj);
}
value = swig_php_fetch_object(obj);
value->ptr = ptr;
value->newobject = (newobject & 1);
value->type = type;
}
}
/* This pointer conversion routine takes the native pointer p (along with
its type name) and converts it by calling appropriate casting functions
according to ty. The resultant pointer is returned, or NULL is returned
if the pointer can't be cast.
Sadly PHP has no API to find a type name from a type id, only from an
instance of a resource of the type id, so we have to pass type_name as well.
The two functions which might call this are:
SWIG_ConvertResourcePtr which gets the type name from the resource
and the registered zend destructors for which we have one per type each
with the type name hard wired in. */
static void *
SWIG_ConvertResourceData(void * p, const char *type_name, swig_type_info *ty) {
swig_cast_info *tc;
void *result = 0;
if (!ty) {
/* They don't care about the target type, so just pass on the pointer! */
return p;
}
if (! type_name) {
/* can't convert p to ptr type ty if we don't know what type p is */
return NULL;
}
/* convert and cast p from type_name to ptr as ty. */
tc = SWIG_TypeCheck(type_name, ty);
if (tc) {
int newmemory = 0;
result = SWIG_TypeCast(tc, p, &newmemory);
assert(!newmemory); /* newmemory handling not yet implemented */
}
return result;
}
/* This function returns a pointer of type ty by extracting the pointer
and type info from the resource in z. z must be a resource.
If it fails, NULL is returned.
It uses SWIG_ConvertResourceData to do the real work. */
static void *
SWIG_ConvertResourcePtr(zval *z, swig_type_info *ty, int flags) {
swig_object_wrapper *value;
void *p;
const char *type_name;
if (Z_RES_TYPE_P(z) == -1) return NULL;
value = (swig_object_wrapper *) Z_RES_VAL_P(z);
if (flags & SWIG_POINTER_DISOWN) {
value->newobject = 0;
}
p = value->ptr;
type_name=zend_rsrc_list_get_rsrc_type(Z_RES_P(z));
return SWIG_ConvertResourceData(p, type_name, ty);
}
/* We allow passing of a RESOURCE pointing to the object or an OBJECT whose
_cPtr is a resource pointing to the object */
/* We wrap C/C++ pointers as PHP objects. */
static int
SWIG_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags) {
SWIG_ConvertPtrAndOwn(zval *z, void **ptr, swig_type_info *ty, int flags, swig_owntype *own) {
if (own)
*own = 0;
if (z == NULL) {
*ptr = 0;
return 0;
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
}
switch (Z_TYPE_P(z)) {
case IS_OBJECT: {
HashTable * ht = Z_OBJ_HT_P(z)->get_properties(z);
if (ht) {
zval * _cPtr = zend_hash_str_find(ht, "_cPtr", sizeof("_cPtr") - 1);
if (_cPtr) {
if (Z_TYPE_P(_cPtr) == IS_INDIRECT) {
_cPtr = Z_INDIRECT_P(_cPtr);
}
if (Z_TYPE_P(_cPtr) == IS_RESOURCE) {
*ptr = SWIG_ConvertResourcePtr(_cPtr, ty, flags);
return (*ptr == NULL ? -1 : 0);
}
}
swig_object_wrapper *value = SWIG_Z_FETCH_OBJ_P(z);
if (!ty) {
/* They don't care about the target type, so just pass on the pointer! */
*ptr = value->ptr;
} else {
swig_cast_info *tc = SWIG_TypeCheckStruct(value->type, ty);
if (tc) {
int newmemory = 0;
*ptr = SWIG_TypeCast(tc, value->ptr, &newmemory);
if (newmemory == SWIG_CAST_NEW_MEMORY) {
assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
if (own)
*own |= SWIG_CAST_NEW_MEMORY;
}
} else {
*ptr = NULL;
}
}
break;
if (*ptr == NULL) return SWIG_ERROR;
if (flags & SWIG_POINTER_DISOWN) {
value->newobject = 0;
}
return SWIG_OK;
}
case IS_RESOURCE:
*ptr = SWIG_ConvertResourcePtr(z, ty, flags);
return (*ptr == NULL ? -1 : 0);
case IS_NULL:
*ptr = 0;
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
@ -230,6 +167,11 @@ SWIG_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags) {
return -1;
}
static int
SWIG_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags) {
return SWIG_ConvertPtrAndOwn(z, ptr, ty, flags, 0);
}
static const char const_name[] = "swig_runtime_data_type_pointer";
static swig_module_info *SWIG_Php_GetModule() {
zval *pointer = zend_get_constant_str(const_name, sizeof(const_name) - 1);
@ -237,10 +179,31 @@ static swig_module_info *SWIG_Php_GetModule() {
if (Z_TYPE_P(pointer) == IS_LONG) {
return (swig_module_info *) pointer->value.lval;
}
}
}
return NULL;
}
static void SWIG_Php_SetModule(swig_module_info *pointer, int module_number) {
REGISTER_LONG_CONSTANT(const_name, (long) pointer, CONST_CS | CONST_PERSISTENT);
}
/* Common parts of the "create_object" object handler. */
static zend_object *SWIG_Php_do_create_object(zend_class_entry *ce, zend_object_handlers *handlers) {
swig_object_wrapper *obj = (swig_object_wrapper*)zend_object_alloc(sizeof(swig_object_wrapper), ce);
zend_object_std_init(&obj->std, ce);
object_properties_init(&obj->std, ce);
obj->std.handlers = handlers;
obj->newobject = 1;
return &obj->std;
}
/* Common parts of the "free_obj" object handler.
Returns void* pointer if the C/C++ object should be destroyed. */
static void* SWIG_Php_free_obj(zend_object *object) {
if (object) {
swig_object_wrapper *obj = swig_php_fetch_object(object);
zend_object_std_dtor(&obj->std);
if (obj->newobject) return obj->ptr;
}
return NULL;
}

View file

@ -7,4 +7,3 @@
%include <std/std_except.i>
%apply size_t { std::size_t };

View file

@ -35,7 +35,7 @@ namespace std {
map();
map(const map& other);
unsigned int size() const;
void clear();
%extend {

View file

@ -33,10 +33,8 @@ namespace std {
%}
%typemap(directorout) string %{
if (!EG(exception)) {
convert_to_string($input);
$result.assign(Z_STRVAL_P($input), Z_STRLEN_P($input));
}
%}
%typemap(out) string %{
@ -74,12 +72,10 @@ namespace std {
%}
%typemap(directorout) string & ($*1_ltype *temp) %{
if (!EG(exception)) {
convert_to_string($input);
temp = new $*1_ltype(Z_STRVAL_P($input), Z_STRLEN_P($input));
swig_acquire_ownership(temp);
$result = temp;
}
%}
%typemap(argout) string & %{

View file

@ -112,5 +112,3 @@ namespace std {
%define specialize_std_vector(T)
#warning "specialize_std_vector - specialization for type T no longer needed"
%enddef

View file

@ -7,4 +7,3 @@
%include <std_vector.i>
%include <std_map.i>
%include <std_pair.i>

View file

@ -153,6 +153,7 @@ INT_TYPEMAP(long long);
ZVAL_STRING($result, temp);
}
%}
INT_TYPEMAP(unsigned long long);
%typemap(argout,fragment="t_output_helper") unsigned long long *OUTPUT
{
@ -276,7 +277,8 @@ INT_TYPEMAP(unsigned long long);
/* So... we didn't get a ref or ptr, but we'll accept NULL by reference */
if (!(Z_ISREF($input) && Z_ISNULL_P(Z_REFVAL($input)))) {
/* wasn't a pre/ref/thing, OR anything like an int thing */
SWIG_PHP_Error(E_ERROR, "Type error in argument $arg of $symname.");
zend_type_error("Expected reference or NULL for argument $arg of $symname");
return;
}
}
force=0;

View file

@ -17,8 +17,8 @@
errno = 0;
lvar = (t) strtoll(Z_STRVAL(invar), &endptr, 10);
if (*endptr && !errno) break;
/* FALL THRU */
}
/* FALL THRU */
default:
lvar = (t) zval_get_long(&invar);
}
@ -34,8 +34,8 @@
errno = 0;
lvar = (t) strtoull(Z_STRVAL(invar), &endptr, 10);
if (*endptr && !errno) break;
/* FALL THRU */
}
/* FALL THRU */
default:
lvar = (t) zval_get_long(&invar);
}
@ -75,16 +75,21 @@
%}
%typemap(directorout) TYPE
%{
if (!EG(exception)) {
CONVERT_IN($result, $1_ltype, *$input);
}
CONVERT_IN($result, $1_ltype, *$input);
%}
%typemap(directorout) const TYPE & ($*1_ltype temp)
%typemap(directorout) const TYPE &
%{
if (!EG(exception)) {
CONVERT_IN(temp, $*1_ltype, *$input);
$*1_ltype swig_val;
CONVERT_IN(swig_val, $*1_ltype, *$input);
$1_ltype temp = new $*1_ltype(($*1_ltype)swig_val);
swig_acquire_ownership(temp);
$result = temp;
%}
%typemap(directorfree) const TYPE &
%{
if (director) {
director->swig_release_ownership(%as_voidptr($input));
}
$result = &temp;
%}
%enddef

View file

@ -1,326 +0,0 @@
/* -----------------------------------------------------------------------------
* pike.swg
*
* Pike configuration module.
* ----------------------------------------------------------------------------- */
%insert(runtime) "swigrun.swg"; // Common C API type-checking code
%insert(runtime) "pikerun.swg"; // Pike run-time code
%insert(runtime) %{
#ifdef __cplusplus
extern "C" {
#endif
#include <pike/global.h>
#include <pike/module.h>
#include <pike/interpret.h>
#ifdef __cplusplus
}
#endif
%}
/* -----------------------------------------------------------------------------
* standard typemaps
* ----------------------------------------------------------------------------- */
/* --- Input arguments --- */
/* Primitive datatypes. */
%typemap(in, pikedesc="tInt")
int, unsigned int, short, unsigned short,
long, unsigned long, char, signed char, unsigned char,
bool, enum SWIGTYPE, long long, unsigned long long
{
if ($input.type != T_INT)
Pike_error("Bad argument: Expected an integer.\n");
$1 = ($1_ltype) $input.u.integer;
}
%typemap(in, pikedesc="tFloat") float, double {
if ($input.type != T_FLOAT)
Pike_error("Bad argument: Expected a float.\n");
$1 = ($1_ltype) $input.u.float_number;
}
%typemap(in, pikedesc="tStr") char *, char [ANY] {
if ($input.type != T_STRING)
Pike_error("Bad argument: Expected a string.\n");
$1 = ($1_ltype) STR0($input.u.string);
}
/* Pointers, references and arrays */
%typemap(in) SWIGTYPE *,
SWIGTYPE &,
SWIGTYPE &&,
SWIGTYPE []
"SWIG_ConvertPtr($input.u.object, (void **) &$1, $1_descriptor, 1);"
/* Void pointer. Accepts any kind of pointer */
%typemap(in) void * "/* FIXME */";
/* Object passed by value. Convert to a pointer */
%typemap(in) SWIGTYPE ($&1_ltype argp) "/* FIXME */";
/* Pointer to a class member */
%typemap(in) SWIGTYPE (CLASS::*) "/* FIXME */";
/* Const primitive references. Passed by value */
%typemap(in, pikedesc="tInt") const int & (int temp),
const short & (short temp),
const long & (long temp),
const unsigned int & (unsigned int temp),
const unsigned short & (unsigned short temp),
const unsigned long & (unsigned long temp),
const char & (char temp),
const signed char & (signed char temp),
const unsigned char & (unsigned char temp),
const bool & (bool temp),
const long long & ($*1_ltype temp),
const unsigned long long & ($*1_ltype temp),
const enum SWIGTYPE & ($*1_ltype temp),
const enum SWIGTYPE && ($*1_ltype temp)
{
if ($input.type != T_INT)
Pike_error("Bad argument: Expected an integer.\n");
temp = ($*1_ltype) $input.u.integer;
$1 = &temp;
}
%typemap(in, pikedesc="tFloat") const float & (float temp),
const double & (double temp)
{
if ($input.type != T_FLOAT)
Pike_error("Bad argument: Expected a float.\n");
temp = ($*1_ltype) $input.u.float_number;
$1 = &temp;
}
/* -----------------------------------------------------------------------------
* Output Typemaps
* ----------------------------------------------------------------------------- */
%typemap(out, pikedesc="tInt")
int, unsigned int,
short, unsigned short,
long, unsigned long,
char, signed char, unsigned char,
bool, enum SWIGTYPE
"push_int($1);";
%typemap(out, pikedesc="tInt") long long "push_int64($1);";
%typemap(out, pikedesc="tInt") unsigned long long "push_int64($1);";
%typemap(out, pikedesc="tFloat") float, double "push_float($1);";
%typemap(out, pikedesc="tStr") char * "push_text($1);";
/* Pointers, references, and arrays */
%typemap(out, pikedesc="tObj") SWIGTYPE*, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] "push_object(SWIG_NewPointerObj((void *) $1, $1_descriptor, $owner));";
/* Void return value; don't push anything */
%typemap(out, pikedesc="tVoid") void "";
/* Dynamic casts */
%typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC "/* FIXME */";
/* Member pointer */
%typemap(out) SWIGTYPE (CLASS::*) "/* FIXME */";
/* Special typemap for character array return values */
%typemap(out, pikedesc="tStr") char [ANY], const char [ANY] "push_text($1);";
/* Primitive types--return by value */
%typemap(out, pikedesc="tObj") SWIGTYPE
#ifdef __cplusplus
{
$&1_ltype resultptr;
resultptr = new $1_ltype((const $1_ltype &) $1);
push_object(SWIG_NewPointerObj((void *) resultptr, $&1_descriptor, 1));
}
#else
{
$&1_ltype resultptr;
resultptr = ($&1_ltype) malloc(sizeof($1_type));
memmove(resultptr, &$1, sizeof($1_type));
push_object(SWIG_NewPointerObj((void *) resultptr, $&1_descriptor, 1));
}
#endif
/* References to primitive types. Return by value */
%typemap(out, pikedesc="tInt") const int &, const unsigned int &,
const short &, const unsigned short &,
const long &, const unsigned long &,
const char &, const signed char &, const unsigned char &,
const bool &,
const long long &, const unsigned long long &,
const enum SWIGTYPE & ($*1_ltype temp),
const enum SWIGTYPE && ($*1_ltype temp)
"push_int(*($1));";
%typemap(out, pikedesc="tFloat") const float &, const double & "push_float(*($1));";
/************************ Constant Typemaps *****************************/
%typemap(constant)
int, unsigned int,
short, unsigned short,
long, unsigned long,
signed char, unsigned char,
bool, enum SWIGTYPE,
long long, unsigned long long
"add_integer_constant(\"$symname\", $1, 0);";
%typemap(constant) char
"add_integer_constant(\"$symname\", '$1', 0);";
%typemap(constant) long long, unsigned long long
"add_integer_constant(\"$symname\", $1, 0);";
%typemap(constant) float, double
"add_float_constant(\"$symname\", $1, 0);";
%typemap(constant) char *
"add_string_constant(\"$symname\", \"$1\", 0);";
/* ------------------------------------------------------------
* String & length
* ------------------------------------------------------------ */
%typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) {
if ($input.type != T_STRING)
Pike_error("Bad argument: Expected a string.\n");
$1 = ($1_ltype) STR0($input.u.string);
$2 = ($2_ltype) $input.u.string->length;
}
/* ------------------------------------------------------------
* ANSI C typemaps
* ------------------------------------------------------------ */
%typemap(in, pikedesc="tInt") size_t {
if ($input.type != T_INT)
Pike_error("Bad argument: Expected an integer.\n");
$1 = ($1_ltype) $input.u.integer;
}
%typemap(out) size_t = long;
/* ------------------------------------------------------------
* Typechecking rules
* ------------------------------------------------------------ */
%typecheck(SWIG_TYPECHECK_INTEGER)
int, short, long,
unsigned int, unsigned short, unsigned long,
signed char, unsigned char,
long long, unsigned long long,
const int &, const short &, const long &,
const unsigned int &, const unsigned short &, const unsigned long &,
const long long &, const unsigned long long &,
enum SWIGTYPE, enum SWIGTYPE &, SWIGTYPE &&,
bool, const bool &
{
$1 = ($input.type == T_INT) ? 1 : 0;
}
%typecheck(SWIG_TYPECHECK_DOUBLE)
float, double,
const float &, const double &
{
$1 = (($input.type == T_FLOAT) || ($input.type == T_INT)) ? 1 : 0;
}
%typecheck(SWIG_TYPECHECK_CHAR) char {
$1 = ($input.type == T_INT) ? 1 : 0;
}
%typecheck(SWIG_TYPECHECK_STRING) char * {
$1 = ($input.type == T_STRING) ? 1 : 0;
}
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
void *ptr;
if (SWIG_ConvertPtr($input.u.object, (void **) &ptr, $1_descriptor, 0) == -1) {
$1 = 0;
} else {
$1 = 1;
}
}
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE {
void *ptr;
if (SWIG_ConvertPtr($input.u.object, (void **) &ptr, $&1_descriptor, 0) == -1) {
$1 = 0;
} else {
$1 = 1;
}
}
%typecheck(SWIG_TYPECHECK_VOIDPTR) void * {
void *ptr;
if (SWIG_ConvertPtr($input.u.object, (void **) &ptr, 0, 0) == -1) {
$1 = 0;
} else {
$1 = 1;
}
}
/* 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("`+") *::operator+;
%rename("`-") *::operator-;
%rename("`*") *::operator*;
%rename("`/") *::operator/;
%rename("`%") *::operator%;
%rename("`<<") *::operator<<;
%rename("`>>") *::operator>>;
%rename("`&") *::operator&;
%rename("`|") *::operator|;
%rename("`^") *::operator^;
%rename("`~") *::operator~;
%rename("`<") *::operator<;
%rename("`>") *::operator>;
%rename("`==") *::operator==;
/* Special cases */
%rename("`()") *::operator();
#endif
/* ------------------------------------------------------------
* The start of the Pike initialization function
* ------------------------------------------------------------ */
%init "swiginit.swg"
%init %{
#ifdef __cplusplus
extern "C"
#endif
PIKE_MODULE_EXIT {}
#ifdef __cplusplus
extern "C"
#endif
PIKE_MODULE_INIT
{
struct program *pr;
SWIG_InitializeModule(0);
%}
/* pike keywords */
%include <pikekw.swg>

View file

@ -1,55 +0,0 @@
#ifndef PIKE_PIKEKW_SWG_
#define PIKE_PIKEKW_SWG_
/* Warnings for Pike keywords */
#define PIKEKW(x) %namewarn("314: '" #x "' is a pike keyword") #x
/*
from
http://www.http://docs.linux.cz/pike/tutorial_C.html
*/
PIKEKW(array);
PIKEKW(break);
PIKEKW(case);
PIKEKW(catch);
PIKEKW(continue);
PIKEKW(default);
PIKEKW(do);
PIKEKW(else);
PIKEKW(float);
PIKEKW(for);
PIKEKW(foreach);
PIKEKW(function);
PIKEKW(gauge);
PIKEKW(if);
PIKEKW(inherit);
PIKEKW(inline);
PIKEKW(int);
PIKEKW(lambda);
PIKEKW(mapping);
PIKEKW(mixed);
PIKEKW(multiset);
PIKEKW(nomask);
PIKEKW(object);
PIKEKW(predef);
PIKEKW(private);
PIKEKW(program);
PIKEKW(protected);
PIKEKW(public);
PIKEKW(return);
PIKEKW(sscanf);
PIKEKW(static);
PIKEKW(string);
PIKEKW(switch);
PIKEKW(typeof);
PIKEKW(varargs);
PIKEKW(void);
PIKEKW(while);
#undef PIKEKW
#endif //PIKE_PIKEKW_SWG_

View file

@ -1,71 +0,0 @@
/* -----------------------------------------------------------------------------
* pikerun.swg
*
* This file contains the runtime support for Pike modules
* and includes code for managing global variables and pointer
* type checking.
* ----------------------------------------------------------------------------- */
#ifdef __cplusplus
extern "C" {
#endif
#include "pike/object.h"
#include "pike/program.h"
#ifdef __cplusplus
}
#endif
#include <assert.h>
/* Stores information about a wrapped object */
typedef struct swig_object_wrapper {
void *self;
swig_type_info *type;
} swig_object_wrapper;
#ifdef THIS
#undef THIS
#endif
#define THIS (((swig_object_wrapper *) Pike_fp->current_storage)->self)
#define SWIG_ConvertPtr SWIG_Pike_ConvertPtr
#define SWIG_NewPointerObj SWIG_Pike_NewPointerObj
#define SWIG_GetModule(clientdata) SWIG_Pike_GetModule(clientdata)
#define SWIG_SetModule(clientdata, pointer) SWIG_Pike_SetModule(pointer)
/* These need to be filled in before type sharing between modules will work */
static swig_module_info *SWIG_Pike_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
return 0;
}
static void SWIG_Pike_SetModule(swig_module_info *pointer) {
}
/* Convert a pointer value */
static int
SWIG_Pike_ConvertPtr(struct object *obj, void **ptr, swig_type_info *ty, int flags) {
struct program *pr;
swig_cast_info *tc;
swig_object_wrapper *obj_wrapper;
if (ty) {
pr = (struct program *) ty->clientdata;
obj_wrapper = (swig_object_wrapper *) get_storage(obj, pr);
if (obj_wrapper && obj_wrapper->type) {
tc = SWIG_TypeCheckStruct(obj_wrapper->type, ty);
if (tc) {
int newmemory = 0;
*ptr = SWIG_TypeCast(tc, obj_wrapper->self, &newmemory);
assert(!newmemory); /* newmemory handling not yet implemented */
return 0;
}
}
}
return -1;
}
/* Create a new pointer object */
static struct object *
SWIG_Pike_NewPointerObj(void *ptr, swig_type_info *type, int own) {
return 0;
}

View file

@ -1,60 +0,0 @@
/* -----------------------------------------------------------------------------
* std_string.i
*
* SWIG typemaps for std::string
* ----------------------------------------------------------------------------- */
%{
#include <string>
%}
namespace std {
%naturalvar string;
class string;
/* Overloading check */
%typemap(typecheck) string = char *;
%typemap(typecheck) const string & = char *;
%typemap(in, pikedesc="tStr") string {
if ($input.type != T_STRING)
Pike_error("Bad argument: Expected a string.\n");
$1.assign(STR0($input.u.string));
}
%typemap(in, pikedesc="tStr") const string & ($*1_ltype temp) {
if ($input.type != T_STRING)
Pike_error("Bad argument: Expected a string.\n");
temp.assign(STR0($input.u.string));
$1 = &temp;
}
%typemap(out, pikedesc="tStr") string "push_text($1.c_str());";
%typemap(out, pikedesc="tStr") const string & "push_text($1->c_str());";
%typemap(directorin) string, const string &, string & "$1.c_str()";
%typemap(directorin) string *, const string * "$1->c_str()";
%typemap(directorout) string {
if ($input.type == T_STRING)
$result.assign(STR0($input.u.string));
else
throw Swig::DirectorTypeMismatchException("string expected");
}
%typemap(directorout) const string & ($*1_ltype temp) {
if ($input.type == T_STRING) {
temp.assign(STR0($input.u.string));
$result = &temp;
} else {
throw Swig::DirectorTypeMismatchException("string expected");
}
}
}

View file

@ -256,6 +256,12 @@ SwigPyStaticVar_Type(void) {
#if PY_VERSION_HEX >= 0x03040000
0, /* tp_finalize */
#endif
#if PY_VERSION_HEX >= 0x03080000
0, /* tp_vectorcall */
#endif
#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000)
0, /* tp_print */
#endif
#ifdef COUNT_ALLOCS
0, /* tp_allocs */
0, /* tp_frees */
@ -334,6 +340,12 @@ SwigPyObjectType(void) {
#if PY_VERSION_HEX >= 0x03040000
0, /* tp_finalize */
#endif
#if PY_VERSION_HEX >= 0x03080000
0, /* tp_vectorcall */
#endif
#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000)
0, /* tp_print */
#endif
#ifdef COUNT_ALLOCS
0, /* tp_allocs */
0, /* tp_frees */
@ -402,10 +414,10 @@ SwigPyBuiltin_ThisClosure (PyObject *self, void *SWIGUNUSEDPARM(closure)) {
SWIGINTERN void
SwigPyBuiltin_SetMetaType (PyTypeObject *type, PyTypeObject *metatype)
{
#if PY_VERSION_HEX >= 0x03000000
type->ob_base.ob_base.ob_type = metatype;
#if PY_VERSION_HEX >= 0x030900A4
Py_SET_TYPE(type, metatype);
#else
type->ob_type = metatype;
Py_TYPE(type) = metatype;
#endif
}

View file

@ -12,15 +12,16 @@
#include <complex.h>
%}
#define complex _Complex
/* C complex constructor */
#define CCplxConst(r, i) ((r) + I*(i))
%swig_cplxflt_convn(float complex, CCplxConst, creal, cimag);
%swig_cplxdbl_convn(double complex, CCplxConst, creal, cimag);
%swig_cplxdbl_convn(complex, CCplxConst, creal, cimag);
%swig_cplxflt_convn(float _Complex, CCplxConst, creal, cimag);
%swig_cplxdbl_convn(double _Complex, CCplxConst, creal, cimag);
%swig_cplxdbl_convn(_Complex, CCplxConst, creal, cimag);
/* declaring the typemaps */
%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float complex);
%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double complex);
%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex);
%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float _Complex);
%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double _Complex);
%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, _Complex);

View file

@ -33,5 +33,5 @@ SWIGINTERN PyObject *swig_call_defargs(PyObject *self, PyObject *args) {
SWIG_PYTHON_THREAD_END_BLOCK;
return NULL;
}
return PyEval_CallObject(func,parms);
return PyObject_Call(func, parms, NULL);
}

View file

@ -17,13 +17,13 @@
int res; Py_ssize_t size = 0; void *buf = 0;
Py_buffer view;
res = PyObject_GetBuffer($input, &view, PyBUF_WRITABLE);
size = view.len;
buf = view.buf;
PyBuffer_Release(&view);
if (res < 0) {
PyErr_Clear();
%argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
}
size = view.len;
buf = view.buf;
PyBuffer_Release(&view);
$1 = ($1_ltype) buf;
$2 = ($2_ltype) (size/sizeof($*1_type));
}
@ -47,12 +47,12 @@
int res; void *buf = 0;
Py_buffer view;
res = PyObject_GetBuffer($input, &view, PyBUF_WRITABLE);
buf = view.buf;
PyBuffer_Release(&view);
if (res < 0) {
PyErr_Clear();
%argument_fail(res, "(TYPEMAP)", $symname, $argnum);
}
buf = view.buf;
PyBuffer_Release(&view);
$1 = ($1_ltype) buf;
}
%enddef
@ -76,13 +76,13 @@
int res; Py_ssize_t size = 0; const void *buf = 0;
Py_buffer view;
res = PyObject_GetBuffer($input, &view, PyBUF_CONTIG_RO);
size = view.len;
buf = view.buf;
PyBuffer_Release(&view);
if (res < 0) {
PyErr_Clear();
%argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
}
size = view.len;
buf = view.buf;
PyBuffer_Release(&view);
$1 = ($1_ltype) buf;
$2 = ($2_ltype) (size / sizeof($*1_type));
}
@ -108,14 +108,12 @@
int res; const void *buf = 0;
Py_buffer view;
res = PyObject_GetBuffer($input, &view, PyBUF_CONTIG_RO);
buf = view.buf;
PyBuffer_Release(&view);
if (res < 0) {
PyErr_Clear();
%argument_fail(res, "(TYPEMAP)", $symname, $argnum);
}
buf = view.buf;
PyBuffer_Release(&view);
$1 = ($1_ltype) buf;
}
%enddef

View file

@ -65,7 +65,7 @@ SWIG_AsVal(Type)(PyObject *o, Type *val)
float re;
int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re));
if (SWIG_IsOK(res)) {
if (val) *val = Constructor(re, 0.0);
if (val) *val = Constructor(re, 0.0f);
return res;
}
}

View file

@ -52,7 +52,7 @@ namespace swig {
struct container_owner {
// By default, do not add the back-reference (for value types)
// Specialization below will check the reference for pointer types.
static bool back_reference(PyObject* child, PyObject* owner) {
static bool back_reference(PyObject* /*child*/, PyObject* /*owner*/) {
return false;
}
};

View file

@ -95,8 +95,12 @@ SWIG_Python_RaiseOrModifyTypeError(const char *message)
#else
newvalue = PyString_FromFormat("%s\nAdditional information:\n%s", PyString_AsString(value), message);
#endif
Py_XDECREF(value);
PyErr_Restore(type, newvalue, traceback);
if (newvalue) {
Py_XDECREF(value);
PyErr_Restore(type, newvalue, traceback);
} else {
PyErr_Restore(type, value, traceback);
}
} else {
/* Raise TypeError using given message */
PyErr_SetString(PyExc_TypeError, message);

View file

@ -37,15 +37,19 @@
SWIGINTERN char*
SWIG_Python_str_AsChar(PyObject *str)
{
#if PY_VERSION_HEX >= 0x03000000
#if PY_VERSION_HEX >= 0x03030000
return (char *)PyUnicode_AsUTF8(str);
#elif PY_VERSION_HEX >= 0x03000000
char *newstr = 0;
str = PyUnicode_AsUTF8String(str);
if (str) {
char *cstr;
Py_ssize_t len;
PyBytes_AsStringAndSize(str, &cstr, &len);
newstr = (char *) malloc(len+1);
memcpy(newstr, cstr, len+1);
if (PyBytes_AsStringAndSize(str, &cstr, &len) != -1) {
newstr = (char *) malloc(len+1);
if (newstr)
memcpy(newstr, cstr, len+1);
}
Py_XDECREF(str);
}
return newstr;
@ -54,10 +58,10 @@ SWIG_Python_str_AsChar(PyObject *str)
#endif
}
#if PY_VERSION_HEX >= 0x03000000
# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) )
#if PY_VERSION_HEX >= 0x03030000 || PY_VERSION_HEX < 0x03000000
# define SWIG_Python_str_DelForPy3(x)
#else
# define SWIG_Python_str_DelForPy3(x)
# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) )
#endif
@ -75,8 +79,7 @@ SWIG_Python_str_FromChar(const char *c)
# define PyObject_DEL PyObject_Del
#endif
// SWIGPY_USE_CAPSULE is no longer used within SWIG itself, but some user
// interface files check for it.
/* SWIGPY_USE_CAPSULE is no longer used within SWIG itself, but some user interface files check for it. */
# define SWIGPY_USE_CAPSULE
# define SWIGPY_CAPSULE_NAME ("swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME)

View file

@ -30,214 +30,6 @@ SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyO
extern "C" {
#endif
/* Python-specific SWIG API */
#define SWIG_newvarlink() SWIG_Python_newvarlink()
#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr)
#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants)
/* -----------------------------------------------------------------------------
* global variable support code.
* ----------------------------------------------------------------------------- */
typedef struct swig_globalvar {
char *name; /* Name of global variable */
PyObject *(*get_attr)(void); /* Return the current value */
int (*set_attr)(PyObject *); /* Set the value */
struct swig_globalvar *next;
} swig_globalvar;
typedef struct swig_varlinkobject {
PyObject_HEAD
swig_globalvar *vars;
} swig_varlinkobject;
SWIGINTERN PyObject *
swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) {
#if PY_VERSION_HEX >= 0x03000000
return PyUnicode_InternFromString("<Swig global variables>");
#else
return PyString_FromString("<Swig global variables>");
#endif
}
SWIGINTERN PyObject *
swig_varlink_str(swig_varlinkobject *v) {
#if PY_VERSION_HEX >= 0x03000000
PyObject *str = PyUnicode_InternFromString("(");
PyObject *tail;
PyObject *joined;
swig_globalvar *var;
for (var = v->vars; var; var=var->next) {
tail = PyUnicode_FromString(var->name);
joined = PyUnicode_Concat(str, tail);
Py_DecRef(str);
Py_DecRef(tail);
str = joined;
if (var->next) {
tail = PyUnicode_InternFromString(", ");
joined = PyUnicode_Concat(str, tail);
Py_DecRef(str);
Py_DecRef(tail);
str = joined;
}
}
tail = PyUnicode_InternFromString(")");
joined = PyUnicode_Concat(str, tail);
Py_DecRef(str);
Py_DecRef(tail);
str = joined;
#else
PyObject *str = PyString_FromString("(");
swig_globalvar *var;
for (var = v->vars; var; var=var->next) {
PyString_ConcatAndDel(&str,PyString_FromString(var->name));
if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", "));
}
PyString_ConcatAndDel(&str,PyString_FromString(")"));
#endif
return str;
}
SWIGINTERN void
swig_varlink_dealloc(swig_varlinkobject *v) {
swig_globalvar *var = v->vars;
while (var) {
swig_globalvar *n = var->next;
free(var->name);
free(var);
var = n;
}
}
SWIGINTERN PyObject *
swig_varlink_getattr(swig_varlinkobject *v, char *n) {
PyObject *res = NULL;
swig_globalvar *var = v->vars;
while (var) {
if (strcmp(var->name,n) == 0) {
res = (*var->get_attr)();
break;
}
var = var->next;
}
if (res == NULL && !PyErr_Occurred()) {
PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n);
}
return res;
}
SWIGINTERN int
swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
int res = 1;
swig_globalvar *var = v->vars;
while (var) {
if (strcmp(var->name,n) == 0) {
res = (*var->set_attr)(p);
break;
}
var = var->next;
}
if (res == 1 && !PyErr_Occurred()) {
PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n);
}
return res;
}
SWIGINTERN PyTypeObject*
swig_varlink_type(void) {
static char varlink__doc__[] = "Swig var link object";
static PyTypeObject varlink_type;
static int type_init = 0;
if (!type_init) {
const PyTypeObject tmp = {
#if PY_VERSION_HEX >= 0x03000000
PyVarObject_HEAD_INIT(NULL, 0)
#else
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
#endif
"swigvarlink", /* tp_name */
sizeof(swig_varlinkobject), /* tp_basicsize */
0, /* tp_itemsize */
(destructor) swig_varlink_dealloc, /* tp_dealloc */
0, /* tp_print */
(getattrfunc) swig_varlink_getattr, /* tp_getattr */
(setattrfunc) swig_varlink_setattr, /* tp_setattr */
0, /* tp_compare */
(reprfunc) swig_varlink_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
(reprfunc) swig_varlink_str, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
0, /* tp_flags */
varlink__doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
0, /* tp_del */
0, /* tp_version_tag */
#if PY_VERSION_HEX >= 0x03040000
0, /* tp_finalize */
#endif
#ifdef COUNT_ALLOCS
0, /* tp_allocs */
0, /* tp_frees */
0, /* tp_maxalloc */
0, /* tp_prev */
0 /* tp_next */
#endif
};
varlink_type = tmp;
type_init = 1;
if (PyType_Ready(&varlink_type) < 0)
return NULL;
}
return &varlink_type;
}
/* Create a variable linking object for use later */
SWIGINTERN PyObject *
SWIG_Python_newvarlink(void) {
swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type());
if (result) {
result->vars = 0;
}
return ((PyObject*) result);
}
SWIGINTERN void
SWIG_Python_addvarlink(PyObject *p, const char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
swig_varlinkobject *v = (swig_varlinkobject *) p;
swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
if (gv) {
size_t size = strlen(name)+1;
gv->name = (char *)malloc(size);
if (gv->name) {
memcpy(gv->name, name, size);
gv->get_attr = get_attr;
gv->set_attr = set_attr;
gv->next = v->vars;
}
}
v->vars = gv;
}
SWIGINTERN PyObject *
SWIG_globals(void) {
static PyObject *globals = 0;
if (!globals) {
globals = SWIG_newvarlink();
}
return globals;
}
/* -----------------------------------------------------------------------------
* constants/methods manipulation
* ----------------------------------------------------------------------------- */
@ -266,15 +58,12 @@ SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
}
}
/* -----------------------------------------------------------------------------*/
/* Fix SwigMethods to carry the callback ptrs when needed */
/* -----------------------------------------------------------------------------*/
/* -----------------------------------------------------------------------------
* Patch %callback methods' docstrings to hold the callback ptrs
* -----------------------------------------------------------------------------*/
SWIGINTERN void
SWIG_Python_FixMethods(PyMethodDef *methods,
swig_const_info *const_table,
swig_type_info **types,
swig_type_info **types_initial) {
SWIG_Python_FixMethods(PyMethodDef *methods, const swig_const_info *const_table, swig_type_info **types, swig_type_info **types_initial) {
size_t i;
for (i = 0; methods[i].ml_name; ++i) {
const char *c = methods[i].ml_doc;
@ -282,7 +71,7 @@ SWIG_Python_FixMethods(PyMethodDef *methods,
c = strstr(c, "swig_ptr: ");
if (c) {
int j;
swig_const_info *ci = 0;
const swig_const_info *ci = 0;
const char *name = c + 10;
for (j = 0; const_table[j].type; ++j) {
if (strncmp(const_table[j].name, name,

View file

@ -127,7 +127,12 @@ SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
if (!PyList_Check(result)) {
PyObject *o2 = result;
result = PyList_New(1);
PyList_SetItem(result, 0, o2);
if (result) {
PyList_SET_ITEM(result, 0, o2);
} else {
Py_DECREF(obj);
return o2;
}
}
PyList_Append(result,obj);
Py_DECREF(obj);
@ -183,6 +188,19 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
}
}
SWIGINTERN int
SWIG_Python_CheckNoKeywords(PyObject *kwargs, const char *name) {
int no_kwargs = 1;
if (kwargs) {
assert(PyDict_Check(kwargs));
if (PyDict_Size(kwargs) > 0) {
PyErr_Format(PyExc_TypeError, "%s() does not take keyword arguments", name);
no_kwargs = 0;
}
}
return no_kwargs;
}
/* A functor is a function object with one single object argument */
#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL);
@ -196,6 +214,230 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Python-specific SWIG API */
#define SWIG_newvarlink() SWIG_Python_newvarlink()
#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr)
#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants)
/* -----------------------------------------------------------------------------
* global variable support code.
* ----------------------------------------------------------------------------- */
typedef struct swig_globalvar {
char *name; /* Name of global variable */
PyObject *(*get_attr)(void); /* Return the current value */
int (*set_attr)(PyObject *); /* Set the value */
struct swig_globalvar *next;
} swig_globalvar;
typedef struct swig_varlinkobject {
PyObject_HEAD
swig_globalvar *vars;
} swig_varlinkobject;
SWIGINTERN PyObject *
swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) {
#if PY_VERSION_HEX >= 0x03000000
return PyUnicode_InternFromString("<Swig global variables>");
#else
return PyString_FromString("<Swig global variables>");
#endif
}
SWIGINTERN PyObject *
swig_varlink_str(swig_varlinkobject *v) {
#if PY_VERSION_HEX >= 0x03000000
PyObject *str = PyUnicode_InternFromString("(");
PyObject *tail;
PyObject *joined;
swig_globalvar *var;
for (var = v->vars; var; var=var->next) {
tail = PyUnicode_FromString(var->name);
joined = PyUnicode_Concat(str, tail);
Py_DecRef(str);
Py_DecRef(tail);
str = joined;
if (var->next) {
tail = PyUnicode_InternFromString(", ");
joined = PyUnicode_Concat(str, tail);
Py_DecRef(str);
Py_DecRef(tail);
str = joined;
}
}
tail = PyUnicode_InternFromString(")");
joined = PyUnicode_Concat(str, tail);
Py_DecRef(str);
Py_DecRef(tail);
str = joined;
#else
PyObject *str = PyString_FromString("(");
swig_globalvar *var;
for (var = v->vars; var; var=var->next) {
PyString_ConcatAndDel(&str,PyString_FromString(var->name));
if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", "));
}
PyString_ConcatAndDel(&str,PyString_FromString(")"));
#endif
return str;
}
SWIGINTERN void
swig_varlink_dealloc(swig_varlinkobject *v) {
swig_globalvar *var = v->vars;
while (var) {
swig_globalvar *n = var->next;
free(var->name);
free(var);
var = n;
}
}
SWIGINTERN PyObject *
swig_varlink_getattr(swig_varlinkobject *v, char *n) {
PyObject *res = NULL;
swig_globalvar *var = v->vars;
while (var) {
if (strcmp(var->name,n) == 0) {
res = (*var->get_attr)();
break;
}
var = var->next;
}
if (res == NULL && !PyErr_Occurred()) {
PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n);
}
return res;
}
SWIGINTERN int
swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
int res = 1;
swig_globalvar *var = v->vars;
while (var) {
if (strcmp(var->name,n) == 0) {
res = (*var->set_attr)(p);
break;
}
var = var->next;
}
if (res == 1 && !PyErr_Occurred()) {
PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n);
}
return res;
}
SWIGINTERN PyTypeObject*
swig_varlink_type(void) {
static char varlink__doc__[] = "Swig var link object";
static PyTypeObject varlink_type;
static int type_init = 0;
if (!type_init) {
const PyTypeObject tmp = {
#if PY_VERSION_HEX >= 0x03000000
PyVarObject_HEAD_INIT(NULL, 0)
#else
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
#endif
"swigvarlink", /* tp_name */
sizeof(swig_varlinkobject), /* tp_basicsize */
0, /* tp_itemsize */
(destructor) swig_varlink_dealloc, /* tp_dealloc */
0, /* tp_print */
(getattrfunc) swig_varlink_getattr, /* tp_getattr */
(setattrfunc) swig_varlink_setattr, /* tp_setattr */
0, /* tp_compare */
(reprfunc) swig_varlink_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
(reprfunc) swig_varlink_str, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
0, /* tp_flags */
varlink__doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
0, /* tp_del */
0, /* tp_version_tag */
#if PY_VERSION_HEX >= 0x03040000
0, /* tp_finalize */
#endif
#if PY_VERSION_HEX >= 0x03080000
0, /* tp_vectorcall */
#endif
#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000)
0, /* tp_print */
#endif
#ifdef COUNT_ALLOCS
0, /* tp_allocs */
0, /* tp_frees */
0, /* tp_maxalloc */
0, /* tp_prev */
0 /* tp_next */
#endif
};
varlink_type = tmp;
type_init = 1;
if (PyType_Ready(&varlink_type) < 0)
return NULL;
}
return &varlink_type;
}
/* Create a variable linking object for use later */
SWIGINTERN PyObject *
SWIG_Python_newvarlink(void) {
swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type());
if (result) {
result->vars = 0;
}
return ((PyObject*) result);
}
SWIGINTERN void
SWIG_Python_addvarlink(PyObject *p, const char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
swig_varlinkobject *v = (swig_varlinkobject *) p;
swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
if (gv) {
size_t size = strlen(name)+1;
gv->name = (char *)malloc(size);
if (gv->name) {
memcpy(gv->name, name, size);
gv->get_attr = get_attr;
gv->set_attr = set_attr;
gv->next = v->vars;
}
}
v->vars = gv;
}
static PyObject *Swig_Globals_global = NULL;
SWIGINTERN PyObject *
SWIG_globals(void) {
if (Swig_Globals_global == NULL) {
Swig_Globals_global = SWIG_newvarlink();
}
return Swig_Globals_global;
}
#ifdef __cplusplus
}
#endif
/* -----------------------------------------------------------------------------
* Pointer declarations
* ----------------------------------------------------------------------------- */
@ -266,18 +508,25 @@ SwigPyClientData_New(PyObject* obj)
/* the newraw method and newargs arguments used to create a new raw instance */
if (PyClass_Check(obj)) {
data->newraw = 0;
data->newargs = obj;
Py_INCREF(obj);
data->newargs = obj;
} else {
data->newraw = PyObject_GetAttrString(data->klass, "__new__");
if (data->newraw) {
Py_INCREF(data->newraw);
data->newargs = PyTuple_New(1);
PyTuple_SetItem(data->newargs, 0, obj);
data->newargs = PyTuple_New(1);
if (data->newargs) {
Py_INCREF(obj);
PyTuple_SET_ITEM(data->newargs, 0, obj);
} else {
Py_DECREF(data->newraw);
Py_DECREF(data->klass);
free(data);
return 0;
}
} else {
data->newargs = obj;
Py_INCREF(obj);
data->newargs = obj;
}
Py_INCREF(data->newargs);
}
/* the destroy method, aka as the C++ delete method */
data->destroy = PyObject_GetAttrString(data->klass, "__swig_destroy__");
@ -286,10 +535,7 @@ SwigPyClientData_New(PyObject* obj)
data->destroy = 0;
}
if (data->destroy) {
int flags;
Py_INCREF(data->destroy);
flags = PyCFunction_GET_FLAGS(data->destroy);
data->delargs = !(flags & (METH_O));
data->delargs = !(PyCFunction_GET_FLAGS(data->destroy) & METH_O);
} else {
data->delargs = 0;
}
@ -300,10 +546,13 @@ SwigPyClientData_New(PyObject* obj)
}
SWIGRUNTIME void
SwigPyClientData_Del(SwigPyClientData *data) {
SwigPyClientData_Del(SwigPyClientData *data)
{
Py_XDECREF(data->klass);
Py_XDECREF(data->newraw);
Py_XDECREF(data->newargs);
Py_XDECREF(data->destroy);
free(data);
}
/* =============== SwigPyObject =====================*/
@ -330,7 +579,7 @@ SwigPyObject_get___dict__(PyObject *v, PyObject *SWIGUNUSEDPARM(args))
if (!sobj->dict)
sobj->dict = PyDict_New();
Py_INCREF(sobj->dict);
Py_XINCREF(sobj->dict);
return sobj->dict;
}
@ -348,18 +597,21 @@ SwigPyObject_format(const char* fmt, SwigPyObject *v)
PyObject *res = NULL;
PyObject *args = PyTuple_New(1);
if (args) {
if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) {
PyObject *ofmt = SWIG_Python_str_FromChar(fmt);
PyObject *val = SwigPyObject_long(v);
if (val) {
PyObject *ofmt;
PyTuple_SET_ITEM(args, 0, val);
ofmt = SWIG_Python_str_FromChar(fmt);
if (ofmt) {
#if PY_VERSION_HEX >= 0x03000000
res = PyUnicode_Format(ofmt,args);
res = PyUnicode_Format(ofmt,args);
#else
res = PyString_Format(ofmt,args);
res = PyString_Format(ofmt,args);
#endif
Py_DECREF(ofmt);
Py_DECREF(ofmt);
}
Py_DECREF(args);
}
Py_DECREF(args);
}
return res;
}
@ -381,18 +633,23 @@ SwigPyObject_repr(SwigPyObject *v)
{
const char *name = SWIG_TypePrettyName(v->ty);
PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", (name ? name : "unknown"), (void *)v);
if (v->next) {
if (repr && v->next) {
PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next);
if (nrep) {
# if PY_VERSION_HEX >= 0x03000000
PyObject *joined = PyUnicode_Concat(repr, nrep);
Py_DecRef(repr);
Py_DecRef(nrep);
repr = joined;
PyObject *joined = PyUnicode_Concat(repr, nrep);
Py_DecRef(repr);
Py_DecRef(nrep);
repr = joined;
# else
PyString_ConcatAndDel(&repr,nrep);
PyString_ConcatAndDel(&repr,nrep);
# endif
} else {
Py_DecRef(repr);
repr = NULL;
}
}
return repr;
return repr;
}
/* We need a version taking two PyObject* parameters so it's a valid
@ -488,8 +745,12 @@ SwigPyObject_dealloc(PyObject *v)
if (data->delargs) {
/* we need to create a temporary object to carry the destroy operation */
PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0);
res = SWIG_Python_CallFunctor(destroy, tmp);
Py_DECREF(tmp);
if (tmp) {
res = SWIG_Python_CallFunctor(destroy, tmp);
} else {
res = 0;
}
Py_XDECREF(tmp);
} else {
PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
PyObject *mself = PyCFunction_GET_SELF(destroy);
@ -510,6 +771,9 @@ SwigPyObject_dealloc(PyObject *v)
#endif
}
Py_XDECREF(next);
#ifdef SWIGPYTHON_BUILTIN
Py_XDECREF(sobj->dict);
#endif
PyObject_DEL(v);
}
@ -565,9 +829,9 @@ SwigPyObject_own(PyObject *v, PyObject *args)
PyObject *obj = PyBool_FromLong(sobj->own);
if (val) {
if (PyObject_IsTrue(val)) {
SwigPyObject_acquire(v,args);
Py_DECREF(SwigPyObject_acquire(v,args));
} else {
SwigPyObject_disown(v,args);
Py_DECREF(SwigPyObject_disown(v,args));
}
}
return obj;
@ -696,6 +960,12 @@ SwigPyObject_TypeOnce(void) {
#if PY_VERSION_HEX >= 0x03040000
0, /* tp_finalize */
#endif
#if PY_VERSION_HEX >= 0x03080000
0, /* tp_vectorcall */
#endif
#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000)
0, /* tp_print */
#endif
#ifdef COUNT_ALLOCS
0, /* tp_allocs */
0, /* tp_frees */
@ -706,7 +976,7 @@ SwigPyObject_TypeOnce(void) {
};
swigpyobject_type = tmp;
type_init = 1;
if (PyType_Ready(&swigpyobject_type) < 0)
if (PyType_Ready(&swigpyobject_type) != 0)
return NULL;
}
return &swigpyobject_type;
@ -721,6 +991,9 @@ SwigPyObject_New(void *ptr, swig_type_info *ty, int own)
sobj->ty = ty;
sobj->own = own;
sobj->next = 0;
#ifdef SWIGPYTHON_BUILTIN
sobj->dict = 0;
#endif
}
return (PyObject *)sobj;
}
@ -857,6 +1130,12 @@ SwigPyPacked_TypeOnce(void) {
#if PY_VERSION_HEX >= 0x03040000
0, /* tp_finalize */
#endif
#if PY_VERSION_HEX >= 0x03080000
0, /* tp_vectorcall */
#endif
#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000)
0, /* tp_print */
#endif
#ifdef COUNT_ALLOCS
0, /* tp_allocs */
0, /* tp_frees */
@ -867,7 +1146,7 @@ SwigPyPacked_TypeOnce(void) {
};
swigpypacked_type = tmp;
type_init = 1;
if (PyType_Ready(&swigpypacked_type) < 0)
if (PyType_Ready(&swigpypacked_type) != 0)
return NULL;
}
return &swigpypacked_type;
@ -1175,12 +1454,17 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this)
#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
PyObject **dictptr = _PyObject_GetDictPtr(inst);
if (dictptr != NULL) {
PyObject *dict = *dictptr;
if (dict == NULL) {
dict = PyDict_New();
*dictptr = dict;
PyDict_SetItem(dict, SWIG_This(), swig_this);
}
PyObject *dict = *dictptr;
if (dict == NULL) {
dict = PyDict_New();
*dictptr = dict;
}
if (dict) {
PyDict_SetItem(dict, SWIG_This(), swig_this);
} else{
Py_DECREF(inst);
inst = 0;
}
}
#else
if (PyObject_SetAttr(inst, SWIG_This(), swig_this) == -1) {
@ -1220,25 +1504,25 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this)
return inst;
}
SWIGRUNTIME void
SWIGRUNTIME int
SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
{
PyObject *dict;
#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
PyObject **dictptr = _PyObject_GetDictPtr(inst);
if (dictptr != NULL) {
dict = *dictptr;
if (dict == NULL) {
dict = PyDict_New();
*dictptr = dict;
}
PyDict_SetItem(dict, SWIG_This(), swig_this);
return;
}
PyObject **dictptr = _PyObject_GetDictPtr(inst);
if (dictptr != NULL) {
PyObject *dict = *dictptr;
if (dict == NULL) {
dict = PyDict_New();
*dictptr = dict;
}
if (dict) {
return PyDict_SetItem(dict, SWIG_This(), swig_this);
} else{
return -1;
}
}
#endif
dict = PyObject_GetAttrString(inst, "__dict__");
PyDict_SetItem(dict, SWIG_This(), swig_this);
Py_DECREF(dict);
return PyObject_SetAttr(inst, SWIG_This(), swig_this);
}
@ -1250,9 +1534,10 @@ SWIG_Python_InitShadowInstance(PyObject *args) {
} else {
SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]);
if (sthis) {
SwigPyObject_append((PyObject*) sthis, obj[1]);
Py_DECREF(SwigPyObject_append((PyObject*) sthis, obj[1]));
} else {
SWIG_Python_SetSwigThis(obj[0], obj[1]);
if (SWIG_Python_SetSwigThis(obj[0], obj[1]) != 0)
return NULL;
}
return SWIG_Py_Void();
}
@ -1288,7 +1573,9 @@ SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int f
} else {
newobj = PyObject_New(SwigPyObject, clientdata->pytype);
#ifdef SWIGPYTHON_BUILTIN
newobj->dict = 0;
if (newobj) {
newobj->dict = 0;
}
#endif
}
if (newobj) {
@ -1327,6 +1614,17 @@ SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
void *SWIG_ReturnGlobalTypeList(void *);
#endif
static PyObject *Swig_TypeCache_global = NULL;
/* The python cached type query */
SWIGRUNTIME PyObject *
SWIG_Python_TypeCache(void) {
if (Swig_TypeCache_global == NULL) {
Swig_TypeCache_global = PyDict_New();
}
return Swig_TypeCache_global;
}
SWIGRUNTIME swig_module_info *
SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
static void *type_pointer = (void *)0;
@ -1355,11 +1653,16 @@ SWIG_Python_DestroyModule(PyObject *obj)
swig_type_info *ty = types[i];
if (ty->owndata) {
SwigPyClientData *data = (SwigPyClientData *) ty->clientdata;
ty->clientdata = 0;
if (data) SwigPyClientData_Del(data);
}
}
Py_DECREF(SWIG_This());
Swig_This_global = NULL;
Py_DECREF(SWIG_globals());
Swig_Globals_global = NULL;
Py_DECREF(SWIG_Python_TypeCache());
Swig_TypeCache_global = NULL;
}
SWIGRUNTIME void
@ -1373,19 +1676,14 @@ SWIG_Python_SetModule(swig_module_info *swig_module) {
#endif
PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule);
if (pointer && module) {
PyModule_AddObject(module, "type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer);
if (PyModule_AddObject(module, "type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer) != 0) {
Py_DECREF(pointer);
}
} else {
Py_XDECREF(pointer);
}
}
/* The python cached type query */
SWIGRUNTIME PyObject *
SWIG_Python_TypeCache(void) {
static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New();
return cache;
}
SWIGRUNTIME swig_type_info *
SWIG_Python_TypeQuery(const char *type)
{
@ -1400,8 +1698,10 @@ SWIG_Python_TypeQuery(const char *type)
descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
if (descriptor) {
obj = PyCapsule_New((void*) descriptor, NULL, NULL);
PyDict_SetItem(cache, key, obj);
Py_DECREF(obj);
if (obj) {
PyDict_SetItem(cache, key, obj);
Py_DECREF(obj);
}
}
}
Py_DECREF(key);
@ -1544,7 +1844,7 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) {
}
if (!tp->tp_dict) {
if (PyType_Ready(tp) < 0)
if (PyType_Ready(tp) != 0)
goto done;
}
@ -1559,7 +1859,7 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) {
} else {
encoded_name = PyUnicode_AsUTF8String(name);
if (!encoded_name)
return -1;
goto done;
}
PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name));
Py_DECREF(encoded_name);

View file

@ -45,11 +45,20 @@ namespace swig {
template <class Type>
struct traits_asptr {
static int asptr(PyObject *obj, Type **val) {
Type *p = 0;
int res = SWIG_ERROR;
swig_type_info *descriptor = type_info<Type>();
int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res)) {
if (val) *val = p;
if (val) {
Type *p = 0;
int newmem = 0;
res = descriptor ? SWIG_ConvertPtrAndOwn(obj, (void **)&p, descriptor, 0, &newmem) : SWIG_ERROR;
if (SWIG_IsOK(res)) {
if (newmem & SWIG_CAST_NEW_MEMORY) {
res |= SWIG_NEWOBJMASK;
}
*val = p;
}
} else {
res = descriptor ? SWIG_ConvertPtr(obj, 0, descriptor, 0) : SWIG_ERROR;
}
return res;
}

Some files were not shown because too many files have changed in this diff Show more