Skip to content

Commit

Permalink
Rename blob type to bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
giannitedesco committed Jun 26, 2021
1 parent 7760b93 commit 750294d
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ struct line {
timestamp time;
point line_start;
point line_end;
blob comment;
bytes comment;
};
```

Fixed width integer types from 8 to 128 bit are supported, along with the
`blob` type, which is a variable-length sequence of bytes.
`bytes` type, which is a variable-length sequence of bytes.

## Target Languages
The following target languages are currently supported:
Expand All @@ -59,10 +59,10 @@ Target languages are implemented purely as `jinja2` templates.
## Serialization format
The serialization format for fixed-length objects is simply a packed C struct.

For any object which contains `blob` type fields:
For any object which contains `bytes` type fields:
- a 32bit unsigned record length is prepended to the struct
- all `blob` type fields are converted to `u32` and contain the length of the blob
- all blob contents are appended after the struct in the order in which they appear
- all `bytes` type fields are converted to `u32` and contain the length of the bytes
- all bytes contents are appended after the struct in the order in which they appear

For example, following the example above, the serialization would be:

Expand Down
4 changes: 2 additions & 2 deletions examples/example1.xpdt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct timespan {

struct item {
u32 id; # User id
blob first_name; # given name
blob surname; # surname
bytes first_name; # given name
bytes surname; # surname
timestamp last_login;
};
2 changes: 1 addition & 1 deletion test/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

_all_types = '''
struct fixed {
blob blob;
bytes bytes;
u128 u128;
u64 u64;
i64 i64;
Expand Down
2 changes: 1 addition & 1 deletion test/test_roundtrip.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def setUp(self):
MemberDef('id', BaseType.u32),
MemberDef('first_name', BaseType.utf8),
MemberDef('surname', BaseType.utf8),
MemberDef('data', BaseType.blob),
MemberDef('data', BaseType.bytes),
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion test/test_stringy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def setUp(self):
struct_name='Item',
members=[
MemberDecl('id', 'u32'),
MemberDecl('name', 'blob'),
MemberDecl('name', 'bytes'),
],
),
StructDecl(
Expand Down
4 changes: 2 additions & 2 deletions xpdt/basetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
'base_types',
)

Blob = BufType()
Bytes = BufType()
Utf8 = Utf8Type()
xu128 = UuidType()
UnsignedInt8 = IntegralType(8, False)
Expand All @@ -28,7 +28,7 @@
class BaseType(TypeDef, Enum):
__slots__ = ()

blob = 'blob', Blob
bytes = 'bytes', Bytes
utf8 = 'utf8', Utf8
u8 = 'u8', UnsignedInt8
i8 = 'i8', SignedInt8
Expand Down
2 changes: 1 addition & 1 deletion xpdt/templates/macros.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ struct /*{struct.tag}*/ {



/*#- macro blob_struct_decl(struct) -#*/
/*#- macro vbuf_struct_decl(struct) -#*/

/*{struct_xptrs(struct)}*/ {
// for member in struct.vbuf_members
Expand Down
2 changes: 1 addition & 1 deletion xpdt/templates/xpdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

/*{macros.serialized_struct_decl(struct)}*/

/*{macros.blob_struct_decl(struct)}*/
/*{macros.vbuf_struct_decl(struct)}*/
/*# endif #*/
/*#- endfor -#*/

Expand Down

0 comments on commit 750294d

Please sign in to comment.