Refactor: Apply consistent formatting and fix include order
diff --git a/compiler/util/parser_types.py b/compiler/util/parser_types.py
index a3ef34d..89cb186 100644
--- a/compiler/util/parser_types.py
+++ b/compiler/util/parser_types.py
@@ -15,7 +15,7 @@
"""Types related to the LR(1) parser.
This module contains types used by the LR(1) parser, which are also used in
-other parts of the compiler:
+other parts of the compiler:
SourcePosition: a position (zero-width) within a source file.
SourceLocation: a span within a source file.
diff --git a/runtime/cpp/emboss_defines.h b/runtime/cpp/emboss_defines.h
index e76d231..14b578b 100644
--- a/runtime/cpp/emboss_defines.h
+++ b/runtime/cpp/emboss_defines.h
@@ -245,7 +245,7 @@
// GCC's attribute syntax disallows parentheses in that particular position.
#if !defined(EMBOSS_ALIAS_SAFE_POINTER_CAST)
#define EMBOSS_ALIAS_SAFE_POINTER_CAST(t, x) \
- reinterpret_cast<t __attribute__((__may_alias__)) *>((x))
+ reinterpret_cast<t __attribute__((__may_alias__))*>((x))
#endif // !defined(EMBOSS_LITTLE_ENDIAN_TO_NATIVE)
#endif // !defined(__INTEL_COMPILER)
diff --git a/runtime/cpp/test/emboss_cpp_types_test.cc b/runtime/cpp/test/emboss_cpp_types_test.cc
index c88c640..41306b9 100644
--- a/runtime/cpp/test/emboss_cpp_types_test.cc
+++ b/runtime/cpp/test/emboss_cpp_types_test.cc
@@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include <cstddef>
-
#include "runtime/cpp/emboss_cpp_types.h"
+#include <cstddef>
+
#include "gtest/gtest.h"
namespace emboss {
@@ -101,20 +101,20 @@
EXPECT_TRUE(
(::std::is_same<LeastWidthInteger<64>::Signed, ::std::int64_t>::value));
#if EMBOSS_HAS_INT128
- EXPECT_TRUE((
- ::std::is_same<LeastWidthInteger<65>::Unsigned, __uint128_t>::value));
+ EXPECT_TRUE(
+ (::std::is_same<LeastWidthInteger<65>::Unsigned, __uint128_t>::value));
EXPECT_TRUE(
(::std::is_same<LeastWidthInteger<65>::Signed, __int128_t>::value));
- EXPECT_TRUE((
- ::std::is_same<LeastWidthInteger<96>::Unsigned, __uint128_t>::value));
+ EXPECT_TRUE(
+ (::std::is_same<LeastWidthInteger<96>::Unsigned, __uint128_t>::value));
EXPECT_TRUE(
(::std::is_same<LeastWidthInteger<96>::Signed, __int128_t>::value));
- EXPECT_TRUE((
- ::std::is_same<LeastWidthInteger<127>::Unsigned, __uint128_t>::value));
+ EXPECT_TRUE(
+ (::std::is_same<LeastWidthInteger<127>::Unsigned, __uint128_t>::value));
EXPECT_TRUE(
(::std::is_same<LeastWidthInteger<127>::Signed, __int128_t>::value));
- EXPECT_TRUE((
- ::std::is_same<LeastWidthInteger<128>::Unsigned, __uint128_t>::value));
+ EXPECT_TRUE(
+ (::std::is_same<LeastWidthInteger<128>::Unsigned, __uint128_t>::value));
EXPECT_TRUE(
(::std::is_same<LeastWidthInteger<128>::Signed, __int128_t>::value));
#endif // EMBOSS_HAS_INT128
diff --git a/runtime/cpp/test/emboss_prelude_test.cc b/runtime/cpp/test/emboss_prelude_test.cc
index fe92782..a46617a 100644
--- a/runtime/cpp/test/emboss_prelude_test.cc
+++ b/runtime/cpp/test/emboss_prelude_test.cc
@@ -38,9 +38,9 @@
TEST(FlagView, Methods) {
::std::uint8_t byte = 0;
- auto flag_view =
- FlagView<ViewParameters<1>, OffsetBitBlock<BitBlockN<8>>>{BitBlockN<8>{
- ReadWriteContiguousBuffer{&byte, 1}}.GetOffsetStorage<1, 0>(0, 1)};
+ auto flag_view = FlagView<ViewParameters<1>, OffsetBitBlock<BitBlockN<8>>>{
+ BitBlockN<8>{ReadWriteContiguousBuffer{&byte, 1}}.GetOffsetStorage<1, 0>(
+ 0, 1)};
EXPECT_FALSE(flag_view.Read());
byte = 0xfe;
EXPECT_FALSE(flag_view.Read());
@@ -60,8 +60,9 @@
TEST(FlagView, TextDecode) {
::std::uint8_t byte = 0;
const auto flag_view =
- FlagView<ViewParameters<1>, OffsetBitBlock<BitBlockN<8>>>{BitBlockN<8>{
- ReadWriteContiguousBuffer{&byte, 1}}.GetOffsetStorage<1, 0>(0, 1)};
+ FlagView<ViewParameters<1>, OffsetBitBlock<BitBlockN<8>>>{
+ BitBlockN<8>{ReadWriteContiguousBuffer{&byte, 1}}
+ .GetOffsetStorage<1, 0>(0, 1)};
EXPECT_FALSE(UpdateFromText(flag_view, ""));
EXPECT_FALSE(UpdateFromText(flag_view, "FALSE"));
EXPECT_FALSE(UpdateFromText(flag_view, "TRUE"));
@@ -85,8 +86,9 @@
TEST(FlagView, TextEncode) {
::std::uint8_t byte = 0;
const auto flag_view =
- FlagView<ViewParameters<1>, OffsetBitBlock<BitBlockN<8>>>{BitBlockN<8>{
- ReadWriteContiguousBuffer{&byte, 1}}.GetOffsetStorage<1, 0>(0, 1)};
+ FlagView<ViewParameters<1>, OffsetBitBlock<BitBlockN<8>>>{
+ BitBlockN<8>{ReadWriteContiguousBuffer{&byte, 1}}
+ .GetOffsetStorage<1, 0>(0, 1)};
EXPECT_EQ("false", WriteToString(flag_view));
byte = 1;
EXPECT_EQ("true", WriteToString(flag_view));
@@ -158,15 +160,18 @@
UIntView<ViewParameters<64>, BitBlockType>::ValueType>::value));
#if EMBOSS_HAS_INT128
using BitBlockType128 = BitBlockN<128>;
- EXPECT_TRUE((::std::is_same<
- __uint128_t,
- UIntView<ViewParameters<65>, BitBlockType128>::ValueType>::value));
- EXPECT_TRUE((::std::is_same<
- __uint128_t,
- UIntView<ViewParameters<96>, BitBlockType128>::ValueType>::value));
- EXPECT_TRUE((::std::is_same<
- __uint128_t,
- UIntView<ViewParameters<128>, BitBlockType128>::ValueType>::value));
+ EXPECT_TRUE(
+ (::std::is_same<
+ __uint128_t,
+ UIntView<ViewParameters<65>, BitBlockType128>::ValueType>::value));
+ EXPECT_TRUE(
+ (::std::is_same<
+ __uint128_t,
+ UIntView<ViewParameters<96>, BitBlockType128>::ValueType>::value));
+ EXPECT_TRUE(
+ (::std::is_same<
+ __uint128_t,
+ UIntView<ViewParameters<128>, BitBlockType128>::ValueType>::value));
#endif // EMBOSS_HAS_INT128
}
@@ -296,9 +301,9 @@
TEST(UIntView, NonByteSize) {
::std::vector</**/ ::std::uint8_t> bytes = {{0x00, 0x00, 0x80, 0x80}};
auto uint23_view =
- UIntView<ViewParameters<23>, OffsetBitBlock<BitBlockN<24>>>{BitBlockN<24>{
- ReadWriteContiguousBuffer{bytes.data(),
- 3}}.GetOffsetStorage<1, 0>(0, 23)};
+ UIntView<ViewParameters<23>, OffsetBitBlock<BitBlockN<24>>>{
+ BitBlockN<24>{ReadWriteContiguousBuffer{bytes.data(), 3}}
+ .GetOffsetStorage<1, 0>(0, 23)};
EXPECT_EQ(0x0U, uint23_view.Read());
EXPECT_FALSE(uint23_view.CouldWriteValue(0x800f0e));
EXPECT_FALSE(uint23_view.CouldWriteValue(0x800000));
@@ -366,15 +371,15 @@
IntView<ViewParameters<64>, BitBlockType>::ValueType>::value));
#if EMBOSS_HAS_INT128
using BitBlockType128 = BitBlockN<128>;
- EXPECT_TRUE((::std::is_same<
- __int128_t,
- IntView<ViewParameters<65>, BitBlockType128>::ValueType>::value));
- EXPECT_TRUE((::std::is_same<
- __int128_t,
- IntView<ViewParameters<96>, BitBlockType128>::ValueType>::value));
- EXPECT_TRUE((::std::is_same<
- __int128_t,
- IntView<ViewParameters<128>, BitBlockType128>::ValueType>::value));
+ EXPECT_TRUE(
+ (::std::is_same<__int128_t, IntView<ViewParameters<65>,
+ BitBlockType128>::ValueType>::value));
+ EXPECT_TRUE(
+ (::std::is_same<__int128_t, IntView<ViewParameters<96>,
+ BitBlockType128>::ValueType>::value));
+ EXPECT_TRUE(
+ (::std::is_same<__int128_t, IntView<ViewParameters<128>,
+ BitBlockType128>::ValueType>::value));
#endif // EMBOSS_HAS_INT128
}
@@ -509,10 +514,9 @@
TEST(IntView, NonByteSize) {
::std::vector</**/ ::std::uint8_t> bytes = {{0x00, 0x00, 0x80, 0x80}};
- auto int23_view =
- IntView<ViewParameters<23>, OffsetBitBlock<BitBlockN<24>>>{BitBlockN<24>{
- ReadWriteContiguousBuffer{bytes.data(),
- 3}}.GetOffsetStorage<1, 0>(0, 23)};
+ auto int23_view = IntView<ViewParameters<23>, OffsetBitBlock<BitBlockN<24>>>{
+ BitBlockN<24>{ReadWriteContiguousBuffer{bytes.data(), 3}}
+ .GetOffsetStorage<1, 0>(0, 23)};
EXPECT_EQ(0x0, int23_view.Read());
EXPECT_FALSE(int23_view.CouldWriteValue(0x400f0e));
#if EMBOSS_CHECK_ABORTS
@@ -533,9 +537,9 @@
TEST(IntView, OneBit) {
::std::uint8_t bytes[] = {0xfe};
- auto int1_view =
- IntView<ViewParameters<1>, OffsetBitBlock<BitBlockN<8>>>{BitBlockN<8>{
- ReadWriteContiguousBuffer{bytes, 1}}.GetOffsetStorage<1, 0>(0, 1)};
+ auto int1_view = IntView<ViewParameters<1>, OffsetBitBlock<BitBlockN<8>>>{
+ BitBlockN<8>{ReadWriteContiguousBuffer{bytes, 1}}.GetOffsetStorage<1, 0>(
+ 0, 1)};
EXPECT_TRUE(int1_view.Ok());
EXPECT_TRUE(int1_view.IsComplete());
EXPECT_EQ(0, int1_view.Read());
@@ -780,10 +784,9 @@
TEST(BcdView, NonByteSize) {
::std::vector</**/ ::std::uint8_t> bytes = {{0x00, 0x00, 0x80, 0x80}};
- auto bcd23_view =
- BcdView<ViewParameters<23>, OffsetBitBlock<BitBlockN<24>>>{BitBlockN<24>{
- ReadWriteContiguousBuffer{bytes.data(),
- 3}}.GetOffsetStorage<1, 0>(0, 23)};
+ auto bcd23_view = BcdView<ViewParameters<23>, OffsetBitBlock<BitBlockN<24>>>{
+ BitBlockN<24>{ReadWriteContiguousBuffer{bytes.data(), 3}}
+ .GetOffsetStorage<1, 0>(0, 23)};
EXPECT_EQ(0x0U, bcd23_view.Read());
EXPECT_FALSE(bcd23_view.CouldWriteValue(800000));
EXPECT_TRUE(bcd23_view.CouldWriteValue(799999));
diff --git a/testdata/__init__.py b/testdata/__init__.py
index 086a24e..e69de29 100644
--- a/testdata/__init__.py
+++ b/testdata/__init__.py
@@ -1,13 +0,0 @@
-# Copyright 2019 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
diff --git a/testdata/int128_sizes.emb b/testdata/int128_sizes.emb
index 120ef7a..1e988c2 100644
--- a/testdata/int128_sizes.emb
+++ b/testdata/int128_sizes.emb
@@ -20,49 +20,49 @@
struct UInt128Sizes:
- 0 [+9] UInt nine_byte
- 9 [+10] UInt ten_byte
- 19 [+11] UInt eleven_byte
- 30 [+12] UInt twelve_byte
- 42 [+13] UInt thirteen_byte
- 55 [+14] UInt fourteen_byte
- 69 [+15] UInt fifteen_byte
- 84 [+16] UInt sixteen_byte
+ 0 [+9] UInt nine_byte
+ 9 [+10] UInt ten_byte
+ 19 [+11] UInt eleven_byte
+ 30 [+12] UInt twelve_byte
+ 42 [+13] UInt thirteen_byte
+ 55 [+14] UInt fourteen_byte
+ 69 [+15] UInt fifteen_byte
+ 84 [+16] UInt sixteen_byte
struct Int128Sizes:
- 0 [+9] Int nine_byte
- 9 [+10] Int ten_byte
- 19 [+11] Int eleven_byte
- 30 [+12] Int twelve_byte
- 42 [+13] Int thirteen_byte
- 55 [+14] Int fourteen_byte
- 69 [+15] Int fifteen_byte
- 84 [+16] Int sixteen_byte
+ 0 [+9] Int nine_byte
+ 9 [+10] Int ten_byte
+ 19 [+11] Int eleven_byte
+ 30 [+12] Int twelve_byte
+ 42 [+13] Int thirteen_byte
+ 55 [+14] Int fourteen_byte
+ 69 [+15] Int fifteen_byte
+ 84 [+16] Int sixteen_byte
struct BigEndianUInt128Sizes:
[$default byte_order: "BigEndian"]
- 0 [+9] UInt nine_byte
- 9 [+10] UInt ten_byte
- 19 [+11] UInt eleven_byte
- 30 [+12] UInt twelve_byte
- 42 [+13] UInt thirteen_byte
- 55 [+14] UInt fourteen_byte
- 69 [+15] UInt fifteen_byte
- 84 [+16] UInt sixteen_byte
+ 0 [+9] UInt nine_byte
+ 9 [+10] UInt ten_byte
+ 19 [+11] UInt eleven_byte
+ 30 [+12] UInt twelve_byte
+ 42 [+13] UInt thirteen_byte
+ 55 [+14] UInt fourteen_byte
+ 69 [+15] UInt fifteen_byte
+ 84 [+16] UInt sixteen_byte
struct BigEndianInt128Sizes:
[$default byte_order: "BigEndian"]
- 0 [+9] Int nine_byte
- 9 [+10] Int ten_byte
- 19 [+11] Int eleven_byte
- 30 [+12] Int twelve_byte
- 42 [+13] Int thirteen_byte
- 55 [+14] Int fourteen_byte
- 69 [+15] Int fifteen_byte
- 84 [+16] Int sixteen_byte
+ 0 [+9] Int nine_byte
+ 9 [+10] Int ten_byte
+ 19 [+11] Int eleven_byte
+ 30 [+12] Int twelve_byte
+ 42 [+13] Int thirteen_byte
+ 55 [+14] Int fourteen_byte
+ 69 [+15] Int fifteen_byte
+ 84 [+16] Int sixteen_byte
struct UInt128ArraySizes:
@@ -77,10 +77,10 @@
struct AnonymousBits128:
- 0 [+16] bits:
- 0 [+65] UInt lower_65_bits
- 65 [+63] UInt upper_63_bits
+ 0 [+16] bits:
+ 0 [+65] UInt lower_65_bits
+ 65 [+63] UInt upper_63_bits
16 [+16] bits:
- 0 [+64] UInt lower_64_bits
- 64 [+64] UInt upper_64_bits
+ 0 [+64] UInt lower_64_bits
+ 64 [+64] UInt upper_64_bits