Kross

plugin.cpp
1 /***************************************************************************
2  * plugin.cpp
3  * This file is part of the KDE project
4  * copyright (C)2007 by Sebastian Sauer ([email protected])
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  * You should have received a copy of the GNU Library General Public License
15  * along with this program; see the file COPYING. If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  ***************************************************************************/
19 
20 #include "plugin.h"
21 #include "values_p.h"
22 #include "kross_qts_plugin_debug.h"
23 
24 #include "../core/manager.h"
25 
26 using namespace Kross;
27 
28 namespace Kross
29 {
30 
31 /// \internal d-pointer class.
32 class EcmaPlugin::Private
33 {
34 public:
35  QScriptValue manager;
36 };
37 
38 }
39 
41  : QScriptExtensionPlugin(parent)
42  , d(new Private)
43 {
44  //qDebug()<<QString("EcmaPlugin Ctor");
45 }
46 
48 {
49  //qDebug()<<QString("EcmaPlugin Dtor");
50  delete d;
51 }
52 
53 void EcmaPlugin::initialize(const QString &key, QScriptEngine *engine)
54 {
55  if (key.toLower() == "kross") {
56  QScriptValue global = engine->globalObject();
57 
58  //QScriptContext *context = engine->currentContext();
59  d->manager = engine->newQObject(&Kross::Manager::self());
60  global.setProperty("Kross", d->manager);
61 
62  initializeCore(engine);
63  initializeGui(engine);
64  } else {
65  qCDebug(KROSS_QTS_PLUGIN_LOG) << "Plugin::initialize unhandled key=" << key;
66  }
67 }
68 
70 {
71  //qDebug()<<"> Plugin::keys";
72  return QStringList() << "kross";
73 }
74 
75 #include "moc_plugin.cpp"
EcmaPlugin(QObject *parent=nullptr)
Constructor.
Definition: plugin.cpp:40
QStringList keys() const override
Returns the list of keys this plugin supports.
Definition: plugin.cpp:69
~EcmaPlugin() override
Destructor.
Definition: plugin.cpp:47
QString toLower() const const
void initialize(const QString &key, QScriptEngine *engine) override
Initializes this extension.
Definition: plugin.cpp:53
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Dec 7 2023 04:10:00 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.