File indexing completed on 2024-04-28 15:28:45

0001 /* This file is part of the KDE libraries
0002     Copyright (C) 2004,2005,2006 Ian Reinhart Geiser <geiseri@kde.org>
0003     Copyright (C) 2004,2005,2006 Matt Broadstone <mbroadst@gmail.com>
0004     Copyright (C) 2004,2005,2006 Richard J. Moore <rich@kde.org>
0005     Copyright (C) 2004,2005,2006 Erik L. Bunce <kde@bunce.us>
0006 
0007     This library is free software; you can redistribute it and/or
0008     modify it under the terms of the GNU Library General Public
0009     License as published by the Free Software Foundation; either
0010     version 2 of the License, or (at your option) any later version.
0011 
0012     This library is distributed in the hope that it will be useful,
0013     but WITHOUT ANY WARRANTY; without even the implied warranty of
0014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015     Library General Public License for more details.
0016 
0017     You should have received a copy of the GNU Library General Public License
0018     along with this library; see the file COPYING.LIB.  If not, write to
0019     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0020     Boston, MA 02110-1301, USA.
0021 */
0022 
0023 #ifndef KJSEGLOBAL_H
0024 #define KJSEGLOBAL_H
0025 
0026 #include <kjsembed_export.h>
0027 #include <qglobal.h>
0028 
0029 #if !defined(Q_OS_WIN)
0030 #include <stdlib.h>
0031 #include <ctype.h>
0032 
0033 namespace KJSEmbed
0034 {
0035 KJSEMBED_EXPORT void RedirectIOToConsole();
0036 }
0037 
0038 #endif
0039 
0040 #include <QTextStream>
0041 namespace KJSEmbed
0042 {
0043 KJSEMBED_EXPORT QTextStream *conin();
0044 KJSEMBED_EXPORT QTextStream *conout();
0045 KJSEMBED_EXPORT QTextStream *conerr();
0046 }
0047 
0048 #include <kjs/ustring.h>
0049 #include <kjs/identifier.h>
0050 #include <kjs/value.h>
0051 
0052 namespace KJSEmbed
0053 {
0054 inline QString toQString(const KJS::UString &u)
0055 {
0056     return QString((QChar *)u.data(), u.size());
0057 }
0058 inline QString toQString(const KJS::Identifier &i)
0059 {
0060     return QString((QChar *)i.data(), i.size());
0061 }
0062 inline KJS::UString toUString(const QString &qs)
0063 {
0064     return KJS::UString((KJS::UChar *)qs.data(), qs.size());
0065 }
0066 }
0067 
0068 namespace KJS
0069 {
0070 inline KJS::JSCell *jsString(const QString &s)
0071 {
0072     return jsString(KJSEmbed::toUString(s));
0073 }
0074 }
0075 
0076 #ifndef QT_ONLY
0077 
0078 /*
0079  * These are the normal definitions used when KDE is available.
0080  */
0081 
0082 #include <QDebug>
0083 #include <klocalizedstring.h>
0084 
0085 #else // QT_ONLY
0086 
0087 /*
0088  * These are the custom definitions used when we only have Qt.
0089  */
0090 
0091 KJSEMBED_EXPORT QTextStream &kdDebug(int area = 0);
0092 KJSEMBED_EXPORT QTextStream &kdWarning(int area = 0);
0093 
0094 #ifndef NO_I18N
0095 KJSEMBED_EXPORT QString i18n(const char *string);
0096 #else
0097 #define i18n(x) QString(x)
0098 #endif // NO_I18N
0099 
0100 inline KJSEMBED_EXPORT QString i18n(const QString &string, const QString &comment)
0101 {
0102     return i18n(string.toUtf8().data(), comment.toUtf8().data());
0103 }
0104 template <typename A1>
0105 inline QString i18n(const char *text, const A1 &a1)
0106 {
0107     return i18n(text).arg(a1);
0108 }
0109 template <typename A1, typename A2>
0110 inline QString i18n(const char *text, const A1 &a1, const A2 &a2)
0111 {
0112     return i18n(text).arg(a1).arg(a2);
0113 }
0114 template <typename A1, typename A2, typename A3>
0115 inline QString i18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3)
0116 {
0117     return i18n(text).arg(a1).arg(a2).arg(a3);
0118 }
0119 template <typename A1, typename A2, typename A3, typename A4>
0120 inline QString i18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4)
0121 {
0122     return i18n(text).arg(a1).arg(a2).arg(a3).arg(a4);
0123 }
0124 
0125 #endif // QT_ONLY
0126 
0127 #endif // KJSEGLOBAL_H
0128