janet

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: MIT Imports: 13 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",
}
View Source
var (
	METHOD_REGEX = regexp.MustCompile("^# doc: (\\w+)$")
)

Functions

func IsValidType added in v0.1.6

func IsValidType(value interface{}) bool

IsValidType returns true if the given value can be translated to a Janet value.

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 Callback

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

type Docstrings added in v0.1.6

type Docstrings interface {
	Docstrings() map[string]string
}

Docstrings provides docstrings for module methods. This is a mapping from the method's Go name to its Janet docstring.

type Documented added in v0.1.6

type Documented interface {
	Documentation() string
}

Documented provides documentation in the form of a Markdown-formatted string. All of the lines following a top-level Markdown header with a title that matches a Go method name will be included as the Janet documentation for that method.

For example, providing a string that looks like this: ``` # doc: SomeMethod This is some documentation # doc: SomeMethodB This is some other documentation ``` Will result in SomeMethod and SomeMethodB having those docstrings.

type Fiber

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

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 Keyword added in v0.1.5

type Keyword string

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
}

Renamable provides a mapping from Go method names to Janet function names. This is useful for declaring Janet functions that are not valid Go, such as "boolean?".

type Request

type Request interface{}

type Result

type Result struct {
	Out   *Value
	Error error
}

type Table

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

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, docstring string, callback interface{}) error

func (*VM) Env added in v0.1.6

func (v *VM) Env() *Table

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

func (*VM) Unmarshal added in v0.1.11

func (v *VM) Unmarshal(source C.Janet, dest 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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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