mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Bug 846: Add plenty of JS_InstanceOf assertions and checks.
This commit is contained in:
parent
bbf0d478e9
commit
47dce0922b
@ -25,6 +25,7 @@
|
||||
#include "ecmascript/spidermonkey/form.h"
|
||||
#include "ecmascript/spidermonkey/location.h"
|
||||
#include "ecmascript/spidermonkey/document.h"
|
||||
#include "ecmascript/spidermonkey/window.h"
|
||||
#include "intl/gettext/libintl.h"
|
||||
#include "main/select.h"
|
||||
#include "osdep/newwin.h"
|
||||
@ -79,7 +80,12 @@ document_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
struct document *document;
|
||||
struct session *ses;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &document_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_win = JS_GetParent(ctx, obj);
|
||||
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||
doc_view = vs->doc_view;
|
||||
document = doc_view->document;
|
||||
@ -171,7 +177,12 @@ document_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
struct document_view *doc_view;
|
||||
struct document *document;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &document_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_win = JS_GetParent(ctx, obj);
|
||||
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||
doc_view = vs->doc_view;
|
||||
document = doc_view->document;
|
||||
|
@ -22,7 +22,9 @@
|
||||
#include "document/forms.h"
|
||||
#include "document/view.h"
|
||||
#include "ecmascript/ecmascript.h"
|
||||
#include "ecmascript/spidermonkey/document.h"
|
||||
#include "ecmascript/spidermonkey/form.h"
|
||||
#include "ecmascript/spidermonkey/window.h"
|
||||
#include "intl/gettext/libintl.h"
|
||||
#include "main/select.h"
|
||||
#include "osdep/newwin.h"
|
||||
@ -44,6 +46,9 @@
|
||||
#include "viewer/text/vs.h"
|
||||
|
||||
|
||||
static const JSClass form_class; /* defined below */
|
||||
|
||||
|
||||
/* Accordingly to the JS specs, each input type should own object. That'd be a
|
||||
* huge PITA though, however DOM comes to the rescue and defines just a single
|
||||
* HTMLInputElement. The difference could be spotted only by some clever tricky
|
||||
@ -136,9 +141,18 @@ input_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
int linknum;
|
||||
struct link *link = NULL;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &input_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_form = JS_GetParent(ctx, obj);
|
||||
assert(JS_InstanceOf(ctx, parent_form, (JSClass *) &form_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_doc = JS_GetParent(ctx, parent_form);
|
||||
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_win = JS_GetParent(ctx, parent_doc);
|
||||
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||
doc_view = vs->doc_view;
|
||||
document = doc_view->document;
|
||||
@ -268,9 +282,18 @@ input_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
struct link *link = NULL;
|
||||
unicode_val_T accesskey;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &input_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_form = JS_GetParent(ctx, obj);
|
||||
assert(JS_InstanceOf(ctx, parent_form, (JSClass *) &form_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_doc = JS_GetParent(ctx, parent_form);
|
||||
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_win = JS_GetParent(ctx, parent_doc);
|
||||
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||
doc_view = vs->doc_view;
|
||||
document = doc_view->document;
|
||||
@ -376,9 +399,17 @@ input_click(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
struct form_control *fc;
|
||||
int linknum;
|
||||
|
||||
if (!JS_InstanceOf(ctx, obj, (JSClass *) &input_class, argv)) return JS_FALSE;
|
||||
parent_form = JS_GetParent(ctx, obj);
|
||||
assert(JS_InstanceOf(ctx, parent_form, (JSClass *) &form_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_doc = JS_GetParent(ctx, parent_form);
|
||||
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_win = JS_GetParent(ctx, parent_doc);
|
||||
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||
doc_view = vs->doc_view;
|
||||
document = doc_view->document;
|
||||
@ -420,9 +451,17 @@ input_focus(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
struct form_control *fc;
|
||||
int linknum;
|
||||
|
||||
if (!JS_InstanceOf(ctx, obj, (JSClass *) &input_class, argv)) return JS_FALSE;
|
||||
parent_form = JS_GetParent(ctx, obj);
|
||||
assert(JS_InstanceOf(ctx, parent_form, (JSClass *) &form_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_doc = JS_GetParent(ctx, parent_form);
|
||||
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_win = JS_GetParent(ctx, parent_doc);
|
||||
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||
doc_view = vs->doc_view;
|
||||
document = doc_view->document;
|
||||
@ -542,9 +581,18 @@ form_elements_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
struct form_view *form_view;
|
||||
struct form *form;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &form_elements_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_form = JS_GetParent(ctx, obj);
|
||||
assert(JS_InstanceOf(ctx, parent_form, (JSClass *) &form_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_doc = JS_GetParent(ctx, parent_form);
|
||||
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_win = JS_GetParent(ctx, parent_doc);
|
||||
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||
doc_view = vs->doc_view;
|
||||
document = doc_view->document;
|
||||
@ -590,9 +638,17 @@ form_elements_item(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval
|
||||
int counter = -1;
|
||||
int index;
|
||||
|
||||
if (!JS_InstanceOf(ctx, obj, (JSClass *) &form_elements_class, argv)) return JS_FALSE;
|
||||
parent_form = JS_GetParent(ctx, obj);
|
||||
assert(JS_InstanceOf(ctx, parent_form, (JSClass *) &form_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_doc = JS_GetParent(ctx, parent_form);
|
||||
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_win = JS_GetParent(ctx, parent_doc);
|
||||
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||
doc_view = vs->doc_view;
|
||||
document = doc_view->document;
|
||||
@ -636,9 +692,17 @@ form_elements_namedItem(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv,
|
||||
struct form_control *fc;
|
||||
unsigned char *string;
|
||||
|
||||
if (!JS_InstanceOf(ctx, obj, (JSClass *) &form_elements_class, argv)) return JS_FALSE;
|
||||
parent_form = JS_GetParent(ctx, obj);
|
||||
assert(JS_InstanceOf(ctx, parent_form, (JSClass *) &form_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_doc = JS_GetParent(ctx, parent_form);
|
||||
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_win = JS_GetParent(ctx, parent_doc);
|
||||
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||
doc_view = vs->doc_view;
|
||||
document = doc_view->document;
|
||||
@ -724,8 +788,15 @@ form_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
struct form_view *fv;
|
||||
struct form *form;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &form_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_doc = JS_GetParent(ctx, obj);
|
||||
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_win = JS_GetParent(ctx, parent_doc);
|
||||
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||
doc_view = vs->doc_view;
|
||||
fv = JS_GetPrivate(ctx, obj); /* from @form_class */
|
||||
@ -839,8 +910,15 @@ form_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
struct form *form;
|
||||
unsigned char *string;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &form_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_doc = JS_GetParent(ctx, obj);
|
||||
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_win = JS_GetParent(ctx, parent_doc);
|
||||
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||
doc_view = vs->doc_view;
|
||||
fv = JS_GetPrivate(ctx, obj); /* from @form_class */
|
||||
@ -909,8 +987,14 @@ form_reset(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
struct form_view *fv;
|
||||
struct form *form;
|
||||
|
||||
if (!JS_InstanceOf(ctx, obj, (JSClass *) &form_class, argv)) return JS_FALSE;
|
||||
parent_doc = JS_GetParent(ctx, obj);
|
||||
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_win = JS_GetParent(ctx, parent_doc);
|
||||
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||
doc_view = vs->doc_view;
|
||||
fv = JS_GetPrivate(ctx, obj); /* from @form_class */
|
||||
@ -938,8 +1022,14 @@ form_submit(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
struct form_view *fv;
|
||||
struct form *form;
|
||||
|
||||
if (!JS_InstanceOf(ctx, obj, (JSClass *) &form_class, argv)) return JS_FALSE;
|
||||
parent_doc = JS_GetParent(ctx, obj);
|
||||
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_win = JS_GetParent(ctx, parent_doc);
|
||||
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||
doc_view = vs->doc_view;
|
||||
ses = doc_view->session;
|
||||
@ -972,8 +1062,6 @@ get_form_object(JSContext *ctx, JSObject *jsdoc, struct form_view *fv)
|
||||
fv->ecmascript_obj = jsform;
|
||||
return fv->ecmascript_obj;
|
||||
}
|
||||
|
||||
|
||||
static JSBool forms_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp);
|
||||
|
||||
/* Each @forms_class object must have a @document_class parent. */
|
||||
@ -1012,8 +1100,15 @@ forms_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
struct document_view *doc_view;
|
||||
struct document *document;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &forms_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_doc = JS_GetParent(ctx, obj);
|
||||
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_win = JS_GetParent(ctx, parent_doc);
|
||||
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||
doc_view = vs->doc_view;
|
||||
document = doc_view->document;
|
||||
@ -1050,8 +1145,14 @@ forms_item(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
int counter = -1;
|
||||
int index;
|
||||
|
||||
if (!JS_InstanceOf(ctx, obj, (JSClass *) &forms_class, argv)) return JS_FALSE;
|
||||
parent_doc = JS_GetParent(ctx, obj);
|
||||
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_win = JS_GetParent(ctx, parent_doc);
|
||||
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||
|
||||
if (argc != 1)
|
||||
@ -1084,8 +1185,14 @@ forms_namedItem(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *r
|
||||
struct form *form;
|
||||
unsigned char *string;
|
||||
|
||||
if (!JS_InstanceOf(ctx, obj, (JSClass *) &forms_class, argv)) return JS_FALSE;
|
||||
parent_doc = JS_GetParent(ctx, obj);
|
||||
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_win = JS_GetParent(ctx, parent_doc);
|
||||
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||
doc_view = vs->doc_view;
|
||||
document = doc_view->document;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "document/view.h"
|
||||
#include "ecmascript/ecmascript.h"
|
||||
#include "ecmascript/spidermonkey/location.h"
|
||||
#include "ecmascript/spidermonkey/window.h"
|
||||
#include "intl/gettext/libintl.h"
|
||||
#include "main/select.h"
|
||||
#include "osdep/newwin.h"
|
||||
@ -148,7 +149,12 @@ location_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
JSObject *parent_win; /* instance of @window_class */
|
||||
struct view_state *vs;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &location_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_win = JS_GetParent(ctx, obj);
|
||||
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||
|
||||
if (!JSVAL_IS_INT(id))
|
||||
@ -176,7 +182,12 @@ location_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
struct view_state *vs;
|
||||
struct document_view *doc_view;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &location_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_win = JS_GetParent(ctx, obj);
|
||||
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||
doc_view = vs->doc_view;
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "document/view.h"
|
||||
#include "ecmascript/ecmascript.h"
|
||||
#include "ecmascript/spidermonkey/unibar.h"
|
||||
#include "ecmascript/spidermonkey/window.h"
|
||||
#include "intl/gettext/libintl.h"
|
||||
#include "main/select.h"
|
||||
#include "osdep/newwin.h"
|
||||
@ -81,7 +82,13 @@ unibar_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
struct session_status *status;
|
||||
unsigned char *bar;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &menubar_class, NULL)
|
||||
|| JS_InstanceOf(ctx, obj, (JSClass *) &statusbar_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_win = JS_GetParent(ctx, obj);
|
||||
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||
doc_view = vs->doc_view;
|
||||
status = &doc_view->session->status;
|
||||
@ -127,7 +134,13 @@ unibar_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
struct session_status *status;
|
||||
unsigned char *bar;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &menubar_class, NULL)
|
||||
|| JS_InstanceOf(ctx, obj, (JSClass *) &statusbar_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
parent_win = JS_GetParent(ctx, obj);
|
||||
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||
doc_view = vs->doc_view;
|
||||
status = &doc_view->session->status;
|
||||
|
@ -122,6 +122,9 @@ window_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
struct view_state *vs;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &window_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, obj); /* from @window_class */
|
||||
|
||||
/* No need for special window.location measurements - when
|
||||
@ -243,6 +246,9 @@ window_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
struct view_state *vs;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &window_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, obj); /* from @window_class */
|
||||
|
||||
if (JSVAL_IS_STRING(id)) {
|
||||
@ -292,6 +298,8 @@ window_alert(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval
|
||||
struct view_state *vs;
|
||||
unsigned char *string;
|
||||
|
||||
if (!JS_InstanceOf(ctx, obj, (JSClass *) &window_class, argv)) return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, obj); /* from @window_class */
|
||||
|
||||
if (argc != 1)
|
||||
@ -321,6 +329,8 @@ window_open(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
static time_t ratelimit_start;
|
||||
static int ratelimit_count;
|
||||
|
||||
if (!JS_InstanceOf(ctx, obj, (JSClass *) &window_class, argv)) return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, obj); /* from @window_class */
|
||||
doc_view = vs->doc_view;
|
||||
ses = doc_view->session;
|
||||
|
@ -21,12 +21,17 @@ struct smjs_action_fn_callback_hop {
|
||||
action_id_T action_id;
|
||||
};
|
||||
|
||||
static const JSClass action_fn_class; /* defined below */
|
||||
|
||||
/* @action_fn_class.finalize */
|
||||
static void
|
||||
smjs_action_fn_finalize(JSContext *ctx, JSObject *obj)
|
||||
{
|
||||
struct smjs_action_fn_callback_hop *hop;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &action_fn_class, NULL));
|
||||
if_assert_failed return;
|
||||
|
||||
hop = JS_GetPrivate(ctx, obj); /* from @action_fn_class */
|
||||
|
||||
if (hop) mem_free(hop);
|
||||
@ -40,7 +45,9 @@ smjs_action_fn_callback(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv,
|
||||
struct smjs_action_fn_callback_hop *hop;
|
||||
JSObject *fn_obj;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &action_fn_class, NULL));
|
||||
assert(smjs_ctx);
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
*rval = JS_FALSE;
|
||||
|
||||
|
@ -14,6 +14,9 @@
|
||||
#include "util/memory.h"
|
||||
|
||||
|
||||
static const JSClass bookmark_class, bookmark_folder_class; /* defined below */
|
||||
|
||||
|
||||
/*** common code ***/
|
||||
|
||||
static JSObject *
|
||||
@ -21,6 +24,9 @@ smjs_get_bookmark_generic_object(struct bookmark *bookmark, JSClass *clasp)
|
||||
{
|
||||
JSObject *jsobj;
|
||||
|
||||
assert(clasp == &bookmark_class || clasp == &bookmark_folder_class);
|
||||
if_assert_failed return NULL;
|
||||
|
||||
jsobj = JS_NewObject(smjs_ctx, clasp, NULL, NULL);
|
||||
if (!jsobj) return NULL;
|
||||
|
||||
@ -41,6 +47,10 @@ bookmark_finalize(JSContext *ctx, JSObject *obj)
|
||||
{
|
||||
struct bookmark *bookmark;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &bookmark_class, NULL)
|
||||
|| JS_InstanceOf(ctx, obj, (JSClass *) &bookmark_folder_class, NULL));
|
||||
if_assert_failed return;
|
||||
|
||||
bookmark = JS_GetPrivate(ctx, obj); /* from @bookmark_class or @bookmark_folder_class */
|
||||
|
||||
if (bookmark) object_unlock(bookmark);
|
||||
@ -70,6 +80,9 @@ bookmark_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
struct bookmark *bookmark;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &bookmark_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
bookmark = JS_GetPrivate(ctx, obj); /* from @bookmark_class */
|
||||
|
||||
if (!bookmark) return JS_FALSE;
|
||||
@ -108,6 +121,9 @@ bookmark_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
struct bookmark *bookmark;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &bookmark_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
bookmark = JS_GetPrivate(ctx, obj); /* from @bookmark_class */
|
||||
|
||||
if (!bookmark) return JS_FALSE;
|
||||
@ -175,6 +191,9 @@ bookmark_folder_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
struct bookmark *folder;
|
||||
unsigned char *title;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &bookmark_folder_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
folder = JS_GetPrivate(ctx, obj); /* from @bookmark_folder_class */
|
||||
|
||||
*vp = JSVAL_NULL;
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include "util/error.h"
|
||||
#include "util/memory.h"
|
||||
|
||||
static const JSClass cache_entry_class; /* defined below */
|
||||
|
||||
enum cache_entry_prop {
|
||||
CACHE_ENTRY_CONTENT,
|
||||
CACHE_ENTRY_TYPE,
|
||||
@ -37,6 +39,9 @@ cache_entry_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
struct cache_entry *cached;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &cache_entry_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
cached = JS_GetPrivate(ctx, obj); /* from @cache_entry_class */
|
||||
|
||||
if (!cache_entry_is_valid(cached)) return JS_FALSE;
|
||||
@ -91,6 +96,9 @@ cache_entry_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
struct cache_entry *cached;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &cache_entry_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
cached = JS_GetPrivate(ctx, obj); /* from @cache_entry_class */
|
||||
|
||||
if (!cache_entry_is_valid(cached)) return JS_FALSE;
|
||||
@ -141,6 +149,9 @@ cache_entry_finalize(JSContext *ctx, JSObject *obj)
|
||||
{
|
||||
struct cache_entry *cached;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &cache_entry_class, NULL));
|
||||
if_assert_failed return;
|
||||
|
||||
cached = JS_GetPrivate(ctx, obj); /* from @cache_entry_class */
|
||||
|
||||
if (!cached) return;
|
||||
|
@ -13,12 +13,18 @@
|
||||
#include "util/memory.h"
|
||||
|
||||
|
||||
static const JSClass smjs_globhist_item_class; /* defined below */
|
||||
|
||||
|
||||
/* @smjs_globhist_item_class.finalize */
|
||||
static void
|
||||
smjs_globhist_item_finalize(JSContext *ctx, JSObject *obj)
|
||||
{
|
||||
struct global_history_item *history_item;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &smjs_globhist_item_class, NULL));
|
||||
if_assert_failed return;
|
||||
|
||||
history_item = JS_GetPrivate(ctx, obj); /* from @smjs_globhist_item_class */
|
||||
|
||||
if (history_item) object_unlock(history_item);
|
||||
@ -44,6 +50,9 @@ smjs_globhist_item_get_property(JSContext *ctx, JSObject *obj, jsval id,
|
||||
{
|
||||
struct global_history_item *history_item;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &smjs_globhist_item_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
history_item = JS_GetPrivate(ctx, obj); /* from @smjs_globhist_item_class */
|
||||
|
||||
if (!history_item) return JS_FALSE;
|
||||
@ -98,6 +107,9 @@ smjs_globhist_item_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *
|
||||
{
|
||||
struct global_history_item *history_item;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &smjs_globhist_item_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
history_item = JS_GetPrivate(ctx, obj); /* from @smjs_globhist_item_class */
|
||||
|
||||
if (!history_item) return JS_FALSE;
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include "scripting/smjs/elinks_object.h"
|
||||
#include "util/memory.h"
|
||||
|
||||
static const JSClass keymap_class; /* defined below */
|
||||
|
||||
/* @keymap_class.getProperty */
|
||||
static JSBool
|
||||
keymap_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
@ -22,6 +24,9 @@ keymap_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
int *data;
|
||||
enum keymap_id keymap_id = *data;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &keymap_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
data = JS_GetPrivate(ctx, obj); /* from @keymap_class */
|
||||
|
||||
keystroke_str = JS_GetStringBytes(JS_ValueToString(ctx, id));
|
||||
@ -70,6 +75,9 @@ keymap_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
unsigned char *keymap_str;
|
||||
const unsigned char *keystroke_str;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &keymap_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
data = JS_GetPrivate(ctx, obj); /* from @keymap_class */
|
||||
|
||||
/* Ugly fact: we need to get the string from the id to give to bind_do,
|
||||
@ -139,6 +147,9 @@ keymap_finalize(JSContext *ctx, JSObject *obj)
|
||||
{
|
||||
void *data;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &keymap_class, NULL));
|
||||
if_assert_failed return;
|
||||
|
||||
data = JS_GetPrivate(ctx, obj); /* from @keymap_class */
|
||||
|
||||
mem_free(data);
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "util/memory.h"
|
||||
#include "viewer/text/vs.h"
|
||||
|
||||
static const JSClass view_state_class; /* defined below */
|
||||
|
||||
enum view_state_prop {
|
||||
VIEW_STATE_PLAIN,
|
||||
VIEW_STATE_URI,
|
||||
@ -37,6 +39,9 @@ view_state_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
struct view_state *vs;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &view_state_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, obj); /* from @view_state_class */
|
||||
|
||||
undef_to_jsval(ctx, vp);
|
||||
@ -68,6 +73,9 @@ view_state_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
struct view_state *vs;
|
||||
|
||||
assert(JS_InstanceOf(ctx, obj, (JSClass *) &view_state_class, NULL));
|
||||
if_assert_failed return JS_FALSE;
|
||||
|
||||
vs = JS_GetPrivate(ctx, obj); /* from @view_state_class */
|
||||
|
||||
if (!JSVAL_IS_INT(id))
|
||||
|
Loading…
Reference in New Issue
Block a user