[gjs: 3/5] gjs: Ensure that we always use unique names for static values and types
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 3/5] gjs: Ensure that we always use unique names for static values and types
- Date: Fri, 14 May 2021 04:11:05 +0000 (UTC)
commit 4703b56bedfde9ecfde663fa42d344c820e854ec
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Thu May 6 19:06:23 2021 +0200
gjs: Ensure that we always use unique names for static values and types
This is a prepartory work to get the unity builds possible
gi/arg-cache.cpp | 4 +++-
gi/arg.cpp | 6 ++++--
gi/gobject.cpp | 10 +++++-----
gi/private.cpp | 8 ++++----
gjs/context.cpp | 2 +-
gjs/coverage.cpp | 2 +-
modules/cairo-context.cpp | 10 ++++------
modules/cairo-pattern.cpp | 7 ++-----
modules/cairo-private.h | 6 ++++++
modules/cairo-region.cpp | 8 +++-----
modules/cairo-surface.cpp | 16 +++++-----------
11 files changed, 38 insertions(+), 41 deletions(-)
---
diff --git a/gi/arg-cache.cpp b/gi/arg-cache.cpp
index 6fb1e1f0..14e4cff3 100644
--- a/gi/arg-cache.cpp
+++ b/gi/arg-cache.cpp
@@ -1350,10 +1350,12 @@ static void gjs_arg_cache_build_flags_mask(GjsArgumentCache* self,
self->contents.flags_mask = mask;
}
+namespace arg_cache {
[[nodiscard]] static inline bool is_gdk_atom(GIBaseInfo* info) {
return strcmp("Atom", g_base_info_get_name(info)) == 0 &&
strcmp("Gdk", g_base_info_get_namespace(info)) == 0;
}
+} // namespace arg_cache
static void gjs_arg_cache_build_interface_in_arg(GjsArgumentCache* self,
GIBaseInfo* interface_info,
@@ -1418,7 +1420,7 @@ static void gjs_arg_cache_build_interface_in_arg(GjsArgumentCache* self,
return;
}
- if (is_gdk_atom(interface_info)) {
+ if (arg_cache::is_gdk_atom(interface_info)) {
// Fall back to the generic marshaller
self->marshallers = &fallback_interface_in_marshallers;
return;
diff --git a/gi/arg.cpp b/gi/arg.cpp
index f5f83202..85edfc4d 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -1150,10 +1150,12 @@ bool gjs_array_to_explicit_array(JSContext* context, JS::HandleValue value,
return true;
}
+namespace arg {
[[nodiscard]] static bool is_gdk_atom(GIBaseInfo* info) {
return (strcmp("Atom", g_base_info_get_name(info)) == 0 &&
strcmp("Gdk", g_base_info_get_namespace(info)) == 0);
}
+} // namespace arg
static void
intern_gdk_atom(const char *name,
@@ -1229,7 +1231,7 @@ static bool value_to_interface_gi_argument(
g_value_unset(&gvalue);
return true;
- } else if (is_gdk_atom(interface_info)) {
+ } else if (arg::is_gdk_atom(interface_info)) {
if (!value.isNull() && !value.isString()) {
*report_type_mismatch = true;
return false;
@@ -2632,7 +2634,7 @@ gjs_value_from_g_argument (JSContext *context,
}
if (interface_type == GI_INFO_TYPE_STRUCT || interface_type == GI_INFO_TYPE_BOXED) {
- if (is_gdk_atom(interface_info)) {
+ if (arg::is_gdk_atom(interface_info)) {
GjsAutoFunctionInfo atom_name_fun =
g_struct_info_find_method(interface_info, "name");
GIArgument atom_name_ret;
diff --git a/gi/gobject.cpp b/gi/gobject.cpp
index 1de4b469..2c1dc987 100644
--- a/gi/gobject.cpp
+++ b/gi/gobject.cpp
@@ -27,7 +27,7 @@
static std::unordered_map<GType, AutoParamArray> class_init_properties;
-[[nodiscard]] static JSContext* current_context() {
+[[nodiscard]] static JSContext* current_js_context() {
GjsContext* gjs = gjs_context_get_current();
return static_cast<JSContext*>(gjs_context_get_native_context(gjs));
}
@@ -106,7 +106,7 @@ static void gjs_object_base_finalize(void* klass) {
static GObject* gjs_object_constructor(
GType type, unsigned n_construct_properties,
GObjectConstructParam* construct_properties) {
- JSContext* cx = current_context();
+ JSContext* cx = current_js_context();
GjsContextPrivate* gjs = GjsContextPrivate::from_cx(cx);
if (!gjs->object_init_list().empty()) {
@@ -168,7 +168,7 @@ static void gjs_object_set_gproperty(GObject* object,
unsigned property_id [[maybe_unused]],
const GValue* value, GParamSpec* pspec) {
auto* priv = ObjectInstance::for_gobject(object);
- JSContext *cx = current_context();
+ JSContext* cx = current_js_context();
JS::RootedObject js_obj(cx, priv->wrapper());
JSAutoRealm ar(cx, js_obj);
@@ -181,7 +181,7 @@ static void gjs_object_get_gproperty(GObject* object,
unsigned property_id [[maybe_unused]],
GValue* value, GParamSpec* pspec) {
auto* priv = ObjectInstance::for_gobject(object);
- JSContext *cx = current_context();
+ JSContext* cx = current_js_context();
JS::RootedObject js_obj(cx, priv->wrapper());
JS::RootedValue jsvalue(cx);
@@ -218,7 +218,7 @@ static void gjs_object_class_init(void* class_pointer, void*) {
static void gjs_object_custom_init(GTypeInstance* instance,
void* g_class [[maybe_unused]]) {
- JSContext *cx = current_context();
+ JSContext* cx = current_js_context();
GjsContextPrivate* gjs = GjsContextPrivate::from_cx(cx);
if (gjs->object_init_list().empty())
diff --git a/gi/private.cpp b/gi/private.cpp
index 935295bb..a6ecc723 100644
--- a/gi/private.cpp
+++ b/gi/private.cpp
@@ -403,7 +403,7 @@ GJS_JSAPI_RETURN_CONVENTION static bool symbol_getter(JSContext* cx,
return true;
}
-static JSFunctionSpec module_funcs[] = {
+static JSFunctionSpec private_module_funcs[] = {
JS_FN("override_property", gjs_override_property, 2, GJS_MODULE_PROP_FLAGS),
JS_FN("register_interface", gjs_register_interface, 3,
GJS_MODULE_PROP_FLAGS),
@@ -412,7 +412,7 @@ static JSFunctionSpec module_funcs[] = {
JS_FS_END,
};
-static JSPropertySpec module_props[] = {
+static JSPropertySpec private_module_props[] = {
JS_PSG("hook_up_vfunc_symbol", symbol_getter<&GjsAtoms::hook_up_vfunc>,
GJS_MODULE_PROP_FLAGS),
JS_PSG("signal_find_symbol", symbol_getter<&GjsAtoms::signal_find>,
@@ -428,6 +428,6 @@ static JSPropertySpec module_props[] = {
bool gjs_define_private_gi_stuff(JSContext* cx,
JS::MutableHandleObject module) {
module.set(JS_NewPlainObject(cx));
- return JS_DefineFunctions(cx, module, module_funcs) &&
- JS_DefineProperties(cx, module, module_props);
+ return JS_DefineFunctions(cx, module, private_module_funcs) &&
+ JS_DefineProperties(cx, module, private_module_props);
}
diff --git a/gjs/context.cpp b/gjs/context.cpp
index 59709572..436f2e53 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -127,7 +127,7 @@ GjsContextPrivate* GjsContextPrivate::from_current_context() {
}
enum {
- PROP_0,
+ PROP_CONTEXT_0,
PROP_PROGRAM_PATH,
PROP_SEARCH_PATH,
PROP_PROGRAM_NAME,
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index b6e0835b..924ef376 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -50,7 +50,7 @@ G_DEFINE_TYPE_WITH_PRIVATE(GjsCoverage,
G_TYPE_OBJECT)
enum {
- PROP_0,
+ PROP_COVERAGE_0,
PROP_PREFIXES,
PROP_CONTEXT,
PROP_CACHE,
diff --git a/modules/cairo-context.cpp b/modules/cairo-context.cpp
index 696af554..803b9e19 100644
--- a/modules/cairo-context.cpp
+++ b/modules/cairo-context.cpp
@@ -946,12 +946,10 @@ static bool context_release_argument(JSContext*, GITransfer transfer,
return true;
}
-static GjsForeignInfo foreign_info = {
- context_to_g_argument,
- context_from_g_argument,
- context_release_argument
-};
-
void gjs_cairo_context_init(void) {
+ static GjsForeignInfo foreign_info = {context_to_g_argument,
+ context_from_g_argument,
+ context_release_argument};
+
gjs_struct_foreign_register("cairo", "Context", &foreign_info);
}
diff --git a/modules/cairo-pattern.cpp b/modules/cairo-pattern.cpp
index d3f90fae..093e6fd8 100644
--- a/modules/cairo-pattern.cpp
+++ b/modules/cairo-pattern.cpp
@@ -31,11 +31,8 @@ const JSPropertySpec CairoPattern::proto_props[] = {
/* Methods */
GJS_JSAPI_RETURN_CONVENTION
-static bool
-getType_func(JSContext *context,
- unsigned argc,
- JS::Value *vp)
-{
+bool CairoPattern::getType_func(JSContext* context, unsigned argc,
+ JS::Value* vp) {
GJS_GET_THIS(context, argc, vp, rec, obj);
cairo_pattern_type_t type;
diff --git a/modules/cairo-private.h b/modules/cairo-private.h
index 7a05b783..a470a94a 100644
--- a/modules/cairo-private.h
+++ b/modules/cairo-private.h
@@ -192,6 +192,9 @@ class CairoSurface : public CWrapper<CairoSurface, cairo_surface_t> {
return cairo_surface_reference(surface);
}
+ GJS_JSAPI_RETURN_CONVENTION
+ static bool getType_func(JSContext* context, unsigned argc, JS::Value* vp);
+
public:
GJS_JSAPI_RETURN_CONVENTION
static JSObject* from_c_ptr(JSContext* cx, cairo_surface_t* surface);
@@ -416,6 +419,9 @@ class CairoPattern : public CWrapper<CairoPattern, cairo_pattern_t> {
return cairo_pattern_reference(pattern);
}
+ GJS_JSAPI_RETURN_CONVENTION
+ static bool getType_func(JSContext* context, unsigned argc, JS::Value* vp);
+
protected:
static void finalize_impl(JSFreeOp* fop, cairo_pattern_t* pattern);
diff --git a/modules/cairo-region.cpp b/modules/cairo-region.cpp
index a0fb1f1d..a6333f77 100644
--- a/modules/cairo-region.cpp
+++ b/modules/cairo-region.cpp
@@ -276,12 +276,10 @@ static bool region_release_argument(JSContext*, GITransfer transfer,
return true;
}
-static GjsForeignInfo foreign_info = {
- region_to_g_argument,
- region_from_g_argument,
- region_release_argument
-};
void gjs_cairo_region_init(void) {
+ static GjsForeignInfo foreign_info = {
+ region_to_g_argument, region_from_g_argument, region_release_argument};
+
gjs_struct_foreign_register("cairo", "Region", &foreign_info);
}
diff --git a/modules/cairo-surface.cpp b/modules/cairo-surface.cpp
index 2818adf0..287598e4 100644
--- a/modules/cairo-surface.cpp
+++ b/modules/cairo-surface.cpp
@@ -62,11 +62,8 @@ writeToPNG_func(JSContext *context,
}
GJS_JSAPI_RETURN_CONVENTION
-static bool
-getType_func(JSContext *context,
- unsigned argc,
- JS::Value *vp)
-{
+bool CairoSurface::getType_func(JSContext* context, unsigned argc,
+ JS::Value* vp) {
GJS_GET_THIS(context, argc, vp, rec, obj);
cairo_surface_type_t type;
@@ -230,12 +227,9 @@ static bool surface_release_argument(JSContext*, GITransfer transfer,
return true;
}
-static GjsForeignInfo foreign_info = {
- surface_to_g_argument,
- surface_from_g_argument,
- surface_release_argument
-};
-
void gjs_cairo_surface_init(void) {
+ static GjsForeignInfo foreign_info = {surface_to_g_argument,
+ surface_from_g_argument,
+ surface_release_argument};
gjs_struct_foreign_register("cairo", "Surface", &foreign_info);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]