mirror of
https://github.com/status-im/react-native.git
synced 2025-02-24 15:18:10 +00:00
Summary: This change is aiming to reduce some of the forking changes we have internally in order to use CxxReact for some additional out of tree platforms. Some of the fixes allow more of the code to compile when using Microsoft Visual Studio Compiler. In particular the change around the default value of RN_EXPORT and some changes around how to enable the packing attribute. Another change moves more of the code for JSBigFileString into the cpp file, so that people can share the header but replace the implementation as appropriate for other platforms. And finally the removal of an unused header include. This is unlikely to be the extent of the changes required for MSVC, but at least gets one of our complication blocks to work against an unforked RN. Pull Request resolved: https://github.com/facebook/react-native/pull/22182 Differential Revision: D12967758 Pulled By: cpojer fbshipit-source-id: a2cc018aedaa9916cd644bfbd9e3a55330cd4c52
68 lines
1.5 KiB
C++
68 lines
1.5 KiB
C++
// Copyright (c) Facebook, Inc. and its 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 <cstdint>
|
|
#include <cstring>
|
|
#include <folly/Portability.h>
|
|
|
|
#ifndef RN_EXPORT
|
|
#define RN_EXPORT __attribute__((visibility("default")))
|
|
#endif
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
/*
|
|
* ScriptTag
|
|
*
|
|
* 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.
|
|
*/
|
|
enum struct ScriptTag {
|
|
String = 0,
|
|
RAMBundle,
|
|
BCBundle,
|
|
};
|
|
|
|
/**
|
|
* BundleHeader
|
|
*
|
|
* 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 BundleHeader {
|
|
BundleHeader() {
|
|
std::memset(this, 0, sizeof(BundleHeader));
|
|
}
|
|
|
|
uint32_t magic;
|
|
uint32_t reserved_;
|
|
uint32_t version;
|
|
};
|
|
FOLLY_PACK_POP
|
|
|
|
/**
|
|
* parseTypeFromHeader
|
|
*
|
|
* Takes the first 8 bytes of a bundle, and returns a tag describing the
|
|
* bundle's format.
|
|
*/
|
|
RN_EXPORT ScriptTag parseTypeFromHeader(const BundleHeader& header);
|
|
|
|
/**
|
|
* stringForScriptTag
|
|
*
|
|
* Convert an `ScriptTag` enum into a string, useful for emitting in errors
|
|
* and diagnostic messages.
|
|
*/
|
|
RN_EXPORT const char* stringForScriptTag(const ScriptTag& tag);
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|