[gjs: 9/11] foreign: Use gjs_eval_with_scope() instead of public API
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 9/11] foreign: Use gjs_eval_with_scope() instead of public API
- Date: Thu, 25 Jan 2018 01:22:58 +0000 (UTC)
commit 43e11fcdb75096f40a9a72d0ee787bfcc6a86915
Author: Philip Chimento <philip endlessm com>
Date: Tue Jan 23 20:14:19 2018 -0800
foreign: Use gjs_eval_with_scope() instead of public API
It was probably a bad idea already to use the public gjs_context_eval()
API to import the foreign cairo module, since it didn't handle the GError
in the error case.
Now, since we intend to run the profiler from the public API point, it's
a bad idea to use it internally. Use gjs_eval_with_scope() instead.
gi/foreign.cpp | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
---
diff --git a/gi/foreign.cpp b/gi/foreign.cpp
index cc32ef0..007f605 100644
--- a/gi/foreign.cpp
+++ b/gi/foreign.cpp
@@ -61,8 +61,6 @@ gjs_foreign_load_foreign_module(JSContext *context,
int i;
for (i = 0; foreign_modules[i].gi_namespace; ++i) {
- int code;
- GError *error = NULL;
char *script;
if (strcmp(gi_namespace, foreign_modules[i].gi_namespace) != 0)
@@ -74,12 +72,11 @@ gjs_foreign_load_foreign_module(JSContext *context,
// FIXME: Find a way to check if a module is imported
// and only execute this statement if isn't
script = g_strdup_printf("imports.%s;", gi_namespace);
- if (!gjs_context_eval((GjsContext*) JS_GetContextPrivate(context), script, strlen(script),
- "<internal>", &code,
- &error)) {
- g_printerr("ERROR: %s\n", error->message);
+ JS::RootedValue retval(context);
+ if (!gjs_eval_with_scope(context, nullptr, script, strlen(script),
+ "<internal>", &retval)) {
+ g_critical("ERROR importing foreign module %s\n", gi_namespace);
g_free(script);
- g_error_free(error);
return false;
}
g_free(script);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]