Class: Runtime
- Inherits:
-
Object
- Object
- Runtime
- Defined in:
- lib/runtime.rb
Instance Attribute Summary collapse
-
#builtins ⇒ Object
readonly
Returns the value of attribute builtins.
-
#directions ⇒ Object
readonly
Returns the value of attribute directions.
-
#enums ⇒ Object
readonly
Returns the value of attribute enums.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#includes ⇒ Object
readonly
Returns the value of attribute includes.
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
-
#sequences ⇒ Object
readonly
Returns the value of attribute sequences.
-
#structs ⇒ Object
readonly
Returns the value of attribute structs.
Instance Method Summary collapse
- #add_direction(direction_def) ⇒ Object
- #add_enum(enum_def) ⇒ Object
- #add_include(runtime) ⇒ Object
- #add_node(node_def) ⇒ Object
- #add_sequence(sequence_def) ⇒ Object
- #add_struct(struct_def) ⇒ Object
- #get_direction(client, direction, server) ⇒ Object
- #get_node_directions(node, side) ⇒ Object
- #get_sequence(name) ⇒ Object
- #get_type(name) ⇒ Object
- #init_builtins ⇒ Object
-
#initialize(filename) ⇒ Runtime
constructor
A new instance of Runtime.
Constructor Details
#initialize(filename) ⇒ Runtime
Returns a new instance of Runtime.
198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/runtime.rb', line 198 def initialize filename @filename = filename @builtins = {} @enums = {} @nodes = {} @structs = {} @directions = [] @sequences = {} @includes = [] self.init_builtins end |
Instance Attribute Details
#builtins ⇒ Object (readonly)
Returns the value of attribute builtins.
190 191 192 |
# File 'lib/runtime.rb', line 190 def builtins @builtins end |
#directions ⇒ Object (readonly)
Returns the value of attribute directions.
194 195 196 |
# File 'lib/runtime.rb', line 194 def directions @directions end |
#enums ⇒ Object (readonly)
Returns the value of attribute enums.
192 193 194 |
# File 'lib/runtime.rb', line 192 def enums @enums end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
189 190 191 |
# File 'lib/runtime.rb', line 189 def filename @filename end |
#includes ⇒ Object (readonly)
Returns the value of attribute includes.
196 197 198 |
# File 'lib/runtime.rb', line 196 def includes @includes end |
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
191 192 193 |
# File 'lib/runtime.rb', line 191 def nodes @nodes end |
#sequences ⇒ Object (readonly)
Returns the value of attribute sequences.
195 196 197 |
# File 'lib/runtime.rb', line 195 def sequences @sequences end |
#structs ⇒ Object (readonly)
Returns the value of attribute structs.
193 194 195 |
# File 'lib/runtime.rb', line 193 def structs @structs end |
Instance Method Details
#add_direction(direction_def) ⇒ Object
267 268 269 |
# File 'lib/runtime.rb', line 267 def add_direction direction_def @directions.push direction_def end |
#add_enum(enum_def) ⇒ Object
236 237 238 |
# File 'lib/runtime.rb', line 236 def add_enum enum_def @enums[enum_def.name] = enum_def end |
#add_include(runtime) ⇒ Object
299 300 301 |
# File 'lib/runtime.rb', line 299 def add_include runtime @includes.push runtime end |
#add_node(node_def) ⇒ Object
240 241 242 243 |
# File 'lib/runtime.rb', line 240 def add_node node_def @nodes[node_def.name] = node_def @nodes[node_def.nickname] = node_def if node_def.name != node_def.nickname end |
#add_sequence(sequence_def) ⇒ Object
283 284 285 |
# File 'lib/runtime.rb', line 283 def add_sequence sequence_def @sequences[sequence_def.name] = sequence_def end |
#add_struct(struct_def) ⇒ Object
245 246 247 |
# File 'lib/runtime.rb', line 245 def add_struct struct_def @structs[struct_def.name] = struct_def end |
#get_direction(client, direction, server) ⇒ Object
271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/runtime.rb', line 271 def get_direction client, direction, server dir = @directions.find { |d| d.client == client and d.server == server and d.direction == direction } return dir if dir != nil @includes.each do |i| dir = i.get_direction client, direction, server return dir if dir != nil end return nil end |
#get_node_directions(node, side) ⇒ Object
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
# File 'lib/runtime.rb', line 303 def get_node_directions node, side node_directions = {} @directions.each do |direction| next if side == :client and direction.client != node next if side == :server and direction.server != node opposite_node = nil case side when :client opposite_node = direction.server when :server opposite_node = direction.client end node_direction = node_directions[opposite_node] if node_direction == nil node_direction = NodeDirection.new node, opposite_node node_directions[opposite_node] = node_direction end if side == :client and direction.direction == :left node_direction.in_direction = direction elsif side == :client and direction.direction == :right node_direction.out_direction = direction elsif side == :server and direction.direction == :left node_direction.out_direction = direction elsif side == :server and direction.direction == :right node_direction.in_direction = direction end end node_directions.values end |
#get_sequence(name) ⇒ Object
287 288 289 290 291 292 293 294 295 296 297 |
# File 'lib/runtime.rb', line 287 def get_sequence name sequence = @sequences[name] return sequence if sequence != nil @includes.each do |i| sequence = i.get_sequence name return sequence if sequence != nil end return nil end |
#get_type(name) ⇒ Object
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/runtime.rb', line 249 def get_type name type_def = @builtins[name] return type_def, self if type_def != nil type_def = @enums[name] return type_def, self if type_def != nil type_def = @structs[name] return type_def, self if type_def != nil @includes.each do |i| type_def = i.get_type name return type_def, i if type_def != nil end return nil, self end |
#init_builtins ⇒ Object
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/runtime.rb', line 211 def init_builtins type_names = [ 'Bool', 'Byte', 'Short', 'Int', 'Long', 'UShort', 'UInt', 'ULong', 'Float', 'Double', 'String', 'DateTime', 'ByteBuffer', 'List', 'Set', 'Map', 'Vector2', 'Vector3', 'Color', ] type_names.each { |t| @builtins[t] = BuiltinTypeDef.new t } end |