• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KJS-API

kjsprivate.h

Go to the documentation of this file.
00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (C) 2008 Harri Porten (porten@kde.org)
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Library General Public
00007  *  License as published by the Free Software Foundation; either
00008  *  version 2 of the License, or (at your option) any later version.
00009  *
00010  *  This library 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  *
00015  *  You should have received a copy of the GNU Library General Public License
00016  *  along with this library; see the file COPYING.LIB.  If not, write to
00017  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  *  Boston, MA 02110-1301, USA.
00019  *
00020  */
00021 
00022 #ifndef KJSPRIVATE_H
00023 #define KJSPRIVATE_H
00024 
00025 #include "kjs/ustring.h"
00026 #include "kjs/identifier.h"
00027 #include "kjs/list.h"
00028 #include <QtCore/QString>
00029 
00030 #define JSVALUE_HANDLE(v) reinterpret_cast<KJSObjectHandle*>(v)
00031 #define JSVALUE(h) reinterpret_cast<KJS::JSValue*>((h)->hnd)
00032 
00033 #define EXECSTATE_HANDLE(c) reinterpret_cast<KJSContextHandle*>(c)
00034 #define EXECSTATE(ctx) reinterpret_cast<ExecState*>((ctx)->hnd)
00035 
00036 #define INTERPRETER_HANDLE(i) reinterpret_cast<KJSInterpreterHandle*>(i)
00037 #define INTERPRETER(h) reinterpret_cast<KJS::Interpreter*>((h)->hnd)
00038 
00039 #define PROTOTYPE_HANDLE(p) reinterpret_cast<KJSPrototypeHandle*>(p)
00040 #define PROTOTYPE(h) reinterpret_cast<CustomPrototype*>((h)->hnd)
00041 
00042 #define LIST_HANDLE(l) reinterpret_cast<const KJSArgumentsHandle*>(l)
00043 #define LIST(h) reinterpret_cast<const KJS::List*>((h)->hnd)
00044 
00045 // FIXME: duplicated in khtml/ecma/kjs_binding.h
00046 #define KJS_CHECK_THIS( ClassName, theObj ) \
00047        if (!theObj || !theObj->inherits(&ClassName::info)) { \
00048                KJS::UString errMsg = "Attempt at calling a function that expects a "; \
00049                errMsg += ClassName::info.className; \
00050                errMsg += " on a "; \
00051                errMsg += theObj->className(); \
00052                KJS::JSObject *err = KJS::Error::create(exec, KJS::TypeError, errMsg.ascii()); \
00053                exec->setException(err); \
00054                return err; \
00055        }
00056 
00057 static inline KJS::UString toUString(const QString& s)
00058 {
00059     // ### can be done faster. see khtml/ecma/kjs_binding.cpp
00060     int l = s.length();
00061     const KJS::UChar* u = reinterpret_cast<const KJS::UChar*>(s.unicode());
00062     return KJS::UString(u, l);
00063 }
00064 
00065 static inline KJS::Identifier toIdentifier(const QString& s)
00066 {
00067     int l = s.length();
00068     const KJS::UChar* u = reinterpret_cast<const KJS::UChar*>(s.unicode());
00069     return KJS::Identifier(u, l);
00070 }
00071 
00072 static inline QString toQString(const KJS::UString& s)
00073 {
00074     int l = s.size();
00075     const QChar* u = reinterpret_cast<const QChar*>(s.data());
00076     return QString(u, l);
00077 }
00078 
00079 #endif

KJS-API

Skip menu "KJS-API"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal