[Pike] Remove code for Pike

We dropped support for it in SWIG 4.0.0 and nobody has stepped forward
to revive it in over 2 years.

See #2009.
This commit is contained in:
Olly Betts 2021-05-13 11:11:40 +12:00
commit 11bb422bd3
37 changed files with 5 additions and 2534 deletions

View file

@ -1,326 +0,0 @@
/* -----------------------------------------------------------------------------
* pike.swg
*
* Pike configuration module.
* ----------------------------------------------------------------------------- */
%insert(runtime) "swigrun.swg"; // Common C API type-checking code
%insert(runtime) "pikerun.swg"; // Pike run-time code
%insert(runtime) %{
#ifdef __cplusplus
extern "C" {
#endif
#include <pike/global.h>
#include <pike/module.h>
#include <pike/interpret.h>
#ifdef __cplusplus
}
#endif
%}
/* -----------------------------------------------------------------------------
* standard typemaps
* ----------------------------------------------------------------------------- */
/* --- Input arguments --- */
/* Primitive datatypes. */
%typemap(in, pikedesc="tInt")
int, unsigned int, short, unsigned short,
long, unsigned long, char, signed char, unsigned char,
bool, enum SWIGTYPE, long long, unsigned long long
{
if ($input.type != T_INT)
Pike_error("Bad argument: Expected an integer.\n");
$1 = ($1_ltype) $input.u.integer;
}
%typemap(in, pikedesc="tFloat") float, double {
if ($input.type != T_FLOAT)
Pike_error("Bad argument: Expected a float.\n");
$1 = ($1_ltype) $input.u.float_number;
}
%typemap(in, pikedesc="tStr") char *, char [ANY] {
if ($input.type != T_STRING)
Pike_error("Bad argument: Expected a string.\n");
$1 = ($1_ltype) STR0($input.u.string);
}
/* Pointers, references and arrays */
%typemap(in) SWIGTYPE *,
SWIGTYPE &,
SWIGTYPE &&,
SWIGTYPE []
"SWIG_ConvertPtr($input.u.object, (void **) &$1, $1_descriptor, 1);"
/* Void pointer. Accepts any kind of pointer */
%typemap(in) void * "/* FIXME */";
/* Object passed by value. Convert to a pointer */
%typemap(in) SWIGTYPE ($&1_ltype argp) "/* FIXME */";
/* Pointer to a class member */
%typemap(in) SWIGTYPE (CLASS::*) "/* FIXME */";
/* Const primitive references. Passed by value */
%typemap(in, pikedesc="tInt") const int & (int temp),
const short & (short temp),
const long & (long temp),
const unsigned int & (unsigned int temp),
const unsigned short & (unsigned short temp),
const unsigned long & (unsigned long temp),
const char & (char temp),
const signed char & (signed char temp),
const unsigned char & (unsigned char temp),
const bool & (bool temp),
const long long & ($*1_ltype temp),
const unsigned long long & ($*1_ltype temp),
const enum SWIGTYPE & ($*1_ltype temp),
const enum SWIGTYPE && ($*1_ltype temp)
{
if ($input.type != T_INT)
Pike_error("Bad argument: Expected an integer.\n");
temp = ($*1_ltype) $input.u.integer;
$1 = &temp;
}
%typemap(in, pikedesc="tFloat") const float & (float temp),
const double & (double temp)
{
if ($input.type != T_FLOAT)
Pike_error("Bad argument: Expected a float.\n");
temp = ($*1_ltype) $input.u.float_number;
$1 = &temp;
}
/* -----------------------------------------------------------------------------
* Output Typemaps
* ----------------------------------------------------------------------------- */
%typemap(out, pikedesc="tInt")
int, unsigned int,
short, unsigned short,
long, unsigned long,
char, signed char, unsigned char,
bool, enum SWIGTYPE
"push_int($1);";
%typemap(out, pikedesc="tInt") long long "push_int64($1);";
%typemap(out, pikedesc="tInt") unsigned long long "push_int64($1);";
%typemap(out, pikedesc="tFloat") float, double "push_float($1);";
%typemap(out, pikedesc="tStr") char * "push_text($1);";
/* Pointers, references, and arrays */
%typemap(out, pikedesc="tObj") SWIGTYPE*, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] "push_object(SWIG_NewPointerObj((void *) $1, $1_descriptor, $owner));";
/* Void return value; don't push anything */
%typemap(out, pikedesc="tVoid") void "";
/* Dynamic casts */
%typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC "/* FIXME */";
/* Member pointer */
%typemap(out) SWIGTYPE (CLASS::*) "/* FIXME */";
/* Special typemap for character array return values */
%typemap(out, pikedesc="tStr") char [ANY], const char [ANY] "push_text($1);";
/* Primitive types--return by value */
%typemap(out, pikedesc="tObj") SWIGTYPE
#ifdef __cplusplus
{
$&1_ltype resultptr;
resultptr = new $1_ltype((const $1_ltype &) $1);
push_object(SWIG_NewPointerObj((void *) resultptr, $&1_descriptor, 1));
}
#else
{
$&1_ltype resultptr;
resultptr = ($&1_ltype) malloc(sizeof($1_type));
memmove(resultptr, &$1, sizeof($1_type));
push_object(SWIG_NewPointerObj((void *) resultptr, $&1_descriptor, 1));
}
#endif
/* References to primitive types. Return by value */
%typemap(out, pikedesc="tInt") const int &, const unsigned int &,
const short &, const unsigned short &,
const long &, const unsigned long &,
const char &, const signed char &, const unsigned char &,
const bool &,
const long long &, const unsigned long long &,
const enum SWIGTYPE & ($*1_ltype temp),
const enum SWIGTYPE && ($*1_ltype temp)
"push_int(*($1));";
%typemap(out, pikedesc="tFloat") const float &, const double & "push_float(*($1));";
/************************ Constant Typemaps *****************************/
%typemap(constant)
int, unsigned int,
short, unsigned short,
long, unsigned long,
signed char, unsigned char,
bool, enum SWIGTYPE,
long long, unsigned long long
"add_integer_constant(\"$symname\", $1, 0);";
%typemap(constant) char
"add_integer_constant(\"$symname\", '$1', 0);";
%typemap(constant) long long, unsigned long long
"add_integer_constant(\"$symname\", $1, 0);";
%typemap(constant) float, double
"add_float_constant(\"$symname\", $1, 0);";
%typemap(constant) char *
"add_string_constant(\"$symname\", \"$1\", 0);";
/* ------------------------------------------------------------
* String & length
* ------------------------------------------------------------ */
%typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) {
if ($input.type != T_STRING)
Pike_error("Bad argument: Expected a string.\n");
$1 = ($1_ltype) STR0($input.u.string);
$2 = ($2_ltype) $input.u.string->length;
}
/* ------------------------------------------------------------
* ANSI C typemaps
* ------------------------------------------------------------ */
%typemap(in, pikedesc="tInt") size_t {
if ($input.type != T_INT)
Pike_error("Bad argument: Expected an integer.\n");
$1 = ($1_ltype) $input.u.integer;
}
%typemap(out) size_t = long;
/* ------------------------------------------------------------
* Typechecking rules
* ------------------------------------------------------------ */
%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, enum SWIGTYPE &, SWIGTYPE &&,
bool, const bool &
{
$1 = ($input.type == T_INT) ? 1 : 0;
}
%typecheck(SWIG_TYPECHECK_DOUBLE)
float, double,
const float &, const double &
{
$1 = (($input.type == T_FLOAT) || ($input.type == T_INT)) ? 1 : 0;
}
%typecheck(SWIG_TYPECHECK_CHAR) char {
$1 = ($input.type == T_INT) ? 1 : 0;
}
%typecheck(SWIG_TYPECHECK_STRING) char * {
$1 = ($input.type == T_STRING) ? 1 : 0;
}
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
void *ptr;
if (SWIG_ConvertPtr($input.u.object, (void **) &ptr, $1_descriptor, 0) == -1) {
$1 = 0;
} else {
$1 = 1;
}
}
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE {
void *ptr;
if (SWIG_ConvertPtr($input.u.object, (void **) &ptr, $&1_descriptor, 0) == -1) {
$1 = 0;
} else {
$1 = 1;
}
}
%typecheck(SWIG_TYPECHECK_VOIDPTR) void * {
void *ptr;
if (SWIG_ConvertPtr($input.u.object, (void **) &ptr, 0, 0) == -1) {
$1 = 0;
} else {
$1 = 1;
}
}
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
/* ------------------------------------------------------------
* Overloaded operator support
* ------------------------------------------------------------ */
#ifdef __cplusplus
%rename("`+") *::operator+;
%rename("`-") *::operator-;
%rename("`*") *::operator*;
%rename("`/") *::operator/;
%rename("`%") *::operator%;
%rename("`<<") *::operator<<;
%rename("`>>") *::operator>>;
%rename("`&") *::operator&;
%rename("`|") *::operator|;
%rename("`^") *::operator^;
%rename("`~") *::operator~;
%rename("`<") *::operator<;
%rename("`>") *::operator>;
%rename("`==") *::operator==;
/* Special cases */
%rename("`()") *::operator();
#endif
/* ------------------------------------------------------------
* The start of the Pike initialization function
* ------------------------------------------------------------ */
%init "swiginit.swg"
%init %{
#ifdef __cplusplus
extern "C"
#endif
PIKE_MODULE_EXIT {}
#ifdef __cplusplus
extern "C"
#endif
PIKE_MODULE_INIT
{
struct program *pr;
SWIG_InitializeModule(0);
%}
/* pike keywords */
%include <pikekw.swg>

View file

@ -1,55 +0,0 @@
#ifndef PIKE_PIKEKW_SWG_
#define PIKE_PIKEKW_SWG_
/* Warnings for Pike keywords */
#define PIKEKW(x) %namewarn("314: '" #x "' is a pike keyword") #x
/*
from
http://www.http://docs.linux.cz/pike/tutorial_C.html
*/
PIKEKW(array);
PIKEKW(break);
PIKEKW(case);
PIKEKW(catch);
PIKEKW(continue);
PIKEKW(default);
PIKEKW(do);
PIKEKW(else);
PIKEKW(float);
PIKEKW(for);
PIKEKW(foreach);
PIKEKW(function);
PIKEKW(gauge);
PIKEKW(if);
PIKEKW(inherit);
PIKEKW(inline);
PIKEKW(int);
PIKEKW(lambda);
PIKEKW(mapping);
PIKEKW(mixed);
PIKEKW(multiset);
PIKEKW(nomask);
PIKEKW(object);
PIKEKW(predef);
PIKEKW(private);
PIKEKW(program);
PIKEKW(protected);
PIKEKW(public);
PIKEKW(return);
PIKEKW(sscanf);
PIKEKW(static);
PIKEKW(string);
PIKEKW(switch);
PIKEKW(typeof);
PIKEKW(varargs);
PIKEKW(void);
PIKEKW(while);
#undef PIKEKW
#endif //PIKE_PIKEKW_SWG_

View file

@ -1,71 +0,0 @@
/* -----------------------------------------------------------------------------
* pikerun.swg
*
* This file contains the runtime support for Pike modules
* and includes code for managing global variables and pointer
* type checking.
* ----------------------------------------------------------------------------- */
#ifdef __cplusplus
extern "C" {
#endif
#include "pike/object.h"
#include "pike/program.h"
#ifdef __cplusplus
}
#endif
#include <assert.h>
/* Stores information about a wrapped object */
typedef struct swig_object_wrapper {
void *self;
swig_type_info *type;
} swig_object_wrapper;
#ifdef THIS
#undef THIS
#endif
#define THIS (((swig_object_wrapper *) Pike_fp->current_storage)->self)
#define SWIG_ConvertPtr SWIG_Pike_ConvertPtr
#define SWIG_NewPointerObj SWIG_Pike_NewPointerObj
#define SWIG_GetModule(clientdata) SWIG_Pike_GetModule(clientdata)
#define SWIG_SetModule(clientdata, pointer) SWIG_Pike_SetModule(pointer)
/* These need to be filled in before type sharing between modules will work */
static swig_module_info *SWIG_Pike_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
return 0;
}
static void SWIG_Pike_SetModule(swig_module_info *pointer) {
}
/* Convert a pointer value */
static int
SWIG_Pike_ConvertPtr(struct object *obj, void **ptr, swig_type_info *ty, int flags) {
struct program *pr;
swig_cast_info *tc;
swig_object_wrapper *obj_wrapper;
if (ty) {
pr = (struct program *) ty->clientdata;
obj_wrapper = (swig_object_wrapper *) get_storage(obj, pr);
if (obj_wrapper && obj_wrapper->type) {
tc = SWIG_TypeCheckStruct(obj_wrapper->type, ty);
if (tc) {
int newmemory = 0;
*ptr = SWIG_TypeCast(tc, obj_wrapper->self, &newmemory);
assert(!newmemory); /* newmemory handling not yet implemented */
return 0;
}
}
}
return -1;
}
/* Create a new pointer object */
static struct object *
SWIG_Pike_NewPointerObj(void *ptr, swig_type_info *type, int own) {
return 0;
}

View file

@ -1,60 +0,0 @@
/* -----------------------------------------------------------------------------
* std_string.i
*
* SWIG typemaps for std::string
* ----------------------------------------------------------------------------- */
%{
#include <string>
%}
namespace std {
%naturalvar string;
class string;
/* Overloading check */
%typemap(typecheck) string = char *;
%typemap(typecheck) const string & = char *;
%typemap(in, pikedesc="tStr") string {
if ($input.type != T_STRING)
Pike_error("Bad argument: Expected a string.\n");
$1.assign(STR0($input.u.string));
}
%typemap(in, pikedesc="tStr") const string & ($*1_ltype temp) {
if ($input.type != T_STRING)
Pike_error("Bad argument: Expected a string.\n");
temp.assign(STR0($input.u.string));
$1 = &temp;
}
%typemap(out, pikedesc="tStr") string "push_text($1.c_str());";
%typemap(out, pikedesc="tStr") const string & "push_text($1->c_str());";
%typemap(directorin) string, const string &, string & "$1.c_str()";
%typemap(directorin) string *, const string * "$1->c_str()";
%typemap(directorout) string {
if ($input.type == T_STRING)
$result.assign(STR0($input.u.string));
else
throw Swig::DirectorTypeMismatchException("string expected");
}
%typemap(directorout) const string & ($*1_ltype temp) {
if ($input.type == T_STRING) {
temp.assign(STR0($input.u.string));
$result = &temp;
} else {
throw Swig::DirectorTypeMismatchException("string expected");
}
}
}