Skip to content

Commit 5140bc8

Browse files
committed
style: v fmt . -w
1 parent ee3bd71 commit 5140bc8

3 files changed

Lines changed: 101 additions & 87 deletions

File tree

decode.v

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import time
44
import encoding.hex
55
import encoding.binary
66

7-
const (
8-
msg_bad_desc = 'unrecognized descriptor byte'
9-
)
7+
const msg_bad_desc = 'unrecognized descriptor byte'
108

119
struct Decoder {
1210
config Config = default_config()

examples/basic.v

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import msgpack
44
import time
55

66
pub struct TestStructA {
7-
field_a int [codec: 'codecdata1']
8-
field_b string [codec: 'codecdata2']
7+
field_a int @[codec: 'codecdata1']
8+
field_b string @[codec: 'codecdata2']
99
field_c TestStructB
1010
field_d []string
1111
// TODO: fix compiler (comptime generic infer)
@@ -16,8 +16,8 @@ pub struct TestStructA {
1616
}
1717

1818
pub struct TestStructB {
19-
field_a int [codec: 'codecdata1']
20-
field_b string [codec: 'codecdata2']
19+
field_a int @[codec: 'codecdata1']
20+
field_b string @[codec: 'codecdata2']
2121
}
2222

2323
fn main() {

types.v

Lines changed: 96 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -3,83 +3,101 @@ module msgpack
33
import math
44

55
// Spec: https://github.com/msgpack/msgpack/blob/master/spec.md
6-
const (
7-
// 7-bit positive integer
8-
mp_pos_fix_int_min = u8(0x00)
9-
mp_pos_fix_int_max = u8(0x7f)
10-
// map whose length is up to 15 elements
11-
mp_fix_map_min = u8(0x80)
12-
mp_fix_map_max = u8(0x8f)
13-
// array whose length is up to 15 elements
14-
mp_fix_array_min = u8(0x90)
15-
mp_fix_array_max = u8(0x9f)
16-
// byte array whose length is up to 31 bytes
17-
mp_fix_str_min = u8(0xa0)
18-
mp_fix_str_max = u8(0xbf)
19-
// nil
20-
mp_nil = u8(0xc0)
21-
// _ = u8(0xc1) // never used
22-
// booleans
23-
mp_false = u8(0xc2)
24-
mp_true = u8(0xc3)
25-
// byte array whose length is up to:
26-
mp_bin_8 = u8(0xc4) // (2^8)-1 bytes
27-
mp_bin_16 = u8(0xc5) // (2^16)-1 bytes (big-endian)
28-
mp_bin_32 = u8(0xc6) // (2^32)-1 bytes (big-endian)
29-
// integer and a byte array whose length is up to:
30-
mp_ext_8 = u8(0xc7) // (2^8)-1 bytes
31-
mp_ext_16 = u8(0xc8) // (2^16)-1 bytes (big-endian)
32-
mp_ext_32 = u8(0xc9) // (2^32)-1 bytes (big-endian)
33-
// single|double precision floating point number (big-endian, IEEE 754)
34-
mp_f32 = u8(0xca)
35-
mp_f64 = u8(0xcb)
36-
// 8|16|32|64-bit unsigned integer
37-
mp_u8 = u8(0xcc)
38-
mp_u16 = u8(0xcd) // (big-endian)
39-
mp_u32 = u8(0xce) // (big-endian)
40-
mp_u64 = u8(0xcf) // (big-endian)
41-
// 8|16|32|64-bit signed integer
42-
mp_i8 = u8(0xd0)
43-
mp_i16 = u8(0xd1) // (big-endian)
44-
mp_i32 = u8(0xd2) // (big-endian)
45-
mp_i64 = u8(0xd3) // (big-endian)
46-
// integer and a byte array whose length is:
47-
mp_fix_ext_1 = u8(0xd4) // 1 byte
48-
mp_fix_ext_2 = u8(0xd5) // 2 bytes
49-
mp_fix_ext_4 = u8(0xd6) // 4 bytes
50-
mp_fix_ext_8 = u8(0xd7) // 8 bytes
51-
mp_fix_ext_16 = u8(0xd8) // 16 bytes
52-
// byte array whose length is up to:
53-
mp_str_8 = u8(0xd9) // (2^8)-1 bytes
54-
mp_str_16 = u8(0xda) // (2^16)-1 bytes (big-endian)
55-
mp_str_32 = u8(0xdb) // (2^32)-1 bytes (big-endian)
56-
// array whose length is up to (big-endian):
57-
mp_array_16 = u8(0xdc) // (2^16)-1 elements
58-
mp_array_32 = u8(0xdd) // (2^32)-1 elements
59-
// map whose length is up to (big-endian):
60-
mp_map_16 = u8(0xde) // (2^16)-1 elements
61-
mp_map_32 = u8(0xdf) // (2^32)-1 elements
62-
// 5-bit negative integer
63-
mp_neg_fix_int_min = u8(0xe0)
64-
mp_neg_fix_int_max = u8(0xff)
65-
)
6+
// 7-bit positive integer
7+
const mp_pos_fix_int_min = u8(0x00)
8+
const mp_pos_fix_int_max = u8(0x7f)
9+
// map whose length is up to 15 elements
10+
const mp_fix_map_min = u8(0x80)
11+
const mp_fix_map_max = u8(0x8f)
12+
// array whose length is up to 15 elements
13+
const mp_fix_array_min = u8(0x90)
14+
const mp_fix_array_max = u8(0x9f)
15+
// byte array whose length is up to 31 bytes
16+
const mp_fix_str_min = u8(0xa0)
17+
const mp_fix_str_max = u8(0xbf)
18+
// nil
19+
const mp_nil = u8(0xc0)
20+
// _ = u8(0xc1) // never used
21+
// booleans
22+
const mp_false = u8(0xc2)
23+
const mp_true = u8(0xc3)
24+
// byte array whose length is up to:
25+
const mp_bin_8 = u8(0xc4)
26+
// (2^8)-1 bytes
27+
const mp_bin_16 = u8(0xc5)
28+
// (2^16)-1 bytes (big-endian)
29+
const mp_bin_32 = u8(0xc6)
30+
// (2^32)-1 bytes (big-endian)
31+
// integer and a byte array whose length is up to:
32+
const mp_ext_8 = u8(0xc7)
33+
// (2^8)-1 bytes
34+
const mp_ext_16 = u8(0xc8)
35+
// (2^16)-1 bytes (big-endian)
36+
const mp_ext_32 = u8(0xc9)
37+
// (2^32)-1 bytes (big-endian)
38+
// single|double precision floating point number (big-endian, IEEE 754)
39+
const mp_f32 = u8(0xca)
40+
const mp_f64 = u8(0xcb)
41+
// 8|16|32|64-bit unsigned integer
42+
const mp_u8 = u8(0xcc)
43+
const mp_u16 = u8(0xcd)
44+
// (big-endian)
45+
const mp_u32 = u8(0xce)
46+
// (big-endian)
47+
const mp_u64 = u8(0xcf)
48+
// (big-endian)
49+
// 8|16|32|64-bit signed integer
50+
const mp_i8 = u8(0xd0)
51+
const mp_i16 = u8(0xd1)
52+
// (big-endian)
53+
const mp_i32 = u8(0xd2)
54+
// (big-endian)
55+
const mp_i64 = u8(0xd3)
56+
// (big-endian)
57+
// integer and a byte array whose length is:
58+
const mp_fix_ext_1 = u8(0xd4)
59+
// 1 byte
60+
const mp_fix_ext_2 = u8(0xd5)
61+
// 2 bytes
62+
const mp_fix_ext_4 = u8(0xd6)
63+
// 4 bytes
64+
const mp_fix_ext_8 = u8(0xd7)
65+
// 8 bytes
66+
const mp_fix_ext_16 = u8(0xd8)
67+
// 16 bytes
68+
// byte array whose length is up to:
69+
const mp_str_8 = u8(0xd9)
70+
// (2^8)-1 bytes
71+
const mp_str_16 = u8(0xda)
72+
// (2^16)-1 bytes (big-endian)
73+
const mp_str_32 = u8(0xdb)
74+
// (2^32)-1 bytes (big-endian)
75+
// array whose length is up to (big-endian):
76+
const mp_array_16 = u8(0xdc)
77+
// (2^16)-1 elements
78+
const mp_array_32 = u8(0xdd)
79+
// (2^32)-1 elements
80+
// map whose length is up to (big-endian):
81+
const mp_map_16 = u8(0xde)
82+
// (2^16)-1 elements
83+
const mp_map_32 = u8(0xdf)
84+
// (2^32)-1 elements
85+
// 5-bit negative integer
86+
const mp_neg_fix_int_min = u8(0xe0)
87+
const mp_neg_fix_int_max = u8(0xff)
6688

6789
// Applications can assign 0 to 127 to store application-specific type information.
6890
// MessagePack reserves -1 to -128 for future extension to add predefined types.
69-
const (
70-
// Timestamp
71-
mp_time_ext_type = u8(-1)
72-
)
91+
// Timestamp
92+
const mp_time_ext_type = u8(-1)
7393

74-
const (
75-
// container_len_unknown is length returned from read_(map|array)_len
76-
// when a format doesn't prefix the length.
77-
// For example, json doesn't pre-determine the length of a container (sequence/map).
78-
// container_len_unknown = -1
79-
// container_len_nil is length returned from read_(map|array)_len
80-
// when a 'nil' was encountered in the stream.
81-
container_len_nil = math.min_i32
82-
)
94+
// container_len_unknown is length returned from read_(map|array)_len
95+
// when a format doesn't prefix the length.
96+
// For example, json doesn't pre-determine the length of a container (sequence/map).
97+
// container_len_unknown = -1
98+
// container_len_nil is length returned from read_(map|array)_len
99+
// when a 'nil' was encountered in the stream.
100+
const container_len_nil = math.min_i32
83101

84102
struct RawExt {
85103
tag u64
@@ -101,13 +119,11 @@ struct ContainerType {
101119
b32 u8
102120
}
103121

104-
const (
105-
container_raw_legacy = ContainerType{32, mp_fix_str_min, 0, mp_str_16, mp_str_32}
106-
container_str = ContainerType{32, mp_fix_str_min, mp_str_8, mp_str_16, mp_str_32}
107-
container_bin = ContainerType{0, 0, mp_bin_8, mp_bin_16, mp_bin_32}
108-
container_array = ContainerType{16, mp_fix_array_min, 0, mp_array_16, mp_array_32}
109-
container_map = ContainerType{16, mp_fix_map_min, 0, mp_map_16, mp_map_32}
110-
)
122+
const container_raw_legacy = ContainerType{32, mp_fix_str_min, 0, mp_str_16, mp_str_32}
123+
const container_str = ContainerType{32, mp_fix_str_min, mp_str_8, mp_str_16, mp_str_32}
124+
const container_bin = ContainerType{0, 0, mp_bin_8, mp_bin_16, mp_bin_32}
125+
const container_array = ContainerType{16, mp_fix_array_min, 0, mp_array_16, mp_array_32}
126+
const container_map = ContainerType{16, mp_fix_map_min, 0, mp_map_16, mp_map_32}
111127

112128
// valueType is the stream type
113129
enum ValueType {

0 commit comments

Comments
 (0)