func RegProxyIpairs(L *lua.State, table, name string) {
	L.GetGlobal("ipairs")
	ref := L.Ref(lua.LUA_REGISTRYINDEX)

	f := func(L *lua.State) int {
		// See Lua >=5.2 source code.
		if L.GetMetaField(1, "__ipairs") {
			L.PushValue(1)
			L.Call(1, 3)
			return 3
		}
		L.RawGeti(lua.LUA_REGISTRYINDEX, ref)
		L.PushValue(1)
		L.Call(1, 3)
		return 3
	}

	Register(L, table, Map{
		name: f,
	})
}
func RegProxyIpairs(L *lua.State, table, name string) {
	L.GetGlobal("ipairs")
	ref := L.Ref(lua.LUA_REGISTRYINDEX)

	f := func(L *lua.State) int {
		// See Lua >=5.2 source code.
		if L.GetMetaField(1, "__ipairs") {
			L.PushValue(1)
			L.Call(1, 3)
			return 3
		}
		L.RawGeti(lua.LUA_REGISTRYINDEX, ref)
		L.PushValue(1)
		L.Call(1, 3)
		return 3
	}

	Register(L, table, Map{
		name: f,
	})
}
// Register a function 'table.name' equivalent to ProxyIpairs that uses 'ipairs'
// when '__ipairs' is not present.
//
// This is much faster than ProxyIpairs.