[Go] Renamed 'FooBarAbs' to 'FooBarAbstract' in the documentation and examples.

This commit is contained in:
Michael Schaller 2015-08-09 14:32:23 +02:00
commit 608ef60ecf
5 changed files with 144 additions and 140 deletions

View file

@ -606,22 +606,22 @@ completely to avoid common pitfalls with directors in Go.
<H4><a name="Go_director_example_cpp_code"></a>23.4.7.1 Example C++ code</H4> <H4><a name="Go_director_example_cpp_code"></a>23.4.7.1 Example C++ code</H4>
<p> <p>
The step by step guide is based on two example C++ classes. FooBarAbs is an The step by step guide is based on two example C++ classes. FooBarAbstract is
abstract C++ class and the FooBarCpp class inherits from it. This guide an abstract C++ class and the FooBarCpp class inherits from it. This guide
explains how to implement a FooBarGo class similar to the FooBarCpp class. explains how to implement a FooBarGo class similar to the FooBarCpp class.
</p> </p>
<p> <p>
<tt>FooBarAbs</tt> abstract C++ class: <tt>FooBarAbstract</tt> abstract C++ class:
</p> </p>
<div class="code"> <div class="code">
<pre> <pre>
class FooBarAbs class FooBarAbstract
{ {
public: public:
FooBarAbs() {}; FooBarAbstract() {};
virtual ~FooBarAbs() {}; virtual ~FooBarAbstract() {};
std::string FooBar() { std::string FooBar() {
return this->Foo() + ", " + this->Bar(); return this->Foo() + ", " + this->Bar();
@ -643,11 +643,11 @@ protected:
<div class="code"> <div class="code">
<pre> <pre>
class FooBarCpp : public FooBarAbs class FooBarCpp : public FooBarAbstract
{ {
protected: protected:
virtual std::string Foo() { virtual std::string Foo() {
return "C++ " + FooBarAbs::Foo(); return "C++ " + FooBarAbstract::Foo();
} }
virtual std::string Bar() { virtual std::string Bar() {
@ -691,14 +691,14 @@ directive, like this:
<p> <p>
Second, you must use the %feature("director") directive to tell SWIG which Second, you must use the %feature("director") directive to tell SWIG which
classes should get directors. In the example the FooBarAbs class needs the classes should get directors. In the example the FooBarAbstract class needs the
director feature enabled so that the FooBarGo class can inherit from it, like director feature enabled so that the FooBarGo class can inherit from it, like
this: this:
</p> </p>
<div class="code"> <div class="code">
<pre> <pre>
%feature("director") FooBarAbs; %feature("director") FooBarAbstract;
</pre> </pre>
</div> </div>
@ -782,21 +782,21 @@ As an example see part of the <tt>FooBarGo</tt> class:
<div class="code"> <div class="code">
<pre> <pre>
type overwrittenMethodsOnFooBarAbs struct { type overwrittenMethodsOnFooBarAbstract struct {
fb FooBarAbs fb FooBarAbstract
} }
func (om *overwrittenMethodsOnFooBarAbs) Foo() string { func (om *overwrittenMethodsOnFooBarAbstract) Foo() string {
... ...
} }
func (om *overwrittenMethodsOnFooBarAbs) Bar() string { func (om *overwrittenMethodsOnFooBarAbstract) Bar() string {
... ...
} }
func NewFooBarGo() FooBarGo { func NewFooBarGo() FooBarGo {
om := &amp;overwrittenMethodsOnFooBarAbs{} om := &amp;overwrittenMethodsOnFooBarAbstract{}
fb := NewDirectorFooBarAbs(om) fb := NewDirectorFooBarAbstract(om)
om.fb = fb om.fb = fb
... ...
} }
@ -806,25 +806,25 @@ func NewFooBarGo() FooBarGo {
<p> <p>
The complete example, including the <tt>FooBarGoo</tt> class implementation, can The complete example, including the <tt>FooBarGoo</tt> class implementation, can
be found in <a href="#Go_director_foobargo_class">the end of the guide</a>. In be found in <a href="#Go_director_foobargo_class">the end of the guide</a>. In
this part of the example the virtual methods <tt>FooBarAbs::Foo</tt> and this part of the example the virtual methods <tt>FooBarAbstract::Foo</tt> and
<tt>FooBarAbs::Bar</tt> have been overwritten with Go methods similarly to how <tt>FooBarAbstract::Bar</tt> have been overwritten with Go methods similarly to
the <tt>FooBarAbs</tt> virtual methods are overwritten by the <tt>FooBarCpp</tt> how the <tt>FooBarAbstract</tt> virtual methods are overwritten by the
class. <tt>FooBarCpp</tt> class.
</p> </p>
<p> <p>
The <tt>DirectorInterface</tt> in the example is implemented by the The <tt>DirectorInterface</tt> in the example is implemented by the
<tt>overwrittenMethodsOnFooBarAbs</tt> Go struct type. A pointer to a <tt>overwrittenMethodsOnFooBarAbstract</tt> Go struct type. A pointer to a
<tt>overwrittenMethodsOnFooBarAbs</tt> struct instance will be given to the <tt>overwrittenMethodsOnFooBarAbstract</tt> struct instance will be given to the
<tt>NewDirectorFooBarAbs</tt> constructor function. The constructor return <tt>NewDirectorFooBarAbstract</tt> constructor function. The constructor return
value implements the <tt>FooBarAbs</tt> interface. value implements the <tt>FooBarAbstract</tt> interface.
<tt>overwrittenMethodsOnFooBarAbs</tt> could in theory be any Go type but in <tt>overwrittenMethodsOnFooBarAbstract</tt> could in theory be any Go type but
practice a struct is used as it typically contains at least a value of the in practice a struct is used as it typically contains at least a value of the
C++ class interface so that the overwritten methods can use the rest of the C++ class interface so that the overwritten methods can use the rest of the
C++ class. If the <tt>FooBarGo</tt> class would receive additional constructor C++ class. If the <tt>FooBarGo</tt> class would receive additional constructor
arguments then these would also typically be stored in the arguments then these would also typically be stored in the
<tt>overwrittenMethodsOnFooBarAbs</tt> struct so that they can be used by the <tt>overwrittenMethodsOnFooBarAbstract</tt> struct so that they can be used by
Go methods. the Go methods.
</p> </p>
@ -840,7 +840,7 @@ the method in the base class. This is also the case for the
<div class="code"> <div class="code">
<pre> <pre>
virtual std::string Foo() { virtual std::string Foo() {
return "C++ " + FooBarAbs::Foo(); return "C++ " + FooBarAbstract::Foo();
} }
</pre> </pre>
</div> </div>
@ -853,8 +853,8 @@ The <tt>FooBarGo.Foo</tt> implementation in the example looks like this:
<div class="code"> <div class="code">
<pre> <pre>
func (om *overwrittenMethodsOnFooBarAbs) Foo() string { func (om *overwrittenMethodsOnFooBarAbstract) Foo() string {
return "Go " + DirectorFooBarAbsFoo(om.fb) return "Go " + DirectorFooBarAbstractFoo(om.fb)
} }
</pre> </pre>
</div> </div>
@ -887,31 +887,31 @@ this:
<div class="code"> <div class="code">
<pre> <pre>
type FooBarGo interface { type FooBarGo interface {
FooBarAbs FooBarAbstract
deleteFooBarAbs() deleteFooBarAbstract()
IsFooBarGo() IsFooBarGo()
} }
type fooBarGo struct { type fooBarGo struct {
FooBarAbs FooBarAbstract
} }
func (fbgs *fooBarGo) deleteFooBarAbs() { func (fbgs *fooBarGo) deleteFooBarAbstract() {
DeleteDirectorFooBarAbs(fbgs.FooBarAbs) DeleteDirectorFooBarAbstract(fbgs.FooBarAbstract)
} }
func (fbgs *fooBarGo) IsFooBarGo() {} func (fbgs *fooBarGo) IsFooBarGo() {}
func NewFooBarGo() FooBarGo { func NewFooBarGo() FooBarGo {
om := &amp;overwrittenMethodsOnFooBarAbs{} om := &amp;overwrittenMethodsOnFooBarAbstract{}
fb := NewDirectorFooBarAbs(om) fb := NewDirectorFooBarAbstract(om)
om.fb = fb om.fb = fb
return &amp;fooBarGo{FooBarAbs: fb} return &amp;fooBarGo{FooBarAbstract: fb}
} }
func DeleteFooBarGo(fbg FooBarGo) { func DeleteFooBarGo(fbg FooBarGo) {
fbg.deleteFooBarAbs() fbg.deleteFooBarAbstract()
} }
</pre> </pre>
</div> </div>
@ -921,12 +921,12 @@ func DeleteFooBarGo(fbg FooBarGo) {
The complete example, including the <tt>FooBarGoo</tt> class implementation, can The complete example, including the <tt>FooBarGoo</tt> class implementation, can
be found in <a href="#Go_director_foobargo_class">the end of the guide</a>. In be found in <a href="#Go_director_foobargo_class">the end of the guide</a>. In
this part of the example the private <tt>fooBarGo</tt> struct embeds <tt> this part of the example the private <tt>fooBarGo</tt> struct embeds <tt>
FooBarAbs</tt> which lets the <tt>fooBarGo</tt> Go type "inherit" all the FooBarAbstract</tt> which lets the <tt>fooBarGo</tt> Go type "inherit" all the
methods of the <tt>FooBarAbs</tt> C++ class by means of embedding. The public methods of the <tt>FooBarAbstract</tt> C++ class by means of embedding. The
<tt>FooBarGo</tt> interface type includes the <tt>FooBarAbs</tt> interface and public <tt>FooBarGo</tt> interface type includes the <tt>FooBarAbstract</tt>
hence <tt>FooBarGo</tt> can be used as a drop in replacement for interface and hence <tt>FooBarGo</tt> can be used as a drop in replacement for
<tt>FooBarAbs</tt> while the reverse isn't possible and would raise a compile <tt>FooBarAbstract</tt> while the reverse isn't possible and would raise a
time error. Furthemore the constructor and destructor functions <tt> compile time error. Furthemore the constructor and destructor functions <tt>
NewFooBarGo</tt> and <tt>DeleteFooBarGo</tt> take care of all the director NewFooBarGo</tt> and <tt>DeleteFooBarGo</tt> take care of all the director
specifics and to the user the class appears as any other SWIG wrapped C++ specifics and to the user the class appears as any other SWIG wrapped C++
class. class.
@ -946,13 +946,13 @@ in the <tt>FooBarGo</tt> class is here:
<div class="code"> <div class="code">
<pre> <pre>
type overwrittenMethodsOnFooBarAbs struct { type overwrittenMethodsOnFooBarAbstract struct {
fb FooBarAbs fb FooBarAbstract
} }
func NewFooBarGo() FooBarGo { func NewFooBarGo() FooBarGo {
om := &amp;overwrittenMethodsOnFooBarAbs{} om := &amp;overwrittenMethodsOnFooBarAbstract{}
fb := NewDirectorFooBarAbs(om) // fb.v = om fb := NewDirectorFooBarAbstract(om) // fb.v = om
om.fb = fb // Backlink causes cycle as fb.v = om! om.fb = fb // Backlink causes cycle as fb.v = om!
... ...
} }
@ -963,27 +963,27 @@ func NewFooBarGo() FooBarGo {
In order to be able to use <tt>runtime.SetFinalizer</tt> nevertheless the In order to be able to use <tt>runtime.SetFinalizer</tt> nevertheless the
finalizer needs to be set on something that isn't in a cycle and that references finalizer needs to be set on something that isn't in a cycle and that references
the director object instance. In the <tt>FooBarGo</tt> class example the <tt> the director object instance. In the <tt>FooBarGo</tt> class example the <tt>
FooBarAbs</tt> director instance can be automatically deleted by setting the FooBarAbstract</tt> director instance can be automatically deleted by setting
finalizer on <tt>fooBarGo</tt>: the finalizer on <tt>fooBarGo</tt>:
</p> </p>
<div class="code"> <div class="code">
<pre> <pre>
type fooBarGo struct { type fooBarGo struct {
FooBarAbs FooBarAbstract
} }
type overwrittenMethodsOnFooBarAbs struct { type overwrittenMethodsOnFooBarAbstract struct {
fb FooBarAbs fb FooBarAbstract
} }
func NewFooBarGo() FooBarGo { func NewFooBarGo() FooBarGo {
om := &amp;overwrittenMethodsOnFooBarAbs{} om := &amp;overwrittenMethodsOnFooBarAbstract{}
fb := NewDirectorFooBarAbs(om) fb := NewDirectorFooBarAbstract(om)
om.fb = fb // Backlink causes cycle as fb.v = om! om.fb = fb // Backlink causes cycle as fb.v = om!
fbgs := &amp;fooBarGo{FooBarAbs: fb} fbgs := &amp;fooBarGo{FooBarAbstract: fb}
runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbs) runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbstract)
return fbgs return fbgs
} }
</pre> </pre>
@ -1007,73 +1007,75 @@ The complete and annotated <tt>FooBarGo</tt> class looks like this:
<div class="code"> <div class="code">
<pre> <pre>
// FooBarGo is a superset of FooBarAbs and hence FooBarGo can be used as a drop // FooBarGo is a superset of FooBarAbstract and hence FooBarGo can be used as a
// in replacement for FooBarAbs but the reverse causes a compile time error. // drop in replacement for FooBarAbstract but the reverse causes a compile time
// error.
type FooBarGo interface { type FooBarGo interface {
FooBarAbs FooBarAbstract
deleteFooBarAbs() deleteFooBarAbstract()
IsFooBarGo() IsFooBarGo()
} }
// Via embedding fooBarGo "inherits" all methods of FooBarAbs. // Via embedding fooBarGo "inherits" all methods of FooBarAbstract.
type fooBarGo struct { type fooBarGo struct {
FooBarAbs FooBarAbstract
} }
func (fbgs *fooBarGo) deleteFooBarAbs() { func (fbgs *fooBarGo) deleteFooBarAbstract() {
DeleteDirectorFooBarAbs(fbgs.FooBarAbs) DeleteDirectorFooBarAbstract(fbgs.FooBarAbstract)
} }
// The IsFooBarGo method ensures that FooBarGo is a superset of FooBarAbs. // The IsFooBarGo method ensures that FooBarGo is a superset of FooBarAbstract.
// This is also how the class hierarchy gets represented by the SWIG generated // This is also how the class hierarchy gets represented by the SWIG generated
// wrapper code. For an instance FooBarCpp has the IsFooBarAbs and IsFooBarCpp // wrapper code. For an instance FooBarCpp has the IsFooBarAbstract and
// methods. // IsFooBarCpp methods.
func (fbgs *fooBarGo) IsFooBarGo() {} func (fbgs *fooBarGo) IsFooBarGo() {}
// Go type that defines the DirectorInterface. It contains the Foo and Bar // Go type that defines the DirectorInterface. It contains the Foo and Bar
// methods that overwrite the respective virtual C++ methods on FooBarAbs. // methods that overwrite the respective virtual C++ methods on FooBarAbstract.
type overwrittenMethodsOnFooBarAbs struct { type overwrittenMethodsOnFooBarAbstract struct {
// Backlink to FooBarAbs so that the rest of the class can be used by the // Backlink to FooBarAbstract so that the rest of the class can be used by
// overridden methods. // the overridden methods.
fb FooBarAbs fb FooBarAbstract
// If additional constructor arguments have been given they are typically // If additional constructor arguments have been given they are typically
// stored here so that the overriden methods can use them. // stored here so that the overriden methods can use them.
} }
func (om *overwrittenMethodsOnFooBarAbs) Foo() string { func (om *overwrittenMethodsOnFooBarAbstract) Foo() string {
// DirectorFooBarAbsFoo calls the base method FooBarAbs::Foo. // DirectorFooBarAbstractFoo calls the base method FooBarAbstract::Foo.
return "Go " + DirectorFooBarAbsFoo(om.fb) return "Go " + DirectorFooBarAbstractFoo(om.fb)
} }
func (om *overwrittenMethodsOnFooBarAbs) Bar() string { func (om *overwrittenMethodsOnFooBarAbstract) Bar() string {
return "Go Bar" return "Go Bar"
} }
func NewFooBarGo() FooBarGo { func NewFooBarGo() FooBarGo {
// Instantiate FooBarAbs with selected methods overridden. The methods that // Instantiate FooBarAbstract with selected methods overridden. The methods
// will be overwritten are defined on overwrittenMethodsOnFooBarAbs and have // that will be overwritten are defined on
// a compatible signature to the respective virtual C++ methods. // overwrittenMethodsOnFooBarAbstract and have a compatible signature to the
// Furthermore additional constructor arguments will be typically stored in // respective virtual C++ methods. Furthermore additional constructor
// the overwrittenMethodsOnFooBarAbs struct. // arguments will be typically stored in the
om := &amp;overwrittenMethodsOnFooBarAbs{} // overwrittenMethodsOnFooBarAbstract struct.
fb := NewDirectorFooBarAbs(om) om := &amp;overwrittenMethodsOnFooBarAbstract{}
fb := NewDirectorFooBarAbstract(om)
om.fb = fb // Backlink causes cycle as fb.v = om! om.fb = fb // Backlink causes cycle as fb.v = om!
fbgs := &amp;fooBarGo{FooBarAbs: fb} fbgs := &amp;fooBarGo{FooBarAbstract: fb}
// The memory of the FooBarAbs director object instance can be automatically // The memory of the FooBarAbstract director object instance can be
// freed once the FooBarGo instance is garbage collected by uncommenting the // automatically freed once the FooBarGo instance is garbage collected by
// following line. Please make sure to understand the runtime.SetFinalizer // uncommenting the following line. Please make sure to understand the
// specific gotchas before doing this. Furthemore DeleteFooBarGo should be // runtime.SetFinalizer specific gotchas before doing this. Furthemore
// deleted if a finalizer is in use or the fooBarGo struct needs additional // DeleteFooBarGo should be deleted if a finalizer is in use or the fooBarGo
// data to prevent double deletion. // struct needs additional data to prevent double deletion.
// runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbs) // runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbstract)
return fbgs return fbgs
} }
// Recommended to be removed if runtime.SetFinalizer is in use. // Recommended to be removed if runtime.SetFinalizer is in use.
func DeleteFooBarGo(fbg FooBarGo) { func DeleteFooBarGo(fbg FooBarGo) {
fbg.deleteFooBarAbs() fbg.deleteFooBarAbstract()
} }
</pre> </pre>
</div> </div>
@ -1094,11 +1096,11 @@ For comparison the <tt>FooBarCpp</tt> class looks like this:
<div class="code"> <div class="code">
<pre> <pre>
class FooBarCpp : public FooBarAbs class FooBarCpp : public FooBarAbstract
{ {
protected: protected:
virtual std::string Foo() { virtual std::string Foo() {
return "C++ " + FooBarAbs::Foo(); return "C++ " + FooBarAbstract::Foo();
} }
virtual std::string Bar() { virtual std::string Bar() {

View file

@ -1,70 +1,72 @@
package example package example
// FooBarGo is a superset of FooBarAbs and hence FooBarGo can be used as a drop // FooBarGo is a superset of FooBarAbstract and hence FooBarGo can be used as a
// in replacement for FooBarAbs but the reverse causes a compile time error. // drop in replacement for FooBarAbstract but the reverse causes a compile time
// error.
type FooBarGo interface { type FooBarGo interface {
FooBarAbs FooBarAbstract
deleteFooBarAbs() deleteFooBarAbstract()
IsFooBarGo() IsFooBarGo()
} }
// Via embedding fooBarGo "inherits" all methods of FooBarAbs. // Via embedding fooBarGo "inherits" all methods of FooBarAbstract.
type fooBarGo struct { type fooBarGo struct {
FooBarAbs FooBarAbstract
} }
func (fbgs *fooBarGo) deleteFooBarAbs() { func (fbgs *fooBarGo) deleteFooBarAbstract() {
DeleteDirectorFooBarAbs(fbgs.FooBarAbs) DeleteDirectorFooBarAbstract(fbgs.FooBarAbstract)
} }
// The IsFooBarGo method ensures that FooBarGo is a superset of FooBarAbs. // The IsFooBarGo method ensures that FooBarGo is a superset of FooBarAbstract.
// This is also how the class hierarchy gets represented by the SWIG generated // This is also how the class hierarchy gets represented by the SWIG generated
// wrapper code. For an instance FooBarCpp has the IsFooBarAbs and IsFooBarCpp // wrapper code. For an instance FooBarCpp has the IsFooBarAbstract and
// methods. // IsFooBarCpp methods.
func (fbgs *fooBarGo) IsFooBarGo() {} func (fbgs *fooBarGo) IsFooBarGo() {}
// Go type that defines the DirectorInterface. It contains the Foo and Bar // Go type that defines the DirectorInterface. It contains the Foo and Bar
// methods that overwrite the respective virtual C++ methods on FooBarAbs. // methods that overwrite the respective virtual C++ methods on FooBarAbstract.
type overwrittenMethodsOnFooBarAbs struct { type overwrittenMethodsOnFooBarAbstract struct {
// Backlink to FooBarAbs so that the rest of the class can be used by the // Backlink to FooBarAbstract so that the rest of the class can be used by
// overridden methods. // the overridden methods.
fb FooBarAbs fb FooBarAbstract
// If additional constructor arguments have been given they are typically // If additional constructor arguments have been given they are typically
// stored here so that the overriden methods can use them. // stored here so that the overriden methods can use them.
} }
func (om *overwrittenMethodsOnFooBarAbs) Foo() string { func (om *overwrittenMethodsOnFooBarAbstract) Foo() string {
// DirectorFooBarAbsFoo calls the base method FooBarAbs::Foo. // DirectorFooBarAbstractFoo calls the base method FooBarAbstract::Foo.
return "Go " + DirectorFooBarAbsFoo(om.fb) return "Go " + DirectorFooBarAbstractFoo(om.fb)
} }
func (om *overwrittenMethodsOnFooBarAbs) Bar() string { func (om *overwrittenMethodsOnFooBarAbstract) Bar() string {
return "Go Bar" return "Go Bar"
} }
func NewFooBarGo() FooBarGo { func NewFooBarGo() FooBarGo {
// Instantiate FooBarAbs with selected methods overridden. The methods that // Instantiate FooBarAbstract with selected methods overridden. The methods
// will be overwritten are defined on overwrittenMethodsOnFooBarAbs and have // that will be overwritten are defined on
// a compatible signature to the respective virtual C++ methods. // overwrittenMethodsOnFooBarAbstract and have a compatible signature to the
// Furthermore additional constructor arguments will be typically stored in // respective virtual C++ methods. Furthermore additional constructor
// the overwrittenMethodsOnFooBarAbs struct. // arguments will be typically stored in the
om := &overwrittenMethodsOnFooBarAbs{} // overwrittenMethodsOnFooBarAbstract struct.
fb := NewDirectorFooBarAbs(om) om := &overwrittenMethodsOnFooBarAbstract{}
fb := NewDirectorFooBarAbstract(om)
om.fb = fb // Backlink causes cycle as fb.v = om! om.fb = fb // Backlink causes cycle as fb.v = om!
fbgs := &fooBarGo{FooBarAbs: fb} fbgs := &fooBarGo{FooBarAbstract: fb}
// The memory of the FooBarAbs director object instance can be automatically // The memory of the FooBarAbstract director object instance can be
// freed once the FooBarGo instance is garbage collected by uncommenting the // automatically freed once the FooBarGo instance is garbage collected by
// following line. Please make sure to understand the runtime.SetFinalizer // uncommenting the following line. Please make sure to understand the
// specific gotchas before doing this. Furthemore DeleteFooBarGo should be // runtime.SetFinalizer specific gotchas before doing this. Furthemore
// deleted if a finalizer is in use or the fooBarGo struct needs additional // DeleteFooBarGo should be deleted if a finalizer is in use or the fooBarGo
// data to prevent double deletion. // struct needs additional data to prevent double deletion.
// runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbs) // runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbstract)
return fbgs return fbgs
} }
// Recommended to be removed if runtime.SetFinalizer is in use. // Recommended to be removed if runtime.SetFinalizer is in use.
func DeleteFooBarGo(fbg FooBarGo) { func DeleteFooBarGo(fbg FooBarGo) {
fbg.deleteFooBarAbs() fbg.deleteFooBarAbstract()
} }

View file

@ -6,11 +6,11 @@
#include <string> #include <string>
class FooBarAbs class FooBarAbstract
{ {
public: public:
FooBarAbs() {}; FooBarAbstract() {};
virtual ~FooBarAbs() {}; virtual ~FooBarAbstract() {};
std::string FooBar() { std::string FooBar() {
return this->Foo() + ", " + this->Bar(); return this->Foo() + ", " + this->Bar();
@ -25,11 +25,11 @@ protected:
}; };
class FooBarCpp : public FooBarAbs class FooBarCpp : public FooBarAbstract
{ {
protected: protected:
virtual std::string Foo() { virtual std::string Foo() {
return "C++ " + FooBarAbs::Foo(); return "C++ " + FooBarAbstract::Foo();
} }
virtual std::string Bar() { virtual std::string Bar() {

View file

@ -7,5 +7,5 @@
#include "director.h" #include "director.h"
%} %}
%feature("director") FooBarAbs; %feature("director") FooBarAbstract;
%include "director.h" %include "director.h"

View file

@ -18,7 +18,7 @@ Classes</a> documentation subsection for an explanation of this example.
<p> <p>
<ul> <ul>
<li><a href="director.go">director.go</a>. Go source with the definition of the FooBarGo class. <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 FooBarAbs and FooBarCpp classes. <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="example.i">example.i</a>. SWIG interface file.
<li><a href="runme.go">runme.go</a>. Sample Go program. <li><a href="runme.go">runme.go</a>. Sample Go program.
</ul> </ul>