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 Marshalable
- type Named
- type Params
- type PartialCallback
- type Renamable
- type Request
- type Result
- type Table
- type Unmarshalable
- 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) Marshal(source interface{}) (value *Value, err error)
- func (v *VM) Module(name string, module 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 MARSHALABLE = reflect.TypeOf((*Marshalable)(nil)).Elem()
var (
METHOD_REGEX = regexp.MustCompile("^# doc: (\\w+)$")
)
var UNMARSHALABLE = reflect.TypeOf((*Unmarshalable)(nil)).Elem()
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 Marshalable ¶ added in v0.4.0
type Marshalable interface {
MarshalJanet() interface{}
}
Marshalable lets you define a custom (pure) transformation to perform on this type prior to translating it into a Janet value.
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?".
type Unmarshalable ¶ added in v0.4.0
Unmarshalable lets you define custom code for turning a Janet value into this type.
type VM ¶
type VM struct { deadlock.RWMutex // contains filtered or unexported fields }
func (*VM) ExecuteCall ¶
func (*VM) Lookup ¶ added in v0.1.17
Lookup finds a previously registered callback by its Janet name and returns it.