github.com/traefik/yaegi@v0.15.1/stdlib/go1_20_context.go (about)

     1  // Code generated by 'yaegi extract context'. DO NOT EDIT.
     2  
     3  //go:build go1.20
     4  // +build go1.20
     5  
     6  package stdlib
     7  
     8  import (
     9  	"context"
    10  	"reflect"
    11  	"time"
    12  )
    13  
    14  func init() {
    15  	Symbols["context/context"] = map[string]reflect.Value{
    16  		// function, constant and variable definitions
    17  		"Background":       reflect.ValueOf(context.Background),
    18  		"Canceled":         reflect.ValueOf(&context.Canceled).Elem(),
    19  		"Cause":            reflect.ValueOf(context.Cause),
    20  		"DeadlineExceeded": reflect.ValueOf(&context.DeadlineExceeded).Elem(),
    21  		"TODO":             reflect.ValueOf(context.TODO),
    22  		"WithCancel":       reflect.ValueOf(context.WithCancel),
    23  		"WithCancelCause":  reflect.ValueOf(context.WithCancelCause),
    24  		"WithDeadline":     reflect.ValueOf(context.WithDeadline),
    25  		"WithTimeout":      reflect.ValueOf(context.WithTimeout),
    26  		"WithValue":        reflect.ValueOf(context.WithValue),
    27  
    28  		// type definitions
    29  		"CancelCauseFunc": reflect.ValueOf((*context.CancelCauseFunc)(nil)),
    30  		"CancelFunc":      reflect.ValueOf((*context.CancelFunc)(nil)),
    31  		"Context":         reflect.ValueOf((*context.Context)(nil)),
    32  
    33  		// interface wrapper definitions
    34  		"_Context": reflect.ValueOf((*_context_Context)(nil)),
    35  	}
    36  }
    37  
    38  // _context_Context is an interface wrapper for Context type
    39  type _context_Context struct {
    40  	IValue    interface{}
    41  	WDeadline func() (deadline time.Time, ok bool)
    42  	WDone     func() <-chan struct{}
    43  	WErr      func() error
    44  	WValue    func(key any) any
    45  }
    46  
    47  func (W _context_Context) Deadline() (deadline time.Time, ok bool) {
    48  	return W.WDeadline()
    49  }
    50  func (W _context_Context) Done() <-chan struct{} {
    51  	return W.WDone()
    52  }
    53  func (W _context_Context) Err() error {
    54  	return W.WErr()
    55  }
    56  func (W _context_Context) Value(key any) any {
    57  	return W.WValue(key)
    58  }