object

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MakeVirtual = func(__proto__ interface{}, properties properties) {
	makeVirtual(__proto__.(prototype), properties)
}
View Source
var TypeError = func(prototype interface{}) error {
	return fmt.Errorf("%v is not a Class", reflect.TypeOf(prototype).String())
}

Functions

func FuncAnalyse

func FuncAnalyse(m interface{})

func GetFunctionFullName

func GetFunctionFullName(i interface{}) string

func GetFunctionName

func GetFunctionName(i interface{}) string

func GetMembers

func GetMembers(i interface{})

获取一个对象的字段和方法

Types

type Class

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

抽象类,因为interface没有成员变量 通过class,将外部结构体转为接口

func (*Class) Invoke

func (c *Class) Invoke(method interface{}, args ...interface{}) []interface{}

func (*Class) InvokeByName

func (c *Class) InvokeByName(name string, args ...interface{}) []interface{}

call virtual method by name 后续增加虚函数表缓存策略

func (*Class) SetProperities

func (c *Class) SetProperities(properties properties)

func (*Class) SetProto

func (c *Class) SetProto(__proto__ prototype)

type Father

type Father struct {
	Class
	Name string
}

func (*Father) Say

func (*Father) Say()

func (Father) Speak

func (Father) Speak()

type Son

type Son struct {
	Father
}

public Son : public Father Son需要继承自Father,而需要对Father做访问权限控制,则想到增加代理类,如同智能指针一样, class就是代理类 MakeVirtual 为son的构造函数

func (*Son) Hello

func (*Son) Hello(string)

func (*Son) Say

func (*Son) Say(name string)

Jump to

Keyboard shortcuts

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