chiark / gitweb /
sod
5 years agosrc/class-output.lisp: Fix missing parentheses around `me' in message macros.
Mark Wooding [Tue, 15 May 2018 10:04:53 +0000 (11:04 +0100)]
src/class-output.lisp: Fix missing parentheses around `me' in message macros.

What was I thinking?

5 years agodoc/concepts.tex: Fix garbled fragment ordering rules.
Mark Wooding [Tue, 15 May 2018 09:49:05 +0000 (10:49 +0100)]
doc/concepts.tex: Fix garbled fragment ordering rules.

5 years agodoc/runtime.tex: Fix name of `SOD_XCHAIN' macro.
Mark Wooding [Tue, 15 May 2018 09:48:23 +0000 (10:48 +0100)]
doc/runtime.tex: Fix name of `SOD_XCHAIN' macro.

The index entry was right, but the synopsis showed the wrong name.

5 years agodoc/structures.tex, lib/sod-structs.3: Fix in-chain ichain exemplar.
Mark Wooding [Tue, 15 May 2018 09:46:00 +0000 (10:46 +0100)]
doc/structures.tex, lib/sod-structs.3: Fix in-chain ichain exemplar.

The general ichain structure is for some superclass on the same chain,
but not necessarily the chain head.  The later prose already has this
right, but the synopsis at the beginning of the section didn't.

5 years agosrc/optparse.lisp: Indent a line correctly.
Mark Wooding [Tue, 15 May 2018 09:45:35 +0000 (10:45 +0100)]
src/optparse.lisp: Indent a line correctly.

5 years agotest/test.sod: Abbreviate the T1 class nicknames.
Mark Wooding [Wed, 2 Aug 2017 19:53:31 +0000 (20:53 +0100)]
test/test.sod: Abbreviate the T1 class nicknames.

They don't actually need to have `t1' in them.

5 years agosrc/method-impl.lisp: Mark `sod__obj' as ignorable in effective methods.
Mark Wooding [Wed, 2 Aug 2017 11:25:34 +0000 (12:25 +0100)]
src/method-impl.lisp: Mark `sod__obj' as ignorable in effective methods.

Very trivial effective methods don't need this, and the warnings are
annoying.

5 years agosrc/method-aggregate.lisp: Allow useful behaviour if no primary methods.
Mark Wooding [Wed, 2 Aug 2017 10:00:39 +0000 (11:00 +0100)]
src/method-aggregate.lisp: Allow useful behaviour if no primary methods.

Many aggregating combinations have obvious things to do even if they
have no primary methods; e.g., `progn' should do nothing, and
combinations based on operators with identity should return that
identity.  This actually covers all of them except `min' and `max'.

5 years agodoc/intro.tex: Begin a (rather extensive) comparison with C++.
Mark Wooding [Wed, 2 Aug 2017 09:59:28 +0000 (10:59 +0100)]
doc/intro.tex: Begin a (rather extensive) comparison with C++.

I think this doesn't fit well here, but these things need saying
somewhere.

5 years agodoc/Makefile.am, doc/sod.tex: Actually include the stub intro.
Mark Wooding [Wed, 2 Aug 2017 09:58:56 +0000 (10:58 +0100)]
doc/Makefile.am, doc/sod.tex: Actually include the stub intro.

5 years agodoc/intro.tex: Fix erroneous `\manpage' to correct `\man'.
Mark Wooding [Wed, 2 Aug 2017 09:58:11 +0000 (10:58 +0100)]
doc/intro.tex: Fix erroneous `\manpage' to correct `\man'.

5 years agodoc/concepts.tex: Include diagram of standard method combination.
Mark Wooding [Wed, 2 Aug 2017 09:57:31 +0000 (10:57 +0100)]
doc/concepts.tex: Include diagram of standard method combination.

5 years agodoc/Makefile.am: Enable `\nonstopmode' in TeX processing.
Mark Wooding [Wed, 2 Aug 2017 09:56:29 +0000 (10:56 +0100)]
doc/Makefile.am: Enable `\nonstopmode' in TeX processing.

Now the build doesn't grind to a halt because I've upset TeX again.

5 years agodoc/Makefile.am: Abstract out repeated TeX arguments into a variable.
Mark Wooding [Wed, 2 Aug 2017 09:55:51 +0000 (10:55 +0100)]
doc/Makefile.am: Abstract out repeated TeX arguments into a variable.

5 years agodoc/structures.tex: Fix variable reuse in keyword-args message signature.
Mark Wooding [Wed, 2 Aug 2017 09:52:35 +0000 (10:52 +0100)]
doc/structures.tex: Fix variable reuse in keyword-args message signature.

I had `m' as both the message name and the total number of arguments.

5 years agodoc/concepts.tex: Warn about allocating resources in init methods.
Mark Wooding [Wed, 2 Aug 2017 09:52:06 +0000 (10:52 +0100)]
doc/concepts.tex: Warn about allocating resources in init methods.

5 years agodoc/concepts.tex: Fix missing superclass in a code example.
Mark Wooding [Wed, 2 Aug 2017 09:51:22 +0000 (10:51 +0100)]
doc/concepts.tex: Fix missing superclass in a code example.

5 years agodoc/concepts.tex: Fix copy-and-paste fail in `Destruction' section.
Mark Wooding [Wed, 2 Aug 2017 09:50:40 +0000 (10:50 +0100)]
doc/concepts.tex: Fix copy-and-paste fail in `Destruction' section.

5 years agodoc/concepts.tex: Update `Slot initializers', about class initialization.
Mark Wooding [Wed, 2 Aug 2017 09:48:54 +0000 (10:48 +0100)]
doc/concepts.tex: Update `Slot initializers', about class initialization.

The old initialization function has been replaced by a message.

5 years agodoc/concepts.tex: A number of minor fixes.
Mark Wooding [Wed, 2 Aug 2017 09:44:02 +0000 (10:44 +0100)]
doc/concepts.tex: A number of minor fixes.

  * Insert a missing paren.

  * Insert missing space after `\Cplusplus'.

  * Hyphenate `pointer-to-class-type' in the description of conversions,
    because it's easy to mis-associate otherwise.

  * Fix erroneous (probably copy-and-paste) `upcast' to `downcast'.

  * Improve wording about failing downcasts.

5 years agosrc/optparse.lisp: Use low-level slot accessor in `option' printer.
Mark Wooding [Wed, 2 Aug 2017 09:41:05 +0000 (10:41 +0100)]
src/optparse.lisp: Use low-level slot accessor in `option' printer.

If I try to use the access wrapper, I get compiler warnings about how
the previous use of the function wasn't inlined; but if I declare the
wrapper earlier then it might not inline anything.  The printer is
rarely used, so this isn't a bad place to be.

5 years agosrc/class-make-impl.lisp: Introduce property to choose initarg class.
Mark Wooding [Wed, 2 Aug 2017 09:40:14 +0000 (10:40 +0100)]
src/class-make-impl.lisp: Introduce property to choose initarg class.

This is now uniform, at least.

5 years agodoc/syntax.tex: Describe the built-in properties for objects.
Mark Wooding [Wed, 2 Aug 2017 09:32:40 +0000 (10:32 +0100)]
doc/syntax.tex: Describe the built-in properties for objects.

All a bit rough, but at least there's a place to write this stuff down
now.

5 years agodoc/syntax.tex: Give cross-ref to (stub) metaclass section.
Mark Wooding [Wed, 2 Aug 2017 09:31:36 +0000 (10:31 +0100)]
doc/syntax.tex: Give cross-ref to (stub) metaclass section.

Fixes a fixme.

5 years agoVarious, style: Generally prefer `: ' over ` : '.
Mark Wooding [Wed, 2 Aug 2017 09:29:28 +0000 (10:29 +0100)]
Various, style: Generally prefer `: ' over ` : '.

Before subclass lists, output constraints, and bitfield widths.  Retain
` : ' in conditional expressions to match ` ? ' which I don't want to
change, at least for now.

5 years agodoc/: Work in progress.
Mark Wooding [Mon, 14 Dec 2015 17:51:53 +0000 (17:51 +0000)]
doc/: Work in progress.

5 years agodoc/refintro.tex: Introduction to reference section.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/refintro.tex: Introduction to reference section.

This is the start of a major reorganization of the reference material.

5 years agodoc/stdmeth.tex: A TikZ diagram of the standard method combination.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/stdmeth.tex: A TikZ diagram of the standard method combination.

For safekeeping.  Remove the old (Lisp-specific) SVG version now that we
don't need it any more.

5 years agodoc/structures.tex, lib/sod-structs.3: Justify union $C$__ichainu_$h$.
Mark Wooding [Fri, 8 Jun 2018 18:31:04 +0000 (19:31 +0100)]
doc/structures.tex, lib/sod-structs.3: Justify union $C$__ichainu_$h$.

5 years agodoc/structures.tex: Remove spurious line breaks in the source.
Mark Wooding [Fri, 8 Jun 2018 18:30:26 +0000 (19:30 +0100)]
doc/structures.tex: Remove spurious line breaks in the source.

Debris from copying from the troff(1) source.

5 years agolib/sod-structs.3: Move the definition of type $C$ somewhere more sensible.
Mark Wooding [Fri, 8 Jun 2018 18:28:54 +0000 (19:28 +0100)]
lib/sod-structs.3: Move the definition of type $C$ somewhere more sensible.

Now it's just after where we explain struct $C$__ichain_$h$, which is
where the similar text in the LaTeX manual is.

5 years agolib/sod-structs.3: Fix misnamed `struct SodClass__ilayout'.
Mark Wooding [Fri, 8 Jun 2018 18:27:50 +0000 (19:27 +0100)]
lib/sod-structs.3: Fix misnamed `struct SodClass__ilayout'.

5 years agolib/keyword.h: Some minor fixes to comments.
Mark Wooding [Thu, 7 Jun 2018 17:50:26 +0000 (18:50 +0100)]
lib/keyword.h: Some minor fixes to comments.

Delete some stray spaces, and fix some mangled English.

6 years agodoc/syntax.tex, src/sod-module.5: Add missing `<TYPE>' expression syntax.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/syntax.tex, src/sod-module.5: Add missing `<TYPE>' expression syntax.

6 years agodoc/syntax.tex, src/sod-module.5: Abstract out <plain-type> nonterminal.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/syntax.tex, src/sod-module.5: Abstract out <plain-type> nonterminal.

6 years agodoc/parsing.tex: Document missing `:ignore-unconsumed' flag to `error'.
Mark Wooding [Sun, 5 Jun 2016 22:08:08 +0000 (23:08 +0100)]
doc/parsing.tex: Document missing `:ignore-unconsumed' flag to `error'.

6 years agodoc/structures.tex, lib/sod-structs.3: Define variable `M'.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/structures.tex, lib/sod-structs.3: Define variable `M'.

Oops.

6 years agodoc/{misc,parsing}.tex: Write <form> rather than <body-form>.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/{misc,parsing}.tex: Write <form> rather than <body-form>.

6 years agodoc/{runtime,structures}.tex: Fix careless transfer from the manpages.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/{runtime,structures}.tex: Fix careless transfer from the manpages.

6 years agodoc/meta.tex: Fix nonterminal `<...>' to `@<...>'.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/meta.tex: Fix nonterminal `<...>' to `@<...>'.

6 years agodoc/: Align backslashes in C-macros by the right-hand margin.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/: Align backslashes in C-macros by the right-hand margin.

Do this in the source, and in the typeset code.

6 years agodoc/: Align layout control commands to right margin in `tabbing' etc.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/: Align layout control commands to right margin in `tabbing' etc.

This is mostly clean in `--word-diff'.  Here are the exceptions.

  * doc/parsing.tex: `--word-diff' gets confused around the various
    `condition-with-location' subclasses.  This is clean in `-b', so
    there's not actually anything complicated happening here.

  * doc/parsing.tex: I've sneakily removed a pointless trailing `%'.

  * doc/runtime.tex: I've inserted a couple of linebreaks with `%' so as
    to shorten the source-file lines.

  * doc/runtime.tex: Some `\-' have harmlessly moved past `@\\' macro-
    backslashes to take their proper places on the right margin.

6 years agodoc/sod.sty: Typeset code upright, even if surrounding text is italic.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/sod.sty: Typeset code upright, even if surrounding text is italic.

6 years agodoc/output.tex: Add the `user' and `early-user' output items to comment.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/output.tex: Add the `user' and `early-user' output items to comment.

6 years agodoc/sod.sty, doc/runtime.tex: Improve comment typesetting in code.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/sod.sty, doc/runtime.tex: Improve comment typesetting in code.

  * Don't typeset the initial `;' as commentary; handle multiple initial
    `;;' in sequence.

  * Add new commands for general inside-comment typesetting, and for
    C-style `/* ... */' comments.  Maybe there should be a thing for
    C++-style comments, but I don't tend to use them anyway.

  * Highlight code text in commentary.

6 years agodoc/parsing.tex: Fix awful inconsistency in indentation.
Mark Wooding [Sat, 22 Jul 2017 15:48:33 +0000 (16:48 +0100)]
doc/parsing.tex: Fix awful inconsistency in indentation.

Somehow the descriptions of the various condition classes ended up all
over the place.

6 years agodoc/syntax.tex: Replace `listing' environments with `prog'.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/syntax.tex: Replace `listing' environments with `prog'.

6 years agodoc/syntax.tex: Mention superclass list is mandatory.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/syntax.tex: Mention superclass list is mandatory.

And discuss the difficulties of actually defining new root classes.

6 years agodoc/runtime.tex: Remove stray space between `*' and its operand.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/runtime.tex: Remove stray space between `*' and its operand.

6 years agodoc/syntax.tex: Fix wording error in description of <one-or-more>.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/syntax.tex: Fix wording error in description of <one-or-more>.

Probably a cut-and-paste mistake.

6 years agodoc/list-exports.lisp, doc/SYMBOLS: Report on condition classes.
Mark Wooding [Sun, 26 Mar 2017 09:01:28 +0000 (10:01 +0100)]
doc/list-exports.lisp, doc/SYMBOLS: Report on condition classes.

Unfortunately, they don't have a well-defined metaclass, but we can dig
it out anyway.

6 years agodoc/list-exports.lisp, doc/SYMBOLS: Mark methods with their qualifiers.
Mark Wooding [Sun, 26 Mar 2017 09:16:34 +0000 (10:16 +0100)]
doc/list-exports.lisp, doc/SYMBOLS: Mark methods with their qualifiers.

6 years agodoc/list-exports.lisp: Insert correct Emacs dropping.
Mark Wooding [Sun, 2 Apr 2017 15:16:58 +0000 (16:16 +0100)]
doc/list-exports.lisp: Insert correct Emacs dropping.

6 years agodoc/list-exports.lisp: Relatively mild changes for ASDF3.
Mark Wooding [Sat, 8 Jul 2017 23:45:24 +0000 (00:45 +0100)]
doc/list-exports.lisp: Relatively mild changes for ASDF3.

I can't be bothered to support ASDF2 still, since this is only a tool
for people actually hacking on SOD, to try to keep the documentation
approximately in line with the code.

6 years agosrc/optparse.lisp, src/classes.lisp: Don't leak slot names.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/optparse.lisp, src/classes.lisp: Don't leak slot names.

This were the last slot-name leaks.  Yay!

6 years agosrc/lexer-proto.lisp (lexer-error): Fix spin from bad `format' string.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/lexer-proto.lisp (lexer-error): Fix spin from bad `format' string.

What should have been the `else' branch of the hairy list presentation
said `~;:' instead of `~:;', with the result that if there are four or
more expected character sequences, no branch of the conditional matches,
and the loop body doesn't consume any items so it spins forever.

6 years agosrc/c-types-impl.lisp: Fix name of `wchar_t'.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/c-types-impl.lisp: Fix name of `wchar_t'.

Not sure how this ended up being wrong.

6 years agosrc/class-output.lisp (find-class-initializer): Use correct keyword.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/class-output.lisp (find-class-initializer): Use correct keyword.

This is a silly typo which persisted because the class-initializer
machinery hasn't been tested much yet.

6 years agosrc/parser/floc-proto.lisp: Restore missing argument.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/parser/floc-proto.lisp: Restore missing argument.

This code path was clearly never exercised.

6 years agosrc/method-proto.lisp (make-trampoline): Ignore unused keyword pointers.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/method-proto.lisp (make-trampoline): Ignore unused keyword pointers.

If we're not going to need a keyword pointer (because the applicable
methods have no keyword arguments) then ignore it explicitly.  (We can't
just omit the arguments, because direct-method functions may have to
work as part of an effective method which /does/ have keyword arguments
-- maybe even downstream -- and the trampoline functions must have the
same signature either way.)

6 years agosrc/method-proto.lisp (invoke-delegation-chain): Pass keyword args correctly.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/method-proto.lisp (invoke-delegation-chain): Pass keyword args correctly.

It's not correct to commit to `&sod__kw' or `sod__kw' for the entire
chain.  Typically, the first method gets called with `&sod__kw', but the
rest want plain `sod__kw'.

6 years agosrc/method-proto.lisp: Set `*keyword-struct-disposition*' properly.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/method-proto.lisp: Set `*keyword-struct-disposition*' properly.

No idea where this one came from.

6 years agolib/sod.h: Fix bungled varargs support macro.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
lib/sod.h: Fix bungled varargs support macro.

6 years agovars.am: Tweak `silent-rules' machinery.
Mark Wooding [Sun, 9 Jul 2017 01:00:52 +0000 (02:00 +0100)]
vars.am: Tweak `silent-rules' machinery.

Since Automake 1.11, the advice for setting up custom silent-rules
recipes has changed, so use the new machinery.

Also, I'm no longer mainly working on wheezy, and Automake has made the
operation field two spaces wider while I wasn't looking, so make the
output line up properly.

This means that SOD now requires Automake 1.11.2 or later to build from
the Git tree.

7 years agodebian/rules: Cope with `sbuild', which sets a fake home directory.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
debian/rules: Cope with `sbuild', which sets a fake home directory.

7 years agodebian/libsod-dev.install: Fix name of manpage.
Mark Wooding [Sun, 29 May 2016 15:32:47 +0000 (16:32 +0100)]
debian/libsod-dev.install: Fix name of manpage.

7 years agotest/Makefile.am: Distribute the test program source.
Mark Wooding [Sun, 29 May 2016 15:30:23 +0000 (16:30 +0100)]
test/Makefile.am: Distribute the test program source.

7 years agoMerge branches 'mdw/kwargs' and 'mdw/c11'
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
Merge branches 'mdw/kwargs' and 'mdw/c11'

* mdw/kwargs: (29 commits)
  New feature: initialization keyword arguments.
  src/method-{proto,impl}.lisp: New `method-keyword-argument-lists' protocol.
  New feature: proper object lifecycle protocol; init and teardown fragments.
  src/builtin.lisp: Bind `me' around slot initializers, and define the order.
  Replace the `init' class-slot function with an `init' message.
  Compatibility: the `init' function no longer calls `imprint' for you.
  src/method-{proto,impl}.lisp: Introduce `effective-method-live-p' protocol.
  doc/runtime.tex, lib/sod.3: Restructure the runtime library reference.
  doc/concepts.tex: Reorganize the instance lifecycle material.
  doc/: Miscellaneous clarifications and rewordings.
  doc/concepts.tex: Don't highlight `primary' as literal, because it's not.
  src/: Abolish the distinction between different kinds of initializers.
  src/method-{proto,impl}.lisp: Abolish `sod-message-no-varargs-tail'.
  New feature: messages with keyword arguments!
  lib/: Pure C machinery for handling `keyword arguments' to functions.
  doc/runtime.tex: Demote the object-system support stuff to a section.
  src/c-types-*.lisp: New type for functions which take keyword arguments.
  src/c-types-parse.lisp (parse-declarator): Refactor argument list parsing.
  src/c-types-parse.lisp (parse-declarator): Explain how it works.
  src/: New function `reify-variable-argument-tail'.
  ...

* mdw/c11:
  src/c-types-impl.lisp, src/c-types-parse.lisp: Support C11 `_Alignas'.
  src/c-types-{proto,impl,parse}.lisp: Add `storage specifiers' to the model.
  src/c-types-{impl,parse}.lisp: Support C11 `_Atomic'.
  src/c-types-{impl,parse}.tex: Support `_Atomic' types.
  src/c-types-parse.lisp: Introduce a pluggable parser for declspecs.
  src/c-types-parse.lisp: Hoist up the `ds-FOO' methods for raw types.
  src/c-types-parse.lisp: Improve handling of compatibility keywords.
  src/final.lisp: Add function for interactively testing type parsing.
  src/c-types-proto.lisp, src/c-types-impl.lisp: Qualifier name protocol.
  src/module-parse.lisp (parse-raw-class-item): Commit after declarator.
  Add a new class slot `align', holding the instance layout alignment.
  src/c-types-impl.lisp (make-or-intern-c-type): Pull out useful function.
  src/c-types-parse.lisp, src/c-types-proto.lisp: Some minor cleanups.
  src/parser/parser-proto.lisp: Add functions returning standard parsers.
  src/parser/: Allow parsers to commit to a parse while peeking.
  doc/clang.tex: Improve documentation of C type spec expansion.

Conflicts:
doc/SYMBOLS (regenerated)
doc/syntax.tex (hand-merge; extra parameter to <declarator>)
lib/sod.h (simple hand-merge)
src/sod-module.5 (extra parameter to <declarator>, added by hand)

7 years agosrc/c-types-impl.lisp, src/c-types-parse.lisp: Support C11 `_Alignas'.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/c-types-impl.lisp, src/c-types-parse.lisp: Support C11 `_Alignas'.

7 years agosrc/c-types-{proto,impl,parse}.lisp: Add `storage specifiers' to the model.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/c-types-{proto,impl,parse}.lisp: Add `storage specifiers' to the model.

A slightly unusual kind of thing.  This is intended to capture things
like storage classes and similar which are determinedly `top level',
unlike qualifiers which stay attached to the base type in the presence
of declarator operators.

Storage specifiers are attached to a special carrier type
`c-storage-specifiers-type' (with all of the necessary trimmings), and
there is new machinery (`wrap-c-type') to arrange that this stays at the
outermost level when deriving new types from existing ones.

There is a pile of additional protocol, mostly mirroring the main types
protocol, for dealing with storage-specifier syntax, in both Lisp and C.

7 years agosrc/c-types-{impl,parse}.lisp: Support C11 `_Atomic'.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/c-types-{impl,parse}.lisp: Support C11 `_Atomic'.

This change adds support for both the `_Atomic' type qualifier and the
`_Atomic(...)' type specifier.

7 years agoNew feature: initialization keyword arguments.
Mark Wooding [Tue, 15 Dec 2015 19:15:23 +0000 (19:15 +0000)]
New feature: initialization keyword arguments.

Initialization keyword arguments can now be declared in class
definitions.  They become additional keyword arguments accepted by the
object's `init' effective method.  The initialization arguments are
available for use (by name) within slot initializer expressions and
initialization fragments.

  * `User' initargs are otherwise passive.  They may usefully have a
    default value, which is used if the argument is
    omitted.  (Alternatively, user code can test the `suppliedp' flag
    and behave accordingly.)

  * `Slot' initargs are associated with an effective slot.  If one of a
    slot's initargs is provided in the `init' message, then its value is
    used to initialize the slot, instead of the slot initializer.  If
    more than one applicable initarg is provided, then priority is given
    to the initargs defined in more specific superclasses; if this
    doesn't disambiguate, then one of the initargs is chosen
    arbitrarily (this situation is likely an error).

7 years agosrc/method-{proto,impl}.lisp: New `method-keyword-argument-lists' protocol.
Mark Wooding [Tue, 5 Jan 2016 22:43:47 +0000 (22:43 +0000)]
src/method-{proto,impl}.lisp: New `method-keyword-argument-lists' protocol.

In case method classes want to introduce keyword arguments from
somewhere other than the obvious direct methods, there's now a separate
bit of protocol for determining the lists of keyword arguments which
need to be merged together.

7 years agoNew feature: proper object lifecycle protocol; init and teardown fragments.
Mark Wooding [Tue, 15 Dec 2015 19:15:23 +0000 (19:15 +0000)]
New feature: proper object lifecycle protocol; init and teardown fragments.

A class definition may contain fragments of C code for initialization
and teardown.  Initialization fragments are invoked from the default
`init' message behaviour, in least-to-most specific order, immediately
after initializing the corresponding class's direct slots (if any);
teardown fragments are included in the default behaviour of a new
`teardown' message, in most-to-least specific order.

Now that we have initialization and teardown, we can implement more
useful object lifecycle functionality around them, e.g., dealing with
dynamically allocated objects.  Appropriate new definitions have been
added to the library.

7 years agosrc/builtin.lisp: Bind `me' around slot initializers, and define the order.
Mark Wooding [Tue, 15 Dec 2015 19:15:23 +0000 (19:15 +0000)]
src/builtin.lisp: Bind `me' around slot initializers, and define the order.

Previously, the `init' method kernel (and the `init' class-slot function
before that) initialized one chain at a time, then down the chains,
because this made for a convenient traversal of the class layout.  But
it sucks for users.

Make this better.  Bind `me' around slot initializers -- to the type of
the direct slot.  This means that initializers can compute their values
based on other previously initialized slots, which is useful because
subclasses can override initializers for their superclasses.

The `me' pointer has the type of the class owning the direct slots being
initialized, which means that referring to substructure belonging to
classes other than the superclasses of the slot owner is hard, even if
the initializer can be sure (because it was defined on some subclass)
that those other classes are available.  This is nonetheless the right
thing because (a) it means that the `me' pointer has a reliable type,
and (b) the slots belonging any other classes which might be of interest
won't have been initialized by this point.

Take the opportunity to clarify the documentation regarding slot
initialization generally.

7 years agoReplace the `init' class-slot function with an `init' message.
Mark Wooding [Tue, 15 Dec 2015 19:15:23 +0000 (19:15 +0000)]
Replace the `init' class-slot function with an `init' message.

The `SodObject' class now defines an `init' message.  This message takes
keywords, which can be collected by methods and used to set up objects
in interesting ways.

The `init' message's default behaviour (unless overridden by a primary
or around method) is to initialize the instance's slots using the most
specific applicable initializers, just as the old `init' function used
to do.

Obviously, one can send an `init' message to an instance before it's
been imprinted, so that has to be done as a separate step now.  The
`SOD_DECL' macro has been adjusted to cope.  It also takes an additional
argument containing keyword arguments to be passed with the `init'
message (which constitutes an additional compatibility break).

The library has grown a new pair of functions `sod_init' and `sod_initv'
which wrap up the initialization protocol, and a macro `SOD_INIT' which
improves type safety a little.

(Some of the new code in `src/builtin.lisp' is a little odd.  This is
intended to accommodate future changes better.)

7 years agoCompatibility: the `init' function no longer calls `imprint' for you.
Mark Wooding [Sat, 7 May 2016 13:45:18 +0000 (14:45 +0100)]
Compatibility: the `init' function no longer calls `imprint' for you.

It will make much less sense later.

7 years agosrc/method-{proto,impl}.lisp: Introduce `effective-method-live-p' protocol.
Mark Wooding [Tue, 15 Dec 2015 19:15:23 +0000 (19:15 +0000)]
src/method-{proto,impl}.lisp: Introduce `effective-method-live-p' protocol.

Previously, the `compute-method-entry-functions' method defined on
`simple-effective-method' would bail out early if there were no primary
methods.  This is unsatisfactory: subclasses of `simple-effective-
method' might want to introduce more complicated method combination
machinery.

Make this a proper part of the protocol: introduce `effective-method-
live-p', which gets to decide whether to make method-entry functions or
just leave the vtable pointers null.  Now `simple-effective-method' can
decide, in the same way, to suppress the method entries based on the
existence of primary methods, but subclasses can apply more (or less)
subtle policy.

7 years agodoc/runtime.tex, lib/sod.3: Restructure the runtime library reference.
Mark Wooding [Tue, 15 Dec 2015 19:15:23 +0000 (19:15 +0000)]
doc/runtime.tex, lib/sod.3: Restructure the runtime library reference.

Reorder the descriptions of the various macros and functions along more
useful thematic lines.  Some of the sections are currently a bit thin
but they'll fill out later.

Mostly this is just moving text about, but some edits have been made.
Most significantly, `SOD_CONVERT' and `sod_convert' are now discussed
together rather than separately.

7 years agodoc/concepts.tex: Reorganize the instance lifecycle material.
Mark Wooding [Tue, 15 Dec 2015 19:15:23 +0000 (19:15 +0000)]
doc/concepts.tex: Reorganize the instance lifecycle material.

Promote it to its own section and overhaul the text ready for further
improvements.

7 years agodoc/: Miscellaneous clarifications and rewordings.
Mark Wooding [Sat, 7 May 2016 14:32:51 +0000 (15:32 +0100)]
doc/: Miscellaneous clarifications and rewordings.

7 years agodoc/concepts.tex: Don't highlight `primary' as literal, because it's not.
Mark Wooding [Sat, 7 May 2016 09:56:54 +0000 (10:56 +0100)]
doc/concepts.tex: Don't highlight `primary' as literal, because it's not.

7 years agosrc/: Abolish the distinction between different kinds of initializers.
Mark Wooding [Tue, 5 Jan 2016 19:18:55 +0000 (19:18 +0000)]
src/: Abolish the distinction between different kinds of initializers.

It made parsing difficult, both because the kind and value needed to be
carted about together, and just technically because of `scan-c-fragment'
interacts badly with token-level lookahead.

Against that, the formatting benefits are very slim, and more so when
one considers that there are ugly `#line' markers around the value
fragment.

So, the distinction is gone; there are no more `value-kind' slots or
arguments; and the `value-form' is now just plain `value'.

This is a fairly straightforward change (except for the radical
simplification of the `parse-initializer' function, which hardly needs
to exist any more), but somewhat far-reaching.

7 years agosrc/method-{proto,impl}.lisp: Abolish `sod-message-no-varargs-tail'.
Mark Wooding [Wed, 16 Dec 2015 10:43:47 +0000 (10:43 +0000)]
src/method-{proto,impl}.lisp: Abolish `sod-message-no-varargs-tail'.

This was promised earlier.  All but one of the callers of this method
were lost during the introduction of keyword-argument messages, and it
doesn't seem worth keeping this corner of the method protocol just for
that.

7 years agoNew feature: messages with keyword arguments!
Mark Wooding [Tue, 15 Dec 2015 19:15:23 +0000 (19:15 +0000)]
New feature: messages with keyword arguments!

Let's start with the new functionality.

You can define messages which are meant to be given keyword arguments,
and methods which retrieve and (presumably) act on those keywords.  The
behaviour is as in Common Lisp: the acceptable keywords for a message
sent to an object are precisely those keywords acceptable to any
applicable method, and those listed in the message definition itself.

The Sod translator takes care of picking keyword argument lists apart
and passing actual arguments to the direct methods; arguments can have
default values (and each direct method can have different defaults),
and/or find out whether a keyword was actually provided.  The only picky
rule is that if two methods (or a method and the message itself) each
define an argument with the same keyword, then those arguments must also
have the same type.

The new code -- and there's quite a lot of it -- mostly concerns itself
with coping with messages and methods which accept keyword arguments,
and generating the proper functions and instructions for gathering them
and passing them about.  This is rather annoying and fiddly.

In particular, it seems as if I ought to be able to have factored the
existing machinery much better than I actually did if only I were more
clever, so that this new stuff could slot in neatly; instead, it looks
as if I just turned the program upside-down and shook hard, which is
pretty accurate really.

7 years agolib/: Pure C machinery for handling `keyword arguments' to functions.
Mark Wooding [Sun, 10 Jan 2016 13:51:04 +0000 (13:51 +0000)]
lib/: Pure C machinery for handling `keyword arguments' to functions.

The new `keyword.h' header file defines a bunch of (somewhat nasty)
macros which allow one to define, parse, pass, and access things which
look a bit like Common Lisp's keyword arguments.  There are a few
support functions, mostly for reporting errors.

7 years agodoc/runtime.tex: Demote the object-system support stuff to a section.
Mark Wooding [Sat, 2 Jan 2016 15:29:23 +0000 (15:29 +0000)]
doc/runtime.tex: Demote the object-system support stuff to a section.

There will be more sections later.

7 years agosrc/c-types-*.lisp: New type for functions which take keyword arguments.
Mark Wooding [Sun, 10 Jan 2016 13:51:04 +0000 (13:51 +0000)]
src/c-types-*.lisp: New type for functions which take keyword arguments.

This commit introduces a new `c-keyword-function-type', including
printing and parsing the things, and some utilities for working with
keyword argument lists (most notably merging them while providing useful
diagnostics about type mismatches).  This involves enhancing the
`argument' type to include an optional default value.

The surface syntax uses a `?' to separate the preceding mandatory
positional arguments from the following optional keyword arguments.  I'm
not completely thrilled by this choice, but I can't see many better
options.  The corresponding use of a `:keys' marker in the S-expression
syntax is also somewhat ugly (especially the way that `make-function-
type' acts on it), but better choices seemed thin on the ground.

An earlier experiment introduced a `keyword-argument' subclass, rather
than enhancing the existing `argument' structure, but it made many
things (e.g., commentifying argument lists) unnecessarily painful for
little benefit -- especially when I realised that it's important to
distinguish an ordinary function from one which notionally accepts
keyword arguments but doesn't actually define any (yet).

7 years agosrc/c-types-parse.lisp (parse-declarator): Refactor argument list parsing.
Mark Wooding [Wed, 16 Dec 2015 05:57:20 +0000 (05:57 +0000)]
src/c-types-parse.lisp (parse-declarator): Refactor argument list parsing.

The `argument-list' parser is now less monolithic: the work of parsing
individual arguments is given to new functions `arg-decl' and
`argument'.

Also, the interface between `argument-list' and its parent
`postfix-lparen' is changed.  Instead of simply returning its argument
list, `argument-list' now returns a function which can be applied to a
base type to produce the appropriate function type.

None of this changes any externally observable behaviour.

7 years agosrc/c-types-parse.lisp (parse-declarator): Explain how it works.
Mark Wooding [Wed, 16 Dec 2015 05:49:38 +0000 (05:49 +0000)]
src/c-types-parse.lisp (parse-declarator): Explain how it works.

It's a little confusing, even to me.

7 years agosrc/: New function `reify-variable-argument-tail'.
Mark Wooding [Wed, 16 Dec 2015 04:03:46 +0000 (04:03 +0000)]
src/: New function `reify-variable-argument-tail'.

This does the work behind `sod-message-no-varargs-tail' (only I've
simplified it by using `substitute' rather than pointlessly doing the
work by hand like an idiot).

Heads up: `sod-message-no-varargs-tail' is going to be abolished
entirely soon.

7 years agosrc/: Factor out common machinery in `check-method-type' methods.
Mark Wooding [Wed, 16 Dec 2015 02:18:38 +0000 (02:18 +0000)]
src/: Factor out common machinery in `check-method-type' methods.

The checking logic and error messages were partially duplicated in the
various methods.  Clean this mess up because that's just bad form (and
because it's about to change).

This also clears up a minor bug in the method on `aggregating-message',
which used to report a confusing error message if the method return type
wasn't what it was expecting.

7 years agosrc/method-impl.lisp: Abolish the `emf-entry-tail' variable.
Mark Wooding [Tue, 15 Dec 2015 17:13:38 +0000 (17:13 +0000)]
src/method-impl.lisp: Abolish the `emf-entry-tail' variable.

It's not different from `entry-args'.

7 years agosrc/: Make pretty-printing better at handling tight margins.
Mark Wooding [Tue, 15 Dec 2015 18:31:42 +0000 (18:31 +0000)]
src/: Make pretty-printing better at handling tight margins.

Insert some more newlines, and make existing ones less miserly.  Also,
make sure margins are set before the newlines, rather than after.

Printing for `var' is lightly hacked to allow a break before the
initializer.

7 years agosrc/c-types-impl.lisp: Refactor pretty-printing of function types.
Mark Wooding [Tue, 15 Dec 2015 18:29:49 +0000 (18:29 +0000)]
src/c-types-impl.lisp: Refactor pretty-printing of function types.

This will pay off later.  Even now, it's a bit easier to read.

If you pay attention, you'll notice that there's an extra logical block
around the argument list which doesn't seem to do anything very useful.
That too will pay off later.  Nothing else has actually changed yet.

7 years agosrc/codegen-proto.lisp: New instruction types `cond' and `for',
Mark Wooding [Wed, 16 Dec 2015 07:39:30 +0000 (07:39 +0000)]
src/codegen-proto.lisp: New instruction types `cond' and `for',

The `cond' instruction makes a ternary conditional expression of the
`COND ? CONSEQ : ALT' variety.

The `for' instruction makes one of C's fancy loops.

Maybe the format strings are interesting.

7 years agosrc/: Add commentary to the generated code.
Mark Wooding [Tue, 5 Jan 2016 21:55:24 +0000 (21:55 +0000)]
src/: Add commentary to the generated code.

Introduce a new `banner' instruction whose purpose is to act as section
heading in the code: a blank line is left (except at the head of a
block, hence the earlier expansion of the `format' string) and the
banner text written as a beautifully formatted comment.

The new `format' string, in `format-banner-comment', is just about
interesting enough to make up for the loss of the `block' printer.

7 years agosrc/codegen-proto.lisp: Rewrite `block' printing longhand.
Mark Wooding [Tue, 5 Jan 2016 21:52:36 +0000 (21:52 +0000)]
src/codegen-proto.lisp: Rewrite `block' printing longhand.

There are going to be some changes made to it, so it has to be written
out suitably.  Nothing should be very different.  The way newlines are
handled is a little tricksy.

A shame, really, because the old `format' string was quite fun.

7 years agodoc/sod.sty, doc/structures.tex: Use non-indenting variant of `prog'.
Mark Wooding [Tue, 15 Dec 2015 19:15:23 +0000 (19:15 +0000)]
doc/sod.sty, doc/structures.tex: Use non-indenting variant of `prog'.

Otherwise space is wasted when program fragments are shown in floats.

7 years agodoc/sod.sty, doc/*.tex: New notation for line control in `prog'.
Mark Wooding [Sat, 2 Jan 2016 15:37:03 +0000 (15:37 +0000)]
doc/sod.sty, doc/*.tex: New notation for line control in `prog'.

By default, breaks are no longer allowed between lines in a `prog'
environment.  `\\+' introduces some vertical whitespace and allows a
break.  `\\-' introduces a little space, but doesn't allow a break.