bind

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

README

The bind package is currently not in use

Documentation

Overview

Package bind Energy has not been exported or added yet

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBinds

func GetBinds(fn func(bind *V8bind))

GetBinds 获取绑定的字段

Types

type BindType

type BindType int8

BindType 绑定值类型

动态类型是可变类型, NewDynamic创建绑定变量, 函数传值方式
静态类型是不可变类型, NewStatic创建绑定变量, 直接传入变量指针, 非 interface{} 类型
const (
	BtDynamic BindType = iota // 动态类型
	BtStatic                  // 静态类型
)

type Data

type Data struct {
	P string       `json:"P"`
	T reflect.Kind `json:"T"`
	V any          `json:"V"`
}

type JSArray

type JSArray interface {
	JSValue
	AsArray() JSArray
	Items() []JSValue
	Get(index int) JSValue

	Add(value any) JSValue
	Set(index int, value any) JSValue
	Clear()
	Remove(index int)
	// contains filtered or unexported methods
}

func NewArray

func NewArray(name string, values []any) JSArray

NewArray GO&JS 数组类型

type JSBoolean

type JSBoolean interface {
	JSValue
	AsBoolean() JSBoolean
	BooleanValue() bool
}

func NewBoolean

func NewBoolean(name string, value bool) JSBoolean

NewBoolean GO&JS 布尔类型

type JSDouble

type JSDouble interface {
	JSValue
	AsDouble() JSDouble
	DoubleValue() float64
}

func NewDouble

func NewDouble(name string, value float64) JSDouble

NewDouble GO&JS 浮点类型

type JSFunction

type JSFunction interface {
	JSValue
	AsFunction() JSFunction
	// Invoke 调用函数
	//	入参: 以参数列表形式传入参数
	//		入参如果参数类型或数量不匹配这些参数将以类型的默认值传入
	//		nil 无入参
	//	出参: 以参数列表形式返回参数
	//		无返回值返回nil
	Invoke(argumentList json.JSONArray) (resultArgument json.JSONArray)
}

func NewFunction

func NewFunction(name string, fn any) JSFunction

NewFunction GO&JS 函数类型

type JSInteger

type JSInteger interface {
	JSValue
	AsInteger() JSInteger
	IntegerValue() int
}

func NewInteger

func NewInteger(name string, value int) JSInteger

NewInteger GO&JS 数字类型

type JSObject

type JSObject interface {
	JSValue
	ObjectValue() any
	Get(fieldName string) JSValue
	Set(fieldName string, value any)
	// contains filtered or unexported methods
}

func NewObject

func NewObject(object any) JSObject

NewObject GO&JS 对象类型 &struct{} 仅结构

type JSString

type JSString interface {
	JSValue
	AsString() JSString
	StringValue() string
}

func NewString

func NewString(name, value string) JSString

NewString GO&JS 字符串类型

type JSUndefined

type JSUndefined interface {
	JSValue
	AsUndefined() JSUndefined
	UndefinedValue() string
}

func NewUndefined

func NewUndefined(name string) JSUndefined

NewUndefined GO&JS 未定义类型

type JSValue

type JSValue interface {
	Name() string             //当前变量绑定的名称
	JSON() json.JSON          //
	Value() any               //
	SetValue(value any)       //设置新值
	IsInteger() bool          //是否 Integer
	IsDouble() bool           //是否 Double
	IsString() bool           //是否 String
	IsBoolean() bool          //是否 Boolean
	IsObject() bool           //是否 Object
	IsArray() bool            //是否 Array
	IsUndefined() bool        //是否 Undefined
	IsFunction() bool         //是否 Function
	AsInteger() JSInteger     //转换为 Integer 失败返回 nil
	AsDouble() JSDouble       //转换为 Double 失败返回 nil
	AsString() JSString       //转换为 String 失败返回 nil
	AsBoolean() JSBoolean     //转换为 Boolean 失败返回 nil
	AsUndefined() JSUndefined //转换为 Undefined 失败返回 nil
	AsFunction() JSFunction   //转换为 Function 失败返回 nil

	AsV8Value() JSValue //转换为 JSValue
	StringValue() string
	BooleanValue() bool
	DoubleValue() float64
	IntegerValue() int
	UndefinedValue() string
	// Invoke 调用函数
	//	入参: 以参数列表形式传入参数
	//		入参如果参数类型或数量不匹配这些参数将以类型的默认值传入
	//		nil 无入参
	//	出参: 以参数列表形式返回参数
	//		无返回值返回nil
	Invoke(argumentList json.JSONArray) (resultArgument json.JSONArray)
	Id() int            //指针ID
	Type() reflect.Kind //值类型
	BindType() BindType //绑定类型
	// contains filtered or unexported methods
}

JSValue

GO和JS动态变量类型

在主进程有效

type V8Value

type V8Value struct {
	*json.JsonData
	// contains filtered or unexported fields
}

V8Value 绑定到JS的字段

func (*V8Value) AsBoolean

func (m *V8Value) AsBoolean() JSBoolean

func (*V8Value) AsDouble

func (m *V8Value) AsDouble() JSDouble

func (*V8Value) AsFunction

func (m *V8Value) AsFunction() JSFunction

func (*V8Value) AsInteger

func (m *V8Value) AsInteger() JSInteger

func (*V8Value) AsString

func (m *V8Value) AsString() JSString

func (*V8Value) AsUndefined

func (m *V8Value) AsUndefined() JSUndefined

func (*V8Value) AsV8Value

func (m *V8Value) AsV8Value() JSValue

func (*V8Value) BindType

func (m *V8Value) BindType() BindType

BindType 绑定类型

func (*V8Value) BooleanValue

func (m *V8Value) BooleanValue() bool

func (*V8Value) DoubleValue

func (m *V8Value) DoubleValue() float64

func (*V8Value) Id

func (m *V8Value) Id() int

func (*V8Value) IntegerValue

func (m *V8Value) IntegerValue() int

func (*V8Value) Invoke

func (m *V8Value) Invoke(argumentList json.JSONArray) (resultArgument json.JSONArray)

func (*V8Value) IsArray

func (m *V8Value) IsArray() bool

func (*V8Value) IsBoolean

func (m *V8Value) IsBoolean() bool

func (*V8Value) IsDouble

func (m *V8Value) IsDouble() bool

func (*V8Value) IsFunction

func (m *V8Value) IsFunction() bool

func (*V8Value) IsInteger

func (m *V8Value) IsInteger() bool

func (*V8Value) IsObject

func (m *V8Value) IsObject() bool

func (*V8Value) IsString

func (m *V8Value) IsString() bool

func (*V8Value) IsUndefined

func (m *V8Value) IsUndefined() bool

func (*V8Value) JSON

func (m *V8Value) JSON() json.JSON

func (*V8Value) Name

func (m *V8Value) Name() string

func (*V8Value) SetValue

func (m *V8Value) SetValue(value any)

SetValue 设置值

func (*V8Value) StringValue

func (m *V8Value) StringValue() string

func (*V8Value) Type

func (m *V8Value) Type() reflect.Kind

func (*V8Value) UndefinedValue

func (m *V8Value) UndefinedValue() string

func (*V8Value) Value

func (m *V8Value) Value() any

type V8bind

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

V8bind

func (*V8bind) Add

func (m *V8bind) Add(value JSValue) uintptr

Add 添加 JSValue 并返回 id

func (*V8bind) ElementToJSValue

func (m *V8bind) ElementToJSValue(item *list.Element) JSValue

func (*V8bind) FieldCollection

func (m *V8bind) FieldCollection() *list.List

func (*V8bind) Get

func (m *V8bind) Get(id uintptr) *list.Element

Get list element

func (*V8bind) GetJSValue

func (m *V8bind) GetJSValue(id uintptr) JSValue

GetJSValue 返回 JSValue

func (*V8bind) HasFieldCollection

func (m *V8bind) HasFieldCollection() map[string]uintptr

func (*V8bind) HasSize

func (m *V8bind) HasSize() int

func (*V8bind) Remove

func (m *V8bind) Remove(id uintptr) any

Remove 删除

func (*V8bind) Set

func (m *V8bind) Set(value JSValue)

Set 添加或修改

参数
	 name: 唯一字段名, 重复将被覆盖
	value: 值

func (*V8bind) Size

func (m *V8bind) Size() int

Jump to

Keyboard shortcuts

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