func (lo *LuaObject) Iter() (*LuaTableIter, error) {
	L := lo.l
	lo.Push()
	defer L.Pop(1)
	if L.IsTable(-1) {
		return &LuaTableIter{lo: lo, keyRef: lua.LUA_NOREF, iterRef: lua.LUA_NOREF}, nil
	} else if L.GetMetaField(-1, "__pairs") {
		// __pairs(t) = iterator, t, first-key.
		L.PushValue(-2)
		// Only keep iterator on stack, hence '1' result only.
		err := L.Call(1, 1)
		if err != nil {
			L.Pop(1)
			return nil, err
		}
		ref := L.Ref(lua.LUA_REGISTRYINDEX)
		return &LuaTableIter{lo: lo, keyRef: lua.LUA_NOREF, iterRef: ref}, nil
	} else {
		return nil, ErrLuaObjectIndexable
	}
}
func (lo *LuaObject) Iter() (*LuaTableIter, error) {
	L := lo.l
	lo.Push()
	defer L.Pop(1)
	if L.IsTable(-1) {
		return &LuaTableIter{lo: lo, keyRef: lua.LUA_NOREF, iterRef: lua.LUA_NOREF}, nil
	} else if L.GetMetaField(-1, "__pairs") {
		
		L.PushValue(-2)
		
		err := L.Call(1, 1)
		if err != nil {
			L.Pop(1)
			return nil, err
		}
		ref := L.Ref(lua.LUA_REGISTRYINDEX)
		return &LuaTableIter{lo: lo, keyRef: lua.LUA_NOREF, iterRef: ref}, nil
	} else {
		return nil, ErrLuaObjectIndexable
	}
}
func ( lo * LuaObject ) Iter ( ) ( * LuaTableIter , error ) { L := lo . l lo . Push ( ) defer L . Pop ( 1 ) if L . IsTable ( - 1 ) { return & LuaTableIter { lo : lo , keyRef : lua . LUA_NOREF , iterRef : lua . LUA_NOREF } , nil } else if L . GetMetaField ( - 1 , " " ) { // __pairs(t) = iterator, t, first-key. L . PushValue ( - 2 ) // Only keep iterator on stack, hence '1' result only. err := L . Call ( 1 , 1 ) if err != nil { L . Pop ( 1 ) return nil , err } ref := L . Ref ( lua . LUA_REGISTRYINDEX ) return & LuaTableIter { lo : lo , keyRef : lua . LUA_NOREF , iterRef : ref } , nil } else { return nil , ErrLuaObjectIndexable } }
// Iter creates a Lua iterator.
Iter creates a Lua iterator .