Skip to content

Commit

Permalink
lex: refactor $blob, $link, and $bytes serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
bnewbold committed Mar 29, 2023
1 parent 143f76f commit 8a404c3
Show file tree
Hide file tree
Showing 5 changed files with 441 additions and 89 deletions.
2 changes: 1 addition & 1 deletion gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func main() {
panic(err)
}

if err := cbg.WriteMapEncodersToFile("lex/util/cbor_gen.go", "util", lexutil.CborChecker{}, lexutil.Blob{}); err != nil {
if err := cbg.WriteMapEncodersToFile("lex/util/cbor_gen.go", "util", lexutil.CborChecker{}, lexutil.LegacyBlob{}, lexutil.BlobSchema{}); err != nil {
panic(err)
}

Expand Down
8 changes: 4 additions & 4 deletions lex/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -1018,10 +1018,8 @@ func (s *TypeSchema) typeNameForField(name, k string, v TypeSchema) (string, err
return "util.LexiconTypeDecoder", nil
case "union":
return "*" + name + "_" + strings.Title(k), nil
case "image":
return "*util.Blob", nil
case "blob":
return "*util.Blob", nil
return "*util.LexBlob", nil
case "array":
subt, err := s.typeNameForField(name+"_"+strings.Title(k), "Elem", *v.Items)
if err != nil {
Expand All @@ -1030,7 +1028,9 @@ func (s *TypeSchema) typeNameForField(name, k string, v TypeSchema) (string, err

return "[]" + subt, nil
case "cid-link":
return "cid.Cid", nil
return "util.LexLink", nil
case "bytes":
return "util.LexBytes", nil
default:
return "", fmt.Errorf("field %q in %s has unsupported type name (%s)", k, name, v.Type)
}
Expand Down
188 changes: 174 additions & 14 deletions lex/util/cbor_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8a404c3

Please sign in to comment.