// NewCompileContext constructs a *CompileContext from a *Mrb.
432822
func NewCompileContext(m *Mrb) *CompileContext {
	return &CompileContext{
		ctx: C.mrbc_context_new(m.state),
		mrb: m,
	}
}
630939
func NewContext(ctx context.Context, ci CallInfo) context.Context {
	return context.WithValue(ctx, callInfoKey, ci)
}
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,
	}
}
1217986
func NewContext(ctx context.Context, v *LoggerMeta) context.Context {
	if v == nil {
		return ctx
	}

	return context.WithValue(ctx, loggerMetaKey, v)
}
217260
func MakeContext(
	creator keybase1.UserOrTeamID, writer keybase1.UserOrTeamID, nonce RefNonce,
	bType keybase1.BlockType) Context {
	return Context{
		Creator:   creator,
		Writer:    writer,
		RefNonce:  nonce,
		BlockType: bType,
	}
}
1001696
func NewContextWithContext(name string, ctx context.Context) *Context {
	return &Context{
		Context: ctx,
		Name:    name,
		Args:    []string{},
		data:    map[interface{}]interface{}{},
		moot:    &sync.Mutex{},
	}
}
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
}
1235036
func (w *Ware) CreateContext() *context {
	c := &context{inject.New(), w.handlers, w.action, nil, 0}
	c.SetParent(w)
	c.MapTo(c, (*Context)(nil))
	return c
}
1264423
func NewContext(BlockSize int) *Context {
	return &Context{
		blockSize:    BlockSize,
		uniqueHasher: md5.New(),
	}
}
841658
func NewContext(api APIClient, dataDir string) *Context {
	return &Context{
		api:      api,
		dataDir:  dataDir,
		payloads: make(map[string]payload.Payload),
		updates:  make(map[string]payload.Payload),
	}
}
729613
func NewContext(bashpath string, debug bool) (*Context, error) {
	executable, err := osext.Executable()
	if err != nil {
		return nil, err
	}
	return &Context{
		Debug:    debug,
		BashPath: bashpath,
		SelfPath: executable,
		Stdin:    os.Stdin,
		Stdout:   os.Stdout,
		Stderr:   os.Stderr,
		scripts:  make([][]byte, 0),
		vars:     make([]string, 0),
		funcs:    make(map[string]func([]string)),
	}, nil
}
1241751
func NewContext(width, height int) *Context {
	return NewContextForRGBA(image.NewRGBA(image.Rect(0, 0, width, height)))
}
135403
func NewContextManager() *ContextManager {
	mgr := &ContextManager{values: make(map[uint]Values)}
	mgrRegistryMtx.Lock()
	defer mgrRegistryMtx.Unlock()
	mgrRegistry[mgr] = true
	return mgr
}
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
}
99599
func (widgets *Widgets) NewContext(context *Context) *Context {
	if context == nil {
		context = &Context{}
	}

	if context.DB == nil {
		context.DB = widgets.Config.DB
	}

	if context.Options == nil {
		context.Options = map[string]interface{}{}
	}

	if context.FuncMaps == nil {
		context.FuncMaps = template.FuncMap{}
	}

	for key, fc := range widgets.funcMaps {
		if _, ok := context.FuncMaps[key]; !ok {
			context.FuncMaps[key] = fc
		}
	}

	context.Widgets = widgets
	return context
}
517682
func NewContext(res http.ResponseWriter, req *http.Request) *Context {
	return NewContextWith(res, req, nil)
}
608565
func NewContext(ctx context.Context, xs XStater) context.Context {
	return context.WithValue(ctx, xstatsKey, xs)
}