Skip to content

Commit bb0b9f8

Browse files
committed
mpp: remove no more used enums and things
They are unused after switch to new codec.
1 parent eeb575f commit bb0b9f8

File tree

2 files changed

+5
-148
lines changed

2 files changed

+5
-148
lines changed

src/mpp/Constants.hpp

Lines changed: 5 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#pragma once
21
/*
32
* Copyright 2010-2020, Tarantool AUTHORS, please see AUTHORS file.
43
*
@@ -29,8 +28,9 @@
2928
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3029
* SUCH DAMAGE.
3130
*/
31+
#pragma once
3232

33-
#include <iostream> // TODO - make output to iostream optional?
33+
#include <iostream>
3434
#include <variant>
3535
#include <limits>
3636

@@ -52,42 +52,6 @@ enum Family : uint8_t {
5252
};
5353
} // namespace compact {
5454

55-
using FamilyUnder_t = uint32_t;
56-
enum Family : FamilyUnder_t {
57-
MP_NIL = 1u << compact::MP_NIL,
58-
MP_IGNR = 1u << compact::MP_IGNR,
59-
MP_BOOL = 1u << compact::MP_BOOL,
60-
MP_INT = 1u << compact::MP_INT,
61-
MP_FLT = 1u << compact::MP_FLT,
62-
MP_STR = 1u << compact::MP_STR,
63-
MP_BIN = 1u << compact::MP_BIN,
64-
MP_ARR = 1u << compact::MP_ARR,
65-
MP_MAP = 1u << compact::MP_MAP,
66-
MP_EXT = 1u << compact::MP_EXT,
67-
MP_NUM = (1u << compact::MP_INT) | (1u << compact::MP_FLT),
68-
MP_NONE = 0,
69-
MP_ANY = std::numeric_limits<FamilyUnder_t>::max(),
70-
};
71-
72-
enum ReadError_t {
73-
READ_ERROR_NEED_MORE,
74-
READ_ERROR_BAD_MSGPACK,
75-
READ_ERROR_WRONG_TYPE,
76-
READ_ERROR_MAX_DEPTH_REACHED,
77-
READ_ERROR_ABORTED_BY_USER,
78-
READ_ERROR_END
79-
};
80-
81-
enum ReadResult_t : FamilyUnder_t {
82-
READ_SUCCESS = 0,
83-
READ_NEED_MORE = 1u << READ_ERROR_NEED_MORE,
84-
READ_BAD_MSGPACK = 1u << READ_ERROR_BAD_MSGPACK,
85-
READ_WRONG_TYPE = 1u << READ_ERROR_WRONG_TYPE,
86-
READ_MAX_DEPTH_REACHED = 1u << READ_ERROR_MAX_DEPTH_REACHED,
87-
READ_ABORTED_BY_USER = 1u << READ_ERROR_ABORTED_BY_USER,
88-
READ_RESULT_END
89-
};
90-
9155
inline const char *FamilyName[] = {
9256
"MP_NIL",
9357
"MP_IGNR",
@@ -120,51 +84,6 @@ inline const char *FamilyHumanName[] = {
12084
};
12185
static_assert(std::size(FamilyHumanName) == compact::MP_END + 2, "Smth is forgotten");
12286

123-
inline const char *ReadErrorName[] = {
124-
"READ_ERROR_NEED_MORE",
125-
"READ_ERROR_BAD_MSGPACK",
126-
"READ_ERROR_WRONG_TYPE",
127-
"READ_ERROR_MAX_DEPTH_REACHED",
128-
"READ_ERROR_ABORTED_BY_USER",
129-
"READ_ERROR_UNKNOWN",
130-
"READ_SUCCESS",
131-
};
132-
static_assert(std::size(ReadErrorName) == READ_ERROR_END + 2, "Forgotten");
133-
134-
inline constexpr Family
135-
operator|(Family a, Family b)
136-
{
137-
return static_cast<Family>(static_cast<FamilyUnder_t>(a) |
138-
static_cast<FamilyUnder_t>(b));
139-
}
140-
141-
inline constexpr Family
142-
operator&(Family a, Family b)
143-
{
144-
return static_cast<Family>(static_cast<FamilyUnder_t>(a) &
145-
static_cast<FamilyUnder_t>(b));
146-
}
147-
148-
inline constexpr ReadResult_t
149-
operator|(ReadResult_t a, ReadResult_t b)
150-
{
151-
return static_cast<ReadResult_t>(static_cast<FamilyUnder_t>(a) |
152-
static_cast<FamilyUnder_t>(b));
153-
}
154-
155-
inline constexpr ReadResult_t
156-
operator&(ReadResult_t a, ReadResult_t b)
157-
{
158-
return static_cast<ReadResult_t>(static_cast<FamilyUnder_t>(a) &
159-
static_cast<FamilyUnder_t>(b));
160-
}
161-
162-
inline constexpr ReadResult_t
163-
operator~(ReadResult_t a)
164-
{
165-
return static_cast<ReadResult_t>(~static_cast<FamilyUnder_t>(a));
166-
}
167-
16887
inline std::ostream&
16988
operator<<(std::ostream& strm, compact::Family t)
17089
{
@@ -174,27 +93,6 @@ operator<<(std::ostream& strm, compact::Family t)
17493
return strm << FamilyName[t];
17594
}
17695

177-
inline std::ostream&
178-
operator<<(std::ostream& strm, Family t)
179-
{
180-
if (t == MP_NONE)
181-
return strm << FamilyName[compact::Family::MP_END + 1];
182-
static_assert(sizeof(FamilyUnder_t) == sizeof(t), "Very wrong");
183-
FamilyUnder_t base = t;
184-
bool first = true;
185-
do {
186-
static_assert(sizeof(unsigned) == sizeof(t), "Wrong ctz");
187-
unsigned part = __builtin_ctz(base);
188-
base ^= 1u << part;
189-
if (first)
190-
first = false;
191-
else
192-
strm << "|";
193-
strm << static_cast<compact::Family>(part);
194-
} while (base != 0);
195-
return strm;
196-
}
197-
19896
template <compact::Family ...FAMILY>
19997
struct family_sequence {
20098
static constexpr std::size_t size() noexcept
@@ -203,7 +101,7 @@ struct family_sequence {
203101
}
204102
};
205103

206-
template <compact::Family NEW_FAMILY, compact::Family ...FAMILY>
104+
template <compact::Family NEW_FAMILY, compact::Family... FAMILY>
207105
static constexpr auto family_sequence_populate(struct family_sequence<FAMILY...>)
208106
{
209107
return family_sequence<NEW_FAMILY, FAMILY...>{};
@@ -250,7 +148,7 @@ struct family_sequence_contains_h<NEEDLE> {
250148
static constexpr bool value = false;
251149
};
252150

253-
} //namespace details
151+
} // namespace details
254152

255153
template <compact::Family NEEDLE, compact::Family ...HAYSTACK>
256154
static constexpr bool family_sequence_contains(family_sequence<HAYSTACK...>) {
@@ -268,40 +166,4 @@ operator<<(std::ostream& strm, family_sequence<FAMILY...>)
268166
return strm;
269167
}
270168

271-
inline std::ostream&
272-
operator<<(std::ostream& strm, ReadError_t t)
273-
{
274-
if (t >= READ_ERROR_END)
275-
return strm << ReadErrorName[READ_ERROR_END]
276-
<< "(" << static_cast<uint64_t>(t) << ")";
277-
return strm << ReadErrorName[t];
278-
}
279-
280-
inline std::ostream&
281-
operator<<(std::ostream& strm, ReadResult_t t)
282-
{
283-
if (t == READ_SUCCESS)
284-
return strm << ReadErrorName[READ_ERROR_END + 1];
285-
static_assert(sizeof(FamilyUnder_t) == sizeof(t), "Very wrong");
286-
FamilyUnder_t base = t;
287-
bool first = true;
288-
do {
289-
static_assert(sizeof(unsigned) == sizeof(t), "Wrong ctz");
290-
unsigned part = __builtin_ctz(base);
291-
base ^= 1u << part;
292-
if (first)
293-
first = false;
294-
else
295-
strm << "|";
296-
strm << static_cast<ReadError_t>(part);
297-
} while (base != 0);
298-
return strm;
299-
}
300-
301-
struct StrValue { uint32_t offset; uint32_t size; };
302-
struct BinValue { uint32_t offset; uint32_t size; };
303-
struct ArrValue { uint32_t offset; uint32_t size; };
304-
struct MapValue { uint32_t offset; uint32_t size; };
305-
struct ExtValue { int8_t type; uint8_t offset; uint32_t size; };
306-
307-
} // namespace mpp {
169+
} // namespace mpp

test/EncDecTest.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,6 @@ test_type_visual()
167167
std::cout << compact::MP_ARR << " "
168168
<< compact::MP_MAP << " "
169169
<< compact::MP_EXT << "\n";
170-
std::cout << MP_NIL << " "
171-
<< MP_BOOL << " "
172-
<< (MP_INT) << " "
173-
<< (MP_BIN | MP_STR) << " "
174-
<< (MP_INT | MP_FLT) << "\n";
175170

176171
std::cout << "(" << family_sequence<>{} << ") "
177172
<< "(" << family_sequence<compact::MP_NIL>{} << ") "

0 commit comments

Comments
 (0)