Matthias Brantner has proposed merging 
lp:~zorba-coders/zorba/feature-setvar-typed into lp:zorba.

Requested reviews:
  Matthias Brantner (matthias-brantner)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/feature-setvar-typed/+merge/217313
-- 
https://code.launchpad.net/~zorba-coders/zorba/feature-setvar-typed/+merge/217313
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'bin/zorbacmd.cpp'
--- bin/zorbacmd.cpp	2014-02-20 00:58:25 +0000
+++ bin/zorbacmd.cpp	2014-04-25 23:04:09 +0000
@@ -250,7 +250,7 @@
         dctx->setVariable( i->var_name, doc );
       } else {
         Item item( zorba->getItemFactory()->createString( i->var_value ) );
-        dctx->setVariable( i->var_name, item );
+        dctx->setVariable( i->var_name, item, true );
       }
     }
     catch ( ... ) {

=== modified file 'include/zorba/dynamic_context.h'
--- include/zorba/dynamic_context.h	2013-08-14 08:46:44 +0000
+++ include/zorba/dynamic_context.h	2014-04-25 23:04:09 +0000
@@ -65,7 +65,8 @@
   virtual bool
   setVariable(
       const String& aQName,
-      const Item& aItem) = 0;
+      const Item& aItem,
+      bool cast = false) = 0;
 
   /** 
    * \brief Defines the external variable identified by an expanded QName and

=== modified file 'src/api/dynamiccontextimpl.cpp'
--- src/api/dynamiccontextimpl.cpp	2013-09-16 09:08:27 +0000
+++ src/api/dynamiccontextimpl.cpp	2014-04-25 23:04:09 +0000
@@ -36,6 +36,7 @@
 #include "api/item_iter_store.h"
 #include "api/dynamiccontextimpl.h"
 
+#include "compiler/expression/var_expr.h"
 #include "compiler/parser/query_loc.h"
 #include "compiler/parsetree/parsenodes.h"
 #include "compiler/api/compilercb.h"
@@ -46,6 +47,7 @@
 #include "store/api/store.h"
 #include "store/api/item_factory.h"
 #include "store/api/temp_seq.h"
+#include "types/casting.h"
 
 #include "util/xml_util.h"
 
@@ -380,7 +382,8 @@
 ********************************************************************************/
 bool DynamicContextImpl::setVariable(
     const String& inVarName,
-    const Item& inValue)
+    const Item& inValue,
+    bool cast)
 {
   ZORBA_DCTX_TRY
   {
@@ -410,6 +413,15 @@
       throw;
     }
 
+    if ( cast ) {
+      store::Item_t temp;
+      GenericCast::castToAtomic(
+        temp, value, var->getType(), var->getVar()->get_type_manager(),
+        /*nsCtx*/ nullptr, QueryLoc::null
+      );
+      value = temp;
+    }
+
     ulong varId = var->getId();
 
     theCtx->add_variable(varId, value);

=== modified file 'src/api/dynamiccontextimpl.h'
--- src/api/dynamiccontextimpl.h	2013-08-01 07:57:57 +0000
+++ src/api/dynamiccontextimpl.h	2014-04-25 23:04:09 +0000
@@ -96,7 +96,8 @@
   virtual bool
   setVariable(
       const String& inVarName,
-      const Item& inValue);
+      const Item& inValue,
+      bool cast = false);
 
   virtual bool
   setVariable(

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to