parent
3208ff2bf5
commit
6e2b54be2f
3 changed files with 39 additions and 0 deletions
|
|
@ -29,3 +29,33 @@ struct TYPE2 {
|
|||
struct TYPE { };
|
||||
struct TYPE2 { };
|
||||
%}
|
||||
|
||||
|
||||
// Overriding __new__ test: https://github.com/swig/swig/pull/1357
|
||||
%inline %{
|
||||
class Foo {
|
||||
public:
|
||||
virtual ~Foo() {}
|
||||
Foo() {}
|
||||
};
|
||||
|
||||
Foo* get_foo() {return new Foo();}
|
||||
%}
|
||||
|
||||
%pythoncode %{
|
||||
print_debug = True
|
||||
%}
|
||||
|
||||
%extend Foo {
|
||||
// Note that %pythoncode is not available with -builtin
|
||||
%pythoncode %{
|
||||
def __new__(cls, *args, **kwargs):
|
||||
if print_debug:
|
||||
print('in Foo.__new__()')
|
||||
return super(Foo, cls).__new__(cls)
|
||||
|
||||
def __init__(self):
|
||||
if print_debug:
|
||||
print('in Foo.__init__()')
|
||||
%}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue