Skip to content

Commit

Permalink
fix: Safely guard nil unwrap for dictionary lookup in Swift (#79)
Browse files Browse the repository at this point in the history
* fix: Safely `guard` nil unwrap for dictionary lookup in Swift

* fix: Use force-unwrap (`!`) because it can never be nil.
  • Loading branch information
mrousavy authored Aug 28, 2024
1 parent a0e2fea commit fd85cf5
Show file tree
Hide file tree
Showing 71 changed files with 73 additions and 73 deletions.
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1820,11 +1820,11 @@ SPEC CHECKSUMS:
DoubleConversion: 76ab83afb40bddeeee456813d9c04f67f78771b5
FBLazyVector: 38bb611218305c3bc61803e287b8a81c6f63b619
fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120
glog: fdfdfe5479092de0c4bdbebedd9056951f092c4f
glog: 69ef571f3de08433d766d614c73a9838a06bf7eb
hermes-engine: 3b6e0717ca847e2fc90a201e59db36caf04dee88
NitroImage: a230ad8b4dce2b6bd12458570398cffe5463b877
NitroModules: 276be5564c64e498c7a243d778ff79370c5a84a7
RCT-Folly: 02617c592a293bd6d418e0a88ff4ee1f88329b47
RCT-Folly: 4464f4d875961fce86008d45f4ecf6cef6de0740
RCTDeprecation: 34cbf122b623037ea9facad2e92e53434c5c7422
RCTRequired: 24c446d7bcd0f517d516b6265d8df04dc3eb1219
RCTTypeSafety: ef5e91bd791abd3a99b2c75fd565791102a66352
Expand Down
2 changes: 1 addition & 1 deletion packages/nitrogen/src/syntax/swift/SwiftCxxBridgedType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ export class SwiftCxxBridgedType implements BridgedType<'swift', 'c++'> {
var dictionary = ${record.getCode('swift')}(minimumCapacity: ${cppParameterName}.size())
let keys = ${getKeysFunc}(${cppParameterName})
for key in keys {
let value = ${cppParameterName}[key]
let value = ${cppParameterName}[key]!
dictionary[${wrappingKey.parseFromCppToSwift('key', 'swift')}] = ${wrappingValue.parseFromCppToSwift('value', 'swift')}
}
return dictionary
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# NitroImage+autolinking.cmake
# Tue Aug 27 2024
# Wed Aug 28 2024
# This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
# https://github.com/mrousavy/nitro
# Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// NitroImage+autolinking.gradle
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// JCar.hpp
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// JFunc_void_Person.hpp
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// JFunc_void_std__string.hpp
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// JHybridImageFactorySpec.cpp
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// HybridImageFactorySpec.hpp
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// JHybridImageSpec.cpp
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// HybridImageSpec.hpp
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// JHybridKotlinTestObjectSpec.cpp
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// HybridKotlinTestObjectSpec.hpp
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// JImageFormat.hpp
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// JImageSize.hpp
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// JPerson.hpp
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// JPixelFormat.hpp
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// JPowertrain.hpp
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// Car.kt
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// Func_void_Person.kt
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// Func_void_std__string.kt
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// HybridImageFactorySpec.kt
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// HybridImageSpec.kt
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// HybridKotlinTestObjectSpec.kt
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// ImageFormat.kt
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// ImageSize.kt
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// Person.kt
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// PixelFormat.kt
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// Powertrain.kt
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# NitroImage+autolinking.rb
# Tue Aug 27 2024
# Wed Aug 28 2024
# This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
# https://github.com/mrousavy/nitro
# Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// NitroImage-Swift-Cxx-Bridge.cpp
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// NitroImage-Swift-Cxx-Bridge.hpp
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// NitroImage-Swift-Cxx-Umbrella.hpp
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// HybridImageFactorySpecSwift.cpp
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// HybridImageFactorySpecSwift.hpp
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// HybridImageSpecSwift.cpp
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// HybridImageSpecSwift.hpp
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// HybridSwiftKotlinTestObjectSpecSwift.cpp
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// HybridSwiftKotlinTestObjectSpecSwift.hpp
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// CallbackHolder.swift
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// Car.swift
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// HybridImageFactorySpec.swift
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// HybridImageFactorySpecCxx.swift
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// HybridImageSpec.swift
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// HybridImageSpecCxx.swift
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// HybridSwiftKotlinTestObjectSpec.swift
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// HybridSwiftKotlinTestObjectSpecCxx.swift
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down Expand Up @@ -190,7 +190,7 @@ public final class HybridSwiftKotlinTestObjectSpecCxx {
var dictionary = Dictionary<String, Double>(minimumCapacity: newValue.size())
let keys = bridge.get_std__unordered_map_std__string__double__keys(newValue)
for key in keys {
let value = newValue[key]
let value = newValue[key]!
dictionary[String(key)] = value
}
return dictionary
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///
/// ImageFormat.swift
/// Tue Aug 27 2024
/// Wed Aug 28 2024
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
Expand Down
Loading

0 comments on commit fd85cf5

Please sign in to comment.