36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
do local strptr = (lib.mem.ptr(int8))
local strref = (lib.mem.ref(int8))
local byteptr = (lib.mem.ptr(uint8))
local function install_funcs(ty)
ty.metamethods.__cast = function(from,to,e)
local v = e:asvalue()
if type(v) == 'string' then
print('hard-coding pstr',v,#v)
return `ty {ptr = v, ct = [#v]}
elseif from == &int8 then
return `ty {ptr = e, ct = m.sz(e)}
elseif to == &int8 then
return e.ptr
end
end
|
|
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
do local strptr = (lib.mem.ptr(int8))
local strref = (lib.mem.ref(int8))
local byteptr = (lib.mem.ptr(uint8))
local function install_funcs(ty)
ty.metamethods.__cast = function(from,to,e)
local v = e:asvalue()
if type(v) == 'string' then
return `ty {ptr = v, ct = [#v]}
elseif from == &int8 then
return `ty {ptr = e, ct = m.sz(e)}
elseif to == &int8 then
return e.ptr
end
end
|