Commit d5b6cd3a authored by Eric Myhre's avatar Eric Myhre

schema-schema: add "stringprefix" to union strategies.

Absence of this is an oversight, and I just happened to catch it while
passing through the vicinity.

Also: dropped a comment for later review on the bytesprefix strategy.
While adding the stringprefix strategy, it's hard not to notice that
variable length strings are allowed; so, it occurs to me we should
probably do the same for byteprefix.  (Also, possibly renaming it to
byte*s*prefix.)  Doing this would also fix the ancient weirdness of
the map being flipped in an awkward way to evade int keys, which is
a very happy coincidence (and in retrospect, I'm not sure why we didn't
think of this solution earlier).
parent ea354c47
......@@ -193,14 +193,16 @@ func init() {
"UnionRepresentation_Keyed",
"UnionRepresentation_Envelope",
"UnionRepresentation_Inline",
"UnionRepresentation_StringPrefix",
"UnionRepresentation_BytePrefix",
},
schema.SpawnUnionRepresentationKeyed(map[string]schema.TypeName{
"kinded": "UnionRepresentation_Kinded",
"keyed": "UnionRepresentation_Keyed",
"envelope": "UnionRepresentation_Envelope",
"inline": "UnionRepresentation_Inline",
"byteprefix": "UnionRepresentation_BytePrefix",
"kinded": "UnionRepresentation_Kinded",
"keyed": "UnionRepresentation_Keyed",
"envelope": "UnionRepresentation_Envelope",
"inline": "UnionRepresentation_Inline",
"stringprefix": "UnionRepresentation_StringPrefix",
"byteprefix": "UnionRepresentation_BytePrefix",
}),
))
ts.Accumulate(schema.SpawnMap("UnionRepresentation_Kinded",
......@@ -224,8 +226,15 @@ func init() {
},
schema.StructRepresentation_Map{},
))
ts.Accumulate(schema.SpawnStruct("UnionRepresentation_StringPrefix",
[]schema.StructField{
schema.SpawnStructField("discriminantTable", "Map__String__TypeName", false, false), // todo: dodging inline defn's again.
},
schema.StructRepresentation_Map{},
))
ts.Accumulate(schema.SpawnStruct("UnionRepresentation_BytePrefix",
[]schema.StructField{
// REVIEW: for schema-schema overall: this is a very funny type. Should we use strings here? And perhaps make it use hex for maximum clarity? This would also allow multi-byte prefixes, which would match what's already done by stringprefix representation.
schema.SpawnStructField("discriminantTable", "Map__TypeName__Int", false, false), // todo: dodging inline defn's again.
},
schema.StructRepresentation_Map{},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment