Documentation ¶
Index ¶
- func CatchFatalErrors()
- func ConfigRegisterScriptEngineBuilder(engineName string, builder ScriptEngineBuilder)
- func DeclareBackgroundTaskEnded()
- func DeclareBackgroundTaskStarted()
- func DynamicCallFunction(toCall any, callArgs []reflect.Value) (result []reflect.Value, errorMsg string)
- func EndOfAllBackgroundTasks()
- func ExecuteScriptContent(scriptContent, scriptOrigin string, scriptEngine ScriptEngine)
- func ForEachScriptEngine(f func(engine ScriptEngine))
- func ForceExitingVM()
- func GoStringToQuotedString2(value string) string
- func LogScriptError(error *ScriptErrorMessage)
- func OnUnCatchScriptError(error *ScriptErrorMessage)
- func PauseMs(timeInMs int)
- func ReflectValueToAny(resV reflect.Value) any
- func SafeGoRoutine(f func())
- func SetErrorTranslator(handler ErrorTranslatorF)
- type DisposeSharedResourceF
- type EmbeddedFile
- type ErrorTranslatorF
- type FunctionGroup
- type FunctionModule
- func (m *FunctionModule) AddAsyncFunction(jsName string, goFunctionName string, jsFunction any)
- func (m *FunctionModule) AddFunction(javascriptName string, goFunctionName string, goFunctionRef any)
- func (m *FunctionModule) DeclareNodeModule(embedded embed.FS, embeddedDirPath string, modName string)
- func (m *FunctionModule) GetFunctionRegistry() *FunctionRegistry
- func (m *FunctionModule) ModName() string
- func (m *FunctionModule) UseCustomGroup(jsGroupName string) *FunctionGroup
- func (m *FunctionModule) UseGroupGlobal() *FunctionGroup
- type FunctionRegistry
- func (m *FunctionRegistry) EnableDynamicMode(enabled bool)
- func (m *FunctionRegistry) GetAllFunctions(sortList bool) []*RegisteredFunction
- func (m *FunctionRegistry) GetEmbeddedModulesTSX() map[string]EmbeddedFile
- func (m *FunctionRegistry) GetNamespaces() map[string]bool
- func (m *FunctionRegistry) GetRefToFunction(jsFunctionName string) *RegisteredFunction
- func (m *FunctionRegistry) IsUsingDynamicMode() bool
- func (m *FunctionRegistry) UseGoNamespace(goNamespace string) *FunctionModule
- type ParsedGoFunction
- type RegisteredFunction
- type ScriptCallback
- type ScriptEngine
- type ScriptEngineBuilder
- type ScriptErrorMessage
- type ScriptExecResult
- type ScriptFunction
- type SharedResource
- type StackTraceFrame
- type StringBuffer
- type TaskQueue
- type V8ScriptCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CatchFatalErrors ¶
func CatchFatalErrors()
func ConfigRegisterScriptEngineBuilder ¶
func ConfigRegisterScriptEngineBuilder(engineName string, builder ScriptEngineBuilder)
func DeclareBackgroundTaskEnded ¶
func DeclareBackgroundTaskEnded()
func DeclareBackgroundTaskStarted ¶
func DeclareBackgroundTaskStarted()
func DynamicCallFunction ¶
func EndOfAllBackgroundTasks ¶
func EndOfAllBackgroundTasks()
func ExecuteScriptContent ¶
func ExecuteScriptContent(scriptContent, scriptOrigin string, scriptEngine ScriptEngine)
func ForEachScriptEngine ¶
func ForEachScriptEngine(f func(engine ScriptEngine))
func ForceExitingVM ¶
func ForceExitingVM()
ForceExitingVM allows stopping the process without doing an os.exit. It's a requirement if profiling the memory, since without that, the log file isn't correctly flushed.
func GoStringToQuotedString2 ¶
func LogScriptError ¶
func LogScriptError(error *ScriptErrorMessage)
func OnUnCatchScriptError ¶
func OnUnCatchScriptError(error *ScriptErrorMessage)
func ReflectValueToAny ¶
func SafeGoRoutine ¶
func SafeGoRoutine(f func())
func SetErrorTranslator ¶
func SetErrorTranslator(handler ErrorTranslatorF)
Types ¶
type DisposeSharedResourceF ¶
type DisposeSharedResourceF func(value any)
type EmbeddedFile ¶
func (*EmbeddedFile) Read ¶
func (m *EmbeddedFile) Read() ([]byte, error)
type ErrorTranslatorF ¶
type ErrorTranslatorF func(error *ScriptErrorMessage)
type FunctionGroup ¶
type FunctionGroup struct {
// contains filtered or unexported fields
}
func (*FunctionGroup) AddAsyncFunction ¶
func (m *FunctionGroup) AddAsyncFunction(jsName string, goFunctionName string, jsFunction any)
func (*FunctionGroup) AddFunction ¶
func (m *FunctionGroup) AddFunction(javascriptName string, goFunctionName string, goFunctionRef any)
type FunctionModule ¶
type FunctionModule struct {
// contains filtered or unexported fields
}
func (*FunctionModule) AddAsyncFunction ¶
func (m *FunctionModule) AddAsyncFunction(jsName string, goFunctionName string, jsFunction any)
AddAsyncFunction add an async function to a javascript group which name is the name of the go namespace last part.
func (*FunctionModule) AddFunction ¶
func (m *FunctionModule) AddFunction(javascriptName string, goFunctionName string, goFunctionRef any)
AddFunction add a function to a javascript group which name is the name of the go namespace last part.
func (*FunctionModule) DeclareNodeModule ¶
func (m *FunctionModule) DeclareNodeModule(embedded embed.FS, embeddedDirPath string, modName string)
func (*FunctionModule) GetFunctionRegistry ¶
func (m *FunctionModule) GetFunctionRegistry() *FunctionRegistry
func (*FunctionModule) ModName ¶
func (m *FunctionModule) ModName() string
func (*FunctionModule) UseCustomGroup ¶
func (m *FunctionModule) UseCustomGroup(jsGroupName string) *FunctionGroup
UseCustomGroup allows using another javascript group than the default group for this go namespace.
func (*FunctionModule) UseGroupGlobal ¶
func (m *FunctionModule) UseGroupGlobal() *FunctionGroup
UseGroupGlobal allows using the global group where functionsArray directly accessible to javascript scripts without importing them.
type FunctionRegistry ¶
type FunctionRegistry struct {
// contains filtered or unexported fields
}
func GetFunctionRegistry ¶
func GetFunctionRegistry() *FunctionRegistry
func (*FunctionRegistry) EnableDynamicMode ¶
func (m *FunctionRegistry) EnableDynamicMode(enabled bool)
func (*FunctionRegistry) GetAllFunctions ¶
func (m *FunctionRegistry) GetAllFunctions(sortList bool) []*RegisteredFunction
func (*FunctionRegistry) GetEmbeddedModulesTSX ¶
func (m *FunctionRegistry) GetEmbeddedModulesTSX() map[string]EmbeddedFile
func (*FunctionRegistry) GetNamespaces ¶
func (m *FunctionRegistry) GetNamespaces() map[string]bool
func (*FunctionRegistry) GetRefToFunction ¶
func (m *FunctionRegistry) GetRefToFunction(jsFunctionName string) *RegisteredFunction
func (*FunctionRegistry) IsUsingDynamicMode ¶
func (m *FunctionRegistry) IsUsingDynamicMode() bool
func (*FunctionRegistry) UseGoNamespace ¶
func (m *FunctionRegistry) UseGoNamespace(goNamespace string) *FunctionModule
type ParsedGoFunction ¶
type ParsedGoFunction struct { GeneratorUniqName string GoFunctionName string ParamTypes []string ParamTypeRefs []reflect.Type CallParamNamespaces []string ReturnType string ReturnErrorOffset int JsFunctionName string JsGroupName string }
func ParseGoFunction ¶
func ParseGoFunction(fct *RegisteredFunction) (ParsedGoFunction, error)
func (*ParsedGoFunction) GetGoFunctionName ¶
func (m *ParsedGoFunction) GetGoFunctionName() string
func (*ParsedGoFunction) GetJsFunctionName ¶
func (m *ParsedGoFunction) GetJsFunctionName() string
type RegisteredFunction ¶
type ScriptCallback ¶
type ScriptCallback func(error *ScriptErrorMessage)
type ScriptEngine ¶
type ScriptEngine interface { // Start the engine, which is call one all is initialized in the Go side. Start() // GetEngineLanguage allows to know if it' a "javascript" engine or a "python" engine. GetEngineLanguage() string // GetEngineName the name of the underlying engine. For exemple "progpv8". GetEngineName() string WaitDebuggerReady() // GetInternalEngineVersion the version of the engine used internally. // For exemple if it's using Google V8, then return the v8 engine version. GetInternalEngineVersion() string // ExecuteScript execute a script by giving his content. ExecuteScript(scriptContent string, compiledFilePath string) *ScriptErrorMessage // Shutdown stop the engine. He can't be used anymore after that. // It mainly occurs after a fatal error or at script ends. Shutdown() // DisarmError remove the current error and allows continuing execution. // The error params allows to avoid case where a new error occurs since. DisarmError(error *ScriptErrorMessage) }
func GetScriptEngine ¶
func GetScriptEngine(engineName string) ScriptEngine
type ScriptEngineBuilder ¶
type ScriptEngineBuilder = func() ScriptEngine
type ScriptErrorMessage ¶
type ScriptErrorMessage struct { ScriptEngine ScriptEngine Error string ErrorLevel int StartColumn int EndColumn int StartPosition int EndPosition int SourceMapUrl string ScriptPath string StackTraceFrameCount int StackTraceFrames []StackTraceFrame // contains filtered or unexported fields }
func (*ScriptErrorMessage) DisarmError ¶
func (m *ScriptErrorMessage) DisarmError()
DisarmError allows to continue after an un-catch error.
func (*ScriptErrorMessage) Print ¶
func (m *ScriptErrorMessage) Print()
func (*ScriptErrorMessage) StackTrace ¶
func (m *ScriptErrorMessage) StackTrace() string
func (*ScriptErrorMessage) Translate ¶
func (m *ScriptErrorMessage) Translate()
type ScriptExecResult ¶
type ScriptExecResult struct { ScriptError *ScriptErrorMessage GoError error }
func (*ScriptExecResult) HasError ¶
func (m *ScriptExecResult) HasError() bool
func (*ScriptExecResult) PrintError ¶
func (m *ScriptExecResult) PrintError() bool
type ScriptFunction ¶
type SharedResource ¶
type SharedResource struct { // contains filtered or unexported fields }
func GetSharedResource ¶
func GetSharedResource(id int) *SharedResource
func NewSharedResource ¶
func NewSharedResource(value any, onDispose DisposeSharedResourceF) *SharedResource
func (*SharedResource) Dispose ¶
func (m *SharedResource) Dispose()
func (*SharedResource) GetId ¶
func (m *SharedResource) GetId() int
type StackTraceFrame ¶
type StringBuffer ¶
type StringBuffer []byte
StringBuffer allows the code generator to known that we want this bytes to be send as if it was a string. Allows to avoid the cost of converting []byte to string before calling javascript.
type TaskQueue ¶
type TaskQueue struct {
// contains filtered or unexported fields
}
TaskQueue allows executing the C++ calls from only one thread. Without that, Go can be short on available threads which lead to a crash.
This protection is only required where there is a lot of calls that can be blocked the thread. It's essentially when calling an event and calling a callback function.
func NewTaskQueue ¶
func NewTaskQueue() *TaskQueue
func (*TaskQueue) IsDisposed ¶
type V8ScriptCallback ¶
type V8ScriptCallback func(result ScriptExecResult)