From 09d2231fc008aa4b54061394d5192ca9e2ff003a Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Thu, 4 Dec 2014 02:15:22 -0500 Subject: [PATCH 1/6] `f:length' added This is aggressively tested in every instance where it could be affected, since any mishandling of this value would be incredibly dangerous (best case, it would blow up and abort; worst case, data are interchanged between refs). --- src/apply/ref.xsl | 29 ++++++++++++++++++++++++- test/apply/ref.xspec | 51 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/src/apply/ref.xsl b/src/apply/ref.xsl index c1a7be4..32b92ff 100644 --- a/src/apply/ref.xsl +++ b/src/apply/ref.xsl @@ -66,7 +66,7 @@ - + @@ -200,6 +200,9 @@ + + @@ -234,4 +237,28 @@ ($args, f:args( $fnref )) )" /> + + + + + + + + + + diff --git a/test/apply/ref.xspec b/test/apply/ref.xspec index 86d0b2a..cc67ffe 100644 --- a/test/apply/ref.xspec +++ b/test/apply/ref.xspec @@ -68,6 +68,13 @@ + + + @@ -281,6 +288,10 @@ + + @@ -296,6 +307,10 @@ + + @@ -313,6 +328,10 @@ + + @@ -330,6 +349,10 @@ + + @@ -347,6 +370,10 @@ + + @@ -419,6 +446,10 @@ + + @@ -448,6 +479,10 @@ + + @@ -470,6 +505,10 @@ + + @@ -494,6 +533,10 @@ + + @@ -523,6 +566,10 @@ + + @@ -545,6 +592,10 @@ + + From 2760834bfb113340095d3b70453df5d6bc5ef0f6 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Thu, 4 Dec 2014 15:26:33 -0500 Subject: [PATCH 2/6] partial.xspec using `f:make-ref' instead of manual construction --- test/apply/partial.xspec | 60 +++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/test/apply/partial.xspec b/test/apply/partial.xspec index aca7643..605b7ea 100644 --- a/test/apply/partial.xspec +++ b/test/apply/partial.xspec @@ -27,6 +27,11 @@ xmlns:foo="http://www.lovullo.com/_junk" stylesheet="partial-test.xsl"> + + + @@ -89,11 +94,10 @@ test="$x:result[ 1 ] and $x:result[ 1 ] = foo:ternary-applied" /> - + test="$x:result[ 2 ] is $args/foo:a + and $x:result[ 3 ] is $args/foo:b + and $x:result[ 4 ] is $args/foo:c" /> @@ -144,9 +148,9 @@ arguments to a target"> - - - + @@ -160,9 +164,9 @@ - - - + @@ -178,9 +182,9 @@ - - - + @@ -198,9 +202,9 @@ - - - + - - - + - - - + - - - + - - - + - + + + + diff --git a/test/apply/ref.xspec b/test/apply/ref.xspec index cc67ffe..9ab87bd 100644 --- a/test/apply/ref.xspec +++ b/test/apply/ref.xspec @@ -423,6 +423,23 @@ + + + + + + + + + + + From 658edd87170ea9b179c4067e2e593ffb0113264c Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Thu, 4 Dec 2014 03:20:16 -0500 Subject: [PATCH 4/6] `f:set-args' respects and echoes adjacent data by references Was previously clobbered. --- src/apply/ref.xsl | 6 +++++- test/apply/ref.xspec | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/apply/ref.xsl b/src/apply/ref.xsl index 62ea53e..602b39f 100644 --- a/src/apply/ref.xsl +++ b/src/apply/ref.xsl @@ -211,7 +211,11 @@ - + + diff --git a/test/apply/ref.xspec b/test/apply/ref.xspec index 9ab87bd..2c64e54 100644 --- a/test/apply/ref.xspec +++ b/test/apply/ref.xspec @@ -375,6 +375,32 @@ sequence" test="f:length( $x:result ) = count( $x:result )" /> + + + + + + + + + + + + + + + + + + From 4c27b8d15dfcb0aab67c42ff4224a0186f58fd36 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Thu, 4 Dec 2014 03:28:36 -0500 Subject: [PATCH 5/6] Assurances that all other `f:*' functions properly handle adjacent data --- test/apply/ref.xspec | 115 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 112 insertions(+), 3 deletions(-) diff --git a/test/apply/ref.xspec b/test/apply/ref.xspec index 2c64e54..1259c9e 100644 --- a/test/apply/ref.xspec +++ b/test/apply/ref.xspec @@ -109,6 +109,19 @@ + + + + + + + + + @@ -230,14 +243,30 @@ + + + + + + + + + + + - - + + @@ -249,6 +278,20 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -640,5 +716,38 @@ sequence" test="f:length( $x:result ) = count( $x:result )" /> + + + + + + + + + + + + + + + + + + + + From 0b5ed975a0af211bdef11d2a6ec0a54ae972e362 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Thu, 4 Dec 2014 03:33:50 -0500 Subject: [PATCH 6/6] `arity/ref.xsl' documentation updated to reflect data adjacency guarantees --- src/apply/ref.xsl | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/apply/ref.xsl b/src/apply/ref.xsl index 602b39f..b1a2881 100644 --- a/src/apply/ref.xsl +++ b/src/apply/ref.xsl @@ -31,15 +31,25 @@ The descriptor @var{desc} has the following format: @example - + @end example where the @var{target} node shares the same QName as the function to - be applied, and @var{@arity} is its arity. The @var{f:ref} node may - be decorated with additional attributes depending on its context or + be applied, and @var{@arity} is its arity. @var{@length} caches the + number of items (in a sequence) that make up the reference; it can + be retrieved with @code{f:length}. The @var{f:ref} node may be + decorated with additional attributes depending on its context or constructor. + + Each of these functions respects data adjacent to the given + reference (which is at the head of the sequence). For example, + @code{f:set-args} will set the arguments of the dynamic function + reference represented by the head of the provided sequence, but will + leave all data following the reference untouched; this allows + references to be processed in a streaming manner without cutting the + sequence up before operating on the reference. -->