Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions flatdata-cpp/include/flatdata/DebugDataAccessStatistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <shared_mutex>
#include <utility>
#include <vector>
#include <algorithm>

namespace flatdata
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ enum : {{ node.type|cpp_base_type}}
{% if node.doc %}
{{- node.doc|cpp_doc }}
{% endif %}
{{ node.name }} = {{ node.value }}
{{ node.name }} = {{ node.value }}{{ node.type.annotation }}
};
{%- endmacro %}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ enum class {{ enum.name }} : {{ enum.type|cpp_base_type }}
{% if value.doc %}
{{ value.doc|cpp_doc }}
{% endif %}
{{ value.name }} = {{ value.value }}{{ "," if not loop.last }}
{{ value.name }} = {{ value.value }}{{ enum.type.annotation }}{{ "," if not loop.last }}
{% endfor %}
};

Expand Down
16 changes: 16 additions & 0 deletions flatdata-generator/flatdata/generator/tree/helpers/basictype.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ class BasicType:
"i64": 64
}

_TYPE_ANNOTATION = {
"bool": "",
"u8": "",
"i8": "",
"u16": "",
"i16": "",
"u32": "UL",
"i32": "L",
"u64": "ULL",
"i64": "LL"
}

@staticmethod
def is_basic_type(name):
return name in grammar.BASIC_TYPES
Expand All @@ -41,6 +53,10 @@ def width(self):
def is_signed(self):
return self._name[0] == 'i'

@property
def annotation(self):
return self._TYPE_ANNOTATION[self._name]

def bits_required(self, value):
if self.is_signed:
if value >= 0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ def name(self):
def width(self):
return self._type.width

@property
def annotation(self):
return self._type.annotation

@property
def is_signed(self):
return self._type.is_signed
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
enum : uint32_t
{
// This is a comment about foo
FOO = 0
FOO = 0UL
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ enum : uint64_t
/*
* This is a comment about bar
*/
BAR = 0
BAR = 0ULL
};
Original file line number Diff line number Diff line change
Expand Up @@ -141,139 +141,139 @@ enum : uint16_t
namespace n {
enum : int32_t
{
FOO_I32_NEG = -2147483648
FOO_I32_NEG = -2147483648L
};
} // namespace n

namespace n {
enum : int32_t
{
FOO_I32_POS = 2147483647
FOO_I32_POS = 2147483647L
};
} // namespace n

namespace n {
enum : int32_t
{
FOO_I32_ZERO = 0
FOO_I32_ZERO = 0L
};
} // namespace n

namespace n {
enum : int32_t
{
FOO_I32_NEG_HEX = -2147483648
FOO_I32_NEG_HEX = -2147483648L
};
} // namespace n

namespace n {
enum : int32_t
{
FOO_I32_POS_HEX = 2147483647
FOO_I32_POS_HEX = 2147483647L
};
} // namespace n

namespace n {
enum : int32_t
{
FOO_I32_ZERO_HEX = 0
FOO_I32_ZERO_HEX = 0L
};
} // namespace n

namespace n {
enum : uint32_t
{
FOO_U32_POS = 4294967295
FOO_U32_POS = 4294967295UL
};
} // namespace n

namespace n {
enum : uint32_t
{
FOO_U32_ZERO = 0
FOO_U32_ZERO = 0UL
};
} // namespace n

namespace n {
enum : uint32_t
{
FOO_U32_POS_HEX = 4294967295
FOO_U32_POS_HEX = 4294967295UL
};
} // namespace n

namespace n {
enum : uint32_t
{
FOO_U32_ZERO_HEX = 0
FOO_U32_ZERO_HEX = 0UL
};
} // namespace n

namespace n {
enum : int64_t
{
FOO_I64_NEG = -9223372036854775808
FOO_I64_NEG = -9223372036854775808LL
};
} // namespace n

namespace n {
enum : int64_t
{
FOO_I64_POS = 9223372036854775807
FOO_I64_POS = 9223372036854775807LL
};
} // namespace n

namespace n {
enum : int64_t
{
FOO_I64_ZERO = 0
FOO_I64_ZERO = 0LL
};
} // namespace n

namespace n {
enum : int64_t
{
FOO_I64_NEG_HEX = -9223372036854775808
FOO_I64_NEG_HEX = -9223372036854775808LL
};
} // namespace n

namespace n {
enum : int64_t
{
FOO_I64_POS_HEX = 9223372036854775807
FOO_I64_POS_HEX = 9223372036854775807LL
};
} // namespace n

namespace n {
enum : int64_t
{
FOO_I64_ZERO_HEX = 0
FOO_I64_ZERO_HEX = 0LL
};
} // namespace n

namespace n {
enum : uint64_t
{
FOO_U64_POS = 18446744073709551615
FOO_U64_POS = 18446744073709551615ULL
};
} // namespace n

namespace n {
enum : uint64_t
{
FOO_U64_ZERO = 0
FOO_U64_ZERO = 0ULL
};
} // namespace n

namespace n {
enum : uint64_t
{
FOO_U64_POS_HEX = 18446744073709551615
FOO_U64_POS_HEX = 18446744073709551615ULL
};
} // namespace n

namespace n {
enum : uint64_t
{
FOO_U64_ZERO_HEX = 0
FOO_U64_ZERO_HEX = 0ULL
};
} // namespace n
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
enum class Foo : uint64_t
{
// This is a comment about Foo.a
A = 0,
A = 0ULL,
// This is a comment about Foo.b
B = 1
B = 1ULL
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ enum class Bar : uint64_t
/*
* This is a comment about Bar.a
*/
A = 0,
A = 0ULL,
/*
* This is a comment about Bar.b
*/
B = 1
B = 1ULL
};
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ namespace n {

enum class EnumI32 : int32_t
{
VALUE = 0,
UNKNOWN_VALUE_MINUS_1 = -1
VALUE = 0L,
UNKNOWN_VALUE_MINUS_1 = -1L
};

inline
Expand Down Expand Up @@ -350,8 +350,8 @@ namespace n {

enum class EnumU32 : uint32_t
{
VALUE = 0,
UNKNOWN_VALUE_1 = 1
VALUE = 0UL,
UNKNOWN_VALUE_1 = 1UL
};

inline
Expand Down Expand Up @@ -418,8 +418,8 @@ namespace n {

enum class EnumI64 : int64_t
{
VALUE = 0,
UNKNOWN_VALUE_MINUS_1 = -1
VALUE = 0LL,
UNKNOWN_VALUE_MINUS_1 = -1LL
};

inline
Expand Down Expand Up @@ -486,8 +486,8 @@ namespace n {

enum class EnumU64 : uint64_t
{
VALUE = 0,
UNKNOWN_VALUE_1 = 1
VALUE = 0ULL,
UNKNOWN_VALUE_1 = 1ULL
};

inline
Expand Down
Loading