mirror of
https://github.com/status-im/react-native.git
synced 2025-02-23 06:38:13 +00:00
Add MarkerSection
Summary: @public Adds a class for triggering markers. This calls `startMarker()` on construction, and `endMarker()` on destruction, thus being usable like a "scope guard": the object is instantiated, and automatically destroyed when going out of scope. Reviewed By: SidharthGuglani Differential Revision: D13817589 fbshipit-source-id: fd88884af970c1c0933d9ca6843f3f8f5d28b9e6
This commit is contained in:
parent
27b4d21564
commit
f1a3137b41
@ -1074,6 +1074,9 @@
|
||||
AC4A6AF921FB4EA900FBEC39 /* YGMarker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AC4A6AF821FB4EA900FBEC39 /* YGMarker.cpp */; };
|
||||
AC4A6AFA21FB4EBF00FBEC39 /* YGMarker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AC4A6AF821FB4EA900FBEC39 /* YGMarker.cpp */; };
|
||||
AC4A6AFB21FB4ECA00FBEC39 /* YGMarker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AC4A6AF821FB4EA900FBEC39 /* YGMarker.cpp */; };
|
||||
AC52CEDE21FB3FF9003C6BEC /* instrumentation.h in Headers */ = {isa = PBXBuildFile; fileRef = AC52CEDD21FB3FF9003C6BEC /* instrumentation.h */; };
|
||||
AC52CEDF21FB401D003C6BEC /* instrumentation.h in Headers */ = {isa = PBXBuildFile; fileRef = AC52CEDD21FB3FF9003C6BEC /* instrumentation.h */; };
|
||||
AC52CEE021FB403B003C6BEC /* instrumentation.h in Headers */ = {isa = PBXBuildFile; fileRef = AC52CEDD21FB3FF9003C6BEC /* instrumentation.h */; };
|
||||
AC6B69E321B1467C00B2B68A /* YGValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AC6B69E121B1467C00B2B68A /* YGValue.cpp */; };
|
||||
AC6B69E421B1467C00B2B68A /* YGValue.h in Headers */ = {isa = PBXBuildFile; fileRef = AC6B69E221B1467C00B2B68A /* YGValue.h */; };
|
||||
AC6B69E521B1469A00B2B68A /* YGValue.h in Headers */ = {isa = PBXBuildFile; fileRef = AC6B69E221B1467C00B2B68A /* YGValue.h */; };
|
||||
@ -2236,6 +2239,7 @@
|
||||
A2440AA01DF8D854006E7BFC /* RCTReloadCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTReloadCommand.h; sourceTree = "<group>"; };
|
||||
A2440AA11DF8D854006E7BFC /* RCTReloadCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTReloadCommand.m; sourceTree = "<group>"; };
|
||||
AC4A6AF821FB4EA900FBEC39 /* YGMarker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGMarker.cpp; sourceTree = "<group>"; };
|
||||
AC52CEDD21FB3FF9003C6BEC /* instrumentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = instrumentation.h; sourceTree = "<group>"; };
|
||||
AC6B69E121B1467C00B2B68A /* YGValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGValue.cpp; sourceTree = "<group>"; };
|
||||
AC6B69E221B1467C00B2B68A /* YGValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YGValue.h; sourceTree = "<group>"; };
|
||||
AC70D2E81DE489E4002E6351 /* RCTJavaScriptLoader.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RCTJavaScriptLoader.mm; sourceTree = "<group>"; };
|
||||
@ -2365,6 +2369,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
AC4A6AF821FB4EA900FBEC39 /* YGMarker.cpp */,
|
||||
AC52CEDD21FB3FF9003C6BEC /* instrumentation.h */,
|
||||
AC90463D21C91CC2005B24B3 /* CompactValue.h */,
|
||||
AC6B69E121B1467C00B2B68A /* YGValue.cpp */,
|
||||
AC6B69E221B1467C00B2B68A /* YGValue.h */,
|
||||
@ -3297,6 +3302,7 @@
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
AC52CEE021FB403B003C6BEC /* instrumentation.h in Headers */,
|
||||
AC90463F21C91D02005B24B3 /* CompactValue.h in Headers */,
|
||||
AC6B69E821B146C500B2B68A /* YGValue.h in Headers */,
|
||||
AC8360D221B025EF00FC46B9 /* YGConfig.h in Headers */,
|
||||
@ -3362,6 +3368,7 @@
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
AC52CEDF21FB401D003C6BEC /* instrumentation.h in Headers */,
|
||||
AC90464021C91D14005B24B3 /* CompactValue.h in Headers */,
|
||||
AC6B69E521B1469A00B2B68A /* YGValue.h in Headers */,
|
||||
AC8360CF21B0258B00FC46B9 /* YGConfig.h in Headers */,
|
||||
@ -3506,6 +3513,7 @@
|
||||
AC6B69E421B1467C00B2B68A /* YGValue.h in Headers */,
|
||||
3D80DA571DF820620028D040 /* RCTSourceCode.h in Headers */,
|
||||
EBF21BBC1FC498270052F4D5 /* InspectorInterfaces.h in Headers */,
|
||||
AC52CEDE21FB3FF9003C6BEC /* instrumentation.h in Headers */,
|
||||
3D80DA581DF820620028D040 /* RCTStatusBarManager.h in Headers */,
|
||||
3D80DA591DF820620028D040 /* RCTTiming.h in Headers */,
|
||||
3D80DA5A1DF820620028D040 /* RCTUIManager.h in Headers */,
|
||||
|
@ -37,3 +37,25 @@ typedef struct {
|
||||
void YGConfigSetMarkerCallbacks(YGConfigRef, YGMarkerCallbacks);
|
||||
|
||||
YG_EXTERN_C_END
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace marker {
|
||||
namespace detail {
|
||||
|
||||
template <YGMarker M>
|
||||
struct MarkerData;
|
||||
|
||||
template <>
|
||||
struct MarkerData<YGMarkerLayout> {
|
||||
using type = YGMarkerLayoutData;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace marker
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
|
||||
#endif // __cplusplus
|
||||
|
44
ReactCommon/yoga/yoga/instrumentation.h
Normal file
44
ReactCommon/yoga/yoga/instrumentation.h
Normal file
@ -0,0 +1,44 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
#include "YGConfig.h"
|
||||
#include "YGMarker.h"
|
||||
#include "YGNode.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace marker {
|
||||
|
||||
template <YGMarker MarkerType>
|
||||
class MarkerSection {
|
||||
public:
|
||||
MarkerSection(YGNodeRef node) : MarkerSection{node, node->getConfig()} {}
|
||||
~MarkerSection() {
|
||||
if (endMarker_) {
|
||||
endMarker_(MarkerType, node_, {&data}, userData_);
|
||||
}
|
||||
}
|
||||
|
||||
typename detail::MarkerData<MarkerType>::type data = {};
|
||||
|
||||
private:
|
||||
decltype(YGMarkerCallbacks{}.endMarker) endMarker_;
|
||||
YGNodeRef node_;
|
||||
void* userData_;
|
||||
|
||||
MarkerSection(YGNodeRef node, YGConfigRef config)
|
||||
: MarkerSection{node, config ? &config->markerCallbacks : nullptr} {}
|
||||
MarkerSection(YGNodeRef node, YGMarkerCallbacks* callbacks)
|
||||
: endMarker_{callbacks ? callbacks->endMarker : nullptr},
|
||||
node_{node},
|
||||
userData_{callbacks && callbacks->startMarker
|
||||
? callbacks->startMarker(MarkerType, node, {&data})
|
||||
: nullptr} {}
|
||||
};
|
||||
|
||||
} // namespace marker
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
Loading…
x
Reference in New Issue
Block a user