1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00

Add the number of interpreters to Resources box

Introduce static int interpreter_count in src/ecmascript/ecmascript.c.

Maintain interpreter_count in ecmascript_get_interpreter and
ecmascript_put_interpreter.

Introduce ecmascript_get_interpreter_count.

Display the number of ECMAScript interpreters that have been allocated
for documents in the Resources dialog box.
This commit is contained in:
Miciah Dashiel Butler Masters 2008-09-06 20:18:10 +00:00
parent 80a5c6d466
commit f62d2d1ae4
4 changed files with 25 additions and 0 deletions

2
NEWS
View File

@ -46,6 +46,8 @@ Miscellaneous:
* enhancement: Add a new entry Link Info under Link main menu.
* enhancement: New option protocol.http.compression.
* enhancement: Indicate backgrounded downloads using an unused led.
* enhancement: Display the number of ECMAScript interpreters that have
been allocated for documents in the Resources dialog.
//////////////////////////////////////////////////////////////////////
The following changes should be removed from NEWS before ELinks 0.13.0

View File

@ -19,6 +19,7 @@
#include "config/options.h"
#include "dialogs/info.h"
#include "document/renderer.h"
#include "ecmascript/ecmascript.h"
#include "intl/gettext/libintl.h"
#include "main/select.h"
#include "main/timer.h"
@ -231,6 +232,15 @@ get_resource_info(struct terminal *term, void *data)
val_add(n_("%ld refreshing", "%ld refreshing", val, term));
add_to_string(&info, ".\n");
#ifdef CONFIG_ECMASCRIPT
add_to_string(&info, _("ECMAScript", term));
add_to_string(&info, ": ");
val = ecmascript_get_interpreter_count();
val_add(n_("%ld interpreter", "%ld interpreters", val, term));
add_to_string(&info, ".\n");
#endif
add_to_string(&info, _("Interlinking", term));
add_to_string(&info, ": ");
if (term->master)

View File

@ -66,6 +66,8 @@ static struct option_info ecmascript_options[] = {
NULL_OPTION_INFO,
};
static int interpreter_count;
struct ecmascript_interpreter *
ecmascript_get_interpreter(struct view_state *vs)
{
@ -77,6 +79,8 @@ ecmascript_get_interpreter(struct view_state *vs)
if (!interpreter)
return NULL;
++interpreter_count;
interpreter->vs = vs;
interpreter->vs->ecmascript_fragile = 0;
init_list(interpreter->onload_snippets);
@ -85,6 +89,7 @@ ecmascript_get_interpreter(struct view_state *vs)
#else
spidermonkey_get_interpreter(interpreter);
#endif
init_string(&interpreter->code);
return interpreter;
}
@ -111,6 +116,13 @@ ecmascript_put_interpreter(struct ecmascript_interpreter *interpreter)
interpreter->vs->ecmascript = NULL;
interpreter->vs->ecmascript_fragile = 1;
mem_free(interpreter);
--interpreter_count;
}
int
ecmascript_get_interpreter_count(void)
{
return interpreter_count;
}
void

View File

@ -71,6 +71,7 @@ void ecmascript_free_urls(struct module *module);
struct ecmascript_interpreter *ecmascript_get_interpreter(struct view_state*vs);
void ecmascript_put_interpreter(struct ecmascript_interpreter *interpreter);
int ecmascript_get_interpreter_count(void);
void ecmascript_detach_form_view(struct form_view *fv);
void ecmascript_detach_form_state(struct form_state *fs);