MCPcopy Create free account
hub / github.com/dirkvranckaert/AndroidDecompiler / formatPointerOrReferenceCast

Method formatPointerOrReferenceCast

astyle/src/ASFormatter.cpp:3645–3701  ·  view source on GitHub ↗

* format pointer or reference cast * currentChar contains the pointer or reference * NOTE: the pointers and references in function definitions * are processed as a cast (e.g. void foo(void*, void*)) * is processed here. */

Source from the content-addressed store, hash-verified

3643 * is processed here.
3644 */
3645void ASFormatter::formatPointerOrReferenceCast(void)
3646{
3647 assert(currentChar == '*' || currentChar == '&' || currentChar == '^');
3648 assert(!isJavaStyle());
3649
3650 int pa = pointerAlignment;
3651 int ra = referenceAlignment;
3652 int itemAlignment = (currentChar == '*' || currentChar == '^') ? pa : ((ra == REF_SAME_AS_PTR) ? pa : ra);
3653
3654 string sequenceToInsert(1, currentChar);
3655 if (isSequenceReached("**") || isSequenceReached("&&"))
3656 {
3657 goForward(1);
3658 sequenceToInsert.append(1, currentLine[charNum]);
3659 }
3660 if (itemAlignment == PTR_ALIGN_NONE)
3661 {
3662 appendSequence(sequenceToInsert, false);
3663 return;
3664 }
3665 // remove preceding whitespace
3666 char prevCh = ' ';
3667 size_t prevNum = formattedLine.find_last_not_of(" \t");
3668 if (prevNum != string::npos)
3669 {
3670 prevCh = formattedLine[prevNum];
3671 if (prevNum + 1 < formattedLine.length()
3672 && isWhiteSpace(formattedLine[prevNum + 1])
3673 && prevCh != '(')
3674 {
3675 spacePadNum -= (formattedLine.length() - 1 - prevNum);
3676 formattedLine.erase(prevNum + 1);
3677 }
3678 }
3679 bool isAfterScopeResolution = previousNonWSChar == ':';
3680 if ((itemAlignment == PTR_ALIGN_MIDDLE || itemAlignment == PTR_ALIGN_NAME)
3681 && !isAfterScopeResolution && prevCh != '(')
3682 {
3683 appendSpacePad();
3684 // in this case appendSpacePad may or may not update the split point
3685 if (maxCodeLength != string::npos && formattedLine.length() > 0)
3686 updateFormattedLineSplitPointsPointerOrReference(formattedLine.length() - 1);
3687 appendSequence(sequenceToInsert, false);
3688 }
3689 else
3690 appendSequence(sequenceToInsert, false);
3691 // remove trailing whitespace if paren or comma follow
3692 char nextChar = peekNextChar();
3693 if (nextChar == ')' || nextChar == ',')
3694 {
3695 while (isWhiteSpace(currentLine[charNum + 1]))
3696 {
3697 goForward(1);
3698 spacePadNum--;
3699 }
3700 }
3701}
3702

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected