diff options
author | Wim <wim@42.be> | 2020-01-09 21:52:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-09 21:52:19 +0100 |
commit | 9d84d6dd643c4017074e81465671cd9b25f9539a (patch) | |
tree | 8a767f91d655a6cf21d476e4fb7aa6fd8a952df8 /vendor/github.com/d5/tengo/objects/module_map.go | |
parent | 0f708daf2d14dcca261ef98cc698a1b1f2a6aa74 (diff) | |
download | matterbridge-msglm-9d84d6dd643c4017074e81465671cd9b25f9539a.tar.gz matterbridge-msglm-9d84d6dd643c4017074e81465671cd9b25f9539a.tar.bz2 matterbridge-msglm-9d84d6dd643c4017074e81465671cd9b25f9539a.zip |
Update to tengo v2 (#976)
Diffstat (limited to 'vendor/github.com/d5/tengo/objects/module_map.go')
-rw-r--r-- | vendor/github.com/d5/tengo/objects/module_map.go | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/vendor/github.com/d5/tengo/objects/module_map.go b/vendor/github.com/d5/tengo/objects/module_map.go deleted file mode 100644 index 874b8a2b..00000000 --- a/vendor/github.com/d5/tengo/objects/module_map.go +++ /dev/null @@ -1,77 +0,0 @@ -package objects - -// ModuleMap represents a set of named modules. -// Use NewModuleMap to create a new module map. -type ModuleMap struct { - m map[string]Importable -} - -// NewModuleMap creates a new module map. -func NewModuleMap() *ModuleMap { - return &ModuleMap{ - m: make(map[string]Importable), - } -} - -// Add adds an import module. -func (m *ModuleMap) Add(name string, module Importable) { - m.m[name] = module -} - -// AddBuiltinModule adds a builtin module. -func (m *ModuleMap) AddBuiltinModule(name string, attrs map[string]Object) { - m.m[name] = &BuiltinModule{Attrs: attrs} -} - -// AddSourceModule adds a source module. -func (m *ModuleMap) AddSourceModule(name string, src []byte) { - m.m[name] = &SourceModule{Src: src} -} - -// Remove removes a named module. -func (m *ModuleMap) Remove(name string) { - delete(m.m, name) -} - -// Get returns an import module identified by name. -// It returns if the name is not found. -func (m *ModuleMap) Get(name string) Importable { - return m.m[name] -} - -// GetBuiltinModule returns a builtin module identified by name. -// It returns if the name is not found or the module is not a builtin module. -func (m *ModuleMap) GetBuiltinModule(name string) *BuiltinModule { - mod, _ := m.m[name].(*BuiltinModule) - return mod -} - -// GetSourceModule returns a source module identified by name. -// It returns if the name is not found or the module is not a source module. -func (m *ModuleMap) GetSourceModule(name string) *SourceModule { - mod, _ := m.m[name].(*SourceModule) - return mod -} - -// Copy creates a copy of the module map. -func (m *ModuleMap) Copy() *ModuleMap { - c := &ModuleMap{ - m: make(map[string]Importable), - } - for name, mod := range m.m { - c.m[name] = mod - } - return c -} - -// Len returns the number of named modules. -func (m *ModuleMap) Len() int { - return len(m.m) -} - -// AddMap adds named modules from another module map. -func (m *ModuleMap) AddMap(o *ModuleMap) { - for name, mod := range o.m { - m.m[name] = mod - } -} |