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
}{awhen @<condition> @<form>^*
}
82 \begin{describe
}{mac
}{acond @
{ (@<condition> @<form>^*) @
}^*
}
87 {acase @<scrutinee> @
{ (@
{ @<case> @! (@<case>^*) @
} @<form>^*) @
}^*
}
89 {aecase @<scrutinee> @
{ (@
{ @<case> @! (@<case>^*) @
} @<form>^*) @
}^*
}
90 \dhead{mac
}{atypecase @<scrutinee> @
{ (@<type> @<form>^*) @
}^*
}
91 \dhead{mac
}{aetypecase @<scrutinee> @
{ (@<type> @<form>^*) @
}^*
}}
94 \begin{describe
}{mac
}{asetf @
{ @<place> @<value> @
}^*
}
97 \begin{describe
}{gf
}{instance-initargs @<instance>
}
101 {\dhead{fun
}{copy-instance @<instance> \&rest @<initargs>
}
102 \dhead{gf
}{copy-instance-using-class @<class> @<instance>
107 {\dhead{gf
}{generic-function-methods @<generic-function> @> @<list>
}
108 \dhead{gf
}{method-specializers @<method> @> @<list>
}
109 \dhead{cls
}{eql-specializer
}
110 \dhead{gf
}{eql-specializer-object @<specializer> @> @<value>
}}
113 \begin{describe
}{fun
}{make-list-builder \&optional @<initial> @> @<builder>
}
116 \begin{describe
}{fun
}{lbuild-add @<builder> @<item> @> @<builder>
}
119 \begin{describe
}{fun
}{lbuild-add-list @<builder> @<list> @> @<builder>
}
122 \begin{describe
}{fun
}{lbuild-list @<builder> @> @<list>
}
125 \begin{describe
}{fun
}
126 {mappend @<function> @<list> \&rest @<more-lists> @> @<result-list>
}
129 \begin{describe
}{cls
}{inconsistent-merge-error (error) \&key :candidates
}
132 \begin{describe
}{gf
}{merge-error-candidates @<error> @> @<list>
}
135 \begin{describe
}{fun
}
136 {merge-lists @<lists> \&key :pick (:test \#'eql) @> @<list>
}
139 \begin{describe
}{mac
}
140 {categorize (\=@<item-var> @<items>
141 @
[[ :bind (@
{ @<var> @!
142 (@<var> @
[@<value>@
]) @
}^*) @
]])
144 (@
{ (@<cat-var> @<cat-predicate>) @
}^*) \-\\
150 \begin{describe
}{fun
}
151 {frob-identifier @<string> \&key :swap-case :swap-hyphen
152 @> @<frobbed-string>
}
155 \begin{describe
}{fun
}{whitespace-char-p @<character> @> @<generic-function>
}
158 \begin{describe
}{fun
}
159 {update-position @<character> @<line> @<column>
160 @> @<new-line> @<new-column>
}
163 \begin{describe
}{fun
}
164 {backtrack-position @<character> @<line> @<column>
165 @> @<old-line> @<old-column>
}
168 \begin{describe
}{fun
}
169 {compose @<function> \&rest @<more-functions> @> @<function>
}
172 \begin{describe
}{fun
}{symbolicate \&rest @<symbols> @> @<symbol>
}
175 \begin{describe
}{mac
}
176 {maybe-print-unreadable-object
179 :identity @<identity> @
]]) \\
\ind
184 \begin{describe
}{fun
}{print-ugly-stuff @<stream> @<func> @> @<value>^*
}
187 \begin{describe
}{mac
}
188 {dosequence (@<var> @<sequence>
189 @
[[ :start @<start> @! :end @<end> @!
190 :indexvar @<var> @
]]) \\
\ind
192 @
{ @<tag> @! @<statement> @
}^*
}
195 \begin{describe
}{mac
}
196 {define-access-wrapper @<from> @<to>
197 @
[[ :read-only @<read-only-flag> @
]]}
200 \begin{describe
}{mac
}
201 {default-slot (@<instance> @<slot> @
[@<slot-names>@
]) \\
\ind
205 \begin{describe
}{mac
}
206 {define-on-demand-slot @<class> @<slot> (@<instance>) \\
\ind
207 @
[[ @<declaration>^* @! @<doc-string> @
]] \\
211 %%%--------------------------------------------------------------------------
212 \section{Condition utilities
} \label{sec:misc.condition
}
214 These symbols are defined in the @|sod-parser| package.
216 \begin{describe
}{cls
}{enclosing-condition (condition) \&key :condition
}
220 {enclosed-condition @<enclosing-condition> @> @<condition>
}
223 \begin{describe
}{fun
}{cerror* @<datum> \&rest @<arguments>
}
226 %%%--------------------------------------------------------------------------
227 \section{Option parser
} \label{sec:misc.optparse
}
229 These symbols are defined in the @!optparse| package.
231 \begin{describe
}{fun
}{exit \&optional (@<code>
0) \&key :abrupt
}
234 \begin{describe
}{var
}{*program-name*
}
237 \begin{describe
}{var
}{*command-line*
}
240 \begin{describe
}{fun
}{set-command-line-arguments
}
243 \begin{describe
}{fun
}{moan @<format-string> \&rest @<format-args>
}
246 \begin{describe
}{fun
}{die @<format-string> \&rest @<format-args>
}
249 \begin{describe
}{var
}{*options*
}
252 \begin{describe
}{cls
}{option
}
255 \begin{describe
}{fun
}{optionp @<object> @> @<generalized-boolean>
}
258 \begin{describe
}{fun
}
259 {make-option \=@<long-name> @<short-name> \+\\
260 \&optional @<arg-name> \\
261 \&key :tag :negated-tag
262 :arg-optional-p :documentation \-
267 {\dhead{fun
}{opt-short-name @<option> @> @<character-or-null>
}
268 \dhead{fun
}{setf (opt-short-name @<option>) @<character-or-null>
}
269 \dhead{fun
}{opt-long-name @<option> @> @<string-or-null>
}
270 \dhead{fun
}{setf (opt-long-name @<option>) @<string-or-null>
}
271 \dhead{fun
}{opt-tag @<option> @> @<tag>
}
272 \dhead{fun
}{setf (opt-tag @<option>) @<tag>
}
273 \dhead{fun
}{opt-negated-tag @<option> @> @<tag>
}
274 \dhead{fun
}{setf (opt-negated-tag @<option>) @<tag>
}
275 \dhead{fun
}{opt-arg-name @<option> @> @<string-or-null>
}
276 \dhead{fun
}{setf (opt-arg-name @<option>) @<string-or-null>
}
277 \dhead{fun
}{opt-optional-p @<option> @> @<generalized-boolean>
}
278 \dhead{fun
}{setf (opt-optional-p @<option>) @<generalized-boolean>
}
279 \dhead{fun
}{opt-documentation @<option> @> @<string-or-null>
}
280 \dhead{fun
}{setf (opt-documentation @<option>) @<string-or-null>
}}
283 \begin{describe
}{cls
}{option-parser
}
286 \begin{describe
}{fun
}{option-parser-p @<object> @> @<generalized-boolean>
}
289 \begin{describe
}{fun
}
290 {make-option-parser \&key \=:args :options :non-option :numericp \+ \\
291 :negated-numeric-p long-only-p \-
292 \nlret @<option-parser>
}
296 {\dhead{fun
}{op-options @<option-parser> @> @<list>
}
297 \dhead{fun
}{setf (op-options @<option-parser>) @<list>
}
298 \dhead{fun
}{op-non-option @<option-parser> @> @<action>
}
299 \dhead{fun
}{setf (op-non-option @<option-parser>) @<action>
}
300 \dhead{fun
}{op-long-only-p @<option-parser> @> @<generalized-boolean>
}
301 \dhead{fun
}{setf (op-long-only-p @<option-parser>) @<generalized-boolean>
}
302 \dhead{fun
}{op-numeric-p @<option-parser> @> @<generalized-boolean>
}
303 \dhead{fun
}{setf (op-numeric-p @<option-parser>) @<generalized-boolean>
}
304 \dhead{fun
}{op-negated-numeric-p @<option-parser> @<generalized-boolean>
}
305 \dhead{fun
}{setf (op-negated-numeric-p @<option-parser>) @<generalized-boolean>
}
306 \dhead{fun
}{op-negated-p @<option-parser> @> @<generalized-boolean>
}
307 \dhead{fun
}{setf (op-negated-p @<option-parser>) @<generalized-boolean>
}}
310 \begin{describe
}{cls
}
311 {option-parse-error (error simple-condition)
312 \&key :format-control :format-arguments
}
315 \begin{describe
}{fun
}{option-parse-remainder @<option-parser>
}
318 \begin{describe
}{fun
}{option-parse-return @<tag> \&optional @<argument>
}
321 \begin{describe
}{fun
}{option-parse-next @<option-parser>
}
324 \begin{describe
}{mac
}{option-parse-try @<form>^*
}
327 \begin{describe
}{mac
}{with-unix-error-reporting () @<form>^*
}
330 \begin{describe
}{mac
}
331 {defopthandler @<name> (@<var> @
[@<arg>@
]) @<lambda-list> \\
\ind
332 @
[[ @<declaration>^* @! @<doc-string> @
]] \\
336 \begin{describe
}{fun
}
337 {invoke-option-handler @<handler> @<locative> @<arg> @<arguments>
}
340 \begin{describe
}{opt
}{set \&optional @<value>
}
343 \begin{describe
}{opt
}{clear \&optional @<value>
}
346 \begin{describe
}{opt
}{inc \&optional @<maximum> @<step>
}
349 \begin{describe
}{opt
}{dec \&optional <minimum> <step>
}
352 \begin{describe
}{opt
}{read
}
355 \begin{describe
}{opt
}{int \&key :radix :min :max
}
358 \begin{describe
}{opt
}{string
}
361 \begin{describe
}{opt
}{keyword \&optional @<valid>
}
364 \begin{describe
}{opt
}{list \&optional @<handler> \&rest @<handler-args>
}
367 \begin{describe
}{mac
}
368 {defoptmacro @<name> @<lambda-list> \\
\ind
369 @
[[ @<declaration>^* @! @<doc-string> @
]] \\
373 \begin{describe
}{fun
}{parse-option-form @<form>
}
376 \begin{describe
}{mac
}
377 {options @
{ \=@<string> @! \+ \\
378 @<option-macro> @! (@<option-macro> @<macro-arg>^*) @! \\
379 (@
[[ \=@<character> @! (:short-name @<character>) @! \+ \\
380 @<string>^* @! @<symbol> @! @<rational> @!
381 (:long-name @<string>) @! \\
382 (@<string> @<format-arg>^+) @!
383 (:doc @<string> @<format-arg>^*) @! \\
384 (:arg @<arg-name>) @! (:opt-arg @<arg-name>) @! \\
385 @<keyword> @! (:tag @<tag>) @!
386 (:negated-tag @<tag>) @! \\
387 @
{ (@<handler> @<var> @<handler-arg>^*) @
}^*
391 \begin{describe
}{fun
}
392 {simple-usage @<option-list> \&optional @<mandatory-args> @> @<list>
}
395 \begin{describe
}{fun
}{show-usage @<prog> @<usage> \&optional @<stream>
}
398 \begin{describe
}{fun
}
399 {show-help @<prog> @<usage> @<option-list> \&optional @<stream>
}
402 \begin{describe
}{fun
}{sanity-check-option-list @<option-list>
}
407 \dhead{var
}{*version*
}
408 \dhead{var
}{*usage*
}}
411 \begin{describe
}{fun
}{do-usage \&optional @<stream>
}
414 \begin{describe
}{fun
}{die-usage
}
417 \begin{describe
}{optmac
}
418 {help-options \&key :short-help :short-version :short-usage
}
421 \begin{describe
}{fun
}
422 {define-program \&key \=:program-name \+ \\
423 :help :version :usage :full-usage \\
427 \begin{describe
}{mac
}
428 {do-options (@
[[ :parser @<option-parser> @
]]) \\
\ind
429 @
{ (@
{ @<case> @! (@<case>^*)@
} (@
[@
[@<opt-var>@
] @<arg-var>@
])
433 %%%--------------------------------------------------------------------------
434 \section{Property sets
} \label{sec:misc.pset
}
436 \begin{describe
}{fun
}{property-key @<name> @> @<keyword>
}
439 \begin{describe
}{gf
}{decode-property @<raw-value> @> @<type> @<value>
}
442 \begin{describe
}{cls
}{property
}
445 \begin{describe
}{fun
}{propertyp @<object> @> @<generalized-boolean>
}
448 \begin{describe
}{fun
}
449 {make-property @<name> @<raw-value> \&key :type :location :seenp
}
453 {\dhead{fun
}{p-name @<property> @> @<name>
}
454 \dhead{fun
}{p-value @<property> @> @<value>
}
455 \dhead{fun
}{p-type @<property> @> @<type>
}
456 \dhead{fun
}{p-key @<property> @> @<symbol>
}
457 \dhead{fun
}{p-seenp @<property> @> @<boolean>
}
458 \dhead{fun
}{setf (p-seenp @<property>) @<boolean>
}}
461 \begin{describe
}{gf
}{decode-property @<raw-value> @> @<type> @<value>
}
465 {coerce-property-value @<value> @<type> @<wanted> @> @<coerced-value>
}
468 \begin{describe
}{cls
}{pset
}
471 \begin{describe
}{fun
}{psetp @<object> @> @<generalized-boolean>
}
474 \begin{describe
}{fun
}{make-pset @> @<pset>
}
477 \begin{describe
}{fun
}{pset-get @<pset> @<key> @> @<property-or-nil>
}
480 \begin{describe
}{fun
}{pset-store @<pset> @<property> @> @<property>
}
483 \begin{describe
}{fun
}{pset-map @<func> @<pset>
}
486 \begin{describe
}{mac
}
487 {with-pset-iterator (@<iter> @<pset>) @<declaration>^* @<form>^*
}
490 \begin{describe
}{fun
}
491 {store-property @<pset> @<name> @<value> \&key :type :location
495 \begin{describe
}{fun
}
496 {get-property @<pset> @<name> @<type> \&optional @<default>
497 @> @<value> @<floc-or-nil>
}
500 \begin{describe
}{fun
}
501 {add-property @<pset> @<name> @<value> \&key :type :location
505 \begin{describe
}{fun
}{make-property-set \&rest @<plist> @> @<pset>
}
508 \begin{describe
}{gf
}{property-set @<thing> @> @<pset>
}
511 \begin{describe
}{fun
}{check-unused-properties @<pset>
}
514 \begin{describe
}{mac
}
515 {default-slot-from-property
516 (@<instance> @<slot> @
[@<slot-names>@
]) \\
\ind\ind
517 (@<pset> @<property> @<type> @
[@<prop-var> @<convert-form>^*@
]) \- \\
522 \begin{describe
}{fun
}
523 {parse-property-set @<scanner>
524 @> @<result> @<success-flag> @<consumed-flag>
}
527 %%%--------------------------------------------------------------------------
528 \section{Miscellaneous translator features
} \label{sec:misc.pset
}
530 \begin{describe
}{var
}{*sod-version*
}
533 \begin{describe
}{var
}{*debugout-pathname*
}
536 \begin{describe
}{fun
}{test-module @<path> @<reason>
}
539 \begin{describe
}{fun
}
540 {test-parse-c-type @<string>
541 @> t @<c-type> @<kernel> @<string> @! nil @<indicator>
}
544 \begin{describe
}{mac
}
545 {test-parser (@<scanner>) @<parser> @<input>
546 @> @<success-flag> @<result> @<remainder>
}
549 \begin{describe
}{fun
}{exercise
}
552 \begin{describe
}{fun
}{sod-frontend:main
}
555 %%%----- That's all, folks --------------------------------------------------
559 %%% TeX-master: "sod.tex"