SWIG は、派生クラスの継承された静的関数をラップしません。どうすれば解決できますか?
これが問題の簡単な図です。
これは単純な C++ ヘッダー ファイルです。
// file test.hpp
#include <iostream>
class B
{
public:
static void stat()
{ std::cerr << "=== calling static function B::stat" << std::endl; }
void nonstat() const
{ std::cerr << "==== calling B::nonstat for some object of B" << std::endl; }
};
class D : public B {};
C++ ソース ファイルには、ヘッダー ファイルのみが含まれています。
// file test.cpp
#include "test.hpp"
SWIG インターフェイス ファイルには、C++ ヘッダー ファイルのみが含まれています。
// file test.swig
%module test
%{
#include "test.hpp"
%}
%include "test.hpp"
次に、次のように swig ラッパー コードを生成します。
swig -c++ -tcl8 -namespace main.swig
そして、これで共有ライブラリを作成します:
g++ -fpic -Wall -pedantic -fno-strict-aliasing \
test.cpp test_wrap.cxx -o libtest.so
そのため、tcl インタープリターで libtest.so をロードし、ラップされたインターフェイスを使用しようとすると、次のように動作します。
% load libtest.so test
% test::B b
% test::D d
% b nonstat # works fine
% d nonstat # works fine
% test::B_stat # works fine
% test::D_stat # DOESN'T WORK !!
質問は、SWIG を D::stat でラップするにはどうすればよいかということです。