Merge branch 'fix-cast' into master

This commit is contained in:
Sergio Garcia Murillo 2021-11-29 16:12:38 +01:00 • committed by GitHub
commit 975a36d5a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
537 changed files with 6412 additions and 29161 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

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

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

@ -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 >= 8
# define SWIG_HANDLE_VALUE_ERROR_FOR_PHP8 code == SWIG_ValueError ? zend_ce_value_error :
#else
# define SWIG_HANDLE_VALUE_ERROR_FOR_PHP8
#endif
#define SWIG_exception(code, msg) do { zend_throw_exception( \
code == SWIG_TypeError ? zend_ce_type_error : \
SWIG_HANDLE_VALUE_ERROR_FOR_PHP8 \
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")

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

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

@ -1,19 +1,16 @@
%insert(init) %{
SWIGRUNTIME void
SWIG_JSC_SetModule(void *clientdata, swig_module_info *swig_module) {
JSGlobalContextRef context;
SWIG_JSC_SetModule(JSGlobalContextRef context, swig_module_info *swig_module) {
JSObjectRef globalObject;
JSStringRef moduleName;
JSClassDefinition classDef;
JSClassRef classRef;
JSObjectRef object;
if(clientdata == 0){
if(context == 0){
return;
}
context = (JSGlobalContextRef)clientdata;
globalObject = JSContextGetGlobalObject(context);
moduleName = JSStringCreateWithUTF8CString("swig_module_info_data");
@ -29,19 +26,16 @@ SWIG_JSC_SetModule(void *clientdata, swig_module_info *swig_module) {
JSStringRelease(moduleName);
}
SWIGRUNTIME swig_module_info *
SWIG_JSC_GetModule(void *clientdata) {
JSGlobalContextRef context;
SWIG_JSC_GetModule(JSGlobalContextRef context) {
JSObjectRef globalObject;
JSStringRef moduleName;
JSValueRef value;
JSObjectRef object;
if(clientdata == 0){
if(context == 0){
return 0;
}
context = (JSGlobalContextRef)clientdata;
globalObject = JSContextGetGlobalObject(context);
moduleName = JSStringCreateWithUTF8CString("swig_module_info_data");
@ -59,6 +53,7 @@ SWIG_JSC_GetModule(void *clientdata) {
#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"
@ -76,7 +71,7 @@ extern "C" {
#endif
bool SWIGJSC_INIT (JSGlobalContextRef context, JSObjectRef *exports) {
SWIG_InitializeModule((void*)context);
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;
}

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

@ -432,7 +432,7 @@ fail:
$jsmangledname_class_0->SetHiddenPrototype(true);
v8::Local<v8::Object> $jsmangledname_obj = $jsmangledname_class_0->GetFunction();
#else
v8::Local<v8::Object> $jsmangledname_obj = $jsmangledname_class_0->GetFunction(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked();
v8::Local<v8::Object> $jsmangledname_obj = $jsmangledname_class_0->GetFunction(context).ToLocalChecked();
#endif
%}
@ -444,10 +444,10 @@ fail:
* ----------------------------------------------------------------------------- */
%fragment("jsv8_register_class", "templates")
%{
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
#if (V8_MAJOR_VERSION-0) < 5
$jsparent_obj->Set(SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj);
#else
SWIGV8_MAYBE_CHECK($jsparent_obj->Set(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj));
SWIGV8_MAYBE_CHECK($jsparent_obj->Set(context, SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj));
#endif
%}
@ -469,10 +469,10 @@ fail:
* ----------------------------------------------------------------------------- */
%fragment("jsv8_register_namespace", "templates")
%{
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
#if (V8_MAJOR_VERSION-0) < 5
$jsparent_obj->Set(SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj);
#else
SWIGV8_MAYBE_CHECK($jsparent_obj->Set(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj));
SWIGV8_MAYBE_CHECK($jsparent_obj->Set(context, SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj));
#endif
%}
@ -509,7 +509,7 @@ fail:
* ----------------------------------------------------------------------------- */
%fragment("jsv8_register_static_function", "templates")
%{
SWIGV8_AddStaticFunction($jsparent_obj, "$jsname", $jswrapper);
SWIGV8_AddStaticFunction($jsparent_obj, "$jsname", $jswrapper, context);
%}
/* -----------------------------------------------------------------------------
@ -523,5 +523,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

@ -17,7 +17,7 @@ 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);
SWIGV8_ARRAY_SET(vals, 0, SWIG_From(double)(Real(c)));
SWIGV8_ARRAY_SET(vals, 1, SWIG_From(double)(Imag(c)));
@ -39,23 +39,23 @@ SWIG_AsVal_dec(Type) (SWIGV8_VALUE o, Type* val)
if (o->IsArray()) {
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)(SWIGV8_ARRAY_GET(array, 0), &re);
if(!SWIG_IsOK(res)) {
if (!SWIG_IsOK(res)) {
return SWIG_TypeError;
}
res = SWIG_AsVal(double)(SWIGV8_ARRAY_GET(array, 1), &im);
if(!SWIG_IsOK(res)) {
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)) {
@ -81,17 +81,17 @@ SWIG_AsVal_dec(Type) (SWIGV8_VALUE o, Type* val)
if (o->IsArray()) {
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)(SWIGV8_ARRAY_GET(array, 0), &re);
if(!SWIG_IsOK(res)) {
if (!SWIG_IsOK(res)) {
return SWIG_TypeError;
}
res = SWIG_AsVal(double)(SWIGV8_ARRAY_GET(array, 1), &im);
if(!SWIG_IsOK(res)) {
if (!SWIG_IsOK(res)) {
return SWIG_TypeError;
}
@ -102,7 +102,7 @@ SWIG_AsVal_dec(Type) (SWIGV8_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

@ -61,11 +61,11 @@ SWIGRUNTIME void SWIGV8_AddMemberVariable(SWIGV8_FUNCTION_TEMPLATE class_templ,
* Registers a class method with given name for a given object.
*/
SWIGRUNTIME void SWIGV8_AddStaticFunction(SWIGV8_OBJECT obj, const char* symbol,
const SwigV8FunctionCallback& _func) {
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) || (SWIG_V8_VERSION < 0x0704)
const SwigV8FunctionCallback& _func, v8::Local<v8::Context> context) {
#if (V8_MAJOR_VERSION-0) < 5
obj->Set(SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction());
#else
SWIGV8_MAYBE_CHECK(obj->Set(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked()));
SWIGV8_MAYBE_CHECK(obj->Set(context, SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction(context).ToLocalChecked()));
#endif
}
@ -73,11 +73,12 @@ SWIGRUNTIME void SWIGV8_AddStaticFunction(SWIGV8_OBJECT obj, const char* symbol,
* Registers a class method with given name for a given object.
*/
SWIGRUNTIME void SWIGV8_AddStaticVariable(SWIGV8_OBJECT obj, const char* symbol,
SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback setter) {
SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback setter,
v8::Local<v8::Context> context) {
#if (V8_MAJOR_VERSION-0) < 5
obj->SetAccessor(SWIGV8_SYMBOL_NEW(symbol), getter, setter);
#else
SWIGV8_MAYBE_CHECK(obj->SetAccessor(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW(symbol), getter, setter));
SWIGV8_MAYBE_CHECK(obj->SetAccessor(context, SWIGV8_SYMBOL_NEW(symbol), getter, setter));
#endif
}

View file

@ -5,27 +5,27 @@
%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);
global_obj->SetPrivate(context, privateKey, mod);
#endif
}
SWIGRUNTIME swig_module_info *
SWIG_V8_GetModule(void *) {
v8::Local<v8::Object> global_obj = SWIGV8_CURRENT_CONTEXT()->Global();
SWIG_V8_GetModule(v8::Local<v8::Context> context) {
v8::Local<v8::Object> global_obj = context->Global();
#if (V8_MAJOR_VERSION-0) < 5
v8::Local<v8::Value> moduleinfo = global_obj->GetHiddenValue(SWIGV8_STRING_NEW("swig_module_info_data"));
#else
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
@ -52,6 +52,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 +65,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 (SWIGV8_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 (SWIGV8_OBJECT exports, SWIGV8_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();
SWIGV8_OBJECT exports_obj = exports;
SWIG_InitializeModule(context);
%}
@ -124,6 +125,10 @@ void SWIGV8_INIT (SWIGV8_OBJECT exports, SWIGV8_OBJECT /*module*/)
}
#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

@ -50,28 +50,29 @@ typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
#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)
#elif (SWIG_V8_VERSION < 0x0704)
#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, v8::String::kNormalString)
#define SWIGV8_SYMBOL_NEW(sym) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sym, v8::String::kNormalString)
#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)
#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
#endif
#if (SWIG_V8_VERSION < 0x0704)
#if (V8_MAJOR_VERSION-0) < 5
#define SWIGV8_MAYBE_CHECK(maybe) maybe
#elif (SWIG_V8_VERSION < 0x0704)
#define SWIGV8_MAYBE_CHECK(maybe) maybe.FromJust()
#else
#define SWIGV8_MAYBE_CHECK(maybe) maybe.Check()
#endif
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032318)
#define SWIGV8_ARRAY_NEW() v8::Array::New()
#define SWIGV8_ARRAY_NEW(size) v8::Array::New(size)
#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)
@ -91,7 +92,7 @@ typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
#define SWIGV8_ARRAY_GET(array, index) (array)->Get(index)
#define SWIGV8_ARRAY_SET(array, index, value) (array)->Set(index, value)
#else
#define SWIGV8_ARRAY_NEW() v8::Array::New(v8::Isolate::GetCurrent())
#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)
@ -120,15 +121,7 @@ typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
#define SWIGV8_SET_CLASS_TEMPL(class_templ, class) class_templ.Reset(v8::Isolate::GetCurrent(), class);
#endif
#ifdef NODE_VERSION
#if NODE_VERSION_AT_LEAST(10, 12, 0)
#define SWIG_NODE_AT_LEAST_1012
#endif
#endif
//Necessary to check Node.js version because V8 API changes are backported in Node.js
#if (defined(NODE_VERSION) && !defined(SWIG_NODE_AT_LEAST_1012)) || \
(!defined(NODE_VERSION) && (V8_MAJOR_VERSION-0) < 7)
#if (V8_MAJOR_VERSION-0) < 6 || (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()
@ -136,22 +129,18 @@ typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue()
#define SWIGV8_WRITE_UTF8(handle, buffer, len) (handle)->WriteUtf8(buffer, len)
#define SWIGV8_UTF8_LENGTH(handle) (handle)->Utf8Length()
#elif (SWIG_V8_VERSION < 0x0704)
#define SWIGV8_TO_OBJECT(handle) (handle)->ToObject(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked()
#define SWIGV8_TO_STRING(handle) (handle)->ToString(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked()
#define SWIGV8_NUMBER_VALUE(handle) (handle)->NumberValue(SWIGV8_CURRENT_CONTEXT()).ToChecked()
#define SWIGV8_INTEGER_VALUE(handle) (handle)->IntegerValue(SWIGV8_CURRENT_CONTEXT()).ToChecked()
#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue(SWIGV8_CURRENT_CONTEXT()).ToChecked()
#define SWIGV8_WRITE_UTF8(handle, buffer, len) (handle)->WriteUtf8(v8::Isolate::GetCurrent(), buffer, len)
#define SWIGV8_UTF8_LENGTH(handle) (handle)->Utf8Length(v8::Isolate::GetCurrent())
#else
#define SWIGV8_TO_OBJECT(handle) (handle)->ToObject(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked()
#define SWIGV8_TO_STRING(handle) (handle)->ToString(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked()
#define SWIGV8_NUMBER_VALUE(handle) (handle)->NumberValue(SWIGV8_CURRENT_CONTEXT()).ToChecked()
#define SWIGV8_INTEGER_VALUE(handle) (handle)->IntegerValue(SWIGV8_CURRENT_CONTEXT()).ToChecked()
#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue(v8::Isolate::GetCurrent())
#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
/* ---------------------------------------------------------------------------
@ -291,6 +280,7 @@ SWIGRUNTIME int SWIG_V8_ConvertInstancePtr(SWIGV8_OBJECT objRef, void **ptr, swi
}
int newmemory = 0;
*ptr = SWIG_TypeCast(tc, cdata->swigCObject, &newmemory);
assert(!newmemory); /* newmemory handling not yet implemented */
} else {
*ptr = cdata->swigCObject;
}
@ -325,7 +315,7 @@ SWIGRUNTIME int SWIG_V8_GetInstancePtr(SWIGV8_VALUE valRef, void **ptr) {
if(!valRef->IsObject()) {
return SWIG_TypeError;
}
SWIGV8_OBJECT objRef = SWIGV8_TO_OBJECT(valRef);
SWIGV8_OBJECT objRef = SWIGV8_OBJECT::Cast(valRef);
if(objRef->InternalFieldCount() < 1) return SWIG_ERROR;
@ -420,7 +410,7 @@ SWIGRUNTIME int SWIG_V8_ConvertPtr(SWIGV8_VALUE valRef, void **ptr, swig_type_in
if(!valRef->IsObject()) {
return SWIG_TypeError;
}
SWIGV8_OBJECT objRef = SWIGV8_TO_OBJECT(valRef);
SWIGV8_OBJECT objRef = SWIGV8_OBJECT::Cast(valRef);
return SWIG_V8_ConvertInstancePtr(objRef, ptr, info, flags);
}
@ -454,7 +444,7 @@ SWIGRUNTIME SWIGV8_VALUE SWIG_V8_NewPointerObj(void *ptr, swig_type_info *info,
}
#endif
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) || (SWIG_V8_VERSION < 0x0704)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
v8::Local<v8::Object> result = class_templ->InstanceTemplate()->NewInstance();
#else
v8::Local<v8::Object> result = class_templ->InstanceTemplate()->NewInstance(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked();
@ -707,9 +697,9 @@ 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();
SWIGV8_ARRAY tmparr = SWIGV8_ARRAY_NEW(0);
SWIGV8_ARRAY_SET(tmparr, 0, result);
result = tmparr;
}

View file

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

View file

@ -8,13 +8,13 @@ SWIG_AsCharPtrAndSize(SWIGV8_VALUE valRef, char** cptr, size_t* psize, int *allo
{
if(valRef->IsString()) {
%#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
v8::Handle<v8::String> js_str = SWIGV8_TO_STRING(valRef);
v8::Handle<v8::String> js_str = v8::Handle<v8::String>::Cast(valRef);
%#else
v8::Local<v8::String> js_str = SWIGV8_TO_STRING(valRef);
v8::Local<v8::String> js_str = v8::Local<v8::String>::Cast(valRef);
%#endif
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;
@ -24,7 +24,7 @@ SWIG_AsCharPtrAndSize(SWIGV8_VALUE valRef, char** cptr, size_t* psize, int *allo
return SWIG_OK;
} else {
if(valRef->IsObject()) {
SWIGV8_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) {

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

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

@ -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.
*/

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(SWIGTYPE_$class_ce, "$const_name", sizeof("$const_name") - 1, ($1_type)$value);
%}
%typemap(classconsttab) bool %{
zend_declare_class_constant_bool(SWIGTYPE_$class_ce, "$const_name", sizeof("$const_name") - 1, ($1_type)$value);
%}
%typemap(classconsttab) float,
double %{
zend_declare_class_constant_double(SWIGTYPE_$class_ce, "$const_name", sizeof("$const_name") - 1, $value);
%}
%typemap(classconsttab) char %{
{
char swig_char = $value;
zend_declare_class_constant_stringl(SWIGTYPE_$class_ce, "$const_name", sizeof("$const_name") - 1, &swig_char, 1);
}
%}
%typemap(classconsttab) char *,
const char *,
char [],
const char [] %{
zend_declare_class_constant_string(SWIGTYPE_$class_ce, "$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(SWIGTYPE_$class_ce, "$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);
}
%}
@ -370,12 +391,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 +404,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 +424,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 +483,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 +558,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 >= 8
# define SWIG_PHP_INTERFACE_Stringable_CE zend_ce_stringable
# define SWIG_PHP_INTERFACE_Stringable_HEADER "zend_interfaces.h"
#endif
%}

View file

@ -55,6 +55,7 @@ PHPKW(endwhile);
PHPKW(extends);
PHPKW(final);
PHPKW(finally);
PHPKW(fn); // as of PHP 7.4
PHPKW(for);
PHPKW(foreach);
PHPKW(function);
@ -65,6 +66,7 @@ PHPKW(implements);
PHPKW(instanceof);
PHPKW(insteadof);
PHPKW(interface);
PHPKW(match); // as of PHP 8.0
PHPKW(namespace);
PHPKW(new);
PHPKW(or);
@ -119,6 +121,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 +140,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 +152,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 +164,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 +413,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 +623,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 +650,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);

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,74 +77,49 @@ 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) php_fetch_object(Z_OBJ_P(zv))
static inline
swig_object_wrapper * 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 = 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
@ -139,15 +127,10 @@ SWIG_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject) {
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. */
This is called by SWIG_ConvertPtr which gets the type name from the
swig_object_wrapper. */
static void *
SWIG_ConvertResourceData(void * p, const char *type_name, swig_type_info *ty) {
SWIG_ConvertPtrData(void * p, const char *type_name, swig_type_info *ty, int *own) {
swig_cast_info *tc;
void *result = 0;
@ -156,7 +139,7 @@ SWIG_ConvertResourceData(void * p, const char *type_name, swig_type_info *ty) {
return p;
}
if (! type_name) {
if (! type_name) {
/* can't convert p to ptr type ty if we don't know what type p is */
return NULL;
}
@ -166,62 +149,36 @@ SWIG_ConvertResourceData(void * p, const char *type_name, swig_type_info *ty) {
if (tc) {
int newmemory = 0;
result = SWIG_TypeCast(tc, p, &newmemory);
assert(!newmemory); /* newmemory handling not yet implemented */
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;
}
}
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);
*ptr = SWIG_ConvertPtrData(value->ptr, value->type->name, ty, own);
if (*ptr == NULL) return SWIG_ERROR;
if (flags & SWIG_POINTER_DISOWN) {
value->newobject = 0;
}
break;
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 +187,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,7 +199,7 @@ static swig_module_info *SWIG_Php_GetModule() {
if (Z_TYPE_P(pointer) == IS_LONG) {
return (swig_module_info *) pointer->value.lval;
}
}
}
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

@ -276,7 +276,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

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

@ -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);
@ -279,18 +284,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__");
@ -299,10 +311,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;
}
@ -313,10 +322,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 =====================*/
@ -343,7 +355,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;
}
@ -361,18 +373,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;
}
@ -394,18 +409,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
@ -501,8 +521,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);
@ -523,6 +547,9 @@ SwigPyObject_dealloc(PyObject *v)
#endif
}
Py_XDECREF(next);
#ifdef SWIGPYTHON_BUILTIN
Py_XDECREF(sobj->dict);
#endif
PyObject_DEL(v);
}
@ -578,9 +605,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;
@ -725,7 +752,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;
@ -740,6 +767,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;
}
@ -892,7 +922,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;
@ -1200,12 +1230,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) {
@ -1256,7 +1291,11 @@ SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
dict = PyDict_New();
*dictptr = dict;
}
return PyDict_SetItem(dict, SWIG_This(), swig_this);
if (dict) {
return PyDict_SetItem(dict, SWIG_This(), swig_this);
} else{
return -1;
}
}
#endif
return PyObject_SetAttr(inst, SWIG_This(), swig_this);
@ -1271,7 +1310,7 @@ 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 {
if (SWIG_Python_SetSwigThis(obj[0], obj[1]) != 0)
return NULL;
@ -1310,7 +1349,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) {
@ -1349,6 +1390,13 @@ SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
void *SWIG_ReturnGlobalTypeList(void *);
#endif
/* The python cached type query */
SWIGRUNTIME PyObject *
SWIG_Python_TypeCache(void) {
static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New();
return cache;
}
SWIGRUNTIME swig_module_info *
SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
static void *type_pointer = (void *)0;
@ -1377,11 +1425,13 @@ 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_Python_TypeCache());
}
SWIGRUNTIME void
@ -1395,19 +1445,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)
{
@ -1422,8 +1467,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);
@ -1566,7 +1613,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;
}
@ -1581,7 +1628,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

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

@ -77,7 +77,7 @@ AUTODOC(operator>, "Higher than comparison operator");
AUTODOC(operator<<, "Left shifting or appending operator");
AUTODOC(operator>>, "Right shifting operator or extracting operator");
AUTODOC(operator+, "Add operator");
AUTODOC(operator-, "Substraction operator");
AUTODOC(operator-, "Subtraction operator");
AUTODOC(operator+(), "Positive operator");
AUTODOC(operator-(), "Negation operator");
AUTODOC(operator&, "AND operator");
@ -93,7 +93,7 @@ AUTODOC(__gt__, "Higher than comparison operator");
AUTODOC(__lshift__, "Left shifting or appending operator");
AUTODOC(__rshift__, "Right shifting operator or extracting operator");
AUTODOC(__add___, "Add operator");
AUTODOC(__sub__, "Substraction operator");
AUTODOC(__sub__, "Subtraction operator");
AUTODOC(__pos__, "Positive operator");
AUTODOC(__neg__, "Negation operator");
AUTODOC(__and__, "AND operator");

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

@ -18,7 +18,7 @@ SWIG_Int_AsEnum(void *pvApiCtx, int iVar, int *enumValue, char *fname) {
}
%fragment(SWIG_From_frag(Enum), "header", fragment="SWIG_Int_FromEnum") {
%#define SWIG_From_Enum(scilabValue) SWIG_Int_FromEnum(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
%#define SWIG_From_Enum(scilabValue) SWIG_Int_FromEnum(pvApiCtx, SWIG_Scilab_GetOutputPosition(), (int)scilabValue, SWIG_Scilab_GetFuncName())
}
%fragment("SWIG_Int_FromEnum", "header", fragment="SWIG_SciDouble_FromInt") {
SWIGINTERN int

View file

@ -50,9 +50,12 @@ extern "C" {
#define SWIGRUNTIME_DEBUG
#endif
#ifndef SWIG_INIT_CLIENT_DATA_TYPE
#define SWIG_INIT_CLIENT_DATA_TYPE void *
#endif
SWIGRUNTIME void
SWIG_InitializeModule(void *clientdata) {
SWIG_InitializeModule(SWIG_INIT_CLIENT_DATA_TYPE clientdata) {
size_t i;
swig_module_info *module_head, *iter;
int init;

View file

@ -115,7 +115,7 @@
SWIG errors code.
Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
allows to return the 'cast rank', for example, if you have this
allows returning the 'cast rank', for example, if you have this
int food(double)
int fooi(int);

View file

@ -126,7 +126,7 @@ MacintoshInit()
*
* This procedure calls initialization routines require a Tcl
* interp as an argument. This call effectively makes the passed
* iterpreter the "main" interpreter for the application.
* interpreter the "main" interpreter for the application.
*
* Results:
* Returns TCL_OK if everything went fine. If it didn't the

View file

@ -562,29 +562,29 @@
* ------------------------------------------------------------ */
%typemap(in) 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)) {
%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)) {
%variable_fail(res, "$type", "$name");
}
}
%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));
}
%typemap(constcode,noblock=1) SWIGTYPE (CLASS::*) {
%set_constant("$symname", SWIG_NewMemberObj(%as_voidptr(&$value), sizeof($type), $descriptor));
%set_constant("$symname", SWIG_NewMemberObj(%as_voidptr(&$value), sizeof($value), $descriptor));
}
#if defined(SWIG_DIRECTOR_TYPEMAPS)
@ -592,13 +592,13 @@
/* directorin */
%typemap(directorin,noblock=1) SWIGTYPE (CLASS::*) {
$input = SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor);
$input = SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($1), $descriptor);
}
/* directorout */
%typemap(directorout) SWIGTYPE (CLASS::*) {
int swig_res = SWIG_ConvertMember($input,%as_voidptr(&$result), sizeof($type), $descriptor);
int swig_res = SWIG_ConvertMember($input,%as_voidptr(&$result), sizeof($result), $descriptor);
if (!SWIG_IsOK(swig_res)) {
%dirout_fail(swig_res,"$type");
}

View file

@ -1,101 +0,0 @@
/* Define a C preprocessor symbol that can be used in interface files
to distinguish between the SWIG language modules. */
#define SWIG_UFFI
/* Typespecs for basic types. */
%typemap(ffitype) char ":char";
%typemap(ffitype) unsigned char ":unsigned-char";
%typemap(ffitype) signed char ":char";
%typemap(ffitype) short ":short";
%typemap(ffitype) signed short ":short";
%typemap(ffitype) unsigned short ":unsigned-short";
%typemap(ffitype) int ":int";
%typemap(ffitype) signed int ":int";
%typemap(ffitype) unsigned int ":unsigned-int";
%typemap(ffitype) long ":long";
%typemap(ffitype) signed long ":long";
%typemap(ffitype) unsigned long ":unsigned-long";
%typemap(ffitype) float ":float";
%typemap(ffitype) double ":double";
%typemap(ffitype) char * ":cstring";
%typemap(ffitype) void * ":pointer-void";
%typemap(ffitype) void ":void";
// FIXME: This is guesswork
typedef long size_t;
%wrapper %{
(eval-when (compile eval)
;;; You can define your own identifier converter if you want.
;;; Use the -identifier-converter command line argument to
;;; specify its name.
(defun identifier-convert-null (id &key type)
(declare (ignore type))
(read-from-string id))
(defun identifier-convert-lispify (cname &key type)
(assert (stringp cname))
(if (eq type :constant)
(setf cname (format nil "*~A*" cname)))
(setf cname (replace-regexp cname "_" "-"))
(let ((lastcase :other)
newcase char res)
(dotimes (n (length cname))
(setf char (schar cname n))
(if* (alpha-char-p char)
then
(setf newcase (if (upper-case-p char) :upper :lower))
(when (or (and (eq lastcase :upper) (eq newcase :lower))
(and (eq lastcase :lower) (eq newcase :upper)))
;; case change... add a dash
(push #\- res)
(setf newcase :other))
(push (char-downcase char) res)
(setf lastcase newcase)
else
(push char res)
(setf lastcase :other)))
(read-from-string (coerce (nreverse res) 'string))))
(defun identifier-convert-low-level (cname &key type)
(assert (stringp cname))
(if (eq type :constant)
(setf cname (format nil "+~A+" cname)))
(setf cname (substitute #\- #\_ cname))
(if (eq type :operator)
(setf cname (format nil "%~A" cname)))
(if (eq type :constant-function)
nil)
(read-from-string cname))
(defmacro swig-defconstant (string value &key (export T))
(let ((symbol (funcall *swig-identifier-converter* string :type :constant)))
`(eval-when (compile load eval)
(uffi:def-constant ,symbol ,value ,export))))
(defmacro swig-defun (name &rest rest)
(let ((symbol (funcall *swig-identifier-converter* name :type :operator)))
`(eval-when (compile load eval)
(uffi:def-function (,name ,symbol) ,@rest)
(export (quote ,symbol)))))
(defmacro swig-def-struct (name &rest fields)
"Declare a struct object"
(let ((symbol (funcall *swig-identifier-converter* name :type :type)))
`(eval-when (compile load eval)
(uffi:def-struct ,symbol ,@fields)
(export (quote ,symbol)))))
) ;; eval-when
%}