nitrogen 0.29.8 → 0.30.1
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/Logger.d.ts +10 -0
- package/lib/autolinking/Autolinking.d.ts +8 -0
- package/lib/autolinking/android/createCMakeExtension.d.ts +6 -0
- package/lib/autolinking/android/createGradleExtension.d.ts +5 -0
- package/lib/autolinking/android/createHybridObjectInitializer.d.ts +2 -0
- package/lib/autolinking/createAndroidAutolinking.d.ts +11 -0
- package/lib/autolinking/createIOSAutolinking.d.ts +5 -0
- package/lib/autolinking/ios/createHybridObjectInitializer.d.ts +9 -0
- package/lib/autolinking/ios/createPodspecRubyExtension.d.ts +5 -0
- package/lib/autolinking/ios/createSwiftCxxBridge.d.ts +2 -0
- package/lib/autolinking/ios/createSwiftUmbrellaHeader.d.ts +3 -0
- package/lib/config/NitroConfig.d.ts +52 -0
- package/lib/config/NitroUserConfig.d.ts +22 -0
- package/lib/config/getConfig.d.ts +2 -0
- package/lib/createGitAttributes.d.ts +1 -0
- package/lib/createPlatformSpec.d.ts +4 -0
- package/lib/getFiles.d.ts +1 -0
- package/lib/getPlatformSpecs.d.ts +17 -0
- package/lib/index.d.ts +2 -0
- package/lib/init.d.ts +1 -0
- package/lib/init.js +1 -1
- package/lib/nitrogen.d.ts +11 -0
- package/lib/prettifyDirectory.d.ts +1 -0
- package/lib/syntax/BridgedType.d.ts +41 -0
- package/lib/syntax/CodeNode.d.ts +23 -0
- package/lib/syntax/Method.d.ts +41 -0
- package/lib/syntax/Parameter.d.ts +15 -0
- package/lib/syntax/Property.d.ts +50 -0
- package/lib/syntax/SourceFile.d.ts +70 -0
- package/lib/syntax/c++/CppEnum.d.ts +6 -0
- package/lib/syntax/c++/CppHybridObject.d.ts +3 -0
- package/lib/syntax/c++/CppHybridObjectRegistration.d.ts +17 -0
- package/lib/syntax/c++/CppStruct.d.ts +3 -0
- package/lib/syntax/c++/CppStruct.js +4 -0
- package/lib/syntax/c++/CppUnion.d.ts +6 -0
- package/lib/syntax/c++/getForwardDeclaration.d.ts +3 -0
- package/lib/syntax/c++/includeNitroHeader.d.ts +7 -0
- package/lib/syntax/createType.d.ts +15 -0
- package/lib/syntax/getAllTypes.d.ts +3 -0
- package/lib/syntax/getCustomTypeConfig.d.ts +8 -0
- package/lib/syntax/getInterfaceProperties.d.ts +4 -0
- package/lib/syntax/getReferencedTypes.d.ts +2 -0
- package/lib/syntax/helpers.d.ts +13 -0
- package/lib/syntax/isCoreType.d.ts +9 -0
- package/lib/syntax/kotlin/FbjniHybridObject.d.ts +3 -0
- package/lib/syntax/kotlin/JNINativeRegistrations.d.ts +8 -0
- package/lib/syntax/kotlin/KotlinBoxedPrimitive.d.ts +7 -0
- package/lib/syntax/kotlin/KotlinCxxBridgedType.d.ts +19 -0
- package/lib/syntax/kotlin/KotlinCxxBridgedType.js +0 -14
- package/lib/syntax/kotlin/KotlinEnum.d.ts +3 -0
- package/lib/syntax/kotlin/KotlinFunction.d.ts +3 -0
- package/lib/syntax/kotlin/KotlinHybridObject.d.ts +3 -0
- package/lib/syntax/kotlin/KotlinHybridObject.js +1 -1
- package/lib/syntax/kotlin/KotlinHybridObjectRegistration.d.ts +17 -0
- package/lib/syntax/kotlin/KotlinStruct.d.ts +3 -0
- package/lib/syntax/kotlin/KotlinStruct.js +51 -46
- package/lib/syntax/kotlin/KotlinVariant.d.ts +3 -0
- package/lib/syntax/kotlin/KotlinVariant.js +37 -4
- package/lib/syntax/swift/SwiftCxxBridgedType.d.ts +21 -0
- package/lib/syntax/swift/SwiftCxxBridgedType.js +5 -2
- package/lib/syntax/swift/SwiftCxxTypeHelper.d.ts +0 -1
- package/lib/syntax/swift/SwiftCxxTypeHelper.js +3 -6
- package/lib/syntax/swift/SwiftEnum.d.ts +3 -0
- package/lib/syntax/swift/SwiftFunction.d.ts +3 -0
- package/lib/syntax/swift/SwiftHybridObject.d.ts +3 -0
- package/lib/syntax/swift/SwiftHybridObjectBridge.d.ts +11 -0
- package/lib/syntax/swift/SwiftHybridObjectRegistration.d.ts +19 -0
- package/lib/syntax/swift/SwiftStruct.d.ts +3 -0
- package/lib/syntax/swift/SwiftVariant.d.ts +3 -0
- package/lib/syntax/swift/isPrimitivelyCopyable.d.ts +7 -0
- package/lib/syntax/swift/isPrimitivelyCopyable.js +18 -0
- package/lib/syntax/types/ArrayBufferType.d.ts +10 -0
- package/lib/syntax/types/BigIntType.d.ts +10 -0
- package/lib/syntax/types/BooleanType.d.ts +10 -0
- package/lib/syntax/types/DateType.d.ts +10 -0
- package/lib/syntax/types/EnumType.d.ts +23 -0
- package/lib/syntax/types/ErrorType.d.ts +11 -0
- package/lib/syntax/types/FunctionType.d.ts +29 -0
- package/lib/syntax/types/HybridObjectBaseType.d.ts +11 -0
- package/lib/syntax/types/HybridObjectType.d.ts +23 -0
- package/lib/syntax/types/MapType.d.ts +10 -0
- package/lib/syntax/types/NamedWrappingType.d.ts +14 -0
- package/lib/syntax/types/NullType.d.ts +10 -0
- package/lib/syntax/types/NumberType.d.ts +10 -0
- package/lib/syntax/types/OptionalType.d.ts +13 -0
- package/lib/syntax/types/PromiseType.d.ts +16 -0
- package/lib/syntax/types/RecordType.d.ts +13 -0
- package/lib/syntax/types/ResultWrappingType.d.ts +13 -0
- package/lib/syntax/types/StringType.d.ts +10 -0
- package/lib/syntax/types/StructType.d.ts +14 -0
- package/lib/syntax/types/TupleType.d.ts +12 -0
- package/lib/syntax/types/Type.d.ts +55 -0
- package/lib/syntax/types/VariantType.d.ts +19 -0
- package/lib/syntax/types/VoidType.d.ts +10 -0
- package/lib/syntax/types/getTypeAs.d.ts +2 -0
- package/lib/utils.d.ts +22 -0
- package/lib/views/CppHybridViewComponent.d.ts +14 -0
- package/lib/views/createHostComponentJs.d.ts +3 -0
- package/lib/views/kotlin/KotlinHybridViewManager.d.ts +3 -0
- package/lib/views/swift/SwiftHybridViewManager.d.ts +3 -0
- package/lib/writeFile.d.ts +5 -0
- package/package.json +3 -3
- package/src/init.ts +1 -1
- package/src/syntax/c++/CppStruct.ts +4 -0
- package/src/syntax/kotlin/KotlinCxxBridgedType.ts +0 -14
- package/src/syntax/kotlin/KotlinHybridObject.ts +1 -1
- package/src/syntax/kotlin/KotlinStruct.ts +54 -47
- package/src/syntax/kotlin/KotlinVariant.ts +37 -4
- package/src/syntax/swift/SwiftCxxBridgedType.ts +5 -2
- package/src/syntax/swift/SwiftCxxTypeHelper.ts +3 -7
- package/src/syntax/swift/isPrimitivelyCopyable.ts +20 -0
|
@@ -22,7 +22,6 @@ import { VariantType } from '../types/VariantType.js'
|
|
|
22
22
|
import { getReferencedTypes } from '../getReferencedTypes.js'
|
|
23
23
|
import {
|
|
24
24
|
createSwiftCxxHelpers,
|
|
25
|
-
isPrimitivelyCopyable,
|
|
26
25
|
type SwiftCxxHelper,
|
|
27
26
|
} from './SwiftCxxTypeHelper.js'
|
|
28
27
|
import { createSwiftEnumBridge } from './SwiftEnum.js'
|
|
@@ -33,6 +32,7 @@ import { NamedWrappingType } from '../types/NamedWrappingType.js'
|
|
|
33
32
|
import { ErrorType } from '../types/ErrorType.js'
|
|
34
33
|
import { createSwiftFunctionBridge } from './SwiftFunction.js'
|
|
35
34
|
import type { Language } from '../../getPlatformSpecs.js'
|
|
35
|
+
import { isPrimitivelyCopyable } from './isPrimitivelyCopyable.js'
|
|
36
36
|
|
|
37
37
|
// TODO: Remove enum bridge once Swift fixes bidirectional enums crashing the `-Swift.h` header.
|
|
38
38
|
|
|
@@ -449,7 +449,10 @@ export class SwiftCxxBridgedType implements BridgedType<'swift', 'c++'> {
|
|
|
449
449
|
return `${cppParameterName}.has_value() ? ${cppParameterName}.pointee : nil`
|
|
450
450
|
}
|
|
451
451
|
}
|
|
452
|
-
|
|
452
|
+
// TODO: Remove this check for booleans once https://github.com/swiftlang/swift/issues/84848 is fixed.
|
|
453
|
+
const swiftBug84848Workaround =
|
|
454
|
+
optional.wrappingType.kind === 'boolean'
|
|
455
|
+
if (!wrapping.needsSpecialHandling && !swiftBug84848Workaround) {
|
|
453
456
|
return `${cppParameterName}.value`
|
|
454
457
|
}
|
|
455
458
|
return `
|
|
@@ -19,6 +19,7 @@ import { VoidType } from '../types/VoidType.js'
|
|
|
19
19
|
import { NamedWrappingType } from '../types/NamedWrappingType.js'
|
|
20
20
|
import { ErrorType } from '../types/ErrorType.js'
|
|
21
21
|
import { ResultWrappingType } from '../types/ResultWrappingType.js'
|
|
22
|
+
import { isPrimitivelyCopyable } from './isPrimitivelyCopyable.js'
|
|
22
23
|
|
|
23
24
|
export interface SwiftCxxHelper {
|
|
24
25
|
cxxHeader: {
|
|
@@ -148,7 +149,7 @@ return ${cxxNamespace}::get_${internalName}(cppType);
|
|
|
148
149
|
*/
|
|
149
150
|
using ${name} = ${actualType};
|
|
150
151
|
${actualType} create_${name}(void* NON_NULL swiftUnsafePointer) noexcept;
|
|
151
|
-
void* NON_NULL get_${name}(${name} cppType)
|
|
152
|
+
void* NON_NULL get_${name}(${name} cppType);
|
|
152
153
|
`.trim(),
|
|
153
154
|
requiredIncludes: type.getRequiredImports('c++'),
|
|
154
155
|
},
|
|
@@ -157,7 +158,7 @@ void* NON_NULL get_${name}(${name} cppType) noexcept;
|
|
|
157
158
|
${actualType} create_${name}(void* NON_NULL swiftUnsafePointer) noexcept {
|
|
158
159
|
${indent(createImplementation, ' ')}
|
|
159
160
|
}
|
|
160
|
-
void* NON_NULL get_${name}(${name} cppType)
|
|
161
|
+
void* NON_NULL get_${name}(${name} cppType) {
|
|
161
162
|
${indent(getImplementation, ' ')}
|
|
162
163
|
}
|
|
163
164
|
`.trim(),
|
|
@@ -260,11 +261,6 @@ inline ${wrappedBridge.getTypeCode('c++')} get_${name}(const ${actualType}& opti
|
|
|
260
261
|
}
|
|
261
262
|
}
|
|
262
263
|
|
|
263
|
-
export function isPrimitivelyCopyable(type: Type): boolean {
|
|
264
|
-
const bridgedType = new SwiftCxxBridgedType(type, true)
|
|
265
|
-
return !bridgedType.needsSpecialHandling
|
|
266
|
-
}
|
|
267
|
-
|
|
268
264
|
/**
|
|
269
265
|
* Creates a C++ `create_vector_T<T>(size)` function that can be called from Swift.
|
|
270
266
|
*/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Type } from '../types/Type.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns `true` if the given {@linkcode type} is a datatype that
|
|
5
|
+
* can be copied without running a copy constructor or special logic
|
|
6
|
+
* to copy the data over. In other words; it's _primitively copyable_.
|
|
7
|
+
*/
|
|
8
|
+
export function isPrimitivelyCopyable(type: Type): boolean {
|
|
9
|
+
switch (type.kind) {
|
|
10
|
+
case 'number':
|
|
11
|
+
case 'boolean':
|
|
12
|
+
case 'bigint':
|
|
13
|
+
case 'enum':
|
|
14
|
+
case 'null':
|
|
15
|
+
case 'void':
|
|
16
|
+
return true
|
|
17
|
+
default:
|
|
18
|
+
return false
|
|
19
|
+
}
|
|
20
|
+
}
|