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
}
154 {frob-identifier @<string> \&key :swap-case :swap-hyphen
155 @> @<frobbed-string>
}
158 \begin{describe
}{fun
}{whitespace-char-p @<character> @> @<generic-function>
}
161 \begin{describe
}{fun
}
162 {update-position @<character> @<line> @<column>
163 @> @<new-line> @<new-column>
}
166 \begin{describe
}{fun
}
167 {backtrack-position @<character> @<line> @<column>
168 @> @<old-line> @<old-column>
}
171 \begin{describe
}{fun
}
172 {compose @<function> \&rest @<more-functions> @> @<function>
}
175 \begin{describe
}{fun
}{symbolicate \&rest @<symbols> @> @<symbol>
}
178 \begin{describe
}{mac
}
179 {maybe-print-unreadable-object
182 :identity @<identity> @
]]) \\
\ind
187 \begin{describe
}{fun
}{print-ugly-stuff @<stream> @<func> @> @<value>^*
}
190 \begin{describe
}{mac
}
191 {dosequence (@<var> @<sequence>
192 @
[[ :start @<start> @! :end @<end> @!
193 :indexvar @<var> @
]]) \\
\ind
195 @
{ @<tag> @! @<statement> @
}^*
}
198 \begin{describe
}{mac
}
199 {define-access-wrapper @<from> @<to>
200 @
[[ :read-only @<read-only-flag> @
]]}
203 \begin{describe
}{fun
}
204 {designated-condition
205 \=@<default-type> @<datum> @<arguments> \\
206 \>\&key :allow-pointless-arguments
210 \begin{describe
}{mac
}
211 {default-slot (@<instance> @<slot> @
[@<slot-names>@
]) \\
\ind
215 \begin{describe
}{mac
}
216 {define-on-demand-slot @<class> @<slot> (@<instance>) \\
\ind
217 @
[[ @<declaration>^* @! @<doc-string> @
]] \\
221 %%%--------------------------------------------------------------------------
222 \section{Condition utilities
} \label{sec:misc.condition
}
224 These symbols are defined in the @|sod-parser| package.
226 \begin{describe
}{cls
}{enclosing-condition (condition) \&key :condition
}
230 {enclosed-condition @<enclosing-condition> @> @<condition>
}
233 \begin{describe
}{cls
}{information (condition) \&key
}
236 \begin{describe
}{cls
}
237 {simple-information (simple-condition information) \\
\ind
238 \&key :format-control :format-arguments
}
241 \begin{describe
}{fun
}{info @<datum> \&rest @<arguments> @> @<flag>
}
244 \begin{describe
}{rst
}{noted
}
247 \begin{describe
}{fun
}{cerror* @<datum> \&rest @<arguments>
}
250 %%%--------------------------------------------------------------------------
251 \section{Option parser
} \label{sec:misc.optparse
}
253 These symbols are defined in the @!optparse| package.
255 \begin{describe
}{fun
}{exit \&optional (@<code>
0) \&key :abrupt
}
258 \begin{describe
}{var
}{*program-name*
}
261 \begin{describe
}{var
}{*command-line*
}
264 \begin{describe
}{fun
}{set-command-line-arguments
}
267 \begin{describe
}{fun
}{moan @<format-string> \&rest @<format-args>
}
270 \begin{describe
}{fun
}{die @<format-string> \&rest @<format-args>
}
273 \begin{describe
}{var
}{*options*
}
276 \begin{describe
}{cls
}{option
}
279 \begin{describe
}{fun
}{optionp @<object> @> @<generalized-boolean>
}
282 \begin{describe
}{fun
}
283 {make-option \=@<long-name> @<short-name> \+\\
284 \&optional @<arg-name> \\
285 \&key :tag :negated-tag
286 :arg-optional-p :documentation \-
291 {\dhead{fun
}{opt-short-name @<option> @> @<character-or-null>
}
292 \dhead{fun
}{setf (opt-short-name @<option>) @<character-or-null>
}
293 \dhead{fun
}{opt-long-name @<option> @> @<string-or-null>
}
294 \dhead{fun
}{setf (opt-long-name @<option>) @<string-or-null>
}
295 \dhead{fun
}{opt-tag @<option> @> @<tag>
}
296 \dhead{fun
}{setf (opt-tag @<option>) @<tag>
}
297 \dhead{fun
}{opt-negated-tag @<option> @> @<tag>
}
298 \dhead{fun
}{setf (opt-negated-tag @<option>) @<tag>
}
299 \dhead{fun
}{opt-arg-name @<option> @> @<string-or-null>
}
300 \dhead{fun
}{setf (opt-arg-name @<option>) @<string-or-null>
}
301 \dhead{fun
}{opt-optional-p @<option> @> @<generalized-boolean>
}
302 \dhead{fun
}{setf (opt-optional-p @<option>) @<generalized-boolean>
}
303 \dhead{fun
}{opt-documentation @<option> @> @<string-or-null>
}
304 \dhead{fun
}{setf (opt-documentation @<option>) @<string-or-null>
}}
307 \begin{describe
}{cls
}{option-parser
}
310 \begin{describe
}{fun
}{option-parser-p @<object> @> @<generalized-boolean>
}
313 \begin{describe
}{fun
}
314 {make-option-parser \&key \=:args :options :non-option :numericp \+ \\
315 :negated-numeric-p long-only-p \-
316 \nlret @<option-parser>
}
320 {\dhead{fun
}{op-options @<option-parser> @> @<list>
}
321 \dhead{fun
}{setf (op-options @<option-parser>) @<list>
}
322 \dhead{fun
}{op-non-option @<option-parser> @> @<action>
}
323 \dhead{fun
}{setf (op-non-option @<option-parser>) @<action>
}
324 \dhead{fun
}{op-long-only-p @<option-parser> @> @<generalized-boolean>
}
325 \dhead{fun
}{setf (op-long-only-p @<option-parser>) @<generalized-boolean>
}
326 \dhead{fun
}{op-numeric-p @<option-parser> @> @<generalized-boolean>
}
327 \dhead{fun
}{setf (op-numeric-p @<option-parser>) @<generalized-boolean>
}
328 \dhead{fun
}{op-negated-numeric-p @<option-parser> @<generalized-boolean>
}
329 \dhead{fun
}{setf (op-negated-numeric-p @<option-parser>) @<generalized-boolean>
}
330 \dhead{fun
}{op-negated-p @<option-parser> @> @<generalized-boolean>
}
331 \dhead{fun
}{setf (op-negated-p @<option-parser>) @<generalized-boolean>
}}
334 \begin{describe
}{cls
}
335 {option-parse-error (error simple-condition)
336 \&key :format-control :format-arguments
}
339 \begin{describe
}{fun
}{option-parse-remainder @<option-parser>
}
342 \begin{describe
}{fun
}{option-parse-return @<tag> \&optional @<argument>
}
345 \begin{describe
}{fun
}{option-parse-next @<option-parser>
}
348 \begin{describe
}{mac
}{option-parse-try @<form>^*
}
351 \begin{describe
}{mac
}{with-unix-error-reporting () @<form>^*
}
354 \begin{describe
}{mac
}
355 {defopthandler @<name> (@<var> @
[@<arg>@
]) @<lambda-list> \\
\ind
356 @
[[ @<declaration>^* @! @<doc-string> @
]] \\
360 \begin{describe
}{fun
}
361 {invoke-option-handler @<handler> @<locative> @<arg> @<arguments>
}
364 \begin{describe
}{opt
}{set \&optional @<value>
}
367 \begin{describe
}{opt
}{clear \&optional @<value>
}
370 \begin{describe
}{opt
}{inc \&optional @<maximum> @<step>
}
373 \begin{describe
}{opt
}{dec \&optional <minimum> <step>
}
376 \begin{describe
}{opt
}{read
}
379 \begin{describe
}{opt
}{int \&key :radix :min :max
}
382 \begin{describe
}{opt
}{string
}
385 \begin{describe
}{opt
}{keyword \&optional @<valid>
}
388 \begin{describe
}{opt
}{list \&optional @<handler> \&rest @<handler-args>
}
391 \begin{describe
}{mac
}
392 {defoptmacro @<name> @<lambda-list> \\
\ind
393 @
[[ @<declaration>^* @! @<doc-string> @
]] \\
397 \begin{describe
}{fun
}{parse-option-form @<form>
}
400 \begin{describe
}{mac
}
401 {options @
{ \=@<string> @! \+ \\
402 @<option-macro> @! (@<option-macro> @<macro-arg>^*) @! \\
403 (@
[[ \=@<character> @! (:short-name @<character>) @! \+ \\
404 @<string>^* @! @<symbol> @! @<rational> @!
405 (:long-name @<string>) @! \\
406 (@<string> @<format-arg>^+) @!
407 (:doc @<string> @<format-arg>^*) @! \\
408 (:arg @<arg-name>) @! (:opt-arg @<arg-name>) @! \\
409 @<keyword> @! (:tag @<tag>) @!
410 (:negated-tag @<tag>) @! \\
411 @
{ (@<handler> @<var> @<handler-arg>^*) @
}^*
415 \begin{describe
}{fun
}
416 {simple-usage @<option-list> \&optional @<mandatory-args> @> @<list>
}
419 \begin{describe
}{fun
}{show-usage @<prog> @<usage> \&optional @<stream>
}
422 \begin{describe
}{fun
}
423 {show-help @<prog> @<usage> @<option-list> \&optional @<stream>
}
426 \begin{describe
}{fun
}{sanity-check-option-list @<option-list>
}
431 \dhead{var
}{*version*
}
432 \dhead{var
}{*usage*
}}
435 \begin{describe
}{fun
}{do-usage \&optional @<stream>
}
438 \begin{describe
}{fun
}{die-usage
}
441 \begin{describe
}{optmac
}
442 {help-options \&key :short-help :short-version :short-usage
}
445 \begin{describe
}{fun
}
446 {define-program \&key \=:program-name \+ \\
447 :help :version :usage :full-usage \\
451 \begin{describe
}{mac
}
452 {do-options (@
[[ :parser @<option-parser> @
]]) \\
\ind
453 @
{ (@
{ @<case> @! (@<case>^*)@
} (@
[@
[@<opt-var>@
] @<arg-var>@
])
457 %%%--------------------------------------------------------------------------
458 \section{Property sets
} \label{sec:misc.pset
}
460 \begin{describe
}{fun
}{property-key @<name> @> @<keyword>
}
463 \begin{describe
}{gf
}{decode-property @<raw-value> @> @<type> @<value>
}
466 \begin{describe
}{cls
}{property
}
469 \begin{describe
}{fun
}{propertyp @<object> @> @<generalized-boolean>
}
472 \begin{describe
}{fun
}
473 {make-property @<name> @<raw-value> \&key :type :location :seenp
}
477 {\dhead{fun
}{p-name @<property> @> @<name>
}
478 \dhead{fun
}{p-value @<property> @> @<value>
}
479 \dhead{fun
}{p-type @<property> @> @<type>
}
480 \dhead{fun
}{p-key @<property> @> @<symbol>
}
481 \dhead{fun
}{p-seenp @<property> @> @<boolean>
}
482 \dhead{fun
}{setf (p-seenp @<property>) @<boolean>
}}
485 \begin{describe
}{gf
}{decode-property @<raw-value> @> @<type> @<value>
}
489 {coerce-property-value @<value> @<type> @<wanted> @> @<coerced-value>
}
492 \begin{describe
}{cls
}{pset
}
495 \begin{describe
}{fun
}{psetp @<object> @> @<generalized-boolean>
}
498 \begin{describe
}{fun
}{make-pset @> @<pset>
}
501 \begin{describe
}{fun
}{pset-get @<pset> @<key> @> @<property-or-nil>
}
504 \begin{describe
}{fun
}{pset-store @<pset> @<property> @> @<property>
}
507 \begin{describe
}{fun
}{pset-map @<func> @<pset>
}
510 \begin{describe
}{mac
}
511 {with-pset-iterator (@<iter> @<pset>) @<declaration>^* @<form>^*
}
514 \begin{describe
}{fun
}
515 {store-property @<pset> @<name> @<value> \&key :type :location
519 \begin{describe
}{fun
}
520 {get-property @<pset> @<name> @<type> \&optional @<default>
521 @> @<value> @<floc-or-nil>
}
524 \begin{describe
}{fun
}
525 {add-property @<pset> @<name> @<value> \&key :type :location
529 \begin{describe
}{fun
}{make-property-set \&rest @<plist> @> @<pset>
}
532 \begin{describe
}{gf
}{property-set @<thing> @> @<pset>
}
535 \begin{describe
}{fun
}{check-unused-properties @<pset>
}
538 \begin{describe
}{mac
}
539 {default-slot-from-property
540 (@<instance> @<slot> @
[@<slot-names>@
]) \\
\ind\ind
541 (@<pset> @<property> @<type> @
[@<prop-var> @<convert-form>^*@
]) \- \\
546 \begin{describe
}{fun
}
547 {parse-property @<scanner> @<pset>
548 @> @<result> @<success-flag> @<consumed-flag>
}
551 \begin{describe
}{fun
}
552 {parse-property-set @<scanner>
553 @> @<result> @<success-flag> @<consumed-flag>
}
556 %%%--------------------------------------------------------------------------
557 \section{Miscellaneous translator features
} \label{sec:misc.pset
}
559 \begin{describe
}{var
}{*sod-version*
}
562 \begin{describe
}{var
}{*debugout-pathname*
}
565 \begin{describe
}{fun
}{test-module @<path> @<reason>
}
568 \begin{describe
}{fun
}
569 {test-parse-c-type @<string>
570 @> t @<c-type> @<kernel> @<string> @! nil @<indicator>
}
573 \begin{describe
}{mac
}
574 {test-parser (@<scanner> \&key :backtrace) @<parser> @<input>
575 @> @<result> @<status> @<remainder>
}
578 \begin{describe
}{fun
}{exercise
}
581 \begin{describe
}{fun
}{sod-frontend:main
}
584 %%%----- That's all, folks --------------------------------------------------
588 %%% TeX-master: "sod.tex"