c++ - FFI 的 Ruby 扩展

标签 c++ ruby ffi

我有这样的,例如,带有类的 C++ 库:

class Hello2

bool doSomething()
end

end

class Hello

  Hello2 getStatus()
{
  Hello2* hello2 = new Hello2();
  return hello2;
}

end

如何通过 ffi ( https://github.com/ffi/ffi ) 映射它?因为它不是静态方法。我在 ruby 中需要这样的东西:

obj1 = Hello.new
obj2 = obj1.get_status
obj2.do_something

谢谢。

最佳答案

以下是一些可能有用的链接:

这是 rb++ 的 github 存储库中示例的链接:

https://github.com/jameskilton/rbplusplus/tree/master/samples/my_math

关于c++ - FFI 的 Ruby 扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7960101/

相关文章:

ruby-on-rails - Ruby 类( super )

mysql - Rails - 安装 Gem 时出错

rust - 在 C 管理的内存中正确存储 Rust Rc<T>

c# - 为什么 if( !A && !B ) 不能优化为单个 TEST 指令?

c++ - 使用 gcc/g++ 编译器编译 c++

ruby - 顶层方法的定义

c++ - ffi.C 缺少所有符号的所有声明

ncurses - native 调用接口(interface) : how to translate "wchar_t"?

c++ - 如果我们使用参数构造函数,我们是否需要在 C++ 中提供默认构造函数?

c++ - 我对 enable_if 和 has_member 做错了什么?