mirror of
https://gitee.com/openharmony/napi_generator
synced 2024-11-23 08:20:01 +00:00
adapt to modify unittest cases
Signed-off-by: gou-jingjing <goujingjing@kaihong.com>
This commit is contained in:
parent
229514d470
commit
f3b970c1cd
@ -115,7 +115,7 @@ describe('enum second part', function () {
|
||||
});
|
||||
});
|
||||
|
||||
// ネ<EFBFBD>ホメ<EFBFBD>」イ簗ヤ
|
||||
// Input exception testing
|
||||
describe('enum third part', function () {
|
||||
// function fun1(v0: string, v1: GrantStatus): GrantStatus;
|
||||
it('test fun1 exception ', function () {
|
||||
@ -176,6 +176,6 @@ describe('enum third part', function () {
|
||||
}
|
||||
assert.strictEqual(ret3, true)
|
||||
});
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
@ -207,8 +207,8 @@ function partOfFunctionTwo() {
|
||||
let data = "if_direct(v1: string, v2: boolean): string;";
|
||||
let ret = analyzeFunction(data, false, `if_direct`, "v1: string, v2: boolean", "asdfgh");
|
||||
let retJson = JSON.stringify(ret);
|
||||
let str1 = "{\"name\":\"v1\",\"type\":\"string\",\"optional\":false},";
|
||||
let str2 = "{\"name\":\"v2\",\"type\":\"boolean\",\"optional\":false}";
|
||||
let str1 = "{\"name\":\"v1\",\"type\":\"string\",\"optional\":false,\"realType\":\"string\"},";
|
||||
let str2 = "{\"name\":\"v2\",\"type\":\"boolean\",\"optional\":false,\"realType\":\"boolean\"}";
|
||||
let retValue = retJson.search(str1 + str2)
|
||||
assert.strictEqual(retValue > 0, true);
|
||||
let retName = retJson.search("\"name\":\"if_direct\"");
|
||||
@ -221,8 +221,8 @@ function partOfFunctionTwo() {
|
||||
let data = "if_async(v1: string, cb: AsyncCallback<string>): string;";
|
||||
let ret = analyzeFunction(data, false, `if_async`, "v1: string, cb: AsyncCallback<string>", "qwerty");
|
||||
let retJson = JSON.stringify(ret)
|
||||
let str1 = "{\"name\":\"v1\",\"type\":\"string\",\"optional\":false},";
|
||||
let str2 = "{\"name\":\"cb\",\"type\":\"AsyncCallback<string>\",\"optional\":false}";
|
||||
let str1 = "{\"name\":\"v1\",\"type\":\"string\",\"optional\":false,\"realType\":\"string\"},";
|
||||
let str2 = "{\"name\":\"cb\",\"type\":\"AsyncCallback<string>\",\"optional\":false,\"realType\":\"AsyncCallback<string>\"}";
|
||||
let retValue = retJson.search(str1 + str2)
|
||||
assert.strictEqual(retValue > 0, true);
|
||||
let retName = retJson.search("\"name\":\"if_async\"")
|
||||
@ -258,15 +258,15 @@ function partOfInterface(correctResult) {
|
||||
let valueArray = retJson.substring(retJson.indexOf("\[") + 1, retJson.indexOf("\]")).split("}");
|
||||
let numContain = valueArray[0].indexOf("\"name\":\"num1\",\"type\":\"NUMBER_TYPE_");
|
||||
assert.strictEqual(numContain > 0, true);
|
||||
assert.strictEqual(valueArray[1], ",{\"name\":\"str1\",\"type\":\"string\",\"optional\":false");
|
||||
assert.strictEqual(valueArray[2], ",{\"name\":\"bool1\",\"type\":\"boolean\",\"optional\":false");
|
||||
assert.strictEqual(valueArray[1], ",{\"name\":\"str1\",\"type\":\"string\",\"realType\":\"string\",\"optional\":false");
|
||||
assert.strictEqual(valueArray[2], ",{\"name\":\"bool1\",\"type\":\"boolean\",\"realType\":\"boolean\",\"optional\":false");
|
||||
let numArrayCon = valueArray[3].indexOf("\"name\":\"nums\",\"type\":\"Array<NUMBER_TYPE_");
|
||||
assert.strictEqual(numArrayCon > 0, true);
|
||||
assert.strictEqual(valueArray[4], ",{\"name\":\"strs\",\"type\":\"Array<string>\",\"optional\":false");
|
||||
assert.strictEqual(valueArray[5], ",{\"name\":\"bools\",\"type\":\"Array<boolean>\",\"optional\":false");
|
||||
assert.strictEqual(valueArray[4], ",{\"name\":\"strs\",\"type\":\"Array<string>\",\"realType\":\"Array<string>\",\"optional\":false");
|
||||
assert.strictEqual(valueArray[5], ",{\"name\":\"bools\",\"type\":\"Array<boolean>\",\"realType\":\"Array<boolean>\",\"optional\":false");
|
||||
let numMapCon = valueArray[6].indexOf("\"name\":\"mapNum\",\"type\":\"Map<string,NUMBER_TYPE_");
|
||||
assert.strictEqual(numMapCon > 0, true);
|
||||
assert.strictEqual(valueArray[7], ",{\"name\":\"mapStr\",\"type\":\"Map<string,string>\",\"optional\":false");
|
||||
assert.strictEqual(valueArray[7], ",{\"name\":\"mapStr\",\"type\":\"Map<string,string>\",\"realType\":\"Map<string,string>\",\"optional\":false");
|
||||
let mapNumCon = retJson.indexOf("\"name\":\"mapNum2\",\"type\":\"{[key:string]:NUMBER_TYPE_");
|
||||
assert.strictEqual(mapNumCon > 0, true);
|
||||
let mapStrCon = retJson.indexOf("\"name\":\"mapStr2\",\"type\":\"{[key:string]:string}");
|
||||
@ -276,8 +276,8 @@ function partOfInterface(correctResult) {
|
||||
let asyncExit = retJson.search("\"name\":\"if_async\",\"type\":4")
|
||||
assert.strictEqual(asyncExit > 0, true);
|
||||
let asyncArray = retJson.substring(retJson.lastIndexOf("\[") + 1, retJson.lastIndexOf("\]")).split("}");
|
||||
assert.strictEqual(asyncArray[0], "{\"name\":\"v1\",\"type\":\"string\",\"optional\":false");
|
||||
assert.strictEqual(asyncArray[1], ",{\"name\":\"cb\",\"type\":\"AsyncCallback<string>\",\"optional\":false");
|
||||
assert.strictEqual(asyncArray[0], "{\"name\":\"v1\",\"type\":\"string\",\"optional\":false,\"realType\":\"string\"");
|
||||
assert.strictEqual(asyncArray[1], ",{\"name\":\"cb\",\"type\":\"AsyncCallback<string>\",\"optional\":false,\"realType\":\"AsyncCallback<string>\"");
|
||||
assert.strictEqual(asyncArray[2], "],\"ret\":\"string\",\"isStatic\":false");
|
||||
});
|
||||
}
|
||||
@ -321,7 +321,7 @@ function partOfNamespace(correctResult) {
|
||||
let qiePianStart = interResult.lastIndexOf("function") - 1;
|
||||
let qiepianEnd = interResult.lastIndexOf("parentNameList")-2;
|
||||
let interFun = interResult.substring(qiePianStart, qiepianEnd);
|
||||
let interValue = "\"value\":[{\"name\":\"v1\",\"type\":\"string\",\"optional\":false}],";
|
||||
let interValue = "\"value\":[{\"name\":\"v1\",\"type\":\"string\",\"optional\":false,\"realType\":\"string\"}],";
|
||||
let interRet = "\"ret\":\"string\","
|
||||
let interIsStatic = "\"isStatic\":false\}]"
|
||||
let funcResult = "\"function\":[{\"name\":\"fix\",\"type\":1," + interValue + interRet + interIsStatic;
|
||||
@ -344,7 +344,7 @@ function partOfNamespace(correctResult) {
|
||||
let qiePianStart = nameResult.lastIndexOf("\"function\"");
|
||||
let funcResult = nameResult.substring(qiePianStart, nameResult.lastIndexOf("\"interface\"") - 2);
|
||||
assert.strictEqual(funcResult.search("\"name\":\"fun1\",\"type\":1") > 0, true)
|
||||
assert.strictEqual(funcResult.search("{\"name\":\"v\",\"type\":\"string\",\"optional\":false}") > 0, true)
|
||||
assert.strictEqual(funcResult.search("{\"name\":\"v\",\"type\":\"string\",\"optional\":false,\"realType\":\"string\"}") > 0, true)
|
||||
});
|
||||
|
||||
partOfNamespaceTwo(correctResult);
|
||||
|
@ -699,12 +699,12 @@ function jsToCParamArray() {
|
||||
function jsToCParamMap() {
|
||||
let value = 'uint32_t len = pxt->GetMapLength(b);\n' +
|
||||
'for (uint32_t i = 0; i < len; i++) {\n' +
|
||||
' std::string tt;\n' +
|
||||
' std::string tt1;\n' +
|
||||
' bool tt1;\n' +
|
||||
' pxt->SwapJs2CUtf8(pxt->GetMapElementName(b, i), tt);\n' +
|
||||
' tt1 = pxt->SwapJs2CBool(pxt->GetMapElementValue(b, tt.c_str()));\n' +
|
||||
' pxt->SwapJs2CUtf8(pxt->GetMapElementName(b, i), tt1);\n' +
|
||||
' tt1 = pxt->SwapJs2CBool(pxt->GetMapElementValue(b, tt1.c_str()));\n' +
|
||||
'\n' +
|
||||
' a.insert(std::make_pair(tt, tt1));\n' +
|
||||
' a.insert(std::make_pair(tt1, tt1));\n' +
|
||||
'}'
|
||||
return value
|
||||
}
|
||||
@ -717,7 +717,8 @@ function jsToCParamMap1() {
|
||||
// ' [replace_swap]\n' +
|
||||
// ' a.insert(std::make_pair(tt, tt1));\n' +
|
||||
// '}'
|
||||
let value = "uint32_t len = pxt->GetMapLength(b);\nfor (uint32_t i = 0; i < len; i++) {\n std::string tt0;\n number tt1;\n [replace_swap]\n a.insert(std::make_pair(tt0, tt1));\n}"
|
||||
// let value = "uint32_t len = pxt->GetMapLength(b);\nfor (uint32_t i = 0; i < len; i++) {\n std::string tt0;\n number tt1;\n [replace_swap]\n a.insert(std::make_pair(tt0, tt1));\n}"
|
||||
let value = "uint32_t len = pxt->GetMapLength(b);\nfor (uint32_t i = 0; i < len; i++) {\n std::string tt1;\n number tt1;\n [replace_swap]\n a.insert(std::make_pair(tt1, tt1));\n}"
|
||||
return value
|
||||
}
|
||||
|
||||
@ -1305,7 +1306,7 @@ function paramGenerateAndAssert(dataType) {
|
||||
interface: [],
|
||||
namespace: []
|
||||
}
|
||||
let funcValue = { name: "v", type: dataType, optional: false }
|
||||
let funcValue = { name: "v", type: dataType, optional: false, realType: dataType }
|
||||
if (null != data) {
|
||||
paramGenerate(0, funcValue, param, data)
|
||||
} else {
|
||||
|
@ -56,7 +56,7 @@
|
||||
"anyTempleteFunc": "\"vio->in0_type = pxt->GetAnyType(pxt->GetArgv(XNapiTool::ZERO));\\npxt->SetAnyValue(vio->in0_type, pxt->GetArgv(XNapiTool::ZERO), vio->in0);\\n\"",
|
||||
"objectTempleteFunc": "\"uint32_t len = pxt->GetMapLength(pxt->GetArgv(XNapiTool::ZERO));\\nfor (uint32_t i = 0; i < len; i++) {\\nstd::string tt;\\nstd::any tt;\\npxt->SwapJs2CUtf8(pxt->GetMapElementName(pxt->GetArgv(XNapiTool::ZERO), i), tt);\\nnapi_value valueObj = pxt->GetMapElementValue(pxt->GetArgv(XNapiTool::ZERO), tt.c_str());\\nstd::string valueObjType = pxt->GetAnyType(valueObj);\\nif (valueObjType == \\\"string\\\") {\\nstd::string tt;\\npxt->SwapJs2CUtf8(valueObj, tt);\\ntt = tt;\\n} else if (valueObjType == \\\"boolean\\\") {\\nbool tt;\\ntt = pxt->SwapJs2CBool(valueObj);\\ntt = tt;\\n} else if (valueObjType == \\\"number\\\") {\\nNUMBER_JS_2_C(valueObj, NUMBER_TYPE_, tt);\\n} else if (valueObjType == \\\"arr_string\\\") {\\nuint32_t len = pxt->GetArrayLength(valueObj);\\nstd::vector<std::string> arr;\\nfor(uint32_t i = 0; i < len; i++) {\\nnapi_value arr_value_result;\\nnapi_get_element(env, valueObj, i, &arr_value_result);\\nstd::string tt;\\npxt->SwapJs2CUtf8(arr_value_result, tt);\\narr.push_back(tt);\\n}\\ntt = arr;\\n} else if (valueObjType == \\\"arr_boolean\\\") {\\nuint32_t len = pxt->GetArrayLength(valueObj);\\nstd::vector<bool> arr;\\nfor(uint32_t i = 0; i < len; i++) {\\nnapi_value arr_value_result;\\nnapi_get_element(env, valueObj, i, &arr_value_result);\\nbool tt;\\ntt = pxt->SwapJs2CBool(arr_value_result);\\narr.push_back(tt);\\n}\\ntt = arr;\\n} else if (valueObjType == \\\"arr_number\\\") {\\nuint32_t len = pxt->GetArrayLength(valueObj);\\nstd::vector<NUMBER_TYPE_> arr;\\nfor(uint32_t i = 0; i < len; i++) {\\nnapi_value arr_value_result;\\nNUMBER_TYPE_ tt;\\nnapi_get_element(env, valueObj, i, &arr_value_result);\\nNUMBER_JS_2_C(arr_value_result, NUMBER_TYPE_, tt);\\narr.push_back(tt);\\n}\\ntt = arr;\\n\\n} else if (valueObjType == \\\"map_string\\\" || valueObjType == \\\"map_number\\\" || valueObjType == \\\"map_boolean\\\") {\\nnapi_value obj_name_value;\\nnapi_value obj_name_result;\\nnapi_valuetype obj_name_type;\\nnapi_get_property_names (env, valueObj, &obj_name_value);\\nuint32_t ret;\\nnapi_get_array_length(env, obj_name_value, &ret);\\nstd::vector<std::any> anyValue;\\nfor(uint32_t i = 0; i < ret; i++) {\\nnapi_get_element (env, obj_name_value, i, &obj_name_result);\\nnapi_typeof(env, obj_name_result, &obj_name_type);\\nif (obj_name_type == napi_string) {\\nnapi_value obj_value;\\nnapi_valuetype obj_value_type;\\nstd::string obj_name_string;\\npxt->SwapJs2CUtf8(obj_name_result, obj_name_string);\\nnapi_get_named_property (env, valueObj, obj_name_string.c_str(), &obj_value);\\nnapi_typeof(env, obj_value, &obj_value_type);\\nstd::map<std::string, std::any> anyValueMap;\\nif (obj_value_type == napi_string) {\\nstd::string tt;\\npxt->SwapJs2CUtf8(obj_value, tt);\\nanyValueMap.insert(std::make_pair(obj_name_string, tt));\\nanyValue.push_back(anyValueMap);\\n} else if (obj_value_type == napi_number) {\\nNUMBER_TYPE_ tt;\\nNUMBER_JS_2_C(obj_value, NUMBER_TYPE_, tt );\\nanyValueMap.insert(std::make_pair(obj_name_string, tt));\\nanyValue.push_back(anyValueMap);\\n} else if (obj_value_type == napi_boolean) {\\nbool tt;\\ntt = pxt->SwapJs2CBool(obj_value);\\nanyValueMap.insert(std::make_pair(obj_name_string, tt));\\nanyValue.push_back(anyValueMap);\\n}\\n}\\n}\\ntt = anyValue;\\n\\n}\\n\\nvio->in0.insert(std::make_pair(tt, tt));\\n}\\n\"",
|
||||
"unionTempleteFunc": "\"vio->in0_type = pxt->GetUnionType(pxt->GetArgv(XNapiTool::ZERO));\\nif (vio->in0_type == \\\"string\\\") {\\nstd::string union_string;\\npxt->SwapJs2CUtf8(pxt->GetArgv(XNapiTool::ZERO), union_string);\\nvio->in0 = union_string;\\n}\\nif (vio->in0_type == \\\"number\\\") {\\nstd::uint32_t union_number;\\nNUMBER_JS_2_C(pxt->GetArgv(XNapiTool::ZERO), NUMBER_TYPE_1, union_number);\\nvio->in0 = union_number;\\n}\\nif (vio->in0_type == \\\"boolean\\\") {\\nbool union_boolean;\\nBOOLEAN_JS_2_C(pxt->GetArgv(XNapiTool::ZERO), bool, union_boolean);\\n\\nvio->in0 = union_boolean;\\n}\\n\"",
|
||||
"generateNamespace":"{\"implH\":\"\\nnamespacenapitest{\\nnamespacenapitest_interface{\\nclassTestInterface;\\r\\nenumclassTestEnum{\\nname=0,\\n};\\n\\nclassTestInterface{\\npublic:\\nNUMBER_TYPE_1age;\\n\\n};\\n\\nboolfun1(std::vector<std::string>&v,std::string&out);\\n}\\n}\",\"implCpp\":\"\\nnamespacenapitest{\\nnamespacenapitest_interface{\\n\\nboolfun1(std::vector<std::string>&v,std::string&out)\\n{\\n\\nreturntrue;\\n}\\n\\n}\\n}\",\"middleBody\":\"\\nnamespacenapitest{\\nnamespacenapitest_interface{\\nnapi_valueTestInterface_middle::constructor(napi_envenv,napi_callback_infoinfo)\\n{\\nXNapiTool*pxt=newXNapiTool(env,info);\\nnapi_statusstatus;\\nsize_targc;\\nstatus=napi_get_cb_info(env,info,&argc,nullptr,nullptr,nullptr);\\nif(argc>0){\\nnapi_valueargs[argc];\\nstatus=napi_get_cb_info(env,info,&argc,args,nullptr,nullptr);\\nif(status!=napi_ok){\\nreturnnullptr;\\n}\\nstructconstructor_value_struct*vio=newconstructor_value_struct();\\n\\nTestInterface*p=newTestInterface();\\nnapi_valuethisvar=pxt->WrapInstance(reinterpret_cast<DataPtr>(p),TestInterface_middle::release);\\ndeletevio;\\nreturnthisvar;\\n}else{\\nTestInterface*p=newTestInterface();\\nnapi_valuethisvar=pxt->WrapInstance(reinterpret_cast<DataPtr>(p),TestInterface_middle::release);\\nreturnthisvar;\\n}\\n}\\nvoidTestInterface_middle::release(DataPtrp)\\n{\\nvoid*dataPtr=p;\\nTestInterface*p2=static_cast<TestInterface*>(dataPtr);\\ndeletep2;\\n}\\n\\nnapi_valueTestInterface_middle::getvalue_age(napi_envenv,napi_callback_infoinfo)\\n{\\nXNapiTool*pxt=std::make_unique<XNapiTool>(env,info).release();\\nvoid*instPtr=pxt->UnWarpInstance();\\nTestInterface*p=static_cast<TestInterface*>(instPtr);\\nnapi_valueresult=nullptr;\\nresult=NUMBER_C_2_JS(pxt,p->age);\\n\\ndeletepxt;\\nreturnresult;\\n}\\nnapi_valueTestInterface_middle::setvalue_age(napi_envenv,napi_callback_infoinfo)\\n{\\nstd::shared_ptr<XNapiTool>pxt=std::make_shared<XNapiTool>(env,info);\\nvoid*instPtr=pxt->UnWarpInstance();\\nTestInterface*p=static_cast<TestInterface*>(instPtr);\\nNUMBER_JS_2_C(pxt->GetArgv(XNapiTool::ZERO),NUMBER_TYPE_1,p->age);\\nreturnnullptr;\\n}\\n\\nnapi_valuefun1_middle(napi_envenv,napi_callback_infoinfo)\\n{\\nXNapiTool*pxt=std::make_unique<XNapiTool>(env,info).release();\\nif(pxt->IsFailed()){\\nnapi_valueerr=pxt->GetError();\\ndeletepxt;\\nreturnerr;\\n}\\n\\nstructfun1_value_struct*vio=newfun1_value_struct();\\nuint32_tlen=pxt->GetArrayLength(pxt->GetArgv(XNapiTool::ZERO));\\nfor(uint32_ti=0;i<len;i++){\\nstd::stringtt;\\npxt->SwapJs2CUtf8(pxt->GetArrayElement(pxt->GetArgv(XNapiTool::ZERO),i),tt);\\nvio->in0.push_back(tt);\\n}\\n\\nfun1(vio->in0,vio->out);\\nnapi_valueresult=nullptr;\\nresult=pxt->SwapC2JsUtf8(vio->out.c_str());\\n\\ndeletevio;\\ndeletepxt;//release\\nreturnresult;\\n}\\n}\\n}\",\"middleInit\":\"std::map<constchar*,std::any>enumMapTestEnum;\\nenumMapTestEnum[\\\"name\\\"]=0;\\npxt->CreateEnumObject(\\\"TestEnum\\\",enumMapTestEnum);\\n{\\nstd::map<constchar*,std::map<constchar*,napi_callback>>valueList;\\nvalueList[\\\"age\\\"][\\\"getvalue\\\"]=napitest::napitest_interface::TestInterface_middle::getvalue_age;\\nvalueList[\\\"age\\\"][\\\"setvalue\\\"]=napitest::napitest_interface::TestInterface_middle::setvalue_age;\\nstd::map<constchar*,napi_callback>funcList;\\npxt->DefineClass(\\\"TestInterface\\\",napitest::napitest_interface::TestInterface_middle::constructor,\\nvalueList,funcList);\\n}\\npxt->DefineFunction(\\\"fun1\\\",napitest::napitest_interface::fun1_middle);\\n\",\"middleH\":\"\\nnamespacenapitest{\\nnamespacenapitest_interface{\\nclassTestInterface_middle{\\npublic:\\nstructconstructor_value_struct{\\n};\\nstaticnapi_valueconstructor(napi_envenv,napi_callback_infoinfo);\\nstaticvoidrelease(DataPtrp);\\n\\nstaticnapi_valuegetvalue_age(napi_envenv,napi_callback_infoinfo);\\nstaticnapi_valuesetvalue_age(napi_envenv,napi_callback_infoinfo);\\n\\n};\\n\\nstructfun1_value_struct{\\nstd::vector<std::string>in0;\\nstd::stringout;\\n\\n};\\n\\nnapi_valuefun1_middle(napi_envenv,napi_callback_infoinfo);\\n\\n}\\n}\"}",
|
||||
"generateNamespace":"{\"implH\":\"\\nnamespacenapitest{\\nnamespacenapitest_interface{\\nclassTestInterface;\\r\\nenumclassTestEnum{\\nname=0,\\n};\\n\\nclassTestInterface{\\npublic:\\nNUMBER_TYPE_1age;\\n\\n};\\n\\nboolfun1(std::vector<std::string>&v,std::string&out);\\n}\\n}\",\"implCpp\":\"\\nnamespacenapitest{\\nnamespacenapitest_interface{\\n\\nboolfun1(std::vector<std::string>&v,std::string&out)\\n{\\n\\nreturntrue;\\n}\\n\\n}\\n}\",\"middleBody\":\"\\nnamespacenapitest{\\nnamespacenapitest_interface{\\nstd::map<constchar*,std::any>enumMapTestEnum;\\n\\nnapi_valueTestInterface_middle::constructor(napi_envenv,napi_callback_infoinfo)\\n{\\nXNapiTool*pxt=newXNapiTool(env,info);\\nnapi_statusstatus;\\nsize_targc;\\nstatus=napi_get_cb_info(env,info,&argc,nullptr,nullptr,nullptr);\\nif(argc>0){\\nnapi_valueargs[argc];\\nstatus=napi_get_cb_info(env,info,&argc,args,nullptr,nullptr);\\nif(status!=napi_ok){\\nreturnnullptr;\\n}\\nstructconstructor_value_struct*vio=newconstructor_value_struct();\\n\\nTestInterface*p=newTestInterface();\\nnapi_valuethisvar=pxt->WrapInstance(reinterpret_cast<DataPtr>(p),TestInterface_middle::release);\\ndeletevio;\\nreturnthisvar;\\n}else{\\nTestInterface*p=newTestInterface();\\nnapi_valuethisvar=pxt->WrapInstance(reinterpret_cast<DataPtr>(p),TestInterface_middle::release);\\nreturnthisvar;\\n}\\n}\\nvoidTestInterface_middle::release(DataPtrp)\\n{\\nvoid*dataPtr=p;\\nTestInterface*p2=static_cast<TestInterface*>(dataPtr);\\ndeletep2;\\n}\\n\\nnapi_valueTestInterface_middle::getvalue_age(napi_envenv,napi_callback_infoinfo)\\n{\\nXNapiTool*pxt=std::make_unique<XNapiTool>(env,info).release();\\nvoid*instPtr=pxt->UnWarpInstance();\\nTestInterface*p=static_cast<TestInterface*>(instPtr);\\nnapi_valueresult=nullptr;\\nresult=NUMBER_C_2_JS(pxt,p->age);\\n\\ndeletepxt;\\nreturnresult;\\n}\\nnapi_valueTestInterface_middle::setvalue_age(napi_envenv,napi_callback_infoinfo)\\n{\\nstd::shared_ptr<XNapiTool>pxt=std::make_shared<XNapiTool>(env,info);\\nvoid*instPtr=pxt->UnWarpInstance();\\nTestInterface*p=static_cast<TestInterface*>(instPtr);\\nNUMBER_JS_2_C(pxt->GetArgv(XNapiTool::ZERO),NUMBER_TYPE_1,p->age);\\nreturnnullptr;\\n}\\n\\nnapi_valuefun1_middle(napi_envenv,napi_callback_infoinfo)\\n{\\nXNapiTool*pxt=std::make_unique<XNapiTool>(env,info).release();\\nif(pxt->IsFailed()){\\nnapi_valueerr=pxt->GetError();\\ndeletepxt;\\nreturnerr;\\n}\\n\\nstructfun1_value_struct*vio=newfun1_value_struct();\\nuint32_tlen=pxt->GetArrayLength(pxt->GetArgv(XNapiTool::ZERO));\\nfor(uint32_ti=0;i<len;i++){\\nstd::stringtt;\\npxt->SwapJs2CUtf8(pxt->GetArrayElement(pxt->GetArgv(XNapiTool::ZERO),i),tt);\\nvio->in0.push_back(tt);\\n}\\n\\nfun1(vio->in0,vio->out);\\nnapi_valueresult=nullptr;\\nresult=pxt->SwapC2JsUtf8(vio->out.c_str());\\n\\ndeletevio;\\ndeletepxt;//release\\nreturnresult;\\n}\\n}\\n}\",\"middleInit\":\"napitest::napitest_interface::enumMapTestEnum[\\\"name\\\"]=0;\\npxt->CreateEnumObject(\\\"TestEnum\\\",napitest::napitest_interface::enumMapTestEnum);\\n{\\nstd::map<constchar*,std::map<constchar*,napi_callback>>valueList;\\nvalueList[\\\"age\\\"][\\\"getvalue\\\"]=napitest::napitest_interface::TestInterface_middle::getvalue_age;\\nvalueList[\\\"age\\\"][\\\"setvalue\\\"]=napitest::napitest_interface::TestInterface_middle::setvalue_age;\\nstd::map<constchar*,napi_callback>funcList;\\npxt->DefineClass(\\\"TestInterface\\\",napitest::napitest_interface::TestInterface_middle::constructor,\\nvalueList,funcList);\\n}\\npxt->DefineFunction(\\\"fun1\\\",napitest::napitest_interface::fun1_middle);\\n\",\"middleH\":\"\\nnamespacenapitest{\\nnamespacenapitest_interface{\\nclassTestInterface_middle{\\npublic:\\nstructconstructor_value_struct{\\n};\\nstaticnapi_valueconstructor(napi_envenv,napi_callback_infoinfo);\\nstaticvoidrelease(DataPtrp);\\n\\nstaticnapi_valuegetvalue_age(napi_envenv,napi_callback_infoinfo);\\nstaticnapi_valuesetvalue_age(napi_envenv,napi_callback_infoinfo);\\n\\n};\\n\\nstructfun1_value_struct{\\nstd::vector<std::string>in0;\\nstd::stringout;\\n\\n};\\n\\nnapi_valuefun1_middle(napi_envenv,napi_callback_infoinfo);\\n\\n}\\n}\"}",
|
||||
"ParamGenerate1": "\"{\\\"optionalParamDestory\\\":\\\"\\\",\\\"valueCheckout\\\":\\\"NUMBER_JS_2_C(pxt->GetArgv(XNapiTool::ZERO), NUMBER_TYPE_1, vio->in0);\\\\n\\\",\\\"valueDefine\\\":\\\"NUMBER_TYPE_1& v\\\",\\\"valueFill\\\":\\\"vio->in0\\\",\\\"valueIn\\\":\\\"\\\\nNUMBER_TYPE_1 in0;\\\",\\\"valueOut\\\":\\\"\\\",\\\"valuePackage\\\":\\\"\\\"}\"",
|
||||
"ParamGenerate2": "\"{\\\"optionalParamDestory\\\":\\\"\\\",\\\"valueCheckout\\\":\\\"BOOLEAN_JS_2_C(pxt->GetArgv(XNapiTool::ZERO), bool, vio->in0);\\\\n\\\\n\\\",\\\"valueDefine\\\":\\\"bool& v\\\",\\\"valueFill\\\":\\\"vio->in0\\\",\\\"valueIn\\\":\\\"\\\\nbool in0;\\\",\\\"valueOut\\\":\\\"\\\",\\\"valuePackage\\\":\\\"\\\"}\"",
|
||||
"ParamGenerate3": "\"{\\\"optionalParamDestory\\\":\\\"\\\",\\\"valueCheckout\\\":\\\"uint32_t len = pxt->GetArrayLength(pxt->GetArgv(XNapiTool::ZERO));\\\\nfor (uint32_t i = 0; i < len; i++) {\\\\nstd::string tt;\\\\npxt->SwapJs2CUtf8(pxt->GetArrayElement(pxt->GetArgv(XNapiTool::ZERO), i), tt);\\\\nvio->in0.push_back(tt);\\\\n}\\\\n\\\",\\\"valueDefine\\\":\\\"std::vector<std::string>&v\\\",\\\"valueFill\\\":\\\"vio->in0\\\",\\\"valueIn\\\":\\\"\\\\nstd::vector<std::string> in0;\\\",\\\"valueOut\\\":\\\"\\\",\\\"valuePackage\\\":\\\"\\\"}\"",
|
||||
|
Loading…
Reference in New Issue
Block a user