From fd040f066b906ce63396b9703bc16d32bcc5204e Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Wed, 2 Aug 2017 10:29:28 +0100 Subject: [PATCH] Various, style: Generally prefer `: ' over ` : '. Organization: Straylight/Edgeware From: Mark Wooding 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. --- doc/structures.tex | 2 +- doc/syntax.tex | 8 ++++---- doc/tutorial.tex | 8 ++++---- lib/keyword.h | 2 +- src/builtin.lisp | 2 +- src/class-output.lisp | 4 ++-- test/chimaera.sod | 16 ++++++++-------- test/test.sod | 34 +++++++++++++++++----------------- 8 files changed, 38 insertions(+), 38 deletions(-) diff --git a/doc/structures.tex b/doc/structures.tex index 7cc825a..c5c2219 100644 --- a/doc/structures.tex +++ b/doc/structures.tex @@ -201,7 +201,7 @@ recommended. \begin{describe}[SodClass]{cls} {[nick = cls, link = SodObject] \\ - class SodClass : SodObject \{ \\ \ind + class SodClass: SodObject \{ \\ \ind const char *name; \\ const char *nick; \\ size_t initsz; \\ diff --git a/doc/syntax.tex b/doc/syntax.tex index 18b46e1..c6033cf 100644 --- a/doc/syntax.tex +++ b/doc/syntax.tex @@ -540,11 +540,11 @@ necessary in order to resolve certain kinds of circularity. For example, \begin{prog} class Sub; \\+ -class Super : SodObject \{ \\ \ind +class Super: SodObject \{ \\ \ind Sub *sub; \-\\ \}; \\+ -class Sub : Super \{ \\ \ind +class Sub: Super \{ \\ \ind /* \dots\ */ \-\\ \}; \end{prog} @@ -625,14 +625,14 @@ An @, if present, is treated as if a separate For example, \begin{prog} [nick = eg] \\ -class Example : Super \{ \\ \ind +class Example: Super \{ \\ \ind int foo = 17; \-\\ \}; \end{prog} means the same as \begin{prog} [nick = eg] \\ -class Example : Super \{ \\ \ind +class Example: Super \{ \\ \ind int foo; \\ eg.foo = 17; \-\\ \}; diff --git a/doc/tutorial.tex b/doc/tutorial.tex index ac38e06..3d90293 100644 --- a/doc/tutorial.tex +++ b/doc/tutorial.tex @@ -111,16 +111,16 @@ The following is a simple Sod input file. \begin{prog} /* -*-sod-*- */ \\+ - code c : includes \{ \\ + code c: includes \{ \\ \#include "greeter.h" \\ \} \\+ - code h : includes \{ \\ + code h: includes \{ \\ \#include \\ \#include \\ \} \\+ - class Greeter : SodObject \{ \\ \ind + class Greeter: SodObject \{ \\ \ind void greet(FILE *fp) \{ \\ \ind fputs("Hello, world!\textbackslash n", fp); \-\\ \} \-\\ @@ -175,7 +175,7 @@ approach to all of this: it expects you, the programmer, to deal with it. The basic syntax for @"code" stanzas is \begin{prog} - code @ : @
\{ \\ \ind + code @: @
\{ \\ \ind @ \-\\ \} \end{prog} diff --git a/lib/keyword.h b/lib/keyword.h index 783f0b7..432fbd1 100644 --- a/lib/keyword.h +++ b/lib/keyword.h @@ -235,7 +235,7 @@ extern kw_unkhookfn *kw_unkhook; set##_KWSET(KWSET__SUPPLIEDP) \ set##_KWSET(KWSET__STRUCTMEM) \ } -#define KWSET__SUPPLIEDP(type, name, dflt) unsigned name##_suppliedp : 1; +#define KWSET__SUPPLIEDP(type, name, dflt) unsigned name##_suppliedp: 1; #define KWSET__STRUCTMEM(type, name, dflt) type name; /* --- @KWSET_PARSEFN@ --- * diff --git a/src/builtin.lisp b/src/builtin.lisp index 0787b8d..c10e5ad 100644 --- a/src/builtin.lisp +++ b/src/builtin.lisp @@ -279,7 +279,7 @@ (default (sod-initarg-default initarg))) (definst suppliedp-struct (stream) (flags var) (format stream - "~@" + "~@" flags var)) ;; Initialization. diff --git a/src/class-output.lisp b/src/class-output.lisp index 2d1c222..806de35 100644 --- a/src/class-output.lisp +++ b/src/class-output.lisp @@ -299,7 +299,7 @@ (defmethod hook-output progn (c-function-keywords type)))) (when keys (format stream "struct ~A {~%~ - ~{ unsigned ~A : 1;~%~}~ + ~{ unsigned ~A: 1;~%~}~ };~2%" (direct-method-suppliedp-struct-tag method) (mapcar #'argument-name keys)))))))) @@ -511,7 +511,7 @@ (defmethod hook-output progn class) (format stream "~&struct ~A {~%" (effective-method-keyword-struct-tag method)) - (format stream "~{ unsigned ~A__suppliedp : 1;~%~}" + (format stream "~{ unsigned ~A__suppliedp: 1;~%~}" (mapcar #'argument-name keys)) (dolist (key keys) (write-string " " stream) diff --git a/test/chimaera.sod b/test/chimaera.sod index 976c727..b30248c 100644 --- a/test/chimaera.sod +++ b/test/chimaera.sod @@ -3,34 +3,34 @@ * A simple SOD module for testing. */ -code c : includes { +code c: includes { #include #include "chimaera.h" } -code h : includes { +code h: includes { #include "sod.h" } [nick = nml, link = SodObject] -class Animal : SodObject { +class Animal: SodObject { int tickles = 0; [combination = progn] void tickle(); [role = before] void nml.tickle() { me->nml.tickles++; } } -class Lion : Animal { +class Lion: Animal { void bite() { puts("Munch!"); } void nml.tickle() { Lion_bite(me); } } -class Goat : Animal { +class Goat: Animal { void butt() { puts("Bonk!"); } void nml.tickle() { Goat_butt(me); } } -class Serpent : Animal { +class Serpent: Animal { int limit = 2; void hiss() { puts("Sssss!"); } @@ -44,11 +44,11 @@ class Serpent : Animal { } [nick = sir, link = Animal] -class Chimaera : Lion, Goat, Serpent { +class Chimaera: Lion, Goat, Serpent { serpent.limit = 1; } -code c : user { +code c: user { /*----- Main driver code --------------------------------------------------*/ static void tickle_animal(Animal *a) diff --git a/test/test.sod b/test/test.sod index 776228b..192f631 100644 --- a/test/test.sod +++ b/test/test.sod @@ -1,10 +1,10 @@ /* -*-sod-*- */ -code h : includes { +code h: includes { #include "sod.h" } -code c : includes { +code c: includes { #include #include #include @@ -12,7 +12,7 @@ code c : includes { #include "test.h" } -code c : early_user { +code c: early_user { /*----- Preliminary definitions -------------------------------------------*/ /* Confuse the fragment scanner... */ @@ -44,7 +44,7 @@ static void done(int q, const char *where) { step(q, where); } } -code c : (tests head) +code c: (tests head) [user (tests head) tests (tests tail) main (user end)] { /*----- Test machinery ----------------------------------------------------*/ @@ -52,12 +52,12 @@ code c : (tests head) static void tests(void) LBRACE } -code c : (tests tail) { +code c: (tests tail) { RBRACE } -code c : main { +code c: main { /*----- Main program ------------------------------------------------------*/ int main(void) @@ -70,7 +70,7 @@ int main(void) /*----- Various kinds of method combinations ------------------------------*/ -code h : early_user { +code h: early_user { struct item { struct item *next; const char *p; @@ -78,7 +78,7 @@ struct item { } -code c : early_user { +code c: early_user { static void *xmalloc(size_t n) { void *p = malloc(n); @@ -136,7 +136,7 @@ static int check_vec(struct vec *v, ...) } [link = SodObject, nick = t1base] -class T1Base : SodObject { +class T1Base: SodObject { [combination = progn] void aprogn() { STEP(1); } [combination = sum] int asum() { return 1; } [combination = and] int aand() { return 8; } @@ -158,7 +158,7 @@ class T1Base : SodObject { } [link = T1Base, nick = t1sub] -class T1Sub : T1Base { +class T1Sub: T1Base { void t1base.aprogn() { STEP(0); } int t1base.asum() { return 2; } int t1base.aand() { return 6; } @@ -167,7 +167,7 @@ class T1Sub : T1Base { int t1base.avec() { return 4; } } -code c : tests { +code c: tests { prepare("aggregate, base"); { SOD_DECL(T1Base, t1, NO_KWARGS); struct item *l; @@ -205,14 +205,14 @@ code c : tests { /*----- Slot and user initargs --------------------------------------------*/ [link = SodObject, nick = t2] -class T2 : SodObject { +class T2: SodObject { [initarg = x] int x = 0; initarg int y = 1; init { if (!y) STEP(0); } } -code c : tests { +code c: tests { prepare("initargs, defaults"); { SOD_DECL(T2, t, NO_KWARGS); if (t->t2.x == 0) STEP(0); @@ -228,24 +228,24 @@ code c : tests { /*----- Keyword argument propagation --------------------------------------*/ [link = SodObject, nick = base] -class T3Base : SodObject { +class T3Base: SodObject { void m0(?int x) { STEP(x); } void m1(?) { } } [link = T3Base, nick = mid] -class T3Mid : T3Base { +class T3Mid: T3Base { void base.m0(?int y) { STEP(y); CALL_NEXT_METHOD; } void base.m1(?) { STEP(4); CALL_NEXT_METHOD; } } [link = T3Mid, nick = sub] -class T3Sub : T3Mid { +class T3Sub: T3Mid { void base.m0(?int z) { STEP(z); CALL_NEXT_METHOD; } void base.m1(?int z) { STEP(z); CALL_NEXT_METHOD; } } -code c : tests { +code c: tests { prepare("kwargs"); { SOD_DECL(T3Sub, t, NO_KWARGS); T3Base_m0(t, KWARGS(K(z, 0) K(y, 1) K(x, 2))); -- [mdw]