[pango/simple-fontmap: 13/31] Add PANGO_DECLARE_INTERNAL_TYPE
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/simple-fontmap: 13/31] Add PANGO_DECLARE_INTERNAL_TYPE
- Date: Sun, 26 Dec 2021 18:03:15 +0000 (UTC)
commit b6199dd25bc5b5493beb8c3c81e80e8ff9e5e3fa
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Dec 23 08:48:14 2021 -0500
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.
pango/pango-types.h | 41 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
---
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__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]