mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Move smjs_invoke_elinks_object_method from hooks.c to elinks_object.c.
This commit is contained in:
parent
3302baca35
commit
71fb9a1db7
@ -54,3 +54,30 @@ smjs_get_elinks_object(JSObject *global_object)
|
|||||||
(JSClass *) &elinks_class, NULL, 0, NULL,
|
(JSClass *) &elinks_class, NULL, 0, NULL,
|
||||||
(JSFunctionSpec *) elinks_funcs, NULL, NULL);
|
(JSFunctionSpec *) elinks_funcs, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If elinks.<method> is defined, call it with the given arguments,
|
||||||
|
* store the return value in rval, and return JS_TRUE. Else return JS_FALSE. */
|
||||||
|
JSBool
|
||||||
|
smjs_invoke_elinks_object_method(unsigned char *method, jsval argv[], int argc,
|
||||||
|
jsval *rval)
|
||||||
|
{
|
||||||
|
JSFunction *func;
|
||||||
|
|
||||||
|
assert(smjs_ctx);
|
||||||
|
assert(smjs_elinks_object);
|
||||||
|
assert(rval);
|
||||||
|
assert(argv);
|
||||||
|
|
||||||
|
if (JS_FALSE == JS_GetProperty(smjs_ctx, smjs_elinks_object,
|
||||||
|
method, rval))
|
||||||
|
return JS_FALSE;
|
||||||
|
|
||||||
|
if (JSVAL_VOID == *rval)
|
||||||
|
return JS_FALSE;
|
||||||
|
|
||||||
|
func = JS_ValueToFunction(smjs_ctx, *rval);
|
||||||
|
assert(func);
|
||||||
|
|
||||||
|
return JS_CallFunction(smjs_ctx, smjs_elinks_object,
|
||||||
|
func, argc, argv, rval);
|
||||||
|
}
|
||||||
|
@ -4,5 +4,7 @@
|
|||||||
#include "ecmascript/spidermonkey/util.h"
|
#include "ecmascript/spidermonkey/util.h"
|
||||||
|
|
||||||
JSObject *smjs_get_elinks_object(JSObject *global_object);
|
JSObject *smjs_get_elinks_object(JSObject *global_object);
|
||||||
|
JSBool smjs_invoke_elinks_object_method(unsigned char *method,
|
||||||
|
jsval argv[], int argc, jsval *rval);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -17,33 +17,6 @@
|
|||||||
#include "session/session.h"
|
#include "session/session.h"
|
||||||
|
|
||||||
|
|
||||||
/* If elinks.<method> is defined, call it with the given arguments,
|
|
||||||
* store the return value in rval, and return JS_TRUE. Else return JS_FALSE. */
|
|
||||||
static JSBool
|
|
||||||
smjs_invoke_elinks_object_method(unsigned char *method, jsval argv[], int argc,
|
|
||||||
jsval *rval)
|
|
||||||
{
|
|
||||||
JSFunction *func;
|
|
||||||
|
|
||||||
assert(smjs_ctx);
|
|
||||||
assert(smjs_elinks_object);
|
|
||||||
assert(rval);
|
|
||||||
assert(argv);
|
|
||||||
|
|
||||||
if (JS_FALSE == JS_GetProperty(smjs_ctx, smjs_elinks_object,
|
|
||||||
method, rval))
|
|
||||||
return JS_FALSE;
|
|
||||||
|
|
||||||
if (JSVAL_VOID == *rval)
|
|
||||||
return JS_FALSE;
|
|
||||||
|
|
||||||
func = JS_ValueToFunction(smjs_ctx, *rval);
|
|
||||||
assert(func);
|
|
||||||
|
|
||||||
return JS_CallFunction(smjs_ctx, smjs_elinks_object,
|
|
||||||
func, argc, argv, rval);
|
|
||||||
}
|
|
||||||
|
|
||||||
static enum evhook_status
|
static enum evhook_status
|
||||||
script_hook_pre_format_html(va_list ap, void *data)
|
script_hook_pre_format_html(va_list ap, void *data)
|
||||||
{
|
{
|
||||||
@ -64,7 +37,8 @@ script_hook_pre_format_html(va_list ap, void *data)
|
|||||||
|
|
||||||
args[0] = OBJECT_TO_JSVAL(cache_entry_object);
|
args[0] = OBJECT_TO_JSVAL(cache_entry_object);
|
||||||
|
|
||||||
if (JS_TRUE == call_script_hook("preformat_html", args, 1, &rval))
|
if (JS_TRUE == smjs_invoke_elinks_object_method("preformat_html",
|
||||||
|
args, 1, &rval))
|
||||||
if (JS_FALSE == JSVAL_TO_BOOLEAN(rval))
|
if (JS_FALSE == JSVAL_TO_BOOLEAN(rval))
|
||||||
ret = EVENT_HOOK_STATUS_LAST;
|
ret = EVENT_HOOK_STATUS_LAST;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user