Merge lp:~zorba-coders/zorba/ft-sctx-get-functions into lp:zorba

Proposed by Matthias Brantner
Status: Merged
Approved by: Till Westmann
Approved revision: 10667
Merged at revision: 10667
Proposed branch: lp:~zorba-coders/zorba/ft-sctx-get-functions
Merge into: lp:zorba
Diff against target: 127 lines (+84/-0)
4 files modified
ChangeLog (+1/-0)
include/zorba/static_context.h (+21/-0)
src/api/staticcontextimpl.cpp (+53/-0)
src/api/staticcontextimpl.h (+9/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/ft-sctx-get-functions
Reviewer Review Type Date Requested Status
Till Westmann Approve
Matthias Brantner Approve
Review via email: mp+93672@code.launchpad.net

Commit message

added two api functions to introspect the functions of a static context

Description of the change

added two api functions to introspect the functions of a static context

To post a comment you must log in.
Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job ft-sctx-get-functions-2012-02-18T00-42-01.751Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1. Got: 1 Approve, 1 Pending.

Revision history for this message
Till Westmann (tillw) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job ft-sctx-get-functions-2012-02-18T01-56-00.472Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2012-02-16 14:11:02 +0000
3+++ ChangeLog 2012-02-18 00:40:27 +0000
4@@ -37,6 +37,7 @@
5 * Fixed bug #867022 (added location and params to some XPTY0004 errors)
6 * zerr is not predeclared anymore to be http://www.zorba-xquery.com/errors
7 * Add new XQuery interface for the PHP bindings.
8+ * Added two API methods StaticContext::getFunctions to introspect the functions of a static context
9 * Added API method Item::getNamespaceBindings().
10 * Added a transcoding streambuffer to the API which allows transcoding arbitrary encodings
11 from and to UTF-8
12
13=== modified file 'include/zorba/static_context.h'
14--- include/zorba/static_context.h 2012-02-02 09:56:52 +0000
15+++ include/zorba/static_context.h 2012-02-18 00:40:27 +0000
16@@ -412,6 +412,27 @@
17 virtual void
18 getFunctionAnnotations(const Item& aQName, int arity, std::vector<Annotation_t>& aAnnotations) const = 0;
19
20+ /** \brief Get all functions declared in the given static context
21+ *
22+ * @return aFunctions all of the said functions
23+ */
24+ virtual void
25+ getFunctions(std::vector<Function_t>& aFunctions) const = 0;
26+
27+ /** \brief Get all functions with a specified namespace and airty\
28+ * declared in the given static context.
29+ *
30+ * @param aFnNameUri the namespace for the functions to return
31+ * @param arity the arity for the functions to return
32+ *
33+ * @return aFunctions all of the said functions
34+ */
35+ virtual void
36+ getFunctions(
37+ const String& aFnNameUri,
38+ uint32_t arity,
39+ std::vector<Function_t>& aFunctions) const = 0;
40+
41 /** \brief Set the type of the context item.
42 */
43 virtual void
44
45=== modified file 'src/api/staticcontextimpl.cpp'
46--- src/api/staticcontextimpl.cpp 2012-02-02 09:56:52 +0000
47+++ src/api/staticcontextimpl.cpp 2012-02-18 00:40:27 +0000
48@@ -849,6 +849,59 @@
49
50
51 void
52+StaticContextImpl::getFunctions(std::vector<Function_t>& aFunctions) const
53+{
54+ try
55+ {
56+ std::vector<function*> lInternalFunctions;
57+
58+ theCtx->get_functions(lInternalFunctions);
59+
60+ for (std::vector<function*>::const_iterator lIter = lInternalFunctions.begin();
61+ lIter != lInternalFunctions.end(); ++lIter)
62+ {
63+ Function_t lFunc(new FunctionImpl(*lIter, theDiagnosticHandler));
64+ aFunctions.push_back(lFunc);
65+ }
66+ }
67+ catch (ZorbaException const& e)
68+ {
69+ ZorbaImpl::notifyError(theDiagnosticHandler, e);
70+ }
71+}
72+
73+
74+void
75+StaticContextImpl::getFunctions(
76+ const String& aFnNameUri,
77+ uint32_t arity,
78+ std::vector<Function_t>& aFunctions) const
79+{
80+ try
81+ {
82+ std::vector<function*> lInternalFunctions;
83+
84+ theCtx->get_functions(lInternalFunctions);
85+
86+ for (std::vector<function*>::const_iterator lIter = lInternalFunctions.begin();
87+ lIter != lInternalFunctions.end(); ++lIter)
88+ {
89+ const zstring& lNamespace = (*lIter)->getName()->getNamespace();
90+ if (lNamespace == aFnNameUri.c_str() && (*lIter)->getArity() == arity)
91+ {
92+ Function_t lFunc(new FunctionImpl(*lIter, theDiagnosticHandler));
93+ aFunctions.push_back(lFunc);
94+ }
95+ }
96+ }
97+ catch (ZorbaException const& e)
98+ {
99+ ZorbaImpl::notifyError(theDiagnosticHandler, e);
100+ }
101+}
102+
103+
104+void
105 StaticContextImpl::getFunctionAnnotations(
106 const Item& aQName,
107 int arity,
108
109=== modified file 'src/api/staticcontextimpl.h'
110--- src/api/staticcontextimpl.h 2012-02-02 09:56:52 +0000
111+++ src/api/staticcontextimpl.h 2012-02-18 00:40:27 +0000
112@@ -192,6 +192,15 @@
113 getFunctionAnnotations(const Item& aQName, int arity, std::vector<Annotation_t>& aAnnotations) const;
114
115 virtual void
116+ getFunctions(std::vector<Function_t>& aFunctions) const;
117+
118+ virtual void
119+ getFunctions(
120+ const String& aFnNameUri,
121+ uint32_t arity,
122+ std::vector<Function_t>& aFunctions) const;
123+
124+ virtual void
125 setContextItemStaticType(TypeIdentifier_t type);
126
127 virtual TypeIdentifier_t

Subscribers

People subscribed via source and target branches