You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2008/07/04 15:14:07 UTC
svn commit: r674040 -
/incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb
Author: gsim
Date: Fri Jul 4 06:14:06 2008
New Revision: 674040
URL: http://svn.apache.org/viewvc?rev=674040&view=rev
Log:
Allow default values for packed structs to be overridden (currently used for message.transfer.accept-mode)
Modified:
incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb
Modified: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb?rev=674040&r1=674039&r2=674040&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb (original)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb Fri Jul 4 06:14:06 2008
@@ -48,7 +48,7 @@
def default_initialisation(s)
params = s.fields.select {|f| ValueTypes.include?(f.cpptype.name) || (!is_packed(s) && f.type_ == "bit")}
- strings = params.collect {|f| "#{f.cppname}(0)"}
+ strings = params.collect {|f| "#{f.cppname}(#{f.default_value})"}
strings << "flags(0)" if (is_packed(s))
if strings.empty?
return ""
Re: svn commit: r674040 -
/incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb
Posted by Alan Conway <ac...@redhat.com>.
On Fri, 2008-07-04 at 13:14 +0000, gsim@apache.org wrote:
> Author: gsim
> Date: Fri Jul 4 06:14:06 2008
> New Revision: 674040
>
> URL: http://svn.apache.org/viewvc?rev=674040&view=rev
> Log:
> Allow default values for packed structs to be overridden (currently used for message.transfer.accept-mode)
>
>
> Modified:
> incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb
>
> Modified: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb
> URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb?rev=674040&r1=674039&r2=674040&view=diff
> ==============================================================================
> --- incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb (original)
> +++ incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb Fri Jul 4 06:14:06 2008
> @@ -48,7 +48,7 @@
>
> def default_initialisation(s)
> params = s.fields.select {|f| ValueTypes.include?(f.cpptype.name) || (!is_packed(s) && f.type_ == "bit")}
> - strings = params.collect {|f| "#{f.cppname}(0)"}
> + strings = params.collect {|f| "#{f.cppname}(#{f.default_value})"}
> strings << "flags(0)" if (is_packed(s))
> if strings.empty?
> return ""
>
Actually the compiler should be able to apply the "elided copy
optimization" here, so this may not have any performance impact at all
on optimized code.
Re: svn commit: r674040
- /incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb
Posted by Alan Conway <ac...@redhat.com>.
On Fri, 2008-07-04 at 14:59 +0100, Gordon Sim wrote:
> Alan Conway wrote:
> > On Fri, 2008-07-04 at 13:14 +0000, gsim@apache.org wrote:
> >> Author: gsim
> >> Date: Fri Jul 4 06:14:06 2008
> >> New Revision: 674040
> >>
> >> URL: http://svn.apache.org/viewvc?rev=674040&view=rev
> >> Log:
> >> Allow default values for packed structs to be overridden (currently used for message.transfer.accept-mode)
> >>
> >>
> >> Modified:
> >> incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb
> >>
> >> Modified: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb
> >> URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb?rev=674040&r1=674039&r2=674040&view=diff
> >> ==============================================================================
> >> --- incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb (original)
> >> +++ incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb Fri Jul 4 06:14:06 2008
> >> @@ -48,7 +48,7 @@
> >>
> >> def default_initialisation(s)
> >> params = s.fields.select {|f| ValueTypes.include?(f.cpptype.name) || (!is_packed(s) && f.type_ == "bit")}
> >> - strings = params.collect {|f| "#{f.cppname}(0)"}
> >> + strings = params.collect {|f| "#{f.cppname}(#{f.default_value})"}
> >> strings << "flags(0)" if (is_packed(s))
> >> if strings.empty?
> >> return ""
> >
> >
> > This fix will result in things like:
> >
> > Foo() : fooString(std::string()) {}
>
> No, I don't think it will. Explicit initialisation is only used for the
> various int types.
You're quite right. A nice simple fix.
Cheers,
Alan.
Re: svn commit: r674040 - /incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb
Posted by Gordon Sim <gs...@redhat.com>.
Alan Conway wrote:
> On Fri, 2008-07-04 at 13:14 +0000, gsim@apache.org wrote:
>> Author: gsim
>> Date: Fri Jul 4 06:14:06 2008
>> New Revision: 674040
>>
>> URL: http://svn.apache.org/viewvc?rev=674040&view=rev
>> Log:
>> Allow default values for packed structs to be overridden (currently used for message.transfer.accept-mode)
>>
>>
>> Modified:
>> incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb
>>
>> Modified: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb
>> URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb?rev=674040&r1=674039&r2=674040&view=diff
>> ==============================================================================
>> --- incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb (original)
>> +++ incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb Fri Jul 4 06:14:06 2008
>> @@ -48,7 +48,7 @@
>>
>> def default_initialisation(s)
>> params = s.fields.select {|f| ValueTypes.include?(f.cpptype.name) || (!is_packed(s) && f.type_ == "bit")}
>> - strings = params.collect {|f| "#{f.cppname}(0)"}
>> + strings = params.collect {|f| "#{f.cppname}(#{f.default_value})"}
>> strings << "flags(0)" if (is_packed(s))
>> if strings.empty?
>> return ""
>
>
> This fix will result in things like:
>
> Foo() : fooString(std::string()) {}
No, I don't think it will. Explicit initialisation is only used for the
various int types.
Re: svn commit: r674040 -
/incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb
Posted by Alan Conway <ac...@redhat.com>.
On Fri, 2008-07-04 at 13:14 +0000, gsim@apache.org wrote:
> Author: gsim
> Date: Fri Jul 4 06:14:06 2008
> New Revision: 674040
>
> URL: http://svn.apache.org/viewvc?rev=674040&view=rev
> Log:
> Allow default values for packed structs to be overridden (currently used for message.transfer.accept-mode)
>
>
> Modified:
> incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb
>
> Modified: incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb
> URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb?rev=674040&r1=674039&r2=674040&view=diff
> ==============================================================================
> --- incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb (original)
> +++ incubator/qpid/trunk/qpid/cpp/rubygen/framing.0-10/structs.rb Fri Jul 4 06:14:06 2008
> @@ -48,7 +48,7 @@
>
> def default_initialisation(s)
> params = s.fields.select {|f| ValueTypes.include?(f.cpptype.name) || (!is_packed(s) && f.type_ == "bit")}
> - strings = params.collect {|f| "#{f.cppname}(0)"}
> + strings = params.collect {|f| "#{f.cppname}(#{f.default_value})"}
> strings << "flags(0)" if (is_packed(s))
> if strings.empty?
> return ""
This fix will result in things like:
Foo() : fooString(std::string()) {}
Which is correct but stylistically odd and from a performance viewpoint
invokes a default ctor + a copy ctor instead of just a default. That's
what I was trying to avoid in the more complicated patch. We should
verify the performance impact - if there is none then maybe we can leave
it that way.