~ubuntu-branches/ubuntu/lucid/pitivi/lucid

« back to all changes in this revision

Viewing changes to common/gstdoc-scangobj

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2009-05-27 14:22:49 UTC
  • mfrom: (1.2.1 upstream) (3.1.13 experimental)
  • Revision ID: james.westby@ubuntu.com-20090527142249-tj0qnkc37320ylml
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
           'output-dir' => \$OUTPUT_DIR,
52
52
           'version' => \$PRINT_VERSION,
53
53
           'help' => \$PRINT_HELP);
54
 
           
 
54
 
55
55
GetOptions(\%optctl, "module=s", "source=s", "types:s", "output-dir:s", "nogtkinit", "type-init-func:s", "version", "help");
56
56
 
57
57
if ($NO_GTK_INIT) {
81
81
 
82
82
$OUTPUT_DIR = $OUTPUT_DIR ? $OUTPUT_DIR : ".";
83
83
 
84
 
# THOMAS: dynamic types; only use types file for headers
85
 
 $TYPES_FILE = $TYPES_FILE ? $TYPES_FILE : "$OUTPUT_DIR/$MODULE.types";
 
84
$TYPES_FILE = $TYPES_FILE ? $TYPES_FILE : "$OUTPUT_DIR/$MODULE.types";
86
85
 
87
86
open (TYPES, $TYPES_FILE) || die "Cannot open $TYPES_FILE: $!\n";
88
87
open (OUTPUT, ">$MODULE-scan.c") || die "Cannot open $MODULE-scan.c: $!\n";
101
100
# write a C program to scan the types
102
101
 
103
102
$includes = "";
104
 
#@types = ();
 
103
@types = ();
 
104
@impl_types = ();
105
105
 
106
106
for (<TYPES>) {
107
107
    if (/^#include/) {
108
108
        $includes .= $_;
109
 
#    } elsif (/^%/) {
110
 
#       next;
111
 
#    } elsif (/^\s*$/) {
112
 
#       next;
113
 
#    } else {
114
 
#       chomp;
115
 
#       push @types, $_;
 
109
    } elsif (/^%/) {
 
110
        next;
 
111
    } elsif (/^\s*$/) {
 
112
        next;
 
113
    } elsif (/^type:(.*)$/) {
 
114
        $t = $1;
 
115
        chomp $t;
 
116
        push @impl_types, $t;
 
117
    } else {
 
118
        chomp;
 
119
        push @types, $_;
116
120
    }
117
121
}
118
122
 
119
 
#$ntypes = @types + 1;
 
123
$ntypes = @types + @impl_types;
120
124
 
121
125
print OUTPUT <<EOT;
122
126
#include <string.h>
125
129
#include <errno.h>
126
130
 
127
131
$includes
 
132
 
128
133
#ifdef GTK_IS_WIDGET_CLASS
129
134
#include <gtk/gtkversion.h>
130
135
#endif
137
142
    GList *factories = NULL;
138
143
    GList *l;
139
144
    GstElementFactory *factory = NULL;
 
145
    GType type;
140
146
 
141
147
    gint i = 0;
142
148
 
151
157
      plugin = (GstPlugin *) (plugins->data);
152
158
      plugins = g_list_next (plugins);
153
159
      source = gst_plugin_get_source (plugin);
154
 
      g_print ("source: %s\\n", source);
155
 
      if (!source || strcmp (gst_plugin_get_source (plugin), "$SOURCE") != 0) {
 
160
      /*g_print ("plugin: %s source: %s\\n", plugin->desc.name, source);*/
 
161
      if (!source || strcmp (source, "$SOURCE") != 0) {
156
162
        continue;
157
163
      }
 
164
      g_print ("plugin: %s source: %s\\n", plugin->desc.name, source);
158
165
 
159
166
      features =
160
167
          gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
170
177
 
171
178
        if (GST_IS_ELEMENT_FACTORY (feature)) {
172
179
          factory = GST_ELEMENT_FACTORY (feature);
173
 
          factories = g_list_append (factories, factory);
 
180
          factories = g_list_prepend (factories, factory);
174
181
        }
175
182
        features = g_list_next (features);
176
183
      }
179
186
    g_message ("number of element factories: %d", g_list_length (factories));
180
187
 
181
188
    /* allocate the object_types array to hold them */
182
 
    object_types = g_new0 (GType, g_list_length (factories)+1);
 
189
    object_types = g_new0 (GType, g_list_length (factories)+$ntypes+1);
183
190
 
184
191
    l = factories;
185
192
    i = 0;
186
193
 
187
194
    /* fill it */
188
195
    while (l) {
189
 
      GType type;
190
196
      factory = GST_ELEMENT_FACTORY (l->data);
191
 
      g_message ("adding type for factory %s", gst_element_factory_get_longname (factory));
192
197
      type = gst_element_factory_get_element_type (factory);
193
 
      g_message ("adding type %p", (void *) type);
194
 
      object_types[i] = type;
195
 
      i++;
 
198
      if (type != 0) {
 
199
        g_message ("adding type %p for factory %s", (void *) type, gst_element_factory_get_longname (factory));
 
200
        object_types[i++] = type;
 
201
      } else {
 
202
        g_message ("type info for factory %s not found",
 
203
            gst_element_factory_get_longname (factory));
 
204
      }
196
205
      l = g_list_next (l);
197
206
    }
 
207
 
 
208
EOT
 
209
 
 
210
# get_type functions:
 
211
for (@types) {
 
212
print OUTPUT <<EOT;
 
213
    type = $_ ();
 
214
    if (type == 0) {
 
215
      g_message ("$_ () didn't return a valid type");
 
216
    }
 
217
    else {
 
218
      object_types[i++] = type;
 
219
    }
 
220
EOT
 
221
}
 
222
 
 
223
# Implicit types retrieved from GLib:
 
224
for (@impl_types) {
 
225
print OUTPUT <<EOT;
 
226
    type = g_type_from_name ("$_");
 
227
    if (type == 0) {
 
228
      g_message ("Implicit type $_ not found");
 
229
    }
 
230
    else {
 
231
      object_types[i++] = type;
 
232
    }
 
233
EOT
 
234
}
 
235
 
 
236
print OUTPUT <<EOT;
 
237
 
198
238
    object_types[i] = 0;
199
 
EOT
200
 
 
201
 
print OUTPUT <<EOT;
202
239
 
203
240
    /* Need to make sure all the types are loaded in and initialize
204
241
     * their signals and properties.
206
243
    for (i=0; object_types[i]; i++) {
207
244
      if (G_TYPE_IS_CLASSED (object_types[i]))
208
245
        g_type_class_ref (object_types[i]);
 
246
        else {
 
247
          g_warning ("not reffing type: %s", g_type_name (object_types[i]));
 
248
        }
209
249
    }
210
250
 
211
251
    return object_types;
536
576
  if (g_type_is_a (type, G_TYPE_POINTER))
537
577
    *is_pointer = TRUE;
538
578
 
 
579
  /* But enums are not */
 
580
  if (g_type_is_a (type, G_TYPE_ENUM) ||
 
581
      g_type_is_a (type, G_TYPE_FLAGS))
 
582
    *is_pointer = FALSE;
 
583
 
539
584
  return type_name;
540
585
}
541
586
 
832
877
    }
833
878
  output_hierarchy (fp, G_TYPE_OBJECT, 0);
834
879
  output_hierarchy (fp, G_TYPE_INTERFACE, 0);
835
 
  
 
880
 
836
881
  for (i=0; object_types[i]; i++) {
837
882
    if (!g_type_parent (object_types[i]) &&
 
883
      (object_types[i] != G_TYPE_NONE) &&
838
884
      (object_types[i] != G_TYPE_OBJECT) &&
839
885
      (object_types[i] != G_TYPE_INTERFACE)
840
886
    ) {
 
887
      g_warning ("printing hierarchy for root type: %s",
 
888
          g_type_name (object_types[i]));
841
889
      output_hierarchy (fp, object_types[i], 0);
842
890
    }
843
891
  }
 
892
  /* for debugging
 
893
  for (i=0; object_types[i]; i++) {
 
894
    if(object_types[i] != G_TYPE_NONE) {
 
895
      g_print ("type has not been added to hierarchy: %s\\n",
 
896
        g_type_name (object_types[i]));
 
897
    }
 
898
  }
 
899
  for debugging */
844
900
 
845
901
  fclose (fp);
846
902
}
858
914
  if (!type)
859
915
    return;
860
916
 
 
917
  /* for debugging
 
918
  for (i=0; object_types[i]; i++) {
 
919
    if(object_types[i] == type) {
 
920
      g_print ("added type to hierarchy (level %d): %s\\n",
 
921
        level, g_type_name (type));
 
922
      object_types[i] = G_TYPE_NONE;
 
923
      break;
 
924
    }
 
925
  }
 
926
  for debugging */
 
927
 
861
928
  for (i = 0; i < level; i++)
862
929
    fprintf (fp, "  ");
863
 
  fprintf (fp, g_type_name (type));
 
930
  fprintf (fp, "%s", g_type_name (type));
864
931
  fprintf (fp, "\\n");
865
932
 
866
933
  children = g_type_children (type, &n_children);
867
934
 
868
 
  for (i=0; i < n_children; i++)
 
935
  for (i=0; i < n_children; i++) {
869
936
    output_hierarchy (fp, children[i], level + 1);
 
937
  }
870
938
 
871
939
  g_free (children);
872
940
}
873
941
 
874
942
static void output_object_interfaces (void)
875
943
{
 
944
  guint i;
876
945
  FILE *fp;
877
946
 
878
947
  fp = fopen (interfaces_filename, "w");
882
951
      return;
883
952
    }
884
953
  output_interfaces (fp, G_TYPE_OBJECT);
 
954
 
 
955
  for (i = 0; object_types[i]; i++)
 
956
    {
 
957
      if (!g_type_parent (object_types[i]) &&
 
958
          (object_types[i] != G_TYPE_OBJECT) &&
 
959
          G_TYPE_IS_INSTANTIATABLE (object_types[i]))
 
960
        {
 
961
          output_interfaces (fp, object_types[i]);
 
962
        }
 
963
    }
885
964
  fclose (fp);
886
965
}
887
966
 
900
979
 
901
980
  if (n_interfaces > 0)
902
981
    {
903
 
      fprintf (fp, g_type_name (type));
 
982
      fprintf (fp, "%s", g_type_name (type));
904
983
      for (i=0; i < n_interfaces; i++)
905
984
          fprintf (fp, " %s", g_type_name (interfaces[i]));
906
985
      fprintf (fp, "\\n");
945
1024
 
946
1025
  if (n_prerequisites > 0)
947
1026
    {
948
 
      fprintf (fp, g_type_name (type));
 
1027
      fprintf (fp, "%s", g_type_name (type));
949
1028
      for (i=0; i < n_prerequisites; i++)
950
1029
          fprintf (fp, " %s", g_type_name (prerequisites[i]));
951
1030
      fprintf (fp, "\\n");
1425
1504
  guint n_properties;
1426
1505
  gboolean child_prop;
1427
1506
  gboolean style_prop;
 
1507
  gboolean is_pointer;
 
1508
  const gchar *type_name;
1428
1509
  gchar *type_desc;
1429
1510
  gchar *default_value;
1430
1511
 
1431
 
  if (G_TYPE_IS_CLASSED (object_type))
 
1512
  if (G_TYPE_IS_OBJECT (object_type))
1432
1513
    {
1433
1514
      class = g_type_class_peek (object_type);
1434
1515
      if (!class)
1493
1574
 
1494
1575
        type_desc = describe_type (spec);
1495
1576
        default_value = describe_default (spec);
1496
 
        fprintf (fp, "<ARG>\\n<NAME>%s::%s</NAME>\\n<TYPE>%s</TYPE>\\n<RANGE>%s</RANGE>\\n<FLAGS>%s</FLAGS>\\n<NICK>%s</NICK>\\n<BLURB>%s%s</BLURB>\\n<DEFAULT>%s</DEFAULT>\\n</ARG>\\n\\n",
1497
 
                 object_class_name, g_param_spec_get_name (spec), g_type_name (spec->value_type), type_desc, flags, nick ? nick : "(null)", blurb ? blurb : "(null)", dot, default_value);
 
1577
        type_name = get_type_name (spec->value_type, &is_pointer);
 
1578
        fprintf (fp, "<ARG>\\n<NAME>%s::%s</NAME>\\n<TYPE>%s%s</TYPE>\\n<RANGE>%s</RANGE>\\n<FLAGS>%s</FLAGS>\\n<NICK>%s</NICK>\\n<BLURB>%s%s</BLURB>\\n<DEFAULT>%s</DEFAULT>\\n</ARG>\\n\\n",
 
1579
                 object_class_name, g_param_spec_get_name (spec), type_name, is_pointer ? "*" : "", type_desc, flags, nick ? nick : "(null)", blurb ? blurb : "(null)", dot, default_value);
1498
1580
        g_free (type_desc);
1499
1581
        g_free (default_value);
1500
1582
      }
1554
1636
unlink "./$MODULE-scan.c", "./$MODULE-scan.o", "./$MODULE-scan.lo", "./$MODULE-scan";
1555
1637
 
1556
1638
#&UpdateFileIfChanged ($old_signals_filename, $new_signals_filename, 0);
1557
 
#&UpdateFileIfChanged ($old_hierarchy_filename, $new_hierarchy_filename, 0);
1558
 
#&UpdateFileIfChanged ($old_interfaces_filename, $new_interfaces_filename, 0);
1559
 
#&UpdateFileIfChanged ($old_prerequisites_filename, $new_prerequisites_filename, 0);
 
1639
&UpdateFileIfChanged ($old_hierarchy_filename, $new_hierarchy_filename, 0);
 
1640
&UpdateFileIfChanged ($old_interfaces_filename, $new_interfaces_filename, 0);
 
1641
&UpdateFileIfChanged ($old_prerequisites_filename, $new_prerequisites_filename, 0);
1560
1642
#&UpdateFileIfChanged ($old_args_filename, $new_args_filename, 0);
1561
1643
 
1562
1644