@react-native/codegen
Advanced tools
Comparing version 0.74.0-nightly-20231126-b50a7093b to 0.74.0-nightly-20231127-86c5abac2
@@ -260,29 +260,33 @@ /** | ||
); | ||
return Object.keys(aliasMap) | ||
.map(alias => { | ||
const value = aliasMap[alias]; | ||
if (value.properties.length === 0) { | ||
return ''; | ||
} | ||
const structName = `${moduleName}Base${alias}`; | ||
const templateParameterWithTypename = value.properties | ||
.map((v, i) => `typename P${i}`) | ||
.join(', '); | ||
const templateParameter = value.properties | ||
.map((v, i) => 'P' + i) | ||
.join(', '); | ||
const debugParameterConversion = value.properties | ||
.map( | ||
(v, i) => ` static ${getCppType(v)} ${ | ||
v.name | ||
}ToJs(jsi::Runtime &rt, P${i} value) { | ||
// TODO: T171006733 [Begin] Remove deprecated Cxx TMs structs after a new release. | ||
return ( | ||
Object.keys(aliasMap) | ||
.map(alias => { | ||
const value = aliasMap[alias]; | ||
if (value.properties.length === 0) { | ||
return ''; | ||
} | ||
const structName = `${moduleName}Base${alias}`; | ||
const structNameNew = `${moduleName}${alias}`; | ||
const templateParameterWithTypename = value.properties | ||
.map((v, i) => `typename P${i}`) | ||
.join(', '); | ||
const templateParameter = value.properties | ||
.map((v, i) => 'P' + i) | ||
.join(', '); | ||
const debugParameterConversion = value.properties | ||
.map( | ||
(v, i) => ` static ${getCppType(v)} ${ | ||
v.name | ||
}ToJs(jsi::Runtime &rt, P${i} value) { | ||
return bridging::toJs(rt, value); | ||
}`, | ||
) | ||
.join('\n\n'); | ||
return ` | ||
) | ||
.join('\n\n'); | ||
return ` | ||
#pragma mark - ${structName} | ||
template <${templateParameterWithTypename}> | ||
struct ${structName} { | ||
struct [[deprecated("Use ${structNameNew} instead.")]] ${structName} { | ||
${value.properties.map((v, i) => ' P' + i + ' ' + v.name).join(';\n')}; | ||
@@ -297,3 +301,3 @@ bool operator==(const ${structName} &other) const { | ||
template <${templateParameterWithTypename}> | ||
struct ${structName}Bridging { | ||
struct [[deprecated("Use ${structNameNew}Bridging instead.")]] ${structName}Bridging { | ||
static ${structName}<${templateParameter}> fromJs( | ||
@@ -338,4 +342,83 @@ jsi::Runtime &rt, | ||
`; | ||
}) | ||
.join('\n'); | ||
}) | ||
.join('\n') + | ||
// TODO: T171006733 [End] Remove deprecated Cxx TMs structs after a new release. | ||
Object.keys(aliasMap) | ||
.map(alias => { | ||
const value = aliasMap[alias]; | ||
if (value.properties.length === 0) { | ||
return ''; | ||
} | ||
const structName = `${moduleName}${alias}`; | ||
const templateParameterWithTypename = value.properties | ||
.map((v, i) => `typename P${i}`) | ||
.join(', '); | ||
const debugParameterConversion = value.properties | ||
.map( | ||
(v, i) => ` static ${getCppType(v)} ${ | ||
v.name | ||
}ToJs(jsi::Runtime &rt, decltype(types.${v.name}) value) { | ||
return bridging::toJs(rt, value); | ||
}`, | ||
) | ||
.join('\n\n'); | ||
return ` | ||
#pragma mark - ${structName} | ||
template <${templateParameterWithTypename}> | ||
struct ${structName} { | ||
${value.properties.map((v, i) => ' P' + i + ' ' + v.name).join(';\n')}; | ||
bool operator==(const ${structName} &other) const { | ||
return ${value.properties | ||
.map(v => `${v.name} == other.${v.name}`) | ||
.join(' && ')}; | ||
} | ||
}; | ||
template <typename T> | ||
struct ${structName}Bridging { | ||
static T types; | ||
static T fromJs( | ||
jsi::Runtime &rt, | ||
const jsi::Object &value, | ||
const std::shared_ptr<CallInvoker> &jsInvoker) { | ||
T result{ | ||
${value.properties | ||
.map( | ||
(v, i) => | ||
` bridging::fromJs<decltype(types.${v.name})>(rt, value.getProperty(rt, "${v.name}"), jsInvoker)`, | ||
) | ||
.join(',\n')}}; | ||
return result; | ||
} | ||
#ifdef DEBUG | ||
${debugParameterConversion} | ||
#endif | ||
static jsi::Object toJs( | ||
jsi::Runtime &rt, | ||
const T &value, | ||
const std::shared_ptr<CallInvoker> &jsInvoker) { | ||
auto result = facebook::jsi::Object(rt); | ||
${value.properties | ||
.map((v, i) => { | ||
if (v.optional) { | ||
return ` if (value.${v.name}) { | ||
result.setProperty(rt, "${v.name}", bridging::toJs(rt, value.${v.name}.value(), jsInvoker)); | ||
}`; | ||
} else { | ||
return ` result.setProperty(rt, "${v.name}", bridging::toJs(rt, value.${v.name}, jsInvoker));`; | ||
} | ||
}) | ||
.join('\n')} | ||
return result; | ||
} | ||
}; | ||
`; | ||
}) | ||
.join('\n') | ||
); | ||
} | ||
@@ -342,0 +425,0 @@ const EnumTemplate = ({ |
{ | ||
"name": "@react-native/codegen", | ||
"version": "0.74.0-nightly-20231126-b50a7093b", | ||
"version": "0.74.0-nightly-20231127-86c5abac2", | ||
"description": "Code generation tools for React Native", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
1533124
24695
391