use unsafe_load() to convert the value to a julia object, then
> unsafe_store() to write the new struct back.
>
> at some point, I want to modify unsafe_load/unsafe_store to take a
> fieldname symbol as the second argument to make this functionality more
> direct available. however, there hasn't seemed to be a request / issue open
> for it yet.
>
PLEASE, do.
I have the same type of problem but I'm not able to solve it with the
solutions proposed in this thread.
See, I have this and want to change the *rgb_low*
julia> gmt_lut = unsafe_load(C.range, 1);
julia> gmt_lut.rgb_low
GMT.Array_4_Cdouble(0.583333333333333,0.0,1.0,0.0)
which is a
immutable Array_4_Cdouble
d1::Cdouble
d2::Cdouble
d3::Cdouble
d4::Cdouble
end
so I do
julia> z = GMT.Array_4_Cdouble(0.0, 0.0, 0.0, 0.0)
GMT.Array_4_Cdouble(0.0,0.0,0.0,0.0)
julia> unsafe_store!(pointer([gmt_lut.rgb_low]), z)
Ptr{GMT.Array_4_Cdouble} @0x00000000819faf60
no errors but I don't know where new *z* immutable landed on because I keep
seeing the old value
julia> gmt_lut.rgb_low
GMT.Array_4_Cdouble(0.583333333333333,0.0,1.0,0.0)
I suspect part of it is dues to the pointer([gmt_lut.rgb_low]) command
because when I do several of those on line I keep getting different
addresses
julia> pointer([gmt_lut.rgb_low])
Ptr{GMT.Array_4_Cdouble} @0x0000000082b7baf0
julia> pointer([gmt_lut.rgb_low])
Ptr{GMT.Array_4_Cdouble} @0x0000000082ba00d0
julia> pointer([gmt_lut.rgb_low])
Ptr{GMT.Array_4_Cdouble} @0x0000000082ba0670
but than how can modify this field(s)?