Tarantool development patches archive
 help / color / mirror / Atom feed
From: Nikita Pettik <korablev@tarantool.org>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v2 2/3] box: introduce box_return_mp() public C function
Date: Mon, 27 Apr 2020 15:14:08 +0000	[thread overview]
Message-ID: <20200427151408.GD30870@tarantool.org> (raw)
In-Reply-To: <0d4129e35ccfa9cbfd8e4204e8179acb545cf46b.1587600640.git.v.shpilevoy@tarantool.org>

On 23 Apr 02:12, Vladislav Shpilevoy wrote:
> +
> +int
> +test_return_mp(box_function_ctx_t *ctx, const char *args, const char *args_end)
> +{
> +	(void) args;
> +	(void) args_end;
> +	char buf[512];
> +	char *pos = mp_encode_uint(buf, 1);
> +	int rc = box_return_mp(ctx, buf, pos);
> +	if (rc != 0)
> +		return rc;
> +
> +	pos = mp_encode_int(buf, -1);
> +	rc = box_return_mp(ctx, buf, pos);
> +	if (rc != 0)
> +		return rc;
> +
> +	pos = mp_encode_uint(buf, UINT64_MAX);
> +	rc = box_return_mp(ctx, buf, pos);
> +	if (rc != 0)
> +		return rc;
> +
> +	const char *str = "123456789101112131415";
> +	pos = mp_encode_str(buf, str, strlen(str));
> +	rc = box_return_mp(ctx, buf, pos);
> +	if (rc != 0)
> +		return rc;
> +
> +	pos = mp_encode_array(buf, 1);
> +	pos = mp_encode_uint(pos, 2);
> +	box_tuple_t *tuple = box_tuple_new(box_tuple_format_default(),
> +					   buf, pos);
> +	if (tuple == NULL)
> +		return -1;
> +	rc = box_return_tuple(ctx, tuple);

Probably I'm missing something (since I've never used C API) but
when I do:

res = net:connect(box.cfg.listen):call(name)
print(type(res[5]))

I get table. But shouldn't it be tuple (cdata), since it (last member)
is explicitly wrapped into tuple)? I guess it is due to certain
convention but failed to find it in docs. Could you please clarify?

  parent reply	other threads:[~2020-04-27 15:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-23  0:12 [Tarantool-patches] [PATCH v2 0/3] box_return_mp Vladislav Shpilevoy
2020-04-23  0:12 ` [Tarantool-patches] [PATCH v2 1/3] box: introduce port_c Vladislav Shpilevoy
2020-04-24 12:22   ` Igor Munkin
2020-04-24 22:06     ` Vladislav Shpilevoy
2020-04-23  0:12 ` [Tarantool-patches] [PATCH v2 2/3] box: introduce box_return_mp() public C function Vladislav Shpilevoy
2020-04-24 12:22   ` Igor Munkin
2020-04-27 15:14   ` Nikita Pettik [this message]
2020-04-27 21:29     ` Vladislav Shpilevoy
2020-04-27 22:55       ` Nikita Pettik
2020-04-23  0:12 ` [Tarantool-patches] [PATCH v2 3/3] box: replace port_tuple with port_c everywhere Vladislav Shpilevoy
2020-04-25  0:21   ` Igor Munkin
2020-04-26 19:22     ` Vladislav Shpilevoy
2020-04-27  9:12       ` Igor Munkin
2020-04-27  9:18         ` Igor Munkin
2020-04-27 14:10   ` Nikita Pettik
2020-04-28 11:08 ` [Tarantool-patches] [PATCH v2 0/3] box_return_mp Kirill Yukhin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200427151408.GD30870@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v2 2/3] box: introduce box_return_mp() public C function' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox