init: simplify keyword_map
I've heard that keyword_map is too complex, in particular the tuple
and the pair in BuiltinFunctionMap, so this change removes a lot of
that complexity and, more importantly, better documents how all of
this works.
Test: boot, init unit tests
Change-Id: I74e5f9de7f2ec524cb6127bb9da2956b5f307f56
diff --git a/init/builtins.h b/init/builtins.h
index 7bbf6aa..f0ff1eb 100644
--- a/init/builtins.h
+++ b/init/builtins.h
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-#ifndef _INIT_BUILTINS_H
-#define _INIT_BUILTINS_H
+#pragma once
#include <functional>
#include <map>
@@ -31,18 +30,16 @@
using BuiltinFunction = std::function<Result<void>(const BuiltinArguments&)>;
-using KeywordFunctionMap = KeywordMap<std::pair<bool, BuiltinFunction>>;
-class BuiltinFunctionMap : public KeywordFunctionMap {
- public:
- BuiltinFunctionMap() {}
-
- private:
- const Map& map() const override;
+struct BuiltinFunctionMapValue {
+ bool run_in_subcontext;
+ BuiltinFunction function;
};
+using BuiltinFunctionMap = KeywordMap<BuiltinFunctionMapValue>;
+
+const BuiltinFunctionMap& GetBuiltinFunctionMap();
+
extern std::vector<std::string> late_import_paths;
} // namespace init
} // namespace android
-
-#endif