massive typemap unification
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7676 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
5bbd841acc
commit
7e5e4fd1f9
144 changed files with 6378 additions and 7248 deletions
1
Lib/tcl/cdata.i
Normal file
1
Lib/tcl/cdata.i
Normal file
|
|
@ -0,0 +1 @@
|
|||
%include <typemaps/cdata.swg>
|
||||
|
|
@ -10,70 +10,45 @@
|
|||
* some way.
|
||||
*/
|
||||
|
||||
/* %cstring_input_binary(TYPEMAP, SIZE)
|
||||
/*
|
||||
* %cstring_input_binary(TYPEMAP, SIZE)
|
||||
*
|
||||
* Macro makes a function accept binary string data along with
|
||||
* a size.
|
||||
*/
|
||||
|
||||
%define %cstring_input_binary(TYPEMAP, SIZE)
|
||||
%apply (char *STRING, int LENGTH) { (TYPEMAP, SIZE) };
|
||||
%enddef
|
||||
|
||||
/*
|
||||
* %cstring_bounded_output(TYPEMAP, MAX)
|
||||
*
|
||||
* This macro is used to return a NULL-terminated output string of
|
||||
* some maximum length. For example:
|
||||
*
|
||||
* %cstring_bounded_output(char *outx, 512);
|
||||
* void foo(char *outx) {
|
||||
* %cstring_bounded_output(Char *outx, 512);
|
||||
* void foo(Char *outx) {
|
||||
* sprintf(outx,"blah blah\n");
|
||||
* }
|
||||
*
|
||||
*/
|
||||
|
||||
%define %cstring_bounded_output(TYPEMAP,MAX)
|
||||
%typemap(ignore) TYPEMAP(char temp[MAX+1]) {
|
||||
$1 = ($1_ltype) temp;
|
||||
}
|
||||
%typemap(argout,fragment="t_output_helper") TYPEMAP {
|
||||
Tcl_Obj *o;
|
||||
$1[MAX] = 0;
|
||||
o = Tcl_NewStringObj($1,-1);
|
||||
Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp), o);
|
||||
}
|
||||
%enddef
|
||||
|
||||
/*
|
||||
* %cstring_chunk_output(TYPEMAP, SIZE)
|
||||
*
|
||||
* This macro is used to return a chunk of binary string data.
|
||||
* Embedded NULLs are okay. For example:
|
||||
*
|
||||
* %cstring_chunk_output(char *outx, 512);
|
||||
* void foo(char *outx) {
|
||||
* %cstring_chunk_output(Char *outx, 512);
|
||||
* void foo(Char *outx) {
|
||||
* memmove(outx, somedata, 512);
|
||||
* }
|
||||
*
|
||||
*/
|
||||
|
||||
%define %cstring_chunk_output(TYPEMAP,SIZE)
|
||||
%typemap(ignore) TYPEMAP(char temp[SIZE]) {
|
||||
$1 = ($1_ltype) temp;
|
||||
}
|
||||
%typemap(argout,fragment="t_output_helper") TYPEMAP {
|
||||
Tcl_Obj *o = Tcl_NewStringObj($1,SIZE);
|
||||
Tcl_ListObjAppendElement(interp, Tcl_GetObjResult(interp),o);
|
||||
}
|
||||
%enddef
|
||||
|
||||
/*
|
||||
* %cstring_bounded_mutable(TYPEMAP, SIZE)
|
||||
*
|
||||
* This macro is used to wrap a string that's going to mutate.
|
||||
*
|
||||
* %cstring_bounded_mutable(char *in, 512);
|
||||
* %cstring_bounded_mutable(Char *in, 512);
|
||||
* void foo(in *x) {
|
||||
* while (*x) {
|
||||
* *x = toupper(*x);
|
||||
|
|
@ -83,28 +58,13 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
%define %cstring_bounded_mutable(TYPEMAP,MAX)
|
||||
%typemap(in) TYPEMAP(char temp[MAX+1]) {
|
||||
char *t = Tcl_GetStringFromObj($input,NULL);
|
||||
strncpy(temp,t,MAX);
|
||||
$1 = ($1_ltype) temp;
|
||||
}
|
||||
%typemap(argout,fragment="t_output_helper") TYPEMAP {
|
||||
Tcl_Obj *o;
|
||||
$1[MAX] = 0;
|
||||
o = Tcl_NewStringObj($1,-1);
|
||||
Tcl_ListObjAppendElement(interp, Tcl_GetObjResult(interp),o);
|
||||
}
|
||||
%enddef
|
||||
|
||||
/*
|
||||
* %cstring_mutable(TYPEMAP [, expansion])
|
||||
*
|
||||
* This macro is used to wrap a string that will mutate in place.
|
||||
* It may change size up to a user-defined expansion.
|
||||
*
|
||||
* %cstring_mutable(char *in);
|
||||
* %cstring_mutable(Char *in);
|
||||
* void foo(in *x) {
|
||||
* while (*x) {
|
||||
* *x = toupper(*x);
|
||||
|
|
@ -114,177 +74,64 @@
|
|||
*
|
||||
*/
|
||||
|
||||
%define %cstring_mutable(TYPEMAP,...)
|
||||
%typemap(in) TYPEMAP {
|
||||
int n;
|
||||
char *t = Tcl_GetStringFromObj($input,&n);
|
||||
$1 = ($1_ltype) t;
|
||||
|
||||
#if #__VA_ARGS__ == ""
|
||||
#ifdef __cplusplus
|
||||
$1 = ($1_ltype) new char[n+1];
|
||||
#else
|
||||
$1 = ($1_ltype) malloc(n+1);
|
||||
#endif
|
||||
#else
|
||||
#ifdef __cplusplus
|
||||
$1 = ($1_ltype) new char[n+1+__VA_ARGS__];
|
||||
#else
|
||||
$1 = ($1_ltype) malloc(n+1+__VA_ARGS__);
|
||||
#endif
|
||||
#endif
|
||||
memmove($1,t,n);
|
||||
$1[n] = 0;
|
||||
}
|
||||
|
||||
%typemap(argout,fragment="t_output_helper") TYPEMAP {
|
||||
Tcl_Obj *o;
|
||||
o = Tcl_NewStringObj($1,-1);
|
||||
Tcl_ListObjAppendElement(interp, Tcl_GetObjResult(interp), o);
|
||||
#ifdef __cplusplus
|
||||
delete[] $1;
|
||||
#else
|
||||
free($1);
|
||||
#endif
|
||||
}
|
||||
%enddef
|
||||
|
||||
/*
|
||||
* %cstring_output_maxsize(TYPEMAP, SIZE)
|
||||
*
|
||||
* This macro returns data in a string of some user-defined size.
|
||||
*
|
||||
* %cstring_output_maxsize(char *outx, int max) {
|
||||
* void foo(char *outx, int max) {
|
||||
* %cstring_output_maxsize(Char *outx, int max) {
|
||||
* void foo(Char *outx, int max) {
|
||||
* sprintf(outx,"blah blah\n");
|
||||
* }
|
||||
*/
|
||||
|
||||
%define %cstring_output_maxsize(TYPEMAP, SIZE)
|
||||
%typemap(in) (TYPEMAP, SIZE) {
|
||||
long temp;
|
||||
if (Tcl_GetLongFromObj(interp,$input,&temp) != TCL_OK) {
|
||||
SWIG_fail;
|
||||
}
|
||||
$2 = ($2_ltype) temp;
|
||||
#ifdef __cplusplus
|
||||
$1 = ($1_ltype) new char[$2+1];
|
||||
#else
|
||||
$1 = ($1_ltype) malloc($2+1);
|
||||
#endif
|
||||
}
|
||||
%typemap(argout,fragment="t_output_helper") (TYPEMAP,SIZE) {
|
||||
Tcl_Obj *o;
|
||||
o = Tcl_NewStringObj($1,-1);
|
||||
Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),o);
|
||||
#ifdef __cplusplus
|
||||
delete [] $1;
|
||||
#else
|
||||
free($1);
|
||||
#endif
|
||||
}
|
||||
%enddef
|
||||
|
||||
/*
|
||||
* %cstring_output_withsize(TYPEMAP, SIZE)
|
||||
*
|
||||
* This macro is used to return character data along with a size
|
||||
* This macro is used to return Character data along with a size
|
||||
* parameter.
|
||||
*
|
||||
* %cstring_output_maxsize(char *outx, int *max) {
|
||||
* void foo(char *outx, int *max) {
|
||||
* %cstring_output_maxsize(Char *outx, int *max) {
|
||||
* void foo(Char *outx, int *max) {
|
||||
* sprintf(outx,"blah blah\n");
|
||||
* *max = strlen(outx);
|
||||
* }
|
||||
*/
|
||||
|
||||
%define %cstring_output_withsize(TYPEMAP, SIZE)
|
||||
%typemap(in) (TYPEMAP, SIZE) {
|
||||
long n;
|
||||
if (Tcl_GetLongFromObj(interp,$input,&n) != TCL_OK) {
|
||||
SWIG_fail;
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
$1 = ($1_ltype) new char[n+1];
|
||||
$2 = ($2_ltype) new $*1_ltype;
|
||||
#else
|
||||
$1 = ($1_ltype) malloc(n+1);
|
||||
$2 = ($2_ltype) malloc(sizeof($*1_ltype));
|
||||
#endif
|
||||
*$2 = n;
|
||||
}
|
||||
%typemap(argout,fragment="t_output_helper") (TYPEMAP,SIZE) {
|
||||
Tcl_Obj *o;
|
||||
o = Tcl_NewStringObj($1,*$2);
|
||||
Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp), o);
|
||||
#ifdef __cplusplus
|
||||
delete [] $1;
|
||||
delete $2;
|
||||
#else
|
||||
free($1);
|
||||
free($2);
|
||||
#endif
|
||||
}
|
||||
%enddef
|
||||
|
||||
|
||||
/*
|
||||
* %cstring_output_allocate(TYPEMAP, RELEASE)
|
||||
*
|
||||
* This macro is used to return character data that was
|
||||
* This macro is used to return Character data that was
|
||||
* allocated with new or malloc.
|
||||
*
|
||||
* %cstring_output_allocated(char **outx, free($1));
|
||||
* void foo(char **outx) {
|
||||
* *outx = (char *) malloc(512);
|
||||
* %cstring_output_allocated(Char **outx, free($1));
|
||||
* void foo(Char **outx) {
|
||||
* *outx = (Char *) malloc(512);
|
||||
* sprintf(outx,"blah blah\n");
|
||||
* }
|
||||
*/
|
||||
|
||||
%define %cstring_output_allocate(TYPEMAP, RELEASE)
|
||||
%typemap(ignore) TYPEMAP($*1_ltype temp = 0) {
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(argout,fragment="t_output_helper") TYPEMAP {
|
||||
if (*$1) {
|
||||
Tcl_Obj *o = Tcl_NewStringObj(*$1,-1);
|
||||
RELEASE;
|
||||
Tcl_ListObjAppendElement(interp, Tcl_GetObjResult(interp), o);
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
/*
|
||||
* %cstring_output_allocate_size(TYPEMAP, SIZE, RELEASE)
|
||||
*
|
||||
* This macro is used to return character data that was
|
||||
* This macro is used to return Character data that was
|
||||
* allocated with new or malloc.
|
||||
*
|
||||
* %cstring_output_allocated(char **outx, int *sz, free($1));
|
||||
* void foo(char **outx, int *sz) {
|
||||
* *outx = (char *) malloc(512);
|
||||
* %cstring_output_allocated(Char **outx, int *sz, free($1));
|
||||
* void foo(Char **outx, int *sz) {
|
||||
* *outx = (Char *) malloc(512);
|
||||
* sprintf(outx,"blah blah\n");
|
||||
* *sz = strlen(outx);
|
||||
* }
|
||||
*/
|
||||
|
||||
%define %cstring_output_allocate_size(TYPEMAP, SIZE, RELEASE)
|
||||
%typemap(ignore) (TYPEMAP, SIZE) ($*1_ltype temp = 0, $*2_ltype tempn) {
|
||||
$1 = &temp;
|
||||
$2 = &tempn;
|
||||
}
|
||||
|
||||
%typemap(argout,fragment="t_output_helper")(TYPEMAP,SIZE) {
|
||||
if (*$1) {
|
||||
Tcl_Obj *o = Tcl_NewStringObj(*$1,*$2);
|
||||
RELEASE;
|
||||
Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp), o);
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
|
||||
|
||||
|
||||
%include <typemaps/cstring.swg>
|
||||
%include <tclstrings.swg>
|
||||
|
||||
%typemap_cstrings(%cstring,
|
||||
char,
|
||||
SWIG_AsCharPtr,
|
||||
SWIG_AsCharPtrAndSize,
|
||||
SWIG_FromCharPtr,
|
||||
SWIG_FromCharPtrAndSize);
|
||||
|
||||
|
|
|
|||
137
Lib/tcl/cwstring.i
Normal file
137
Lib/tcl/cwstring.i
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* cstring.i
|
||||
* $Header$
|
||||
*
|
||||
|
||||
* This file provides typemaps and macros for dealing with various forms
|
||||
* of C character string handling. The primary use of this module
|
||||
* is in returning character data that has been allocated or changed in
|
||||
* some way.
|
||||
*/
|
||||
|
||||
/*
|
||||
* %cwstring_input_binary(TYPEMAP, SIZE)
|
||||
*
|
||||
* Macro makes a function accept binary string data along with
|
||||
* a size.
|
||||
*/
|
||||
|
||||
/*
|
||||
* %cwstring_bounded_output(TYPEMAP, MAX)
|
||||
*
|
||||
* This macro is used to return a NULL-terminated output string of
|
||||
* some maximum length. For example:
|
||||
*
|
||||
* %cwstring_bounded_output(wchar_t *outx, 512);
|
||||
* void foo(wchar_t *outx) {
|
||||
* sprintf(outx,"blah blah\n");
|
||||
* }
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* %cwstring_chunk_output(TYPEMAP, SIZE)
|
||||
*
|
||||
* This macro is used to return a chunk of binary string data.
|
||||
* Embedded NULLs are okay. For example:
|
||||
*
|
||||
* %cwstring_chunk_output(wchar_t *outx, 512);
|
||||
* void foo(wchar_t *outx) {
|
||||
* memmove(outx, somedata, 512);
|
||||
* }
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* %cwstring_bounded_mutable(TYPEMAP, SIZE)
|
||||
*
|
||||
* This macro is used to wrap a string that's going to mutate.
|
||||
*
|
||||
* %cwstring_bounded_mutable(wchar_t *in, 512);
|
||||
* void foo(in *x) {
|
||||
* while (*x) {
|
||||
* *x = toupper(*x);
|
||||
* x++;
|
||||
* }
|
||||
* }
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* %cwstring_mutable(TYPEMAP [, expansion])
|
||||
*
|
||||
* This macro is used to wrap a string that will mutate in place.
|
||||
* It may change size up to a user-defined expansion.
|
||||
*
|
||||
* %cwstring_mutable(wchar_t *in);
|
||||
* void foo(in *x) {
|
||||
* while (*x) {
|
||||
* *x = toupper(*x);
|
||||
* x++;
|
||||
* }
|
||||
* }
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* %cwstring_output_maxsize(TYPEMAP, SIZE)
|
||||
*
|
||||
* This macro returns data in a string of some user-defined size.
|
||||
*
|
||||
* %cwstring_output_maxsize(wchar_t *outx, int max) {
|
||||
* void foo(wchar_t *outx, int max) {
|
||||
* sprintf(outx,"blah blah\n");
|
||||
* }
|
||||
*/
|
||||
|
||||
/*
|
||||
* %cwstring_output_withsize(TYPEMAP, SIZE)
|
||||
*
|
||||
* This macro is used to return wchar_tacter data along with a size
|
||||
* parameter.
|
||||
*
|
||||
* %cwstring_output_maxsize(wchar_t *outx, int *max) {
|
||||
* void foo(wchar_t *outx, int *max) {
|
||||
* sprintf(outx,"blah blah\n");
|
||||
* *max = strlen(outx);
|
||||
* }
|
||||
*/
|
||||
|
||||
/*
|
||||
* %cwstring_output_allocate(TYPEMAP, RELEASE)
|
||||
*
|
||||
* This macro is used to return wchar_tacter data that was
|
||||
* allocated with new or malloc.
|
||||
*
|
||||
* %cwstring_output_allocated(wchar_t **outx, free($1));
|
||||
* void foo(wchar_t **outx) {
|
||||
* *outx = (wchar_t *) malloc(512);
|
||||
* sprintf(outx,"blah blah\n");
|
||||
* }
|
||||
*/
|
||||
|
||||
/*
|
||||
* %cwstring_output_allocate_size(TYPEMAP, SIZE, RELEASE)
|
||||
*
|
||||
* This macro is used to return wchar_tacter data that was
|
||||
* allocated with new or malloc.
|
||||
*
|
||||
* %cwstring_output_allocated(wchar_t **outx, int *sz, free($1));
|
||||
* void foo(wchar_t **outx, int *sz) {
|
||||
* *outx = (wchar_t *) malloc(512);
|
||||
* sprintf(outx,"blah blah\n");
|
||||
* *sz = strlen(outx);
|
||||
* }
|
||||
*/
|
||||
|
||||
|
||||
%include <typemaps/cstring.swg>
|
||||
%include <pywstrings.swg>
|
||||
|
||||
%typemap_cstrings(%cwstring,
|
||||
wchar_t,
|
||||
SWIG_AsWCharPtr,
|
||||
SWIG_AsWCharPtrAndSize,
|
||||
SWIG_FromWCharPtr,
|
||||
SWIG_FromWCharArray);
|
||||
|
||||
|
|
@ -1,56 +1,37 @@
|
|||
//
|
||||
// SWIG typemaps for std::string
|
||||
// Luigi Ballabio and Manu ???
|
||||
// Apr 26, 2002
|
||||
// std::string
|
||||
//
|
||||
// Tcl implementation
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// std::string is typemapped by value
|
||||
// This can prevent exporting methods which return a string
|
||||
// in order for the user to modify it.
|
||||
// However, I think I'll wait until someone asks for it...
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
%include exception.i
|
||||
#ifndef SWIG_STD_BASIC_STRING
|
||||
#define SWIG_STD_STRING
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
|
||||
class string;
|
||||
|
||||
/* Overloading check */
|
||||
%typemap(typecheck) string = char *;
|
||||
%typemap(typecheck) const string & = char *;
|
||||
|
||||
%typemap(in) string {
|
||||
$1 = std::string(Tcl_GetStringFromObj($input,NULL));
|
||||
}
|
||||
|
||||
%typemap(in) const string & (std::string temp) {
|
||||
temp = std::string(Tcl_GetStringFromObj($input,NULL));
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(out) string {
|
||||
Tcl_SetStringObj($result,(char*)$1.c_str(),$1.length());
|
||||
}
|
||||
|
||||
%typemap(out) const string & {
|
||||
Tcl_SetStringObj($result,(char*)$1->c_str(),$1->length());
|
||||
}
|
||||
|
||||
%typemap(throws) string {
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj((char*) $1.c_str(), -1));
|
||||
SWIG_fail;
|
||||
}
|
||||
|
||||
%typemap(throws) const string & {
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj((char*) $1.c_str(), -1));
|
||||
SWIG_fail;
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
class string;
|
||||
}
|
||||
|
||||
%include <typemaps/std_string.swg>
|
||||
%include <tclstrings.swg>
|
||||
|
||||
%fragment("Tcl_std_string_asptr","header",fragment="SWIG_AsCharPtrAndSize") {
|
||||
%tcl_asptr_decl(std::string)
|
||||
}
|
||||
%fragment("Tcl_std_string_asval","header",fragment="Tcl_std_string_asptr") {
|
||||
%tcl_asptr_decl(std::string)
|
||||
}
|
||||
|
||||
%std_string_asptr_frag(std::string, char, SWIG_AsCharPtrAndSize, "Tcl_std_string_asptr")
|
||||
%std_string_asval_frag(std::string, "Tcl_std_string_asval")
|
||||
%std_string_from(std::string, SWIG_FromCharPtrAndSize)
|
||||
|
||||
%typemap_asptrfromn(SWIG_CCode(STRING), std::string);
|
||||
|
||||
#else
|
||||
|
||||
%include <std/std_string.i>
|
||||
|
||||
#endif
|
||||
|
|
|
|||
37
Lib/tcl/std_wstring.i
Normal file
37
Lib/tcl/std_wstring.i
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
//
|
||||
// std::wstring
|
||||
//
|
||||
|
||||
#ifndef SWIG_STD_BASIC_STRING
|
||||
#define SWIG_STD_WSTRING
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
%}
|
||||
|
||||
namespace std
|
||||
{
|
||||
class wstring;
|
||||
}
|
||||
|
||||
%include <typemaps/std_string.i>
|
||||
%include <tclwstrings.swg>
|
||||
|
||||
%fragment("Tcl_std_wstring_asptr","header",fragment="SWIG_AsCharPtrAndSize") {
|
||||
%tcl_asptr_decl(std::wstring)
|
||||
}
|
||||
%fragment("Tcl_std_wstring_asval","header",fragment="Tcl_std_wstring_asptr") {
|
||||
%tcl_asptr_decl(std::wstring)
|
||||
}
|
||||
|
||||
%std_string_asptr_frag(std::wstring, wchar_t, SWIG_AsCharPtrAndSize, "Tcl_std_wstring_asptr")
|
||||
%std_string_asval_frag(std::wstring, "Tcl_std_wstring_asval")
|
||||
%std_string_from(std::wstring, SWIG_FromCharPtrAndSize)
|
||||
|
||||
%typemap_asptrfromn(SWIG_CCode(UNISTRING), std::wstring);
|
||||
|
||||
#else
|
||||
|
||||
%include <std/std_string.i>
|
||||
|
||||
#endif
|
||||
743
Lib/tcl/tcl8.swg
743
Lib/tcl/tcl8.swg
|
|
@ -1,730 +1,53 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* tcl8.swg
|
||||
* tcl.swg
|
||||
*
|
||||
* Tcl8 configuration module.
|
||||
* Tcl configuration module.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%runtime "swigrun.swg" // Common C API type-checking code
|
||||
%runtime "swigtcl8.swg"
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* --- standard typemaps ---
|
||||
* The runtime part
|
||||
* ----------------------------------------------------------------------------- */
|
||||
%include <tclruntime.swg>
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Special user directives
|
||||
* ----------------------------------------------------------------------------- */
|
||||
%include <tcluserdir.swg>
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Inner macros
|
||||
* ----------------------------------------------------------------------------- */
|
||||
%include <tclmacros.swg>
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Error manipulation
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* Input arguments */
|
||||
|
||||
/* For primitive types, the Tcl module uses a special function
|
||||
|
||||
SWIG_GetArgs(Tcl_Interp *, int objc, Tcl_Obj *CONST objv[], const char *fmt, ...)
|
||||
|
||||
The fmt field contains special conversion characters i,h,l,b,f,d,c,p, and o
|
||||
that are used to marshal different types. The parse codes below correspond
|
||||
to these special codes */
|
||||
|
||||
%typemap(in,parse="i") int "";
|
||||
%typemap(in,parse="h") short, unsigned short "";
|
||||
%typemap(in,parse="l") long "";
|
||||
%typemap(in,parse="b") signed char, unsigned char "";
|
||||
%typemap(in,parse="f") float "";
|
||||
%typemap(in,parse="d") double "";
|
||||
%typemap(in,parse="c") char "";
|
||||
%typemap(in,parse="s") char *, char [ANY] "";
|
||||
|
||||
/* Pointers */
|
||||
%typemap(in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE []
|
||||
"if ((SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor,SWIG_POINTER_EXCEPTION | $disown) != TCL_OK)) SWIG_fail;";
|
||||
|
||||
%typemap(in) void *
|
||||
"if ((SWIG_ConvertPtr($input, (void **) &$1, 0,SWIG_POINTER_EXCEPTION | $disown) != TCL_OK)) SWIG_fail;";
|
||||
|
||||
/* For bools, we first convert to an integer and then to a bool. There
|
||||
is no guarantee that a bool is the same size as an int so we have to do this */
|
||||
|
||||
%typemap(in) bool (int tempb) "if (Tcl_GetIntFromObj(interp,$input,&tempb) == TCL_ERROR) SWIG_fail;
|
||||
$1 = tempb ? true : false;";
|
||||
|
||||
%typemap(in) unsigned int "$1 = ($1_ltype) strtoul(Tcl_GetStringFromObj($input,NULL), 0, 0);";
|
||||
%typemap(in) unsigned long "$1 = ($1_ltype) strtoul(Tcl_GetStringFromObj($input,NULL), 0, 0);";
|
||||
|
||||
/* These will pass an integer as an unsigned long. However, the implementation is crippled due
|
||||
to limited precision in Tcl */
|
||||
|
||||
%typemap(in) long long "$1 = ($1_ltype) strtoll(Tcl_GetStringFromObj($input,NULL),0,0);";
|
||||
%typemap(in) unsigned long long "$1 = ($1_ltype) strtoull(Tcl_GetStringFromObj($input,NULL), 0, 0);";
|
||||
|
||||
/* Enum parsing. Note: internally SWIG converts enums to/from integers so it's okay to use
|
||||
the "i" parse code here */
|
||||
|
||||
%typemap(in,parse="i") enum SWIGTYPE "";
|
||||
|
||||
/* Unknown type. We convert from a pointer */
|
||||
%typemap(in) SWIGTYPE ($&1_ltype argp)
|
||||
"if ((SWIG_ConvertPtr($input, (void **) &argp, $&1_descriptor,SWIG_POINTER_EXCEPTION ) != TCL_OK)) SWIG_fail;
|
||||
$1 = *argp; ";
|
||||
|
||||
/* Member pointer */
|
||||
%typemap(in) SWIGTYPE (CLASS::*) "if ((SWIG_ConvertPacked($input, (void *) &$1, sizeof($1_type), $1_descriptor, SWIG_POINTER_EXCEPTION)) != TCL_OK) SWIG_fail;";
|
||||
|
||||
/* Special constant variations. These typemaps can be used to parse objects that are both constants
|
||||
or values. A Hash table lookup will occur. */
|
||||
|
||||
%typemap(in,parse="I") int CONSTANT, unsigned int CONSTANT "";
|
||||
%typemap(in,parse="H") short CONSTANT, unsigned short CONSTANT "";
|
||||
%typemap(in,parse="L") long CONSTANT, unsigned long CONSTANT "";
|
||||
%typemap(in,parse="B") signed char CONSTANT, unsigned char CONSTANT "";
|
||||
%typemap(in,parse="F") float CONSTANT "";
|
||||
%typemap(in,parse="D") double CONSTANT "";
|
||||
%typemap(in,parse="C") char CONSTANT "";
|
||||
%typemap(in,parse="S") char * CONSTANT "";
|
||||
%typemap(in,parse="P") SWIGTYPE *CONSTANT, SWIGTYPE &CONSTANT, SWIGTYPE CONSTANT [] "";
|
||||
%typemap(in,parse="I") enum SWIGTYPE CONSTANT "";
|
||||
|
||||
/* Constant references. Passed by value */
|
||||
/* Const primitive references. Passed by value */
|
||||
|
||||
%typemap(in) const int & ($*1_ltype temp),
|
||||
const short & ($*1_ltype temp),
|
||||
const long & ($*1_ltype temp),
|
||||
const unsigned short & ($*1_ltype temp),
|
||||
const signed char & ($*1_ltype temp),
|
||||
const unsigned char & ($*1_ltype temp),
|
||||
const enum SWIGTYPE & ($*1_ltype temp)
|
||||
{
|
||||
long ltemp;
|
||||
if (Tcl_GetLongFromObj(interp, $input, <emp) != TCL_OK) {
|
||||
SWIG_fail;
|
||||
}
|
||||
temp = ($*1_ltype) ltemp;
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(in) const unsigned int & ($*1_ltype temp)
|
||||
"temp = ($*1_ltype) strtoul(Tcl_GetStringFromObj($input,NULL),0,0);
|
||||
$1 = &temp;";
|
||||
|
||||
%typemap(in) const unsigned long & ($*1_ltype temp)
|
||||
"temp = ($*1_ltype) strtoul(Tcl_GetStringFromObj($input,NULL),0,0);
|
||||
$1 = &temp;";
|
||||
|
||||
%typemap(in) const bool & (bool temp)
|
||||
{
|
||||
long ltemp;
|
||||
if (Tcl_GetLongFromObj(interp, $input, <emp) != TCL_OK) {
|
||||
SWIG_fail;
|
||||
}
|
||||
temp = ltemp ? true : false;
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
|
||||
%typemap(in) const float & (float temp),
|
||||
const double & (double temp)
|
||||
{
|
||||
double dtemp;
|
||||
if (Tcl_GetDoubleFromObj(interp, $input, &dtemp) != TCL_OK) {
|
||||
SWIG_fail;
|
||||
}
|
||||
temp = ($*1_ltype) dtemp;
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(in) const long long & ($*1_ltype temp)
|
||||
"temp = ($*1_ltype) strtoll(Tcl_GetStringFromObj($input,NULL),0,0);
|
||||
$1 = &temp;";
|
||||
|
||||
%typemap(in) const unsigned long long & ($*1_ltype temp)
|
||||
"temp = ($*1_ltype) strtoull(Tcl_GetStringFromObj($input,NULL),0,0);
|
||||
$1 = &temp;";
|
||||
|
||||
%typemap(in) const char &(char temp) {
|
||||
char *stemp = Tcl_GetStringFromObj($input,NULL);
|
||||
temp = *stemp;
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
/* Output values */
|
||||
|
||||
%typemap(out) bool, int, short, unsigned short, signed char, unsigned char, enum SWIGTYPE
|
||||
"Tcl_SetObjResult(interp,Tcl_NewIntObj((long) $1));";
|
||||
|
||||
%typemap(out) long
|
||||
"Tcl_SetObjResult(interp,Tcl_NewLongObj((long) $1));";
|
||||
|
||||
%typemap(out) unsigned int, unsigned long {
|
||||
char temp[256];
|
||||
sprintf(temp,"%lu", (unsigned long) $1);
|
||||
Tcl_SetObjResult(interp,Tcl_NewStringObj(temp,-1));
|
||||
}
|
||||
|
||||
|
||||
%typemap(out) long long {
|
||||
char temp[256];
|
||||
sprintf(temp,"%lld", (long long) $1);
|
||||
Tcl_SetObjResult(interp,Tcl_NewStringObj(temp,-1));
|
||||
}
|
||||
|
||||
%typemap(out) unsigned long long {
|
||||
char temp[256];
|
||||
sprintf(temp,"%llu", (unsigned long long) $1);
|
||||
Tcl_SetObjResult(interp,Tcl_NewStringObj(temp,-1));
|
||||
}
|
||||
|
||||
%typemap(out) char
|
||||
"Tcl_SetObjResult(interp,Tcl_NewStringObj(&$1,1));";
|
||||
|
||||
%typemap(out) float, double
|
||||
"Tcl_SetObjResult(interp,Tcl_NewDoubleObj((double) $1));";
|
||||
|
||||
%typemap(out) char *
|
||||
"Tcl_SetObjResult(interp,Tcl_NewStringObj($1,-1));";
|
||||
|
||||
%typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE []
|
||||
"Tcl_SetObjResult(interp,SWIG_NewPointerObj((void *) $1, $1_descriptor, $owner));";
|
||||
|
||||
%typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC {
|
||||
swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor,(void **) &$1);
|
||||
Tcl_SetObjResult(interp,SWIG_NewPointerObj((void *) $1, ty, $owner));
|
||||
}
|
||||
|
||||
%typemap(out) SWIGTYPE *INSTANCE, SWIGTYPE &INSTANCE, SWIGTYPE INSTANCE[]
|
||||
"Tcl_SetObjResult(interp,SWIG_NewInstanceObj((void *) $1, $1_descriptor, $owner));";
|
||||
|
||||
%typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE []
|
||||
"Tcl_SetObjResult(interp,SWIG_NewInstanceObj((void *) $1, $1_descriptor, $owner));";
|
||||
|
||||
%typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC {
|
||||
swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor,(void **) &$1);
|
||||
Tcl_SetObjResult(interp,SWIG_NewInstanceObj((void *) $1, ty, $owner));
|
||||
}
|
||||
|
||||
%typemap(out) SWIGTYPE (CLASS::*)
|
||||
"Tcl_SetObjResult(interp, SWIG_NewPackedObj((void *) &$1, sizeof($1_type), $1_descriptor, $owner));";
|
||||
|
||||
%typemap(out) void "";
|
||||
|
||||
/* Primitive types--return by value */
|
||||
%typemap(out) SWIGTYPE NOINSTANCE
|
||||
#ifdef __cplusplus
|
||||
{
|
||||
$&1_ltype resultptr;
|
||||
resultptr = new $1_ltype(($1_ltype &) $1);
|
||||
Tcl_SetObjResult(interp,SWIG_NewPointerObj((void*) resultptr, $&1_descriptor, $owner));
|
||||
}
|
||||
#else
|
||||
{
|
||||
$&1_ltype resultptr;
|
||||
resultptr = ($&1_ltype) malloc(sizeof($1_type));
|
||||
memmove(resultptr, &$1, sizeof($1_type));
|
||||
Tcl_SetObjResult(interp,SWIG_NewPointerObj((void*) resultptr, $&1_descriptor, $owner));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Primitive types--return by value */
|
||||
%typemap(out) SWIGTYPE INSTANCE
|
||||
#ifdef __cplusplus
|
||||
{
|
||||
$&1_ltype resultptr;
|
||||
resultptr = new $1_ltype(($1_ltype &) $1);
|
||||
Tcl_SetObjResult(interp,SWIG_NewInstanceObj((void*) resultptr, $&1_descriptor,1));
|
||||
}
|
||||
#else
|
||||
{
|
||||
$&1_ltype resultptr;
|
||||
resultptr = ($&1_ltype) malloc(sizeof($1_type));
|
||||
memmove(resultptr, &$1, sizeof($1_type));
|
||||
Tcl_SetObjResult(interp,SWIG_NewInstanceObj((void*) resultptr, $&1_descriptor,1));
|
||||
}
|
||||
#endif
|
||||
|
||||
%typemap(out) SWIGTYPE = SWIGTYPE INSTANCE;
|
||||
|
||||
/* Special typemap for character array returns */
|
||||
%typemap(out) char [ANY] "Tcl_SetObjResult(interp,Tcl_NewStringObj($1,-1));"
|
||||
|
||||
|
||||
/* Primitive references */
|
||||
|
||||
%typemap(out) const int &,
|
||||
const short &, const unsigned short &,
|
||||
const signed char &, const unsigned char &,
|
||||
const bool &,
|
||||
const enum SWIGTYPE &
|
||||
"Tcl_SetObjResult(interp,Tcl_NewIntObj((long) *($1)));";
|
||||
|
||||
%typemap(out) const long &
|
||||
"Tcl_SetObjResult(interp,Tcl_NewLongObj((long) *($1)));";
|
||||
|
||||
%typemap(out) const unsigned int &, const unsigned long &
|
||||
{
|
||||
char temp[256];
|
||||
sprintf(temp,"%lu", (unsigned long)*($1));
|
||||
Tcl_SetObjResult(interp,Tcl_NewStringObj(temp,-1));
|
||||
}
|
||||
|
||||
|
||||
%typemap(out) const float &, const double &
|
||||
"Tcl_SetObjResult(interp,Tcl_NewDoubleObj((double) *($1)));";
|
||||
|
||||
%typemap(out) const long long & {
|
||||
char temp[256];
|
||||
sprintf(temp,"%lld", (long long)*($1));
|
||||
Tcl_SetObjResult(interp,Tcl_NewStringObj(temp,-1));
|
||||
}
|
||||
|
||||
%typemap(out) const unsigned long long &
|
||||
{
|
||||
char temp[256];
|
||||
sprintf(temp,"%llu", (unsigned long long)*($1));
|
||||
Tcl_SetObjResult(interp,Tcl_NewStringObj(temp,-1));
|
||||
}
|
||||
|
||||
%typemap(out) const char &
|
||||
"Tcl_SetObjResult(interp,Tcl_NewStringObj($1,1));";
|
||||
|
||||
|
||||
/* --- Variable output --- */
|
||||
|
||||
%typemap(varout) int, short, unsigned short, signed char, unsigned char, bool, enum SWIGTYPE
|
||||
"$result = Tcl_NewIntObj((long) $1);";
|
||||
|
||||
%typemap(varout) long
|
||||
"$result = Tcl_NewLongObj((long) $1);";
|
||||
|
||||
%typemap(varout) unsigned int, unsigned long {
|
||||
char temp[256];
|
||||
sprintf(temp,"%lu", (unsigned long)$1);
|
||||
$result = Tcl_NewStringObj(temp,-1);
|
||||
}
|
||||
|
||||
%typemap(varout) long long {
|
||||
char temp[256];
|
||||
sprintf(temp,"%lld", (long long)$1);
|
||||
$result = Tcl_NewStringObj(temp,-1);
|
||||
}
|
||||
|
||||
%typemap(varout) unsigned long long {
|
||||
char temp[256];
|
||||
sprintf(temp,"%llu", (unsigned long long)$1);
|
||||
$result = Tcl_NewStringObj(temp,-1);
|
||||
}
|
||||
|
||||
%typemap(varout) double,float "$result = Tcl_NewDoubleObj((double) $1);";
|
||||
%typemap(varout) char * "$result = Tcl_NewStringObj((char*) $1,-1);";
|
||||
%typemap(varout) char [ANY] "$result = Tcl_NewStringObj((char *) $1,-1);";
|
||||
%typemap(varout) char "$result = Tcl_NewStringObj(&$1,1);";
|
||||
%typemap(varout) SWIGTYPE *, SWIGTYPE [] "$result = SWIG_NewPointerObj((void *) $1, $1_descriptor, 0);";
|
||||
%typemap(varout) SWIGTYPE & "$result = SWIG_NewPointerObj((void *) &$1, $1_descriptor, 0);";
|
||||
|
||||
%typemap(varout) SWIGTYPE *INSTANCE, SWIGTYPE INSTANCE[]
|
||||
"$result = SWIG_NewInstanceObj((void *) $1, $1_descriptor, 0);";
|
||||
|
||||
%typemap(varout) SWIGTYPE &INSTANCE
|
||||
"$result = SWIG_NewInstanceObj((void *) &$1, $1_descriptor, 0);";
|
||||
|
||||
%typemap(varout) SWIGTYPE INSTANCE "$result = SWIG_NewInstanceObj((void *) &$1, $&1_descriptor, 0);";
|
||||
%typemap(varout) SWIGTYPE "$result = SWIG_NewInstanceObj((void *) &$1, $&1_descriptor, 0);";
|
||||
%typemap(varout) SWIGTYPE (CLASS::*) "$result = SWIG_NewPackedObj((void *) &$1, sizeof($1_type), $1_descriptor, 0);";
|
||||
|
||||
/* -- Variable input --- */
|
||||
|
||||
%typemap(varin) int, short, unsigned short, long, signed char, unsigned char
|
||||
{
|
||||
long temp;
|
||||
if (Tcl_GetLongFromObj(interp, $input, &temp) != TCL_OK) {
|
||||
return (char*) "Type error. expected an integer";
|
||||
}
|
||||
$1 = ($1_type) temp;
|
||||
}
|
||||
|
||||
%typemap(varin) unsigned int, unsigned long "$1 = ($1_ltype) strtoul(Tcl_GetStringFromObj($input,NULL),0,0);";
|
||||
|
||||
%typemap(varin) enum SWIGTYPE
|
||||
{
|
||||
int temp;
|
||||
if (Tcl_GetIntFromObj(interp, $input, &temp) != TCL_OK) {
|
||||
return (char*) "Type error. expected an integer";
|
||||
}
|
||||
if (sizeof(int) != sizeof($1)) {
|
||||
return (char*) "enum variable '$name' can not be set.";
|
||||
}
|
||||
*(int *)(void *)&($1) = temp;
|
||||
}
|
||||
|
||||
%typemap(varin) bool
|
||||
{
|
||||
long temp;
|
||||
if (Tcl_GetLongFromObj(interp, $input, &temp) != TCL_OK) {
|
||||
return (char*) "Type error. expected an integer";
|
||||
}
|
||||
$1 = temp ? true : false;
|
||||
}
|
||||
|
||||
%typemap(varin) long long "$1 = ($1_ltype) strtoll(Tcl_GetStringFromObj($input,NULL),0,0);";
|
||||
%typemap(varin) unsigned long long "$1 = ($1_ltype) strtoull(Tcl_GetStringFromObj($input,NULL),0,0);";
|
||||
|
||||
%typemap(varin) double, float {
|
||||
double temp;
|
||||
if (Tcl_GetDoubleFromObj(interp, $input, &temp) != TCL_OK) {
|
||||
return (char*) "Type error. expected a double.";
|
||||
}
|
||||
$1 = ($1_type) temp;
|
||||
}
|
||||
|
||||
%typemap(varin) char *
|
||||
#ifdef __cplusplus
|
||||
{
|
||||
char *temp = Tcl_GetStringFromObj($input,NULL);
|
||||
if ($1) delete [] $1;
|
||||
$1 = ($1_type) new char[strlen(temp)+1];
|
||||
strcpy((char *) $1,temp);
|
||||
}
|
||||
#else
|
||||
{
|
||||
char *temp = Tcl_GetStringFromObj($input,NULL);
|
||||
if ($1) free((char*)$1);
|
||||
$1 = ($1_type) malloc(strlen(temp)+1);
|
||||
strcpy((char *) $1,temp);
|
||||
}
|
||||
#endif
|
||||
|
||||
%typemap(varin,warning="451:Setting const char * variable may leak memory") const char *
|
||||
#ifdef __cplusplus
|
||||
{
|
||||
char *temp = Tcl_GetStringFromObj($input,NULL);
|
||||
$1 = ($1_type) new char[strlen(temp)+1];
|
||||
strcpy((char *) $1,temp);
|
||||
}
|
||||
#else
|
||||
{
|
||||
char *temp = Tcl_GetStringFromObj($input,NULL);
|
||||
$1 = ($1_type) malloc(strlen(temp)+1);
|
||||
strcpy((char *) $1,temp);
|
||||
}
|
||||
#endif
|
||||
|
||||
%typemap(varin) char [ANY] {
|
||||
char *temp = Tcl_GetStringFromObj($input,NULL);
|
||||
strncpy((char*)$1,temp,$1_dim0);
|
||||
}
|
||||
|
||||
%typemap(varin,warning="462: Unable to set variable of type char []") char [] {
|
||||
return (char*)"Variable $symname is read-only.";
|
||||
}
|
||||
|
||||
%typemap(varin) char
|
||||
{
|
||||
char *temp = Tcl_GetStringFromObj($input,NULL);
|
||||
$1 = *temp;
|
||||
}
|
||||
|
||||
%typemap(varin) SWIGTYPE * {
|
||||
if (SWIG_ConvertPtr($input,(void **)&$1,$1_descriptor, SWIG_POINTER_EXCEPTION | SWIG_POINTER_DISOWN) != TCL_OK) {
|
||||
return (char*)"Type error. Expected $1_ltype";
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(varin,warning="462: Unable to set dimensionless array variable") SWIGTYPE [] {
|
||||
return (char*)"Variable $symname is read-only.";
|
||||
}
|
||||
|
||||
%typemap(varin) void * {
|
||||
void *temp;
|
||||
if (SWIG_ConvertPtr($input,&temp,0, SWIG_POINTER_EXCEPTION | SWIG_POINTER_DISOWN) != TCL_OK) {
|
||||
return (char*)"Type error. Expected $1_ltype";
|
||||
}
|
||||
$1 = ($1_type) temp;
|
||||
}
|
||||
|
||||
%typemap(varin) SWIGTYPE & {
|
||||
void *temp;
|
||||
if (SWIG_ConvertPtr($input,&temp,$1_descriptor, SWIG_POINTER_EXCEPTION) != TCL_OK) {
|
||||
return (char*)"Type error. Expected $1_ltype";
|
||||
}
|
||||
$1 = *($1_ltype) temp;
|
||||
}
|
||||
|
||||
%typemap(varin) SWIGTYPE {
|
||||
void *temp;
|
||||
if (SWIG_ConvertPtr($input,&temp,$&1_descriptor, SWIG_POINTER_EXCEPTION) != TCL_OK) {
|
||||
return (char*)"Type error. Expected $&1_ltype";
|
||||
}
|
||||
$1 = *(($&1_type) temp);
|
||||
}
|
||||
|
||||
%typemap(varin) SWIGTYPE [ANY] {
|
||||
void *temp;
|
||||
if (SWIG_ConvertPtr($input,&temp,$1_descriptor, SWIG_POINTER_EXCEPTION) != TCL_OK) {
|
||||
return (char *)"Type error. Expected $1_ltype";
|
||||
}
|
||||
memmove((void *) $1,temp,$1_size*sizeof($1_basetype));
|
||||
}
|
||||
|
||||
%typemap(varin) SWIGTYPE (CLASS::*) {
|
||||
char temp[sizeof($1_type)];
|
||||
if (SWIG_ConvertPacked($input, temp, sizeof($1_type), $1_descriptor, SWIG_POINTER_EXCEPTION) != TCL_OK) {
|
||||
return (char *) "Type error. Expected $1_ltype";
|
||||
}
|
||||
memmove((void *) &$1, temp, sizeof($1_type));
|
||||
}
|
||||
|
||||
/* --- Constants --- */
|
||||
|
||||
%typemap(consttab) int, short, unsigned short, unsigned char, signed char, bool, enum SWIGTYPE
|
||||
{ SWIG_TCL_INT, (char *)"$nsname", (long) $value, 0, 0, 0}
|
||||
|
||||
%typemap(consttab) unsigned int, unsigned long
|
||||
{ SWIG_TCL_STRING, (char *) "$nsname", 0, 0, (void *)"$value", 0}
|
||||
|
||||
%typemap(consttab) float, double
|
||||
{ SWIG_TCL_FLOAT, (char*)"$nsname", 0, (double) $value, 0, 0}
|
||||
|
||||
%typemap(consttab) char, char *
|
||||
{ SWIG_TCL_STRING, (char*)"$nsname", 0, 0, (void *)"$value", 0}
|
||||
|
||||
%typemap(consttab) long long, unsigned long long
|
||||
{ SWIG_TCL_STRING, (char *) "$nsname", 0, 0, (void *)"$value", 0}
|
||||
|
||||
%typemap(consttab) SWIGTYPE *, SWIGTYPE &, SWIGTYPE []
|
||||
{ SWIG_TCL_POINTER, (char*)"$nsname", 0, 0, (void *)$value, &$1_descriptor}
|
||||
|
||||
%typemap(consttab) SWIGTYPE (CLASS::*)
|
||||
{ SWIG_TCL_BINARY, (char *)"$nsname", sizeof($type), 0, (void *)&$value, &$1_descriptor}
|
||||
|
||||
%include <tclerrors.swg>
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Look for user fragments file. If not found, include empty system one.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
%include "tclfragments.swg"
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Typemap specializations
|
||||
* ----------------------------------------------------------------------------- */
|
||||
%include <tcltypemaps.swg>
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* String & length
|
||||
* Overloaded operator support
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%typemap(in) (char *STRING, int LENGTH) {
|
||||
int temp;
|
||||
$1 = ($1_ltype) Tcl_GetStringFromObj($input,&temp);
|
||||
$2 = ($2_ltype) temp;
|
||||
}
|
||||
%include <tclopers.swg>
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Typechecking rules
|
||||
* Warnings for Python keywords
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_INTEGER)
|
||||
int, short, long,
|
||||
unsigned int, unsigned short, unsigned long,
|
||||
signed char, unsigned char,
|
||||
const int &, const short &, const long &,
|
||||
const unsigned int &, const unsigned short &, const unsigned long &,
|
||||
enum SWIGTYPE, const enum SWIGTYPE &,
|
||||
bool, const bool &
|
||||
{
|
||||
long tmp;
|
||||
if (Tcl_GetLongFromObj(NULL,$input,&tmp) == TCL_ERROR) $1 = 0;
|
||||
else $1 = 1;
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_INTEGER)
|
||||
long long, const long long &
|
||||
{
|
||||
int len;
|
||||
char *end = 0;
|
||||
char *str = Tcl_GetStringFromObj($input, &len);
|
||||
strtoll(str, &end, 0);
|
||||
$1 = (end != 0) && (*end != '\0') && (str != end) && (errno == 0);
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_INTEGER)
|
||||
unsigned long long, const unsigned long long &
|
||||
{
|
||||
int len;
|
||||
char *end = 0;
|
||||
char *str = Tcl_GetStringFromObj($input, &len);
|
||||
strtoull(str, &end, 0);
|
||||
$1 = (end != 0) && (*end != '\0') && (str != end) && (errno == 0);
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_DOUBLE)
|
||||
float, double,
|
||||
const float &, const double &
|
||||
{
|
||||
double tmp;
|
||||
if (Tcl_GetDoubleFromObj(NULL,$input,&tmp) == TCL_ERROR) $1 = 0;
|
||||
else $1 = 1;
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_CHAR) char {
|
||||
char *tmp;
|
||||
int len;
|
||||
tmp = Tcl_GetStringFromObj($input,&len);
|
||||
$1 = (len == 1) ? 1 : 0;
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_STRING) char * {
|
||||
$1 = 1;
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
|
||||
void *ptr;
|
||||
if (SWIG_ConvertPtr($input, (void **) &ptr, $1_descriptor, 0) == TCL_ERROR) {
|
||||
$1 = 0;
|
||||
} else {
|
||||
$1 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE {
|
||||
void *ptr;
|
||||
if (SWIG_ConvertPtr($input, (void **) &ptr, $&1_descriptor, 0) == TCL_ERROR) {
|
||||
$1 = 0;
|
||||
} else {
|
||||
$1 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_VOIDPTR) void * {
|
||||
void *ptr;
|
||||
if (SWIG_ConvertPtr($input, (void **) &ptr, 0, 0) == TCL_ERROR) {
|
||||
$1 = 0;
|
||||
} else {
|
||||
$1 = 1;
|
||||
}
|
||||
}
|
||||
%include <tclkw.swg>
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Exception handling
|
||||
* The Python initialization function
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%typemap(throws) int,
|
||||
long,
|
||||
short,
|
||||
unsigned int,
|
||||
unsigned long,
|
||||
unsigned short {
|
||||
Tcl_SetObjResult(interp, Tcl_NewIntObj((long) $1));
|
||||
SWIG_fail;
|
||||
}
|
||||
|
||||
%typemap(throws) SWIGTYPE CLASS {
|
||||
$&1_ltype temp = new $1_ltype($1);
|
||||
Tcl_SetObjResult(interp, SWIG_NewInstanceObj((void *) temp, $&1_descriptor, 1));
|
||||
SWIG_fail;
|
||||
}
|
||||
|
||||
%typemap(throws) SWIGTYPE {
|
||||
(void)$1;
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj((char*) "$1_type", -1));
|
||||
SWIG_fail;
|
||||
}
|
||||
|
||||
%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY] {
|
||||
(void)$1;
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj((char*) "$1_type", -1));
|
||||
SWIG_fail;
|
||||
}
|
||||
|
||||
%typemap(throws) enum SWIGTYPE {
|
||||
(void)$1;
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj((char*) "$1_type", -1));
|
||||
SWIG_fail;
|
||||
}
|
||||
|
||||
%typemap(throws) char * {
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj((char*) $1, -1));
|
||||
SWIG_fail;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* ANSI C typemaps
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%types(size_t);
|
||||
%apply unsigned long { size_t };
|
||||
%apply const unsigned long& { const size_t& };
|
||||
|
||||
%types(ptrdiff_t);
|
||||
%apply long { ptrdiff_t };
|
||||
%apply const long& { const ptrdiff_t& };
|
||||
%include <tclinit.swg>
|
||||
|
||||
|
||||
// Some special reserved words in classes
|
||||
%include "tcl8kw.swg"
|
||||
|
||||
/* C++ overloaded operators.
|
||||
|
||||
These declarations define how SWIG is going to rename C++
|
||||
overloaded operators in Tcl. Since Tcl allows identifiers
|
||||
to be essentially any valid string, we'll just use the
|
||||
normal operator names */
|
||||
|
||||
#ifdef __cplusplus
|
||||
%rename("+") *::operator+;
|
||||
//%rename("u+") *::operator+(); // Unary +
|
||||
//%rename("u+") *::operator+() const; // Unary +
|
||||
%rename("-") *::operator-;
|
||||
//%rename("u-") *::operator-(); // Unary -
|
||||
//%rename("u-") *::operator-() const; // Unary -
|
||||
%rename("*") *::operator*;
|
||||
%rename("/") *::operator/;
|
||||
%rename("<<") *::operator<<;
|
||||
%rename(">>") *::operator>>;
|
||||
%rename("&") *::operator&;
|
||||
%rename("|") *::operator|;
|
||||
%rename("^") *::operator^;
|
||||
%rename("%") *::operator%;
|
||||
%rename("=") *::operator=;
|
||||
#endif
|
||||
|
||||
|
||||
/* This initialization code exports the module initialization function */
|
||||
|
||||
%header %{
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifdef MAC_TCL
|
||||
#pragma export on
|
||||
#endif
|
||||
SWIGEXPORT int SWIG_init(Tcl_Interp *);
|
||||
#ifdef MAC_TCL
|
||||
#pragma export off
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
%}
|
||||
|
||||
/* Start the initialization function */
|
||||
|
||||
%insert(init) "swiginit.swg"
|
||||
|
||||
%init %{
|
||||
SWIGEXPORT int SWIG_init(Tcl_Interp *interp) {
|
||||
int i;
|
||||
if (interp == 0) return TCL_ERROR;
|
||||
#ifdef USE_TCL_STUBS
|
||||
if (Tcl_InitStubs(interp, (char*)"8.1", 0) == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
Tcl_PkgProvide(interp, (char*)SWIG_name, (char*)SWIG_version);
|
||||
|
||||
#ifdef SWIG_namespace
|
||||
Tcl_Eval(interp, "namespace eval " SWIG_namespace " { }");
|
||||
#endif
|
||||
|
||||
SWIG_InitializeModule((void *) interp);
|
||||
SWIG_PropagateClientData();
|
||||
|
||||
for (i = 0; swig_commands[i].name; i++) {
|
||||
Tcl_CreateObjCommand(interp, (char *) swig_commands[i].name, (swig_wrapper_func) swig_commands[i].wrapper, swig_commands[i].clientdata, NULL);
|
||||
}
|
||||
for (i = 0; swig_variables[i].name; i++) {
|
||||
Tcl_SetVar(interp, (char *) swig_variables[i].name, (char *) "", TCL_GLOBAL_ONLY);
|
||||
Tcl_TraceVar(interp, (char *) swig_variables[i].name, TCL_TRACE_READS | TCL_GLOBAL_ONLY, (Tcl_VarTraceProc *) swig_variables[i].get, (ClientData) swig_variables[i].addr);
|
||||
Tcl_TraceVar(interp, (char *) swig_variables[i].name, TCL_TRACE_WRITES | TCL_GLOBAL_ONLY, (Tcl_VarTraceProc *) swig_variables[i].set, (ClientData) swig_variables[i].addr);
|
||||
}
|
||||
SWIG_InstallConstants(interp, swig_constants);
|
||||
%}
|
||||
|
||||
/* Note: the initialization function is closed after all code is generated */
|
||||
|
|
|
|||
107
Lib/tcl/tclapi.swg
Normal file
107
Lib/tcl/tclapi.swg
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* SWIG API. Portion that goes into the runtime
|
||||
* ----------------------------------------------------------------------------- */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Constant declarations
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* Constant Types */
|
||||
#define SWIG_TCL_POINTER 4
|
||||
#define SWIG_TCL_BINARY 5
|
||||
|
||||
/* Constant information structure */
|
||||
typedef struct swig_const_info {
|
||||
int type;
|
||||
char *name;
|
||||
long lvalue;
|
||||
double dvalue;
|
||||
void *pvalue;
|
||||
swig_type_info **ptype;
|
||||
} swig_const_info;
|
||||
|
||||
typedef int (*swig_wrapper)(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST []);
|
||||
typedef int (*swig_wrapper_func)(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST []);
|
||||
typedef char *(*swig_variable_func)(ClientData, Tcl_Interp *, char *, char *, int);
|
||||
typedef void (*swig_delete_func)(ClientData);
|
||||
|
||||
typedef struct swig_method {
|
||||
const char *name;
|
||||
swig_wrapper method;
|
||||
} swig_method;
|
||||
|
||||
typedef struct swig_attribute {
|
||||
const char *name;
|
||||
swig_wrapper getmethod;
|
||||
swig_wrapper setmethod;
|
||||
} swig_attribute;
|
||||
|
||||
typedef struct swig_class {
|
||||
const char *name;
|
||||
swig_type_info **type;
|
||||
swig_wrapper constructor;
|
||||
void (*destructor)(void *);
|
||||
swig_method *methods;
|
||||
swig_attribute *attributes;
|
||||
struct swig_class **bases;
|
||||
char **base_names;
|
||||
swig_module_info *module;
|
||||
} swig_class;
|
||||
|
||||
typedef struct swig_instance {
|
||||
Tcl_Obj *thisptr;
|
||||
void *thisvalue;
|
||||
swig_class *classptr;
|
||||
int destroy;
|
||||
Tcl_Command cmdtok;
|
||||
} swig_instance;
|
||||
|
||||
/* Structure for command table */
|
||||
typedef struct {
|
||||
const char *name;
|
||||
int (*wrapper)(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST []);
|
||||
ClientData clientdata;
|
||||
} swig_command_info;
|
||||
|
||||
/* Structure for variable linking table */
|
||||
typedef struct {
|
||||
const char *name;
|
||||
void *addr;
|
||||
char * (*get)(ClientData, Tcl_Interp *, char *, char *, int);
|
||||
char * (*set)(ClientData, Tcl_Interp *, char *, char *, int);
|
||||
} swig_var_info;
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------*
|
||||
* Install a constant object
|
||||
* -----------------------------------------------------------------------------*/
|
||||
|
||||
static Tcl_HashTable swigconstTable;
|
||||
static int swigconstTableinit = 0;
|
||||
|
||||
SWIGINTERN void
|
||||
SWIG_Tcl_SetConstantObj(Tcl_Interp *interp, const char* name, Tcl_Obj *obj) {
|
||||
int newobj;
|
||||
Tcl_ObjSetVar2(interp,Tcl_NewStringObj(name,-1), NULL, obj, TCL_GLOBAL_ONLY);
|
||||
Tcl_SetHashValue(Tcl_CreateHashEntry(&swigconstTable, name, &newobj), (ClientData) obj);
|
||||
}
|
||||
|
||||
SWIGINTERN Tcl_Obj *
|
||||
SWIG_Tcl_GetConstantObj(const char *key) {
|
||||
Tcl_HashEntry *entryPtr;
|
||||
if (!swigconstTableinit) return 0;
|
||||
entryPtr = Tcl_FindHashEntry(&swigconstTable, key);
|
||||
if (entryPtr) {
|
||||
return (Tcl_Obj *) Tcl_GetHashValue(entryPtr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
75
Lib/tcl/tclerrors.swg
Normal file
75
Lib/tcl/tclerrors.swg
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* error manipulation
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%insert("header") %{
|
||||
|
||||
|
||||
SWIGINTERN const char*
|
||||
SWIG_Tcl_ErrorType(int code) {
|
||||
switch(code) {
|
||||
case SWIG_MemoryError:
|
||||
return "MemoryError";
|
||||
break;
|
||||
case SWIG_IOError:
|
||||
return "IOError";
|
||||
break;
|
||||
case SWIG_RuntimeError:
|
||||
return "RuntimeError";
|
||||
break;
|
||||
case SWIG_IndexError:
|
||||
return "IndexError";
|
||||
break;
|
||||
case SWIG_TypeError:
|
||||
return "TypeError";
|
||||
break;
|
||||
case SWIG_DivisionByZero:
|
||||
return "ZeroDivisionError";
|
||||
break;
|
||||
case SWIG_OverflowError:
|
||||
return "OverflowError";
|
||||
break;
|
||||
case SWIG_SyntaxError:
|
||||
return "SyntaxError";
|
||||
break;
|
||||
case SWIG_ValueError:
|
||||
return "ValueError";
|
||||
break;
|
||||
case SWIG_SystemError:
|
||||
return "SystemError";
|
||||
break;
|
||||
case SWIG_AttributeError:
|
||||
return "AttributeError";
|
||||
break;
|
||||
default:
|
||||
return "RuntimeError";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SWIGINTERN void
|
||||
SWIG_Tcl_SetErrorObj(Tcl_Interp *interp, const char *ctype, Tcl_Obj *obj)
|
||||
{
|
||||
Tcl_ResetResult(interp);
|
||||
Tcl_SetObjResult(interp, obj);
|
||||
Tcl_SetErrorCode(interp, "SWIG", ctype, NULL);
|
||||
}
|
||||
|
||||
SWIGINTERN void
|
||||
SWIG_Tcl_SetErrorMsg(Tcl_Interp *interp, const char *ctype, const char *mesg)
|
||||
{
|
||||
Tcl_ResetResult(interp);
|
||||
Tcl_SetErrorCode(interp, "SWIG", ctype, NULL);
|
||||
Tcl_AddErrorInfo(interp, mesg);
|
||||
}
|
||||
|
||||
SWIGINTERNINLINE void
|
||||
SWIG_Tcl_AddErrorMsg(Tcl_Interp *interp, const char* mesg)
|
||||
{
|
||||
Tcl_AddErrorInfo(interp, mesg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
%}
|
||||
23
Lib/tcl/tclfragments.swg
Normal file
23
Lib/tcl/tclfragments.swg
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
|
||||
Create a file with this name, 'fragments.i', in your working
|
||||
directory and add all the %fragments you want to take precedence
|
||||
over the ones defined by default by swig.
|
||||
|
||||
For example, if you add:
|
||||
|
||||
%fragment(SWIG_AsVal_frag(int),"header") {
|
||||
SWIGINTERNINLINE int
|
||||
SWIG_AsVal_dec(int)(TclObject *obj, int *val)
|
||||
{
|
||||
<your code here>;
|
||||
}
|
||||
}
|
||||
|
||||
this will replace the code used to retreive an integer value for all
|
||||
the typemaps that need it, including:
|
||||
|
||||
int, std::vector<int>, std::list<std::pair<int,int> >, etc.
|
||||
|
||||
|
||||
*/
|
||||
106
Lib/tcl/tclinit.swg
Normal file
106
Lib/tcl/tclinit.swg
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
/* ------------------------------------------------------------
|
||||
* The start of the Tcl initialization function
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%insert(init) "swiginit.swg"
|
||||
|
||||
/* This initialization code exports the module initialization function */
|
||||
|
||||
%header %{
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifdef MAC_TCL
|
||||
#pragma export on
|
||||
#endif
|
||||
SWIGEXPORT int SWIG_init(Tcl_Interp *);
|
||||
#ifdef MAC_TCL
|
||||
#pragma export off
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
%}
|
||||
|
||||
%init %{
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* constants/methods manipulation
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* Install Constants */
|
||||
|
||||
SWIGINTERN void
|
||||
SWIG_Tcl_InstallConstants(Tcl_Interp *interp, swig_const_info constants[]) {
|
||||
int i;
|
||||
Tcl_Obj *obj;
|
||||
|
||||
if (!swigconstTableinit) {
|
||||
Tcl_InitHashTable(&swigconstTable, TCL_STRING_KEYS);
|
||||
swigconstTableinit = 1;
|
||||
}
|
||||
for (i = 0; constants[i].type; i++) {
|
||||
switch(constants[i].type) {
|
||||
case SWIG_TCL_POINTER:
|
||||
obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
|
||||
break;
|
||||
case SWIG_TCL_BINARY:
|
||||
obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype),0);
|
||||
break;
|
||||
default:
|
||||
obj = 0;
|
||||
break;
|
||||
}
|
||||
if (obj) {
|
||||
SWIG_Tcl_SetConstantObj(interp, constants[i].name, obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* -----------------------------------------------------------------------------*
|
||||
* Partial Init method
|
||||
* -----------------------------------------------------------------------------*/
|
||||
|
||||
SWIGEXPORT int SWIG_init(Tcl_Interp *interp) {
|
||||
int i;
|
||||
if (interp == 0) return TCL_ERROR;
|
||||
#ifdef USE_TCL_STUBS
|
||||
if (Tcl_InitStubs(interp, (char*)"8.1", 0) == NULL) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
#endif
|
||||
Tcl_PkgProvide(interp, (char*)SWIG_name, (char*)SWIG_version);
|
||||
|
||||
#ifdef SWIG_namespace
|
||||
Tcl_Eval(interp, "namespace eval " SWIG_namespace " { }");
|
||||
#endif
|
||||
|
||||
SWIG_InitializeModule((void *) interp);
|
||||
SWIG_PropagateClientData();
|
||||
|
||||
for (i = 0; swig_commands[i].name; i++) {
|
||||
Tcl_CreateObjCommand(interp, (char *) swig_commands[i].name, (swig_wrapper_func) swig_commands[i].wrapper,
|
||||
swig_commands[i].clientdata, NULL);
|
||||
}
|
||||
for (i = 0; swig_variables[i].name; i++) {
|
||||
Tcl_SetVar(interp, (char *) swig_variables[i].name, (char *) "", TCL_GLOBAL_ONLY);
|
||||
Tcl_TraceVar(interp, (char *) swig_variables[i].name, TCL_TRACE_READS | TCL_GLOBAL_ONLY,
|
||||
(Tcl_VarTraceProc *) swig_variables[i].get, (ClientData) swig_variables[i].addr);
|
||||
Tcl_TraceVar(interp, (char *) swig_variables[i].name, TCL_TRACE_WRITES | TCL_GLOBAL_ONLY,
|
||||
(Tcl_VarTraceProc *) swig_variables[i].set, (ClientData) swig_variables[i].addr);
|
||||
}
|
||||
|
||||
SWIG_Tcl_InstallConstants(interp, swig_constants);
|
||||
|
||||
%}
|
||||
|
||||
/* Note: the initialization function is closed after all code is generated */
|
||||
26
Lib/tcl/tclmacros.swg
Normal file
26
Lib/tcl/tclmacros.swg
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
%include <typemaps/swigmacros.swg>
|
||||
|
||||
|
||||
/* aux macros to deal with the interp argument */
|
||||
|
||||
#undef SWIG_As_dec
|
||||
#undef SWIG_AsPtr_dec
|
||||
#undef SWIG_AsVal_dec
|
||||
|
||||
#define SWIG_Tcl_AsVal(Type...) SWIG_Tcl_ ## AsVal ## _ ## #@Type
|
||||
#define SWIG_AsVal_dec(Type...) SWIG_ ## AsVal_dec ## _ ## #@Type
|
||||
|
||||
#define SWIG_Tcl_AsPtr(Type...) SWIG_Tcl_ ## AsPtr ## _ ## #@Type
|
||||
#define SWIG_AsPtr_dec(Type...) SWIG_ ## AsPtr_dec ## _ ## #@Type
|
||||
|
||||
|
||||
%define %tcl_asval_decl(Type...)
|
||||
%#define SWIG_AsVal_dec(Type)(obj,val) SWIG_Tcl_AsVal(Type)(Tcl_Interp *interp, obj, val)
|
||||
%#define SWIG_AsVal(Type)(obj,val) SWIG_Tcl_AsVal(Type)(interp, obj, val)
|
||||
%enddef
|
||||
|
||||
|
||||
%define %tcl_asptr_decl(Type...)
|
||||
%#define SWIG_AsPtr_dec(Type)(obj,ptr) SWIG_Tcl_AsPtr(Type)(Tcl_Interp *interp, obj, ptr)
|
||||
%#define SWIG_AsPtr(Type)(obj,ptr) SWIG_Tcl_AsPtr(Type)(interp, obj, ptr)
|
||||
%enddef
|
||||
24
Lib/tcl/tclopers.swg
Normal file
24
Lib/tcl/tclopers.swg
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/* C++ overloaded operators.
|
||||
|
||||
These declarations define how SWIG is going to rename C++
|
||||
overloaded operators in Tcl. Since Tcl allows identifiers
|
||||
to be essentially any valid string, we'll just use the
|
||||
normal operator names */
|
||||
|
||||
#ifdef __cplusplus
|
||||
%rename("+") *::operator+;
|
||||
//%rename("u+") *::operator+(); // Unary +
|
||||
//%rename("u+") *::operator+() const; // Unary +
|
||||
%rename("-") *::operator-;
|
||||
//%rename("u-") *::operator-(); // Unary -
|
||||
//%rename("u-") *::operator-() const; // Unary -
|
||||
%rename("*") *::operator*;
|
||||
%rename("/") *::operator/;
|
||||
%rename("<<") *::operator<<;
|
||||
%rename(">>") *::operator>>;
|
||||
%rename("&") *::operator&;
|
||||
%rename("|") *::operator|;
|
||||
%rename("^") *::operator^;
|
||||
%rename("%") *::operator%;
|
||||
%rename("=") *::operator=;
|
||||
#endif
|
||||
308
Lib/tcl/tclprimtypes.swg
Normal file
308
Lib/tcl/tclprimtypes.swg
Normal file
|
|
@ -0,0 +1,308 @@
|
|||
%include <typemaps/primtypes.swg>
|
||||
|
||||
/* Macro for 'signed long' derived types */
|
||||
|
||||
%define %type_slong(Type, Frag, Min, Max)
|
||||
%derived_type_from(long, Type)
|
||||
%fragment("Tcl_asval_"{Type},"header",fragment=Frag) %{
|
||||
%tcl_asval_decl(Type)
|
||||
%}
|
||||
%signed_derived_type_asval(long, Type, "Tcl_asval_"{Type} , Min, Max)
|
||||
%enddef
|
||||
|
||||
/* Macro for 'unsigned long' derived types */
|
||||
|
||||
%define %type_ulong(Type, Frag, Max)
|
||||
%derived_type_from(unsigned long, Type)
|
||||
%fragment("Tcl_asval_"{Type},"header",fragment=Frag) %{
|
||||
%tcl_asval_decl(Type)
|
||||
%}
|
||||
%unsigned_derived_type_asval(unsigned long, Type, "Tcl_asval_"{Type}, Max)
|
||||
%enddef
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Primitive Types
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
/* boolean */
|
||||
|
||||
%fragment(SWIG_From_frag(bool),"header") {
|
||||
SWIG_define(SWIG_From_dec(bool), Tcl_NewBooleanObj)
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_frag(bool),"header") {
|
||||
%tcl_asval_decl(bool)
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(bool)(Tcl_Obj *obj, bool *val)
|
||||
{
|
||||
int v;
|
||||
if (Tcl_GetBooleanFromObj(0, obj, &v) == TCL_OK) {
|
||||
if (val) *val = v ? true : false;
|
||||
return SWIG_OK;
|
||||
}
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
}
|
||||
|
||||
/* signed/unsigned char */
|
||||
|
||||
%type_slong(signed char, "<limits.h>", SCHAR_MIN, SCHAR_MAX)
|
||||
%type_ulong(unsigned char, "<limits.h>", UCHAR_MAX)
|
||||
|
||||
/* short/unsigned short */
|
||||
|
||||
%type_slong(short, "<limits.h>", SHRT_MIN, SHRT_MAX)
|
||||
%type_ulong(unsigned short, "<limits.h>", USHRT_MAX)
|
||||
|
||||
/* int/unsigned int */
|
||||
|
||||
%type_slong(int, "<limits.h>", INT_MIN, INT_MAX)
|
||||
%type_ulong(unsigned int, "<limits.h>", UINT_MAX)
|
||||
|
||||
/* signed/unsigned wchar_t */
|
||||
|
||||
#ifdef __cplusplus
|
||||
%type_slong(signed wchar_t, "<wchar.h>", WCHAR_MIN, WCHAR_MAX)
|
||||
%type_ulong(unsigned wchar_t, "<wchar.h>", UWCHAR_MAX)
|
||||
#endif
|
||||
|
||||
|
||||
/* long */
|
||||
|
||||
%fragment(SWIG_From_frag(long),"header",
|
||||
fragment="<limits.h>") {
|
||||
SWIGINTERNINLINE Tcl_Obj*
|
||||
SWIG_From_dec(long)(long value)
|
||||
{
|
||||
if (((long) INT_MIN <= value) && (value <= (long) INT_MAX)) {
|
||||
return Tcl_NewIntObj(SWIG_numeric_cast(value,int));
|
||||
} else {
|
||||
return Tcl_NewLongObj(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_frag(long),"header") {
|
||||
%tcl_asval_decl(long)
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(long)(Tcl_Obj *obj, long* val)
|
||||
{
|
||||
long v;
|
||||
if (Tcl_GetLongFromObj(0,obj, &v) == TCL_OK) {
|
||||
if (val) *val = (long) v;
|
||||
return SWIG_OK;
|
||||
}
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
}
|
||||
|
||||
/* unsigned long */
|
||||
|
||||
%fragment(SWIG_From_frag(unsigned long),"header",
|
||||
fragment=SWIG_From_frag(long)) {
|
||||
SWIGINTERNINLINE Tcl_Obj*
|
||||
SWIG_From_dec(unsigned long)(unsigned long value)
|
||||
{
|
||||
if (value < (unsigned long) LONG_MAX) {
|
||||
return SWIG_From(long)(SWIG_numeric_cast(value, long));
|
||||
} else {
|
||||
char temp[256];
|
||||
snprintf(temp, sizeof(temp),"%lu", value);
|
||||
return Tcl_NewStringObj(temp,-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_frag(unsigned long),"header") {
|
||||
%tcl_asval_decl(unsigned long)
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(unsigned long)(Tcl_Obj *obj, unsigned long *val) {
|
||||
int len = 0;
|
||||
const char *nptr = Tcl_GetStringFromObj(obj, &len);
|
||||
if (nptr && len > 0) {
|
||||
char *endptr;
|
||||
unsigned long v = strtoul(nptr, &endptr,0);
|
||||
if (errno == ERANGE) {
|
||||
errno = 0;
|
||||
return SWIG_OverflowError;
|
||||
} else {
|
||||
if (*endptr == '\0') {
|
||||
if (val) *val = v;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
}
|
||||
|
||||
/* long long */
|
||||
|
||||
%fragment(SWIG_From_frag(long long),"header",
|
||||
fragment=SWIG_From_frag(long),
|
||||
fragment="<limits.h>") {
|
||||
SWIGINTERNINLINE Tcl_Obj*
|
||||
SWIG_From_dec(long long)(long long value)
|
||||
{
|
||||
if (((long long) LONG_MIN <= value) && (value <= (long long) LONG_MAX)) {
|
||||
return SWIG_From(long)(SWIG_numeric_cast(value,long));
|
||||
} else {
|
||||
char temp[256];
|
||||
snprintf(temp, sizeof(temp),"%lld", value);
|
||||
return Tcl_NewStringObj(temp,-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_frag(long long),"header") {
|
||||
%tcl_asval_decl(long long)
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(long long)(Tcl_Obj *obj, long long *val)
|
||||
{
|
||||
int len = 0;
|
||||
const char *nptr = Tcl_GetStringFromObj(obj, &len);
|
||||
if (nptr && len > 0) {
|
||||
char *endptr;
|
||||
long long v = strtoll(nptr, &endptr,0);
|
||||
if (errno == ERANGE) {
|
||||
errno = 0;
|
||||
return SWIG_OverflowError;
|
||||
} else {
|
||||
if (*endptr == '\0') {
|
||||
if (val) *val = v;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
}
|
||||
|
||||
/* unsigned long long */
|
||||
|
||||
%fragment(SWIG_From_frag(unsigned long long),"header",
|
||||
fragment=SWIG_From_frag(long long),
|
||||
fragment="<limits.h>") {
|
||||
SWIGINTERNINLINE Tcl_Obj*
|
||||
SWIG_From_dec(unsigned long long)(unsigned long long value)
|
||||
{
|
||||
if (value < (unsigned long long) LONG_MAX) {
|
||||
return SWIG_From(long long)(SWIG_numeric_cast(value, long long));
|
||||
} else {
|
||||
char temp[256];
|
||||
snprintf(temp, sizeof(temp),"%llu", value);
|
||||
return Tcl_NewStringObj(temp,-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_frag(unsigned long long),"header",
|
||||
fragment=SWIG_AsVal_frag(unsigned long)) {
|
||||
%tcl_asval_decl(unsigned long long)
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(unsigned long long)(Tcl_Obj *obj, unsigned long long *val)
|
||||
{
|
||||
int len = 0;
|
||||
const char *nptr = Tcl_GetStringFromObj(obj, &len);
|
||||
if (nptr && len > 0) {
|
||||
char *endptr;
|
||||
unsigned long long v = strtoull(nptr, &endptr,0);
|
||||
if (errno == ERANGE) {
|
||||
errno = 0;
|
||||
return SWIG_OverflowError;
|
||||
} else {
|
||||
if (*endptr == '\0') {
|
||||
if (val) *val = v;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
}
|
||||
|
||||
/* float */
|
||||
|
||||
%derived_type_from(double, float)
|
||||
%fragment("Tcl_asval_float","header",fragment="<float.h>") {
|
||||
%tcl_asval_decl(float)
|
||||
}
|
||||
%signed_derived_type_asval(double, float, "Tcl_asval_float", -FLT_MAX, FLT_MAX)
|
||||
|
||||
/* double */
|
||||
|
||||
%fragment(SWIG_From_frag(double),"header") {
|
||||
SWIG_define(SWIG_From_dec(double), Tcl_NewDoubleObj)
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_frag(double),"header") {
|
||||
%tcl_asval_decl(double)
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(double)(Tcl_Obj *obj, double *val)
|
||||
{
|
||||
double v;
|
||||
if (Tcl_GetDoubleFromObj(0, obj, &v) == TCL_OK) {
|
||||
if (val) *val = v;
|
||||
return SWIG_OK;
|
||||
}
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
}
|
||||
|
||||
/* char */
|
||||
|
||||
%fragment(SWIG_From_frag(char),"header") {
|
||||
SWIGINTERNINLINE Tcl_Obj*
|
||||
SWIG_From_dec(char)(char c)
|
||||
{
|
||||
return Tcl_NewStringObj(&c,1);
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_frag(char),"header",
|
||||
fragment="SWIG_AsCharArray",
|
||||
fragment=SWIG_AsVal_frag(signed char)) {
|
||||
%tcl_asval_decl(char)
|
||||
|
||||
SWIGINTERNINLINE int
|
||||
SWIG_AsVal_dec(char)(Tcl_Obj *obj, char *val)
|
||||
{
|
||||
return SWIG_AsCharArray(obj, val, 1) == SWIG_OK ? SWIG_OK : SWIG_TypeError;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* wchar_t */
|
||||
|
||||
%fragment(SWIG_From_frag(wchar_t),"header") {
|
||||
SWIGINTERNINLINE Tcl_Obj*
|
||||
SWIG_From_dec(wchar_t)(wchar_t c)
|
||||
{
|
||||
return Tcl_NewUnicodeObj(&c, 1);
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_frag(wchar_t),"header",
|
||||
fragment="SWIG_AsWCharArray",
|
||||
fragment="<wchar.h>",
|
||||
fragment=SWIG_AsVal_frag(long)) {
|
||||
%tcl_asval_decl(wchar_t)
|
||||
|
||||
SWIGINTERNINLINE int
|
||||
SWIG_AsVal_dec(wchar_t)(Tcl_Obj *obj, wchar_t *val)
|
||||
{
|
||||
return (SWIG_AsWCharArray(obj, val, 1) == SWIG_OK) ? SWIG_OK : SWIG_TypeError;
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Apply the primitive typemap for all the types with checkcode
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%apply_checkctypes(%typemap_primitive)
|
||||
|
|
@ -1,139 +1,96 @@
|
|||
/*
|
||||
* $Header$
|
||||
*
|
||||
* swigtcl8.swg
|
||||
*/
|
||||
/***********************************************************************
|
||||
* tclrun.swg
|
||||
*
|
||||
* This file contains the runtime support for Tcl modules
|
||||
* and includes code for managing global variables and pointer
|
||||
* type checking.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#include <tcl.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <ctype.h>
|
||||
/* Common SWIG API */
|
||||
|
||||
/* for raw pointers */
|
||||
#define SWIG_ConvertPtr(oc, ptr, ty, flags) SWIG_Tcl_ConvertPtr(interp, oc, ptr, ty, flags)
|
||||
#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Tcl_NewPointerObj(ptr, type, flags)
|
||||
|
||||
/* for raw packed data */
|
||||
#define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) SWIG_Tcl_ConvertPacked(interp, obj, ptr, sz, ty, flags)
|
||||
#define SWIG_NewPackedObj(ptr, sz, type, flags) SWIG_Tcl_NewPackedObj(ptr, sz, type, flags)
|
||||
|
||||
/* for class or struct pointers */
|
||||
#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_Tcl_ConvertPtr(interp, obj, pptr, type, flags)
|
||||
#define SWIG_NewInstanceObj(thisvalue, type, flags) SWIG_Tcl_NewInstanceObj(interp, thisvalue, type, flags)
|
||||
|
||||
/* for C or C++ function pointers */
|
||||
#define SWIG_ConvertFunctionPtr(obj, pptr, type, flags) SWIG_Tcl_ConvertPtr(interp, obj, pptr, type, flags)
|
||||
#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Tcl_NewPointerObj(ptr, type, 0)
|
||||
|
||||
/* for C++ member pointers, ie, member methods */
|
||||
#define SWIG_ConvertMember(obj, ptr, sz, ty, flags) SWIG_Tcl_ConvertPacked(interp,obj, ptr, sz, ty, flags)
|
||||
#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Tcl_NewPackedObj(ptr, sz, type, 0)
|
||||
|
||||
/* Runtime API */
|
||||
#define SWIG_GetModule(clientdata) SWIG_Tcl_GetModule((Tcl_Interp *) (clientdata))
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Tcl_SetModule((Tcl_Interp *) (clientdata), pointer)
|
||||
|
||||
/* Tcl-specific SWIG API */
|
||||
#define SWIG_Acquire(ptr) SWIG_Tcl_Acquire(ptr)
|
||||
#define SWIG_MethodCommand SWIG_Tcl_MethodCommand
|
||||
#define SWIG_Disown(ptr) SWIG_Tcl_Disown(ptr)
|
||||
#define SWIG_ConvertPtrFromString(c, ptr, ty, flags) SWIG_Tcl_ConvertPtrFromString(interp, c, ptr, ty, flags)
|
||||
#define SWIG_MakePtr(c, ptr, ty, flags) SWIG_Tcl_MakePtr(c, ptr, ty, flags)
|
||||
#define SWIG_PointerTypeFromString(c) SWIG_Tcl_PointerTypeFromString(c)
|
||||
#define SWIG_GetArgs SWIG_Tcl_GetArgs
|
||||
#define SWIG_GetConstantObj(key) SWIG_Tcl_GetConstantObj(key)
|
||||
#define SWIG_ObjectConstructor SWIG_Tcl_ObjectConstructor
|
||||
#define SWIG_Thisown(ptr) SWIG_Tcl_Thisown(ptr)
|
||||
#define SWIG_ObjectDelete SWIG_Tcl_ObjectDelete
|
||||
|
||||
/* Error manipulation */
|
||||
#define SWIG_fail goto fail
|
||||
#define SWIG_var_fail return "$name"
|
||||
#define SWIG_exception(code, msg) do { SWIG_Tcl_SetErrorMsg(interp, SWIG_Tcl_ErrorType(code), msg); SWIG_fail; } while (0)
|
||||
#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Tcl_SetErrorMsg(interp, 0, msg); SWIG_fail; } else
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Constant table */
|
||||
|
||||
#define SWIG_TCL_INT 1
|
||||
#define SWIG_TCL_FLOAT 2
|
||||
#define SWIG_TCL_STRING 3
|
||||
#define SWIG_TCL_POINTER 4
|
||||
#define SWIG_TCL_BINARY 5
|
||||
|
||||
/* Flags for pointer conversion */
|
||||
#define SWIG_POINTER_EXCEPTION 0x1
|
||||
#define SWIG_POINTER_DISOWN 0x2
|
||||
|
||||
/* Swig fail macro */
|
||||
|
||||
#define SWIG_fail goto fail
|
||||
|
||||
/* Constant information structure */
|
||||
typedef struct swig_const_info {
|
||||
int type;
|
||||
char *name;
|
||||
long lvalue;
|
||||
double dvalue;
|
||||
void *pvalue;
|
||||
swig_type_info **ptype;
|
||||
} swig_const_info;
|
||||
|
||||
typedef int (*swig_wrapper)(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST []);
|
||||
typedef int (*swig_wrapper_func)(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST []);
|
||||
typedef char *(*swig_variable_func)(ClientData, Tcl_Interp *, char *, char *, int);
|
||||
typedef void (*swig_delete_func)(ClientData);
|
||||
|
||||
typedef struct swig_method {
|
||||
const char *name;
|
||||
swig_wrapper method;
|
||||
} swig_method;
|
||||
|
||||
typedef struct swig_attribute {
|
||||
const char *name;
|
||||
swig_wrapper getmethod;
|
||||
swig_wrapper setmethod;
|
||||
} swig_attribute;
|
||||
|
||||
typedef struct swig_class {
|
||||
const char *name;
|
||||
swig_type_info **type;
|
||||
swig_wrapper constructor;
|
||||
void (*destructor)(void *);
|
||||
swig_method *methods;
|
||||
swig_attribute *attributes;
|
||||
struct swig_class **bases;
|
||||
char **base_names;
|
||||
swig_module_info *module;
|
||||
} swig_class;
|
||||
|
||||
typedef struct swig_instance {
|
||||
Tcl_Obj *thisptr;
|
||||
void *thisvalue;
|
||||
swig_class *classptr;
|
||||
int destroy;
|
||||
Tcl_Command cmdtok;
|
||||
} swig_instance;
|
||||
|
||||
#define SWIG_NewPointerObj(ptr, type, flags) \
|
||||
SWIG_Tcl_NewPointerObj(ptr, type, flags)
|
||||
#define SWIG_ConvertPtr(oc, ptr, ty, flags) \
|
||||
SWIG_Tcl_ConvertPtr(interp, oc, ptr, ty, flags)
|
||||
#define SWIG_ConvertPtrFromString(c, ptr, ty, flags) \
|
||||
SWIG_Tcl_ConvertPtrFromString(interp, c, ptr, ty, flags)
|
||||
#define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) \
|
||||
SWIG_Tcl_ConvertPacked(interp, obj, ptr, sz, ty, flags)
|
||||
#define SWIG_MakePtr(c, ptr, ty, flags) \
|
||||
SWIG_Tcl_MakePtr(c, ptr, ty, flags)
|
||||
#define SWIG_NewPackedObj(ptr, sz, type, flags) \
|
||||
SWIG_Tcl_NewPackedObj(ptr, sz, type, flags)
|
||||
#define SWIG_GetArgs SWIG_Tcl_GetArgs
|
||||
#define SWIG_PointerTypeFromString(c) \
|
||||
SWIG_Tcl_PointerTypeFromString(c)
|
||||
#define SWIG_Acquire(ptr) \
|
||||
SWIG_Tcl_Acquire(ptr)
|
||||
#define SWIG_Disown(ptr) \
|
||||
SWIG_Tcl_Disown(ptr)
|
||||
#define SWIG_Thisown(ptr) \
|
||||
SWIG_Tcl_Thisown(ptr)
|
||||
#define SWIG_InstallConstants(interp, constants) \
|
||||
SWIG_Tcl_InstallConstants(interp, constants)
|
||||
#define SWIG_GetConstant(key) \
|
||||
SWIG_Tcl_GetConstant(key)
|
||||
#define SWIG_NewInstanceObj(thisvalue, type, flags) \
|
||||
SWIG_Tcl_NewInstanceObj(interp, thisvalue, type, flags)
|
||||
#define SWIG_ObjectConstructor SWIG_Tcl_ObjectConstructor
|
||||
#define SWIG_MethodCommand SWIG_Tcl_MethodCommand
|
||||
#define SWIG_ObjectDelete SWIG_Tcl_ObjectDelete
|
||||
|
||||
/* Runtime API */
|
||||
#define SWIG_GetModule(clientdata) SWIG_Tcl_GetModule((Tcl_Interp *) (clientdata))
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Tcl_SetModule((Tcl_Interp *) (clientdata), pointer)
|
||||
#define SWIG_MODULE_CLIENTDATA_TYPE Tcl_Interp *
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* pointers/data manipulation
|
||||
* ----------------------------------------------------------------------------- */
|
||||
/* Object support */
|
||||
static Tcl_HashTable swigobjectTable;
|
||||
static int swigobjectTableinit = 0;
|
||||
|
||||
/* Acquire ownership of a pointer */
|
||||
static void
|
||||
SWIG_Tcl_Acquire(void *ptr) {
|
||||
Tcl_HashEntry *entryPtr;
|
||||
int newobj;
|
||||
SWIGRUNTIME Tcl_HashTable*
|
||||
SWIG_Tcl_ObjectTable() {
|
||||
static Tcl_HashTable swigobjectTable;
|
||||
static int swigobjectTableinit = 0;
|
||||
if (!swigobjectTableinit) {
|
||||
Tcl_InitHashTable(&swigobjectTable, TCL_ONE_WORD_KEYS);
|
||||
swigobjectTableinit = 1;
|
||||
}
|
||||
entryPtr = Tcl_CreateHashEntry(&swigobjectTable, (char *) ptr, &newobj);
|
||||
return &swigobjectTable;
|
||||
}
|
||||
|
||||
/* Acquire ownership of a pointer */
|
||||
SWIGRUNTIME void
|
||||
SWIG_Tcl_Acquire(void *ptr) {
|
||||
int newobj;
|
||||
Tcl_CreateHashEntry(SWIG_Tcl_ObjectTable(), (char *) ptr, &newobj);
|
||||
}
|
||||
|
||||
SWIGRUNTIME int
|
||||
SWIG_Tcl_Thisown(void *ptr) {
|
||||
if (Tcl_FindHashEntry(SWIG_Tcl_ObjectTable(), (char *) ptr)) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Disown a pointer. Returns 1 if we owned it to begin with */
|
||||
static int
|
||||
SWIGRUNTIME int
|
||||
SWIG_Tcl_Disown(void *ptr) {
|
||||
Tcl_HashEntry *entryPtr;
|
||||
if (!swigobjectTableinit) return 0;
|
||||
entryPtr = Tcl_FindHashEntry(&swigobjectTable, (char *) ptr);
|
||||
Tcl_HashEntry *entryPtr = Tcl_FindHashEntry(SWIG_Tcl_ObjectTable(), (char *) ptr);
|
||||
if (entryPtr) {
|
||||
Tcl_DeleteHashEntry(entryPtr);
|
||||
return 1;
|
||||
|
|
@ -141,23 +98,14 @@ SWIG_Tcl_Disown(void *ptr) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SWIG_Tcl_Thisown(void *ptr) {
|
||||
if (!swigobjectTableinit) return 0;
|
||||
if (Tcl_FindHashEntry(&swigobjectTable, (char *) ptr)) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Convert a pointer value */
|
||||
static int
|
||||
SWIGRUNTIME int
|
||||
SWIG_Tcl_ConvertPtrFromString(Tcl_Interp *interp, const char *c, void **ptr, swig_type_info *ty, int flags) {
|
||||
swig_cast_info *tc;
|
||||
/* Pointer values must start with leading underscore */
|
||||
while (*c != '_') {
|
||||
*ptr = (void *) 0;
|
||||
if (strcmp(c,"NULL") == 0) return TCL_OK;
|
||||
if (strcmp(c,"NULL") == 0) return SWIG_OK;
|
||||
/* Hmmm. It could be an object name. */
|
||||
if (Tcl_VarEval(interp,c," cget -this", (char *) NULL) == TCL_OK) {
|
||||
Tcl_Obj *result = Tcl_GetObjResult(interp);
|
||||
|
|
@ -165,38 +113,32 @@ SWIG_Tcl_ConvertPtrFromString(Tcl_Interp *interp, const char *c, void **ptr, swi
|
|||
continue;
|
||||
}
|
||||
Tcl_ResetResult(interp);
|
||||
if (flags & SWIG_POINTER_EXCEPTION)
|
||||
Tcl_SetResult(interp, (char *) "Type error. Expected a pointer", TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
c++;
|
||||
c = SWIG_UnpackData(c,ptr,sizeof(void *));
|
||||
if (ty) {
|
||||
tc = SWIG_TypeCheck(c,ty);
|
||||
if ((!tc) && (flags & SWIG_POINTER_EXCEPTION)) {
|
||||
Tcl_SetResult(interp, (char *) "Type error. Expected ", TCL_STATIC);
|
||||
Tcl_AppendElement(interp, (char *) ty->name);
|
||||
return TCL_ERROR;
|
||||
} else if (!tc) {
|
||||
if (!tc) {
|
||||
Tcl_ResetResult(interp);
|
||||
return TCL_ERROR;
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (flags & SWIG_POINTER_DISOWN) {
|
||||
SWIG_Disown((void *) *ptr);
|
||||
}
|
||||
*ptr = SWIG_TypeCast(tc,(void *) *ptr);
|
||||
}
|
||||
return TCL_OK;
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
/* Convert a pointer value */
|
||||
static SWIGINLINE int
|
||||
SWIGRUNTIMEINLINE int
|
||||
SWIG_Tcl_ConvertPtr(Tcl_Interp *interp, Tcl_Obj *oc, void **ptr, swig_type_info *ty, int flags) {
|
||||
return SWIG_Tcl_ConvertPtrFromString(interp, Tcl_GetStringFromObj(oc,NULL), ptr, ty, flags);
|
||||
}
|
||||
|
||||
/* Convert a pointer value */
|
||||
static char *
|
||||
SWIGRUNTIME char *
|
||||
SWIG_Tcl_PointerTypeFromString(char *c) {
|
||||
char d;
|
||||
/* Pointer values must start with leading underscore. NULL has no type */
|
||||
|
|
@ -213,7 +155,7 @@ SWIG_Tcl_PointerTypeFromString(char *c) {
|
|||
}
|
||||
|
||||
/* Convert a packed value value */
|
||||
static int
|
||||
SWIGRUNTIME int
|
||||
SWIG_Tcl_ConvertPacked(Tcl_Interp *interp, Tcl_Obj *obj, void *ptr, int sz, swig_type_info *ty, int flags) {
|
||||
swig_cast_info *tc;
|
||||
const char *c;
|
||||
|
|
@ -228,7 +170,7 @@ SWIG_Tcl_ConvertPacked(Tcl_Interp *interp, Tcl_Obj *obj, void *ptr, int sz, swig
|
|||
tc = SWIG_TypeCheck(c,ty);
|
||||
if (!tc) goto type_error;
|
||||
}
|
||||
return TCL_OK;
|
||||
return SWIG_OK;
|
||||
|
||||
type_error:
|
||||
|
||||
|
|
@ -236,18 +178,18 @@ type_error:
|
|||
if (ty) {
|
||||
Tcl_SetResult(interp, (char *) "Type error. Expected ", TCL_STATIC);
|
||||
Tcl_AppendElement(interp, (char *) ty->name);
|
||||
return TCL_ERROR;
|
||||
return SWIG_ERROR;
|
||||
} else {
|
||||
Tcl_SetResult(interp, (char *) "Expected packed data.", TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
return TCL_ERROR;
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/* Take a pointer and convert it to a string */
|
||||
static void
|
||||
SWIGRUNTIME void
|
||||
SWIG_Tcl_MakePtr(char *c, void *ptr, swig_type_info *ty, int flags) {
|
||||
if (ptr) {
|
||||
*(c++) = '_';
|
||||
|
|
@ -260,16 +202,16 @@ SWIG_Tcl_MakePtr(char *c, void *ptr, swig_type_info *ty, int flags) {
|
|||
}
|
||||
|
||||
/* Create a new pointer object */
|
||||
static SWIGINLINE Tcl_Obj *
|
||||
SWIGRUNTIMEINLINE Tcl_Obj *
|
||||
SWIG_Tcl_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
|
||||
Tcl_Obj *robj;
|
||||
char result[512];
|
||||
char result[SWIG_BUFFER_SIZE];
|
||||
SWIG_MakePtr(result,ptr,type,flags);
|
||||
robj = Tcl_NewStringObj(result,-1);
|
||||
return robj;
|
||||
}
|
||||
|
||||
static Tcl_Obj *
|
||||
SWIGRUNTIME Tcl_Obj *
|
||||
SWIG_Tcl_NewPackedObj(void *ptr, int sz, swig_type_info *type, int flags) {
|
||||
char result[1024];
|
||||
char *r = result;
|
||||
|
|
@ -281,160 +223,42 @@ SWIG_Tcl_NewPackedObj(void *ptr, int sz, swig_type_info *type, int flags) {
|
|||
return Tcl_NewStringObj(result,-1);
|
||||
}
|
||||
|
||||
static Tcl_HashTable swigconstTable;
|
||||
static int swigconstTableinit = 0;
|
||||
/* -----------------------------------------------------------------------------*
|
||||
* Get type list
|
||||
* -----------------------------------------------------------------------------*/
|
||||
|
||||
/* Install Constants */
|
||||
static void
|
||||
SWIG_Tcl_InstallConstants(Tcl_Interp *interp, swig_const_info constants[]) {
|
||||
int i;
|
||||
Tcl_Obj *obj;
|
||||
Tcl_HashEntry *entryPtr;
|
||||
int newobj;
|
||||
SWIGRUNTIME swig_module_info *
|
||||
SWIG_Tcl_GetModule(Tcl_Interp *interp) {
|
||||
char *data;
|
||||
swig_module_info *ret = 0;
|
||||
|
||||
/* first check if pointer already created */
|
||||
data = (char *) Tcl_GetVar(interp, "swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME,
|
||||
TCL_GLOBAL_ONLY);
|
||||
if (data) {
|
||||
SWIG_UnpackData(data, &ret, sizeof(swig_type_info **));
|
||||
}
|
||||
|
||||
if (!swigconstTableinit) {
|
||||
Tcl_InitHashTable(&swigconstTable, TCL_STRING_KEYS);
|
||||
swigconstTableinit = 1;
|
||||
}
|
||||
for (i = 0; constants[i].type; i++) {
|
||||
switch(constants[i].type) {
|
||||
case SWIG_TCL_INT:
|
||||
obj = Tcl_NewIntObj(constants[i].lvalue);
|
||||
break;
|
||||
case SWIG_TCL_FLOAT:
|
||||
obj = Tcl_NewDoubleObj(constants[i].dvalue);
|
||||
break;
|
||||
case SWIG_TCL_STRING:
|
||||
obj = Tcl_NewStringObj((char *) constants[i].pvalue,-1);
|
||||
break;
|
||||
case SWIG_TCL_POINTER:
|
||||
obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
|
||||
break;
|
||||
case SWIG_TCL_BINARY:
|
||||
obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype),0);
|
||||
break;
|
||||
default:
|
||||
obj = 0;
|
||||
break;
|
||||
}
|
||||
if (obj) {
|
||||
Tcl_ObjSetVar2(interp,Tcl_NewStringObj(constants[i].name,-1), NULL, obj, TCL_GLOBAL_ONLY);
|
||||
entryPtr = Tcl_CreateHashEntry(&swigconstTable, constants[i].name, &newobj);
|
||||
Tcl_SetHashValue(entryPtr, (ClientData) obj);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static Tcl_Obj *
|
||||
SWIG_Tcl_GetConstant(const char *key) {
|
||||
Tcl_HashEntry *entryPtr;
|
||||
if (!swigconstTableinit) return 0;
|
||||
entryPtr = Tcl_FindHashEntry(&swigconstTable, key);
|
||||
if (entryPtr) {
|
||||
return (Tcl_Obj *) Tcl_GetHashValue(entryPtr);
|
||||
}
|
||||
return 0;
|
||||
SWIGRUNTIME void
|
||||
SWIG_Tcl_SetModule(Tcl_Interp *interp, swig_module_info *module) {
|
||||
char buf[SWIG_BUFFER_SIZE];
|
||||
char *data;
|
||||
|
||||
/* create a new pointer */
|
||||
data = SWIG_PackData(buf, &module, sizeof(swig_type_info **));
|
||||
*data = 0;
|
||||
Tcl_SetVar(interp, "swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, buf, 0);
|
||||
}
|
||||
|
||||
/* Get arguments */
|
||||
static int
|
||||
SWIG_Tcl_GetArgs(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], const char *fmt, ...) {
|
||||
int argno = 0, opt = 0;
|
||||
long tempi;
|
||||
double tempd;
|
||||
const char *c;
|
||||
va_list ap;
|
||||
void *vptr;
|
||||
Tcl_Obj *obj = 0;
|
||||
swig_type_info *ty;
|
||||
/* -----------------------------------------------------------------------------*
|
||||
* Object auxiliars
|
||||
* -----------------------------------------------------------------------------*/
|
||||
|
||||
va_start(ap,fmt);
|
||||
for (c = fmt; (*c && (*c != ':') && (*c != ';')); c++,argno++) {
|
||||
if (*c == '|') {
|
||||
opt = 1;
|
||||
c++;
|
||||
}
|
||||
if (argno >= (objc-1)) {
|
||||
if (!opt) {
|
||||
Tcl_SetResult(interp, (char *) "Wrong # args. ", TCL_STATIC);
|
||||
goto argerror;
|
||||
} else {
|
||||
va_end(ap);
|
||||
return TCL_OK;
|
||||
}
|
||||
}
|
||||
|
||||
vptr = va_arg(ap,void *);
|
||||
if (vptr) {
|
||||
if (isupper(*c)) {
|
||||
obj = SWIG_GetConstant(Tcl_GetStringFromObj(objv[argno+1],0));
|
||||
if (!obj) obj = objv[argno+1];
|
||||
} else {
|
||||
obj = objv[argno+1];
|
||||
}
|
||||
switch(*c) {
|
||||
case 'i': case 'I':
|
||||
case 'l': case 'L':
|
||||
case 'h': case 'H':
|
||||
case 'b': case 'B':
|
||||
if (Tcl_GetLongFromObj(interp,obj,&tempi) != TCL_OK) goto argerror;
|
||||
if ((*c == 'i') || (*c == 'I')) *((int *)vptr) = (int)tempi;
|
||||
else if ((*c == 'l') || (*c == 'L')) *((long *)vptr) = (long)tempi;
|
||||
else if ((*c == 'h') || (*c == 'H')) *((short*)vptr) = (short)tempi;
|
||||
else if ((*c == 'b') || (*c == 'B')) *((unsigned char *)vptr) = (unsigned char)tempi;
|
||||
break;
|
||||
case 'f': case 'F':
|
||||
case 'd': case 'D':
|
||||
if (Tcl_GetDoubleFromObj(interp,obj,&tempd) != TCL_OK) goto argerror;
|
||||
if ((*c == 'f') || (*c == 'F')) *((float *) vptr) = (float)tempd;
|
||||
else if ((*c == 'd') || (*c == 'D')) *((double*) vptr) = tempd;
|
||||
break;
|
||||
case 's': case 'S':
|
||||
if (*(c+1) == '#') {
|
||||
int *vlptr = (int *) va_arg(ap, void *);
|
||||
*((char **) vptr) = Tcl_GetStringFromObj(obj, vlptr);
|
||||
c++;
|
||||
} else {
|
||||
*((char **)vptr) = Tcl_GetStringFromObj(obj,NULL);
|
||||
}
|
||||
break;
|
||||
case 'c': case 'C':
|
||||
*((char *)vptr) = *(Tcl_GetStringFromObj(obj,NULL));
|
||||
break;
|
||||
case 'p': case 'P':
|
||||
ty = (swig_type_info *) va_arg(ap, void *);
|
||||
if (SWIG_Tcl_ConvertPtr(interp, obj, (void **) vptr, ty, SWIG_POINTER_EXCEPTION) == TCL_ERROR) goto argerror;
|
||||
break;
|
||||
case 'o': case 'O':
|
||||
*((Tcl_Obj **)vptr) = objv[argno+1];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((*c != ';') && ((objc-1) > argno)) {
|
||||
Tcl_SetResult(interp, (char *) "Wrong # args.", TCL_STATIC);
|
||||
goto argerror;
|
||||
}
|
||||
va_end(ap);
|
||||
return TCL_OK;
|
||||
|
||||
argerror:
|
||||
{
|
||||
char temp[32];
|
||||
sprintf(temp,"%d", argno+1);
|
||||
c = strchr(fmt,':');
|
||||
if (!c) c = strchr(fmt,';');
|
||||
if (!c) c = (char *)"";
|
||||
Tcl_AppendResult(interp,c," argument ", temp, NULL);
|
||||
va_end(ap);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SWIGRUNTIME void
|
||||
SWIG_Tcl_ObjectDelete(ClientData clientData) {
|
||||
swig_instance *si = (swig_instance *) clientData;
|
||||
if ((si) && (si->destroy) && (SWIG_Disown(si->thisvalue))) {
|
||||
|
|
@ -447,7 +271,7 @@ SWIG_Tcl_ObjectDelete(ClientData clientData) {
|
|||
}
|
||||
|
||||
/* Function to invoke object methods given an instance */
|
||||
static int
|
||||
SWIGRUNTIME int
|
||||
SWIG_Tcl_MethodCommand(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST _objv[]) {
|
||||
char *method, *attrname;
|
||||
swig_instance *inst = (swig_instance *) clientData;
|
||||
|
|
@ -598,7 +422,6 @@ SWIG_Tcl_MethodCommand(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_
|
|||
Tcl_SetResult(interp,(char *) "Invalid attribute name.", TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
Tcl_SetResult(interp, (char *) "Invalid method. Must be one of: configure cget -acquire -disown -delete", TCL_STATIC);
|
||||
cls = inst->classptr;
|
||||
bi = 0;
|
||||
|
|
@ -628,8 +451,33 @@ SWIG_Tcl_MethodCommand(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_
|
|||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
/* This function takes the current result and turns it into an object command */
|
||||
SWIGRUNTIME Tcl_Obj *
|
||||
SWIG_Tcl_NewInstanceObj(Tcl_Interp *interp, void *thisvalue, swig_type_info *type, int flags) {
|
||||
Tcl_Obj *robj = SWIG_NewPointerObj(thisvalue, type,0);
|
||||
/* Check to see if this pointer belongs to a class or not */
|
||||
if ((type->clientdata) && (interp)) {
|
||||
Tcl_CmdInfo ci;
|
||||
char *name;
|
||||
name = Tcl_GetStringFromObj(robj,NULL);
|
||||
if (!Tcl_GetCommandInfo(interp,name, &ci) || (flags)) {
|
||||
swig_instance *newinst = (swig_instance *) malloc(sizeof(swig_instance));
|
||||
newinst->thisptr = Tcl_DuplicateObj(robj);
|
||||
Tcl_IncrRefCount(newinst->thisptr);
|
||||
newinst->thisvalue = thisvalue;
|
||||
newinst->classptr = (swig_class *) type->clientdata;
|
||||
newinst->destroy = flags;
|
||||
newinst->cmdtok = Tcl_CreateObjCommand(interp, Tcl_GetStringFromObj(robj,NULL), (swig_wrapper_func) SWIG_MethodCommand, (ClientData) newinst, (swig_delete_func) SWIG_ObjectDelete);
|
||||
if (flags) {
|
||||
SWIG_Acquire(thisvalue);
|
||||
}
|
||||
}
|
||||
}
|
||||
return robj;
|
||||
}
|
||||
|
||||
/* Function to create objects */
|
||||
static int
|
||||
SWIGRUNTIME int
|
||||
SWIG_Tcl_ObjectConstructor(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
|
||||
Tcl_Obj *newObj = 0;
|
||||
void *thisvalue = 0;
|
||||
|
|
@ -689,7 +537,7 @@ SWIG_Tcl_ObjectConstructor(ClientData clientData, Tcl_Interp *interp, int objc,
|
|||
Tcl_SetResult(interp, (char *) "No constructor available.", TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (SWIG_Tcl_ConvertPtr(interp,newObj, (void **) &thisvalue, *(classptr->type), SWIG_POINTER_EXCEPTION) == TCL_ERROR) {
|
||||
if (SWIG_Tcl_ConvertPtr(interp,newObj, (void **) &thisvalue, *(classptr->type), 0) != SWIG_OK) {
|
||||
Tcl_DecrRefCount(newObj);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
|
@ -706,81 +554,106 @@ SWIG_Tcl_ObjectConstructor(ClientData clientData, Tcl_Interp *interp, int objc,
|
|||
return TCL_OK;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------*
|
||||
* Get arguments
|
||||
* -----------------------------------------------------------------------------*/
|
||||
SWIGRUNTIME int
|
||||
SWIG_Tcl_GetArgs(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], const char *fmt, ...) {
|
||||
int argno = 0, opt = 0;
|
||||
long tempi;
|
||||
double tempd;
|
||||
const char *c;
|
||||
va_list ap;
|
||||
void *vptr;
|
||||
Tcl_Obj *obj = 0;
|
||||
swig_type_info *ty;
|
||||
|
||||
/* This function takes the current result and turns it into an object command */
|
||||
static Tcl_Obj *
|
||||
SWIG_Tcl_NewInstanceObj(Tcl_Interp *interp, void *thisvalue, swig_type_info *type, int flags) {
|
||||
Tcl_Obj *robj = SWIG_NewPointerObj(thisvalue, type,0);
|
||||
/* Check to see if this pointer belongs to a class or not */
|
||||
if ((type->clientdata) && (interp)) {
|
||||
Tcl_CmdInfo ci;
|
||||
char *name;
|
||||
name = Tcl_GetStringFromObj(robj,NULL);
|
||||
if (!Tcl_GetCommandInfo(interp,name, &ci) || (flags)) {
|
||||
swig_instance *newinst = (swig_instance *) malloc(sizeof(swig_instance));
|
||||
newinst->thisptr = Tcl_DuplicateObj(robj);
|
||||
Tcl_IncrRefCount(newinst->thisptr);
|
||||
newinst->thisvalue = thisvalue;
|
||||
newinst->classptr = (swig_class *) type->clientdata;
|
||||
newinst->destroy = flags;
|
||||
newinst->cmdtok = Tcl_CreateObjCommand(interp, Tcl_GetStringFromObj(robj,NULL), (swig_wrapper_func) SWIG_MethodCommand, (ClientData) newinst, (swig_delete_func) SWIG_ObjectDelete);
|
||||
if (flags) {
|
||||
SWIG_Acquire(thisvalue);
|
||||
va_start(ap,fmt);
|
||||
for (c = fmt; (*c && (*c != ':') && (*c != ';')); c++,argno++) {
|
||||
if (*c == '|') {
|
||||
opt = 1;
|
||||
c++;
|
||||
}
|
||||
if (argno >= (objc-1)) {
|
||||
if (!opt) {
|
||||
Tcl_SetResult(interp, (char *) "Wrong number of arguments ", TCL_STATIC);
|
||||
goto argerror;
|
||||
} else {
|
||||
va_end(ap);
|
||||
return TCL_OK;
|
||||
}
|
||||
}
|
||||
|
||||
vptr = va_arg(ap,void *);
|
||||
if (vptr) {
|
||||
if (isupper(*c)) {
|
||||
obj = SWIG_Tcl_GetConstantObj(Tcl_GetStringFromObj(objv[argno+1],0));
|
||||
if (!obj) obj = objv[argno+1];
|
||||
} else {
|
||||
obj = objv[argno+1];
|
||||
}
|
||||
switch(*c) {
|
||||
case 'i': case 'I':
|
||||
case 'l': case 'L':
|
||||
case 'h': case 'H':
|
||||
case 'b': case 'B':
|
||||
if (Tcl_GetLongFromObj(interp,obj,&tempi) != TCL_OK) goto argerror;
|
||||
if ((*c == 'i') || (*c == 'I')) *((int *)vptr) = (int)tempi;
|
||||
else if ((*c == 'l') || (*c == 'L')) *((long *)vptr) = (long)tempi;
|
||||
else if ((*c == 'h') || (*c == 'H')) *((short*)vptr) = (short)tempi;
|
||||
else if ((*c == 'b') || (*c == 'B')) *((unsigned char *)vptr) = (unsigned char)tempi;
|
||||
break;
|
||||
case 'f': case 'F':
|
||||
case 'd': case 'D':
|
||||
if (Tcl_GetDoubleFromObj(interp,obj,&tempd) != TCL_OK) goto argerror;
|
||||
if ((*c == 'f') || (*c == 'F')) *((float *) vptr) = (float)tempd;
|
||||
else if ((*c == 'd') || (*c == 'D')) *((double*) vptr) = tempd;
|
||||
break;
|
||||
case 's': case 'S':
|
||||
if (*(c+1) == '#') {
|
||||
int *vlptr = (int *) va_arg(ap, void *);
|
||||
*((char **) vptr) = Tcl_GetStringFromObj(obj, vlptr);
|
||||
c++;
|
||||
} else {
|
||||
*((char **)vptr) = Tcl_GetStringFromObj(obj,NULL);
|
||||
}
|
||||
break;
|
||||
case 'c': case 'C':
|
||||
*((char *)vptr) = *(Tcl_GetStringFromObj(obj,NULL));
|
||||
break;
|
||||
case 'p': case 'P':
|
||||
ty = (swig_type_info *) va_arg(ap, void *);
|
||||
if (SWIG_Tcl_ConvertPtr(interp, obj, (void **) vptr, ty, 0) != SWIG_OK) goto argerror;
|
||||
break;
|
||||
case 'o': case 'O':
|
||||
*((Tcl_Obj **)vptr) = objv[argno+1];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return robj;
|
||||
}
|
||||
|
||||
/* Structure for command table */
|
||||
typedef struct {
|
||||
const char *name;
|
||||
int (*wrapper)(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST []);
|
||||
ClientData clientdata;
|
||||
} swig_command_info;
|
||||
|
||||
/* Structure for variable linking table */
|
||||
typedef struct {
|
||||
const char *name;
|
||||
void *addr;
|
||||
char * (*get)(ClientData, Tcl_Interp *, char *, char *, int);
|
||||
char * (*set)(ClientData, Tcl_Interp *, char *, char *, int);
|
||||
} swig_var_info;
|
||||
|
||||
|
||||
/* Contract support */
|
||||
|
||||
#define SWIG_contract_assert(expr, msg) if (!(expr)) { Tcl_SetResult(interp, (char *) msg, TCL_STATIC ); goto fail; } else
|
||||
|
||||
static swig_module_info *
|
||||
SWIG_Tcl_GetModule(Tcl_Interp *interp) {
|
||||
char *data;
|
||||
swig_module_info *ret = 0;
|
||||
|
||||
/* first check if pointer already created */
|
||||
data = (char *) Tcl_GetVar(interp, "swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TCL_GLOBAL_ONLY);
|
||||
if (data) {
|
||||
SWIG_UnpackData(data, &ret, sizeof(swig_type_info **));
|
||||
if ((*c != ';') && ((objc-1) > argno)) {
|
||||
Tcl_SetResult(interp, (char *) "Wrong # args.", TCL_STATIC);
|
||||
goto argerror;
|
||||
}
|
||||
va_end(ap);
|
||||
return TCL_OK;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
SWIG_Tcl_SetModule(Tcl_Interp *interp, swig_module_info *module) {
|
||||
char buf[512];
|
||||
char *data;
|
||||
|
||||
/* create a new pointer */
|
||||
data = SWIG_PackData(buf, &module, sizeof(swig_type_info **));
|
||||
*data = 0;
|
||||
Tcl_SetVar(interp, "swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, buf, 0);
|
||||
argerror:
|
||||
{
|
||||
char temp[32];
|
||||
sprintf(temp,"%d", argno+1);
|
||||
c = strchr(fmt,':');
|
||||
if (!c) c = strchr(fmt,';');
|
||||
if (!c) c = (char *)"";
|
||||
Tcl_AppendResult(interp,c," argument ", temp, NULL);
|
||||
va_end(ap);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
13
Lib/tcl/tclruntime.swg
Normal file
13
Lib/tcl/tclruntime.swg
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/* tcl.h has to appear first */
|
||||
%insert(runtime) %{
|
||||
#include <stdio.h>
|
||||
#include <tcl.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <ctype.h>
|
||||
%}
|
||||
|
||||
%insert(runtime) "swigrun.swg"; /* Common C API type-checking code */
|
||||
%insert(runtime) "tclapi.swg"; /* SWIG/Tcl API */
|
||||
%insert(runtime) "tclrun.swg"; /* Tcl run-time code */
|
||||
36
Lib/tcl/tclstrings.swg
Normal file
36
Lib/tcl/tclstrings.swg
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/* ------------------------------------------------------------
|
||||
* utility methods for char strings
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%fragment("SWIG_AsCharPtrAndSize","header") {
|
||||
SWIGINTERN int
|
||||
SWIG_AsCharPtrAndSize(Tcl_Obj *obj, char** cptr, size_t* psize, int *alloc)
|
||||
{
|
||||
int len = 0;
|
||||
char *cstr = Tcl_GetStringFromObj(obj, &len);
|
||||
if (cstr) {
|
||||
if (cptr) *cptr = cstr;
|
||||
if (psize) *psize = len + 1;
|
||||
if (alloc) *alloc = SWIG_OLDOBJ;
|
||||
return SWIG_OK;
|
||||
}
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
%fragment("SWIG_FromCharPtrAndSize","header",
|
||||
fragment="<limits.h>") {
|
||||
SWIGINTERNINLINE Tcl_Obj *
|
||||
SWIG_FromCharPtrAndSize(const char* carray, size_t size)
|
||||
{
|
||||
return (size < INT_MAX) ? Tcl_NewStringObj(carray, SWIG_numeric_cast(size,int)) : NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* The plain char * handling
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%include <typemaps/strings.swg>
|
||||
%typemap_string(char, Char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, strlen)
|
||||
13
Lib/tcl/tclswigtype.swg
Normal file
13
Lib/tcl/tclswigtype.swg
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
%include <typemaps/swigtype.swg>
|
||||
|
||||
%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;
|
||||
}
|
||||
|
||||
42
Lib/tcl/tcltypemaps.swg
Normal file
42
Lib/tcl/tcltypemaps.swg
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Typemap specializations
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* no director supported in Tcl */
|
||||
#ifdef SWIG_DIRECTOR_TYPEMAPS
|
||||
#undef SWIG_DIRECTOR_TYPEMAPS
|
||||
#endif
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Basic definitions
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%define_swig_object(Tcl_Obj *)
|
||||
|
||||
#define SWIG_SetResultObj(obj) $result = obj
|
||||
#define SWIG_AppendResultObj(obj) $result = (Tcl_ListObjAppendElement(NULL,$result,obj) == TCL_OK) ? $result : NULL;
|
||||
#define SWIG_SetConstantObj(name, obj) SWIG_Tcl_SetConstantObj(interp, name, obj)
|
||||
#define SWIG_NoneObject() NULL
|
||||
|
||||
/* error manipulation */
|
||||
#define SWIG_ErrorType(code) SWIG_Tcl_ErrorType(code)
|
||||
#define SWIG_SetErrorObj(code,obj) SWIG_Tcl_SetErrorObj(interp,SWIG_ErrorType(code),obj)
|
||||
#define SWIG_SetErrorMsg(code,msg) SWIG_Tcl_SetErrorMsg(interp,SWIG_ErrorType(code),msg)
|
||||
#define SWIG_ExceptionObj(d,type,obj) SWIG_Tcl_SetErrorObj(interp,type,obj)
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* All the typemaps
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include "tclfragments.swg"
|
||||
|
||||
%include <tclswigtype.swg>
|
||||
%include <typemaps/void.swg>
|
||||
%include <typemaps/valtypes.swg>
|
||||
%include <typemaps/ptrtypes.swg>
|
||||
%include <typemaps/swigobject.swg>
|
||||
%include <typemaps/inoutlist.swg>
|
||||
%include <tclprimtypes.swg>
|
||||
%include <tclstrings.swg>
|
||||
%include <typemaps/misctypes.swg>
|
||||
%include <typemaps/enumint.swg>
|
||||
5
Lib/tcl/tcluserdir.swg
Normal file
5
Lib/tcl/tcluserdir.swg
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Special user directives
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
36
Lib/tcl/tclwstrings.swg
Normal file
36
Lib/tcl/tclwstrings.swg
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/* ------------------------------------------------------------
|
||||
* utility methods for wchar strings
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%fragment("SWIG_AsCharPtrAndSize","header") {
|
||||
SWIGINTERN int
|
||||
SWIG_AsWCharPtrAndSize(Tcl_Obj *obj, wchar_t** cptr, size_t* psize, int *alloc)
|
||||
{
|
||||
int len = 0;
|
||||
wchar_t *cstr = Tcl_GetUnicodeFromObj(obj, &len);
|
||||
if (cstr) {
|
||||
if (cptr) *cptr = cstr;
|
||||
if (psize) *psize = len + 1;
|
||||
if (alloc) *alloc = SWIG_OLDOBJ;
|
||||
return SWIG_OK;
|
||||
}
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_FromWCharPtrAndSize","header",
|
||||
fragment="<limits.h>") {
|
||||
SWIGINTERNINLINE Tcl_Obj *
|
||||
SWIG_FromWCharPtrAndSize(const wchar_t* carray, size_t size)
|
||||
{
|
||||
return (size < INT_MAX) ? Tcl_NewUnicodeObj(carray, SWIG_numeric_cast(size,int)) : NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* The plain char * handling
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%include <typemaps/strings.swg>
|
||||
%typemap_string(wchar_t, WChar, SWIG_AsWCharPtrAndSize, SWIG_FromWCharPtrAndSize, wcslen)
|
||||
|
|
@ -1,507 +1 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* typemaps.i
|
||||
*
|
||||
* Swig typemap library for Tcl8. This file contains various sorts
|
||||
* of typemaps for modifying Swig's code generation.
|
||||
*
|
||||
* Author: David Beazley (beazley@cs.uchicago.edu)
|
||||
*
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
The SWIG typemap library provides a language independent mechanism for
|
||||
supporting output arguments, input values, and other C function
|
||||
calling mechanisms. The primary use of the library is to provide a
|
||||
better interface to certain C function--especially those involving
|
||||
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);
|
||||
|
||||
*/
|
||||
|
||||
%typemap(in) double *INPUT(double temp), double &INPUT(double temp)
|
||||
{
|
||||
if (Tcl_GetDoubleFromObj(interp,$input,&temp) == TCL_ERROR) {
|
||||
SWIG_fail;
|
||||
}
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(in) float *INPUT(double dvalue, float temp), float &INPUT(double dvalue, float temp)
|
||||
{
|
||||
if (Tcl_GetDoubleFromObj(interp,$input,&dvalue) == TCL_ERROR) {
|
||||
SWIG_fail;
|
||||
}
|
||||
temp = (float) dvalue;
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(in) int *INPUT(int temp), int &INPUT(int temp)
|
||||
{
|
||||
if (Tcl_GetIntFromObj(interp,$input,&temp) == TCL_ERROR) {
|
||||
SWIG_fail;
|
||||
}
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(in) short *INPUT(int ivalue, short temp), short &INPUT(int ivalue, short temp)
|
||||
{
|
||||
if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) {
|
||||
SWIG_fail;
|
||||
}
|
||||
temp = (short) ivalue;
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(in) long *INPUT(int ivalue, long temp), long &INPUT(int ivalue, long temp)
|
||||
{
|
||||
if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) {
|
||||
SWIG_fail;
|
||||
}
|
||||
temp = (long) ivalue;
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(in) unsigned int *INPUT(int ivalue, unsigned int temp),
|
||||
unsigned int &INPUT(int ivalue, unsigned int temp)
|
||||
{
|
||||
if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) {
|
||||
SWIG_fail;
|
||||
}
|
||||
temp = (unsigned int) ivalue;
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(in) unsigned short *INPUT(int ivalue, unsigned short temp),
|
||||
unsigned short &INPUT(int ivalue, unsigned short temp)
|
||||
{
|
||||
if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) {
|
||||
SWIG_fail;
|
||||
}
|
||||
temp = (unsigned short) ivalue;
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(in) unsigned long *INPUT(int ivalue, unsigned long temp),
|
||||
unsigned long &INPUT(int ivalue, unsigned long temp)
|
||||
{
|
||||
if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) {
|
||||
SWIG_fail;
|
||||
}
|
||||
temp = (unsigned long) ivalue;
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(in) unsigned char *INPUT(int ivalue, unsigned char temp),
|
||||
unsigned char &INPUT(int ivalue, unsigned char temp)
|
||||
{
|
||||
if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) {
|
||||
SWIG_fail;
|
||||
}
|
||||
temp = (unsigned char) ivalue;
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(in) signed char *INPUT(int ivalue, signed char temp),
|
||||
signed char &INPUT(int ivalue, signed char temp)
|
||||
{
|
||||
if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) {
|
||||
SWIG_fail;
|
||||
}
|
||||
temp = (signed char) ivalue;
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(in) bool *INPUT(int ivalue, bool temp),
|
||||
bool &INPUT(int ivalue, bool temp)
|
||||
{
|
||||
if (Tcl_GetIntFromObj(interp,$input,&ivalue) == TCL_ERROR) {
|
||||
SWIG_fail;
|
||||
}
|
||||
temp = ivalue ? true : false;
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(in) long long *INPUT($*1_ltype temp),
|
||||
long long &INPUT($*1_ltype temp)
|
||||
{
|
||||
temp = ($*1_ltype) strtoll(Tcl_GetStringFromObj($input,NULL),0,0);
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(in) unsigned long long *INPUT($*1_ltype temp),
|
||||
unsigned long long &INPUT($*1_ltype temp)
|
||||
{
|
||||
temp = ($*1_ltype) strtoull(Tcl_GetStringFromObj($input,NULL),0,0);
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
// 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 Tcl list.
|
||||
|
||||
int *OUTPUT
|
||||
short *OUTPUT
|
||||
long *OUTPUT
|
||||
long long *OUTPUT
|
||||
unsigned int *OUTPUT
|
||||
unsigned short *OUTPUT
|
||||
unsigned long *OUTPUT
|
||||
unsigned long long *OUTPUT
|
||||
unsigned char *OUTPUT
|
||||
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 Tcl output of the function would be a list containing both
|
||||
output values.
|
||||
|
||||
*/
|
||||
|
||||
%typemap(in,numinputs=0) int *OUTPUT(int temp),
|
||||
short *OUTPUT(short temp),
|
||||
long *OUTPUT(long temp),
|
||||
unsigned int *OUTPUT(unsigned int temp),
|
||||
unsigned short *OUTPUT(unsigned short temp),
|
||||
unsigned long *OUTPUT(unsigned long temp),
|
||||
unsigned char *OUTPUT(unsigned char temp),
|
||||
signed char *OUTPUT(signed char temp),
|
||||
bool *OUTPUT(bool temp),
|
||||
float *OUTPUT(float temp),
|
||||
double *OUTPUT(double temp),
|
||||
long long *OUTPUT($*1_ltype temp),
|
||||
unsigned long long *OUTPUT($*1_ltype temp),
|
||||
int &OUTPUT(int temp),
|
||||
short &OUTPUT(short temp),
|
||||
long &OUTPUT(long temp),
|
||||
unsigned int &OUTPUT(unsigned int temp),
|
||||
unsigned short &OUTPUT(unsigned short temp),
|
||||
unsigned long &OUTPUT(unsigned long temp),
|
||||
signed char &OUTPUT(signed char temp),
|
||||
bool &OUTPUT(bool temp),
|
||||
unsigned char &OUTPUT(unsigned char temp),
|
||||
float &OUTPUT(float temp),
|
||||
double &OUTPUT(double temp),
|
||||
long long &OUTPUT($*1_ltype temp),
|
||||
unsigned long long &OUTPUT($*1_ltype temp)
|
||||
"$1 = &temp;";
|
||||
|
||||
%typemap(argout) int *OUTPUT, int &OUTPUT,
|
||||
short *OUTPUT, short &OUTPUT,
|
||||
long *OUTPUT, long &OUTPUT,
|
||||
unsigned int *OUTPUT, unsigned int &OUTPUT,
|
||||
unsigned short *OUTPUT, unsigned short &OUTPUT,
|
||||
unsigned long *OUTPUT, unsigned long &OUTPUT,
|
||||
unsigned char *OUTPUT, unsigned char &OUTPUT,
|
||||
signed char *OUTPUT, signed char &OUTPUT,
|
||||
bool *OUTPUT, bool &OUTPUT
|
||||
{
|
||||
Tcl_Obj *o;
|
||||
o = Tcl_NewIntObj((int) *($1));
|
||||
Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),o);
|
||||
}
|
||||
|
||||
%typemap(argout) float *OUTPUT, float &OUTPUT,
|
||||
double *OUTPUT, double &OUTPUT
|
||||
{
|
||||
Tcl_Obj *o;
|
||||
o = Tcl_NewDoubleObj((double) *($1));
|
||||
Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),o);
|
||||
}
|
||||
|
||||
%typemap(argout) long long *OUTPUT, long long &OUTPUT
|
||||
{
|
||||
char temp[256];
|
||||
Tcl_Obj *o;
|
||||
sprintf(temp,"%lld",(long long)*($1));
|
||||
o = Tcl_NewStringObj(temp,-1);
|
||||
Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),o);
|
||||
}
|
||||
|
||||
%typemap(argout) unsigned long long *OUTPUT, unsigned long long &OUTPUT
|
||||
{
|
||||
char temp[256];
|
||||
Tcl_Obj *o;
|
||||
sprintf(temp,"%llu",(unsigned long long)*($1));
|
||||
o = Tcl_NewStringObj(temp,-1);
|
||||
Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),o);
|
||||
}
|
||||
|
||||
// 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 Tcl list.
|
||||
|
||||
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 Tcl). Rather, the modified input value shows
|
||||
up as the return value of the function. Thus, to apply this function
|
||||
to a Tcl variable you might do this :
|
||||
|
||||
set x [neg $x]
|
||||
|
||||
*/
|
||||
|
||||
|
||||
%typemap(in) int *INOUT = int *INPUT;
|
||||
%typemap(in) short *INOUT = short *INPUT;
|
||||
%typemap(in) long *INOUT = long *INPUT;
|
||||
%typemap(in) unsigned int *INOUT = unsigned int *INPUT;
|
||||
%typemap(in) unsigned short *INOUT = unsigned short *INPUT;
|
||||
%typemap(in) unsigned long *INOUT = unsigned long *INPUT;
|
||||
%typemap(in) unsigned char *INOUT = unsigned char *INPUT;
|
||||
%typemap(in) signed char *INOUT = signed char *INPUT;
|
||||
%typemap(in) bool *INOUT = bool *INPUT;
|
||||
%typemap(in) float *INOUT = float *INPUT;
|
||||
%typemap(in) double *INOUT = double *INPUT;
|
||||
%typemap(in) long long *INOUT = long long *INPUT;
|
||||
%typemap(in) unsigned long long *INOUT = unsigned long long *INPUT;
|
||||
|
||||
%typemap(in) int &INOUT = int &INPUT;
|
||||
%typemap(in) short &INOUT = short &INPUT;
|
||||
%typemap(in) long &INOUT = long &INPUT;
|
||||
%typemap(in) unsigned int &INOUT = unsigned int &INPUT;
|
||||
%typemap(in) unsigned short &INOUT = unsigned short &INPUT;
|
||||
%typemap(in) unsigned long &INOUT = unsigned long &INPUT;
|
||||
%typemap(in) unsigned char &INOUT = unsigned char &INPUT;
|
||||
%typemap(in) signed char &INOUT = signed char &INPUT;
|
||||
%typemap(in) bool &INOUT = bool &INPUT;
|
||||
%typemap(in) float &INOUT = float &INPUT;
|
||||
%typemap(in) double &INOUT = double &INPUT;
|
||||
%typemap(in) long long &INOUT = long long &INPUT;
|
||||
%typemap(in) unsigned long long &INOUT = unsigned long long &INPUT;
|
||||
|
||||
%typemap(argout) int *INOUT = int *OUTPUT;
|
||||
%typemap(argout) short *INOUT = short *OUTPUT;
|
||||
%typemap(argout) long *INOUT = long *OUTPUT;
|
||||
%typemap(argout) unsigned int *INOUT = unsigned int *OUTPUT;
|
||||
%typemap(argout) unsigned short *INOUT = unsigned short *OUTPUT;
|
||||
%typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT;
|
||||
%typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT;
|
||||
%typemap(argout) signed char *INOUT = signed char *OUTPUT;
|
||||
%typemap(argout) bool *INOUT = bool *OUTPUT;
|
||||
%typemap(argout) float *INOUT = float *OUTPUT;
|
||||
%typemap(argout) double *INOUT = double *OUTPUT;
|
||||
%typemap(argout) long long *INOUT = long long *OUTPUT;
|
||||
%typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT;
|
||||
|
||||
%typemap(argout) int &INOUT = int &OUTPUT;
|
||||
%typemap(argout) short &INOUT = short &OUTPUT;
|
||||
%typemap(argout) long &INOUT = long &OUTPUT;
|
||||
%typemap(argout) unsigned int &INOUT = unsigned int &OUTPUT;
|
||||
%typemap(argout) unsigned short &INOUT = unsigned short &OUTPUT;
|
||||
%typemap(argout) unsigned long &INOUT = unsigned long &OUTPUT;
|
||||
%typemap(argout) unsigned char &INOUT = unsigned char &OUTPUT;
|
||||
%typemap(argout) signed char &INOUT = signed char &OUTPUT;
|
||||
%typemap(argout) bool &INOUT = bool &OUTPUT;
|
||||
%typemap(argout) float &INOUT = float &OUTPUT;
|
||||
%typemap(argout) double &INOUT = double &OUTPUT;
|
||||
%typemap(argout) long long &INOUT = long long &OUTPUT;
|
||||
%typemap(argout) unsigned long long &INOUT = unsigned long long &OUTPUT;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Special types
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// If interp * appears as a function argument, we ignore it and get
|
||||
// it from the wrapper function.
|
||||
|
||||
/*
|
||||
The typemaps.i library also provides the following mappings :
|
||||
|
||||
Tcl_Interp *interp
|
||||
|
||||
Passes the current Tcl_Interp value directly to a C function.
|
||||
This can be used to work with existing wrapper functions or
|
||||
if you just need the interp value for some reason. When used,
|
||||
the 'interp' parameter becomes hidden in the Tcl interface--that
|
||||
is, you don't specify it explicitly. SWIG fills in its value
|
||||
automatically.
|
||||
|
||||
int Tcl_Result
|
||||
|
||||
Makes the integer return code of a function the return value
|
||||
of a SWIG generated wrapper function. For example :
|
||||
|
||||
int foo() {
|
||||
... do stuff ...
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
could be wrapped as follows :
|
||||
|
||||
%include typemaps.i
|
||||
%apply int Tcl_Result { int foo };
|
||||
int foo();
|
||||
|
||||
*/
|
||||
|
||||
%typemap(in,numinputs=0) Tcl_Interp *interp {
|
||||
$1 = interp;
|
||||
}
|
||||
|
||||
// If return code is a Tcl_Result, simply pass it on
|
||||
|
||||
%typemap(out) int Tcl_Result {
|
||||
return $1;
|
||||
}
|
||||
|
||||
/* Overloading information */
|
||||
|
||||
%typemap(typecheck) double *INPUT = double;
|
||||
%typemap(typecheck) bool *INPUT = bool;
|
||||
%typemap(typecheck) signed char *INPUT = signed char;
|
||||
%typemap(typecheck) unsigned char *INPUT = unsigned char;
|
||||
%typemap(typecheck) unsigned long *INPUT = unsigned long;
|
||||
%typemap(typecheck) unsigned short *INPUT = unsigned short;
|
||||
%typemap(typecheck) unsigned int *INPUT = unsigned int;
|
||||
%typemap(typecheck) long *INPUT = long;
|
||||
%typemap(typecheck) short *INPUT = short;
|
||||
%typemap(typecheck) int *INPUT = int;
|
||||
%typemap(typecheck) float *INPUT = float;
|
||||
%typemap(typecheck) long long *INPUT = long long;
|
||||
%typemap(typecheck) unsigned long long *INPUT = unsigned long long;
|
||||
|
||||
%typemap(typecheck) double &INPUT = double;
|
||||
%typemap(typecheck) bool &INPUT = bool;
|
||||
%typemap(typecheck) signed char &INPUT = signed char;
|
||||
%typemap(typecheck) unsigned char &INPUT = unsigned char;
|
||||
%typemap(typecheck) unsigned long &INPUT = unsigned long;
|
||||
%typemap(typecheck) unsigned short &INPUT = unsigned short;
|
||||
%typemap(typecheck) unsigned int &INPUT = unsigned int;
|
||||
%typemap(typecheck) long &INPUT = long;
|
||||
%typemap(typecheck) short &INPUT = short;
|
||||
%typemap(typecheck) int &INPUT = int;
|
||||
%typemap(typecheck) float &INPUT = float;
|
||||
%typemap(typecheck) long long &INPUT = long long;
|
||||
%typemap(typecheck) unsigned long long &INPUT = unsigned long long;
|
||||
|
||||
%typemap(typecheck) double *INOUT = double;
|
||||
%typemap(typecheck) bool *INOUT = bool;
|
||||
%typemap(typecheck) signed char *INOUT = signed char;
|
||||
%typemap(typecheck) unsigned char *INOUT = unsigned char;
|
||||
%typemap(typecheck) unsigned long *INOUT = unsigned long;
|
||||
%typemap(typecheck) unsigned short *INOUT = unsigned short;
|
||||
%typemap(typecheck) unsigned int *INOUT = unsigned int;
|
||||
%typemap(typecheck) long *INOUT = long;
|
||||
%typemap(typecheck) short *INOUT = short;
|
||||
%typemap(typecheck) int *INOUT = int;
|
||||
%typemap(typecheck) float *INOUT = float;
|
||||
%typemap(typecheck) long long *INOUT = long long;
|
||||
%typemap(typecheck) unsigned long long *INOUT = unsigned long long;
|
||||
|
||||
%typemap(typecheck) double &INOUT = double;
|
||||
%typemap(typecheck) bool &INOUT = bool;
|
||||
%typemap(typecheck) signed char &INOUT = signed char;
|
||||
%typemap(typecheck) unsigned char &INOUT = unsigned char;
|
||||
%typemap(typecheck) unsigned long &INOUT = unsigned long;
|
||||
%typemap(typecheck) unsigned short &INOUT = unsigned short;
|
||||
%typemap(typecheck) unsigned int &INOUT = unsigned int;
|
||||
%typemap(typecheck) long &INOUT = long;
|
||||
%typemap(typecheck) short &INOUT = short;
|
||||
%typemap(typecheck) int &INOUT = int;
|
||||
%typemap(typecheck) float &INOUT = float;
|
||||
%typemap(typecheck) long long &INOUT = long long;
|
||||
%typemap(typecheck) unsigned long long &INOUT = unsigned long long;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
%include <typemaps/typemaps.swg>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue