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/SWIG@5510 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
65a0e91dc2
commit
634b973f31
11 changed files with 154 additions and 41 deletions
|
|
@ -1,5 +1,32 @@
|
||||||
Version 1.3.20 (In progress)
|
Version 1.3.20 (In progress)
|
||||||
============================
|
============================
|
||||||
|
12/08/2003: mmatus (Marcelo Matus)
|
||||||
|
The director protected member support (dirprot)
|
||||||
|
is disabled by default.
|
||||||
|
|
||||||
|
It can be enable by using '-dirprot' or by adding
|
||||||
|
the option to the module declaration, like:
|
||||||
|
|
||||||
|
%module(directors="1",dirprot="1") my_module
|
||||||
|
|
||||||
|
This module option was added to properly compile the
|
||||||
|
director_protected.i and director_nested.i examples.
|
||||||
|
|
||||||
|
The feature has been tested with python[2.2,2.3]
|
||||||
|
and ruby[1.6.7], both at compilation and runtime, and
|
||||||
|
java[j2sdk1.4.1_01], but only at compilation (my java
|
||||||
|
installation doesn't run any of the director examples,
|
||||||
|
olds nor news).
|
||||||
|
|
||||||
|
Please test for ocaml and java.
|
||||||
|
|
||||||
|
The errors reported by William and Scott were fixed,
|
||||||
|
except for a warning about SWIG_JavaThrowExecption()
|
||||||
|
multiply defined. I can't reproduce this error with my
|
||||||
|
examples. We will wait for Scott to send us a minimal
|
||||||
|
case.
|
||||||
|
|
||||||
|
|
||||||
12/07/2003: mmatus (Marcelo Matus)
|
12/07/2003: mmatus (Marcelo Matus)
|
||||||
The director protected member support has been
|
The director protected member support has been
|
||||||
completly moved out from python.cxx, and now
|
completly moved out from python.cxx, and now
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
%module(directors="1") director_nested
|
%module(directors="1",dirprot="1") director_nested
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
%newobject *::create();
|
%newobject *::create();
|
||||||
|
|
||||||
%inline %{
|
%inline {
|
||||||
template <class C>
|
template <class C>
|
||||||
class Foo {
|
class Foo {
|
||||||
public:
|
public:
|
||||||
|
|
@ -25,11 +25,11 @@
|
||||||
protected:
|
protected:
|
||||||
virtual std::string do_advance() = 0;
|
virtual std::string do_advance() = 0;
|
||||||
};
|
};
|
||||||
%}
|
}
|
||||||
|
|
||||||
%template(Foo_int) Foo<int>;
|
%template(Foo_int) Foo<int>;
|
||||||
|
|
||||||
%inline %{
|
%inline {
|
||||||
|
|
||||||
class Bar : public Foo<int>
|
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;
|
virtual std::string do_step() const = 0;
|
||||||
|
#else
|
||||||
|
virtual std::string do_step() const {return "";};
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class C>
|
template <class C>
|
||||||
|
|
@ -56,7 +61,7 @@
|
||||||
public:
|
public:
|
||||||
virtual C get_value() const = 0;
|
virtual C get_value() const = 0;
|
||||||
};
|
};
|
||||||
%}
|
}
|
||||||
|
|
||||||
%template(FooBar_int) FooBar<int>;
|
%template(FooBar_int) FooBar<int>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
%module(directors="1") director_protected
|
%module(directors="1",dirprot="1") director_protected
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
%newobject *::create();
|
%newobject *::create();
|
||||||
|
|
||||||
%inline %{
|
%inline {
|
||||||
class Foo {
|
class Foo {
|
||||||
public:
|
public:
|
||||||
virtual ~Foo() {}
|
virtual ~Foo() {}
|
||||||
|
|
@ -20,7 +20,15 @@ public:
|
||||||
return "Foo::pong();" + ping();
|
return "Foo::pong();" + ping();
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
#if defined(SWIGPYTHON) || defined(SWIGRUBY) \
|
||||||
|
|| defined(SWIGJAVA) || defined(SWIGOCAML)
|
||||||
virtual std::string ping() = 0;
|
virtual std::string ping() = 0;
|
||||||
|
#else
|
||||||
|
virtual std::string ping() { return "";};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void hellom() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class Bar : public Foo
|
class Bar : public Foo
|
||||||
|
|
@ -43,8 +51,9 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
int hi;
|
int hi;
|
||||||
|
void him() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
%}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
34
Examples/test-suite/ruby/director_nested_runme.rb
Normal file
34
Examples/test-suite/ruby/director_nested_runme.rb
Normal 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;"
|
||||||
13
Examples/test-suite/ruby/director_protected_runme.rb
Normal file
13
Examples/test-suite/ruby/director_protected_runme.rb
Normal 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();"
|
||||||
|
|
@ -268,6 +268,9 @@ class JAVA : public Language {
|
||||||
if (Getattr(optionsnode, "directors")) {
|
if (Getattr(optionsnode, "directors")) {
|
||||||
allow_directors();
|
allow_directors();
|
||||||
}
|
}
|
||||||
|
if (Getattr(optionsnode, "dirprot")) {
|
||||||
|
allow_dirprot();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize all of the output files */
|
/* Initialize all of the output files */
|
||||||
|
|
|
||||||
|
|
@ -1720,6 +1720,7 @@ int Language::classHandler(Node *n) {
|
||||||
classDirectorDisown(n);
|
classDirectorDisown(n);
|
||||||
|
|
||||||
/* emit all the protected virtual members as needed */
|
/* emit all the protected virtual members as needed */
|
||||||
|
if (director_protected_mode) {
|
||||||
Node *vtable = Getattr(n, "vtable");
|
Node *vtable = Getattr(n, "vtable");
|
||||||
String* symname = Getattr(n, "sym:name");
|
String* symname = Getattr(n, "sym:name");
|
||||||
Node *item;
|
Node *item;
|
||||||
|
|
@ -1740,11 +1741,11 @@ int Language::classHandler(Node *n) {
|
||||||
Node* m = Copy(method);
|
Node* m = Copy(method);
|
||||||
String* mdecl = Getattr(m,"decl");
|
String* mdecl = Getattr(m,"decl");
|
||||||
Setattr(m,"parentNode", n);
|
Setattr(m,"parentNode", n);
|
||||||
/* ugly trick, to avoid an uglier one later on emit. We take
|
/* ugly trick, to avoid an uglier one later on emit. We
|
||||||
the 'const' out from calling method to avoid the ugly const
|
take the 'const' out from calling method to avoid the
|
||||||
casting latter. The casting from 'non-const' to 'const' is not
|
ugly const casting latter. The casting from 'non-const'
|
||||||
needed here, but it prevents the simple replacement of
|
to 'const' is not needed here, but it prevents the simple
|
||||||
arg1 by darg on emit.cxx.
|
replacement of arg1 by darg on emit.cxx.
|
||||||
*/
|
*/
|
||||||
if (Strncmp(mdecl, "q(const).", 9)== 0)
|
if (Strncmp(mdecl, "q(const).", 9)== 0)
|
||||||
Replace(mdecl,"q(const).","", DOH_REPLACE_FIRST);
|
Replace(mdecl,"q(const).","", DOH_REPLACE_FIRST);
|
||||||
|
|
@ -1756,6 +1757,7 @@ int Language::classHandler(Node *n) {
|
||||||
}
|
}
|
||||||
cplus_mode = old_mode;
|
cplus_mode = old_mode;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
@ -2184,6 +2186,14 @@ void Language::allow_directors(int val) {
|
||||||
directors = val;
|
directors = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Language::allow_dirprot()
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void Language::allow_dirprot(int val) {
|
||||||
|
director_protected_mode = val;
|
||||||
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Language::directorsEnabled()
|
* Language::directorsEnabled()
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
|
||||||
|
|
@ -196,6 +196,9 @@ public:
|
||||||
if (Getattr(options, "directors")) {
|
if (Getattr(options, "directors")) {
|
||||||
allow_directors();
|
allow_directors();
|
||||||
}
|
}
|
||||||
|
if (Getattr(options, "dirprot")) {
|
||||||
|
allow_dirprot();
|
||||||
|
}
|
||||||
if (Getattr(options, "sizeof")) {
|
if (Getattr(options, "sizeof")) {
|
||||||
generate_sizeof = 1;
|
generate_sizeof = 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,9 @@ public:
|
||||||
if (Getattr(options, "directors")) {
|
if (Getattr(options, "directors")) {
|
||||||
allow_directors();
|
allow_directors();
|
||||||
}
|
}
|
||||||
|
if (Getattr(options, "dirprot")) {
|
||||||
|
allow_dirprot();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -335,6 +335,9 @@ public:
|
||||||
if (Getattr(options, "directors")) {
|
if (Getattr(options, "directors")) {
|
||||||
allow_directors();
|
allow_directors();
|
||||||
}
|
}
|
||||||
|
if (Getattr(options, "dirprot")) {
|
||||||
|
allow_dirprot();
|
||||||
|
}
|
||||||
if (Getattr(options, "ruby_globalmodule")) {
|
if (Getattr(options, "ruby_globalmodule")) {
|
||||||
useGlobalModule = true;
|
useGlobalModule = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -214,6 +214,9 @@ public:
|
||||||
/* Allow director related code generation */
|
/* Allow director related code generation */
|
||||||
void allow_directors(int val = 1);
|
void allow_directors(int val = 1);
|
||||||
|
|
||||||
|
/* Allow director protected members related code generation */
|
||||||
|
void allow_dirprot(int val = 1);
|
||||||
|
|
||||||
/* Return true if directors are enabled */
|
/* Return true if directors are enabled */
|
||||||
int directorsEnabled() const;
|
int directorsEnabled() const;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue