-
Notifications
You must be signed in to change notification settings - Fork 0
/
opertaion.go
38 lines (32 loc) · 899 Bytes
/
opertaion.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package jsonpack
import (
"github.com/modern-go/reflect2"
)
type operation struct {
propName string
handler opHandler
handlerType opHandlerType
children []*operation
}
type structOperation struct {
handler opHandler
handlerType opHandlerType
opType reflect2.Type
opInstance *operation
field reflect2.StructField
isPtrType bool
children []*structOperation
}
func newOperation(field string, handler opHandler, handlerType opHandlerType) *operation {
return &operation{field, handler, handlerType, make([]*operation, 0)}
}
func newStructOperation(handler opHandler, handlerType opHandlerType) *structOperation {
op := &structOperation{}
op.handler = handler
op.handlerType = handlerType
op.children = make([]*structOperation, 0)
return op
}
func (s *structOperation) appendChild(child *structOperation) {
s.children = append(s.children, child)
}