From: Mark Wooding Date: Thu, 26 May 2016 08:26:09 +0000 (+0100) Subject: Merge branches 'mdw/kwargs' and 'mdw/c11' X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/sod/commitdiff_plain/f64eb323a5798e155cc494043f5f750abf50a482 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 ) lib/sod.h (simple hand-merge) src/sod-module.5 (extra parameter to , added by hand) --- f64eb323a5798e155cc494043f5f750abf50a482 diff --cc doc/SYMBOLS index 00bfb3b,20e2eef..cec9fa3 --- a/doc/SYMBOLS +++ b/doc/SYMBOLS @@@ -20,11 -23,10 +23,12 @@@ c-types-impl.lis bool c-type c-array-dimensions generic c-array-type class + c-atomic-type class c-enum-type class c-function-arguments generic + c-function-keywords generic c-function-type class + c-keyword-function-type class c-pointer-type class c-struct-type class c-tagged-type-kind generic @@@ -624,8 -600,9 +642,10 @@@ cl: c-type c-array-type c-function-type + c-keyword-function-type + c-storage-specifiers-type qualifiable-c-type + c-atomic-type c-pointer-type simple-c-type c-class-type @@@ -730,8 -701,9 +750,11 @@@ c-fragment-tex c-fragment c-function-arguments c-function-type +c-function-keywords + c-keyword-function-type + c-qualifier-keyword + (eql :atomic) + cl:symbol c-tagged-type-kind c-enum-type c-struct-type @@@ -743,10 -715,12 +766,13 @@@ c-type-clas c-type-equal-p t t c-array-type c-array-type + c-atomic-type c-atomic-type c-class-type c-class-type c-function-type c-function-type + c-keyword-function-type c-keyword-function-type c-pointer-type c-pointer-type + c-storage-specifiers-type c-type + c-type c-storage-specifiers-type qualifiable-c-type qualifiable-c-type simple-c-type simple-c-type tagged-c-type tagged-c-type @@@ -862,8 -839,7 +892,7 @@@ compute-islot sod-class sod-class compute-method-entry-functions basic-effective-method - simple-effective-method + effective-method - simple-effective-method compute-sod-effective-method sod-message sod-class compute-vtable @@@ -1261,9 -1207,10 +1301,11 @@@ pprint-c-storage-specifie pprint-c-type t t t c-array-type t t + c-atomic-type t t c-function-type t t + c-keyword-function-type t t c-pointer-type t t + c-storage-specifiers-type t t simple-c-type t t tagged-c-type t t primary-method-class diff --cc doc/clang.tex index 6f7e218,ce34265..0c6c4bb --- a/doc/clang.tex +++ b/doc/clang.tex @@@ -46,10 -46,10 +46,11 @@@ The class hierarchy is shown in~\xref{f @|c-struct-type| \\ @|c-union-type| \\ @|c-enum-type| \- \\ + @|c-atomic-type| \\ @|c-pointer-type| \- \\ @|c-array-type| \\ - @|c-function-type| + @|c-function-type| \\ \ind + @|c-keyword-function-type| \- \end{tabbing}} \caption{Classes representing C types} \label{fig:codegen.c-types.classes} diff --cc doc/structures.tex index 42739ef,b63a336..3826bdc --- a/doc/structures.tex +++ b/doc/structures.tex @@@ -204,7 -139,9 +204,8 @@@ recommended const char *name; \\ const char *nick; \\ size_t initsz; \\ + size_t align; \\ void *(*imprint)(void *@

); \\ - void *(*init)(void *@

); \\ size_t n_supers; \\ const SodClass *const *supers; \\ size_t n_cpl; \\ diff --cc doc/syntax.tex index 3034b1e,b8ae797..21f835e --- a/doc/syntax.tex +++ b/doc/syntax.tex @@@ -509,11 -522,13 +522,14 @@@ All of these have their usual C meaning ::= @^+ - ::= $[\epsilon]$ ++ ::= $[\epsilon, \mbox{@}]$ + + ::= $[\mbox{@ @! $\epsilon$}]$ + ::= + $[\mbox{@ @! $\epsilon$}, \mbox{@}]$ - ::= $[\mbox{@}]$ - - ::= "." + ::= + $[\mbox{@}, \mbox{@}]$ \end{grammar} The declarator syntax is taken from C, but with some differences. diff --cc lib/sod-structs.3 index 029cabd,5624d33..35f668f --- a/lib/sod-structs.3 +++ b/lib/sod-structs.3 @@@ -105,7 -95,9 +105,8 @@@ struct SodObject__ilayout \h'8n'const char *name; \h'8n'const char *nick; \h'8n'size_t initsz; + \h'8n'size_t align; \h'8n'void *(*imprint)(void *\fIp\fB); -\h'8n'void *(*init)(void *\fIp\fB); \h'8n'size_t n_supers; \h'8n'const SodClass *const *supers; \h'8n'size_t n_cpl; diff --cc lib/sod.h index 8945810,943ed4b..4588626 --- a/lib/sod.h +++ b/lib/sod.h @@@ -77,15 -87,26 +87,35 @@@ /* We're going to want to make use of this ourselves. */ SOD__VARARGS_MACROS_PREAMBLE + /* --- @SOD__ALIGNOF@ --- * + * + * Arguments: @type@ = a C type name, consisting of declaration specifiers + * and `*[QUALIFIERS]' declarator operators + * + * Returns: A sufficient alignment for objects of the given @type@, as a + * @size_t@. + */ + + #if __STDC_VERSION__ >= 201112 + # define SOD__ALIGNOF(type) _Alignof(type) + #elif SOD__GCC_P(4, 7) + # define SOD__ALIGNOF(type) __extension__ _Alignof(type) + #elif defined(__GNUC__) + # define SOD__ALIGNOF(type) __alignof__(type) + #else + # define SOD__ALIGNOF(type) \ + offsetof(struct { char sod__x; type sod__y; }, sod__y) + #endif + +/* --- @SOD__IGNORE@ --- * + * + * Arguments: @var@ = some variable name + * + * Use: Suppress any warning that @var@ isn't used. + */ + +#define SOD__IGNORE(var) ((void)(var)) + /* --- @SOD__CAR@ --- * * * Arguments: @...@ = a nonempty list of arguments diff --cc src/sod-module.5 index 66937da,1837524..949e781 --- a/src/sod-module.5 +++ b/src/sod-module.5 @@@ -877,9 -890,13 +913,13 @@@ and one of the following, up to reorder .IR declaration-specifier \*+ .I argument-declarator .br + .I abstract-declarator + ::= -.IR declarator [\*e] ++.IR declarator "[\*e, " argument-list ] + .br .I argument-declarator ::= -.IR declarator [ identifier " | \*e]" +.IR declarator [ identifier " | \*e, " argument-list ] .br .I simple-declarator ::=