Perl added to the Unified typemap library, cleaner way to use the library, and 'normalized' macro names
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7707 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
f2324be428
commit
f2f1b9889f
112 changed files with 3262 additions and 3375 deletions
2
SWIG/Lib/perl5/carrays.i
Normal file
2
SWIG/Lib/perl5/carrays.i
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
%include <typemaps/carrays.swg>
|
||||
|
||||
1
SWIG/Lib/perl5/cdata.i
Normal file
1
SWIG/Lib/perl5/cdata.i
Normal file
|
|
@ -0,0 +1 @@
|
|||
%include <typemaps/cdata.swg>
|
||||
1
SWIG/Lib/perl5/cmalloc.i
Normal file
1
SWIG/Lib/perl5/cmalloc.i
Normal file
|
|
@ -0,0 +1 @@
|
|||
%include <typemaps/cmalloc.swg>
|
||||
1
SWIG/Lib/perl5/cpointer.i
Normal file
1
SWIG/Lib/perl5/cpointer.i
Normal file
|
|
@ -0,0 +1 @@
|
|||
%include <typemaps/cpointer.swg>
|
||||
1
SWIG/Lib/perl5/cstring.i
Normal file
1
SWIG/Lib/perl5/cstring.i
Normal file
|
|
@ -0,0 +1 @@
|
|||
%include <typemaps/cstring.swg>
|
||||
1
SWIG/Lib/perl5/exception.i
Normal file
1
SWIG/Lib/perl5/exception.i
Normal file
|
|
@ -0,0 +1 @@
|
|||
%include <typemaps/exception.swg>
|
||||
|
|
@ -1,583 +1,52 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* perl5.swg
|
||||
/* ------------------------------------------------------------
|
||||
* perl.swg
|
||||
*
|
||||
* Perl 5 configuration file
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%runtime "swigrun.swg" // Common C API type-checking code
|
||||
%runtime "perlrun.swg" // Perl runtime functions
|
||||
%runtime "noembed.h" // undefine Perl5 macros
|
||||
|
||||
#define %perlcode %insert("perl")
|
||||
|
||||
/* Typemaps for input parameters */
|
||||
|
||||
%typemap(in) int, short, long, signed char, enum SWIGTYPE
|
||||
"$1 = ($1_ltype) SvIV($input);";
|
||||
|
||||
%typemap(in) bool
|
||||
"$1 = SvIV($input) ? true : false;";
|
||||
|
||||
%typemap(in) unsigned int, unsigned short, unsigned long, unsigned char
|
||||
"$1 = ($1_ltype) SvUV($input);";
|
||||
|
||||
%typemap(in) char
|
||||
"$1 = ($1_ltype) *SvPV($input,PL_na);";
|
||||
|
||||
%typemap(in) float, double
|
||||
"$1 = ($1_ltype) SvNV($input);\n";
|
||||
|
||||
%typemap(in) long long "$1 = ($1_ltype) strtoll(SvPV($input, PL_na), 0, 0);";
|
||||
%typemap(in) unsigned long long "$1 = ($1_ltype) strtoull(SvPV($input, PL_na), 0, 0);";
|
||||
|
||||
%typemap(in) char *
|
||||
"if (!SvOK((SV*) $input)) $1 = 0;
|
||||
else $1 = ($1_ltype) SvPV($input, PL_na);";
|
||||
|
||||
%typemap(in) char [ANY]
|
||||
"$1 = SvPV($input,PL_na);\n";
|
||||
|
||||
%typemap(in) SWIGTYPE *, SWIGTYPE [], SWIGTYPE & {
|
||||
if (SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor,0) < 0) {
|
||||
SWIG_croak("Type error in argument $argnum of $symname. Expected $1_mangle");
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(in) void * {
|
||||
if (SWIG_ConvertPtr($input, (void **) &$1, 0,0) < 0) {
|
||||
SWIG_croak("Type error in argument $argnum of $symname. Expected $1_mangle");
|
||||
}
|
||||
}
|
||||
|
||||
/* Object passed by value. Convert to a pointer */
|
||||
%typemap(in) SWIGTYPE {
|
||||
$&1_ltype argp;
|
||||
if (SWIG_ConvertPtr($input,(void **) &argp, $&1_descriptor,0) < 0) {
|
||||
SWIG_croak("Type error in argument $argnum of $symname. Expected $&1_mangle");
|
||||
}
|
||||
$1 = *argp;
|
||||
}
|
||||
|
||||
/* Pointer to a class member */
|
||||
%typemap(in) SWIGTYPE (CLASS::*) {
|
||||
if ((SWIG_ConvertPacked($input, (void *) &$1, sizeof($1_type), $1_descriptor,0)) < 0) {
|
||||
SWIG_croak("Type error in argument $argnum of $symname. Expected $&1_mangle");
|
||||
}
|
||||
}
|
||||
|
||||
/* Const primitive references. Passed by value */
|
||||
|
||||
%typemap(in) const int & (int temp),
|
||||
const short & (short temp),
|
||||
const long & (long temp),
|
||||
const signed char & (signed char temp),
|
||||
const enum SWIGTYPE & ($*1_ltype temp)
|
||||
"temp = ($*1_ltype) SvIV($input);
|
||||
$1 = &temp;";
|
||||
|
||||
%typemap(in) const bool & (bool temp)
|
||||
"temp = SvIV($input) ? true : false;
|
||||
$1 = &temp;";
|
||||
|
||||
%typemap(in) const unsigned int & (unsigned int temp),
|
||||
const unsigned short & (unsigned short temp),
|
||||
const unsigned long & (unsigned long temp),
|
||||
const unsigned char & (unsigned char temp)
|
||||
"temp = ($*1_ltype) SvUV($input);
|
||||
$1 = &temp;";
|
||||
|
||||
%typemap(in) const float & (float temp),
|
||||
const double & (double temp)
|
||||
"temp = ($*1_ltype) SvNV($input);
|
||||
$1 = &temp;";
|
||||
|
||||
%typemap(in) const long long & ($*1_ltype temp)
|
||||
"temp = ($*1_ltype) strtoll(SvPV($input,PL_na),0,0);
|
||||
$1 = &temp;";
|
||||
|
||||
%typemap(in) const unsigned long long & ($*1_ltype temp)
|
||||
"temp = ($*1_ltype) strtoull(SvPV($input, PL_na),0,0);
|
||||
$1 = &temp;";
|
||||
|
||||
%typemap(in) const char &(char temp) {
|
||||
temp = *SvPV($input,PL_na);
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
/* Typemap for output values */
|
||||
|
||||
%typemap(out) int, short, long, signed char, bool, enum SWIGTYPE
|
||||
"ST(argvi) = sv_newmortal();
|
||||
sv_setiv(ST(argvi++), (IV) $1);";
|
||||
|
||||
%typemap(out) unsigned int, unsigned short, unsigned long, unsigned char
|
||||
"ST(argvi) = sv_newmortal();
|
||||
sv_setuv(ST(argvi++), (UV) $1);";
|
||||
|
||||
%typemap(out) float, double
|
||||
"ST(argvi) = sv_newmortal();
|
||||
sv_setnv(ST(argvi++), (double) $1);";
|
||||
|
||||
%typemap(out) char
|
||||
"ST(argvi) = sv_newmortal();
|
||||
sv_setpvn((SV*)ST(argvi++), &$1, 1);";
|
||||
|
||||
%typemap(out) char *
|
||||
"ST(argvi) = sv_newmortal();
|
||||
if ($1) {
|
||||
sv_setpv((SV*)ST(argvi++), (char *) $1);
|
||||
} else {
|
||||
sv_setsv((SV*)ST(argvi++), &PL_sv_undef);
|
||||
}";
|
||||
|
||||
%typemap(out) long long {
|
||||
char temp[256];
|
||||
sprintf(temp,"%lld", (long long) $1);
|
||||
ST(argvi) = sv_newmortal();
|
||||
sv_setpv((SV*)ST(argvi++), temp);
|
||||
}
|
||||
|
||||
%typemap(out) unsigned long long {
|
||||
char temp[256];
|
||||
sprintf(temp,"%llu", (unsigned long long) $1);
|
||||
ST(argvi) = sv_newmortal();
|
||||
sv_setpv((SV*)ST(argvi++), temp);
|
||||
}
|
||||
|
||||
%typemap(out) SWIGTYPE *, SWIGTYPE [], SWIGTYPE &
|
||||
"ST(argvi) = sv_newmortal();
|
||||
SWIG_MakePtr(ST(argvi++), (void *) $1, $1_descriptor, $shadow|$owner);";
|
||||
|
||||
|
||||
%typemap(out) SWIGTYPE
|
||||
#ifdef __cplusplus
|
||||
{
|
||||
$&1_ltype resultobj = new $1_ltype(($1_ltype &)$1);
|
||||
ST(argvi) = sv_newmortal();
|
||||
SWIG_MakePtr(ST(argvi++), (void *) resultobj, $&1_descriptor, $shadow|SWIG_OWNER);
|
||||
}
|
||||
#else
|
||||
{
|
||||
$&1_ltype resultobj = ($&1_ltype) malloc(sizeof($1_type));
|
||||
memmove(resultobj, &$1, sizeof($1_type));
|
||||
ST(argvi) = sv_newmortal();
|
||||
SWIG_MakePtr(ST(argvi++), (void *) resultobj, $&1_descriptor, $shadow|SWIG_OWNER);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Dynamic casts */
|
||||
|
||||
%typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC {
|
||||
swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1);
|
||||
ST(argvi) = sv_newmortal();
|
||||
SWIG_MakePtr(ST(argvi++), (void *) $1, ty, $shadow|$owner);
|
||||
}
|
||||
|
||||
/* Member pointer */
|
||||
%typemap(out) SWIGTYPE (CLASS::*) {
|
||||
ST(argvi) = sv_newmortal();
|
||||
SWIG_MakePackedObj(ST(argvi), (void *) &$1, sizeof($1_type), $1_descriptor);
|
||||
argvi++;
|
||||
}
|
||||
|
||||
%typemap(out) void "";
|
||||
|
||||
/* Typemap for character array returns */
|
||||
|
||||
%typemap(out) char [ANY]
|
||||
"ST(argvi) = sv_newmortal();
|
||||
sv_setpv((SV*)ST(argvi++),(char *) $1);";
|
||||
|
||||
|
||||
|
||||
/* References to primitive types. Return by value */
|
||||
|
||||
%typemap(out) const int &,
|
||||
const short &,
|
||||
const long &,
|
||||
const signed char &,
|
||||
const bool &,
|
||||
const enum SWIGTYPE &
|
||||
"ST(argvi) = sv_newmortal();
|
||||
sv_setiv(ST(argvi++), (IV) *($1));";
|
||||
|
||||
%typemap(out) const unsigned int &,
|
||||
const unsigned short &,
|
||||
const unsigned long &,
|
||||
const unsigned char &
|
||||
"ST(argvi) = sv_newmortal();
|
||||
sv_setuv(ST(argvi++), (UV) *($1));";
|
||||
|
||||
%typemap(out) const float &, const double &
|
||||
"ST(argvi) = sv_newmortal();
|
||||
sv_setnv(ST(argvi++), (double) *($1));";
|
||||
|
||||
%typemap(out) const long long & {
|
||||
char temp[256];
|
||||
sprintf(temp,"%lld", (long long)*($1));
|
||||
ST(argvi) = sv_newmortal();
|
||||
sv_setpv((SV*)ST(argvi++), temp);
|
||||
}
|
||||
|
||||
%typemap(out) const unsigned long long & {
|
||||
char temp[256];
|
||||
sprintf(temp,"%llu", (unsigned long long)*($1));
|
||||
ST(argvi) = sv_newmortal();
|
||||
sv_setpv((SV*)ST(argvi++), temp);
|
||||
}
|
||||
|
||||
%typemap(out) const char &
|
||||
"ST(argvi) = sv_newmortal();
|
||||
sv_setpvn((SV*)ST(argvi++), $1, 1);";
|
||||
|
||||
|
||||
/* Variable input */
|
||||
|
||||
%typemap(varin) int, short, long, signed char
|
||||
"$1 = ($1_ltype) SvIV($input);";
|
||||
|
||||
%typemap(varin) bool
|
||||
"$1 = SvIV($input) ? true : false;";
|
||||
|
||||
%typemap(varin) unsigned int, unsigned short, unsigned long, unsigned char
|
||||
"$1 = ($1_ltype) SvUV($input);";
|
||||
|
||||
%typemap(varin) char
|
||||
"$1 = ($1_ltype) *SvPV($input,PL_na);";
|
||||
|
||||
%typemap(varin) float, double
|
||||
"$1 = ($1_ltype) SvNV($input);\n";
|
||||
|
||||
%typemap(varin) long long "$1 = ($1_ltype) strtoll(SvPV($input, PL_na), 0, 0);";
|
||||
%typemap(varin) unsigned long long "$1 = ($1_ltype) strtoull(SvPV($input, PL_na), 0, 0);";
|
||||
|
||||
%typemap(varin) SWIGTYPE * {
|
||||
void *temp;
|
||||
if (SWIG_ConvertPtr($input, &temp, $1_descriptor,0) < 0) {
|
||||
croak("Type error in argument $argnum of $symname. Expected $1_mangle");
|
||||
}
|
||||
$1 = ($1_ltype) temp;
|
||||
}
|
||||
|
||||
%typemap(varin) SWIGTYPE [ANY] {
|
||||
int i;
|
||||
$1_basetype *temp;
|
||||
$1_basetype *b = ($1_basetype *) $1;
|
||||
if (SWIG_ConvertPtr($input, (void **) &temp, $1_descriptor,0) < 0) {
|
||||
croak("Type error in argument $argnum of $symname. Expected $1_mangle");
|
||||
}
|
||||
for (i = 0; i < $1_size; i++) b[i] = temp[i];
|
||||
}
|
||||
|
||||
%typemap(varin,warning="462:Unable to set dimensionless array variable") SWIGTYPE []
|
||||
{
|
||||
croak("C/C++ variable '$name' is read-only");
|
||||
}
|
||||
|
||||
%typemap(varin) SWIGTYPE & {
|
||||
void *temp;
|
||||
if (SWIG_ConvertPtr($input, &temp, $1_descriptor,0) < 0) {
|
||||
croak("Type error in argument $argnum of $symname. Expected $1_mangle");
|
||||
}
|
||||
$1 = *($1_ltype) temp;
|
||||
}
|
||||
|
||||
%typemap(varin) void * {
|
||||
void *temp;
|
||||
if (SWIG_ConvertPtr($input, &temp, 0,0) < 0) {
|
||||
croak("Type error in argument $argnum of $symname. Expected $1_mangle");
|
||||
}
|
||||
$1 = temp;
|
||||
}
|
||||
|
||||
/* Object passed by value. Convert to a pointer */
|
||||
%typemap(varin) SWIGTYPE {
|
||||
$&1_ltype temp;
|
||||
if (SWIG_ConvertPtr($input,(void **) &temp, $&1_descriptor,0) < 0) {
|
||||
croak("Type error in argument $argnum of $symname. Expected $&1_mangle");
|
||||
}
|
||||
$1 = *temp;
|
||||
}
|
||||
|
||||
/* Member pointer */
|
||||
%typemap(varin) SWIGTYPE (CLASS::*) {
|
||||
char temp[sizeof($1_type)];
|
||||
if (SWIG_ConvertPacked($input, (void *) temp, sizeof($1_type), $1_descriptor, 0) < 0) {
|
||||
croak("Type error in argument $argnum of $symname. Expected $&1_mangle");
|
||||
}
|
||||
memmove((void *) &$1, temp, sizeof($1_type));
|
||||
}
|
||||
|
||||
/* Const primitive references. Passed by value */
|
||||
|
||||
%typemap(varin) const int & (int temp),
|
||||
const short & (short temp),
|
||||
const long & (long temp),
|
||||
const signed char & (signed char temp),
|
||||
const enum SWIGTYPE & ($*1_ltype temp)
|
||||
"temp = ($*1_ltype) SvIV($input);
|
||||
$1 = &temp;";
|
||||
|
||||
%typemap(varin) const bool & (bool temp)
|
||||
"temp = SvIV($input) ? true : false;
|
||||
$1 = &temp;";
|
||||
|
||||
%typemap(varin) const unsigned int & (unsigned int temp),
|
||||
const unsigned short & (unsigned short temp),
|
||||
const unsigned long & (unsigned long temp),
|
||||
const unsigned char & (unsigned char temp)
|
||||
"temp = ($*1_ltype) SvUV($input);
|
||||
$1 = &temp;";
|
||||
|
||||
%typemap(varin) const float & (float temp),
|
||||
const double & (double temp)
|
||||
"temp = ($*1_ltype) SvNV($input);
|
||||
$1 = &temp;";
|
||||
|
||||
%typemap(varin) const long long & ($*1_ltype temp)
|
||||
"temp = ($1_ltype) strtoll(SvPV($input,PL_na),0,0);
|
||||
$1 = &temp;";
|
||||
|
||||
%typemap(varin) const unsigned long long & ($*1_ltype temp)
|
||||
"temp = ($1_ltype) strtoull(SvPV($input, PL_na),0,0);
|
||||
$1 = &temp;";
|
||||
|
||||
%typemap(varin) const char &(char temp) {
|
||||
temp = *SvPV($input,PL_na);
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(varin) char *
|
||||
#ifdef __cplusplus
|
||||
{
|
||||
char *_a = (char *) SvPV(sv,PL_na);
|
||||
if ($1) delete [] $1;
|
||||
$1 = new char[strlen(_a)+1];
|
||||
strcpy((char *)$1,_a);
|
||||
}
|
||||
#else
|
||||
{
|
||||
char *_a = (char *) SvPV(sv,PL_na);
|
||||
if ($1) free((char *) $1);
|
||||
$1 = (char *) malloc(strlen(_a)+1);
|
||||
strcpy((char *)$1,_a);
|
||||
}
|
||||
#endif
|
||||
|
||||
%typemap(varin,warning="451:Setting const char * variable may leak memory") const char *
|
||||
#ifdef __cplusplus
|
||||
{
|
||||
char *_a = (char *) SvPV(sv,PL_na);
|
||||
$1 = new char[strlen(_a)+1];
|
||||
strcpy((char *)$1,_a);
|
||||
}
|
||||
#else
|
||||
{
|
||||
char *_a = (char *) SvPV(sv,PL_na);
|
||||
$1 = (char *) malloc(strlen(_a)+1);
|
||||
strcpy((char *)$1,_a);
|
||||
}
|
||||
#endif
|
||||
|
||||
%typemap(varin) char [ANY]
|
||||
"strncpy($1, (char *) SvPV(sv,PL_na), $1_dim0);";
|
||||
|
||||
%typemap(varin,warning="462: Unable to set variable of type char []") char []
|
||||
{ croak("Variable $symname is read-only."); }
|
||||
|
||||
%typemap(varin) enum SWIGTYPE {
|
||||
if (sizeof(int) != sizeof($1)) {
|
||||
croak("enum variable '$name' can not be set.");
|
||||
}
|
||||
*(int *)(void *)&($1) = SvIV($input);
|
||||
}
|
||||
|
||||
/* --- Typemaps for variable output --- */
|
||||
|
||||
%typemap(varout) int, short, long, signed char, bool, enum SWIGTYPE
|
||||
"sv_setiv($result, (IV) $1);";
|
||||
|
||||
%typemap(varout) unsigned int, unsigned short, unsigned long, unsigned char
|
||||
"sv_setuv($result, (UV) $1);";
|
||||
|
||||
%typemap(varout) float, double
|
||||
"sv_setnv($result, (double) $1);";
|
||||
|
||||
%typemap(varout) char
|
||||
"sv_setpvn((SV *) $result, &$1, 1);";
|
||||
|
||||
%typemap(varout) long long {
|
||||
char temp[256];
|
||||
sprintf(temp,"%lld",(long long)$1);
|
||||
sv_setpv((SV *) $result, temp);
|
||||
}
|
||||
|
||||
%typemap(varout) unsigned long long {
|
||||
char temp[256];
|
||||
sprintf(temp,"%llu",(unsigned long long)$1);
|
||||
sv_setpv((SV *) $result, temp);
|
||||
}
|
||||
|
||||
%typemap(varout) char *, char [ANY]
|
||||
"if ($1) {
|
||||
sv_setpv((SV*)$result, (char *) $1);
|
||||
} else {
|
||||
sv_setsv((SV*)$result, &PL_sv_undef);
|
||||
}";
|
||||
|
||||
//%typemap(varout) SWIGTYPE *, SWIGTYPE &, SWIGTYPE []
|
||||
// "SWIG_MakePtr($result, (void *) $1, $1_descriptor);";
|
||||
|
||||
%typemap(varout,type="$1_descriptor") SWIGTYPE *, SWIGTYPE []
|
||||
"sv_setiv(SvRV($result),(IV) $1);";
|
||||
|
||||
%typemap(varout,type="$1_descriptor") SWIGTYPE &
|
||||
"sv_setiv(SvRV($result),(IV) &$1);";
|
||||
|
||||
//%typemap(varout) SWIGTYPE
|
||||
// "SWIG_MakePtr($result, (void *) &$1, $&1_descriptor);";
|
||||
|
||||
%typemap(varout,type="$&1_descriptor") SWIGTYPE
|
||||
"sv_setiv(SvRV($result), (IV) &$1);";
|
||||
|
||||
%typemap(varout,type="$1_descriptor") SWIGTYPE (CLASS::*) {
|
||||
SWIG_MakePackedObj($result, (void *) &$1, sizeof($1_type), $1_descriptor);
|
||||
}
|
||||
|
||||
/* --- Typemaps for constants --- *
|
||||
|
||||
/* --- Constants --- */
|
||||
|
||||
%typemap(consttab) int, unsigned int, short, unsigned short, long, unsigned long, unsigned char, signed char, bool, enum SWIGTYPE
|
||||
{ SWIG_INT, (char *) SWIG_prefix "$symname", (long) $value, 0, 0, 0}
|
||||
|
||||
%typemap(consttab) float, double
|
||||
{ SWIG_FLOAT, (char *) SWIG_prefix "$symname", 0, (double) $value, 0, 0}
|
||||
|
||||
%typemap(consttab) char, char *
|
||||
{ SWIG_STRING, (char *) SWIG_prefix "$symname", 0, 0, (void *)$value, 0}
|
||||
|
||||
%typemap(consttab) long long, unsigned long long
|
||||
{ SWIG_STRING, (char *) SWIG_prefix "$symname", 0, 0, (void *) "$value", 0}
|
||||
|
||||
%typemap(consttab) SWIGTYPE *, SWIGTYPE &, SWIGTYPE []
|
||||
{ SWIG_POINTER, (char *) SWIG_prefix "$symname", 0, 0, (void *)$value, &$1_descriptor}
|
||||
|
||||
%typemap(consttab) SWIGTYPE (CLASS::*)
|
||||
{ SWIG_BINARY, (char *) SWIG_prefix "$symname", sizeof($type), 0, (void *)&$value, &$1_descriptor}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* String & length
|
||||
* Perl configuration module.
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%typemap(in) (char *STRING, int LENGTH) {
|
||||
STRLEN temp;
|
||||
$1 = ($1_ltype) SvPV($input,temp);
|
||||
$2 = ($2_ltype) temp;
|
||||
}
|
||||
/* ------------------------------------------------------------
|
||||
* Inner macros
|
||||
* ------------------------------------------------------------ */
|
||||
%include <perlmacros.swg>
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Typechecking rules
|
||||
* Error manipulation
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_INTEGER)
|
||||
int, short, long,
|
||||
unsigned int, unsigned short, unsigned long,
|
||||
signed char, unsigned char,
|
||||
long long, unsigned long long,
|
||||
const int &, const short &, const long &,
|
||||
const unsigned int &, const unsigned short &, const unsigned long &,
|
||||
const long long &, const unsigned long long &,
|
||||
enum SWIGTYPE, const enum SWIGTYPE &,
|
||||
bool, const bool &
|
||||
{
|
||||
$1 = SvIOK($input) ? 1 : 0;
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_DOUBLE)
|
||||
float, double,
|
||||
const float &, const double &
|
||||
{
|
||||
$1 = SvNIOK($input) ? 1 : 0;
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_CHAR) char {
|
||||
$1 = SvPOK($input) ? 1 : 0;
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_STRING) char * {
|
||||
$1 = SvPOK($input) ? 1 : 0;
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
|
||||
void *tmp;
|
||||
if (SWIG_ConvertPtr($input, (void **) &tmp, $1_descriptor, 0) == -1) {
|
||||
$1 = 0;
|
||||
} else {
|
||||
$1 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE {
|
||||
void *tmp;
|
||||
if (SWIG_ConvertPtr($input, (void **) &tmp, $&1_descriptor, 0) == -1) {
|
||||
$1 = 0;
|
||||
} else {
|
||||
$1 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_VOIDPTR) void * {
|
||||
void *tmp;
|
||||
if (SWIG_ConvertPtr($input, (void **) &tmp, 0, 0) == -1) {
|
||||
$1 = 0;
|
||||
} else {
|
||||
$1 = 1;
|
||||
}
|
||||
}
|
||||
%include <perlerrors.swg>
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Exception handling
|
||||
* The runtime part
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%typemap(throws) int,
|
||||
long,
|
||||
short,
|
||||
unsigned int,
|
||||
unsigned long,
|
||||
unsigned short {
|
||||
SWIG_SetErrorf("%d", $1); SWIG_fail;
|
||||
}
|
||||
|
||||
/* throws real objects */
|
||||
%typemap(throws) SWIGTYPE
|
||||
{
|
||||
SV *esv=sv_newmortal();
|
||||
$&1_ltype copy = new $1_ltype(($1_ltype &)$1);
|
||||
SWIG_MakePtr(esv, (void *) copy,
|
||||
$&1_descriptor, SWIG_OWNER);
|
||||
SWIG_croakSV(esv);
|
||||
}
|
||||
|
||||
%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY] %{
|
||||
(void)$1;
|
||||
SWIG_croak("C++ $1_type exception thrown");
|
||||
%}
|
||||
|
||||
%typemap(throws) enum SWIGTYPE %{
|
||||
(void)$1;
|
||||
SWIG_croak("C++ $1_type exception thrown");
|
||||
%}
|
||||
|
||||
%typemap(throws) char * {
|
||||
SWIG_croak($1);
|
||||
}
|
||||
%include <perlruntime.swg>
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* ANSI C typemaps
|
||||
* Special user directives
|
||||
* ------------------------------------------------------------ */
|
||||
%include <perluserdir.swg>
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Look for user fragments file.
|
||||
* ------------------------------------------------------------ */
|
||||
%include "perlfragments.swg"
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Typemap specializations
|
||||
* ------------------------------------------------------------ */
|
||||
%include <perltypemaps.swg>
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Overloaded operator support
|
||||
* ------------------------------------------------------------ */
|
||||
%include <perlopers.swg>
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Warnings for Perl keywords
|
||||
* ------------------------------------------------------------ */
|
||||
%include <perlkw.swg>
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* The Perl initialization function
|
||||
* ------------------------------------------------------------ */
|
||||
%include <perlinit.swg>
|
||||
|
||||
%apply unsigned long { size_t };
|
||||
|
||||
%include "perlinit.swg"
|
||||
|
|
|
|||
54
SWIG/Lib/perl5/perlerrors.swg
Normal file
54
SWIG/Lib/perl5/perlerrors.swg
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* error manipulation
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%insert("runtime") "swigerrors.swg"
|
||||
|
||||
%insert("header") %{
|
||||
|
||||
SWIGINTERN const char*
|
||||
SWIG_Perl_ErrorType(int code) {
|
||||
const char* type = 0;
|
||||
switch(code) {
|
||||
case SWIG_MemoryError:
|
||||
type = "MemoryError";
|
||||
break;
|
||||
case SWIG_IOError:
|
||||
type = "IOError";
|
||||
break;
|
||||
case SWIG_RuntimeError:
|
||||
type = "RuntimeError";
|
||||
break;
|
||||
case SWIG_IndexError:
|
||||
type = "IndexError";
|
||||
break;
|
||||
case SWIG_TypeError:
|
||||
type = "TypeError";
|
||||
break;
|
||||
case SWIG_DivisionByZero:
|
||||
type = "ZeroDivisionError";
|
||||
break;
|
||||
case SWIG_OverflowError:
|
||||
type = "OverflowError";
|
||||
break;
|
||||
case SWIG_SyntaxError:
|
||||
type = "SyntaxError";
|
||||
break;
|
||||
case SWIG_ValueError:
|
||||
type = "ValueError";
|
||||
break;
|
||||
case SWIG_SystemError:
|
||||
type = "SystemError";
|
||||
break;
|
||||
case SWIG_AttributeError:
|
||||
type = "AttributeError";
|
||||
break;
|
||||
default:
|
||||
type = "RuntimeError";
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
|
||||
23
SWIG/Lib/perl5/perlfragments.swg
Normal file
23
SWIG/Lib/perl5/perlfragments.swg
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
|
||||
Create a file with this name, 'fragments.i', in your working
|
||||
directory and add all the %fragments you want to take precedence
|
||||
over the ones defined by default by swig.
|
||||
|
||||
For example, if you add:
|
||||
|
||||
%fragment(SWIG_AsVal_frag(int),"header") {
|
||||
SWIGINTERNINLINE int
|
||||
SWIG_AsVal(int)(PyObject *obj, int *val)
|
||||
{
|
||||
<your code here>;
|
||||
}
|
||||
}
|
||||
|
||||
this will replace the code used to retreive an integer value for all
|
||||
the typemaps that need it, including:
|
||||
|
||||
int, std::vector<int>, std::list<std::pair<int,int> >, etc.
|
||||
|
||||
|
||||
*/
|
||||
251
SWIG/Lib/perl5/perlkw.swg
Normal file
251
SWIG/Lib/perl5/perlkw.swg
Normal file
|
|
@ -0,0 +1,251 @@
|
|||
/* Warnings for Perl keywords */
|
||||
#define PERLKW(x) %namewarn("314:" `x` " is a perl keyword") `x`
|
||||
#define PERLBN(x) %namewarn("321:" `x` " conflicts with a built-in name in perl") "::" `x`
|
||||
|
||||
|
||||
/*
|
||||
|
||||
From http://www.rocketaware.com/perl/perlfunc/
|
||||
|
||||
*/
|
||||
|
||||
/* Functions for SCALARs or strings*/
|
||||
PERLBN(chomp);
|
||||
PERLBN(chop);
|
||||
PERLBN(chr);
|
||||
PERLBN(crypt);
|
||||
PERLBN(hex);
|
||||
PERLBN(index);
|
||||
PERLBN(lc);
|
||||
PERLBN(lcfirst);
|
||||
PERLBN(length);
|
||||
PERLBN(oct);
|
||||
PERLBN(ord);
|
||||
PERLBN(pack);
|
||||
PERLBN(reverse);
|
||||
PERLBN(rindex);
|
||||
PERLBN(sprintf);
|
||||
PERLBN(substr);
|
||||
PERLBN(uc);
|
||||
PERLBN(ucfirst);
|
||||
|
||||
/* Regular expressions and pattern matching */
|
||||
PERLBN(m);
|
||||
PERLBN(pos);
|
||||
PERLBN(quotemeta);
|
||||
PERLBN(split);
|
||||
PERLBN(study);
|
||||
|
||||
/* Numeric functions */
|
||||
PERLBN(abs);
|
||||
PERLBN(atan2);
|
||||
PERLBN(cos);
|
||||
PERLBN(exp);
|
||||
PERLBN(hex);
|
||||
PERLBN(int);
|
||||
PERLBN(log);
|
||||
PERLBN(oct);
|
||||
PERLBN(rand);
|
||||
PERLBN(sin);
|
||||
PERLBN(sqrt);
|
||||
PERLBN(srand);
|
||||
|
||||
|
||||
/* Functions for real @ARRAYs*/
|
||||
PERLBN(pop);
|
||||
PERLBN(push);
|
||||
PERLBN(shift);
|
||||
PERLBN(splice);
|
||||
PERLBN(unshift);
|
||||
|
||||
/* Functions for list data*/
|
||||
PERLBN(grep);
|
||||
PERLBN(join);
|
||||
PERLBN(map);
|
||||
PERLBN(qw);
|
||||
PERLBN(reverse);
|
||||
PERLBN(sort);
|
||||
PERLBN(unpack);
|
||||
|
||||
|
||||
/* Functions for real %HASHes*/
|
||||
PERLBN(delete);
|
||||
PERLBN(each);
|
||||
PERLBN(exists);
|
||||
PERLBN(keys);
|
||||
PERLBN(values);
|
||||
|
||||
|
||||
/* Input and output functions*/
|
||||
|
||||
PERLBN(binmode);
|
||||
PERLBN(close);
|
||||
PERLBN(closedir);
|
||||
PERLBN(dbmclose);
|
||||
PERLBN(dbmopen);
|
||||
PERLBN(die);
|
||||
PERLBN(eof);
|
||||
PERLBN(fileno);
|
||||
PERLBN(flock);
|
||||
PERLBN(format);
|
||||
PERLBN(getc);
|
||||
PERLBN(print);
|
||||
PERLBN(printf);
|
||||
PERLBN(read);
|
||||
PERLBN(readdir);
|
||||
PERLBN(rewinddir);
|
||||
PERLBN(seek);
|
||||
PERLBN(seekdir);
|
||||
PERLBN(select);
|
||||
PERLBN(syscall);
|
||||
PERLBN(sysread);
|
||||
PERLBN(sysseek);
|
||||
PERLBN(syswrite);
|
||||
PERLBN(tell);
|
||||
PERLBN(telldir);
|
||||
PERLBN(truncate);
|
||||
PERLBN(warn);
|
||||
PERLBN(write);
|
||||
|
||||
|
||||
/* Functions for fixed length data or records*/
|
||||
PERLBN(pack);
|
||||
PERLBN(read);
|
||||
PERLBN(syscall);
|
||||
PERLBN(sysread);
|
||||
PERLBN(syswrite);
|
||||
PERLBN(unpack);
|
||||
PERLBN(vec);
|
||||
|
||||
|
||||
/* Functions for filehandles, files, or directories */
|
||||
PERLBN(chdir);
|
||||
PERLBN(chmod);
|
||||
PERLBN(chown);
|
||||
PERLBN(chroot);
|
||||
PERLBN(fcntl);
|
||||
PERLBN(glob);
|
||||
PERLBN(ioctl);
|
||||
PERLBN(link);
|
||||
PERLBN(lstat);
|
||||
PERLBN(mkdir);
|
||||
PERLBN(open);
|
||||
PERLBN(opendir);
|
||||
PERLBN(readlink);
|
||||
PERLBN(rename);
|
||||
PERLBN(rmdir);
|
||||
PERLBN(stat);
|
||||
PERLBN(symlink);
|
||||
PERLBN(umask);
|
||||
PERLBN(unlink);
|
||||
PERLBN(utime);
|
||||
|
||||
|
||||
/* Keywords related to the control flow of your perl program */
|
||||
PERLKW(caller);
|
||||
PERLKW(continue);
|
||||
PERLKW(die);
|
||||
PERLKW(do);
|
||||
PERLKW(dump);
|
||||
PERLKW(eval);
|
||||
PERLKW(exit);
|
||||
PERLKW(goto);
|
||||
PERLKW(last);
|
||||
PERLKW(next);
|
||||
PERLKW(redo);
|
||||
PERLKW(return);
|
||||
PERLKW(sub);
|
||||
PERLKW(wantarray);
|
||||
|
||||
|
||||
/* Keywords related to scoping */
|
||||
PERLKW(caller);
|
||||
PERLKW(import);
|
||||
PERLKW(local);
|
||||
PERLKW(my);
|
||||
PERLKW(package);
|
||||
PERLKW(use);
|
||||
|
||||
|
||||
/* Miscellaneous functions */
|
||||
PERLBN("defined");
|
||||
PERLBN(dump);
|
||||
PERLBN(eval);
|
||||
PERLBN(formline);
|
||||
PERLBN(local);
|
||||
PERLBN(my);
|
||||
PERLBN(reset);
|
||||
PERLBN(scalar);
|
||||
PERLBN(undef);
|
||||
PERLBN(wantarray);
|
||||
|
||||
|
||||
/* Functions for processes and process groups */
|
||||
PERLBN(alarm);
|
||||
PERLBN(exec);
|
||||
PERLBN(fork);
|
||||
PERLBN(getpgrp);
|
||||
PERLBN(getppid);
|
||||
PERLBN(getpriority);
|
||||
PERLBN(kill);
|
||||
PERLBN(pipe);
|
||||
PERLBN(setpgrp);
|
||||
PERLBN(setpriority);
|
||||
PERLBN(sleep);
|
||||
PERLBN(system);
|
||||
PERLBN(times);
|
||||
PERLBN(wait);
|
||||
PERLBN(waitpid);
|
||||
|
||||
|
||||
/* Keywords related to perl modules */
|
||||
PERLKW(do);
|
||||
PERLKW(import);
|
||||
PERLKW(no);
|
||||
PERLKW(package);
|
||||
PERLKW(require);
|
||||
PERLKW(use);
|
||||
|
||||
|
||||
/* Keywords related to classes and object-orientedness */
|
||||
PERLKW(bless);
|
||||
PERLKW(dbmclose);
|
||||
PERLKW(dbmopen);
|
||||
PERLKW(package);
|
||||
PERLKW(ref);
|
||||
PERLKW(tie);
|
||||
PERLKW(tied);
|
||||
PERLKW(untie);
|
||||
PERLKW(use);
|
||||
|
||||
/* Functions new in perl5 */
|
||||
PERLBN(abs);
|
||||
PERLBN(bless);
|
||||
PERLBN(chomp);
|
||||
PERLBN(chr);
|
||||
PERLBN(exists);
|
||||
PERLBN(formline);
|
||||
PERLBN(glob);
|
||||
PERLBN(import);
|
||||
PERLBN(lc);
|
||||
PERLBN(lcfirst);
|
||||
PERLBN(map);
|
||||
PERLBN(my);
|
||||
PERLBN(no);
|
||||
PERLBN(prototype);
|
||||
PERLBN(qx);
|
||||
PERLBN(qw);
|
||||
PERLBN(readline);
|
||||
PERLBN(readpipe);
|
||||
PERLBN(ref);
|
||||
PERLBN(sub);
|
||||
PERLBN(sysopen);
|
||||
PERLBN(tie);
|
||||
PERLBN(tied);
|
||||
PERLBN(uc);
|
||||
PERLBN(ucfirst);
|
||||
PERLBN(untie);
|
||||
PERLBN(use);
|
||||
|
||||
#undef PERLKW
|
||||
#undef PERLBN
|
||||
17
SWIG/Lib/perl5/perlmacros.swg
Normal file
17
SWIG/Lib/perl5/perlmacros.swg
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
in Perl we need to pass the CPerl value, sometimes,
|
||||
so, we define decl/call macros as needed.
|
||||
*/
|
||||
|
||||
|
||||
#define SWIG_ASPTR_DECL_ARGS SWIG_PERL_DECL_ARGS_2
|
||||
#define SWIG_ASPTR_CALL_ARGS SWIG_PERL_CALL_ARGS_2
|
||||
|
||||
#define SWIG_ASVAL_DECL_ARGS SWIG_PERL_DECL_ARGS_2
|
||||
#define SWIG_ASVAL_CALL_ARGS SWIG_PERL_CALL_ARGS_2
|
||||
|
||||
#define SWIG_FROM_DECL_ARGS SWIG_PERL_DECL_ARGS_1
|
||||
#define SWIG_FROM_CALL_ARGS SWIG_PERL_CALL_ARGS_1
|
||||
|
||||
%include <typemaps/swigmacros.swg>
|
||||
|
||||
52
SWIG/Lib/perl5/perlopers.swg
Normal file
52
SWIG/Lib/perl5/perlopers.swg
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/* ------------------------------------------------------------
|
||||
* Overloaded operator support
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
%rename(__add__) *::operator+;
|
||||
%rename(__pos__) *::operator+();
|
||||
%rename(__pos__) *::operator+() const;
|
||||
%rename(__sub__) *::operator-;
|
||||
%rename(__neg__) *::operator-();
|
||||
%rename(__neg__) *::operator-() const;
|
||||
%rename(__mul__) *::operator*;
|
||||
%rename(__div__) *::operator/;
|
||||
%rename(__mod__) *::operator%;
|
||||
%rename(__lshift__) *::operator<<;
|
||||
%rename(__rshift__) *::operator>>;
|
||||
%rename(__and__) *::operator&;
|
||||
%rename(__or__) *::operator|;
|
||||
%rename(__xor__) *::operator^;
|
||||
%rename(__invert__) *::operator~;
|
||||
%rename(__lt__) *::operator<;
|
||||
%rename(__le__) *::operator<=;
|
||||
%rename(__gt__) *::operator>;
|
||||
%rename(__ge__) *::operator>=;
|
||||
%rename(__eq__) *::operator==;
|
||||
|
||||
/* Special cases */
|
||||
%rename(__call__) *::operator();
|
||||
|
||||
/* Ignored operators */
|
||||
%ignorewarn("378:operator!= ignored") operator!=;
|
||||
%ignorewarn("365:operator+= ignored") operator+=;
|
||||
%ignorewarn("366:operator-= ignored") operator-=;
|
||||
%ignorewarn("367:operator*= ignored") operator*=;
|
||||
%ignorewarn("368:operator/= ignored") operator/=;
|
||||
%ignorewarn("369:operator%= ignored") operator%=;
|
||||
%ignorewarn("375:operator<<= ignored") operator<<=;
|
||||
%ignorewarn("376:operator>>= ignored") operator>>=;
|
||||
%ignorewarn("371:operator&= ignored") operator&=;
|
||||
%ignorewarn("372:operator|= ignored") operator|=;
|
||||
%ignorewarn("370:operator^= ignored") operator^=;
|
||||
%ignorewarn("362:operator= ignored") operator=;
|
||||
%ignorewarn("383:operator++ ignored") operator++;
|
||||
%ignorewarn("384:operator-- ignored") operator--;
|
||||
%ignorewarn("381:operator&& ignored") operator&&;
|
||||
%ignorewarn("382:operator|| ignored") operator||;
|
||||
// %ignorewarn("387:operator-> ignored") operator->;
|
||||
%ignorewarn("386:operator->* ignored") operator->*;
|
||||
%ignorewarn("389:operator[] ignored (consider using %extend)") operator[];
|
||||
|
||||
#endif /* __cplusplus */
|
||||
209
SWIG/Lib/perl5/perlprimtypes.swg
Normal file
209
SWIG/Lib/perl5/perlprimtypes.swg
Normal file
|
|
@ -0,0 +1,209 @@
|
|||
/* ------------------------------------------------------------
|
||||
* Primitive Types
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
|
||||
/* boolean */
|
||||
|
||||
%fragment(SWIG_From_frag(bool),"header") {
|
||||
SWIGINTERN SV *
|
||||
SWIG_From_dec(bool)(bool value)
|
||||
{
|
||||
SV *obj = sv_newmortal();
|
||||
sv_setiv(obj, value ? 1 : 0);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_frag(bool),"header",fragment=SWIG_AsVal_frag(long)) {
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(bool)(SV *obj, bool *val)
|
||||
{
|
||||
long v;
|
||||
if (SWIG_AsVal(long)(obj, val ? &v : 0) == SWIG_OK) {
|
||||
if (val) *val = v ? true : false;
|
||||
return SWIG_OK;
|
||||
}
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
}
|
||||
|
||||
/* long */
|
||||
|
||||
%fragment(SWIG_From_frag(long),"header") {
|
||||
SWIGINTERNINLINE SV *
|
||||
SWIG_From_dec(long)(long value)
|
||||
{
|
||||
SV *obj = sv_newmortal();
|
||||
sv_setiv(obj, (IV) value);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
%fragment(SWIG_AsVal_frag(long),"header") {
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(long)(SV *obj, long* val)
|
||||
{
|
||||
if (SvIOK(obj)) {
|
||||
if (val) *val = SvIV(obj);
|
||||
return SWIG_OK;
|
||||
}
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
}
|
||||
|
||||
/* unsigned long */
|
||||
|
||||
%fragment(SWIG_From_frag(unsigned long),"header") {
|
||||
SWIGINTERNINLINE SV *
|
||||
SWIG_From_dec(unsigned long)(unsigned long value)
|
||||
{
|
||||
SV *obj = sv_newmortal();
|
||||
sv_setuv(obj, (UV) value);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
%fragment(SWIG_AsVal_frag(unsigned long),"header") {
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(unsigned long)(SV *obj, unsigned long *val)
|
||||
{
|
||||
if (SvUOK(obj)) {
|
||||
if (val) *val = SvUV(obj);
|
||||
return SWIG_OK;
|
||||
} else if (SvIOK(obj)) {
|
||||
long v = SvIV(obj);
|
||||
if (v > 0) {
|
||||
if (val) *val = SvUV(obj);
|
||||
return SWIG_OK;
|
||||
} else {
|
||||
return SWIG_OverflowError;
|
||||
}
|
||||
}
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
}
|
||||
|
||||
/* long long */
|
||||
|
||||
%fragment(SWIG_From_frag(long long),"header",
|
||||
fragment=SWIG_From_frag(long),
|
||||
fragment="<limits.h>") {
|
||||
SWIGINTERNINLINE SV *
|
||||
SWIG_From_dec(long long)(long long value)
|
||||
{
|
||||
if (((long long) LONG_MIN <= value) && (value <= (long long) LONG_MAX)) {
|
||||
return SWIG_From(long)(%numeric_cast(value,long));
|
||||
} else {
|
||||
char temp[256];
|
||||
SV *obj = sv_newmortal();
|
||||
snprintf(temp, sizeof(temp),"%lld", value);
|
||||
sv_setpv(obj, temp);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_frag(long long),"header") {
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(long long)(SV *obj, long long *val)
|
||||
{
|
||||
if (SvIOK(obj)) {
|
||||
if (val) *val = SvIV(obj);
|
||||
return SWIG_OK;
|
||||
} else {
|
||||
const char *nptr = SvPV(obj, PL_na);
|
||||
if (nptr) {
|
||||
char *endptr;
|
||||
long long v = strtoll(nptr, &endptr,0);
|
||||
if (errno == ERANGE) {
|
||||
errno = 0;
|
||||
return SWIG_OverflowError;
|
||||
} else {
|
||||
if (*endptr == '\0') {
|
||||
if (val) *val = v;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* unsigned long long */
|
||||
|
||||
%fragment(SWIG_From_frag(unsigned long long),"header",
|
||||
fragment=SWIG_From_frag(long long),
|
||||
fragment="<limits.h>") {
|
||||
SWIGINTERNINLINE SV *
|
||||
SWIG_From_dec(unsigned long long)(unsigned long long value)
|
||||
{
|
||||
if (value < (unsigned long long) LONG_MAX) {
|
||||
return SWIG_From(long long)(%numeric_cast(value, long long));
|
||||
} else {
|
||||
char temp[256];
|
||||
SV *obj = sv_newmortal();
|
||||
snprintf(temp, sizeof(temp),"%llu", value);
|
||||
sv_setpv(obj, temp);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_frag(unsigned long long),"header") {
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(unsigned long long)(SV *obj, unsigned long long *val)
|
||||
{
|
||||
if (SvUOK(obj)) {
|
||||
if (val) *val = SvUV(obj);
|
||||
return SWIG_OK;
|
||||
} else {
|
||||
const char *nptr = SvPV(obj, PL_na);
|
||||
if (nptr) {
|
||||
char *endptr;
|
||||
unsigned long long v = strtoull(nptr, &endptr,0);
|
||||
if (errno == ERANGE) {
|
||||
errno = 0;
|
||||
return SWIG_OverflowError;
|
||||
} else {
|
||||
if (*endptr == '\0') {
|
||||
if (val) *val = v;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
}
|
||||
|
||||
/* double */
|
||||
|
||||
%fragment(SWIG_From_frag(double),"header") {
|
||||
SWIGINTERNINLINE SV *
|
||||
SWIG_From_dec(double)(double value)
|
||||
{
|
||||
SV *obj = sv_newmortal();
|
||||
sv_setnv(obj, value);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_frag(double),"header") {
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(double)(SV *obj, double *val)
|
||||
{
|
||||
if (SvNIOK(obj)) {
|
||||
if (val) *val = SvNV(obj);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,183 +1,90 @@
|
|||
/* ---------------------------------------------------------------------- -*- c -*-
|
||||
* perl5.swg
|
||||
/***********************************************************************
|
||||
* perlrun.swg
|
||||
*
|
||||
* Perl5 runtime library
|
||||
* $Header$
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#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
|
||||
|
||||
#ifndef pTHX_
|
||||
#define pTHX_
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Macro to call an XS function */
|
||||
|
||||
#ifdef PERL_OBJECT
|
||||
# define SWIG_CALLXS(_name) _name(cv,pPerl)
|
||||
#else
|
||||
# ifndef MULTIPLICITY
|
||||
# define SWIG_CALLXS(_name) _name(cv)
|
||||
# else
|
||||
# define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Contract support */
|
||||
|
||||
#define SWIG_contract_assert(expr,msg) if (!(expr)) { SWIG_croak(msg); } else
|
||||
|
||||
/* Note: SwigMagicFuncHack is a typedef used to get the C++ compiler to just shut up already */
|
||||
|
||||
* This file contains the runtime support for Ruby modules
|
||||
* and includes code for managing global variables and pointer
|
||||
* type checking.
|
||||
*
|
||||
************************************************************************/
|
||||
#ifdef PERL_OBJECT
|
||||
#define MAGIC_PPERL CPerlObj *pPerl = (CPerlObj *) this;
|
||||
typedef int (CPerlObj::*SwigMagicFunc)(SV *, MAGIC *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
typedef int (CPerlObj::*SwigMagicFuncHack)(SV *, MAGIC *);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b)
|
||||
#define SWIGCLASS_STATIC
|
||||
#define SWIG_PERL_OBJECT_DECL CPerlObj *pPerl,
|
||||
#define SWIG_PERL_OBJECT_CALL pPerl,
|
||||
#else
|
||||
#define MAGIC_PPERL
|
||||
#define SWIGCLASS_STATIC static
|
||||
#ifndef MULTIPLICITY
|
||||
#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b)
|
||||
typedef int (*SwigMagicFunc)(SV *, MAGIC *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#define SWIG_PERL_OBJECT_DECL
|
||||
#define SWIG_PERL_OBJECT_CALL
|
||||
#endif
|
||||
typedef int (*SwigMagicFuncHack)(SV *, MAGIC *);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#else
|
||||
#define SWIG_MAGIC(a,b) (struct interpreter *interp, SV *a, MAGIC *b)
|
||||
typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *);
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
typedef int (*SwigMagicFuncHack)(struct interpreter *, SV *, MAGIC *);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#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
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SWIG_OWNER 1
|
||||
#define SWIG_SHADOW 2
|
||||
|
||||
/* Common SWIG API */
|
||||
|
||||
#ifdef PERL_OBJECT
|
||||
# define SWIG_ConvertPtr(obj, pp, type, flags) \
|
||||
SWIG_Perl_ConvertPtr(pPerl, obj, pp, type, flags)
|
||||
# define SWIG_NewPointerObj(p, type, flags) \
|
||||
SWIG_Perl_NewPointerObj(pPerl, p, type, flags)
|
||||
# define SWIG_MakePackedObj(sv, p, s, type) \
|
||||
SWIG_Perl_MakePackedObj(pPerl, sv, p, s, type)
|
||||
# define SWIG_ConvertPacked(obj, p, s, type, flags) \
|
||||
SWIG_Perl_ConvertPacked(pPerl, obj, p, s, type, flags)
|
||||
/* for raw pointers */
|
||||
#define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Perl_ConvertPtr(SWIG_PERL_OBJECT_CALL obj, pp, type, flags)
|
||||
#define SWIG_NewPointerObj(p, type, flags) SWIG_Perl_NewPointerObj(SWIG_PERL_OBJECT_CALL p, type, flags)
|
||||
|
||||
/* for raw packed data */
|
||||
#define SWIG_ConvertPacked(obj, p, s, type) SWIG_Perl_ConvertPacked(SWIG_PERL_OBJECT_CALL obj, p, s, type)
|
||||
#define SWIG_NewPackedObj(p, s, type) SWIG_Perl_NewPackedObj(SWIG_PERL_OBJECT_CALL p, s, type)
|
||||
|
||||
/* for class or struct pointers */
|
||||
#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags)
|
||||
#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags)
|
||||
|
||||
/* for C or C++ function pointers */
|
||||
#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0)
|
||||
#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0)
|
||||
|
||||
/* for C++ member pointers, ie, member methods */
|
||||
#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_ConvertPacked(obj, ptr, sz, ty)
|
||||
#define SWIG_NewMemberObj(ptr, sz, type) SWIG_NewPackedObj(ptr, sz, type)
|
||||
|
||||
#else
|
||||
# define SWIG_ConvertPtr(obj, pp, type, flags) \
|
||||
SWIG_Perl_ConvertPtr(obj, pp, type, flags)
|
||||
# define SWIG_NewPointerObj(p, type, flags) \
|
||||
SWIG_Perl_NewPointerObj(p, type, flags)
|
||||
# define SWIG_MakePackedObj(sv, p, s, type) \
|
||||
SWIG_Perl_MakePackedObj(sv, p, s, type )
|
||||
# define SWIG_ConvertPacked(obj, p, s, type, flags) \
|
||||
SWIG_Perl_ConvertPacked(obj, p, s, type, flags)
|
||||
#endif
|
||||
|
||||
/* Runtime API */
|
||||
#define SWIG_GetModule(clientdata) SWIG_Perl_GetModule()
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Perl_SetModule(pointer)
|
||||
|
||||
/* Perl-specific API */
|
||||
#ifdef PERL_OBJECT
|
||||
# define SWIG_MakePtr(sv, ptr, type, flags) \
|
||||
SWIG_Perl_MakePtr(pPerl, sv, ptr, type, flags)
|
||||
# define SWIG_SetError(str) \
|
||||
SWIG_Perl_SetError(pPerl, str)
|
||||
#else
|
||||
# define SWIG_MakePtr(sv, ptr, type, flags) \
|
||||
SWIG_Perl_MakePtr(sv, ptr, type, flags)
|
||||
# define SWIG_SetError(str) \
|
||||
SWIG_Perl_SetError(str)
|
||||
# define SWIG_SetErrorSV(str) \
|
||||
SWIG_Perl_SetErrorSV(str)
|
||||
#define SWIG_GetModule(clientdata) SWIG_Perl_GetModule()
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Perl_SetModule(pointer)
|
||||
|
||||
|
||||
/* Error manipulation */
|
||||
|
||||
#define SWIG_ErrorType(code) SWIG_Perl_ErrorType(code)
|
||||
#define SWIG_Error(code, msg) sv_setpvf(perl_get_sv("@", TRUE), "%s error %s\n", SWIG_ErrorType(code), msg)
|
||||
#define SWIG_fail goto fail
|
||||
|
||||
/* Perl-specific SWIG API */
|
||||
|
||||
#define SWIG_MakePtr(sv, ptr, type, flags) SWIG_Perl_MakePtr(SWIG_PERL_OBJECT_CALL sv, ptr, type, flags)
|
||||
#define SWIG_MakePackedObj(sv, p, s, type) SWIG_Perl_MakePackedObj(SWIG_PERL_OBJECT_CALL sv, p, s, type)
|
||||
#define SWIG_SetError(str) SWIG_Error(SWIG_RuntimeError, str)
|
||||
|
||||
|
||||
#define SWIG_PERL_DECL_ARGS_1(arg1) (SWIG_PERL_OBJECT_DECL arg1)
|
||||
#define SWIG_PERL_CALL_ARGS_1(arg1) (SWIG_PERL_OBJECT_CALL arg1)
|
||||
#define SWIG_PERL_DECL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_DECL arg1, arg2)
|
||||
#define SWIG_PERL_CALL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_CALL arg1, arg2)
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* pointers/data manipulation
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#if 0
|
||||
} /* cc-mode */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define SWIG_SetErrorf SWIG_Perl_SetErrorf
|
||||
#define SWIG_OWNER SWIG_POINTER_OWN
|
||||
#define SWIG_SHADOW SWIG_OWNER << 1
|
||||
|
||||
#define SWIG_MAYBE_PERL_OBJECT SWIG_PERL_OBJECT_DECL
|
||||
|
||||
#ifdef PERL_OBJECT
|
||||
# define SWIG_MAYBE_PERL_OBJECT CPerlObj *pPerl,
|
||||
#else
|
||||
# define SWIG_MAYBE_PERL_OBJECT
|
||||
#endif
|
||||
|
||||
static swig_cast_info *
|
||||
SWIGRUNTIME swig_cast_info *
|
||||
SWIG_Perl_TypeCheckRV(SWIG_MAYBE_PERL_OBJECT SV *rv, swig_type_info *ty) {
|
||||
SWIG_TypeCheck_Template(sv_derived_from(rv, (char *) iter->type->name), ty);
|
||||
}
|
||||
|
||||
/* Function for getting a pointer value */
|
||||
|
||||
static int
|
||||
SWIGRUNTIME int
|
||||
SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags) {
|
||||
swig_cast_info *tc;
|
||||
void *voidptr = (void *)0;
|
||||
|
|
@ -201,7 +108,7 @@ SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *
|
|||
}
|
||||
}
|
||||
} else {
|
||||
return -1;
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
} else {
|
||||
tmp = SvIV((SV*)SvRV(sv));
|
||||
|
|
@ -209,37 +116,36 @@ SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *
|
|||
voidptr = (void *)tmp;
|
||||
if (!_t) {
|
||||
*(ptr) = voidptr;
|
||||
return 0;
|
||||
return SWIG_OK;
|
||||
}
|
||||
} else if (! SvOK(sv)) { /* Check for undef */
|
||||
*(ptr) = (void *) 0;
|
||||
return 0;
|
||||
return SWIG_OK;
|
||||
} else if (SvTYPE(sv) == SVt_RV) { /* Check for NULL pointer */
|
||||
*(ptr) = (void *) 0;
|
||||
if (!SvROK(sv))
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
if (!SvROK(sv)) {
|
||||
*(ptr) = (void *) 0;
|
||||
return SWIG_OK;
|
||||
} else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
} else { /* Don't know what it is */
|
||||
*(ptr) = (void *) 0;
|
||||
return -1;
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (_t) {
|
||||
/* Now see if the types match */
|
||||
char *_c = HvNAME(SvSTASH(SvRV(sv)));
|
||||
tc = SWIG_TypeCheck(_c,_t);
|
||||
if (!tc) {
|
||||
*ptr = voidptr;
|
||||
return -1;
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
*ptr = SWIG_TypeCast(tc,voidptr);
|
||||
return 0;
|
||||
return SWIG_OK;
|
||||
}
|
||||
*ptr = voidptr;
|
||||
return 0;
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
SWIGRUNTIME void
|
||||
SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, int flags) {
|
||||
if (ptr && (flags & SWIG_SHADOW)) {
|
||||
SV *self;
|
||||
|
|
@ -268,15 +174,15 @@ SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, i
|
|||
}
|
||||
}
|
||||
|
||||
static SWIGINLINE SV *
|
||||
SWIGRUNTIMEINLINE SV *
|
||||
SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *ptr, swig_type_info *t, int flags) {
|
||||
SV *result = sv_newmortal();
|
||||
SWIG_MakePtr(result, ptr, t, flags);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, int sz, swig_type_info *type) {
|
||||
SWIGRUNTIME void
|
||||
SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, int sz, swig_type_info *type) {
|
||||
char result[1024];
|
||||
char *r = result;
|
||||
if ((2*sz + 1 + strlen(type->name)) > 1000) return;
|
||||
|
|
@ -286,49 +192,35 @@ static void
|
|||
sv_setpv(sv, result);
|
||||
}
|
||||
|
||||
SWIGRUNTIME SV *
|
||||
SWIG_Perl_NewPackedObj(SWIG_MAYBE_PERL_OBJECT void *ptr, int sz, swig_type_info *type) {
|
||||
SV *result = sv_newmortal();
|
||||
SWIG_Perl_MakePackedObj(result, ptr, sz, type);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Convert a packed value value */
|
||||
static int
|
||||
SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty, int flags) {
|
||||
SWIGRUNTIME int
|
||||
SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty) {
|
||||
swig_cast_info *tc;
|
||||
const char *c = 0;
|
||||
|
||||
if ((!obj) || (!SvOK(obj))) return -1;
|
||||
if ((!obj) || (!SvOK(obj))) return SWIG_ERROR;
|
||||
c = SvPV(obj, PL_na);
|
||||
/* Pointer values must start with leading underscore */
|
||||
if (*c != '_') return -1;
|
||||
if (*c != '_') return SWIG_ERROR;
|
||||
c++;
|
||||
c = SWIG_UnpackData(c,ptr,sz);
|
||||
if (ty) {
|
||||
tc = SWIG_TypeCheck(c,ty);
|
||||
if (!tc) return -1;
|
||||
if (!tc) return SWIG_ERROR;
|
||||
}
|
||||
return 0;
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
static SWIGINLINE void
|
||||
SWIG_Perl_SetError(SWIG_MAYBE_PERL_OBJECT const char *error) {
|
||||
if (error) sv_setpv(perl_get_sv("@", TRUE), error);
|
||||
}
|
||||
|
||||
static SWIGINLINE void
|
||||
SWIG_Perl_SetErrorSV(SWIG_MAYBE_PERL_OBJECT SV *error) {
|
||||
if (error) sv_setsv(perl_get_sv("@", TRUE), error);
|
||||
}
|
||||
|
||||
static void
|
||||
SWIG_Perl_SetErrorf(const char *fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
sv_vsetpvfn(perl_get_sv("@", TRUE), fmt, strlen(fmt), &args, Null(SV**), 0, Null(bool*));
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
/* Macros for low-level exception handling */
|
||||
#define SWIG_fail goto fail
|
||||
#define SWIG_croak(x) { SWIG_SetError(x); goto fail; }
|
||||
#define SWIG_croakSV(x) { SWIG_SetErrorSV(x); goto fail; }
|
||||
/* most preprocessors do not support vararg macros :-( */
|
||||
/* #define SWIG_croakf(x...) { SWIG_SetErrorf(x); goto fail; } */
|
||||
#define SWIG_croak(x) { SWIG_Error(SWIG_RuntimeError, x); SWIG_fail; }
|
||||
|
||||
|
||||
typedef XS(SwigPerlWrapper);
|
||||
|
|
@ -358,9 +250,6 @@ typedef struct swig_constant_info {
|
|||
swig_type_info **ptype;
|
||||
} swig_constant_info;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Structure for variable table */
|
||||
typedef struct {
|
||||
|
|
@ -374,14 +263,15 @@ typedef struct {
|
|||
#ifndef PERL_OBJECT
|
||||
#define swig_create_magic(s,a,b,c) _swig_create_magic(s,a,b,c)
|
||||
#ifndef MULTIPLICITY
|
||||
static void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) {
|
||||
SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *))
|
||||
#else
|
||||
static void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) {
|
||||
SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *))
|
||||
#endif
|
||||
#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, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) {
|
||||
SWIGRUNTIME void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *))
|
||||
#endif
|
||||
{
|
||||
MAGIC *mg;
|
||||
sv_magic(sv,sv,'U',(char *) name,strlen(name));
|
||||
mg = mg_find(sv,'U');
|
||||
|
|
@ -394,7 +284,7 @@ static void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (C
|
|||
}
|
||||
|
||||
|
||||
static swig_module_info *
|
||||
SWIGRUNTIME swig_module_info *
|
||||
SWIG_Perl_GetModule() {
|
||||
static void *type_pointer = (void *)0;
|
||||
SV *pointer;
|
||||
|
|
@ -410,7 +300,7 @@ SWIG_Perl_GetModule() {
|
|||
return (swig_module_info *) type_pointer;
|
||||
}
|
||||
|
||||
static void
|
||||
SWIGRUNTIME void
|
||||
SWIG_Perl_SetModule(swig_module_info *module) {
|
||||
SV *pointer;
|
||||
|
||||
|
|
@ -418,3 +308,10 @@ SWIG_Perl_SetModule(swig_module_info *module) {
|
|||
pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TRUE);
|
||||
sv_setiv(pointer, PTR2IV(module));
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if 0
|
||||
{ /* cc-mode */
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
101
SWIG/Lib/perl5/perlruntime.swg
Normal file
101
SWIG/Lib/perl5/perlruntime.swg
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
%insert(runtime) %{
|
||||
|
||||
#include <EXTERN.h>
|
||||
#include <perl.h>
|
||||
#include <XSUB.h>
|
||||
|
||||
/* Get rid of free and malloc defined by perl */
|
||||
#undef free
|
||||
#undef malloc
|
||||
|
||||
#ifndef pTHX_
|
||||
#define pTHX_
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* Macro to call an XS function */
|
||||
|
||||
#ifdef PERL_OBJECT
|
||||
# define SWIG_CALLXS(_name) _name(cv,pPerl)
|
||||
#else
|
||||
# ifndef MULTIPLICITY
|
||||
# define SWIG_CALLXS(_name) _name(cv)
|
||||
# else
|
||||
# define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Note: SwigMagicFuncHack is a typedef used to get the C++ compiler to just shut up already */
|
||||
|
||||
#ifdef PERL_OBJECT
|
||||
#define MAGIC_PPERL CPerlObj *pPerl = (CPerlObj *) this;
|
||||
typedef int (CPerlObj::*SwigMagicFunc)(SV *, MAGIC *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
typedef int (CPerlObj::*SwigMagicFuncHack)(SV *, MAGIC *);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b)
|
||||
#define SWIGCLASS_STATIC
|
||||
#else
|
||||
#define MAGIC_PPERL
|
||||
#define SWIGCLASS_STATIC static
|
||||
#ifndef MULTIPLICITY
|
||||
#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b)
|
||||
typedef int (*SwigMagicFunc)(SV *, MAGIC *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
typedef int (*SwigMagicFuncHack)(SV *, MAGIC *);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#else
|
||||
#define SWIG_MAGIC(a,b) (struct interpreter *interp, SV *a, MAGIC *b)
|
||||
typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *);
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
typedef int (*SwigMagicFuncHack)(struct interpreter *, SV *, MAGIC *);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#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
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
%}
|
||||
|
||||
|
||||
%runtime "swigrun.swg" // Common C API type-checking code
|
||||
%runtime "perlrun.swg" // Perl runtime functions
|
||||
%runtime "noembed.h" // undefine Perl5 macros
|
||||
|
||||
48
SWIG/Lib/perl5/perlstrings.swg
Normal file
48
SWIG/Lib/perl5/perlstrings.swg
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/* ------------------------------------------------------------
|
||||
* utility methods for char strings
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%fragment("SWIG_AsCharPtrAndSize","header") {
|
||||
SWIGINTERN int
|
||||
SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc)
|
||||
{
|
||||
static swig_type_info* pchar_info = 0;
|
||||
char* vptr = 0;
|
||||
if (!pchar_info) pchar_info = SWIG_TypeQuery("char *");
|
||||
if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_info, 0) == SWIG_OK) {
|
||||
if (cptr) *cptr = vptr;
|
||||
if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0;
|
||||
if (alloc) *alloc = SWIG_OLDOBJ;
|
||||
return SWIG_OK;
|
||||
} else {
|
||||
if (SvPOK(obj)) {
|
||||
STRLEN len = 0;
|
||||
char *cstr = SvPV(obj, len);
|
||||
size_t size = len + 1;
|
||||
if (cptr) {
|
||||
if (alloc) {
|
||||
if (*alloc == SWIG_NEWOBJ) {
|
||||
*cptr = %new_copy_array(cstr, size, char);
|
||||
} else {
|
||||
*cptr = cstr;
|
||||
*alloc = SWIG_OLDOBJ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (psize) *psize = size;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_FromCharPtrAndSize","header") {
|
||||
SWIGINTERNINLINE SV *
|
||||
SWIG_FromCharPtrAndSize(const char* carray, size_t size)
|
||||
{
|
||||
SV *obj = sv_newmortal();
|
||||
sv_setpv(obj, carray);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
44
SWIG/Lib/perl5/perltypemaps.swg
Normal file
44
SWIG/Lib/perl5/perltypemaps.swg
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Typemap specializations
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* no director supported in Perl */
|
||||
#ifdef SWIG_DIRECTOR_TYPEMAPS
|
||||
#undef SWIG_DIRECTOR_TYPEMAPS
|
||||
#endif
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Basic definitions
|
||||
*
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#define %newpointer_flags $shadow
|
||||
#define %newinstance_flags $shadow
|
||||
|
||||
#define SWIG_Object SV *
|
||||
#define VOID_Object $result; argvi=0
|
||||
|
||||
#define %set_output(obj) $result = obj; argvi++
|
||||
#define %append_output(obj) if (argvi >= items) EXTEND(sp,1); %set_output(obj)
|
||||
#define %set_varoutput(obj) sv_setsv($result,obj);
|
||||
#define %raise(obj, type, desc) sv_setsv(perl_get_sv("@", TRUE), obj); croak(Nullch)
|
||||
%define %set_constant(name, obj) {
|
||||
SV *sv = get_sv((char*) SWIG_prefix name, TRUE | 0x2);
|
||||
sv_setsv(sv, obj);
|
||||
SvREADONLY_on(sv);
|
||||
}
|
||||
%enddef
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* All the typemaps
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
%include <perlprimtypes.swg>
|
||||
%include <perlstrings.swg>
|
||||
|
||||
%include <typemaps/swigtypemaps.swg>
|
||||
|
||||
|
||||
2
SWIG/Lib/perl5/perluserdir.swg
Normal file
2
SWIG/Lib/perl5/perluserdir.swg
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#define %perlcode %insert("perl")
|
||||
|
||||
|
|
@ -1,75 +1,2 @@
|
|||
//
|
||||
// SWIG typemaps for std::string
|
||||
// Roy M. LeCates
|
||||
// October 23, 2002
|
||||
//
|
||||
// Perl implementation
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// std::string is typemapped by value
|
||||
// This can prevent exporting methods which return a string
|
||||
// in order for the user to modify it.
|
||||
// However, I think I'll wait until someone asks for it...
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
%include exception.i
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
|
||||
class string;
|
||||
|
||||
/* Overloading check */
|
||||
%typemap(typecheck) string = char *;
|
||||
%typemap(typecheck) const string & = char *;
|
||||
|
||||
%typemap(in) string {
|
||||
STRLEN len;
|
||||
const char *ptr = SvPV($input, len);
|
||||
if (!ptr) {
|
||||
SWIG_croak("Undefined variable in argument $argnum of $symname.");
|
||||
} else {
|
||||
$1 = std::string(ptr, len);
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(in) string *INPUT(std::string temp),
|
||||
const string & (std::string temp) {
|
||||
STRLEN len;
|
||||
const char *ptr = SvPV($input, len);
|
||||
if (!ptr) {
|
||||
SWIG_croak("Undefined variable in argument $argnum of $symname.");
|
||||
} else {
|
||||
temp.assign(ptr, len);
|
||||
$1 = &temp;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(out) string {
|
||||
if (argvi >= items) EXTEND(sp, 1); // bump stack ptr, if needed
|
||||
char *data = const_cast<char*>($1.data());
|
||||
sv_setpvn($result = sv_newmortal(), data, $1.size());
|
||||
++argvi;
|
||||
}
|
||||
|
||||
%typemap(out) const string & {
|
||||
if (argvi >= items) EXTEND(sp, 1); // bump stack ptr, if needed
|
||||
char *data = const_cast<char*>($1->data());
|
||||
sv_setpvn($result = sv_newmortal(), data, $1->size());
|
||||
++argvi;
|
||||
}
|
||||
|
||||
%typemap(throws) const string & {
|
||||
SWIG_croak($1.c_str());
|
||||
}
|
||||
|
||||
%typemap(throws) string {
|
||||
SWIG_croak($1.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
%include <perlstrings.swg>
|
||||
%include <typemaps/std_string.swg>
|
||||
|
|
|
|||
|
|
@ -1,597 +1 @@
|
|||
//
|
||||
// SWIG Typemap library
|
||||
// Dave Beazley
|
||||
// May 5, 1997
|
||||
//
|
||||
// Perl5 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.
|
||||
//
|
||||
|
||||
/*
|
||||
The SWIG typemap library provides a language independent mechanism for
|
||||
supporting output arguments, input values, and other C function
|
||||
calling mechanisms. The primary use of the library is to provide a
|
||||
better interface to certain C function--especially those involving
|
||||
pointers.
|
||||
*/
|
||||
|
||||
// INPUT typemaps.
|
||||
// These remap a C pointer to be an "INPUT" value which is passed by value
|
||||
// instead of reference.
|
||||
|
||||
|
||||
/*
|
||||
The following methods can be applied to turn a pointer into a simple
|
||||
"input" value. That is, instead of passing a pointer to an object,
|
||||
you would use a real value instead.
|
||||
|
||||
int *INPUT
|
||||
short *INPUT
|
||||
long *INPUT
|
||||
long long *INPUT
|
||||
unsigned int *INPUT
|
||||
unsigned short *INPUT
|
||||
unsigned long *INPUT
|
||||
unsigned long long *INPUT
|
||||
unsigned char *INPUT
|
||||
bool *INPUT
|
||||
float *INPUT
|
||||
double *INPUT
|
||||
|
||||
To use these, suppose you had a C function like this :
|
||||
|
||||
double fadd(double *a, double *b) {
|
||||
return *a+*b;
|
||||
}
|
||||
|
||||
You could wrap it with SWIG as follows :
|
||||
|
||||
%include typemaps.i
|
||||
double fadd(double *INPUT, double *INPUT);
|
||||
|
||||
or you can use the %apply directive :
|
||||
|
||||
%include typemaps.i
|
||||
%apply double *INPUT { double *a, double *b };
|
||||
double fadd(double *a, double *b);
|
||||
|
||||
*/
|
||||
|
||||
%define INPUT_TYPEMAP(type, converter)
|
||||
%typemap(in) type *INPUT(type temp), type &INPUT(type temp) {
|
||||
temp = (type) converter($input);
|
||||
$1 = &temp;
|
||||
}
|
||||
%typemap(typecheck) type *INPUT = type;
|
||||
%typemap(typecheck) type &INPUT = type;
|
||||
%enddef
|
||||
|
||||
INPUT_TYPEMAP(float, SvNV);
|
||||
INPUT_TYPEMAP(double, SvNV);
|
||||
INPUT_TYPEMAP(int, SvIV);
|
||||
INPUT_TYPEMAP(long, SvIV);
|
||||
INPUT_TYPEMAP(short, SvIV);
|
||||
INPUT_TYPEMAP(signed char, SvIV);
|
||||
INPUT_TYPEMAP(unsigned int, SvUV);
|
||||
INPUT_TYPEMAP(unsigned long, SvUV);
|
||||
INPUT_TYPEMAP(unsigned short, SvUV);
|
||||
INPUT_TYPEMAP(unsigned char, SvUV);
|
||||
|
||||
%typemap(in) bool *INPUT(bool temp), bool &INPUT(bool temp) {
|
||||
temp = SvIV($input) ? true : false;
|
||||
$1 = &temp;
|
||||
}
|
||||
%typemap(typecheck) bool *INPUT = bool;
|
||||
%typemap(typecheck) bool &INPUT = bool;
|
||||
|
||||
%typemap(in) long long *INPUT($*1_ltype temp), long long &INPUT($*1_ltype temp) {
|
||||
temp = strtoll(SvPV($input,PL_na), 0, 0);
|
||||
$1 = &temp;
|
||||
}
|
||||
%typemap(typecheck) long long *INPUT = long long;
|
||||
%typemap(typecheck) long long &INPUT = long long;
|
||||
|
||||
%typemap(in) unsigned long long *INPUT($*1_ltype temp), unsigned long long &INPUT($*1_ltype temp) {
|
||||
temp = strtoull(SvPV($input,PL_na), 0, 0);
|
||||
$1 = &temp;
|
||||
}
|
||||
%typemap(typecheck) unsigned long long *INPUT = unsigned long long;
|
||||
%typemap(typecheck) unsigned long long &INPUT = unsigned long long;
|
||||
|
||||
|
||||
#undef INPUT_TYPEMAP
|
||||
|
||||
// OUTPUT typemaps. These typemaps are used for parameters that
|
||||
// are output only. The output value is appended to the result as
|
||||
// a list element.
|
||||
|
||||
/*
|
||||
The following methods can be applied to turn a pointer into an "output"
|
||||
value. When calling a function, no input value would be given for
|
||||
a parameter, but an output value would be returned. In the case of
|
||||
multiple output values, functions will return a Perl array.
|
||||
|
||||
int *OUTPUT
|
||||
short *OUTPUT
|
||||
long *OUTPUT
|
||||
long long *OUTPUT
|
||||
unsigned int *OUTPUT
|
||||
unsigned short *OUTPUT
|
||||
unsigned long *OUTPUT
|
||||
unsigned long long *OUTPUT
|
||||
unsigned char *OUTPUT
|
||||
bool *OUTPUT
|
||||
float *OUTPUT
|
||||
double *OUTPUT
|
||||
|
||||
For example, suppose you were trying to wrap the modf() function in the
|
||||
C math library which splits x into integral and fractional parts (and
|
||||
returns the integer part in one of its parameters).:
|
||||
|
||||
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 Perl output of the function would be an array containing both
|
||||
output values.
|
||||
|
||||
*/
|
||||
|
||||
// Force the argument to be ignored.
|
||||
|
||||
%typemap(in,numinputs=0) int *OUTPUT(int temp), int &OUTPUT(int temp),
|
||||
short *OUTPUT(short temp), short &OUTPUT(short temp),
|
||||
long *OUTPUT(long temp), long &OUTPUT(long temp),
|
||||
unsigned int *OUTPUT(unsigned int temp), unsigned int &OUTPUT(unsigned int temp),
|
||||
unsigned short *OUTPUT(unsigned short temp), unsigned short &OUTPUT(unsigned short temp),
|
||||
unsigned long *OUTPUT(unsigned long temp), unsigned long &OUTPUT(unsigned long temp),
|
||||
unsigned char *OUTPUT(unsigned char temp), unsigned char &OUTPUT(unsigned char temp),
|
||||
signed char *OUTPUT(signed char temp), signed char &OUTPUT(signed char temp),
|
||||
bool *OUTPUT(bool temp), bool &OUTPUT(bool temp),
|
||||
float *OUTPUT(float temp), float &OUTPUT(float temp),
|
||||
double *OUTPUT(double temp), double &OUTPUT(double temp),
|
||||
long long *OUTPUT($*1_ltype temp), long long &OUTPUT($*1_ltype temp),
|
||||
unsigned long long *OUTPUT($*1_ltype temp), unsigned long long &OUTPUT($*1_ltype temp)
|
||||
"$1 = &temp;";
|
||||
|
||||
%typemap(argout) int *OUTPUT, int &OUTPUT,
|
||||
short *OUTPUT, short &OUTPUT,
|
||||
long *OUTPUT, long &OUTPUT,
|
||||
signed char *OUTPUT, signed char &OUTPUT,
|
||||
bool *OUTPUT, bool &OUTPUT
|
||||
{
|
||||
if (argvi >= items) {
|
||||
EXTEND(sp,1);
|
||||
}
|
||||
$result = sv_newmortal();
|
||||
sv_setiv($result,(IV) *($1));
|
||||
argvi++;
|
||||
}
|
||||
|
||||
%typemap(argout) unsigned int *OUTPUT, unsigned int &OUTPUT,
|
||||
unsigned short *OUTPUT, unsigned short &OUTPUT,
|
||||
unsigned long *OUTPUT, unsigned long &OUTPUT,
|
||||
unsigned char *OUTPUT, unsigned char &OUTPUT
|
||||
{
|
||||
if (argvi >= items) {
|
||||
EXTEND(sp,1);
|
||||
}
|
||||
$result = sv_newmortal();
|
||||
sv_setuv($result,(UV) *($1));
|
||||
argvi++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
%typemap(argout) float *OUTPUT, float &OUTPUT,
|
||||
double *OUTPUT, double &OUTPUT
|
||||
{
|
||||
if (argvi >= items) {
|
||||
EXTEND(sp,1);
|
||||
}
|
||||
$result = sv_newmortal();
|
||||
sv_setnv($result,(double) *($1));
|
||||
argvi++;
|
||||
}
|
||||
|
||||
%typemap(argout) long long *OUTPUT, long long &OUTPUT {
|
||||
char temp[256];
|
||||
if (argvi >= items) {
|
||||
EXTEND(sp,1);
|
||||
}
|
||||
sprintf(temp,"%lld", (long long)*($1));
|
||||
$result = sv_newmortal();
|
||||
sv_setpv($result,temp);
|
||||
argvi++;
|
||||
}
|
||||
|
||||
%typemap(argout) unsigned long long *OUTPUT, unsigned long long &OUTPUT {
|
||||
char temp[256];
|
||||
if (argvi >= items) {
|
||||
EXTEND(sp,1);
|
||||
}
|
||||
sprintf(temp,"%llu", (unsigned long long)*($1));
|
||||
$result = sv_newmortal();
|
||||
sv_setpv($result,temp);
|
||||
argvi++;
|
||||
}
|
||||
|
||||
// INOUT
|
||||
// Mappings for an argument that is both an input and output
|
||||
// parameter
|
||||
|
||||
/*
|
||||
The following methods can be applied to make a function parameter both
|
||||
an input and output value. This combines the behavior of both the
|
||||
"INPUT" and "OUTPUT" methods described earlier. Output values are
|
||||
returned in the form of a Perl array.
|
||||
|
||||
int *INOUT
|
||||
short *INOUT
|
||||
long *INOUT
|
||||
long long *INOUT
|
||||
unsigned int *INOUT
|
||||
unsigned short *INOUT
|
||||
unsigned long *INOUT
|
||||
unsigned long long *INOUT
|
||||
unsigned char *INOUT
|
||||
bool *INOUT
|
||||
float *INOUT
|
||||
double *INOUT
|
||||
|
||||
For example, suppose you were trying to wrap the following function :
|
||||
|
||||
void neg(double *x) {
|
||||
*x = -(*x);
|
||||
}
|
||||
|
||||
You could wrap it with SWIG as follows :
|
||||
|
||||
%include typemaps.i
|
||||
void neg(double *INOUT);
|
||||
|
||||
or you can use the %apply directive :
|
||||
|
||||
%include typemaps.i
|
||||
%apply double *INOUT { double *x };
|
||||
void neg(double *x);
|
||||
|
||||
Unlike C, this mapping does not directly modify the input value.
|
||||
Rather, the modified input value shows up as the return value of the
|
||||
function. Thus, to apply this function to a Perl variable you might
|
||||
do this :
|
||||
|
||||
$x = neg($x);
|
||||
|
||||
*/
|
||||
|
||||
%typemap(in) int *INOUT = int *INPUT;
|
||||
%typemap(in) short *INOUT = short *INPUT;
|
||||
%typemap(in) long *INOUT = long *INPUT;
|
||||
%typemap(in) unsigned *INOUT = unsigned *INPUT;
|
||||
%typemap(in) unsigned short *INOUT = unsigned short *INPUT;
|
||||
%typemap(in) unsigned long *INOUT = unsigned long *INPUT;
|
||||
%typemap(in) unsigned char *INOUT = unsigned char *INPUT;
|
||||
%typemap(in) signed char *INOUT = signed char *INPUT;
|
||||
%typemap(in) bool *INOUT = bool *INPUT;
|
||||
%typemap(in) float *INOUT = float *INPUT;
|
||||
%typemap(in) double *INOUT = double *INPUT;
|
||||
%typemap(in) long long *INOUT = long long *INPUT;
|
||||
%typemap(in) unsigned long long *INOUT = unsigned long long *INPUT;
|
||||
|
||||
%typemap(in) int &INOUT = int &INPUT;
|
||||
%typemap(in) short &INOUT = short &INPUT;
|
||||
%typemap(in) long &INOUT = long &INPUT;
|
||||
%typemap(in) unsigned &INOUT = unsigned &INPUT;
|
||||
%typemap(in) unsigned short &INOUT = unsigned short &INPUT;
|
||||
%typemap(in) unsigned long &INOUT = unsigned long &INPUT;
|
||||
%typemap(in) unsigned char &INOUT = unsigned char &INPUT;
|
||||
%typemap(in) signed char &INOUT = signed char &INPUT;
|
||||
%typemap(in) bool &INOUT = bool &INPUT;
|
||||
%typemap(in) float &INOUT = float &INPUT;
|
||||
%typemap(in) double &INOUT = double &INPUT;
|
||||
%typemap(in) long long &INOUT = long long &INPUT;
|
||||
%typemap(in) unsigned long long &INOUT = unsigned long long &INPUT;
|
||||
|
||||
|
||||
%typemap(argout) int *INOUT = int *OUTPUT;
|
||||
%typemap(argout) short *INOUT = short *OUTPUT;
|
||||
%typemap(argout) long *INOUT = long *OUTPUT;
|
||||
%typemap(argout) unsigned *INOUT = unsigned *OUTPUT;
|
||||
%typemap(argout) unsigned short *INOUT = unsigned short *OUTPUT;
|
||||
%typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT;
|
||||
%typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT;
|
||||
%typemap(argout) signed char *INOUT = signed char *OUTPUT;
|
||||
%typemap(argout) bool *INOUT = bool *OUTPUT;
|
||||
%typemap(argout) float *INOUT = float *OUTPUT;
|
||||
%typemap(argout) double *INOUT = double *OUTPUT;
|
||||
%typemap(argout) long long *INOUT = long long *OUTPUT;
|
||||
%typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT;
|
||||
|
||||
|
||||
%typemap(argout) int &INOUT = int &OUTPUT;
|
||||
%typemap(argout) short &INOUT = short &OUTPUT;
|
||||
%typemap(argout) long &INOUT = long &OUTPUT;
|
||||
%typemap(argout) unsigned &INOUT = unsigned &OUTPUT;
|
||||
%typemap(argout) unsigned short &INOUT = unsigned short &OUTPUT;
|
||||
%typemap(argout) unsigned long &INOUT = unsigned long &OUTPUT;
|
||||
%typemap(argout) unsigned char &INOUT = unsigned char &OUTPUT;
|
||||
%typemap(argout) signed char &INOUT = signed char &OUTPUT;
|
||||
%typemap(argout) bool &INOUT = bool &OUTPUT;
|
||||
%typemap(argout) float &INOUT = float &OUTPUT;
|
||||
%typemap(argout) double &INOUT = double &OUTPUT;
|
||||
%typemap(argout) long long &INOUT = long long &OUTPUT;
|
||||
%typemap(argout) unsigned long long &INOUT = unsigned long long &OUTPUT;
|
||||
|
||||
// REFERENCE
|
||||
// Accept Perl references as pointers
|
||||
|
||||
/*
|
||||
The following methods make Perl references work like simple C
|
||||
pointers. References can only be used for simple input/output
|
||||
values, not C arrays however. It should also be noted that
|
||||
REFERENCES are specific to Perl and not supported in other
|
||||
scripting languages at this time.
|
||||
|
||||
int *REFERENCE
|
||||
short *REFERENCE
|
||||
long *REFERENCE
|
||||
unsigned int *REFERENCE
|
||||
unsigned short *REFERENCE
|
||||
unsigned long *REFERENCE
|
||||
unsigned char *REFERENCE
|
||||
float *REFERENCE
|
||||
double *REFERENCE
|
||||
|
||||
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 *REFERENCE);
|
||||
|
||||
or you can use the %apply directive :
|
||||
|
||||
%include typemaps.i
|
||||
%apply double *REFERENCE { double *x };
|
||||
void neg(double *x);
|
||||
|
||||
Unlike the INOUT mapping described previous, this approach directly
|
||||
modifies the value of a Perl reference. Thus, you could use it
|
||||
as follows :
|
||||
|
||||
$x = 3;
|
||||
neg(\$x);
|
||||
print "$x\n"; # Should print out -3.
|
||||
|
||||
*/
|
||||
|
||||
%typemap(in) double *REFERENCE (double dvalue), double &REFERENCE(double dvalue)
|
||||
{
|
||||
SV *tempsv;
|
||||
if (!SvROK($input)) {
|
||||
SWIG_croak("expected a reference");
|
||||
}
|
||||
tempsv = SvRV($input);
|
||||
if ((!SvNOK(tempsv)) && (!SvIOK(tempsv))) {
|
||||
printf("Received %d\n", SvTYPE(tempsv));
|
||||
SWIG_croak("Expected a double reference.");
|
||||
}
|
||||
dvalue = SvNV(tempsv);
|
||||
$1 = &dvalue;
|
||||
}
|
||||
|
||||
%typemap(in) float *REFERENCE (float dvalue), float &REFERENCE(float dvalue)
|
||||
{
|
||||
SV *tempsv;
|
||||
if (!SvROK($input)) {
|
||||
SWIG_croak("expected a reference");
|
||||
}
|
||||
tempsv = SvRV($input);
|
||||
if ((!SvNOK(tempsv)) && (!SvIOK(tempsv))) {
|
||||
SWIG_croak("expected a double reference");
|
||||
}
|
||||
dvalue = (float) SvNV(tempsv);
|
||||
$1 = &dvalue;
|
||||
}
|
||||
|
||||
%typemap(in) int *REFERENCE (int dvalue), int &REFERENCE (int dvalue)
|
||||
{
|
||||
SV *tempsv;
|
||||
if (!SvROK($input)) {
|
||||
SWIG_croak("expected a reference");
|
||||
}
|
||||
tempsv = SvRV($input);
|
||||
if (!SvIOK(tempsv)) {
|
||||
SWIG_croak("expected a integer reference");
|
||||
}
|
||||
dvalue = SvIV(tempsv);
|
||||
$1 = &dvalue;
|
||||
}
|
||||
|
||||
%typemap(in) short *REFERENCE (short dvalue), short &REFERENCE(short dvalue)
|
||||
{
|
||||
SV *tempsv;
|
||||
if (!SvROK($input)) {
|
||||
SWIG_croak("expected a reference");
|
||||
}
|
||||
tempsv = SvRV($input);
|
||||
if (!SvIOK(tempsv)) {
|
||||
SWIG_croak("expected a integer reference");
|
||||
}
|
||||
dvalue = (short) SvIV(tempsv);
|
||||
$1 = &dvalue;
|
||||
}
|
||||
%typemap(in) long *REFERENCE (long dvalue), long &REFERENCE(long dvalue)
|
||||
{
|
||||
SV *tempsv;
|
||||
if (!SvROK($input)) {
|
||||
SWIG_croak("expected a reference");
|
||||
}
|
||||
tempsv = SvRV($input);
|
||||
if (!SvIOK(tempsv)) {
|
||||
SWIG_croak("expected a integer reference");
|
||||
}
|
||||
dvalue = (long) SvIV(tempsv);
|
||||
$1 = &dvalue;
|
||||
}
|
||||
%typemap(in) unsigned int *REFERENCE (unsigned int dvalue), unsigned int &REFERENCE(unsigned int dvalue)
|
||||
{
|
||||
SV *tempsv;
|
||||
if (!SvROK($input)) {
|
||||
SWIG_croak("expected a reference");
|
||||
}
|
||||
tempsv = SvRV($input);
|
||||
if (!SvIOK(tempsv)) {
|
||||
SWIG_croak("expected a integer reference");
|
||||
}
|
||||
dvalue = (unsigned int) SvUV(tempsv);
|
||||
$1 = &dvalue;
|
||||
}
|
||||
%typemap(in) unsigned short *REFERENCE (unsigned short dvalue), unsigned short &REFERENCE(unsigned short dvalue)
|
||||
{
|
||||
SV *tempsv;
|
||||
if (!SvROK($input)) {
|
||||
SWIG_croak("expected a reference");
|
||||
}
|
||||
tempsv = SvRV($input);
|
||||
if (!SvIOK(tempsv)) {
|
||||
SWIG_croak("expected a integer reference");
|
||||
}
|
||||
dvalue = (unsigned short) SvUV(tempsv);
|
||||
$1 = &dvalue;
|
||||
}
|
||||
%typemap(in) unsigned long *REFERENCE (unsigned long dvalue), unsigned long &REFERENCE(unsigned long dvalue)
|
||||
{
|
||||
SV *tempsv;
|
||||
if (!SvROK($input)) {
|
||||
SWIG_croak("expected a reference");
|
||||
}
|
||||
tempsv = SvRV($input);
|
||||
if (!SvIOK(tempsv)) {
|
||||
SWIG_croak("expected a integer reference");
|
||||
}
|
||||
dvalue = (unsigned long) SvUV(tempsv);
|
||||
$1 = &dvalue;
|
||||
}
|
||||
|
||||
%typemap(in) unsigned char *REFERENCE (unsigned char dvalue), unsigned char &REFERENCE(unsigned char dvalue)
|
||||
{
|
||||
SV *tempsv;
|
||||
if (!SvROK($input)) {
|
||||
SWIG_croak("expected a reference");
|
||||
}
|
||||
tempsv = SvRV($input);
|
||||
if (!SvIOK(tempsv)) {
|
||||
SWIG_croak("expected a integer reference");
|
||||
}
|
||||
dvalue = (unsigned char) SvUV(tempsv);
|
||||
$1 = &dvalue;
|
||||
}
|
||||
|
||||
%typemap(in) signed char *REFERENCE (signed char dvalue), signed char &REFERENCE(signed char dvalue)
|
||||
{
|
||||
SV *tempsv;
|
||||
if (!SvROK($input)) {
|
||||
SWIG_croak("expected a reference");
|
||||
}
|
||||
tempsv = SvRV($input);
|
||||
if (!SvIOK(tempsv)) {
|
||||
SWIG_croak("expected a integer reference");
|
||||
}
|
||||
dvalue = (signed char) SvIV(tempsv);
|
||||
$1 = &dvalue;
|
||||
}
|
||||
|
||||
%typemap(in) bool *REFERENCE (bool dvalue), bool &REFERENCE(bool dvalue)
|
||||
{
|
||||
SV *tempsv;
|
||||
if (!SvROK($input)) {
|
||||
SWIG_croak("expected a reference");
|
||||
}
|
||||
tempsv = SvRV($input);
|
||||
if (!SvIOK(tempsv)) {
|
||||
SWIG_croak("expected a integer reference");
|
||||
}
|
||||
dvalue = (bool) SvIV(tempsv);
|
||||
$1 = &dvalue;
|
||||
}
|
||||
|
||||
%typemap(argout) double *REFERENCE, double &REFERENCE,
|
||||
float *REFERENCE, float &REFERENCE
|
||||
{
|
||||
SV *tempsv;
|
||||
tempsv = SvRV($arg);
|
||||
if (!$1) SWIG_croak("expected a reference");
|
||||
sv_setnv(tempsv, (double) *$1);
|
||||
}
|
||||
|
||||
%typemap(argout) int *REFERENCE, int &REFERENCE,
|
||||
short *REFERENCE, short &REFERENCE,
|
||||
long *REFERENCE, long &REFERENCE,
|
||||
signed char *REFERENCE, unsigned char &REFERENCE,
|
||||
bool *REFERENCE, bool &REFERENCE
|
||||
{
|
||||
SV *tempsv;
|
||||
tempsv = SvRV($input);
|
||||
if (!$1) SWIG_croak("expected a reference");
|
||||
sv_setiv(tempsv, (IV) *$1);
|
||||
}
|
||||
|
||||
%typemap(argout) unsigned int *REFERENCE, unsigned int &REFERENCE,
|
||||
unsigned short *REFERENCE, unsigned short &REFERENCE,
|
||||
unsigned long *REFERENCE, unsigned long &REFERENCE,
|
||||
unsigned char *REFERENCE, unsigned char &REFERENCE
|
||||
{
|
||||
SV *tempsv;
|
||||
tempsv = SvRV($input);
|
||||
if (!$1) SWIG_croak("expected a reference");
|
||||
sv_setuv(tempsv, (UV) *$1);
|
||||
}
|
||||
|
||||
/* Overloading information */
|
||||
|
||||
%typemap(typecheck) double *INOUT = double;
|
||||
%typemap(typecheck) bool *INOUT = bool;
|
||||
%typemap(typecheck) signed char *INOUT = signed char;
|
||||
%typemap(typecheck) unsigned char *INOUT = unsigned char;
|
||||
%typemap(typecheck) unsigned long *INOUT = unsigned long;
|
||||
%typemap(typecheck) unsigned short *INOUT = unsigned short;
|
||||
%typemap(typecheck) unsigned int *INOUT = unsigned int;
|
||||
%typemap(typecheck) long *INOUT = long;
|
||||
%typemap(typecheck) short *INOUT = short;
|
||||
%typemap(typecheck) int *INOUT = int;
|
||||
%typemap(typecheck) float *INOUT = float;
|
||||
%typemap(typecheck) long long *INOUT = long long;
|
||||
%typemap(typecheck) unsigned long long *INOUT = unsigned long long;
|
||||
|
||||
%typemap(typecheck) double &INOUT = double;
|
||||
%typemap(typecheck) bool &INOUT = bool;
|
||||
%typemap(typecheck) signed char &INOUT = signed char;
|
||||
%typemap(typecheck) unsigned char &INOUT = unsigned char;
|
||||
%typemap(typecheck) unsigned long &INOUT = unsigned long;
|
||||
%typemap(typecheck) unsigned short &INOUT = unsigned short;
|
||||
%typemap(typecheck) unsigned int &INOUT = unsigned int;
|
||||
%typemap(typecheck) long &INOUT = long;
|
||||
%typemap(typecheck) short &INOUT = short;
|
||||
%typemap(typecheck) int &INOUT = int;
|
||||
%typemap(typecheck) float &INOUT = float;
|
||||
%typemap(typecheck) long long &INOUT = long long;
|
||||
%typemap(typecheck) unsigned long long &INOUT = unsigned long long;
|
||||
|
||||
%include <typemaps/typemaps.swg>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue