[gstreamermm] Moved wrapped enum sensing code out of plug-in generator to m4 files.
- From: José Alburquerque <jaalburqu src gnome org>
- To: svn-commits-list gnome org
- Subject: [gstreamermm] Moved wrapped enum sensing code out of plug-in generator to m4 files.
- Date: Mon, 29 Jun 2009 01:42:38 +0000 (UTC)
commit 2ca8fa62d2a8298b94b281f638c4f88b63e1e467
Author: José Alburquerque <jaalburqu svn gnome org>
Date: Sun Jun 28 21:17:43 2009 -0400
Moved wrapped enum sensing code out of plug-in generator to m4 files.
ChangeLog | 10 ++
build_shared/Makefile_gensrc.am_fragment | 2 +-
.../extra_defs_gen/generate_plugin_gmmproc_file.cc | 85 ++-----------------
tools/m4/ctocpp_base.m4 | 89 ++++++++++++++++++++
4 files changed, 107 insertions(+), 79 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e79a691..ecd1f67 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-06-28 José Alburquerque <jaalburqu svn gnome org>
+
+ * tools/extra_defs_gen/generate_plugin_gmmproc_file.cc:
+ * tools/m4/ctocpp_base.m4:
+ * build_shared/Makefile_gensrc.am_fragment: Moved wrapped enum sensing
+ code out of plug-in generator to m4 files so that other gstreamermm
+ modules can define their own wrapped enums. This makes the plug-in
+ generation slightly slower but the benefit of letting other modules
+ define which enums are already wrapped is gained.
+
2009-06-25 José Alburquerque <jaalburqu svn gnome org>
* configure.ac:
diff --git a/build_shared/Makefile_gensrc.am_fragment b/build_shared/Makefile_gensrc.am_fragment
index 0aa6f96..c0a34d6 100644
--- a/build_shared/Makefile_gensrc.am_fragment
+++ b/build_shared/Makefile_gensrc.am_fragment
@@ -109,7 +109,7 @@ $(files_all_plugin_ccg): $(generate_plugin_dep) $(tools_plugin_m4) \
$(eval cppname = $$(subst $$(plugin_name)=,,$$(plugin_def)))
sed -n '1,/^$$/p' $(license_header_source_file) > $(srcdir)/$@
$(run_generate_plugin_gmmproc_file) --ccg $(plugin_name) \
- $(cppname) >> $(srcdir)/$@
+ $(cppname) | $(M4) -I $(tools_dir_m4) >> $(srcdir)/$@
$(stamp_dir)/stamp-%: %.hg %.ccg $(tools_m4) $(files_defs)
$(run_gmmproc) $(notdir $*) $(srcdir) $(gensrc_destdir)
diff --git a/tools/extra_defs_gen/generate_plugin_gmmproc_file.cc b/tools/extra_defs_gen/generate_plugin_gmmproc_file.cc
index dd39a02..fefb596 100644
--- a/tools/extra_defs_gen/generate_plugin_gmmproc_file.cc
+++ b/tools/extra_defs_gen/generate_plugin_gmmproc_file.cc
@@ -38,56 +38,6 @@ static Glib::ustring parentNameSpace;
GType type = 0;
-// To add an enum that is already wrapped to the list of wrapped enum, add
-// alphabetically below and increment WRAPPED_ENUMS_SIZE.
-static const int WRAPPED_ENUMS_SIZE = 43;
-static const char* wrappedEnums[WRAPPED_ENUMS_SIZE] =
-{
- "GstActivateMode",
- "GstAssocFlags",
- "GstAutoplugSelectResult",
- "GstBufferCopyFlags",
- "GstBufferFlag",
- "GstBufferingMode",
- "GstBusFlags",
- "GstBusSyncReply",
- "GstClockEntryType",
- "GstClockFlags",
- "GstClockReturn",
- "GstColorBalanceType",
- "GstElementFlags",
- "GstEventType",
- "GstEventTypeFlags",
- "GstFlowReturn",
- "GstFormat",
- "GstIndexCertainty",
- "GstIndexEntryType",
- "GstIndexFlags",
- "GstIndexLookupMethod",
- "GstIndexResolverMethod",
- "GstIteratorItem",
- "GstIteratorResult",
- "GstMessageType",
- "GstMiniObjectFlags",
- "GstPadDirection",
- "GstPadFlags",
- "GstPadLinkReturn",
- "GstPadPresence",
- "GstPadTemplateFlags",
- "GstQueryType",
- "GstRank",
- "GstSeekFlags",
- "GstSeekType",
- "GstState",
- "GstStateChange",
- "GstStateChangeReturn",
- "GstTagFlag",
- "GstTagMergeMode",
- "GstTaskState",
- "GstTCPProtocol",
- "GstURIType"
-};
-
// To add a base class that is already wrapped to the list of wrapped base
// classes, add alphabetically below and increment WRAPPED_BASE_CLASSES_SIZE.
static const int WRAPPED_BASE_CLASSES_SIZE = 14;
@@ -158,18 +108,6 @@ Glib::ustring get_cast_macro(const Glib::ustring& typeName)
return result;
}
-bool is_wrapped_enum(const Glib::ustring& cTypeName)
-{
- for(int i = 0; i < WRAPPED_ENUMS_SIZE &&
- cTypeName.compare(wrappedEnums[i]) >= 0; i++)
- {
- if(cTypeName.compare(wrappedEnums[i]) == 0)
- return true;
- }
-
- return false;
-}
-
bool is_wrapped_base_class(const Glib::ustring& cTypeName)
{
for(int i = 0; i < WRAPPED_BASE_CLASSES_SIZE &&
@@ -240,35 +178,24 @@ Glib::ustring get_property_wrap_statements(Glib::ustring& includeMacroCalls,
Glib::ustring propertyCType = g_type_name(propertyGType) +
(Glib::ustring) (gst_type_is_a_pointer(propertyGType) ? "*" : "");
- bool enumIsWrapped = false;
-
- if((G_TYPE_IS_ENUM(propertyGType) || G_TYPE_IS_FLAGS(propertyGType)) &&
- !(enumIsWrapped = is_wrapped_enum(propertyCType)))
+ if((G_TYPE_IS_ENUM(propertyGType) || G_TYPE_IS_FLAGS(propertyGType)))
{
Glib::ustring propertyCppType = propertyCType.substr(3);
- enumWrapStatements += "_WRAP_ENUM(" + propertyCType.substr(3) + ", " +
- propertyCType + ")\n";
- enumWrapStatements += "_TRANSLATION(`" + propertyCType + "',`" +
- propertyCppType + "',`" + propertyCppType + "')dnl\n";
+ enumWrapStatements += "_WRAP_PLUGIN_ENUM(" + propertyCppType +
+ ", " + propertyCType + ")\n";
Glib::ustring enumGetTypeFunctionName =
get_cast_macro(propertyCType).lowercase() + "_get_type";
enumGTypeFunctionDefinitions +=
- "static GType " + enumGetTypeFunctionName + "()\n" +
- "{\n" +
- " static GType const type = g_type_from_name(\"" +
- propertyCType + "\");\n" +
- " return type;\n" +
- "}\n\n";
+ "_PLUGIN_ENUM_GET_TYPE_FUNC(" + propertyCType + ")";
}
wrapStatements += " _WRAP_PROPERTY(\"" + propertyName + "\", " +
"_TRANSLATE(" + propertyCType + ", `return'))\n";
- if(!G_TYPE_IS_ENUM(propertyGType) || enumIsWrapped)
- includeMacroCalls += "_TRANSLATION_INCLUDE(" + propertyCType + ")dnl\n";
+ includeMacroCalls += "_TRANSLATION_INCLUDE(" + propertyCType + ")dnl\n";
}
}
}
@@ -572,6 +499,8 @@ void generate_hg_file(const Glib::ustring& includeMacroCalls,
void generate_ccg_file(const Glib::ustring& enumGTypeFunctionDefinitions,
const Glib::ustring& cClassSignalDeclarations)
{
+ std::cout << "include(ctocpp_base.m4)dnl" << std::endl;
+ std::cout << "changecom()dnl" << std::endl;
std::cout << "_PINCLUDE(" << parentInclude << "/private/" <<
cppParentTypeName.lowercase() << "_p.h)" << std::endl << std::endl;
diff --git a/tools/m4/ctocpp_base.m4 b/tools/m4/ctocpp_base.m4
index d7c163e..ca4678c 100644
--- a/tools/m4/ctocpp_base.m4
+++ b/tools/m4/ctocpp_base.m4
@@ -6,6 +6,11 @@ dnl
dnl __HASH variable borrowed form glibmm's convert_base.m4 file
define(`__HASH',`__`'translit(`$*',`ABCDEFGHIJKLMNOPQRSTUVWXYZ<>[]&*, ',`abcdefghijklmnopqrstuvwxyzVBNMRSC_')`'')
+dnl _GET_TYPE_FUNC(GtkWidget) -> gtk_widget_get_type(). Borrowed from glibmm's convert_base.m4 file (see glibmm's m4 file for docs).
+define(`_GET_TYPE_FUNC',`dnl
+translit(substr(patsubst(patsubst(`$1',`[A-Z][A-Z]+',`_\&'),`[A-Z][a-z]',`_\&'),1),`[A-Z]',`[a-z]')_get_type()`'dnl
+')
+
dnl Macro to insert left quote
define(`_LQ',`changequote(<,>)`dnl'
changequote`'')
@@ -82,6 +87,45 @@ m4exit(1)`'dnl
')`'dnl
')dnl
+dnl _ENUM_IS_WRAPPED(CEnumType)
+dnl
+dnl Used to tell when an enum has been wrapped. When a _WRAP_PLUGIN_ENUM() is
+dnl used to wrap enums used in plug-ins, the enum will be wrapped only if it
+dnl hasn't been flagged as wrapped by this macro.
+dnl
+define(`_ENUM_IS_WRAPPED',`dnl
+define(`EIW'__HASH(`$1'))dnl
+')dnl
+
+dnl _WRAP_PLUGIN_ENUM(CppEnumType, CEnumType)
+dnl
+dnl Attempts to generate a _WRAP_ENUM() and a _TRANSLATION() macro for an enum
+dnl used by a plug-in. If the enum has been flagged as wrapped by the
+dnl _ENUM_IS_WRAPPED() macro nothing will be generated.
+define(`_WRAP_PLUGIN_ENUM',`dnl
+ifdef(`EIW'__HASH(`$2'),,`dnl
+_WRAP_ENUM($1,$2)dnl
+_TRANSLATION(`$2',`$1',`$1')dnl
+')`'dnl
+')dnl
+
+dnl _PLUGIN_ENUM_GET_TYPE_FUNC(CEnumType)
+dnl
+dnl Attempts to generate a *_get_type() function for an enum specific to a
+dnl plug-in. If the enum has been flagged as wrapped by the
+dnl _ENUM_IS_WRAPPED() macro it is taken taken to be a non-plugin enum and
+dnl nothing will be generated.
+define(`_PLUGIN_ENUM_GET_TYPE_FUNC',`dnl
+ifdef(`EIW'__HASH(`$1'),,`dnl
+static GType _GET_TYPE_FUNC($1)
+{
+ static GType const type = g_type_from_name("$1");
+ return type;
+}
+
+')`'dnl
+')dnl
+
#Basic C to C++ translations
_TRANSLATION(`void',`void',`void')
_TRANSLATION(`gboolean',`bool',`bool')
@@ -96,5 +140,50 @@ _TRANSLATION(`gdouble',`double',`double')
#String C to C++ translations
_TRANSLATION(`gchararray',`Glib::ustring',`const Glib::ustring&',`Glib::ustring')
+#Wrapped enums
+_ENUM_IS_WRAPPED(GstActivateMode)
+_ENUM_IS_WRAPPED(GstAssocFlags)
+_ENUM_IS_WRAPPED(GstAutoplugSelectResult)
+_ENUM_IS_WRAPPED(GstBufferCopyFlags)
+_ENUM_IS_WRAPPED(GstBufferFlag)
+_ENUM_IS_WRAPPED(GstBufferingMode)
+_ENUM_IS_WRAPPED(GstBusFlags)
+_ENUM_IS_WRAPPED(GstBusSyncReply)
+_ENUM_IS_WRAPPED(GstClockEntryType)
+_ENUM_IS_WRAPPED(GstClockFlags)
+_ENUM_IS_WRAPPED(GstClockReturn)
+_ENUM_IS_WRAPPED(GstColorBalanceType)
+_ENUM_IS_WRAPPED(GstElementFlags)
+_ENUM_IS_WRAPPED(GstEventType)
+_ENUM_IS_WRAPPED(GstEventTypeFlags)
+_ENUM_IS_WRAPPED(GstFlowReturn)
+_ENUM_IS_WRAPPED(GstFormat)
+_ENUM_IS_WRAPPED(GstIndexCertainty)
+_ENUM_IS_WRAPPED(GstIndexEntryType)
+_ENUM_IS_WRAPPED(GstIndexFlags)
+_ENUM_IS_WRAPPED(GstIndexLookupMethod)
+_ENUM_IS_WRAPPED(GstIndexResolverMethod)
+_ENUM_IS_WRAPPED(GstIteratorItem)
+_ENUM_IS_WRAPPED(GstIteratorResult)
+_ENUM_IS_WRAPPED(GstMessageType)
+_ENUM_IS_WRAPPED(GstMiniObjectFlags)
+_ENUM_IS_WRAPPED(GstPadDirection)
+_ENUM_IS_WRAPPED(GstPadFlags)
+_ENUM_IS_WRAPPED(GstPadLinkReturn)
+_ENUM_IS_WRAPPED(GstPadPresence)
+_ENUM_IS_WRAPPED(GstPadTemplateFlags)
+_ENUM_IS_WRAPPED(GstQueryType)
+_ENUM_IS_WRAPPED(GstRank)
+_ENUM_IS_WRAPPED(GstSeekFlags)
+_ENUM_IS_WRAPPED(GstSeekType)
+_ENUM_IS_WRAPPED(GstState)
+_ENUM_IS_WRAPPED(GstStateChange)
+_ENUM_IS_WRAPPED(GstStateChangeReturn)
+_ENUM_IS_WRAPPED(GstTagFlag)
+_ENUM_IS_WRAPPED(GstTagMergeMode)
+_ENUM_IS_WRAPPED(GstTaskState)
+_ENUM_IS_WRAPPED(GstTCPProtocol)
+_ENUM_IS_WRAPPED(GstURIType)
+
include(ctocpp.m4)
divert(0)dnl
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]