File tree 3 files changed +14
-4
lines changed
3 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -377,7 +377,12 @@ language instantiates these fields.
377
377
378
378
:superclasses: :class: `<field> `
379
379
380
- :keyword type-function: A unary Dylan function computing the type.
380
+ :keyword type-function: A unary Dylan function computing the type of the field.
381
+
382
+ :description:
383
+
384
+ The default value for the *type-function * keyword is
385
+ :func: `payload-type `.
381
386
382
387
See also
383
388
Original file line number Diff line number Diff line change @@ -213,8 +213,6 @@ binary data definition.
213
213
variably-typed field payload, type-function: frame.payload-type;
214
214
end;
215
215
216
- FIXME: why is payload-type not the default type-function of a variable-typed field?
217
-
218
216
The first line specifies the name ``<ethernet-frame> ``, and its
219
217
superclass, :class: `<header-frame> `.
220
218
@@ -235,6 +233,8 @@ binary data definition.
235
233
236
234
The last field is the payload, whose type is variable and given by
237
235
applying the function ``payload-type `` to the concrete frame instance.
236
+ The default type-function of a :class: `<variably-typed-field> ` is
237
+ :func: `payload-type `.
238
238
239
239
A payload for an ``<ethernet-frame> `` might be a ``<vlan-tag> ``, if
240
240
the ``type-code `` is ``#x8100 `` (the keyword ``over `` does the hairy
Original file line number Diff line number Diff line change @@ -30,6 +30,11 @@ define function compute-static-offset (list :: <simple-vector>)
30
30
field.fixup-function := fixup-protocol-magic;
31
31
end ;
32
32
end ;
33
+ if (instance? (field, <variably-typed-field>))
34
+ unless (slot-initialized? (field, type-function))
35
+ field.type-function := payload-type;
36
+ end ;
37
+ end ;
33
38
if (start ~= $unknown-at-compile-time)
34
39
unless (field.dynamic-start)
35
40
if (field.static-start = $unknown-at-compile-time)
124
129
125
130
define class <variably-typed-field> (<field>)
126
131
// type-function has to return a subclass of <container-frame>
127
- slot type-function, required- init-keyword: type-function:;
132
+ slot type-function, init-keyword: type-function:;
128
133
end ;
129
134
130
135
define abstract class <repeated-field> (<statically-typed-field>)
You can’t perform that action at this time.
0 commit comments