diff --git a/ridlbe/base/visitorbase.rb b/ridlbe/base/visitorbase.rb index fc2875f2..d499dc40 100644 --- a/ridlbe/base/visitorbase.rb +++ b/ridlbe/base/visitorbase.rb @@ -255,7 +255,7 @@ def parse(__output__, __template__, __extra_props__ = {}) @__erb_out = __output__ @__extra_props = __extra_props__ @__template = __template__ - _erb = if (RUBY_VERSION.split('.').map { |x| x.to_i } <=> [2, 6, 0]) < 0 + _erb = if (RUBY_VERSION.split('.').map { |x| x.to_i } <=> [2, 6, 0]).negative? # TODO: remove this as soon as we do not need to support ancient Ruby anymore ERB.new(__template__.code, nil, '%', '@__erb_out.erbout') else diff --git a/ridlbe/base/writerbase.rb b/ridlbe/base/writerbase.rb index 93aaa89d..4888759d 100644 --- a/ridlbe/base/writerbase.rb +++ b/ridlbe/base/writerbase.rb @@ -44,7 +44,7 @@ def inc_nest(in_ = 1) def dec_nest(in_ = 1) @nest -= in_ - @nest = 0 if @nest < 0 + @nest = 0 if @nest.negative? end def write_regen_section(sectionid, options = nil, proc = nil) diff --git a/ridlbe/c++11/config/cxx_type.rb b/ridlbe/c++11/config/cxx_type.rb index c247aac9..3d6e6adc 100644 --- a/ridlbe/c++11/config/cxx_type.rb +++ b/ridlbe/c++11/config/cxx_type.rb @@ -444,7 +444,7 @@ def os_fmt class String def cxx_type(_scope = nil) - (size.to_i > 0) ? "TAOX11_IDL::bounded_string<#{size}>" : 'std::string' + (size.to_i.positive?) ? "TAOX11_IDL::bounded_string<#{size}>" : 'std::string' end def proxy_cxxtype(_scope = nil) @@ -460,7 +460,7 @@ def scoped_cxx_typecode end def cxx_member_type_name - (size.to_i > 0) ? "bounded_string<#{size}>" : 'string' + (size.to_i.positive?) ? "bounded_string<#{size}>" : 'string' end def value_to_s(v, _scope = nil) @@ -468,7 +468,7 @@ def value_to_s(v, _scope = nil) end def is_standard_type? - self.size.to_i == 0 + self.size.to_i.zero? end def os_fmt @@ -478,7 +478,7 @@ def os_fmt class WString def cxx_type(_scope = nil) - (size.to_i > 0) ? "TAOX11_IDL::bounded_wstring<#{size}>" : 'std::wstring' + (size.to_i.positive?) ? "TAOX11_IDL::bounded_wstring<#{size}>" : 'std::wstring' end def proxy_cxxtype(_scope = nil) @@ -494,7 +494,7 @@ def scoped_cxx_typecode end def cxx_member_type_name - (size.to_i > 0) ? "bounded_wstring<#{size}>" : 'wstring' + (size.to_i.positive?) ? "bounded_wstring<#{size}>" : 'wstring' end def value_to_s(v, _scope = nil) @@ -517,7 +517,7 @@ def value_to_s(v, _scope = nil) end def is_standard_type? - self.size.to_i == 0 + self.size.to_i.zero? end def os_fmt @@ -911,15 +911,15 @@ def value_to_s(v, _scope = nil) class Sequence def cxx_type(scope = nil) - (size.to_i > 0) ? "TAOX11_NAMESPACE::IDL::bounded_vector<#{basetype.cxx_member_type(scope)}, #{size}>" : "std::vector<#{basetype.cxx_member_type(scope)}>" + (size.to_i.positive?) ? "TAOX11_NAMESPACE::IDL::bounded_vector<#{basetype.cxx_member_type(scope)}, #{size}>" : "std::vector<#{basetype.cxx_member_type(scope)}>" end def proxy_cxxtype(scope = nil) - (size.to_i > 0) ? "TAOX11_NAMESPACE::IDL::bounded_vector<#{basetype.proxy_cxxtype(scope)}, #{size}>" : "std::vector<#{basetype.proxy_cxxtype(scope)}>" + (size.to_i.positive?) ? "TAOX11_NAMESPACE::IDL::bounded_vector<#{basetype.proxy_cxxtype(scope)}, #{size}>" : "std::vector<#{basetype.proxy_cxxtype(scope)}>" end def resolved_cxx_type(scope = nil) - (size.to_i > 0) ? "TAOX11_NAMESPACE::IDL::bounded_vector<#{basetype.resolved_cxx_member_type(scope)}, #{size}>" : "std::vector<#{basetype.resolved_cxx_member_type(scope)}>" + (size.to_i.positive?) ? "TAOX11_NAMESPACE::IDL::bounded_vector<#{basetype.resolved_cxx_member_type(scope)}, #{size}>" : "std::vector<#{basetype.resolved_cxx_member_type(scope)}>" end def base_traits_cxx_typename @@ -934,15 +934,15 @@ def cxx_anyop_arg_typename(scope = nil) class Map def cxx_type(scope = nil) - (size.to_i > 0) ? "TAOX11_NAMESPACE::IDL::bounded_map<#{keytype.cxx_member_type(scope)}, #{valuetype.cxx_member_type(scope)}, #{size}>" : "std::map<#{keytype.cxx_member_type(scope)}, #{valuetype.cxx_member_type(scope)}>" + (size.to_i.positive?) ? "TAOX11_NAMESPACE::IDL::bounded_map<#{keytype.cxx_member_type(scope)}, #{valuetype.cxx_member_type(scope)}, #{size}>" : "std::map<#{keytype.cxx_member_type(scope)}, #{valuetype.cxx_member_type(scope)}>" end def proxy_cxxtype(scope = nil) - (size.to_i > 0) ? "TAOX11_NAMESPACE::IDL::bounded_map<#{keytype.proxy_cxxtype(scope)}, #{valuetype.proxy_cxxtype(scope)}, #{size}>" : "std::map<#{keytype.proxy_cxxtype(scope)}, #{valuetype.proxy_cxxtype(scope)}>" + (size.to_i.positive?) ? "TAOX11_NAMESPACE::IDL::bounded_map<#{keytype.proxy_cxxtype(scope)}, #{valuetype.proxy_cxxtype(scope)}, #{size}>" : "std::map<#{keytype.proxy_cxxtype(scope)}, #{valuetype.proxy_cxxtype(scope)}>" end def resolved_cxx_type(scope = nil) - (size.to_i > 0) ? "TAOX11_NAMESPACE::IDL::bounded_map<#{keytype.resolved_cxx_member_type(scope)}, #{valuetype.resolved_cxx_member_type(scope)}, #{size}>" : "std::map<#{keytype.resolved_cxx_member_type(scope)}, #{valuetype.resolved_cxx_member_type(scope)}>" + (size.to_i.positive?) ? "TAOX11_NAMESPACE::IDL::bounded_map<#{keytype.resolved_cxx_member_type(scope)}, #{valuetype.resolved_cxx_member_type(scope)}, #{size}>" : "std::map<#{keytype.resolved_cxx_member_type(scope)}, #{valuetype.resolved_cxx_member_type(scope)}>" end def key_traits_cxx_typename diff --git a/ridlbe/c++11/visitors/typedef.rb b/ridlbe/c++11/visitors/typedef.rb index 8bc088ed..b2e91af1 100644 --- a/ridlbe/c++11/visitors/typedef.rb +++ b/ridlbe/c++11/visitors/typedef.rb @@ -70,7 +70,7 @@ def is_bounded_type? IDL::Type::Map, IDL::Type::String, IDL::Type::WString - self._resolved_idltype.size.to_i > 0 + self._resolved_idltype.size.to_i.positive? else false end @@ -86,7 +86,7 @@ def resolved_guard_signature when IDL::Type::Sequence, IDL::Type::String, IDL::Type::WString - _guard << "_#{self._resolved_idltype.size}" if self._resolved_idltype.size.to_i > 0 + _guard << "_#{self._resolved_idltype.size}" if self._resolved_idltype.size.to_i.positive? when IDL::Type::Array _guard << "_#{self._resolved_idltype.sizes.join('_')}" end diff --git a/ridlbe/c++11/writers/stubheader.rb b/ridlbe/c++11/writers/stubheader.rb index 6d89b1fb..d1f282d3 100644 --- a/ridlbe/c++11/writers/stubheader.rb +++ b/ridlbe/c++11/writers/stubheader.rb @@ -427,20 +427,20 @@ def visit_typedef(node) when IDL::Type::Fixed add_include('tao/x11/fixed_t.h') when IDL::Type::Sequence - add_include('tao/x11/bounded_vector_t.h') if idl_type.size.to_i > 0 - add_include('tao/x11/bounded_type_traits_t.h') if idl_type.size.to_i > 0 + add_include('tao/x11/bounded_vector_t.h') if idl_type.size.to_i.positive? + add_include('tao/x11/bounded_type_traits_t.h') if idl_type.size.to_i.positive? check_idl_type(idl_type.basetype) when IDL::Type::Map add_include('map') - add_include('tao/x11/bounded_map_t.h') if idl_type.size.to_i > 0 - add_include('tao/x11/bounded_type_traits_t.h') if idl_type.size.to_i > 0 + add_include('tao/x11/bounded_map_t.h') if idl_type.size.to_i.positive? + add_include('tao/x11/bounded_type_traits_t.h') if idl_type.size.to_i.positive? check_idl_type(idl_type.keytype) check_idl_type(idl_type.valuetype) when IDL::Type::Array check_idl_type(idl_type.basetype) when IDL::Type::String, IDL::Type::WString - add_include('tao/x11/bounded_string_t.h') if idl_type.size.to_i > 0 - add_include('tao/x11/bounded_type_traits_t.h') if idl_type.size.to_i > 0 + add_include('tao/x11/bounded_string_t.h') if idl_type.size.to_i.positive? + add_include('tao/x11/bounded_type_traits_t.h') if idl_type.size.to_i.positive? end end @@ -555,7 +555,7 @@ def visit_typedef(node) when IDL::Type::Array visitor(ArrayVisitor).visit_idl_traits(node) when IDL::Type::String, IDL::Type::WString - visitor(StringVisitor).visit_idl_traits(node) if idl_type.size.to_i > 0 # only for bounded strings + visitor(StringVisitor).visit_idl_traits(node) if idl_type.size.to_i.positive? # only for bounded strings when IDL::Type::Fixed visitor(FixedVisitor).visit_idl_traits(node) end