Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions cfg/gtk.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -52,33 +52,39 @@
<define name="G_STRINGIFY_ARG(contents)" value="#contents"/>
<define name="G_STRLOC" value="__FILE__ &quot;:&quot; G_STRINGIFY (__LINE__)"/>
<define name="G_STRFUNC" value="((const char*) (__FUNCTION__))"/>
<define name="G_DEFINE_TYPE(TN, t_n, T_P)" value=""/>
<define name="G_DEFINE_TYPE_WITH_PRIVATE(TN, t_n, T_P)" value=""/>
<define name="G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_)" value=""/>
<define name="G_DEFINE_FINAL_TYPE(TN, t_n, T_P)" value=""/>
<define name="G_DEFINE_FINAL_TYPE_WITH_PRIVATE(TN, t_n, T_P)" value=""/>
<define name="G_DEFINE_FINAL_TYPE_WITH_CODE(TN, t_n, T_P, _C_)" value=""/>
<define name="G_DEFINE_ABSTRACT_TYPE(TN, t_n, T_P)" value=""/>
<define name="G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(TN, t_n, T_P)" value=""/>
<define name="G_DEFINE_ABSTRACT_TYPE_WITH_CODE(TN, t_n, T_P, _C_)" value=""/>
<define name="G_DEFINE_DYNAMIC_TYPE(TN, t_n, T_P)" value=""/>
<define name="G_DEFINE_DYNAMIC_TYPE_EXTENDED(TN, t_n, T_P, _f_, _C_)" value=""/>
<define name="G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(TN, t_n, T_P)" value=""/>
<define name="G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(TypeName, func)" value=""/>
<define name="G_DEFINE_AUTO_CLEANUP_FREE_FUNC(TypeName, func, none)" value=""/>
<define name="G_DEFINE_AUTOPTR_CLEANUP_FUNC(TypeName, func)" value=""/>
<define name="G_DEFINE_BOXED_TYPE(TypeName,type_name,copy_func,free_func)" value=""/>
<define name="G_DEFINE_BOXED_TYPE_WITH_CODE(TypeName,type_name,copy_func,free_func,_C_)" value=""/>
<define name="G_DEFINE_DYNAMIC_TYPE(TN, t_n, T_P)" value=""/>
<define name="G_DEFINE_DYNAMIC_TYPE_EXTENDED(TN, t_n, T_P, _f_, _C_)" value=""/>
<define name="G_DEFINE_ENUM_TYPE(TypeName, type_name, ...)" value=""/>
<define name="G_DEFINE_ENUM_VALUE(EnumValue, EnumNick)" value=""/>
<define name="G_DEFINE_EXTENDED_ERROR(ErrorType, error_type)" value=""/>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI review

Minor: the real G_DEFINE_EXTENDED_ERROR calls the user-written <error_type>_private_init, _private_copy and _private_clear functions. Because this define expands to nothing, --enable=unusedFunction reports all three as never used. G_DEFINE_TYPE already has the same problem with *_class_init/*_init, so this is consistent and not a blocker. It might still be worth a line in gtk.c, together with the G_DEFINE_POINTER_TYPE* defines, which also have no test yet.

<define name="G_DEFINE_FINAL_TYPE(TN, t_n, T_P)" value=""/>
<define name="G_DEFINE_FINAL_TYPE_WITH_CODE(TN, t_n, T_P, _C_)" value=""/>
<define name="G_DEFINE_FINAL_TYPE_WITH_PRIVATE(TN, t_n, T_P)" value=""/>
<define name="G_DEFINE_FLAGS_TYPE(TypeName, type_name, ...)" value=""/>
<define name="G_DEFINE_INTERFACE(TN, t_n, T_P)" value=""/>
<define name="G_DEFINE_INTERFACE_WITH_CODE(TN, t_n, T_P, _C_)" value=""/>
<define name="G_DEFINE_POINTER_TYPE(TypeName, type_name)" value=""/>
<define name="G_DEFINE_POINTER_TYPE_WITH_CODE(TypeName, type_name, _C_)" value=""/>
<define name="G_DEFINE_QUARK(QN,q_n)" value=""/>
<define name="G_DEFINE_TYPE(TN, t_n, T_P)" value=""/>
<define name="G_DEFINE_TYPE_EXTENDED(TN, t_n, T_P, _f_, _C_)" value=""/>
<define name="G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_)" value=""/>
<define name="G_DEFINE_TYPE_WITH_PRIVATE(TN, t_n, T_P)" value=""/>
<define name="G_BEGIN_DECLS" value=""/>
<define name="G_END_DECLS" value=""/>
<define name="G_ADD_PRIVATE(TypeName)" value=""/>
<define name="G_PRIVATE_OFFSET(TypeName, field)" value=""/>
<define name="G_PRIVATE_FIELD(TypeName, inst, field_type, field_name)" value=""/>
<define name="G_PRIVATE_FIELD_P(TypeName, inst, field_name)" value=""/>
<define name="G_DEFINE_INTERFACE(TN, t_n, T_P)" value=""/>
<define name="G_DEFINE_INTERFACE_WITH_CODE(TN, t_n, T_P, _C_)" value=""/>
<define name="G_DEFINE_TYPE_EXTENDED(TN, t_n, T_P, _f_, _C_)" value=""/>
<define name="G_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init)" value=""/>
<define name="G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(TypeName, func)" value=""/>
<define name="G_DEFINE_AUTO_CLEANUP_FREE_FUNC(TypeName, func, none)" value=""/>
<define name="G_DEFINE_AUTOPTR_CLEANUP_FUNC(TypeName, func)" value=""/>
<define name="MAX(a, b)" value="(((a) &gt; (b)) ? (a) : (b))"/>
<define name="MIN(a, b)" value="(((a) &lt; (b)) ? (a) : (b))"/>
<define name="ABS(a)" value="(((a) &lt; 0) ? -(a) : (a))"/>
Expand Down
43 changes: 43 additions & 0 deletions test/cfg/gtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,3 +655,46 @@ int g_return_val_if_reached_test(const char *s) {

return 0;
}

#define MY_APP_TYPE_WINDOW my_app_window_get_type()
G_DECLARE_FINAL_TYPE(MyAppWindow, my_app_window, MY_APP, WINDOW, GtkWindow)
struct _MyAppWindow {
GtkWindow parent;
};
G_DEFINE_TYPE(MyAppWindow, my_app_window, GTK_TYPE_WINDOW)
// cppcheck-suppress constParameterPointer
static void my_app_window_class_init(MyAppWindowClass *class) {
}
// cppcheck-suppress constParameterPointer
static void my_app_window_init(MyAppWindow *window) {
}

void g_declare_and_define_type_test(void) {
// cppcheck-suppress checkLibraryFunction
MyAppWindow *window = g_object_new(MY_APP_TYPE_WINDOW, NULL);
gtk_widget_show(GTK_WIDGET(window));
g_object_unref(window);
}

#if GLIB_CHECK_VERSION(2, 74, 0)
typedef enum {
MY_ENUM_A,
MY_ENUM_B,
} MyEnum;
G_DEFINE_ENUM_TYPE (MyEnum, my_enum,
G_DEFINE_ENUM_VALUE (MY_ENUM_A, "a"),
G_DEFINE_ENUM_VALUE (MY_ENUM_B, "b"))
typedef enum {
MY_FLAGS_A = 1 << 0,
MY_FLAGS_B = 1 << 1,
} MyFlags;
G_DEFINE_FLAGS_TYPE (MyFlags, my_flags,
G_DEFINE_ENUM_VALUE (MY_FLAGS_A, "a"),
G_DEFINE_ENUM_VALUE (MY_FLAGS_B, "b"))

int g_define_enum_and_flags_type_test(void) {
MyEnum e = MY_ENUM_A;
MyFlags f = MY_FLAGS_A;
return e + f;
}
#endif
Loading