closure

package
v0.0.0-...-b87070f Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2021 License: ISC Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const FrameSize = 3

FrameSize is the number of frames that FuncStack should trace back from.

Variables

This section is empty.

Functions

This section is empty.

Types

type FuncStack

type FuncStack struct {
	Func   reflect.Value
	Frames []uintptr
}

FuncStack wraps a function value and provides function frames containing the caller trace for debugging.

func NewFuncStack

func NewFuncStack(fn interface{}, frameSkip int) *FuncStack

NewFuncStack creates a new FuncStack. It panics if fn is not a function. The given frameSkip is added 2, meaning the first frame from 0 will start from the caller of NewFuncStack.

func NewIdleFuncStack

func NewIdleFuncStack(fn interface{}, frameSkip int) *FuncStack

NewIdleFuncStack works akin to NewFuncStack, but it also validates the given function type for the correct acceptable signatures for SourceFunc while also caching the checks.

func (*FuncStack) IsValid

func (fs *FuncStack) IsValid() bool

IsValid returns true if the given FuncStack is not a zero-value i.e. valid.

func (*FuncStack) Panicf

func (fs *FuncStack) Panicf(msgf string, v ...interface{})

Panicf panics with the given FuncStack printed to standard error.

func (*FuncStack) TryRepanic

func (fs *FuncStack) TryRepanic()

TryRepanic attempts to recover a panic. If successful, it will re-panic with the trace, or none if there is already one.

type Registry

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

Registry describes the local closure registry of each object.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates an empty closure registry.

func (*Registry) Delete

func (r *Registry) Delete(gclosure unsafe.Pointer)

Delete deletes the given GClosure callback.

func (*Registry) Load

func (r *Registry) Load(gclosure unsafe.Pointer) *FuncStack

Load loads the given GClosure's callback. Nil is returned if it's not found.

func (*Registry) Register

func (r *Registry) Register(gclosure unsafe.Pointer, callback *FuncStack)

Register registers the given GClosure callback.

Jump to

Keyboard shortcuts

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