ruby: fix assigning value to pointer to number

develop
jj 2012-10-12 13:33:58 +02:00
parent 1f88c0eeed
commit c089534f73
1 changed files with 13 additions and 1 deletions

@ -282,6 +282,10 @@ module DFHack
DFHack.memory_read_int32(@_memaddr) & 0xffffffff
end
def _setp(v)
DFHack.memory_write_int32(@_memaddr, v)
end
def _get
addr = _getp
return if addr == 0
@ -294,7 +298,15 @@ module DFHack
case v
when Pointer; DFHack.memory_write_int32(@_memaddr, v._getp)
when MemStruct; DFHack.memory_write_int32(@_memaddr, v._memaddr)
when Integer; DFHack.memory_write_int32(@_memaddr, v)
when Integer
if @_tg and @_tg.kind_of?(MemHack::Number)
if _getp == 0
_setp(DFHack.malloc(@_tg._bits/8))
end
@_tg._at(_getp)._set(v)
else
DFHack.memory_write_int32(@_memaddr, v)
end
when nil; DFHack.memory_write_int32(@_memaddr, 0)
else _get._set(v)
end