Add wrenAbortFiber().
Thanks, @underscorediscovery!
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "error.h"
|
||||
|
||||
static void runtimeError(WrenVM* vm)
|
||||
{
|
||||
wrenEnsureSlots(vm, 1);
|
||||
wrenSetSlotString(vm, 0, "Error!");
|
||||
wrenAbortFiber(vm, 0);
|
||||
}
|
||||
|
||||
WrenForeignMethodFn errorBindMethod(const char* signature)
|
||||
{
|
||||
if (strcmp(signature, "static Error.runtimeError") == 0) return runtimeError;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "wren.h"
|
||||
|
||||
WrenForeignMethodFn errorBindMethod(const char* signature);
|
||||
@@ -0,0 +1,12 @@
|
||||
class Error {
|
||||
foreign static runtimeError
|
||||
}
|
||||
|
||||
var fiber = Fiber.new {
|
||||
Error.runtimeError
|
||||
}
|
||||
|
||||
var error = fiber.try()
|
||||
System.print(error) // expect: Error!
|
||||
System.print(fiber.isDone) // expect: true
|
||||
System.print(fiber.error) // expect: Error!
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "benchmark.h"
|
||||
#include "call.h"
|
||||
#include "error.h"
|
||||
#include "get_variable.h"
|
||||
#include "foreign_class.h"
|
||||
#include "handle.h"
|
||||
@@ -35,6 +36,9 @@ static WrenForeignMethodFn bindForeignMethod(
|
||||
|
||||
method = benchmarkBindMethod(fullName);
|
||||
if (method != NULL) return method;
|
||||
|
||||
method = errorBindMethod(fullName);
|
||||
if (method != NULL) return method;
|
||||
|
||||
method = getVariableBindMethod(fullName);
|
||||
if (method != NULL) return method;
|
||||
|
||||
Reference in New Issue
Block a user