Class: Typelib::Type
- Inherits:
-
Object
- Object
- Typelib::Type
- Defined in:
- lib/orogen/gen/typekit.rb,
lib/orogen/marshallers/iostream.rb,
lib/orogen/typenames.rb
Constant Summary collapse
- @@index_var_stack =
Array.new
Class Method Summary collapse
- .allocate_index ⇒ Object
- .arg_type ⇒ Object
- .code_assign(result, indent, dest, src) ⇒ Object
- .contains_int64? ⇒ Boolean
- .contains_opaques? ⇒ Boolean
- .cxx_basename ⇒ Object
- .cxx_name ⇒ Object
- .cxx_namespace ⇒ Object
- .index_var_stack ⇒ Object
- .inlines_code? ⇒ Boolean
- .method_name(fullname = true) ⇒ Object
- .name_as_word ⇒ Object
- .normalize_cxxname(name) ⇒ Object
- .normalize_cxxname_part(name) ⇒ Object
- .normalize_typename(name) ⇒ Object
- .normalize_typename_part(name) ⇒ Object
- .ref_type ⇒ Object
- .to_stream(typekit, result, indent) ⇒ Object
Class Method Details
.allocate_index ⇒ Object
110 111 112 113 114 115 |
# File 'lib/orogen/gen/typekit.rb', line 110 def self.allocate_index index_var_stack.push "i#{index_var_stack.size}" yield(index_var_stack.last) ensure index_var_stack.pop end |
.arg_type ⇒ Object
94 |
# File 'lib/orogen/gen/typekit.rb', line 94 def self.arg_type; "#{cxx_name} const&" end |
.code_assign(result, indent, dest, src) ⇒ Object
119 120 121 |
# File 'lib/orogen/gen/typekit.rb', line 119 def self.code_assign(result, indent, dest, src) result << "#{indent}#{dest} = #{src};\n" end |
.contains_int64? ⇒ Boolean
104 105 106 |
# File 'lib/orogen/gen/typekit.rb', line 104 def self.contains_int64? dependencies.any? { |t| t.contains_int64? } end |
.contains_opaques? ⇒ Boolean
84 85 86 87 88 89 |
# File 'lib/orogen/typenames.rb', line 84 def self.contains_opaques? if @contains_opaques.nil? @contains_opaques = contains?(Typelib::OpaqueType) end @contains_opaques end |
.cxx_basename ⇒ Object
84 85 86 |
# File 'lib/orogen/gen/typekit.rb', line 84 def self.cxx_basename normalize_cxxname(basename) end |
.cxx_name ⇒ Object
81 82 83 |
# File 'lib/orogen/gen/typekit.rb', line 81 def self.cxx_name normalize_cxxname(name) end |
.cxx_namespace ⇒ Object
87 88 89 |
# File 'lib/orogen/gen/typekit.rb', line 87 def self.cxx_namespace namespace('::') end |
.index_var_stack ⇒ Object
109 |
# File 'lib/orogen/gen/typekit.rb', line 109 def self.index_var_stack; @@index_var_stack end |
.inlines_code? ⇒ Boolean
117 |
# File 'lib/orogen/gen/typekit.rb', line 117 def self.inlines_code?; false end |
.method_name(fullname = true) ⇒ Object
97 98 99 100 101 102 |
# File 'lib/orogen/gen/typekit.rb', line 97 def self.method_name(fullname = true) base = if fullname then full_name('_', true) else basename('_') end base.gsub(/[<>\[\], ]/, '_') end |
.name_as_word ⇒ Object
90 91 92 |
# File 'lib/orogen/gen/typekit.rb', line 90 def self.name_as_word cxx_name.gsub(/[^\w+]/, '_') end |
.normalize_cxxname(name) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/orogen/gen/typekit.rb', line 38 def self.normalize_cxxname(name) if name =~ /::/ raise Orocos::Generation::InternalError, "normalize_cxxname called with a C++ type name (#{name})" end if name =~ /(.*)((?:\[\d+\])+)$/ name = $1 suffix = $2 else suffix = '' end converted = Typelib.split_typename(name).map do |p| normalize_cxxname_part(p) end if converted.size == 1 "#{converted.first}#{suffix}" else "::" + converted.join("::") + suffix end end |
.normalize_cxxname_part(name) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/orogen/gen/typekit.rb', line 60 def self.normalize_cxxname_part(name) name, template_arguments = Typelib::CXX.parse_template(name) name = name.gsub('/', '::') if name =~ /^::(.*)/ name = $1 end if !template_arguments.empty? template_arguments.map! do |arg| if arg !~ /^\d+$/ normalize_cxxname(arg) else arg end end "#{name}< #{template_arguments.join(", ")} >" else name end end |
.normalize_typename(name) ⇒ Object
10 11 12 13 14 |
# File 'lib/orogen/gen/typekit.rb', line 10 def self.normalize_typename(name) "/" + Typelib.split_typename(name).map do |part| normalize_typename_part(part) end.join("/") end |
.normalize_typename_part(name) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/orogen/gen/typekit.rb', line 16 def self.normalize_typename_part(name) # Remove all trailing array modifiers first if name =~ /(.*)(\[\d+\]+)$/ name, array_modifiers = $1, $2 end name, template_arguments = Typelib::CXX.parse_template(name) template_arguments.map! do |arg| arg = if arg !~ /^\d+$/ && arg[0, 1] != "/" "/#{arg}" else arg end end if !template_arguments.empty? "#{name}<#{template_arguments.join(",")}>#{array_modifiers}" else "#{name}#{array_modifiers}" end end |
.ref_type ⇒ Object
95 |
# File 'lib/orogen/gen/typekit.rb', line 95 def self.ref_type; "#{cxx_name}&" end |
.to_stream(typekit, result, indent) ⇒ Object
3 4 5 6 |
# File 'lib/orogen/marshallers/iostream.rb', line 3 def self.to_stream(typekit, result, indent) STDERR.puts "to_ostream not implemented for #{name}" result end |