[gjs: 5/21] maint: Rename variables named "string"
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 5/21] maint: Rename variables named "string"
- Date: Sun, 9 Jun 2019 17:02:35 +0000 (UTC)
commit fff5748501669dfa337adaf1f7b8ff82dcaa0187
Author: Philip Chimento <philip chimento gmail com>
Date: Sun May 19 23:51:16 2019 -0700
maint: Rename variables named "string"
Having a variable named "string" causes a weird false positive case of
CPPLINT. Regardless, it's better to describe what the string is for.
gi/function.cpp | 26 +++++++++-----------------
modules/console.cpp | 4 ++--
2 files changed, 11 insertions(+), 19 deletions(-)
---
diff --git a/gi/function.cpp b/gi/function.cpp
index 22103b1e..269deac3 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -1507,21 +1507,18 @@ function_to_string (JSContext *context,
JS::Value *vp)
{
GJS_GET_PRIV(context, argc, vp, rec, to, Function, priv);
- gchar *string;
- bool free;
- bool ret = false;
int i, n_args, n_jsargs;
GString *arg_names_str;
gchar *arg_names;
if (priv == NULL) {
- string = (gchar *) "function () {\n}";
- free = false;
- goto out;
+ JSString* retval = JS_NewStringCopyZ(context, "function () {\n}");
+ if (!retval)
+ return false;
+ rec.rval().setString(retval);
+ return true;
}
- free = true;
-
n_args = g_callable_info_get_n_args(priv->info);
n_jsargs = 0;
arg_names_str = g_string_new("");
@@ -1544,26 +1541,21 @@ function_to_string (JSContext *context,
}
arg_names = g_string_free(arg_names_str, false);
+ GjsAutoChar descr;
if (g_base_info_get_type(priv->info) == GI_INFO_TYPE_FUNCTION) {
- string = g_strdup_printf(
+ descr = g_strdup_printf(
"function %s(%s) {\n\t/* wrapper for native symbol %s(); */\n}",
g_base_info_get_name(priv->info), arg_names,
g_function_info_get_symbol(priv->info));
} else {
- string = g_strdup_printf(
+ descr = g_strdup_printf(
"function %s(%s) {\n\t/* wrapper for native symbol */\n}",
g_base_info_get_name(priv->info), arg_names);
}
g_free(arg_names);
- out:
- if (gjs_string_from_utf8(context, string, rec.rval()))
- ret = true;
-
- if (free)
- g_free(string);
- return ret;
+ return gjs_string_from_utf8(context, descr, rec.rval());
}
/* The bizarre thing about this vtable is that it applies to both
diff --git a/modules/console.cpp b/modules/console.cpp
index 972309b9..d37b568b 100644
--- a/modules/console.cpp
+++ b/modules/console.cpp
@@ -216,8 +216,8 @@ public:
g_assert(!JSREPORT_IS_WARNING(report->flags));
gjs_console_print_error(report);
} else {
- GjsAutoChar string = gjs_value_debug_string(m_cx, v_exn);
- g_printerr("error: %s\n", string.get());
+ GjsAutoChar display_str = gjs_value_debug_string(m_cx, v_exn);
+ g_printerr("error: %s\n", display_str.get());
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]