1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Bug 846: Separate JS_GetParent & JS_GetPrivate calls from initializations.

This will allow the types of objects to be checked before those calls.

(Adapted from bbf0d478e9 in ELinks 0.12.GIT.)
This commit is contained in:
Kalle Olavi Niemitalo 2006-11-25 21:14:56 +02:00 committed by Kalle Olavi Niemitalo
parent 4c58b4c56c
commit 9a829b3277
9 changed files with 308 additions and 136 deletions

View File

@ -73,11 +73,17 @@ const JSPropertySpec document_props[] = {
static JSBool
document_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
JSObject *parent_win = JS_GetParent(ctx, obj);
struct view_state *vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
struct document_view *doc_view = vs->doc_view;
struct document *document = doc_view->document;
struct session *ses = doc_view->session;
JSObject *parent_win; /* instance of @window_class */
struct view_state *vs;
struct document_view *doc_view;
struct document *document;
struct session *ses;
parent_win = JS_GetParent(ctx, obj);
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
doc_view = vs->doc_view;
document = doc_view->document;
ses = doc_view->session;
if (JSVAL_IS_STRING(id)) {
struct form *form;
@ -157,10 +163,15 @@ document_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
static JSBool
document_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
JSObject *parent_win = JS_GetParent(ctx, obj);
struct view_state *vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
struct document_view *doc_view = vs->doc_view;
struct document *document = doc_view->document;
JSObject *parent_win; /* instance of @window_class */
struct view_state *vs;
struct document_view *doc_view;
struct document *document;
parent_win = JS_GetParent(ctx, obj);
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
doc_view = vs->doc_view;
document = doc_view->document;
if (JSVAL_IS_STRING(id)) {
#ifdef CONFIG_COOKIES

View File

@ -120,17 +120,26 @@ static const JSFunctionSpec input_funcs[] = {
static JSBool
input_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
JSObject *parent_form = JS_GetParent(ctx, obj);
JSObject *parent_doc = JS_GetParent(ctx, parent_form);
JSObject *parent_win = JS_GetParent(ctx, parent_doc);
struct view_state *vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
struct document_view *doc_view = vs->doc_view;
struct document *document = doc_view->document;
struct form_state *fs = JS_GetPrivate(ctx, obj); /* from @input_class */
struct form_control *fc = find_form_control(document, fs);
JSObject *parent_form; /* instance of @form_class */
JSObject *parent_doc; /* instance of @document_class */
JSObject *parent_win; /* instance of @window_class */
struct view_state *vs;
struct document_view *doc_view;
struct document *document;
struct form_state *fs;
struct form_control *fc;
int linknum;
struct link *link = NULL;
parent_form = JS_GetParent(ctx, obj);
parent_doc = JS_GetParent(ctx, parent_form);
parent_win = JS_GetParent(ctx, parent_doc);
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
doc_view = vs->doc_view;
document = doc_view->document;
fs = JS_GetPrivate(ctx, obj); /* from @input_class */
fc = find_form_control(document, fs);
assert(fc);
assert(fc->form && fs);
@ -233,17 +242,26 @@ input_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
static JSBool
input_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
JSObject *parent_form = JS_GetParent(ctx, obj);
JSObject *parent_doc = JS_GetParent(ctx, parent_form);
JSObject *parent_win = JS_GetParent(ctx, parent_doc);
struct view_state *vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
struct document_view *doc_view = vs->doc_view;
struct document *document = doc_view->document;
struct form_state *fs = JS_GetPrivate(ctx, obj); /* from @input_class */
struct form_control *fc = find_form_control(document, fs);
JSObject *parent_form; /* instance of @form_class */
JSObject *parent_doc; /* instance of @document_class */
JSObject *parent_win; /* instance of @window_class */
struct view_state *vs;
struct document_view *doc_view;
struct document *document;
struct form_state *fs;
struct form_control *fc;
int linknum;
struct link *link = NULL;
parent_form = JS_GetParent(ctx, obj);
parent_doc = JS_GetParent(ctx, parent_form);
parent_win = JS_GetParent(ctx, parent_doc);
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
doc_view = vs->doc_view;
document = doc_view->document;
fs = JS_GetPrivate(ctx, obj); /* from @input_class */
fc = find_form_control(document, fs);
assert(fc);
assert(fc->form && fs);
@ -319,17 +337,26 @@ input_blur(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool
input_click(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
JSObject *parent_form = JS_GetParent(ctx, obj);
JSObject *parent_doc = JS_GetParent(ctx, parent_form);
JSObject *parent_win = JS_GetParent(ctx, parent_doc);
struct view_state *vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
struct document_view *doc_view = vs->doc_view;
struct document *document = doc_view->document;
struct session *ses = doc_view->session;
struct form_state *fs = JS_GetPrivate(ctx, obj); /* from @input_class */
JSObject *parent_form; /* instance of @form_class */
JSObject *parent_doc; /* instance of @document_class */
JSObject *parent_win; /* instance of @window_class */
struct view_state *vs;
struct document_view *doc_view;
struct document *document;
struct session *ses;
struct form_state *fs;
struct form_control *fc;
int linknum;
parent_form = JS_GetParent(ctx, obj);
parent_doc = JS_GetParent(ctx, parent_form);
parent_win = JS_GetParent(ctx, parent_doc);
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
doc_view = vs->doc_view;
document = doc_view->document;
ses = doc_view->session;
fs = JS_GetPrivate(ctx, obj); /* from @input_class */
assert(fs);
fc = find_form_control(document, fs);
assert(fc);
@ -354,17 +381,26 @@ input_click(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool
input_focus(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
JSObject *parent_form = JS_GetParent(ctx, obj);
JSObject *parent_doc = JS_GetParent(ctx, parent_form);
JSObject *parent_win = JS_GetParent(ctx, parent_doc);
struct view_state *vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
struct document_view *doc_view = vs->doc_view;
struct document *document = doc_view->document;
struct session *ses = doc_view->session;
struct form_state *fs = JS_GetPrivate(ctx, obj); /* from @input_class */
JSObject *parent_form; /* instance of @form_class */
JSObject *parent_doc; /* instance of @document_class */
JSObject *parent_win; /* instance of @window_class */
struct view_state *vs;
struct document_view *doc_view;
struct document *document;
struct session *ses;
struct form_state *fs;
struct form_control *fc;
int linknum;
parent_form = JS_GetParent(ctx, obj);
parent_doc = JS_GetParent(ctx, parent_form);
parent_win = JS_GetParent(ctx, parent_doc);
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
doc_view = vs->doc_view;
document = doc_view->document;
ses = doc_view->session;
fs = JS_GetPrivate(ctx, obj); /* from @input_class */
assert(fs);
fc = find_form_control(document, fs);
assert(fc);
@ -467,14 +503,23 @@ static const JSPropertySpec form_elements_props[] = {
static JSBool
form_elements_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
JSObject *parent_form = JS_GetParent(ctx, obj);
JSObject *parent_doc = JS_GetParent(ctx, parent_form);
JSObject *parent_win = JS_GetParent(ctx, parent_doc);
struct view_state *vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
struct document_view *doc_view = vs->doc_view;
struct document *document = doc_view->document;
struct form_view *form_view = JS_GetPrivate(ctx, parent_form); /* from @form_class */
struct form *form = find_form_by_form_view(document, form_view);
JSObject *parent_form; /* instance of @form_class */
JSObject *parent_doc; /* instance of @document_class */
JSObject *parent_win; /* instance of @window_class */
struct view_state *vs;
struct document_view *doc_view;
struct document *document;
struct form_view *form_view;
struct form *form;
parent_form = JS_GetParent(ctx, obj);
parent_doc = JS_GetParent(ctx, parent_form);
parent_win = JS_GetParent(ctx, parent_doc);
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
doc_view = vs->doc_view;
document = doc_view->document;
form_view = JS_GetPrivate(ctx, parent_form); /* from @form_class */
form = find_form_by_form_view(document, form_view);
if (JSVAL_IS_STRING(id)) {
form_elements_namedItem(ctx, obj, 1, &id, vp);
@ -503,18 +548,27 @@ form_elements_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
static JSBool
form_elements_item(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
JSObject *parent_form = JS_GetParent(ctx, obj);
JSObject *parent_doc = JS_GetParent(ctx, parent_form);
JSObject *parent_win = JS_GetParent(ctx, parent_doc);
struct view_state *vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
struct document_view *doc_view = vs->doc_view;
struct document *document = doc_view->document;
struct form_view *form_view = JS_GetPrivate(ctx, parent_form); /* from @form_class */
struct form *form = find_form_by_form_view(document, form_view);
JSObject *parent_form; /* instance of @form_class */
JSObject *parent_doc; /* instance of @document_class */
JSObject *parent_win; /* instance of @window_class */
struct view_state *vs;
struct document_view *doc_view;
struct document *document;
struct form_view *form_view;
struct form *form;
struct form_control *fc;
int counter = -1;
int index;
parent_form = JS_GetParent(ctx, obj);
parent_doc = JS_GetParent(ctx, parent_form);
parent_win = JS_GetParent(ctx, parent_doc);
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
doc_view = vs->doc_view;
document = doc_view->document;
form_view = JS_GetPrivate(ctx, parent_form); /* from @form_class */
form = find_form_by_form_view(document, form_view);
if (argc != 1)
return JS_TRUE;
@ -541,17 +595,26 @@ form_elements_item(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval
static JSBool
form_elements_namedItem(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
JSObject *parent_form = JS_GetParent(ctx, obj);
JSObject *parent_doc = JS_GetParent(ctx, parent_form);
JSObject *parent_win = JS_GetParent(ctx, parent_doc);
struct view_state *vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
struct document_view *doc_view = vs->doc_view;
struct document *document = doc_view->document;
struct form_view *form_view = JS_GetPrivate(ctx, parent_form); /* from @form_class */
struct form *form = find_form_by_form_view(document, form_view);
JSObject *parent_form; /* instance of @form_class */
JSObject *parent_doc; /* instance of @document_class */
JSObject *parent_win; /* instance of @window_class */
struct view_state *vs;
struct document_view *doc_view;
struct document *document;
struct form_view *form_view;
struct form *form;
struct form_control *fc;
unsigned char *string;
parent_form = JS_GetParent(ctx, obj);
parent_doc = JS_GetParent(ctx, parent_form);
parent_win = JS_GetParent(ctx, parent_doc);
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
doc_view = vs->doc_view;
document = doc_view->document;
form_view = JS_GetPrivate(ctx, parent_form); /* from @form_class */
form = find_form_by_form_view(document, form_view);
if (argc != 1)
return JS_TRUE;
@ -624,12 +687,19 @@ static JSBool
form_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
/* DBG("doc %p %s\n", parent_doc, JS_GetStringBytes(JS_ValueToString(ctx, OBJECT_TO_JSVAL(parent_doc)))); */
JSObject *parent_doc = JS_GetParent(ctx, obj);
JSObject *parent_win = JS_GetParent(ctx, parent_doc);
struct view_state *vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
struct document_view *doc_view = vs->doc_view;
struct form_view *fv = JS_GetPrivate(ctx, obj); /* from @form_class */
struct form *form = find_form_by_form_view(doc_view->document, fv);
JSObject *parent_doc; /* instance of @document_class */
JSObject *parent_win; /* instance of @window_class */
struct view_state *vs;
struct document_view *doc_view;
struct form_view *fv;
struct form *form;
parent_doc = JS_GetParent(ctx, obj);
parent_win = JS_GetParent(ctx, parent_doc);
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
doc_view = vs->doc_view;
fv = JS_GetPrivate(ctx, obj); /* from @form_class */
form = find_form_by_form_view(doc_view->document, fv);
assert(form);
@ -731,14 +801,21 @@ form_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
static JSBool
form_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
JSObject *parent_doc = JS_GetParent(ctx, obj);
JSObject *parent_win = JS_GetParent(ctx, parent_doc);
struct view_state *vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
struct document_view *doc_view = vs->doc_view;
struct form_view *fv = JS_GetPrivate(ctx, obj); /* from @form_class */
struct form *form = find_form_by_form_view(doc_view->document, fv);
JSObject *parent_doc; /* instance of @document_class */
JSObject *parent_win; /* instance of @window_class */
struct view_state *vs;
struct document_view *doc_view;
struct form_view *fv;
struct form *form;
unsigned char *string;
parent_doc = JS_GetParent(ctx, obj);
parent_win = JS_GetParent(ctx, parent_doc);
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
doc_view = vs->doc_view;
fv = JS_GetPrivate(ctx, obj); /* from @form_class */
form = find_form_by_form_view(doc_view->document, fv);
assert(form);
if (!JSVAL_IS_INT(id))
@ -790,12 +867,19 @@ form_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
static JSBool
form_reset(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
JSObject *parent_doc = JS_GetParent(ctx, obj);
JSObject *parent_win = JS_GetParent(ctx, parent_doc);
struct view_state *vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
struct document_view *doc_view = vs->doc_view;
struct form_view *fv = JS_GetPrivate(ctx, obj); /* from @form_class */
struct form *form = find_form_by_form_view(doc_view->document, fv);
JSObject *parent_doc; /* instance of @document_class */
JSObject *parent_win; /* instance of @window_class */
struct view_state *vs;
struct document_view *doc_view;
struct form_view *fv;
struct form *form;
parent_doc = JS_GetParent(ctx, obj);
parent_win = JS_GetParent(ctx, parent_doc);
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
doc_view = vs->doc_view;
fv = JS_GetPrivate(ctx, obj); /* from @form_class */
form = find_form_by_form_view(doc_view->document, fv);
assert(form);
@ -811,13 +895,21 @@ form_reset(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool
form_submit(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
JSObject *parent_doc = JS_GetParent(ctx, obj);
JSObject *parent_win = JS_GetParent(ctx, parent_doc);
struct view_state *vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
struct document_view *doc_view = vs->doc_view;
struct session *ses = doc_view->session;
struct form_view *fv = JS_GetPrivate(ctx, obj); /* from @form_class */
struct form *form = find_form_by_form_view(doc_view->document, fv);
JSObject *parent_doc; /* instance of @document_class */
JSObject *parent_win; /* instance of @window_class */
struct view_state *vs;
struct document_view *doc_view;
struct session *ses;
struct form_view *fv;
struct form *form;
parent_doc = JS_GetParent(ctx, obj);
parent_win = JS_GetParent(ctx, parent_doc);
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
doc_view = vs->doc_view;
ses = doc_view->session;
fv = JS_GetPrivate(ctx, obj); /* from @form_class */
form = find_form_by_form_view(doc_view->document, fv);
assert(form);
submit_given_form(ses, doc_view, form);
@ -877,11 +969,17 @@ const JSPropertySpec forms_props[] = {
static JSBool
forms_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
JSObject *parent_doc = JS_GetParent(ctx, obj);
JSObject *parent_win = JS_GetParent(ctx, parent_doc);
struct view_state *vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
struct document_view *doc_view = vs->doc_view;
struct document *document = doc_view->document;
JSObject *parent_doc; /* instance of @document_class */
JSObject *parent_win; /* instance of @window_class */
struct view_state *vs;
struct document_view *doc_view;
struct document *document;
parent_doc = JS_GetParent(ctx, obj);
parent_win = JS_GetParent(ctx, parent_doc);
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
doc_view = vs->doc_view;
document = doc_view->document;
if (JSVAL_IS_STRING(id)) {
forms_namedItem(ctx, obj, 1, &id, vp);
@ -908,13 +1006,17 @@ forms_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
static JSBool
forms_item(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
JSObject *parent_doc = JS_GetParent(ctx, obj);
JSObject *parent_win = JS_GetParent(ctx, parent_doc);
struct view_state *vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
JSObject *parent_doc; /* instance of @document_class */
JSObject *parent_win; /* instance of @window_class */
struct view_state *vs;
struct form_view *fv;
int counter = -1;
int index;
parent_doc = JS_GetParent(ctx, obj);
parent_win = JS_GetParent(ctx, parent_doc);
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
if (argc != 1)
return JS_TRUE;
@ -937,14 +1039,20 @@ forms_item(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool
forms_namedItem(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
JSObject *parent_doc = JS_GetParent(ctx, obj);
JSObject *parent_win = JS_GetParent(ctx, parent_doc);
struct view_state *vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
struct document_view *doc_view = vs->doc_view;
struct document *document = doc_view->document;
JSObject *parent_doc; /* instance of @document_class */
JSObject *parent_win; /* instance of @window_class */
struct view_state *vs;
struct document_view *doc_view;
struct document *document;
struct form *form;
unsigned char *string;
parent_doc = JS_GetParent(ctx, obj);
parent_win = JS_GetParent(ctx, parent_doc);
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
doc_view = vs->doc_view;
document = doc_view->document;
if (argc != 1)
return JS_TRUE;

View File

@ -145,8 +145,11 @@ const JSPropertySpec location_props[] = {
static JSBool
location_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
JSObject *parent_win = JS_GetParent(ctx, obj);
struct view_state *vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
JSObject *parent_win; /* instance of @window_class */
struct view_state *vs;
parent_win = JS_GetParent(ctx, obj);
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
if (!JSVAL_IS_INT(id))
return JS_TRUE;
@ -169,9 +172,13 @@ location_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
static JSBool
location_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
JSObject *parent_win = JS_GetParent(ctx, obj);
struct view_state *vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
struct document_view *doc_view = vs->doc_view;
JSObject *parent_win; /* instance of @window_class */
struct view_state *vs;
struct document_view *doc_view;
parent_win = JS_GetParent(ctx, obj);
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
doc_view = vs->doc_view;
if (!JSVAL_IS_INT(id))
return JS_TRUE;

View File

@ -75,11 +75,17 @@ const JSPropertySpec unibar_props[] = {
static JSBool
unibar_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
JSObject *parent_win = JS_GetParent(ctx, obj);
struct view_state *vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
struct document_view *doc_view = vs->doc_view;
struct session_status *status = &doc_view->session->status;
unsigned char *bar = JS_GetPrivate(ctx, obj); /* from @menubar_class or @statusbar_class */
JSObject *parent_win; /* instance of @window_class */
struct view_state *vs;
struct document_view *doc_view;
struct session_status *status;
unsigned char *bar;
parent_win = JS_GetParent(ctx, obj);
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
doc_view = vs->doc_view;
status = &doc_view->session->status;
bar = JS_GetPrivate(ctx, obj); /* from @menubar_class or @statusbar_class */
if (!JSVAL_IS_INT(id))
return JS_TRUE;
@ -115,11 +121,17 @@ unibar_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
static JSBool
unibar_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
JSObject *parent_win = JS_GetParent(ctx, obj);
struct view_state *vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
struct document_view *doc_view = vs->doc_view;
struct session_status *status = &doc_view->session->status;
unsigned char *bar = JS_GetPrivate(ctx, obj); /* from @menubar_class or @statusbar_class */
JSObject *parent_win; /* instance of @window_class */
struct view_state *vs;
struct document_view *doc_view;
struct session_status *status;
unsigned char *bar;
parent_win = JS_GetParent(ctx, obj);
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
doc_view = vs->doc_view;
status = &doc_view->session->status;
bar = JS_GetPrivate(ctx, obj); /* from @menubar_class or @statusbar_class */
if (!JSVAL_IS_INT(id))
return JS_TRUE;

View File

@ -118,7 +118,9 @@ find_child_frame(struct document_view *doc_view, struct frame_desc *tframe)
static JSBool
window_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
struct view_state *vs = JS_GetPrivate(ctx, obj); /* from @window_class */
struct view_state *vs;
vs = JS_GetPrivate(ctx, obj); /* from @window_class */
/* No need for special window.location measurements - when
* location is then evaluated in string context, toString()
@ -235,7 +237,9 @@ void location_goto(struct document_view *doc_view, unsigned char *url);
static JSBool
window_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
struct view_state *vs = JS_GetPrivate(ctx, obj); /* from @window_class */
struct view_state *vs;
vs = JS_GetPrivate(ctx, obj); /* from @window_class */
if (JSVAL_IS_STRING(id)) {
if (!strcmp(jsval_to_string(ctx, &id), "location")) {
@ -275,9 +279,11 @@ const JSFunctionSpec window_funcs[] = {
static JSBool
window_alert(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
struct view_state *vs = JS_GetPrivate(ctx, obj); /* from @window_class */
struct view_state *vs;
unsigned char *string;
vs = JS_GetPrivate(ctx, obj); /* from @window_class */
if (argc != 1)
return JS_TRUE;
@ -324,15 +330,19 @@ delayed_goto_uri_frame(void *data)
static JSBool
window_open(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
struct view_state *vs = JS_GetPrivate(ctx, obj); /* from @window_class */
struct document_view *doc_view = vs->doc_view;
struct session *ses = doc_view->session;
struct view_state *vs;
struct document_view *doc_view;
struct session *ses;
unsigned char *target = "";
unsigned char *url;
struct uri *uri;
static time_t ratelimit_start;
static int ratelimit_count;
vs = JS_GetPrivate(ctx, obj); /* from @window_class */
doc_view = vs->doc_view;
ses = doc_view->session;
if (get_opt_bool("ecmascript.block_window_opening")) {
#ifdef CONFIG_LEDS
set_led_value(ses->status.popup_led, 'P');

View File

@ -39,7 +39,9 @@ smjs_get_bookmark_generic_object(struct bookmark *bookmark, JSClass *clasp)
static void
bookmark_finalize(JSContext *ctx, JSObject *obj)
{
struct bookmark *bookmark = JS_GetPrivate(ctx, obj); /* from @bookmark_class or @bookmark_folder_class */
struct bookmark *bookmark;
bookmark = JS_GetPrivate(ctx, obj); /* from @bookmark_class or @bookmark_folder_class */
if (bookmark) object_unlock(bookmark);
}
@ -66,7 +68,9 @@ static JSObject *smjs_get_bookmark_folder_object(struct bookmark *bookmark);
static JSBool
bookmark_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
struct bookmark *bookmark = JS_GetPrivate(ctx, obj); /* from @bookmark_class */
struct bookmark *bookmark;
bookmark = JS_GetPrivate(ctx, obj); /* from @bookmark_class */
if (!bookmark) return JS_FALSE;
@ -102,7 +106,9 @@ bookmark_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
static JSBool
bookmark_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
struct bookmark *bookmark = JS_GetPrivate(ctx, obj); /* from @bookmark_class */
struct bookmark *bookmark;
bookmark = JS_GetPrivate(ctx, obj); /* from @bookmark_class */
if (!bookmark) return JS_FALSE;
@ -166,9 +172,11 @@ static JSBool
bookmark_folder_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
struct bookmark *bookmark;
struct bookmark *folder = JS_GetPrivate(ctx, obj); /* from @bookmark_folder_class */
struct bookmark *folder;
unsigned char *title;
folder = JS_GetPrivate(ctx, obj); /* from @bookmark_folder_class */
title = JS_GetStringBytes(JS_ValueToString(ctx, id));
if (!title) {
*vp = JSVAL_NULL;

View File

@ -35,7 +35,9 @@ static const JSPropertySpec cache_entry_props[] = {
static JSBool
cache_entry_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
struct cache_entry *cached = JS_GetPrivate(ctx, obj); /* from @cache_entry_class */
struct cache_entry *cached;
cached = JS_GetPrivate(ctx, obj); /* from @cache_entry_class */
if (!cache_entry_is_valid(cached)) return JS_FALSE;
@ -87,7 +89,9 @@ cache_entry_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
static JSBool
cache_entry_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
struct cache_entry *cached = JS_GetPrivate(ctx, obj); /* from @cache_entry_class */
struct cache_entry *cached;
cached = JS_GetPrivate(ctx, obj); /* from @cache_entry_class */
if (!cache_entry_is_valid(cached)) return JS_FALSE;
@ -135,7 +139,9 @@ cache_entry_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
static void
cache_entry_finalize(JSContext *ctx, JSObject *obj)
{
struct cache_entry *cached = JS_GetPrivate(ctx, obj); /* from @cache_entry_class */
struct cache_entry *cached;
cached = JS_GetPrivate(ctx, obj); /* from @cache_entry_class */
if (!cached) return;

View File

@ -19,9 +19,11 @@ keymap_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
unsigned char *action_str;
unsigned char *keystroke_str;
int *data = JS_GetPrivate(ctx, obj); /* from @keymap_class */
int *data;
enum keymap_id keymap_id = *data;
data = JS_GetPrivate(ctx, obj); /* from @keymap_class */
keystroke_str = JS_GetStringBytes(JS_ValueToString(ctx, id));
if (!keystroke_str) goto ret_null;
@ -63,11 +65,13 @@ smjs_keybinding_action_callback(va_list ap, void *data)
static JSBool
keymap_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
int *data = JS_GetPrivate(ctx, obj); /* from @keymap_class */
int *data;
enum keymap_id keymap_id = *data;
unsigned char *keymap_str;
unsigned char *keystroke_str;
data = JS_GetPrivate(ctx, obj); /* from @keymap_class */
/* Ugly fact: we need to get the string from the id to give to bind_do,
* which will of course then convert the string back to an id... */
keymap_str = get_keymap_name(keymap_id);
@ -133,7 +137,9 @@ keymap_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
static void
keymap_finalize(JSContext *ctx, JSObject *obj)
{
void *data = JS_GetPrivate(ctx, obj); /* from @keymap_class */
void *data;
data = JS_GetPrivate(ctx, obj); /* from @keymap_class */
mem_free(data);
}

View File

@ -31,7 +31,9 @@ static const JSPropertySpec view_state_props[] = {
static JSBool
view_state_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
struct view_state *vs = JS_GetPrivate(ctx, obj); /* from @view_state_class */
struct view_state *vs;
vs = JS_GetPrivate(ctx, obj); /* from @view_state_class */
undef_to_jsval(ctx, vp);
@ -60,7 +62,9 @@ view_state_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
static JSBool
view_state_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
{
struct view_state *vs = JS_GetPrivate(ctx, obj); /* from @view_state_class */
struct view_state *vs;
vs = JS_GetPrivate(ctx, obj); /* from @view_state_class */
if (!JSVAL_IS_INT(id))
return JS_FALSE;