The great merge

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4141 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2002-11-30 22:01:28 +00:00
commit 516036631c
1508 changed files with 125983 additions and 44037 deletions

View file

@ -0,0 +1,4 @@
example.o
example.so
example_wrap.cxx
example_wrap.o

View file

@ -0,0 +1,19 @@
TOP = ../..
SWIG = $(TOP)/../swig
CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
LIBS = -lstdc++ -lm
all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp
static::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static
clean::
$(MAKE) -f $(TOP)/Makefile pike_clean
check: all

View file

@ -0,0 +1,115 @@
#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;
}

View file

@ -0,0 +1,41 @@
#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

View file

@ -0,0 +1,28 @@
/* 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"

View file

@ -0,0 +1,83 @@
// 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;
}