zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #14352
[Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
Rodolfo Ochoa has proposed merging lp:~zorba-coders/zorba/bug923686 into lp:zorba.
Requested reviews:
Markos Zaharioudakis (markos-za)
Related bugs:
Bug #923686 in Zorba: "If context item is set, context position and context size need to be set"
https://bugs.launchpad.net/zorba/+bug/923686
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug923686/+merge/124531
Fixes so context position and context size can be set.
--
https://code.launchpad.net/~zorba-coders/zorba/bug923686/+merge/124531
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'include/zorba/dynamic_context.h'
--- include/zorba/dynamic_context.h 2012-09-11 22:55:05 +0000
+++ include/zorba/dynamic_context.h 2012-09-14 22:13:39 +0000
@@ -280,7 +280,49 @@
/** \brief Destructor
*/
virtual ~DynamicContext( ) {}
+<<<<<<< TREE
+=======
+
+public:
+
+ /** \brief Defines the context item size.
+ *
+ * @param aItem the Item that is used as value for the context item size.
+ * @return true if the context item size was set, false otherwise.
+ * @throw ZorbaException if an error occured (e.g. the given Item is not valid).
+ */
+ virtual bool
+ setContextSize(const Item& aItem) = 0;
+
+ /** \brief Defines the context item position.
+ *
+ * @param aItem the Item that is used as value for the context item position.
+ * @return true if the context item position was set, false otherwise.
+ * @throw ZorbaException if an error occured (e.g. the given Item is not valid).
+ */
+ virtual bool
+ setContextPosition(const Item& aItem) = 0;
+
+ /** \brief Returns the current value of the context item size.
+ *
+ * @param aItem an Item representing the current value of the context item size.
+ * @return true if the variable has been retrieved successfully, false otherwise.
+ * @throw ZorbaException if an error occured.
+ */
+ virtual bool
+ getContextSize(Item& aItem) const = 0;
+
+ /** \brief Returns the current value of the context item position.
+ *
+ * @param aItem an Item representing the current value of the context item position.
+ * @return true if the variable has been retrieved successfully, false otherwise.
+ * @throw ZorbaException if an error occured.
+ */
+ virtual bool
+ getContextPosition(Item& aItem) const = 0;
+
+>>>>>>> MERGE-SOURCE
};
} /* namespace zorba */
=== modified file 'src/api/dynamiccontextimpl.cpp'
--- src/api/dynamiccontextimpl.cpp 2012-09-11 22:55:05 +0000
+++ src/api/dynamiccontextimpl.cpp 2012-09-14 22:13:39 +0000
@@ -646,5 +646,59 @@
return false;
}
+/****************************************************************************//**
+
+********************************************************************************/
+bool DynamicContextImpl::setContextSize(const Item& inValue)
+{
+ String varName = Unmarshaller::newString(static_context::DOT_SIZE_VAR_NAME);
+ return setVariable(varName, inValue);
+}
+
+/****************************************************************************//**
+
+********************************************************************************/
+bool DynamicContextImpl::setContextPosition(const Item& inValue)
+{
+ String varName = Unmarshaller::newString(static_context::DOT_POS_VAR_NAME);
+ return setVariable(varName, inValue);
+}
+
+/****************************************************************************//**
+
+********************************************************************************/
+bool DynamicContextImpl::getContextPosition(Item& outValue) const
+{
+ String varName;
+
+ ZORBA_DCTX_TRY
+ {
+ varName = Unmarshaller::newString(static_context::DOT_POS_VAR_NAME);
+ }
+ ZORBA_DCTX_CATCH
+
+ Iterator_t dummy;
+
+ return getVariable("", varName, outValue, dummy);
+}
+
+/****************************************************************************//**
+
+********************************************************************************/
+bool DynamicContextImpl::getContextSize(Item& outValue) const
+{
+ String varName;
+
+ ZORBA_DCTX_TRY
+ {
+ varName = Unmarshaller::newString(static_context::DOT_SIZE_VAR_NAME);
+ }
+ ZORBA_DCTX_CATCH
+
+ Iterator_t dummy;
+
+ return getVariable("", varName, outValue, dummy);
+}
+
} // namespace zorba
/* vim:set et sw=2 ts=2: */
=== modified file 'src/api/dynamiccontextimpl.h'
--- src/api/dynamiccontextimpl.h 2012-09-11 22:55:05 +0000
+++ src/api/dynamiccontextimpl.h 2012-09-14 22:13:39 +0000
@@ -157,6 +157,19 @@
VarInfo* get_var_info(const zstring& varName);
VarInfo* get_var_info(const zstring& varUri, const zstring& varLocalName) const;
+
+public:
+ virtual bool
+ setContextSize(const Item& inValue);
+
+ virtual bool
+ setContextPosition(const Item& inValue);
+
+ virtual bool
+ getContextSize(Item& outValue) const;
+
+ virtual bool
+ getContextPosition(Item& outValue) const;
};
} /* namespace zorba */
=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp 2012-09-14 04:33:18 +0000
+++ src/compiler/translator/translator.cpp 2012-09-14 22:13:39 +0000
@@ -736,7 +736,6 @@
return theRootTranslator->theDotPosVarName;
}
-
const QName* getLastIdxVarName() const
{
return theRootTranslator->theLastIdxVarName;
@@ -2363,7 +2362,17 @@
DOT_VARNAME,
var_expr::prolog_var,
theSctx->get_context_item_type());
+ var_expr_t var2 = bind_var(loc,
+ DOT_POS_VARNAME,
+ var_expr::prolog_var,
+ theRTM.INTEGER_TYPE_ONE);
+ var_expr_t var3 = bind_var(loc,
+ LAST_IDX_VARNAME,
+ var_expr::prolog_var,
+ theRTM.INTEGER_TYPE_ONE);
var->set_unique_id(1);
+ var2->set_unique_id(2);
+ var3->set_unique_id(3);
//GlobalBinding b(var, NULL, true);
//declare_var(b, theModulesInfo->theInitExprs);
=== modified file 'src/precompiled/stdafx.h'
--- src/precompiled/stdafx.h 2012-09-11 22:55:05 +0000
+++ src/precompiled/stdafx.h 2012-09-14 22:13:39 +0000
@@ -24,11 +24,8 @@
#include <memory>
#include <sstream>
- #include <xfwrap>
- #include <xfwrap1>
#include <istream>
#include <cstdio>
- #include <xxshared>
#include <crtdefs.h>
#include <map>
#include <set>
@@ -62,7 +59,6 @@
#include "zorbatypes/rclock.h"
#include "zorbatypes/schema_types.h"
#include "zorbatypes/timezone.h"
- #include "zorbatypes/transcoder.h"
#include "zorbatypes/URI.h"
#include "zorbatypes/xerces_xmlcharray.h"
#include "zorbatypes/zorbatypes_decl.h"
=== modified file 'src/util/json_util.cpp'
--- src/util/json_util.cpp 2012-07-26 04:31:37 +0000
+++ src/util/json_util.cpp 2012-09-14 22:13:39 +0000
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include "stdafx.h"
#include <iomanip>
#include <iostream>
=== modified file 'test/CMakeLists.txt'
--- test/CMakeLists.txt 2012-09-11 22:55:05 +0000
+++ test/CMakeLists.txt 2012-09-14 22:13:39 +0000
@@ -36,6 +36,7 @@
ADD_SUBDIRECTORY(parser)
ADD_SUBDIRECTORY(update)
ADD_SUBDIRECTORY(sax2)
+ADD_SUBDIRECTORY(empty)
SET (TEST_PLAN_SERIALIZER_SRCS
test_plan_serializer.cpp
=== added directory 'test/empty'
=== added file 'test/empty/CMakeLists.txt'
--- test/empty/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ test/empty/CMakeLists.txt 2012-09-14 22:13:39 +0000
@@ -0,0 +1,25 @@
+# Copyright 2006-2008 The FLWOR Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+INCLUDE_DIRECTORIES(AFTER ${CMAKE_SOURCE_DIR}/src/)
+INCLUDE_DIRECTORIES(AFTER ${CMAKE_CURRENT_SOURCE_DIR})
+
+SET(SRCS
+ main.cpp
+)
+
+INCLUDE("${CMAKE_SOURCE_DIR}/cmake_modules/ZorbaGenerateExe.cmake")
+ZORBA_GENERATE_EXE("empty" "${SRCS}" "" "empty" "bin")
+
+
=== added file 'test/empty/main.cpp'
--- test/empty/main.cpp 1970-01-01 00:00:00 +0000
+++ test/empty/main.cpp 2012-09-14 22:13:39 +0000
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <iostream>
+#include <fstream>
+#include <sstream>
+
+#include <zorba/zorba.h>
+#include <zorba/store_manager.h>
+#include <zorba/uri_resolvers.h>
+#include <zorba/xquery_exception.h>
+
+
+using namespace zorba;
+
+/**
+ * Example to show the binding of external variables in the query context.
+ */
+bool example_1(Zorba* aZorba)
+{
+ XQuery_t lQuery = aZorba->compileQuery("declare variable $var external; $var + $var");
+
+ ItemFactory* lFactory = aZorba->getItemFactory();
+
+ /* The item that is to be bound to the external variable */
+ Item lItem = lFactory->createInteger(4);
+
+ DynamicContext* lCtx = lQuery->getDynamicContext();
+
+ /* Actually perform the binding. */
+ lCtx->setVariable("var", lItem);
+
+ try {
+
+ std::cout << lQuery << std::endl;
+
+ } catch (ZorbaException &e) {
+ std::cerr << e << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
+
+int main(int argc, char* argv[])
+{
+ void* lStore = zorba::StoreManager::getStore();
+
+ Zorba* lZorba = Zorba::getInstance(lStore);
+ bool res = false;
+
+ std::cout << "executing example 1" << std::endl;
+ res = example_1(lZorba);
+ if (!res) return 1;
+ std::cout << std::endl;
+
+ lZorba->shutdown();
+ zorba::StoreManager::shutdownStore(lStore);
+ return 0;
+}
=== modified file 'test/rbkt/modules/java/CMakeLists.txt'
--- test/rbkt/modules/java/CMakeLists.txt 2012-09-11 22:55:05 +0000
+++ test/rbkt/modules/java/CMakeLists.txt 2012-09-14 22:13:39 +0000
@@ -31,6 +31,8 @@
GET_PROPERTY (JavaTest2_JAR_FILE TARGET JavaTest2 PROPERTY JAR_FILE)
DECLARE_ZORBA_JAR(FILE ${JavaTest_JAR_FILE} TARGET JavaTest TEST_ONLY)
DECLARE_ZORBA_JAR(FILE ${JavaTest2_JAR_FILE} TARGET JavaTest2 TEST_ONLY)
+ SET_TARGET_PROPERTIES (JavaTest PROPERTIES FOLDER "APIs")
+ SET_TARGET_PROPERTIES (JavaTest2 PROPERTIES FOLDER "APIs")
ENDIF (Java_Development_FOUND)
ENDIF (${RESULT} GREATER -1)
Follow ups
-
[Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: noreply, 2012-09-26
-
[Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Zorba Build Bot, 2012-09-26
-
[Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Zorba Build Bot, 2012-09-26
-
[Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Markos Zaharioudakis, 2012-09-26
-
[Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Zorba Build Bot, 2012-09-26
-
Re: [Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Zorba Build Bot, 2012-09-26
-
[Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Zorba Build Bot, 2012-09-26
-
[Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Markos Zaharioudakis, 2012-09-26
-
Re: [Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Markos Zaharioudakis, 2012-09-26
-
[Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Zorba Build Bot, 2012-09-22
-
Re: [Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Zorba Build Bot, 2012-09-22
-
[Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Zorba Build Bot, 2012-09-22
-
[Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Rodolfo Ochoa, 2012-09-22
-
Re: [Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Markos Zaharioudakis, 2012-09-19
-
[Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Zorba Build Bot, 2012-09-19
-
Re: [Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Zorba Build Bot, 2012-09-19
-
[Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Zorba Build Bot, 2012-09-19
-
[Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Chris Hillery, 2012-09-19
-
Re: [Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Chris Hillery, 2012-09-19
-
[Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Zorba Build Bot, 2012-09-19
-
Re: [Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Zorba Build Bot, 2012-09-19
-
[Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Zorba Build Bot, 2012-09-19
-
[Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Chris Hillery, 2012-09-19
-
[Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Zorba Build Bot, 2012-09-19
-
Re: [Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Zorba Build Bot, 2012-09-19
-
[Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Zorba Build Bot, 2012-09-19
-
[Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Markos Zaharioudakis, 2012-09-19
-
Re: [Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Markos Zaharioudakis, 2012-09-17
-
[Merge] lp:~zorba-coders/zorba/bug923686 into lp:zorba
From: Rodolfo Ochoa, 2012-09-14