The dirprot feature is now disabled by default. Added dirprot option and ruby runtime examples.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5510 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2003-12-09 02:52:08 +00:00
commit 86edc68494
11 changed files with 154 additions and 41 deletions

View file

@ -1,4 +1,4 @@
%module(directors="1") director_nested
%module(directors="1",dirprot="1") director_nested
%{
#include <string>
@ -11,7 +11,7 @@
%newobject *::create();
%inline %{
%inline {
template <class C>
class Foo {
public:
@ -25,11 +25,11 @@
protected:
virtual std::string do_advance() = 0;
};
%}
}
%template(Foo_int) Foo<int>;
%inline %{
%inline {
class Bar : public Foo<int>
{
@ -47,7 +47,12 @@
}
#if defined(SWIGPYTHON) || defined(SWIGRUBY) || \
defined(SWIGJAVA) || defined(SWIGOCAML)
virtual std::string do_step() const = 0;
#else
virtual std::string do_step() const {return "";};
#endif
};
template <class C>
@ -56,7 +61,7 @@
public:
virtual C get_value() const = 0;
};
%}
}
%template(FooBar_int) FooBar<int>;

View file

@ -1,4 +1,4 @@
%module(directors="1") director_protected
%module(directors="1",dirprot="1") director_protected
%{
#include <string>
@ -12,7 +12,7 @@
%newobject *::create();
%inline %{
%inline {
class Foo {
public:
virtual ~Foo() {}
@ -20,7 +20,15 @@ public:
return "Foo::pong();" + ping();
}
protected:
#if defined(SWIGPYTHON) || defined(SWIGRUBY) \
|| defined(SWIGJAVA) || defined(SWIGOCAML)
virtual std::string ping() = 0;
#else
virtual std::string ping() { return "";};
#endif
void hellom() {}
};
class Bar : public Foo
@ -43,8 +51,9 @@ protected:
};
int hi;
void him() {}
};
%}
}

View file

@ -0,0 +1,34 @@
require 'director_nested'
class A < Director_nested::FooBar_int
def do_step
"A::do_step;"
end
def get_value
"A::get_value"
end
end
a = A.new
raise RuntimeError if a.step != "Bar::step;Foo::advance;Bar::do_advance;A::do_step;"
class B < Director_nested::FooBar_int
def do_advance
"B::do_advance;" + do_step
end
def do_step
"B::do_step;"
end
def get_value
"B::get_value"
end
end
b = B.new
raise RuntimeError if b.step != "Bar::step;Foo::advance;B::do_advance;B::do_step;"

View file

@ -0,0 +1,13 @@
require 'director_protected'
class FooBar < Director_protected::Bar
def ping
"FooBar::ping();"
end
end
b = Director_protected::Bar.new
fb = FooBar.new
raise RuntimeError if b.pong != "Bar::pong();Foo::pong();Bar::ping();"
raise RuntimeError if fb.pong != "Bar::pong();Foo::pong();FooBar::ping();"