github.com/gobwas/gtrace@v0.4.3/test/test_returned_gtrace.go (about)

     1  // Code generated by gtrace. DO NOT EDIT.
     2  
     3  package test
     4  
     5  // Compose returns a new TraceReturningTrace which has functional fields composed
     6  // both from t and x.
     7  func (t TraceReturningTrace) Compose(x TraceReturningTrace) (ret TraceReturningTrace) {
     8  	switch {
     9  	case t.OnReturnedTrace == nil:
    10  		ret.OnReturnedTrace = x.OnReturnedTrace
    11  	case x.OnReturnedTrace == nil:
    12  		ret.OnReturnedTrace = t.OnReturnedTrace
    13  	default:
    14  		h1 := t.OnReturnedTrace
    15  		h2 := x.OnReturnedTrace
    16  		ret.OnReturnedTrace = func() ReturnedTrace {
    17  			r1 := h1()
    18  			r2 := h2()
    19  			switch {
    20  			case r1.isZero():
    21  				return r2
    22  			case r2.isZero():
    23  				return r1
    24  			default:
    25  				return r1.Compose(r2)
    26  			}
    27  		}
    28  	}
    29  	return ret
    30  }
    31  func (t TraceReturningTrace) onReturnedTrace() ReturnedTrace {
    32  	fn := t.OnReturnedTrace
    33  	if fn == nil {
    34  		return ReturnedTrace{}
    35  	}
    36  	res := fn()
    37  	return res
    38  }
    39  // Compose returns a new ReturnedTrace which has functional fields composed
    40  // both from t and x.
    41  func (t ReturnedTrace) Compose(x ReturnedTrace) (ret ReturnedTrace) {
    42  	switch {
    43  	case t.OnSomething == nil:
    44  		ret.OnSomething = x.OnSomething
    45  	case x.OnSomething == nil:
    46  		ret.OnSomething = t.OnSomething
    47  	default:
    48  		h1 := t.OnSomething
    49  		h2 := x.OnSomething
    50  		ret.OnSomething = func(a int, b int) {
    51  			h1(a, b)
    52  			h2(a, b)
    53  		}
    54  	}
    55  	switch {
    56  	case t.OnFoo == nil:
    57  		ret.OnFoo = x.OnFoo
    58  	case x.OnFoo == nil:
    59  		ret.OnFoo = t.OnFoo
    60  	default:
    61  		h1 := t.OnFoo
    62  		h2 := x.OnFoo
    63  		ret.OnFoo = func(i int, i1 int) {
    64  			h1(i, i1)
    65  			h2(i, i1)
    66  		}
    67  	}
    68  	switch {
    69  	case t.OnBar == nil:
    70  		ret.OnBar = x.OnBar
    71  	case x.OnBar == nil:
    72  		ret.OnBar = t.OnBar
    73  	default:
    74  		h1 := t.OnBar
    75  		h2 := x.OnBar
    76  		ret.OnBar = func(i int, i1 int) {
    77  			h1(i, i1)
    78  			h2(i, i1)
    79  		}
    80  	}
    81  	switch {
    82  	case t.OnBaz == nil:
    83  		ret.OnBaz = x.OnBaz
    84  	case x.OnBaz == nil:
    85  		ret.OnBaz = t.OnBaz
    86  	default:
    87  		h1 := t.OnBaz
    88  		h2 := x.OnBaz
    89  		ret.OnBaz = func(i int, i1 int) {
    90  			h1(i, i1)
    91  			h2(i, i1)
    92  		}
    93  	}
    94  	return ret
    95  }
    96  // isZero checks whether t is empty
    97  func (t ReturnedTrace) isZero() bool {
    98  	if t.OnSomething != nil {
    99  		return false
   100  	}
   101  	if t.OnFoo != nil {
   102  		return false
   103  	}
   104  	if t.OnBar != nil {
   105  		return false
   106  	}
   107  	if t.OnBaz != nil {
   108  		return false
   109  	}
   110  	return true
   111  }
   112  func (t ReturnedTrace) onSomething(a int, b int) {
   113  	fn := t.OnSomething
   114  	if fn == nil {
   115  		return
   116  	}
   117  	fn(a, b)
   118  }
   119  func (t ReturnedTrace) onFoo(i int, i1 int) {
   120  	fn := t.OnFoo
   121  	if fn == nil {
   122  		return
   123  	}
   124  	fn(i, i1)
   125  }
   126  func (t ReturnedTrace) onBar(i int, i1 int) {
   127  	fn := t.OnBar
   128  	if fn == nil {
   129  		return
   130  	}
   131  	fn(i, i1)
   132  }
   133  func (t ReturnedTrace) onBaz(i int, i1 int) {
   134  	fn := t.OnBaz
   135  	if fn == nil {
   136  		return
   137  	}
   138  	fn(i, i1)
   139  }
   140  func traceReturningTraceOnReturnedTrace(t TraceReturningTrace) ReturnedTrace {
   141  	res := t.onReturnedTrace()
   142  	return res
   143  }