[gjs: 2/16] foreign: Make gjs_struct_foreign_register() infallible
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 2/16] foreign: Make gjs_struct_foreign_register() infallible
- Date: Sat, 3 Nov 2018 02:41:24 +0000 (UTC)
commit 4ce4a046883735ec6fddefaa7771cf653ebaa548
Author: Philip Chimento <philip chimento gmail com>
Date: Sun Oct 28 16:50:14 2018 -0400
foreign: Make gjs_struct_foreign_register() infallible
This function could only return true except in cases of programmer error,
and the return value was already ignored in all callers.
gi/foreign.cpp | 14 +++++---------
gi/foreign.h | 5 ++---
2 files changed, 7 insertions(+), 12 deletions(-)
---
diff --git a/gi/foreign.cpp b/gi/foreign.cpp
index 007f6058..43b3c310 100644
--- a/gi/foreign.cpp
+++ b/gi/foreign.cpp
@@ -87,20 +87,16 @@ gjs_foreign_load_foreign_module(JSContext *context,
return false;
}
-bool
-gjs_struct_foreign_register(const char *gi_namespace,
- const char *type_name,
- GjsForeignInfo *info)
-{
+void gjs_struct_foreign_register(const char* gi_namespace,
+ const char* type_name, GjsForeignInfo* info) {
char *canonical_name;
- g_return_val_if_fail(info != NULL, false);
- g_return_val_if_fail(info->to_func != NULL, false);
- g_return_val_if_fail(info->from_func != NULL, false);
+ g_return_if_fail(info);
+ g_return_if_fail(info->to_func);
+ g_return_if_fail(info->from_func);
canonical_name = g_strdup_printf("%s.%s", gi_namespace, type_name);
g_hash_table_insert(get_foreign_structs(), canonical_name, info);
- return true;
}
static GjsForeignInfo *
diff --git a/gi/foreign.h b/gi/foreign.h
index 41e92c2e..4b58e45f 100644
--- a/gi/foreign.h
+++ b/gi/foreign.h
@@ -51,9 +51,8 @@ typedef struct {
GjsArgOverrideReleaseGArgumentFunc release_func;
} GjsForeignInfo;
-bool gjs_struct_foreign_register (const char *gi_namespace,
- const char *type_name,
- GjsForeignInfo *info);
+void gjs_struct_foreign_register(const char* gi_namespace,
+ const char* type_name, GjsForeignInfo* info);
bool gjs_struct_foreign_convert_to_g_argument (JSContext *context,
JS::Value value,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]