diff --git a/ace_lite.gni b/ace_lite.gni index 32cda30..4b1749c 100755 --- a/ace_lite.gni +++ b/ace_lite.gni @@ -35,6 +35,7 @@ ace_lite_include_dirs = [ "//utils/native/lite/include", "${aafwk_lite_path}/interfaces/kits/ability_lite", "${aafwk_lite_path}/interfaces/kits/want_lite", + "${aafwk_lite_path}/frameworks/abilitymgr_lite/include", "${aafwk_lite_path}/interfaces/innerkits/abilitymgr_lite", "${appexecfwk_lite_path}/interfaces/kits/bundle_lite", "${appexecfwk_lite_path}/utils/bundle_lite", diff --git a/frameworks/BUILD.gn b/frameworks/BUILD.gn index 5b96908..196c3a6 100755 --- a/frameworks/BUILD.gn +++ b/frameworks/BUILD.gn @@ -25,25 +25,35 @@ lite_component("jsfwk") { config("ace_lite_config") { include_dirs = ace_lite_include_dirs - if (ohos_kernel_type == "liteos_a" || ohos_kernel_type == "liteos_m") { - include_dirs += [ "targets/liteos_a" ] - } else if (ohos_kernel_type == "linux") { - include_dirs += [ "targets/linux" ] - } + cflags_cc = [ "-std=c++14" ] ldflags = [ "-lstdc++" ] - ldflags += [ "-lpthread" ] - ldflags += [ "-Wl,-rpath-link=$ohos_root_path/$root_out_dir" ] + + if (ohos_kernel_type == "liteos_m") { + ldflags += [ "-lposix" ] + } else { + ldflags += [ "-lpthread" ] + ldflags += [ "-Wl,-rpath-link=$ohos_root_path/$root_out_dir" ] + } } -shared_library("ace_lite") { - configs -= [ "//build/lite/config:language_cpp" ] - cflags = [ "-Wall" ] - cflags_cc = cflags - configs += [ ":ace_lite_config" ] - public_configs = configs +lite_library("ace_lite") { + if (ohos_kernel_type == "liteos_m") { + target_type = "static_library" + } else { + target_type = "shared_library" + } + + deps = [ "targets" ] + public_configs = [ ":ace_lite_config" ] sources = ace_lite_sources + if (ohos_kernel_type == "liteos_m") { + sources -= [ + "$ACE_LITE_PATH/src/core/context/ace_ability.cpp", + "$ACE_LITE_PATH/src/core/modules/dfx_module.cpp", + ] + } public_deps = [ "$ACE_LITE_COMMON_PATH:ace_common_lite", @@ -51,19 +61,30 @@ shared_library("ace_lite") { "$NATIVE_ENGINE_PATH:ace_native_engine_lite", "//base/global/i18n_lite/frameworks/i18n:global_i18n", "//base/global/resmgr_lite/frameworks/resmgr_lite:global_resmgr", - "//build/lite/config/component/cJSON:cjson_shared", - "//foundation/graphic/surface:lite_surface", "//foundation/graphic/ui:lite_ui", - "//foundation/multimedia/camera_lite/frameworks:camera_lite", - "//foundation/multimedia/media_lite/frameworks/player_lite:player_lite", - "//third_party/bounds_checking_function:libsec_shared", - "//third_party/jerryscript/jerry-core:jerry-core_shared", - "//third_party/jerryscript/jerry-ext:jerry-ext_shared", - "//third_party/jerryscript/jerry-libm:jerry-libm_shared", - "//third_party/jerryscript/jerry-port/default:jerry-port-default_shared", "//utils/native/lite/timer_task:ace_kit_timer", ] + if (ohos_kernel_type == "liteos_m") { + public_deps += [ + "//build/lite/config/component/cJSON:cjson_static", + "//third_party/bounds_checking_function:libsec_static", + "//third_party/jerryscript:jerry_engine", + ] + } else { + public_deps += [ + "//build/lite/config/component/cJSON:cjson_shared", + "//foundation/graphic/surface:lite_surface", + "//foundation/multimedia/camera_lite/frameworks:camera_lite", + "//foundation/multimedia/media_lite/frameworks/player_lite:player_lite", + "//third_party/bounds_checking_function:libsec_shared", + "//third_party/jerryscript/jerry-core:jerry-core_shared", + "//third_party/jerryscript/jerry-ext:jerry-ext_shared", + "//third_party/jerryscript/jerry-libm:jerry-libm_shared", + "//third_party/jerryscript/jerry-port/default:jerry-port-default_shared", + ] + } + defines = [] if (ohos_build_type == "debug") { @@ -73,7 +94,7 @@ shared_library("ace_lite") { } if (LOSCFG_TEST_JS_BUILD) { - defines += [ "JSFWK_TEST" ] + defines += [ "JSFWK_TEST=1" ] } if (enable_ohos_appexecfwk_feature_ability == true) { diff --git a/frameworks/common/BUILD.gn b/frameworks/common/BUILD.gn old mode 100644 new mode 100755 index d51cc4e..5d18b6b --- a/frameworks/common/BUILD.gn +++ b/frameworks/common/BUILD.gn @@ -22,7 +22,13 @@ lite_component("ace_common_lite") { features = [ ":ace_common" ] } -shared_library("ace_common") { +lite_library("ace_common") { + if (ohos_kernel_type == "liteos_m") { + target_type = "static_library" + } else { + target_type = "shared_library" + } + include_dirs = [ "$ace_common_root/log", "$ace_common_root/memory", @@ -32,11 +38,6 @@ shared_library("ace_common") { "//base/hiviewdfx/hilog_lite/interfaces/native/kits", "//third_party/bounds_checking_function/include", ] - if (ohos_kernel_type == "liteos_a" || ohos_kernel_type == "liteos_m") { - include_dirs += [ "$ace_target_root/liteos_a" ] - } else if (ohos_kernel_type == "linux") { - include_dirs += [ "$ace_target_root/linux" ] - } cflags = [ "-Wall" ] cflags_cc = cflags @@ -49,5 +50,10 @@ shared_library("ace_common") { "$ace_common_root/memory/memory_heap.cpp", ] - public_deps = [ "//third_party/bounds_checking_function:libsec_shared" ] + if (ohos_kernel_type == "liteos_m") { + deps = [ "//third_party/bounds_checking_function:libsec_static" ] + } else { + deps = [ "//third_party/bounds_checking_function:libsec_shared" ] + } + deps += [ "$ace_target_root" ] } diff --git a/frameworks/common/log/ace_log.cpp b/frameworks/common/log/ace_log.cpp index 31d13c8..afe2abe 100644 --- a/frameworks/common/log/ace_log.cpp +++ b/frameworks/common/log/ace_log.cpp @@ -16,7 +16,7 @@ #include "ace_log.h" #include #include -#ifdef TARGET_SIMULATOR +#if (TARGET_SIMULATOR == 1) #include namespace OHOS { diff --git a/frameworks/common/log/ace_log.h b/frameworks/common/log/ace_log.h index 7cd4d83..bdff492 100644 --- a/frameworks/common/log/ace_log.h +++ b/frameworks/common/log/ace_log.h @@ -18,21 +18,21 @@ #include "acelite_config.h" -#if defined(FEATURE_ACELITE_HI_LOG_PRINTF) && defined(FEATURE_ACELITE_MC_LOG_PRINTF) +#if ((FEATURE_ACELITE_HI_LOG_PRINTF == 1) && (FEATURE_ACELITE_MC_LOG_PRINTF == 1)) #error Only one marco can be defined -#elif defined(FEATURE_ACELITE_HI_LOG_PRINTF) && defined(TARGET_SIMULATOR) +#elif ((FEATURE_ACELITE_HI_LOG_PRINTF == 1) && (TARGET_SIMULATOR == 1)) #error Only one marco can be defined -#elif defined(FEATURE_ACELITE_MC_LOG_PRINTF) && defined(TARGET_SIMULATOR) +#elif ((FEATURE_ACELITE_MC_LOG_PRINTF == 1) && (TARGET_SIMULATOR == 1)) #error Only one macro can be defined #endif -#if defined(FEATURE_ACELITE_HI_LOG_PRINTF) +#if (FEATURE_ACELITE_HI_LOG_PRINTF == 1) #undef LOG_DOMAIN #undef LOG_TAG #define LOG_DOMAIN 0xD003900 #define LOG_TAG "ACE" #include "hilog/log.h" -#elif defined(FEATURE_ACELITE_MC_LOG_PRINTF) +#elif (FEATURE_ACELITE_MC_LOG_PRINTF == 1) #include "hilog/log.h" #ifndef HILOG_DEBUG #define HILOG_DEBUG(mod, format, ...) @@ -52,7 +52,7 @@ #ifndef HILOG_RACE #define HILOG_RACE(mod, format, ...) #endif -#elif (defined(TARGET_SIMULATOR)) +#elif (TARGET_SIMULATOR == 1) namespace OHOS { namespace ACELite { typedef enum { HILOG_MODULE_ACE = 1 } HiLogModuleType; diff --git a/frameworks/include/base/dft_impl.h b/frameworks/include/base/dft_impl.h index 86742d3..37bee3e 100755 --- a/frameworks/include/base/dft_impl.h +++ b/frameworks/include/base/dft_impl.h @@ -18,7 +18,7 @@ #include "acelite_config.h" -#if (defined(OHOS_ACELITE_PRODUCT_WATCH) || (defined(FEATURE_CUSTOM_ENTRY_PAGE))) +#if ((OHOS_ACELITE_PRODUCT_WATCH == 1) || (FEATURE_CUSTOM_ENTRY_PAGE == 1)) #include "memory_heap.h" namespace OHOS { diff --git a/frameworks/include/base/js_config.h b/frameworks/include/base/js_config.h index e7c0257..d86ef4b 100644 --- a/frameworks/include/base/js_config.h +++ b/frameworks/include/base/js_config.h @@ -59,7 +59,7 @@ * * Default: 0 on real device and 1 on PC simulator */ -#ifdef TARGET_SIMULATOR +#if (TARGET_SIMULATOR == 1) #define ENGINE_DEBUGGER 1 #else #define ENGINE_DEBUGGER 0 diff --git a/frameworks/include/base/js_debugger_config.h b/frameworks/include/base/js_debugger_config.h index 134ea33..cc4a585 100644 --- a/frameworks/include/base/js_debugger_config.h +++ b/frameworks/include/base/js_debugger_config.h @@ -133,7 +133,7 @@ public: void ReleaseJSContext(); private: #if ENABLED(ENGINE_DEBUGGER) -#ifdef JS_ENGINE_EXTERNAL_CONTEXT +#if (JS_ENGINE_EXTERNAL_CONTEXT == 1) void *engineContext_ = nullptr; #endif // JS_ENGINE_EXTERNAL_CONTEXT bool debuggerStarted_ = false; diff --git a/frameworks/include/resource/video_panel_image_res.h b/frameworks/include/resource/video_panel_image_res.h index f939dd7..208f4a4 100644 --- a/frameworks/include/resource/video_panel_image_res.h +++ b/frameworks/include/resource/video_panel_image_res.h @@ -16,7 +16,7 @@ #ifndef OHOS_ACELITE_VIDEO_PANEL_IMAGE_RES_H #define OHOS_ACELITE_VIDEO_PANEL_IMAGE_RES_H #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) #include "gfx_utils/image_info.h" namespace OHOS { diff --git a/frameworks/module_manager/BUILD.gn b/frameworks/module_manager/BUILD.gn old mode 100644 new mode 100755 index a28ba6a..0e262cb --- a/frameworks/module_manager/BUILD.gn +++ b/frameworks/module_manager/BUILD.gn @@ -22,7 +22,15 @@ lite_component("ace_module_manager_lite") { features = [ ":ace_module_manager" ] } -shared_library("ace_module_manager") { +lite_library("ace_module_manager") { + if (ohos_kernel_type == "liteos_m") { + target_type = "static_library" + } else { + target_type = "shared_library" + cflags = [ "-Wall" ] + cflags_cc = cflags + } + include_dirs = [ "$ace_frameworks_root/common/log", "$ace_frameworks_root/common/utils", @@ -34,27 +42,31 @@ shared_library("ace_module_manager") { "//third_party/jerryscript/jerry-core/include", "//third_party/bounds_checking_function/include", ] - if (ohos_kernel_type == "liteos_a" || ohos_kernel_type == "liteos_m") { - include_dirs += [ "$ace_target_root/liteos_a" ] - } else if (ohos_kernel_type == "linux") { - include_dirs += [ "$ace_target_root/linux" ] - } - - cflags = [ "-Wall" ] - cflags_cc = cflags + deps = [ "$ace_target_root" ] sources = [ "$ace_frameworks_root/module_manager/module_manager.cpp" ] public_deps = [ "$ace_frameworks_root/common:ace_common_lite", "$ace_frameworks_root/native_engine:ace_native_engine_lite", - "${appexecfwk_lite_path}/interfaces/kits/bundle_lite/js/builtin:capability_api", - "//base/powermgr/battery_lite/frameworks/js:ace_battery_kits", - "//base/security/huks/frameworks/crypto_lite/js/builtin:ace_kit_cipher", - "//foundation/communication/netstack/frameworks/js/builtin:http_lite_shared", - "//foundation/multimedia/media_lite/interfaces/kits/player_lite/js/builtin:audio_lite_api", - "//third_party/bounds_checking_function:libsec_shared", - "//third_party/jerryscript/jerry-core:jerry-core_shared", "//utils/native/lite/js/builtin:ace_utils_kits", ] + + if (ohos_kernel_type == "liteos_m") { + public_deps += [ + "//foundation/graphic/ui:ui", + "//third_party/bounds_checking_function:libsec_static", + "//third_party/jerryscript:jerry_engine", + ] + } else { + public_deps += [ + "${appexecfwk_lite_path}/interfaces/kits/bundle_lite/js/builtin:capability_api", + "//base/powermgr/battery_lite/frameworks/js:ace_battery_kits", + "//base/security/huks/frameworks/crypto_lite/js/builtin:ace_kit_cipher", + "//foundation/communication/netstack/frameworks/js/builtin:http_lite_shared", + "//foundation/multimedia/media_lite/interfaces/kits/player_lite/js/builtin:audio_lite_api", + "//third_party/bounds_checking_function:libsec_shared", + "//third_party/jerryscript/jerry-core:jerry-core_shared", + ] + } } diff --git a/frameworks/module_manager/module_manager.cpp b/frameworks/module_manager/module_manager.cpp index 4a76f5a..57d04b3 100644 --- a/frameworks/module_manager/module_manager.cpp +++ b/frameworks/module_manager/module_manager.cpp @@ -39,14 +39,14 @@ JSIValue ModuleManager::RequireModule(const char * const moduleName) if (!strcmp(category, CATEGORY_SYSTEM) || !strcmp(category, CATEGORY_OHOS)) { uint16_t moduleCount = sizeof(OHOS_MODULES) / sizeof(Module); moduleObj = GetModuleObject(name, OHOS_MODULES, moduleCount, requiredSystemModules); -#ifdef FEATURE_PRODUCT_MODULE +#if (FEATURE_PRODUCT_MODULE == 1) if ((JSI::ValueIsUndefined(moduleObj)) && (productModulesGetter_ != nullptr)) { uint16_t prodModCount; const Module* prodModules = productModulesGetter_(prodModCount); moduleObj = GetModuleObject(name, prodModules, prodModCount, requiredSystemModules); } #endif // FEATURE_PRODUCT_MODULE -#ifdef FEATURE_PRIVATE_MODULE +#if (FEATURE_PRIVATE_MODULE == 1) if ((JSI::ValueIsUndefined(moduleObj)) && (privateModulesGetter_ != nullptr)) { const char * const bundleName = (bundleNameGetter_ != nullptr) ? bundleNameGetter_() : nullptr; moduleObj = GetModuleObject(name, nullptr, 0, requiredSystemModules, bundleName); @@ -149,7 +149,7 @@ JSIValue ModuleManager::GetModuleObject(const char * const moduleName, const Mod } } } -#ifdef FEATURE_PRIVATE_MODULE +#if (FEATURE_PRIVATE_MODULE == 1) else { uint16_t count; const PrivateModule *privateModules = diff --git a/frameworks/module_manager/ohos_module_config.h b/frameworks/module_manager/ohos_module_config.h index a0386c9..f8eb744 100644 --- a/frameworks/module_manager/ohos_module_config.h +++ b/frameworks/module_manager/ohos_module_config.h @@ -21,108 +21,108 @@ namespace OHOS { namespace ACELite { -#ifdef ENABLE_MODULE_REQUIRE_TEST +#if (ENABLE_MODULE_REQUIRE_TEST == 1) extern void InitSampleModule(JSIValue exports); #endif extern void InitRouterModule(JSIValue exports); extern void InitAppModule(JSIValue exports); -#ifdef FEATURE_SUPPORT_HTTP +#if (FEATURE_SUPPORT_HTTP == 1) extern void InitFetchModule(JSIValue exports); #endif // FEATURE_SUPPORT_HTTP -#ifdef FEATURE_MODULE_AUDIO +#if (FEATURE_MODULE_AUDIO == 1) extern void InitAudioModule(JSIValue exports); #endif // FEATURE_MODULE_AUDIO -#ifdef FEATURE_ACELITE_DFX_MODULE +#if (FEATURE_ACELITE_DFX_MODULE == 1) extern void InitDfxModule(JSIValue exports); #endif // FEATURE_ACELITE_DFX_MODULE -#ifdef ENABLE_MODULE_CIPHER +#if (ENABLE_MODULE_CIPHER == 1) extern void InitCipherModule(JSIValue exports); #endif -#ifdef FEATURE_MODULE_DIALOG +#if (FEATURE_MODULE_DIALOG == 1) extern void InitDialogModule(JSIValue exports); #endif // FEATURE_MODULE_DIALOG -#ifdef FEATURE_MODULE_STORAGE +#if (FEATURE_MODULE_STORAGE == 1) extern void InitNativeApiFs(JSIValue exports); extern void InitNativeApiKv(JSIValue exports); #endif -#ifdef FEATURE_MODULE_DEVICE +#if (FEATURE_MODULE_DEVICE == 1) extern void InitDeviceModule(JSIValue exports); #endif -#ifdef FEATURE_MODULE_GEO +#if (FEATURE_MODULE_GEO == 1) extern void InitLocationModule(JSIValue exports); #endif -#ifdef FEATURE_MODULE_SENSOR +#if (FEATURE_MODULE_SENSOR == 1) extern void InitVibratorModule(JSIValue exports); extern void InitSensorModule(JSIValue exports); #endif -#ifdef FEATURE_MODULE_BRIGHTNESS +#if (FEATURE_MODULE_BRIGHTNESS == 1) extern void InitBrightnessModule(JSIValue exports); #endif -#ifdef FEATURE_MODULE_BATTERY +#if (FEATURE_MODULE_BATTERY == 1) extern void InitBatteryModule(JSIValue exports); #endif -#ifdef FEATURE_MODULE_CONFIGURATION +#if (FEATURE_MODULE_CONFIGURATION == 1) extern void InitLocaleModule(JSIValue exports); #endif -#ifdef FEATURE_ACELITE_SYSTEM_CAPABILITY +#if (FEATURE_ACELITE_SYSTEM_CAPABILITY == 1) extern void InitCapabilityModule(JSIValue exports); #endif // Config information for built-in JS modules of OHOS platform const Module OHOS_MODULES[] = { -#ifdef ENABLE_MODULE_REQUIRE_TEST +#if (ENABLE_MODULE_REQUIRE_TEST == 1) {"sample", InitSampleModule}, #endif {"app", InitAppModule}, -#ifdef FEATURE_SUPPORT_HTTP +#if (FEATURE_SUPPORT_HTTP == 1) {"fetch", InitFetchModule}, #endif // FEATURE_SUPPORT_HTTP -#ifdef FEATURE_MODULE_AUDIO +#if (FEATURE_MODULE_AUDIO == 1) {"audio", InitAudioModule}, #endif // FEATURE_MODULE_AUDIO -#ifdef FEATURE_ACELITE_DFX_MODULE +#if (FEATURE_ACELITE_DFX_MODULE == 1) {"dfx", InitDfxModule}, #endif // FEATURE_ACELITE_DFX_MODULE {"router", InitRouterModule}, -#ifdef ENABLE_MODULE_CIPHER +#if (ENABLE_MODULE_CIPHER == 1) {"cipher", InitCipherModule}, #endif -#ifdef FEATURE_MODULE_DIALOG +#if (FEATURE_MODULE_DIALOG == 1) {"prompt", InitDialogModule}, #endif // FEATURE_MODULE_DIALOG -#ifdef FEATURE_MODULE_STORAGE +#if (FEATURE_MODULE_STORAGE == 1) {"file", InitNativeApiFs}, {"storage", InitNativeApiKv}, #endif -#ifdef FEATURE_MODULE_DEVICE +#if (FEATURE_MODULE_DEVICE == 1) {"device", InitDeviceModule}, #endif -#ifdef FEATURE_MODULE_GEO +#if (FEATURE_MODULE_GEO == 1) {"geolocation", InitLocationModule}, #endif -#ifdef FEATURE_MODULE_SENSOR +#if (FEATURE_MODULE_SENSOR == 1) {"vibrator", InitVibratorModule}, {"sensor", InitSensorModule}, #endif -#ifdef FEATURE_MODULE_BRIGHTNESS +#if (FEATURE_MODULE_BRIGHTNESS == 1) {"brightness", InitBrightnessModule}, #endif -#ifdef FEATURE_MODULE_BATTERY +#if (FEATURE_MODULE_BATTERY == 1) {"battery", InitBatteryModule}, #endif -#ifdef FEATURE_MODULE_CONFIGURATION +#if (FEATURE_MODULE_CONFIGURATION == 1) {"configuration", InitLocaleModule}, #endif -#ifdef FEATURE_ACELITE_SYSTEM_CAPABILITY +#if (FEATURE_ACELITE_SYSTEM_CAPABILITY == 1) {"capability", InitCapabilityModule}, #endif }; diff --git a/frameworks/native_engine/BUILD.gn b/frameworks/native_engine/BUILD.gn old mode 100644 new mode 100755 index ac56627..139cf4e --- a/frameworks/native_engine/BUILD.gn +++ b/frameworks/native_engine/BUILD.gn @@ -23,7 +23,13 @@ lite_component("ace_native_engine_lite") { features = [ ":ace_native_engine" ] } -shared_library("ace_native_engine") { +lite_library("ace_native_engine") { + if (ohos_kernel_type == "liteos_m") { + target_type = "static_library" + } else { + target_type = "shared_library" + } + include_dirs = [ "$ace_common_root/log", "$ace_common_root/memory", @@ -33,11 +39,8 @@ shared_library("ace_native_engine") { "//base/hiviewdfx/hilog_lite/interfaces/native/kits", "//third_party/jerryscript/jerry-core/include", ] - if (ohos_kernel_type == "liteos_a" || ohos_kernel_type == "liteos_m") { - include_dirs += [ "$ace_target_root/liteos_a" ] - } else if (ohos_kernel_type == "linux") { - include_dirs += [ "$ace_target_root/linux" ] - } + + deps = [ "$ace_target_root" ] cflags = [ "-Wall" ] cflags_cc = cflags @@ -48,8 +51,14 @@ shared_library("ace_native_engine") { "$native_engine_root/jsi/jsi.cpp", ] - public_deps = [ - "$ace_common_root:ace_common_lite", - "//third_party/jerryscript/jerry-core:jerry-core_shared", - ] + public_deps = [ "$ace_common_root:ace_common_lite" ] + + if (ohos_kernel_type == "liteos_m") { + public_deps += [ + "//foundation/graphic/ui:ui", + "//third_party/jerryscript:jerry_engine", + ] + } else { + public_deps += [ "//third_party/jerryscript/jerry-core:jerry-core_shared" ] + } } diff --git a/frameworks/native_engine/async/message_queue_utils.cpp b/frameworks/native_engine/async/message_queue_utils.cpp old mode 100644 new mode 100755 index 18fc87c..8ec3f5a --- a/frameworks/native_engine/async/message_queue_utils.cpp +++ b/frameworks/native_engine/async/message_queue_utils.cpp @@ -16,7 +16,7 @@ #include "message_queue_utils.h" #include "ace_log.h" #include "acelite_config.h" -#ifdef OHOS_ACELITE_PRODUCT_WATCH +#if (OHOS_ACELITE_PRODUCT_WATCH == 1) #include "cmsis_os2.h" #endif @@ -28,7 +28,7 @@ QueueHandler MessageQueueUtils::CreateMessageQueue(uint32_t capacity, uint32_t m HILOG_ERROR(HILOG_MODULE_ACE, "MessageQueueUtils:CreateMessageQueue parameters invalid!"); return nullptr; } -#if (defined(__LINUX__) || defined(__LITEOS__)) +#if (defined(__LINUX__) || defined(__LITEOS_A__)) HILOG_WARN(HILOG_MODULE_ACE, "todo call linux createMessageQueue interface here!"); return nullptr; #else @@ -43,7 +43,7 @@ int8_t MessageQueueUtils::DeleteMessageQueue(QueueHandler handler) HILOG_ERROR(HILOG_MODULE_ACE, "MessageQueueUtils:DeleteMessageQueue parameters invalid!"); return MSGQ_FAIL; } -#if (defined(__LINUX__) || defined(__LITEOS__)) +#if (defined(__LINUX__) || defined(__LITEOS_A__)) HILOG_WARN(HILOG_MODULE_ACE, "todo call linux deleteMessageQueue interface here!"); return MSGQ_FAIL; #else @@ -62,7 +62,7 @@ int8_t MessageQueueUtils::PutMessage(QueueHandler handler, const void* msgPtr, u HILOG_ERROR(HILOG_MODULE_ACE, "MessageQueueUtils:PutMessage parameters invalid!"); return MSGQ_FAIL; } -#if (defined(__LINUX__) || defined(__LITEOS__)) +#if (defined(__LINUX__) || defined(__LITEOS_A__)) HILOG_WARN(HILOG_MODULE_ACE, "todo call linux putmsg interface here!"); return MSGQ_FAIL; #else @@ -82,7 +82,7 @@ int8_t MessageQueueUtils::GetMessage(QueueHandler handler, void* msgPtr, uint32_ HILOG_ERROR(HILOG_MODULE_ACE, "MessageQueueUtils:GetMessage parameters invalid!"); return MSGQ_FAIL; } -#if (defined(__LINUX__) || defined(__LITEOS__)) +#if (defined(__LINUX__) || defined(__LITEOS_A__)) HILOG_WARN(HILOG_MODULE_ACE, "todo call linux getmsg interface here!"); return MSGQ_FAIL; #else diff --git a/frameworks/native_engine/jsi/internal/jsi_internal.h b/frameworks/native_engine/jsi/internal/jsi_internal.h index b1fc0ab..8773e76 100644 --- a/frameworks/native_engine/jsi/internal/jsi_internal.h +++ b/frameworks/native_engine/jsi/internal/jsi_internal.h @@ -17,14 +17,14 @@ #define OHOS_ACELITE_JSI_INTERNAL_H #include "jsi_config.h" -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) #include "jerryscript.h" #endif /** * Macros for conversions between jsi-values and jerry-values. */ -#if defined (ENABLE_JERRY) +#if (ENABLE_JERRY == 1) #define AS_JERRY_VALUE(jsiValue) (jerry_value_t)(uintptr_t) jsiValue #define AS_JLENGTH_VALUE(jsiValue) (jerry_length_t)(uintptr_t) jsiValue #define AS_JSI_VALUE(jValue) (JSIValue)(uintptr_t) jValue @@ -33,7 +33,7 @@ /** * A convenience macro to create jerry-values. */ -#if defined (ENABLE_JERRY) +#if (ENABLE_JERRY == 1) #define JERRY_CREATE(var, create) jerry_value_t var = (create); #endif diff --git a/frameworks/native_engine/jsi/jsi.cpp b/frameworks/native_engine/jsi/jsi.cpp index df2b548..d5ddb77 100644 --- a/frameworks/native_engine/jsi/jsi.cpp +++ b/frameworks/native_engine/jsi/jsi.cpp @@ -16,7 +16,7 @@ #include #include -#ifdef OHOS_ACELITE_PRODUCT_WATCH +#if (OHOS_ACELITE_PRODUCT_WATCH == 1) #include "securec.h" #endif // OHOS_ACELITE_PRODUCT_WATCH #include "ace_log.h" @@ -27,7 +27,7 @@ namespace OHOS { namespace ACELite { JSIValue JSI::GetGlobalObject() { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) return AS_JSI_VALUE(jerry_get_global_object()); #else HILOG_ERROR(HILOG_MODULE_ACE, "JSI:GetGlobalObject has not been implemented in this js engine!"); @@ -37,7 +37,7 @@ JSIValue JSI::GetGlobalObject() JSIValue JSI::CreateObject() { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) return AS_JSI_VALUE(jerry_create_object()); #else HILOG_ERROR(HILOG_MODULE_ACE, "JSI:CreateObject has not been implemented in this js engine!"); @@ -51,7 +51,7 @@ void JSI::SetProperty(JSIValue object, JSIValue key, JSIValue value) HILOG_ERROR(HILOG_MODULE_ACE, "JSI:SetProperty failed!"); return; } -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_value_t jObject = AS_JERRY_VALUE(object); jerry_value_t jKey = AS_JERRY_VALUE(key); jerry_value_t jVal = AS_JERRY_VALUE(value); @@ -68,7 +68,7 @@ void JSI::SetNamedProperty(JSIValue object, const char * const propName, JSIValu HILOG_ERROR(HILOG_MODULE_ACE, "JSI:SetNamedProperty failed!"); return; } -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_value_t jKey = jerry_create_string((const jerry_char_t *)propName); SetProperty(object, AS_JSI_VALUE(jKey), value); jerry_release_value(jKey); @@ -121,7 +121,7 @@ void JSI::SetStringPropertyWithBufferSize(JSIValue object, const char * const pr ReleaseValue(strValue); } -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) /** * @brief: CreateJerryFuncHelper is used to create jerry function * along with JSI::CreateFunction, for internal use only. @@ -166,7 +166,7 @@ JSIValue JSI::CreateFunction(JSIFunctionHandler handler) HILOG_ERROR(HILOG_MODULE_ACE, "JSI:CreateFunction failed!"); return CreateUndefined(); } -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_value_t jFunc = jerry_create_external_function(CreateJerryFuncHelper); void *nativePointer = reinterpret_cast(handler); jerry_set_object_native_pointer(jFunc, nativePointer, nullptr); @@ -182,7 +182,7 @@ JSIValue JSI::CreateString(const char * const str) if (str == nullptr) { return CreateUndefined(); } -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) return AS_JSI_VALUE(jerry_create_string(reinterpret_cast(str))); #else HILOG_ERROR(HILOG_MODULE_ACE, "JSI:CreateString has not been implemented in this js engine!"); @@ -195,7 +195,7 @@ JSIValue JSI::CreateStringWithBufferSize(const char * const str, size_t size) if (str == nullptr) { return CreateUndefined(); } -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) return AS_JSI_VALUE(jerry_create_string_sz(reinterpret_cast(str), size)); #else HILOG_ERROR(HILOG_MODULE_ACE, "JSI:CreateStringWithBufferSize has not been implemented in this js engine!"); @@ -205,7 +205,7 @@ JSIValue JSI::CreateStringWithBufferSize(const char * const str, size_t size) JSIValue JSI::CreateUndefined() { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) return AS_JSI_VALUE(jerry_create_undefined()); #else HILOG_ERROR(HILOG_MODULE_ACE, "JSI:CreateUndefined has not been implemented in this js engine!"); @@ -215,7 +215,7 @@ JSIValue JSI::CreateUndefined() bool JSI::ValueIsFunction(JSIValue value) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) return jerry_value_is_function(AS_JERRY_VALUE(value)); #else HILOG_ERROR(HILOG_MODULE_ACE, "JSI:ValueIsFunction has not been implemented in this js engine!"); @@ -225,7 +225,7 @@ bool JSI::ValueIsFunction(JSIValue value) bool JSI::ValueIsUndefined(JSIValue value) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) return jerry_value_is_undefined(AS_JERRY_VALUE(value)); #else HILOG_ERROR(HILOG_MODULE_ACE, "JSI:ValueIsUndefined has not been implemented in this js engine!"); @@ -235,7 +235,7 @@ bool JSI::ValueIsUndefined(JSIValue value) bool JSI::ValueIsNumber(JSIValue value) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) return jerry_value_is_number(AS_JERRY_VALUE(value)); #else HILOG_ERROR(HILOG_MODULE_ACE, "JSI:ValueIsNumber has not been implemented in this js engine!"); @@ -245,7 +245,7 @@ bool JSI::ValueIsNumber(JSIValue value) bool JSI::ValueIsString(JSIValue value) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) return jerry_value_is_string(AS_JERRY_VALUE(value)); #else HILOG_ERROR(HILOG_MODULE_ACE, "JSI:ValueIsString has not been implemented in this js engine!"); @@ -255,7 +255,7 @@ bool JSI::ValueIsString(JSIValue value) bool JSI::ValueIsBoolean(JSIValue value) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) return jerry_value_is_boolean(AS_JERRY_VALUE(value)); #else HILOG_ERROR(HILOG_MODULE_ACE, "JSI:ValueIsBoolean has not been implemented in this js engine!"); @@ -265,7 +265,7 @@ bool JSI::ValueIsBoolean(JSIValue value) bool JSI::ValueIsNull(JSIValue value) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) return jerry_value_is_null(AS_JERRY_VALUE(value)); #else HILOG_ERROR(HILOG_MODULE_ACE, "JSI:ValueIsNull has not been implemented in this js engine!"); @@ -275,7 +275,7 @@ bool JSI::ValueIsNull(JSIValue value) bool JSI::ValueIsObject(JSIValue value) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) return jerry_value_is_object(AS_JERRY_VALUE(value)); #else HILOG_ERROR(HILOG_MODULE_ACE, "JSI:ValueIsObject has not been implemented in this js engine!"); @@ -285,7 +285,7 @@ bool JSI::ValueIsObject(JSIValue value) bool JSI::ValueIsError(JSIValue value) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) return jerry_value_is_error(AS_JERRY_VALUE(value)); #else HILOG_ERROR(HILOG_MODULE_ACE, "JSI:ValueIsError has not been implemented in this js engine!"); @@ -299,7 +299,7 @@ char *JSI::JsonStringify(JSIValue value) HILOG_ERROR(HILOG_MODULE_ACE, "JSI:JsonStringify failed!"); return nullptr; } -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_value_t stringified = jerry_json_stringify(AS_JERRY_VALUE(value)); char *res = ValueToString(AS_JSI_VALUE(stringified)); jerry_release_value(stringified); @@ -316,7 +316,7 @@ JSIValue JSI::JsonParse(const char * const str) HILOG_ERROR(HILOG_MODULE_ACE, "JSI:JsonParse failed!"); return CreateUndefined(); } -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_value_t jVal = jerry_json_parse(reinterpret_cast(str), strlen(str)); return AS_JSI_VALUE(jVal); #else @@ -331,7 +331,7 @@ JSIValue JSI::GetProperty(JSIValue object, JSIValue key) HILOG_ERROR(HILOG_MODULE_ACE, "JSI:GetProperty failed!"); return CreateUndefined(); } -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_value_t jObject = AS_JERRY_VALUE(object); jerry_value_t jKey = AS_JERRY_VALUE(key); return AS_JSI_VALUE(jerry_get_property(jObject, jKey)); @@ -347,7 +347,7 @@ JSIValue JSI::GetNamedProperty(JSIValue object, const char * const propName) HILOG_ERROR(HILOG_MODULE_ACE, "JSI:GetNamedProperty failed!"); return CreateUndefined(); } -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_value_t jKey = jerry_create_string(reinterpret_cast(propName)); JSIValue result = GetProperty(object, AS_JSI_VALUE(jKey)); jerry_release_value(jKey); @@ -408,7 +408,7 @@ char *JSI::GetStringPropertyWithBufferSize(JSIValue object, const char * const p void JSI::ReleaseValue(JSIValue value) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) if (value != ARGS_END) { jerry_release_value(AS_JERRY_VALUE(value)); } @@ -431,7 +431,7 @@ void JSI::CallFunction(JSIValue funcObj, JSIValue thisVal, const JSIValue *argv, HILOG_ERROR(HILOG_MODULE_ACE, "JSI:CallFunction failed!"); return; } -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_value_t jFunc = AS_JERRY_VALUE(funcObj); jerry_value_t jThis = AS_JERRY_VALUE(thisVal); if ((argv == nullptr) || argc == 0) { @@ -465,7 +465,7 @@ void JSI::CallFunction(JSIValue funcObj, JSIValue thisVal, const JSIValue *argv, JSIValue JSI::CreateNumber(double value) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) return AS_JSI_VALUE(jerry_create_number(value)); #else HILOG_ERROR(HILOG_MODULE_ACE, "JSI:CreateNumber has not been implemented in this js engine!"); @@ -475,7 +475,7 @@ JSIValue JSI::CreateNumber(double value) JSIValue JSI::CreateNumberNaN() { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) return AS_JSI_VALUE(jerry_create_number_nan()); #else HILOG_ERROR(HILOG_MODULE_ACE, "JSI:CreateNumberNan has not been implemented in this js engine!"); @@ -483,7 +483,7 @@ JSIValue JSI::CreateNumberNaN() #endif } -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) static jerry_error_t GetJerryErrorType(JsiErrorType jsiType) { jerry_error_t jerryType; @@ -556,7 +556,7 @@ JSIValue JSI::CreateError(JsiErrorType type, const char * const errorMsg) HILOG_ERROR(HILOG_MODULE_ACE, "JSI:CreateError parameters invalid!"); return CreateUndefined(); } -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_error_t jerryType = GetJerryErrorType(type); jerry_value_t jError = jerry_create_error(jerryType, reinterpret_cast(errorMsg)); return AS_JSI_VALUE(jError); @@ -571,7 +571,7 @@ JsiErrorType JSI::GetErrorType(JSIValue errorValue) if (!ValueIsError(errorValue)) { return JsiErrorType::JSI_ERROR_INVALID; } -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_value_t jError = AS_JERRY_VALUE(errorValue); jerry_error_t jerryType = jerry_get_error_type(jError); return GetJsiErrorType(jerryType); @@ -583,7 +583,7 @@ JsiErrorType JSI::GetErrorType(JSIValue errorValue) JSIValue JSI::CreateBoolean(bool value) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) return AS_JSI_VALUE(jerry_create_boolean(value)); #else HILOG_ERROR(HILOG_MODULE_ACE, "JSI:CreateBoolean has not been implemented in this js engine!"); @@ -593,7 +593,7 @@ JSIValue JSI::CreateBoolean(bool value) JSIValue JSI::CreateNull() { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) return AS_JSI_VALUE(jerry_create_null()); #else HILOG_ERROR(HILOG_MODULE_ACE, "JSI:CreateNull has not been implemented in this js engine!"); @@ -601,10 +601,10 @@ JSIValue JSI::CreateNull() #endif } -#if defined(JS_FWK_SYMBOL) +#if (JS_FWK_SYMBOL == 1) JSIValue JSI::CreateSymbol(JSIValue description) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_value_t jDsc = AS_JERRY_VALUE(description); return AS_JSI_VALUE(jerry_create_symbol(jDsc)); #else @@ -615,7 +615,7 @@ JSIValue JSI::CreateSymbol(JSIValue description) bool JSI::ValueIsSymbol(JSIValue value) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) return jerry_value_is_symbol(AS_JERRY_VALUE(value)); #else HILOG_ERROR(HILOG_MODULE_ACE, "JSI:ValueIsSymbol has not been implemented in this js engine!"); @@ -626,7 +626,7 @@ bool JSI::ValueIsSymbol(JSIValue value) JSIValue JSI::CreateArray(uint32_t length) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) return AS_JSI_VALUE(jerry_create_array(length)); #else HILOG_ERROR(HILOG_MODULE_ACE, "JSI:CreateArray has not been implemented in this js engine!"); @@ -636,7 +636,7 @@ JSIValue JSI::CreateArray(uint32_t length) bool JSI::SetPropertyByIndex(JSIValue object, uint32_t index, JSIValue value) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_value_t jObject = AS_JERRY_VALUE(object); jerry_value_t jVal = AS_JERRY_VALUE(value); @@ -655,7 +655,7 @@ bool JSI::SetPropertyByIndex(JSIValue object, uint32_t index, JSIValue value) char *JSI::ValueToString(JSIValue value) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) char *result = nullptr; jerry_value_t jVal = AS_JERRY_VALUE(value); if (!jerry_value_is_string(jVal)) { @@ -698,7 +698,7 @@ char *JSI::ValueToString(JSIValue value) char *JSI::ValueToStringWithBufferSize(JSIValue value, size_t &size) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) auto jVal = AS_JERRY_VALUE(value); if (!jerry_value_is_string(jVal)) { HILOG_ERROR(HILOG_MODULE_ACE, "JSI:ValueToStringWithBufferSize params invalid!"); @@ -737,7 +737,7 @@ char *JSI::ValueToStringWithBufferSize(JSIValue value, size_t &size) double JSI::ValueToNumber(JSIValue value) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_value_t jVal = AS_JERRY_VALUE(value); if (!jerry_value_is_number(jVal)) { HILOG_ERROR(HILOG_MODULE_ACE, "JSI:ValueToNumber params invalid!"); @@ -752,7 +752,7 @@ double JSI::ValueToNumber(JSIValue value) bool JSI::ValueToBoolean(JSIValue value) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_value_t jVal = AS_JERRY_VALUE(value); if (!jerry_value_is_boolean(jVal)) { HILOG_ERROR(HILOG_MODULE_ACE, "JSI:ValueToBoolean params invalid!"); @@ -767,7 +767,7 @@ bool JSI::ValueToBoolean(JSIValue value) uint32_t JSI::GetArrayLength(JSIValue value) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_value_t jVal = AS_JERRY_VALUE(value); if (!jerry_value_is_array(jVal)) { HILOG_ERROR(HILOG_MODULE_ACE, "JSI:GetArrayLength params invalid!"); @@ -782,7 +782,7 @@ uint32_t JSI::GetArrayLength(JSIValue value) JSIValue JSI::GetPropertyByIndex(JSIValue object, uint32_t index) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_value_t jVal = AS_JERRY_VALUE(object); return AS_JSI_VALUE(jerry_get_property_by_index(jVal, index)); #else @@ -797,7 +797,7 @@ JSIValue JSI::GetObjectKeys(JSIValue object) HILOG_ERROR(HILOG_MODULE_ACE, "JSI:GetObjectKeys failed!"); return CreateUndefined(); } -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_value_t jVal = AS_JERRY_VALUE(object); return AS_JSI_VALUE(jerry_get_object_keys(jVal)); #else @@ -808,7 +808,7 @@ JSIValue JSI::GetObjectKeys(JSIValue object) bool JSI::GetJSHeapStatus(JSHeapStatus &heapStatus) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_heap_stats_t stats = {0}; if (!jerry_get_memory_stats(&stats)) { return false; @@ -825,7 +825,7 @@ bool JSI::GetJSHeapStatus(JSHeapStatus &heapStatus) bool JSI::ValueIsArray(JSIValue value) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) return jerry_value_is_array(AS_JERRY_VALUE(value)); #else HILOG_ERROR(HILOG_MODULE_ACE, "JSI:ValueIsArray has not been implemented in this js engine!"); @@ -835,7 +835,7 @@ bool JSI::ValueIsArray(JSIValue value) JSIValue JSI::AcquireValue(JSIValue value) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_value_t jVal = AS_JERRY_VALUE(value); return AS_JSI_VALUE(jerry_acquire_value(jVal)); #else @@ -861,7 +861,7 @@ void JSI::SetOnDestroy(JSIValue object, NativeCallback callback) HILOG_ERROR(HILOG_MODULE_ACE, "JSI:SetOnDestroy failed!"); return; } -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) void *nativePtr = reinterpret_cast(callback); jerry_set_object_native_pointer(AS_JERRY_VALUE(object), nativePtr, nullptr); #else @@ -897,7 +897,7 @@ void JSI::SetNamedPointer(JSIValue object, const char * const name, JsiCallback HILOG_ERROR(HILOG_MODULE_ACE, "JSI:SetNamedPointer failed!"); return; } -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) JSIValue funObj = JSI::CreateObject(); void *nativePtr = reinterpret_cast(callback); jerry_set_object_native_pointer(AS_JERRY_VALUE(funObj), nativePtr, nullptr); @@ -908,8 +908,8 @@ void JSI::SetNamedPointer(JSIValue object, const char * const name, JsiCallback #endif } -#if defined(JS_FWK_TYPEDARRAY) -#if defined(ENABLE_JERRY) +#if (JS_FWK_TYPEDARRAY == 1) +#if (ENABLE_JERRY == 1) // Helper function for JSI TypedArray type convert TypedArrayType GetJsiArrayType(jerry_typedarray_type_t jerryType) { @@ -960,7 +960,7 @@ uint8_t *JSI::GetTypedArrayInfo(JSIValue typedArray, HILOG_ERROR(HILOG_MODULE_ACE, "JSI:GetTypedArrayInfo failed!"); return nullptr; } -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_value_t jVal = AS_JERRY_VALUE(typedArray); jerry_typedarray_type_t jType = jerry_get_typedarray_type(jVal); type = GetJsiArrayType(jType); @@ -980,7 +980,7 @@ uint8_t *JSI::GetTypedArrayInfo(JSIValue typedArray, #endif } -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) // Helper function for jerry TypedArray type convert jerry_typedarray_type_t GetJerryArrayType(TypedArrayType jsiType) { @@ -1023,7 +1023,7 @@ jerry_typedarray_type_t GetJerryArrayType(TypedArrayType jsiType) JSIValue JSI::CreateTypedArray(TypedArrayType type, size_t length, JSIValue arrayBuffer, size_t byteOffset) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_typedarray_type_t jType = GetJerryArrayType(type); jerry_value_t jArrayBuffer = AS_JERRY_VALUE(arrayBuffer); jerry_value_t jVal = jerry_create_typedarray_for_arraybuffer_sz(jType, jArrayBuffer, (jerry_length_t)byteOffset, @@ -1041,7 +1041,7 @@ uint8_t *JSI::GetArrayBufferInfo(JSIValue arrayBuffer, size_t &byteLength) HILOG_ERROR(HILOG_MODULE_ACE, "JSI:GetArrayBufferInfo failed!"); return nullptr; } -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_value_t jVal = AS_JERRY_VALUE(arrayBuffer); jerry_length_t len = jerry_get_arraybuffer_byte_length(jVal); @@ -1058,7 +1058,7 @@ JSIValue JSI::CreateArrayBuffer(size_t byteLength, uint8_t *&buffPtr) if (byteLength == 0) { return CreateUndefined(); } -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_value_t jVal = jerry_create_arraybuffer((jerry_length_t)byteLength); buffPtr = jerry_get_arraybuffer_pointer(jVal); return AS_JSI_VALUE(jVal); @@ -1070,7 +1070,7 @@ JSIValue JSI::CreateArrayBuffer(size_t byteLength, uint8_t *&buffPtr) bool JSI::ValueIsArrayBuffer(JSIValue value) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) return jerry_value_is_arraybuffer(AS_JERRY_VALUE(value)); #else HILOG_ERROR(HILOG_MODULE_ACE, "JSI:ValueIsArrayBuffer has not been implemented in this js engine!"); @@ -1080,7 +1080,7 @@ bool JSI::ValueIsArrayBuffer(JSIValue value) bool JSI::ValueIsTypedArray(JSIValue value) { -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) return jerry_value_is_typedarray(AS_JERRY_VALUE(value)); #else HILOG_ERROR(HILOG_MODULE_ACE, "JSI:ValueIsTypedArray has not been implemented in this js engine!"); @@ -1095,7 +1095,7 @@ bool JSI::DefineProperty(JSIValue object, JSIValue propName, JSPropertyDescripto HILOG_ERROR(HILOG_MODULE_ACE, "JSI:DefineProperty failed!"); return false; } -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_property_descriptor_t jerryDesc; jerry_init_property_descriptor_fields(&jerryDesc); @@ -1130,7 +1130,7 @@ bool JSI::DefineNamedProperty(JSIValue object, const char * const propNameStr, J HILOG_ERROR(HILOG_MODULE_ACE, "JSI:DefineNamedProperty failed!"); return false; } -#if defined(ENABLE_JERRY) +#if (ENABLE_JERRY == 1) jerry_value_t propName = jerry_create_string(reinterpret_cast(propNameStr)); bool res = DefineProperty(object, AS_JSI_VALUE(propName), descriptor); jerry_release_value(propName); diff --git a/frameworks/src/core/base/ace_lock.cpp b/frameworks/src/core/base/ace_lock.cpp index 7d5f407..b20ebfe 100644 --- a/frameworks/src/core/base/ace_lock.cpp +++ b/frameworks/src/core/base/ace_lock.cpp @@ -14,7 +14,7 @@ */ #include "ace_lock.h" -#if (defined(__LITEOS_M__) || defined(OHOS_ACELITE_PRODUCT_WATCH)) +#if (defined(__LITEOS_M__) || (OHOS_ACELITE_PRODUCT_WATCH == 1)) #include "los_task.h" #endif @@ -62,7 +62,7 @@ AutoLockGuard::AutoLockGuard(LockType &lock) : lock_(lock) { #if (defined(__LINUX__) || defined(__LITEOS_A__)) lock_.Lock(); -#elif (defined(__LITEOS_M__) || defined(OHOS_ACELITE_PRODUCT_WATCH)) +#elif (defined(__LITEOS_M__) || (OHOS_ACELITE_PRODUCT_WATCH == 1)) LOS_TaskLock(); #else (void)lock_; @@ -73,7 +73,7 @@ AutoLockGuard::~AutoLockGuard() { #if (defined(__LINUX__) || defined(__LITEOS_A__)) lock_.Unlock(); -#elif (defined(__LITEOS_M__) || defined(OHOS_ACELITE_PRODUCT_WATCH)) +#elif (defined(__LITEOS_M__) || (OHOS_ACELITE_PRODUCT_WATCH == 1)) LOS_TaskUnlock(); #endif } diff --git a/frameworks/src/core/base/dft_impl.cpp b/frameworks/src/core/base/dft_impl.cpp index abbbdb2..e55904c 100755 --- a/frameworks/src/core/base/dft_impl.cpp +++ b/frameworks/src/core/base/dft_impl.cpp @@ -15,7 +15,7 @@ #include "dft_impl.h" -#if (defined(OHOS_ACELITE_PRODUCT_WATCH)||(defined(FEATURE_CUSTOM_ENTRY_PAGE))) +#if ((OHOS_ACELITE_PRODUCT_WATCH == 1) || (FEATURE_CUSTOM_ENTRY_PAGE == 1)) #include "ace_log.h" #include "js_app_context.h" diff --git a/frameworks/src/core/base/js_debugger_config.cpp b/frameworks/src/core/base/js_debugger_config.cpp index 068d821..c012739 100644 --- a/frameworks/src/core/base/js_debugger_config.cpp +++ b/frameworks/src/core/base/js_debugger_config.cpp @@ -81,7 +81,7 @@ void Debugger::FlushOutput() fflush(stdout); } -#ifdef JS_ENGINE_EXTERNAL_CONTEXT +#if (JS_ENGINE_EXTERNAL_CONTEXT == 1) static void *AllocEngineContext(size_t size, void *cbDataP) { (void)(cbDataP); @@ -91,7 +91,7 @@ static void *AllocEngineContext(size_t size, void *cbDataP) void Debugger::SetupJSContext() { -#ifdef JS_ENGINE_EXTERNAL_CONTEXT +#if (JS_ENGINE_EXTERNAL_CONTEXT == 1) if (engineContext_ != nullptr) { // do not repeat the setup process return; @@ -112,7 +112,7 @@ void Debugger::SetupJSContext() void Debugger::ReleaseJSContext() { -#ifdef JS_ENGINE_EXTERNAL_CONTEXT +#if (JS_ENGINE_EXTERNAL_CONTEXT == 1) if (engineContext_ == nullptr) { return; } diff --git a/frameworks/src/core/base/js_fwk_common.cpp b/frameworks/src/core/base/js_fwk_common.cpp index fd92f2e..1c7600a 100755 --- a/frameworks/src/core/base/js_fwk_common.cpp +++ b/frameworks/src/core/base/js_fwk_common.cpp @@ -39,7 +39,7 @@ #include "securec.h" #include "task_manager.h" -#if ((defined __LITEOS__) || (defined __linux__) || (defined SCREENSIZE_SPECIFIED)) +#if ((defined __LITEOS__) || (defined __linux__) || (SCREENSIZE_SPECIFIED == 1)) #include #endif @@ -585,7 +585,7 @@ int32_t GetFileSize(const char * const filePath) static int32_t OpenFileInternal(const char * const orgFullPath, bool binary = false) { const char *path = orgFullPath; -#ifndef QT_SIMULATOR +#if (QT_SIMULATOR != 1) #ifndef __LITEOS_M__ // no path canonicalization on M core char fullPath[PATH_MAX + 1] = {0}; #if ((defined(__WIN32)) || (defined(__WIN64))) @@ -1097,7 +1097,7 @@ struct JSPageSpecific jsPageSpecific; uint16_t GetHorizontalResolution() { // SCREENSIZE_SPECIFIED is temporarily set, when ui and graphic unifid, this can be removed -#if ((defined __LITEOS__) || (defined __linux__) || (defined SCREENSIZE_SPECIFIED)) +#if ((defined __LITEOS__) || (defined __linux__) || (SCREENSIZE_SPECIFIED == 1)) return Screen::GetInstance().GetWidth(); #else uint16_t horizontalResolution = 454; @@ -1109,7 +1109,7 @@ uint16_t GetHorizontalResolution() uint16_t GetVerticalResolution() { -#if ((defined __LITEOS__) || (defined __linux__) || (defined SCREENSIZE_SPECIFIED)) +#if ((defined __LITEOS__) || (defined __linux__) || (SCREENSIZE_SPECIFIED == 1)) return Screen::GetInstance().GetHeight(); #else uint16_t horizontalResolution = 454; @@ -1178,7 +1178,7 @@ void ExpandImagePathMem(char *&imagePath, const int16_t dotPos, const int16_t su imagePath = newImagePath; } -#ifdef OHOS_ACELITE_PRODUCT_WATCH +#if (OHOS_ACELITE_PRODUCT_WATCH == 1) void CureImagePath(char *&imagePath) { if (imagePath == nullptr) { @@ -1264,7 +1264,7 @@ const char *ParseImageSrc(jerry_value_t source) char *imageSrc = JsAppContext::GetInstance()->GetResourcePath(rawSrc); ace_free(rawSrc); rawSrc = nullptr; -#ifdef OHOS_ACELITE_PRODUCT_WATCH +#if (OHOS_ACELITE_PRODUCT_WATCH == 1) CureImagePath(imageSrc); #endif // OHOS_ACELITE_PRODUCT_WATCH return imageSrc; diff --git a/frameworks/src/core/base/js_fwk_common.h b/frameworks/src/core/base/js_fwk_common.h index b146342..3afbf42 100755 --- a/frameworks/src/core/base/js_fwk_common.h +++ b/frameworks/src/core/base/js_fwk_common.h @@ -105,13 +105,13 @@ constexpr uint32_t TEXT_BLUE_COLOR_MASK = 0x0000ff; constexpr int RED_COLOR_START_BIT = 16; constexpr int GREEN_COLOR_START_BIT = 8; constexpr char ATTR_SRC[] = "src"; // image-animator -#ifdef FEATURE_COMPONENT_ANALOG_CLOCK +#if (FEATURE_COMPONENT_ANALOG_CLOCK == 1) constexpr char CLOCK_HAND_IS_IMAGE[] = "isImage"; constexpr char COMMON_STYLE_OPACITY[] = "opacity"; constexpr char COMMON_STYLE_COLOR[] = "color"; #endif // FEATURE_COMPONENT_ANALOG_CLOCK constexpr uint8_t DEFAULT_FONT_SIZE = 30; -#ifdef FEATURE_COMPONENT_CANVAS +#if (FEATURE_COMPONENT_CANVAS == 1) constexpr uint8_t DEFAULT_FONT_LETTERSPACE = 2; #endif // FEATURE_COMPONENT_CANVAS constexpr char DEFAULT_FONT_FAMILY[] = DEFAULT_VECTOR_FONT_FILENAME; @@ -158,7 +158,7 @@ constexpr char TRANSITION_TRANSFORM_Y[] = "translateY"; constexpr char CONSTRUCTOR_VIEW_MODEL[] = "ViewModel"; constexpr char CONSTRUCTOR_ABILITY_SLICE[] = "AbilitySlice"; -#ifdef FEATURE_ROTATION_API +#if (FEATURE_ROTATION_API == 1) constexpr char FUNC_ROTATION_NAME[] = "rotation"; constexpr char ATTR_NAME_FOCUS[] = "focus"; #endif // FEATURE_ROTATION_API @@ -280,7 +280,7 @@ JSValue CallWithRootAbilitySlice(JSValue func); JSValue CreateWatcher(JSValue getter, JSHandler handler, JSValue options); void ExpandImagePathMem(char *&imagePath, const int16_t dotPos, const int16_t suffixLen, const int16_t imagePathLen); -#ifdef OHOS_ACELITE_PRODUCT_WATCH +#if (OHOS_ACELITE_PRODUCT_WATCH == 1) void CureImagePath(char *&imagePath); #endif // OHOS_ACELITE_PRODUCT_WATCH const char *ParseImageSrc(jerry_value_t source); diff --git a/frameworks/src/core/base/key_parser.cpp b/frameworks/src/core/base/key_parser.cpp index c7758cd..d77e250 100644 --- a/frameworks/src/core/base/key_parser.cpp +++ b/frameworks/src/core/base/key_parser.cpp @@ -26,20 +26,20 @@ namespace ACELite { #endif // KEYWORD // Replace the struct keys.h "KEYWORD" sector for init -#if defined(ENABLE_KEY) +#if (ENABLE_KEY == 1) #define KEYWORD(enumkey, keystr) {#keystr, K_##enumkey, static_cast(strlen(#enumkey))}, #else // ENABLE_KEY #define KEYWORD(enumkey, keystr) {K_##enumkey, static_cast(strlen(#enumkey))}, #endif // ENABLE_KEY static const struct { -#if defined(ENABLE_KEY) +#if (ENABLE_KEY == 1) const char * const key; #endif const uint16_t ID; const uint8_t LENGTH; } G_KEYWORD_INFO[KEYWORDS_MAX] = { -#if defined(ENABLE_KEY) +#if (ENABLE_KEY == 1) {"UNKNOWN", K_UNKNOWN, static_cast(strlen("UNKNOWN"))}, #else // ENABLE_KEY {K_UNKNOWN, static_cast(strlen("UNKNOWN"))}, @@ -69,7 +69,7 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) if (!strcmp(s, "lignItems")) { return K_ALIGN_ITEMS; } -#ifdef FEATURE_COMPONENT_ANALOG_CLOCK +#if (FEATURE_COMPONENT_ANALOG_CLOCK == 1) if (!strcmp(s, "nalog-clock")) { return K_ANALOG_CLOCK; } @@ -95,7 +95,7 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) if (!strcmp(s, "rc")) { return K_ARC; } -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) if (!strcmp(s, "utoplay")) { return K_AUTOPLAY; } @@ -149,12 +149,12 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) } break; case 'c': -#ifdef FEATURE_COMPONENT_CAMERA +#if (FEATURE_COMPONENT_CAMERA == 1) if (!strcmp(s, "amera")) { return K_CAMERA; } #endif // FEATURE_COMPONENT_CAMERA -#ifdef FEATURE_COMPONENT_CANVAS +#if (FEATURE_COMPONENT_CANVAS == 1) if (!strcmp(s, "anvas")) { return K_CANVAS; } @@ -177,7 +177,7 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) if (!strcmp(s, "olumn-reverse")) { return K_COLUMN_REVERSE; } -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) if (!strcmp(s, "ontrols")) { return K_CONTROLS; } @@ -200,7 +200,7 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) if (!strcmp(s, "lip")) { return K_CLIP; } -#ifdef FEATURE_COMPONENT_ANALOG_CLOCK +#if (FEATURE_COMPONENT_ANALOG_CLOCK == 1) if (!strcmp(s, "lock-hand")) { return K_CLOCK_HAND; } @@ -216,12 +216,12 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) if (!strcmp(s, "atasets")) { return K_DATASETS; } -#ifdef FEATURE_DATE_FORMAT +#if (FEATURE_DATE_FORMAT == 1) if (!strcmp(s, "ay")) { return K_DAY; } #endif -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) if (!strcmp(s, "ate")) { return K_DATE; } @@ -255,16 +255,16 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) if (!strcmp(s, "llipsis")) { return K_ELLIPSIS; } -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) if (!strcmp(s, "nd")) { return K_END; } #endif // FEATURE_COMPONENT_DATE_PICKER -#if (defined(FEATURE_COMPONENT_CAMERA) || defined(FEATURE_COMPONENT_VIDEO)) +#if ((FEATURE_COMPONENT_CAMERA == 1) || (FEATURE_COMPONENT_VIDEO == 1)) if (!strcmp(s, "rror")) { return K_ERROR; } -#endif // defined(FEATURE_COMPONENT_CAMERA) || defined(FEATURE_COMPONENT_VIDEO) +#endif // ((FEATURE_COMPONENT_CAMERA == 1) || (FEATURE_COMPONENT_VIDEO == 1)) if (!strcmp(s, "xpand")) { return K_EXPAND; } @@ -282,7 +282,7 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) if (!strcmp(s, "ixedsize")) { return K_FIXED_SIZE; } -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) if (!strcmp(s, "inish")) { return K_FINISH; } @@ -316,12 +316,12 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) if (!strcmp(s, "eight")) { return K_HEIGHT; } -#if (defined(FEATURE_COMPONENT_ANALOG_CLOCK)) || (defined(FEATURE_DATE_FORMAT)) +#if ((FEATURE_COMPONENT_ANALOG_CLOCK == 1) || (FEATURE_DATE_FORMAT == 1)) if (!strcmp(s, "our")) { return K_HOUR; } #endif // FEATURE_COMPONENT_ANALOG_CLOCK -#ifdef FEATURE_DATE_FORMAT +#if (FEATURE_DATE_FORMAT == 1) if (!strcmp(s, "our12")) { return K_HOUR12; } @@ -393,7 +393,7 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) if (!strcmp(s, "oop")) { return K_LOOP; } -#ifdef FEATURE_DATE_FORMAT +#if (FEATURE_DATE_FORMAT == 1) if (!strcmp(s, "ong")) { return K_LONG; } @@ -427,12 +427,12 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) if (!strcmp(s, "ini")) { return K_MINI; } -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) if (!strcmp(s, "uted")) { return K_MUTED; } #endif // FEATURE_COMPONENT_VIDEO -#ifdef FEATURE_NUMBER_FORMAT +#if (FEATURE_NUMBER_FORMAT == 1) if (!strcmp(s, "inimumFractionDigits")) { return K_MINIMUMFRACTIONDIGITS; } @@ -440,7 +440,7 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) return K_MAXIMUMFRACTIONDIGITS; } #endif -#ifdef FEATURE_DATE_FORMAT +#if (FEATURE_DATE_FORMAT == 1) if (!strcmp(s, "inute")) { return K_MINUTE; } @@ -456,7 +456,7 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) if (!strcmp(s, "one")) { return K_NONE; } -#ifdef FEATURE_DATE_FORMAT +#if (FEATURE_DATE_FORMAT == 1) if (!strcmp(s, "umeric")) { return K_NUMERIC; } @@ -489,7 +489,7 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) if (!strcmp(s, "addingTop")) { return K_PADDING_TOP; } -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) if (!strcmp(s, "ause")) { return K_PAUSE; } @@ -500,7 +500,7 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) if (!strcmp(s, "icker-view")) { return K_PICKER_VIEW; } -#ifdef FEATURE_COMPONENT_ANALOG_CLOCK +#if (FEATURE_COMPONENT_ANALOG_CLOCK == 1) if (!strcmp(s, "ivotX")) { return K_PIVOT_X; } @@ -508,7 +508,7 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) return K_PIVOT_Y; } #endif // FEATURE_COMPONENT_ANALOG_CLOCK -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) if (!strcmp(s, "repared")) { return K_PREPARED; } @@ -517,7 +517,7 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) return K_PROGRESS; } break; -#ifdef FEATURE_COMPONENT_QRCODE +#if (FEATURE_COMPONENT_QRCODE == 1) case 'q': if (!strcmp(s, "rcode")) { return K_QRCODE; @@ -569,12 +569,12 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) if (!strcmp(s, "crollstart")) { return K_SCROLLSTART; } -#ifdef FEATURE_COMPONENT_ANALOG_CLOCK +#if (FEATURE_COMPONENT_ANALOG_CLOCK == 1) if (!strcmp(s, "ec")) { return K_SEC; } #endif // FEATURE_COMPONENT_ANALOG_CLOCK -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) if (!strcmp(s, "eeked")) { return K_SEEKED; } @@ -597,7 +597,7 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) if (!strcmp(s, "how")) { return K_SHOW; } -#ifdef FEATURE_DATE_FORMAT +#if (FEATURE_DATE_FORMAT == 1) if (!strcmp(s, "hort")) { return K_SHORT; } @@ -623,11 +623,11 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) if (!strcmp(s, "top")) { return K_STOP; } -#if (defined(FEATURE_COMPONENT_DATE_PICKER) || defined(FEATURE_COMPONENT_VIDEO)) +#if ((FEATURE_COMPONENT_DATE_PICKER == 1) || (FEATURE_COMPONENT_VIDEO == 1)) if (!strcmp(s, "tart")) { return K_START; } -#endif // (defined(FEATURE_COMPONENT_DATE_PICKER) || defined(FEATURE_COMPONENT_VIDEO) +#endif // ((FEATURE_COMPONENT_DATE_PICKER == 1) || (FEATURE_COMPONENT_VIDEO == 1)) if (!strcmp(s, "tartAngle")) { return K_START_ANGLE; } @@ -637,7 +637,7 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) if (!strcmp(s, "trokeWidth")) { return K_STROKE_WIDTH; } -#ifdef FEATURE_NUMBER_FORMAT +#if (FEATURE_NUMBER_FORMAT == 1) if (!strcmp(s, "tyle")) { return K_STYLE; } @@ -653,7 +653,7 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) } break; case 't': -#ifdef FEATURE_COMPONENT_TABS +#if (FEATURE_COMPONENT_TABS == 1) if (!strcmp(s, "ab-bar")) { return K_TAB_BAR; } @@ -667,7 +667,7 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) if (!strcmp(s, "ime")) { return K_TIME; } -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) if (!strcmp(s, "imeupdate")) { return K_TIME_UPDATE; } @@ -710,14 +710,14 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) if (!strcmp(s, "extOverflow")) { return K_TEXT_OVERFLOW; } -#ifdef FEATURE_COMPONENT_ANALOG_CLOCK +#if (FEATURE_COMPONENT_ANALOG_CLOCK == 1) if (!strcmp(s, "ype")) { return K_TYPE; } #endif // FEATURE_COMPONENT_ANALOG_CLOCK break; case 'u': -#ifdef FEATURE_NUMBER_FORMAT +#if (FEATURE_NUMBER_FORMAT == 1) if (!strcmp(s, "seGrouping")) { return K_USEGROUP; } @@ -730,7 +730,7 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) if (!strcmp(s, "ertical")) { return K_VERTICAL; } -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) if (!strcmp(s, "ideo")) { return K_VIDEO; } @@ -745,7 +745,7 @@ uint16_t KeyParser::ParseKeyId(const char *s, const size_t len) } break; case '2': -#ifdef FEATURE_DATE_FORMAT +#if (FEATURE_DATE_FORMAT == 1) if (!strcmp(s, "-digit")) { return K_DIGIT2; } @@ -781,7 +781,7 @@ const char *KeyParser::GetKeyById(uint16_t id) if (!IsKeyValid(id)) { return "UNKNOWN"; } -#if defined(ENABLE_KEY) +#if (ENABLE_KEY == 1) return G_KEYWORD_INFO[id].key; #else return "UNKNOWN"; diff --git a/frameworks/src/core/base/keys.h b/frameworks/src/core/base/keys.h index 00e25ac..1947e84 100755 --- a/frameworks/src/core/base/keys.h +++ b/frameworks/src/core/base/keys.h @@ -38,7 +38,7 @@ enum { // Reused by the struct begin // Sample:KEYWORD(enum_string, real-key-string) KEYWORD(ALIGN_ITEMS, alignItems) // layout style -#ifdef FEATURE_COMPONENT_ANALOG_CLOCK +#if (FEATURE_COMPONENT_ANALOG_CLOCK == 1) KEYWORD(ANALOG_CLOCK, analog-clock) // tag name #endif // FEATURE_COMPONENT_ANALOG_CLOCK KEYWORD(ANIMATION_DELAY, animationDelay) // animation delay @@ -48,7 +48,7 @@ enum { KEYWORD(ANIMATION_NAME, animationName) // animation name KEYWORD(ANIMATION_TIMING_FUNCTION, animationTimingFunction) // animation timing function KEYWORD(ARC, arc) // circle progress -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) KEYWORD(AUTOPLAY, autoplay) // video component autoplay attribute #endif // FEATURE_COMPONENT_VIDEO KEYWORD(BACKGROUND_COLOR, backgroundColor) // chart line color @@ -66,10 +66,10 @@ enum { KEYWORD(BORDER_TOP_WIDTH, borderTopWidth) // common style border top width KEYWORD(BORDER_WIDTH, borderWidth) // common style, horizon progress style KEYWORD(BREAK, break) // text overflow type -#ifdef FEATURE_COMPONENT_CAMERA +#if (FEATURE_COMPONENT_CAMERA == 1) KEYWORD(CAMERA, camera) // camera component #endif // FEATURE_COMPONENT_CAMERA -#ifdef FEATURE_COMPONENT_CANVAS +#if (FEATURE_COMPONENT_CANVAS == 1) KEYWORD(CANVAS, canvas) // tag name #endif // FEATURE_COMPONENT_CANVAS KEYWORD(CENTER, center) // text align type @@ -81,22 +81,22 @@ enum { KEYWORD(CLICK, click) // click event listener KEYWORD(CLIP, clip) // text overflow type KEYWORD(CHART, chart) // tag name -#ifdef FEATURE_COMPONENT_ANALOG_CLOCK +#if (FEATURE_COMPONENT_ANALOG_CLOCK == 1) KEYWORD(CLOCK_HAND, clock-hand) // tag name #endif // FEATURE_COMPONENT_ANALOG_CLOCK KEYWORD(COLOR, color) // text style type, rectangular clock-hand fill color, horizon progress style KEYWORD(COLUMN, column) // layout style KEYWORD(COLUMN_REVERSE, column-reverse) // layout style KEYWORD(CONTAIN, contain) // image component contain -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) KEYWORD(CONTROLS, controls) // video component controls attribute #endif // FEATURE_COMPONENT_VIDEO KEYWORD(COVER, cover) // image component cover KEYWORD(DATASETS, datasets) // chart data -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) KEYWORD(DATE, date) // picker-view attr value #endif // FEATURE_COMPONENT_DATE_PICKER -#ifdef FEATURE_DATE_FORMAT +#if (FEATURE_DATE_FORMAT == 1) KEYWORD(DAY, day) KEYWORD(DIGIT2, digit2) #endif @@ -109,15 +109,15 @@ enum { KEYWORD(EASE_IN_OUT, ease-in-out) // animation time function value KEYWORD(EASE_OUT, ease-out) // animation time function value KEYWORD(ELLIPSIS, ellipsis) // text overflow type -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) KEYWORD(END, end) // date picker-view attr #endif // FEATURE_COMPONENT_DATE_PICKER -#if (defined(FEATURE_COMPONENT_CAMERA) || defined(FEATURE_COMPONENT_VIDEO)) +#if ((FEATURE_COMPONENT_CAMERA == 1) || (FEATURE_COMPONENT_VIDEO == 1)) KEYWORD(ERROR, error) // camera component error event #endif // FEATURE_COMPONENT_CAMERA KEYWORD(EXPAND, expand) // text overflow type KEYWORD(FALSE, false) // common attributes -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) KEYWORD(FINISH, finish) // video component finish event tag #endif // FEATURE_COMPONENT_VIDEO KEYWORD(FILL, fill) // image component fill @@ -132,10 +132,10 @@ enum { KEYWORD(FONT_FAMILY, fontFamily) // text style type KEYWORD(FORWARDS, forwards) // animation fill value KEYWORD(HEIGHT, height) // common attributes -#if (defined(FEATURE_COMPONENT_ANALOG_CLOCK)) || (defined(FEATURE_DATE_FORMAT)) +#if ((FEATURE_COMPONENT_ANALOG_CLOCK == 1) || (FEATURE_DATE_FORMAT == 1)) KEYWORD(HOUR, hour) // analog-clock hour #endif // FEATURE_COMPONENT_ANALOG_CLOCK FEATURE_DATE_FORMAT -#ifdef FEATURE_DATE_FORMAT +#if (FEATURE_DATE_FORMAT == 1) KEYWORD(HOUR12, hour12) #endif KEYWORD(ID, id) // common attributes @@ -157,7 +157,7 @@ enum { KEYWORD(LINE_HEIGHT, lineHeight) // text style type KEYWORD(LIST, list) // list tag name KEYWORD(LIST_ITEM, list-item) // list-item tag name -#ifdef FEATURE_DATE_FORMAT +#if (FEATURE_DATE_FORMAT == 1) KEYWORD(LONG, long) #endif KEYWORD(LONGPRESS, longpress) // long progress event listener @@ -171,16 +171,16 @@ enum { KEYWORD(MAX, max) // common attributes KEYWORD(MIN, min) // common attributes, analog-clock minute KEYWORD(MINI, mini) // text font size type -#ifdef FEATURE_DATE_FORMAT +#if (FEATURE_DATE_FORMAT == 1) KEYWORD(MINUTE, minute) KEYWORD(MONTH, month) #endif -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) KEYWORD(MUTED, muted) // video component muted attribute #endif // FEATURE_COMPONENT_VIDEO KEYWORD(NAME, name) // the attribute name KEYWORD(NONE, none) // animation fill value -#ifdef FEATURE_DATE_FORMAT +#if (FEATURE_DATE_FORMAT == 1) KEYWORD(NUMERIC, numeric) #endif KEYWORD(OBJECT_FIT, objectFit) // image component object-fit @@ -194,21 +194,21 @@ enum { KEYWORD(PERCENT, percent) KEYWORD(PICKER_VIEW, picker-view) // tag name KEYWORD(REF, ref) // common attribute -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) KEYWORD(PREPARED, prepared) // video component prepared event #endif // FEATURE_COMPONENT_VIDEO -#ifdef FEATURE_COMPONENT_ANALOG_CLOCK +#if (FEATURE_COMPONENT_ANALOG_CLOCK == 1) KEYWORD(PIVOT_X, pivotX) // clock-hand pivot-x KEYWORD(PIVOT_Y, pivotY) // clock-hand pivot-y #endif // FEATURE_COMPONENT_ANALOG_CLOCK KEYWORD(PROGRESS, progress) // progress tag name -#ifdef FEATURE_COMPONENT_QRCODE +#if (FEATURE_COMPONENT_QRCODE == 1) KEYWORD(QRCODE, qrcode) // qrcode tag name #endif KEYWORD(RADIO, radio) // the type in input KEYWORD(RADIUS, radius) // circle progress radius KEYWORD(RANGE, range) // picker-view attr -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) KEYWORD(PAUSE, pause) // video component pause event tag #endif // FEATURE_COMPONENT_VIDEO KEYWORD(REVERSE, reverse) // image-animator attribute @@ -221,13 +221,13 @@ enum { KEYWORD(SCROLLDELAY, scrolldelay) // marquee scroll delay KEYWORD(SCROLLEND, scrollend) // scroll end event listener KEYWORD(SCROLLSTART, scrollstart) // scroll start event listener -#ifdef FEATURE_COMPONENT_ANALOG_CLOCK +#if (FEATURE_COMPONENT_ANALOG_CLOCK == 1) KEYWORD(SEC, sec) // analog-clock second #endif // FEATURE_COMPONENT_ANALOG_CLOCK -#ifdef FEATURE_DATE_FORMAT +#if (FEATURE_DATE_FORMAT == 1) KEYWORD(SECOND, second) #endif -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) KEYWORD(SEEKING, seeking) // // video component seeking event tag KEYWORD(SEEKED, seeked) // // video component seeked event tag #endif // FEATURE_COMPONENT_VIDEO @@ -235,7 +235,7 @@ enum { KEYWORD(SELECTED_COLOR, selectedColor) // picker-view style KEYWORD(SELECTED_FONT_FAMILY, selectedFontFamily) // picker-view style KEYWORD(SELECTED_FONT_SIZE, selectedFontSize) // picker-view style -#ifdef FEATURE_DATE_FORMAT +#if (FEATURE_DATE_FORMAT == 1) KEYWORD(SHORT, short) #endif KEYWORD(SHOW, show) @@ -247,16 +247,16 @@ enum { KEYWORD(STACK, stack) // tag name KEYWORD(STANDARD, standard) // text font size type KEYWORD(STOP, stop) // image-animator stop event, video component end event tag -#if (defined(FEATURE_COMPONENT_DATE_PICKER) || defined(FEATURE_COMPONENT_VIDEO)) +#if ((FEATURE_COMPONENT_DATE_PICKER == 1) || (FEATURE_COMPONENT_VIDEO == 1)) KEYWORD(START, start) // date picker-view attr, video component start event tag -#endif // (defined(FEATURE_COMPONENT_DATE_PICKER) || defined(FEATURE_COMPONENT_VIDEO) +#endif // ((FEATURE_COMPONENT_DATE_PICKER == 1) || (FEATURE_COMPONENT_VIDEO == 1)) KEYWORD(START_ANGLE, startAngle) // circle progress start angle KEYWORD(STEP, step) KEYWORD(STROKE_WIDTH, strokeWidth) // horizon/arc progress style KEYWORD(SWIPE, swipe) // swipe event listener KEYWORD(SWIPER, swiper) // tag name KEYWORD(SWITCH, switch) // tag name -#ifdef FEATURE_COMPONENT_TABS +#if (FEATURE_COMPONENT_TABS == 1) KEYWORD(TAB_BAR, tab-bar) // tag name KEYWORD(TAB_CONTENT, tab-content) // tag name KEYWORD(TABS, tabs) // tag name @@ -265,7 +265,7 @@ enum { KEYWORD(TEXT_ALIGN, textAlign) // text style type KEYWORD(TEXT_OVERFLOW, textOverflow) // text style type KEYWORD(TIME, time) // picker-view attr value -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) KEYWORD(TIME_UPDATE, timeupdate) // video component timeupdate event tag #endif // FEATURE_COMPONENT_VIDEO KEYWORD(TOP, top) @@ -279,21 +279,21 @@ enum { KEYWORD(TRANSLATE_X, translateX) // animation transform x KEYWORD(TRANSLATE_Y, translateY) // animation transform y KEYWORD(TRUE, true) // common attributes -#ifdef FEATURE_COMPONENT_ANALOG_CLOCK +#if (FEATURE_COMPONENT_ANALOG_CLOCK == 1) KEYWORD(TYPE, type) // clock-hand type #endif // FEATURE_COMPONENT_ANALOG_CLOCK KEYWORD(VALUE, value) // common attributes KEYWORD(VERTICAL, vertical) // swiper attr vertical -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) KEYWORD(VIDEO, video) // video tag name #endif // FEATURE_COMPONENT_VIDEO KEYWORD(WIDTH, width) // common attributes KEYWORD(WRAP, wrap) // flex wrap -#ifdef FEATURE_DATE_FORMAT +#if (FEATURE_DATE_FORMAT == 1) KEYWORD(WEEKDAY, weekday) KEYWORD(YEAR, year) #endif -#ifdef FEATURE_NUMBER_FORMAT +#if (FEATURE_NUMBER_FORMAT == 1) KEYWORD(STYLE, style) KEYWORD(USEGROUP, useGroup) KEYWORD(MINIMUMFRACTIONDIGITS, minimumFractionDigits) diff --git a/frameworks/src/core/base/locale_util.cpp b/frameworks/src/core/base/locale_util.cpp index ee145cb..f65e509 100755 --- a/frameworks/src/core/base/locale_util.cpp +++ b/frameworks/src/core/base/locale_util.cpp @@ -14,7 +14,7 @@ */ #include "locale_util.h" -#ifdef FEATURE_INTL_MODULE +#if (FEATURE_INTL_MODULE == 1) #include "ace_log.h" #include "global.h" #include "js_fwk_common.h" diff --git a/frameworks/src/core/base/locale_util.h b/frameworks/src/core/base/locale_util.h index 8a8bd76..9124f26 100644 --- a/frameworks/src/core/base/locale_util.h +++ b/frameworks/src/core/base/locale_util.h @@ -16,7 +16,7 @@ #ifndef OHOS_ACELITE_LOCALE_UTIL_H #define OHOS_ACELITE_LOCALE_UTIL_H #include "acelite_config.h" -#ifdef FEATURE_INTL_MODULE +#if (FEATURE_INTL_MODULE == 1) #include "locale_info.h" #include "non_copyable.h" namespace OHOS { diff --git a/frameworks/src/core/base/product_adapter.cpp b/frameworks/src/core/base/product_adapter.cpp index a650c82..6b41549 100644 --- a/frameworks/src/core/base/product_adapter.cpp +++ b/frameworks/src/core/base/product_adapter.cpp @@ -161,7 +161,7 @@ void ProductAdapter::RegTEHandlers(const TEHandlingHooks &teHandlingHooks) // read the global value directly here. TEDispatchingResult ProductAdapter::DispatchTEMessage() { -#ifdef OHOS_ACELITE_PRODUCT_WATCH // only some specific products support TE dispatching +#if (OHOS_ACELITE_PRODUCT_WATCH == 1) // only some specific products support TE dispatching if (!g_isRenderTickAcceptable) { return TEDispatchingResult::REFUSED; } diff --git a/frameworks/src/core/components/analog_clock_component.cpp b/frameworks/src/core/components/analog_clock_component.cpp index 0842f82..2161a94 100644 --- a/frameworks/src/core/components/analog_clock_component.cpp +++ b/frameworks/src/core/components/analog_clock_component.cpp @@ -15,7 +15,7 @@ #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_ANALOG_CLOCK +#if (FEATURE_COMPONENT_ANALOG_CLOCK == 1) #include "ace_log.h" #include "analog_clock_component.h" diff --git a/frameworks/src/core/components/analog_clock_component.h b/frameworks/src/core/components/analog_clock_component.h index 01520a9..3f03cf7 100644 --- a/frameworks/src/core/components/analog_clock_component.h +++ b/frameworks/src/core/components/analog_clock_component.h @@ -18,7 +18,7 @@ #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_ANALOG_CLOCK +#if (FEATURE_COMPONENT_ANALOG_CLOCK == 1) #include "component.h" #include "non_copyable.h" diff --git a/frameworks/src/core/components/camera_component.cpp b/frameworks/src/core/components/camera_component.cpp index 420903c..8e08a04 100755 --- a/frameworks/src/core/components/camera_component.cpp +++ b/frameworks/src/core/components/camera_component.cpp @@ -14,7 +14,7 @@ */ #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_CAMERA +#if (FEATURE_COMPONENT_CAMERA == 1) #include "camera_component.h" #include diff --git a/frameworks/src/core/components/camera_component.h b/frameworks/src/core/components/camera_component.h index 71ab07b..69a848e 100755 --- a/frameworks/src/core/components/camera_component.h +++ b/frameworks/src/core/components/camera_component.h @@ -17,7 +17,7 @@ #define OHOS_ACELITE_CAMERA_COMPONENT_H #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_CAMERA +#if (FEATURE_COMPONENT_CAMERA == 1) #include "component.h" #include "camera_kit.h" diff --git a/frameworks/src/core/components/canvas_component.cpp b/frameworks/src/core/components/canvas_component.cpp index e78c09e..883ce8b 100644 --- a/frameworks/src/core/components/canvas_component.cpp +++ b/frameworks/src/core/components/canvas_component.cpp @@ -15,7 +15,7 @@ #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_CANVAS +#if (FEATURE_COMPONENT_CANVAS == 1) #include "canvas_component.h" #include "js_fwk_common.h" #include "product_adapter.h" diff --git a/frameworks/src/core/components/canvas_component.h b/frameworks/src/core/components/canvas_component.h index 46ec159..0c878a3 100644 --- a/frameworks/src/core/components/canvas_component.h +++ b/frameworks/src/core/components/canvas_component.h @@ -18,7 +18,7 @@ #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_CANVAS +#if (FEATURE_COMPONENT_CANVAS == 1) #include "component.h" #include "non_copyable.h" #include "ui_canvas.h" diff --git a/frameworks/src/core/components/clock_hand_component.cpp b/frameworks/src/core/components/clock_hand_component.cpp index 7d31b31..b00ab19 100644 --- a/frameworks/src/core/components/clock_hand_component.cpp +++ b/frameworks/src/core/components/clock_hand_component.cpp @@ -15,7 +15,7 @@ #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_ANALOG_CLOCK +#if (FEATURE_COMPONENT_ANALOG_CLOCK == 1) #include "ace_log.h" #include "ace_mem_base.h" diff --git a/frameworks/src/core/components/clock_hand_component.h b/frameworks/src/core/components/clock_hand_component.h index ef784a2..c2d9848 100644 --- a/frameworks/src/core/components/clock_hand_component.h +++ b/frameworks/src/core/components/clock_hand_component.h @@ -18,7 +18,7 @@ #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_ANALOG_CLOCK +#if (FEATURE_COMPONENT_ANALOG_CLOCK == 1) #include "component.h" #include "non_copyable.h" diff --git a/frameworks/src/core/components/component.cpp b/frameworks/src/core/components/component.cpp index 0a8084e..56dfde5 100755 --- a/frameworks/src/core/components/component.cpp +++ b/frameworks/src/core/components/component.cpp @@ -202,7 +202,7 @@ void Component::Release() { // detach self from fatal handler monitoring FatalHandler::GetInstance().DetachComponentNode(this); -#ifdef FEATURE_LAZY_LOADING_MODULE +#if (FEATURE_LAZY_LOADING_MODULE == 1) // detach from lazy pending list JsAppContext *context = JsAppContext::GetInstance(); LazyLoadManager *lazyLoadManager = const_cast(context->GetLazyLoadManager()); @@ -1097,7 +1097,7 @@ void Component::ParseAttrs() if (freeze_) { newAttrValue = JSFunction::Call(attrValue, viewModel_, nullptr, 0); } else { -#ifdef FEATURE_LAZY_LOADING_MODULE +#if (FEATURE_LAZY_LOADING_MODULE == 1) newAttrValue = CallJSFunction(attrValue, viewModel_, nullptr, 0); JsAppContext *context = JsAppContext::GetInstance(); LazyLoadManager *lazyLoadManager = const_cast(context->GetLazyLoadManager()); @@ -1922,7 +1922,7 @@ bool Component::HandleBackgroundImg(const AppStyleItem &styleItem, char *&presse filePath = nullptr; return result; } -#ifdef OHOS_ACELITE_PRODUCT_WATCH +#if (OHOS_ACELITE_PRODUCT_WATCH == 1) // convert .png/jpeg/bmp to .bin subfix CureImagePath(imagePath); #endif // OHOS_ACELITE_PRODUCT_WATCH @@ -1944,7 +1944,7 @@ bool Component::HandleBackgroundImg(const AppStyleItem &styleItem, char *&presse return result; } -#ifdef FEATURE_ROTATION_API +#if (FEATURE_ROTATION_API == 1) jerry_value_t Component::HandleRotationRequest(const jerry_value_t func, const jerry_value_t dom, const jerry_value_t args[], diff --git a/frameworks/src/core/components/component.h b/frameworks/src/core/components/component.h index ca96517..a30fea8 100755 --- a/frameworks/src/core/components/component.h +++ b/frameworks/src/core/components/component.h @@ -469,7 +469,7 @@ protected: */ bool HandleBackgroundImg(const AppStyleItem &styleItem, char *&pressedImage, char *&normalImage) const; -#ifdef FEATURE_ROTATION_API +#if (FEATURE_ROTATION_API == 1) /** * @brief the rotation API handling function, the child component can register it for rotation API supporting * @param func function object diff --git a/frameworks/src/core/components/component_factory.h b/frameworks/src/core/components/component_factory.h index c686ee8..8b06446 100755 --- a/frameworks/src/core/components/component_factory.h +++ b/frameworks/src/core/components/component_factory.h @@ -17,14 +17,14 @@ #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_ANALOG_CLOCK +#if (FEATURE_COMPONENT_ANALOG_CLOCK == 1) #include "analog_clock_component.h" #include "clock_hand_component.h" #endif // FEATURE_COMPONENT_ANALOG_CLOCK -#ifdef FEATURE_COMPONENT_CAMERA +#if (FEATURE_COMPONENT_CAMERA == 1) #include "camera_component.h" #endif // FEATURE_COMPONENT_CAMERA -#ifdef FEATURE_COMPONENT_CANVAS +#if (FEATURE_COMPONENT_CANVAS == 1) #include "canvas_component.h" #endif // FEATURE_COMPONENT_CANVAS #include "chart_component.h" @@ -45,14 +45,14 @@ #include "marquee_component.h" #include "non_copyable.h" #include "picker_view_component.h" -#ifdef FEATURE_COMPONENT_QRCODE +#if (FEATURE_COMPONENT_QRCODE == 1) #include "qrcode_component.h" #endif #include "slider_component.h" #include "stack_component.h" #include "swiper_component.h" #include "switch_component.h" -#ifdef FEATURE_COMPONENT_TABS +#if (FEATURE_COMPONENT_TABS == 1) #include "tab_bar_component.h" #include "tab_content_component.h" #include "tabs_component.h" @@ -80,12 +80,12 @@ public: Component* component; switch (componentNameId) { -#ifdef FEATURE_COMPONENT_CAMERA +#if (FEATURE_COMPONENT_CAMERA == 1) case K_CAMERA: component = new CameraComponent(options, children, styleManager); break; #endif -#ifdef FEATURE_COMPONENT_CANVAS +#if (FEATURE_COMPONENT_CANVAS == 1) case K_CANVAS: component = new CanvasComponent(options, children, styleManager); break; @@ -112,7 +112,7 @@ public: } break; } -#ifdef FEATURE_COMPONENT_TABS +#if (FEATURE_COMPONENT_TABS == 1) case K_TAB_BAR: component = new TabBarComponent(options, children, styleManager); break; @@ -141,7 +141,7 @@ public: case K_LIST_ITEM: component = new DivComponent(options, children, styleManager); break; -#ifdef FEATURE_COMPONENT_ANALOG_CLOCK +#if (FEATURE_COMPONENT_ANALOG_CLOCK == 1) case K_CLOCK_HAND: component = new ClockHandComponent(options, children, styleManager); break; @@ -170,12 +170,12 @@ public: case K_PICKER_VIEW: component = new PickerViewComponent(options, children, styleManager); break; -#ifdef FEATURE_COMPONENT_QRCODE +#if (FEATURE_COMPONENT_QRCODE == 1) case K_QRCODE: component = new QrcodeComponent(options, children, styleManager); break; #endif // FEATURE_COMPONENT_QRCODE -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) case K_VIDEO: component = new VideoComponent(options, children, styleManager); break; diff --git a/frameworks/src/core/components/list_component.cpp b/frameworks/src/core/components/list_component.cpp index f621e62..c14e6e0 100755 --- a/frameworks/src/core/components/list_component.cpp +++ b/frameworks/src/core/components/list_component.cpp @@ -30,7 +30,7 @@ ListComponent::ListComponent(JSValue options, JSValue children, AppStyleManager { SetComponentName(K_LIST); RegisterNamedFunction(FUNC_SCROLLTO, ListScrollTo); -#ifdef FEATURE_ROTATION_API +#if (FEATURE_ROTATION_API == 1) RegisterNamedFunction(FUNC_ROTATION_NAME, HandleRotationRequest); #endif // FEATURE_ROTATION_API } diff --git a/frameworks/src/core/components/panel_view.cpp b/frameworks/src/core/components/panel_view.cpp index c4b94a2..eaf6558 100755 --- a/frameworks/src/core/components/panel_view.cpp +++ b/frameworks/src/core/components/panel_view.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) #include "panel_view.h" #include "graphic_config.h" diff --git a/frameworks/src/core/components/panel_view.h b/frameworks/src/core/components/panel_view.h index 9045ee5..9455f50 100755 --- a/frameworks/src/core/components/panel_view.h +++ b/frameworks/src/core/components/panel_view.h @@ -16,7 +16,7 @@ #define OHOS_ACELITE_PANEL_VIEW_H #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) #include "ace_log.h" #include "flex_layout.h" diff --git a/frameworks/src/core/components/picker_view_component.cpp b/frameworks/src/core/components/picker_view_component.cpp index d20174f..dbf7aeb 100755 --- a/frameworks/src/core/components/picker_view_component.cpp +++ b/frameworks/src/core/components/picker_view_component.cpp @@ -29,7 +29,7 @@ namespace OHOS { namespace ACELite { -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) void DatePickerListener::OnDatePickerStoped(UIDatePicker &picker) { if (!jerry_value_is_function(dateCallback_)) { @@ -94,7 +94,7 @@ PickerViewComponent::PickerViewComponent(jerry_value_t options, jerry_value_t ch pTextArray_(nullptr), textArraySize_(0), textPickerListener_(nullptr), -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) dateSelected_(nullptr), dateStart_(nullptr), dateEnd_(nullptr), @@ -105,7 +105,7 @@ PickerViewComponent::PickerViewComponent(jerry_value_t options, jerry_value_t ch { SetComponentName(K_PICKER_VIEW); fontSize_ = ProductAdapter::GetDefaultFontSize(); -#ifdef FEATURE_ROTATION_API +#if (FEATURE_ROTATION_API == 1) RegisterNamedFunction(FUNC_ROTATION_NAME, HandleRotationRequest); #endif // FEATURE_ROTATION_API } @@ -123,7 +123,7 @@ bool PickerViewComponent::CreateNativeViews() result = CreateTimePicker(); break; } -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) case PickerType::DATE: { result = CreateDatePicker(); break; @@ -190,7 +190,7 @@ bool PickerViewComponent::CreateTimePicker() return true; } -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) bool PickerViewComponent::CreateDatePicker() { UIDatePicker *uiDatePicker = new UIDatePicker(); @@ -248,7 +248,7 @@ void PickerViewComponent::ReleaseNativeViews() ACE_FREE(fontFamily_); ACE_FREE(selectedFontFamily_); -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) // free date picker resources if (datePickerListener_ != nullptr) { delete datePickerListener_; @@ -285,7 +285,7 @@ void PickerViewComponent::PostUpdate(uint16_t attrKeyId) switch (attrKeyId) { case K_SELECTED: -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) case K_START: case K_END: #endif // FEATURE_COMPONENT_DATE_PICKER @@ -334,7 +334,7 @@ void PickerViewComponent::UpdatePickerStyles() const timePicker->SetTextColor(color_, selectedColor_); break; } -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) case PickerType::DATE: { uint8_t fontId = font->GetFontId(fontFamily_, fontSize_); uint8_t selectedFontId = font->GetFontId(selectedFontFamily_, selectedFontSize_); @@ -367,7 +367,7 @@ void PickerViewComponent::UpdatePickerAttrs() const } break; } -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) case PickerType::DATE: { UIDatePicker *datePicker = reinterpret_cast(pickerView_); if (dateStart_ != nullptr) { @@ -401,7 +401,7 @@ bool PickerViewComponent::SetPrivateAttribute(uint16_t attrKeyId, jerry_value_t } break; } -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) case K_START: { if (pickerType_ == PickerType::DATE) { ACE_FREE(dateStart_); @@ -514,7 +514,7 @@ PickerViewComponent::PickerType PickerViewComponent::GetPickerType() const case K_TIME: type = PickerType::TIME; break; -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) case K_DATE: type = PickerType::DATE; break; @@ -540,7 +540,7 @@ bool PickerViewComponent::SetPickerSelected(jerry_value_t selectedValue) timeSelected_ = MallocStringOf(selectedValue); break; } -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) case PickerType::DATE: { ACE_FREE(dateSelected_); dateSelected_ = MallocStringOf(selectedValue); @@ -572,7 +572,7 @@ void PickerViewComponent::SetPickerListener(jerry_value_t funcValue) const } break; } -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) case PickerType::DATE: { if (datePickerListener_ != nullptr) { UIDatePicker *datePicker = reinterpret_cast(pickerView_); diff --git a/frameworks/src/core/components/picker_view_component.h b/frameworks/src/core/components/picker_view_component.h index 1aca88b..cc00eb9 100644 --- a/frameworks/src/core/components/picker_view_component.h +++ b/frameworks/src/core/components/picker_view_component.h @@ -19,7 +19,7 @@ #include "acelite_config.h" #include "component.h" #include "non_copyable.h" -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) #include "ui_date_picker.h" #endif // FEATURE_COMPONENT_DATE_PICKER #include "ui_time_picker.h" @@ -30,7 +30,7 @@ static constexpr char TEXT_PICKER_NEW_VALUE[] = "newValue"; static constexpr char TEXT_PICKER_NEW_SELECTED[] = "newSelected"; static constexpr char TIME_PICKER_HOUR[] = "hour"; static constexpr char TIME_PICKER_MINUTE[] = "minute"; -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) static constexpr char DATE_PICKER_YEAR[] = "year"; static constexpr char DATE_PICKER_MONTH[] = "month"; static constexpr char DATE_PICKER_DAY[] = "day"; @@ -92,7 +92,7 @@ private: jerry_value_t timeCallback_; }; -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) /** * @brief listener class for date picker onchange event. */ @@ -147,7 +147,7 @@ protected: UNKNOWN, TEXT, TIME, -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) DATE, #endif // FEATURE_COMPONENT_DATE_PICKER TYPE_MAX @@ -158,7 +158,7 @@ private: PickerType GetPickerType() const; bool CreateTextPicker(); bool CreateTimePicker(); -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) bool CreateDatePicker(); #endif // FEATURE_COMPONENT_DATE_PICKER bool SetPickerSelected(jerry_value_t selectedValue); @@ -184,7 +184,7 @@ private: uint16_t textArraySize_; TextPickerListener* textPickerListener_; -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) // date picker-view attributes char* dateSelected_; char* dateStart_; diff --git a/frameworks/src/core/components/qrcode_component.cpp b/frameworks/src/core/components/qrcode_component.cpp index e54033b..2e567e5 100755 --- a/frameworks/src/core/components/qrcode_component.cpp +++ b/frameworks/src/core/components/qrcode_component.cpp @@ -14,7 +14,7 @@ */ #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_QRCODE +#if (FEATURE_COMPONENT_QRCODE == 1) #include "qrcode_component.h" #include "ace_log.h" #include "ace_mem_base.h" diff --git a/frameworks/src/core/components/qrcode_component.h b/frameworks/src/core/components/qrcode_component.h index 406cb57..9e12abe 100755 --- a/frameworks/src/core/components/qrcode_component.h +++ b/frameworks/src/core/components/qrcode_component.h @@ -16,7 +16,7 @@ #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_QRCODE +#if (FEATURE_COMPONENT_QRCODE == 1) #include "component.h" #include "key_parser.h" #include "non_copyable.h" diff --git a/frameworks/src/core/components/slider_component.cpp b/frameworks/src/core/components/slider_component.cpp index c6bd1df..fb5f40e 100755 --- a/frameworks/src/core/components/slider_component.cpp +++ b/frameworks/src/core/components/slider_component.cpp @@ -30,7 +30,7 @@ SliderComponent::SliderComponent(jerry_value_t options, jerry_value_t children, direction_(UISlider::Direction::DIR_LEFT_TO_RIGHT) { SetComponentName(K_SLIDER); -#ifdef FEATURE_ROTATION_API +#if (FEATURE_ROTATION_API == 1) RegisterNamedFunction(FUNC_ROTATION_NAME, HandleRotationRequest); #endif // FEATURE_ROTATION_API } diff --git a/frameworks/src/core/components/swiper_component.cpp b/frameworks/src/core/components/swiper_component.cpp index 987396e..6c148f0 100755 --- a/frameworks/src/core/components/swiper_component.cpp +++ b/frameworks/src/core/components/swiper_component.cpp @@ -29,7 +29,7 @@ SwiperComponent::SwiperComponent(jerry_value_t options, jerry_value_t children, { SetComponentName(K_SWIPER); swiperView_.SetLoopState(true); -#ifdef FEATURE_ROTATION_API +#if (FEATURE_ROTATION_API == 1) RegisterNamedFunction(FUNC_ROTATION_NAME, HandleRotationRequest); #endif // FEATURE_ROTATION_API } diff --git a/frameworks/src/core/components/tab_bar_component.cpp b/frameworks/src/core/components/tab_bar_component.cpp index 194373b..3875da2 100755 --- a/frameworks/src/core/components/tab_bar_component.cpp +++ b/frameworks/src/core/components/tab_bar_component.cpp @@ -15,7 +15,7 @@ #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_TABS +#if (FEATURE_COMPONENT_TABS == 1) #include "js_fwk_common.h" #include "key_parser.h" diff --git a/frameworks/src/core/components/tab_bar_component.h b/frameworks/src/core/components/tab_bar_component.h index 3317275..f7052ed 100644 --- a/frameworks/src/core/components/tab_bar_component.h +++ b/frameworks/src/core/components/tab_bar_component.h @@ -18,7 +18,7 @@ #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_TABS +#if (FEATURE_COMPONENT_TABS == 1) #include "component.h" #include "non_copyable.h" diff --git a/frameworks/src/core/components/tab_content_component.cpp b/frameworks/src/core/components/tab_content_component.cpp index 7cbabe0..55b800d 100644 --- a/frameworks/src/core/components/tab_content_component.cpp +++ b/frameworks/src/core/components/tab_content_component.cpp @@ -15,7 +15,7 @@ #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_TABS +#if (FEATURE_COMPONENT_TABS == 1) #include "js_fwk_common.h" #include "keys.h" diff --git a/frameworks/src/core/components/tab_content_component.h b/frameworks/src/core/components/tab_content_component.h index f1dd7ab..7e91e01 100644 --- a/frameworks/src/core/components/tab_content_component.h +++ b/frameworks/src/core/components/tab_content_component.h @@ -18,7 +18,7 @@ #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_TABS +#if (FEATURE_COMPONENT_TABS == 1) #include "component.h" #include "non_copyable.h" diff --git a/frameworks/src/core/components/tabs_component.cpp b/frameworks/src/core/components/tabs_component.cpp index e9f5d46..cce673a 100755 --- a/frameworks/src/core/components/tabs_component.cpp +++ b/frameworks/src/core/components/tabs_component.cpp @@ -15,7 +15,7 @@ #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_TABS +#if (FEATURE_COMPONENT_TABS == 1) #include "ace_log.h" #include "keys.h" diff --git a/frameworks/src/core/components/tabs_component.h b/frameworks/src/core/components/tabs_component.h index d518488..0a07067 100644 --- a/frameworks/src/core/components/tabs_component.h +++ b/frameworks/src/core/components/tabs_component.h @@ -18,7 +18,7 @@ #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_TABS +#if (FEATURE_COMPONENT_TABS == 1) #include "component.h" #include "non_copyable.h" diff --git a/frameworks/src/core/components/test/unittest/common/BUILD.gn b/frameworks/src/core/components/test/unittest/common/BUILD.gn index 00a9d40..396f4e7 100755 --- a/frameworks/src/core/components/test/unittest/common/BUILD.gn +++ b/frameworks/src/core/components/test/unittest/common/BUILD.gn @@ -310,4 +310,4 @@ unittest("js_frameworks_test_canvas") { "canvas_tdd_test.cpp", ] deps = ace_test_deps -} \ No newline at end of file +} diff --git a/frameworks/src/core/components/test/unittest/common/picker_view_tdd_test.cpp b/frameworks/src/core/components/test/unittest/common/picker_view_tdd_test.cpp index 33110dc..937fc85 100755 --- a/frameworks/src/core/components/test/unittest/common/picker_view_tdd_test.cpp +++ b/frameworks/src/core/components/test/unittest/common/picker_view_tdd_test.cpp @@ -20,7 +20,7 @@ #include "root_view.h" #include "stylemgr/app_style_item.h" #include "stylemgr/app_style_manager.h" -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) #include "ui_date_picker.h" #endif #include "ui_picker.h" @@ -137,7 +137,7 @@ void PickerViewTddTest::ComponentPickerviewAttributeSetTest001() EXPECT_TRUE(pickerComponent != nullptr); UIPicker* textPicker = reinterpret_cast(pickerComponent->GetComponentRootView()); UITimePicker* timePicker = reinterpret_cast(pickerComponent->GetComponentRootView()); -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) UIDatePicker* datePicker = reinterpret_cast(pickerComponent->GetComponentRootView()); #endif @@ -145,7 +145,7 @@ void PickerViewTddTest::ComponentPickerviewAttributeSetTest001() * @tc.expected: step1. native picker object is nullptr */ if (!textPicker && !timePicker -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) && !datePicker #endif ) { @@ -154,7 +154,7 @@ void PickerViewTddTest::ComponentPickerviewAttributeSetTest001() printf("ComponentPickerviewAttributeSetTest001 fail\n"); } EXPECT_TRUE((textPicker == nullptr) && (timePicker == nullptr) -#ifdef FEATURE_COMPONENT_DATE_PICKER +#if (FEATURE_COMPONENT_DATE_PICKER == 1) && (datePicker != nullptr) #endif ); diff --git a/frameworks/src/core/components/video_component.cpp b/frameworks/src/core/components/video_component.cpp index 4c7d9ac..3b159e6 100644 --- a/frameworks/src/core/components/video_component.cpp +++ b/frameworks/src/core/components/video_component.cpp @@ -13,13 +13,13 @@ * limitations under the License. */ #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) #include "video_component.h" #include "ace_log.h" #include "key_parser.h" #include "keys.h" -#ifdef FEATURE_UPDATE_VIDEO_PROGRESS_ASYNC +#if (FEATURE_UPDATE_VIDEO_PROGRESS_ASYNC == 1) #include #include "ace_ability.h" #endif // FEATURE_UPDATE_VIDEO_PROGRESS_ASYNC @@ -32,7 +32,7 @@ const char * const VideoComponent::FUNC_SET_CURRENT_TIME = "setCurrentTime"; const char * const VideoComponent::FUNC_SET_Volume = "setVolume"; List VideoComponent::componentNodes_; -#ifdef FEATURE_UPDATE_VIDEO_PROGRESS_ASYNC +#if (FEATURE_UPDATE_VIDEO_PROGRESS_ASYNC == 1) pthread_mutex_t VideoComponent::updateLock_ = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t VideoComponent::updateCondition_ = PTHREAD_COND_INITIALIZER; #endif // FEATURE_UPDATE_VIDEO_PROGRESS_ASYN @@ -457,7 +457,7 @@ void VideoComponent::SetComponentReleasingFlag(bool releasing) isReleasing_ = releasing; } -#ifdef FEATURE_UPDATE_VIDEO_PROGRESS_ASYNC +#if (FEATURE_UPDATE_VIDEO_PROGRESS_ASYNC == 1) bool VideoComponent::PrepareProgressUpdatingThread() { int ret = pthread_mutex_init(&updateLock_, nullptr); diff --git a/frameworks/src/core/components/video_component.h b/frameworks/src/core/components/video_component.h index a5892f0..d03876b 100755 --- a/frameworks/src/core/components/video_component.h +++ b/frameworks/src/core/components/video_component.h @@ -16,8 +16,8 @@ #define OHOS_ACELITE_VIDEO_COMPONENT_H #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_VIDEO -#ifdef FEATURE_UPDATE_VIDEO_PROGRESS_ASYNC +#if (FEATURE_COMPONENT_VIDEO == 1) +#if (FEATURE_UPDATE_VIDEO_PROGRESS_ASYNC == 1) #include #include #endif // FEATURE_UPDATE_VIDEO_PROGRESS_ASYNC @@ -384,7 +384,7 @@ private: bool isPlaying_; bool isReleasing_; bool isUpdatingHandlerQuited_; -#ifdef FEATURE_UPDATE_VIDEO_PROGRESS_ASYNC +#if (FEATURE_UPDATE_VIDEO_PROGRESS_ASYNC == 1) static pthread_mutex_t updateLock_; static pthread_cond_t updateCondition_; #endif // FEATURE_UPDATE_VIDEO_PROGRESS_ASYNC diff --git a/frameworks/src/core/components/video_state_callback.h b/frameworks/src/core/components/video_state_callback.h index 189fd07..261f9b0 100644 --- a/frameworks/src/core/components/video_state_callback.h +++ b/frameworks/src/core/components/video_state_callback.h @@ -16,7 +16,7 @@ #define OHOS_ACELITE_VIDEO_STATE_CALLBACK_H #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) #include diff --git a/frameworks/src/core/components/video_view.cpp b/frameworks/src/core/components/video_view.cpp index bc057c3..fb59e39 100755 --- a/frameworks/src/core/components/video_view.cpp +++ b/frameworks/src/core/components/video_view.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) #include "video_view.h" #include "video_state_callback.h" diff --git a/frameworks/src/core/context/ace_ability.h b/frameworks/src/core/context/ace_ability.h index 539d037..a1c5364 100755 --- a/frameworks/src/core/context/ace_ability.h +++ b/frameworks/src/core/context/ace_ability.h @@ -22,7 +22,7 @@ #include "ability_loader.h" #include "js_ability.h" -#ifdef OHOS_ACELITE_PRODUCT_WATCH +#if (OHOS_ACELITE_PRODUCT_WATCH == 1) #error AceAbility only be used for L1 upper #endif diff --git a/frameworks/src/core/context/ace_event_error_code.cpp b/frameworks/src/core/context/ace_event_error_code.cpp index 851179a..795f89f 100644 --- a/frameworks/src/core/context/ace_event_error_code.cpp +++ b/frameworks/src/core/context/ace_event_error_code.cpp @@ -16,7 +16,7 @@ #include "ace_event_error_code.h" #include "product_adapter.h" -#ifdef FEATURE_ACELITE_MC_EVENT_ERROR_CODE_PRINT +#if (FEATURE_ACELITE_MC_EVENT_ERROR_CODE_PRINT == 1) namespace OHOS { namespace ACELite { EventErrorCodePrint *EventErrorCodePrint::GetInstance() diff --git a/frameworks/src/core/context/ace_event_error_code.h b/frameworks/src/core/context/ace_event_error_code.h index 24c1093..5ff98e6 100644 --- a/frameworks/src/core/context/ace_event_error_code.h +++ b/frameworks/src/core/context/ace_event_error_code.h @@ -18,7 +18,7 @@ #include "acelite_config.h" -#if defined(FEATURE_ACELITE_MC_EVENT_ERROR_CODE_PRINT) +#if (FEATURE_ACELITE_MC_EVENT_ERROR_CODE_PRINT == 1) #include "ace_event_id.h" #include "memory_heap.h" #include "non_copyable.h" @@ -35,7 +35,7 @@ #define ACE_ERROR_CODE_PRINT(info2, rfu) #endif // ENABLED(FEATURE_ACELITE_MC_EVENT_ERROR_CODE_PRINT) -#if defined(FEATURE_ACELITE_MC_EVENT_ERROR_CODE_PRINT) +#if (FEATURE_ACELITE_MC_EVENT_ERROR_CODE_PRINT == 1) namespace OHOS { namespace ACELite { class EventErrorCodePrint final : public MemoryHeap { diff --git a/frameworks/src/core/context/fatal_handler.cpp b/frameworks/src/core/context/fatal_handler.cpp index a23b57e..41da0f4 100644 --- a/frameworks/src/core/context/fatal_handler.cpp +++ b/frameworks/src/core/context/fatal_handler.cpp @@ -17,7 +17,7 @@ #include "ace_event_error_code.h" #include "ace_log.h" #include "async_task_manager.h" -#ifdef OHOS_ACELITE_PRODUCT_WATCH +#if (OHOS_ACELITE_PRODUCT_WATCH == 1) #include "cmsis_os2.h" #endif // OHOS_ACELITE_PRODUCT_WATCH #include "jerryscript-port-default.h" @@ -52,7 +52,7 @@ bool FatalHandler::IsAppExitingWrapper() static void HandleFatal(int errorCode) { -#ifdef FEATURE_FATAL_ERROR_HANDLING +#if (FEATURE_FATAL_ERROR_HANDLING == 1) HILOG_ERROR(HILOG_MODULE_ACE, "hitted by fatal error[%{public}d]", errorCode); if (FatalHandler::GetInstance().IsFatalErrorHitted()) { // fatal hitted again during one fatal handing, return to avoid dead loop @@ -69,7 +69,7 @@ static void HandleFatal(int errorCode) const uint32_t sleepTime = 3000; uint8_t maxRetryCount = 20; while (maxRetryCount > 0) { -#ifdef OHOS_ACELITE_PRODUCT_WATCH +#if (OHOS_ACELITE_PRODUCT_WATCH == 1) osDelay(sleepTime); #endif // OHOS_ACELITE_PRODUCT_WATCH maxRetryCount--; @@ -177,7 +177,7 @@ void FatalHandler::ResetRendering() TaskManager::GetInstance()->ResetTaskHandlerMutex(); SetTEHandlingFlag(false); } -#ifdef OHOS_ACELITE_PRODUCT_WATCH +#if (OHOS_ACELITE_PRODUCT_WATCH == 1) ProductAdapter::NotifyRenderEnd(); #endif } diff --git a/frameworks/src/core/context/js_ability.cpp b/frameworks/src/core/context/js_ability.cpp index a71b813..26bd90e 100644 --- a/frameworks/src/core/context/js_ability.cpp +++ b/frameworks/src/core/context/js_ability.cpp @@ -20,7 +20,7 @@ #include "ace_log.h" #include "acelite_config.h" #include "async_task_manager.h" -#ifdef OHOS_ACELITE_PRODUCT_WATCH +#if (OHOS_ACELITE_PRODUCT_WATCH == 1) #include "dft_impl.h" #endif // OHOS_ACELITE_PRODUCT_WATCH #include "fatal_handler.h" @@ -49,21 +49,21 @@ static JSAbilityImpl *CastAbilityImpl(void *abilityImpl) static void DumpNativeMemoryUsage() { -#ifdef OHOS_ACELITE_PRODUCT_WATCH +#if (OHOS_ACELITE_PRODUCT_WATCH == 1) NativeMemInfo memInfo; ProductAdapter::GetNativeMemInfo(&memInfo); HILOG_DEBUG(HILOG_MODULE_ACE, "available free size: %{public}d", memInfo.freeSize); #endif // OHOS_ACELITE_PRODUCT_WATCH } -#ifdef OHOS_ACELITE_PRODUCT_WATCH +#if (OHOS_ACELITE_PRODUCT_WATCH == 1) extern "C" void RestoreSystemWrapper(const char *crashMessage); #endif JSAbility::~JSAbility() { // check the status if (jsAbilityImpl_ != nullptr) { -#ifdef OHOS_ACELITE_PRODUCT_WATCH +#if (OHOS_ACELITE_PRODUCT_WATCH == 1) // the JSAbility instance can only be destroied after transfering the app to DESTROY state RestoreSystemWrapper("AMS is deleting app task but without normal lifecycle transition!"); #endif @@ -93,7 +93,7 @@ void JSAbility::Launch(const char * const abilityPath, const char * const bundle HILOG_INFO(HILOG_MODULE_ACE, "LIFECYCLE: JS Ability is launching"); -#ifndef MOCK_JS_ASYNC_WORK +#if (MOCK_JS_ASYNC_WORK != 1) JsAsyncWork::SetFatalHandleFunc(FatalHandler::IsErrorHittedWrapper, FatalHandler::IsAppExitingWrapper); #endif #if (defined(__LINUX__) || defined(__LITEOS_A__)) @@ -110,7 +110,7 @@ void JSAbility::Launch(const char * const abilityPath, const char * const bundle // mark the flag in advance to make sure we can take over render tick as soon as possible ProductAdapter::UpdateRenderTickAcceptable(true); JSAbilityImpl *jsAbilityImpl = CastAbilityImpl(jsAbilityImpl_); -#ifndef MOCK_JS_ASYNC_WORK +#if (MOCK_JS_ASYNC_WORK != 1) // simulator uses the self-implementation for async work, this interface is not included JsAsyncWork::SetEnvStatus(true); #endif @@ -160,7 +160,7 @@ void JSAbility::TransferToDestroy() return; } -#ifndef MOCK_JS_ASYNC_WORK +#if (MOCK_JS_ASYNC_WORK != 1) // simulator uses the self-implementation for async work, this interface is not included JsAsyncWork::SetEnvStatus(false); #endif @@ -173,12 +173,12 @@ void JSAbility::TransferToDestroy() ProductAdapter::UpdateRenderTickAcceptable(false); FatalHandler::GetInstance().ResetRendering(); FatalHandler::GetInstance().SetExitingFlag(false); -#ifdef FEATURE_SCREEN_ON_VISIBLE +#if (FEATURE_SCREEN_ON_VISIBLE == 1) if (ProductAdapter::SetScreenOnVisible(false) == false) { HILOG_ERROR(HILOG_MODULE_ACE, "Fail to recover screen visible property"); } #endif -#ifdef OHOS_ACELITE_PRODUCT_WATCH +#if (OHOS_ACELITE_PRODUCT_WATCH == 1) JsAsyncWork::SetAppQueueHandler(nullptr); DftImpl::GetInstance()->RegisterPageReplaced(nullptr); #endif // OHOS_ACELITE_PRODUCT_WATCH diff --git a/frameworks/src/core/context/js_app_context.cpp b/frameworks/src/core/context/js_app_context.cpp index 87afbe1..2c81d1c 100755 --- a/frameworks/src/core/context/js_app_context.cpp +++ b/frameworks/src/core/context/js_app_context.cpp @@ -16,10 +16,10 @@ #include "js_app_context.h" #include "ace_event_error_code.h" #include "ace_log.h" -#if (defined(__LINUX__) || defined(__LITEOS__)) +#if (defined(__LINUX__) || defined(__LITEOS_A__)) #include "ace_ability.h" #endif -#ifdef FEATURE_API_VERSION +#if (FEATURE_API_VERSION == 1) #include "bundle_manager.h" #endif // FEATURE_API_VERSION #include "component_factory.h" @@ -33,7 +33,7 @@ #include "string_util.h" #include "task_manager.h" #include "ui_view_group.h" -#ifndef OHOS_ACELITE_PRODUCT_WATCH +#if (OHOS_ACELITE_PRODUCT_WATCH != 1) #include "ability_env.h" #endif @@ -314,7 +314,7 @@ char *JsAppContext::GetResourcePath(const char *uri) const HILOG_ERROR(HILOG_MODULE_ACE, "fail to get resource path."); return nullptr; } -#ifdef OHOS_ACELITE_PRODUCT_WATCH +#if (OHOS_ACELITE_PRODUCT_WATCH == 1) // no GetDataPath API provided on watch, contact the path by the product configuration insteadly char *relocatedPath = ProcessResourcePathByConfiguration(size, path); #else @@ -362,7 +362,7 @@ char *JsAppContext::ProcessResourcePathByConfiguration(size_t origUriLength, con void JsAppContext::LoadApiVersion() { -#ifdef FEATURE_API_VERSION +#if (FEATURE_API_VERSION == 1) BundleInfo bundle = {0}; uint8_t retCode = GetBundleInfo(currentBundleName_, false, &bundle); if (retCode != 0) { diff --git a/frameworks/src/core/context/js_app_environment.cpp b/frameworks/src/core/context/js_app_environment.cpp index 7b7c03a..db701d8 100755 --- a/frameworks/src/core/context/js_app_environment.cpp +++ b/frameworks/src/core/context/js_app_environment.cpp @@ -35,7 +35,8 @@ #include "presets/version_module.h" #include "product_adapter.h" #include "system_info.h" -#ifdef JS_ENGINE_STATIC_MULTI_CONTEXTS_ENABLED +#if (JS_ENGINE_STATIC_MULTI_CONTEXTS_ENABLED == 1) + extern "C" { #include "generate-bytecode.h" } @@ -64,17 +65,17 @@ void JsAppEnvironment::LoadAceBuiltInModules() const void JsAppEnvironment::InitJsFramework() const { START_TRACING(ENGINE_INIT); -#ifdef JS_ENGINE_STATIC_MULTI_CONTEXTS_ENABLED +#if (JS_ENGINE_STATIC_MULTI_CONTEXTS_ENABLED == 1) js_task_context_init(); #endif -#ifndef JERRY_PORTING_DEPENDENCY +#if (JERRY_PORTING_DEPENDENCY == 0) Srand((unsigned)jerry_port_get_current_time()); #endif Debugger::GetInstance().SetupJSContext(); jerry_init(JERRY_INIT_EMPTY); STOP_TRACING(); START_TRACING(FWK_INIT); -#ifdef JSFWK_TEST +#if (JSFWK_TEST == 1) jerry_value_t globalThis = jerry_get_global_object(); jerry_release_value(jerryx_set_property_str(globalThis, "globalThis", globalThis)); jerry_release_value(globalThis); @@ -126,7 +127,7 @@ void JsAppEnvironment::Cleanup() jerry_cleanup(); // free the external JS context, only can be called after clean up engine Debugger::GetInstance().ReleaseJSContext(); -#ifdef JS_ENGINE_STATIC_MULTI_CONTEXTS_ENABLED +#if (JS_ENGINE_STATIC_MULTI_CONTEXTS_ENABLED == 1) jerry_port_default_remove_current_context_record(); #endif } diff --git a/frameworks/src/core/context/js_profiler.cpp b/frameworks/src/core/context/js_profiler.cpp index 5864a67..cf43de3 100644 --- a/frameworks/src/core/context/js_profiler.cpp +++ b/frameworks/src/core/context/js_profiler.cpp @@ -21,11 +21,11 @@ #include "js_async_work.h" #include "js_fwk_common.h" #include "key_parser.h" -#if defined(FEATURE_ACELITE_MC_JS_PROFILER) +#if (FEATURE_ACELITE_MC_JS_PROFILER == 1) #include #include "los_tick.h" #include "unistd.h" -#elif defined(FEATURE_ACELITE_JS_PROFILER) +#elif (FEATURE_ACELITE_JS_PROFILER == 1) #include #else #include @@ -40,7 +40,7 @@ namespace ACELite { */ static bool g_isFirst = true; -#if defined(FEATURE_ACELITE_MC_JS_PROFILER) +#if (FEATURE_ACELITE_MC_JS_PROFILER == 1) static uint16_t g_profiler_msg_index = 0; #else static constexpr uint8_t PHASE_NAME_LENGTH = 50; @@ -60,7 +60,7 @@ struct ProfilerPhase { * NOTE: Keep this array sync with PerformanceTag definations */ static const ProfilerPhase g_profilerPhaseConfig[] = { -#if defined(FEATURE_ACELITE_MC_JS_PROFILER) +#if (FEATURE_ACELITE_MC_JS_PROFILER == 1) // id, parent {P_UNKNOWN, P_UNKNOWN}, {LAUNCH, P_UNKNOWN}, @@ -157,7 +157,7 @@ static const ProfilerPhase g_profilerPhaseConfig[] = { #endif }; -#ifdef FEATURE_ACELITE_MC_JS_PROFILER +#if (FEATURE_ACELITE_MC_JS_PROFILER == 1) JSProfiler::JSProfiler() : data_(nullptr), dataCount_(0), traceIdSlot_(0), enabled_(false), msg_(nullptr) {} #else JSProfiler::JSProfiler() : data_(nullptr), dataCount_(0), traceIdSlot_(0), enabled_(false) {} @@ -176,7 +176,7 @@ JSProfiler *JSProfiler::GetInstance() bool JSProfiler::IsEnabled() { bool isEnabled = enabled_ && (data_ != nullptr); -#ifdef FEATURE_ACELITE_MC_JS_PROFILER +#if (FEATURE_ACELITE_MC_JS_PROFILER == 1) isEnabled = isEnabled && (msg_ != nullptr); #endif return isEnabled; @@ -193,7 +193,7 @@ void JSProfiler::PrepareDataBuffer() HILOG_ERROR(HILOG_MODULE_ACE, "malloc performance data buffer failed"); return; } -#ifdef FEATURE_ACELITE_MC_JS_PROFILER +#if (FEATURE_ACELITE_MC_JS_PROFILER == 1) msg_ = static_cast(ace_malloc(PROFILER_MSG_LENGTH * sizeof(ProfilerMsg))); if (msg_ == nullptr) { HILOG_ERROR(HILOG_MODULE_ACE, "malloc performance data buffer failed"); @@ -205,7 +205,7 @@ void JSProfiler::PrepareDataBuffer() ResetData(); } -#ifdef FEATURE_ACELITE_MC_JS_PROFILER +#if (FEATURE_ACELITE_MC_JS_PROFILER == 1) void JSProfiler::FlushProfilerMsg(void *data) { if (data == nullptr) { @@ -255,7 +255,7 @@ void JSProfiler::FlushProfilerMsg(void *data) void JSProfiler::Release() { ACE_FREE(data_); -#ifdef FEATURE_ACELITE_MC_JS_PROFILER +#if (FEATURE_ACELITE_MC_JS_PROFILER == 1) ACE_FREE(msg_); #endif } @@ -270,7 +270,7 @@ void JSProfiler::ResetData() } } -#ifdef FEATURE_ACELITE_MC_JS_PROFILER +#if (FEATURE_ACELITE_MC_JS_PROFILER == 1) if (msg_) { if (memset_s(msg_, (PROFILER_MSG_LENGTH * sizeof(ProfilerMsg)), 0, (PROFILER_MSG_LENGTH * sizeof(ProfilerMsg))) != 0) { @@ -351,7 +351,7 @@ void JSProfiler::Output() // for too many round details, we just print out bigger than 0 items to save the log IO band width continue; } -#if defined(FEATURE_ACELITE_MC_JS_PROFILER) +#if (FEATURE_ACELITE_MC_JS_PROFILER == 1) if (g_profiler_msg_index == 0) { if ((data.label != LAUNCH) && (data.label != ROUTER_REPLACE)) { continue; @@ -381,7 +381,7 @@ void JSProfiler::Output() g_profilerPhaseConfig[g_profilerPhaseConfig[data.label].parentPhase].phaseName); #endif } -#ifdef FEATURE_ACELITE_MC_JS_PROFILER +#if (FEATURE_ACELITE_MC_JS_PROFILER == 1) JsAsyncWork::DispatchAsyncWork(FlushProfilerMsg, this); #else // reset all records after output to trace @@ -391,10 +391,10 @@ void JSProfiler::Output() uint64_t JSProfiler::GetCurrentClockTick() const { -#if defined(FEATURE_ACELITE_MC_JS_PROFILER) +#if (FEATURE_ACELITE_MC_JS_PROFILER == 1) // real device return LOS_TickCountGet(); // count in clock ticks, usually is ms -#elif defined(FEATURE_ACELITE_JS_PROFILER) +#elif (FEATURE_ACELITE_JS_PROFILER == 1) const uint32_t unit = 1000; // ipcamera struct timeval timeVal; @@ -414,7 +414,7 @@ uint64_t JSProfiler::CalculateElapsedTime(uint64_t start, uint64_t end) const } uint64_t interval = end - start; -#if defined(FEATURE_ACELITE_MC_JS_PROFILER) || defined(FEATURE_ACELITE_JS_PROFILER) +#if ((FEATURE_ACELITE_MC_JS_PROFILER == 1) || (FEATURE_ACELITE_JS_PROFILER == 1)) // real device return interval; #else diff --git a/frameworks/src/core/context/js_profiler.h b/frameworks/src/core/context/js_profiler.h index 071e136..6ba738c 100644 --- a/frameworks/src/core/context/js_profiler.h +++ b/frameworks/src/core/context/js_profiler.h @@ -120,7 +120,7 @@ struct PerformanceData { uint8_t component; }; -#ifdef FEATURE_ACELITE_MC_JS_PROFILER +#if (FEATURE_ACELITE_MC_JS_PROFILER == 1) static constexpr uint8_t MSG_LENGTH = 20; struct ProfilerMsg { @@ -157,7 +157,7 @@ public: */ void Release(); -#ifdef FEATURE_ACELITE_MC_JS_PROFILER +#if (FEATURE_ACELITE_MC_JS_PROFILER == 1) /** * @brief Flush output to file. */ @@ -236,7 +236,7 @@ private: uint16_t dataCount_ = 0; uint16_t traceIdSlot_ = 0; bool enabled_ = false; -#ifdef FEATURE_ACELITE_MC_JS_PROFILER +#if (FEATURE_ACELITE_MC_JS_PROFILER == 1) static constexpr uint8_t PROFILER_MSG_LENGTH = 128; static constexpr uint8_t TEXT_LENGTH = 30; ProfilerMsg *msg_ = nullptr; diff --git a/frameworks/src/core/context/js_timer_list.cpp b/frameworks/src/core/context/js_timer_list.cpp index dd4f05c..734a80e 100644 --- a/frameworks/src/core/context/js_timer_list.cpp +++ b/frameworks/src/core/context/js_timer_list.cpp @@ -15,7 +15,7 @@ #include "acelite_config.h" -#ifdef FEATURE_TIMER_MODULE +#if (FEATURE_TIMER_MODULE == 1) #include "js_timer_list.h" #include "presets/timer_module.h" #include "ace_mem_base.h" diff --git a/frameworks/src/core/context/js_timer_list.h b/frameworks/src/core/context/js_timer_list.h index 0980ebf..a90fbbd 100755 --- a/frameworks/src/core/context/js_timer_list.h +++ b/frameworks/src/core/context/js_timer_list.h @@ -19,7 +19,7 @@ #include "acelite_config.h" -#ifdef FEATURE_TIMER_MODULE +#if (FEATURE_TIMER_MODULE == 1) #include #include #include "memory_heap.h" diff --git a/frameworks/src/core/dialog/js_dialog.cpp b/frameworks/src/core/dialog/js_dialog.cpp index c6a729f..1ce7007 100755 --- a/frameworks/src/core/dialog/js_dialog.cpp +++ b/frameworks/src/core/dialog/js_dialog.cpp @@ -14,7 +14,7 @@ */ #include "acelite_config.h" -#ifdef FEATURE_MODULE_DIALOG +#if (FEATURE_MODULE_DIALOG == 1) #include "ace_log.h" #include "js_async_work.h" #include "js_dialog.h" diff --git a/frameworks/src/core/dialog/js_dialog.h b/frameworks/src/core/dialog/js_dialog.h index 84ec676..2e6a522 100755 --- a/frameworks/src/core/dialog/js_dialog.h +++ b/frameworks/src/core/dialog/js_dialog.h @@ -17,7 +17,7 @@ #define OHOS_ACELITE_JS_DIALOG_H #include "acelite_config.h" -#ifdef FEATURE_MODULE_DIALOG +#if (FEATURE_MODULE_DIALOG == 1) #include "jsi.h" #include "js_fwk_common.h" #include "non_copyable.h" diff --git a/frameworks/src/core/modules/app_module.cpp b/frameworks/src/core/modules/app_module.cpp index 0573743..410632e 100644 --- a/frameworks/src/core/modules/app_module.cpp +++ b/frameworks/src/core/modules/app_module.cpp @@ -16,7 +16,7 @@ #include "app_module.h" #include "ace_log.h" #include "js_app_context.h" -#ifdef FEATURE_SCREEN_ON_VISIBLE +#if (FEATURE_SCREEN_ON_VISIBLE == 1) #include "js_async_work.h" #include "product_adapter.h" #endif @@ -28,7 +28,7 @@ const char * const AppModule::KEY_APP_NAME = "appName"; const char * const AppModule::KEY_VERSION_NAME = "versionName"; const char * const AppModule::KEY_VERSION_CODE = "versionCode"; -#ifdef FEATURE_SCREEN_ON_VISIBLE +#if (FEATURE_SCREEN_ON_VISIBLE == 1) const char * const AppModule::SCREEN_ON_VISIBLE_KEY = "visible"; const char * const AppModule::SCREEN_ON_VISIBLE_DATA = "data"; const char * const AppModule::SCREEN_ON_VISIBLE_CODE = "code"; @@ -128,7 +128,7 @@ JSIValue AppModule::Terminate(const JSIValue thisVal, const JSIValue *args, uint return JSI::CreateUndefined(); } -#ifdef FEATURE_SCREEN_ON_VISIBLE +#if (FEATURE_SCREEN_ON_VISIBLE == 1) JSIValue AppModule::ScreenOnVisible(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum) { JSIValue undefValue = JSI::CreateUndefined(); diff --git a/frameworks/src/core/modules/app_module.h b/frameworks/src/core/modules/app_module.h index ea843f7..8eef43e 100644 --- a/frameworks/src/core/modules/app_module.h +++ b/frameworks/src/core/modules/app_module.h @@ -30,7 +30,7 @@ public: ~AppModule() = default; static JSIValue GetInfo(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum); static JSIValue Terminate(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum); -#ifdef FEATURE_SCREEN_ON_VISIBLE +#if (FEATURE_SCREEN_ON_VISIBLE == 1) static JSIValue ScreenOnVisible(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum); #endif @@ -42,7 +42,7 @@ private: static cJSON* ReadManifest(); -#ifdef FEATURE_SCREEN_ON_VISIBLE +#if (FEATURE_SCREEN_ON_VISIBLE == 1) static const char * const SCREEN_ON_VISIBLE_KEY; static const char * const SCREEN_ON_VISIBLE_DATA; static const char * const SCREEN_ON_VISIBLE_CODE; @@ -61,7 +61,7 @@ void InitAppModule(JSIValue exports) { JSI::SetModuleAPI(exports, "getInfo", AppModule::GetInfo); JSI::SetModuleAPI(exports, "terminate", AppModule::Terminate); -#ifdef FEATURE_SCREEN_ON_VISIBLE +#if (FEATURE_SCREEN_ON_VISIBLE == 1) JSI::SetModuleAPI(exports, "screenOnVisible", AppModule::ScreenOnVisible); #endif } diff --git a/frameworks/src/core/modules/dfx_module.cpp b/frameworks/src/core/modules/dfx_module.cpp index 751fa86..175dc71 100755 --- a/frameworks/src/core/modules/dfx_module.cpp +++ b/frameworks/src/core/modules/dfx_module.cpp @@ -18,7 +18,7 @@ #include "ui_dump_dom_tree.h" #ifdef FEATURE_ACELITE_MC_DFX_MODULE #include "ui_snapshot.h" -#elif defined(FEATURE_ACELITE_LITE_DFX_MODULE) +#elif (FEATURE_ACELITE_LITE_DFX_MODULE == 1) #ifdef __LITEOS_A__ #include "ability_env.h" #endif @@ -77,7 +77,7 @@ bool DfxModule::IsEventInjectorRegistered(EventDataType type) return true; } -#ifdef FEATURE_ACELITE_DFX_MODULE +#if (FEATURE_ACELITE_DFX_MODULE == 1) JSIValue DfxModule::Screenshot(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum) { #ifdef FEATURE_ACELITE_MC_DFX_MODULE @@ -88,7 +88,7 @@ JSIValue DfxModule::Screenshot(const JSIValue thisVal, const JSIValue *args, uin retVal = JSI::CreateBoolean(false); } return retVal; -#elif defined(FEATURE_ACELITE_LITE_DFX_MODULE) +#elif (FEATURE_ACELITE_LITE_DFX_MODULE == 1) JSIValue retVal = JSI::CreateBoolean(true); #ifdef __LITEOS_A__ const char * const savingPath = GetDataPath(); @@ -120,7 +120,7 @@ JSIValue DfxModule::DumpDomTree(const JSIValue thisVal, const JSIValue *args, ui } char *viewId = GetDomViewId(args); -#ifdef FEATURE_ACELITE_LITE_DFX_MODULE +#if (FEATURE_ACELITE_LITE_DFX_MODULE == 1) #ifdef __LITEOS_A__ const char * const savingPath = GetDataPath(); #else @@ -136,7 +136,7 @@ JSIValue DfxModule::DumpDomTree(const JSIValue thisVal, const JSIValue *args, ui retVal = JSI::CreateBoolean(true); } -#ifdef FEATURE_ACELITE_LITE_DFX_MODULE +#if (FEATURE_ACELITE_LITE_DFX_MODULE == 1) if (path != nullptr) { ace_free(path); } diff --git a/frameworks/src/core/modules/dfx_module.h b/frameworks/src/core/modules/dfx_module.h index 18aca8f..37233ba 100644 --- a/frameworks/src/core/modules/dfx_module.h +++ b/frameworks/src/core/modules/dfx_module.h @@ -26,7 +26,7 @@ namespace ACELite { class DfxModule final : public MemoryHeap { public: ACE_DISALLOW_COPY_AND_MOVE(DfxModule); -#ifdef FEATURE_ACELITE_DFX_MODULE +#if (FEATURE_ACELITE_DFX_MODULE == 1) static JSIValue Screenshot(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum); #endif static JSIValue InjectEvent(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum); @@ -49,7 +49,7 @@ private: void InitDfxModule(JSIValue exports) { -#ifdef FEATURE_ACELITE_DFX_MODULE +#if (FEATURE_ACELITE_DFX_MODULE == 1) JSI::SetModuleAPI(exports, "screenshotToFile", DfxModule::Screenshot); #endif // FEATURE_ACELITE_DFX_MODULE JSI::SetModuleAPI(exports, "injectEvent", DfxModule::InjectEvent); diff --git a/frameworks/src/core/modules/dialog_module.cpp b/frameworks/src/core/modules/dialog_module.cpp index 36a6f47..402534f 100755 --- a/frameworks/src/core/modules/dialog_module.cpp +++ b/frameworks/src/core/modules/dialog_module.cpp @@ -14,7 +14,7 @@ */ #include "acelite_config.h" -#ifdef FEATURE_MODULE_DIALOG +#if (FEATURE_MODULE_DIALOG == 1) #include "dialog_module.h" #include "ace_log.h" #include "js_profiler.h" diff --git a/frameworks/src/core/modules/dialog_module.h b/frameworks/src/core/modules/dialog_module.h index 5da154f..fa2cb9d 100755 --- a/frameworks/src/core/modules/dialog_module.h +++ b/frameworks/src/core/modules/dialog_module.h @@ -17,7 +17,7 @@ #define OHOS_ACELITE_DIALOG_MODULE_H #include "acelite_config.h" -#ifdef FEATURE_MODULE_DIALOG +#if (FEATURE_MODULE_DIALOG == 1) #include "jsi.h" #include "js_fwk_common.h" #include "non_copyable.h" diff --git a/frameworks/src/core/modules/presets/cjson_parser.cpp b/frameworks/src/core/modules/presets/cjson_parser.cpp index 3fc5ae6..f1952a6 100755 --- a/frameworks/src/core/modules/presets/cjson_parser.cpp +++ b/frameworks/src/core/modules/presets/cjson_parser.cpp @@ -14,7 +14,7 @@ */ #include "cjson_parser.h" -#ifdef FEATURE_LOCALIZATION_MODULE +#if (FEATURE_LOCALIZATION_MODULE == 1) #include "ace_log.h" #include "global.h" #include "js_fwk_common.h" diff --git a/frameworks/src/core/modules/presets/cjson_parser.h b/frameworks/src/core/modules/presets/cjson_parser.h index 0312804..ed7ac5a 100644 --- a/frameworks/src/core/modules/presets/cjson_parser.h +++ b/frameworks/src/core/modules/presets/cjson_parser.h @@ -16,7 +16,7 @@ #define OHOS_ACELITE_CJSON_PARSER_H #include "acelite_config.h" -#ifdef FEATURE_LOCALIZATION_MODULE +#if (FEATURE_LOCALIZATION_MODULE == 1) #include #include #ifdef __LITEOS_A__ diff --git a/frameworks/src/core/modules/presets/console_log_impl.cpp b/frameworks/src/core/modules/presets/console_log_impl.cpp index 286ed5f..fb3b47e 100644 --- a/frameworks/src/core/modules/presets/console_log_impl.cpp +++ b/frameworks/src/core/modules/presets/console_log_impl.cpp @@ -16,7 +16,7 @@ #include "console_log_impl.h" #if ENABLED(CONSOLE_LOG_OUTPUT) #include "js_app_environment.h" -#ifdef FEATURE_USER_MC_LOG_PRINTF +#if (FEATURE_USER_MC_LOG_PRINTF == 1) #include "product_adapter.h" #endif // FEATURE_USER_MC_LOG_PRINTF #ifdef FEATURE_ACELITE_HI_LOG_PRINTF @@ -143,7 +143,7 @@ void LogString(const LogLevel logLevel, const char * const str) if (str == nullptr) { return; } -#if defined(FEATURE_ACELITE_HI_LOG_PRINTF) || defined(FEATURE_USER_MC_LOG_PRINTF) +#if ((FEATURE_ACELITE_HI_LOG_PRINTF == 1) || (FEATURE_USER_MC_LOG_PRINTF == 1)) size_t strLength = strlen(str); for (size_t i = 0; i < strLength; i++) { LogChar(str[i], logLevel, false); @@ -169,7 +169,7 @@ void LogChar(char c, const LogLevel logLevel, bool endFlag) if (c == '\n' || !endFlag) { // this is the newline during the console log, need to append the loglevel prefix, // example: console.log("aa\nbb"); -#if !defined(FEATURE_ACELITE_HI_LOG_PRINTF) && !defined(FEATURE_USER_MC_LOG_PRINTF) +#if ((FEATURE_ACELITE_HI_LOG_PRINTF != 1) && (FEATURE_USER_MC_LOG_PRINTF != 1)) Output(logLevel, "\n", 1); // hilog will trace our the line separator directly #endif if (!endFlag) { @@ -205,7 +205,7 @@ static void OutputToHiLog(const LogLevel logLevel, const char * const str) break; } } -#elif defined(FEATURE_USER_MC_LOG_PRINTF) +#elif (FEATURE_USER_MC_LOG_PRINTF == 1) static void OutputToHiLog(const LogLevel logLevel, const char * const str) { switch (logLevel) { @@ -247,7 +247,7 @@ void Output(const LogLevel logLevel, const char * const str, const uint8_t lengt } (void)length; Debugger::GetInstance().Output(str); -#if defined(FEATURE_ACELITE_HI_LOG_PRINTF) || defined(FEATURE_USER_MC_LOG_PRINTF) +#if ((FEATURE_ACELITE_HI_LOG_PRINTF == 1) || (FEATURE_USER_MC_LOG_PRINTF == 1)) OutputToHiLog(logLevel, str); #endif #ifdef TDD_ASSERTIONS diff --git a/frameworks/src/core/modules/presets/date_time_format_module.cpp b/frameworks/src/core/modules/presets/date_time_format_module.cpp index c5fd981..5127671 100644 --- a/frameworks/src/core/modules/presets/date_time_format_module.cpp +++ b/frameworks/src/core/modules/presets/date_time_format_module.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ #include "date_time_format_module.h" -#ifdef FEATURE_DATE_FORMAT +#if (FEATURE_DATE_FORMAT == 1) #include #include "ace_log.h" #include "locale_util.h" diff --git a/frameworks/src/core/modules/presets/date_time_format_module.h b/frameworks/src/core/modules/presets/date_time_format_module.h index a9ea5d3..2232c8b 100644 --- a/frameworks/src/core/modules/presets/date_time_format_module.h +++ b/frameworks/src/core/modules/presets/date_time_format_module.h @@ -17,7 +17,7 @@ #define OHOS_ACELITE_DATE_TIME_FORMAT_MODULE_H #include "acelite_config.h" -#ifdef FEATURE_DATE_FORMAT +#if (FEATURE_DATE_FORMAT == 1) #include "js_fwk_common.h" #include "date_time_format.h" namespace OHOS { diff --git a/frameworks/src/core/modules/presets/feature_ability_module.cpp b/frameworks/src/core/modules/presets/feature_ability_module.cpp index 0f26104..677d357 100755 --- a/frameworks/src/core/modules/presets/feature_ability_module.cpp +++ b/frameworks/src/core/modules/presets/feature_ability_module.cpp @@ -14,7 +14,7 @@ */ #include "feature_ability_module.h" -#ifdef FEATURE_FEATURE_ABILITY_MODULE +#if (FEATURE_FEATURE_ABILITY_MODULE == 1) #include "ace_event_error_code.h" #include "ace_log.h" #include "fatal_handler.h" diff --git a/frameworks/src/core/modules/presets/feature_ability_module.h b/frameworks/src/core/modules/presets/feature_ability_module.h index dc6639d..be9c27b 100755 --- a/frameworks/src/core/modules/presets/feature_ability_module.h +++ b/frameworks/src/core/modules/presets/feature_ability_module.h @@ -19,7 +19,7 @@ #include "acelite_config.h" #include "non_copyable.h" -#ifdef FEATURE_FEATURE_ABILITY_MODULE +#if (FEATURE_FEATURE_ABILITY_MODULE == 1) #include "ability_kit.h" #include "presets/preset_module.h" namespace OHOS { @@ -201,14 +201,14 @@ public: ~FeaAbilityModule() = default; static void Load() { -#ifdef FEATURE_FEATURE_ABILITY_MODULE +#if (FEATURE_FEATURE_ABILITY_MODULE == 1) FeatureAbilityModule featureAbilityModule; featureAbilityModule.Init(); #endif } static void Release() { -#ifdef FEATURE_FEATURE_ABILITY_MODULE +#if (FEATURE_FEATURE_ABILITY_MODULE == 1) FeatureAbilityModule::Release(); #endif } diff --git a/frameworks/src/core/modules/presets/intl_module.cpp b/frameworks/src/core/modules/presets/intl_module.cpp index 40214f0..ee37360 100644 --- a/frameworks/src/core/modules/presets/intl_module.cpp +++ b/frameworks/src/core/modules/presets/intl_module.cpp @@ -14,7 +14,7 @@ */ #include "intl_module.h" -#ifdef FEATURE_INTL_MODULE +#if (FEATURE_INTL_MODULE == 1) #include "ace_log.h" #include "date_time_format_module.h" #include "global.h" @@ -27,10 +27,10 @@ void IntlModule::Init() { jerry_value_t globalObj = jerry_get_global_object(); jerry_value_t baseObj = jerry_create_object(); -#ifdef FEATURE_NUMBER_FORMAT +#if (FEATURE_NUMBER_FORMAT == 1) NumberFormatModule::Init(baseObj); #endif -#ifdef FEATURE_DATE_FORMAT +#if (FEATURE_DATE_FORMAT == 1) DateTimeFormatModule::Init(baseObj); #endif JerrySetNamedProperty(globalObj, "Intl", baseObj); diff --git a/frameworks/src/core/modules/presets/intl_module.h b/frameworks/src/core/modules/presets/intl_module.h index d0fae5a..b917e17 100644 --- a/frameworks/src/core/modules/presets/intl_module.h +++ b/frameworks/src/core/modules/presets/intl_module.h @@ -16,7 +16,7 @@ #ifndef OHOS_ACELITE_INTL_MODULE_H #define OHOS_ACELITE_INTL_MODULE_H #include "acelite_config.h" -#ifdef FEATURE_INTL_MODULE +#if (FEATURE_INTL_MODULE == 1) #include "js_fwk_common.h" #include "non_copyable.h" #include "locale_info.h" @@ -55,7 +55,7 @@ public: static void Load() { -#ifdef FEATURE_INTL_MODULE +#if (FEATURE_INTL_MODULE == 1) IntlModule *intlModule = IntlModule::GetInstance(); intlModule->Init(); #endif diff --git a/frameworks/src/core/modules/presets/jstest_module.cpp b/frameworks/src/core/modules/presets/jstest_module.cpp index af4aa3f..763351c 100644 --- a/frameworks/src/core/modules/presets/jstest_module.cpp +++ b/frameworks/src/core/modules/presets/jstest_module.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ #include "jstest_module.h" -#if (defined(JSFWK_TEST) && defined(OHOS_ACELITE_PRODUCT_WATCH)) +#if ((JSFWK_TEST == 1) && (OHOS_ACELITE_PRODUCT_WATCH == 1)) #include #include "ace_mem_base.h" #include "test_fwk.h" diff --git a/frameworks/src/core/modules/presets/jstest_module.h b/frameworks/src/core/modules/presets/jstest_module.h index 91b2531..6e0cbae 100644 --- a/frameworks/src/core/modules/presets/jstest_module.h +++ b/frameworks/src/core/modules/presets/jstest_module.h @@ -17,7 +17,7 @@ #include "acelite_config.h" #include "non_copyable.h" -#if (defined(JSFWK_TEST) && defined(OHOS_ACELITE_PRODUCT_WATCH)) +#if ((JSFWK_TEST == 1) && (OHOS_ACELITE_PRODUCT_WATCH == 1)) #include "presets/preset_module.h" namespace OHOS { namespace ACELite { @@ -57,7 +57,7 @@ public: ~JsTestModule() = default; static void Load() { -#if (defined(JSFWK_TEST) && defined(OHOS_ACELITE_PRODUCT_WATCH)) +#if ((JSFWK_TEST == 1) && (OHOS_ACELITE_PRODUCT_WATCH == 1)) JSTestModule jsTestModule; jsTestModule.Init(); #endif diff --git a/frameworks/src/core/modules/presets/localization_module.cpp b/frameworks/src/core/modules/presets/localization_module.cpp index 269456c..0c81e4d 100644 --- a/frameworks/src/core/modules/presets/localization_module.cpp +++ b/frameworks/src/core/modules/presets/localization_module.cpp @@ -15,7 +15,7 @@ #include "localization_module.h" #include "ace_event_error_code.h" -#ifdef FEATURE_LOCALIZATION_MODULE +#if (FEATURE_LOCALIZATION_MODULE == 1) #include "ace_log.h" #include "js_fwk_common.h" #include diff --git a/frameworks/src/core/modules/presets/localization_module.h b/frameworks/src/core/modules/presets/localization_module.h index 219534f..1b335f0 100644 --- a/frameworks/src/core/modules/presets/localization_module.h +++ b/frameworks/src/core/modules/presets/localization_module.h @@ -17,7 +17,7 @@ #include "acelite_config.h" #include "non_copyable.h" -#ifdef FEATURE_LOCALIZATION_MODULE +#if (FEATURE_LOCALIZATION_MODULE == 1) #include "cjson_parser.h" #include "presets/preset_module.h" namespace OHOS { @@ -85,14 +85,14 @@ public: ~LocalModule() = default; static void Load() { -#ifdef FEATURE_LOCALIZATION_MODULE +#if (FEATURE_LOCALIZATION_MODULE == 1) LocalizationModule *localizationModule = LocalizationModule::GetInstance(); localizationModule->Init(); #endif } static void Clear() { -#ifdef FEATURE_LOCALIZATION_MODULE +#if (FEATURE_LOCALIZATION_MODULE == 1) LocalizationModule *localization = LocalizationModule::GetInstance(); localization->Clear(); #endif diff --git a/frameworks/src/core/modules/presets/number_format_module.cpp b/frameworks/src/core/modules/presets/number_format_module.cpp index 8ff8a8f..62744e6 100755 --- a/frameworks/src/core/modules/presets/number_format_module.cpp +++ b/frameworks/src/core/modules/presets/number_format_module.cpp @@ -15,7 +15,7 @@ #include "number_format_module.h" #include "ace_log.h" -#ifdef FEATURE_NUMBER_FORMAT +#if (FEATURE_NUMBER_FORMAT == 1) #include "locale_util.h" #include "string.h" #include "key_parser.h" diff --git a/frameworks/src/core/modules/presets/number_format_module.h b/frameworks/src/core/modules/presets/number_format_module.h index d0eab33..82b8a51 100644 --- a/frameworks/src/core/modules/presets/number_format_module.h +++ b/frameworks/src/core/modules/presets/number_format_module.h @@ -17,7 +17,7 @@ #define OHOS_ACELITE_NUMBER_FORMAT_MODEL_H #include "acelite_config.h" -#ifdef FEATURE_NUMBER_FORMAT +#if (FEATURE_NUMBER_FORMAT == 1) #include "gfx_utils/list.h" #include "js_fwk_common.h" #include "number_format.h" diff --git a/frameworks/src/core/modules/presets/test/unittest/BUILD.gn b/frameworks/src/core/modules/presets/test/unittest/BUILD.gn index 4d423e4..f6fbfee 100755 --- a/frameworks/src/core/modules/presets/test/unittest/BUILD.gn +++ b/frameworks/src/core/modules/presets/test/unittest/BUILD.gn @@ -56,8 +56,8 @@ unittest("js_frameworks_test_localization") { output_dir = test_output_root configs = [ "$ace_lite_root/test:test_common_config" ] sources = [ - "$ace_lite_root/test/moduletest/common/basic_tdd_test.cpp", - "common/localization_module_tdd_test.cpp" - ] + "$ace_lite_root/test/moduletest/common/basic_tdd_test.cpp", + "common/localization_module_tdd_test.cpp", + ] deps = ace_test_deps -} \ No newline at end of file +} diff --git a/frameworks/src/core/modules/presets/test/unittest/common/date_time_module_tdd_test.cpp b/frameworks/src/core/modules/presets/test/unittest/common/date_time_module_tdd_test.cpp index b269e13..3d7f45d 100755 --- a/frameworks/src/core/modules/presets/test/unittest/common/date_time_module_tdd_test.cpp +++ b/frameworks/src/core/modules/presets/test/unittest/common/date_time_module_tdd_test.cpp @@ -14,7 +14,7 @@ */ #include "date_time_module_tdd_test.h" -#ifdef FEATURE_DATE_FORMAT +#if (FEATURE_DATE_FORMAT == 1) #include "global.h" #include "js_app_context.h" #include "js_app_environment.h" diff --git a/frameworks/src/core/modules/presets/test/unittest/common/date_time_module_tdd_test.h b/frameworks/src/core/modules/presets/test/unittest/common/date_time_module_tdd_test.h index 440aa08..1f08b77 100755 --- a/frameworks/src/core/modules/presets/test/unittest/common/date_time_module_tdd_test.h +++ b/frameworks/src/core/modules/presets/test/unittest/common/date_time_module_tdd_test.h @@ -22,7 +22,7 @@ #endif #include "acelite_config.h" -#ifdef FEATURE_DATE_FORMAT +#if (FEATURE_DATE_FORMAT == 1) #include "test_common.h" #include "js_fwk_common.h" namespace OHOS { diff --git a/frameworks/src/core/modules/presets/test/unittest/common/localization_module_tdd_test.cpp b/frameworks/src/core/modules/presets/test/unittest/common/localization_module_tdd_test.cpp index 85f91dc..faa2271 100644 --- a/frameworks/src/core/modules/presets/test/unittest/common/localization_module_tdd_test.cpp +++ b/frameworks/src/core/modules/presets/test/unittest/common/localization_module_tdd_test.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ #include "localization_module_tdd_test.h" -#ifdef FEATURE_LOCALIZATION_MODULE +#if (FEATURE_LOCALIZATION_MODULE == 1) #include "ace_log.h" #include "global.h" #include "js_app_context.h" @@ -23,7 +23,7 @@ namespace OHOS { namespace ACELite { void LocalizationModuleTddTest::SetUp() { -#ifdef TARGET_SIMULATOR +#if (TARGET_SIMULATOR == 1) constexpr char testAppPath[] = "..\\moduletest\\unittest"; #elif defined(__linux__) constexpr char testAppPath[] = "/storage/data"; diff --git a/frameworks/src/core/modules/presets/test/unittest/common/localization_module_tdd_test.h b/frameworks/src/core/modules/presets/test/unittest/common/localization_module_tdd_test.h index 97662c8..826fa80 100644 --- a/frameworks/src/core/modules/presets/test/unittest/common/localization_module_tdd_test.h +++ b/frameworks/src/core/modules/presets/test/unittest/common/localization_module_tdd_test.h @@ -15,7 +15,7 @@ #ifndef LOCALIZATION_MODULE_TEST_H #define LOCALIZATION_MODULE_TEST_H #include "acelite_config.h" -#ifdef FEATURE_LOCALIZATION_MODULE +#if (FEATURE_LOCALIZATION_MODULE == 1) #include "basic_tdd_test.h" #include "test_common.h" #include "js_fwk_common.h" diff --git a/frameworks/src/core/modules/presets/test/unittest/common/number_format_module_tdd_test.cpp b/frameworks/src/core/modules/presets/test/unittest/common/number_format_module_tdd_test.cpp index ecd0893..ced8dca 100755 --- a/frameworks/src/core/modules/presets/test/unittest/common/number_format_module_tdd_test.cpp +++ b/frameworks/src/core/modules/presets/test/unittest/common/number_format_module_tdd_test.cpp @@ -14,7 +14,7 @@ */ #include "number_format_module_tdd_test.h" -#ifdef FEATURE_NUMBER_FORMAT +#if (FEATURE_NUMBER_FORMAT == 1) #include "global.h" #include "js_app_context.h" #include "js_app_environment.h" diff --git a/frameworks/src/core/modules/presets/test/unittest/common/number_format_module_tdd_test.h b/frameworks/src/core/modules/presets/test/unittest/common/number_format_module_tdd_test.h index 8e25f58..86cfc07 100755 --- a/frameworks/src/core/modules/presets/test/unittest/common/number_format_module_tdd_test.h +++ b/frameworks/src/core/modules/presets/test/unittest/common/number_format_module_tdd_test.h @@ -22,7 +22,7 @@ #endif #include "acelite_config.h" -#ifdef FEATURE_NUMBER_FORMAT +#if (FEATURE_NUMBER_FORMAT == 1) #include "test_common.h" #include "js_fwk_common.h" namespace OHOS { diff --git a/frameworks/src/core/modules/presets/timer_module.cpp b/frameworks/src/core/modules/presets/timer_module.cpp index 7a73102..0be0c78 100755 --- a/frameworks/src/core/modules/presets/timer_module.cpp +++ b/frameworks/src/core/modules/presets/timer_module.cpp @@ -14,7 +14,7 @@ */ #include "timer_module.h" -#ifdef FEATURE_TIMER_MODULE +#if (FEATURE_TIMER_MODULE == 1) #include #include #include "ace_log.h" diff --git a/frameworks/src/core/modules/presets/timer_module.h b/frameworks/src/core/modules/presets/timer_module.h index 2ce69f5..a715fa4 100644 --- a/frameworks/src/core/modules/presets/timer_module.h +++ b/frameworks/src/core/modules/presets/timer_module.h @@ -17,7 +17,7 @@ #include "acelite_config.h" #include "non_copyable.h" -#ifdef FEATURE_TIMER_MODULE +#if (FEATURE_TIMER_MODULE == 1) #include "ace_log.h" #include "js_timer_list.h" #include "presets/preset_module.h" @@ -149,14 +149,14 @@ public: ~TimersModule() = default; static void Load() { -#ifdef FEATURE_TIMER_MODULE +#if (FEATURE_TIMER_MODULE == 1) TimerModule *timerModule = const_cast(TimerModule::GetInstance()); timerModule->Init(); #endif } static void Clear() { -#ifdef FEATURE_TIMER_MODULE +#if (FEATURE_TIMER_MODULE == 1) TimerModule *timerModule = const_cast(TimerModule::GetInstance()); timerModule->Clear(); #endif diff --git a/frameworks/src/core/modules/sample_module.cpp b/frameworks/src/core/modules/sample_module.cpp index b4b4b23..f525403 100644 --- a/frameworks/src/core/modules/sample_module.cpp +++ b/frameworks/src/core/modules/sample_module.cpp @@ -14,8 +14,8 @@ */ #include "sample_module.h" -#ifdef ENABLE_MODULE_REQUIRE_TEST -#ifndef TARGET_SIMULATOR +#if (ENABLE_MODULE_REQUIRE_TEST == 1) +#if (TARGET_SIMULATOR != 1) #include "js_async_work.h" #endif #include "ace_log.h" @@ -60,7 +60,7 @@ JSIValue SampleModule::TestStandardCallback(const JSIValue thisVal, const JSIVal return undefValue; } -#ifndef TARGET_SIMULATOR +#if (TARGET_SIMULATOR != 1) struct AsyncParams : public MemoryHeap { AsyncParams() : result(nullptr), callback(nullptr), context(nullptr) {} @@ -102,7 +102,7 @@ JSIValue SampleModule::TestCallbackWithArgs(const JSIValue thisVal, const JSIVal JSI::SetStringProperty(result, "param2", str); JSI::ReleaseString(str); } -#ifndef TARGET_SIMULATOR +#if (TARGET_SIMULATOR != 1) AsyncParams *params = new AsyncParams(); if (params == nullptr) { JSI::ReleaseValueList(result, callback); diff --git a/frameworks/src/core/modules/sample_module.h b/frameworks/src/core/modules/sample_module.h index 23dcc02..e949fd3 100644 --- a/frameworks/src/core/modules/sample_module.h +++ b/frameworks/src/core/modules/sample_module.h @@ -17,7 +17,7 @@ #define OHOS_ACELITE_SAMPLE_MODULE_H #include "acelite_config.h" -#ifdef ENABLE_MODULE_REQUIRE_TEST +#if (ENABLE_MODULE_REQUIRE_TEST == 1) #include "jsi.h" #include "non_copyable.h" diff --git a/frameworks/src/core/resource/video_muted_image_res.cpp b/frameworks/src/core/resource/video_muted_image_res.cpp index 072bddf..69b9f6b 100644 --- a/frameworks/src/core/resource/video_muted_image_res.cpp +++ b/frameworks/src/core/resource/video_muted_image_res.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) #include "video_panel_image_res.h" #include "gfx_utils/graphic_types.h" diff --git a/frameworks/src/core/resource/video_play_image_res.cpp b/frameworks/src/core/resource/video_play_image_res.cpp index 2d65d6d..cf59212 100644 --- a/frameworks/src/core/resource/video_play_image_res.cpp +++ b/frameworks/src/core/resource/video_play_image_res.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ #include "acelite_config.h" -#ifdef FEATURE_COMPONENT_VIDEO +#if (FEATURE_COMPONENT_VIDEO == 1) #include "video_panel_image_res.h" #include "gfx_utils/graphic_types.h" diff --git a/frameworks/src/core/router/js_router.cpp b/frameworks/src/core/router/js_router.cpp index cadef8d..40c45a2 100755 --- a/frameworks/src/core/router/js_router.cpp +++ b/frameworks/src/core/router/js_router.cpp @@ -16,7 +16,7 @@ #include "js_router.h" #include "ace_log.h" -#if (defined(OHOS_ACELITE_PRODUCT_WATCH) || (defined(FEATURE_CUSTOM_ENTRY_PAGE))) +#if ((OHOS_ACELITE_PRODUCT_WATCH == 1) || (FEATURE_CUSTOM_ENTRY_PAGE == 1)) #include "dft_impl.h" #endif #include "async_task_manager.h" @@ -98,7 +98,7 @@ void Router::ReplaceSync() // above call will move sm into ready state, than let the page show currentSm_->ChangeState(SHOW_STATE); } -#if (defined(OHOS_ACELITE_PRODUCT_WATCH) || (defined(FEATURE_CUSTOM_ENTRY_PAGE))) +#if ((OHOS_ACELITE_PRODUCT_WATCH == 1) || (FEATURE_CUSTOM_ENTRY_PAGE == 1)) DftImpl::GetInstance()->CallbackPageReplaced(currentSm_->GetCurrentState()); #endif STOP_TRACING(); diff --git a/frameworks/src/core/stylemgr/app_style_manager.cpp b/frameworks/src/core/stylemgr/app_style_manager.cpp index 273d9e5..0dd9834 100755 --- a/frameworks/src/core/stylemgr/app_style_manager.cpp +++ b/frameworks/src/core/stylemgr/app_style_manager.cpp @@ -187,7 +187,7 @@ void AppStyleManager::HandleDynamicStyle(const jerry_value_t options, Component if (curr.IsFreeze()) { expressionValue = JSFunction::Call(propValue, curr.GetViewModel(), nullptr, 0); } else { -#ifdef FEATURE_LAZY_LOADING_MODULE +#if (FEATURE_LAZY_LOADING_MODULE == 1) expressionValue = CallJSFunction(propValue, curr.GetNativeElement(), nullptr, 0); JsAppContext *context = JsAppContext::GetInstance(); LazyLoadManager *lazyLoadManager = const_cast(context->GetLazyLoadManager()); diff --git a/frameworks/targets/BUILD.gn b/frameworks/targets/BUILD.gn new file mode 100644 index 0000000..0907007 --- /dev/null +++ b/frameworks/targets/BUILD.gn @@ -0,0 +1,38 @@ +#Copyright (c) 2020-2021 Huawei Device Co., Ltd. +#Licensed under the Apache License, Version 2.0 (the "License"); +#you may not use this file except in compliance with the License. +#You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +#Unless required by applicable law or agreed to in writing, software +#distributed under the License is distributed on an "AS IS" BASIS, +#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +#See the License for the specific language governing permissions and +#limitations under the License. + +import("//build/lite/config/component/lite_component.gni") +import("//foundation/ace/ace_engine_lite/ace_lite.gni") + +declare_args() { + enable_ohos_ace_engine_lite_product_config = false +} + +config("ace_lite_target_config") { + if (enable_ohos_ace_engine_lite_product_config) { + defines = [ "ENABLE_OHOS_ACELITE_PRODUCT_CONFIG=1" ] + } + include_dirs = [ "$product_path/ace_lite_config" ] + if (ohos_kernel_type == "liteos_m") { + include_dirs += [ "liteos_m" ] + } else if (ohos_kernel_type == "liteos_a") { + include_dirs += [ "liteos_a" ] + } else if (ohos_kernel_type == "linux") { + include_dirs += [ "linux" ] + } +} + +group("targets") { + public_configs = [ ":ace_lite_target_config" ] + public_configs += [ "//foundation/graphic/utils:graphic_utils_public_config" ] +} diff --git a/frameworks/targets/default/acelite_config.h b/frameworks/targets/default/acelite_config.h index e03494c..8792eef 100644 --- a/frameworks/targets/default/acelite_config.h +++ b/frameworks/targets/default/acelite_config.h @@ -29,7 +29,7 @@ #ifdef FEATURE_TEST_IMPLEMENTATION #error "must keep the global configuration unique" #else -#define FEATURE_TEST_IMPLEMENTATION +#define FEATURE_TEST_IMPLEMENTATION 1 #endif /** @@ -38,7 +38,7 @@ #ifdef FEATURE_ACELITE_HI_LOG_PRINTF #error "must keep the global configuration unique" #else -#define FEATURE_ACELITE_HI_LOG_PRINTF +#define FEATURE_ACELITE_HI_LOG_PRINTF 1 #endif /** @@ -47,7 +47,7 @@ #ifdef FEATURE_ACELITE_MEMORY_POOL #error "must keep the global configuration unique" #else -#define FEATURE_ACELITE_MEMORY_POOL +#define FEATURE_ACELITE_MEMORY_POOL 1 #endif ////////////////////////////////////////////////////////////////////////////////////////////////// @@ -62,7 +62,7 @@ #ifdef FEATURE_COMPONENT_ANALOG_CLOCK #error "must keep the global configuration unique" #else -#define FEATURE_COMPONENT_ANALOG_CLOCK +#define FEATURE_COMPONENT_ANALOG_CLOCK 1 #endif /** @@ -71,7 +71,7 @@ #ifdef FEATURE_COMPONENT_TABS #error "must keep the global configuration unique" #else -#define FEATURE_COMPONENT_TABS +#define FEATURE_COMPONENT_TABS 1 #endif /** diff --git a/frameworks/targets/linux/acelite_config.h b/frameworks/targets/linux/acelite_config.h index 8c4e99a..02d20a8 100755 --- a/frameworks/targets/linux/acelite_config.h +++ b/frameworks/targets/linux/acelite_config.h @@ -21,7 +21,6 @@ * hi3516_linux config for hmf * ================================================================================================ */ -#define OHOS_ACELITE_LINUX // NOTE: DO NOT use this macro directly /** * Compile all test entry for hmf @@ -29,7 +28,7 @@ #ifdef FEATURE_TEST_IMPLEMENTATION #error "must keep the global configuration unique" #else -#define FEATURE_TEST_IMPLEMENTATION +#define FEATURE_TEST_IMPLEMENTATION 1 #endif /** @@ -38,7 +37,7 @@ #ifdef FEATURE_ACELITE_HI_LOG_PRINTF #error "must keep the global configuration unique" #else -#define FEATURE_ACELITE_HI_LOG_PRINTF +#define FEATURE_ACELITE_HI_LOG_PRINTF 1 #endif /** @@ -47,7 +46,7 @@ #ifdef FEATURE_ROOTVIEW_CUSTOM_BACKGROUND_COLOR #error "must keep the global configuration unique" #else -#define FEATURE_ROOTVIEW_CUSTOM_BACKGROUND_COLOR +#define FEATURE_ROOTVIEW_CUSTOM_BACKGROUND_COLOR 1 #endif /** @@ -56,7 +55,7 @@ #ifdef FEATURE_ACELITE_SYSTEM_CAPABILITY #error "must keep the system capability unique" #else -#define FEATURE_ACELITE_SYSTEM_CAPABILITY +#define FEATURE_ACELITE_SYSTEM_CAPABILITY 1 #endif /** @@ -65,68 +64,68 @@ #ifdef FEATURE_ACELITE_JS_PROFILER #error "must keep the global configuration unique" #else -#define FEATURE_ACELITE_JS_PROFILER +#define FEATURE_ACELITE_JS_PROFILER 1 #endif /** * support audio API for JS */ -#define FEATURE_MODULE_AUDIO +#define FEATURE_MODULE_AUDIO 1 /** * switch for cipher module */ -#define ENABLE_MODULE_CIPHER +#define ENABLE_MODULE_CIPHER 1 /** * support storage and file API for JS */ -#define FEATURE_MODULE_STORAGE +#define FEATURE_MODULE_STORAGE 1 /** * support device API for JS */ -#define FEATURE_MODULE_DEVICE +#define FEATURE_MODULE_DEVICE 1 /** * timer module */ -#define FEATURE_TIMER_MODULE +#define FEATURE_TIMER_MODULE 1 /** * support lite ace dfx module */ -#define FEATURE_ACELITE_DFX_MODULE +#define FEATURE_ACELITE_DFX_MODULE 1 -#define FEATURE_ACELITE_LITE_DFX_MODULE +#define FEATURE_ACELITE_LITE_DFX_MODULE 1 -#define FEATURE_API_VERSION +#define FEATURE_API_VERSION 1 /** * enable Canvas component Feature API on ipcamera real devices */ -#define FEATURE_COMPONENT_CANVAS +#define FEATURE_COMPONENT_CANVAS 1 -#define FEATURE_LOCALIZATION_MODULE +#define FEATURE_LOCALIZATION_MODULE 1 #ifdef FEATURE_COMPONENT_CAMERA #error "must keep the global configuration unique" #else -#define FEATURE_COMPONENT_CAMERA +#define FEATURE_COMPONENT_CAMERA 1 #endif #ifdef FEATURE_COMPONENT_VIDEO #error "must keep the global configuration unique" #else -#define FEATURE_COMPONENT_VIDEO +#define FEATURE_COMPONENT_VIDEO 1 #endif -#define FEATURE_UPDATE_VIDEO_PROGRESS_ASYNC +#define FEATURE_UPDATE_VIDEO_PROGRESS_ASYNC 1 #ifdef FEATURE_MODULE_DIALOG #error "must keep the global configuration unique" #else -#define FEATURE_MODULE_DIALOG +#define FEATURE_MODULE_DIALOG 1 #endif #define DEFAULT_PROFILER_MSG_PATH "/user/data/" diff --git a/frameworks/targets/liteos_a/acelite_config.h b/frameworks/targets/liteos_a/acelite_config.h index 32b52e4..b188a5d 100755 --- a/frameworks/targets/liteos_a/acelite_config.h +++ b/frameworks/targets/liteos_a/acelite_config.h @@ -29,7 +29,7 @@ #ifdef FEATURE_TEST_IMPLEMENTATION #error "must keep the global configuration unique" #else -#define FEATURE_TEST_IMPLEMENTATION +#define FEATURE_TEST_IMPLEMENTATION 1 #endif /** @@ -38,7 +38,7 @@ #ifdef FEATURE_ACELITE_HI_LOG_PRINTF #error "must keep the global configuration unique" #else -#define FEATURE_ACELITE_HI_LOG_PRINTF +#define FEATURE_ACELITE_HI_LOG_PRINTF 1 #endif /** @@ -47,7 +47,7 @@ #ifdef FEATURE_ROOTVIEW_CUSTOM_BACKGROUND_COLOR #error "must keep the global configuration unique" #else -#define FEATURE_ROOTVIEW_CUSTOM_BACKGROUND_COLOR +#define FEATURE_ROOTVIEW_CUSTOM_BACKGROUND_COLOR 1 #endif /** @@ -56,7 +56,7 @@ #ifdef FEATURE_ACELITE_SYSTEM_CAPABILITY #error "must keep the system capability unique" #else -#define FEATURE_ACELITE_SYSTEM_CAPABILITY +#define FEATURE_ACELITE_SYSTEM_CAPABILITY 1 #endif /** @@ -65,94 +65,94 @@ #ifdef FEATURE_ACELITE_JS_PROFILER #error "must keep the global configuration unique" #else -#define FEATURE_ACELITE_JS_PROFILER +#define FEATURE_ACELITE_JS_PROFILER 1 #endif /** * support audio API for JS */ -#define FEATURE_MODULE_AUDIO +#define FEATURE_MODULE_AUDIO 1 /** * switch for cipher module */ -#define ENABLE_MODULE_CIPHER +#define ENABLE_MODULE_CIPHER 1 /** * support storage and file API for JS */ -#define FEATURE_MODULE_STORAGE +#define FEATURE_MODULE_STORAGE 1 /** * support battery API for JS */ -#define FEATURE_MODULE_BATTERY +#define FEATURE_MODULE_BATTERY 1 /** * support device API for JS */ -#define FEATURE_MODULE_DEVICE +#define FEATURE_MODULE_DEVICE 1 /** * timer module */ -#define FEATURE_TIMER_MODULE +#define FEATURE_TIMER_MODULE 1 /** * date time module */ -#define FEATURE_DATE_FORMAT +#define FEATURE_DATE_FORMAT 1 -#define FEATURE_API_VERSION +#define FEATURE_API_VERSION 1 /** * support lite ace dfx module */ -#define FEATURE_ACELITE_DFX_MODULE +#define FEATURE_ACELITE_DFX_MODULE 1 -#define FEATURE_ACELITE_LITE_DFX_MODULE +#define FEATURE_ACELITE_LITE_DFX_MODULE 1 /** * enable Canvas component Feature API on ipcamera real devices */ -#define FEATURE_COMPONENT_CANVAS +#define FEATURE_COMPONENT_CANVAS 1 -#define FEATURE_LOCALIZATION_MODULE +#define FEATURE_LOCALIZATION_MODULE 1 #ifdef FEATURE_COMPONENT_CAMERA #error "must keep the global configuration unique" #else -#define FEATURE_COMPONENT_CAMERA +#define FEATURE_COMPONENT_CAMERA 1 #endif -#ifdef FEATURE_COMPONENT_QRCODE +#if (FEATURE_COMPONENT_QRCODE == 1) #error "must keep the global configuration unique" #else -#define FEATURE_COMPONENT_QRCODE +#define FEATURE_COMPONENT_QRCODE 1 #endif #ifdef FEATURE_COMPONENT_VIDEO #error "must keep the global configuration unique" #else -#define FEATURE_COMPONENT_VIDEO +#define FEATURE_COMPONENT_VIDEO 1 #endif #ifdef FEATURE_MODULE_DIALOG #error "must keep the global configuration unique" #else -#define FEATURE_MODULE_DIALOG +#define FEATURE_MODULE_DIALOG 1 #endif /** * support intl module */ -#define FEATURE_INTL_MODULE +#define FEATURE_INTL_MODULE 1 /** * supoort number format module */ -#define FEATURE_NUMBER_FORMAT +#define FEATURE_NUMBER_FORMAT 1 -#define FEATURE_UPDATE_VIDEO_PROGRESS_ASYNC +#define FEATURE_UPDATE_VIDEO_PROGRESS_ASYNC 1 #define DEFAULT_PROFILER_MSG_PATH "/storage/user/data/" @@ -160,6 +160,6 @@ #define RUNTIME_MODE_FILE_PATH "/storage/user/data/js_snapshot_enable" -#define FEATURE_SUPPORT_HTTP +#define FEATURE_SUPPORT_HTTP 1 #endif // OHOS_ACELITE_CONFIG_H diff --git a/frameworks/targets/liteos_m/acelite_config.h b/frameworks/targets/liteos_m/acelite_config.h index ad16e44..b33b55d 100755 --- a/frameworks/targets/liteos_m/acelite_config.h +++ b/frameworks/targets/liteos_m/acelite_config.h @@ -19,6 +19,9 @@ // some features depend on the low layer configuration #include "graphic_config.h" +#if (ENABLE_OHOS_ACELITE_PRODUCT_CONFIG == 1) +#include "product_acelite_config.h" +#endif /** * ================================================================================================ * config for wearable @@ -27,77 +30,109 @@ /** * the flag indicating watch product */ -#define OHOS_ACELITE_PRODUCT_WATCH +#ifndef OHOS_ACELITE_PRODUCT_WATCH +#define OHOS_ACELITE_PRODUCT_WATCH 1 +#endif // delete this after jerry porting is ready -#define JERRY_PORTING_DEPENDENCY +#ifndef JERRY_PORTING_DEPENDENCY +#define JERRY_PORTING_DEPENDENCY 1 +#endif /** * enable Canvas component Feature API on ipcamera real devices */ -#define FEATURE_COMPONENT_CANVAS +#ifndef FEATURE_COMPONENT_CANVAS +#define FEATURE_COMPONENT_CANVAS 1 +#endif /** * enable QRcode component */ -#define FEATURE_COMPONENT_QRCODE +#ifndef FEATURE_COMPONENT_QRCODE +#define FEATURE_COMPONENT_QRCODE 1 +#endif /** * support terminate() API from JS */ -#define FEATURE_TERMINATE_ABILITY +#ifndef FEATURE_TERMINATE_ABILITY +#define FEATURE_TERMINATE_ABILITY 1 +#endif /** * support screenOnVisible() API from JS */ -#define FEATURE_SCREEN_ON_VISIBLE +#ifndef FEATURE_SCREEN_ON_VISIBLE +#define FEATURE_SCREEN_ON_VISIBLE 1 +#endif -#ifdef ACELITE_DEPENDENCY_IS_READY /** * enable FeatureAbility API */ -#define FEATURE_FEATURE_ABILITY_MODULE -#endif // ACELITE_DEPENDENCY_IS_READY +#ifndef FEATURE_FEATURE_ABILITY_MODULE +#define FEATURE_FEATURE_ABILITY_MODULE 1 +#endif /** * enable timer JS API */ -#define FEATURE_TIMER_MODULE +#ifndef FEATURE_TIMER_MODULE +#define FEATURE_TIMER_MODULE 1 +#endif /** * enable localization feature */ -#define FEATURE_LOCALIZATION_MODULE +#ifndef FEATURE_LOCALIZATION_MODULE +#define FEATURE_LOCALIZATION_MODULE 1 +#endif + +#ifndef FEATURE_ACELITE_HI_LOG_PRINTF +#define FEATURE_ACELITE_HI_LOG_PRINTF 1 +#endif /** * support mc ace log module trace */ -#define FEATURE_ACELITE_MC_LOG_PRINTF +#ifndef FEATURE_ACELITE_MC_LOG_PRINTF +#define FEATURE_ACELITE_MC_LOG_PRINTF 1 +#endif /** * support mc ace event and error code print */ -#define FEATURE_ACELITE_MC_EVENT_ERROR_CODE_PRINT +#ifndef FEATURE_ACELITE_MC_EVENT_ERROR_CODE_PRINT +#define FEATURE_ACELITE_MC_EVENT_ERROR_CODE_PRINT 1 +#endif /** * support mc console log */ -#define FEATURE_USER_MC_LOG_PRINTF +#ifndef FEATURE_USER_MC_LOG_PRINTF +#define FEATURE_USER_MC_LOG_PRINTF 1 +#endif /** * support config for product JS modules */ -#define FEATURE_PRODUCT_MODULE +#ifndef FEATURE_PRODUCT_MODULE +#define FEATURE_PRODUCT_MODULE 1 +#endif /** * support config for private JS modules */ -#define FEATURE_PRIVATE_MODULE +#ifndef FEATURE_PRIVATE_MODULE +#define FEATURE_PRIVATE_MODULE 1 +#endif /** * support using memory pool from product side */ -#define FEATURE_ACELITE_PRODUCT_MEMORY_POOL +#ifndef FEATURE_ACELITE_PRODUCT_MEMORY_POOL +#define FEATURE_ACELITE_PRODUCT_MEMORY_POOL 1 +#endif /** * define the max length of user's console log @@ -106,65 +141,126 @@ #define CONSOLE_LOG_LINE_MAX_LENGTH (96) #endif -#ifdef ACELITE_DEPENDENCY_IS_READY +#ifndef ACELITE_DEPENDENCY_IS_READY +#define ACELITE_DEPENDENCY_IS_READY 1 +#endif /** * support mc ace dfx module */ -#define FEATURE_ACELITE_DFX_MODULE +#ifndef FEATURE_ACELITE_DFX_MODULE +#define FEATURE_ACELITE_DFX_MODULE 1 +#endif -#define FEATURE_ACELITE_LITE_DFX_MODULE +#ifndef FEATURE_ACELITE_LITE_DFX_MODULE +#define FEATURE_ACELITE_LITE_DFX_MODULE 1 #endif /** * support mc lazy loading */ -#define FEATURE_LAZY_LOADING_MODULE +#ifndef FEATURE_LAZY_LOADING_MODULE +#define FEATURE_LAZY_LOADING_MODULE 1 +#endif /** * support fatal error handling on device which not support process */ #ifndef FEATURE_FATAL_ERROR_HANDLING -#define FEATURE_FATAL_ERROR_HANDLING +#define FEATURE_FATAL_ERROR_HANDLING 1 #endif /** * support intl module */ -#define FEATURE_INTL_MODULE +#ifndef FEATURE_INTL_MODULE +#define FEATURE_INTL_MODULE 1 +#endif /** * supoort number format module */ -#define FEATURE_NUMBER_FORMAT +#ifndef FEATURE_NUMBER_FORMAT +#define FEATURE_NUMBER_FORMAT 1 +#endif /** * date time module */ -#define FEATURE_DATE_FORMAT +#ifndef FEATURE_DATE_FORMAT +#define FEATURE_DATE_FORMAT 1 +#endif -#define FEATURE_API_VERSION +#ifndef FEATURE_API_VERSION +#define FEATURE_API_VERSION 1 +#endif -#define JS_ENGINE_STATIC_MULTI_CONTEXTS_ENABLED +#ifndef JS_ENGINE_STATIC_MULTI_CONTEXTS_ENABLED +#define JS_ENGINE_STATIC_MULTI_CONTEXTS_ENABLED 1 +#endif + +#ifndef FEATURE_MODULE_STORAGE +#define FEATURE_MODULE_STORAGE 0 +#endif + +#ifndef FEATURE_MODULE_AUDIO +#define FEATURE_MODULE_AUDIO 0 +#endif + +#ifndef FEATURE_MODULE_DEVICE +#define FEATURE_MODULE_DEVICE 0 +#endif + +#ifndef FEATURE_SUPPORT_HTTP +#define FEATURE_SUPPORT_HTTP 0 +#endif + +#ifndef FEATURE_MODULE_GEO +#define FEATURE_MODULE_GEO 0 +#endif + +#ifndef FEATURE_MODULE_SENSOR +#define FEATURE_MODULE_SENSOR 0 +#endif + +#ifndef FEATURE_MODULE_BRIGHTNESS +#define FEATURE_MODULE_BRIGHTNESS 0 +#endif + +#ifndef FEATURE_MODULE_BATTERY +#define FEATURE_MODULE_BATTERY 0 +#endif + +#ifndef FEATURE_MODULE_CONFIGURATION +#define FEATURE_MODULE_CONFIGURATION 0 +#endif /** * support js profiler */ -#define FEATURE_ACELITE_MC_JS_PROFILER +#ifndef FEATURE_ACELITE_MC_JS_PROFILER +#define FEATURE_ACELITE_MC_JS_PROFILER 1 +#endif +#ifndef DEFAULT_PROFILER_MSG_PATH #define DEFAULT_PROFILER_MSG_PATH "user/log/" +#endif +#ifndef PROFILER_ENABLE_FLAG_FILE #define PROFILER_ENABLE_FLAG_FILE "user/data/profiler_enable" +#endif +#ifndef RUNTIME_MODE_FILE_PATH #define RUNTIME_MODE_FILE_PATH "user/data/jsparser_enable" +#endif /** * Rotation API feature */ -#if (defined(ENABLE_ROTATE_INPUT) && (ENABLE_ROTATE_INPUT == 1)) +#if (ENABLE_ROTATE_INPUT == 1) // low layer supports #ifndef FEATURE_ROTATION_API -#define FEATURE_ROTATION_API +#define FEATURE_ROTATION_API 1 #endif -#endif // (defined(ENABLE_ROTATE_INPUT) && (ENABLE_ROTATE_INPUT == 1)) +#endif // (ENABLE_ROTATE_INPUT == 1) #endif // OHOS_ACELITE_CONFIG_H diff --git a/frameworks/targets/platform_adapter.cpp b/frameworks/targets/platform_adapter.cpp old mode 100644 new mode 100755 index ef3d193..5cdf59b --- a/frameworks/targets/platform_adapter.cpp +++ b/frameworks/targets/platform_adapter.cpp @@ -16,7 +16,7 @@ #include "platform_adapter.h" #include #include "acelite_config.h" -#if (defined(__LINUX__) || defined(__LITEOS__)) +#if (defined(__LINUX__) || defined(__LITEOS_A__)) #include "ace_ability.h" #endif #include "ace_log.h" @@ -28,7 +28,7 @@ namespace OHOS { namespace ACELite { void PrintVersionTrace() { -#ifdef TARGET_SIMULATOR +#if (TARGET_SIMULATOR == 1) // output version trace on simulator HILOG_DEBUG(HILOG_MODULE_ACE, "ACELite version: %{public}s", ACEVersion::GetStr()); HILOG_DEBUG(HILOG_MODULE_ACE, "ACELite commit: %{public}s", ACEVersion::GetCommit()); @@ -38,7 +38,7 @@ void PrintVersionTrace() void SetEngineSnapshotMode(bool &mode) { -#ifndef TARGET_SIMULATOR +#if (TARGET_SIMULATOR != 1) mode = true; #else mode = false; @@ -50,15 +50,15 @@ void SetEngineSnapshotModeManually(bool &mode) #if (defined(__LINUX__) || defined(__LITEOS_A__)) // if not starting debugger, on real device, give a chance to use JS mode manually mode = IsFileExisted(RUNTIME_MODE_FILE_PATH); -#elif !defined(TARGET_SIMULATOR) +#elif (TARGET_SIMULATOR != 1) mode = !(IsFileExisted(RUNTIME_MODE_FILE_PATH)); #endif } void Terminate(uint16_t token) { -#ifndef TARGET_SIMULATOR // no AMS support on PC simulator -#ifdef FEATURE_TERMINATE_ABILITY +#if (TARGET_SIMULATOR != 1) // no AMS support on PC simulator +#if (FEATURE_TERMINATE_ABILITY == 1) ProductAdapter::SendTerminatingRequest(token, false); #else AceAbility::TerminateSelf(); @@ -68,7 +68,7 @@ void Terminate(uint16_t token) void Srand(unsigned seed) { -#ifdef TARGET_SIMULATOR +#if (TARGET_SIMULATOR == 1) srand(seed); #endif // TARGET_SIMULATOR } diff --git a/frameworks/targets/simulator/BUILD.gn b/frameworks/targets/simulator/BUILD.gn index b34d33b..73498c5 100755 --- a/frameworks/targets/simulator/BUILD.gn +++ b/frameworks/targets/simulator/BUILD.gn @@ -57,10 +57,10 @@ ohos_static_library("ace_lite") { "//third_party/jerryscript:libjerryscript", ] defines = [ - "TARGET_SIMULATOR", - "JS_ENGINE_EXTERNAL_CONTEXT", - "SCREENSIZE_SPECIFIED", - "MOCK_JS_ASYNC_WORK", + "TARGET_SIMULATOR=1", + "JS_ENGINE_EXTERNAL_CONTEXT=1", + "SCREENSIZE_SPECIFIED=1", + "MOCK_JS_ASYNC_WORK=1", ] if (is_debug == "debug") { defines += [ "JS_PROFILER=1" ] @@ -68,7 +68,7 @@ ohos_static_library("ace_lite") { defines += [ "JS_PROFILER=0" ] } if (LOSCFG_TEST_JS_BUILD) { - defines += [ "JSFWK_TEST" ] + defines += [ "JSFWK_TEST=1" ] } if (enable_ohos_appexecfwk_feature_ability == true) { defines += [ "ABILITY_WINDOW_SUPPORT" ] diff --git a/frameworks/targets/simulator/acelite_config.h b/frameworks/targets/simulator/acelite_config.h index fff942d..bc33262 100755 --- a/frameworks/targets/simulator/acelite_config.h +++ b/frameworks/targets/simulator/acelite_config.h @@ -26,14 +26,14 @@ #define OHOS_ACELITE_SIMULATOR_WIN // NOTE: DO NOT use this macro directly #ifndef JSFWK_TEST -#define JSFWK_TEST +#define JSFWK_TEST 1 #endif /** * The macro is used to distingush the real device and simulator. */ #ifndef TARGET_SIMULATOR -#define TARGET_SIMULATOR +#define TARGET_SIMULATOR 1 #endif /** @@ -42,18 +42,18 @@ #ifdef FEATURE_TEST_IMPLEMENTATION #error "must keep the global configuration unique" #else -#define FEATURE_TEST_IMPLEMENTATION +#define FEATURE_TEST_IMPLEMENTATION 1 #endif /** * enable FeatureAbility API */ -#define FEATURE_FEATURE_ABILITY_MODULE +#define FEATURE_FEATURE_ABILITY_MODULE 1 /** * support device API for JS */ -#define FEATURE_MODULE_DEVICE +#define FEATURE_MODULE_DEVICE 1 /** * support geo location API for JS @@ -83,7 +83,7 @@ /** * timer module */ -#define FEATURE_TIMER_MODULE +#define FEATURE_TIMER_MODULE 1 /** * execute timer callback directly for previewer @@ -93,14 +93,14 @@ /** * support storage API for JS */ -#define FEATURE_MODULE_STORAGE +#define FEATURE_MODULE_STORAGE 1 /** * localization module */ -#define FEATURE_LOCALIZATION_MODULE +#define FEATURE_LOCALIZATION_MODULE 1 -#define FEATURE_CUSTOM_ENTRY_PAGE +#define FEATURE_CUSTOM_ENTRY_PAGE 1 /** * module require test @@ -108,7 +108,7 @@ #ifdef ENABLE_MODULE_REQUIRE_TEST #error "must keep the global configuration unique" #else -#define ENABLE_MODULE_REQUIRE_TEST +#define ENABLE_MODULE_REQUIRE_TEST 1 #endif /** @@ -121,12 +121,14 @@ /** * enable Canvas component Feature API on simulator */ -#define FEATURE_COMPONENT_CANVAS +#ifndef FEATURE_COMPONENT_CANVAS +#define FEATURE_COMPONENT_CANVAS 1 +#endif -#ifdef FEATURE_COMPONENT_QRCODE +#if (FEATURE_COMPONENT_QRCODE == 1) #error "must keep the global configuration unique" #else -#define FEATURE_COMPONENT_QRCODE +#define FEATURE_COMPONENT_QRCODE 1 #endif #ifdef _WIN32 @@ -149,11 +151,11 @@ /** * Rotation API feature */ -#if (defined(ENABLE_ROTATE_INPUT) && (ENABLE_ROTATE_INPUT == 1)) +#if (ENABLE_ROTATE_INPUT == 1) // low layer supports #ifndef FEATURE_ROTATION_API #define FEATURE_ROTATION_API #endif -#endif // (defined(ENABLE_ROTATE_INPUT) && (ENABLE_ROTATE_INPUT == 1)) +#endif // (ENABLE_ROTATE_INPUT == 1) #endif // OHOS_ACELITE_CONFIG_H diff --git a/frameworks/tools/qt/simulator/jsfwk/jsfwk.pro b/frameworks/tools/qt/simulator/jsfwk/jsfwk.pro index f8f7fbb..60f6d3c 100644 --- a/frameworks/tools/qt/simulator/jsfwk/jsfwk.pro +++ b/frameworks/tools/qt/simulator/jsfwk/jsfwk.pro @@ -9,11 +9,11 @@ DESTDIR = ../libs DEFINES -= UNICODE DEFINES -= FEATURE_TIMER_MODULE -DEFINES += TARGET_SIMULATOR -DEFINES += JS_ENGINE_EXTERNAL_CONTEXT -DEFINES += SCREENSIZE_SPECIFIED +DEFINES += TARGET_SIMULATOR=1 +DEFINES += JS_ENGINE_EXTERNAL_CONTEXT=1 +DEFINES += SCREENSIZE_SPECIFIED=1 DEFINES += JS_PROFILER=0 -DEFINES += QT_SIMULATOR +DEFINES += QT_SIMULATOR=1 # Following defines are copied from libui.pro, as jsfwk depends the ui defines, and there is no way to # share those macros. But graphic module might consider to setup them in one C header file, which can @@ -31,7 +31,7 @@ eval(is_debug == release) { } LOSCFG_TEST_JS_BUILD { - DEFINES += JSFWK_TEST + DEFINES += JSFWK_TEST=1 } ROOT_PATH = ../../../../../../../.. diff --git a/frameworks/tools/qt/simulator/jsfwk/targets/simulator/acelite_config.h b/frameworks/tools/qt/simulator/jsfwk/targets/simulator/acelite_config.h index e7edb28..4fde3b7 100644 --- a/frameworks/tools/qt/simulator/jsfwk/targets/simulator/acelite_config.h +++ b/frameworks/tools/qt/simulator/jsfwk/targets/simulator/acelite_config.h @@ -27,14 +27,14 @@ #define OHOS_ACELITE_SIMULATOR_WIN // NOTE: DO NOT use this macro directly #ifndef JSFWK_TEST -#define JSFWK_TEST +#define JSFWK_TEST 1 #endif /** * The macro is used to distingush the real device and simulator. */ #ifndef TARGET_SIMULATOR -#define TARGET_SIMULATOR +#define TARGET_SIMULATOR 1 #endif /** @@ -43,37 +43,37 @@ #ifdef FEATURE_TEST_IMPLEMENTATION #error "must keep the global configuration unique" #else -#define FEATURE_TEST_IMPLEMENTATION +#define FEATURE_TEST_IMPLEMENTATION 1 #endif -#define FEATURE_API_VERSION +#define FEATURE_API_VERSION 1 -#ifndef QT_SIMULATOR +#if (QT_SIMULATOR != 1) /** * enable FeatureAbility API */ -#define FEATURE_FEATURE_ABILITY_MODULE +#define FEATURE_FEATURE_ABILITY_MODULE 1 /** * support device API for JS */ -#define FEATURE_MODULE_DEVICE +#define FEATURE_MODULE_DEVICE 1 /** * support geo location API for JS */ -#define FEATURE_MODULE_GEO +#define FEATURE_MODULE_GEO 1 /** * support sensor API for JS */ -#define FEATURE_MODULE_SENSOR +#define FEATURE_MODULE_SENSOR 1 /** * support brightness API for JS */ -#define FEATURE_MODULE_BRIGHTNESS +#define FEATURE_MODULE_BRIGHTNESS 1 /** * support battery API for JS @@ -83,33 +83,33 @@ /** * support configuration API for JS */ -#define FEATURE_MODULE_CONFIGURATION +#define FEATURE_MODULE_CONFIGURATION 1 /** * support storage API for JS */ -#define FEATURE_MODULE_STORAGE +#define FEATURE_MODULE_STORAGE 1 #endif // QT_SIMULATOR /** * localization module */ -#define FEATURE_LOCALIZATION_MODULE +#define FEATURE_LOCALIZATION_MODULE 1 -#define FEATURE_LAZY_LOADING_MODULE +#define FEATURE_LAZY_LOADING_MODULE 1 /** * enable fatal error handling */ -#define FEATURE_FATAL_ERROR_HANDLING +#define FEATURE_FATAL_ERROR_HANDLING 1 /** * timer module */ -#define FEATURE_TIMER_MODULE +#define FEATURE_TIMER_MODULE 1 -#define FEATURE_CUSTOM_ENTRY_PAGE +#define FEATURE_CUSTOM_ENTRY_PAGE 1 /** * module require test @@ -117,7 +117,7 @@ #ifdef ENABLE_MODULE_REQUIRE_TEST #error "must keep the global configuration unique" #else -#define ENABLE_MODULE_REQUIRE_TEST +#define ENABLE_MODULE_REQUIRE_TEST 1 #endif /** @@ -130,17 +130,19 @@ /** * enable Canvas component Feature API on simulator */ -#define FEATURE_COMPONENT_CANVAS +#ifndef FEATURE_COMPONENT_CANVAS +#define FEATURE_COMPONENT_CANVAS 1 +#endif -#ifdef FEATURE_COMPONENT_QRCODE +#if (FEATURE_COMPONENT_QRCODE == 1) #error "must keep the global configuration unique" #else -#define FEATURE_COMPONENT_QRCODE +#define FEATURE_COMPONENT_QRCODE 1 #endif #ifdef _WIN32 // support memory analysis, only on win -#ifndef QT_SIMULATOR +#if (QT_SIMULATOR != 1) #define SIMULATOR_MEMORY_ANALYSIS #endif #endif @@ -160,11 +162,11 @@ /** * Rotation API feature */ -#if (defined(ENABLE_ROTATE_INPUT) && (ENABLE_ROTATE_INPUT == 1)) +#if (ENABLE_ROTATE_INPUT == 1) // low layer supports #ifndef FEATURE_ROTATION_API -#define FEATURE_ROTATION_API +#define FEATURE_ROTATION_API 1 #endif -#endif // (defined(ENABLE_ROTATE_INPUT) && (ENABLE_ROTATE_INPUT == 1)) +#endif // (ENABLE_ROTATE_INPUT == 1) #endif // OHOS_ACELITE_CONFIG_H diff --git a/interfaces/innerkits/builtin/jsi/jsi.h b/interfaces/innerkits/builtin/jsi/jsi.h index e32a551..dfa8ac1 100755 --- a/interfaces/innerkits/builtin/jsi/jsi.h +++ b/interfaces/innerkits/builtin/jsi/jsi.h @@ -429,7 +429,7 @@ public: */ static JSIValue CreateNull(); -#ifdef JS_FWK_SYMBOL +#if (JS_FWK_SYMBOL == 1) /** * @brief Create a javascript symbol. * @@ -604,7 +604,7 @@ public: */ static void SetOnTerminate(JSIValue object, JsiCallback callback); -#ifdef JS_FWK_TYPEDARRAY +#if (JS_FWK_TYPEDARRAY == 1) /** * @brief Get the properties of the given javascript TypedArray object. * diff --git a/test/ace_test_config.gni b/test/ace_test_config.gni index 672c1eb..415e11c 100755 --- a/test/ace_test_config.gni +++ b/test/ace_test_config.gni @@ -69,7 +69,7 @@ ace_test_configs = [ "$ace_lite_root/frameworks:ace_lite_config" ] ace_test_defines = [ "TDD_ASSERTIONS", "__LITEOS__", - "FEATURE_TERMINATE_ABILITY", + "FEATURE_TERMINATE_ABILITY=1", ] ace_test_deps = [ @@ -80,6 +80,7 @@ ace_test_deps = [ "${appexecfwk_lite_path}/frameworks/bundle_lite:bundle", "//base/powermgr/battery_lite/frameworks/js:ace_battery_kits", "//foundation/ace/ace_engine_lite/frameworks:ace_lite", + "//foundation/ace/ace_engine_lite/frameworks/targets", "//foundation/communication/ipc_lite:liteipc_adapter", "//foundation/distributedschedule/samgr_lite/communication/broadcast", "//foundation/distributedschedule/samgr_lite/samgr:samgr",