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

Function AStyleMain

astyle/src/astyle_main.cpp:3587–3663  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3585 * No /EXPORT is required for x64
3586 */
3587extern "C" EXPORT char* STDCALL AStyleMain(const char* pSourceIn, // the source to be formatted
3588 const char* pOptions, // AStyle options
3589 fpError fpErrorHandler, // error handler function
3590 fpAlloc fpMemoryAlloc) // memory allocation function
3591{
3592 if (fpErrorHandler == NULL) // cannot display a message if no error handler
3593 return NULL;
3594
3595 if (pSourceIn == NULL)
3596 {
3597 fpErrorHandler(101, "No pointer to source input.");
3598 return NULL;
3599 }
3600 if (pOptions == NULL)
3601 {
3602 fpErrorHandler(102, "No pointer to AStyle options.");
3603 return NULL;
3604 }
3605 if (fpMemoryAlloc == NULL)
3606 {
3607 fpErrorHandler(103, "No pointer to memory allocation function.");
3608 return NULL;
3609 }
3610
3611 ASFormatter formatter;
3612 ASOptions options(formatter);
3613
3614 vector<string> optionsVector;
3615 istringstream opt(pOptions);
3616
3617 options.importOptions(opt, optionsVector);
3618
3619 bool ok = options.parseOptions(optionsVector, "Invalid Artistic Style options:");
3620 if (!ok)
3621 fpErrorHandler(130, options.getOptionErrors().c_str());
3622
3623 istringstream in(pSourceIn);
3624 ASStreamIterator<istringstream> streamIterator(&in);
3625 ostringstream out;
3626 formatter.init(&streamIterator);
3627
3628 while (formatter.hasMoreLines())
3629 {
3630 out << formatter.nextLine();
3631 if (formatter.hasMoreLines())
3632 out << streamIterator.getOutputEOL();
3633 else
3634 {
3635 // this can happen if the file if missing a closing bracket and break-blocks is requested
3636 if (formatter.getIsLineReady())
3637 {
3638 out << streamIterator.getOutputEOL();
3639 out << formatter.nextLine();
3640 }
3641 }
3642 }
3643
3644 unsigned long textSizeOut = out.str().length();

Callers 2

formatUtf16Method · 0.85

Calls 9

importOptionsMethod · 0.80
parseOptionsMethod · 0.80
getOptionErrorsMethod · 0.80
getOutputEOLMethod · 0.80
getIsLineReadyMethod · 0.80
getChecksumDiffMethod · 0.80
initMethod · 0.45
hasMoreLinesMethod · 0.45
nextLineMethod · 0.45

Tested by

no test coverage detected