diff --git a/CHANGES.current b/CHANGES.current index 13d76ef04..928e0befd 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2021-05-13: olly + [Pike] #2009 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. + 2021-05-13: olly [Modula3] #2009 Remove code for Modula3. We dropped support for it in SWIG 4.0.0 and nobody has stepped forward to revive it in over 2 diff --git a/Doc/Manual/Pike.html b/Doc/Manual/Pike.html deleted file mode 100644 index 2b8432399..000000000 --- a/Doc/Manual/Pike.html +++ /dev/null @@ -1,246 +0,0 @@ - - - -SWIG and Pike - - - - - -

37 SWIG and Pike

- -
- -
- - - - -

-This chapter describes SWIG support for Pike. As of this writing, the -SWIG Pike module is still under development and is not considered -ready for prime time. The Pike module is being developed against the -Pike 7.4.10 release and may not be compatible with previous versions -of Pike. -

- -

-This chapter covers most SWIG features, but certain low-level details -are covered in less depth than in earlier chapters. At the very -least, make sure you read the "SWIG Basics" -chapter.
-

- -

37.1 Preliminaries

- - -

37.1.1 Running SWIG

- - -

-Suppose that you defined a SWIG module such as the following: -

- -
-
%module example

%{
#include "example.h"
%}

int fact(int n);
-
- -

-To build a C extension module for Pike, run SWIG using the -pike option : -

- -
-
$ swig -pike example.i
-
- -

-If you're building a C++ extension, be sure to add the -c++ option: -

- -
-
$ swig -c++ -pike example.i
-
- -

-This creates a single source file named example_wrap.c (or example_wrap.cxx, if you -ran SWIG with the -c++ option). -The SWIG-generated source file contains the low-level wrappers that need -to be compiled and linked with the rest of your C/C++ application to -create an extension module. -

- -

-The name of the wrapper file is derived from the name of the input -file. For example, if the input file is example.i, the name -of the wrapper file is example_wrap.c. To change this, you -can use the -o option: -

- -
-
$ swig -pike -o pseudonym.c example.i
-
-

37.1.2 Getting the right header files

- - -

-In order to compile the C/C++ wrappers, the compiler needs to know the -path to the Pike header files. These files are usually contained in a -directory such as -

- -
-
/usr/local/pike/7.4.10/include/pike
-
- -

-There doesn't seem to be any way to get Pike itself to reveal the -location of these files, so you may need to hunt around for them. -You're looking for files with the names global.h, program.h -and so on. -

- -

37.1.3 Using your module

- - -

-To use your module, simply use Pike's import statement: -

- -
-$ pike
-Pike v7.4 release 10 running Hilfe v3.5 (Incremental Pike Frontend)
-> import example;
-> fact(4);
-(1) Result: 24
-
- -

37.2 Basic C/C++ Mapping

- - -

37.2.1 Modules

- - -

-All of the code for a given SWIG module is wrapped into a single Pike -module. Since the name of the shared library that implements your -module ultimately determines the module's name (as far as Pike is -concerned), SWIG's %module directive doesn't really have any -significance. -

- -

37.2.2 Functions

- - -

-Global functions are wrapped as new Pike built-in functions. For -example, -

- -
-%module example
-
-int fact(int n);
-
- -

-creates a new built-in function example.fact(n) that works -exactly as you'd expect it to: -

- -
-> import example;
-> fact(4);
-(1) Result: 24
-
- -

37.2.3 Global variables

- - -

-Global variables are currently wrapped as a pair of functions, one to get -the current value of the variable and another to set it. For example, the -declaration -

- -
-%module example
-
-double Foo;
-
- -

-will result in two functions, Foo_get() and Foo_set(): -

- -
-> import example;
-> Foo_get();
-(1) Result: 3.000000
-> Foo_set(3.14159);
-(2) Result: 0
-> Foo_get();
-(3) Result: 3.141590
-
- -

37.2.4 Constants and enumerated types

- - -

-Enumerated types in C/C++ declarations are wrapped as Pike constants, -not as Pike enums. -

- -

37.2.5 Constructors and Destructors

- - -

-Constructors are wrapped as create() methods, and destructors are -wrapped as destroy() methods, for Pike classes. -

- -

37.2.6 Static Members

- - -

-Since Pike doesn't support static methods or data for Pike classes, static -member functions in your C++ classes are wrapped as regular functions and -static member variables are wrapped as pairs of functions (one to get the -value of the static member variable, and another to set it). The names of -these functions are prepended with the name of the class. -For example, given this C++ class declaration: -

- -
-class Shape
-{
-public:
-  static void print();
-  static int nshapes;
-};
-
- -

-SWIG will generate a Shape_print() method that invokes the static -Shape::print() member function, as well as a pair of methods, -Shape_nshapes_get() and Shape_nshapes_set(), to get and set -the value of Shape::nshapes. -

- - - diff --git a/Examples/pike/check.list b/Examples/pike/check.list deleted file mode 100644 index d6c8e2e7b..000000000 --- a/Examples/pike/check.list +++ /dev/null @@ -1,7 +0,0 @@ -# see top-level Makefile.in -class -constants -enum -overload -simple -template diff --git a/Examples/pike/class/Makefile b/Examples/pike/class/Makefile deleted file mode 100644 index e5319dbe2..000000000 --- a/Examples/pike/class/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -CXXSRCS = example.cxx -TARGET = example -INTERFACE = example.i -LIBS = -lm - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp - -static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_clean diff --git a/Examples/pike/class/example.cxx b/Examples/pike/class/example.cxx deleted file mode 100644 index 046304519..000000000 --- a/Examples/pike/class/example.cxx +++ /dev/null @@ -1,28 +0,0 @@ -/* File : example.cxx */ - -#include "example.h" -#define M_PI 3.14159265358979323846 - -/* Move the shape to a new location */ -void Shape::move(double dx, double dy) { - x += dx; - y += dy; -} - -int Shape::nshapes = 0; - -double Circle::area() { - return M_PI*radius*radius; -} - -double Circle::perimeter() { - return 2*M_PI*radius; -} - -double Square::area() { - return width*width; -} - -double Square::perimeter() { - return 4*width; -} diff --git a/Examples/pike/class/example.h b/Examples/pike/class/example.h deleted file mode 100644 index 0dff185b2..000000000 --- a/Examples/pike/class/example.h +++ /dev/null @@ -1,34 +0,0 @@ -/* File : example.h */ - -class Shape { -public: - Shape() { - nshapes++; - } - virtual ~Shape() { - nshapes--; - } - double x, y; - void move(double dx, double dy); - virtual double area() = 0; - virtual double perimeter() = 0; - static int nshapes; -}; - -class Circle : public Shape { -private: - double radius; -public: - Circle(double r) : radius(r) { } - virtual double area(); - virtual double perimeter(); -}; - -class Square : public Shape { -private: - double width; -public: - Square(double w) : width(w) { } - virtual double area(); - virtual double perimeter(); -}; diff --git a/Examples/pike/class/example.i b/Examples/pike/class/example.i deleted file mode 100644 index fbdf7249f..000000000 --- a/Examples/pike/class/example.i +++ /dev/null @@ -1,9 +0,0 @@ -/* File : example.i */ -%module example - -%{ -#include "example.h" -%} - -/* Let's just grab the original header file here */ -%include "example.h" diff --git a/Examples/pike/class/runme.pike b/Examples/pike/class/runme.pike deleted file mode 100644 index a6377600e..000000000 --- a/Examples/pike/class/runme.pike +++ /dev/null @@ -1,53 +0,0 @@ -import .example; - -int main() -{ - // ----- Object creation ----- - - write("Creating some objects:\n"); - Circle c = Circle(10.0); - write(" Created circle.\n"); - Square s = Square(10.0); - write(" Created square.\n"); - - // ----- Access a static member ----- - - write("\nA total of " + Shape_nshapes_get() + " shapes were created\n"); - - // ----- Member data access ----- - - // Set the location of the object - - c->x_set(20.0); - c->y_set(30.0); - - s->x_set(-10.0); - s->y_set(5.0); - - write("\nHere is their current position:\n"); - write(" Circle = (%f, %f)\n", c->x_get(), c->y_get()); - write(" Square = (%f, %f)\n", s->x_get(), s->y_get()); - - // ----- Call some methods ----- - - write("\nHere are some properties of the shapes:\n"); - write(" The circle:\n"); - write(" area = %f.\n", c->area()); - write(" perimeter = %f.\n", c->perimeter()); - write(" The square:\n"); - write(" area = %f.\n", s->area()); - write(" perimeter = %f.\n", s->perimeter()); - - write("\nGuess I'll clean up now\n"); - - /* See if we can force 's' to be garbage-collected */ - s = 0; - - /* Now we should be down to only 1 shape */ - write("%d shapes remain\n", Shape_nshapes_get()); - - /* Done */ - write("Goodbye\n"); - - return 0; -} diff --git a/Examples/pike/constants/Makefile b/Examples/pike/constants/Makefile deleted file mode 100644 index 45da7d269..000000000 --- a/Examples/pike/constants/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -SRCS = -TARGET = example -INTERFACE = example.i - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike - -static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - TARGET='mypike' INTERFACE='$(INTERFACE)' pike_static - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_clean diff --git a/Examples/pike/constants/example.i b/Examples/pike/constants/example.i deleted file mode 100644 index 4f7b1a4d7..000000000 --- a/Examples/pike/constants/example.i +++ /dev/null @@ -1,27 +0,0 @@ -/* File : example.i */ -%module example - -/* A few preprocessor macros */ - -#define ICONST 42 -#define FCONST 2.1828 -#define CCONST 'x' -#define CCONST2 '\n' -#define SCONST "Hello World" -#define SCONST2 "\"Hello World\"" - -/* This should work just fine */ -#define EXPR ICONST + 3*(FCONST) - -/* This shouldn't do anything */ -#define EXTERN extern - -/* Neither should this (BAR isn't defined) */ -#define FOO (ICONST + BAR) - -/* The following directives also produce constants */ - -%constant int iconst = 37; -%constant double fconst = 3.14; - - diff --git a/Examples/pike/constants/runme.pike b/Examples/pike/constants/runme.pike deleted file mode 100644 index a8d9f944f..000000000 --- a/Examples/pike/constants/runme.pike +++ /dev/null @@ -1,24 +0,0 @@ -int main() -{ - write("ICONST = %d (should be 42)\n", .example.ICONST); - write("FCONST = %f (should be 2.1828)\n", .example.FCONST); - write("CCONST = %c (should be 'x')\n", .example.CCONST); - write("CCONST2 = %c (this should be on a new line)\n", .example.CCONST2); - write("SCONST = %s (should be 'Hello World')\n", .example.SCONST); - write("SCONST2 = %s (should be '\"Hello World\"')\n", .example.SCONST2); - write("EXPR = %f (should be 48.5484)\n", .example.EXPR); - write("iconst = %d (should be 37)\n", .example.iconst); - write("fconst = %f (should be 3.14)\n", .example.fconst); - - if (search(indices(.example), "EXTERN") == -1) - write("EXTERN isn't defined (good)\n"); - else - write("EXTERN is defined (bad)\n"); - - if (search(indices(.example), "FOO") == -1) - write("FOO isn't defined (good)\n"); - else - write("FOO is defined (bad)\n"); - - return 0; -} diff --git a/Examples/pike/enum/Makefile b/Examples/pike/enum/Makefile deleted file mode 100644 index e5319dbe2..000000000 --- a/Examples/pike/enum/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -CXXSRCS = example.cxx -TARGET = example -INTERFACE = example.i -LIBS = -lm - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp - -static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_clean diff --git a/Examples/pike/enum/README b/Examples/pike/enum/README deleted file mode 100644 index 055aa9fce..000000000 --- a/Examples/pike/enum/README +++ /dev/null @@ -1,13 +0,0 @@ -This example will not compile with Pike versions 7.4.20 unless you first -patch the Pike sources. The problem is for line 91 of Pike's "stralloc.h" -(usually installed as /usr/local/pike/7.4.10/include/pike/stralloc.h). That -line reads: - - tmp.ptr=ptr; - -but should be patched to read: - - tmp.ptr=(p_wchar0 *) ptr; - -This bug has been reported to the Pike developers. - diff --git a/Examples/pike/enum/example.cxx b/Examples/pike/enum/example.cxx deleted file mode 100644 index 6785e57ac..000000000 --- a/Examples/pike/enum/example.cxx +++ /dev/null @@ -1,37 +0,0 @@ -/* File : example.c */ - -#include "example.h" -#include - -void Foo::enum_test(speed s) { - if (s == IMPULSE) { - printf("IMPULSE speed\n"); - } else if (s == WARP) { - printf("WARP speed\n"); - } else if (s == LUDICROUS) { - printf("LUDICROUS speed\n"); - } else { - printf("Unknown speed\n"); - } -} - -void enum_test(color c, Foo::speed s) { - if (c == RED) { - printf("color = RED, "); - } else if (c == BLUE) { - printf("color = BLUE, "); - } else if (c == GREEN) { - printf("color = GREEN, "); - } else { - printf("color = Unknown color!, "); - } - if (s == Foo::IMPULSE) { - printf("speed = IMPULSE speed\n"); - } else if (s == Foo::WARP) { - printf("speed = WARP speed\n"); - } else if (s == Foo::LUDICROUS) { - printf("speed = LUDICROUS speed\n"); - } else { - printf("speed = Unknown speed!\n"); - } -} diff --git a/Examples/pike/enum/example.h b/Examples/pike/enum/example.h deleted file mode 100644 index 525d62afc..000000000 --- a/Examples/pike/enum/example.h +++ /dev/null @@ -1,13 +0,0 @@ -/* File : example.h */ - -enum color { RED, BLUE, GREEN }; - -class Foo { - public: - Foo() { } - enum speed { IMPULSE, WARP, LUDICROUS }; - void enum_test(speed s); -}; - -void enum_test(color c, Foo::speed s); - diff --git a/Examples/pike/enum/example.i b/Examples/pike/enum/example.i deleted file mode 100644 index 23ee8a822..000000000 --- a/Examples/pike/enum/example.i +++ /dev/null @@ -1,11 +0,0 @@ -/* File : example.i */ -%module example - -%{ -#include "example.h" -%} - -/* Let's just grab the original header file here */ - -%include "example.h" - diff --git a/Examples/pike/enum/runme.pike b/Examples/pike/enum/runme.pike deleted file mode 100644 index 4846356b3..000000000 --- a/Examples/pike/enum/runme.pike +++ /dev/null @@ -1,28 +0,0 @@ -int main() -{ - write("*** color ***\n"); - write(" RED = " + .example.RED + "\n"); - write(" BLUE = " + .example.BLUE + "\n"); - write(" GREEN = " + .example.GREEN + "\n"); - - write("\n*** Foo::speed ***\n"); - write(" Foo_IMPULSE = " + .example.Foo.IMPULSE + "\n"); - write(" Foo_WARP = " + .example.Foo.WARP + "\n"); - write(" Foo_LUDICROUS = " + .example.Foo.LUDICROUS + "\n"); - - write("\nTesting use of enums with functions\n\n"); - - .example.enum_test(.example.RED, .example.Foo.IMPULSE); - .example.enum_test(.example.BLUE, .example.Foo.WARP); - .example.enum_test(.example.GREEN, .example.Foo.LUDICROUS); - .example.enum_test(1234, 5678); - - write("\nTesting use of enum with class method\n"); - .example.Foo f = .example.Foo(); - - f->enum_test(.example.Foo.IMPULSE); - f->enum_test(.example.Foo.WARP); - f->enum_test(.example.Foo.LUDICROUS); - - return 0; -} diff --git a/Examples/pike/overload/Makefile b/Examples/pike/overload/Makefile deleted file mode 100644 index 5e5fe669b..000000000 --- a/Examples/pike/overload/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -CXXSRCS = example.cxx -TARGET = example -INTERFACE = example.i -LIBS = -lstdc++ -lm - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp - -static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_clean diff --git a/Examples/pike/overload/example.cxx b/Examples/pike/overload/example.cxx deleted file mode 100644 index 3760fdd49..000000000 --- a/Examples/pike/overload/example.cxx +++ /dev/null @@ -1,115 +0,0 @@ -#include - -#include "example.h" - -// Overloaded constructors for class Bar -Bar::Bar() { - std::cout << "Called Bar::Bar()" << std::endl; -} - -Bar::Bar(const Bar&) { - std::cout << "Called Bar::Bar(const Bar&)" << std::endl; -} - -Bar::Bar(double x) { - std::cout << "Called Bar::Bar(double) with x = " << x << std::endl; -} - -Bar::Bar(double x, char *y) { - std::cout << "Called Bar::Bar(double, char *) with x, y = " << x << ", \"" << y << "\"" << std::endl; -} - -Bar::Bar(int x, int y) { - std::cout << "Called Bar::Bar(int, int) with x, y = " << x << ", " << y << std::endl; -} - -Bar::Bar(char *x) { - std::cout << "Called Bar::Bar(char *) with x = \"" << x << "\"" << std::endl; -} - -Bar::Bar(int x) { - std::cout << "Called Bar::Bar(int) with x = " << x << std::endl; -} - -Bar::Bar(long x) { - std::cout << "Called Bar::Bar(long) with x = " << x << std::endl; -} - -Bar::Bar(Bar *x) { - std::cout << "Called Bar::Bar(Bar *) with x = " << x << std::endl; -} - -// Overloaded member functions -void Bar::foo(const Bar& x) { - std::cout << "Called Bar::foo(const Bar&) with &x = " << &x << std::endl; -} - -void Bar::foo(double x) { - std::cout << "Called Bar::foo(double) with x = " << x << std::endl; -} - -void Bar::foo(double x, char *y) { - std::cout << "Called Bar::foo(double, char *) with x, y = " << x << ", \"" << y << "\"" << std::endl; -} - -void Bar::foo(int x, int y) { - std::cout << "Called Bar::foo(int, int) with x, y = " << x << ", " << y << std::endl; -} - -void Bar::foo(char *x) { - std::cout << "Called Bar::foo(char *) with x = \"" << x << "\"" << std::endl; -} - -void Bar::foo(int x) { - std::cout << "Called Bar::foo(int) with x = " << x << std::endl; -} - -void Bar::foo(long x) { - std::cout << "Called Bar::foo(long) with x = " << x << std::endl; -} - -void Bar::foo(Bar *x) { - std::cout << "Called Bar::foo(Bar *) with x = " << x << std::endl; -} - -void Bar::spam(int x, int y, int z) { - std::cout << "Called Bar::spam(int, int, int) with x, y, z = " << x << ", " << y << ", " << z << std::endl; -} - -void Bar::spam(double x, int y, int z) { - std::cout << "Called Bar::spam(double, int, int) with x, y, z = " << x << ", " << y << ", " << z << std::endl; -} - -// Overloaded global methods -void foo(const Bar& x) { - std::cout << "Called foo(const Bar& x) with &x = " << &x << std::endl; -} - -void foo(double x) { - std::cout << "Called foo(double) with x = " << x << std::endl; -} - -void foo(double x, char *y) { - std::cout << "Called foo(double, char *) with x, y = " << x << ", \"" << y << "\"" << std::endl; -} - -void foo(int x, int y) { - std::cout << "Called foo(int, int) with x, y = " << x << ", " << y << std::endl; -} - -void foo(char *x) { - std::cout << "Called foo(char *) with x = \"" << x << "\"" << std::endl; -} - -void foo(int x) { - std::cout << "Called foo(int) with x = " << x << std::endl; -} - -void foo(long x) { - std::cout << "Called foo(long) with x = " << x << std::endl; -} - -void foo(Bar *x) { - std::cout << "Called foo(Bar *) with x = " << x << std::endl; -} - diff --git a/Examples/pike/overload/example.h b/Examples/pike/overload/example.h deleted file mode 100644 index e47a122ee..000000000 --- a/Examples/pike/overload/example.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef EXAMPLE_H -#define EXAMPLE_H - -class Bar { -public: - Bar(); - Bar(const Bar&); - Bar(double); - Bar(double, char *); - Bar(int, int); - Bar(char *); - Bar(long); - Bar(int); - Bar(Bar *); - - void foo(const Bar&); - void foo(double); - void foo(double, char *); - void foo(int, int); - void foo(char *); - void foo(long); - void foo(int); - void foo(Bar *); - - void spam(int x, int y=2, int z=3); - void spam(double x, int y=2, int z=3); -}; - -void foo(const Bar&); -void foo(double); -void foo(double, char *); -void foo(int, int); -void foo(char *); -void foo(int); -void foo(long); -void foo(Bar *); - -void spam(int x, int y=2, int z=3); -void spam(double x, int y=2, int z=3); - -#endif diff --git a/Examples/pike/overload/example.i b/Examples/pike/overload/example.i deleted file mode 100644 index ddcd006be..000000000 --- a/Examples/pike/overload/example.i +++ /dev/null @@ -1,28 +0,0 @@ -/* File : example.i */ -%module example - -%{ -#include "example.h" -%} - -/** - * These overloaded declarations conflict with other overloads (as far as - * SWIG's Ruby module's implementation for overloaded methods is concerned). - * One option is use the %rename directive to rename the conflicting methods; - * here, we're just using %ignore to avoid wrapping some of the overloaded - * functions altogether. - */ - -%ignore Bar; - -%ignore Bar::Bar(Bar *); -%ignore Bar::Bar(long); - -%ignore Bar::foo(const Bar&); -%ignore Bar::foo(long); - -%ignore ::foo(const Bar&); -%ignore ::foo(int); - -/* Let's just grab the original header file here */ -%include "example.h" diff --git a/Examples/pike/overload/runme.pike b/Examples/pike/overload/runme.pike deleted file mode 100644 index d30e947b3..000000000 --- a/Examples/pike/overload/runme.pike +++ /dev/null @@ -1,83 +0,0 @@ -// import .example; - -int main() -{ - // This should invoke foo(double) - .example.foo(3.14159); - - // This should invoke foo(double, char *) - .example.foo(3.14159, "Pi"); - - // This should invoke foo(int, int) - .example.foo(3, 4); - - // This should invoke foo(char *) - .example.foo("This is a test"); - - // This should invoke foo(long) - .example.foo(42); - - /* - // This should invoke Bar::Bar() followed by foo(Bar *) - foo(Bar.new); - - // Skip a line - write("\n"); - - // This should invoke Bar::Bar(double) - Bar.new(3.14159); - - // This should invoke Bar::Bar(double, char *) - Bar.new(3.14159, "Pi"); - - // This should invoke Bar::Bar(int, int) - Bar.new(3, 4); - - // This should invoke Bar::Bar(char *) - Bar.new("This is a test"); - - // This should invoke Bar::Bar(int) - Bar.new(42); - - // This should invoke Bar::Bar() for the input argument, - // followed by Bar::Bar(const Bar&). - Bar.new(Bar.new); - - // Skip a line - write("\n"); - */ - - // Construct a new Bar instance (invokes Bar::Bar()) - /* - bar = Bar.new; - - // This should invoke Bar::foo(double) - bar.foo(3.14159); - - // This should invoke Bar::foo(double, char *) - bar.foo(3.14159, "Pi"); - - // This should invoke Bar::foo(int, int) - bar.foo(3, 4); - - // This should invoke Bar::foo(char *) - bar.foo("This is a test"); - - // This should invoke Bar::foo(int) - bar.foo(42); - - // This should invoke Bar::Bar() to construct the input - // argument, followed by Bar::foo(Bar *). - bar.foo(Example::Bar.new); - - // This should invoke Bar::spam(int x, int y, int z) - bar.spam(1); - - // This should invoke Bar::spam(double x, int y, int z) - bar.spam(3.14159); - */ - - write("Goodbye\n"); - - return 0; -} diff --git a/Examples/pike/simple/Makefile b/Examples/pike/simple/Makefile deleted file mode 100644 index 8b49b4ea5..000000000 --- a/Examples/pike/simple/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -SRCS = example.c -TARGET = example -INTERFACE = example.i - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike - -static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - TARGET='mypike' INTERFACE='$(INTERFACE)' pike_static - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_clean diff --git a/Examples/pike/simple/example.c b/Examples/pike/simple/example.c deleted file mode 100644 index 1c2af789c..000000000 --- a/Examples/pike/simple/example.c +++ /dev/null @@ -1,18 +0,0 @@ -/* File : example.c */ - -/* A global variable */ -double Foo = 3.0; - -/* Compute the greatest common divisor of positive integers */ -int gcd(int x, int y) { - int g; - g = y; - while (x > 0) { - g = x; - x = y % x; - y = g; - } - return g; -} - - diff --git a/Examples/pike/simple/example.i b/Examples/pike/simple/example.i deleted file mode 100644 index 24093b9bf..000000000 --- a/Examples/pike/simple/example.i +++ /dev/null @@ -1,7 +0,0 @@ -/* File : example.i */ -%module example - -%inline %{ -extern int gcd(int x, int y); -extern double Foo; -%} diff --git a/Examples/pike/simple/runme.pike b/Examples/pike/simple/runme.pike deleted file mode 100644 index a6a78e9e7..000000000 --- a/Examples/pike/simple/runme.pike +++ /dev/null @@ -1,20 +0,0 @@ -int main() -{ - /* Call our gcd() function */ - int x = 42; - int y = 105; - int g = .example.gcd(x, y); - write("The gcd of %d and %d is %d\n", x, y, g); - - /* Manipulate the Foo global variable */ - /* Output its current value */ - write("Foo = %f\n", .example->Foo_get()); - - /* Change its value */ - .example->Foo_set(3.1415926); - - /* See if the change took effect */ - write("Foo = %f\n", .example->Foo_get()); - - return 0; -} diff --git a/Examples/pike/template/Makefile b/Examples/pike/template/Makefile deleted file mode 100644 index 513dc3b4b..000000000 --- a/Examples/pike/template/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -CXXSRCS = -TARGET = example -INTERFACE = example.i -LIBS = -lm -SWIGOPT = - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp - -static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - SWIGOPT='$(SWIGOPT)' TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_clean diff --git a/Examples/pike/template/example.h b/Examples/pike/template/example.h deleted file mode 100644 index 7401df650..000000000 --- a/Examples/pike/template/example.h +++ /dev/null @@ -1,32 +0,0 @@ -/* File : example.h */ - -// Some template definitions - -template T max(T a, T b) { return a>b ? a : b; } - -template class vector { - T *v; - int sz; - public: - vector(int _sz) { - v = new T[_sz]; - sz = _sz; - } - T &get(int index) { - return v[index]; - } - void set(int index, T &val) { - v[index] = val; - } -#ifdef SWIG - %extend { - T getitem(int index) { - return $self->get(index); - } - void setitem(int index, T val) { - $self->set(index,val); - } - } -#endif -}; - diff --git a/Examples/pike/template/example.i b/Examples/pike/template/example.i deleted file mode 100644 index 8f94c4da1..000000000 --- a/Examples/pike/template/example.i +++ /dev/null @@ -1,17 +0,0 @@ -/* File : example.i */ -%module example - -%{ -#include "example.h" -%} - -/* Let's just grab the original header file here */ -%include "example.h" - -/* Now instantiate some specific template declarations */ - -%template(maxint) max; -%template(maxdouble) max; -%template(vecint) vector; -%template(vecdouble) vector; - diff --git a/Examples/pike/template/runme.pike b/Examples/pike/template/runme.pike deleted file mode 100644 index 36825c3e3..000000000 --- a/Examples/pike/template/runme.pike +++ /dev/null @@ -1,33 +0,0 @@ -int main() -{ - // Call some templated functions - write(sprintf("%d\n", .example.maxint(3, 7))); - write(sprintf("%f\n", .example.maxdouble(3.14, 2.18))); - - // Create some objects - .example.vecint iv = .example.vecint(100); - .example.vecdouble dv = .example.vecdouble(1000); - - for (int i = 0; i < 100; i++) { - iv->setitem(i, 2*i); - } - - for (int i = 0; i < 1000; i++) { - dv->setitem(i, 1.0/(i+1)); - } - - int isum = 0; - for (int i = 0; i < 100; i++) { - isum += iv->getitem(i); - } - - write(sprintf("%d\n", isum)); - - float fsum = 0.0; - for (int i = 0; i < 1000; i++) { - fsum += dv->getitem(i); - } - write(sprintf("%f\n", fsum)); - - return 0; -} diff --git a/Examples/test-suite/pike/Makefile.in b/Examples/test-suite/pike/Makefile.in deleted file mode 100644 index 6e1bdfbff..000000000 --- a/Examples/test-suite/pike/Makefile.in +++ /dev/null @@ -1,49 +0,0 @@ -####################################################################### -# Makefile for Pike test-suite -####################################################################### - -LANGUAGE = pike -PIKE = pike -SCRIPTSUFFIX = _runme.pike - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -top_builddir = @top_builddir@ - -include $(srcdir)/../common.mk - -# Overridden variables here -# none! - -# Custom tests - tests with additional commandline options -# none! - -# Rules for the different types of tests -%.cpptest: - $(setup) - +$(swig_and_compile_cpp) - $(run_testcase) - -%.ctest: - $(setup) - +$(swig_and_compile_c) - $(run_testcase) - -%.multicpptest: - $(setup) - +$(swig_and_compile_multi_cpp) - $(run_testcase) - -# Runs the testcase. A testcase is only run if -# a file is found which has _runme.pike appended after the testcase name. -run_testcase = \ - if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PIKE) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ - fi - -# Clean: remove the generated .pike file -%.clean: - @rm -f $*.pike; - -clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' pike_clean diff --git a/Lib/pike/pike.swg b/Lib/pike/pike.swg deleted file mode 100644 index a36bf3ad2..000000000 --- a/Lib/pike/pike.swg +++ /dev/null @@ -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 -#include -#include -#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 diff --git a/Lib/pike/pikekw.swg b/Lib/pike/pikekw.swg deleted file mode 100644 index 844b1f189..000000000 --- a/Lib/pike/pikekw.swg +++ /dev/null @@ -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_ diff --git a/Lib/pike/pikerun.swg b/Lib/pike/pikerun.swg deleted file mode 100644 index 6ec1143cf..000000000 --- a/Lib/pike/pikerun.swg +++ /dev/null @@ -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 - -/* 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; -} diff --git a/Lib/pike/std_string.i b/Lib/pike/std_string.i deleted file mode 100644 index b32b3c112..000000000 --- a/Lib/pike/std_string.i +++ /dev/null @@ -1,60 +0,0 @@ -/* ----------------------------------------------------------------------------- - * std_string.i - * - * SWIG typemaps for std::string - * ----------------------------------------------------------------------------- */ - -%{ -#include -%} - -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"); - } - } - -} - diff --git a/Source/Modules/pike.cxx b/Source/Modules/pike.cxx deleted file mode 100644 index c8cd08718..000000000 --- a/Source/Modules/pike.cxx +++ /dev/null @@ -1,892 +0,0 @@ -/* ----------------------------------------------------------------------------- - * This file is part of SWIG, which is licensed as a whole under version 3 - * (or any later version) of the GNU General Public License. Some additional - * terms also apply to certain portions of SWIG. The full details of the SWIG - * license and copyrights can be found in the LICENSE and COPYRIGHT files - * included with the SWIG source code as distributed by the SWIG developers - * and at http://www.swig.org/legal.html. - * - * pike.cxx - * - * Pike language module for SWIG. - * ----------------------------------------------------------------------------- */ - -/* - * Notes: - * - * - The current approach used for "out" typemaps is inconsistent with - * how "out" typemaps are handled by other language modules. Instead - * of converting the C/C++ type ($1) to a Pike object type (e.g. a - * struct svalue), we're just calling the appropriate push_XXX - * (e.g. push_int) to push the return value onto the stack. - * - * - Pike classes can't have static member functions or data, so we need - * to find some other appropriate mapping for C++ static member functions - * and data. - * - * - Pike doesn't seem to provide any default way to print the memory - * address, etc. for extension objects. Should we do something here? - * - */ - -#include "swigmod.h" - -#include // for isalnum() - -static const char *usage = "\ -Pike Options (available with -pike)\n\ - [no additional options]\n\ -\n"; - -class PIKE:public Language { -private: - - File *f_begin; - File *f_runtime; - File *f_header; - File *f_wrappers; - File *f_init; - File *f_classInit; - - String *PrefixPlusUnderscore; - int current; - - // Wrap modes - enum { - NO_CPP, - MEMBER_FUNC, - CONSTRUCTOR, - DESTRUCTOR, - MEMBER_VAR, - CLASS_CONST, - STATIC_FUNC, - STATIC_VAR - }; - -public: - - /* --------------------------------------------------------------------- - * PIKE() - * - * Initialize member data - * --------------------------------------------------------------------- */ - - PIKE() { - f_begin = 0; - f_runtime = 0; - f_header = 0; - f_wrappers = 0; - f_init = 0; - f_classInit = 0; - PrefixPlusUnderscore = 0; - current = NO_CPP; - } - - /* --------------------------------------------------------------------- - * main() - * - * Parse command line options and initializes variables. - * --------------------------------------------------------------------- */ - - virtual void main(int argc, char *argv[]) { - - /* Set location of SWIG library */ - SWIG_library_directory("pike"); - - /* Look for certain command line options */ - for (int i = 1; i < argc; i++) { - if (argv[i]) { - if (strcmp(argv[i], "-help") == 0) { - fputs(usage, stdout); - } - } - } - - /* Add a symbol to the parser for conditional compilation */ - Preprocessor_define("SWIGPIKE 1", 0); - - /* Set language-specific configuration file */ - SWIG_config_file("pike.swg"); - - /* Set typemap language */ - SWIG_typemap_lang("pike"); - - /* Enable overloaded methods support */ - allow_overloading(); - } - - /* --------------------------------------------------------------------- - * top() - * --------------------------------------------------------------------- */ - - virtual int top(Node *n) { - /* Get the module name */ - String *module = Getattr(n, "name"); - - /* Get the output file name */ - String *outfile = Getattr(n, "outfile"); - - /* Open the output file */ - f_begin = NewFile(outfile, "w", SWIG_output_files()); - if (!f_begin) { - FileErrorDisplay(outfile); - SWIG_exit(EXIT_FAILURE); - } - f_runtime = NewString(""); - f_init = NewString(""); - f_classInit = NewString(""); - f_header = NewString(""); - f_wrappers = NewString(""); - - /* Register file targets with the SWIG file handler */ - Swig_register_filebyname("header", f_header); - Swig_register_filebyname("wrapper", f_wrappers); - Swig_register_filebyname("begin", f_begin); - Swig_register_filebyname("runtime", f_runtime); - Swig_register_filebyname("init", f_init); - Swig_register_filebyname("classInit", f_classInit); - - /* Standard stuff for the SWIG runtime section */ - Swig_banner(f_begin); - - Printf(f_runtime, "\n\n#ifndef SWIGPIKE\n#define SWIGPIKE\n#endif\n\n"); - - Printf(f_header, "#define SWIG_init pike_module_init\n"); - Printf(f_header, "#define SWIG_name \"%s\"\n\n", module); - - /* Change naming scheme for constructors and destructors */ - Swig_name_register("construct", "%n%c_create"); - Swig_name_register("destroy", "%n%c_destroy"); - - /* Current wrap type */ - current = NO_CPP; - - /* Emit code for children */ - Language::top(n); - - /* Close the initialization function */ - Printf(f_init, "}\n"); - SwigType_emit_type_table(f_runtime, f_wrappers); - - /* Close all of the files */ - Dump(f_runtime, f_begin); - Dump(f_header, f_begin); - Dump(f_wrappers, f_begin); - Wrapper_pretty_print(f_init, f_begin); - - Delete(f_header); - Delete(f_wrappers); - Delete(f_init); - Delete(f_classInit); - Delete(f_runtime); - Delete(f_begin); - - /* Done */ - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * validIdentifier() - * ------------------------------------------------------------ */ - - virtual int validIdentifier(String *s) { - char *c = Char(s); - const char *c0 = c; - const char *c1 = c0 + 1; - while (*c) { - if (*c == '`' && c == c0) { - c++; - continue; - } - if ((*c == '+' || *c == '-' || *c == '*' || *c == '/') && c == c1) { - c++; - continue; - } - if (!(isalnum(*c) || (*c == '_'))) - return 0; - c++; - } - return 1; - } - - /* ------------------------------------------------------------ - * importDirective() - * ------------------------------------------------------------ */ - - virtual int importDirective(Node *n) { - String *modname = Getattr(n, "module"); - if (modname) { - Printf(f_init, "pike_require(\"%s\");\n", modname); - } - return Language::importDirective(n); - } - - /* ------------------------------------------------------------ - * strip() - * - * For names that begin with the current class prefix plus an - * underscore (e.g. "Foo_enum_test"), return the base function - * name (i.e. "enum_test"). - * ------------------------------------------------------------ */ - - String *strip(const DOHconst_String_or_char_ptr name) { - String *s = Copy(name); - if (Strncmp(name, PrefixPlusUnderscore, Len(PrefixPlusUnderscore)) != 0) { - return s; - } - Replaceall(s, PrefixPlusUnderscore, ""); - return s; - } - - /* ------------------------------------------------------------ - * add_method() - * ------------------------------------------------------------ */ - - void add_method(const DOHconst_String_or_char_ptr name, const DOHconst_String_or_char_ptr function, const DOHconst_String_or_char_ptr description) { - String *rename = NULL; - switch (current) { - case NO_CPP: - rename = NewString(name); - Printf(f_init, "ADD_FUNCTION(\"%s\", %s, tFunc(%s), 0);\n", rename, function, description); - break; - case STATIC_FUNC: - case STATIC_VAR: - rename = NewString(name); - Printf(f_init, "ADD_FUNCTION(\"%s\", %s, tFunc(%s), 0);\n", rename, function, description); - break; - case CONSTRUCTOR: - case DESTRUCTOR: - case MEMBER_FUNC: - case MEMBER_VAR: - rename = strip(name); - Printf(f_classInit, "ADD_FUNCTION(\"%s\", %s, tFunc(%s), 0);\n", rename, function, description); - break; - case CLASS_CONST: // shouldn't have gotten here for CLASS_CONST nodes - default: // what is this? - assert(false); - } - Delete(rename); - } - - /* --------------------------------------------------------------------- - * functionWrapper() - * - * Create a function declaration and register it with the interpreter. - * --------------------------------------------------------------------- */ - - virtual int functionWrapper(Node *n) { - - String *name = Getattr(n, "name"); - String *iname = Getattr(n, "sym:name"); - SwigType *d = Getattr(n, "type"); - ParmList *l = Getattr(n, "parms"); - - Parm *p; - String *tm; - int i; - - String *overname = 0; - if (Getattr(n, "sym:overloaded")) { - overname = Getattr(n, "sym:overname"); - } else { - if (!addSymbol(iname, n)) - return SWIG_ERROR; - } - - Wrapper *f = NewWrapper(); - - // Emit all of the local variables for holding arguments. - emit_parameter_variables(l, f); - - /* Attach the standard typemaps */ - emit_attach_parmmaps(l, f); - Setattr(n, "wrap:parms", l); - - /* Get number of required and total arguments */ - int num_arguments = emit_num_arguments(l); - int varargs = emit_isvarargs(l); - - /* Which input argument to start with? */ - int start = (current == MEMBER_FUNC || current == MEMBER_VAR || current == DESTRUCTOR) ? 1 : 0; - - /* Offset to skip over the attribute name */ - // int offset = (current == MEMBER_VAR) ? 1 : 0; - int offset = 0; - - String *wname = Swig_name_wrapper(iname); - if (overname) { - Append(wname, overname); - } - Setattr(n, "wrap:name", wname); - - Printv(f->def, "static void ", wname, "(INT32 args) {", NIL); - - /* Generate code for argument marshalling */ - String *description = NewString(""); - char source[64]; - for (i = 0, p = l; i < num_arguments; i++) { - - while (checkAttribute(p, "tmap:in:numinputs", "0")) { - p = Getattr(p, "tmap:in:next"); - } - - SwigType *pt = Getattr(p, "type"); - String *ln = Getattr(p, "lname"); - - if (i < start) { - String *lstr = SwigType_lstr(pt, 0); - Printf(f->code, "%s = (%s) THIS;\n", ln, lstr); - Delete(lstr); - } else { - /* Look for an input typemap */ - sprintf(source, "Pike_sp[%d-args]", i - start + offset); - if ((tm = Getattr(p, "tmap:in"))) { - Replaceall(tm, "$input", source); - Setattr(p, "emit:input", source); - Printf(f->code, "%s\n", tm); - String *pikedesc = Getattr(p, "tmap:in:pikedesc"); - if (pikedesc) { - Printv(description, pikedesc, " ", NIL); - } - p = Getattr(p, "tmap:in:next"); - continue; - } else { - Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); - break; - } - } - p = nextSibling(p); - } - - /* Check for trailing varargs */ - if (varargs) { - if (p && (tm = Getattr(p, "tmap:in"))) { - Replaceall(tm, "$input", "varargs"); - Printv(f->code, tm, "\n", NIL); - } - } - - /* Insert constraint checking code */ - for (p = l; p;) { - if ((tm = Getattr(p, "tmap:check"))) { - Printv(f->code, tm, "\n", NIL); - p = Getattr(p, "tmap:check:next"); - } else { - p = nextSibling(p); - } - } - - /* Insert cleanup code */ - String *cleanup = NewString(""); - for (p = l; p;) { - if ((tm = Getattr(p, "tmap:freearg"))) { - Printv(cleanup, tm, "\n", NIL); - p = Getattr(p, "tmap:freearg:next"); - } else { - p = nextSibling(p); - } - } - - /* Insert argument output code */ - String *outarg = NewString(""); - for (p = l; p;) { - if ((tm = Getattr(p, "tmap:argout"))) { - Replaceall(tm, "$arg", Getattr(p, "emit:input")); - Replaceall(tm, "$input", Getattr(p, "emit:input")); - Printv(outarg, tm, "\n", NIL); - p = Getattr(p, "tmap:argout:next"); - } else { - p = nextSibling(p); - } - } - - /* Emit the function call */ - String *actioncode = emit_action(n); - - /* Clear the return stack */ - Printf(actioncode, "pop_n_elems(args);\n"); - - /* Return the function value */ - if (current == CONSTRUCTOR) { - Printv(actioncode, "THIS = (void *) ", Swig_cresult_name(), ";\n", NIL); - Printv(description, ", tVoid", NIL); - } else if (current == DESTRUCTOR) { - Printv(description, ", tVoid", NIL); - } else { - Printv(description, ", ", NIL); - if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { - actioncode = 0; - Replaceall(tm, "$result", "resultobj"); - if (GetFlag(n, "feature:new")) { - Replaceall(tm, "$owner", "1"); - } else { - Replaceall(tm, "$owner", "0"); - } - String *pikedesc = Getattr(n, "tmap:out:pikedesc"); - if (pikedesc) { - Printv(description, pikedesc, NIL); - } - Printf(f->code, "%s\n", tm); - } else { - Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(d, 0), name); - } - } - if (actioncode) { - Append(f->code, actioncode); - Delete(actioncode); - } - emit_return_variable(n, d, f); - - /* Output argument output code */ - Printv(f->code, outarg, NIL); - - /* Output cleanup code */ - Printv(f->code, cleanup, NIL); - - /* Look to see if there is any newfree cleanup code */ - if (GetFlag(n, "feature:new")) { - if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { - Printf(f->code, "%s\n", tm); - } - } - - /* See if there is any return cleanup code */ - if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { - Printf(f->code, "%s\n", tm); - } - - /* Close the function */ - Printf(f->code, "}\n"); - - /* Substitute the cleanup code */ - Replaceall(f->code, "$cleanup", cleanup); - - /* Substitute the function name */ - Replaceall(f->code, "$symname", iname); - Replaceall(f->code, "$result", "resultobj"); - - /* Dump the function out */ - Wrapper_print(f, f_wrappers); - - /* Now register the function with the interpreter. */ - if (!Getattr(n, "sym:overloaded")) { - add_method(iname, wname, description); - } else { - if (!Getattr(n, "sym:nextSibling")) { - dispatchFunction(n); - } - } - - Delete(cleanup); - Delete(outarg); - Delete(description); - Delete(wname); - DelWrapper(f); - - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * dispatchFunction() - * - * Emit overloading dispatch function - * ------------------------------------------------------------ */ - - void dispatchFunction(Node *n) { - /* Last node in overloaded chain */ - - int maxargs; - String *tmp = NewString(""); - String *dispatch = Swig_overload_dispatch(n, "%s(args); return;", &maxargs); - - /* Generate a dispatch wrapper for all overloaded functions */ - - Wrapper *f = NewWrapper(); - String *symname = Getattr(n, "sym:name"); - String *wname = Swig_name_wrapper(symname); - - Printf(f->def, "static void %s(INT32 args) {", wname); - - Wrapper_add_local(f, "argc", "INT32 argc"); - Printf(tmp, "struct svalue argv[%d]", maxargs); - Wrapper_add_local(f, "argv", tmp); - Wrapper_add_local(f, "ii", "INT32 ii"); - - Printf(f->code, "argc = args;\n"); - Printf(f->code, "for (ii = 0; (ii < argc) && (ii < %d); ii++) {\n", maxargs); - Printf(f->code, "argv[ii] = Pike_sp[ii-args];\n"); - Printf(f->code, "}\n"); - - Replaceall(dispatch, "$args", "self, args"); - Printv(f->code, dispatch, "\n", NIL); - Printf(f->code, "Pike_error(\"No matching function for overloaded '%s'.\");\n", symname); - Printv(f->code, "}\n", NIL); - - Wrapper_print(f, f_wrappers); - - String *description = NewString(""); - Printf(description, "tAny,"); - if (current == CONSTRUCTOR || current == DESTRUCTOR) { - Printf(description, " tVoid"); - } else { - String *pd = Getattr(n, "tmap:out:pikedesc"); - if (pd) - Printf(description, " %s", pd); - } - add_method(symname, wname, description); - Delete(description); - - DelWrapper(f); - Delete(dispatch); - Delete(tmp); - Delete(wname); - } - - /* ------------------------------------------------------------ - * variableWrapper() - * ------------------------------------------------------------ */ - - virtual int variableWrapper(Node *n) { - return Language::variableWrapper(n); - } - - /* ------------------------------------------------------------ - * constantWrapper() - * ------------------------------------------------------------ */ - - virtual int constantWrapper(Node *n) { - - Swig_require("constantWrapper", n, "*sym:name", "type", "value", NIL); - - String *symname = Getattr(n, "sym:name"); - SwigType *type = Getattr(n, "type"); - String *value = Getattr(n, "value"); - bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0); - - if (SwigType_type(type) == T_MPOINTER) { - /* Special hook for member pointer */ - String *wname = Swig_name_wrapper(symname); - Printf(f_header, "static %s = %s;\n", SwigType_str(type, wname), value); - value = wname; - } else if (SwigType_type(type) == T_CHAR && is_enum_item) { - type = NewSwigType(T_INT); - Setattr(n, "type", type); - } - - /* Perform constant typemap substitution */ - String *tm = Swig_typemap_lookup("constant", n, value, 0); - if (tm) { - Replaceall(tm, "$symname", symname); - Replaceall(tm, "$value", value); - Printf(f_init, "%s\n", tm); - } else { - Swig_warning(WARN_TYPEMAP_CONST_UNDEF, input_file, line_number, "Unsupported constant value %s = %s\n", SwigType_str(type, 0), value); - } - - Swig_restore(n); - - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * nativeWrapper() - * ------------------------------------------------------------ */ - - virtual int nativeWrapper(Node *n) { - // return Language::nativeWrapper(n); - String *name = Getattr(n, "sym:name"); - String *wrapname = Getattr(n, "wrap:name"); - - if (!addSymbol(wrapname, n)) - return SWIG_ERROR; - - add_method(name, wrapname, 0); - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * enumDeclaration() - * ------------------------------------------------------------ */ - - virtual int enumDeclaration(Node *n) { - return Language::enumDeclaration(n); - } - - /* ------------------------------------------------------------ - * enumvalueDeclaration() - * ------------------------------------------------------------ */ - - virtual int enumvalueDeclaration(Node *n) { - return Language::enumvalueDeclaration(n); - } - - /* ------------------------------------------------------------ - * classDeclaration() - * ------------------------------------------------------------ */ - - virtual int classDeclaration(Node *n) { - return Language::classDeclaration(n); - } - - /* ------------------------------------------------------------ - * classHandler() - * ------------------------------------------------------------ */ - - virtual int classHandler(Node *n) { - - String *symname = Getattr(n, "sym:name"); - if (!addSymbol(symname, n)) - return SWIG_ERROR; - - PrefixPlusUnderscore = NewStringf("%s_", getClassPrefix()); - - Printf(f_classInit, "start_new_program();\n"); - - /* Handle inheritance */ - List *baselist = Getattr(n, "bases"); - if (baselist && Len(baselist) > 0) { - Iterator base = First(baselist); - while (base.item) { - String *basename = Getattr(base.item, "name"); - SwigType *basetype = NewString(basename); - SwigType_add_pointer(basetype); - SwigType_remember(basetype); - String *basemangle = SwigType_manglestr(basetype); - Printf(f_classInit, "low_inherit((struct program *) SWIGTYPE%s->clientdata, 0, 0, 0, 0, 0);\n", basemangle); - Delete(basemangle); - Delete(basetype); - base = Next(base); - } - } else { - Printf(f_classInit, "ADD_STORAGE(swig_object_wrapper);\n"); - } - - Language::classHandler(n); - - /* Accessors for member variables */ - /* - List *membervariables = Getattr(n,"membervariables"); - if (membervariables && Len(membervariables) > 0) { - membervariableAccessors(membervariables); - } - */ - - /* Done, close the class and dump its definition to the init function */ - Printf(f_classInit, "add_program_constant(\"%s\", pr = end_program(), 0);\n", symname); - Dump(f_classInit, f_init); - Clear(f_classInit); - - SwigType *tt = NewString(symname); - SwigType_add_pointer(tt); - SwigType_remember(tt); - String *tm = SwigType_manglestr(tt); - Printf(f_init, "SWIG_TypeClientData(SWIGTYPE%s, (void *) pr);\n", tm); - Delete(tm); - Delete(tt); - - Delete(PrefixPlusUnderscore); - PrefixPlusUnderscore = 0; - - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * memberfunctionHandler() - * - * Method for adding C++ member function - * ------------------------------------------------------------ */ - - virtual int memberfunctionHandler(Node *n) { - current = MEMBER_FUNC; - Language::memberfunctionHandler(n); - current = NO_CPP; - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * constructorHandler() - * - * Method for adding C++ member constructor - * ------------------------------------------------------------ */ - - virtual int constructorHandler(Node *n) { - current = CONSTRUCTOR; - Language::constructorHandler(n); - current = NO_CPP; - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * destructorHandler() - * ------------------------------------------------------------ */ - - virtual int destructorHandler(Node *n) { - current = DESTRUCTOR; - Language::destructorHandler(n); - current = NO_CPP; - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * membervariableAccessors() - * ------------------------------------------------------------ */ - - void membervariableAccessors(List *membervariables) { - String *name; - Iterator i; - bool need_setter; - String *funcname; - - /* If at least one of them is mutable, we need a setter */ - need_setter = false; - i = First(membervariables); - while (i.item) { - if (!GetFlag(i.item, "feature:immutable")) { - need_setter = true; - break; - } - i = Next(i); - } - - /* Create a function to set the values of the (mutable) variables */ - if (need_setter) { - Wrapper *wrapper = NewWrapper(); - String *setter = Swig_name_member(NSPACE_TODO, getClassPrefix(), "`->="); - String *wname = Swig_name_wrapper(setter); - Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL); - Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n"); - - i = First(membervariables); - while (i.item) { - if (!GetFlag(i.item, "feature:immutable")) { - name = Getattr(i.item, "name"); - funcname = Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, getClassPrefix(), name))); - Printf(wrapper->code, "if (!strcmp(name, \"%s\")) {\n", name); - Printf(wrapper->code, "%s(args);\n", funcname); - Printf(wrapper->code, "return;\n"); - Printf(wrapper->code, "}\n"); - Delete(funcname); - } - i = Next(i); - } - - /* Close the function */ - Printf(wrapper->code, "pop_n_elems(args);\n"); - Printf(wrapper->code, "}\n"); - - /* Dump wrapper code to the output file */ - Wrapper_print(wrapper, f_wrappers); - - /* Register it with Pike */ - String *description = NewString("tStr tFloat, tVoid"); - add_method("`->=", wname, description); - Delete(description); - - /* Clean up */ - Delete(wname); - Delete(setter); - DelWrapper(wrapper); - } - - /* Create a function to get the values of the (mutable) variables */ - Wrapper *wrapper = NewWrapper(); - String *getter = Swig_name_member(NSPACE_TODO, getClassPrefix(), "`->"); - String *wname = Swig_name_wrapper(getter); - Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL); - Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n"); - - i = First(membervariables); - while (i.item) { - name = Getattr(i.item, "name"); - funcname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, getClassPrefix(), name))); - Printf(wrapper->code, "if (!strcmp(name, \"%s\")) {\n", name); - Printf(wrapper->code, "%s(args);\n", funcname); - Printf(wrapper->code, "return;\n"); - Printf(wrapper->code, "}\n"); - Delete(funcname); - i = Next(i); - } - - /* Close the function */ - Printf(wrapper->code, "pop_n_elems(args);\n"); - Printf(wrapper->code, "}\n"); - - /* Dump wrapper code to the output file */ - Wrapper_print(wrapper, f_wrappers); - - /* Register it with Pike */ - String *description = NewString("tStr, tMix"); - add_method("`->", wname, description); - Delete(description); - - /* Clean up */ - Delete(wname); - Delete(getter); - DelWrapper(wrapper); - } - - /* ------------------------------------------------------------ - * membervariableHandler() - * ------------------------------------------------------------ */ - - virtual int membervariableHandler(Node *n) { - List *membervariables = Getattr(getCurrentClass(), "membervariables"); - if (!membervariables) { - membervariables = NewList(); - Setattr(getCurrentClass(), "membervariables", membervariables); - } - Append(membervariables, n); - current = MEMBER_VAR; - Language::membervariableHandler(n); - current = NO_CPP; - return SWIG_OK; - } - - /* ----------------------------------------------------------------------- - * staticmemberfunctionHandler() - * - * Wrap a static C++ function - * ---------------------------------------------------------------------- */ - - virtual int staticmemberfunctionHandler(Node *n) { - current = STATIC_FUNC; - Language::staticmemberfunctionHandler(n); - current = NO_CPP; - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * memberconstantHandler() - * - * Create a C++ constant - * ------------------------------------------------------------ */ - - virtual int memberconstantHandler(Node *n) { - current = CLASS_CONST; - constantWrapper(n); - current = NO_CPP; - return SWIG_OK; - } - - /* --------------------------------------------------------------------- - * staticmembervariableHandler() - * --------------------------------------------------------------------- */ - - virtual int staticmembervariableHandler(Node *n) { - current = STATIC_VAR; - Language::staticmembervariableHandler(n); - current = NO_CPP; - return SWIG_OK; - } -}; - -/* ----------------------------------------------------------------------------- - * swig_pike() - Instantiate module - * ----------------------------------------------------------------------------- */ - -static Language *new_swig_pike() { - return new PIKE(); -} -extern "C" Language *swig_pike(void) { - return new_swig_pike(); -} diff --git a/Tools/check-include-path.pike b/Tools/check-include-path.pike deleted file mode 100644 index 2bfb2b901..000000000 --- a/Tools/check-include-path.pike +++ /dev/null @@ -1,20 +0,0 @@ -/** - * This is a helper script to identify the proper include path - * for Pike header files. It should be run with the full path - * to the Pike executable as its single argument, e.g. - * - * pike check-include-path.pike /usr/local/bin/pike - * - * and its output should be the correct path to the header - * files, e.g. - * - * /usr/local/pike/7.2.239/include/pike - * - */ - -int main(int argc, array(string) argv) -{ - string prefix = replace(argv[1], "/bin/pike", ""); - write(prefix + "/pike/" + __MAJOR__ + "." + __MINOR__ + "." + __BUILD__ + "/include/pike"); - return 0; -}