idlize

Форк
0
65 строк · 2.3 Кб
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

16
import { IndentedPrinter } from "../../IndentedPrinter"
17
import { makeFileNameFromClassName } from "../FileGenerators"
18
import { MaterializedClass } from "../Materialized"
19
import { PeerClass } from "../PeerClass"
20
import { PeerLibrary } from "../PeerLibrary"
21

22

23
export class GniVisitor {
24
    gni = new IndentedPrinter()
25

26
    constructor(
27
        protected library: PeerLibrary
28
    ) { }
29

30
    printGniEntries(clazz: PeerClass): void {
31
        const className = makeFileNameFromClassName(clazz.componentName)
32
        this.gni.print(`"../arkoala/implementation/${className}_modifier.cpp",`)
33
    }
34

35
    printMaterializedClassSourcePaths(clazz: MaterializedClass) {
36
        const className = makeFileNameFromClassName(clazz.className)
37
        this.gni.print(`"../arkoala/implementation/${className}_modifier.cpp",`)
38
    }
39

40
    // TODO: have a proper Peer module visitor
41
    printGniSource() {
42
        this.gni.print("generated_sources = [")
43
        this.gni.pushIndent()
44
        this.library.files.forEach(file => {
45
            file.peers.forEach(clazz => this.printGniEntries(clazz))
46
        })
47
        this.library.materializedClasses.forEach(clazz => {
48
            this.printMaterializedClassSourcePaths(clazz)
49
        })
50

51
        this.gni.print(`"../arkoala/utility/converter.cpp",`)
52
        this.gni.print(`"../arkoala/implementation/view_model_bridge.cpp",`)
53
        this.gni.print(`"../arkoala/implementation/all_modifiers.cpp",`)
54
        this.gni.print(`"../arkoala/implementation/all_events.cpp",`)
55

56
        this.gni.popIndent()
57
        this.gni.print("]")
58
    }
59
}
60

61
export function printGniSources(peerLibrary: PeerLibrary): string {
62
    const visitor = new GniVisitor(peerLibrary)
63
    visitor.printGniSource()
64
    return visitor.gni.getOutput().join("\n")
65
}

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.