@angadie/chittie-react-native 0.1.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.
Files changed (60) hide show
  1. package/ChittieReactNative.podspec +32 -0
  2. package/LICENSE +24 -0
  3. package/README.md +80 -0
  4. package/android/CMakeLists.txt +25 -0
  5. package/android/build.gradle +100 -0
  6. package/android/fix-prefab.gradle +37 -0
  7. package/android/gradle.properties +5 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  9. package/android/src/main/java/com/margelo/nitro/chittie/HybridChittieRasterizer.kt +53 -0
  10. package/app.plugin.js +5 -0
  11. package/ios/HybridChittieRasterizer.swift +48 -0
  12. package/lib/commonjs/adapter.js +33 -0
  13. package/lib/commonjs/adapter.js.map +1 -0
  14. package/lib/commonjs/index.js +34 -0
  15. package/lib/commonjs/index.js.map +1 -0
  16. package/lib/commonjs/package.json +1 -0
  17. package/lib/commonjs/specs/ChittieRasterizer.nitro.js +6 -0
  18. package/lib/commonjs/specs/ChittieRasterizer.nitro.js.map +1 -0
  19. package/lib/module/adapter.js +29 -0
  20. package/lib/module/adapter.js.map +1 -0
  21. package/lib/module/index.js +25 -0
  22. package/lib/module/index.js.map +1 -0
  23. package/lib/module/specs/ChittieRasterizer.nitro.js +4 -0
  24. package/lib/module/specs/ChittieRasterizer.nitro.js.map +1 -0
  25. package/lib/typescript/src/adapter.d.ts +11 -0
  26. package/lib/typescript/src/adapter.d.ts.map +1 -0
  27. package/lib/typescript/src/index.d.ts +15 -0
  28. package/lib/typescript/src/index.d.ts.map +1 -0
  29. package/lib/typescript/src/specs/ChittieRasterizer.nitro.d.ts +23 -0
  30. package/lib/typescript/src/specs/ChittieRasterizer.nitro.d.ts.map +1 -0
  31. package/nitro.json +23 -0
  32. package/nitrogen/generated/.gitattributes +1 -0
  33. package/nitrogen/generated/android/ChittieReactNative+autolinking.cmake +81 -0
  34. package/nitrogen/generated/android/ChittieReactNative+autolinking.gradle +27 -0
  35. package/nitrogen/generated/android/ChittieReactNativeOnLoad.cpp +54 -0
  36. package/nitrogen/generated/android/ChittieReactNativeOnLoad.hpp +34 -0
  37. package/nitrogen/generated/android/c++/JHybridChittieRasterizerSpec.cpp +58 -0
  38. package/nitrogen/generated/android/c++/JHybridChittieRasterizerSpec.hpp +63 -0
  39. package/nitrogen/generated/android/c++/JRasterBitmap.hpp +66 -0
  40. package/nitrogen/generated/android/kotlin/com/margelo/nitro/chittie/ChittieReactNativeOnLoad.kt +35 -0
  41. package/nitrogen/generated/android/kotlin/com/margelo/nitro/chittie/HybridChittieRasterizerSpec.kt +54 -0
  42. package/nitrogen/generated/android/kotlin/com/margelo/nitro/chittie/RasterBitmap.kt +44 -0
  43. package/nitrogen/generated/ios/ChittieReactNative+autolinking.rb +60 -0
  44. package/nitrogen/generated/ios/ChittieReactNative-Swift-Cxx-Bridge.cpp +33 -0
  45. package/nitrogen/generated/ios/ChittieReactNative-Swift-Cxx-Bridge.hpp +54 -0
  46. package/nitrogen/generated/ios/ChittieReactNative-Swift-Cxx-Umbrella.hpp +48 -0
  47. package/nitrogen/generated/ios/ChittieReactNativeAutolinking.mm +33 -0
  48. package/nitrogen/generated/ios/ChittieReactNativeAutolinking.swift +26 -0
  49. package/nitrogen/generated/ios/c++/HybridChittieRasterizerSpecSwift.cpp +11 -0
  50. package/nitrogen/generated/ios/c++/HybridChittieRasterizerSpecSwift.hpp +88 -0
  51. package/nitrogen/generated/ios/swift/HybridChittieRasterizerSpec.swift +55 -0
  52. package/nitrogen/generated/ios/swift/HybridChittieRasterizerSpec_cxx.swift +138 -0
  53. package/nitrogen/generated/ios/swift/RasterBitmap.swift +39 -0
  54. package/nitrogen/generated/shared/c++/HybridChittieRasterizerSpec.cpp +21 -0
  55. package/nitrogen/generated/shared/c++/HybridChittieRasterizerSpec.hpp +64 -0
  56. package/nitrogen/generated/shared/c++/RasterBitmap.hpp +91 -0
  57. package/package.json +77 -0
  58. package/src/adapter.ts +25 -0
  59. package/src/index.ts +27 -0
  60. package/src/specs/ChittieRasterizer.nitro.ts +21 -0
@@ -0,0 +1,54 @@
1
+ ///
2
+ /// ChittieReactNative-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 `HybridChittieRasterizerSpec` to properly resolve imports.
12
+ namespace margelo::nitro::chittie { class HybridChittieRasterizerSpec; }
13
+ // Forward declaration of `RasterBitmap` to properly resolve imports.
14
+ namespace margelo::nitro::chittie { struct RasterBitmap; }
15
+
16
+ // Forward declarations of Swift defined types
17
+ // Forward declaration of `HybridChittieRasterizerSpec_cxx` to properly resolve imports.
18
+ namespace ChittieReactNative { class HybridChittieRasterizerSpec_cxx; }
19
+
20
+ // Include C++ defined types
21
+ #include "HybridChittieRasterizerSpec.hpp"
22
+ #include "RasterBitmap.hpp"
23
+ #include <NitroModules/Result.hpp>
24
+ #include <exception>
25
+ #include <memory>
26
+
27
+ /**
28
+ * Contains specialized versions of C++ templated types so they can be accessed from Swift,
29
+ * as well as helper functions to interact with those C++ types from Swift.
30
+ */
31
+ namespace margelo::nitro::chittie::bridge::swift {
32
+
33
+ // pragma MARK: std::shared_ptr<HybridChittieRasterizerSpec>
34
+ /**
35
+ * Specialized version of `std::shared_ptr<HybridChittieRasterizerSpec>`.
36
+ */
37
+ using std__shared_ptr_HybridChittieRasterizerSpec_ = std::shared_ptr<HybridChittieRasterizerSpec>;
38
+ std::shared_ptr<HybridChittieRasterizerSpec> create_std__shared_ptr_HybridChittieRasterizerSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
39
+ void* NON_NULL get_std__shared_ptr_HybridChittieRasterizerSpec_(std__shared_ptr_HybridChittieRasterizerSpec_ cppType);
40
+
41
+ // pragma MARK: std::weak_ptr<HybridChittieRasterizerSpec>
42
+ using std__weak_ptr_HybridChittieRasterizerSpec_ = std::weak_ptr<HybridChittieRasterizerSpec>;
43
+ inline std__weak_ptr_HybridChittieRasterizerSpec_ weakify_std__shared_ptr_HybridChittieRasterizerSpec_(const std::shared_ptr<HybridChittieRasterizerSpec>& strong) noexcept { return strong; }
44
+
45
+ // pragma MARK: Result<RasterBitmap>
46
+ using Result_RasterBitmap_ = Result<RasterBitmap>;
47
+ inline Result_RasterBitmap_ create_Result_RasterBitmap_(const RasterBitmap& value) noexcept {
48
+ return Result<RasterBitmap>::withValue(value);
49
+ }
50
+ inline Result_RasterBitmap_ create_Result_RasterBitmap_(const std::exception_ptr& error) noexcept {
51
+ return Result<RasterBitmap>::withError(error);
52
+ }
53
+
54
+ } // namespace margelo::nitro::chittie::bridge::swift
@@ -0,0 +1,48 @@
1
+ ///
2
+ /// ChittieReactNative-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 `HybridChittieRasterizerSpec` to properly resolve imports.
12
+ namespace margelo::nitro::chittie { class HybridChittieRasterizerSpec; }
13
+ // Forward declaration of `RasterBitmap` to properly resolve imports.
14
+ namespace margelo::nitro::chittie { struct RasterBitmap; }
15
+
16
+ // Include C++ defined types
17
+ #include "HybridChittieRasterizerSpec.hpp"
18
+ #include "RasterBitmap.hpp"
19
+ #include <NitroModules/ArrayBuffer.hpp>
20
+ #include <NitroModules/Result.hpp>
21
+ #include <exception>
22
+ #include <memory>
23
+ #include <string>
24
+
25
+ // C++ helpers for Swift
26
+ #include "ChittieReactNative-Swift-Cxx-Bridge.hpp"
27
+
28
+ // Common C++ types used in Swift
29
+ #include <NitroModules/ArrayBufferHolder.hpp>
30
+ #include <NitroModules/AnyMapUtils.hpp>
31
+ #include <NitroModules/RuntimeError.hpp>
32
+ #include <NitroModules/DateToChronoDate.hpp>
33
+
34
+ // Forward declarations of Swift defined types
35
+ // Forward declaration of `HybridChittieRasterizerSpec_cxx` to properly resolve imports.
36
+ namespace ChittieReactNative { class HybridChittieRasterizerSpec_cxx; }
37
+
38
+ // Include Swift defined types
39
+ #if __has_include("ChittieReactNative-Swift.h")
40
+ // This header is generated by Xcode/Swift on every app build.
41
+ // If it cannot be found, make sure the Swift module's name (= podspec name) is actually "ChittieReactNative".
42
+ #include "ChittieReactNative-Swift.h"
43
+ // Same as above, but used when building with frameworks (`use_frameworks`)
44
+ #elif __has_include(<ChittieReactNative/ChittieReactNative-Swift.h>)
45
+ #include <ChittieReactNative/ChittieReactNative-Swift.h>
46
+ #else
47
+ #error ChittieReactNative's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "ChittieReactNative", and try building the app first.
48
+ #endif
@@ -0,0 +1,33 @@
1
+ ///
2
+ /// ChittieReactNativeAutolinking.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 "ChittieReactNative-Swift-Cxx-Umbrella.hpp"
11
+ #import <type_traits>
12
+
13
+ #include "HybridChittieRasterizerSpecSwift.hpp"
14
+
15
+ @interface ChittieReactNativeAutolinking : NSObject
16
+ @end
17
+
18
+ @implementation ChittieReactNativeAutolinking
19
+
20
+ + (void) load {
21
+ using namespace margelo::nitro;
22
+ using namespace margelo::nitro::chittie;
23
+
24
+ HybridObjectRegistry::registerHybridObjectConstructor(
25
+ "ChittieRasterizer",
26
+ []() -> std::shared_ptr<HybridObject> {
27
+ std::shared_ptr<HybridChittieRasterizerSpec> hybridObject = ChittieReactNative::ChittieReactNativeAutolinking::createChittieRasterizer();
28
+ return hybridObject;
29
+ }
30
+ );
31
+ }
32
+
33
+ @end
@@ -0,0 +1,26 @@
1
+ ///
2
+ /// ChittieReactNativeAutolinking.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 ChittieReactNativeAutolinking {
13
+ public typealias bridge = margelo.nitro.chittie.bridge.swift
14
+
15
+ public static func createChittieRasterizer() -> bridge.std__shared_ptr_HybridChittieRasterizerSpec_ {
16
+ let hybridObject = HybridChittieRasterizer()
17
+ return { () -> bridge.std__shared_ptr_HybridChittieRasterizerSpec_ in
18
+ let __cxxWrapped = hybridObject.getCxxWrapper()
19
+ return __cxxWrapped.getCxxPart()
20
+ }()
21
+ }
22
+
23
+ public static func isChittieRasterizerRecyclable() -> Bool {
24
+ return HybridChittieRasterizer.self is any RecyclableView.Type
25
+ }
26
+ }
@@ -0,0 +1,11 @@
1
+ ///
2
+ /// HybridChittieRasterizerSpecSwift.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 "HybridChittieRasterizerSpecSwift.hpp"
9
+
10
+ namespace margelo::nitro::chittie {
11
+ } // namespace margelo::nitro::chittie
@@ -0,0 +1,88 @@
1
+ ///
2
+ /// HybridChittieRasterizerSpecSwift.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 "HybridChittieRasterizerSpec.hpp"
11
+
12
+ // Forward declaration of `HybridChittieRasterizerSpec_cxx` to properly resolve imports.
13
+ namespace ChittieReactNative { class HybridChittieRasterizerSpec_cxx; }
14
+
15
+ // Forward declaration of `RasterBitmap` to properly resolve imports.
16
+ namespace margelo::nitro::chittie { struct RasterBitmap; }
17
+ // Forward declaration of `ArrayBufferHolder` to properly resolve imports.
18
+ namespace NitroModules { class ArrayBufferHolder; }
19
+
20
+ #include "RasterBitmap.hpp"
21
+ #include <NitroModules/ArrayBuffer.hpp>
22
+ #include <NitroModules/ArrayBufferHolder.hpp>
23
+ #include <string>
24
+
25
+ #include "ChittieReactNative-Swift-Cxx-Umbrella.hpp"
26
+
27
+ namespace margelo::nitro::chittie {
28
+
29
+ /**
30
+ * The C++ part of HybridChittieRasterizerSpec_cxx.swift.
31
+ *
32
+ * HybridChittieRasterizerSpecSwift (C++) accesses HybridChittieRasterizerSpec_cxx (Swift), and might
33
+ * contain some additional bridging code for C++ <> Swift interop.
34
+ *
35
+ * Since this obviously introduces an overhead, I hope at some point in
36
+ * the future, HybridChittieRasterizerSpec_cxx can directly inherit from the C++ class HybridChittieRasterizerSpec
37
+ * to simplify the whole structure and memory management.
38
+ */
39
+ class HybridChittieRasterizerSpecSwift: public virtual HybridChittieRasterizerSpec {
40
+ public:
41
+ // Constructor from a Swift instance
42
+ explicit HybridChittieRasterizerSpecSwift(const ChittieReactNative::HybridChittieRasterizerSpec_cxx& swiftPart):
43
+ HybridObject(HybridChittieRasterizerSpec::TAG),
44
+ _swiftPart(swiftPart) { }
45
+
46
+ public:
47
+ // Get the Swift part
48
+ inline ChittieReactNative::HybridChittieRasterizerSpec_cxx& getSwiftPart() noexcept {
49
+ return _swiftPart;
50
+ }
51
+
52
+ public:
53
+ inline size_t getExternalMemorySize() noexcept override {
54
+ return _swiftPart.getMemorySize();
55
+ }
56
+ bool equals(const std::shared_ptr<HybridObject>& other) override {
57
+ if (auto otherCast = std::dynamic_pointer_cast<HybridChittieRasterizerSpecSwift>(other)) {
58
+ return _swiftPart.equals(otherCast->_swiftPart);
59
+ }
60
+ return false;
61
+ }
62
+ void dispose() noexcept override {
63
+ _swiftPart.dispose();
64
+ }
65
+ std::string toString() override {
66
+ return _swiftPart.toString();
67
+ }
68
+
69
+ public:
70
+ // Properties
71
+
72
+
73
+ public:
74
+ // Methods
75
+ inline RasterBitmap rasterize(const std::string& text, double fontSize, double maxWidth, bool bold) override {
76
+ auto __result = _swiftPart.rasterize(text, std::forward<decltype(fontSize)>(fontSize), std::forward<decltype(maxWidth)>(maxWidth), std::forward<decltype(bold)>(bold));
77
+ if (__result.hasError()) [[unlikely]] {
78
+ std::rethrow_exception(__result.error());
79
+ }
80
+ auto __value = std::move(__result.value());
81
+ return __value;
82
+ }
83
+
84
+ private:
85
+ ChittieReactNative::HybridChittieRasterizerSpec_cxx _swiftPart;
86
+ };
87
+
88
+ } // namespace margelo::nitro::chittie
@@ -0,0 +1,55 @@
1
+ ///
2
+ /// HybridChittieRasterizerSpec.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 ``HybridChittieRasterizerSpec``
11
+ public protocol HybridChittieRasterizerSpec_protocol: HybridObject {
12
+ // Properties
13
+
14
+
15
+ // Methods
16
+ func rasterize(text: String, fontSize: Double, maxWidth: Double, bold: Bool) throws -> RasterBitmap
17
+ }
18
+
19
+ public extension HybridChittieRasterizerSpec_protocol {
20
+ /// Default implementation of ``HybridObject.toString``
21
+ func toString() -> String {
22
+ return "[HybridObject ChittieRasterizer]"
23
+ }
24
+ }
25
+
26
+ /// See ``HybridChittieRasterizerSpec``
27
+ open class HybridChittieRasterizerSpec_base {
28
+ private weak var cxxWrapper: HybridChittieRasterizerSpec_cxx? = nil
29
+ public init() { }
30
+ public func getCxxWrapper() -> HybridChittieRasterizerSpec_cxx {
31
+ #if DEBUG
32
+ guard self is any HybridChittieRasterizerSpec else {
33
+ fatalError("`self` is not a `HybridChittieRasterizerSpec`! Did you accidentally inherit from `HybridChittieRasterizerSpec_base` instead of `HybridChittieRasterizerSpec`?")
34
+ }
35
+ #endif
36
+ if let cxxWrapper = self.cxxWrapper {
37
+ return cxxWrapper
38
+ } else {
39
+ let cxxWrapper = HybridChittieRasterizerSpec_cxx(self as! any HybridChittieRasterizerSpec)
40
+ self.cxxWrapper = cxxWrapper
41
+ return cxxWrapper
42
+ }
43
+ }
44
+ }
45
+
46
+ /**
47
+ * A Swift base-protocol representing the ChittieRasterizer HybridObject.
48
+ * Implement this protocol to create Swift-based instances of ChittieRasterizer.
49
+ * ```swift
50
+ * class HybridChittieRasterizer : HybridChittieRasterizerSpec {
51
+ * // ...
52
+ * }
53
+ * ```
54
+ */
55
+ public typealias HybridChittieRasterizerSpec = HybridChittieRasterizerSpec_protocol & HybridChittieRasterizerSpec_base
@@ -0,0 +1,138 @@
1
+ ///
2
+ /// HybridChittieRasterizerSpec_cxx.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
+ /**
11
+ * A class implementation that bridges HybridChittieRasterizerSpec over to C++.
12
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
13
+ *
14
+ * Also, some Swift types need to be bridged with special handling:
15
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
16
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
17
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
18
+ */
19
+ open class HybridChittieRasterizerSpec_cxx {
20
+ /**
21
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::chittie::bridge::swift`)
22
+ * from `ChittieReactNative-Swift-Cxx-Bridge.hpp`.
23
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
24
+ */
25
+ public typealias bridge = margelo.nitro.chittie.bridge.swift
26
+
27
+ /**
28
+ * Holds an instance of the `HybridChittieRasterizerSpec` Swift protocol.
29
+ */
30
+ private var __implementation: any HybridChittieRasterizerSpec
31
+
32
+ /**
33
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
34
+ */
35
+ private var __cxxPart: bridge.std__weak_ptr_HybridChittieRasterizerSpec_
36
+
37
+ /**
38
+ * Create a new `HybridChittieRasterizerSpec_cxx` that wraps the given `HybridChittieRasterizerSpec`.
39
+ * All properties and methods bridge to C++ types.
40
+ */
41
+ public init(_ implementation: any HybridChittieRasterizerSpec) {
42
+ self.__implementation = implementation
43
+ self.__cxxPart = .init()
44
+ /* no base class */
45
+ }
46
+
47
+ /**
48
+ * Get the actual `HybridChittieRasterizerSpec` instance this class wraps.
49
+ */
50
+ @inline(__always)
51
+ public func getHybridChittieRasterizerSpec() -> any HybridChittieRasterizerSpec {
52
+ return __implementation
53
+ }
54
+
55
+ /**
56
+ * Casts this instance to a retained unsafe raw pointer.
57
+ * This acquires one additional strong reference on the object!
58
+ */
59
+ public func toUnsafe() -> UnsafeMutableRawPointer {
60
+ return Unmanaged.passRetained(self).toOpaque()
61
+ }
62
+
63
+ /**
64
+ * Casts an unsafe pointer to a `HybridChittieRasterizerSpec_cxx`.
65
+ * The pointer has to be a retained opaque `Unmanaged<HybridChittieRasterizerSpec_cxx>`.
66
+ * This removes one strong reference from the object!
67
+ */
68
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridChittieRasterizerSpec_cxx {
69
+ return Unmanaged<HybridChittieRasterizerSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
70
+ }
71
+
72
+ /**
73
+ * Gets (or creates) the C++ part of this Hybrid Object.
74
+ * The C++ part is a `std::shared_ptr<HybridChittieRasterizerSpec>`.
75
+ */
76
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridChittieRasterizerSpec_ {
77
+ let cachedCxxPart = self.__cxxPart.lock()
78
+ if Bool(fromCxx: cachedCxxPart) {
79
+ return cachedCxxPart
80
+ } else {
81
+ let newCxxPart = bridge.create_std__shared_ptr_HybridChittieRasterizerSpec_(self.toUnsafe())
82
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridChittieRasterizerSpec_(newCxxPart)
83
+ return newCxxPart
84
+ }
85
+ }
86
+
87
+
88
+
89
+ /**
90
+ * Get the memory size of the Swift class (plus size of any other allocations)
91
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
92
+ */
93
+ @inline(__always)
94
+ public var memorySize: Int {
95
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
96
+ }
97
+
98
+ /**
99
+ * Compares this object with the given [other] object for reference equality.
100
+ */
101
+ @inline(__always)
102
+ public func equals(other: HybridChittieRasterizerSpec_cxx) -> Bool {
103
+ return self.__implementation === other.__implementation
104
+ }
105
+
106
+ /**
107
+ * Call dispose() on the Swift class.
108
+ * This _may_ be called manually from JS.
109
+ */
110
+ @inline(__always)
111
+ public func dispose() {
112
+ self.__implementation.dispose()
113
+ }
114
+
115
+ /**
116
+ * Call toString() on the Swift class.
117
+ */
118
+ @inline(__always)
119
+ public func toString() -> String {
120
+ return self.__implementation.toString()
121
+ }
122
+
123
+ // Properties
124
+
125
+
126
+ // Methods
127
+ @inline(__always)
128
+ public final func rasterize(text: std.string, fontSize: Double, maxWidth: Double, bold: Bool) -> bridge.Result_RasterBitmap_ {
129
+ do {
130
+ let __result = try self.__implementation.rasterize(text: String(text), fontSize: fontSize, maxWidth: maxWidth, bold: bold)
131
+ let __resultCpp = __result
132
+ return bridge.create_Result_RasterBitmap_(__resultCpp)
133
+ } catch (let __error) {
134
+ let __exceptionPtr = __error.toCpp()
135
+ return bridge.create_Result_RasterBitmap_(__exceptionPtr)
136
+ }
137
+ }
138
+ }
@@ -0,0 +1,39 @@
1
+ ///
2
+ /// RasterBitmap.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
+ /**
11
+ * Represents an instance of `RasterBitmap`, backed by a C++ struct.
12
+ */
13
+ public typealias RasterBitmap = margelo.nitro.chittie.RasterBitmap
14
+
15
+ public extension RasterBitmap {
16
+ private typealias bridge = margelo.nitro.chittie.bridge.swift
17
+
18
+ /**
19
+ * Create a new instance of `RasterBitmap`.
20
+ */
21
+ init(data: ArrayBuffer, width: Double, height: Double) {
22
+ self.init(data.getArrayBuffer(), width, height)
23
+ }
24
+
25
+ @inline(__always)
26
+ var data: ArrayBuffer {
27
+ return ArrayBuffer(self.__data)
28
+ }
29
+
30
+ @inline(__always)
31
+ var width: Double {
32
+ return self.__width
33
+ }
34
+
35
+ @inline(__always)
36
+ var height: Double {
37
+ return self.__height
38
+ }
39
+ }
@@ -0,0 +1,21 @@
1
+ ///
2
+ /// HybridChittieRasterizerSpec.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 "HybridChittieRasterizerSpec.hpp"
9
+
10
+ namespace margelo::nitro::chittie {
11
+
12
+ void HybridChittieRasterizerSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridMethod("rasterize", &HybridChittieRasterizerSpec::rasterize);
18
+ });
19
+ }
20
+
21
+ } // namespace margelo::nitro::chittie
@@ -0,0 +1,64 @@
1
+ ///
2
+ /// HybridChittieRasterizerSpec.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
+ #if __has_include(<NitroModules/HybridObject.hpp>)
11
+ #include <NitroModules/HybridObject.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+
16
+ // Forward declaration of `RasterBitmap` to properly resolve imports.
17
+ namespace margelo::nitro::chittie { struct RasterBitmap; }
18
+
19
+ #include "RasterBitmap.hpp"
20
+ #include <string>
21
+
22
+ namespace margelo::nitro::chittie {
23
+
24
+ using namespace margelo::nitro;
25
+
26
+ /**
27
+ * An abstract base class for `ChittieRasterizer`
28
+ * Inherit this class to create instances of `HybridChittieRasterizerSpec` in C++.
29
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
30
+ * @example
31
+ * ```cpp
32
+ * class HybridChittieRasterizer: public HybridChittieRasterizerSpec {
33
+ * public:
34
+ * HybridChittieRasterizer(...): HybridObject(TAG) { ... }
35
+ * // ...
36
+ * };
37
+ * ```
38
+ */
39
+ class HybridChittieRasterizerSpec: public virtual HybridObject {
40
+ public:
41
+ // Constructor
42
+ explicit HybridChittieRasterizerSpec(): HybridObject(TAG) { }
43
+
44
+ // Destructor
45
+ ~HybridChittieRasterizerSpec() override = default;
46
+
47
+ public:
48
+ // Properties
49
+
50
+
51
+ public:
52
+ // Methods
53
+ virtual RasterBitmap rasterize(const std::string& text, double fontSize, double maxWidth, bool bold) = 0;
54
+
55
+ protected:
56
+ // Hybrid Setup
57
+ void loadHybridMethods() override;
58
+
59
+ protected:
60
+ // Tag for logging
61
+ static constexpr auto TAG = "ChittieRasterizer";
62
+ };
63
+
64
+ } // namespace margelo::nitro::chittie
@@ -0,0 +1,91 @@
1
+ ///
2
+ /// RasterBitmap.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
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+
32
+
33
+ #include <NitroModules/ArrayBuffer.hpp>
34
+
35
+ namespace margelo::nitro::chittie {
36
+
37
+ /**
38
+ * A struct which can be represented as a JavaScript object (RasterBitmap).
39
+ */
40
+ struct RasterBitmap final {
41
+ public:
42
+ std::shared_ptr<ArrayBuffer> data SWIFT_PRIVATE;
43
+ double width SWIFT_PRIVATE;
44
+ double height SWIFT_PRIVATE;
45
+
46
+ public:
47
+ RasterBitmap() = default;
48
+ explicit RasterBitmap(std::shared_ptr<ArrayBuffer> data, double width, double height): data(data), width(width), height(height) {}
49
+
50
+ public:
51
+ friend bool operator==(const RasterBitmap& lhs, const RasterBitmap& rhs) = default;
52
+ };
53
+
54
+ } // namespace margelo::nitro::chittie
55
+
56
+ namespace margelo::nitro {
57
+
58
+ // C++ RasterBitmap <> JS RasterBitmap (object)
59
+ template <>
60
+ struct JSIConverter<margelo::nitro::chittie::RasterBitmap> final {
61
+ static inline margelo::nitro::chittie::RasterBitmap fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
62
+ jsi::Object obj = arg.asObject(runtime);
63
+ return margelo::nitro::chittie::RasterBitmap(
64
+ JSIConverter<std::shared_ptr<ArrayBuffer>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "data"))),
65
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width"))),
66
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height")))
67
+ );
68
+ }
69
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::chittie::RasterBitmap& arg) {
70
+ jsi::Object obj(runtime);
71
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "data"), JSIConverter<std::shared_ptr<ArrayBuffer>>::toJSI(runtime, arg.data));
72
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "width"), JSIConverter<double>::toJSI(runtime, arg.width));
73
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "height"), JSIConverter<double>::toJSI(runtime, arg.height));
74
+ return obj;
75
+ }
76
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
77
+ if (!value.isObject()) {
78
+ return false;
79
+ }
80
+ jsi::Object obj = value.getObject(runtime);
81
+ if (!nitro::isPlainObject(runtime, obj)) {
82
+ return false;
83
+ }
84
+ if (!JSIConverter<std::shared_ptr<ArrayBuffer>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "data")))) return false;
85
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width")))) return false;
86
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height")))) return false;
87
+ return true;
88
+ }
89
+ };
90
+
91
+ } // namespace margelo::nitro