split project with app & doric module
This commit is contained in:
32
doric-Qt/example/doric/yoga/internal/experiments-inl.h
Normal file
32
doric-Qt/example/doric/yoga/internal/experiments-inl.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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 "experiments.h"
|
||||
|
||||
#include <bitset>
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace internal {
|
||||
|
||||
namespace detail {
|
||||
extern std::bitset<sizeof(int)> enabledExperiments;
|
||||
} // namespace detail
|
||||
|
||||
inline bool isEnabled(Experiment experiment) {
|
||||
return detail::enabledExperiments.test(static_cast<size_t>(experiment));
|
||||
}
|
||||
|
||||
inline void disableAllExperiments() {
|
||||
detail::enabledExperiments = 0;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
38
doric-Qt/example/doric/yoga/internal/experiments.cpp
Normal file
38
doric-Qt/example/doric/yoga/internal/experiments.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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 "experiments.h"
|
||||
#include "experiments-inl.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace internal {
|
||||
|
||||
namespace detail {
|
||||
|
||||
std::bitset<sizeof(int)> enabledExperiments = 0;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
void enable(Experiment experiment) {
|
||||
detail::enabledExperiments.set(static_cast<size_t>(experiment));
|
||||
}
|
||||
|
||||
void disable(Experiment experiment) {
|
||||
detail::enabledExperiments.reset(static_cast<size_t>(experiment));
|
||||
}
|
||||
|
||||
bool toggle(Experiment experiment) {
|
||||
auto bit = static_cast<size_t>(experiment);
|
||||
auto previousState = detail::enabledExperiments.test(bit);
|
||||
detail::enabledExperiments.flip(bit);
|
||||
return previousState;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
26
doric-Qt/example/doric/yoga/internal/experiments.h
Normal file
26
doric-Qt/example/doric/yoga/internal/experiments.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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 <cstddef>
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace internal {
|
||||
|
||||
enum struct Experiment : size_t {
|
||||
kDoubleMeasureCallbacks,
|
||||
};
|
||||
|
||||
void enable(Experiment);
|
||||
void disable(Experiment);
|
||||
bool toggle(Experiment);
|
||||
|
||||
} // namespace internal
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
Reference in New Issue
Block a user