mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 17:20:36 +00:00
docs: Store all non-element types in a separate other-types array
And also make sure to not duplicate them.
This commit is contained in:
parent
994d74faf4
commit
65e266fe6e
1 changed files with 105 additions and 74 deletions
|
@ -11,7 +11,8 @@
|
||||||
#include "gst/gst-i18n-app.h"
|
#include "gst/gst-i18n-app.h"
|
||||||
|
|
||||||
static GRegex *cleanup_caps_field = NULL;
|
static GRegex *cleanup_caps_field = NULL;
|
||||||
static void _add_object_details (GString * json, GObject * object);
|
static void _add_object_details (GString * json, GString * other_types,
|
||||||
|
GHashTable * seen_other_types, GObject * object);
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
has_sometimes_template (GObject * object)
|
has_sometimes_template (GObject * object)
|
||||||
|
@ -129,14 +130,13 @@ _serialize_flags_default (GString * json, GType gtype, GValue * value)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_serialize_flags (GString * json, const gchar * key_name, GType gtype)
|
_serialize_flags (GString * json, GType gtype)
|
||||||
{
|
{
|
||||||
GFlagsValue *values = G_FLAGS_CLASS (g_type_class_ref (gtype))->values;
|
GFlagsValue *values = G_FLAGS_CLASS (g_type_class_ref (gtype))->values;
|
||||||
|
|
||||||
g_string_append_printf (json, "\"%s\": {", key_name);
|
g_string_append_printf (json, "%s\"%s\": { "
|
||||||
|
"\"kind\": \"flags\"," "\"values\": [", json->len ? "," : "",
|
||||||
g_string_append_printf (json, "\"name\": \"%s\", "
|
g_type_name (gtype));
|
||||||
"\"kind\": \"flags\"," "\"values\": [", g_type_name (gtype));
|
|
||||||
|
|
||||||
while (values[0].value_name) {
|
while (values[0].value_name) {
|
||||||
gchar *value_name = json_strescape (values[0].value_name);
|
gchar *value_name = json_strescape (values[0].value_name);
|
||||||
|
@ -183,17 +183,16 @@ _serialize_enum_default (GString * json, GType gtype, GValue * value)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_serialize_enum (GString * json, const gchar * key_name, GType gtype)
|
_serialize_enum (GString * json, GType gtype)
|
||||||
{
|
{
|
||||||
GEnumValue *values;
|
GEnumValue *values;
|
||||||
guint j = 0;
|
guint j = 0;
|
||||||
|
|
||||||
values = G_ENUM_CLASS (g_type_class_ref (gtype))->values;
|
values = G_ENUM_CLASS (g_type_class_ref (gtype))->values;
|
||||||
|
|
||||||
g_string_append_printf (json, "\"%s\": {", key_name);
|
g_string_append_printf (json, "%s\"%s\": { "
|
||||||
|
"\"kind\": \"enum\"," "\"values\": [", json->len ? "," : "",
|
||||||
g_string_append_printf (json, "\"name\": \"%s\", "
|
g_type_name (gtype));
|
||||||
"\"kind\": \"enum\"," "\"values\": [", g_type_name (gtype));
|
|
||||||
|
|
||||||
while (values[j].value_name) {
|
while (values[j].value_name) {
|
||||||
gchar *value_name = json_strescape (values[j].value_name);
|
gchar *value_name = json_strescape (values[j].value_name);
|
||||||
|
@ -214,30 +213,36 @@ _serialize_enum (GString * json, const gchar * key_name, GType gtype)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_serialize_object (GString * json, const gchar * key_name, GType gtype)
|
_serialize_object (GString * json, GHashTable * seen_other_types, GType gtype)
|
||||||
{
|
{
|
||||||
GObject *tmpobj;
|
GObject *tmpobj;
|
||||||
|
GString *other_types = NULL;
|
||||||
|
|
||||||
g_string_append_printf (json, "\"%s\": {", key_name);
|
g_string_append_printf (json, "%s\"%s\": { "
|
||||||
|
"\"kind\": \"object\"", json->len ? "," : "", g_type_name (gtype));
|
||||||
g_string_append_printf (json, "\"name\": \"%s\", "
|
|
||||||
"\"kind\": \"object\"", g_type_name (gtype));
|
|
||||||
|
|
||||||
if (!G_TYPE_IS_ABSTRACT (gtype) && !G_TYPE_IS_INTERFACE (gtype)
|
if (!G_TYPE_IS_ABSTRACT (gtype) && !G_TYPE_IS_INTERFACE (gtype)
|
||||||
&& G_TYPE_IS_INSTANTIATABLE (gtype)
|
&& G_TYPE_IS_INSTANTIATABLE (gtype)
|
||||||
&& !g_type_is_a (gtype, G_TYPE_INITABLE)
|
&& !g_type_is_a (gtype, G_TYPE_INITABLE)
|
||||||
&& !g_type_is_a (gtype, G_TYPE_ASYNC_INITABLE)) {
|
&& !g_type_is_a (gtype, G_TYPE_ASYNC_INITABLE)) {
|
||||||
|
other_types = g_string_new ("");
|
||||||
g_string_append_c (json, ',');
|
g_string_append_c (json, ',');
|
||||||
tmpobj = g_object_new (gtype, NULL);
|
tmpobj = g_object_new (gtype, NULL);
|
||||||
_add_object_details (json, tmpobj);
|
_add_object_details (json, other_types, seen_other_types, tmpobj);
|
||||||
gst_object_unref (tmpobj);
|
gst_object_unref (tmpobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_string_append_c (json, '}');
|
g_string_append_c (json, '}');
|
||||||
|
|
||||||
|
if (other_types->len) {
|
||||||
|
g_string_append_printf (json, ",%s", other_types->str);
|
||||||
|
}
|
||||||
|
g_string_free (other_types, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_add_signals (GString * json, GObject * object)
|
_add_signals (GString * json, GString * other_types,
|
||||||
|
GHashTable * seen_other_types, GObject * object)
|
||||||
{
|
{
|
||||||
gboolean opened = FALSE;
|
gboolean opened = FALSE;
|
||||||
guint *signals;
|
guint *signals;
|
||||||
|
@ -308,40 +313,44 @@ _add_signals (GString * json, GObject * object)
|
||||||
g_string_append_c (json, ',');
|
g_string_append_c (json, ',');
|
||||||
}
|
}
|
||||||
|
|
||||||
g_string_append_printf (json, "{ \"name\": \"%s\",", arg_name);
|
g_string_append_printf (json, "{ \"name\": \"%s\","
|
||||||
|
"\"type\": \"%s\" }", arg_name,
|
||||||
if (g_type_is_a (query->param_types[j], G_TYPE_ENUM)
|
|
||||||
&& gst_type_is_plugin_api (query->param_types[j])) {
|
|
||||||
_serialize_enum (json, "type", query->param_types[j]);
|
|
||||||
} else if (g_type_is_a (query->param_types[j], G_TYPE_FLAGS)
|
|
||||||
&& gst_type_is_plugin_api (query->param_types[j])) {
|
|
||||||
_serialize_flags (json, "type", query->param_types[j]);
|
|
||||||
} else if (g_type_is_a (query->param_types[j], G_TYPE_OBJECT)
|
|
||||||
&& gst_type_is_plugin_api (query->param_types[j])) {
|
|
||||||
_serialize_object (json, "type", query->param_types[j]);
|
|
||||||
} else {
|
|
||||||
g_string_append_printf (json, "\"type\": \"%s\"",
|
|
||||||
g_type_name (query->param_types[j]));
|
g_type_name (query->param_types[j]));
|
||||||
}
|
|
||||||
|
|
||||||
g_string_append_c (json, '}');
|
if (!g_hash_table_contains (seen_other_types,
|
||||||
|
g_type_name (query->param_types[j]))
|
||||||
|
&& gst_type_is_plugin_api (query->param_types[j])) {
|
||||||
|
g_hash_table_insert (seen_other_types,
|
||||||
|
(gpointer) g_type_name (query->param_types[j]), NULL);
|
||||||
|
|
||||||
|
if (g_type_is_a (query->param_types[j], G_TYPE_ENUM)) {
|
||||||
|
_serialize_enum (other_types, query->param_types[j]);
|
||||||
|
} else if (g_type_is_a (query->param_types[j], G_TYPE_FLAGS)) {
|
||||||
|
_serialize_flags (other_types, query->param_types[j]);
|
||||||
|
} else if (g_type_is_a (query->param_types[j], G_TYPE_OBJECT)) {
|
||||||
|
_serialize_object (other_types, seen_other_types,
|
||||||
|
query->param_types[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
g_string_append_c (json, ']');
|
g_string_append_c (json, ']');
|
||||||
|
|
||||||
g_string_append_c (json, ',');
|
if (!g_hash_table_contains (seen_other_types,
|
||||||
if (g_type_is_a (query->return_type, G_TYPE_ENUM)
|
g_type_name (query->return_type))
|
||||||
&& gst_type_is_plugin_api (query->return_type)) {
|
&& gst_type_is_plugin_api (query->return_type)) {
|
||||||
_serialize_enum (json, "return-type", query->return_type);
|
g_hash_table_insert (seen_other_types,
|
||||||
} else if (g_type_is_a (query->return_type, G_TYPE_FLAGS)
|
(gpointer) g_type_name (query->return_type), NULL);
|
||||||
&& gst_type_is_plugin_api (query->return_type)) {
|
if (g_type_is_a (query->return_type, G_TYPE_ENUM)) {
|
||||||
_serialize_flags (json, "return-type", query->return_type);
|
_serialize_enum (other_types, query->return_type);
|
||||||
} else if (g_type_is_a (query->return_type, G_TYPE_OBJECT)
|
} else if (g_type_is_a (query->return_type, G_TYPE_FLAGS)) {
|
||||||
&& gst_type_is_plugin_api (query->return_type)) {
|
_serialize_flags (other_types, query->return_type);
|
||||||
_serialize_object (json, "return-type", query->return_type);
|
} else if (g_type_is_a (query->return_type, G_TYPE_OBJECT)) {
|
||||||
} else {
|
_serialize_object (other_types, seen_other_types, query->return_type);
|
||||||
g_string_append_printf (json,
|
|
||||||
"\"return-type\": \"%s\"", g_type_name (query->return_type));
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_string_append_printf (json,
|
||||||
|
",\"return-type\": \"%s\"", g_type_name (query->return_type));
|
||||||
|
|
||||||
if (query->signal_flags & G_SIGNAL_RUN_FIRST)
|
if (query->signal_flags & G_SIGNAL_RUN_FIRST)
|
||||||
g_string_append (json, ",\"when\": \"first\"");
|
g_string_append (json, ",\"when\": \"first\"");
|
||||||
|
@ -375,7 +384,8 @@ _add_signals (GString * json, GObject * object)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_add_properties (GString * json, GObject * object, GObjectClass * klass)
|
_add_properties (GString * json, GString * other_types,
|
||||||
|
GHashTable * seen_other_types, GObject * object, GObjectClass * klass)
|
||||||
{
|
{
|
||||||
gchar *tmpstr;
|
gchar *tmpstr;
|
||||||
guint i, n_props;
|
guint i, n_props;
|
||||||
|
@ -413,28 +423,29 @@ _add_properties (GString * json, GObject * object, GObjectClass * klass)
|
||||||
"\"construct\": %s,"
|
"\"construct\": %s,"
|
||||||
"\"readable\": %s,"
|
"\"readable\": %s,"
|
||||||
"\"writable\": %s,"
|
"\"writable\": %s,"
|
||||||
"\"blurb\": \"%s\"",
|
"\"blurb\": \"%s\","
|
||||||
|
"\"type\": \"%s\"",
|
||||||
opened ? "," : "",
|
opened ? "," : "",
|
||||||
spec->name,
|
spec->name,
|
||||||
spec->flags & G_PARAM_CONSTRUCT_ONLY ? "true" : "false",
|
spec->flags & G_PARAM_CONSTRUCT_ONLY ? "true" : "false",
|
||||||
spec->flags & G_PARAM_CONSTRUCT ? "true" : "false",
|
spec->flags & G_PARAM_CONSTRUCT ? "true" : "false",
|
||||||
spec->flags & G_PARAM_READABLE ? "true" : "false",
|
spec->flags & G_PARAM_READABLE ? "true" : "false",
|
||||||
spec->flags & G_PARAM_WRITABLE ? "true" : "false", tmpstr);
|
spec->flags & G_PARAM_WRITABLE ? "true" : "false", tmpstr,
|
||||||
|
g_type_name (G_PARAM_SPEC_VALUE_TYPE (spec)));
|
||||||
g_free (tmpstr);
|
g_free (tmpstr);
|
||||||
|
|
||||||
g_string_append_c (json, ',');
|
if (!g_hash_table_contains (seen_other_types,
|
||||||
if (G_IS_PARAM_SPEC_ENUM (spec)
|
g_type_name (spec->value_type))
|
||||||
&& gst_type_is_plugin_api (spec->value_type)) {
|
&& gst_type_is_plugin_api (spec->value_type)) {
|
||||||
_serialize_enum (json, "type", spec->value_type);
|
g_hash_table_insert (seen_other_types,
|
||||||
} else if (G_IS_PARAM_SPEC_FLAGS (spec)
|
(gpointer) g_type_name (spec->value_type), NULL);
|
||||||
&& gst_type_is_plugin_api (spec->value_type)) {
|
if (G_IS_PARAM_SPEC_ENUM (spec)) {
|
||||||
_serialize_flags (json, "type", spec->value_type);
|
_serialize_enum (other_types, spec->value_type);
|
||||||
} else if (G_IS_PARAM_SPEC_OBJECT (spec)
|
} else if (G_IS_PARAM_SPEC_FLAGS (spec)) {
|
||||||
&& gst_type_is_plugin_api (spec->value_type)) {
|
_serialize_flags (other_types, spec->value_type);
|
||||||
_serialize_object (json, "type", spec->value_type);
|
} else if (G_IS_PARAM_SPEC_OBJECT (spec)) {
|
||||||
} else {
|
_serialize_object (other_types, seen_other_types, spec->value_type);
|
||||||
g_string_append_printf (json,
|
}
|
||||||
"\"type\": \"%s\"", g_type_name (G_PARAM_SPEC_VALUE_TYPE (spec)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (G_VALUE_TYPE (&value)) {
|
switch (G_VALUE_TYPE (&value)) {
|
||||||
|
@ -675,7 +686,8 @@ _build_caps (const GstCaps * caps)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_add_element_pad_templates (GString * json, GstElement * element,
|
_add_element_pad_templates (GString * json, GString * other_types,
|
||||||
|
GHashTable * seen_other_types, GstElement * element,
|
||||||
GstElementFactory * factory)
|
GstElementFactory * factory)
|
||||||
{
|
{
|
||||||
gboolean opened = FALSE;
|
gboolean opened = FALSE;
|
||||||
|
@ -714,10 +726,16 @@ _add_element_pad_templates (GString * json, GstElement * element,
|
||||||
tmpl = gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (element),
|
tmpl = gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (element),
|
||||||
padtemplate->name_template);
|
padtemplate->name_template);
|
||||||
pad_type = GST_PAD_TEMPLATE_GTYPE (tmpl);
|
pad_type = GST_PAD_TEMPLATE_GTYPE (tmpl);
|
||||||
if (pad_type != G_TYPE_NONE && pad_type != GST_TYPE_PAD
|
if (pad_type != G_TYPE_NONE && pad_type != GST_TYPE_PAD) {
|
||||||
|
g_string_append_printf (json, ", \"type\": \"%s\"",
|
||||||
|
g_type_name (pad_type));
|
||||||
|
|
||||||
|
if (!g_hash_table_contains (seen_other_types, g_type_name (pad_type))
|
||||||
&& gst_type_is_plugin_api (pad_type)) {
|
&& gst_type_is_plugin_api (pad_type)) {
|
||||||
g_string_append_c (json, ',');
|
g_hash_table_insert (seen_other_types,
|
||||||
_serialize_object (json, "type", pad_type);
|
(gpointer) g_type_name (pad_type), NULL);
|
||||||
|
_serialize_object (other_types, seen_other_types, pad_type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
g_string_append_c (json, '}');
|
g_string_append_c (json, '}');
|
||||||
}
|
}
|
||||||
|
@ -777,7 +795,8 @@ _add_factory_details (GString * json, GstElementFactory * factory)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_add_object_details (GString * json, GObject * object)
|
_add_object_details (GString * json, GString * other_types,
|
||||||
|
GHashTable * seen_other_types, GObject * object)
|
||||||
{
|
{
|
||||||
GType type;
|
GType type;
|
||||||
GType *interfaces;
|
GType *interfaces;
|
||||||
|
@ -808,13 +827,14 @@ _add_object_details (GString * json, GObject * object)
|
||||||
g_free (interfaces);
|
g_free (interfaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
_add_properties (json, object, G_OBJECT_GET_CLASS (object));
|
_add_properties (json, other_types, seen_other_types, object,
|
||||||
_add_signals (json, object);
|
G_OBJECT_GET_CLASS (object));
|
||||||
|
_add_signals (json, other_types, seen_other_types, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_add_element_details (GString * json, GstPluginFeature * feature)
|
_add_element_details (GString * json, GString * other_types,
|
||||||
|
GHashTable * seen_other_types, GstPluginFeature * feature)
|
||||||
{
|
{
|
||||||
GstElement *element =
|
GstElement *element =
|
||||||
gst_element_factory_create (GST_ELEMENT_FACTORY (feature), NULL);
|
gst_element_factory_create (GST_ELEMENT_FACTORY (feature), NULL);
|
||||||
|
@ -829,9 +849,10 @@ _add_element_details (GString * json, GstPluginFeature * feature)
|
||||||
get_rank_name (s, gst_plugin_feature_get_rank (feature)));
|
get_rank_name (s, gst_plugin_feature_get_rank (feature)));
|
||||||
|
|
||||||
_add_factory_details (json, GST_ELEMENT_FACTORY (feature));
|
_add_factory_details (json, GST_ELEMENT_FACTORY (feature));
|
||||||
_add_object_details (json, G_OBJECT (element));
|
_add_object_details (json, other_types, seen_other_types, G_OBJECT (element));
|
||||||
|
|
||||||
_add_element_pad_templates (json, element, GST_ELEMENT_FACTORY (feature));
|
_add_element_pad_templates (json, other_types, seen_other_types, element,
|
||||||
|
GST_ELEMENT_FACTORY (feature));
|
||||||
|
|
||||||
g_string_append (json, "}");
|
g_string_append (json, "}");
|
||||||
}
|
}
|
||||||
|
@ -842,6 +863,8 @@ main (int argc, char *argv[])
|
||||||
gchar *libfile;
|
gchar *libfile;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GString *json;
|
GString *json;
|
||||||
|
GString *other_types;
|
||||||
|
GHashTable *seen_other_types;
|
||||||
GstPlugin *plugin;
|
GstPlugin *plugin;
|
||||||
gboolean f = TRUE;
|
gboolean f = TRUE;
|
||||||
GList *features, *tmp;
|
GList *features, *tmp;
|
||||||
|
@ -875,6 +898,9 @@ main (int argc, char *argv[])
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
other_types = g_string_new ("");
|
||||||
|
seen_other_types = g_hash_table_new (g_str_hash, g_str_equal);
|
||||||
|
|
||||||
basename = g_filename_display_basename (libfile);
|
basename = g_filename_display_basename (libfile);
|
||||||
splitext = g_strsplit (basename, ".", 2);
|
splitext = g_strsplit (basename, ".", 2);
|
||||||
filename =
|
filename =
|
||||||
|
@ -909,10 +935,11 @@ main (int argc, char *argv[])
|
||||||
if (GST_IS_ELEMENT_FACTORY (feature)) {
|
if (GST_IS_ELEMENT_FACTORY (feature)) {
|
||||||
if (!f)
|
if (!f)
|
||||||
g_string_append_printf (json, ",");
|
g_string_append_printf (json, ",");
|
||||||
_add_element_details (json, feature);
|
_add_element_details (json, other_types, seen_other_types, feature);
|
||||||
f = FALSE;
|
f = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_string_append (json, "}, \"tracers\": {");
|
g_string_append (json, "}, \"tracers\": {");
|
||||||
gst_plugin_feature_list_free (features);
|
gst_plugin_feature_list_free (features);
|
||||||
|
|
||||||
|
@ -930,8 +957,12 @@ main (int argc, char *argv[])
|
||||||
f = FALSE;
|
f = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_string_append (json, "}}");
|
g_string_append_printf (json, "}, \"other-types\": {%s}}",
|
||||||
|
other_types->str);
|
||||||
gst_plugin_feature_list_free (features);
|
gst_plugin_feature_list_free (features);
|
||||||
|
|
||||||
|
g_hash_table_unref (seen_other_types);
|
||||||
|
g_string_free (other_types, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_string_append_c (json, '}');
|
g_string_append_c (json, '}');
|
||||||
|
|
Loading…
Reference in a new issue