Merged from trunk
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12656 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
954256979c
557 changed files with 27074 additions and 5555 deletions
|
|
@ -69,7 +69,7 @@ IOBJS = $(IWRAP:.i=.@OBJEXT@)
|
|||
CPP_DLLIBS = #-L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \
|
||||
-L/usr/local/lib -lg++ -lstdc++ -lgcc
|
||||
|
||||
# Solaris workshop 5.0
|
||||
# Solaris workshop 5.0
|
||||
# CPP_DLLIBS = -L/opt/SUNWspro/lib -lCrun
|
||||
|
||||
# Symbols used for using shared libraries
|
||||
|
|
@ -159,7 +159,7 @@ tcl_cpp: $(SRCS)
|
|||
# -----------------------------------------------------------------
|
||||
|
||||
tcl_clean:
|
||||
rm -f *_wrap* *~ .~* mytclsh@EXEEXT@
|
||||
rm -f *_wrap* *~ .~* mytclsh@EXEEXT@
|
||||
rm -f core @EXTRA_CLEAN@
|
||||
rm -f *.@OBJEXT@ *@SO@
|
||||
|
||||
|
|
@ -296,9 +296,9 @@ python_static_cpp: $(SRCS)
|
|||
$(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
|
||||
$(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET)
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# -----------------------------------------------------------------
|
||||
# Running a Python example
|
||||
# -----------------------------------------------------------------
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
ifeq (,$(PY3))
|
||||
PYSCRIPT = runme.py
|
||||
|
|
@ -313,7 +313,7 @@ python_run: $(PYSCRIPT)
|
|||
|
||||
runme3.py: runme.py
|
||||
cp $< $@
|
||||
$(PY2TO3) -w $@ >/dev/null 2>&1
|
||||
$(PY2TO3) -w $@ >/dev/null 2>&1
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Cleaning the python examples
|
||||
|
|
@ -332,7 +332,7 @@ python_clean:
|
|||
|
||||
# Make sure these locate your Octave installation
|
||||
OCTAVE_INCLUDE= $(DEFS) @OCTAVEEXT@
|
||||
OCTAVE_LIB =
|
||||
OCTAVE_LIB =
|
||||
|
||||
# Extra Octave specific dynamic linking options
|
||||
OCTAVE_DLNK = @OCTAVEDYNAMICLINKING@
|
||||
|
|
@ -548,14 +548,14 @@ mzscheme: $(SRCS)
|
|||
mzscheme_cpp: $(SRCS)
|
||||
$(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACEPATH)
|
||||
$(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS)
|
||||
$(CXXSHARED) $(CFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS)
|
||||
$(CXXSHARED) $(CFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS)
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Cleaning the mzscheme examples
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
mzscheme_clean:
|
||||
rm -f *_wrap* *~ .~*
|
||||
rm -f *_wrap* *~ .~*
|
||||
rm -f core @EXTRA_CLEAN@
|
||||
rm -f *.@OBJEXT@ *@SO@
|
||||
|
||||
|
|
@ -632,7 +632,7 @@ ocaml_static_cpp: $(SRCS)
|
|||
$(OCAMLCORE)
|
||||
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
|
||||
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
|
||||
$(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
|
||||
$(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
|
||||
$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS)
|
||||
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
|
||||
$(OCC) -g -c $(INTERFACE:%.i=%.ml)
|
||||
|
|
@ -643,13 +643,13 @@ ocaml_static_cpp: $(SRCS)
|
|||
$(INTERFACE:%.i=%.cmo) \
|
||||
$(PROGFILE:%.ml=%.cmo) \
|
||||
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
|
||||
-cclib "$(LIBS)" -cc '$(CXX)'
|
||||
-cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings'
|
||||
|
||||
ocaml_static_cpp_toplevel: $(SRCS)
|
||||
$(OCAMLCORE)
|
||||
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
|
||||
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
|
||||
$(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
|
||||
$(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
|
||||
$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS)
|
||||
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
|
||||
$(OCC) -g -c $(INTERFACE:%.i=%.ml)
|
||||
|
|
@ -657,17 +657,17 @@ ocaml_static_cpp_toplevel: $(SRCS)
|
|||
$(OCC) $(OCAMLPP) -c $(PROGFILE)
|
||||
$(NOLINK) || $(OCAMLMKTOP) \
|
||||
swig.cmo \
|
||||
-I $(OCAMLP4WHERE) camlp4o.cma swigp4.cmo \
|
||||
-I $(OCAMLP4WHERE) dynlink.cma camlp4o.cma swigp4.cmo \
|
||||
-g -ccopt -g -cclib -g -custom -o $(TARGET)_top \
|
||||
$(INTERFACE:%.i=%.cmo) \
|
||||
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
|
||||
-cclib "$(LIBS)" -cc '$(CXX)'
|
||||
-cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings'
|
||||
|
||||
ocaml_dynamic_cpp: $(SRCS)
|
||||
$(OCAMLCORE)
|
||||
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
|
||||
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
|
||||
$(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
|
||||
$(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
|
||||
$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS) -ccopt -fPIC
|
||||
$(CXXSHARED) $(CFLAGS) -o $(INTERFACE:%.i=%@SO@) \
|
||||
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
|
||||
|
|
@ -684,7 +684,7 @@ ocaml_dynamic_cpp: $(SRCS)
|
|||
$(OCC) -cclib -export-dynamic -g -ccopt -g -cclib -g -custom \
|
||||
-o $(TARGET) \
|
||||
-package dl -linkpkg \
|
||||
$(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX)'
|
||||
$(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX) -Wno-write-strings'
|
||||
|
||||
ocaml_clean:
|
||||
rm -f *_wrap* *~ .~* *.cmo *.cmi $(MLFILE) $(MLFILE)i swig.mli swig.cmi swig.ml swig.cmo swigp4.ml swigp4.cmo
|
||||
|
|
@ -781,7 +781,7 @@ PHP=@PHP@
|
|||
PHPSCRIPT ?= runme.php
|
||||
|
||||
php_run:
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off $(PHPSCRIPT)
|
||||
$(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off $(PHPSCRIPT)
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Cleaning the PHP examples
|
||||
|
|
@ -844,7 +844,7 @@ pike_cpp_static: $(SRCS)
|
|||
# -----------------------------------------------------------------
|
||||
|
||||
pike_clean:
|
||||
rm -f *_wrap* *~ .~* mypike@EXEEXT@
|
||||
rm -f *_wrap* *~ .~* mypike@EXEEXT@
|
||||
rm -f core @EXTRA_CLEAN@
|
||||
rm -f *.@OBJEXT@ *@SO@
|
||||
|
||||
|
|
@ -861,7 +861,7 @@ CHICKEN_CFLAGS = @CHICKENOPTS@
|
|||
CHICKENOPTS = -quiet
|
||||
CHICKEN_MAIN =
|
||||
|
||||
# SWIG produces $(ISRCS) (the C wrapper file)
|
||||
# SWIG produces $(ISRCS) (the C wrapper file)
|
||||
# and $(CHICKEN_GENERATED_SCHEME) (the Scheme wrapper file):
|
||||
CHICKEN_GENERATED_SCHEME = $(INTERFACE:.i=.scm)
|
||||
CHICKEN_COMPILED_SCHEME = $(INTERFACE:.i=_chicken.c)
|
||||
|
|
@ -1053,12 +1053,12 @@ lua_clean:
|
|||
|
||||
allegrocl: $(SRCS)
|
||||
$(SWIG) -allegrocl -cwrap $(SWIGOPT) $(INTERFACEPATH)
|
||||
$(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
|
||||
$(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
|
||||
$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
|
||||
|
||||
allegrocl_cpp: $(SRCS)
|
||||
$(SWIG) -c++ -allegrocl $(SWIGOPT) $(INTERFACEPATH)
|
||||
$(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
|
||||
$(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
|
||||
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
|
||||
|
||||
allegrocl_clean:
|
||||
|
|
@ -1087,12 +1087,12 @@ clisp_clean:
|
|||
|
||||
cffi: $(SRCS)
|
||||
$(SWIG) -cffi $(SWIGOPT) $(INTERFACEPATH)
|
||||
# $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
|
||||
# $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
|
||||
# $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
|
||||
|
||||
cffi_cpp: $(SRCS)
|
||||
$(SWIG) -c++ -cffi $(SWIGOPT) $(INTERFACEPATH)
|
||||
$(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
|
||||
$(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
|
||||
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
|
||||
|
||||
cffi_clean:
|
||||
|
|
@ -1106,12 +1106,12 @@ cffi_clean:
|
|||
|
||||
uffi: $(SRCS)
|
||||
$(SWIG) -uffi $(SWIGOPT) $(INTERFACEPATH)
|
||||
# $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
|
||||
# $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
|
||||
# $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
|
||||
|
||||
uffi_cpp: $(SRCS)
|
||||
$(SWIG) -c++ -uffi $(SWIGOPT) $(INTERFACEPATH)
|
||||
# $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
|
||||
# $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
|
||||
# $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
|
||||
|
||||
uffi_clean:
|
||||
|
|
@ -1255,3 +1255,69 @@ go_clean:
|
|||
rm -f *_wrap* *_gc* .~* runme
|
||||
rm -f core @EXTRA_CLEAN@
|
||||
rm -f *.@OBJEXT@ *.[568] *.a *@SO@
|
||||
|
||||
##################################################################
|
||||
##### D ######
|
||||
##################################################################
|
||||
|
||||
DLIBPREFIX = @DLIBPREFIX@
|
||||
|
||||
ifeq (,$(D_VERSION))
|
||||
D_VERSION = @DDEFAULTVERSION@
|
||||
endif
|
||||
|
||||
ifeq (2,$(D_VERSION))
|
||||
SWIGD = $(SWIG) -d -d2
|
||||
DCOMPILER = @D2COMPILER@
|
||||
else
|
||||
SWIGD = $(SWIG) -d
|
||||
DCOMPILER = @D1COMPILER@
|
||||
endif
|
||||
|
||||
ifeq (dmd,$(DCOMPILER))
|
||||
# DMD is 32bit only by now
|
||||
DCFLAGS = -m32
|
||||
endif
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Build a dynamically loadable D wrapper for a C module
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
d: $(SRCS)
|
||||
$(SWIGD) $(SWIGOPT) $(INTERFACEPATH)
|
||||
$(CC) -c $(CCSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES)
|
||||
$(LDSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(DLIBPREFIX)$(TARGET)$(SO)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Build a dynamically loadable D wrapper for a C++ module
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
d_cpp: $(SRCS)
|
||||
$(SWIGD) -c++ $(SWIGOPT) $(INTERFACEPATH)
|
||||
$(CXX) -c $(CCSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES)
|
||||
$(CXXSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(DLIBPREFIX)$(TARGET)$(SO)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Compile D files
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
# Clear the DFLAGS environment variable for the compiler call itself
|
||||
# to work around a discrepancy in argument handling between DMD and LDC.
|
||||
d_compile: $(SRCS)
|
||||
DFLAGS="" $(COMPILETOOL) $(DCOMPILER) $(DFLAGS) $(DSRCS)
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Run D example
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
d_run:
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./runme
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Clean the D examples
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
d_clean:
|
||||
rm -f *_wrap* *~ .~* runme runme.exe `find . -name \*.d | grep -v runme.d`
|
||||
rm -f core @EXTRA_CLEAN@
|
||||
rm -f *.@OBJEXT@ *@SO@
|
||||
|
|
|
|||
30
Examples/d/callback/Makefile
Normal file
30
Examples/d/callback/Makefile
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
ifeq (2,$(D_VERSION))
|
||||
WORKING_DIR = d2/
|
||||
else
|
||||
WORKING_DIR = d1/
|
||||
endif
|
||||
|
||||
TOP = ../../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx
|
||||
EXTRA_LDFLAGS = example.o example_wrap.o
|
||||
TARGET = example_wrap
|
||||
SWIGOPT =
|
||||
DSRCS = *.d
|
||||
DFLAGS = -ofrunme
|
||||
|
||||
|
||||
all:: d
|
||||
|
||||
d::
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \
|
||||
$(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
|
||||
|
||||
clean::
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile d_clean
|
||||
|
||||
check: all
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile d_run
|
||||
36
Examples/d/callback/d1/runme.d
Normal file
36
Examples/d/callback/d1/runme.d
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
module runme;
|
||||
|
||||
import tango.io.Stdout;
|
||||
import example;
|
||||
|
||||
public class DCallback : Callback {
|
||||
public override void run() {
|
||||
Stdout( "DCallback.run()" ).newline;
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
auto caller = new Caller();
|
||||
|
||||
Stdout( "Adding and calling a normal C++ callback" ).newline;
|
||||
Stdout( "----------------------------------------" ).newline;
|
||||
{
|
||||
scope auto callback = new Callback();
|
||||
caller.setCallback(callback);
|
||||
caller.call();
|
||||
caller.resetCallback();
|
||||
}
|
||||
|
||||
Stdout.newline;
|
||||
Stdout( "Adding and calling a D callback" ).newline;
|
||||
Stdout( "-------------------------------" ).newline;
|
||||
{
|
||||
scope auto callback = new DCallback();
|
||||
caller.setCallback(callback);
|
||||
caller.call();
|
||||
caller.resetCallback();
|
||||
}
|
||||
|
||||
Stdout.newline;
|
||||
Stdout( "D exit" ).newline;
|
||||
}
|
||||
36
Examples/d/callback/d2/runme.d
Normal file
36
Examples/d/callback/d2/runme.d
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
module runme;
|
||||
|
||||
import std.stdio;
|
||||
import example;
|
||||
|
||||
public class DCallback : Callback {
|
||||
public override void run() {
|
||||
writeln( "DCallback.run()" );
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
auto caller = new Caller();
|
||||
|
||||
writeln( "Adding and calling a normal C++ callback" );
|
||||
writeln( "----------------------------------------" );
|
||||
{
|
||||
scope auto callback = new Callback();
|
||||
caller.setCallback(callback);
|
||||
caller.call();
|
||||
caller.resetCallback();
|
||||
}
|
||||
|
||||
writeln();
|
||||
writeln( "Adding and calling a D callback" );
|
||||
writeln( "-------------------------------" );
|
||||
{
|
||||
scope auto callback = new DCallback();
|
||||
caller.setCallback(callback);
|
||||
caller.call();
|
||||
caller.resetCallback();
|
||||
}
|
||||
|
||||
writeln();
|
||||
writeln( "D exit" );
|
||||
}
|
||||
4
Examples/d/callback/example.cxx
Normal file
4
Examples/d/callback/example.cxx
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
/* File : example.cxx */
|
||||
|
||||
#include "example.h"
|
||||
|
||||
24
Examples/d/callback/example.h
Normal file
24
Examples/d/callback/example.h
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/* File : example.h */
|
||||
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
|
||||
class Callback {
|
||||
public:
|
||||
virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; }
|
||||
virtual void run() { std::cout << "Callback::run()" << std::endl; }
|
||||
};
|
||||
|
||||
|
||||
class Caller {
|
||||
private:
|
||||
Callback *_callback;
|
||||
public:
|
||||
Caller(): _callback(0) {}
|
||||
~Caller() { delCallback(); }
|
||||
void delCallback() { delete _callback; _callback = 0; }
|
||||
void setCallback(Callback *cb) { delCallback(); _callback = cb; }
|
||||
void resetCallback() { _callback = 0; }
|
||||
void call() { if (_callback) _callback->run(); }
|
||||
};
|
||||
|
||||
13
Examples/d/callback/example.i
Normal file
13
Examples/d/callback/example.i
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/* File : example.i */
|
||||
%module(directors="1") example
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
%include "std_string.i"
|
||||
|
||||
/* turn on director wrapping Callback */
|
||||
%feature("director") Callback;
|
||||
|
||||
%include "example.h"
|
||||
|
||||
9
Examples/d/check.list
Normal file
9
Examples/d/check.list
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# See top-level Makefile.in.
|
||||
callback
|
||||
class
|
||||
constants
|
||||
enum
|
||||
extend
|
||||
funcptr
|
||||
simple
|
||||
variables
|
||||
30
Examples/d/class/Makefile
Normal file
30
Examples/d/class/Makefile
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
ifeq (2,$(D_VERSION))
|
||||
WORKING_DIR = d2/
|
||||
else
|
||||
WORKING_DIR = d1/
|
||||
endif
|
||||
|
||||
TOP = ../../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx
|
||||
EXTRA_LDFLAGS = example.o example_wrap.o
|
||||
TARGET = example_wrap
|
||||
SWIGOPT =
|
||||
DSRCS = *.d
|
||||
DFLAGS = -ofrunme
|
||||
|
||||
|
||||
all:: d
|
||||
|
||||
d::
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \
|
||||
$(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
|
||||
|
||||
clean::
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile d_clean
|
||||
|
||||
check: all
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile d_run
|
||||
58
Examples/d/class/d1/runme.d
Normal file
58
Examples/d/class/d1/runme.d
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
// This example illustrates how C++ classes can be used from D using SWIG.
|
||||
// The D class gets mapped onto the C++ class and behaves as if it is a D class.
|
||||
module runme;
|
||||
|
||||
import tango.io.Stdout;
|
||||
import example;
|
||||
|
||||
void main() {
|
||||
// ----- Object creation -----
|
||||
|
||||
Stdout( "Creating some objects:" ).newline;
|
||||
|
||||
{
|
||||
scope Square s = new Square(10);
|
||||
scope Circle c = new Circle(10);
|
||||
|
||||
// ----- Access a static member -----
|
||||
Stdout.format( "{} shapes were created.", Shape.nshapes ).newline;
|
||||
|
||||
// ----- Member data access -----
|
||||
|
||||
// Notice how we can do this using functions specific to
|
||||
// the 'Circle' class.
|
||||
c.x = 20;
|
||||
c.y = 30;
|
||||
|
||||
// Now use the same functions in the base class
|
||||
Shape shape = s;
|
||||
shape.x = -10;
|
||||
shape.y = 5;
|
||||
|
||||
Stdout( "\nHere is their current position:" ).newline;
|
||||
Stdout.format( " Circle = ( {}, {} )", c.x, c.y ).newline;
|
||||
Stdout.format( " Square = ( {}, {} )", s.x, s.y ).newline;
|
||||
|
||||
// ----- Call some methods -----
|
||||
|
||||
Stdout( "\nHere are some properties of the shapes:" ).newline;
|
||||
Shape[] shapes = [ cast(Shape) c, cast(Shape) s ];
|
||||
foreach ( currentShape; shapes )
|
||||
{
|
||||
Stdout.format( " {}", currentShape.classinfo.name ).newline;
|
||||
Stdout.format( " area = {}", currentShape.area() ).newline;
|
||||
Stdout.format( " perimeter = {}", currentShape.perimeter() ).newline;
|
||||
}
|
||||
|
||||
// Notice how the area() and perimeter() functions really
|
||||
// invoke the appropriate virtual method on each object.
|
||||
|
||||
// ----- Delete everything -----
|
||||
Stdout( "\nGuess I'll clean up now:" ).newline;
|
||||
// Note: when this using scope is exited the D destructors are called which
|
||||
// in turn call the C++ destructors.
|
||||
}
|
||||
|
||||
Stdout.format( "{} shapes remain", Shape.nshapes ).newline;
|
||||
Stdout( "\nGoodbye!" ).newline;
|
||||
}
|
||||
58
Examples/d/class/d2/runme.d
Normal file
58
Examples/d/class/d2/runme.d
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
// This example illustrates how C++ classes can be used from D using SWIG.
|
||||
// The D class gets mapped onto the C++ class and behaves as if it is a D class.
|
||||
module runme;
|
||||
|
||||
import std.stdio;
|
||||
import example;
|
||||
|
||||
void main() {
|
||||
// ----- Object creation -----
|
||||
|
||||
writeln( "Creating some objects:" );
|
||||
|
||||
{
|
||||
scope Square s = new Square(10);
|
||||
scope Circle c = new Circle(10);
|
||||
|
||||
// ----- Access a static member -----
|
||||
writefln( "%s shapes were created.", Shape.nshapes );
|
||||
|
||||
// ----- Member data access -----
|
||||
|
||||
// Notice how we can do this using functions specific to
|
||||
// the 'Circle' class.
|
||||
c.x = 20;
|
||||
c.y = 30;
|
||||
|
||||
// Now use the same functions in the base class
|
||||
Shape shape = s;
|
||||
shape.x = -10;
|
||||
shape.y = 5;
|
||||
|
||||
writeln( "\nHere is their current position:" );
|
||||
writefln( " Circle = ( %s, %s )", c.x, c.y );
|
||||
writefln( " Square = ( %s, %s )", s.x, s.y );
|
||||
|
||||
// ----- Call some methods -----
|
||||
|
||||
writeln( "\nHere are some properties of the shapes:" );
|
||||
Shape[] shapes = [ cast(Shape) c, cast(Shape) s ];
|
||||
foreach ( currentShape; shapes )
|
||||
{
|
||||
writefln( " %s", currentShape.classinfo.name );
|
||||
writefln( " area = %s", currentShape.area() );
|
||||
writefln( " perimeter = %s", currentShape.perimeter() );
|
||||
}
|
||||
|
||||
// Notice how the area() and perimeter() functions really
|
||||
// invoke the appropriate virtual method on each object.
|
||||
|
||||
// ----- Delete everything -----
|
||||
writeln( "\nGuess I'll clean up now:" );
|
||||
// Note: when this using scope is exited the D destructors are called which
|
||||
// in turn call the C++ destructors.
|
||||
}
|
||||
|
||||
writefln( "%s shapes remain", Shape.nshapes );
|
||||
writeln( "\nGoodbye!" );
|
||||
}
|
||||
28
Examples/d/class/example.cxx
Normal file
28
Examples/d/class/example.cxx
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/* File : example.c */
|
||||
|
||||
#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(void) {
|
||||
return M_PI*radius*radius;
|
||||
}
|
||||
|
||||
double Circle::perimeter(void) {
|
||||
return 2*M_PI*radius;
|
||||
}
|
||||
|
||||
double Square::area(void) {
|
||||
return width*width;
|
||||
}
|
||||
|
||||
double Square::perimeter(void) {
|
||||
return 4*width;
|
||||
}
|
||||
34
Examples/d/class/example.h
Normal file
34
Examples/d/class/example.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* File : example.h */
|
||||
|
||||
class Shape {
|
||||
public:
|
||||
Shape() {
|
||||
nshapes++;
|
||||
}
|
||||
virtual ~Shape() {
|
||||
nshapes--;
|
||||
};
|
||||
double x, y;
|
||||
void move(double dx, double dy);
|
||||
virtual double area(void) = 0;
|
||||
virtual double perimeter(void) = 0;
|
||||
static int nshapes;
|
||||
};
|
||||
|
||||
class Circle : public Shape {
|
||||
private:
|
||||
double radius;
|
||||
public:
|
||||
Circle(double r) : radius(r) { };
|
||||
virtual double area(void);
|
||||
virtual double perimeter(void);
|
||||
};
|
||||
|
||||
class Square : public Shape {
|
||||
private:
|
||||
double width;
|
||||
public:
|
||||
Square(double w) : width(w) { };
|
||||
virtual double area(void);
|
||||
virtual double perimeter(void);
|
||||
};
|
||||
10
Examples/d/class/example.i
Normal file
10
Examples/d/class/example.i
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
/* Let's just grab the original header file here */
|
||||
%include "example.h"
|
||||
|
||||
30
Examples/d/constants/Makefile
Normal file
30
Examples/d/constants/Makefile
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
ifeq (2,$(D_VERSION))
|
||||
WORKING_DIR = d2/
|
||||
else
|
||||
WORKING_DIR = d1/
|
||||
endif
|
||||
|
||||
TOP = ../../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
EXTRA_CFLAGS = -I../ example_wrap.c
|
||||
EXTRA_LDFLAGS = example_wrap.o
|
||||
TARGET = example_wrap
|
||||
SWIGOPT =
|
||||
DSRCS = *.d
|
||||
DFLAGS = -ofrunme
|
||||
|
||||
|
||||
all:: d
|
||||
|
||||
d::
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \
|
||||
$(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
|
||||
|
||||
clean::
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile d_clean
|
||||
|
||||
check: all
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile d_run
|
||||
28
Examples/d/constants/d1/runme.d
Normal file
28
Examples/d/constants/d1/runme.d
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
module runme;
|
||||
|
||||
import tango.io.Stdout;
|
||||
static import example;
|
||||
|
||||
void main() {
|
||||
Stdout.formatln("ICONST = {} (should be 42)", example.ICONST);
|
||||
Stdout.formatln("FCONST = {} (should be 2.18)", example.FCONST);
|
||||
Stdout.formatln("CCONST = {} (should be 'x')", example.CCONST);
|
||||
Stdout.formatln("CCONST2 = {} (this should be on a new line)", example.CCONST2);
|
||||
Stdout.formatln("SCONST = {} (should be 'Hello World')", example.SCONST);
|
||||
Stdout.formatln("SCONST2 = {} (should be '\"Hello World\"')", example.SCONST2);
|
||||
Stdout.formatln("EXPR = {} (should be 48.55)", example.EXPR);
|
||||
Stdout.formatln("iconst = {} (should be 37)", example.iconst);
|
||||
Stdout.formatln("fconst = {} (should be 3.14)", example.fconst);
|
||||
|
||||
static if (is(typeof(example.EXTERN))) {
|
||||
Stdout.formatln("EXTERN should not be defined, but is: {}.", example.EXTERN );
|
||||
} else {
|
||||
Stdout.formatln("EXTERN isn't defined (good)");
|
||||
}
|
||||
|
||||
static if (is(typeof(example.FOO))) {
|
||||
Stdout.formatln("FOO should not be defined, but is: {}.", example.FOO);
|
||||
} else {
|
||||
Stdout.formatln("FOO isn't defined (good)");
|
||||
}
|
||||
}
|
||||
28
Examples/d/constants/d2/runme.d
Normal file
28
Examples/d/constants/d2/runme.d
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
module runme;
|
||||
|
||||
import std.stdio;
|
||||
static import example;
|
||||
|
||||
void main() {
|
||||
writefln("ICONST = %s (should be 42)", example.ICONST);
|
||||
writefln("FCONST = %s (should be 2.1828)", example.FCONST);
|
||||
writefln("CCONST = %s (should be 'x')", example.CCONST);
|
||||
writefln("CCONST2 = %s (this should be on a new line)", example.CCONST2);
|
||||
writefln("SCONST = %s (should be 'Hello World')", example.SCONST);
|
||||
writefln("SCONST2 = %s (should be '\"Hello World\"')", example.SCONST2);
|
||||
writefln("EXPR = %s (should be 48.5484)", example.EXPR);
|
||||
writefln("iconst = %s (should be 37)", example.iconst);
|
||||
writefln("fconst = %s (should be 3.14)", example.fconst);
|
||||
|
||||
static if (is(typeof(example.EXTERN))) {
|
||||
writefln("EXTERN should not be defined, but is: %s.", example.EXTERN );
|
||||
} else {
|
||||
writeln("EXTERN isn't defined (good)");
|
||||
}
|
||||
|
||||
static if (is(typeof(example.FOO))) {
|
||||
writefln("FOO should not be defined, but is: %s.", example.FOO);
|
||||
} else {
|
||||
writeln("FOO isn't defined (good)");
|
||||
}
|
||||
}
|
||||
23
Examples/d/constants/example.d
Normal file
23
Examples/d/constants/example.d
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 1.3.41
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing--modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
module example;
|
||||
|
||||
static import example_wrap;
|
||||
|
||||
static import tango.stdc.stringz;
|
||||
|
||||
public const int ICONST = 42;
|
||||
public const double FCONST = 2.1828;
|
||||
public const char CCONST = 'x';
|
||||
public const char CCONST2 = '\n';
|
||||
public const char[] SCONST = "Hello World";
|
||||
public const char[] SCONST2 = "\"Hello World\"";
|
||||
public const double EXPR = 42+3*(2.1828);
|
||||
public const int iconst = 37;
|
||||
public const double fconst = 3.14;
|
||||
32
Examples/d/constants/example.i
Normal file
32
Examples/d/constants/example.i
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
/* Force the generated D code to use the C constant values rather than
|
||||
retrieving them at runtime. You can also try disabling the feature and
|
||||
compare the generated code. */
|
||||
%dmanifestconst;
|
||||
|
||||
|
||||
/* 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;
|
||||
30
Examples/d/enum/Makefile
Normal file
30
Examples/d/enum/Makefile
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
ifeq (2,$(D_VERSION))
|
||||
WORKING_DIR = d2/
|
||||
else
|
||||
WORKING_DIR = d1/
|
||||
endif
|
||||
|
||||
TOP = ../../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx
|
||||
EXTRA_LDFLAGS = example.o example_wrap.o
|
||||
TARGET = example_wrap
|
||||
SWIGOPT =
|
||||
DSRCS = *.d
|
||||
DFLAGS = -ofrunme
|
||||
|
||||
|
||||
all:: d
|
||||
|
||||
d::
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \
|
||||
$(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
|
||||
|
||||
clean::
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile d_clean
|
||||
|
||||
check: all
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile d_run
|
||||
28
Examples/d/enum/d1/runme.d
Normal file
28
Examples/d/enum/d1/runme.d
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
module runme;
|
||||
|
||||
import tango.io.Stdout;
|
||||
import example;
|
||||
|
||||
void main() {
|
||||
Stdout( "Printing out some enum values:" ).newline;
|
||||
Stdout(" color:").newline;
|
||||
Stdout.formatln(" {} = {}", color.RED, cast(int)color.RED);
|
||||
Stdout.formatln(" {} = {}", color.BLUE, cast(int)color.BLUE);
|
||||
Stdout.formatln(" {} = {}", color.GREEN, cast(int)color.GREEN);
|
||||
|
||||
Stdout("\n Foo.speed:").newline;
|
||||
Stdout.formatln(" Foo.{} = {}", Foo.speed.IMPULSE, cast(int)Foo.speed.IMPULSE);
|
||||
Stdout.formatln(" Foo.{} = {}", Foo.speed.WARP, cast(int)Foo.speed.WARP);
|
||||
Stdout.formatln(" Foo.{} = {}", Foo.speed.LUDICROUS , cast(int)Foo.speed.LUDICROUS);
|
||||
|
||||
Stdout("\nTesting use of enums with functions:").newline;
|
||||
example.enum_test(color.RED, Foo.speed.IMPULSE);
|
||||
example.enum_test(color.BLUE, Foo.speed.WARP);
|
||||
example.enum_test(color.GREEN, Foo.speed.LUDICROUS);
|
||||
|
||||
Stdout( "\nTesting use of enum with class method:" ).newline;
|
||||
scope f = new Foo();
|
||||
f.enum_test(Foo.speed.IMPULSE);
|
||||
f.enum_test(Foo.speed.WARP);
|
||||
f.enum_test(Foo.speed.LUDICROUS);
|
||||
}
|
||||
28
Examples/d/enum/d2/runme.d
Normal file
28
Examples/d/enum/d2/runme.d
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
module runme;
|
||||
|
||||
import std.stdio;
|
||||
import example;
|
||||
|
||||
void main() {
|
||||
writeln( "Printing out some enum values:" );
|
||||
writeln(" color:");
|
||||
writefln(" %s = %s", color.RED, cast(int)color.RED);
|
||||
writefln(" %s = %s", color.BLUE, cast(int)color.BLUE);
|
||||
writefln(" %s = %s", color.GREEN, cast(int)color.GREEN);
|
||||
|
||||
writeln("\n Foo.speed:");
|
||||
writefln(" Foo.%s = %s", Foo.speed.IMPULSE, cast(int)Foo.speed.IMPULSE);
|
||||
writefln(" Foo.%s = %s", Foo.speed.WARP, cast(int)Foo.speed.WARP);
|
||||
writefln(" Foo.%s = %s", Foo.speed.LUDICROUS , cast(int)Foo.speed.LUDICROUS);
|
||||
|
||||
writeln("\nTesting use of enums with functions:");
|
||||
example.enum_test(color.RED, Foo.speed.IMPULSE);
|
||||
example.enum_test(color.BLUE, Foo.speed.WARP);
|
||||
example.enum_test(color.GREEN, Foo.speed.LUDICROUS);
|
||||
|
||||
writeln( "\nTesting use of enum with class method:" );
|
||||
scope f = new Foo();
|
||||
f.enum_test(Foo.speed.IMPULSE);
|
||||
f.enum_test(Foo.speed.WARP);
|
||||
f.enum_test(Foo.speed.LUDICROUS);
|
||||
}
|
||||
37
Examples/d/enum/example.cxx
Normal file
37
Examples/d/enum/example.cxx
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* File : example.cxx */
|
||||
|
||||
#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");
|
||||
}
|
||||
}
|
||||
13
Examples/d/enum/example.h
Normal file
13
Examples/d/enum/example.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/* File : example.h */
|
||||
|
||||
enum color { RED, BLUE, GREEN };
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
Foo() { }
|
||||
enum speed { IMPULSE=10, WARP=20, LUDICROUS=30 };
|
||||
void enum_test(speed s);
|
||||
};
|
||||
|
||||
void enum_test(color c, Foo::speed s);
|
||||
|
||||
11
Examples/d/enum/example.i
Normal file
11
Examples/d/enum/example.i
Normal 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"
|
||||
|
||||
30
Examples/d/extend/Makefile
Normal file
30
Examples/d/extend/Makefile
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
ifeq (2,$(D_VERSION))
|
||||
WORKING_DIR = d2/
|
||||
else
|
||||
WORKING_DIR = d1/
|
||||
endif
|
||||
|
||||
TOP = ../../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx
|
||||
EXTRA_LDFLAGS = example.o example_wrap.o
|
||||
TARGET = example_wrap
|
||||
SWIGOPT =
|
||||
DSRCS = *.d
|
||||
DFLAGS = -ofrunme
|
||||
|
||||
|
||||
all:: d
|
||||
|
||||
d::
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \
|
||||
$(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
|
||||
|
||||
clean::
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile d_clean
|
||||
|
||||
check: all
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile d_run
|
||||
75
Examples/d/extend/d1/runme.d
Normal file
75
Examples/d/extend/d1/runme.d
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/// This file illustrates the cross language polymorphism using directors.
|
||||
module runme;
|
||||
|
||||
import example;
|
||||
import tango.io.Stdout;
|
||||
|
||||
// CEO class, which overrides Employee.getPosition().
|
||||
class CEO : Manager {
|
||||
public:
|
||||
this( char[] name ) {
|
||||
super( name );
|
||||
}
|
||||
|
||||
override char[] getPosition() {
|
||||
return "CEO";
|
||||
}
|
||||
|
||||
// Public method to stop the SWIG proxy base class from thinking it owns the underlying C++ memory.
|
||||
void disownMemory() {
|
||||
swigCMemOwn = false;
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
// Create an instance of CEO, a class derived from the D proxy of the
|
||||
// underlying C++ class. The calls to getName() and getPosition() are standard,
|
||||
// the call to getTitle() uses the director wrappers to call CEO.getPosition().
|
||||
|
||||
auto e = new CEO( "Alice" );
|
||||
Stdout.formatln( "{} is a {}.", e.getName(), e.getPosition() );
|
||||
Stdout.formatln( "Just call her '{}'.", e.getTitle() );
|
||||
Stdout( "----------------------" ).newline;
|
||||
|
||||
{
|
||||
// Create a new EmployeeList instance. This class does not have a C++
|
||||
// director wrapper, but can be used freely with other classes that do.
|
||||
scope auto list = new EmployeeList();
|
||||
|
||||
// EmployeeList owns its items, so we must surrender ownership of objects we add.
|
||||
e.disownMemory();
|
||||
list.addEmployee(e);
|
||||
Stdout( "----------------------" ).newline;
|
||||
|
||||
// Now we access the first four items in list (three are C++ objects that
|
||||
// EmployeeList's constructor adds, the last is our CEO). The virtual
|
||||
// methods of all these instances are treated the same. For items 0, 1, and
|
||||
// 2, all methods resolve in C++. For item 3, our CEO, getTitle calls
|
||||
// getPosition which resolves in D. The call to getPosition is
|
||||
// slightly different, however, because of the overidden getPosition() call, since
|
||||
// now the object reference has been "laundered" by passing through
|
||||
// EmployeeList as an Employee*. Previously, D resolved the call
|
||||
// immediately in CEO, but now D thinks the object is an instance of
|
||||
// class Employee. So the call passes through the
|
||||
// Employee proxy class and on to the C wrappers and C++ director,
|
||||
// eventually ending up back at the D CEO implementation of getPosition().
|
||||
// The call to getTitle() for item 3 runs the C++ Employee::getTitle()
|
||||
// method, which in turn calls getPosition(). This virtual method call
|
||||
// passes down through the C++ director class to the D implementation
|
||||
// in CEO. All this routing takes place transparently.
|
||||
|
||||
Stdout( "(position, title) for items 0-3:" ).newline;
|
||||
Stdout.formatln( " {}, '{}'", list.getItem(0).getPosition(), list.getItem(0).getTitle() );
|
||||
Stdout.formatln( " {}, '{}'", list.getItem(1).getPosition(), list.getItem(1).getTitle() );
|
||||
Stdout.formatln( " {}, '{}'", list.getItem(2).getPosition(), list.getItem(2).getTitle() );
|
||||
Stdout.formatln( " {}, '{}'", list.getItem(3).getPosition(), list.getItem(3).getTitle() );
|
||||
Stdout( "----------------------" ).newline;
|
||||
|
||||
// All Employees will be destroyed when the EmployeeList goes out of scope,
|
||||
// including the CEO instance.
|
||||
}
|
||||
Stdout( "----------------------" ).newline;
|
||||
|
||||
// All done.
|
||||
Stdout( "Exiting cleanly from D code." ).newline;
|
||||
}
|
||||
75
Examples/d/extend/d2/runme.d
Normal file
75
Examples/d/extend/d2/runme.d
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/// This file illustrates the cross language polymorphism using directors.
|
||||
module runme;
|
||||
|
||||
import std.stdio;
|
||||
import example;
|
||||
|
||||
// CEO class, which overrides Employee.getPosition().
|
||||
class CEO : Manager {
|
||||
public:
|
||||
this( string name ) {
|
||||
super( name );
|
||||
}
|
||||
|
||||
override string getPosition() const {
|
||||
return "CEO";
|
||||
}
|
||||
|
||||
// Public method to stop the SWIG proxy base class from thinking it owns the underlying C++ memory.
|
||||
void disownMemory() {
|
||||
swigCMemOwn = false;
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
// Create an instance of CEO, a class derived from the D proxy of the
|
||||
// underlying C++ class. The calls to getName() and getPosition() are standard,
|
||||
// the call to getTitle() uses the director wrappers to call CEO.getPosition().
|
||||
|
||||
auto e = new CEO( "Alice" );
|
||||
writefln( "%s is a %s.", e.getName(), e.getPosition() );
|
||||
writefln( "Just call her '%s'.", e.getTitle() );
|
||||
writeln( "----------------------" );
|
||||
|
||||
{
|
||||
// Create a new EmployeeList instance. This class does not have a C++
|
||||
// director wrapper, but can be used freely with other classes that do.
|
||||
scope auto list = new EmployeeList();
|
||||
|
||||
// EmployeeList owns its items, so we must surrender ownership of objects we add.
|
||||
e.disownMemory();
|
||||
list.addEmployee(e);
|
||||
writeln( "----------------------" );
|
||||
|
||||
// Now we access the first four items in list (three are C++ objects that
|
||||
// EmployeeList's constructor adds, the last is our CEO). The virtual
|
||||
// methods of all these instances are treated the same. For items 0, 1, and
|
||||
// 2, all methods resolve in C++. For item 3, our CEO, getTitle calls
|
||||
// getPosition which resolves in D. The call to getPosition is
|
||||
// slightly different, however, because of the overidden getPosition() call, since
|
||||
// now the object reference has been "laundered" by passing through
|
||||
// EmployeeList as an Employee*. Previously, D resolved the call
|
||||
// immediately in CEO, but now D thinks the object is an instance of
|
||||
// class Employee. So the call passes through the
|
||||
// Employee proxy class and on to the C wrappers and C++ director,
|
||||
// eventually ending up back at the D CEO implementation of getPosition().
|
||||
// The call to getTitle() for item 3 runs the C++ Employee::getTitle()
|
||||
// method, which in turn calls getPosition(). This virtual method call
|
||||
// passes down through the C++ director class to the D implementation
|
||||
// in CEO. All this routing takes place transparently.
|
||||
|
||||
writeln( "(position, title) for items 0-3:" );
|
||||
writefln( " %s, '%s'", list.getItem(0).getPosition(), list.getItem(0).getTitle() );
|
||||
writefln( " %s, '%s'", list.getItem(1).getPosition(), list.getItem(1).getTitle() );
|
||||
writefln( " %s, '%s'", list.getItem(2).getPosition(), list.getItem(2).getTitle() );
|
||||
writefln( " %s, '%s'", list.getItem(3).getPosition(), list.getItem(3).getTitle() );
|
||||
writeln( "----------------------" );
|
||||
|
||||
// All Employees will be destroyed when the EmployeeList goes out of scope,
|
||||
// including the CEO instance.
|
||||
}
|
||||
writeln( "----------------------" );
|
||||
|
||||
// All done.
|
||||
writeln( "Exiting cleanly from D code." );
|
||||
}
|
||||
4
Examples/d/extend/example.cxx
Normal file
4
Examples/d/extend/example.cxx
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
/* File : example.cxx */
|
||||
|
||||
#include "example.h"
|
||||
|
||||
56
Examples/d/extend/example.h
Normal file
56
Examples/d/extend/example.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/* File : example.h */
|
||||
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
|
||||
class Employee {
|
||||
private:
|
||||
std::string name;
|
||||
public:
|
||||
Employee(const char* n): name(n) {}
|
||||
virtual std::string getTitle() { return getPosition() + " " + getName(); }
|
||||
virtual std::string getName() { return name; }
|
||||
virtual std::string getPosition() const { return "Employee"; }
|
||||
virtual ~Employee() { printf("~Employee() @ %p\n", this); }
|
||||
};
|
||||
|
||||
|
||||
class Manager: public Employee {
|
||||
public:
|
||||
Manager(const char* n): Employee(n) {}
|
||||
virtual std::string getPosition() const { return "Manager"; }
|
||||
};
|
||||
|
||||
|
||||
class EmployeeList {
|
||||
std::vector<Employee*> list;
|
||||
public:
|
||||
EmployeeList() {
|
||||
list.push_back(new Employee("Bob"));
|
||||
list.push_back(new Employee("Jane"));
|
||||
list.push_back(new Manager("Ted"));
|
||||
}
|
||||
void addEmployee(Employee *p) {
|
||||
list.push_back(p);
|
||||
std::cout << "New employee added. Current employees are:" << std::endl;
|
||||
std::vector<Employee*>::iterator i;
|
||||
for (i=list.begin(); i!=list.end(); i++) {
|
||||
std::cout << " " << (*i)->getTitle() << std::endl;
|
||||
}
|
||||
}
|
||||
const Employee *getItem(int i) {
|
||||
return list[i];
|
||||
}
|
||||
~EmployeeList() {
|
||||
std::vector<Employee*>::iterator i;
|
||||
std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl;
|
||||
for (i=list.begin(); i!=list.end(); i++) {
|
||||
delete *i;
|
||||
}
|
||||
std::cout << "~EmployeeList empty." << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
14
Examples/d/extend/example.i
Normal file
14
Examples/d/extend/example.i
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/* File : example.i */
|
||||
%module(directors="1") example
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
%include "std_string.i"
|
||||
|
||||
/* turn on director wrapping for Manager */
|
||||
%feature("director") Employee;
|
||||
%feature("director") Manager;
|
||||
|
||||
%include "example.h"
|
||||
|
||||
30
Examples/d/funcptr/Makefile
Normal file
30
Examples/d/funcptr/Makefile
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
ifeq (2,$(D_VERSION))
|
||||
WORKING_DIR = d2/
|
||||
else
|
||||
WORKING_DIR = d1/
|
||||
endif
|
||||
|
||||
TOP = ../../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
EXTRA_CFLAGS = -I../ ../example.c example_wrap.c
|
||||
EXTRA_LDFLAGS = example.o example_wrap.o
|
||||
TARGET = example_wrap
|
||||
SWIGOPT =
|
||||
DSRCS = *.d
|
||||
DFLAGS = -ofrunme
|
||||
|
||||
|
||||
all:: d
|
||||
|
||||
d::
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \
|
||||
$(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
|
||||
|
||||
clean::
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile d_clean
|
||||
|
||||
check: all
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile d_run
|
||||
42
Examples/d/funcptr/d1/runme.d
Normal file
42
Examples/d/funcptr/d1/runme.d
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
module runme;
|
||||
|
||||
import tango.io.Stdout;
|
||||
static import example;
|
||||
|
||||
extern(C) int add(int a, int b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
extern(C) int sub(int a, int b) {
|
||||
return a - b;
|
||||
}
|
||||
|
||||
extern(C) int mul(int a, int b) {
|
||||
return a * b;
|
||||
}
|
||||
|
||||
void main() {
|
||||
int a = 37;
|
||||
int b = 42;
|
||||
|
||||
Stdout( "a = " )( a ).newline;
|
||||
Stdout( "b = " )( b ).newline;
|
||||
|
||||
Stdout( "Trying some C callback functions:" ).newline;
|
||||
Stdout( " ADD(a,b) = " )( example.do_op( a, b, example.ADD ) ).newline;
|
||||
Stdout( " SUB(a,b) = " )( example.do_op( a, b, example.SUB ) ).newline;
|
||||
Stdout( " MUL(a,b) = " )( example.do_op( a, b, example.MUL ) ).newline;
|
||||
|
||||
version (LDC) {
|
||||
// Currently, there is no way to specify the calling convention for
|
||||
// function pointer parameters in D, but LDC does strict typechecking for
|
||||
// them (which is reasonable, but not covered by the language spec yet).
|
||||
// As a result, there is no way to make the code below compile with LDC at
|
||||
// the moment, so just skip it.
|
||||
} else {
|
||||
Stdout( "Now the same with callback functions defined in D:" ).newline;
|
||||
Stdout( " add(a,b) = " )( example.do_op( a, b, &add ) ).newline;
|
||||
Stdout( " sub(a,b) = " )( example.do_op( a, b, &sub ) ).newline;
|
||||
Stdout( " mul(a,b) = " )( example.do_op( a, b, &mul ) ).newline;
|
||||
}
|
||||
}
|
||||
34
Examples/d/funcptr/d2/runme.d
Normal file
34
Examples/d/funcptr/d2/runme.d
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
module runme;
|
||||
|
||||
import std.stdio;
|
||||
static import example;
|
||||
|
||||
extern(C) int add(int a, int b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
extern(C) int sub(int a, int b) {
|
||||
return a - b;
|
||||
}
|
||||
|
||||
extern(C) int mul(int a, int b) {
|
||||
return a * b;
|
||||
}
|
||||
|
||||
void main() {
|
||||
int a = 37;
|
||||
int b = 42;
|
||||
|
||||
writefln( "a = %s", a );
|
||||
writefln( "b = %s", b );
|
||||
|
||||
writeln( "Trying some C callback functions:" );
|
||||
writefln( " ADD(a,b) = %s", example.do_op( a, b, example.ADD ) );
|
||||
writefln( " SUB(a,b) = %s", example.do_op( a, b, example.SUB ) );
|
||||
writefln( " MUL(a,b) = %s", example.do_op( a, b, example.MUL ) );
|
||||
|
||||
writeln( "Now the same with callback functions defined in D:" );
|
||||
writefln( " add(a,b) = %s", example.do_op( a, b, &add ) );
|
||||
writefln( " sub(a,b) = %s", example.do_op( a, b, &sub ) );
|
||||
writefln( " mul(a,b) = %s", example.do_op( a, b, &mul ) );
|
||||
}
|
||||
19
Examples/d/funcptr/example.c
Normal file
19
Examples/d/funcptr/example.c
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/* File : example.c */
|
||||
|
||||
int do_op(int a, int b, int (*op)(int,int)) {
|
||||
return (*op)(a,b);
|
||||
}
|
||||
|
||||
int add(int a, int b) {
|
||||
return a+b;
|
||||
}
|
||||
|
||||
int sub(int a, int b) {
|
||||
return a-b;
|
||||
}
|
||||
|
||||
int mul(int a, int b) {
|
||||
return a*b;
|
||||
}
|
||||
|
||||
int (*funcvar)(int,int) = add;
|
||||
9
Examples/d/funcptr/example.h
Normal file
9
Examples/d/funcptr/example.h
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
/* file: example.h */
|
||||
|
||||
extern int do_op(int,int, int (*op)(int,int));
|
||||
extern int add(int,int);
|
||||
extern int sub(int,int);
|
||||
extern int mul(int,int);
|
||||
|
||||
extern int (*funcvar)(int,int);
|
||||
|
||||
16
Examples/d/funcptr/example.i
Normal file
16
Examples/d/funcptr/example.i
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
/* Wrap a function taking a pointer to a function */
|
||||
extern int do_op(int a, int b, int (*op)(int, int));
|
||||
|
||||
/* Now install a bunch of "ops" as constants */
|
||||
%constant int (*ADD)(int,int) = add;
|
||||
%constant int (*SUB)(int,int) = sub;
|
||||
%constant int (*MUL)(int,int) = mul;
|
||||
|
||||
extern int (*funcvar)(int,int);
|
||||
|
||||
30
Examples/d/simple/Makefile
Normal file
30
Examples/d/simple/Makefile
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
ifeq (2,$(D_VERSION))
|
||||
WORKING_DIR = d2/
|
||||
else
|
||||
WORKING_DIR = d1/
|
||||
endif
|
||||
|
||||
TOP = ../../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
EXTRA_CFLAGS = -I../ ../example.c example_wrap.c
|
||||
EXTRA_LDFLAGS = example.o example_wrap.o
|
||||
TARGET = example_wrap
|
||||
SWIGOPT =
|
||||
DSRCS = *.d
|
||||
DFLAGS = -ofrunme
|
||||
|
||||
|
||||
all:: d
|
||||
|
||||
d::
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \
|
||||
$(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
|
||||
|
||||
clean::
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile d_clean
|
||||
|
||||
check: all
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile d_run
|
||||
27
Examples/d/simple/d1/runme.d
Normal file
27
Examples/d/simple/d1/runme.d
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
module runme;
|
||||
|
||||
import tango.io.Stdout;
|
||||
static import example;
|
||||
|
||||
void main() {
|
||||
/*
|
||||
* Call our gcd() function.
|
||||
*/
|
||||
int x = 42;
|
||||
int y = 105;
|
||||
int g = example.gcd( x, y );
|
||||
Stdout.format( "The gcd of {} and {} is {}.", x, y, g ).newline;
|
||||
|
||||
/*
|
||||
* Manipulate the Foo global variable.
|
||||
*/
|
||||
|
||||
// Output its current value
|
||||
Stdout.format( "Foo = {}", example.Foo ).newline;
|
||||
|
||||
// Change its value
|
||||
example.Foo = 3.1415926;
|
||||
|
||||
// See if the change took effect
|
||||
Stdout.format( "Foo = {}", example.Foo ).newline;
|
||||
}
|
||||
27
Examples/d/simple/d2/runme.d
Normal file
27
Examples/d/simple/d2/runme.d
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
module runme;
|
||||
|
||||
import std.stdio;
|
||||
static import example;
|
||||
|
||||
void main() {
|
||||
/*
|
||||
* Call our gcd() function.
|
||||
*/
|
||||
int x = 42;
|
||||
int y = 105;
|
||||
int g = example.gcd(x, y);
|
||||
writefln("The gcd of %s and %s is %s.", x, y, g);
|
||||
|
||||
/*
|
||||
* Manipulate the Foo global variable.
|
||||
*/
|
||||
|
||||
// Output its current value
|
||||
writefln("Foo = %s", example.Foo);
|
||||
|
||||
// Change its value
|
||||
example.Foo = 3.1415926;
|
||||
|
||||
// See if the change took effect
|
||||
writefln("Foo = %s", example.Foo);
|
||||
}
|
||||
18
Examples/d/simple/example.c
Normal file
18
Examples/d/simple/example.c
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/* 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;
|
||||
}
|
||||
|
||||
|
||||
7
Examples/d/simple/example.i
Normal file
7
Examples/d/simple/example.i
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
%inline %{
|
||||
extern int gcd(int x, int y);
|
||||
extern double Foo;
|
||||
%}
|
||||
30
Examples/d/variables/Makefile
Normal file
30
Examples/d/variables/Makefile
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
ifeq (2,$(D_VERSION))
|
||||
WORKING_DIR = d2/
|
||||
else
|
||||
WORKING_DIR = d1/
|
||||
endif
|
||||
|
||||
TOP = ../../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
EXTRA_CFLAGS = -I../ ../example.c example_wrap.c
|
||||
EXTRA_LDFLAGS = example.o example_wrap.o
|
||||
TARGET = example_wrap
|
||||
SWIGOPT =
|
||||
DSRCS = *.d
|
||||
DFLAGS = -ofrunme
|
||||
|
||||
|
||||
all:: d
|
||||
|
||||
d::
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \
|
||||
$(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
|
||||
|
||||
clean::
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile d_clean
|
||||
|
||||
check: all
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile d_run
|
||||
71
Examples/d/variables/d1/runme.d
Normal file
71
Examples/d/variables/d1/runme.d
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
// This example illustrates global variable access from C#.
|
||||
module runme;
|
||||
|
||||
import tango.io.Stdout;
|
||||
static import example;
|
||||
|
||||
void main() {
|
||||
// Try to set the values of some global variables
|
||||
example.ivar = 42;
|
||||
example.svar = -31000;
|
||||
example.lvar = 65537;
|
||||
example.uivar = 123456;
|
||||
example.usvar = 61000;
|
||||
example.ulvar = 654321;
|
||||
example.scvar = -13;
|
||||
example.ucvar = 251;
|
||||
example.cvar = 'S';
|
||||
example.fvar = 3.14159f;
|
||||
example.dvar = 2.1828;
|
||||
example.strvar = "Hello World";
|
||||
example.iptrvar = example.new_int(37);
|
||||
example.ptptr = example.new_Point(37,42);
|
||||
example.name = "Bill";
|
||||
|
||||
// Now print out the values of the variables
|
||||
Stdout.formatln( "Variables (printed from D):" );
|
||||
Stdout.formatln( "ivar = {}", example.ivar );
|
||||
Stdout.formatln( "svar = {}", example.svar );
|
||||
Stdout.formatln( "lvar = {}", example.lvar );
|
||||
Stdout.formatln( "uivar = {}", example.uivar );
|
||||
Stdout.formatln( "usvar = {}", example.usvar );
|
||||
Stdout.formatln( "ulvar = {}", example.ulvar );
|
||||
Stdout.formatln( "scvar = {}", example.scvar );
|
||||
Stdout.formatln( "ucvar = {}", example.ucvar );
|
||||
Stdout.formatln( "fvar = {}", example.fvar );
|
||||
Stdout.formatln( "dvar = {}", example.dvar );
|
||||
Stdout.formatln( "cvar = {}", example.cvar );
|
||||
Stdout.formatln( "strvar = {}", example.strvar );
|
||||
Stdout.formatln( "cstrvar = {}", example.cstrvar );
|
||||
Stdout.formatln( "iptrvar = {}", example.iptrvar );
|
||||
Stdout.formatln( "name = {}", example.name );
|
||||
Stdout.formatln( "ptptr = {} {}", example.ptptr, example.Point_print(example.ptptr) );
|
||||
Stdout.formatln( "pt = {} {}", example.pt, example.Point_print(example.pt) );
|
||||
Stdout.formatln( "status = {}", example.status );
|
||||
|
||||
Stdout.formatln( "\nVariables (printed from the C library):" );
|
||||
example.print_vars();
|
||||
|
||||
Stdout.formatln( "\nNow I'm going to try and modify some read only variables:" );
|
||||
Stdout.formatln( "Checking that the read only variables are readonly..." );
|
||||
|
||||
Stdout( " 'path'..." );
|
||||
static if ( is( typeof( example.path = "a" ) ) )
|
||||
Stdout.formatln("Oh dear, this variable is not read only!");
|
||||
else
|
||||
Stdout.formatln("Good.");
|
||||
|
||||
Stdout( " 'status'..." );
|
||||
static if ( is( typeof( example.status = 2 ) ) )
|
||||
Stdout.formatln("Oh dear, this variable is not read only!");
|
||||
else
|
||||
Stdout.formatln("Good.");
|
||||
|
||||
Stdout.formatln( "\nI'm going to try and update a structure variable:" );
|
||||
|
||||
example.pt = example.ptptr;
|
||||
|
||||
Stdout( "The new value is " ).flush;
|
||||
example.pt_print();
|
||||
Stdout.formatln( "You should see the value {}", example.Point_print(example.ptptr) );
|
||||
}
|
||||
71
Examples/d/variables/d2/runme.d
Normal file
71
Examples/d/variables/d2/runme.d
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
// This example illustrates global variable access from C#.
|
||||
module runme;
|
||||
|
||||
import std.stdio;
|
||||
static import example;
|
||||
|
||||
void main() {
|
||||
// Try to set the values of some global variables
|
||||
example.ivar = 42;
|
||||
example.svar = -31000;
|
||||
example.lvar = 65537;
|
||||
example.uivar = 123456;
|
||||
example.usvar = 61000;
|
||||
example.ulvar = 654321;
|
||||
example.scvar = -13;
|
||||
example.ucvar = 251;
|
||||
example.cvar = 'S';
|
||||
example.fvar = 3.14159f;
|
||||
example.dvar = 2.1828;
|
||||
example.strvar = "Hello World";
|
||||
example.iptrvar = example.new_int(37);
|
||||
example.ptptr = example.new_Point(37,42);
|
||||
example.name = "Bill";
|
||||
|
||||
// Now print out the values of the variables
|
||||
writefln( "Variables (printed from D):" );
|
||||
writefln( "ivar = %s", example.ivar );
|
||||
writefln( "svar = %s", example.svar );
|
||||
writefln( "lvar = %s", example.lvar );
|
||||
writefln( "uivar = %s", example.uivar );
|
||||
writefln( "usvar = %s", example.usvar );
|
||||
writefln( "ulvar = %s", example.ulvar );
|
||||
writefln( "scvar = %s", example.scvar );
|
||||
writefln( "ucvar = %s", example.ucvar );
|
||||
writefln( "fvar = %s", example.fvar );
|
||||
writefln( "dvar = %s", example.dvar );
|
||||
writefln( "cvar = %s", example.cvar );
|
||||
writefln( "strvar = %s", example.strvar );
|
||||
writefln( "cstrvar = %s", example.cstrvar );
|
||||
writefln( "iptrvar = %s", example.iptrvar );
|
||||
writefln( "name = %s", example.name );
|
||||
writefln( "ptptr = %s %s", example.ptptr, example.Point_print(example.ptptr) );
|
||||
writefln( "pt = %s %s", example.pt, example.Point_print(example.pt) );
|
||||
writefln( "status = %s", example.status );
|
||||
|
||||
writefln( "\nVariables (printed from the C library):" );
|
||||
example.print_vars();
|
||||
|
||||
writefln( "\nNow I'm going to try and modify some read only variables:" );
|
||||
writefln( "Checking that the read only variables are readonly..." );
|
||||
|
||||
writeln( " 'path'..." );
|
||||
static if ( is( typeof( example.path = "a" ) ) )
|
||||
writefln("Oh dear, this variable is not read only!");
|
||||
else
|
||||
writefln("Good.");
|
||||
|
||||
writeln( " 'status'..." );
|
||||
static if ( is( typeof( example.status = 2 ) ) )
|
||||
writefln("Oh dear, this variable is not read only!");
|
||||
else
|
||||
writefln("Good.");
|
||||
|
||||
writefln( "\nI'm going to try and update a structure variable:" );
|
||||
|
||||
example.pt = example.ptptr;
|
||||
|
||||
write( "The new value is " );
|
||||
example.pt_print();
|
||||
writefln( "You should see the value %s", example.Point_print(example.ptptr) );
|
||||
}
|
||||
91
Examples/d/variables/example.c
Normal file
91
Examples/d/variables/example.c
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
/* File : example.c */
|
||||
|
||||
/* I'm a file containing some C global variables */
|
||||
|
||||
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
|
||||
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
|
||||
# define _CRT_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "example.h"
|
||||
|
||||
int ivar = 0;
|
||||
short svar = 0;
|
||||
long lvar = 0;
|
||||
unsigned int uivar = 0;
|
||||
unsigned short usvar = 0;
|
||||
unsigned long ulvar = 0;
|
||||
signed char scvar = 0;
|
||||
unsigned char ucvar = 0;
|
||||
char cvar = 0;
|
||||
float fvar = 0;
|
||||
double dvar = 0;
|
||||
char *strvar = 0;
|
||||
const char cstrvar[] = "Goodbye";
|
||||
int *iptrvar = 0;
|
||||
char name[256] = "Dave";
|
||||
char path[256] = "/home/beazley";
|
||||
|
||||
|
||||
/* Global variables involving a structure */
|
||||
Point *ptptr = 0;
|
||||
Point pt = { 10, 20 };
|
||||
|
||||
/* A variable that we will make read-only in the interface */
|
||||
int status = 1;
|
||||
|
||||
/* A debugging function to print out their values */
|
||||
|
||||
void print_vars() {
|
||||
printf("ivar = %d\n", ivar);
|
||||
printf("svar = %d\n", svar);
|
||||
printf("lvar = %ld\n", lvar);
|
||||
printf("uivar = %u\n", uivar);
|
||||
printf("usvar = %u\n", usvar);
|
||||
printf("ulvar = %lu\n", ulvar);
|
||||
printf("scvar = %d\n", scvar);
|
||||
printf("ucvar = %u\n", ucvar);
|
||||
printf("fvar = %g\n", fvar);
|
||||
printf("dvar = %g\n", dvar);
|
||||
printf("cvar = %c\n", cvar);
|
||||
printf("strvar = %s\n", strvar ? strvar : "(null)");
|
||||
printf("cstrvar = %s\n", cstrvar ? cstrvar : "(null)");
|
||||
printf("iptrvar = %p\n", iptrvar);
|
||||
printf("name = %s\n", name);
|
||||
printf("ptptr = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
|
||||
printf("pt = (%d, %d)\n", pt.x, pt.y);
|
||||
printf("status = %d\n", status);
|
||||
}
|
||||
|
||||
/* A function to create an integer (to test iptrvar) */
|
||||
|
||||
int *new_int(int value) {
|
||||
int *ip = (int *) malloc(sizeof(int));
|
||||
*ip = value;
|
||||
return ip;
|
||||
}
|
||||
|
||||
/* A function to create a point */
|
||||
|
||||
Point *new_Point(int x, int y) {
|
||||
Point *p = (Point *) malloc(sizeof(Point));
|
||||
p->x = x;
|
||||
p->y = y;
|
||||
return p;
|
||||
}
|
||||
|
||||
char * Point_print(Point *p) {
|
||||
static char buffer[256];
|
||||
if (p) {
|
||||
sprintf(buffer,"(%d, %d)", p->x,p->y);
|
||||
} else {
|
||||
sprintf(buffer,"null");
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void pt_print() {
|
||||
printf("(%d, %d)\n", pt.x, pt.y);
|
||||
}
|
||||
6
Examples/d/variables/example.h
Normal file
6
Examples/d/variables/example.h
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
/* File: example.h */
|
||||
|
||||
typedef struct {
|
||||
int x,y;
|
||||
} Point;
|
||||
|
||||
49
Examples/d/variables/example.i
Normal file
49
Examples/d/variables/example.i
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
/* Some global variable declarations */
|
||||
%inline %{
|
||||
extern int ivar;
|
||||
extern short svar;
|
||||
extern long lvar;
|
||||
extern unsigned int uivar;
|
||||
extern unsigned short usvar;
|
||||
extern unsigned long ulvar;
|
||||
extern signed char scvar;
|
||||
extern unsigned char ucvar;
|
||||
extern char cvar;
|
||||
extern float fvar;
|
||||
extern double dvar;
|
||||
extern char *strvar;
|
||||
extern const char cstrvar[];
|
||||
extern int *iptrvar;
|
||||
extern char name[256];
|
||||
|
||||
extern Point *ptptr;
|
||||
extern Point pt;
|
||||
%}
|
||||
|
||||
|
||||
/* Some read-only variables */
|
||||
|
||||
%immutable;
|
||||
|
||||
%inline %{
|
||||
extern int status;
|
||||
extern char path[256];
|
||||
%}
|
||||
|
||||
%mutable;
|
||||
|
||||
/* Some helper functions to make it easier to test */
|
||||
%inline %{
|
||||
extern void print_vars();
|
||||
extern int *new_int(int value);
|
||||
extern Point *new_Point(int x, int y);
|
||||
extern char *Point_print(Point *p);
|
||||
extern void pt_print();
|
||||
%}
|
||||
|
||||
|
|
@ -1,188 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 2.0.1
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
package example
|
||||
|
||||
|
||||
type _swig_fnptr *byte
|
||||
type _swig_memberptr *byte
|
||||
|
||||
|
||||
func _swig_allocatememory(int) *byte
|
||||
func _swig_internal_allocate(len int) *byte {
|
||||
return _swig_allocatememory(len)
|
||||
}
|
||||
|
||||
func _swig_allocatestring(*byte, int) string
|
||||
func _swig_internal_makegostring(p *byte, l int) string {
|
||||
return _swig_allocatestring(p, l)
|
||||
}
|
||||
|
||||
func _swig_internal_gopanic(p *byte, l int) {
|
||||
panic(_swig_allocatestring(p, l))
|
||||
}
|
||||
|
||||
type _swig_DirectorCallback struct {
|
||||
SwigcptrCallback
|
||||
v interface{}
|
||||
}
|
||||
|
||||
func (p *_swig_DirectorCallback) Swigcptr() uintptr {
|
||||
return p.SwigcptrCallback.Swigcptr()
|
||||
}
|
||||
|
||||
func (p *_swig_DirectorCallback) SwigIsCallback() {
|
||||
}
|
||||
|
||||
func (p *_swig_DirectorCallback) DirectorInterface() interface{} {
|
||||
return p.v
|
||||
}
|
||||
|
||||
func _swig_NewDirectorCallbackCallback(*_swig_DirectorCallback) SwigcptrCallback
|
||||
|
||||
func NewDirectorCallback(v interface{}) Callback {
|
||||
p := &_swig_DirectorCallback{0, v}
|
||||
p.SwigcptrCallback = _swig_NewDirectorCallbackCallback(p)
|
||||
return p
|
||||
}
|
||||
|
||||
func _swig_wrap_DeleteDirectorCallback(uintptr)
|
||||
|
||||
func DeleteDirectorCallback(arg1 Callback) {
|
||||
_swig_wrap_DeleteDirectorCallback(arg1.Swigcptr())
|
||||
}
|
||||
|
||||
func Swiggo_DeleteDirector_Callback(p *_swig_DirectorCallback) {
|
||||
p.SwigcptrCallback = 0
|
||||
}
|
||||
|
||||
type _swig_DirectorInterfaceCallbackRun interface {
|
||||
Run()
|
||||
}
|
||||
|
||||
func _swig_wrap__swig_DirectorCallback_upcall_Run(SwigcptrCallback)
|
||||
func (swig_p *_swig_DirectorCallback) Run() {
|
||||
if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceCallbackRun); swig_ok {
|
||||
swig_g.Run()
|
||||
return
|
||||
}
|
||||
_swig_wrap__swig_DirectorCallback_upcall_Run(swig_p.SwigcptrCallback)
|
||||
}
|
||||
|
||||
func DirectorCallbackRun(p Callback) {
|
||||
_swig_wrap__swig_DirectorCallback_upcall_Run(p.(*_swig_DirectorCallback).SwigcptrCallback)
|
||||
}
|
||||
|
||||
func Swig_DirectorCallback_callback_run(p *_swig_DirectorCallback) {
|
||||
p.Run()
|
||||
}
|
||||
|
||||
type SwigcptrCallback uintptr
|
||||
|
||||
func (p SwigcptrCallback) Swigcptr() uintptr {
|
||||
return (uintptr)(p)
|
||||
}
|
||||
|
||||
func (p SwigcptrCallback) SwigIsCallback() {
|
||||
}
|
||||
|
||||
func (p SwigcptrCallback) DirectorInterface() interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func _swig_wrap_delete_Callback(uintptr)
|
||||
|
||||
func DeleteCallback(arg1 Callback) {
|
||||
_swig_wrap_delete_Callback(arg1.Swigcptr())
|
||||
}
|
||||
|
||||
func _swig_wrap_Callback_run(SwigcptrCallback)
|
||||
|
||||
func (arg1 SwigcptrCallback) Run() {
|
||||
_swig_wrap_Callback_run(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_new_Callback() SwigcptrCallback
|
||||
|
||||
func NewCallback() Callback {
|
||||
return _swig_wrap_new_Callback()
|
||||
}
|
||||
|
||||
type Callback interface {
|
||||
Swigcptr() uintptr
|
||||
SwigIsCallback()
|
||||
DirectorInterface() interface{}
|
||||
Run()
|
||||
}
|
||||
|
||||
type SwigcptrCaller uintptr
|
||||
|
||||
func (p SwigcptrCaller) Swigcptr() uintptr {
|
||||
return (uintptr)(p)
|
||||
}
|
||||
|
||||
func (p SwigcptrCaller) SwigIsCaller() {
|
||||
}
|
||||
|
||||
func _swig_wrap_new_Caller() SwigcptrCaller
|
||||
|
||||
func NewCaller() Caller {
|
||||
return _swig_wrap_new_Caller()
|
||||
}
|
||||
|
||||
func _swig_wrap_delete_Caller(uintptr)
|
||||
|
||||
func DeleteCaller(arg1 Caller) {
|
||||
_swig_wrap_delete_Caller(arg1.Swigcptr())
|
||||
}
|
||||
|
||||
func _swig_wrap_Caller_delCallback(SwigcptrCaller)
|
||||
|
||||
func (arg1 SwigcptrCaller) DelCallback() {
|
||||
_swig_wrap_Caller_delCallback(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_Caller_setCallback(SwigcptrCaller, uintptr)
|
||||
|
||||
func (arg1 SwigcptrCaller) SetCallback(arg2 Callback) {
|
||||
_swig_wrap_Caller_setCallback(arg1, arg2.Swigcptr())
|
||||
}
|
||||
|
||||
func _swig_wrap_Caller_call(SwigcptrCaller)
|
||||
|
||||
func (arg1 SwigcptrCaller) Call() {
|
||||
_swig_wrap_Caller_call(arg1)
|
||||
}
|
||||
|
||||
type Caller interface {
|
||||
Swigcptr() uintptr
|
||||
SwigIsCaller()
|
||||
DelCallback()
|
||||
SetCallback(arg2 Callback)
|
||||
Call()
|
||||
}
|
||||
|
||||
|
||||
type SwigcptrSwigDirector_Callback uintptr
|
||||
type SwigDirector_Callback interface {
|
||||
Swigcptr() uintptr;
|
||||
}
|
||||
func (p SwigcptrSwigDirector_Callback) Swigcptr() uintptr {
|
||||
return uintptr(p)
|
||||
}
|
||||
|
||||
type SwigcptrVoid uintptr
|
||||
type Void interface {
|
||||
Swigcptr() uintptr;
|
||||
}
|
||||
func (p SwigcptrVoid) Swigcptr() uintptr {
|
||||
return uintptr(p)
|
||||
}
|
||||
|
||||
|
|
@ -1,284 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 2.0.1
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
package example
|
||||
|
||||
|
||||
type _swig_fnptr *byte
|
||||
type _swig_memberptr *byte
|
||||
|
||||
|
||||
func _swig_allocatememory(int) *byte
|
||||
func _swig_internal_allocate(len int) *byte {
|
||||
return _swig_allocatememory(len)
|
||||
}
|
||||
|
||||
func _swig_allocatestring(*byte, int) string
|
||||
func _swig_internal_makegostring(p *byte, l int) string {
|
||||
return _swig_allocatestring(p, l)
|
||||
}
|
||||
|
||||
func _swig_internal_gopanic(p *byte, l int) {
|
||||
panic(_swig_allocatestring(p, l))
|
||||
}
|
||||
|
||||
type SwigcptrShape uintptr
|
||||
|
||||
func (p SwigcptrShape) Swigcptr() uintptr {
|
||||
return (uintptr)(p)
|
||||
}
|
||||
|
||||
func (p SwigcptrShape) SwigIsShape() {
|
||||
}
|
||||
|
||||
func _swig_wrap_delete_Shape(uintptr)
|
||||
|
||||
func DeleteShape(arg1 Shape) {
|
||||
_swig_wrap_delete_Shape(arg1.Swigcptr())
|
||||
}
|
||||
|
||||
func _swig_wrap_Shape_x_set(SwigcptrShape, float64)
|
||||
|
||||
func (arg1 SwigcptrShape) SetX(arg2 float64) {
|
||||
_swig_wrap_Shape_x_set(arg1, arg2)
|
||||
}
|
||||
|
||||
func _swig_wrap_Shape_x_get(SwigcptrShape) float64
|
||||
|
||||
func (arg1 SwigcptrShape) GetX() float64 {
|
||||
return _swig_wrap_Shape_x_get(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_Shape_y_set(SwigcptrShape, float64)
|
||||
|
||||
func (arg1 SwigcptrShape) SetY(arg2 float64) {
|
||||
_swig_wrap_Shape_y_set(arg1, arg2)
|
||||
}
|
||||
|
||||
func _swig_wrap_Shape_y_get(SwigcptrShape) float64
|
||||
|
||||
func (arg1 SwigcptrShape) GetY() float64 {
|
||||
return _swig_wrap_Shape_y_get(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_Shape_move(SwigcptrShape, float64, float64)
|
||||
|
||||
func (arg1 SwigcptrShape) Move(arg2 float64, arg3 float64) {
|
||||
_swig_wrap_Shape_move(arg1, arg2, arg3)
|
||||
}
|
||||
|
||||
func _swig_wrap_Shape_area(SwigcptrShape) float64
|
||||
|
||||
func (arg1 SwigcptrShape) Area() float64 {
|
||||
return _swig_wrap_Shape_area(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_Shape_perimeter(SwigcptrShape) float64
|
||||
|
||||
func (arg1 SwigcptrShape) Perimeter() float64 {
|
||||
return _swig_wrap_Shape_perimeter(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_Shape_nshapes_set(int)
|
||||
|
||||
func SetShapeNshapes(arg1 int) {
|
||||
_swig_wrap_Shape_nshapes_set(arg1)
|
||||
}
|
||||
|
||||
func GetShapeNshapes() int
|
||||
type Shape interface {
|
||||
Swigcptr() uintptr
|
||||
SwigIsShape()
|
||||
SetX(arg2 float64)
|
||||
GetX() float64
|
||||
SetY(arg2 float64)
|
||||
GetY() float64
|
||||
Move(arg2 float64, arg3 float64)
|
||||
Area() float64
|
||||
Perimeter() float64
|
||||
}
|
||||
|
||||
type SwigcptrCircle uintptr
|
||||
|
||||
func (p SwigcptrCircle) Swigcptr() uintptr {
|
||||
return (uintptr)(p)
|
||||
}
|
||||
|
||||
func (p SwigcptrCircle) SwigIsCircle() {
|
||||
}
|
||||
|
||||
func _swig_wrap_new_Circle(float64) SwigcptrCircle
|
||||
|
||||
func NewCircle(arg1 float64) Circle {
|
||||
return _swig_wrap_new_Circle(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_Circle_area(SwigcptrCircle) float64
|
||||
|
||||
func (arg1 SwigcptrCircle) Area() float64 {
|
||||
return _swig_wrap_Circle_area(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_Circle_perimeter(SwigcptrCircle) float64
|
||||
|
||||
func (arg1 SwigcptrCircle) Perimeter() float64 {
|
||||
return _swig_wrap_Circle_perimeter(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_delete_Circle(uintptr)
|
||||
|
||||
func DeleteCircle(arg1 Circle) {
|
||||
_swig_wrap_delete_Circle(arg1.Swigcptr())
|
||||
}
|
||||
|
||||
func _swig_wrap_SetCircle_X(SwigcptrCircle, float64)
|
||||
|
||||
func (_swig_base SwigcptrCircle) SetX(arg1 float64) {
|
||||
_swig_wrap_SetCircle_X(_swig_base, arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_GetCircle_X(SwigcptrCircle) float64
|
||||
|
||||
func (_swig_base SwigcptrCircle) GetX() float64 {
|
||||
return _swig_wrap_GetCircle_X(_swig_base)
|
||||
}
|
||||
|
||||
func _swig_wrap_SetCircle_Y(SwigcptrCircle, float64)
|
||||
|
||||
func (_swig_base SwigcptrCircle) SetY(arg1 float64) {
|
||||
_swig_wrap_SetCircle_Y(_swig_base, arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_GetCircle_Y(SwigcptrCircle) float64
|
||||
|
||||
func (_swig_base SwigcptrCircle) GetY() float64 {
|
||||
return _swig_wrap_GetCircle_Y(_swig_base)
|
||||
}
|
||||
|
||||
func _swig_wrap_Circle_move(SwigcptrCircle, float64, float64)
|
||||
|
||||
func (_swig_base SwigcptrCircle) Move(arg1 float64, arg2 float64) {
|
||||
_swig_wrap_Circle_move(_swig_base, arg1, arg2)
|
||||
}
|
||||
|
||||
func (p SwigcptrCircle) SwigIsShape() {
|
||||
}
|
||||
|
||||
func (p SwigcptrCircle) SwigGetShape() Shape {
|
||||
return SwigcptrShape(p.Swigcptr())
|
||||
}
|
||||
|
||||
type Circle interface {
|
||||
Swigcptr() uintptr
|
||||
SwigIsCircle()
|
||||
Area() float64
|
||||
Perimeter() float64
|
||||
SetX(arg1 float64)
|
||||
GetX() float64
|
||||
SetY(arg1 float64)
|
||||
GetY() float64
|
||||
Move(arg1 float64, arg2 float64)
|
||||
SwigIsShape()
|
||||
SwigGetShape() Shape
|
||||
}
|
||||
|
||||
type SwigcptrSquare uintptr
|
||||
|
||||
func (p SwigcptrSquare) Swigcptr() uintptr {
|
||||
return (uintptr)(p)
|
||||
}
|
||||
|
||||
func (p SwigcptrSquare) SwigIsSquare() {
|
||||
}
|
||||
|
||||
func _swig_wrap_new_Square(float64) SwigcptrSquare
|
||||
|
||||
func NewSquare(arg1 float64) Square {
|
||||
return _swig_wrap_new_Square(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_Square_area(SwigcptrSquare) float64
|
||||
|
||||
func (arg1 SwigcptrSquare) Area() float64 {
|
||||
return _swig_wrap_Square_area(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_Square_perimeter(SwigcptrSquare) float64
|
||||
|
||||
func (arg1 SwigcptrSquare) Perimeter() float64 {
|
||||
return _swig_wrap_Square_perimeter(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_delete_Square(uintptr)
|
||||
|
||||
func DeleteSquare(arg1 Square) {
|
||||
_swig_wrap_delete_Square(arg1.Swigcptr())
|
||||
}
|
||||
|
||||
func _swig_wrap_SetSquare_X(SwigcptrSquare, float64)
|
||||
|
||||
func (_swig_base SwigcptrSquare) SetX(arg1 float64) {
|
||||
_swig_wrap_SetSquare_X(_swig_base, arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_GetSquare_X(SwigcptrSquare) float64
|
||||
|
||||
func (_swig_base SwigcptrSquare) GetX() float64 {
|
||||
return _swig_wrap_GetSquare_X(_swig_base)
|
||||
}
|
||||
|
||||
func _swig_wrap_SetSquare_Y(SwigcptrSquare, float64)
|
||||
|
||||
func (_swig_base SwigcptrSquare) SetY(arg1 float64) {
|
||||
_swig_wrap_SetSquare_Y(_swig_base, arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_GetSquare_Y(SwigcptrSquare) float64
|
||||
|
||||
func (_swig_base SwigcptrSquare) GetY() float64 {
|
||||
return _swig_wrap_GetSquare_Y(_swig_base)
|
||||
}
|
||||
|
||||
func _swig_wrap_Square_move(SwigcptrSquare, float64, float64)
|
||||
|
||||
func (_swig_base SwigcptrSquare) Move(arg1 float64, arg2 float64) {
|
||||
_swig_wrap_Square_move(_swig_base, arg1, arg2)
|
||||
}
|
||||
|
||||
func (p SwigcptrSquare) SwigIsShape() {
|
||||
}
|
||||
|
||||
func (p SwigcptrSquare) SwigGetShape() Shape {
|
||||
return SwigcptrShape(p.Swigcptr())
|
||||
}
|
||||
|
||||
type Square interface {
|
||||
Swigcptr() uintptr
|
||||
SwigIsSquare()
|
||||
Area() float64
|
||||
Perimeter() float64
|
||||
SetX(arg1 float64)
|
||||
GetX() float64
|
||||
SetY(arg1 float64)
|
||||
GetY() float64
|
||||
Move(arg1 float64, arg2 float64)
|
||||
SwigIsShape()
|
||||
SwigGetShape() Shape
|
||||
}
|
||||
|
||||
|
||||
type SwigcptrVoid uintptr
|
||||
type Void interface {
|
||||
Swigcptr() uintptr;
|
||||
}
|
||||
func (p SwigcptrVoid) Swigcptr() uintptr {
|
||||
return uintptr(p)
|
||||
}
|
||||
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 2.0.1
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
package example
|
||||
|
||||
|
||||
type _swig_fnptr *byte
|
||||
type _swig_memberptr *byte
|
||||
|
||||
|
||||
func _swig_allocatememory(int) *byte
|
||||
func _swig_internal_allocate(len int) *byte {
|
||||
return _swig_allocatememory(len)
|
||||
}
|
||||
|
||||
func _swig_allocatestring(*byte, int) string
|
||||
func _swig_internal_makegostring(p *byte, l int) string {
|
||||
return _swig_allocatestring(p, l)
|
||||
}
|
||||
|
||||
func _swig_internal_gopanic(p *byte, l int) {
|
||||
panic(_swig_allocatestring(p, l))
|
||||
}
|
||||
|
||||
const ICONST int = 42
|
||||
const FCONST float64 = 2.1828
|
||||
const CCONST byte = 'x'
|
||||
func _swig_getCCONST2() byte
|
||||
var CCONST2 byte = _swig_getCCONST2()
|
||||
const SCONST string = "Hello World"
|
||||
func _swig_getSCONST2() string
|
||||
var SCONST2 string = _swig_getSCONST2()
|
||||
func _swig_getEXPR() float64
|
||||
var EXPR float64 = _swig_getEXPR()
|
||||
const Iconst int = 37
|
||||
const Fconst float64 = 3.14
|
||||
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 2.0.1
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
package example
|
||||
|
||||
|
||||
type _swig_fnptr *byte
|
||||
type _swig_memberptr *byte
|
||||
|
||||
|
||||
func _swig_allocatememory(int) *byte
|
||||
func _swig_internal_allocate(len int) *byte {
|
||||
return _swig_allocatememory(len)
|
||||
}
|
||||
|
||||
func _swig_allocatestring(*byte, int) string
|
||||
func _swig_internal_makegostring(p *byte, l int) string {
|
||||
return _swig_allocatestring(p, l)
|
||||
}
|
||||
|
||||
func _swig_internal_gopanic(p *byte, l int) {
|
||||
panic(_swig_allocatestring(p, l))
|
||||
}
|
||||
|
||||
type Color int
|
||||
func _swig_getRED() Color
|
||||
var RED Color = _swig_getRED()
|
||||
func _swig_getBLUE() Color
|
||||
var BLUE Color = _swig_getBLUE()
|
||||
func _swig_getGREEN() Color
|
||||
var GREEN Color = _swig_getGREEN()
|
||||
type SwigcptrFoo uintptr
|
||||
|
||||
func (p SwigcptrFoo) Swigcptr() uintptr {
|
||||
return (uintptr)(p)
|
||||
}
|
||||
|
||||
func (p SwigcptrFoo) SwigIsFoo() {
|
||||
}
|
||||
|
||||
func _swig_wrap_new_Foo() SwigcptrFoo
|
||||
|
||||
func NewFoo() Foo {
|
||||
return _swig_wrap_new_Foo()
|
||||
}
|
||||
|
||||
type FooSpeed int
|
||||
func _swig_getFoo_IMPULSE_Foo() FooSpeed
|
||||
var FooIMPULSE FooSpeed = _swig_getFoo_IMPULSE_Foo()
|
||||
func _swig_getFoo_WARP_Foo() FooSpeed
|
||||
var FooWARP FooSpeed = _swig_getFoo_WARP_Foo()
|
||||
func _swig_getFoo_LUDICROUS_Foo() FooSpeed
|
||||
var FooLUDICROUS FooSpeed = _swig_getFoo_LUDICROUS_Foo()
|
||||
func _swig_wrap_Foo_enum_test(SwigcptrFoo, FooSpeed)
|
||||
|
||||
func (arg1 SwigcptrFoo) Enum_test(arg2 FooSpeed) {
|
||||
_swig_wrap_Foo_enum_test(arg1, arg2)
|
||||
}
|
||||
|
||||
func _swig_wrap_delete_Foo(uintptr)
|
||||
|
||||
func DeleteFoo(arg1 Foo) {
|
||||
_swig_wrap_delete_Foo(arg1.Swigcptr())
|
||||
}
|
||||
|
||||
type Foo interface {
|
||||
Swigcptr() uintptr
|
||||
SwigIsFoo()
|
||||
Enum_test(arg2 FooSpeed)
|
||||
}
|
||||
|
||||
func _swig_wrap_enum_test(Color, FooSpeed)
|
||||
|
||||
func Enum_test(arg1 Color, arg2 FooSpeed) {
|
||||
_swig_wrap_enum_test(arg1, arg2)
|
||||
}
|
||||
|
||||
|
||||
type SwigcptrVoid uintptr
|
||||
type Void interface {
|
||||
Swigcptr() uintptr;
|
||||
}
|
||||
func (p SwigcptrVoid) Swigcptr() uintptr {
|
||||
return uintptr(p)
|
||||
}
|
||||
|
||||
|
|
@ -1,397 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 2.0.1
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
package example
|
||||
|
||||
|
||||
type _swig_fnptr *byte
|
||||
type _swig_memberptr *byte
|
||||
|
||||
|
||||
func _swig_allocatememory(int) *byte
|
||||
func _swig_internal_allocate(len int) *byte {
|
||||
return _swig_allocatememory(len)
|
||||
}
|
||||
|
||||
func _swig_allocatestring(*byte, int) string
|
||||
func _swig_internal_makegostring(p *byte, l int) string {
|
||||
return _swig_allocatestring(p, l)
|
||||
}
|
||||
|
||||
func _swig_internal_gopanic(p *byte, l int) {
|
||||
panic(_swig_allocatestring(p, l))
|
||||
}
|
||||
|
||||
type _swig_DirectorEmployee struct {
|
||||
SwigcptrEmployee
|
||||
v interface{}
|
||||
}
|
||||
|
||||
func (p *_swig_DirectorEmployee) Swigcptr() uintptr {
|
||||
return p.SwigcptrEmployee.Swigcptr()
|
||||
}
|
||||
|
||||
func (p *_swig_DirectorEmployee) SwigIsEmployee() {
|
||||
}
|
||||
|
||||
func (p *_swig_DirectorEmployee) DirectorInterface() interface{} {
|
||||
return p.v
|
||||
}
|
||||
|
||||
func _swig_NewDirectorEmployeeEmployee(*_swig_DirectorEmployee, string) SwigcptrEmployee
|
||||
|
||||
func NewDirectorEmployee(v interface{}, arg1 string) Employee {
|
||||
p := &_swig_DirectorEmployee{0, v}
|
||||
p.SwigcptrEmployee = _swig_NewDirectorEmployeeEmployee(p, arg1)
|
||||
return p
|
||||
}
|
||||
|
||||
type _swig_DirectorInterfaceEmployeeGetTitle interface {
|
||||
GetTitle() string
|
||||
}
|
||||
|
||||
func _swig_wrap__swig_DirectorEmployee_upcall_GetTitle(SwigcptrEmployee) string
|
||||
func (swig_p *_swig_DirectorEmployee) GetTitle() string {
|
||||
if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceEmployeeGetTitle); swig_ok {
|
||||
return swig_g.GetTitle()
|
||||
}
|
||||
return _swig_wrap__swig_DirectorEmployee_upcall_GetTitle(swig_p.SwigcptrEmployee)
|
||||
}
|
||||
|
||||
func DirectorEmployeeGetTitle(p Employee) string {
|
||||
return _swig_wrap__swig_DirectorEmployee_upcall_GetTitle(p.(*_swig_DirectorEmployee).SwigcptrEmployee)
|
||||
}
|
||||
|
||||
func Swig_DirectorEmployee_callback_getTitle(p *_swig_DirectorEmployee) (swig_result string) {
|
||||
return p.GetTitle()
|
||||
}
|
||||
|
||||
type _swig_DirectorInterfaceEmployeeGetName interface {
|
||||
GetName() string
|
||||
}
|
||||
|
||||
func _swig_wrap__swig_DirectorEmployee_upcall_GetName(SwigcptrEmployee) string
|
||||
func (swig_p *_swig_DirectorEmployee) GetName() string {
|
||||
if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceEmployeeGetName); swig_ok {
|
||||
return swig_g.GetName()
|
||||
}
|
||||
return _swig_wrap__swig_DirectorEmployee_upcall_GetName(swig_p.SwigcptrEmployee)
|
||||
}
|
||||
|
||||
func DirectorEmployeeGetName(p Employee) string {
|
||||
return _swig_wrap__swig_DirectorEmployee_upcall_GetName(p.(*_swig_DirectorEmployee).SwigcptrEmployee)
|
||||
}
|
||||
|
||||
func Swig_DirectorEmployee_callback_getName(p *_swig_DirectorEmployee) (swig_result string) {
|
||||
return p.GetName()
|
||||
}
|
||||
|
||||
type _swig_DirectorInterfaceEmployeeGetPosition interface {
|
||||
GetPosition() string
|
||||
}
|
||||
|
||||
func _swig_wrap__swig_DirectorEmployee_upcall_GetPosition(SwigcptrEmployee) string
|
||||
func (swig_p *_swig_DirectorEmployee) GetPosition() string {
|
||||
if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceEmployeeGetPosition); swig_ok {
|
||||
return swig_g.GetPosition()
|
||||
}
|
||||
return _swig_wrap__swig_DirectorEmployee_upcall_GetPosition(swig_p.SwigcptrEmployee)
|
||||
}
|
||||
|
||||
func DirectorEmployeeGetPosition(p Employee) string {
|
||||
return _swig_wrap__swig_DirectorEmployee_upcall_GetPosition(p.(*_swig_DirectorEmployee).SwigcptrEmployee)
|
||||
}
|
||||
|
||||
func Swig_DirectorEmployee_callback_getPosition(p *_swig_DirectorEmployee) (swig_result string) {
|
||||
return p.GetPosition()
|
||||
}
|
||||
|
||||
func _swig_wrap_DeleteDirectorEmployee(uintptr)
|
||||
|
||||
func DeleteDirectorEmployee(arg1 Employee) {
|
||||
_swig_wrap_DeleteDirectorEmployee(arg1.Swigcptr())
|
||||
}
|
||||
|
||||
func Swiggo_DeleteDirector_Employee(p *_swig_DirectorEmployee) {
|
||||
p.SwigcptrEmployee = 0
|
||||
}
|
||||
|
||||
type SwigcptrEmployee uintptr
|
||||
|
||||
func (p SwigcptrEmployee) Swigcptr() uintptr {
|
||||
return (uintptr)(p)
|
||||
}
|
||||
|
||||
func (p SwigcptrEmployee) SwigIsEmployee() {
|
||||
}
|
||||
|
||||
func (p SwigcptrEmployee) DirectorInterface() interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func _swig_wrap_new_Employee(string) SwigcptrEmployee
|
||||
|
||||
func NewEmployee(arg1 string) Employee {
|
||||
return _swig_wrap_new_Employee(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_Employee_getTitle(SwigcptrEmployee) string
|
||||
|
||||
func (arg1 SwigcptrEmployee) GetTitle() string {
|
||||
return _swig_wrap_Employee_getTitle(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_Employee_getName(SwigcptrEmployee) string
|
||||
|
||||
func (arg1 SwigcptrEmployee) GetName() string {
|
||||
return _swig_wrap_Employee_getName(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_Employee_getPosition(SwigcptrEmployee) string
|
||||
|
||||
func (arg1 SwigcptrEmployee) GetPosition() string {
|
||||
return _swig_wrap_Employee_getPosition(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_delete_Employee(uintptr)
|
||||
|
||||
func DeleteEmployee(arg1 Employee) {
|
||||
_swig_wrap_delete_Employee(arg1.Swigcptr())
|
||||
}
|
||||
|
||||
type Employee interface {
|
||||
Swigcptr() uintptr
|
||||
SwigIsEmployee()
|
||||
DirectorInterface() interface{}
|
||||
GetTitle() string
|
||||
GetName() string
|
||||
GetPosition() string
|
||||
}
|
||||
|
||||
type _swig_DirectorManager struct {
|
||||
SwigcptrManager
|
||||
v interface{}
|
||||
}
|
||||
|
||||
func (p *_swig_DirectorManager) Swigcptr() uintptr {
|
||||
return p.SwigcptrManager.Swigcptr()
|
||||
}
|
||||
|
||||
func (p *_swig_DirectorManager) SwigIsManager() {
|
||||
}
|
||||
|
||||
func (p *_swig_DirectorManager) DirectorInterface() interface{} {
|
||||
return p.v
|
||||
}
|
||||
|
||||
func _swig_NewDirectorManagerManager(*_swig_DirectorManager, string) SwigcptrManager
|
||||
|
||||
func NewDirectorManager(v interface{}, arg1 string) Manager {
|
||||
p := &_swig_DirectorManager{0, v}
|
||||
p.SwigcptrManager = _swig_NewDirectorManagerManager(p, arg1)
|
||||
return p
|
||||
}
|
||||
|
||||
type _swig_DirectorInterfaceManagerGetTitle interface {
|
||||
GetTitle() string
|
||||
}
|
||||
|
||||
func _swig_wrap__swig_DirectorManager_upcall_GetTitle(SwigcptrManager) string
|
||||
func (swig_p *_swig_DirectorManager) GetTitle() string {
|
||||
if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceManagerGetTitle); swig_ok {
|
||||
return swig_g.GetTitle()
|
||||
}
|
||||
return _swig_wrap__swig_DirectorManager_upcall_GetTitle(swig_p.SwigcptrManager)
|
||||
}
|
||||
|
||||
func DirectorManagerGetTitle(p Manager) string {
|
||||
return _swig_wrap__swig_DirectorManager_upcall_GetTitle(p.(*_swig_DirectorManager).SwigcptrManager)
|
||||
}
|
||||
|
||||
func Swig_DirectorManager_callback_getTitle(p *_swig_DirectorManager) (swig_result string) {
|
||||
return p.GetTitle()
|
||||
}
|
||||
|
||||
type _swig_DirectorInterfaceManagerGetName interface {
|
||||
GetName() string
|
||||
}
|
||||
|
||||
func _swig_wrap__swig_DirectorManager_upcall_GetName(SwigcptrManager) string
|
||||
func (swig_p *_swig_DirectorManager) GetName() string {
|
||||
if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceManagerGetName); swig_ok {
|
||||
return swig_g.GetName()
|
||||
}
|
||||
return _swig_wrap__swig_DirectorManager_upcall_GetName(swig_p.SwigcptrManager)
|
||||
}
|
||||
|
||||
func DirectorManagerGetName(p Manager) string {
|
||||
return _swig_wrap__swig_DirectorManager_upcall_GetName(p.(*_swig_DirectorManager).SwigcptrManager)
|
||||
}
|
||||
|
||||
func Swig_DirectorManager_callback_getName(p *_swig_DirectorManager) (swig_result string) {
|
||||
return p.GetName()
|
||||
}
|
||||
|
||||
type _swig_DirectorInterfaceManagerGetPosition interface {
|
||||
GetPosition() string
|
||||
}
|
||||
|
||||
func _swig_wrap__swig_DirectorManager_upcall_GetPosition(SwigcptrManager) string
|
||||
func (swig_p *_swig_DirectorManager) GetPosition() string {
|
||||
if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceManagerGetPosition); swig_ok {
|
||||
return swig_g.GetPosition()
|
||||
}
|
||||
return _swig_wrap__swig_DirectorManager_upcall_GetPosition(swig_p.SwigcptrManager)
|
||||
}
|
||||
|
||||
func DirectorManagerGetPosition(p Manager) string {
|
||||
return _swig_wrap__swig_DirectorManager_upcall_GetPosition(p.(*_swig_DirectorManager).SwigcptrManager)
|
||||
}
|
||||
|
||||
func Swig_DirectorManager_callback_getPosition(p *_swig_DirectorManager) (swig_result string) {
|
||||
return p.GetPosition()
|
||||
}
|
||||
|
||||
func _swig_wrap_DeleteDirectorManager(uintptr)
|
||||
|
||||
func DeleteDirectorManager(arg1 Manager) {
|
||||
_swig_wrap_DeleteDirectorManager(arg1.Swigcptr())
|
||||
}
|
||||
|
||||
func Swiggo_DeleteDirector_Manager(p *_swig_DirectorManager) {
|
||||
p.SwigcptrManager = 0
|
||||
}
|
||||
|
||||
type SwigcptrManager uintptr
|
||||
|
||||
func (p SwigcptrManager) Swigcptr() uintptr {
|
||||
return (uintptr)(p)
|
||||
}
|
||||
|
||||
func (p SwigcptrManager) SwigIsManager() {
|
||||
}
|
||||
|
||||
func (p SwigcptrManager) DirectorInterface() interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func _swig_wrap_new_Manager(string) SwigcptrManager
|
||||
|
||||
func NewManager(arg1 string) Manager {
|
||||
return _swig_wrap_new_Manager(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_Manager_getPosition(SwigcptrManager) string
|
||||
|
||||
func (arg1 SwigcptrManager) GetPosition() string {
|
||||
return _swig_wrap_Manager_getPosition(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_delete_Manager(uintptr)
|
||||
|
||||
func DeleteManager(arg1 Manager) {
|
||||
_swig_wrap_delete_Manager(arg1.Swigcptr())
|
||||
}
|
||||
|
||||
func _swig_wrap_Manager_getTitle(SwigcptrManager) string
|
||||
|
||||
func (_swig_base SwigcptrManager) GetTitle() string {
|
||||
return _swig_wrap_Manager_getTitle(_swig_base)
|
||||
}
|
||||
|
||||
func _swig_wrap_Manager_getName(SwigcptrManager) string
|
||||
|
||||
func (_swig_base SwigcptrManager) GetName() string {
|
||||
return _swig_wrap_Manager_getName(_swig_base)
|
||||
}
|
||||
|
||||
func (p SwigcptrManager) SwigIsEmployee() {
|
||||
}
|
||||
|
||||
func (p SwigcptrManager) SwigGetEmployee() Employee {
|
||||
return SwigcptrEmployee(p.Swigcptr())
|
||||
}
|
||||
|
||||
type Manager interface {
|
||||
Swigcptr() uintptr
|
||||
SwigIsManager()
|
||||
DirectorInterface() interface{}
|
||||
GetPosition() string
|
||||
GetTitle() string
|
||||
GetName() string
|
||||
SwigIsEmployee()
|
||||
SwigGetEmployee() Employee
|
||||
}
|
||||
|
||||
type SwigcptrEmployeeList uintptr
|
||||
|
||||
func (p SwigcptrEmployeeList) Swigcptr() uintptr {
|
||||
return (uintptr)(p)
|
||||
}
|
||||
|
||||
func (p SwigcptrEmployeeList) SwigIsEmployeeList() {
|
||||
}
|
||||
|
||||
func _swig_wrap_new_EmployeeList() SwigcptrEmployeeList
|
||||
|
||||
func NewEmployeeList() EmployeeList {
|
||||
return _swig_wrap_new_EmployeeList()
|
||||
}
|
||||
|
||||
func _swig_wrap_EmployeeList_addEmployee(SwigcptrEmployeeList, uintptr)
|
||||
|
||||
func (arg1 SwigcptrEmployeeList) AddEmployee(arg2 Employee) {
|
||||
_swig_wrap_EmployeeList_addEmployee(arg1, arg2.Swigcptr())
|
||||
}
|
||||
|
||||
func _swig_wrap_EmployeeList_get_item(SwigcptrEmployeeList, int) SwigcptrEmployee
|
||||
|
||||
func (arg1 SwigcptrEmployeeList) Get_item(arg2 int) Employee {
|
||||
return _swig_wrap_EmployeeList_get_item(arg1, arg2)
|
||||
}
|
||||
|
||||
func _swig_wrap_delete_EmployeeList(uintptr)
|
||||
|
||||
func DeleteEmployeeList(arg1 EmployeeList) {
|
||||
_swig_wrap_delete_EmployeeList(arg1.Swigcptr())
|
||||
}
|
||||
|
||||
type EmployeeList interface {
|
||||
Swigcptr() uintptr
|
||||
SwigIsEmployeeList()
|
||||
AddEmployee(arg2 Employee)
|
||||
Get_item(arg2 int) Employee
|
||||
}
|
||||
|
||||
|
||||
type SwigcptrSwigDirector_Manager uintptr
|
||||
type SwigDirector_Manager interface {
|
||||
Swigcptr() uintptr;
|
||||
}
|
||||
func (p SwigcptrSwigDirector_Manager) Swigcptr() uintptr {
|
||||
return uintptr(p)
|
||||
}
|
||||
|
||||
type SwigcptrSwigDirector_Employee uintptr
|
||||
type SwigDirector_Employee interface {
|
||||
Swigcptr() uintptr;
|
||||
}
|
||||
func (p SwigcptrSwigDirector_Employee) Swigcptr() uintptr {
|
||||
return uintptr(p)
|
||||
}
|
||||
|
||||
type SwigcptrVoid uintptr
|
||||
type Void interface {
|
||||
Swigcptr() uintptr;
|
||||
}
|
||||
func (p SwigcptrVoid) Swigcptr() uintptr {
|
||||
return uintptr(p)
|
||||
}
|
||||
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 2.0.1
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
package example
|
||||
|
||||
|
||||
type _swig_fnptr *byte
|
||||
type _swig_memberptr *byte
|
||||
|
||||
|
||||
func _swig_allocatememory(int) *byte
|
||||
func _swig_internal_allocate(len int) *byte {
|
||||
return _swig_allocatememory(len)
|
||||
}
|
||||
|
||||
func _swig_allocatestring(*byte, int) string
|
||||
func _swig_internal_makegostring(p *byte, l int) string {
|
||||
return _swig_allocatestring(p, l)
|
||||
}
|
||||
|
||||
func _swig_internal_gopanic(p *byte, l int) {
|
||||
panic(_swig_allocatestring(p, l))
|
||||
}
|
||||
|
||||
func Do_op(int, int, _swig_fnptr) int
|
||||
func _swig_getADD() _swig_fnptr
|
||||
var ADD _swig_fnptr = _swig_getADD()
|
||||
func _swig_getSUB() _swig_fnptr
|
||||
var SUB _swig_fnptr = _swig_getSUB()
|
||||
func _swig_getMUL() _swig_fnptr
|
||||
var MUL _swig_fnptr = _swig_getMUL()
|
||||
func _swig_wrap_funcvar_set(_swig_fnptr)
|
||||
|
||||
func SetFuncvar(arg1 _swig_fnptr) {
|
||||
_swig_wrap_funcvar_set(arg1)
|
||||
}
|
||||
|
||||
func GetFuncvar() _swig_fnptr
|
||||
|
||||
type SwigcptrVoid uintptr
|
||||
type Void interface {
|
||||
Swigcptr() uintptr;
|
||||
}
|
||||
func (p SwigcptrVoid) Swigcptr() uintptr {
|
||||
return uintptr(p)
|
||||
}
|
||||
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 2.0.1
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
package example
|
||||
|
||||
|
||||
type _swig_fnptr *byte
|
||||
type _swig_memberptr *byte
|
||||
|
||||
|
||||
func _swig_allocatememory(int) *byte
|
||||
func _swig_internal_allocate(len int) *byte {
|
||||
return _swig_allocatememory(len)
|
||||
}
|
||||
|
||||
func _swig_allocatestring(*byte, int) string
|
||||
func _swig_internal_makegostring(p *byte, l int) string {
|
||||
return _swig_allocatestring(p, l)
|
||||
}
|
||||
|
||||
func _swig_internal_gopanic(p *byte, l int) {
|
||||
panic(_swig_allocatestring(p, l))
|
||||
}
|
||||
|
||||
func Gcd(int, int) int
|
||||
func Gcdmain([]string) int
|
||||
func Count(string, byte) int
|
||||
func _swig_wrap_capitalize([]string)
|
||||
|
||||
func Capitalize(arg1 []string) {
|
||||
_swig_wrap_capitalize(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_circle(float64, float64)
|
||||
|
||||
func Circle(arg1 float64, arg2 float64) {
|
||||
_swig_wrap_circle(arg1, arg2)
|
||||
}
|
||||
|
||||
|
||||
type SwigcptrVoid uintptr
|
||||
type Void interface {
|
||||
Swigcptr() uintptr;
|
||||
}
|
||||
func (p SwigcptrVoid) Swigcptr() uintptr {
|
||||
return uintptr(p)
|
||||
}
|
||||
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 2.0.1
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
package example
|
||||
|
||||
|
||||
type _swig_fnptr *byte
|
||||
type _swig_memberptr *byte
|
||||
|
||||
|
||||
func _swig_allocatememory(int) *byte
|
||||
func _swig_internal_allocate(len int) *byte {
|
||||
return _swig_allocatememory(len)
|
||||
}
|
||||
|
||||
func _swig_allocatestring(*byte, int) string
|
||||
func _swig_internal_makegostring(p *byte, l int) string {
|
||||
return _swig_allocatestring(p, l)
|
||||
}
|
||||
|
||||
func _swig_internal_gopanic(p *byte, l int) {
|
||||
panic(_swig_allocatestring(p, l))
|
||||
}
|
||||
|
||||
func _swig_wrap_add(*int, *int, *int)
|
||||
|
||||
func Add(arg1 *int, arg2 *int, arg3 *int) {
|
||||
_swig_wrap_add(arg1, arg2, arg3)
|
||||
}
|
||||
|
||||
func New_intp() *int
|
||||
func Copy_intp(int) *int
|
||||
func _swig_wrap_delete_intp(*int)
|
||||
|
||||
func Delete_intp(arg1 *int) {
|
||||
_swig_wrap_delete_intp(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_intp_assign(*int, int)
|
||||
|
||||
func Intp_assign(arg1 *int, arg2 int) {
|
||||
_swig_wrap_intp_assign(arg1, arg2)
|
||||
}
|
||||
|
||||
func Intp_value(*int) int
|
||||
func _swig_wrap_sub(int, int, []int)
|
||||
|
||||
func Sub(arg1 int, arg2 int, arg3 []int) {
|
||||
_swig_wrap_sub(arg1, arg2, arg3)
|
||||
}
|
||||
|
||||
func Divide(int, int, []int) int
|
||||
|
||||
type SwigcptrVoid uintptr
|
||||
type Void interface {
|
||||
Swigcptr() uintptr;
|
||||
}
|
||||
func (p SwigcptrVoid) Swigcptr() uintptr {
|
||||
return uintptr(p)
|
||||
}
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ func main() {
|
|||
|
||||
// Now try the typemap library
|
||||
// Now it is no longer necessary to manufacture pointers.
|
||||
// Instead we use a single element array which in Java is modifiable.
|
||||
// Instead we use a single element slice which in Go is modifiable.
|
||||
|
||||
fmt.Println("Trying the typemap library")
|
||||
r := []int{0}
|
||||
|
|
|
|||
|
|
@ -1,126 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 2.0.1
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
package example
|
||||
|
||||
|
||||
type _swig_fnptr *byte
|
||||
type _swig_memberptr *byte
|
||||
|
||||
|
||||
func _swig_allocatememory(int) *byte
|
||||
func _swig_internal_allocate(len int) *byte {
|
||||
return _swig_allocatememory(len)
|
||||
}
|
||||
|
||||
func _swig_allocatestring(*byte, int) string
|
||||
func _swig_internal_makegostring(p *byte, l int) string {
|
||||
return _swig_allocatestring(p, l)
|
||||
}
|
||||
|
||||
func _swig_internal_gopanic(p *byte, l int) {
|
||||
panic(_swig_allocatestring(p, l))
|
||||
}
|
||||
|
||||
type SwigcptrVector uintptr
|
||||
|
||||
func (p SwigcptrVector) Swigcptr() uintptr {
|
||||
return (uintptr)(p)
|
||||
}
|
||||
|
||||
func (p SwigcptrVector) SwigIsVector() {
|
||||
}
|
||||
|
||||
func _swig_wrap_new_Vector(float64, float64, float64) SwigcptrVector
|
||||
|
||||
func NewVector(arg1 float64, arg2 float64, arg3 float64) Vector {
|
||||
return _swig_wrap_new_Vector(arg1, arg2, arg3)
|
||||
}
|
||||
|
||||
func _swig_wrap_delete_Vector(uintptr)
|
||||
|
||||
func DeleteVector(arg1 Vector) {
|
||||
_swig_wrap_delete_Vector(arg1.Swigcptr())
|
||||
}
|
||||
|
||||
func _swig_wrap_Vector_print(SwigcptrVector) string
|
||||
|
||||
func (arg1 SwigcptrVector) Print() string {
|
||||
return _swig_wrap_Vector_print(arg1)
|
||||
}
|
||||
|
||||
type Vector interface {
|
||||
Swigcptr() uintptr
|
||||
SwigIsVector()
|
||||
Print() string
|
||||
}
|
||||
|
||||
func _swig_wrap_addv(uintptr, uintptr) SwigcptrVector
|
||||
|
||||
func Addv(arg1 Vector, arg2 Vector) Vector {
|
||||
return _swig_wrap_addv(arg1.Swigcptr(), arg2.Swigcptr())
|
||||
}
|
||||
|
||||
type SwigcptrVectorArray uintptr
|
||||
|
||||
func (p SwigcptrVectorArray) Swigcptr() uintptr {
|
||||
return (uintptr)(p)
|
||||
}
|
||||
|
||||
func (p SwigcptrVectorArray) SwigIsVectorArray() {
|
||||
}
|
||||
|
||||
func _swig_wrap_new_VectorArray(int) SwigcptrVectorArray
|
||||
|
||||
func NewVectorArray(arg1 int) VectorArray {
|
||||
return _swig_wrap_new_VectorArray(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_delete_VectorArray(uintptr)
|
||||
|
||||
func DeleteVectorArray(arg1 VectorArray) {
|
||||
_swig_wrap_delete_VectorArray(arg1.Swigcptr())
|
||||
}
|
||||
|
||||
func _swig_wrap_VectorArray_size(SwigcptrVectorArray) int
|
||||
|
||||
func (arg1 SwigcptrVectorArray) Size() int {
|
||||
return _swig_wrap_VectorArray_size(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_VectorArray_get(SwigcptrVectorArray, int) SwigcptrVector
|
||||
|
||||
func (arg1 SwigcptrVectorArray) Get(arg2 int) Vector {
|
||||
return _swig_wrap_VectorArray_get(arg1, arg2)
|
||||
}
|
||||
|
||||
func _swig_wrap_VectorArray_set(SwigcptrVectorArray, int, uintptr)
|
||||
|
||||
func (arg1 SwigcptrVectorArray) Set(arg2 int, arg3 Vector) {
|
||||
_swig_wrap_VectorArray_set(arg1, arg2, arg3.Swigcptr())
|
||||
}
|
||||
|
||||
type VectorArray interface {
|
||||
Swigcptr() uintptr
|
||||
SwigIsVectorArray()
|
||||
Size() int
|
||||
Get(arg2 int) Vector
|
||||
Set(arg2 int, arg3 Vector)
|
||||
}
|
||||
|
||||
|
||||
type SwigcptrVoid uintptr
|
||||
type Void interface {
|
||||
Swigcptr() uintptr;
|
||||
}
|
||||
func (p SwigcptrVoid) Swigcptr() uintptr {
|
||||
return uintptr(p)
|
||||
}
|
||||
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 2.0.1
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
package example
|
||||
|
||||
|
||||
type _swig_fnptr *byte
|
||||
type _swig_memberptr *byte
|
||||
|
||||
|
||||
func _swig_allocatememory(int) *byte
|
||||
func _swig_internal_allocate(len int) *byte {
|
||||
return _swig_allocatememory(len)
|
||||
}
|
||||
|
||||
func _swig_allocatestring(*byte, int) string
|
||||
func _swig_internal_makegostring(p *byte, l int) string {
|
||||
return _swig_allocatestring(p, l)
|
||||
}
|
||||
|
||||
func _swig_internal_gopanic(p *byte, l int) {
|
||||
panic(_swig_allocatestring(p, l))
|
||||
}
|
||||
|
||||
func Gcd(int, int) int
|
||||
func _swig_wrap_Foo_set(float64)
|
||||
|
||||
func SetFoo(arg1 float64) {
|
||||
_swig_wrap_Foo_set(arg1)
|
||||
}
|
||||
|
||||
func GetFoo() float64
|
||||
|
||||
type SwigcptrVoid uintptr
|
||||
type Void interface {
|
||||
Swigcptr() uintptr;
|
||||
}
|
||||
func (p SwigcptrVoid) Swigcptr() uintptr {
|
||||
return uintptr(p)
|
||||
}
|
||||
|
||||
|
|
@ -1,150 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 2.0.1
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
package example
|
||||
|
||||
|
||||
type _swig_fnptr *byte
|
||||
type _swig_memberptr *byte
|
||||
|
||||
|
||||
func _swig_allocatememory(int) *byte
|
||||
func _swig_internal_allocate(len int) *byte {
|
||||
return _swig_allocatememory(len)
|
||||
}
|
||||
|
||||
func _swig_allocatestring(*byte, int) string
|
||||
func _swig_internal_makegostring(p *byte, l int) string {
|
||||
return _swig_allocatestring(p, l)
|
||||
}
|
||||
|
||||
func _swig_internal_gopanic(p *byte, l int) {
|
||||
panic(_swig_allocatestring(p, l))
|
||||
}
|
||||
|
||||
func Maxint(int, int) int
|
||||
func Maxdouble(float64, float64) float64
|
||||
type SwigcptrVecint uintptr
|
||||
|
||||
func (p SwigcptrVecint) Swigcptr() uintptr {
|
||||
return (uintptr)(p)
|
||||
}
|
||||
|
||||
func (p SwigcptrVecint) SwigIsVecint() {
|
||||
}
|
||||
|
||||
func _swig_wrap_new_vecint(int) SwigcptrVecint
|
||||
|
||||
func NewVecint(arg1 int) Vecint {
|
||||
return _swig_wrap_new_vecint(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_vecint_get(SwigcptrVecint, int) *int
|
||||
|
||||
func (arg1 SwigcptrVecint) Get(arg2 int) *int {
|
||||
return _swig_wrap_vecint_get(arg1, arg2)
|
||||
}
|
||||
|
||||
func _swig_wrap_vecint_set(SwigcptrVecint, int, *int)
|
||||
|
||||
func (arg1 SwigcptrVecint) Set(arg2 int, arg3 *int) {
|
||||
_swig_wrap_vecint_set(arg1, arg2, arg3)
|
||||
}
|
||||
|
||||
func _swig_wrap_vecint_getitem(SwigcptrVecint, int) int
|
||||
|
||||
func (arg1 SwigcptrVecint) Getitem(arg2 int) int {
|
||||
return _swig_wrap_vecint_getitem(arg1, arg2)
|
||||
}
|
||||
|
||||
func _swig_wrap_vecint_setitem(SwigcptrVecint, int, int)
|
||||
|
||||
func (arg1 SwigcptrVecint) Setitem(arg2 int, arg3 int) {
|
||||
_swig_wrap_vecint_setitem(arg1, arg2, arg3)
|
||||
}
|
||||
|
||||
func _swig_wrap_delete_vecint(uintptr)
|
||||
|
||||
func DeleteVecint(arg1 Vecint) {
|
||||
_swig_wrap_delete_vecint(arg1.Swigcptr())
|
||||
}
|
||||
|
||||
type Vecint interface {
|
||||
Swigcptr() uintptr
|
||||
SwigIsVecint()
|
||||
Get(arg2 int) *int
|
||||
Set(arg2 int, arg3 *int)
|
||||
Getitem(arg2 int) int
|
||||
Setitem(arg2 int, arg3 int)
|
||||
}
|
||||
|
||||
type SwigcptrVecdouble uintptr
|
||||
|
||||
func (p SwigcptrVecdouble) Swigcptr() uintptr {
|
||||
return (uintptr)(p)
|
||||
}
|
||||
|
||||
func (p SwigcptrVecdouble) SwigIsVecdouble() {
|
||||
}
|
||||
|
||||
func _swig_wrap_new_vecdouble(int) SwigcptrVecdouble
|
||||
|
||||
func NewVecdouble(arg1 int) Vecdouble {
|
||||
return _swig_wrap_new_vecdouble(arg1)
|
||||
}
|
||||
|
||||
func _swig_wrap_vecdouble_get(SwigcptrVecdouble, int) *float64
|
||||
|
||||
func (arg1 SwigcptrVecdouble) Get(arg2 int) *float64 {
|
||||
return _swig_wrap_vecdouble_get(arg1, arg2)
|
||||
}
|
||||
|
||||
func _swig_wrap_vecdouble_set(SwigcptrVecdouble, int, *float64)
|
||||
|
||||
func (arg1 SwigcptrVecdouble) Set(arg2 int, arg3 *float64) {
|
||||
_swig_wrap_vecdouble_set(arg1, arg2, arg3)
|
||||
}
|
||||
|
||||
func _swig_wrap_vecdouble_getitem(SwigcptrVecdouble, int) float64
|
||||
|
||||
func (arg1 SwigcptrVecdouble) Getitem(arg2 int) float64 {
|
||||
return _swig_wrap_vecdouble_getitem(arg1, arg2)
|
||||
}
|
||||
|
||||
func _swig_wrap_vecdouble_setitem(SwigcptrVecdouble, int, float64)
|
||||
|
||||
func (arg1 SwigcptrVecdouble) Setitem(arg2 int, arg3 float64) {
|
||||
_swig_wrap_vecdouble_setitem(arg1, arg2, arg3)
|
||||
}
|
||||
|
||||
func _swig_wrap_delete_vecdouble(uintptr)
|
||||
|
||||
func DeleteVecdouble(arg1 Vecdouble) {
|
||||
_swig_wrap_delete_vecdouble(arg1.Swigcptr())
|
||||
}
|
||||
|
||||
type Vecdouble interface {
|
||||
Swigcptr() uintptr
|
||||
SwigIsVecdouble()
|
||||
Get(arg2 int) *float64
|
||||
Set(arg2 int, arg3 *float64)
|
||||
Getitem(arg2 int) float64
|
||||
Setitem(arg2 int, arg3 float64)
|
||||
}
|
||||
|
||||
|
||||
type SwigcptrVoid uintptr
|
||||
type Void interface {
|
||||
Swigcptr() uintptr;
|
||||
}
|
||||
func (p SwigcptrVoid) Swigcptr() uintptr {
|
||||
return uintptr(p)
|
||||
}
|
||||
|
||||
|
|
@ -1,198 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 2.0.1
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
package example
|
||||
|
||||
|
||||
type _swig_fnptr *byte
|
||||
type _swig_memberptr *byte
|
||||
|
||||
|
||||
func _swig_allocatememory(int) *byte
|
||||
func _swig_internal_allocate(len int) *byte {
|
||||
return _swig_allocatememory(len)
|
||||
}
|
||||
|
||||
func _swig_allocatestring(*byte, int) string
|
||||
func _swig_internal_makegostring(p *byte, l int) string {
|
||||
return _swig_allocatestring(p, l)
|
||||
}
|
||||
|
||||
func _swig_internal_gopanic(p *byte, l int) {
|
||||
panic(_swig_allocatestring(p, l))
|
||||
}
|
||||
|
||||
func _swig_wrap_ivar_set(int)
|
||||
|
||||
func SetIvar(arg1 int) {
|
||||
_swig_wrap_ivar_set(arg1)
|
||||
}
|
||||
|
||||
func GetIvar() int
|
||||
func _swig_wrap_svar_set(int16)
|
||||
|
||||
func SetSvar(arg1 int16) {
|
||||
_swig_wrap_svar_set(arg1)
|
||||
}
|
||||
|
||||
func GetSvar() int16
|
||||
func _swig_wrap_lvar_set(int32)
|
||||
|
||||
func SetLvar(arg1 int32) {
|
||||
_swig_wrap_lvar_set(arg1)
|
||||
}
|
||||
|
||||
func GetLvar() int32
|
||||
func _swig_wrap_uivar_set(uint)
|
||||
|
||||
func SetUivar(arg1 uint) {
|
||||
_swig_wrap_uivar_set(arg1)
|
||||
}
|
||||
|
||||
func GetUivar() uint
|
||||
func _swig_wrap_usvar_set(uint16)
|
||||
|
||||
func SetUsvar(arg1 uint16) {
|
||||
_swig_wrap_usvar_set(arg1)
|
||||
}
|
||||
|
||||
func GetUsvar() uint16
|
||||
func _swig_wrap_ulvar_set(uint32)
|
||||
|
||||
func SetUlvar(arg1 uint32) {
|
||||
_swig_wrap_ulvar_set(arg1)
|
||||
}
|
||||
|
||||
func GetUlvar() uint32
|
||||
func _swig_wrap_scvar_set(int8)
|
||||
|
||||
func SetScvar(arg1 int8) {
|
||||
_swig_wrap_scvar_set(arg1)
|
||||
}
|
||||
|
||||
func GetScvar() int8
|
||||
func _swig_wrap_ucvar_set(byte)
|
||||
|
||||
func SetUcvar(arg1 byte) {
|
||||
_swig_wrap_ucvar_set(arg1)
|
||||
}
|
||||
|
||||
func GetUcvar() byte
|
||||
func _swig_wrap_cvar_set(byte)
|
||||
|
||||
func SetCvar(arg1 byte) {
|
||||
_swig_wrap_cvar_set(arg1)
|
||||
}
|
||||
|
||||
func GetCvar() byte
|
||||
func _swig_wrap_fvar_set(float32)
|
||||
|
||||
func SetFvar(arg1 float32) {
|
||||
_swig_wrap_fvar_set(arg1)
|
||||
}
|
||||
|
||||
func GetFvar() float32
|
||||
func _swig_wrap_dvar_set(float64)
|
||||
|
||||
func SetDvar(arg1 float64) {
|
||||
_swig_wrap_dvar_set(arg1)
|
||||
}
|
||||
|
||||
func GetDvar() float64
|
||||
func _swig_wrap_strvar_set(string)
|
||||
|
||||
func SetStrvar(arg1 string) {
|
||||
_swig_wrap_strvar_set(arg1)
|
||||
}
|
||||
|
||||
func GetStrvar() string
|
||||
func GetCstrvar() string
|
||||
func _swig_wrap_iptrvar_set(*int)
|
||||
|
||||
func SetIptrvar(arg1 *int) {
|
||||
_swig_wrap_iptrvar_set(arg1)
|
||||
}
|
||||
|
||||
func GetIptrvar() *int
|
||||
func _swig_wrap_name_set(string)
|
||||
|
||||
func SetName(arg1 string) {
|
||||
_swig_wrap_name_set(arg1)
|
||||
}
|
||||
|
||||
func GetName() string
|
||||
func _swig_wrap_ptptr_set(uintptr)
|
||||
|
||||
func SetPtptr(arg1 Point) {
|
||||
_swig_wrap_ptptr_set(arg1.Swigcptr())
|
||||
}
|
||||
|
||||
func _swig_wrap_ptptr_get() SwigcptrPoint
|
||||
|
||||
func GetPtptr() Point {
|
||||
return _swig_wrap_ptptr_get()
|
||||
}
|
||||
|
||||
func _swig_wrap_pt_set(uintptr)
|
||||
|
||||
func SetPt(arg1 Point) {
|
||||
_swig_wrap_pt_set(arg1.Swigcptr())
|
||||
}
|
||||
|
||||
func _swig_wrap_pt_get() SwigcptrPoint
|
||||
|
||||
func GetPt() Point {
|
||||
return _swig_wrap_pt_get()
|
||||
}
|
||||
|
||||
func GetStatus() int
|
||||
func GetPath() string
|
||||
func _swig_wrap_print_vars()
|
||||
|
||||
func Print_vars() {
|
||||
_swig_wrap_print_vars()
|
||||
}
|
||||
|
||||
func New_int(int) *int
|
||||
func _swig_wrap_new_Point(int, int) SwigcptrPoint
|
||||
|
||||
func New_Point(arg1 int, arg2 int) Point {
|
||||
return _swig_wrap_new_Point(arg1, arg2)
|
||||
}
|
||||
|
||||
func _swig_wrap_Point_print(uintptr) string
|
||||
|
||||
func Point_print(arg1 Point) string {
|
||||
return _swig_wrap_Point_print(arg1.Swigcptr())
|
||||
}
|
||||
|
||||
func _swig_wrap_pt_print()
|
||||
|
||||
func Pt_print() {
|
||||
_swig_wrap_pt_print()
|
||||
}
|
||||
|
||||
|
||||
type SwigcptrPoint uintptr
|
||||
type Point interface {
|
||||
Swigcptr() uintptr;
|
||||
}
|
||||
func (p SwigcptrPoint) Swigcptr() uintptr {
|
||||
return uintptr(p)
|
||||
}
|
||||
|
||||
type SwigcptrVoid uintptr
|
||||
type Void interface {
|
||||
Swigcptr() uintptr;
|
||||
}
|
||||
func (p SwigcptrVoid) Swigcptr() uintptr {
|
||||
return uintptr(p)
|
||||
}
|
||||
|
||||
|
|
@ -1,4 +1,8 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
%{
|
||||
extern "C" void factor(int &x, int &y);
|
||||
%}
|
||||
|
||||
extern "C" void factor(int &x, int &y);
|
||||
|
|
|
|||
|
|
@ -46,3 +46,5 @@ void draw_depth_map( volume *v, int div_x, int div_y ) {
|
|||
}
|
||||
|
||||
double volume::depth( double x, double y ) { return 0.0; }
|
||||
|
||||
volume::~volume() { }
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ public:
|
|||
|
||||
class volume {
|
||||
public:
|
||||
virtual double depth( double x, double y );
|
||||
virtual double depth( double x, double y );
|
||||
virtual ~volume();
|
||||
};
|
||||
|
||||
extern void draw_shape_coverage( shape *s, int div_x, int div_y );
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
--- New ---
|
||||
|
||||
It's not possible to access std::(w)string at the moment as it breaks other string examples.
|
||||
|
||||
--- Old ---
|
||||
|
||||
This example shows how to use both std::string and std::wstring in Ocaml,
|
||||
and also demonstrates that one might use this to make a locale-obedient
|
||||
Ocaml program.
|
||||
|
|
|
|||
|
|
@ -1,14 +1,18 @@
|
|||
/* -*- mode: c++ -*- */
|
||||
/* File : example.h -- Tests all string typemaps */
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
void takes_std_string( std::string in ) {
|
||||
cout << "takes_std_string( \"" << in << "\" );" << endl;
|
||||
}
|
||||
|
||||
std::string gives_std_string() {
|
||||
time_t t;
|
||||
|
||||
return std::string( asctime( localtime( &t ) ) );
|
||||
struct timeval tv;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
return std::string( asctime( localtime( &tv.tv_sec ) ) );
|
||||
}
|
||||
|
||||
void takes_char_ptr( char *p ) {
|
||||
|
|
@ -24,10 +28,10 @@ void takes_and_gives_std_string( std::string &inout ) {
|
|||
inout.insert( inout.end(), ']' );
|
||||
}
|
||||
|
||||
void takes_and_gives_char_ptr( char *&ptr ) {
|
||||
char *pout = strchr( ptr, '.' );
|
||||
if( pout ) ptr = pout + 1;
|
||||
else ptr = "foo";
|
||||
void takes_and_gives_char_ptr( char *&inout ) {
|
||||
char *pout = strchr( inout, '.' );
|
||||
if( pout ) inout = pout + 1;
|
||||
else inout = "foo";
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -35,11 +35,10 @@ print " Square = (" . $s->x . "," . $s->y . ")\n";
|
|||
|
||||
# ----- Call some methods -----
|
||||
|
||||
print "\nHere are some properties of the shapes:\n";
|
||||
print "\nCall some overloaded methods:\n";
|
||||
foreach (array(1, 2.1, "quick brown fox", $c, $s) as $o) {
|
||||
print " ".get_class($o)." \$o\n";
|
||||
print " overloaded = " . overloaded($o) . "\n";
|
||||
}
|
||||
print " overloaded = " . overloaded($o) . "\n";
|
||||
}
|
||||
|
||||
# Need to unset($o) or else we hang on to a reference to the Square object.
|
||||
unset($o);
|
||||
|
|
|
|||
37
Examples/python/performance/Makefile
Normal file
37
Examples/python/performance/Makefile
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
ifeq (,$(PY3))
|
||||
PYSCRIPT = runme.py
|
||||
else
|
||||
PYSCRIPT = runme3.py
|
||||
endif
|
||||
|
||||
default : all
|
||||
|
||||
include ../../Makefile
|
||||
|
||||
SUBDIRS := constructor func hierarchy operator hierarchy_operator
|
||||
|
||||
.PHONY : all $(SUBDIRS)
|
||||
|
||||
all : $(SUBDIRS:%=%-build)
|
||||
@for subdir in $(SUBDIRS); do \
|
||||
echo Running $$subdir test... ; \
|
||||
echo -------------------------------------------------------------------------------- ; \
|
||||
cd $$subdir; \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(PYTHON) $(PYSCRIPT); \
|
||||
cd ..; \
|
||||
done
|
||||
|
||||
$(SUBDIRS) :
|
||||
$(MAKE) -C $@
|
||||
@echo Running $$subdir test...
|
||||
@echo --------------------------------------------------------------------------------
|
||||
cd $@ && env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(PYTHON) $(PYSCRIPT)
|
||||
|
||||
%-build :
|
||||
$(MAKE) -C $*
|
||||
|
||||
%-clean :
|
||||
$(MAKE) -s -C $* clean
|
||||
|
||||
clean : $(SUBDIRS:%=%-clean)
|
||||
rm -f *.pyc
|
||||
21
Examples/python/performance/constructor/Makefile
Normal file
21
Examples/python/performance/constructor/Makefile
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
TOP = ../../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
CXXSRCS =
|
||||
TARGET = Simple
|
||||
INTERFACE = Simple.i
|
||||
|
||||
all :
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
|
||||
TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
|
||||
TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
|
||||
TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp
|
||||
|
||||
static :
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||
TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
|
||||
|
||||
clean :
|
||||
$(MAKE) -f $(TOP)/Makefile python_clean
|
||||
rm -f $(TARGET).py
|
||||
8
Examples/python/performance/constructor/Simple.i
Normal file
8
Examples/python/performance/constructor/Simple.i
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
%inline %{
|
||||
class MyClass {
|
||||
public:
|
||||
MyClass () {}
|
||||
~MyClass () {}
|
||||
void func () {}
|
||||
};
|
||||
%}
|
||||
11
Examples/python/performance/constructor/runme.py
Normal file
11
Examples/python/performance/constructor/runme.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env
|
||||
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
import harness
|
||||
|
||||
def proc (mod) :
|
||||
for i in range(1000000) :
|
||||
x = mod.MyClass()
|
||||
|
||||
harness.run(proc)
|
||||
23
Examples/python/performance/func/Makefile
Normal file
23
Examples/python/performance/func/Makefile
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
TOP = ../../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
CXXSRCS =
|
||||
TARGET = Simple
|
||||
INTERFACE = Simple.i
|
||||
|
||||
default : all
|
||||
|
||||
all :
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
|
||||
TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
|
||||
TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
|
||||
TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp
|
||||
|
||||
static :
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||
TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
|
||||
|
||||
clean :
|
||||
$(MAKE) -f $(TOP)/Makefile python_clean
|
||||
rm -f $(TARGET).py
|
||||
8
Examples/python/performance/func/Simple.i
Normal file
8
Examples/python/performance/func/Simple.i
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
%inline %{
|
||||
class MyClass {
|
||||
public:
|
||||
MyClass () {}
|
||||
~MyClass () {}
|
||||
void func () {}
|
||||
};
|
||||
%}
|
||||
12
Examples/python/performance/func/runme.py
Normal file
12
Examples/python/performance/func/runme.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env
|
||||
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
import harness
|
||||
|
||||
def proc (mod) :
|
||||
x = mod.MyClass()
|
||||
for i in range(10000000) :
|
||||
x.func()
|
||||
|
||||
harness.run(proc)
|
||||
30
Examples/python/performance/harness.py
Normal file
30
Examples/python/performance/harness.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env
|
||||
|
||||
import sys
|
||||
import time
|
||||
import imp
|
||||
from subprocess import *
|
||||
|
||||
def run (proc) :
|
||||
|
||||
try :
|
||||
mod = imp.find_module(sys.argv[1])
|
||||
mod = imp.load_module(sys.argv[1], *mod)
|
||||
|
||||
t1 = time.clock()
|
||||
proc(mod)
|
||||
t2 = time.clock()
|
||||
print "%s took %f seconds" % (mod.__name__, t2 - t1)
|
||||
|
||||
except IndexError :
|
||||
proc = Popen([sys.executable, 'runme.py', 'Simple_baseline'], stdout=PIPE)
|
||||
(stdout, stderr) = proc.communicate()
|
||||
print stdout
|
||||
|
||||
proc = Popen([sys.executable, 'runme.py', 'Simple_optimized'], stdout=PIPE)
|
||||
(stdout, stderr) = proc.communicate()
|
||||
print stdout
|
||||
|
||||
proc = Popen([sys.executable, 'runme.py', 'Simple_builtin'], stdout=PIPE)
|
||||
(stdout, stderr) = proc.communicate()
|
||||
print stdout
|
||||
23
Examples/python/performance/hierarchy/Makefile
Normal file
23
Examples/python/performance/hierarchy/Makefile
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
TOP = ../../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
CXXSRCS =
|
||||
TARGET = Simple
|
||||
INTERFACE = Simple.i
|
||||
|
||||
default : all
|
||||
|
||||
all :
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
|
||||
TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
|
||||
TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
|
||||
TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp
|
||||
|
||||
static :
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||
TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
|
||||
|
||||
clean :
|
||||
$(MAKE) -f $(TOP)/Makefile python_clean
|
||||
rm -f $(TARGET).py
|
||||
52
Examples/python/performance/hierarchy/Simple.i
Normal file
52
Examples/python/performance/hierarchy/Simple.i
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
%inline %{
|
||||
|
||||
class A {
|
||||
public:
|
||||
A () {}
|
||||
~A () {}
|
||||
void func () {}
|
||||
};
|
||||
|
||||
class B : public A {
|
||||
public:
|
||||
B () {}
|
||||
~B () {}
|
||||
};
|
||||
|
||||
class C : public B {
|
||||
public:
|
||||
C () {}
|
||||
~C () {}
|
||||
};
|
||||
|
||||
class D : public C {
|
||||
public:
|
||||
D () {}
|
||||
~D () {}
|
||||
};
|
||||
|
||||
class E : public D {
|
||||
public:
|
||||
E () {}
|
||||
~E () {}
|
||||
};
|
||||
|
||||
class F : public E {
|
||||
public:
|
||||
F () {}
|
||||
~F () {}
|
||||
};
|
||||
|
||||
class G : public F {
|
||||
public:
|
||||
G () {}
|
||||
~G () {}
|
||||
};
|
||||
|
||||
class H : public G {
|
||||
public:
|
||||
H () {}
|
||||
~H () {}
|
||||
};
|
||||
|
||||
%}
|
||||
12
Examples/python/performance/hierarchy/runme.py
Normal file
12
Examples/python/performance/hierarchy/runme.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env
|
||||
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
import harness
|
||||
|
||||
def proc (mod) :
|
||||
x = mod.H()
|
||||
for i in range(10000000) :
|
||||
x.func()
|
||||
|
||||
harness.run(proc)
|
||||
23
Examples/python/performance/hierarchy_operator/Makefile
Normal file
23
Examples/python/performance/hierarchy_operator/Makefile
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
TOP = ../../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
CXXSRCS =
|
||||
TARGET = Simple
|
||||
INTERFACE = Simple.i
|
||||
|
||||
default : all
|
||||
|
||||
all :
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
|
||||
TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
|
||||
TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
|
||||
TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp
|
||||
|
||||
static :
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||
TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
|
||||
|
||||
clean :
|
||||
$(MAKE) -f $(TOP)/Makefile python_clean
|
||||
rm -f $(TARGET).py
|
||||
53
Examples/python/performance/hierarchy_operator/Simple.i
Normal file
53
Examples/python/performance/hierarchy_operator/Simple.i
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
%inline %{
|
||||
|
||||
class A {
|
||||
public:
|
||||
A () {}
|
||||
~A () {}
|
||||
void func () {}
|
||||
A& operator+= (int i) { return *this; }
|
||||
};
|
||||
|
||||
class B : public A {
|
||||
public:
|
||||
B () {}
|
||||
~B () {}
|
||||
};
|
||||
|
||||
class C : public B {
|
||||
public:
|
||||
C () {}
|
||||
~C () {}
|
||||
};
|
||||
|
||||
class D : public C {
|
||||
public:
|
||||
D () {}
|
||||
~D () {}
|
||||
};
|
||||
|
||||
class E : public D {
|
||||
public:
|
||||
E () {}
|
||||
~E () {}
|
||||
};
|
||||
|
||||
class F : public E {
|
||||
public:
|
||||
F () {}
|
||||
~F () {}
|
||||
};
|
||||
|
||||
class G : public F {
|
||||
public:
|
||||
G () {}
|
||||
~G () {}
|
||||
};
|
||||
|
||||
class H : public G {
|
||||
public:
|
||||
H () {}
|
||||
~H () {}
|
||||
};
|
||||
|
||||
%}
|
||||
12
Examples/python/performance/hierarchy_operator/runme.py
Normal file
12
Examples/python/performance/hierarchy_operator/runme.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env
|
||||
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
import harness
|
||||
|
||||
def proc (mod) :
|
||||
x = mod.H()
|
||||
for i in range(10000000) :
|
||||
x += i
|
||||
|
||||
harness.run(proc)
|
||||
23
Examples/python/performance/operator/Makefile
Normal file
23
Examples/python/performance/operator/Makefile
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
TOP = ../../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
CXXSRCS =
|
||||
TARGET = Simple
|
||||
INTERFACE = Simple.i
|
||||
|
||||
default : all
|
||||
|
||||
all :
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
|
||||
TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
|
||||
TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
|
||||
TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp
|
||||
|
||||
static :
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||
TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
|
||||
|
||||
clean :
|
||||
$(MAKE) -f $(TOP)/Makefile python_clean
|
||||
rm -f $(TARGET).py
|
||||
8
Examples/python/performance/operator/Simple.i
Normal file
8
Examples/python/performance/operator/Simple.i
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
%inline %{
|
||||
class MyClass {
|
||||
public:
|
||||
MyClass () {}
|
||||
~MyClass () {}
|
||||
MyClass& operator+ (int i) { return *this; }
|
||||
};
|
||||
%}
|
||||
12
Examples/python/performance/operator/runme.py
Normal file
12
Examples/python/performance/operator/runme.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env
|
||||
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
import harness
|
||||
|
||||
def proc (mod) :
|
||||
x = mod.MyClass()
|
||||
for i in range(10000000) :
|
||||
x = x + i
|
||||
|
||||
harness.run(proc)
|
||||
|
|
@ -2,10 +2,12 @@
|
|||
|
||||
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_PHP_MULTIPLE_INHERITANCE) D; /* C#, Java, PHP multiple inheritance */
|
||||
SWIGWARN_D_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_PHP_MULTIPLE_INHERITANCE) D; /* C#, D, Java, PHP multiple inheritance */
|
||||
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, Java, PHP multiple inheritance */
|
||||
SWIGWARN_D_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, D, Java, PHP multiple inheritance */
|
||||
|
||||
%inline %{
|
||||
#if defined(_MSC_VER)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,43 @@
|
|||
%module array_typedef_memberin
|
||||
%inline %{
|
||||
typedef short arr_short8[8];
|
||||
typedef short Eight[8];
|
||||
typedef const short ConstEight[8];
|
||||
namespace ArrayExample
|
||||
{
|
||||
class ExampleDetail
|
||||
{
|
||||
public:
|
||||
arr_short8 node_list;
|
||||
};
|
||||
Eight node_list;
|
||||
#ifndef _MSC_VER
|
||||
const Eight node_list2;
|
||||
ConstEight node_list3;
|
||||
#else
|
||||
Eight node_list2;
|
||||
Eight node_list3;
|
||||
#endif
|
||||
|
||||
void fn1(Eight a) {}
|
||||
void fn2(const Eight a) {}
|
||||
void fn3(ConstEight a) {}
|
||||
|
||||
void fn4(Eight* a) {}
|
||||
void fn5(ConstEight* a) {}
|
||||
void fn6(const ConstEight* a) {}
|
||||
|
||||
void fn7(Eight*& a) {}
|
||||
void fn8(ConstEight*& a) {}
|
||||
void fn9(const ConstEight*& a) {}
|
||||
};
|
||||
}
|
||||
|
||||
typedef int Four[4];
|
||||
typedef const int ConstFour[4];
|
||||
|
||||
void test_1(int (*v)[4]) {}
|
||||
void test_2(Four *v) {}
|
||||
void test_3(const Four *v) {}
|
||||
void test_4(ConstFour *v) {}
|
||||
void test_5(const int (*v)[4]) {}
|
||||
void test_3r(const Four *&v) {}
|
||||
void test_4r(ConstFour *&v) {}
|
||||
%}
|
||||
|
|
|
|||
29
Examples/test-suite/char_binary.i
Normal file
29
Examples/test-suite/char_binary.i
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
A test case for testing non null terminated char pointers.
|
||||
*/
|
||||
|
||||
%module char_binary
|
||||
|
||||
%apply (char *STRING, size_t LENGTH) { (const char *str, size_t len) }
|
||||
|
||||
%inline %{
|
||||
struct Test {
|
||||
size_t strlen(const char *str, size_t len) {
|
||||
return len;
|
||||
}
|
||||
};
|
||||
|
||||
typedef char namet[5];
|
||||
namet var_namet;
|
||||
|
||||
typedef char* pchar;
|
||||
pchar var_pchar;
|
||||
%}
|
||||
|
||||
// Remove string handling typemaps and treat as pointer
|
||||
%typemap(freearg) SWIGTYPE * ""
|
||||
%apply SWIGTYPE * { char * }
|
||||
|
||||
%include "carrays.i"
|
||||
%array_functions(char, pchar);
|
||||
|
||||
|
|
@ -148,12 +148,14 @@ CPP_TEST_CASES += \
|
|||
cpp_static \
|
||||
cpp_typedef \
|
||||
default_args \
|
||||
default_arg_values \
|
||||
default_constructor \
|
||||
defvalue_constructor \
|
||||
derived_byvalue \
|
||||
derived_nested \
|
||||
destructor_reprotected \
|
||||
director_abstract \
|
||||
director_alternating \
|
||||
director_basic \
|
||||
director_classes \
|
||||
director_classic \
|
||||
|
|
@ -166,6 +168,7 @@ CPP_TEST_CASES += \
|
|||
director_finalizer \
|
||||
director_frob \
|
||||
director_ignore \
|
||||
director_keywords \
|
||||
director_namespace_clash \
|
||||
director_nested \
|
||||
director_overload \
|
||||
|
|
@ -228,9 +231,11 @@ CPP_TEST_CASES += \
|
|||
li_cpointer \
|
||||
li_stdint \
|
||||
li_typemaps \
|
||||
li_typemaps_apply \
|
||||
li_windows \
|
||||
long_long_apply \
|
||||
memberin_extend \
|
||||
member_funcptr_galore \
|
||||
member_pointer \
|
||||
member_template \
|
||||
minherit \
|
||||
|
|
@ -259,11 +264,13 @@ CPP_TEST_CASES += \
|
|||
null_pointer \
|
||||
operator_overload \
|
||||
operator_overload_break \
|
||||
operator_pointer_ref \
|
||||
operbool \
|
||||
ordering \
|
||||
overload_copy \
|
||||
overload_extend \
|
||||
overload_rename \
|
||||
overload_return_type \
|
||||
overload_simple \
|
||||
overload_subtype \
|
||||
overload_template \
|
||||
|
|
@ -283,6 +290,7 @@ CPP_TEST_CASES += \
|
|||
rename3 \
|
||||
rename4 \
|
||||
rename_scope \
|
||||
rename_simple \
|
||||
rename_strip_encoder \
|
||||
rename_pcre_encoder \
|
||||
rename_pcre_enum \
|
||||
|
|
@ -307,6 +315,7 @@ CPP_TEST_CASES += \
|
|||
smart_pointer_rename \
|
||||
smart_pointer_simple \
|
||||
smart_pointer_static \
|
||||
smart_pointer_template_const_overload \
|
||||
smart_pointer_templatemethods \
|
||||
smart_pointer_templatevariables \
|
||||
smart_pointer_typedef \
|
||||
|
|
@ -318,11 +327,11 @@ CPP_TEST_CASES += \
|
|||
struct_initialization_cpp \
|
||||
struct_value \
|
||||
symbol_clash \
|
||||
template \
|
||||
template_arg_replace \
|
||||
template_arg_scope \
|
||||
template_arg_typename \
|
||||
template_array_numeric \
|
||||
template_basic \
|
||||
template_base_template \
|
||||
template_classes \
|
||||
template_const_ref \
|
||||
|
|
@ -396,6 +405,7 @@ CPP_TEST_CASES += \
|
|||
typedef_scope \
|
||||
typedef_sizet \
|
||||
typedef_struct \
|
||||
typemap_arrays \
|
||||
typemap_delete \
|
||||
typemap_global_scope \
|
||||
typemap_namespace \
|
||||
|
|
@ -415,6 +425,7 @@ CPP_TEST_CASES += \
|
|||
using_extend \
|
||||
using_inherit \
|
||||
using_namespace \
|
||||
using_namespace_loop \
|
||||
using_pointers \
|
||||
using_private \
|
||||
using_protected \
|
||||
|
|
@ -423,6 +434,7 @@ CPP_TEST_CASES += \
|
|||
valuewrapper_const \
|
||||
valuewrapper_opaque \
|
||||
varargs \
|
||||
varargs_overload \
|
||||
virtual_destructor \
|
||||
virtual_poly \
|
||||
voidtest \
|
||||
|
|
@ -466,7 +478,7 @@ C_TEST_CASES += \
|
|||
extern_declaration \
|
||||
funcptr \
|
||||
function_typedef \
|
||||
immutable \
|
||||
immutable_values \
|
||||
inctest \
|
||||
integers \
|
||||
keyword_rename \
|
||||
|
|
@ -487,6 +499,8 @@ C_TEST_CASES += \
|
|||
overload_extendc \
|
||||
preproc \
|
||||
preproc_constants_c \
|
||||
preproc_defined \
|
||||
preproc_include \
|
||||
preproc_line_file \
|
||||
ret_by_value \
|
||||
simple_array \
|
||||
|
|
@ -504,6 +518,7 @@ C_TEST_CASES += \
|
|||
MULTI_CPP_TEST_CASES += \
|
||||
clientdata_prop \
|
||||
imports \
|
||||
import_stl \
|
||||
packageoption \
|
||||
mod \
|
||||
template_typedef_import \
|
||||
|
|
@ -511,6 +526,7 @@ MULTI_CPP_TEST_CASES += \
|
|||
|
||||
# Custom tests - tests with additional commandline options
|
||||
wallkw.cpptest: SWIGOPT += -Wallkw
|
||||
preproc_include.ctest: SWIGOPT += -includeall
|
||||
|
||||
|
||||
NOT_BROKEN_TEST_CASES = $(CPP_TEST_CASES:=.cpptest) \
|
||||
|
|
|
|||
|
|
@ -3,12 +3,17 @@
|
|||
%warnfilter(SWIGWARN_RUBY_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_PHP_MULTIPLE_INHERITANCE) C; /* Ruby, C#, Java, PHP multiple inheritance */
|
||||
SWIGWARN_D_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_PHP_MULTIPLE_INHERITANCE) C; /* Ruby, C#, D, Java, PHP multiple inheritance */
|
||||
|
||||
#ifdef SWIGCSHARP
|
||||
%ignore B::bar; // otherwise get a warning: `C.bar' no suitable methods found to override
|
||||
#endif
|
||||
|
||||
#ifdef SWIGD
|
||||
%ignore B::bar; // Prevents getting an error that C.bar does not override any function because multiple inheritance is not supported.
|
||||
#endif
|
||||
|
||||
%contract test_preassert(int a, int b) {
|
||||
require:
|
||||
a > 0;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,12 @@
|
|||
|
||||
%newobject Bar::testFoo;
|
||||
|
||||
%{
|
||||
#if defined(__SUNPRO_CC)
|
||||
#pragma error_messages (off, wbadasg) /* Assigning extern "C" ... */
|
||||
#endif
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
|
||||
class Foo {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
LANGUAGE = csharp
|
||||
SCRIPTSUFFIX = _runme.cs
|
||||
INTERPRETER = @CSHARPCILINTERPRETER@
|
||||
INTERPRETER_FLAGS = @CSHARPCILINTERPRETER_FLAGS@
|
||||
CSHARPPATHSEPARATOR = "@CSHARPPATHSEPARATOR@"
|
||||
CSHARPCYGPATH_W = @CSHARPCYGPATH_W@
|
||||
srcdir = @srcdir@
|
||||
|
|
@ -64,16 +65,17 @@ setup = \
|
|||
# Compiles C# files then runs the testcase. A testcase is only run if
|
||||
# a file is found which has _runme.cs appended after the testcase name.
|
||||
# Note C# uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows and SHLIB_PATH on HPUX.
|
||||
# DYLD_FALLBACK_LIBRARY_PATH is cleared for MacOSX.
|
||||
run_testcase = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
$(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
|
||||
CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
|
||||
CSHARPFLAGS='-nologo -debug+ $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
|
||||
CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile && \
|
||||
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" $(RUNTOOL) $(INTERPRETER) $*_runme.exe; \
|
||||
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_FALLBACK_LIBRARY_PATH= $(RUNTOOL) $(INTERPRETER) $(INTERPRETER_FLAGS) $*_runme.exe; \
|
||||
else \
|
||||
cd $* && \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
|
||||
CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \
|
||||
CSHARPFLAGS='-nologo -debug+ $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \
|
||||
CSHARPSRCS='`find . -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile; \
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,43 @@ public class csharp_prepost_runme {
|
|||
throw new Exception("Expecting CustomInt attribute");
|
||||
}
|
||||
}
|
||||
// Dates
|
||||
{
|
||||
// pre post typemap attributes example
|
||||
System.DateTime dateIn = new System.DateTime(2011, 4, 13);
|
||||
System.DateTime dateOut = new System.DateTime();
|
||||
|
||||
// Note in calls below, dateIn remains unchanged and dateOut
|
||||
// is set to a new value by the C++ call
|
||||
csharp_prepostNamespace.Action action = new csharp_prepostNamespace.Action(dateIn, out dateOut);
|
||||
if (dateOut != dateIn)
|
||||
throw new Exception("dates wrong");
|
||||
|
||||
dateIn = new System.DateTime(2012, 7, 14);
|
||||
action.doSomething(dateIn, out dateOut);
|
||||
if (dateOut != dateIn)
|
||||
throw new Exception("dates wrong");
|
||||
|
||||
System.DateTime refDate = new System.DateTime(1999, 12, 31);
|
||||
if (csharp_prepost.ImportantDate != refDate)
|
||||
throw new Exception("dates wrong");
|
||||
|
||||
refDate = new System.DateTime(1999, 12, 31);
|
||||
csharp_prepost.ImportantDate = refDate;
|
||||
System.DateTime importantDate = csharp_prepost.ImportantDate;
|
||||
if (importantDate != refDate)
|
||||
throw new Exception("dates wrong");
|
||||
|
||||
System.DateTime christmasEve = new System.DateTime(2000, 12, 24);
|
||||
csharp_prepost.addYears(ref christmasEve, 10);
|
||||
if (christmasEve != new System.DateTime(2010, 12, 24))
|
||||
throw new Exception("dates wrong");
|
||||
|
||||
Person person = new Person();
|
||||
person.Birthday = christmasEve;
|
||||
if (person.Birthday != christmasEve)
|
||||
throw new Exception("dates wrong");
|
||||
}
|
||||
}
|
||||
private static void Assert(double d1, double d2) {
|
||||
if (d1 != d2)
|
||||
|
|
|
|||
11
Examples/test-suite/csharp/director_alternating_runme.cs
Normal file
11
Examples/test-suite/csharp/director_alternating_runme.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
using System;
|
||||
using director_alternatingNamespace;
|
||||
|
||||
public class director_alternating_runme {
|
||||
public static void Main() {
|
||||
if (director_alternating.getBar().id() != director_alternating.idFromGetBar())
|
||||
throw new Exception("idFromGetBar failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -16,6 +16,7 @@ public class runme
|
|||
Foo f = b.create();
|
||||
FooBar fb = new FooBar();
|
||||
FooBar2 fb2 = new FooBar2();
|
||||
FooBar3 fb3 = new FooBar3();
|
||||
|
||||
String s;
|
||||
s = fb.used();
|
||||
|
|
@ -37,6 +38,21 @@ public class runme
|
|||
s = fb.pong();
|
||||
if ( s != ("Bar::pong();Foo::pong();FooBar::ping();"))
|
||||
throw new Exception("bad FooBar::pong");
|
||||
|
||||
// if (fb3.cheer() != "FooBar3::cheer();")
|
||||
// throw new Exception("bad fb3::cheer");
|
||||
|
||||
if (fb2.callping() != "FooBar2::ping();")
|
||||
throw new Exception("bad fb2.callping");
|
||||
|
||||
if (fb2.callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();")
|
||||
throw new Exception("bad fb2.callcheer");
|
||||
|
||||
if (fb3.callping() != "Bar::ping();")
|
||||
throw new Exception("bad fb3.callping");
|
||||
|
||||
if (fb3.callcheer() != "FooBar3::cheer();")
|
||||
throw new Exception("bad fb3.callcheer");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -69,4 +85,16 @@ class FooBar2 : Bar
|
|||
}
|
||||
}
|
||||
|
||||
class FooBar3 : Bar
|
||||
{
|
||||
public FooBar3() : base()
|
||||
{
|
||||
}
|
||||
|
||||
protected override String cheer()
|
||||
{
|
||||
return "FooBar3::cheer();";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -405,6 +405,28 @@ public class runme {
|
|||
if ((int)enum_thorough.repeatTest(repeat.llast) != 3) throw new Exception("repeatTest 5 failed");
|
||||
if ((int)enum_thorough.repeatTest(repeat.end) != 3) throw new Exception("repeatTest 6 failed");
|
||||
}
|
||||
// different types
|
||||
{
|
||||
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typeint) != 10) throw new Exception("differentTypes 1 failed");
|
||||
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typeboolfalse) != 0) throw new Exception("differentTypes 2 failed");
|
||||
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typebooltrue) != 1) throw new Exception("differentTypes 3 failed");
|
||||
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typebooltwo) != 2) throw new Exception("differentTypes 4 failed");
|
||||
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typechar) != 'C') throw new Exception("differentTypes 5 failed");
|
||||
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typedefaultint) != 'D') throw new Exception("differentTypes 6 failed");
|
||||
|
||||
int global_enum = enum_thorough.global_typeint;
|
||||
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed");
|
||||
global_enum = enum_thorough.global_typeboolfalse;
|
||||
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed");
|
||||
global_enum = enum_thorough.global_typebooltrue;
|
||||
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed");
|
||||
global_enum = enum_thorough.global_typebooltwo;
|
||||
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed");
|
||||
global_enum = enum_thorough.global_typechar;
|
||||
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed");
|
||||
global_enum = enum_thorough.global_typedefaultint;
|
||||
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -405,6 +405,28 @@ public class runme {
|
|||
if (enum_thorough_simple.repeatTest(enum_thorough_simple.llast) != 3) throw new Exception("repeatTest 5 failed");
|
||||
if (enum_thorough_simple.repeatTest(enum_thorough_simple.end) != 3) throw new Exception("repeatTest 6 failed");
|
||||
}
|
||||
// different types
|
||||
{
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typeint) != 10) throw new Exception("differentTypes 1 failed");
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typeboolfalse) != 0) throw new Exception("differentTypes 2 failed");
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typebooltrue) != 1) throw new Exception("differentTypes 3 failed");
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typebooltwo) != 2) throw new Exception("differentTypes 4 failed");
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typechar) != 'C') throw new Exception("differentTypes 5 failed");
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typedefaultint) != 'D') throw new Exception("differentTypes 6 failed");
|
||||
|
||||
int global_enum = enum_thorough_simple.global_typeint;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed");
|
||||
global_enum = enum_thorough_simple.global_typeboolfalse;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed");
|
||||
global_enum = enum_thorough_simple.global_typebooltrue;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed");
|
||||
global_enum = enum_thorough_simple.global_typebooltwo;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed");
|
||||
global_enum = enum_thorough_simple.global_typechar;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed");
|
||||
global_enum = enum_thorough_simple.global_typedefaultint;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -405,6 +405,28 @@ public class runme {
|
|||
if (enum_thorough_typesafe.repeatTest(repeat.llast).swigValue != 3) throw new Exception("repeatTest 5 failed");
|
||||
if (enum_thorough_typesafe.repeatTest(repeat.end).swigValue != 3) throw new Exception("repeatTest 6 failed");
|
||||
}
|
||||
// different types
|
||||
{
|
||||
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typeint).swigValue != 10) throw new Exception("differentTypes 1 failed");
|
||||
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typebooltrue).swigValue != 1) throw new Exception("differentTypes 2 failed");
|
||||
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typebooltwo).swigValue != 2) throw new Exception("differentTypes 3 failed");
|
||||
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typeboolfalse).swigValue != 0) throw new Exception("differentTypes 4 failed");
|
||||
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typechar).swigValue != (int)'C') throw new Exception("differentTypes 5 failed");
|
||||
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typedefaultint).swigValue != (int)'D') throw new Exception("differentTypes 6 failed");
|
||||
|
||||
int global_enum = enum_thorough_typesafe.global_typeint;
|
||||
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed");
|
||||
global_enum = enum_thorough_typesafe.global_typeboolfalse;
|
||||
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed");
|
||||
global_enum = enum_thorough_typesafe.global_typebooltrue;
|
||||
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed");
|
||||
global_enum = enum_thorough_typesafe.global_typebooltwo;
|
||||
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed");
|
||||
global_enum = enum_thorough_typesafe.global_typechar;
|
||||
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed");
|
||||
global_enum = enum_thorough_typesafe.global_typedefaultint;
|
||||
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
43
Examples/test-suite/csharp/friends_runme.cs
Normal file
43
Examples/test-suite/csharp/friends_runme.cs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using friendsNamespace;
|
||||
|
||||
public class friends_runme {
|
||||
public static void Main() {
|
||||
A a = new A(2);
|
||||
|
||||
if (friends.get_val1(a) != 2)
|
||||
throw new Exception("failed");
|
||||
if (friends.get_val2(a) != 4)
|
||||
throw new Exception("failed");
|
||||
if (friends.get_val3(a) != 6)
|
||||
throw new Exception("failed");
|
||||
|
||||
// nice overload working fine
|
||||
if (friends.get_val1(1,2,3) != 1)
|
||||
throw new Exception("failed");
|
||||
|
||||
B b = new B(3);
|
||||
|
||||
// David's case
|
||||
if (friends.mix(a,b) != 5)
|
||||
throw new Exception("failed");
|
||||
|
||||
D_d di = new D_d(2);
|
||||
D_d dd = new D_d(3.3);
|
||||
|
||||
// incredible template overloading working just fine
|
||||
if (friends.get_val1(di) != 2)
|
||||
throw new Exception("failed");
|
||||
if (friends.get_val1(dd) != 3.3)
|
||||
throw new Exception("failed");
|
||||
|
||||
friends.set(di, 4);
|
||||
friends.set(dd, 1.3);
|
||||
|
||||
if (friends.get_val1(di) != 4)
|
||||
throw new Exception("failed");
|
||||
if (friends.get_val1(dd) != 1.3)
|
||||
throw new Exception("failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -68,6 +68,7 @@ public class li_std_map_runme {
|
|||
{
|
||||
IList<string> keys = new List<string>(simap.Keys);
|
||||
IList<int> values = new List<int>(simap.Values);
|
||||
Dictionary<string, int> check = new Dictionary<string, int>();
|
||||
if (keys.Count != collectionSize)
|
||||
throw new Exception("Keys count test failed");
|
||||
|
||||
|
|
@ -78,6 +79,13 @@ public class li_std_map_runme {
|
|||
{
|
||||
if (simap[keys[i]] != values[i])
|
||||
throw new Exception("Keys and values test failed for index " + i);
|
||||
check.Add(keys[i], values[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < collectionSize; i++)
|
||||
{
|
||||
if (!check.ContainsKey(i.ToString()))
|
||||
throw new Exception("Keys and Values ContainsKey test " + i + " failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ using System;
|
|||
|
||||
public class runme
|
||||
{
|
||||
static void Main()
|
||||
static void Main()
|
||||
{
|
||||
// constructors and destructors
|
||||
nspaceNamespace.Outer.Inner1.Color color1 = new nspaceNamespace.Outer.Inner1.Color();
|
||||
|
|
@ -62,7 +62,7 @@ public class runme
|
|||
throw new ApplicationException("Transmission2 wrong");
|
||||
|
||||
// turn feature off / ignoring
|
||||
nspaceNamespace.Outer.nspace ns = new nspaceNamespace.Outer.nspace();
|
||||
nspaceNamespace.Outer.namespce ns = new nspaceNamespace.Outer.namespce();
|
||||
ns.Dispose();
|
||||
nspaceNamespace.NoNSpacePlease nons = new nspaceNamespace.NoNSpacePlease();
|
||||
nons.Dispose();
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue