will be described later.
\begin{describe}[struct kwval]{type}
- {struct kwval \{ \\ \ind
- const char *kw; \\
- const void *val; \- \\
+ {struct kwval \{ \\ \ind
+ const char *kw; \\
+ const void *val; \-\\
\};}
The @|kwval| structure describes a keyword argument name/value pair. The
\end{describe}
\begin{describe}[struct kwtab]{type}
- {struct kwtab \{ \\ \ind
- const struct kwval *v; \\
- size_t n; \- \\
+ {struct kwtab \{ \\ \ind
+ const struct kwval *v; \\
+ size_t n; \-\\
\};}
The @|kwtab| structure describes a list of keyword arguments, represented
\end{prog}
with no separation between them. For example:
\begin{prog}
- \#define example_KWSET(_) @\\ \\ \ind
- _(int, x, 0) @\\ \\
+ \#define example_KWSET(_) \macsl \\ \ind
+ _(int, x, 0) \macsl \\
_(const char *, y, NULL)
\end{prog}
The macro @|KWSET_PARSEFN| defines a keyword argument \emph{parser
function}
\begin{prog}
- void @<set>{}_kwparse(\=struct @<set>{}_kwargs *@<kw>,
- const char *@<kwfirst>, va_list *@<ap>, \+ \\
- const struct kwval *@<v>, size_t @<n>);
+ void @<set>{}_kwparse%
+ (\=struct @<set>{}_kwargs *@<kw>,
+ const char *@<kwfirst>, va_list *@<ap>, \+\\
+ const struct kwval *@<v>, size_t @<n>);
\end{prog}
The macro call can (and usually will) be preceded by storage class
specifiers such as @|static|, for example to adjust the linkage of the
which expects keyword arguments, but don't supply any and forget the null
pointer which terminates the (empty) list.} %
If @<kwfirst> is a null pointer, then @<ap> need not be a valid pointer;
- otherwise, the cursor object @|* @<ap>| will be modified as the function
+ otherwise, the cursor object @|*@<ap>| will be modified as the function
extracts successive arguments from the tail.
The keyword vector is read from the vector of @|kwval| structures starting
\end{describe}
\begin{describe}[kw_parseempty]{fun}
- {void kw_parseempty(\=const char *@<set>,
- const char *@<kwfirst>, va_list *@<ap>, \+ \\
- const struct kwval *@<v>, size_t @<n>);}
+ {void kw_parseempty%
+ (\=const char *@<set>,
+ const char *@<kwfirst>, va_list *@<ap>, \+\\
+ const struct kwval *@<v>, size_t @<n>);}
This function checks an keyword argument list to make sure that contains no
keyword arguments (other than the special ones described in
\xref{sec:runtime.keywords.calling}).
\begin{prog}
\#define KWARGS_TEST(k, val) KWARGS(K(k, val) K(kw.unknown, 0))
- \\+
+ \\+
static jmp_buf kw_test_jmp;
- \\+
- static void kw_test_unknown(const char *set, const char *kw) \\
- \{ \\ \ind
- if (strcmp(kw, "kw.unknown")) longjmp(kw_test_jmp, 1); \\
- else longjmp(kw_test_jmp, 2); \- \\
- \}
- \\+
- \#define KW_TEST(flag, set, call) do \{ @\\ \\ \ind
- kw_unkhookfn *oldunk = kw_unkhook; @\\ \\
- kw_unkhook = kw_test_unknown; @\\ \\
- switch (setjmp(kw_test_jmp)) \{ @\\ \\ \ind
- case 0: call; abort(); @\\ \\
- case 1: flag = 1; break; @\\ \\
- case 2: flag = 0; break; @\\ \\
- default: abort(); \- @\\ \\
- \} @\\ \\
- kw_unkhook = oldunk; \- @\\ \\
- \} while (0)
- \\+
- /* Example of use */ \\
- int f; \\
+ \\+
+ static void kw_test_unknown(const char *set, const char *kw) \\
+ \{ \\ \ind
+ if (strcmp(kw, "kw.unknown")) longjmp(kw_test_jmp, 1); \\
+ else longjmp(kw_test_jmp, 2); \-\\
+ \} \\+
+
+ \#define KW_TEST(flag, set, call) do \{ \macsl \\ \ind
+ kw_unkhookfn *oldunk = kw_unkhook; \macsl \\
+ kw_unkhook = kw_test_unknown; \macsl \\
+ switch (setjmp(kw_test_jmp)) \{ \macsl \\ \ind
+ case 0: call; abort(); \macsl \\
+ case 1: flag = 1; break; \macsl \\
+ case 2: flag = 0; break; \macsl \\
+ default: abort(); \macsl\-\\
+ \} \macsl \\
+ kw_unkhook = oldunk; \macsl\-\\
+ \} while (0) \\+
+
+ @/* Example of use */ \\
+ int f; \\
KW_TEST(f, somefunc(1, "two", 3, KWARGS_TEST("shiny", 68.7))); \\
- /\=* now f is nonzero if `somefunc' accepts the `shiny' keyword \+ \\
- {}* (which we hope wants a double argument) \\
+ /\=* \comment{now @|f| is nonzero if @|somefunc| accepts the
+ @|shiny| keyword} \+\\
+ {}* \comment{(which we hope wants a @|double| argument)} \\
{}*/
\end{prog}