[tarantool-patches] Re: [PATCH v1 1/1] implement mp_stack class

Alexander Turenko alexander.turenko at tarantool.org
Thu Jan 17 19:34:09 MSK 2019


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.



More information about the Tarantool-patches mailing list