gomini

package module
v0.0.0-...-af991f4 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2018 License: Apache-2.0 Imports: 24 Imported by: 0

README

gomini

Go + Typescript for Embedded development? Not Possible? It is, Gomini!

What does Gomini mean?

Gomini is actually a combination of Go(lang) and Mini(mal) which both is related to embedded (small) device development and also, and that becomes clear when digging into the codebase, it also stands for Gemini. The astrological sign of the Zodiac. Gemini is, again, used for two reasons; the twins represent Go and Typescript and Zodiac is the device this framework was originally developed for.

Documentation

Index

Constants

View Source
const (
	KernelVfsAppsPath     = "/kernel/apps"
	KernelVfsCachePath    = "/kernel/cache"
	KernelVfsTypesPath    = "/kernel/@types"
	KernelVfsWritablePath = "/kernel/data"
)

Variables

This section is empty.

Functions

func IsKernelFile

func IsKernelFile(filesystem afero.Fs, name string) bool

Types

type Any

type Any interface{}

type ApiProviderBinder

type ApiProviderBinder func(kernel Bundle, bundle Bundle, builder ObjectCreator)

type Bundle

type Bundle interface {
	ID() string
	Name() string
	Privileged() bool
	Privileges() []string
	SecurityInterceptor() SecurityInterceptor
	Export(value Value, target interface{}) error
	Status() BundleStatus
	Filesystem() afero.Fs

	Null() Value
	Undefined() Value

	NewObjectBuilder(objectName string) ObjectCreator
	NewObject() Object
	NewException(err error) Object
	ToValue(value interface{}) Value
	FreezeObject(object Object)
	DeepFreezeObject(object Object)
	NewTypeError(args ...interface{}) Value
	Sandbox() Sandbox
	// contains filtered or unexported methods
}

type BundleFilesystemConfig

type BundleFilesystemConfig struct {
	NewModuleFilesystem func() (afero.Fs, error)
	// contains filtered or unexported fields
}

type BundleStatus

type BundleStatus int
const (
	BundleStatusStopped BundleStatus = iota
	BundleStatusStarted
	BundleStatusStarting
	BundleStatusStopping
	BundleStatusDownloading
	BundleStatusUpdating
	BundleStatusFailed
	BundleStatusInstalled
)

func (BundleStatus) String

func (b BundleStatus) String() string

type Callable

type Callable func(this Value, arguments ...Value) (Value, error)

type CompositeFs

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

func NewCompositeFs

func NewCompositeFs(base afero.Fs) *CompositeFs

func (*CompositeFs) Chmod

func (c *CompositeFs) Chmod(name string, mode os.FileMode) error

func (*CompositeFs) Chtimes

func (c *CompositeFs) Chtimes(name string, atime time.Time, mtime time.Time) error

func (*CompositeFs) Create

func (c *CompositeFs) Create(name string) (afero.File, error)

func (*CompositeFs) Mkdir

func (c *CompositeFs) Mkdir(name string, perm os.FileMode) error

func (*CompositeFs) MkdirAll

func (c *CompositeFs) MkdirAll(path string, perm os.FileMode) error

func (*CompositeFs) Mount

func (c *CompositeFs) Mount(mount afero.Fs, path string) error

func (*CompositeFs) Name

func (c *CompositeFs) Name() string

func (*CompositeFs) Open

func (c *CompositeFs) Open(name string) (afero.File, error)

func (*CompositeFs) OpenFile

func (c *CompositeFs) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error)

func (*CompositeFs) Remove

func (c *CompositeFs) Remove(name string) error

func (*CompositeFs) RemoveAll

func (c *CompositeFs) RemoveAll(path string) error

func (*CompositeFs) Rename

func (c *CompositeFs) Rename(oldname, newname string) error

func (*CompositeFs) Stat

func (c *CompositeFs) Stat(name string) (os.FileInfo, error)

type FunctionCall

type FunctionCall struct {
	This      Value
	Arguments []Value
	Bundle    Bundle
}

func (FunctionCall) Argument

func (f FunctionCall) Argument(idx int) Value

type Getter

type Getter func() (value interface{})

type GoFunction

type GoFunction interface{}

type Kernel

type Kernel interface {
	Bundle

	// Start starts the kernel after all KernelModules by executing
	// the given JavaScript (*.js) or TypeScript (*.ts) file path,
	// which is relative to the kernel virtual filesystem base.
	Start(entryPoint string) error

	// Stop stops the kernel. No further scripts will be executed
	// after this point.
	Stop() error
}

Kernel is the root Bundle implementation and has special privileges. Also the kernel provides access to all native APIs provided by either builtin modules or loaded external kernel module plugins.

func New

func New(kernelConfig KernelConfig) (Kernel, error)

type KernelConfig

type KernelConfig struct {
	NewKernelFilesystem func(baseFilesystem afero.Fs) (afero.Fs, error)
	NewBundleFilesystem func(bundleFilesystemConfig BundleFilesystemConfig) (afero.Fs, error)
	NewSandbox          func(bundle Bundle) Sandbox
	KernelModules       []KernelModule
	BundleApiProviders  []ApiProviderBinder
}

type KernelModule

type KernelModule interface {
	ID() string
	Name() string
	SecurityInterceptor() SecurityInterceptor
	KernelModuleBinder() KernelModuleBinder
}

type KernelModuleBinder

type KernelModuleBinder func(bundle Bundle, builder ObjectBuilder)

type KernelSyscall

type KernelSyscall func(caller Bundle) interface{}

type KeyManager

type KeyManager interface {
	GetKey(fingerprint string) ([]byte, error)
}

type Module

type Module interface {
	ID() string
	Name() string
	Origin() Origin
	Bundle() Bundle

	IsAccessible(caller Bundle) error
	// contains filtered or unexported methods
}

type NativeFunction

type NativeFunction func(call FunctionCall) Value

type Object

type Object interface {
	Value

	Get(name string) Value
	PropertyDescriptor(name string) PropertyDescriptor

	Freeze() Object
	DeepFreeze() Object

	DefineFunction(functionName, propertyName string, function NativeFunction) Object
	DefineGoFunction(functionName, propertyName string, function GoFunction) Object
	DefineConstant(constantName string, value interface{}) Object
	DefineSimpleProperty(propertyName string, value interface{}) Object
	DefineObjectProperty(objectName string, objectBinder ObjectBinder) Object
	DefineAccessorProperty(propertyName string, getter Getter, setter Setter) Object
}

type ObjectBinder

type ObjectBinder func(builder ObjectBuilder)

type ObjectBuilder

type ObjectBuilder interface {
	DefineFunction(functionName, propertyName string, function NativeFunction) ObjectBuilder
	DefineGoFunction(functionName, propertyName string, function GoFunction) ObjectBuilder
	DefineConstant(constantName string, value interface{}) ObjectBuilder
	DefineSimpleProperty(propertyName string, value interface{}) ObjectBuilder
	DefineObjectProperty(objectName string, objectBinder ObjectBinder) ObjectBuilder
	DefineAccessorProperty(propertyName string, getter Getter, setter Setter) ObjectBuilder
}

type ObjectCreator

type ObjectCreator interface {
	ObjectBuilder
	Build() Object
	BuildInto(objectName string, parent Object)
}

type Origin

type Origin interface {
	Filename() string
	Path() string
	FullPath() string
}

type Position

type Position struct {
	Line, Col int
}

type PropertyDescriptor

type PropertyDescriptor struct {
	Original interface{}

	Value Value

	Getter Getter
	Setter Setter

	Writable     PropertyFlag
	Configurable PropertyFlag
	Enumerable   PropertyFlag
}

type PropertyFlag

type PropertyFlag uint8
const (
	Flag_NotSet PropertyFlag = iota
	Flag_False
	Flag_True
)

type ResourceLoader

type ResourceLoader interface {
	LoadResource(kernel *kernel, filesystem afero.Fs, filename string) ([]byte, error)
}

type Sandbox

type Sandbox interface {
	NewObject() Object

	// NewObjectCreator returns an ObjectCreator instance which can be used
	// to define script Object instances.
	//
	// The provided objectName will be used to register the object with the
	// given parent when ObjectCreator::BuildInto is called.
	NewObjectCreator(objectName string) ObjectCreator
	NewNamedNativeFunction(functionName string, function GoFunction) Value
	NewTypeError(args ...interface{}) Object
	NewError(err error) Object

	NewModuleProxy(object Object, objectName string, caller Bundle) (Object, error)
	IsAccessible(module Module, caller Bundle) error

	Compile(filename, source string) (script Script, cacheable bool, err error)
	Execute(script Script) (Value, error)
	CaptureCallStack(maxStackFrames int) []StackFrame
	NewDebugger() (interface{}, error)

	Global() Object
	NullValue() Value
	UndefinedValue() Value

	ToValue(value interface{}) Value
	Export(value Value, target interface{}) error
}

type Script

type Script interface {
}

type SecurityInterceptor

type SecurityInterceptor func(caller Bundle, property string) (accessGranted bool)

type Setter

type Setter func(value interface{})

type StackFrame

type StackFrame interface {
	Position() Position
	SrcName() string
	FuncName() string
	String() string
}

type Value

type Value interface {
	ToInteger() int64
	ToFloat() float64
	ToBoolean() bool
	ToNumber() Value
	ToString() Value

	ToObject() Object

	SameAs(other Value) bool
	Equals(other Value) bool
	StrictEquals(other Value) bool

	Export() interface{}
	ExportType() reflect.Type

	String() string

	IsObject() bool
	IsArray() bool
	IsDefined() bool

	Unwrap() interface{}
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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