← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~fcavalieri/zorba/accept-pul into lp:zorba

 

Federico Cavalieri has proposed merging lp:~fcavalieri/zorba/accept-pul into lp:zorba.

Requested reviews:
  Markos Zaharioudakis (markos-za)

For more details, see:
https://code.launchpad.net/~fcavalieri/zorba/accept-pul/+merge/76613

Introduced accept-pul annotation which allows a function to accept an updating expression as parameter
-- 
https://code.launchpad.net/~fcavalieri/zorba/accept-pul/+merge/76613
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/annotations/annotations.cpp'
--- src/annotations/annotations.cpp	2011-08-11 17:19:25 +0000
+++ src/annotations/annotations.cpp	2011-09-22 16:35:50 +0000
@@ -307,6 +307,9 @@
   GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "streamable");
   aCtx->add_ann(StaticContextConsts::zann_streamable, lTmp);
 
+  GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "accept-pul");
+  aCtx->add_ann(StaticContextConsts::zann_acceptpul, lTmp);
+
   //
   // Zorba annotations - xqddf
   //

=== modified file 'src/compiler/expression/fo_expr.cpp'
--- src/compiler/expression/fo_expr.cpp	2011-07-29 06:13:28 +0000
+++ src/compiler/expression/fo_expr.cpp	2011-09-22 16:35:50 +0000
@@ -228,7 +228,13 @@
 
       expr* arg = theArgs[i].getp();
 
-      if (arg->is_updating())
+      if (arg->is_updating() &&
+    		  !(
+    		  func->getAnnotationList()
+    		  &&
+    		  func->getAnnotationList()->contains(theSctx->lookup_ann(StaticContextConsts::zann_acceptpul))
+    		  )
+      )
       {
         throw XQUERY_EXCEPTION(err::XUST0001,
                                ERROR_PARAMS(ZED(XUST0001_Generic)),

=== modified file 'src/context/static_context_consts.h'
--- src/context/static_context_consts.h	2011-07-21 23:02:27 +0000
+++ src/context/static_context_consts.h	2011-09-22 16:35:50 +0000
@@ -146,6 +146,7 @@
     zann_const,
     zann_ordered,
     zann_unordered,
+    zann_acceptpul,
     zann_read_only_nodes,
     zann_mutable_nodes,
 

=== added file 'test/rbkt/ExpQueryResults/zorba/annotations/annot-acceptpul.xml.res'
--- test/rbkt/ExpQueryResults/zorba/annotations/annot-acceptpul.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/annotations/annot-acceptpul.xml.res	2011-09-22 16:35:50 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+passed passed
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/annotations/annot-acceptpul.xq'
--- test/rbkt/Queries/zorba/annotations/annot-acceptpul.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/annotations/annot-acceptpul.xq	2011-09-22 16:35:50 +0000
@@ -0,0 +1,15 @@
+declare namespace ann = "http://www.zorba-xquery.com/annotations";;
+
+declare updating function local:upd()
+{
+ let $node as element():= <a><b/></a>
+ return rename node $node/b as "new-name"
+};
+
+declare %ann:accept-pul function local:works($pul as item()*)
+{
+  "passed"
+};
+
+local:works(local:upd()),
+local:works(let $node as element():= <a><b/></a> return rename node $node/b as "new-name")


Follow ups