diff --git a/example/__tests__/nitro.harness.ts b/example/__tests__/nitro.harness.ts index 16655867b..3abce3813 100644 --- a/example/__tests__/nitro.harness.ts +++ b/example/__tests__/nitro.harness.ts @@ -23,11 +23,12 @@ function createTestRunner( } } -const testObjectCpp = - NitroModules.createHybridObject('TestObjectCpp') +const testObjectCpp = NitroModules.createHybridObject( + 'NitroTestTestObjectCpp' +) const testObjectSwiftKotlin = NitroModules.createHybridObject( - 'TestObjectSwiftKotlin' + 'NitroTestTestObjectSwiftKotlin' ) describe('TestObject (C++)', createTestRunner(testObjectCpp)) diff --git a/example/android/build.gradle b/example/android/build.gradle index dad99b022..859f764ce 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,7 +1,7 @@ buildscript { ext { buildToolsVersion = "36.0.0" - minSdkVersion = 24 + minSdkVersion = 26 compileSdkVersion = 36 targetSdkVersion = 36 ndkVersion = "27.1.12297006" diff --git a/example/ios/NitroExample.xcodeproj/project.pbxproj b/example/ios/NitroExample.xcodeproj/project.pbxproj index 8ccffb976..0896f8c4f 100644 --- a/example/ios/NitroExample.xcodeproj/project.pbxproj +++ b/example/ios/NitroExample.xcodeproj/project.pbxproj @@ -649,4 +649,4 @@ /* End XCConfigurationList section */ }; rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */; -} +} \ No newline at end of file diff --git a/example/src/getTests.ts b/example/src/getTests.ts index aea8dbdc6..fb985b49c 100644 --- a/example/src/getTests.ts +++ b/example/src/getTests.ts @@ -9,7 +9,8 @@ import { type OptionalWrapper, WeirdNumbersEnum, CustomString, - Base, + // HybridBase, + type Base, HybridPlatformObject, HybridChild, } from 'react-native-nitro-test' @@ -24,7 +25,12 @@ import { getHybridObjectConstructor, NitroModules, } from 'react-native-nitro-modules' -import { HybridSomeExternalObject } from 'react-native-nitro-test-external' +import { + HybridSomeExternalObject, + type Base as ExternalBase, + HybridBlaBla, + HybridBase as ExternalHybridBase, +} from 'react-native-nitro-test-external' type TestResult = | { @@ -51,6 +57,9 @@ export interface GetTestsOptions { backend?: AssertionBackend } +const TEST_MODULE_NAME = 'NitroTest' +const TEST_EXTERNAL_MODULE_NAME = 'NitroTestExternal' + const TEST_PERSON: Person = { age: 24, name: 'Marc', @@ -139,7 +148,7 @@ const DATE_PLUS_1H = (() => { return new Date(current + oneHourInMilliseconds) })() -const BASE = NitroModules.createHybridObject('Base') +const BASE = NitroModules.createHybridObject(`${TEST_MODULE_NAME}Base`) let lotsOfCallbacks: ((num: number) => void)[] = [] @@ -2025,15 +2034,19 @@ export function getTests( .toContain('childValue') .toContain('baseValue') ), - createTest('createBase() has name "Base"', () => - it(() => testObject.createBase().name) - .didNotThrow() - .equals('Base') + createTest( + `${TEST_MODULE_NAME} createBase() has name "${TEST_MODULE_NAME}Base"`, + () => + it(() => testObject.createBase().name) + .didNotThrow() + .equals(`${TEST_MODULE_NAME}Base`) ), - createTest('createChild() has name "Child"', () => - it(() => testObject.createChild().name) - .didNotThrow() - .equals('Child') + createTest( + `${TEST_MODULE_NAME} createChild() has name "${TEST_MODULE_NAME}Child"`, + () => + it(() => testObject.createChild().name) + .didNotThrow() + .equals(`${TEST_MODULE_NAME}Child`) ), createTest('createChild() has overridden toString()', () => it(() => testObject.createChild().toString()) @@ -2045,10 +2058,12 @@ export function getTests( .didNotThrow() .equals('HybridChild custom toString() :)') ), - createTest('createBaseActualChild() has name "Child"', () => - it(() => testObject.createBaseActualChild().name) - .didNotThrow() - .equals('Child') + createTest( + `${TEST_MODULE_NAME} createBaseActualChild() has name "${TEST_MODULE_NAME}Child"`, + () => + it(() => testObject.createBaseActualChild().name) + .didNotThrow() + .equals(`${TEST_MODULE_NAME}Child`) ), createTest('createBaseActualChild() works', () => it(() => testObject.createBaseActualChild()) @@ -2181,8 +2196,9 @@ export function getTests( ), createTest('new T() works', () => it(() => { - const HybridTestObjectCpp = - getHybridObjectConstructor('TestObjectCpp') + const HybridTestObjectCpp = getHybridObjectConstructor( + `${TEST_MODULE_NAME}TestObjectCpp` + ) const instance = new HybridTestObjectCpp() return instance }) @@ -2191,8 +2207,9 @@ export function getTests( ), createTest('new T() instanceof works', () => it(() => { - const HybridTestObjectCpp = - getHybridObjectConstructor('TestObjectCpp') + const HybridTestObjectCpp = getHybridObjectConstructor( + `${TEST_MODULE_NAME}TestObjectCpp` + ) const instance = new HybridTestObjectCpp() return instance instanceof HybridTestObjectCpp }) @@ -2201,8 +2218,9 @@ export function getTests( ), createTest('{} instanceof works', () => it(() => { - const HybridTestObjectCpp = - getHybridObjectConstructor('TestObjectCpp') + const HybridTestObjectCpp = getHybridObjectConstructor( + `${TEST_MODULE_NAME}TestObjectCpp` + ) return {} instanceof HybridTestObjectCpp }) .didNotThrow() @@ -2210,8 +2228,9 @@ export function getTests( ), createTest('new T() =/= new T()', () => it(() => { - const HybridTestObjectCpp = - getHybridObjectConstructor('TestObjectCpp') + const HybridTestObjectCpp = getHybridObjectConstructor( + `${TEST_MODULE_NAME}TestObjectCpp` + ) const a = new HybridTestObjectCpp() const b = new HybridTestObjectCpp() return a === b @@ -2221,8 +2240,9 @@ export function getTests( ), createTest('new T() a == a', () => it(() => { - const HybridTestObjectCpp = - getHybridObjectConstructor('TestObjectCpp') + const HybridTestObjectCpp = getHybridObjectConstructor( + `${TEST_MODULE_NAME}TestObjectCpp` + ) const a = new HybridTestObjectCpp() // eslint-disable-next-line no-self-compare return a === a @@ -2327,5 +2347,52 @@ export function getTests( .didNotThrow() .equals(true) ), + createTest('Create ExternalBase while Base exists', () => + it(() => { + return NitroModules.createHybridObject( + `${TEST_EXTERNAL_MODULE_NAME}Base` + ) + }) + .didNotThrow() + .didReturn('object') + .toContain('abc') + ), + createTest('ExternalBase is not an instance of Base', () => + it(() => { + const BaseConstructor = getHybridObjectConstructor( + `${TEST_MODULE_NAME}Base` + ) + const ExternalBaseConstructor = + getHybridObjectConstructor( + `${TEST_EXTERNAL_MODULE_NAME}Base` + ) + const externalInstance = new ExternalBaseConstructor() + return externalInstance instanceof BaseConstructor + }) + .didNotThrow() + .equals(false) + ), + createTest('ExternalBase =/= Base name', () => + it(() => { + return ExternalHybridBase.name === BASE.name + }) + .didNotThrow() + .equals(false) + ), + createTest('ExternalBlaBla.base =/= BASE .toString()', () => + it(() => { + return HybridBlaBla.base?.toString() === BASE.toString() + }) + .didNotThrow() + .equals(false) + ), + createTest('External Base HybridObject name contains library prefix', () => + it(() => { + return ExternalHybridBase.name + }) + .didNotThrow() + .didReturn('string') + .toStringContain(TEST_EXTERNAL_MODULE_NAME) + ), ] } diff --git a/example/src/screens/EvalScreen.tsx b/example/src/screens/EvalScreen.tsx index c7933bc9d..1c95c7dd3 100644 --- a/example/src/screens/EvalScreen.tsx +++ b/example/src/screens/EvalScreen.tsx @@ -22,7 +22,7 @@ const PRE_CODE = ` const NitroModules = globalThis.NitroModulesProxy; `.trim() const DEFAULT_CODE = ` -const testObject = NitroModules.createHybridObject('TestObjectCpp') +const testObject = NitroModules.createHybridObject('NitroTestTestObjectCpp') JSON.stringify(testObject) `.trim() diff --git a/example/src/screens/ViewScreen.tsx b/example/src/screens/ViewScreen.tsx index c17b84864..c53ae0a8b 100644 --- a/example/src/screens/ViewScreen.tsx +++ b/example/src/screens/ViewScreen.tsx @@ -9,6 +9,7 @@ import { RecyclableTestView, TestView, } from 'react-native-nitro-test' +import { TestView as ExternalTestView } from 'react-native-nitro-test-external' import { useIsFocused } from '@react-navigation/native' const VIEWS_X = 15 @@ -43,6 +44,23 @@ export function ViewScreenImpl() { }} /> ) + } else if (i % 3 === 1) { + return ( + { + console.log(`Ref initialized!`) + ref.testMethod() + })} + style={styles.view} + isCyan={i % 2 === 0} + testCallback={callback(() => console.log(`Callback called!`))} + hasBeenCalled={false} + onTouchEnd={() => { + console.log(`Touched View #${i}!`) + }} + /> + ) } else { return ( `import ${name}Config from '../json/${name}Config.json'` + ) + + const registrations = hybridViewNames.map( + (name) => + ` ${name}: {\n name: '${moduleName}${name}',\n config: ${name}Config,\n },` + ) + + const code = ` +${createFileMetadataString(`${viewHostComponentGetterName}.ts`)} +import { + getHostComponent, + type HybridViewMethods, + type HybridViewProps, + type ViewConfig, +} from 'react-native-nitro-modules' + +${imports.join('\n')} + +const REGISTERED_COMPONENTS = { +${registrations.join('\n')} +} as const + +export function get${moduleName}HostComponent< + Props extends HybridViewProps, + Methods extends HybridViewMethods, +>( + name: keyof typeof REGISTERED_COMPONENTS +): ReturnType> { + const component = REGISTERED_COMPONENTS[name] + const config = component.config as ViewConfig + return getHostComponent(component.name, () => config) +} + `.trim() + return { + content: code, + language: 'ts' as Language, + name: `${viewHostComponentGetterName}.ts`, + platform: 'shared', + subdirectory: [], + } +} + +export function generateHybridObjectCreator( + hybridObjectNames: string[] +): SourceFile { + const autolinkedHybridObjects = Object.keys( + NitroConfig.current.getAutolinkedHybridObjects() + ) + hybridObjectNames = hybridObjectNames.filter((name) => + autolinkedHybridObjects.includes(name) + ) + const moduleName = NitroConfig.current.getIosModuleName() + const hybridObjectCreatorName = `create${moduleName}HybridObject` + + const registrations = hybridObjectNames.map( + (name) => ` ${name}: '${moduleName}${name}',` + ) + + const code = ` +${createFileMetadataString(`${hybridObjectCreatorName}.ts`)} +import { NitroModules, type HybridObject } from 'react-native-nitro-modules' + +const REGISTERED_OBJECTS = { +${registrations.join('\n')} +} as const + +export function create${moduleName}HybridObject>( + name: keyof typeof REGISTERED_OBJECTS +): ReturnType> { + return NitroModules.createHybridObject(REGISTERED_OBJECTS[name]) +} + + `.trim() + + return { + content: code, + language: 'ts' as Language, + name: `${hybridObjectCreatorName}.ts`, + platform: 'shared', + subdirectory: [], + } +} diff --git a/packages/nitrogen/src/nitrogen.ts b/packages/nitrogen/src/nitrogen.ts index 3fe66d57a..17c62aed6 100644 --- a/packages/nitrogen/src/nitrogen.ts +++ b/packages/nitrogen/src/nitrogen.ts @@ -26,6 +26,10 @@ import type { Autolinking } from './autolinking/Autolinking.js' import { createGitAttributes } from './createGitAttributes.js' import type { PlatformSpec } from 'react-native-nitro-modules' import { NITROGEN_VERSION } from './config/nitrogenVersion.js' +import { + generateHybridObjectCreator, + generateViewHostComponentGetter, +} from './createTsHelpers.js' interface NitrogenOptions { baseDirectory: string @@ -91,6 +95,8 @@ export async function runNitrogen({ const usedPlatforms: Platform[] = [] const filesAfter: string[] = [] const writtenFiles: SourceFile[] = [] + const hybridViewNames: string[] = [] + const hybridObjectNames: string[] = [] for (const sourceFile of project.getSourceFiles()) { Logger.info(`⏳ Parsing ${sourceFile.getBaseName()}...`) @@ -107,12 +113,15 @@ export async function runNitrogen({ try { let platformSpec: PlatformSpec if (isHybridView(declaration.getType())) { - // Hybrid View Props + // Hybrid View + hybridViewNames.push(typeName) platformSpec = getHybridViewPlatforms(declaration) } else if (extendsHybridObject(declaration.getType(), true)) { - // Hybrid View + // Hybrid Object + hybridObjectNames.push(typeName) platformSpec = getHybridObjectPlatforms(declaration) } else { + // Just a regular interface or type alias continue } @@ -218,6 +227,32 @@ export async function runNitrogen({ } } + // TypeScript utils + if (hybridViewNames.length > 0) { + Logger.info(`📘 Generating TypeScript helper for hybrid views...`) + const viewHelperFile = generateViewHostComponentGetter(hybridViewNames) + const basePath = path.join( + outputDirectory, + viewHelperFile.platform, + viewHelperFile.language + ) + const actualPath = await writeFile(basePath, viewHelperFile) + filesAfter.push(actualPath) + } + + if (hybridObjectNames.length > 0) { + Logger.info(`📘 Generating TypeScript helper for hybrid objects...`) + const hybridObjectHelperFile = + generateHybridObjectCreator(hybridObjectNames) + const basePath = path.join( + outputDirectory, + hybridObjectHelperFile.platform, + hybridObjectHelperFile.language + ) + const actualPath = await writeFile(basePath, hybridObjectHelperFile) + filesAfter.push(actualPath) + } + try { // write a .gitattributes file const markAsGenerated = NitroConfig.current.getGitAttributesGeneratedFlag() diff --git a/packages/nitrogen/src/syntax/c++/CppEnum.ts b/packages/nitrogen/src/syntax/c++/CppEnum.ts index 55ea99a42..6edfb4e50 100644 --- a/packages/nitrogen/src/syntax/c++/CppEnum.ts +++ b/packages/nitrogen/src/syntax/c++/CppEnum.ts @@ -1,7 +1,7 @@ import { NitroConfig } from '../../config/NitroConfig.js' import { indent, toLowerCamelCase } from '../../utils.js' import type { SourceFile } from '../SourceFile.js' -import { createFileMetadataString } from '../helpers.js' +import { createFileMetadataString, getWithModuleName } from '../helpers.js' import type { EnumMember } from '../types/EnumType.js' import { includeNitroHeader } from './includeNitroHeader.js' @@ -67,9 +67,11 @@ switch (integer) { `.trim() } + const fileName = getWithModuleName(NitroConfig.current, typename) + // Create entire C++ file const cppCode = ` -${createFileMetadataString(`${typename}.hpp`)} +${createFileMetadataString(`${fileName}.hpp`)} #pragma once @@ -121,7 +123,7 @@ namespace margelo::nitro { return { content: cppCode, subdirectory: [], - name: `${typename}.hpp`, + name: `${fileName}.hpp`, language: 'c++', platform: 'shared', } diff --git a/packages/nitrogen/src/syntax/c++/CppHybridObject.ts b/packages/nitrogen/src/syntax/c++/CppHybridObject.ts index 2256b0561..3a28e894f 100644 --- a/packages/nitrogen/src/syntax/c++/CppHybridObject.ts +++ b/packages/nitrogen/src/syntax/c++/CppHybridObject.ts @@ -1,5 +1,9 @@ import type { SourceFile } from '../SourceFile.js' -import { createFileMetadataString, isNotDuplicate } from '../helpers.js' +import { + createFileMetadataString, + getWithModuleName, + isNotDuplicate, +} from '../helpers.js' import { indent } from '../../utils.js' import type { HybridObjectSpec } from '../HybridObjectSpec.js' import { includeHeader, includeNitroHeader } from './includeNitroHeader.js' @@ -43,9 +47,12 @@ export function createCppHybridObject(spec: HybridObjectSpec): SourceFile[] { bases.push(`public virtual ${fullName}`) } + const hybridTSpecName = getWithModuleName(spec.config, name.HybridTSpec) + const registeredName = getWithModuleName(spec.config, name.T) + // Generate the full header / code const cppHeaderCode = ` -${createFileMetadataString(`${name.HybridTSpec}.hpp`)} +${createFileMetadataString(`${hybridTSpecName}.hpp`)} #pragma once @@ -94,7 +101,7 @@ namespace ${cxxNamespace} { protected: // Tag for logging - static constexpr auto TAG = "${spec.name}"; + static constexpr auto TAG = "${registeredName}"; }; } // namespace ${cxxNamespace} @@ -132,9 +139,9 @@ namespace ${cxxNamespace} { } const cppBodyCode = ` -${createFileMetadataString(`${name.HybridTSpec}.cpp`)} +${createFileMetadataString(`${hybridTSpecName}.cpp`)} -#include "${name.HybridTSpec}.hpp" +#include "${hybridTSpecName}.hpp" namespace ${cxxNamespace} { @@ -153,14 +160,14 @@ namespace ${cxxNamespace} { const files: SourceFile[] = [] files.push({ content: cppHeaderCode, - name: `${name.HybridTSpec}.hpp`, + name: `${hybridTSpecName}.hpp`, subdirectory: [], language: 'c++', platform: 'shared', }) files.push({ content: cppBodyCode, - name: `${name.HybridTSpec}.cpp`, + name: `${hybridTSpecName}.cpp`, subdirectory: [], language: 'c++', platform: 'shared', diff --git a/packages/nitrogen/src/syntax/c++/CppHybridObjectRegistration.ts b/packages/nitrogen/src/syntax/c++/CppHybridObjectRegistration.ts index dcdea6583..512d6c700 100644 --- a/packages/nitrogen/src/syntax/c++/CppHybridObjectRegistration.ts +++ b/packages/nitrogen/src/syntax/c++/CppHybridObjectRegistration.ts @@ -1,3 +1,5 @@ +import { NitroConfig } from '../../config/NitroConfig.js' +import { getWithModuleName } from '../helpers.js' import type { SourceImport } from '../SourceFile.js' interface Props { @@ -20,13 +22,17 @@ export function createCppHybridObjectRegistration({ hybridObjectName, cppClassName, }: Props): CppHybridObjectRegistration { + const registeredName = getWithModuleName( + NitroConfig.current, + hybridObjectName + ) return { requiredImports: [ { name: `${cppClassName}.hpp`, language: 'c++', space: 'user' }, ], cppCode: ` HybridObjectRegistry::registerHybridObjectConstructor( - "${hybridObjectName}", + "${registeredName}", []() -> std::shared_ptr { static_assert(std::is_default_constructible_v<${cppClassName}>, "The HybridObject \\"${cppClassName}\\" is not default-constructible! " diff --git a/packages/nitrogen/src/syntax/c++/CppStruct.ts b/packages/nitrogen/src/syntax/c++/CppStruct.ts index 586066827..d79d5bf0b 100644 --- a/packages/nitrogen/src/syntax/c++/CppStruct.ts +++ b/packages/nitrogen/src/syntax/c++/CppStruct.ts @@ -1,6 +1,10 @@ import type { FileWithReferencedTypes } from '../SourceFile.js' import { indent } from '../../utils.js' -import { createFileMetadataString, isNotDuplicate } from '../helpers.js' +import { + createFileMetadataString, + getWithModuleName, + isNotDuplicate, +} from '../helpers.js' import type { NamedType } from '../types/Type.js' import { includeHeader, includeNitroHeader } from './includeNitroHeader.js' import { NitroConfig } from '../../config/NitroConfig.js' @@ -74,8 +78,10 @@ export function createCppStruct( .filter(isNotDuplicate) const cxxNamespace = NitroConfig.current.getCxxNamespace('c++') + const fileName = getWithModuleName(NitroConfig.current, typename) + const cppCode = ` -${createFileMetadataString(`${typename}.hpp`)} +${createFileMetadataString(`${fileName}.hpp`)} #pragma once @@ -140,7 +146,7 @@ namespace margelo::nitro { ` return { content: cppCode, - name: `${typename}.hpp`, + name: `${fileName}.hpp`, subdirectory: [], language: 'c++', referencedTypes: properties, diff --git a/packages/nitrogen/src/syntax/c++/CppUnion.ts b/packages/nitrogen/src/syntax/c++/CppUnion.ts index 7e8efd37e..657528edf 100644 --- a/packages/nitrogen/src/syntax/c++/CppUnion.ts +++ b/packages/nitrogen/src/syntax/c++/CppUnion.ts @@ -1,5 +1,5 @@ import type { SourceFile } from '../SourceFile.js' -import { createFileMetadataString } from './../helpers.js' +import { createFileMetadataString, getWithModuleName } from './../helpers.js' import { indent, toLowerCamelCase } from '../../utils.js' import type { EnumMember } from '../types/EnumType.js' import { includeNitroHeader } from './includeNitroHeader.js' @@ -38,8 +38,10 @@ export function createCppUnion( .join('\n') const cxxNamespace = NitroConfig.current.getCxxNamespace('c++') + const fileName = getWithModuleName(NitroConfig.current, typename) + const cppCode = ` -${createFileMetadataString(`${typename}.hpp`)} +${createFileMetadataString(`${fileName}.hpp`)} #pragma once @@ -97,7 +99,7 @@ namespace margelo::nitro { ` return { content: cppCode, - name: `${typename}.hpp`, + name: `${fileName}.hpp`, subdirectory: [], language: 'c++', platform: 'shared', diff --git a/packages/nitrogen/src/syntax/helpers.ts b/packages/nitrogen/src/syntax/helpers.ts index 78c2541ce..beac2a5c4 100644 --- a/packages/nitrogen/src/syntax/helpers.ts +++ b/packages/nitrogen/src/syntax/helpers.ts @@ -4,6 +4,7 @@ import type { Type } from './types/Type.js' import { getTypeAs } from './types/getTypeAs.js' import { OptionalType } from './types/OptionalType.js' import { ArrayType } from './types/ArrayType.js' +import { NitroConfig } from '../config/NitroConfig.js' type Comment = '///' | '#' @@ -21,6 +22,13 @@ ${comment} `.trim() } +export function getWithModuleName( + sourceConfig: NitroConfig, + originalName: T +): `${string}${T}` { + return `${sourceConfig.getIosModuleName()}${originalName}` +} + export function isFunction(type: Type): boolean { switch (type.kind) { case 'function': @@ -173,3 +181,24 @@ export function getRelativeDirectory(file: SourceFile): string { export function getRelativeDirectoryGenerated(...subpath: string[]): string { return path.join('..', 'nitrogen', 'generated', ...subpath) } + +/** + * Some headers like `NitroModules/Result.hpp` cause an error when included before own module headers. + */ +export function sortIosIncludesWithOwnFirst(includes: string[]): string[] { + const moduleName = NitroConfig.current.getIosModuleName() + const ownIncludes: string[] = [] + const otherIncludes: string[] = [] + + for (const include of includes) { + if (include.startsWith(`#include <${moduleName}/`)) { + ownIncludes.push(include) + } else { + otherIncludes.push(include) + } + } + + ownIncludes.sort() + otherIncludes.sort() + return [...ownIncludes, ...otherIncludes] +} diff --git a/packages/nitrogen/src/syntax/kotlin/FbjniHybridObject.ts b/packages/nitrogen/src/syntax/kotlin/FbjniHybridObject.ts index 7332d6131..6a585027d 100644 --- a/packages/nitrogen/src/syntax/kotlin/FbjniHybridObject.ts +++ b/packages/nitrogen/src/syntax/kotlin/FbjniHybridObject.ts @@ -3,7 +3,11 @@ import { getForwardDeclaration } from '../c++/getForwardDeclaration.js' import { includeHeader } from '../c++/includeNitroHeader.js' import { getAllTypes } from '../getAllTypes.js' import { getHybridObjectName } from '../getHybridObjectName.js' -import { createFileMetadataString, isNotDuplicate } from '../helpers.js' +import { + createFileMetadataString, + getWithModuleName, + isNotDuplicate, +} from '../helpers.js' import type { HybridObjectSpec } from '../HybridObjectSpec.js' import { Method } from '../Method.js' import type { Property } from '../Property.js' @@ -81,6 +85,8 @@ export function createFbjniHybridObject(spec: HybridObjectSpec): SourceFile[] { }) } + const hybridTSpecName = getWithModuleName(spec.config, name.HybridTSpec) + const cppHeaderCode = ` ${createFileMetadataString(`${name.HybridTSpec}.hpp`)} @@ -88,7 +94,7 @@ ${createFileMetadataString(`${name.HybridTSpec}.hpp`)} #include #include -#include "${name.HybridTSpec}.hpp" +#include "${hybridTSpecName}.hpp" ${cppImports .map((i) => i.forwardDeclaration) diff --git a/packages/nitrogen/src/syntax/kotlin/KotlinHybridObject.ts b/packages/nitrogen/src/syntax/kotlin/KotlinHybridObject.ts index b72834011..64f4f5424 100644 --- a/packages/nitrogen/src/syntax/kotlin/KotlinHybridObject.ts +++ b/packages/nitrogen/src/syntax/kotlin/KotlinHybridObject.ts @@ -2,7 +2,11 @@ import { indent } from '../../utils.js' import { createKotlinHybridViewManager } from '../../views/kotlin/KotlinHybridViewManager.js' import { getAllTypes } from '../getAllTypes.js' import { getHybridObjectName } from '../getHybridObjectName.js' -import { createFileMetadataString, isNotDuplicate } from '../helpers.js' +import { + createFileMetadataString, + getWithModuleName, + isNotDuplicate, +} from '../helpers.js' import type { HybridObjectSpec } from '../HybridObjectSpec.js' import { Method } from '../Method.js' import { Property } from '../Property.js' @@ -60,6 +64,8 @@ export function createKotlinHybridObject(spec: HybridObjectSpec): SourceFile[] { const javaPackage = spec.config.getAndroidPackage('java/kotlin') + const registeredName = getWithModuleName(spec.config, name.T) + // 1. Create Kotlin abstract class definition const abstractClassCode = ` ${createFileMetadataString(`${name.HybridTSpec}.kt`)} @@ -91,7 +97,7 @@ abstract class ${name.HybridTSpec}: ${kotlinBase}() { // Default implementation of \`HybridObject.toString()\` override fun toString(): String { - return "[HybridObject ${name.T}]" + return "[HybridObject ${registeredName}]" } // C++ backing class diff --git a/packages/nitrogen/src/syntax/kotlin/KotlinHybridObjectRegistration.ts b/packages/nitrogen/src/syntax/kotlin/KotlinHybridObjectRegistration.ts index d6b7fee75..ec605faf3 100644 --- a/packages/nitrogen/src/syntax/kotlin/KotlinHybridObjectRegistration.ts +++ b/packages/nitrogen/src/syntax/kotlin/KotlinHybridObjectRegistration.ts @@ -1,5 +1,6 @@ import { NitroConfig } from '../../config/NitroConfig.js' import { getHybridObjectName } from '../getHybridObjectName.js' +import { getWithModuleName } from '../helpers.js' import type { SourceImport } from '../SourceFile.js' interface Props { @@ -28,6 +29,10 @@ export function createJNIHybridObjectRegistration({ 'c++/jni', jniClassName ) + const registeredName = getWithModuleName( + NitroConfig.current, + hybridObjectName + ) return { requiredImports: [ @@ -50,7 +55,7 @@ struct ${JHybridTSpec}Impl: public jni::JavaClass<${JHybridTSpec}Impl, ${JHybrid `.trim(), cppCode: ` HybridObjectRegistry::registerHybridObjectConstructor( - "${hybridObjectName}", + "${registeredName}", []() -> std::shared_ptr { return ${JHybridTSpec}Impl::create(); } diff --git a/packages/nitrogen/src/syntax/swift/SwiftCxxTypeHelper.ts b/packages/nitrogen/src/syntax/swift/SwiftCxxTypeHelper.ts index 117564908..d3be964a4 100644 --- a/packages/nitrogen/src/syntax/swift/SwiftCxxTypeHelper.ts +++ b/packages/nitrogen/src/syntax/swift/SwiftCxxTypeHelper.ts @@ -1,4 +1,8 @@ -import { escapeCppName, toReferenceType } from '../helpers.js' +import { + escapeCppName, + getWithModuleName, + toReferenceType, +} from '../helpers.js' import type { SourceImport } from '../SourceFile.js' import { VariantType } from '../types/VariantType.js' import { ArrayType } from '../types/ArrayType.js' @@ -87,10 +91,14 @@ function createCxxHybridObjectSwiftHelper( const includes: SourceImport[] = [] if (!type.sourceConfig.isExternalConfig) { // we are including our Swift helper internally. this is a private header so we can include just fine. + const hybridTSpecSwiftName = getWithModuleName( + type.sourceConfig, + HybridTSpecSwift + ) includes.push({ language: 'c++', // Hybrid Object Swift C++ class wrapper - name: `${HybridTSpecSwift}.hpp`, + name: `${hybridTSpecSwiftName}.hpp`, space: 'user', }) } else { diff --git a/packages/nitrogen/src/syntax/swift/SwiftHybridObject.ts b/packages/nitrogen/src/syntax/swift/SwiftHybridObject.ts index 1a05a7714..b903ef528 100644 --- a/packages/nitrogen/src/syntax/swift/SwiftHybridObject.ts +++ b/packages/nitrogen/src/syntax/swift/SwiftHybridObject.ts @@ -1,7 +1,11 @@ import { indent } from '../../utils.js' import { createSwiftHybridViewManager } from '../../views/swift/SwiftHybridViewManager.js' import { getHybridObjectName } from '../getHybridObjectName.js' -import { createFileMetadataString, isNotDuplicate } from '../helpers.js' +import { + createFileMetadataString, + getWithModuleName, + isNotDuplicate, +} from '../helpers.js' import type { HybridObjectSpec } from '../HybridObjectSpec.js' import type { SourceFile } from '../SourceFile.js' import { HybridObjectType } from '../types/HybridObjectType.js' @@ -67,6 +71,8 @@ public ${hasBaseClass ? 'override func' : 'func'} getCxxWrapper() -> ${name.Hybr requiredImports.push('import NitroModules') const imports = requiredImports.filter(isNotDuplicate) + const registeredName = getWithModuleName(spec.config, name.T) + const protocolCode = ` ${createFileMetadataString(`${protocolName}.swift`)} @@ -84,7 +90,7 @@ public protocol ${protocolName}_protocol: ${protocolBaseClasses.join(', ')} { public extension ${protocolName}_protocol { /// Default implementation of \`\`HybridObject.toString\`\` func toString() -> String { - return "[HybridObject ${name.T}]" + return "[HybridObject ${registeredName}]" } } diff --git a/packages/nitrogen/src/syntax/swift/SwiftHybridObjectBridge.ts b/packages/nitrogen/src/syntax/swift/SwiftHybridObjectBridge.ts index bb28038e2..bb5b55319 100644 --- a/packages/nitrogen/src/syntax/swift/SwiftHybridObjectBridge.ts +++ b/packages/nitrogen/src/syntax/swift/SwiftHybridObjectBridge.ts @@ -6,6 +6,7 @@ import type { Method } from '../Method.js' import { createFileMetadataString, escapeCppName, + getWithModuleName, isNotDuplicate, } from '../helpers.js' import type { SourceFile } from '../SourceFile.js' @@ -354,7 +355,7 @@ if (__result.hasError()) [[unlikely]] { cppBaseCtorCalls.push(`${baseName.HybridTSpecSwift}(swiftPart)`) extraImports.push({ language: 'c++', - name: `${baseName.HybridTSpecSwift}.hpp`, + name: `${getWithModuleName(spec.config, baseName.HybridTSpecSwift)}.hpp`, space: 'user', forwardDeclaration: getForwardDeclaration( 'class', @@ -372,13 +373,19 @@ if (__result.hasError()) [[unlikely]] { .map((i) => includeHeader(i)) .filter(isNotDuplicate) + const hybridTSpecSwiftName = getWithModuleName( + spec.config, + name.HybridTSpecSwift + ) + const hybridTSpecName = getWithModuleName(spec.config, name.HybridTSpec) + // TODO: Remove forward declaration once Swift fixes the wrong order in generated -Swift.h headers! const cppHybridObjectCode = ` -${createFileMetadataString(`${name.HybridTSpecSwift}.hpp`)} +${createFileMetadataString(`${hybridTSpecSwiftName}.hpp`)} #pragma once -#include "${name.HybridTSpec}.hpp" +#include "${hybridTSpecName}.hpp" ${getForwardDeclaration('class', name.HybridTSpecCxx, iosModuleName)} @@ -445,9 +452,9 @@ namespace ${cxxNamespace} { } // namespace ${cxxNamespace} ` const cppHybridObjectCodeCpp = ` -${createFileMetadataString(`${name.HybridTSpecSwift}.cpp`)} +${createFileMetadataString(`${hybridTSpecSwiftName}.cpp`)} -#include "${name.HybridTSpecSwift}.hpp" +#include "${hybridTSpecSwiftName}.hpp" namespace ${cxxNamespace} { } // namespace ${cxxNamespace} @@ -465,14 +472,14 @@ namespace ${cxxNamespace} { files.push({ content: cppHybridObjectCode, language: 'c++', - name: `${name.HybridTSpecSwift}.hpp`, + name: `${hybridTSpecSwiftName}.hpp`, subdirectory: [], platform: 'ios', }) files.push({ content: cppHybridObjectCodeCpp, language: 'c++', - name: `${name.HybridTSpecSwift}.cpp`, + name: `${hybridTSpecSwiftName}.cpp`, subdirectory: [], platform: 'ios', }) diff --git a/packages/nitrogen/src/syntax/swift/SwiftHybridObjectRegistration.ts b/packages/nitrogen/src/syntax/swift/SwiftHybridObjectRegistration.ts index cfbb53e37..cd70a8194 100644 --- a/packages/nitrogen/src/syntax/swift/SwiftHybridObjectRegistration.ts +++ b/packages/nitrogen/src/syntax/swift/SwiftHybridObjectRegistration.ts @@ -1,6 +1,7 @@ import { NitroConfig } from '../../config/NitroConfig.js' import { indent } from '../../utils.js' import { getHybridObjectName } from '../getHybridObjectName.js' +import { getWithModuleName } from '../helpers.js' import type { SourceImport } from '../SourceFile.js' import { HybridObjectType } from '../types/HybridObjectType.js' import { SwiftCxxBridgedType } from './SwiftCxxBridgedType.js' @@ -45,6 +46,14 @@ export function createSwiftHybridObjectRegistration({ swiftClassName, }: Props): SwiftHybridObjectRegistration { const { HybridTSpecSwift } = getHybridObjectName(hybridObjectName) + const hybridTSpecSwiftName = getWithModuleName( + NitroConfig.current, + HybridTSpecSwift + ) + const registeredName = getWithModuleName( + NitroConfig.current, + hybridObjectName + ) const type = new HybridObjectType( hybridObjectName, @@ -66,11 +75,11 @@ public static func is${hybridObjectName}Recyclable() -> Bool { } `.trim(), requiredImports: [ - { name: `${HybridTSpecSwift}.hpp`, language: 'c++', space: 'user' }, + { name: `${hybridTSpecSwiftName}.hpp`, language: 'c++', space: 'user' }, ], cppCode: ` HybridObjectRegistry::registerHybridObjectConstructor( - "${hybridObjectName}", + "${registeredName}", []() -> std::shared_ptr { ${type.getCode('c++')} hybridObject = ${getHybridObjectConstructorCall(hybridObjectName)} return hybridObject; diff --git a/packages/nitrogen/src/syntax/types/HybridObjectType.ts b/packages/nitrogen/src/syntax/types/HybridObjectType.ts index ceeed0f1e..1e9bba8c9 100644 --- a/packages/nitrogen/src/syntax/types/HybridObjectType.ts +++ b/packages/nitrogen/src/syntax/types/HybridObjectType.ts @@ -2,6 +2,7 @@ import { type NitroConfig } from '../../config/NitroConfig.js' import type { Language } from '../../getPlatformSpecs.js' import { getForwardDeclaration } from '../c++/getForwardDeclaration.js' import { getHybridObjectName } from '../getHybridObjectName.js' +import { getWithModuleName } from '../helpers.js' import type { HybridObjectSpec } from '../HybridObjectSpec.js' import type { SourceFile, SourceImport } from '../SourceFile.js' import type { GetCodeOptions, Type, TypeKind } from './Type.js' @@ -138,6 +139,11 @@ export class HybridObjectType implements Type { const cxxNamespace = this.sourceConfig.getCxxNamespace('c++') const imports: SourceImport[] = [] + const hybridTSpecName = getWithModuleName( + this.sourceConfig, + name.HybridTSpec + ) + switch (language) { case 'c++': { imports.push({ @@ -148,7 +154,7 @@ export class HybridObjectType implements Type { if (this.sourceConfig.isExternalConfig) { const cxxImport = this.getExternalCxxImportName() imports.push({ - name: `${cxxImport}/${name.HybridTSpec}.hpp`, + name: `${cxxImport}/${hybridTSpecName}.hpp`, forwardDeclaration: getForwardDeclaration( 'class', name.HybridTSpec, @@ -159,7 +165,7 @@ export class HybridObjectType implements Type { }) } else { imports.push({ - name: `${name.HybridTSpec}.hpp`, + name: `${hybridTSpecName}.hpp`, forwardDeclaration: getForwardDeclaration( 'class', name.HybridTSpec, diff --git a/packages/nitrogen/src/views/CppHybridViewComponent.ts b/packages/nitrogen/src/views/CppHybridViewComponent.ts index 55ada8153..e12792f2e 100644 --- a/packages/nitrogen/src/views/CppHybridViewComponent.ts +++ b/packages/nitrogen/src/views/CppHybridViewComponent.ts @@ -4,6 +4,7 @@ import { createIndentation, indent } from '../utils.js' import { createFileMetadataString, escapeCppName, + getWithModuleName, isFunction, isNotDuplicate, } from '../syntax/helpers.js' @@ -23,6 +24,7 @@ interface ViewComponentNames { nameVariable: `${string}ComponentName` shadowNodeClassName: `${string}ShadowNode` descriptorClassName: `${string}ComponentDescriptor` + uiClassName: string component: `${string}Component` manager: `${string}Manager` } @@ -37,7 +39,9 @@ export function getViewComponentNames( nameVariable: `${name.HybridT}ComponentName`, shadowNodeClassName: `${name.HybridT}ShadowNode`, descriptorClassName: `${name.HybridT}ComponentDescriptor`, - component: `${name.HybridT}Component`, + uiClassName: getWithModuleName(spec.config, name.T), + // Component name must be unique to avoid conflicts with other modules + component: getWithModuleName(spec.config, `${name.HybridT}Component`), manager: `${name.HybridT}Manager`, } } @@ -59,13 +63,14 @@ export function createViewComponentShadowNodeFiles( ) } - const { T, HybridT } = getHybridObjectName(spec.name) + const { HybridT } = getHybridObjectName(spec.name) const { propsClassName, stateClassName, nameVariable, shadowNodeClassName, descriptorClassName, + uiClassName, component, } = getViewComponentNames(spec) @@ -223,6 +228,7 @@ ${name}([&]() -> CachedProp<${type}> { const ctorIndent = createIndentation(propsClassName.length * 2) const descriptorIndent = createIndentation(descriptorClassName.length) + const componentCode = ` ${createFileMetadataString(`${component}.cpp`)} @@ -241,7 +247,7 @@ ${createFileMetadataString(`${component}.cpp`)} namespace ${namespace} { - extern const char ${nameVariable}[] = "${T}"; + extern const char ${nameVariable}[] = "${uiClassName}"; ${propsClassName}::${propsClassName}(const react::PropsParserContext& context, ${ctorIndent} const ${propsClassName}& sourceProps, diff --git a/packages/nitrogen/src/views/createHostComponentJs.ts b/packages/nitrogen/src/views/createHostComponentJs.ts index 6a8c3cded..6d048f98e 100644 --- a/packages/nitrogen/src/views/createHostComponentJs.ts +++ b/packages/nitrogen/src/views/createHostComponentJs.ts @@ -3,16 +3,18 @@ import type { HybridObjectSpec } from '../syntax/HybridObjectSpec.js' import type { SourceFile } from '../syntax/SourceFile.js' import { getHybridObjectName } from '../syntax/getHybridObjectName.js' import { indent } from '../utils.js' +import { getViewComponentNames } from './CppHybridViewComponent.js' export function createHostComponentJs(spec: HybridObjectSpec): SourceFile[] { const { T } = getHybridObjectName(spec.name) + const { uiClassName } = getViewComponentNames(spec) const props = spec.properties.map((p) => `"${p.name}": true`) props.push(`"hybridRef": true`) const code = ` { - "uiViewClassName": "${T}", + "uiViewClassName": "${uiClassName}", "supportsRawText": false, "bubblingEventTypes": {}, "directEventTypes": {}, diff --git a/packages/nitrogen/src/views/kotlin/KotlinHybridViewManager.ts b/packages/nitrogen/src/views/kotlin/KotlinHybridViewManager.ts index a27718115..4b8f4f3a2 100644 --- a/packages/nitrogen/src/views/kotlin/KotlinHybridViewManager.ts +++ b/packages/nitrogen/src/views/kotlin/KotlinHybridViewManager.ts @@ -26,6 +26,7 @@ export function createKotlinHybridViewManager( component, propsClassName, descriptorClassName, + uiClassName, } = getViewComponentNames(spec) const stateUpdaterName = `${stateClassName}Updater` const implementation = spec.config.getAndroidAutolinkedImplementation( @@ -64,7 +65,7 @@ public class ${manager}: SimpleViewManager() { } override fun getName(): String { - return "${spec.name}" + return "${uiClassName}" } override fun createViewInstance(reactContext: ThemedReactContext): View { diff --git a/packages/nitrogen/src/views/swift/SwiftHybridViewManager.ts b/packages/nitrogen/src/views/swift/SwiftHybridViewManager.ts index 68c579ffb..5d914121a 100644 --- a/packages/nitrogen/src/views/swift/SwiftHybridViewManager.ts +++ b/packages/nitrogen/src/views/swift/SwiftHybridViewManager.ts @@ -7,6 +7,7 @@ import { import { createFileMetadataString, escapeCppName, + getWithModuleName, } from '../../syntax/helpers.js' import { getUmbrellaHeaderName } from '../../autolinking/ios/createSwiftUmbrellaHeader.js' import { getHybridObjectName } from '../../syntax/getHybridObjectName.js' @@ -52,6 +53,8 @@ if (newViewProps.${name}.isDirty) { `.trim() }) + const hybridTSpecSwiftName = getWithModuleName(spec.config, HybridTSpecSwift) + const mmFile = ` ${createFileMetadataString(`${component}.mm`)} @@ -64,7 +67,7 @@ ${createFileMetadataString(`${component}.mm`)} #import #import -#import "${HybridTSpecSwift}.hpp" +#import "${hybridTSpecSwiftName}.hpp" #import "${getUmbrellaHeaderName()}" #if __has_include() diff --git a/packages/react-native-nitro-test-external/android/src/main/java/com/margelo/nitro/test/external/HybridBase.kt b/packages/react-native-nitro-test-external/android/src/main/java/com/margelo/nitro/test/external/HybridBase.kt new file mode 100644 index 000000000..586973322 --- /dev/null +++ b/packages/react-native-nitro-test-external/android/src/main/java/com/margelo/nitro/test/external/HybridBase.kt @@ -0,0 +1,10 @@ +package com.margelo.nitro.test.external + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip + +@Keep +@DoNotStrip +class HybridBase : HybridBaseSpec() { + override val abc: Double = 10.0 +} diff --git a/packages/react-native-nitro-test-external/android/src/main/java/com/margelo/nitro/test/external/HybridBlaBla.kt b/packages/react-native-nitro-test-external/android/src/main/java/com/margelo/nitro/test/external/HybridBlaBla.kt new file mode 100644 index 000000000..58ed69ede --- /dev/null +++ b/packages/react-native-nitro-test-external/android/src/main/java/com/margelo/nitro/test/external/HybridBlaBla.kt @@ -0,0 +1,10 @@ +package com.margelo.nitro.test.external + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip + +@Keep +@DoNotStrip +class HybridBlaBla : HybridBlaBlaSpec() { + override var base: HybridBaseSpec? = HybridBase() +} diff --git a/packages/react-native-nitro-test-external/android/src/main/java/com/margelo/nitro/test/external/HybridTestView.kt b/packages/react-native-nitro-test-external/android/src/main/java/com/margelo/nitro/test/external/HybridTestView.kt new file mode 100644 index 000000000..7b24025ca --- /dev/null +++ b/packages/react-native-nitro-test-external/android/src/main/java/com/margelo/nitro/test/external/HybridTestView.kt @@ -0,0 +1,32 @@ +package com.margelo.nitro.test.external + +import android.graphics.Color +import android.view.View +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip +import com.facebook.react.uimanager.ThemedReactContext + +@Keep +@DoNotStrip +class HybridTestView( + val context: ThemedReactContext, +) : HybridTestViewSpec() { + // View + override val view: View = View(context) + + // Props + override var isCyan: Boolean = false + set(value) { + field = value + val color = if (value) Color.CYAN else Color.BLUE + view.setBackgroundColor(color) + } + override var hasBeenCalled: Boolean = false + override var testCallback: () -> Unit = {} + + // Methods + override fun testMethod() { + hasBeenCalled = true + testCallback() + } +} diff --git a/packages/react-native-nitro-test-external/android/src/main/java/com/margelo/nitro/test/external/NitroTestExternalPackage.kt b/packages/react-native-nitro-test-external/android/src/main/java/com/margelo/nitro/test/external/NitroTestExternalPackage.kt index fff28ddfe..58aff4877 100644 --- a/packages/react-native-nitro-test-external/android/src/main/java/com/margelo/nitro/test/external/NitroTestExternalPackage.kt +++ b/packages/react-native-nitro-test-external/android/src/main/java/com/margelo/nitro/test/external/NitroTestExternalPackage.kt @@ -4,6 +4,8 @@ import com.facebook.react.BaseReactPackage import com.facebook.react.bridge.NativeModule import com.facebook.react.bridge.ReactApplicationContext import com.facebook.react.module.model.ReactModuleInfoProvider +import com.facebook.react.uimanager.ViewManager +import com.margelo.nitro.test.external.views.HybridTestViewManager public class NitroTestExternalPackage : BaseReactPackage() { override fun getModule( @@ -13,6 +15,12 @@ public class NitroTestExternalPackage : BaseReactPackage() { override fun getReactModuleInfoProvider(): ReactModuleInfoProvider = ReactModuleInfoProvider { HashMap() } + override fun createViewManagers(reactContext: ReactApplicationContext): List> { + val viewManagers = ArrayList>() + viewManagers.add(HybridTestViewManager()) + return viewManagers + } + companion object { init { NitroTestExternalOnLoad.initializeNative() diff --git a/packages/react-native-nitro-test-external/ios/HybridBase.swift b/packages/react-native-nitro-test-external/ios/HybridBase.swift new file mode 100644 index 000000000..e64cbee58 --- /dev/null +++ b/packages/react-native-nitro-test-external/ios/HybridBase.swift @@ -0,0 +1,12 @@ +// +// HybridSomeExternalObject +// NitroTestExternal +// +// Created by Marc Rousavy on 14.08.25. +// + +import NitroModules + +class HybridBase: HybridBaseSpec { + var abc: Double = 10 +} diff --git a/packages/react-native-nitro-test-external/ios/HybridBlaBla.swift b/packages/react-native-nitro-test-external/ios/HybridBlaBla.swift new file mode 100644 index 000000000..312114cb6 --- /dev/null +++ b/packages/react-native-nitro-test-external/ios/HybridBlaBla.swift @@ -0,0 +1,12 @@ +// +// HybridSomeExternalObject +// NitroTestExternal +// +// Created by Marc Rousavy on 14.08.25. +// + +import NitroModules + +class HybridBlaBla: HybridBlaBlaSpec { + var base: HybridBaseSpec? = HybridBase() +} diff --git a/packages/react-native-nitro-test-external/ios/HybridTestView.swift b/packages/react-native-nitro-test-external/ios/HybridTestView.swift new file mode 100644 index 000000000..45bb2d34c --- /dev/null +++ b/packages/react-native-nitro-test-external/ios/HybridTestView.swift @@ -0,0 +1,29 @@ +// +// HybridTestView.swift +// react-native-nitro-test +// +// Created by Marc Rousavy on 03.10.24. +// + +import NitroModules +import UIKit + +class HybridTestView: HybridTestViewSpec { + // UIView + var view: UIView = UIView() + + // Props + var isCyan: Bool = false { + didSet { + view.backgroundColor = isCyan ? .systemCyan : .systemBlue + } + } + var hasBeenCalled: Bool = false + var testCallback: () -> Void = {} + + // Methods + func testMethod() throws { + hasBeenCalled = true + testCallback() + } +} diff --git a/packages/react-native-nitro-test-external/nitro.json b/packages/react-native-nitro-test-external/nitro.json index 62fe81c40..bc405a672 100644 --- a/packages/react-native-nitro-test-external/nitro.json +++ b/packages/react-native-nitro-test-external/nitro.json @@ -18,6 +18,36 @@ "language": "kotlin", "implementationClassName": "HybridSomeExternalObject" } + }, + "BlaBla": { + "ios": { + "language": "swift", + "implementationClassName": "HybridBlaBla" + }, + "android": { + "language": "kotlin", + "implementationClassName": "HybridBlaBla" + } + }, + "Base": { + "ios": { + "language": "swift", + "implementationClassName": "HybridBase" + }, + "android": { + "language": "kotlin", + "implementationClassName": "HybridBase" + } + }, + "TestView": { + "ios": { + "language": "swift", + "implementationClassName": "HybridTestView" + }, + "android": { + "language": "kotlin", + "implementationClassName": "HybridTestView" + } } }, "ignorePaths": [ diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/NitroTestExternal+autolinking.cmake b/packages/react-native-nitro-test-external/nitrogen/generated/android/NitroTestExternal+autolinking.cmake index 79c9340a2..e03935509 100644 --- a/packages/react-native-nitro-test-external/nitrogen/generated/android/NitroTestExternal+autolinking.cmake +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/NitroTestExternal+autolinking.cmake @@ -33,9 +33,17 @@ target_sources( # Autolinking Setup ../nitrogen/generated/android/NitroTestExternalOnLoad.cpp # Shared Nitrogen C++ sources - ../nitrogen/generated/shared/c++/HybridSomeExternalObjectSpec.cpp + ../nitrogen/generated/shared/c++/NitroTestExternalHybridSomeExternalObjectSpec.cpp + ../nitrogen/generated/shared/c++/NitroTestExternalHybridBaseSpec.cpp + ../nitrogen/generated/shared/c++/NitroTestExternalHybridBlaBlaSpec.cpp + ../nitrogen/generated/shared/c++/NitroTestExternalHybridTestViewSpec.cpp + ../nitrogen/generated/shared/c++/views/NitroTestExternalHybridTestViewComponent.cpp # Android-specific Nitrogen C++ sources ../nitrogen/generated/android/c++/JHybridSomeExternalObjectSpec.cpp + ../nitrogen/generated/android/c++/JHybridBaseSpec.cpp + ../nitrogen/generated/android/c++/JHybridBlaBlaSpec.cpp + ../nitrogen/generated/android/c++/JHybridTestViewSpec.cpp + ../nitrogen/generated/android/c++/views/JHybridTestViewStateUpdater.cpp ) # From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/NitroTestExternalOnLoad.cpp b/packages/react-native-nitro-test-external/nitrogen/generated/android/NitroTestExternalOnLoad.cpp index 53a6a8167..fa0c56211 100644 --- a/packages/react-native-nitro-test-external/nitrogen/generated/android/NitroTestExternalOnLoad.cpp +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/NitroTestExternalOnLoad.cpp @@ -16,6 +16,11 @@ #include #include "JHybridSomeExternalObjectSpec.hpp" +#include "JHybridBaseSpec.hpp" +#include "JHybridBlaBlaSpec.hpp" +#include "JHybridTestViewSpec.hpp" +#include "JFunc_void.hpp" +#include "views/JHybridTestViewStateUpdater.hpp" #include namespace margelo::nitro::test::external { @@ -34,6 +39,30 @@ struct JHybridSomeExternalObjectSpecImpl: public jni::JavaClassgetJHybridSomeExternalObjectSpec(); } }; +struct JHybridBlaBlaSpecImpl: public jni::JavaClass { + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/external/HybridBlaBla;"; + static std::shared_ptr create() { + static const auto constructorFn = javaClassStatic()->getConstructor(); + jni::local_ref javaPart = javaClassStatic()->newObject(constructorFn); + return javaPart->getJHybridBlaBlaSpec(); + } +}; +struct JHybridBaseSpecImpl: public jni::JavaClass { + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/external/HybridBase;"; + static std::shared_ptr create() { + static const auto constructorFn = javaClassStatic()->getConstructor(); + jni::local_ref javaPart = javaClassStatic()->newObject(constructorFn); + return javaPart->getJHybridBaseSpec(); + } +}; +struct JHybridTestViewSpecImpl: public jni::JavaClass { + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/external/HybridTestView;"; + static std::shared_ptr create() { + static const auto constructorFn = javaClassStatic()->getConstructor(); + jni::local_ref javaPart = javaClassStatic()->newObject(constructorFn); + return javaPart->getJHybridTestViewSpec(); + } +}; void registerAllNatives() { using namespace margelo::nitro; @@ -41,14 +70,37 @@ void registerAllNatives() { // Register native JNI methods margelo::nitro::test::external::JHybridSomeExternalObjectSpec::CxxPart::registerNatives(); + margelo::nitro::test::external::JHybridBaseSpec::CxxPart::registerNatives(); + margelo::nitro::test::external::JHybridBlaBlaSpec::CxxPart::registerNatives(); + margelo::nitro::test::external::JHybridTestViewSpec::CxxPart::registerNatives(); + margelo::nitro::test::external::JFunc_void_cxx::registerNatives(); + margelo::nitro::test::external::views::JHybridTestViewStateUpdater::registerNatives(); // Register Nitro Hybrid Objects HybridObjectRegistry::registerHybridObjectConstructor( - "SomeExternalObject", + "NitroTestExternalSomeExternalObject", []() -> std::shared_ptr { return JHybridSomeExternalObjectSpecImpl::create(); } ); + HybridObjectRegistry::registerHybridObjectConstructor( + "NitroTestExternalBlaBla", + []() -> std::shared_ptr { + return JHybridBlaBlaSpecImpl::create(); + } + ); + HybridObjectRegistry::registerHybridObjectConstructor( + "NitroTestExternalBase", + []() -> std::shared_ptr { + return JHybridBaseSpecImpl::create(); + } + ); + HybridObjectRegistry::registerHybridObjectConstructor( + "NitroTestExternalTestView", + []() -> std::shared_ptr { + return JHybridTestViewSpecImpl::create(); + } + ); } } // namespace margelo::nitro::test::external diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JFunc_void.hpp b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JFunc_void.hpp new file mode 100644 index 000000000..c139c6499 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JFunc_void.hpp @@ -0,0 +1,75 @@ +/// +/// JFunc_void.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include + +#include +#include + +namespace margelo::nitro::test::external { + + using namespace facebook; + + /** + * Represents the Java/Kotlin callback `() -> Unit`. + * This can be passed around between C++ and Java/Kotlin. + */ + struct JFunc_void: public jni::JavaClass { + public: + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/external/Func_void;"; + + public: + /** + * Invokes the function this `JFunc_void` instance holds through JNI. + */ + void invoke() const { + static const auto method = javaClassStatic()->getMethod("invoke"); + method(self()); + } + }; + + /** + * An implementation of Func_void that is backed by a C++ implementation (using `std::function<...>`) + */ + class JFunc_void_cxx final: public jni::HybridClass { + public: + static jni::local_ref fromCpp(const std::function& func) { + return JFunc_void_cxx::newObjectCxxArgs(func); + } + + public: + /** + * Invokes the C++ `std::function<...>` this `JFunc_void_cxx` instance holds. + */ + void invoke_cxx() { + _func(); + } + + public: + [[nodiscard]] + inline const std::function& getFunction() const { + return _func; + } + + public: + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/external/Func_void_cxx;"; + static void registerNatives() { + registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_cxx::invoke_cxx)}); + } + + private: + explicit JFunc_void_cxx(const std::function& func): _func(func) { } + + private: + friend HybridBase; + std::function _func; + }; + +} // namespace margelo::nitro::test::external diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridBaseSpec.cpp b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridBaseSpec.cpp new file mode 100644 index 000000000..9f9b7e749 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridBaseSpec.cpp @@ -0,0 +1,53 @@ +/// +/// JHybridBaseSpec.cpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#include "JHybridBaseSpec.hpp" + + + + + +namespace margelo::nitro::test::external { + + std::shared_ptr JHybridBaseSpec::JavaPart::getJHybridBaseSpec() { + auto hybridObject = JHybridObject::JavaPart::getJHybridObject(); + auto castHybridObject = std::dynamic_pointer_cast(hybridObject); + if (castHybridObject == nullptr) [[unlikely]] { + throw std::runtime_error("Failed to downcast JHybridObject to JHybridBaseSpec!"); + } + return castHybridObject; + } + + jni::local_ref JHybridBaseSpec::CxxPart::initHybrid(jni::alias_ref jThis) { + return makeCxxInstance(jThis); + } + + std::shared_ptr JHybridBaseSpec::CxxPart::createHybridObject(const jni::local_ref& javaPart) { + auto castJavaPart = jni::dynamic_ref_cast(javaPart); + if (castJavaPart == nullptr) [[unlikely]] { + throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridBaseSpec::JavaPart!"); + } + return std::make_shared(castJavaPart); + } + + void JHybridBaseSpec::CxxPart::registerNatives() { + registerHybrid({ + makeNativeMethod("initHybrid", JHybridBaseSpec::CxxPart::initHybrid), + }); + } + + // Properties + double JHybridBaseSpec::getAbc() { + static const auto method = _javaPart->javaClassStatic()->getMethod("getAbc"); + auto __result = method(_javaPart); + return __result; + } + + // Methods + + +} // namespace margelo::nitro::test::external diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridBaseSpec.hpp b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridBaseSpec.hpp new file mode 100644 index 000000000..a9ba2a3d3 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridBaseSpec.hpp @@ -0,0 +1,63 @@ +/// +/// HybridBaseSpec.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include +#include "NitroTestExternalHybridBaseSpec.hpp" + + + + +namespace margelo::nitro::test::external { + + using namespace facebook; + + class JHybridBaseSpec: public virtual HybridBaseSpec, public virtual JHybridObject { + public: + struct JavaPart: public jni::JavaClass { + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/external/HybridBaseSpec;"; + std::shared_ptr getJHybridBaseSpec(); + }; + struct CxxPart: public jni::HybridClass { + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/external/HybridBaseSpec$CxxPart;"; + static jni::local_ref initHybrid(jni::alias_ref jThis); + static void registerNatives(); + using HybridBase::HybridBase; + protected: + std::shared_ptr createHybridObject(const jni::local_ref& javaPart) override; + }; + + public: + explicit JHybridBaseSpec(const jni::local_ref& javaPart): + HybridObject(HybridBaseSpec::TAG), + JHybridObject(javaPart), + _javaPart(jni::make_global(javaPart)) {} + ~JHybridBaseSpec() override { + // Hermes GC can destroy JS objects on a non-JNI Thread. + jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); }); + } + + public: + inline const jni::global_ref& getJavaPart() const noexcept { + return _javaPart; + } + + public: + // Properties + double getAbc() override; + + public: + // Methods + + + private: + jni::global_ref _javaPart; + }; + +} // namespace margelo::nitro::test::external diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridBlaBlaSpec.cpp b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridBlaBlaSpec.cpp new file mode 100644 index 000000000..7ea97848a --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridBlaBlaSpec.cpp @@ -0,0 +1,61 @@ +/// +/// JHybridBlaBlaSpec.cpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#include "JHybridBlaBlaSpec.hpp" + +// Forward declaration of `HybridBaseSpec` to properly resolve imports. +namespace margelo::nitro::test::external { class HybridBaseSpec; } + +#include +#include "NitroTestExternalHybridBaseSpec.hpp" +#include +#include "JHybridBaseSpec.hpp" + +namespace margelo::nitro::test::external { + + std::shared_ptr JHybridBlaBlaSpec::JavaPart::getJHybridBlaBlaSpec() { + auto hybridObject = JHybridObject::JavaPart::getJHybridObject(); + auto castHybridObject = std::dynamic_pointer_cast(hybridObject); + if (castHybridObject == nullptr) [[unlikely]] { + throw std::runtime_error("Failed to downcast JHybridObject to JHybridBlaBlaSpec!"); + } + return castHybridObject; + } + + jni::local_ref JHybridBlaBlaSpec::CxxPart::initHybrid(jni::alias_ref jThis) { + return makeCxxInstance(jThis); + } + + std::shared_ptr JHybridBlaBlaSpec::CxxPart::createHybridObject(const jni::local_ref& javaPart) { + auto castJavaPart = jni::dynamic_ref_cast(javaPart); + if (castJavaPart == nullptr) [[unlikely]] { + throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridBlaBlaSpec::JavaPart!"); + } + return std::make_shared(castJavaPart); + } + + void JHybridBlaBlaSpec::CxxPart::registerNatives() { + registerHybrid({ + makeNativeMethod("initHybrid", JHybridBlaBlaSpec::CxxPart::initHybrid), + }); + } + + // Properties + std::optional> JHybridBlaBlaSpec::getBase() { + static const auto method = _javaPart->javaClassStatic()->getMethod()>("getBase"); + auto __result = method(_javaPart); + return __result != nullptr ? std::make_optional(__result->getJHybridBaseSpec()) : std::nullopt; + } + void JHybridBlaBlaSpec::setBase(const std::optional>& base) { + static const auto method = _javaPart->javaClassStatic()->getMethod /* base */)>("setBase"); + method(_javaPart, base.has_value() ? std::dynamic_pointer_cast(base.value())->getJavaPart() : nullptr); + } + + // Methods + + +} // namespace margelo::nitro::test::external diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridBlaBlaSpec.hpp b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridBlaBlaSpec.hpp new file mode 100644 index 000000000..83c984eb4 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridBlaBlaSpec.hpp @@ -0,0 +1,64 @@ +/// +/// HybridBlaBlaSpec.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include +#include "NitroTestExternalHybridBlaBlaSpec.hpp" + + + + +namespace margelo::nitro::test::external { + + using namespace facebook; + + class JHybridBlaBlaSpec: public virtual HybridBlaBlaSpec, public virtual JHybridObject { + public: + struct JavaPart: public jni::JavaClass { + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/external/HybridBlaBlaSpec;"; + std::shared_ptr getJHybridBlaBlaSpec(); + }; + struct CxxPart: public jni::HybridClass { + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/external/HybridBlaBlaSpec$CxxPart;"; + static jni::local_ref initHybrid(jni::alias_ref jThis); + static void registerNatives(); + using HybridBase::HybridBase; + protected: + std::shared_ptr createHybridObject(const jni::local_ref& javaPart) override; + }; + + public: + explicit JHybridBlaBlaSpec(const jni::local_ref& javaPart): + HybridObject(HybridBlaBlaSpec::TAG), + JHybridObject(javaPart), + _javaPart(jni::make_global(javaPart)) {} + ~JHybridBlaBlaSpec() override { + // Hermes GC can destroy JS objects on a non-JNI Thread. + jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); }); + } + + public: + inline const jni::global_ref& getJavaPart() const noexcept { + return _javaPart; + } + + public: + // Properties + std::optional> getBase() override; + void setBase(const std::optional>& base) override; + + public: + // Methods + + + private: + jni::global_ref _javaPart; + }; + +} // namespace margelo::nitro::test::external diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridSomeExternalObjectSpec.cpp b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridSomeExternalObjectSpec.cpp index 5455f6101..c8b7237ab 100644 --- a/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridSomeExternalObjectSpec.cpp +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridSomeExternalObjectSpec.cpp @@ -11,7 +11,7 @@ namespace margelo::nitro::test::external { struct OptionalPrimitivesHolder; } #include -#include "OptionalPrimitivesHolder.hpp" +#include "NitroTestExternalOptionalPrimitivesHolder.hpp" #include "JOptionalPrimitivesHolder.hpp" #include diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridSomeExternalObjectSpec.hpp b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridSomeExternalObjectSpec.hpp index 30645703b..a871ca696 100644 --- a/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridSomeExternalObjectSpec.hpp +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridSomeExternalObjectSpec.hpp @@ -9,7 +9,7 @@ #include #include -#include "HybridSomeExternalObjectSpec.hpp" +#include "NitroTestExternalHybridSomeExternalObjectSpec.hpp" diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridTestViewSpec.cpp b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridTestViewSpec.cpp new file mode 100644 index 000000000..633689209 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridTestViewSpec.cpp @@ -0,0 +1,88 @@ +/// +/// JHybridTestViewSpec.cpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#include "JHybridTestViewSpec.hpp" + + + +#include +#include "JFunc_void.hpp" +#include + +namespace margelo::nitro::test::external { + + std::shared_ptr JHybridTestViewSpec::JavaPart::getJHybridTestViewSpec() { + auto hybridObject = JHybridObject::JavaPart::getJHybridObject(); + auto castHybridObject = std::dynamic_pointer_cast(hybridObject); + if (castHybridObject == nullptr) [[unlikely]] { + throw std::runtime_error("Failed to downcast JHybridObject to JHybridTestViewSpec!"); + } + return castHybridObject; + } + + jni::local_ref JHybridTestViewSpec::CxxPart::initHybrid(jni::alias_ref jThis) { + return makeCxxInstance(jThis); + } + + std::shared_ptr JHybridTestViewSpec::CxxPart::createHybridObject(const jni::local_ref& javaPart) { + auto castJavaPart = jni::dynamic_ref_cast(javaPart); + if (castJavaPart == nullptr) [[unlikely]] { + throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridTestViewSpec::JavaPart!"); + } + return std::make_shared(castJavaPart); + } + + void JHybridTestViewSpec::CxxPart::registerNatives() { + registerHybrid({ + makeNativeMethod("initHybrid", JHybridTestViewSpec::CxxPart::initHybrid), + }); + } + + // Properties + bool JHybridTestViewSpec::getIsCyan() { + static const auto method = _javaPart->javaClassStatic()->getMethod("isCyan"); + auto __result = method(_javaPart); + return static_cast(__result); + } + void JHybridTestViewSpec::setIsCyan(bool isCyan) { + static const auto method = _javaPart->javaClassStatic()->getMethod("setCyan"); + method(_javaPart, isCyan); + } + bool JHybridTestViewSpec::getHasBeenCalled() { + static const auto method = _javaPart->javaClassStatic()->getMethod("getHasBeenCalled"); + auto __result = method(_javaPart); + return static_cast(__result); + } + void JHybridTestViewSpec::setHasBeenCalled(bool hasBeenCalled) { + static const auto method = _javaPart->javaClassStatic()->getMethod("setHasBeenCalled"); + method(_javaPart, hasBeenCalled); + } + std::function JHybridTestViewSpec::getTestCallback() { + static const auto method = _javaPart->javaClassStatic()->getMethod()>("getTestCallback_cxx"); + auto __result = method(_javaPart); + return [&]() -> std::function { + if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] { + auto downcast = jni::static_ref_cast(__result); + return downcast->cthis()->getFunction(); + } else { + auto __resultRef = jni::make_global(__result); + return JNICallable(std::move(__resultRef)); + } + }(); + } + void JHybridTestViewSpec::setTestCallback(const std::function& testCallback) { + static const auto method = _javaPart->javaClassStatic()->getMethod /* testCallback */)>("setTestCallback_cxx"); + method(_javaPart, JFunc_void_cxx::fromCpp(testCallback)); + } + + // Methods + void JHybridTestViewSpec::testMethod() { + static const auto method = _javaPart->javaClassStatic()->getMethod("testMethod"); + method(_javaPart); + } + +} // namespace margelo::nitro::test::external diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridTestViewSpec.hpp b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridTestViewSpec.hpp new file mode 100644 index 000000000..4c9157754 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridTestViewSpec.hpp @@ -0,0 +1,68 @@ +/// +/// HybridTestViewSpec.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include +#include "NitroTestExternalHybridTestViewSpec.hpp" + + + + +namespace margelo::nitro::test::external { + + using namespace facebook; + + class JHybridTestViewSpec: public virtual HybridTestViewSpec, public virtual JHybridObject { + public: + struct JavaPart: public jni::JavaClass { + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/external/HybridTestViewSpec;"; + std::shared_ptr getJHybridTestViewSpec(); + }; + struct CxxPart: public jni::HybridClass { + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/external/HybridTestViewSpec$CxxPart;"; + static jni::local_ref initHybrid(jni::alias_ref jThis); + static void registerNatives(); + using HybridBase::HybridBase; + protected: + std::shared_ptr createHybridObject(const jni::local_ref& javaPart) override; + }; + + public: + explicit JHybridTestViewSpec(const jni::local_ref& javaPart): + HybridObject(HybridTestViewSpec::TAG), + JHybridObject(javaPart), + _javaPart(jni::make_global(javaPart)) {} + ~JHybridTestViewSpec() override { + // Hermes GC can destroy JS objects on a non-JNI Thread. + jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); }); + } + + public: + inline const jni::global_ref& getJavaPart() const noexcept { + return _javaPart; + } + + public: + // Properties + bool getIsCyan() override; + void setIsCyan(bool isCyan) override; + bool getHasBeenCalled() override; + void setHasBeenCalled(bool hasBeenCalled) override; + std::function getTestCallback() override; + void setTestCallback(const std::function& testCallback) override; + + public: + // Methods + void testMethod() override; + + private: + jni::global_ref _javaPart; + }; + +} // namespace margelo::nitro::test::external diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JOptionalPrimitivesHolder.hpp b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JOptionalPrimitivesHolder.hpp index bc648c6b9..2fe19357d 100644 --- a/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JOptionalPrimitivesHolder.hpp +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JOptionalPrimitivesHolder.hpp @@ -8,7 +8,7 @@ #pragma once #include -#include "OptionalPrimitivesHolder.hpp" +#include "NitroTestExternalOptionalPrimitivesHolder.hpp" #include diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/views/JHybridTestViewStateUpdater.cpp b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/views/JHybridTestViewStateUpdater.cpp new file mode 100644 index 000000000..b75e61a55 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/views/JHybridTestViewStateUpdater.cpp @@ -0,0 +1,64 @@ +/// +/// JHybridTestViewStateUpdater.cpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#include "JHybridTestViewStateUpdater.hpp" +#include "views/NitroTestExternalHybridTestViewComponent.hpp" +#include +#include + +namespace margelo::nitro::test::external::views { + +using namespace facebook; +using ConcreteStateData = react::ConcreteState; + +void JHybridTestViewStateUpdater::updateViewProps(jni::alias_ref /* class */, + jni::alias_ref javaView, + jni::alias_ref stateWrapperInterface) { + std::shared_ptr hybridView = javaView->getJHybridTestViewSpec(); + + // Get concrete StateWrapperImpl from passed StateWrapper interface object + jobject rawStateWrapper = stateWrapperInterface.get(); + if (!stateWrapperInterface->isInstanceOf(react::StateWrapperImpl::javaClassStatic())) [[unlikely]] { + throw std::runtime_error("StateWrapper is not a StateWrapperImpl"); + } + auto stateWrapper = jni::alias_ref{ + static_cast(rawStateWrapper)}; + std::shared_ptr state = stateWrapper->cthis()->getState(); + auto concreteState = std::static_pointer_cast(state); + const HybridTestViewState& data = concreteState->getData(); + const std::shared_ptr& props = data.getProps(); + if (props == nullptr) [[unlikely]] { + // Props aren't set yet! + throw std::runtime_error("HybridTestViewState's data doesn't contain any props!"); + } + + // Update all props if they are dirty + if (props->isCyan.isDirty) { + hybridView->setIsCyan(props->isCyan.value); + props->isCyan.isDirty = false; + } + if (props->hasBeenCalled.isDirty) { + hybridView->setHasBeenCalled(props->hasBeenCalled.value); + props->hasBeenCalled.isDirty = false; + } + if (props->testCallback.isDirty) { + hybridView->setTestCallback(props->testCallback.value); + props->testCallback.isDirty = false; + } + + // Update hybridRef if it changed + if (props->hybridRef.isDirty) { + // hybridRef changed - call it with new this + const auto& maybeFunc = props->hybridRef.value; + if (maybeFunc.has_value()) { + maybeFunc.value()(hybridView); + } + props->hybridRef.isDirty = false; + } +} + +} // namespace margelo::nitro::test::external::views diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/views/JHybridTestViewStateUpdater.hpp b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/views/JHybridTestViewStateUpdater.hpp new file mode 100644 index 000000000..02361399c --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/views/JHybridTestViewStateUpdater.hpp @@ -0,0 +1,49 @@ +/// +/// JHybridTestViewStateUpdater.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#ifndef RN_SERIALIZABLE_STATE +#error NitroTestExternal was compiled without the 'RN_SERIALIZABLE_STATE' flag. This flag is required for Nitro Views - set it in your CMakeLists! +#endif + +#include +#include +#include +#include +#include +#include +#include "JHybridTestViewSpec.hpp" +#include "views/NitroTestExternalHybridTestViewComponent.hpp" + +namespace margelo::nitro::test::external::views { + +using namespace facebook; + +class JHybridTestViewStateUpdater final: public jni::JavaClass { +public: + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/external/views/HybridTestViewStateUpdater;"; + +public: + static void updateViewProps(jni::alias_ref /* class */, + jni::alias_ref view, + jni::alias_ref stateWrapperInterface); + +public: + static void registerNatives() { + // Register JNI calls + javaClassStatic()->registerNatives({ + makeNativeMethod("updateViewProps", JHybridTestViewStateUpdater::updateViewProps), + }); + // Register React Native view component descriptor + auto provider = react::concreteComponentDescriptorProvider(); + auto providerRegistry = react::CoreComponentsRegistry::sharedProviderRegistry(); + providerRegistry->add(provider); + } +}; + +} // namespace margelo::nitro::test::external::views diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/kotlin/com/margelo/nitro/test/external/Func_void.kt b/packages/react-native-nitro-test-external/nitrogen/generated/android/kotlin/com/margelo/nitro/test/external/Func_void.kt new file mode 100644 index 000000000..fbf9c9310 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/kotlin/com/margelo/nitro/test/external/Func_void.kt @@ -0,0 +1,80 @@ +/// +/// Func_void.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.test.external + +import androidx.annotation.Keep +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStrip +import dalvik.annotation.optimization.FastNative + + +/** + * Represents the JavaScript callback `() => void`. + * This can be either implemented in C++ (in which case it might be a callback coming from JS), + * or in Kotlin/Java (in which case it is a native callback). + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType") +fun interface Func_void: () -> Unit { + /** + * Call the given JS callback. + * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted. + */ + @DoNotStrip + @Keep + override fun invoke(): Unit +} + +/** + * Represents the JavaScript callback `() => void`. + * This is implemented in C++, via a `std::function<...>`. + * The callback might be coming from JS. + */ +@DoNotStrip +@Keep +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", "FunctionName", + "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName", +) +class Func_void_cxx: Func_void { + @DoNotStrip + @Keep + private val mHybridData: HybridData + + @DoNotStrip + @Keep + private constructor(hybridData: HybridData) { + mHybridData = hybridData + } + + @DoNotStrip + @Keep + override fun invoke(): Unit + = invoke_cxx() + + @FastNative + private external fun invoke_cxx(): Unit +} + +/** + * Represents the JavaScript callback `() => void`. + * This is implemented in Java/Kotlin, via a `() -> Unit`. + * The callback is always coming from native. + */ +@DoNotStrip +@Keep +@Suppress("ClassName", "RedundantUnitReturnType", "unused") +class Func_void_java(private val function: () -> Unit): Func_void { + @DoNotStrip + @Keep + override fun invoke(): Unit { + return this.function() + } +} diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/kotlin/com/margelo/nitro/test/external/HybridBaseSpec.kt b/packages/react-native-nitro-test-external/nitrogen/generated/android/kotlin/com/margelo/nitro/test/external/HybridBaseSpec.kt new file mode 100644 index 000000000..a5dfcc73e --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/kotlin/com/margelo/nitro/test/external/HybridBaseSpec.kt @@ -0,0 +1,54 @@ +/// +/// HybridBaseSpec.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.test.external + +import androidx.annotation.Keep +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.HybridObject + +/** + * A Kotlin class representing the Base HybridObject. + * Implement this abstract class to create Kotlin-based instances of Base. + */ +@DoNotStrip +@Keep +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet", + "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName" +) +abstract class HybridBaseSpec: HybridObject() { + // Properties + @get:DoNotStrip + @get:Keep + abstract val abc: Double + + // Methods + + + // Default implementation of `HybridObject.toString()` + override fun toString(): String { + return "[HybridObject NitroTestExternalBase]" + } + + // C++ backing class + @DoNotStrip + @Keep + protected open class CxxPart(javaPart: HybridBaseSpec): HybridObject.CxxPart(javaPart) { + // C++ JHybridBaseSpec::CxxPart::initHybrid(...) + external override fun initHybrid(): HybridData + } + override fun createCxxPart(): CxxPart { + return CxxPart(this) + } + + companion object { + protected const val TAG = "HybridBaseSpec" + } +} diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/kotlin/com/margelo/nitro/test/external/HybridBlaBlaSpec.kt b/packages/react-native-nitro-test-external/nitrogen/generated/android/kotlin/com/margelo/nitro/test/external/HybridBlaBlaSpec.kt new file mode 100644 index 000000000..4968a7f47 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/kotlin/com/margelo/nitro/test/external/HybridBlaBlaSpec.kt @@ -0,0 +1,56 @@ +/// +/// HybridBlaBlaSpec.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.test.external + +import androidx.annotation.Keep +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.HybridObject + +/** + * A Kotlin class representing the BlaBla HybridObject. + * Implement this abstract class to create Kotlin-based instances of BlaBla. + */ +@DoNotStrip +@Keep +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet", + "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName" +) +abstract class HybridBlaBlaSpec: HybridObject() { + // Properties + @get:DoNotStrip + @get:Keep + @set:DoNotStrip + @set:Keep + abstract var base: HybridBaseSpec? + + // Methods + + + // Default implementation of `HybridObject.toString()` + override fun toString(): String { + return "[HybridObject NitroTestExternalBlaBla]" + } + + // C++ backing class + @DoNotStrip + @Keep + protected open class CxxPart(javaPart: HybridBlaBlaSpec): HybridObject.CxxPart(javaPart) { + // C++ JHybridBlaBlaSpec::CxxPart::initHybrid(...) + external override fun initHybrid(): HybridData + } + override fun createCxxPart(): CxxPart { + return CxxPart(this) + } + + companion object { + protected const val TAG = "HybridBlaBlaSpec" + } +} diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/kotlin/com/margelo/nitro/test/external/HybridSomeExternalObjectSpec.kt b/packages/react-native-nitro-test-external/nitrogen/generated/android/kotlin/com/margelo/nitro/test/external/HybridSomeExternalObjectSpec.kt index 78da5b90b..942a2aa56 100644 --- a/packages/react-native-nitro-test-external/nitrogen/generated/android/kotlin/com/margelo/nitro/test/external/HybridSomeExternalObjectSpec.kt +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/kotlin/com/margelo/nitro/test/external/HybridSomeExternalObjectSpec.kt @@ -43,7 +43,7 @@ abstract class HybridSomeExternalObjectSpec: HybridObject() { // Default implementation of `HybridObject.toString()` override fun toString(): String { - return "[HybridObject SomeExternalObject]" + return "[HybridObject NitroTestExternalSomeExternalObject]" } // C++ backing class diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/kotlin/com/margelo/nitro/test/external/HybridTestViewSpec.kt b/packages/react-native-nitro-test-external/nitrogen/generated/android/kotlin/com/margelo/nitro/test/external/HybridTestViewSpec.kt new file mode 100644 index 000000000..d6eb4ff77 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/kotlin/com/margelo/nitro/test/external/HybridTestViewSpec.kt @@ -0,0 +1,79 @@ +/// +/// HybridTestViewSpec.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.test.external + +import androidx.annotation.Keep +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.HybridObject +import com.margelo.nitro.views.HybridView + +/** + * A Kotlin class representing the TestView HybridObject. + * Implement this abstract class to create Kotlin-based instances of TestView. + */ +@DoNotStrip +@Keep +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet", + "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName" +) +abstract class HybridTestViewSpec: HybridView() { + // Properties + @get:DoNotStrip + @get:Keep + @set:DoNotStrip + @set:Keep + abstract var isCyan: Boolean + + @get:DoNotStrip + @get:Keep + @set:DoNotStrip + @set:Keep + abstract var hasBeenCalled: Boolean + + abstract var testCallback: () -> Unit + + private var testCallback_cxx: Func_void + @Keep + @DoNotStrip + get() { + return Func_void_java(testCallback) + } + @Keep + @DoNotStrip + set(value) { + testCallback = value + } + + // Methods + @DoNotStrip + @Keep + abstract fun testMethod(): Unit + + // Default implementation of `HybridObject.toString()` + override fun toString(): String { + return "[HybridObject NitroTestExternalTestView]" + } + + // C++ backing class + @DoNotStrip + @Keep + protected open class CxxPart(javaPart: HybridTestViewSpec): HybridObject.CxxPart(javaPart) { + // C++ JHybridTestViewSpec::CxxPart::initHybrid(...) + external override fun initHybrid(): HybridData + } + override fun createCxxPart(): CxxPart { + return CxxPart(this) + } + + companion object { + protected const val TAG = "HybridTestViewSpec" + } +} diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/kotlin/com/margelo/nitro/test/external/views/HybridTestViewManager.kt b/packages/react-native-nitro-test-external/nitrogen/generated/android/kotlin/com/margelo/nitro/test/external/views/HybridTestViewManager.kt new file mode 100644 index 000000000..4961d4164 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/kotlin/com/margelo/nitro/test/external/views/HybridTestViewManager.kt @@ -0,0 +1,80 @@ +/// +/// HybridTestViewManager.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.test.external.views + +import android.view.View +import com.facebook.react.uimanager.ReactStylesDiffMap +import com.facebook.react.uimanager.SimpleViewManager +import com.facebook.react.uimanager.StateWrapper +import com.facebook.react.uimanager.ThemedReactContext +import com.margelo.nitro.R.id.associated_hybrid_view_tag +import com.margelo.nitro.views.RecyclableView +import com.margelo.nitro.test.external.* + +/** + * Represents the React Native `ViewManager` for the "TestView" Nitro HybridView. + */ +public class HybridTestViewManager: SimpleViewManager() { + init { + if (RecyclableView::class.java.isAssignableFrom(HybridTestView::class.java)) { + // Enable view recycling + super.setupViewRecycling() + } + } + + override fun getName(): String { + return "NitroTestExternalTestView" + } + + override fun createViewInstance(reactContext: ThemedReactContext): View { + val hybridView = HybridTestView(reactContext) + val view = hybridView.view + view.setTag(associated_hybrid_view_tag, hybridView) + return view + } + + override fun updateState(view: View, props: ReactStylesDiffMap, stateWrapper: StateWrapper): Any? { + val hybridView = getHybridView(view) + ?: throw Error("Couldn't find view $view in local views table!") + + // 1. Update each prop individually + hybridView.beforeUpdate() + HybridTestViewStateUpdater.updateViewProps(hybridView, stateWrapper) + hybridView.afterUpdate() + + // 2. Continue in base View props + return super.updateState(view, props, stateWrapper) + } + + override fun onDropViewInstance(view: View) { + val hybridView = getHybridView(view) + hybridView?.onDropView() + return super.onDropViewInstance(view) + } + + protected override fun prepareToRecycleView(reactContext: ThemedReactContext, view: View): View? { + super.prepareToRecycleView(reactContext, view) + val hybridView = getHybridView(view) + ?: return null + + @Suppress("USELESS_IS_CHECK") + if (hybridView is RecyclableView) { + // Recycle in it's implementation + hybridView.prepareForRecycle() + + // Maybe update the view if it changed + return hybridView.view + } else { + return null + } + } + + private fun getHybridView(view: View): HybridTestView? { + return view.getTag(associated_hybrid_view_tag) as? HybridTestView + } +} diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/kotlin/com/margelo/nitro/test/external/views/HybridTestViewStateUpdater.kt b/packages/react-native-nitro-test-external/nitrogen/generated/android/kotlin/com/margelo/nitro/test/external/views/HybridTestViewStateUpdater.kt new file mode 100644 index 000000000..b28101854 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/kotlin/com/margelo/nitro/test/external/views/HybridTestViewStateUpdater.kt @@ -0,0 +1,23 @@ +/// +/// HybridTestViewStateUpdater.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.test.external.views + +import com.facebook.react.uimanager.StateWrapper +import com.margelo.nitro.test.external.* + +internal class HybridTestViewStateUpdater { + companion object { + /** + * Updates the props for [view] through C++. + * The [state] prop is expected to contain [view]'s props as wrapped Fabric state. + */ + @Suppress("KotlinJniMissingFunction") + @JvmStatic + external fun updateViewProps(view: HybridTestViewSpec, state: StateWrapper) + } +} diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/ios/NitroTestExternal-Swift-Cxx-Bridge.cpp b/packages/react-native-nitro-test-external/nitrogen/generated/ios/NitroTestExternal-Swift-Cxx-Bridge.cpp index eb8fe3589..9e5a3886f 100644 --- a/packages/react-native-nitro-test-external/nitrogen/generated/ios/NitroTestExternal-Swift-Cxx-Bridge.cpp +++ b/packages/react-native-nitro-test-external/nitrogen/generated/ios/NitroTestExternal-Swift-Cxx-Bridge.cpp @@ -8,8 +8,11 @@ #include "NitroTestExternal-Swift-Cxx-Bridge.hpp" // Include C++ implementation defined types -#include "HybridSomeExternalObjectSpecSwift.hpp" #include "NitroTestExternal-Swift-Cxx-Umbrella.hpp" +#include "NitroTestExternalHybridBaseSpecSwift.hpp" +#include "NitroTestExternalHybridBlaBlaSpecSwift.hpp" +#include "NitroTestExternalHybridSomeExternalObjectSpecSwift.hpp" +#include "NitroTestExternalHybridTestViewSpecSwift.hpp" #include namespace margelo::nitro::test::external::bridge::swift { @@ -29,5 +32,61 @@ namespace margelo::nitro::test::external::bridge::swift { NitroTestExternal::HybridSomeExternalObjectSpec_cxx& swiftPart = swiftWrapper->getSwiftPart(); return swiftPart.toUnsafe(); } + + // pragma MARK: std::shared_ptr + std::shared_ptr create_std__shared_ptr_HybridBaseSpec_(void* NON_NULL swiftUnsafePointer) noexcept { + NitroTestExternal::HybridBaseSpec_cxx swiftPart = NitroTestExternal::HybridBaseSpec_cxx::fromUnsafe(swiftUnsafePointer); + return std::make_shared(swiftPart); + } + void* NON_NULL get_std__shared_ptr_HybridBaseSpec_(std__shared_ptr_HybridBaseSpec_ cppType) { + std::shared_ptr swiftWrapper = std::dynamic_pointer_cast(cppType); + #ifdef NITRO_DEBUG + if (swiftWrapper == nullptr) [[unlikely]] { + throw std::runtime_error("Class \"HybridBaseSpec\" is not implemented in Swift!"); + } + #endif + NitroTestExternal::HybridBaseSpec_cxx& swiftPart = swiftWrapper->getSwiftPart(); + return swiftPart.toUnsafe(); + } + + // pragma MARK: std::shared_ptr + std::shared_ptr create_std__shared_ptr_HybridBlaBlaSpec_(void* NON_NULL swiftUnsafePointer) noexcept { + NitroTestExternal::HybridBlaBlaSpec_cxx swiftPart = NitroTestExternal::HybridBlaBlaSpec_cxx::fromUnsafe(swiftUnsafePointer); + return std::make_shared(swiftPart); + } + void* NON_NULL get_std__shared_ptr_HybridBlaBlaSpec_(std__shared_ptr_HybridBlaBlaSpec_ cppType) { + std::shared_ptr swiftWrapper = std::dynamic_pointer_cast(cppType); + #ifdef NITRO_DEBUG + if (swiftWrapper == nullptr) [[unlikely]] { + throw std::runtime_error("Class \"HybridBlaBlaSpec\" is not implemented in Swift!"); + } + #endif + NitroTestExternal::HybridBlaBlaSpec_cxx& swiftPart = swiftWrapper->getSwiftPart(); + return swiftPart.toUnsafe(); + } + + // pragma MARK: std::function + Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept { + auto swiftClosure = NitroTestExternal::Func_void::fromUnsafe(swiftClosureWrapper); + return [swiftClosure = std::move(swiftClosure)]() mutable -> void { + swiftClosure.call(); + }; + } + + // pragma MARK: std::shared_ptr + std::shared_ptr create_std__shared_ptr_HybridTestViewSpec_(void* NON_NULL swiftUnsafePointer) noexcept { + NitroTestExternal::HybridTestViewSpec_cxx swiftPart = NitroTestExternal::HybridTestViewSpec_cxx::fromUnsafe(swiftUnsafePointer); + return std::make_shared(swiftPart); + } + void* NON_NULL get_std__shared_ptr_HybridTestViewSpec_(std__shared_ptr_HybridTestViewSpec_ cppType) { + std::shared_ptr swiftWrapper = std::dynamic_pointer_cast(cppType); + #ifdef NITRO_DEBUG + if (swiftWrapper == nullptr) [[unlikely]] { + throw std::runtime_error("Class \"HybridTestViewSpec\" is not implemented in Swift!"); + } + #endif + NitroTestExternal::HybridTestViewSpec_cxx& swiftPart = swiftWrapper->getSwiftPart(); + return swiftPart.toUnsafe(); + } } // namespace margelo::nitro::test::external::bridge::swift diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/ios/NitroTestExternal-Swift-Cxx-Bridge.hpp b/packages/react-native-nitro-test-external/nitrogen/generated/ios/NitroTestExternal-Swift-Cxx-Bridge.hpp index a89feb409..4963599ce 100644 --- a/packages/react-native-nitro-test-external/nitrogen/generated/ios/NitroTestExternal-Swift-Cxx-Bridge.hpp +++ b/packages/react-native-nitro-test-external/nitrogen/generated/ios/NitroTestExternal-Swift-Cxx-Bridge.hpp @@ -8,20 +8,36 @@ #pragma once // Forward declarations of C++ defined types +// Forward declaration of `HybridBaseSpec` to properly resolve imports. +namespace margelo::nitro::test::external { class HybridBaseSpec; } +// Forward declaration of `HybridBlaBlaSpec` to properly resolve imports. +namespace margelo::nitro::test::external { class HybridBlaBlaSpec; } // Forward declaration of `HybridSomeExternalObjectSpec` to properly resolve imports. namespace margelo::nitro::test::external { class HybridSomeExternalObjectSpec; } +// Forward declaration of `HybridTestViewSpec` to properly resolve imports. +namespace margelo::nitro::test::external { class HybridTestViewSpec; } // Forward declaration of `OptionalPrimitivesHolder` to properly resolve imports. namespace margelo::nitro::test::external { struct OptionalPrimitivesHolder; } // Forward declarations of Swift defined types +// Forward declaration of `HybridBaseSpec_cxx` to properly resolve imports. +namespace NitroTestExternal { class HybridBaseSpec_cxx; } +// Forward declaration of `HybridBlaBlaSpec_cxx` to properly resolve imports. +namespace NitroTestExternal { class HybridBlaBlaSpec_cxx; } // Forward declaration of `HybridSomeExternalObjectSpec_cxx` to properly resolve imports. namespace NitroTestExternal { class HybridSomeExternalObjectSpec_cxx; } +// Forward declaration of `HybridTestViewSpec_cxx` to properly resolve imports. +namespace NitroTestExternal { class HybridTestViewSpec_cxx; } // Include C++ defined types -#include "HybridSomeExternalObjectSpec.hpp" -#include "OptionalPrimitivesHolder.hpp" +#include "NitroTestExternalHybridBaseSpec.hpp" +#include "NitroTestExternalHybridBlaBlaSpec.hpp" +#include "NitroTestExternalHybridSomeExternalObjectSpec.hpp" +#include "NitroTestExternalHybridTestViewSpec.hpp" +#include "NitroTestExternalOptionalPrimitivesHolder.hpp" #include #include +#include #include #include #include @@ -121,5 +137,87 @@ namespace margelo::nitro::test::external::bridge::swift { inline Result_OptionalPrimitivesHolder_ create_Result_OptionalPrimitivesHolder_(const std::exception_ptr& error) noexcept { return Result::withError(error); } + + // pragma MARK: std::shared_ptr + /** + * Specialized version of `std::shared_ptr`. + */ + using std__shared_ptr_HybridBaseSpec_ = std::shared_ptr; + std::shared_ptr create_std__shared_ptr_HybridBaseSpec_(void* NON_NULL swiftUnsafePointer) noexcept; + void* NON_NULL get_std__shared_ptr_HybridBaseSpec_(std__shared_ptr_HybridBaseSpec_ cppType); + + // pragma MARK: std::weak_ptr + using std__weak_ptr_HybridBaseSpec_ = std::weak_ptr; + inline std__weak_ptr_HybridBaseSpec_ weakify_std__shared_ptr_HybridBaseSpec_(const std::shared_ptr& strong) noexcept { return strong; } + + // pragma MARK: std::optional> + /** + * Specialized version of `std::optional>`. + */ + using std__optional_std__shared_ptr_HybridBaseSpec__ = std::optional>; + inline std::optional> create_std__optional_std__shared_ptr_HybridBaseSpec__(const std::shared_ptr& value) noexcept { + return std::optional>(value); + } + inline bool has_value_std__optional_std__shared_ptr_HybridBaseSpec__(const std::optional>& optional) noexcept { + return optional.has_value(); + } + inline std::shared_ptr get_std__optional_std__shared_ptr_HybridBaseSpec__(const std::optional>& optional) noexcept { + return optional.value(); + } + + // pragma MARK: std::shared_ptr + /** + * Specialized version of `std::shared_ptr`. + */ + using std__shared_ptr_HybridBlaBlaSpec_ = std::shared_ptr; + std::shared_ptr create_std__shared_ptr_HybridBlaBlaSpec_(void* NON_NULL swiftUnsafePointer) noexcept; + void* NON_NULL get_std__shared_ptr_HybridBlaBlaSpec_(std__shared_ptr_HybridBlaBlaSpec_ cppType); + + // pragma MARK: std::weak_ptr + using std__weak_ptr_HybridBlaBlaSpec_ = std::weak_ptr; + inline std__weak_ptr_HybridBlaBlaSpec_ weakify_std__shared_ptr_HybridBlaBlaSpec_(const std::shared_ptr& strong) noexcept { return strong; } + + // pragma MARK: std::function + /** + * Specialized version of `std::function`. + */ + using Func_void = std::function; + /** + * Wrapper class for a `std::function`, this can be used from Swift. + */ + class Func_void_Wrapper final { + public: + explicit Func_void_Wrapper(std::function&& func): _function(std::make_unique>(std::move(func))) {} + inline void call() const noexcept { + _function->operator()(); + } + private: + std::unique_ptr> _function; + } SWIFT_NONCOPYABLE; + Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept; + inline Func_void_Wrapper wrap_Func_void(Func_void value) noexcept { + return Func_void_Wrapper(std::move(value)); + } + + // pragma MARK: std::shared_ptr + /** + * Specialized version of `std::shared_ptr`. + */ + using std__shared_ptr_HybridTestViewSpec_ = std::shared_ptr; + std::shared_ptr create_std__shared_ptr_HybridTestViewSpec_(void* NON_NULL swiftUnsafePointer) noexcept; + void* NON_NULL get_std__shared_ptr_HybridTestViewSpec_(std__shared_ptr_HybridTestViewSpec_ cppType); + + // pragma MARK: std::weak_ptr + using std__weak_ptr_HybridTestViewSpec_ = std::weak_ptr; + inline std__weak_ptr_HybridTestViewSpec_ weakify_std__shared_ptr_HybridTestViewSpec_(const std::shared_ptr& strong) noexcept { return strong; } + + // pragma MARK: Result + using Result_void_ = Result; + inline Result_void_ create_Result_void_() noexcept { + return Result::withValue(); + } + inline Result_void_ create_Result_void_(const std::exception_ptr& error) noexcept { + return Result::withError(error); + } } // namespace margelo::nitro::test::external::bridge::swift diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/ios/NitroTestExternal-Swift-Cxx-Umbrella.hpp b/packages/react-native-nitro-test-external/nitrogen/generated/ios/NitroTestExternal-Swift-Cxx-Umbrella.hpp index a08536f9e..24c19f2c3 100644 --- a/packages/react-native-nitro-test-external/nitrogen/generated/ios/NitroTestExternal-Swift-Cxx-Umbrella.hpp +++ b/packages/react-native-nitro-test-external/nitrogen/generated/ios/NitroTestExternal-Swift-Cxx-Umbrella.hpp @@ -8,16 +8,26 @@ #pragma once // Forward declarations of C++ defined types +// Forward declaration of `HybridBaseSpec` to properly resolve imports. +namespace margelo::nitro::test::external { class HybridBaseSpec; } +// Forward declaration of `HybridBlaBlaSpec` to properly resolve imports. +namespace margelo::nitro::test::external { class HybridBlaBlaSpec; } // Forward declaration of `HybridSomeExternalObjectSpec` to properly resolve imports. namespace margelo::nitro::test::external { class HybridSomeExternalObjectSpec; } +// Forward declaration of `HybridTestViewSpec` to properly resolve imports. +namespace margelo::nitro::test::external { class HybridTestViewSpec; } // Forward declaration of `OptionalPrimitivesHolder` to properly resolve imports. namespace margelo::nitro::test::external { struct OptionalPrimitivesHolder; } // Include C++ defined types -#include "HybridSomeExternalObjectSpec.hpp" -#include "OptionalPrimitivesHolder.hpp" +#include "NitroTestExternalHybridBaseSpec.hpp" +#include "NitroTestExternalHybridBlaBlaSpec.hpp" +#include "NitroTestExternalHybridSomeExternalObjectSpec.hpp" +#include "NitroTestExternalHybridTestViewSpec.hpp" +#include "NitroTestExternalOptionalPrimitivesHolder.hpp" #include #include +#include #include #include #include @@ -32,8 +42,14 @@ namespace margelo::nitro::test::external { struct OptionalPrimitivesHolder; } #include // Forward declarations of Swift defined types +// Forward declaration of `HybridBaseSpec_cxx` to properly resolve imports. +namespace NitroTestExternal { class HybridBaseSpec_cxx; } +// Forward declaration of `HybridBlaBlaSpec_cxx` to properly resolve imports. +namespace NitroTestExternal { class HybridBlaBlaSpec_cxx; } // Forward declaration of `HybridSomeExternalObjectSpec_cxx` to properly resolve imports. namespace NitroTestExternal { class HybridSomeExternalObjectSpec_cxx; } +// Forward declaration of `HybridTestViewSpec_cxx` to properly resolve imports. +namespace NitroTestExternal { class HybridTestViewSpec_cxx; } // Include Swift defined types #if __has_include("NitroTestExternal-Swift.h") diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/ios/NitroTestExternalAutolinking.mm b/packages/react-native-nitro-test-external/nitrogen/generated/ios/NitroTestExternalAutolinking.mm index af7ce0ece..49325da29 100644 --- a/packages/react-native-nitro-test-external/nitrogen/generated/ios/NitroTestExternalAutolinking.mm +++ b/packages/react-native-nitro-test-external/nitrogen/generated/ios/NitroTestExternalAutolinking.mm @@ -10,7 +10,10 @@ #import "NitroTestExternal-Swift-Cxx-Umbrella.hpp" #import -#include "HybridSomeExternalObjectSpecSwift.hpp" +#include "NitroTestExternalHybridSomeExternalObjectSpecSwift.hpp" +#include "NitroTestExternalHybridBlaBlaSpecSwift.hpp" +#include "NitroTestExternalHybridBaseSpecSwift.hpp" +#include "NitroTestExternalHybridTestViewSpecSwift.hpp" @interface NitroTestExternalAutolinking : NSObject @end @@ -22,12 +25,33 @@ + (void) load { using namespace margelo::nitro::test::external; HybridObjectRegistry::registerHybridObjectConstructor( - "SomeExternalObject", + "NitroTestExternalSomeExternalObject", []() -> std::shared_ptr { std::shared_ptr hybridObject = NitroTestExternal::NitroTestExternalAutolinking::createSomeExternalObject(); return hybridObject; } ); + HybridObjectRegistry::registerHybridObjectConstructor( + "NitroTestExternalBlaBla", + []() -> std::shared_ptr { + std::shared_ptr hybridObject = NitroTestExternal::NitroTestExternalAutolinking::createBlaBla(); + return hybridObject; + } + ); + HybridObjectRegistry::registerHybridObjectConstructor( + "NitroTestExternalBase", + []() -> std::shared_ptr { + std::shared_ptr hybridObject = NitroTestExternal::NitroTestExternalAutolinking::createBase(); + return hybridObject; + } + ); + HybridObjectRegistry::registerHybridObjectConstructor( + "NitroTestExternalTestView", + []() -> std::shared_ptr { + std::shared_ptr hybridObject = NitroTestExternal::NitroTestExternalAutolinking::createTestView(); + return hybridObject; + } + ); } @end diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/ios/NitroTestExternalAutolinking.swift b/packages/react-native-nitro-test-external/nitrogen/generated/ios/NitroTestExternalAutolinking.swift index ac792028a..ac08c3baf 100644 --- a/packages/react-native-nitro-test-external/nitrogen/generated/ios/NitroTestExternalAutolinking.swift +++ b/packages/react-native-nitro-test-external/nitrogen/generated/ios/NitroTestExternalAutolinking.swift @@ -23,4 +23,40 @@ public final class NitroTestExternalAutolinking { public static func isSomeExternalObjectRecyclable() -> Bool { return HybridSomeExternalObject.self is any RecyclableView.Type } + + public static func createBlaBla() -> bridge.std__shared_ptr_HybridBlaBlaSpec_ { + let hybridObject = HybridBlaBla() + return { () -> bridge.std__shared_ptr_HybridBlaBlaSpec_ in + let __cxxWrapped = hybridObject.getCxxWrapper() + return __cxxWrapped.getCxxPart() + }() + } + + public static func isBlaBlaRecyclable() -> Bool { + return HybridBlaBla.self is any RecyclableView.Type + } + + public static func createBase() -> bridge.std__shared_ptr_HybridBaseSpec_ { + let hybridObject = HybridBase() + return { () -> bridge.std__shared_ptr_HybridBaseSpec_ in + let __cxxWrapped = hybridObject.getCxxWrapper() + return __cxxWrapped.getCxxPart() + }() + } + + public static func isBaseRecyclable() -> Bool { + return HybridBase.self is any RecyclableView.Type + } + + public static func createTestView() -> bridge.std__shared_ptr_HybridTestViewSpec_ { + let hybridObject = HybridTestView() + return { () -> bridge.std__shared_ptr_HybridTestViewSpec_ in + let __cxxWrapped = hybridObject.getCxxWrapper() + return __cxxWrapped.getCxxPart() + }() + } + + public static func isTestViewRecyclable() -> Bool { + return HybridTestView.self is any RecyclableView.Type + } } diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/HybridSomeExternalObjectSpecSwift.cpp b/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridBaseSpecSwift.cpp similarity index 71% rename from packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/HybridSomeExternalObjectSpecSwift.cpp rename to packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridBaseSpecSwift.cpp index d5c454d5c..04e527d01 100644 --- a/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/HybridSomeExternalObjectSpecSwift.cpp +++ b/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridBaseSpecSwift.cpp @@ -1,11 +1,11 @@ /// -/// HybridSomeExternalObjectSpecSwift.cpp +/// NitroTestExternalHybridBaseSpecSwift.cpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo /// -#include "HybridSomeExternalObjectSpecSwift.hpp" +#include "NitroTestExternalHybridBaseSpecSwift.hpp" namespace margelo::nitro::test::external { } // namespace margelo::nitro::test::external diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridBaseSpecSwift.hpp b/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridBaseSpecSwift.hpp new file mode 100644 index 000000000..9ef66e259 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridBaseSpecSwift.hpp @@ -0,0 +1,77 @@ +/// +/// NitroTestExternalHybridBaseSpecSwift.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include "NitroTestExternalHybridBaseSpec.hpp" + +// Forward declaration of `HybridBaseSpec_cxx` to properly resolve imports. +namespace NitroTestExternal { class HybridBaseSpec_cxx; } + + + + + +#include "NitroTestExternal-Swift-Cxx-Umbrella.hpp" + +namespace margelo::nitro::test::external { + + /** + * The C++ part of HybridBaseSpec_cxx.swift. + * + * HybridBaseSpecSwift (C++) accesses HybridBaseSpec_cxx (Swift), and might + * contain some additional bridging code for C++ <> Swift interop. + * + * Since this obviously introduces an overhead, I hope at some point in + * the future, HybridBaseSpec_cxx can directly inherit from the C++ class HybridBaseSpec + * to simplify the whole structure and memory management. + */ + class HybridBaseSpecSwift: public virtual HybridBaseSpec { + public: + // Constructor from a Swift instance + explicit HybridBaseSpecSwift(const NitroTestExternal::HybridBaseSpec_cxx& swiftPart): + HybridObject(HybridBaseSpec::TAG), + _swiftPart(swiftPart) { } + + public: + // Get the Swift part + inline NitroTestExternal::HybridBaseSpec_cxx& getSwiftPart() noexcept { + return _swiftPart; + } + + public: + inline size_t getExternalMemorySize() noexcept override { + return _swiftPart.getMemorySize(); + } + bool equals(const std::shared_ptr& other) override { + if (auto otherCast = std::dynamic_pointer_cast(other)) { + return _swiftPart.equals(otherCast->_swiftPart); + } + return false; + } + void dispose() noexcept override { + _swiftPart.dispose(); + } + std::string toString() override { + return _swiftPart.toString(); + } + + public: + // Properties + inline double getAbc() noexcept override { + return _swiftPart.getAbc(); + } + + public: + // Methods + + + private: + NitroTestExternal::HybridBaseSpec_cxx _swiftPart; + }; + +} // namespace margelo::nitro::test::external diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridBlaBlaSpecSwift.cpp b/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridBlaBlaSpecSwift.cpp new file mode 100644 index 000000000..8ef296547 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridBlaBlaSpecSwift.cpp @@ -0,0 +1,11 @@ +/// +/// NitroTestExternalHybridBlaBlaSpecSwift.cpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#include "NitroTestExternalHybridBlaBlaSpecSwift.hpp" + +namespace margelo::nitro::test::external { +} // namespace margelo::nitro::test::external diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridBlaBlaSpecSwift.hpp b/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridBlaBlaSpecSwift.hpp new file mode 100644 index 000000000..41d5ff531 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridBlaBlaSpecSwift.hpp @@ -0,0 +1,84 @@ +/// +/// NitroTestExternalHybridBlaBlaSpecSwift.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include "NitroTestExternalHybridBlaBlaSpec.hpp" + +// Forward declaration of `HybridBlaBlaSpec_cxx` to properly resolve imports. +namespace NitroTestExternal { class HybridBlaBlaSpec_cxx; } + +// Forward declaration of `HybridBaseSpec` to properly resolve imports. +namespace margelo::nitro::test::external { class HybridBaseSpec; } + +#include +#include "NitroTestExternalHybridBaseSpec.hpp" +#include + +#include "NitroTestExternal-Swift-Cxx-Umbrella.hpp" + +namespace margelo::nitro::test::external { + + /** + * The C++ part of HybridBlaBlaSpec_cxx.swift. + * + * HybridBlaBlaSpecSwift (C++) accesses HybridBlaBlaSpec_cxx (Swift), and might + * contain some additional bridging code for C++ <> Swift interop. + * + * Since this obviously introduces an overhead, I hope at some point in + * the future, HybridBlaBlaSpec_cxx can directly inherit from the C++ class HybridBlaBlaSpec + * to simplify the whole structure and memory management. + */ + class HybridBlaBlaSpecSwift: public virtual HybridBlaBlaSpec { + public: + // Constructor from a Swift instance + explicit HybridBlaBlaSpecSwift(const NitroTestExternal::HybridBlaBlaSpec_cxx& swiftPart): + HybridObject(HybridBlaBlaSpec::TAG), + _swiftPart(swiftPart) { } + + public: + // Get the Swift part + inline NitroTestExternal::HybridBlaBlaSpec_cxx& getSwiftPart() noexcept { + return _swiftPart; + } + + public: + inline size_t getExternalMemorySize() noexcept override { + return _swiftPart.getMemorySize(); + } + bool equals(const std::shared_ptr& other) override { + if (auto otherCast = std::dynamic_pointer_cast(other)) { + return _swiftPart.equals(otherCast->_swiftPart); + } + return false; + } + void dispose() noexcept override { + _swiftPart.dispose(); + } + std::string toString() override { + return _swiftPart.toString(); + } + + public: + // Properties + inline std::optional> getBase() noexcept override { + auto __result = _swiftPart.getBase(); + return __result; + } + inline void setBase(const std::optional>& base) noexcept override { + _swiftPart.setBase(base); + } + + public: + // Methods + + + private: + NitroTestExternal::HybridBlaBlaSpec_cxx _swiftPart; + }; + +} // namespace margelo::nitro::test::external diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridSomeExternalObjectSpecSwift.cpp b/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridSomeExternalObjectSpecSwift.cpp new file mode 100644 index 000000000..77ea34d26 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridSomeExternalObjectSpecSwift.cpp @@ -0,0 +1,11 @@ +/// +/// NitroTestExternalHybridSomeExternalObjectSpecSwift.cpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#include "NitroTestExternalHybridSomeExternalObjectSpecSwift.hpp" + +namespace margelo::nitro::test::external { +} // namespace margelo::nitro::test::external diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/HybridSomeExternalObjectSpecSwift.hpp b/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridSomeExternalObjectSpecSwift.hpp similarity index 94% rename from packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/HybridSomeExternalObjectSpecSwift.hpp rename to packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridSomeExternalObjectSpecSwift.hpp index 30ea0e4df..7060cc49c 100644 --- a/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/HybridSomeExternalObjectSpecSwift.hpp +++ b/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridSomeExternalObjectSpecSwift.hpp @@ -1,5 +1,5 @@ /// -/// HybridSomeExternalObjectSpecSwift.hpp +/// NitroTestExternalHybridSomeExternalObjectSpecSwift.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -7,7 +7,7 @@ #pragma once -#include "HybridSomeExternalObjectSpec.hpp" +#include "NitroTestExternalHybridSomeExternalObjectSpec.hpp" // Forward declaration of `HybridSomeExternalObjectSpec_cxx` to properly resolve imports. namespace NitroTestExternal { class HybridSomeExternalObjectSpec_cxx; } @@ -16,7 +16,7 @@ namespace NitroTestExternal { class HybridSomeExternalObjectSpec_cxx; } namespace margelo::nitro::test::external { struct OptionalPrimitivesHolder; } #include -#include "OptionalPrimitivesHolder.hpp" +#include "NitroTestExternalOptionalPrimitivesHolder.hpp" #include #include "NitroTestExternal-Swift-Cxx-Umbrella.hpp" diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridTestViewSpecSwift.cpp b/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridTestViewSpecSwift.cpp new file mode 100644 index 000000000..86fa1568c --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridTestViewSpecSwift.cpp @@ -0,0 +1,11 @@ +/// +/// NitroTestExternalHybridTestViewSpecSwift.cpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#include "NitroTestExternalHybridTestViewSpecSwift.hpp" + +namespace margelo::nitro::test::external { +} // namespace margelo::nitro::test::external diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridTestViewSpecSwift.hpp b/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridTestViewSpecSwift.hpp new file mode 100644 index 000000000..ceb2f7879 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/NitroTestExternalHybridTestViewSpecSwift.hpp @@ -0,0 +1,98 @@ +/// +/// NitroTestExternalHybridTestViewSpecSwift.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include "NitroTestExternalHybridTestViewSpec.hpp" + +// Forward declaration of `HybridTestViewSpec_cxx` to properly resolve imports. +namespace NitroTestExternal { class HybridTestViewSpec_cxx; } + + + +#include + +#include "NitroTestExternal-Swift-Cxx-Umbrella.hpp" + +namespace margelo::nitro::test::external { + + /** + * The C++ part of HybridTestViewSpec_cxx.swift. + * + * HybridTestViewSpecSwift (C++) accesses HybridTestViewSpec_cxx (Swift), and might + * contain some additional bridging code for C++ <> Swift interop. + * + * Since this obviously introduces an overhead, I hope at some point in + * the future, HybridTestViewSpec_cxx can directly inherit from the C++ class HybridTestViewSpec + * to simplify the whole structure and memory management. + */ + class HybridTestViewSpecSwift: public virtual HybridTestViewSpec { + public: + // Constructor from a Swift instance + explicit HybridTestViewSpecSwift(const NitroTestExternal::HybridTestViewSpec_cxx& swiftPart): + HybridObject(HybridTestViewSpec::TAG), + _swiftPart(swiftPart) { } + + public: + // Get the Swift part + inline NitroTestExternal::HybridTestViewSpec_cxx& getSwiftPart() noexcept { + return _swiftPart; + } + + public: + inline size_t getExternalMemorySize() noexcept override { + return _swiftPart.getMemorySize(); + } + bool equals(const std::shared_ptr& other) override { + if (auto otherCast = std::dynamic_pointer_cast(other)) { + return _swiftPart.equals(otherCast->_swiftPart); + } + return false; + } + void dispose() noexcept override { + _swiftPart.dispose(); + } + std::string toString() override { + return _swiftPart.toString(); + } + + public: + // Properties + inline bool getIsCyan() noexcept override { + return _swiftPart.isCyan(); + } + inline void setIsCyan(bool isCyan) noexcept override { + _swiftPart.setIsCyan(std::forward(isCyan)); + } + inline bool getHasBeenCalled() noexcept override { + return _swiftPart.hasBeenCalled(); + } + inline void setHasBeenCalled(bool hasBeenCalled) noexcept override { + _swiftPart.setHasBeenCalled(std::forward(hasBeenCalled)); + } + inline std::function getTestCallback() noexcept override { + auto __result = _swiftPart.getTestCallback(); + return __result; + } + inline void setTestCallback(const std::function& testCallback) noexcept override { + _swiftPart.setTestCallback(testCallback); + } + + public: + // Methods + inline void testMethod() override { + auto __result = _swiftPart.testMethod(); + if (__result.hasError()) [[unlikely]] { + std::rethrow_exception(__result.error()); + } + } + + private: + NitroTestExternal::HybridTestViewSpec_cxx _swiftPart; + }; + +} // namespace margelo::nitro::test::external diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/views/NitroTestExternalHybridTestViewComponent.mm b/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/views/NitroTestExternalHybridTestViewComponent.mm new file mode 100644 index 000000000..d5b02777c --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/ios/c++/views/NitroTestExternalHybridTestViewComponent.mm @@ -0,0 +1,132 @@ +/// +/// NitroTestExternalHybridTestViewComponent.mm +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#import "NitroTestExternalHybridTestViewComponent.hpp" +#import +#import +#import +#import +#import +#import +#import + +#import "NitroTestExternalHybridTestViewSpecSwift.hpp" +#import "NitroTestExternal-Swift-Cxx-Umbrella.hpp" + +#if __has_include() +#include +#if REACT_NATIVE_VERSION_MINOR >= 82 +#define ENABLE_RCT_COMPONENT_VIEW_INVALIDATE +#endif +#endif + +using namespace facebook; +using namespace margelo::nitro::test::external; +using namespace margelo::nitro::test::external::views; + +/** + * Represents the React Native View holder for the Nitro "TestView" HybridView. + */ +@interface NitroTestExternalHybridTestViewComponent: RCTViewComponentView ++ (BOOL)shouldBeRecycled; +@end + +@implementation NitroTestExternalHybridTestViewComponent { + std::shared_ptr _hybridView; +} + ++ (void) load { + [super load]; + [RCTComponentViewFactory.currentComponentViewFactory registerComponentViewClass:[NitroTestExternalHybridTestViewComponent class]]; +} + ++ (react::ComponentDescriptorProvider) componentDescriptorProvider { + return react::concreteComponentDescriptorProvider(); +} + +- (instancetype) init { + if (self = [super init]) { + std::shared_ptr hybridView = NitroTestExternal::NitroTestExternalAutolinking::createTestView(); + _hybridView = std::dynamic_pointer_cast(hybridView); + [self updateView]; + } + return self; +} + +- (void) updateView { + // 1. Get Swift part + NitroTestExternal::HybridTestViewSpec_cxx& swiftPart = _hybridView->getSwiftPart(); + + // 2. Get UIView* + void* viewUnsafe = swiftPart.getView(); + UIView* view = (__bridge_transfer UIView*) viewUnsafe; + + // 3. Update RCTViewComponentView's [contentView] + [self setContentView:view]; +} + +- (void) updateProps:(const std::shared_ptr&)props + oldProps:(const std::shared_ptr&)oldProps { + // 1. Downcast props + const auto& newViewPropsConst = *std::static_pointer_cast(props); + auto& newViewProps = const_cast(newViewPropsConst); + NitroTestExternal::HybridTestViewSpec_cxx& swiftPart = _hybridView->getSwiftPart(); + + // 2. Update each prop individually + swiftPart.beforeUpdate(); + + // isCyan: boolean + if (newViewProps.isCyan.isDirty) { + swiftPart.setIsCyan(newViewProps.isCyan.value); + newViewProps.isCyan.isDirty = false; + } + // hasBeenCalled: boolean + if (newViewProps.hasBeenCalled.isDirty) { + swiftPart.setHasBeenCalled(newViewProps.hasBeenCalled.value); + newViewProps.hasBeenCalled.isDirty = false; + } + // testCallback: function + if (newViewProps.testCallback.isDirty) { + swiftPart.setTestCallback(newViewProps.testCallback.value); + newViewProps.testCallback.isDirty = false; + } + + swiftPart.afterUpdate(); + + // 3. Update hybridRef if it changed + if (newViewProps.hybridRef.isDirty) { + // hybridRef changed - call it with new this + const auto& maybeFunc = newViewProps.hybridRef.value; + if (maybeFunc.has_value()) { + maybeFunc.value()(_hybridView); + } + newViewProps.hybridRef.isDirty = false; + } + + // 4. Continue in base class + [super updateProps:props oldProps:oldProps]; +} + ++ (BOOL)shouldBeRecycled { + return NitroTestExternal::NitroTestExternalAutolinking::isTestViewRecyclable(); +} + +- (void)prepareForRecycle { + [super prepareForRecycle]; + NitroTestExternal::HybridTestViewSpec_cxx& swiftPart = _hybridView->getSwiftPart(); + swiftPart.maybePrepareForRecycle(); +} + +#ifdef ENABLE_RCT_COMPONENT_VIEW_INVALIDATE +- (void)invalidate { + NitroTestExternal::HybridTestViewSpec_cxx& swiftPart = _hybridView->getSwiftPart(); + swiftPart.onDropView(); + [super invalidate]; +} +#endif + +@end diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/Func_void.swift b/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/Func_void.swift new file mode 100644 index 000000000..6a489e3bc --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/Func_void.swift @@ -0,0 +1,46 @@ +/// +/// Func_void.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * Wraps a Swift `() -> Void` as a class. + * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`. + */ +public final class Func_void { + public typealias bridge = margelo.nitro.test.external.bridge.swift + + private let closure: () -> Void + + public init(_ closure: @escaping () -> Void) { + self.closure = closure + } + + @inline(__always) + public func call() -> Void { + self.closure() + } + + /** + * Casts this instance to a retained unsafe raw pointer. + * This acquires one additional strong reference on the object! + */ + @inline(__always) + public func toUnsafe() -> UnsafeMutableRawPointer { + return Unmanaged.passRetained(self).toOpaque() + } + + /** + * Casts an unsafe pointer to a `Func_void`. + * The pointer has to be a retained opaque `Unmanaged`. + * This removes one strong reference from the object! + */ + @inline(__always) + public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void { + return Unmanaged.fromOpaque(pointer).takeRetainedValue() + } +} diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/HybridBaseSpec.swift b/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/HybridBaseSpec.swift new file mode 100644 index 000000000..df5b80230 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/HybridBaseSpec.swift @@ -0,0 +1,55 @@ +/// +/// HybridBaseSpec.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +import NitroModules + +/// See ``HybridBaseSpec`` +public protocol HybridBaseSpec_protocol: HybridObject { + // Properties + var abc: Double { get } + + // Methods + +} + +public extension HybridBaseSpec_protocol { + /// Default implementation of ``HybridObject.toString`` + func toString() -> String { + return "[HybridObject NitroTestExternalBase]" + } +} + +/// See ``HybridBaseSpec`` +open class HybridBaseSpec_base { + private weak var cxxWrapper: HybridBaseSpec_cxx? = nil + public init() { } + public func getCxxWrapper() -> HybridBaseSpec_cxx { + #if DEBUG + guard self is any HybridBaseSpec else { + fatalError("`self` is not a `HybridBaseSpec`! Did you accidentally inherit from `HybridBaseSpec_base` instead of `HybridBaseSpec`?") + } + #endif + if let cxxWrapper = self.cxxWrapper { + return cxxWrapper + } else { + let cxxWrapper = HybridBaseSpec_cxx(self as! any HybridBaseSpec) + self.cxxWrapper = cxxWrapper + return cxxWrapper + } + } +} + +/** + * A Swift base-protocol representing the Base HybridObject. + * Implement this protocol to create Swift-based instances of Base. + * ```swift + * class HybridBase : HybridBaseSpec { + * // ... + * } + * ``` + */ +public typealias HybridBaseSpec = HybridBaseSpec_protocol & HybridBaseSpec_base diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/HybridBaseSpec_cxx.swift b/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/HybridBaseSpec_cxx.swift new file mode 100644 index 000000000..e050d6285 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/HybridBaseSpec_cxx.swift @@ -0,0 +1,133 @@ +/// +/// HybridBaseSpec_cxx.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * A class implementation that bridges HybridBaseSpec over to C++. + * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined. + * + * Also, some Swift types need to be bridged with special handling: + * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330) + * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper + * - Throwing methods need to be wrapped with a Result type, as exceptions cannot be propagated to C++ + */ +open class HybridBaseSpec_cxx { + /** + * The Swift <> C++ bridge's namespace (`margelo::nitro::test::external::bridge::swift`) + * from `NitroTestExternal-Swift-Cxx-Bridge.hpp`. + * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift. + */ + public typealias bridge = margelo.nitro.test.external.bridge.swift + + /** + * Holds an instance of the `HybridBaseSpec` Swift protocol. + */ + private var __implementation: any HybridBaseSpec + + /** + * Holds a weak pointer to the C++ class that wraps the Swift class. + */ + private var __cxxPart: bridge.std__weak_ptr_HybridBaseSpec_ + + /** + * Create a new `HybridBaseSpec_cxx` that wraps the given `HybridBaseSpec`. + * All properties and methods bridge to C++ types. + */ + public init(_ implementation: any HybridBaseSpec) { + self.__implementation = implementation + self.__cxxPart = .init() + /* no base class */ + } + + /** + * Get the actual `HybridBaseSpec` instance this class wraps. + */ + @inline(__always) + public func getHybridBaseSpec() -> any HybridBaseSpec { + return __implementation + } + + /** + * Casts this instance to a retained unsafe raw pointer. + * This acquires one additional strong reference on the object! + */ + public func toUnsafe() -> UnsafeMutableRawPointer { + return Unmanaged.passRetained(self).toOpaque() + } + + /** + * Casts an unsafe pointer to a `HybridBaseSpec_cxx`. + * The pointer has to be a retained opaque `Unmanaged`. + * This removes one strong reference from the object! + */ + public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridBaseSpec_cxx { + return Unmanaged.fromOpaque(pointer).takeRetainedValue() + } + + /** + * Gets (or creates) the C++ part of this Hybrid Object. + * The C++ part is a `std::shared_ptr`. + */ + public func getCxxPart() -> bridge.std__shared_ptr_HybridBaseSpec_ { + let cachedCxxPart = self.__cxxPart.lock() + if Bool(fromCxx: cachedCxxPart) { + return cachedCxxPart + } else { + let newCxxPart = bridge.create_std__shared_ptr_HybridBaseSpec_(self.toUnsafe()) + __cxxPart = bridge.weakify_std__shared_ptr_HybridBaseSpec_(newCxxPart) + return newCxxPart + } + } + + + + /** + * Get the memory size of the Swift class (plus size of any other allocations) + * so the JS VM can properly track it and garbage-collect the JS object if needed. + */ + @inline(__always) + public var memorySize: Int { + return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize + } + + /** + * Compares this object with the given [other] object for reference equality. + */ + @inline(__always) + public func equals(other: HybridBaseSpec_cxx) -> Bool { + return self.__implementation === other.__implementation + } + + /** + * Call dispose() on the Swift class. + * This _may_ be called manually from JS. + */ + @inline(__always) + public func dispose() { + self.__implementation.dispose() + } + + /** + * Call toString() on the Swift class. + */ + @inline(__always) + public func toString() -> String { + return self.__implementation.toString() + } + + // Properties + public final var abc: Double { + @inline(__always) + get { + return self.__implementation.abc + } + } + + // Methods + +} diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/HybridBlaBlaSpec.swift b/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/HybridBlaBlaSpec.swift new file mode 100644 index 000000000..912527ad0 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/HybridBlaBlaSpec.swift @@ -0,0 +1,55 @@ +/// +/// HybridBlaBlaSpec.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +import NitroModules + +/// See ``HybridBlaBlaSpec`` +public protocol HybridBlaBlaSpec_protocol: HybridObject { + // Properties + var base: (any HybridBaseSpec)? { get set } + + // Methods + +} + +public extension HybridBlaBlaSpec_protocol { + /// Default implementation of ``HybridObject.toString`` + func toString() -> String { + return "[HybridObject NitroTestExternalBlaBla]" + } +} + +/// See ``HybridBlaBlaSpec`` +open class HybridBlaBlaSpec_base { + private weak var cxxWrapper: HybridBlaBlaSpec_cxx? = nil + public init() { } + public func getCxxWrapper() -> HybridBlaBlaSpec_cxx { + #if DEBUG + guard self is any HybridBlaBlaSpec else { + fatalError("`self` is not a `HybridBlaBlaSpec`! Did you accidentally inherit from `HybridBlaBlaSpec_base` instead of `HybridBlaBlaSpec`?") + } + #endif + if let cxxWrapper = self.cxxWrapper { + return cxxWrapper + } else { + let cxxWrapper = HybridBlaBlaSpec_cxx(self as! any HybridBlaBlaSpec) + self.cxxWrapper = cxxWrapper + return cxxWrapper + } + } +} + +/** + * A Swift base-protocol representing the BlaBla HybridObject. + * Implement this protocol to create Swift-based instances of BlaBla. + * ```swift + * class HybridBlaBla : HybridBlaBlaSpec { + * // ... + * } + * ``` + */ +public typealias HybridBlaBlaSpec = HybridBlaBlaSpec_protocol & HybridBlaBlaSpec_base diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/HybridBlaBlaSpec_cxx.swift b/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/HybridBlaBlaSpec_cxx.swift new file mode 100644 index 000000000..ce895b2c0 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/HybridBlaBlaSpec_cxx.swift @@ -0,0 +1,157 @@ +/// +/// HybridBlaBlaSpec_cxx.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * A class implementation that bridges HybridBlaBlaSpec over to C++. + * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined. + * + * Also, some Swift types need to be bridged with special handling: + * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330) + * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper + * - Throwing methods need to be wrapped with a Result type, as exceptions cannot be propagated to C++ + */ +open class HybridBlaBlaSpec_cxx { + /** + * The Swift <> C++ bridge's namespace (`margelo::nitro::test::external::bridge::swift`) + * from `NitroTestExternal-Swift-Cxx-Bridge.hpp`. + * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift. + */ + public typealias bridge = margelo.nitro.test.external.bridge.swift + + /** + * Holds an instance of the `HybridBlaBlaSpec` Swift protocol. + */ + private var __implementation: any HybridBlaBlaSpec + + /** + * Holds a weak pointer to the C++ class that wraps the Swift class. + */ + private var __cxxPart: bridge.std__weak_ptr_HybridBlaBlaSpec_ + + /** + * Create a new `HybridBlaBlaSpec_cxx` that wraps the given `HybridBlaBlaSpec`. + * All properties and methods bridge to C++ types. + */ + public init(_ implementation: any HybridBlaBlaSpec) { + self.__implementation = implementation + self.__cxxPart = .init() + /* no base class */ + } + + /** + * Get the actual `HybridBlaBlaSpec` instance this class wraps. + */ + @inline(__always) + public func getHybridBlaBlaSpec() -> any HybridBlaBlaSpec { + return __implementation + } + + /** + * Casts this instance to a retained unsafe raw pointer. + * This acquires one additional strong reference on the object! + */ + public func toUnsafe() -> UnsafeMutableRawPointer { + return Unmanaged.passRetained(self).toOpaque() + } + + /** + * Casts an unsafe pointer to a `HybridBlaBlaSpec_cxx`. + * The pointer has to be a retained opaque `Unmanaged`. + * This removes one strong reference from the object! + */ + public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridBlaBlaSpec_cxx { + return Unmanaged.fromOpaque(pointer).takeRetainedValue() + } + + /** + * Gets (or creates) the C++ part of this Hybrid Object. + * The C++ part is a `std::shared_ptr`. + */ + public func getCxxPart() -> bridge.std__shared_ptr_HybridBlaBlaSpec_ { + let cachedCxxPart = self.__cxxPart.lock() + if Bool(fromCxx: cachedCxxPart) { + return cachedCxxPart + } else { + let newCxxPart = bridge.create_std__shared_ptr_HybridBlaBlaSpec_(self.toUnsafe()) + __cxxPart = bridge.weakify_std__shared_ptr_HybridBlaBlaSpec_(newCxxPart) + return newCxxPart + } + } + + + + /** + * Get the memory size of the Swift class (plus size of any other allocations) + * so the JS VM can properly track it and garbage-collect the JS object if needed. + */ + @inline(__always) + public var memorySize: Int { + return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize + } + + /** + * Compares this object with the given [other] object for reference equality. + */ + @inline(__always) + public func equals(other: HybridBlaBlaSpec_cxx) -> Bool { + return self.__implementation === other.__implementation + } + + /** + * Call dispose() on the Swift class. + * This _may_ be called manually from JS. + */ + @inline(__always) + public func dispose() { + self.__implementation.dispose() + } + + /** + * Call toString() on the Swift class. + */ + @inline(__always) + public func toString() -> String { + return self.__implementation.toString() + } + + // Properties + public final var base: bridge.std__optional_std__shared_ptr_HybridBaseSpec__ { + @inline(__always) + get { + return { () -> bridge.std__optional_std__shared_ptr_HybridBaseSpec__ in + if let __unwrappedValue = self.__implementation.base { + return bridge.create_std__optional_std__shared_ptr_HybridBaseSpec__({ () -> bridge.std__shared_ptr_HybridBaseSpec_ in + let __cxxWrapped = __unwrappedValue.getCxxWrapper() + return __cxxWrapped.getCxxPart() + }()) + } else { + return .init() + } + }() + } + @inline(__always) + set { + self.__implementation.base = { () -> (any HybridBaseSpec)? in + if bridge.has_value_std__optional_std__shared_ptr_HybridBaseSpec__(newValue) { + let __unwrapped = bridge.get_std__optional_std__shared_ptr_HybridBaseSpec__(newValue) + return { () -> any HybridBaseSpec in + let __unsafePointer = bridge.get_std__shared_ptr_HybridBaseSpec_(__unwrapped) + let __instance = HybridBaseSpec_cxx.fromUnsafe(__unsafePointer) + return __instance.getHybridBaseSpec() + }() + } else { + return nil + } + }() + } + } + + // Methods + +} diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/HybridSomeExternalObjectSpec.swift b/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/HybridSomeExternalObjectSpec.swift index df2329ca5..3a6fa655a 100644 --- a/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/HybridSomeExternalObjectSpec.swift +++ b/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/HybridSomeExternalObjectSpec.swift @@ -20,7 +20,7 @@ public protocol HybridSomeExternalObjectSpec_protocol: HybridObject { public extension HybridSomeExternalObjectSpec_protocol { /// Default implementation of ``HybridObject.toString`` func toString() -> String { - return "[HybridObject SomeExternalObject]" + return "[HybridObject NitroTestExternalSomeExternalObject]" } } diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/HybridTestViewSpec.swift b/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/HybridTestViewSpec.swift new file mode 100644 index 000000000..2ab1f4bb8 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/HybridTestViewSpec.swift @@ -0,0 +1,57 @@ +/// +/// HybridTestViewSpec.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +import NitroModules + +/// See ``HybridTestViewSpec`` +public protocol HybridTestViewSpec_protocol: HybridObject, HybridView { + // Properties + var isCyan: Bool { get set } + var hasBeenCalled: Bool { get set } + var testCallback: () -> Void { get set } + + // Methods + func testMethod() throws -> Void +} + +public extension HybridTestViewSpec_protocol { + /// Default implementation of ``HybridObject.toString`` + func toString() -> String { + return "[HybridObject NitroTestExternalTestView]" + } +} + +/// See ``HybridTestViewSpec`` +open class HybridTestViewSpec_base { + private weak var cxxWrapper: HybridTestViewSpec_cxx? = nil + public init() { } + public func getCxxWrapper() -> HybridTestViewSpec_cxx { + #if DEBUG + guard self is any HybridTestViewSpec else { + fatalError("`self` is not a `HybridTestViewSpec`! Did you accidentally inherit from `HybridTestViewSpec_base` instead of `HybridTestViewSpec`?") + } + #endif + if let cxxWrapper = self.cxxWrapper { + return cxxWrapper + } else { + let cxxWrapper = HybridTestViewSpec_cxx(self as! any HybridTestViewSpec) + self.cxxWrapper = cxxWrapper + return cxxWrapper + } + } +} + +/** + * A Swift base-protocol representing the TestView HybridObject. + * Implement this protocol to create Swift-based instances of TestView. + * ```swift + * class HybridTestView : HybridTestViewSpec { + * // ... + * } + * ``` + */ +public typealias HybridTestViewSpec = HybridTestViewSpec_protocol & HybridTestViewSpec_base diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/HybridTestViewSpec_cxx.swift b/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/HybridTestViewSpec_cxx.swift new file mode 100644 index 000000000..c71f31196 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/ios/swift/HybridTestViewSpec_cxx.swift @@ -0,0 +1,197 @@ +/// +/// HybridTestViewSpec_cxx.swift +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +import NitroModules + +/** + * A class implementation that bridges HybridTestViewSpec over to C++. + * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined. + * + * Also, some Swift types need to be bridged with special handling: + * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330) + * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper + * - Throwing methods need to be wrapped with a Result type, as exceptions cannot be propagated to C++ + */ +open class HybridTestViewSpec_cxx { + /** + * The Swift <> C++ bridge's namespace (`margelo::nitro::test::external::bridge::swift`) + * from `NitroTestExternal-Swift-Cxx-Bridge.hpp`. + * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift. + */ + public typealias bridge = margelo.nitro.test.external.bridge.swift + + /** + * Holds an instance of the `HybridTestViewSpec` Swift protocol. + */ + private var __implementation: any HybridTestViewSpec + + /** + * Holds a weak pointer to the C++ class that wraps the Swift class. + */ + private var __cxxPart: bridge.std__weak_ptr_HybridTestViewSpec_ + + /** + * Create a new `HybridTestViewSpec_cxx` that wraps the given `HybridTestViewSpec`. + * All properties and methods bridge to C++ types. + */ + public init(_ implementation: any HybridTestViewSpec) { + self.__implementation = implementation + self.__cxxPart = .init() + /* no base class */ + } + + /** + * Get the actual `HybridTestViewSpec` instance this class wraps. + */ + @inline(__always) + public func getHybridTestViewSpec() -> any HybridTestViewSpec { + return __implementation + } + + /** + * Casts this instance to a retained unsafe raw pointer. + * This acquires one additional strong reference on the object! + */ + public func toUnsafe() -> UnsafeMutableRawPointer { + return Unmanaged.passRetained(self).toOpaque() + } + + /** + * Casts an unsafe pointer to a `HybridTestViewSpec_cxx`. + * The pointer has to be a retained opaque `Unmanaged`. + * This removes one strong reference from the object! + */ + public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridTestViewSpec_cxx { + return Unmanaged.fromOpaque(pointer).takeRetainedValue() + } + + /** + * Gets (or creates) the C++ part of this Hybrid Object. + * The C++ part is a `std::shared_ptr`. + */ + public func getCxxPart() -> bridge.std__shared_ptr_HybridTestViewSpec_ { + let cachedCxxPart = self.__cxxPart.lock() + if Bool(fromCxx: cachedCxxPart) { + return cachedCxxPart + } else { + let newCxxPart = bridge.create_std__shared_ptr_HybridTestViewSpec_(self.toUnsafe()) + __cxxPart = bridge.weakify_std__shared_ptr_HybridTestViewSpec_(newCxxPart) + return newCxxPart + } + } + + + + /** + * Get the memory size of the Swift class (plus size of any other allocations) + * so the JS VM can properly track it and garbage-collect the JS object if needed. + */ + @inline(__always) + public var memorySize: Int { + return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize + } + + /** + * Compares this object with the given [other] object for reference equality. + */ + @inline(__always) + public func equals(other: HybridTestViewSpec_cxx) -> Bool { + return self.__implementation === other.__implementation + } + + /** + * Call dispose() on the Swift class. + * This _may_ be called manually from JS. + */ + @inline(__always) + public func dispose() { + self.__implementation.dispose() + } + + /** + * Call toString() on the Swift class. + */ + @inline(__always) + public func toString() -> String { + return self.__implementation.toString() + } + + // Properties + public final var isCyan: Bool { + @inline(__always) + get { + return self.__implementation.isCyan + } + @inline(__always) + set { + self.__implementation.isCyan = newValue + } + } + + public final var hasBeenCalled: Bool { + @inline(__always) + get { + return self.__implementation.hasBeenCalled + } + @inline(__always) + set { + self.__implementation.hasBeenCalled = newValue + } + } + + public final var testCallback: bridge.Func_void { + @inline(__always) + get { + return { () -> bridge.Func_void in + let __closureWrapper = Func_void(self.__implementation.testCallback) + return bridge.create_Func_void(__closureWrapper.toUnsafe()) + }() + } + @inline(__always) + set { + self.__implementation.testCallback = { () -> () -> Void in + let __wrappedFunction = bridge.wrap_Func_void(newValue) + return { () -> Void in + __wrappedFunction.call() + } + }() + } + } + + // Methods + @inline(__always) + public final func testMethod() -> bridge.Result_void_ { + do { + try self.__implementation.testMethod() + return bridge.create_Result_void_() + } catch (let __error) { + let __exceptionPtr = __error.toCpp() + return bridge.create_Result_void_(__exceptionPtr) + } + } + + public final func getView() -> UnsafeMutableRawPointer { + return Unmanaged.passRetained(__implementation.view).toOpaque() + } + + public final func beforeUpdate() { + __implementation.beforeUpdate() + } + + public final func afterUpdate() { + __implementation.afterUpdate() + } + + public final func maybePrepareForRecycle() { + guard let recyclable = __implementation as? any RecyclableView else { return } + recyclable.prepareForRecycle() + } + + public final func onDropView() { + __implementation.onDropView() + } +} diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridBaseSpec.cpp b/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridBaseSpec.cpp new file mode 100644 index 000000000..793387dde --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridBaseSpec.cpp @@ -0,0 +1,21 @@ +/// +/// NitroTestExternalHybridBaseSpec.cpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#include "NitroTestExternalHybridBaseSpec.hpp" + +namespace margelo::nitro::test::external { + + void HybridBaseSpec::loadHybridMethods() { + // load base methods/properties + HybridObject::loadHybridMethods(); + // load custom methods/properties + registerHybrids(this, [](Prototype& prototype) { + prototype.registerHybridGetter("abc", &HybridBaseSpec::getAbc); + }); + } + +} // namespace margelo::nitro::test::external diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridBaseSpec.hpp b/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridBaseSpec.hpp new file mode 100644 index 000000000..51e4ff8d2 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridBaseSpec.hpp @@ -0,0 +1,62 @@ +/// +/// NitroTestExternalHybridBaseSpec.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + + + + + +namespace margelo::nitro::test::external { + + using namespace margelo::nitro; + + /** + * An abstract base class for `Base` + * Inherit this class to create instances of `HybridBaseSpec` in C++. + * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual. + * @example + * ```cpp + * class HybridBase: public HybridBaseSpec { + * public: + * HybridBase(...): HybridObject(TAG) { ... } + * // ... + * }; + * ``` + */ + class HybridBaseSpec: public virtual HybridObject { + public: + // Constructor + explicit HybridBaseSpec(): HybridObject(TAG) { } + + // Destructor + ~HybridBaseSpec() override = default; + + public: + // Properties + virtual double getAbc() = 0; + + public: + // Methods + + + protected: + // Hybrid Setup + void loadHybridMethods() override; + + protected: + // Tag for logging + static constexpr auto TAG = "NitroTestExternalBase"; + }; + +} // namespace margelo::nitro::test::external diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridBlaBlaSpec.cpp b/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridBlaBlaSpec.cpp new file mode 100644 index 000000000..e0706f8e2 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridBlaBlaSpec.cpp @@ -0,0 +1,22 @@ +/// +/// NitroTestExternalHybridBlaBlaSpec.cpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#include "NitroTestExternalHybridBlaBlaSpec.hpp" + +namespace margelo::nitro::test::external { + + void HybridBlaBlaSpec::loadHybridMethods() { + // load base methods/properties + HybridObject::loadHybridMethods(); + // load custom methods/properties + registerHybrids(this, [](Prototype& prototype) { + prototype.registerHybridGetter("base", &HybridBlaBlaSpec::getBase); + prototype.registerHybridSetter("base", &HybridBlaBlaSpec::setBase); + }); + } + +} // namespace margelo::nitro::test::external diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridBlaBlaSpec.hpp b/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridBlaBlaSpec.hpp new file mode 100644 index 000000000..980880cdc --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridBlaBlaSpec.hpp @@ -0,0 +1,66 @@ +/// +/// NitroTestExternalHybridBlaBlaSpec.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + +// Forward declaration of `HybridBaseSpec` to properly resolve imports. +namespace margelo::nitro::test::external { class HybridBaseSpec; } + +#include +#include "NitroTestExternalHybridBaseSpec.hpp" +#include + +namespace margelo::nitro::test::external { + + using namespace margelo::nitro; + + /** + * An abstract base class for `BlaBla` + * Inherit this class to create instances of `HybridBlaBlaSpec` in C++. + * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual. + * @example + * ```cpp + * class HybridBlaBla: public HybridBlaBlaSpec { + * public: + * HybridBlaBla(...): HybridObject(TAG) { ... } + * // ... + * }; + * ``` + */ + class HybridBlaBlaSpec: public virtual HybridObject { + public: + // Constructor + explicit HybridBlaBlaSpec(): HybridObject(TAG) { } + + // Destructor + ~HybridBlaBlaSpec() override = default; + + public: + // Properties + virtual std::optional> getBase() = 0; + virtual void setBase(const std::optional>& base) = 0; + + public: + // Methods + + + protected: + // Hybrid Setup + void loadHybridMethods() override; + + protected: + // Tag for logging + static constexpr auto TAG = "NitroTestExternalBlaBla"; + }; + +} // namespace margelo::nitro::test::external diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/HybridSomeExternalObjectSpec.cpp b/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridSomeExternalObjectSpec.cpp similarity index 86% rename from packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/HybridSomeExternalObjectSpec.cpp rename to packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridSomeExternalObjectSpec.cpp index fbde40425..8e66b5918 100644 --- a/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/HybridSomeExternalObjectSpec.cpp +++ b/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridSomeExternalObjectSpec.cpp @@ -1,11 +1,11 @@ /// -/// HybridSomeExternalObjectSpec.cpp +/// NitroTestExternalHybridSomeExternalObjectSpec.cpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo /// -#include "HybridSomeExternalObjectSpec.hpp" +#include "NitroTestExternalHybridSomeExternalObjectSpec.hpp" namespace margelo::nitro::test::external { diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/HybridSomeExternalObjectSpec.hpp b/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridSomeExternalObjectSpec.hpp similarity index 90% rename from packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/HybridSomeExternalObjectSpec.hpp rename to packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridSomeExternalObjectSpec.hpp index 8f24ffe41..c3e3d7b2d 100644 --- a/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/HybridSomeExternalObjectSpec.hpp +++ b/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridSomeExternalObjectSpec.hpp @@ -1,5 +1,5 @@ /// -/// HybridSomeExternalObjectSpec.hpp +/// NitroTestExternalHybridSomeExternalObjectSpec.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -17,7 +17,7 @@ namespace margelo::nitro::test::external { struct OptionalPrimitivesHolder; } #include -#include "OptionalPrimitivesHolder.hpp" +#include "NitroTestExternalOptionalPrimitivesHolder.hpp" #include namespace margelo::nitro::test::external { @@ -60,7 +60,7 @@ namespace margelo::nitro::test::external { protected: // Tag for logging - static constexpr auto TAG = "SomeExternalObject"; + static constexpr auto TAG = "NitroTestExternalSomeExternalObject"; }; } // namespace margelo::nitro::test::external diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridTestViewSpec.cpp b/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridTestViewSpec.cpp new file mode 100644 index 000000000..b1435c7ea --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridTestViewSpec.cpp @@ -0,0 +1,27 @@ +/// +/// NitroTestExternalHybridTestViewSpec.cpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#include "NitroTestExternalHybridTestViewSpec.hpp" + +namespace margelo::nitro::test::external { + + void HybridTestViewSpec::loadHybridMethods() { + // load base methods/properties + HybridObject::loadHybridMethods(); + // load custom methods/properties + registerHybrids(this, [](Prototype& prototype) { + prototype.registerHybridGetter("isCyan", &HybridTestViewSpec::getIsCyan); + prototype.registerHybridSetter("isCyan", &HybridTestViewSpec::setIsCyan); + prototype.registerHybridGetter("hasBeenCalled", &HybridTestViewSpec::getHasBeenCalled); + prototype.registerHybridSetter("hasBeenCalled", &HybridTestViewSpec::setHasBeenCalled); + prototype.registerHybridGetter("testCallback", &HybridTestViewSpec::getTestCallback); + prototype.registerHybridSetter("testCallback", &HybridTestViewSpec::setTestCallback); + prototype.registerHybridMethod("testMethod", &HybridTestViewSpec::testMethod); + }); + } + +} // namespace margelo::nitro::test::external diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridTestViewSpec.hpp b/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridTestViewSpec.hpp new file mode 100644 index 000000000..493cbf5af --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalHybridTestViewSpec.hpp @@ -0,0 +1,67 @@ +/// +/// NitroTestExternalHybridTestViewSpec.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + + + +#include + +namespace margelo::nitro::test::external { + + using namespace margelo::nitro; + + /** + * An abstract base class for `TestView` + * Inherit this class to create instances of `HybridTestViewSpec` in C++. + * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual. + * @example + * ```cpp + * class HybridTestView: public HybridTestViewSpec { + * public: + * HybridTestView(...): HybridObject(TAG) { ... } + * // ... + * }; + * ``` + */ + class HybridTestViewSpec: public virtual HybridObject { + public: + // Constructor + explicit HybridTestViewSpec(): HybridObject(TAG) { } + + // Destructor + ~HybridTestViewSpec() override = default; + + public: + // Properties + virtual bool getIsCyan() = 0; + virtual void setIsCyan(bool isCyan) = 0; + virtual bool getHasBeenCalled() = 0; + virtual void setHasBeenCalled(bool hasBeenCalled) = 0; + virtual std::function getTestCallback() = 0; + virtual void setTestCallback(const std::function& testCallback) = 0; + + public: + // Methods + virtual void testMethod() = 0; + + protected: + // Hybrid Setup + void loadHybridMethods() override; + + protected: + // Tag for logging + static constexpr auto TAG = "NitroTestExternalTestView"; + }; + +} // namespace margelo::nitro::test::external diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/OptionalPrimitivesHolder.hpp b/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalOptionalPrimitivesHolder.hpp similarity index 98% rename from packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/OptionalPrimitivesHolder.hpp rename to packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalOptionalPrimitivesHolder.hpp index 8175fa6d1..c8d69b3b8 100644 --- a/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/OptionalPrimitivesHolder.hpp +++ b/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/NitroTestExternalOptionalPrimitivesHolder.hpp @@ -1,5 +1,5 @@ /// -/// OptionalPrimitivesHolder.hpp +/// NitroTestExternalOptionalPrimitivesHolder.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/views/NitroTestExternalHybridTestViewComponent.cpp b/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/views/NitroTestExternalHybridTestViewComponent.cpp new file mode 100644 index 000000000..8bfdb4a63 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/views/NitroTestExternalHybridTestViewComponent.cpp @@ -0,0 +1,105 @@ +/// +/// NitroTestExternalHybridTestViewComponent.cpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#include "NitroTestExternalHybridTestViewComponent.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace margelo::nitro::test::external::views { + + extern const char HybridTestViewComponentName[] = "NitroTestExternalTestView"; + + HybridTestViewProps::HybridTestViewProps(const react::PropsParserContext& context, + const HybridTestViewProps& sourceProps, + const react::RawProps& rawProps): + react::ViewProps(context, sourceProps, rawProps, filterObjectKeys), + isCyan([&]() -> CachedProp { + try { + const react::RawValue* rawValue = rawProps.at("isCyan", nullptr, nullptr); + if (rawValue == nullptr) return sourceProps.isCyan; + const auto& [runtime, value] = (std::pair)*rawValue; + return CachedProp::fromRawValue(*runtime, value, sourceProps.isCyan); + } catch (const std::exception& exc) { + throw std::runtime_error(std::string("TestView.isCyan: ") + exc.what()); + } + }()), + hasBeenCalled([&]() -> CachedProp { + try { + const react::RawValue* rawValue = rawProps.at("hasBeenCalled", nullptr, nullptr); + if (rawValue == nullptr) return sourceProps.hasBeenCalled; + const auto& [runtime, value] = (std::pair)*rawValue; + return CachedProp::fromRawValue(*runtime, value, sourceProps.hasBeenCalled); + } catch (const std::exception& exc) { + throw std::runtime_error(std::string("TestView.hasBeenCalled: ") + exc.what()); + } + }()), + testCallback([&]() -> CachedProp> { + try { + const react::RawValue* rawValue = rawProps.at("testCallback", nullptr, nullptr); + if (rawValue == nullptr) return sourceProps.testCallback; + const auto& [runtime, value] = (std::pair)*rawValue; + return CachedProp>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.testCallback); + } catch (const std::exception& exc) { + throw std::runtime_error(std::string("TestView.testCallback: ") + exc.what()); + } + }()), + hybridRef([&]() -> CachedProp& /* ref */)>>> { + try { + const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr); + if (rawValue == nullptr) return sourceProps.hybridRef; + const auto& [runtime, value] = (std::pair)*rawValue; + return CachedProp& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.hybridRef); + } catch (const std::exception& exc) { + throw std::runtime_error(std::string("TestView.hybridRef: ") + exc.what()); + } + }()) { } + + bool HybridTestViewProps::filterObjectKeys(const std::string& propName) { + switch (hashString(propName)) { + case hashString("isCyan"): return true; + case hashString("hasBeenCalled"): return true; + case hashString("testCallback"): return true; + case hashString("hybridRef"): return true; + default: return false; + } + } + + HybridTestViewComponentDescriptor::HybridTestViewComponentDescriptor(const react::ComponentDescriptorParameters& parameters) + : ConcreteComponentDescriptor(parameters, + react::RawPropsParser(/* enableJsiParser */ true)) {} + + std::shared_ptr HybridTestViewComponentDescriptor::cloneProps(const react::PropsParserContext& context, + const std::shared_ptr& props, + react::RawProps rawProps) const { + // 1. Prepare raw props parser + rawProps.parse(rawPropsParser_); + // 2. Copy props with Nitro's cached copy constructor + return HybridTestViewShadowNode::Props(context, /* & */ rawProps, props); + } + +#ifdef ANDROID + void HybridTestViewComponentDescriptor::adopt(react::ShadowNode& shadowNode) const { + // This is called immediately after `ShadowNode` is created, cloned or in progress. + // On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++. + auto& concreteShadowNode = static_cast(shadowNode); + const std::shared_ptr& constProps = concreteShadowNode.getConcreteSharedProps(); + const std::shared_ptr& props = std::const_pointer_cast(constProps); + HybridTestViewState state{props}; + concreteShadowNode.setStateData(std::move(state)); + } +#endif + +} // namespace margelo::nitro::test::external::views diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/views/NitroTestExternalHybridTestViewComponent.hpp b/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/views/NitroTestExternalHybridTestViewComponent.hpp new file mode 100644 index 000000000..2df303794 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/shared/c++/views/NitroTestExternalHybridTestViewComponent.hpp @@ -0,0 +1,112 @@ +/// +/// NitroTestExternalHybridTestViewComponent.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include "NitroTestExternalHybridTestViewSpec.hpp" +#include + +namespace margelo::nitro::test::external::views { + + using namespace facebook; + + /** + * The name of the actual native View. + */ + extern const char HybridTestViewComponentName[]; + + /** + * Props for the "TestView" View. + */ + class HybridTestViewProps final: public react::ViewProps { + public: + HybridTestViewProps() = default; + HybridTestViewProps(const react::PropsParserContext& context, + const HybridTestViewProps& sourceProps, + const react::RawProps& rawProps); + + public: + CachedProp isCyan; + CachedProp hasBeenCalled; + CachedProp> testCallback; + CachedProp& /* ref */)>>> hybridRef; + + private: + static bool filterObjectKeys(const std::string& propName); + }; + + /** + * State for the "TestView" View. + */ + class HybridTestViewState final { + public: + HybridTestViewState() = default; + explicit HybridTestViewState(const std::shared_ptr& props): + _props(props) {} + + public: + [[nodiscard]] + const std::shared_ptr& getProps() const { + return _props; + } + + public: +#ifdef ANDROID + HybridTestViewState(const HybridTestViewState& /* previousState */, folly::dynamic /* data */) {} + folly::dynamic getDynamic() const { + throw std::runtime_error("HybridTestViewState does not support folly!"); + } + react::MapBuffer getMapBuffer() const { + throw std::runtime_error("HybridTestViewState does not support MapBuffer!"); + }; +#endif + + private: + std::shared_ptr _props; + }; + + /** + * The Shadow Node for the "TestView" View. + */ + using HybridTestViewShadowNode = react::ConcreteViewShadowNode; + + /** + * The Component Descriptor for the "TestView" View. + */ + class HybridTestViewComponentDescriptor final: public react::ConcreteComponentDescriptor { + public: + explicit HybridTestViewComponentDescriptor(const react::ComponentDescriptorParameters& parameters); + + public: + /** + * A faster path for cloning props - reuses the caching logic from `HybridTestViewProps`. + */ + std::shared_ptr cloneProps(const react::PropsParserContext& context, + const std::shared_ptr& props, + react::RawProps rawProps) const override; +#ifdef ANDROID + void adopt(react::ShadowNode& shadowNode) const override; +#endif + }; + + /* The actual view for "TestView" needs to be implemented in platform-specific code. */ + +} // namespace margelo::nitro::test::external::views diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/shared/json/TestViewConfig.json b/packages/react-native-nitro-test-external/nitrogen/generated/shared/json/TestViewConfig.json new file mode 100644 index 000000000..41d68d6f6 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/shared/json/TestViewConfig.json @@ -0,0 +1,12 @@ +{ + "uiViewClassName": "NitroTestExternalTestView", + "supportsRawText": false, + "bubblingEventTypes": {}, + "directEventTypes": {}, + "validAttributes": { + "isCyan": true, + "hasBeenCalled": true, + "testCallback": true, + "hybridRef": true + } +} diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/shared/ts/createNitroTestExternalHybridObject.ts b/packages/react-native-nitro-test-external/nitrogen/generated/shared/ts/createNitroTestExternalHybridObject.ts new file mode 100644 index 000000000..0b7f3d077 --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/shared/ts/createNitroTestExternalHybridObject.ts @@ -0,0 +1,19 @@ +/// +/// createNitroTestExternalHybridObject.ts +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// +import { NitroModules, type HybridObject } from 'react-native-nitro-modules' + +const REGISTERED_OBJECTS = { + SomeExternalObject: 'NitroTestExternalSomeExternalObject', + Base: 'NitroTestExternalBase', + BlaBla: 'NitroTestExternalBlaBla', +} as const + +export function createNitroTestExternalHybridObject>( + name: keyof typeof REGISTERED_OBJECTS +): ReturnType> { + return NitroModules.createHybridObject(REGISTERED_OBJECTS[name]) +} diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/shared/ts/getNitroTestExternalHostComponent.ts b/packages/react-native-nitro-test-external/nitrogen/generated/shared/ts/getNitroTestExternalHostComponent.ts new file mode 100644 index 000000000..9acf6025b --- /dev/null +++ b/packages/react-native-nitro-test-external/nitrogen/generated/shared/ts/getNitroTestExternalHostComponent.ts @@ -0,0 +1,32 @@ +/// +/// getNitroTestExternalHostComponent.ts +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// +import { + getHostComponent, + type HybridViewMethods, + type HybridViewProps, + type ViewConfig, +} from 'react-native-nitro-modules' + +import TestViewConfig from '../json/TestViewConfig.json' + +const REGISTERED_COMPONENTS = { + TestView: { + name: 'NitroTestExternalTestView', + config: TestViewConfig, + }, +} as const + +export function getNitroTestExternalHostComponent< + Props extends HybridViewProps, + Methods extends HybridViewMethods, +>( + name: keyof typeof REGISTERED_COMPONENTS +): ReturnType> { + const component = REGISTERED_COMPONENTS[name] + const config = component.config as ViewConfig + return getHostComponent(component.name, () => config) +} diff --git a/packages/react-native-nitro-test-external/package.json b/packages/react-native-nitro-test-external/package.json index 954b333a3..deba84d9c 100644 --- a/packages/react-native-nitro-test-external/package.json +++ b/packages/react-native-nitro-test-external/package.json @@ -2,9 +2,9 @@ "name": "react-native-nitro-test-external", "version": "0.35.6", "description": "react-native-nitro-test-external", - "main": "lib/index", - "module": "lib/index", - "types": "lib/index.d.ts", + "main": "lib/src/index", + "module": "lib/src/index", + "types": "lib/src/index.d.ts", "react-native": "src/index", "source": "src/index", "files": [ diff --git a/packages/react-native-nitro-test-external/src/index.ts b/packages/react-native-nitro-test-external/src/index.ts index a170bd751..d3f426d5a 100644 --- a/packages/react-native-nitro-test-external/src/index.ts +++ b/packages/react-native-nitro-test-external/src/index.ts @@ -1,7 +1,33 @@ -import { NitroModules } from 'react-native-nitro-modules' -import type { SomeExternalObject } from './specs/SomeExternalObject.nitro' +import { type HybridRef } from 'react-native-nitro-modules' +import type { + Base, + BlaBla, + SomeExternalObject, +} from './specs/SomeExternalObject.nitro' +import type { TestViewMethods, TestViewProps } from './specs/TestView.nitro' +import { createNitroTestExternalHybridObject } from '../nitrogen/generated/shared/ts/createNitroTestExternalHybridObject' +import { getNitroTestExternalHostComponent } from '../nitrogen/generated/shared/ts/getNitroTestExternalHostComponent' export const HybridSomeExternalObject = - NitroModules.createHybridObject('SomeExternalObject') + createNitroTestExternalHybridObject('SomeExternalObject') -export { type SomeExternalObject } from './specs/SomeExternalObject.nitro' +export const HybridBlaBla = + createNitroTestExternalHybridObject('BlaBla') + +export const HybridBase = createNitroTestExternalHybridObject('Base') + +export { + type Base, + type BlaBla, + type SomeExternalObject, +} from './specs/SomeExternalObject.nitro' + +/** + * Represents the HybridView `TestView`, which can be rendered as a React Native view. + */ +export const TestView = getNitroTestExternalHostComponent< + TestViewProps, + TestViewMethods +>('TestView') + +export type TestViewRef = HybridRef diff --git a/packages/react-native-nitro-test-external/src/specs/SomeExternalObject.nitro.ts b/packages/react-native-nitro-test-external/src/specs/SomeExternalObject.nitro.ts index fbf3a0a9b..6b423826d 100644 --- a/packages/react-native-nitro-test-external/src/specs/SomeExternalObject.nitro.ts +++ b/packages/react-native-nitro-test-external/src/specs/SomeExternalObject.nitro.ts @@ -28,3 +28,15 @@ export interface SomeExternalObject optionalInt64?: Int64 ): OptionalPrimitivesHolder } + +// This is a simple `HybridObject` with just one value. +export interface Base + extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> { + readonly abc: number +} + +// This is a simple `HybridObject` with just one value. +export interface BlaBla + extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> { + base?: Base +} diff --git a/packages/react-native-nitro-test-external/src/specs/TestView.nitro.ts b/packages/react-native-nitro-test-external/src/specs/TestView.nitro.ts new file mode 100644 index 000000000..8f8fe0a2f --- /dev/null +++ b/packages/react-native-nitro-test-external/src/specs/TestView.nitro.ts @@ -0,0 +1,18 @@ +import type { + HybridView, + HybridViewMethods, + HybridViewProps, +} from 'react-native-nitro-modules' + +export type ColorScheme = 'light' | 'dark' + +export interface TestViewProps extends HybridViewProps { + isCyan: boolean + hasBeenCalled: boolean + testCallback: () => void +} +export interface TestViewMethods extends HybridViewMethods { + testMethod(): void +} + +export type TestView = HybridView diff --git a/packages/react-native-nitro-test-external/tsconfig.json b/packages/react-native-nitro-test-external/tsconfig.json index bea65346b..897d06063 100644 --- a/packages/react-native-nitro-test-external/tsconfig.json +++ b/packages/react-native-nitro-test-external/tsconfig.json @@ -3,10 +3,14 @@ "@tsconfig/react-native/tsconfig.json", "../../config/tsconfig.json" ], - "include": ["src"], + "include": [ + "src", + "nitrogen/generated/shared/ts", + "nitrogen/generated/shared/json/*.json" + ], "compilerOptions": { - "rootDir": "src", + "rootDir": ".", "outDir": "lib", - "jsx": "react" + "jsx": "react", } } diff --git a/packages/react-native-nitro-test/cpp/HybridBase.hpp b/packages/react-native-nitro-test/cpp/HybridBase.hpp index 236fde5ce..b43daf6b2 100644 --- a/packages/react-native-nitro-test/cpp/HybridBase.hpp +++ b/packages/react-native-nitro-test/cpp/HybridBase.hpp @@ -7,7 +7,7 @@ #pragma once -#include "HybridBaseSpec.hpp" +#include "NitroTestHybridBaseSpec.hpp" namespace margelo::nitro::test { diff --git a/packages/react-native-nitro-test/cpp/HybridChild.hpp b/packages/react-native-nitro-test/cpp/HybridChild.hpp index 4e8da52c9..64db61c62 100644 --- a/packages/react-native-nitro-test/cpp/HybridChild.hpp +++ b/packages/react-native-nitro-test/cpp/HybridChild.hpp @@ -8,7 +8,7 @@ #pragma once #include "HybridBase.hpp" -#include "HybridChildSpec.hpp" +#include "NitroTestHybridChildSpec.hpp" namespace margelo::nitro::test { diff --git a/packages/react-native-nitro-test/cpp/HybridSomeInternalObject.hpp b/packages/react-native-nitro-test/cpp/HybridSomeInternalObject.hpp index c29c0432f..c92cffcfe 100644 --- a/packages/react-native-nitro-test/cpp/HybridSomeInternalObject.hpp +++ b/packages/react-native-nitro-test/cpp/HybridSomeInternalObject.hpp @@ -7,7 +7,7 @@ #pragma once -#include +#include namespace margelo::nitro::test { diff --git a/packages/react-native-nitro-test/cpp/HybridTestObjectCpp.hpp b/packages/react-native-nitro-test/cpp/HybridTestObjectCpp.hpp index eca4916bc..613b17790 100644 --- a/packages/react-native-nitro-test/cpp/HybridTestObjectCpp.hpp +++ b/packages/react-native-nitro-test/cpp/HybridTestObjectCpp.hpp @@ -7,7 +7,7 @@ #pragma once -#include "HybridTestObjectCppSpec.hpp" +#include "NitroTestHybridTestObjectCppSpec.hpp" #include namespace margelo::nitro::test { diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/NitroTest+autolinking.cmake b/packages/react-native-nitro-test/nitrogen/generated/android/NitroTest+autolinking.cmake index 453148d1b..f3f0a856d 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/NitroTest+autolinking.cmake +++ b/packages/react-native-nitro-test/nitrogen/generated/android/NitroTest+autolinking.cmake @@ -33,15 +33,15 @@ target_sources( # Autolinking Setup ../nitrogen/generated/android/NitroTestOnLoad.cpp # Shared Nitrogen C++ sources - ../nitrogen/generated/shared/c++/HybridBaseSpec.cpp - ../nitrogen/generated/shared/c++/HybridChildSpec.cpp - ../nitrogen/generated/shared/c++/HybridPlatformObjectSpec.cpp - ../nitrogen/generated/shared/c++/HybridRecyclableTestViewSpec.cpp - ../nitrogen/generated/shared/c++/views/HybridRecyclableTestViewComponent.cpp - ../nitrogen/generated/shared/c++/HybridTestObjectCppSpec.cpp - ../nitrogen/generated/shared/c++/HybridTestObjectSwiftKotlinSpec.cpp - ../nitrogen/generated/shared/c++/HybridTestViewSpec.cpp - ../nitrogen/generated/shared/c++/views/HybridTestViewComponent.cpp + ../nitrogen/generated/shared/c++/NitroTestHybridBaseSpec.cpp + ../nitrogen/generated/shared/c++/NitroTestHybridChildSpec.cpp + ../nitrogen/generated/shared/c++/NitroTestHybridPlatformObjectSpec.cpp + ../nitrogen/generated/shared/c++/NitroTestHybridRecyclableTestViewSpec.cpp + ../nitrogen/generated/shared/c++/views/NitroTestHybridRecyclableTestViewComponent.cpp + ../nitrogen/generated/shared/c++/NitroTestHybridTestObjectCppSpec.cpp + ../nitrogen/generated/shared/c++/NitroTestHybridTestObjectSwiftKotlinSpec.cpp + ../nitrogen/generated/shared/c++/NitroTestHybridTestViewSpec.cpp + ../nitrogen/generated/shared/c++/views/NitroTestHybridTestViewComponent.cpp # Android-specific Nitrogen C++ sources ../nitrogen/generated/android/c++/JHybridBaseSpec.cpp ../nitrogen/generated/android/c++/JHybridChildSpec.cpp diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/NitroTestOnLoad.cpp b/packages/react-native-nitro-test/nitrogen/generated/android/NitroTestOnLoad.cpp index 5ebdab53b..7fa925144 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/NitroTestOnLoad.cpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/NitroTestOnLoad.cpp @@ -125,7 +125,7 @@ void registerAllNatives() { // Register Nitro Hybrid Objects HybridObjectRegistry::registerHybridObjectConstructor( - "TestObjectCpp", + "NitroTestTestObjectCpp", []() -> std::shared_ptr { static_assert(std::is_default_constructible_v, "The HybridObject \"HybridTestObjectCpp\" is not default-constructible! " @@ -134,37 +134,37 @@ void registerAllNatives() { } ); HybridObjectRegistry::registerHybridObjectConstructor( - "TestObjectSwiftKotlin", + "NitroTestTestObjectSwiftKotlin", []() -> std::shared_ptr { return JHybridTestObjectSwiftKotlinSpecImpl::create(); } ); HybridObjectRegistry::registerHybridObjectConstructor( - "Base", + "NitroTestBase", []() -> std::shared_ptr { return JHybridBaseSpecImpl::create(); } ); HybridObjectRegistry::registerHybridObjectConstructor( - "Child", + "NitroTestChild", []() -> std::shared_ptr { return JHybridChildSpecImpl::create(); } ); HybridObjectRegistry::registerHybridObjectConstructor( - "PlatformObject", + "NitroTestPlatformObject", []() -> std::shared_ptr { return JHybridPlatformObjectSpecImpl::create(); } ); HybridObjectRegistry::registerHybridObjectConstructor( - "TestView", + "NitroTestTestView", []() -> std::shared_ptr { return JHybridTestViewSpecImpl::create(); } ); HybridObjectRegistry::registerHybridObjectConstructor( - "RecyclableTestView", + "NitroTestRecyclableTestView", []() -> std::shared_ptr { return JHybridRecyclableTestViewSpecImpl::create(); } diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JCar.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JCar.hpp index b19d34b53..42d02c222 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JCar.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JCar.hpp @@ -8,13 +8,13 @@ #pragma once #include -#include "Car.hpp" +#include "NitroTestCar.hpp" #include "JPerson.hpp" #include "JPowertrain.hpp" #include "JVariant_String_Double.hpp" -#include "Person.hpp" -#include "Powertrain.hpp" +#include "NitroTestPerson.hpp" +#include "NitroTestPowertrain.hpp" #include #include #include diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JColorScheme.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JColorScheme.hpp index 1995f592a..91dea1e65 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JColorScheme.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JColorScheme.hpp @@ -8,7 +8,7 @@ #pragma once #include -#include "ColorScheme.hpp" +#include "NitroTestColorScheme.hpp" namespace margelo::nitro::test { diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JCoreTypesVariant.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JCoreTypesVariant.hpp index adcd72700..eb4503c9b 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JCoreTypesVariant.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JCoreTypesVariant.hpp @@ -12,7 +12,7 @@ #include #include -#include "WrappedJsStruct.hpp" +#include "NitroTestWrappedJsStruct.hpp" #include #include #include @@ -21,7 +21,7 @@ #include "JFunc_void_double.hpp" #include #include "JWrappedJsStruct.hpp" -#include "JsStyleStruct.hpp" +#include "NitroTestJsStyleStruct.hpp" #include "JJsStyleStruct.hpp" #include #include diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JExternalObjectStruct.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JExternalObjectStruct.hpp index aa59aea18..8fd5afd7b 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JExternalObjectStruct.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JExternalObjectStruct.hpp @@ -8,10 +8,10 @@ #pragma once #include -#include "ExternalObjectStruct.hpp" +#include "NitroTestExternalObjectStruct.hpp" -#include #include +#include #include namespace margelo::nitro::test { diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_margelo__nitro__test__external__HybridSomeExternalObjectSpec_.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_margelo__nitro__test__external__HybridSomeExternalObjectSpec_.hpp index 9a1754da9..1b0f68644 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_margelo__nitro__test__external__HybridSomeExternalObjectSpec_.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_margelo__nitro__test__external__HybridSomeExternalObjectSpec_.hpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_std__vector_Powertrain_.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_std__vector_Powertrain_.hpp index 966fe3d3c..fd6ab8dca 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_std__vector_Powertrain_.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_std__vector_Powertrain_.hpp @@ -10,7 +10,7 @@ #include #include -#include "Powertrain.hpp" +#include "NitroTestPowertrain.hpp" #include #include #include diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridBaseSpec.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridBaseSpec.hpp index 18bdcf92c..d6240f274 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridBaseSpec.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridBaseSpec.hpp @@ -9,7 +9,7 @@ #include #include -#include "HybridBaseSpec.hpp" +#include "NitroTestHybridBaseSpec.hpp" diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridChildSpec.cpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridChildSpec.cpp index f7178b520..a7b64161a 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridChildSpec.cpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridChildSpec.cpp @@ -15,13 +15,13 @@ namespace margelo::nitro::test { enum class Powertrain; } namespace margelo::nitro::test { struct Person; } #include -#include "Car.hpp" +#include "NitroTestCar.hpp" #include #include "JNamedVariant.hpp" #include "JCar.hpp" -#include "Powertrain.hpp" +#include "NitroTestPowertrain.hpp" #include "JPowertrain.hpp" -#include "Person.hpp" +#include "NitroTestPerson.hpp" #include #include "JPerson.hpp" #include diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridChildSpec.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridChildSpec.hpp index 7ae265342..dfe1f680f 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridChildSpec.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridChildSpec.hpp @@ -9,7 +9,7 @@ #include #include -#include "HybridChildSpec.hpp" +#include "NitroTestHybridChildSpec.hpp" // Forward declaration of `JHybridBaseSpec` to properly resolve imports. namespace margelo::nitro::test { class JHybridBaseSpec; } diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridPlatformObjectSpec.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridPlatformObjectSpec.hpp index 0caca67fa..503ef7388 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridPlatformObjectSpec.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridPlatformObjectSpec.hpp @@ -9,7 +9,7 @@ #include #include -#include "HybridPlatformObjectSpec.hpp" +#include "NitroTestHybridPlatformObjectSpec.hpp" diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridRecyclableTestViewSpec.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridRecyclableTestViewSpec.hpp index 0683c6250..ea8794e2f 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridRecyclableTestViewSpec.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridRecyclableTestViewSpec.hpp @@ -9,7 +9,7 @@ #include #include -#include "HybridRecyclableTestViewSpec.hpp" +#include "NitroTestHybridRecyclableTestViewSpec.hpp" diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestObjectSwiftKotlinSpec.cpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestObjectSwiftKotlinSpec.cpp index 10a20494f..6ea8a5208 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestObjectSwiftKotlinSpec.cpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestObjectSwiftKotlinSpec.cpp @@ -45,7 +45,7 @@ namespace margelo::nitro::test { struct SecondMapWrapper; } namespace margelo::nitro::test { class HybridTestViewSpec; } #include -#include "HybridTestObjectSwiftKotlinSpec.hpp" +#include "NitroTestHybridTestObjectSwiftKotlinSpec.hpp" #include "JHybridTestObjectSwiftKotlinSpec.hpp" #include #include @@ -54,20 +54,20 @@ namespace margelo::nitro::test { class HybridTestViewSpec; } #include #include "JVariant_NullType_String.hpp" #include -#include "Powertrain.hpp" +#include "NitroTestPowertrain.hpp" #include "JPowertrain.hpp" -#include "OldEnum.hpp" +#include "NitroTestOldEnum.hpp" #include "JOldEnum.hpp" #include #include "JFunc_void_double.hpp" #include #include "JVariant_String_Double.hpp" -#include "Person.hpp" +#include "NitroTestPerson.hpp" #include "JVariant_HybridTestObjectSwiftKotlinSpec_Person.hpp" #include "JPerson.hpp" -#include "PartialPerson.hpp" +#include "NitroTestPartialPerson.hpp" #include "JPartialPerson.hpp" -#include "HybridChildSpec.hpp" +#include "NitroTestHybridChildSpec.hpp" #include "JHybridChildSpec.hpp" #include "JFunc_void.hpp" #include @@ -81,36 +81,36 @@ namespace margelo::nitro::test { class HybridTestViewSpec; } #include #include #include -#include "Car.hpp" +#include "NitroTestCar.hpp" #include "JCar.hpp" -#include "WrappedJsStruct.hpp" +#include "NitroTestWrappedJsStruct.hpp" #include "JWrappedJsStruct.hpp" -#include "JsStyleStruct.hpp" +#include "NitroTestJsStyleStruct.hpp" #include "JJsStyleStruct.hpp" -#include "OptionalWrapper.hpp" +#include "NitroTestOptionalWrapper.hpp" #include "JOptionalWrapper.hpp" -#include "OptionalCallback.hpp" +#include "NitroTestOptionalCallback.hpp" #include "JOptionalCallback.hpp" #include "JVariant_______Unit_Double.hpp" #include "JVariant_Boolean_OldEnum.hpp" -#include "WeirdNumbersEnum.hpp" +#include "NitroTestWeirdNumbersEnum.hpp" #include "JVariant_Boolean_WeirdNumbersEnum.hpp" #include "JWeirdNumbersEnum.hpp" #include "JVariant_Car_Person.hpp" #include "JNamedVariant.hpp" -#include "HybridBaseSpec.hpp" +#include "NitroTestHybridBaseSpec.hpp" #include "JVariant_HybridBaseSpec_OptionalWrapper.hpp" #include "JHybridBaseSpec.hpp" #include "JCoreTypesVariant.hpp" -#include +#include #include -#include "ExternalObjectStruct.hpp" +#include "NitroTestExternalObjectStruct.hpp" #include "JExternalObjectStruct.hpp" #include "JStringOrExternal.hpp" #include "JFunc_void_std__vector_Powertrain_.hpp" -#include "MapWrapper.hpp" +#include "NitroTestMapWrapper.hpp" #include "JMapWrapper.hpp" -#include "SecondMapWrapper.hpp" +#include "NitroTestSecondMapWrapper.hpp" #include "JSecondMapWrapper.hpp" #include #include "JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_void____.hpp" @@ -123,7 +123,7 @@ namespace margelo::nitro::test { class HybridTestViewSpec; } #include "JFunc_std__shared_ptr_Promise_std__string__.hpp" #include "JVariant_Boolean_DoubleArray_Array_String__String_Double.hpp" #include "JFunc_double.hpp" -#include "HybridTestViewSpec.hpp" +#include "NitroTestHybridTestViewSpec.hpp" #include "JHybridTestViewSpec.hpp" #include "JFunc_std__shared_ptr_margelo__nitro__test__external__HybridSomeExternalObjectSpec_.hpp" diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestObjectSwiftKotlinSpec.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestObjectSwiftKotlinSpec.hpp index 2237267fb..6c6518e42 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestObjectSwiftKotlinSpec.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestObjectSwiftKotlinSpec.hpp @@ -9,7 +9,7 @@ #include #include -#include "HybridTestObjectSwiftKotlinSpec.hpp" +#include "NitroTestHybridTestObjectSwiftKotlinSpec.hpp" diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestViewSpec.cpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestViewSpec.cpp index 7a612c4af..d6ff08b0c 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestViewSpec.cpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestViewSpec.cpp @@ -10,7 +10,7 @@ // Forward declaration of `ColorScheme` to properly resolve imports. namespace margelo::nitro::test { enum class ColorScheme; } -#include "ColorScheme.hpp" +#include "NitroTestColorScheme.hpp" #include "JColorScheme.hpp" #include #include "JFunc_void.hpp" diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestViewSpec.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestViewSpec.hpp index 715471554..6bac658fb 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestViewSpec.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestViewSpec.hpp @@ -9,7 +9,7 @@ #include #include -#include "HybridTestViewSpec.hpp" +#include "NitroTestHybridTestViewSpec.hpp" diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JJsStyleStruct.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JJsStyleStruct.hpp index 3dc4e3811..cb93ed702 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JJsStyleStruct.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JJsStyleStruct.hpp @@ -8,7 +8,7 @@ #pragma once #include -#include "JsStyleStruct.hpp" +#include "NitroTestJsStyleStruct.hpp" #include "JFunc_void_double.hpp" #include diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JMapWrapper.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JMapWrapper.hpp index 7f0d644be..b9d54f213 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JMapWrapper.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JMapWrapper.hpp @@ -8,10 +8,10 @@ #pragma once #include -#include "MapWrapper.hpp" +#include "NitroTestMapWrapper.hpp" #include "JSecondMapWrapper.hpp" -#include "SecondMapWrapper.hpp" +#include "NitroTestSecondMapWrapper.hpp" #include #include diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JNamedVariant.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JNamedVariant.hpp index e763f29f8..c3a77d03a 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JNamedVariant.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JNamedVariant.hpp @@ -11,12 +11,12 @@ #include #include -#include "Car.hpp" +#include "NitroTestCar.hpp" #include #include "JCar.hpp" -#include "Powertrain.hpp" +#include "NitroTestPowertrain.hpp" #include "JPowertrain.hpp" -#include "Person.hpp" +#include "NitroTestPerson.hpp" #include #include "JPerson.hpp" #include diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOldEnum.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOldEnum.hpp index 45fb9f184..4cc3175e6 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOldEnum.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOldEnum.hpp @@ -8,7 +8,7 @@ #pragma once #include -#include "OldEnum.hpp" +#include "NitroTestOldEnum.hpp" namespace margelo::nitro::test { diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOptionalCallback.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOptionalCallback.hpp index 83279d7eb..b601e70bf 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOptionalCallback.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOptionalCallback.hpp @@ -8,7 +8,7 @@ #pragma once #include -#include "OptionalCallback.hpp" +#include "NitroTestOptionalCallback.hpp" #include "JFunc_void.hpp" #include "JVariant_______Unit_Double.hpp" diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOptionalWrapper.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOptionalWrapper.hpp index f3454348e..53150787f 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOptionalWrapper.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOptionalWrapper.hpp @@ -8,7 +8,7 @@ #pragma once #include -#include "OptionalWrapper.hpp" +#include "NitroTestOptionalWrapper.hpp" #include #include diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPartialPerson.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPartialPerson.hpp index 62d26c796..be934f8ec 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPartialPerson.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPartialPerson.hpp @@ -8,7 +8,7 @@ #pragma once #include -#include "PartialPerson.hpp" +#include "NitroTestPartialPerson.hpp" #include #include diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPerson.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPerson.hpp index adc2b46db..08e72cf55 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPerson.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPerson.hpp @@ -8,7 +8,7 @@ #pragma once #include -#include "Person.hpp" +#include "NitroTestPerson.hpp" #include diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPowertrain.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPowertrain.hpp index b30e1c998..1a160e814 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPowertrain.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPowertrain.hpp @@ -8,7 +8,7 @@ #pragma once #include -#include "Powertrain.hpp" +#include "NitroTestPowertrain.hpp" namespace margelo::nitro::test { diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JSecondMapWrapper.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JSecondMapWrapper.hpp index 8879c7184..94dead489 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JSecondMapWrapper.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JSecondMapWrapper.hpp @@ -8,7 +8,7 @@ #pragma once #include -#include "SecondMapWrapper.hpp" +#include "NitroTestSecondMapWrapper.hpp" #include #include diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JStringOrExternal.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JStringOrExternal.hpp index edcee2d49..54e85f29c 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JStringOrExternal.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JStringOrExternal.hpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_OldEnum.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_OldEnum.hpp index 9e33352f2..fa22892a4 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_OldEnum.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_OldEnum.hpp @@ -10,7 +10,7 @@ #include #include -#include "OldEnum.hpp" +#include "NitroTestOldEnum.hpp" #include #include "JOldEnum.hpp" diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_WeirdNumbersEnum.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_WeirdNumbersEnum.hpp index eca8f9e97..ecd44d57f 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_WeirdNumbersEnum.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_WeirdNumbersEnum.hpp @@ -10,7 +10,7 @@ #include #include -#include "WeirdNumbersEnum.hpp" +#include "NitroTestWeirdNumbersEnum.hpp" #include #include "JWeirdNumbersEnum.hpp" diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Car_Person.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Car_Person.hpp index 40c6e67c2..08fe476f1 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Car_Person.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Car_Person.hpp @@ -10,12 +10,12 @@ #include #include -#include "Car.hpp" -#include "Person.hpp" +#include "NitroTestCar.hpp" +#include "NitroTestPerson.hpp" #include #include "JCar.hpp" #include -#include "Powertrain.hpp" +#include "NitroTestPowertrain.hpp" #include "JPowertrain.hpp" #include #include "JPerson.hpp" diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_HybridBaseSpec_OptionalWrapper.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_HybridBaseSpec_OptionalWrapper.hpp index 56fdb1a12..8679aef60 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_HybridBaseSpec_OptionalWrapper.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_HybridBaseSpec_OptionalWrapper.hpp @@ -11,8 +11,8 @@ #include #include -#include "HybridBaseSpec.hpp" -#include "OptionalWrapper.hpp" +#include "NitroTestHybridBaseSpec.hpp" +#include "NitroTestOptionalWrapper.hpp" #include #include "JHybridBaseSpec.hpp" #include "JOptionalWrapper.hpp" diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_HybridTestObjectSwiftKotlinSpec_Person.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_HybridTestObjectSwiftKotlinSpec_Person.hpp index 171390827..6f60ebe85 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_HybridTestObjectSwiftKotlinSpec_Person.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_HybridTestObjectSwiftKotlinSpec_Person.hpp @@ -11,8 +11,8 @@ #include #include -#include "HybridTestObjectSwiftKotlinSpec.hpp" -#include "Person.hpp" +#include "NitroTestHybridTestObjectSwiftKotlinSpec.hpp" +#include "NitroTestPerson.hpp" #include #include "JHybridTestObjectSwiftKotlinSpec.hpp" #include "JPerson.hpp" diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JWeirdNumbersEnum.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JWeirdNumbersEnum.hpp index c3ca0c92c..cb620adb3 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JWeirdNumbersEnum.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JWeirdNumbersEnum.hpp @@ -8,7 +8,7 @@ #pragma once #include -#include "WeirdNumbersEnum.hpp" +#include "NitroTestWeirdNumbersEnum.hpp" namespace margelo::nitro::test { diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JWrappedJsStruct.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JWrappedJsStruct.hpp index 0c5233351..06483d349 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JWrappedJsStruct.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JWrappedJsStruct.hpp @@ -8,11 +8,11 @@ #pragma once #include -#include "WrappedJsStruct.hpp" +#include "NitroTestWrappedJsStruct.hpp" #include "JFunc_void_double.hpp" #include "JJsStyleStruct.hpp" -#include "JsStyleStruct.hpp" +#include "NitroTestJsStyleStruct.hpp" #include #include #include diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/views/JHybridRecyclableTestViewStateUpdater.cpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/views/JHybridRecyclableTestViewStateUpdater.cpp index cb4b7c3a8..800762619 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/views/JHybridRecyclableTestViewStateUpdater.cpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/views/JHybridRecyclableTestViewStateUpdater.cpp @@ -6,7 +6,7 @@ /// #include "JHybridRecyclableTestViewStateUpdater.hpp" -#include "views/HybridRecyclableTestViewComponent.hpp" +#include "views/NitroTestHybridRecyclableTestViewComponent.hpp" #include #include diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/views/JHybridRecyclableTestViewStateUpdater.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/views/JHybridRecyclableTestViewStateUpdater.hpp index 0bd9385b3..70e962552 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/views/JHybridRecyclableTestViewStateUpdater.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/views/JHybridRecyclableTestViewStateUpdater.hpp @@ -18,7 +18,7 @@ #include #include #include "JHybridRecyclableTestViewSpec.hpp" -#include "views/HybridRecyclableTestViewComponent.hpp" +#include "views/NitroTestHybridRecyclableTestViewComponent.hpp" namespace margelo::nitro::test::views { diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/views/JHybridTestViewStateUpdater.cpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/views/JHybridTestViewStateUpdater.cpp index fb6584818..5cac1d7e6 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/views/JHybridTestViewStateUpdater.cpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/views/JHybridTestViewStateUpdater.cpp @@ -6,7 +6,7 @@ /// #include "JHybridTestViewStateUpdater.hpp" -#include "views/HybridTestViewComponent.hpp" +#include "views/NitroTestHybridTestViewComponent.hpp" #include #include diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/views/JHybridTestViewStateUpdater.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/views/JHybridTestViewStateUpdater.hpp index b71ecbeb1..b46ba534e 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/views/JHybridTestViewStateUpdater.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/views/JHybridTestViewStateUpdater.hpp @@ -18,7 +18,7 @@ #include #include #include "JHybridTestViewSpec.hpp" -#include "views/HybridTestViewComponent.hpp" +#include "views/NitroTestHybridTestViewComponent.hpp" namespace margelo::nitro::test::views { diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridBaseSpec.kt b/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridBaseSpec.kt index 9c8bf6f40..508617475 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridBaseSpec.kt +++ b/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridBaseSpec.kt @@ -34,7 +34,7 @@ abstract class HybridBaseSpec: HybridObject() { // Default implementation of `HybridObject.toString()` override fun toString(): String { - return "[HybridObject Base]" + return "[HybridObject NitroTestBase]" } // C++ backing class diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridChildSpec.kt b/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridChildSpec.kt index 7de7f5028..691507046 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridChildSpec.kt +++ b/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridChildSpec.kt @@ -36,7 +36,7 @@ abstract class HybridChildSpec: HybridBaseSpec() { // Default implementation of `HybridObject.toString()` override fun toString(): String { - return "[HybridObject Child]" + return "[HybridObject NitroTestChild]" } // C++ backing class diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridPlatformObjectSpec.kt b/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridPlatformObjectSpec.kt index 1e8e53c8b..e17c7a057 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridPlatformObjectSpec.kt +++ b/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridPlatformObjectSpec.kt @@ -34,7 +34,7 @@ abstract class HybridPlatformObjectSpec: HybridObject() { // Default implementation of `HybridObject.toString()` override fun toString(): String { - return "[HybridObject PlatformObject]" + return "[HybridObject NitroTestPlatformObject]" } // C++ backing class diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridRecyclableTestViewSpec.kt b/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridRecyclableTestViewSpec.kt index d6d1fe7b3..13db03db7 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridRecyclableTestViewSpec.kt +++ b/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridRecyclableTestViewSpec.kt @@ -37,7 +37,7 @@ abstract class HybridRecyclableTestViewSpec: HybridView() { // Default implementation of `HybridObject.toString()` override fun toString(): String { - return "[HybridObject RecyclableTestView]" + return "[HybridObject NitroTestRecyclableTestView]" } // C++ backing class diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridTestObjectSwiftKotlinSpec.kt b/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridTestObjectSwiftKotlinSpec.kt index c7e3b3994..d87ea3ef7 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridTestObjectSwiftKotlinSpec.kt +++ b/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridTestObjectSwiftKotlinSpec.kt @@ -640,7 +640,7 @@ abstract class HybridTestObjectSwiftKotlinSpec: HybridObject() { // Default implementation of `HybridObject.toString()` override fun toString(): String { - return "[HybridObject TestObjectSwiftKotlin]" + return "[HybridObject NitroTestTestObjectSwiftKotlin]" } // C++ backing class diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridTestViewSpec.kt b/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridTestViewSpec.kt index f144d544a..3bb105bac 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridTestViewSpec.kt +++ b/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/HybridTestViewSpec.kt @@ -65,7 +65,7 @@ abstract class HybridTestViewSpec: HybridView() { // Default implementation of `HybridObject.toString()` override fun toString(): String { - return "[HybridObject TestView]" + return "[HybridObject NitroTestTestView]" } // C++ backing class diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/views/HybridRecyclableTestViewManager.kt b/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/views/HybridRecyclableTestViewManager.kt index c325e51a5..75196045e 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/views/HybridRecyclableTestViewManager.kt +++ b/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/views/HybridRecyclableTestViewManager.kt @@ -28,7 +28,7 @@ public class HybridRecyclableTestViewManager: SimpleViewManager() { } override fun getName(): String { - return "RecyclableTestView" + return "NitroTestRecyclableTestView" } override fun createViewInstance(reactContext: ThemedReactContext): View { diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/views/HybridTestViewManager.kt b/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/views/HybridTestViewManager.kt index 6ee9d802a..acd47b465 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/views/HybridTestViewManager.kt +++ b/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/views/HybridTestViewManager.kt @@ -28,7 +28,7 @@ public class HybridTestViewManager: SimpleViewManager() { } override fun getName(): String { - return "TestView" + return "NitroTestTestView" } override fun createViewInstance(reactContext: ThemedReactContext): View { diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/NitroTest-Swift-Cxx-Bridge.cpp b/packages/react-native-nitro-test/nitrogen/generated/ios/NitroTest-Swift-Cxx-Bridge.cpp index 7b54268b1..033e152b5 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/NitroTest-Swift-Cxx-Bridge.cpp +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/NitroTest-Swift-Cxx-Bridge.cpp @@ -8,13 +8,13 @@ #include "NitroTest-Swift-Cxx-Bridge.hpp" // Include C++ implementation defined types -#include "HybridBaseSpecSwift.hpp" -#include "HybridChildSpecSwift.hpp" -#include "HybridPlatformObjectSpecSwift.hpp" -#include "HybridRecyclableTestViewSpecSwift.hpp" -#include "HybridTestObjectSwiftKotlinSpecSwift.hpp" -#include "HybridTestViewSpecSwift.hpp" #include "NitroTest-Swift-Cxx-Umbrella.hpp" +#include "NitroTestHybridBaseSpecSwift.hpp" +#include "NitroTestHybridChildSpecSwift.hpp" +#include "NitroTestHybridPlatformObjectSpecSwift.hpp" +#include "NitroTestHybridRecyclableTestViewSpecSwift.hpp" +#include "NitroTestHybridTestObjectSwiftKotlinSpecSwift.hpp" +#include "NitroTestHybridTestViewSpecSwift.hpp" #include #include diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/NitroTest-Swift-Cxx-Bridge.hpp b/packages/react-native-nitro-test/nitrogen/generated/ios/NitroTest-Swift-Cxx-Bridge.hpp index 6be8569b2..34f9a5f60 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/NitroTest-Swift-Cxx-Bridge.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/NitroTest-Swift-Cxx-Bridge.hpp @@ -64,23 +64,23 @@ namespace NitroTest { class HybridTestObjectSwiftKotlinSpec_cxx; } namespace NitroTest { class HybridTestViewSpec_cxx; } // Include C++ defined types -#include "Car.hpp" -#include "ExternalObjectStruct.hpp" -#include "HybridBaseSpec.hpp" -#include "HybridChildSpec.hpp" -#include "HybridPlatformObjectSpec.hpp" -#include "HybridRecyclableTestViewSpec.hpp" -#include "HybridTestObjectSwiftKotlinSpec.hpp" -#include "HybridTestViewSpec.hpp" -#include "JsStyleStruct.hpp" -#include "OldEnum.hpp" -#include "OptionalCallback.hpp" -#include "OptionalWrapper.hpp" -#include "PartialPerson.hpp" -#include "Person.hpp" -#include "Powertrain.hpp" -#include "WeirdNumbersEnum.hpp" -#include "WrappedJsStruct.hpp" +#include "NitroTestCar.hpp" +#include "NitroTestExternalObjectStruct.hpp" +#include "NitroTestHybridBaseSpec.hpp" +#include "NitroTestHybridChildSpec.hpp" +#include "NitroTestHybridPlatformObjectSpec.hpp" +#include "NitroTestHybridRecyclableTestViewSpec.hpp" +#include "NitroTestHybridTestObjectSwiftKotlinSpec.hpp" +#include "NitroTestHybridTestViewSpec.hpp" +#include "NitroTestJsStyleStruct.hpp" +#include "NitroTestOldEnum.hpp" +#include "NitroTestOptionalCallback.hpp" +#include "NitroTestOptionalWrapper.hpp" +#include "NitroTestPartialPerson.hpp" +#include "NitroTestPerson.hpp" +#include "NitroTestPowertrain.hpp" +#include "NitroTestWeirdNumbersEnum.hpp" +#include "NitroTestWrappedJsStruct.hpp" #include #include #include @@ -88,7 +88,7 @@ namespace NitroTest { class HybridTestViewSpec_cxx; } #include #include #include -#include +#include #include #include #include diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/NitroTest-Swift-Cxx-Umbrella.hpp b/packages/react-native-nitro-test/nitrogen/generated/ios/NitroTest-Swift-Cxx-Umbrella.hpp index 861fc58f4..51a2bbb80 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/NitroTest-Swift-Cxx-Umbrella.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/NitroTest-Swift-Cxx-Umbrella.hpp @@ -52,32 +52,32 @@ namespace margelo::nitro::test { enum class WeirdNumbersEnum; } namespace margelo::nitro::test { struct WrappedJsStruct; } // Include C++ defined types -#include "Car.hpp" -#include "ColorScheme.hpp" -#include "ExternalObjectStruct.hpp" -#include "HybridBaseSpec.hpp" -#include "HybridChildSpec.hpp" -#include "HybridPlatformObjectSpec.hpp" -#include "HybridRecyclableTestViewSpec.hpp" -#include "HybridTestObjectSwiftKotlinSpec.hpp" -#include "HybridTestViewSpec.hpp" -#include "JsStyleStruct.hpp" -#include "MapWrapper.hpp" -#include "OldEnum.hpp" -#include "OptionalCallback.hpp" -#include "OptionalWrapper.hpp" -#include "PartialPerson.hpp" -#include "Person.hpp" -#include "Powertrain.hpp" -#include "SecondMapWrapper.hpp" -#include "WeirdNumbersEnum.hpp" -#include "WrappedJsStruct.hpp" +#include "NitroTestCar.hpp" +#include "NitroTestColorScheme.hpp" +#include "NitroTestExternalObjectStruct.hpp" +#include "NitroTestHybridBaseSpec.hpp" +#include "NitroTestHybridChildSpec.hpp" +#include "NitroTestHybridPlatformObjectSpec.hpp" +#include "NitroTestHybridRecyclableTestViewSpec.hpp" +#include "NitroTestHybridTestObjectSwiftKotlinSpec.hpp" +#include "NitroTestHybridTestViewSpec.hpp" +#include "NitroTestJsStyleStruct.hpp" +#include "NitroTestMapWrapper.hpp" +#include "NitroTestOldEnum.hpp" +#include "NitroTestOptionalCallback.hpp" +#include "NitroTestOptionalWrapper.hpp" +#include "NitroTestPartialPerson.hpp" +#include "NitroTestPerson.hpp" +#include "NitroTestPowertrain.hpp" +#include "NitroTestSecondMapWrapper.hpp" +#include "NitroTestWeirdNumbersEnum.hpp" +#include "NitroTestWrappedJsStruct.hpp" #include #include #include #include #include -#include +#include #include #include #include diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/NitroTestAutolinking.mm b/packages/react-native-nitro-test/nitrogen/generated/ios/NitroTestAutolinking.mm index 1a2b5b22c..0e3200d88 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/NitroTestAutolinking.mm +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/NitroTestAutolinking.mm @@ -11,12 +11,12 @@ #import #include "HybridTestObjectCpp.hpp" -#include "HybridTestObjectSwiftKotlinSpecSwift.hpp" -#include "HybridBaseSpecSwift.hpp" -#include "HybridChildSpecSwift.hpp" -#include "HybridPlatformObjectSpecSwift.hpp" -#include "HybridTestViewSpecSwift.hpp" -#include "HybridRecyclableTestViewSpecSwift.hpp" +#include "NitroTestHybridTestObjectSwiftKotlinSpecSwift.hpp" +#include "NitroTestHybridBaseSpecSwift.hpp" +#include "NitroTestHybridChildSpecSwift.hpp" +#include "NitroTestHybridPlatformObjectSpecSwift.hpp" +#include "NitroTestHybridTestViewSpecSwift.hpp" +#include "NitroTestHybridRecyclableTestViewSpecSwift.hpp" @interface NitroTestAutolinking : NSObject @end @@ -28,7 +28,7 @@ + (void) load { using namespace margelo::nitro::test; HybridObjectRegistry::registerHybridObjectConstructor( - "TestObjectCpp", + "NitroTestTestObjectCpp", []() -> std::shared_ptr { static_assert(std::is_default_constructible_v, "The HybridObject \"HybridTestObjectCpp\" is not default-constructible! " @@ -37,42 +37,42 @@ + (void) load { } ); HybridObjectRegistry::registerHybridObjectConstructor( - "TestObjectSwiftKotlin", + "NitroTestTestObjectSwiftKotlin", []() -> std::shared_ptr { std::shared_ptr hybridObject = NitroTest::NitroTestAutolinking::createTestObjectSwiftKotlin(); return hybridObject; } ); HybridObjectRegistry::registerHybridObjectConstructor( - "Base", + "NitroTestBase", []() -> std::shared_ptr { std::shared_ptr hybridObject = NitroTest::NitroTestAutolinking::createBase(); return hybridObject; } ); HybridObjectRegistry::registerHybridObjectConstructor( - "Child", + "NitroTestChild", []() -> std::shared_ptr { std::shared_ptr hybridObject = NitroTest::NitroTestAutolinking::createChild(); return hybridObject; } ); HybridObjectRegistry::registerHybridObjectConstructor( - "PlatformObject", + "NitroTestPlatformObject", []() -> std::shared_ptr { std::shared_ptr hybridObject = NitroTest::NitroTestAutolinking::createPlatformObject(); return hybridObject; } ); HybridObjectRegistry::registerHybridObjectConstructor( - "TestView", + "NitroTestTestView", []() -> std::shared_ptr { std::shared_ptr hybridObject = NitroTest::NitroTestAutolinking::createTestView(); return hybridObject; } ); HybridObjectRegistry::registerHybridObjectConstructor( - "RecyclableTestView", + "NitroTestRecyclableTestView", []() -> std::shared_ptr { std::shared_ptr hybridObject = NitroTest::NitroTestAutolinking::createRecyclableTestView(); return hybridObject; diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridTestObjectSwiftKotlinSpecSwift.cpp b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridTestObjectSwiftKotlinSpecSwift.cpp deleted file mode 100644 index 078d47e43..000000000 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridTestObjectSwiftKotlinSpecSwift.cpp +++ /dev/null @@ -1,11 +0,0 @@ -/// -/// HybridTestObjectSwiftKotlinSpecSwift.cpp -/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. -/// https://github.com/mrousavy/nitro -/// Copyright © Marc Rousavy @ Margelo -/// - -#include "HybridTestObjectSwiftKotlinSpecSwift.hpp" - -namespace margelo::nitro::test { -} // namespace margelo::nitro::test diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridTestViewSpecSwift.cpp b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridBaseSpecSwift.cpp similarity index 73% rename from packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridTestViewSpecSwift.cpp rename to packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridBaseSpecSwift.cpp index cd21d608a..3c89f6c01 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridTestViewSpecSwift.cpp +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridBaseSpecSwift.cpp @@ -1,11 +1,11 @@ /// -/// HybridTestViewSpecSwift.cpp +/// NitroTestHybridBaseSpecSwift.cpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo /// -#include "HybridTestViewSpecSwift.hpp" +#include "NitroTestHybridBaseSpecSwift.hpp" namespace margelo::nitro::test { } // namespace margelo::nitro::test diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridBaseSpecSwift.hpp b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridBaseSpecSwift.hpp similarity index 96% rename from packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridBaseSpecSwift.hpp rename to packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridBaseSpecSwift.hpp index 413f19ffb..22b18a341 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridBaseSpecSwift.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridBaseSpecSwift.hpp @@ -1,5 +1,5 @@ /// -/// HybridBaseSpecSwift.hpp +/// NitroTestHybridBaseSpecSwift.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -7,7 +7,7 @@ #pragma once -#include "HybridBaseSpec.hpp" +#include "NitroTestHybridBaseSpec.hpp" // Forward declaration of `HybridBaseSpec_cxx` to properly resolve imports. namespace NitroTest { class HybridBaseSpec_cxx; } diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridBaseSpecSwift.cpp b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridChildSpecSwift.cpp similarity index 72% rename from packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridBaseSpecSwift.cpp rename to packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridChildSpecSwift.cpp index 9b5099bad..f432c8ab7 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridBaseSpecSwift.cpp +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridChildSpecSwift.cpp @@ -1,11 +1,11 @@ /// -/// HybridBaseSpecSwift.cpp +/// NitroTestHybridChildSpecSwift.cpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo /// -#include "HybridBaseSpecSwift.hpp" +#include "NitroTestHybridChildSpecSwift.hpp" namespace margelo::nitro::test { } // namespace margelo::nitro::test diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridChildSpecSwift.hpp b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridChildSpecSwift.hpp similarity index 93% rename from packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridChildSpecSwift.hpp rename to packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridChildSpecSwift.hpp index 631a79677..31e0cf3de 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridChildSpecSwift.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridChildSpecSwift.hpp @@ -1,5 +1,5 @@ /// -/// HybridChildSpecSwift.hpp +/// NitroTestHybridChildSpecSwift.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -7,7 +7,7 @@ #pragma once -#include "HybridChildSpec.hpp" +#include "NitroTestHybridChildSpec.hpp" // Forward declaration of `HybridChildSpec_cxx` to properly resolve imports. namespace NitroTest { class HybridChildSpec_cxx; } @@ -22,13 +22,13 @@ namespace margelo::nitro::test { struct Person; } namespace margelo::nitro::test { class HybridBaseSpecSwift; } #include -#include "Car.hpp" +#include "NitroTestCar.hpp" #include -#include "Powertrain.hpp" -#include "Person.hpp" +#include "NitroTestPowertrain.hpp" +#include "NitroTestPerson.hpp" #include #include -#include "HybridBaseSpecSwift.hpp" +#include "NitroTestHybridBaseSpecSwift.hpp" #include "NitroTest-Swift-Cxx-Umbrella.hpp" diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridRecyclableTestViewSpecSwift.cpp b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridPlatformObjectSpecSwift.cpp similarity index 68% rename from packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridRecyclableTestViewSpecSwift.cpp rename to packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridPlatformObjectSpecSwift.cpp index a7dd92caf..a824ca63e 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridRecyclableTestViewSpecSwift.cpp +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridPlatformObjectSpecSwift.cpp @@ -1,11 +1,11 @@ /// -/// HybridRecyclableTestViewSpecSwift.cpp +/// NitroTestHybridPlatformObjectSpecSwift.cpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo /// -#include "HybridRecyclableTestViewSpecSwift.hpp" +#include "NitroTestHybridPlatformObjectSpecSwift.hpp" namespace margelo::nitro::test { } // namespace margelo::nitro::test diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridPlatformObjectSpecSwift.hpp b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridPlatformObjectSpecSwift.hpp similarity index 96% rename from packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridPlatformObjectSpecSwift.hpp rename to packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridPlatformObjectSpecSwift.hpp index d1268acc3..98c67f248 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridPlatformObjectSpecSwift.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridPlatformObjectSpecSwift.hpp @@ -1,5 +1,5 @@ /// -/// HybridPlatformObjectSpecSwift.hpp +/// NitroTestHybridPlatformObjectSpecSwift.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -7,7 +7,7 @@ #pragma once -#include "HybridPlatformObjectSpec.hpp" +#include "NitroTestHybridPlatformObjectSpec.hpp" // Forward declaration of `HybridPlatformObjectSpec_cxx` to properly resolve imports. namespace NitroTest { class HybridPlatformObjectSpec_cxx; } diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridPlatformObjectSpecSwift.cpp b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridRecyclableTestViewSpecSwift.cpp similarity index 67% rename from packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridPlatformObjectSpecSwift.cpp rename to packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridRecyclableTestViewSpecSwift.cpp index 3ed83a327..272ca322d 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridPlatformObjectSpecSwift.cpp +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridRecyclableTestViewSpecSwift.cpp @@ -1,11 +1,11 @@ /// -/// HybridPlatformObjectSpecSwift.cpp +/// NitroTestHybridRecyclableTestViewSpecSwift.cpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo /// -#include "HybridPlatformObjectSpecSwift.hpp" +#include "NitroTestHybridRecyclableTestViewSpecSwift.hpp" namespace margelo::nitro::test { } // namespace margelo::nitro::test diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridRecyclableTestViewSpecSwift.hpp b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridRecyclableTestViewSpecSwift.hpp similarity index 95% rename from packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridRecyclableTestViewSpecSwift.hpp rename to packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridRecyclableTestViewSpecSwift.hpp index 88c2df2bf..53193163c 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridRecyclableTestViewSpecSwift.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridRecyclableTestViewSpecSwift.hpp @@ -1,5 +1,5 @@ /// -/// HybridRecyclableTestViewSpecSwift.hpp +/// NitroTestHybridRecyclableTestViewSpecSwift.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -7,7 +7,7 @@ #pragma once -#include "HybridRecyclableTestViewSpec.hpp" +#include "NitroTestHybridRecyclableTestViewSpec.hpp" // Forward declaration of `HybridRecyclableTestViewSpec_cxx` to properly resolve imports. namespace NitroTest { class HybridRecyclableTestViewSpec_cxx; } diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridTestObjectSwiftKotlinSpecSwift.cpp b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridTestObjectSwiftKotlinSpecSwift.cpp new file mode 100644 index 000000000..6c401c4ec --- /dev/null +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridTestObjectSwiftKotlinSpecSwift.cpp @@ -0,0 +1,11 @@ +/// +/// NitroTestHybridTestObjectSwiftKotlinSpecSwift.cpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#include "NitroTestHybridTestObjectSwiftKotlinSpecSwift.hpp" + +namespace margelo::nitro::test { +} // namespace margelo::nitro::test diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridTestObjectSwiftKotlinSpecSwift.hpp b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridTestObjectSwiftKotlinSpecSwift.hpp similarity index 98% rename from packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridTestObjectSwiftKotlinSpecSwift.hpp rename to packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridTestObjectSwiftKotlinSpecSwift.hpp index f593576d1..815250669 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridTestObjectSwiftKotlinSpecSwift.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridTestObjectSwiftKotlinSpecSwift.hpp @@ -1,5 +1,5 @@ /// -/// HybridTestObjectSwiftKotlinSpecSwift.hpp +/// NitroTestHybridTestObjectSwiftKotlinSpecSwift.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -7,7 +7,7 @@ #pragma once -#include "HybridTestObjectSwiftKotlinSpec.hpp" +#include "NitroTestHybridTestObjectSwiftKotlinSpec.hpp" // Forward declaration of `HybridTestObjectSwiftKotlinSpec_cxx` to properly resolve imports. namespace NitroTest { class HybridTestObjectSwiftKotlinSpec_cxx; } @@ -52,37 +52,37 @@ namespace margelo::nitro::test::external { class HybridSomeExternalObjectSpec; } namespace margelo::nitro::test { struct ExternalObjectStruct; } #include -#include "HybridTestObjectSwiftKotlinSpec.hpp" +#include "NitroTestHybridTestObjectSwiftKotlinSpec.hpp" #include #include #include #include #include -#include "Powertrain.hpp" -#include "OldEnum.hpp" +#include "NitroTestPowertrain.hpp" +#include "NitroTestOldEnum.hpp" #include -#include "Person.hpp" -#include "PartialPerson.hpp" -#include "Car.hpp" -#include "HybridChildSpec.hpp" +#include "NitroTestPerson.hpp" +#include "NitroTestPartialPerson.hpp" +#include "NitroTestCar.hpp" +#include "NitroTestHybridChildSpec.hpp" #include #include #include #include #include -#include "MapWrapper.hpp" -#include "SecondMapWrapper.hpp" +#include "NitroTestMapWrapper.hpp" +#include "NitroTestSecondMapWrapper.hpp" #include #include -#include "JsStyleStruct.hpp" -#include "WrappedJsStruct.hpp" -#include "OptionalWrapper.hpp" -#include "OptionalCallback.hpp" -#include "WeirdNumbersEnum.hpp" -#include "HybridBaseSpec.hpp" -#include "HybridTestViewSpec.hpp" -#include -#include "ExternalObjectStruct.hpp" +#include "NitroTestJsStyleStruct.hpp" +#include "NitroTestWrappedJsStruct.hpp" +#include "NitroTestOptionalWrapper.hpp" +#include "NitroTestOptionalCallback.hpp" +#include "NitroTestWeirdNumbersEnum.hpp" +#include "NitroTestHybridBaseSpec.hpp" +#include "NitroTestHybridTestViewSpec.hpp" +#include +#include "NitroTestExternalObjectStruct.hpp" #include "NitroTest-Swift-Cxx-Umbrella.hpp" diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridChildSpecSwift.cpp b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridTestViewSpecSwift.cpp similarity index 71% rename from packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridChildSpecSwift.cpp rename to packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridTestViewSpecSwift.cpp index 736e7065f..ba2fda8ce 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridChildSpecSwift.cpp +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridTestViewSpecSwift.cpp @@ -1,11 +1,11 @@ /// -/// HybridChildSpecSwift.cpp +/// NitroTestHybridTestViewSpecSwift.cpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo /// -#include "HybridChildSpecSwift.hpp" +#include "NitroTestHybridTestViewSpecSwift.hpp" namespace margelo::nitro::test { } // namespace margelo::nitro::test diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridTestViewSpecSwift.hpp b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridTestViewSpecSwift.hpp similarity index 96% rename from packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridTestViewSpecSwift.hpp rename to packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridTestViewSpecSwift.hpp index 986c483ac..1b3d1c3ab 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/HybridTestViewSpecSwift.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/NitroTestHybridTestViewSpecSwift.hpp @@ -1,5 +1,5 @@ /// -/// HybridTestViewSpecSwift.hpp +/// NitroTestHybridTestViewSpecSwift.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -7,7 +7,7 @@ #pragma once -#include "HybridTestViewSpec.hpp" +#include "NitroTestHybridTestViewSpec.hpp" // Forward declaration of `HybridTestViewSpec_cxx` to properly resolve imports. namespace NitroTest { class HybridTestViewSpec_cxx; } @@ -15,7 +15,7 @@ namespace NitroTest { class HybridTestViewSpec_cxx; } // Forward declaration of `ColorScheme` to properly resolve imports. namespace margelo::nitro::test { enum class ColorScheme; } -#include "ColorScheme.hpp" +#include "NitroTestColorScheme.hpp" #include #include "NitroTest-Swift-Cxx-Umbrella.hpp" diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/views/HybridRecyclableTestViewComponent.mm b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/views/NitroTestHybridRecyclableTestViewComponent.mm similarity index 90% rename from packages/react-native-nitro-test/nitrogen/generated/ios/c++/views/HybridRecyclableTestViewComponent.mm rename to packages/react-native-nitro-test/nitrogen/generated/ios/c++/views/NitroTestHybridRecyclableTestViewComponent.mm index 06ecc420d..41255110c 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/views/HybridRecyclableTestViewComponent.mm +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/views/NitroTestHybridRecyclableTestViewComponent.mm @@ -1,11 +1,11 @@ /// -/// HybridRecyclableTestViewComponent.mm +/// NitroTestHybridRecyclableTestViewComponent.mm /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo /// -#import "HybridRecyclableTestViewComponent.hpp" +#import "NitroTestHybridRecyclableTestViewComponent.hpp" #import #import #import @@ -14,7 +14,7 @@ #import #import -#import "HybridRecyclableTestViewSpecSwift.hpp" +#import "NitroTestHybridRecyclableTestViewSpecSwift.hpp" #import "NitroTest-Swift-Cxx-Umbrella.hpp" #if __has_include() @@ -31,17 +31,17 @@ /** * Represents the React Native View holder for the Nitro "RecyclableTestView" HybridView. */ -@interface HybridRecyclableTestViewComponent: RCTViewComponentView +@interface NitroTestHybridRecyclableTestViewComponent: RCTViewComponentView + (BOOL)shouldBeRecycled; @end -@implementation HybridRecyclableTestViewComponent { +@implementation NitroTestHybridRecyclableTestViewComponent { std::shared_ptr _hybridView; } + (void) load { [super load]; - [RCTComponentViewFactory.currentComponentViewFactory registerComponentViewClass:[HybridRecyclableTestViewComponent class]]; + [RCTComponentViewFactory.currentComponentViewFactory registerComponentViewClass:[NitroTestHybridRecyclableTestViewComponent class]]; } + (react::ComponentDescriptorProvider) componentDescriptorProvider { diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/views/HybridTestViewComponent.mm b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/views/NitroTestHybridTestViewComponent.mm similarity index 92% rename from packages/react-native-nitro-test/nitrogen/generated/ios/c++/views/HybridTestViewComponent.mm rename to packages/react-native-nitro-test/nitrogen/generated/ios/c++/views/NitroTestHybridTestViewComponent.mm index 191b76da7..58ebb664b 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/views/HybridTestViewComponent.mm +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/views/NitroTestHybridTestViewComponent.mm @@ -1,11 +1,11 @@ /// -/// HybridTestViewComponent.mm +/// NitroTestHybridTestViewComponent.mm /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo /// -#import "HybridTestViewComponent.hpp" +#import "NitroTestHybridTestViewComponent.hpp" #import #import #import @@ -14,7 +14,7 @@ #import #import -#import "HybridTestViewSpecSwift.hpp" +#import "NitroTestHybridTestViewSpecSwift.hpp" #import "NitroTest-Swift-Cxx-Umbrella.hpp" #if __has_include() @@ -31,17 +31,17 @@ /** * Represents the React Native View holder for the Nitro "TestView" HybridView. */ -@interface HybridTestViewComponent: RCTViewComponentView +@interface NitroTestHybridTestViewComponent: RCTViewComponentView + (BOOL)shouldBeRecycled; @end -@implementation HybridTestViewComponent { +@implementation NitroTestHybridTestViewComponent { std::shared_ptr _hybridView; } + (void) load { [super load]; - [RCTComponentViewFactory.currentComponentViewFactory registerComponentViewClass:[HybridTestViewComponent class]]; + [RCTComponentViewFactory.currentComponentViewFactory registerComponentViewClass:[NitroTestHybridTestViewComponent class]]; } + (react::ComponentDescriptorProvider) componentDescriptorProvider { diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridBaseSpec.swift b/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridBaseSpec.swift index 322357dc3..6e801611b 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridBaseSpec.swift +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridBaseSpec.swift @@ -19,7 +19,7 @@ public protocol HybridBaseSpec_protocol: HybridObject { public extension HybridBaseSpec_protocol { /// Default implementation of ``HybridObject.toString`` func toString() -> String { - return "[HybridObject Base]" + return "[HybridObject NitroTestBase]" } } diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridChildSpec.swift b/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridChildSpec.swift index 060cacd64..a049951fb 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridChildSpec.swift +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridChildSpec.swift @@ -19,7 +19,7 @@ public protocol HybridChildSpec_protocol: HybridObject, HybridBaseSpec_protocol public extension HybridChildSpec_protocol { /// Default implementation of ``HybridObject.toString`` func toString() -> String { - return "[HybridObject Child]" + return "[HybridObject NitroTestChild]" } } diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridPlatformObjectSpec.swift b/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridPlatformObjectSpec.swift index 71343c2fb..714b6ef0a 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridPlatformObjectSpec.swift +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridPlatformObjectSpec.swift @@ -19,7 +19,7 @@ public protocol HybridPlatformObjectSpec_protocol: HybridObject { public extension HybridPlatformObjectSpec_protocol { /// Default implementation of ``HybridObject.toString`` func toString() -> String { - return "[HybridObject PlatformObject]" + return "[HybridObject NitroTestPlatformObject]" } } diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridRecyclableTestViewSpec.swift b/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridRecyclableTestViewSpec.swift index 6d606db6c..d74d292dd 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridRecyclableTestViewSpec.swift +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridRecyclableTestViewSpec.swift @@ -19,7 +19,7 @@ public protocol HybridRecyclableTestViewSpec_protocol: HybridObject, HybridView public extension HybridRecyclableTestViewSpec_protocol { /// Default implementation of ``HybridObject.toString`` func toString() -> String { - return "[HybridObject RecyclableTestView]" + return "[HybridObject NitroTestRecyclableTestView]" } } diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridTestObjectSwiftKotlinSpec.swift b/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridTestObjectSwiftKotlinSpec.swift index 2348b096f..e75c107bd 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridTestObjectSwiftKotlinSpec.swift +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridTestObjectSwiftKotlinSpec.swift @@ -136,7 +136,7 @@ public protocol HybridTestObjectSwiftKotlinSpec_protocol: HybridObject { public extension HybridTestObjectSwiftKotlinSpec_protocol { /// Default implementation of ``HybridObject.toString`` func toString() -> String { - return "[HybridObject TestObjectSwiftKotlin]" + return "[HybridObject NitroTestTestObjectSwiftKotlin]" } } diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridTestViewSpec.swift b/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridTestViewSpec.swift index 7f05d599a..780211c11 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridTestViewSpec.swift +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridTestViewSpec.swift @@ -22,7 +22,7 @@ public protocol HybridTestViewSpec_protocol: HybridObject, HybridView { public extension HybridTestViewSpec_protocol { /// Default implementation of ``HybridObject.toString`` func toString() -> String { - return "[HybridObject TestView]" + return "[HybridObject NitroTestTestView]" } } diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/Car.hpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestCar.hpp similarity index 98% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/Car.hpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestCar.hpp index 01dbc28c6..7ee04f11a 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/Car.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestCar.hpp @@ -1,5 +1,5 @@ /// -/// Car.hpp +/// NitroTestCar.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -34,8 +34,8 @@ namespace margelo::nitro::test { enum class Powertrain; } namespace margelo::nitro::test { struct Person; } #include -#include "Powertrain.hpp" -#include "Person.hpp" +#include "NitroTestPowertrain.hpp" +#include "NitroTestPerson.hpp" #include #include #include diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/ColorScheme.hpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestColorScheme.hpp similarity index 98% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/ColorScheme.hpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestColorScheme.hpp index 147f25be5..6180b5a51 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/ColorScheme.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestColorScheme.hpp @@ -1,5 +1,5 @@ /// -/// ColorScheme.hpp +/// NitroTestColorScheme.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/ExternalObjectStruct.hpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestExternalObjectStruct.hpp similarity index 96% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/ExternalObjectStruct.hpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestExternalObjectStruct.hpp index 1be39830d..75a6972cc 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/ExternalObjectStruct.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestExternalObjectStruct.hpp @@ -1,5 +1,5 @@ /// -/// ExternalObjectStruct.hpp +/// NitroTestExternalObjectStruct.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -32,7 +32,7 @@ namespace margelo::nitro::test::external { class HybridSomeExternalObjectSpec; } #include -#include +#include namespace margelo::nitro::test { diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridBaseSpec.cpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridBaseSpec.cpp similarity index 88% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridBaseSpec.cpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridBaseSpec.cpp index d79a5b92d..e0a1ba635 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridBaseSpec.cpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridBaseSpec.cpp @@ -1,11 +1,11 @@ /// -/// HybridBaseSpec.cpp +/// NitroTestHybridBaseSpec.cpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo /// -#include "HybridBaseSpec.hpp" +#include "NitroTestHybridBaseSpec.hpp" namespace margelo::nitro::test { diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridBaseSpec.hpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridBaseSpec.hpp similarity index 93% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridBaseSpec.hpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridBaseSpec.hpp index c816c756a..b0d305021 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridBaseSpec.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridBaseSpec.hpp @@ -1,5 +1,5 @@ /// -/// HybridBaseSpec.hpp +/// NitroTestHybridBaseSpec.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -56,7 +56,7 @@ namespace margelo::nitro::test { protected: // Tag for logging - static constexpr auto TAG = "Base"; + static constexpr auto TAG = "NitroTestBase"; }; } // namespace margelo::nitro::test diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridChildSpec.cpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridChildSpec.cpp similarity index 90% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridChildSpec.cpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridChildSpec.cpp index 49c1891e1..23e9a502a 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridChildSpec.cpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridChildSpec.cpp @@ -1,11 +1,11 @@ /// -/// HybridChildSpec.cpp +/// NitroTestHybridChildSpec.cpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo /// -#include "HybridChildSpec.hpp" +#include "NitroTestHybridChildSpec.hpp" namespace margelo::nitro::test { diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridChildSpec.hpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridChildSpec.hpp similarity index 91% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridChildSpec.hpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridChildSpec.hpp index 4167e5a84..fa69d7624 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridChildSpec.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridChildSpec.hpp @@ -1,5 +1,5 @@ /// -/// HybridChildSpec.hpp +/// NitroTestHybridChildSpec.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -19,10 +19,10 @@ namespace margelo::nitro::test { struct Car; } namespace margelo::nitro::test { class HybridBaseSpec; } #include -#include "Car.hpp" +#include "NitroTestCar.hpp" #include #include -#include "HybridBaseSpec.hpp" +#include "NitroTestHybridBaseSpec.hpp" namespace margelo::nitro::test { @@ -63,7 +63,7 @@ namespace margelo::nitro::test { protected: // Tag for logging - static constexpr auto TAG = "Child"; + static constexpr auto TAG = "NitroTestChild"; }; } // namespace margelo::nitro::test diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridPlatformObjectSpec.cpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridPlatformObjectSpec.cpp similarity index 85% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridPlatformObjectSpec.cpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridPlatformObjectSpec.cpp index 4866308ea..56d60af60 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridPlatformObjectSpec.cpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridPlatformObjectSpec.cpp @@ -1,11 +1,11 @@ /// -/// HybridPlatformObjectSpec.cpp +/// NitroTestHybridPlatformObjectSpec.cpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo /// -#include "HybridPlatformObjectSpec.hpp" +#include "NitroTestHybridPlatformObjectSpec.hpp" namespace margelo::nitro::test { diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridPlatformObjectSpec.hpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridPlatformObjectSpec.hpp similarity index 93% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridPlatformObjectSpec.hpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridPlatformObjectSpec.hpp index 48bfd5d5a..7b42f7a0e 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridPlatformObjectSpec.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridPlatformObjectSpec.hpp @@ -1,5 +1,5 @@ /// -/// HybridPlatformObjectSpec.hpp +/// NitroTestHybridPlatformObjectSpec.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -56,7 +56,7 @@ namespace margelo::nitro::test { protected: // Tag for logging - static constexpr auto TAG = "PlatformObject"; + static constexpr auto TAG = "NitroTestPlatformObject"; }; } // namespace margelo::nitro::test diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridRecyclableTestViewSpec.cpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridRecyclableTestViewSpec.cpp similarity index 86% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridRecyclableTestViewSpec.cpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridRecyclableTestViewSpec.cpp index 75f25ad74..415650666 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridRecyclableTestViewSpec.cpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridRecyclableTestViewSpec.cpp @@ -1,11 +1,11 @@ /// -/// HybridRecyclableTestViewSpec.cpp +/// NitroTestHybridRecyclableTestViewSpec.cpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo /// -#include "HybridRecyclableTestViewSpec.hpp" +#include "NitroTestHybridRecyclableTestViewSpec.hpp" namespace margelo::nitro::test { diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridRecyclableTestViewSpec.hpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridRecyclableTestViewSpec.hpp similarity index 92% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridRecyclableTestViewSpec.hpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridRecyclableTestViewSpec.hpp index 049ba9690..f06059f57 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridRecyclableTestViewSpec.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridRecyclableTestViewSpec.hpp @@ -1,5 +1,5 @@ /// -/// HybridRecyclableTestViewSpec.hpp +/// NitroTestHybridRecyclableTestViewSpec.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -57,7 +57,7 @@ namespace margelo::nitro::test { protected: // Tag for logging - static constexpr auto TAG = "RecyclableTestView"; + static constexpr auto TAG = "NitroTestRecyclableTestView"; }; } // namespace margelo::nitro::test diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridTestObjectCppSpec.cpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridTestObjectCppSpec.cpp similarity index 99% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridTestObjectCppSpec.cpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridTestObjectCppSpec.cpp index 51242a503..782a40062 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridTestObjectCppSpec.cpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridTestObjectCppSpec.cpp @@ -1,11 +1,11 @@ /// -/// HybridTestObjectCppSpec.cpp +/// NitroTestHybridTestObjectCppSpec.cpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo /// -#include "HybridTestObjectCppSpec.hpp" +#include "NitroTestHybridTestObjectCppSpec.hpp" namespace margelo::nitro::test { diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridTestObjectCppSpec.hpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridTestObjectCppSpec.hpp similarity index 95% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridTestObjectCppSpec.hpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridTestObjectCppSpec.hpp index fb0dd217d..6076c5630 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridTestObjectCppSpec.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridTestObjectCppSpec.hpp @@ -1,5 +1,5 @@ /// -/// HybridTestObjectCppSpec.hpp +/// NitroTestHybridTestObjectCppSpec.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -53,36 +53,36 @@ namespace margelo::nitro::test { struct ExternalObjectStruct; } #include #include #include -#include "HybridTestObjectCppSpec.hpp" +#include "NitroTestHybridTestObjectCppSpec.hpp" #include #include #include #include -#include "Powertrain.hpp" -#include "OldEnum.hpp" +#include "NitroTestPowertrain.hpp" +#include "NitroTestOldEnum.hpp" #include -#include "Person.hpp" +#include "NitroTestPerson.hpp" #include #include "CustomString.hpp" -#include "PartialPerson.hpp" -#include "Car.hpp" -#include "HybridChildSpec.hpp" +#include "NitroTestPartialPerson.hpp" +#include "NitroTestCar.hpp" +#include "NitroTestHybridChildSpec.hpp" #include #include #include #include -#include "MapWrapper.hpp" +#include "NitroTestMapWrapper.hpp" #include #include -#include "JsStyleStruct.hpp" -#include "WrappedJsStruct.hpp" -#include "OptionalWrapper.hpp" -#include "OptionalCallback.hpp" -#include "WeirdNumbersEnum.hpp" -#include "HybridBaseSpec.hpp" -#include "HybridTestViewSpec.hpp" -#include -#include "ExternalObjectStruct.hpp" +#include "NitroTestJsStyleStruct.hpp" +#include "NitroTestWrappedJsStruct.hpp" +#include "NitroTestOptionalWrapper.hpp" +#include "NitroTestOptionalCallback.hpp" +#include "NitroTestWeirdNumbersEnum.hpp" +#include "NitroTestHybridBaseSpec.hpp" +#include "NitroTestHybridTestViewSpec.hpp" +#include +#include "NitroTestExternalObjectStruct.hpp" namespace margelo::nitro::test { @@ -263,7 +263,7 @@ namespace margelo::nitro::test { protected: // Tag for logging - static constexpr auto TAG = "TestObjectCpp"; + static constexpr auto TAG = "NitroTestTestObjectCpp"; }; } // namespace margelo::nitro::test diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridTestObjectSwiftKotlinSpec.cpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridTestObjectSwiftKotlinSpec.cpp similarity index 99% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridTestObjectSwiftKotlinSpec.cpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridTestObjectSwiftKotlinSpec.cpp index aa7df70ca..a5028ae4d 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridTestObjectSwiftKotlinSpec.cpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridTestObjectSwiftKotlinSpec.cpp @@ -1,11 +1,11 @@ /// -/// HybridTestObjectSwiftKotlinSpec.cpp +/// NitroTestHybridTestObjectSwiftKotlinSpec.cpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo /// -#include "HybridTestObjectSwiftKotlinSpec.hpp" +#include "NitroTestHybridTestObjectSwiftKotlinSpec.hpp" namespace margelo::nitro::test { diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridTestObjectSwiftKotlinSpec.hpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridTestObjectSwiftKotlinSpec.hpp similarity index 95% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridTestObjectSwiftKotlinSpec.hpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridTestObjectSwiftKotlinSpec.hpp index e7f82b8de..7d951f92b 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridTestObjectSwiftKotlinSpec.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridTestObjectSwiftKotlinSpec.hpp @@ -1,5 +1,5 @@ /// -/// HybridTestObjectSwiftKotlinSpec.hpp +/// NitroTestHybridTestObjectSwiftKotlinSpec.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -49,35 +49,35 @@ namespace margelo::nitro::test::external { class HybridSomeExternalObjectSpec; } namespace margelo::nitro::test { struct ExternalObjectStruct; } #include -#include "HybridTestObjectSwiftKotlinSpec.hpp" +#include "NitroTestHybridTestObjectSwiftKotlinSpec.hpp" #include #include #include #include #include -#include "Powertrain.hpp" -#include "OldEnum.hpp" +#include "NitroTestPowertrain.hpp" +#include "NitroTestOldEnum.hpp" #include -#include "Person.hpp" -#include "PartialPerson.hpp" -#include "Car.hpp" -#include "HybridChildSpec.hpp" +#include "NitroTestPerson.hpp" +#include "NitroTestPartialPerson.hpp" +#include "NitroTestCar.hpp" +#include "NitroTestHybridChildSpec.hpp" #include #include #include #include -#include "MapWrapper.hpp" +#include "NitroTestMapWrapper.hpp" #include #include -#include "JsStyleStruct.hpp" -#include "WrappedJsStruct.hpp" -#include "OptionalWrapper.hpp" -#include "OptionalCallback.hpp" -#include "WeirdNumbersEnum.hpp" -#include "HybridBaseSpec.hpp" -#include "HybridTestViewSpec.hpp" -#include -#include "ExternalObjectStruct.hpp" +#include "NitroTestJsStyleStruct.hpp" +#include "NitroTestWrappedJsStruct.hpp" +#include "NitroTestOptionalWrapper.hpp" +#include "NitroTestOptionalCallback.hpp" +#include "NitroTestWeirdNumbersEnum.hpp" +#include "NitroTestHybridBaseSpec.hpp" +#include "NitroTestHybridTestViewSpec.hpp" +#include +#include "NitroTestExternalObjectStruct.hpp" namespace margelo::nitro::test { @@ -251,7 +251,7 @@ namespace margelo::nitro::test { protected: // Tag for logging - static constexpr auto TAG = "TestObjectSwiftKotlin"; + static constexpr auto TAG = "NitroTestTestObjectSwiftKotlin"; }; } // namespace margelo::nitro::test diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridTestViewSpec.cpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridTestViewSpec.cpp similarity index 94% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridTestViewSpec.cpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridTestViewSpec.cpp index 59067d7f9..54ded6dbf 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridTestViewSpec.cpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridTestViewSpec.cpp @@ -1,11 +1,11 @@ /// -/// HybridTestViewSpec.cpp +/// NitroTestHybridTestViewSpec.cpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo /// -#include "HybridTestViewSpec.hpp" +#include "NitroTestHybridTestViewSpec.hpp" namespace margelo::nitro::test { diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridTestViewSpec.hpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridTestViewSpec.hpp similarity index 93% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridTestViewSpec.hpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridTestViewSpec.hpp index 463f36360..6a205d091 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/HybridTestViewSpec.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestHybridTestViewSpec.hpp @@ -1,5 +1,5 @@ /// -/// HybridTestViewSpec.hpp +/// NitroTestHybridTestViewSpec.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -16,7 +16,7 @@ // Forward declaration of `ColorScheme` to properly resolve imports. namespace margelo::nitro::test { enum class ColorScheme; } -#include "ColorScheme.hpp" +#include "NitroTestColorScheme.hpp" #include namespace margelo::nitro::test { @@ -65,7 +65,7 @@ namespace margelo::nitro::test { protected: // Tag for logging - static constexpr auto TAG = "TestView"; + static constexpr auto TAG = "NitroTestTestView"; }; } // namespace margelo::nitro::test diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/JsStyleStruct.hpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestJsStyleStruct.hpp similarity index 99% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/JsStyleStruct.hpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestJsStyleStruct.hpp index 4b7c4ccf3..9a74a8748 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/JsStyleStruct.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestJsStyleStruct.hpp @@ -1,5 +1,5 @@ /// -/// JsStyleStruct.hpp +/// NitroTestJsStyleStruct.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/MapWrapper.hpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestMapWrapper.hpp similarity index 98% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/MapWrapper.hpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestMapWrapper.hpp index 5d2e05460..49b8e0261 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/MapWrapper.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestMapWrapper.hpp @@ -1,5 +1,5 @@ /// -/// MapWrapper.hpp +/// NitroTestMapWrapper.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -33,7 +33,7 @@ namespace margelo::nitro::test { struct SecondMapWrapper; } #include #include -#include "SecondMapWrapper.hpp" +#include "NitroTestSecondMapWrapper.hpp" namespace margelo::nitro::test { diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/OldEnum.hpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestOldEnum.hpp similarity index 98% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/OldEnum.hpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestOldEnum.hpp index 28ead8441..6f440dcfe 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/OldEnum.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestOldEnum.hpp @@ -1,5 +1,5 @@ /// -/// OldEnum.hpp +/// NitroTestOldEnum.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/OptionalCallback.hpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestOptionalCallback.hpp similarity index 98% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/OptionalCallback.hpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestOptionalCallback.hpp index fc448b52e..189d240c8 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/OptionalCallback.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestOptionalCallback.hpp @@ -1,5 +1,5 @@ /// -/// OptionalCallback.hpp +/// NitroTestOptionalCallback.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/OptionalWrapper.hpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestOptionalWrapper.hpp similarity index 99% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/OptionalWrapper.hpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestOptionalWrapper.hpp index 2f6de6bcd..ace19fbc7 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/OptionalWrapper.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestOptionalWrapper.hpp @@ -1,5 +1,5 @@ /// -/// OptionalWrapper.hpp +/// NitroTestOptionalWrapper.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/PartialPerson.hpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestPartialPerson.hpp similarity index 99% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/PartialPerson.hpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestPartialPerson.hpp index f3e43a0fd..ce438fb54 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/PartialPerson.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestPartialPerson.hpp @@ -1,5 +1,5 @@ /// -/// PartialPerson.hpp +/// NitroTestPartialPerson.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/Person.hpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestPerson.hpp similarity index 99% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/Person.hpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestPerson.hpp index 700dd3548..0c7cd7a0c 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/Person.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestPerson.hpp @@ -1,5 +1,5 @@ /// -/// Person.hpp +/// NitroTestPerson.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/Powertrain.hpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestPowertrain.hpp similarity index 99% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/Powertrain.hpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestPowertrain.hpp index cd2cb9f50..66ffde854 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/Powertrain.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestPowertrain.hpp @@ -1,5 +1,5 @@ /// -/// Powertrain.hpp +/// NitroTestPowertrain.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/SecondMapWrapper.hpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestSecondMapWrapper.hpp similarity index 98% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/SecondMapWrapper.hpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestSecondMapWrapper.hpp index 3444b0302..746a44e7d 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/SecondMapWrapper.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestSecondMapWrapper.hpp @@ -1,5 +1,5 @@ /// -/// SecondMapWrapper.hpp +/// NitroTestSecondMapWrapper.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/WeirdNumbersEnum.hpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestWeirdNumbersEnum.hpp similarity index 98% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/WeirdNumbersEnum.hpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestWeirdNumbersEnum.hpp index ff6b34e4a..6fcfb2c9d 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/WeirdNumbersEnum.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestWeirdNumbersEnum.hpp @@ -1,5 +1,5 @@ /// -/// WeirdNumbersEnum.hpp +/// NitroTestWeirdNumbersEnum.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/WrappedJsStruct.hpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestWrappedJsStruct.hpp similarity index 98% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/WrappedJsStruct.hpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestWrappedJsStruct.hpp index b27a51f19..14958847e 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/WrappedJsStruct.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/NitroTestWrappedJsStruct.hpp @@ -1,5 +1,5 @@ /// -/// WrappedJsStruct.hpp +/// NitroTestWrappedJsStruct.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -31,7 +31,7 @@ // Forward declaration of `JsStyleStruct` to properly resolve imports. namespace margelo::nitro::test { struct JsStyleStruct; } -#include "JsStyleStruct.hpp" +#include "NitroTestJsStyleStruct.hpp" #include namespace margelo::nitro::test { diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/HybridRecyclableTestViewComponent.cpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/NitroTestHybridRecyclableTestViewComponent.cpp similarity index 95% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/HybridRecyclableTestViewComponent.cpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/NitroTestHybridRecyclableTestViewComponent.cpp index 26f75060e..367deff62 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/HybridRecyclableTestViewComponent.cpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/NitroTestHybridRecyclableTestViewComponent.cpp @@ -1,11 +1,11 @@ /// -/// HybridRecyclableTestViewComponent.cpp +/// NitroTestHybridRecyclableTestViewComponent.cpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo /// -#include "HybridRecyclableTestViewComponent.hpp" +#include "NitroTestHybridRecyclableTestViewComponent.hpp" #include #include @@ -20,7 +20,7 @@ namespace margelo::nitro::test::views { - extern const char HybridRecyclableTestViewComponentName[] = "RecyclableTestView"; + extern const char HybridRecyclableTestViewComponentName[] = "NitroTestRecyclableTestView"; HybridRecyclableTestViewProps::HybridRecyclableTestViewProps(const react::PropsParserContext& context, const HybridRecyclableTestViewProps& sourceProps, diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/HybridRecyclableTestViewComponent.hpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/NitroTestHybridRecyclableTestViewComponent.hpp similarity index 97% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/HybridRecyclableTestViewComponent.hpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/NitroTestHybridRecyclableTestViewComponent.hpp index f5fa26f1c..8337c0d8c 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/HybridRecyclableTestViewComponent.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/NitroTestHybridRecyclableTestViewComponent.hpp @@ -1,5 +1,5 @@ /// -/// HybridRecyclableTestViewComponent.hpp +/// NitroTestHybridRecyclableTestViewComponent.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -17,7 +17,7 @@ #include #include -#include "HybridRecyclableTestViewSpec.hpp" +#include "NitroTestHybridRecyclableTestViewSpec.hpp" #include #include diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/HybridTestViewComponent.cpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/NitroTestHybridTestViewComponent.cpp similarity index 97% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/HybridTestViewComponent.cpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/NitroTestHybridTestViewComponent.cpp index 700abfa5f..7e7993be6 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/HybridTestViewComponent.cpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/NitroTestHybridTestViewComponent.cpp @@ -1,11 +1,11 @@ /// -/// HybridTestViewComponent.cpp +/// NitroTestHybridTestViewComponent.cpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo /// -#include "HybridTestViewComponent.hpp" +#include "NitroTestHybridTestViewComponent.hpp" #include #include @@ -20,7 +20,7 @@ namespace margelo::nitro::test::views { - extern const char HybridTestViewComponentName[] = "TestView"; + extern const char HybridTestViewComponentName[] = "NitroTestTestView"; HybridTestViewProps::HybridTestViewProps(const react::PropsParserContext& context, const HybridTestViewProps& sourceProps, diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/HybridTestViewComponent.hpp b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/NitroTestHybridTestViewComponent.hpp similarity index 96% rename from packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/HybridTestViewComponent.hpp rename to packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/NitroTestHybridTestViewComponent.hpp index 2e2f681b1..d79bb46ce 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/HybridTestViewComponent.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/c++/views/NitroTestHybridTestViewComponent.hpp @@ -1,5 +1,5 @@ /// -/// HybridTestViewComponent.hpp +/// NitroTestHybridTestViewComponent.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -16,10 +16,10 @@ #include #include -#include "ColorScheme.hpp" +#include "NitroTestColorScheme.hpp" #include #include -#include "HybridTestViewSpec.hpp" +#include "NitroTestHybridTestViewSpec.hpp" #include namespace margelo::nitro::test::views { diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/json/RecyclableTestViewConfig.json b/packages/react-native-nitro-test/nitrogen/generated/shared/json/RecyclableTestViewConfig.json index f4b75b61c..969176f49 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/json/RecyclableTestViewConfig.json +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/json/RecyclableTestViewConfig.json @@ -1,5 +1,5 @@ { - "uiViewClassName": "RecyclableTestView", + "uiViewClassName": "NitroTestRecyclableTestView", "supportsRawText": false, "bubblingEventTypes": {}, "directEventTypes": {}, diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/json/TestViewConfig.json b/packages/react-native-nitro-test/nitrogen/generated/shared/json/TestViewConfig.json index ef9bbaaf6..8d40ae144 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/shared/json/TestViewConfig.json +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/json/TestViewConfig.json @@ -1,5 +1,5 @@ { - "uiViewClassName": "TestView", + "uiViewClassName": "NitroTestTestView", "supportsRawText": false, "bubblingEventTypes": {}, "directEventTypes": {}, diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/ts/createNitroTestHybridObject.ts b/packages/react-native-nitro-test/nitrogen/generated/shared/ts/createNitroTestHybridObject.ts new file mode 100644 index 000000000..e90cabbd8 --- /dev/null +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/ts/createNitroTestHybridObject.ts @@ -0,0 +1,21 @@ +/// +/// createNitroTestHybridObject.ts +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// +import { NitroModules, type HybridObject } from 'react-native-nitro-modules' + +const REGISTERED_OBJECTS = { + Base: 'NitroTestBase', + Child: 'NitroTestChild', + PlatformObject: 'NitroTestPlatformObject', + TestObjectCpp: 'NitroTestTestObjectCpp', + TestObjectSwiftKotlin: 'NitroTestTestObjectSwiftKotlin', +} as const + +export function createNitroTestHybridObject>( + name: keyof typeof REGISTERED_OBJECTS +): ReturnType> { + return NitroModules.createHybridObject(REGISTERED_OBJECTS[name]) +} diff --git a/packages/react-native-nitro-test/nitrogen/generated/shared/ts/getNitroTestHostComponent.ts b/packages/react-native-nitro-test/nitrogen/generated/shared/ts/getNitroTestHostComponent.ts new file mode 100644 index 000000000..5016b576c --- /dev/null +++ b/packages/react-native-nitro-test/nitrogen/generated/shared/ts/getNitroTestHostComponent.ts @@ -0,0 +1,37 @@ +/// +/// getNitroTestHostComponent.ts +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// +import { + getHostComponent, + type HybridViewMethods, + type HybridViewProps, + type ViewConfig, +} from 'react-native-nitro-modules' + +import RecyclableTestViewConfig from '../json/RecyclableTestViewConfig.json' +import TestViewConfig from '../json/TestViewConfig.json' + +const REGISTERED_COMPONENTS = { + RecyclableTestView: { + name: 'NitroTestRecyclableTestView', + config: RecyclableTestViewConfig, + }, + TestView: { + name: 'NitroTestTestView', + config: TestViewConfig, + }, +} as const + +export function getNitroTestHostComponent< + Props extends HybridViewProps, + Methods extends HybridViewMethods, +>( + name: keyof typeof REGISTERED_COMPONENTS +): ReturnType> { + const component = REGISTERED_COMPONENTS[name] + const config = component.config as ViewConfig + return getHostComponent(component.name, () => config) +} diff --git a/packages/react-native-nitro-test/package.json b/packages/react-native-nitro-test/package.json index 342c96a99..83fea0cf8 100644 --- a/packages/react-native-nitro-test/package.json +++ b/packages/react-native-nitro-test/package.json @@ -2,9 +2,9 @@ "name": "react-native-nitro-test", "version": "0.35.6", "description": "A testing playground library for Nitro Modules.", - "main": "lib/index", - "module": "lib/index", - "types": "lib/index.d.ts", + "main": "lib/src/index", + "module": "lib/src/index", + "types": "lib/src/index.d.ts", "react-native": "src/index", "source": "src/index", "files": [ diff --git a/packages/react-native-nitro-test/src/index.ts b/packages/react-native-nitro-test/src/index.ts index 6d4b6070d..58f127fcb 100644 --- a/packages/react-native-nitro-test/src/index.ts +++ b/packages/react-native-nitro-test/src/index.ts @@ -1,4 +1,3 @@ -import { NitroModules } from 'react-native-nitro-modules' import { type TestObjectCpp, type TestObjectSwiftKotlin, @@ -6,6 +5,7 @@ import { import { type PlatformObject } from './specs/PlatformObject.nitro' import type { Base } from './specs/Base.nitro' import type { Child } from './specs/Child.nitro' +import { createNitroTestHybridObject } from '../nitrogen/generated/shared/ts/createNitroTestHybridObject' // Export all Hybrid Object types export * from './specs/Base.nitro' @@ -16,15 +16,13 @@ export * from './specs/TestView.nitro' // Export all HybridObject singleton instances export const HybridTestObjectCpp = - NitroModules.createHybridObject('TestObjectCpp') + createNitroTestHybridObject('TestObjectCpp') export const HybridTestObjectSwiftKotlin = - NitroModules.createHybridObject( - 'TestObjectSwiftKotlin' - ) -export const HybridBase = NitroModules.createHybridObject('Base') -export const HybridChild = NitroModules.createHybridObject('Child') + createNitroTestHybridObject('TestObjectSwiftKotlin') +export const HybridBase = createNitroTestHybridObject('Base') +export const HybridChild = createNitroTestHybridObject('Child') export const HybridPlatformObject = - NitroModules.createHybridObject('PlatformObject') + createNitroTestHybridObject('PlatformObject') // Export View (+ its ref type) export { TestView, type TestViewRef } from './views/TestView' diff --git a/packages/react-native-nitro-test/src/views/RecyclableTestView.ts b/packages/react-native-nitro-test/src/views/RecyclableTestView.ts index ec4ddef7e..c949a0fc5 100644 --- a/packages/react-native-nitro-test/src/views/RecyclableTestView.ts +++ b/packages/react-native-nitro-test/src/views/RecyclableTestView.ts @@ -1,17 +1,17 @@ -import { getHostComponent, type HybridRef } from 'react-native-nitro-modules' -import RecyclableTestViewConfig from '../../nitrogen/generated/shared/json/RecyclableTestViewConfig.json' +import { type HybridRef } from 'react-native-nitro-modules' import { type RecyclableTestViewMethods, type RecyclableTestViewProps, } from '../specs/RecyclableTestView.nitro' +import { getNitroTestHostComponent } from '../../nitrogen/generated/shared/ts/getNitroTestHostComponent' /** * Represents the HybridView `TestView`, which can be rendered as a React Native view. */ -export const RecyclableTestView = getHostComponent< +export const RecyclableTestView = getNitroTestHostComponent< RecyclableTestViewProps, RecyclableTestViewMethods ->('RecyclableTestView', () => RecyclableTestViewConfig) +>('RecyclableTestView') export type RecyclableTestViewRef = HybridRef< RecyclableTestViewProps, diff --git a/packages/react-native-nitro-test/src/views/TestView.ts b/packages/react-native-nitro-test/src/views/TestView.ts index f3d82fcd5..8e0860883 100644 --- a/packages/react-native-nitro-test/src/views/TestView.ts +++ b/packages/react-native-nitro-test/src/views/TestView.ts @@ -1,16 +1,16 @@ -import { getHostComponent, type HybridRef } from 'react-native-nitro-modules' -import TestViewConfig from '../../nitrogen/generated/shared/json/TestViewConfig.json' +import { type HybridRef } from 'react-native-nitro-modules' import { type TestViewMethods, type TestViewProps, } from '../specs/TestView.nitro' +import { getNitroTestHostComponent } from '../../nitrogen/generated/shared/ts/getNitroTestHostComponent' /** * Represents the HybridView `TestView`, which can be rendered as a React Native view. */ -export const TestView = getHostComponent( - 'TestView', - () => TestViewConfig -) +export const TestView = getNitroTestHostComponent< + TestViewProps, + TestViewMethods +>('TestView') export type TestViewRef = HybridRef diff --git a/packages/react-native-nitro-test/tsconfig.json b/packages/react-native-nitro-test/tsconfig.json index bea65346b..897d06063 100644 --- a/packages/react-native-nitro-test/tsconfig.json +++ b/packages/react-native-nitro-test/tsconfig.json @@ -3,10 +3,14 @@ "@tsconfig/react-native/tsconfig.json", "../../config/tsconfig.json" ], - "include": ["src"], + "include": [ + "src", + "nitrogen/generated/shared/ts", + "nitrogen/generated/shared/json/*.json" + ], "compilerOptions": { - "rootDir": "src", + "rootDir": ".", "outDir": "lib", - "jsx": "react" + "jsx": "react", } }