mirror of
https://github.com/rkd77/elinks.git
synced 2024-10-04 04:14:18 -04:00
b94657869b
Previously, spidermonkey_get_interpreter() and init_smjs() each called JS_SetErrorReporter on the JSContexts they created. However, JS_SetErrorReporter actually sets the error reporter of the JSRuntime associated with the JSContext, and all of our JSContexts use the same JSRuntime nowadays, so only the error_reporter() of src/ecmascript/spidermonkey.c was left installed. Because this error_reporter() asserts that JS_GetContextPrivate(ctx) returns a non-NULL pointer, and init_smjs() does not set a private pointer for smjs_ctx, any error in smjs_ctx could cause an assertion failure, at least in principle. Fix this by making spidermonkey_runtime_addref() install a shared error_reporter() when it creates the JSRuntime and the first JSContext. The shared error_reporter() then checks the JSContext and calls the appropriate function. The two error reporters are quite similar with each other. In the future, we could move the common code into shared functions. I'm not doing that yet though, because fixing the bug doesn't require it.
26 lines
1014 B
C
26 lines
1014 B
C
#ifndef EL__ECMASCRIPT_SPIDERMONKEY_H
|
|
#define EL__ECMASCRIPT_SPIDERMONKEY_H
|
|
|
|
struct ecmascript_interpreter;
|
|
struct form_state;
|
|
struct form_view;
|
|
struct JSContext;
|
|
struct JSErrorReport;
|
|
struct string;
|
|
|
|
void *spidermonkey_get_interpreter(struct ecmascript_interpreter *interpreter);
|
|
void spidermonkey_put_interpreter(struct ecmascript_interpreter *interpreter);
|
|
|
|
void spidermonkey_detach_form_view(struct form_view *fv);
|
|
void spidermonkey_detach_form_state(struct form_state *fs);
|
|
void spidermonkey_moved_form_state(struct form_state *fs);
|
|
|
|
void spidermonkey_eval(struct ecmascript_interpreter *interpreter, struct string *code, struct string *ret);
|
|
unsigned char *spidermonkey_eval_stringback(struct ecmascript_interpreter *interpreter, struct string *code);
|
|
int spidermonkey_eval_boolback(struct ecmascript_interpreter *interpreter, struct string *code);
|
|
|
|
void spidermonkey_error_reporter(struct JSContext *ctx, const char *message, struct JSErrorReport *report);
|
|
|
|
extern struct module spidermonkey_module;
|
|
#endif
|