github.com/hsfzxjy/dgo/go@v0.2.0/go_method.go (about) 1 package dgo 2 3 type MethodCallImplFunc func(*Port, MethodCallFlag, []*Dart_CObject) 4 5 type MethodCallId uint32 6 7 type MethodCallFlag uint16 8 9 func (f MethodCallFlag) IsPinned() bool { return f&0b1 != 0 } 10 11 var methodCallMap = map[MethodCallId]MethodCallImplFunc{} 12 13 //lint:ignore U1000 Use go:linkname to call this function 14 func methodCallRegister(funcId MethodCallId, impl MethodCallImplFunc) { 15 methodCallMap[funcId] = impl 16 } 17 18 type invokingGoMethod struct { 19 payload uint64 20 port *Port 21 } 22 23 func (m invokingGoMethod) id() MethodCallId { return MethodCallId(m.payload & (1<<32 - 1)) } 24 func (m invokingGoMethod) flag() MethodCallFlag { return MethodCallFlag(m.payload >> 32) } 25 26 func (m invokingGoMethod) specialInt() {} 27 func (m invokingGoMethod) handleCObjects(objs []*Dart_CObject) { 28 methodCallMap[m.id()](m.port, m.flag(), objs) 29 }