fix self references

try removing self references in method definitions.
If this creates awkward wording, it can always be allowed
in another CL. Also tighten rules for identifying function
references in include comments.

R=briansoman@google.com, caryclark@google.com
TBR=reed@google.com
Bug: skia:6898
Change-Id: I1a0e6b2a76dacfe71d134deb4589fb74e6611a03
Reviewed-on: https://skia-review.googlesource.com/28624
Commit-Queue: Cary Clark <caryclark@skia.org>
Reviewed-by: Cary Clark <caryclark@skia.org>
This commit is contained in:
Cary Clark 2017-07-31 11:48:27 -04:00 committed by Skia Commit-Bot
parent df0e09feac
commit 579985ce4f
6 changed files with 128 additions and 84 deletions

View File

@ -359,7 +359,8 @@ Used by subclasses with custom implementations for draw methods.
#Param width Zero or greater. ##
#Param height Zero or greater. ##
#Param props The LCD striping orientation and setting for device independent fonts.
If nullptr, use Legacy_Font_Host settings. ##
If nullptr, use Legacy_Font_Host settings.
#Param ##
#Return Canvas placeholder with dimensions. ##
@ -2372,7 +2373,8 @@ This is private API to be used only by Android framework.
##
#Param rect The maximum allowed clip in device coordinates.
Empty rect means max clip is not enforced. ##
Empty rect means max clip is not enforced.
#Param ##
##
@ -5240,11 +5242,14 @@ Image_Filter, and Blend_Mode. If Shader is provided it is treated as the Coons
patch texture; Blend_Mode mode combines Color colors and Shader if both are provided.
#Param cubics Point array cubics specifying the four cubics starting at the top left corner,
in clockwise order, sharing every fourth point. The last cubic ends at the first point. ##
in clockwise order, sharing every fourth point. The last cubic ends at the first point.
#Param ##
#Param colors Color array color associating colors with corners in top left, top right, bottom right,
bottom left order. ##
bottom left order.
#Param ##
#Param texCoords Point array texCoords mapping Shader as texture to corners in same order, if paint
contains Shader; or nullptr. ##
contains Shader; or nullptr.
#Param ##
#Param mode Blend_Mode for colors and Shader if present. ##
#Param paint Shader, Color_Filter, Blend_Mode, used to draw. ##
@ -5288,11 +5293,14 @@ Image_Filter, (?) and Blend_Mode. If Shader is provided it is treated as the Coo
patch texture.
#Param cubics Point array cubics specifying the four cubics starting at the top left corner,
in clockwise order, sharing every fourth point. The last cubic ends at the first point. ##
in clockwise order, sharing every fourth point. The last cubic ends at the first point.
#Param ##
#Param colors Color array color associating colors with corners in top left, top right, bottom right,
bottom left order; or nullptr. ##
bottom left order; or nullptr.
#Param ##
#Param texCoords Point array texCoords mapping Shader as texture to corners in same order, if paint
contains Shader; or nullptr. ##
contains Shader; or nullptr.
#Param ##
#Param paint Shader, Color_Filter, Blend_Mode, used to draw. ##
#Example

View File

@ -1500,7 +1500,7 @@ Automatic_Hinting only affects platforms that use FreeType as the Font_Manager.
Automatic_Hinting has no effect if Hinting is set to kNo_Hinting or
kSlight_Hinting.
setAutohinted only affects platforms that use FreeType as the Font_Manager.
Only affects platforms that use FreeType as the Font_Manager.
Sets kAutoHinting_Flag if useAutohinter is true.
Clears kAutoHinting_Flag if useAutohinter is false.
@ -1814,7 +1814,7 @@ draws faster; a higher setting looks better when the image is scaled.
Sets Filter_Quality, the image filtering level. A lower setting
draws faster; a higher setting looks better when the image is scaled.
setFilterQuality does not check to see if quality is valid.
Does not check to see if quality is valid.
#Param quality one of: kNone_SkFilterQuality, kLow_SkFilterQuality,
kMedium_SkFilterQuality, kHigh_SkFilterQuality
@ -2613,7 +2613,7 @@ void draw(SkCanvas* canvas) {
 The geometry drawn at the corners of strokes.
#Param join one of: kMiter_Join, kRound_Join, kBevel_Join;
otherwise, setStrokeJoin has no effect
otherwise, has no effect
##
#Example
@ -2978,7 +2978,7 @@ void draw(SkCanvas* canvas) {
#Method SkBlendMode getBlendMode() const
Returns Blend_Mode.
By default, getBlendMode returns SkBlendMode::kSrcOver.
By default, returns SkBlendMode::kSrcOver.
#Return mode used to combine source color with destination color ##
@ -3643,7 +3643,7 @@ Deprecated.
Sets Draw_Looper to drawLooper,
decrementing Reference_Count of the previous drawLooper.
Pass nullptr to clear Draw_Looper and leave Draw_Looper effect on drawing unaltered.
setDrawLooper does not alter drawLooper Reference_Count.
Does not alter drawLooper Reference_Count.
#Param drawLooper Iterates through drawing one or more time, altering Paint ##
@ -4084,7 +4084,8 @@ void draw(SkCanvas* canvas) {
Invalid values for encoding are ignored.
#Param encoding one of: kUTF8_TextEncoding, kUTF16_TextEncoding, kUTF32_TextEncoding, or
kGlyphID_TextEncoding ##
kGlyphID_TextEncoding
#Param ##
#Example
SkPaint paint;
@ -4421,7 +4422,7 @@ void draw(SkCanvas* canvas) {
descent, ascent, and leading.
Result is scaled by Text_Size but does not take into account
dimensions required by stroking and Path_Effect.
getFontSpacing returns the same result as getFontMetrics.
Returns the same result as getFontMetrics.
 #Return recommended spacing between lines ##
@ -4447,11 +4448,11 @@ void draw(SkCanvas* canvas) {
Returns the union of bounds of all glyphs.
Returned dimensions are computed by Font_Manager from font data,
ignoring Hinting. getFontBounds includes Text_Size, Text_Scale_X,
ignoring Hinting. Includes Text_Size, Text_Scale_X,
and Text_Skew_X, but not Fake_Bold or Path_Effect.
If Text_Size is large, Text_Scale_X is one, and Text_Skew_X is zero,
getFontBounds returns the same bounds as Font_Metrics { FontMetrics::fXMin,
returns the same bounds as Font_Metrics { FontMetrics::fXMin,
FontMetrics::fTop, FontMetrics::fXMax, FontMetrics::fBottom }.
#Return union of bounds of all glyphs ##
@ -4486,7 +4487,7 @@ glyphs may be nullptr, to compute the glyph count.
Does not check text for valid character encoding or valid
glyph indices.
If byteLength equals zero, textToGlyphs returns zero.
If byteLength equals zero, returns zero.
If byteLength includes a partial character, the partial character is ignored.
If Text_Encoding is kUTF8_TextEncoding and
@ -4545,8 +4546,8 @@ text contains an invalid UTF-8 sequence, zero is returned.
Returns false if any characters in text are not supported in
Typeface.
If Text_Encoding is kGlyphID_TextEncoding, containsText
returns true if all glyph indices in text are non-zero; containsText
If Text_Encoding is kGlyphID_TextEncoding,
returns true if all glyph indices in text are non-zero;
does not check to see if text contains valid glyph indices for Typeface.
Returns true if bytelength is zero.
@ -4827,7 +4828,7 @@ Returns the geometry as Path equivalent to the drawn text.
Uses Text_Encoding to decode text, Typeface to get the glyph paths,
and Text_Size, Fake_Bold, and Path_Effect to scale and modify the glyph paths.
All of the glyph paths are stored in path.
getTextPath uses x, y, and Text_Align to position path.
Uses x, y, and Text_Align to position path.
#Param text character codes or glyph indices ##
#Param length number of bytes of text ##
@ -5121,8 +5122,8 @@ void draw(SkCanvas* canvas) {
#Method bool nothingToDraw() const
Returns true if Paint prevents all drawing.
If nothingToDraw returns false, the Paint may or may not allow drawing.
Returns true if Paint prevents all drawing;
otherwise, the Paint may or may not allow drawing.
Returns true if Blend_Mode and Color_Alpha are enabled,
and computed Color_Alpha is zero.

View File

@ -288,7 +288,7 @@ public:
/** If true, pixels on the active edges of SkPath may be drawn with partial transparency.
Equivalent to getFlags masked with kAntiAlias_Flag.
Equivalent to getFlags() masked with kAntiAlias_Flag.
@return kAntiAlias_Flag state
*/
@ -308,7 +308,7 @@ public:
/** If true, color error may be distributed to smooth color transition.
Equivalent to getFlags masked with kDither_Flag.
Equivalent to getFlags() masked with kDither_Flag.
@return kDither_Flag state
*/
@ -327,7 +327,7 @@ public:
/** If true, text is converted to SkPath before drawing and measuring.
Equivalent to getFlags masked with kLinearText_Flag.
Equivalent to getFlags() masked with kLinearText_Flag.
@return kLinearText_Flag state
*/
@ -347,7 +347,7 @@ public:
/** If true, glyphs at different sub-pixel positions may differ on pixel edge coverage.
Equivalent to getFlags masked with kSubpixelText_Flag.
Equivalent to getFlags() masked with kSubpixelText_Flag.
@return kSubpixelText_Flag state
*/
@ -385,7 +385,7 @@ public:
/** If true, font engine may return glyphs from font bitmaps instead of from outlines.
Equivalent to getFlags masked with kEmbeddedBitmapText_Flag.
Equivalent to getFlags() masked with kEmbeddedBitmapText_Flag.
@return kEmbeddedBitmapText_Flag state
*/
@ -406,7 +406,7 @@ public:
platform uses FreeType as the font manager, instruct the font manager to always hint
glyphs.
Equivalent to getFlags masked with kAutoHinting_Flag.
Equivalent to getFlags() masked with kAutoHinting_Flag.
@return kAutoHinting_Flag state
*/
@ -419,7 +419,7 @@ public:
auto-hinting has no effect if SkPaint::Hinting is set to kNo_Hinting or
kSlight_Hinting.
setAutohinted only affects platforms that use FreeType as the font manager.
Only affects platforms that use FreeType as the font manager.
Sets kAutoHinting_Flag if useAutohinter is true.
Clears kAutoHinting_Flag if useAutohinter is false.
@ -430,7 +430,7 @@ public:
/** If true, glyphs are drawn top to bottom instead of left to right.
Equivalent to getFlags masked with kVerticalText_Flag.
Equivalent to getFlags() masked with kVerticalText_Flag.
@return kVerticalText_Flag state
*/
@ -451,7 +451,7 @@ public:
/** If true, approximate bold by increasing the stroke width when creating glyph bitmaps
from outlines.
Equivalent to getFlags masked with kFakeBoldText_Flag.
Equivalent to getFlags() masked with kFakeBoldText_Flag.
@return kFakeBoldText_Flag state
*/
@ -470,7 +470,7 @@ public:
/** Returns if character spacing may be adjusted by the hinting difference.
Equivalent to getFlags masked with kDevKernText_Flag.
Equivalent to getFlags() masked with kDevKernText_Flag.
@return kDevKernText_Flag state
*/
@ -499,7 +499,7 @@ public:
/** Sets SkFilterQuality, the image filtering level. A lower setting
draws faster; a higher setting looks better when the image is scaled.
setFilterQuality does not check to see if quality is valid.
Does not check to see if quality is valid.
@param quality one of: kNone_SkFilterQuality, kLow_SkFilterQuality,
kMedium_SkFilterQuality, kHigh_SkFilterQuality
@ -713,7 +713,7 @@ public:
/** The geometry drawn at the corners of strokes.
@param join one of: kMiter_Join, kRound_Join, kBevel_Join;
otherwise, setStrokeJoin has no effect
otherwise, has no effect
*/
void setStrokeJoin(Join join);
@ -790,7 +790,7 @@ public:
void setColorFilter(sk_sp<SkColorFilter> colorFilter);
/** Returns SkBlendMode.
By default, getBlendMode returns SkBlendMode::kSrcOver.
By default, returns SkBlendMode::kSrcOver.
@return mode used to combine source color with destination color
*/
@ -951,7 +951,7 @@ public:
/** Sets SkDrawLooper to drawLooper,
decrementing SkRefCnt of the previous drawLooper.
Pass nullptr to clear SkDrawLooper and leave SkDrawLooper effect on drawing unaltered.
setDrawLooper does not alter drawLooper SkRefCnt.
Does not alter drawLooper SkRefCnt.
@param drawLooper Iterates through drawing one or more time, altering SkPaint
*/
@ -970,7 +970,7 @@ public:
SkCanvas::drawPosTextH, SkCanvas::drawTextOnPath,
SkCanvas::drawTextOnPathHV, SkCanvas::drawTextRSXform, SkCanvas::drawTextBlob,
and SkCanvas::drawString;
as well as calls that place text glyphs like getTextWidths and getTextPath.
as well as calls that place text glyphs like getTextWidths() and getTextPath().
The text position is set by the font for both horizontal and vertical text.
Typically, for horizontal text, the position is to the left side of the glyph on the
@ -1093,11 +1093,12 @@ public:
Invalid values for encoding are ignored.
@param encoding one of: kUTF8_TextEncoding, kUTF16_TextEncoding, kUTF32_TextEncoding, or
kGlyphID_TextEncoding
*/
void setTextEncoding(TextEncoding encoding);
/** \struct SkPaint::FontMetrics
FontMetrics is filled out by getFontMetrics. FontMetrics contents reflect the values
FontMetrics is filled out by getFontMetrics(). FontMetrics contents reflect the values
computed by font manager using SkTypeface. Values are set to zero if they are
not availble.
@ -1288,7 +1289,7 @@ public:
descent, ascent, and leading.
Result is scaled by text size but does not take into account
dimensions required by stroking and SkPathEffect.
getFontSpacing returns the same result as getFontMetrics.
Returns the same result as getFontMetrics().
@return recommended spacing between lines
*/
@ -1302,7 +1303,7 @@ public:
Does not check text for valid character encoding or valid
glyph indices.
If byteLength equals zero, textToGlyphs returns zero.
If byteLength equals zero, returns zero.
If byteLength includes a partial character, the partial character is ignored.
If SkPaint::TextEncoding is kUTF8_TextEncoding and
@ -1320,8 +1321,8 @@ public:
Returns false if any characters in text are not supported in
SkTypeface.
If SkPaint::TextEncoding is kGlyphID_TextEncoding, containsText
returns true if all glyph indices in text are non-zero; containsText
If SkPaint::TextEncoding is kGlyphID_TextEncoding,
returns true if all glyph indices in text are non-zero;
does not check to see if text contains valid glyph indices for SkTypeface.
Returns true if bytelength is zero.
@ -1347,7 +1348,7 @@ public:
/** Returns the number of glyphs in text.
Uses SkPaint::TextEncoding to count the glyphs.
Returns the same result as textToGlyphs.
Returns the same result as textToGlyphs().
@param text character stroage encoded with SkPaint::TextEncoding
@param byteLength length of character storage in bytes
@ -1433,7 +1434,7 @@ public:
Uses SkPaint::TextEncoding to decode text, SkTypeface to get the glyph paths,
and text size, fake bold, and SkPathEffect to scale and modify the glyph paths.
All of the glyph paths are stored in path.
getTextPath uses x, y, and SkPaint::Align to position path.
Uses x, y, and SkPaint::Align to position path.
@param text character codes or glyph indices
@param length number of bytes of text
@ -1549,19 +1550,19 @@ public:
/** Returns the union of bounds of all glyphs.
Returned dimensions are computed by font manager from font data,
ignoring SkPaint::Hinting. getFontBounds includes text size, text scale x,
ignoring SkPaint::Hinting. Includes text size, text scale x,
and text skew x, but not fake bold or SkPathEffect.
If text size is large, text scale x is one, and text skew x is zero,
getFontBounds returns the same bounds as SkPaint::FontMetrics { FontMetrics::fXMin,
returns the same bounds as SkPaint::FontMetrics { FontMetrics::fXMin,
FontMetrics::fTop, FontMetrics::fXMax, FontMetrics::fBottom }.
@return union of bounds of all glyphs
*/
SkRect getFontBounds() const;
/** Returns true if SkPaint prevents all drawing.
If nothingToDraw returns false, the SkPaint may or may not allow drawing.
/** Returns true if SkPaint prevents all drawing;
otherwise, the SkPaint may or may not allow drawing.
Returns true if SkBlendMode and alpha are enabled,
and computed alpha is zero.
@ -1580,7 +1581,7 @@ public:
bool canComputeFastBounds() const;
/** (to be made private)
Only call this if canComputeFastBounds returned true. This takes a
Only call this if canComputeFastBounds() returned true. This takes a
raw rectangle (the raw bounds of a shape), and adjusts it for stylistic
effects in the paint (e.g. stroking). If needed, it uses the storage
rect parameter. It returns the adjusted bounds that can then be used

View File

@ -48,20 +48,10 @@ more complications I haven't figured out. I don't know when or how to pluralize
references. This should be "objects' reference counts" probably, but then
I lose the link to SkRefCnt.
SkPaint.bmh line 2074
arcs at front of sentence not capitalized
SkPaint.bmh line 2639
I'd argue that 'fill path' is OK, in that is it the path that will fill, not the path
that has already been filled. I see the awkwardness though, and will add it to my bug list.
check for function name in its own description
multiple line #Param / #Return only copies first line?
rework underlinethickness / strikeout thickness
getTextIntercepts lost underline comment
*/
static string normalized_name(string name) {
@ -1018,6 +1008,19 @@ bool BmhParser::addDefinition(const char* defStart, bool hasEnd, MarkType markTy
if (!this->popParentStack(fParent)) { // if not one liner, pop
return false;
}
if (MarkType::kParam == markType || MarkType::kReturn == markType) {
const char* parmEndCheck = definition->fContentEnd;
while (parmEndCheck < definition->fTerminator) {
if (fMC == parmEndCheck[0]) {
break;
}
if (' ' < parmEndCheck[0]) {
this->reportError<bool>(
"use full end marker on multiline #Param and #Return");
}
++parmEndCheck;
}
}
} else {
fMarkup.emplace_front(markType, defStart, fLineCount, fParent);
definition = &fMarkup.front();

View File

@ -1625,19 +1625,21 @@ public:
void enumMembersOut(const RootDefinition* root, const Definition& child);
void enumSizeItems(const Definition& child);
int lookupMethod(const PunctuationState punctuation, const Word word,
const int start, const int run, int lastWrite, const char last,
const int start, const int run, int lastWrite,
const char* data);
int lookupReference(const PunctuationState punctuation, const Word word,
const int start, const int run, int lastWrite, const char last,
const char* data);
void methodOut(const Definition* method);
void methodOut(const Definition* method, const Definition& child);
bool populate(Definition* def, RootDefinition* root);
bool populate(BmhParser& bmhParser);
void reset() override {
INHERITED::resetCommon();
fBmhMethod = nullptr;
fBmhParser = nullptr;
fEnumDef = nullptr;
fMethodDef = nullptr;
fStructDef = nullptr;
fAnonymousEnumCount = 1;
fInStruct = false;
@ -1654,7 +1656,9 @@ public:
private:
BmhParser* fBmhParser;
Definition* fDeferComment;
const Definition* fBmhMethod;
const Definition* fEnumDef;
const Definition* fMethodDef;
const Definition* fStructDef;
const char* fContinuation; // used to construct paren-qualified method name
int fAnonymousEnumCount;

View File

@ -322,7 +322,9 @@ void IncludeWriter::enumSizeItems(const Definition& child) {
}
// walk children and output complete method doxygen description
void IncludeWriter::methodOut(const Definition* method) {
void IncludeWriter::methodOut(const Definition* method, const Definition& child) {
fBmhMethod = method;
fMethodDef = &child;
fContinuation = nullptr;
fDeferComment = nullptr;
if (0 == fIndent) {
@ -414,6 +416,8 @@ void IncludeWriter::methodOut(const Definition* method) {
fIndent -= 4;
this->lfcr();
this->writeCommentTrailer();
fBmhMethod = nullptr;
fMethodDef = nullptr;
}
void IncludeWriter::structOut(const Definition* root, const Definition& child,
@ -596,7 +600,7 @@ bool IncludeWriter::populate(Definition* def, RootDefinition* root) {
params.skipToEndBracket('(');
if (params.fEnd - params.fChar >= childLen &&
!strncmp(params.fChar, child.fContentStart, childLen)) {
this->methodOut(clonedMethod);
this->methodOut(clonedMethod, child);
break;
}
++alternate;
@ -636,7 +640,7 @@ bool IncludeWriter::populate(Definition* def, RootDefinition* root) {
fclose(fOut); // so we can see what we've written so far
return this->reportError<bool>("method not found");
}
this->methodOut(method);
this->methodOut(method, child);
continue;
}
methodName += "()";
@ -645,7 +649,7 @@ bool IncludeWriter::populate(Definition* def, RootDefinition* root) {
method = method->fParent;
}
if (method) {
this->methodOut(method);
this->methodOut(method, child);
continue;
}
fLineCount = child.fLineCount;
@ -680,7 +684,7 @@ bool IncludeWriter::populate(Definition* def, RootDefinition* root) {
clonedMethod = method;
continue;
}
this->methodOut(method);
this->methodOut(method, child);
continue;
}
if (Definition::Type::kKeyWord == child.fType) {
@ -903,9 +907,11 @@ static string ConvertRef(const string str, bool first) {
return substitute;
}
// FIXME: buggy that this is called with strings containing spaces but resolveRef below is not..
string IncludeWriter::resolveMethod(const char* start, const char* end, bool first) {
string methodname(start, end - start);
if (string::npos != methodname.find("()")) {
return "";
}
string substitute;
auto rootDefIter = fBmhParser->fMethodMap.find(methodname);
if (fBmhParser->fMethodMap.end() != rootDefIter) {
@ -925,6 +931,11 @@ string IncludeWriter::resolveMethod(const char* start, const char* end, bool fir
substitute = methodname + "()";
}
}
if (fMethodDef && methodname == fMethodDef->fName) {
TextParser report(fBmhMethod);
report.reportError("method should not include references to itself");
return "";
}
return substitute;
}
@ -953,6 +964,8 @@ string IncludeWriter::resolveRef(const char* start, const char* end, bool first)
}
}
SkDebugf("unfound: %s\n", undername.c_str());
this->reportError("reference unfound");
return "";
}
}
}
@ -1004,25 +1017,30 @@ string IncludeWriter::resolveRef(const char* start, const char* end, bool first)
}
return substitute;
}
int IncludeWriter::lookupMethod(const PunctuationState punctuation, const Word word,
const int start, const int run, int lastWrite, const char last, const char* data) {
const int end = PunctuationState::kDelimiter == punctuation ||
const int lastSpace, const int run, int lastWrite, const char* data) {
int wordStart = lastSpace;
while (' ' >= data[wordStart]) {
++wordStart;
}
const int wordEnd = PunctuationState::kDelimiter == punctuation ||
PunctuationState::kPeriod == punctuation ? run - 1 : run;
string temp = this->resolveMethod(&data[start], &data[end], Word::kFirst == word);
string temp = this->resolveMethod(&data[wordStart], &data[wordEnd], Word::kFirst == word);
if (temp.length()) {
if (start > lastWrite) {
SkASSERT(data[start - 1] >= ' ');
if (wordStart > lastWrite) {
SkASSERT(data[wordStart - 1] >= ' ');
if (' ' == data[lastWrite]) {
this->writeSpace();
}
this->writeBlockTrim(start - lastWrite, &data[lastWrite]);
if (' ' == data[start - 1]) {
this->writeBlockTrim(wordStart - lastWrite, &data[lastWrite]);
if (' ' == data[wordStart - 1]) {
this->writeSpace();
}
}
SkASSERT(temp[temp.length() - 1] > ' ');
this->writeString(temp.c_str());
lastWrite = end;
lastWrite = wordEnd;
}
return lastWrite;
}
@ -1076,8 +1094,10 @@ IncludeWriter::Wrote IncludeWriter::rewriteBlock(int size, const char* data) {
int lastWrite = 0;
int lineFeeds = 0;
int lastPrintable = 0;
int lastSpace = -1;
char c = 0;
char last;
bool embeddedSymbol = false;
bool hasLower = false;
bool hasUpper = false;
bool hasSymbol = false;
@ -1120,9 +1140,9 @@ IncludeWriter::Wrote IncludeWriter::rewriteBlock(int size, const char* data) {
lastWrite, last, data);
break;
case Word::kMixed:
if (hasUpper && hasLower && !hasSymbol) {
lastWrite = this->lookupMethod(punctuation, word, start, run,
lastWrite, last, data);
if (hasUpper && hasLower && !hasSymbol && lastSpace > 0) {
lastWrite = this->lookupMethod(punctuation, word, lastSpace, run,
lastWrite, data);
}
break;
default:
@ -1132,9 +1152,11 @@ IncludeWriter::Wrote IncludeWriter::rewriteBlock(int size, const char* data) {
(PunctuationState::kStart == punctuation && ' ' >= last) ?
PunctuationState::kStart : PunctuationState::kSpace;
word = Word::kStart;
embeddedSymbol = false;
hasLower = false;
hasUpper = false;
hasSymbol = false;
lastSpace = run;
break;
case '.':
switch (word) {
@ -1153,10 +1175,9 @@ IncludeWriter::Wrote IncludeWriter::rewriteBlock(int size, const char* data) {
default:
SkASSERT(0);
}
hasSymbol = true;
embeddedSymbol = true;
break;
case ',': case ';': case ':':
hasSymbol |= PunctuationState::kDelimiter == punctuation;
switch (word) {
case Word::kStart:
punctuation = PunctuationState::kDelimiter;
@ -1173,13 +1194,14 @@ IncludeWriter::Wrote IncludeWriter::rewriteBlock(int size, const char* data) {
default:
SkASSERT(0);
}
embeddedSymbol = true;
break;
case '\'': // possessive apostrophe isn't treated as delimiting punctation
case '=':
case '!': // assumed not to be punctuation, but a programming symbol
case '&': case '>': case '<': case '{': case '}': case '/': case '*':
word = Word::kMixed;
hasSymbol = true;
embeddedSymbol = true;
break;
case '(':
if (' ' == last) {
@ -1187,11 +1209,11 @@ IncludeWriter::Wrote IncludeWriter::rewriteBlock(int size, const char* data) {
} else {
word = Word::kMixed;
}
hasSymbol = true;
embeddedSymbol = true;
break;
case ')': // assume word type has already been set
punctuation = PunctuationState::kDelimiter;
hasSymbol = true;
embeddedSymbol = true;
break;
case '_':
switch (word) {
@ -1208,6 +1230,7 @@ IncludeWriter::Wrote IncludeWriter::rewriteBlock(int size, const char* data) {
default:
SkASSERT(0);
}
hasSymbol |= embeddedSymbol;
break;
case 'A': case 'B': case 'C': case 'D': case 'E':
case 'F': case 'G': case 'H': case 'I': case 'J':
@ -1242,6 +1265,7 @@ IncludeWriter::Wrote IncludeWriter::rewriteBlock(int size, const char* data) {
PunctuationState::kDelimiter == punctuation) {
word = Word::kMixed;
}
hasSymbol |= embeddedSymbol;
break;
case 'a': case 'b': case 'c': case 'd': case 'e':
case 'f': case 'g': case 'h': case 'i': case 'j':
@ -1266,6 +1290,7 @@ IncludeWriter::Wrote IncludeWriter::rewriteBlock(int size, const char* data) {
}
hasLower = true;
punctuation = PunctuationState::kStart;
hasSymbol |= embeddedSymbol;
break;
default:
SkASSERT(0);
@ -1274,6 +1299,8 @@ IncludeWriter::Wrote IncludeWriter::rewriteBlock(int size, const char* data) {
}
if ((word == Word::kCap || word == Word::kFirst || word == Word::kUnderline) && hasLower) {
lastWrite = this->lookupReference(punctuation, word, start, run, lastWrite, last, data);
} else if (word == Word::kMixed && hasUpper && hasLower && !hasSymbol && lastSpace > 0) {
lastWrite = this->lookupMethod(punctuation, word, lastSpace, run, lastWrite, data);
}
if (run > lastWrite) {
if (' ' == data[lastWrite]) {