From fc4063cd63a81dd91297e8fbdef22c32d0854e34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Fazekas?= Date: Fri, 19 Sep 2025 10:43:47 +0200 Subject: [PATCH 1/7] refactor(codegen): separate property names, extract variable name declarations --- .../components/GenerateEventEmitterCpp.js | 57 ++++++++++++++----- 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js index 6d9b72cd2909ae..117e3ba73291e6 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js +++ b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js @@ -100,6 +100,7 @@ function generateSetter( propertyName: string, propertyParts: $ReadOnlyArray, usingEvent: boolean, + context: { numberOfVariables: number }, valueMapper: string => string = value => value, ) { const eventChain = usingEvent @@ -117,6 +118,7 @@ function generateObjectSetter( typeAnnotation: ObjectTypeAnnotation, extraIncludes: Set, usingEvent: boolean, + context: { numberOfVariables: number }, ) { return ` { @@ -128,6 +130,7 @@ function generateObjectSetter( propertyParts.concat([propertyName]), extraIncludes, usingEvent, + context, ), 2, )} @@ -137,12 +140,12 @@ function generateObjectSetter( } function setValueAtIndex( - propertyName: string, + arrayVariable: string, indexVariable: string, loopLocalVariable: string, mappingFunction: string => string = value => value, ) { - return `${propertyName}.setValueAtIndex(runtime, ${indexVariable}++, ${mappingFunction( + return `${arrayVariable}.setValueAtIndex(runtime, ${indexVariable}++, ${mappingFunction( loopLocalVariable, )});`; } @@ -154,43 +157,49 @@ function generateArraySetter( elementType: EventTypeAnnotation, extraIncludes: Set, usingEvent: boolean, + context: { numberOfVariables: number }, ): string { const eventChain = usingEvent ? `event.${[...propertyParts, propertyName].join('.')}` : [...propertyParts, propertyName].join('.'); + const arrayVariable = propertyName; const indexVar = `${propertyName}Index`; const innerLoopVar = `${propertyName}Value`; return ` - auto ${propertyName} = jsi::Array(runtime, ${eventChain}.size()); + auto ${arrayVariable} = jsi::Array(runtime, ${eventChain}.size()); size_t ${indexVar} = 0; for (auto ${innerLoopVar} : ${eventChain}) { ${handleArrayElementType( elementType, propertyName, + arrayVariable, indexVar, innerLoopVar, propertyParts, extraIncludes, usingEvent, + context, )} } - ${variableName}.setProperty(runtime, "${propertyName}", ${propertyName}); + ${variableName}.setProperty(runtime, "${propertyName}", ${arrayVariable}); `; } function handleArrayElementType( elementType: EventTypeAnnotation, propertyName: string, + arrayVariable: string, indexVariable: string, loopLocalVariable: string, propertyParts: $ReadOnlyArray, extraIncludes: Set, usingEvent: boolean, + context: { numberOfVariables: number }, ): string { switch (elementType.type) { case 'BooleanTypeAnnotation': return setValueAtIndex( - propertyName, + arrayVariable, indexVariable, loopLocalVariable, val => `(bool)${val}`, @@ -199,17 +208,17 @@ function handleArrayElementType( case 'Int32TypeAnnotation': case 'DoubleTypeAnnotation': case 'FloatTypeAnnotation': - return setValueAtIndex(propertyName, indexVariable, loopLocalVariable); + return setValueAtIndex(arrayVariable, indexVariable, loopLocalVariable); case 'MixedTypeAnnotation': return setValueAtIndex( - propertyName, + arrayVariable, indexVariable, loopLocalVariable, val => `jsi::valueFromDynamic(runtime, ${val})`, ); case 'StringLiteralUnionTypeAnnotation': return setValueAtIndex( - propertyName, + arrayVariable, indexVariable, loopLocalVariable, val => `toString(${val})`, @@ -217,21 +226,25 @@ function handleArrayElementType( case 'ObjectTypeAnnotation': return convertObjectTypeArray( propertyName, + arrayVariable, indexVariable, loopLocalVariable, propertyParts, elementType, extraIncludes, + context, ); case 'ArrayTypeAnnotation': return convertArrayTypeArray( propertyName, + arrayVariable, indexVariable, loopLocalVariable, propertyParts, elementType, extraIncludes, usingEvent, + context, ); default: throw new Error( @@ -242,51 +255,60 @@ function handleArrayElementType( function convertObjectTypeArray( propertyName: string, + arrayVariable: string, indexVariable: string, loopLocalVariable: string, propertyParts: $ReadOnlyArray, objectTypeAnnotation: ObjectTypeAnnotation, extraIncludes: Set, + context: { numberOfVariables: number }, ): string { - return `auto ${propertyName}Object = jsi::Object(runtime); + const variableName = `${propertyName}Object`; + return `auto ${variableName} = jsi::Object(runtime); ${generateSetters( - `${propertyName}Object`, + variableName, objectTypeAnnotation.properties, [].concat([loopLocalVariable]), extraIncludes, false, + context )} - ${setValueAtIndex(propertyName, indexVariable, `${propertyName}Object`)}`; + ${setValueAtIndex(arrayVariable, indexVariable, variableName)}`; } function convertArrayTypeArray( propertyName: string, + arrayVariable: string, indexVariable: string, loopLocalVariable: string, propertyParts: $ReadOnlyArray, eventTypeAnnotation: EventTypeAnnotation, extraIncludes: Set, usingEvent: boolean, + context: { numberOfVariables: number }, ): string { if (eventTypeAnnotation.type !== 'ArrayTypeAnnotation') { throw new Error( `Inconsistent eventTypeAnnotation received. Expected type = 'ArrayTypeAnnotation'; received = ${eventTypeAnnotation.type}`, ); } - return `auto ${propertyName}Array = jsi::Array(runtime, ${loopLocalVariable}.size()); + const nestedArrayVariable = `${propertyName}Array`; + return `auto ${nestedArrayVariable} = jsi::Array(runtime, ${loopLocalVariable}.size()); size_t ${indexVariable}Internal = 0; for (auto ${loopLocalVariable}Internal : ${loopLocalVariable}) { ${handleArrayElementType( eventTypeAnnotation.elementType, `${propertyName}Array`, + nestedArrayVariable, `${indexVariable}Internal`, `${loopLocalVariable}Internal`, propertyParts, extraIncludes, usingEvent, + context, )} } - ${setValueAtIndex(propertyName, indexVariable, `${propertyName}Array`)}`; + ${setValueAtIndex(arrayVariable, indexVariable, nestedArrayVariable)}`; } function generateSetters( @@ -295,6 +317,7 @@ function generateSetters( propertyParts: $ReadOnlyArray, extraIncludes: Set, usingEvent: boolean = true, + context: { numberOfVariables: number }, ): string { const propSetters = properties .map(eventProperty => { @@ -310,6 +333,7 @@ function generateSetters( eventProperty.name, propertyParts, usingEvent, + context, ); case 'MixedTypeAnnotation': extraIncludes.add('#include '); @@ -318,6 +342,7 @@ function generateSetters( eventProperty.name, propertyParts, usingEvent, + context, prop => `jsi::valueFromDynamic(runtime, ${prop})`, ); case 'StringLiteralUnionTypeAnnotation': @@ -326,6 +351,7 @@ function generateSetters( eventProperty.name, propertyParts, usingEvent, + context, prop => `toString(${prop})`, ); case 'ObjectTypeAnnotation': @@ -336,6 +362,7 @@ function generateSetters( typeAnnotation, extraIncludes, usingEvent, + context, ); case 'ArrayTypeAnnotation': return generateArraySetter( @@ -345,6 +372,7 @@ function generateSetters( typeAnnotation.elementType, extraIncludes, usingEvent, + context, ); default: (typeAnnotation.type: empty); @@ -375,6 +403,7 @@ function generateEvent( : `${event.name[2].toLowerCase()}${event.name.slice(3)}`; if (event.typeAnnotation.argument) { + const context = { numberOfVariables: 0 }; const implementation = ` auto payload = jsi::Object(runtime); ${generateSetters( @@ -382,6 +411,8 @@ function generateEvent( event.typeAnnotation.argument.properties, [], extraIncludes, + true, + context, )} return payload; `.trim(); From 41688be160e707b6e03756a170ab038adee83d2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Fazekas?= Date: Fri, 19 Sep 2025 11:25:03 +0200 Subject: [PATCH 2/7] use variable names with suffix to avoid shdowing variables --- .../components/GenerateEventEmitterCpp.js | 47 ++++++++++++------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js index 117e3ba73291e6..4968e070c568c2 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js +++ b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js @@ -100,7 +100,7 @@ function generateSetter( propertyName: string, propertyParts: $ReadOnlyArray, usingEvent: boolean, - context: { numberOfVariables: number }, + context: { variableSuffix: number }, valueMapper: string => string = value => value, ) { const eventChain = usingEvent @@ -118,13 +118,15 @@ function generateObjectSetter( typeAnnotation: ObjectTypeAnnotation, extraIncludes: Set, usingEvent: boolean, - context: { numberOfVariables: number }, + context: { variableSuffix: number }, ) { + const objectVariable = variable(`${propertyName}`, context); return ` { - auto ${propertyName} = jsi::Object(runtime); + auto ${objectVariable} = jsi::Object(runtime); ${indent( generateSetters( + objectVariable, propertyName, typeAnnotation.properties, propertyParts.concat([propertyName]), @@ -134,7 +136,7 @@ function generateObjectSetter( ), 2, )} - ${variableName}.setProperty(runtime, "${propertyName}", ${propertyName}); + ${variableName}.setProperty(runtime, "${propertyName}", ${objectVariable}); } `.trim(); } @@ -150,6 +152,11 @@ function setValueAtIndex( )});`; } +function variable(name: string, context: { variableSuffix: number }): string { + context.variableSuffix++; + return `${name}_${context.variableSuffix}`; +} + function generateArraySetter( variableName: string, propertyName: string, @@ -162,9 +169,9 @@ function generateArraySetter( const eventChain = usingEvent ? `event.${[...propertyParts, propertyName].join('.')}` : [...propertyParts, propertyName].join('.'); - const arrayVariable = propertyName; - const indexVar = `${propertyName}Index`; - const innerLoopVar = `${propertyName}Value`; + const arrayVariable = variable(propertyName, context); + const indexVar = variable(`${propertyName}Index`, context); + const innerLoopVar = variable(`${propertyName}Value`, context); return ` auto ${arrayVariable} = jsi::Array(runtime, ${eventChain}.size()); size_t ${indexVar} = 0; @@ -263,10 +270,11 @@ function convertObjectTypeArray( extraIncludes: Set, context: { numberOfVariables: number }, ): string { - const variableName = `${propertyName}Object`; + const variableName = variable(`${propertyName}Object`, context); return `auto ${variableName} = jsi::Object(runtime); ${generateSetters( variableName, + `${propertyName}Object`, objectTypeAnnotation.properties, [].concat([loopLocalVariable]), extraIncludes, @@ -292,7 +300,7 @@ function convertArrayTypeArray( `Inconsistent eventTypeAnnotation received. Expected type = 'ArrayTypeAnnotation'; received = ${eventTypeAnnotation.type}`, ); } - const nestedArrayVariable = `${propertyName}Array`; + const nestedArrayVariable = variable(`${propertyName}Array`, context); return `auto ${nestedArrayVariable} = jsi::Array(runtime, ${loopLocalVariable}.size()); size_t ${indexVariable}Internal = 0; for (auto ${loopLocalVariable}Internal : ${loopLocalVariable}) { @@ -312,12 +320,13 @@ function convertArrayTypeArray( } function generateSetters( + variableName: string, parentPropertyName: string, properties: $ReadOnlyArray>, propertyParts: $ReadOnlyArray, extraIncludes: Set, usingEvent: boolean = true, - context: { numberOfVariables: number }, + context: { variableSuffix: number }, ): string { const propSetters = properties .map(eventProperty => { @@ -329,7 +338,7 @@ function generateSetters( case 'DoubleTypeAnnotation': case 'FloatTypeAnnotation': return generateSetter( - parentPropertyName, + variableName, eventProperty.name, propertyParts, usingEvent, @@ -338,7 +347,7 @@ function generateSetters( case 'MixedTypeAnnotation': extraIncludes.add('#include '); return generateSetter( - parentPropertyName, + variableName, eventProperty.name, propertyParts, usingEvent, @@ -347,7 +356,7 @@ function generateSetters( ); case 'StringLiteralUnionTypeAnnotation': return generateSetter( - parentPropertyName, + variableName, eventProperty.name, propertyParts, usingEvent, @@ -356,7 +365,7 @@ function generateSetters( ); case 'ObjectTypeAnnotation': return generateObjectSetter( - parentPropertyName, + variableName, eventProperty.name, propertyParts, typeAnnotation, @@ -366,7 +375,7 @@ function generateSetters( ); case 'ArrayTypeAnnotation': return generateArraySetter( - parentPropertyName, + variableName, eventProperty.name, propertyParts, typeAnnotation.elementType, @@ -403,18 +412,20 @@ function generateEvent( : `${event.name[2].toLowerCase()}${event.name.slice(3)}`; if (event.typeAnnotation.argument) { - const context = { numberOfVariables: 0 }; + const context = { variableSuffix: 0 }; + const variableName = 'payload'; const implementation = ` - auto payload = jsi::Object(runtime); + auto ${variableName} = jsi::Object(runtime); ${generateSetters( 'payload', + variableName, event.typeAnnotation.argument.properties, [], extraIncludes, true, context, )} - return payload; + return ${variableName}; `.trim(); if (!event.name.startsWith('on')) { From 0f12edecfd2562632a1630dd4f664d548409f7cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Fazekas?= Date: Fri, 19 Sep 2025 11:26:45 +0200 Subject: [PATCH 3/7] test: update fixutres --- .../GenerateEventEmitterCpp-test.js.snap | 32 +++---- .../GenerateEventEmitterCpp-test.js.snap | 32 +++---- .../GenerateEventEmitterCpp-test.js.snap | 90 +++++++++---------- 3 files changed, 77 insertions(+), 77 deletions(-) diff --git a/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap b/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap index 6e338000624c00..05a7c25ae15714 100644 --- a/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap +++ b/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap @@ -153,29 +153,29 @@ void EventNestedObjectPropsNativeComponentViewEventEmitter::onChange(OnChange ev dispatchEvent(\\"change\\", [event=std::move(event)](jsi::Runtime &runtime) { auto payload = jsi::Object(runtime); { - auto location = jsi::Object(runtime); + auto location_1 = jsi::Object(runtime); { - auto source = jsi::Object(runtime); - source.setProperty(runtime, \\"url\\", event.location.source.url); - location.setProperty(runtime, \\"source\\", source); + auto source_2 = jsi::Object(runtime); + source_2.setProperty(runtime, \\"url\\", event.location.source.url); + location_1.setProperty(runtime, \\"source\\", source_2); } - location.setProperty(runtime, \\"x\\", event.location.x); - location.setProperty(runtime, \\"y\\", event.location.y); + location_1.setProperty(runtime, \\"x\\", event.location.x); + location_1.setProperty(runtime, \\"y\\", event.location.y); - auto arrayOfObjects = jsi::Array(runtime, event.location.arrayOfObjects.size()); - size_t arrayOfObjectsIndex = 0; - for (auto arrayOfObjectsValue : event.location.arrayOfObjects) { - auto arrayOfObjectsObject = jsi::Object(runtime); + auto arrayOfObjects_3 = jsi::Array(runtime, event.location.arrayOfObjects.size()); + size_t arrayOfObjectsIndex_4 = 0; + for (auto arrayOfObjectsValue_5 : event.location.arrayOfObjects) { + auto arrayOfObjectsObject_6 = jsi::Object(runtime); { - auto value = jsi::Object(runtime); - value.setProperty(runtime, \\"str\\", arrayOfObjectsValue.value.str); - arrayOfObjectsObject.setProperty(runtime, \\"value\\", value); + auto value_7 = jsi::Object(runtime); + value_7.setProperty(runtime, \\"str\\", arrayOfObjectsValue_5.value.str); + arrayOfObjectsObject_6.setProperty(runtime, \\"value\\", value_7); } - arrayOfObjects.setValueAtIndex(runtime, arrayOfObjectsIndex++, arrayOfObjectsObject); + arrayOfObjects_3.setValueAtIndex(runtime, arrayOfObjectsIndex_4++, arrayOfObjectsObject_6); } - location.setProperty(runtime, \\"arrayOfObjects\\", arrayOfObjects); + location_1.setProperty(runtime, \\"arrayOfObjects\\", arrayOfObjects_3); - payload.setProperty(runtime, \\"location\\", location); + payload.setProperty(runtime, \\"location\\", location_1); } return payload; }); diff --git a/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap b/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap index ec4329c725214e..7df6bfa4d6e3b7 100644 --- a/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap +++ b/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap @@ -153,29 +153,29 @@ void EventNestedObjectPropsNativeComponentViewEventEmitter::onChange(OnChange ev dispatchEvent(\\"change\\", [event=std::move(event)](jsi::Runtime &runtime) { auto payload = jsi::Object(runtime); { - auto location = jsi::Object(runtime); + auto location_1 = jsi::Object(runtime); { - auto source = jsi::Object(runtime); - source.setProperty(runtime, \\"url\\", event.location.source.url); - location.setProperty(runtime, \\"source\\", source); + auto source_2 = jsi::Object(runtime); + source_2.setProperty(runtime, \\"url\\", event.location.source.url); + location_1.setProperty(runtime, \\"source\\", source_2); } - location.setProperty(runtime, \\"x\\", event.location.x); - location.setProperty(runtime, \\"y\\", event.location.y); + location_1.setProperty(runtime, \\"x\\", event.location.x); + location_1.setProperty(runtime, \\"y\\", event.location.y); - auto arrayOfObjects = jsi::Array(runtime, event.location.arrayOfObjects.size()); - size_t arrayOfObjectsIndex = 0; - for (auto arrayOfObjectsValue : event.location.arrayOfObjects) { - auto arrayOfObjectsObject = jsi::Object(runtime); + auto arrayOfObjects_3 = jsi::Array(runtime, event.location.arrayOfObjects.size()); + size_t arrayOfObjectsIndex_4 = 0; + for (auto arrayOfObjectsValue_5 : event.location.arrayOfObjects) { + auto arrayOfObjectsObject_6 = jsi::Object(runtime); { - auto value = jsi::Object(runtime); - value.setProperty(runtime, \\"str\\", arrayOfObjectsValue.value.str); - arrayOfObjectsObject.setProperty(runtime, \\"value\\", value); + auto value_7 = jsi::Object(runtime); + value_7.setProperty(runtime, \\"str\\", arrayOfObjectsValue_5.value.str); + arrayOfObjectsObject_6.setProperty(runtime, \\"value\\", value_7); } - arrayOfObjects.setValueAtIndex(runtime, arrayOfObjectsIndex++, arrayOfObjectsObject); + arrayOfObjects_3.setValueAtIndex(runtime, arrayOfObjectsIndex_4++, arrayOfObjectsObject_6); } - location.setProperty(runtime, \\"arrayOfObjects\\", arrayOfObjects); + location_1.setProperty(runtime, \\"arrayOfObjects\\", arrayOfObjects_3); - payload.setProperty(runtime, \\"location\\", location); + payload.setProperty(runtime, \\"location\\", location_1); } return payload; }); diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap index 78c49307b2db21..500201d7a57571 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap @@ -197,15 +197,15 @@ void EventsNestedObjectNativeComponentEventEmitter::onChange(OnChange event) con dispatchEvent(\\"change\\", [event=std::move(event)](jsi::Runtime &runtime) { auto payload = jsi::Object(runtime); { - auto location = jsi::Object(runtime); + auto location_1 = jsi::Object(runtime); { - auto source = jsi::Object(runtime); - source.setProperty(runtime, \\"url\\", event.location.source.url); - location.setProperty(runtime, \\"source\\", source); + auto source_2 = jsi::Object(runtime); + source_2.setProperty(runtime, \\"url\\", event.location.source.url); + location_1.setProperty(runtime, \\"source\\", source_2); } - location.setProperty(runtime, \\"x\\", event.location.x); - location.setProperty(runtime, \\"y\\", event.location.y); - payload.setProperty(runtime, \\"location\\", location); + location_1.setProperty(runtime, \\"x\\", event.location.x); + location_1.setProperty(runtime, \\"y\\", event.location.y); + payload.setProperty(runtime, \\"location\\", location_1); } return payload; }); @@ -249,60 +249,60 @@ void EventsNativeComponentEventEmitter::onArrayEventType(OnArrayEventType event) dispatchEvent(\\"arrayEventType\\", [event=std::move(event)](jsi::Runtime &runtime) { auto payload = jsi::Object(runtime); - auto bool_array_event_prop = jsi::Array(runtime, event.bool_array_event_prop.size()); - size_t bool_array_event_propIndex = 0; - for (auto bool_array_event_propValue : event.bool_array_event_prop) { - bool_array_event_prop.setValueAtIndex(runtime, bool_array_event_propIndex++, (bool)bool_array_event_propValue); + auto bool_array_event_prop_1 = jsi::Array(runtime, event.bool_array_event_prop.size()); + size_t bool_array_event_propIndex_2 = 0; + for (auto bool_array_event_propValue_3 : event.bool_array_event_prop) { + bool_array_event_prop_1.setValueAtIndex(runtime, bool_array_event_propIndex_2++, (bool)bool_array_event_propValue_3); } - payload.setProperty(runtime, \\"bool_array_event_prop\\", bool_array_event_prop); + payload.setProperty(runtime, \\"bool_array_event_prop\\", bool_array_event_prop_1); - auto string_enum_event_prop = jsi::Array(runtime, event.string_enum_event_prop.size()); - size_t string_enum_event_propIndex = 0; - for (auto string_enum_event_propValue : event.string_enum_event_prop) { - string_enum_event_prop.setValueAtIndex(runtime, string_enum_event_propIndex++, toString(string_enum_event_propValue)); + auto string_enum_event_prop_4 = jsi::Array(runtime, event.string_enum_event_prop.size()); + size_t string_enum_event_propIndex_5 = 0; + for (auto string_enum_event_propValue_6 : event.string_enum_event_prop) { + string_enum_event_prop_4.setValueAtIndex(runtime, string_enum_event_propIndex_5++, toString(string_enum_event_propValue_6)); } - payload.setProperty(runtime, \\"string_enum_event_prop\\", string_enum_event_prop); + payload.setProperty(runtime, \\"string_enum_event_prop\\", string_enum_event_prop_4); - auto array_array_event_prop = jsi::Array(runtime, event.array_array_event_prop.size()); - size_t array_array_event_propIndex = 0; - for (auto array_array_event_propValue : event.array_array_event_prop) { - auto array_array_event_propArray = jsi::Array(runtime, array_array_event_propValue.size()); - size_t array_array_event_propIndexInternal = 0; - for (auto array_array_event_propValueInternal : array_array_event_propValue) { - array_array_event_propArray.setValueAtIndex(runtime, array_array_event_propIndexInternal++, array_array_event_propValueInternal); + auto array_array_event_prop_7 = jsi::Array(runtime, event.array_array_event_prop.size()); + size_t array_array_event_propIndex_8 = 0; + for (auto array_array_event_propValue_9 : event.array_array_event_prop) { + auto array_array_event_propArray_10 = jsi::Array(runtime, array_array_event_propValue_9.size()); + size_t array_array_event_propIndex_8Internal = 0; + for (auto array_array_event_propValue_9Internal : array_array_event_propValue_9) { + array_array_event_propArray_10.setValueAtIndex(runtime, array_array_event_propIndex_8Internal++, array_array_event_propValue_9Internal); } - array_array_event_prop.setValueAtIndex(runtime, array_array_event_propIndex++, array_array_event_propArray); + array_array_event_prop_7.setValueAtIndex(runtime, array_array_event_propIndex_8++, array_array_event_propArray_10); } - payload.setProperty(runtime, \\"array_array_event_prop\\", array_array_event_prop); + payload.setProperty(runtime, \\"array_array_event_prop\\", array_array_event_prop_7); - auto array_object_event_prop = jsi::Array(runtime, event.array_object_event_prop.size()); - size_t array_object_event_propIndex = 0; - for (auto array_object_event_propValue : event.array_object_event_prop) { - auto array_object_event_propObject = jsi::Object(runtime); - array_object_event_propObject.setProperty(runtime, \\"lat\\", array_object_event_propValue.lat); -array_object_event_propObject.setProperty(runtime, \\"lon\\", array_object_event_propValue.lon); - - auto names = jsi::Array(runtime, array_object_event_propValue.names.size()); - size_t namesIndex = 0; - for (auto namesValue : array_object_event_propValue.names) { - names.setValueAtIndex(runtime, namesIndex++, namesValue); + auto array_object_event_prop_11 = jsi::Array(runtime, event.array_object_event_prop.size()); + size_t array_object_event_propIndex_12 = 0; + for (auto array_object_event_propValue_13 : event.array_object_event_prop) { + auto array_object_event_propObject_14 = jsi::Object(runtime); + array_object_event_propObject_14.setProperty(runtime, \\"lat\\", array_object_event_propValue_13.lat); +array_object_event_propObject_14.setProperty(runtime, \\"lon\\", array_object_event_propValue_13.lon); + + auto names_15 = jsi::Array(runtime, array_object_event_propValue_13.names.size()); + size_t namesIndex_16 = 0; + for (auto namesValue_17 : array_object_event_propValue_13.names) { + names_15.setValueAtIndex(runtime, namesIndex_16++, namesValue_17); } - array_object_event_propObject.setProperty(runtime, \\"names\\", names); + array_object_event_propObject_14.setProperty(runtime, \\"names\\", names_15); - array_object_event_prop.setValueAtIndex(runtime, array_object_event_propIndex++, array_object_event_propObject); + array_object_event_prop_11.setValueAtIndex(runtime, array_object_event_propIndex_12++, array_object_event_propObject_14); } - payload.setProperty(runtime, \\"array_object_event_prop\\", array_object_event_prop); + payload.setProperty(runtime, \\"array_object_event_prop\\", array_object_event_prop_11); - auto array_mixed_event_prop = jsi::Array(runtime, event.array_mixed_event_prop.size()); - size_t array_mixed_event_propIndex = 0; - for (auto array_mixed_event_propValue : event.array_mixed_event_prop) { - array_mixed_event_prop.setValueAtIndex(runtime, array_mixed_event_propIndex++, jsi::valueFromDynamic(runtime, array_mixed_event_propValue)); + auto array_mixed_event_prop_18 = jsi::Array(runtime, event.array_mixed_event_prop.size()); + size_t array_mixed_event_propIndex_19 = 0; + for (auto array_mixed_event_propValue_20 : event.array_mixed_event_prop) { + array_mixed_event_prop_18.setValueAtIndex(runtime, array_mixed_event_propIndex_19++, jsi::valueFromDynamic(runtime, array_mixed_event_propValue_20)); } - payload.setProperty(runtime, \\"array_mixed_event_prop\\", array_mixed_event_prop); + payload.setProperty(runtime, \\"array_mixed_event_prop\\", array_mixed_event_prop_18); return payload; }); From da248dc5045b97d83399b38bf254512cb1d9dd82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Fazekas?= Date: Fri, 19 Sep 2025 11:49:52 +0200 Subject: [PATCH 4/7] doc: added comment --- .../src/generators/components/GenerateEventEmitterCpp.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js index 4968e070c568c2..c955aa63b3ce89 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js +++ b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js @@ -153,6 +153,9 @@ function setValueAtIndex( } function variable(name: string, context: { variableSuffix: number }): string { + // Ensure variable names are unique by adding a suffix. + // Prevents C++ variable name collisions for properties with the same name. + // See: https://github.com/facebook/react-native/issues/53839 context.variableSuffix++; return `${name}_${context.variableSuffix}`; } From 5f8cb3495ab75776427f74a8c11e0ea808e8ce67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Fazekas?= Date: Fri, 19 Sep 2025 12:07:20 +0200 Subject: [PATCH 5/7] fix: flow types --- .../src/generators/components/GenerateEventEmitterCpp.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js index c955aa63b3ce89..414ff65ef5c551 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js +++ b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js @@ -167,7 +167,7 @@ function generateArraySetter( elementType: EventTypeAnnotation, extraIncludes: Set, usingEvent: boolean, - context: { numberOfVariables: number }, + context: { variableSuffix: number }, ): string { const eventChain = usingEvent ? `event.${[...propertyParts, propertyName].join('.')}` @@ -204,7 +204,7 @@ function handleArrayElementType( propertyParts: $ReadOnlyArray, extraIncludes: Set, usingEvent: boolean, - context: { numberOfVariables: number }, + context: { variableSuffix: number }, ): string { switch (elementType.type) { case 'BooleanTypeAnnotation': @@ -271,7 +271,7 @@ function convertObjectTypeArray( propertyParts: $ReadOnlyArray, objectTypeAnnotation: ObjectTypeAnnotation, extraIncludes: Set, - context: { numberOfVariables: number }, + context: { variableSuffix: number }, ): string { const variableName = variable(`${propertyName}Object`, context); return `auto ${variableName} = jsi::Object(runtime); @@ -296,7 +296,7 @@ function convertArrayTypeArray( eventTypeAnnotation: EventTypeAnnotation, extraIncludes: Set, usingEvent: boolean, - context: { numberOfVariables: number }, + context: { variableSuffix: number }, ): string { if (eventTypeAnnotation.type !== 'ArrayTypeAnnotation') { throw new Error( From f64541fe7dc3400b602261dcb84a20bb2737fdb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Fazekas?= Date: Fri, 19 Sep 2025 12:19:23 +0200 Subject: [PATCH 6/7] prettier --- .../components/GenerateEventEmitterCpp.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js index 414ff65ef5c551..13500380cb735b 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js +++ b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js @@ -100,7 +100,7 @@ function generateSetter( propertyName: string, propertyParts: $ReadOnlyArray, usingEvent: boolean, - context: { variableSuffix: number }, + context: {variableSuffix: number}, valueMapper: string => string = value => value, ) { const eventChain = usingEvent @@ -118,7 +118,7 @@ function generateObjectSetter( typeAnnotation: ObjectTypeAnnotation, extraIncludes: Set, usingEvent: boolean, - context: { variableSuffix: number }, + context: {variableSuffix: number}, ) { const objectVariable = variable(`${propertyName}`, context); return ` @@ -152,7 +152,7 @@ function setValueAtIndex( )});`; } -function variable(name: string, context: { variableSuffix: number }): string { +function variable(name: string, context: {variableSuffix: number}): string { // Ensure variable names are unique by adding a suffix. // Prevents C++ variable name collisions for properties with the same name. // See: https://github.com/facebook/react-native/issues/53839 @@ -167,7 +167,7 @@ function generateArraySetter( elementType: EventTypeAnnotation, extraIncludes: Set, usingEvent: boolean, - context: { variableSuffix: number }, + context: {variableSuffix: number}, ): string { const eventChain = usingEvent ? `event.${[...propertyParts, propertyName].join('.')}` @@ -204,7 +204,7 @@ function handleArrayElementType( propertyParts: $ReadOnlyArray, extraIncludes: Set, usingEvent: boolean, - context: { variableSuffix: number }, + context: {variableSuffix: number}, ): string { switch (elementType.type) { case 'BooleanTypeAnnotation': @@ -271,7 +271,7 @@ function convertObjectTypeArray( propertyParts: $ReadOnlyArray, objectTypeAnnotation: ObjectTypeAnnotation, extraIncludes: Set, - context: { variableSuffix: number }, + context: {variableSuffix: number}, ): string { const variableName = variable(`${propertyName}Object`, context); return `auto ${variableName} = jsi::Object(runtime); @@ -282,7 +282,7 @@ function convertObjectTypeArray( [].concat([loopLocalVariable]), extraIncludes, false, - context + context, )} ${setValueAtIndex(arrayVariable, indexVariable, variableName)}`; } @@ -296,7 +296,7 @@ function convertArrayTypeArray( eventTypeAnnotation: EventTypeAnnotation, extraIncludes: Set, usingEvent: boolean, - context: { variableSuffix: number }, + context: {variableSuffix: number}, ): string { if (eventTypeAnnotation.type !== 'ArrayTypeAnnotation') { throw new Error( @@ -329,7 +329,7 @@ function generateSetters( propertyParts: $ReadOnlyArray, extraIncludes: Set, usingEvent: boolean = true, - context: { variableSuffix: number }, + context: {variableSuffix: number}, ): string { const propSetters = properties .map(eventProperty => { @@ -415,7 +415,7 @@ function generateEvent( : `${event.name[2].toLowerCase()}${event.name.slice(3)}`; if (event.typeAnnotation.argument) { - const context = { variableSuffix: 0 }; + const context = {variableSuffix: 0}; const variableName = 'payload'; const implementation = ` auto ${variableName} = jsi::Object(runtime); From 6dcb8efcf4dd04281db64de7f6003c4e75ed0405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Fazekas?= Date: Fri, 19 Sep 2025 20:51:54 +0200 Subject: [PATCH 7/7] added codegen suffix --- .../GenerateEventEmitterCpp-test.js.snap | 32 +++---- .../GenerateEventEmitterCpp-test.js.snap | 32 +++---- .../components/GenerateEventEmitterCpp.js | 2 +- .../GenerateEventEmitterCpp-test.js.snap | 90 +++++++++---------- 4 files changed, 78 insertions(+), 78 deletions(-) diff --git a/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap b/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap index 05a7c25ae15714..49bbb7175f16b4 100644 --- a/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap +++ b/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap @@ -153,29 +153,29 @@ void EventNestedObjectPropsNativeComponentViewEventEmitter::onChange(OnChange ev dispatchEvent(\\"change\\", [event=std::move(event)](jsi::Runtime &runtime) { auto payload = jsi::Object(runtime); { - auto location_1 = jsi::Object(runtime); + auto location_codegen1 = jsi::Object(runtime); { - auto source_2 = jsi::Object(runtime); - source_2.setProperty(runtime, \\"url\\", event.location.source.url); - location_1.setProperty(runtime, \\"source\\", source_2); + auto source_codegen2 = jsi::Object(runtime); + source_codegen2.setProperty(runtime, \\"url\\", event.location.source.url); + location_codegen1.setProperty(runtime, \\"source\\", source_codegen2); } - location_1.setProperty(runtime, \\"x\\", event.location.x); - location_1.setProperty(runtime, \\"y\\", event.location.y); + location_codegen1.setProperty(runtime, \\"x\\", event.location.x); + location_codegen1.setProperty(runtime, \\"y\\", event.location.y); - auto arrayOfObjects_3 = jsi::Array(runtime, event.location.arrayOfObjects.size()); - size_t arrayOfObjectsIndex_4 = 0; - for (auto arrayOfObjectsValue_5 : event.location.arrayOfObjects) { - auto arrayOfObjectsObject_6 = jsi::Object(runtime); + auto arrayOfObjects_codegen3 = jsi::Array(runtime, event.location.arrayOfObjects.size()); + size_t arrayOfObjectsIndex_codegen4 = 0; + for (auto arrayOfObjectsValue_codegen5 : event.location.arrayOfObjects) { + auto arrayOfObjectsObject_codegen6 = jsi::Object(runtime); { - auto value_7 = jsi::Object(runtime); - value_7.setProperty(runtime, \\"str\\", arrayOfObjectsValue_5.value.str); - arrayOfObjectsObject_6.setProperty(runtime, \\"value\\", value_7); + auto value_codegen7 = jsi::Object(runtime); + value_codegen7.setProperty(runtime, \\"str\\", arrayOfObjectsValue_codegen5.value.str); + arrayOfObjectsObject_codegen6.setProperty(runtime, \\"value\\", value_codegen7); } - arrayOfObjects_3.setValueAtIndex(runtime, arrayOfObjectsIndex_4++, arrayOfObjectsObject_6); + arrayOfObjects_codegen3.setValueAtIndex(runtime, arrayOfObjectsIndex_codegen4++, arrayOfObjectsObject_codegen6); } - location_1.setProperty(runtime, \\"arrayOfObjects\\", arrayOfObjects_3); + location_codegen1.setProperty(runtime, \\"arrayOfObjects\\", arrayOfObjects_codegen3); - payload.setProperty(runtime, \\"location\\", location_1); + payload.setProperty(runtime, \\"location\\", location_codegen1); } return payload; }); diff --git a/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap b/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap index 7df6bfa4d6e3b7..deb724e1e26f9a 100644 --- a/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap +++ b/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GenerateEventEmitterCpp-test.js.snap @@ -153,29 +153,29 @@ void EventNestedObjectPropsNativeComponentViewEventEmitter::onChange(OnChange ev dispatchEvent(\\"change\\", [event=std::move(event)](jsi::Runtime &runtime) { auto payload = jsi::Object(runtime); { - auto location_1 = jsi::Object(runtime); + auto location_codegen1 = jsi::Object(runtime); { - auto source_2 = jsi::Object(runtime); - source_2.setProperty(runtime, \\"url\\", event.location.source.url); - location_1.setProperty(runtime, \\"source\\", source_2); + auto source_codegen2 = jsi::Object(runtime); + source_codegen2.setProperty(runtime, \\"url\\", event.location.source.url); + location_codegen1.setProperty(runtime, \\"source\\", source_codegen2); } - location_1.setProperty(runtime, \\"x\\", event.location.x); - location_1.setProperty(runtime, \\"y\\", event.location.y); + location_codegen1.setProperty(runtime, \\"x\\", event.location.x); + location_codegen1.setProperty(runtime, \\"y\\", event.location.y); - auto arrayOfObjects_3 = jsi::Array(runtime, event.location.arrayOfObjects.size()); - size_t arrayOfObjectsIndex_4 = 0; - for (auto arrayOfObjectsValue_5 : event.location.arrayOfObjects) { - auto arrayOfObjectsObject_6 = jsi::Object(runtime); + auto arrayOfObjects_codegen3 = jsi::Array(runtime, event.location.arrayOfObjects.size()); + size_t arrayOfObjectsIndex_codegen4 = 0; + for (auto arrayOfObjectsValue_codegen5 : event.location.arrayOfObjects) { + auto arrayOfObjectsObject_codegen6 = jsi::Object(runtime); { - auto value_7 = jsi::Object(runtime); - value_7.setProperty(runtime, \\"str\\", arrayOfObjectsValue_5.value.str); - arrayOfObjectsObject_6.setProperty(runtime, \\"value\\", value_7); + auto value_codegen7 = jsi::Object(runtime); + value_codegen7.setProperty(runtime, \\"str\\", arrayOfObjectsValue_codegen5.value.str); + arrayOfObjectsObject_codegen6.setProperty(runtime, \\"value\\", value_codegen7); } - arrayOfObjects_3.setValueAtIndex(runtime, arrayOfObjectsIndex_4++, arrayOfObjectsObject_6); + arrayOfObjects_codegen3.setValueAtIndex(runtime, arrayOfObjectsIndex_codegen4++, arrayOfObjectsObject_codegen6); } - location_1.setProperty(runtime, \\"arrayOfObjects\\", arrayOfObjects_3); + location_codegen1.setProperty(runtime, \\"arrayOfObjects\\", arrayOfObjects_codegen3); - payload.setProperty(runtime, \\"location\\", location_1); + payload.setProperty(runtime, \\"location\\", location_codegen1); } return payload; }); diff --git a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js index 13500380cb735b..92deabb0e8ac65 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js +++ b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js @@ -157,7 +157,7 @@ function variable(name: string, context: {variableSuffix: number}): string { // Prevents C++ variable name collisions for properties with the same name. // See: https://github.com/facebook/react-native/issues/53839 context.variableSuffix++; - return `${name}_${context.variableSuffix}`; + return `${name}_codegen${context.variableSuffix}`; } function generateArraySetter( diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap index 500201d7a57571..5f5a90978305ab 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap @@ -197,15 +197,15 @@ void EventsNestedObjectNativeComponentEventEmitter::onChange(OnChange event) con dispatchEvent(\\"change\\", [event=std::move(event)](jsi::Runtime &runtime) { auto payload = jsi::Object(runtime); { - auto location_1 = jsi::Object(runtime); + auto location_codegen1 = jsi::Object(runtime); { - auto source_2 = jsi::Object(runtime); - source_2.setProperty(runtime, \\"url\\", event.location.source.url); - location_1.setProperty(runtime, \\"source\\", source_2); + auto source_codegen2 = jsi::Object(runtime); + source_codegen2.setProperty(runtime, \\"url\\", event.location.source.url); + location_codegen1.setProperty(runtime, \\"source\\", source_codegen2); } - location_1.setProperty(runtime, \\"x\\", event.location.x); - location_1.setProperty(runtime, \\"y\\", event.location.y); - payload.setProperty(runtime, \\"location\\", location_1); + location_codegen1.setProperty(runtime, \\"x\\", event.location.x); + location_codegen1.setProperty(runtime, \\"y\\", event.location.y); + payload.setProperty(runtime, \\"location\\", location_codegen1); } return payload; }); @@ -249,60 +249,60 @@ void EventsNativeComponentEventEmitter::onArrayEventType(OnArrayEventType event) dispatchEvent(\\"arrayEventType\\", [event=std::move(event)](jsi::Runtime &runtime) { auto payload = jsi::Object(runtime); - auto bool_array_event_prop_1 = jsi::Array(runtime, event.bool_array_event_prop.size()); - size_t bool_array_event_propIndex_2 = 0; - for (auto bool_array_event_propValue_3 : event.bool_array_event_prop) { - bool_array_event_prop_1.setValueAtIndex(runtime, bool_array_event_propIndex_2++, (bool)bool_array_event_propValue_3); + auto bool_array_event_prop_codegen1 = jsi::Array(runtime, event.bool_array_event_prop.size()); + size_t bool_array_event_propIndex_codegen2 = 0; + for (auto bool_array_event_propValue_codegen3 : event.bool_array_event_prop) { + bool_array_event_prop_codegen1.setValueAtIndex(runtime, bool_array_event_propIndex_codegen2++, (bool)bool_array_event_propValue_codegen3); } - payload.setProperty(runtime, \\"bool_array_event_prop\\", bool_array_event_prop_1); + payload.setProperty(runtime, \\"bool_array_event_prop\\", bool_array_event_prop_codegen1); - auto string_enum_event_prop_4 = jsi::Array(runtime, event.string_enum_event_prop.size()); - size_t string_enum_event_propIndex_5 = 0; - for (auto string_enum_event_propValue_6 : event.string_enum_event_prop) { - string_enum_event_prop_4.setValueAtIndex(runtime, string_enum_event_propIndex_5++, toString(string_enum_event_propValue_6)); + auto string_enum_event_prop_codegen4 = jsi::Array(runtime, event.string_enum_event_prop.size()); + size_t string_enum_event_propIndex_codegen5 = 0; + for (auto string_enum_event_propValue_codegen6 : event.string_enum_event_prop) { + string_enum_event_prop_codegen4.setValueAtIndex(runtime, string_enum_event_propIndex_codegen5++, toString(string_enum_event_propValue_codegen6)); } - payload.setProperty(runtime, \\"string_enum_event_prop\\", string_enum_event_prop_4); + payload.setProperty(runtime, \\"string_enum_event_prop\\", string_enum_event_prop_codegen4); - auto array_array_event_prop_7 = jsi::Array(runtime, event.array_array_event_prop.size()); - size_t array_array_event_propIndex_8 = 0; - for (auto array_array_event_propValue_9 : event.array_array_event_prop) { - auto array_array_event_propArray_10 = jsi::Array(runtime, array_array_event_propValue_9.size()); - size_t array_array_event_propIndex_8Internal = 0; - for (auto array_array_event_propValue_9Internal : array_array_event_propValue_9) { - array_array_event_propArray_10.setValueAtIndex(runtime, array_array_event_propIndex_8Internal++, array_array_event_propValue_9Internal); + auto array_array_event_prop_codegen7 = jsi::Array(runtime, event.array_array_event_prop.size()); + size_t array_array_event_propIndex_codegen8 = 0; + for (auto array_array_event_propValue_codegen9 : event.array_array_event_prop) { + auto array_array_event_propArray_codegen10 = jsi::Array(runtime, array_array_event_propValue_codegen9.size()); + size_t array_array_event_propIndex_codegen8Internal = 0; + for (auto array_array_event_propValue_codegen9Internal : array_array_event_propValue_codegen9) { + array_array_event_propArray_codegen10.setValueAtIndex(runtime, array_array_event_propIndex_codegen8Internal++, array_array_event_propValue_codegen9Internal); } - array_array_event_prop_7.setValueAtIndex(runtime, array_array_event_propIndex_8++, array_array_event_propArray_10); + array_array_event_prop_codegen7.setValueAtIndex(runtime, array_array_event_propIndex_codegen8++, array_array_event_propArray_codegen10); } - payload.setProperty(runtime, \\"array_array_event_prop\\", array_array_event_prop_7); + payload.setProperty(runtime, \\"array_array_event_prop\\", array_array_event_prop_codegen7); - auto array_object_event_prop_11 = jsi::Array(runtime, event.array_object_event_prop.size()); - size_t array_object_event_propIndex_12 = 0; - for (auto array_object_event_propValue_13 : event.array_object_event_prop) { - auto array_object_event_propObject_14 = jsi::Object(runtime); - array_object_event_propObject_14.setProperty(runtime, \\"lat\\", array_object_event_propValue_13.lat); -array_object_event_propObject_14.setProperty(runtime, \\"lon\\", array_object_event_propValue_13.lon); - - auto names_15 = jsi::Array(runtime, array_object_event_propValue_13.names.size()); - size_t namesIndex_16 = 0; - for (auto namesValue_17 : array_object_event_propValue_13.names) { - names_15.setValueAtIndex(runtime, namesIndex_16++, namesValue_17); + auto array_object_event_prop_codegen11 = jsi::Array(runtime, event.array_object_event_prop.size()); + size_t array_object_event_propIndex_codegen12 = 0; + for (auto array_object_event_propValue_codegen13 : event.array_object_event_prop) { + auto array_object_event_propObject_codegen14 = jsi::Object(runtime); + array_object_event_propObject_codegen14.setProperty(runtime, \\"lat\\", array_object_event_propValue_codegen13.lat); +array_object_event_propObject_codegen14.setProperty(runtime, \\"lon\\", array_object_event_propValue_codegen13.lon); + + auto names_codegen15 = jsi::Array(runtime, array_object_event_propValue_codegen13.names.size()); + size_t namesIndex_codegen16 = 0; + for (auto namesValue_codegen17 : array_object_event_propValue_codegen13.names) { + names_codegen15.setValueAtIndex(runtime, namesIndex_codegen16++, namesValue_codegen17); } - array_object_event_propObject_14.setProperty(runtime, \\"names\\", names_15); + array_object_event_propObject_codegen14.setProperty(runtime, \\"names\\", names_codegen15); - array_object_event_prop_11.setValueAtIndex(runtime, array_object_event_propIndex_12++, array_object_event_propObject_14); + array_object_event_prop_codegen11.setValueAtIndex(runtime, array_object_event_propIndex_codegen12++, array_object_event_propObject_codegen14); } - payload.setProperty(runtime, \\"array_object_event_prop\\", array_object_event_prop_11); + payload.setProperty(runtime, \\"array_object_event_prop\\", array_object_event_prop_codegen11); - auto array_mixed_event_prop_18 = jsi::Array(runtime, event.array_mixed_event_prop.size()); - size_t array_mixed_event_propIndex_19 = 0; - for (auto array_mixed_event_propValue_20 : event.array_mixed_event_prop) { - array_mixed_event_prop_18.setValueAtIndex(runtime, array_mixed_event_propIndex_19++, jsi::valueFromDynamic(runtime, array_mixed_event_propValue_20)); + auto array_mixed_event_prop_codegen18 = jsi::Array(runtime, event.array_mixed_event_prop.size()); + size_t array_mixed_event_propIndex_codegen19 = 0; + for (auto array_mixed_event_propValue_codegen20 : event.array_mixed_event_prop) { + array_mixed_event_prop_codegen18.setValueAtIndex(runtime, array_mixed_event_propIndex_codegen19++, jsi::valueFromDynamic(runtime, array_mixed_event_propValue_codegen20)); } - payload.setProperty(runtime, \\"array_mixed_event_prop\\", array_mixed_event_prop_18); + payload.setProperty(runtime, \\"array_mixed_event_prop\\", array_mixed_event_prop_codegen18); return payload; });