[glibmm/gmmproc-refactor] Implement _MEMBER_* macros.
- From: Krzesimir Nowak <krnowak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm/gmmproc-refactor] Implement _MEMBER_* macros.
- Date: Thu, 28 Jun 2012 21:31:58 +0000 (UTC)
commit 5c86ceacc228150bd48da8f8bedae9a3a5fd4e70
Author: Krzesimir Nowak <qdlacz gmail com>
Date: Thu Jun 28 23:25:23 2012 +0200
Implement _MEMBER_* macros.
Also, deprecate _MEMBER_{GET,SET}_GOBJECT in favor of
_MEMBER_{GET,SET}_REF_PTR - this macro is not limited to only
GObject wrappers, but is generally for reffed members.
tools/pm/Common/Output.pm | 1 +
tools/pm/Common/Output/Member.pm | 262 ++++++++++++++++++++++++++++++++++++++
tools/pm/Common/WrapParser.pm | 102 +++++++++++++++
3 files changed, 365 insertions(+), 0 deletions(-)
---
diff --git a/tools/pm/Common/Output.pm b/tools/pm/Common/Output.pm
index 1678b95..eb79576 100644
--- a/tools/pm/Common/Output.pm
+++ b/tools/pm/Common/Output.pm
@@ -32,6 +32,7 @@ use Common::Output::GError;
use Common::Output::GObject;
use Common::Output::GtkObject;
use Common::Output::Interface;
+use Common::Output::Member;
use Common::Output::Method;
use Common::Output::Misc;
use Common::Output::OpaqueCopyable;
diff --git a/tools/pm/Common/Output/Member.pm b/tools/pm/Common/Output/Member.pm
new file mode 100644
index 0000000..857f382
--- /dev/null
+++ b/tools/pm/Common/Output/Member.pm
@@ -0,0 +1,262 @@
+# -*- mode: perl; perl-indent-level: 2; indent-tabs-mode: nil -*-
+# gmmproc - Common::Output::Member module
+#
+# Copyright 2012 glibmm development team
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+#
+
+package Common::Output::Member;
+
+use strict;
+use warnings;
+
+sub nl
+{
+ return Common::Output::Shared::nl @_;
+}
+
+sub output_get
+{
+ my ($wrap_parser, $cxx_name, $c_name, $cxx_type, $c_type, $deprecated) = @_;
+ my $section_manager = $wrap_parser->get_section_manager ();
+ my $main_section = $wrap_parser->get_main_section ();
+ my $cc_section = Common::Output::Shared::get_section ($wrap_parser, Common::Sections::CC_NAMESPACE);
+ my $type_info_local = $wrap_parser->get_type_info_local ();
+ my $main_code_string = '';
+ my $cc_code_string = '';
+ my $full_cxx_type = Common::Output::Shared::get_full_cxx_type ($wrap_parser);
+ my $conversion = $type_info_local->get_conversion ($c_type, $cxx_type, Common::TypeInfo::Common::TRANSFER_NONE, 'gobj()->' . $c_name);
+
+ if ($deprecated)
+ {
+ $main_code_string .= Common::Output::Shared::deprecate_start ($wrap_parser);
+ $cc_code_string .= Common::Output::Shared::deprecate_start ($wrap_parser);
+ }
+
+ $main_code_string .= nl (join ('', $cxx_type, ' get_', $cxx_name, '() const;'));
+ $cc_code_string .= nl (join ('', $cxx_type, ' ', $full_cxx_type, '::get_', $cxx_name, '() const')) .
+ nl ('{') .
+ nl (join ('', ' return ', $conversion, ';')) .
+ nl ('}') .
+ nl ();
+
+ if ($deprecated)
+ {
+ $main_code_string .= Common::Output::Shared::deprecate_end ($wrap_parser);
+ $cc_code_string .= Common::Output::Shared::deprecate_end ($wrap_parser);
+ }
+
+ $section_manager->append_string_to_section ($main_code_string, $main_section);
+ $section_manager->append_string_to_section ($cc_code_string, $cc_section);
+}
+
+sub output_get_ptr
+{
+ my ($wrap_parser, $cxx_name, $c_name, $cxx_type, $c_type, $deprecated) = @_;
+ my $section_manager = $wrap_parser->get_section_manager ();
+ my $main_section = $wrap_parser->get_main_section ();
+ my $cc_section = Common::Output::Shared::get_section ($wrap_parser, Common::Sections::CC_NAMESPACE);
+ my $type_info_local = $wrap_parser->get_type_info_local ();
+ my $main_code_string = '';
+ my $cc_code_string = '';
+ my $full_cxx_type = Common::Output::Shared::get_full_cxx_type ($wrap_parser);
+ my $conversion = $type_info_local->get_conversion ($c_type, $cxx_type, Common::TypeInfo::Common::TRANSFER_NONE, 'gobj()->' . $c_name);
+ my $const_conversion = $type_info_local->get_conversion ($c_type, 'const ' . $cxx_type, Common::TypeInfo::Common::TRANSFER_NONE, 'gobj()->' . $c_name);
+
+ if ($deprecated)
+ {
+ $main_code_string .= Common::Output::Shared::deprecate_start ($wrap_parser);
+ $cc_code_string .= Common::Output::Shared::deprecate_start ($wrap_parser);
+ }
+
+ $main_code_string .= nl (join ('', $cxx_type, ' get_', $cxx_name, '();')) .
+ nl (join ('', 'const ', $cxx_type, ' get_', $cxx_name, '() const;')) .
+ $cc_code_string .= nl (join ('', $cxx_type, ' ', $full_cxx_type, '::get_', $cxx_name, '()')) .
+ nl ('{') .
+ nl (join ('', ' return ', $conversion, ';')) .
+ nl ('}') .
+ nl () .
+ nl (join ('', 'const ', $cxx_type, ' ', $full_cxx_type, '::get_', $cxx_name, '() const')) .
+ nl ('{') .
+ nl (join ('', ' return ', $const_conversion, ';')) .
+ nl ('}') .
+ nl ();
+
+ if ($deprecated)
+ {
+ $main_code_string .= Common::Output::Shared::deprecate_end ($wrap_parser);
+ $cc_code_string .= Common::Output::Shared::deprecate_end ($wrap_parser);
+ }
+
+ $section_manager->append_string_to_section ($main_code_string, $main_section);
+ $section_manager->append_string_to_section ($cc_code_string, $cc_section);
+}
+
+sub output_get_ref_ptr
+{
+ my ($wrap_parser, $cxx_name, $c_name, $cxx_type, $c_type, $deprecated) = @_;
+ my $section_manager = $wrap_parser->get_section_manager ();
+ my $main_section = $wrap_parser->get_main_section ();
+ my $cc_section = Common::Output::Shared::get_section ($wrap_parser, Common::Sections::CC_NAMESPACE);
+ my $type_info_local = $wrap_parser->get_type_info_local ();
+ my $main_code_string = '';
+ my $cc_code_string = '';
+ my $full_cxx_type = Common::Output::Shared::get_full_cxx_type ($wrap_parser);
+ my $reffed_cxx_type = 'Glib::RefPtr< ' . $cxx_type . '>';
+ my $reffed_const_cxx_type = 'Glib::RefPtr< const ' . $cxx_type . '>';
+ my $conversion = $type_info_local->get_conversion ($c_type, $reffed_cxx_type, Common::TypeInfo::Common::TRANSFER_NONE, 'gobj()->' . $c_name);
+ my $const_conversion = $type_info_local->get_conversion ($c_type, $reffed_const_cxx_type, Common::TypeInfo::Common::TRANSFER_NONE, 'gobj()->' . $c_name);
+
+ if ($deprecated)
+ {
+ $main_code_string .= Common::Output::Shared::deprecate_start ($wrap_parser);
+ $cc_code_string .= Common::Output::Shared::deprecate_start ($wrap_parser);
+ }
+
+ $main_code_string .= nl (join ('', $reffed_cxx_type, ' get_', $cxx_name, '();')) .
+ nl (join ('', $reffed_const_cxx_type, ' get_', $cxx_name, '() const;')) .
+ $cc_code_string .= nl (join ('', $cxx_type, ' ', $full_cxx_type, '::get_', $cxx_name, '()')) .
+ nl ('{') .
+ nl (join ('', ' return ', $conversion, ';')) .
+ nl ('}') .
+ nl () .
+ nl (join ('', $reffed_const_cxx_type, ' ', $full_cxx_type, '::get_', $cxx_name, '() const')) .
+ nl ('{') .
+ nl (join ('', ' return ', $const_conversion, ';')) .
+ nl ('}') .
+ nl ();
+
+ if ($deprecated)
+ {
+ $main_code_string .= Common::Output::Shared::deprecate_end ($wrap_parser);
+ $cc_code_string .= Common::Output::Shared::deprecate_end ($wrap_parser);
+ }
+
+ $section_manager->append_string_to_section ($main_code_string, $main_section);
+ $section_manager->append_string_to_section ($cc_code_string, $cc_section);
+}
+
+sub output_set
+{
+ my ($wrap_parser, $cxx_name, $c_name, $cxx_type, $c_type, $deprecated) = @_;
+ my $section_manager = $wrap_parser->get_section_manager ();
+ my $main_section = $wrap_parser->get_main_section ();
+ my $cc_section = Common::Output::Shared::get_section ($wrap_parser, Common::Sections::CC_NAMESPACE);
+ my $type_info_local = $wrap_parser->get_type_info_local ();
+ my $main_code_string = '';
+ my $cc_code_string = '';
+ my $full_cxx_type = Common::Output::Shared::get_full_cxx_type ($wrap_parser);
+ my $conversion = $type_info_local->get_conversion ($cxx_type, $c_type, Common::TypeInfo::Common::TRANSFER_NONE, 'value');
+
+ if ($deprecated)
+ {
+ $main_code_string .= Common::Output::Shared::deprecate_start ($wrap_parser);
+ $cc_code_string .= Common::Output::Shared::deprecate_start ($wrap_parser);
+ }
+
+ $main_code_string .= nl (join ('', 'void set_', $cxx_name, '(const ', $cxx_type, '& value);'));
+ $cc_code_string .= nl (join ('', 'void ', $full_cxx_type, '::set_', $cxx_name, '(const ', $cxx_type, '& value)')) .
+ nl ('{') .
+ nl (join ('', ' gobj->', $c_name, ' = ', $conversion, ';')) .
+ nl ('}') .
+ nl ();
+
+ if ($deprecated)
+ {
+ $main_code_string .= Common::Output::Shared::deprecate_end ($wrap_parser);
+ $cc_code_string .= Common::Output::Shared::deprecate_end ($wrap_parser);
+ }
+
+ $section_manager->append_string_to_section ($main_code_string, $main_section);
+ $section_manager->append_string_to_section ($cc_code_string, $cc_section);
+}
+
+sub output_set_ptr
+{
+ my ($wrap_parser, $cxx_name, $c_name, $cxx_type, $c_type, $deprecated) = @_;
+ my $section_manager = $wrap_parser->get_section_manager ();
+ my $main_section = $wrap_parser->get_main_section ();
+ my $cc_section = Common::Output::Shared::get_section ($wrap_parser, Common::Sections::CC_NAMESPACE);
+ my $type_info_local = $wrap_parser->get_type_info_local ();
+ my $main_code_string = '';
+ my $cc_code_string = '';
+ my $full_cxx_type = Common::Output::Shared::get_full_cxx_type ($wrap_parser);
+ my $conversion = $type_info_local->get_conversion ($cxx_type, $c_type, Common::TypeInfo::Common::TRANSFER_NONE, 'value');
+
+ if ($deprecated)
+ {
+ $main_code_string .= Common::Output::Shared::deprecate_start ($wrap_parser);
+ $cc_code_string .= Common::Output::Shared::deprecate_start ($wrap_parser);
+ }
+
+ $main_code_string .= nl (join ('', 'void set_', $cxx_name, '(const ', $cxx_type, ' value);'));
+ $cc_code_string .= nl (join ('', 'void ', $full_cxx_type, '::set_', $cxx_name, '(const ', $cxx_type, ' value)')) .
+ nl ('{') .
+ nl (join ('', ' gobj->', $c_name, ' = ', $conversion, ';')) .
+ nl ('}') .
+ nl ();
+
+ if ($deprecated)
+ {
+ $main_code_string .= Common::Output::Shared::deprecate_end ($wrap_parser);
+ $cc_code_string .= Common::Output::Shared::deprecate_end ($wrap_parser);
+ }
+
+ $section_manager->append_string_to_section ($main_code_string, $main_section);
+ $section_manager->append_string_to_section ($cc_code_string, $cc_section);
+}
+
+sub output_set_ref_ptr
+{
+ my ($wrap_parser, $cxx_name, $c_name, $cxx_type, $c_type, $deprecated) = @_;
+ my $section_manager = $wrap_parser->get_section_manager ();
+ my $main_section = $wrap_parser->get_main_section ();
+ my $cc_section = Common::Output::Shared::get_section ($wrap_parser, Common::Sections::CC_NAMESPACE);
+ my $type_info_local = $wrap_parser->get_type_info_local ();
+ my $main_code_string = '';
+ my $cc_code_string = '';
+ my $full_cxx_type = Common::Output::Shared::get_full_cxx_type ($wrap_parser);
+ my $ref_cxx_type = join ('', 'Glib::RefPtr< ', $cxx_type, ' >');
+ my $conversion = $type_info_local->get_conversion ($ref_cxx_type, $c_type, Common::TypeInfo::Common::TRANSFER_NONE, 'value');
+ my $old_conversion = $type_info_local->get_conversion ($c_type, $ref_cxx_type, Common::TypeInfo::TRANSFER_FULL, 'gobj->' . $c_name);
+
+ if ($deprecated)
+ {
+ $main_code_string .= Common::Output::Shared::deprecate_start ($wrap_parser);
+ $cc_code_string .= Common::Output::Shared::deprecate_start ($wrap_parser);
+ }
+
+ $main_code_string .= nl (join ('', 'void set_', $cxx_name, '(const ', $ref_cxx_type, '& value);'));
+ $cc_code_string .= nl (join ('', 'void ', $full_cxx_type, '::set_', $cxx_name, '(const ', $ref_cxx_type, '& value)')) .
+ nl ('{') .
+ nl (' // Take possession of the old value, unrefing it in the destructor.') .
+ nl (join ('', ' ', $ref_cxx_type, ' old_value(', $old_conversion, ');')) .
+ nl () .
+ nl (join ('', ' gobj->', $c_name, ' = ', $conversion, ';')) .
+ nl ('}') .
+ nl ();
+
+ if ($deprecated)
+ {
+ $main_code_string .= Common::Output::Shared::deprecate_end ($wrap_parser);
+ $cc_code_string .= Common::Output::Shared::deprecate_end ($wrap_parser);
+ }
+
+ $section_manager->append_string_to_section ($main_code_string, $main_section);
+ $section_manager->append_string_to_section ($cc_code_string, $cc_section);
+}
+
+1; # indicate proper module load.
diff --git a/tools/pm/Common/WrapParser.pm b/tools/pm/Common/WrapParser.pm
index 036c678..a37e836 100644
--- a/tools/pm/Common/WrapParser.pm
+++ b/tools/pm/Common/WrapParser.pm
@@ -2912,6 +2912,100 @@ sub _deprecate_ifdef_end
Common::Output::Shared::deprecate_end ($self);
}
+sub _on_member_set
+{
+ my ($self) = @_;
+ my @args = Common::Shared::string_split_commas ($self->_extract_bracketed_text ());
+
+ if (@args != 4)
+ {
+ $self->fixed_error ('Wrong number of parameters');
+ }
+
+ Common::Output::Member::output_set ($self, @args);
+}
+
+sub _on_member_set_ptr
+{
+ my ($self) = @_;
+ my @args = Common::Shared::string_split_commas ($self->_extract_bracketed_text ());
+
+ if (@args != 4)
+ {
+ $self->fixed_error ('Wrong number of parameters');
+ }
+
+ Common::Output::Member::output_set_ptr ($self, @args);
+}
+
+sub _on_member_set_gobject
+{
+ my ($self) = @_;
+
+ $self->fixed_warning ('This macro is deprecated, please use _MEMBER_SET_REF_PTR');
+ $self->on_member_set_ref_ptr ();
+}
+
+sub _on_member_set_ref_ptr
+{
+ my ($self) = @_;
+ my @args = Common::Shared::string_split_commas ($self->_extract_bracketed_text ());
+
+ if (@args != 4)
+ {
+ $self->fixed_error ('Wrong number of parameters');
+ }
+
+ Common::Output::Member::output_set_ref_ptr ($self, @args);
+}
+
+sub _on_member_get
+{
+ my ($self) = @_;
+ my @args = Common::Shared::string_split_commas ($self->_extract_bracketed_text ());
+
+ if (@args != 4)
+ {
+ $self->fixed_error ('Wrong number of parameters');
+ }
+
+ Common::Output::Member::output_get ($self, @args);
+}
+
+sub _on_member_get_ptr
+{
+ my ($self) = @_;
+ my @args = Common::Shared::string_split_commas ($self->_extract_bracketed_text ());
+
+ if (@args != 4)
+ {
+ $self->fixed_error ('Wrong number of parameters');
+ }
+
+ Common::Output::Member::output_get_ptr ($self, @args);
+}
+
+sub _on_member_get_gobject
+{
+ my ($self) = @_;
+
+ $self->fixed_warning ('This macro is deprecated, please use _MEMBER_GET_REF_PTR');
+ $self->_on_member_get_ref_ptr ();
+}
+
+sub _on_member_get_ref_ptr
+{
+ my ($self) = @_;
+ my @args = Common::Shared::string_split_commas ($self->_extract_bracketed_text ());
+
+ if (@args != 4)
+ {
+ $self->fixed_error ('Wrong number of parameters');
+ }
+
+ Common::Output::Member::output_get_ref_ptr ($self, @args);
+}
+
###
### HANDLERS ABOVE
###
@@ -3079,6 +3173,14 @@ sub new ($$$$$$)
'_CUSTOM_DEFAULT_CTOR' => sub { $self->_on_custom_default_ctor (@_); },
'_DEPRECATE_IFDEF_START' => sub { $self->_on_deprecate_ifdef_start (@_); },
'_DEPRECATE_IFDEF_END' => sub { $self->_on_deprecate_ifdef_end (@_); },
+ '_MEMBER_SET' => sub { $self->_on_member_set (@_); },
+ '_MEMBER_SET_PTR' => sub { $self->_on_member_set_ptr (@_); },
+ '_MEMBER_SET_GOBJECT' => sub { $self->_on_member_set_gobject (@_); },
+ '_MEMBER_SET_REF_PTR' => sub { $self->_on_member_set_ref_ptr (@_); },
+ '_MEMBER_GET' => sub { $self->_on_member_get (@_); },
+ '_MEMBER_GET_PTR' => sub { $self->_on_member_get_ptr (@_); },
+ '_MEMBER_GET_GOBJECT' => sub { $self->_on_member_get_gobject (@_); },
+ '_MEMBER_GET_REF_PTR' => sub { $self->_on_member_get_ref_ptr (@_); },
};
return $self;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]