[libdazzle/libdazzle-3-26] build: add useful macros to public API



commit ef9140cf57a7e1f0d0cf37b0895d52f8de83d955
Author: Christian Hergert <chergert redhat com>
Date:   Tue Sep 12 15:31:55 2017 -0700

    build: add useful macros to public API

 src/dazzle.h                |    1 +
 src/util/dzl-macros.h       |   64 +++++++++++++++++++++++++++++++++++++++++++
 src/util/dzl-util-private.h |   30 +-------------------
 src/util/meson.build        |    1 +
 4 files changed, 68 insertions(+), 28 deletions(-)
---
diff --git a/src/dazzle.h b/src/dazzle.h
index 5ac1a21..82d801f 100644
--- a/src/dazzle.h
+++ b/src/dazzle.h
@@ -133,6 +133,7 @@ G_BEGIN_DECLS
 #include "util/dzl-gtk.h"
 #include "util/dzl-heap.h"
 #include "util/dzl-int-pair.h"
+#include "util/dzl-macros.h"
 #include "util/dzl-pango.h"
 #include "util/dzl-rgba.h"
 #include "util/dzl-ring.h"
diff --git a/src/util/dzl-macros.h b/src/util/dzl-macros.h
new file mode 100644
index 0000000..7238f0b
--- /dev/null
+++ b/src/util/dzl-macros.h
@@ -0,0 +1,64 @@
+/* dzl-macros.h
+ *
+ * Copyright (C) 2017 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef DZL_MACROS_H
+#define DZL_MACROS_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#if defined(_MSC_VER)
+# define DZL_ALIGNED_BEGIN(_N) __declspec(align(_N))
+# define DZL_ALIGNED_END(_N)
+#else
+# define DZL_ALIGNED_BEGIN(_N)
+# define DZL_ALIGNED_END(_N) __attribute__((aligned(_N)))
+#endif
+
+#define dzl_clear_weak_pointer(ptr) \
+  (*(ptr) ? (g_object_remove_weak_pointer((GObject*)*(ptr), (gpointer*)ptr),*(ptr)=NULL,1) : 0)
+
+#define dzl_set_weak_pointer(ptr,obj) \
+  
((obj!=*(ptr))?(dzl_clear_weak_pointer(ptr),*(ptr)=obj,((obj)?g_object_add_weak_pointer((GObject*)obj,(gpointer*)ptr),NULL:NULL),1):0)
+
+static inline gboolean
+dzl_str_empty0 (const gchar *str)
+{
+  return str == NULL || *str == '\0';
+}
+
+static inline gboolean
+dzl_str_equal0 (const gchar *str1,
+                const gchar *str2)
+{
+  return g_strcmp0 (str1, str2) == 0;
+}
+
+static inline void
+dzl_clear_source (guint *source_ptr)
+{
+  guint source = *source_ptr;
+  *source_ptr = 0;
+  if (source != 0)
+    g_source_remove (source);
+}
+
+G_END_DECLS
+
+#endif /* DZL_MACROS_H */
diff --git a/src/util/dzl-util-private.h b/src/util/dzl-util-private.h
index c08d8ed..b426818 100644
--- a/src/util/dzl-util-private.h
+++ b/src/util/dzl-util-private.h
@@ -21,35 +21,9 @@
 
 #include <gtk/gtk.h>
 
-G_BEGIN_DECLS
-
-#define dzl_clear_weak_pointer(ptr) \
-  (*(ptr) ? (g_object_remove_weak_pointer((GObject*)*(ptr), (gpointer*)ptr),*(ptr)=NULL,1) : 0)
-
-#define dzl_set_weak_pointer(ptr,obj) \
-  
((obj!=*(ptr))?(dzl_clear_weak_pointer(ptr),*(ptr)=obj,((obj)?g_object_add_weak_pointer((GObject*)obj,(gpointer*)ptr),NULL:NULL),1):0)
+#include "dzl-macros.h"
 
-static inline gboolean
-dzl_str_empty0 (const gchar *str)
-{
-  return str == NULL || *str == '\0';
-}
-
-static inline gboolean
-dzl_str_equal0 (const gchar *str1,
-                const gchar *str2)
-{
-  return g_strcmp0 (str1, str2) == 0;
-}
-
-static inline void
-dzl_clear_source (guint *source_ptr)
-{
-  guint source = *source_ptr;
-  *source_ptr = 0;
-  if (source != 0)
-    g_source_remove (source);
-}
+G_BEGIN_DECLS
 
 void          dzl_gtk_widget_class_add_css_resource (GtkWidgetClass   *widget_class,
                                                      const gchar      *resource);
diff --git a/src/util/meson.build b/src/util/meson.build
index 9ce06d4..276286a 100644
--- a/src/util/meson.build
+++ b/src/util/meson.build
@@ -7,6 +7,7 @@ util_headers = [
   'dzl-gtk.h',
   'dzl-heap.h',
   'dzl-int-pair.h',
+  'dzl-macros.h',
   'dzl-pango.h',
   'dzl-rgba.h',
   'dzl-ring.h',


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]