mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
063c2b4668
Summary: React Native is compiled downstream with MSVC, meaning the introduction of code depending on language extensions specific to gcc/clang may cause breakage. We can enable `-Wpedantic` to flag any behavior not officially supported by the specified C++ standard. This will includes rules beyond what MSVC has trouble with, but seems to not have too many "noisy warnings". This change enables -Wpedantic in BUCK targets within ReactCommon. This makes the OSS C++ build for Android/iOS slightly more permissive than the internal build, A followup is to add the changes to OSS build logic as well, to avoid contributors seeing more errors upon internal submission. (checking with cortinico on how to do this for Android). react-native-windows uses a higher warning level than `-Wall`, which is an additional cause of compilation failures, but is not addressed as part of this change. Changelog: [Internal][Changed] - Enable -Wpedantic for targets inside ReactCommon Reviewed By: rshest Differential Revision: D38457812 fbshipit-source-id: 014da1ac0b7ad8f78154e6e447ed58def6bd0d47
77 lines
1.8 KiB
C++
77 lines
1.8 KiB
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <folly/Portability.h>
|
|
#include <cstdint>
|
|
#include <cstring>
|
|
|
|
#ifndef RN_EXPORT
|
|
#define RN_EXPORT __attribute__((visibility("default")))
|
|
#endif
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
/*
|
|
* Scripts given to the JS Executors to run could be in any of the following
|
|
* formats. They are tagged so the executor knows how to run them.
|
|
* Hermes bytecode bundles (as encoded by hermesc, not metro) are not treated
|
|
* in a special way, they will be identified as ScriptTag::String.
|
|
*/
|
|
enum struct ScriptTag {
|
|
String = 0,
|
|
RAMBundle,
|
|
MetroHBCBundle,
|
|
};
|
|
|
|
/**
|
|
* RAM bundles and BC bundles begin with headers. For RAM bundles this is
|
|
* 4 bytes, for BC bundles this is 12 bytes. This structure holds the first 12
|
|
* bytes from a bundle in a way that gives access to that information.
|
|
*/
|
|
FOLLY_PACK_PUSH
|
|
|
|
struct FOLLY_PACK_ATTR Magic32 {
|
|
uint32_t value;
|
|
uint32_t reserved_;
|
|
};
|
|
|
|
struct FOLLY_PACK_ATTR BundleHeader {
|
|
BundleHeader() {
|
|
std::memset(this, 0, sizeof(BundleHeader));
|
|
}
|
|
|
|
union {
|
|
Magic32 magic32;
|
|
uint64_t magic64;
|
|
};
|
|
uint32_t version;
|
|
};
|
|
FOLLY_PACK_POP
|
|
|
|
/**
|
|
* Takes the first 8 bytes of a bundle, and returns a tag describing the
|
|
* bundle's format.
|
|
*/
|
|
RN_EXPORT ScriptTag parseTypeFromHeader(const BundleHeader &header);
|
|
|
|
/**
|
|
* Convert an `ScriptTag` enum into a string, useful for emitting in errors
|
|
* and diagnostic messages.
|
|
*/
|
|
RN_EXPORT const char *stringForScriptTag(const ScriptTag &tag);
|
|
|
|
/**
|
|
* Check whether a given bundle is hermesc-generated bytecode
|
|
*/
|
|
RN_EXPORT bool isHermesBytecodeBundle(const BundleHeader &header);
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|