janet

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: MIT Imports: 12 Imported by: 0

README

go-janet

To update the janet version, clone it and run make, then copy build/c/janet.c, src/include/janet.h, and src/conf/janetconf.h to this directory.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEFAULT_CALL_OPTIONS = CallOptions{
	UpdateEnv: true,
}
View Source
var ERROR_FREED = fmt.Errorf("cannot use freed value")
View Source
var GO_BOOT_FILE []byte
View Source
var JANET_TYPE_TO_STRING map[C.JanetType]string = map[C.JanetType]string{
	C.JANET_NUMBER:    "number",
	C.JANET_NIL:       "nil",
	C.JANET_BOOLEAN:   "boolean",
	C.JANET_FIBER:     "fiber",
	C.JANET_STRING:    "string",
	C.JANET_SYMBOL:    "symbol",
	C.JANET_KEYWORD:   "keyword",
	C.JANET_ARRAY:     "array",
	C.JANET_TUPLE:     "tuple",
	C.JANET_TABLE:     "table",
	C.JANET_STRUCT:    "struct",
	C.JANET_BUFFER:    "buffer",
	C.JANET_FUNCTION:  "function",
	C.JANET_CFUNCTION: "cfunction",
	C.JANET_ABSTRACT:  "abstract",
	C.JANET_POINTER:   "pointer",
}

Functions

This section is empty.

Types

type Call

type Call struct {
	Code       []byte
	SourcePath string
	Options    CallOptions
}

func CallBytes

func CallBytes(data []byte) Call

func CallString

func CallString(code string) Call

type CallOptions

type CallOptions struct {
	// Whether to allow the code to mutate the current environment.
	UpdateEnv bool
}

type CallRequest

type CallRequest struct {
	Params
	Call
}

type Callback

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

type Fiber

type Fiber struct {
	*Value
	// contains filtered or unexported fields
}

type FiberRequest

type FiberRequest struct {
	Params
	// The fiber to run
	Fiber Fiber
	// The value with which to resume
	In *Value
}

type Function

type Function struct {
	*Value
	// contains filtered or unexported fields
}

func (*Function) Call

func (f *Function) Call(ctx context.Context, params ...interface{}) error

func (*Function) CallContext

func (f *Function) CallContext(
	ctx context.Context,
	user interface{},
	params ...interface{},
) error

type FunctionRequest

type FunctionRequest struct {
	Params
	Args     []interface{}
	Function *Function
}

type Named

type Named[T any] struct {
	// contains filtered or unexported fields
}

func (*Named[T]) Values

func (n *Named[T]) Values() T

func (*Named[T]) WithDefault

func (n *Named[T]) WithDefault(defaults T) T

type Params

type Params struct {
	Context context.Context
	User    interface{}
	Result  chan Result
}

func (Params) Error

func (p Params) Error(err error)

func (Params) Ok

func (p Params) Ok()

func (Params) Out

func (p Params) Out(value *Value)

func (Params) Pipe

func (p Params) Pipe() Params

Make new Params with an overwritten Result channel.

func (Params) Wait

func (p Params) Wait() error

type PartialCallback

type PartialCallback struct {
	Type reflect.Type
	// contains filtered or unexported fields
}

func (*PartialCallback) Call

func (p *PartialCallback) Call() []reflect.Value

type Renamable

type Renamable interface {
	Renames() map[string]string
}

Allow the user to rename struct methods arbitrarily.

type Request

type Request interface{}

type ResolveRequest

type ResolveRequest struct {
	Params
	Fiber Fiber
	// The type signature of the callback
	Type reflect.Type
	// The results of the function call
	Out []reflect.Value
}

A request to receive the result of a callback.

type Result

type Result struct {
	Out   *Value
	Error error
}

type Table

type Table struct {
	*Value
	// contains filtered or unexported fields
}

type UnlockRequest

type UnlockRequest struct {
	Value *Value
}

type VM

type VM struct {
	deadlock.RWMutex
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context) (*VM, error)

func (*VM) Callback

func (v *VM) Callback(name string, callback interface{}) error

func (*VM) Execute

func (v *VM) Execute(ctx context.Context, code string) error

func (*VM) ExecuteCall

func (v *VM) ExecuteCall(ctx context.Context, user interface{}, call Call) error

func (*VM) ExecuteFile

func (v *VM) ExecuteFile(ctx context.Context, path string) error

func (*VM) Module

func (v *VM) Module(name string, module interface{}) error

type Value

type Value struct {
	deadlock.RWMutex
	// contains filtered or unexported fields
}

func (*Value) Free

func (v *Value) Free()

func (*Value) IsFree

func (v *Value) IsFree() bool

func (*Value) Unmarshal

func (v *Value) Unmarshal(dest interface{}) error

Jump to

Keyboard shortcuts

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