webm_parser: Convert style to match the rest of libwebm
Remove webm_parser/clang-format-style. Run clang-format -style=file -i for each source file. Change-Id: Ieaf44bd323375cbcfec67014e94b7742d6bda14a
This commit is contained in:
parent
24be76dcb2
commit
25d26028c1
@ -1,91 +0,0 @@
|
||||
---
|
||||
Language: Cpp
|
||||
# BasedOnStyle: Google
|
||||
AccessModifierOffset: -1
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlinesLeft: true
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: true
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: true
|
||||
AlwaysBreakTemplateDeclarations: false
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BraceWrapping:
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 80
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: true
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
|
||||
IncludeCategories:
|
||||
- Regex: '^<.*\.h>'
|
||||
Priority: 1
|
||||
- Regex: '^<.*'
|
||||
Priority: 2
|
||||
- Regex: '.*'
|
||||
Priority: 3
|
||||
IndentCaseLabels: true
|
||||
IndentWidth: 2
|
||||
IndentWrappedFunctionNames: false
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: false
|
||||
PenaltyBreakBeforeFirstCallParameter: 1
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 200
|
||||
PointerAlignment: Left
|
||||
ReflowComments: true
|
||||
SortIncludes: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 2
|
||||
SpacesInAngles: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Auto
|
||||
TabWidth: 8
|
||||
UseTab: Never
|
||||
...
|
||||
|
@ -956,8 +956,10 @@ class DemoCallback : public Callback {
|
||||
PrintValue("timecode", simple_block.timecode);
|
||||
PrintValue("lacing", simple_block.lacing);
|
||||
std::string flags = (simple_block.is_visible) ? "visible" : "invisible";
|
||||
if (simple_block.is_key_frame) flags += ", key frame";
|
||||
if (simple_block.is_discardable) flags += ", discardable";
|
||||
if (simple_block.is_key_frame)
|
||||
flags += ", key frame";
|
||||
if (simple_block.is_discardable)
|
||||
flags += ", discardable";
|
||||
PrintValue("flags", flags);
|
||||
*action = Action::kRead;
|
||||
return Status(Status::kOkCompleted);
|
||||
@ -1096,16 +1098,15 @@ class DemoCallback : public Callback {
|
||||
int main(int argc, char* argv[]) {
|
||||
if ((argc != 1 && argc != 2) ||
|
||||
(argc == 2 && argv[1] == std::string("--help"))) {
|
||||
std::cerr << "Usage:\n"
|
||||
<< argv[0] << " [path-to-webm-file]\n\n"
|
||||
std::cerr << "Usage:\n" << argv[0] << " [path-to-webm-file]\n\n"
|
||||
<< "Prints info for the WebM file specified in the command line. "
|
||||
"If no file is\n"
|
||||
<< "specified, stdin is used as input.\n";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
FILE* file = (argc == 2) ? std::fopen(argv[1], "rb")
|
||||
: std::freopen(nullptr, "rb", stdin);
|
||||
FILE* file = (argc == 2) ? std::fopen(argv[1], "rb") :
|
||||
std::freopen(nullptr, "rb", stdin);
|
||||
if (!file) {
|
||||
std::cerr << "File cannot be opened\n";
|
||||
return EXIT_FAILURE;
|
||||
|
@ -63,8 +63,8 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data,
|
||||
|
||||
#if __AFL_COMPILER
|
||||
int main(int argc, char* argv[]) {
|
||||
FILE* file = (argc == 2) ? std::fopen(argv[1], "rb")
|
||||
: std::freopen(nullptr, "rb", stdin);
|
||||
FILE* file = (argc == 2) ? std::fopen(argv[1], "rb") :
|
||||
std::freopen(nullptr, "rb", stdin);
|
||||
if (!file) {
|
||||
std::cerr << "File cannot be opened\n";
|
||||
return EXIT_FAILURE;
|
||||
|
@ -36,7 +36,8 @@ namespace webm {
|
||||
Otherwise it will return false since the element was ommitted or skipped when
|
||||
parsing.
|
||||
*/
|
||||
template <typename T> class Element {
|
||||
template <typename T>
|
||||
class Element {
|
||||
public:
|
||||
/**
|
||||
Value-initializes the element's value and makes `is_present()` false.
|
||||
|
@ -72,7 +72,8 @@ class FileReader : public Reader {
|
||||
private:
|
||||
struct FileCloseFunctor {
|
||||
void operator()(FILE* file) const {
|
||||
if (file) std::fclose(file);
|
||||
if (file)
|
||||
std::fclose(file);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -45,7 +45,8 @@ class IstreamReader : public Reader {
|
||||
reference derived from `std::istream`.
|
||||
*/
|
||||
template <typename T>
|
||||
explicit IstreamReader(T&& istream) : istream_(new T(std::move(istream))) {}
|
||||
explicit IstreamReader(T&& istream)
|
||||
: istream_(new T(std::move(istream))) {}
|
||||
|
||||
/**
|
||||
Constructs a new reader by moving the provided reader into the new reader.
|
||||
|
@ -60,7 +60,7 @@ class Ancestory {
|
||||
// Constructs an Ancestory using the first count elements of ancestory.
|
||||
// ancestory must have static storage duration.
|
||||
template <std::size_t N>
|
||||
Ancestory(const Id (&ancestory)[N], std::size_t count)
|
||||
Ancestory(const Id(&ancestory)[N], std::size_t count)
|
||||
: begin_(ancestory), end_(ancestory + count) {
|
||||
assert(count <= N);
|
||||
}
|
||||
|
@ -13,7 +13,8 @@ namespace webm {
|
||||
|
||||
std::uint8_t CountLeadingZeros(std::uint8_t value) {
|
||||
// Special case for 0 since we can't shift by sizeof(T) * 8 bytes.
|
||||
if (value == 0) return 8;
|
||||
if (value == 0)
|
||||
return 8;
|
||||
|
||||
std::uint8_t count = 0;
|
||||
while (!(value & (0x80 >> count))) {
|
||||
|
@ -50,11 +50,13 @@ class BlockHeaderParser : public Parser {
|
||||
int timecode_bytes_remaining_ = 2;
|
||||
|
||||
enum class State {
|
||||
/* clang-format off */
|
||||
// State Transitions to state When
|
||||
kReadingTrackNumber, // kReadingTimecode track parsed
|
||||
kReadingTimecode, // kReadingFlags timecode parsed
|
||||
kReadingFlags, // kDone flags parsed
|
||||
kDone, // No transitions from here (must call Init)
|
||||
/* clang-format on */
|
||||
} state_ = State::kReadingTrackNumber;
|
||||
};
|
||||
|
||||
|
@ -274,7 +274,8 @@ Status BasicBlockParser<T>::Feed(Callback* callback, Reader* reader,
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T> bool BasicBlockParser<T>::WasSkipped() const {
|
||||
template <typename T>
|
||||
bool BasicBlockParser<T>::WasSkipped() const {
|
||||
return state_ == State::kSkipping;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,8 @@ namespace webm {
|
||||
// http://www.webmproject.org/docs/container/#Block
|
||||
// http://matroska.org/technical/specs/index.html#block_structure
|
||||
// http://matroska.org/technical/specs/index.html#simpleblock_structure
|
||||
template <typename T> class BasicBlockParser : public ElementParser {
|
||||
template <typename T>
|
||||
class BasicBlockParser : public ElementParser {
|
||||
static_assert(std::is_same<T, Block>::value ||
|
||||
std::is_same<T, SimpleBlock>::value,
|
||||
"T must be Block or SimpleBlock");
|
||||
@ -89,6 +90,7 @@ template <typename T> class BasicBlockParser : public ElementParser {
|
||||
|
||||
// Parsing states for the finite-state machine.
|
||||
enum class State {
|
||||
/* clang-format off */
|
||||
// State Transitions to state When
|
||||
kReadingHeader, // kGettingAction no lacing
|
||||
// kReadingLaceCount yes lacing
|
||||
@ -106,6 +108,7 @@ template <typename T> class BasicBlockParser : public ElementParser {
|
||||
kSkipping, // No transitions from here (must call Init)
|
||||
kReadingFrames, // kDone all frames read
|
||||
kDone, // No transitions from here (must call Init)
|
||||
/* clang-format on */
|
||||
};
|
||||
|
||||
// The current state of the parser.
|
||||
|
@ -26,7 +26,8 @@ namespace webm {
|
||||
// Spec reference for string/binary elements:
|
||||
// http://matroska.org/technical/specs/index.html#EBML_ex
|
||||
// https://github.com/Matroska-Org/ebml-specification/blob/master/specification.markdown#ebml-element-types
|
||||
template <typename T> class ByteParser : public ElementParser {
|
||||
template <typename T>
|
||||
class ByteParser : public ElementParser {
|
||||
public:
|
||||
static_assert(std::is_same<T, std::vector<std::uint8_t>>::value ||
|
||||
std::is_same<T, std::string>::value,
|
||||
|
@ -135,7 +135,8 @@ Status Callback::Skip(Reader* reader, std::uint64_t* bytes_remaining) {
|
||||
assert(reader != nullptr);
|
||||
assert(bytes_remaining != nullptr);
|
||||
|
||||
if (*bytes_remaining == 0) return Status(Status::kOkCompleted);
|
||||
if (*bytes_remaining == 0)
|
||||
return Status(Status::kOkCompleted);
|
||||
|
||||
Status status;
|
||||
do {
|
||||
|
@ -27,7 +27,8 @@ namespace webm {
|
||||
// http://matroska.org/technical/specs/index.html#EBML_ex
|
||||
// https://github.com/Matroska-Org/ebml-specification/blob/master/specification.markdown#element-data-size
|
||||
// https://github.com/Matroska-Org/ebml-specification/blob/master/specification.markdown#ebml-element-types
|
||||
template <typename T> class IntParser : public ElementParser {
|
||||
template <typename T>
|
||||
class IntParser : public ElementParser {
|
||||
public:
|
||||
static_assert(
|
||||
std::is_same<T, std::int64_t>::value ||
|
||||
|
@ -55,7 +55,8 @@ class MasterParser : public ElementParser {
|
||||
//
|
||||
// Initializer lists don't support move-only types (i.e. std::unique_ptr), so
|
||||
// instead a variadic template is used.
|
||||
template <typename... T> explicit MasterParser(T&&... parser_pairs) {
|
||||
template <typename... T>
|
||||
explicit MasterParser(T&&... parser_pairs) {
|
||||
// Prefer an odd reserve size. This makes libc++ use a prime number for the
|
||||
// bucket count. Otherwise, if it happens to be a power of 2, then libc++
|
||||
// will use a power-of-2 bucket count (and since Matroska EBML IDs have low
|
||||
@ -127,6 +128,7 @@ class MasterParser : public ElementParser {
|
||||
private:
|
||||
// Parsing states for the finite-state machine.
|
||||
enum class State {
|
||||
/* clang-format off */
|
||||
// State Transitions to state When
|
||||
kFirstReadOfChildId, // kFinishingReadingChildId size(id) > 1
|
||||
// kReadingChildSize size(id) == 1
|
||||
@ -142,6 +144,7 @@ class MasterParser : public ElementParser {
|
||||
// kFirstReadOfChildId read < my_size_
|
||||
// kEndReached read == my_size_
|
||||
kEndReached, // No transitions from here (must call Init)
|
||||
/* clang-format on */
|
||||
};
|
||||
|
||||
using StdHashId = std::hash<std::underlying_type<Id>::type>;
|
||||
@ -204,7 +207,8 @@ class MasterParser : public ElementParser {
|
||||
|
||||
// Inserts the parser into the parsers_ map and asserts it is the only parser
|
||||
// registers to parse the corresponding Id.
|
||||
template <typename T> void InsertParser(T&& parser) {
|
||||
template <typename T>
|
||||
void InsertParser(T&& parser) {
|
||||
bool inserted = parsers_.insert(std::forward<T>(parser)).second;
|
||||
(void)inserted; // Silence unused variable warning.
|
||||
assert(inserted); // Make sure there aren't duplicates.
|
||||
|
@ -58,7 +58,8 @@ namespace webm {
|
||||
// : MasterValueParser(MakeChild<BoolParser>(Id::kBar, &Foo::bar),
|
||||
// MakeChild<BoolParser>(Id::kBaz, &Foo::baz)) {}
|
||||
// };
|
||||
template <typename T> class MasterValueParser : public ElementParser {
|
||||
template <typename T>
|
||||
class MasterValueParser : public ElementParser {
|
||||
public:
|
||||
Status Init(const ElementMetadata& metadata,
|
||||
std::uint64_t max_size) override {
|
||||
@ -340,10 +341,12 @@ template <typename T> class MasterValueParser : public ElementParser {
|
||||
|
||||
// Helper struct that will be std::true_type if Tag is in Tags, or
|
||||
// std::false_type otherwise.
|
||||
template <typename Tag, typename... Tags> struct HasTag;
|
||||
template <typename Tag, typename... Tags>
|
||||
struct HasTag;
|
||||
|
||||
// Base condition: Tags is empty, so it trivially does not contain Tag.
|
||||
template <typename Tag> struct HasTag<Tag> : std::false_type {};
|
||||
template <typename Tag>
|
||||
struct HasTag<Tag> : std::false_type {};
|
||||
|
||||
// If the head of the Tags list is a different tag, skip it and check the
|
||||
// remaining tags.
|
||||
@ -409,7 +412,8 @@ template <typename T> class MasterValueParser : public ElementParser {
|
||||
return Status(Status::kOkCompleted);
|
||||
}
|
||||
|
||||
template <typename Tag> constexpr static bool has_tag() {
|
||||
template <typename Tag>
|
||||
constexpr static bool has_tag() {
|
||||
return HasTag<Tag, Tags...>::value;
|
||||
}
|
||||
};
|
||||
|
@ -24,7 +24,8 @@ namespace webm {
|
||||
// parsing operations. The parser is allocated when Init is called. This class
|
||||
// is intended to be used with recursive elements, where a parser needs to
|
||||
// recursively instantiate parsers of the same type.
|
||||
template <typename T> class RecursiveParser : public ElementParser {
|
||||
template <typename T>
|
||||
class RecursiveParser : public ElementParser {
|
||||
public:
|
||||
RecursiveParser() = default;
|
||||
|
||||
|
@ -55,10 +55,12 @@ class VirtualBlockParser : public ElementParser {
|
||||
BlockHeaderParser parser_;
|
||||
|
||||
enum class State {
|
||||
/* clang-format off */
|
||||
// State Transitions to state When
|
||||
kReadingHeader, // kValidatingSize header parsed
|
||||
kValidatingSize, // kDone no errors
|
||||
kDone, // No transitions from here (must call Init)
|
||||
/* clang-format on */
|
||||
} state_ = State::kReadingHeader;
|
||||
};
|
||||
|
||||
|
@ -184,6 +184,7 @@ class WebmParser::DocumentParser {
|
||||
private:
|
||||
// Parsing states for the finite-state machine.
|
||||
enum class State {
|
||||
/* clang-format off */
|
||||
// State Transitions to state When
|
||||
kBegin, // kReadingChildId done
|
||||
kReadingChildId, // kReadingChildSize done
|
||||
@ -195,6 +196,7 @@ class WebmParser::DocumentParser {
|
||||
kReadingChildBody, // kValidatingChildSize cached metadata
|
||||
// kReadingChildId otherwise
|
||||
kEndReached, // No transitions from here
|
||||
/* clang-format on */
|
||||
};
|
||||
|
||||
// The parser for parsing child element Ids.
|
||||
|
@ -24,7 +24,8 @@ namespace webm {
|
||||
|
||||
// Base class for unit tests that test an instance of the Parser inteface. The
|
||||
// template parameter T is the parser class being tested.
|
||||
template <typename T> class ParserTest : public testing::Test {
|
||||
template <typename T>
|
||||
class ParserTest : public testing::Test {
|
||||
public:
|
||||
// Sets the reader's internal buffer to the given buffer.
|
||||
virtual void SetReaderData(std::vector<std::uint8_t> data) {
|
||||
@ -34,7 +35,8 @@ template <typename T> class ParserTest : public testing::Test {
|
||||
// Destroys and recreates the parser, forwarding the arguments to the
|
||||
// constructor. This is primarily useful for tests that require the parser to
|
||||
// have different constructor parameters.
|
||||
template <typename... Args> void ResetParser(Args&&... args) {
|
||||
template <typename... Args>
|
||||
void ResetParser(Args&&... args) {
|
||||
parser_.~T();
|
||||
new (&parser_) T(std::forward<Args>(args)...);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace {
|
||||
// Creates a std::array from a string literal (and omits the trailing
|
||||
// NUL-character).
|
||||
template <std::size_t N>
|
||||
std::array<std::uint8_t, N - 1> ArrayFromString(const char (&string)[N]) {
|
||||
std::array<std::uint8_t, N - 1> ArrayFromString(const char(&string)[N]) {
|
||||
std::array<std::uint8_t, N - 1> array;
|
||||
std::copy_n(string, N - 1, array.begin());
|
||||
return array;
|
||||
|
Loading…
Reference in New Issue
Block a user