我在 Objective-C 中构建了一个 Ruby 扩展。现在我想使用@throw/@catch 等代替基于宏的异常处理和自构建错误处理。
我正在使用 GCC 附带的 GNU 运行时。
当我使用我的扩展程序运行我的 Ruby 应用程序时,它会在发生异常时立即转储核心。abort() 来自 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 异常?