2018-11-29 11:35:34 -08:00
|
|
|
/**
|
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2018-04-04 09:24:34 -07:00
|
|
|
*
|
2018-11-29 11:35:34 -08:00
|
|
|
* This source code is licensed under the MIT license found in the LICENSE
|
|
|
|
* file in the root directory of this source tree.
|
2018-04-04 09:24:34 -07:00
|
|
|
*/
|
|
|
|
#include "YGConfig.h"
|
|
|
|
|
2019-02-20 11:52:38 -08:00
|
|
|
YGConfig::YGConfig(YGLogger logger) : cloneNodeCallback_{nullptr} {
|
2019-02-19 09:54:45 -08:00
|
|
|
logger_.noContext = logger;
|
|
|
|
loggerUsesContext_ = false;
|
|
|
|
}
|
2019-02-19 09:54:45 -08:00
|
|
|
|
|
|
|
void YGConfig::log(
|
|
|
|
YGConfig* config,
|
|
|
|
YGNode* node,
|
|
|
|
YGLogLevel logLevel,
|
2019-02-19 09:54:45 -08:00
|
|
|
void* logContext,
|
2019-02-19 09:54:45 -08:00
|
|
|
const char* format,
|
|
|
|
va_list args) {
|
2019-02-19 09:54:45 -08:00
|
|
|
if (loggerUsesContext_) {
|
|
|
|
logger_.withContext(config, node, logLevel, logContext, format, args);
|
|
|
|
} else {
|
|
|
|
logger_.noContext(config, node, logLevel, format, args);
|
|
|
|
}
|
2019-02-19 09:54:45 -08:00
|
|
|
}
|
2019-02-20 11:52:38 -08:00
|
|
|
|
|
|
|
YGNodeRef YGConfig::cloneNode(YGNodeRef node, YGNodeRef owner, int childIndex) {
|
|
|
|
YGNodeRef clone = nullptr;
|
|
|
|
if (cloneNodeCallback_ != nullptr) {
|
|
|
|
clone = cloneNodeCallback_(node, owner, childIndex);
|
|
|
|
}
|
|
|
|
if (clone == nullptr) {
|
|
|
|
clone = YGNodeClone(node);
|
|
|
|
}
|
|
|
|
return clone;
|
|
|
|
}
|