Documentation
¶
Index ¶
- Constants
- func AssignArgs(data ESConstructorData, op ESOperation) g.Generator
- func CreateInitFunction(data ESConstructorData) g.Generator
- func CreateV8Constructor(data ESConstructorData) g.Generator
- func CreateV8ConstructorBody(data ESConstructorData) g.Generator
- func CreateV8ConstructorWrapperBody(data ESConstructorData) g.Generator
- func CreateV8Generator(data ESConstructorData) g.Generator
- func CreateV8IllegalConstructorBody(data ESConstructorData) g.Generator
- func CreateV8WrapperMethodInstanceInvocations(prototype ESConstructorData, op ESOperation, baseFunctionName string, ...) g.Generator
- func CreateV8WrapperTypeGenerator(data ESConstructorData) g.Generator
- func GetInstanceAndError(id g.Generator, errId g.Generator, data ESConstructorData) g.Generator
- func IsNodeType(typeName string) bool
- func ReturnOnAnyError(errNames []g.Generator) g.Generator
- func V8RequireContext(wrapper WrapperInstance) g.Generator
- type ConstructorBuilder
- func (builder ConstructorBuilder) InstallAttributeHandler(op ESAttribute) g.Generator
- func (builder ConstructorBuilder) InstallAttributeHandlers(data ESConstructorData) g.Generator
- func (builder ConstructorBuilder) InstallFunctionHandlers(data ESConstructorData) JenGenerator
- func (iso ConstructorBuilder) NewFunctionTemplate(cb g.Generator) g.Generator
- func (builder ConstructorBuilder) NewFunctionTemplateOfWrappedMethod(name string) g.Generator
- type ESAttribute
- type ESClassWrapper
- func (s *ESClassWrapper) CreateWrapper()
- func (w *ESClassWrapper) GetMethodCustomization(name string) (result ESMethodWrapper)
- func (w *ESClassWrapper) MarkMembersAsIgnored(names ...string)
- func (w *ESClassWrapper) MarkMembersAsNotImplemented(names ...string)
- func (w *ESClassWrapper) Method(name string) (result *ESMethodWrapper)
- type ESConstructorData
- func (d ESConstructorData) AttributesToInstall() iter.Seq[ESAttribute]
- func (d ESConstructorData) GetInternalPackage() string
- func (d ESConstructorData) Name() string
- func (d ESConstructorData) WrapperFunctionsToGenerate() iter.Seq[ESOperation]
- func (d ESConstructorData) WrapperFunctionsToInstall() iter.Seq[ESOperation]
- type ESMethodArgument
- func (a *ESMethodArgument) HasDefault() *ESMethodArgument
- func (a *ESMethodArgument) HasDefaultValue(value string)
- func (a *ESMethodArgument) Ignore()
- func (a *ESMethodArgument) Required() *ESMethodArgument
- func (a *ESMethodArgument) SetDecoder(d string) *ESMethodArgument
- func (a *ESMethodArgument) SetEncoder(e string) *ESMethodArgument
- type ESMethodWrapper
- func (w *ESMethodWrapper) Argument(name string) (result *ESMethodArgument)
- func (w *ESMethodWrapper) Ignore() *ESMethodWrapper
- func (w *ESMethodWrapper) SetCustomImplementation() *ESMethodWrapper
- func (w *ESMethodWrapper) SetEncoder(e string) *ESMethodWrapper
- func (w *ESMethodWrapper) SetNoError() *ESMethodWrapper
- func (w *ESMethodWrapper) SetNotImplemented() *ESMethodWrapper
- type ESOperation
- type ESOperationArgument
- type GojaNamingStrategy
- type GojaTargetGenerators
- func (gen GojaTargetGenerators) CreateInitFunction(data ESConstructorData) g.Generator
- func (gen GojaTargetGenerators) CreateJSConstructorGenerator(data ESConstructorData) g.Generator
- func (gen GojaTargetGenerators) CreatePrototypeInitializer(data ESConstructorData) g.Generator
- func (gen GojaTargetGenerators) CreateWrapperMethod(data ESConstructorData, op ESOperation) g.Generator
- func (gen GojaTargetGenerators) CreateWrapperMethodBody(data ESConstructorData, op ESOperation, callArgument g.Generator) g.Generator
- func (gen GojaTargetGenerators) CreateWrapperMethods(data ESConstructorData) g.Generator
- func (gen GojaTargetGenerators) CreateWrapperStruct(data ESConstructorData) g.Generator
- type JenGenerator
- func CreateV8ConstructorWrapper(data ESConstructorData) JenGenerator
- func CreateV8FunctionTemplateCallbackBody(data ESConstructorData, op ESOperation) JenGenerator
- func CreateV8WrapperMethod(data ESConstructorData, op ESOperation) JenGenerator
- func CreateV8WrapperMethods(data ESConstructorData) JenGenerator
- type NewV8FunctionTemplate
- type ReturnOnError
- type ScriptWrapperModulesGenerator
- type TargetGenerators
- type TypeCustomization
- type V8InstanceInvocation
- type V8InstanceInvocationResult
- type V8ReadArg
- type V8ReadArguments
- type V8TargetGenerators
- type WrapperGeneratorFileSpec
- type WrapperGeneratorsSpec
- type WrapperInstance
- type WrapperTypeSpec
Constants ¶
const ( NAME = "gost-dom" BASE_PKG = "github.com/gost-dom/browser" ISSUE_URL = "https://github.com/gost-dom/browser/issues" )
Names that relate to the project name, which would only change if the project is moved/renamed.
Variables ¶
This section is empty.
Functions ¶
func AssignArgs ¶
func AssignArgs(data ESConstructorData, op ESOperation) g.Generator
func CreateInitFunction ¶
func CreateInitFunction(data ESConstructorData) g.Generator
func CreateV8Constructor ¶
func CreateV8Constructor(data ESConstructorData) g.Generator
func CreateV8ConstructorBody ¶
func CreateV8ConstructorBody(data ESConstructorData) g.Generator
func CreateV8ConstructorWrapperBody ¶
func CreateV8ConstructorWrapperBody(data ESConstructorData) g.Generator
func CreateV8Generator ¶
func CreateV8Generator(data ESConstructorData) g.Generator
func CreateV8IllegalConstructorBody ¶
func CreateV8IllegalConstructorBody(data ESConstructorData) g.Generator
func CreateV8WrapperMethodInstanceInvocations ¶
func CreateV8WrapperMethodInstanceInvocations( prototype ESConstructorData, op ESOperation, baseFunctionName string, args []V8ReadArg, instanceErr g.Generator, createCallInstance func(string, []g.Generator, ESOperation) g.Generator, extraError bool, ) g.Generator
func CreateV8WrapperTypeGenerator ¶
func CreateV8WrapperTypeGenerator(data ESConstructorData) g.Generator
func GetInstanceAndError ¶
func IsNodeType ¶
func V8RequireContext ¶
func V8RequireContext(wrapper WrapperInstance) g.Generator
Types ¶
type ConstructorBuilder ¶
type ConstructorBuilder struct {
Proto v8PrototypeTemplate
InstanceTmpl v8InstanceTemplate
Wrapper WrapperInstance
// contains filtered or unexported fields
}
The ConstructorBuilder is the function that creates the ES constructor itself, i.e. starts with a new function template, installs prototypes on the template, etc.
func NewConstructorBuilder ¶
func NewConstructorBuilder() ConstructorBuilder
func (ConstructorBuilder) InstallAttributeHandler ¶
func (builder ConstructorBuilder) InstallAttributeHandler( op ESAttribute, ) g.Generator
func (ConstructorBuilder) InstallAttributeHandlers ¶
func (builder ConstructorBuilder) InstallAttributeHandlers( data ESConstructorData, ) g.Generator
func (ConstructorBuilder) InstallFunctionHandlers ¶
func (builder ConstructorBuilder) InstallFunctionHandlers( data ESConstructorData, ) JenGenerator
func (ConstructorBuilder) NewFunctionTemplate ¶
func (ConstructorBuilder) NewFunctionTemplateOfWrappedMethod ¶
func (builder ConstructorBuilder) NewFunctionTemplateOfWrappedMethod(name string) g.Generator
type ESAttribute ¶
type ESAttribute struct {
Name string
Getter *ESOperation
Setter *ESOperation
}
func CreateAttributes ¶
func CreateAttributes( dataData WrapperTypeSpec, idlName idl.TypeSpec, ) (res []ESAttribute)
type ESClassWrapper ¶
type ESClassWrapper struct {
DomSpec *WrapperGeneratorFileSpec
TypeName string
InnerTypeName string
WrapperTypeName string
Receiver string
RunCustomCode bool
WrapperStruct bool
SkipPrototypeRegistration bool
IncludeIncludes bool
Customization map[string]*ESMethodWrapper
}
ESClassWrapper contains information about how to generate ES wrapper code around a class in the web specification.
All classes will be generated using a set of defaults. Data in this structure will allow deviating from the defaults.
func (*ESClassWrapper) CreateWrapper ¶
func (s *ESClassWrapper) CreateWrapper()
func (*ESClassWrapper) GetMethodCustomization ¶
func (w *ESClassWrapper) GetMethodCustomization(name string) (result ESMethodWrapper)
func (*ESClassWrapper) MarkMembersAsIgnored ¶
func (w *ESClassWrapper) MarkMembersAsIgnored(names ...string)
func (*ESClassWrapper) MarkMembersAsNotImplemented ¶
func (w *ESClassWrapper) MarkMembersAsNotImplemented(names ...string)
func (*ESClassWrapper) Method ¶
func (w *ESClassWrapper) Method(name string) (result *ESMethodWrapper)
type ESConstructorData ¶
type ESConstructorData struct {
Spec *ESClassWrapper
InnerTypeName string
WrapperTypeName string
WrapperTypeBaseName string
Receiver string
Inheritance string
Operations []ESOperation
Attributes []ESAttribute
Constructor *ESOperation
RunCustomCode bool
}
func (ESConstructorData) AttributesToInstall ¶
func (d ESConstructorData) AttributesToInstall() iter.Seq[ESAttribute]
func (ESConstructorData) GetInternalPackage ¶
func (d ESConstructorData) GetInternalPackage() string
func (ESConstructorData) Name ¶
func (d ESConstructorData) Name() string
func (ESConstructorData) WrapperFunctionsToGenerate ¶
func (d ESConstructorData) WrapperFunctionsToGenerate() iter.Seq[ESOperation]
func (ESConstructorData) WrapperFunctionsToInstall ¶
func (d ESConstructorData) WrapperFunctionsToInstall() iter.Seq[ESOperation]
type ESMethodArgument ¶
type ESMethodArgument struct {
// contains filtered or unexported fields
}
func (*ESMethodArgument) HasDefault ¶
func (a *ESMethodArgument) HasDefault() *ESMethodArgument
func (*ESMethodArgument) HasDefaultValue ¶
func (a *ESMethodArgument) HasDefaultValue(value string)
func (*ESMethodArgument) Ignore ¶
func (a *ESMethodArgument) Ignore()
func (*ESMethodArgument) Required ¶
func (a *ESMethodArgument) Required() *ESMethodArgument
func (*ESMethodArgument) SetDecoder ¶
func (a *ESMethodArgument) SetDecoder(d string) *ESMethodArgument
func (*ESMethodArgument) SetEncoder ¶
func (a *ESMethodArgument) SetEncoder(e string) *ESMethodArgument
type ESMethodWrapper ¶
type ESMethodWrapper struct {
// When set, the ES wrapper will generate an error with the message, "Not implemented"
NotImplemented bool
// When set, nothing will be generated for the member
Ignored bool
// HasNoError tells that the wrapped Go method doesn't generate an error.
HasNoError bool
// CustomImplementation tells that the wrapper code will be generated by hand.
// Code generator will still install a function on the prototype template
// referencing the custom function
CustomImplementation bool
Arguments map[string]*ESMethodArgument
// Name of the method that will convert the result to JS
Encoder string
}
ESMethodWrapper contains information about how to generate ES wrapper code around a single class method.
func (*ESMethodWrapper) Argument ¶
func (w *ESMethodWrapper) Argument(name string) (result *ESMethodArgument)
func (*ESMethodWrapper) Ignore ¶
func (w *ESMethodWrapper) Ignore() *ESMethodWrapper
func (*ESMethodWrapper) SetCustomImplementation ¶
func (w *ESMethodWrapper) SetCustomImplementation() *ESMethodWrapper
func (*ESMethodWrapper) SetEncoder ¶
func (w *ESMethodWrapper) SetEncoder(e string) *ESMethodWrapper
func (*ESMethodWrapper) SetNoError ¶
func (w *ESMethodWrapper) SetNoError() *ESMethodWrapper
SetNoError is a simple wrapper around [HasNoError] to support a chaning DSL syntax.
func (*ESMethodWrapper) SetNotImplemented ¶
func (w *ESMethodWrapper) SetNotImplemented() *ESMethodWrapper
SetNotImplemented is a simple wrapper around [NotImplemented] to support a chaning DSL syntax.
type ESOperation ¶
type ESOperation struct {
Name string
NotImplemented bool
RetType idl.RetType
HasError bool
CustomImplementation bool
MethodCustomization ESMethodWrapper
Arguments []ESOperationArgument
}
func CreateConstructor ¶
func CreateConstructor( dataData WrapperTypeSpec, idlName idl.TypeSpec) *ESOperation
func CreateInstanceMethods ¶
func CreateInstanceMethods( dataData WrapperTypeSpec, idlName idl.TypeSpec) (result []ESOperation)
func (ESOperation) Encoder ¶
func (o ESOperation) Encoder() string
func (ESOperation) GetHasError ¶
func (op ESOperation) GetHasError() bool
func (ESOperation) HasResult ¶
func (op ESOperation) HasResult() bool
func (ESOperation) WrapperMethodName ¶
func (o ESOperation) WrapperMethodName() string
type ESOperationArgument ¶
type ESOperationArgument struct {
Name string
Type string
Optional bool
Variadic bool
IdlType idl.IdlTypes
ArgumentSpec ESMethodArgument
Ignore bool
}
func (ESOperationArgument) DefaultValueInGo ¶
func (a ESOperationArgument) DefaultValueInGo() (name string, ok bool)
func (ESOperationArgument) OptionalInGo ¶
func (a ESOperationArgument) OptionalInGo() bool
type GojaNamingStrategy ¶
type GojaNamingStrategy struct {
ESConstructorData
}
func (GojaNamingStrategy) PrototypeWrapperBaseName ¶
func (s GojaNamingStrategy) PrototypeWrapperBaseName() string
func (GojaNamingStrategy) PrototypeWrapperConstructorName ¶
func (s GojaNamingStrategy) PrototypeWrapperConstructorName() string
func (GojaNamingStrategy) PrototypeWrapperTypeName ¶
func (s GojaNamingStrategy) PrototypeWrapperTypeName() string
func (GojaNamingStrategy) ReceiverName ¶
func (s GojaNamingStrategy) ReceiverName() string
type GojaTargetGenerators ¶
type GojaTargetGenerators struct{}
func (GojaTargetGenerators) CreateInitFunction ¶
func (gen GojaTargetGenerators) CreateInitFunction(data ESConstructorData) g.Generator
func (GojaTargetGenerators) CreateJSConstructorGenerator ¶
func (gen GojaTargetGenerators) CreateJSConstructorGenerator(data ESConstructorData) g.Generator
func (GojaTargetGenerators) CreatePrototypeInitializer ¶
func (gen GojaTargetGenerators) CreatePrototypeInitializer(data ESConstructorData) g.Generator
CreatePrototypeInitializer creates the "initializePrototype" method, which sets all the properties on the prototypes on this class.
func (GojaTargetGenerators) CreateWrapperMethod ¶
func (gen GojaTargetGenerators) CreateWrapperMethod( data ESConstructorData, op ESOperation, ) g.Generator
func (GojaTargetGenerators) CreateWrapperMethodBody ¶
func (gen GojaTargetGenerators) CreateWrapperMethodBody( data ESConstructorData, op ESOperation, callArgument g.Generator, ) g.Generator
func (GojaTargetGenerators) CreateWrapperMethods ¶
func (gen GojaTargetGenerators) CreateWrapperMethods(data ESConstructorData) g.Generator
func (GojaTargetGenerators) CreateWrapperStruct ¶
func (gen GojaTargetGenerators) CreateWrapperStruct(data ESConstructorData) g.Generator
type JenGenerator ¶
func CreateV8ConstructorWrapper ¶
func CreateV8ConstructorWrapper(data ESConstructorData) JenGenerator
func CreateV8FunctionTemplateCallbackBody ¶
func CreateV8FunctionTemplateCallbackBody( data ESConstructorData, op ESOperation, ) JenGenerator
func CreateV8WrapperMethod ¶
func CreateV8WrapperMethod( data ESConstructorData, op ESOperation, ) JenGenerator
func CreateV8WrapperMethods ¶
func CreateV8WrapperMethods(data ESConstructorData) JenGenerator
type NewV8FunctionTemplate ¶
type NewV8FunctionTemplate struct {
// contains filtered or unexported fields
}
func (NewV8FunctionTemplate) Generate ¶
func (t NewV8FunctionTemplate) Generate() *jen.Statement
type ReturnOnError ¶
type ReturnOnError struct {
// contains filtered or unexported fields
}
func (ReturnOnError) Generate ¶
func (ret ReturnOnError) Generate() *jen.Statement
type ScriptWrapperModulesGenerator ¶
type ScriptWrapperModulesGenerator struct {
Specs WrapperGeneratorsSpec
PackagePath string
TargetGenerators TargetGenerators
}
func NewGojaWrapperModuleGenerator ¶
func NewGojaWrapperModuleGenerator() ScriptWrapperModulesGenerator
func NewScriptWrapperModulesGenerator ¶
func NewScriptWrapperModulesGenerator() ScriptWrapperModulesGenerator
func (ScriptWrapperModulesGenerator) GenerateScriptWrappers ¶
func (gen ScriptWrapperModulesGenerator) GenerateScriptWrappers() error
type TargetGenerators ¶
type TargetGenerators interface {
CreateJSConstructorGenerator(data ESConstructorData) g.Generator
}
type TypeCustomization ¶
type TypeCustomization []string
type V8InstanceInvocation ¶
type V8InstanceInvocation struct {
Name string
Args []g.Generator
Op ESOperation
Instance *g.Value
Receiver WrapperInstance
}
func (V8InstanceInvocation) GetGenerator ¶
func (c V8InstanceInvocation) GetGenerator() V8InstanceInvocationResult
func (V8InstanceInvocation) PerformCall ¶
func (c V8InstanceInvocation) PerformCall() (genRes V8InstanceInvocationResult)
type V8ReadArguments ¶
func ReadArguments ¶
func ReadArguments(data ESConstructorData, op ESOperation) (res V8ReadArguments)
func (V8ReadArguments) Generate ¶
func (r V8ReadArguments) Generate() *jen.Statement
type V8TargetGenerators ¶
type V8TargetGenerators struct{}
func (V8TargetGenerators) CreateJSConstructorGenerator ¶
func (_ V8TargetGenerators) CreateJSConstructorGenerator(data ESConstructorData) g.Generator
type WrapperGeneratorFileSpec ¶
type WrapperGeneratorFileSpec struct {
Name string
MultipleFiles bool
Types map[string]WrapperTypeSpec
}
func (WrapperGeneratorFileSpec) GetTypesSorted ¶
func (spec WrapperGeneratorFileSpec) GetTypesSorted() []WrapperTypeSpec
func (*WrapperGeneratorFileSpec) SetMultipleFiles ¶
func (spec *WrapperGeneratorFileSpec) SetMultipleFiles(value bool)
func (*WrapperGeneratorFileSpec) Type ¶
func (s *WrapperGeneratorFileSpec) Type(typeName string) WrapperTypeSpec
func (WrapperGeneratorFileSpec) UseMultipleFiles ¶
func (spec WrapperGeneratorFileSpec) UseMultipleFiles() bool
type WrapperGeneratorsSpec ¶
type WrapperGeneratorsSpec map[string](*WrapperGeneratorFileSpec)
WrapperGeneratorsSpec is a list of specifications for generating ES wrapper code. Each key in the map correspond to a specific IDL file
func CreateSpecs ¶
func CreateSpecs() WrapperGeneratorsSpec
func NewWrapperGeneratorsSpec ¶
func NewWrapperGeneratorsSpec() WrapperGeneratorsSpec
func (WrapperGeneratorsSpec) Module ¶
func (g WrapperGeneratorsSpec) Module(spec string) *WrapperGeneratorFileSpec
type WrapperInstance ¶
func (WrapperInstance) GetScriptHost ¶
func (i WrapperInstance) GetScriptHost() g.Value
func (WrapperInstance) MustGetContext ¶
func (i WrapperInstance) MustGetContext(info g.Generator) g.Generator
type WrapperTypeSpec ¶
type WrapperTypeSpec = *ESClassWrapper