Lines Matching defs:pExp

525 static RTEXITCODE   vbcppMacroExpandIt(PVBCPP pThis, PVBCPPMACROEXP pExp, size_t offMacro, PVBCPPMACRO pMacro, size_t offParameters);
526 static RTEXITCODE vbcppMacroExpandReScan(PVBCPP pThis, PVBCPPMACROEXP pExp, VBCPPMACRORESCANMODE enmMode, size_t *pcReplacements);
527 static void vbcppMacroExpandCleanup(PVBCPPMACROEXP pExp);
1691 static RTEXITCODE vbcppMacroExpandReplace(PVBCPP pThis, PVBCPPMACROEXP pExp, size_t off, size_t cchToReplace,
1699 && !RT_C_IS_SPACE(pExp->StrBuf.pszBuf[off - 1]);
1700 bool const fTrailingSpace = off + cchToReplace < pExp->StrBuf.cchBuf
1701 && !RT_C_IS_SPACE(pExp->StrBuf.pszBuf[off + cchToReplace]);
1712 size_t cbMinBuf = offMore + pExp->StrBuf.cchBuf + 1;
1713 RTEXITCODE rcExit = vbcppStrBufGrow(&pExp->StrBuf, cbMinBuf);
1718 memmove(&pExp->StrBuf.pszBuf[off + cchToReplace + offMore],
1719 &pExp->StrBuf.pszBuf[off + cchToReplace],
1720 pExp->StrBuf.cchBuf - off - cchToReplace + 1);
1721 pExp->StrBuf.cchBuf += offMore;
1729 memmove(&pExp->StrBuf.pszBuf[off + cchToReplace - offLess],
1730 &pExp->StrBuf.pszBuf[off + cchToReplace],
1731 pExp->StrBuf.cchBuf - off - cchToReplace + 1);
1732 pExp->StrBuf.cchBuf -= offLess;
1738 char *pszCur = &pExp->StrBuf.pszBuf[off];
1745 Assert(strlen(pExp->StrBuf.pszBuf) == pExp->StrBuf.cchBuf);
1751 static unsigned vbcppMacroExpandPeekCh(PVBCPPMACROEXP pExp, size_t *poff)
1754 if (off >= pExp->StrBuf.cchBuf)
1755 return pExp->pStrmInput ? ScmStreamPeekCh(pExp->pStrmInput) : ~(unsigned)0;
1756 return pExp->StrBuf.pszBuf[off];
1760 static unsigned vbcppMacroExpandGetCh(PVBCPPMACROEXP pExp, size_t *poff)
1763 if (off >= pExp->StrBuf.cchBuf)
1764 return pExp->pStrmInput ? ScmStreamGetCh(pExp->pStrmInput) : ~(unsigned)0;
1766 return pExp->StrBuf.pszBuf[off];
1770 static RTEXITCODE vbcppMacroExpandSkipEolEx(PVBCPP pThis, PVBCPPMACROEXP pExp, size_t *poff, unsigned chFirst)
1774 unsigned ch2 = vbcppMacroExpandPeekCh(pExp, poff);
1777 ch2 = ScmStreamGetCh(pExp->pStrmInput);
1785 static RTEXITCODE vbcppMacroExpandSkipEol(PVBCPP pThis, PVBCPPMACROEXP pExp, size_t *poff)
1787 unsigned ch = vbcppMacroExpandGetCh(pExp, poff);
1789 return vbcppMacroExpandSkipEolEx(pThis, pExp, poff, ch);
1793 static RTEXITCODE vbcppMacroExpandSkipCommentLine(PVBCPP pThis, PVBCPPMACROEXP pExp, size_t *poff)
1795 unsigned ch = vbcppMacroExpandGetCh(pExp, poff);
1799 while ((ch = vbcppMacroExpandGetCh(pExp, poff)) != ~(unsigned)0)
1803 RTEXITCODE rcExit = vbcppMacroExpandSkipEolEx(pThis, pExp, poff, ch);
1816 static RTEXITCODE vbcppMacroExpandSkipComment(PVBCPP pThis, PVBCPPMACROEXP pExp, size_t *poff)
1818 unsigned ch = vbcppMacroExpandGetCh(pExp, poff);
1823 while ((ch = vbcppMacroExpandGetCh(pExp, poff)) != ~(unsigned)0)
1830 RTEXITCODE rcExit = vbcppMacroExpandSkipEolEx(pThis, pExp, poff, ch);
1847 static RTEXITCODE vbcppMacroExpandGrowArgArray(PVBCPP pThis, PVBCPPMACROEXP pExp, uint32_t cMinArgs)
1849 if (cMinArgs > pExp->cArgsAlloced)
1851 void *pv = RTMemRealloc(pExp->papszArgs, cMinArgs * sizeof(char *));
1854 pExp->papszArgs = (char **)pv;
1855 pExp->cArgsAlloced = cMinArgs;
1861 static RTEXITCODE vbcppMacroExpandAddEmptyParameter(PVBCPP pThis, PVBCPPMACROEXP pExp)
1863 RTEXITCODE rcExit = vbcppMacroExpandGrowArgArray(pThis, pExp, pExp->cArgs + 1);
1868 pExp->papszArgs[pExp->cArgs++] = pszArg;
1876 static RTEXITCODE vbcppMacroExpandGatherParameters(PVBCPP pThis, PVBCPPMACROEXP pExp, size_t *poff, uint32_t cArgsHint)
1883 while (pExp->cArgs > 0)
1885 RTMemFree(pExp->papszArgs[--pExp->cArgs]);
1886 pExp->papszArgs[pExp->cArgs] = NULL;
1892 unsigned ch = vbcppMacroExpandGetCh(pExp, poff);
1905 while ((ch = vbcppMacroExpandGetCh(pExp, poff)) != ~(unsigned)0)
1919 else if (pExp->cArgs || cArgsHint > 0)
1920 rcExit = vbcppMacroExpandAddEmptyParameter(pThis, pExp);
1934 rcExit = vbcppMacroExpandAddEmptyParameter(pThis, pExp);
1947 unsigned ch2 = vbcppMacroExpandPeekCh(pExp, poff);
1952 rcExit = vbcppMacroExpandSkipCommentLine(pThis, pExp, poff);
1954 rcExit = vbcppMacroExpandSkipComment(pThis, pExp, poff);
1977 unsigned ch2 = vbcppMacroExpandPeekCh(pExp, poff);
1980 rcExit = vbcppMacroExpandSkipEol(pThis, pExp, poff);
1996 rcExit = vbcppMacroExpandGrowArgArray(pThis, pExp, RT_MAX(pExp->cArgs + 1, cArgsHint));
1999 pExp->papszArgs[pExp->cArgs++] = pszArg;
2010 pExp->papszArgs[pExp->cArgs - 1] = pszArg;
2035 * @param pExp The expansion context.
2040 static RTEXITCODE vbcppMacroExpandValueWithArguments(PVBCPP pThis, PVBCPPMACROEXP pExp, PVBCPPMACRO pMacro,
2140 Assert(iArg < pExp->cArgs);
2141 rcExit = vbcppStrBufAppend(pStrBuf, pExp->papszArgs[iArg]);
2142 if (*pExp->papszArgs[iArg] != '\0' && rcExit == RTEXITCODE_SUCCESS)
2148 if (iArg < pExp->cArgs)
2152 rcExit = vbcppStrBufAppend(pStrBuf, pExp->papszArgs[iArg]);
2156 if (iArg >= pExp->cArgs)
2190 * @param pExp The expansion context.
2200 static RTEXITCODE vbcppMacroExpandIt(PVBCPP pThis, PVBCPPMACROEXP pExp, size_t offMacro, PVBCPPMACRO pMacro,
2204 Assert(offMacro + pMacro->Core.cchString <= pExp->StrBuf.cchBuf);
2212 rcExit = vbcppMacroExpandGatherParameters(pThis, pExp, &offParameters, pMacro->cArgs + pMacro->fVarArg);
2215 if (pExp->cArgs > pMacro->cArgs && !pMacro->fVarArg)
2217 pMacro->Core.pszString, pExp->cArgs, pMacro->cArgs);
2218 else if (pExp->cArgs < pMacro->cArgs)
2220 pMacro->Core.pszString, pExp->cArgs, pMacro->cArgs);
2226 rcExit = vbcppMacroExpandValueWithArguments(pThis, pExp, pMacro, &ValueBuf);
2228 rcExit = vbcppMacroExpandReplace(pThis, pExp, offMacro, offParameters - offMacro,
2237 rcExit = vbcppMacroExpandReplace(pThis, pExp, offMacro, pMacro->Core.cchString, pMacro->szValue, pMacro->cchValue);
2245 pMacro->pUpExpanding = pExp->pMacroStack;
2246 pExp->pMacroStack = pMacro;
2262 * @param pExp The expansion context.
2268 static bool vbcppMacroExpandLookForLeftParenthesis(PVBCPP pThis, PVBCPPMACROEXP pExp, size_t *poff)
2274 while (off < pExp->StrBuf.cchBuf)
2276 char ch = pExp->StrBuf.pszBuf[off];
2292 PSCMSTREAM pStrmInput = pExp->pStrmInput;
2298 *poff = pExp->StrBuf.cchBuf;
2313 * @param pExp The expansion context.
2319 static RTEXITCODE vbcppMacroExpandDefinedOperator(PVBCPP pThis, PVBCPPMACROEXP pExp, size_t offStart, size_t *poff)
2321 Assert(!pExp->pStrmInput); /* offset usage below. */
2327 while ((ch = vbcppMacroExpandGetCh(pExp, poff)) != ~(unsigned)0)
2332 while ((ch = vbcppMacroExpandGetCh(pExp, poff)) != ~(unsigned)0)
2343 while ((ch = vbcppMacroExpandGetCh(pExp, poff)) != ~(unsigned)0)
2354 ch = vbcppMacroExpandGetCh(pExp, poff);
2362 const char *pszResult = vbcppMacroExists(pThis, &pExp->StrBuf.pszBuf[offDefine], cchDefine)
2364 RTEXITCODE rcExit = vbcppMacroExpandReplace(pThis, pExp, offStart, *poff - offStart, pszResult, 1);
2375 * @param pExp The expansion context.
2380 static RTEXITCODE vbcppMacroExpandReScan(PVBCPP pThis, PVBCPPMACROEXP pExp, VBCPPMACRORESCANMODE enmMode, size_t *pcReplacements)
2386 while ( off < pExp->StrBuf.cchBuf
2387 && (ch = vbcppMacroExpandGetCh(pExp, &off)) != ~(unsigned)0)
2395 while ( off < pExp->StrBuf.cchBuf
2396 && (ch = vbcppMacroExpandGetCh(pExp, &off)) != ~(unsigned)0)
2400 ch = vbcppMacroExpandGetCh(pExp, &off);
2415 && off + 1 < pExp->StrBuf.cchBuf
2416 && RT_C_IS_DIGIT(vbcppMacroExpandPeekCh(pExp, &off))
2420 while ( off < pExp->StrBuf.cchBuf
2421 && (ch = vbcppMacroExpandPeekCh(pExp, &off)) != ~(unsigned)0
2423 vbcppMacroExpandGetCh(pExp, &off);
2431 while ( off < pExp->StrBuf.cchBuf
2432 && (ch = vbcppMacroExpandPeekCh(pExp, &off)) != ~(unsigned)0
2434 vbcppMacroExpandGetCh(pExp, &off);
2437 PVBCPPMACRO pMacro = vbcppMacroLookup(pThis, &pExp->StrBuf.pszBuf[offDefine], cchDefine);
2440 || vbcppMacroExpandLookForLeftParenthesis(pThis, pExp, &off)) )
2442 rcExit = vbcppMacroExpandIt(pThis, pExp, offDefine, pMacro, off);
2450 && !strncmp(&pExp->StrBuf.pszBuf[offDefine], "defined", cchDefine))
2451 rcExit = vbcppMacroExpandDefinedOperator(pThis, pExp, offDefine, &off);
2473 * @param pExp The expansion context.
2475 static void vbcppMacroExpandCleanup(PVBCPPMACROEXP pExp)
2478 while (pExp->pMacroStack)
2480 PVBCPPMACRO pMacro = pExp->pMacroStack;
2481 pExp->pMacroStack = pMacro->pUpExpanding;
2488 while (pExp->cArgs > 0)
2490 RTMemFree(pExp->papszArgs[--pExp->cArgs]);
2491 pExp->papszArgs[pExp->cArgs] = NULL;
2494 RTMemFree(pExp->papszArgs);
2495 pExp->papszArgs = NULL;
2497 vbcppStrBufDelete(&pExp->StrBuf);