Documentation
¶
Index ¶
- Variables
- func Create(class Class, props ...interface{}) interface{}
- func FieldGetBoolFunc(inst reflect.Value, field *classVTField) (v interface{}, err error)
- func FieldGetComplex128Func(inst reflect.Value, field *classVTField) (v interface{}, err error)
- func FieldGetComplex64Func(inst reflect.Value, field *classVTField) (v interface{}, err error)
- func FieldGetFloat32Func(inst reflect.Value, field *classVTField) (v interface{}, err error)
- func FieldGetFloat64Func(inst reflect.Value, field *classVTField) (v interface{}, err error)
- func FieldGetInt16Func(inst reflect.Value, field *classVTField) (v interface{}, err error)
- func FieldGetInt32Func(inst reflect.Value, field *classVTField) (v interface{}, err error)
- func FieldGetInt64Func(inst reflect.Value, field *classVTField) (v interface{}, err error)
- func FieldGetInt8Func(inst reflect.Value, field *classVTField) (v interface{}, err error)
- func FieldGetIntFunc(inst reflect.Value, field *classVTField) (v interface{}, err error)
- func FieldGetInterfaceFunc(inst reflect.Value, field *classVTField) (v interface{}, err error)
- func FieldGetStringFunc(inst reflect.Value, field *classVTField) (v interface{}, err error)
- func FieldGetUint16Func(inst reflect.Value, field *classVTField) (v interface{}, err error)
- func FieldGetUint32Func(inst reflect.Value, field *classVTField) (v interface{}, err error)
- func FieldGetUint64Func(inst reflect.Value, field *classVTField) (v interface{}, err error)
- func FieldGetUint8Func(inst reflect.Value, field *classVTField) (v interface{}, err error)
- func FieldGetUintFunc(inst reflect.Value, field *classVTField) (v interface{}, err error)
- func FieldSetAnyFunc(inst reflect.Value, field *classVTField, value interface{}) error
- func FieldSetBoolFunc(inst reflect.Value, field *classVTField, value interface{}) error
- func FieldSetChanFunc(inst reflect.Value, field *classVTField, value interface{}) error
- func FieldSetComplex128Func(inst reflect.Value, field *classVTField, value interface{}) error
- func FieldSetComplex64Func(inst reflect.Value, field *classVTField, value interface{}) error
- func FieldSetFloat32Func(inst reflect.Value, field *classVTField, value interface{}) error
- func FieldSetFloat64Func(inst reflect.Value, field *classVTField, value interface{}) error
- func FieldSetInt16Func(inst reflect.Value, field *classVTField, value interface{}) error
- func FieldSetInt32Func(inst reflect.Value, field *classVTField, value interface{}) error
- func FieldSetInt64Func(inst reflect.Value, field *classVTField, value interface{}) error
- func FieldSetInt8Func(inst reflect.Value, field *classVTField, value interface{}) error
- func FieldSetIntFunc(inst reflect.Value, field *classVTField, value interface{}) error
- func FieldSetMapFunc(inst reflect.Value, field *classVTField, value interface{}) (err error)
- func FieldSetPtrFunc(inst reflect.Value, field *classVTField, value interface{}) (err error)
- func FieldSetSliceFunc(inst reflect.Value, field *classVTField, value interface{}) (err error)
- func FieldSetStringFunc(inst reflect.Value, field *classVTField, value interface{}) error
- func FieldSetStructFunc(inst reflect.Value, field *classVTField, value interface{}) (err error)
- func FieldSetUint16Func(inst reflect.Value, field *classVTField, value interface{}) error
- func FieldSetUint32Func(inst reflect.Value, field *classVTField, value interface{}) error
- func FieldSetUint64Func(inst reflect.Value, field *classVTField, value interface{}) error
- func FieldSetUint8Func(inst reflect.Value, field *classVTField, value interface{}) error
- func FieldSetUintFunc(inst reflect.Value, field *classVTField, value interface{}) error
- func FieldSetUintPtrFunc(inst reflect.Value, field *classVTField, value interface{}) error
- func Free(obj *Object)
- type Class
- type ClassField
- type ClassMethod
- type ClassTag
- type Object
- type ObjectDynamicFieldObserver
- type ObjectFieldObserver
- type ObjectHello
- type TClass
- type TClassTag
- type TDemo1
- type TDemo2
- type TObject
- func (o *TObject) Call(method string, params ...interface{}) (results []interface{}, err error)
- func (o *TObject) ClassName() string
- func (o *TObject) ClassTag() ClassTag
- func (o *TObject) ClassType() reflect.Type
- func (o *TObject) Constructor(props ...interface{}) interface{}
- func (o *TObject) Destroy()
- func (o *TObject) DynamicFieldCount() int
- func (o *TObject) DynamicGet(fieldName string) interface{}
- func (o *TObject) DynamicGetOrSet(fieldName string, setValue interface{}) interface{}
- func (o *TObject) DynamicGetOrSetVar(fieldName string, setValue interface{}) *_type.TVar
- func (o *TObject) DynamicGetVar(fieldName string) *_type.TVar
- func (o *TObject) DynamicSet(fieldName string, value interface{}) interface{}
- func (o *TObject) DynamicTrySet(fieldName string, value interface{}) interface{}
- func (o *TObject) FieldCount() int
- func (o *TObject) Fields() []*ClassField
- func (o *TObject) ForEachDynamicFields(fn func(k string, v interface{}) bool)
- func (o *TObject) ForEachFields(fn func(fieldName string, tag ClassTag, fieldType reflect.Type) bool)
- func (o *TObject) ForEachMethods(fn func(methodName string, params []reflect.Type, results []reflect.Type) bool)
- func (o *TObject) Get(fieldName string) interface{}
- func (o *TObject) GetVar(fieldName string) *_type.TVar
- func (o *TObject) HasDynamicField(fieldName string) bool
- func (o *TObject) HasField(fieldName string) bool
- func (o *TObject) HasMethod(method string) bool
- func (o *TObject) Implements(parent Class) bool
- func (o *TObject) MethodCount() int
- func (o *TObject) Methods() []*ClassMethod
- func (o *TObject) NewInstance(props ...interface{}) interface{}
- func (o *TObject) SafeSet(fieldName string, value interface{}) (err error)
- func (o *TObject) SayHello() string
- func (o *TObject) Set(fieldName string, value interface{}) (err error)
- func (o *TObject) This() interface{}
- func (o *TObject) ToParent(parent Class) interface{}
- type TagValue
Constants ¶
This section is empty.
Variables ¶
View Source
var TDemo1Class = ClassOf((*TDemo1)(nil))
View Source
var TDemo2Class = ClassOf((*TDemo2)(nil), NewClassTagByMap(map[string]string{
"filter": "11111",
"summary": "this is Demo2 class tag test",
}))
View Source
var TObjectClass = ClassOf((*TObject)(nil))
Functions ¶
func FieldGetBoolFunc ¶
func FieldGetComplex128Func ¶
func FieldGetComplex64Func ¶
func FieldGetFloat32Func ¶
func FieldGetFloat64Func ¶
func FieldGetInt16Func ¶
func FieldGetInt32Func ¶
func FieldGetInt64Func ¶
func FieldGetInt8Func ¶
func FieldGetIntFunc ¶
func FieldGetInterfaceFunc ¶
func FieldGetStringFunc ¶
func FieldGetUint16Func ¶
func FieldGetUint32Func ¶
func FieldGetUint64Func ¶
func FieldGetUint8Func ¶
func FieldGetUintFunc ¶
func FieldSetAnyFunc ¶
func FieldSetBoolFunc ¶
func FieldSetChanFunc ¶
func FieldSetComplex128Func ¶
func FieldSetComplex64Func ¶
func FieldSetFloat32Func ¶
func FieldSetFloat64Func ¶
func FieldSetInt16Func ¶
func FieldSetInt32Func ¶
func FieldSetInt64Func ¶
func FieldSetInt8Func ¶
func FieldSetIntFunc ¶
func FieldSetMapFunc ¶
func FieldSetPtrFunc ¶
func FieldSetSliceFunc ¶
func FieldSetStringFunc ¶
func FieldSetStructFunc ¶
func FieldSetUint16Func ¶
func FieldSetUint32Func ¶
func FieldSetUint64Func ¶
func FieldSetUint8Func ¶
func FieldSetUintFunc ¶
func FieldSetUintPtrFunc ¶
Types ¶
type ClassField ¶
type ClassField struct {
// contains filtered or unexported fields
}
func (*ClassField) Name ¶
func (cf *ClassField) Name() string
func (*ClassField) String ¶
func (cf *ClassField) String() string
func (*ClassField) Tag ¶
func (cf *ClassField) Tag() ClassTag
func (*ClassField) Type ¶
func (cf *ClassField) Type() reflect.Type
type ClassMethod ¶
type ClassMethod struct {
// contains filtered or unexported fields
}
func (*ClassMethod) Name ¶
func (cm *ClassMethod) Name() string
func (*ClassMethod) ParamTypes ¶
func (cm *ClassMethod) ParamTypes() []reflect.Type
func (*ClassMethod) ResultTypes ¶
func (cm *ClassMethod) ResultTypes() []reflect.Type
func (*ClassMethod) String ¶
func (cm *ClassMethod) String() string
type ClassTag ¶
type ClassTag = *TClassTag
func GetClassTag ¶
func NewClassTag ¶
func NewClassTagByMap ¶
type Object ¶
type Object interface { // 类对象构造方法 // inst:为类实例指定, props参数由实现子类管理参数个数 Constructor(props ...interface{}) interface{} // 析构方法 Destroy() // 类实例指针 This() interface{} // 创建新实例 NewInstance(props ...interface{}) interface{} // 是否继承某类 Implements(parent Class) bool // 转换成父类指针 ToParent(parent Class) interface{} // 类名称 ClassName() string // 类类型 ClassType() reflect.Type // 设置字段值 Set(fieldName string, value interface{}) error // 自动转换数据类型为字段类型后设置字段值 SafeSet(fieldName string, value interface{}) (err error) // 获取字段值 Get(fieldName string) interface{} GetVar(fieldName string) *_type.TVar // 设置动态字段值, 如果字段不存在则不设置,返回字段原来值 DynamicSet(fieldName string, value interface{}) interface{} // 设置动态字段值,字段不存在时则创建,返回字段原来值 DynamicTrySet(fieldName string, value interface{}) interface{} // 获取动态字段值 DynamicGet(fieldName string) interface{} DynamicGetVar(fieldName string) *_type.TVar // 获取或设置动态字段, 如果不存在时,使使用setValue进行设置,setValue可以是实际值或func() interface{}类型的函数 DynamicGetOrSet(fieldName string, setValue interface{}) interface{} DynamicGetOrSetVar(fieldName string, setValue interface{}) *_type.TVar // 调用类方法 Call(method string, params ...interface{}) (results []interface{}, err error) // 检查类是否存在某方法 HasMethod(method string) bool // 检查类是否存在某字段 HasField(fieldName string) bool // 是否存在某动态字段 HasDynamicField(fieldName string) bool // 动态字段值 DynamicFieldCount() int // 遍历动态字段列表,fn返回false时结束遍历 ForEachDynamicFields(fn func(k string, v interface{}) bool) // 类对象定义字段数 FieldCount() int // 遍历对象字段列表 ForEachFields(fn func(fieldName string, tag ClassTag, fieldType reflect.Type) bool) // 类对象定义方法数 MethodCount() int // 类tag注解 ClassTag() ClassTag // 获取类对象所有字段列表 Fields() []*ClassField // 获取类对象方法列表 Methods() []*ClassMethod // 遍历类对象方法 ForEachMethods(fn func(methodName string, params []reflect.Type, results []reflect.Type) bool) }
type ObjectFieldObserver ¶
type ObjectFieldObserver interface { // 当设置字段值时触发,仅在调用Set、DynamicSet、DynamicTrySet、DynamicGetOrSet方法设置新值时发生.如果返回false将取消设置 OnFieldChanged(fieldName string, oldV, newV interface{}) bool }
类对象观察器
type ObjectHello ¶
type ObjectHello interface {
Hello() string
}
type TDemo1 ¶
func (*TDemo1) Constructor ¶
func (d *TDemo1) Constructor(props ...interface{}) interface{}
type TDemo2 ¶
func (*TDemo2) Constructor ¶
func (d2 *TDemo2) Constructor(props ...interface{}) interface{}
func (*TDemo2) OnFieldChanged ¶
type TObject ¶
type TObject struct {
// contains filtered or unexported fields
}
func (*TObject) Constructor ¶
func (o *TObject) Constructor(props ...interface{}) interface{}
func (*TObject) DynamicFieldCount ¶
func (*TObject) DynamicGetOrSet ¶
func (*TObject) DynamicGetOrSetVar ¶
func (*TObject) DynamicSet ¶
设置动态字段值,如果字段不存在则不进行设置
func (*TObject) DynamicTrySet ¶
字段存不存在都设置新值
func (*TObject) Fields ¶
func (o *TObject) Fields() []*ClassField
func (*TObject) ForEachDynamicFields ¶
func (*TObject) ForEachFields ¶
func (*TObject) ForEachMethods ¶
func (*TObject) HasDynamicField ¶
func (*TObject) Methods ¶
func (o *TObject) Methods() []*ClassMethod
func (*TObject) NewInstance ¶
func (o *TObject) NewInstance(props ...interface{}) interface{}
Source Files
¶
- xclass.go
- xclass_class.go
- xclass_extend_field.go
- xclass_field.go
- xclass_func.go
- xclass_method.go
- xclass_object.go
- xclass_object_api.go
- xclass_object_extend.go
- xclass_object_fields.go
- xclass_object_hello.go
- xclass_object_iface.go
- xclass_object_methods.go
- xclass_object_observer.go
- xclass_object_props.go
- xclass_test_demo.go
- xclass_vt.go
- xclass_vt_alloc.go
- xclass_vt_class.go
- xclass_vt_class_api.go
- xclass_vt_class_tree.go
- xclass_vt_class_tree_api.go
- xclass_vt_extend_field.go
- xclass_vt_extend_field_api.go
- xclass_vt_field.go
- xclass_vt_field_api.go
- xclass_vt_field_getter.go
- xclass_vt_field_getter_api.go
- xclass_vt_field_setter.go
- xclass_vt_field_setter_api.go
- xclass_vt_field_tag.go
- xclass_vt_method.go
- xclass_vt_method_api.go
Click to show internal directories.
Click to hide internal directories.