@react-native-windows/codegen 0.71.4 → 0.71.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/CHANGELOG.md +21 -4
- package/lib-commonjs/Cli.js +18 -1
- package/lib-commonjs/Cli.js.map +1 -1
- package/lib-commonjs/generators/AliasGen.d.ts +2 -1
- package/lib-commonjs/generators/AliasGen.js +9 -9
- package/lib-commonjs/generators/AliasGen.js.map +1 -1
- package/lib-commonjs/generators/GenerateNM2.d.ts +4 -2
- package/lib-commonjs/generators/GenerateNM2.js +7 -3
- package/lib-commonjs/generators/GenerateNM2.js.map +1 -1
- package/lib-commonjs/generators/ObjectTypes.d.ts +6 -2
- package/lib-commonjs/generators/ObjectTypes.js +9 -9
- package/lib-commonjs/generators/ObjectTypes.js.map +1 -1
- package/lib-commonjs/generators/ParamTypes.d.ts +3 -2
- package/lib-commonjs/generators/ParamTypes.js +27 -27
- package/lib-commonjs/generators/ParamTypes.js.map +1 -1
- package/lib-commonjs/generators/ReturnTypes.d.ts +3 -2
- package/lib-commonjs/generators/ReturnTypes.js +7 -7
- package/lib-commonjs/generators/ReturnTypes.js.map +1 -1
- package/lib-commonjs/generators/ValidateMethods.d.ts +2 -1
- package/lib-commonjs/generators/ValidateMethods.js +15 -15
- package/lib-commonjs/generators/ValidateMethods.js.map +1 -1
- package/lib-commonjs/index.d.ts +10 -13
- package/lib-commonjs/index.js +6 -4
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +3 -3
- package/src/Cli.ts +26 -2
- package/src/generators/AliasGen.ts +18 -6
- package/src/generators/GenerateNM2.ts +11 -2
- package/src/generators/ObjectTypes.ts +15 -3
- package/src/generators/ParamTypes.ts +43 -9
- package/src/generators/ReturnTypes.ts +18 -3
- package/src/generators/ValidateMethods.ts +32 -4
- package/src/index.ts +18 -14
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
getAliasCppName,
|
|
22
22
|
getAnonymousAliasCppName,
|
|
23
23
|
} from './AliasManaging';
|
|
24
|
+
import type {CppCodegenOptions} from './ObjectTypes';
|
|
24
25
|
|
|
25
26
|
type NativeModuleParamShape = NamedShape<
|
|
26
27
|
Nullable<NativeModuleParamTypeAnnotation>
|
|
@@ -42,11 +43,12 @@ function decorateType(type: string, target: ParamTarget): string {
|
|
|
42
43
|
function translateUnionReturnType(
|
|
43
44
|
type: NativeModuleEnumDeclaration | NativeModuleUnionTypeAnnotation,
|
|
44
45
|
target: ParamTarget,
|
|
46
|
+
options: CppCodegenOptions,
|
|
45
47
|
): string {
|
|
46
48
|
const memberType = type.memberType;
|
|
47
49
|
switch (type.memberType) {
|
|
48
50
|
case 'StringTypeAnnotation':
|
|
49
|
-
return
|
|
51
|
+
return options.cppStringType;
|
|
50
52
|
case 'NumberTypeAnnotation':
|
|
51
53
|
return 'double';
|
|
52
54
|
case 'ObjectTypeAnnotation':
|
|
@@ -63,25 +65,41 @@ function translateFunction(
|
|
|
63
65
|
aliases: AliasMap,
|
|
64
66
|
baseAliasName: string,
|
|
65
67
|
target: ParamTarget,
|
|
68
|
+
options: CppCodegenOptions,
|
|
66
69
|
): string {
|
|
67
70
|
// TODO: type.returnTypeAnnotation
|
|
68
71
|
switch (target) {
|
|
69
72
|
case 'spec':
|
|
70
73
|
return `Callback<${param.params
|
|
71
74
|
.map((p: NativeModuleParamShape) =>
|
|
72
|
-
translateSpecFunctionParam(
|
|
75
|
+
translateSpecFunctionParam(
|
|
76
|
+
p,
|
|
77
|
+
aliases,
|
|
78
|
+
`${baseAliasName}_${p.name}`,
|
|
79
|
+
options,
|
|
80
|
+
),
|
|
73
81
|
)
|
|
74
82
|
.join(', ')}>`;
|
|
75
83
|
case 'template':
|
|
76
84
|
return `std::function<void(${param.params
|
|
77
85
|
.map((p: NativeModuleParamShape) =>
|
|
78
|
-
translateCallbackParam(
|
|
86
|
+
translateCallbackParam(
|
|
87
|
+
p,
|
|
88
|
+
aliases,
|
|
89
|
+
`${baseAliasName}_${p.name}`,
|
|
90
|
+
options,
|
|
91
|
+
),
|
|
79
92
|
)
|
|
80
93
|
.join(', ')})>`;
|
|
81
94
|
default:
|
|
82
95
|
return `std::function<void(${param.params
|
|
83
96
|
.map((p: NativeModuleParamShape) =>
|
|
84
|
-
translateCallbackParam(
|
|
97
|
+
translateCallbackParam(
|
|
98
|
+
p,
|
|
99
|
+
aliases,
|
|
100
|
+
`${baseAliasName}_${p.name}`,
|
|
101
|
+
options,
|
|
102
|
+
),
|
|
85
103
|
)
|
|
86
104
|
.join(', ')})> const &`;
|
|
87
105
|
}
|
|
@@ -94,6 +112,7 @@ function translateArray(
|
|
|
94
112
|
aliases: AliasMap,
|
|
95
113
|
baseAliasName: string,
|
|
96
114
|
target: ParamTarget,
|
|
115
|
+
options: CppCodegenOptions,
|
|
97
116
|
): string {
|
|
98
117
|
if (param.elementType) {
|
|
99
118
|
switch (target) {
|
|
@@ -105,6 +124,7 @@ function translateArray(
|
|
|
105
124
|
`${baseAliasName}_element`,
|
|
106
125
|
'template',
|
|
107
126
|
'template',
|
|
127
|
+
options,
|
|
108
128
|
)}>`;
|
|
109
129
|
default:
|
|
110
130
|
return `std::vector<${translateNullableParamType(
|
|
@@ -113,6 +133,7 @@ function translateArray(
|
|
|
113
133
|
`${baseAliasName}_element`,
|
|
114
134
|
'template',
|
|
115
135
|
'template',
|
|
136
|
+
options,
|
|
116
137
|
)}> const &`;
|
|
117
138
|
}
|
|
118
139
|
} else {
|
|
@@ -125,12 +146,13 @@ function translateParam(
|
|
|
125
146
|
aliases: AliasMap,
|
|
126
147
|
baseAliasName: string,
|
|
127
148
|
target: ParamTarget,
|
|
149
|
+
options: CppCodegenOptions,
|
|
128
150
|
): string {
|
|
129
151
|
// avoid: Property 'type' does not exist on type 'never'
|
|
130
152
|
const paramType = param.type;
|
|
131
153
|
switch (param.type) {
|
|
132
154
|
case 'StringTypeAnnotation':
|
|
133
|
-
return
|
|
155
|
+
return options.cppStringType;
|
|
134
156
|
case 'NumberTypeAnnotation':
|
|
135
157
|
case 'FloatTypeAnnotation':
|
|
136
158
|
case 'DoubleTypeAnnotation':
|
|
@@ -140,9 +162,9 @@ function translateParam(
|
|
|
140
162
|
case 'BooleanTypeAnnotation':
|
|
141
163
|
return 'bool';
|
|
142
164
|
case 'FunctionTypeAnnotation':
|
|
143
|
-
return translateFunction(param, aliases, baseAliasName, target);
|
|
165
|
+
return translateFunction(param, aliases, baseAliasName, target, options);
|
|
144
166
|
case 'ArrayTypeAnnotation':
|
|
145
|
-
return translateArray(param, aliases, baseAliasName, target);
|
|
167
|
+
return translateArray(param, aliases, baseAliasName, target, options);
|
|
146
168
|
case 'GenericObjectTypeAnnotation':
|
|
147
169
|
return decorateType('::React::JSValue', target);
|
|
148
170
|
case 'ObjectTypeAnnotation':
|
|
@@ -163,7 +185,7 @@ function translateParam(
|
|
|
163
185
|
return decorateType(getAliasCppName(param.name), target);
|
|
164
186
|
case 'EnumDeclaration':
|
|
165
187
|
case 'UnionTypeAnnotation':
|
|
166
|
-
return translateUnionReturnType(param, target);
|
|
188
|
+
return translateUnionReturnType(param, target, options);
|
|
167
189
|
default:
|
|
168
190
|
throw new Error(`Unhandled type in translateParam: ${paramType}`);
|
|
169
191
|
}
|
|
@@ -175,6 +197,7 @@ function translateNullableParamType(
|
|
|
175
197
|
baseAliasName: string,
|
|
176
198
|
nullableTarget: ParamTarget,
|
|
177
199
|
target: ParamTarget,
|
|
200
|
+
options: CppCodegenOptions,
|
|
178
201
|
): string {
|
|
179
202
|
switch (paramType.type) {
|
|
180
203
|
case 'NullableTypeAnnotation':
|
|
@@ -183,9 +206,10 @@ function translateNullableParamType(
|
|
|
183
206
|
aliases,
|
|
184
207
|
baseAliasName,
|
|
185
208
|
nullableTarget,
|
|
209
|
+
options,
|
|
186
210
|
)}>`;
|
|
187
211
|
default:
|
|
188
|
-
return translateParam(paramType, aliases, baseAliasName, target);
|
|
212
|
+
return translateParam(paramType, aliases, baseAliasName, target, options);
|
|
189
213
|
}
|
|
190
214
|
}
|
|
191
215
|
|
|
@@ -193,6 +217,7 @@ function translateSpecFunctionParam(
|
|
|
193
217
|
param: NativeModuleParamShape,
|
|
194
218
|
aliases: AliasMap,
|
|
195
219
|
baseAliasName: string,
|
|
220
|
+
options: CppCodegenOptions,
|
|
196
221
|
): string {
|
|
197
222
|
return translateNullableParamType(
|
|
198
223
|
param.typeAnnotation,
|
|
@@ -200,6 +225,7 @@ function translateSpecFunctionParam(
|
|
|
200
225
|
baseAliasName,
|
|
201
226
|
'spec',
|
|
202
227
|
'spec',
|
|
228
|
+
options,
|
|
203
229
|
);
|
|
204
230
|
}
|
|
205
231
|
|
|
@@ -207,6 +233,7 @@ function translateCallbackParam(
|
|
|
207
233
|
param: NativeModuleParamShape,
|
|
208
234
|
aliases: AliasMap,
|
|
209
235
|
baseAliasName: string,
|
|
236
|
+
options: CppCodegenOptions,
|
|
210
237
|
): string {
|
|
211
238
|
return translateNullableParamType(
|
|
212
239
|
param.typeAnnotation,
|
|
@@ -214,6 +241,7 @@ function translateCallbackParam(
|
|
|
214
241
|
baseAliasName,
|
|
215
242
|
'template',
|
|
216
243
|
'callback-arg',
|
|
244
|
+
options,
|
|
217
245
|
);
|
|
218
246
|
}
|
|
219
247
|
|
|
@@ -221,6 +249,7 @@ function translateFunctionParam(
|
|
|
221
249
|
param: NativeModuleParamShape,
|
|
222
250
|
aliases: AliasMap,
|
|
223
251
|
baseAliasName: string,
|
|
252
|
+
options: CppCodegenOptions,
|
|
224
253
|
): string {
|
|
225
254
|
return translateNullableParamType(
|
|
226
255
|
param.typeAnnotation,
|
|
@@ -228,6 +257,7 @@ function translateFunctionParam(
|
|
|
228
257
|
baseAliasName,
|
|
229
258
|
'template',
|
|
230
259
|
'method-arg',
|
|
260
|
+
options,
|
|
231
261
|
);
|
|
232
262
|
}
|
|
233
263
|
|
|
@@ -235,12 +265,14 @@ export function translateSpecArgs(
|
|
|
235
265
|
params: ReadonlyArray<NativeModuleParamShape>,
|
|
236
266
|
aliases: AliasMap,
|
|
237
267
|
baseAliasName: string,
|
|
268
|
+
options: CppCodegenOptions,
|
|
238
269
|
) {
|
|
239
270
|
return params.map(param => {
|
|
240
271
|
const translatedParam = translateSpecFunctionParam(
|
|
241
272
|
param,
|
|
242
273
|
aliases,
|
|
243
274
|
`${baseAliasName}_${param.name}`,
|
|
275
|
+
options,
|
|
244
276
|
);
|
|
245
277
|
return `${translatedParam}`;
|
|
246
278
|
});
|
|
@@ -250,12 +282,14 @@ export function translateArgs(
|
|
|
250
282
|
params: ReadonlyArray<NativeModuleParamShape>,
|
|
251
283
|
aliases: AliasMap,
|
|
252
284
|
baseAliasName: string,
|
|
285
|
+
options: CppCodegenOptions,
|
|
253
286
|
) {
|
|
254
287
|
return params.map(param => {
|
|
255
288
|
const translatedParam = translateFunctionParam(
|
|
256
289
|
param,
|
|
257
290
|
aliases,
|
|
258
291
|
`${baseAliasName}_${param.name}`,
|
|
292
|
+
options,
|
|
259
293
|
);
|
|
260
294
|
return `${translatedParam} ${param.name}`;
|
|
261
295
|
});
|
|
@@ -11,12 +11,13 @@ import type {
|
|
|
11
11
|
Nullable,
|
|
12
12
|
} from 'react-native-tscodegen';
|
|
13
13
|
import {AliasMap} from './AliasManaging';
|
|
14
|
-
import {translateFieldOrReturnType} from './ObjectTypes';
|
|
14
|
+
import {CppCodegenOptions, translateFieldOrReturnType} from './ObjectTypes';
|
|
15
15
|
|
|
16
16
|
function translateReturnType(
|
|
17
17
|
type: Nullable<NativeModuleReturnTypeAnnotation>,
|
|
18
18
|
aliases: AliasMap,
|
|
19
19
|
baseAliasName: string,
|
|
20
|
+
options: CppCodegenOptions,
|
|
20
21
|
): string {
|
|
21
22
|
switch (type.type) {
|
|
22
23
|
case 'VoidTypeAnnotation':
|
|
@@ -27,6 +28,7 @@ function translateReturnType(
|
|
|
27
28
|
type.typeAnnotation,
|
|
28
29
|
aliases,
|
|
29
30
|
baseAliasName,
|
|
31
|
+
options,
|
|
30
32
|
)}>`;
|
|
31
33
|
default:
|
|
32
34
|
return translateFieldOrReturnType(
|
|
@@ -34,6 +36,7 @@ function translateReturnType(
|
|
|
34
36
|
aliases,
|
|
35
37
|
baseAliasName,
|
|
36
38
|
'translateReturnType',
|
|
39
|
+
options,
|
|
37
40
|
);
|
|
38
41
|
}
|
|
39
42
|
}
|
|
@@ -42,14 +45,26 @@ export function translateSpecReturnType(
|
|
|
42
45
|
type: Nullable<NativeModuleReturnTypeAnnotation>,
|
|
43
46
|
aliases: AliasMap,
|
|
44
47
|
baseAliasName: string,
|
|
48
|
+
options: CppCodegenOptions,
|
|
45
49
|
) {
|
|
46
|
-
return translateReturnType(
|
|
50
|
+
return translateReturnType(
|
|
51
|
+
type,
|
|
52
|
+
aliases,
|
|
53
|
+
`${baseAliasName}_returnType`,
|
|
54
|
+
options,
|
|
55
|
+
);
|
|
47
56
|
}
|
|
48
57
|
|
|
49
58
|
export function translateImplReturnType(
|
|
50
59
|
type: Nullable<NativeModuleReturnTypeAnnotation>,
|
|
51
60
|
aliases: AliasMap,
|
|
52
61
|
baseAliasName: string,
|
|
62
|
+
options: CppCodegenOptions,
|
|
53
63
|
) {
|
|
54
|
-
return translateReturnType(
|
|
64
|
+
return translateReturnType(
|
|
65
|
+
type,
|
|
66
|
+
aliases,
|
|
67
|
+
`${baseAliasName}_returnType`,
|
|
68
|
+
options,
|
|
69
|
+
);
|
|
55
70
|
}
|
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
NativeModuleSchema,
|
|
13
13
|
} from 'react-native-tscodegen';
|
|
14
14
|
import {AliasMap} from './AliasManaging';
|
|
15
|
+
import type {CppCodegenOptions} from './ObjectTypes';
|
|
15
16
|
import {translateArgs, translateSpecArgs} from './ParamTypes';
|
|
16
17
|
import {translateImplReturnType, translateSpecReturnType} from './ReturnTypes';
|
|
17
18
|
|
|
@@ -27,8 +28,9 @@ function getPossibleMethodSignatures(
|
|
|
27
28
|
funcType: NativeModuleFunctionTypeAnnotation,
|
|
28
29
|
aliases: AliasMap,
|
|
29
30
|
baseAliasName: string,
|
|
31
|
+
options: CppCodegenOptions,
|
|
30
32
|
): string[] {
|
|
31
|
-
const args = translateArgs(funcType.params, aliases, baseAliasName);
|
|
33
|
+
const args = translateArgs(funcType.params, aliases, baseAliasName, options);
|
|
32
34
|
if (funcType.returnTypeAnnotation.type === 'PromiseTypeAnnotation') {
|
|
33
35
|
if (funcType.returnTypeAnnotation.elementType) {
|
|
34
36
|
args.push(
|
|
@@ -36,6 +38,7 @@ function getPossibleMethodSignatures(
|
|
|
36
38
|
funcType.returnTypeAnnotation.elementType,
|
|
37
39
|
aliases,
|
|
38
40
|
baseAliasName,
|
|
41
|
+
options,
|
|
39
42
|
)}> &&result`,
|
|
40
43
|
);
|
|
41
44
|
} else {
|
|
@@ -50,6 +53,7 @@ function getPossibleMethodSignatures(
|
|
|
50
53
|
funcType.returnTypeAnnotation,
|
|
51
54
|
aliases,
|
|
52
55
|
baseAliasName,
|
|
56
|
+
options,
|
|
53
57
|
)} ${prop.name}(${args.join(', ')}) noexcept { /* implementation */ }`;
|
|
54
58
|
|
|
55
59
|
const staticsig = `REACT_${isMethodSync(funcType) ? 'SYNC_' : ''}METHOD(${
|
|
@@ -58,6 +62,7 @@ function getPossibleMethodSignatures(
|
|
|
58
62
|
funcType.returnTypeAnnotation,
|
|
59
63
|
aliases,
|
|
60
64
|
baseAliasName,
|
|
65
|
+
options,
|
|
61
66
|
)} ${prop.name}(${args.join(', ')}) noexcept { /* implementation */ }`;
|
|
62
67
|
|
|
63
68
|
return [sig, staticsig];
|
|
@@ -68,8 +73,15 @@ function translatePossibleMethodSignatures(
|
|
|
68
73
|
funcType: NativeModuleFunctionTypeAnnotation,
|
|
69
74
|
aliases: AliasMap,
|
|
70
75
|
baseAliasName: string,
|
|
76
|
+
options: CppCodegenOptions,
|
|
71
77
|
): string {
|
|
72
|
-
return getPossibleMethodSignatures(
|
|
78
|
+
return getPossibleMethodSignatures(
|
|
79
|
+
prop,
|
|
80
|
+
funcType,
|
|
81
|
+
aliases,
|
|
82
|
+
baseAliasName,
|
|
83
|
+
options,
|
|
84
|
+
)
|
|
73
85
|
.map(sig => `" ${sig}\\n"`)
|
|
74
86
|
.join('\n ');
|
|
75
87
|
}
|
|
@@ -78,6 +90,7 @@ function renderProperties(
|
|
|
78
90
|
properties: ReadonlyArray<NativeModulePropertyShape>,
|
|
79
91
|
aliases: AliasMap,
|
|
80
92
|
tuple: boolean,
|
|
93
|
+
options: CppCodegenOptions,
|
|
81
94
|
): string {
|
|
82
95
|
// TODO: generate code for constants
|
|
83
96
|
return properties
|
|
@@ -95,12 +108,14 @@ function renderProperties(
|
|
|
95
108
|
funcType.params,
|
|
96
109
|
aliases,
|
|
97
110
|
propAliasName,
|
|
111
|
+
options,
|
|
98
112
|
);
|
|
99
113
|
|
|
100
114
|
const translatedReturnParam = translateSpecReturnType(
|
|
101
115
|
funcType.returnTypeAnnotation,
|
|
102
116
|
aliases,
|
|
103
117
|
propAliasName,
|
|
118
|
+
options,
|
|
104
119
|
);
|
|
105
120
|
|
|
106
121
|
if (funcType.returnTypeAnnotation.type === 'PromiseTypeAnnotation') {
|
|
@@ -110,6 +125,7 @@ function renderProperties(
|
|
|
110
125
|
funcType.returnTypeAnnotation.elementType,
|
|
111
126
|
aliases,
|
|
112
127
|
propAliasName,
|
|
128
|
+
options,
|
|
113
129
|
)}>`,
|
|
114
130
|
);
|
|
115
131
|
} else {
|
|
@@ -132,6 +148,7 @@ function renderProperties(
|
|
|
132
148
|
funcType,
|
|
133
149
|
aliases,
|
|
134
150
|
propAliasName,
|
|
151
|
+
options,
|
|
135
152
|
)});`;
|
|
136
153
|
}
|
|
137
154
|
})
|
|
@@ -141,9 +158,20 @@ function renderProperties(
|
|
|
141
158
|
export function generateValidateMethods(
|
|
142
159
|
nativeModule: NativeModuleSchema,
|
|
143
160
|
aliases: AliasMap,
|
|
161
|
+
options: CppCodegenOptions,
|
|
144
162
|
): [string, string] {
|
|
145
163
|
const properties = nativeModule.spec.properties;
|
|
146
|
-
const traversedProperties = renderProperties(
|
|
147
|
-
|
|
164
|
+
const traversedProperties = renderProperties(
|
|
165
|
+
properties,
|
|
166
|
+
aliases,
|
|
167
|
+
false,
|
|
168
|
+
options,
|
|
169
|
+
);
|
|
170
|
+
const traversedPropertyTuples = renderProperties(
|
|
171
|
+
properties,
|
|
172
|
+
aliases,
|
|
173
|
+
true,
|
|
174
|
+
options,
|
|
175
|
+
);
|
|
148
176
|
return [traversedPropertyTuples, traversedProperties];
|
|
149
177
|
}
|
package/src/index.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import path from 'path';
|
|
9
9
|
import fs from '@react-native-windows/fs';
|
|
10
10
|
import globby from 'globby';
|
|
11
|
+
import type {CppStringTypes} from './generators/GenerateNM2';
|
|
11
12
|
import {createNM2Generator} from './generators/GenerateNM2';
|
|
12
13
|
import {
|
|
13
14
|
generateTypeScript,
|
|
@@ -15,7 +16,9 @@ import {
|
|
|
15
16
|
} from './generators/GenerateTypeScript';
|
|
16
17
|
import type {SchemaType} from 'react-native-tscodegen';
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
export type {CppStringTypes} from './generators/GenerateNM2';
|
|
20
|
+
|
|
21
|
+
// Load @react-native/codegen from react-native
|
|
19
22
|
const rnPath = path.dirname(require.resolve('react-native/package.json'));
|
|
20
23
|
const rncodegenPath = path.dirname(
|
|
21
24
|
require.resolve('react-native-codegen/package.json', {paths: [rnPath]}),
|
|
@@ -31,15 +34,19 @@ const schemaValidator = require(path.resolve(
|
|
|
31
34
|
'lib/SchemaValidator',
|
|
32
35
|
));
|
|
33
36
|
|
|
34
|
-
interface
|
|
37
|
+
export interface SharedOptions {
|
|
35
38
|
libraryName: string;
|
|
36
39
|
methodOnly: boolean;
|
|
37
40
|
modulesCxx: boolean;
|
|
38
|
-
moduleSpecName: string;
|
|
39
41
|
modulesTypeScriptTypes: boolean;
|
|
40
42
|
modulesWindows: boolean;
|
|
41
43
|
namespace: string;
|
|
42
44
|
outputDirectory: string;
|
|
45
|
+
cppStringType: CppStringTypes;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface Options extends SharedOptions {
|
|
49
|
+
moduleSpecName: string;
|
|
43
50
|
schema: SchemaType;
|
|
44
51
|
}
|
|
45
52
|
|
|
@@ -183,11 +190,12 @@ export function generate(
|
|
|
183
190
|
libraryName,
|
|
184
191
|
methodOnly,
|
|
185
192
|
modulesCxx,
|
|
186
|
-
moduleSpecName,
|
|
187
193
|
modulesTypeScriptTypes,
|
|
188
194
|
modulesWindows,
|
|
189
195
|
namespace,
|
|
190
196
|
outputDirectory,
|
|
197
|
+
cppStringType,
|
|
198
|
+
moduleSpecName,
|
|
191
199
|
schema,
|
|
192
200
|
}: Options,
|
|
193
201
|
{/*generators,*/ test}: Config,
|
|
@@ -210,6 +218,7 @@ export function generate(
|
|
|
210
218
|
const generateNM2 = createNM2Generator({
|
|
211
219
|
methodOnly,
|
|
212
220
|
namespace,
|
|
221
|
+
cppStringType,
|
|
213
222
|
});
|
|
214
223
|
|
|
215
224
|
const generateJsiModuleH = require(path.resolve(
|
|
@@ -315,18 +324,11 @@ export function generate(
|
|
|
315
324
|
return writeMapToFiles(generatedFiles, outputDirectory);
|
|
316
325
|
}
|
|
317
326
|
|
|
318
|
-
export
|
|
327
|
+
export interface CodeGenOptions extends SharedOptions {
|
|
319
328
|
file?: string;
|
|
320
329
|
files?: string[];
|
|
321
|
-
libraryName: string;
|
|
322
|
-
methodOnly: boolean;
|
|
323
|
-
modulesCxx: boolean;
|
|
324
|
-
modulesTypeScriptTypes: boolean;
|
|
325
|
-
modulesWindows: boolean;
|
|
326
|
-
namespace: string;
|
|
327
|
-
outputDirectory: string;
|
|
328
330
|
test: boolean;
|
|
329
|
-
}
|
|
331
|
+
}
|
|
330
332
|
|
|
331
333
|
export function runCodeGen(options: CodeGenOptions): boolean {
|
|
332
334
|
if (!options.file && !options.files)
|
|
@@ -345,17 +347,19 @@ export function runCodeGen(options: CodeGenOptions): boolean {
|
|
|
345
347
|
modulesWindows,
|
|
346
348
|
namespace,
|
|
347
349
|
outputDirectory,
|
|
350
|
+
cppStringType,
|
|
348
351
|
} = options;
|
|
349
352
|
return generate(
|
|
350
353
|
{
|
|
351
354
|
libraryName,
|
|
352
355
|
methodOnly,
|
|
353
356
|
modulesCxx,
|
|
354
|
-
moduleSpecName,
|
|
355
357
|
modulesTypeScriptTypes,
|
|
356
358
|
modulesWindows,
|
|
357
359
|
namespace,
|
|
358
360
|
outputDirectory,
|
|
361
|
+
cppStringType,
|
|
362
|
+
moduleSpecName,
|
|
359
363
|
schema,
|
|
360
364
|
},
|
|
361
365
|
{generators: [], test: options.test},
|