KJS-API
kjsprivate.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
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
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