diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-12-23 08:48:14 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-01-28 09:03:03 -0500 |
commit | fd46d4348549a2155ded0ab7ea260c2730ad3d57 (patch) | |
tree | f101908feb8b838912faf5ac6db6313ada2872c4 /pango | |
parent | 39a1a509dd8073b6c7a998b5b1bc2316ae4ae408 (diff) | |
download | pango-fd46d4348549a2155ded0ab7ea260c2730ad3d57.tar.gz |
Add PANGO_DECLARE_INTERNAL_TYPE
This will be used in future commits for
making types that can be internally derived
without exposing them to 3rd parties.
Diffstat (limited to 'pango')
-rw-r--r-- | pango/pango-types.h | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/pango/pango-types.h b/pango/pango-types.h index ed86f699..0b6456a3 100644 --- a/pango/pango-types.h +++ b/pango/pango-types.h @@ -231,7 +231,6 @@ PANGO_AVAILABLE_IN_1_16 void pango_extents_to_pixels (PangoRectangle *inclusive, PangoRectangle *nearest); - #include <pango/pango-gravity.h> #include <pango/pango-language.h> #include <pango/pango-matrix.h> @@ -239,6 +238,46 @@ void pango_extents_to_pixels (PangoRectangle *inclusive, #include <pango/pango-bidi-type.h> +/* + * PANGO_DECLARE_INTERNAL_TYPE: + * @ModuleObjName: The name of the new type, in camel case (like GtkWidget) + * @module_obj_name: The name of the new type in lowercase, with words + * separated by '_' (like 'gtk_widget') + * @MODULE: The name of the module, in all caps (like 'GTK') + * @OBJ_NAME: The bare name of the type, in all caps (like 'WIDGET') + * @ParentName: the name of the parent type, in camel case (like GtkWidget) + * + * A convenience macro for emitting the usual declarations in the + * header file for a type which is intended to be subclassed only + * by internal consumers. + * + * This macro differs from %G_DECLARE_DERIVABLE_TYPE and %G_DECLARE_FINAL_TYPE + * by declaring a type that is only derivable internally. Internal users can + * derive this type, assuming they have access to the instance and class + * structures; external users will not be able to subclass this type. + */ +#define PANGO_DECLARE_INTERNAL_TYPE(ModuleObjName, module_obj_name, MODULE, OBJ_NAME, ParentName) \ + GType module_obj_name##_get_type (void); \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + typedef struct _##ModuleObjName ModuleObjName; \ + typedef struct _##ModuleObjName##Class ModuleObjName##Class; \ + \ + _GLIB_DEFINE_AUTOPTR_CHAINUP (ModuleObjName, ParentName) \ + G_DEFINE_AUTOPTR_CLEANUP_FUNC (ModuleObjName##Class, g_type_class_unref) \ + \ + G_GNUC_UNUSED static inline ModuleObjName * MODULE##_##OBJ_NAME (gpointer ptr) { \ + return G_TYPE_CHECK_INSTANCE_CAST (ptr, module_obj_name##_get_type (), ModuleObjName); } \ + G_GNUC_UNUSED static inline ModuleObjName##Class * MODULE##_##OBJ_NAME##_CLASS (gpointer ptr) { \ + return G_TYPE_CHECK_CLASS_CAST (ptr, module_obj_name##_get_type (), ModuleObjName##Class); } \ + G_GNUC_UNUSED static inline gboolean MODULE##_IS_##OBJ_NAME (gpointer ptr) { \ + return G_TYPE_CHECK_INSTANCE_TYPE (ptr, module_obj_name##_get_type ()); } \ + G_GNUC_UNUSED static inline gboolean MODULE##_IS_##OBJ_NAME##_CLASS (gpointer ptr) { \ + return G_TYPE_CHECK_CLASS_TYPE (ptr, module_obj_name##_get_type ()); } \ + G_GNUC_UNUSED static inline ModuleObjName##Class * MODULE##_##OBJ_NAME##_GET_CLASS (gpointer ptr) { \ + return G_TYPE_INSTANCE_GET_CLASS (ptr, module_obj_name##_get_type (), ModuleObjName##Class); } \ + G_GNUC_END_IGNORE_DEPRECATIONS + + G_END_DECLS #endif /* __PANGO_TYPES_H__ */ |