From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Thu, 17 Jan 2019 19:34:09 +0300 From: Alexander Turenko Subject: Re: [tarantool-patches] Re: [PATCH v1 1/1] implement mp_stack class Message-ID: <20190117163409.hvga32kxxgcc5sat@tkn_work_nb> References: <9613f79e65d9838763422aae0bfb3ca9e2901a32.1547645639.git.kshcherbatov@gmail.com> <20190117115843.nqellm5mmsglqnlf@tkn_work_nb> <842c55cd-5d3f-e857-42f4-94d648c88273@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <842c55cd-5d3f-e857-42f4-94d648c88273@tarantool.org> To: Kirill Shcherbatov Cc: tarantool-patches@freelists.org, vdavydov.dev@gmail.com, Kirill Shcherbatov List-ID: We discussed with Vladimir what could be motivating example for this set of functions to show those are really general-purpose and should reside in the library. He proposed to implement simple (as much as possible) converter from msgpack to json. It only need to support map, array, int and string. The code can be written as a test to the library. > +/** > + * \brief Advance a mp_stack_top()::\a curr attribute of the > + * \a stack. The \a stack must not be empty. > + * \param stack - the pointer to a stack to operate with > + * \retval true, when the top frame have already parsed: > + * mp_stack_top()::\a curr >= mp_stack_top()::\a size; > + * false otherwise. > + */ > +MP_PROTO bool > +mp_stack_advance(struct mp_stack *stack) > +{ > + struct mp_frame *frame = mp_stack_top(stack); > + return ++frame->curr > frame->size; The doxygen comment says it is >=, while the actual code uses >. The contract description is not clear: the function signals when it moves over the last item, not when it reaches the last item. WBR, Alexander Turenko.