File indexing completed on 2024-03-24 15:37:26

0001 /***************************************************************************
0002  * plugin.cpp
0003  * This file is part of the KDE project
0004  * copyright (C)2007 by Sebastian Sauer (mail@dipe.org)
0005  *
0006  * This program is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Library General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2 of the License, or (at your option) any later version.
0010  * This program is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * Library General Public License for more details.
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this program; see the file COPYING.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  ***************************************************************************/
0019 
0020 #include "plugin.h"
0021 #include "values_p.h"
0022 #include "kross_qts_plugin_debug.h"
0023 
0024 #include "../core/manager.h"
0025 
0026 using namespace Kross;
0027 
0028 namespace Kross
0029 {
0030 
0031 /// \internal d-pointer class.
0032 class EcmaPlugin::Private
0033 {
0034 public:
0035     QScriptValue manager;
0036 };
0037 
0038 }
0039 
0040 EcmaPlugin::EcmaPlugin(QObject *parent)
0041     : QScriptExtensionPlugin(parent)
0042     , d(new Private)
0043 {
0044     //qDebug()<<QString("EcmaPlugin Ctor");
0045 }
0046 
0047 EcmaPlugin::~EcmaPlugin()
0048 {
0049     //qDebug()<<QString("EcmaPlugin Dtor");
0050     delete d;
0051 }
0052 
0053 void EcmaPlugin::initialize(const QString &key, QScriptEngine *engine)
0054 {
0055     if (key.toLower() == "kross") {
0056         QScriptValue global = engine->globalObject();
0057 
0058         //QScriptContext *context = engine->currentContext();
0059         d->manager = engine->newQObject(&Kross::Manager::self());
0060         global.setProperty("Kross", d->manager);
0061 
0062         initializeCore(engine);
0063         initializeGui(engine);
0064     } else {
0065         qCDebug(KROSS_QTS_PLUGIN_LOG) << "Plugin::initialize unhandled key=" << key;
0066     }
0067 }
0068 
0069 QStringList EcmaPlugin::keys() const
0070 {
0071     //qDebug()<<"> Plugin::keys";
0072     return QStringList() << "kross";
0073 }
0074 
0075 #include "moc_plugin.cpp"