Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/markos-scratch into lp:zorba.
Commit message: removed jn:null() + allow empty seq as input to jn:size() Requested reviews: Markos Zaharioudakis (markos-za) For more details, see: https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/179692 removed jn:null() + allow empty seq as input to jn:size() -- https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/179692 Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'modules/org/jsoniq/www/functions.xq' --- modules/org/jsoniq/www/functions.xq 2013-08-12 09:59:18 +0000 +++ modules/org/jsoniq/www/functions.xq 2013-08-12 12:50:29 +0000 @@ -215,7 +215,7 @@ : @param $j A JSON Array. : @return The number of items in $j. :) -declare function jn:size($j as array()) as xs:integer external; +declare function jn:size($j as array()?) as xs:integer? external; (:~ @@ -260,14 +260,4 @@ declare function jn:null() as js:null external; -(:~ - : Tests whether the supplied atomic item is a JSON null. - : - : @param An atomic item. - : - : @return true if the item is of type js:null. - :) -declare function jn:is-null($i as xs:anyAtomicType) as xs:boolean external; - - === modified file 'src/functions/func_jsoniq_functions_impl.cpp' --- src/functions/func_jsoniq_functions_impl.cpp 2013-08-09 10:23:10 +0000 +++ src/functions/func_jsoniq_functions_impl.cpp 2013-08-12 12:50:29 +0000 @@ -70,6 +70,18 @@ /******************************************************************************* ********************************************************************************/ +xqtref_t fn_jsoniq_size::getReturnType(const fo_expr* caller) const +{ + if (caller->get_arg(0)->get_return_type()->get_quantifier() == TypeConstants::QUANT_ONE) + return GENV_TYPESYSTEM.INTEGER_TYPE_ONE; + + return theSignature.returnType(); +} + + +/******************************************************************************* + +********************************************************************************/ PlanIter_t fn_jsoniq_keys::codegen( CompilerCB*, static_context* sctx, === modified file 'src/functions/pregenerated/func_jsoniq_functions.cpp' --- src/functions/pregenerated/func_jsoniq_functions.cpp 2013-08-12 10:27:18 +0000 +++ src/functions/pregenerated/func_jsoniq_functions.cpp 2013-08-12 12:50:29 +0000 @@ -154,16 +154,6 @@ return new JSONNullIterator(sctx, loc); } -PlanIter_t fn_jsoniq_is_null::codegen( - CompilerCB*, - static_context* sctx, - const QueryLoc& loc, - std::vector<PlanIter_t>& argv, - expr& ann) const -{ - return new JSONIsNullIterator(sctx, loc, argv[0]); -} - PlanIter_t op_zorba_json_object_insert::codegen( CompilerCB*, static_context* sctx, @@ -431,8 +421,8 @@ { DECL_WITH_KIND(sctx, fn_jsoniq_size, (createQName("http://jsoniq.org/functions","","size"), - GENV_TYPESYSTEM.JSON_ARRAY_TYPE_ONE, - GENV_TYPESYSTEM.INTEGER_TYPE_ONE), + GENV_TYPESYSTEM.JSON_ARRAY_TYPE_QUESTION, + GENV_TYPESYSTEM.INTEGER_TYPE_QUESTION), FunctionConsts::FN_JSONIQ_SIZE_1); } @@ -464,18 +454,6 @@ { - DECL_WITH_KIND(sctx, fn_jsoniq_is_null, - (createQName("http://jsoniq.org/functions","","is-null"), - GENV_TYPESYSTEM.ANY_ATOMIC_TYPE_ONE, - GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE), - FunctionConsts::FN_JSONIQ_IS_NULL_1); - - } - - - - - { DECL_WITH_KIND(sctx, op_zorba_json_object_insert, (createQName("http://zorba.io/internal/zorba-ops","","json-object-insert"), GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE, === modified file 'src/functions/pregenerated/func_jsoniq_functions.h' --- src/functions/pregenerated/func_jsoniq_functions.h 2013-08-09 10:23:10 +0000 +++ src/functions/pregenerated/func_jsoniq_functions.h 2013-08-12 12:50:29 +0000 @@ -287,6 +287,8 @@ } + xqtref_t getReturnType(const fo_expr* caller) const; + bool propagatesInputNodes(expr* fo, csize producer) const { return false; } bool mustCopyInputNodes(expr* fo, csize producer) const { return false; } @@ -329,21 +331,6 @@ }; -//fn-jsoniq:is-null -class fn_jsoniq_is_null : public function -{ -public: - fn_jsoniq_is_null(const signature& sig, FunctionConsts::FunctionKind kind) - : - function(sig, kind) - { - - } - - CODEGEN_DECL(); -}; - - //op-zorba:json-object-insert class op_zorba_json_object_insert : public function { === modified file 'src/functions/pregenerated/function_enum.h' --- src/functions/pregenerated/function_enum.h 2013-08-09 10:23:10 +0000 +++ src/functions/pregenerated/function_enum.h 2013-08-12 12:50:29 +0000 @@ -271,7 +271,6 @@ FN_JSONIQ_SIZE_1, FN_JSONIQ_FLATTEN_1, FN_JSONIQ_NULL_0, - FN_JSONIQ_IS_NULL_1, OP_ZORBA_JSON_OBJECT_INSERT_2, OP_ZORBA_JSON_ARRAY_INSERT_3, OP_ZORBA_JSON_DELETE_2, === modified file 'src/runtime/json/jsoniq_functions_impl.cpp' --- src/runtime/json/jsoniq_functions_impl.cpp 2013-08-09 10:23:10 +0000 +++ src/runtime/json/jsoniq_functions_impl.cpp 2013-08-12 12:50:29 +0000 @@ -1278,17 +1278,18 @@ store::Item_t& result, PlanState& planState) const { - store::Item_t lJSONItem; - xs_integer lSize; + store::Item_t item; + xs_integer size; PlanIteratorState* state; DEFAULT_STACK_INIT(PlanIteratorState, state, planState); - consumeNext(lJSONItem, theChild.getp(), planState); - - lSize = lJSONItem->getArraySize(); - - STACK_PUSH(GENV_ITEMFACTORY->createInteger(result, lSize), state); + if (consumeNext(item, theChild.getp(), planState)) + { + size = item->getArraySize(); + + STACK_PUSH(GENV_ITEMFACTORY->createInteger(result, size), state); + } STACK_END(state); } @@ -1516,6 +1517,7 @@ } +#if 0 /******************************************************************************* jn:is-null(xs:anyAtomicType) as xs:boolean ********************************************************************************/ @@ -1537,6 +1539,7 @@ STACK_END(state); } +#endif /******************************************************************************* === modified file 'src/runtime/json/pregenerated/jsoniq_functions.cpp' --- src/runtime/json/pregenerated/jsoniq_functions.cpp 2013-06-18 18:55:33 +0000 +++ src/runtime/json/pregenerated/jsoniq_functions.cpp 2013-08-12 12:50:29 +0000 @@ -505,30 +505,6 @@ // </JSONNullIterator> -// <JSONIsNullIterator> -SERIALIZABLE_CLASS_VERSIONS(JSONIsNullIterator) - -void JSONIsNullIterator::serialize(::zorba::serialization::Archiver& ar) -{ - serialize_baseclass(ar, - (UnaryBaseIterator<JSONIsNullIterator, PlanIteratorState>*)this); -} - - -void JSONIsNullIterator::accept(PlanIterVisitor& v) const -{ - v.beginVisit(*this); - - theChild->accept(v); - - v.endVisit(*this); -} - -JSONIsNullIterator::~JSONIsNullIterator() {} - -// </JSONIsNullIterator> - - // <JSONObjectInsertIterator> SERIALIZABLE_CLASS_VERSIONS(JSONObjectInsertIterator) === modified file 'src/runtime/json/pregenerated/jsoniq_functions.h' --- src/runtime/json/pregenerated/jsoniq_functions.h 2013-06-18 18:55:33 +0000 +++ src/runtime/json/pregenerated/jsoniq_functions.h 2013-08-12 12:50:29 +0000 @@ -655,36 +655,6 @@ /** * - * Author: - */ -class JSONIsNullIterator : public UnaryBaseIterator<JSONIsNullIterator, PlanIteratorState> -{ -public: - SERIALIZABLE_CLASS(JSONIsNullIterator); - - SERIALIZABLE_CLASS_CONSTRUCTOR2T(JSONIsNullIterator, - UnaryBaseIterator<JSONIsNullIterator, PlanIteratorState>); - - void serialize( ::zorba::serialization::Archiver& ar); - - JSONIsNullIterator( - static_context* sctx, - const QueryLoc& loc, - PlanIter_t& child) - : - UnaryBaseIterator<JSONIsNullIterator, PlanIteratorState>(sctx, loc, child) - {} - - virtual ~JSONIsNullIterator(); - - void accept(PlanIterVisitor& v) const; - - bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; -}; - - -/** - * * internal function * * Author: Zorba Team === modified file 'src/runtime/pregenerated/iterator_enum.h' --- src/runtime/pregenerated/iterator_enum.h 2013-07-26 21:05:40 +0000 +++ src/runtime/pregenerated/iterator_enum.h 2013-08-12 12:50:29 +0000 @@ -179,7 +179,6 @@ TYPE_JSONArraySizeIterator, TYPE_JSONArrayFlattenIterator, TYPE_JSONNullIterator, - TYPE_JSONIsNullIterator, TYPE_JSONObjectInsertIterator, TYPE_JSONArrayInsertIterator, TYPE_JSONDeleteIterator, === modified file 'src/runtime/spec/json/jsoniq_functions.xml' --- src/runtime/spec/json/jsoniq_functions.xml 2013-08-09 10:23:10 +0000 +++ src/runtime/spec/json/jsoniq_functions.xml 2013-08-12 12:50:29 +0000 @@ -479,11 +479,12 @@ <zorba:function isDeterministic="true"> <zorba:signature localname="size" prefix="fn-jsoniq"> - <zorba:param>array()</zorba:param> - <zorba:output>xs:integer</zorba:output> + <zorba:param>array()?</zorba:param> + <zorba:output>xs:integer?</zorba:output> </zorba:signature> <zorba:methods> + <zorba:getReturnType/> <zorba:propagatesInputNodes value="false"/> <zorba:mustCopyInputNodes value="false"/> </zorba:methods> @@ -543,7 +544,6 @@ <!-- /******************************************************************************* ********************************************************************************/ ---> <zorba:iterator name="JSONIsNullIterator" arity="unary"> <zorba:function isDeterministic="true"> @@ -555,7 +555,7 @@ </zorba:function> </zorba:iterator> - +--> <!-- /******************************************************************************* === modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h' --- src/runtime/visitors/pregenerated/planiter_visitor.h 2013-07-26 21:05:40 +0000 +++ src/runtime/visitors/pregenerated/planiter_visitor.h 2013-08-12 12:50:29 +0000 @@ -364,8 +364,6 @@ class JSONNullIterator; - class JSONIsNullIterator; - class JSONObjectInsertIterator; class JSONArrayInsertIterator; @@ -1252,9 +1250,6 @@ virtual void beginVisit ( const JSONNullIterator& ) = 0; virtual void endVisit ( const JSONNullIterator& ) = 0; - virtual void beginVisit ( const JSONIsNullIterator& ) = 0; - virtual void endVisit ( const JSONIsNullIterator& ) = 0; - virtual void beginVisit ( const JSONObjectInsertIterator& ) = 0; virtual void endVisit ( const JSONObjectInsertIterator& ) = 0; === modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp' --- src/runtime/visitors/pregenerated/printer_visitor.cpp 2013-08-05 11:54:06 +0000 +++ src/runtime/visitors/pregenerated/printer_visitor.cpp 2013-08-12 12:50:29 +0000 @@ -2220,20 +2220,6 @@ // </JSONNullIterator> -// <JSONIsNullIterator> -void PrinterVisitor::beginVisit ( const JSONIsNullIterator& a) { - thePrinter.startBeginVisit("JSONIsNullIterator", ++theId); - printCommons( &a, theId ); - thePrinter.endBeginVisit( theId ); -} - -void PrinterVisitor::endVisit ( const JSONIsNullIterator& ) { - thePrinter.startEndVisit(); - thePrinter.endEndVisit(); -} -// </JSONIsNullIterator> - - // <JSONObjectInsertIterator> void PrinterVisitor::beginVisit ( const JSONObjectInsertIterator& a) { thePrinter.startBeginVisit("JSONObjectInsertIterator", ++theId); === modified file 'src/runtime/visitors/pregenerated/printer_visitor.h' --- src/runtime/visitors/pregenerated/printer_visitor.h 2013-07-26 21:05:40 +0000 +++ src/runtime/visitors/pregenerated/printer_visitor.h 2013-08-12 12:50:29 +0000 @@ -556,9 +556,6 @@ void beginVisit( const JSONNullIterator& ); void endVisit ( const JSONNullIterator& ); - void beginVisit( const JSONIsNullIterator& ); - void endVisit ( const JSONIsNullIterator& ); - void beginVisit( const JSONObjectInsertIterator& ); void endVisit ( const JSONObjectInsertIterator& ); === modified file 'test/rbkt/Queries/zorba/jsoniq/null04.xq' --- test/rbkt/Queries/zorba/jsoniq/null04.xq 2012-09-13 12:51:41 +0000 +++ test/rbkt/Queries/zorba/jsoniq/null04.xq 2013-08-12 12:50:29 +0000 @@ -1,2 +1,2 @@ -jn:is-null(jn:null()) +jn:null() instance of js:null === modified file 'test/rbkt/Queries/zorba/jsoniq/null05.xq' --- test/rbkt/Queries/zorba/jsoniq/null05.xq 2012-09-13 12:51:41 +0000 +++ test/rbkt/Queries/zorba/jsoniq/null05.xq 2013-08-12 12:50:29 +0000 @@ -1,2 +1,2 @@ -jn:is-null("null") +"null" instance of js:null
-- 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