Documentation ¶
Index ¶
- Variables
- func IsValidType(value interface{}) bool
- type Call
- type CallOptions
- type Callback
- type Docstrings
- type Documented
- type Fiber
- type Function
- type Keyword
- type Named
- type Params
- type PartialCallback
- type Renamable
- type Request
- type Result
- type Table
- type VM
- func (v *VM) Callback(name string, docstring string, callback interface{}) error
- func (v *VM) Env() *Table
- func (v *VM) Execute(ctx context.Context, code string) error
- func (v *VM) ExecuteCall(ctx context.Context, user interface{}, call Call) error
- func (v *VM) ExecuteFile(ctx context.Context, path string) error
- func (v *VM) Lookup(name string) (callback *Callback, ok bool)
- func (v *VM) Module(name string, module interface{}) error
- func (v *VM) Unmarshal(source C.Janet, dest interface{}) error
- type Value
Constants ¶
This section is empty.
Variables ¶
var DEFAULT_CALL_OPTIONS = CallOptions{ UpdateEnv: true, }
var ERROR_FREED = fmt.Errorf("cannot use freed value")
var GO_BOOT_FILE []byte
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", }
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 CallString ¶
type CallOptions ¶
type CallOptions struct { // Whether to allow the code to mutate the current environment. UpdateEnv bool }
type Docstrings ¶ added in v0.1.6
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 Named ¶
type Named[T any] struct { // contains filtered or unexported fields }
func (*Named[T]) WithDefault ¶
func (n *Named[T]) WithDefault(defaults T) T
type PartialCallback ¶
func (*PartialCallback) Call ¶
func (p *PartialCallback) Call() []reflect.Value
type Renamable ¶
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?".