diff --git a/native/android/app/CMakeLists.txt b/native/android/app/CMakeLists.txt --- a/native/android/app/CMakeLists.txt +++ b/native/android/app/CMakeLists.txt @@ -118,7 +118,7 @@ "./src/cpp/jsiInstaller.cpp" ) -set(GENERATED_NATIVE_CODE "../../cpp/CommonCpp/_generated/commJSI-generated.cpp") +file(GLOB GENERATED_NATIVE_CODE "../../cpp/CommonCpp/_generated/*JSI-generated.cpp") set(RUST_NATIVE_CODE "../../native_rust_library/RustCallback.cpp") file(GLOB CRYPTO_NATIVE_CODE "../../cpp/CommonCpp/CryptoTools/*.cpp") file(GLOB DB_NATIVE_CODE "../../cpp/CommonCpp/DatabaseManagers/*.cpp") diff --git a/native/codegen/src/index.js b/native/codegen/src/index.js --- a/native/codegen/src/index.js +++ b/native/codegen/src/index.js @@ -7,7 +7,12 @@ import codeGen from './CodeGen.js'; ('use strict'); -const schemaInPath = path.resolve('./schema/CommCoreModuleSchema.js'); const outPath = path.resolve('./cpp/CommonCpp/_generated'); -codeGen('comm', schemaInPath, ['cpp', 'h'], outPath); +// CommCoreModule +const coreModuleSchemaPath = path.resolve('./schema/CommCoreModuleSchema.js'); +codeGen('comm', coreModuleSchemaPath, ['cpp', 'h'], outPath); + +// CommUtilsModule +const utilsModuleSchemaPath = path.resolve('./schema/CommUtilsModuleSchema.js'); +codeGen('utils', utilsModuleSchemaPath, ['cpp', 'h'], outPath); diff --git a/native/cpp/CommonCpp/_generated/utilsJSI-generated.cpp b/native/cpp/CommonCpp/_generated/utilsJSI-generated.cpp new file mode 100644 --- /dev/null +++ b/native/cpp/CommonCpp/_generated/utilsJSI-generated.cpp @@ -0,0 +1,34 @@ +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleH.js + */ + +#include "utilsJSI.h" + +namespace facebook { +namespace react { + +static jsi::Value __hostFunction_CommUtilsModuleSchemaCxxSpecJSI_writeBufferToFile(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->writeBufferToFile(rt, args[0].asString(rt), args[1].asObject(rt)); +} +static jsi::Value __hostFunction_CommUtilsModuleSchemaCxxSpecJSI_readBufferFromFile(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->readBufferFromFile(rt, args[0].asString(rt)); +} +static jsi::Value __hostFunction_CommUtilsModuleSchemaCxxSpecJSI_base64EncodeBuffer(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->base64EncodeBuffer(rt, args[0].asObject(rt)); +} + +CommUtilsModuleSchemaCxxSpecJSI::CommUtilsModuleSchemaCxxSpecJSI(std::shared_ptr jsInvoker) + : TurboModule("CommUtilsTurboModule", jsInvoker) { + methodMap_["writeBufferToFile"] = MethodMetadata {2, __hostFunction_CommUtilsModuleSchemaCxxSpecJSI_writeBufferToFile}; + methodMap_["readBufferFromFile"] = MethodMetadata {1, __hostFunction_CommUtilsModuleSchemaCxxSpecJSI_readBufferFromFile}; + methodMap_["base64EncodeBuffer"] = MethodMetadata {1, __hostFunction_CommUtilsModuleSchemaCxxSpecJSI_base64EncodeBuffer}; +} + + +} // namespace react +} // namespace facebook diff --git a/native/cpp/CommonCpp/_generated/utilsJSI.h b/native/cpp/CommonCpp/_generated/utilsJSI.h new file mode 100644 --- /dev/null +++ b/native/cpp/CommonCpp/_generated/utilsJSI.h @@ -0,0 +1,80 @@ +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleH.js + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT CommUtilsModuleSchemaCxxSpecJSI : public TurboModule { +protected: + CommUtilsModuleSchemaCxxSpecJSI(std::shared_ptr jsInvoker); + +public: + virtual jsi::Value writeBufferToFile(jsi::Runtime &rt, jsi::String path, jsi::Object data) = 0; + virtual jsi::Value readBufferFromFile(jsi::Runtime &rt, jsi::String path) = 0; + virtual jsi::String base64EncodeBuffer(jsi::Runtime &rt, jsi::Object data) = 0; + +}; + +template +class JSI_EXPORT CommUtilsModuleSchemaCxxSpec : public TurboModule { +public: + jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override { + return delegate_.get(rt, propName); + } + +protected: + CommUtilsModuleSchemaCxxSpec(std::shared_ptr jsInvoker) + : TurboModule("CommUtilsTurboModule", jsInvoker), + delegate_(static_cast(this), jsInvoker) {} + +private: + class Delegate : public CommUtilsModuleSchemaCxxSpecJSI { + public: + Delegate(T *instance, std::shared_ptr jsInvoker) : + CommUtilsModuleSchemaCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {} + + jsi::Value writeBufferToFile(jsi::Runtime &rt, jsi::String path, jsi::Object data) override { + static_assert( + bridging::getParameterCount(&T::writeBufferToFile) == 3, + "Expected writeBufferToFile(...) to have 3 parameters"); + + return bridging::callFromJs( + rt, &T::writeBufferToFile, jsInvoker_, instance_, std::move(path), std::move(data)); + } + jsi::Value readBufferFromFile(jsi::Runtime &rt, jsi::String path) override { + static_assert( + bridging::getParameterCount(&T::readBufferFromFile) == 2, + "Expected readBufferFromFile(...) to have 2 parameters"); + + return bridging::callFromJs( + rt, &T::readBufferFromFile, jsInvoker_, instance_, std::move(path)); + } + jsi::String base64EncodeBuffer(jsi::Runtime &rt, jsi::Object data) override { + static_assert( + bridging::getParameterCount(&T::base64EncodeBuffer) == 2, + "Expected base64EncodeBuffer(...) to have 2 parameters"); + + return bridging::callFromJs( + rt, &T::base64EncodeBuffer, jsInvoker_, instance_, std::move(data)); + } + + private: + T *instance_; + }; + + Delegate delegate_; +}; + +} // namespace react +} // namespace facebook diff --git a/native/ios/Comm.xcodeproj/project.pbxproj b/native/ios/Comm.xcodeproj/project.pbxproj --- a/native/ios/Comm.xcodeproj/project.pbxproj +++ b/native/ios/Comm.xcodeproj/project.pbxproj @@ -37,6 +37,7 @@ 7F8D602926535F2A0053CB29 /* IBMPlexSans-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7F8D602626535EEE0053CB29 /* IBMPlexSans-Regular.ttf */; }; 7FA2DCDE293E62F500991BA4 /* CommIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7FA2DCDC293E62F500991BA4 /* CommIcons.ttf */; }; 7FA2DCDF293E62F500991BA4 /* SWMansionIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7FA2DCDD293E62F500991BA4 /* SWMansionIcons.ttf */; }; + 7FBB2A7629E94539002C6493 /* utilsJSI-generated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7FBB2A7529E94539002C6493 /* utilsJSI-generated.cpp */; }; 7FE4D9F5291DFE9300667BF6 /* commJSI-generated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7FE4D9F4291DFE9300667BF6 /* commJSI-generated.cpp */; }; 8B38121629CE5742000C52E9 /* RustPromiseManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8B38121529CE5742000C52E9 /* RustPromiseManager.cpp */; }; 8B652FA6295EAA5B009F8163 /* RustCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8B652FA5295EAA5B009F8163 /* RustCallback.cpp */; }; @@ -162,6 +163,8 @@ 7F8D602726535EEE0053CB29 /* IBMPlexSans-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "IBMPlexSans-Bold.ttf"; path = "Resources/IBMPlexSans-Bold.ttf"; sourceTree = ""; }; 7FA2DCDC293E62F500991BA4 /* CommIcons.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = CommIcons.ttf; path = ../fonts/CommIcons.ttf; sourceTree = ""; }; 7FA2DCDD293E62F500991BA4 /* SWMansionIcons.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = SWMansionIcons.ttf; path = ../fonts/SWMansionIcons.ttf; sourceTree = ""; }; + 7FBB2A7529E94539002C6493 /* utilsJSI-generated.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "utilsJSI-generated.cpp"; sourceTree = ""; }; + 7FBB2A7729E94541002C6493 /* utilsJSI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = utilsJSI.h; sourceTree = ""; }; 7FCEA2DC2444010B004017B1 /* Comm-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Comm-Bridging-Header.h"; sourceTree = ""; }; 7FCFD8BD1E81B8DF00629B0E /* Comm.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = Comm.entitlements; path = Comm/Comm.entitlements; sourceTree = ""; }; 7FE4D9F3291DFE9300667BF6 /* commJSI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = commJSI.h; sourceTree = ""; }; @@ -437,6 +440,8 @@ children = ( 7FE4D9F4291DFE9300667BF6 /* commJSI-generated.cpp */, 7FE4D9F3291DFE9300667BF6 /* commJSI.h */, + 7FBB2A7529E94539002C6493 /* utilsJSI-generated.cpp */, + 7FBB2A7729E94541002C6493 /* utilsJSI.h */, ); path = _generated; sourceTree = ""; @@ -985,6 +990,7 @@ 71BE844A2636A944002849D2 /* CommCoreModule.cpp in Sources */, 71D4D7CC26C50B1000FCDBCD /* CommSecureStore.mm in Sources */, 8B38121629CE5742000C52E9 /* RustPromiseManager.cpp in Sources */, + 7FBB2A7629E94539002C6493 /* utilsJSI-generated.cpp in Sources */, 711B408425DA97F9005F8F06 /* dummy.swift in Sources */, 8E86A6D329537EBB000BBE7D /* DatabaseManager.cpp in Sources */, CBDEC69B28ED867000C17588 /* GlobalDBSingleton.mm in Sources */,