A few minor changes.
- Make module 'new' functions return slices of properties structs rather than
just one.
- Fix a couple places where errors were being reported incorrectly.
- Add ModuleContext methods for dealing with other modules.
- Make property value unpacking skip unexported struct fields rather than
panicing.
Change-Id: I4775ef77ff0514fc2ce5abccbe2ce534c05272f4
diff --git a/blueprint/module_ctx.go b/blueprint/module_ctx.go
index 19f6d10..f664c93 100644
--- a/blueprint/module_ctx.go
+++ b/blueprint/module_ctx.go
@@ -11,11 +11,13 @@
type ModuleContext interface {
ModuleName() string
+ OtherModuleName(m Module) string
ModuleDir() string
Config() interface{}
ModuleErrorf(fmt string, args ...interface{})
PropertyErrorf(property, fmt string, args ...interface{})
+ OtherModuleErrorf(m Module, fmt string, args ...interface{})
Variable(name, value string)
Rule(name string, params RuleParams, argNames ...string) Rule
@@ -43,6 +45,11 @@
return m.info.properties.Name
}
+func (m *moduleContext) OtherModuleName(module Module) string {
+ info := m.context.moduleInfo[module]
+ return info.properties.Name
+}
+
func (m *moduleContext) ModuleDir() string {
return filepath.Dir(m.info.relBlueprintsFile)
}
@@ -72,6 +79,16 @@
})
}
+func (m *moduleContext) OtherModuleErrorf(module Module, format string,
+ args ...interface{}) {
+
+ info := m.context.moduleInfo[module]
+ m.errs = append(m.errs, &Error{
+ Err: fmt.Errorf(format, args...),
+ Pos: info.pos,
+ })
+}
+
func (m *moduleContext) Variable(name, value string) {
v, err := m.scope.AddLocalVariable(name, value)
if err != nil {