summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2023-12-21 23:42:56 +0000
committer Spandan Das <spandandas@google.com> 2023-12-22 00:06:05 +0000
commit24c1cbe63e19e6c5145fe8c0391e6334bcdd17b1 (patch)
tree3e2d8d4760880b6edbe18c919b430f23c5b02785
parenta41b8ecc62e0b91357e9067243488f53c27b5209 (diff)
Reland "Remove non-generic provider APIs"
There are no more callers to the non-generic provider APIs, remove them. This reapplies I4d336340e630643f98531787a81e0f1f18ec108d after I79736e44d85bc6e8c97f08ebf783b40533a3e6ae removed a newly introduced usage. Bug: 316410648 Change-Id: I152f8e5ef8330b811d3f42f8c2c73943ac0979bb Test: builds
-rw-r--r--android/base_module_context.go51
-rw-r--r--android/provider.go4
-rw-r--r--android/testing.go10
3 files changed, 15 insertions, 50 deletions
diff --git a/android/base_module_context.go b/android/base_module_context.go
index 2a4b12ee5..3dfe1234b 100644
--- a/android/base_module_context.go
+++ b/android/base_module_context.go
@@ -75,34 +75,28 @@ type BaseModuleContext interface {
// It is intended for use inside the visit functions of Visit* and WalkDeps.
OtherModuleType(m blueprint.Module) string
- // OtherModuleProvider returns the value for a provider for the given module. If the value is
- // not set it returns the zero value of the type of the provider, so the return value can always
- // be type asserted to the type of the provider. The value returned may be a deep copy of the
- // value originally passed to SetProvider.
- OtherModuleProvider(m blueprint.Module, provider blueprint.AnyProviderKey) any
-
- // OtherModuleHasProvider returns true if the provider for the given module has been set.
- OtherModuleHasProvider(m blueprint.Module, provider blueprint.AnyProviderKey) bool
-
+ // otherModuleProvider returns the value for a provider for the given module. If the value is
+ // not set it returns nil and false. The value returned may be a deep copy of the value originally
+ // passed to SetProvider.
+ //
+ // This method shouldn't be used directly, prefer the type-safe android.OtherModuleProvider instead.
otherModuleProvider(m blueprint.Module, provider blueprint.AnyProviderKey) (any, bool)
// Provider returns the value for a provider for the current module. If the value is
- // not set it returns the zero value of the type of the provider, so the return value can always
- // be type asserted to the type of the provider. It panics if called before the appropriate
+ // not set it returns nil and false. It panics if called before the appropriate
// mutator or GenerateBuildActions pass for the provider. The value returned may be a deep
// copy of the value originally passed to SetProvider.
- Provider(provider blueprint.AnyProviderKey) any
-
- // HasProvider returns true if the provider for the current module has been set.
- HasProvider(provider blueprint.AnyProviderKey) bool
-
+ //
+ // This method shouldn't be used directly, prefer the type-safe android.ModuleProvider instead.
provider(provider blueprint.AnyProviderKey) (any, bool)
- // SetProvider sets the value for a provider for the current module. It panics if not called
+ // setProvider sets the value for a provider for the current module. It panics if not called
// during the appropriate mutator or GenerateBuildActions pass for the provider, if the value
// is not of the appropriate type, or if the value has already been set. The value should not
// be modified after being passed to SetProvider.
- SetProvider(provider blueprint.AnyProviderKey, value interface{})
+ //
+ // This method shouldn't be used directly, prefer the type-safe android.SetProvider instead.
+ setProvider(provider blueprint.AnyProviderKey, value any)
GetDirectDepsWithTag(tag blueprint.DependencyTag) []Module
@@ -264,35 +258,16 @@ func (b *baseModuleContext) OtherModuleReverseDependencyVariantExists(name strin
func (b *baseModuleContext) OtherModuleType(m blueprint.Module) string {
return b.bp.OtherModuleType(m)
}
-func (b *baseModuleContext) OtherModuleProvider(m blueprint.Module, provider blueprint.AnyProviderKey) any {
- value, _ := b.bp.OtherModuleProvider(m, provider)
- return value
-}
-
-func (b *baseModuleContext) OtherModuleHasProvider(m blueprint.Module, provider blueprint.AnyProviderKey) bool {
- _, ok := b.bp.OtherModuleProvider(m, provider)
- return ok
-}
func (b *baseModuleContext) otherModuleProvider(m blueprint.Module, provider blueprint.AnyProviderKey) (any, bool) {
return b.bp.OtherModuleProvider(m, provider)
}
-func (b *baseModuleContext) Provider(provider blueprint.AnyProviderKey) any {
- value, _ := b.bp.Provider(provider)
- return value
-}
-
-func (b *baseModuleContext) HasProvider(provider blueprint.AnyProviderKey) bool {
- _, ok := b.bp.Provider(provider)
- return ok
-}
-
func (b *baseModuleContext) provider(provider blueprint.AnyProviderKey) (any, bool) {
return b.bp.Provider(provider)
}
-func (b *baseModuleContext) SetProvider(provider blueprint.AnyProviderKey, value any) {
+func (b *baseModuleContext) setProvider(provider blueprint.AnyProviderKey, value any) {
b.bp.SetProvider(provider, value)
}
diff --git a/android/provider.go b/android/provider.go
index b2cc7c06d..3b9c5d2ba 100644
--- a/android/provider.go
+++ b/android/provider.go
@@ -79,7 +79,7 @@ func SingletonModuleProvider[K any](ctx SingletonModuleProviderContext, module b
// SetProviderContext is a helper interface that is a subset of ModuleContext, BottomUpMutatorContext, or
// TopDownMutatorContext for use in SetProvider.
type SetProviderContext interface {
- SetProvider(provider blueprint.AnyProviderKey, value any)
+ setProvider(provider blueprint.AnyProviderKey, value any)
}
var _ SetProviderContext = BaseModuleContext(nil)
@@ -95,7 +95,7 @@ var _ SetProviderContext = TopDownMutatorContext(nil)
// SetProviderContext is a helper interface that accepts ModuleContext, BottomUpMutatorContext, or
// TopDownMutatorContext.
func SetProvider[K any](ctx SetProviderContext, provider blueprint.ProviderKey[K], value K) {
- ctx.SetProvider(provider, value)
+ ctx.setProvider(provider, value)
}
var _ OtherModuleProviderContext = (*otherModuleProviderAdaptor)(nil)
diff --git a/android/testing.go b/android/testing.go
index 39a268b23..3d0300a01 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -203,16 +203,6 @@ func (ctx *TestContext) HardCodedPreArchMutators(f RegisterMutatorFunc) {
ctx.PreArchMutators(f)
}
-func (ctx *TestContext) ModuleProvider(m blueprint.Module, p blueprint.AnyProviderKey) any {
- value, _ := ctx.Context.ModuleProvider(m, p)
- return value
-}
-
-func (ctx *TestContext) ModuleHasProvider(m blueprint.Module, p blueprint.AnyProviderKey) bool {
- _, ok := ctx.Context.ModuleProvider(m, p)
- return ok
-}
-
func (ctx *TestContext) moduleProvider(m blueprint.Module, p blueprint.AnyProviderKey) (any, bool) {
return ctx.Context.ModuleProvider(m, p)
}