// NewContext creates a new Context. This is the only function that will panic if it is unable to create the context.
492087
func NewContext() (retVal *Context) {
	var internal C.cudnnHandle_t
	if err := result(C.cudnnCreate(&internal)); err != nil {
		panic(err)
	}
	retVal = &Context{internal}
	return retVal
}
85393
func NewContext(b *parser.Builder, nameSystems namer.NameSystems, canonicalOrderName string) (*Context, error) {
	universe, err := b.FindTypes()
	if err != nil {
		return nil, err
	}

	c := &Context{
		Namers:   namer.NameSystems{},
		Universe: universe,
		Inputs:   b.FindPackages(),
		FileTypes: map[string]FileType{
			GolangFileType: NewGolangFile(),
		},
		builder: b,
	}

	for name, systemNamer := range nameSystems {
		c.Namers[name] = systemNamer
		if name == canonicalOrderName {
			orderer := namer.Orderer{Namer: systemNamer}
			c.Order = orderer.OrderUniverse(universe)
		}
	}
	return c, nil
}
181677
func NewContext(ctx context.Context, logger KayveeLogger) context.Context {
	return context.WithValue(ctx, loggerKey, logger)
}
528049
func NewContext() Context {
	ctx := Context{}
	smokingChoices := []randutil.Choice{
		{2, "Smoker"},
		{3, "Non-smoker"},
		{1, "Ex-smoker"}}
	sc, _ := randutil.WeightedChoice(smokingChoices)
	ctx.Smoker = sc.Item.(string)

	alcoholChoices := []randutil.Choice{
		{2, "Occasional"},
		{1, "Heavy"},
		{1, "None"}}
	ac, _ := randutil.WeightedChoice(alcoholChoices)
	ctx.Alcohol = ac.Item.(string)

	cholesterolChoices := []randutil.Choice{
		{3, "Optimal"},
		{1, "Near Optimal"},
		{2, "Borderline"},
		{1, "High"},
		{2, "Very High"}}
	cc, _ := randutil.WeightedChoice(cholesterolChoices)
	ctx.Cholesterol = cc.Item.(string)

	hc, _ := randutil.ChoiceString([]string{"Normal", "Pre-hypertension", "Hypertension"})
	ctx.Hypertention = hc

	dc, _ := randutil.ChoiceString([]string{"Normal", "Pre-diabetes", "Diabetes"})
	ctx.Diabetes = dc
	return ctx
}
898564
func newContext(ctx context.Context, resource, name string, gvk schema.GroupVersionKind) context.Context {
	oldInfo, found := genericapirequest.RequestInfoFrom(ctx)
	if !found {
		return ctx
	}
	newInfo := genericapirequest.RequestInfo{
		IsResourceRequest: true,
		Verb:              "get",
		Namespace:         oldInfo.Namespace,
		Resource:          resource,
		Name:              name,
		Parts:             []string{resource, name},
		APIGroup:          gvk.Group,
		APIVersion:        gvk.Version,
	}
	return genericapirequest.WithRequestInfo(ctx, &newInfo)
}
480218
func NewContext(p Project, opts ...func(*Context) error) (*Context, error) {
	envOr := func(key, def string) string {
		if v := os.Getenv(key); v != "" {
			return v
		}
		return def
	}

	defaults := []func(*Context) error{
		// must come before GcToolchain()
		func(c *Context) error {
			c.gohostos = runtime.GOOS
			c.gohostarch = runtime.GOARCH
			c.gotargetos = envOr("GOOS", runtime.GOOS)
			c.gotargetarch = envOr("GOARCH", runtime.GOARCH)
			c.debug = func(string, ...interface{}) {} // null logger
			return nil
		},
		GcToolchain(),
	}
	workdir, err := ioutil.TempDir("", "gb")
	if err != nil {
		return nil, err
	}

	ctx := Context{
		Project:   p,
		workdir:   workdir,
		buildmode: "exe",
		pkgs:      make(map[string]*Package),
	}

	for _, opt := range append(defaults, opts...) {
		err := opt(&ctx)
		if err != nil {
			return nil, err
		}
	}

	// sort build tags to ensure the ctxSring and Suffix is stable
	sort.Strings(ctx.buildtags)

	bc := build.Default
	bc.GOOS = ctx.gotargetos
	bc.GOARCH = ctx.gotargetarch
	bc.CgoEnabled = cgoEnabled(ctx.gohostos, ctx.gohostarch, ctx.gotargetos, ctx.gotargetarch)
	bc.ReleaseTags = releaseTags
	bc.BuildTags = ctx.buildtags

	i, err := buildImporter(&bc, &ctx)
	if err != nil {
		return nil, err
	}

	ctx.importer = i

	// C and unsafe are fake packages synthesised by the compiler.
	// Insert fake packages into the package cache.
	for _, name := range []string{"C", "unsafe"} {
		pkg, err := ctx.newPackage(&build.Package{
			Name:       name,
			ImportPath: name,
			Dir:        name, // fake, but helps diagnostics
			Goroot:     true,
		})
		if err != nil {
			return nil, err
		}
		pkg.NotStale = true
		ctx.pkgs[pkg.ImportPath] = pkg
	}

	return &ctx, err
}
62412
func NewContext(req *http.Request) context.Context {
	return WithContext(context.Background(), req)
}
1304582
func NewContext(ctx context.Context, r *Registration, plugins *Set, root, state string) *InitContext {
	return &InitContext{
		Context: ctx,
		Root:    filepath.Join(root, r.URI()),
		State:   filepath.Join(state, r.URI()),
		Meta: &Meta{
			Exports: map[string]string{},
		},
		plugins: plugins,
	}
}
415863
func NewContext() *KBFSContext {
	g := libkb.NewGlobalContextInit()
	g.ConfigureConfig()
	g.ConfigureLogging()
	g.ConfigureCaches()
	g.ConfigureMerkleClient()
	return NewContextFromGlobalContext(g)
}
298871
func NewContext(ctx context.Context, msg *sqs.Message) context.Context {
	return context.WithValue(ctx, sqsMessageKey, msg)
}
571729
func NewContext(napnap *NapNap, req *http.Request, writer ResponseWriter) *Context {
	return &Context{
		NapNap:  napnap,
		Request: req,
		Writer:  writer,
	}
}
601305
func NewContext(ctx context.Context, rw http.ResponseWriter, req *http.Request, params url.Values) context.Context {
	if ctx == nil {
		ctx = context.Background()
	}
	request := &RequestData{Request: req, Params: params}
	response := &ResponseData{ResponseWriter: rw}
	ctx = context.WithValue(ctx, respKey, response)
	ctx = context.WithValue(ctx, reqKey, request)

	return ctx
}
13116
func NewContext(req *Request, res *Response, f *Fibre) *Context {
	return &Context{
		fibre:    f,
		request:  req,
		response: res,
	}
}
1249656
func NewContext() (*Context, error) {
	context := new(Context)
	err := tspiError(C.Tspi_Context_Create(&context.context))
	return context, err
}
142218
func NewContext(req engine.Request, res engine.Response, e *Echo) Context {
	c := &xContext{
		Validator:   DefaultNopValidate,
		Translator:  DefaultNopTranslate,
		Emitter:     emitter.DefaultCondEmitter,
		Transaction: DefaultNopTransaction,
		context:     context.Background(),
		request:     req,
		response:    res,
		echo:        e,
		pvalues:     make([]string, *e.maxParam),
		store:       make(Store),
		handler:     NotFoundHandler,
		funcs:       make(map[string]interface{}),
		sessioner:   DefaultSession,
	}
	c.cookier = NewCookier(c)
	c.dataEngine = NewData(c)
	return c
}
441297
func NewContext(ctx context.Context, log Interface) context.Context {
	return context.WithValue(ctx, LogCTXKey, log)
}
160093
func NewContext() *Context {
	ctx, cancel := context.WithCancel(context.Background())
	sctx := &Context{
		values:      make(map[fmt.Stringer]interface{}),
		sessionVars: variable.NewSessionVars(),
		ctx:         ctx,
		cancel:      cancel,
	}
	sctx.sessionVars.InitChunkSize = 2
	sctx.sessionVars.MaxChunkSize = 32
	sctx.sessionVars.StmtCtx.TimeZone = time.UTC
	sctx.sessionVars.GlobalVarsAccessor = variable.NewMockGlobalAccessor()
	return sctx
}