core

package
v0.0.0-...-dbc11f2 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2019 License: BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddExec

func AddExec(L *lua.LState, m *lua.LTable)

AddExec adds the exec package to the lua table m

func AddReader

func AddReader(L *lua.LState, m *lua.LTable)

AddReader is the module loader function for lualib.reader

func AddTimer

func AddTimer(L *lua.LState, m *lua.LTable)

AddTimer adds the exec package to the lua table m

func Loader

func Loader(L *lua.LState) int

func OpenCore

func OpenCore(L *lua.LState)

func OpenCoreWithName

func OpenCoreWithName(name string, L *lua.LState)

Types

type LineCallbackOptions

type LineCallbackOptions struct {
	// PrefixArgs holds a list of arguments that should be passed to the callback
	// before the actual line
	PrefixArgs []lua.LValue

	// SuffixArgs holds a list of arguments that should be passed to the callback
	// after the actual line
	SuffixArgs []lua.LValue
}

LineCallbackOptions holds additional options for Reader.WithLineCallback

type Reader

type Reader struct {
	io.Reader
}

Reader wraps the io.Reader interface into a dedicated type exposed to Lua

func NewReader

func NewReader(L *lua.LState, source io.Reader) (*lua.LUserData, *Reader)

NewReader is a utility method that creates a new reader object. The returned LUserData still needs to be pushed to the Lua stack using L.Push

func (*Reader) Close

func (r *Reader) Close() error

Close implements io.ReadCloser

func (*Reader) WithLineCallback

func (r *Reader) WithLineCallback(lineCb callback.Callback, opts *LineCallbackOptions)

WithLineCallback starts reading from the reader and calls the provided callback for each line

type Timer

type Timer struct {
	*TimerOptions
	// contains filtered or unexported fields
}

func NewTimer

func NewTimer(L *lua.LState, opts TimerOptions) (*lua.LUserData, *Timer)

NewTimer creates a new timer for the given lua.LState. Note that the caller is responsible for initializing the timer by calling .Init(). Passing the timer-object to lua without calling .Init() may have strange side-effects

func (*Timer) Again

func (t *Timer) Again()

Again restart the time. This is equalent to calling .Stop() and .Start()

func (*Timer) Init

func (t *Timer) Init(L *lua.LState) error

Init initializes the timer. If CallNow is set, Init() will try to execute the callback. In this case, if L is provided, the callback function will run immediately. If L is nil, the callback is scheduled on the loop and Init() will wait for it to finish. Note that the caller MUST provide L if it's currently running inside the loop. Otherwise it will deadlock. The returned error will always be nil if CallNow is set to false. If the callback is invoked immediately, the returned error may be a lua error

func (*Timer) IsStarted

func (t *Timer) IsStarted() bool

IsStarted returns true if the timer is started

func (*Timer) Start

func (t *Timer) Start()

Start starts the timer if its not running

func (*Timer) Stop

func (t *Timer) Stop()

Stop stops the timer if its running

type TimerOptions

type TimerOptions struct {
	// Timeout for the timer. After each timeout, the Callback function is invoked
	// this field MUST be set
	Timeout time.Duration

	// Autostart defines whether the time should start immediately
	Autostart bool

	// CallNow defines whether the callback function should be triggered immediately
	CallNow bool

	// Callback is the actual callback function to invoke
	Callback callback.Callback

	// SingleShot configures the timer to automaticall stop after the first timeout
	SingleShot bool
}

TimerOptions holds configuration options for a new timer

Jump to

Keyboard shortcuts

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