Since I have made several changes to SWIG over the years to accomodate

special cases and other things in wxPython, and since I plan on making
several more, I've decided to put the SWIG sources in wxPython's CVS
instead of relying on maintaining patches.  This effectivly becomes a
fork of an obsolete version of SWIG, :-( but since SWIG 1.3 still
doesn't have some things I rely on in 1.1, not to mention that my
custom patches would all have to be redone, I felt that this is the
easier road to take.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15307 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2002-04-29 19:56:57 +00:00
parent 3bd1e03385
commit c90f71dd8c
135 changed files with 51307 additions and 1 deletions

View File

@@ -0,0 +1,135 @@
# Generated automatically from Makefile.in by configure.
# ---------------------------------------------------------------
# $Header$
# SWIG Tcl/Tk Makefile
#
# This file can be used to build various Tcl extensions with SWIG.
# By default this file is set up for dynamic loading, but it can
# be easily customized for static extensions by modifying various
# portions of the file.
#
# SRCS = C source files
# CXXSRCS = C++ source files
# OBJCSRCS = Objective-C source files
# OBJS = Additional .o files (compiled previously)
# INTERFACE = SWIG interface file
# TARGET = Name of target module or executable
#
# Many portions of this file were created by the SWIG configure
# script and should already reflect your machine. However, you
# may need to modify the Makefile to reflect your specific
# application.
#----------------------------------------------------------------
SRCS =
CXXSRCS =
OBJCSRCS =
OBJS =
INTERFACE =
WRAPFILE = $(INTERFACE:.i=_wrap.c)
WRAPOBJ = $(INTERFACE:.i=_wrap.o)
TARGET = module.so # Use this kind of target for dynamic loading
#TARGET = my_tclsh # Use this target for static linking
prefix = /usr/local
exec_prefix = ${prefix}
CC = cc
CXX = CC
OBJC = cc -Wno-import # -Wno-import needed for gcc
CFLAGS =
INCLUDE =
LIBS =
# SWIG Options
# SWIG = location of the SWIG executable
# SWIGOPT = SWIG compiler options
# SWIGCC = Compiler used to compile the wrapper file
SWIG = $(exec_prefix)/bin/swig
SWIGOPT = -tcl # use -tcl8 for Tcl 8.0
SWIGCC = $(CC)
# SWIG Library files. Uncomment one of these for rebuilding tclsh or wish
#SWIGLIB = -ltclsh.i
#SWIGLIB = -lwish.i
# Rules for creating .o files from source.
COBJS = $(SRCS:.c=.o)
CXXOBJS = $(CXXSRCS:.cxx=.o)
OBJCOBJS = $(OBJCSRCS:.m=.o)
ALLOBJS = $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(OBJS)
# Command that will be used to build the final extension.
BUILD = $(SWIGCC)
# Uncomment the following if you are using dynamic loading
CCSHARED =
BUILD = ld -G
# Uncomment the following if you are using dynamic loading with C++ and
# need to provide additional link libraries (this is not always required).
#DLL_LIBS = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \
-L/usr/local/lib -lg++ -lstdc++ -lgcc
# X11 installation (needed to rebuild Tk extensions)
XLIB = -L/usr/openwin/lib -lX11
XINCLUDE = -I/usr/openwin/include
# Tcl installation (where is Tcl/Tk located)
TCL_INCLUDE = -I/usr/local/include
TCL_LIB = -L/usr/local/lib
# Build libraries (needed for static builds)
LIBM = -lm
LIBC =
SYSLIBS = $(LIBM) $(LIBC) -lsocket -lnsl -ldl
# Build options (uncomment only one these)
BUILD_LIBS = $(LIBS) # Dynamic loading
#BUILD_LIBS = $(TCL_LIB) -ltcl $(LIBS) $(SYSLIBS) # tclsh
#BUILD_LIBS = $(TCL_LIB) -ltk -ltcl $(XLIB) $(LIBS) $(SYSLIBS) # wish
# Compilation rules for non-SWIG components
.SUFFIXES: .c .cxx .m
.c.o:
$(CC) $(CCSHARED) $(CFLAGS) $(INCLUDE) -c $<
.cxx.o:
$(CXX) $(CCSHARED) $(CXXFLAGS) $(INCLUDE) -c $<
.m.o:
$(OBJC) $(CCSHARED) $(CFLAGS) $(INCLUDE) -c $<
# ----------------------------------------------------------------------
# Rules for building the extension
# ----------------------------------------------------------------------
all: $(TARGET)
# Convert the wrapper file into an object file
$(WRAPOBJ) : $(WRAPFILE)
$(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(WRAPFILE) $(INCLUDE) $(TCL_INCLUDE)
$(WRAPFILE) : $(INTERFACE)
$(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIB) $(INTERFACE)
$(TARGET): $(WRAPOBJ) $(ALLOBJS)
$(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET)
clean:
rm -f $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(WRAPOBJ) $(WRAPFILE) $(TARGET)

View File

@@ -0,0 +1,134 @@
# ---------------------------------------------------------------
# $Header$
# SWIG Tcl/Tk Makefile
#
# This file can be used to build various Tcl extensions with SWIG.
# By default this file is set up for dynamic loading, but it can
# be easily customized for static extensions by modifying various
# portions of the file.
#
# SRCS = C source files
# CXXSRCS = C++ source files
# OBJCSRCS = Objective-C source files
# OBJS = Additional .o files (compiled previously)
# INTERFACE = SWIG interface file
# TARGET = Name of target module or executable
#
# Many portions of this file were created by the SWIG configure
# script and should already reflect your machine. However, you
# may need to modify the Makefile to reflect your specific
# application.
#----------------------------------------------------------------
SRCS =
CXXSRCS =
OBJCSRCS =
OBJS =
INTERFACE =
WRAPFILE = $(INTERFACE:.i=_wrap.c)
WRAPOBJ = $(INTERFACE:.i=_wrap.o)
TARGET = module@SO@ # Use this kind of target for dynamic loading
#TARGET = my_tclsh # Use this target for static linking
prefix = @prefix@
exec_prefix = @exec_prefix@
CC = @CC@
CXX = @CXX@
OBJC = @CC@ -Wno-import # -Wno-import needed for gcc
CFLAGS =
INCLUDE =
LIBS =
# SWIG Options
# SWIG = location of the SWIG executable
# SWIGOPT = SWIG compiler options
# SWIGCC = Compiler used to compile the wrapper file
SWIG = $(exec_prefix)/bin/swig
SWIGOPT = -tcl # use -tcl8 for Tcl 8.0
SWIGCC = $(CC)
# SWIG Library files. Uncomment one of these for rebuilding tclsh or wish
#SWIGLIB = -ltclsh.i
#SWIGLIB = -lwish.i
# Rules for creating .o files from source.
COBJS = $(SRCS:.c=.o)
CXXOBJS = $(CXXSRCS:.cxx=.o)
OBJCOBJS = $(OBJCSRCS:.m=.o)
ALLOBJS = $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(OBJS)
# Command that will be used to build the final extension.
BUILD = $(SWIGCC)
# Uncomment the following if you are using dynamic loading
CCSHARED = @CCSHARED@
BUILD = @LDSHARED@
# Uncomment the following if you are using dynamic loading with C++ and
# need to provide additional link libraries (this is not always required).
#DLL_LIBS = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \
-L/usr/local/lib -lg++ -lstdc++ -lgcc
# X11 installation (needed to rebuild Tk extensions)
XLIB = @XLIBSW@
XINCLUDE = @XINCLUDES@
# Tcl installation (where is Tcl/Tk located)
TCL_INCLUDE = @TCLINCLUDE@
TCL_LIB = @TCLLIB@
# Build libraries (needed for static builds)
LIBM = @LIBM@
LIBC = @LIBC@
SYSLIBS = $(LIBM) $(LIBC) @LIBS@
# Build options (uncomment only one these)
BUILD_LIBS = $(LIBS) # Dynamic loading
#BUILD_LIBS = $(TCL_LIB) -ltcl $(LIBS) $(SYSLIBS) # tclsh
#BUILD_LIBS = $(TCL_LIB) -ltk -ltcl $(XLIB) $(LIBS) $(SYSLIBS) # wish
# Compilation rules for non-SWIG components
.SUFFIXES: .c .cxx .m
.c.o:
$(CC) $(CCSHARED) $(CFLAGS) $(INCLUDE) -c $<
.cxx.o:
$(CXX) $(CCSHARED) $(CXXFLAGS) $(INCLUDE) -c $<
.m.o:
$(OBJC) $(CCSHARED) $(CFLAGS) $(INCLUDE) -c $<
# ----------------------------------------------------------------------
# Rules for building the extension
# ----------------------------------------------------------------------
all: $(TARGET)
# Convert the wrapper file into an object file
$(WRAPOBJ) : $(WRAPFILE)
$(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(WRAPFILE) $(INCLUDE) $(TCL_INCLUDE)
$(WRAPFILE) : $(INTERFACE)
$(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIB) $(INTERFACE)
$(TARGET): $(WRAPOBJ) $(ALLOBJS)
$(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET)
clean:
rm -f $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(WRAPOBJ) $(WRAPFILE) $(TARGET)

View File

@@ -0,0 +1,28 @@
// Initialization code for BLT
%{
#ifdef __cplusplus
extern "C" {
#endif
extern int Blt_Init(Tcl_Interp *);
#ifdef __cplusplus
}
#endif
%}
#ifdef AUTODOC
%subsection "blt.i"
%text %{
This module initializes the BLT package. This is usually done in
combination with the wish.i or similar module. For example :
%include wish.i // Build a new wish executable
%include blt.i // Initialize BLT
%}
#endif
%init %{
if (Blt_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
%}

View File

@@ -0,0 +1,27 @@
/* configcode.swg */
else if ((*(argv[1]) == 'c') && (strncmp(argv[1],"configure") == 0) && (argv[1][1])) {
int i = 2;
cmd = 0;
while (i+1 < argc) {
@CONFIGMETHODS@
if (cmd) {
oldarg = argv[i];
argv[i] = &temp[0];
rcode = (*cmd)(clientData,interp,3,&argv[i-1]);
argv[i] = oldarg;
if (rcode == TCL_ERROR) return rcode;
cmd = 0;
} else {
Tcl_SetResult(interp,"Invalid configure option. Must be { @CONFIGLIST@ }",TCL_STATIC);
return TCL_ERROR;
}
i+=2;
}
if ((i < argc) || (i == 2)) {
Tcl_SetResult(interp,"{ @CONFIGLIST@ }",TCL_STATIC);
return TCL_ERROR;
}
return TCL_OK;
}

View File

@@ -0,0 +1,108 @@
// constarray.i
//
// This module changes SWIG to place constant values into a Tcl array
#ifdef AUTODOC
%subsection "Array Constants",pre
%text %{
%include constarray.i
This module changes SWIG so that constant values are placed into a Tcl
array instead of global variables. The array is given the same name as
the SWIG module (specified with the %module directive).
This module should generally be included at the top of an interface
file before any declarations appear. Furthermore, this module changes
the default handling of basic datatypes including integers, floats,
and character strings.
When this module is used, constants are simply accessed through the
module name. For example :
%module example
...
#define FOO 42
would be accessed as '$example(FOO)'
Note : This module replaces the existing mechanism for creating constants.
The method used by this module is based on a set of typemaps supplied
by Tim Medley.
%}
#endif
%typemap(tcl,const) int SWIG_DEFAULT_TYPE,
unsigned int SWIG_DEFAULT_TYPE,
long SWIG_DEFAULT_TYPE,
unsigned long SWIG_DEFAULT_TYPE,
short SWIG_DEFAULT_TYPE,
unsigned short SWIG_DEFAULT_TYPE,
unsigned char SWIG_DEFAULT_TYPE,
signed char SWIG_DEFAULT_TYPE
{
static int ivalue = (int) $source;
Tcl_LinkVar(interp,SWIG_name "($target)",(char *) &ivalue, TCL_LINK_INT | TCL_LINK_READ_ONLY);
}
%typemap(tcl,const) float SWIG_DEFAULT_TYPE,
double SWIG_DEFAULT_TYPE
{
static double dvalue = (double) $source;
Tcl_LinkVar(interp, SWIG_prefix SWIG_name "($target)",(char *) &dvalue, TCL_LINK_DOUBLE | TCL_LINK_READ_ONLY);
}
%typemap(tcl,const) char *SWIG_DEFAULT_TYPE
{
static char *cvalue = $source;
Tcl_LinkVar(interp, SWIG_prefix SWIG_name "($target)",(char *) &cvalue, TCL_LINK_STRING | TCL_LINK_READ_ONLY);
}
%typemap(tcl,const) Pointer *SWIG_DEFAULT_TYPE
{
static char *pvalue;
pvalue = (char *) malloc(20+strlen("$mangle"));
SWIG_MakePtr(pvalue, (void *) ($source), "$mangle");
Tcl_LinkVar(interp, SWIG_prefix SWIG_name "($target)",(char *) &pvalue, TCL_LINK_STRING | TCL_LINK_READ_ONLY);
}
// ----------------------------------------------------------------------------------
// Tcl 8 Object versions
// ----------------------------------------------------------------------------------
%typemap(tcl8,const) int SWIG_DEFAULT_TYPE,
unsigned int SWIG_DEFAULT_TYPE,
long SWIG_DEFAULT_TYPE,
unsigned long SWIG_DEFAULT_TYPE,
short SWIG_DEFAULT_TYPE,
unsigned short SWIG_DEFAULT_TYPE,
unsigned char SWIG_DEFAULT_TYPE,
signed char SWIG_DEFAULT_TYPE
{
static int ivalue = (int) $source;
Tcl_LinkVar(interp, SWIG_prefix SWIG_name "($target)",(char *) &ivalue, TCL_LINK_INT | TCL_LINK_READ_ONLY);
}
%typemap(tcl8,const) float SWIG_DEFAULT_TYPE,
double SWIG_DEFAULT_TYPE
{
static double dvalue = (double) $source;
Tcl_LinkVar(interp, SWIG_prefix SWIG_name "($target)",(char *) &dvalue, TCL_LINK_DOUBLE | TCL_LINK_READ_ONLY);
}
%typemap(tcl8,const) char *SWIG_DEFAULT_TYPE
{
static char *cvalue = $source;
Tcl_LinkVar(interp, SWIG_prefix SWIG_name "($target)",(char *) &cvalue, TCL_LINK_STRING | TCL_LINK_READ_ONLY);
}
%typemap(tcl8,const) Pointer *SWIG_DEFAULT_TYPE
{
static char *pvalue;
pvalue = (char *) malloc(20+strlen("$mangle"));
SWIG_MakePtr(pvalue, (void *) ($source), "$mangle");
Tcl_LinkVar(interp, SWIG_prefix SWIG_name "($target)",(char *) &pvalue, TCL_LINK_STRING | TCL_LINK_READ_ONLY);
}

View File

@@ -0,0 +1,223 @@
// consthash.i
//
// This module changes SWIG to place constant values into a Tcl
// hash table.
#ifdef AUTODOC
%subsection "Hash Constants",pre
%text %{
%include consthash.i
This module changes SWIG so that constant values are placed into a Tcl
hash table in addition to normal Tcl variables. When working with systems
involving large numbers of constants, the use of a hash table
simplifies use because it is no longer necessary to declare constants
using the 'global' statement.
This module should generally be included at the top of an interface
file before any declarations appear. Furthermore, this module changes
the default handling of basic datatypes including integers, floats,
and character strings.
When this module is used, constants are simply accessed by name
without the associated dollar sign. For example :
#define FOO 42
would be accessed as 'FOO' in Tcl, not '$FOO'.
Note : This module only affects integer, float, and character
constants. Pointer constants are not currently affected. This module
should not break existing Tcl scripts that rely on the normal SWIG
constant mechanism.
%}
#endif
%{
static Tcl_HashTable intHash, doubleHash, charHash;
static Tcl_HashEntry *entryPtr;
static int init_dummy;
%}
%init %{
Tcl_InitHashTable(&intHash, TCL_STRING_KEYS);
Tcl_InitHashTable(&doubleHash, TCL_STRING_KEYS);
Tcl_InitHashTable(&charHash, TCL_STRING_KEYS);
%}
%typemap(tcl,const) int SWIG_DEFAULT_TYPE,
unsigned int SWIG_DEFAULT_TYPE,
long SWIG_DEFAULT_TYPE,
unsigned long SWIG_DEFAULT_TYPE,
short SWIG_DEFAULT_TYPE,
unsigned short SWIG_DEFAULT_TYPE,
unsigned char SWIG_DEFAULT_TYPE,
signed char SWIG_DEFAULT_TYPE
{
static int ivalue = (int) $source;
entryPtr = Tcl_CreateHashEntry(&intHash, "$target", &init_dummy);
Tcl_SetHashValue(entryPtr, &ivalue);
Tcl_LinkVar(interp, SWIG_prefix "$target",(char *) &ivalue, TCL_LINK_INT | TCL_LINK_READ_ONLY);
}
%typemap(tcl,const) float SWIG_DEFAULT_TYPE,
double SWIG_DEFAULT_TYPE
{
static double dvalue = (double) $source;
entryPtr = Tcl_CreateHashEntry(&doubleHash, "$target", &init_dummy);
Tcl_SetHashValue(entryPtr, &dvalue);
Tcl_LinkVar(interp, SWIG_prefix "$target",(char *) &dvalue, TCL_LINK_DOUBLE | TCL_LINK_READ_ONLY);
}
%typemap(tcl,const) char *SWIG_DEFAULT_TYPE
{
static char *cvalue = $source;
entryPtr = Tcl_CreateHashEntry(&charHash, "$target", &init_dummy);
Tcl_SetHashValue(entryPtr, &cvalue);
Tcl_LinkVar(interp, SWIG_prefix "$target",(char *) &cvalue, TCL_LINK_STRING | TCL_LINK_READ_ONLY);
}
// Change input handling to look for names
%typemap(tcl,in) int SWIG_DEFAULT_TYPE,
unsigned int SWIG_DEFAULT_TYPE,
long SWIG_DEFAULT_TYPE,
unsigned long SWIG_DEFAULT_TYPE,
short SWIG_DEFAULT_TYPE,
unsigned short SWIG_DEFAULT_TYPE,
unsigned char SWIG_DEFAULT_TYPE,
signed char SWIG_DEFAULT_TYPE
{
Tcl_HashEntry *entry;
entry = Tcl_FindHashEntry(&intHash,$source);
if (entry) {
$target = ($type) (*((int *) Tcl_GetHashValue(entry)));
} else {
int temp;
if (Tcl_GetInt(interp, $source, &temp) == TCL_ERROR) return TCL_ERROR;
$target = ($type) temp;
}
}
%typemap(tcl,in) float SWIG_DEFAULT_TYPE,
double SWIG_DEFAULT_TYPE
{
Tcl_HashEntry *entry;
entry = Tcl_FindHashEntry(&doubleHash,$source);
if (entry) {
$target = ($type) (*((double *) Tcl_GetHashValue(entry)));
} else if (entry = Tcl_FindHashEntry(&intHash,$source)) {
$target = ($type) (*((int *) Tcl_GetHashValue(entry)));
} else {
double temp;
if (Tcl_GetDouble(interp,$source,&temp) == TCL_ERROR) return TCL_ERROR;
$target = ($type) temp;
}
}
%typemap(tcl,in) char *SWIG_DEFAULT_TYPE
{
Tcl_HashEntry *entry;
entry = Tcl_FindHashEntry(&charHash,$source);
if (entry) {
$target = ($type) (*((char **) Tcl_GetHashValue(entry)));
} else {
$target = $source;
}
}
// ----------------------------------------------------------------------------------
// Tcl 8 Object versions
// ----------------------------------------------------------------------------------
%typemap(tcl8,const) int SWIG_DEFAULT_TYPE,
unsigned int SWIG_DEFAULT_TYPE,
long SWIG_DEFAULT_TYPE,
unsigned long SWIG_DEFAULT_TYPE,
short SWIG_DEFAULT_TYPE,
unsigned short SWIG_DEFAULT_TYPE,
unsigned char SWIG_DEFAULT_TYPE,
signed char SWIG_DEFAULT_TYPE
{
static int ivalue = (int) $source;
entryPtr = Tcl_CreateHashEntry(&intHash, "$target", &init_dummy);
Tcl_SetHashValue(entryPtr, &ivalue);
Tcl_LinkVar(interp, SWIG_prefix "$target",(char *) &ivalue, TCL_LINK_INT | TCL_LINK_READ_ONLY);
}
%typemap(tcl8,const) float SWIG_DEFAULT_TYPE,
double SWIG_DEFAULT_TYPE
{
static double dvalue = (double) $source;
entryPtr = Tcl_CreateHashEntry(&doubleHash, "$target", &init_dummy);
Tcl_SetHashValue(entryPtr, &dvalue);
Tcl_LinkVar(interp, SWIG_prefix "$target",(char *) &dvalue, TCL_LINK_DOUBLE | TCL_LINK_READ_ONLY);
}
%typemap(tcl8,const) char *SWIG_DEFAULT_TYPE
{
static char *cvalue = $source;
entryPtr = Tcl_CreateHashEntry(&charHash, "$target", &init_dummy);
Tcl_SetHashValue(entryPtr, &cvalue);
Tcl_LinkVar(interp, SWIG_prefix "$target",(char *) &cvalue, TCL_LINK_STRING | TCL_LINK_READ_ONLY);
}
// Change input handling to look for names
%typemap(tcl8,in) int SWIG_DEFAULT_TYPE,
unsigned int SWIG_DEFAULT_TYPE,
long SWIG_DEFAULT_TYPE,
unsigned long SWIG_DEFAULT_TYPE,
short SWIG_DEFAULT_TYPE,
unsigned short SWIG_DEFAULT_TYPE,
unsigned char SWIG_DEFAULT_TYPE,
signed char SWIG_DEFAULT_TYPE
{
Tcl_HashEntry *entry;
int _len;
char *_str = Tcl_GetStringFromObj($source,&_len);
entry = Tcl_FindHashEntry(&intHash,_str);
if (entry) {
$target = ($type) (*((int *) Tcl_GetHashValue(entry)));
} else {
int temp;
if (Tcl_GetIntFromObj(interp, $source, &temp) == TCL_ERROR) return TCL_ERROR;
$target = ($type) temp;
}
}
%typemap(tcl8,in) float SWIG_DEFAULT_TYPE,
double SWIG_DEFAULT_TYPE
{
Tcl_HashEntry *entry;
int _len;
char *_str = Tcl_GetStringFromObj($source,&_len);
entry = Tcl_FindHashEntry(&doubleHash,_str);
if (entry) {
$target = ($type) (*((double *) Tcl_GetHashValue(entry)));
} else if (entry = Tcl_FindHashEntry(&intHash,_str)) {
$target = ($type) (*((int *) Tcl_GetHashValue(entry)));
} else {
double temp;
if (Tcl_GetDoubleFromObj(interp,$source,&temp) == TCL_ERROR) return TCL_ERROR;
$target = ($type) temp;
}
}
%typemap(tcl8,in) char *SWIG_DEFAULT_TYPE
{
Tcl_HashEntry *entry;
int _len;
char *_str = Tcl_GetStringFromObj($source,&_len);
entry = Tcl_FindHashEntry(&charHash,_str);
if (entry) {
$target = ($type) (*((char **) Tcl_GetHashValue(entry)));
} else {
$target = _str;
}
}

View File

@@ -0,0 +1,6 @@
/* delcmd.swg : Tcl object deletion method */
static void TclDelete@CLASS@(ClientData clientData) {
@DESTRUCTOR@((@CLASSTYPE@) clientData);
}

View File

@@ -0,0 +1,6 @@
/* delcmd.swg : Tcl object deletion method */
static void TclDelete@CLASS@(ClientData clientData) {
@DESTRUCTOR@((@CLASSTYPE@) clientData);
}

View File

@@ -0,0 +1,97 @@
//
// $Header$
// SWIG File for building expect
// Dave Beazley
// March 18, 1996
//
/* Revision History
* $Log$
* Revision 1.1 2002/04/29 19:56:56 RD
* Since I have made several changes to SWIG over the years to accomodate
* special cases and other things in wxPython, and since I plan on making
* several more, I've decided to put the SWIG sources in wxPython's CVS
* instead of relying on maintaining patches. This effectivly becomes a
* fork of an obsolete version of SWIG, :-( but since SWIG 1.3 still
* doesn't have some things I rely on in 1.1, not to mention that my
* custom patches would all have to be redone, I felt that this is the
* easier road to take.
*
* Revision 1.2 1999/11/05 21:45:14 beazley
* Minor Changes
*
* Revision 1.1.1.1 1999/02/28 02:00:55 beazley
* Swig1.1
*
* Revision 1.1 1996/05/22 19:47:45 beazley
* Initial revision
*
*/
#ifdef AUTODOC
%subsection "expect.i"
%text %{
This module provides a main() function for building an extended version of
Expect. It has been tested with Expect 5.19, but may need modification
for newer versions.
%}
#endif
%{
/* main.c - main() and some logging routines for expect
Written by: Don Libes, NIST, 2/6/90
Design and implementation of this program was paid for by U.S. tax
dollars. Therefore it is public domain. However, the author and NIST
would appreciate credit if this program or parts of it are used.
*/
#include "expect_cf.h"
#include <stdio.h>
#include "expect_tcl.h"
void
main(argc, argv)
int argc;
char *argv[];
{
int rc = 0;
Tcl_Interp *interp = Tcl_CreateInterp();
int SWIG_init(Tcl_Interp *);
if (Tcl_Init(interp) == TCL_ERROR) {
fprintf(stderr,"Tcl_Init failed: %s\n",interp->result);
exit(1);
}
if (Exp_Init(interp) == TCL_ERROR) {
fprintf(stderr,"Exp_Init failed: %s\n",interp->result);
exit(1);
}
/* SWIG initialization. --- 2/11/96 */
if (SWIG_init(interp) == TCL_ERROR) {
fprintf(stderr,"SWIG initialization failed: %s\n", interp->result);
exit(1);
}
exp_parse_argv(interp,argc,argv);
/* become interactive if requested or "nothing to do" */
if (exp_interactive)
(void) exp_interpreter(interp);
else if (exp_cmdfile)
rc = exp_interpret_cmdfile(interp,exp_cmdfile);
else if (exp_cmdfilename)
rc = exp_interpret_cmdfilename(interp,exp_cmdfilename);
/* assert(exp_cmdlinecmds != 0) */
exp_exit(interp,rc);
/*NOTREACHED*/
}
%}

View File

@@ -0,0 +1,733 @@
//
// $Header$
//
// SWIG file for building expectk
// Dave Beazley
// March 18, 1996
//
/* Revision History
* $Log$
* Revision 1.1 2002/04/29 19:56:56 RD
* Since I have made several changes to SWIG over the years to accomodate
* special cases and other things in wxPython, and since I plan on making
* several more, I've decided to put the SWIG sources in wxPython's CVS
* instead of relying on maintaining patches. This effectivly becomes a
* fork of an obsolete version of SWIG, :-( but since SWIG 1.3 still
* doesn't have some things I rely on in 1.1, not to mention that my
* custom patches would all have to be redone, I felt that this is the
* easier road to take.
*
* Revision 1.2 1999/11/05 21:45:14 beazley
* Minor Changes
*
* Revision 1.1.1.1 1999/02/28 02:00:55 beazley
* Swig1.1
*
* Revision 1.1 1996/05/22 19:47:45 beazley
* Initial revision
*
*/
#ifdef AUTODOC
%subsection "expectk.i"
%text %{
This module provides a main() function for building an extended version of
expectk. It has been tested with Expect 5.19, but may need modification
for newer versions.
%}
#endif
%{
/* exp_main_tk.c - main for expectk
This is "main.c" from the Tk distribution with some minor modifications to
support Expect.
Don Libes, NIST, 12/19/92
*/
/*
* main.c --
*
* This file contains the main program for "wish", a windowing
* shell based on Tk and Tcl. It also provides a template that
* can be used as the basis for main programs for other Tk
* applications.
*
* Copyright (c) 1990-1993 The Regents of the University of California.
* All rights reserved.
*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
* software and its documentation for any purpose, provided that the
* above copyright notice and the following two paragraphs appear in
* all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/
/*#include "tkConfig.h"*/
/*#include "tkInt.h"*/
#include <tk.h>
#include "expect_tcl.h"
#include "Dbg.h"
#include "string.h"
#ifdef TK_EXTENDED
# include "tclExtend.h"
#endif
/*
* Global variables used by the main program:
*/
static Tk_Window mainWindow; /* The main window for the application. If
* NULL then the application no longer
* exists. */
static Tcl_Interp *interp; /* Interpreter for this application. */
#if 0
char *tcl_RcFileName = NULL; /* Name of a user-specific startup script
* to source if the application is being run
* interactively (e.g. "~/.wishrc"). Set
* by Tcl_AppInit. NULL means don't source
* anything ever. */
#endif
static Tcl_DString command; /* Used to assemble lines of terminal input
* into Tcl commands. */
static int tty; /* Non-zero means standard input is a
* terminal-like device. Zero means it's
* a file. */
static char normalExitCmd[] = "exit";
static char errorExitCmd[] = "exit 1";
/*
* Command-line options:
*/
int synchronize = 0;
char *fileName = NULL;
char *name = NULL;
char *display = NULL;
char *geometry = NULL;
/* for Expect */
int my_rc = 1;
int sys_rc = 1;
int optcmd_eval();
int dashdash; /* not used, but Tk's arg parser requires a placeholder */
#ifdef TCL_DEBUGGER
int optcmd_debug();
#endif
Tk_ArgvInfo argTable[] = {
{"-file", TK_ARGV_STRING, (char *) NULL, (char *) &fileName,
"File from which to read commands"},
{"-geometry", TK_ARGV_STRING, (char *) NULL, (char *) &geometry,
"Initial geometry for window"},
{"-display", TK_ARGV_STRING, (char *) NULL, (char *) &display,
"Display to use"},
{"-name", TK_ARGV_STRING, (char *) NULL, (char *) &name,
"Name to use for application"},
{"-sync", TK_ARGV_CONSTANT, (char *) 1, (char *) &synchronize,
"Use synchronous mode for display server"},
/* for Expect */
{"-buffer", TK_ARGV_STRING, (char *) 1, (char *) &exp_buffer_command_input,
"Buffer command input"},
{"-command", TK_ARGV_GENFUNC, (char *) optcmd_eval, (char *)0,
"Command(s) to execute immediately"},
{"-diag", TK_ARGV_CONSTANT, (char *) 1, (char *) &exp_is_debugging,
"Enable diagnostics"},
{"--", TK_ARGV_REST, (char *)NULL, (char *)&dashdash,
"End of options"},
#if TCL_DEBUGGER
{"-Debug", TK_ARGV_GENFUNC, (char *) optcmd_debug, (char *)0,
"Enable debugger"},
#endif
{"-interactive", TK_ARGV_CONSTANT, (char *) 1, (char *) &exp_interactive,
"Interactive mode"},
{"-norc", TK_ARGV_CONSTANT, (char *) 0, (char *) &my_rc,
"Don't read ~/.expect.rc"},
{"-NORC", TK_ARGV_CONSTANT, (char *) 0, (char *) &sys_rc,
"Don't read system-wide expect.rc"},
{(char *) NULL, TK_ARGV_END, (char *) NULL, (char *) NULL,
(char *) NULL}
};
#ifdef TCL_DEBUGGER
/*ARGSUSED*/
int
optcmd_debug(dst,interp,key,argc,argv)
char *dst;
Tcl_Interp *interp;
char *key;
int argc;
char **argv;
{
int i;
if (argc == 0) {
strcpy(interp->result,"-Debug flag needs 1 or 0 argument");
return -1;
}
if (Tcl_GetInt(interp,argv[0],&i) != TCL_OK) {
return -1;
}
if (i) {
Dbg_On(interp,0);
}
argc--;
for (i=0;i<argc;i++) {
argv[i] = argv[i+1];
}
return argc;
}
#endif /*TCL_DEBUGGER*/
/*ARGSUSED*/
int
optcmd_eval(dst,interp,key,argc,argv)
char *dst;
Tcl_Interp *interp;
char *key;
int argc;
char **argv;
{
int i;
int rc;
exp_cmdlinecmds = 1;
rc = Tcl_Eval(interp,argv[0]);
if (rc == TCL_ERROR) return -1;
argc--;
for (i=0;i<argc;i++) {
argv[i] = argv[i+1];
}
return argc;
}
/*
* Declaration for Tcl command procedure to create demo widget. This
* procedure is only invoked if SQUARE_DEMO is defined.
*/
extern int SquareCmd _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int argc, char *argv[]));
/*
* Forward declarations for procedures defined later in this file:
*/
static void Prompt _ANSI_ARGS_((Tcl_Interp *interp, int partial));
static void StdinProc _ANSI_ARGS_((ClientData clientData,
int mask));
/*
*----------------------------------------------------------------------
*
* main --
*
* Main program for Wish.
*
* Results:
* None. This procedure never returns (it exits the process when
* it's done
*
* Side effects:
* This procedure initializes the wish world and then starts
* interpreting commands; almost anything could happen, depending
* on the script being interpreted.
*
*----------------------------------------------------------------------
*/
int
main(argc, argv)
int argc; /* Number of arguments. */
char **argv; /* Array of argument strings. */
{
char *args, *p, *msg, *class;
char buf[20];
int code;
int SWIG_init(Tcl_Interp *);
extern char *exp_argv0;
int used_argv1_for_filename = 0; /* added for Expect - DEL */
#ifdef TK_EXTENDED
tk_mainInterp = interp = Tcl_CreateExtendedInterp();
#else
interp = Tcl_CreateInterp();
#endif
#ifdef TCL_MEM_DEBUG
Tcl_InitMemory(interp);
#endif
if (Exp_Init(interp) == TCL_ERROR) {
fprintf(stderr,"Exp_Init failed: %s\n",interp->result);
return 1;
}
/* Add SWIG Extension */
if (SWIG_init(interp) == TCL_ERROR) {
fprintf(stderr,"Unable to initialize user-extensions : %s\n", interp->result);
return 1;
}
exp_argv0 = argv[0];
#ifdef TCL_DEBUGGER
Dbg_ArgcArgv(argc,argv,1);
#endif
/*
* Parse command-line arguments.
*/
if (Tk_ParseArgv(interp, (Tk_Window) NULL, &argc, argv, argTable, 0)
!= TCL_OK) {
fprintf(stderr, "%s\n", interp->result);
exit(1);
}
if (!fileName) { /* added for Expect - DEL */
fileName = argv[1];
used_argv1_for_filename = 1;
}
if (name == NULL) {
if (fileName != NULL) {
p = fileName;
} else {
p = argv[0];
}
name = strrchr(p, '/');
if (name != NULL) {
name++;
} else {
name = p;
}
}
/* if user hasn't explicitly requested we be interactive */
/* look for a file or some other source of commands */
if (fileName && !exp_interactive) {
if (0 == strcmp(fileName,"-")) {
exp_cmdfile = stdin;
} else if (exp_buffer_command_input) {
if (NULL == (exp_cmdfile = fopen(fileName,"r"))) {
perror(fileName);
exp_exit(interp,1);
} else {
exp_close_on_exec(fileno(exp_cmdfile));
}
} else {
exp_cmdfilename = fileName;
}
} else if (!exp_cmdlinecmds) {
/* no other source of commands, force interactive */
exp_interactive = 1;
}
/*
* If a display was specified, put it into the DISPLAY
* environment variable so that it will be available for
* any sub-processes created by us.
*/
if (display != NULL) {
Tcl_SetVar2(interp, "env", "DISPLAY", display, TCL_GLOBAL_ONLY);
}
/*
* Initialize the Tk application. If a -name option was provided,
* use it; otherwise, if a file name was provided, use the last
* element of its path as the name of the application; otherwise
* use the last element of the program name. For the application's
* class, capitalize the first letter of the name.
*/
#if TK_MAJOR_VERSION >= 4
class = (char *) ckalloc((unsigned) (strlen(name) + 1));
strcpy(class, name);
class[0] = toupper((unsigned char) class[0]);
mainWindow = Tk_CreateMainWindow(interp, display, name, class);
#else
# if TK_MAJOR_VERSION == 3 && TK_MINOR_VERSION < 4
mainWindow = Tk_CreateMainWindow(interp, display, name);
# else
mainWindow = Tk_CreateMainWindow(interp, display, name, "Tk");
# endif
#endif
if (mainWindow == NULL) {
fprintf(stderr, "%s\n", interp->result);
exit(1);
}
#if TK_MAJOR_VERSION == 3 && TK_MINOR_VERSION < 4
Tk_SetClass(mainWindow, "Tk");
#endif
if (synchronize) {
XSynchronize(Tk_Display(mainWindow), True);
}
#if TK_MAJOR_VERSION < 4
Tk_GeometryRequest(mainWindow, 200, 200);
#endif
/*
* Make command-line arguments available in the Tcl variables "argc"
* and "argv". Also set the "geometry" variable from the geometry
* specified on the command line.
*/
if (used_argv1_for_filename) { /* added for Expect - DEL */
argv++;
argc--;
/* if no script name, use interpreter name */
if (!argv[0] && !fileName) argv[0] = name;
}
args = Tcl_Merge(argc-1, argv+1);
Tcl_SetVar(interp, "argv", args, TCL_GLOBAL_ONLY);
ckfree(args);
sprintf(buf, "%d", argc-1);
Tcl_SetVar(interp, "argc", buf, TCL_GLOBAL_ONLY);
Tcl_SetVar(interp, "argv0", (fileName != NULL) ? fileName : argv[0],
TCL_GLOBAL_ONLY);
if (geometry != NULL) {
#if TK_MAJOR_VERSION < 4
Tcl_SetVar(interp, "geometry", geometry, TCL_GLOBAL_ONLY);
#else
Tcl_SetVar(interp, "geometry", geometry, TCL_GLOBAL_ONLY);
code = Tcl_VarEval(interp, "wm geometry . ", geometry, (char *) NULL);
if (code != TCL_OK) {
fprintf(stderr, "%s\n", interp->result);
}
#endif
}
/*
* Set the "tcl_interactive" variable.
*/
tty = isatty(0);
Tcl_SetVar(interp, "tcl_interactive",
((fileName == NULL) && tty) ? "1" : "0", TCL_GLOBAL_ONLY);
/*
* Add a few application-specific commands to the application's
* interpreter.
*/
#ifdef SQUARE_DEMO
Tcl_CreateCommand(interp, "square", SquareCmd, (ClientData) mainWindow,
(void (*)()) NULL);
#endif
if (Tcl_Init(interp) == TCL_ERROR) {
fprintf(stderr,"Tcl_Init failed: %s\n",interp->result);
return 1;
}
if (Tk_Init(interp) == TCL_ERROR) {
fprintf(stderr,"Tk_Init failed: %s\n",interp->result);
return 1;
}
/* Call Exp_Init again because Tcl_Init resets auto_path, sigh. */
/* A better solution would be to execute Tcl/Tk_Init much earlier */
/* (before argc/argv is processed). */
if (Exp_Init(interp) == TCL_ERROR) {
fprintf(stderr,"Exp_Init failed: %s\n",interp->result);
return 1;
}
#if 0
tcl_RcFileName = "~/.wishrc";
/*
* Invoke application-specific initialization.
*/
if (Tcl_AppInit(interp) != TCL_OK) {
fprintf(stderr, "Tcl_AppInit failed: %s\n", interp->result);
}
#endif
exp_interpret_rcfiles(interp,my_rc,sys_rc);
#ifdef TK_EXTENDED
tclAppName = "Wish";
tclAppLongname = "Wish - Tk Shell";
tclAppVersion = TK_VERSION;
Tcl_ShellEnvInit (interp, TCLSH_ABORT_STARTUP_ERR,
name,
0, NULL, /* argv var already set */
fileName == NULL, /* interactive? */
NULL); /* Standard default file */
#endif
/*
* Set the geometry of the main window, if requested.
*/
if (geometry != NULL) {
code = Tcl_VarEval(interp, "wm geometry . ", geometry, (char *) NULL);
if (code != TCL_OK) {
fprintf(stderr, "%s\n", interp->result);
}
}
/*
* Invoke the script specified on the command line, if any.
*/
/* become interactive if requested or "nothing to do" */
if (exp_interactive) {
(void) exp_interpreter(interp);
} else if (exp_cmdfile) {
int rc = exp_interpret_cmdfile(interp,exp_cmdfile);
if (rc != TCL_OK) exp_exit(interp,rc);
Tk_MainLoop();
} else if (exp_cmdfilename) {
int rc = exp_interpret_cmdfilename(interp,exp_cmdfilename);
if (rc != TCL_OK) exp_exit(interp,rc);
Tk_MainLoop();
}
/*
* Don't exit directly, but rather invoke the Tcl "exit" command.
* This gives the application the opportunity to redefine "exit"
* to do additional cleanup.
*/
Tcl_Eval(interp,normalExitCmd);
exit(1);
#if 0
if (fileName != NULL) {
Dbg_On(interp,0);
code = Tcl_VarEval(interp, "source ", fileName, (char *) NULL);
if (code != TCL_OK) {
goto error;
}
tty = 0;
} else {
/*
* Commands will come from standard input, so set up an event
* handler for standard input. If the input device is aEvaluate the
* .rc file, if one has been specified, set up an event handler
* for standard input, and print a prompt if the input
* device is a terminal.
*/
if (tcl_RcFileName != NULL) {
Tcl_DString buffer;
char *fullName;
fullName = Tcl_TildeSubst(interp, tcl_RcFileName, &buffer);
if (fullName == NULL) {
fprintf(stderr, "%s\n", interp->result);
} else {
if (access(fullName, R_OK) == 0) {
code = Tcl_EvalFile(interp, fullName);
if (code != TCL_OK) {
fprintf(stderr, "%s\n", interp->result);
}
}
}
Tcl_DStringFree(&buffer);
}
Tk_CreateFileHandler(0, TK_READABLE, StdinProc, (ClientData) 0);
if (tty) {
Prompt(interp, 0);
}
}
fflush(stdout);
Tcl_DStringInit(&command);
/*
* Loop infinitely, waiting for commands to execute. When there
* are no windows left, Tk_MainLoop returns and we exit.
*/
Tk_MainLoop();
/*
* Don't exit directly, but rather invoke the Tcl "exit" command.
* This gives the application the opportunity to redefine "exit"
* to do additional cleanup.
*/
Tcl_Eval(interp, "exit");
exit(1);
error:
msg = Tcl_GetVar(interp, "errorInfo", TCL_GLOBAL_ONLY);
if (msg == NULL) {
msg = interp->result;
}
fprintf(stderr, "%s\n", msg);
Tcl_Eval(interp, errorExitCmd);
return 1; /* Needed only to prevent compiler warnings. */
#endif /*0*/
}
#if 0
/*
*----------------------------------------------------------------------
*
* StdinProc --
*
* This procedure is invoked by the event dispatcher whenever
* standard input becomes readable. It grabs the next line of
* input characters, adds them to a command being assembled, and
* executes the command if it's complete.
*
* Results:
* None.
*
* Side effects:
* Could be almost arbitrary, depending on the command that's
* typed.
*
*----------------------------------------------------------------------
*/
/* ARGSUSED */
static void
StdinProc(clientData, mask)
ClientData clientData; /* Not used. */
int mask; /* Not used. */
{
#define BUFFER_SIZE 4000
char input[BUFFER_SIZE+1];
static int gotPartial = 0;
char *cmd;
int code, count;
count = read(fileno(stdin), input, BUFFER_SIZE);
if (count <= 0) {
if (!gotPartial) {
if (tty) {
Tcl_Eval(interp, "exit");
exit(1);
} else {
Tk_DeleteFileHandler(0);
}
return;
} else {
count = 0;
}
}
cmd = Tcl_DStringAppend(&command, input, count);
if (count != 0) {
if ((input[count-1] != '\n') && (input[count-1] != ';')) {
gotPartial = 1;
goto prompt;
}
if (!Tcl_CommandComplete(cmd)) {
gotPartial = 1;
goto prompt;
}
}
gotPartial = 0;
/*
* Disable the stdin file handler while evaluating the command;
* otherwise if the command re-enters the event loop we might
* process commands from stdin before the current command is
* finished. Among other things, this will trash the text of the
* command being evaluated.
*/
Tk_CreateFileHandler(0, 0, StdinProc, (ClientData) 0);
code = Tcl_RecordAndEval(interp, cmd, 0);
Tk_CreateFileHandler(0, TK_READABLE, StdinProc, (ClientData) 0);
Tcl_DStringFree(&command);
if (*interp->result != 0) {
if ((code != TCL_OK) || (tty)) {
printf("%s\n", interp->result);
}
}
/*
* Output a prompt.
*/
prompt:
if (tty) {
Prompt(interp, gotPartial);
}
}
/*
*----------------------------------------------------------------------
*
* Prompt --
*
* Issue a prompt on standard output, or invoke a script
* to issue the prompt.
*
* Results:
* None.
*
* Side effects:
* A prompt gets output, and a Tcl script may be evaluated
* in interp.
*
*----------------------------------------------------------------------
*/
static void
Prompt(interp, partial)
Tcl_Interp *interp; /* Interpreter to use for prompting. */
int partial; /* Non-zero means there already
* exists a partial command, so use
* the secondary prompt. */
{
char *promptCmd;
int code;
promptCmd = Tcl_GetVar(interp,
partial ? "tcl_prompt2" : "tcl_prompt1", TCL_GLOBAL_ONLY);
if (promptCmd == NULL) {
defaultPrompt:
if (!partial) {
fputs("% ", stdout);
}
} else {
code = Tcl_Eval(interp, promptCmd);
if (code != TCL_OK) {
Tcl_AddErrorInfo(interp,
"\n (script that generates prompt)");
fprintf(stderr, "%s\n", interp->result);
goto defaultPrompt;
}
}
fflush(stdout);
}
#endif /*0*/
%}

View File

@@ -0,0 +1,170 @@
//
// SWIG Interface file for building a new version of ish
// Dave Beazley
// August 14, 1996
//
#ifdef AUTODOC
%subsection "ish.i"
%text %{
This module provides a main() program needed to build a new version
of the [incr Tcl] 'ish' executable. It has been tested with itcl 2.1,
but may need tweaking for later versions and for use with C++.
%}
#endif
%{
/*
* tclAppInit.c --
*
* Provides a default version of the main program and Tcl_AppInit
* procedure for Tcl applications (without Tk).
*
* Copyright (c) 1993 The Regents of the University of California.
* Copyright (c) 1994-1995 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* SCCS: @(#) tclAppInit.c 1.17 96/03/26 12:45:29
*/
/*
* The following variable is a special hack that is needed in order for
* Sun shared libraries to be used for Tcl.
*/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SWIG_RcFileName
char *SWIG_RcFileName = "~/.tclshrc";
#endif
extern int matherr _ANSI_ARGS_((void));
static int (*dummyMathPtr) _ANSI_ARGS_((void)) = matherr;
#ifdef __cplusplus
}
#endif
#ifdef TCL_TEST
extern int Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp));
extern int Tclptest_Init _ANSI_ARGS_((Tcl_Interp *interp));
#endif /* TCL_TEST */
#if (TCL_MAJOR_VERSION == 7) && (TCL_MINOR_VERSION < 4)
/*
* The following variable is a special hack that allows applications
* to be linked using the procedure "main" from the Tcl7.3 library. The
* variable generates a reference to "main", which causes main to
* be brought in from the library (and all of Tcl with it).
*/
extern int main _ANSI_ARGS_((int argc, char **argv));
static int (*dummyMainPtr) _ANSI_ARGS_((int argc, char **argv)) = main;
#else
/*
*----------------------------------------------------------------------
*
* main --
*
* This is the main program for the application.
*
* Results:
* None: Tcl_Main never returns here, so this procedure never
* returns either.
*
* Side effects:
* Whatever the application does.
*
*----------------------------------------------------------------------
*/
int
#ifdef _USING_PROTOTYPES_
main (int argc, /* Number of command-line arguments. */
char **argv) /* Values of command-line arguments. */
#else
main(argc, argv)
int argc; /* Number of command-line arguments. */
char **argv; /* Values of command-line arguments. */
#endif
{
Tcl_Main(argc, argv, Tcl_AppInit);
return 0; /* Needed only to prevent compiler warning. */
}
#endif
/*
*----------------------------------------------------------------------
*
* Tcl_AppInit --
*
* This procedure performs application-specific initialization.
* Most applications, especially those that incorporate additional
* packages, will have their own version of this procedure.
*
* Results:
* Returns a standard Tcl completion code, and leaves an error
* message in interp->result if an error occurs.
*
* Side effects:
* Depends on the startup script.
*
*----------------------------------------------------------------------
*/
int
#ifdef _USING_PROTOTYPES_
Tcl_AppInit (Tcl_Interp *interp) /* Interpreter for application. */
#else
Tcl_AppInit(interp)
Tcl_Interp *interp; /* Interpreter for application. */
#endif
{
if (Tcl_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
if (SWIG_init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
/*
* Call the init procedures for included packages. Each call should
* look like this:
*
* if (Mod_Init(interp) == TCL_ERROR) {
* return TCL_ERROR;
* }
*
* where "Mod" is the name of the module.
*/
/*
* Call Tcl_CreateCommand for application-specific commands, if
* they weren't already created by the init procedures called above.
*/
/*
* Specify a user-specific startup file to invoke if the application
* is run interactively. Typically the startup file is "~/.apprc"
* where "app" is the name of the application. If this line is deleted
* then no user-specific startup file will be run under any conditions.
*/
#if (TCL_MAJOR_VERSION > 7) || (TCL_MINOR_VERSION > 4)
Tcl_SetVar(interp, "tcl_rcFileName", SWIG_RcFileName, TCL_GLOBAL_ONLY);
#else
tcl_RcFileName = SWIG_RcFileName;
#endif
return TCL_OK;
}
%}

View File

@@ -0,0 +1,152 @@
//
// SWIG Interface file for building a new version of itclsh
// Dave Beazley
// August 14, 1996
//
#ifdef AUTODOC
%subsection "itclsh.i"
%text %{
This module provides a main() program needed to build a new version
of the [incr Tcl] 'itclsh' executable. It has been tested with itcl 2.1,
but may need tweaking for later versions and for use with C++.
%}
#endif
%{
/*
* tclAppInit.c --
*
* Provides a default version of the main program and Tcl_AppInit
* procedure for Tcl applications (without Tk).
*
* Copyright (c) 1993 The Regents of the University of California.
* Copyright (c) 1994-1995 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
static char sccsid[] = "@(#) tclAppInit.c 1.13 95/06/08 10:55:54";
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SWIG_RcFileName
char *SWIG_RcFileName = "~/.tclshrc";
#endif
extern int Itcl_Init _ANSI_ARGS_((Tcl_Interp *interp));
/*
* The following variable is a special hack that is needed in order for
* Sun shared libraries to be used for Tcl.
*/
extern int matherr _ANSI_ARGS_((void));
static int (*dummyMathPtr) _ANSI_ARGS_((void)) = matherr;
#ifdef __cplusplus
}
#endif
/*
*----------------------------------------------------------------------
*
* main --
*
* This is the main program for the application.
*
* Results:
* None: Tcl_Main never returns here, so this procedure never
* returns either.
*
* Side effects:
* Whatever the application does.
*
*----------------------------------------------------------------------
*/
int
main(argc, argv)
int argc; /* Number of command-line arguments. */
char **argv; /* Values of command-line arguments. */
{
Tcl_Main(argc, argv, Tcl_AppInit);
return 0; /* Needed only to prevent compiler warning. */
}
/*
*----------------------------------------------------------------------
*
* Tcl_AppInit --
*
* This procedure performs application-specific initialization.
* Most applications, especially those that incorporate additional
* packages, will have their own version of this procedure.
*
* Results:
* Returns a standard Tcl completion code, and leaves an error
* message in interp->result if an error occurs.
*
* Side effects:
* Depends on the startup script.
*
*----------------------------------------------------------------------
*/
int
Tcl_AppInit(interp)
Tcl_Interp *interp; /* Interpreter for application. */
{
if (Tcl_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
/*
* Call the init procedures for included packages. Each call should
* look like this:
*
* if (Mod_Init(interp) == TCL_ERROR) {
* return TCL_ERROR;
* }
*
* where "Mod" is the name of the module.
*/
if (Itcl_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
if (SWIG_init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
#if (TCL_MAJOR_VERSION > 7) || (TCL_MINOR_VERSION > 4)
Tcl_StaticPackage(interp, "Itcl", Itcl_Init, (Tcl_PackageInitProc *) NULL);
#endif
/*
* Call Tcl_CreateCommand for application-specific commands, if
* they weren't already created by the init procedures called above.
*/
/*
* Specify a user-specific startup file to invoke if the application
* is run interactively. Typically the startup file is "~/.apprc"
* where "app" is the name of the application. If this line is deleted
* then no user-specific startup file will be run under any conditions.
*/
#if (TCL_MAJOR_VERSION > 7) || (TCL_MINOR_VERSION > 4)
Tcl_SetVar(interp, "tcl_rcFileName", SWIG_RcFileName, TCL_GLOBAL_ONLY);
#else
tcl_RcFileName = SWIG_RcFileName;
#endif
return TCL_OK;
}
%}

View File

@@ -0,0 +1,150 @@
//
// SWIG Interface file for building a new version of itkwish
// Dave Beazley
// August 14, 1996
//
#ifdef AUTODOC
%subsection "itkwish.i"
%text %{
This module provides a main() program needed to build a new version
of the [incr Tcl] 'itkwish' executable. It has been tested with itcl 2.1,
but may need tweaking for later versions and for use with C++.
%}
#endif
%{
/*
* tkAppInit.c --
*
* Provides a default version of the Tcl_AppInit procedure for
* use in wish and similar Tk-based applications.
*
* Copyright (c) 1993 The Regents of the University of California.
* Copyright (c) 1994 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#ifndef lint
static char sccsid[] = "@(#) tkAppInit.c 1.15 95/06/28 13:14:28";
#endif /* not lint */
#include <tk.h>
EXTERN int Itcl_Init _ANSI_ARGS_((Tcl_Interp *interp));
EXTERN int Itk_Init _ANSI_ARGS_((Tcl_Interp *interp));
/*
* The following variable is a special hack that is needed in order for
* Sun shared libraries to be used for Tcl.
*/
#ifndef SWIG_RcFileName
char *SWIG_RcFileName = "~/.itkwishrc";
#endif
extern int matherr();
static int (*dummyMathPtr)() = matherr;
/*
*----------------------------------------------------------------------
*
* main --
*
* This is the main program for the application.
*
* Results:
* None: Tk_Main never returns here, so this procedure never
* returns either.
*
* Side effects:
* Whatever the application does.
*
*----------------------------------------------------------------------
*/
int
main(argc, argv)
int argc; /* Number of command-line arguments. */
char **argv; /* Values of command-line arguments. */
{
Tk_Main(argc, argv, Tcl_AppInit);
return 0; /* Needed only to prevent compiler warning. */
}
/*
*----------------------------------------------------------------------
*
* Tcl_AppInit --
*
* This procedure performs application-specific initialization.
* Most applications, especially those that incorporate additional
* packages, will have their own version of this procedure.
*
* Results:
* Returns a standard Tcl completion code, and leaves an error
* message in interp->result if an error occurs.
*
* Side effects:
* Depends on the startup script.
*
*----------------------------------------------------------------------
*/
int
Tcl_AppInit(interp)
Tcl_Interp *interp; /* Interpreter for application. */
{
if (Tcl_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
if (Tk_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
/*
* Call the init procedures for included packages. Each call should
* look like this:
*
* if (Mod_Init(interp) == TCL_ERROR) {
* return TCL_ERROR;
* }
*
* where "Mod" is the name of the module.
*/
if (Itcl_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
if (Itk_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
if (SWIG_init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
if (Tcl_PkgRequire(interp, "Iwidgets", (char*)NULL, 0) == NULL) {
return TCL_ERROR;
}
/*
* Call Tcl_CreateCommand for application-specific commands, if
* they weren't already created by the init procedures called above.
*/
/*
* Specify a user-specific startup file to invoke if the application
* is run interactively. Typically the startup file is "~/.apprc"
* where "app" is the name of the application. If this line is deleted
* then no user-specific startup file will be run under any conditions.
*/
Tcl_SetVar(interp, "tcl_rcFileName", SWIG_RcFileName, TCL_GLOBAL_ONLY);
return TCL_OK;
}
%}

View File

@@ -0,0 +1,180 @@
//
// SWIG Interface file for building a new version of iwish
// Dave Beazley
// August 14, 1996
//
#ifdef AUTODOC
%subsection "iwish.i"
%text %{
This module provides a main() program needed to build a new version
of the [incr Tcl] 'iwish' executable. It has been tested with itcl 2.1,
but may need tweaking for later versions and for use with C++.
%}
#endif
%{
/*
* tkAppInit.c --
*
* Provides a default version of the Tcl_AppInit procedure for
* use in wish and similar Tk-based applications.
*
* Copyright (c) 1993 The Regents of the University of California.
* Copyright (c) 1994 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* SCCS: @(#) tkAppInit.c 1.21 96/03/26 16:47:07
*/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SWIG_RcFileName
char *SWIG_RcFileName = "~/.wishrc";
#endif
extern int Tk_Init _ANSI_ARGS_((Tcl_Interp *interp));
extern void Tk_Main _ANSI_ARGS_((int argc, char **argv,
Tcl_AppInitProc *appInitProc));
/*
* The following variable is a special hack that is needed in order for
* Sun shared libraries to be used for Tcl.
*/
extern int matherr _ANSI_ARGS_((void));
static int (*tclDummyMathPtr) _ANSI_ARGS_((void)) = matherr;
#ifdef __cplusplus
}
#endif
#ifdef TK_TEST
extern int Tktest_Init _ANSI_ARGS_((Tcl_Interp *interp));
#endif /* TK_TEST */
#if (TCL_MAJOR_VERSION == 7) && (TCL_MINOR_VERSION < 4)
/*
* The following variable is a special hack that allows applications
* to be linked using the procedure "main" from the Tcl7.3 library. The
* variable generates a reference to "main", which causes main to
* be brought in from the library (and all of Tcl with it).
*/
extern int main _ANSI_ARGS_((int argc, char **argv));
static int (*dummyMainPtr) _ANSI_ARGS_((int argc, char **argv)) = main;
#else
/*
*----------------------------------------------------------------------
*
* main --
*
* This is the main program for the application.
*
* Results:
* None: Tk_Main never returns here, so this procedure never
* returns either.
*
* Side effects:
* Whatever the application does.
*
*----------------------------------------------------------------------
*/
int
#ifdef _USING_PROTOTYPES_
main (int argc, /* Number of command-line arguments. */
char **argv) /* Values of command-line arguments. */
#else
main(argc, argv)
int argc; /* Number of command-line arguments. */
char **argv; /* Values of command-line arguments. */
#endif
{
Tk_Main(argc, argv, Tcl_AppInit);
return 0; /* Needed only to prevent compiler warning. */
}
#endif
/*
*----------------------------------------------------------------------
*
* Tcl_AppInit --
*
* This procedure performs application-specific initialization.
* Most applications, especially those that incorporate additional
* packages, will have their own version of this procedure.
*
* Results:
* Returns a standard Tcl completion code, and leaves an error
* message in interp->result if an error occurs.
*
* Side effects:
* Depends on the startup script.
*
*----------------------------------------------------------------------
*/
int
#ifdef _USING_PROTOTYPES_
Tcl_AppInit (Tcl_Interp *interp) /* Interpreter for application. */
#else
Tcl_AppInit(interp)
Tcl_Interp *interp; /* Interpreter for application. */
#endif
{
if (Tcl_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
if (Tk_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
if (SWIG_init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
#if (TCL_MAJOR_VERSION > 7) || (TCL_MINOR_VERSION > 4)
Tcl_StaticPackage(interp, "Tk", Tk_Init, (Tcl_PackageInitProc *) NULL);
#endif
/*
* Call the init procedures for included packages. Each call should
* look like this:
*
* if (Mod_Init(interp) == TCL_ERROR) {
* return TCL_ERROR;
* }
*
* where "Mod" is the name of the module.
*/
/*
* Call Tcl_CreateCommand for application-specific commands, if
* they weren't already created by the init procedures called above.
*/
/*
* Specify a user-specific startup file to invoke if the application
* is run interactively. Typically the startup file is "~/.apprc"
* where "app" is the name of the application. If this line is deleted
* then no user-specific startup file will be run under any conditions.
*/
#if (TCL_MAJOR_VERSION > 7) || (TCL_MINOR_VERSION > 4)
Tcl_SetVar(interp, "tcl_rcFileName", SWIG_RcFileName, TCL_GLOBAL_ONLY);
#else
tcl_RcFileName = SWIG_RcFileName;
#endif
return TCL_OK;
}
%}

View File

@@ -0,0 +1,86 @@
/*
* tclMacAppInit.c --
*
* Provides a version of the Tcl_AppInit procedure for the example shell.
*
* Copyright (c) 1993-1994 Lockheed Missle & Space Company, AI Center
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* SCCS: @(#) tclMacAppInit.c 1.17 97/01/21 18:13:34
*/
#include "tcl.h"
#include "tclInt.h"
#include "tclMacInt.h"
#if defined(THINK_C)
# include <console.h>
#elif defined(__MWERKS__)
# include <SIOUX.h>
short InstallConsole _ANSI_ARGS_((short fd));
#endif
/*
*----------------------------------------------------------------------
*
* MacintoshInit --
*
* This procedure calls initalization routines to set up a simple
* console on a Macintosh. This is necessary as the Mac doesn't
* have a stdout & stderr by default.
*
* Results:
* Returns TCL_OK if everything went fine. If it didn't the
* application should probably fail.
*
* Side effects:
* Inits the appropiate console package.
*
*----------------------------------------------------------------------
*/
#ifdef __cpluscplus
extern "C"
#endif
extern int
MacintoshInit()
{
#if defined(THINK_C)
/* Set options for Think C console package */
/* The console package calls the Mac init calls */
console_options.pause_atexit = 0;
console_options.title = "\pTcl Interpreter";
#elif defined(__MWERKS__)
/* Set options for CodeWarrior SIOUX package */
SIOUXSettings.autocloseonquit = true;
SIOUXSettings.showstatusline = true;
SIOUXSettings.asktosaveonclose = false;
InstallConsole(0);
SIOUXSetTitle("\pTcl Interpreter");
#elif defined(applec)
/* Init packages used by MPW SIOW package */
InitGraf((Ptr)&qd.thePort);
InitFonts();
InitWindows();
InitMenus();
TEInit();
InitDialogs(nil);
InitCursor();
#endif
TclMacSetEventProc((TclMacConvertEventPtr) SIOUXHandleOneEvent);
/* No problems with initialization */
return TCL_OK;
}

View File

@@ -0,0 +1,229 @@
/* This is a support file needed to build a new version of Wish
Normally, this capability is found in TkAppInit.c, but this creates
tons of namespace problems for many applications. */
#include <Gestalt.h>
#include <ToolUtils.h>
#include <Fonts.h>
#include <Dialogs.h>
#include <SegLoad.h>
#include <Traps.h>
#include "tk.h"
#include "tkInt.h"
#include "tkMacInt.h"
typedef int (*TclMacConvertEventPtr) _ANSI_ARGS_((EventRecord *eventPtr));
Tcl_Interp *gStdoutInterp = NULL;
void TclMacSetEventProc _ANSI_ARGS_((TclMacConvertEventPtr procPtr));
int TkMacConvertEvent _ANSI_ARGS_((EventRecord *eventPtr));
/*
* Prototypes for functions the ANSI library needs to link against.
*/
short InstallConsole _ANSI_ARGS_((short fd));
void RemoveConsole _ANSI_ARGS_((void));
long WriteCharsToConsole _ANSI_ARGS_((char *buff, long n));
long ReadCharsFromConsole _ANSI_ARGS_((char *buff, long n));
extern char * __ttyname _ANSI_ARGS_((long fildes));
short SIOUXHandleOneEvent _ANSI_ARGS_((EventRecord *event));
/*
* Forward declarations for procedures defined later in this file:
*/
/*
*----------------------------------------------------------------------
*
* MacintoshInit --
*
* This procedure calls Mac specific initilization calls. Most of
* these calls must be made as soon as possible in the startup
* process.
*
* Results:
* Returns TCL_OK if everything went fine. If it didn't the
* application should probably fail.
*
* Side effects:
* Inits the application.
*
*----------------------------------------------------------------------
*/
int
MacintoshInit()
{
int i;
long result, mask = 0x0700; /* mask = system 7.x */
/*
* Tk needs us to set the qd pointer it uses. This is needed
* so Tk doesn't have to assume the availablity of the qd global
* variable. Which in turn allows Tk to be used in code resources.
*/
tcl_macQdPtr = &qd;
InitGraf(&tcl_macQdPtr->thePort);
InitFonts();
InitWindows();
InitMenus();
InitDialogs((long) NULL);
InitCursor();
/*
* Make sure we are running on system 7 or higher
*/
if ((NGetTrapAddress(_Gestalt, ToolTrap) ==
NGetTrapAddress(_Unimplemented, ToolTrap))
|| (((Gestalt(gestaltSystemVersion, &result) != noErr)
|| (mask != (result & mask))))) {
panic("Tcl/Tk requires System 7 or higher.");
}
/*
* Make sure we have color quick draw
* (this means we can't run on 68000 macs)
*/
if (((Gestalt(gestaltQuickdrawVersion, &result) != noErr)
|| (result < gestalt32BitQD13))) {
panic("Tk requires Color QuickDraw.");
}
FlushEvents(everyEvent, 0);
SetEventMask(everyEvent);
/*
* Set up stack & heap sizes
*/
/* TODO: stack size
size = StackSpace();
SetAppLimit(GetAppLimit() - 8192);
*/
MaxApplZone();
for (i = 0; i < 4; i++) {
(void) MoreMasters();
}
TclMacSetEventProc(TkMacConvertEvent);
TkConsoleCreate();
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* SetupMainInterp --
*
* This procedure calls initalization routines require a Tcl
* interp as an argument. This call effectively makes the passed
* iterpreter the "main" interpreter for the application.
*
* Results:
* Returns TCL_OK if everything went fine. If it didn't the
* application should probably fail.
*
* Side effects:
* More initilization.
*
*----------------------------------------------------------------------
*/
int
SetupMainInterp(
Tcl_Interp *interp)
{
/*
* Initialize the console only if we are running as an interactive
* application.
*/
TkMacInitAppleEvents(interp);
TkMacInitMenus(interp);
if (strcmp(Tcl_GetVar(interp, "tcl_interactive", TCL_GLOBAL_ONLY), "1")
== 0) {
if (TkConsoleInit(interp) == TCL_ERROR) {
goto error;
}
}
/*
* Attach the global interpreter to tk's expected global console
*/
gStdoutInterp = interp;
return TCL_OK;
error:
panic(interp->result);
return TCL_ERROR;
}
/*
*----------------------------------------------------------------------
*
* InstallConsole, RemoveConsole, etc. --
*
* The following functions provide the UI for the console package.
* Users wishing to replace SIOUX with their own console package
* need only provide the four functions below in a library.
*
* Results:
* See SIOUX documentation for details.
*
* Side effects:
* See SIOUX documentation for details.
*
*----------------------------------------------------------------------
*/
short
InstallConsole(short fd)
{
#pragma unused (fd)
return 0;
}
void
RemoveConsole(void)
{
}
long
WriteCharsToConsole(char *buffer, long n)
{
TkConsolePrint(gStdoutInterp, TCL_STDOUT, buffer, n);
return n;
}
long
ReadCharsFromConsole(char *buffer, long n)
{
return 0;
}
extern char *
__ttyname(long fildes)
{
static char *__devicename = "null device";
if (fildes >= 0 && fildes <= 2) {
return (__devicename);
}
return (0L);
}
short
SIOUXHandleOneEvent(EventRecord *event)
{
return 0;
}

View File

@@ -0,0 +1,74 @@
/* methodcmd.swg : Tcl method invocation */
static int Tcl@CLASS@MethodCmd(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) {
int (*cmd)(ClientData, Tcl_Interp *, int, char **) = 0;
char temp[256], *oldarg;
int rcode;
int length;
char c;
if (argc < 2) {
Tcl_SetResult(interp,"@CLASS@ methods : { @METHODLIST@ }",TCL_STATIC);
return TCL_ERROR;
}
c = argv[1][0];
length = strlen(argv[1]);
SWIG_MakePtr(temp,(void *) clientData, "@CLASSMANGLE@");
if (0);
@METHODS@
else if ((c == 'c') && (strncmp(argv[1],"configure",length) == 0) && (length >= 2)) {
int i = 2;
cmd = 0;
while (i+1 < argc) {
@CONFIGMETHODS@
if (cmd) {
oldarg = argv[i];
argv[i] = &temp[0];
rcode = (*cmd)(clientData,interp,3,&argv[i-1]);
argv[i] = oldarg;
if (rcode == TCL_ERROR) return rcode;
cmd = 0;
} else {
Tcl_SetResult(interp,"Invalid configure option. Must be { @CONFIGLIST@ }",TCL_STATIC);
return TCL_ERROR;
}
i+=2;
}
if ((i < argc) || (i == 2)) {
Tcl_SetResult(interp,"{ @CONFIGLIST@ }",TCL_STATIC);
return TCL_ERROR;
}
return TCL_OK;
} else if ((c == 'c') && (strncmp(argv[1],"cget",length) == 0) && (length >= 2)) {
if (argc == 3) {
if (0) {}
@CGETMETHODS@
else if (strcmp(argv[2],"-this") == 0) {
SWIG_MakePtr(interp->result,(void *) clientData, "@CLASSMANGLE@");
return TCL_OK;
}
if (cmd) {
oldarg = argv[2];
argv[2] = &temp[0];
rcode = (*cmd)(clientData,interp,argc-1,&argv[1]);
argv[2] = oldarg;
return rcode;
} else {
Tcl_SetResult(interp,"Invalid cget option. Must be { -this @CGETLIST@ }",TCL_STATIC);
return TCL_ERROR;
}
} else {
Tcl_SetResult(interp,"{ -this @CGETLIST@ }", TCL_STATIC);
return TCL_ERROR;
}
}
if (!cmd) {
Tcl_SetResult(interp,"Invalid Method. Must be { @METHODLIST@}",TCL_STATIC);
return TCL_ERROR;
}
oldarg = argv[1];
argv[1] = &temp[0];
rcode = (*cmd)(clientData,interp,argc,argv);
argv[1] = oldarg;
return rcode;
}

View File

@@ -0,0 +1,96 @@
/* methodcmd8.swg : Tcl8.x method invocation */
static int Tcl@CLASS@MethodCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST _objv[]) {
int (*cmd)(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST*) = 0;
char *_str;
int rcode;
Tcl_Obj **objv;
Tcl_Obj *oldarg,*tcl_result,*obj;
int length;
char c;
tcl_result = Tcl_GetObjResult(interp);
objv = (Tcl_Obj **) _objv;
if (objc < 2) {
Tcl_SetStringObj(tcl_result,"@CLASS@ methods : { @METHODLIST@ }",-1);
return TCL_ERROR;
}
obj = Tcl_NewObj();
SWIG_SetPointerObj(obj,(void *) clientData,"@CLASSMANGLE@");
_str = Tcl_GetStringFromObj(objv[1],&length);
c = *_str;
if (0);
@METHODS@
else if ((c == 'c') && (strncmp(_str,"configure",length) == 0) && (length >= 2)) {
int i = 2;
cmd = 0;
while (i+1 < objc) {
_str = Tcl_GetStringFromObj(objv[i],&length);
@CONFIGMETHODS@
if (cmd) {
oldarg = objv[i];
objv[i] = obj;
rcode = (*cmd)(clientData,interp,3,&objv[i-1]);
objv[i] = oldarg;
if (rcode == TCL_ERROR) {
Tcl_DecrRefCount(obj);
return rcode;
}
cmd = 0;
} else {
Tcl_SetStringObj(tcl_result,"Invalid configure option. Must be { @CONFIGLIST@ }",-1);
Tcl_DecrRefCount(obj);
return TCL_ERROR;
}
i+=2;
}
if ((i < objc) || (i == 2)) {
Tcl_SetStringObj(tcl_result,"{ @CONFIGLIST@ }",-1);
Tcl_DecrRefCount(obj);
return TCL_ERROR;
}
Tcl_DecrRefCount(obj);
return TCL_OK;
} else if ((c == 'c') && (strncmp(_str,"cget",length) == 0) && (length >= 2)) {
if (objc == 3) {
_str = Tcl_GetStringFromObj(objv[2],&length);
if (0) {}
@CGETMETHODS@
else if (strcmp(_str,"-this") == 0) {
SWIG_SetPointerObj(tcl_result,(void *) clientData, "@CLASSMANGLE@");
Tcl_DecrRefCount(obj);
return TCL_OK;
}
if (cmd) {
oldarg = objv[2];
objv[2] = obj;
rcode = (*cmd)(clientData,interp,objc-1,&objv[1]);
objv[2] = oldarg;
Tcl_DecrRefCount(obj);
return rcode;
} else {
Tcl_SetStringObj(tcl_result,"Invalid cget option. Must be { -this @CGETLIST@ }",-1);
Tcl_DecrRefCount(obj);
return TCL_ERROR;
}
} else {
Tcl_SetStringObj(tcl_result,"{ -this @CGETLIST@ }", -1);
Tcl_DecrRefCount(obj);
return TCL_ERROR;
}
}
if (!cmd) {
Tcl_SetStringObj(tcl_result,"Invalid Method. Must be { @METHODLIST@}",-1);
Tcl_DecrRefCount(obj);
return TCL_ERROR;
}
oldarg = objv[1];
objv[1] = obj;
rcode = (*cmd)(clientData,interp,objc,objv);
objv[1] = oldarg;
Tcl_DecrRefCount(obj);
return rcode;
}

View File

@@ -0,0 +1,69 @@
/* objcmd.swg : Tcl object creation */
static int Tcl@CLASS@Cmd(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) {
void (*del)(ClientData) = 0;
char *name = 0;
int (*cmd)(ClientData, Tcl_Interp *, int, char **) = 0;
@CLASSTYPE@ newObj = 0;
int firstarg = 0;
int thisarg = 0;
if (argc == 1) {
cmd = @TCLCONSTRUCTOR@;
} else {
if (strcmp(argv[1],"-this") == 0) thisarg = 2;
else if (strcmp(argv[1],"-args") == 0) {
firstarg = 1;
cmd = @TCLCONSTRUCTOR@;
} else if (argc == 2) {
firstarg = 1;
name = argv[1];
cmd = @TCLCONSTRUCTOR@;
} else if (argc >= 3) {
name = argv[1];
if (strcmp(argv[2],"-this") == 0) thisarg = 3;
else {
firstarg = 1;
cmd = @TCLCONSTRUCTOR@;
}
}
}
if (cmd) {
int result;
result = (*cmd)(clientData,interp,argc-firstarg,&argv[firstarg]);
if (result == TCL_OK) {
SWIG_GetPtr(interp->result,(void **) &newObj,"@CLASSMANGLE@");
} else { return result; }
if (!name) name = interp->result;
del = @TCLDESTRUCTOR@;
} else if (thisarg > 0) {
if (thisarg < argc) {
char *r;
r = SWIG_GetPtr(argv[thisarg],(void **) &newObj,"@CLASSMANGLE@");
if (r) {
interp->result = "Type error. not a @CLASS@ object.";
return TCL_ERROR;
}
if (!name) name = argv[thisarg];
/* Return value is same as pointer value */
Tcl_SetResult(interp,argv[thisarg],TCL_VOLATILE);
} else {
interp->result = "wrong # args.";
return TCL_ERROR;
}
} else {
interp->result = "No constructor available.";
return TCL_ERROR;
}
{
Tcl_CmdInfo dummy;
if (!Tcl_GetCommandInfo(interp,name,&dummy)) {
Tcl_CreateCommand(interp,name, Tcl@CLASS@MethodCmd, (ClientData) newObj, del);
return TCL_OK;
} else {
Tcl_SetResult(interp,"",TCL_VOLATILE);
Tcl_AppendResult(interp,"Object ", name, " already exists!", (char *) NULL);
return TCL_ERROR;
}
}
}

View File

@@ -0,0 +1,74 @@
/* objcmd8.swg : Tcl 8.x object creation */
static int Tcl@CLASS@Cmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
void (*del)(ClientData) = 0;
char *name = 0;
int (*cmd)(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST*) = 0;
@CLASSTYPE@ newObj = 0;
int firstarg = 0;
int thisarg = 0;
int length;
char *_str;
Tcl_Obj *tcl_result;
tcl_result = Tcl_GetObjResult(interp);
if (objc == 1) {
cmd = @TCLCONSTRUCTOR@;
} else {
_str = Tcl_GetStringFromObj(objv[1],&length);
if (strcmp(_str,"-this") == 0) thisarg = 2;
else if (strcmp(_str,"-args") == 0) {
firstarg = 1;
cmd = @TCLCONSTRUCTOR@;
} else if (objc == 2) {
firstarg = 1;
name = _str;
cmd = @TCLCONSTRUCTOR@;
} else if (objc >= 3) {
name = _str;
_str = Tcl_GetStringFromObj(objv[2],&length);
if (strcmp(_str,"-this") == 0) thisarg = 3;
else {
firstarg = 1;
cmd = @TCLCONSTRUCTOR@;
}
}
}
if (cmd) {
int result;
result = (*cmd)(clientData,interp,objc-firstarg,&objv[firstarg]);
if (result == TCL_OK) {
SWIG_GetPointerObj(interp,tcl_result,(void **) &newObj,"@CLASSMANGLE@");
} else { return result; }
if (!name) name = Tcl_GetStringFromObj(tcl_result,&length);
del = @TCLDESTRUCTOR@;
} else if (thisarg > 0) {
if (thisarg < objc) {
char *r;
r = SWIG_GetPointerObj(interp,objv[thisarg],(void **) &newObj,"@CLASSMANGLE@");
if (r) {
Tcl_SetStringObj(tcl_result,"Type error. not a @CLASS@ object.",-1);
return TCL_ERROR;
}
if (!name) name = Tcl_GetStringFromObj(objv[thisarg],&length);
Tcl_SetStringObj(tcl_result,name,-1);
} else {
Tcl_SetStringObj(tcl_result,"wrong # args.",-1);
return TCL_ERROR;
}
} else {
Tcl_SetStringObj(tcl_result,"No constructor available.",-1);
return TCL_ERROR;
}
{
Tcl_CmdInfo dummy;
if (!Tcl_GetCommandInfo(interp,name,&dummy)) {
Tcl_CreateObjCommand(interp,name, Tcl@CLASS@MethodCmd, (ClientData) newObj, del);
return TCL_OK;
} else {
Tcl_SetStringObj(tcl_result,"Object name already exists!",-1);
return TCL_ERROR;
}
}
}

View File

@@ -0,0 +1,695 @@
//
// SWIG pointer conversion and utility library
//
// Dave Beazley
// April 19, 1997
//
// Tcl specific implementation. This file is included
// by the file ../pointer.i
#if defined(SWIGTCL8)
// -----------------------------------------------------------------
// Define a hack for GetPtr on Tcl 8
//
// -----------------------------------------------------------------
%{
static char *_SWIG_GetPtr(Tcl_Interp *interp, char *s, void **ptr, char *type) {
Tcl_Obj *obj;
char *c;
obj = Tcl_NewStringObj(s, strlen(s));
c = SWIG_GetPointerObj(interp, obj, ptr, type);
if (c) {
c = strstr(s,c);
}
Tcl_DecrRefCount(obj);
return c;
}
#define SWIG_GetPtr(a,b,c) _SWIG_GetPtr(interp, a,b,c)
%}
#endif
%{
#include <ctype.h>
/*------------------------------------------------------------------
ptrcast(value,type)
Constructs a new pointer value. Value may either be a string
or an integer. Type is a string corresponding to either the
C datatype or mangled datatype.
ptrcast(0,"Vector *")
or
ptrcast(0,"Vector_p")
------------------------------------------------------------------ */
static int ptrcast(Tcl_Interp *interp, char *_ptrvalue, char *type) {
char *r,*s;
void *ptr;
char *typestr,*c;
int pv;
int error = 0;
/* Produce a "mangled" version of the type string. */
typestr = (char *) malloc(strlen(type)+2);
/* Go through and munge the typestring */
r = typestr;
*(r++) = '_';
c = type;
while (*c) {
if (!isspace(*c)) {
if ((*c == '*') || (*c == '&')) {
*(r++) = 'p';
}
else *(r++) = *c;
} else {
*(r++) = '_';
}
c++;
}
*(r++) = 0;
/* Check to see what kind of object _PTRVALUE is */
if (Tcl_GetInt(interp,_ptrvalue,&pv) == TCL_OK) {
ptr = (void *) pv;
/* Received a numerical value. Make a pointer out of it */
r = (char *) malloc(strlen(typestr)+22);
if (ptr) {
SWIG_MakePtr(r, ptr, typestr);
} else {
sprintf(r,"_0%s",typestr);
}
Tcl_SetResult(interp,r,TCL_VOLATILE);
free(r);
} else {
/* Have a string. Try to get the real pointer value */
s = _ptrvalue;
r = (char *) malloc(strlen(type)+22);
/* Now extract the pointer value */
if (!SWIG_GetPtr(s,&ptr,0)) {
if (ptr) {
SWIG_MakePtr(r,ptr,typestr);
} else {
sprintf(r,"_0%s",typestr);
}
Tcl_SetResult(interp,r,TCL_VOLATILE);
} else {
error = 1;
}
free(r);
}
free(typestr);
if (error) {
Tcl_SetResult(interp,"Type error in ptrcast. Argument is not a valid pointer value.",TCL_VOLATILE);
return TCL_ERROR;
}
return TCL_OK;
}
/*------------------------------------------------------------------
ptrvalue(ptr,type = 0)
Attempts to dereference a pointer value. If type is given, it
will try to use that type. Otherwise, this function will attempt
to "guess" the proper datatype by checking against all of the
builtin C datatypes.
------------------------------------------------------------------ */
static int ptrvalue(Tcl_Interp *interp, char *_ptrvalue, int index, char *type) {
void *ptr;
char *s;
int error = 0;
if (type) {
if (strlen(type) == 0) type = 0;
}
s = _ptrvalue;
if (SWIG_GetPtr(s,&ptr,0)) {
Tcl_SetResult(interp,"Type error in ptrvalue. Argument is not a valid pointer value.",
TCL_STATIC);
return TCL_ERROR;
}
/* If no datatype was passed, try a few common datatypes first */
if (!type) {
/* No datatype was passed. Type to figure out if it's a common one */
if (!SWIG_GetPtr(s,&ptr,"_int_p")) {
type = "int";
} else if (!SWIG_GetPtr(s,&ptr,"_double_p")) {
type = "double";
} else if (!SWIG_GetPtr(s,&ptr,"_short_p")) {
type = "short";
} else if (!SWIG_GetPtr(s,&ptr,"_long_p")) {
type = "long";
} else if (!SWIG_GetPtr(s,&ptr,"_float_p")) {
type = "float";
} else if (!SWIG_GetPtr(s,&ptr,"_char_p")) {
type = "char";
} else if (!SWIG_GetPtr(s,&ptr,"_char_pp")) {
type = "char *";
} else {
type = "unknown";
}
}
if (!ptr) {
Tcl_SetResult(interp,"Unable to dereference NULL pointer.",TCL_STATIC);
return TCL_ERROR;
}
/* Now we have a datatype. Try to figure out what to do about it */
if (strcmp(type,"int") == 0) {
sprintf(interp->result,"%ld",(long) *(((int *) ptr) + index));
} else if (strcmp(type,"double") == 0) {
Tcl_PrintDouble(interp,(double) *(((double *) ptr)+index), interp->result);
} else if (strcmp(type,"short") == 0) {
sprintf(interp->result,"%ld",(long) *(((short *) ptr) + index));
} else if (strcmp(type,"long") == 0) {
sprintf(interp->result,"%ld",(long) *(((long *) ptr) + index));
} else if (strcmp(type,"float") == 0) {
Tcl_PrintDouble(interp,(double) *(((float *) ptr)+index), interp->result);
} else if (strcmp(type,"char") == 0) {
Tcl_SetResult(interp,((char *) ptr) + index, TCL_VOLATILE);
} else if (strcmp(type,"char *") == 0) {
char *c = *(((char **) ptr)+index);
if (c) Tcl_SetResult(interp,(char *) c, TCL_VOLATILE);
else Tcl_SetResult(interp,"NULL", TCL_VOLATILE);
} else {
Tcl_SetResult(interp,"Unable to dereference unsupported datatype.",TCL_STATIC);
return TCL_ERROR;
}
return TCL_OK;
}
/*------------------------------------------------------------------
ptrcreate(type,value = 0,numelements = 1)
Attempts to create a new object of given type. Type must be
a basic C datatype. Will not create complex objects.
------------------------------------------------------------------ */
static int ptrcreate(Tcl_Interp *interp, char *type, char *_ptrvalue, int numelements) {
void *ptr;
int sz;
char *cast;
char temp[40];
/* Check the type string against a variety of possibilities */
if (strcmp(type,"int") == 0) {
sz = sizeof(int)*numelements;
cast = "_int_p";
} else if (strcmp(type,"short") == 0) {
sz = sizeof(short)*numelements;
cast = "_short_p";
} else if (strcmp(type,"long") == 0) {
sz = sizeof(long)*numelements;
cast = "_long_p";
} else if (strcmp(type,"double") == 0) {
sz = sizeof(double)*numelements;
cast = "_double_p";
} else if (strcmp(type,"float") == 0) {
sz = sizeof(float)*numelements;
cast = "_float_p";
} else if (strcmp(type,"char") == 0) {
sz = sizeof(char)*numelements;
cast = "_char_p";
} else if (strcmp(type,"char *") == 0) {
sz = sizeof(char *)*(numelements+1);
cast = "_char_pp";
} else if (strcmp(type,"void") == 0) {
sz = numelements;
} else {
Tcl_SetResult(interp,"Unable to create unknown datatype.",TCL_STATIC);
return TCL_ERROR;
}
/* Create the new object */
ptr = (void *) malloc(sz);
if (!ptr) {
Tcl_SetResult(interp,"Out of memory in ptrcreate.",TCL_STATIC);
return TCL_ERROR;
}
/* Now try to set its default value */
if (_ptrvalue) {
if (strcmp(type,"int") == 0) {
int *ip,i,ivalue;
Tcl_GetInt(interp,_ptrvalue,&ivalue);
ip = (int *) ptr;
for (i = 0; i < numelements; i++)
ip[i] = ivalue;
} else if (strcmp(type,"short") == 0) {
short *ip;
int i, ivalue;
Tcl_GetInt(interp,_ptrvalue,&ivalue);
ip = (short *) ptr;
for (i = 0; i < numelements; i++)
ip[i] = (short) ivalue;
} else if (strcmp(type,"long") == 0) {
long *ip;
int i, ivalue;
Tcl_GetInt(interp,_ptrvalue,&ivalue);
ip = (long *) ptr;
for (i = 0; i < numelements; i++)
ip[i] = (long) ivalue;
} else if (strcmp(type,"double") == 0) {
double *ip,ivalue;
int i;
Tcl_GetDouble(interp,_ptrvalue,&ivalue);
ip = (double *) ptr;
for (i = 0; i < numelements; i++)
ip[i] = ivalue;
} else if (strcmp(type,"float") == 0) {
float *ip;
double ivalue;
int i;
Tcl_GetDouble(interp,_ptrvalue,&ivalue);
ip = (float *) ptr;
for (i = 0; i < numelements; i++)
ip[i] = (double) ivalue;
} else if (strcmp(type,"char") == 0) {
char *ip,*ivalue;
ivalue = (char *) _ptrvalue;
ip = (char *) ptr;
strncpy(ip,ivalue,numelements-1);
} else if (strcmp(type,"char *") == 0) {
char **ip, *ivalue;
int i;
ivalue = (char *) _ptrvalue;
ip = (char **) ptr;
for (i = 0; i < numelements; i++) {
if (ivalue) {
ip[i] = (char *) malloc(strlen(ivalue)+1);
strcpy(ip[i],ivalue);
} else {
ip[i] = 0;
}
}
ip[numelements] = 0;
}
}
/* Create the pointer value */
SWIG_MakePtr(temp,ptr,cast);
Tcl_SetResult(interp,temp,TCL_VOLATILE);
return TCL_OK;
}
/*------------------------------------------------------------------
ptrset(ptr,value,index = 0,type = 0)
Attempts to set the value of a pointer variable. If type is
given, we will use that type. Otherwise, we'll guess the datatype.
------------------------------------------------------------------ */
static int ptrset(Tcl_Interp *interp, char *_PTRVALUE, char *_VALUE, int index, char *type) {
void *ptr;
char *s;
s = _PTRVALUE;
if (SWIG_GetPtr(s,&ptr,0)) {
Tcl_SetResult(interp,"Type error in ptrset. Argument is not a valid pointer value.",
TCL_STATIC);
return TCL_ERROR;
}
/* If no datatype was passed, try a few common datatypes first */
if (!type) {
/* No datatype was passed. Type to figure out if it's a common one */
if (!SWIG_GetPtr(s,&ptr,"_int_p")) {
type = "int";
} else if (!SWIG_GetPtr(s,&ptr,"_double_p")) {
type = "double";
} else if (!SWIG_GetPtr(s,&ptr,"_short_p")) {
type = "short";
} else if (!SWIG_GetPtr(s,&ptr,"_long_p")) {
type = "long";
} else if (!SWIG_GetPtr(s,&ptr,"_float_p")) {
type = "float";
} else if (!SWIG_GetPtr(s,&ptr,"_char_p")) {
type = "char";
} else if (!SWIG_GetPtr(s,&ptr,"_char_pp")) {
type = "char *";
} else {
type = "unknown";
}
}
if (!ptr) {
Tcl_SetResult(interp,"Unable to set NULL pointer.",TCL_STATIC);
return TCL_ERROR;
}
/* Now we have a datatype. Try to figure out what to do about it */
if (strcmp(type,"int") == 0) {
int ivalue;
Tcl_GetInt(interp,_VALUE, &ivalue);
*(((int *) ptr)+index) = ivalue;
} else if (strcmp(type,"double") == 0) {
double ivalue;
Tcl_GetDouble(interp,_VALUE, &ivalue);
*(((double *) ptr)+index) = (double) ivalue;
} else if (strcmp(type,"short") == 0) {
int ivalue;
Tcl_GetInt(interp,_VALUE, &ivalue);
*(((short *) ptr)+index) = (short) ivalue;
} else if (strcmp(type,"long") == 0) {
int ivalue;
Tcl_GetInt(interp,_VALUE, &ivalue);
*(((long *) ptr)+index) = (long) ivalue;
} else if (strcmp(type,"float") == 0) {
double ivalue;
Tcl_GetDouble(interp,_VALUE, &ivalue);
*(((float *) ptr)+index) = (float) ivalue;
} else if (strcmp(type,"char") == 0) {
char *c = _VALUE;
strcpy(((char *) ptr)+index, c);
} else if (strcmp(type,"char *") == 0) {
char *c = _VALUE;
char **ca = (char **) ptr;
if (ca[index]) free(ca[index]);
if (strcmp(c,"NULL") == 0) {
ca[index] = 0;
} else {
ca[index] = (char *) malloc(strlen(c)+1);
strcpy(ca[index],c);
}
} else {
Tcl_SetResult(interp,"Unable to set unsupported datatype.",TCL_STATIC);
return TCL_ERROR;
}
return TCL_OK;
}
/*------------------------------------------------------------------
ptradd(ptr,offset)
Adds a value to an existing pointer value. Will do a type-dependent
add for basic datatypes. For other datatypes, will do a byte-add.
------------------------------------------------------------------ */
static int ptradd(Tcl_Interp *interp, char *_PTRVALUE, int offset) {
char *r,*s;
void *ptr,*junk;
char *type;
/* Check to see what kind of object _PTRVALUE is */
s = _PTRVALUE;
/* Try to handle a few common datatypes first */
if (!SWIG_GetPtr(s,&ptr,"_int_p")) {
ptr = (void *) (((int *) ptr) + offset);
} else if (!SWIG_GetPtr(s,&ptr,"_double_p")) {
ptr = (void *) (((double *) ptr) + offset);
} else if (!SWIG_GetPtr(s,&ptr,"_short_p")) {
ptr = (void *) (((short *) ptr) + offset);
} else if (!SWIG_GetPtr(s,&ptr,"_long_p")) {
ptr = (void *) (((long *) ptr) + offset);
} else if (!SWIG_GetPtr(s,&ptr,"_float_p")) {
ptr = (void *) (((float *) ptr) + offset);
} else if (!SWIG_GetPtr(s,&ptr,"_char_p")) {
ptr = (void *) (((char *) ptr) + offset);
} else if (!SWIG_GetPtr(s,&ptr,0)) {
ptr = (void *) (((char *) ptr) + offset);
} else {
Tcl_SetResult(interp,"Type error in ptradd. Argument is not a valid pointer value.",TCL_STATIC);
return TCL_ERROR;
}
type = SWIG_GetPtr(s,&junk,"INVALID POINTER");
r = (char *) malloc(strlen(type)+20);
if (ptr) {
SWIG_MakePtr(r,ptr,type);
} else {
sprintf(r,"_0%s",type);
}
Tcl_SetResult(interp,r,TCL_VOLATILE);
free(r);
return TCL_OK;
}
/*------------------------------------------------------------------
ptrmap(type1,type2)
Allows a mapping between type1 and type2. (Like a typedef)
------------------------------------------------------------------ */
static void ptrmap(char *type1, char *type2) {
char *typestr1,*typestr2,*c,*r;
/* Produce a "mangled" version of the type string. */
typestr1 = (char *) malloc(strlen(type1)+2);
/* Go through and munge the typestring */
r = typestr1;
*(r++) = '_';
c = type1;
while (*c) {
if (!isspace(*c)) {
if ((*c == '*') || (*c == '&')) {
*(r++) = 'p';
}
else *(r++) = *c;
} else {
*(r++) = '_';
}
c++;
}
*(r++) = 0;
typestr2 = (char *) malloc(strlen(type2)+2);
/* Go through and munge the typestring */
r = typestr2;
*(r++) = '_';
c = type2;
while (*c) {
if (!isspace(*c)) {
if ((*c == '*') || (*c == '&')) {
*(r++) = 'p';
}
else *(r++) = *c;
} else {
*(r++) = '_';
}
c++;
}
*(r++) = 0;
SWIG_RegisterMapping(typestr1,typestr2,0);
SWIG_RegisterMapping(typestr2,typestr1,0);
}
/*------------------------------------------------------------------
ptrfree(ptr)
Destroys a pointer value
------------------------------------------------------------------ */
int ptrfree(Tcl_Interp *interp, char *_PTRVALUE) {
void *ptr, *junk;
char *s;
s = _PTRVALUE;
if (SWIG_GetPtr(s,&ptr,0)) {
Tcl_SetResult(interp,"Type error in ptrfree. Argument is not a valid pointer value.",TCL_STATIC);
return TCL_ERROR;
}
/* Check to see if this pointer is a char ** */
if (!SWIG_GetPtr(s,&junk,"_char_pp")) {
char **c = (char **) ptr;
if (c) {
int i = 0;
while (c[i]) {
free(c[i]);
i++;
}
}
}
if (ptr)
free((char *) ptr);
return TCL_OK;
}
%}
%typemap(tcl,out) int ptrcast,
int ptrvalue,
int ptrcreate,
int ptrset,
int ptradd,
int ptrfree
{
return $source;
}
%typemap(tcl8,out) int ptrcast,
int ptrvalue,
int ptrcreate,
int ptrset,
int ptradd,
int ptrfree
{
return $source;
}
// Ignore the Tcl_Interp * value, but set it to a value
%typemap(tcl,ignore) Tcl_Interp * {
$target = interp;
}
%typemap(tcl8,ignore) Tcl_Interp * {
$target = interp;
}
int ptrcast(Tcl_Interp *interp, char *ptr, char *type);
// Casts a pointer ptr to a new datatype given by the string type.
// type may be either the SWIG generated representation of a datatype
// or the C representation. For example :
//
// ptrcast $ptr double_p # Tcl representation
// ptrcast $ptr "double *" # C representation
//
// A new pointer value is returned. ptr may also be an integer
// value in which case the value will be used to set the pointer
// value. For example :
//
// set a [ptrcast 0 Vector_p]
//
// Will create a NULL pointer of type "Vector_p"
//
// The casting operation is sensitive to formatting. As a result,
// "double *" is different than "double*". As a result of thumb,
// there should always be exactly one space between the C datatype
// and any pointer specifiers (*).
int ptrvalue(Tcl_Interp *interp, char *ptr, int index = 0, char *type = 0);
// Returns the value that a pointer is pointing to (ie. dereferencing).
// The type is automatically inferred by the pointer type--thus, an
// integer pointer will return an integer, a double will return a double,
// and so on. The index and type fields are optional parameters. When
// an index is specified, this function returns the value of ptr[index].
// This allows array access. When a type is specified, it overrides
// the given pointer type. Examples :
//
// ptrvalue $a # Returns the value *a
// ptrvalue $a 10 # Returns the value a[10]
// ptrvalue $a 10 double # Returns a[10] assuming a is a double *
int ptrset(Tcl_Interp *interp, char *ptr, char *value, int index = 0, char *type = 0);
// Sets the value pointed to by a pointer. The type is automatically
// inferred from the pointer type so this function will work for
// integers, floats, doubles, etc... The index and type fields are
// optional. When an index is given, it provides array access. When
// type is specified, it overrides the given pointer type. Examples :
//
// ptrset $a 3 # Sets the value *a = 3
// ptrset $a 3 10 # Sets a[10] = 3
// ptrset $a 3 10 int # Sets a[10] = 3 assuming a is a int *
int ptrcreate(Tcl_Interp *interp, char *type, char *value = 0, int nitems = 1);
// Creates a new object and returns a pointer to it. This function
// can be used to create various kinds of objects for use in C functions.
// type specifies the basic C datatype to create and value is an
// optional parameter that can be used to set the initial value of the
// object. nitems is an optional parameter that can be used to create
// an array. This function results in a memory allocation using
// malloc(). Examples :
//
// set a [ptrcreate "double"] # Create a new double, return pointer
// set a [ptrcreate int 7] # Create an integer, set value to 7
// set a [ptrcreate int 0 1000] # Create an integer array with initial
// # values all set to zero
//
// This function only recognizes a few common C datatypes as listed below :
//
// int, short, long, float, double, char, char *, void
//
// All other datatypes will result in an error. However, other
// datatypes can be created by using the ptrcast function. For
// example:
//
// set a [ptrcast [ptrcreate int 0 100],"unsigned int *"]
int ptrfree(Tcl_Interp *interp, char *ptr);
// Destroys the memory pointed to by ptr. This function calls free()
// and should only be used with objects created by ptrcreate(). Since
// this function calls free, it may work with other objects, but this
// is generally discouraged unless you absolutely know what you're
// doing.
int ptradd(Tcl_Interp *interp, char *ptr, int offset);
// Adds a value to the current pointer value. For the C datatypes of
// int, short, long, float, double, and char, the offset value is the
// number of objects and works in exactly the same manner as in C. For
// example, the following code steps through the elements of an array
//
// set a [ptrcreate double 0 100] # Create an array double a[100]
// set b $a
// for {set i 0} {$i < 100} {incr i 1} {
// ptrset $b [expr{0.0025*$i}] # set *b = 0.0025*i
// set b [ptradd $b 1] # b++ (go to next double)
// }
//
// In this case, adding one to b goes to the next double.
//
// For all other datatypes (including all complex datatypes), the
// offset corresponds to bytes. This function does not perform any
// bounds checking and negative offsets are perfectly legal.
void ptrmap(char *type1, char *type2);
// This is a rarely used function that performs essentially the same
// operation as a C typedef. To manage datatypes at run-time, SWIG
// modules manage an internal symbol table of type mappings. This
// table keeps track of which types are equivalent to each other. The
// ptrmap() function provides a mechanism for scripts to add symbols
// to this table. For example :
//
// ptrmap double_p Real_p
//
// would make the types "double_p" and "Real_p" equivalent to each
// other. Pointers of either type could now be used interchangably.
//
// Normally this function is not needed, but it can be used to
// circumvent SWIG's normal type-checking behavior or to work around
// weird type-handling bugs.
// Clear the ignore typemap
%typemap(tcl,ignore) Tcl_Interp *;
%typemap(tcl8,ignore) Tcl_Interp *;

View File

@@ -0,0 +1,249 @@
/*
* $Header$
*
* swigtcl.swg
*/
#if defined(_WIN32) || defined(__WIN32__)
# if defined(_MSC_VER)
# define SWIGEXPORT(a) __declspec(dllexport) a
# else
# if defined(__BORLANDC__)
# define SWIGEXPORT(a) a _export
# else
# define SWIGEXPORT(a) a
# endif
# endif
#else
# define SWIGEXPORT(a) a
#endif
/*****************************************************************************
* $Header$
*
* swigptr.swg
*****************************************************************************/
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef SWIG_NOINCLUDE
extern void SWIG_MakePtr(char *, void *, char *);
extern void SWIG_RegisterMapping(char *, char *, void *(*)(void *));
extern char *SWIG_GetPtr(char *, void **, char *);
#else
#ifdef SWIG_GLOBAL
#define SWIGSTATICRUNTIME(a) SWIGEXPORT(a)
#else
#define SWIGSTATICRUNTIME(a) static a
#endif
/* SWIG pointer structure */
typedef struct SwigPtrType {
char *name; /* Datatype name */
int len; /* Length (used for optimization) */
void *(*cast)(void *); /* Pointer casting function */
struct SwigPtrType *next; /* Linked list pointer */
} SwigPtrType;
/* Pointer cache structure */
typedef struct {
int stat; /* Status (valid) bit */
SwigPtrType *tp; /* Pointer to type structure */
char name[256]; /* Given datatype name */
char mapped[256]; /* Equivalent name */
} SwigCacheType;
static int SwigPtrMax = 64; /* Max entries that can be currently held */
static int SwigPtrN = 0; /* Current number of entries */
static int SwigPtrSort = 0; /* Status flag indicating sort */
static int SwigStart[256]; /* Starting positions of types */
static SwigPtrType *SwigPtrTable = 0; /* Table containing pointer equivalences */
/* Cached values */
#define SWIG_CACHESIZE 8
#define SWIG_CACHEMASK 0x7
static SwigCacheType SwigCache[SWIG_CACHESIZE];
static int SwigCacheIndex = 0;
static int SwigLastCache = 0;
/* Sort comparison function */
static int swigsort(const void *data1, const void *data2) {
SwigPtrType *d1 = (SwigPtrType *) data1;
SwigPtrType *d2 = (SwigPtrType *) data2;
return strcmp(d1->name,d2->name);
}
/* Register a new datatype with the type-checker */
SWIGSTATICRUNTIME(void)
SWIG_RegisterMapping(char *origtype, char *newtype, void *(*cast)(void *)) {
int i;
SwigPtrType *t = 0,*t1;
/* Allocate the pointer table if necessary */
if (!SwigPtrTable) {
SwigPtrTable = (SwigPtrType *) malloc(SwigPtrMax*sizeof(SwigPtrType));
}
/* Grow the table */
if (SwigPtrN >= SwigPtrMax) {
SwigPtrMax = 2*SwigPtrMax;
SwigPtrTable = (SwigPtrType *) realloc((char *) SwigPtrTable,SwigPtrMax*sizeof(SwigPtrType));
}
for (i = 0; i < SwigPtrN; i++) {
if (strcmp(SwigPtrTable[i].name,origtype) == 0) {
t = &SwigPtrTable[i];
break;
}
}
if (!t) {
t = &SwigPtrTable[SwigPtrN++];
t->name = origtype;
t->len = strlen(t->name);
t->cast = 0;
t->next = 0;
}
/* Check for existing entries */
while (t->next) {
if ((strcmp(t->name,newtype) == 0)) {
if (cast) t->cast = cast;
return;
}
t = t->next;
}
t1 = (SwigPtrType *) malloc(sizeof(SwigPtrType));
t1->name = newtype;
t1->len = strlen(t1->name);
t1->cast = cast;
t1->next = 0;
t->next = t1;
SwigPtrSort = 0;
}
/* Make a pointer value string */
SWIGSTATICRUNTIME(void)
SWIG_MakePtr(char *c, const void *ptr, char *type) {
static char hex[17] = "0123456789abcdef";
unsigned long p, s;
char result[24], *r;
r = result;
p = (unsigned long) ptr;
if (p > 0) {
while (p > 0) {
s = p & 0xf;
*(r++) = hex[s];
p = p >> 4;
}
*r = '_';
while (r >= result)
*(c++) = *(r--);
strcpy (c, type);
} else {
strcpy (c, "NULL");
}
}
/* Function for getting a pointer value */
SWIGSTATICRUNTIME(char *)
SWIG_GetPtr(char *c, void **ptr, char *t)
{
unsigned long p;
char temp_type[256], *name;
int i, len, start, end;
SwigPtrType *sp,*tp;
SwigCacheType *cache;
register int d;
p = 0;
/* Pointer values must start with leading underscore */
if (*c != '_') {
*ptr = (void *) 0;
if (strcmp(c,"NULL") == 0) return (char *) 0;
else c;
}
c++;
/* Extract hex value from pointer */
while (d = *c) {
if ((d >= '0') && (d <= '9'))
p = (p << 4) + (d - '0');
else if ((d >= 'a') && (d <= 'f'))
p = (p << 4) + (d - ('a'-10));
else
break;
c++;
}
*ptr = (void *) p;
if ((!t) || (strcmp(t,c)==0)) return (char *) 0;
if (!SwigPtrSort) {
qsort((void *) SwigPtrTable, SwigPtrN, sizeof(SwigPtrType), swigsort);
for (i = 0; i < 256; i++) SwigStart[i] = SwigPtrN;
for (i = SwigPtrN-1; i >= 0; i--) SwigStart[(int) (SwigPtrTable[i].name[1])] = i;
for (i = 255; i >= 1; i--) {
if (SwigStart[i-1] > SwigStart[i])
SwigStart[i-1] = SwigStart[i];
}
SwigPtrSort = 1;
for (i = 0; i < SWIG_CACHESIZE; i++) SwigCache[i].stat = 0;
}
/* First check cache for matches. Uses last cache value as starting point */
cache = &SwigCache[SwigLastCache];
for (i = 0; i < SWIG_CACHESIZE; i++) {
if (cache->stat && (strcmp(t,cache->name) == 0) && (strcmp(c,cache->mapped) == 0)) {
cache->stat++;
if (cache->tp->cast) *ptr = (*(cache->tp->cast))(*ptr);
return (char *) 0;
}
SwigLastCache = (SwigLastCache+1) & SWIG_CACHEMASK;
if (!SwigLastCache) cache = SwigCache;
else cache++;
}
/* Type mismatch. Look through type-mapping table */
start = SwigStart[(int) t[1]];
end = SwigStart[(int) t[1]+1];
sp = &SwigPtrTable[start];
/* Try to find a match */
while (start <= end) {
if (strncmp(t,sp->name,sp->len) == 0) {
name = sp->name;
len = sp->len;
tp = sp->next;
/* Try to find entry for our given datatype */
while(tp) {
if (tp->len >= 255) {
return c;
}
strcpy(temp_type,tp->name);
strncat(temp_type,t+len,255-tp->len);
if (strcmp(c,temp_type) == 0) {
strcpy(SwigCache[SwigCacheIndex].mapped,c);
strcpy(SwigCache[SwigCacheIndex].name,t);
SwigCache[SwigCacheIndex].stat = 1;
SwigCache[SwigCacheIndex].tp = tp;
SwigCacheIndex = SwigCacheIndex & SWIG_CACHEMASK;
/* Get pointer value */
*ptr = (void *) p;
if (tp->cast) *ptr = (*(tp->cast))(*ptr);
return (char *) 0;
}
tp = tp->next;
}
}
sp++;
start++;
}
return c;
}
#endif
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,367 @@
/**************************************************************************
* $Header$
*
* swigtcl8.swg
*
* This file provides type-checked pointer support to Tcl 8.0.
**********************************************************************/
#if defined(_WIN32) || defined(__WIN32__)
# if defined(_MSC_VER)
# define SWIGEXPORT(a) __declspec(dllexport) a
# else
# if defined(__BORLANDC__)
# define SWIGEXPORT(a) a _export
# else
# define SWIGEXPORT(a) a
# endif
# endif
#else
# define SWIGEXPORT(a) a
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifdef SWIG_GLOBAL
#include <tcl.h>
#define SWIGSTATICRUNTIME(a) SWIGEXPORT(a)
#else
#define SWIGSTATICRUNTIME(a) static a
#endif
#ifdef SWIG_NOINCLUDE
extern void SWIG_SetPointerObj(Tcl_Obj *, void *, char *);
extern void SWIG_RegisterMapping(char *, char *, void *(*)(void *));
extern char *SWIG_GetPointerObj(Tcl_Interp *, Tcl_Obj *, void **, char *);
extern int SWIG_MakePtr(char *, const void *, char *);
extern void SWIG_RegisterType();
#else
/* These are internal variables. Should be static */
typedef struct SwigPtrType {
char *name;
int len;
void *(*cast)(void *);
struct SwigPtrType *next;
} SwigPtrType;
/* Pointer cache structure */
typedef struct {
int stat; /* Status (valid) bit */
SwigPtrType *tp; /* Pointer to type structure */
char name[256]; /* Given datatype name */
char mapped[256]; /* Equivalent name */
} SwigCacheType;
static int SwigPtrMax = 64; /* Max entries that can be currently held */
static int SwigPtrN = 0; /* Current number of entries */
static int SwigPtrSort = 0; /* Status flag indicating sort */
static int SwigStart[256]; /* Array containing start locations (for searching) */
static SwigPtrType *SwigPtrTable = 0; /* Table containing pointer equivalences */
/* Cached values */
#define SWIG_CACHESIZE 8
#define SWIG_CACHEMASK 0x7
static SwigCacheType SwigCache[SWIG_CACHESIZE];
static int SwigCacheIndex = 0;
static int SwigLastCache = 0;
/* Sort comparison function */
static int swigsort(const void *data1, const void *data2) {
SwigPtrType *d1 = (SwigPtrType *) data1;
SwigPtrType *d2 = (SwigPtrType *) data2;
return strcmp(d1->name,d2->name);
}
/* Binary Search function */
static int swigcmp(const void *key, const void *data) {
char *k = (char *) key;
SwigPtrType *d = (SwigPtrType *) data;
return strncmp(k,d->name,d->len);
}
/*---------------------------------------------------------------------
* SWIG_RegisterMapping(char *origtype, char *newtype, void *(*cast)(void *))
*
* Register a new type-mapping with the type-checking system.
*---------------------------------------------------------------------*/
SWIGSTATICRUNTIME(void)
SWIG_RegisterMapping(char *origtype, char *newtype, void *(*cast)(void *)) {
int i;
SwigPtrType *t = 0, *t1;
if (!SwigPtrTable) {
SwigPtrTable = (SwigPtrType *) malloc(SwigPtrMax*sizeof(SwigPtrType));
SwigPtrN = 0;
}
if (SwigPtrN >= SwigPtrMax) {
SwigPtrMax = 2*SwigPtrMax;
SwigPtrTable = (SwigPtrType *) realloc(SwigPtrTable,SwigPtrMax*sizeof(SwigPtrType));
}
for (i = 0; i < SwigPtrN; i++)
if (strcmp(SwigPtrTable[i].name,origtype) == 0) {
t = &SwigPtrTable[i];
break;
}
if (!t) {
t = &SwigPtrTable[SwigPtrN];
t->name = origtype;
t->len = strlen(origtype);
t->cast = 0;
t->next = 0;
SwigPtrN++;
}
while (t->next) {
if (strcmp(t->name,newtype) == 0) {
if (cast) t->cast = cast;
return;
}
t = t->next;
}
t1 = (SwigPtrType *) malloc(sizeof(SwigPtrType));
t1->name = newtype;
t1->len = strlen(newtype);
t1->cast = cast;
t1->next = 0;
t->next = t1;
SwigPtrSort = 0;
}
/*---------------------------------------------------------------------
* void SWIG_SetPointerObj(Tcl_Obj *objPtr, void *ptr, char *type)
*
* Sets a Tcl object to a pointer value.
* ptr = void pointer value
* type = string representing type
*
*---------------------------------------------------------------------*/
SWIGSTATICRUNTIME(void)
SWIG_SetPointerObj(Tcl_Obj *objPtr, void *_ptr, char *type) {
static char _hex[16] =
{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'a', 'b', 'c', 'd', 'e', 'f'};
unsigned long _p, _s;
char _result[20], *_r; /* Note : a 64-bit hex number = 16 digits */
char _temp[20], *_c;
_r = _result;
_p = (unsigned long) _ptr;
if (_p > 0) {
while (_p > 0) {
_s = _p & 0xf;
*(_r++) = _hex[_s];
_p = _p >> 4;
}
*_r = '_';
_c = &_temp[0];
while (_r >= _result)
*(_c++) = *(_r--);
*_c = 0;
Tcl_SetStringObj(objPtr,_temp,-1);
} else {
Tcl_SetStringObj(objPtr,"NULL",-1);
}
if (_ptr)
Tcl_AppendToObj(objPtr,type,-1);
}
/* This is for backwards compatibility */
SWIGSTATICRUNTIME(int)
SWIG_MakePtr(char *_c, const void *_ptr, char *type)
{
static char _hex[16] =
{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'a', 'b', 'c', 'd', 'e', 'f'};
unsigned long _p, _s;
char _result[20], *_r;
int l = 0;
_r = _result;
_p = (unsigned long) _ptr;
if (_p > 0) {
while (_p > 0) {
_s = _p & 0xf;
*(_r++) = _hex[_s];
_p = _p >> 4;
l++;
}
*_r = '_';
l++;
while (_r >= _result)
*(_c++) = *(_r--);
_r = type;
while (*_r)
*(_c++) = *(_r++);
*(_c) = 0;
} else {
strcpy (_c, "NULL");
}
return l;
}
/*---------------------------------------------------------------------
* char *SWIG_GetPointerObj(Tcl_Interp *interp, Tcl_Obj *objPtr, void **ptr, char *type)
*
* Attempts to extract a pointer value from our pointer type.
* Upon failure, returns a string corresponding to the actual datatype.
* Upon success, returns NULL and sets the pointer value in ptr.
*---------------------------------------------------------------------*/
SWIGSTATICRUNTIME(char *)
SWIG_GetPointerObj(Tcl_Interp *interp, Tcl_Obj *objPtr, void **ptr, char *_t) {
unsigned long _p;
char temp_type[256];
char *name;
int i, len;
SwigPtrType *sp,*tp;
SwigCacheType *cache;
int start, end;
char *_c;
_p = 0;
/* Extract the pointer value as a string */
_c = Tcl_GetStringFromObj(objPtr, &i);
/* Pointer values must start with leading underscore */
if (*_c == '_') {
_c++;
/* Extract hex value from pointer */
while (*_c) {
if ((*_c >= '0') && (*_c <= '9'))
_p = (_p << 4) + (*_c - '0');
else if ((*_c >= 'a') && (*_c <= 'f'))
_p = (_p << 4) + ((*_c - 'a') + 10);
else
break;
_c++;
}
if (_t) {
if (strcmp(_t,_c)) {
if (!SwigPtrSort) {
qsort((void *) SwigPtrTable, SwigPtrN, sizeof(SwigPtrType), swigsort);
for (i = 0; i < 256; i++) {
SwigStart[i] = SwigPtrN;
}
for (i = SwigPtrN-1; i >= 0; i--) {
SwigStart[(int) (SwigPtrTable[i].name[1])] = i;
}
for (i = 255; i >= 1; i--) {
if (SwigStart[i-1] > SwigStart[i])
SwigStart[i-1] = SwigStart[i];
}
SwigPtrSort = 1;
for (i = 0; i < SWIG_CACHESIZE; i++)
SwigCache[i].stat = 0;
}
/* First check cache for matches. Uses last cache value as starting point */
cache = &SwigCache[SwigLastCache];
for (i = 0; i < SWIG_CACHESIZE; i++) {
if (cache->stat) {
if (strcmp(_t,cache->name) == 0) {
if (strcmp(_c,cache->mapped) == 0) {
cache->stat++;
*ptr = (void *) _p;
if (cache->tp->cast) *ptr = (*(cache->tp->cast))(*ptr);
return (char *) 0;
}
}
}
SwigLastCache = (SwigLastCache+1) & SWIG_CACHEMASK;
if (!SwigLastCache) cache = SwigCache;
else cache++;
}
/* We have a type mismatch. Will have to look through our type
mapping table to figure out whether or not we can accept this datatype */
start = SwigStart[(int) _t[1]];
end = SwigStart[(int) _t[1]+1];
sp = &SwigPtrTable[start];
while (start < end) {
if (swigcmp(_t,sp) == 0) break;
sp++;
start++;
}
if (start > end) sp = 0;
/* Try to find a match for this */
while (start <= end) {
if (swigcmp(_t,sp) == 0) {
name = sp->name;
len = sp->len;
tp = sp->next;
/* Try to find entry for our given datatype */
while(tp) {
if (tp->len >= 255) {
return _c;
}
strcpy(temp_type,tp->name);
strncat(temp_type,_t+len,255-tp->len);
if (strcmp(_c,temp_type) == 0) {
strcpy(SwigCache[SwigCacheIndex].mapped,_c);
strcpy(SwigCache[SwigCacheIndex].name,_t);
SwigCache[SwigCacheIndex].stat = 1;
SwigCache[SwigCacheIndex].tp = tp;
SwigCacheIndex = SwigCacheIndex & SWIG_CACHEMASK;
/* Get pointer value */
*ptr = (void *) _p;
if (tp->cast) *ptr = (*(tp->cast))(*ptr);
return (char *) 0;
}
tp = tp->next;
}
}
sp++;
start++;
}
/* Didn't find any sort of match for this data.
Get the pointer value and return the received type */
*ptr = (void *) _p;
return _c;
} else {
/* Found a match on the first try. Return pointer value */
*ptr = (void *) _p;
return (char *) 0;
}
} else {
/* No type specified. Good luck */
*ptr = (void *) _p;
return (char *) 0;
}
} else {
if (strcmp (_c, "NULL") == 0) {
*ptr = (void *) 0;
return (char *) 0;
}
*ptr = (void *) 0;
return _c;
}
}
/*---------------------------------------------------------------------
* void SWIG_RegisterType()
*
* Registers our new datatype with an interpreter.
*---------------------------------------------------------------------*/
SWIGSTATICRUNTIME(void)
SWIG_RegisterType() {
/* Does nothing at the moment */
}
#endif
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,106 @@
//
// $Header$
//
// SWIG File for building new tclsh program
// Dave Beazley
// April 25, 1996
//
/* Revision History
* $Log$
* Revision 1.1 2002/04/29 19:56:57 RD
* Since I have made several changes to SWIG over the years to accomodate
* special cases and other things in wxPython, and since I plan on making
* several more, I've decided to put the SWIG sources in wxPython's CVS
* instead of relying on maintaining patches. This effectivly becomes a
* fork of an obsolete version of SWIG, :-( but since SWIG 1.3 still
* doesn't have some things I rely on in 1.1, not to mention that my
* custom patches would all have to be redone, I felt that this is the
* easier road to take.
*
* Revision 1.1.1.1 1999/02/28 02:00:56 beazley
* Swig1.1
*
* Revision 1.1 1996/05/22 19:47:45 beazley
* Initial revision
*
*/
#ifdef AUTODOC
%subsection "tclsh.i"
%text %{
This module provides the Tcl_AppInit() function needed to build a
new version of the tclsh executable. This file should not be used
when using dynamic loading. To make an interface file work with
both static and dynamic loading, put something like this in your
interface file :
#ifdef STATIC
%include tclsh.i
#endif
%}
#endif
%{
/* A TCL_AppInit() function that lets you build a new copy
* of tclsh.
*
* The macro SWIG_init contains the name of the initialization
* function in the wrapper file.
*/
#ifndef SWIG_RcFileName
char *SWIG_RcFileName = "~/.myapprc";
#endif
#ifdef MAC_TCL
extern int MacintoshInit _ANSI_ARGS_((void));
#endif
int Tcl_AppInit(Tcl_Interp *interp){
if (Tcl_Init(interp) == TCL_ERROR)
return TCL_ERROR;
/* Now initialize our functions */
if (SWIG_init(interp) == TCL_ERROR)
return TCL_ERROR;
#if TCL_MAJOR_VERSION > 7 || TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION >= 5
Tcl_SetVar(interp,"tcl_rcFileName",SWIG_RcFileName,TCL_GLOBAL_ONLY);
#else
tcl_RcFileName = SWIG_RcFileName;
#endif
#ifdef SWIG_RcRsrcName
Tcl_SetVar(interp,"tcl_rcRsrcName",SWIG_RcRsrcName,TCL_GLOBAL);
#endif
return TCL_OK;
}
#if TCL_MAJOR_VERSION > 7 || TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION >= 4
int main(int argc, char **argv) {
#ifdef MAC_TCL
char *newArgv[2];
if (MacintoshInit() != TCL_OK) {
Tcl_Exit(1);
}
argc = 1;
newArgv[0] = "tclsh";
newArgv[1] = NULL;
argv = newArgv;
#endif
Tcl_Main(argc, argv, Tcl_AppInit);
return(0);
}
#else
extern int main();
#endif
%}

View File

@@ -0,0 +1,29 @@
// Initialization code for Tix
%{
#ifdef __cplusplus
extern "C" {
#endif
extern int Tix_Init(Tcl_Interp *);
#ifdef __cplusplus
}
#endif
%}
#ifdef AUTODOC
%subsection "tix.i"
%text %{
This module initializes the Tix extension. This is usually done in
combination with the wish.i or similar module. For example :
%include wish.i // Build a new wish executable
%include tix.i // Initialize Tix
%}
#endif
%init %{
if (Tix_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
%}

View File

@@ -0,0 +1,555 @@
//
// SWIG Typemap library
// Dave Beazley
// May 4, 1997
//
// Tcl implementation
//
// This library provides standard typemaps for modifying SWIG's behavior.
// With enough entries in this file, I hope that very few people actually
// ever need to write a typemap.
#ifdef AUTODOC
%section "Typemap Library (Tcl)",info,after,pre,nosort,skip=1,chop_left=3,chop_right=0,chop_top=0,chop_bottom=0
%text %{
%include typemaps.i
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.
%}
#endif
// ------------------------------------------------------------------------
// Pointer handling
//
// These mappings provide support for input/output arguments and common
// uses for C/C++ pointers.
// ------------------------------------------------------------------------
// INPUT typemaps.
// These remap a C pointer to be an "INPUT" value which is passed by value
// instead of reference.
#ifdef AUTODOC
%subsection "Input Methods"
%text %{
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
unsigned int *INPUT
unsigned short *INPUT
unsigned long *INPUT
unsigned char *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);
%}
#endif
%typemap(tcl,in) double *INPUT(double temp)
{
if (Tcl_GetDouble(interp,$source,&temp) == TCL_ERROR) {
return TCL_ERROR;
}
$target = &temp;
}
%typemap(tcl,in) float *INPUT(double dvalue, float temp)
{
if (Tcl_GetDouble(interp,$source,&dvalue) == TCL_ERROR) {
return TCL_ERROR;
}
temp = (float) dvalue;
$target = &temp;
}
%typemap(tcl,in) int *INPUT(int temp)
{
if (Tcl_GetInt(interp,$source,&temp) == TCL_ERROR) {
return TCL_ERROR;
}
$target = &temp;
}
%typemap(tcl,in) short *INPUT(int ivalue, short temp)
{
if (Tcl_GetInt(interp,$source,&ivalue) == TCL_ERROR) {
return TCL_ERROR;
}
temp = (short) ivalue;
$target = &temp;
}
%typemap(tcl,in) long *INPUT(int ivalue, long temp)
{
if (Tcl_GetInt(interp,$source,&ivalue) == TCL_ERROR) {
return TCL_ERROR;
}
temp = (long) ivalue;
$target = &temp;
}
%typemap(tcl,in) unsigned int *INPUT(int ivalue, unsigned int temp)
{
if (Tcl_GetInt(interp,$source,&ivalue) == TCL_ERROR) {
return TCL_ERROR;
}
temp = (unsigned int) ivalue;
$target = &temp;
}
%typemap(tcl,in) unsigned short *INPUT(int ivalue, unsigned short temp)
{
if (Tcl_GetInt(interp,$source,&ivalue) == TCL_ERROR) {
return TCL_ERROR;
}
temp = (unsigned short) ivalue;
$target = &temp;
}
%typemap(tcl,in) unsigned long *INPUT(int ivalue, unsigned long temp)
{
if (Tcl_GetInt(interp,$source,&ivalue) == TCL_ERROR) {
return TCL_ERROR;
}
temp = (unsigned long) ivalue;
$target = &temp;
}
%typemap(tcl,in) unsigned char *INPUT(int ivalue, unsigned char temp)
{
if (Tcl_GetInt(interp,$source,&ivalue) == TCL_ERROR) {
return TCL_ERROR;
}
temp = (unsigned char) ivalue;
$target = &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.
#ifdef AUTODOC
%subsection "Output Methods"
%text %{
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
unsigned int *OUTPUT
unsigned short *OUTPUT
unsigned long *OUTPUT
unsigned char *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.
%}
#endif
// Force the argument to be ignored.
%typemap(tcl,ignore) 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),
float *OUTPUT(float temp),
double *OUTPUT(double temp)
{
$target = &temp;
}
%typemap(tcl,argout) int *OUTPUT,
short *OUTPUT,
long *OUTPUT
{
char dtemp[64];
sprintf(dtemp,"%ld",(long) *($source));
Tcl_AppendElement(interp,dtemp);
}
%typemap(tcl,argout) unsigned int *OUTPUT,
unsigned short *OUTPUT,
unsigned long *OUTPUT,
unsigned char *OUTPUT
{
char dtemp[64];
sprintf(dtemp,"%lu", (unsigned long) *($source));
Tcl_AppendElement(interp,dtemp);
}
%typemap(tcl,argout) float *OUTPUT,
double *OUTPUT
{
char dtemp[TCL_DOUBLE_SPACE];
Tcl_PrintDouble(interp, (double) *($source), dtemp);
Tcl_AppendElement(interp,dtemp);
}
// BOTH
// Mappings for an argument that is both an input and output
// parameter
#ifdef AUTODOC
%subsection "Input/Output Methods"
%text %{
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 *BOTH
short *BOTH
long *BOTH
unsigned int *BOTH
unsigned short *BOTH
unsigned long *BOTH
unsigned char *BOTH
float *BOTH
double *BOTH
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 *BOTH);
or you can use the %apply directive :
%include typemaps.i
%apply double *BOTH { 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]
%}
#endif
%typemap(tcl,in) int *BOTH = int *INPUT;
%typemap(tcl,in) short *BOTH = short *INPUT;
%typemap(tcl,in) long *BOTH = long *INPUT;
%typemap(tcl,in) unsigned int *BOTH = unsigned int *INPUT;
%typemap(tcl,in) unsigned short *BOTH = unsigned short *INPUT;
%typemap(tcl,in) unsigned long *BOTH = unsigned long *INPUT;
%typemap(tcl,in) unsigned char *BOTH = unsigned char *INPUT;
%typemap(tcl,in) float *BOTH = float *INPUT;
%typemap(tcl,in) double *BOTH = double *INPUT;
%typemap(tcl,argout) int *BOTH = int *OUTPUT;
%typemap(tcl,argout) short *BOTH = short *OUTPUT;
%typemap(tcl,argout) long *BOTH = long *OUTPUT;
%typemap(tcl,argout) unsigned int *BOTH = unsigned int *OUTPUT;
%typemap(tcl,argout) unsigned short *BOTH = unsigned short *OUTPUT;
%typemap(tcl,argout) unsigned long *BOTH = unsigned long *OUTPUT;
%typemap(tcl,argout) unsigned char *BOTH = unsigned char *OUTPUT;
%typemap(tcl,argout) float *BOTH = float *OUTPUT;
%typemap(tcl,argout) double *BOTH = double *OUTPUT;
// --------------------------------------------------------------------
// Special types
//
// --------------------------------------------------------------------
// If interp * appears as a function argument, we ignore it and get
// it from the wrapper function.
#ifdef AUTODOC
%subsection "Special Methods"
%text %{
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();
%}
#endif
%typemap(tcl,ignore) Tcl_Interp *interp {
$target = interp;
}
// If return code is a Tcl_Result, simply pass it on
%typemap(tcl,out) int Tcl_Result {
interp->result = "";
return $source;
}
/***************************************************************************
* Tcl 8.0 typemaps
***************************************************************************/
// ------------------------------------------------------------------------
// Pointer handling
//
// These mappings provide support for input/output arguments and common
// uses for C/C++ pointers.
// ------------------------------------------------------------------------
// INPUT typemaps.
// These remap a C pointer to be an "INPUT" value which is passed by value
// instead of reference.
%typemap(tcl8,in) double *INPUT(double temp)
{
if (Tcl_GetDoubleFromObj(interp,$source,&temp) == TCL_ERROR) {
return TCL_ERROR;
}
$target = &temp;
}
%typemap(tcl8,in) float *INPUT(double dvalue, float temp)
{
if (Tcl_GetDoubleFromObj(interp,$source,&dvalue) == TCL_ERROR) {
return TCL_ERROR;
}
temp = (float) dvalue;
$target = &temp;
}
%typemap(tcl8,in) int *INPUT(int temp)
{
if (Tcl_GetIntFromObj(interp,$source,&temp) == TCL_ERROR) {
return TCL_ERROR;
}
$target = &temp;
}
%typemap(tcl8,in) short *INPUT(int ivalue, short temp)
{
if (Tcl_GetIntFromObj(interp,$source,&ivalue) == TCL_ERROR) {
return TCL_ERROR;
}
temp = (short) ivalue;
$target = &temp;
}
%typemap(tcl8,in) long *INPUT(int ivalue, long temp)
{
if (Tcl_GetIntFromObj(interp,$source,&ivalue) == TCL_ERROR) {
return TCL_ERROR;
}
temp = (long) ivalue;
$target = &temp;
}
%typemap(tcl8,in) unsigned int *INPUT(int ivalue, unsigned int temp)
{
if (Tcl_GetIntFromObj(interp,$source,&ivalue) == TCL_ERROR) {
return TCL_ERROR;
}
temp = (unsigned int) ivalue;
$target = &temp;
}
%typemap(tcl8,in) unsigned short *INPUT(int ivalue, unsigned short temp)
{
if (Tcl_GetIntFromObj(interp,$source,&ivalue) == TCL_ERROR) {
return TCL_ERROR;
}
temp = (unsigned short) ivalue;
$target = &temp;
}
%typemap(tcl8,in) unsigned long *INPUT(int ivalue, unsigned long temp)
{
if (Tcl_GetIntFromObj(interp,$source,&ivalue) == TCL_ERROR) {
return TCL_ERROR;
}
temp = (unsigned long) ivalue;
$target = &temp;
}
%typemap(tcl8,in) unsigned char *INPUT(int ivalue, unsigned char temp)
{
if (Tcl_GetIntFromObj(interp,$source,&ivalue) == TCL_ERROR) {
return TCL_ERROR;
}
temp = (unsigned char) ivalue;
$target = &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.
// Force the argument to be ignored.
%typemap(tcl8,ignore) 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),
float *OUTPUT(float temp),
double *OUTPUT(double temp)
{
$target = &temp;
}
%typemap(tcl8,argout) int *OUTPUT,
short *OUTPUT,
long *OUTPUT,
unsigned int *OUTPUT,
unsigned short *OUTPUT,
unsigned long *OUTPUT,
unsigned char *OUTPUT
{
Tcl_Obj *o;
o = Tcl_NewIntObj((int) *($source));
Tcl_ListObjAppendElement(interp,$target,o);
}
%typemap(tcl8,argout) float *OUTPUT,
double *OUTPUT
{
Tcl_Obj *o;
o = Tcl_NewDoubleObj((double) *($source));
Tcl_ListObjAppendElement(interp,$target,o);
}
// BOTH
// Mappings for an argument that is both an input and output
// parameter
%typemap(tcl8,in) int *BOTH = int *INPUT;
%typemap(tcl8,in) short *BOTH = short *INPUT;
%typemap(tcl8,in) long *BOTH = long *INPUT;
%typemap(tcl8,in) unsigned int *BOTH = unsigned int *INPUT;
%typemap(tcl8,in) unsigned short *BOTH = unsigned short *INPUT;
%typemap(tcl8,in) unsigned long *BOTH = unsigned long *INPUT;
%typemap(tcl8,in) unsigned char *BOTH = unsigned char *INPUT;
%typemap(tcl8,in) float *BOTH = float *INPUT;
%typemap(tcl8,in) double *BOTH = double *INPUT;
%typemap(tcl8,argout) int *BOTH = int *OUTPUT;
%typemap(tcl8,argout) short *BOTH = short *OUTPUT;
%typemap(tcl8,argout) long *BOTH = long *OUTPUT;
%typemap(tcl8,argout) unsigned int *BOTH = unsigned int *OUTPUT;
%typemap(tcl8,argout) unsigned short *BOTH = unsigned short *OUTPUT;
%typemap(tcl8,argout) unsigned long *BOTH = unsigned long *OUTPUT;
%typemap(tcl8,argout) unsigned char *BOTH = unsigned char *OUTPUT;
%typemap(tcl8,argout) float *BOTH = float *OUTPUT;
%typemap(tcl8,argout) double *BOTH = double *OUTPUT;
// --------------------------------------------------------------------
// Special types
//
// --------------------------------------------------------------------
// If interp * appears as a function argument, we ignore it and get
// it from the wrapper function.
%typemap(tcl8,ignore) Tcl_Interp *interp {
$target = interp;
}
// If return code is a Tcl_Result, simply pass it on
%typemap(tcl8,out) int Tcl_Result {
return $source;
}

View File

@@ -0,0 +1,170 @@
//
// $Header$
//
// SWIG File for making wish
// Dave Beazley
// April 25, 1996
//
/* Revision History
* $Log$
* Revision 1.1 2002/04/29 19:56:57 RD
* Since I have made several changes to SWIG over the years to accomodate
* special cases and other things in wxPython, and since I plan on making
* several more, I've decided to put the SWIG sources in wxPython's CVS
* instead of relying on maintaining patches. This effectivly becomes a
* fork of an obsolete version of SWIG, :-( but since SWIG 1.3 still
* doesn't have some things I rely on in 1.1, not to mention that my
* custom patches would all have to be redone, I felt that this is the
* easier road to take.
*
* Revision 1.2 1999/11/05 21:45:14 beazley
* Minor Changes
*
* Revision 1.1.1.1 1999/02/28 02:00:56 beazley
* Swig1.1
*
* Revision 1.1 1996/05/22 19:47:45 beazley
* Initial revision
*
*/
#ifdef AUTODOC
%subsection "wish.i"
%text %{
This module provides the Tk_AppInit() function needed to build a
new version of the wish executable. Like tclsh.i, this file should
not be used with dynamic loading. To make an interface file work with
both static and dynamic loading, put something like this in your
interface file :
#ifdef STATIC
%include wish.i
#endif
A startup file may be specified by defining the symbol SWIG_RcFileName
as follows (this should be included in a code-block) :
#define SWIG_RcFileName "~/.mywishrc"
%}
#endif
%{
/* Initialization code for wish */
#include <tk.h>
#ifndef SWIG_RcFileName
char *SWIG_RcFileName = "~/.wishrc";
#endif
#ifdef MAC_TCL
extern int MacintoshInit _ANSI_ARGS_((void));
extern int SetupMainInterp _ANSI_ARGS_((Tcl_Interp *interp));
#endif
/*
*----------------------------------------------------------------------
*
* Tcl_AppInit --
*
* This procedure performs application-specific initialization.
* Most applications, especially those that incorporate additional
* packages, will have their own version of this procedure.
*
* Results:
* Returns a standard Tcl completion code, and leaves an error
* message in interp->result if an error occurs.
*
* Side effects:
* Depends on the startup script.
*
*----------------------------------------------------------------------
*/
int Tcl_AppInit(Tcl_Interp *interp)
{
#ifndef MAC_TCL
Tk_Window main;
main = Tk_MainWindow(interp);
#endif
/*
* Call the init procedures for included packages. Each call should
* look like this:
*
* if (Mod_Init(interp) == TCL_ERROR) {
* return TCL_ERROR;
* }
*
* where "Mod" is the name of the module.
*/
if (Tcl_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
if (Tk_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
/*
* Call Tcl_CreateCommand for application-specific commands, if
* they weren't already created by the init procedures called above.
*/
if (SWIG_init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
#ifdef MAC_TCL
SetupMainInterp(interp);
#endif
/*
* Specify a user-specific startup file to invoke if the application
* is run interactively. Typically the startup file is "~/.apprc"
* where "app" is the name of the application. If this line is deleted
* then no user-specific startup file will be run under any conditions.
*/
#if TCL_MAJOR_VERSION >= 8 || TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION >= 5
Tcl_SetVar(interp,"tcl_rcFileName",SWIG_RcFileName,TCL_GLOBAL_ONLY);
#else
tcl_RcFileName = SWIG_RcFileName;
#endif
/* For Macintosh might also want this */
#ifdef MAC_TCL
#ifdef SWIG_RcRsrcName
Tcl_SetVar(interp,"tcl_rcRsrcName",SWIG_RcRsrcName,TCL_GLOBAL_ONLY);
#endif
#endif
return TCL_OK;
}
#if TK_MAJOR_VERSION >= 4
int main(int argc, char **argv) {
#ifdef MAC_TCL
char *newArgv[2];
if (MacintoshInit() != TCL_OK) {
Tcl_Exit(1);
}
argc = 1;
newArgv[0] = "Wish";
newArgv[1] = NULL;
argv = newArgv;
#endif
Tk_Main(argc, argv, Tcl_AppInit);
return(0);
}
#else
extern int main();
#endif
%}