From 7e3e890fedfb20e7018fadfa87ed97eef7f2b720 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Sun, 13 Jul 2014 15:03:24 +0200 Subject: Added get filter, unified index properties --- src/context.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- src/template.cpp | 24 ++++++++++++++++++++ 2 files changed, 90 insertions(+), 2 deletions(-) diff --git a/src/context.cpp b/src/context.cpp index cd44e1b..f03f6f8 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -658,6 +658,11 @@ class TranslateContext::Private : public PropertyMapper static bool extractAll = Config_getBool("EXTRACT_ALL"); return theTranslator->trFileMembersDescription(extractAll); } + TemplateVariant namespaceMembersDescription() const + { + static bool extractAll = Config_getBool("EXTRACT_ALL"); + return theTranslator->trNamespaceMemberDescription(extractAll); + } TemplateVariant relatedPagesDesc() const { return theTranslator->trRelatedPagesDescription(); @@ -980,6 +985,8 @@ class TranslateContext::Private : public PropertyMapper addProperty("related", this,&Private::related); //%% string macros addProperty("macros", this,&Private::macros); + //%% string namespaceMembersDescription + addProperty("namespaceMembersDescription",this,&Private::namespaceMembersDescription); m_javaOpt = Config_getBool("OPTIMIZE_OUTPUT_JAVA"); m_fortranOpt = Config_getBool("OPTIMIZE_FOR_FORTRAN"); @@ -3131,6 +3138,7 @@ class MemberContext::Private : public DefinitionContext addProperty("eventAttrs", this,&Private::eventAttrs); addProperty("class", this,&Private::getClass); addProperty("file", this,&Private::getFile); + addProperty("namespace", this,&Private::getNamespace); addProperty("definition", this,&Private::definition); addProperty("parameters", this,&Private::parameters); addProperty("hasParameterList", this,&Private::hasParameterList); @@ -3610,6 +3618,21 @@ class MemberContext::Private : public DefinitionContext return TemplateVariant(FALSE); } } + TemplateVariant getNamespace() const + { + if (!m_cache.namespaceDef && m_memberDef->getNamespaceDef()) + { + m_cache.namespaceDef.reset(NamespaceContext::alloc(m_memberDef->getNamespaceDef())); + } + if (m_cache.namespaceDef) + { + return m_cache.namespaceDef.get(); + } + else + { + return TemplateVariant(FALSE); + } + } TemplateVariant definition() const { return createLinkedText(m_memberDef,relPathAsString(), @@ -4041,6 +4064,7 @@ class MemberContext::Private : public DefinitionContext SharedPtr arguments; SharedPtr enumValues; SharedPtr fileDef; + SharedPtr namespaceDef; SharedPtr classDef; SharedPtr anonymousType; SharedPtr templateDecls; @@ -6519,6 +6543,9 @@ class GlobalsIndexContext::Private : public PropertyMapper addProperty("enums", this,&Private::enums); addProperty("enumValues", this,&Private::enumValues); addProperty("macros", this,&Private::macros); + addProperty("properties", this,&Private::properties); + addProperty("events", this,&Private::events); + addProperty("related", this,&Private::related); addProperty("fileName", this,&Private::fileName); addProperty("relPath", this,&Private::relPath); addProperty("highlight", this,&Private::highlight); @@ -6582,6 +6609,18 @@ class GlobalsIndexContext::Private : public PropertyMapper { return getMembersFiltered(m_cache.macros,&MemberDef::isDefine); } + TemplateVariant properties() const + { + return FALSE; + } + TemplateVariant events() const + { + return FALSE; + } + TemplateVariant related() const + { + return FALSE; + } TemplateVariant fileName() const { return "globals"; @@ -6647,7 +6686,8 @@ class ClassMembersIndexContext::Private : public PropertyMapper addProperty("variables", this,&Private::variables); addProperty("typedefs", this,&Private::typedefs); addProperty("enums", this,&Private::enums); - addProperty("enumvalues", this,&Private::enumvalues); + addProperty("enumValues", this,&Private::enumValues); + addProperty("macros", this,&Private::macros); addProperty("properties", this,&Private::properties); addProperty("events", this,&Private::events); addProperty("related", this,&Private::related); @@ -6706,10 +6746,14 @@ class ClassMembersIndexContext::Private : public PropertyMapper { return getMembersFiltered(m_cache.enums,&MemberDef::isEnumerate); } - TemplateVariant enumvalues() const + TemplateVariant enumValues() const { return getMembersFiltered(m_cache.enumValues,&MemberDef::isEnumValue); } + TemplateVariant macros() const + { + return FALSE; + } TemplateVariant properties() const { return getMembersFiltered(m_cache.properties,&MemberDef::isProperty); @@ -6790,6 +6834,10 @@ class NamespaceMembersIndexContext::Private : public PropertyMapper addProperty("typedefs", this,&Private::typedefs); addProperty("enums", this,&Private::enums); addProperty("enumValues", this,&Private::enumValues); + addProperty("macros", this,&Private::macros); + addProperty("properties", this,&Private::properties); + addProperty("events", this,&Private::events); + addProperty("related", this,&Private::related); addProperty("fileName", this,&Private::fileName); addProperty("relPath", this,&Private::relPath); addProperty("highlight", this,&Private::highlight); @@ -6849,6 +6897,22 @@ class NamespaceMembersIndexContext::Private : public PropertyMapper { return getMembersFiltered(m_cache.enumValues,&MemberDef::isEnumValue); } + TemplateVariant macros() const + { + return FALSE; + } + TemplateVariant properties() const + { + return FALSE; + } + TemplateVariant events() const + { + return FALSE; + } + TemplateVariant related() const + { + return FALSE; + } TemplateVariant fileName() const { return "namespacemembers"; diff --git a/src/template.cpp b/src/template.cpp index 9070b98..2f9f69c 100644 --- a/src/template.cpp +++ b/src/template.cpp @@ -770,6 +770,29 @@ class FilterAdd //----------------------------------------------------------------------------- +/** @brief The implementation of the "get" filter */ +class FilterGet +{ + public: + static TemplateVariant apply(const TemplateVariant &v,const TemplateVariant &arg) + { + if (v.isValid() && v.type()==TemplateVariant::Struct && arg.type()==TemplateVariant::String) + { + TemplateVariant result = v.toStruct()->get(arg.toString()); + //printf("\nok[%s]=%d\n",arg.toString().data(),result.type()); + return result; + } + else + { + //printf("\nnok[%s]\n",arg.toString().data()); + return FALSE; + } + } +}; + + +//----------------------------------------------------------------------------- + /** @brief The implementation of the "append" filter */ class FilterAppend { @@ -1356,6 +1379,7 @@ class TemplateFilterFactory // register a handlers for each filter we support static TemplateFilterFactory::AutoRegister fAdd("add"); +static TemplateFilterFactory::AutoRegister fGet("get"); static TemplateFilterFactory::AutoRegister fAppend("append"); static TemplateFilterFactory::AutoRegister fLength("length"); static TemplateFilterFactory::AutoRegister fNoWrap("nowrap"); -- cgit v0.12