summaryrefslogtreecommitdiff
path: root/Examples/go
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/go')
-rw-r--r--Examples/go/callback/Makefile12
-rw-r--r--Examples/go/callback/example.h1
-rw-r--r--Examples/go/callback/gocallback.go41
-rw-r--r--Examples/go/callback/index.html64
-rw-r--r--Examples/go/callback/runme.go16
-rw-r--r--Examples/go/check.list1
-rw-r--r--Examples/go/director/Makefile24
-rw-r--r--Examples/go/director/director.go72
-rw-r--r--Examples/go/director/director.h41
-rw-r--r--Examples/go/director/example.i11
-rw-r--r--Examples/go/director/index.html28
-rw-r--r--Examples/go/director/runme.go39
-rw-r--r--Examples/go/extend/Makefile12
-rw-r--r--Examples/go/extend/ceo.go37
-rw-r--r--Examples/go/extend/example.h2
-rw-r--r--Examples/go/extend/index.html13
-rw-r--r--Examples/go/extend/runme.go20
-rw-r--r--Examples/go/index.html45
18 files changed, 366 insertions, 113 deletions
diff --git a/Examples/go/callback/Makefile b/Examples/go/callback/Makefile
index bf5275f14..7441e09bd 100644
--- a/Examples/go/callback/Makefile
+++ b/Examples/go/callback/Makefile
@@ -1,6 +1,7 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
CXXSRCS = callback.cxx
+GOSRCS = gocallback.go
TARGET = example
INTERFACE = example.i
SWIGOPT =
@@ -9,8 +10,15 @@ check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp
+ if [ -n '$(SRCDIR)' ]; then \
+ cp $(GOSRCS:%=$(SRCDIR)/%) .; \
+ fi
+ @# Note: example.go gets generated by SWIG
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' GOSRCS='example.go $(GOSRCS)' \
+ SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp
clean:
+ if [ -n '$(SRCDIR)' ]; then \
+ rm $(GOSRCS) || true; \
+ fi
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean
diff --git a/Examples/go/callback/example.h b/Examples/go/callback/example.h
index 1a0e8c432..74ddad954 100644
--- a/Examples/go/callback/example.h
+++ b/Examples/go/callback/example.h
@@ -20,4 +20,3 @@ public:
void setCallback(Callback *cb) { delCallback(); _callback = cb; }
void call() { if (_callback) _callback->run(); }
};
-
diff --git a/Examples/go/callback/gocallback.go b/Examples/go/callback/gocallback.go
new file mode 100644
index 000000000..20fd0627a
--- /dev/null
+++ b/Examples/go/callback/gocallback.go
@@ -0,0 +1,41 @@
+package example
+
+import (
+ "fmt"
+)
+
+type GoCallback interface {
+ Callback
+ deleteCallback()
+ IsGoCallback()
+}
+
+type goCallback struct {
+ Callback
+}
+
+func (p *goCallback) deleteCallback() {
+ DeleteDirectorCallback(p.Callback)
+}
+
+func (p *goCallback) IsGoCallback() {}
+
+type overwrittenMethodsOnCallback struct {
+ p Callback
+}
+
+func NewGoCallback() GoCallback {
+ om := &overwrittenMethodsOnCallback{}
+ p := NewDirectorCallback(om)
+ om.p = p
+
+ return &goCallback{Callback: p}
+}
+
+func DeleteGoCallback(p GoCallback) {
+ p.deleteCallback()
+}
+
+func (p *goCallback) Run() {
+ fmt.Println("GoCallback.Run")
+}
diff --git a/Examples/go/callback/index.html b/Examples/go/callback/index.html
index b053cf547..9a53065b0 100644
--- a/Examples/go/callback/index.html
+++ b/Examples/go/callback/index.html
@@ -12,67 +12,17 @@
<H2>Implementing C++ callbacks in Go</H2>
<p>
-This example illustrates how to use directors to implement C++
-callbacks in Go.
-</p>
-
-<p>
-Because Go and C++ use inheritance differently, you must call a
-different function to create a class which uses callbacks. Instead of
-calling the usual constructor function whose name is <tt>New</tt>
-followed by the capitalized name of the class, you call a function
-named <tt>NewDirector</tt> followed by the capitalized name of the
-class.
-</p>
-
-<p>
-The first argument to the <tt>NewDirector</tt> function is an instance
-of a type. The <tt>NewDirector</tt> function will return an interface
-value as usual. However, when calling any method on the returned
-value, the program will first check whether the value passed
-to <tt>NewDirector</tt> implements that method. If it does, the
-method will be called in Go. This is true whether the method is
-called from Go code or C++ code.
-</p>
-
-<p>
-Note that the Go code will be called with just the Go value, not the
-C++ value. If the Go code needs to call a C++ method on itself, you
-need to get a copy of the C++ object. This is typically done as
-follows:
-
-<blockquote>
-<pre>
-type Child struct { abi Parent }
-func (p *Child) ChildMethod() {
- p.abi.ParentMethod()
-}
-func f() {
- p := &Child{nil}
- d := NewDirectorParent(p)
- p.abi = d
- ...
-}
-</pre>
-</blockquote>
-
-In other words, we first create the Go value. We pass that to
-the <tt>NewDirector</tt> function to create the C++ value; this C++
-value will be created with an association to the Go value. We then
-store the C++ value in the Go value, giving us the reverse
-association. That permits us to call parent methods from the child.
-
-</p>
-
-<p>
-To delete a director object, use the function <tt>DeleteDirector</tt>
-followed by the capitalized name of the class.
+This example illustrates how to use directors to implement C++ callbacks in Go.
+See the <a href="../../../Doc/Manual/Go.html#Go_director_classes">Go Director
+Classes</a> documentation subsection for an in-depth explanation how to use the
+director feature.
</p>
<p>
<ul>
-<li><a href="example.h">example.h</a>. Header file containing some enums.
-<li><a href="example.i">example.i</a>. Interface file.
+<li><a href="example.h">example.h</a>. Header with the definition of the Caller and Callback classes.
+<li><a href="example.i">example.i</a>. SWIG interface file.
+<li><a href="gocallback.go">gocallback.go</a>. Go source with the definition of the GoCallback class.
<li><a href="runme.go">runme.go</a>. Sample Go program.
</ul>
diff --git a/Examples/go/callback/runme.go b/Examples/go/callback/runme.go
index 2eef77fdb..03ab0c5e2 100644
--- a/Examples/go/callback/runme.go
+++ b/Examples/go/callback/runme.go
@@ -16,26 +16,18 @@ func main() {
caller.Call()
caller.DelCallback()
- callback = NewDirectorCallback(new(GoCallback))
+ go_callback := NewGoCallback()
fmt.Println()
fmt.Println("Adding and calling a Go callback")
- fmt.Println("------------------------------------")
+ fmt.Println("--------------------------------")
- caller.SetCallback(callback)
+ caller.SetCallback(go_callback)
caller.Call()
caller.DelCallback()
- // Test that a double delete does not occur as the object has
- // already been deleted from the C++ layer.
- DeleteDirectorCallback(callback)
+ DeleteGoCallback(go_callback)
fmt.Println()
fmt.Println("Go exit")
}
-
-type GoCallback struct{}
-
-func (p *GoCallback) Run() {
- fmt.Println("GoCallback.Run")
-}
diff --git a/Examples/go/check.list b/Examples/go/check.list
index 5399b8979..b3f34b306 100644
--- a/Examples/go/check.list
+++ b/Examples/go/check.list
@@ -2,6 +2,7 @@
callback
class
constants
+director
enum
extend
funcptr
diff --git a/Examples/go/director/Makefile b/Examples/go/director/Makefile
new file mode 100644
index 000000000..2e9e87b89
--- /dev/null
+++ b/Examples/go/director/Makefile
@@ -0,0 +1,24 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+GOSRCS = director.go
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
+
+build:
+ if [ -n '$(SRCDIR)' ]; then \
+ cp $(GOSRCS:%=$(SRCDIR)/%) .; \
+ fi
+ @# Note: example.go gets generated by SWIG
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' GOSRCS='example.go $(GOSRCS)' \
+ SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp
+
+clean:
+ if [ -n '$(SRCDIR)' ]; then \
+ rm $(GOSRCS) || true; \
+ fi
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean
diff --git a/Examples/go/director/director.go b/Examples/go/director/director.go
new file mode 100644
index 000000000..4f99bfc6d
--- /dev/null
+++ b/Examples/go/director/director.go
@@ -0,0 +1,72 @@
+package example
+
+// FooBarGo is a superset of FooBarAbstract and hence FooBarGo can be used as a
+// drop in replacement for FooBarAbstract but the reverse causes a compile time
+// error.
+type FooBarGo interface {
+ FooBarAbstract
+ deleteFooBarAbstract()
+ IsFooBarGo()
+}
+
+// Via embedding fooBarGo "inherits" all methods of FooBarAbstract.
+type fooBarGo struct {
+ FooBarAbstract
+}
+
+func (fbgs *fooBarGo) deleteFooBarAbstract() {
+ DeleteDirectorFooBarAbstract(fbgs.FooBarAbstract)
+}
+
+// The IsFooBarGo method ensures that FooBarGo is a superset of FooBarAbstract.
+// This is also how the class hierarchy gets represented by the SWIG generated
+// wrapper code. For an instance FooBarCpp has the IsFooBarAbstract and
+// IsFooBarCpp methods.
+func (fbgs *fooBarGo) IsFooBarGo() {}
+
+// Go type that defines the DirectorInterface. It contains the Foo and Bar
+// methods that overwrite the respective virtual C++ methods on FooBarAbstract.
+type overwrittenMethodsOnFooBarAbstract struct {
+ // Backlink to FooBarAbstract so that the rest of the class can be used by
+ // the overridden methods.
+ fb FooBarAbstract
+
+ // If additional constructor arguments have been given they are typically
+ // stored here so that the overriden methods can use them.
+}
+
+func (om *overwrittenMethodsOnFooBarAbstract) Foo() string {
+ // DirectorFooBarAbstractFoo calls the base method FooBarAbstract::Foo.
+ return "Go " + DirectorFooBarAbstractFoo(om.fb)
+}
+
+func (om *overwrittenMethodsOnFooBarAbstract) Bar() string {
+ return "Go Bar"
+}
+
+func NewFooBarGo() FooBarGo {
+ // Instantiate FooBarAbstract with selected methods overridden. The methods
+ // that will be overwritten are defined on
+ // overwrittenMethodsOnFooBarAbstract and have a compatible signature to the
+ // respective virtual C++ methods. Furthermore additional constructor
+ // arguments will be typically stored in the
+ // overwrittenMethodsOnFooBarAbstract struct.
+ om := &overwrittenMethodsOnFooBarAbstract{}
+ fb := NewDirectorFooBarAbstract(om)
+ om.fb = fb // Backlink causes cycle as fb.v = om!
+
+ fbgs := &fooBarGo{FooBarAbstract: fb}
+ // The memory of the FooBarAbstract director object instance can be
+ // automatically freed once the FooBarGo instance is garbage collected by
+ // uncommenting the following line. Please make sure to understand the
+ // runtime.SetFinalizer specific gotchas before doing this. Furthemore
+ // DeleteFooBarGo should be deleted if a finalizer is in use or the fooBarGo
+ // struct needs additional data to prevent double deletion.
+ // runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbstract)
+ return fbgs
+}
+
+// Recommended to be removed if runtime.SetFinalizer is in use.
+func DeleteFooBarGo(fbg FooBarGo) {
+ fbg.deleteFooBarAbstract()
+}
diff --git a/Examples/go/director/director.h b/Examples/go/director/director.h
new file mode 100644
index 000000000..339a9adcd
--- /dev/null
+++ b/Examples/go/director/director.h
@@ -0,0 +1,41 @@
+#ifndef DIRECTOR_H
+#define DIRECTOR_H
+
+
+#include <stdio.h>
+#include <string>
+
+
+class FooBarAbstract
+{
+public:
+ FooBarAbstract() {};
+ virtual ~FooBarAbstract() {};
+
+ std::string FooBar() {
+ return this->Foo() + ", " + this->Bar();
+ };
+
+protected:
+ virtual std::string Foo() {
+ return "Foo";
+ };
+
+ virtual std::string Bar() = 0;
+};
+
+
+class FooBarCpp : public FooBarAbstract
+{
+protected:
+ virtual std::string Foo() {
+ return "C++ " + FooBarAbstract::Foo();
+ }
+
+ virtual std::string Bar() {
+ return "C++ Bar";
+ }
+};
+
+
+#endif
diff --git a/Examples/go/director/example.i b/Examples/go/director/example.i
new file mode 100644
index 000000000..e832bd8c6
--- /dev/null
+++ b/Examples/go/director/example.i
@@ -0,0 +1,11 @@
+/* File : example.i */
+%module(directors="1") example
+
+%include "std_string.i"
+
+%header %{
+#include "director.h"
+%}
+
+%feature("director") FooBarAbstract;
+%include "director.h"
diff --git a/Examples/go/director/index.html b/Examples/go/director/index.html
new file mode 100644
index 000000000..b93e780e5
--- /dev/null
+++ b/Examples/go/director/index.html
@@ -0,0 +1,28 @@
+<html>
+<head>
+<title>SWIG:Examples:go:director</title>
+</head>
+
+<body bgcolor="#ffffff">
+
+<tt>SWIG/Examples/go/director/</tt>
+<hr>
+
+<H2>How to subclass a C++ class with a Go type</H2>
+
+<p>
+See the <a href="../../../Doc/Manual/Go.html#Go_director_classes">Go Director
+Classes</a> documentation subsection for an explanation of this example.
+</p>
+
+<p>
+<ul>
+<li><a href="director.go">director.go</a>. Go source with the definition of the FooBarGo class.
+<li><a href="director.h">director.h</a>. Header with the definition of the FooBarAbstract and FooBarCpp classes.
+<li><a href="example.i">example.i</a>. SWIG interface file.
+<li><a href="runme.go">runme.go</a>. Sample Go program.
+</ul>
+
+<hr>
+</body>
+</html>
diff --git a/Examples/go/director/runme.go b/Examples/go/director/runme.go
new file mode 100644
index 000000000..0d839bc88
--- /dev/null
+++ b/Examples/go/director/runme.go
@@ -0,0 +1,39 @@
+package main
+
+import (
+ "./example"
+ "fmt"
+ "os"
+)
+
+func Compare(name string, got string, exp string) error {
+ fmt.Printf("%s; Got: '%s'; Expected: '%s'\n", name, got, exp)
+ if got != exp {
+ return fmt.Errorf("%s returned unexpected string! Got: '%s'; Expected: '%s'\n", name, got, exp)
+ }
+ return nil
+}
+
+func TestFooBarCpp() error {
+ fb := example.NewFooBarCpp()
+ defer example.DeleteFooBarCpp(fb)
+ return Compare("FooBarCpp.FooBar()", fb.FooBar(), "C++ Foo, C++ Bar")
+}
+
+func TestFooBarGo() error {
+ fb := example.NewFooBarGo()
+ defer example.DeleteFooBarGo(fb)
+ return Compare("FooBarGo.FooBar()", fb.FooBar(), "Go Foo, Go Bar")
+}
+
+func main() {
+ fmt.Println("Test output:")
+ fmt.Println("------------")
+ err := TestFooBarCpp()
+ err = TestFooBarGo()
+ fmt.Println("------------")
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Tests failed! Last error: %s\n", err.Error())
+ os.Exit(1)
+ }
+}
diff --git a/Examples/go/extend/Makefile b/Examples/go/extend/Makefile
index 290694210..a9f2d8d7d 100644
--- a/Examples/go/extend/Makefile
+++ b/Examples/go/extend/Makefile
@@ -1,6 +1,7 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
CXXSRCS = extend.cxx
+GOSRCS = ceo.go
TARGET = example
INTERFACE = example.i
SWIGOPT =
@@ -9,8 +10,15 @@ check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp
+ if [ -n '$(SRCDIR)' ]; then \
+ cp $(GOSRCS:%=$(SRCDIR)/%) .; \
+ fi
+ @# Note: example.go gets generated by SWIG
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' GOSRCS='example.go $(GOSRCS)' \
+ SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp
clean:
+ if [ -n '$(SRCDIR)' ]; then \
+ rm $(GOSRCS) || true; \
+ fi
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean
diff --git a/Examples/go/extend/ceo.go b/Examples/go/extend/ceo.go
new file mode 100644
index 000000000..8f00c92f2
--- /dev/null
+++ b/Examples/go/extend/ceo.go
@@ -0,0 +1,37 @@
+package example
+
+type CEO interface {
+ Manager
+ deleteManager()
+ IsCEO()
+}
+
+type ceo struct {
+ Manager
+}
+
+func (p *ceo) deleteManager() {
+ DeleteDirectorManager(p.Manager)
+}
+
+func (p *ceo) IsCEO() {}
+
+type overwrittenMethodsOnManager struct {
+ p Manager
+}
+
+func NewCEO(name string) CEO {
+ om := &overwrittenMethodsOnManager{}
+ p := NewDirectorManager(om, name)
+ om.p = p
+
+ return &ceo{Manager: p}
+}
+
+func DeleteCEO(p CEO) {
+ p.deleteManager()
+}
+
+func (p *ceo) GetPosition() string {
+ return "CEO"
+}
diff --git a/Examples/go/extend/example.h b/Examples/go/extend/example.h
index ca1aed28f..0c3b721bd 100644
--- a/Examples/go/extend/example.h
+++ b/Examples/go/extend/example.h
@@ -44,7 +44,7 @@ public:
const Employee *get_item(int i) {
return list[i];
}
- ~EmployeeList() {
+ ~EmployeeList() {
std::vector<Employee*>::iterator i;
std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl;
for (i=list.begin(); i!=list.end(); i++) {
diff --git a/Examples/go/extend/index.html b/Examples/go/extend/index.html
index 471fa9cdc..31788b2aa 100644
--- a/Examples/go/extend/index.html
+++ b/Examples/go/extend/index.html
@@ -12,13 +12,16 @@
<H2>Extending a simple C++ class in Go</H2>
<p>
-This example illustrates the extending of a C++ class with cross
-language polymorphism.
-
+This example illustrates how to inherit from a C++ class in Go.
+See the <a href="../../../Doc/Manual/Go.html#Go_director_classes">Go Director
+Classes</a> documentation subsection for an in-depth explanation how to use the
+director feature.
<p>
+
<ul>
-<li><a href="example.h">example.h</a>. Header file containing some enums.
-<li><a href="example.i">example.i</a>. Interface file.
+<li><a href="ceo.go">ceo.go</a>. Go source with the definition of the CEO class.
+<li><a href="example.h">example.h</a>. Header with the definition of the Employee, Manager and EmployeeList classes.
+<li><a href="example.i">example.i</a>. SWIG interface file.
<li><a href="runme.go">runme.go</a>. Sample Go program.
</ul>
diff --git a/Examples/go/extend/runme.go b/Examples/go/extend/runme.go
index 770e27802..a56968937 100644
--- a/Examples/go/extend/runme.go
+++ b/Examples/go/extend/runme.go
@@ -7,19 +7,12 @@ import (
"fmt"
)
-type CEO struct{}
-
-func (p *CEO) GetPosition() string {
- return "CEO"
-}
-
func main() {
// Create an instance of CEO, a class derived from the Go
// 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().
-
- e := NewDirectorManager(new(CEO), "Alice")
+ e := NewCEO("Alice")
fmt.Println(e.GetName(), " is a ", e.GetPosition())
fmt.Println("Just call her \"", e.GetTitle(), "\"")
fmt.Println("----------------------")
@@ -27,7 +20,6 @@ func main() {
// Create a new EmployeeList instance. This class does not
// have a C++ director wrapper, but can be used freely with
// other classes that do.
-
list := NewEmployeeList()
// EmployeeList owns its items, so we must surrender ownership
@@ -49,15 +41,13 @@ func main() {
// CEO, but now Go 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 Java CEO implementation of
+ // ending up back at the Go 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 Java implementation
+ // through the C++ director class to the Go implementation
// in CEO. All this routing takes place transparently.
-
fmt.Println("(position, title) for items 0-3:")
-
fmt.Println(" ", list.Get_item(0).GetPosition(), ", \"", list.Get_item(0).GetTitle(), "\"")
fmt.Println(" ", list.Get_item(1).GetPosition(), ", \"", list.Get_item(1).GetTitle(), "\"")
fmt.Println(" ", list.Get_item(2).GetPosition(), ", \"", list.Get_item(2).GetTitle(), "\"")
@@ -66,11 +56,11 @@ func main() {
// Time to delete the EmployeeList, which will delete all the
// Employee* items it contains. The last item is our CEO,
- // which gets destroyed as well.
+ // which gets destroyed as well and hence there is no need to
+ // call DeleteCEO.
DeleteEmployeeList(list)
fmt.Println("----------------------")
// All done.
-
fmt.Println("Go exit")
}
diff --git a/Examples/go/index.html b/Examples/go/index.html
index 21dda21b5..467f4ecb7 100644
--- a/Examples/go/index.html
+++ b/Examples/go/index.html
@@ -23,6 +23,7 @@ certain C declarations are turned into constants.
<li><a href="template/index.html">template</a>. C++ templates.
<li><a href="callback/index.html">callback</a>. C++ callbacks using directors.
<li><a href="extend/index.html">extend</a>. Polymorphism using directors.
+<li><a href="director/index.html">director</a>. Example how to utilize the director feature.
</ul>
<h2>Compilation Issues</h2>
@@ -37,20 +38,23 @@ certain C declarations are turned into constants.
</blockquote>
<li>On Unix the compilation of examples is done using the
-file <tt>Example/Makefile</tt>. This makefile performs a manual
-module compilation which is platform specific. When using
-the <tt>6g</tt> or <tt>8g</tt> compiler, the steps look like this
+file <tt>Example/Makefile</tt>. Normally builds are done simply
+using <tt>go build</tt>. For testing purposes this makefile performs
+a manual module compilation that is platform specific. When using
+the <tt>gc</tt> compiler, the steps look approximately like this
(GNU/Linux):
<blockquote>
<pre>
-% swig -go interface.i
-% gcc -fpic -c interface_wrap.c
-% gcc -shared interface_wrap.o $(OBJS) -o interfacemodule.so
-% 6g interface.go
-% 6c interface_gc.c
-% gopack grc interface.a interface.6 interface_gc.6
-% 6l program.6
+% swig -go -cgo interface.i
+% mkdir -p gopath/src/interface
+% cp interface_wrap.c interface_wrap.h interface.go gopath/src/interface
+% GOPATH=`pwd`/gopath
+% export GOPATH
+% cd gopath/src/interface
+% go build
+% go tool compile $(SRCDIR)/runme.go
+% go tool link -o runme runme.o
</pre>
</blockquote>
@@ -58,10 +62,15 @@ the <tt>6g</tt> or <tt>8g</tt> compiler, the steps look like this
<blockquote>
<pre>
-% swig -go interface.i
-% gcc -c interface_wrap.c
-% gccgo -c interface.go
-% gccgo program.o interface.o interface_wrap.o
+% swig -go -cgo interface.i
+% mkdir -p gopath/src/interface
+% cp interface_wrap.c interface_wrap.h interface.go gopath/src/interface
+% GOPATH=`pwd`/gopath
+% export GOPATH
+% cd gopath/src/interface
+% go build
+% gccgo -c $(SRCDIR)/runme.go
+% gccgo -o runme runme.o interface.a
</pre>
</blockquote
@@ -76,14 +85,14 @@ The examples have been extensively tested on the following platforms:
</ul>
All of the examples were last tested with the following configuration
-(10 May 2010):
+(5 August 2015):
<ul>
-<li>Ubuntu Hardy
-<li>gcc-4.2.4
+<li>Ubuntu Trusty
+<li>gcc-4.8.4
</ul>
-Your mileage may vary. If you experience a problem, please let us know by
+Your mileage may vary. If you experience a problem, please let us know by
contacting us on the <a href="http://www.swig.org/mail.html">mailing lists</a>.
</body>
</html>