|
| 1 | +# S-expression standard: Low-level constants |
| 2 | + |
| 3 | +## Status |
| 4 | + |
| 5 | +Draft |
| 6 | + |
| 7 | +## Abstract |
| 8 | + |
| 9 | +This document defines a S-expression schema to represent constant |
| 10 | +values extracted from code written in low-level programming languages. |
| 11 | +Values can be strings, integers (signed or unsigned), or real numbers. |
| 12 | +Additionally, information about the size and offset of record fields |
| 13 | +can be encoded. Input and outputs suitable for a "groveler" (a program |
| 14 | +to retrieve such values) are specified. |
| 15 | + |
| 16 | +## Rationale |
| 17 | + |
| 18 | +## Specification |
| 19 | + |
| 20 | +### Groveler input language |
| 21 | + |
| 22 | +``` |
| 23 | +(pkg-config-path <string>) |
| 24 | +(pkg-config <string>) |
| 25 | +(include <angle-bracket-header>) |
| 26 | +(include "string-header") |
| 27 | +(error <string>) |
| 28 | +(warning <string>) |
| 29 | +
|
| 30 | +(when <expression> |
| 31 | + <body>...) |
| 32 | +
|
| 33 | +(type-signedness <type>) |
| 34 | +(type-size <type>) |
| 35 | +(type-slot <type> <slot>) |
| 36 | +(constant <constant> signed|unsigned|string) |
| 37 | +(call-constant <function> <constant> signed|unsigned|string) |
| 38 | +(constant-ifdef <constant> signed|unsigned|string) |
| 39 | +(call-constant-ifdef <function> <constant> signed|unsigned|string) |
| 40 | +``` |
| 41 | + |
| 42 | +### Groveler output language |
| 43 | + |
| 44 | +``` |
| 45 | +(constant <constant> <value>) |
| 46 | +(call-constant <function> <constant> <value>) |
| 47 | +(type-signedness <type> <signedness>) |
| 48 | +(type-size <type> <size>) |
| 49 | +(slot-size <type> <slot> <size>) |
| 50 | +(slot-offset <type> <slot> <size>) |
| 51 | +``` |
| 52 | + |
| 53 | +## Examples |
| 54 | + |
| 55 | +### GTK |
| 56 | + |
| 57 | +Input: |
| 58 | + |
| 59 | +``` |
| 60 | +(constant GTK_STYLE_PROPERTY_BACKGROUND_COLOR string) |
| 61 | +(constant GTK_STYLE_CLASS_DIM_LABEL string) |
| 62 | +(constant GTK_WINDOW_TOPLEVEL unsigned) |
| 63 | +``` |
| 64 | + |
| 65 | +Output: |
| 66 | + |
| 67 | +```Lisp |
| 68 | +(constant GTK_STYLE_PROPERTY_BACKGROUND_COLOR "background-color") |
| 69 | +(constant GTK_STYLE_CLASS_DIM_LABEL "dim-label") |
| 70 | +(constant GTK_WINDOW_TOPLEVEL 0) |
| 71 | +``` |
| 72 | + |
| 73 | +### Conditionals and function calls |
| 74 | + |
| 75 | +Input: |
| 76 | + |
| 77 | +```Lisp |
| 78 | +(include <errno.h>) |
| 79 | +(include <string.h>) |
| 80 | +(constant-ifdef EACCES signed) |
| 81 | +(call-constant-ifdef strerror EACCES string) |
| 82 | +``` |
| 83 | + |
| 84 | +Output when found: |
| 85 | + |
| 86 | +``` |
| 87 | +(constant EACCES 13) |
| 88 | +(call-constant strerror EACCES "Permission denied") |
| 89 | +``` |
| 90 | + |
| 91 | +Output when missing: |
| 92 | + |
| 93 | +``` |
| 94 | +(constant EACCES undefined) |
| 95 | +(call-constant strerror EACCES undefined) |
| 96 | +``` |
0 commit comments