Commit 58e0fb89 authored by Milo Yip's avatar Milo Yip

In iterative parsing, always use SizeType to prevent potential alignment problem on some platforms.

parent 7fa194d1
...@@ -1045,9 +1045,9 @@ private: ...@@ -1045,9 +1045,9 @@ private:
else if (src == IterativeParsingKeyValueDelimiterState) else if (src == IterativeParsingKeyValueDelimiterState)
n = IterativeParsingMemberValueState; n = IterativeParsingMemberValueState;
// Push current state. // Push current state.
*stack_.template Push<IterativeParsingState>(1) = n; *stack_.template Push<SizeType>(1) = n;
// Initialize and push the member/element count. // Initialize and push the member/element count.
*stack_.template Push<int>(1) = 0; *stack_.template Push<SizeType>(1) = 0;
// Call handler // Call handler
bool hr = (dst == IterativeParsingObjectInitialState) ? handler.StartObject() : handler.StartArray(); bool hr = (dst == IterativeParsingObjectInitialState) ? handler.StartObject() : handler.StartArray();
// On handler short circuits the parsing. // On handler short circuits the parsing.
...@@ -1096,18 +1096,18 @@ private: ...@@ -1096,18 +1096,18 @@ private:
case IterativeParsingElementDelimiterState: case IterativeParsingElementDelimiterState:
is.Take(); is.Take();
// Update member/element count. // Update member/element count.
*stack_.template Top<int>() = *stack_.template Top<int>() + 1; *stack_.template Top<SizeType>() = *stack_.template Top<SizeType>() + 1;
return dst; return dst;
case IterativeParsingObjectFinishState: case IterativeParsingObjectFinishState:
{ {
// Get member count. // Get member count.
int c = *stack_.template Pop<int>(1); SizeType c = *stack_.template Pop<SizeType>(1);
// If the object is not empty, count the last member. // If the object is not empty, count the last member.
if (src == IterativeParsingMemberValueState) if (src == IterativeParsingMemberValueState)
++c; ++c;
// Restore the state. // Restore the state.
IterativeParsingState n = *stack_.template Pop<IterativeParsingState>(1); IterativeParsingState n = static_cast<IterativeParsingState>(*stack_.template Pop<SizeType>(1));
// Transit to Finish state if this is the topmost scope. // Transit to Finish state if this is the topmost scope.
if (n == IterativeParsingStartState) if (n == IterativeParsingStartState)
n = IterativeParsingFinishState; n = IterativeParsingFinishState;
...@@ -1127,12 +1127,12 @@ private: ...@@ -1127,12 +1127,12 @@ private:
case IterativeParsingArrayFinishState: case IterativeParsingArrayFinishState:
{ {
// Get element count. // Get element count.
int c = *stack_.template Pop<int>(1); SizeType c = *stack_.template Pop<SizeType>(1);
// If the array is not empty, count the last element. // If the array is not empty, count the last element.
if (src == IterativeParsingElementState) if (src == IterativeParsingElementState)
++c; ++c;
// Restore the state. // Restore the state.
IterativeParsingState n = *stack_.template Pop<IterativeParsingState>(1); IterativeParsingState n = static_cast<IterativeParsingState>(*stack_.template Pop<SizeType>(1));
// Transit to Finish state if this is the topmost scope. // Transit to Finish state if this is the topmost scope.
if (n == IterativeParsingStartState) if (n == IterativeParsingStartState)
n = IterativeParsingFinishState; n = IterativeParsingFinishState;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment