2017-07-26 4 views
1

Cppクラスの一部であるPythonでオーバーライド関数を使用しようとしています。SwigでC++スーパークラスを生成する方法

class A { 

    public: 
     int func() { return 0; }; 
     A(); 
}; 

class B : A { 
public: 
    B(); 
    ~B(); 
}; 

私は

swig -python -fvirtual -modern -keyword -w511 -module a_swig -outdir . -c++ -I. a_swig.i 

ガブガブ飲むのPythonのファイルを生成するには、次のコマンドを使用します。しかし、私は、生成され、このPythonのファイルを参照してください。私はBがAから拡張されて見たい

class A(object): 
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') 
__repr__ = _swig_repr 

def func(self): 
    return _iris_swig.A_func(self) 

def __init__(self): 
    this = _A_swig.new_A() 
    try: 
     self.this.append(this) 
    except __builtin__.Exception: 
     self.this = this 
__swig_destroy__ = _A_swig.delete_A 
__del__ = lambda self: None 

A_swigregister = _A_swig.A_swigregister 
A_swigregister(A) 

class B(object): 
    thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') 
__repr__ = _swig_repr 

    def __init__(self, *args, **kwargs): 
    this = _A_swig.new_B(*args, **kwargs) 
    try: 
     self.this.append(this) 
    except __builtin__.Exception: 
     self.this = this 
    __swig_destroy__ = _iris_swig.delete_B 
    __del__ = lambda self: None 
packet_header_iris_swigregister = _iris_swig.packet_header_iris_swigregister 
packet_header_iris_swigregister(packet_header_iris) 

をので、私はPythonでb.func()を使用することができます

紛失しているものはありますか?

答えて

1

クラスBのみがAからプライベートに継承されるため、SWIGはPythonでそれを表現できません。それを公開継承に変更すると、希望する関係が表示されます。

関連する問題