3 %%% Miscellaneous functionality
5 %%% (c) 2015 Straylight/Edgeware
8 %%%----- Licensing notice ---------------------------------------------------
10 %%% This file is part of the Sensible Object Design, an object system for C.
12 %%% SOD is free software; you can redistribute it and/or modify
13 %%% it under the terms of the GNU General Public License as published by
14 %%% the Free Software Foundation; either version 2 of the License, or
15 %%% (at your option) any later version.
17 %%% SOD is distributed in the hope that it will be useful,
18 %%% but WITHOUT ANY WARRANTY; without even the implied warranty of
19 %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 %%% GNU General Public License for more details.
22 %%% You should have received a copy of the GNU General Public License
23 %%% along with SOD; if not, write to the Free Software Foundation,
24 %%% Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 \chapter{Miscellaneous functionality} \label{ch:misc}
28 %%%--------------------------------------------------------------------------
29 \section{Utilities} \label{sec:misc.utilities}
31 These symbols are defined in the @|sod-utilities| package.
34 {with-gensyms (@{ @<var> @! (@<var> @[@<name>@]) @}^*) \\ \ind
40 {once-only (@[[ :environment @<env> @]]
41 @{ @<var> @! (@<var> @[@<value-form>@]) @}^*) \\ \ind
47 {parse-body @<body> \&key :docp :declp
48 @> @<doc-string> @<declarations> @<body-forms>}
51 \begin{describe}{cls}{loc}
54 \begin{describe}{fun}{locp @<object> @> @<generalized-boolean>}
57 \begin{describe}{mac}{locf @<place> @> @<locative>}
61 {\dhead{fun}{ref @<locative> @> @<value>}
62 \dhead{fun}{setf (ref @<locative>) @<value>}}
67 @{ @<var> @! (@{ @<var> @!
68 (@<var> @[@<locative>@]) @}^*) @} \\ \ind
73 \begin{describe}{sym}{it}
76 \begin{describe}{mac}{aif @<condition> @<consequent> @[@<alt>@]}
79 \begin{describe}{mac}{aand @<form>^*}
82 \begin{describe}{mac}{awhen @<condition> @<form>^*}
85 \begin{describe}{mac}{acond @{ (@<condition> @<form>^*) @}^*}
90 {acase @<scrutinee> @{ (@{ @<case> @! (@<case>^*) @} @<form>^*) @}^*}
92 {aecase @<scrutinee> @{ (@{ @<case> @! (@<case>^*) @} @<form>^*) @}^*}
93 \dhead{mac}{atypecase @<scrutinee> @{ (@<type> @<form>^*) @}^*}
94 \dhead{mac}{aetypecase @<scrutinee> @{ (@<type> @<form>^*) @}^*}}
97 \begin{describe}{mac}{asetf @{ @<place> @<value> @}^*}
100 \begin{describe}{gf}{instance-initargs @<instance>}
104 {\dhead{fun}{copy-instance @<instance> \&rest @<initargs>}
105 \dhead{gf}{copy-instance-using-class @<class> @<instance>
110 {\dhead{gf}{generic-function-methods @<generic-function> @> @<list>}
111 \dhead{gf}{method-specializers @<method> @> @<list>}
112 \dhead{cls}{eql-specializer}
113 \dhead{gf}{eql-specializer-object @<specializer> @> @<value>}}
116 \begin{describe}{fun}{make-list-builder \&optional @<initial> @> @<builder>}
119 \begin{describe}{fun}{lbuild-add @<builder> @<item> @> @<builder>}
122 \begin{describe}{fun}{lbuild-add-list @<builder> @<list> @> @<builder>}
125 \begin{describe}{fun}{lbuild-list @<builder> @> @<list>}
128 \begin{describe}{fun}
129 {mappend @<function> @<list> \&rest @<more-lists> @> @<result-list>}
132 \begin{describe}{cls}{inconsistent-merge-error (error) \&key :candidates}
135 \begin{describe}{gf}{merge-error-candidates @<error> @> @<list>}
138 \begin{describe}{fun}
139 {merge-lists @<lists> \&key :pick (:test \#'eql) :present @> @<list>}
142 \begin{describe}{mac}
143 {categorize (\=@<item-var> @<items>
144 @[[ :bind (@{ @<var> @!
145 (@<var> @[@<value>@]) @}^*) @]])
147 (@{ (@<cat-var> @<cat-predicate>) @}^*) \-\\
153 \begin{describe}{fun}{partial-order-minima @<items> @<order> @> @<list>}
156 \begin{describe}{fun}
157 {frob-identifier @<string> \&key :swap-case :swap-hyphen
158 @> @<frobbed-string>}
161 \begin{describe}{fun}{whitespace-char-p @<character> @> @<generic-function>}
164 \begin{describe}{fun}
165 {update-position @<character> @<line> @<column>
166 @> @<new-line> @<new-column>}
169 \begin{describe}{fun}
170 {backtrack-position @<character> @<line> @<column>
171 @> @<old-line> @<old-column>}
174 \begin{describe}{fun}
175 {compose @<function> \&rest @<more-functions> @> @<function>}
178 \begin{describe}{mac}{defvar @<name> @<documentation> @> @<name>}
181 \begin{describe}{fun}{symbolicate \&rest @<symbols> @> @<symbol>}
184 \begin{describe}{mac}
185 {maybe-print-unreadable-object
188 :identity @<identity> @]]) \\ \ind
193 \begin{describe}{fun}{print-ugly-stuff @<stream> @<func> @> @<value>^*}
196 \begin{describe}{mac}
197 {dosequence (@<var> @<sequence>
198 @[[ :start @<start> @! :end @<end> @!
199 :indexvar @<var> @]]) \\ \ind
201 @{ @<tag> @! @<statement> @}^*}
204 \begin{describe}{mac}
205 {define-access-wrapper @<from> @<to>
206 @[[ :read-only @<read-only-flag> @]]}
209 \begin{describe}{fun}
210 {designated-condition
211 \=@<default-type> @<datum> @<arguments> \\
212 \>\&key :allow-pointless-arguments
216 \begin{describe}{mac}
217 {default-slot (@<instance> @<slot> @[@<slot-names>@]) \\ \ind
221 \begin{describe}{mac}
222 {define-on-demand-slot @<class> @<slot> (@<instance>) \\ \ind
223 @[[ @<declaration>^* @! @<doc-string> @]] \\
227 %%%--------------------------------------------------------------------------
228 \section{Condition utilities} \label{sec:misc.condition}
230 These symbols are defined in the @|sod-parser| package.
232 \begin{describe}{cls}{enclosing-condition (condition) \&key :condition}
236 {enclosed-condition @<enclosing-condition> @> @<condition>}
239 \begin{describe}{cls}{information (condition) \&key}
242 \begin{describe}{cls}
243 {simple-information (simple-condition information) \\ \ind
244 \&key :format-control :format-arguments}
247 \begin{describe}{fun}{info @<datum> \&rest @<arguments> @> @<flag>}
250 \begin{describe}{rst}{noted}
253 \begin{describe}{fun}{cerror* @<datum> \&rest @<arguments>}
256 %%%--------------------------------------------------------------------------
257 \section{Option parser} \label{sec:misc.optparse}
259 These symbols are defined in the @!optparse| package.
261 \begin{describe}{fun}{exit \&optional (@<code> 0) \&key :abrupt}
264 \begin{describe}{var}{*program-name*}
267 \begin{describe}{var}{*command-line*}
270 \begin{describe}{fun}{set-command-line-arguments}
273 \begin{describe}{fun}{moan @<format-string> \&rest @<format-args>}
276 \begin{describe}{fun}{die @<format-string> \&rest @<format-args>}
279 \begin{describe}{var}{*options*}
282 \begin{describe}{cls}{option}
285 \begin{describe}{fun}{optionp @<object> @> @<generalized-boolean>}
288 \begin{describe}{fun}
289 {make-option \=@<long-name> @<short-name> \+\\
290 \&optional @<arg-name> \\
291 \&key :tag :negated-tag
292 :arg-optional-p :documentation \-
297 {\dhead{fun}{opt-short-name @<option> @> @<character-or-null>}
298 \dhead{fun}{setf (opt-short-name @<option>) @<character-or-null>}
299 \dhead{fun}{opt-long-name @<option> @> @<string-or-null>}
300 \dhead{fun}{setf (opt-long-name @<option>) @<string-or-null>}
301 \dhead{fun}{opt-tag @<option> @> @<tag>}
302 \dhead{fun}{setf (opt-tag @<option>) @<tag>}
303 \dhead{fun}{opt-negated-tag @<option> @> @<tag>}
304 \dhead{fun}{setf (opt-negated-tag @<option>) @<tag>}
305 \dhead{fun}{opt-arg-name @<option> @> @<string-or-null>}
306 \dhead{fun}{setf (opt-arg-name @<option>) @<string-or-null>}
307 \dhead{fun}{opt-optional-p @<option> @> @<generalized-boolean>}
308 \dhead{fun}{setf (opt-optional-p @<option>) @<generalized-boolean>}
309 \dhead{fun}{opt-documentation @<option> @> @<string-or-null>}
310 \dhead{fun}{setf (opt-documentation @<option>) @<string-or-null>}}
313 \begin{describe}{cls}{option-parser}
316 \begin{describe}{fun}{option-parser-p @<object> @> @<generalized-boolean>}
319 \begin{describe}{fun}
320 {make-option-parser \&key \=:args :options :non-option :numericp \+ \\
321 :negated-numeric-p long-only-p \-
322 \nlret @<option-parser>}
326 {\dhead{fun}{op-options @<option-parser> @> @<list>}
327 \dhead{fun}{setf (op-options @<option-parser>) @<list>}
328 \dhead{fun}{op-non-option @<option-parser> @> @<action>}
329 \dhead{fun}{setf (op-non-option @<option-parser>) @<action>}
330 \dhead{fun}{op-long-only-p @<option-parser> @> @<generalized-boolean>}
331 \dhead{fun}{setf (op-long-only-p @<option-parser>) @<generalized-boolean>}
332 \dhead{fun}{op-numeric-p @<option-parser> @> @<generalized-boolean>}
333 \dhead{fun}{setf (op-numeric-p @<option-parser>) @<generalized-boolean>}
334 \dhead{fun}{op-negated-numeric-p @<option-parser> @<generalized-boolean>}
335 \dhead{fun}{setf (op-negated-numeric-p @<option-parser>) @<generalized-boolean>}
336 \dhead{fun}{op-negated-p @<option-parser> @> @<generalized-boolean>}
337 \dhead{fun}{setf (op-negated-p @<option-parser>) @<generalized-boolean>}}
340 \begin{describe}{cls}
341 {option-parse-error (error simple-condition)
342 \&key :format-control :format-arguments}
345 \begin{describe}{fun}{option-parse-remainder @<option-parser>}
348 \begin{describe}{fun}{option-parse-return @<tag> \&optional @<argument>}
351 \begin{describe}{fun}{option-parse-next @<option-parser>}
354 \begin{describe}{mac}{option-parse-try @<form>^*}
357 \begin{describe}{mac}{with-unix-error-reporting () @<form>^*}
360 \begin{describe}{mac}
361 {defopthandler @<name> (@<var> @[@<arg>@]) @<lambda-list> \\ \ind
362 @[[ @<declaration>^* @! @<doc-string> @]] \\
366 \begin{describe}{fun}
367 {invoke-option-handler @<handler> @<locative> @<arg> @<arguments>}
370 \begin{describe}{opt}{set \&optional @<value>}
373 \begin{describe}{opt}{clear \&optional @<value>}
376 \begin{describe}{opt}{inc \&optional @<maximum> @<step>}
379 \begin{describe}{opt}{dec \&optional <minimum> <step>}
382 \begin{describe}{opt}{read}
385 \begin{describe}{opt}{int \&key :radix :min :max}
388 \begin{describe}{opt}{string}
391 \begin{describe}{opt}{keyword \&optional @<valid>}
394 \begin{describe}{opt}{list \&optional @<handler> \&rest @<handler-args>}
397 \begin{describe}{mac}
398 {defoptmacro @<name> @<lambda-list> \\ \ind
399 @[[ @<declaration>^* @! @<doc-string> @]] \\
403 \begin{describe}{fun}{parse-option-form @<form>}
406 \begin{describe}{mac}
407 {options @{ \=@<string> @! \+ \\
408 @<option-macro> @! (@<option-macro> @<macro-arg>^*) @! \\
409 (@[[ \=@<character> @! (:short-name @<character>) @! \+ \\
410 @<string>^* @! @<symbol> @! @<rational> @!
411 (:long-name @<string>) @! \\
412 (@<string> @<format-arg>^+) @!
413 (:doc @<string> @<format-arg>^*) @! \\
414 (:arg @<arg-name>) @! (:opt-arg @<arg-name>) @! \\
415 @<keyword> @! (:tag @<tag>) @!
416 (:negated-tag @<tag>) @! \\
417 @{ (@<handler> @<var> @<handler-arg>^*) @}^*
421 \begin{describe}{fun}
422 {simple-usage @<option-list> \&optional @<mandatory-args> @> @<list>}
425 \begin{describe}{fun}{show-usage @<prog> @<usage> \&optional @<stream>}
428 \begin{describe}{fun}
429 {show-help @<prog> @<usage> @<option-list> \&optional @<stream>}
432 \begin{describe}{fun}{sanity-check-option-list @<option-list>}
437 \dhead{var}{*version*}
438 \dhead{var}{*usage*}}
441 \begin{describe}{fun}{do-usage \&optional @<stream>}
444 \begin{describe}{fun}{die-usage}
447 \begin{describe}{optmac}
448 {help-options \&key :short-help :short-version :short-usage}
451 \begin{describe}{fun}
452 {define-program \&key \=:program-name \+ \\
453 :help :version :usage :full-usage \\
457 \begin{describe}{mac}
458 {do-options (@[[ :parser @<option-parser> @]]) \\ \ind
459 @{ (@{ @<case> @! (@<case>^*)@} (@[@[@<opt-var>@] @<arg-var>@])
463 %%%--------------------------------------------------------------------------
464 \section{Property sets} \label{sec:misc.pset}
466 \begin{describe}{fun}{property-key @<name> @> @<keyword>}
469 \begin{describe}{gf}{decode-property @<raw-value> @> @<type> @<value>}
472 \begin{describe}{cls}{property}
475 \begin{describe}{fun}{propertyp @<object> @> @<generalized-boolean>}
478 \begin{describe}{fun}
479 {make-property @<name> @<raw-value> \&key :type :location :seenp}
483 {\dhead{fun}{p-name @<property> @> @<name>}
484 \dhead{fun}{p-value @<property> @> @<value>}
485 \dhead{fun}{p-type @<property> @> @<type>}
486 \dhead{fun}{p-key @<property> @> @<symbol>}
487 \dhead{fun}{p-seenp @<property> @> @<boolean>}
488 \dhead{fun}{setf (p-seenp @<property>) @<boolean>}}
491 \begin{describe}{gf}{decode-property @<raw-value> @> @<type> @<value>}
495 {coerce-property-value @<value> @<type> @<wanted> @> @<coerced-value>}
498 \begin{describe}{cls}{pset}
501 \begin{describe}{fun}{psetp @<object> @> @<generalized-boolean>}
504 \begin{describe}{fun}{make-pset @> @<pset>}
507 \begin{describe}{fun}{pset-get @<pset> @<key> @> @<property-or-nil>}
510 \begin{describe}{fun}{pset-store @<pset> @<property> @> @<property>}
513 \begin{describe}{fun}{pset-map @<func> @<pset>}
516 \begin{describe}{mac}
517 {with-pset-iterator (@<iter> @<pset>) @<declaration>^* @<form>^*}
520 \begin{describe}{fun}
521 {store-property @<pset> @<name> @<value> \&key :type :location
525 \begin{describe}{fun}
526 {get-property @<pset> @<name> @<type> \&optional @<default>
527 @> @<value> @<floc-or-nil>}
530 \begin{describe}{fun}
531 {add-property @<pset> @<name> @<value> \&key :type :location
535 \begin{describe}{fun}{make-property-set \&rest @<plist> @> @<pset>}
538 \begin{describe}{gf}{property-set @<thing> @> @<pset>}
541 \begin{describe}{fun}{check-unused-properties @<pset>}
544 \begin{describe}{mac}
545 {default-slot-from-property
546 (@<instance> @<slot> @[@<slot-names>@]) \\ \ind\ind
547 (@<pset> @<property> @<type> @[@<prop-var> @<convert-form>^*@]) \- \\
552 \begin{describe}{fun}
553 {parse-property @<scanner> @<pset>
554 @> @<result> @<success-flag> @<consumed-flag>}
557 \begin{describe}{fun}
558 {parse-property-set @<scanner>
559 @> @<result> @<success-flag> @<consumed-flag>}
562 %%%--------------------------------------------------------------------------
563 \section{Miscellaneous translator features} \label{sec:misc.pset}
565 \begin{describe}{var}{*sod-version*}
568 \begin{describe}{var}{*debugout-pathname*}
571 \begin{describe}{fun}{test-module @<path> \&key :reason @> @<status>}
574 \begin{describe}{fun}
575 {test-parse-c-type @<string>
576 @> t @<c-type> @<kernel> @<string> @! nil @<indicator>}
579 \begin{describe}{mac}
580 {test-parser (@<scanner> \&key :backtrace) @<parser> @<input>
581 @> @<result> @<status> @<remainder>}
584 \begin{describe}{fun}{exercise}
587 \begin{describe}{fun}{sod-frontend:main}
590 %%%----- That's all, folks --------------------------------------------------
594 %%% TeX-master: "sod.tex"