[poincare] Function LayoutFromAddress

Created function Layout::LayoutFromAddress, which creates in the pool a layout
that has been stored in a buffer. Functionally identical to
Expression::ExpressionFromAddress.

Change-Id: I204e6b7d42f259ef2732563aa2a168a644060867
This commit is contained in:
Gabriel Ozouf
2020-06-11 11:16:01 +02:00
committed by Émilie Feral
parent 0927ffca29
commit 9527894b25
2 changed files with 8 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ public:
assert(isUninitialized() || !TreeHandle::node()->isGhost());
return static_cast<LayoutNode *>(TreeHandle::node());
}
static Layout LayoutFromAddress(const void * address, size_t size);
// Properties
LayoutNode::Type type() const { return node()->type(); }

View File

@@ -18,6 +18,13 @@ Layout Layout::clone() const {
return cast;
}
Layout Layout::LayoutFromAddress(const void * address, size_t size) {
if (address == nullptr || size == 0) {
return Layout();
}
return Layout(static_cast<LayoutNode *>(TreePool::sharedPool()->copyTreeFromAddress(address, size)));
}
int Layout::serializeParsedExpression(char * buffer, int bufferSize, Context * context) const {
/* This method fixes the following problem:
* Some layouts have a special serialization so they can be parsed afterwards,