poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Added PK_MI_REQ_PRINTV request for MI.


From: Jose E. Marchesi
Subject: Re: Added PK_MI_REQ_PRINTV request for MI.
Date: Mon, 02 Aug 2021 23:40:10 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hi Kostas.

Thanks for the patch.

> +        case PK_MI_REQ_PRINTV:
> +          {
> +            int success_p, retcode;
> +            pk_mi_msg resp;
> +            pk_val val, arg;
> +            const char *errmsg;
> +
> +            if (pk_mi_get_num_args (msg) != 1)
> +              {
> +                success_p = 0;
> +                errmsg = "Expected exactly one argument for PRINTV request";
> +              }

I don't think you want to check for num_args there, for two reasons:

First, the arguments in messages are handled by name (i.e. you ask for
pk_mi_get_arg for "value", not for the first argument) and that is more
robust, since if in the future we expand the request to have more
arguments, the implementation would just ignore the extra ones.

Also, if we wanted to check for the exact number of arguments, it would
be better to do so in the generic code in pk-mi-msg*.

So you don't need to add the pk_mi_get_num_args accessor.

> +            else
> +              {
> +                arg = pk_mi_get_arg (msg, "value");
> +                assert (pk_defvar (poke_compiler, "mi_value", arg) == PK_OK);
> +                retcode = pk_compile_expression (poke_compiler,
> +                                                 "format (\"%v\", mi_value)",
> +                                                 NULL, &val);
> +                success_p = retcode == PK_OK;
> +                if (!success_p)
> +                  errmsg = "Invalid value for PRINTV request";
> +              }
> +
> +              resp = pk_mi_make_resp (PK_MI_RESP_PRINTV, pk_mi_msg_number 
> (msg),
> +                                      success_p, errmsg);
> +              pk_mi_set_arg (resp, "string", val);
> +              pk_mi_send (resp);
> +              pk_mi_msg_free (resp);
> +              break;
> +          }
>          default:
>            assert (0);
>          }

The patch is also missing documentation for the new request, in the
manual.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]