考虑以下两个FFI结构: class A < FFI::Struct
layout :data, :int
end
class B < FFI::Struct
layout :nested, A
end
要实例他们: a = A.new
b = B.new
现在,当我尝试分配a到b.nested这样的: b[:nested] = a
我收到以下错误: ArgumentEr
的代码应该是这样的: def bring_into_scope(module)
#here the caller of the method should get methods from +module+
end
class Bar
def bar_method
#do stuff
end
end
class Foo
def init
我正在为封装C++库的C API编写一个Ruby API。 C API捕获C++库抛出的C++异常。 理想情况下,我可以进入并修改C库以便引发Ruby异常,但由于我使用的是FFI,因此这不是一个真正的选择。 C API将带有“捕获异常:”的异常字符串前置,打印到STDERR,然后继续,基本上忽略该错误。我想在rspec中观察这些类型的字符串。 这可能吗?这确实是在rspec之前完成的,但我不太清楚