Method: Efl::EcoreGetopt::REcoreGetopt#set_value

Defined in:
lib/efl/ecore_getopt.rb

#set_value(key, ptype, val = nil) ⇒ Object

[View source]

132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/efl/ecore_getopt.rb', line 132

def set_value key, ptype, val=nil
    skey = key.to_s
    r = @values[skey]
    if r.nil?
        case ptype
        when :list
            p = FFI::MemoryPointer.new :pointer
            p.write_pointer val[0]
            r = @values[skey] = [ ptype, p, val[1] ]    # add sub_type info
        when :choice
            p = FFI::MemoryPointer.new :pointer
            p.write_pointer FFI::Pointer::NULL
            r = @values[skey] = [ ptype, p ]
        when :string
            p = FFI::MemoryPointer.new :pointer
            p.write_pointer FFI::Pointer::NULL
            r = @values[skey] = [ ptype, p ]
        when :pointer
            r = @values[skey] = [ ptype, val ]
        else
            p = FFI::MemoryPointer.new ptype
            p.send 'write_'+ptype.to_s, val unless val.nil?
            r = @values[skey] = [ ptype, p ]
        end
        @pts << p
    end
    @values_order.insert -2, skey
    r
end