mirror of
https://gitee.com/openharmony/napi_generator
synced 2024-11-23 08:20:01 +00:00
del isOnflag
Signed-off-by: zhaojunxia <zhaojunxia@kaihong.com>
This commit is contained in:
parent
a52511c2c9
commit
aa41e04cc4
@ -190,22 +190,6 @@ function analyseSubReturn(ret, data, results) {
|
||||
return ret
|
||||
}
|
||||
|
||||
// 判断 注册的 type 的是否为interface
|
||||
function getCallbackInterface(type, results) {
|
||||
let allInterfaces = results.interface
|
||||
if (allInterfaces === null || allInterfaces === undefined || results.interface === null) {
|
||||
NapiLog.logError("Invalid param: allInterfaces")
|
||||
return null;
|
||||
}
|
||||
|
||||
for (let i in allInterfaces) {
|
||||
if (allInterfaces[i].name == type) {
|
||||
return allInterfaces[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**函数解析 */
|
||||
function analyzeFunction(data, isStatic, name, values, ret, results, interfaceName = '') {
|
||||
let res = analyzeFuncNoNameInterface(data, values, results)
|
||||
@ -264,13 +248,6 @@ function analyzeFunction(data, isStatic, name, values, ret, results, interfaceNa
|
||||
"ret": ret
|
||||
})
|
||||
}
|
||||
|
||||
// results中的interfaceName打标记标识为isOnCb
|
||||
// 获取注册关联的interface
|
||||
let interCb = getCallbackInterface(interfaceName, results);
|
||||
if (interCb) {
|
||||
interCb.isOnCb = true;
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
const { TestClass1, TestClass2, ModelEvent, TestClass3, on, off, TestClass4, TestClass5,
|
||||
TestClass6, TestClass7, TestClass10, TestClass11, TestClass12 } = require("./out/build/Release/napitest")
|
||||
TestClass6, TestClass7, TestClass10, TestClass11, TestClass12} = require("./out/build/Release/napitest")
|
||||
const testObj = require("./out/build/Release/napitest")
|
||||
var assert = require("assert");
|
||||
|
||||
@ -289,3 +289,33 @@ describe('test register/unRegister callback interface/type param is optional', f
|
||||
|
||||
});
|
||||
|
||||
class NodeISayHelloListenerImpl {
|
||||
listener = null;
|
||||
bb = "d";
|
||||
constructor(listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
onSayHelloStart(info) {
|
||||
console.log('----onSayHelloStart XXX', info);
|
||||
}
|
||||
onSayHelloEnd(info) {
|
||||
console.log('----onSayHelloEnd abc.', info);
|
||||
}
|
||||
}
|
||||
function onSayHelloStart(info) {
|
||||
console.log('----aaa bbb ccc onSayHelloStart xxx', info);
|
||||
}
|
||||
|
||||
describe('test Obj callback', function () {
|
||||
let nis = new testObj.NodeISayHello();
|
||||
// 注册回调
|
||||
it('test NodeISayHello addSayHelloListener', function () {
|
||||
nis.addSayHelloListener(new NodeISayHelloListenerImpl());
|
||||
});
|
||||
|
||||
it('test NodeISayHello sayHello', function () {
|
||||
nis.sayHello("js", "native", testObj.SayType.kInitiative);
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user