Added files
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@39 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
7ee1dec92d
commit
09bd3946db
37 changed files with 6653 additions and 0 deletions
401
SWIG/Lib/array.i
Normal file
401
SWIG/Lib/array.i
Normal file
|
|
@ -0,0 +1,401 @@
|
|||
//
|
||||
// array.i
|
||||
// Dave Beazley
|
||||
// November 30, 1996
|
||||
//
|
||||
// This SWIG library file provides access to C arrays.
|
||||
|
||||
%module carray
|
||||
|
||||
%section "SWIG C Array Module",info,after,pre,nosort,skip=1,chop_left=3,chop_right=0,chop_top=0,chop_bottom=0
|
||||
|
||||
%text %{
|
||||
%include array.i
|
||||
|
||||
This module provides scripting language access to various kinds of C/C++
|
||||
arrays. For each datatype, a collection of four functions are created :
|
||||
|
||||
<type>_array(size) : Create a new array of given size
|
||||
<type>_get(array, index) : Get an element from the array
|
||||
<type>_set(array, index, value) : Set an element in the array
|
||||
<type>_destroy(array) : Destroy an array
|
||||
|
||||
The functions in this library are only low-level accessor functions
|
||||
designed to directly access C arrays. Like C, no bounds checking is
|
||||
performed so use at your own peril.
|
||||
%}
|
||||
|
||||
// Grab the SWIG exception library
|
||||
|
||||
#ifndef AUTODOC
|
||||
%include exception.i
|
||||
#endif
|
||||
|
||||
// A Typemap used to check input arguments.
|
||||
|
||||
%typemap(check) int *, double *, float *, char **, short *, long * {
|
||||
if (!$target) {
|
||||
SWIG_exception(SWIG_ValueError,"Received a NULL Pointer");
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(ret) int *, double *, float *, char **, short *, long * {
|
||||
if (!$source) {
|
||||
SWIG_exception(SWIG_MemoryError,"Out of memory.");
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Integer array support
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
%subsection "Integer Arrays"
|
||||
%text %{
|
||||
The following functions provide access to integer arrays (mapped
|
||||
onto the C 'int' datatype.
|
||||
%}
|
||||
|
||||
%{
|
||||
#include <limits.h>
|
||||
|
||||
/* Create a new integer array */
|
||||
|
||||
static int *int_array(int size) {
|
||||
#ifdef __cplusplus
|
||||
return new int[size];
|
||||
#else
|
||||
return (int *) malloc(size*sizeof(int));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Destroy an integer array */
|
||||
|
||||
static void int_destroy(int *array) {
|
||||
if (array) {
|
||||
#ifdef __cplusplus
|
||||
delete array;
|
||||
#else
|
||||
free(array);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* Return an element */
|
||||
|
||||
static int int_get(int *array, int index) {
|
||||
if (array) {
|
||||
return array[index];
|
||||
} else {
|
||||
return INT_MIN;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set an element */
|
||||
|
||||
static int int_set(int *array, int index, int value) {
|
||||
if (array) {
|
||||
return (array[index] = value);
|
||||
} else {
|
||||
return INT_MIN;
|
||||
}
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
int *int_array(int nitems);
|
||||
/* Creates a new array of integers. nitems specifies the number of elements.
|
||||
The array is created using malloc() in C and new() in C++. */
|
||||
|
||||
void int_destroy(int *array);
|
||||
/* Destroys the given array. */
|
||||
|
||||
int int_get(int *array, int index);
|
||||
/* Returns the value of array[index]. */
|
||||
|
||||
int int_set(int *array, int index, int value);
|
||||
/* Sets array[index] = value. Returns value. */
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Floating point
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
%subsection "Floating Point Arrays"
|
||||
/* The following functions provide access to arrays of floats and doubles. */
|
||||
|
||||
|
||||
%{
|
||||
#include <float.h>
|
||||
|
||||
/* Create a new float array */
|
||||
|
||||
static float *float_array(int size) {
|
||||
#ifdef __cplusplus
|
||||
return new float[size];
|
||||
#else
|
||||
return (float *) malloc(size*sizeof(float));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Destroy an array */
|
||||
|
||||
static void float_destroy(float *array) {
|
||||
if (array) {
|
||||
#ifdef __cplusplus
|
||||
delete array;
|
||||
#else
|
||||
free(array);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* Return an element */
|
||||
|
||||
static float float_get(float *array, int index) {
|
||||
if (array) {
|
||||
return array[index];
|
||||
} else {
|
||||
return FLT_MIN;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set an element */
|
||||
|
||||
static float float_set(float *array, int index, float value) {
|
||||
if (array) {
|
||||
return (array[index] = value);
|
||||
} else {
|
||||
return FLT_MIN;
|
||||
}
|
||||
}
|
||||
|
||||
/* Create a new double array */
|
||||
|
||||
static double *double_array(int size) {
|
||||
#ifdef __cplusplus
|
||||
return new double[size];
|
||||
#else
|
||||
return (double *) malloc(size*sizeof(double));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Destroy an array */
|
||||
|
||||
static void double_destroy(double *array) {
|
||||
if (array) {
|
||||
#ifdef __cplusplus
|
||||
delete array;
|
||||
#else
|
||||
free(array);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* Return an element */
|
||||
|
||||
static double double_get(double *array, int index) {
|
||||
if (array) {
|
||||
return array[index];
|
||||
} else {
|
||||
return FLT_MIN;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set an element */
|
||||
|
||||
static double double_set(double *array, int index, double value) {
|
||||
if (array) {
|
||||
return (array[index] = value);
|
||||
} else {
|
||||
return FLT_MIN;
|
||||
}
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
double *double_array(int nitems);
|
||||
/* Creates a new array of doubles. nitems specifies the number of elements.
|
||||
The array is created using malloc() in C and new() in C++. */
|
||||
|
||||
void double_destroy(double *array);
|
||||
/* Destroys the given array. */
|
||||
|
||||
double double_get(double *array, int index);
|
||||
/* Returns the value of array[index]. */
|
||||
|
||||
double double_set(double *array, int index, double value);
|
||||
/* Sets array[index] = value. Returns value. */
|
||||
|
||||
float *float_array(int nitems);
|
||||
/* Creates a new array of floats. nitems specifies the number of elements.
|
||||
The array is created using malloc() in C and new() in C++. */
|
||||
|
||||
void float_destroy(float *array);
|
||||
/* Destroys the given array. */
|
||||
|
||||
float float_get(float *array, int index);
|
||||
/* Returns the value of array[index]. */
|
||||
|
||||
float float_set(float *array, int index, float value);
|
||||
/* Sets array[index] = value. Returns value. */
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Character strings
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
%subsection "String Arrays"
|
||||
|
||||
%text %{
|
||||
The following functions provide support for the 'char **' datatype. This
|
||||
is primarily used to handle argument lists and other similar structures that
|
||||
need to be passed to a C/C++ function.
|
||||
%}
|
||||
|
||||
#if defined(SWIGTCL)
|
||||
%text %{
|
||||
To convert from a Tcl list into a 'char **', the following code can be used :
|
||||
|
||||
# $list is a list
|
||||
set args [string_array expr {[llength $list] + 1}]
|
||||
set i 0
|
||||
foreach a $list {
|
||||
string_set $args $i $a
|
||||
incr i 1
|
||||
}
|
||||
string_set $i ""
|
||||
# $args is now a char ** type
|
||||
%}
|
||||
#elif defined(SWIGPERL)
|
||||
|
||||
%text %{
|
||||
To convert from a Perl list into a 'char **', code similar to the following
|
||||
can be used :
|
||||
|
||||
# @list is a list
|
||||
my $l = scalar(@list);
|
||||
my $args = string_array($l+1);
|
||||
my $i = 0;
|
||||
foreach $arg (@list) {
|
||||
string_set($args,$i,$arg);
|
||||
$i++;
|
||||
}
|
||||
string_set($args,$i,"");
|
||||
|
||||
(of course, there is always more than one way to do it)
|
||||
%}
|
||||
#elif defined(SWIGPYTHON)
|
||||
|
||||
%text %{
|
||||
To convert from a Python list to a 'char **', code similar to the following
|
||||
can be used :
|
||||
|
||||
# 'list' is a list
|
||||
args = string_array(len(list)+1)
|
||||
for i in range(0,len(list)):
|
||||
string_set(args,i,list[i])
|
||||
string_set(args,len(list),"")
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
||||
%{
|
||||
/* Create character string arrays */
|
||||
|
||||
static char **string_array(int size) {
|
||||
char **a;
|
||||
int i;
|
||||
#ifdef __cplusplus
|
||||
a = new char *[size];
|
||||
#else
|
||||
a = (char **) malloc(size*sizeof(char *));
|
||||
#endif
|
||||
for (i = 0; i < size; i++)
|
||||
a[i] = 0;
|
||||
return a;
|
||||
}
|
||||
|
||||
/* Destroy a string array */
|
||||
|
||||
static void string_destroy(char **array) {
|
||||
int i = 0;
|
||||
if (array) {
|
||||
while (array[i]) {
|
||||
#ifdef __cplusplus
|
||||
delete array[i];
|
||||
#else
|
||||
free(array[i]);
|
||||
#endif
|
||||
i++;
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
delete array;
|
||||
#else
|
||||
free(array);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* Get an element */
|
||||
|
||||
static char *string_get(char **array_string, int index) {
|
||||
if (array_string)
|
||||
if (array_string[index]) return (array_string[index]);
|
||||
else return "";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
/* Set an element */
|
||||
|
||||
static char *string_set(char **array_string, int index, char * val) {
|
||||
if (array_string) {
|
||||
if (array_string[index]) {
|
||||
#ifdef __cplusplus
|
||||
delete array_string[index];
|
||||
#else
|
||||
free(array_string[index]);
|
||||
#endif
|
||||
}
|
||||
if (strlen(val) > 0) {
|
||||
#ifdef __cplusplus
|
||||
array_string[index] = new char[strlen(val)+1];
|
||||
#else
|
||||
array_string[index] = (char *) malloc(strlen(val)+1);
|
||||
#endif
|
||||
strcpy(array_string[index],val);
|
||||
return array_string[index];
|
||||
} else {
|
||||
array_string[index] = 0;
|
||||
return val;
|
||||
}
|
||||
} else return val;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
char **string_array(int nitems);
|
||||
/* Creates a new array of strings. nitems specifies the number of elements.
|
||||
The array is created using malloc() in C and new() in C++. Each element
|
||||
of the array is set to NULL upon initialization. */
|
||||
|
||||
void string_destroy(char **array);
|
||||
/* Destroys the given array. Each element of the array is assumed to be
|
||||
a NULL-terminated string allocated with malloc() or new(). All of
|
||||
these strings will be destroyed as well. (It is probably only safe to
|
||||
use this function on an array created by string_array) */
|
||||
|
||||
char *string_get(char **array, int index);
|
||||
/* Returns the value of array[index]. Returns a string of zero length
|
||||
if the corresponding element is NULL. */
|
||||
|
||||
char *string_set(char **array, int index, char *value);
|
||||
/* Sets array[index] = value. value is assumed to be a NULL-terminated
|
||||
string. A string of zero length is mapped into a NULL value. When
|
||||
setting the value, the value will be copied into a new string allocated
|
||||
with malloc() or new(). Any previous value in the array will be
|
||||
destroyed. */
|
||||
|
||||
|
||||
%typemap(check) int *, double *, float *, char **, short *, long * = PREVIOUS;
|
||||
%typemap(out) int *, double *, float *, char **, short *, long * = PREVIOUS;
|
||||
|
||||
101
SWIG/Lib/autodoc.i
Normal file
101
SWIG/Lib/autodoc.i
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
// This file automatically generates the SWIG library documentation
|
||||
%doconly
|
||||
%style latex_section="\\newpage \\section{:}"
|
||||
%title "SWIG Library Reference",pre,sort,chop_left = 0,noinfo
|
||||
/*
|
||||
Version 1.1p4
|
||||
January, 1998
|
||||
|
||||
Copyright (C) 1996-1998
|
||||
Dave Beazley
|
||||
|
||||
(This file was automatically generated by SWIG)
|
||||
*/
|
||||
%style html_contents="<hr><h2>:</h2>"
|
||||
%module swig_lib
|
||||
|
||||
%section " Introduction"
|
||||
%text %{
|
||||
This file describes all of the functions in the generic SWIG library.
|
||||
The SWIG library is a collection of generally useful functions that
|
||||
can be used to supplement an interface file. These include functions
|
||||
to manipulate arrays, functions from the C library, and interesting
|
||||
modules.
|
||||
|
||||
This document is automatically generated by SWIG from the file
|
||||
"swig_lib/autodoc.i". Some modules may supply additional documentation
|
||||
for a particular target language. To recreate the documentation for
|
||||
a particular target language, simply run SWIG on the file 'autodoc.i'
|
||||
with the appropriate target language option.
|
||||
%}
|
||||
|
||||
#if defined(SWIGTCL)
|
||||
%text %{
|
||||
This document has been generated for Tcl.
|
||||
%}
|
||||
#elif defined(SWIGPERL)
|
||||
%text %{
|
||||
This document has been generated for Perl.
|
||||
%}
|
||||
#elif defined(SWIGPYTHON)
|
||||
%text %{
|
||||
This document has been generated for Python.
|
||||
%}
|
||||
#endif
|
||||
|
||||
%subsection "Call for contributions"
|
||||
%text %{
|
||||
My long-term goal is for the SWIG library to be a collection of useful
|
||||
modules that can be used to quickly put together interesting programs.
|
||||
To contribute new modules send e-mail to beazley@cs.utah.edu and I
|
||||
will include them here.
|
||||
%}
|
||||
|
||||
#define AUTODOC
|
||||
|
||||
%include array.i
|
||||
%include math.i
|
||||
%include timers.i
|
||||
%include malloc.i
|
||||
%include memory.i
|
||||
%include exception.i
|
||||
%include pointer.i
|
||||
%include constraints.i
|
||||
%include typemaps.i
|
||||
|
||||
#ifdef SWIGTCL
|
||||
%section "Tcl Library Files",nosort
|
||||
%text %{
|
||||
The following library modules are available when using the Tcl
|
||||
language module.
|
||||
%}
|
||||
%include "tcl/consthash.i"
|
||||
%include "tcl/constarray.i"
|
||||
%include "tcl/tclsh.i"
|
||||
%include "tcl/wish.i"
|
||||
#endif
|
||||
|
||||
#ifdef SWIGPYTHON
|
||||
%section "Python Library Files",nosort
|
||||
%text %{
|
||||
The following modules are available when using the Python language
|
||||
module.
|
||||
%}
|
||||
%include "python/embed.i"
|
||||
%include "python/embed14.i"
|
||||
%include "python/embed13.i"
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SWIGPERL
|
||||
%section "Perl Library Files",nosort
|
||||
|
||||
%text %{
|
||||
The following modules are available when using the Perl5 language
|
||||
module.
|
||||
%}
|
||||
|
||||
%include "perl5/perlmain.i"
|
||||
#endif
|
||||
|
||||
|
||||
175
SWIG/Lib/carray.i
Normal file
175
SWIG/Lib/carray.i
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
//
|
||||
// $Header$
|
||||
// carray.i
|
||||
// Dave Beazley
|
||||
// March 24, 1996
|
||||
//
|
||||
// This SWIG library file supports C arrays of various datatypes.
|
||||
// These arrays are probably *not* compatible with scripting languages
|
||||
// but they are compatible with C functions.
|
||||
//
|
||||
/* Revision History
|
||||
* -- $Log$
|
||||
* -- Revision 1.1 2000/01/11 21:15:47 beazley
|
||||
* -- Added files
|
||||
* --
|
||||
* -- Revision 1.1.1.1 1999/02/28 02:00:53 beazley
|
||||
* -- Swig1.1
|
||||
* --
|
||||
* -- Revision 1.1 1996/05/22 17:23:48 beazley
|
||||
* -- Initial revision
|
||||
* --
|
||||
*/
|
||||
|
||||
%module carray
|
||||
%{
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* Create an integer array of given size */
|
||||
|
||||
static int *array_int(int size) {
|
||||
return (int *) malloc(size*sizeof(int));
|
||||
}
|
||||
|
||||
static int get_int(int *array_int, int index) {
|
||||
if (array_int)
|
||||
return (array_int[index]);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_int(int *array_int, int index, int val) {
|
||||
if (array_int)
|
||||
return (array_int[index] = val);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Create double precision arrays */
|
||||
|
||||
static double *array_double(int size) {
|
||||
return (double *) malloc(size*sizeof(double));
|
||||
}
|
||||
|
||||
static double get_double(double *array_double, int index) {
|
||||
if (array_double)
|
||||
return (array_double[index]);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static double set_double(double *array_double, int index, double val) {
|
||||
if (array_double)
|
||||
return (array_double[index] = val);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Create byte arrays */
|
||||
|
||||
typedef unsigned char byte;
|
||||
|
||||
static byte *array_byte(int size) {
|
||||
return (byte *) malloc(size*sizeof(byte));
|
||||
}
|
||||
|
||||
static byte get_byte(byte *array_byte, int index) {
|
||||
if (array_byte)
|
||||
return (array_byte[index]);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static byte set_byte(byte *array_byte, int index, byte val) {
|
||||
if (array_byte)
|
||||
return (array_byte[index] = val);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Create character string arrays */
|
||||
|
||||
static char **array_string(int size) {
|
||||
char **a;
|
||||
int i;
|
||||
|
||||
a = (char **) malloc(size*sizeof(char *));
|
||||
for (i = 0; i < size; i++)
|
||||
a[i] = 0;
|
||||
return a;
|
||||
}
|
||||
|
||||
static char *get_string(char **array_string, int index) {
|
||||
if (array_string)
|
||||
return (array_string[index]);
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
static char *set_string(char **array_string, int index, char * val) {
|
||||
if (array_string) {
|
||||
if (array_string[index]) free(array_string[index]);
|
||||
if (strlen(val) > 0) {
|
||||
array_string[index] = (char *) malloc(strlen(val)+1);
|
||||
strcpy(array_string[index],val);
|
||||
return array_string[index];
|
||||
} else {
|
||||
array_string[index] = 0;
|
||||
return val;
|
||||
}
|
||||
}
|
||||
else
|
||||
return val;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%section "Array Operations"
|
||||
|
||||
int *array_int(int size);
|
||||
/* Creates an integer array of size elements. Integers are the same
|
||||
size as the C int type. */
|
||||
|
||||
int get_int(int *array_int, int index) ;
|
||||
/* Return the integer in array_int[index] */
|
||||
|
||||
int set_int(int *array_int, int index, int ival);
|
||||
/* Sets array_int[index] = ival. Returns it's value so you
|
||||
can use this function in an expression. */
|
||||
|
||||
/* Create double precision arrays */
|
||||
|
||||
double *array_double(int size);
|
||||
/* Creates an array of double precision floats. */
|
||||
|
||||
double get_double(double *array_double, int index);
|
||||
/* Return the double in array_double[index] */
|
||||
|
||||
double set_double(double *array_double, int index, double dval);
|
||||
/* Sets array_double[index] = dval. Returns it's value */
|
||||
|
||||
typedef unsigned char byte;
|
||||
|
||||
byte *array_byte(int nbytes);
|
||||
/* Creates a byte array. A byte is defined as an unsigned char. */
|
||||
|
||||
byte get_byte(byte *array_byte, int index);
|
||||
/* Returns array_byte[index] */
|
||||
|
||||
byte set_byte(byte *array_byte, int index, byte val);
|
||||
/* Sets array_byte[index] = val. Returns it's new value */
|
||||
|
||||
char **array_string(int size);
|
||||
/* Creates a string array. A string is array is the same as char ** in C */
|
||||
|
||||
char *get_string(char **array_string, int index);
|
||||
/* Returns character string in array_string[index]. If that entry is
|
||||
NULL, returns an empty string */
|
||||
|
||||
char *set_string(char **array_string, int index, char * string);
|
||||
/* Sets array_string[index] = string. string must be a 0-terminated
|
||||
ASCII string. If string is "" then this will create a NULL pointer. */
|
||||
|
||||
|
||||
|
||||
208
SWIG/Lib/constraints.i
Normal file
208
SWIG/Lib/constraints.i
Normal file
|
|
@ -0,0 +1,208 @@
|
|||
//
|
||||
// SWIG constraint library
|
||||
// Dave Beazley
|
||||
// May 4, 1997
|
||||
//
|
||||
// This library file contains typemaps for implementing various kinds of
|
||||
// constraints. Depends upon the SWIG exception library for generating
|
||||
// errors in a language-independent manner.
|
||||
|
||||
#ifdef AUTODOC
|
||||
%section "Constraint Library",info,after,pre,nosort,skip=1,chop_left=3,chop_right=0,chop_top=0,chop_bottom=0
|
||||
|
||||
%text %{
|
||||
%include constraints.i
|
||||
|
||||
This library provides support for applying constraints to function
|
||||
arguments. Using a constraint, you can restrict arguments to be
|
||||
positive numbers, non-NULL pointers, and so on. The following
|
||||
constraints are available :
|
||||
|
||||
Number POSITIVE - Positive number (not zero)
|
||||
Number NEGATIVE - Negative number (not zero)
|
||||
Number NONZERO - Nonzero number
|
||||
Number NONNEGATIVE - Positive number (including zero)
|
||||
Number NONPOSITIVE - Negative number (including zero)
|
||||
Pointer NONNULL - Non-NULL pointer
|
||||
Pointer ALIGN8 - 8-byte aligned pointer
|
||||
Pointer ALIGN4 - 4-byte aligned pointer
|
||||
Pointer ALIGN2 - 2-byte aligned pointer
|
||||
|
||||
To use the constraints, you need to "apply" them to specific
|
||||
function arguments in your code. This is done using the %apply
|
||||
directive. For example :
|
||||
|
||||
%apply Number NONNEGATIVE { double nonneg };
|
||||
double sqrt(double nonneg); // Name of argument must match
|
||||
|
||||
%apply Pointer NONNULL { void *ptr };
|
||||
void *malloc(int POSITIVE); // May return a NULL pointer
|
||||
void free(void *ptr); // May not accept a NULL pointer
|
||||
|
||||
Any function argument of the type you specify with the %apply directive
|
||||
will be checked with the appropriate constraint. Multiple types may
|
||||
be specified as follows :
|
||||
|
||||
%apply Pointer NONNULL { void *, Vector *, List *, double *};
|
||||
|
||||
In this case, all of the types listed would be checked for non-NULL
|
||||
pointers.
|
||||
|
||||
The common datatypes of int, short, long, unsigned int, unsigned long,
|
||||
unsigned short, unsigned char, signed char, float, and double can be
|
||||
checked without using the %apply directive by simply using the
|
||||
constraint name as the parameter name. For example :
|
||||
|
||||
double sqrt(double NONNEGATIVE);
|
||||
double log(double POSITIVE);
|
||||
|
||||
If you have used typedef to change type-names, you can also do this :
|
||||
|
||||
%apply double { Real }; // Make everything defined for doubles
|
||||
// work for Reals.
|
||||
Real sqrt(Real NONNEGATIVE);
|
||||
Real log(Real POSITIVE);
|
||||
|
||||
%}
|
||||
#endif
|
||||
|
||||
%include exception.i
|
||||
|
||||
// Positive numbers
|
||||
|
||||
%typemap(check) int POSITIVE,
|
||||
short POSITIVE,
|
||||
long POSITIVE,
|
||||
unsigned int POSITIVE,
|
||||
unsigned short POSITIVE,
|
||||
unsigned long POSITIVE,
|
||||
signed char POSITIVE,
|
||||
unsigned char POSITIVE,
|
||||
float POSITIVE,
|
||||
double POSITIVE,
|
||||
Number POSITIVE
|
||||
{
|
||||
if ($target <= 0) {
|
||||
SWIG_exception(SWIG_ValueError,"Expected a positive value.");
|
||||
}
|
||||
}
|
||||
|
||||
// Negative numbers
|
||||
|
||||
%typemap(check) int NEGATIVE,
|
||||
short NEGATIVE,
|
||||
long NEGATIVE,
|
||||
unsigned int NEGATIVE,
|
||||
unsigned short NEGATIVE,
|
||||
unsigned long NEGATIVE,
|
||||
signed char NEGATIVE,
|
||||
unsigned char NEGATIVE,
|
||||
float NEGATIVE,
|
||||
double NEGATIVE,
|
||||
Number NEGATIVE
|
||||
{
|
||||
if ($target >= 0) {
|
||||
SWIG_exception(SWIG_ValueError,"Expected a negative value.");
|
||||
}
|
||||
}
|
||||
|
||||
// Nonzero numbers
|
||||
|
||||
%typemap(check) int NONZERO,
|
||||
short NONZERO,
|
||||
long NONZERO,
|
||||
unsigned int NONZERO,
|
||||
unsigned short NONZERO,
|
||||
unsigned long NONZERO,
|
||||
signed char NONZERO,
|
||||
unsigned char NONZERO,
|
||||
float NONZERO,
|
||||
double NONZERO,
|
||||
Number NONZERO
|
||||
{
|
||||
if ($target == 0) {
|
||||
SWIG_exception(SWIG_ValueError,"Expected a nonzero value.");
|
||||
}
|
||||
}
|
||||
|
||||
// Nonnegative numbers
|
||||
|
||||
%typemap(check) int NONNEGATIVE,
|
||||
short NONNEGATIVE,
|
||||
long NONNEGATIVE,
|
||||
unsigned int NONNEGATIVE,
|
||||
unsigned short NONNEGATIVE,
|
||||
unsigned long NONNEGATIVE,
|
||||
signed char NONNEGATIVE,
|
||||
unsigned char NONNEGATIVE,
|
||||
float NONNEGATIVE,
|
||||
double NONNEGATIVE,
|
||||
Number NONNEGATIVE
|
||||
{
|
||||
if ($target < 0) {
|
||||
SWIG_exception(SWIG_ValueError,"Expected a non-negative value.");
|
||||
}
|
||||
}
|
||||
|
||||
// Nonpositive numbers
|
||||
|
||||
%typemap(check) int NONPOSITIVE,
|
||||
short NONPOSITIVE,
|
||||
long NONPOSITIVE,
|
||||
unsigned int NONPOSITIVE,
|
||||
unsigned short NONPOSITIVE,
|
||||
unsigned long NONPOSITIVE,
|
||||
signed char NONPOSITIVE,
|
||||
unsigned char NONPOSITIVE,
|
||||
float NONPOSITIVE,
|
||||
double NONPOSITIVE,
|
||||
Number NONPOSITIVE
|
||||
{
|
||||
if ($target < 0) {
|
||||
SWIG_exception(SWIG_ValueError,"Expected a non-positive value.");
|
||||
}
|
||||
}
|
||||
|
||||
// Non-NULL pointer
|
||||
|
||||
%typemap(check) void * NONNULL,
|
||||
Pointer NONNULL
|
||||
{
|
||||
if (!$target) {
|
||||
SWIG_exception(SWIG_ValueError,"Received a NULL pointer.");
|
||||
}
|
||||
}
|
||||
|
||||
// Aligned pointers
|
||||
|
||||
%typemap(check) void * ALIGN8,
|
||||
Pointer ALIGN8
|
||||
{
|
||||
long tmp;
|
||||
tmp = (long) $target;
|
||||
if (tmp & 7) {
|
||||
SWIG_exception(SWIG_ValueError,"Pointer must be 8-byte aligned.");
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(check) void * ALIGN4,
|
||||
Pointer ALIGN4
|
||||
{
|
||||
long tmp;
|
||||
tmp = (long) $target;
|
||||
if (tmp & 3) {
|
||||
SWIG_exception(SWIG_ValueError,"Pointer must be 4-byte aligned.");
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(check) void * ALIGN2,
|
||||
Pointer ALIGN2
|
||||
{
|
||||
long tmp;
|
||||
tmp = (long) $target;
|
||||
if (tmp & 1) {
|
||||
SWIG_exception(SWIG_ValueError,"Pointer must be 2-byte aligned.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
64
SWIG/Lib/ctype.i
Normal file
64
SWIG/Lib/ctype.i
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
//
|
||||
// ctype.i
|
||||
// Dave Beazley
|
||||
// November 30, 1996
|
||||
// SWIG file for character tests
|
||||
//
|
||||
|
||||
%module ctype
|
||||
%{
|
||||
#include <ctype.h>
|
||||
%}
|
||||
|
||||
%section "Character Class Testing Module",after,info,nosort,pre,chop_left=3,chop_bottom=0,chop_top=0,chop_right=0,skip=1
|
||||
|
||||
%text %{
|
||||
%include ctype.i
|
||||
|
||||
This module provides access to a number of functions for testing
|
||||
characters. These functions are in the C <ctype.h> library.
|
||||
Most scripting languages already provide much of this functionality,
|
||||
but just in case you want to use one of the built-in C functions,
|
||||
you can use this module.
|
||||
%}
|
||||
|
||||
int isalnum(char c);
|
||||
/* Returns 1 if isalpha(c) or isdigit(c) is true. */
|
||||
|
||||
int isalpha(char c);
|
||||
/* Returns 1 if isupper(c) or islower(c) is true. */
|
||||
|
||||
int iscntrl(char c);
|
||||
/* Returns 1 if c is a control character. */
|
||||
|
||||
int isdigit(char c);
|
||||
/* Returns 1 if c is a decimal digit. */
|
||||
|
||||
int isgraph(char c);
|
||||
/* Returns 1 if c is a printing character except space. */
|
||||
|
||||
int islower(char c);
|
||||
/* Returns 1 if c is a lower-case letter. */
|
||||
|
||||
int isprint(char c);
|
||||
/* Returns 1 if c is a printing character including space. */
|
||||
|
||||
int ispunct(char c);
|
||||
/* Returns 1 if c is a printing character except space or letter
|
||||
or digit. */
|
||||
|
||||
int isspace(char c);
|
||||
/* Returns 1 if c is a space, formfeed, newline, carriage return,
|
||||
tab, or vertical tab. */
|
||||
|
||||
int isupper(char c);
|
||||
/* Returns 1 if c is an upper case letter. */
|
||||
|
||||
int isxdigit(char c);
|
||||
/* Returns 1 if c is a hexadecimal digit. */
|
||||
|
||||
char tolower(char c);
|
||||
/* Converts c to lower case */
|
||||
|
||||
char toupper(char c);
|
||||
/* Converts c to upper case */
|
||||
146
SWIG/Lib/exception.i
Normal file
146
SWIG/Lib/exception.i
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
//
|
||||
// except.i
|
||||
// Dave Beazley
|
||||
// April 14, 1997
|
||||
//
|
||||
// This SWIG library file provides language independent exception handling
|
||||
|
||||
#ifdef AUTODOC
|
||||
%section "Exception Handling Library",info,after,pre,nosort,skip=1,chop_left=3,chop_right=0,chop_top=0,chop_bottom=0
|
||||
|
||||
%text %{
|
||||
%include exception.i
|
||||
|
||||
This library provides language independent support for raising scripting
|
||||
language exceptions in SWIG generated wrapper code. Normally, this is
|
||||
used in conjunction with the %except directive.
|
||||
|
||||
To raise an exception, use the following function call :
|
||||
|
||||
SWIG_exception(int exctype, char *msg);
|
||||
|
||||
'exctype' is an exception type code and may be one of the following :
|
||||
|
||||
SWIG_MemoryError
|
||||
SWIG_IOError
|
||||
SWIG_RuntimeError
|
||||
SWIG_IndexError
|
||||
SWIG_TypeError
|
||||
SWIG_DivisionByZero
|
||||
SWIG_OverflowError
|
||||
SWIG_SyntaxError
|
||||
SWIG_ValueError
|
||||
SWIG_SystemError
|
||||
SWIG_UnknownError
|
||||
|
||||
'msg' is an error string that should be reported to the user.
|
||||
|
||||
The library is normally used in conjunction with the %except directive
|
||||
as follows :
|
||||
|
||||
%except {
|
||||
try {
|
||||
$function
|
||||
} catch RangeError {
|
||||
SWIG_exception(SWIG_IndexError,"Array index out of bounds");
|
||||
} catch(...) {
|
||||
SWIG_exception(SWIG_UnknownError,"Uncaught exception");
|
||||
}
|
||||
}
|
||||
|
||||
It is important to note that the SWIG_exception() function is only available
|
||||
to the C code generated by SWIG. It is not available in the scripting language
|
||||
interface itself.
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
||||
%{
|
||||
#define SWIG_MemoryError 1
|
||||
#define SWIG_IOError 2
|
||||
#define SWIG_RuntimeError 3
|
||||
#define SWIG_IndexError 4
|
||||
#define SWIG_TypeError 5
|
||||
#define SWIG_DivisionByZero 6
|
||||
#define SWIG_OverflowError 7
|
||||
#define SWIG_SyntaxError 8
|
||||
#define SWIG_ValueError 9
|
||||
#define SWIG_SystemError 10
|
||||
#define SWIG_UnknownError 99
|
||||
%}
|
||||
|
||||
#ifdef SWIGTCL8
|
||||
%{
|
||||
#define SWIG_exception(a,b) Tcl_SetResult(interp,b,TCL_VOLATILE); return TCL_ERROR
|
||||
%}
|
||||
#else
|
||||
#ifdef SWIGTCL
|
||||
%{
|
||||
#define SWIG_exception(a,b) Tcl_SetResult(interp,b,TCL_VOLATILE); return TCL_ERROR
|
||||
%}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SWIGPERL5
|
||||
%{
|
||||
#define SWIG_exception(a,b) croak(b)
|
||||
%}
|
||||
#endif
|
||||
|
||||
#ifdef SWIGPERL4
|
||||
%{
|
||||
#define SWIG_exception(a,b) fatal(b)
|
||||
%}
|
||||
#endif
|
||||
|
||||
#ifdef SWIGPYTHON
|
||||
%{
|
||||
static void _SWIG_exception(int code, char *msg) {
|
||||
switch(code) {
|
||||
case SWIG_MemoryError:
|
||||
PyErr_SetString(PyExc_MemoryError,msg);
|
||||
break;
|
||||
case SWIG_IOError:
|
||||
PyErr_SetString(PyExc_IOError,msg);
|
||||
break;
|
||||
case SWIG_RuntimeError:
|
||||
PyErr_SetString(PyExc_RuntimeError,msg);
|
||||
break;
|
||||
case SWIG_IndexError:
|
||||
PyErr_SetString(PyExc_IndexError,msg);
|
||||
break;
|
||||
case SWIG_TypeError:
|
||||
PyErr_SetString(PyExc_TypeError,msg);
|
||||
break;
|
||||
case SWIG_DivisionByZero:
|
||||
PyErr_SetString(PyExc_ZeroDivisionError,msg);
|
||||
break;
|
||||
case SWIG_OverflowError:
|
||||
PyErr_SetString(PyExc_OverflowError,msg);
|
||||
break;
|
||||
case SWIG_SyntaxError:
|
||||
PyErr_SetString(PyExc_SyntaxError,msg);
|
||||
break;
|
||||
case SWIG_ValueError:
|
||||
PyErr_SetString(PyExc_ValueError,msg);
|
||||
break;
|
||||
case SWIG_SystemError:
|
||||
PyErr_SetString(PyExc_SystemError,msg);
|
||||
break;
|
||||
default:
|
||||
PyErr_SetString(PyExc_RuntimeError,msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define SWIG_exception(a,b) _SWIG_exception(a,b); return NULL
|
||||
%}
|
||||
#endif
|
||||
|
||||
#ifdef SWIGGUILE
|
||||
%echo %{
|
||||
exception.i : Guile not currently supported.
|
||||
%}
|
||||
#endif
|
||||
|
||||
|
||||
4
SWIG/Lib/guile/Makefile
Normal file
4
SWIG/Lib/guile/Makefile
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
co::
|
||||
co RCS/*.i* RCS/*.swg*
|
||||
|
||||
15
SWIG/Lib/guile/guile.swg
Normal file
15
SWIG/Lib/guile/guile.swg
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/* -----------------------------------------------------------------------
|
||||
* swig_lib/guile/guile.swg
|
||||
*
|
||||
* Guile configuration file. This file assumes FSF Guile 1.0. It may not
|
||||
* work with other versions
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
#include "guile/gh.h"
|
||||
|
||||
/* Since GUILE seems to be somewhat incomplete, these bindings
|
||||
are used in the SWIG generated code. To change the Guile
|
||||
interface, simply change this file */
|
||||
|
||||
#define GH_NOT_PASSED SCM_UNDEFINED
|
||||
|
||||
21
SWIG/Lib/guile/guilemain.i
Normal file
21
SWIG/Lib/guile/guilemain.i
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
%{
|
||||
void guile_main(void *closure, int argc, char **argv) {
|
||||
char buffer[1024];
|
||||
void SWIG_init();
|
||||
SWIG_init();
|
||||
printf("starting Guile...\n");
|
||||
printf("guile >");
|
||||
while (fgets(buffer,1024,stdin)) {
|
||||
gh_eval_str(buffer);
|
||||
printf("guile >");
|
||||
}
|
||||
}
|
||||
|
||||
void main(int argc, char **argv) {
|
||||
gh_enter(argc,argv, guile_main);
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
|
||||
|
||||
71
SWIG/Lib/guile/interpreter.i
Normal file
71
SWIG/Lib/guile/interpreter.i
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
//
|
||||
// $Header$
|
||||
//
|
||||
// SWIG file for a simple Guile interpreter
|
||||
//
|
||||
/* Revision History
|
||||
* $Log$
|
||||
* Revision 1.1 2000/01/11 21:15:50 beazley
|
||||
* Added files
|
||||
*
|
||||
* Revision 1.1.1.1 1999/02/28 02:00:54 beazley
|
||||
* Swig1.1
|
||||
*
|
||||
* Revision 1.1 1996/05/22 20:02:10 beazley
|
||||
* Initial revision
|
||||
*
|
||||
*/
|
||||
|
||||
%{
|
||||
|
||||
#include <stdio.h>
|
||||
GSCM_status guile_init();
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
GSCM_status status;
|
||||
GSCM_top_level toplev;
|
||||
char *eval_answer;
|
||||
char input_str[16384];
|
||||
int done;
|
||||
|
||||
/* start a scheme interpreter */
|
||||
status = gscm_run_scm(argc, argv, 0, stdout, stderr, guile_init, 0, "#t");
|
||||
if (status != GSCM_OK) {
|
||||
fputs(gscm_error_msg(status), stderr);
|
||||
fputc('\n', stderr);
|
||||
printf("Error in startup.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* create the top level environment */
|
||||
status = gscm_create_top_level(&toplev);
|
||||
if (status != GSCM_OK) {
|
||||
fputs(gscm_error_msg(status), stderr);
|
||||
fputc('\n', stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* now sit in a scheme eval loop: I input the expressions, have guile
|
||||
* evaluate them, and then get another expression.
|
||||
*/
|
||||
done = 0;
|
||||
fprintf(stdout,"Guile > ");
|
||||
while (!done) {
|
||||
if (fgets(input_str,16384,stdin) == NULL) {
|
||||
exit(1);
|
||||
} else {
|
||||
if (strncmp(input_str,"quit",4) == 0) exit(1);
|
||||
status = gscm_eval_str(&eval_answer, toplev, input_str);
|
||||
fprintf(stdout,"%s\n", eval_answer);
|
||||
fprintf(stdout,"Guile > ");
|
||||
}
|
||||
}
|
||||
|
||||
/* now clean up and quit */
|
||||
gscm_destroy_top_level(toplev);
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
|
||||
|
||||
57
SWIG/Lib/malloc.i
Normal file
57
SWIG/Lib/malloc.i
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
//
|
||||
// $Header$
|
||||
//
|
||||
// malloc.i
|
||||
// Dave Beazley
|
||||
// March 24, 1996
|
||||
// SWIG file for memory management functions
|
||||
// (also contained in stdlib.i)
|
||||
//
|
||||
/* Revision History
|
||||
* $Log$
|
||||
* Revision 1.1 2000/01/11 21:15:48 beazley
|
||||
* Added files
|
||||
*
|
||||
* Revision 1.1.1.1 1999/02/28 02:00:53 beazley
|
||||
* Swig1.1
|
||||
*
|
||||
* Revision 1.1 1996/05/22 17:27:01 beazley
|
||||
* Initial revision
|
||||
*
|
||||
*/
|
||||
|
||||
%module malloc
|
||||
%{
|
||||
#include <stdlib.h>
|
||||
%}
|
||||
|
||||
%section "Memory Allocation Module",
|
||||
pre,info,after,nosort,chop_left=3,chop_right=0,chop_top=0,chop_bottom=0,skip=1
|
||||
|
||||
%text %{
|
||||
%include malloc.i
|
||||
|
||||
This module provides access to a few basic C memory management functions.
|
||||
All functions return void pointers, but realloc() and free() will operate
|
||||
on any sort of pointer. Sizes should be specified in bytes.
|
||||
%}
|
||||
|
||||
void *calloc(unsigned nobj, unsigned size);
|
||||
/* Returns a pointer to a space for an array of nobj objects, each with
|
||||
size bytes. Returns NULL if the request can't be satisfied.
|
||||
Initializes the space to zero bytes. */
|
||||
|
||||
void *malloc(unsigned size);
|
||||
/* Returns a pointer to space for an object of size bytes. Returns NULL
|
||||
upon failure. */
|
||||
|
||||
void *realloc(void *ptr, unsigned size);
|
||||
/* Changes the size of the object pointed to by ptr to size bytes.
|
||||
The contents will be unchanged up the minimum of the old and new
|
||||
sizes. Returns a pointer to the new space of NULL upon failure,
|
||||
in which case *ptr is unchanged. */
|
||||
|
||||
void free(void *ptr);
|
||||
/* Deallocates the space pointed to by ptr. Does nothing if ptr is NULL.
|
||||
ptr must be a space previously allocated by calloc, malloc, or realloc. */
|
||||
|
||||
113
SWIG/Lib/math.i
Normal file
113
SWIG/Lib/math.i
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
//
|
||||
// $Header$
|
||||
//
|
||||
// math.i
|
||||
// Dave Beazley
|
||||
// March 24, 1996
|
||||
// SWIG file for floating point operations
|
||||
//
|
||||
/* Revision history
|
||||
* $Log$
|
||||
* Revision 1.1 2000/01/11 21:15:48 beazley
|
||||
* Added files
|
||||
*
|
||||
* Revision 1.1.1.1 1999/02/28 02:00:53 beazley
|
||||
* Swig1.1
|
||||
*
|
||||
* Revision 1.1 1996/05/22 17:27:01 beazley
|
||||
* Initial revision
|
||||
*
|
||||
*/
|
||||
|
||||
%module math
|
||||
%{
|
||||
#include <math.h>
|
||||
%}
|
||||
|
||||
%section "SWIG Math Module",after,info,nosort,pre,chop_left=3,chop_bottom=0,chop_top=0,chop_right=0,skip=1
|
||||
|
||||
%text %{
|
||||
%include math.i
|
||||
|
||||
This module provides access to the C math library and contains most
|
||||
of the functions in <math.h>. Most scripting languages already provide
|
||||
math support, but in certain cases, this module can provide more
|
||||
direct access.
|
||||
%}
|
||||
|
||||
%subsection "Functions"
|
||||
|
||||
|
||||
extern double cos(double x);
|
||||
/* Cosine of x */
|
||||
|
||||
extern double sin(double x);
|
||||
/* Sine of x */
|
||||
|
||||
extern double tan(double x);
|
||||
/* Tangent of x */
|
||||
|
||||
extern double acos(double x);
|
||||
/* Inverse cosine in range [-PI/2,PI/2], x in [-1,1]. */
|
||||
|
||||
extern double asin(double x);
|
||||
/* Inverse sine in range [0,PI], x in [-1,1]. */
|
||||
|
||||
extern double atan(double x);
|
||||
/* Inverse tangent in range [-PI/2,PI/2]. */
|
||||
|
||||
extern double atan2(double y, double x);
|
||||
/* Inverse tangent of y/x in range [-PI,PI]. */
|
||||
|
||||
extern double cosh(double x);
|
||||
/* Hyperbolic cosine of x */
|
||||
|
||||
extern double sinh(double x);
|
||||
/* Hyperbolic sine of x */
|
||||
|
||||
extern double tanh(double x);
|
||||
/* Hyperbolic tangent of x */
|
||||
|
||||
extern double exp(double x);
|
||||
/* Natural exponential function e^x */
|
||||
|
||||
extern double log(double x);
|
||||
/* Natural logarithm ln(x), x > 0 */
|
||||
|
||||
extern double log10(double x);
|
||||
/* Base 10 logarithm, x > 0 */
|
||||
|
||||
extern double pow(double x, double y);
|
||||
/* Power function x^y. */
|
||||
|
||||
extern double sqrt(double x);
|
||||
/* Square root. x >= 0 */
|
||||
|
||||
extern double fabs(double x);
|
||||
/* Absolute value of x */
|
||||
|
||||
extern double ceil(double x);
|
||||
/* Smallest integer not less than x, as a double */
|
||||
|
||||
extern double floor(double x);
|
||||
/* Largest integer not greater than x, as a double */
|
||||
|
||||
extern double fmod(double x, double y);
|
||||
/* Floating-point remainder of x/y, with the same sign as x. */
|
||||
|
||||
%subsection "Mathematical constants",noinfo
|
||||
|
||||
#define M_E 2.7182818284590452354
|
||||
#define M_LOG2E 1.4426950408889634074
|
||||
#define M_LOG10E 0.43429448190325182765
|
||||
#define M_LN2 0.69314718055994530942
|
||||
#define M_LN10 2.30258509299404568402
|
||||
#define M_PI 3.14159265358979323846
|
||||
#define M_PI_2 1.57079632679489661923
|
||||
#define M_PI_4 0.78539816339744830962
|
||||
#define M_1_PI 0.31830988618379067154
|
||||
#define M_2_PI 0.63661977236758134308
|
||||
#define M_2_SQRTPI 1.12837916709551257390
|
||||
#define M_SQRT2 1.41421356237309504880
|
||||
#define M_SQRT1_2 0.70710678118654752440
|
||||
|
||||
39
SWIG/Lib/memory.i
Normal file
39
SWIG/Lib/memory.i
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
//
|
||||
// memory.i
|
||||
// Dave Beazley
|
||||
// November 30, 1996
|
||||
// SWIG file for memory operations
|
||||
//
|
||||
|
||||
%module memory
|
||||
%{
|
||||
#include <string.h>
|
||||
%}
|
||||
|
||||
%section "Memory Manipulation Module",after,info,nosort,pre,chop_left=3,chop_bottom=0,chop_top=0,chop_right=0,skip=1
|
||||
|
||||
%text %{
|
||||
%include memory.i
|
||||
|
||||
This module provides support for a few memory operations from the C
|
||||
<string.h> library. These functions can be used to manipulate binary
|
||||
data. s and t are of type void *, cs and ct are both of type const void *.
|
||||
%}
|
||||
|
||||
void *memcpy(void *s, const void *ct, int n);
|
||||
/* Copy n characters from ct to s, and return s */
|
||||
|
||||
void *memmove(void *s, const void *ct, int n);
|
||||
/* Same as memcpy except that it works even if the objects overlap. */
|
||||
|
||||
int memcmp(const void *cs, const void *ct, int n);
|
||||
/* Compare the first n characters of cs with ct. Returns 0 if
|
||||
they are equal, <0 if cs < ct, and >0 if cs > ct. */
|
||||
|
||||
void *memchr(const void *cs, char c, int n);
|
||||
/* Returns pointer to the first occurrence of character c in cs. */
|
||||
|
||||
void *memset(void *s, char c, int n);
|
||||
/* Place character c into first n characters of s, return s */
|
||||
|
||||
|
||||
56
SWIG/Lib/objc.i
Normal file
56
SWIG/Lib/objc.i
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
// SWIG Objective-C configuration file
|
||||
// Dave Beazley
|
||||
// Copyright (C) 1997
|
||||
|
||||
// This file provides support to Objective-C parsing and
|
||||
// should be included with just about any Objective-C module
|
||||
|
||||
// Base Object class
|
||||
|
||||
@interface Object { }
|
||||
|
||||
-(char *) name; // Get object name
|
||||
|
||||
@end
|
||||
|
||||
typedef Object *id; // Make 'id' behave like any other "Object"
|
||||
|
||||
// Typemaps to make *id work like kind of like a void pointer
|
||||
|
||||
%typemap(python,in) id {
|
||||
char *temp;
|
||||
if (!PyString_Check($source)) {
|
||||
PyErr_SetString(PyExc_TypeError,"Expecting an 'id' in argument $argnum of $name");
|
||||
return NULL;
|
||||
}
|
||||
temp = PyString_AsString($source);
|
||||
if (SWIG_GetPtr(temp, (void **) &$target, 0)) {
|
||||
PyErr_SetString(PyExc_TypeError,"Expecting an 'id' in argument $argnum of $name");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(tcl,in) id {
|
||||
if (SWIG_GetPtr($source,(void **) &$target, 0)) {
|
||||
Tcl_SetResult(interp,"Expecting an 'id' in argument $argnum of $name",TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(tcl8,in) id {
|
||||
if (SWIG_GetPointerObj(interp, $source, (void **) &$target, 0)) {
|
||||
Tcl_SetStringObj(result_obj, "Expecting an 'id' in argument $argnum of $name");
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(perl5,in) id {
|
||||
if (SWIG_GetPtr($source, (void **) &$target, 0)) {
|
||||
croak("Expecting an 'id' in argument $argnum of $name");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
139
SWIG/Lib/perl5/Makefile.in
Normal file
139
SWIG/Lib/perl5/Makefile.in
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
# ---------------------------------------------------------------
|
||||
# $Header$
|
||||
# SWIG Perl5 Makefile
|
||||
#
|
||||
# This file can be used to build various Perl5 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.
|
||||
#----------------------------------------------------------------
|
||||
|
||||
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 = myperl # 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 = -perl5
|
||||
SWIGCC = $(CC)
|
||||
|
||||
# SWIG Library files. Uncomment this to staticly rebuild Perl
|
||||
#SWIGLIB = -static -lperlmain.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 (possibly needed if using Perl-Tk)
|
||||
|
||||
XLIB = @XLIBSW@
|
||||
XINCLUDE = @XINCLUDES@
|
||||
|
||||
# Perl installation
|
||||
|
||||
PERL_INCLUDE = -I@PERL5EXT@
|
||||
PERL_LIB = -L@PERL5EXT@ -lperl
|
||||
PERL_FLAGS = -Dbool=char -Dexplicit=
|
||||
|
||||
# Tcl installation. If using Tk you might need this
|
||||
|
||||
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)
|
||||
|
||||
#TK_LIB = $(TCL_LIB) -ltcl -ltk $(XLIB)
|
||||
BUILD_LIBS = $(LIBS) # Dynamic loading
|
||||
#BUILD_LIBS = $(PERL_LIB) $(TK_LIB) $(LIBS) $(SYSLIBS) # Static linking
|
||||
|
||||
# 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) $(INCLUDE) $(PERL_INCLUDE) $(PERL_FLAGS) $(WRAPFILE)
|
||||
|
||||
$(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)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
21
SWIG/Lib/perl5/Makefile.pl
Normal file
21
SWIG/Lib/perl5/Makefile.pl
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# File : Makefile.pl
|
||||
# MakeMaker file for a SWIG module. Use this file if you are
|
||||
# producing a module for general use or distribution.
|
||||
#
|
||||
# 1. Modify the file as appropriate. Replace $module with the
|
||||
# real name of your module and wrapper file.
|
||||
# 2. Run perl as 'perl Makefile.pl'
|
||||
# 3. Type 'make' to build your module
|
||||
# 4. Type 'make install' to install your module.
|
||||
#
|
||||
# See "Programming Perl", 2nd. Ed, for more gory details than
|
||||
# you ever wanted to know.
|
||||
|
||||
use ExtUtils::MakeMaker;
|
||||
WriteMakefile(
|
||||
'NAME' => '$module', # Name of your module
|
||||
'LIBS' => [''], # Custom libraries (if any)
|
||||
'OBJECT' => '$module_wrap.o' # Object files
|
||||
);
|
||||
|
||||
|
||||
24
SWIG/Lib/perl5/headers.swg
Normal file
24
SWIG/Lib/perl5/headers.swg
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/* $Header$ */
|
||||
/* Implementation : PERL 5 */
|
||||
|
||||
#define SWIGPERL
|
||||
#define SWIGPERL5
|
||||
#ifdef __cplusplus
|
||||
/* Needed on some windows machines---since MS plays funny
|
||||
games with the header files under C++ */
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "EXTERN.h"
|
||||
#include "perl.h"
|
||||
#include "XSUB.h"
|
||||
|
||||
/* Get rid of free and malloc defined by perl */
|
||||
#undef free
|
||||
#undef malloc
|
||||
|
||||
#include <string.h>
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
366
SWIG/Lib/perl5/perl5.swg
Normal file
366
SWIG/Lib/perl5/perl5.swg
Normal file
|
|
@ -0,0 +1,366 @@
|
|||
/* Definitions for compiling Perl extensions on a variety of machines */
|
||||
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
|
||||
# if defined(_MSC_VER)
|
||||
# if defined(STATIC_LINKED)
|
||||
# define SWIGEXPORT(a) a
|
||||
# else
|
||||
# define SWIGEXPORT(a) __declspec(dllexport) a
|
||||
# endif
|
||||
# else
|
||||
# if defined(__BORLANDC__)
|
||||
# define SWIGEXPORT(a) a _export
|
||||
# else
|
||||
# define SWIGEXPORT(a) a
|
||||
# endif
|
||||
#endif
|
||||
#else
|
||||
# define SWIGEXPORT(a) a
|
||||
#endif
|
||||
|
||||
#ifdef PERL_OBJECT
|
||||
#define MAGIC_PPERL CPerlObj *pPerl = (CPerlObj *) this;
|
||||
#define MAGIC_CAST (int (CPerlObj::*)(SV *, MAGIC *))
|
||||
#define SWIGCLASS_STATIC
|
||||
#else
|
||||
#define MAGIC_PPERL
|
||||
#define MAGIC_CAST
|
||||
#define SWIGCLASS_STATIC static
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) && defined(PERL_OBJECT) && !defined(PerlIO_exportFILE)
|
||||
#define PerlIO_exportFILE(fh,fl) (FILE*)(fh)
|
||||
#endif
|
||||
|
||||
/* Modifications for newer Perl 5.005 releases */
|
||||
|
||||
#if !defined(PERL_REVISION) || ((PERL_REVISION >= 5) && ((PERL_VERSION < 5) || ((PERL_VERSION == 5) && (PERL_SUBVERSION < 50))))
|
||||
#ifndef PL_sv_yes
|
||||
#define PL_sv_yes sv_yes
|
||||
#endif
|
||||
#ifndef PL_sv_undef
|
||||
#define PL_sv_undef sv_undef
|
||||
#endif
|
||||
#ifndef PL_na
|
||||
#define PL_na na
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Pointer type-checking code
|
||||
*****************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef SWIG_NOINCLUDE
|
||||
extern void SWIG_MakePtr(char *, void *, char *);
|
||||
#ifndef PERL_OBJECT
|
||||
extern void SWIG_RegisterMapping(char *, char *, void *(*)(void *));
|
||||
#else
|
||||
#define SWIG_RegisterMapping(a,b,c) _SWIG_RegisterMapping(pPerl,a,b,c);
|
||||
extern void _SWIG_RegisterMapping(CPerlObj *,char *, char *, void *(*)(void *),int);
|
||||
#endif
|
||||
#ifndef PERL_OBJECT
|
||||
extern char *SWIG_GetPtr(SV *, void **, char *);
|
||||
#else
|
||||
extern char *_SWIG_GetPtr(CPerlObj *, SV *, void **, char *);
|
||||
#define SWIG_GetPtr(a,b,c) _SWIG_GetPtr(pPerl,a,b,c)
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifdef SWIG_GLOBAL
|
||||
#define SWIGSTATICRUNTIME(a) SWIGEXPORT(a)
|
||||
#else
|
||||
#define SWIGSTATICRUNTIME(a) static a
|
||||
#endif
|
||||
|
||||
/* 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 SwigPtrType *SwigPtrTable = 0; /* Table containing pointer equivalences */
|
||||
static int SwigStart[256]; /* Table containing starting positions */
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
/* Register a new datatype with the type-checker */
|
||||
|
||||
#ifndef PERL_OBJECT
|
||||
SWIGSTATICRUNTIME(void)
|
||||
SWIG_RegisterMapping(char *origtype, char *newtype, void *(*cast)(void *)) {
|
||||
#else
|
||||
#define SWIG_RegisterMapping(a,b,c) _SWIG_RegisterMapping(pPerl, a,b,c)
|
||||
SWIGSTATICRUNTIME(void)
|
||||
_SWIG_RegisterMapping(CPerlObj *pPerl, char *origtype, char *newtype, void *(*cast)(void *)) {
|
||||
#endif
|
||||
|
||||
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(t->name);
|
||||
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(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[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 */
|
||||
_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--);
|
||||
} else {
|
||||
strcpy (_c, "NULL");
|
||||
}
|
||||
if (_ptr)
|
||||
strcpy (_c, type);
|
||||
}
|
||||
|
||||
/* Function for getting a pointer value */
|
||||
|
||||
#ifndef PERL_OBJECT
|
||||
SWIGSTATICRUNTIME(char *)
|
||||
SWIG_GetPtr(SV *sv, void **ptr, char *_t)
|
||||
#else
|
||||
#define SWIG_GetPtr(a,b,c) _SWIG_GetPtr(pPerl,a,b,c)
|
||||
SWIGSTATICRUNTIME(char *)
|
||||
_SWIG_GetPtr(CPerlObj *pPerl, SV *sv, void **ptr, char *_t)
|
||||
#endif
|
||||
{
|
||||
char temp_type[256];
|
||||
char *name,*_c;
|
||||
int len,i,start,end;
|
||||
IV tmp;
|
||||
SwigPtrType *sp,*tp;
|
||||
SwigCacheType *cache;
|
||||
|
||||
/* If magical, apply more magic */
|
||||
|
||||
if (SvGMAGICAL(sv))
|
||||
mg_get(sv);
|
||||
|
||||
/* Check to see if this is an object */
|
||||
if (sv_isobject(sv)) {
|
||||
SV *tsv = (SV*) SvRV(sv);
|
||||
if ((SvTYPE(tsv) == SVt_PVHV)) {
|
||||
MAGIC *mg;
|
||||
if (SvMAGICAL(tsv)) {
|
||||
mg = mg_find(tsv,'P');
|
||||
if (mg) {
|
||||
SV *rsv = mg->mg_obj;
|
||||
if (sv_isobject(rsv)) {
|
||||
tmp = SvIV((SV*)SvRV(rsv));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return "Not a valid pointer value";
|
||||
}
|
||||
} else {
|
||||
tmp = SvIV((SV*)SvRV(sv));
|
||||
}
|
||||
if (!_t) {
|
||||
*(ptr) = (void *) tmp;
|
||||
return (char *) 0;
|
||||
}
|
||||
} else if (! SvOK(sv)) { /* Check for undef */
|
||||
*(ptr) = (void *) 0;
|
||||
return (char *) 0;
|
||||
} else if (SvTYPE(sv) == SVt_RV) { /* Check for NULL pointer */
|
||||
*(ptr) = (void *) 0;
|
||||
if (!SvROK(sv))
|
||||
return (char *) 0;
|
||||
else
|
||||
return "Not a valid pointer value";
|
||||
} else { /* Don't know what it is */
|
||||
*(ptr) = (void *) 0;
|
||||
return "Not a valid pointer value";
|
||||
}
|
||||
if (_t) {
|
||||
/* Now see if the types match */
|
||||
|
||||
if (!sv_isa(sv,_t)) {
|
||||
_c = HvNAME(SvSTASH(SvRV(sv)));
|
||||
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[SwigPtrTable[i].name[0]] = 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 *) tmp;
|
||||
if (cache->tp->cast) *ptr = (*(cache->tp->cast))(*ptr);
|
||||
return (char *) 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
SwigLastCache = (SwigLastCache+1) & SWIG_CACHEMASK;
|
||||
if (!SwigLastCache) cache = SwigCache;
|
||||
else cache++;
|
||||
}
|
||||
|
||||
start = SwigStart[_t[0]];
|
||||
end = SwigStart[_t[0]+1];
|
||||
sp = &SwigPtrTable[start];
|
||||
while (start < end) {
|
||||
if (swigcmp(_t,sp) == 0) break;
|
||||
sp++;
|
||||
start++;
|
||||
}
|
||||
if (start > end) sp = 0;
|
||||
while (start <= end) {
|
||||
if (swigcmp(_t,sp) == 0) {
|
||||
name = sp->name;
|
||||
len = sp->len;
|
||||
tp = sp->next;
|
||||
while(tp) {
|
||||
if (tp->len >= 255) {
|
||||
return _c;
|
||||
}
|
||||
strcpy(temp_type,tp->name);
|
||||
strncat(temp_type,_t+len,255-tp->len);
|
||||
if (sv_isa(sv,temp_type)) {
|
||||
/* Get pointer value */
|
||||
*ptr = (void *) tmp;
|
||||
if (tp->cast) *ptr = (*(tp->cast))(*ptr);
|
||||
|
||||
strcpy(SwigCache[SwigCacheIndex].mapped,_c);
|
||||
strcpy(SwigCache[SwigCacheIndex].name,_t);
|
||||
SwigCache[SwigCacheIndex].stat = 1;
|
||||
SwigCache[SwigCacheIndex].tp = tp;
|
||||
SwigCacheIndex = SwigCacheIndex & SWIG_CACHEMASK;
|
||||
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 *) tmp;
|
||||
return _c;
|
||||
} else {
|
||||
/* Found a match on the first try. Return pointer value */
|
||||
*ptr = (void *) tmp;
|
||||
return (char *) 0;
|
||||
}
|
||||
}
|
||||
*ptr = (void *) tmp;
|
||||
return (char *) 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
19
SWIG/Lib/perl5/perl5mg.swg
Normal file
19
SWIG/Lib/perl5/perl5mg.swg
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/* Magic variable code */
|
||||
#ifndef PERL_OBJECT
|
||||
#define swig_create_magic(s,a,b,c) _swig_create_magic(s,a,b,c)
|
||||
static void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) {
|
||||
#else
|
||||
#define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c)
|
||||
static void _swig_create_magic(CPerlObj *pPerl, SV *sv, char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) {
|
||||
#endif
|
||||
MAGIC *mg;
|
||||
sv_magic(sv,sv,'U',name,strlen(name));
|
||||
mg = mg_find(sv,'U');
|
||||
mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL));
|
||||
mg->mg_virtual->svt_get = get;
|
||||
mg->mg_virtual->svt_set = set;
|
||||
mg->mg_virtual->svt_len = 0;
|
||||
mg->mg_virtual->svt_clear = 0;
|
||||
mg->mg_virtual->svt_free = 0;
|
||||
}
|
||||
|
||||
80
SWIG/Lib/perl5/perlmain.i
Normal file
80
SWIG/Lib/perl5/perlmain.i
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
// $Header$
|
||||
// Code to statically rebuild perl5.
|
||||
//
|
||||
|
||||
#ifdef AUTODOC
|
||||
%subsection "perlmain.i"
|
||||
%text %{
|
||||
This module provides support for building a new version of the
|
||||
Perl executable. This will be necessary on systems that do
|
||||
not support shared libraries and may be necessary with C++
|
||||
extensions.
|
||||
|
||||
This module may only build a stripped down version of the
|
||||
Perl executable. Thus, it may be necessary (or desirable)
|
||||
to hand-edit this file for your particular application. To
|
||||
do this, simply copy this file from swig_lib/perl5/perlmain.i
|
||||
to your working directory and make the appropriate modifications.
|
||||
|
||||
This library file works with Perl 5.003. It may work with earlier
|
||||
versions, but it hasn't been tested. As far as I know, this
|
||||
library is C++ safe.
|
||||
%}
|
||||
#endif
|
||||
|
||||
%{
|
||||
|
||||
static void xs_init _((void));
|
||||
static PerlInterpreter *my_perl;
|
||||
|
||||
int perl_eval(char *string) {
|
||||
char *argv[2];
|
||||
argv[0] = string;
|
||||
argv[1] = (char *) 0;
|
||||
return perl_call_argv("eval",0,argv);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv, char **env)
|
||||
{
|
||||
int exitstatus;
|
||||
|
||||
my_perl = perl_alloc();
|
||||
if (!my_perl)
|
||||
exit(1);
|
||||
perl_construct( my_perl );
|
||||
|
||||
exitstatus = perl_parse( my_perl, xs_init, argc, argv, (char **) NULL );
|
||||
if (exitstatus)
|
||||
exit( exitstatus );
|
||||
|
||||
/* Initialize all of the module variables */
|
||||
|
||||
exitstatus = perl_run( my_perl );
|
||||
|
||||
perl_destruct( my_perl );
|
||||
perl_free( my_perl );
|
||||
|
||||
exit( exitstatus );
|
||||
}
|
||||
|
||||
/* Register any extra external extensions */
|
||||
|
||||
/* Do not delete this line--writemain depends on it */
|
||||
/* EXTERN_C void boot_DynaLoader _((CV* cv)); */
|
||||
|
||||
static void
|
||||
xs_init()
|
||||
{
|
||||
/* dXSUB_SYS; */
|
||||
char *file = __FILE__;
|
||||
{
|
||||
/* newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); */
|
||||
newXS(SWIG_name, SWIG_init, file);
|
||||
#ifdef SWIGMODINIT
|
||||
SWIGMODINIT
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
%}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue