Initial commit

This commit is contained in:
Bassem Girgis
2018-12-20 17:34:07 -06:00
parent 7a2d899662
commit 81b4b9e273
34743 changed files with 5940233 additions and 0 deletions

View File

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

View File

@@ -0,0 +1,13 @@
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.

View File

@@ -0,0 +1,37 @@
/* 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");
}
}

View File

@@ -0,0 +1,13 @@
/* 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);

View File

@@ -0,0 +1,11 @@
/* File : example.i */
%module example
%{
#include "example.h"
%}
/* Let's just grab the original header file here */
%include "example.h"

View File

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