Rename Evaluate() to Get() and add GetDefault()

Part of the design of property structs is that they were easy to access.
In keeping with that spirit, use a shorter and easier to spell name
for the getter, and add GetDefault() so that you don't need to pass
the result of Get() to one of the
proptools.StringDefault/BoolDefault/etc functions.

Bug: 323382414
Test: m nothing --no-skip-soong-tests
Change-Id: I0b8df151de59f2cd9463425c6666cbfda6bf47f2
This commit is contained in:
Cole Faust 2024-04-04 10:55:19 -07:00
parent 02dd6e5640
commit b78ce43ae3
2 changed files with 7 additions and 7 deletions

View file

@ -109,9 +109,9 @@ func pathPropertiesForPropertyStruct(ctx BottomUpMutatorContext, ps interface{})
case reflect.Struct: case reflect.Struct:
intf := sv.Interface() intf := sv.Interface()
if configurable, ok := intf.(proptools.Configurable[string]); ok { if configurable, ok := intf.(proptools.Configurable[string]); ok {
ret = append(ret, proptools.String(configurable.Evaluate(ctx))) ret = append(ret, configurable.GetOrDefault(ctx, ""))
} else if configurable, ok := intf.(proptools.Configurable[[]string]); ok { } else if configurable, ok := intf.(proptools.Configurable[[]string]); ok {
ret = append(ret, proptools.Slice(configurable.Evaluate(ctx))...) ret = append(ret, configurable.GetOrDefault(ctx, nil)...)
} else { } else {
panic(fmt.Errorf(`field %s in type %s has tag android:"path" but is not a string or slice of strings, it is a %s`, panic(fmt.Errorf(`field %s in type %s has tag android:"path" but is not a string or slice of strings, it is a %s`,
v.Type().FieldByIndex(i).Name, v.Type(), sv.Type())) v.Type().FieldByIndex(i).Name, v.Type(), sv.Type()))

View file

@ -489,11 +489,11 @@ type selectsMockModule struct {
func (p *selectsMockModule) GenerateAndroidBuildActions(ctx ModuleContext) { func (p *selectsMockModule) GenerateAndroidBuildActions(ctx ModuleContext) {
SetProvider(ctx, selectsTestProviderKey, selectsTestProvider{ SetProvider(ctx, selectsTestProviderKey, selectsTestProvider{
my_bool: p.properties.My_bool.Evaluate(ctx), my_bool: p.properties.My_bool.Get(ctx),
my_string: p.properties.My_string.Evaluate(ctx), my_string: p.properties.My_string.Get(ctx),
my_string_list: p.properties.My_string_list.Evaluate(ctx), my_string_list: p.properties.My_string_list.Get(ctx),
my_paths: p.properties.My_paths.Evaluate(ctx), my_paths: p.properties.My_paths.Get(ctx),
replacing_string_list: p.properties.Replacing_string_list.Evaluate(ctx), replacing_string_list: p.properties.Replacing_string_list.Get(ctx),
}) })
} }