[gtk-doc] Do not treat enums, flags and structs as objects even if they have a GType.



commit b36b9644a5f33448885c7a9d8255ec0ded2e0fb4
Author: David Necas <yeti physics muni cz>
Date:   Mon Jun 20 10:13:59 2011 +0200

    Do not treat enums, flags and structs as objects even if they have a GType.

 gtkdoc-mkdb.in                              |   26 ++++++++++++---------
 tests/gobject/docs-tmpl/tester-sections.txt |    4 +++
 tests/gobject/docs/tester-sections.txt      |    4 +++
 tests/gobject/src/gtypes.c                  |   19 ++++++++++++++++
 tests/gobject/src/gtypes.h                  |   32 +++++++++++++++++++++++++++
 5 files changed, 74 insertions(+), 11 deletions(-)
---
diff --git a/gtkdoc-mkdb.in b/gtkdoc-mkdb.in
index 3bf33df..996ea58 100755
--- a/gtkdoc-mkdb.in
+++ b/gtkdoc-mkdb.in
@@ -258,9 +258,11 @@ my %AllDocumentedSymbols;
 # Undeclared yet documented symbols
 my %UndeclaredSymbols;
 
-# These global arrays store GObject, subclasses and the hierarchy.
+# These global arrays store GObject, subclasses and the hierarchy (also of
+# non-object derived types).
 my @Objects;
 my @ObjectLevels;
+my %ObjectRoots;
 
 my %Interfaces;
 my %Prerequisites;
@@ -1444,7 +1446,7 @@ sub OutputStruct {
     if (&CheckIsObject ($symbol)) {
         #print "Found struct gtype: $symbol\n";
         $is_gtype = 1;
-        $default_to_public = 0;
+        $default_to_public = $ObjectRoots{$symbol} eq 'GBoxed';
     }
 
     my $id;
@@ -1558,7 +1560,7 @@ sub OutputStruct {
     my $params = $SymbolParams{$symbol};
 
     # If no parameters are filled in, we don't generate the description
-    # table, for backwards compatibility
+    # table, for backwards compatibility.
 
     my $found = 0;
     if (defined $params) {
@@ -5158,12 +5160,17 @@ sub ReadObjectHierarchy {
     # child turns up.
     my @pending_objects = ();
     my @pending_levels = ();
+    my $root;
     while (<INPUT>) {
         if (m/\S+/) {
             my $object = $&;
             my $level = (length($`)) / 2 + 1;
             my $xref = "";
 
+            if ($level == 1) {
+                $root = $object;
+            }
+
             while (($#pending_levels >= 0) && ($pending_levels[$#pending_levels] >= $level)) {
                 my $pobject = pop(@pending_objects);
                 my $plevel = pop(@pending_levels);
@@ -5181,6 +5188,7 @@ sub ReadObjectHierarchy {
                      print (OUTPUT ' ' x ($level * 4), "$xref\n");
                     push (@Objects, $object);
                     push (@ObjectLevels, $level);
+                    $ObjectRoots{$object} = $root;
                 }
             }
             #else {
@@ -5379,14 +5387,10 @@ sub ReadArgsFile {
 
 sub CheckIsObject {
     my ($name) = @_;
-
-    my $object;
-    foreach $object (@Objects) {
-        if ($object eq $name) {
-            return 1;
-        }
-    }
-    return 0;
+    my $root = $ObjectRoots{$name};
+    # Let GBoxed pass as an object here to get -struct appended to the id
+    # and prevent conflicts with sections.
+    return defined($root) and $root ne 'GEnum' and $root ne 'GFlags';
 }
 
 
diff --git a/tests/gobject/docs-tmpl/tester-sections.txt b/tests/gobject/docs-tmpl/tester-sections.txt
index 7745c12..06ef0dc 100644
--- a/tests/gobject/docs-tmpl/tester-sections.txt
+++ b/tests/gobject/docs-tmpl/tester-sections.txt
@@ -53,10 +53,14 @@ gtkdoc_iface2_get_type
 <SECTION>
 <FILE>types</FILE>
 GtkdocEnum
+GtkdocPlainOldData
+GtkdocBoxedPlainOldData
 <SUBSECTION Standard>
 GTKDOC_TYPE_ENUM
 GTKDOC_TYPE_BOXED
 gtkdoc_enum_get_type
 gtkdoc_boxed_get_type
+GTKDOC_TYPE_BOXED_PLAIN_OLD_DATA
+gtkdoc_boxed_plain_old_data_get_type
 </SECTION>
 
diff --git a/tests/gobject/docs/tester-sections.txt b/tests/gobject/docs/tester-sections.txt
index 7745c12..06ef0dc 100644
--- a/tests/gobject/docs/tester-sections.txt
+++ b/tests/gobject/docs/tester-sections.txt
@@ -53,10 +53,14 @@ gtkdoc_iface2_get_type
 <SECTION>
 <FILE>types</FILE>
 GtkdocEnum
+GtkdocPlainOldData
+GtkdocBoxedPlainOldData
 <SUBSECTION Standard>
 GTKDOC_TYPE_ENUM
 GTKDOC_TYPE_BOXED
 gtkdoc_enum_get_type
 gtkdoc_boxed_get_type
+GTKDOC_TYPE_BOXED_PLAIN_OLD_DATA
+gtkdoc_boxed_plain_old_data_get_type
 </SECTION>
 
diff --git a/tests/gobject/src/gtypes.c b/tests/gobject/src/gtypes.c
index 43f7403..2e75e5f 100644
--- a/tests/gobject/src/gtypes.c
+++ b/tests/gobject/src/gtypes.c
@@ -46,3 +46,22 @@ GType gtkdoc_boxed_get_type (void) {
   return type;
 }
 
+/* boxed plain old data: class internals */
+
+static gpointer gtkdoc_boxed_plain_old_data_copy (gpointer boxed) {
+  return g_memdup(boxed, sizeof(GtkdocBoxedPlainOldData));
+}
+
+static void gtkdoc_boxed_plain_old_data_free (gpointer boxed) {
+  g_free(boxed);
+}
+
+GType gtkdoc_boxed_plain_old_data_get_type (void) {
+  static GType type = 0;
+  if (type == 0) {
+    type = g_boxed_type_register_static("GtkdocBoxedPlainOldData",
+                                        (GBoxedCopyFunc) gtkdoc_boxed_plain_old_data_copy,
+                                        (GBoxedFreeFunc) gtkdoc_boxed_plain_old_data_free);
+  }
+  return type;
+}
diff --git a/tests/gobject/src/gtypes.h b/tests/gobject/src/gtypes.h
index 6e89381..7edb7bf 100644
--- a/tests/gobject/src/gtypes.h
+++ b/tests/gobject/src/gtypes.h
@@ -27,5 +27,37 @@ GType  gtkdoc_enum_get_type(void) G_GNUC_CONST;
 GType  gtkdoc_boxed_get_type(void) G_GNUC_CONST;
 
 
+/**
+ * GtkdocPlainOldData:
+ * @n: Some integer member.
+ * @x: Some floating point member.
+ *
+ * Unboxed plain old data that should default to public members.
+ **/
+typedef struct {
+    guint n;
+    gdouble x;
+    /*<private>*/
+    gpointer priv;
+} GtkdocPlainOldData;
+
+#define GTKDOC_TYPE_BOXED_PLAIN_OLD_DATA (gtkdoc_boxed_plain_old_data_get_type ())
+
+/**
+ * GtkdocBoxedPlainOldData:
+ * @n: Some integer member.
+ * @x: Some floating point member.
+ *
+ * Boxed plain old data that should default to public members.
+ **/
+typedef struct {
+    guint n;
+    gdouble x;
+    /*<private>*/
+    gpointer priv;
+} GtkdocBoxedPlainOldData;
+
+GType  gtkdoc_boxed_plain_old_data_get_type(void) G_GNUC_CONST;
+
 #endif // GTKDOC_TYPES_H
 



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