[gtk-doc] tests: add examples for other gobject types



commit 06cea18d0b88e0ade6700bbe5e675deb2ad65db6
Author: Stefan Kost <ensonic users sf net>
Date:   Fri Dec 25 23:48:17 2009 +0200

    tests: add examples for other gobject types
    
    Add a boxed and a enum type to the gobject tests.

 tests/gobject/docs-tmpl/tester-docs.xml     |    1 +
 tests/gobject/docs-tmpl/tester-sections.txt |   10 ++++++
 tests/gobject/docs-tmpl/tester.types        |    2 +
 tests/gobject/docs/tester-docs.xml          |    1 +
 tests/gobject/docs/tester-sections.txt      |   10 ++++++
 tests/gobject/src/Makefile.am               |    6 +++-
 tests/gobject/src/giface.h                  |    4 ++-
 tests/gobject/src/gobject.h                 |    4 ++-
 tests/gobject/src/gtypes.c                  |   47 +++++++++++++++++++++++++++
 tests/gobject/src/gtypes.h                  |   29 ++++++++++++++++
 tests/gobject/src/tester.h                  |    1 +
 11 files changed, 112 insertions(+), 3 deletions(-)
---
diff --git a/tests/gobject/docs-tmpl/tester-docs.xml b/tests/gobject/docs-tmpl/tester-docs.xml
index 796adf3..5f9b599 100644
--- a/tests/gobject/docs-tmpl/tester-docs.xml
+++ b/tests/gobject/docs-tmpl/tester-docs.xml
@@ -26,6 +26,7 @@
     <title>Tests</title>
     <xi:include href="xml/object.xml"/>
     <xi:include href="xml/iface.xml"/>
+    <xi:include href="xml/types.xml"/>
   </chapter>
 
   <chapter id="object-tree">
diff --git a/tests/gobject/docs-tmpl/tester-sections.txt b/tests/gobject/docs-tmpl/tester-sections.txt
index be57415..4bb7b57 100644
--- a/tests/gobject/docs-tmpl/tester-sections.txt
+++ b/tests/gobject/docs-tmpl/tester-sections.txt
@@ -34,3 +34,13 @@ gtkdoc_iface_get_type
 GTKDOC_IFACE_GET_INTERFACE
 </SECTION>
 
+<SECTION>
+<FILE>types</FILE>
+GtkdocEnum
+<SUBSECTION Standard>
+GTKDOC_TYPE_ENUM
+GTKDOC_TYPE_BOXED
+gtkdoc_enum_get_type
+gtkdoc_boxed_get_type
+</SECTION>
+
diff --git a/tests/gobject/docs-tmpl/tester.types b/tests/gobject/docs-tmpl/tester.types
index b4b6cea..a6d82a2 100644
--- a/tests/gobject/docs-tmpl/tester.types
+++ b/tests/gobject/docs-tmpl/tester.types
@@ -2,3 +2,5 @@
 
 gtkdoc_object_get_type
 gtkdoc_iface_get_type
+gtkdoc_enum_get_type
+gtkdoc_boxed_get_type
diff --git a/tests/gobject/docs/tester-docs.xml b/tests/gobject/docs/tester-docs.xml
index 261e789..86c0f0b 100644
--- a/tests/gobject/docs/tester-docs.xml
+++ b/tests/gobject/docs/tester-docs.xml
@@ -49,6 +49,7 @@
       <title>Tests</title>
       <xi:include href="xml/object.xml"/>
       <xi:include href="xml/iface.xml"/>
+      <xi:include href="xml/types.xml"/>
     </chapter>
   </reference>
 
diff --git a/tests/gobject/docs/tester-sections.txt b/tests/gobject/docs/tester-sections.txt
index 7e5e90b..7e96f5b 100644
--- a/tests/gobject/docs/tester-sections.txt
+++ b/tests/gobject/docs/tester-sections.txt
@@ -32,3 +32,13 @@ gtkdoc_iface_get_type
 GTKDOC_IFACE_GET_INTERFACE
 </SECTION>
 
+<SECTION>
+<FILE>types</FILE>
+GtkdocEnum
+<SUBSECTION Standard>
+GTKDOC_TYPE_ENUM
+GTKDOC_TYPE_BOXED
+gtkdoc_enum_get_type
+gtkdoc_boxed_get_type
+</SECTION>
+
diff --git a/tests/gobject/src/Makefile.am b/tests/gobject/src/Makefile.am
index 96af1b9..eaa6a40 100644
--- a/tests/gobject/src/Makefile.am
+++ b/tests/gobject/src/Makefile.am
@@ -4,7 +4,11 @@ if BUILD_TESTS
 
 noinst_LTLIBRARIES = libtester.la
 
-libtester_la_SOURCES = gobject.c gobject.h giface.c giface.h tester.h
+libtester_la_SOURCES = \
+	gobject.c gobject.h \
+	giface.c giface.h \
+	gtypes.c gtypes.h \
+	tester.h
 #libtester_la_LIBADD = $(TEST_DEPS_LIBS)
 
 AM_CPPFLAGS = $(TEST_DEPS_CFLAGS)
diff --git a/tests/gobject/src/giface.h b/tests/gobject/src/giface.h
index 15f2a95..66ae29b 100644
--- a/tests/gobject/src/giface.h
+++ b/tests/gobject/src/giface.h
@@ -4,12 +4,14 @@
 #include <glib.h>
 #include <glib-object.h>
 
+/* type macros */
+
 #define GTKDOC_TYPE_IFACE               (gtkdoc_iface_get_type ())
 #define GTKDOC_IFACE(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTKDOC_TYPE_IFACE, GtkdocIface))
 #define GTKDOC_IS_IFACE(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTKDOC_TYPE_IFACE))
 #define GTKDOC_IFACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTKDOC_TYPE_IFACE, GtkdocIfaceInterface))
 
-/* type macros */
+/* type structs */
 
 /**
  * GtkdocIface:
diff --git a/tests/gobject/src/gobject.h b/tests/gobject/src/gobject.h
index 5be9b9c..1404626 100644
--- a/tests/gobject/src/gobject.h
+++ b/tests/gobject/src/gobject.h
@@ -4,6 +4,8 @@
 #include <glib.h>
 #include <glib-object.h>
 
+/* type macros */
+
 #define GTKDOC_TYPE_OBJECT            (gtkdoc_object_get_type ())
 #define GTKDOC_OBJECT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTKDOC_TYPE_OBJECT, GtkdocObject))
 #define GTKDOC_OBJECT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTKDOCTYPE_OBJECT, GtkdocObjectClass))
@@ -11,7 +13,7 @@
 #define GTKDOC_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTKDOC_TYPE_OBJECT))
 #define GTKDOC_OBJECT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTKDOC_TYPE_OBJECT, GtkdocObjectClass))
 
-/* type macros */
+/* type structs */
 
 typedef struct _GtkdocObject GtkdocObject;
 typedef struct _GtkdocObjectClass GtkdocObjectClass;
diff --git a/tests/gobject/src/gtypes.c b/tests/gobject/src/gtypes.c
new file mode 100644
index 0000000..b8530c3
--- /dev/null
+++ b/tests/gobject/src/gtypes.c
@@ -0,0 +1,47 @@
+/**
+ * SECTION:types
+ * @title: GtkdocTypes
+ * @short_description: other gobject types for gtk-doc unit test
+ * @see_also: #GtkdocObject, #GtkdocIface
+ *
+ * This file contains non-sense code for the sole purpose of testing the docs.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "gtypes.h"
+
+/* enum: class internals */
+
+GType gtkdoc_enum_get_type (void) {
+  static GType type = 0;
+  if(type==0) {
+    static const GEnumValue values[] = {
+      { GTKDOC_ENUM_V1,          "GTKDOC_ENUM_V1",          "first" },
+      { GTKDOC_ENUM_V2,          "GTKDOC_ENUM_V2",          "second" },
+      { 0, NULL, NULL},
+    };
+    type = g_enum_register_static ("GtkdocEnum", values);
+  }
+  return type;
+}
+
+/* boxed: class internals */
+
+static gpointer gtkdoc_boxed_copy (gpointer boxed) {
+  return boxed;
+}
+
+static void gtkdoc_boxed_free (gpointer boxed) {
+}
+
+GType gtkdoc_boxed_get_type (void) {
+  static GType type = 0;
+  if (type == 0) {
+    type = g_boxed_type_register_static("GtkdocBoxed",
+        (GBoxedCopyFunc) gtkdoc_boxed_copy, (GBoxedFreeFunc) gtkdoc_boxed_free);
+  }
+  return type;
+}
+
diff --git a/tests/gobject/src/gtypes.h b/tests/gobject/src/gtypes.h
new file mode 100644
index 0000000..40ed826
--- /dev/null
+++ b/tests/gobject/src/gtypes.h
@@ -0,0 +1,29 @@
+#ifndef GTKDOC_TYPES_H
+#define GTKDOC_TYPES_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+/* type macros */
+
+#define GTKDOC_TYPE_ENUM              (gtkdoc_enum_get_type ())
+#define GTKDOC_TYPE_BOXED             (gtkdoc_boxed_get_type ())
+
+/**
+ * GtkdocEnum:
+ * @GTKDOC_ENUM_V1: first
+ * @GTKDOC_ENUM_V2: second
+ *
+ * Enum values for the #GtkdocEnum type.
+ */
+typedef enum {
+  GTKDOC_ENUM_V1=0,
+  GTKDOC_ENUM_V2
+} GtkdocEnum;
+
+GType  gtkdoc_enum_get_type(void) G_GNUC_CONST;
+GType  gtkdoc_boxed_get_type(void) G_GNUC_CONST;
+
+
+#endif // GTKDOC_TYPES_H
+
diff --git a/tests/gobject/src/tester.h b/tests/gobject/src/tester.h
index 7fb109c..36cb91c 100644
--- a/tests/gobject/src/tester.h
+++ b/tests/gobject/src/tester.h
@@ -3,6 +3,7 @@
 
 #include "gobject.h"
 #include "giface.h"
+#include "gtypes.h"
 
 #endif // GTKDOC_TESTER_H
 



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