Description: fix compile failed

IssueNo: https://gitee.com/openharmony/ace_engine_lite/issues/I4QHVT
Feature or Bugfix: Bugfix
Binary Source:No
Signed-off-by: lancer <haoshuo@huawei.com>
This commit is contained in:
lancer
2022-01-12 17:10:32 +08:00
parent 1915a4abeb
commit 0718558cfb
26 changed files with 219 additions and 205 deletions
+2 -2
View File
@@ -125,13 +125,13 @@ PenaltyBreakString: 1000
# 对于每个在行字符数限制之外的字符的penalty
PenaltyExcessCharacter: 1000000
# 将函数的返回类型放到它自己的行的penalty
PenaltyReturnTypeOnItsOwnLine: 60
PenaltyReturnTypeOnItsOwnLine: 6000
# 指针和引用的对齐: Left, Right, Middle
PointerAlignment: Right
# 允许重新排版注释
ReflowComments: true
# 允许排序#include
SortIncludes: true
SortIncludes: false
# 在C风格类型转换后添加空格
SpaceAfterCStyleCast: false
# 在赋值运算符之前添加空格
+2 -2
View File
@@ -23,8 +23,8 @@
* #if DISABLED(LOG_OUTPUT)
* #if ENABLED(LOG_OUTPUT)
*/
#define JS_ENABLED(CONFIGURATION) ((CONFIGURATION) == 1)
#define JS_DISABLED(CONFIGURATION) ((CONFIGURATION) != 1)
#define IS_ENABLED(CONFIGURATION) ((CONFIGURATION) == 1)
#define IS_DISABLED(CONFIGURATION) ((CONFIGURATION) != 1)
/**
* Enable/Disable JS framework runtime performance measurement.
+9 -3
View File
@@ -26,9 +26,15 @@
namespace OHOS {
namespace ACELite {
// the protocol type the engine supports
enum DebugProtocol : uint8_t { TCP, SERIAL };
enum DebugProtocol : uint8_t {
TCP,
SERIAL
};
// the protocol channel type the engine supports
enum DebugChannel : uint8_t { WEBSOCKET, RAWPACKET };
enum DebugChannel : uint8_t {
WEBSOCKET,
RAWPACKET
};
const uint16_t DEFAULT_PORT = 5001; // default port
struct DebuggerConfig : public MemoryHeap {
DebugProtocol protocol; // use tcp as default
@@ -127,7 +133,7 @@ public:
void ReleaseJSContext();
private:
#if JS_ENABLED(ENGINE_DEBUGGER)
#if IS_ENABLED(ENGINE_DEBUGGER)
#if (JS_ENGINE_EXTERNAL_CONTEXT == 1)
void *engineContext_ = nullptr;
#endif // JS_ENGINE_EXTERNAL_CONTEXT
@@ -377,7 +377,7 @@ void JsiInterfaceTddTest::JSIInterfaceTest010()
TDD_CASE_END();
}
#if JS_ENABLED(JS_FWK_SYMBOL)
#if IS_ENABLED(JS_FWK_SYMBOL)
void JsiInterfaceTddTest::JSIInterfaceTest011()
{
TDD_CASE_BEGIN();
@@ -597,7 +597,7 @@ void JsiInterfaceTddTest::JSIInterfaceTest017()
TDD_CASE_END();
}
#if JS_ENABLED(JS_FWK_TYPEDARRAY)
#if IS_ENABLED(JS_FWK_TYPEDARRAY)
void JsiInterfaceTddTest::JSIInterfaceTest018()
{
TDD_CASE_BEGIN();
@@ -870,7 +870,7 @@ void JsiInterfaceTddTest::RunTests()
JSIInterfaceTest008();
JSIInterfaceTest009();
JSIInterfaceTest010();
#if JS_ENABLED(JS_FWK_SYMBOL)
#if IS_ENABLED(JS_FWK_SYMBOL)
JSIInterfaceTest011();
#endif // ENABLED(JS_FWK_SYMBOL)
JSIInterfaceTest012();
@@ -879,7 +879,7 @@ void JsiInterfaceTddTest::RunTests()
JSIInterfaceTest015();
JSIInterfaceTest016();
JSIInterfaceTest017();
#if JS_ENABLED(JS_FWK_TYPEDARRAY)
#if IS_ENABLED(JS_FWK_TYPEDARRAY)
JSIInterfaceTest018();
JSIInterfaceTest019();
#endif // ENABLED(JS_FWK_TYPEDARRAY)
@@ -990,7 +990,7 @@ HWTEST_F(JsiInterfaceTddTest, test010, TestSize.Level1)
JsiInterfaceTddTest::JSIInterfaceTest010();
}
#if JS_ENABLED(JS_FWK_SYMBOL)
#if IS_ENABLED(JS_FWK_SYMBOL)
/**
* @tc.name: JSIInterfaceTest011
* @tc.desc: Verify JSI interface related to Symbol object.
@@ -1062,7 +1062,7 @@ HWTEST_F(JsiInterfaceTddTest, test017, TestSize.Level1)
JsiInterfaceTddTest::JSIInterfaceTest017();
}
#if JS_ENABLED(JS_FWK_TYPEDARRAY)
#if IS_ENABLED(JS_FWK_TYPEDARRAY)
/**
* @tc.name: JSIInterfaceTest018
* @tc.desc: Verify JSI interface related to JS ArrayBuffer.
@@ -56,7 +56,7 @@ public:
void JSIInterfaceTest008();
void JSIInterfaceTest009();
void JSIInterfaceTest010();
#if JS_ENABLED(JS_FWK_SYMBOL)
#if IS_ENABLED(JS_FWK_SYMBOL)
void JSIInterfaceTest011();
#endif // ENABLED(JS_FWK_SYMBOL)
void JSIInterfaceTest012();
@@ -65,7 +65,7 @@ public:
void JSIInterfaceTest015();
void JSIInterfaceTest016();
void JSIInterfaceTest017();
#if JS_ENABLED(JS_FWK_TYPEDARRAY)
#if IS_ENABLED(JS_FWK_TYPEDARRAY)
void JSIInterfaceTest018();
void JSIInterfaceTest019();
#endif // ENABLED(JS_FWK_TYPEDARRAY)
+1 -1
View File
@@ -20,7 +20,7 @@
#include "js_config.h"
#if JS_ENABLED(ACE_LITE_VERSION_JS_API)
#if IS_ENABLED(ACE_LITE_VERSION_JS_API)
namespace OHOS {
namespace ACELite {
@@ -29,7 +29,7 @@ Debugger &Debugger::GetInstance()
return instance;
}
#if JS_ENABLED(ENGINE_DEBUGGER)
#if IS_ENABLED(ENGINE_DEBUGGER)
bool Debugger::IsDebuggerEnabled()
{
return debuggerConfig_.startDebuggerServer;
@@ -70,7 +70,7 @@ void Debugger::TearDownDebugger()
debuggerStarted_ = false;
}
void Debugger::Output(const char *const str)
void Debugger::Output(const char * const str)
{
// print out the log into stdout anyway
printf("%s", str);
@@ -135,7 +135,7 @@ void Debugger::StartDebugger() {}
void Debugger::TearDownDebugger() {}
void Debugger::Output(const char *const str)
void Debugger::Output(const char * const str)
{
UNUSED(str);
}
+36 -36
View File
@@ -31,7 +31,7 @@
#include "js_app_context.h"
#include "js_app_environment.h"
#include "js_profiler.h"
#if JS_ENABLED(CONSOLE_LOG_OUTPUT)
#if IS_ENABLED(CONSOLE_LOG_OUTPUT)
#include "presets/console_module.h"
#endif
#include "presets/console_log_impl.h"
@@ -49,33 +49,33 @@
namespace OHOS {
namespace ACELite {
void JerrySetNamedProperty(jerry_value_t object, const char *const name, jerry_value_t propValue)
void JerrySetNamedProperty(jerry_value_t object, const char * const name, jerry_value_t propValue)
{
jerry_release_value(jerryx_set_property_str(object, name, propValue));
}
void JerrySetNumberProperty(jerry_value_t object, const char *const name, double value)
void JerrySetNumberProperty(jerry_value_t object, const char * const name, double value)
{
jerry_value_t numValue = jerry_create_number(value);
JerrySetNamedProperty(object, name, numValue);
jerry_release_value(numValue);
}
void JerrySetStringProperty(jerry_value_t object, const char *const name, const char *const value)
void JerrySetStringProperty(jerry_value_t object, const char * const name, const char * const value)
{
jerry_value_t strValue = jerry_create_string(reinterpret_cast<const jerry_char_t *>(value));
JerrySetNamedProperty(object, name, strValue);
jerry_release_value(strValue);
}
void JerrySetStringProperty(jerry_value_t object, const char *const name, const char *const value, uint32_t length)
void JerrySetStringProperty(jerry_value_t object, const char * const name, const char * const value, uint32_t length)
{
jerry_value_t strValue = jerry_create_string_sz_from_utf8(reinterpret_cast<const jerry_char_t *>(value), length);
JerrySetNamedProperty(object, name, strValue);
jerry_release_value(strValue);
}
char *JerryMallocStringProperty(const jerry_value_t object, const char *const name, uint16_t &length)
char *JerryMallocStringProperty(const jerry_value_t object, const char * const name, uint16_t &length)
{
jerry_value_t propValue = jerryx_get_property_str(object, name);
char *res = MallocStringOf(propValue, &length);
@@ -83,7 +83,7 @@ char *JerryMallocStringProperty(const jerry_value_t object, const char *const na
return res;
}
int16_t JerryGetIntegerProperty(jerry_value_t object, const char *const name)
int16_t JerryGetIntegerProperty(jerry_value_t object, const char * const name)
{
jerry_value_t value = jerryx_get_property_str(object, name);
int16_t result = IntegerOf(value);
@@ -91,7 +91,7 @@ int16_t JerryGetIntegerProperty(jerry_value_t object, const char *const name)
return result;
}
bool JerryGetBoolProperty(jerry_value_t object, const char *const name, bool &outValue)
bool JerryGetBoolProperty(jerry_value_t object, const char * const name, bool &outValue)
{
jerry_value_t value = jerryx_get_property_str(object, name);
if (!jerry_value_is_boolean(value)) {
@@ -104,7 +104,7 @@ bool JerryGetBoolProperty(jerry_value_t object, const char *const name, bool &ou
return true;
}
void JerrySetFuncProperty(jerry_value_t object, const char *const name, jerry_external_handler_t handler)
void JerrySetFuncProperty(jerry_value_t object, const char * const name, jerry_external_handler_t handler)
{
if (name == nullptr || !strlen(name)) {
HILOG_ERROR(HILOG_MODULE_ACE, "Failed to set function property cause by empty name.");
@@ -256,7 +256,7 @@ void PrintErrorMessage(const jerry_value_t errorValue)
DfxAssist dfxAssist;
dfxAssist.DumpErrorCode(errorValue);
dfxAssist.DumpErrorMessage(errorValue);
#if JS_ENABLED(ENGINE_DEBUGGER)
#if IS_ENABLED(ENGINE_DEBUGGER)
FlushOutput();
#endif
}
@@ -304,7 +304,7 @@ jerry_value_t CallJSWatcher(jerry_value_t arg1,
{
jerry_value_t globalObject = jerry_get_global_object();
jerry_value_t appViewModel = jerryx_get_property_str(globalObject, ATTR_ROOT);
const char *const attrWatch = "$watch";
const char * const attrWatch = "$watch";
jerry_value_t watchFunction = jerryx_get_property_str(appViewModel, attrWatch);
jerry_value_t callbackFunc = jerry_create_external_function(watcherCB);
jerry_value_t args[ARG_LENGTH_WATCHER] = {arg1, callbackFunc, arg3};
@@ -381,7 +381,7 @@ void ClearEventListener(const jerry_value_t args[], const uint8_t argc)
* only used in this file, caller must make sure the target buffer is big enough.
* return the copied byte count.
*/
static size_t AppendTwoPath(char *const first, uint8_t startIndex, const char *const sec, const uint16_t destSize)
static size_t AppendTwoPath(char * const first, uint8_t startIndex, const char * const sec, const uint16_t destSize)
{
if ((first == nullptr) || (sec == nullptr) || (strlen(sec) == 0)) {
return 0;
@@ -475,18 +475,18 @@ char *RelocateFilePath(const char *appRootPath, const char *subPath, const char
}
// judge absolute path or relative path (start with . is absolute otherwise relative)
static bool PathIsRelative(const char *const resPath)
static bool PathIsRelative(const char * const resPath)
{
return strncmp(PATH_PREFIX, resPath, strlen(PATH_PREFIX)) == 0;
}
char *RelocateFilePathRelative(const char *const appRootPath, const char *const resFileName)
char *RelocateFilePathRelative(const char * const appRootPath, const char * const resFileName)
{
const char *const jsPath = JsAppContext::GetInstance()->GetCurrentJsPath();
const char * const jsPath = JsAppContext::GetInstance()->GetCurrentJsPath();
if (jsPath == nullptr) {
return nullptr;
}
const char *const ret = strrchr(jsPath, RESOURCE_SEPARATOR);
const char * const ret = strrchr(jsPath, RESOURCE_SEPARATOR);
if (ret == nullptr) {
return nullptr;
}
@@ -526,7 +526,7 @@ char *RelocateFilePathRelative(const char *const appRootPath, const char *const
// relocate file name to appRootPath/common/fileName
// e.x. /system/app/73709738-2d9d-4947-ac63-9858dcae7ccb/common/right.png
char *RelocateResourceFilePath(const char *const appRootPath, const char *const resFileName)
char *RelocateResourceFilePath(const char * const appRootPath, const char * const resFileName)
{
if (PathIsRelative(resFileName)) {
// deal with relative path
@@ -540,12 +540,12 @@ char *RelocateResourceFilePath(const char *const appRootPath, const char *const
// relocate file name to appRootPath/src/fileName
// e.x. /system/app/73709738-2d9d-4947-ac63-9858dcae7ccb/src/index.js
// NOTE: srcFileName must be the relative path to src folder
char *RelocateJSSourceFilePath(const char *const appRootPath, const char *const srcFileName)
char *RelocateJSSourceFilePath(const char * const appRootPath, const char * const srcFileName)
{
return RelocateFilePath(appRootPath, SRC_SUB_FOLDER_NAME, srcFileName);
}
char *ReadJSFile(const char *const appPath, const char *const jsFileName)
char *ReadJSFile(const char * const appPath, const char * const jsFileName)
{
uint32_t contentLength = 0;
return ReadJSFile(appPath, jsFileName, contentLength);
@@ -554,7 +554,7 @@ char *ReadJSFile(const char *const appPath, const char *const jsFileName)
/**
* Check if the given file exists or not.
*/
bool IsFileExisted(const char *const filePath)
bool IsFileExisted(const char * const filePath)
{
if (filePath == nullptr) {
return false;
@@ -569,7 +569,7 @@ bool IsFileExisted(const char *const filePath)
/**
* Whether file existed and 0 represents file not existed.
*/
int32_t GetFileSize(const char *const filePath)
int32_t GetFileSize(const char * const filePath)
{
if (filePath == nullptr) {
return 0;
@@ -582,7 +582,7 @@ int32_t GetFileSize(const char *const filePath)
return info.st_size;
}
static int32_t OpenFileInternal(const char *const orgFullPath, bool binary = false)
static int32_t OpenFileInternal(const char * const orgFullPath, bool binary = false)
{
const char *path = orgFullPath;
#if (QT_SIMULATOR != 1)
@@ -604,7 +604,7 @@ static int32_t OpenFileInternal(const char *const orgFullPath, bool binary = fal
return open(path, O_RDONLY);
}
static void OutputFileMaxLimitationTrace(const char *const fullPath, size_t limitation)
static void OutputFileMaxLimitationTrace(const char * const fullPath, size_t limitation)
{
if (fullPath == nullptr || strlen(fullPath) == 0) {
return;
@@ -631,7 +631,7 @@ static void OutputFileMaxLimitationTrace(const char *const fullPath, size_t limi
/**
* Check if the file length is under MAX limitation.
*/
static bool CheckFileLength(const char *const fullPath, int32_t &outFileSize)
static bool CheckFileLength(const char * const fullPath, int32_t &outFileSize)
{
outFileSize = 0;
int32_t fileSize = GetFileSize(fullPath);
@@ -652,7 +652,7 @@ static bool CheckFileLength(const char *const fullPath, int32_t &outFileSize)
* Read file content from one give full file path.
* Return value must be freed by caller.
*/
char *ReadFile(const char *const fullPath, uint32_t &fileSize, const bool binary)
char *ReadFile(const char * const fullPath, uint32_t &fileSize, const bool binary)
{
UNUSED(binary);
char *scriptBuffer = nullptr;
@@ -707,7 +707,7 @@ char *ReadFile(const char *const fullPath, uint32_t &fileSize, const bool binary
* give app path, such as /system/app/uuid/, read script string from /system/app/uuid/src/index.js,
* return value must be freed by caller.
*/
char *ReadJSFile(const char *const appPath, const char *const jsFileName, uint32_t &fileSize)
char *ReadJSFile(const char * const appPath, const char * const jsFileName, uint32_t &fileSize)
{
fileSize = 0;
// RelocateFilePath() will check the input parameters
@@ -730,7 +730,7 @@ char *ReadJSFile(const char *const appPath, const char *const jsFileName, uint32
return fileBuffer;
}
static void CalculatePathPosFromUri(const char *const url, const size_t length, size_t *start, size_t *pathLength)
static void CalculatePathPosFromUri(const char * const url, const size_t length, size_t *start, size_t *pathLength)
{
const uint8_t minLength = 4;
if ((url == nullptr) || (length <= minLength)) {
@@ -770,7 +770,7 @@ static void CalculatePathPosFromUri(const char *const url, const size_t length,
*
* @return the url itself, "common/logo.png"
*/
char *CreatePathStrFromUrl(const char *const url)
char *CreatePathStrFromUrl(const char * const url)
{
if (url == nullptr) {
return nullptr;
@@ -942,15 +942,15 @@ bool StartWith(const char *sequence, const char *prefix)
return true;
}
bool IsHexColor(const char *const target)
bool IsHexColor(const char * const target)
{
return StartWith(target, PREFIX_HEX_COLOR);
}
bool IsRgbColor(const char *const target)
bool IsRgbColor(const char * const target)
{
return StartWith(target, PREFIX_RGB_COLOR);
}
bool IsRgbaColor(const char *const target)
bool IsRgbaColor(const char * const target)
{
return StartWith(target, PREFIX_RGBA_COLOR);
}
@@ -967,7 +967,7 @@ constexpr uint8_t IDX_ARGB_ALPHA_END = 2;
constexpr uint8_t IDX_ARGB_COLOR_BEGIN = 3;
constexpr uint8_t BITS_PER_BYTE = 8;
bool ParseHexColor(const char *const source, uint32_t &color, uint8_t &alpha)
bool ParseHexColor(const char * const source, uint32_t &color, uint8_t &alpha)
{
if ((source == nullptr) || (strlen(source) <= 1)) {
return false;
@@ -1006,7 +1006,7 @@ bool ParseHexColor(const char *const source, uint32_t &color, uint8_t &alpha)
return false;
}
bool ParseRgbaColor(const char *const source, uint32_t &color, uint8_t &alpha)
bool ParseRgbaColor(const char * const source, uint32_t &color, uint8_t &alpha)
{
uint8_t idxOpenBrace = 0;
uint8_t idxCloseBrace = 0;
@@ -1071,7 +1071,7 @@ bool ParseRgbaColor(const char *const source, uint32_t &color, uint8_t &alpha)
return true;
}
bool ParseColor(const char *const source, uint32_t &color, uint8_t &alpha)
bool ParseColor(const char * const source, uint32_t &color, uint8_t &alpha)
{
if (source == nullptr) {
return false;
@@ -1187,7 +1187,7 @@ void CureImagePath(char *&imagePath)
int16_t dotPos = -1;
const int16_t suffixLen = 3;
const size_t imagePathLen = strlen(imagePath);
const char *const suffixName = "bin";
const char * const suffixName = "bin";
if (imagePathLen >= PATH_LENGTH_MAX) {
return;
@@ -1268,7 +1268,7 @@ const char *ParseImageSrc(jerry_value_t source)
return imageSrc;
}
bool CopyFontFamily(char *&destination, const char *const fontFamily, uint32_t fontFamilyNameLen)
bool CopyFontFamily(char *&destination, const char * const fontFamily, uint32_t fontFamilyNameLen)
{
// unused parameter for now, added for clean up warning
UNUSED(fontFamilyNameLen);
+25 -25
View File
@@ -70,7 +70,7 @@ struct Watcher : public MemoryHeap {
void ThrowError();
#if JS_ENABLED(JS_PROFILER)
#if IS_ENABLED(JS_PROFILER)
#ifndef LOG_PROFILER_TRACE
#define LOG_PROFILER(format, ...) printf(format "\n", ##__VA_ARGS__)
#define LOG_PROFILER_TRACE(format, ...) printf("[PERFORMANCE]:" format "\n", ##__VA_ARGS__)
@@ -169,13 +169,13 @@ uint16_t GetHorizontalResolution();
uint16_t GetVerticalResolution();
// global functions
void JerrySetNamedProperty(jerry_value_t object, const char *const name, jerry_value_t propValue);
void JerrySetNumberProperty(jerry_value_t object, const char *const name, double value);
void JerrySetStringProperty(jerry_value_t object, const char *const name, const char *const value);
void JerrySetStringProperty(jerry_value_t object, const char *const name, const char *const value, uint32_t length);
void JerrySetNamedProperty(jerry_value_t object, const char * const name, jerry_value_t propValue);
void JerrySetNumberProperty(jerry_value_t object, const char * const name, double value);
void JerrySetStringProperty(jerry_value_t object, const char * const name, const char * const value);
void JerrySetStringProperty(jerry_value_t object, const char * const name, const char * const value, uint32_t length);
// value returned should be freed by caller when it's not nullptr and won't be used any more
char *JerryMallocStringProperty(const jerry_value_t object, const char *const name, uint16_t &length);
int16_t JerryGetIntegerProperty(jerry_value_t object, const char *const name);
char *JerryMallocStringProperty(const jerry_value_t object, const char * const name, uint16_t &length);
int16_t JerryGetIntegerProperty(jerry_value_t object, const char * const name);
/**
* @brief try to parse bool property from one JS object, caller should check the returned result before using outValue.
* @param object the given object
@@ -183,8 +183,8 @@ int16_t JerryGetIntegerProperty(jerry_value_t object, const char *const name);
* @param outValue the target property value
* @return true if the parse successfully
*/
bool JerryGetBoolProperty(jerry_value_t object, const char *const name, bool &outValue);
void JerrySetFuncProperty(jerry_value_t object, const char *const name, jerry_external_handler_t handler);
bool JerryGetBoolProperty(jerry_value_t object, const char * const name, bool &outValue);
void JerrySetFuncProperty(jerry_value_t object, const char * const name, jerry_external_handler_t handler);
char *MallocStringOf(jerry_value_t source);
// convert one jerry string value to char*, and return the string length
char *MallocStringOf(jerry_value_t source, uint16_t *strLength);
@@ -196,22 +196,22 @@ char *RelocateFilePath(const char *appRootPath, const char *subPath, const char
// relocate file name to appRootPath/dirA/dirB/fileName
// e.x. /system/app/73709738-2d9d-4947-ac63-9858dcae7ccb/pages/index/right.png
char *RelocateFilePathRelative(const char *const appRootPath, const char *const resFileName);
char *RelocateFilePathRelative(const char * const appRootPath, const char * const resFileName);
// returned value must be freed by caller
char *RelocateResourceFilePath(const char *const appRootPath, const char *const resFileName);
char *RelocateResourceFilePath(const char * const appRootPath, const char * const resFileName);
// returned value must be freed by caller
char *RelocateJSSourceFilePath(const char *const appRootPath, const char *const srcFileName);
char *RelocateJSSourceFilePath(const char * const appRootPath, const char * const srcFileName);
// read from src file, return value must be freed by caller
char *ReadJSFile(const char *const appPath, const char *const jsFileName);
char *ReadJSFile(const char * const appPath, const char * const jsFileName);
// read the given file and return the whole file content
char *ReadJSFile(const char *const appPath, const char *const jsFileName, uint32_t &fileSize);
char *ReadJSFile(const char * const appPath, const char * const jsFileName, uint32_t &fileSize);
// read the given file and return the whole file content
char *ReadFile(const char *const fullPath, uint32_t &fileSize, const bool binary);
char *ReadFile(const char * const fullPath, uint32_t &fileSize, const bool binary);
// check whether the given file exists
bool IsFileExisted(const char *const filePath);
bool IsFileExisted(const char * const filePath);
// Whether file existed and return the file size. 0 represents file not existed.
int32_t GetFileSize(const char *const filePath);
int32_t GetFileSize(const char * const filePath);
/**
* @brief give out the path string from an url pattern, "url(common/logo.png)".
@@ -220,7 +220,7 @@ int32_t GetFileSize(const char *const filePath);
*
* @return the url itself, "common/logo.png"
*/
char *CreatePathStrFromUrl(const char *const url);
char *CreatePathStrFromUrl(const char * const url);
/**
* @brief Call jerry_has_property and return the result
*
@@ -305,13 +305,13 @@ constexpr char DELIMITER[] = ",";
constexpr char RESOURCE_SEPARATOR = '/';
bool StartWith(const char *sequence, const char *prefix);
bool IsHexColor(const char *const target);
bool IsRgbColor(const char *const target);
bool IsRgbaColor(const char *const target);
bool ParseHexColor(const char *const source, uint32_t &color, uint8_t &alpha);
bool ParseRgbaColor(const char *const source, uint32_t &color, uint8_t &alpha);
bool ParseColor(const char *const source, uint32_t &color, uint8_t &alpha);
bool CopyFontFamily(char *&destination, const char *const fontFamily, uint32_t fontFamilyNameLen = 0);
bool IsHexColor(const char * const target);
bool IsRgbColor(const char * const target);
bool IsRgbaColor(const char * const target);
bool ParseHexColor(const char * const source, uint32_t &color, uint8_t &alpha);
bool ParseRgbaColor(const char * const source, uint32_t &color, uint8_t &alpha);
bool ParseColor(const char * const source, uint32_t &color, uint8_t &alpha);
bool CopyFontFamily(char *&destination, const char * const fontFamily, uint32_t fontFamilyNameLen = 0);
#if (defined(_WIN32) || defined(_WIN64))
constexpr char PATH_SEPARATOR = '\\';
@@ -24,31 +24,31 @@
namespace OHOS {
namespace ACELite {
// default fill style color=black
const char *const CanvasComponent::DEFAULT_FILLSTYLE = "#000000";
const char * const CanvasComponent::DEFAULT_FILLSTYLE = "#000000";
// default stroke style color=black
const char *const CanvasComponent::DEFAULT_STROKESTYLE = "#000000";
const char * const CanvasComponent::DEFAULT_STROKESTYLE = "#000000";
// default text align=left
const char *const CanvasComponent::DEFAULT_TEXTALIGN = "left";
const char * const CanvasComponent::DEFAULT_TEXTALIGN = "left";
// API-attribute
const char *const CanvasComponent::ATTR_FILLSTYLE = "fillStyle";
const char *const CanvasComponent::ATTR_STROKESTYLE = "strokeStyle";
const char *const CanvasComponent::ATTR_LINEWIDTH = "lineWidth";
const char *const CanvasComponent::ATTR_FONT = "font";
const char *const CanvasComponent::ATTR_TEXTALIGN = "textAlign";
const char * const CanvasComponent::ATTR_FILLSTYLE = "fillStyle";
const char * const CanvasComponent::ATTR_STROKESTYLE = "strokeStyle";
const char * const CanvasComponent::ATTR_LINEWIDTH = "lineWidth";
const char * const CanvasComponent::ATTR_FONT = "font";
const char * const CanvasComponent::ATTR_TEXTALIGN = "textAlign";
// API-method
const char *const CanvasComponent::FUNC_GETCONTEXT = "getContext";
const char *const CanvasComponent::FUNC_FILLRECT = "fillRect";
const char *const CanvasComponent::FUNC_STROKERECT = "strokeRect";
const char *const CanvasComponent::FUNC_FILLTEXT = "fillText";
const char *const CanvasComponent::FUNC_BEGINPATH = "beginPath";
const char *const CanvasComponent::FUNC_MOVETO = "moveTo";
const char *const CanvasComponent::FUNC_LINETO = "lineTo";
const char *const CanvasComponent::FUNC_RECT = "rect";
const char *const CanvasComponent::FUNC_ARC = "arc";
const char *const CanvasComponent::FUNC_CLOSEPATH = "closePath";
const char *const CanvasComponent::FUNC_STROKE = "stroke";
const char * const CanvasComponent::FUNC_GETCONTEXT = "getContext";
const char * const CanvasComponent::FUNC_FILLRECT = "fillRect";
const char * const CanvasComponent::FUNC_STROKERECT = "strokeRect";
const char * const CanvasComponent::FUNC_FILLTEXT = "fillText";
const char * const CanvasComponent::FUNC_BEGINPATH = "beginPath";
const char * const CanvasComponent::FUNC_MOVETO = "moveTo";
const char * const CanvasComponent::FUNC_LINETO = "lineTo";
const char * const CanvasComponent::FUNC_RECT = "rect";
const char * const CanvasComponent::FUNC_ARC = "arc";
const char * const CanvasComponent::FUNC_CLOSEPATH = "closePath";
const char * const CanvasComponent::FUNC_STROKE = "stroke";
// create canvas draw attribute-callback mapping
const AttrMap CanvasComponent::attrMap_[] = {{ATTR_FILLSTYLE, FillStyleSetter, FillStyleGetter},
@@ -59,10 +59,18 @@ const AttrMap CanvasComponent::attrMap_[] = {{ATTR_FILLSTYLE, FillStyleSetter, F
// create canvas draw method-callback mapping
const MethodMap CanvasComponent::methodMap_[] = {
{FUNC_GETCONTEXT, GetContext}, {FUNC_FILLRECT, FillRect}, {FUNC_STROKERECT, StrokeRect},
{FUNC_FILLTEXT, FillText}, {FUNC_BEGINPATH, BeginPath}, {FUNC_MOVETO, MoveTo},
{FUNC_LINETO, LineTo}, {FUNC_RECT, Rect}, {FUNC_ARC, Arc},
{FUNC_CLOSEPATH, ClosePath}, {FUNC_STROKE, Stroke}};
{FUNC_GETCONTEXT, GetContext},
{FUNC_FILLRECT, FillRect},
{FUNC_STROKERECT, StrokeRect},
{FUNC_FILLTEXT, FillText},
{FUNC_BEGINPATH, BeginPath},
{FUNC_MOVETO, MoveTo},
{FUNC_LINETO, LineTo},
{FUNC_RECT, Rect},
{FUNC_ARC, Arc},
{FUNC_CLOSEPATH, ClosePath},
{FUNC_STROKE, Stroke}
};
CanvasComponent::CanvasComponent(jerry_value_t options, jerry_value_t children, AppStyleManager *styleManager)
: Component(options, children, styleManager),
+6 -6
View File
@@ -269,7 +269,7 @@ bool Component::UpdateView(uint16_t attrKeyId, jerry_value_t attrValue)
return updateResult;
}
void Component::RegisterNamedFunction(const char *const name, jerry_external_handler_t handler) const
void Component::RegisterNamedFunction(const char * const name, jerry_external_handler_t handler) const
{
JerrySetFuncProperty(nativeElement_, name, handler);
}
@@ -742,7 +742,7 @@ void Component::SetAnimationKeyFrames(const UIView &view, const AppStyleItem *st
}
}
const char *const value = GetStyleStrValue(styleItem);
const char * const value = GetStyleStrValue(styleItem);
if (value == nullptr) {
HILOG_ERROR(HILOG_MODULE_ACE, "animation name is not string value");
return;
@@ -777,7 +777,7 @@ void Component::SetAnimationKeyFrames(const AppStyleItem *item)
isAnimationKeyFramesSet_ = false;
while (item) {
const char *const itemValue = item->GetStrValue();
const char * const itemValue = item->GetStrValue();
if ((itemValue == nullptr) || (strlen(itemValue) == 0)) {
return;
@@ -876,7 +876,7 @@ void Component::SetAnimationStyle(const UIView &view, const AppStyleItem *styleI
}
}
const char *const strValue = GetStyleStrValue(styleItem);
const char * const strValue = GetStyleStrValue(styleItem);
const size_t strLen = GetStyleStrValueLen(styleItem);
if (strValue == nullptr) {
HILOG_ERROR(HILOG_MODULE_ACE, "animation style item is null");
@@ -1431,7 +1431,7 @@ void Component::SetVisible(UIView &view, const AppStyleItem *styleItem) const
HILOG_ERROR(HILOG_MODULE_ACE, "Visible style value is invalid!");
return;
}
const char *const strValue = GetStyleStrValue(styleItem);
const char * const strValue = GetStyleStrValue(styleItem);
if (strValue == nullptr) {
return;
}
@@ -1927,7 +1927,7 @@ bool Component::HandleBackgroundImg(const AppStyleItem &styleItem, char *&presse
{
bool result = false;
if (styleItem.GetValueType() == STYLE_PROP_VALUE_TYPE_STRING) {
const char *const url = styleItem.GetStrValue();
const char * const url = styleItem.GetStrValue();
char *filePath = CreatePathStrFromUrl(url);
if (filePath != nullptr) {
char *imagePath = JsAppContext::GetInstance()->GetResourcePath(filePath);
@@ -176,11 +176,11 @@ public:
ACE_DISALLOW_COPY_AND_MOVE(ViewOnTouchListener);
ViewOnTouchListener(jerry_value_t vm, bool isStopPropagation)
: vm_(jerry_acquire_value(vm)),
isStopPropagation_(isStopPropagation),
bindTouchStartFunc_(UNDEFINED),
bindTouchMoveFunc_(UNDEFINED),
bindTouchEndFunc_(UNDEFINED),
bindSwipeFunc_(UNDEFINED)
bindSwipeFunc_(UNDEFINED),
isStopPropagation_(isStopPropagation)
{
}
@@ -20,7 +20,7 @@
#include "js_debugger_config.h"
#include "js_router.h"
#include "js_timer_list.h"
#if JS_ENABLED(JS_PROFILER)
#if IS_ENABLED(JS_PROFILER)
#include "js_profiler.h"
#endif
#include "non_copyable.h"
@@ -43,7 +43,7 @@ public:
isEnvInit_(false),
router_(nullptr)
{
#if JS_ENABLED(JS_PROFILER)
#if IS_ENABLED(JS_PROFILER)
// Call GetInstance() to prepare data
JSProfiler::GetInstance()->PrepareDataBuffer();
#endif
@@ -58,7 +58,7 @@ public:
*/
virtual ~JSAbilityImpl()
{
#if JS_ENABLED(JS_PROFILER)
#if IS_ENABLED(JS_PROFILER)
// Call release() to free all performance data
JSProfiler::GetInstance()->Release();
#endif
@@ -69,7 +69,7 @@ public:
*
* @brief initialize JS executing environment, including JS engine and JS fwk
*/
void InitEnvironment(const char *const abilityPath, const char *const bundleName, uint16_t token);
void InitEnvironment(const char * const abilityPath, const char * const bundleName, uint16_t token);
/**
* @fn JSAbilityRuntime::CleanUp()
@@ -120,7 +120,7 @@ private:
void InvokeOnCreate() const;
void InvokeOnDestroy() const;
void InvokeOnBackPressed() const;
void InvokeMethodWithoutParameter(const char *const name) const;
void InvokeMethodWithoutParameter(const char * const name) const;
JsAppContext *appContext_;
jerry_value_t abilityModel_; // the object evaled from user JS code
+1 -1
View File
@@ -15,7 +15,7 @@
#include "js_profiler.h"
// invoked into compiling only if performance measurement enabled
#if JS_ENABLED(JS_PROFILER)
#if IS_ENABLED(JS_PROFILER)
#include "ace_log.h"
#include "ace_mem_base.h"
#include "js_async_work.h"
+2 -2
View File
@@ -24,7 +24,7 @@
/*
* Wrapper macro, use directly in code after including this header file.
*/
#if JS_ENABLED(JS_PROFILER)
#if IS_ENABLED(JS_PROFILER)
// start tracing for one given phase, and return a traceId which will be used when calling STOP_TRACING
#define START_TRACING(traceTag) JSProfiler::GetInstance()->PushTrace(traceTag, 0, 0)
// start tracing for one given phase, and provids the component name together
@@ -44,7 +44,7 @@
#endif // ENABLED(JS_PROFILER)
// invoked into compiling only if performance measurement enabled
#if JS_ENABLED(JS_PROFILER)
#if IS_ENABLED(JS_PROFILER)
namespace OHOS {
namespace ACELite {
/**
@@ -24,13 +24,13 @@
namespace OHOS {
namespace ACELite {
JSfwkTddTest::JSfwkTddTest(){}
JSfwkTddTest::JSfwkTddTest() {}
static JSAbility* g_targetJSAbility = nullptr;
static char* g_currentTestCaseName = nullptr;
static JSAbility *g_targetJSAbility = nullptr;
static char *g_currentTestCaseName = nullptr;
static uint8_t g_assertRecord = 0;
void JSfwkTddTest::TestCaseB(const char* name) const
void JSfwkTddTest::TestCaseB(const char *name) const
{
g_assertRecord = 0;
g_currentTestCaseName = const_cast<char *>(name);
@@ -88,7 +88,7 @@ void JSfwkTddTest::ACELiteFrameworkInitialization001()
/**
* @tc.steps: step3. check if the top JS ability is initialized
*/
JSAbilityImpl* jsAbilityImpl = const_cast<JSAbilityImpl *>(JsAppContext::GetInstance()->GetTopJSAbilityImpl());
JSAbilityImpl *jsAbilityImpl = const_cast<JSAbilityImpl *>(JsAppContext::GetInstance()->GetTopJSAbilityImpl());
EXPECT_TRUE(jsAbilityImpl == nullptr);
/**
* @tc.steps: step4. clean up test environment
@@ -111,7 +111,7 @@ void JSfwkTddTest::ACELiteFrameworkInitialization002()
/**
* @tc.steps: step3. check if the top JS ability is initialized
*/
JSAbilityImpl* jsAbilityImpl = const_cast<JSAbilityImpl *>(JsAppContext::GetInstance()->GetTopJSAbilityImpl());
JSAbilityImpl *jsAbilityImpl = const_cast<JSAbilityImpl *>(JsAppContext::GetInstance()->GetTopJSAbilityImpl());
EXPECT_TRUE(jsAbilityImpl == nullptr);
/**
* @tc.steps: step4. clean up test environment
@@ -135,7 +135,7 @@ void JSfwkTddTest::ACELiteFrameworkInitialization003()
/**
* @tc.steps: step3. check if the top JS ability is initialized
*/
JSAbilityImpl* jsAbilityImpl = const_cast<JSAbilityImpl *>(JsAppContext::GetInstance()->GetTopJSAbilityImpl());
JSAbilityImpl *jsAbilityImpl = const_cast<JSAbilityImpl *>(JsAppContext::GetInstance()->GetTopJSAbilityImpl());
EXPECT_TRUE(jsAbilityImpl != nullptr);
/**
@@ -166,7 +166,7 @@ void JSfwkTddTest::ACELiteFrameworkInitialization009()
* @tc.steps: step1. init test environment
*/
TDD_CASE_BEGIN();
#if ENABLED(ACE_LITE_VERSION_JS_API)
#if IS_ENABLED(ACE_LITE_VERSION_JS_API)
/**
* @tc.steps: step2. check version code
*/
@@ -178,7 +178,7 @@ void JSfwkTddTest::ACELiteFrameworkInitialization009()
/**
* @tc.steps: step4. check build timestamp
*/
const char* buildStamp = ACEVersion::GetTimeStamp();
const char *buildStamp = ACEVersion::GetTimeStamp();
EXPECT_TRUE(buildStamp != nullptr);
constexpr char firstVersionBuildStamp[] = "2020-05-09 16:31:41";
if (strcmp(buildStamp, firstVersionBuildStamp) == 0) {
@@ -450,5 +450,5 @@ HWTEST_F(JSfwkTddTest, engineIntegrating004, TestSize.Level1)
JSfwkTddTest::AceliteFrameworkEngineIntegrating04();
}
#endif
}
}
} // namespace ACELite
} // namespace OHOS
@@ -14,7 +14,7 @@
*/
#include "console_log_impl.h"
#if JS_ENABLED(CONSOLE_LOG_OUTPUT)
#if IS_ENABLED(CONSOLE_LOG_OUTPUT)
#include "js_app_environment.h"
#if (FEATURE_USER_MC_LOG_PRINTF == 1)
#include "product_adapter.h"
@@ -48,7 +48,7 @@ jerry_value_t LogNative(const LogLevel logLevel,
// print out log level if needed
LogOutLevel(logLevel);
const char *const nullStr = "\\u0000";
const char * const nullStr = "\\u0000";
jerry_value_t retVal = jerry_create_undefined();
for (jerry_length_t argIndex = 0; argIndex < argc; argIndex++) {
@@ -138,7 +138,7 @@ void LogOutLevel(const LogLevel logLevel)
*
* @param str the string to print out
*/
void LogString(const LogLevel logLevel, const char *const str)
void LogString(const LogLevel logLevel, const char * const str)
{
if (str == nullptr) {
return;
@@ -180,7 +180,7 @@ void LogChar(char c, const LogLevel logLevel, bool endFlag)
}
#ifdef FEATURE_ACELITE_HI_LOG_PRINTF
static void OutputToHiLog(const LogLevel logLevel, const char *const str)
static void OutputToHiLog(const LogLevel logLevel, const char * const str)
{
switch (logLevel) {
case LOG_LEVEL_ERR:
@@ -206,7 +206,7 @@ static void OutputToHiLog(const LogLevel logLevel, const char *const str)
}
}
#elif (FEATURE_USER_MC_LOG_PRINTF == 1)
static void OutputToHiLog(const LogLevel logLevel, const char *const str)
static void OutputToHiLog(const LogLevel logLevel, const char * const str)
{
switch (logLevel) {
case LOG_LEVEL_ERR:
@@ -240,7 +240,7 @@ void RegisterJSLogOutputHandler(JSLogOutputExtraHandler extraHandler)
}
#endif // TDD_ASSERTIONS
void Output(const LogLevel logLevel, const char *const str, const uint8_t length)
void Output(const LogLevel logLevel, const char * const str, const uint8_t length)
{
if (str == nullptr) {
return;
@@ -19,7 +19,7 @@
#include "acelite_config.h"
#include "js_config.h"
#if JS_ENABLED(CONSOLE_LOG_OUTPUT)
#if IS_ENABLED(CONSOLE_LOG_OUTPUT)
#include "jerryscript.h"
@@ -50,7 +50,7 @@ void RegisterJSLogOutputHandler(JSLogOutputExtraHandler extraHandler);
* @param logLevel the log level
* @param str the string to print out
*/
void LogString(const LogLevel logLevel, const char *const str);
void LogString(const LogLevel logLevel, const char * const str);
/**
* @brief: Output given string into stdout or the log file.
@@ -59,7 +59,7 @@ void LogString(const LogLevel logLevel, const char *const str);
* @param str the string to print
* @param length the string's length
*/
void Output(const LogLevel logLevel, const char *const str, const uint8_t length);
void Output(const LogLevel logLevel, const char * const str, const uint8_t length);
/**
* @brief: Flush the output.
@@ -14,7 +14,7 @@
*/
#include "presets/console_module.h"
#if JS_ENABLED(CONSOLE_LOG_OUTPUT)
#if IS_ENABLED(CONSOLE_LOG_OUTPUT)
#include "presets/console_log_impl.h"
#endif // ENABLED(CONSOLE_LOG_OUTPUT)
@@ -22,11 +22,11 @@ namespace OHOS {
namespace ACELite {
void ConsoleModule::Init()
{
const char *const debug = "debug";
const char *const info = "info";
const char *const warn = "warn";
const char *const log = "log";
const char *const error = "error";
const char * const debug = "debug";
const char * const info = "info";
const char * const warn = "warn";
const char * const log = "log";
const char * const error = "error";
CreateNamedFunction(debug, LogDebug);
CreateNamedFunction(info, LogInfo);
CreateNamedFunction(warn, LogWarn);
@@ -39,7 +39,7 @@ jerry_value_t ConsoleModule::LogDebug(const jerry_value_t func,
const jerry_value_t *args,
const jerry_length_t length)
{
#if JS_DISABLED(CONSOLE_LOG_OUTPUT)
#if IS_DISABLED(CONSOLE_LOG_OUTPUT)
return UNDEFINED;
#else
return LogNative(LOG_LEVEL_DEBUG, func, context, args, length);
@@ -51,7 +51,7 @@ jerry_value_t ConsoleModule::LogInfo(const jerry_value_t func,
const jerry_value_t *args,
const jerry_length_t length)
{
#if JS_DISABLED(CONSOLE_LOG_OUTPUT)
#if IS_DISABLED(CONSOLE_LOG_OUTPUT)
return UNDEFINED;
#else
return LogNative(LOG_LEVEL_INFO, func, context, args, length);
@@ -63,7 +63,7 @@ jerry_value_t ConsoleModule::LogWarn(const jerry_value_t func,
const jerry_value_t *args,
const jerry_length_t length)
{
#if JS_DISABLED(CONSOLE_LOG_OUTPUT)
#if IS_DISABLED(CONSOLE_LOG_OUTPUT)
return UNDEFINED;
#else
return LogNative(LOG_LEVEL_WARN, func, context, args, length);
@@ -75,7 +75,7 @@ jerry_value_t ConsoleModule::Log(const jerry_value_t func,
const jerry_value_t *args,
const jerry_length_t length)
{
#if JS_DISABLED(CONSOLE_LOG_OUTPUT)
#if IS_DISABLED(CONSOLE_LOG_OUTPUT)
return UNDEFINED;
#else
return LogNative(LOG_LEVEL_NONE, func, context, args, length);
@@ -87,7 +87,7 @@ jerry_value_t ConsoleModule::LogError(const jerry_value_t func,
const jerry_value_t *args,
const jerry_length_t length)
{
#if JS_DISABLED(CONSOLE_LOG_OUTPUT)
#if IS_DISABLED(CONSOLE_LOG_OUTPUT)
return UNDEFINED;
#else
return LogNative(LOG_LEVEL_ERR, func, context, args, length);
@@ -13,7 +13,7 @@
* limitations under the License.
*/
#include "profiler_module.h"
#if JS_ENABLED(JS_PROFILER)
#if IS_ENABLED(JS_PROFILER)
namespace OHOS {
namespace ACELite {
/**
@@ -25,8 +25,8 @@ namespace ACELite {
*/
void ProfilerModule::Init()
{
const char *const startTracingFunc = "startTracing";
const char *const stopTracingFunc = "stopTracing";
const char * const startTracingFunc = "startTracing";
const char * const stopTracingFunc = "stopTracing";
CreateNamedFunction(startTracingFunc, StartTracing);
CreateNamedFunction(stopTracingFunc, StopTracing);
}
@@ -36,7 +36,7 @@ jerry_value_t ProfilerModule::StartTracing(const jerry_value_t func,
const jerry_value_t *args,
const jerry_length_t argsNum)
{
#if JS_ENABLED(JS_PROFILER)
#if IS_ENABLED(JS_PROFILER)
if ((args == nullptr) || (argsNum < 1)) {
return UNDEFINED;
}
@@ -64,7 +64,7 @@ jerry_value_t ProfilerModule::StopTracing(const jerry_value_t func,
const jerry_value_t *args,
const jerry_length_t argsNum)
{
#if JS_ENABLED(JS_PROFILER)
#if IS_ENABLED(JS_PROFILER)
STOP_TRACING();
#endif
return UNDEFINED;
@@ -17,7 +17,7 @@
#include "js_profiler.h"
#include "non_copyable.h"
#if JS_ENABLED(JS_PROFILER)
#if IS_ENABLED(JS_PROFILER)
#include "presets/preset_module.h"
namespace OHOS {
namespace ACELite {
@@ -82,7 +82,7 @@ public:
~PerformaceProfilerModule() = default;
static void Load()
{
#if JS_ENABLED(JS_PROFILER)
#if IS_ENABLED(JS_PROFILER)
ProfilerModule profilerModule;
profilerModule.Init();
#endif
@@ -14,7 +14,7 @@
*/
#include "version_module.h"
#if JS_ENABLED(ACE_LITE_VERSION_JS_API)
#if IS_ENABLED(ACE_LITE_VERSION_JS_API)
#include "ace_log.h"
#include "ace_version.h"
#include "platform_adapter.h"
@@ -34,7 +34,7 @@ jerry_value_t VersionModule::GetACEVersion(const jerry_value_t func,
const jerry_value_t args[],
const jerry_length_t argsNum)
{
const char *const versionStr = ACEVersion::GetStr();
const char * const versionStr = ACEVersion::GetStr();
return jerry_create_string(reinterpret_cast<const jerry_char_t *>(versionStr));
}
@@ -43,7 +43,7 @@ jerry_value_t VersionModule::GetACECommit(const jerry_value_t func,
const jerry_value_t args[],
const jerry_length_t argsNum)
{
const char *const commitStr = ACEVersion::GetCommit();
const char * const commitStr = ACEVersion::GetCommit();
return jerry_create_string(reinterpret_cast<const jerry_char_t *>(commitStr));
}
@@ -52,7 +52,7 @@ jerry_value_t VersionModule::GetACEBuildStamp(const jerry_value_t func,
const jerry_value_t args[],
const jerry_length_t argsNum)
{
const char *const stampStr = ACEVersion::GetTimeStamp();
const char * const stampStr = ACEVersion::GetTimeStamp();
return jerry_create_string(reinterpret_cast<const jerry_char_t *>(stampStr));
}
} // namespace ACELite
@@ -19,7 +19,7 @@
#include "acelite_config.h"
#include "js_config.h"
#include "non_copyable.h"
#if JS_ENABLED(ACE_LITE_VERSION_JS_API)
#if IS_ENABLED(ACE_LITE_VERSION_JS_API)
#include "presets/preset_module.h"
namespace OHOS {
namespace ACELite {
@@ -70,7 +70,7 @@ public:
~AceVersionModule() = default;
static void Load()
{
#if JS_ENABLED(ACE_LITE_VERSION_JS_API)
#if IS_ENABLED(ACE_LITE_VERSION_JS_API)
VersionModule versionModule;
versionModule.Init();
#endif
@@ -86,7 +86,7 @@ void StateMachine::SetCurrentState(int8_t newState)
currentState_ = newState;
}
int StateMachine::GenerateJsPagePath(const char *const uri)
int StateMachine::GenerateJsPagePath(const char * const uri)
{
size_t uriLen = strlen(uri);
if (uriLen >= PATH_LENGTH_MAX) {
@@ -107,7 +107,7 @@ int StateMachine::GenerateJsPagePath(const char *const uri)
len = strlen(JS_INDEX_FILE_PATH);
}
#endif
const char *const sourceFileSuffix = (JsAppEnvironment::GetInstance()->IsSnapshotMode()) ? ".bc" : ".js";
const char * const sourceFileSuffix = (JsAppEnvironment::GetInstance()->IsSnapshotMode()) ? ".bc" : ".js";
len += strlen(sourceFileSuffix);
// add ending character:'\0'
len += 1;
@@ -133,7 +133,7 @@ int StateMachine::GenerateJsPagePath(const char *const uri)
return SUCCESS;
}
void StateMachine::RegisterUriAndParamsToPage(const char *const uri, jerry_value_t params)
void StateMachine::RegisterUriAndParamsToPage(const char * const uri, jerry_value_t params)
{
jerry_value_t globalObject = jerry_get_global_object();
if (!IS_UNDEFINED(params)) {
@@ -246,7 +246,7 @@ bool StateMachine::CheckJSSourceFile() const
break;
}
const char *const anotherSuffix = (JsAppEnvironment::GetInstance()->IsSnapshotMode()) ? ".js" : ".bc";
const char * const anotherSuffix = (JsAppEnvironment::GetInstance()->IsSnapshotMode()) ? ".js" : ".bc";
// change file suffix to another mode file
if (strcpy_s((fullPath + (pathLength - fileSuffixLength)), (fileSuffixLength + 1), anotherSuffix) != EOK) {
break;
@@ -324,7 +324,7 @@ static void ForceGC(void *data)
{
static_cast<void>(data);
jerry_gc(jerry_gc_mode_t::JERRY_GC_PRESSURE_HIGH);
#if JS_ENABLED(JS_PROFILER)
#if IS_ENABLED(JS_PROFILER)
if (JSProfiler::GetInstance()->IsEnabled()) {
// dump the JS heap status
JSHeapStatus heapStatus;
@@ -388,7 +388,7 @@ void StateMachine::HidePage() const
JsAsyncWork::DispatchAsyncWork(ForceGC, nullptr);
}
void StateMachine::InvokePageLifeCycleCallback(const char *const name) const
void StateMachine::InvokePageLifeCycleCallback(const char * const name) const
{
if (FatalHandler::GetInstance().IsJSRuntimeFatal()) {
// can not continue to involve any JS object creating on engine in case runtime fatal
+18 -18
View File
@@ -25,7 +25,7 @@ void JSRelease(JSValue value)
return jerry_release_value(value);
}
JSValue JSString::Create(const char *const value)
JSValue JSString::Create(const char * const value)
{
return jerry_create_string(reinterpret_cast<const jerry_char_t *>(value));
}
@@ -116,7 +116,7 @@ JSValue JSObject::Get(JSValue target, JSValue key)
return jerry_get_property(target, key);
}
JSValue JSObject::Get(JSValue target, const char *const prop)
JSValue JSObject::Get(JSValue target, const char * const prop)
{
JSValue key = JSString::Create(prop);
JSValue value = jerry_get_property(target, key);
@@ -124,63 +124,63 @@ JSValue JSObject::Get(JSValue target, const char *const prop)
return value;
}
char *JSObject::GetString(JSValue target, const char *const prop)
char *JSObject::GetString(JSValue target, const char * const prop)
{
JSValue value = JSObject::Get(target, prop);
char *content = JSString::Value(value);
JSRelease(value);
return content;
}
double JSObject::GetNumber(JSValue target, const char *const prop)
double JSObject::GetNumber(JSValue target, const char * const prop)
{
JSValue value = JSObject::Get(target, prop);
double number = JSNumber::Value(value);
JSRelease(value);
return number;
}
bool JSObject::GetBoolean(JSValue target, const char *const prop)
bool JSObject::GetBoolean(JSValue target, const char * const prop)
{
JSValue value = JSObject::Get(target, prop);
bool flag = JSBoolean::Value(value);
JSRelease(value);
return flag;
}
void JSObject::Set(JSValue target, const char *const prop, JSValue value)
void JSObject::Set(JSValue target, const char * const prop, JSValue value)
{
JSValue key = JSString::Create(prop);
jerry_release_value(jerry_set_property(target, key, value));
JSRelease(key);
}
void JSObject::SetString(JSValue target, const char *const prop, const char *const value)
void JSObject::SetString(JSValue target, const char * const prop, const char * const value)
{
JSValue attr = JSString::Create(value);
JSObject::Set(target, prop, attr);
JSRelease(attr);
}
void JSObject::SetNumber(JSValue target, const char *const prop, const double value)
void JSObject::SetNumber(JSValue target, const char * const prop, const double value)
{
JSValue attr = JSNumber::Create(value);
JSObject::Set(target, prop, attr);
JSRelease(attr);
}
void JSObject::SetBoolean(JSValue target, const char *const prop, const bool value)
void JSObject::SetBoolean(JSValue target, const char * const prop, const bool value)
{
JSValue attr = JSBoolean::Create(value);
JSObject::Set(target, prop, attr);
JSRelease(attr);
}
void JSObject::Set(JSValue target, const char *const prop, JSHandler handler)
void JSObject::Set(JSValue target, const char * const prop, JSHandler handler)
{
JSValue func = JSFunction::Create(handler);
JSObject::Set(target, prop, func);
JSRelease(func);
}
bool JSObject::Del(JSValue target, const char *const prop)
bool JSObject::Del(JSValue target, const char * const prop)
{
JSValue key = JSString::Create(prop);
bool result = jerry_delete_property(target, key);
@@ -203,7 +203,7 @@ bool JSObject::DelNativePointer(JSValue target)
return jerry_delete_object_native_pointer(target, nullptr);
}
JSValue JSObject::Call(JSValue target, const char *const prop, JSValue args[], JSSize size)
JSValue JSObject::Call(JSValue target, const char * const prop, JSValue args[], JSSize size)
{
JSValue func = Get(target, prop);
JSValue value = JSFunction::Call(func, target, args, size);
@@ -211,7 +211,7 @@ JSValue JSObject::Call(JSValue target, const char *const prop, JSValue args[], J
return value;
}
JSValue JSObject::Call(JSValue target, const char *const prop)
JSValue JSObject::Call(JSValue target, const char * const prop)
{
return JSObject::Call(target, prop, nullptr, 0);
}
@@ -231,7 +231,7 @@ JSValue JSGlobal::Get()
return jerry_get_global_object();
}
JSValue JSGlobal::Get(const char *const prop)
JSValue JSGlobal::Get(const char * const prop)
{
JSValue global = JSGlobal::Get();
JSValue result = JSObject::Get(global, prop);
@@ -239,27 +239,27 @@ JSValue JSGlobal::Get(const char *const prop)
return result;
}
void JSGlobal::Set(const char *const prop, JSValue value)
void JSGlobal::Set(const char * const prop, JSValue value)
{
JSValue global = JSGlobal::Get();
JSObject::Set(global, prop, value);
JSRelease(global);
}
void JSGlobal::Del(const char *const props)
void JSGlobal::Del(const char * const props)
{
JSValue global = JSGlobal::Get();
JSObject::Del(global, props);
JSRelease(global);
}
JSValue JSGlobal::Call(const char *const prop, JSValue args[], JSSize size)
JSValue JSGlobal::Call(const char * const prop, JSValue args[], JSSize size)
{
JSValue global = JSGlobal::Get();
JSValue result = JSObject::Call(global, prop, args, size);
JSRelease(global);
return result;
}
JSValue JSGlobal::Call(const char *const prop)
JSValue JSGlobal::Call(const char * const prop)
{
return JSGlobal::Call(prop, nullptr, 0);
}
+18 -18
View File
@@ -30,7 +30,7 @@ void JSRelease(JSValue value);
class JSString final : public MemoryHeap {
public:
static JSValue Create(const char *const value);
static JSValue Create(const char * const value);
static bool Is(JSValue target);
static char *Value(JSValue value);
};
@@ -47,18 +47,18 @@ public:
static JSValue Create();
static JSValue Keys(JSValue target);
static JSValue Get(JSValue target, JSValue key);
static JSValue Get(JSValue target, const char *const prop);
static char *GetString(JSValue target, const char *const prop);
static double GetNumber(JSValue target, const char *const prop);
static bool GetBoolean(JSValue target, const char *const prop);
static void Set(JSValue target, const char *const prop, JSValue value);
static void SetString(JSValue target, const char *const prop, const char *const value);
static void SetNumber(JSValue target, const char *const prop, const double value);
static void SetBoolean(JSValue target, const char *const prop, const bool value);
static void Set(JSValue target, const char *const prop, JSHandler handler);
static bool Del(JSValue target, const char *const prop);
static JSValue Call(JSValue target, const char *const prop, JSValue args[], JSSize size);
static JSValue Call(JSValue target, const char *const prop);
static JSValue Get(JSValue target, const char * const prop);
static char *GetString(JSValue target, const char * const prop);
static double GetNumber(JSValue target, const char * const prop);
static bool GetBoolean(JSValue target, const char * const prop);
static void Set(JSValue target, const char * const prop, JSValue value);
static void SetString(JSValue target, const char * const prop, const char * const value);
static void SetNumber(JSValue target, const char * const prop, const double value);
static void SetBoolean(JSValue target, const char * const prop, const bool value);
static void Set(JSValue target, const char * const prop, JSHandler handler);
static bool Del(JSValue target, const char * const prop);
static JSValue Call(JSValue target, const char * const prop, JSValue args[], JSSize size);
static JSValue Call(JSValue target, const char * const prop);
static bool GetNativePointer(JSValue target, void **nativePointer);
static void SetNativePointer(JSValue target, void *nativePointer);
static bool DelNativePointer(JSValue target);
@@ -69,11 +69,11 @@ public:
class JSGlobal final : public MemoryHeap {
public:
static JSValue Get();
static JSValue Get(const char *const prop);
static void Set(const char *const prop, JSValue value);
static void Del(const char *const props);
static JSValue Call(const char *const prop, JSValue args[], JSSize size);
static JSValue Call(const char *const prop);
static JSValue Get(const char * const prop);
static void Set(const char * const prop, JSValue value);
static void Del(const char * const props);
static JSValue Call(const char * const prop, JSValue args[], JSSize size);
static JSValue Call(const char * const prop);
};
class JSUndefined final : public MemoryHeap {