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 \subsection{Macro utilities}
37 {with-gensyms (@{ @<var> @! (@<var> @[@<name>@]) @}^*) \\ \ind
43 {once-only (@[[ :environment @<env> @]]
44 @{ @<var> @! (@<var> @[@<value-form>@]) @}^*) \\ \ind
50 {parse-body @<body> \&key :docp :declp
51 @> @<doc-string> @<declarations> @<body-forms>}
54 \begin{describe}{cls}{loc}
57 \begin{describe}{fun}{symbolicate \&rest @<symbols> @> @<symbol>}
61 \subsection{Locatives}
63 \begin{describe}{fun}{locp @<object> @> @<generalized-boolean>}
66 \begin{describe}{mac}{locf @<place> @> @<locative>}
70 {\dhead{fun}{ref @<locative> @> @<value>}
71 \dhead{fun}{setf (ref @<locative>) @<value>}}
76 @{ @<var> @! (@{ @<var> @!
77 (@<var> @[@<locative>@]) @}^*) @} \\ \ind
83 \subsection{Anaphorics}
85 \begin{describe}{sym}{it}
88 \begin{describe}{mac}{aif @<condition> @<consequent> @[@<alt>@]}
91 \begin{describe}{mac}{aand @<form>^*}
94 \begin{describe}{mac}{awhen @<condition> @<form>^*}
97 \begin{describe}{mac}{acond @{ (@<condition> @<form>^*) @}^*}
102 {acase @<scrutinee> @{ (@{ @<case> @! (@<case>^*) @} @<form>^*) @}^*}
104 {aecase @<scrutinee> @{ (@{ @<case> @! (@<case>^*) @} @<form>^*) @}^*}
105 \dhead{mac}{atypecase @<scrutinee> @{ (@<type> @<form>^*) @}^*}
106 \dhead{mac}{aetypecase @<scrutinee> @{ (@<type> @<form>^*) @}^*}}
109 \begin{describe}{mac}{asetf @{ @<place> @<value> @}^*}
113 \subsection{Metaobject protocol utilities}
115 \begin{describe}{gf}{instance-initargs @<instance>}
119 {\dhead{fun}{copy-instance @<instance> \&rest @<initargs>}
120 \dhead{gf}{copy-instance-using-class @<class> @<instance>
125 {\dhead{gf}{generic-function-methods @<generic-function> @> @<list>}
126 \dhead{gf}{method-specializers @<method> @> @<list>}
127 \dhead{cls}{eql-specializer}
128 \dhead{gf}{eql-specializer-object @<specializer> @> @<value>}}
132 \subsection{Other CLOS utilities}
134 \begin{describe}{mac}
135 {default-slot (@<instance> @<slot> @[@<slot-names>@]) \\ \ind
139 \begin{describe}{mac}
140 {define-on-demand-slot @<class> @<slot> (@<instance>) \\ \ind
141 @[[ @<declaration>^* @! @<doc-string> @]] \\
146 \subsection{Building lists}
148 \begin{describe}{fun}{make-list-builder \&optional @<initial> @> @<builder>}
151 \begin{describe}{fun}{lbuild-add @<builder> @<item> @> @<builder>}
154 \begin{describe}{fun}{lbuild-add-list @<builder> @<list> @> @<builder>}
157 \begin{describe}{fun}{lbuild-list @<builder> @> @<list>}
161 \subsection{Merging lists}
163 \begin{describe}{cls}{inconsistent-merge-error (error) \&key :candidates}
166 \begin{describe}{gf}{merge-error-candidates @<error> @> @<list>}
169 \begin{describe}{fun}
170 {merge-lists @<lists> \&key :pick (:test \#'eql) :present @> @<list>}
174 \subsection{Other list utilities}
176 \begin{describe}{fun}
177 {mappend @<function> @<list> \&rest @<more-lists> @> @<result-list>}
180 \begin{describe}{fun}
181 {distinguished-point-shortest-paths @<root> @<neighbours-func>
185 \begin{describe}{mac}
186 {categorize (\=@<item-var> @<items>
187 @[[ :bind (@{ @<var> @!
188 (@<var> @[@<value>@]) @}^*) @]])
190 (@{ (@<cat-var> @<cat-predicate>) @}^*) \-\\
196 \begin{describe}{fun}{partial-order-minima @<items> @<order> @> @<list>}
199 \begin{describe}{fun}
200 {find-duplicates @<report> @<sequence> \&key :identity :test}
204 \subsection{Position tracking}
206 \begin{describe}{fun}
207 {whitespace-char-p @<character> @> @<generalized-boolean>}
210 \begin{describe}{fun}
211 {update-position @<character> @<line> @<column>
212 @> @<new-line> @<new-column>}
215 \begin{describe}{fun}
216 {backtrack-position @<character> @<line> @<column>
217 @> @<old-line> @<old-column>}
221 \subsection{Object printing}
223 \begin{describe}{mac}
224 {maybe-print-unreadable-object
227 :identity @<identity> @]]) \\ \ind
232 \begin{describe}{fun}{print-ugly-stuff @<stream> @<func> @> @<value>^*}
236 \subsection{Condition utilities}
238 \begin{describe}{cls}
239 {simple-control-error (control-error simple-error)
240 \&key :format-control :format-arguments}
243 \begin{describe}{fun}
244 {designated-condition
245 \=@<default-type> @<datum> @<arguments> \\
246 \>\&key :allow-pointless-arguments
250 \begin{describe}{fun}
251 {invoke-associated-restart @<restart> @<condition> \&rest @<arguments>}
255 \subsection{Very miscellaneous utilities}
257 \begin{describe}{fun}
258 {frob-identifier @<string> \&key :swap-case :swap-hyphen
259 @> @<frobbed-string>}
262 \begin{describe}{fun}
263 {compose @<function> \&rest @<more-functions> @> @<function>}
266 \begin{describe}{mac}{defvar-unbound @<name> @<documentation> @> @<name>}
269 \begin{describe}{mac}
270 {dosequence (@<var> @<sequence>
271 @[[ :start @<start> @! :end @<end> @!
272 :indexvar @<var> @]]) \\ \ind
274 @{ @<tag> @! @<statement> @}^*}
277 \begin{describe}{mac}
278 {define-access-wrapper @<from> @<to>
279 @[[ :read-only @<read-only-flag> @]]}
282 %%%--------------------------------------------------------------------------
283 \section{Condition utilities} \label{sec:misc.condition}
285 These symbols are defined in the @|sod-parser| package.
287 \begin{describe}{cls}{enclosing-condition (condition) \&key :condition}
291 {enclosed-condition @<enclosing-condition> @> @<condition>}
294 \begin{describe}{cls}{information (condition) \&key}
297 \begin{describe}{cls}
298 {simple-information (simple-condition information) \\ \ind
299 \&key :format-control :format-arguments}
302 \begin{describe}{fun}{info @<datum> \&rest @<arguments> @> @<flag>}
307 \dhead{fun}{noted \&optional @<condition>}}
310 \begin{describe}{fun}{cerror* @<datum> \&rest @<arguments>}
313 %%%--------------------------------------------------------------------------
314 \section{Option parser} \label{sec:misc.optparse}
316 These symbols are defined in the @|optparse| package.
318 \begin{describe}{fun}{exit \&optional (@<code> 0) \&key :abrupt}
321 \begin{describe}{var}{*program-name*}
324 \begin{describe}{var}{*command-line*}
327 \begin{describe}{fun}{set-command-line-arguments}
330 \begin{describe}{fun}{moan @<format-string> \&rest @<format-args>}
333 \begin{describe}{fun}{die @<format-string> \&rest @<format-args>}
336 \begin{describe}{var}{*options*}
339 \begin{describe}{cls}{option}
342 \begin{describe}{fun}{optionp @<object> @> @<generalized-boolean>}
345 \begin{describe}{fun}
346 {make-option \=@<long-name> @<short-name> \+\\
347 \&optional @<arg-name> \\
348 \&key :tag :negated-tag
349 :arg-optional-p :documentation \-
354 {\dhead{fun}{opt-short-name @<option> @> @<character-or-null>}
355 \dhead{fun}{setf (opt-short-name @<option>) @<character-or-null>}
356 \dhead{fun}{opt-long-name @<option> @> @<string-or-null>}
357 \dhead{fun}{setf (opt-long-name @<option>) @<string-or-null>}
358 \dhead{fun}{opt-tag @<option> @> @<tag>}
359 \dhead{fun}{setf (opt-tag @<option>) @<tag>}
360 \dhead{fun}{opt-negated-tag @<option> @> @<tag>}
361 \dhead{fun}{setf (opt-negated-tag @<option>) @<tag>}
362 \dhead{fun}{opt-arg-name @<option> @> @<string-or-null>}
363 \dhead{fun}{setf (opt-arg-name @<option>) @<string-or-null>}
364 \dhead{fun}{opt-optional-p @<option> @> @<generalized-boolean>}
365 \dhead{fun}{setf (opt-optional-p @<option>) @<generalized-boolean>}
366 \dhead{fun}{opt-documentation @<option> @> @<string-or-null>}
367 \dhead{fun}{setf (opt-documentation @<option>) @<string-or-null>}}
370 \begin{describe}{cls}{option-parser}
373 \begin{describe}{fun}{option-parser-p @<object> @> @<generalized-boolean>}
376 \begin{describe}{fun}
377 {make-option-parser \&key \=:args :options :non-option :numericp \+ \\
378 :negated-numeric-p long-only-p \-
379 \nlret @<option-parser>}
383 {\dhead{fun}{op-options @<option-parser> @> @<list>}
384 \dhead{fun}{setf (op-options @<option-parser>) @<list>}
385 \dhead{fun}{op-non-option @<option-parser> @> @<action>}
386 \dhead{fun}{setf (op-non-option @<option-parser>) @<action>}
387 \dhead{fun}{op-long-only-p @<option-parser> @> @<generalized-boolean>}
388 \dhead{fun}{setf (op-long-only-p @<option-parser>) @<generalized-boolean>}
389 \dhead{fun}{op-numeric-p @<option-parser> @> @<generalized-boolean>}
390 \dhead{fun}{setf (op-numeric-p @<option-parser>) @<generalized-boolean>}
391 \dhead{fun}{op-negated-numeric-p @<option-parser> @<generalized-boolean>}
392 \dhead{fun}{setf (op-negated-numeric-p @<option-parser>) @<generalized-boolean>}
393 \dhead{fun}{op-negated-p @<option-parser> @> @<generalized-boolean>}
394 \dhead{fun}{setf (op-negated-p @<option-parser>) @<generalized-boolean>}}
397 \begin{describe}{cls}
398 {option-parse-error (error simple-condition)
399 \&key :format-control :format-arguments}
402 \begin{describe}{fun}{option-parse-remainder @<option-parser>}
405 \begin{describe}{fun}{option-parse-return @<tag> \&optional @<argument>}
408 \begin{describe}{fun}{option-parse-next @<option-parser>}
411 \begin{describe}{mac}{option-parse-try @<form>^*}
414 \begin{describe}{mac}{with-unix-error-reporting () @<form>^*}
417 \begin{describe}{mac}
418 {defopthandler @<name> (@<var> @[@<arg>@]) @<lambda-list> \\ \ind
419 @[[ @<declaration>^* @! @<doc-string> @]] \\
423 \begin{describe}{fun}
424 {invoke-option-handler @<handler> @<locative> @<arg> @<arguments>}
427 \begin{describe}{opt}{set \&optional @<value>}
430 \begin{describe}{opt}{clear \&optional @<value>}
433 \begin{describe}{opt}{inc \&optional @<maximum> @<step>}
436 \begin{describe}{opt}{dec \&optional <minimum> <step>}
439 \begin{describe}{opt}{read}
442 \begin{describe}{opt}{int \&key :radix :min :max}
445 \begin{describe}{opt}{string}
448 \begin{describe}{opt}{keyword \&optional @<valid>}
451 \begin{describe}{opt}{list \&optional @<handler> \&rest @<handler-args>}
454 \begin{describe}{mac}
455 {defoptmacro @<name> @<lambda-list> \\ \ind
456 @[[ @<declaration>^* @! @<doc-string> @]] \\
460 \begin{describe}{fun}{parse-option-form @<form>}
463 \begin{describe}{mac}
464 {options @{ \=@<string> @! \+ \\
465 @<option-macro> @! (@<option-macro> @<macro-arg>^*) @! \\
466 (@[[ \=@<character> @! (:short-name @<character>) @! \+ \\
467 @<string>^* @! @<symbol> @! @<rational> @!
468 (:long-name @<string>) @! \\
469 (@<string> @<format-arg>^+) @!
470 (:doc @<string> @<format-arg>^*) @! \\
471 (:arg @<arg-name>) @! (:opt-arg @<arg-name>) @! \\
472 @<keyword> @! (:tag @<tag>) @!
473 (:negated-tag @<tag>) @! \\
474 @{ (@<handler> @<var> @<handler-arg>^*) @}^*
478 \begin{describe}{fun}
479 {simple-usage @<option-list> \&optional @<mandatory-args> @> @<list>}
482 \begin{describe}{fun}{show-usage @<prog> @<usage> \&optional @<stream>}
485 \begin{describe}{fun}
486 {show-help @<prog> @<usage> @<option-list> \&optional @<stream>}
489 \begin{describe}{fun}{sanity-check-option-list @<option-list>}
494 \dhead{var}{*version*}
495 \dhead{var}{*usage*}}
498 \begin{describe}{fun}{do-usage \&optional @<stream>}
501 \begin{describe}{fun}{die-usage}
504 \begin{describe}{optmac}
505 {help-options \&key :short-help :short-version :short-usage}
508 \begin{describe}{fun}
509 {define-program \&key \=:program-name \+ \\
510 :help :version :usage :full-usage \\
514 \begin{describe}{mac}
515 {do-options (@[[ :parser @<option-parser> @]]) \\ \ind
516 @{ (@{ @<case> @! (@<case>^*)@} (@[@[@<opt-var>@] @<arg-var>@])
520 %%%--------------------------------------------------------------------------
521 \section{Property sets} \label{sec:misc.pset}
523 \begin{describe}{fun}{property-key @<name> @> @<keyword>}
526 \begin{describe}{gf}{decode-property @<raw-value> @> @<type> @<value>}
529 \begin{describe}{cls}{property}
532 \begin{describe}{fun}{propertyp @<object> @> @<generalized-boolean>}
535 \begin{describe}{fun}
536 {make-property @<name> @<raw-value> \&key :type :location :seenp}
540 {\dhead{fun}{p-name @<property> @> @<name>}
541 \dhead{fun}{p-value @<property> @> @<value>}
542 \dhead{fun}{p-type @<property> @> @<type>}
543 \dhead{fun}{p-key @<property> @> @<symbol>}
544 \dhead{fun}{p-seenp @<property> @> @<boolean>}
545 \dhead{fun}{setf (p-seenp @<property>) @<boolean>}}
549 {coerce-property-value @<value> @<type> @<wanted> @> @<coerced-value>}
552 \begin{describe}{cls}{pset}
555 \begin{describe}{fun}{psetp @<object> @> @<generalized-boolean>}
558 \begin{describe}{fun}{make-pset @> @<pset>}
561 \begin{describe}{fun}{pset-get @<pset> @<key> @> @<property-or-nil>}
564 \begin{describe}{fun}{pset-store @<pset> @<property> @> @<property>}
567 \begin{describe}{fun}{pset-map @<func> @<pset>}
570 \begin{describe}{mac}
571 {with-pset-iterator (@<iter> @<pset>) @<declaration>^* @<form>^*}
574 \begin{describe}{fun}
575 {store-property @<pset> @<name> @<value> \&key :type :location
579 \begin{describe}{fun}
580 {get-property @<pset> @<name> @<type> \&optional @<default>
581 @> @<value> @<floc-or-nil>}
584 \begin{describe}{fun}
585 {add-property @<pset> @<name> @<value> \&key :type :location
589 \begin{describe}{fun}{make-property-set \&rest @<plist> @> @<pset>}
592 \begin{describe}{gf}{property-set @<thing> @> @<pset>}
595 \begin{describe}{fun}{check-unused-properties @<pset>}
598 \begin{describe}{mac}
599 {default-slot-from-property
600 (@<instance> @<slot> @[@<slot-names>@]) \\ \ind\ind
601 (@<pset> @<property> @<type> @[@<prop-var> @<convert-form>^*@]) \- \\
606 \begin{describe}{fun}
607 {parse-property @<scanner> @<pset>
608 @> @<result> @<success-flag> @<consumed-flag>}
611 \begin{describe}{fun}
612 {parse-property-set @<scanner>
613 @> @<result> @<success-flag> @<consumed-flag>}
616 %%%--------------------------------------------------------------------------
617 \section{Miscellaneous translator features} \label{sec:misc.misc}
619 \begin{describe}{var}{*sod-version*}
622 \begin{describe}{var}{*debugout-pathname*}
625 \begin{describe}{fun}
626 {test-module @<path> \&key :reason :clear :backtrace @> @<status>}
629 \begin{describe}{fun}
630 {test-parse-c-type @<string>
631 @> t @<c-type> @<kernel> @<string> @! nil @<indicator>}
634 \begin{describe}{fun}
635 {test-parse-pset @<string>
636 @> t @<pset> @! nil @<indicator>}
639 \begin{describe}{mac}
640 {test-parser (@<scanner> \&key :backtrace) @<parser> @<input>
641 @> @<result> @<status> @<remainder>}
644 \begin{describe}{fun}{exercise}
647 \begin{describe}{fun}{sod-frontend:main}
650 %%%----- That's all, folks --------------------------------------------------
654 %%% TeX-master: "sod.tex"