react-native-yolo 0.0.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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +29 -0
  3. package/Yolo.podspec +31 -0
  4. package/android/CMakeLists.txt +32 -0
  5. package/android/build.gradle +148 -0
  6. package/android/fix-prefab.gradle +51 -0
  7. package/android/gradle.properties +5 -0
  8. package/android/src/main/AndroidManifest.xml +2 -0
  9. package/android/src/main/cpp/cpp-adapter.cpp +9 -0
  10. package/android/src/main/java/com/yolo/HybridYolo.kt +12 -0
  11. package/android/src/main/java/com/yolo/YoloPackage.kt +20 -0
  12. package/ios/Bridge.h +8 -0
  13. package/ios/HybridYolo.swift +14 -0
  14. package/lib/commonjs/index.js +9 -0
  15. package/lib/commonjs/index.js.map +1 -0
  16. package/lib/commonjs/package.json +1 -0
  17. package/lib/commonjs/specs/yolo.nitro.js +6 -0
  18. package/lib/commonjs/specs/yolo.nitro.js.map +1 -0
  19. package/lib/module/index.js +5 -0
  20. package/lib/module/index.js.map +1 -0
  21. package/lib/module/specs/yolo.nitro.js +4 -0
  22. package/lib/module/specs/yolo.nitro.js.map +1 -0
  23. package/lib/typescript/src/index.d.ts +3 -0
  24. package/lib/typescript/src/index.d.ts.map +1 -0
  25. package/lib/typescript/src/specs/yolo.nitro.d.ts +9 -0
  26. package/lib/typescript/src/specs/yolo.nitro.d.ts.map +1 -0
  27. package/nitro.json +30 -0
  28. package/nitrogen/generated/.gitattributes +1 -0
  29. package/nitrogen/generated/android/Yolo+autolinking.cmake +81 -0
  30. package/nitrogen/generated/android/Yolo+autolinking.gradle +27 -0
  31. package/nitrogen/generated/android/YoloOnLoad.cpp +54 -0
  32. package/nitrogen/generated/android/YoloOnLoad.hpp +34 -0
  33. package/nitrogen/generated/android/c++/JHybridYoloSpec.cpp +58 -0
  34. package/nitrogen/generated/android/c++/JHybridYoloSpec.hpp +64 -0
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/yolo/HybridYoloSpec.kt +58 -0
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/yolo/YoloOnLoad.kt +35 -0
  37. package/nitrogen/generated/ios/Yolo+autolinking.rb +62 -0
  38. package/nitrogen/generated/ios/Yolo-Swift-Cxx-Bridge.cpp +33 -0
  39. package/nitrogen/generated/ios/Yolo-Swift-Cxx-Bridge.hpp +51 -0
  40. package/nitrogen/generated/ios/Yolo-Swift-Cxx-Umbrella.hpp +43 -0
  41. package/nitrogen/generated/ios/YoloAutolinking.mm +33 -0
  42. package/nitrogen/generated/ios/YoloAutolinking.swift +26 -0
  43. package/nitrogen/generated/ios/c++/HybridYoloSpecSwift.cpp +11 -0
  44. package/nitrogen/generated/ios/c++/HybridYoloSpecSwift.hpp +90 -0
  45. package/nitrogen/generated/ios/swift/HybridYoloSpec.swift +56 -0
  46. package/nitrogen/generated/ios/swift/HybridYoloSpec_cxx.swift +150 -0
  47. package/nitrogen/generated/shared/c++/HybridYoloSpec.cpp +22 -0
  48. package/nitrogen/generated/shared/c++/HybridYoloSpec.hpp +63 -0
  49. package/package.json +122 -0
  50. package/src/index.ts +5 -0
  51. package/src/specs/yolo.nitro.ts +6 -0
@@ -0,0 +1,34 @@
1
+ ///
2
+ /// YoloOnLoad.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include <jni.h>
9
+ #include <functional>
10
+ #include <NitroModules/NitroDefines.hpp>
11
+
12
+ namespace margelo::nitro::yolo {
13
+
14
+ [[deprecated("Use registerNatives() instead.")]]
15
+ int initialize(JavaVM* vm);
16
+
17
+ /**
18
+ * Register the native (C++) part of Yolo, and autolinks all Hybrid Objects.
19
+ * Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`),
20
+ * inside a `facebook::jni::initialize(vm, ...)` call.
21
+ * Example:
22
+ * ```cpp (cpp-adapter.cpp)
23
+ * JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
24
+ * return facebook::jni::initialize(vm, []() {
25
+ * // register all Yolo HybridObjects
26
+ * margelo::nitro::yolo::registerNatives();
27
+ * // any other custom registrations go here.
28
+ * });
29
+ * }
30
+ * ```
31
+ */
32
+ void registerAllNatives();
33
+
34
+ } // namespace margelo::nitro::yolo
@@ -0,0 +1,58 @@
1
+ ///
2
+ /// JHybridYoloSpec.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "JHybridYoloSpec.hpp"
9
+
10
+
11
+
12
+
13
+
14
+ namespace margelo::nitro::yolo {
15
+
16
+ std::shared_ptr<JHybridYoloSpec> JHybridYoloSpec::JavaPart::getJHybridYoloSpec() {
17
+ auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
18
+ auto castHybridObject = std::dynamic_pointer_cast<JHybridYoloSpec>(hybridObject);
19
+ if (castHybridObject == nullptr) [[unlikely]] {
20
+ throw std::runtime_error("Failed to downcast JHybridObject to JHybridYoloSpec!");
21
+ }
22
+ return castHybridObject;
23
+ }
24
+
25
+ jni::local_ref<JHybridYoloSpec::CxxPart::jhybriddata> JHybridYoloSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
26
+ return makeCxxInstance(jThis);
27
+ }
28
+
29
+ std::shared_ptr<JHybridObject> JHybridYoloSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
30
+ auto castJavaPart = jni::dynamic_ref_cast<JHybridYoloSpec::JavaPart>(javaPart);
31
+ if (castJavaPart == nullptr) [[unlikely]] {
32
+ throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridYoloSpec::JavaPart!");
33
+ }
34
+ return std::make_shared<JHybridYoloSpec>(castJavaPart);
35
+ }
36
+
37
+ void JHybridYoloSpec::CxxPart::registerNatives() {
38
+ registerHybrid({
39
+ makeNativeMethod("initHybrid", JHybridYoloSpec::CxxPart::initHybrid),
40
+ });
41
+ }
42
+
43
+ // Properties
44
+
45
+
46
+ // Methods
47
+ double JHybridYoloSpec::sum(double num1, double num2) {
48
+ static const auto method = _javaPart->javaClassStatic()->getMethod<double(double /* num1 */, double /* num2 */)>("sum");
49
+ auto __result = method(_javaPart, num1, num2);
50
+ return __result;
51
+ }
52
+ double JHybridYoloSpec::subtract(double num1, double num2) {
53
+ static const auto method = _javaPart->javaClassStatic()->getMethod<double(double /* num1 */, double /* num2 */)>("subtract");
54
+ auto __result = method(_javaPart, num1, num2);
55
+ return __result;
56
+ }
57
+
58
+ } // namespace margelo::nitro::yolo
@@ -0,0 +1,64 @@
1
+ ///
2
+ /// HybridYoloSpec.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <NitroModules/JHybridObject.hpp>
11
+ #include <fbjni/fbjni.h>
12
+ #include "HybridYoloSpec.hpp"
13
+
14
+
15
+
16
+
17
+ namespace margelo::nitro::yolo {
18
+
19
+ using namespace facebook;
20
+
21
+ class JHybridYoloSpec: public virtual HybridYoloSpec, public virtual JHybridObject {
22
+ public:
23
+ struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
24
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/yolo/HybridYoloSpec;";
25
+ std::shared_ptr<JHybridYoloSpec> getJHybridYoloSpec();
26
+ };
27
+ struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
28
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/yolo/HybridYoloSpec$CxxPart;";
29
+ static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
30
+ static void registerNatives();
31
+ using HybridBase::HybridBase;
32
+ protected:
33
+ std::shared_ptr<JHybridObject> createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) override;
34
+ };
35
+
36
+ public:
37
+ explicit JHybridYoloSpec(const jni::local_ref<JHybridYoloSpec::JavaPart>& javaPart):
38
+ HybridObject(HybridYoloSpec::TAG),
39
+ JHybridObject(javaPart),
40
+ _javaPart(jni::make_global(javaPart)) {}
41
+ ~JHybridYoloSpec() override {
42
+ // Hermes GC can destroy JS objects on a non-JNI Thread.
43
+ jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
44
+ }
45
+
46
+ public:
47
+ inline const jni::global_ref<JHybridYoloSpec::JavaPart>& getJavaPart() const noexcept {
48
+ return _javaPart;
49
+ }
50
+
51
+ public:
52
+ // Properties
53
+
54
+
55
+ public:
56
+ // Methods
57
+ double sum(double num1, double num2) override;
58
+ double subtract(double num1, double num2) override;
59
+
60
+ private:
61
+ jni::global_ref<JHybridYoloSpec::JavaPart> _javaPart;
62
+ };
63
+
64
+ } // namespace margelo::nitro::yolo
@@ -0,0 +1,58 @@
1
+ ///
2
+ /// HybridYoloSpec.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.yolo
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.jni.HybridData
12
+ import com.facebook.proguard.annotations.DoNotStrip
13
+ import com.margelo.nitro.core.HybridObject
14
+
15
+ /**
16
+ * A Kotlin class representing the Yolo HybridObject.
17
+ * Implement this abstract class to create Kotlin-based instances of Yolo.
18
+ */
19
+ @DoNotStrip
20
+ @Keep
21
+ @Suppress(
22
+ "KotlinJniMissingFunction", "unused",
23
+ "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
24
+ "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
25
+ )
26
+ abstract class HybridYoloSpec: HybridObject() {
27
+ // Properties
28
+
29
+
30
+ // Methods
31
+ @DoNotStrip
32
+ @Keep
33
+ abstract fun sum(num1: Double, num2: Double): Double
34
+
35
+ @DoNotStrip
36
+ @Keep
37
+ abstract fun subtract(num1: Double, num2: Double): Double
38
+
39
+ // Default implementation of `HybridObject.toString()`
40
+ override fun toString(): String {
41
+ return "[HybridObject Yolo]"
42
+ }
43
+
44
+ // C++ backing class
45
+ @DoNotStrip
46
+ @Keep
47
+ protected open class CxxPart(javaPart: HybridYoloSpec): HybridObject.CxxPart(javaPart) {
48
+ // C++ JHybridYoloSpec::CxxPart::initHybrid(...)
49
+ external override fun initHybrid(): HybridData
50
+ }
51
+ override fun createCxxPart(): CxxPart {
52
+ return CxxPart(this)
53
+ }
54
+
55
+ companion object {
56
+ protected const val TAG = "HybridYoloSpec"
57
+ }
58
+ }
@@ -0,0 +1,35 @@
1
+ ///
2
+ /// YoloOnLoad.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.yolo
9
+
10
+ import android.util.Log
11
+
12
+ internal class YoloOnLoad {
13
+ companion object {
14
+ private const val TAG = "YoloOnLoad"
15
+ private var didLoad = false
16
+ /**
17
+ * Initializes the native part of "Yolo".
18
+ * This method is idempotent and can be called more than once.
19
+ */
20
+ @JvmStatic
21
+ fun initializeNative() {
22
+ if (didLoad) return
23
+ try {
24
+ Log.i(TAG, "Loading Yolo C++ library...")
25
+ System.loadLibrary("Yolo")
26
+ Log.i(TAG, "Successfully loaded Yolo C++ library!")
27
+ didLoad = true
28
+ } catch (e: Error) {
29
+ Log.e(TAG, "Failed to load Yolo C++ library! Is it properly installed and linked? " +
30
+ "Is the name correct? (see `CMakeLists.txt`, at `add_library(...)`)", e)
31
+ throw e
32
+ }
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,62 @@
1
+ #
2
+ # Yolo+autolinking.rb
3
+ # This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ # https://github.com/mrousavy/nitro
5
+ # Copyright © Marc Rousavy @ Margelo
6
+ #
7
+
8
+ # This is a Ruby script that adds all files generated by Nitrogen
9
+ # to the given podspec.
10
+ #
11
+ # To use it, add this to your .podspec:
12
+ # ```ruby
13
+ # Pod::Spec.new do |spec|
14
+ # # ...
15
+ #
16
+ # # Add all files generated by Nitrogen
17
+ # load 'nitrogen/generated/ios/Yolo+autolinking.rb'
18
+ # add_nitrogen_files(spec)
19
+ # end
20
+ # ```
21
+
22
+ def add_nitrogen_files(spec)
23
+ Pod::UI.puts "[NitroModules] 🔥 Yolo is boosted by nitro!"
24
+
25
+ spec.dependency "NitroModules"
26
+
27
+ current_source_files = Array(spec.attributes_hash['source_files'])
28
+ spec.source_files = current_source_files + [
29
+ # Generated cross-platform specs
30
+ "nitrogen/generated/shared/**/*.{h,hpp,c,cpp,swift}",
31
+ # Generated bridges for the cross-platform specs
32
+ "nitrogen/generated/ios/**/*.{h,hpp,c,cpp,mm,swift}",
33
+ ]
34
+
35
+ current_public_header_files = Array(spec.attributes_hash['public_header_files'])
36
+ spec.public_header_files = current_public_header_files + [
37
+ # Generated specs
38
+ "nitrogen/generated/shared/**/*.{h,hpp}",
39
+ # Swift to C++ bridging helpers
40
+ "nitrogen/generated/ios/Yolo-Swift-Cxx-Bridge.hpp"
41
+ ]
42
+
43
+ current_private_header_files = Array(spec.attributes_hash['private_header_files'])
44
+ spec.private_header_files = current_private_header_files + [
45
+ # iOS specific specs
46
+ "nitrogen/generated/ios/c++/**/*.{h,hpp}",
47
+ # Views are framework-specific and should be private
48
+ "nitrogen/generated/shared/**/views/**/*"
49
+ ]
50
+
51
+ current_pod_target_xcconfig = spec.attributes_hash['pod_target_xcconfig'] || {}
52
+ spec.pod_target_xcconfig = current_pod_target_xcconfig.merge({
53
+ # Use C++ 20
54
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
55
+ # Enables C++ <-> Swift interop (by default it's only ObjC)
56
+ "SWIFT_OBJC_INTEROP_MODE" => "objcxx",
57
+ # Enables stricter modular headers
58
+ "DEFINES_MODULE" => "YES",
59
+ # Disable auto-generated ObjC header for Swift (Static linkage on Xcode 26.4 breaks here)
60
+ "SWIFT_INSTALL_OBJC_HEADER" => "NO",
61
+ })
62
+ end
@@ -0,0 +1,33 @@
1
+ ///
2
+ /// Yolo-Swift-Cxx-Bridge.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "Yolo-Swift-Cxx-Bridge.hpp"
9
+
10
+ // Include C++ implementation defined types
11
+ #include "HybridYoloSpecSwift.hpp"
12
+ #include "Yolo-Swift-Cxx-Umbrella.hpp"
13
+ #include <NitroModules/NitroDefines.hpp>
14
+
15
+ namespace margelo::nitro::yolo::bridge::swift {
16
+
17
+ // pragma MARK: std::shared_ptr<HybridYoloSpec>
18
+ std::shared_ptr<HybridYoloSpec> create_std__shared_ptr_HybridYoloSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
19
+ Yolo::HybridYoloSpec_cxx swiftPart = Yolo::HybridYoloSpec_cxx::fromUnsafe(swiftUnsafePointer);
20
+ return std::make_shared<margelo::nitro::yolo::HybridYoloSpecSwift>(swiftPart);
21
+ }
22
+ void* NON_NULL get_std__shared_ptr_HybridYoloSpec_(std__shared_ptr_HybridYoloSpec_ cppType) {
23
+ std::shared_ptr<margelo::nitro::yolo::HybridYoloSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::yolo::HybridYoloSpecSwift>(cppType);
24
+ #ifdef NITRO_DEBUG
25
+ if (swiftWrapper == nullptr) [[unlikely]] {
26
+ throw std::runtime_error("Class \"HybridYoloSpec\" is not implemented in Swift!");
27
+ }
28
+ #endif
29
+ Yolo::HybridYoloSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
30
+ return swiftPart.toUnsafe();
31
+ }
32
+
33
+ } // namespace margelo::nitro::yolo::bridge::swift
@@ -0,0 +1,51 @@
1
+ ///
2
+ /// Yolo-Swift-Cxx-Bridge.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ // Forward declarations of C++ defined types
11
+ // Forward declaration of `HybridYoloSpec` to properly resolve imports.
12
+ namespace margelo::nitro::yolo { class HybridYoloSpec; }
13
+
14
+ // Forward declarations of Swift defined types
15
+ // Forward declaration of `HybridYoloSpec_cxx` to properly resolve imports.
16
+ namespace Yolo { class HybridYoloSpec_cxx; }
17
+
18
+ // Include C++ defined types
19
+ #include "HybridYoloSpec.hpp"
20
+ #include <NitroModules/Result.hpp>
21
+ #include <exception>
22
+ #include <memory>
23
+
24
+ /**
25
+ * Contains specialized versions of C++ templated types so they can be accessed from Swift,
26
+ * as well as helper functions to interact with those C++ types from Swift.
27
+ */
28
+ namespace margelo::nitro::yolo::bridge::swift {
29
+
30
+ // pragma MARK: std::shared_ptr<HybridYoloSpec>
31
+ /**
32
+ * Specialized version of `std::shared_ptr<HybridYoloSpec>`.
33
+ */
34
+ using std__shared_ptr_HybridYoloSpec_ = std::shared_ptr<HybridYoloSpec>;
35
+ std::shared_ptr<HybridYoloSpec> create_std__shared_ptr_HybridYoloSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
36
+ void* NON_NULL get_std__shared_ptr_HybridYoloSpec_(std__shared_ptr_HybridYoloSpec_ cppType);
37
+
38
+ // pragma MARK: std::weak_ptr<HybridYoloSpec>
39
+ using std__weak_ptr_HybridYoloSpec_ = std::weak_ptr<HybridYoloSpec>;
40
+ inline std__weak_ptr_HybridYoloSpec_ weakify_std__shared_ptr_HybridYoloSpec_(const std::shared_ptr<HybridYoloSpec>& strong) noexcept { return strong; }
41
+
42
+ // pragma MARK: Result<double>
43
+ using Result_double_ = Result<double>;
44
+ inline Result_double_ create_Result_double_(double value) noexcept {
45
+ return Result<double>::withValue(std::move(value));
46
+ }
47
+ inline Result_double_ create_Result_double_(const std::exception_ptr& error) noexcept {
48
+ return Result<double>::withError(error);
49
+ }
50
+
51
+ } // namespace margelo::nitro::yolo::bridge::swift
@@ -0,0 +1,43 @@
1
+ ///
2
+ /// Yolo-Swift-Cxx-Umbrella.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ // Forward declarations of C++ defined types
11
+ // Forward declaration of `HybridYoloSpec` to properly resolve imports.
12
+ namespace margelo::nitro::yolo { class HybridYoloSpec; }
13
+
14
+ // Include C++ defined types
15
+ #include "HybridYoloSpec.hpp"
16
+ #include <NitroModules/Result.hpp>
17
+ #include <exception>
18
+ #include <memory>
19
+
20
+ // C++ helpers for Swift
21
+ #include "Yolo-Swift-Cxx-Bridge.hpp"
22
+
23
+ // Common C++ types used in Swift
24
+ #include <NitroModules/ArrayBufferHolder.hpp>
25
+ #include <NitroModules/AnyMapUtils.hpp>
26
+ #include <NitroModules/RuntimeError.hpp>
27
+ #include <NitroModules/DateToChronoDate.hpp>
28
+
29
+ // Forward declarations of Swift defined types
30
+ // Forward declaration of `HybridYoloSpec_cxx` to properly resolve imports.
31
+ namespace Yolo { class HybridYoloSpec_cxx; }
32
+
33
+ // Include Swift defined types
34
+ #if __has_include("Yolo-Swift.h")
35
+ // This header is generated by Xcode/Swift on every app build.
36
+ // If it cannot be found, make sure the Swift module's name (= podspec name) is actually "Yolo".
37
+ #include "Yolo-Swift.h"
38
+ // Same as above, but used when building with frameworks (`use_frameworks`)
39
+ #elif __has_include(<Yolo/Yolo-Swift.h>)
40
+ #include <Yolo/Yolo-Swift.h>
41
+ #else
42
+ #error Yolo's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "Yolo", and try building the app first.
43
+ #endif
@@ -0,0 +1,33 @@
1
+ ///
2
+ /// YoloAutolinking.mm
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import <NitroModules/HybridObjectRegistry.hpp>
10
+ #import "Yolo-Swift-Cxx-Umbrella.hpp"
11
+ #import <type_traits>
12
+
13
+ #include "HybridYoloSpecSwift.hpp"
14
+
15
+ @interface YoloAutolinking : NSObject
16
+ @end
17
+
18
+ @implementation YoloAutolinking
19
+
20
+ + (void) load {
21
+ using namespace margelo::nitro;
22
+ using namespace margelo::nitro::yolo;
23
+
24
+ HybridObjectRegistry::registerHybridObjectConstructor(
25
+ "Yolo",
26
+ []() -> std::shared_ptr<HybridObject> {
27
+ std::shared_ptr<HybridYoloSpec> hybridObject = Yolo::YoloAutolinking::createYolo();
28
+ return hybridObject;
29
+ }
30
+ );
31
+ }
32
+
33
+ @end
@@ -0,0 +1,26 @@
1
+ ///
2
+ /// YoloAutolinking.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ // TODO: Use empty enums once Swift supports exporting them as namespaces
11
+ // See: https://github.com/swiftlang/swift/pull/83616
12
+ public final class YoloAutolinking {
13
+ public typealias bridge = margelo.nitro.yolo.bridge.swift
14
+
15
+ public static func createYolo() -> bridge.std__shared_ptr_HybridYoloSpec_ {
16
+ let hybridObject = HybridYolo()
17
+ return { () -> bridge.std__shared_ptr_HybridYoloSpec_ in
18
+ let __cxxWrapped = hybridObject.getCxxWrapper()
19
+ return __cxxWrapped.getCxxPart()
20
+ }()
21
+ }
22
+
23
+ public static func isYoloRecyclable() -> Bool {
24
+ return HybridYolo.self is any RecyclableView.Type
25
+ }
26
+ }
@@ -0,0 +1,11 @@
1
+ ///
2
+ /// HybridYoloSpecSwift.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridYoloSpecSwift.hpp"
9
+
10
+ namespace margelo::nitro::yolo {
11
+ } // namespace margelo::nitro::yolo
@@ -0,0 +1,90 @@
1
+ ///
2
+ /// HybridYoloSpecSwift.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include "HybridYoloSpec.hpp"
11
+
12
+ // Forward declaration of `HybridYoloSpec_cxx` to properly resolve imports.
13
+ namespace Yolo { class HybridYoloSpec_cxx; }
14
+
15
+
16
+
17
+
18
+
19
+ #include "Yolo-Swift-Cxx-Umbrella.hpp"
20
+
21
+ namespace margelo::nitro::yolo {
22
+
23
+ /**
24
+ * The C++ part of HybridYoloSpec_cxx.swift.
25
+ *
26
+ * HybridYoloSpecSwift (C++) accesses HybridYoloSpec_cxx (Swift), and might
27
+ * contain some additional bridging code for C++ <> Swift interop.
28
+ *
29
+ * Since this obviously introduces an overhead, I hope at some point in
30
+ * the future, HybridYoloSpec_cxx can directly inherit from the C++ class HybridYoloSpec
31
+ * to simplify the whole structure and memory management.
32
+ */
33
+ class HybridYoloSpecSwift: public virtual HybridYoloSpec {
34
+ public:
35
+ // Constructor from a Swift instance
36
+ explicit HybridYoloSpecSwift(const Yolo::HybridYoloSpec_cxx& swiftPart):
37
+ HybridObject(HybridYoloSpec::TAG),
38
+ _swiftPart(swiftPart) { }
39
+
40
+ public:
41
+ // Get the Swift part
42
+ inline Yolo::HybridYoloSpec_cxx& getSwiftPart() noexcept {
43
+ return _swiftPart;
44
+ }
45
+
46
+ public:
47
+ inline size_t getExternalMemorySize() noexcept override {
48
+ return _swiftPart.getMemorySize();
49
+ }
50
+ bool equals(const std::shared_ptr<HybridObject>& other) override {
51
+ if (auto otherCast = std::dynamic_pointer_cast<HybridYoloSpecSwift>(other)) {
52
+ return _swiftPart.equals(otherCast->_swiftPart);
53
+ }
54
+ return false;
55
+ }
56
+ void dispose() noexcept override {
57
+ _swiftPart.dispose();
58
+ }
59
+ std::string toString() override {
60
+ return _swiftPart.toString();
61
+ }
62
+
63
+ public:
64
+ // Properties
65
+
66
+
67
+ public:
68
+ // Methods
69
+ inline double sum(double num1, double num2) override {
70
+ auto __result = _swiftPart.sum(std::forward<decltype(num1)>(num1), std::forward<decltype(num2)>(num2));
71
+ if (__result.hasError()) [[unlikely]] {
72
+ std::rethrow_exception(__result.error());
73
+ }
74
+ auto __value = std::move(__result.value());
75
+ return __value;
76
+ }
77
+ inline double subtract(double num1, double num2) override {
78
+ auto __result = _swiftPart.subtract(std::forward<decltype(num1)>(num1), std::forward<decltype(num2)>(num2));
79
+ if (__result.hasError()) [[unlikely]] {
80
+ std::rethrow_exception(__result.error());
81
+ }
82
+ auto __value = std::move(__result.value());
83
+ return __value;
84
+ }
85
+
86
+ private:
87
+ Yolo::HybridYoloSpec_cxx _swiftPart;
88
+ };
89
+
90
+ } // namespace margelo::nitro::yolo
@@ -0,0 +1,56 @@
1
+ ///
2
+ /// HybridYoloSpec.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /// See ``HybridYoloSpec``
11
+ public protocol HybridYoloSpec_protocol: HybridObject {
12
+ // Properties
13
+
14
+
15
+ // Methods
16
+ func sum(num1: Double, num2: Double) throws -> Double
17
+ func subtract(num1: Double, num2: Double) throws -> Double
18
+ }
19
+
20
+ public extension HybridYoloSpec_protocol {
21
+ /// Default implementation of ``HybridObject.toString``
22
+ func toString() -> String {
23
+ return "[HybridObject Yolo]"
24
+ }
25
+ }
26
+
27
+ /// See ``HybridYoloSpec``
28
+ open class HybridYoloSpec_base {
29
+ private weak var cxxWrapper: HybridYoloSpec_cxx? = nil
30
+ public init() { }
31
+ public func getCxxWrapper() -> HybridYoloSpec_cxx {
32
+ #if DEBUG
33
+ guard self is any HybridYoloSpec else {
34
+ fatalError("`self` is not a `HybridYoloSpec`! Did you accidentally inherit from `HybridYoloSpec_base` instead of `HybridYoloSpec`?")
35
+ }
36
+ #endif
37
+ if let cxxWrapper = self.cxxWrapper {
38
+ return cxxWrapper
39
+ } else {
40
+ let cxxWrapper = HybridYoloSpec_cxx(self as! any HybridYoloSpec)
41
+ self.cxxWrapper = cxxWrapper
42
+ return cxxWrapper
43
+ }
44
+ }
45
+ }
46
+
47
+ /**
48
+ * A Swift base-protocol representing the Yolo HybridObject.
49
+ * Implement this protocol to create Swift-based instances of Yolo.
50
+ * ```swift
51
+ * class HybridYolo : HybridYoloSpec {
52
+ * // ...
53
+ * }
54
+ * ```
55
+ */
56
+ public typealias HybridYoloSpec = HybridYoloSpec_protocol & HybridYoloSpec_base