nitrogen 0.33.8 → 0.33.9

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.
@@ -425,10 +425,14 @@ export class SwiftCxxBridgedType {
425
425
  return `${cppParameterName}.has_value() ? ${cppParameterName}.pointee : nil`;
426
426
  }
427
427
  }
428
- // TODO: Remove this check for booleans once https://github.com/swiftlang/swift/issues/84848 is fixed.
429
- const swiftBug84848Workaround = optional.wrappingType.kind === 'boolean';
430
- if (!wrapping.needsSpecialHandling && !swiftBug84848Workaround) {
431
- return `${cppParameterName}.value`;
428
+ // TODO: Remove this check for booleans/doubles once https://github.com/swiftlang/swift/issues/84848 is fixed.
429
+ // Right now, optionals of doubles or booleans (and who knows what else?) fail to compile when `.value` is used.
430
+ const swiftBug84848Workaround = optional.wrappingType.kind === 'boolean' ||
431
+ optional.wrappingType.kind === 'number';
432
+ if (!swiftBug84848Workaround) {
433
+ if (!wrapping.needsSpecialHandling) {
434
+ return `${cppParameterName}.value`;
435
+ }
432
436
  }
433
437
  return `
434
438
  { () -> ${optional.getCode('swift')} in
@@ -209,7 +209,7 @@ inline bool has_value_${name}(const ${actualType}& optional) noexcept {
209
209
  return optional.has_value();
210
210
  }
211
211
  inline ${wrappedBridge.getTypeCode('c++')} get_${name}(const ${actualType}& optional) noexcept {
212
- return *optional;
212
+ return optional.value();
213
213
  }
214
214
  `.trim(),
215
215
  requiredIncludes: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitrogen",
3
- "version": "0.33.8",
3
+ "version": "0.33.9",
4
4
  "description": "The code-generator for react-native-nitro-modules.",
5
5
  "main": "lib/index",
6
6
  "types": "lib/index.d.ts",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "chalk": "^5.3.0",
38
- "react-native-nitro-modules": "^0.33.8",
38
+ "react-native-nitro-modules": "^0.33.9",
39
39
  "ts-morph": "^27.0.0",
40
40
  "yargs": "^18.0.0",
41
41
  "zod": "^4.0.5"
@@ -465,11 +465,15 @@ export class SwiftCxxBridgedType implements BridgedType<'swift', 'c++'> {
465
465
  return `${cppParameterName}.has_value() ? ${cppParameterName}.pointee : nil`
466
466
  }
467
467
  }
468
- // TODO: Remove this check for booleans once https://github.com/swiftlang/swift/issues/84848 is fixed.
468
+ // TODO: Remove this check for booleans/doubles once https://github.com/swiftlang/swift/issues/84848 is fixed.
469
+ // Right now, optionals of doubles or booleans (and who knows what else?) fail to compile when `.value` is used.
469
470
  const swiftBug84848Workaround =
470
- optional.wrappingType.kind === 'boolean'
471
- if (!wrapping.needsSpecialHandling && !swiftBug84848Workaround) {
472
- return `${cppParameterName}.value`
471
+ optional.wrappingType.kind === 'boolean' ||
472
+ optional.wrappingType.kind === 'number'
473
+ if (!swiftBug84848Workaround) {
474
+ if (!wrapping.needsSpecialHandling) {
475
+ return `${cppParameterName}.value`
476
+ }
473
477
  }
474
478
  return `
475
479
  { () -> ${optional.getCode('swift')} in
@@ -249,7 +249,7 @@ inline bool has_value_${name}(const ${actualType}& optional) noexcept {
249
249
  return optional.has_value();
250
250
  }
251
251
  inline ${wrappedBridge.getTypeCode('c++')} get_${name}(const ${actualType}& optional) noexcept {
252
- return *optional;
252
+ return optional.value();
253
253
  }
254
254
  `.trim(),
255
255
  requiredIncludes: [
@@ -1,13 +0,0 @@
1
- import type { Language } from '../../getPlatformSpecs.js';
2
- import type { SourceFile, SourceImport } from '../SourceFile.js';
3
- import type { Type, TypeKind } from './Type.js';
4
- export declare class BigIntType implements Type {
5
- private signed;
6
- constructor(signed: boolean);
7
- get canBePassedByReference(): boolean;
8
- get kind(): TypeKind;
9
- get isEquatable(): boolean;
10
- getCode(language: Language): string;
11
- getExtraFiles(): SourceFile[];
12
- getRequiredImports(): SourceImport[];
13
- }
@@ -1,48 +0,0 @@
1
- export class BigIntType {
2
- signed;
3
- constructor(signed) {
4
- this.signed = signed;
5
- }
6
- get canBePassedByReference() {
7
- // It's a primitive.
8
- return false;
9
- }
10
- get kind() {
11
- return 'bigint';
12
- }
13
- get isEquatable() {
14
- return true;
15
- }
16
- getCode(language) {
17
- if (this.signed) {
18
- switch (language) {
19
- case 'c++':
20
- return 'int64_t';
21
- case 'swift':
22
- return 'Int64';
23
- case 'kotlin':
24
- return 'Long';
25
- default:
26
- throw new Error(`Language ${language} is not yet supported for BigIntType!`);
27
- }
28
- }
29
- else {
30
- switch (language) {
31
- case 'c++':
32
- return 'uint64_t';
33
- case 'swift':
34
- return 'UInt64';
35
- case 'kotlin':
36
- return 'ULong';
37
- default:
38
- throw new Error(`Language ${language} is not yet supported for BigIntType!`);
39
- }
40
- }
41
- }
42
- getExtraFiles() {
43
- return [];
44
- }
45
- getRequiredImports() {
46
- return [];
47
- }
48
- }