Merge from core

This commit is contained in:
Jesse Beder
2014-03-23 20:17:34 -05:00
21 changed files with 577 additions and 683 deletions

View File

@@ -47,11 +47,7 @@ class EmitFromEvents : public EventHandler {
Emitter& m_emitter; Emitter& m_emitter;
struct State { struct State {
enum value { enum value { WaitingForSequenceEntry, WaitingForKey, WaitingForValue };
WaitingForSequenceEntry,
WaitingForKey,
WaitingForValue
};
}; };
std::stack<State::value> m_stateStack; std::stack<State::value> m_stateStack;
}; };

View File

@@ -9,15 +9,7 @@
namespace YAML { namespace YAML {
struct EmitterNodeType { struct EmitterNodeType {
enum value { enum value { None, Property, Scalar, FlowSeq, BlockSeq, FlowMap, BlockMap };
None,
Property,
Scalar,
FlowSeq,
BlockSeq,
FlowMap,
BlockMap
};
}; };
} }

View File

@@ -85,11 +85,7 @@ inline _Anchor Anchor(const std::string content) { return _Anchor(content); }
struct _Tag { struct _Tag {
struct Type { struct Type {
enum value { enum value { Verbatim, PrimaryHandle, NamedHandle };
Verbatim,
PrimaryHandle,
NamedHandle
};
}; };
explicit _Tag(const std::string& prefix_, const std::string& content_, explicit _Tag(const std::string& prefix_, const std::string& content_,

View File

@@ -10,103 +10,71 @@
namespace YAML { namespace YAML {
template <typename> template <typename>
struct is_numeric { struct is_numeric {
enum { enum { value = false };
value = false
};
}; };
template <> template <>
struct is_numeric<char> { struct is_numeric<char> {
enum { enum { value = true };
value = true
};
}; };
template <> template <>
struct is_numeric<unsigned char> { struct is_numeric<unsigned char> {
enum { enum { value = true };
value = true
};
}; };
template <> template <>
struct is_numeric<int> { struct is_numeric<int> {
enum { enum { value = true };
value = true
};
}; };
template <> template <>
struct is_numeric<unsigned int> { struct is_numeric<unsigned int> {
enum { enum { value = true };
value = true
};
}; };
template <> template <>
struct is_numeric<long int> { struct is_numeric<long int> {
enum { enum { value = true };
value = true
};
}; };
template <> template <>
struct is_numeric<unsigned long int> { struct is_numeric<unsigned long int> {
enum { enum { value = true };
value = true
};
}; };
template <> template <>
struct is_numeric<short int> { struct is_numeric<short int> {
enum { enum { value = true };
value = true
};
}; };
template <> template <>
struct is_numeric<unsigned short int> { struct is_numeric<unsigned short int> {
enum { enum { value = true };
value = true
};
}; };
#if defined(_MSC_VER) && (_MSC_VER < 1310) #if defined(_MSC_VER) && (_MSC_VER < 1310)
template <> template <>
struct is_numeric<__int64> { struct is_numeric<__int64> {
enum { enum { value = true };
value = true
};
}; };
template <> template <>
struct is_numeric<unsigned __int64> { struct is_numeric<unsigned __int64> {
enum { enum { value = true };
value = true
};
}; };
#else #else
template <> template <>
struct is_numeric<long long> { struct is_numeric<long long> {
enum { enum { value = true };
value = true
};
}; };
template <> template <>
struct is_numeric<unsigned long long> { struct is_numeric<unsigned long long> {
enum { enum { value = true };
value = true
};
}; };
#endif #endif
template <> template <>
struct is_numeric<float> { struct is_numeric<float> {
enum { enum { value = true };
value = true
};
}; };
template <> template <>
struct is_numeric<double> { struct is_numeric<double> {
enum { enum { value = true };
value = true
};
}; };
template <> template <>
struct is_numeric<long double> { struct is_numeric<long double> {
enum { enum { value = true };
value = true
};
}; };
template <bool, class T = void> template <bool, class T = void>

View File

@@ -12,14 +12,7 @@
namespace YAML { namespace YAML {
struct CollectionType { struct CollectionType {
enum value { enum value { None, BlockMap, BlockSeq, FlowMap, FlowSeq, CompactMap };
None,
BlockMap,
BlockSeq,
FlowMap,
FlowSeq,
CompactMap
};
}; };
class CollectionStack { class CollectionStack {

View File

@@ -8,8 +8,8 @@ Directives::Directives() {
version.minor = 2; version.minor = 2;
} }
const std::string Directives::TranslateTagHandle(const std::string& handle) const std::string Directives::TranslateTagHandle(
const { const std::string& handle) const {
std::map<std::string, std::string>::const_iterator it = tags.find(handle); std::map<std::string, std::string>::const_iterator it = tags.find(handle);
if (it == tags.end()) { if (it == tags.end()) {
if (handle == "!!") if (handle == "!!")

View File

@@ -82,8 +82,8 @@ void EmitterState::StartedNode() {
m_hasNonContent = false; m_hasNonContent = false;
} }
EmitterNodeType::value EmitterState::NextGroupType(GroupType::value type) EmitterNodeType::value EmitterState::NextGroupType(
const { GroupType::value type) const {
if (type == GroupType::Seq) { if (type == GroupType::Seq) {
if (GetFlowType(type) == Block) if (GetFlowType(type) == Block)
return EmitterNodeType::BlockSeq; return EmitterNodeType::BlockSeq;

View File

@@ -19,24 +19,13 @@
namespace YAML { namespace YAML {
struct FmtScope { struct FmtScope {
enum value { enum value { Local, Global };
Local,
Global
};
}; };
struct GroupType { struct GroupType {
enum value { enum value { None, Seq, Map };
None,
Seq,
Map
};
}; };
struct FlowType { struct FlowType {
enum value { enum value { None, Flow, Block };
None,
Flow,
Block
};
}; };
class EmitterState { class EmitterState {

View File

@@ -13,9 +13,7 @@
namespace YAML { namespace YAML {
namespace Utils { namespace Utils {
namespace { namespace {
enum { enum { REPLACEMENT_CHARACTER = 0xFFFD };
REPLACEMENT_CHARACTER = 0xFFFD
};
bool IsAnchorChar(int ch) { // test for ns-anchor-char bool IsAnchorChar(int ch) { // test for ns-anchor-char
switch (ch) { switch (ch) {

View File

@@ -21,12 +21,7 @@ namespace YAML {
class Binary; class Binary;
struct StringFormat { struct StringFormat {
enum value { enum value { Plain, SingleQuoted, DoubleQuoted, Literal };
Plain,
SingleQuoted,
DoubleQuoted,
Literal
};
}; };
namespace Utils { namespace Utils {

View File

@@ -104,8 +104,8 @@ inline int RegEx::MatchOpEmpty(const Source& source) const {
} }
template <> template <>
inline int RegEx::MatchOpEmpty<StringCharSource>(const StringCharSource& source) inline int RegEx::MatchOpEmpty<StringCharSource>(
const { const StringCharSource& source) const {
return !source return !source
? 0 ? 0
: -1; // the empty regex only is successful on the empty string : -1; // the empty regex only is successful on the empty string

View File

@@ -36,16 +36,8 @@ class Scanner {
private: private:
struct IndentMarker { struct IndentMarker {
enum INDENT_TYPE { enum INDENT_TYPE { MAP, SEQ, NONE };
MAP, enum STATUS { VALID, INVALID, UNKNOWN };
SEQ,
NONE
};
enum STATUS {
VALID,
INVALID,
UNKNOWN
};
IndentMarker(int column_, INDENT_TYPE type_) IndentMarker(int column_, INDENT_TYPE type_)
: column(column_), type(type_), status(VALID), pStartToken(0) {} : column(column_), type(type_), status(VALID), pStartToken(0) {}
@@ -55,10 +47,7 @@ class Scanner {
Token *pStartToken; Token *pStartToken;
}; };
enum FLOW_MARKER { enum FLOW_MARKER { FLOW_MAP, FLOW_SEQ };
FLOW_MAP,
FLOW_SEQ
};
private: private:
// scanning // scanning

View File

@@ -13,21 +13,9 @@
#include "stream.h" #include "stream.h"
namespace YAML { namespace YAML {
enum CHOMP { enum CHOMP { STRIP = -1, CLIP, KEEP };
STRIP = -1, enum ACTION { NONE, BREAK, THROW };
CLIP, enum FOLD { DONT_FOLD, FOLD_BLOCK, FOLD_FLOW };
KEEP
};
enum ACTION {
NONE,
BREAK,
THROW
};
enum FOLD {
DONT_FOLD,
FOLD_BLOCK,
FOLD_FLOW
};
struct ScanScalarParams { struct ScanScalarParams {
ScanScalarParams() ScanScalarParams()

View File

@@ -70,42 +70,42 @@ static bool s_introFinalState[] = {false, // uis_start
static UtfIntroState s_introTransitions[][uictMax] = { static UtfIntroState s_introTransitions[][uictMax] = {
// uict00, uictBB, uictBF, uictEF, // uict00, uictBB, uictBF, uictEF,
// uictFE, uictFF, uictAscii, uictOther // uictFE, uictFF, uictAscii, uictOther
{uis_utfbe_b1, uis_utf8, uis_utf8, uis_utf8_bom1, {uis_utfbe_b1, uis_utf8, uis_utf8, uis_utf8_bom1, uis_utf16be_bom1,
uis_utf16be_bom1, uis_utfle_bom1, uis_utf8_imp, uis_utf8}, uis_utfle_bom1, uis_utf8_imp, uis_utf8},
{uis_utf32be_b2, uis_utf8, uis_utf8, uis_utf8, {uis_utf32be_b2, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8,
uis_utf8, uis_utf8, uis_utf16be, uis_utf8}, uis_utf16be, uis_utf8},
{uis_utf32be, uis_utf8, uis_utf8, uis_utf8, {uis_utf32be, uis_utf8, uis_utf8, uis_utf8, uis_utf32be_bom3, uis_utf8,
uis_utf32be_bom3, uis_utf8, uis_utf8, uis_utf8}, uis_utf8, uis_utf8},
{uis_utf8, uis_utf8, uis_utf8, uis_utf8, {uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf32be, uis_utf8,
uis_utf8, uis_utf32be, uis_utf8, uis_utf8}, uis_utf8},
{uis_utf32be, uis_utf32be, uis_utf32be, uis_utf32be, {uis_utf32be, uis_utf32be, uis_utf32be, uis_utf32be, uis_utf32be,
uis_utf32be, uis_utf32be, uis_utf32be, uis_utf32be}, uis_utf32be, uis_utf32be, uis_utf32be},
{uis_utf16be, uis_utf16be, uis_utf16be, uis_utf16be, {uis_utf16be, uis_utf16be, uis_utf16be, uis_utf16be, uis_utf16be,
uis_utf16be, uis_utf16be, uis_utf16be, uis_utf16be}, uis_utf16be, uis_utf16be, uis_utf16be},
{uis_utf8, uis_utf8, uis_utf8, uis_utf8, {uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf16be, uis_utf8,
uis_utf8, uis_utf16be, uis_utf8, uis_utf8}, uis_utf8},
{uis_utf8, uis_utf8, uis_utf8, uis_utf8, {uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf16le_bom2, uis_utf8,
uis_utf16le_bom2, uis_utf8, uis_utf8, uis_utf8}, uis_utf8, uis_utf8},
{uis_utf32le_bom3, uis_utf16le, uis_utf16le, uis_utf16le, {uis_utf32le_bom3, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le,
uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le}, uis_utf16le, uis_utf16le, uis_utf16le},
{uis_utf32le, uis_utf16le, uis_utf16le, uis_utf16le, {uis_utf32le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le,
uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le}, uis_utf16le, uis_utf16le, uis_utf16le},
{uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, {uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le,
uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le}, uis_utf16le, uis_utf16le, uis_utf16le},
{uis_utf32le, uis_utf32le, uis_utf32le, uis_utf32le, {uis_utf32le, uis_utf32le, uis_utf32le, uis_utf32le, uis_utf32le,
uis_utf32le, uis_utf32le, uis_utf32le, uis_utf32le}, uis_utf32le, uis_utf32le, uis_utf32le},
{uis_utf16le_imp, uis_utf8, uis_utf8, uis_utf8, {uis_utf16le_imp, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8,
uis_utf8, uis_utf8, uis_utf8, uis_utf8}, uis_utf8, uis_utf8},
{uis_utf32le_imp3, uis_utf16le, uis_utf16le, uis_utf16le, {uis_utf32le_imp3, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le,
uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le}, uis_utf16le, uis_utf16le, uis_utf16le},
{uis_utf32le, uis_utf16le, uis_utf16le, uis_utf16le, {uis_utf32le, uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le,
uis_utf16le, uis_utf16le, uis_utf16le, uis_utf16le}, uis_utf16le, uis_utf16le, uis_utf16le},
{uis_utf8, uis_utf8_bom2, uis_utf8, uis_utf8, {uis_utf8, uis_utf8_bom2, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8,
uis_utf8, uis_utf8, uis_utf8, uis_utf8}, uis_utf8},
{uis_utf8, uis_utf8, uis_utf8, uis_utf8, {uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8,
uis_utf8, uis_utf8, uis_utf8, uis_utf8}, uis_utf8},
{uis_utf8, uis_utf8, uis_utf8, uis_utf8, {uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8, uis_utf8,
uis_utf8, uis_utf8, uis_utf8, uis_utf8}, }; uis_utf8}, };
static char s_introUngetCount[][uictMax] = { static char s_introUngetCount[][uictMax] = {
// uict00, uictBB, uictBF, uictEF, uictFE, uictFF, uictAscii, uictOther // uict00, uictBB, uictBF, uictEF, uictFE, uictFF, uictAscii, uictOther

View File

@@ -41,13 +41,7 @@ class Stream : private noncopyable {
void ResetColumn() { m_mark.column = 0; } void ResetColumn() { m_mark.column = 0; }
private: private:
enum CharacterSet { enum CharacterSet { utf8, utf16le, utf16be, utf32le, utf32be };
utf8,
utf16le,
utf16be,
utf32le,
utf32be
};
std::istream& m_input; std::istream& m_input;
Mark m_mark; Mark m_mark;

View File

@@ -22,11 +22,7 @@ const std::string TokenNames[] = {
struct Token { struct Token {
// enums // enums
enum STATUS { enum STATUS { VALID, INVALID, UNVERIFIED };
VALID,
INVALID,
UNVERIFIED
};
enum TYPE { enum TYPE {
DIRECTIVE, DIRECTIVE,
DOC_START, DOC_START,

View File

@@ -6,6 +6,7 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
using ::testing::_; using ::testing::_;
using ::testing::InSequence;
namespace YAML { namespace YAML {
namespace { namespace {
@@ -92,6 +93,7 @@ class EncodingTest : public HandlerTest {
} }
void Run() { void Run() {
InSequence sequence;
EXPECT_CALL(handler, OnDocumentStart(_)); EXPECT_CALL(handler, OnDocumentStart(_));
EXPECT_CALL(handler, OnSequenceStart(_, "?", 0)); EXPECT_CALL(handler, OnSequenceStart(_, "?", 0));
for (std::size_t i = 0; i < m_entries.size(); i++) { for (std::size_t i = 0; i < m_entries.size(); i++) {

View File

@@ -9755,6 +9755,5 @@ TEST_F(GenEmitterTest, test19e33bce2d816b447759) {
EXPECT_CALL(handler, OnDocumentEnd()); EXPECT_CALL(handler, OnDocumentEnd());
Parse(out.c_str()); Parse(out.c_str());
} }
} }
} }

View File

@@ -21,5 +21,4 @@ class MockEventHandler : public EventHandler {
MOCK_METHOD3(OnMapStart, void(const Mark&, const std::string&, anchor_t)); MOCK_METHOD3(OnMapStart, void(const Mark&, const std::string&, anchor_t));
MOCK_METHOD0(OnMapEnd, void()); MOCK_METHOD0(OnMapEnd, void());
}; };
} }