Skip to content

Commit cf4963f

Browse files
NickGerlemanfacebook-github-bot
authored andcommitted
Start enabling -Wextra and -Wconversion in "rn_xplat_cxx_library" (1/2)
Summary: ## Stack These can suss out some real bugs, and helps further avoid mismatch with downstream MSVC on /W4 as used by MSFT. I enabled the families of warnings, but suppressed some major individual warnings that weren't clean. But I did clean some up, notably, missing initializer, and shortening 64 bit to 32 bit. We can do some of the rest incrementally (e.g. `-Wunused-parameter` has a fixit). This change illuminates that MapBuffer is missing 64 bit integer support, but we often pass 64 bit counters to it, which is a bug. For now I just left TODOs around those. `rn_xplat_cxx_library` is used for external libraries interfacing with RN, which we probably don't want to police, so I structured these stricter warnings as an opt-in flag, only enabled for our own rules. ## Diff This fixes up source code to avoid emitting the extra warnings now enforced. Of what is enabled, this is mostly shortening 64 to 32, or missing field in initializer. Changelog: [Internal] Reviewed By: christophpurrer Differential Revision: D52589303 fbshipit-source-id: 11cb778d065799fd0ead3ae706934146d13500bb
1 parent 822bf52 commit cf4963f

File tree

25 files changed

+77
-59
lines changed

25 files changed

+77
-59
lines changed

packages/react-native/React/Base/RCTBridgeModule.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ RCT_EXTERN_C_END
236236
*/
237237
#define RCT_REMAP_METHOD(js_name, method) \
238238
_RCT_EXTERN_REMAP_METHOD(js_name, method, NO) \
239-
-(void)method RCT_DYNAMIC;
239+
-(void)method RCT_DYNAMIC
240240

241241
/**
242242
* Similar to RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD but lets you set
@@ -248,7 +248,7 @@ RCT_EXTERN_C_END
248248
*/
249249
#define RCT_REMAP_BLOCKING_SYNCHRONOUS_METHOD(js_name, returnType, method) \
250250
_RCT_EXTERN_REMAP_METHOD(js_name, method, YES) \
251-
-(returnType)method RCT_DYNAMIC;
251+
-(returnType)method RCT_DYNAMIC
252252

253253
/**
254254
* Use this macro in a private Objective-C implementation file to automatically

packages/react-native/ReactAndroid/src/main/jni/react/fabric/CoreComponentsRegistry.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,16 @@ CoreComponentsRegistry::initHybrid(
8585
[](const EventDispatcher::Weak& eventDispatcher,
8686
const ContextContainer::Shared& contextContainer)
8787
-> ComponentDescriptorRegistry::Shared {
88+
ComponentDescriptorParameters params{
89+
.eventDispatcher = eventDispatcher,
90+
.contextContainer = contextContainer,
91+
.flavor = nullptr};
92+
8893
auto registry = CoreComponentsRegistry::sharedProviderRegistry()
89-
->createComponentDescriptorRegistry(
90-
{eventDispatcher, contextContainer});
94+
->createComponentDescriptorRegistry(params);
9195
auto& mutableRegistry = const_cast<ComponentDescriptorRegistry&>(*registry);
9296
mutableRegistry.setFallbackComponentDescriptor(
93-
std::make_shared<UnimplementedNativeViewComponentDescriptor>(
94-
ComponentDescriptorParameters{
95-
eventDispatcher, contextContainer, nullptr}));
97+
std::make_shared<UnimplementedNativeViewComponentDescriptor>(params));
9698

9799
return registry;
98100
};

packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static inline int getIntBufferSizeForType(CppMountItem::Type mountItemType) {
8585

8686
static inline void updateBufferSizes(
8787
CppMountItem::Type mountItemType,
88-
int numInstructions,
88+
size_t numInstructions,
8989
int& batchMountItemIntsSize,
9090
int& batchMountItemObjectsSize) {
9191
if (numInstructions == 0) {
@@ -182,7 +182,7 @@ static inline void computeBufferSizes(
182182

183183
static inline void writeIntBufferTypePreamble(
184184
int mountItemType,
185-
int numItems,
185+
size_t numItems,
186186
_JNIEnv* env,
187187
jintArray& intBufferArray,
188188
int& intBufferPosition) {
@@ -193,7 +193,7 @@ static inline void writeIntBufferTypePreamble(
193193
intBufferPosition += 1;
194194
} else {
195195
temp[0] = mountItemType | CppMountItem::Type::Multiple;
196-
temp[1] = numItems;
196+
temp[1] = static_cast<jint>(numItems);
197197
env->SetIntArrayRegion(intBufferArray, intBufferPosition, 2, temp);
198198
intBufferPosition += 2;
199199
}

packages/react-native/ReactAndroid/src/main/jni/react/fabric/ReactNativeConfigHolder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
#import "ReactNativeConfigHolder.h"
8+
#include "ReactNativeConfigHolder.h"
99

1010
#include <fbjni/fbjni.h>
1111

packages/react-native/ReactAndroid/src/main/jni/react/jni/MethodInvoker.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ jint extractInteger(const folly::dynamic& value) {
5959
// The logic here is taken from convertDynamicIfIntegral, but the
6060
// return type and exception are different.
6161
if (value.isInt()) {
62-
return value.getInt();
62+
// TODO: this truncates 64 bit ints, valid in JS
63+
return static_cast<jint>(value.getInt());
6364
}
6465
double dbl = value.getDouble();
6566
jint result = static_cast<jint>(dbl);
@@ -227,7 +228,7 @@ MethodCallResult MethodInvoker::invoke(
227228

228229
auto env = Environment::current();
229230
auto argCount = signature_.size() - 2;
230-
JniLocalScope scope(env, argCount);
231+
JniLocalScope scope(env, static_cast<int>(argCount));
231232
jvalue args[argCount];
232233
std::transform(
233234
signature_.begin() + 2,

packages/react-native/ReactAndroid/src/main/jni/react/jni/ReadableNativeArray.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void ReadableNativeArray::mapException(std::exception_ptr ex) {
2323
}
2424

2525
local_ref<JArrayClass<jobject>> ReadableNativeArray::importArray() {
26-
jint size = array_.size();
26+
auto size = static_cast<jint>(array_.size());
2727
auto jarray = JArrayClass<jobject>::newArray(size);
2828
for (jint ii = 0; ii < size; ii++) {
2929
addDynamicToJArray(jarray, ii, array_.at(ii));
@@ -32,7 +32,7 @@ local_ref<JArrayClass<jobject>> ReadableNativeArray::importArray() {
3232
}
3333

3434
local_ref<JArrayClass<jobject>> ReadableNativeArray::importTypeArray() {
35-
jint size = array_.size();
35+
auto size = static_cast<jint>(array_.size());
3636
auto jarray = JArrayClass<jobject>::newArray(size);
3737
for (jint ii = 0; ii < size; ii++) {
3838
(*jarray)[ii] = ReadableType::getType(array_.at(ii).type());

packages/react-native/ReactAndroid/src/main/jni/react/jni/ReadableNativeMap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ local_ref<JArrayClass<jstring>> ReadableNativeMap::importKeys() {
8080
local_ref<JArrayClass<jobject>> ReadableNativeMap::importValues() {
8181
throwIfConsumed();
8282

83-
jint size = keys_.value().size();
83+
auto size = static_cast<jint>(keys_.value().size());
8484
auto jarray = JArrayClass<jobject>::newArray(size);
8585
for (jint ii = 0; ii < size; ii++) {
8686
const std::string& key = (*keys_)[ii].getString();
@@ -92,7 +92,7 @@ local_ref<JArrayClass<jobject>> ReadableNativeMap::importValues() {
9292
local_ref<JArrayClass<jobject>> ReadableNativeMap::importTypes() {
9393
throwIfConsumed();
9494

95-
jint size = keys_.value().size();
95+
auto size = static_cast<jint>(keys_.value().size());
9696
auto jarray = JArrayClass<jobject>::newArray(size);
9797
for (jint ii = 0; ii < size; ii++) {
9898
const std::string& key = (*keys_)[ii].getString();

packages/react-native/ReactAndroid/src/main/jni/react/newarchdefaults/DefaultComponentsRegistry.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,17 @@ DefaultComponentsRegistry::initHybrid(
4040
[](const EventDispatcher::Weak& eventDispatcher,
4141
const ContextContainer::Shared& contextContainer)
4242
-> ComponentDescriptorRegistry::Shared {
43+
ComponentDescriptorParameters params{
44+
.eventDispatcher = eventDispatcher,
45+
.contextContainer = contextContainer,
46+
.flavor = nullptr};
47+
4348
auto registry = DefaultComponentsRegistry::sharedProviderRegistry()
44-
->createComponentDescriptorRegistry(
45-
{eventDispatcher, contextContainer});
49+
->createComponentDescriptorRegistry(params);
4650

4751
auto& mutableRegistry = const_cast<ComponentDescriptorRegistry&>(*registry);
4852
mutableRegistry.setFallbackComponentDescriptor(
49-
std::make_shared<UnimplementedNativeViewComponentDescriptor>(
50-
ComponentDescriptorParameters{
51-
eventDispatcher, contextContainer, nullptr}));
53+
std::make_shared<UnimplementedNativeViewComponentDescriptor>(params));
5254

5355
return registry;
5456
};

packages/react-native/ReactCommon/cxxreact/JSBigString.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ JSBigFileString::JSBigFileString(int fd, size_t size, off_t offset /*= 0*/)
3838
const static auto ps = sysconf(_SC_PAGESIZE);
3939
auto d = lldiv(offset, ps);
4040

41-
m_mapOff = d.quot;
42-
m_pageOff = d.rem;
41+
m_mapOff = static_cast<off_t>(d.quot);
42+
m_pageOff = static_cast<off_t>(d.rem);
4343
m_size = size + m_pageOff;
4444
} else {
4545
m_mapOff = 0;

packages/react-native/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,15 @@ JNIArgs convertJSIArgsToJNIArgs(
250250
size_t count,
251251
const std::shared_ptr<CallInvoker>& jsInvoker,
252252
TurboModuleMethodValueKind valueKind) {
253-
unsigned int expectedArgumentCount = valueKind == PromiseKind
253+
size_t expectedArgumentCount = valueKind == PromiseKind
254254
? methodArgTypes.size() - 1
255255
: methodArgTypes.size();
256256

257257
if (expectedArgumentCount != count) {
258258
throw JavaTurboModuleInvalidArgumentCountException(
259-
methodName, count, expectedArgumentCount);
259+
methodName,
260+
static_cast<int>(count),
261+
static_cast<int>(expectedArgumentCount));
260262
}
261263

262264
JNIArgs jniArgs(valueKind == PromiseKind ? count + 1 : count);
@@ -505,7 +507,8 @@ jsi::Value JavaTurboModule::invokeJavaMethod(
505507
* GlobalReferences. The LocalReferences are then promptly deleted
506508
* after the conversion.
507509
*/
508-
unsigned int actualArgCount = valueKind == VoidKind ? 0 : argCount;
510+
unsigned int actualArgCount =
511+
valueKind == VoidKind ? 0 : static_cast<unsigned int>(argCount);
509512
unsigned int estimatedLocalRefCount =
510513
actualArgCount + maxReturnObjects + buffer;
511514

packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTInteropTurboModule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class JSI_EXPORT ObjCInteropTurboModule : public ObjCTurboModule {
2323
struct MethodDescriptor {
2424
std::string methodName;
2525
SEL selector;
26-
int jsArgCount;
26+
size_t jsArgCount;
2727
TurboModuleMethodValueKind jsReturnKind;
2828
};
2929

packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTInteropTurboModule.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,11 @@ T RCTConvertTo(SEL selector, id json)
192192
methodArgumentTypeNames_ = methodArgTypeNames;
193193

194194
for (const ExportedMethod &method : methods) {
195-
const int numArgs = [method.argumentTypes count];
195+
const size_t numArgs = [method.argumentTypes count];
196196
const bool isPromiseMethod =
197197
numArgs >= 2 && [method.argumentTypes[numArgs - 1] isEqualToString:@"RCTPromiseRejectBlock"];
198198

199-
const int jsArgCount = isPromiseMethod ? numArgs - 2 : numArgs;
199+
const size_t jsArgCount = isPromiseMethod ? numArgs - 2 : numArgs;
200200

201201
/**
202202
* In the TurboModule system, only promises and voids are special. So, set those.
@@ -330,7 +330,7 @@ T RCTConvertTo(SEL selector, id json)
330330
NSString *methodName = @(methodNameCStr);
331331
std::string methodJsSignature = name_ + "." + methodNameCStr + "()";
332332

333-
NSString *argumentType = getArgumentTypeName(runtime, methodName, index);
333+
NSString *argumentType = getArgumentTypeName(runtime, methodName, static_cast<int>(index));
334334
std::string errorPrefix = methodJsSignature + ": Error while converting JavaScript argument " +
335335
std::to_string(index) + " to Objective C type " + [argumentType UTF8String] + ". ";
336336

@@ -586,7 +586,7 @@ T RCTConvertTo(SEL selector, id json)
586586
}
587587

588588
if ([methodArgumentTypeNames_[methodName] count] <= argIndex) {
589-
int paramCount = [methodArgumentTypeNames_[methodName] count];
589+
size_t paramCount = [methodArgumentTypeNames_[methodName] count];
590590
throw jsi::JSError(runtime, errorPrefix + "Method has only " + std::to_string(paramCount) + " parameter types.");
591591
}
592592

packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class JSI_EXPORT ObjCTurboModule : public TurboModule {
6262
std::shared_ptr<NativeMethodCallInvoker> nativeMethodCallInvoker_;
6363

6464
protected:
65-
void setMethodArgConversionSelector(NSString *methodName, int argIndex, NSString *fnName);
65+
void setMethodArgConversionSelector(NSString *methodName, size_t argIndex, NSString *fnName);
6666

6767
/**
6868
* Why is this virtual?
@@ -126,8 +126,8 @@ class JSI_EXPORT ObjCTurboModule : public TurboModule {
126126
NSDictionary<NSString *, NSArray<NSString *> *> *methodArgumentTypeNames_;
127127

128128
bool isMethodSync(TurboModuleMethodValueKind returnType);
129-
BOOL hasMethodArgConversionSelector(NSString *methodName, int argIndex);
130-
SEL getMethodArgConversionSelector(NSString *methodName, int argIndex);
129+
BOOL hasMethodArgConversionSelector(NSString *methodName, size_t argIndex);
130+
SEL getMethodArgConversionSelector(NSString *methodName, size_t argIndex);
131131
NSInvocation *createMethodInvocation(
132132
jsi::Runtime &runtime,
133133
bool isSync,

packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ SystraceSection s(
595595
* Convert objects using RCTConvert.
596596
*/
597597
if (objCArgType == @encode(id)) {
598-
NSString *argumentType = getArgumentTypeName(runtime, methodNameNSString, i);
598+
NSString *argumentType = getArgumentTypeName(runtime, methodNameNSString, static_cast<int>(i));
599599
if (argumentType != nil) {
600600
NSString *rctConvertMethodName = [NSString stringWithFormat:@"%@:", argumentType];
601601
SEL rctConvertSelector = NSSelectorFromString(rctConvertMethodName);
@@ -776,19 +776,19 @@ SystraceSection s(
776776
return returnValue;
777777
}
778778

779-
BOOL ObjCTurboModule::hasMethodArgConversionSelector(NSString *methodName, int argIndex)
779+
BOOL ObjCTurboModule::hasMethodArgConversionSelector(NSString *methodName, size_t argIndex)
780780
{
781781
return methodArgConversionSelectors_ && methodArgConversionSelectors_[methodName] &&
782782
![methodArgConversionSelectors_[methodName][argIndex] isEqual:[NSNull null]];
783783
}
784784

785-
SEL ObjCTurboModule::getMethodArgConversionSelector(NSString *methodName, int argIndex)
785+
SEL ObjCTurboModule::getMethodArgConversionSelector(NSString *methodName, size_t argIndex)
786786
{
787787
assert(hasMethodArgConversionSelector(methodName, argIndex));
788788
return (SEL)((NSValue *)methodArgConversionSelectors_[methodName][argIndex]).pointerValue;
789789
}
790790

791-
void ObjCTurboModule::setMethodArgConversionSelector(NSString *methodName, int argIndex, NSString *fnName)
791+
void ObjCTurboModule::setMethodArgConversionSelector(NSString *methodName, size_t argIndex, NSString *fnName)
792792
{
793793
if (!methodArgConversionSelectors_) {
794794
methodArgConversionSelectors_ = [NSMutableDictionary new];

packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,9 +1162,10 @@ inline MapBuffer toMapBuffer(const AttributedString& attributedString) {
11621162
}
11631163

11641164
auto builder = MapBufferBuilder();
1165-
builder.putInt(
1166-
AS_KEY_HASH,
1167-
std::hash<facebook::react::AttributedString>{}(attributedString));
1165+
size_t hash =
1166+
std::hash<facebook::react::AttributedString>{}(attributedString);
1167+
// TODO: This truncates half the hash
1168+
builder.putInt(AS_KEY_HASH, static_cast<int>(hash));
11681169
builder.putString(AS_KEY_STRING, attributedString.getString());
11691170
auto fragmentsMap = fragmentsBuilder.build();
11701171
builder.putMapBuffer(AS_KEY_FRAGMENTS, fragmentsMap);

packages/react-native/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ @implementation RCTLegacyViewManagerInteropCoordinator {
4646
- (instancetype)initWithComponentData:(RCTComponentData *)componentData
4747
bridge:(nullable RCTBridge *)bridge
4848
bridgeProxy:(nullable RCTBridgeProxy *)bridgeProxy
49-
bridgelessInteropData:(RCTBridgeModuleDecorator *)bridgelessInteropData;
49+
bridgelessInteropData:(RCTBridgeModuleDecorator *)bridgelessInteropData
5050
{
5151
if (self = [super init]) {
5252
_componentData = componentData;
@@ -89,7 +89,7 @@ - (void)removeObserveForTag:(NSInteger)tag
8989
[_eventInterceptors removeObjectForKey:[NSNumber numberWithInteger:tag]];
9090
}
9191

92-
- (UIView *)createPaperViewWithTag:(NSInteger)tag;
92+
- (UIView *)createPaperViewWithTag:(NSInteger)tag
9393
{
9494
UIView *view = [_componentData createViewWithTag:[NSNumber numberWithInteger:tag] rootTag:NULL];
9595
[_bridgelessInteropData attachInteropAPIsToModule:(id<RCTBridgeModule>)_componentData.bridgelessViewManager];

packages/react-native/ReactCommon/react/renderer/components/textinput/platform/android/react/renderer/components/androidtextinput/AndroidTextInputState.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ MapBuffer AndroidTextInputState::getMapBuffer() const {
8888
auto builder = MapBufferBuilder();
8989
// See comment in getDynamic block.
9090
if (cachedAttributedStringId == 0) {
91-
builder.putInt(TX_STATE_KEY_MOST_RECENT_EVENT_COUNT, mostRecentEventCount);
91+
// TODO truncation
92+
builder.putInt(
93+
TX_STATE_KEY_MOST_RECENT_EVENT_COUNT,
94+
static_cast<int32_t>(mostRecentEventCount));
9295

9396
auto attStringMapBuffer = toMapBuffer(attributedString);
9497
builder.putMapBuffer(TX_STATE_KEY_ATTRIBUTED_STRING, attStringMapBuffer);

packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputShadowNode.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ AttributedString TextInputShadowNode::getAttributedString(
6060
layoutContext.fontSizeMultiplier);
6161
auto attributedString = AttributedString{};
6262

63-
attributedString.appendFragment(
64-
AttributedString::Fragment{getConcreteProps().text, textAttributes});
63+
attributedString.appendFragment(AttributedString::Fragment{
64+
.string = getConcreteProps().text,
65+
.textAttributes = textAttributes,
66+
// TODO: Is this really meant to be by value?
67+
.parentShadowView = ShadowView{}});
6568

6669
auto attachments = Attachments{};
6770
BaseTextShadowNode::buildAttributedString(

packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/AccessibilityPropsMapBuffer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace facebook::react {
1212

1313
static MapBuffer convertAccessibilityActions(
1414
const std::vector<AccessibilityAction>& actions) {
15-
MapBufferBuilder builder(actions.size());
15+
MapBufferBuilder builder(static_cast<uint32_t>(actions.size()));
1616
for (auto i = 0; i < actions.size(); i++) {
1717
const auto& action = actions[i];
1818
MapBufferBuilder actionsBuilder(2);
@@ -28,7 +28,7 @@ static MapBuffer convertAccessibilityActions(
2828

2929
static MapBuffer convertAccessibilityLabelledBy(
3030
const AccessibilityLabelledBy& labelledBy) {
31-
MapBufferBuilder builder(labelledBy.value.size());
31+
MapBufferBuilder builder(static_cast<uint32_t>(labelledBy.value.size()));
3232
for (auto i = 0; i < labelledBy.value.size(); i++) {
3333
builder.putString(i, labelledBy.value[i]);
3434
}

packages/react-native/ReactCommon/react/renderer/mapbuffer/MapBufferBuilder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,18 @@ void MapBufferBuilder::putMapBuffer(MapBuffer::Key key, const MapBuffer& map) {
116116
void MapBufferBuilder::putMapBufferList(
117117
MapBuffer::Key key,
118118
const std::vector<MapBuffer>& mapBufferList) {
119-
int32_t offset = dynamicData_.size();
119+
auto offset = static_cast<int32_t>(dynamicData_.size());
120120
int32_t dataSize = 0;
121121
for (const MapBuffer& mapBuffer : mapBufferList) {
122-
dataSize = dataSize + INT_SIZE + mapBuffer.size();
122+
dataSize = dataSize + INT_SIZE + static_cast<int32_t>(mapBuffer.size());
123123
}
124124

125125
dynamicData_.resize(offset + INT_SIZE, 0);
126126
memcpy(dynamicData_.data() + offset, &dataSize, INT_SIZE);
127127

128128
for (const MapBuffer& mapBuffer : mapBufferList) {
129-
int32_t mapBufferSize = mapBuffer.size();
130-
int32_t dynamicDataSize = dynamicData_.size();
129+
auto mapBufferSize = static_cast<int32_t>(mapBuffer.size());
130+
auto dynamicDataSize = static_cast<int32_t>(dynamicData_.size());
131131
dynamicData_.resize(dynamicDataSize + INT_SIZE + mapBufferSize, 0);
132132
// format [length of buffer (int)] + [bytes of MapBuffer]
133133
memcpy(dynamicData_.data() + dynamicDataSize, &mapBufferSize, INT_SIZE);

packages/react-native/ReactCommon/react/renderer/mapbuffer/MapBufferBuilder.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class MapBufferBuilder {
2727

2828
void putInt(MapBuffer::Key key, int32_t value);
2929

30+
// TODO: Support 64 bit integers
31+
3032
void putBool(MapBuffer::Key key, bool value);
3133

3234
void putDouble(MapBuffer::Key key, double value);

0 commit comments

Comments
 (0)