xdump: Make meta-type numbers portable, get rid of meta-type "c"
The xdump field data types are abstract symbols "d", "f", "s" and "c". However, the abstraction leaks: we dump the enum nsc_type ca_type values verbatim in meta table field "type", and have symbol table meta-type map all integer types to "d", and both floating-point types to "f". Not a problem for well-behaved clients, since all they do with the dumped value is referencing table meta-type. It is a problem for version-test: since the integer type compatible with an enumeration type is implementation-defined, the type value of selectors of enumeration type can vary between compilers. It also makes table meta-type a somewhat ugly exception to the rule that a symbol table maps integers to names 1:1. Virtual selectors let us seal the abstraction: dump the promoted ca_type value. The integer types get all promoted to NSC_LONG. This takes care of version-test. The floating-point types get all promoted to NSC_DOUBLE. Makes sense. NSC_STRINGY gets promoted to NSC_STRING. This changes all field data types "c" to "s". Getting rid of "c" is a welcome simplification, because now the meaning of meta type field "len" no longer depends on "type", but always means that the array is dumped as that many fields. We lose string length limit information, though. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
6e9f256c68
commit
89a06ec2d4
5 changed files with 671 additions and 696 deletions
62
doc/xdump
62
doc/xdump
|
@ -253,7 +253,7 @@ of xdump meta T are:
|
|||
- "d", field uses intnum syntax
|
||||
- "g", field uses flonum syntax
|
||||
- "s", field uses string syntax
|
||||
- "c", field uses string syntax
|
||||
- "c", field uses string syntax (only until version 4.3.33)
|
||||
|
||||
* flags: The field's flags, a symbol set. Flags are:
|
||||
- "deity", field visible only to deities
|
||||
|
@ -263,9 +263,10 @@ of xdump meta T are:
|
|||
enabled. Masked values are replaced by -1.
|
||||
|
||||
* len: If non-zero, then the record encodes an array with that many
|
||||
elements. If field type encodes symbol "c", it is a character
|
||||
array, which is dumped as a single string field. Else, the array is
|
||||
dumped as len fields.
|
||||
elements. The array is dumped as len fields.
|
||||
|
||||
Only until version 4.3.33: if field type encodes symbol "c", it is a
|
||||
character array, and is dumped as a single string field.
|
||||
|
||||
* table: Key for xdump table. Unless -1, it defines the table
|
||||
referenced by the field value. Field type must encode symbol "d"
|
||||
|
@ -312,12 +313,12 @@ its meta-data, and to make sense of that table, we need meta-meta
|
|||
data. So we start with that:
|
||||
|
||||
[3:640] Command : xdump meta meta
|
||||
XDUMP meta meta 1464554085
|
||||
XDUMP meta meta 1466920477
|
||||
"name" 3 0 0 -1
|
||||
"type" 8 0 0 33
|
||||
"flags" 8 8 0 32
|
||||
"len" 7 0 0 -1
|
||||
"table" 8 0 0 26
|
||||
"type" 1 0 0 33
|
||||
"flags" 1 8 0 32
|
||||
"len" 1 0 0 -1
|
||||
"table" 1 0 0 26
|
||||
/5
|
||||
|
||||
To interpret this table, we have to know the field names and their
|
||||
|
@ -341,8 +342,8 @@ know, namely the table of tables. Let's dump that next, starting with
|
|||
its meta-data:
|
||||
|
||||
[3:640] Command : xdump meta table
|
||||
XDUMP meta table 1464554085
|
||||
"uid" 8 0 0 26
|
||||
XDUMP meta table 1466920477
|
||||
"uid" 1 0 0 26
|
||||
"name" 3 0 0 -1
|
||||
/2
|
||||
|
||||
|
@ -353,7 +354,7 @@ table itself. Indeed, its value matches the one we got in xdump meta
|
|||
meta. Let's try to dump the table:
|
||||
|
||||
[5:640] Command : xdump 26 *
|
||||
XDUMP table 1464554085
|
||||
XDUMP table 1466920477
|
||||
0 "sect"
|
||||
1 "ship"
|
||||
[...]
|
||||
|
@ -364,7 +365,7 @@ meta. Let's try to dump the table:
|
|||
[...]
|
||||
26 "table"
|
||||
[...]
|
||||
/47
|
||||
/48
|
||||
|
||||
It worked!
|
||||
|
||||
|
@ -372,37 +373,26 @@ Now dump the two symbol tables we postponed. Because xdump accepts
|
|||
table IDs as well as names, we don't have to know their names:
|
||||
|
||||
[5:640] Command : xdump meta 33
|
||||
xdump meta 33
|
||||
XDUMP meta meta-type 1464554085
|
||||
"value" 8 0 0 -1
|
||||
XDUMP meta meta-type 1466920477
|
||||
"value" 1 0 0 -1
|
||||
"name" 3 0 0 -1
|
||||
/2
|
||||
|
||||
[6:640] Command : xdump 33 *
|
||||
XDUMP meta-type 1464554085
|
||||
XDUMP meta-type 1466920477
|
||||
1 "d"
|
||||
2 "g"
|
||||
3 "s"
|
||||
4 "d"
|
||||
5 "d"
|
||||
6 "d"
|
||||
7 "d"
|
||||
8 "d"
|
||||
9 "d"
|
||||
10 "d"
|
||||
11 "d"
|
||||
12 "g"
|
||||
13 "c"
|
||||
/13
|
||||
/3
|
||||
|
||||
[7:640] Command : xdump meta 32
|
||||
XDUMP meta meta-flags 1464554085
|
||||
"value" 8 0 0 -1
|
||||
XDUMP meta meta-flags 1466920477
|
||||
"value" 1 0 0 -1
|
||||
"name" 3 0 0 -1
|
||||
/2
|
||||
|
||||
[7:640] Command : xdump 32 *
|
||||
XDUMP meta-flags 1464554085
|
||||
XDUMP meta-flags 1466920477
|
||||
1 "deity"
|
||||
8 "bits"
|
||||
16 "hidden"
|
||||
|
@ -422,11 +412,11 @@ Dumping the remaining tables is easy: just walk the table of tables.
|
|||
Here's the first one:
|
||||
|
||||
[7:640] Command : xdump meta 0
|
||||
XDUMP meta sect 1464554085
|
||||
"owner" 5 0 0 8
|
||||
"xloc" 9 0 0 -1
|
||||
"yloc" 10 0 0 -1
|
||||
"des" 4 0 0 18
|
||||
XDUMP meta sect 1466920477
|
||||
"owner" 1 0 0 8
|
||||
"xloc" 1 0 0 -1
|
||||
"yloc" 1 0 0 -1
|
||||
"des" 1 0 0 18
|
||||
[...]
|
||||
/78
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue