Merge lp:~zorba-coders/zorba/bug-948879 into lp:zorba

Proposed by Matthias Brantner
Status: Superseded
Proposed branch: lp:~zorba-coders/zorba/bug-948879
Merge into: lp:zorba
Diff against target: 188 lines (+110/-0)
6 files modified
ChangeLog (+1/-0)
include/zorba/static_context.h (+32/-0)
include/zorba/xmldatamanager.h (+2/-0)
src/api/staticcontextimpl.cpp (+46/-0)
src/api/staticcontextimpl.h (+6/-0)
test/unit/static_context.cpp (+23/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug-948879
Reviewer Review Type Date Requested Status
Chris Hillery Needs Fixing
Matthias Brantner Approve
Review via email: mp+101708@code.launchpad.net

This proposal has been superseded by a proposal from 2012-04-13.

Commit message

fix for bug #948879 (--uri-path doesn't work with fetch:content())

Description of the change

fix for bug #948879 (--uri-path doesn't work with fetch:content())

Deprecated the C++ API's XmlDataManager::fetch function and replaced it with two StaticContext::fetch functions.

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 bug-948879-2012-04-12T10-16-01.483Z 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, Needs Fixing < 1, Pending < 1. Got: 1 Approve, 1 Pending.

Revision history for this message
Chris Hillery (ceejatec) wrote :

To maintain ABI compatibility, new virtual functions in the public API need to be added at the end of the class definition. At least, that is what I've been led to believe. Not sure if we're caring about ABI compat yet, but we might as well get into the habit.

review: Needs Fixing
lp:~zorba-coders/zorba/bug-948879 updated
10755. By Matthias Brantner

fixed review comments and moved new functions to the end of the class for maintaining abi compatibility

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ChangeLog'
--- ChangeLog 2012-04-12 09:32:55 +0000
+++ ChangeLog 2012-04-13 09:14:20 +0000
@@ -11,6 +11,7 @@
11 * Fixed bug 955170 (Catch clause with URILiteral-based wilcard NameTest)11 * Fixed bug 955170 (Catch clause with URILiteral-based wilcard NameTest)
12 * Fixed bug 955135 (err:XQDY0044 not caught by try-catch expressions)12 * Fixed bug 955135 (err:XQDY0044 not caught by try-catch expressions)
13 * Fixed bug #967864 (var substitution did not update theFreeVars property)13 * Fixed bug #967864 (var substitution did not update theFreeVars property)
14 * Fixed bug #948879 (--uri-path doesn't work with fetch:content())
14 * Fixed bug in window iterator (binding the end vars in the output tuple stream)15 * Fixed bug in window iterator (binding the end vars in the output tuple stream)
15 * Fixed bug #866547 (protect index-join rule from general flwor)16 * Fixed bug #866547 (protect index-join rule from general flwor)
16 * Fixed bug #967428 (do not hoist index creation outside a try-catch)17 * Fixed bug #967428 (do not hoist index creation outside a try-catch)
1718
=== modified file 'include/zorba/static_context.h'
--- include/zorba/static_context.h 2012-03-28 05:19:57 +0000
+++ include/zorba/static_context.h 2012-04-13 09:14:20 +0000
@@ -685,6 +685,38 @@
685 */685 */
686 virtual void686 virtual void
687 getFullLibPath(std::vector<String>& aLibPath) const = 0;687 getFullLibPath(std::vector<String>& aLibPath) const = 0;
688
689 /** \brief Fetches an resource refered to by the given URI.
690 *
691 * Resolution is done using the URI mappers and resolvers registered
692 * in this static context. If no such mappers or resolvers have been
693 * registered, the built-in ones are used.
694 *
695 * The default EntityKind for resources fetched by this function
696 * is "SOME_CONTENT".
697 *
698 * @param aURI the name of the resource to fetch
699 *
700 * @return the fetched resource
701 */
702 virtual Item
703 fetch(const String& aURI) const = 0;
704
705 /** \brief Fetches an resource refered to by the given URI.
706 *
707 * Resolution is done using the URI mappers and resolvers registered
708 * in this static context. If no such mappers or resolvers have been
709 * registered, the built-in ones are used.
710 *
711 * @param aURI the name of the resource to fetch
712 *
713 * @param aEntityKind the kind of the entity to fetch (i.e.
714 * SOME_CONTENT, SCHEMA, MODULE, THESAURUS, or STOP_WORDS)
715 *
716 * @return the fetched resource
717 */
718 virtual Item
719 fetch(const String& aURI, const String& aEntityKind) const = 0;
688};720};
689721
690} /* namespace zorba */722} /* namespace zorba */
691723
=== modified file 'include/zorba/xmldatamanager.h'
--- include/zorba/xmldatamanager.h 2012-03-28 05:19:57 +0000
+++ include/zorba/xmldatamanager.h 2012-04-13 09:14:20 +0000
@@ -187,6 +187,8 @@
187 ParseOptions& aOptions) const = 0;187 ParseOptions& aOptions) const = 0;
188188
189 /** \brief Fetches an resource refered to by the given URI.189 /** \brief Fetches an resource refered to by the given URI.
190 *
191 * @deprecated this function has been replaced by StaticContext::fetch.
190 */192 */
191 virtual Item193 virtual Item
192 fetch(const String& aURI) const = 0;194 fetch(const String& aURI) const = 0;
193195
=== modified file 'src/api/staticcontextimpl.cpp'
--- src/api/staticcontextimpl.cpp 2012-03-28 05:19:57 +0000
+++ src/api/staticcontextimpl.cpp 2012-04-13 09:14:20 +0000
@@ -25,6 +25,7 @@
25#include <zorba/typeident.h>25#include <zorba/typeident.h>
26#include <zorba/util/path.h>26#include <zorba/util/path.h>
27#include <zorba/empty_sequence.h>27#include <zorba/empty_sequence.h>
28#include <zorba/singleton_item_sequence.h>
2829
29#include "store/api/item_factory.h"30#include "store/api/item_factory.h"
30#include "store/api/temp_seq.h"31#include "store/api/temp_seq.h"
@@ -1539,5 +1540,50 @@
1539 ZORBA_CATCH1540 ZORBA_CATCH
1540}1541}
15411542
1543Item
1544StaticContextImpl::fetch(const String& aURI) const
1545{
1546 return fetch(aURI, "SOME_CONTENT");
1547}
1548
1549Item
1550StaticContextImpl::fetch(
1551 const String& aURI,
1552 const String& aEntityKind) const
1553{
1554 ZORBA_TRY
1555 {
1556 Zorba* lZorba = Zorba::getInstance(0);
1557 ItemFactory* lFactory = lZorba->getItemFactory();
1558
1559 Item lQName = lFactory->createQName(static_context::ZORBA_FETCH_FN_NS,
1560 "content");
1561
1562 // create a streamable string item
1563 std::vector<ItemSequence_t> lArgs;
1564 lArgs.push_back(new SingletonItemSequence(lFactory->createString(aURI)));
1565 lArgs.push_back(
1566 new SingletonItemSequence(lFactory->createString(aEntityKind)));
1567
1568 StaticContext_t lCtx = createChildContext();
1569
1570 Zorba_CompilerHints_t lHints;
1571 std::ostringstream lProlog;
1572 lProlog
1573 << "import module namespace d = '" << static_context::ZORBA_FETCH_FN_NS << "';";
1574
1575 lCtx->loadProlog(lProlog.str(), lHints);
1576
1577 ItemSequence_t lSeq = lCtx->invoke(lQName, lArgs);
1578 Iterator_t lIter = lSeq->getIterator();
1579 lIter->open();
1580 Item lRes;
1581 lIter->next(lRes);
1582 return lRes;
1583 }
1584 ZORBA_CATCH
1585 return 0;
1586}
1587
1542} /* namespace zorba */1588} /* namespace zorba */
1543/* vim:set et sw=2 ts=2: */1589/* vim:set et sw=2 ts=2: */
15441590
=== modified file 'src/api/staticcontextimpl.h'
--- src/api/staticcontextimpl.h 2012-03-28 05:19:57 +0000
+++ src/api/staticcontextimpl.h 2012-04-13 09:14:20 +0000
@@ -281,6 +281,12 @@
281 virtual void281 virtual void
282 getFullLibPath(std::vector<String>& aLibPath) const;282 getFullLibPath(std::vector<String>& aLibPath) const;
283283
284 virtual Item
285 fetch(const String& aURI) const;
286
287 virtual Item
288 fetch(const String& aURI, const String& aEntityKind) const;
289
284protected:290protected:
285 String291 String
286 createInvokeQuery(const Function_t&, size_t aArity) const;292 createInvokeQuery(const Function_t&, size_t aArity) const;
287293
=== modified file 'test/unit/static_context.cpp'
--- test/unit/static_context.cpp 2012-01-17 19:07:24 +0000
+++ test/unit/static_context.cpp 2012-04-13 09:14:20 +0000
@@ -60,6 +60,26 @@
60 return lFooFound && lBindings.size() == 6;60 return lFooFound && lBindings.size() == 6;
61}61}
6262
63bool
64sctx_test_2(Zorba* const zorba)
65{
66 StaticContext_t lSctx = zorba->createStaticContext();
67
68 Zorba_CompilerHints_t lHints;
69
70 try
71 {
72 Item lFetched = lSctx->fetch("http://www.zorba-xquery.com/modules/fetch", "MODULE");
73
74 return !lFetched.isNull();
75 }
76 catch (ZorbaException& e)
77 {
78 std::cerr << e << std::endl;
79 }
80 return false;
81}
82
63int static_context( int argc, char *argv[] ) {83int static_context( int argc, char *argv[] ) {
64 void *const zstore = StoreManager::getStore();84 void *const zstore = StoreManager::getStore();
65 Zorba *const zorba = Zorba::getInstance( zstore );85 Zorba *const zorba = Zorba::getInstance( zstore );
@@ -67,6 +87,9 @@
67 if (!sctx_test_1(zorba))87 if (!sctx_test_1(zorba))
68 return 1;88 return 1;
6989
90 if (!sctx_test_2(zorba))
91 return 2;
92
70 zorba->shutdown();93 zorba->shutdown();
71 StoreManager::shutdownStore( zstore );94 StoreManager::shutdownStore( zstore );
72 return 0;95 return 0;

Subscribers

People subscribed via source and target branches