Kross
plugin.cpp
Go to the documentation of this file.00001 /*************************************************************************** 00002 * plugin.cpp 00003 * This file is part of the KDE project 00004 * copyright (C)2007 by Sebastian Sauer (mail@dipe.org) 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this program; see the file COPYING. If not, write to 00016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 ***************************************************************************/ 00019 00020 #include "plugin.h" 00021 #include "values_p.h" 00022 00023 #include "../core/manager.h" 00024 00025 #include <QDebug> 00026 00027 using namespace Kross; 00028 00029 Q_EXPORT_PLUGIN2(krossqtsplugin, Kross::EcmaPlugin) 00030 00031 namespace Kross { 00032 00034 class EcmaPlugin::Private 00035 { 00036 public: 00037 QScriptValue manager; 00038 }; 00039 00040 } 00041 00042 EcmaPlugin::EcmaPlugin(QObject* parent) 00043 : QScriptExtensionPlugin(parent) 00044 , d(new Private) 00045 { 00046 //qDebug()<<QString("EcmaPlugin Ctor"); 00047 } 00048 00049 EcmaPlugin::~EcmaPlugin() 00050 { 00051 //qDebug()<<QString("EcmaPlugin Dtor"); 00052 delete d; 00053 } 00054 00055 void EcmaPlugin::initialize(const QString& key, QScriptEngine* engine) 00056 { 00057 if( key.toLower() == "kross" ) { 00058 QScriptValue global = engine->globalObject(); 00059 00060 //QScriptContext *context = engine->currentContext(); 00061 d->manager = engine->newQObject( &Kross::Manager::self() ); 00062 global.setProperty("Kross", d->manager); 00063 00064 initializeCore(engine); 00065 initializeGui(engine); 00066 } 00067 else 00068 qDebug()<<QString("Plugin::initialize unhandled key=%1").arg(key); 00069 } 00070 00071 QStringList EcmaPlugin::keys() const 00072 { 00073 //qDebug()<<"> Plugin::keys"; 00074 return QStringList() << "kross"; 00075 } 00076