[glibmm/gmmproc-refactor] Implement _CONSTRUCT macro.
- From: Krzesimir Nowak <krnowak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm/gmmproc-refactor] Implement _CONSTRUCT macro.
- Date: Thu, 28 Jun 2012 21:31:48 +0000 (UTC)
commit 5b4c3d1626c1f992c1db5606b9c248f599f7a354
Author: Krzesimir Nowak <qdlacz gmail com>
Date: Thu Jun 28 23:19:36 2012 +0200
Implement _CONSTRUCT macro.
Also added a new private static method to GObject wrappers needed
by _CONSTRUCT. That way I don't have to implement _CONSTRUCT_SPECIFIC
macro, but instead in future just deprecated it in favor of _CONSTRUCT.
tools/pm/Common/Output/Ctor.pm | 8 ++------
tools/pm/Common/Output/GObject.pm | 1 +
tools/pm/Common/Output/Interface.pm | 1 +
tools/pm/Common/WrapParser.pm | 27 +++++++++++++++++++++++++++
4 files changed, 31 insertions(+), 6 deletions(-)
---
diff --git a/tools/pm/Common/Output/Ctor.pm b/tools/pm/Common/Output/Ctor.pm
index d44f212..593136a 100644
--- a/tools/pm/Common/Output/Ctor.pm
+++ b/tools/pm/Common/Output/Ctor.pm
@@ -60,8 +60,6 @@ sub ctor_default ($)
my $main_section = $wrap_parser->get_main_section;
my $section_manager = $wrap_parser->get_section_manager;
my $full_cxx_type = Common::Output::Shared::get_full_cxx_type $wrap_parser;
- my $cxx_class_type = Common::Output::Shared::get_cxx_class_type $wrap_parser;
- my $base_member = (lc $cxx_class_type) . '_';
my $section = Common::Output::Shared::get_section $wrap_parser, Common::Sections::CC_NAMESPACE;
my $conditional = initially_unowned_sink $wrap_parser;
@@ -70,7 +68,7 @@ sub ctor_default ($)
(nl ':') .
(nl ' // Mark this class as non-derived to allow C++ vfuncs to be skipped.') .
(nl ' Glib::ObjectBase(0),') .
- (nl ' CppParentType(Glib::ConstructParams(', $base_member, '.init()))') .
+ (nl ' CppParentType(Glib::ConstructParams(get_static_cpp_class_type_instance().init()))') .
(nl '{');
# TODO: There is SECTION_CC_INITIALIZE_CLASS_EXTRA imported. Check if it is needed.
$section_manager->push_section ($section);
@@ -94,8 +92,6 @@ sub wrap_ctor ($$$$$$$)
(nl);
my $section = Common::Output::Shared::get_section $wrap_parser, Common::Sections::CC_NAMESPACE;
my $full_cxx_type = Common::Output::Shared::get_full_cxx_type $wrap_parser;
- my $cxx_class_type = Common::Output::Shared::get_cxx_class_type $wrap_parser;
- my $base_member = (lc $cxx_class_type) . '_';
my $conditional = initially_unowned_sink $wrap_parser;
my $type_info_local = $wrap_parser->get_type_info_local ();
my $ctor_params_str = join ', ', '', (map { join '', '"', $c_prop_names->[$_], '", ', ($type_info_local->get_conversion ($cxx_param_types->[$_], $c_param_types->[$_], $c_param_transfers->[$_], $cxx_param_names->[$_])) } 0 .. (@{$cxx_param_types} - 1)), 'static_cast<char*>(0)';
@@ -105,7 +101,7 @@ sub wrap_ctor ($$$$$$$)
(nl ':') .
(nl ' // Mark this class as non-derived to allow C++ vfuncs to be skipped.') .
(nl ' Glib::ObjectBase(0),') .
- (nl ' CppParentType(Glib::ConstructParams(', $base_member, '.init()', $ctor_params_str, '))') .
+ (nl ' CppParentType(Glib::ConstructParams(get_static_cpp_class_type_instance().init()', $ctor_params_str, '))') .
(nl '{');
# TODO: There is SECTION_CC_INITIALIZE_CLASS_EXTRA imported. Check if it is needed.
$section_manager->push_section ($section);
diff --git a/tools/pm/Common/Output/GObject.pm b/tools/pm/Common/Output/GObject.pm
index 2257537..3341868 100644
--- a/tools/pm/Common/Output/GObject.pm
+++ b/tools/pm/Common/Output/GObject.pm
@@ -85,6 +85,7 @@ sub _output_h_in_class ($$$$$$)
$code_string = nl (' friend class ' . $cxx_class_type . ';') .
nl (' static CppClassType ' . $base_member . ';') .
+ nl (' static CppClassType& get_static_cpp_class_type_instance() { return ' . $base_member . '; }') .
nl () .
nl ('private:') .
nl (' // noncopyable') .
diff --git a/tools/pm/Common/Output/Interface.pm b/tools/pm/Common/Output/Interface.pm
index 5855865..c17cdc4 100644
--- a/tools/pm/Common/Output/Interface.pm
+++ b/tools/pm/Common/Output/Interface.pm
@@ -72,6 +72,7 @@ sub _output_h_in_class ($$$$)
nl ('private:') .
nl (' friend class ' . $cxx_class_type . ';') .
nl (' static CppClassType ' . $base_member . ';') .
+ nl (' static CppClassType& get_static_cpp_class_type_instance() { return ' . $base_member . '; }') .
nl () .
nl (' // noncopyable') .
nl (Common::Output::Shared::copy_protos_str $cxx_type) .
diff --git a/tools/pm/Common/WrapParser.pm b/tools/pm/Common/WrapParser.pm
index 7f0a148..7533ad6 100644
--- a/tools/pm/Common/WrapParser.pm
+++ b/tools/pm/Common/WrapParser.pm
@@ -2863,6 +2863,32 @@ sub _on_config_include
$section);
}
+# TODO: move it to Ctor.pm
+sub _on_construct
+{
+ my ($self) = @_;
+ my @args = Common::Shared::string_split_commas ($self->_extract_bracketed_text ());
+ my $section = $self->get_main_section ();
+ my $section_manager = $self->get_section_manager ();
+ my $params = '';
+
+ if (@args)
+ {
+ my $param_str = join (', ', @args);
+
+ $params = join ('', ', ', $param_str, ', static_cast<char*>(0)');
+ }
+
+ my @lines =
+ (
+ '// Mark this class as non-derived to allow C++ vfuncs to be skipped.',
+ 'Glib::ObjectBase(0),',
+ join ('', 'CppParentType(Glib::ConstructParams(get_static_cpp_class_type_instance().init()', $params, ')')
+ );
+
+ $section_manager->append_string_to_section (join ("\n", @lines), $section);
+}
+
###
### HANDLERS ABOVE
###
@@ -3026,6 +3052,7 @@ sub new ($$$$$$)
# TODO: this should be an example of plugin handler.
'_UNICHAR_FUNC_BOOL' => sub { $self->_on_unichar_func_bool (@_); },
'_CONFIGINCLUDE' => sub { $self->_on_config_include (@_); },
+ '_CONSTRUCT' => sub { $self->_on_construct (@_); },
};
return $self;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]