Introduce CSSAssertSetFailFunc and CSSAsserFail to throw managed exception
Summary: - Define CSS_ASSERT_FAIL_ENABLED for P/Invoke (Visual Studio project already has it) - Pass managed delegate pointer to unmanaged side via P/Invoke. - CSSAssertFail will call the managed delegate when assert failed. - The delegate will throw managed exception. Reviewed By: emilsjolander Differential Revision: D3982084 fbshipit-source-id: 058a87c10ca89238362be4d8759cc00dd0c9b376
This commit is contained in:
committed by
Facebook Github Bot
parent
90844d62c5
commit
56f6efdecf
@@ -219,6 +219,7 @@ void _CSSNodeMarkDirty(const CSSNodeRef node) {
|
||||
}
|
||||
|
||||
void CSSNodeInsertChild(const CSSNodeRef node, const CSSNodeRef child, const uint32_t index) {
|
||||
CSS_ASSERT(child->parent == NULL, "Child already has a parent, it must be removed first.");
|
||||
CSSNodeListInsert(node->children, child, index);
|
||||
child->parent = node;
|
||||
_CSSNodeMarkDirty(node);
|
||||
@@ -2295,3 +2296,17 @@ void CSSNodeCalculateLayout(const CSSNodeRef node,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CSS_ASSERT_FAIL_ENABLED
|
||||
static CSSAssertFailFunc gAssertFailFunc;
|
||||
|
||||
void CSSAssertSetFailFunc(CSSAssertFailFunc func) {
|
||||
gAssertFailFunc = func;
|
||||
}
|
||||
|
||||
void CSSAssertFail(const char *message) {
|
||||
if (gAssertFailFunc) {
|
||||
(*gAssertFailFunc)(message);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user