zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #05075
[Merge] lp:~zorba-coders/zorba/ft-sctx-get-functions into lp:zorba
Matthias Brantner has proposed merging lp:~zorba-coders/zorba/ft-sctx-get-functions into lp:zorba.
Requested reviews:
Matthias Brantner (matthias-brantner)
Till Westmann (tillw)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/ft-sctx-get-functions/+merge/93672
added two api functions to introspect the functions of a static context
--
https://code.launchpad.net/~zorba-coders/zorba/ft-sctx-get-functions/+merge/93672
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog 2012-02-16 14:11:02 +0000
+++ ChangeLog 2012-02-18 00:40:27 +0000
@@ -37,6 +37,7 @@
* Fixed bug #867022 (added location and params to some XPTY0004 errors)
* zerr is not predeclared anymore to be http://www.zorba-xquery.com/errors
* Add new XQuery interface for the PHP bindings.
+ * Added two API methods StaticContext::getFunctions to introspect the functions of a static context
* Added API method Item::getNamespaceBindings().
* Added a transcoding streambuffer to the API which allows transcoding arbitrary encodings
from and to UTF-8
=== modified file 'include/zorba/static_context.h'
--- include/zorba/static_context.h 2012-02-02 09:56:52 +0000
+++ include/zorba/static_context.h 2012-02-18 00:40:27 +0000
@@ -412,6 +412,27 @@
virtual void
getFunctionAnnotations(const Item& aQName, int arity, std::vector<Annotation_t>& aAnnotations) const = 0;
+ /** \brief Get all functions declared in the given static context
+ *
+ * @return aFunctions all of the said functions
+ */
+ virtual void
+ getFunctions(std::vector<Function_t>& aFunctions) const = 0;
+
+ /** \brief Get all functions with a specified namespace and airty\
+ * declared in the given static context.
+ *
+ * @param aFnNameUri the namespace for the functions to return
+ * @param arity the arity for the functions to return
+ *
+ * @return aFunctions all of the said functions
+ */
+ virtual void
+ getFunctions(
+ const String& aFnNameUri,
+ uint32_t arity,
+ std::vector<Function_t>& aFunctions) const = 0;
+
/** \brief Set the type of the context item.
*/
virtual void
=== modified file 'src/api/staticcontextimpl.cpp'
--- src/api/staticcontextimpl.cpp 2012-02-02 09:56:52 +0000
+++ src/api/staticcontextimpl.cpp 2012-02-18 00:40:27 +0000
@@ -849,6 +849,59 @@
void
+StaticContextImpl::getFunctions(std::vector<Function_t>& aFunctions) const
+{
+ try
+ {
+ std::vector<function*> lInternalFunctions;
+
+ theCtx->get_functions(lInternalFunctions);
+
+ for (std::vector<function*>::const_iterator lIter = lInternalFunctions.begin();
+ lIter != lInternalFunctions.end(); ++lIter)
+ {
+ Function_t lFunc(new FunctionImpl(*lIter, theDiagnosticHandler));
+ aFunctions.push_back(lFunc);
+ }
+ }
+ catch (ZorbaException const& e)
+ {
+ ZorbaImpl::notifyError(theDiagnosticHandler, e);
+ }
+}
+
+
+void
+StaticContextImpl::getFunctions(
+ const String& aFnNameUri,
+ uint32_t arity,
+ std::vector<Function_t>& aFunctions) const
+{
+ try
+ {
+ std::vector<function*> lInternalFunctions;
+
+ theCtx->get_functions(lInternalFunctions);
+
+ for (std::vector<function*>::const_iterator lIter = lInternalFunctions.begin();
+ lIter != lInternalFunctions.end(); ++lIter)
+ {
+ const zstring& lNamespace = (*lIter)->getName()->getNamespace();
+ if (lNamespace == aFnNameUri.c_str() && (*lIter)->getArity() == arity)
+ {
+ Function_t lFunc(new FunctionImpl(*lIter, theDiagnosticHandler));
+ aFunctions.push_back(lFunc);
+ }
+ }
+ }
+ catch (ZorbaException const& e)
+ {
+ ZorbaImpl::notifyError(theDiagnosticHandler, e);
+ }
+}
+
+
+void
StaticContextImpl::getFunctionAnnotations(
const Item& aQName,
int arity,
=== modified file 'src/api/staticcontextimpl.h'
--- src/api/staticcontextimpl.h 2012-02-02 09:56:52 +0000
+++ src/api/staticcontextimpl.h 2012-02-18 00:40:27 +0000
@@ -192,6 +192,15 @@
getFunctionAnnotations(const Item& aQName, int arity, std::vector<Annotation_t>& aAnnotations) const;
virtual void
+ getFunctions(std::vector<Function_t>& aFunctions) const;
+
+ virtual void
+ getFunctions(
+ const String& aFnNameUri,
+ uint32_t arity,
+ std::vector<Function_t>& aFunctions) const;
+
+ virtual void
setContextItemStaticType(TypeIdentifier_t type);
virtual TypeIdentifier_t
Follow ups
-
[Merge] lp:~zorba-coders/zorba/ft-sctx-get-functions into lp:zorba
From: noreply, 2012-02-18
-
[Merge] lp:~zorba-coders/zorba/ft-sctx-get-functions into lp:zorba
From: Zorba Build Bot, 2012-02-18
-
[Merge] lp:~zorba-coders/zorba/ft-sctx-get-functions into lp:zorba
From: Zorba Build Bot, 2012-02-18
-
[Merge] lp:~zorba-coders/zorba/ft-sctx-get-functions into lp:zorba
From: Till Westmann, 2012-02-18
-
Re: [Merge] lp:~zorba-coders/zorba/ft-sctx-get-functions into lp:zorba
From: Till Westmann, 2012-02-18
-
[Merge] lp:~zorba-coders/zorba/ft-sctx-get-functions into lp:zorba
From: Zorba Build Bot, 2012-02-18
-
Re: [Merge] lp:~zorba-coders/zorba/ft-sctx-get-functions into lp:zorba
From: Zorba Build Bot, 2012-02-18
-
[Merge] lp:~zorba-coders/zorba/ft-sctx-get-functions into lp:zorba
From: Zorba Build Bot, 2012-02-18
-
[Merge] lp:~zorba-coders/zorba/ft-sctx-get-functions into lp:zorba
From: Zorba Build Bot, 2012-02-18
-
[Merge] lp:~zorba-coders/zorba/ft-sctx-get-functions into lp:zorba
From: Matthias Brantner, 2012-02-18
-
Re: [Merge] lp:~zorba-coders/zorba/ft-sctx-get-functions into lp:zorba
From: Matthias Brantner, 2012-02-18