Skip to content

Commit c582ef3

Browse files
committed
default for type-function is payload-type now!
1 parent ff69c67 commit c582ef3

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

documentation/source/reference.rst

+6-1
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,12 @@ language instantiates these fields.
377377

378378
:superclasses: :class:`<field>`
379379

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`.
381386

382387
See also
383388

documentation/source/usage.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,6 @@ binary data definition.
213213
variably-typed field payload, type-function: frame.payload-type;
214214
end;
215215
216-
FIXME: why is payload-type not the default type-function of a variable-typed field?
217-
218216
The first line specifies the name ``<ethernet-frame>``, and its
219217
superclass, :class:`<header-frame>`.
220218

@@ -235,6 +233,8 @@ binary data definition.
235233

236234
The last field is the payload, whose type is variable and given by
237235
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`.
238238

239239
A payload for an ``<ethernet-frame>`` might be a ``<vlan-tag>``, if
240240
the ``type-code`` is ``#x8100`` (the keyword ``over`` does the hairy

fields.dylan

+6-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ define function compute-static-offset (list :: <simple-vector>)
3030
field.fixup-function := fixup-protocol-magic;
3131
end;
3232
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;
3338
if (start ~= $unknown-at-compile-time)
3439
unless (field.dynamic-start)
3540
if (field.static-start = $unknown-at-compile-time)
@@ -124,7 +129,7 @@ end;
124129

125130
define class <variably-typed-field> (<field>)
126131
//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:;
128133
end;
129134

130135
define abstract class <repeated-field> (<statically-typed-field>)

0 commit comments

Comments
 (0)