85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
# File 'lib/grm.rb', line 85
def push(key, value)
key = key.to_s if key.is_a?(Symbol)
case value
when String
GRM.args_push(@args, key, "s", :const_string, value)
when Integer
GRM.args_push(@args, key, "i", :int, value)
when Float
GRM.args_push(@args, key, "d", :double, value)
when Args
GRM.args_push(@args, key, "a", :voidp, value.address)
value.to_gr.free = nil
when Array
case value[0]
when String
addresses = value.collect {|v| Fiddle::Pointer[v].to_i}
GRM.args_push(@args, key, "nS",
:int, value.size,
:voidp, addresses.pack("J*"))
when Integer
GRM.args_push(@args, key, "nI",
:int, value.size,
:voidp, value.pack("i*"))
when Float
GRM.args_push(@args, key, "nD",
:int, value.size,
:voidp, value.pack("d*"))
when Args
GRM.args_push(@args, key, "nA",
:int, value.size,
:voidp, value.collect(&:address).pack("J*"))
value.each do |v|
v.to_gr.free = nil
end
else
vs = value.collect {|v| Args.new(**v)}
@references.concat(vs)
GRM.args_push(@args, key, "nA",
:int, value.size,
:voidp, vs.collect(&:address).pack("J*"))
vs.each do |v|
v.to_gr.free = nil
end
end
else
v = Args.new(**value)
@references << v
GRM.args_push(@args, key, "a", :voidp, v.address)
v.to_gr.free = nil
end
end
|