From f3983b3edc51ac788c63a3fda489019c012c1271 Mon Sep 17 00:00:00 2001 From: utkarshgautamnyu Date: Thu, 12 Oct 2017 11:34:28 -0700 Subject: [PATCH] Update JSBaker.cpp --- libraries/baking/src/JSBaker.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/libraries/baking/src/JSBaker.cpp b/libraries/baking/src/JSBaker.cpp index cd58a715fb..75811bea49 100644 --- a/libraries/baking/src/JSBaker.cpp +++ b/libraries/baking/src/JSBaker.cpp @@ -38,7 +38,7 @@ void JSBaker::bake() { QByteArray outputJS; // Call baking on inputJS and store result in outputJS - bool success = bakeJS(&inputJS, &outputJS); + bool success = bakeJS(inputJS, outputJS); if (!success) { qCDebug(js_baking) << "Bake Failed"; handleError("Unterminated multi-line comment"); @@ -69,9 +69,9 @@ void JSBaker::bake() { emit finished(); } -bool JSBaker::bakeJS(const QByteArray* inputFile, QByteArray* outputFile) { +bool JSBaker::bakeJS(const QByteArray& inputFile, QByteArray& outputFile) { // Read from inputFile and write to outputFile per character - QTextStream in(*inputFile, QIODevice::ReadOnly); + QTextStream in(inputFile, QIODevice::ReadOnly); QTextStream out(outputFile, QIODevice::WriteOnly); // Algorithm requires the knowledge of previous and next character for each character read @@ -90,7 +90,7 @@ bool JSBaker::bakeJS(const QByteArray* inputFile, QByteArray* outputFile) { } else if (currentCharacter == '/') { // Check if single line comment i.e. // if (nextCharacter == '/') { - handleSingleLineComments(&in); + handleSingleLineComments(in); //Start fresh after handling comments previousCharacter = '\n'; @@ -98,7 +98,7 @@ bool JSBaker::bakeJS(const QByteArray* inputFile, QByteArray* outputFile) { continue; } else if (nextCharacter == '*') { // Check if multi line comment i.e. /* - bool success = handleMultiLineComments(&in); + bool success = handleMultiLineComments(in); if (!success) { // Errors present return false return false; @@ -175,22 +175,22 @@ bool JSBaker::bakeJS(const QByteArray* inputFile, QByteArray* outputFile) { return true; } -void JSBaker::handleSingleLineComments(QTextStream* in) { +void JSBaker::handleSingleLineComments(QTextStream& in) { QChar character; - while (!in->atEnd()) { - *in >> character; + while (!in.atEnd()) { + in >> character; if (character == '\n') { break; } } } -bool JSBaker::handleMultiLineComments(QTextStream* in) { +bool JSBaker::handleMultiLineComments(QTextStream& in) { QChar character; - while (!in->atEnd()) { - *in >> character; + while (!in.atEnd()) { + in >> character; if (character == '*') { - if (in->read(1) == '/') { + if (in.read(1) == '/') { return true; } }