fix smart_pointer + extend
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6835 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
13aee4b0e7
commit
bffe7fd9c7
6 changed files with 72 additions and 11 deletions
|
|
@ -191,6 +191,7 @@ CPP_TEST_CASES += \
|
||||||
sizet \
|
sizet \
|
||||||
smart_pointer_const \
|
smart_pointer_const \
|
||||||
smart_pointer_const2 \
|
smart_pointer_const2 \
|
||||||
|
smart_pointer_extend \
|
||||||
smart_pointer_member \
|
smart_pointer_member \
|
||||||
smart_pointer_multi \
|
smart_pointer_multi \
|
||||||
smart_pointer_multi_typedef \
|
smart_pointer_multi_typedef \
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
from smart_pointer_extend import *
|
||||||
|
|
||||||
|
f = Foo()
|
||||||
|
b = Bar(f)
|
||||||
|
|
||||||
|
if b.extension() != f.extension():
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
|
b = CBase()
|
||||||
|
d = CDerived()
|
||||||
|
p = CPtr()
|
||||||
|
|
||||||
|
|
||||||
|
if d.foo() != p.foo():
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -19,6 +19,3 @@ if b.x != f.x:
|
||||||
|
|
||||||
if b.z != f.z:
|
if b.z != f.z:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if b.extension() != f.extension():
|
|
||||||
raise RuntimeError
|
|
||||||
|
|
|
||||||
50
SWIG/Examples/test-suite/smart_pointer_extend.i
Normal file
50
SWIG/Examples/test-suite/smart_pointer_extend.i
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
%module smart_pointer_extend
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
|
||||||
|
class CBase
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
class CDerived : public CBase
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
class CPtr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CDerived* operator->(void) {return 0;};
|
||||||
|
};
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
||||||
|
%extend CBase {
|
||||||
|
int foo(void) {return 1;};
|
||||||
|
}
|
||||||
|
|
||||||
|
%extend CDerived {
|
||||||
|
int foo(void) {return 2;};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
%extend Foo
|
||||||
|
{
|
||||||
|
int extension(int i, int j) { return i; }
|
||||||
|
int extension(int i) { return i; }
|
||||||
|
int extension() { return 1; }
|
||||||
|
}
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
struct Foo {
|
||||||
|
};
|
||||||
|
|
||||||
|
class Bar {
|
||||||
|
Foo *f;
|
||||||
|
public:
|
||||||
|
Bar(Foo *f) : f(f) { }
|
||||||
|
Foo *operator->() {
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
@ -1,12 +1,6 @@
|
||||||
%module smart_pointer_member
|
%module smart_pointer_member
|
||||||
|
|
||||||
|
|
||||||
%extend Foo
|
|
||||||
{
|
|
||||||
int extension(int i, int j) { return i; }
|
|
||||||
int extension(int i) { return i; }
|
|
||||||
int extension() { return 1; }
|
|
||||||
}
|
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -267,8 +267,8 @@ class Allocate : public Dispatcher {
|
||||||
c = nextSibling(c);
|
c = nextSibling(c);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (Strcmp(nodeType(c),"extend") == 0) {
|
if (!isconst && (Strcmp(nodeType(c),"extend") == 0)) {
|
||||||
Append(methods,c);
|
methods = smart_pointer_methods(c, methods, isconst);
|
||||||
} else if (Strcmp(nodeType(c),"cdecl") == 0) {
|
} else if (Strcmp(nodeType(c),"cdecl") == 0) {
|
||||||
if (!Getattr(c,"feature:ignore")) {
|
if (!Getattr(c,"feature:ignore")) {
|
||||||
String *storage = Getattr(c,"storage");
|
String *storage = Getattr(c,"storage");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue