我在Objective-C中构建了一个Ruby扩展。现在我想使用@ throw/@ catch等,而不是基于宏的异常处理和自我构建错误处理。如何使用新的异常(@ throw ...)使用Objective-C构建Ruby扩展?
我正在使用GCC附带的GNU运行时。
当我用我的扩展运行我的Ruby应用程序时,一旦发生异常,核心就会转储。中止()来自GNU Objective-C运行(libobjc/exception.c:375):
void
objc_exception_throw (id value)
{
struct ObjcException *header = calloc (1, sizeof (*header));
header->base.exception_class = __objc_exception_class;
header->base.exception_cleanup = __objc_exception_cleanup;
header->value = value;
#ifdef SJLJ_EXCEPTIONS
_Unwind_SjLj_RaiseException (&header->base);
#else
_Unwind_RaiseException (&header->base);
#endif
/* Some sort of unwinding error. */
abort();
}
自从我与-fobjc-exceptions
编译我认为_Unwind_RaiseException
被调用。
有什么办法可以在Ruby扩展中使用Objective-C异常吗?