From 75f6ee4c3130309794084dd24da6e1979bfdd12d Mon Sep 17 00:00:00 2001 From: zhaojunxia Date: Wed, 26 Apr 2023 13:56:36 +0800 Subject: [PATCH] style: modify service tools code for codecheck Signed-off-by: zhaojunxia --- hdc/service/service-gen/src/gen/generate.js | 10 ++-- hdc/service/service-gen/src/tools/common.js | 52 ++++++++++----------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/hdc/service/service-gen/src/gen/generate.js b/hdc/service/service-gen/src/gen/generate.js index 945adeef..5132521a 100755 --- a/hdc/service/service-gen/src/gen/generate.js +++ b/hdc/service/service-gen/src/gen/generate.js @@ -20,7 +20,7 @@ const { iServiceHTemplate, proxyHTemplate, stubHTemplate, serviceHTemplate, prox proxyFuncTemplate, stubCppTemplate, stubInnerFuncTemplate, serviceCppTemplate, serviceFuncImplTemplate, clientCppTemplate, buildGnTemplate, bundleJsonTemplate, profileGnTemplate, profileXmlTemplate, serviceCfgTemplate, serviceCfgGnTemplate, iServiceCppTemplate } = require("./fileTemplate"); -const { DATA_W_MAP, DATA_R_MAP, VECTOR_W_MAP, VECTOR_R_MAP, getParcelType, AllParseFileList, MarshallInfo, +const { DATA_WRITE_MAP, DATA_READ_MAP, VECTOR_WRITE_MAP, VECTOR_READ_MAP, getParcelType, AllParseFileList, MarshallInfo, ProcessingClassList} = require("../tools/common"); let rootHFileSrc = ""; // .h文件的源码 @@ -330,7 +330,7 @@ function genClassWriteString(objName, parcelName, marshallInfo, classInfo) { function genVectorWrite(vectorName, parcelName, vecType, matchs) { let rawType = re.getReg(vecType, matchs.regs[2]); let parcelType = getParcelType(rawType); - let wFunc = VECTOR_W_MAP.get(parcelType); + let wFunc = VECTOR_WRITE_MAP.get(parcelType); if (!wFunc) { NapiLog.logError("Unsupport writing with type: " + vecType); return ""; @@ -353,7 +353,7 @@ function genWrite(srcName, parcelName, vType) { } let parcelType = getParcelType(vType); - let wFunc = DATA_W_MAP.get(parcelType); + let wFunc = DATA_WRITE_MAP.get(parcelType); if (!wFunc) { let result = findClassGenInfo(vType); if (!result[0] && !result[1]) { @@ -381,7 +381,7 @@ function genWrite(srcName, parcelName, vType) { function genVectorRead(parcelName, vectorName, vecType, matchs) { let rawType = re.getReg(vecType, matchs.regs[2]); let parcelType = getParcelType(rawType); - let rFunc = VECTOR_R_MAP.get(parcelType); + let rFunc = VECTOR_READ_MAP.get(parcelType); if (!rFunc) { NapiLog.logError("Unsupport reading with type: " + vecType); return ""; @@ -403,7 +403,7 @@ function genRead(parcelName, destObj) { } let parcelType = getParcelType(destObj.type); - let rFunc = DATA_R_MAP.get(parcelType); + let rFunc = DATA_READ_MAP.get(parcelType); if (!rFunc) { let result = findClassGenInfo(destObj.type); if (!result[0] && !result[1]) { diff --git a/hdc/service/service-gen/src/tools/common.js b/hdc/service/service-gen/src/tools/common.js index d241e6b2..c921d833 100755 --- a/hdc/service/service-gen/src/tools/common.js +++ b/hdc/service/service-gen/src/tools/common.js @@ -12,27 +12,27 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// remote消息中变量类型名(key)与对应的写parcel方法名(value)的映射(参考parcel.h) -const DATA_W_MAP = new Map( - [["bool", "WriteBoolUnaligned"], ["int8_t", "WriteInt8"], ["uint8_t", "ReadUint8"], - ["int16_t", "WriteInt16"], ["uint16_t", "WriteUint16"], - ["int32_t", "WriteInt32"], ["uint32_t", "WriteUint32"], ["int64_t", "WriteInt64"], ["uint64_t", "WriteUint64"], - ["float", "WriteFloat"], ["double", "WriteDouble"], ["char *", "WriteCString"], ["std::string", "WriteString"], - ["string", "WriteString"] -]); - // remote消息中变量类型名(key)与对应的读parcel方法名(value)的映射(参考parcel.h) -const DATA_R_MAP = new Map( - [["bool", "ReadBoolUnaligned"], ["int8_t", "ReadInt8"], ["uint8_t", "ReadUint8"], +const DATA_READ_MAP = new Map( + [["int8_t", "ReadInt8"], ["uint8_t", "ReadUint8"], ["int16_t", "ReadInt16"], ["uint16_t", "ReadUint16"], ["int32_t", "ReadInt32"], ["uint32_t", "ReadUint32"], ["int64_t", "ReadInt64"], ["uint64_t", "ReadUint64"], ["float", "ReadFloat"], ["double", "ReadDouble"], ["char *", "ReadCString"], ["std::string", "ReadString"], - ["string", "ReadString"] + ["string", "ReadString"], ["bool", "ReadBoolUnaligned"] +]); + +// remote消息中变量类型名(key)与对应的写parcel方法名(value)的映射(参考parcel.h) +const DATA_WRITE_MAP = new Map( + [["int8_t", "WriteInt8"], ["uint8_t", "ReadUint8"], + ["int16_t", "WriteInt16"], ["uint16_t", "WriteUint16"], + ["int32_t", "WriteInt32"], ["uint32_t", "WriteUint32"], ["int64_t", "WriteInt64"], ["uint64_t", "WriteUint64"], + ["float", "WriteFloat"], ["double", "WriteDouble"], ["char *", "WriteCString"], ["std::string", "WriteString"], + ["string", "WriteString"], ["bool", "WriteBoolUnaligned"] ]); // 常用类型转换表, 将C语言常见类型(key)转换为remote data读写函数使用的类型(value) // 例如 ErrCode 类型在框架中的系统原型为int类型,这里映射成int32_t, -// 因为int32_t类型在 DATA_W_MAP/DATA_R_MAP 表中有对应的读写数据方法(WriteInt32/ReadInt32) +// 因为int32_t类型在 DATA_WRITE_MAP/DATA_READ_MAP 表中有对应的读写数据方法(WriteInt32/ReadInt32) const TYPE_DEF_MAP = new Map( [["ErrCode", "int32_t"], ["char", "int8_t"], ["short", "int16_t"], ["int", "int32_t"], ["long", "int64_t"], ["unsigned char", "uint8_t"], ["unsigned short", "uint16_t"], ["unsigned int", "uint32_t"], @@ -40,22 +40,22 @@ const TYPE_DEF_MAP = new Map( ["long long", "double"], ["long double", "double"] ]); -// remote消息中vector变量类型名(key)与对应的写parcel方法名(value)的映射(参考parcel.h) -const VECTOR_W_MAP = new Map( - [["bool", "WriteBoolVector"], ["int8_t", "WriteInt8Vector"], ["uint8_t", "WriteUInt8Vector"], - ["int16_t", "WriteInt16Vector"], ["uint16_t", "WriteUInt16Vector"], ["int32_t", "WriteInt32Vector"], - ["uint32_t", "WriteUInt32Vector"], ["int64_t", "WriteInt64Vector"], ["uint64_t", "WriteUInt64Vector"], - ["float", "WriteFloatVector"], ["double", "WriteDoubleVector"], ["u16string", "WriteString16Vector"], - ["std::string", "WriteStringVector"], ["string", "WriteStringVector"] -]); - // remote消息中vector变量类型名(key)与对应的读parcel方法名(value)的映射(参考parcel.h) -const VECTOR_R_MAP = new Map( - [["bool", "ReadBoolVector"], ["int8_t", "ReadInt8Vector"], ["uint8_t", "ReadUInt8Vector"], +const VECTOR_READ_MAP = new Map( + [["int8_t", "ReadInt8Vector"], ["uint8_t", "ReadUInt8Vector"], ["int16_t", "ReadInt16Vector"], ["uint16_t", "ReadUInt16Vector"], ["int32_t", "ReadInt32Vector"], ["uint32_t", "ReadUInt32Vector"], ["int64_t", "ReadInt64Vector"], ["uint64_t", "ReadUInt64Vector"], ["float", "ReadFloatVector"], ["double", "ReadDoubleVector"], ["u16string", "ReadString16Vector"], - ["std::string", "ReadStringVector"], ["string", "ReadStringVector"] + ["std::string", "ReadStringVector"], ["string", "ReadStringVector"], ["bool", "ReadBoolVector"] +]); + +// remote消息中vector变量类型名(key)与对应的写parcel方法名(value)的映射(参考parcel.h) +const VECTOR_WRITE_MAP = new Map( + [["int8_t", "WriteInt8Vector"], ["uint8_t", "WriteUInt8Vector"], + ["int16_t", "WriteInt16Vector"], ["uint16_t", "WriteUInt16Vector"], ["int32_t", "WriteInt32Vector"], + ["uint32_t", "WriteUInt32Vector"], ["int64_t", "WriteInt64Vector"], ["uint64_t", "WriteUInt64Vector"], + ["float", "WriteFloatVector"], ["double", "WriteDoubleVector"], ["u16string", "WriteString16Vector"], + ["std::string", "WriteStringVector"], ["string", "WriteStringVector"], ["bool", "WriteBoolVector"] ]); function getParcelType(srcType) { @@ -123,7 +123,7 @@ ProcessingClassList.findByName = function (className) { } module.exports = { - DATA_W_MAP, DATA_R_MAP, VECTOR_W_MAP, VECTOR_R_MAP, getParcelType, AllParseFileList, MarshallInfo, + DATA_WRITE_MAP, DATA_READ_MAP, VECTOR_WRITE_MAP, VECTOR_READ_MAP, getParcelType, AllParseFileList, MarshallInfo, ProcessingClassList } -- Gitee