Class: Typelib::Type

Inherits:
Object
  • Object
show all
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

Class Method Details

.allocate_indexObject



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_typeObject



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

Returns:

  • (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

Returns:

  • (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_basenameObject



84
85
86
# File 'lib/orogen/gen/typekit.rb', line 84

def self.cxx_basename
    normalize_cxxname(basename)
end

.cxx_nameObject



81
82
83
# File 'lib/orogen/gen/typekit.rb', line 81

def self.cxx_name
    normalize_cxxname(name)
end

.cxx_namespaceObject



87
88
89
# File 'lib/orogen/gen/typekit.rb', line 87

def self.cxx_namespace
    namespace('::')
end

.index_var_stackObject



109
# File 'lib/orogen/gen/typekit.rb', line 109

def self.index_var_stack; @@index_var_stack end

.inlines_code?Boolean

Returns:

  • (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_wordObject



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_typeObject



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