func main() { var L *lua.State L = lua.NewState() L.OpenLibs() rawptr := L.NewUserdata(uintptr(unsafe.Sizeof(Userdata{}))) var ptr *Userdata ptr = (*Userdata)(rawptr) ptr.a = 2 ptr.b = 3 fmt.Println(ptr) rawptr2 := L.ToUserdata(-1) ptr2 := (*Userdata)(rawptr2) fmt.Println(ptr2) }
func valueOfProxy(L *lua.State, idx int) (reflect.Value, reflect.Type) { vp := (*ValueProxy)(L.ToUserdata(idx)) return vp.value, vp.t }