idlize

Форк
0
/
NativeModule_template.ts 
147 строк · 5.2 Кб
1
import { NativeModuleEmpty } from "./NativeModuleEmpty"
2
import {
3
  NativeStringBase,
4
  providePlatformDefinedData,
5
  nullptr,
6
  Access,
7
  withByteArray,
8
  CallbackRegistry,
9
  ArrayDecoder
10
} from "@koalaui/interop"
11

12
export type NodePointer = pointer
13
export type PipelineContext = pointer
14

15
let theModule: NativeModule | undefined = undefined
16

17
declare const LOAD_NATIVE: NativeModule
18

19
export function nativeModule(): NativeModule {
20
    if (theModule) return theModule
21
    if (%USE_EMPTY%)
22
        theModule = new NativeModuleEmpty()
23
    else
24
        theModule = LOAD_NATIVE as NativeModule
25
    return theModule
26
}
27

28
class NativeString extends NativeStringBase {
29
    constructor(ptr: KPointer) {
30
        super(ptr)
31
    }
32
    protected bytesLength(): int32 {
33
        return nativeModule()._StringLength(this.ptr)
34
    }
35
    protected getData(data: Uint8Array): void {
36
        withByteArray(data, Access.WRITE, (dataPtr: KUint8ArrayPtr) => {
37
            nativeModule()._StringData(this.ptr, dataPtr, data.length)
38
        })
39
    }
40
    close(): void {
41
        nativeModule()._InvokeFinalizer(this.ptr, nativeModule()._GetStringFinalizer())
42
        this.ptr = nullptr
43
    }
44
}
45

46
providePlatformDefinedData({
47
    nativeString(ptr: KPointer): NativeStringBase { return new NativeString(ptr) },
48
    nativeStringArrayDecoder(): ArrayDecoder<NativeStringBase> { throw new Error("Not implemented") },
49
    callbackRegistry(): CallbackRegistry | undefined { return undefined }
50
})
51

52
export interface InteropOps {
53
    _GetGroupedLog(index: KInt): KPointer
54
    _StartGroupedLog(index: KInt): void
55
    _StopGroupedLog(index: KInt): void
56
    _GetStringFinalizer(): KPointer
57
    _InvokeFinalizer(ptr: KPointer, finalizer: KPointer): void
58
    _GetNodeFinalizer(): KPointer
59
    _StringLength(ptr: KPointer): KInt
60
    _StringData(ptr: KPointer, buffer: KUint8ArrayPtr, length: KInt): void
61
    _StringMake(value: KStringPtr): KPointer
62
    _ManagedStringWrite(value: KStringPtr, buffer: KUint8ArrayPtr, offset: KInt): KInt
63
    _Test_SetEventsApi(): void
64
    _Test_Common_OnChildTouchTest(valueArray: Uint8Array, valueSerializerLength: KInt): void
65
    _Test_List_OnScrollVisibleContentChange(valueArray: Uint8Array, valueSerializerLength: KInt): void
66
    _Test_TextPicker_OnAccept(valueArray: Uint8Array, valueSerializerLength: KInt): void
67
    _TestPerfNumber(value: KInt): KInt
68
    _TestPerfNumberWithArray(value: KUint8ArrayPtr, length: KInt): void
69
    _StartPerf(traceName: KStringPtr): void
70
    _EndPerf(traceName: KStringPtr): void
71
    _DumpPerf(options: KInt): KPointer
72
}
73

74
export interface GraphicsOps {
75
    // TODO fill me if needed
76
}
77

78
export interface NodeOps {
79
    _CreateNode(type: KInt, id: KInt, flags: KInt): NodePointer
80
    _GetNodeByViewStack(): NodePointer
81
    _DisposeNode(ptr: NodePointer): void
82

83
    _AddChild(parent: NodePointer, child: NodePointer): KInt
84
    _RemoveChild(parent: NodePointer, child: NodePointer): void
85
    _InsertChildAfter(parent: NodePointer, child: NodePointer, sibling: NodePointer): KInt
86
    _InsertChildBefore(parent: NodePointer, child: NodePointer, sibling: NodePointer): KInt
87
    _InsertChildAt(parent: NodePointer, child: NodePointer,  position: KInt): KInt
88
    _ApplyModifierFinish(ptr: NodePointer): void
89
    _MarkDirty(ptr: NodePointer, flag: KUInt): void
90
    _IsBuilderNode(ptr: NodePointer): KBoolean
91
    _ConvertLengthMetricsUnit(value: KFloat, originUnit: KInt, targetUnit: KInt): KFloat
92
    // #endregion
93

94
    // getUtilsModifier
95
    // getCanvasRenderingContext2DModifier
96

97
    // setCallbackMethod
98
    // setCustomMethodFlag
99

100
    // registerCustomNodeAsyncEvent
101
    // unregisterCustomNodeAsyncEvent
102
    // registerCustomNodeAsyncEventReceiver
103

104
    // #region EXTENDED NODE
105
    _SetCustomCallback(node: NodePointer, callbackId: KInt): void
106
    _MeasureLayoutAndDraw(root: NodePointer): void
107
    _MeasureNode(root: NodePointer, data: KFloat32ArrayPtr): KInt
108
    _LayoutNode(root: NodePointer, data: KFloat32ArrayPtr): KInt
109
    _DrawNode(root: NodePointer, data: KFloat32ArrayPtr): KInt
110

111
    // setAttachNodePtr
112
    // getAttachNodePtr
113

114
    _SetMeasureWidth(root: NodePointer, value: KInt): void
115
    _GetMeasureWidth(root: NodePointer): KInt
116
    _SetMeasureHeight(root: NodePointer, value: KInt): void
117
    _GetMeasureHeight(root: NodePointer): KInt
118
    _SetX(root: NodePointer, value: KInt): void
119
    _GetX(root: NodePointer): KInt
120
    _SetY(root: NodePointer, value: KInt): void
121
    _GetY(root: NodePointer): KInt
122

123
    // getLayoutConstraint
124

125
    _SetAlignment(root: NodePointer, value: KInt): void
126
    _GetAlignment(root: NodePointer): KInt
127

128
    _IndexerChecker(node: NodePointer): KInt
129

130
    _SetRangeUpdater(node: NodePointer, updaterId: KInt): void
131
    _SetLazyItemIndexer(node: NodePointer, indexerId: KInt): KInt
132

133
    _GetPipelineContext(nodePtr:NodePointer): PipelineContext
134

135
    _SetVsyncCallback(pipelineContext: PipelineContext, callbackId: KInt): KInt
136
    _UnblockVsyncWait(pipelineContext: PipelineContext): KInt
137

138
    _SetChildTotalCount(ptr: NodePointer, value: KInt): void
139
    _ShowCrash(messagePtr: KStringPtr): void
140
}
141

142
export interface ComponentOps {
143
%GENERATED_METHODS%
144
}
145

146
export interface NativeModuleIntegrated extends InteropOps, /*GraphicsOps, NodeOps,*/ ComponentOps {}
147
export interface NativeModule extends InteropOps, GraphicsOps, NodeOps, ComponentOps {}

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

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

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

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