From f9c4f4cd2e05d99ab856da1edad4711255d9572e Mon Sep 17 00:00:00 2001 From: fupengfei001 Date: Mon, 3 Apr 2023 14:12:59 +0800 Subject: [PATCH 1/2] fupengfei6@huawei.com Signed-off-by: fupengfei001 --- .../src/generate/generateCommonUtil.ts | 20 +++++++++++++++++ .../generatePropertySignatureDeclaration.ts | 22 ++++++++++++------- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/mock-generate/src/generate/generateCommonUtil.ts b/mock-generate/src/generate/generateCommonUtil.ts index 8d933828..bdc2431c 100644 --- a/mock-generate/src/generate/generateCommonUtil.ts +++ b/mock-generate/src/generate/generateCommonUtil.ts @@ -346,3 +346,23 @@ export function generateSymbolIterator(methodEntity: MethodEntity): string { return iteratorMethod; } + +/** + * generate callback property + * @param kindName + * @returns + */ +export function getCallbackPropertyReturn(kindName: string): any { + const genericTypeName = kindName.split('<')[1].split('>')[0]; + if (genericTypeName === 'string') { + return `return ''`; + } else if (genericTypeName === 'number') { + return `return 0`; + } else if (genericTypeName === 'boolean') { + return `return true`; + } else if (genericTypeName === 'void') { + return ''; + } else { + return `return ${genericTypeName}`; + } +} \ No newline at end of file diff --git a/mock-generate/src/generate/generatePropertySignatureDeclaration.ts b/mock-generate/src/generate/generatePropertySignatureDeclaration.ts index c69fefba..51f6e727 100644 --- a/mock-generate/src/generate/generatePropertySignatureDeclaration.ts +++ b/mock-generate/src/generate/generatePropertySignatureDeclaration.ts @@ -17,7 +17,7 @@ import { SourceFile, SyntaxKind } from 'typescript'; import { PropertySignatureEntity } from '../declaration-node/propertySignatureDeclaration'; import { checkIsGenericSymbol, getCallbackStatement, getTheRealReferenceFromImport, - getWarnConsole, propertyTypeWhiteList + getWarnConsole, propertyTypeWhiteList, getCallbackPropertyReturn } from './generateCommonUtil'; /** @@ -46,15 +46,21 @@ export function generatePropertySignatureDeclaration(rootName: string, propertyS propertySignature.propertyTypeName === 'bool' || propertySignature.propertyTypeName === 'Data') { propertySignatureBody = `${propertySignature.propertyName}: '[PC Preview] unkonwn ${propertySignature.propertyName}',`; } else { - if (propertySignature.propertyTypeName.includes('<')) { - const preSplit = propertySignature.propertyTypeName.split('<'); - const genericArg = preSplit[preSplit.length - 1].split('>')[0]; - propertySignatureBody = `${propertySignature.propertyName}: ${genericArg},`; + if (propertySignature.propertyTypeName.includes('Callback') && propertySignature.propertyTypeName.includes('<') + && propertySignature.propertyTypeName.includes('>')) { + const retVal = getCallbackPropertyReturn(propertySignature.propertyTypeName); + propertySignatureBody = `${propertySignature.propertyName}: ()=>{ ${retVal} },`; } else { - if (propertyTypeWhiteList(propertySignature.propertyTypeName) === propertySignature.propertyTypeName) { - propertySignatureBody = `${propertySignature.propertyName}: ${getTheRealReferenceFromImport(sourceFile, propertySignature.propertyTypeName)},`; + if (propertySignature.propertyTypeName.includes('<')) { + const preSplit = propertySignature.propertyTypeName.split('<'); + const genericArg = preSplit[preSplit.length - 1].split('>')[0]; + propertySignatureBody = `${propertySignature.propertyName}: ${genericArg},`; } else { - propertySignatureBody = `${propertySignature.propertyName}: ${propertyTypeWhiteList(propertySignature.propertyTypeName)},`; + if (propertyTypeWhiteList(propertySignature.propertyTypeName) === propertySignature.propertyTypeName) { + propertySignatureBody = `${propertySignature.propertyName}: ${getTheRealReferenceFromImport(sourceFile, propertySignature.propertyTypeName)},`; + } else { + propertySignatureBody = `${propertySignature.propertyName}: ${propertyTypeWhiteList(propertySignature.propertyTypeName)},`; + } } } } -- Gitee From 512b24c531b23c70d111163754f9a7a485e2a98f Mon Sep 17 00:00:00 2001 From: fupengfei001 Date: Tue, 4 Apr 2023 15:45:25 +0800 Subject: [PATCH 2/2] fupengfei6@huawei.com Signed-off-by: fupengfei001 --- runtime/main/extend/systemplugin/napi/index.js | 6 ------ runtime/vdom/Element.ts | 7 ------- 2 files changed, 13 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index 2f6de647..d79cbefb 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -58,8 +58,6 @@ import { mockBatteryStatistics } from './ohos_batteryStatistics' import { mockIntl } from './ohos_intl' import { mockI18N } from './ohos_i18n' import { mockRpc } from './ohos_rpc' -import { mockWebgl } from './webgl/webgl' -import { mockWebgl2 } from './webgl/webgl2' import { mockProcess } from './ohos_process' import { mockUrl } from './ohos_url' import { mockHiAppEvent } from './ohos_hiAppEvent' @@ -386,10 +384,6 @@ export function mockRequireNapiFun() { return mockBatteryStatistics(); case "rpc": return mockRpc(); - case "webgl": - return mockWebgl(); - case "webgl2": - return mockWebgl2(); case "process": return mockProcess(); case "url": diff --git a/runtime/vdom/Element.ts b/runtime/vdom/Element.ts index 68083815..b0ee0856 100644 --- a/runtime/vdom/Element.ts +++ b/runtime/vdom/Element.ts @@ -34,8 +34,6 @@ import { FragBlockInterface, import Vm from '../main/model'; import { CSS_INHERITANCE } from '../main/app/bundle'; import {interceptCallback} from '../main/manage/event/callbackIntercept'; -import {mockWebgl} from '../main/extend/systemplugin/napi/webgl/webgl'; -import {mockWebgl2} from '../main/extend/systemplugin/napi/webgl/webgl2'; import { VmOptions } from '../main/model/vmOptions'; /** * Element is a basic class to describe a tree node in vdom. @@ -83,11 +81,6 @@ class Element extends Node { if (taskCenter) { // support aceapp callback style args = interceptCallback(args); - if (args[0] === 'webgl') { - return mockWebgl(); - } else if (args[0] === 'webgl2') { - return mockWebgl2(); - } const ret = taskCenter.send('component', { ref: this.ref, component: type, -- Gitee