// requireGlobal imports module modName into the global namespace with the
// identifier id.  panics if an error results from the function execution
540651
func requireGlobal(l *lua.LState, id, modName string) {
	if err := l.CallByParam(lua.P{
		Fn:      l.GetGlobal("require"),
		NRet:    1,
		Protect: true,
	}, lua.LString(modName)); err != nil {
		panic(err)
	}
	mod := l.Get(-1)
	l.Pop(1)

	l.SetGlobal(id, mod)
}
931903
func GetOperGlobal(obj *GlobalInspect) error {
	// Check if we handle this object
	if objCallbackHandler.GlobalCb == nil {
		log.Errorf("No callback registered for global object")
		return errors.New("Invalid object type")
	}

	// Perform callback
	err := objCallbackHandler.GlobalCb.GlobalGetOper(obj)
	if err != nil {
		log.Errorf("GlobalDelete retruned error for: %+v. Err: %v", obj, err)
		return err
	}

	return nil
}
305676
func FindGlobal(key string) *Global {
	collections.globalMutex.Lock()
	defer collections.globalMutex.Unlock()

	obj := collections.globals[key]
	if obj == nil {
		return nil
	}

	return obj
}
1334713
func (c *Runtime) GlobalLexicalScopeNames(executionContextId int) ([]string, error) {
	var v RuntimeGlobalLexicalScopeNamesParams
	v.ExecutionContextId = executionContextId
	return c.GlobalLexicalScopeNamesWithParams(&v)
}
106526
func (m *Manager) AddRequiredScope(globalId string, requiredScope RequiredScope) error {
	qry := bson.M{"globalid": globalId}
	update := bson.M{"$push": bson.M{"requiredscopes": requiredScope}}
	return m.collection.Update(qry, update)
}
924743
func (ctx *Context) PushGlobalGoFunction(name string, f interface{}) (int, error) {
	return ctx.Context.PushGlobalGoFunction(name, ctx.wrapFunction(f))
}
1178099
func CreateGlobal(obj *Global) error {
	// Validate parameters
	err := ValidateGlobal(obj)
	if err != nil {
		log.Errorf("ValidateGlobal retruned error for: %+v. Err: %v", obj, err)
		return err
	}

	// Check if we handle this object
	if objCallbackHandler.GlobalCb == nil {
		log.Errorf("No callback registered for global object")
		return errors.New("Invalid object type")
	}

	saveObj := obj

	collections.globalMutex.Lock()
	key := collections.globals[obj.Key]
	collections.globalMutex.Unlock()

	// Check if object already exists
	if key != nil {
		// Perform Update callback
		err = objCallbackHandler.GlobalCb.GlobalUpdate(collections.globals[obj.Key], obj)
		if err != nil {
			log.Errorf("GlobalUpdate retruned error for: %+v. Err: %v", obj, err)
			return err
		}

		// save the original object after update
		collections.globalMutex.Lock()
		saveObj = collections.globals[obj.Key]
		collections.globalMutex.Unlock()
	} else {
		// save it in cache
		collections.globalMutex.Lock()
		collections.globals[obj.Key] = obj
		collections.globalMutex.Unlock()

		// Perform Create callback
		err = objCallbackHandler.GlobalCb.GlobalCreate(obj)
		if err != nil {
			log.Errorf("GlobalCreate retruned error for: %+v. Err: %v", obj, err)
			collections.globalMutex.Lock()
			delete(collections.globals, obj.Key)
			collections.globalMutex.Unlock()
			return err
		}
	}

	// Write it to modeldb
	collections.globalMutex.Lock()
	err = saveObj.Write()
	collections.globalMutex.Unlock()
	if err != nil {
		log.Errorf("Error saving global %s to db. Err: %v", saveObj.Key, err)
		return err
	}

	return nil
}
872516
func NewGlobalContext() *GlobalContext {
	log := logger.New("keybase")
	ret := &GlobalContext{
		Log:                log,
		VDL:                NewVDebugLog(log),
		SKBKeyringMu:       new(sync.Mutex),
		perUserKeyringMu:   new(sync.Mutex),
		cacheMu:            new(sync.RWMutex),
		socketWrapperMu:    new(sync.RWMutex),
		shutdownOnce:       new(sync.Once),
		clockMu:            new(sync.Mutex),
		clock:              clockwork.NewRealClock(),
		hookMu:             new(sync.RWMutex),
		oodiMu:             new(sync.RWMutex),
		outOfDateInfo:      &keybase1.OutOfDateInfo{},
		lastUpgradeWarning: new(time.Time),
		uchMu:              new(sync.Mutex),
		secretStoreMu:      new(sync.Mutex),
		NewTriplesec:       NewSecureTriplesec,
		ActiveDevice:       NewActiveDevice(),
		switchUserMu:       NewVerboseLock(VLog0, "switchUserMu"),
		FeatureFlags:       NewFeatureFlagSet(),
		switchedUsers:      make(map[NormalizedUsername]bool),
	}
	return ret
}
960616
func (s *Set) AddGlobal(key string, i interface{}) *Set {
	s.gmx.Lock()
	if s.globals == nil {
		s.globals = make(VarMap)
	}
	s.globals[key] = reflect.ValueOf(i)
	s.gmx.Unlock()
	return s
}
212496
func (ebs *awsElasticBlockStore) GetGlobalMapPath(spec *volume.Spec) (string, error) {
	volumeSource, _, err := getVolumeSource(spec)
	if err != nil {
		return "", err
	}
	return filepath.Join(ebs.plugin.host.GetVolumeDevicePluginDir(awsElasticBlockStorePluginName), string(volumeSource.VolumeID)), nil
}
508592
func (b *Builder) RequireObject(require bool) *Builder {
	b.requireObject = require
	return b
}
149227
func (c *Context) GlobalGeneric(name string) interface{} {
	if fs := lookupGlobalFlagSet(name, c); fs != nil {
		return lookupGeneric(name, fs)
	}
	return nil
}
579372
func (s *DescribeGlobalTableSettingsOutput) SetGlobalTableName(v string) *DescribeGlobalTableSettingsOutput {
	s.GlobalTableName = &v
	return s
}
315750
func (c *Context) GlobalInt64Slice(name string) []int64 {
	if fs := lookupGlobalFlagSet(name, c); fs != nil {
		return lookupInt64Slice(name, fs)
	}
	return nil
}
1254259
func (c *Context) GlobalBool(name string) bool {
	return lookupBool(name, c.globalSet)
}
808885
func (c *Context) GlobalIntSlice(name string) []int {
	if fs := lookupGlobalFlagSet(name, c); fs != nil {
		return lookupIntSlice(name, fs)
	}
	return nil
}
1174522
func (d *Context) RequireContext(index int) *Context {
	return contextFromPointer(C.duk_require_context(d.duk_context, C.duk_idx_t(index)))
}