github.com/gobwas/gtrace@v0.4.3/test/test_shortcut_gtrace.go (about) 1 // Code generated by gtrace. DO NOT EDIT. 2 3 package test 4 5 // Compose returns a new ShortcutPerFieldTrace which has functional fields composed 6 // both from t and x. 7 func (t ShortcutPerFieldTrace) Compose(x ShortcutPerFieldTrace) (ret ShortcutPerFieldTrace) { 8 switch { 9 case t.OnFoo == nil: 10 ret.OnFoo = x.OnFoo 11 case x.OnFoo == nil: 12 ret.OnFoo = t.OnFoo 13 default: 14 h1 := t.OnFoo 15 h2 := x.OnFoo 16 ret.OnFoo = func() { 17 h1() 18 h2() 19 } 20 } 21 switch { 22 case t.OnBar == nil: 23 ret.OnBar = x.OnBar 24 case x.OnBar == nil: 25 ret.OnBar = t.OnBar 26 default: 27 h1 := t.OnBar 28 h2 := x.OnBar 29 ret.OnBar = func() { 30 h1() 31 h2() 32 } 33 } 34 return ret 35 } 36 func (t ShortcutPerFieldTrace) onFoo() { 37 fn := t.OnFoo 38 if fn == nil { 39 return 40 } 41 fn() 42 } 43 func (t ShortcutPerFieldTrace) onBar() { 44 fn := t.OnBar 45 if fn == nil { 46 return 47 } 48 fn() 49 } 50 func shortcutPerFieldTraceOnFoo(t ShortcutPerFieldTrace) { 51 t.onFoo() 52 }