nitrogen 0.31.10 → 0.32.0
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/lib/autolinking/ios/createPodspecRubyExtension.js +1 -1
- package/lib/index.js +1 -1
- package/lib/syntax/c++/CppStruct.js +20 -4
- package/lib/syntax/createType.js +1 -1
- package/lib/syntax/getHybridObjectName.d.ts +1 -1
- package/lib/syntax/kotlin/KotlinCxxBridgedType.js +19 -13
- package/lib/syntax/kotlin/KotlinEnum.js +3 -6
- package/lib/syntax/kotlin/KotlinStruct.js +1 -1
- package/lib/syntax/kotlin/KotlinVariant.js +1 -1
- package/lib/syntax/swift/SwiftCxxTypeHelper.js +1 -1
- package/lib/syntax/swift/SwiftStruct.js +2 -8
- package/lib/syntax/types/AnyHybridObjectType.d.ts +1 -0
- package/lib/syntax/types/AnyHybridObjectType.js +3 -0
- package/lib/syntax/types/ArrayBufferType.d.ts +1 -0
- package/lib/syntax/types/ArrayBufferType.js +3 -0
- package/lib/syntax/types/ArrayType.d.ts +1 -0
- package/lib/syntax/types/ArrayType.js +3 -0
- package/lib/syntax/types/BigIntType.d.ts +1 -0
- package/lib/syntax/types/BigIntType.js +3 -0
- package/lib/syntax/types/BooleanType.d.ts +1 -0
- package/lib/syntax/types/BooleanType.js +3 -0
- package/lib/syntax/types/CustomType.d.ts +1 -0
- package/lib/syntax/types/CustomType.js +3 -0
- package/lib/syntax/types/DateType.d.ts +1 -0
- package/lib/syntax/types/DateType.js +3 -0
- package/lib/syntax/types/EnumType.d.ts +1 -0
- package/lib/syntax/types/EnumType.js +3 -0
- package/lib/syntax/types/ErrorType.d.ts +1 -0
- package/lib/syntax/types/ErrorType.js +4 -1
- package/lib/syntax/types/FunctionType.d.ts +1 -0
- package/lib/syntax/types/FunctionType.js +3 -0
- package/lib/syntax/types/HybridObjectType.d.ts +1 -0
- package/lib/syntax/types/HybridObjectType.js +3 -0
- package/lib/syntax/types/MapType.d.ts +1 -0
- package/lib/syntax/types/MapType.js +3 -0
- package/lib/syntax/types/NamedWrappingType.d.ts +1 -0
- package/lib/syntax/types/NamedWrappingType.js +3 -0
- package/lib/syntax/types/NullType.d.ts +1 -0
- package/lib/syntax/types/NullType.js +3 -0
- package/lib/syntax/types/NumberType.d.ts +1 -0
- package/lib/syntax/types/NumberType.js +3 -0
- package/lib/syntax/types/OptionalType.d.ts +1 -0
- package/lib/syntax/types/OptionalType.js +3 -0
- package/lib/syntax/types/PromiseType.d.ts +1 -0
- package/lib/syntax/types/PromiseType.js +3 -0
- package/lib/syntax/types/RecordType.d.ts +1 -0
- package/lib/syntax/types/RecordType.js +3 -0
- package/lib/syntax/types/ResultWrappingType.d.ts +1 -0
- package/lib/syntax/types/ResultWrappingType.js +3 -0
- package/lib/syntax/types/StringType.d.ts +1 -0
- package/lib/syntax/types/StringType.js +3 -0
- package/lib/syntax/types/StructType.d.ts +1 -0
- package/lib/syntax/types/StructType.js +3 -0
- package/lib/syntax/types/TupleType.d.ts +1 -0
- package/lib/syntax/types/TupleType.js +3 -0
- package/lib/syntax/types/Type.d.ts +4 -0
- package/lib/syntax/types/VariantType.d.ts +1 -0
- package/lib/syntax/types/VariantType.js +3 -0
- package/lib/syntax/types/VoidType.d.ts +1 -0
- package/lib/syntax/types/VoidType.js +3 -0
- package/lib/views/CppHybridViewComponent.js +2 -1
- package/lib/writeFile.d.ts +1 -1
- package/lib/writeFile.js +1 -1
- package/package.json +2 -3
- package/src/autolinking/ios/createPodspecRubyExtension.ts +1 -1
- package/src/index.ts +1 -1
- package/src/syntax/c++/CppStruct.ts +20 -4
- package/src/syntax/createType.ts +1 -1
- package/src/syntax/getHybridObjectName.ts +1 -1
- package/src/syntax/kotlin/KotlinCxxBridgedType.ts +29 -13
- package/src/syntax/kotlin/KotlinEnum.ts +3 -7
- package/src/syntax/kotlin/KotlinStruct.ts +1 -1
- package/src/syntax/kotlin/KotlinVariant.ts +1 -1
- package/src/syntax/swift/SwiftCxxTypeHelper.ts +1 -1
- package/src/syntax/swift/SwiftStruct.ts +2 -8
- package/src/syntax/types/AnyHybridObjectType.ts +3 -0
- package/src/syntax/types/ArrayBufferType.ts +3 -0
- package/src/syntax/types/ArrayType.ts +3 -0
- package/src/syntax/types/BigIntType.ts +3 -0
- package/src/syntax/types/BooleanType.ts +3 -0
- package/src/syntax/types/CustomType.ts +3 -0
- package/src/syntax/types/DateType.ts +3 -0
- package/src/syntax/types/EnumType.ts +3 -0
- package/src/syntax/types/ErrorType.ts +4 -1
- package/src/syntax/types/FunctionType.ts +3 -0
- package/src/syntax/types/HybridObjectType.ts +3 -0
- package/src/syntax/types/MapType.ts +3 -0
- package/src/syntax/types/NamedWrappingType.ts +3 -0
- package/src/syntax/types/NullType.ts +3 -0
- package/src/syntax/types/NumberType.ts +3 -0
- package/src/syntax/types/OptionalType.ts +3 -0
- package/src/syntax/types/PromiseType.ts +3 -0
- package/src/syntax/types/RecordType.ts +3 -0
- package/src/syntax/types/ResultWrappingType.ts +3 -0
- package/src/syntax/types/StringType.ts +3 -0
- package/src/syntax/types/StructType.ts +3 -0
- package/src/syntax/types/TupleType.ts +3 -0
- package/src/syntax/types/Type.ts +4 -0
- package/src/syntax/types/VariantType.ts +3 -0
- package/src/syntax/types/VoidType.ts +3 -0
- package/src/views/CppHybridViewComponent.ts +2 -1
- package/src/writeFile.ts +1 -1
- package/lib/syntax/types/UndefinedType.d.ts +0 -10
- package/lib/syntax/types/UndefinedType.js +0 -23
|
@@ -52,7 +52,7 @@ def add_nitrogen_files(spec)
|
|
|
52
52
|
spec.pod_target_xcconfig = current_pod_target_xcconfig.merge({
|
|
53
53
|
# Use C++ 20
|
|
54
54
|
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
|
|
55
|
-
# Enables C++ <-> Swift interop (by default it's only
|
|
55
|
+
# Enables C++ <-> Swift interop (by default it's only ObjC)
|
|
56
56
|
"SWIFT_OBJC_INTEROP_MODE" => "objcxx",
|
|
57
57
|
# Enables stricter modular headers
|
|
58
58
|
"DEFINES_MODULE" => "YES",
|
package/lib/index.js
CHANGED
|
@@ -67,7 +67,7 @@ await yargs(hideBin(process.argv))
|
|
|
67
67
|
.usage(`Usage: ${chalk.bold('$0 [options]')}\n` +
|
|
68
68
|
`$0 is a code-generater for Nitro Modules (${chalk.underline('https://github.com/mrousavy/nitro')})\n` +
|
|
69
69
|
`It converts all TypeScript specs found in ${chalk.underline('**/*.nitro.ts')} to C++, Swift or Kotlin specs.\n` +
|
|
70
|
-
`Each library/module must have a ${chalk.underline('nitro.json')} configuration file in
|
|
70
|
+
`Each library/module must have a ${chalk.underline('nitro.json')} configuration file in its root directory.\n` +
|
|
71
71
|
`$Nitrogen Version: ${chalk.bold(NITROGEN_VERSION)}`)
|
|
72
72
|
.help()
|
|
73
73
|
.strict()
|
|
@@ -21,16 +21,28 @@ export function createCppStruct(typename, properties) {
|
|
|
21
21
|
includeNameInfo: false,
|
|
22
22
|
};
|
|
23
23
|
const cppFromJsiParams = properties
|
|
24
|
-
.map((p) => `JSIConverter<${p.getCode('c++', codeOptions)}>::fromJSI(runtime, obj.getProperty(runtime, "${p.name}"))`)
|
|
24
|
+
.map((p) => `JSIConverter<${p.getCode('c++', codeOptions)}>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "${p.name}")))`)
|
|
25
25
|
.join(',\n');
|
|
26
26
|
// Get C++ code for converting each member to a jsi::Value
|
|
27
27
|
const cppToJsiCalls = properties
|
|
28
|
-
.map((p) => `obj.setProperty(runtime, "${p.name}", JSIConverter<${p.getCode('c++', codeOptions)}>::toJSI(runtime, arg.${p.escapedName}));`)
|
|
28
|
+
.map((p) => `obj.setProperty(runtime, PropNameIDCache::get(runtime, "${p.name}"), JSIConverter<${p.getCode('c++', codeOptions)}>::toJSI(runtime, arg.${p.escapedName}));`)
|
|
29
29
|
.join('\n');
|
|
30
30
|
// Get C++ code for verifying if jsi::Value can be converted to type
|
|
31
31
|
const cppCanConvertCalls = properties
|
|
32
|
-
.map((p) => `if (!JSIConverter<${p.getCode('c++', codeOptions)}>::canConvert(runtime, obj.getProperty(runtime, "${p.name}"))) return false;`)
|
|
32
|
+
.map((p) => `if (!JSIConverter<${p.getCode('c++', codeOptions)}>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "${p.name}")))) return false;`)
|
|
33
33
|
.join('\n');
|
|
34
|
+
// Only equatable types have an operator== overload
|
|
35
|
+
let equatableFunc;
|
|
36
|
+
const isEquatable = properties.every((p) => p.isEquatable);
|
|
37
|
+
if (isEquatable) {
|
|
38
|
+
equatableFunc = `friend bool operator==(const ${typename}& lhs, const ${typename}& rhs) = default;`;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const nonEquatableTypes = properties
|
|
42
|
+
.filter((p) => !p.isEquatable)
|
|
43
|
+
.map((p) => p.name);
|
|
44
|
+
equatableFunc = `// ${typename} is not equatable because these properties are not equatable: ${nonEquatableTypes.join(', ')}`;
|
|
45
|
+
}
|
|
34
46
|
// Get C++ includes for each extra-file we need to include
|
|
35
47
|
const includedTypes = properties.flatMap((r) => r.getRequiredImports('c++'));
|
|
36
48
|
const cppForwardDeclarations = includedTypes
|
|
@@ -49,6 +61,7 @@ ${createFileMetadataString(`${typename}.hpp`)}
|
|
|
49
61
|
${includeNitroHeader('JSIConverter.hpp')}
|
|
50
62
|
${includeNitroHeader('NitroDefines.hpp')}
|
|
51
63
|
${includeNitroHeader('JSIHelpers.hpp')}
|
|
64
|
+
${includeNitroHeader('PropNameIDCache.hpp')}
|
|
52
65
|
|
|
53
66
|
${cppForwardDeclarations.join('\n')}
|
|
54
67
|
|
|
@@ -59,13 +72,16 @@ namespace ${cxxNamespace} {
|
|
|
59
72
|
/**
|
|
60
73
|
* A struct which can be represented as a JavaScript object (${typename}).
|
|
61
74
|
*/
|
|
62
|
-
struct ${typename} {
|
|
75
|
+
struct ${typename} final {
|
|
63
76
|
public:
|
|
64
77
|
${indent(cppStructProps, ' ')}
|
|
65
78
|
|
|
66
79
|
public:
|
|
67
80
|
${typename}() = default;
|
|
68
81
|
explicit ${typename}(${cppConstructorParams}): ${cppInitializerParams} {}
|
|
82
|
+
|
|
83
|
+
public:
|
|
84
|
+
${indent(equatableFunc, ' ')}
|
|
69
85
|
};
|
|
70
86
|
|
|
71
87
|
} // namespace ${cxxNamespace}
|
package/lib/syntax/createType.js
CHANGED
|
@@ -302,7 +302,7 @@ export function createType(language, type, isOptional) {
|
|
|
302
302
|
}
|
|
303
303
|
else if (type.isUndefined()) {
|
|
304
304
|
throw new Error(`The TypeScript type "undefined" cannot be represented in Nitro.\n` +
|
|
305
|
-
`- If you want to make a type optional, add \`?\` to
|
|
305
|
+
`- If you want to make a type optional, add \`?\` to its name, or make it an union with \`undefined\`.\n` +
|
|
306
306
|
`- If you want a method that returns nothing, use \`void\` instead.\n` +
|
|
307
307
|
`- If you want to represent an explicit absence of a value, use \`null\` instead.`);
|
|
308
308
|
}
|
|
@@ -11,7 +11,7 @@ export interface HybridObjectName {
|
|
|
11
11
|
HybridT: string;
|
|
12
12
|
/**
|
|
13
13
|
* The name of the C++ class, Kotlin interface or Swift protocol that represents the
|
|
14
|
-
* specification (all of
|
|
14
|
+
* specification (all of its virtual properties and methods) of the Hybrid Object.
|
|
15
15
|
* @example "HybridImageSpec"
|
|
16
16
|
*/
|
|
17
17
|
HybridTSpec: string;
|
|
@@ -100,11 +100,6 @@ export class KotlinCxxBridgedType {
|
|
|
100
100
|
name: 'NitroModules/JArrayBuffer.hpp',
|
|
101
101
|
space: 'system',
|
|
102
102
|
});
|
|
103
|
-
imports.push({
|
|
104
|
-
language: 'c++',
|
|
105
|
-
name: 'NitroModules/JUnit.hpp',
|
|
106
|
-
space: 'system',
|
|
107
|
-
});
|
|
108
103
|
break;
|
|
109
104
|
case 'promise':
|
|
110
105
|
imports.push({
|
|
@@ -112,6 +107,15 @@ export class KotlinCxxBridgedType {
|
|
|
112
107
|
name: 'NitroModules/JPromise.hpp',
|
|
113
108
|
space: 'system',
|
|
114
109
|
});
|
|
110
|
+
const promiseType = getTypeAs(this.type, PromiseType);
|
|
111
|
+
if (promiseType.resultingType.kind === 'void') {
|
|
112
|
+
// Promise<void> uses JUnit
|
|
113
|
+
imports.push({
|
|
114
|
+
language: 'c++',
|
|
115
|
+
name: 'NitroModules/JUnit.hpp',
|
|
116
|
+
space: 'system',
|
|
117
|
+
});
|
|
118
|
+
}
|
|
115
119
|
break;
|
|
116
120
|
case 'date':
|
|
117
121
|
imports.push({
|
|
@@ -274,8 +278,8 @@ export class KotlinCxxBridgedType {
|
|
|
274
278
|
switch (language) {
|
|
275
279
|
case 'c++':
|
|
276
280
|
const recordType = getTypeAs(this.type, RecordType);
|
|
277
|
-
const keyType = new KotlinCxxBridgedType(recordType.keyType).getTypeCode(language);
|
|
278
|
-
const valueType = new KotlinCxxBridgedType(recordType.valueType).getTypeCode(language);
|
|
281
|
+
const keyType = new KotlinCxxBridgedType(recordType.keyType).getTypeCode(language, true);
|
|
282
|
+
const valueType = new KotlinCxxBridgedType(recordType.valueType).getTypeCode(language, true);
|
|
279
283
|
return `jni::JMap<${keyType}, ${valueType}>`;
|
|
280
284
|
default:
|
|
281
285
|
return this.type.getCode(language);
|
|
@@ -552,10 +556,12 @@ export class KotlinCxxBridgedType {
|
|
|
552
556
|
const record = getTypeAs(this.type, RecordType);
|
|
553
557
|
const key = new KotlinCxxBridgedType(record.keyType);
|
|
554
558
|
const value = new KotlinCxxBridgedType(record.valueType);
|
|
555
|
-
const parseKey = key.parseFromCppToKotlin('__entry.first', 'c++');
|
|
556
|
-
const parseValue = value.parseFromCppToKotlin('__entry.second', 'c++');
|
|
557
|
-
const
|
|
558
|
-
const
|
|
559
|
+
const parseKey = key.parseFromCppToKotlin('__entry.first', 'c++', true);
|
|
560
|
+
const parseValue = value.parseFromCppToKotlin('__entry.second', 'c++', true);
|
|
561
|
+
const keyType = key.getTypeCode('c++', true);
|
|
562
|
+
const valueType = value.getTypeCode('c++', true);
|
|
563
|
+
const javaMapType = `jni::JMap<${keyType}, ${valueType}>`;
|
|
564
|
+
const javaHashMapType = `jni::JHashMap<${keyType}, ${valueType}>`;
|
|
559
565
|
return `
|
|
560
566
|
[&]() -> jni::local_ref<${javaMapType}> {
|
|
561
567
|
auto __map = ${javaHashMapType}::create(${parameterName}.size());
|
|
@@ -817,8 +823,8 @@ export class KotlinCxxBridgedType {
|
|
|
817
823
|
const record = getTypeAs(this.type, RecordType);
|
|
818
824
|
const key = new KotlinCxxBridgedType(record.keyType);
|
|
819
825
|
const value = new KotlinCxxBridgedType(record.valueType);
|
|
820
|
-
const parseKey = key.parseFromKotlinToCpp('__entry.first', 'c++');
|
|
821
|
-
const parseValue = value.parseFromKotlinToCpp('__entry.second', 'c++');
|
|
826
|
+
const parseKey = key.parseFromKotlinToCpp('__entry.first', 'c++', true);
|
|
827
|
+
const parseValue = value.parseFromKotlinToCpp('__entry.second', 'c++', true);
|
|
822
828
|
const cxxType = this.type.getCode('c++');
|
|
823
829
|
return `
|
|
824
830
|
[&]() {
|
|
@@ -20,6 +20,8 @@ import com.facebook.proguard.annotations.DoNotStrip
|
|
|
20
20
|
@Keep
|
|
21
21
|
enum class ${enumType.enumName}(@DoNotStrip @Keep val value: Int) {
|
|
22
22
|
${indent(members.join(',\n'), ' ')};
|
|
23
|
+
|
|
24
|
+
companion object
|
|
23
25
|
}
|
|
24
26
|
`.trim();
|
|
25
27
|
const cxxNamespace = NitroConfig.current.getCxxNamespace('c++');
|
|
@@ -88,21 +90,16 @@ namespace ${cxxNamespace} {
|
|
|
88
90
|
}
|
|
89
91
|
function getCppToJniConverterCode(cppValueName, enumType) {
|
|
90
92
|
const jniEnumName = `J${enumType.enumName}`;
|
|
91
|
-
const fields = enumType.enumMembers.map((m) => {
|
|
92
|
-
const fieldName = `field${capitalizeName(m.name)}`;
|
|
93
|
-
return `static const auto ${fieldName} = clazz->getStaticField<${jniEnumName}>("${m.name}");`;
|
|
94
|
-
});
|
|
95
93
|
const cases = enumType.enumMembers.map((m) => {
|
|
96
94
|
const fieldName = `field${capitalizeName(m.name)}`;
|
|
97
95
|
return `
|
|
98
96
|
case ${enumType.enumName}::${m.name}:
|
|
97
|
+
static const auto ${fieldName} = clazz->getStaticField<${jniEnumName}>("${m.name}");
|
|
99
98
|
return clazz->getStaticFieldValue(${fieldName});
|
|
100
99
|
`.trim();
|
|
101
100
|
});
|
|
102
101
|
return `
|
|
103
102
|
static const auto clazz = javaClassStatic();
|
|
104
|
-
${fields.join('\n')}
|
|
105
|
-
|
|
106
103
|
switch (${cppValueName}) {
|
|
107
104
|
${indent(cases.join('\n'), ' ')}
|
|
108
105
|
default:
|
|
@@ -134,7 +134,7 @@ if (isInstanceOf(${namespace}::${innerName}::javaClassStatic())) {
|
|
|
134
134
|
const innerName = capitalizeName(label);
|
|
135
135
|
const descriptor = NitroConfig.current.getAndroidPackage('c++/jni', `${kotlinName}$${innerName}`);
|
|
136
136
|
return `
|
|
137
|
-
class ${innerName}: public jni::JavaClass<${innerName}, J${kotlinName}> {
|
|
137
|
+
class ${innerName} final: public jni::JavaClass<${innerName}, J${kotlinName}> {
|
|
138
138
|
public:
|
|
139
139
|
static auto constexpr kJavaDescriptor = "L${descriptor};";
|
|
140
140
|
|
|
@@ -462,7 +462,7 @@ inline ${t.getCode('c++')} get_${i}() const noexcept {
|
|
|
462
462
|
* std::variant cannot be used in Swift because of a Swift bug.
|
|
463
463
|
* Not even specializing it works. So we create a wrapper struct.
|
|
464
464
|
*/
|
|
465
|
-
struct ${name} {
|
|
465
|
+
struct ${name} final {
|
|
466
466
|
${actualType} variant;
|
|
467
467
|
${name}(${actualType} variant): variant(variant) { }
|
|
468
468
|
operator ${actualType}() const noexcept {
|
|
@@ -13,15 +13,9 @@ export function createSwiftStructBridge(struct) {
|
|
|
13
13
|
const bridge = new SwiftCxxBridgedType(p, true);
|
|
14
14
|
const cppName = `self.__${p.escapedName}`;
|
|
15
15
|
return `
|
|
16
|
+
@inline(__always)
|
|
16
17
|
var ${p.escapedName}: ${p.getCode('swift')} {
|
|
17
|
-
|
|
18
|
-
get {
|
|
19
|
-
return ${indent(bridge.parseFromCppToSwift(cppName, 'swift'), ' ')}
|
|
20
|
-
}
|
|
21
|
-
@inline(__always)
|
|
22
|
-
set {
|
|
23
|
-
${cppName} = ${indent(bridge.parseFromSwiftToCpp('newValue', 'swift'), ' ')}
|
|
24
|
-
}
|
|
18
|
+
return ${indent(bridge.parseFromCppToSwift(cppName, 'swift'), ' ')}
|
|
25
19
|
}
|
|
26
20
|
`.trim();
|
|
27
21
|
})
|
|
@@ -5,6 +5,7 @@ export declare class AnyHybridObjectType implements Type {
|
|
|
5
5
|
constructor();
|
|
6
6
|
get canBePassedByReference(): boolean;
|
|
7
7
|
get kind(): TypeKind;
|
|
8
|
+
get isEquatable(): boolean;
|
|
8
9
|
getCode(language: Language): string;
|
|
9
10
|
getExtraFiles(): SourceFile[];
|
|
10
11
|
getRequiredImports(language: Language): SourceImport[];
|
|
@@ -4,6 +4,7 @@ import type { Type, TypeKind } from './Type.js';
|
|
|
4
4
|
export declare class ArrayBufferType implements Type {
|
|
5
5
|
get canBePassedByReference(): boolean;
|
|
6
6
|
get kind(): TypeKind;
|
|
7
|
+
get isEquatable(): boolean;
|
|
7
8
|
getCode(language: Language): string;
|
|
8
9
|
getExtraFiles(): SourceFile[];
|
|
9
10
|
getRequiredImports(language: Language): SourceImport[];
|
|
@@ -6,6 +6,7 @@ export declare class ArrayType implements Type {
|
|
|
6
6
|
constructor(itemType: Type);
|
|
7
7
|
get canBePassedByReference(): boolean;
|
|
8
8
|
get kind(): TypeKind;
|
|
9
|
+
get isEquatable(): boolean;
|
|
9
10
|
getCode(language: Language, options?: GetCodeOptions): string;
|
|
10
11
|
getExtraFiles(): SourceFile[];
|
|
11
12
|
getRequiredImports(language: Language): SourceImport[];
|
|
@@ -4,6 +4,7 @@ import type { Type, TypeKind } from './Type.js';
|
|
|
4
4
|
export declare class BigIntType implements Type {
|
|
5
5
|
get canBePassedByReference(): boolean;
|
|
6
6
|
get kind(): TypeKind;
|
|
7
|
+
get isEquatable(): boolean;
|
|
7
8
|
getCode(language: Language): string;
|
|
8
9
|
getExtraFiles(): SourceFile[];
|
|
9
10
|
getRequiredImports(): SourceImport[];
|
|
@@ -4,6 +4,7 @@ import type { Type, TypeKind } from './Type.js';
|
|
|
4
4
|
export declare class BooleanType implements Type {
|
|
5
5
|
get canBePassedByReference(): boolean;
|
|
6
6
|
get kind(): TypeKind;
|
|
7
|
+
get isEquatable(): boolean;
|
|
7
8
|
getCode(language: Language): string;
|
|
8
9
|
getExtraFiles(): SourceFile[];
|
|
9
10
|
getRequiredImports(): SourceImport[];
|
|
@@ -8,6 +8,7 @@ export declare class CustomType implements Type {
|
|
|
8
8
|
constructor(typeName: string, typeConfig: CustomTypeConfig);
|
|
9
9
|
get canBePassedByReference(): boolean;
|
|
10
10
|
get kind(): TypeKind;
|
|
11
|
+
get isEquatable(): boolean;
|
|
11
12
|
getCode(language: Language): string;
|
|
12
13
|
getExtraFiles(): SourceFile[];
|
|
13
14
|
getRequiredImports(language: Language): SourceImport[];
|
|
@@ -4,6 +4,7 @@ import type { Type, TypeKind } from './Type.js';
|
|
|
4
4
|
export declare class DateType implements Type {
|
|
5
5
|
get canBePassedByReference(): boolean;
|
|
6
6
|
get kind(): TypeKind;
|
|
7
|
+
get isEquatable(): boolean;
|
|
7
8
|
getCode(language: Language): string;
|
|
8
9
|
getExtraFiles(): SourceFile[];
|
|
9
10
|
getRequiredImports(language: Language): SourceImport[];
|
|
@@ -17,6 +17,7 @@ export declare class EnumType implements Type {
|
|
|
17
17
|
constructor(enumName: string, union: TSMorphType<ts.UnionType>);
|
|
18
18
|
get canBePassedByReference(): boolean;
|
|
19
19
|
get kind(): TypeKind;
|
|
20
|
+
get isEquatable(): boolean;
|
|
20
21
|
getCode(language: Language, { fullyQualified }?: GetCodeOptions): string;
|
|
21
22
|
getExtraFiles(): SourceFile[];
|
|
22
23
|
getRequiredImports(language: Language): SourceImport[];
|
|
@@ -5,6 +5,7 @@ export declare class ErrorType implements Type {
|
|
|
5
5
|
constructor();
|
|
6
6
|
get canBePassedByReference(): boolean;
|
|
7
7
|
get kind(): TypeKind;
|
|
8
|
+
get isEquatable(): boolean;
|
|
8
9
|
getCode(language: Language): string;
|
|
9
10
|
getExtraFiles(): SourceFile[];
|
|
10
11
|
getRequiredImports(language: Language): SourceImport[];
|
|
@@ -2,12 +2,15 @@ import {} from '../SourceFile.js';
|
|
|
2
2
|
export class ErrorType {
|
|
3
3
|
constructor() { }
|
|
4
4
|
get canBePassedByReference() {
|
|
5
|
-
// It's
|
|
5
|
+
// It's an exception<..>, pass by reference.
|
|
6
6
|
return true;
|
|
7
7
|
}
|
|
8
8
|
get kind() {
|
|
9
9
|
return 'error';
|
|
10
10
|
}
|
|
11
|
+
get isEquatable() {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
11
14
|
getCode(language) {
|
|
12
15
|
switch (language) {
|
|
13
16
|
case 'c++':
|
|
@@ -12,6 +12,7 @@ export declare class FunctionType implements Type {
|
|
|
12
12
|
get jsName(): string;
|
|
13
13
|
get canBePassedByReference(): boolean;
|
|
14
14
|
get kind(): TypeKind;
|
|
15
|
+
get isEquatable(): boolean;
|
|
15
16
|
/**
|
|
16
17
|
* For a function, get the forward recreation of it:
|
|
17
18
|
* If variable is called `func`, this would return:
|
|
@@ -15,6 +15,7 @@ export declare class HybridObjectType implements Type {
|
|
|
15
15
|
constructor(spec: HybridObjectSpec);
|
|
16
16
|
get canBePassedByReference(): boolean;
|
|
17
17
|
get kind(): TypeKind;
|
|
18
|
+
get isEquatable(): boolean;
|
|
18
19
|
getCode(language: Language, options?: GetHybridObjectCodeOptions): string;
|
|
19
20
|
getExtraFiles(): SourceFile[];
|
|
20
21
|
private getExternalCxxImportName;
|
|
@@ -32,6 +32,9 @@ export class HybridObjectType {
|
|
|
32
32
|
get kind() {
|
|
33
33
|
return 'hybrid-object';
|
|
34
34
|
}
|
|
35
|
+
get isEquatable() {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
35
38
|
getCode(language, options = {}) {
|
|
36
39
|
const name = getHybridObjectName(this.hybridObjectName);
|
|
37
40
|
const mode = options.mode ?? 'strong';
|
|
@@ -4,6 +4,7 @@ import type { Type, TypeKind } from './Type.js';
|
|
|
4
4
|
export declare class MapType implements Type {
|
|
5
5
|
get canBePassedByReference(): boolean;
|
|
6
6
|
get kind(): TypeKind;
|
|
7
|
+
get isEquatable(): boolean;
|
|
7
8
|
getCode(language: Language): string;
|
|
8
9
|
getExtraFiles(): SourceFile[];
|
|
9
10
|
getRequiredImports(language: Language): SourceImport[];
|
|
@@ -7,6 +7,7 @@ export declare class NamedWrappingType<T extends Type> implements NamedType {
|
|
|
7
7
|
constructor(name: string, type: T);
|
|
8
8
|
get escapedName(): string;
|
|
9
9
|
get kind(): TypeKind;
|
|
10
|
+
get isEquatable(): boolean;
|
|
10
11
|
get canBePassedByReference(): boolean;
|
|
11
12
|
getCode(language: Language, options?: GetCodeOptions): string;
|
|
12
13
|
getExtraFiles(): SourceFile[];
|
|
@@ -4,6 +4,7 @@ import type { Type, TypeKind } from './Type.js';
|
|
|
4
4
|
export declare class NullType implements Type {
|
|
5
5
|
get canBePassedByReference(): boolean;
|
|
6
6
|
get kind(): TypeKind;
|
|
7
|
+
get isEquatable(): boolean;
|
|
7
8
|
getCode(language: Language): string;
|
|
8
9
|
getExtraFiles(): SourceFile[];
|
|
9
10
|
getRequiredImports(language: Language): SourceImport[];
|
|
@@ -4,6 +4,7 @@ import type { Type, TypeKind } from './Type.js';
|
|
|
4
4
|
export declare class NumberType implements Type {
|
|
5
5
|
get canBePassedByReference(): boolean;
|
|
6
6
|
get kind(): TypeKind;
|
|
7
|
+
get isEquatable(): boolean;
|
|
7
8
|
getCode(language: Language): string;
|
|
8
9
|
getExtraFiles(): SourceFile[];
|
|
9
10
|
getRequiredImports(): SourceImport[];
|
|
@@ -6,6 +6,7 @@ export declare class OptionalType implements Type {
|
|
|
6
6
|
constructor(wrappingType: Type);
|
|
7
7
|
get canBePassedByReference(): boolean;
|
|
8
8
|
get kind(): TypeKind;
|
|
9
|
+
get isEquatable(): boolean;
|
|
9
10
|
get needsBraces(): boolean;
|
|
10
11
|
getCode(language: Language, options?: GetCodeOptions): string;
|
|
11
12
|
getExtraFiles(): SourceFile[];
|
|
@@ -8,6 +8,7 @@ export declare class PromiseType implements Type {
|
|
|
8
8
|
constructor(resultingType: Type);
|
|
9
9
|
get canBePassedByReference(): boolean;
|
|
10
10
|
get kind(): TypeKind;
|
|
11
|
+
get isEquatable(): boolean;
|
|
11
12
|
get resolverFunction(): FunctionType;
|
|
12
13
|
get rejecterFunction(): FunctionType;
|
|
13
14
|
getCode(language: Language, options?: GetCodeOptions): string;
|
|
@@ -7,6 +7,7 @@ export declare class RecordType implements Type {
|
|
|
7
7
|
constructor(keyType: Type, valueType: Type);
|
|
8
8
|
get canBePassedByReference(): boolean;
|
|
9
9
|
get kind(): TypeKind;
|
|
10
|
+
get isEquatable(): boolean;
|
|
10
11
|
getCode(language: Language, options?: GetCodeOptions): string;
|
|
11
12
|
getExtraFiles(): SourceFile[];
|
|
12
13
|
getRequiredImports(language: Language): SourceImport[];
|
|
@@ -13,6 +13,9 @@ export class RecordType {
|
|
|
13
13
|
get kind() {
|
|
14
14
|
return 'record';
|
|
15
15
|
}
|
|
16
|
+
get isEquatable() {
|
|
17
|
+
return this.keyType.isEquatable && this.valueType.isEquatable;
|
|
18
|
+
}
|
|
16
19
|
getCode(language, options) {
|
|
17
20
|
const keyCode = this.keyType.getCode(language, options);
|
|
18
21
|
const valueCode = this.valueType.getCode(language, options);
|
|
@@ -7,6 +7,7 @@ export declare class ResultWrappingType implements Type {
|
|
|
7
7
|
constructor(result: Type);
|
|
8
8
|
get canBePassedByReference(): boolean;
|
|
9
9
|
get kind(): TypeKind;
|
|
10
|
+
get isEquatable(): boolean;
|
|
10
11
|
getCode(language: Language, options?: GetCodeOptions): string;
|
|
11
12
|
getExtraFiles(): SourceFile[];
|
|
12
13
|
getRequiredImports(language: Language): SourceImport[];
|
|
@@ -13,6 +13,9 @@ export class ResultWrappingType {
|
|
|
13
13
|
get kind() {
|
|
14
14
|
return 'result-wrapper';
|
|
15
15
|
}
|
|
16
|
+
get isEquatable() {
|
|
17
|
+
return this.result.isEquatable && this.error.isEquatable;
|
|
18
|
+
}
|
|
16
19
|
getCode(language, options) {
|
|
17
20
|
const type = this.result.getCode(language, options);
|
|
18
21
|
switch (language) {
|