Я пытаюсь создать интерфейс SWIG Python для библиотеки C ++, добавить обертки Python для некоторых функций, и я был бы очень признателен за помощь от кого-то, имеющего опыт работы с SWIG.
Пока у меня есть такойисточники:
test.h
namespace Test {
class CodeResponseEvent {
public:
CodeResponseEvent(std::string activation_code);
std::string getActivationCode() const;
private:
const std::string activation_code_;
};
class CodeRequestEvent {
public:
CodeRequestEvent(std::string user_id);
std::shared_ptr<CodeResponseEvent> execute();
private:
const std::string user_id_;
};
}
test.i
%module test
%include std_string.i
%include <std_shared_ptr.i>
%{#include "test.h"%}
%include "test.h"
%shared_ptr(Test::CodeResponseEvent);
Python-код выглядит так:
codeResponse = test.CodeRequestEvent("user").execute()
В результате я получаюзначение
<Swig Object of type 'std::shared_ptr< Test::CodeResponseEvent> *'>
Итак, вопрос в том, как развернуть этот SwigPyobject для вызова метода getActivationCode ()?