diff options
Diffstat (limited to 'src/core/parser')
-rw-r--r-- | src/core/parser/stack/DocumentHandler.cpp | 23 | ||||
-rw-r--r-- | src/core/parser/stack/DocumentHandler.hpp | 5 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/core/parser/stack/DocumentHandler.cpp b/src/core/parser/stack/DocumentHandler.cpp index 331fb0b..7a81186 100644 --- a/src/core/parser/stack/DocumentHandler.cpp +++ b/src/core/parser/stack/DocumentHandler.cpp @@ -52,6 +52,29 @@ bool DocumentHandler::startCommand(Variant::mapType &args) void DocumentHandler::end() { scope().pop(logger()); } +/* DocumentField */ + +Rooted<FieldDescriptor> DocumentField::getDescriptor() +{ + // Fetch the FieldDescriptor from the parent node. The parent node should + // either be a structured entity or an annotation entity + Rooted<Managed> parent = getParent(); + if (parent->isa(&RttiTypes::StructuredEntity)) { + return parent.cast<StructuredEntity>() + ->getDescriptor() + ->getFieldDescriptor(fieldIdx); + } else if (parent->isa(&RttiTypes::AnnotationEntity)) { + return parent.cast<AnnotationEntity>() + ->getDescriptor() + ->getFieldDescriptor(fieldIdx); + } + + // Well, we never should get here + // TODO: Introduce macro for unreachable code? + assert(!"This should never be reached"); + return nullptr; +} + /* DocumentChildHandler */ DocumentChildHandler::DocumentChildHandler(const HandlerData &handlerData) diff --git a/src/core/parser/stack/DocumentHandler.hpp b/src/core/parser/stack/DocumentHandler.hpp index 47534fb..5157709 100644 --- a/src/core/parser/stack/DocumentHandler.hpp +++ b/src/core/parser/stack/DocumentHandler.hpp @@ -84,6 +84,11 @@ public: : Node(mgr, parent), fieldIdx(fieldIdx), transparent(transparent) { } + + /** + * Returns the FieldDescriptor represented by this DocumentField instance. + */ + Rooted<FieldDescriptor> getDescriptor(); }; /** |