[glibmm] ActionGroup: Add the query_action() methods.
- From: Josà Alburquerque <jaalburqu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] ActionGroup: Add the query_action() methods.
- Date: Mon, 1 Oct 2012 03:20:18 +0000 (UTC)
commit d694160400455f2156f4b298c7f34bb1616ec894
Author: Josà Alburquerque <jaalburqu svn gnome org>
Date: Sun Sep 30 23:18:08 2012 -0400
ActionGroup: Add the query_action() methods.
* tools/m4/base.m4:
* tools/m4/convert_base.m4:
* tools/m4/filelist.am:
* tools/m4/initialize.m4:
* tools/m4/initialize_base.m4:
* tools/m4/initialize_gio.m4:
* tools/m4/initialize_glib.m4:
* tools/m4/initialize_glibmm.m4: Move the _INITIALIZE macros into
their own files as is done for the _CONVERT macros so that some basic
types that are common (like initializing a bool& from a gboolean) can
be defined once and used in other circumstances.
* gio/src/dbusconnection.hg: Move an _INITIALIZATION macro to the
general files above (the gio initialize file).
* gio/src/actiongroup.hg: Add the query_action() methods (the needed
_INITIALIZATION macros are in the glib initialize file).
* tools/pm/Output.pm (convert_args_cpp_to_c): Correct the indentation
of the declarations of the C output variables and the setting of the
C++ output parameters from the C variables for methods that use the
output parameter feature of gmmproc.
ChangeLog | 27 +++++++++++++++++++++
gio/src/actiongroup.hg | 3 ++
gio/src/dbusconnection.hg | 2 -
tools/m4/base.m4 | 6 +++++
tools/m4/convert_base.m4 | 23 ------------------
tools/m4/filelist.am | 5 ++++
tools/m4/initialize.m4 | 4 +++
tools/m4/initialize_base.m4 | 51 +++++++++++++++++++++++++++++++++++++++++
tools/m4/initialize_gio.m4 | 6 +++++
tools/m4/initialize_glib.m4 | 13 ++++++++++
tools/m4/initialize_glibmm.m4 | 6 +++++
tools/pm/Output.pm | 10 ++++----
12 files changed, 126 insertions(+), 30 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index cab17c1..55fddc7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,32 @@
2012-09-30 Josà Alburquerque <jaalburquerque gmail com>
+ ActionGroup: Add the query_action() methods.
+
+ * tools/m4/base.m4:
+ * tools/m4/convert_base.m4:
+ * tools/m4/filelist.am:
+ * tools/m4/initialize.m4:
+ * tools/m4/initialize_base.m4:
+ * tools/m4/initialize_gio.m4:
+ * tools/m4/initialize_glib.m4:
+ * tools/m4/initialize_glibmm.m4: Move the _INITIALIZE macros into
+ their own files as is done for the _CONVERT macros so that some basic
+ types that are common (like initializing a bool& from a gboolean) can
+ be defined once and used in other circumstances.
+
+ * gio/src/dbusconnection.hg: Move an _INITIALIZATION macro to the
+ general files above (the gio initialize file).
+
+ * gio/src/actiongroup.hg: Add the query_action() methods (the needed
+ _INITIALIZATION macros are in the glib initialize file).
+
+ * tools/pm/Output.pm (convert_args_cpp_to_c): Correct the indentation
+ of the declarations of the C output variables and the setting of the
+ C++ output parameters from the C variables for methods that use the
+ output parameter feature of gmmproc.
+
+2012-09-30 Josà Alburquerque <jaalburquerque gmail com>
+
RegEx: Add the get_has_cr_or_lf() method.
* glib/src/regex.hg:
diff --git a/gio/src/actiongroup.hg b/gio/src/actiongroup.hg
index 195af00..777fb86 100644
--- a/gio/src/actiongroup.hg
+++ b/gio/src/actiongroup.hg
@@ -33,6 +33,7 @@ namespace Glib
class VariantBase;
class VariantContainerBase;
+class VariantType;
}
@@ -65,6 +66,8 @@ public:
#m4 _CONVERSION(`gchar**',`std::vector<Glib::ustring>',`Glib::ArrayHandler<Glib::ustring>::array_to_vector($3, Glib::OWNERSHIP_DEEP)')
_WRAP_METHOD(std::vector<Glib::ustring> list_actions() const, g_action_group_list_actions)
+ _WRAP_METHOD(bool query_action(const Glib::ustring& action_name, bool& enabled{>>}, Glib::VariantType& parameter_type{>>?}, Glib::VariantBase& state_hint{.>>}, Glib::VariantType& state_type{.>>?}, Glib::VariantBase& state{.>>?}), g_action_group_query_action)
+
_WRAP_METHOD(bool get_action_enabled(const Glib::ustring& action_name) const, g_action_group_get_action_enabled)
_WRAP_METHOD(Glib::VariantType get_action_parameter_type(const Glib::ustring& action_name) const, g_action_group_get_action_parameter_type)
diff --git a/gio/src/dbusconnection.hg b/gio/src/dbusconnection.hg
index b903a79..4770b2a 100644
--- a/gio/src/dbusconnection.hg
+++ b/gio/src/dbusconnection.hg
@@ -782,8 +782,6 @@ public:
const Glib::VariantType& reply_type = Glib::VariantType());
#endif // G_OS_LINUX
-#m4 _INITIALIZATION(`Glib::RefPtr<UnixFDList>&',`GUnixFDList*', `$3 = Glib::wrap($4)')
-
/** Finishes an operation started with call() (with a UnixFDList).
* @param res A AsyncResult obtained from the SlotAsyncReady passed to
* call().
diff --git a/tools/m4/base.m4 b/tools/m4/base.m4
index b6b61e2..c846cfc 100644
--- a/tools/m4/base.m4
+++ b/tools/m4/base.m4
@@ -59,6 +59,12 @@ dnl
m4_include(convert.m4)
dnl
+dnl Initialization macros
+dnl
+
+m4_include(initialize.m4)
+
+dnl
dnl ----------------------- Utility Macros -------------------------
dnl
diff --git a/tools/m4/convert_base.m4 b/tools/m4/convert_base.m4
index ff00606..8d372fa 100644
--- a/tools/m4/convert_base.m4
+++ b/tools/m4/convert_base.m4
@@ -46,29 +46,6 @@ define(`_CONVERSION',`
m4_ifelse(`$3',,,`define(CF`'__HASH2(`$1',`$2'),`$3')')
')
-# _INITIALIZE(target_type, fromtype, output_param_name, c_return, wrap_line)
-#
-# Print an initialize statement from ctype to cpptype
-define(`_INITIALIZE',`dnl
-m4_ifelse(`$1',void,`$4',`dnl
-pushdef(`__INI',`IN`'__HASH2(`$1',`$2')')dnl
-m4_ifdef(__INI,`m4_indir(__INI,m4_substr(`$1',`0',m4_decr(m4_len(`$1'))),`$2',`$3', $4)',`
-m4_errprint(`No initialization for type $1 from type $2 defined (line: $5, output param: $3, c return: $4)
-')
-m4_m4exit(1)
-')`'dnl
-')`'dnl
-')
-
-# _INITIALIZATION(fromtype, totype, initialization)
-#
-# Functions for populating initialization tables.
-#
-define(`_INITIALIZATION',`
-m4_ifelse(`$3',,,`define(IN`'__HASH2(`$1',`$2'),m4_patsubst(`$3',`; +',`;
- '))')
-')
-
define(`_EQUAL',`define(EV`'__HASH(`$1'),`$2')')
/*******************************************************************/
diff --git a/tools/m4/filelist.am b/tools/m4/filelist.am
index 7dbbd78..04d0b01 100644
--- a/tools/m4/filelist.am
+++ b/tools/m4/filelist.am
@@ -20,6 +20,11 @@ files_codegen_m4 = \
doc.m4 \
enum.m4 \
gerror.m4 \
+ initialize.m4 \
+ initialize_base.m4 \
+ initialize_gio.m4 \
+ initialize_glib.m4 \
+ initialize_glibmm.m4 \
list.m4 \
member.m4 \
method.m4 \
diff --git a/tools/m4/initialize.m4 b/tools/m4/initialize.m4
new file mode 100644
index 0000000..0c41505
--- /dev/null
+++ b/tools/m4/initialize.m4
@@ -0,0 +1,4 @@
+dnl Other libraries, such as libgnomeuimm, can provide their own initialize.m4
+dnl files, maybe choosing to include the same files as this one.
+
+include(initialize_glibmm.m4)
diff --git a/tools/m4/initialize_base.m4 b/tools/m4/initialize_base.m4
new file mode 100644
index 0000000..138fe42
--- /dev/null
+++ b/tools/m4/initialize_base.m4
@@ -0,0 +1,51 @@
+dnl
+dnl Macros for keeping track of how to initialize a C++ from a C type.
+
+#
+# Define a hashing for names
+#
+define(`__HASH',`__`'m4_translit(`$*',`ABCDEFGHIJKLMNOPQRSTUVWXYZ<>[]&*, ',`abcdefghijklmnopqrstuvwxyzVBNMRSC_')`'')
+define(`__EQUIV',`m4_ifdef(EV`'__HASH(`$1'),EV`'__HASH(`$1'),`$1')')
+
+dnl __HASH2(firsttype, secondtype)
+dnl
+dnl Provides a textual combination of the two given types which can be used as
+dnl a hash to store and retrieve conversions and initializations. It first
+dnl sees if the two types have equivalent types that should be used in their
+dnl places (using the __EQUIV macro above). Since the types returned by
+dnl __EQUIV may contain commas (because of types such as std::map<>), quote the
+dnl call to the macro to avoid the types to be interpreted as more than one
+dnl argument to the pushdef() calls. Also quote the expansion of the __E1 and
+dnl __E2 macros in the m4_ifelse for the same reason.
+define(`__HASH2',`dnl
+pushdef(`__E1',`__EQUIV(`$1')')pushdef(`__E2',`__EQUIV(`$2')')dnl
+m4_ifelse(_QUOTE(__E1),_QUOTE(__E2),`__EQ',__HASH(__E1)`'__HASH(__E2))`'dnl
+popdef(`__E1')popdef(`__E2')`'')
+
+define(`IN__EQ',`$3')
+
+# _INITIALIZE(target_type, fromtype, output_param_name, c_return, wrap_line)
+#
+# Print an initialize statement from ctype to cpptype
+define(`_INITIALIZE',`dnl
+m4_ifelse(`$1',void,`$4',`dnl
+pushdef(`__INI',`IN`'__HASH2(`$1',`$2')')dnl
+m4_ifdef(__INI,`m4_indir(__INI,m4_substr(`$1',`0',m4_decr(m4_len(`$1'))),`$2',`$3', $4)',`
+m4_errprint(`No initialization for type $1 from type $2 defined (line: $5, output param: $3, c return: $4)
+')
+m4_m4exit(1)
+')`'dnl
+')`'dnl
+')
+
+# _INITIALIZATION(fromtype, totype, initialization)
+#
+# Functions for populating initialization tables.
+#
+define(`_INITIALIZATION',`
+m4_ifelse(`$3',,,`define(IN`'__HASH2(`$1',`$2'),m4_patsubst(`$3',`; +',`;
+ '))')
+')
+
+
+include(initialize_glib.m4)
diff --git a/tools/m4/initialize_gio.m4 b/tools/m4/initialize_gio.m4
new file mode 100644
index 0000000..fcfd145
--- /dev/null
+++ b/tools/m4/initialize_gio.m4
@@ -0,0 +1,6 @@
+dnl
+dnl Initializations for giomm C++ types from Gio C types.
+dnl
+
+dnl UnixFDList
+_INITIALIZATION(`Glib::RefPtr<UnixFDList>&',`GUnixFDList*', `$3 = Glib::wrap($4)')
diff --git a/tools/m4/initialize_glib.m4 b/tools/m4/initialize_glib.m4
new file mode 100644
index 0000000..649fde6
--- /dev/null
+++ b/tools/m4/initialize_glib.m4
@@ -0,0 +1,13 @@
+dnl
+dnl Initialization rules for glibmm C++ types from Glib C types.
+dnl
+
+dnl Basic Types
+_INITIALIZATION(`bool&',`gboolean',`$3 = static_cast<bool>($4)')
+
+
+dnl VariantBase
+_INITIALIZATION(`Glib::VariantBase&',`GVariant*',`$3 = Glib::wrap($4)')
+
+dnl VariantType
+_INITIALIZATION(`Glib::VariantType&',`const GVariantType*',`$3 = Glib::wrap(const_cast<GVariantType*>($4))')
diff --git a/tools/m4/initialize_glibmm.m4 b/tools/m4/initialize_glibmm.m4
new file mode 100644
index 0000000..a5fbecf
--- /dev/null
+++ b/tools/m4/initialize_glibmm.m4
@@ -0,0 +1,6 @@
+dnl $Id$
+
+include(initialize_base.m4)
+include(initialize_glib.m4)
+include(initialize_gio.m4)
+
diff --git a/tools/pm/Output.pm b/tools/pm/Output.pm
index bd8fb80..5312218 100644
--- a/tools/pm/Output.pm
+++ b/tools/pm/Output.pm
@@ -868,9 +868,9 @@ sub convert_args_cpp_to_c($$$$$)
my $c_param_types = $$objCDefsFunc{param_types};
my $c_param_names = $$objCDefsFunc{param_names};
- my @conversions;
- my @declarations;
- my @initializations;
+ my @conversions = ();
+ my @declarations = ();
+ my @initializations = ();
my $num_c_args_expected = scalar(@{$c_param_types});
if( !($static) ) { $num_c_args_expected--; } #The cpp method will need an Object* paramater at the start.
@@ -991,7 +991,7 @@ sub convert_args_cpp_to_c($$$$$)
push(@conversions, "&" . $cOutputParamName);
- push(@initializations, sprintf(" _INITIALIZE(\`%s\',%s,%s,%s,%s);",
+ push(@initializations, sprintf("_INITIALIZE(\`%s\',%s,%s,%s,%s);",
$cppParamType,
$cOutputParamType,
$cppParamName,
@@ -1016,7 +1016,7 @@ sub convert_args_cpp_to_c($$$$$)
}
}
- return ( join(", ", @conversions), join("\n ", @declarations),
+ return ( join(", ", @conversions), join("\n", @declarations),
join("\n ", @initializations) );
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]