@idlizer/core 2.1.9-arktscgen-5 → 2.1.9-arktscgen-6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lib/src/LanguageWriters/ArgConvertors.d.ts +3 -1
- package/build/lib/src/LanguageWriters/ArgConvertors.js +49 -1
- package/build/lib/src/peer-generation/Materialized.d.ts +2 -18
- package/build/lib/src/peer-generation/Materialized.js +6 -54
- package/build/lib/src/peer-generation/PeerClass.d.ts +0 -2
- package/build/lib/src/peer-generation/PeerClass.js +4 -6
- package/build/lib/src/peer-generation/PeerMethod.d.ts +26 -24
- package/build/lib/src/peer-generation/PeerMethod.js +86 -78
- package/package.json +1 -1
- package/build/lib/src/LanguageWriters/convertors/KotlinConvertor.d.ts +0 -24
- package/build/lib/src/LanguageWriters/convertors/KotlinConvertor.js +0 -69
|
@@ -5,6 +5,7 @@ import { NativeModuleType, RuntimeType } from "./common";
|
|
|
5
5
|
import { LibraryInterface } from "../LibraryInterface";
|
|
6
6
|
import { ReferenceResolver } from "../peer-generation/ReferenceResolver";
|
|
7
7
|
import { PeerLibrary } from "../peer-generation/PeerLibrary";
|
|
8
|
+
import { PeerMethodSignature } from "../peer-generation/PeerMethod";
|
|
8
9
|
export declare function getSerializerName(declaration: idl.IDLEntry): string;
|
|
9
10
|
export interface ArgConvertor {
|
|
10
11
|
param: string;
|
|
@@ -26,7 +27,7 @@ export interface ArgConvertor {
|
|
|
26
27
|
getObjectAccessor(languge: Language, value: string, args?: Record<string, string>, writer?: LanguageWriter): string;
|
|
27
28
|
}
|
|
28
29
|
export declare function isDirectConvertedType(originalType: idl.IDLType | undefined, library: PeerLibrary): boolean;
|
|
29
|
-
export declare function isVMContextMethod(method: Method): boolean;
|
|
30
|
+
export declare function isVMContextMethod(method: Method | PeerMethodSignature): boolean;
|
|
30
31
|
export declare function isDirectMethod(method: Method, library: PeerLibrary): boolean;
|
|
31
32
|
export declare abstract class BaseArgConvertor implements ArgConvertor {
|
|
32
33
|
idlType: idl.IDLType;
|
|
@@ -355,4 +356,5 @@ export declare function generateCallbackKindAccess(callback: idl.IDLCallback, la
|
|
|
355
356
|
export declare function generateCallbackKindValue(callback: idl.IDLCallback): number;
|
|
356
357
|
export declare function generateCallbackAPIArguments(library: LibraryInterface, callback: idl.IDLCallback): string[];
|
|
357
358
|
export declare function maybeTransformManagedCallback(callback: idl.IDLCallback, library: ReferenceResolver): idl.IDLCallback | undefined;
|
|
359
|
+
export declare function createOutArgConvertor(library: PeerLibrary, type: idl.IDLType | undefined, otherParams: string[]): ArgConvertor | undefined;
|
|
358
360
|
//# sourceMappingURL=ArgConvertors.d.ts.map
|
|
@@ -24,6 +24,7 @@ import { createEmptyReferenceResolver } from "../peer-generation/ReferenceResolv
|
|
|
24
24
|
import { PrimitiveTypesInstance } from "../peer-generation/PrimitiveType";
|
|
25
25
|
import { qualifiedName } from "../peer-generation/idl/common";
|
|
26
26
|
import { LayoutNodeRole } from "../peer-generation/LayoutManager";
|
|
27
|
+
import { PeerMethodSignature } from "../peer-generation/PeerMethod";
|
|
27
28
|
export function getSerializerName(declaration) {
|
|
28
29
|
return `${idl.getQualifiedName(declaration, "namespace.name").split('.').join('_')}_serializer`;
|
|
29
30
|
}
|
|
@@ -76,7 +77,8 @@ export function isDirectConvertedType(originalType, library) {
|
|
|
76
77
|
}
|
|
77
78
|
export function isVMContextMethod(method) {
|
|
78
79
|
var _a, _b;
|
|
79
|
-
|
|
80
|
+
const isPromise = !!idl.asPromise(method instanceof PeerMethodSignature ? method.returnType : method.signature.returnType);
|
|
81
|
+
return isPromise ||
|
|
80
82
|
!!((_a = method.modifiers) === null || _a === void 0 ? void 0 : _a.includes(MethodModifier.THROWS)) ||
|
|
81
83
|
!!((_b = method.modifiers) === null || _b === void 0 ? void 0 : _b.includes(MethodModifier.FORCE_CONTEXT)) ||
|
|
82
84
|
generatorConfiguration().forceContext.includes(method.name);
|
|
@@ -1294,4 +1296,50 @@ export function maybeTransformManagedCallback(callback, library) {
|
|
|
1294
1296
|
return library.resolveTypeReference(idl.createReferenceType("CustomNodeBuilder"));
|
|
1295
1297
|
return undefined;
|
|
1296
1298
|
}
|
|
1299
|
+
class PromiseOutArgConvertor extends BaseArgConvertor {
|
|
1300
|
+
constructor(library, param, promise) {
|
|
1301
|
+
super(library.createContinuationCallbackReference(promise), [RuntimeType.FUNCTION], false, true, param);
|
|
1302
|
+
this.library = library;
|
|
1303
|
+
this.promise = promise;
|
|
1304
|
+
this.isOut = true;
|
|
1305
|
+
const type = this.idlType;
|
|
1306
|
+
const callbackEntry = library.resolveTypeReference(type);
|
|
1307
|
+
if (!callbackEntry)
|
|
1308
|
+
throw new Error(`Internal error: no callback for ${type.name} resolved`);
|
|
1309
|
+
this.callback = callbackEntry;
|
|
1310
|
+
this.callbackConvertor = new CallbackConvertor(library, param, this.callback, this.library.interopNativeModule);
|
|
1311
|
+
}
|
|
1312
|
+
convertorArg(param, writer) {
|
|
1313
|
+
return this.callbackConvertor.convertorArg(param, writer);
|
|
1314
|
+
}
|
|
1315
|
+
convertorSerialize(param, value, writer) {
|
|
1316
|
+
if (writer.language == Language.CPP) {
|
|
1317
|
+
this.callbackConvertor.convertorSerialize(param, value, writer);
|
|
1318
|
+
return;
|
|
1319
|
+
}
|
|
1320
|
+
const serializeCallback = idl.isVoidType(this.promise.elementType[0])
|
|
1321
|
+
? writer.makeMethodCall(`${param}Serializer`, `holdAndWriteCallbackForPromiseVoid`, [])
|
|
1322
|
+
: writer.makeMethodCall(`${param}Serializer`, `holdAndWriteCallbackForPromise<${writer.getNodeName(this.promise.elementType[0])}>`, []);
|
|
1323
|
+
writer.writeStatement(writer.makeAssign(value, undefined, writer.language == Language.CJ ? writer.makeString(serializeCallback.asString().concat('.promise')) : writer.makeTupleAccess(serializeCallback.asString(), 0), true));
|
|
1324
|
+
}
|
|
1325
|
+
convertorDeserialize(bufferName, deserializerName, assigneer, writer) {
|
|
1326
|
+
return this.callbackConvertor.convertorDeserialize(bufferName, deserializerName, assigneer, writer);
|
|
1327
|
+
}
|
|
1328
|
+
nativeType() {
|
|
1329
|
+
return this.idlType;
|
|
1330
|
+
}
|
|
1331
|
+
isPointerType() {
|
|
1332
|
+
return true;
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
export function createOutArgConvertor(library, type, otherParams) {
|
|
1336
|
+
if (type && idl.isContainerType(type) && idl.IDLContainerUtils.isPromise(type)) {
|
|
1337
|
+
const param = (entropy) => `outputArgumentForReturningPromise${entropy || ''}`;
|
|
1338
|
+
let paramEntropy = 0;
|
|
1339
|
+
while (otherParams === null || otherParams === void 0 ? void 0 : otherParams.includes(param(paramEntropy)))
|
|
1340
|
+
++paramEntropy;
|
|
1341
|
+
return new PromiseOutArgConvertor(library, param(paramEntropy), type);
|
|
1342
|
+
}
|
|
1343
|
+
return undefined;
|
|
1344
|
+
}
|
|
1297
1345
|
//# sourceMappingURL=ArgConvertors.js.map
|
|
@@ -2,8 +2,7 @@ import * as idl from '../idl';
|
|
|
2
2
|
import { ArgConvertor } from '../LanguageWriters/ArgConvertors';
|
|
3
3
|
import { Field, Method } from '../LanguageWriters/LanguageWriter';
|
|
4
4
|
import { PeerClassBase } from './PeerClass';
|
|
5
|
-
import { PeerMethod } from './PeerMethod';
|
|
6
|
-
import { ReferenceResolver } from './ReferenceResolver';
|
|
5
|
+
import { PeerMethod, PeerMethodSignature } from './PeerMethod';
|
|
7
6
|
export declare class MaterializedField {
|
|
8
7
|
field: Field;
|
|
9
8
|
argConvertor: ArgConvertor;
|
|
@@ -14,25 +13,11 @@ export declare class MaterializedField {
|
|
|
14
13
|
}
|
|
15
14
|
export declare class MaterializedMethod extends PeerMethod {
|
|
16
15
|
implementationParentName: string;
|
|
17
|
-
|
|
18
|
-
constructor(originalParentName: string, implementationParentName: string, argConvertors: ArgConvertor[], returnType: idl.IDLType, isCallSignature: boolean, method: Method, outArgConvertor?: ArgConvertor | undefined);
|
|
19
|
-
get peerMethodName(): string;
|
|
20
|
-
get implNamespaceName(): string;
|
|
21
|
-
get toStringName(): string;
|
|
22
|
-
dummyReturnValue(resolver: ReferenceResolver): string | undefined;
|
|
23
|
-
get receiverType(): string;
|
|
24
|
-
get apiCall(): string;
|
|
25
|
-
get apiKind(): string;
|
|
26
|
-
generateReceiver(): {
|
|
27
|
-
argName: string;
|
|
28
|
-
argType: string;
|
|
29
|
-
} | undefined;
|
|
30
|
-
getImplementationName(): string;
|
|
16
|
+
constructor(sig: PeerMethodSignature, originalParentName: string, implementationParentName: string, returnType: idl.IDLType, isCallSignature: boolean, method: Method);
|
|
31
17
|
tsReturnType(): idl.IDLType | undefined;
|
|
32
18
|
getPrivateMethod(): MaterializedMethod;
|
|
33
19
|
withReturnType(returnType: idl.IDLType): MaterializedMethod;
|
|
34
20
|
setOverloadIndex(index: number): void;
|
|
35
|
-
getOverloadPostfix(): string;
|
|
36
21
|
}
|
|
37
22
|
export declare function copyMaterializedMethod(method: MaterializedMethod, overrides: {
|
|
38
23
|
method?: Method;
|
|
@@ -54,7 +39,6 @@ export declare class MaterializedClass implements PeerClassBase {
|
|
|
54
39
|
constructor(decl: idl.IDLInterface, className: string, isInterface: boolean, isStaticMaterialized: boolean, superClass: idl.IDLReferenceType | undefined, interfaces: idl.IDLReferenceType[] | undefined, generics: string[] | undefined, fields: MaterializedField[], ctors: MaterializedMethod[], // zero size when used for global functions
|
|
55
40
|
finalizer: MaterializedMethod | undefined, // undefined when used for global functions
|
|
56
41
|
methods: MaterializedMethod[], needBeGenerated?: boolean, taggedMethods?: idl.IDLMethod[]);
|
|
57
|
-
getComponentName(): string;
|
|
58
42
|
getImplementationName(): string;
|
|
59
43
|
generatedName(isCallSignature: boolean): string;
|
|
60
44
|
private _isGlobal;
|
|
@@ -16,7 +16,7 @@ import * as idl from '../idl';
|
|
|
16
16
|
import { copyMethod, Method, MethodModifier, NamedMethodSignature } from '../LanguageWriters/LanguageWriter';
|
|
17
17
|
import { capitalize } from '../util';
|
|
18
18
|
import { qualifiedName } from './idl/common';
|
|
19
|
-
import { PeerMethod } from './PeerMethod';
|
|
19
|
+
import { PeerMethod, PeerMethodSignature } from './PeerMethod';
|
|
20
20
|
export class MaterializedField {
|
|
21
21
|
constructor(field, argConvertor, outArgConvertor, isNullableOriginalTypeField, extraMethodName = undefined) {
|
|
22
22
|
this.field = field;
|
|
@@ -27,50 +27,9 @@ export class MaterializedField {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
export class MaterializedMethod extends PeerMethod {
|
|
30
|
-
constructor(originalParentName, implementationParentName,
|
|
31
|
-
super(
|
|
30
|
+
constructor(sig, originalParentName, implementationParentName, returnType, isCallSignature, method) {
|
|
31
|
+
super(sig, originalParentName, returnType, isCallSignature, method);
|
|
32
32
|
this.implementationParentName = implementationParentName;
|
|
33
|
-
this.outArgConvertor = outArgConvertor;
|
|
34
|
-
}
|
|
35
|
-
get peerMethodName() {
|
|
36
|
-
return this.overloadedName;
|
|
37
|
-
}
|
|
38
|
-
get implNamespaceName() {
|
|
39
|
-
return `${capitalize(this.originalParentName)}Accessor`;
|
|
40
|
-
}
|
|
41
|
-
get toStringName() {
|
|
42
|
-
switch (this.method.name) {
|
|
43
|
-
case "ctor": return `new ${this.originalParentName}`;
|
|
44
|
-
case "destructor": return `delete ${this.originalParentName}`;
|
|
45
|
-
default: return super.toStringName;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
dummyReturnValue(resolver) {
|
|
49
|
-
if (this.method.name === "ctor")
|
|
50
|
-
return `(Ark_${this.originalParentName}) 100`;
|
|
51
|
-
if (this.method.name === "getFinalizer")
|
|
52
|
-
return `fnPtr<KNativePointer>(dummyClassFinalizer)`;
|
|
53
|
-
return undefined;
|
|
54
|
-
}
|
|
55
|
-
get receiverType() {
|
|
56
|
-
return `Ark_${this.originalParentName}`;
|
|
57
|
-
}
|
|
58
|
-
get apiCall() {
|
|
59
|
-
return "GetAccessors()";
|
|
60
|
-
}
|
|
61
|
-
get apiKind() {
|
|
62
|
-
return "Accessor";
|
|
63
|
-
}
|
|
64
|
-
generateReceiver() {
|
|
65
|
-
if (!this.hasReceiver())
|
|
66
|
-
return undefined;
|
|
67
|
-
return {
|
|
68
|
-
argName: 'peer',
|
|
69
|
-
argType: `Ark_${this.originalParentName}`
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
getImplementationName() {
|
|
73
|
-
return this.implementationParentName;
|
|
74
33
|
}
|
|
75
34
|
tsReturnType() {
|
|
76
35
|
return this.method.signature.returnType;
|
|
@@ -99,14 +58,10 @@ export class MaterializedMethod extends PeerMethod {
|
|
|
99
58
|
setOverloadIndex(index) {
|
|
100
59
|
this.overloadIndex = index;
|
|
101
60
|
}
|
|
102
|
-
getOverloadPostfix() {
|
|
103
|
-
var _a;
|
|
104
|
-
return `${(_a = this.overloadIndex) !== null && _a !== void 0 ? _a : ""}`;
|
|
105
|
-
}
|
|
106
61
|
}
|
|
107
62
|
export function copyMaterializedMethod(method, overrides) {
|
|
108
63
|
var _a;
|
|
109
|
-
const copied = new MaterializedMethod(method.
|
|
64
|
+
const copied = new MaterializedMethod(method.sig, method.originalParentName, method.implementationParentName, method.returnType, method.isCallSignature, (_a = overrides.method) !== null && _a !== void 0 ? _a : method.method);
|
|
110
65
|
copied.setSameOverloadIndex(method);
|
|
111
66
|
return copied;
|
|
112
67
|
}
|
|
@@ -130,14 +85,11 @@ export class MaterializedClass {
|
|
|
130
85
|
this._isGlobal = false;
|
|
131
86
|
PeerMethod.markAndGroupOverloads(methods);
|
|
132
87
|
}
|
|
133
|
-
getComponentName() {
|
|
134
|
-
return this.className;
|
|
135
|
-
}
|
|
136
88
|
getImplementationName() {
|
|
137
89
|
return this.isInterface ? getInternalClassName(this.className) : this.className;
|
|
138
90
|
}
|
|
139
91
|
generatedName(isCallSignature) {
|
|
140
|
-
return this.
|
|
92
|
+
return this.getImplementationName();
|
|
141
93
|
}
|
|
142
94
|
setGlobalScope() {
|
|
143
95
|
this._isGlobal = true;
|
|
@@ -150,7 +102,7 @@ export function createDestroyPeerMethod(clazz) {
|
|
|
150
102
|
if (clazz.isGlobalScope() || clazz.isStaticMaterialized) {
|
|
151
103
|
return undefined;
|
|
152
104
|
}
|
|
153
|
-
return new MaterializedMethod(idl.getQualifiedName(clazz.decl, "namespace.name").split('.').join('_'), clazz.getImplementationName(),
|
|
105
|
+
return new MaterializedMethod(new PeerMethodSignature(PeerMethodSignature.DESTROY, '%NEVER_USED$', [], idl.IDLVoidType, clazz.decl), idl.getQualifiedName(clazz.decl, "namespace.name").split('.').join('_'), clazz.getImplementationName(), idl.IDLVoidType, false, new Method('destroyPeer', new NamedMethodSignature(idl.IDLVoidType, [idl.createReferenceType(clazz.decl)], ['peer'])));
|
|
154
106
|
}
|
|
155
107
|
export function getInternalClassName(name) {
|
|
156
108
|
return `${name}Internal`;
|
|
@@ -2,7 +2,6 @@ import { IDLFile, IDLProperty } from "../idl";
|
|
|
2
2
|
import { PeerMethod } from "./PeerMethod";
|
|
3
3
|
export interface PeerClassBase {
|
|
4
4
|
generatedName(isCallSignature: boolean): string;
|
|
5
|
-
getComponentName(): string;
|
|
6
5
|
}
|
|
7
6
|
export declare class PeerClass implements PeerClassBase {
|
|
8
7
|
readonly file: IDLFile;
|
|
@@ -10,7 +9,6 @@ export declare class PeerClass implements PeerClassBase {
|
|
|
10
9
|
readonly originalFilename: string;
|
|
11
10
|
constructor(file: IDLFile, componentName: string, originalFilename: string);
|
|
12
11
|
generatedName(isCallSignature: boolean): string;
|
|
13
|
-
getComponentName(): string;
|
|
14
12
|
methods: PeerMethod[];
|
|
15
13
|
originalClassName: string | undefined;
|
|
16
14
|
originalInterfaceName: string | undefined;
|
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
* limitations under the License.
|
|
14
14
|
*/
|
|
15
15
|
import { IDLI32Type, IDLPointerType } from "../idl";
|
|
16
|
-
import {
|
|
17
|
-
import { PeerMethod } from "./PeerMethod";
|
|
16
|
+
import { PeerMethod, PeerMethodArg, PeerMethodSignature } from "./PeerMethod";
|
|
18
17
|
import { Method, MethodModifier, NamedMethodSignature } from "../LanguageWriters/LanguageWriter";
|
|
19
18
|
export class PeerClass {
|
|
20
19
|
constructor(file, componentName, originalFilename) {
|
|
@@ -33,11 +32,10 @@ export class PeerClass {
|
|
|
33
32
|
generatedName(isCallSignature) {
|
|
34
33
|
return isCallSignature ? this.originalInterfaceName : this.originalClassName;
|
|
35
34
|
}
|
|
36
|
-
getComponentName() {
|
|
37
|
-
return this.componentName;
|
|
38
|
-
}
|
|
39
35
|
}
|
|
40
36
|
export function createConstructPeerMethod(clazz) {
|
|
41
|
-
|
|
37
|
+
// TODO here is class FQName needed, but can not calculate if from current PeerClass data
|
|
38
|
+
const classFQN = [clazz.componentName];
|
|
39
|
+
return new PeerMethod(new PeerMethodSignature(PeerMethodSignature.CTOR, classFQN.concat(PeerMethodSignature.CTOR).join('_'), [new PeerMethodArg('id', IDLI32Type), new PeerMethodArg('flags', IDLI32Type)], IDLPointerType), clazz.componentName, IDLPointerType, false, new Method('construct', new NamedMethodSignature(IDLPointerType, [IDLI32Type, IDLI32Type], ['id', 'flags']), [MethodModifier.STATIC]));
|
|
42
40
|
}
|
|
43
41
|
//# sourceMappingURL=PeerClass.js.map
|
|
@@ -1,35 +1,37 @@
|
|
|
1
|
+
import * as idl from '../idl';
|
|
1
2
|
import { IDLType } from "../idl";
|
|
2
|
-
import { IdlNameConvertor } from "../LanguageWriters";
|
|
3
3
|
import { ArgConvertor } from "../LanguageWriters/ArgConvertors";
|
|
4
|
-
import { Method } from "../LanguageWriters/LanguageWriter";
|
|
5
|
-
import {
|
|
4
|
+
import { Method, MethodModifier } from "../LanguageWriters/LanguageWriter";
|
|
5
|
+
import { PeerLibrary } from './PeerLibrary';
|
|
6
|
+
export declare class PeerMethodArg {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly type: idl.IDLType;
|
|
9
|
+
constructor(name: string, type: idl.IDLType);
|
|
10
|
+
}
|
|
11
|
+
export declare class PeerMethodSignature {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly fqname: string;
|
|
14
|
+
readonly args: PeerMethodArg[];
|
|
15
|
+
readonly returnType: idl.IDLType;
|
|
16
|
+
readonly context: idl.IDLEntry | undefined;
|
|
17
|
+
readonly modifiers: (MethodModifier.FORCE_CONTEXT | MethodModifier.THROWS)[];
|
|
18
|
+
constructor(name: string, fqname: string, args: PeerMethodArg[], returnType: idl.IDLType, context?: idl.IDLEntry | undefined, modifiers?: (MethodModifier.FORCE_CONTEXT | MethodModifier.THROWS)[]);
|
|
19
|
+
static stub(): PeerMethodSignature;
|
|
20
|
+
static generateOverloadPostfix(decl: idl.IDLConstructor | idl.IDLMethod | idl.IDLCallable | idl.IDLProperty): string;
|
|
21
|
+
static get CTOR(): string;
|
|
22
|
+
static get GET_FINALIZER(): string;
|
|
23
|
+
static get DESTROY(): string;
|
|
24
|
+
}
|
|
6
25
|
export declare class PeerMethod {
|
|
26
|
+
sig: PeerMethodSignature;
|
|
7
27
|
originalParentName: string;
|
|
8
|
-
argConvertors: ArgConvertor[];
|
|
9
28
|
returnType: IDLType;
|
|
10
29
|
isCallSignature: boolean;
|
|
11
30
|
method: Method;
|
|
12
|
-
outArgConvertor?: ArgConvertor | undefined;
|
|
13
31
|
protected overloadIndex?: number;
|
|
14
|
-
constructor(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
get peerMethodName(): string;
|
|
18
|
-
get implNamespaceName(): string;
|
|
19
|
-
get implName(): string;
|
|
20
|
-
get toStringName(): string;
|
|
21
|
-
dummyReturnValue(resolver: ReferenceResolver): string | undefined;
|
|
22
|
-
get receiverType(): string;
|
|
23
|
-
get apiCall(): string;
|
|
24
|
-
get apiKind(): string;
|
|
25
|
-
get argAndOutConvertors(): ArgConvertor[];
|
|
26
|
-
hasReceiver(): boolean;
|
|
27
|
-
generateAPIParameters(converter: IdlNameConvertor): string[];
|
|
28
|
-
generateReceiver(): {
|
|
29
|
-
argName: string;
|
|
30
|
-
argType: string;
|
|
31
|
-
} | undefined;
|
|
32
|
-
getImplementationName(): string;
|
|
32
|
+
constructor(sig: PeerMethodSignature, originalParentName: string, returnType: IDLType, isCallSignature: boolean, method: Method);
|
|
33
|
+
argConvertors(library: PeerLibrary): ArgConvertor[];
|
|
34
|
+
argAndOutConvertors(library: PeerLibrary): ArgConvertor[];
|
|
33
35
|
static markAndGroupOverloads(methods: PeerMethod[]): PeerMethod[];
|
|
34
36
|
setSameOverloadIndex(copyFrom: PeerMethod): void;
|
|
35
37
|
}
|
|
@@ -1,86 +1,94 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
+
import * as idl from '../idl';
|
|
16
|
+
import { createOutArgConvertor } from "../LanguageWriters/ArgConvertors";
|
|
17
|
+
import { MethodModifier } from "../LanguageWriters/LanguageWriter";
|
|
18
|
+
import { isDefined } from "../util";
|
|
19
|
+
export class PeerMethodArg {
|
|
20
|
+
constructor(name, type) {
|
|
21
|
+
this.name = name;
|
|
22
|
+
this.type = type;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export class PeerMethodSignature {
|
|
26
|
+
constructor(
|
|
27
|
+
// contextual name of method
|
|
28
|
+
name,
|
|
29
|
+
// unique name of method (used in global scopes like interop)
|
|
30
|
+
fqname, args, returnType, context = undefined,
|
|
31
|
+
// only modifiers affecting signature. Private, public, static and others - does not belong here
|
|
32
|
+
modifiers = []) {
|
|
33
|
+
this.name = name;
|
|
34
|
+
this.fqname = fqname;
|
|
35
|
+
this.args = args;
|
|
36
|
+
this.returnType = returnType;
|
|
37
|
+
this.context = context;
|
|
38
|
+
this.modifiers = modifiers;
|
|
39
|
+
}
|
|
40
|
+
// whilt migration we're creating PeerMethod, but in reality we shoudnt (created method does not goes through interop and does not have representation in native)
|
|
41
|
+
static stub() {
|
|
42
|
+
return new PeerMethodSignature("%STUB$", "%STUB$", [], idl.IDLVoidType, undefined);
|
|
43
|
+
}
|
|
44
|
+
static generateOverloadPostfix(decl) {
|
|
45
|
+
if (!decl.parent || !idl.isInterface(decl.parent))
|
|
46
|
+
return ``;
|
|
47
|
+
if (idl.isMethod(decl) || idl.isProperty(decl)) {
|
|
48
|
+
let sameNamed = [
|
|
49
|
+
...decl.parent.properties,
|
|
50
|
+
...decl.parent.methods,
|
|
51
|
+
].filter(it => it.name === decl.name);
|
|
52
|
+
const overloadIndex = sameNamed.length > 1 ? sameNamed.indexOf(decl).toString() : '';
|
|
53
|
+
return overloadIndex;
|
|
54
|
+
}
|
|
55
|
+
if (idl.isConstructor(decl)) {
|
|
56
|
+
const sameNamed = decl.parent.constructors.filter(it => it.name === decl.name);
|
|
57
|
+
const overloadIndex = sameNamed.length > 1 ? sameNamed.indexOf(decl).toString() : '';
|
|
58
|
+
return overloadIndex;
|
|
59
|
+
}
|
|
60
|
+
if (idl.isCallable(decl)) {
|
|
61
|
+
const sameNamed = decl.parent.callables;
|
|
62
|
+
const overloadIndex = sameNamed.length > 1 ? sameNamed.indexOf(decl).toString() : '';
|
|
63
|
+
return overloadIndex;
|
|
64
|
+
}
|
|
65
|
+
throw new Error("unexpected type of declaration");
|
|
66
|
+
}
|
|
67
|
+
static get CTOR() { return "construct"; }
|
|
68
|
+
static get GET_FINALIZER() { return "getFinalizer"; }
|
|
69
|
+
static get DESTROY() { return "destroyPeer"; }
|
|
70
|
+
}
|
|
7
71
|
export class PeerMethod {
|
|
8
|
-
constructor(
|
|
72
|
+
constructor(sig, originalParentName, returnType, isCallSignature, method) {
|
|
73
|
+
var _a, _b;
|
|
74
|
+
this.sig = sig;
|
|
9
75
|
this.originalParentName = originalParentName;
|
|
10
|
-
this.argConvertors = argConvertors;
|
|
11
76
|
this.returnType = returnType;
|
|
12
77
|
this.isCallSignature = isCallSignature;
|
|
13
78
|
this.method = method;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
name.startsWith("get"))
|
|
28
|
-
return name;
|
|
29
|
-
return `set${capitalize(name)}`;
|
|
30
|
-
}
|
|
31
|
-
get implNamespaceName() {
|
|
32
|
-
return `${capitalize(this.originalParentName)}Modifier`;
|
|
33
|
-
}
|
|
34
|
-
get implName() {
|
|
35
|
-
return `${capitalize(this.overloadedName)}Impl`;
|
|
36
|
-
}
|
|
37
|
-
get toStringName() {
|
|
38
|
-
return this.method.name;
|
|
39
|
-
}
|
|
40
|
-
dummyReturnValue(resolver) {
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
get receiverType() {
|
|
44
|
-
return "Ark_NodeHandle";
|
|
45
|
-
}
|
|
46
|
-
get apiCall() {
|
|
47
|
-
return "GetNodeModifiers()";
|
|
48
|
-
}
|
|
49
|
-
get apiKind() {
|
|
50
|
-
return "Modifier";
|
|
51
|
-
}
|
|
52
|
-
get argAndOutConvertors() {
|
|
53
|
-
var _a;
|
|
54
|
-
return this.argConvertors.concat((_a = this.outArgConvertor) !== null && _a !== void 0 ? _a : []);
|
|
55
|
-
}
|
|
56
|
-
hasReceiver() {
|
|
57
|
-
var _a;
|
|
58
|
-
return !((_a = this.method.modifiers) === null || _a === void 0 ? void 0 : _a.includes(MethodModifier.STATIC));
|
|
59
|
-
}
|
|
60
|
-
generateAPIParameters(converter) {
|
|
61
|
-
const args = this.argAndOutConvertors.map(it => {
|
|
62
|
-
let isPointer = it.isPointerType();
|
|
63
|
-
return `${isPointer ? "const " : ""}${converter.convert(it.nativeType())}${isPointer ? "*" : ""} ${it.param}`;
|
|
64
|
-
});
|
|
65
|
-
const receiver = this.generateReceiver();
|
|
66
|
-
if (receiver)
|
|
67
|
-
args.unshift(`${receiver.argType} ${receiver.argName}`);
|
|
68
|
-
if (!!asPromise(this.method.signature.returnType))
|
|
69
|
-
args.unshift(`${generatorTypePrefix()}AsyncWorkerPtr asyncWorker`);
|
|
70
|
-
if (isVMContextMethod(this.method))
|
|
71
|
-
args.unshift(`${generatorTypePrefix()}VMContext vmContext`);
|
|
72
|
-
return args;
|
|
73
|
-
}
|
|
74
|
-
generateReceiver() {
|
|
75
|
-
if (!this.hasReceiver())
|
|
76
|
-
return undefined;
|
|
77
|
-
return {
|
|
78
|
-
argName: "node",
|
|
79
|
-
argType: PrimitiveTypesInstance.NativePointer.getText()
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
getImplementationName() {
|
|
83
|
-
return this.originalParentName;
|
|
79
|
+
// todo remove me
|
|
80
|
+
if ((_a = method.modifiers) === null || _a === void 0 ? void 0 : _a.includes(MethodModifier.FORCE_CONTEXT))
|
|
81
|
+
sig.modifiers.push(MethodModifier.FORCE_CONTEXT);
|
|
82
|
+
if ((_b = method.modifiers) === null || _b === void 0 ? void 0 : _b.includes(MethodModifier.THROWS))
|
|
83
|
+
sig.modifiers.push(MethodModifier.THROWS);
|
|
84
|
+
}
|
|
85
|
+
argConvertors(library) {
|
|
86
|
+
return this.sig.args.map(it => library.typeConvertor(it.name, it.type, false));
|
|
87
|
+
}
|
|
88
|
+
argAndOutConvertors(library) {
|
|
89
|
+
const convertors = this.argConvertors(library);
|
|
90
|
+
const outArgConvertor = createOutArgConvertor(library, this.sig.returnType, this.sig.args.map(it => it.name));
|
|
91
|
+
return outArgConvertor ? convertors.concat(outArgConvertor) : convertors;
|
|
84
92
|
}
|
|
85
93
|
static markAndGroupOverloads(methods) {
|
|
86
94
|
let groupedMethods = [];
|
package/package.json
CHANGED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as idl from '../../idl';
|
|
2
|
-
import { ReferenceResolver } from '../../peer-generation/ReferenceResolver';
|
|
3
|
-
import { IdlNameConvertor, NodeConvertor } from '../nameConvertor';
|
|
4
|
-
export declare class KotlinTypeNameConvertor implements NodeConvertor<string>, IdlNameConvertor {
|
|
5
|
-
protected resolver: ReferenceResolver;
|
|
6
|
-
constructor(resolver: ReferenceResolver);
|
|
7
|
-
convert(node: idl.IDLNode): string;
|
|
8
|
-
convertNamespace(node: idl.IDLNamespace): string;
|
|
9
|
-
convertInterface(node: idl.IDLInterface): string;
|
|
10
|
-
convertEnum(node: idl.IDLEnum): string;
|
|
11
|
-
convertTypedef(node: idl.IDLTypedef): string;
|
|
12
|
-
convertCallback(node: idl.IDLCallback): string;
|
|
13
|
-
convertMethod(node: idl.IDLMethod): string;
|
|
14
|
-
convertConstant(node: idl.IDLConstant): string;
|
|
15
|
-
convertOptional(type: idl.IDLOptionalType): string;
|
|
16
|
-
convertUnion(type: idl.IDLUnionType): string;
|
|
17
|
-
convertContainer(type: idl.IDLContainerType): string;
|
|
18
|
-
convertImport(type: idl.IDLImport): string;
|
|
19
|
-
convertTypeReferenceAsImport(type: idl.IDLReferenceType, importClause: string): string;
|
|
20
|
-
convertTypeReference(type: idl.IDLReferenceType): string;
|
|
21
|
-
convertTypeParameter(type: idl.IDLTypeParameterType): string;
|
|
22
|
-
convertPrimitiveType(type: idl.IDLPrimitiveType): string;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=KotlinConvertor.d.ts.map
|
|
@@ -1,69 +0,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
|
-
import { convertNode } from '../nameConvertor';
|
|
16
|
-
export class KotlinTypeNameConvertor {
|
|
17
|
-
constructor(resolver) {
|
|
18
|
-
this.resolver = resolver;
|
|
19
|
-
}
|
|
20
|
-
convert(node) {
|
|
21
|
-
return convertNode(this, node);
|
|
22
|
-
}
|
|
23
|
-
convertNamespace(node) {
|
|
24
|
-
throw new Error("Not implemented");
|
|
25
|
-
}
|
|
26
|
-
convertInterface(node) {
|
|
27
|
-
throw new Error("Not implemented");
|
|
28
|
-
}
|
|
29
|
-
convertEnum(node) {
|
|
30
|
-
throw new Error("Not implemented");
|
|
31
|
-
}
|
|
32
|
-
convertTypedef(node) {
|
|
33
|
-
throw new Error("Not implemented");
|
|
34
|
-
}
|
|
35
|
-
convertCallback(node) {
|
|
36
|
-
throw new Error("Not implemented");
|
|
37
|
-
}
|
|
38
|
-
convertMethod(node) {
|
|
39
|
-
throw new Error("Not implemented");
|
|
40
|
-
}
|
|
41
|
-
convertConstant(node) {
|
|
42
|
-
throw new Error("Not implemented");
|
|
43
|
-
}
|
|
44
|
-
convertOptional(type) {
|
|
45
|
-
throw new Error("Not implemented");
|
|
46
|
-
}
|
|
47
|
-
convertUnion(type) {
|
|
48
|
-
throw new Error("Not implemented");
|
|
49
|
-
}
|
|
50
|
-
convertContainer(type) {
|
|
51
|
-
throw new Error("Not implemented");
|
|
52
|
-
}
|
|
53
|
-
convertImport(type) {
|
|
54
|
-
throw new Error("Not implemented");
|
|
55
|
-
}
|
|
56
|
-
convertTypeReferenceAsImport(type, importClause) {
|
|
57
|
-
throw new Error("Not implemented");
|
|
58
|
-
}
|
|
59
|
-
convertTypeReference(type) {
|
|
60
|
-
throw new Error("Not implemented");
|
|
61
|
-
}
|
|
62
|
-
convertTypeParameter(type) {
|
|
63
|
-
throw new Error("Not implemented");
|
|
64
|
-
}
|
|
65
|
-
convertPrimitiveType(type) {
|
|
66
|
-
throw new Error("Not implemented");
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=KotlinConvertor.js.map
|