C++ 用C+扩展Ruby+;:来自C++;红宝石
我在编写Ruby C++扩展时遇到了一些问题。 我有一些C++库的源代码。它通过文件具有以下功能:C++ 用C+扩展Ruby+;:来自C++;红宝石,c++,ruby,callback,C++,Ruby,Callback,我在编写Ruby C++扩展时遇到了一些问题。 我有一些C++库的源代码。它通过文件具有以下功能: class MyConversation : public Conversation { public: typedef DRef<MyConversation, Conversation> Ref; typedef DRefs<MyConversation, Conversation> Refs; MyConversation(unsign
class MyConversation : public Conversation
{
public:
typedef DRef<MyConversation, Conversation> Ref;
typedef DRefs<MyConversation, Conversation> Refs;
MyConversation(unsigned int oid, SERootObject* root) : Conversation(oid, root) {};
void OnMessage(const MessageRef & message);
};
void MyConversation::OnMessage(const MessageRef & message)
{
// Message handling goes here
};
在ruby中,我需要一个简单的调用:
listener = Object.new
listener.messages do |message|
# As I understand Thread.current != Thread.main
end
如何做到这一点?我完成了从ruby调用c++的函数,但我不明白如何做这样的事情(我对c和c++的知识很薄弱)
谢谢你的帮助
listener = Object.new
listener.messages do |message|
# As I understand Thread.current != Thread.main
end