From f2ca1e84502ba61a0f6204ce3ebb72732b0a8e71 Mon Sep 17 00:00:00 2001
From: Sami Vaarala
Date: Sun, 6 Apr 2014 23:40:49 +0300
Subject: [PATCH] update protected/safe api calls to omit errhandler_index
---
website/api/duk_pcall.txt | 13 +++----------
website/api/duk_pcall_method.txt | 4 ++--
website/api/duk_pcall_prop.txt | 4 ++--
website/api/duk_safe_call.txt | 12 +++---------
4 files changed, 10 insertions(+), 23 deletions(-)
diff --git a/website/api/duk_pcall.txt b/website/api/duk_pcall.txt
index 9c61ca74..d5354b60 100644
--- a/website/api/duk_pcall.txt
+++ b/website/api/duk_pcall.txt
@@ -1,5 +1,5 @@
=proto
-int duk_pcall(duk_context *ctx, int nargs, int errhandler_index);
+int duk_pcall(duk_context *ctx, int nargs);
=stack
[ ... func! arg1! ...! argN! ] -> [ ... retval! ] (if success, return value == 0)
@@ -9,11 +9,7 @@ int duk_pcall(duk_context *ctx, int nargs, int errhandler_index);
Call target function func
with nargs
arguments
(not counting the function itself). The function and its arguments
are replaced by a single return value or a single error value.
-An error thrown during the function call is caught. errhandler_index
points
-to an error handler function in the current stack frame (below call arguments) which
-can modify an error value before it is thrown; to use the default error handler,
-set errhandler_index
to DUK_INVALID_INDEX
.
-
+An error thrown during the function call is caught.
The return value is:
@@ -50,7 +46,7 @@ int rc;
duk_dup(ctx, func_idx);
duk_push_int(ctx, 2);
duk_push_int(ctx, 3);
-rc = duk_pcall(ctx, 2, DUK_INVALID_INDEX); /* [ ... func 2 3 ] -> [ 5 ] */
+rc = duk_pcall(ctx, 2); /* [ ... func 2 3 ] -> [ 5 ] */
if (rc == DUK_EXEC_SUCCESS) {
printf("2+3=%d\n", duk_get_int(ctx, -1));
} else {
@@ -64,6 +60,3 @@ call
=seealso
duk_pcall_method
duk_pcall_prop
-
-=fixme
-Error handler model to be cleaned up.
diff --git a/website/api/duk_pcall_method.txt b/website/api/duk_pcall_method.txt
index 63b12cea..d6c6b581 100644
--- a/website/api/duk_pcall_method.txt
+++ b/website/api/duk_pcall_method.txt
@@ -1,5 +1,5 @@
=proto
-int duk_pcall_method(duk_context *ctx, int nargs, int errhandler_index);
+int duk_pcall_method(duk_context *ctx, int nargs);
=stack
[ ... func! this! arg! ...! argN! ] -> [ ... retval! ] (if success, return value == 0)
@@ -27,7 +27,7 @@ duk_eval(ctx); /* -> [ ... func ] */
duk_push_int(ctx, 123);
duk_push_int(ctx, 2);
duk_push_int(ctx, 3);
-rc = duk_pcall_method(ctx, 2, DUK_INVALID_INDEX); /* [ ... func 123 2 3 ] -> [ 5 ] */
+rc = duk_pcall_method(ctx, 2); /* [ ... func 123 2 3 ] -> [ 5 ] */
if (rc == DUK_EXEC_SUCCESS) {
printf("2+3=%d\n", duk_get_int(ctx, -1)); /* prints 5 */
} else {
diff --git a/website/api/duk_pcall_prop.txt b/website/api/duk_pcall_prop.txt
index 6aa35baa..a0ad381d 100644
--- a/website/api/duk_pcall_prop.txt
+++ b/website/api/duk_pcall_prop.txt
@@ -1,5 +1,5 @@
=proto
-int duk_pcall_prop(duk_context *ctx, int obj_index, int nargs, int errhandler_index);
+int duk_pcall_prop(duk_context *ctx, int obj_index, int nargs);
=stack
[ ... obj! ... key! arg1! ...! argN! ] -> [ ... obj! ... retval! ] (if success, return value == 0)
@@ -18,7 +18,7 @@ int rc;
duk_push_string(ctx, "myAdderMethod");
duk_push_int(ctx, 2);
duk_push_int(ctx, 3);
-rc = duk_pcall_prop(ctx, obj_idx, 2, DUK_INVALID_INDEX); /* [ ... "myAdderMethod" 2 3 ] -> [ ... 5 ] */
+rc = duk_pcall_prop(ctx, obj_idx, 2); /* [ ... "myAdderMethod" 2 3 ] -> [ ... 5 ] */
if (rc == DUK_EXEC_SUCCESS) {
printf("2+3=%d\n", duk_get_int(ctx, -1));
} else {
diff --git a/website/api/duk_safe_call.txt b/website/api/duk_safe_call.txt
index 10c59bb1..67a57b45 100644
--- a/website/api/duk_safe_call.txt
+++ b/website/api/duk_safe_call.txt
@@ -1,5 +1,5 @@
=proto
-int duk_safe_call(duk_context *ctx, duk_safe_call_function func, int nargs, int nrets, int errhandler_index);
+int duk_safe_call(duk_context *ctx, duk_safe_call_function func, int nargs, int nrets);
=stack
[ ... arg1! ...! argN! ] -> [ ... ret1! ...! retN! ]
@@ -8,10 +8,7 @@ int duk_safe_call(duk_context *ctx, duk_safe_call_function func, int nargs, int
Perform a protected pure C function call inside the current value stack frame
(the call is not visible on the call stack). nargs
topmost values in the
current value stack frame are identified as call arguments, and nrets
-return values are provided after the call returns. errhandler_index
points
-to an error handler function in the current stack frame (below call arguments) which
-can modify an error value before it is thrown; to use the default error handler,
-set errhandler_index
to DUK_INVALID_INDEX
.
+return values are provided after the call returns.
The return value is:
@@ -98,7 +95,7 @@ int my_func(duk_context *ctx) {
duk_push_int(ctx, 10);
duk_push_int(ctx, 11);
duk_push_int(ctx, 12);
-rc = duk_safe_call(ctx, my_func, 3 /*nargs*/, 2 /*nrets*/, DUK_INVALID_INDEX);
+rc = duk_safe_call(ctx, my_func, 3 /*nargs*/, 2 /*nrets*/);
if (rc == DUK_EXEC_SUCCESS) {
printf("1st return value: %s\n", duk_to_string(ctx, -2)); /* 21 */
printf("2nd return value: %s\n", duk_to_string(ctx, -1)); /* undefined */
@@ -109,6 +106,3 @@ duk_pop_2(ctx);
=tags
call
-
-=fixme
-Error handler model to be cleaned up.