idlize
58 строк · 2.0 Кб
1/*
2* Copyright (c) 2024 Huawei Device Co., Ltd.
3* Licensed under the Apache License, Version 2.0 (the "License");
4* you may not use this file except in compliance with the License.
5* You may obtain a copy of the License at
6*
7* http://www.apache.org/licenses/LICENSE-2.0
8*
9* Unless required by applicable law or agreed to in writing, software
10* distributed under the License is distributed on an "AS IS" BASIS,
11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12* See the License for the specific language governing permissions and
13* limitations under the License.
14*/
15
16import { PeerFile } from "./PeerFile"
17import { PeerMethod } from "./PeerMethod"
18import { DeclarationTable } from "./DeclarationTable"
19
20export interface PeerClassBase {
21setGenerationContext(context: string| undefined): void
22generatedName(isCallSignature: boolean): string
23
24// TBD: update
25getComponentName(): string
26}
27
28export class PeerClass implements PeerClassBase {
29constructor(
30public readonly file: PeerFile,
31public readonly componentName: string,
32public readonly originalFilename: string,
33public readonly declarationTable: DeclarationTable
34) { }
35
36setGenerationContext(context: string| undefined): void {
37this.declarationTable.setCurrentContext(context)
38}
39
40generatedName(isCallSignature: boolean): string{
41return isCallSignature ? this.originalInterfaceName! : this.originalClassName!
42}
43
44getComponentName(): string {
45return this.componentName
46}
47
48methods: PeerMethod[] = []
49
50originalClassName: string | undefined = undefined
51originalInterfaceName: string | undefined = undefined
52originalParentName: string | undefined = undefined
53originalParentFilename: string | undefined = undefined
54parentComponentName: string | undefined = undefined
55attributesFields: string[] = []
56attributesTypes: {typeName: string, content: string}[] = []
57hasGenericType: boolean = false
58}