mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-08-21 06:50:35 +02:00
64 lines
1.7 KiB
C++
64 lines
1.7 KiB
C++
//
|
|
// JSBaker.h
|
|
// libraries/baking/src
|
|
//
|
|
// Created by Utkarsh Gautam on 9/18/17.
|
|
// Copyright 2017 High Fidelity, Inc.
|
|
//
|
|
// Distributed under the Apache License, Version 2.0.
|
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
//
|
|
|
|
#ifndef hifi_JSBaker_h
|
|
#define hifi_JSBaker_h
|
|
|
|
#include <QUrl>
|
|
|
|
#include "Baker.h"
|
|
#include "JSBakingLoggingCategory.h"
|
|
|
|
static const QString BAKED_JS_EXTENSION = ".baked.js";
|
|
|
|
class JSBaker : public Baker {
|
|
Q_OBJECT
|
|
public:
|
|
JSBaker(const QUrl& jsURL, const QString& bakedOutputDir);
|
|
static bool bakeJS(const QByteArray& inputFile, QByteArray& outputFile);
|
|
|
|
QString getJSPath() const { return _jsURL.toDisplayString(); }
|
|
QString getBakedJSFilePath() const { return _bakedJSFilePath; }
|
|
|
|
public slots:
|
|
virtual void bake() override;
|
|
|
|
signals:
|
|
void originalScriptLoaded();
|
|
|
|
private slots:
|
|
void processScript();
|
|
|
|
private:
|
|
void loadScript();
|
|
void handleScriptNetworkReply();
|
|
|
|
QUrl _jsURL;
|
|
QByteArray _originalScript;
|
|
QString _bakedOutputDir;
|
|
QString _bakedJSFilePath;
|
|
|
|
static void handleSingleLineComments(QTextStream& in);
|
|
static bool handleMultiLineComments(QTextStream& in);
|
|
|
|
static bool canOmitSpace(QChar previousCharacter, QChar nextCharacter);
|
|
static bool canOmitNewLine(QChar previousCharacter, QChar nextCharacter);
|
|
|
|
static bool isAlphanum(QChar c);
|
|
static bool isNonAscii(QChar c);
|
|
static bool isSpecialCharacter(QChar c);
|
|
static bool isSpecialCharacterPrevious(QChar c);
|
|
static bool isSpecialCharacterNext(QChar c);
|
|
static bool isSpaceOrTab(QChar c);
|
|
static bool isQuote(QChar c);
|
|
};
|
|
|
|
#endif // !hifi_JSBaker_h
|