[glibmm/gmmproc-refactor] Add _CUSTOM_CTOR_CAST for BoxedType and OpaqueCopyable outputs.
- From: Krzesimir Nowak <krnowak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm/gmmproc-refactor] Add _CUSTOM_CTOR_CAST for BoxedType and OpaqueCopyable outputs.
- Date: Sun, 22 Jul 2012 18:18:02 +0000 (UTC)
commit 7b18479ac18f2def21e1ed5c437249cf0d9dcac8
Author: Krzesimir Nowak <qdlacz gmail com>
Date: Sun Jul 22 19:55:13 2012 +0200
Add _CUSTOM_CTOR_CAST for BoxedType and OpaqueCopyable outputs.
tools/pm/Common/Output/BoxedType.pm | 30 +++++++++++++++++++------
tools/pm/Common/Output/OpaqueCopyable.pm | 35 +++++++++++++++++++++--------
tools/pm/Common/WrapParser.pm | 12 +++++++++-
3 files changed, 59 insertions(+), 18 deletions(-)
---
diff --git a/tools/pm/Common/Output/BoxedType.pm b/tools/pm/Common/Output/BoxedType.pm
index 25504a6..5febe1e 100644
--- a/tools/pm/Common/Output/BoxedType.pm
+++ b/tools/pm/Common/Output/BoxedType.pm
@@ -68,9 +68,18 @@ sub _output_h_in_class
my $virtual_dtor = 0;
$section_manager->append_conditional ($conditional);
+ $section_manager->append_string (nl ());
+
+ my $variable = Common::Output::Shared::get_variable ($wrap_parser, Common::Variables::CUSTOM_CTOR_CAST);
+
+ $conditional = Common::Output::Shared::generate_conditional ($wrap_parser);
+ $code_string = nl ('explicit ' . $cxx_type . '(' . $c_type . '* gobject, bool make_a_copy = true);') .
+ nl ();
+ $section_manager->append_string_to_conditional ($code_string, $conditional, 0);
+ $section_manager->append_conditional ($conditional);
+ $section_manager->set_variable_for_conditional ($variable, $conditional);
+
$code_string = nl () .
- nl ('explicit ' . $cxx_type . '(' . $c_type . '* gobject, bool make_a_copy = true);') .
- nl () .
nl (Common::Output::Shared::copy_protos_str $cxx_type) .
nl () .
nl (Common::Output::Shared::dtor_proto_str $cxx_type, $virtual_dtor) .
@@ -181,16 +190,23 @@ sub _output_cc
nl (':') .
nl (' gobject_ ((other.gobject_) ? ' . $copy_func . '(other.gobject_) : 0)') .
nl ('{}') .
- nl () .
- nl ($cxx_type . '::' . $cxx_type . '(' . $c_type . '* gobject, bool make_a_copy)') .
+ nl ();
+ $section_manager->append_string ($code_string);
+ $code_string = nl ($cxx_type . '::' . $cxx_type . '(' . $c_type . '* gobject, bool make_a_copy)') .
nl (':') .
nl ('// For BoxedType wrappers, make_a_copy is true by default. The static') .
- nl ('// BoxedTyoe wrappers always take a copy, thus make_a_copy = true') .
+ nl ('// BoxedType wrappers always take a copy, thus make_a_copy = true') .
nl ('// ensures identical behaviour if the default argument is used.') .
nl (' gobject_ ((make_a_copy && gobject) ? ' . $copy_func . '(gobject) : gobject)') .
nl ('{}') .
- nl () .
- nl ($cxx_type . '& ' . $cxx_type . '::operator=(const ' . $cxx_type . '& other)') .
+ nl ();
+
+ $conditional = Common::Output::Shared::generate_conditional ($wrap_parser);
+ $variable = Common::Output::Shared::get_variable ($wrap_parser, Common::Variables::CUSTOM_CTOR_CAST);
+ $section_manager->append_string_to_conditional ($code_string, $conditional, 0);
+ $section_manager->append_conditional ($conditional);
+ $section_manager->set_variable_for_conditional ($variable, $conditional);
+ $code_string = nl ($cxx_type . '& ' . $cxx_type . '::operator=(const ' . $cxx_type . '& other)') .
nl ('{') .
nl (' ' . $cxx_type . ' temp (other);') .
nl (' swap(temp);') .
diff --git a/tools/pm/Common/Output/OpaqueCopyable.pm b/tools/pm/Common/Output/OpaqueCopyable.pm
index d8f4f54..8ce850a 100644
--- a/tools/pm/Common/Output/OpaqueCopyable.pm
+++ b/tools/pm/Common/Output/OpaqueCopyable.pm
@@ -38,7 +38,7 @@ sub _output_h_in_class ($$$)
nl (' typedef ' . $c_type . ' BaseObjectType;') .
nl (Common::Output::Shared::doxy_skip_end) .
nl ();
- my $main_section = $wrap_parser->get_main_section;
+ my $main_section = $wrap_parser->get_main_section ();
$section_manager->push_section ($main_section);
$section_manager->append_string ($code_string);
@@ -46,16 +46,23 @@ sub _output_h_in_class ($$$)
my $conditional = Common::Output::Shared::default_ctor_proto $wrap_parser, $cxx_type;
$section_manager->append_conditional ($conditional);
+ $conditional = Common::Output::Shared::generate_conditional ($wrap_parser);
+
+ my $variable = Common::Output::Shared::get_variable ($wrap_parser, Common::Variables::CUSTOM_CTOR_CAST);
+
+ $code_string = nl (' // Use make_a_copy = true when getting it directly from a struct.') .
+ nl (' explicit ' . $cxx_type . '(' . $c_type . '* castitem, bool make_a_copy = false);') .
+ nl ();
+ $section_manager->append_string_to_conditional ($code_string, $conditional, 0);
+ $section_manager->append_conditional ($conditional);
+ $section_manager->set_variable_for_conditional ($variable, $conditional);
my $copy_proto = 'const';
my $reinterpret = 0;
my $definitions = 1;
my $virtual_dtor = 0;
- $code_string = nl (' // Use make_a_copy = true when getting it directly from a struct.') .
- nl (' explicit ' . $cxx_type . '(' . $c_type . '* castitem, bool make_a_copy = false);') .
- nl () .
- nl (Common::Output::Shared::copy_protos_str $cxx_type) .
+ $code_string = nl (Common::Output::Shared::copy_protos_str $cxx_type) .
nl () .
nl (Common::Output::Shared::dtor_proto_str $cxx_type, $virtual_dtor) .
nl () .
@@ -88,6 +95,7 @@ sub _output_cc ($$$$$$)
my ($wrap_parser, $c_type, $cxx_type, $new_func, $copy_func, $free_func) = @_;
my $section_manager = $wrap_parser->get_section_manager ();
my $custom_default_ctor_var = Common::Output::Shared::get_variable ($wrap_parser, Common::Variables::CUSTOM_DEFAULT_CTOR);
+ my $custom_ctor_cast_var = Common::Output::Shared::get_variable ($wrap_parser, Common::Variables::CUSTOM_CTOR_CAST);
my $conditional = Common::Output::Shared::generate_conditional ($wrap_parser);
my $full_cxx_type = Common::Output::Shared::get_full_cxx_type ($wrap_parser);
my $complete_cxx_type = Common::Output::Shared::get_complete_cxx_type ($wrap_parser);
@@ -110,8 +118,8 @@ sub _output_cc ($$$$$$)
$section_manager->set_variable_for_conditional ($no_wrap_function_var, $conditional);
$conditional = Common::Output::Shared::generate_conditional ($wrap_parser);
- $code_string = Common::Output::Shared::open_namespaces ($wrap_parser) .
- nl ($full_cxx_type . '::' . $cxx_type . '()') .
+ $section_manager->append_string (Common::Output::Shared::open_namespaces ($wrap_parser));
+ $code_string = nl ($full_cxx_type . '::' . $cxx_type . '()') .
nl (':');
if (defined $new_func and $new_func ne '' and $new_func ne 'NONE')
@@ -132,8 +140,10 @@ sub _output_cc ($$$$$$)
nl (':') .
nl (' gobject_((src.gobject_) ? ' . $copy_func . '(src.gobject_) : 0)') .
nl ('{}') .
- nl () .
- nl ($full_cxx_type . '::' . $cxx_type . '(' . $c_type . '* castitem, bool make_a_copy /* = false */)') .
+ nl ();
+ $section_manager->append_string ($code_string);
+ $conditional = Common::Output::Shared::generate_conditional ($wrap_parser);
+ $code_string = nl ($full_cxx_type . '::' . $cxx_type . '(' . $c_type . '* castitem, bool make_a_copy /* = false */)') .
nl ('{') .
nl (' if (!make_a_copy)') .
nl (' {') .
@@ -143,7 +153,7 @@ sub _output_cc ($$$$$$)
nl (' else') .
nl (' {') .
nl (' // We are probably getting it via direct access to a struct,') .
- nl (' // so we can not just take ut - we have to take a copy if it.') .
+ nl (' // so we can not just take it - we have to take a copy if it.') .
nl (' if (castitem)') .
nl (' {') .
nl (' gobject_ = ' . $copy_func . '(castitem);') .
@@ -155,6 +165,11 @@ sub _output_cc ($$$$$$)
nl (' }') .
nl ('}') .
nl ();
+ $section_manager->append_string_to_conditional ($code_string, $conditional);
+ $section_manager->append_conditional ($conditional);
+ $section_manager->set_variable_for_conditional ($custom_ctor_cast_var, $conditional);
+ $code_string = '';
+
if (defined $copy_func and $copy_func ne '' and $copy_func ne 'NONE')
{
$code_string .= nl ($full_cxx_type . '& ' . $full_cxx_type . '::operator=(const ' . $full_cxx_type . '& src)') .
diff --git a/tools/pm/Common/WrapParser.pm b/tools/pm/Common/WrapParser.pm
index f323065..9497859 100644
--- a/tools/pm/Common/WrapParser.pm
+++ b/tools/pm/Common/WrapParser.pm
@@ -3306,6 +3306,15 @@ sub _on_template_keyword
$self->fixed_error ('Hit eof while processing `template\'.');
}
+sub _on_custom_ctor_cast
+{
+ my ($self) = @_;
+ my $variable = Common::Output::Shared::get_variable ($self, Common::Variables::CUSTOM_CTOR_CAST);
+ my $section_manager = $self->get_section_manager ();
+
+ $section_manager->set_variable ($variable, 1);
+}
+
###
### HANDLERS ABOVE
###
@@ -3488,7 +3497,8 @@ sub new
'_INCLUDE_IN_WRAP_INIT' => sub { $self->_on_include_in_wrap_init (@_); },
'_PUSH_SECTION' => sub { $self->_on_push_section (@_); },
'_POP_SECTION' => sub { $self->_on_pop_section (@_); },
- 'template' => sub { $self->_on_template_keyword (@_); }
+ 'template' => sub { $self->_on_template_keyword (@_); },
+ '_CUSTOM_CTOR_CAST' => sub { $self->_on_custom_ctor_cast (@_); }
};
return $self;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]