luawpk

package
v1.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TTany = iota
	TTbin
	TTstr
	TTbool
	TTuint
	TTnum
	TTtime
)
View Source
const ISO8601 = "2006-01-02T15:04:05.999Z07:00"
View Source
const PackMT = "wpk"

PackMT is "wpk" name of Lua metatable.

Variables

View Source
var (
	ErrPackOpened = errors.New("package write stream already opened")
	ErrPackClosed = errors.New("package write stream does not opened")
	ErrDataClosed = errors.New("package data file is not opened")
)

Package writer errors.

View Source
var (
	ErrBadTagKey = errors.New("tag key type is not number or string")
	ErrBadTagVal = errors.New("tag value type is not string or boolean or 'tag' userdata")
)

Tags identifiers conversion errors.

View Source
var (
	// compiled binary version, sets by compiler with command
	//    go build -ldflags="-X 'github.com/schwarzlichtbezirk/wpk/luawpk.BuildVers=%buildvers%'"
	BuildVers string

	// compiled binary build date, sets by compiler with command
	//    go build -ldflags="-X 'github.com/schwarzlichtbezirk/wpk/luawpk.BuildTime=%buildtime%'"
	BuildTime string
)
View Source
var MimeExt = map[string]string{}/* 123 elements not displayed */

MimeExt - map of files extensions and associated MIME types.

View Source
var NameTid = map[string]wpk.TID{
	"offset": wpk.TIDoffset,
	"size":   wpk.TIDsize,
	"path":   wpk.TIDpath,
	"fid":    wpk.TIDfid,
	"mtime":  wpk.TIDmtime,
	"atime":  wpk.TIDatime,
	"ctime":  wpk.TIDctime,
	"btime":  wpk.TIDbtime,
	"attr":   wpk.TIDattr,
	"mime":   wpk.TIDmime,

	"crc32":     wpk.TIDcrc32c,
	"crc32ieee": wpk.TIDcrc32ieee,
	"crc32c":    wpk.TIDcrc32c,
	"crc32k":    wpk.TIDcrc32k,
	"crc64":     wpk.TIDcrc64iso,
	"crc64iso":  wpk.TIDcrc64iso,

	"md5":    wpk.TIDmd5,
	"sha1":   wpk.TIDsha1,
	"sha224": wpk.TIDsha224,
	"sha256": wpk.TIDsha256,
	"sha384": wpk.TIDsha384,
	"sha512": wpk.TIDsha512,

	"tmbjpeg":  wpk.TIDtmbjpeg,
	"tmbwebp":  wpk.TIDtmbwebp,
	"label":    wpk.TIDlabel,
	"link":     wpk.TIDlink,
	"keywords": wpk.TIDkeywords,
	"category": wpk.TIDcategory,
	"version":  wpk.TIDversion,
	"author":   wpk.TIDauthor,
	"comment":  wpk.TIDcomment,
}

NameTid helps convert Lua-table string keys to associated TID values.

View Source
var TidName = func() map[wpk.TID]string {
	var tn = map[wpk.TID]string{}
	for name, tid := range NameTid {
		tn[tid] = name
	}
	return tn
}()

TidName helps format Lua-tables with string keys associated to TID values.

TidType helps to convert raw tags to Lua values.

Functions

func InitLuaVM added in v1.6.3

func InitLuaVM(ls *lua.LState)

InitLuaVM performs initial registrations.

func NewPack

func NewPack(ls *lua.LState) int

NewPack is LuaPackage constructor.

func PushPack

func PushPack(ls *lua.LState, v *LuaPackage)

PushPack push LuaPackage object into stack.

func RegPack

func RegPack(ls *lua.LState)

RegPack registers "wpk" userdata into Lua virtual machine.

func RegPath added in v1.6.3

func RegPath(ls *lua.LState)

RegPath registers "path" namespace into Lua virtual machine.

func RunLuaVM

func RunLuaVM(fpath string) (err error)

RunLuaVM runs specified Lua-script with Lua WPK API.

func TableToTagset

func TableToTagset(lt *lua.LTable, ts wpk.TagsetRaw) (wpk.TagsetRaw, error)

TableToTagset converts Lua-table to TagsetRaw. Lua-table keys can be number identifiers or string names associated ID values. Lua-table values can be strings, numbers, or boolean values.

func TagToValue added in v1.6.0

func TagToValue(tid wpk.TID, tag wpk.TagRaw) (v lua.LValue, err error)

func ValueToTID added in v1.3.0

func ValueToTID(k lua.LValue) (tid wpk.TID, err error)

ValueToTID converts LValue to uint16 tag identifier. Numbers converts explicitly, strings converts to uint16 values which they presents. Error returns on any other case.

func ValueToTag

func ValueToTag(tid wpk.TID, v lua.LValue) (tag wpk.TagRaw, err error)

ValueToTag converts LValue to TagRaw. Strings converts explicitly to byte sequence, boolen converts to 1 byte slice with 1 for 'true' and 0 for 'false'. Otherwise if it is not 'tag' uservalue with TagRaw, returns error.

Types

type ErrKeyUndef

type ErrKeyUndef struct {
	TagKey string
}

ErrKeyUndef represents error on tag identifiers string presentation.

func (*ErrKeyUndef) Error

func (e *ErrKeyUndef) Error() string

type ErrProtected

type ErrProtected struct {
	// contains filtered or unexported fields
}

ErrProtected is "protected tag" error.

func (*ErrProtected) Error

func (e *ErrProtected) Error() string

type LuaPackage

type LuaPackage struct {
	wpk.Package
	// contains filtered or unexported fields
}

LuaPackage is "wpk" userdata structure.

func CheckPack

func CheckPack(ls *lua.LState, arg int) *LuaPackage

CheckPack checks whether the lua argument with given number is a *LUserData with *LuaPackage and returns this *LuaPackage.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL