Files
yoga/yoga/YGConfig.cpp

38 lines
965 B
C++
Raw Normal View History

/**
* 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"
YGConfig::YGConfig(YGLogger logger) : cloneNodeCallback_{nullptr} {
logger_.noContext = logger;
loggerUsesContext_ = false;
}
void YGConfig::log(
YGConfig* config,
YGNode* node,
YGLogLevel logLevel,
void* logContext,
const char* format,
va_list args) {
if (loggerUsesContext_) {
logger_.withContext(config, node, logLevel, logContext, format, args);
} else {
logger_.noContext(config, node, logLevel, format, args);
}
}
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;
}