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

KJS-API

  • sources
  • kde-4.12
  • kdelibs
  • kjs
  • api
kjscontext.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (C) 2008 Harri Porten (porten@kde.org)
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  *
20  */
21 
22 #include "kjscontext.h"
23 #include "kjsinterpreter.h"
24 #include "kjsprivate.h"
25 #include "kjs/object.h"
26 #include "kjs/ExecState.h"
27 #include "kjs/interpreter.h"
28 
29 using namespace KJS;
30 
31 KJSContext::KJSContext(KJSContextHandle* h)
32  : hnd(h)
33 {
34 }
35 
36 bool KJSContext::hasException() const
37 {
38  return EXECSTATE(this)->hadException();
39 }
40 
41 KJSObject KJSContext::throwException(const QString& message) const
42 {
43  ExecState* exec = EXECSTATE(this);
44 
45  JSValue* ex = Error::create(exec, GeneralError, toUString(message),
46  -1, -1, UString());
47  exec->setException(ex);
48 
49  return KJSObject(JSVALUE_HANDLE(ex));
50 }
51 
52 KJSInterpreter KJSContext::interpreter()
53 {
54  ExecState* exec = EXECSTATE(this);
55  Interpreter* ip = exec->dynamicInterpreter();
56 
57  return KJSInterpreter(INTERPRETER_HANDLE(ip));
58 }
KJSContext::KJSInterpreter
friend class KJSInterpreter
Definition: kjscontext.h:44
KJSContext::hasException
bool hasException() const
Returns true if this context has an unhandled exception.
Definition: kjscontext.cpp:36
KJSContext::throwException
KJSObject throwException(const QString &message) const
Throws a general exception with the specified error message.
Definition: kjscontext.cpp:41
INTERPRETER_HANDLE
#define INTERPRETER_HANDLE(i)
Definition: kjsprivate.h:36
toUString
static KJS::UString toUString(const QString &s)
Definition: kjsprivate.h:45
EXECSTATE
#define EXECSTATE(ctx)
Definition: kjsprivate.h:34
kjsinterpreter.h
KJSInterpreter
A class representing a JavaScript interpreter.
Definition: kjsinterpreter.h:82
KJSContext::KJSObject
friend class KJSObject
Definition: kjscontext.h:41
KJSObject
A class representing a JavaScript value.
Definition: kjsobject.h:48
kjscontext.h
KJSContext::interpreter
KJSInterpreter interpreter()
Returns the currently executing interpreter.
Definition: kjscontext.cpp:52
JSVALUE_HANDLE
#define JSVALUE_HANDLE(v)
Definition: kjsprivate.h:30
kjsprivate.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:58 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KJS-API

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal