2011-04-09 21:34:04 +04:00
|
|
|
/*
|
|
|
|
This file is part of the PhantomJS project from Ofi Labs.
|
|
|
|
|
|
|
|
Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
|
2011-08-31 19:29:40 +04:00
|
|
|
Copyright (C) 2011 Ivan De Marino <ivan.de.marino@gmail.com>
|
2011-04-09 21:34:04 +04:00
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
* Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
* Neither the name of the <organization> nor the
|
|
|
|
names of its contributors may be used to endorse or promote products
|
|
|
|
derived from this software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
|
|
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2011-04-09 22:49:22 +04:00
|
|
|
#ifndef PHANTOM_H
|
|
|
|
#define PHANTOM_H
|
|
|
|
|
2012-03-07 06:44:19 +04:00
|
|
|
#include <QPointer>
|
2011-04-08 17:30:50 +04:00
|
|
|
|
2011-06-14 14:28:51 +04:00
|
|
|
#include "filesystem.h"
|
2011-08-16 22:53:56 +04:00
|
|
|
#include "encoding.h"
|
2011-08-28 16:05:34 +04:00
|
|
|
#include "config.h"
|
2012-03-15 10:17:03 +04:00
|
|
|
#include "system.h"
|
2012-12-28 17:43:25 +04:00
|
|
|
#include "childprocess.h"
|
2013-06-18 23:09:36 +04:00
|
|
|
#include "cookiejar.h"
|
A REPL for PhantomJS
This covers [Issue 252](http://code.google.com/p/phantomjs/issues/detail?id=252)
The commit is composed of 12 squashed commits:
commit efdc6ba4f143c30a690fd97d92d80fa412e79999
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Mon Feb 27 00:19:36 2012 +0000
Pretty-pringing and Completion Caching done!
* This completes pretty-printing for the result of evaluated
* expressions in the REPL.
* Also, now we cache the "possible completions", to speed things up
* a bit (nothing fancy though).
* Minor tweaks to the internal doc and the way we "mock"
* pretty-printing for QObjects/REPLCompletanle
* All tests passing :)
commit 1f9ef690e112a535b431fca409b77bb9c09d1c70
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Sun Feb 26 22:35:00 2012 +0000
Moving most of REPL shim JavaScritp code in a separate file. Way
easier to work on.
commit 02d460a16fee14e7096ae7d899c03902c5b8a9c6
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Sat Feb 25 20:25:18 2012 +0000
Initialisation of the Completions is now done in a pure virtual.
This means that every REPLCompletable object will ACTUALLY register
completion strings, ONLY if we are running a REPL
and that object is ACTUALLY created.
Otherwise, why bother?
Adding completions for all exposed REPLCompletable objects
Also, fixed an issue with _getCompletions()
commit 412c3778fb04aa1c7379f8e760afce702b0428dd
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Tue Feb 21 00:49:17 2012 +0000
Few more tweaks to the REPL:
- Now 'phantom' is the first QObject with proper completion
- No repetition in QObject completions
- LVAL of any user expression is now correctly prettified and
printed
Major things left to do:
- Cache completions (using QCache?)
- Add completions for the other QObject
- When the LVAL of a user expression is a QObject, print what's
expected, not the QObject "real" structure
commit 46f04713c8165d898055e15478bb31403f8c93f1
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Tue Feb 7 10:13:23 2012 -0800
Pretty-print expressions result
Still not done though: there are issues with the NON-Native JS
objects.
commit 98b2fe67651dc750b62c6fa9cf1d80317fd9ae06
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Fri Feb 3 00:22:52 2012 -0800
Introducing REPLCompletable.
This class should be inherited by any JavaScript-exposed QObject, to
ensure correct Auto-Completion.
Correct auto-completion for QObjects.
- Now even QObjects can correctly provide auto-completion, and avoid
showing "not for users" methods
- The strings used for the auto-completion are stored in a single
Index: minimum memory footprint
- Still, there is optimization that should be done (when "searching"
for the right completion by prefix)
- Completion for the objects not set up yet, but now it's just a
trivial sequence of "addCompletion('bla')" in their constructors
commit 9bd48618154b1530a37b41f4060440184e23253d
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Thu Feb 2 00:20:25 2012 -0800
Changing the way we import Linenoise.
Will just import a specific commit, and update manually when needed.
commit cfc9bae9fbdab13b01019b34b7cbd565e3153780
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Sun Jan 29 23:22:26 2012 -0800
Made the REPL into a Singleton. With Auto-completion!.
Reasons:
1) Needed a pointer to function (i.e. a static method) to be used
with Linenoise to provide auto-completions
2) It makes more sense, as it's not like we are going to have 2 REPL
running at the same time, are we?
There are problems to address:
- the enumeration in JS seems to return only the native interface of
our objects
- the function completions contain argument types of those functions
- "private" methods are exposed
commit c78bd32e17f8e0e4cc4a0066858de8cc81d33b97
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Sun Jan 29 22:10:20 2012 -0800
Migrating from the original, now [unmantained
Linenoise](https://github.com/antirez/linenoise) to the fairly active
[tadmarshall fork](https://github.com/tadmarshall/linenoise).
Also now the project is imported as a Git Submodule.
Having migrated to the latest Linenoise (see prev. commit), now this
_SHOULD_ work on Windows too.
But, of course, this needs testing. :)
commit 43713c5723d7c5ed446ba41ae8d6f8c9feba7f9b
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Tue Jan 24 23:17:06 2012 -0800
Now that the basics work, I'm adding support for REPL history.
This is something almost everyone today is accustomed to.
Also, now REPL history works!
And I found some useful resources to solve pending TODOs.
commit 31e5f88b044a5b4a823c67527ef8c245d2ac7863
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Sun Jan 22 20:56:36 2012 -0800
Adding Linenoise Project (https://github.com/antirez/linenoise).
For now is included as a drop-in set of files.
Later on, if the Linenoise project has frequent
updates, we might prefer to do it as a
git-submodule.
commit 4be9c15c65db4767e482fba0be13f8aab286d5f3
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Thu Jan 5 15:31:13 2012 +0000
First simple REPL implementation.
- Not complete
- Still doesn't handle arrow keys (needed for history)
2012-01-05 19:31:13 +04:00
|
|
|
|
|
|
|
class WebPage;
|
2012-07-27 20:13:43 +04:00
|
|
|
class CustomPage;
|
A REPL for PhantomJS
This covers [Issue 252](http://code.google.com/p/phantomjs/issues/detail?id=252)
The commit is composed of 12 squashed commits:
commit efdc6ba4f143c30a690fd97d92d80fa412e79999
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Mon Feb 27 00:19:36 2012 +0000
Pretty-pringing and Completion Caching done!
* This completes pretty-printing for the result of evaluated
* expressions in the REPL.
* Also, now we cache the "possible completions", to speed things up
* a bit (nothing fancy though).
* Minor tweaks to the internal doc and the way we "mock"
* pretty-printing for QObjects/REPLCompletanle
* All tests passing :)
commit 1f9ef690e112a535b431fca409b77bb9c09d1c70
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Sun Feb 26 22:35:00 2012 +0000
Moving most of REPL shim JavaScritp code in a separate file. Way
easier to work on.
commit 02d460a16fee14e7096ae7d899c03902c5b8a9c6
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Sat Feb 25 20:25:18 2012 +0000
Initialisation of the Completions is now done in a pure virtual.
This means that every REPLCompletable object will ACTUALLY register
completion strings, ONLY if we are running a REPL
and that object is ACTUALLY created.
Otherwise, why bother?
Adding completions for all exposed REPLCompletable objects
Also, fixed an issue with _getCompletions()
commit 412c3778fb04aa1c7379f8e760afce702b0428dd
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Tue Feb 21 00:49:17 2012 +0000
Few more tweaks to the REPL:
- Now 'phantom' is the first QObject with proper completion
- No repetition in QObject completions
- LVAL of any user expression is now correctly prettified and
printed
Major things left to do:
- Cache completions (using QCache?)
- Add completions for the other QObject
- When the LVAL of a user expression is a QObject, print what's
expected, not the QObject "real" structure
commit 46f04713c8165d898055e15478bb31403f8c93f1
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Tue Feb 7 10:13:23 2012 -0800
Pretty-print expressions result
Still not done though: there are issues with the NON-Native JS
objects.
commit 98b2fe67651dc750b62c6fa9cf1d80317fd9ae06
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Fri Feb 3 00:22:52 2012 -0800
Introducing REPLCompletable.
This class should be inherited by any JavaScript-exposed QObject, to
ensure correct Auto-Completion.
Correct auto-completion for QObjects.
- Now even QObjects can correctly provide auto-completion, and avoid
showing "not for users" methods
- The strings used for the auto-completion are stored in a single
Index: minimum memory footprint
- Still, there is optimization that should be done (when "searching"
for the right completion by prefix)
- Completion for the objects not set up yet, but now it's just a
trivial sequence of "addCompletion('bla')" in their constructors
commit 9bd48618154b1530a37b41f4060440184e23253d
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Thu Feb 2 00:20:25 2012 -0800
Changing the way we import Linenoise.
Will just import a specific commit, and update manually when needed.
commit cfc9bae9fbdab13b01019b34b7cbd565e3153780
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Sun Jan 29 23:22:26 2012 -0800
Made the REPL into a Singleton. With Auto-completion!.
Reasons:
1) Needed a pointer to function (i.e. a static method) to be used
with Linenoise to provide auto-completions
2) It makes more sense, as it's not like we are going to have 2 REPL
running at the same time, are we?
There are problems to address:
- the enumeration in JS seems to return only the native interface of
our objects
- the function completions contain argument types of those functions
- "private" methods are exposed
commit c78bd32e17f8e0e4cc4a0066858de8cc81d33b97
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Sun Jan 29 22:10:20 2012 -0800
Migrating from the original, now [unmantained
Linenoise](https://github.com/antirez/linenoise) to the fairly active
[tadmarshall fork](https://github.com/tadmarshall/linenoise).
Also now the project is imported as a Git Submodule.
Having migrated to the latest Linenoise (see prev. commit), now this
_SHOULD_ work on Windows too.
But, of course, this needs testing. :)
commit 43713c5723d7c5ed446ba41ae8d6f8c9feba7f9b
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Tue Jan 24 23:17:06 2012 -0800
Now that the basics work, I'm adding support for REPL history.
This is something almost everyone today is accustomed to.
Also, now REPL history works!
And I found some useful resources to solve pending TODOs.
commit 31e5f88b044a5b4a823c67527ef8c245d2ac7863
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Sun Jan 22 20:56:36 2012 -0800
Adding Linenoise Project (https://github.com/antirez/linenoise).
For now is included as a drop-in set of files.
Later on, if the Linenoise project has frequent
updates, we might prefer to do it as a
git-submodule.
commit 4be9c15c65db4767e482fba0be13f8aab286d5f3
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Thu Jan 5 15:31:13 2012 +0000
First simple REPL implementation.
- Not complete
- Still doesn't handle arrow keys (needed for history)
2012-01-05 19:31:13 +04:00
|
|
|
class WebServer;
|
2011-04-08 17:30:50 +04:00
|
|
|
|
2012-12-29 20:23:10 +04:00
|
|
|
class Phantom : public QObject
|
2011-04-08 17:30:50 +04:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2011-05-28 09:36:34 +04:00
|
|
|
Q_PROPERTY(QVariantMap defaultPageSettings READ defaultPageSettings)
|
2011-06-18 07:17:58 +04:00
|
|
|
Q_PROPERTY(QString libraryPath READ libraryPath WRITE setLibraryPath)
|
2011-08-16 23:17:42 +04:00
|
|
|
Q_PROPERTY(QString outputEncoding READ outputEncoding WRITE setOutputEncoding)
|
2011-04-08 17:30:50 +04:00
|
|
|
Q_PROPERTY(QVariantMap version READ version)
|
2012-03-17 21:27:13 +04:00
|
|
|
Q_PROPERTY(QObject *page READ page)
|
2012-09-06 10:33:18 +04:00
|
|
|
Q_PROPERTY(bool cookiesEnabled READ areCookiesEnabled WRITE setCookiesEnabled)
|
2012-09-09 15:24:15 +04:00
|
|
|
Q_PROPERTY(QVariantList cookies READ cookies WRITE setCookies)
|
2012-11-19 03:58:21 +04:00
|
|
|
Q_PROPERTY(bool webdriverMode READ webdriverMode)
|
2011-04-08 17:30:50 +04:00
|
|
|
|
2012-07-05 04:21:15 +04:00
|
|
|
private:
|
|
|
|
// Private constructor: the Phantom class is a singleton
|
2011-04-08 17:30:50 +04:00
|
|
|
Phantom(QObject *parent = 0);
|
2012-07-05 04:21:15 +04:00
|
|
|
void init();
|
|
|
|
|
|
|
|
public:
|
|
|
|
static Phantom *instance();
|
2011-10-25 23:16:25 +04:00
|
|
|
virtual ~Phantom();
|
2011-04-08 17:30:50 +04:00
|
|
|
|
2011-05-28 09:36:34 +04:00
|
|
|
QVariantMap defaultPageSettings() const;
|
|
|
|
|
2011-08-16 23:17:42 +04:00
|
|
|
QString outputEncoding() const;
|
|
|
|
void setOutputEncoding(const QString &encoding);
|
2011-08-16 22:18:52 +04:00
|
|
|
|
2011-04-08 17:30:50 +04:00
|
|
|
bool execute();
|
|
|
|
int returnValue() const;
|
|
|
|
|
2011-06-18 07:17:58 +04:00
|
|
|
QString libraryPath() const;
|
|
|
|
void setLibraryPath(const QString &libraryPath);
|
2011-06-13 01:38:34 +04:00
|
|
|
|
2011-04-08 17:30:50 +04:00
|
|
|
QVariantMap version() const;
|
|
|
|
|
2012-07-05 04:21:15 +04:00
|
|
|
QObject *page() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pointer to the Config loaded at startup.
|
|
|
|
* The configuration is determined by the commandline parameters.
|
|
|
|
*
|
|
|
|
* @brief config
|
|
|
|
* @return Pointer to the current Config(uration)
|
|
|
|
*/
|
|
|
|
Config *config();
|
2012-03-17 21:27:13 +04:00
|
|
|
|
2012-06-05 15:43:23 +04:00
|
|
|
bool printDebugMessages() const;
|
|
|
|
|
2012-09-06 10:33:18 +04:00
|
|
|
bool areCookiesEnabled() const;
|
|
|
|
void setCookiesEnabled(const bool value);
|
|
|
|
|
2012-11-19 03:58:21 +04:00
|
|
|
bool webdriverMode() const;
|
|
|
|
|
2012-12-28 17:43:25 +04:00
|
|
|
/**
|
|
|
|
* Create `child_process` module instance
|
|
|
|
*/
|
|
|
|
Q_INVOKABLE QObject *_createChildProcess();
|
|
|
|
|
2011-04-08 17:30:50 +04:00
|
|
|
public slots:
|
2013-06-18 23:09:36 +04:00
|
|
|
QObject *createCookieJar(const QString &filePath);
|
2011-05-25 21:46:51 +04:00
|
|
|
QObject *createWebPage();
|
2011-11-15 16:44:47 +04:00
|
|
|
QObject *createWebServer();
|
2011-09-08 20:55:50 +04:00
|
|
|
QObject *createFilesystem();
|
2012-03-15 10:17:03 +04:00
|
|
|
QObject *createSystem();
|
2012-04-11 17:23:25 +04:00
|
|
|
QObject *createCallback();
|
2012-06-24 01:40:02 +04:00
|
|
|
void loadModule(const QString &moduleSource, const QString &filename);
|
2011-06-10 19:50:49 +04:00
|
|
|
bool injectJs(const QString &jsFilePath);
|
2011-10-25 23:16:25 +04:00
|
|
|
|
2012-09-09 15:24:15 +04:00
|
|
|
/**
|
|
|
|
* Allows to set cookies into the CookieJar.
|
|
|
|
* Pages will be able to access only the cookies they are supposed to see given their URL.
|
|
|
|
*
|
|
|
|
* Cookies are expected in the format:
|
|
|
|
* <pre>
|
|
|
|
* {
|
|
|
|
* "name" : "cookie name (string)",
|
|
|
|
* "value" : "cookie value (string)",
|
|
|
|
* "domain" : "cookie domain (string)",
|
|
|
|
* "path" : "cookie path (string, optional)",
|
|
|
|
* "httponly" : "http only cookie (boolean, optional)",
|
|
|
|
* "secure" : "secure cookie (boolean, optional)",
|
|
|
|
* "expires" : "expiration date (string, GMT format, optional)"
|
|
|
|
* }
|
|
|
|
* </pre>
|
|
|
|
* @brief setCookies
|
|
|
|
* @param cookies Expects a QList of QVariantMaps
|
|
|
|
* @return Boolean "true" if at least 1 cookie was set
|
|
|
|
*/
|
|
|
|
bool setCookies(const QVariantList &cookies);
|
|
|
|
/**
|
|
|
|
* All the Cookies in the CookieJar
|
|
|
|
*
|
|
|
|
* @see WebPage::setCookies for details on the format
|
|
|
|
* @brief cookies
|
|
|
|
* @return QList of QVariantMap cookies visible to this Page, at the current URL.
|
|
|
|
*/
|
|
|
|
QVariantList cookies() const;
|
|
|
|
/**
|
|
|
|
* Add a Cookie (in QVariantMap format) into the CookieJar
|
|
|
|
* @see WebPage::setCookies for details on the format
|
|
|
|
* @brief addCookie
|
|
|
|
* @param cookie Cookie in QVariantMap format
|
|
|
|
* @return Boolean "true" if cookie was added
|
|
|
|
*/
|
|
|
|
bool addCookie(const QVariantMap &cookie);
|
|
|
|
/**
|
|
|
|
* Delete cookie by name from the CookieJar
|
|
|
|
* @brief deleteCookie
|
|
|
|
* @param cookieName Name of the Cookie to delete
|
|
|
|
* @return Boolean "true" if cookie was deleted
|
|
|
|
*/
|
|
|
|
bool deleteCookie(const QString &cookieName);
|
|
|
|
/**
|
|
|
|
* Delete All Cookies from the CookieJar
|
|
|
|
* @brief clearCookies
|
|
|
|
*/
|
|
|
|
void clearCookies();
|
|
|
|
|
2013-12-12 16:05:15 +04:00
|
|
|
/**
|
|
|
|
* Set the application proxy
|
|
|
|
* @brief setProxy
|
|
|
|
* @param ip The proxy ip
|
|
|
|
* @param port The proxy port
|
|
|
|
* @param proxyType The type of this proxy
|
|
|
|
*/
|
|
|
|
void setProxy(const QString &ip, const qint64 &port = 80, const QString &proxyType = "http", const QString &user = NULL, const QString &password = NULL);
|
|
|
|
|
2011-10-25 23:16:25 +04:00
|
|
|
// exit() will not exit in debug mode. debugExit() will always exit.
|
2011-06-20 21:14:08 +04:00
|
|
|
void exit(int code = 0);
|
2011-10-25 23:16:25 +04:00
|
|
|
void debugExit(int code = 0);
|
2011-04-08 17:30:50 +04:00
|
|
|
|
A REPL for PhantomJS
This covers [Issue 252](http://code.google.com/p/phantomjs/issues/detail?id=252)
The commit is composed of 12 squashed commits:
commit efdc6ba4f143c30a690fd97d92d80fa412e79999
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Mon Feb 27 00:19:36 2012 +0000
Pretty-pringing and Completion Caching done!
* This completes pretty-printing for the result of evaluated
* expressions in the REPL.
* Also, now we cache the "possible completions", to speed things up
* a bit (nothing fancy though).
* Minor tweaks to the internal doc and the way we "mock"
* pretty-printing for QObjects/REPLCompletanle
* All tests passing :)
commit 1f9ef690e112a535b431fca409b77bb9c09d1c70
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Sun Feb 26 22:35:00 2012 +0000
Moving most of REPL shim JavaScritp code in a separate file. Way
easier to work on.
commit 02d460a16fee14e7096ae7d899c03902c5b8a9c6
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Sat Feb 25 20:25:18 2012 +0000
Initialisation of the Completions is now done in a pure virtual.
This means that every REPLCompletable object will ACTUALLY register
completion strings, ONLY if we are running a REPL
and that object is ACTUALLY created.
Otherwise, why bother?
Adding completions for all exposed REPLCompletable objects
Also, fixed an issue with _getCompletions()
commit 412c3778fb04aa1c7379f8e760afce702b0428dd
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Tue Feb 21 00:49:17 2012 +0000
Few more tweaks to the REPL:
- Now 'phantom' is the first QObject with proper completion
- No repetition in QObject completions
- LVAL of any user expression is now correctly prettified and
printed
Major things left to do:
- Cache completions (using QCache?)
- Add completions for the other QObject
- When the LVAL of a user expression is a QObject, print what's
expected, not the QObject "real" structure
commit 46f04713c8165d898055e15478bb31403f8c93f1
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Tue Feb 7 10:13:23 2012 -0800
Pretty-print expressions result
Still not done though: there are issues with the NON-Native JS
objects.
commit 98b2fe67651dc750b62c6fa9cf1d80317fd9ae06
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Fri Feb 3 00:22:52 2012 -0800
Introducing REPLCompletable.
This class should be inherited by any JavaScript-exposed QObject, to
ensure correct Auto-Completion.
Correct auto-completion for QObjects.
- Now even QObjects can correctly provide auto-completion, and avoid
showing "not for users" methods
- The strings used for the auto-completion are stored in a single
Index: minimum memory footprint
- Still, there is optimization that should be done (when "searching"
for the right completion by prefix)
- Completion for the objects not set up yet, but now it's just a
trivial sequence of "addCompletion('bla')" in their constructors
commit 9bd48618154b1530a37b41f4060440184e23253d
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Thu Feb 2 00:20:25 2012 -0800
Changing the way we import Linenoise.
Will just import a specific commit, and update manually when needed.
commit cfc9bae9fbdab13b01019b34b7cbd565e3153780
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Sun Jan 29 23:22:26 2012 -0800
Made the REPL into a Singleton. With Auto-completion!.
Reasons:
1) Needed a pointer to function (i.e. a static method) to be used
with Linenoise to provide auto-completions
2) It makes more sense, as it's not like we are going to have 2 REPL
running at the same time, are we?
There are problems to address:
- the enumeration in JS seems to return only the native interface of
our objects
- the function completions contain argument types of those functions
- "private" methods are exposed
commit c78bd32e17f8e0e4cc4a0066858de8cc81d33b97
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Sun Jan 29 22:10:20 2012 -0800
Migrating from the original, now [unmantained
Linenoise](https://github.com/antirez/linenoise) to the fairly active
[tadmarshall fork](https://github.com/tadmarshall/linenoise).
Also now the project is imported as a Git Submodule.
Having migrated to the latest Linenoise (see prev. commit), now this
_SHOULD_ work on Windows too.
But, of course, this needs testing. :)
commit 43713c5723d7c5ed446ba41ae8d6f8c9feba7f9b
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Tue Jan 24 23:17:06 2012 -0800
Now that the basics work, I'm adding support for REPL history.
This is something almost everyone today is accustomed to.
Also, now REPL history works!
And I found some useful resources to solve pending TODOs.
commit 31e5f88b044a5b4a823c67527ef8c245d2ac7863
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Sun Jan 22 20:56:36 2012 -0800
Adding Linenoise Project (https://github.com/antirez/linenoise).
For now is included as a drop-in set of files.
Later on, if the Linenoise project has frequent
updates, we might prefer to do it as a
git-submodule.
commit 4be9c15c65db4767e482fba0be13f8aab286d5f3
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Thu Jan 5 15:31:13 2012 +0000
First simple REPL implementation.
- Not complete
- Still doesn't handle arrow keys (needed for history)
2012-01-05 19:31:13 +04:00
|
|
|
signals:
|
|
|
|
void aboutToExit(int code);
|
|
|
|
|
2011-05-29 08:16:18 +04:00
|
|
|
private slots:
|
2012-03-19 02:22:02 +04:00
|
|
|
void printConsoleMessage(const QString &msg);
|
2011-05-29 08:16:18 +04:00
|
|
|
|
2011-10-25 23:16:25 +04:00
|
|
|
void onInitialized();
|
2012-07-05 04:21:15 +04:00
|
|
|
|
2011-04-08 17:30:50 +04:00
|
|
|
private:
|
2011-10-25 23:16:25 +04:00
|
|
|
void doExit(int code);
|
|
|
|
|
2011-08-16 22:53:56 +04:00
|
|
|
Encoding m_scriptFileEnc;
|
2011-05-26 01:00:20 +04:00
|
|
|
WebPage *m_page;
|
2011-05-29 11:20:56 +04:00
|
|
|
bool m_terminated;
|
2011-04-08 17:30:50 +04:00
|
|
|
int m_returnValue;
|
|
|
|
QString m_script;
|
2011-05-28 07:37:36 +04:00
|
|
|
QVariantMap m_defaultPageSettings;
|
2011-09-09 04:37:01 +04:00
|
|
|
FileSystem *m_filesystem;
|
2012-03-15 10:17:03 +04:00
|
|
|
System *m_system;
|
2012-12-28 17:43:25 +04:00
|
|
|
ChildProcess *m_childprocess;
|
2012-09-24 18:18:52 +04:00
|
|
|
QList<QPointer<WebPage> > m_pages;
|
2011-11-15 16:44:47 +04:00
|
|
|
QList<QPointer<WebServer> > m_servers;
|
2011-08-28 16:05:34 +04:00
|
|
|
Config m_config;
|
2013-06-18 23:09:36 +04:00
|
|
|
CookieJar *m_defaultCookieJar;
|
2012-07-27 20:13:43 +04:00
|
|
|
|
|
|
|
friend class CustomPage;
|
2011-04-08 17:30:50 +04:00
|
|
|
};
|
2011-04-09 22:49:22 +04:00
|
|
|
|
|
|
|
#endif // PHANTOM_H
|