module OroGen::TypekitMarshallers::Corba::ContainerType
Public Instance Methods
corba_arg_type()
click to toggle source
# File lib/orogen/marshallers/corba.rb, line 247 def corba_arg_type; "#{corba_name} const&" end
corba_name()
click to toggle source
# File lib/orogen/marshallers/corba.rb, line 235 def corba_name container_kind = self.container_kind.gsub /.*\//, '' element_name = deference.name.gsub(/[^\w]/, "_") typedef_name = container_kind + "_" + element_name if deference.corba_name !~ /^orogen::/ # This type is mapped into the root namespace "orogen::Corba::#{typedef_name}_" else "#{corba_namespace}::#{typedef_name}_" end end
corba_namespace()
click to toggle source
# File lib/orogen/marshallers/corba.rb, line 250 def corba_namespace deference.corba_namespace end
corba_ref_type()
click to toggle source
# File lib/orogen/marshallers/corba.rb, line 248 def corba_ref_type; "#{corba_name}&" end
from_corba(typekit, result, indent)
click to toggle source
# File lib/orogen/marshallers/corba.rb, line 288 def from_corba(typekit, result, indent) collection_name, element_type = container_kind, deference.name element_type = registry.build(element_type) if container_kind != "/std/vector" raise NotImplementedError, "from_corba is not implemented for other containers than std::vector, got #{container_kind}" end allocate_index do |element_idx| result << "#{indent}size_t const size_#{element_idx} = corba.length();\n" result << "#{indent}value.resize(size_#{element_idx});\n" if collection_name == "/std/vector" && element_type < NumericType result << "if (!value.empty()) #{indent}memcpy(&value[0], &corba[0], size_#{element_idx});" else result << <<-EOT #{indent}for(size_t #{element_idx} = 0; #{element_idx} < size_#{element_idx}; ++#{element_idx}) #{indent}{ EOT if element_type.inlines_code? result << element_type.inline_fromCorba("value[#{element_idx}]", "corba[#{element_idx}]", indent) elsif element_type < ArrayType result << "#{indent} fromCORBA(reinterpret_cast<#{element_type.deference.cxx_name}*>(value[#{element_idx}]), #{element_type.length}, corba[#{element_idx}]);\n"; else result << "#{indent} fromCORBA(value[#{element_idx}], corba[#{element_idx}]);\n"; end result << "#{indent}}\n"; end end result end
to_corba(typekit, result, indent)
click to toggle source
# File lib/orogen/marshallers/corba.rb, line 254 def to_corba(typekit, result, indent) collection_name, element_type = container_kind, deference.name element_type = registry.build(element_type) result << "#{indent}corba.length(value.size());\n" # Special case for array of bytes, we can do a simple memcpy # (maybe extend that later) if collection_name == "/std/vector" && element_type < NumericType && element_type.integer? && element_type.size == 1 result << "if (!value.empty()) #{indent}memcpy(&corba[0], &value[0], value.size());" else allocate_index do |element_idx| result << <<-EOT #{indent}size_t #{element_idx} = 0; #{indent}for(#{cxx_name}::const_iterator it = value.begin(); it != value.end(); ++it, ++#{element_idx}) #{indent}{ EOT if element_type.inlines_code? result << element_type.inline_toCorba("corba[#{element_idx}]", "(*it)", indent) elsif element_type < ArrayType result << indent << " toCORBA(corba[#{element_idx}], reinterpret_cast< #{element_type.deference.cxx_name} const*>(*it), #{element_type.length});\n"; else result << indent << " toCORBA(corba[#{element_idx}], *it);\n"; end result << "#{indent}}\n"; end end result end