eliminate compilation warnings, add docs, and centralize the access to the unified typemap library
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7710 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
b52bcbb2df
commit
e7eeff806a
31 changed files with 746 additions and 492 deletions
|
|
@ -70,4 +70,10 @@
|
|||
#ifdef rewind
|
||||
#undef rewind
|
||||
#endif
|
||||
#ifdef free
|
||||
#undef free
|
||||
#endif
|
||||
#ifdef malloc
|
||||
#undef malloc
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -24,11 +24,6 @@
|
|||
* ------------------------------------------------------------ */
|
||||
%include <perluserdir.swg>
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Look for user fragments file.
|
||||
* ------------------------------------------------------------ */
|
||||
%include "perlfragments.swg"
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Typemap specializations
|
||||
* ------------------------------------------------------------ */
|
||||
|
|
|
|||
|
|
@ -1,17 +1,2 @@
|
|||
/*
|
||||
in Perl we need to pass the CPerl value, sometimes,
|
||||
so, we define decl/call macros as needed.
|
||||
*/
|
||||
|
||||
|
||||
#define SWIG_ASPTR_DECL_ARGS SWIG_PERL_DECL_ARGS_2
|
||||
#define SWIG_ASPTR_CALL_ARGS SWIG_PERL_CALL_ARGS_2
|
||||
|
||||
#define SWIG_ASVAL_DECL_ARGS SWIG_PERL_DECL_ARGS_2
|
||||
#define SWIG_ASVAL_CALL_ARGS SWIG_PERL_CALL_ARGS_2
|
||||
|
||||
#define SWIG_FROM_DECL_ARGS SWIG_PERL_DECL_ARGS_1
|
||||
#define SWIG_FROM_CALL_ARGS SWIG_PERL_CALL_ARGS_1
|
||||
|
||||
%include <typemaps/swigmacros.swg>
|
||||
|
||||
|
|
|
|||
|
|
@ -3,31 +3,6 @@
|
|||
* ------------------------------------------------------------ */
|
||||
|
||||
|
||||
/* boolean */
|
||||
|
||||
%fragment(SWIG_From_frag(bool),"header") {
|
||||
SWIGINTERN SV *
|
||||
SWIG_From_dec(bool)(bool value)
|
||||
{
|
||||
SV *obj = sv_newmortal();
|
||||
sv_setiv(obj, value ? 1 : 0);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_frag(bool),"header",fragment=SWIG_AsVal_frag(long)) {
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(bool)(SV *obj, bool *val)
|
||||
{
|
||||
long v;
|
||||
if (SWIG_AsVal(long)(obj, val ? &v : 0) == SWIG_OK) {
|
||||
if (val) *val = v ? true : false;
|
||||
return SWIG_OK;
|
||||
}
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
}
|
||||
|
||||
/* long */
|
||||
|
||||
%fragment(SWIG_From_frag(long),"header") {
|
||||
|
|
@ -40,7 +15,6 @@ SWIG_From_dec(long)(long value)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
%fragment(SWIG_AsVal_frag(long),"header") {
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(long)(SV *obj, long* val)
|
||||
|
|
@ -65,7 +39,6 @@ SWIG_From_dec(unsigned long)(unsigned long value)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
%fragment(SWIG_AsVal_frag(unsigned long),"header") {
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(unsigned long)(SV *obj, unsigned long *val)
|
||||
|
|
@ -133,7 +106,6 @@ SWIG_AsVal_dec(long long)(SV *obj, long long *val)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* unsigned long long */
|
||||
|
||||
%fragment(SWIG_From_frag(unsigned long long),"header",
|
||||
|
|
@ -205,5 +177,3 @@ SWIG_AsVal_dec(double)(SV *obj, double *val)
|
|||
return SWIG_TypeError;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
************************************************************************/
|
||||
#ifdef PERL_OBJECT
|
||||
#define SWIG_PERL_OBJECT_DECL CPerlObj *pPerl,
|
||||
#define SWIG_PERL_OBJECT_DECL CPerlObj *pPerl SWIGUNUSED,
|
||||
#define SWIG_PERL_OBJECT_CALL pPerl,
|
||||
#else
|
||||
#define SWIG_PERL_OBJECT_DECL
|
||||
|
|
|
|||
|
|
@ -4,10 +4,6 @@
|
|||
#include <perl.h>
|
||||
#include <XSUB.h>
|
||||
|
||||
/* Get rid of free and malloc defined by perl */
|
||||
#undef free
|
||||
#undef malloc
|
||||
|
||||
#ifndef pTHX_
|
||||
#define pTHX_
|
||||
#endif
|
||||
|
|
@ -44,7 +40,7 @@ typedef int (CPerlObj::*SwigMagicFuncHack)(SV *, MAGIC *);
|
|||
#define SWIGCLASS_STATIC
|
||||
#else
|
||||
#define MAGIC_PPERL
|
||||
#define SWIGCLASS_STATIC static
|
||||
#define SWIGCLASS_STATIC static SWIGUNUSED
|
||||
#ifndef MULTIPLICITY
|
||||
#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b)
|
||||
typedef int (*SwigMagicFunc)(SV *, MAGIC *);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,20 @@ SWIGINTERNINLINE SV *
|
|||
SWIG_FromCharPtrAndSize(const char* carray, size_t size)
|
||||
{
|
||||
SV *obj = sv_newmortal();
|
||||
sv_setpv(obj, carray);
|
||||
if (size && carray) {
|
||||
if (carray[size - 1] == 0) {
|
||||
sv_setpv(obj, carray);
|
||||
} else {
|
||||
char *tmp = %new_array(size + 1, char);
|
||||
memcpy(tmp, carray, size);
|
||||
tmp[size] = 0;
|
||||
sv_setpv(obj, tmp);
|
||||
%delete(tmp);
|
||||
}
|
||||
} else {
|
||||
sv_setpv(obj, 0);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,44 +1,85 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Typemap specializations
|
||||
* ----------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------
|
||||
* Typemap specializations for Perl
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
/* no director supported in Perl */
|
||||
/* ------------------------------------------------------------
|
||||
* Fragment section
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
/*
|
||||
in Perl we need to pass the CPerlObj value, sometimes, so, we define
|
||||
the decl/call macros as needed.
|
||||
*/
|
||||
|
||||
#define SWIG_ASPTR_DECL_ARGS SWIG_PERL_DECL_ARGS_2
|
||||
#define SWIG_ASPTR_CALL_ARGS SWIG_PERL_CALL_ARGS_2
|
||||
|
||||
#define SWIG_ASVAL_DECL_ARGS SWIG_PERL_DECL_ARGS_2
|
||||
#define SWIG_ASVAL_CALL_ARGS SWIG_PERL_CALL_ARGS_2
|
||||
|
||||
#define SWIG_FROM_DECL_ARGS SWIG_PERL_DECL_ARGS_1
|
||||
#define SWIG_FROM_CALL_ARGS SWIG_PERL_CALL_ARGS_1
|
||||
|
||||
|
||||
/* Include fundamental fragemt definitions */
|
||||
%include <typemaps/fragments.swg>
|
||||
|
||||
/* Look for user fragments file. */
|
||||
%include "perlfragments.swg"
|
||||
|
||||
/* Perl fragments for primitive types */
|
||||
%include <perlprimtypes.swg>
|
||||
|
||||
/* Perl fragments for char* strings */
|
||||
%include <perlstrings.swg>
|
||||
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Unified typemap section
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
/* No director supported in Perl */
|
||||
#ifdef SWIG_DIRECTOR_TYPEMAPS
|
||||
#undef SWIG_DIRECTOR_TYPEMAPS
|
||||
#endif
|
||||
|
||||
/* Perl types */
|
||||
#define SWIG_Object SV *
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Basic definitions
|
||||
*
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* Perl $shadow flag */
|
||||
#define %newpointer_flags $shadow
|
||||
#define %newinstance_flags $shadow
|
||||
|
||||
#define SWIG_Object SV *
|
||||
#define VOID_Object $result; argvi=0
|
||||
|
||||
#define %set_output(obj) $result = obj; argvi++
|
||||
#define %append_output(obj) if (argvi >= items) EXTEND(sp,1); %set_output(obj)
|
||||
#define %set_varoutput(obj) sv_setsv($result,obj);
|
||||
#define %raise(obj, type, desc) sv_setsv(perl_get_sv("@", TRUE), obj); croak(Nullch)
|
||||
%define %set_constant(name, obj) {
|
||||
/* Complete overload of the output/constant/exception macros */
|
||||
|
||||
/* output */
|
||||
%define %set_output(obj)
|
||||
$result = obj;
|
||||
argvi++ %enddef
|
||||
|
||||
/* append output */
|
||||
%define %append_output(obj)
|
||||
if (argvi >= items) {
|
||||
EXTEND(sp,1);
|
||||
}
|
||||
%set_output(obj) %enddef
|
||||
|
||||
/* variable output */
|
||||
%define %set_varoutput(obj) sv_setsv($result,obj) %enddef
|
||||
|
||||
/* constant */
|
||||
%define %set_constant(name, obj) %begin_block
|
||||
SV *sv = get_sv((char*) SWIG_prefix name, TRUE | 0x2);
|
||||
sv_setsv(sv, obj);
|
||||
SvREADONLY_on(sv);
|
||||
}
|
||||
%enddef
|
||||
%end_block %enddef
|
||||
|
||||
/* raise exception */
|
||||
%define %raise(obj, type, desc)
|
||||
sv_setsv(perl_get_sv("@", TRUE), obj);
|
||||
croak(Nullch) %enddef
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* All the typemaps
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
%include <perlprimtypes.swg>
|
||||
%include <perlstrings.swg>
|
||||
|
||||
/* Include the unified typemap library */
|
||||
%include <typemaps/swigtypemaps.swg>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
/* ------------------------------------------------------------
|
||||
* --- Consttab --- needed for callbacks, it should be removed later.
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%typemap(consttab) SWIGTYPE ((*)(ANY))
|
||||
{ SWIG_PY_POINTER, (char*)"$symname", 0, 0, (void *)($value), &$descriptor }
|
||||
|
||||
%typemap(constcode) SWIGTYPE ((*)(ANY)) "";
|
||||
|
||||
|
|
@ -24,11 +24,6 @@
|
|||
* ------------------------------------------------------------ */
|
||||
%include <pyuserdir.swg>
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Look for user fragments file.
|
||||
* ------------------------------------------------------------ */
|
||||
%include "pyfragments.swg"
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Typemap specializations
|
||||
* ------------------------------------------------------------ */
|
||||
|
|
|
|||
|
|
@ -1,45 +1,79 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Typemap specializations
|
||||
* ----------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------
|
||||
* Typemap specializations for Python
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Fragment section
|
||||
* ------------------------------------------------------------ */
|
||||
/* bool is dangerous in Python, change precedence */
|
||||
#undef SWIG_TYPECHECK_BOOL
|
||||
%define SWIG_TYPECHECK_BOOL 10000 %enddef
|
||||
|
||||
/* Include fundamental fragemt definitions */
|
||||
%include <typemaps/fragments.swg>
|
||||
|
||||
/* Look for user fragments file. */
|
||||
%include "pyfragments.swg"
|
||||
|
||||
/* Python fragments for fundamental types */
|
||||
%include <pyprimtypes.swg>
|
||||
|
||||
/* Python fragments for char* strings */
|
||||
%include <pystrings.swg>
|
||||
|
||||
/* Backward compatibility output helper */
|
||||
%fragment("t_output_helper","header") %{
|
||||
#define t_output_helper SWIG_Python_AppendOutput
|
||||
%}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Unified typemap section
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
/* directors are supported in Python */
|
||||
#ifndef SWIG_DIRECTOR_TYPEMAPS
|
||||
#define SWIG_DIRECTOR_TYPEMAPS
|
||||
#endif
|
||||
|
||||
/* bool is dangerous in Python -> C++, change precedence */
|
||||
#undef SWIG_TYPECHECK_BOOL
|
||||
%define SWIG_TYPECHECK_BOOL 10000 %enddef
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Basic definitions
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* Python types */
|
||||
#define SWIG_Object PyObject *
|
||||
#define VOID_Object (Py_INCREF(Py_None) ? Py_None : 0)
|
||||
|
||||
/* Overload of the output/constant/exception/dirout handling */
|
||||
|
||||
/* append output */
|
||||
#define SWIG_AppendOutput(result,obj) SWIG_Python_AppendOutput(result, obj)
|
||||
#define SWIG_SetConstant(name, obj) %block(PyObject *_obj = obj; PyDict_SetItemString(d, name, _obj); Py_DECREF(_obj))
|
||||
#define SWIG_Raise(obj, type, desc) PyObject *_obj = obj; PyErr_SetObject(SWIG_Python_ExceptionType(desc), _obj); Py_DECREF(_obj)
|
||||
#define SWIG_DirOutFail(code, msg) Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(code), msg)
|
||||
|
||||
/* set constant */
|
||||
%define %set_constant(name, obj) %begin_block
|
||||
PyObject *_obj = obj;
|
||||
PyDict_SetItemString(d, name, _obj);
|
||||
Py_DECREF(_obj);
|
||||
%end_block %enddef
|
||||
|
||||
/* raise */
|
||||
%define %raise(obj, type, desc)
|
||||
PyObject *_obj = obj;
|
||||
PyErr_SetObject(SWIG_Python_ExceptionType(desc), _obj);
|
||||
Py_DECREF(_obj) %enddef
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* All the typemaps
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <pyprimtypes.swg>
|
||||
%include <pystrings.swg>
|
||||
/* Include the unified typemap library */
|
||||
%include <typemaps/swigtypemaps.swg>
|
||||
|
||||
/* fix for callbacks */
|
||||
%include <pyswigtype.swg>
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Backward compatibility output helper
|
||||
* ----------------------------------------------------------------------------- */
|
||||
%fragment("t_output_helper","header") %{
|
||||
#define t_output_helper SWIG_Python_AppendOutput
|
||||
%}
|
||||
/* ------------------------------------------------------------
|
||||
* Python extra typemaps
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
/* Consttab, needed for callbacks, it should be removed later */
|
||||
|
||||
%typemap(consttab) SWIGTYPE ((*)(ANY))
|
||||
{ SWIG_PY_POINTER, (char*)"$symname", 0, 0, (void *)($value), &$descriptor }
|
||||
|
||||
%typemap(constcode) SWIGTYPE ((*)(ANY)) "";
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1 @@
|
|||
%include <typemaps/typemaps.swg>
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -24,11 +24,6 @@
|
|||
* ------------------------------------------------------------ */
|
||||
%include <rubyuserdir.swg>
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Look for user fragments file.
|
||||
* ------------------------------------------------------------ */
|
||||
%include "rubyfragments.swg"
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Typemap specializations
|
||||
* ------------------------------------------------------------ */
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ SWIGINTERN VALUE SWIG_AUX_##Method##(VALUE *args)
|
|||
|
||||
%fragment(SWIG_From_frag(bool),"header") {
|
||||
SWIGINTERNINLINE VALUE
|
||||
SWIG_From_dec(bool)(bool value)
|
||||
SWIG_From_dec(bool)(bool value)
|
||||
{
|
||||
return value ? Qtrue : Qfalse;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,40 +1,51 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Typemap specializations
|
||||
* ----------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------
|
||||
* Typemap specializations for Ruby
|
||||
* ------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------
|
||||
* Fragment section
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
/* directors are supported in Ruby */
|
||||
/* Include fundamental fragemt definitions */
|
||||
%include <typemaps/fragments.swg>
|
||||
|
||||
/* Look for user fragments file. */
|
||||
%include "rubyfragments.swg"
|
||||
|
||||
/* Ruby fragments for primitive types */
|
||||
%include <rubyprimtypes.swg>
|
||||
|
||||
/* Ruby fragments for char* strings */
|
||||
%include <rubystrings.swg>
|
||||
|
||||
/* Backward compatibility output helper */
|
||||
%fragment("output_helper","header") %{
|
||||
#define output_helper SWIG_Ruby_AppendOutput
|
||||
%}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Unified typemap section
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
/* Directors are supported in Ruby */
|
||||
#ifndef SWIG_DIRECTOR_TYPEMAPS
|
||||
#define SWIG_DIRECTOR_TYPEMAPS
|
||||
#endif
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Basic definitions
|
||||
* ----------------------------------------------------------------------------- */
|
||||
/* Ruby types */
|
||||
#define SWIG_Object VALUE
|
||||
#define VOID_Object Qnil
|
||||
|
||||
/* Ruby $track flag */
|
||||
#define %convertptr_flags $track
|
||||
#define %newpointer_flags $track
|
||||
#define %newinstance_flags $track
|
||||
|
||||
#define SWIG_Object VALUE
|
||||
#define VOID_Object Qnil
|
||||
|
||||
/* Simple overload of the output/constant/exception handling */
|
||||
#define SWIG_AppendOutput(result,obj) SWIG_Ruby_AppendOutput(result, obj)
|
||||
#define SWIG_SetConstant(name, obj) rb_define_const($module, name, obj)
|
||||
#define SWIG_Raise(obj, type, desc) rb_exc_raise(rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj)))
|
||||
#define SWIG_DirOutFail(code, msg) Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(code), msg)
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* All the typemaps
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <rubyprimtypes.swg>
|
||||
%include <rubystrings.swg>
|
||||
/* Include the unified typemap library */
|
||||
%include <typemaps/swigtypemaps.swg>
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Backward compatibility output helper
|
||||
* ----------------------------------------------------------------------------- */
|
||||
%fragment("output_helper","header") %{
|
||||
#define output_helper SWIG_Ruby_AppendOutput
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -24,11 +24,6 @@
|
|||
* ------------------------------------------------------------ */
|
||||
%include <tcluserdir.swg>
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Look for user fragments file.
|
||||
* ------------------------------------------------------------ */
|
||||
%include "tclfragments.swg"
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Typemap specializations
|
||||
* ------------------------------------------------------------ */
|
||||
|
|
|
|||
|
|
@ -1,14 +1,3 @@
|
|||
/*
|
||||
in Tcl we need to pass the interp value, so, we
|
||||
define decl/call macros as needed.
|
||||
*/
|
||||
|
||||
#define SWIG_ASPTR_DECL_ARGS SWIG_TCL_DECL_ARGS_2
|
||||
#define SWIG_ASPTR_CALL_ARGS SWIG_TCL_CALL_ARGS_2
|
||||
|
||||
#define SWIG_ASVAL_DECL_ARGS SWIG_TCL_DECL_ARGS_2
|
||||
#define SWIG_ASVAL_CALL_ARGS SWIG_TCL_CALL_ARGS_2
|
||||
|
||||
%include <typemaps/swigmacros.swg>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@
|
|||
#define SWIG_ObjectDelete SWIG_Tcl_ObjectDelete
|
||||
|
||||
|
||||
#define SWIG_TCL_DECL_ARGS_2(arg1, arg2) (Tcl_Interp *interp, arg1, arg2)
|
||||
#define SWIG_TCL_DECL_ARGS_2(arg1, arg2) (Tcl_Interp *interp SWIGUNUSED, arg1, arg2)
|
||||
#define SWIG_TCL_CALL_ARGS_2(arg1, arg2) (interp, arg1, arg2)
|
||||
/* -----------------------------------------------------------------------------
|
||||
* pointers/data manipulation
|
||||
|
|
@ -167,7 +167,7 @@ SWIG_Tcl_PointerTypeFromString(char *c) {
|
|||
|
||||
/* Convert a packed value value */
|
||||
SWIGRUNTIME int
|
||||
SWIG_Tcl_ConvertPacked(Tcl_Interp *interp, Tcl_Obj *obj, void *ptr, int sz, swig_type_info *ty) {
|
||||
SWIG_Tcl_ConvertPacked(Tcl_Interp *interp SWIGUNUSED, Tcl_Obj *obj, void *ptr, int sz, swig_type_info *ty) {
|
||||
swig_cast_info *tc;
|
||||
const char *c;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
%typemap(out) SWIGTYPE = SWIGTYPE INSTANCE;
|
||||
%typemap(out) SWIGTYPE * = SWIGTYPE *INSTANCE;
|
||||
%typemap(out) SWIGTYPE & = SWIGTYPE &INSTANCE;
|
||||
%typemap(out) SWIGTYPE [] = SWIGTYPE INSTANCE[];
|
||||
%typemap(varout) SWIGTYPE = SWIGTYPE INSTANCE;
|
||||
|
||||
%typemap(throws,noblock=1) SWIGTYPE CLASS {
|
||||
SWIG_set_result(SWIG_NewInstanceObj(SWIG_as_voidptr(SWIG_new_copy($1, $1_ltype)), $&1_descriptor, 1));
|
||||
SWIG_fail;
|
||||
}
|
||||
|
||||
|
|
@ -1,31 +1,70 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Typemap specializations
|
||||
* ----------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------
|
||||
* Typemap specializations for Tcl
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
/* no director supported in Tcl */
|
||||
/* ------------------------------------------------------------
|
||||
* Fragment section
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
/*
|
||||
in Tcl we need to pass the interp value, so, we define the decl/call
|
||||
macros as needed.
|
||||
*/
|
||||
|
||||
#define SWIG_ASPTR_DECL_ARGS SWIG_TCL_DECL_ARGS_2
|
||||
#define SWIG_ASPTR_CALL_ARGS SWIG_TCL_CALL_ARGS_2
|
||||
|
||||
#define SWIG_ASVAL_DECL_ARGS SWIG_TCL_DECL_ARGS_2
|
||||
#define SWIG_ASVAL_CALL_ARGS SWIG_TCL_CALL_ARGS_2
|
||||
|
||||
|
||||
/* Include fundamental fragemt definitions */
|
||||
%include <typemaps/fragments.swg>
|
||||
|
||||
/* Look for user fragments file. */
|
||||
%include "tclfragments.swg"
|
||||
|
||||
/* Tcl fragments for primitve types */
|
||||
%include <tclprimtypes.swg>
|
||||
|
||||
/* Tcl fragments for char* strings */
|
||||
%include <tclstrings.swg>
|
||||
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Unified typemap section
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
/* No director supported in Tcl */
|
||||
#ifdef SWIG_DIRECTOR_TYPEMAPS
|
||||
#undef SWIG_DIRECTOR_TYPEMAPS
|
||||
#endif
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Basic definitions
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* Tcl types */
|
||||
#define SWIG_Object Tcl_Obj *
|
||||
#define VOID_Object NULL
|
||||
|
||||
/* Simple overload of the output/constant/exception handling */
|
||||
#define SWIG_AppendOutput(result,obj) (Tcl_ListObjAppendElement(NULL,result,obj) == TCL_OK) ? result : NULL
|
||||
#define SWIG_SetConstant(name, obj) SWIG_Tcl_SetConstantObj(interp, name, obj)
|
||||
#define SWIG_Raise(obj,type,desc) SWIG_Tcl_SetErrorObj(interp,type,obj)
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* All the typemaps
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <tclprimtypes.swg>
|
||||
%include <tclstrings.swg>
|
||||
/* Include the unified typemap library */
|
||||
%include <typemaps/swigtypemaps.swg>
|
||||
|
||||
/* fix for instances */
|
||||
%include <tclswigtype.swg>
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Tcl extra typemaps
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%typemap(out) SWIGTYPE = SWIGTYPE INSTANCE;
|
||||
%typemap(out) SWIGTYPE * = SWIGTYPE *INSTANCE;
|
||||
%typemap(out) SWIGTYPE & = SWIGTYPE &INSTANCE;
|
||||
%typemap(out) SWIGTYPE [] = SWIGTYPE INSTANCE[];
|
||||
%typemap(varout) SWIGTYPE = SWIGTYPE INSTANCE;
|
||||
|
||||
%typemap(throws,noblock=1) SWIGTYPE CLASS {
|
||||
SWIG_set_result(SWIG_NewInstanceObj(SWIG_as_voidptr(SWIG_new_copy($1, $1_ltype)), $&1_descriptor, 1));
|
||||
SWIG_fail;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,39 +26,3 @@
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
typemaps needed due to unnamed enums
|
||||
*/
|
||||
%define %enum_out_typemaps(from_meth,frag)
|
||||
%typemap(out,noblock=1,fragment=frag) enum SWIGTYPE {
|
||||
%set_output(from_meth(($1)));
|
||||
}
|
||||
%typemap(out,noblock=1,fragment=frag) const enum SWIGTYPE& {
|
||||
%set_output(from_meth((*$1)));
|
||||
}
|
||||
%typemap(varout,noblock=1,fragment=frag) enum SWIGTYPE, const enum SWIGTYPE& {
|
||||
%set_varoutput(from_meth($1));
|
||||
}
|
||||
%typemap(constcode,noblock=1,fragment=frag) enum SWIGTYPE {
|
||||
%set_constant("$symname", from_meth($value));
|
||||
}
|
||||
%typemap(directorin,noblock=1,fragment=frag) enum SWIGTYPE *DIRECTORIN {
|
||||
$input = from_meth(*$1_name);
|
||||
}
|
||||
%typemap(directorin,noblock=1,fragment=frag) enum SWIGTYPE, const enum SWIGTYPE& {
|
||||
$input = from_meth($1_name);
|
||||
}
|
||||
%typemap(throws,noblock=1,fragment=frag) enum SWIGTYPE {
|
||||
%raise(from_meth($1),"$type",0);
|
||||
}
|
||||
%enddef
|
||||
|
||||
%enum_out_typemaps(SWIG_From(int),SWIG_From_frag(int));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,143 +0,0 @@
|
|||
/*
|
||||
Special macros to define and use fragment names and declarations.
|
||||
|
||||
These macros generate the names used in fragments, for example, a
|
||||
typical use will be:
|
||||
|
||||
%fragment(SWIG_From_frag(bool),"header") {
|
||||
SWIGINTERNINLINE PyObject*
|
||||
SWIG_From_dec(bool)(bool value)
|
||||
{
|
||||
PyObject *obj = value ? Py_True : Py_False;
|
||||
Py_INCREF(obj);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
and then you can call the method using
|
||||
|
||||
%typemap(out,fragment=SWIG_From_frag(bool)) bool {
|
||||
%set_output(SWIG_From(bool)($1));
|
||||
}
|
||||
|
||||
when the typemap get generated, the proper fragment for the
|
||||
SWIG_From(bool) method will be included.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#define SWIG_Traits_frag(Type...) %string_type(Traits, Type)
|
||||
#define SWIG_AsPtr_frag(Type...) %string_type(AsPtr, Type)
|
||||
#define SWIG_AsVal_frag(Type...) %string_type(AsVal, Type)
|
||||
#define SWIG_From_frag(Type...) %string_type(From, Type)
|
||||
|
||||
|
||||
#ifndef SWIG_ASVAL_DECL_ARGS
|
||||
#define SWIG_ASVAL_DECL_ARGS
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_ASPTR_DECL_ARGS
|
||||
#define SWIG_ASPTR_DECL_ARGS
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_FROM_DECL_ARGS
|
||||
#define SWIG_FROM_DECL_ARGS
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_ASVAL_CALL_ARGS
|
||||
#define SWIG_ASVAL_CALL_ARGS
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_ASPTR_CALL_ARGS
|
||||
#define SWIG_ASPTR_CALL_ARGS
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_FROM_CALL_ARGS
|
||||
#define SWIG_FROM_CALL_ARGS
|
||||
#endif
|
||||
|
||||
|
||||
#define SWIG_AsVal_dec(Type...) %name_type(AsVal, Type) SWIG_ASVAL_DECL_ARGS
|
||||
#define SWIG_AsPtr_dec(Type...) %name_type(AsPtr, Type) SWIG_ASPTR_DECL_ARGS
|
||||
#define SWIG_From_dec(Type...) %name_type(From, Type) SWIG_FROM_DECL_ARGS
|
||||
|
||||
#define SWIG_AsVal(Type...) %name_type(AsVal, Type) SWIG_ASVAL_CALL_ARGS
|
||||
#define SWIG_AsPtr(Type...) %name_type(AsPtr, Type) SWIG_ASPTR_CALL_ARGS
|
||||
#define SWIG_From(Type...) %name_type(From, Type) SWIG_FROM_CALL_ARGS
|
||||
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* common macro helpers
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
|
||||
/* Macros for numeric types */
|
||||
|
||||
%define %numeric_type_from(Type, Base)
|
||||
%fragment(SWIG_From_frag(Type),"header",
|
||||
fragment=SWIG_From_frag(Base)) {
|
||||
SWIGINTERNINLINE SWIG_Object
|
||||
SWIG_From_dec(Type)(Type value)
|
||||
{
|
||||
return SWIG_From(Base)(value);
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
%define %numeric_type_asval(Type, Base, Frag, OverflowCond)
|
||||
%fragment(SWIG_AsVal_frag(Type),"header",
|
||||
fragment=Frag,
|
||||
fragment=SWIG_AsVal_frag(Base)) {
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(Type)(SWIG_Object obj, Type *val)
|
||||
{
|
||||
Base v;
|
||||
int res = SWIG_AsVal(Base)(obj, &v);
|
||||
if (res == SWIG_OK) {
|
||||
if (OverflowCond) {
|
||||
return SWIG_OverflowError;
|
||||
} else {
|
||||
if (val) *val = %numeric_cast(v, Type);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
%define %numeric_signed_type_asval(Type, Base, Frag, Min, Max)
|
||||
%numeric_type_asval(Type, Base, Frag, (v < Min || v > Max))
|
||||
%enddef
|
||||
|
||||
%define %numeric_unsigned_type_asval(Type, Base, Frag, Max)
|
||||
%numeric_type_asval(Type, Base, Frag, (v > Max))
|
||||
%enddef
|
||||
|
||||
|
||||
/* Macro for 'signed long' derived types */
|
||||
|
||||
%define %numeric_slong(Type, Frag, Min, Max)
|
||||
%numeric_type_from(Type, long)
|
||||
%numeric_signed_type_asval(Type, long, Frag , Min, Max)
|
||||
%enddef
|
||||
|
||||
/* Macro for 'unsigned long' derived types */
|
||||
|
||||
%define %numeric_ulong(Type, Frag, Max)
|
||||
%numeric_type_from(Type, unsigned long)
|
||||
%numeric_unsigned_type_asval(Type, unsigned long, Frag, Max)
|
||||
%enddef
|
||||
|
||||
|
||||
/* Macro for 'double' derived types */
|
||||
|
||||
%define %numeric_double(Type, Frag, Min, Max)
|
||||
%numeric_type_from(Type, double)
|
||||
%numeric_signed_type_asval(Type, double, Frag , Min, Max)
|
||||
%enddef
|
||||
|
||||
|
||||
|
|
@ -269,11 +269,51 @@
|
|||
*/
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Define the basic macros to 'normalize' the type fragments
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef SWIG_ASVAL_DECL_ARGS
|
||||
#define SWIG_ASVAL_DECL_ARGS
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_ASPTR_DECL_ARGS
|
||||
#define SWIG_ASPTR_DECL_ARGS
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_FROM_DECL_ARGS
|
||||
#define SWIG_FROM_DECL_ARGS
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_ASVAL_CALL_ARGS
|
||||
#define SWIG_ASVAL_CALL_ARGS
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_ASPTR_CALL_ARGS
|
||||
#define SWIG_ASPTR_CALL_ARGS
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_FROM_CALL_ARGS
|
||||
#define SWIG_FROM_CALL_ARGS
|
||||
#endif
|
||||
|
||||
#define SWIG_Traits_frag(Type...) %string_type(Traits, Type)
|
||||
#define SWIG_AsPtr_frag(Type...) %string_type(AsPtr, Type)
|
||||
#define SWIG_AsVal_frag(Type...) %string_type(AsVal, Type)
|
||||
#define SWIG_From_frag(Type...) %string_type(From, Type)
|
||||
|
||||
#define SWIG_AsVal_dec(Type...) %name_type(AsVal, Type) SWIG_ASVAL_DECL_ARGS
|
||||
#define SWIG_AsPtr_dec(Type...) %name_type(AsPtr, Type) SWIG_ASPTR_DECL_ARGS
|
||||
#define SWIG_From_dec(Type...) %name_type(From, Type) SWIG_FROM_DECL_ARGS
|
||||
|
||||
#define SWIG_AsVal(Type...) %name_type(AsVal, Type) SWIG_ASVAL_CALL_ARGS
|
||||
#define SWIG_AsPtr(Type...) %name_type(AsPtr, Type) SWIG_ASPTR_CALL_ARGS
|
||||
#define SWIG_From(Type...) %name_type(From, Type) SWIG_FROM_CALL_ARGS
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* common fragments
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
|
||||
%fragment("<limits.h>","header") %{
|
||||
#include <limits.h>
|
||||
%}
|
||||
|
|
@ -286,4 +326,90 @@
|
|||
#include <float.h>
|
||||
%}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* special macros for fragments
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* Macros to derive numeric types */
|
||||
|
||||
%define %numeric_type_from(Type, Base)
|
||||
%fragment(SWIG_From_frag(Type),"header",
|
||||
fragment=SWIG_From_frag(Base)) {
|
||||
SWIGINTERNINLINE SWIG_Object
|
||||
SWIG_From_dec(Type)(Type value)
|
||||
{
|
||||
return SWIG_From(Base)(value);
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
%define %numeric_type_asval(Type, Base, Frag, OverflowCond)
|
||||
%fragment(SWIG_AsVal_frag(Type),"header",
|
||||
fragment=Frag,
|
||||
fragment=SWIG_AsVal_frag(Base)) {
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(Type)(SWIG_Object obj, Type *val)
|
||||
{
|
||||
Base v;
|
||||
int res = SWIG_AsVal(Base)(obj, &v);
|
||||
if (res == SWIG_OK) {
|
||||
if (OverflowCond) {
|
||||
return SWIG_OverflowError;
|
||||
} else {
|
||||
if (val) *val = %numeric_cast(v, Type);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
%define %numeric_signed_type_asval(Type, Base, Frag, Min, Max)
|
||||
%numeric_type_asval(Type, Base, Frag, (v < Min || v > Max))
|
||||
%enddef
|
||||
|
||||
%define %numeric_unsigned_type_asval(Type, Base, Frag, Max)
|
||||
%numeric_type_asval(Type, Base, Frag, (v > Max))
|
||||
%enddef
|
||||
|
||||
|
||||
/* Macro for 'signed long' derived types */
|
||||
|
||||
%define %numeric_slong(Type, Frag, Min, Max)
|
||||
%numeric_type_from(Type, long)
|
||||
%numeric_signed_type_asval(Type, long, Frag , Min, Max)
|
||||
%enddef
|
||||
|
||||
/* Macro for 'unsigned long' derived types */
|
||||
|
||||
%define %numeric_ulong(Type, Frag, Max)
|
||||
%numeric_type_from(Type, unsigned long)
|
||||
%numeric_unsigned_type_asval(Type, unsigned long, Frag, Max)
|
||||
%enddef
|
||||
|
||||
|
||||
/* Macro for 'double' derived types */
|
||||
|
||||
%define %numeric_double(Type, Frag, Min, Max)
|
||||
%numeric_type_from(Type, double)
|
||||
%numeric_signed_type_asval(Type, double, Frag , Min, Max)
|
||||
%enddef
|
||||
|
||||
|
||||
/* Macros for missing fragments */
|
||||
|
||||
%define %ensure_fragment(Fragment)
|
||||
%fragment(`Fragment`,"header") {
|
||||
%#error "Swig language implementation must provide the Fragment fragment"
|
||||
}
|
||||
%enddef
|
||||
|
||||
%define %ensure_type_fragments(Type)
|
||||
%fragment(SWIG_From_frag(Type),"header") {
|
||||
%#error "Swig language implementation must provide a SWIG_From_frag(Type) fragment"
|
||||
}
|
||||
%fragment(SWIG_AsVal_frag(Type),"header") {
|
||||
%#error "Swig language implementation must provide a SWIG_AsVal_frag(Type) fragment"
|
||||
}
|
||||
%enddef
|
||||
|
|
|
|||
|
|
@ -1,7 +1,117 @@
|
|||
/* ------------------------------------------------------------
|
||||
* Basic fragments derived from long and double types
|
||||
* Primitive type fragments and macros
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
/*
|
||||
This file provide fragments and macros for the C/C++ primitive types.
|
||||
|
||||
The file defines default fragments for the following types:
|
||||
|
||||
bool
|
||||
signed char
|
||||
unsigned char
|
||||
signed wchar_t // in C++
|
||||
unsigned wchar_t // in C++
|
||||
short
|
||||
unsigned short
|
||||
int
|
||||
unsigned int
|
||||
float
|
||||
|
||||
which can always be redefined in the swig target languge if needed.
|
||||
|
||||
The fragments for the following types, however, need to be defined
|
||||
in the target language always:
|
||||
|
||||
long
|
||||
unsigned long
|
||||
long long
|
||||
unsigned long long
|
||||
double
|
||||
|
||||
If they are not provided, an #error directive will appear in the
|
||||
wrapped code.
|
||||
|
||||
--------------------------------------------------------------------
|
||||
|
||||
This file provides the macro
|
||||
|
||||
%typemaps_primitive(CheckCode, Type)
|
||||
|
||||
which generate the typemaps for a primitive type with a given
|
||||
checkcode. It is assumed the the primitive type is 'normalized' and
|
||||
the corresponding SWIG_AsVal(Type) and SWIG_From(Type) methods are
|
||||
provided via fragments.
|
||||
|
||||
|
||||
The following auxiliar macros (explained with bash pseudo code) are
|
||||
also defined:
|
||||
|
||||
%apply_ctypes(Macro)
|
||||
for i in C Type
|
||||
do
|
||||
Macro($i)
|
||||
done
|
||||
|
||||
%apply_cpptypes(Macro)
|
||||
for i in C++ Type
|
||||
do
|
||||
Macro($i)
|
||||
done
|
||||
|
||||
%apply_ctypes_2(Macro2)
|
||||
for i in C Type
|
||||
do
|
||||
for j in C Type
|
||||
do
|
||||
Macro_2($i, $j)
|
||||
done
|
||||
done
|
||||
|
||||
%apply_cpptypes_2(Macro2)
|
||||
for i in C++ Type
|
||||
do
|
||||
for j in C++ Type
|
||||
do
|
||||
Macro_2($i, $j)
|
||||
done
|
||||
done
|
||||
|
||||
%apply_checkctypes(Macro2)
|
||||
for i in Check Type
|
||||
do
|
||||
Macro2(%checkcode($i), $i)
|
||||
done
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Primitive type fragments
|
||||
* ------------------------------------------------------------ */
|
||||
/* boolean */
|
||||
|
||||
%fragment(SWIG_From_frag(bool),"header",fragment=SWIG_From_frag(long)) {
|
||||
SWIGINTERN SWIG_Object
|
||||
SWIG_From_dec(bool)(bool value)
|
||||
{
|
||||
return SWIG_From(long)(value ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_frag(bool),"header",fragment=SWIG_AsVal_frag(long)) {
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(bool)(SWIG_Object obj, bool *val)
|
||||
{
|
||||
long v;
|
||||
if (SWIG_AsVal(long)(obj, val ? &v : 0) == SWIG_OK) {
|
||||
if (val) *val = v ? true : false;
|
||||
return SWIG_OK;
|
||||
}
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
}
|
||||
|
||||
/* signed/unsigned char */
|
||||
|
||||
%numeric_slong(signed char, "<limits.h>", SCHAR_MIN, SCHAR_MAX)
|
||||
|
|
@ -28,9 +138,23 @@
|
|||
|
||||
%numeric_double(float, "<float.h>", -FLT_MAX, FLT_MAX)
|
||||
|
||||
/* long/unsgined long */
|
||||
|
||||
%ensure_type_fragments(long)
|
||||
%ensure_type_fragments(unsigned long)
|
||||
|
||||
/* long long/unsigned long long */
|
||||
|
||||
%ensure_type_fragments(long long)
|
||||
%ensure_type_fragments(unsigned long long)
|
||||
|
||||
/* double */
|
||||
|
||||
%ensure_type_fragments(double)
|
||||
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* typemap macro for primitive types with asval/from methods
|
||||
* Generate the typemaps for primitive type
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%define %typemaps_primitive(Code, Type)
|
||||
|
|
@ -70,7 +194,12 @@ _apply_macro(Macro, char , __VA_ARGS__);
|
|||
_apply_macro(Macro, wchar_t , __VA_ARGS__);
|
||||
%enddef
|
||||
|
||||
/* apply the Macro(Type) to all the C++ types */
|
||||
/* apply the Macro2(Type1, Type2) to all C types */
|
||||
%define %apply_ctypes_2(Macro2)
|
||||
%apply_ctypes(%apply_ctypes, Macro2)
|
||||
%enddef
|
||||
|
||||
/* apply the Macro(Type) to all C++ types */
|
||||
%define %apply_cpptypes(Macro,...)
|
||||
%apply_ctypes(Macro, __VA_ARGS__)
|
||||
_apply_macro(Macro, std::string, __VA_ARGS__);
|
||||
|
|
@ -78,32 +207,33 @@ _apply_macro(Macro, std::complex<float>, __VA_ARGS__);
|
|||
_apply_macro(Macro, std::complex<double>, __VA_ARGS__);
|
||||
%enddef
|
||||
|
||||
/* apply the Macro2(Type1, Type2) to all the C++ types */
|
||||
/* apply the Macro2(Type1, Type2) to all C++ types */
|
||||
%define %apply_cpptypes_2(Macro2)
|
||||
%apply_cpptypes(%apply_cpptypes, Macro2)
|
||||
%enddef
|
||||
|
||||
%define %apply_checkctypes(Macro)
|
||||
Macro(%checkcode(BOOL), bool);
|
||||
Macro(%checkcode(INT8), signed char);
|
||||
Macro(%checkcode(UINT8), unsigned char);
|
||||
Macro(%checkcode(INT16), short);
|
||||
Macro(%checkcode(UINT16), unsigned short);
|
||||
Macro(%checkcode(INT32), int);
|
||||
Macro(%checkcode(UINT32), unsigned int);
|
||||
Macro(%checkcode(INT64), long);
|
||||
Macro(%checkcode(UINT64), unsigned long);
|
||||
Macro(%checkcode(INT128), long long);
|
||||
Macro(%checkcode(UINT128), unsigned long long);
|
||||
Macro(%checkcode(FLOAT), float);
|
||||
Macro(%checkcode(DOUBLE), double);
|
||||
Macro(%checkcode(CHAR), char);
|
||||
Macro(%checkcode(UNICHAR), wchar_t);
|
||||
/* apply the Macro2(CheckCode,Type) to all Checked Types */
|
||||
%define %apply_checkctypes(Macro2)
|
||||
Macro2(%checkcode(BOOL), bool);
|
||||
Macro2(%checkcode(INT8), signed char);
|
||||
Macro2(%checkcode(UINT8), unsigned char);
|
||||
Macro2(%checkcode(INT16), short);
|
||||
Macro2(%checkcode(UINT16), unsigned short);
|
||||
Macro2(%checkcode(INT32), int);
|
||||
Macro2(%checkcode(UINT32), unsigned int);
|
||||
Macro2(%checkcode(INT64), long);
|
||||
Macro2(%checkcode(UINT64), unsigned long);
|
||||
Macro2(%checkcode(INT128), long long);
|
||||
Macro2(%checkcode(UINT128), unsigned long long);
|
||||
Macro2(%checkcode(FLOAT), float);
|
||||
Macro2(%checkcode(DOUBLE), double);
|
||||
Macro2(%checkcode(CHAR), char);
|
||||
Macro2(%checkcode(UNICHAR), wchar_t);
|
||||
%enddef
|
||||
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Apply the primitive typemap for all the types with checkcode
|
||||
* Generate the typemaps for all the primitive types with checkcode
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%apply_checkctypes(%typemaps_primitive);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
|
||||
%ensure_fragment(SWIG_AsCharPtrAndSize)
|
||||
%ensure_fragment(SWIG_FromCharPtrAndSize)
|
||||
|
||||
%include <typemaps/strings.swg>
|
||||
%typemaps_string(char, Char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, strlen,
|
||||
"<limits.h>", CHAR_MIN, CHAR_MAX)
|
||||
|
|
|
|||
|
|
@ -1,14 +1,97 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* SWIG API. Portion only visible from SWIG
|
||||
* ----------------------------------------------------------------------------- */
|
||||
/*
|
||||
This file implements the internal macros of the 'SWIG API', which
|
||||
are useful to implement all the SWIG target languges.
|
||||
|
||||
Basic preprocessor macros:
|
||||
--------------------------
|
||||
|
||||
%arg(Arg) Safe argument wrap
|
||||
%str(Arg) Stringtify the argument
|
||||
%begin_block Begin a execution block
|
||||
%end_block End a execution block
|
||||
%block(Block) Execute Block as a excecution block
|
||||
%define_as(Def, Val) Define 'Def' as 'Val', expanding Def and Val first
|
||||
%ifcplusplus(V1, V2) if C++ Mode; then V1; else V2; fi
|
||||
|
||||
|
||||
Casting Operations:
|
||||
-------------------
|
||||
|
||||
Swig provides the following casting macros, which implement the
|
||||
corresponding C++ casting operations:
|
||||
|
||||
%const_cast(a, Type) const_cast<Type >(a)
|
||||
%static_cast(a, Type) static_cast<Type >(a)
|
||||
%reinterpret_cast(a, Type) reinterpret_cast<Type >(a)
|
||||
%numeric_cast(a, Type) static_cast<Type >(a)
|
||||
%as_voidptr(a) const_cast<void *>(static_cast<const void *>(a))
|
||||
%as_voidptrptr(a) reinterpret_cast<void **>(a)
|
||||
|
||||
or their C unsafe versions. In C++ we use the safe version unless
|
||||
SWIG_NO_CPLUSPLUS_CAST is defined (usually via the -nocppcast swig flag).
|
||||
|
||||
|
||||
Memory allocation:
|
||||
------------------
|
||||
|
||||
These allocation/freeing macros are safe to use in C or C++ and
|
||||
dispatch the proper new/delete/delete[] or free/malloc calls as
|
||||
needed.
|
||||
|
||||
%new_instance(Type) Allocate a new instance of given Type
|
||||
%new_copy(value,Type) Allocate and initialize a new instance with 'value'
|
||||
%new_array(size,Type) Allocate a new array with given size and Type
|
||||
%new_copy_array(cptr,size,Type) Allocate and initialize a new array from 'cptr'
|
||||
%delete(cptr) Delete an instance
|
||||
%delete_array(cptr) Delete an array
|
||||
|
||||
|
||||
Auxiliar loop macros:
|
||||
---------------------
|
||||
|
||||
%formacro(Macro, Args...) or %formacro_1(Macro, Args...)
|
||||
for i in Args
|
||||
do
|
||||
Macro($i)
|
||||
done
|
||||
|
||||
%formacro_2(Macro2, Args...)
|
||||
for i,j in Args
|
||||
do
|
||||
Macro2($i, $j)
|
||||
done
|
||||
|
||||
|
||||
Swig flags:
|
||||
-----------
|
||||
|
||||
%swig_mark_flag(flag)
|
||||
flag := True
|
||||
|
||||
%evalif(flag,expr)
|
||||
if flag; then
|
||||
expr
|
||||
fi
|
||||
|
||||
%evalif_2(flag1 flag2,expr)
|
||||
if flag1 and flag2; then
|
||||
expr
|
||||
fi
|
||||
|
||||
|
||||
*/
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Basic preprocessor macros
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#define %arg(Arg...) Arg
|
||||
#define %str(Type...) #Type
|
||||
#define %block(Block...) do { Block; } while(0)
|
||||
#define %arg(Arg...) Arg
|
||||
#define %str(Arg) `Arg`
|
||||
#define %begin_block do {
|
||||
#define %end_block } while(0)
|
||||
#define %block(Block...) %begin_block Block; %end_block
|
||||
|
||||
/* define a new macro */
|
||||
%define %define_as(Def, Val...)
|
||||
|
|
@ -41,7 +124,7 @@ nocppval
|
|||
# define %reinterpret_cast(a,Type...) reinterpret_cast<Type >(a)
|
||||
# define %numeric_cast(a,Type...) static_cast<Type >(a)
|
||||
# define %as_voidptr(a) const_cast<void *>(static_cast<const void *>(a))
|
||||
# define %as_voidptrptr(a) reinterpret_cast<void **>(a)
|
||||
# define %as_voidptrptr(a) reinterpret_cast<void **>(a)
|
||||
#else /* C case */
|
||||
# define %const_cast(a,Type...) (Type)(a)
|
||||
# define %static_cast(a,Type...) (Type)(a)
|
||||
|
|
@ -81,27 +164,8 @@ nocppval
|
|||
#define %checkcode(Code) %name_type(TYPECHECK, Code)
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Macros to define language dependent object and the void object.
|
||||
Use them, for example in Tcl, as
|
||||
|
||||
%define_swig_object(Tcl_Obj *)
|
||||
%define_void_object(NULL)
|
||||
*/
|
||||
|
||||
/* VOID_Object */
|
||||
%define %define_void_object(Obj)
|
||||
#define VOID_Object Obj
|
||||
%enddef
|
||||
|
||||
/* SWIG_Object */
|
||||
%define %define_swig_object(Obj)
|
||||
#define SWIG_Object Obj
|
||||
%enddef
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Auxiliar ugly macros used to write typemaps
|
||||
* Auxiliar loop macros
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
|
|
@ -117,6 +181,9 @@ macro(arg1)
|
|||
%define %formacro_1(macro,...)
|
||||
%_formacro_1(macro,__VA_ARGS__,__fordone__)
|
||||
%enddef
|
||||
%define %formacro(macro,...)
|
||||
%_formacro_1(macro,__VA_ARGS__,__fordone__)
|
||||
%enddef
|
||||
|
||||
/* for loop for macro with two arguments */
|
||||
%define %_formacro_2(macro, arg1, arg2, ...)
|
||||
|
|
@ -131,30 +198,21 @@ macro(arg1, arg2)
|
|||
%_formacro_2(macro, __VA_ARGS__, __fordone__)
|
||||
%enddef
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig flags
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
mark a flag, ie, define a macro name but ignore it in
|
||||
the interface.
|
||||
|
||||
the flags latter can be used with %evalif
|
||||
the flag can be later used with %evalif
|
||||
*/
|
||||
|
||||
%define %swig_mark_flag(x)
|
||||
%ignore x;
|
||||
#define x 1
|
||||
%define x 1 %enddef
|
||||
%enddef
|
||||
|
||||
/*
|
||||
%swig_equal_type and %swig_order_type flagged a type of having equal (==,!=)
|
||||
and/or order methods (<=,>=,<,>).
|
||||
*/
|
||||
#define SWIG_OrderType(Type...) %name_type(OrderType, Type)
|
||||
#define SWIG_EqualType(Type...) %name_type(EqualType, Type)
|
||||
|
||||
#define %swig_equal_type(...) %swig_mark_flag(SWIG_EqualType(__VA_ARGS__))
|
||||
#define %swig_order_type(...) \
|
||||
%swig_mark_flag(SWIG_EqualType(__VA_ARGS__)) \
|
||||
%swig_mark_flag(SWIG_OrderType(__VA_ARGS__))
|
||||
|
||||
/*
|
||||
%evalif and %evalif_2 are use to evaluate or process
|
||||
|
|
@ -172,17 +230,11 @@ _expr
|
|||
#endif
|
||||
%enddef
|
||||
|
||||
%define %evalif(_x,...)
|
||||
%_evalif(%arg(_x),%arg(__VA_ARGS__))
|
||||
%define %evalif(_x,_expr...)
|
||||
%_evalif(%arg(_x),%arg(_expr))
|
||||
%enddef
|
||||
|
||||
%define %evalif_2(_x,_y,...)
|
||||
%_evalif_2(%arg(_x),%arg(_y),%arg(__VA_ARGS__))
|
||||
%define %evalif_2(_x,_y,_expr...)
|
||||
%_evalif_2(%arg(_x),%arg(_y),%arg(_expr))
|
||||
%enddef
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Include special macros for fragments
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <typemaps/fragmacros.swg>
|
||||
|
|
|
|||
|
|
@ -2,10 +2,6 @@
|
|||
* Language Object * - Just pass straight through unmodified
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
#if !defined(SWIG_Object)
|
||||
#error "SWIG_Object must be defined using %define_swig_object"
|
||||
#endif
|
||||
|
||||
%typemap(in) SWIG_Object "$1 = $input;";
|
||||
|
||||
%typemap(out,noblock=1) SWIG_Object {
|
||||
|
|
|
|||
|
|
@ -1,68 +1,151 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Typemap specializations
|
||||
* Unified Typemap Library frontend
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* flags for new/convert methods */
|
||||
/*
|
||||
This file provides the frontend to the Unified Typemap Library.
|
||||
|
||||
When using this library in a SWIG target language, you need to
|
||||
define a minimum set of fragments, specialized a couple of macros,
|
||||
and then include this file.
|
||||
|
||||
Typically you will create a 'mytypemaps.swg' file in each target
|
||||
languge, where you will have the following sections:
|
||||
|
||||
=== mytypemaps.swg ===
|
||||
|
||||
// Fragment section
|
||||
%include <typemaps/fragments.swg>
|
||||
<include target language fragments>
|
||||
|
||||
// Unified typemap section
|
||||
<specialized the typemap library macros>
|
||||
%include <typemaps/swigtypemaps.swg>
|
||||
|
||||
// Local typemap section
|
||||
<add/replace extra target language typemaps>
|
||||
|
||||
=== mytypemaps.swg ===
|
||||
|
||||
While we add more docs, please take a look at the following cases
|
||||
to see how you specialized the unified typemap library for a new
|
||||
target language:
|
||||
|
||||
Lib/python/pytypemaps.swg
|
||||
Lib/tcl/tcltypemaps.swg
|
||||
Lib/ruby/rubytypemaps.swg
|
||||
Lib/perl5/perl5typemaps.swg
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language specialization section.
|
||||
*
|
||||
* Tune these macros for each language as needed.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
The SWIG target language object must be provided.
|
||||
For example in python you define:
|
||||
|
||||
#define SWIG_Object PyObject *
|
||||
*/
|
||||
|
||||
#if !defined(SWIG_Object)
|
||||
#error "SWIG_Object must be defined as the SWIG target language object"
|
||||
#endif
|
||||
|
||||
/*==== flags for new/convert methods ====*/
|
||||
|
||||
#ifndef %convertptr_flags
|
||||
%ignore %convertptr_flags;
|
||||
#define %convertptr_flags 0
|
||||
%define %convertptr_flags 0 %enddef
|
||||
#endif
|
||||
|
||||
#ifndef %newpointer_flags
|
||||
%ignore %newpointer_flags;
|
||||
#define %newpointer_flags 0
|
||||
%define %newpointer_flags 0 %enddef
|
||||
#endif
|
||||
|
||||
#ifndef %newinstance_flags
|
||||
%ignore %newinstance_flags;
|
||||
#define %newinstance_flags 0
|
||||
%define %newinstance_flags 0 %enddef
|
||||
#endif
|
||||
|
||||
/* output and constant manipulation */
|
||||
|
||||
#ifndef %set_varoutput
|
||||
#define %set_varoutput(obj) $result = obj
|
||||
#endif
|
||||
/*==== set output ====*/
|
||||
|
||||
#ifndef %set_output
|
||||
#define %set_output(obj) $result = obj
|
||||
/* simple set output operation */
|
||||
#define %set_output(obj) $result = obj
|
||||
#endif
|
||||
|
||||
/*==== set variable output ====*/
|
||||
|
||||
#ifndef %set_varoutput
|
||||
/* simple set varoutput operation */
|
||||
#define %set_varoutput(obj) $result = obj
|
||||
#endif
|
||||
|
||||
/*==== append output ====*/
|
||||
|
||||
#ifndef %append_output
|
||||
#define %append_output(obj) $result = SWIG_AppendOutput($result,obj)
|
||||
#if defined(SWIG_AppendOutput)
|
||||
/* simple append operation */
|
||||
#define %append_output(obj) $result = SWIG_AppendOutput($result,obj)
|
||||
#else
|
||||
#error "Language must define SWIG_AppendOutput or %append_output"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*==== set constant ====*/
|
||||
|
||||
#ifndef %set_constant
|
||||
#define %set_constant(name,value) SWIG_SetConstant(name,value)
|
||||
#if defined(SWIG_SetConstant)
|
||||
/* simple set constant operation */
|
||||
#define %set_constant(name,value) SWIG_SetConstant(name,value)
|
||||
#else
|
||||
#error "Language must define SWIG_SetConstant or %set_constant"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* setting an error and exit */
|
||||
/*==== raise an exception ====*/
|
||||
|
||||
#ifndef %raise
|
||||
#if defined(SWIG_Raise)
|
||||
/* simple raise operation */
|
||||
#define %raise(obj, type, desc) %error_block(SWIG_Raise(obj, type, desc); SWIG_fail)
|
||||
#else
|
||||
#error "Language must define SWIG_Raise or %raise"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*==== director output exception ====*/
|
||||
|
||||
#ifdef SWIG_DIRECTOR_TYPEMAPS
|
||||
#ifndef SWIG_DirOutFail
|
||||
#define SWIG_DirOutFail(code, msg) Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(code), msg)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language independent definitions
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#define %error_block(Block...) %block(Block)
|
||||
#define %argument_fail(code, type, argn) %error_block(SWIG_Error(code, %argfail_fmt(type, argn)); SWIG_fail)
|
||||
#define %argument_nullref(type, argn) %error_block(SWIG_Error(SWIG_ValueError, %argnullref_fmt(type, argn)); SWIG_fail)
|
||||
#define %variable_fail(code, type, name) %error_block(SWIG_Error(code, %varfail_fmt(type, name)); SWIG_fail)
|
||||
#define %variable_nullref(type, name) %error_block(SWIG_Error(SWIG_ValueError, %varnullref_fmt(type, name)); SWIG_fail)
|
||||
|
||||
|
||||
#ifndef %raise
|
||||
#define %raise(obj, type, desc) %error_block(SWIG_Raise(obj, type, desc); SWIG_fail)
|
||||
#endif
|
||||
|
||||
#ifdef SWIG_DIRECTOR_TYPEMAPS
|
||||
#define %dirout_fail(code, type) SWIG_DirOutFail(code, %outfail_fmt(type))
|
||||
#define %dirout_nullref(type) SWIG_DirOutFail(SWIG_ValueError, %outnullref_fmt(type))
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* All the typemaps
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
%include <typemaps/fragments.swg>
|
||||
%include <typemaps/exception.swg>
|
||||
%include <typemaps/swigtype.swg>
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@
|
|||
|
||||
%define %value_varout_typemap(from_meth,frag,Type...)
|
||||
%typemap(varout,noblock=1,fragment=frag) Type, const Type& {
|
||||
%set_varoutput(from_meth(%static_cast($1,$basetype)));
|
||||
%set_varoutput(from_meth(%static_cast($1,Type)));
|
||||
}
|
||||
%enddef
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,6 @@
|
|||
* Void * - Accepts any kind of pointer
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
#if !defined(VOID_Object)
|
||||
#error "VOID_Object must be defined using %define_void_object"
|
||||
#endif
|
||||
|
||||
/* in */
|
||||
|
||||
%typemap(in,noblock=1) void * {
|
||||
|
|
@ -26,9 +22,11 @@
|
|||
|
||||
/* out */
|
||||
|
||||
%typemap(out,noblock=1) void {
|
||||
$result = VOID_Object;
|
||||
}
|
||||
#if defined(VOID_Object)
|
||||
%typemap(out,noblock=1) void { $result = VOID_Object; }
|
||||
#else
|
||||
%typemap(out,noblock=1) void {}
|
||||
#endif
|
||||
|
||||
/* varin */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
%ensure_fragment(SWIG_AsWCharPtrAndSize)
|
||||
%ensure_fragment(SWIG_FromWCharPtrAndSize)
|
||||
|
||||
%include <typemaps/strings.swg>
|
||||
%typemaps_string(wchar_t, WChar, SWIG_AsWCharPtrAndSize, SWIG_FromWCharPtrAndSize, wcslen,
|
||||
"<wchar.h>", WCHAR_MIN, WCHAR_MAX)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue