react-native-fast-json 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 (43) hide show
  1. package/FastJson.podspec +41 -0
  2. package/LICENSE +20 -0
  3. package/README.md +162 -0
  4. package/android/CMakeLists.txt +37 -0
  5. package/android/build.gradle +119 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/cpp/cpp-adapter.cpp +11 -0
  8. package/android/src/main/java/com/margelo/nitro/fastjson/FastJsonPackage.kt +22 -0
  9. package/cpp/HybridFastJson.cpp +61 -0
  10. package/cpp/HybridFastJson.hpp +19 -0
  11. package/cpp/HybridJsonView.cpp +370 -0
  12. package/cpp/HybridJsonView.hpp +39 -0
  13. package/cpp/third_party/simdjson.cpp +65338 -0
  14. package/cpp/third_party/simdjson.h +186793 -0
  15. package/lib/module/FastJson.nitro.js +4 -0
  16. package/lib/module/FastJson.nitro.js.map +1 -0
  17. package/lib/module/index.js +5 -0
  18. package/lib/module/index.js.map +1 -0
  19. package/lib/module/package.json +1 -0
  20. package/lib/typescript/package.json +1 -0
  21. package/lib/typescript/src/FastJson.nitro.d.ts +85 -0
  22. package/lib/typescript/src/FastJson.nitro.d.ts.map +1 -0
  23. package/lib/typescript/src/index.d.ts +4 -0
  24. package/lib/typescript/src/index.d.ts.map +1 -0
  25. package/nitro.json +19 -0
  26. package/nitrogen/generated/android/fastjson+autolinking.cmake +82 -0
  27. package/nitrogen/generated/android/fastjson+autolinking.gradle +27 -0
  28. package/nitrogen/generated/android/fastjsonOnLoad.cpp +49 -0
  29. package/nitrogen/generated/android/fastjsonOnLoad.hpp +34 -0
  30. package/nitrogen/generated/android/kotlin/com/margelo/nitro/fastjson/fastjsonOnLoad.kt +35 -0
  31. package/nitrogen/generated/ios/FastJson+autolinking.rb +62 -0
  32. package/nitrogen/generated/ios/FastJson-Swift-Cxx-Bridge.cpp +17 -0
  33. package/nitrogen/generated/ios/FastJson-Swift-Cxx-Bridge.hpp +27 -0
  34. package/nitrogen/generated/ios/FastJson-Swift-Cxx-Umbrella.hpp +38 -0
  35. package/nitrogen/generated/ios/FastJsonAutolinking.mm +35 -0
  36. package/nitrogen/generated/ios/FastJsonAutolinking.swift +16 -0
  37. package/nitrogen/generated/shared/c++/HybridFastJsonSpec.cpp +23 -0
  38. package/nitrogen/generated/shared/c++/HybridFastJsonSpec.hpp +70 -0
  39. package/nitrogen/generated/shared/c++/HybridJsonViewSpec.cpp +34 -0
  40. package/nitrogen/generated/shared/c++/HybridJsonViewSpec.hpp +81 -0
  41. package/package.json +185 -0
  42. package/src/FastJson.nitro.ts +86 -0
  43. package/src/index.tsx +6 -0
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export {};
4
+ //# sourceMappingURL=FastJson.nitro.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["FastJson.nitro.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ import { NitroModules } from 'react-native-nitro-modules';
4
+ export const fastJson = NitroModules.createHybridObject('FastJson');
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NitroModules","fastJson","createHybridObject"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AAIzD,OAAO,MAAMC,QAAQ,GAAGD,YAAY,CAACE,kBAAkB,CAAW,UAAU,CAAC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,85 @@
1
+ import type { AnyMap, HybridObject } from 'react-native-nitro-modules';
2
+ export interface JsonView extends HybridObject<{
3
+ ios: 'c++';
4
+ android: 'c++';
5
+ }> {
6
+ /**
7
+ * Returns the raw JSON string of the JSON view.
8
+ * @returns The raw JSON string of the JSON view.
9
+ */
10
+ rawJson(): string;
11
+ /**
12
+ * Returns the value of the key in the JSON view.
13
+ * @param key The key to get the value of. Must be a single key, not a path.
14
+ * @returns The value of the key in the JSON view.
15
+ */
16
+ getValue(key: string): JsonView | null;
17
+ /**
18
+ * Returns all the keys or fields of an object or array.
19
+ * Only for objects or arrays.
20
+ * @returns The keys of the JSON view.
21
+ */
22
+ keys(): string[];
23
+ /**
24
+ * Only for arrays. Returns the value of the index of an array.
25
+ * @param index The index to get the value from an array.
26
+ * @returns The value of the index in the array.
27
+ */
28
+ at(index: number): JsonView | null;
29
+ /**
30
+ * Returns all the values of the path specified.
31
+ * @param path simple path e.g $.key1.key2.key3. Indexing is not supported.
32
+ * @returns Returns a JsonView.
33
+ */
34
+ atPath(path: string): JsonView | null;
35
+ /**
36
+ * For dynamic retrieval of nested values with wildcards.
37
+ * Supports indexing with [*] or [number].
38
+ * @param path Must begin with $. e.g $.key1[*].key2[1]
39
+ * @returns all the values of the path specified.
40
+ */
41
+ atPathWithWildcard(path: string): string[] | null;
42
+ /**
43
+ * Type of the value. e.g string, number, boolean, object, array.
44
+ */
45
+ type: string;
46
+ /**
47
+ * Only for objects or arrays.
48
+ * @returns The length of the value. 0 for other types.
49
+ */
50
+ length: number;
51
+ /**
52
+ * Returns the value as a string.
53
+ * @returns The value as a string.
54
+ */
55
+ asString(): string;
56
+ asNumber(): number;
57
+ asBoolean(): boolean;
58
+ /**
59
+ * For casting to JS objects or arrays.
60
+ * Only if element is an object or array.
61
+ * @returns `{data: Record<string, any> | any[]}`.
62
+ */
63
+ asObject(): AnyMap;
64
+ }
65
+ export interface FastJson extends HybridObject<{
66
+ ios: 'c++';
67
+ android: 'c++';
68
+ }> {
69
+ /**
70
+ * Parses a JSON string and returns a Promise that resolves to a JsonView.
71
+ * Not ideal, prefer parseFile or use simple JSON.parse if possible.
72
+ * @param str The JSON string.
73
+ * @returns A Promise that resolves to a JsonView or null. Response is not cached.
74
+ */
75
+ parseString(str: string): Promise<JsonView | null>;
76
+ /**
77
+ * Parses a JSON file and returns a Promise that resolves to a JsonView.
78
+ * No check is done if invalid path is provided. Error handling is left to the caller.
79
+ * @param path The path to the JSON file.
80
+ * @returns A Promise that resolves to a JsonView or null. Response is cached for future calls.
81
+ */
82
+ parseFile(path: string): Promise<JsonView | null>;
83
+ release(source: string): void;
84
+ }
85
+ //# sourceMappingURL=FastJson.nitro.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FastJson.nitro.d.ts","sourceRoot":"","sources":["../../../src/FastJson.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAEvE,MAAM,WAAW,QAAS,SAAQ,YAAY,CAAC;IAC7C,GAAG,EAAE,KAAK,CAAC;IACX,OAAO,EAAE,KAAK,CAAC;CAChB,CAAC;IACA;;;OAGG;IACH,OAAO,IAAI,MAAM,CAAC;IAClB;;;;OAIG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAAC;IACvC;;;;OAIG;IACH,IAAI,IAAI,MAAM,EAAE,CAAC;IACjB;;;;OAIG;IACH,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAAC;IACnC;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAA0B,QAAQ,GAAG,IAAI,CAAC;IAC7D;;;;;OAKG;IACH,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAA2B,MAAM,EAAE,GAAG,IAAI,CAAC;IAC1E;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,IAAI,MAAM,CAAC;IACnB,QAAQ,IAAI,MAAM,CAAC;IACnB,SAAS,IAAI,OAAO,CAAC;IACrB;;;;OAIG;IACH,QAAQ,IAAI,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,QAAS,SAAQ,YAAY,CAAC;IAC7C,GAAG,EAAE,KAAK,CAAC;IACX,OAAO,EAAE,KAAK,CAAC;CAChB,CAAC;IACA;;;;;OAKG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IACnD;;;;;OAKG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IAClD,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B"}
@@ -0,0 +1,4 @@
1
+ import type { FastJson, JsonView } from './FastJson.nitro';
2
+ export declare const fastJson: FastJson;
3
+ export type { JsonView };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE3D,eAAO,MAAM,QAAQ,UAAwD,CAAC;AAC9E,YAAY,EAAE,QAAQ,EAAE,CAAC"}
package/nitro.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "cxxNamespace": ["fastjson"],
3
+ "ios": {
4
+ "iosModuleName": "FastJson"
5
+ },
6
+ "android": {
7
+ "androidNamespace": ["fastjson"],
8
+ "androidCxxLibName": "fastjson"
9
+ },
10
+ "autolinking": {
11
+ "FastJson": {
12
+ "all": {
13
+ "language": "c++",
14
+ "implementationClassName": "HybridFastJson"
15
+ }
16
+ }
17
+ },
18
+ "ignorePaths": ["**/node_modules", "lib"]
19
+ }
@@ -0,0 +1,82 @@
1
+ #
2
+ # fastjson+autolinking.cmake
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 CMake file that adds all files generated by Nitrogen
9
+ # to the current CMake project.
10
+ #
11
+ # To use it, add this to your CMakeLists.txt:
12
+ # ```cmake
13
+ # include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/fastjson+autolinking.cmake)
14
+ # ```
15
+
16
+ # Define a flag to check if we are building properly
17
+ add_definitions(-DBUILDING_FASTJSON_WITH_GENERATED_CMAKE_PROJECT)
18
+
19
+ # Enable Raw Props parsing in react-native (for Nitro Views)
20
+ add_definitions(-DRN_SERIALIZABLE_STATE)
21
+
22
+ # Add all headers that were generated by Nitrogen
23
+ include_directories(
24
+ "../nitrogen/generated/shared/c++"
25
+ "../nitrogen/generated/android/c++"
26
+ "../nitrogen/generated/android/"
27
+ )
28
+
29
+ # Add all .cpp sources that were generated by Nitrogen
30
+ target_sources(
31
+ # CMake project name (Android C++ library name)
32
+ fastjson PRIVATE
33
+ # Autolinking Setup
34
+ ../nitrogen/generated/android/fastjsonOnLoad.cpp
35
+ # Shared Nitrogen C++ sources
36
+ ../nitrogen/generated/shared/c++/HybridJsonViewSpec.cpp
37
+ ../nitrogen/generated/shared/c++/HybridFastJsonSpec.cpp
38
+ # Android-specific Nitrogen C++ sources
39
+
40
+ )
41
+
42
+ # From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
43
+ # Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
44
+ target_compile_definitions(
45
+ fastjson PRIVATE
46
+ -DFOLLY_NO_CONFIG=1
47
+ -DFOLLY_HAVE_CLOCK_GETTIME=1
48
+ -DFOLLY_USE_LIBCPP=1
49
+ -DFOLLY_CFG_NO_COROUTINES=1
50
+ -DFOLLY_MOBILE=1
51
+ -DFOLLY_HAVE_RECVMMSG=1
52
+ -DFOLLY_HAVE_PTHREAD=1
53
+ # Once we target android-23 above, we can comment
54
+ # the following line. NDK uses GNU style stderror_r() after API 23.
55
+ -DFOLLY_HAVE_XSI_STRERROR_R=1
56
+ )
57
+
58
+ # Add all libraries required by the generated specs
59
+ find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
60
+ find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
61
+ find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
62
+
63
+ # Link all libraries together
64
+ target_link_libraries(
65
+ fastjson
66
+ fbjni::fbjni # <-- Facebook C++ JNI helpers
67
+ ReactAndroid::jsi # <-- RN: JSI
68
+ react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
69
+ )
70
+
71
+ # Link react-native (different prefab between RN 0.75 and RN 0.76)
72
+ if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
73
+ target_link_libraries(
74
+ fastjson
75
+ ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
76
+ )
77
+ else()
78
+ target_link_libraries(
79
+ fastjson
80
+ ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
81
+ )
82
+ endif()
@@ -0,0 +1,27 @@
1
+ ///
2
+ /// fastjson+autolinking.gradle
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 Gradle file that adds all files generated by Nitrogen
9
+ /// to the current Gradle project.
10
+ ///
11
+ /// To use it, add this to your build.gradle:
12
+ /// ```gradle
13
+ /// apply from: '../nitrogen/generated/android/fastjson+autolinking.gradle'
14
+ /// ```
15
+
16
+ logger.warn("[NitroModules] 🔥 fastjson is boosted by nitro!")
17
+
18
+ android {
19
+ sourceSets {
20
+ main {
21
+ java.srcDirs += [
22
+ // Nitrogen files
23
+ "${project.projectDir}/../nitrogen/generated/android/kotlin"
24
+ ]
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,49 @@
1
+ ///
2
+ /// fastjsonOnLoad.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
+ #ifndef BUILDING_FASTJSON_WITH_GENERATED_CMAKE_PROJECT
9
+ #error fastjsonOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
10
+ #endif
11
+
12
+ #include "fastjsonOnLoad.hpp"
13
+
14
+ #include <jni.h>
15
+ #include <fbjni/fbjni.h>
16
+ #include <NitroModules/HybridObjectRegistry.hpp>
17
+
18
+ #include "HybridFastJson.hpp"
19
+
20
+ namespace margelo::nitro::fastjson {
21
+
22
+ int initialize(JavaVM* vm) {
23
+ return facebook::jni::initialize(vm, []() {
24
+ ::margelo::nitro::fastjson::registerAllNatives();
25
+ });
26
+ }
27
+
28
+
29
+
30
+ void registerAllNatives() {
31
+ using namespace margelo::nitro;
32
+ using namespace margelo::nitro::fastjson;
33
+
34
+ // Register native JNI methods
35
+
36
+
37
+ // Register Nitro Hybrid Objects
38
+ HybridObjectRegistry::registerHybridObjectConstructor(
39
+ "FastJson",
40
+ []() -> std::shared_ptr<HybridObject> {
41
+ static_assert(std::is_default_constructible_v<HybridFastJson>,
42
+ "The HybridObject \"HybridFastJson\" is not default-constructible! "
43
+ "Create a public constructor that takes zero arguments to be able to autolink this HybridObject.");
44
+ return std::make_shared<HybridFastJson>();
45
+ }
46
+ );
47
+ }
48
+
49
+ } // namespace margelo::nitro::fastjson
@@ -0,0 +1,34 @@
1
+ ///
2
+ /// fastjsonOnLoad.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::fastjson {
13
+
14
+ [[deprecated("Use registerNatives() instead.")]]
15
+ int initialize(JavaVM* vm);
16
+
17
+ /**
18
+ * Register the native (C++) part of fastjson, 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 fastjson HybridObjects
26
+ * margelo::nitro::fastjson::registerNatives();
27
+ * // any other custom registrations go here.
28
+ * });
29
+ * }
30
+ * ```
31
+ */
32
+ void registerAllNatives();
33
+
34
+ } // namespace margelo::nitro::fastjson
@@ -0,0 +1,35 @@
1
+ ///
2
+ /// fastjsonOnLoad.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.fastjson
9
+
10
+ import android.util.Log
11
+
12
+ internal class fastjsonOnLoad {
13
+ companion object {
14
+ private const val TAG = "fastjsonOnLoad"
15
+ private var didLoad = false
16
+ /**
17
+ * Initializes the native part of "fastjson".
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 fastjson C++ library...")
25
+ System.loadLibrary("fastjson")
26
+ Log.i(TAG, "Successfully loaded fastjson C++ library!")
27
+ didLoad = true
28
+ } catch (e: Error) {
29
+ Log.e(TAG, "Failed to load fastjson 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
+ # FastJson+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/FastJson+autolinking.rb'
18
+ # add_nitrogen_files(spec)
19
+ # end
20
+ # ```
21
+
22
+ def add_nitrogen_files(spec)
23
+ Pod::UI.puts "[NitroModules] 🔥 FastJson 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/FastJson-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,17 @@
1
+ ///
2
+ /// FastJson-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 "FastJson-Swift-Cxx-Bridge.hpp"
9
+
10
+ // Include C++ implementation defined types
11
+
12
+
13
+ namespace margelo::nitro::fastjson::bridge::swift {
14
+
15
+
16
+
17
+ } // namespace margelo::nitro::fastjson::bridge::swift
@@ -0,0 +1,27 @@
1
+ ///
2
+ /// FastJson-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
+
12
+
13
+ // Forward declarations of Swift defined types
14
+
15
+
16
+ // Include C++ defined types
17
+
18
+
19
+ /**
20
+ * Contains specialized versions of C++ templated types so they can be accessed from Swift,
21
+ * as well as helper functions to interact with those C++ types from Swift.
22
+ */
23
+ namespace margelo::nitro::fastjson::bridge::swift {
24
+
25
+
26
+
27
+ } // namespace margelo::nitro::fastjson::bridge::swift
@@ -0,0 +1,38 @@
1
+ ///
2
+ /// FastJson-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
+
12
+
13
+ // Include C++ defined types
14
+
15
+
16
+ // C++ helpers for Swift
17
+ #include "FastJson-Swift-Cxx-Bridge.hpp"
18
+
19
+ // Common C++ types used in Swift
20
+ #include <NitroModules/ArrayBufferHolder.hpp>
21
+ #include <NitroModules/AnyMapUtils.hpp>
22
+ #include <NitroModules/RuntimeError.hpp>
23
+ #include <NitroModules/DateToChronoDate.hpp>
24
+
25
+ // Forward declarations of Swift defined types
26
+
27
+
28
+ // Include Swift defined types
29
+ #if __has_include("FastJson-Swift.h")
30
+ // This header is generated by Xcode/Swift on every app build.
31
+ // If it cannot be found, make sure the Swift module's name (= podspec name) is actually "FastJson".
32
+ #include "FastJson-Swift.h"
33
+ // Same as above, but used when building with frameworks (`use_frameworks`)
34
+ #elif __has_include(<FastJson/FastJson-Swift.h>)
35
+ #include <FastJson/FastJson-Swift.h>
36
+ #else
37
+ #error FastJson's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "FastJson", and try building the app first.
38
+ #endif
@@ -0,0 +1,35 @@
1
+ ///
2
+ /// FastJsonAutolinking.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
+
11
+ #import <type_traits>
12
+
13
+ #include "HybridFastJson.hpp"
14
+
15
+ @interface FastJsonAutolinking : NSObject
16
+ @end
17
+
18
+ @implementation FastJsonAutolinking
19
+
20
+ + (void) load {
21
+ using namespace margelo::nitro;
22
+ using namespace margelo::nitro::fastjson;
23
+
24
+ HybridObjectRegistry::registerHybridObjectConstructor(
25
+ "FastJson",
26
+ []() -> std::shared_ptr<HybridObject> {
27
+ static_assert(std::is_default_constructible_v<HybridFastJson>,
28
+ "The HybridObject \"HybridFastJson\" is not default-constructible! "
29
+ "Create a public constructor that takes zero arguments to be able to autolink this HybridObject.");
30
+ return std::make_shared<HybridFastJson>();
31
+ }
32
+ );
33
+ }
34
+
35
+ @end
@@ -0,0 +1,16 @@
1
+ ///
2
+ /// FastJsonAutolinking.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 FastJsonAutolinking {
13
+ public typealias bridge = margelo.nitro.fastjson.bridge.swift
14
+
15
+
16
+ }
@@ -0,0 +1,23 @@
1
+ ///
2
+ /// HybridFastJsonSpec.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 "HybridFastJsonSpec.hpp"
9
+
10
+ namespace margelo::nitro::fastjson {
11
+
12
+ void HybridFastJsonSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridMethod("parseString", &HybridFastJsonSpec::parseString);
18
+ prototype.registerHybridMethod("parseFile", &HybridFastJsonSpec::parseFile);
19
+ prototype.registerHybridMethod("release", &HybridFastJsonSpec::release);
20
+ });
21
+ }
22
+
23
+ } // namespace margelo::nitro::fastjson
@@ -0,0 +1,70 @@
1
+ ///
2
+ /// HybridFastJsonSpec.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 `HybridJsonViewSpec` to properly resolve imports.
17
+ namespace margelo::nitro::fastjson { class HybridJsonViewSpec; }
18
+
19
+ #include <NitroModules/Null.hpp>
20
+ #include <memory>
21
+ #include "HybridJsonViewSpec.hpp"
22
+ #include <variant>
23
+ #include <NitroModules/Promise.hpp>
24
+ #include <string>
25
+
26
+ namespace margelo::nitro::fastjson {
27
+
28
+ using namespace margelo::nitro;
29
+
30
+ /**
31
+ * An abstract base class for `FastJson`
32
+ * Inherit this class to create instances of `HybridFastJsonSpec` in C++.
33
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
34
+ * @example
35
+ * ```cpp
36
+ * class HybridFastJson: public HybridFastJsonSpec {
37
+ * public:
38
+ * HybridFastJson(...): HybridObject(TAG) { ... }
39
+ * // ...
40
+ * };
41
+ * ```
42
+ */
43
+ class HybridFastJsonSpec: public virtual HybridObject {
44
+ public:
45
+ // Constructor
46
+ explicit HybridFastJsonSpec(): HybridObject(TAG) { }
47
+
48
+ // Destructor
49
+ ~HybridFastJsonSpec() override = default;
50
+
51
+ public:
52
+ // Properties
53
+
54
+
55
+ public:
56
+ // Methods
57
+ virtual std::shared_ptr<Promise<std::variant<nitro::NullType, std::shared_ptr<HybridJsonViewSpec>>>> parseString(const std::string& str) = 0;
58
+ virtual std::shared_ptr<Promise<std::variant<nitro::NullType, std::shared_ptr<HybridJsonViewSpec>>>> parseFile(const std::string& path) = 0;
59
+ virtual void release(const std::string& source) = 0;
60
+
61
+ protected:
62
+ // Hybrid Setup
63
+ void loadHybridMethods() override;
64
+
65
+ protected:
66
+ // Tag for logging
67
+ static constexpr auto TAG = "FastJson";
68
+ };
69
+
70
+ } // namespace margelo::nitro::fastjson