promote the 'using' methods to public. Also, fix a sef. fault for using with pointers, see using_pointers.i
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5525 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
6acb22fbfc
commit
3a2ad32d92
3 changed files with 95 additions and 2 deletions
66
SWIG/Examples/test-suite/director_using.i
Normal file
66
SWIG/Examples/test-suite/director_using.i
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
%module(directors="1",dirprot="1") director_nested
|
||||
//%module director_nested
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
%}
|
||||
|
||||
%include "std_string.i"
|
||||
|
||||
%feature("director") Bar;
|
||||
|
||||
%newobject *::create();
|
||||
|
||||
%inline {
|
||||
template <class C>
|
||||
class Foo {
|
||||
public:
|
||||
virtual ~Foo() {}
|
||||
|
||||
std::string advance()
|
||||
{
|
||||
return "Foo::advance;" + do_advance();
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual std::string do_advance() = 0;
|
||||
virtual std::string do_step() const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
%template(Foo_int) Foo<int>;
|
||||
|
||||
%inline {
|
||||
|
||||
class Bar : public Foo<int>
|
||||
{
|
||||
public:
|
||||
|
||||
std::string step()
|
||||
{
|
||||
return "Bar::step;" + advance();
|
||||
}
|
||||
|
||||
|
||||
using Foo<int>::do_step;
|
||||
protected:
|
||||
std::string do_advance()
|
||||
{
|
||||
return "Bar::do_advance;" + do_step();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <class C>
|
||||
class FooBar : public Bar
|
||||
{
|
||||
public:
|
||||
virtual C get_value() const = 0;
|
||||
using Bar::do_advance;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
%template(FooBar_int) FooBar<int>;
|
||||
|
||||
17
SWIG/Examples/test-suite/using_pointers.i
Normal file
17
SWIG/Examples/test-suite/using_pointers.i
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
%module using_pointers
|
||||
|
||||
%inline %{
|
||||
class Foo {
|
||||
public:
|
||||
int x;
|
||||
virtual Foo* blah() { return this; }
|
||||
};
|
||||
|
||||
class FooBar : public Foo {
|
||||
public:
|
||||
using Foo::blah;
|
||||
using Foo::x;
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
|
|
@ -1975,8 +1975,18 @@ int Language::validIdentifier(String *s) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Language::usingDeclaration(Node *n) {
|
||||
if (cplus_mode == CPLUS_PUBLIC) {
|
||||
emit_children(n);
|
||||
const char* access = 0;
|
||||
if ((cplus_mode == CPLUS_PUBLIC)) {
|
||||
Node* np = Copy(n);
|
||||
Node *c;
|
||||
for (c = firstChild(np); c; c = nextSibling(c)) {
|
||||
Setattr(c, "access", "public");
|
||||
/* it seems for some cases this is needed, like A* A::boo() */
|
||||
if (CurrentClass)
|
||||
Setattr(c, "parentNode", CurrentClass);
|
||||
emit_one(c);
|
||||
}
|
||||
Delete(np);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue