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

SEE: setTimeout is a window object method.

This commit is contained in:
Witold Filipczyk 2006-10-24 15:33:14 +02:00 committed by Witold Filipczyk
parent 5521ab2910
commit e5e6727e81
5 changed files with 26 additions and 18 deletions

View File

@ -68,22 +68,6 @@ see_done(struct module *xxx)
{
}
static void
js_setTimeout(struct SEE_interpreter *interp, struct SEE_object *self,
struct SEE_object *thisobj, int argc, struct SEE_value **argv,
struct SEE_value *res)
{
struct ecmascript_interpreter *ei;
unsigned char *code;
int timeout;
if (argc != 2) return;
ei = ((struct global_object *)interp)->interpreter;
code = SEE_value_to_unsigned_char(interp, argv[0]);
timeout = SEE_ToInt32(interp, argv[1]);
ecmascript_set_timeout(ei, code, timeout);
}
void *
see_get_interpreter(struct ecmascript_interpreter *interpreter)
{
@ -104,7 +88,6 @@ see_get_interpreter(struct ecmascript_interpreter *interpreter)
init_js_location_object(interpreter);
init_js_document_object(interpreter);
init_js_forms_object(interpreter);
SEE_CFUNCTION_PUTA(interp, interp->Global, "setTimeout", js_setTimeout, 2, 0);
return interp;
}

View File

@ -95,7 +95,7 @@ struct SEE_string *s_button;
struct SEE_string *s_hidden;
struct SEE_string *s_timeout;
struct SEE_string *s_setTimeout;
void
init_intern_strings(void)
@ -194,4 +194,5 @@ init_intern_strings(void)
s_hidden = SEE_intern_global("hidden");
s_timeout = SEE_intern_global("timeout");
s_setTimeout = SEE_intern_global("setTimeout");
}

View File

@ -100,4 +100,5 @@ extern struct SEE_string *s_button;
extern struct SEE_string *s_hidden;
extern struct SEE_string *s_timeout;
extern struct SEE_string *s_setTimeout;
#endif

View File

@ -54,6 +54,7 @@ static int window_canput(struct SEE_interpreter *, struct SEE_object *, struct S
static int window_hasproperty(struct SEE_interpreter *, struct SEE_object *, struct SEE_string *);
static void js_window_alert(struct SEE_interpreter *, struct SEE_object *, struct SEE_object *, int, struct SEE_value **, struct SEE_value *);
static void js_window_open(struct SEE_interpreter *, struct SEE_object *, struct SEE_object *, int, struct SEE_value **, struct SEE_value *);
static void js_setTimeout(struct SEE_interpreter *, struct SEE_object *, struct SEE_object *, int, struct SEE_value **, struct SEE_value *);
void location_goto(struct document_view *, unsigned char *);
@ -134,6 +135,8 @@ window_get(struct SEE_interpreter *interp, struct SEE_object *o,
SEE_SET_OBJECT(res, win->alert);
} else if (p == s_open) {
SEE_SET_OBJECT(res, win->open);
} else if (p == s_setTimeout) {
SEE_SET_OBJECT(res, win->setTimeout);
} else if (p == s_location) {
SEE_OBJECT_GET(interp, interp->Global, s_location, res);
} else if (p == s_navigator) {
@ -313,6 +316,22 @@ end:
done_uri(uri);
}
static void
js_setTimeout(struct SEE_interpreter *interp, struct SEE_object *self,
struct SEE_object *thisobj, int argc, struct SEE_value **argv,
struct SEE_value *res)
{
struct ecmascript_interpreter *ei;
unsigned char *code;
int timeout;
if (argc != 2) return;
ei = ((struct global_object *)interp)->interpreter;
code = SEE_value_to_unsigned_char(interp, argv[0]);
timeout = SEE_ToInt32(interp, argv[1]);
ecmascript_set_timeout(ei, code, timeout);
}
void
init_js_window_object(struct ecmascript_interpreter *interpreter)
{
@ -331,6 +350,7 @@ init_js_window_object(struct ecmascript_interpreter *interpreter)
g->win->alert = SEE_cfunction_make(interp, js_window_alert, s_alert, 1);
g->win->open = SEE_cfunction_make(interp, js_window_open, s_open, 3);
g->win->setTimeout = SEE_cfunction_make(interp, js_setTimeout, s_setTimeout, 2);
SEE_OBJECT_GET(interp, (struct SEE_object *)g->win, s_top, &v);
SEE_OBJECT_PUT(interp, interp->Global, s_top, &v, 0);
@ -342,6 +362,8 @@ init_js_window_object(struct ecmascript_interpreter *interpreter)
SEE_OBJECT_PUT(interp, interp->Global, s_alert, &v, 0);
SEE_OBJECT_GET(interp, (struct SEE_object *)g->win, s_open, &v);
SEE_OBJECT_PUT(interp, interp->Global, s_open, &v, 0);
SEE_OBJECT_GET(interp, (struct SEE_object *)g->win, s_setTimeout, &v);
SEE_OBJECT_PUT(interp, interp->Global, s_setTimeout, &v, 0);
}
void

View File

@ -13,6 +13,7 @@ struct js_window_object {
struct view_state *vs;
struct SEE_object *alert;
struct SEE_object *open;
struct SEE_object *setTimeout;
};
struct global_object {