Loading tools/aconfig/src/codegen_cpp.rs +13 −28 Original line number Diff line number Diff line Loading @@ -136,10 +136,8 @@ mod tests { use std::collections::HashMap; const EXPORTED_PROD_HEADER_EXPECTED: &str = r#" #ifndef com_android_aconfig_test_HEADER_H #define com_android_aconfig_test_HEADER_H #pragma once #include <string> #include <memory> namespace com::android::aconfig::test { Loading Loading @@ -176,14 +174,11 @@ inline bool enabled_rw() { } } #endif "#; const EXPORTED_TEST_HEADER_EXPECTED: &str = r#" #ifndef com_android_aconfig_test_HEADER_H #define com_android_aconfig_test_HEADER_H #pragma once #include <string> #include <memory> namespace com::android::aconfig::test { Loading Loading @@ -250,16 +245,13 @@ inline void reset_flags() { } } #endif "#; const PROD_FLAG_PROVIDER_HEADER_EXPECTED: &str = r#" #ifndef com_android_aconfig_test_flag_provider_HEADER_H #define com_android_aconfig_test_flag_provider_HEADER_H #pragma once #include "com_android_aconfig_test.h" #include <server_configurable_flags/get_flags.h> using namespace server_configurable_flags; namespace com::android::aconfig::test { class flag_provider : public flag_provider_interface { Loading @@ -270,7 +262,7 @@ public: } virtual bool disabled_rw() override { return GetServerConfigurableFlag( return server_configurable_flags::GetServerConfigurableFlag( "aconfig_test", "com.android.aconfig.test.disabled_rw", "false") == "true"; Loading @@ -281,25 +273,23 @@ public: } virtual bool enabled_rw() override { return GetServerConfigurableFlag( return server_configurable_flags::GetServerConfigurableFlag( "aconfig_test", "com.android.aconfig.test.enabled_rw", "true") == "true"; } }; } #endif "#; const TEST_FLAG_PROVIDER_HEADER_EXPECTED: &str = r#" #ifndef com_android_aconfig_test_flag_provider_HEADER_H #define com_android_aconfig_test_flag_provider_HEADER_H #pragma once #include "com_android_aconfig_test.h" #include <server_configurable_flags/get_flags.h> using namespace server_configurable_flags; #include <unordered_map> #include <string> namespace com::android::aconfig::test { class flag_provider : public flag_provider_interface { Loading Loading @@ -330,7 +320,7 @@ public: if (it != overrides_.end()) { return it->second; } else { return GetServerConfigurableFlag( return server_configurable_flags::GetServerConfigurableFlag( "aconfig_test", "com.android.aconfig.test.disabled_rw", "false") == "true"; Loading Loading @@ -359,7 +349,7 @@ public: if (it != overrides_.end()) { return it->second; } else { return GetServerConfigurableFlag( return server_configurable_flags::GetServerConfigurableFlag( "aconfig_test", "com.android.aconfig.test.enabled_rw", "true") == "true"; Loading @@ -375,7 +365,6 @@ public: } }; } #endif "#; const SOURCE_FILE_EXPECTED: &str = r#" Loading @@ -389,8 +378,7 @@ namespace com::android::aconfig::test { "#; const C_EXPORTED_PROD_HEADER_EXPECTED: &str = r#" #ifndef com_android_aconfig_test_c_HEADER_H #define com_android_aconfig_test_c_HEADER_H #pragma once #ifdef __cplusplus extern "C" { Loading @@ -407,12 +395,10 @@ bool com_android_aconfig_test_enabled_rw(); #ifdef __cplusplus } #endif #endif "#; const C_EXPORTED_TEST_HEADER_EXPECTED: &str = r#" #ifndef com_android_aconfig_test_c_HEADER_H #define com_android_aconfig_test_c_HEADER_H #pragma once #ifdef __cplusplus extern "C" { Loading @@ -439,7 +425,6 @@ void com_android_aconfig_test_reset_flags(); #ifdef __cplusplus } #endif #endif "#; const C_PROD_SOURCE_FILE_EXPECTED: &str = r#" Loading @@ -447,7 +432,7 @@ void com_android_aconfig_test_reset_flags(); #include "com_android_aconfig_test.h" bool com_android_aconfig_test_disabled_ro() { return com::android::aconfig::test::disabled_ro(); return false; } bool com_android_aconfig_test_disabled_rw() { Loading @@ -455,7 +440,7 @@ bool com_android_aconfig_test_disabled_rw() { } bool com_android_aconfig_test_enabled_ro() { return com::android::aconfig::test::enabled_ro(); return true; } bool com_android_aconfig_test_enabled_rw() { Loading tools/aconfig/templates/c_exported_header.template +1 −3 Original line number Diff line number Diff line #ifndef {header}_c_HEADER_H #define {header}_c_HEADER_H #pragma once #ifdef __cplusplus extern "C" \{ Loading @@ -20,4 +19,3 @@ void {header}_reset_flags(); #ifdef __cplusplus } #endif #endif tools/aconfig/templates/c_source_file.template +8 −0 Original line number Diff line number Diff line Loading @@ -3,7 +3,15 @@ {{ for item in class_elements}} bool {header}_{item.flag_name}() \{ {{ if for_test }} return {cpp_namespace}::{item.flag_name}(); {{ -else- }} {{ if not item.readwrite- }} return {item.default_value}; {{ -else- }} return {cpp_namespace}::{item.flag_name}(); {{ -endif }} {{ -endif }} } {{ if for_test }} Loading tools/aconfig/templates/cpp_exported_header.template +1 −4 Original line number Diff line number Diff line #ifndef {header}_HEADER_H #define {header}_HEADER_H #pragma once #include <string> #include <memory> namespace {cpp_namespace} \{ Loading Loading @@ -50,4 +48,3 @@ inline void reset_flags() \{ } {{ -endif }} } #endif tools/aconfig/templates/cpp_prod_flag_provider.template +3 −5 Original line number Diff line number Diff line #ifndef {header}_flag_provider_HEADER_H #define {header}_flag_provider_HEADER_H #pragma once #include "{header}.h" {{ if readwrite }} #include <server_configurable_flags/get_flags.h> using namespace server_configurable_flags; {{ endif }} namespace {cpp_namespace} \{ Loading @@ -12,7 +11,7 @@ public: {{ for item in class_elements}} virtual bool {item.flag_name}() override \{ {{ if item.readwrite- }} return GetServerConfigurableFlag( return server_configurable_flags::GetServerConfigurableFlag( "{item.device_config_namespace}", "{item.device_config_flag}", "{item.default_value}") == "true"; Loading @@ -23,4 +22,3 @@ public: {{ endfor }} }; } #endif Loading
tools/aconfig/src/codegen_cpp.rs +13 −28 Original line number Diff line number Diff line Loading @@ -136,10 +136,8 @@ mod tests { use std::collections::HashMap; const EXPORTED_PROD_HEADER_EXPECTED: &str = r#" #ifndef com_android_aconfig_test_HEADER_H #define com_android_aconfig_test_HEADER_H #pragma once #include <string> #include <memory> namespace com::android::aconfig::test { Loading Loading @@ -176,14 +174,11 @@ inline bool enabled_rw() { } } #endif "#; const EXPORTED_TEST_HEADER_EXPECTED: &str = r#" #ifndef com_android_aconfig_test_HEADER_H #define com_android_aconfig_test_HEADER_H #pragma once #include <string> #include <memory> namespace com::android::aconfig::test { Loading Loading @@ -250,16 +245,13 @@ inline void reset_flags() { } } #endif "#; const PROD_FLAG_PROVIDER_HEADER_EXPECTED: &str = r#" #ifndef com_android_aconfig_test_flag_provider_HEADER_H #define com_android_aconfig_test_flag_provider_HEADER_H #pragma once #include "com_android_aconfig_test.h" #include <server_configurable_flags/get_flags.h> using namespace server_configurable_flags; namespace com::android::aconfig::test { class flag_provider : public flag_provider_interface { Loading @@ -270,7 +262,7 @@ public: } virtual bool disabled_rw() override { return GetServerConfigurableFlag( return server_configurable_flags::GetServerConfigurableFlag( "aconfig_test", "com.android.aconfig.test.disabled_rw", "false") == "true"; Loading @@ -281,25 +273,23 @@ public: } virtual bool enabled_rw() override { return GetServerConfigurableFlag( return server_configurable_flags::GetServerConfigurableFlag( "aconfig_test", "com.android.aconfig.test.enabled_rw", "true") == "true"; } }; } #endif "#; const TEST_FLAG_PROVIDER_HEADER_EXPECTED: &str = r#" #ifndef com_android_aconfig_test_flag_provider_HEADER_H #define com_android_aconfig_test_flag_provider_HEADER_H #pragma once #include "com_android_aconfig_test.h" #include <server_configurable_flags/get_flags.h> using namespace server_configurable_flags; #include <unordered_map> #include <string> namespace com::android::aconfig::test { class flag_provider : public flag_provider_interface { Loading Loading @@ -330,7 +320,7 @@ public: if (it != overrides_.end()) { return it->second; } else { return GetServerConfigurableFlag( return server_configurable_flags::GetServerConfigurableFlag( "aconfig_test", "com.android.aconfig.test.disabled_rw", "false") == "true"; Loading Loading @@ -359,7 +349,7 @@ public: if (it != overrides_.end()) { return it->second; } else { return GetServerConfigurableFlag( return server_configurable_flags::GetServerConfigurableFlag( "aconfig_test", "com.android.aconfig.test.enabled_rw", "true") == "true"; Loading @@ -375,7 +365,6 @@ public: } }; } #endif "#; const SOURCE_FILE_EXPECTED: &str = r#" Loading @@ -389,8 +378,7 @@ namespace com::android::aconfig::test { "#; const C_EXPORTED_PROD_HEADER_EXPECTED: &str = r#" #ifndef com_android_aconfig_test_c_HEADER_H #define com_android_aconfig_test_c_HEADER_H #pragma once #ifdef __cplusplus extern "C" { Loading @@ -407,12 +395,10 @@ bool com_android_aconfig_test_enabled_rw(); #ifdef __cplusplus } #endif #endif "#; const C_EXPORTED_TEST_HEADER_EXPECTED: &str = r#" #ifndef com_android_aconfig_test_c_HEADER_H #define com_android_aconfig_test_c_HEADER_H #pragma once #ifdef __cplusplus extern "C" { Loading @@ -439,7 +425,6 @@ void com_android_aconfig_test_reset_flags(); #ifdef __cplusplus } #endif #endif "#; const C_PROD_SOURCE_FILE_EXPECTED: &str = r#" Loading @@ -447,7 +432,7 @@ void com_android_aconfig_test_reset_flags(); #include "com_android_aconfig_test.h" bool com_android_aconfig_test_disabled_ro() { return com::android::aconfig::test::disabled_ro(); return false; } bool com_android_aconfig_test_disabled_rw() { Loading @@ -455,7 +440,7 @@ bool com_android_aconfig_test_disabled_rw() { } bool com_android_aconfig_test_enabled_ro() { return com::android::aconfig::test::enabled_ro(); return true; } bool com_android_aconfig_test_enabled_rw() { Loading
tools/aconfig/templates/c_exported_header.template +1 −3 Original line number Diff line number Diff line #ifndef {header}_c_HEADER_H #define {header}_c_HEADER_H #pragma once #ifdef __cplusplus extern "C" \{ Loading @@ -20,4 +19,3 @@ void {header}_reset_flags(); #ifdef __cplusplus } #endif #endif
tools/aconfig/templates/c_source_file.template +8 −0 Original line number Diff line number Diff line Loading @@ -3,7 +3,15 @@ {{ for item in class_elements}} bool {header}_{item.flag_name}() \{ {{ if for_test }} return {cpp_namespace}::{item.flag_name}(); {{ -else- }} {{ if not item.readwrite- }} return {item.default_value}; {{ -else- }} return {cpp_namespace}::{item.flag_name}(); {{ -endif }} {{ -endif }} } {{ if for_test }} Loading
tools/aconfig/templates/cpp_exported_header.template +1 −4 Original line number Diff line number Diff line #ifndef {header}_HEADER_H #define {header}_HEADER_H #pragma once #include <string> #include <memory> namespace {cpp_namespace} \{ Loading Loading @@ -50,4 +48,3 @@ inline void reset_flags() \{ } {{ -endif }} } #endif
tools/aconfig/templates/cpp_prod_flag_provider.template +3 −5 Original line number Diff line number Diff line #ifndef {header}_flag_provider_HEADER_H #define {header}_flag_provider_HEADER_H #pragma once #include "{header}.h" {{ if readwrite }} #include <server_configurable_flags/get_flags.h> using namespace server_configurable_flags; {{ endif }} namespace {cpp_namespace} \{ Loading @@ -12,7 +11,7 @@ public: {{ for item in class_elements}} virtual bool {item.flag_name}() override \{ {{ if item.readwrite- }} return GetServerConfigurableFlag( return server_configurable_flags::GetServerConfigurableFlag( "{item.device_config_namespace}", "{item.device_config_flag}", "{item.default_value}") == "true"; Loading @@ -23,4 +22,3 @@ public: {{ endfor }} }; } #endif