Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 用C+扩展Ruby+;:来自C++;红宝石_C++_Ruby_Callback - Fatal编程技术网

C++ 用C+扩展Ruby+;:来自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

我在编写Ruby C++扩展时遇到了一些问题。 我有一些C++库的源代码。它通过文件具有以下功能:

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