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

Method processPreprocessor

astyle/src/ASBeautifier.cpp:1789–1876  ·  view source on GitHub ↗

* Process preprocessor statements and update the beautifier stacks. */

Source from the content-addressed store, hash-verified

1787 * Process preprocessor statements and update the beautifier stacks.
1788 */
1789void ASBeautifier::processPreprocessor(const string &preproc, const string &line)
1790{
1791 // When finding a multi-lined #define statement, the original beautifier
1792 // 1. sets its isInDefineDefinition flag
1793 // 2. clones a new beautifier that will be used for the actual indentation
1794 // of the #define. This clone is put into the activeBeautifierStack in order
1795 // to be called for the actual indentation.
1796 // The original beautifier will have isInDefineDefinition = true, isInDefine = false
1797 // The cloned beautifier will have isInDefineDefinition = true, isInDefine = true
1798 if (shouldIndentPreprocDefine && preproc == "define" && line[line.length() - 1] == '\\')
1799 {
1800 if (!isInDefineDefinition)
1801 {
1802 ASBeautifier* defineBeautifier;
1803
1804 // this is the original beautifier
1805 isInDefineDefinition = true;
1806
1807 // push a new beautifier into the active stack
1808 // this beautifier will be used for the indentation of this define
1809 defineBeautifier = new ASBeautifier(*this);
1810 activeBeautifierStack->push_back(defineBeautifier);
1811 }
1812 else
1813 {
1814 // the is the cloned beautifier that is in charge of indenting the #define.
1815 isInDefine = true;
1816 }
1817 }
1818 else if (preproc.length() >= 2 && preproc.substr(0, 2) == "if")
1819 {
1820 if (isPreprocessorConditionalCplusplus(line) && !g_preprocessorCppExternCBracket)
1821 g_preprocessorCppExternCBracket = 1;
1822 // push a new beautifier into the stack
1823 waitingBeautifierStackLengthStack->push_back(waitingBeautifierStack->size());
1824 activeBeautifierStackLengthStack->push_back(activeBeautifierStack->size());
1825 if (activeBeautifierStackLengthStack->back() == 0)
1826 waitingBeautifierStack->push_back(new ASBeautifier(*this));
1827 else
1828 waitingBeautifierStack->push_back(new ASBeautifier(*activeBeautifierStack->back()));
1829 }
1830 else if (preproc == "else")
1831 {
1832 if (waitingBeautifierStack && !waitingBeautifierStack->empty())
1833 {
1834 // MOVE current waiting beautifier to active stack.
1835 activeBeautifierStack->push_back(waitingBeautifierStack->back());
1836 waitingBeautifierStack->pop_back();
1837 }
1838 }
1839 else if (preproc == "elif")
1840 {
1841 if (waitingBeautifierStack && !waitingBeautifierStack->empty())
1842 {
1843 // append a COPY current waiting beautifier to active stack, WITHOUT deleting the original.
1844 activeBeautifierStack->push_back(new ASBeautifier(*(waitingBeautifierStack->back())));
1845 }
1846 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected