Merge branch 'master' into gsoc2012-scilab

Conflicts:
	.gitignore
	.travis.yml
	COPYRIGHT
	Examples/Makefile.in
	Examples/test-suite/constructor_copy.i
	Makefile.in
	configure.ac
This commit is contained in:
Simon Marchetto 2014-06-06 16:33:16 +02:00
commit 07b06a4089
1502 changed files with 46955 additions and 11374 deletions

View file

@ -17,8 +17,7 @@
enum SWIGTYPE "(cl::setq ACL_ffresult $body)";
%typemap(lout) void "$body";
#ifdef __cplusplus
%typemap(lout) SWIGTYPE[ANY], SWIGTYPE *,
SWIGTYPE &
%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)))
@ -27,7 +26,7 @@
%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
%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)) %}
@ -67,6 +66,7 @@
%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
@ -102,7 +102,7 @@ and error if a setf operation is performed on the address of this object.
long, signed long, unsigned long,
float, double, long double, char *, void *, void,
enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[],
SWIGTYPE[ANY], SWIGTYPE &, const SWIGTYPE "$1_ltype";
SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE &&, const SWIGTYPE "$1_ltype";
%typemap(ctype) SWIGTYPE "$&1_type";
%typemap(in) bool "$1 = (bool)$input;";
@ -112,7 +112,7 @@ and error if a setf operation is performed on the address of this object.
long, signed long, unsigned long,
float, double, long double, char *, void *, void,
enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[],
SWIGTYPE[ANY], SWIGTYPE & "$1 = $input;";
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
@ -167,7 +167,7 @@ SWIG_TYPECHECK_STRING_ARRAY 1140
int, signed int, unsigned int,
long, signed long, unsigned long,
enum SWIGTYPE { $1 = 1; };
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &,
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&,
SWIGTYPE[], SWIGTYPE[ANY],
SWIGTYPE { $1 = 1; };
@ -192,7 +192,7 @@ SWIG_TYPECHECK_STRING_ARRAY 1140
long, signed long, unsigned long,
float, double, long double, char *, void *,
enum SWIGTYPE, SWIGTYPE *,
SWIGTYPE[ANY], SWIGTYPE & "$result = $1;";
SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE && "$result = $1;";
#ifdef __cplusplus
%typemap(out) SWIGTYPE "$result = new $1_ltype($1);";
#else
@ -228,6 +228,7 @@ $body)"
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }

View file

@ -4,14 +4,14 @@
/*
Include all the known keyword warnings. Very useful for adding test
files to the test-suite, or check if your own library is ok for all
files to the test-suite, or checking if your own library is ok for all
the swig supported languages.
Use as
swig -Wallkw ...
If you add a new language, remember to create a separete languagekw.swg
If you add a new language, remember to create a separate languagekw.swg
file, and add it here.
*/
@ -19,14 +19,17 @@
%include <chicken/chickenkw.swg>
%include <csharp/csharpkw.swg>
%include <d/dkw.swg>
%include <go/gokw.swg>
%include <java/javakw.swg>
%include <lua/luakw.swg>
%include <ocaml/ocamlkw.swg>
%include <perl5/perlkw.swg>
%include <php/phpkw.swg>
%include <pike/pikekw.swg>
%include <python/pythonkw.swg>
%include <ocaml/ocamlkw.swg>
%include <r/rkw.swg>
%include <ruby/rubykw.swg>
%include <tcl/tclkw.swg>
%include <perl5/perlkw.swg>
#endif //__Lib_allkw_swg__

View file

@ -20,17 +20,50 @@ typedef struct SWIGCDATA {
$result = scm_from_locale_stringn($1.data,$1.len);
}
%typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH);
#elif SWIGCHICKEN
%typemap(out) SWIGCDATA {
C_word *string_space = C_alloc(C_SIZEOF_STRING($1.len));
$result = C_string(&string_space, $1.len, $1.data);
}
%typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH);
#elif SWIGPHP
%typemap(out) SWIGCDATA {
ZVAL_STRINGL($result, $1.data, $1.len, 1);
}
%typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH);
#elif SWIGJAVA
%apply (char *STRING, int LENGTH) { (const void *indata, int inlen) }
%typemap(jni) SWIGCDATA "jbyteArray"
%typemap(jtype) SWIGCDATA "byte[]"
%typemap(jstype) SWIGCDATA "byte[]"
%fragment("SWIG_JavaArrayOutCDATA", "header") {
static jbyteArray SWIG_JavaArrayOutCDATA(JNIEnv *jenv, char *result, jsize sz) {
jbyte *arr;
int i;
jbyteArray jresult = JCALL1(NewByteArray, jenv, sz);
if (!jresult)
return NULL;
arr = JCALL2(GetByteArrayElements, jenv, jresult, 0);
if (!arr)
return NULL;
for (i=0; i<sz; i++)
arr[i] = (jbyte)result[i];
JCALL3(ReleaseByteArrayElements, jenv, jresult, arr, 0);
return jresult;
}
}
%typemap(out, fragment="SWIG_JavaArrayOutCDATA") SWIGCDATA
%{$result = SWIG_JavaArrayOutCDATA(jenv, (char *)$1.data, $1.len); %}
%typemap(javaout) SWIGCDATA {
return $jnicall;
}
#else
%echo "cdata.i module not supported."
#endif

View file

@ -67,7 +67,7 @@
long, signed long, unsigned long,
float, double, long double, char *, void *, void,
enum SWIGTYPE, SWIGTYPE *,
SWIGTYPE[ANY], SWIGTYPE & "$1_ltype";
SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE && "$1_ltype";
%typemap(ctype) SWIGTYPE "$&1_type";
%typemap(in) bool "$1 = (bool)$input;";
@ -77,7 +77,7 @@
long, signed long, unsigned long,
float, double, long double, char *, void *, void,
enum SWIGTYPE, SWIGTYPE *,
SWIGTYPE[ANY], SWIGTYPE & "$1 = $input;";
SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE && "$1 = $input;";
%typemap(in) SWIGTYPE "$1 = *$input;";
%typemap(out) void "";
@ -88,7 +88,7 @@
long, signed long, unsigned long,
float, double, long double, char *, void *,
enum SWIGTYPE, SWIGTYPE *,
SWIGTYPE[ANY], SWIGTYPE & "$result = $1;";
SWIGTYPE[ANY], SWIGTYPE &, SWIGTYPE && "$result = $1;";
#ifdef __cplusplus
%typemap(out) SWIGTYPE "$result = new $1_type($1);";
#else
@ -109,7 +109,7 @@
int, signed int, unsigned int,
long, signed long, unsigned long,
enum SWIGTYPE { $1 = 1; };
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &,
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&,
SWIGTYPE[ANY], SWIGTYPE { $1 = 1; };
/* This maps C/C++ types to Lisp classes for overload dispatch */
@ -132,6 +132,7 @@
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }

View file

@ -149,6 +149,7 @@ SIMPLE_TYPEMAP(double, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEO
/* enum SWIGTYPE */
%apply int { enum SWIGTYPE };
%apply const int& { const enum SWIGTYPE& };
%apply const int& { const enum SWIGTYPE&& };
%typemap(varin) enum SWIGTYPE
{
@ -178,7 +179,7 @@ SIMPLE_TYPEMAP(double, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEO
%typemap(freearg) char * "if ($1 != NULL) { free ($1); }"
/* Pointers, references, and arrays */
%typemap(in,closcode="(slot-ref $input 'swig-this)") SWIGTYPE *, SWIGTYPE [], SWIGTYPE & {
%typemap(in,closcode="(slot-ref $input 'swig-this)") SWIGTYPE *, SWIGTYPE [], SWIGTYPE &, SWIGTYPE && {
$1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, $disown);
}
@ -199,6 +200,10 @@ SIMPLE_TYPEMAP(double, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEO
$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");
}
@ -216,7 +221,7 @@ SIMPLE_TYPEMAP(double, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEO
$1 = SWIG_MustGetPtr($input, NULL, 1, 0);
}
%typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
%typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
$result = SWIG_NewPointerObj($1, $descriptor, $owner);
}
@ -237,6 +242,11 @@ SIMPLE_TYPEMAP(double, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEO
$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];
@ -531,7 +541,7 @@ $result = C_SCHEME_UNDEFINED;
%typemap(constcode) char *
"static const char *$result = $value;"
%typemap(constcode) SWIGTYPE *, SWIGTYPE &, SWIGTYPE []
%typemap(constcode) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE []
"static const void *$result = (void*) $value;"
/* ------------------------------------------------------------
@ -607,7 +617,7 @@ $result = C_SCHEME_UNDEFINED;
$1 = C_swig_is_string ($input);
}
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
void *ptr;
$1 = !SWIG_ConvertPtr($input, &ptr, $1_descriptor, 0);
}
@ -628,6 +638,17 @@ $result = C_SCHEME_UNDEFINED;
}
}
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE &&
{
void *ptr = 0;
if (SWIG_ConvertPtr($input, &ptr, $descriptor, 0)) {
/* error */
$1 = 0;
} else {
$1 = (ptr != 0);
}
}
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE
{
void *ptr = 0;
@ -673,6 +694,12 @@ $result = C_SCHEME_UNDEFINED;
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
* ------------------------------------------------------------ */
@ -685,6 +712,7 @@ $result = C_SCHEME_UNDEFINED;
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }

View file

@ -313,7 +313,7 @@ SWIG_Chicken_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
swig_module_info *ret = 0;
C_word sym;
/* lookup the type pointer... it is stored in it's own symbol table */
/* 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);
@ -333,7 +333,7 @@ SWIG_Chicken_SetModule(swig_module_info *module) {
C_word pointer;
static C_word *space = 0;
/* type pointer is stored in it's own symbol table */
/* 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);

View file

@ -57,7 +57,7 @@
%typemap(ctype) CTYPE INPUT[] "CTYPE*"
%typemap(cstype) CTYPE INPUT[] "CSTYPE[]"
%typemap(imtype, inattributes="[In, MarshalAs(UnmanagedType.LPArray)]") CTYPE INPUT[] "CSTYPE[]"
%typemap(imtype, inattributes="[global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)]") CTYPE INPUT[] "CSTYPE[]"
%typemap(csin) CTYPE INPUT[] "$csinput"
%typemap(in) CTYPE INPUT[] "$1 = $input;"
@ -68,7 +68,7 @@
%typemap(ctype) CTYPE OUTPUT[] "CTYPE*"
%typemap(cstype) CTYPE OUTPUT[] "CSTYPE[]"
%typemap(imtype, inattributes="[Out, MarshalAs(UnmanagedType.LPArray)]") CTYPE OUTPUT[] "CSTYPE[]"
%typemap(imtype, inattributes="[global::System.Runtime.InteropServices.Out, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)]") CTYPE OUTPUT[] "CSTYPE[]"
%typemap(csin) CTYPE OUTPUT[] "$csinput"
%typemap(in) CTYPE OUTPUT[] "$1 = $input;"
@ -79,7 +79,7 @@
%typemap(ctype) CTYPE INOUT[] "CTYPE*"
%typemap(cstype) CTYPE INOUT[] "CSTYPE[]"
%typemap(imtype, inattributes="[In, Out, MarshalAs(UnmanagedType.LPArray)]") CTYPE INOUT[] "CSTYPE[]"
%typemap(imtype, inattributes="[global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.Out, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)]") CTYPE INOUT[] "CSTYPE[]"
%typemap(csin) CTYPE INOUT[] "$csinput"
%typemap(in) CTYPE INOUT[] "$1 = $input;"
@ -108,12 +108,12 @@ CSHARP_ARRAYS(double, double)
%define CSHARP_ARRAYS_FIXED( CTYPE, CSTYPE )
%typemap(ctype) CTYPE FIXED[] "CTYPE*"
%typemap(imtype) CTYPE FIXED[] "IntPtr"
%typemap(imtype) CTYPE FIXED[] "global::System.IntPtr"
%typemap(cstype) CTYPE FIXED[] "CSTYPE[]"
%typemap(csin,
pre= " fixed ( CSTYPE* swig_ptrTo_$csinput = $csinput ) {",
terminator=" }")
CTYPE FIXED[] "(IntPtr)swig_ptrTo_$csinput"
CTYPE FIXED[] "(global::System.IntPtr)swig_ptrTo_$csinput"
%typemap(in) CTYPE FIXED[] "$1 = $input;"
%typemap(freearg) CTYPE FIXED[] ""

View file

@ -207,11 +207,11 @@
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "void *"
%typemap (imtype, out="IntPtr") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
%typemap (imtype, out="global::System.IntPtr") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "HandleRef"
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "global::System.Runtime.InteropServices.HandleRef"
%typemap (cstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
@ -224,28 +224,28 @@
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(cstype, TYPE).getCPtr($csinput)"
%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > {
IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
global::System.IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
return ret;
}
%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
global::System.IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
return ret;
}
%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & {
IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
global::System.IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
return ret;
}
%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * {
IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
global::System.IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
return ret;
}
%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& {
IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
global::System.IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
return ret;
}
%typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{
@ -274,76 +274,76 @@
return ret;
}
%typemap(csout, excode=SWIGEXCODE) CONST TYPE * {
IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
global::System.IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
return ret;
}
%typemap(csout, excode=SWIGEXCODE) TYPE *CONST& {
IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
global::System.IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
return ret;
}
// Base proxy classes
%typemap(csbody) TYPE %{
private HandleRef swigCPtr;
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
private bool swigCMemOwnBase;
PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) {
PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) {
swigCMemOwnBase = cMemoryOwn;
swigCPtr = new HandleRef(this, cPtr);
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}
CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) {
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
%}
// Derived proxy classes
%typemap(csbody_derived) TYPE %{
private HandleRef swigCPtr;
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
private bool swigCMemOwnDerived;
PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
swigCMemOwnDerived = cMemoryOwn;
swigCPtr = new HandleRef(this, cPtr);
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}
CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) {
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
%}
%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE {
lock(this) {
if (swigCPtr.Handle != IntPtr.Zero) {
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
if (swigCMemOwnBase) {
swigCMemOwnBase = false;
$imcall;
}
swigCPtr = new HandleRef(null, IntPtr.Zero);
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
GC.SuppressFinalize(this);
global::System.GC.SuppressFinalize(this);
}
}
%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE {
lock(this) {
if (swigCPtr.Handle != IntPtr.Zero) {
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
if (swigCMemOwnDerived) {
swigCMemOwnDerived = false;
$imcall;
}
swigCPtr = new HandleRef(null, IntPtr.Zero);
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
GC.SuppressFinalize(this);
global::System.GC.SuppressFinalize(this);
base.Dispose();
}
}
// CONST version needed ???? also for C#
%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "HandleRef"
%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "HandleRef"
%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
@ -424,8 +424,8 @@
%typemap (cstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(cstype, TYPE)"
%typemap (csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(cstype, TYPE).getCPtr($csinput)"
%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
IntPtr cPtr = $imcall;
return (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
global::System.IntPtr cPtr = $imcall;
return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
}
%typemap(csout, excode=SWIGEXCODE) CONST TYPE {
@ -435,75 +435,75 @@
return new $typemap(cstype, TYPE)($imcall, true);
}
%typemap(csout, excode=SWIGEXCODE) CONST TYPE * {
IntPtr cPtr = $imcall;
return (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
global::System.IntPtr cPtr = $imcall;
return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
}
%typemap(csout, excode=SWIGEXCODE) TYPE *CONST& {
IntPtr cPtr = $imcall;
return (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
global::System.IntPtr cPtr = $imcall;
return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
}
// Base proxy classes
%typemap(csbody) TYPE %{
private HandleRef swigCPtr;
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
private bool swigCMemOwnBase;
PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) {
PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) {
swigCMemOwnBase = cMemoryOwn;
swigCPtr = new HandleRef(this, cPtr);
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}
CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) {
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
%}
// Derived proxy classes
%typemap(csbody_derived) TYPE %{
private HandleRef swigCPtr;
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
private bool swigCMemOwnDerived;
PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
swigCMemOwnDerived = cMemoryOwn;
swigCPtr = new HandleRef(this, cPtr);
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}
CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) {
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
%}
%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE {
lock(this) {
if (swigCPtr.Handle != IntPtr.Zero) {
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
if (swigCMemOwnBase) {
swigCMemOwnBase = false;
$imcall;
}
swigCPtr = new HandleRef(null, IntPtr.Zero);
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
GC.SuppressFinalize(this);
global::System.GC.SuppressFinalize(this);
}
}
%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE {
lock(this) {
if (swigCPtr.Handle != IntPtr.Zero) {
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
if (swigCMemOwnDerived) {
swigCMemOwnDerived = false;
$imcall;
}
swigCPtr = new HandleRef(null, IntPtr.Zero);
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
GC.SuppressFinalize(this);
global::System.GC.SuppressFinalize(this);
base.Dispose();
}
}
// CONST version needed ???? also for C#
%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "HandleRef"
%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "HandleRef"
%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;

View file

@ -95,10 +95,10 @@
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "void *"
%typemap (imtype, out="IntPtr") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
%typemap (imtype, out="global::System.IntPtr") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "HandleRef"
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "global::System.Runtime.InteropServices.HandleRef"
%typemap (cstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
@ -110,23 +110,23 @@
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(cstype, TYPE).getCPtr($csinput)"
%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
global::System.IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
return ret;
}
%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & {
IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
global::System.IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
return ret;
}
%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * {
IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
global::System.IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
return ret;
}
%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
global::System.IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
return ret;
}
@ -140,13 +140,13 @@
return ret;
}
%typemap(csout, excode=SWIGEXCODE) CONST TYPE * {
IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
global::System.IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
return ret;
}
%typemap(csout, excode=SWIGEXCODE) TYPE *CONST& {
IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
global::System.IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
return ret;
}
@ -157,78 +157,78 @@
} %}
%typemap(csvarout, excode=SWIGEXCODE2) CONST TYPE * %{
get {
IntPtr cPtr = $imcall;
$csclassname ret = (cPtr == IntPtr.Zero) ? null : new $csclassname(cPtr, true);$excode
global::System.IntPtr cPtr = $imcall;
$csclassname ret = (cPtr == global::System.IntPtr.Zero) ? null : new $csclassname(cPtr, true);$excode
return ret;
} %}
%typemap(csvarout, excode=SWIGEXCODE2) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{
get {
IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
global::System.IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
return ret;
} %}
%typemap(csvarout, excode=SWIGEXCODE2) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{
get {
IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
global::System.IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
return ret;
} %}
// Proxy classes (base classes, ie, not derived classes)
%typemap(csbody) TYPE %{
private HandleRef swigCPtr;
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
private bool swigCMemOwnBase;
PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) {
PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) {
swigCMemOwnBase = cMemoryOwn;
swigCPtr = new HandleRef(this, cPtr);
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}
CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) {
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
%}
// Derived proxy classes
%typemap(csbody_derived) TYPE %{
private HandleRef swigCPtr;
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
private bool swigCMemOwnDerived;
PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
swigCMemOwnDerived = cMemoryOwn;
swigCPtr = new HandleRef(this, cPtr);
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}
CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) {
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
%}
%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE {
lock(this) {
if (swigCPtr.Handle != IntPtr.Zero) {
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
if (swigCMemOwnBase) {
swigCMemOwnBase = false;
$imcall;
}
swigCPtr = new HandleRef(null, IntPtr.Zero);
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
GC.SuppressFinalize(this);
global::System.GC.SuppressFinalize(this);
}
}
%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE {
lock(this) {
if (swigCPtr.Handle != IntPtr.Zero) {
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
if (swigCMemOwnDerived) {
swigCMemOwnDerived = false;
$imcall;
}
swigCPtr = new HandleRef(null, IntPtr.Zero);
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
GC.SuppressFinalize(this);
global::System.GC.SuppressFinalize(this);
base.Dispose();
}
}

View file

@ -11,16 +11,34 @@
* The imtype typemap contains the C# type used in the intermediary class.
* The cstype typemap contains the C# type used in the C# proxy classes, type wrapper classes and module class. */
/* SWIG 3 no longer inserts using directives into generated C# code. For backwards compatibility, the SWIG2_CSHARP
macro can be defined to have SWIG 3 generate using directives similar to those generated by SWIG 2. */
#ifdef SWIG2_CSHARP
%typemap(csimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "\nusing global::System;\nusing global::System.Runtime.InteropServices;\n"
%pragma(csharp) moduleimports=%{
using global::System;
using global::System.Runtime.InteropServices;
%}
%pragma(csharp) imclassimports=%{
using global::System;
using global::System.Runtime.InteropServices;
%}
#endif
/* Fragments */
%fragment("SWIG_PackData", "header") {
/* Pack binary data into a string */
SWIGINTERN char * SWIG_PackData(char *c, void *ptr, size_t sz) {
static const char hex[17] = "0123456789abcdef";
register const unsigned char *u = (unsigned char *) ptr;
register const unsigned char *eu = u + sz;
const unsigned char *u = (unsigned char *) ptr;
const unsigned char *eu = u + sz;
for (; u != eu; ++u) {
register unsigned char uu = *u;
unsigned char uu = *u;
*(c++) = hex[(uu & 0xf0) >> 4];
*(c++) = hex[uu & 0xf];
}
@ -31,11 +49,11 @@ SWIGINTERN char * SWIG_PackData(char *c, void *ptr, size_t sz) {
%fragment("SWIG_UnPackData", "header") {
/* Unpack binary data from a string */
SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
register unsigned char *u = (unsigned char *) ptr;
register const unsigned char *eu = u + sz;
unsigned char *u = (unsigned char *) ptr;
const unsigned char *eu = u + sz;
for (; u != eu; ++u) {
register char d = *(c++);
register unsigned char uu;
char d = *(c++);
unsigned char uu;
if ((d >= '0') && (d <= '9'))
uu = ((d - '0') << 4);
else if ((d >= 'a') && (d <= 'f'))
@ -110,21 +128,25 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
/* Non primitive types */
%typemap(ctype) SWIGTYPE "void *"
%typemap(imtype, out="IntPtr") SWIGTYPE "HandleRef"
%typemap(imtype, out="global::System.IntPtr") SWIGTYPE "global::System.Runtime.InteropServices.HandleRef"
%typemap(cstype) SWIGTYPE "$&csclassname"
%typemap(ctype) SWIGTYPE [] "void *"
%typemap(imtype, out="IntPtr") SWIGTYPE [] "HandleRef"
%typemap(imtype, out="global::System.IntPtr") SWIGTYPE [] "global::System.Runtime.InteropServices.HandleRef"
%typemap(cstype) SWIGTYPE [] "$csclassname"
%typemap(ctype) SWIGTYPE * "void *"
%typemap(imtype, out="IntPtr") SWIGTYPE * "HandleRef"
%typemap(imtype, out="global::System.IntPtr") SWIGTYPE * "global::System.Runtime.InteropServices.HandleRef"
%typemap(cstype) SWIGTYPE * "$csclassname"
%typemap(ctype) SWIGTYPE & "void *"
%typemap(imtype, out="IntPtr") SWIGTYPE & "HandleRef"
%typemap(imtype, out="global::System.IntPtr") SWIGTYPE & "global::System.Runtime.InteropServices.HandleRef"
%typemap(cstype) SWIGTYPE & "$csclassname"
%typemap(ctype) SWIGTYPE && "void *"
%typemap(imtype, out="global::System.IntPtr") SWIGTYPE && "global::System.Runtime.InteropServices.HandleRef"
%typemap(cstype) SWIGTYPE && "$csclassname"
/* pointer to a class member */
%typemap(ctype) SWIGTYPE (CLASS::*) "char *"
%typemap(imtype) SWIGTYPE (CLASS::*) "string"
@ -401,6 +423,11 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type type is null", 0);
return $null;
} %}
%typemap(in, canthrow=1) SWIGTYPE && %{ $1 = ($1_ltype)$input;
if (!$1) {
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type type is null", 0);
return $null;
} %}
%typemap(out) SWIGTYPE * %{ $result = (void *)$1; %}
%typemap(out, fragment="SWIG_PackData") SWIGTYPE (CLASS::*) %{
char buf[128];
@ -409,6 +436,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
$result = SWIG_csharp_string_callback(buf);
%}
%typemap(out) SWIGTYPE & %{ $result = (void *)$1; %}
%typemap(out) SWIGTYPE && %{ $result = (void *)$1; %}
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *
%{ $result = ($1_ltype)$input; %}
@ -421,6 +449,12 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%{ $input = (void *) $1; %}
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &
%{ if (!$input) {
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Unexpected null return for type $1_type", 0);
return $null;
}
$result = ($1_ltype)$input; %}
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &&
%{ if (!$input) {
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Unexpected null return for type $1_type", 0);
return $null;
@ -428,10 +462,13 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
$result = ($1_ltype)$input; %}
%typemap(directorin) SWIGTYPE &
%{ $input = ($1_ltype) &$1; %}
%typemap(directorin) SWIGTYPE &&
%{ $input = ($1_ltype) &$1; %}
%typemap(csdirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*) "($iminput == IntPtr.Zero) ? null : new $csclassname($iminput, false)"
%typemap(csdirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*) "($iminput == global::System.IntPtr.Zero) ? null : new $csclassname($iminput, false)"
%typemap(csdirectorin) SWIGTYPE & "new $csclassname($iminput, false)"
%typemap(csdirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "$csclassname.getCPtr($cscall).Handle"
%typemap(csdirectorin) SWIGTYPE && "new $csclassname($iminput, false)"
%typemap(csdirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE &, SWIGTYPE && "$csclassname.getCPtr($cscall).Handle"
/* Default array handling */
%typemap(in) SWIGTYPE [] %{ $1 = ($1_ltype)$input; %}
@ -526,6 +563,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
SWIGTYPE,
SWIGTYPE *,
SWIGTYPE &,
SWIGTYPE &&,
SWIGTYPE *const&,
SWIGTYPE [],
SWIGTYPE (CLASS::*)
@ -544,7 +582,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, error_msg);
return $null; %}
%typemap(throws, canthrow=1) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY]
%typemap(throws, canthrow=1) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *, SWIGTYPE [ANY]
%{ (void)$1;
SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown");
return $null; %}
@ -575,7 +613,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
"$csinput"
%typemap(csin) char *, char *&, char[ANY], char[] "$csinput"
%typemap(csin) SWIGTYPE "$&csclassname.getCPtr($csinput)"
%typemap(csin) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] "$csclassname.getCPtr($csinput)"
%typemap(csin) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] "$csclassname.getCPtr($csinput)"
%typemap(csin) SWIGTYPE (CLASS::*) "$csclassname.getCMemberPtr($csinput)"
/* The csout typemap is used for converting function return types from the return type
@ -658,9 +696,13 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
$csclassname ret = new $csclassname($imcall, $owner);$excode
return ret;
}
%typemap(csout, excode=SWIGEXCODE) SWIGTYPE && {
$csclassname ret = new $csclassname($imcall, $owner);$excode
return ret;
}
%typemap(csout, excode=SWIGEXCODE) SWIGTYPE *, SWIGTYPE [] {
IntPtr cPtr = $imcall;
$csclassname ret = (cPtr == IntPtr.Zero) ? null : new $csclassname(cPtr, $owner);$excode
global::System.IntPtr cPtr = $imcall;
$csclassname ret = (cPtr == global::System.IntPtr.Zero) ? null : new $csclassname(cPtr, $owner);$excode
return ret;
}
%typemap(csout, excode=SWIGEXCODE) SWIGTYPE (CLASS::*) {
@ -671,7 +713,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
/* Properties */
%typemap(csvarin, excode=SWIGEXCODE2) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
%typemap(csvarin, excode=SWIGEXCODE2) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
set {
$imcall;$excode
} %}
@ -772,10 +814,15 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
$csclassname ret = new $csclassname($imcall, $owner);$excode
return ret;
} %}
%typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE && %{
get {
$csclassname ret = new $csclassname($imcall, $owner);$excode
return ret;
} %}
%typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE *, SWIGTYPE [] %{
get {
IntPtr cPtr = $imcall;
$csclassname ret = (cPtr == IntPtr.Zero) ? null : new $csclassname(cPtr, $owner);$excode
global::System.IntPtr cPtr = $imcall;
$csclassname ret = (cPtr == global::System.IntPtr.Zero) ? null : new $csclassname(cPtr, $owner);$excode
return ret;
} %}
@ -788,12 +835,12 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
/* Pointer reference typemaps */
%typemap(ctype) SWIGTYPE *const& "void *"
%typemap(imtype, out="IntPtr") SWIGTYPE *const& "HandleRef"
%typemap(imtype, out="global::System.IntPtr") SWIGTYPE *const& "global::System.Runtime.InteropServices.HandleRef"
%typemap(cstype) SWIGTYPE *const& "$*csclassname"
%typemap(csin) SWIGTYPE *const& "$*csclassname.getCPtr($csinput)"
%typemap(csout, excode=SWIGEXCODE) SWIGTYPE *const& {
IntPtr cPtr = $imcall;
$*csclassname ret = (cPtr == IntPtr.Zero) ? null : new $*csclassname(cPtr, $owner);$excode
global::System.IntPtr cPtr = $imcall;
$*csclassname ret = (cPtr == global::System.IntPtr.Zero) ? null : new $*csclassname(cPtr, $owner);$excode
return ret;
}
%typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0)
@ -802,27 +849,26 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%typemap(out) SWIGTYPE *const&
%{ $result = (void *)*$1; %}
/* Marshal C/C++ pointer to IntPtr */
/* Marshal C/C++ pointer to global::System.IntPtr */
%typemap(ctype) void *VOID_INT_PTR "void *"
%typemap(imtype) void *VOID_INT_PTR "IntPtr"
%typemap(cstype) void *VOID_INT_PTR "IntPtr"
%typemap(imtype) void *VOID_INT_PTR "global::System.IntPtr"
%typemap(cstype) void *VOID_INT_PTR "global::System.IntPtr"
%typemap(in) void *VOID_INT_PTR %{ $1 = ($1_ltype)$input; %}
%typemap(out) void *VOID_INT_PTR %{ $result = (void *)$1; %}
%typemap(csin) void *VOID_INT_PTR "$csinput"
%typemap(csout, excode=SWIGEXCODE) void *VOID_INT_PTR {
IntPtr ret = $imcall;$excode
global::System.IntPtr ret = $imcall;$excode
return ret;
}
/* Typemaps used for the generation of proxy and type wrapper class code */
%typemap(csbase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(csclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class"
%typemap(cscode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(csimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "\nusing System;\nusing System.Runtime.InteropServices;\n"
%typemap(csinterfaces) SWIGTYPE "IDisposable"
%typemap(csinterfaces) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(csinterfaces_derived) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(csbase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(csclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class"
%typemap(cscode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(csinterfaces) SWIGTYPE "global::System.IDisposable"
%typemap(csinterfaces) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(csinterfaces_derived) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
// csbody typemaps... these are in macros so that the visibility of the methods can be easily changed by users.
@ -830,48 +876,48 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%define SWIG_CSBODY_PROXY(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...)
// Proxy classes (base classes, ie, not derived classes)
%typemap(csbody) TYPE %{
private HandleRef swigCPtr;
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
protected bool swigCMemOwn;
PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) {
PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
swigCPtr = new HandleRef(this, cPtr);
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}
CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) {
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
%}
// Derived proxy classes
%typemap(csbody_derived) TYPE %{
private HandleRef swigCPtr;
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGUpcast(cPtr), cMemoryOwn) {
swigCPtr = new HandleRef(this, cPtr);
PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGUpcast(cPtr), cMemoryOwn) {
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}
CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) {
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
%}
%enddef
%define SWIG_CSBODY_TYPEWRAPPER(PTRCTOR_VISIBILITY, DEFAULTCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...)
// Typewrapper classes
%typemap(csbody) TYPE *, TYPE &, TYPE [] %{
private HandleRef swigCPtr;
%typemap(csbody) TYPE *, TYPE &, TYPE &&, TYPE [] %{
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool futureUse) {
swigCPtr = new HandleRef(this, cPtr);
PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool futureUse) {
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}
DEFAULTCTOR_VISIBILITY $csclassname() {
swigCPtr = new HandleRef(null, IntPtr.Zero);
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) {
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
%}
@ -909,27 +955,27 @@ SWIG_CSBODY_TYPEWRAPPER(internal, protected, internal, SWIGTYPE)
%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") SWIGTYPE {
lock(this) {
if (swigCPtr.Handle != IntPtr.Zero) {
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
if (swigCMemOwn) {
swigCMemOwn = false;
$imcall;
}
swigCPtr = new HandleRef(null, IntPtr.Zero);
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
GC.SuppressFinalize(this);
global::System.GC.SuppressFinalize(this);
}
}
%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") SWIGTYPE {
lock(this) {
if (swigCPtr.Handle != IntPtr.Zero) {
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
if (swigCMemOwn) {
swigCMemOwn = false;
$imcall;
}
swigCPtr = new HandleRef(null, IntPtr.Zero);
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
GC.SuppressFinalize(this);
global::System.GC.SuppressFinalize(this);
base.Dispose();
}
}
@ -952,16 +998,6 @@ SWIG_CSBODY_TYPEWRAPPER(internal, protected, internal, SWIGTYPE)
%pragma(csharp) imclassclassmodifiers="class"
%pragma(csharp) moduleclassmodifiers="public class"
%pragma(csharp) moduleimports=%{
using System;
using System.Runtime.InteropServices;
%}
%pragma(csharp) imclassimports=%{
using System;
using System.Runtime.InteropServices;
%}
/* Some ANSI C typemaps */
%apply unsigned long { size_t };
@ -969,6 +1005,7 @@ using System.Runtime.InteropServices;
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
@ -985,23 +1022,23 @@ using System.Runtime.InteropServices;
/*
// Alternative char * typemaps.
%pragma(csharp) imclasscode=%{
public class SWIGStringMarshal : IDisposable {
public readonly HandleRef swigCPtr;
public class SWIGStringMarshal : global::System.IDisposable {
public readonly global::System.Runtime.InteropServices.HandleRef swigCPtr;
public SWIGStringMarshal(string str) {
swigCPtr = new HandleRef(this, System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(str));
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, global::System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(str));
}
public virtual void Dispose() {
System.Runtime.InteropServices.Marshal.FreeHGlobal(swigCPtr.Handle);
GC.SuppressFinalize(this);
global::System.Runtime.InteropServices.Marshal.FreeHGlobal(swigCPtr.Handle);
global::System.GC.SuppressFinalize(this);
}
}
%}
%typemap(imtype, out="IntPtr") char *, char[ANY], char[] "HandleRef"
%typemap(imtype, out="global::System.IntPtr") char *, char[ANY], char[] "global::System.Runtime.InteropServices.HandleRef"
%typemap(out) char *, char[ANY], char[] %{ $result = $1; %}
%typemap(csin) char *, char[ANY], char[] "new $imclassname.SWIGStringMarshal($csinput).swigCPtr"
%typemap(csout, excode=SWIGEXCODE) char *, char[ANY], char[] {
string ret = System.Runtime.InteropServices.Marshal.PtrToStringAnsi($imcall);$excode
string ret = global::System.Runtime.InteropServices.Marshal.PtrToStringAnsi($imcall);$excode
return ret;
}
%typemap(csvarin, excode=SWIGEXCODE2) char *, char[ANY], char[] %{
@ -1010,7 +1047,7 @@ using System.Runtime.InteropServices;
} %}
%typemap(csvarout, excode=SWIGEXCODE2) char *, char[ANY], char[] %{
get {
string ret = System.Runtime.InteropServices.Marshal.PtrToStringAnsi($imcall);$excode
string ret = global::System.Runtime.InteropServices.Marshal.PtrToStringAnsi($imcall);$excode
return ret;
} %}
*/

View file

@ -149,7 +149,7 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_$module(
static ExceptionArgumentDelegate argumentNullDelegate = new ExceptionArgumentDelegate(SetPendingArgumentNullException);
static ExceptionArgumentDelegate argumentOutOfRangeDelegate = new ExceptionArgumentDelegate(SetPendingArgumentOutOfRangeException);
[DllImport("$dllimport", EntryPoint="SWIGRegisterExceptionCallbacks_$module")]
[global::System.Runtime.InteropServices.DllImport("$dllimport", EntryPoint="SWIGRegisterExceptionCallbacks_$module")]
public static extern void SWIGRegisterExceptionCallbacks_$module(
ExceptionDelegate applicationDelegate,
ExceptionDelegate arithmeticDelegate,
@ -163,58 +163,58 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_$module(
ExceptionDelegate overflowDelegate,
ExceptionDelegate systemExceptionDelegate);
[DllImport("$dllimport", EntryPoint="SWIGRegisterExceptionArgumentCallbacks_$module")]
[global::System.Runtime.InteropServices.DllImport("$dllimport", EntryPoint="SWIGRegisterExceptionArgumentCallbacks_$module")]
public static extern void SWIGRegisterExceptionCallbacksArgument_$module(
ExceptionArgumentDelegate argumentDelegate,
ExceptionArgumentDelegate argumentNullDelegate,
ExceptionArgumentDelegate argumentOutOfRangeDelegate);
static void SetPendingApplicationException(string message) {
SWIGPendingException.Set(new System.ApplicationException(message, SWIGPendingException.Retrieve()));
SWIGPendingException.Set(new global::System.ApplicationException(message, SWIGPendingException.Retrieve()));
}
static void SetPendingArithmeticException(string message) {
SWIGPendingException.Set(new System.ArithmeticException(message, SWIGPendingException.Retrieve()));
SWIGPendingException.Set(new global::System.ArithmeticException(message, SWIGPendingException.Retrieve()));
}
static void SetPendingDivideByZeroException(string message) {
SWIGPendingException.Set(new System.DivideByZeroException(message, SWIGPendingException.Retrieve()));
SWIGPendingException.Set(new global::System.DivideByZeroException(message, SWIGPendingException.Retrieve()));
}
static void SetPendingIndexOutOfRangeException(string message) {
SWIGPendingException.Set(new System.IndexOutOfRangeException(message, SWIGPendingException.Retrieve()));
SWIGPendingException.Set(new global::System.IndexOutOfRangeException(message, SWIGPendingException.Retrieve()));
}
static void SetPendingInvalidCastException(string message) {
SWIGPendingException.Set(new System.InvalidCastException(message, SWIGPendingException.Retrieve()));
SWIGPendingException.Set(new global::System.InvalidCastException(message, SWIGPendingException.Retrieve()));
}
static void SetPendingInvalidOperationException(string message) {
SWIGPendingException.Set(new System.InvalidOperationException(message, SWIGPendingException.Retrieve()));
SWIGPendingException.Set(new global::System.InvalidOperationException(message, SWIGPendingException.Retrieve()));
}
static void SetPendingIOException(string message) {
SWIGPendingException.Set(new System.IO.IOException(message, SWIGPendingException.Retrieve()));
SWIGPendingException.Set(new global::System.IO.IOException(message, SWIGPendingException.Retrieve()));
}
static void SetPendingNullReferenceException(string message) {
SWIGPendingException.Set(new System.NullReferenceException(message, SWIGPendingException.Retrieve()));
SWIGPendingException.Set(new global::System.NullReferenceException(message, SWIGPendingException.Retrieve()));
}
static void SetPendingOutOfMemoryException(string message) {
SWIGPendingException.Set(new System.OutOfMemoryException(message, SWIGPendingException.Retrieve()));
SWIGPendingException.Set(new global::System.OutOfMemoryException(message, SWIGPendingException.Retrieve()));
}
static void SetPendingOverflowException(string message) {
SWIGPendingException.Set(new System.OverflowException(message, SWIGPendingException.Retrieve()));
SWIGPendingException.Set(new global::System.OverflowException(message, SWIGPendingException.Retrieve()));
}
static void SetPendingSystemException(string message) {
SWIGPendingException.Set(new System.SystemException(message, SWIGPendingException.Retrieve()));
SWIGPendingException.Set(new global::System.SystemException(message, SWIGPendingException.Retrieve()));
}
static void SetPendingArgumentException(string message, string paramName) {
SWIGPendingException.Set(new System.ArgumentException(message, paramName, SWIGPendingException.Retrieve()));
SWIGPendingException.Set(new global::System.ArgumentException(message, paramName, SWIGPendingException.Retrieve()));
}
static void SetPendingArgumentNullException(string message, string paramName) {
Exception e = SWIGPendingException.Retrieve();
global::System.Exception e = SWIGPendingException.Retrieve();
if (e != null) message = message + " Inner Exception: " + e.Message;
SWIGPendingException.Set(new System.ArgumentNullException(paramName, message));
SWIGPendingException.Set(new global::System.ArgumentNullException(paramName, message));
}
static void SetPendingArgumentOutOfRangeException(string message, string paramName) {
Exception e = SWIGPendingException.Retrieve();
global::System.Exception e = SWIGPendingException.Retrieve();
if (e != null) message = message + " Inner Exception: " + e.Message;
SWIGPendingException.Set(new System.ArgumentOutOfRangeException(paramName, message));
SWIGPendingException.Set(new global::System.ArgumentOutOfRangeException(paramName, message));
}
static SWIGExceptionHelper() {
@ -241,8 +241,8 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_$module(
protected static SWIGExceptionHelper swigExceptionHelper = new SWIGExceptionHelper();
public class SWIGPendingException {
[ThreadStatic]
private static Exception pendingException = null;
[global::System.ThreadStatic]
private static global::System.Exception pendingException = null;
private static int numExceptionsPending = 0;
public static bool Pending {
@ -255,17 +255,17 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_$module(
}
}
public static void Set(Exception e) {
public static void Set(global::System.Exception e) {
if (pendingException != null)
throw new ApplicationException("FATAL: An earlier pending exception from unmanaged code was missed and thus not thrown (" + pendingException.ToString() + ")", e);
throw new global::System.ApplicationException("FATAL: An earlier pending exception from unmanaged code was missed and thus not thrown (" + pendingException.ToString() + ")", e);
pendingException = e;
lock(typeof($imclassname)) {
numExceptionsPending++;
}
}
public static Exception Retrieve() {
Exception e = null;
public static global::System.Exception Retrieve() {
global::System.Exception e = null;
if (numExceptionsPending > 0) {
if (pendingException != null) {
e = pendingException;
@ -294,7 +294,7 @@ static SWIG_CSharpStringHelperCallback SWIG_csharp_string_callback = NULL;
public delegate string SWIGStringDelegate(string message);
static SWIGStringDelegate stringDelegate = new SWIGStringDelegate(CreateString);
[DllImport("$dllimport", EntryPoint="SWIGRegisterStringCallback_$module")]
[global::System.Runtime.InteropServices.DllImport("$dllimport", EntryPoint="SWIGRegisterStringCallback_$module")]
public static extern void SWIGRegisterStringCallback_$module(SWIGStringDelegate stringDelegate);
static string CreateString(string cString) {

View file

@ -4,6 +4,8 @@
/* Warnings for C# keywords */
#define CSHARPKW(x) %keywordwarn("'" `x` "' is a C# keyword, renaming to '_" `x` "'",rename="_%s") `x`
#define CSHARPCLASSKW(x) %keywordwarn("'" `x` "' is a special method name used in the C# wrapper classes, class renamed to '_" `x` "'",%$isclass,rename="_%s") `x`
/*
from
http://www.jaggersoft.com/csharp_grammar.html#1.7%20Keywords
@ -88,6 +90,7 @@ CSHARPKW(void);
CSHARPKW(volatile);
CSHARPKW(while);
CSHARPCLASSKW(delete);
#undef CSHARPKW

View file

@ -1,16 +1,15 @@
/* -----------------------------------------------------------------------------
* director.swg
*
* This file contains support for director classes so that C# proxy
* This file contains support for director classes so that C# proxy
* methods can be called from C++.
* ----------------------------------------------------------------------------- */
#ifdef __cplusplus
#if defined(DEBUG_DIRECTOR_OWNED)
#include <iostream>
#endif
#include <string>
#include <exception>
namespace Swig {
/* Director base class - not currently used in C# directors */
@ -18,30 +17,30 @@ namespace Swig {
};
/* Base class for director exceptions */
class DirectorException {
class DirectorException : public std::exception {
protected:
std::string swig_msg;
public:
DirectorException(const char* msg) : swig_msg(msg) {
DirectorException(const char *msg) : swig_msg(msg) {
}
DirectorException(const std::string &msg) : swig_msg(msg) {
}
const std::string& what() const {
return swig_msg;
virtual ~DirectorException() throw() {
}
virtual ~DirectorException() {
const char *what() const throw() {
return swig_msg.c_str();
}
};
/* Pure virtual method exception */
class DirectorPureVirtualException : public Swig::DirectorException {
class DirectorPureVirtualException : public DirectorException {
public:
DirectorPureVirtualException(const char* msg) : DirectorException(std::string("Attempt to invoke pure virtual method ") + msg) {
DirectorPureVirtualException(const char *msg) : DirectorException(std::string("Attempt to invoke pure virtual method ") + msg) {
}
};
}
#endif /* __cplusplus */

View file

@ -13,7 +13,7 @@
%typemap(in) const enum SWIGTYPE & ($*1_ltype temp)
%{ temp = ($*1_ltype)$input;
$1 = &temp; %}
%typemap(out) const enum SWIGTYPE & %{ $result = *$1; %}
%typemap(out) const enum SWIGTYPE & %{ $result = (int)*$1; %}
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE &
%{ static $*1_ltype temp = ($*1_ltype)$input;
@ -48,7 +48,7 @@
%typemap(cstype) enum SWIGTYPE "$csclassname"
%typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %}
%typemap(out) enum SWIGTYPE %{ $result = $1; %}
%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %}
%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
%typemap(directorin) enum SWIGTYPE "$input = $1;"

View file

@ -15,7 +15,7 @@
%typemap(in) const enum SWIGTYPE & ($*1_ltype temp)
%{ temp = ($*1_ltype)$input;
$1 = &temp; %}
%typemap(out) const enum SWIGTYPE & %{ $result = *$1; %}
%typemap(out) const enum SWIGTYPE & %{ $result = (int)*$1; %}
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE &
%{ static $*1_ltype temp = ($*1_ltype)$input;
@ -50,7 +50,7 @@
%typemap(cstype) enum SWIGTYPE "int"
%typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %}
%typemap(out) enum SWIGTYPE %{ $result = $1; %}
%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %}
%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
%typemap(directorin) enum SWIGTYPE "$input = $1;"

View file

@ -14,7 +14,7 @@
%typemap(in) const enum SWIGTYPE & ($*1_ltype temp)
%{ temp = ($*1_ltype)$input;
$1 = &temp; %}
%typemap(out) const enum SWIGTYPE & %{ $result = *$1; %}
%typemap(out) const enum SWIGTYPE & %{ $result = (int)*$1; %}
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE &
%{ static $*1_ltype temp = ($*1_ltype)$input;
@ -49,7 +49,7 @@
%typemap(cstype) enum SWIGTYPE "$csclassname"
%typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %}
%typemap(out) enum SWIGTYPE %{ $result = $1; %}
%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %}
%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
%typemap(directorin) enum SWIGTYPE "$input = $1;"
@ -97,7 +97,7 @@
for (int i = 0; i < swigValues.Length; i++)
if (swigValues[i].swigValue == swigValue)
return swigValues[i];
throw new System.ArgumentOutOfRangeException("No enum $csclassname with value " + swigValue);
throw new global::System.ArgumentOutOfRangeException("No enum $csclassname with value " + swigValue);
}
public override string ToString() {

25
Lib/csharp/std_auto_ptr.i Normal file
View file

@ -0,0 +1,25 @@
/*
The typemaps here allow to handle 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).
*/
%define %auto_ptr(TYPE)
%typemap (ctype) std::auto_ptr<TYPE > "void *"
%typemap (imtype, out="System.IntPtr") std::auto_ptr<TYPE > "HandleRef"
%typemap (cstype) std::auto_ptr<TYPE > "$typemap(cstype, TYPE)"
%typemap (out) std::auto_ptr<TYPE > %{
$result = (void *)$1.release();
%}
%typemap(csout, excode=SWIGEXCODE) std::auto_ptr<TYPE > {
System.IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
return ret;
}
%template() std::auto_ptr<TYPE >;
%enddef
namespace std {
template <class T> class auto_ptr {};
}

View file

@ -11,9 +11,7 @@
* %template(MapIntDouble) std::map<int, double>
*
* Notes:
* 1) For .NET 1 compatibility, define SWIG_DOTNET_1 when compiling the C# code. In this case
* the C# wrapper has only basic functionality.
* 2) IEnumerable<> is implemented in the proxy class which is useful for using LINQ with
* 1) IEnumerable<> is implemented in the proxy class which is useful for using LINQ with
* C++ std::map wrappers.
*
* Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents!
@ -28,7 +26,7 @@
/* K is the C++ key type, T is the C++ value type */
%define SWIG_STD_MAP_INTERNAL(K, T, C)
%typemap(csinterfaces) std::map< K, T, C > "IDisposable \n#if !SWIG_DOTNET_1\n , System.Collections.Generic.IDictionary<$typemap(cstype, K), $typemap(cstype, T)>\n#endif\n";
%typemap(csinterfaces) std::map< K, T, C > "global::System.IDisposable \n , global::System.Collections.Generic.IDictionary<$typemap(cstype, K), $typemap(cstype, T)>\n";
%typemap(cscode) std::map<K, T, C > %{
public $typemap(cstype, T) this[$typemap(cstype, K) key] {
@ -62,14 +60,12 @@
}
}
#if !SWIG_DOTNET_1
public System.Collections.Generic.ICollection<$typemap(cstype, K)> Keys {
public global::System.Collections.Generic.ICollection<$typemap(cstype, K)> Keys {
get {
System.Collections.Generic.ICollection<$typemap(cstype, K)> keys = new System.Collections.Generic.List<$typemap(cstype, K)>();
global::System.Collections.Generic.ICollection<$typemap(cstype, K)> keys = new global::System.Collections.Generic.List<$typemap(cstype, K)>();
int size = this.Count;
if (size > 0) {
IntPtr iter = create_iterator_begin();
global::System.IntPtr iter = create_iterator_begin();
for (int i = 0; i < size; i++) {
keys.Add(get_next_key(iter));
}
@ -79,21 +75,21 @@
}
}
public System.Collections.Generic.ICollection<$typemap(cstype, T)> Values {
public global::System.Collections.Generic.ICollection<$typemap(cstype, T)> Values {
get {
System.Collections.Generic.ICollection<$typemap(cstype, T)> vals = new System.Collections.Generic.List<$typemap(cstype, T)>();
foreach (System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> pair in this) {
global::System.Collections.Generic.ICollection<$typemap(cstype, T)> vals = new global::System.Collections.Generic.List<$typemap(cstype, T)>();
foreach (global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> pair in this) {
vals.Add(pair.Value);
}
return vals;
}
}
public void Add(System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) {
public void Add(global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) {
Add(item.Key, item.Value);
}
public bool Remove(System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) {
public bool Remove(global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) {
if (Contains(item)) {
return Remove(item.Key);
} else {
@ -101,7 +97,7 @@
}
}
public bool Contains(System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) {
public bool Contains(global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) {
if (this[item.Key] == item.Value) {
return true;
} else {
@ -109,32 +105,32 @@
}
}
public void CopyTo(System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>[] array) {
public void CopyTo(global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>[] array) {
CopyTo(array, 0);
}
public void CopyTo(System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>[] array, int arrayIndex) {
public void CopyTo(global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>[] array, int arrayIndex) {
if (array == null)
throw new ArgumentNullException("array");
throw new global::System.ArgumentNullException("array");
if (arrayIndex < 0)
throw new ArgumentOutOfRangeException("arrayIndex", "Value is less than zero");
throw new global::System.ArgumentOutOfRangeException("arrayIndex", "Value is less than zero");
if (array.Rank > 1)
throw new ArgumentException("Multi dimensional array.", "array");
throw new global::System.ArgumentException("Multi dimensional array.", "array");
if (arrayIndex+this.Count > array.Length)
throw new ArgumentException("Number of elements to copy is too large.");
throw new global::System.ArgumentException("Number of elements to copy is too large.");
System.Collections.Generic.IList<$typemap(cstype, K)> keyList = new System.Collections.Generic.List<$typemap(cstype, K)>(this.Keys);
global::System.Collections.Generic.IList<$typemap(cstype, K)> keyList = new global::System.Collections.Generic.List<$typemap(cstype, K)>(this.Keys);
for (int i = 0; i < keyList.Count; i++) {
$typemap(cstype, K) currentKey = keyList[i];
array.SetValue(new System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>(currentKey, this[currentKey]), arrayIndex+i);
array.SetValue(new global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>(currentKey, this[currentKey]), arrayIndex+i);
}
}
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>>.GetEnumerator() {
global::System.Collections.Generic.IEnumerator<global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>> global::System.Collections.Generic.IEnumerable<global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>>.GetEnumerator() {
return new $csclassnameEnumerator(this);
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() {
return new $csclassnameEnumerator(this);
}
@ -147,38 +143,38 @@
/// whenever the collection is modified. This has been done for changes in the size of the
/// collection but not when one of the elements of the collection is modified as it is a bit
/// tricky to detect unmanaged code that modifies the collection under our feet.
public sealed class $csclassnameEnumerator : System.Collections.IEnumerator,
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>>
public sealed class $csclassnameEnumerator : global::System.Collections.IEnumerator,
global::System.Collections.Generic.IEnumerator<global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>>
{
private $csclassname collectionRef;
private System.Collections.Generic.IList<$typemap(cstype, K)> keyCollection;
private global::System.Collections.Generic.IList<$typemap(cstype, K)> keyCollection;
private int currentIndex;
private object currentObject;
private int currentSize;
public $csclassnameEnumerator($csclassname collection) {
collectionRef = collection;
keyCollection = new System.Collections.Generic.List<$typemap(cstype, K)>(collection.Keys);
keyCollection = new global::System.Collections.Generic.List<$typemap(cstype, K)>(collection.Keys);
currentIndex = -1;
currentObject = null;
currentSize = collectionRef.Count;
}
// Type-safe iterator Current
public System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> Current {
public global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> Current {
get {
if (currentIndex == -1)
throw new InvalidOperationException("Enumeration not started.");
throw new global::System.InvalidOperationException("Enumeration not started.");
if (currentIndex > currentSize - 1)
throw new InvalidOperationException("Enumeration finished.");
throw new global::System.InvalidOperationException("Enumeration finished.");
if (currentObject == null)
throw new InvalidOperationException("Collection modified.");
return (System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>)currentObject;
throw new global::System.InvalidOperationException("Collection modified.");
return (global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>)currentObject;
}
}
// Type-unsafe IEnumerator.Current
object System.Collections.IEnumerator.Current {
object global::System.Collections.IEnumerator.Current {
get {
return Current;
}
@ -190,7 +186,7 @@
if (moveOkay) {
currentIndex++;
$typemap(cstype, K) currentKey = keyCollection[currentIndex];
currentObject = new System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>(currentKey, collectionRef[currentKey]);
currentObject = new global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>(currentKey, collectionRef[currentKey]);
} else {
currentObject = null;
}
@ -201,7 +197,7 @@
currentIndex = -1;
currentObject = null;
if (collectionRef.Count != currentSize) {
throw new InvalidOperationException("Collection modified.");
throw new global::System.InvalidOperationException("Collection modified.");
}
}
@ -210,7 +206,6 @@
currentObject = null;
}
}
#endif
%}

View file

@ -4,8 +4,6 @@
* SWIG typemaps for std::vector<T>
* C# implementation
* The C# wrapper is made to look and feel like a C# System.Collections.Generic.List<> collection.
* For .NET 1 compatibility, define SWIG_DOTNET_1 when compiling the C# code; then the C# wrapper is
* made to look and feel like a typesafe C# System.Collections.ArrayList.
*
* Note that IEnumerable<> is implemented in the proxy class which is useful for using LINQ with
* C++ std::vector wrappers. The IList<> interface is also implemented to provide enhanced functionality
@ -26,11 +24,11 @@
// MACRO for use within the std::vector class body
%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE, CTYPE...)
%typemap(csinterfaces) std::vector< CTYPE > "IDisposable, System.Collections.IEnumerable\n#if !SWIG_DOTNET_1\n , System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n#endif\n";
%typemap(csinterfaces) std::vector< CTYPE > "global::System.IDisposable, global::System.Collections.IEnumerable\n , global::System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n";
%typemap(cscode) std::vector< CTYPE > %{
public $csclassname(System.Collections.ICollection c) : this() {
public $csclassname(global::System.Collections.ICollection c) : this() {
if (c == null)
throw new ArgumentNullException("c");
throw new global::System.ArgumentNullException("c");
foreach ($typemap(cstype, CTYPE) element in c) {
this.Add(element);
}
@ -63,7 +61,7 @@
}
set {
if (value < size())
throw new ArgumentOutOfRangeException("Capacity");
throw new global::System.ArgumentOutOfRangeException("Capacity");
reserve((uint)value);
}
}
@ -80,53 +78,39 @@
}
}
#if SWIG_DOTNET_1
public void CopyTo(System.Array array)
#else
public void CopyTo($typemap(cstype, CTYPE)[] array)
#endif
{
CopyTo(0, array, 0, this.Count);
}
#if SWIG_DOTNET_1
public void CopyTo(System.Array array, int arrayIndex)
#else
public void CopyTo($typemap(cstype, CTYPE)[] array, int arrayIndex)
#endif
{
CopyTo(0, array, arrayIndex, this.Count);
}
#if SWIG_DOTNET_1
public void CopyTo(int index, System.Array array, int arrayIndex, int count)
#else
public void CopyTo(int index, $typemap(cstype, CTYPE)[] array, int arrayIndex, int count)
#endif
{
if (array == null)
throw new ArgumentNullException("array");
throw new global::System.ArgumentNullException("array");
if (index < 0)
throw new ArgumentOutOfRangeException("index", "Value is less than zero");
throw new global::System.ArgumentOutOfRangeException("index", "Value is less than zero");
if (arrayIndex < 0)
throw new ArgumentOutOfRangeException("arrayIndex", "Value is less than zero");
throw new global::System.ArgumentOutOfRangeException("arrayIndex", "Value is less than zero");
if (count < 0)
throw new ArgumentOutOfRangeException("count", "Value is less than zero");
throw new global::System.ArgumentOutOfRangeException("count", "Value is less than zero");
if (array.Rank > 1)
throw new ArgumentException("Multi dimensional array.", "array");
throw new global::System.ArgumentException("Multi dimensional array.", "array");
if (index+count > this.Count || arrayIndex+count > array.Length)
throw new ArgumentException("Number of elements to copy is too large.");
throw new global::System.ArgumentException("Number of elements to copy is too large.");
for (int i=0; i<count; i++)
array.SetValue(getitemcopy(index+i), arrayIndex+i);
}
#if !SWIG_DOTNET_1
System.Collections.Generic.IEnumerator<$typemap(cstype, CTYPE)> System.Collections.Generic.IEnumerable<$typemap(cstype, CTYPE)>.GetEnumerator() {
global::System.Collections.Generic.IEnumerator<$typemap(cstype, CTYPE)> global::System.Collections.Generic.IEnumerable<$typemap(cstype, CTYPE)>.GetEnumerator() {
return new $csclassnameEnumerator(this);
}
#endif
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() {
return new $csclassnameEnumerator(this);
}
@ -139,10 +123,8 @@
/// whenever the collection is modified. This has been done for changes in the size of the
/// collection but not when one of the elements of the collection is modified as it is a bit
/// tricky to detect unmanaged code that modifies the collection under our feet.
public sealed class $csclassnameEnumerator : System.Collections.IEnumerator
#if !SWIG_DOTNET_1
, System.Collections.Generic.IEnumerator<$typemap(cstype, CTYPE)>
#endif
public sealed class $csclassnameEnumerator : global::System.Collections.IEnumerator
, global::System.Collections.Generic.IEnumerator<$typemap(cstype, CTYPE)>
{
private $csclassname collectionRef;
private int currentIndex;
@ -160,17 +142,17 @@
public $typemap(cstype, CTYPE) Current {
get {
if (currentIndex == -1)
throw new InvalidOperationException("Enumeration not started.");
throw new global::System.InvalidOperationException("Enumeration not started.");
if (currentIndex > currentSize - 1)
throw new InvalidOperationException("Enumeration finished.");
throw new global::System.InvalidOperationException("Enumeration finished.");
if (currentObject == null)
throw new InvalidOperationException("Collection modified.");
throw new global::System.InvalidOperationException("Collection modified.");
return ($typemap(cstype, CTYPE))currentObject;
}
}
// Type-unsafe IEnumerator.Current
object System.Collections.IEnumerator.Current {
object global::System.Collections.IEnumerator.Current {
get {
return Current;
}
@ -192,16 +174,14 @@
currentIndex = -1;
currentObject = null;
if (collectionRef.Count != currentSize) {
throw new InvalidOperationException("Collection modified.");
throw new global::System.InvalidOperationException("Collection modified.");
}
}
#if !SWIG_DOTNET_1
public void Dispose() {
currentIndex = -1;
currentObject = null;
}
#endif
}
%}
@ -237,7 +217,7 @@
else
throw std::out_of_range("index");
}
const_reference getitem(int index) throw (std::out_of_range) {
CONST_REFERENCE getitem(int index) throw (std::out_of_range) {
if (index>=0 && index<(int)$self->size())
return (*$self)[index];
else

View file

@ -23,7 +23,7 @@ class wstring;
// wstring
%typemap(ctype, out="void *") wstring "wchar_t *"
%typemap(imtype, inattributes="[MarshalAs(UnmanagedType.LPWStr)]") wstring "string"
%typemap(imtype, inattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]") wstring "string"
%typemap(cstype) wstring "string"
%typemap(csdirectorin) wstring "$iminput"
%typemap(csdirectorout) wstring "$cscall"
@ -60,7 +60,7 @@ class wstring;
// const wstring &
%typemap(ctype, out="void *") const wstring & "wchar_t *"
%typemap(imtype, inattributes="[MarshalAs(UnmanagedType.LPWStr)]") const wstring & "string"
%typemap(imtype, inattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]") const wstring & "string"
%typemap(cstype) const wstring & "string"
%typemap(csdirectorin) const wstring & "$iminput"

View file

@ -0,0 +1,34 @@
/* -----------------------------------------------------------------------------
* swigtype_inout.i
*
* Pointer pointer and pointer reference handling typemap library for non-primitive types
*
* These mappings provide support for input/output arguments and common
* uses for C/C++ pointer references and pointer to pointers.
*
* These are named typemaps (OUTPUT) and can be used like any named typemap.
* Alternatively they can be made the default by using %apply:
* %apply SWIGTYPE *& OUTPUT { SWIGTYPE *& }
* ----------------------------------------------------------------------------- */
/*
* OUTPUT typemaps. Example usage wrapping:
*
* void f(XXX *& x) { x = new XXX(111); }
*
* would be:
*
* XXX x = null;
* f(out x);
* // use x
* x.Dispose(); // manually clear memory or otherwise leave out and leave it to the garbage collector
*/
%typemap(ctype) SWIGTYPE *& OUTPUT "void **"
%typemap(imtype, out="global::System.IntPtr") SWIGTYPE *& OUTPUT "out global::System.IntPtr"
%typemap(cstype) SWIGTYPE *& OUTPUT "out $*csclassname"
%typemap(csin,
pre=" global::System.IntPtr cPtr_$csinput = global::System.IntPtr.Zero;",
post=" $csinput = (cPtr_$csinput == global::System.IntPtr.Zero) ? null : new $*csclassname(cPtr_$csinput, true);",
cshin="out $csinput") SWIGTYPE *& OUTPUT "out cPtr_$csinput"
%typemap(in) SWIGTYPE *& OUTPUT %{ $1 = ($1_ltype)$input; %}
%typemap(freearg) SWIGTYPE *& OUTPUT ""

View file

@ -55,7 +55,7 @@ In C# you could then use it like this:
%define INPUT_TYPEMAP(TYPE, CTYPE, CSTYPE)
%typemap(ctype, out="void *") TYPE *INPUT, TYPE &INPUT "CTYPE"
%typemap(imtype, out="IntPtr") TYPE *INPUT, TYPE &INPUT "CSTYPE"
%typemap(imtype, out="global::System.IntPtr") TYPE *INPUT, TYPE &INPUT "CSTYPE"
%typemap(cstype, out="$csclassname") TYPE *INPUT, TYPE &INPUT "CSTYPE"
%typemap(csin) TYPE *INPUT, TYPE &INPUT "$csinput"
@ -135,7 +135,7 @@ value returned in the second output parameter. In C# you would use it like this:
%define OUTPUT_TYPEMAP(TYPE, CTYPE, CSTYPE, TYPECHECKPRECEDENCE)
%typemap(ctype, out="void *") TYPE *OUTPUT, TYPE &OUTPUT "CTYPE *"
%typemap(imtype, out="IntPtr") TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE"
%typemap(imtype, out="global::System.IntPtr") TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE"
%typemap(cstype, out="$csclassname") TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE"
%typemap(csin) TYPE *OUTPUT, TYPE &OUTPUT "out $csinput"
@ -224,7 +224,7 @@ of the function return value.
%define INOUT_TYPEMAP(TYPE, CTYPE, CSTYPE, TYPECHECKPRECEDENCE)
%typemap(ctype, out="void *") TYPE *INOUT, TYPE &INOUT "CTYPE *"
%typemap(imtype, out="IntPtr") TYPE *INOUT, TYPE &INOUT "ref CSTYPE"
%typemap(imtype, out="global::System.IntPtr") TYPE *INOUT, TYPE &INOUT "ref CSTYPE"
%typemap(cstype, out="$csclassname") TYPE *INOUT, TYPE &INOUT "ref CSTYPE"
%typemap(csin) TYPE *INOUT, TYPE &INOUT "ref $csinput"

View file

@ -20,14 +20,14 @@ static SWIG_CSharpWStringHelperCallback SWIG_csharp_wstring_callback = NULL;
%pragma(csharp) imclasscode=%{
protected class SWIGWStringHelper {
public delegate string SWIGWStringDelegate(IntPtr message);
public delegate string SWIGWStringDelegate(global::System.IntPtr message);
static SWIGWStringDelegate wstringDelegate = new SWIGWStringDelegate(CreateWString);
[DllImport("$dllimport", EntryPoint="SWIGRegisterWStringCallback_$module")]
[global::System.Runtime.InteropServices.DllImport("$dllimport", EntryPoint="SWIGRegisterWStringCallback_$module")]
public static extern void SWIGRegisterWStringCallback_$module(SWIGWStringDelegate wstringDelegate);
static string CreateWString([MarshalAs(UnmanagedType.LPWStr)]IntPtr cString) {
return System.Runtime.InteropServices.Marshal.PtrToStringUni(cString);
static string CreateWString([global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]global::System.IntPtr cString) {
return global::System.Runtime.InteropServices.Marshal.PtrToStringUni(cString);
}
static SWIGWStringHelper() {
@ -77,12 +77,12 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterWStringCallback_$module(SWIG_CSharpWStri
// wchar_t *
%typemap(ctype) wchar_t * "wchar_t *"
%typemap(imtype, inattributes="[MarshalAs(UnmanagedType.LPWStr)]", out="IntPtr" ) wchar_t * "string"
%typemap(imtype, inattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]", out="global::System.IntPtr" ) wchar_t * "string"
%typemap(cstype) wchar_t * "string"
%typemap(csin) wchar_t * "$csinput"
%typemap(csout, excode=SWIGEXCODE) wchar_t * {
string ret = System.Runtime.InteropServices.Marshal.PtrToStringUni($imcall);$excode
string ret = global::System.Runtime.InteropServices.Marshal.PtrToStringUni($imcall);$excode
return ret;
}
%typemap(csvarin, excode=SWIGEXCODE2) wchar_t * %{

View file

@ -5,42 +5,41 @@
* methods can be called from C++.
* ----------------------------------------------------------------------------- */
#ifdef __cplusplus
#if defined(DEBUG_DIRECTOR_OWNED)
#include <iostream>
#endif
#include <string>
#include <exception>
namespace Swig {
// Director base class not used in D directors.
class Director {
};
// Base class for director exceptions.
class DirectorException {
class DirectorException : public std::exception {
protected:
std::string swig_msg;
public:
DirectorException(const char* msg) : swig_msg(msg) {
}
DirectorException(const std::string &msg) : swig_msg(msg) {
}
const std::string& what() const {
return swig_msg;
virtual ~DirectorException() throw() {
}
virtual ~DirectorException() {
const char *what() const throw() {
return swig_msg.c_str();
}
};
// Exception which is thrown when attempting to call a pure virtual method
// from D code thorugh the director layer.
class DirectorPureVirtualException : public Swig::DirectorException {
// from D code through the director layer.
class DirectorPureVirtualException : public DirectorException {
public:
DirectorPureVirtualException(const char* msg) : DirectorException(std::string("Attempted to invoke pure virtual method ") + msg) {
DirectorPureVirtualException(const char *msg) : DirectorException(std::string("Attempted to invoke pure virtual method ") + msg) {
}
};
}
#endif /* __cplusplus */

View file

@ -53,10 +53,10 @@
/* Pack binary data into a string */
SWIGINTERN char * SWIG_PackData(char *c, void *ptr, size_t sz) {
static const char hex[17] = "0123456789abcdef";
register const unsigned char *u = (unsigned char *) ptr;
register const unsigned char *eu = u + sz;
const unsigned char *u = (unsigned char *) ptr;
const unsigned char *eu = u + sz;
for (; u != eu; ++u) {
register unsigned char uu = *u;
unsigned char uu = *u;
*(c++) = hex[(uu & 0xf0) >> 4];
*(c++) = hex[uu & 0xf];
}
@ -67,11 +67,11 @@ SWIGINTERN char * SWIG_PackData(char *c, void *ptr, size_t sz) {
%fragment("SWIG_UnPackData", "header") {
/* Unpack binary data from a string */
SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
register unsigned char *u = (unsigned char *) ptr;
register const unsigned char *eu = u + sz;
unsigned char *u = (unsigned char *) ptr;
const unsigned char *eu = u + sz;
for (; u != eu; ++u) {
register char d = *(c++);
register unsigned char uu;
char d = *(c++);
unsigned char uu;
if ((d >= '0') && (d <= '9'))
uu = ((d - '0') << 4);
else if ((d >= 'a') && (d <= 'f'))

View file

@ -128,7 +128,7 @@ public void capacity(size_t value) {
return $self->capacity() - $self->size();
}
const_reference remove() throw (std::out_of_range) {
CONST_REFERENCE remove() throw (std::out_of_range) {
if ($self->empty()) {
throw std::out_of_range("Tried to remove last element from empty vector.");
}
@ -138,7 +138,7 @@ public void capacity(size_t value) {
return value;
}
const_reference remove(size_type index) throw (std::out_of_range) {
CONST_REFERENCE remove(size_type index) throw (std::out_of_range) {
if (index >= $self->size()) {
throw std::out_of_range("Tried to remove element with invalid index.");
}
@ -153,7 +153,7 @@ public void capacity(size_t value) {
// Wrappers for setting/getting items with the possibly thrown exception
// specified (important for SWIG wrapper generation).
%extend {
const_reference getElement(size_type index) throw (std::out_of_range) {
CONST_REFERENCE getElement(size_type index) throw (std::out_of_range) {
if ((index < 0) || ($self->size() <= index)) {
throw std::out_of_range("Tried to get value of element with invalid index.");
}
@ -464,7 +464,7 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg)
return pv;
}
const_reference remove() throw (std::out_of_range) {
CONST_REFERENCE remove() throw (std::out_of_range) {
if ($self->empty()) {
throw std::out_of_range("Tried to remove last element from empty vector.");
}
@ -474,7 +474,7 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg)
return value;
}
const_reference remove(size_type index) throw (std::out_of_range) {
CONST_REFERENCE remove(size_type index) throw (std::out_of_range) {
if (index >= $self->size()) {
throw std::out_of_range("Tried to remove element with invalid index.");
}
@ -506,7 +506,7 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg)
// Wrappers for setting/getting items with the possibly thrown exception
// specified (important for SWIG wrapper generation).
%extend {
const_reference getElement(size_type index) throw (std::out_of_range) {
CONST_REFERENCE getElement(size_type index) throw (std::out_of_range) {
if ((index < 0) || ($self->size() <= index)) {
throw std::out_of_range("Tried to get value of element with invalid index.");
}

View file

@ -15,7 +15,7 @@
#ifdef SWIGPHP
%{
#include "zend_exceptions.h"
#define SWIG_exception(code, msg) { zend_throw_exception(NULL, (char*)msg, code TSRMLS_CC); }
#define SWIG_exception(code, msg) zend_throw_exception(NULL, (char*)msg, code TSRMLS_CC)
%}
#endif

View file

@ -4,10 +4,6 @@
%include <gcj/javaprims.i>
extern jobject JvAllocObject (jclass cls);
extern jobject JvAllocObject (jclass cls, jsize sz);
extern void JvInitClass (jclass cls);
extern jstring JvAllocString (jsize sz);
@ -30,7 +26,7 @@ extern void *JvMalloc (jsize size);
extern void JvFree (void *ptr);
extern jint JvCreateJavaVM (void* vm_args);
extern jint JvCreateJavaVM (JvVMInitArgs* vm_args);
extern java::lang::Thread* JvAttachCurrentThread (jstring name, java::lang::ThreadGroup* group);

View file

@ -7,7 +7,8 @@
%{
typedef struct SWIGCDATA {
char *data;
int len;
intgo len;
intgo cap;
} SWIGCDATA;
%}
@ -15,7 +16,8 @@ typedef struct SWIGCDATA {
%typemap(out) SWIGCDATA %{
$result.data = (char*)_swig_goallocate($1.len);
memcpy($result.data, $1.data, $1.len);
$result.len = (int)$1.len;
$result.len = (intgo)$1.len;
$result.cap = $result.len;
%}
/* -----------------------------------------------------------------------------

View file

@ -4,6 +4,9 @@
* Go configuration module.
* ------------------------------------------------------------ */
/* Code insertion directives */
#define %go_import(...) %insert(go_imports) %{__VA_ARGS__%}
/* Basic types */
%typemap(gotype) bool, const bool & "bool"
@ -14,15 +17,8 @@
%typemap(gotype) unsigned short, const unsigned short & "uint16"
%typemap(gotype) int, const int & "int"
%typemap(gotype) unsigned int, const unsigned int & "uint"
#if SWIGGO_LONG_TYPE_SIZE == 32
%typemap(gotype) long, const long & "int32"
%typemap(gotype) unsigned long, const unsigned long & "uint32"
#elif SWIGGO_LONG_TYPE_SIZE == 64
%typemap(gotype) long, const long & "int64"
%typemap(gotype) unsigned long, const unsigned long & "uint64"
#else
#error "SWIGGO_LONG_TYPE_SIZE not 32 or 64"
#endif
%typemap(gotype) long long, const long long & "int64"
%typemap(gotype) unsigned long long, const unsigned long long & "uint64"
%typemap(gotype) float, const float & "float32"
@ -52,14 +48,17 @@
const unsigned short &,
const int &,
const unsigned int &,
const long &,
const unsigned long &,
const long long &,
const unsigned long long &,
const float &,
const double &
%{ $1 = ($1_ltype)&$input; %}
%typemap(in) const long & ($*1_ltype temp),
const unsigned long & ($*1_ltype temp)
%{ temp = ($*1_ltype)$input;
$1 = ($1_ltype)&temp; %}
%typemap(out) bool,
char,
signed char,
@ -163,11 +162,7 @@
/* The size_t type. */
#if SWIGGO_LONG_TYPE_SIZE == 32
%typemap(gotype) size_t, const size_t & %{int%}
#else
%typemap(gotype) size_t, const size_t & %{int64%}
#endif
%typemap(in) size_t
%{ $1 = (size_t)$input; %}
@ -273,6 +268,21 @@
%typemap(directorout) SWIGTYPE &
%{ *($&1_ltype)&$result = $input; %}
%typemap(gotype) SWIGTYPE &&
%{$gotypename%}
%typemap(in) SWIGTYPE &&
%{ $1 = *($&1_ltype)&$input; %}
%typemap(out) SWIGTYPE &&
%{ *($&1_ltype)&$result = $1; %}
%typemap(directorin) SWIGTYPE &&
%{ $input = ($1_ltype)&$1_name; %}
%typemap(directorout) SWIGTYPE &&
%{ *($&1_ltype)&$result = $input; %}
/* C arrays turn into Go pointers. If we know the length we can use a
slice. */
@ -424,7 +434,7 @@
%typemap(throws) char *
%{ _swig_gopanic($1); %}
%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY]
%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY]
%{
(void)$1;
_swig_gopanic("C++ $1_type exception thrown");
@ -471,32 +481,16 @@
const unsigned int &
""
#if SWIGGO_LONG_TYPE_SIZE == 32
%typecheck(SWIG_TYPECHECK_INT32) /* Go int32 */
long,
const long &
""
%typecheck(SWIG_TYPECHECK_INT32) /* Go uint32 */
unsigned long,
const unsigned long &
""
#endif
%typecheck(SWIG_TYPECHECK_INT64) /* Go int64 */
#if SWIGGO_LONG_TYPE_SIZE == 64
long,
const long &,
#endif
long long,
const long long &
""
%typecheck(SWIG_TYPECHECK_INT64) /* Go uint64 */
#if SWIGGO_LONG_TYPE_SIZE == 64
unsigned long,
const unsigned long &,
#endif
unsigned long long,
const unsigned long long &
""
@ -530,6 +524,7 @@
SWIGTYPE,
SWIGTYPE *,
SWIGTYPE &,
SWIGTYPE &&,
SWIGTYPE *const&,
SWIGTYPE [],
SWIGTYPE (CLASS::*)

View file

@ -115,15 +115,8 @@ extern void _cgo_panic(const char *);
version. We assume that the version of gcc used to compile this
file is the same as the version of gccgo. */
#define SWIGCONCAT2(s1, s2) s1 ## s2
#define SWIGCONCAT1(s1, s2) SWIGCONCAT2(s1, s2)
#define SwigCgocall SWIGCONCAT1(SWIGMODULE, SwigCgocall)
#define SwigCgocallDone SWIGCONCAT1(SWIGMODULE, SwigCgocallDone)
#define SwigCgocallBack SWIGCONCAT1(SWIGMODULE, SwigCgocallBack)
#define SwigCgocallBackDone SWIGCONCAT1(SWIGMODULE, SwigCgocallBackDone)
#define SWIG_GCC_VERSION \
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC__PATH_LEVEL__)
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#if SWIG_GCC_VERSION < 40700
#define SwigDoCgocall()
@ -142,22 +135,36 @@ 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
@ -185,30 +192,26 @@ static _gostring_ _swig_makegostring(const char *p, size_t l) {
#ifndef SWIGGO_GCCGO
%insert(go_header) %{
import _ "runtime/cgo"
import "unsafe"
type _ unsafe.Pointer
%}
%go_import("unsafe", _ "runtime/cgo")
#else
%go_import("syscall", "unsafe")
%insert(go_header) %{
import "syscall"
import "unsafe"
type _ syscall.Sockaddr
type _ unsafe.Pointer
%}
#endif
%insert(go_header) %{
type _ unsafe.Pointer
%}
/* Function pointers are translated by the code in go.cxx into
_swig_fnptr. Member pointers are translated to _swig_memberptr. */

View file

@ -59,7 +59,7 @@ namespace std {
%rename(add) push_back;
void push_back(const value_type& x);
%extend {
const_reference get(int i) throw (std::out_of_range) {
bool get(int i) throw (std::out_of_range) {
int size = int(self->size());
if (i>=0 && i<size)
return (*self)[i];

View file

@ -1,4 +1,3 @@
co:
co RCS/*.i* RCS/*.swg*

View file

@ -27,8 +27,7 @@ scm_module_variable (SCM module, SCM sym)
#endif
#if SCM_MAJOR_VERSION >= 2
// scm_c_define_gsubr takes a different parameter type
// depending on the guile version
/* scm_c_define_gsubr takes a different parameter type depending on the guile version */
typedef scm_t_subr swig_guile_proc;
#else
@ -41,10 +40,14 @@ typedef struct swig_guile_clientdata {
SCM goops_class;
} swig_guile_clientdata;
#if SCM_MAJOR_VERSION <= 2
#define scm_to_utf8_string scm_to_locale_string
#define scm_from_utf8_string scm_from_locale_string
#endif
#define SWIG_scm2str(s) \
SWIG_Guile_scm2newstr(s, NULL)
#define SWIG_str02scm(str) \
str ? scm_from_locale_string(str) : SCM_BOOL_F
str ? scm_from_utf8_string(str) : SCM_BOOL_F
# define SWIG_malloc(size) \
scm_malloc(size)
# define SWIG_free(mem) \
@ -84,21 +87,13 @@ SWIGINTERN char *
SWIG_Guile_scm2newstr(SCM str, size_t *len) {
#define FUNC_NAME "SWIG_Guile_scm2newstr"
char *ret;
char *tmp;
size_t l;
SCM_ASSERT (scm_is_string(str), str, 1, FUNC_NAME);
l = scm_c_string_length(str);
ret = (char *) SWIG_malloc( (l + 1) * sizeof(char));
ret = scm_to_utf8_string(str);
if (!ret) return NULL;
tmp = scm_to_locale_string(str);
memcpy(ret, tmp, l);
free(tmp);
ret[l] = '\0';
if (len) *len = l;
if (len) *len = strlen(ret) - 1;
return ret;
#undef FUNC_NAME
}
@ -446,13 +441,8 @@ SWIG_Guile_Init ()
SWIGINTERN swig_module_info *
SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata))
{
SCM module;
SCM variable;
module = SWIG_Guile_Init();
variable = scm_module_variable(module,
scm_from_locale_symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME));
SCM module = SWIG_Guile_Init();
SCM variable = scm_module_variable(module, scm_from_locale_symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME));
if (scm_is_false(variable)) {
return NULL;
} else {
@ -463,11 +453,7 @@ SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata))
SWIGINTERN void
SWIG_Guile_SetModule(swig_module_info *swig_module)
{
SCM module;
SCM variable;
module = SWIG_Guile_Init();
SCM module = SWIG_Guile_Init();
scm_module_define(module,
scm_from_locale_symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME),
scm_from_ulong((unsigned long) swig_module));
@ -482,7 +468,7 @@ SWIG_Guile_GetArgs (SCM *dest, SCM rest,
int num_args_passed = 0;
for (i = 0; i<reqargs; i++) {
if (!SCM_CONSP(rest))
scm_wrong_num_args(scm_from_locale_string(procname ? (char *) procname : "unknown procedure"));
scm_wrong_num_args(scm_from_utf8_string(procname ? (char *) procname : "unknown procedure"));
*dest++ = SCM_CAR(rest);
rest = SCM_CDR(rest);
num_args_passed++;
@ -495,7 +481,7 @@ SWIG_Guile_GetArgs (SCM *dest, SCM rest,
for (; i<optargs; i++)
*dest++ = SCM_UNDEFINED;
if (!SCM_NULLP(rest))
scm_wrong_num_args(scm_from_locale_string(procname ? (char *) procname : "unknown procedure"));
scm_wrong_num_args(scm_from_utf8_string(procname ? (char *) procname : "unknown procedure"));
return num_args_passed;
}

View file

@ -306,7 +306,6 @@ namespace std {
$1 = 1;
} else {
/* check the first element only */
T* x;
SCM o = scm_vector_ref($input,scm_from_ulong(0));
$1 = CHECK(o) ? 1 : 0;
}
@ -315,7 +314,6 @@ namespace std {
$1 = 1;
} else if (scm_is_pair($input)) {
/* check the first element only */
T* x;
SCM head = SCM_CAR($input);
$1 = CHECK(head) ? 1 : 0;
} else {
@ -335,7 +333,6 @@ namespace std {
$1 = 1;
} else {
/* check the first element only */
T* x;
SCM o = scm_vector_ref($input,scm_from_ulong(0));
$1 = CHECK(o) ? 1 : 0;
}
@ -344,7 +341,6 @@ namespace std {
$1 = 1;
} else if (scm_is_pair($input)) {
/* check the first element only */
T* x;
SCM head = SCM_CAR($input);
$1 = CHECK(head) ? 1 : 0;
} else {

View file

@ -6,10 +6,10 @@
/* Pointers */
%typemap(in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
%typemap(in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
$1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, 0);
}
%typemap(freearg) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] "";
%typemap(freearg) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] "";
%typemap(in) void * {
$1 = ($1_ltype)SWIG_MustGetPtr($input, NULL, $argnum, 0);
@ -24,6 +24,10 @@
$1 = *(($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0));
}
%typemap(varin) SWIGTYPE && {
$1 = *(($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0));
}
%typemap(varin) SWIGTYPE [] {
scm_wrong_type_arg((char *) FUNC_NAME, 1, $input);
}
@ -41,7 +45,7 @@
$1 = SWIG_MustGetPtr($input, NULL, 1, 0);
}
%typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
%typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
$result = SWIG_NewPointerObj ($1, $descriptor, $owner);
}
@ -58,6 +62,10 @@
$result = SWIG_NewPointerObj((void *) &$1, $1_descriptor, 0);
}
%typemap(varout) SWIGTYPE && {
$result = SWIG_NewPointerObj((void *) &$1, $1_descriptor, 0);
}
%typemap(throws) SWIGTYPE {
$&ltype temp = new $ltype($1);
scm_throw(scm_from_locale_symbol((char *) "swig-exception"),
@ -71,6 +79,12 @@
SCM_UNDEFINED));
}
%typemap(throws) SWIGTYPE && {
scm_throw(gh_symbol2scm((char *) "swig-exception"),
gh_list(SWIG_NewPointerObj(&$1, $descriptor, 1),
SCM_UNDEFINED));
}
%typemap(throws) SWIGTYPE * {
scm_throw(scm_from_locale_symbol((char *) "swig-exception"),
scm_listify(SWIG_NewPointerObj($1, $descriptor, 1),
@ -430,7 +444,7 @@ typedef unsigned long SCM;
$1 = scm_is_string($input) ? 1 : 0;
}
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
void *ptr;
int res = SWIG_ConvertPtr($input, &ptr, $1_descriptor, 0);
$1 = SWIG_CheckState(res);
@ -450,6 +464,7 @@ typedef unsigned long SCM;
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }

View file

@ -41,12 +41,6 @@ extern "C" {
/* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */
extern imaxdiv_t imaxdiv (intmax_t numer, intmax_t denom);
/* Like `strtol' but convert to `intmax_t'. */
extern intmax_t strtoimax (const char *nptr, char **endptr, int base);
/* Like `strtoul' but convert to `uintmax_t'. */
extern uintmax_t strtoumax (const char *nptr, char ** endptr, int base);
#ifdef SWIG_WCHAR
/* Like `wcstol' but convert to `intmax_t'. */
extern intmax_t wcstoimax (const wchar_t *nptr, wchar_t **endptr, int base);
@ -84,7 +78,7 @@ extern "C" {
extern uintmax_t wcstoumax (const wchar_t *nptr, wchar_t **endptr, int base);
#endif
#endif /* SWIGWORDSIZE32 */
#endif /* SWIGWORDSIZE64 */
#ifdef __cplusplus
}

View file

@ -1,17 +1,18 @@
/* -----------------------------------------------------------------------------
* director.swg
*
* This file contains support for director classes that proxy
* method calls from C++ to Java extensions.
* This file contains support for director classes so that Java proxy
* methods can be called from C++.
* ----------------------------------------------------------------------------- */
#ifdef __cplusplus
#if defined(DEBUG_DIRECTOR_OWNED)
#if defined(DEBUG_DIRECTOR_OWNED) || defined(DEBUG_DIRECTOR_EXCEPTION)
#include <iostream>
#endif
#include <exception>
namespace Swig {
/* Java object wrapper */
class JObjectWrapper {
public:
@ -74,8 +75,7 @@ namespace Swig {
}
/* Java proxy releases ownership of C++ object, C++ object is now
responsible for destruction (creates NewGlobalRef to pin Java
proxy) */
responsible for destruction (creates NewGlobalRef to pin Java proxy) */
void java_change_ownership(JNIEnv *jenv, jobject jself, bool take_or_release) {
if (take_or_release) { /* Java takes ownership of C++ object's lifetime. */
if (!weak_global_) {
@ -83,7 +83,8 @@ namespace Swig {
jthis_ = jenv->NewWeakGlobalRef(jself);
weak_global_ = true;
}
} else { /* Java releases ownership of C++ object's lifetime */
} else {
/* Java releases ownership of C++ object's lifetime */
if (weak_global_) {
jenv->DeleteWeakGlobalRef((jweak)jthis_);
jthis_ = jenv->NewGlobalRef(jself);
@ -123,7 +124,7 @@ namespace Swig {
#endif
env_status = director_->swig_jvm_->GetEnv((void **)&jenv_, JNI_VERSION_1_2);
#if defined(SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON)
// Attach a daemon thread to the JVM. Useful when the JVM should not wait for
// Attach a daemon thread to the JVM. Useful when the JVM should not wait for
// the thread to exit upon shutdown. Only for jdk-1.4 and later.
director_->swig_jvm_->AttachCurrentThreadAsDaemon(jenv, NULL);
#else
@ -191,8 +192,193 @@ namespace Swig {
swig_self_.java_change_ownership(jenv, jself, take_or_release);
}
};
// Utility classes and functions for exception handling.
// Simple holder for a Java string during exception handling, providing access to a c-style string
class JavaString {
public:
JavaString(JNIEnv *jenv, jstring jstr) : jenv_(jenv), jstr_(jstr), cstr_(0) {
if (jenv_ && jstr_)
cstr_ = (const char *) jenv_->GetStringUTFChars(jstr_, NULL);
}
~JavaString() {
if (jenv_ && jstr_ && cstr_)
jenv_->ReleaseStringUTFChars(jstr_, cstr_);
}
const char *c_str(const char *null_string = "null JavaString") const {
return cstr_ ? cstr_ : null_string;
}
private:
// non-copyable
JavaString(const JavaString &);
JavaString &operator=(const JavaString &);
JNIEnv *jenv_;
jstring jstr_;
const char *cstr_;
};
// Helper class to extract the exception message from a Java throwable
class JavaExceptionMessage {
public:
JavaExceptionMessage(JNIEnv *jenv, jthrowable throwable) : message_(jenv, exceptionMessageFromThrowable(jenv, throwable)) {
}
const char *message() const {
return message_.c_str("Could not get exception message in JavaExceptionMessage");
}
private:
// non-copyable
JavaExceptionMessage(const JavaExceptionMessage &);
JavaExceptionMessage &operator=(const JavaExceptionMessage &);
// Get exception message by calling Java method Throwable.getMessage()
static jstring exceptionMessageFromThrowable(JNIEnv *jenv, jthrowable throwable) {
jstring jmsg = NULL;
if (jenv && throwable) {
jenv->ExceptionClear(); // Cannot invoke methods with any pending exceptions
jclass throwclz = jenv->GetObjectClass(throwable);
if (throwclz) {
// All Throwable classes have a getMessage() method, so call it to extract the exception message
jmethodID getMessageMethodID = jenv->GetMethodID(throwclz, "getMessage", "()Ljava/lang/String;");
if (getMessageMethodID)
jmsg = (jstring)jenv->CallObjectMethod(throwable, getMessageMethodID);
}
if (jmsg == NULL && jenv->ExceptionCheck())
jenv->ExceptionClear();
}
return jmsg;
}
JavaString message_;
};
// C++ Exception class for handling Java exceptions thrown during a director method Java upcall
class DirectorException : public std::exception {
public:
// Construct exception from a Java throwable
DirectorException(JNIEnv *jenv, jthrowable throwable) : classname_(0), msg_(0) {
// Call Java method Object.getClass().getName() to obtain the throwable's class name (delimited by '/')
if (throwable) {
jclass throwclz = jenv->GetObjectClass(throwable);
if (throwclz) {
jclass clzclz = jenv->GetObjectClass(throwclz);
if (clzclz) {
jmethodID getNameMethodID = jenv->GetMethodID(clzclz, "getName", "()Ljava/lang/String;");
if (getNameMethodID) {
jstring jstr_classname = (jstring)(jenv->CallObjectMethod(throwclz, getNameMethodID));
// Copy strings, since there is no guarantee that jenv will be active when handled
if (jstr_classname) {
JavaString jsclassname(jenv, jstr_classname);
const char *classname = jsclassname.c_str(0);
if (classname)
classname_ = copypath(classname);
}
}
}
}
}
JavaExceptionMessage exceptionmsg(jenv, throwable);
msg_ = copystr(exceptionmsg.message());
}
// More general constructor for handling as a java.lang.RuntimeException
DirectorException(const char *msg) : classname_(0), msg_(copystr(msg ? msg : "Unspecified DirectorException message")) {
}
~DirectorException() throw() {
delete[] classname_;
delete[] msg_;
}
const char *what() const throw() {
return msg_;
}
// Reconstruct and raise/throw the Java Exception that caused the DirectorException
// Note that any error in the JNI exception handling results in a Java RuntimeException
void raiseJavaException(JNIEnv *jenv) const {
if (jenv) {
jenv->ExceptionClear();
jmethodID ctorMethodID = 0;
jclass throwableclass = 0;
if (classname_) {
throwableclass = jenv->FindClass(classname_);
if (throwableclass)
ctorMethodID = jenv->GetMethodID(throwableclass, "<init>", "(Ljava/lang/String;)V");
}
if (ctorMethodID) {
jenv->ThrowNew(throwableclass, what());
} else {
SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, what());
}
}
}
private:
static char *copypath(const char *srcmsg) {
char *target = copystr(srcmsg);
for (char *c=target; *c; ++c) {
if ('.' == *c)
*c = '/';
}
return target;
}
static char *copystr(const char *srcmsg) {
char *target = 0;
if (srcmsg) {
int msglen = strlen(srcmsg) + 1;
target = new char[msglen];
strncpy(target, srcmsg, msglen);
}
return target;
}
const char *classname_;
const char *msg_;
};
// Helper method to determine if a Java throwable matches a particular Java class type
bool ExceptionMatches(JNIEnv *jenv, jthrowable throwable, const char *classname) {
bool matches = false;
if (throwable && jenv && classname) {
// Exceptions need to be cleared for correct behavior.
// The caller of ExceptionMatches should restore pending exceptions if desired -
// the caller already has the throwable.
jenv->ExceptionClear();
jclass clz = jenv->FindClass(classname);
if (clz) {
jclass classclz = jenv->GetObjectClass(clz);
jmethodID isInstanceMethodID = jenv->GetMethodID(classclz, "isInstance", "(Ljava/lang/Object;)Z");
if (isInstanceMethodID) {
matches = jenv->CallBooleanMethod(clz, isInstanceMethodID, throwable) != 0;
}
}
#if defined(DEBUG_DIRECTOR_EXCEPTION)
if (jenv->ExceptionCheck()) {
// Typically occurs when an invalid classname argument is passed resulting in a ClassNotFoundException
JavaExceptionMessage exc(jenv, jenv->ExceptionOccurred());
std::cout << "Error: ExceptionMatches: class '" << classname << "' : " << exc.message() << std::endl;
}
#endif
}
return matches;
}
}
#endif /* __cplusplus */

View file

@ -65,7 +65,6 @@
%typemap(javacode) enum SWIGTYPE ""
%typemap(javaimports) enum SWIGTYPE ""
%typemap(javainterfaces) enum SWIGTYPE ""
%typemap(javabody) enum SWIGTYPE ""
/*
* SwigNext static inner class used instead of a static int as static fields cannot be accessed from enum initialisers.

View file

@ -64,7 +64,6 @@
%typemap(javacode) enum SWIGTYPE ""
%typemap(javaimports) enum SWIGTYPE ""
%typemap(javainterfaces) enum SWIGTYPE ""
%typemap(javabody) enum SWIGTYPE ""
/*
* The swigToEnum method is used to find the Java enum from a C++ enum integer value. The default one here takes

View file

@ -16,10 +16,10 @@
/* Pack binary data into a string */
SWIGINTERN char * SWIG_PackData(char *c, void *ptr, size_t sz) {
static const char hex[17] = "0123456789abcdef";
register const unsigned char *u = (unsigned char *) ptr;
register const unsigned char *eu = u + sz;
const unsigned char *u = (unsigned char *) ptr;
const unsigned char *eu = u + sz;
for (; u != eu; ++u) {
register unsigned char uu = *u;
unsigned char uu = *u;
*(c++) = hex[(uu & 0xf0) >> 4];
*(c++) = hex[uu & 0xf];
}
@ -30,11 +30,11 @@ SWIGINTERN char * SWIG_PackData(char *c, void *ptr, size_t sz) {
%fragment("SWIG_UnPackData", "header") {
/* Unpack binary data from a string */
SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
register unsigned char *u = (unsigned char *) ptr;
register const unsigned char *eu = u + sz;
unsigned char *u = (unsigned char *) ptr;
const unsigned char *eu = u + sz;
for (; u != eu; ++u) {
register char d = *(c++);
register unsigned char uu;
char d = *(c++);
unsigned char uu;
if ((d >= '0') && (d <= '9'))
uu = ((d - '0') << 4);
else if ((d >= 'a') && (d <= 'f'))
@ -185,6 +185,10 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%typemap(jtype) SWIGTYPE & "long"
%typemap(jstype) SWIGTYPE & "$javaclassname"
%typemap(jni) SWIGTYPE && "jlong"
%typemap(jtype) SWIGTYPE && "long"
%typemap(jstype) SWIGTYPE && "$javaclassname"
/* pointer to a class member */
%typemap(jni) SWIGTYPE (CLASS::*) "jstring"
%typemap(jtype) SWIGTYPE (CLASS::*) "String"
@ -649,6 +653,11 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
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 *
%{ *($&1_ltype)&$result = $1; %}
%typemap(out, fragment="SWIG_PackData", noblock=1) SWIGTYPE (CLASS::*) {
@ -659,6 +668,8 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
}
%typemap(out) SWIGTYPE &
%{ *($&1_ltype)&$result = $1; %}
%typemap(out) SWIGTYPE &&
%{ *($&1_ltype)&$result = $1; %}
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *
%{ $result = *($&1_ltype)&$input; %}
@ -671,6 +682,12 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%{ *(($&1_ltype)&$input) = ($1_ltype) $1; %}
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &
%{ if (!$input) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Unexpected null return for type $1_type");
return $null;
}
$result = *($&1_ltype)&$input; %}
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &&
%{ if (!$input) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Unexpected null return for type $1_type");
return $null;
@ -678,10 +695,13 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
$result = *($&1_ltype)&$input; %}
%typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE &
%{ *($&1_ltype)&$input = ($1_ltype) &$1; %}
%typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE &&
%{ *($&1_ltype)&$input = ($1_ltype) &$1; %}
%typemap(javadirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*) "($jniinput == 0) ? null : new $javaclassname($jniinput, false)"
%typemap(javadirectorin) SWIGTYPE & "new $javaclassname($jniinput, false)"
%typemap(javadirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "$javaclassname.getCPtr($javacall)"
%typemap(javadirectorin) SWIGTYPE && "new $javaclassname($jniinput, false)"
%typemap(javadirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE &, SWIGTYPE && "$javaclassname.getCPtr($javacall)"
/* Default array handling */
%typemap(in) SWIGTYPE [] %{ $1 = *($&1_ltype)&$input; %}
@ -959,6 +979,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
SWIGTYPE,
SWIGTYPE *,
SWIGTYPE &,
SWIGTYPE &&,
SWIGTYPE *const&,
SWIGTYPE [],
SWIGTYPE (CLASS::*)
@ -978,7 +999,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, error_msg);
return $null; %}
%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY]
%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY]
%{ (void)$1;
SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown");
return $null; %}
@ -1029,7 +1050,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
jobjectArray
"$javainput"
%typemap(javain) SWIGTYPE "$&javaclassname.getCPtr($javainput)"
%typemap(javain) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] "$javaclassname.getCPtr($javainput)"
%typemap(javain) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] "$javaclassname.getCPtr($javainput)"
%typemap(javain) SWIGTYPE (CLASS::*) "$javaclassname.getCMemberPtr($javainput)"
/* The javaout typemap is used for converting function return types from the return type
@ -1083,6 +1104,9 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%typemap(javaout) SWIGTYPE & {
return new $javaclassname($jnicall, $owner);
}
%typemap(javaout) SWIGTYPE && {
return new $javaclassname($jnicall, $owner);
}
%typemap(javaout) SWIGTYPE *, SWIGTYPE [] {
long cPtr = $jnicall;
return (cPtr == 0) ? null : new $javaclassname(cPtr, $owner);
@ -1108,11 +1132,11 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%{ *($1_ltype)&$result = *$1; %}
/* Typemaps used for the generation of proxy and type wrapper class code */
%typemap(javabase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(javaclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class"
%typemap(javacode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(javaimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(javainterfaces) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(javabase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(javaclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class"
%typemap(javacode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(javaimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(javainterfaces) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
/* javabody typemaps */
@ -1151,7 +1175,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%define SWIG_JAVABODY_TYPEWRAPPER(PTRCTOR_VISIBILITY, DEFAULTCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...)
// Typewrapper classes
%typemap(javabody) TYPE *, TYPE &, TYPE [] %{
%typemap(javabody) TYPE *, TYPE &, TYPE &&, TYPE [] %{
private long swigCPtr;
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean futureUse) {
@ -1290,6 +1314,7 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }

27
Lib/java/std_auto_ptr.i Normal file
View file

@ -0,0 +1,27 @@
/*
The typemaps here allow to handle 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).
*/
%define %auto_ptr(TYPE)
%typemap (jni) std::auto_ptr<TYPE > "jlong"
%typemap (jtype) std::auto_ptr<TYPE > "long"
%typemap (jstype) std::auto_ptr<TYPE > "$typemap(jstype, TYPE)"
%typemap (out) std::auto_ptr<TYPE > %{
jlong lpp = 0;
*(TYPE**) &lpp = $1.release();
$result = lpp;
%}
%typemap(javaout) std::auto_ptr<TYPE > {
long cPtr = $jnicall;
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
}
%template() std::auto_ptr<TYPE >;
%enddef
namespace std {
template <class T> class auto_ptr {};
}

View file

@ -38,7 +38,9 @@ class string;
%typemap(directorout) string
%{ if(!$input) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string");
if (!jenv->ExceptionCheck()) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string");
}
return $null;
}
const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0);

View file

@ -61,7 +61,7 @@ namespace std {
%rename(add) push_back;
void push_back(const value_type& x);
%extend {
const_reference get(int i) throw (std::out_of_range) {
bool get(int i) throw (std::out_of_range) {
int size = int(self->size());
if (i>=0 && i<size)
return (*self)[i];

View file

@ -0,0 +1,123 @@
/* -----------------------------------------------------------------------------
* arrays_javascript.i
*
* These typemaps give more natural support for arrays. The typemaps are not efficient
* as there is a lot of copying of the array values whenever the array is passed to C/C++
* from JavaScript and vice versa. The JavaScript array is expected to be the same size as the C array.
* An exception is thrown if they are not.
*
* Example usage:
* Wrapping:
*
* %include <arrays_javascript.i>
* %inline %{
* extern int FiddleSticks[3];
* %}
*
* Use from JavaScript like this:
*
* var fs = [10, 11, 12];
* example.FiddleSticks = fs;
* fs = example.FiddleSticks;
* ----------------------------------------------------------------------------- */
%fragment("SWIG_JSCGetIntProperty", "header", fragment=SWIG_AsVal_frag(int)) {}
%fragment("SWIG_JSCGetNumberProperty", "header", fragment=SWIG_AsVal_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) {
if (JSValueIsObject(context, $input))
{
// Convert into Array
array = JSValueToObject(context, $input, NULL);
length = $1_dim0;
$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);
// Get primitive value from JSObject
res = SWIG_AsVal(int)(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) int[], int[ANY] {
free($1);
}
%typemap(out, fragment=SWIG_From_frag(int)) int[], int[ANY] (int length = 0, int i = 0)
{
length = $1_dim0;
JSValueRef values[length];
for (i = 0; i < length; i++)
{
values[i] = SWIG_From(int)($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);
length = $1_dim0;
$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);
// 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

@ -0,0 +1,26 @@
/* -----------------------------------------------------------------------------
* ccomplex.i
*
* C complex typemaps
* ISO C99: 7.3 Complex arithmetic <complex.h>
* ----------------------------------------------------------------------------- */
%include <javascriptcomplex.swg>
%{
#include <complex.h>
%}
/* C complex constructor */
#define CCplxConst(r, i) ((r) + I*(i))
%swig_cplxflt_convn(float complex, CCplxConst, creal, cimag);
%swig_cplxdbl_convn(double complex, CCplxConst, creal, cimag);
%swig_cplxdbl_convn(complex, CCplxConst, creal, cimag);
/* declaring the typemaps */
%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float complex);
%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double complex);
%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex);

View file

@ -0,0 +1 @@
%include <typemaps/cdata.swg>

View file

@ -0,0 +1,6 @@
#ifdef __cplusplus
%include <std_complex.i>
#else
%include <ccomplex.i>
#endif

View file

@ -0,0 +1 @@
%include <typemaps/exception.swg>

View file

@ -0,0 +1,19 @@
/* -----------------------------------------------------------------------------
* javascript.swg
*
* Javascript typemaps
* ----------------------------------------------------------------------------- */
%include <typemaps/swigmacros.swg>
%include <javascripttypemaps.swg>
%include <javascriptruntime.swg>
%include <javascripthelpers.swg>
%include <javascriptkw.swg>
%include <javascriptcode.swg>
%include <javascriptinit.swg>

View file

@ -0,0 +1,427 @@
/* -----------------------------------------------------------------------------
* js_ctor: template for wrapping a ctor.
* - $jswrapper: wrapper of called ctor
* - $jslocals: locals part of wrapper
* - $jscode: code part of wrapper
* - $jsargcount: number of arguments
* - $jsmangledtype: mangled type of class
* ----------------------------------------------------------------------------- */
%fragment ("js_ctor", "templates")
%{
static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
{
$jslocals
if(argc != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
$jscode
return SWIG_JSC_NewPointerObj(context, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN);
goto fail;
fail:
return NULL;
}
%}
/* -----------------------------------------------------------------------------
* js_veto_ctor: a vetoing ctor for abstract classes
* - $jswrapper: name of wrapper
* - $jsname: class name
* ----------------------------------------------------------------------------- */
%fragment ("js_veto_ctor", "templates")
%{
static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef ctorObject,
size_t argc, const JSValueRef argv[], JSValueRef* exception)
{
SWIG_exception(SWIG_ERROR, "Class $jsname can not be instantiated");
return 0;
}
%}
/* -----------------------------------------------------------------------------
* js_ctor_dispatcher: dispatcher for overloaded constructors
* - $jswrapper: name of wrapper
* - $jsname: class name
* - $jsdispatchcases: part containing code for dispatching
* ----------------------------------------------------------------------------- */
%fragment ("js_ctor_dispatcher", "templates")
%{
static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef ctorObject,
size_t argc, const JSValueRef argv[], JSValueRef* exception)
{
JSObjectRef thisObject = NULL;
// switch all cases by means of series of if-returns.
$jsdispatchcases
// default:
SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for construction of $jsname");
fail:
return thisObject;
}
%}
/* -----------------------------------------------------------------------------
* js_overloaded_ctor: template for wrapping a ctor.
* - $jswrapper: wrapper of called ctor
* - $jslocals: locals part of wrapper
* - $jscode: code part of wrapper
* - $jsargcount: number of arguments
* - $jsmangledtype: mangled type of class
* ----------------------------------------------------------------------------- */
%fragment ("js_overloaded_ctor", "templates")
%{
static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
{
$jslocals
$jscode
return SWIG_JSC_NewPointerObj(context, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN);
goto fail;
fail:
return NULL;
}
%}
/* -----------------------------------------------------------------------------
* js_ctor_dispatch_case: template for a dispatch case for calling an overloaded ctor.
* - $jsargcount: number of arguments of called ctor
* - $jswrapper: wrapper of called ctor
*
* Note: a try-catch-like mechanism is used to switch cases
* ----------------------------------------------------------------------------- */
%fragment ("js_ctor_dispatch_case", "templates")
%{
if(argc == $jsargcount) {
thisObject = $jswrapper(context, NULL, argc, argv, exception);
if(thisObject != NULL) { *exception=0; return thisObject; } /* reset exception and return */
}
%}
/* -----------------------------------------------------------------------------
* js_dtor: template for a destructor wrapper
* - $jsmangledname: mangled class name
* - $jstype: class type
* ----------------------------------------------------------------------------- */
%fragment ("js_dtor", "templates")
%{
static void $jswrapper(JSObjectRef thisObject)
{
SwigPrivData* t = (SwigPrivData*) JSObjectGetPrivate(thisObject);
if(t) {
if (t->swigCMemOwn) {
free (($jstype)t->swigCObject);
}
JSObjectSetPrivate(thisObject, NULL);
free(t);
}
}
%}
/* -----------------------------------------------------------------------------
* js_dtor: template for a destructor wrapper
* - $jsmangledname: mangled class name
* - $jstype: class type
* - ${destructor_action}: The custom destructor action to invoke.
* ----------------------------------------------------------------------------- */
%fragment ("js_dtoroverride", "templates")
%{
static void $jswrapper(JSObjectRef thisObject)
{
SwigPrivData* t = (SwigPrivData*) JSObjectGetPrivate(thisObject);
if(t) {
if (t->swigCMemOwn) {
$jstype arg1 = ($jstype)t->swigCObject;
${destructor_action}
}
/* remove the private data to make sure that it isn't accessed elsewhere */
JSObjectSetPrivate(thisObject, NULL);
free(t);
}
}
%}
/* -----------------------------------------------------------------------------
* js_getter: template for getter function wrappers
* - $jswrapper: wrapper function name
* - $jslocals: locals part of wrapper
* - $jscode: code part of wrapper
* ----------------------------------------------------------------------------- */
%fragment ("js_getter", "templates")
%{
static JSValueRef $jswrapper(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
{
$jslocals
JSValueRef jsresult;
$jscode
return jsresult;
goto fail;
fail:
return JSValueMakeUndefined(context);
}
%}
/* -----------------------------------------------------------------------------
* js_setter: template for setter function wrappers
* - $jswrapper: wrapper function name
* - $jslocals: locals part of wrapper
* - $jscode: code part of wrapper
* ----------------------------------------------------------------------------- */
%fragment ("js_setter", "templates")
%{
static bool $jswrapper(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
{
$jslocals
$jscode
return true;
goto fail;
fail:
return false;
}
%}
/* -----------------------------------------------------------------------------
* js_function: template for function wrappers
* - $jswrapper: wrapper function name
* - $jslocals: locals part of wrapper
* - $jscode: code part of wrapper
* ----------------------------------------------------------------------------- */
%fragment ("js_function", "templates")
%{
static JSValueRef $jswrapper(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
{
$jslocals
JSValueRef jsresult;
if(argc != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
$jscode
return jsresult;
goto fail;
fail:
return JSValueMakeUndefined(context);
}
%}
/* -----------------------------------------------------------------------------
* js_function_dispatcher: template for a function dispatcher for overloaded functions
* - $jswrapper: wrapper function name
* - $jsname: name of the wrapped function
* - $jslocals: locals part of wrapper
* - $jscode: code part of wrapper
* ----------------------------------------------------------------------------- */
%fragment ("js_function_dispatcher", "templates")
%{
static JSValueRef $jswrapper(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
{
$jslocals
JSValueRef jsresult;
int res;
$jscode
SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for function $jsname.");
return jsresult;
goto fail;
fail:
return JSValueMakeUndefined(context);
}
%}
/* -----------------------------------------------------------------------------
* js_overloaded_function: template for a overloaded function
* - $jswrapper: wrapper function name
* - $jslocals: locals part of wrapper
* - $jscode: code part of wrapper
* ----------------------------------------------------------------------------- */
%fragment ("js_overloaded_function", "templates")
%{
static int $jswrapper(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception, JSValueRef* p_result)
{
$jslocals
JSValueRef jsresult;
if(argc != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
$jscode
*p_result = jsresult;
return SWIG_OK;
goto fail;
fail:
return SWIG_TypeError;
}
%}
/* -----------------------------------------------------------------------------
* js_function_dispatch_case: template for a case used in the function dispatcher
* - $jswrapper: wrapper function name
* - $jsargcount: number of arguments of overloaded function
* - $jscode: code part of wrapper
* ----------------------------------------------------------------------------- */
%fragment ("js_function_dispatch_case", "templates")
%{
if(argc == $jsargcount) {
res = $jswrapper(context, function, thisObject, argc, argv, exception, &jsresult);
if(res == SWIG_OK) { *exception = 0; return jsresult; }
}
%}
/* -----------------------------------------------------------------------------
* jsc_variable_declaration: template for a variable table entry
* - $jsname: name of the variable
* - $jsgetter: wrapper of getter function
* - $jssetter: wrapper of setter function
* ----------------------------------------------------------------------------- */
%fragment ("jsc_variable_declaration", "templates")
%{
{"$jsname", $jsgetter, $jssetter, kJSPropertyAttributeNone},
%}
/* -----------------------------------------------------------------------------
* jsc_function_declaration: template for a function table entry
* - $jsname: name of the variable
* - $jswrapper: wrapper function
* ----------------------------------------------------------------------------- */
%fragment ("jsc_function_declaration", "templates")
%{
{"$jsname", $jswrapper, kJSPropertyAttributeNone},
%}
/* -----------------------------------------------------------------------------
* jsc_classtemplate_declaration: template for a namespace declaration
* - $jsmangledname: mangled class name
* ----------------------------------------------------------------------------- */
%fragment ("jsc_class_declaration", "templates")
%{
static JSClassDefinition $jsmangledname_classDefinition;
static JSClassDefinition $jsmangledname_objectDefinition;
static JSClassRef $jsmangledname_classRef;
%}
/* -----------------------------------------------------------------------------
* jsc_class_tables: template for a namespace declaration
* - $jsmangledname: mangled class name
* - $jsstaticclassvariables: list of static variable entries
* - $jsstaticclassfunctions: list of static function entries
* - $jsclassvariables: list of member variable entries
* - $jsclassfunctions: list of member function entries
* ----------------------------------------------------------------------------- */
%fragment ("jsc_class_tables", "templates")
%{
static JSStaticValue $jsmangledname_staticValues[] = {
$jsstaticclassvariables
{ 0, 0, 0, 0 }
};
static JSStaticFunction $jsmangledname_staticFunctions[] = {
$jsstaticclassfunctions
{ 0, 0, 0 }
};
static JSStaticValue $jsmangledname_values[] = {
$jsclassvariables
{ 0, 0, 0, 0 }
};
static JSStaticFunction $jsmangledname_functions[] = {
$jsclassfunctions
{ 0, 0, 0 }
};
%}
/* -----------------------------------------------------------------------------
* jsc_define_class_template: template for defining a class template
* - $jsmangledname: mangled class name
* - $jsmangledtype: mangled class type
* - $jsctor: wrapper of ctor
* - $jsbaseclass: mangled name of base class
* ----------------------------------------------------------------------------- */
%fragment ("jsc_class_definition", "templates")
%{
$jsmangledname_classDefinition.staticFunctions = $jsmangledname_staticFunctions;
$jsmangledname_classDefinition.staticValues = $jsmangledname_staticValues;
$jsmangledname_classDefinition.callAsConstructor = $jsctor;
$jsmangledname_objectDefinition.finalize = $jsdtor;
$jsmangledname_objectDefinition.staticValues = $jsmangledname_values;
$jsmangledname_objectDefinition.staticFunctions = $jsmangledname_functions;
$jsclass_inheritance
JSClassRef $jsmangledname_classRef = JSClassCreate(&$jsmangledname_objectDefinition);
SWIGTYPE_$jsmangledtype->clientdata = $jsmangledname_classRef;
%}
%fragment ("jsc_class_inherit", templates)
%{
if (SWIGTYPE_p$jsbaseclassmangled != NULL) {
$jsmangledname_objectDefinition.parentClass = (JSClassRef) SWIGTYPE_p$jsbaseclassmangled->clientdata;
}
%}
%fragment ("jsc_class_noinherit", templates)
%{
$jsmangledname_objectDefinition.parentClass = _SwigObject_classRef;
%}
/* -----------------------------------------------------------------------------
* jsc_register_class: template for registration of a class
* - $jsname: class name
* - $jsmangledname: mangled class name
* - $jsnspace: mangled name of namespace
* ----------------------------------------------------------------------------- */
%fragment ("jsc_class_registration", "templates")
%{
JS_registerClass(context, $jsnspace_object, "$jsname", &$jsmangledname_classDefinition);
%}
/* -----------------------------------------------------------------------------
* jsc_nspace_declaration: template for a namespace declaration
* - $jsnspace: mangled name of the namespace
* - $jsglobalvariables: list of variable entries
* - $jsglobalfunctions: list if fuction entries
* ----------------------------------------------------------------------------- */
%fragment ("jsc_nspace_declaration", "templates")
%{
static JSStaticValue $jsnspace_values[] = {
$jsglobalvariables
{ 0, 0, 0, 0 }
};
static JSStaticFunction $jsnspace_functions[] = {
$jsglobalfunctions
{ 0, 0, 0 }
};
static JSClassDefinition $jsnspace_classDefinition;
%}
/* -----------------------------------------------------------------------------
* jsc_nspace_definition: template for definition of a namespace object
* - $jsmangledname: mangled name of namespace
* ----------------------------------------------------------------------------- */
%fragment ("jsc_nspace_definition", "templates")
%{
$jsmangledname_classDefinition.staticFunctions = $jsmangledname_functions;
$jsmangledname_classDefinition.staticValues = $jsmangledname_values;
JSObjectRef $jsmangledname_object = JSObjectMake(context, JSClassCreate(&$jsmangledname_classDefinition), NULL);
%}
/* -----------------------------------------------------------------------------
* jsc_nspace_registration: template for registration of a namespace object
* - $jsname: name of namespace
* - $jsmangledname: mangled name of namespace
* - $jsparent: mangled name of parent namespace
* ----------------------------------------------------------------------------- */
%fragment ("jsc_nspace_registration", "templates")
%{
JS_registerNamespace(context, $jsmangledname_object, $jsparent_object, "$jsname");
%}

View file

@ -0,0 +1,146 @@
/*
Defines the As/From converters for double/float complex, you need to
provide complex Type, the Name you want to use in the converters,
the complex Constructor method, and the Real and Imag complex
accessor methods.
See the std_complex.i and ccomplex.i for concret examples.
*/
/* the common from converter */
%define %swig_fromcplx_conv(Type, Real, Imag)
%fragment(SWIG_From_frag(Type),"header",
fragment=SWIG_From_frag(double))
{
SWIGINTERNINLINE JSObjectRef
SWIG_From_dec(Type)(%ifcplusplus(const Type&, Type) c)
{
JSValueRef vals[2];
vals[0] = SWIG_From(double)(Real(c));
vals[1] = SWIG_From(double)(Imag(c));
return JSObjectMakeArray(context, 2, vals, NULL);
}
}
%enddef
/* the double case */
%define %swig_cplxdbl_conv(Type, Constructor, Real, Imag)
%fragment(SWIG_AsVal_frag(Type),"header",
fragment=SWIG_AsVal_frag(double))
{
SWIGINTERN int
SWIG_AsVal_dec(Type) (JSValueRef o, Type* val)
{
if (JSValueIsObject(context, o)) {
JSObjectRef array;
JSValueRef exception, js_re, js_im;
double re, im;
int res;
exception = 0;
res = 0;
array = JSValueToObject(context, o, &exception);
if(exception != 0)
return SWIG_TypeError;
js_re = JSObjectGetPropertyAtIndex(context, array, 0, &exception);
if(exception != 0)
return SWIG_TypeError;
js_im = JSObjectGetPropertyAtIndex(context, array, 1, &exception);
if(exception != 0)
return SWIG_TypeError;
res = SWIG_AsVal(double)(js_re, &re);
if(!SWIG_IsOK(res)) {
return SWIG_TypeError;
}
res = SWIG_AsVal(double)(js_im, &im);
if(!SWIG_IsOK(res)) {
return SWIG_TypeError;
}
if (val) *val = Constructor(re, im);
return SWIG_OK;
} else {
double d;
int res = SWIG_AddCast(SWIG_AsVal(double)(o, &d));
if (SWIG_IsOK(res)) {
if (val) *val = Constructor(d, 0.0);
return res;
}
}
return SWIG_TypeError;
}
}
%swig_fromcplx_conv(Type, Real, Imag);
%enddef
/* the float case */
%define %swig_cplxflt_conv(Type, Constructor, Real, Imag)
%fragment(SWIG_AsVal_frag(Type),"header",
fragment=SWIG_AsVal_frag(float)) {
SWIGINTERN int
SWIG_AsVal_dec(Type)(JSValueRef o, Type *val)
{
if (JSValueIsObject(context, o)) {
JSObjectRef array;
JSValueRef exception, js_re, js_im;
double re, im;
int res;
exception = 0;
res = 0;
array = JSValueToObject(context, o, &exception);
if(exception != 0)
return SWIG_TypeError;
js_re = JSObjectGetPropertyAtIndex(context, array, 0, &exception);
if(exception != 0)
return SWIG_TypeError;
js_im = JSObjectGetPropertyAtIndex(context, array, 1, &exception);
if(exception != 0)
return SWIG_TypeError;
res = SWIG_AsVal(double)(js_re, &re);
if(!SWIG_IsOK(res)) {
return SWIG_TypeError;
}
res = SWIG_AsVal(double)(js_im, &im);
if(!SWIG_IsOK(res)) {
return SWIG_TypeError;
}
if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) {
if (val) *val = Constructor(%numeric_cast(re, float),
%numeric_cast(im, float));
return SWIG_OK;
} else {
return SWIG_OverflowError;
}
} else {
float re;
int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re));
if (SWIG_IsOK(res)) {
if (val) *val = Constructor(re, 0.0);
return res;
}
}
return SWIG_TypeError;
}
}
%swig_fromcplx_conv(Type, Real, Imag);
%enddef
#define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \
%swig_cplxflt_conv(Type, Constructor, Real, Imag)
#define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \
%swig_cplxdbl_conv(Type, Constructor, Real, Imag)

View file

@ -0,0 +1,23 @@
/*
Create a file with this name, 'javascriptfragments.swg', in your working
directory and add all the %fragments you want to take precedence
over the default ones defined by swig.
For example, if you add:
%fragment(SWIG_AsVal_frag(int),"header") {
SWIGINTERNINLINE int
SWIG_AsVal(int)(PyObject *obj, int *val)
{
<your code here>;
}
}
this will replace the code used to retrieve an integer value for all
the typemaps that need it, including:
int, std::vector<int>, std::list<std::pair<int,int> >, etc.
*/

View file

@ -0,0 +1,69 @@
%insert(wrapper) %{
SWIGINTERN bool JS_registerClass(JSGlobalContextRef context, JSObjectRef parentObject,
const char* className,
JSClassDefinition* definition) {
JSStringRef js_className = JSStringCreateWithUTF8CString(className);
JSObjectRef classObject = JSObjectMake(context, JSClassCreate(definition), NULL);
JSObjectSetProperty(context, parentObject,
js_className, classObject,
kJSPropertyAttributeNone, NULL);
JSStringRelease(js_className);
return true;
}
SWIGINTERN bool JS_registerNamespace(JSGlobalContextRef context,
JSObjectRef namespaceObj, JSObjectRef parentNamespace,
const char* name)
{
JSStringRef js_name = JSStringCreateWithUTF8CString(name);
JSObjectSetProperty(context, parentNamespace,
js_name, namespaceObj,
kJSPropertyAttributeNone, NULL);
JSStringRelease(js_name);
return true;
}
SWIGINTERN bool JS_registerFunction(JSGlobalContextRef context, JSObjectRef object,
const char* functionName, JSObjectCallAsFunctionCallback callback)
{
JSStringRef js_functionName = JSStringCreateWithUTF8CString(functionName);
JSObjectSetProperty(context, object, js_functionName,
JSObjectMakeFunctionWithCallback(context, js_functionName, callback),
kJSPropertyAttributeNone, NULL);
JSStringRelease(js_functionName);
return true;
}
SWIGINTERN bool JS_veto_set_variable(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
{
char buffer[256];
char msg[512];
int res;
JSStringGetUTF8CString(propertyName, buffer, 256);
res = sprintf(msg, "Tried to write read-only variable: %s.", buffer);
if(res<0) {
SWIG_exception(SWIG_ERROR, "Tried to write read-only variable.");
} else {
SWIG_exception(SWIG_ERROR, msg);
}
return false;
}
SWIGINTERN JSValueRef JS_CharPtrToJSValue(JSContextRef context, char* cstr) {
JSValueRef val;
JSStringRef jsstring = JSStringCreateWithUTF8CString((char*) cstr);
val = JSValueMakeString(context, jsstring);
JSStringRelease(jsstring);
return val;
}
%}

View file

@ -0,0 +1,67 @@
%insert(init) %{
SWIGRUNTIME void
SWIG_JSC_SetModule(swig_module_info *swig_module) {}
SWIGRUNTIME swig_module_info *
SWIG_JSC_GetModule(void) {
return 0;
}
#define SWIG_GetModule(clientdata) SWIG_JSC_GetModule()
#define SWIG_SetModule(clientdata, pointer) SWIG_JSC_SetModule(pointer)
%}
%insert(init) "swiginit.swg"
%fragment ("js_initializer_define", "templates") %{
#define SWIGJSC_INIT $jsname_initialize
%}
// Open the initializer function
%insert(init)
%{
#ifdef __cplusplus
extern "C" {
#endif
bool SWIGJSC_INIT (JSGlobalContextRef context, JSObjectRef *exports) {
SWIG_InitializeModule(0);
%}
/* -----------------------------------------------------------------------------
* js_initializer: template for the module initializer function
* - $jsname: module name
* - $jscreatenamespaces: part with code for creating namespace objects
* - $jscreateclasses: part with code for creating classes
* - $jsregisternamespaces: part with code for registration of namespaces
* ----------------------------------------------------------------------------- */
%fragment ("js_initializer", "templates") %{
/* Initialize the base swig type object */
_SwigObject_objectDefinition.staticFunctions = _SwigObject_functions;
_SwigObject_objectDefinition.staticValues = _SwigObject_values;
_SwigObject_classRef = JSClassCreate(&_SwigObject_objectDefinition);
/* Initialize the PackedData class */
_SwigPackedData_objectDefinition.staticFunctions = _SwigPackedData_functions;
_SwigPackedData_objectDefinition.staticValues = _SwigPackedData_values;
_SwigPackedData_objectDefinition.finalize = _wrap_SwigPackedData_delete;
_SwigPackedData_classRef = JSClassCreate(&_SwigPackedData_objectDefinition);
/* Create objects for namespaces */
$jscreatenamespaces
/* Register classes */
$jsregisterclasses
/* Register namespaces */
$jsregisternamespaces
*exports = exports_object;
return true;
}
#ifdef __cplusplus
}
#endif
%}

View file

@ -0,0 +1,40 @@
#ifndef JAVASCRIPT_JAVASCRIPTKW_SWG_
#define JAVASCRIPT_JAVASCRIPTKW_SWG_
/* Warnings for Java keywords */
#define JAVASCRIPTKW(x) %keywordwarn("'" `x` "' is a javascript keyword, renaming to '_"`x`"'",rename="_%s") `x`
/* Taken from https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Reserved_Words */
JAVASCRIPTKW(break);
JAVASCRIPTKW(case);
JAVASCRIPTKW(catch);
JAVASCRIPTKW(continue);
JAVASCRIPTKW(default);
JAVASCRIPTKW(delete);
JAVASCRIPTKW(do);
JAVASCRIPTKW(else);
JAVASCRIPTKW(finally);
JAVASCRIPTKW(for);
JAVASCRIPTKW(function);
JAVASCRIPTKW(if);
JAVASCRIPTKW(in);
JAVASCRIPTKW(instanceof);
JAVASCRIPTKW(new);
JAVASCRIPTKW(return);
JAVASCRIPTKW(switch);
JAVASCRIPTKW(this);
JAVASCRIPTKW(throw);
JAVASCRIPTKW(try);
JAVASCRIPTKW(typeof);
JAVASCRIPTKW(var);
JAVASCRIPTKW(void);
JAVASCRIPTKW(while);
JAVASCRIPTKW(with);
/* others bad names if any*/
// for example %namewarn("321:clone() is a javascript bad method name") *::clone();
#undef JAVASCRIPTKW
#endif //JAVASCRIPT_JAVASCRIPTKW_SWG_

View file

@ -0,0 +1,182 @@
/* ------------------------------------------------------------
* Primitive Types
* ------------------------------------------------------------ */
/* boolean */
%fragment(SWIG_From_frag(bool),"header") {
SWIGINTERNINLINE
JSValueRef SWIG_From_dec(bool)(bool value)
{
return JSValueMakeBoolean(context, value);
}
}
%fragment(SWIG_AsVal_frag(bool),"header",
fragment=SWIG_AsVal_frag(long)) {
SWIGINTERN
int SWIG_AsVal_dec(bool)(JSValueRef obj, bool *val)
{
if(!JSValueIsBoolean(context, obj)) {
return SWIG_ERROR;
}
if (val) *val = JSValueToBoolean(context, obj);
return SWIG_OK;
}
}
/* int */
%fragment(SWIG_From_frag(int),"header") {
SWIGINTERNINLINE JSValueRef
SWIG_From_dec(int)(int value)
{
return JSValueMakeNumber(context, value);
}
}
/* long */
%fragment(SWIG_From_frag(long),"header") {
SWIGINTERNINLINE JSValueRef
SWIG_From_dec(long)(long value)
{
return JSValueMakeNumber(context, value);
}
}
%fragment(SWIG_AsVal_frag(long),"header",
fragment="SWIG_CanCastAsInteger") {
SWIGINTERN int
SWIG_AsVal_dec(long)(JSValueRef obj, long* val)
{
if (!JSValueIsNumber(context, obj)) {
return SWIG_TypeError;
}
if(val) *val = (long) JSValueToNumber(context, obj, NULL);
return SWIG_OK;
}
}
/* unsigned long */
%fragment(SWIG_From_frag(unsigned long),"header",
fragment=SWIG_From_frag(long)) {
SWIGINTERNINLINE JSValueRef
SWIG_From_dec(unsigned long)(unsigned long value)
{
return (value > LONG_MAX) ?
JSValueMakeNumber(context, value) : JSValueMakeNumber(context, %numeric_cast(value,long));
}
}
%fragment(SWIG_AsVal_frag(unsigned long),"header",
fragment="SWIG_CanCastAsInteger") {
SWIGINTERN int
SWIG_AsVal_dec(unsigned long)(JSValueRef obj, unsigned long *val)
{
if(!JSValueIsNumber(context, obj)) {
return SWIG_TypeError;
}
long longVal = (long) JSValueToNumber(context, obj, NULL);
if(longVal < 0) {
return SWIG_OverflowError;
}
if(val) *val = longVal;
return SWIG_OK;
}
}
/* long long */
// Note: these are copied from 'long' and probably need fixing
%fragment(SWIG_From_frag(long long),"header",
fragment=SWIG_From_frag(long),
fragment="<limits.h>") {
SWIGINTERNINLINE JSValueRef
SWIG_From_dec(long long)(long long value)
{
return JSValueMakeNumber(context, value);
}
}
%fragment(SWIG_AsVal_frag(long long),"header",
fragment=SWIG_AsVal_frag(long),
fragment="SWIG_CanCastAsInteger",
fragment="<limits.h>") {
SWIGINTERN int
SWIG_AsVal_dec(long long)(JSValueRef obj, long long* val)
{
if (!JSValueIsNumber(context, obj)) {
return SWIG_TypeError;
}
if(val) *val = (long long) JSValueToNumber(context, obj, NULL);
return SWIG_OK;
}
}
/* unsigned long long */
// Note: these are copied from 'unsigned long' and probably need fixing
%fragment(SWIG_From_frag(unsigned long long),"header",
fragment=SWIG_From_frag(long long),
fragment="<limits.h>") {
SWIGINTERN JSValueRef
SWIG_From_dec(unsigned long long)(unsigned long long value)
{
return (value > LONG_MAX) ?
JSValueMakeNumber(context, value) : JSValueMakeNumber(context, %numeric_cast(value,long));
}
}
%fragment(SWIG_AsVal_frag(unsigned long long),"header",
fragment=SWIG_AsVal_frag(unsigned long),
fragment="SWIG_CanCastAsInteger",
fragment="<limits.h>") {
SWIGINTERN int
SWIG_AsVal_dec(unsigned long long)(JSValueRef obj, unsigned long long *val)
{
if(!JSValueIsNumber(context, obj)) {
return SWIG_TypeError;
}
long long longVal = (unsigned long long) JSValueToNumber(context, obj, NULL);
if(longVal < 0) {
return SWIG_OverflowError;
}
if(val) *val = longVal;
return SWIG_OK;
}
}
/* double */
%fragment(SWIG_From_frag(double),"header") {
SWIGINTERN JSValueRef
SWIG_From_dec(double) (double val)
{
return JSValueMakeNumber(context, val);
}
}
%fragment(SWIG_AsVal_frag(double),"header") {
SWIGINTERN int
SWIG_AsVal_dec(double)(JSValueRef obj, double *val)
{
if(!JSValueIsNumber(context, obj)) {
return SWIG_TypeError;
}
if(val) *val = JSValueToNumber(context, obj, NULL);
return SWIG_OK;
}
}

View file

@ -0,0 +1,334 @@
/* ----------------------------------------------------------------------------
* Errors and exceptions
*
* ---------------------------------------------------------------------------*/
#define SWIG_Error(code, msg) SWIG_JSC_exception(context, exception, code, msg)
#define SWIG_exception(code, msg) SWIG_JSC_exception(context, exception, code, msg)
#define SWIG_fail goto fail
SWIGRUNTIME void SWIG_Javascript_Raise(JSContextRef context, JSValueRef *exception, const char* type) {
JSStringRef message = JSStringCreateWithUTF8CString(type);
JSValueRef error_arguments[1];
JSObjectRef exception_object;
JSValueRef exception_value;
exception_value = JSValueMakeString(context, message);
/* Converting the result to an object will let JavascriptCore add
"sourceURL" (file) and "line" (number) and "message" to the exception,
instead of just returning a raw string. This is extremely important for debugging your errors.
Using JSObjectMakeError is better than JSValueToObject because the latter only populates
"sourceURL" and "line", but not "message" or any others I don't know about.
*/
error_arguments[0] = exception_value;
exception_object = JSObjectMakeError(context, 1, error_arguments, NULL);
/* Return the exception_object */
*exception = exception_object;
JSStringRelease(message);
}
SWIGRUNTIME void SWIG_JSC_exception(JSContextRef context, JSValueRef *exception, int code, const char* msg) {
SWIG_Javascript_Raise(context, exception, msg);
}
/* ----------------------------------------------------------------------------
* The parent class of all Proxies
*
* ---------------------------------------------------------------------------*/
typedef struct {
bool swigCMemOwn;
void *swigCObject;
swig_type_info *info;
} SwigPrivData;
SWIGRUNTIME JSValueRef _wrap_SwigObject_disown(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
{
JSValueRef jsresult;
JSObjectRef obj = JSValueToObject(context, thisObject, NULL);
SwigPrivData *cdata = (SwigPrivData *) JSObjectGetPrivate(obj);
cdata->swigCMemOwn = false;
jsresult = JSValueMakeUndefined(context);
return jsresult;
}
SWIGRUNTIME JSValueRef _wrap_SwigObject_getCPtr(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
{
JSValueRef jsresult;
long result;
JSObjectRef obj = JSValueToObject(context, thisObject, NULL);
SwigPrivData *cdata = (SwigPrivData*) JSObjectGetPrivate(obj);
result = (long) cdata->swigCObject;
jsresult = JSValueMakeNumber(context, result);
return jsresult;
}
SWIGRUNTIME JSValueRef _wrap_SwigObject_equals(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
{
JSValueRef jsresult;
bool result;
JSObjectRef obj = JSValueToObject(context, thisObject, NULL);
SwigPrivData *cdata = (SwigPrivData*) JSObjectGetPrivate(obj);
JSObjectRef obj2 = JSValueToObject(context, argv[0], NULL);
SwigPrivData *cdata2 = (SwigPrivData*) JSObjectGetPrivate(obj2);
result = (cdata->swigCObject == cdata2->swigCObject);
jsresult = JSValueMakeBoolean(context, result);
return jsresult;
}
SWIGRUNTIME JSStaticValue _SwigObject_values[] = {
{
0, 0, 0, 0
}
};
SWIGRUNTIME JSStaticFunction _SwigObject_functions[] = {
{
"disown",_wrap_SwigObject_disown, kJSPropertyAttributeNone
},
{
"equals",_wrap_SwigObject_equals, kJSPropertyAttributeNone
},
{
"getCPtr",_wrap_SwigObject_getCPtr, kJSPropertyAttributeNone
},
{
0, 0, 0
}
};
SWIGRUNTIME JSClassDefinition _SwigObject_objectDefinition;
SWIGRUNTIME JSClassRef _SwigObject_classRef;
SWIGRUNTIME int SWIG_JSC_ConvertInstancePtr(JSContextRef context, JSObjectRef objRef, void** ptr, swig_type_info *info, int flags) {
SwigPrivData *cdata;
cdata = (SwigPrivData *) JSObjectGetPrivate(objRef);
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;
}
}
*ptr = cdata->swigCObject;
if(flags & SWIG_POINTER_DISOWN) {
cdata->swigCMemOwn = false;
}
return SWIG_OK;
}
SWIGRUNTIME int SWIG_JSC_ConvertPtr(JSContextRef context, JSValueRef valRef, void** ptr, swig_type_info *info, int flags) {
JSObjectRef objRef;
/* special case: JavaScript null => C NULL pointer */
if(JSValueIsNull(context, valRef)) {
*ptr=0;
return SWIG_OK;
}
if(!JSValueIsObject(context, valRef)) {
return SWIG_TypeError;
}
objRef = JSValueToObject(context, valRef, NULL);
if(objRef == NULL) {
return SWIG_ERROR;
}
return SWIG_JSC_ConvertInstancePtr(context, objRef, ptr, info, flags);
}
SWIGRUNTIME JSObjectRef SWIG_JSC_NewPointerObj(JSContextRef context, void *ptr, swig_type_info *info, int flags) {
JSClassRef classRef;
JSObjectRef result;
SwigPrivData *cdata;
if (ptr == NULL) {
// HACK: it is not possible to use JSValueToObject (causing seg-fault)
// This static cast turned out to be a workaround
// In future, we should change the interface of this method
// to return JSValueRef instead of JSObjectRef.
return (JSObjectRef) JSValueMakeNull(context);
}
if(info->clientdata == NULL) {
classRef = _SwigObject_classRef;
} else {
classRef = (JSClassRef) info->clientdata;
}
result = JSObjectMake(context, classRef, NULL);
cdata = (SwigPrivData*) malloc(sizeof(SwigPrivData));
cdata->swigCObject = ptr;
cdata->swigCMemOwn = (flags & SWIG_POINTER_OWN) ? 1 : 0;
cdata->info = info;
JSObjectSetPrivate(result, cdata);
return result;
}
#define SWIG_ConvertPtr(obj, ptr, info, flags) SWIG_JSC_ConvertPtr(context, obj, ptr, info, flags)
#define SWIG_NewPointerObj(ptr, info, flags) SWIG_JSC_NewPointerObj(context, ptr, info, flags)
#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_JSC_ConvertInstancePtr(context, obj, pptr, type, flags)
#define SWIG_NewInstanceObj(thisvalue, type, flags) SWIG_JSC_NewPointerObj(context, thisvalue, type, flags)
#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_JSC_ConvertPtr(context, obj, pptr, type, 0)
#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_JSC_NewPointerObj(context, ptr, type, 0)
/* ----------------------------------------------------------------------------
* A class for packed data
*
* ---------------------------------------------------------------------------*/
typedef struct {
void *data;
size_t size;
swig_type_info *type;
} SwigPackedData;
SWIGRUNTIME JSStaticValue _SwigPackedData_values[] = {
{
0, 0, 0, 0
}
};
SWIGRUNTIME JSStaticFunction _SwigPackedData_functions[] = {
{
0, 0, 0
}
};
SWIGRUNTIME JSClassDefinition _SwigPackedData_objectDefinition;
SWIGRUNTIME JSClassRef _SwigPackedData_classRef;
SWIGRUNTIMEINLINE
int SwigJSCPacked_Check(JSContextRef context, JSValueRef valRef) {
return JSValueIsObjectOfClass(context, valRef, _SwigPackedData_classRef);
}
SWIGRUNTIME
swig_type_info* SwigJSCPacked_UnpackData(JSContextRef context, JSValueRef valRef, void *ptr, size_t size) {
if (SwigJSCPacked_Check(context, valRef)) {
JSObjectRef objRef = JSValueToObject(context, valRef, NULL);
SwigPackedData *sobj = (SwigPackedData *) JSObjectGetPrivate(objRef);
if (sobj->size != size) return 0;
memcpy(ptr, sobj->data, size);
return sobj->type;
} else {
return 0;
}
}
SWIGRUNTIME
int SWIG_JSC_ConvertPacked(JSContextRef context, JSValueRef valRef, void *ptr, size_t sz, swig_type_info *ty) {
swig_type_info *to = SwigJSCPacked_UnpackData(context, valRef, ptr, sz);
if (!to) return SWIG_ERROR;
if (ty) {
if (to != ty) {
/* check type cast? */
swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
if (!tc) return SWIG_ERROR;
}
}
return SWIG_OK;
}
SWIGRUNTIME
JSValueRef SWIG_JSC_NewPackedObj(JSContextRef context, void *data, size_t size, swig_type_info *type) {
JSClassRef classRef = _SwigObject_classRef;
JSObjectRef result = JSObjectMake(context, classRef, NULL);
SwigPackedData* cdata = (SwigPackedData*) malloc(sizeof(SwigPackedData));
cdata->data = data;
cdata->size = size;
cdata->type = type;
JSObjectSetPrivate(result, cdata);
return result;
}
/* SwigPackedData wrappers */
SWIGRUNTIME
void _wrap_SwigPackedData_delete(JSObjectRef obj)
{
SwigPackedData* cdata = (SwigPackedData*) JSObjectGetPrivate(obj);
if (cdata) {
free(cdata->data);
}
}
/* for C++ member pointers, ie, member methods */
#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_JSC_ConvertPacked(context, obj, ptr, sz, ty)
#define SWIG_NewMemberObj(ptr, sz, type) SWIG_JSC_NewPackedObj(context, ptr, sz, type)
/* ---------------------------------------------------------------------------
* Support for IN/OUTPUT typemaps (see Lib/typemaps/inoutlist.swg)
*
* ---------------------------------------------------------------------------*/
SWIGRUNTIME
unsigned int SWIGJSC_ArrayLength(JSContextRef context, JSObjectRef arr) {
static JSStringRef LENGTH = 0;
JSValueRef exception = NULL;
JSValueRef js_length;
double length;
if (LENGTH == 0) {
LENGTH = JSStringCreateWithUTF8CString("length");
}
js_length = JSObjectGetProperty(context, arr, LENGTH, &exception);
if (exception == 0 && JSValueIsNumber(context, js_length)) {
length = JSValueToNumber(context, js_length, 0);
return (unsigned int) length;
} else {
return 0;
}
}
SWIGRUNTIME
JSValueRef SWIGJSC_AppendOutput(JSContextRef context, JSValueRef value, JSValueRef obj) {
JSObjectRef arr;
unsigned int length;
if (JSValueIsUndefined(context, value)) {
arr = JSObjectMakeArray(context, 0, 0, 0);
} else {
arr = JSValueToObject(context, value, 0);
}
length = SWIGJSC_ArrayLength(context, arr);
JSObjectSetPropertyAtIndex(context, arr, length, obj, 0);
return arr;
}

View file

@ -0,0 +1,19 @@
/* -----------------------------------------------------------------------------
* javascriptruntime.swg
*
* Javascript support code
* ----------------------------------------------------------------------------- */
%insert(runtime) %{
#include <JavaScriptCore/JavaScript.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <limits.h>
%}
%insert(runtime) "swigrun.swg"; /* SWIG API */
%insert(runtime) "swigerrors.swg"; /* SWIG errors */
%insert(runtime) "javascriptrun.swg"; /* SWIG errors */

View file

@ -0,0 +1,184 @@
/* ------------------------------------------------------------
* utility methods for char strings
* ------------------------------------------------------------ */
%fragment("SWIG_AsCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") {
SWIGINTERN int
SWIG_JSC_AsCharPtrAndSize(JSContextRef context, JSValueRef valRef, char** cptr, size_t* psize, int *alloc)
{
if(JSValueIsString(context, valRef)) {
JSStringRef js_str = JSValueToStringCopy(context, valRef, NULL);
size_t len = JSStringGetMaximumUTF8CStringSize(js_str);
char* cstr = (char*) %new_array(len, char);
/* JSStringGetUTF8CString returns the length including 0-terminator */
len = JSStringGetUTF8CString(js_str, cstr, len);
if(alloc) *alloc = SWIG_NEWOBJ;
if(psize) *psize = len;
if(cptr) *cptr = cstr;
return SWIG_OK;
} else {
if(JSValueIsObject(context, valRef)) {
JSObjectRef obj = JSValueToObject(context, valRef, NULL);
// try if the object is a wrapped char[]
swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
if (pchar_descriptor) {
void* vptr = 0;
if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) {
if (cptr) *cptr = (char *) vptr;
if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0;
if (alloc) *alloc = SWIG_OLDOBJ;
return SWIG_OK;
}
}
return SWIG_TypeError;
} else {
return SWIG_TypeError;
}
}
}
}
%fragment("SWIG_FromCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") {
SWIGINTERNINLINE JSValueRef
SWIG_JSC_FromCharPtrAndSize(JSContextRef context, const char* carray, size_t size)
{
if (carray) {
if (size > INT_MAX) {
// TODO: handle extra long strings
//swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
//return pchar_descriptor ?
// SWIG_InternalNewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : SWIG_Py_Void();
return JSValueMakeUndefined(context);
} else {
JSStringRef jsstring;
if(size < 2) {
char c[2];
int i;
for(i=0;i<size;++i) {
c[i] = carray[i];
}
c[size] = 0;
jsstring = JSStringCreateWithUTF8CString(c);
} else {
jsstring = JSStringCreateWithUTF8CString(carray);
}
JSValueRef result = JSValueMakeString(context, jsstring);
JSStringRelease(jsstring);
return result;
}
} else {
return JSValueMakeUndefined(context);
}
}
}
%define %_typemap2_string(StringCode, CharCode,
Char, CharName,
SWIG_AsCharPtrAndSize,
SWIG_FromCharPtrAndSize,
SWIG_CharPtrLen,
SWIG_CharBufLen,
SWIG_NewCopyCharArray,
SWIG_DeleteCharArray,
FragLimits, CHAR_MIN, CHAR_MAX)
%fragment("SWIG_From"#CharName"Ptr","header",fragment=#SWIG_FromCharPtrAndSize) {
SWIGINTERNINLINE SWIG_Object
SWIG_JSC_From##CharName##Ptr(JSContextRef context, const Char *cptr)
{
return SWIG_JSC_FromCharPtrAndSize(context, cptr, (cptr ? SWIG_CharPtrLen(cptr) : 0));
}
}
%fragment("SWIG_From"#CharName"Array","header",fragment=#SWIG_FromCharPtrAndSize) {
SWIGINTERNINLINE SWIG_Object
SWIG_JSC_From##CharName##Array(JSContextRef context, const Char *cptr, size_t size)
{
return SWIG_JSC_FromCharPtrAndSize(context, cptr, size);
}
}
%fragment("SWIG_As" #CharName "Ptr","header",fragment=#SWIG_AsCharPtrAndSize) {
%define_as(SWIG_As##CharName##Ptr(obj, val, alloc), SWIG_JSC_AsCharPtrAndSize(context, obj, val, NULL, alloc))
}
%fragment("SWIG_As" #CharName "Array","header",fragment=#SWIG_AsCharPtrAndSize) {
SWIGINTERN int
SWIG_JSC_As##CharName##Array(JSContextRef context, SWIG_Object obj, Char *val, size_t size)
{
Char* cptr = 0; size_t csize = 0; int alloc = SWIG_OLDOBJ;
int res = SWIG_JSC_AsCharPtrAndSize(context, obj, &cptr, &csize, &alloc);
if (SWIG_IsOK(res)) {
if ((csize == size + 1) && cptr && !(cptr[csize-1])) --csize;
if (csize <= size) {
if (val) {
if (csize) memcpy(val, cptr, csize*sizeof(Char));
if (csize < size) memset(val + csize, 0, (size - csize)*sizeof(Char));
}
if (alloc == SWIG_NEWOBJ) {
SWIG_DeleteCharArray(cptr);
res = SWIG_DelNewMask(res);
}
return res;
}
if (alloc == SWIG_NEWOBJ) SWIG_DeleteCharArray(cptr);
}
return SWIG_TypeError;
}
#define SWIG_As##CharName##Array(obj, val, size) SWIG_JSC_As##CharName##Array(context, obj, val, size)
}
/* Char */
%fragment(SWIG_From_frag(Char),"header",fragment=#SWIG_FromCharPtrAndSize) {
SWIGINTERNINLINE SWIG_Object
SWIG_From_dec(Char)(Char c)
{
return SWIG_JSC_FromCharPtrAndSize(context, &c,1);
}
}
%fragment(SWIG_AsVal_frag(Char),"header",
fragment="SWIG_As"#CharName"Array",
fragment=FragLimits,
fragment=SWIG_AsVal_frag(long)) {
SWIGINTERN int
SWIG_AsVal_dec(Char)(SWIG_Object obj, Char *val)
{
int res = SWIG_As##CharName##Array(obj, val, 1);
if (!SWIG_IsOK(res)) {
long v;
res = SWIG_AddCast(SWIG_AsVal(long)(obj, &v));
if (SWIG_IsOK(res)) {
if ((CHAR_MIN <= v) && (v <= CHAR_MAX)) {
if (val) *val = %numeric_cast(v, Char);
} else {
res = SWIG_OverflowError;
}
}
}
return res;
}
}
%_typemap_string(StringCode,
Char,
SWIG_AsCharPtrAndSize,
SWIG_FromCharPtrAndSize,
SWIG_CharPtrLen,
SWIG_CharBufLen,
SWIG_As##CharName##Ptr,
SWIG_From##CharName##Ptr,
SWIG_As##CharName##Array,
SWIG_NewCopyCharArray,
SWIG_DeleteCharArray)
%enddef
%insert(runtime) %{
#define SWIG_AsCharPtrAndSize(val, cptr, psize, alloc) SWIG_JSC_AsCharPtrAndSize(context, val, cptr, psize, alloc)
#define SWIG_FromCharPtrAndSize(cptr, size) SWIG_JSC_FromCharPtrAndSize(context, cptr, size)
#define SWIG_FromCharPtr(cptr) SWIG_JSC_FromCharPtr(context, cptr)
%}

View file

@ -0,0 +1,54 @@
/* ------------------------------------------------------------
* Typemap specializations for Javascript
* ------------------------------------------------------------ */
/* ------------------------------------------------------------
* Fragment section
* ------------------------------------------------------------ */
/* These macros are necessary to provide an extra parameter
to SWIG_AsVal_dec functions (JSContextRef context).
They must be defined before including `typemaps/fragments.swg`
*/
#define SWIG_FROM_DECL_ARGS SWIG_JSC_FROM_DECL_ARGS
#define SWIG_FROM_CALL_ARGS SWIG_JSC_FROM_CALL_ARGS
#define SWIG_AS_DECL_ARGS SWIG_JSC_AS_DECL_ARGS
#define SWIG_AS_CALL_ARGS SWIG_JSC_AS_CALL_ARGS
/* Include fundamental fragemt definitions */
%include <typemaps/fragments.swg>
/* Look for user fragments file. */
%include <javascriptfragments.swg>
/* Javascript fragments for fundamental types */
%include <javascriptprimtypes.swg>
/* Javascript fragments for char* strings */
%include <javascriptstrings.swg>
/* ------------------------------------------------------------
* Unified typemap section
* ------------------------------------------------------------ */
#define SWIG_Object JSValueRef
#define VOID_Object JSValueMakeUndefined(context)
/* append output */
#define SWIG_AppendOutput(result, obj) SWIGJSC_AppendOutput(context, result, obj)
/* set constant */
#define SWIG_SetConstant(name, obj)
/* raise */
#define SWIG_Raise(obj, type, desc) SWIG_Javascript_Raise(context, exception, type)
%insert("runtime") %{
#define SWIG_JSC_FROM_DECL_ARGS(arg1) (JSContextRef context, arg1)
#define SWIG_JSC_FROM_CALL_ARGS(arg1) (context, arg1)
#define SWIG_JSC_AS_DECL_ARGS(arg1, arg2) (JSContextRef context, arg1, arg2)
#define SWIG_JSC_AS_CALL_ARGS(arg1, arg2) (context, arg1, arg2)
%}
/* Include the unified typemap library */
%include <typemaps/swigtypemaps.swg>

View file

@ -0,0 +1,5 @@
%include <std_except.i>
%apply size_t { std::size_t };
%apply const size_t& { const std::size_t& };

View file

@ -0,0 +1,19 @@
/*
* STD C++ complex typemaps
*/
%include <javascriptcomplex.swg>
%{
#include <complex>
%}
/* defining the complex as/from converters */
%swig_cplxdbl_convn(std::complex<double>, std::complex<double>, std::real, std::imag)
%swig_cplxflt_convn(std::complex<float>, std::complex<float>, std::real, std::imag)
/* defining the typemaps */
%typemaps_primitive(%checkcode(CPLXDBL), std::complex<double>);
%typemaps_primitive(%checkcode(CPLXFLT), std::complex<float>);

View file

@ -0,0 +1 @@
%include <std/_std_deque.i>

View file

@ -0,0 +1 @@
%include <typemaps/std_except.swg>

View file

@ -0,0 +1,74 @@
/* -----------------------------------------------------------------------------
* std_map.i
*
* SWIG typemaps for std::map
* ----------------------------------------------------------------------------- */
%include <std_common.i>
// ------------------------------------------------------------------------
// std::map
// ------------------------------------------------------------------------
%{
#include <map>
#include <algorithm>
#include <stdexcept>
%}
// exported class
namespace std {
template<class K, class T> class map {
// add typemaps here
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
map();
map(const map<K,T> &);
unsigned int size() const;
bool empty() const;
void clear();
%extend {
const T& get(const K& key) throw (std::out_of_range) {
std::map<K,T >::iterator i = self->find(key);
if (i != self->end())
return i->second;
else
throw std::out_of_range("key not found");
}
void set(const K& key, const T& x) {
(*self)[key] = x;
}
void del(const K& key) throw (std::out_of_range) {
std::map<K,T >::iterator i = self->find(key);
if (i != self->end())
self->erase(i);
else
throw std::out_of_range("key not found");
}
bool has_key(const K& key) {
std::map<K,T >::iterator i = self->find(key);
return i != self->end();
}
}
};
// Legacy macros (deprecated)
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
#warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary"
%enddef
%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
#warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary"
%enddef
%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
#warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary"
%enddef
}

View file

@ -0,0 +1,34 @@
/* -----------------------------------------------------------------------------
* std_pair.i
*
* SWIG typemaps for std::pair
* ----------------------------------------------------------------------------- */
%include <std_common.i>
%include <exception.i>
// ------------------------------------------------------------------------
// std::pair
// ------------------------------------------------------------------------
%{
#include <utility>
%}
namespace std {
template<class T, class U> struct pair {
pair();
pair(T first, U second);
pair(const pair& p);
template <class U1, class U2> pair(const pair<U1, U2> &p);
T first;
U second;
};
// add specializations here
}

View file

@ -0,0 +1 @@
%include <typemaps/std_string.swg>

View file

@ -0,0 +1,85 @@
/* -----------------------------------------------------------------------------
* std_vector.i
* ----------------------------------------------------------------------------- */
%include <std_common.i>
%{
#include <vector>
#include <stdexcept>
%}
namespace std {
template<class T> class vector {
public:
typedef size_t size_type;
typedef T value_type;
typedef const value_type& const_reference;
vector();
vector(size_type n);
size_type size() const;
size_type capacity() const;
void reserve(size_type n);
%rename(isEmpty) empty;
bool empty() const;
void clear();
%rename(add) push_back;
void push_back(const value_type& x);
%extend {
const_reference get(int i) throw (std::out_of_range) {
int size = int(self->size());
if (i>=0 && i<size)
return (*self)[i];
else
throw std::out_of_range("vector index out of range");
}
void set(int i, const value_type& val) throw (std::out_of_range) {
int size = int(self->size());
if (i>=0 && i<size)
(*self)[i] = val;
else
throw std::out_of_range("vector index out of range");
}
}
};
// bool specialization
template<> class vector<bool> {
public:
typedef size_t size_type;
typedef bool value_type;
typedef bool const_reference;
vector();
vector(size_type n);
size_type size() const;
size_type capacity() const;
void reserve(size_type n);
%rename(isEmpty) empty;
bool empty() const;
void clear();
%rename(add) push_back;
void push_back(const value_type& x);
%extend {
bool get(int i) throw (std::out_of_range) {
int size = int(self->size());
if (i>=0 && i<size)
return (*self)[i];
else
throw std::out_of_range("vector index out of range");
}
void set(int i, const value_type& val) throw (std::out_of_range) {
int size = int(self->size());
if (i>=0 && i<size)
(*self)[i] = val;
else
throw std::out_of_range("vector index out of range");
}
}
};
}
%define specialize_std_vector(T)
#warning "specialize_std_vector - specialization for type T no longer needed"
%enddef

10
Lib/javascript/jsc/stl.i Normal file
View file

@ -0,0 +1,10 @@
/* -----------------------------------------------------------------------------
* stl.i
* ----------------------------------------------------------------------------- */
%include <std_common.i>
%include <std_string.i>
%include <std_vector.i>
%include <std_map.i>
%include <std_pair.i>

View file

@ -0,0 +1,148 @@
/* -----------------------------------------------------------------------------
* typemaps.i
*
* Pointer handling
* These mappings provide support for input/output arguments and common
* uses for C/C++ pointers.
* ----------------------------------------------------------------------------- */
// INPUT typemaps.
// These remap a C pointer to be an "INPUT" value which is passed by value
// instead of reference.
/*
The following methods can be applied to turn a pointer into a simple
"input" value. That is, instead of passing a pointer to an object,
you would use a real value instead.
int *INPUT
short *INPUT
long *INPUT
long long *INPUT
unsigned int *INPUT
unsigned short *INPUT
unsigned long *INPUT
unsigned long long *INPUT
unsigned char *INPUT
bool *INPUT
float *INPUT
double *INPUT
To use these, suppose you had a C function like this :
double fadd(double *a, double *b) {
return *a+*b;
}
You could wrap it with SWIG as follows :
%include <typemaps.i>
double fadd(double *INPUT, double *INPUT);
or you can use the %apply directive :
%include <typemaps.i>
%apply double *INPUT { double *a, double *b };
double fadd(double *a, double *b);
*/
// OUTPUT typemaps. These typemaps are used for parameters that
// are output only. The output value is appended to the result as
// a list element.
/*
The following methods can be applied to turn a pointer into an "output"
value. When calling a function, no input value would be given for
a parameter, but an output value would be returned. In the case of
multiple output values, they are returned in the form of a Python tuple.
int *OUTPUT
short *OUTPUT
long *OUTPUT
long long *OUTPUT
unsigned int *OUTPUT
unsigned short *OUTPUT
unsigned long *OUTPUT
unsigned long long *OUTPUT
unsigned char *OUTPUT
bool *OUTPUT
float *OUTPUT
double *OUTPUT
For example, suppose you were trying to wrap the modf() function in the
C math library which splits x into integral and fractional parts (and
returns the integer part in one of its parameters).K:
double modf(double x, double *ip);
You could wrap it with SWIG as follows :
%include <typemaps.i>
double modf(double x, double *OUTPUT);
or you can use the %apply directive :
%include <typemaps.i>
%apply double *OUTPUT { double *ip };
double modf(double x, double *ip);
The Python output of the function would be a tuple containing both
output values.
*/
// INOUT
// Mappings for an argument that is both an input and output
// parameter
/*
The following methods can be applied to make a function parameter both
an input and output value. This combines the behavior of both the
"INPUT" and "OUTPUT" methods described earlier. Output values are
returned in the form of a Python tuple.
int *INOUT
short *INOUT
long *INOUT
long long *INOUT
unsigned int *INOUT
unsigned short *INOUT
unsigned long *INOUT
unsigned long long *INOUT
unsigned char *INOUT
bool *INOUT
float *INOUT
double *INOUT
For example, suppose you were trying to wrap the following function :
void neg(double *x) {
*x = -(*x);
}
You could wrap it with SWIG as follows :
%include <typemaps.i>
void neg(double *INOUT);
or you can use the %apply directive :
%include <typemaps.i>
%apply double *INOUT { double *x };
void neg(double *x);
Unlike C, this mapping does not directly modify the input value (since
this makes no sense in Python). Rather, the modified input value shows
up as the return value of the function. Thus, to apply this function
to a Python variable you might do this :
x = neg(x)
Note : previous versions of SWIG used the symbol 'BOTH' to mark
input/output arguments. This is still supported, but will be slowly
phased out in future releases.
*/
%include <typemaps/typemaps.swg>

View file

@ -0,0 +1,125 @@
/* -----------------------------------------------------------------------------
* arrays_javascript.i
*
* These typemaps give more natural support for arrays. The typemaps are not efficient
* as there is a lot of copying of the array values whenever the array is passed to C/C++
* from JavaScript and vice versa. The JavaScript array is expected to be the same size as the C array.
* An exception is thrown if they are not.
*
* Example usage:
* Wrapping:
*
* %include <arrays_javascript.i>
* %inline %{
* extern int FiddleSticks[3];
* %}
*
* Use from JavaScript like this:
*
* var fs = [10, 11, 12];
* example.FiddleSticks = fs;
* fs = example.FiddleSticks;
* ----------------------------------------------------------------------------- */
%fragment("SWIG_JSCGetIntProperty", "header", fragment=SWIG_AsVal_frag(int)) {}
%fragment("SWIG_JSCGetNumberProperty", "header", fragment=SWIG_AsVal_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())
{
// Convert into Array
array = v8::Local<v8::Array>::Cast($input);
length = $1_dim0;
$1 = ($*1_ltype *)malloc(sizeof($*1_ltype) * length);
// Get each element from array
for (i = 0; i < length; i++)
{
jsvalue = array->Get(i);
// Get primitive value from JSObject
res = SWIG_AsVal(int)(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) int[], int[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);
for (i = 0; i < length; i++)
{
array->Set(i, SWIG_From(int)($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);
length = $1_dim0;
$1 = ($*1_ltype *)malloc(sizeof($*1_ltype) * length);
// 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

@ -0,0 +1,26 @@
/* -----------------------------------------------------------------------------
* ccomplex.i
*
* C complex typemaps
* ISO C99: 7.3 Complex arithmetic <complex.h>
* ----------------------------------------------------------------------------- */
%include <javscriptcomplex.swg>
%{
#include <complex.h>
%}
/* C complex constructor */
#define CCplxConst(r, i) ((r) + I*(i))
%swig_cplxflt_convn(float complex, CCplxConst, creal, cimag);
%swig_cplxdbl_convn(double complex, CCplxConst, creal, cimag);
%swig_cplxdbl_convn(complex, CCplxConst, creal, cimag);
/* declaring the typemaps */
%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float complex);
%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double complex);
%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex);

View file

@ -0,0 +1 @@
%include <typemaps/cdata.swg>

View file

@ -0,0 +1,6 @@
#ifdef __cplusplus
%include <std_complex.i>
#else
%include <ccomplex.i>
#endif

View file

@ -0,0 +1 @@
%include <typemaps/exception.swg>

View file

@ -0,0 +1,19 @@
/* -----------------------------------------------------------------------------
* javascript.swg
*
* Javascript typemaps
* ----------------------------------------------------------------------------- */
%include <typemaps/swigmacros.swg>
%include <javascripttypemaps.swg>
%include <javascriptruntime.swg>
%include <javascripthelpers.swg>
%include <javascriptkw.swg>
%include <javascriptcode.swg>
%include <javascriptinit.swg>

View file

@ -0,0 +1,468 @@
/* -----------------------------------------------------------------------------
* js_ctor: template for wrapping a ctor.
* - $jswrapper: wrapper of called ctor
* - $jslocals: locals part of wrapper
* - $jscode: code part of wrapper
* - $jsargcount: number of arguments
* - $jsmangledtype: mangled type of class
* ----------------------------------------------------------------------------- */
%fragment("js_ctor", "templates") %{
SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
v8::HandleScope scope;
v8::Handle<v8::Object> self = args.Holder();
$jslocals
if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
$jscode
SWIGV8_SetPrivateData(self, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN);
SWIGV8_RETURN(self);
goto fail;
fail:
SWIGV8_RETURN(v8::Undefined());
}
%}
/* -----------------------------------------------------------------------------
* js_veto_ctor: a vetoing ctor for abstract classes
* - $jswrapper: name of wrapper
* - $jsname: class name
* ----------------------------------------------------------------------------- */
%fragment ("js_veto_ctor", "templates")
%{
SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
v8::HandleScope scope;
SWIG_exception(SWIG_ERROR, "Class $jsname can not be instantiated");
SWIGV8_RETURN(v8::Undefined());
}
%}
/* -----------------------------------------------------------------------------
* js_ctor_dispatcher: dispatcher for overloaded constructors
* - $jswrapper: name of wrapper
* - $jsname: class name
* - $jsdispatchcases: part containing code for dispatching
* ----------------------------------------------------------------------------- */
%fragment ("js_ctor_dispatcher", "templates")
%{
SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
v8::HandleScope scope;
OverloadErrorHandler errorHandler;
v8::Handle<v8::Value> self;
// switch all cases by means of series of if-returns.
$jsdispatchcases
// default:
SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for construction of $jsmangledname");
fail:
SWIGV8_RETURN(v8::Undefined());
}
%}
/* -----------------------------------------------------------------------------
* js_overloaded_ctor: template for wrapping a ctor.
* - $jswrapper: wrapper of called ctor
* - $jslocals: locals part of wrapper
* - $jscode: code part of wrapper
* - $jsargcount: number of arguments
* - $jsmangledtype: mangled type of class
* ----------------------------------------------------------------------------- */
%fragment("js_overloaded_ctor", "templates") %{
SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args, V8ErrorHandler& SWIGV8_ErrorHandler) {
v8::HandleScope scope;
v8::Handle<v8::Object> self = args.Holder();
$jslocals
if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
$jscode
SWIGV8_SetPrivateData(self, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN);
SWIGV8_RETURN(self);
goto fail;
fail:
SWIGV8_RETURN(v8::Undefined());
}
%}
/* -----------------------------------------------------------------------------
* js_ctor_dispatch_case: template for a dispatch case for calling an overloaded ctor.
* - $jsargcount: number of arguments of called ctor
* - $jswrapper: wrapper of called ctor
*
* Note: a try-catch-like mechanism is used to switch cases
* ----------------------------------------------------------------------------- */
%fragment ("js_ctor_dispatch_case", "templates")
%{
if(args.Length() == $jsargcount) {
errorHandler.err.Clear();
#if SWIG_V8_VERSION < 0x031900
self = $jswrapper(args, errorHandler);
if(errorHandler.err.IsEmpty()) {
return scope.Close(self);
}
#else
$jswrapper(args, errorHandler);
if(errorHandler.err.IsEmpty()) {
return;
}
#endif
}
%}
/* -----------------------------------------------------------------------------
* js_dtor: template for a destructor wrapper
* - $jsmangledname: mangled class name
* - $jstype: class type
* ----------------------------------------------------------------------------- */
%fragment ("js_dtor", "templates")
%{
#if (SWIG_V8_VERSION < 0x031900)
void $jswrapper(v8::Persistent< v8::Value > object, void *parameter)
{
SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
#else
void $jswrapper(v8::Isolate *isolate, v8::Persistent< v8::Object > * object, SWIGV8_Proxy *proxy)
{
#endif
if(proxy->swigCMemOwn && proxy->swigCObject) {
#ifdef SWIGRUNTIME_DEBUG
printf("Deleting wrapped instance: %s\n", proxy->info->name);
#endif
$jsfree proxy->swigCObject;
}
delete proxy;
object.Clear();
#if (SWIG_V8_VERSION < 0x031900)
object.Dispose();
#elif (SWIG_V8_VERSION < 0x032100)
object->Dispose(isolate);
#else
object->Dispose();
#endif
}
%}
/* -----------------------------------------------------------------------------
* js_dtoroverride: template for a destructor wrapper
* - $jsmangledname: mangled class name
* - $jstype: class type
* - ${destructor_action}: The custom destructor action to invoke.
* ----------------------------------------------------------------------------- */
%fragment ("js_dtoroverride", "templates")
%{
#if (SWIG_V8_VERSION < 0x031900)
void $jswrapper(v8::Persistent< v8::Value > object, void *parameter)
{
SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
#else
void $jswrapper(v8::Isolate *isolate, v8::Persistent< v8::Object > * object, SWIGV8_Proxy *proxy)
{
#endif
if(proxy->swigCMemOwn && proxy->swigCObject) {
$jstype arg1 = ($jstype)proxy->swigCObject;
${destructor_action}
}
delete proxy;
#if (SWIG_V8_VERSION < 0x031900)
object.Dispose();
#elif (SWIG_V8_VERSION < 0x032100)
object->Dispose(isolate);
#else
object->Dispose();
#endif
}
%}
/* -----------------------------------------------------------------------------
* js_getter: template for getter function wrappers
* - $jswrapper: wrapper function name
* - $jslocals: locals part of wrapper
* - $jscode: code part of wrapper
* ----------------------------------------------------------------------------- */
%fragment("js_getter", "templates")
%{
SwigV8ReturnValue $jswrapper(v8::Local<v8::String> property, const SwigV8PropertyCallbackInfo& info) {
v8::HandleScope scope;
v8::Handle<v8::Value> jsresult;
$jslocals
$jscode
SWIGV8_RETURN_INFO(jsresult, info);
goto fail;
fail:
SWIGV8_RETURN_INFO(v8::Undefined(), info);
}
%}
/* -----------------------------------------------------------------------------
* js_setter: template for setter function wrappers
* - $jswrapper: wrapper function name
* - $jslocals: locals part of wrapper
* - $jscode: code part of wrapper
* ----------------------------------------------------------------------------- */
%fragment("js_setter", "templates")
%{
void $jswrapper(v8::Local<v8::String> property, v8::Local<v8::Value> value,
const SwigV8PropertyCallbackInfoVoid& info) {
v8::HandleScope scope;
$jslocals
$jscode
goto fail;
fail:
return;
}
%}
/* -----------------------------------------------------------------------------
* js_function: template for function wrappers
* - $jswrapper: wrapper function name
* - $jslocals: locals part of wrapper
* - $jscode: code part of wrapper
* ----------------------------------------------------------------------------- */
%fragment("js_function", "templates")
%{
SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
v8::HandleScope scope;
v8::Handle<v8::Value> jsresult;
$jslocals
if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
$jscode
SWIGV8_RETURN(jsresult);
goto fail;
fail:
SWIGV8_RETURN(v8::Undefined());
}
%}
/* -----------------------------------------------------------------------------
* js_function_dispatcher: template for a function dispatcher for overloaded functions
* - $jswrapper: wrapper function name
* - $jsname: name of the wrapped function
* - $jslocals: locals part of wrapper
* - $jscode: code part of wrapper
* ----------------------------------------------------------------------------- */
%fragment("js_function_dispatcher", "templates")
%{
SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
v8::HandleScope scope;
v8::Handle<v8::Value> jsresult;
OverloadErrorHandler errorHandler;
$jscode
SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for function $jsname.");
goto fail;
fail:
SWIGV8_RETURN(v8::Undefined());
}
%}
/* -----------------------------------------------------------------------------
* js_overloaded_function: template for a overloaded function
* - $jswrapper: wrapper function name
* - $jslocals: locals part of wrapper
* - $jscode: code part of wrapper
* ----------------------------------------------------------------------------- */
%fragment ("js_overloaded_function", "templates")
%{
SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args, V8ErrorHandler& SWIGV8_ErrorHandler)
{
v8::HandleScope scope;
v8::Handle<v8::Value> jsresult;
$jslocals
$jscode
SWIGV8_RETURN(jsresult);
goto fail;
fail:
SWIGV8_RETURN(v8::Undefined());
}
%}
/* -----------------------------------------------------------------------------
* js_function_dispatch_case: template for a case used in the function dispatcher
* - $jswrapper: wrapper function name
* - $jsargcount: number of arguments of overloaded function
* - $jscode: code part of wrapper
* ----------------------------------------------------------------------------- */
%fragment ("js_function_dispatch_case", "templates")
%{
if(args.Length() == $jsargcount) {
errorHandler.err.Clear();
#if (SWIG_V8_VERSION < 0x031900)
jsresult = $jswrapper(args, errorHandler);
if(errorHandler.err.IsEmpty()) {
return scope.Close(jsresult);
}
#else
$jswrapper(args, errorHandler);
if(errorHandler.err.IsEmpty()) {
return;
}
#endif
}
%}
/* -----------------------------------------------------------------------------
* jsv8_declare_class_template: template for a class template declaration.
* - $jsmangledname: mangled class name
* ----------------------------------------------------------------------------- */
%fragment("jsv8_declare_class_template", "templates")
%{
SWIGV8_ClientData $jsmangledname_clientData;
%}
/* -----------------------------------------------------------------------------
* jsv8_define_class_template: template for a class template definition.
* - $jsmangledname: mangled class name
* - $jsmangledtype: mangled class type
* - $jsdtor: the dtor wrapper
* ----------------------------------------------------------------------------- */
%fragment("jsv8_define_class_template", "templates")
%{
v8::Handle<v8::FunctionTemplate> $jsmangledname_class = SWIGV8_CreateClassTemplate("$jsmangledname");
#if (SWIG_V8_VERSION < 0x031900)
$jsmangledname_clientData.class_templ = v8::Persistent<v8::FunctionTemplate>::New($jsmangledname_class);
#else
$jsmangledname_clientData.class_templ.Reset(v8::Isolate::GetCurrent(), $jsmangledname_class);
#endif
$jsmangledname_clientData.dtor = $jsdtor;
if (SWIGTYPE_$jsmangledtype->clientdata == 0) {
SWIGTYPE_$jsmangledtype->clientdata = &$jsmangledname_clientData;
}
%}
/* -----------------------------------------------------------------------------
* jsv8_inherit: template for an class inherit statement.
* - $jsmangledname: mangled class name
* - $jsbaseclass: mangled name of the base class
* ----------------------------------------------------------------------------- */
%fragment("jsv8_inherit", "templates")
%{
if (SWIGTYPE_p$jsbaseclass->clientdata && !(static_cast<SWIGV8_ClientData *>(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ.IsEmpty()))
{
#if (SWIG_V8_VERSION < 0x031900)
$jsmangledname_class->Inherit(static_cast<SWIGV8_ClientData *>(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ);
#else
$jsmangledname_class->Inherit(
v8::Handle<v8::FunctionTemplate>::New(
v8::Isolate::GetCurrent(),
static_cast<SWIGV8_ClientData *>(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ)
);
#endif
#ifdef SWIGRUNTIME_DEBUG
printf("Inheritance successful $jsmangledname $jsbaseclass\n");
#endif
} else {
#ifdef SWIGRUNTIME_DEBUG
printf("Unable to inherit baseclass, it didn't exist $jsmangledname $jsbaseclass\n");
#endif
}
%}
/* -----------------------------------------------------------------------------
* jsv8_create_class_instance: template for creating an class object.
* - $jsname: class name
* - $jsmangledname: mangled class name
* ----------------------------------------------------------------------------- */
%fragment("jsv8_create_class_instance", "templates")
%{
v8::Handle<v8::FunctionTemplate> $jsmangledname_class_0 = SWIGV8_CreateClassTemplate("$jsname");
$jsmangledname_class_0->SetCallHandler($jsctor);
$jsmangledname_class_0->Inherit($jsmangledname_class);
$jsmangledname_class_0->SetHiddenPrototype(true);
v8::Handle<v8::Object> $jsmangledname_obj = $jsmangledname_class_0->GetFunction();
%}
/* -----------------------------------------------------------------------------
* jsv8_register_class: template for a statement that registers a class in a parent namespace.
* - $jsname: class name
* - $jsmangledname: mangled class name
* - $jsparent: mangled name of parent namespace
* ----------------------------------------------------------------------------- */
%fragment("jsv8_register_class", "templates")
%{
$jsparent_obj->Set(v8::String::NewSymbol("$jsname"), $jsmangledname_obj);
%}
/* -----------------------------------------------------------------------------
* jsv8_create_namespace: template for a statement that creates a namespace object.
* - $jsmangledname: mangled namespace name
* ----------------------------------------------------------------------------- */
%fragment("jsv8_create_namespace", "templates")
%{
v8::Handle<v8::Object> $jsmangledname_obj = v8::Object::New();
%}
/* -----------------------------------------------------------------------------
* jsv8_register_namespace: template for a statement that registers a namespace in a parent namespace.
* - $jsname: name of namespace
* - $jsmangledname: mangled name of namespace
* - $jsparent: mangled name of parent namespace
* ----------------------------------------------------------------------------- */
%fragment("jsv8_register_namespace", "templates")
%{
$jsparent_obj->Set(v8::String::NewSymbol("$jsname"), $jsmangledname_obj);
%}
/* -----------------------------------------------------------------------------
* jsv8_register_member_function: template for a statement that registers a member function.
* - $jsmangledname: mangled class name
* - $jsname: name of the function
* - $jswrapper: wrapper of the member function
* ----------------------------------------------------------------------------- */
%fragment("jsv8_register_member_function", "templates")
%{
SWIGV8_AddMemberFunction($jsmangledname_class, "$jsname", $jswrapper);
%}
/* -----------------------------------------------------------------------------
* jsv8_register_member_variable: template for a statement that registers a member variable.
* - $jsmangledname: mangled class name
* - $jsname: name of the function
* - $jsgetter: wrapper of the getter function
* - $jssetter: wrapper of the setter function
* ----------------------------------------------------------------------------- */
%fragment("jsv8_register_member_variable", "templates")
%{
SWIGV8_AddMemberVariable($jsmangledname_class, "$jsname", $jsgetter, $jssetter);
%}
/* -----------------------------------------------------------------------------
* jsv8_register_static_function: template for a statement that registers a static class function.
* - $jsname: function name
* - $jswrapper: wrapper of the function
* - $jsparent: mangled name of parent namespace
*
* Note: this template is also used for global functions.
* ----------------------------------------------------------------------------- */
%fragment("jsv8_register_static_function", "templates")
%{
SWIGV8_AddStaticFunction($jsparent_obj, "$jsname", $jswrapper);
%}
/* -----------------------------------------------------------------------------
* jsv8_register_static_variable: template for a statement that registers a static variable.
* - $jsname: variable name
* - $jsparent: mangled name of parent namespace
* - $jsgetter: wrapper of the getter function
* - $jssetter: wrapper of the setter function
*
* Note: this template is also used for global variables.
* ----------------------------------------------------------------------------- */
%fragment("jsv8_register_static_variable", "templates")
%{
SWIGV8_AddStaticVariable($jsparent_obj, "$jsname", $jsgetter, $jssetter);
%}

View file

@ -0,0 +1,123 @@
/*
Defines the As/From converters for double/float complex, you need to
provide complex Type, the Name you want to use in the converters,
the complex Constructor method, and the Real and Imag complex
accessor methods.
See the std_complex.i and ccomplex.i for concret examples.
*/
/* the common from converter */
%define %swig_fromcplx_conv(Type, Real, Imag)
%fragment(SWIG_From_frag(Type),"header",
fragment=SWIG_From_frag(double))
{
SWIGINTERNINLINE v8::Handle<v8::Value>
SWIG_From_dec(Type)(%ifcplusplus(const Type&, Type) c)
{
v8::HandleScope scope;
v8::Local<v8::Array> vals = v8::Array::New(2);
vals->Set(0, SWIG_From(double)(Real(c)));
vals->Set(1, SWIG_From(double)(Imag(c)));
return scope.Close(vals);
}
}
%enddef
/* the double case */
%define %swig_cplxdbl_conv(Type, Constructor, Real, Imag)
%fragment(SWIG_AsVal_frag(Type),"header",
fragment=SWIG_AsVal_frag(double))
{
SWIGINTERN int
SWIG_AsVal_dec(Type) (v8::Handle<v8::Value> o, Type* val)
{
v8::HandleScope scope;
if (o->IsArray()) {
v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(o);
if(array->Length() != 2) SWIG_Error(SWIG_TypeError, "Illegal argument for complex: must be array[2].");
double re, im;
int res;
res = SWIG_AsVal(double)(array->Get(0), &re);
if(!SWIG_IsOK(res)) {
return SWIG_TypeError;
}
res = SWIG_AsVal(double)(array->Get(1), &im);
if(!SWIG_IsOK(res)) {
return SWIG_TypeError;
}
if (val) *val = Constructor(re, im);
return SWIG_OK;
} else if(o->IsNumber()){
double d;
int res = SWIG_AddCast(SWIG_AsVal(double)(o, &d));
if (SWIG_IsOK(res)) {
if (val) *val = Constructor(d, 0.0);
return res;
}
}
return SWIG_TypeError;
}
}
%swig_fromcplx_conv(Type, Real, Imag);
%enddef
/* the float case */
%define %swig_cplxflt_conv(Type, Constructor, Real, Imag)
%fragment(SWIG_AsVal_frag(Type),"header",
fragment=SWIG_AsVal_frag(float)) {
SWIGINTERN int
SWIG_AsVal_dec(Type) (v8::Handle<v8::Value> o, Type* val)
{
v8::HandleScope scope;
if (o->IsArray()) {
v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(o);
if(array->Length() != 2) SWIG_Error(SWIG_TypeError, "Illegal argument for complex: must be array[2].");
double re, im;
int res;
res = SWIG_AsVal(double)(array->Get(0), &re);
if(!SWIG_IsOK(res)) {
return SWIG_TypeError;
}
res = SWIG_AsVal(double)(array->Get(1), &im);
if(!SWIG_IsOK(res)) {
return SWIG_TypeError;
}
if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) {
if (val) *val = Constructor(%numeric_cast(re, float),
%numeric_cast(im, float));
return SWIG_OK;
} else {
return SWIG_OverflowError;
}
} else if(o->IsNumber()){
float re;
int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re));
if (SWIG_IsOK(res)) {
if (val) *val = Constructor(re, 0.0);
return res;
}
}
return SWIG_TypeError;
}
}
%swig_fromcplx_conv(Type, Real, Imag);
%enddef
#define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \
%swig_cplxflt_conv(Type, Constructor, Real, Imag)
#define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \
%swig_cplxdbl_conv(Type, Constructor, Real, Imag)

View file

@ -0,0 +1,23 @@
/*
Create a file with this name, 'javascriptfragments.swg', in your working
directory and add all the %fragments you want to take precedence
over the default ones defined by swig.
For example, if you add:
%fragment(SWIG_AsVal_frag(int),"header") {
SWIGINTERNINLINE int
SWIG_AsVal(int)(PyObject *obj, int *val)
{
<your code here>;
}
}
this will replace the code used to retrieve an integer value for all
the typemaps that need it, including:
int, std::vector<int>, std::list<std::pair<int,int> >, etc.
*/

View file

@ -0,0 +1,87 @@
%insert(runtime) %{
// Note: since 3.19 there are new CallBack types, since 03.21.9 the old ones have been removed
#if SWIG_V8_VERSION < 0x031900
typedef v8::InvocationCallback SwigV8FunctionCallback;
typedef v8::AccessorGetter SwigV8AccessorGetterCallback;
typedef v8::AccessorSetter SwigV8AccessorSetterCallback;
typedef v8::AccessorInfo SwigV8PropertyCallbackInfoVoid;
#else
typedef v8::FunctionCallback SwigV8FunctionCallback;
typedef v8::AccessorGetterCallback SwigV8AccessorGetterCallback;
typedef v8::AccessorSetterCallback SwigV8AccessorSetterCallback;
typedef v8::PropertyCallbackInfo<void> SwigV8PropertyCallbackInfoVoid;
#endif
/**
* Creates a class template for a class with specified initialization function.
*/
SWIGRUNTIME v8::Handle<v8::FunctionTemplate> SWIGV8_CreateClassTemplate(const char* symbol) {
v8::HandleScope scope;
v8::Local<v8::FunctionTemplate> class_templ = v8::FunctionTemplate::New();
class_templ->SetClassName(v8::String::NewSymbol(symbol));
v8::Handle<v8::ObjectTemplate> inst_templ = class_templ->InstanceTemplate();
inst_templ->SetInternalFieldCount(1);
v8::Handle<v8::ObjectTemplate> equals_templ = class_templ->PrototypeTemplate();
equals_templ->Set(v8::String::NewSymbol("equals"), v8::FunctionTemplate::New(_SWIGV8_wrap_equals));
v8::Handle<v8::ObjectTemplate> cptr_templ = class_templ->PrototypeTemplate();
cptr_templ->Set(v8::String::NewSymbol("getCPtr"), v8::FunctionTemplate::New(_wrap_getCPtr));
return scope.Close(class_templ);
}
/**
* Registers a class method with given name for a given class template.
*/
SWIGRUNTIME void SWIGV8_AddMemberFunction(v8::Handle<v8::FunctionTemplate> class_templ, const char* symbol,
SwigV8FunctionCallback _func) {
v8::Handle<v8::ObjectTemplate> proto_templ = class_templ->PrototypeTemplate();
proto_templ->Set(v8::String::NewSymbol(symbol), v8::FunctionTemplate::New(_func));
}
/**
* Registers a class property with given name for a given class template.
*/
SWIGRUNTIME void SWIGV8_AddMemberVariable(v8::Handle<v8::FunctionTemplate> class_templ, const char* symbol,
SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback setter) {
v8::Handle<v8::ObjectTemplate> proto_templ = class_templ->InstanceTemplate();
proto_templ->SetAccessor(v8::String::NewSymbol(symbol), getter, setter);
}
/**
* Registers a class method with given name for a given object.
*/
SWIGRUNTIME void SWIGV8_AddStaticFunction(v8::Handle<v8::Object> obj, const char* symbol,
const SwigV8FunctionCallback& _func) {
obj->Set(v8::String::NewSymbol(symbol), v8::FunctionTemplate::New(_func)->GetFunction());
}
/**
* Registers a class method with given name for a given object.
*/
SWIGRUNTIME void SWIGV8_AddStaticVariable(v8::Handle<v8::Object> obj, const char* symbol,
SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback setter) {
obj->SetAccessor(v8::String::NewSymbol(symbol), getter, setter);
}
SWIGRUNTIME void JS_veto_set_variable(v8::Local<v8::String> property, v8::Local<v8::Value> value,
const SwigV8PropertyCallbackInfoVoid& info)
{
char buffer[256];
char msg[512];
int res;
property->WriteUtf8(buffer, 256);
res = sprintf(msg, "Tried to write read-only variable: %s.", buffer);
if(res<0) {
SWIG_exception(SWIG_ERROR, "Tried to write read-only variable.");
} else {
SWIG_exception(SWIG_ERROR, msg);
}
}
%} // v8_helper_functions

View file

@ -0,0 +1,118 @@
%insert(init) %{
#include <assert.h>
SWIGRUNTIME void
SWIG_V8_SetModule(void *, swig_module_info *swig_module) {
v8::Local<v8::Object> global_obj = v8::Context::GetCurrent()->Global();
v8::Local<v8::External> mod = v8::External::New(swig_module);
assert(!mod.IsEmpty());
global_obj->SetHiddenValue(v8::String::New("swig_module_info_data"), mod);
}
SWIGRUNTIME swig_module_info *
SWIG_V8_GetModule(void *) {
v8::Local<v8::Object> global_obj = v8::Context::GetCurrent()->Global();
v8::Local<v8::Value> moduleinfo = global_obj->GetHiddenValue(v8::String::New("swig_module_info_data"));
if (moduleinfo.IsEmpty())
{
// It's not yet loaded
return 0;
}
v8::Local<v8::External> moduleinfo_extern = v8::Local<v8::External>::Cast(moduleinfo);
if (moduleinfo_extern.IsEmpty())
{
// Something's not right
return 0;
}
void *ptr = moduleinfo_extern->Value();
assert(ptr);
swig_module_info *retptr = static_cast<swig_module_info *>(ptr);
assert(retptr);
return retptr;
}
#define SWIG_GetModule(clientdata) SWIG_V8_GetModule(clientdata)
#define SWIG_SetModule(clientdata, pointer) SWIG_V8_SetModule(clientdata, pointer)
%}
%insert(init) "swiginit.swg"
// Open the initializer function definition here
%fragment ("js_initializer_define", "templates") %{
#define SWIGV8_INIT $jsname_initialize
%}
%insert(init) %{
// Note: 'extern "C"'' disables name mangling which makes it easier to load the symbol manually
// TODO: is it ok to do that?
extern "C"
#if (NODE_MODULE_VERSION < 0x000C)
void SWIGV8_INIT (v8::Handle<v8::Object> exports)
#else
void SWIGV8_INIT (v8::Handle<v8::Object> exports, v8::Handle<v8::Object> /*module*/)
#endif
{
SWIG_InitializeModule(static_cast<void *>(&exports));
v8::HandleScope scope;
v8::Handle<v8::Object> exports_obj = exports;
%}
/* -----------------------------------------------------------------------------
* js_initializer: template for the module initializer function
* - $jsname: module name
* - $jsv8nspaces: part with code creating namespace objects
* - $jsv8classtemplates: part with code creating class templates
* - $jsv8wrappers: part with code that registers wrapper functions
* - $jsv8inheritance: part with inherit statements
* - $jsv8classinstances: part with code creating class objects
* - $jsv8staticwrappers: part with code adding static functions to class objects
* - $jsv8registerclasses: part with code that registers class objects in namespaces
* - $jsv8registernspaces: part with code that registers namespaces in parent namespaces
* ----------------------------------------------------------------------------- */
%fragment("js_initializer", "templates")
%{
// a class template for creating proxies of undefined types
#if (SWIG_V8_VERSION < 0x031900)
SWIGV8_SWIGTYPE_Proxy_class_templ = v8::Persistent<v8::FunctionTemplate>::New(SWIGV8_CreateClassTemplate("SwigProxy"));
#else
SWIGV8_SWIGTYPE_Proxy_class_templ.Reset(v8::Isolate::GetCurrent(), SWIGV8_CreateClassTemplate("SwigProxy"));
#endif
/* create objects for namespaces */
$jsv8nspaces
/* create class templates */
$jsv8classtemplates
/* register wrapper functions */
$jsv8wrappers
/* setup inheritances */
$jsv8inheritance
/* class instances */
$jsv8classinstances
/* add static class functions and variables */
$jsv8staticwrappers
/* register classes */
$jsv8registerclasses
/* create and register namespace objects */
$jsv8registernspaces
}
#if defined(BUILDING_NODE_EXTENSION)
NODE_MODULE($jsname, $jsname_initialize)
#endif
%}

View file

@ -0,0 +1,40 @@
#ifndef JAVASCRIPT_JAVASCRIPTKW_SWG_
#define JAVASCRIPT_JAVASCRIPTKW_SWG_
/* Warnings for Java keywords */
#define JAVASCRIPTKW(x) %keywordwarn("'" `x` "' is a javascript keyword, renaming to '_"`x`"'",rename="_%s") `x`
/* Taken from https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Reserved_Words */
JAVASCRIPTKW(break);
JAVASCRIPTKW(case);
JAVASCRIPTKW(catch);
JAVASCRIPTKW(continue);
JAVASCRIPTKW(default);
JAVASCRIPTKW(delete);
JAVASCRIPTKW(do);
JAVASCRIPTKW(else);
JAVASCRIPTKW(finally);
JAVASCRIPTKW(for);
JAVASCRIPTKW(function);
JAVASCRIPTKW(if);
JAVASCRIPTKW(in);
JAVASCRIPTKW(instanceof);
JAVASCRIPTKW(new);
JAVASCRIPTKW(return);
JAVASCRIPTKW(switch);
JAVASCRIPTKW(this);
JAVASCRIPTKW(throw);
JAVASCRIPTKW(try);
JAVASCRIPTKW(typeof);
JAVASCRIPTKW(var);
JAVASCRIPTKW(void);
JAVASCRIPTKW(while);
JAVASCRIPTKW(with);
/* others bad names if any*/
// for example %namewarn("321:clone() is a javascript bad method name") *::clone();
#undef JAVASCRIPTKW
#endif //JAVASCRIPT_JAVASCRIPTKW_SWG_

View file

@ -0,0 +1,198 @@
/* ------------------------------------------------------------
* Primitive Types
* ------------------------------------------------------------ */
/* boolean */
%fragment(SWIG_From_frag(bool),"header") {
SWIGINTERNINLINE
v8::Handle<v8::Value>
SWIG_From_dec(bool)(bool value)
{
return v8::Boolean::New(value);
}
}
%fragment(SWIG_AsVal_frag(bool),"header",
fragment=SWIG_AsVal_frag(long)) {
SWIGINTERN
int SWIG_AsVal_dec(bool)(v8::Handle<v8::Value> obj, bool *val)
{
if(!obj->IsBoolean()) {
return SWIG_ERROR;
}
if (val) *val = obj->BooleanValue();
return SWIG_OK;
}
}
/* int */
%fragment(SWIG_From_frag(int),"header") {
SWIGINTERNINLINE
v8::Handle<v8::Value> SWIG_From_dec(int)(int value)
{
return v8::Int32::New(value);
}
}
%fragment(SWIG_AsVal_frag(int),"header") {
SWIGINTERN
int SWIG_AsVal_dec(int)(v8::Handle<v8::Value> valRef, int* val)
{
if (!valRef->IsNumber()) {
return SWIG_TypeError;
}
if(val) *val = valRef->IntegerValue();
return SWIG_OK;
}
}
/* long */
%fragment(SWIG_From_frag(long),"header") {
SWIGINTERNINLINE
v8::Handle<v8::Value> SWIG_From_dec(long)(long value)
{
return v8::Number::New(value);
}
}
%fragment(SWIG_AsVal_frag(long),"header",
fragment="SWIG_CanCastAsInteger") {
SWIGINTERN
int SWIG_AsVal_dec(long)(v8::Handle<v8::Value> obj, long* val)
{
if (!obj->IsNumber()) {
return SWIG_TypeError;
}
if(val) *val = (long) obj->IntegerValue();
return SWIG_OK;
}
}
/* unsigned long */
%fragment(SWIG_From_frag(unsigned long),"header",
fragment=SWIG_From_frag(long)) {
SWIGINTERNINLINE
v8::Handle<v8::Value> SWIG_From_dec(unsigned long)(unsigned long value)
{
return (value > LONG_MAX) ?
v8::Integer::NewFromUnsigned(value) : v8::Integer::New(%numeric_cast(value,long));
}
}
%fragment(SWIG_AsVal_frag(unsigned long),"header",
fragment="SWIG_CanCastAsInteger") {
SWIGINTERN
int SWIG_AsVal_dec(unsigned long)(v8::Handle<v8::Value> obj, unsigned long *val)
{
if(!obj->IsNumber()) {
return SWIG_TypeError;
}
long longVal = (long) obj->NumberValue();
if(longVal < 0) {
return SWIG_OverflowError;
}
if(val) *val = longVal;
return SWIG_OK;
}
}
/* long long */
// Note: these are copied from 'long' and probably need fixing
%fragment(SWIG_From_frag(long long),"header",
fragment=SWIG_From_frag(long),
fragment="<limits.h>") {
SWIGINTERNINLINE
v8::Handle<v8::Value> SWIG_From_dec(long long)(long long value)
{
return v8::Number::New(value);
}
}
%fragment(SWIG_AsVal_frag(long long),"header",
fragment=SWIG_AsVal_frag(long),
fragment="SWIG_CanCastAsInteger",
fragment="<limits.h>") {
SWIGINTERN
int SWIG_AsVal_dec(long long)(v8::Handle<v8::Value> obj, long long* val)
{
if (!obj->IsNumber()) {
return SWIG_TypeError;
}
if(val) *val = (long long) obj->IntegerValue();
return SWIG_OK;
}
}
/* unsigned long long */
// Note: these are copied from 'unsigned long' and probably need fixing
%fragment(SWIG_From_frag(unsigned long long),"header",
fragment=SWIG_From_frag(long long),
fragment="<limits.h>") {
SWIGINTERNINLINE
v8::Handle<v8::Value> SWIG_From_dec(unsigned long long)(unsigned long long value)
{
return (value > LONG_MAX) ?
v8::Integer::NewFromUnsigned(value) : v8::Integer::New(%numeric_cast(value,long));
}
}
%fragment(SWIG_AsVal_frag(unsigned long long),"header",
fragment=SWIG_AsVal_frag(unsigned long),
fragment="SWIG_CanCastAsInteger",
fragment="<limits.h>") {
SWIGINTERN
int SWIG_AsVal_dec(unsigned long long)(v8::Handle<v8::Value> obj, unsigned long long *val)
{
if(!obj->IsNumber()) {
return SWIG_TypeError;
}
long long longVal = (long long) obj->NumberValue();
if(longVal < 0) {
return SWIG_OverflowError;
}
if(val) *val = longVal;
return SWIG_OK;
}
}
/* double */
%fragment(SWIG_From_frag(double),"header") {
SWIGINTERN
v8::Handle<v8::Value> SWIG_From_dec(double) (double val)
{
return v8::Number::New(val);
}
}
%fragment(SWIG_AsVal_frag(double),"header") {
SWIGINTERN
int SWIG_AsVal_dec(double)(v8::Handle<v8::Value> obj, double *val)
{
if(!obj->IsNumber()) {
return SWIG_TypeError;
}
if(val) *val = obj->NumberValue();
return SWIG_OK;
}
}

View file

@ -0,0 +1,470 @@
/* ---------------------------------------------------------------------------
* Error handling
*
* ---------------------------------------------------------------------------*/
#define SWIG_Error(code, msg) SWIGV8_ErrorHandler.error(code, msg)
#define SWIG_exception(code, msg) SWIGV8_ErrorHandler.error(code, msg)
#define SWIG_fail goto fail
#define SWIGV8_OVERLOAD false
void SWIG_V8_Raise(const char* msg) {
v8::ThrowException(v8::Exception::Error(v8::String::New(msg)));
}
/*
Note: There are two contexts for handling errors.
A static V8ErrorHandler is used in not overloaded methods.
For overloaded methods the throwing type checking mechanism is used
during dispatching. As V8 exceptions can not be resetted properly
the trick is to use a dynamic ErrorHandler with same local name as the global
one.
- See defintion of SWIG_Error above.
- See code templates 'JS_function_dispatcher', 'JS_functionwrapper_overload',
and 'JS_function_dispatch_case' in javascriptcode.swg
*/
class V8ErrorHandler {
public:
virtual ~V8ErrorHandler() {}
virtual void error(int code, const char* msg) {
SWIG_V8_Raise(msg);
}
};
// this is used in usually
V8ErrorHandler SWIGV8_ErrorHandler;
// instances of this are used in overloaded functions
class OverloadErrorHandler: public V8ErrorHandler {
public:
virtual void error(int code, const char* msg) {
err = v8::Exception::Error(v8::String::New(msg));
if(code != SWIG_TypeError) {
v8::ThrowException(err);
}
}
v8::Handle<v8::Value> err;
};
// Note: these typedefs and defines are used to deal with v8 API changes since version 3.19.00
#if (SWIG_V8_VERSION < 0x031900)
typedef v8::Handle<v8::Value> SwigV8ReturnValue;
typedef v8::Arguments SwigV8Arguments;
typedef v8::AccessorInfo SwigV8PropertyCallbackInfo;
#define SWIGV8_RETURN(val) return scope.Close(val)
#define SWIGV8_RETURN_INFO(val, info) return scope.Close(val)
#else
typedef void SwigV8ReturnValue;
typedef v8::FunctionCallbackInfo<v8::Value> SwigV8Arguments;
typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
#define SWIGV8_RETURN(val) args.GetReturnValue().Set(val); return
#define SWIGV8_RETURN_INFO(val, info) info.GetReturnValue().Set(val); return
#endif
/* ---------------------------------------------------------------------------
* Basic Proxy object
*
* ---------------------------------------------------------------------------*/
// Note: to trigger the v8 gc more often one can tell v8 about the memory consumption
// TODO: we could add a v8 specific parameter to control this value
#define SWIGV8_AVG_OBJ_SIZE 1000
class SWIGV8_Proxy {
public:
SWIGV8_Proxy(): swigCMemOwn(false), swigCObject(0), info(0) {
v8::V8::AdjustAmountOfExternalAllocatedMemory(SWIGV8_AVG_OBJ_SIZE);
};
~SWIGV8_Proxy() {
#if (SWIG_V8_VERSION < 0x031900 || SWIG_V8_VERSION >= 0x032100)
handle.ClearWeak();
handle.Dispose();
#else
handle.ClearWeak(v8::Isolate::GetCurrent());
handle.Dispose(v8::Isolate::GetCurrent());
#endif
handle.Clear();
v8::V8::AdjustAmountOfExternalAllocatedMemory(-SWIGV8_AVG_OBJ_SIZE);
}
bool swigCMemOwn;
void *swigCObject;
swig_type_info *info;
v8::Persistent<v8::Object> handle;
};
class SWIGV8_ClientData {
public:
v8::Persistent<v8::FunctionTemplate> class_templ;
#if (SWIG_V8_VERSION < 0x031900)
void (*dtor) (v8::Persistent< v8::Value> object, void *parameter);
#else
void (*dtor) (v8::Isolate *isolate, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy);
#endif
};
v8::Persistent<v8::FunctionTemplate> SWIGV8_SWIGTYPE_Proxy_class_templ;
int SWIG_V8_ConvertInstancePtr(v8::Handle<v8::Object> objRef, void** ptr, swig_type_info *info, int flags) {
v8::HandleScope scope;
if(objRef->InternalFieldCount() < 1) return SWIG_ERROR;
#if (SWIG_V8_VERSION < 0x031900)
v8::Handle<v8::Value> cdataRef = objRef->GetInternalField(0);
SWIGV8_Proxy *cdata = static_cast<SWIGV8_Proxy *>(v8::External::Unwrap(cdataRef));
#else
SWIGV8_Proxy *cdata = static_cast<SWIGV8_Proxy *>(objRef->GetAlignedPointerFromInternalField(0));
#endif
if(cdata == NULL) {
return SWIG_ERROR;
}
if(cdata->info != info) {
swig_cast_info *tc = SWIG_TypeCheckStruct(cdata->info, info);
if (!tc && cdata->info->name) {
tc = SWIG_TypeCheck(cdata->info->name, info);
}
bool type_valid = tc != 0;
if(!type_valid) {
return SWIG_TypeError;
}
}
*ptr = cdata->swigCObject;
if(flags & SWIG_POINTER_DISOWN) {
cdata->swigCMemOwn = false;
}
return SWIG_OK;
}
#if (SWIG_V8_VERSION < 0x031900)
void SWIGV8_Proxy_DefaultDtor(v8::Persistent< v8::Value > object, void *parameter)
#else
void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy)
#endif
{
#if (SWIG_V8_VERSION < 0x031900)
SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
#endif
delete proxy;
}
int SWIG_V8_GetInstancePtr(v8::Handle<v8::Value> valRef, void** ptr) {
if(!valRef->IsObject()) {
return SWIG_TypeError;
}
v8::Handle<v8::Object> objRef = valRef->ToObject();
if(objRef->InternalFieldCount() < 1) return SWIG_ERROR;
#if (SWIG_V8_VERSION < 0x031900)
v8::Handle<v8::Value> cdataRef = objRef->GetInternalField(0);
SWIGV8_Proxy *cdata = static_cast<SWIGV8_Proxy *>(v8::External::Unwrap(cdataRef));
#else
SWIGV8_Proxy *cdata = static_cast<SWIGV8_Proxy *>(objRef->GetAlignedPointerFromInternalField(0));
#endif
if(cdata == NULL) {
return SWIG_ERROR;
}
*ptr = cdata->swigCObject;
return SWIG_OK;
}
void SWIGV8_SetPrivateData(v8::Handle<v8::Object> obj, void* ptr, swig_type_info *info, int flags) {
SWIGV8_Proxy* cdata = new SWIGV8_Proxy();
cdata->swigCObject = ptr;
cdata->swigCMemOwn = (flags & SWIG_POINTER_OWN) ? 1 : 0;
cdata->info = info;
#if (SWIG_V8_VERSION < 0x031900)
obj->SetPointerInInternalField(0, cdata);
cdata->handle = v8::Persistent<v8::Object>::New(obj);
#else
obj->SetAlignedPointerInInternalField(0, cdata);
cdata->handle.Reset(v8::Isolate::GetCurrent(), obj);
#endif
#if (SWIG_V8_VERSION < 0x031900)
// clientdata must be set for owned data as we need to register the dtor
if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) {
cdata->handle.MakeWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor);
} else {
cdata->handle.MakeWeak(cdata, SWIGV8_Proxy_DefaultDtor);
}
cdata->handle.MarkIndependent();
#else
if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) {
cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor);
} else {
cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, SWIGV8_Proxy_DefaultDtor);
}
#if (SWIG_V8_VERSION < 0x032100)
cdata->handle.MarkIndependent(v8::Isolate::GetCurrent());
#else
cdata->handle.MarkIndependent();
#endif
#endif
}
int SWIG_V8_ConvertPtr(v8::Handle<v8::Value> valRef, void** ptr, swig_type_info *info, int flags) {
v8::HandleScope scope;
/* special case: JavaScript null => C NULL pointer */
if(valRef->IsNull()) {
*ptr=0;
return SWIG_OK;
}
if(!valRef->IsObject()) {
return SWIG_TypeError;
}
v8::Handle<v8::Object> objRef = valRef->ToObject();
return SWIG_V8_ConvertInstancePtr(objRef, ptr, info, flags);
}
v8::Handle<v8::Value> SWIG_V8_NewPointerObj(void *ptr, swig_type_info *info, int flags) {
v8::HandleScope scope;
v8::Handle<v8::FunctionTemplate> class_templ;
if (ptr == NULL) {
return scope.Close(v8::Null());
}
#if (SWIG_V8_VERSION < 0x031900)
if(info->clientdata != 0) {
class_templ = ((SWIGV8_ClientData*) info->clientdata)->class_templ;
} else {
class_templ = SWIGV8_SWIGTYPE_Proxy_class_templ;
}
#else
v8::Isolate *iso = v8::Isolate::GetCurrent();
if(info->clientdata != 0) {
class_templ = v8::Handle<v8::FunctionTemplate>::New(iso, ((SWIGV8_ClientData*) info->clientdata)->class_templ);
} else {
class_templ = v8::Handle<v8::FunctionTemplate>::New(iso, SWIGV8_SWIGTYPE_Proxy_class_templ);
}
#endif
v8::Handle<v8::Object> result = class_templ->InstanceTemplate()->NewInstance();
SWIGV8_SetPrivateData(result, ptr, info, flags);
return scope.Close(result);
}
#define SWIG_ConvertPtr(obj, ptr, info, flags) SWIG_V8_ConvertPtr(obj, ptr, info, flags)
#define SWIG_NewPointerObj(ptr, info, flags) SWIG_V8_NewPointerObj(ptr, info, flags)
#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_V8_ConvertInstancePtr(obj, pptr, type, flags)
#define SWIG_NewInstanceObj(thisvalue, type, flags) SWIG_V8_NewPointerObj(thisvalue, type, flags)
#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_V8_ConvertPtr(obj, pptr, type, 0)
#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_V8_NewPointerObj(ptr, type, 0)
#define SWIG_GetInstancePtr(obj, ptr) SWIG_V8_GetInstancePtr(obj, ptr)
#if (SWIG_V8_VERSION < 0x031900)
v8::Handle<v8::Value> _SWIGV8_wrap_equals(const v8::Arguments &args) {
#else
void _SWIGV8_wrap_equals(const v8::FunctionCallbackInfo<v8::Value>& args) {
#endif
v8::HandleScope scope;
v8::Handle<v8::Value> jsresult;
void *arg1 = (void *) 0 ;
void *arg2 = (void *) 0 ;
bool result;
int res1;
int res2;
if(args.Length() != 1) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for equals.");
res1 = SWIG_GetInstancePtr(args.Holder(), &arg1);
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ERROR, "Could not get pointer from 'this' object for equals.");
}
res2 = SWIG_GetInstancePtr(args[0], &arg2);
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "equals" "', argument " "1"" of type '" "void *""'");
}
result = (bool)(arg1 == arg2);
jsresult = v8::Boolean::New(result);
SWIGV8_RETURN(jsresult);
goto fail;
fail:
SWIGV8_RETURN(v8::Undefined());
}
#if (SWIG_V8_VERSION < 0x031900)
v8::Handle<v8::Value> _wrap_getCPtr(const v8::Arguments &args) {
#else
void _wrap_getCPtr(const v8::FunctionCallbackInfo<v8::Value>& args) {
#endif
v8::HandleScope scope;
v8::Handle<v8::Value> jsresult;
void *arg1 = (void *) 0 ;
long result;
int res1;
res1 = SWIG_GetInstancePtr(args.Holder(), &arg1);
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "getCPtr" "', argument " "1"" of type '" "void *""'");
}
result = (long)arg1;
jsresult = v8::Number::New(result);
SWIGV8_RETURN(jsresult);
goto fail;
fail:
SWIGV8_RETURN(v8::Undefined());
}
/* ---------------------------------------------------------------------------
* PackedData object
*
* ---------------------------------------------------------------------------*/
class SwigV8PackedData {
public:
SwigV8PackedData(void *data, size_t size, swig_type_info *type): data(data), size(size), type(type) {};
~SwigV8PackedData() {
};
void* data;
size_t size;
swig_type_info *type;
v8::Persistent<v8::Object> handle;
};
SWIGRUNTIMEINLINE
int SwigV8Packed_Check(v8::Handle<v8::Value> valRef) {
v8::HandleScope scope;
v8::Handle<v8::Object> objRef = valRef->ToObject();
if(objRef->InternalFieldCount() < 1) return false;
v8::Handle<v8::Value> flag = objRef->GetHiddenValue(v8::String::New("__swig__packed_data__"));
return (flag->IsBoolean() && flag->BooleanValue());
}
SWIGRUNTIME
swig_type_info* SwigV8Packed_UnpackData(v8::Handle<v8::Value> valRef, void *ptr, size_t size) {
if (SwigV8Packed_Check(valRef)) {
v8::HandleScope scope;
SwigV8PackedData *sobj;
v8::Handle<v8::Object> objRef = valRef->ToObject();
#if (SWIG_V8_VERSION < 0x031900)
v8::Handle<v8::Value> cdataRef = objRef->GetInternalField(0);
sobj = static_cast<SwigV8PackedData*>(v8::External::Unwrap(cdataRef));
#else
sobj = static_cast<SwigV8PackedData*>(objRef->GetAlignedPointerFromInternalField(0));
#endif
if (sobj == NULL || sobj->size != size) return 0;
memcpy(ptr, sobj->data, size);
return sobj->type;
} else {
return 0;
}
}
SWIGRUNTIME
int SWIGV8_ConvertPacked(v8::Handle<v8::Value> valRef, void *ptr, size_t sz, swig_type_info *ty) {
swig_type_info *to = SwigV8Packed_UnpackData(valRef, ptr, sz);
if (!to) return SWIG_ERROR;
if (ty) {
if (to != ty) {
/* check type cast? */
swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
if (!tc) return SWIG_ERROR;
}
}
return SWIG_OK;
}
#if (SWIG_V8_VERSION < 0x031900)
void _wrap_SwigV8PackedData_delete(v8::Persistent< v8::Value > object, void *parameter)
{
SwigV8PackedData *cdata = static_cast<SwigV8PackedData *>(parameter);
#else
void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persistent< v8::Object > * object, SwigV8PackedData *cdata)
{
#endif
delete cdata;
#if (SWIG_V8_VERSION < 0x031900)
object.Clear();
object.Dispose();
#elif (SWIG_V8_VERSION < 0x032100)
object->Dispose(isolate);
#else
object->Dispose();
#endif
}
SWIGRUNTIME
v8::Handle<v8::Value> SWIGV8_NewPackedObj(void *data, size_t size, swig_type_info *type) {
v8::HandleScope scope;
SwigV8PackedData* cdata = new SwigV8PackedData(data, size, type);
v8::Handle<v8::Object> obj = v8::Object::New();
obj->SetHiddenValue(v8::String::New("__swig__packed_data__"), v8::Boolean::New(true));
#if (SWIG_V8_VERSION < 0x031900)
obj->SetPointerInInternalField(0, cdata);
cdata->handle = v8::Persistent<v8::Object>::New(obj);
#else
obj->SetAlignedPointerInInternalField(0, cdata);
cdata->handle.Reset(v8::Isolate::GetCurrent(), obj);
#endif
#if (SWIG_V8_VERSION < 0x031900)
cdata->handle.MakeWeak(cdata, _wrap_SwigV8PackedData_delete);
cdata->handle.MarkIndependent();
#else
cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, _wrap_SwigV8PackedData_delete);
# if (SWIG_V8_VERSION < 0x032100)
cdata->handle.MarkIndependent(v8::Isolate::GetCurrent());
# else
cdata->handle.MarkIndependent();
# endif
#endif
return scope.Close(obj);
}
#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIGV8_ConvertPacked(obj, ptr, sz, ty)
#define SWIG_NewMemberObj(ptr, sz, type) SWIGV8_NewPackedObj(ptr, sz, type)
/* ---------------------------------------------------------------------------
* Support for IN/OUTPUT typemaps (see Lib/typemaps/inoutlist.swg)
*
* ---------------------------------------------------------------------------*/
SWIGRUNTIME
v8::Handle<v8::Value> SWIGV8_AppendOutput(v8::Handle<v8::Value> result, v8::Handle<v8::Value> obj) {
v8::HandleScope scope;
if (result->IsUndefined()) {
result = v8::Array::New();
}
v8::Handle<v8::Array> arr = v8::Handle<v8::Array>::Cast(result);
arr->Set(arr->Length(), obj);
return scope.Close(arr);
}

View file

@ -0,0 +1,55 @@
/* -----------------------------------------------------------------------------
* javascriptruntime.swg
*
* ----------------------------------------------------------------------------- */
// V8 Version Macro
// ----------------
// v8 does not (until now) provide a version macro - which is still discussed and may come soon.
// Until then, we set a default version which can be overridden via command line using V8_VERSION:
// swig -javascript -v8 -DV8_VERSION=0x031110
// Or code in the interface file using SWIG_V8_VERSION:
// %begin %{#define SWIG_V8_VERSION 0x031110%}
%define %swig_v8_define_version(version)
%insert("runtime") %{
#ifndef SWIG_V8_VERSION
#define SWIG_V8_VERSION version
#endif
%}
%enddef
#ifdef V8_VERSION
%swig_v8_define_version(V8_VERSION)
#else
// HACK: defining a default version
%swig_v8_define_version(0x031110)
#endif
// Node support
// ------------
#ifdef BUILDING_NODE_EXTENSION
%insert("runtime") %{
#include <node.h>
%}
#endif
// V8 runtime
// ----------
%insert(runtime) %{
#include <v8.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
%}
%insert(runtime) "swigrun.swg"; /* SWIG API */
%insert(runtime) "swigerrors.swg"; /* SWIG errors */
%insert(runtime) "javascriptrun.swg"

View file

@ -0,0 +1,59 @@
/* ------------------------------------------------------------
* utility methods for char strings
* ------------------------------------------------------------ */
%fragment("SWIG_AsCharPtrAndSize", "header", fragment="SWIG_pchar_descriptor") {
SWIGINTERN int
SWIG_AsCharPtrAndSize(v8::Handle<v8::Value> valRef, char** cptr, size_t* psize, int *alloc)
{
if(valRef->IsString()) {
v8::Handle<v8::String> js_str = valRef->ToString();
size_t len = js_str->Utf8Length() + 1;
char* cstr = new char[len];
js_str->WriteUtf8(cstr, len);
if(alloc) *alloc = SWIG_NEWOBJ;
if(psize) *psize = len;
if(cptr) *cptr = cstr;
return SWIG_OK;
} else {
if(valRef->IsObject()) {
v8::Handle<v8::Object> obj = valRef->ToObject();
// try if the object is a wrapped char[]
swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
if (pchar_descriptor) {
void* vptr = 0;
if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) {
if (cptr) *cptr = (char *) vptr;
if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0;
if (alloc) *alloc = SWIG_OLDOBJ;
return SWIG_OK;
}
}
return SWIG_TypeError;
} else {
return SWIG_TypeError;
}
}
}
}
%fragment("SWIG_FromCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") {
SWIGINTERNINLINE v8::Handle<v8::Value>
SWIG_FromCharPtrAndSize(const char* carray, size_t size)
{
if (carray) {
if (size > INT_MAX) {
// TODO: handle extra long strings
return v8::Undefined();
} else {
v8::Handle<v8::String> js_str = v8::String::New(carray, size);
return js_str;
}
} else {
return v8::Undefined();
}
}
}

View file

@ -0,0 +1,43 @@
/* ------------------------------------------------------------
* Typemap specializations for Javascript
* ------------------------------------------------------------ */
/* ------------------------------------------------------------
* Fragment section
* ------------------------------------------------------------ */
/* Include fundamental fragemt definitions */
%include <typemaps/fragments.swg>
/* Look for user fragments file. */
%include <javascriptfragments.swg>
/* Javascript fragments for fundamental types */
%include <javascriptprimtypes.swg>
/* Javascript fragments for char* strings */
%include <javascriptstrings.swg>
/* ------------------------------------------------------------
* Unified typemap section
* ------------------------------------------------------------ */
/* Javascript types */
#define SWIG_Object v8::Handle<v8::Value>
#define VOID_Object v8::Undefined()
/* Overload of the output/constant/exception/dirout handling */
/* append output */
#define SWIG_AppendOutput(result, obj) SWIGV8_AppendOutput(result, obj)
/* set constant */
#define SWIG_SetConstant(name, obj)
/* raise */
#define SWIG_Raise(obj, type, desc) SWIG_V8_Raise(type)
/* Include the unified typemap library */
%include <typemaps/swigtypemaps.swg>

View file

@ -0,0 +1,5 @@
%include <std_except.i>
%apply size_t { std::size_t };
%apply const size_t& { const std::size_t& };

View file

@ -0,0 +1,19 @@
/*
* STD C++ complex typemaps
*/
%include <javascriptcomplex.swg>
%{
#include <complex>
%}
/* defining the complex as/from converters */
%swig_cplxdbl_convn(std::complex<double>, std::complex<double>, std::real, std::imag)
%swig_cplxflt_convn(std::complex<float>, std::complex<float>, std::real, std::imag)
/* defining the typemaps */
%typemaps_primitive(%checkcode(CPLXDBL), std::complex<double>);
%typemaps_primitive(%checkcode(CPLXFLT), std::complex<float>);

View file

@ -0,0 +1 @@
%include <std/_std_deque.i>

View file

@ -0,0 +1 @@
%include <typemaps/std_except.swg>

View file

@ -0,0 +1,74 @@
/* -----------------------------------------------------------------------------
* std_map.i
*
* SWIG typemaps for std::map
* ----------------------------------------------------------------------------- */
%include <std_common.i>
// ------------------------------------------------------------------------
// std::map
// ------------------------------------------------------------------------
%{
#include <map>
#include <algorithm>
#include <stdexcept>
%}
// exported class
namespace std {
template<class K, class T> class map {
// add typemaps here
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
map();
map(const map<K,T> &);
unsigned int size() const;
bool empty() const;
void clear();
%extend {
const T& get(const K& key) throw (std::out_of_range) {
std::map<K,T >::iterator i = self->find(key);
if (i != self->end())
return i->second;
else
throw std::out_of_range("key not found");
}
void set(const K& key, const T& x) {
(*self)[key] = x;
}
void del(const K& key) throw (std::out_of_range) {
std::map<K,T >::iterator i = self->find(key);
if (i != self->end())
self->erase(i);
else
throw std::out_of_range("key not found");
}
bool has_key(const K& key) {
std::map<K,T >::iterator i = self->find(key);
return i != self->end();
}
}
};
// Legacy macros (deprecated)
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
#warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary"
%enddef
%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
#warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary"
%enddef
%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
#warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary"
%enddef
}

View file

@ -0,0 +1,33 @@
/* -----------------------------------------------------------------------------
* std_pair.i
*
* SWIG typemaps for std::pair
* ----------------------------------------------------------------------------- */
%include <std_common.i>
// ------------------------------------------------------------------------
// std::pair
// ------------------------------------------------------------------------
%{
#include <utility>
%}
namespace std {
template<class T, class U> struct pair {
pair();
pair(T first, U second);
pair(const pair& p);
template <class U1, class U2> pair(const pair<U1, U2> &p);
T first;
U second;
};
// add specializations here
}

View file

@ -0,0 +1 @@
%include <typemaps/std_string.swg>

View file

@ -0,0 +1,85 @@
/* -----------------------------------------------------------------------------
* std_vector.i
* ----------------------------------------------------------------------------- */
%include <std_common.i>
%{
#include <vector>
#include <stdexcept>
%}
namespace std {
template<class T> class vector {
public:
typedef size_t size_type;
typedef T value_type;
typedef const value_type& const_reference;
vector();
vector(size_type n);
size_type size() const;
size_type capacity() const;
void reserve(size_type n);
%rename(isEmpty) empty;
bool empty() const;
void clear();
%rename(add) push_back;
void push_back(const value_type& x);
%extend {
const_reference get(int i) throw (std::out_of_range) {
int size = int(self->size());
if (i>=0 && i<size)
return (*self)[i];
else
throw std::out_of_range("vector index out of range");
}
void set(int i, const value_type& val) throw (std::out_of_range) {
int size = int(self->size());
if (i>=0 && i<size)
(*self)[i] = val;
else
throw std::out_of_range("vector index out of range");
}
}
};
// bool specialization
template<> class vector<bool> {
public:
typedef size_t size_type;
typedef bool value_type;
typedef bool const_reference;
vector();
vector(size_type n);
size_type size() const;
size_type capacity() const;
void reserve(size_type n);
%rename(isEmpty) empty;
bool empty() const;
void clear();
%rename(add) push_back;
void push_back(const value_type& x);
%extend {
bool get(int i) throw (std::out_of_range) {
int size = int(self->size());
if (i>=0 && i<size)
return (*self)[i];
else
throw std::out_of_range("vector index out of range");
}
void set(int i, const value_type& val) throw (std::out_of_range) {
int size = int(self->size());
if (i>=0 && i<size)
(*self)[i] = val;
else
throw std::out_of_range("vector index out of range");
}
}
};
}
%define specialize_std_vector(T)
#warning "specialize_std_vector - specialization for type T no longer needed"
%enddef

10
Lib/javascript/v8/stl.i Normal file
View file

@ -0,0 +1,10 @@
/* -----------------------------------------------------------------------------
* stl.i
* ----------------------------------------------------------------------------- */
%include <std_common.i>
%include <std_string.i>
%include <std_vector.i>
%include <std_map.i>
%include <std_pair.i>

View file

@ -0,0 +1,148 @@
/* -----------------------------------------------------------------------------
* typemaps.i
*
* Pointer handling
* These mappings provide support for input/output arguments and common
* uses for C/C++ pointers.
* ----------------------------------------------------------------------------- */
// INPUT typemaps.
// These remap a C pointer to be an "INPUT" value which is passed by value
// instead of reference.
/*
The following methods can be applied to turn a pointer into a simple
"input" value. That is, instead of passing a pointer to an object,
you would use a real value instead.
int *INPUT
short *INPUT
long *INPUT
long long *INPUT
unsigned int *INPUT
unsigned short *INPUT
unsigned long *INPUT
unsigned long long *INPUT
unsigned char *INPUT
bool *INPUT
float *INPUT
double *INPUT
To use these, suppose you had a C function like this :
double fadd(double *a, double *b) {
return *a+*b;
}
You could wrap it with SWIG as follows :
%include <typemaps.i>
double fadd(double *INPUT, double *INPUT);
or you can use the %apply directive :
%include <typemaps.i>
%apply double *INPUT { double *a, double *b };
double fadd(double *a, double *b);
*/
// OUTPUT typemaps. These typemaps are used for parameters that
// are output only. The output value is appended to the result as
// a list element.
/*
The following methods can be applied to turn a pointer into an "output"
value. When calling a function, no input value would be given for
a parameter, but an output value would be returned. In the case of
multiple output values, they are returned in the form of a Python tuple.
int *OUTPUT
short *OUTPUT
long *OUTPUT
long long *OUTPUT
unsigned int *OUTPUT
unsigned short *OUTPUT
unsigned long *OUTPUT
unsigned long long *OUTPUT
unsigned char *OUTPUT
bool *OUTPUT
float *OUTPUT
double *OUTPUT
For example, suppose you were trying to wrap the modf() function in the
C math library which splits x into integral and fractional parts (and
returns the integer part in one of its parameters).K:
double modf(double x, double *ip);
You could wrap it with SWIG as follows :
%include <typemaps.i>
double modf(double x, double *OUTPUT);
or you can use the %apply directive :
%include <typemaps.i>
%apply double *OUTPUT { double *ip };
double modf(double x, double *ip);
The Python output of the function would be a tuple containing both
output values.
*/
// INOUT
// Mappings for an argument that is both an input and output
// parameter
/*
The following methods can be applied to make a function parameter both
an input and output value. This combines the behavior of both the
"INPUT" and "OUTPUT" methods described earlier. Output values are
returned in the form of a Python tuple.
int *INOUT
short *INOUT
long *INOUT
long long *INOUT
unsigned int *INOUT
unsigned short *INOUT
unsigned long *INOUT
unsigned long long *INOUT
unsigned char *INOUT
bool *INOUT
float *INOUT
double *INOUT
For example, suppose you were trying to wrap the following function :
void neg(double *x) {
*x = -(*x);
}
You could wrap it with SWIG as follows :
%include <typemaps.i>
void neg(double *INOUT);
or you can use the %apply directive :
%include <typemaps.i>
%apply double *INOUT { double *x };
void neg(double *x);
Unlike C, this mapping does not directly modify the input value (since
this makes no sense in Python). Rather, the modified input value shows
up as the return value of the function. Thus, to apply this function
to a Python variable you might do this :
x = neg(x)
Note : previous versions of SWIG used the symbol 'BOTH' to mark
input/output arguments. This is still supported, but will be slowly
phased out in future releases.
*/
%include <typemaps/typemaps.swg>

View file

@ -9,8 +9,9 @@
* includes
* ----------------------------------------------------------------------------- */
%include <luatypemaps.swg> /* The typemaps */
%include <luatypemaps.swg> /* The typemaps */
%include <luaruntime.swg> /* The runtime stuff */
%include <luakw.swg> /* Warnings for Lua keywords */
//%include <typemaps/swigmacros.swg>
/* -----------------------------------------------------------------------------
@ -40,12 +41,12 @@
%typemap(consttab) long long, unsigned long long
{SWIG_LUA_CONSTTAB_STRING("$symname", "$value")}
%typemap(consttab) SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &, SWIGTYPE []
{ SWIG_LUA_POINTER, (char *)"$symname", 0, 0, (void *)$value, &$1_descriptor}
%typemap(consttab) SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE []
{ SWIG_LUA_CONSTTAB_POINTER("$symname",$value, $1_descriptor) }
// member function pointers
%typemap(consttab) SWIGTYPE (CLASS::*)
{ SWIG_LUA_BINARY, (char *)"$symname", sizeof($type), 0, (void *)&$value, &$1_descriptor}
{ SWIG_LUA_CONSTTAB_BINARY("$symname", sizeof($type),&$value, $1_descriptor) }
/* -----------------------------------------------------------------------------

View file

@ -103,7 +103,6 @@ void swiglua_ref_clear(SWIGLUA_REF* pref){
}
void swiglua_ref_set(SWIGLUA_REF* pref,lua_State* L,int idx){
// swiglua_ref_clear(pref); /* just in case */
pref->L=L;
lua_pushvalue(L,idx); /* copy obj to top */
pref->ref=luaL_ref(L,LUA_REGISTRYINDEX); /* remove obj from top & put into registry */

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