Make CreateModule return the newly created module

Allow mutators to modify properties of the newly created module
by returning it.

Test: m checkbuild
Change-Id: I682caca86c0c8f7c3ae815a494d4c75962c8e2e8
This commit is contained in:
Colin Cross
2019-09-25 12:58:36 -07:00
parent 7444910e93
commit e003c4abdd
2 changed files with 5 additions and 4 deletions

View File

@@ -121,7 +121,7 @@ type TopDownMutatorContext interface {
Rename(name string)
CreateModule(ModuleFactory, ...interface{})
CreateModule(ModuleFactory, ...interface{}) Module
}
type topDownMutatorContext struct {
@@ -243,9 +243,10 @@ func (t *topDownMutatorContext) Rename(name string) {
t.Module().base().commonProperties.DebugName = name
}
func (t *topDownMutatorContext) CreateModule(factory ModuleFactory, props ...interface{}) {
func (t *topDownMutatorContext) CreateModule(factory ModuleFactory, props ...interface{}) Module {
inherited := []interface{}{&t.Module().base().commonProperties, &t.Module().base().variableProperties}
t.bp.CreateModule(ModuleFactoryAdaptor(factory), append(inherited, props...)...)
module := t.bp.CreateModule(ModuleFactoryAdaptor(factory), append(inherited, props...)...).(Module)
return module
}
func (b *bottomUpMutatorContext) MutatorName() string {