Browse Source

remove internal DUK_ERR_EXEC_xxx codes, use the public DUK_EXEC_xxx codes instead

pull/1/head
Sami Vaarala 11 years ago
parent
commit
c7e02cb12e
  1. 12
      src/duk_api_call.c
  2. 5
      src/duk_error.h
  3. 2
      src/duk_hobject_finalizer.c
  4. 20
      src/duk_js_call.c
  5. 4
      src/duktape.h

12
src/duk_api_call.c

@ -178,12 +178,12 @@ int duk_pcall(duk_context *ctx, int nargs, int errhandler_index) {
* fatal error.
*/
DUK_ERROR(thr, DUK_ERR_API_ERROR, "invalid call args");
return DUK_ERR_EXEC_ERROR; /* unreachable */
return DUK_EXEC_ERROR; /* unreachable */
}
if (!resolve_errhandler(ctx, nargs + 1, errhandler_index, &errhandler)) {
/* error on top of stack */
return DUK_ERR_EXEC_ERROR;
return DUK_EXEC_ERROR;
}
/* awkward; we assume there is space for this */
@ -214,12 +214,12 @@ int duk_pcall_method(duk_context *ctx, int nargs, int errhandler_index) {
if (idx_func < 0 || nargs < 0) {
/* See comments in duk_pcall(). */
DUK_ERROR(thr, DUK_ERR_API_ERROR, "invalid call args");
return DUK_ERR_EXEC_ERROR; /* unreachable */
return DUK_EXEC_ERROR; /* unreachable */
}
if (!resolve_errhandler(ctx, nargs + 2, errhandler_index, &errhandler)) {
/* error on top of stack */
return DUK_ERR_EXEC_ERROR;
return DUK_EXEC_ERROR;
}
call_flags = DUK_CALL_FLAG_PROTECTED; /* protected, respect reclimit, not constructor */
@ -251,12 +251,12 @@ int duk_safe_call(duk_context *ctx, duk_safe_call_function func, int nargs, int
if (duk_get_top(ctx) < nargs || nrets < 0) {
/* See comments in duk_pcall(). */
DUK_ERROR(thr, DUK_ERR_API_ERROR, "invalid call args");
return DUK_ERR_EXEC_ERROR; /* unreachable */
return DUK_EXEC_ERROR; /* unreachable */
}
if (!resolve_errhandler(ctx, nargs, errhandler_index, &errhandler)) {
/* error on top of stack (args popped) */
return DUK_ERR_EXEC_ERROR;
return DUK_EXEC_ERROR;
}
rc = duk_handle_safe_call(thr, /* thread */

5
src/duk_error.h

@ -20,11 +20,6 @@
#define DUK_ERR_OK 0 /* call successful */
#define DUK_ERR_FAIL 1 /* call failed */
/* duk_executor results */
/* FIXME: these need to be in the public API too */
#define DUK_ERR_EXEC_SUCCESS 0 /* thread returned to entry level with success */
#define DUK_ERR_EXEC_ERROR 1 /* thread encountered a so far uncaught error */
/*
* Normal error is thrown with a longjmp() through the current setjmp()
* catchpoint record in the duk_heap. The 'curr_thread' of the duk_heap

2
src/duk_hobject_finalizer.c

@ -72,7 +72,7 @@ void duk_hobject_run_finalizer(duk_hthread *thr, duk_hobject *obj) {
rc = duk_safe_call(ctx, _finalize_helper, 0 /*nargs*/, 1 /*nrets*/, DUK_INVALID_INDEX); /* -> [... obj retval/error] */
DUK_ASSERT_TOP(ctx, entry_top + 2); /* duk_safe_call discipline */
if (rc != DUK_ERR_EXEC_SUCCESS) {
if (rc != DUK_EXEC_SUCCESS) {
/* Note: we ask for one return value from duk_safe_call to get this
* error debugging here.
*/

20
src/duk_js_call.c

@ -512,8 +512,8 @@ static void handle_coerce_effective_this_binding(duk_hthread *thr,
*
* Output stack:
*
* [ retval ] (DUK_ERR_EXEC_SUCCESS)
* [ errobj ] (DUK_ERR_EXEC_ERROR (normal error), protected call)
* [ retval ] (DUK_EXEC_SUCCESS)
* [ errobj ] (DUK_EXEC_ERROR (normal error), protected call)
*
* Even when executing a protected call an error may be thrown in rare cases.
* For instance, if we run out of memory when setting up the return stack
@ -561,7 +561,7 @@ int duk_handle_call(duk_hthread *thr,
duk_hobject *env;
duk_jmpbuf our_jmpbuf;
duk_tval tv_tmp;
int retval = DUK_ERR_EXEC_ERROR;
int retval = DUK_EXEC_ERROR;
int rc;
DUK_ASSERT(thr != NULL);
@ -759,7 +759,7 @@ int duk_handle_call(duk_hthread *thr,
/* Note: currently a second setjmp restoration is done at the target;
* this is OK, but could be refactored away.
*/
retval = DUK_ERR_EXEC_ERROR;
retval = DUK_EXEC_ERROR;
goto shrink_and_finished;
handle_call:
@ -1132,7 +1132,7 @@ int duk_handle_call(duk_hthread *thr,
* Shrink checks and return with success.
*/
retval = DUK_ERR_EXEC_SUCCESS;
retval = DUK_EXEC_SUCCESS;
goto shrink_and_finished;
/*
@ -1209,7 +1209,7 @@ int duk_handle_call(duk_hthread *thr,
* Shrink checks and return with success.
*/
retval = DUK_ERR_EXEC_SUCCESS;
retval = DUK_EXEC_SUCCESS;
goto shrink_and_finished;
shrink_and_finished:
@ -1264,7 +1264,7 @@ int duk_handle_call(duk_hthread *thr,
thread_state_error:
DUK_ERROR(thr, DUK_ERR_TYPE_ERROR, "invalid thread state for call (%d)", thr->state);
DUK_UNREACHABLE();
return DUK_ERR_EXEC_ERROR; /* never executed */
return DUK_EXEC_ERROR; /* never executed */
}
/*
@ -1489,7 +1489,7 @@ int duk_handle_safe_call(duk_hthread *thr,
DUK_DEBUG_DUMP_HTHREAD(thr);
#endif
retval = DUK_ERR_EXEC_ERROR;
retval = DUK_EXEC_ERROR;
goto shrink_and_finished;
/*
@ -1581,7 +1581,7 @@ int duk_handle_safe_call(duk_hthread *thr,
safe_call_adjust_valstack(thr, idx_retbase, num_stack_rets, rc);
/* Note: no need from callstack / catchstack shrink check */
retval = DUK_ERR_EXEC_SUCCESS;
retval = DUK_EXEC_SUCCESS;
goto finished;
shrink_and_finished:
@ -1630,7 +1630,7 @@ int duk_handle_safe_call(duk_hthread *thr,
thread_state_error:
DUK_ERROR(thr, DUK_ERR_TYPE_ERROR, "invalid thread state for safe_call (%d)", thr->state);
DUK_UNREACHABLE();
return DUK_ERR_EXEC_ERROR; /* never executed */
return DUK_EXEC_ERROR; /* never executed */
}
/*

4
src/duktape.h

@ -196,10 +196,6 @@ struct duk_memory_functions {
/* Return codes for protected calls (duk_safe_call(), duk_pcall()). */
#define DUK_EXEC_SUCCESS 0
#define DUK_EXEC_ERROR 1
/* FIXME: these codes will be refined later (separate code for a fatal API error,
* distinct from normal error). These must now match internal DUK_ERR_EXEC_xxx
* defines. The internal codes should be removed.
*/
/*
* If no variadic macros, __FILE__ and __LINE__ are passed through globals

Loading…
Cancel
Save