Class: OroGen::Gen::RTT_CPP::ImportedTypekit

Inherits:
Object
  • Object
show all
Defined in:
lib/orogen/gen/imports.rb,
lib/orogen/marshallers/ros.rb

Overview

Instances of this class represent a typekit that has been imported using Project#using_typekit

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(main_project, name, pkg, registry, typelist, interface_typelist) ⇒ ImportedTypekit


81
82
83
84
85
86
87
# File 'lib/orogen/gen/imports.rb', line 81

def initialize(main_project, name, pkg, registry, typelist, interface_typelist)
    @main_project, @name, @pkg, @registry = main_project, name, pkg, registry
    @typelist = typelist.to_set
    @interface_typelist = interface_typelist.to_set
    @opaques = Array.new
    @opaque_registry = Typelib::Registry.new
end

Instance Attribute Details

#interface_typelistObject (readonly)

Returns the value of attribute interface_typelist


12
13
14
# File 'lib/orogen/gen/imports.rb', line 12

def interface_typelist
  @interface_typelist
end

#main_projectObject (readonly)

Returns the value of attribute main_project


7
8
9
# File 'lib/orogen/gen/imports.rb', line 7

def main_project
  @main_project
end

#nameObject (readonly)

Returns the value of attribute name


8
9
10
# File 'lib/orogen/gen/imports.rb', line 8

def name
  @name
end

#opaque_registryObject (readonly)

Returns the value of attribute opaque_registry


15
16
17
# File 'lib/orogen/gen/imports.rb', line 15

def opaque_registry
  @opaque_registry
end

#opaquesObject (readonly)

Returns the value of attribute opaques


14
15
16
# File 'lib/orogen/gen/imports.rb', line 14

def opaques
  @opaques
end

#pkgObject (readonly)

Returns the value of attribute pkg


9
10
11
# File 'lib/orogen/gen/imports.rb', line 9

def pkg
  @pkg
end

#registryObject (readonly)

Returns the value of attribute registry


10
11
12
# File 'lib/orogen/gen/imports.rb', line 10

def registry
  @registry
end

#typelistObject (readonly)

Returns the value of attribute typelist


11
12
13
# File 'lib/orogen/gen/imports.rb', line 11

def typelist
  @typelist
end

Class Method Details

.from_raw_data(main, name, pkg, registry_xml, typelist_txt) ⇒ Object


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/orogen/gen/imports.rb', line 40

def self.from_raw_data(main, name, pkg, registry_xml, typelist_txt)
    typekit_registry = Typelib::Registry.new
    typekit_registry.merge_xml(registry_xml)

    typekit_typelist, typekit_interface_typelist = parse_typelist(typelist_txt)
    typekit = self.new(main, name,
                  pkg, typekit_registry,
                  typekit_typelist,
                  typekit_interface_typelist)

    # Now initialize the opaque definitions
    doc = REXML::Document.new(registry_xml)
    doc.each_element('//opaque') do |opaque_entry|
        base_type_name  = opaque_entry.attributes['name']
        inter_type_name = opaque_entry.attributes['marshal_as']
        includes        = opaque_entry.attributes['includes']
        needs_copy      = opaque_entry.attributes['needs_copy']
        spec = OpaqueDefinition.new(
            typekit_registry.get(base_type_name),
            inter_type_name,
            { :include => includes.split(':'), :needs_copy => (needs_copy == '1') },
            nil)

        typekit.opaque_registry.merge(typekit_registry.minimal(base_type_name))
        typekit.opaques << spec
    end

    typekit
end

.parse_typelist(typelist_txt) ⇒ Object


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/orogen/gen/imports.rb', line 17

def self.parse_typelist(typelist_txt)
    raw_typelist = typelist_txt.split("\n").map(&:strip)
    typekit_typelist, typekit_interface_typelist = [], []
    raw_typelist.each do |decl|
        # using non greedy kleene star to match first expression: .*?
        # to handle following patterns:
        # /string
        # /unsigned char[8]
        # /unsigned char[8] 0 
        if decl =~ /^(.*) (\d)$/
            type, is_interface = $1, ($2 == '1')
        else
            type, is_interface = decl, true
        end

        typekit_typelist << type
        if is_interface
            typekit_interface_typelist << type
        end
    end
    return typekit_typelist, typekit_interface_typelist
end

Instance Method Details

#defines_array_of?(type) ⇒ Boolean


134
135
136
137
138
139
140
# File 'lib/orogen/gen/imports.rb', line 134

def defines_array_of?(type)
    typename = if type.respond_to?(:name) then type.name
               else type.to_str
               end

    typelist.any? { |str| str =~ /#{Regexp.quote(typename)}(\[\d+\])+/ }
end

#export_types(*args) ⇒ Object


70
# File 'lib/orogen/gen/imports.rb', line 70

def export_types(*args); end

#find_type(type) ⇒ Object


145
146
147
148
149
150
151
# File 'lib/orogen/gen/imports.rb', line 145

def find_type(type)
    if type.respond_to?(:name)
        registry.get(type.name)
    else
        registry.get(type)
    end
end

#has_opaques?Boolean


72
73
74
# File 'lib/orogen/gen/imports.rb', line 72

def has_opaques?
    registry.any? { |t| includes?(t) && t.contains_opaques? }
end

#include_dirsObject


109
110
111
# File 'lib/orogen/gen/imports.rb', line 109

def include_dirs
    pkg.include_dirs.to_set
end

#includes?(type) ⇒ Boolean


153
154
155
156
157
158
# File 'lib/orogen/gen/imports.rb', line 153

def includes?(type)
    typename = if type.respond_to?(:name) then type.name
               else type.to_str
               end
    typelist.include?(typename)
end

#interface_type?(typename) ⇒ Boolean


76
77
78
79
# File 'lib/orogen/gen/imports.rb', line 76

def interface_type?(typename)
    typename = typename.name if typename.respond_to?(:name)
    interface_typelist.include?(typename)
end

#intermediate_type?(*args) ⇒ Boolean


126
127
128
# File 'lib/orogen/gen/imports.rb', line 126

def intermediate_type?(*args)
    main_project.intermediate_type?(*args)
end

#intermediate_type_for(*args) ⇒ Object


122
123
124
# File 'lib/orogen/gen/imports.rb', line 122

def intermediate_type_for(*args)
    main_project.intermediate_type_for(*args)
end

#m_type?(*args) ⇒ Boolean


130
131
132
# File 'lib/orogen/gen/imports.rb', line 130

def m_type?(*args)
    main_project.m_type?(*args)
end

#opaque_type(*args) ⇒ Object

Simply ignore, we load the whole typekit anyway


97
# File 'lib/orogen/gen/imports.rb', line 97

def opaque_type(*args); end

#perform_pending_loadsObject


102
# File 'lib/orogen/gen/imports.rb', line 102

def perform_pending_loads; end

#pkg_corba_nameObject


106
107
108
# File 'lib/orogen/gen/imports.rb', line 106

def pkg_corba_name
    pkg_transport_name('corba')
end

#pkg_nameObject


99
100
101
# File 'lib/orogen/gen/imports.rb', line 99

def pkg_name
    pkg.name
end

#pkg_transport_name(transport_name) ⇒ Object


103
104
105
# File 'lib/orogen/gen/imports.rb', line 103

def pkg_transport_name(transport_name)
    Utilrb::PkgConfig.new(pkg.name.gsub('typekit', "transport-#{transport_name}")).name
end

#ros_mappings(mappings) ⇒ Object


19
20
21
# File 'lib/orogen/marshallers/ros.rb', line 19

def ros_mappings(mappings)
    self
end

#self_typesObject


118
119
120
# File 'lib/orogen/gen/imports.rb', line 118

def self_types
    typelist.map { |name| registry.get(name) }
end

#types_dirObject

Returns the full path to the types/ subdir in the include directory


114
115
116
# File 'lib/orogen/gen/imports.rb', line 114

def types_dir
    File.join(pkg.includedir, name, 'types')
end

#using_library(*args) ⇒ Object


142
# File 'lib/orogen/gen/imports.rb', line 142

def using_library(*args); end

#using_typekit(*args) ⇒ Object


143
# File 'lib/orogen/gen/imports.rb', line 143

def using_typekit(*args); end

#virtual?Boolean


159
# File 'lib/orogen/gen/imports.rb', line 159

def virtual?; false end