Kross
metafunction.h
Go to the documentation of this file.00001 /*************************************************************************** 00002 * metafunction.h 00003 * This file is part of the KDE project 00004 * copyright (C)2005-2006 Ian Reinhart Geiser <geiseri@kde.org> 00005 * copyright (C)2005-2006 Matt Broadstone <mbroadst@gmail.com> 00006 * copyright (C)2005-2006 Richard J. Moore <rich@kde.org> 00007 * copyright (C)2005-2006 Erik L. Bunce <kde@bunce.us> 00008 * copyright (C)2005-2007 by Sebastian Sauer <mail@dipe.org> 00009 * 00010 * This program is free software; you can redistribute it and/or 00011 * modify it under the terms of the GNU Library General Public 00012 * License as published by the Free Software Foundation; either 00013 * version 2 of the License, or (at your option) any later version. 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * Library General Public License for more details. 00018 * You should have received a copy of the GNU Library General Public License 00019 * along with this program; see the file COPYING. If not, write to 00020 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00021 * Boston, MA 02110-1301, USA. 00022 ***************************************************************************/ 00023 00024 #ifndef KROSS_METAFUNCTION_H 00025 #define KROSS_METAFUNCTION_H 00026 00027 #include <QtCore/QObject> 00028 #include <QtCore/QArgument> 00029 #include <QtCore/QByteRef> 00030 #include <QtCore/QPointer> 00031 00032 namespace Kross { 00033 00042 class MetaFunction : public QObject 00043 { 00044 public: 00045 00054 MetaFunction(QObject* sender, const QByteArray& signal) 00055 : QObject(), m_sender(sender), m_signature(QMetaObject::normalizedSignature(signal)) 00056 { 00057 //krossdebug(QString("MetaFunction sender=\"%1\" signal=\"%2\"").arg(sender->objectName()).arg(m_signature.constData())); 00058 const uint signatureSize = m_signature.size() + 1; 00059 00060 // content 00061 m_data[0] = 1; // revision 00062 m_data[1] = 0; // classname 00063 m_data[2] = 0; // classinfo 00064 m_data[3] = 0; // classinfo 00065 m_data[4] = 1; // methods 00066 m_data[5] = 15; // methods 00067 m_data[6] = 0; // properties 00068 m_data[7] = 0; // properties 00069 m_data[8] = 0; // enums/sets 00070 m_data[9] = 0; // enums/sets 00071 00072 // slots 00073 m_data[15] = 15; // signature start 00074 m_data[16] = 15 + signatureSize; // parameters start 00075 m_data[17] = 15 + signatureSize; // type start 00076 m_data[18] = 15 + signatureSize; // tag start 00077 m_data[19] = 0x0a; // flags 00078 m_data[20] = 0; // eod 00079 00080 // data 00081 m_stringData = QByteArray("ScriptFunction\0", 15); 00082 m_stringData += m_signature; 00083 m_stringData += QByteArray("\0\0", 2); 00084 00085 // static metaobject 00086 staticMetaObject.d.superdata = &QObject::staticMetaObject; 00087 staticMetaObject.d.stringdata = m_stringData.data(); 00088 staticMetaObject.d.data = m_data; 00089 staticMetaObject.d.extradata = 0; 00090 } 00091 00095 virtual ~MetaFunction() {} 00096 00101 QMetaObject staticMetaObject; 00102 00107 const QMetaObject *metaObject() const { 00108 return &staticMetaObject; 00109 } 00110 00116 void *qt_metacast(const char *_clname) { 00117 if (! _clname) 00118 return 0; 00119 if (! strcmp(_clname, m_stringData)) 00120 return static_cast<void*>( const_cast< MetaFunction* >(this) ); 00121 return QObject::qt_metacast(_clname); 00122 } 00123 00128 int qt_metacall(QMetaObject::Call _c, int _id, void **_a) = 0; 00129 00130 protected: 00132 QPointer<QObject> m_sender; 00134 QByteArray m_signature; 00136 QByteArray m_stringData; 00138 uint m_data[21]; 00139 }; 00140 00141 } 00142 00143 #endif