[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:
parent
12f3a85916
commit
11bb422bd3
37 changed files with 5 additions and 2534 deletions
|
|
@ -1,7 +0,0 @@
|
|||
# see top-level Makefile.in
|
||||
class
|
||||
constants
|
||||
enum
|
||||
overload
|
||||
simple
|
||||
template
|
||||
|
|
@ -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
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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();
|
||||
};
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
/* Let's just grab the original header file here */
|
||||
%include "example.h"
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -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;
|
||||
|
||||
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -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.
|
||||
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
/* File : example.c */
|
||||
|
||||
#include "example.h"
|
||||
#include <stdio.h>
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
/* Let's just grab the original header file here */
|
||||
|
||||
%include "example.h"
|
||||
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
#include <iostream>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
|
|
@ -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
|
||||
|
|
@ -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"
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
%inline %{
|
||||
extern int gcd(int x, int y);
|
||||
extern double Foo;
|
||||
%}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
/* File : example.h */
|
||||
|
||||
// Some template definitions
|
||||
|
||||
template<class T> T max(T a, T b) { return a>b ? a : b; }
|
||||
|
||||
template<class T> 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
|
||||
};
|
||||
|
||||
|
|
@ -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<int>;
|
||||
%template(maxdouble) max<double>;
|
||||
%template(vecint) vector<int>;
|
||||
%template(vecdouble) vector<double>;
|
||||
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue