class Runtime

Attributes

builtins[R]
directions[R]
enums[R]
filename[R]
nodes[R]
sequences[R]
structs[R]
version[RW]

Public Class Methods

new(filename) click to toggle source
# File lib/runtime.rb, line 198
def initialize filename
        @filename = filename
        @builtins = {}
        @version = 1
        @enums = {}
        @nodes = {}
        @structs = {}
        @directions = []
        @sequences = {}

        self.init_builtins
end

Public Instance Methods

add_direction(direction_def) click to toggle source
# File lib/runtime.rb, line 262
def add_direction direction_def
        @directions.push direction_def
end
add_enum(enum_def) click to toggle source
# File lib/runtime.rb, line 236
def add_enum enum_def
        @enums[enum_def.name] = enum_def
end
add_node(node_def) click to toggle source
# 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) click to toggle source
# File lib/runtime.rb, line 273
def add_sequence sequence_def
        @sequences[sequence_def.name] = sequence_def
end
add_struct(struct_def) click to toggle source
# File lib/runtime.rb, line 245
def add_struct struct_def
        @structs[struct_def.name] = struct_def
end
get_direction(client, direction, server) click to toggle source
# File lib/runtime.rb, line 266
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

        return nil
end
get_node_directions(node, side) click to toggle source
# File lib/runtime.rb, line 284
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) click to toggle source
# File lib/runtime.rb, line 277
def get_sequence name
        sequence = @sequences[name]
        return sequence if sequence != nil

        return nil
end
get_type(name) click to toggle source
# 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

        return nil, self
end
init_builtins() click to toggle source
# 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