コード例 #1
0
ファイル: list.go プロジェクト: sneakyweasel/algernon
// Create a new list.
// id is the name of the list.
// dbindex is the Redis database index (typically 0).
func newList(L *lua.LState, creator pinterface.ICreator, id string) (*lua.LUserData, error) {
	// Create a new list
	list, err := creator.NewList(id)
	if err != nil {
		return nil, err
	}
	// Create a new userdata struct
	ud := L.NewUserData()
	ud.Value = list
	L.SetMetatable(ud, L.GetTypeMetatable(lListClass))
	return ud, nil
}
コード例 #2
0
ファイル: codelib.go プロジェクト: sneakyweasel/algernon
// Create a new code library.
// id is the name of the hash map.
func newCodeLibrary(L *lua.LState, creator pinterface.ICreator, id string) (*lua.LUserData, error) {
	// Create a new Lua Library (hash map)
	lualib, err := creator.NewKeyValue(id)
	if err != nil {
		return nil, err
	}
	// Create a new userdata struct
	ud := L.NewUserData()
	ud.Value = lualib
	L.SetMetatable(ud, L.GetTypeMetatable(lLibraryClass))
	return ud, nil
}
コード例 #3
0
ファイル: keyvalue.go プロジェクト: sneakyweasel/algernon
// Create a new KeyValue collection.
// id is the name of the KeyValue colleciton.
// dbindex is the Redis database index (typically 0).
func newKeyValue(L *lua.LState, creator pinterface.ICreator, id string) (*lua.LUserData, error) {
	// Create a new key/value
	kv, err := creator.NewKeyValue(id)
	if err != nil {
		return nil, err
	}
	// Create a new userdata struct
	ud := L.NewUserData()
	ud.Value = kv
	L.SetMetatable(ud, L.GetTypeMetatable(lKeyValueClass))
	return ud, nil
}
コード例 #4
0
ファイル: hashmap.go プロジェクト: sneakyweasel/algernon
// Create a new hash map.
// id is the name of the hash map.
// dbindex is the Redis database index (typically 0).
func newHashMap(L *lua.LState, creator pinterface.ICreator, id string) (*lua.LUserData, error) {
	// Create a new hash map
	hash, err := creator.NewHashMap(id)
	if err != nil {
		return nil, err
	}
	// Create a new userdata struct
	ud := L.NewUserData()
	ud.Value = hash
	L.SetMetatable(ud, L.GetTypeMetatable(lHashClass))
	return ud, nil
}