Add support for context-aware cloning functions
Summary: @public Context-aware cloning functions are an internal Yoga feature that will be used for Yoga’s JNI code. It will be possible to specify a context when calculating layout, which will be passed on to cloning functions. This will be a private feature. Reviewed By: SidharthGuglani Differential Revision: D14149470 fbshipit-source-id: 1d11106e65f9d872d10f191763da001f8d158a61
This commit is contained in:
committed by
Facebook Github Bot
parent
b1c749075d
commit
2156de5fb5
@@ -17,13 +17,22 @@ struct YGConfig {
|
||||
void* context,
|
||||
const char* format,
|
||||
va_list args);
|
||||
using CloneWithContextFn = YGNodeRef (*)(
|
||||
YGNodeRef node,
|
||||
YGNodeRef owner,
|
||||
int childIndex,
|
||||
void* cloneContext);
|
||||
|
||||
private:
|
||||
YGCloneNodeFunc cloneNodeCallback_ = nullptr;
|
||||
union {
|
||||
CloneWithContextFn withContext;
|
||||
YGCloneNodeFunc noContext;
|
||||
} cloneNodeCallback_;
|
||||
union {
|
||||
LogWithContextFn withContext;
|
||||
YGLogger noContext;
|
||||
} logger_;
|
||||
bool cloneNodeUsesContext_;
|
||||
bool loggerUsesContext_;
|
||||
|
||||
public:
|
||||
@@ -51,8 +60,20 @@ public:
|
||||
setLogger(YGLogger{nullptr});
|
||||
}
|
||||
|
||||
YGNodeRef cloneNode(YGNodeRef node, YGNodeRef owner, int childIndex);
|
||||
YGNodeRef cloneNode(
|
||||
YGNodeRef node,
|
||||
YGNodeRef owner,
|
||||
int childIndex,
|
||||
void* cloneContext);
|
||||
void setCloneNodeCallback(YGCloneNodeFunc cloneNode) {
|
||||
cloneNodeCallback_ = cloneNode;
|
||||
cloneNodeCallback_.noContext = cloneNode;
|
||||
cloneNodeUsesContext_ = false;
|
||||
}
|
||||
void setCloneNodeCallback(CloneWithContextFn cloneNode) {
|
||||
cloneNodeCallback_.withContext = cloneNode;
|
||||
cloneNodeUsesContext_ = true;
|
||||
}
|
||||
void setCloneNodeCallback(std::nullptr_t) {
|
||||
setCloneNodeCallback(YGCloneNodeFunc{nullptr});
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user