2 Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
22 #include "qscriptsyntaxcheckresult.h"
23 #include "qscriptsyntaxcheckresult_p.h"
26 \class QScriptSyntaxCheckResult
28 \brief The QScriptSyntaxCheckResult class provides the result of a script syntax check.
33 QScriptSyntaxCheckResult is returned by QScriptEngine::checkSyntax() to
34 provide information about the syntactical (in)correctness of a script.
38 \enum QScriptSyntaxCheckResult::State
40 This enum specifies the state of a syntax check.
42 \value Error The program contains a syntax error.
43 \value Intermediate The program is incomplete.
44 \value Valid The program is a syntactically correct Qt Script program.
48 Constructs a new QScriptSyntaxCheckResult from the \a other result.
50 QScriptSyntaxCheckResult::QScriptSyntaxCheckResult(const QScriptSyntaxCheckResult
& other
)
55 Constructs a new QScriptSyntaxCheckResult from an internal representation.
58 QScriptSyntaxCheckResult::QScriptSyntaxCheckResult(QScriptSyntaxCheckResultPrivate
* d
)
63 Destroys this QScriptSyntaxCheckResult.
65 QScriptSyntaxCheckResult::~QScriptSyntaxCheckResult()
69 Assigns the \a other result to this QScriptSyntaxCheckResult, and returns a
70 reference to this QScriptSyntaxCheckResult.
72 QScriptSyntaxCheckResult
& QScriptSyntaxCheckResult::operator=(const QScriptSyntaxCheckResult
& other
)
79 Returns the state of this QScriptSyntaxCheckResult.
81 QScriptSyntaxCheckResult::State
QScriptSyntaxCheckResult::state() const
83 return d_ptr
->state();
87 Returns the error line number of this QScriptSyntaxCheckResult, or -1 if
90 \sa state(), errorMessage()
92 int QScriptSyntaxCheckResult::errorLineNumber() const
94 return d_ptr
->errorLineNumber();
98 Returns the error column number of this QScriptSyntaxCheckResult, or -1 if
101 \sa state(), errorLineNumber()
103 int QScriptSyntaxCheckResult::errorColumnNumber() const
105 return d_ptr
->errorColumnNumber();
109 Returns the error message of this QScriptSyntaxCheckResult, or an empty
110 string if there is no error.
112 \sa state(), errorLineNumber()
114 QString
QScriptSyntaxCheckResult::errorMessage() const
116 return d_ptr
->errorMessage();
119 QScriptSyntaxCheckResultPrivate::~QScriptSyntaxCheckResultPrivate()
122 JSValueUnprotect(*m_engine
, m_exception
);
125 QString
QScriptSyntaxCheckResultPrivate::errorMessage() const
130 JSStringRef tmp
= JSValueToStringCopy(*m_engine
, m_exception
, /* exception */ 0);
131 QString message
= QScriptConverter::toString(tmp
);
132 JSStringRelease(tmp
);
136 int QScriptSyntaxCheckResultPrivate::errorLineNumber() const
140 // m_exception is an instance of the Exception so it has "line" attribute.
141 JSStringRef lineAttrName
= QScriptConverter::toString("line");
142 JSValueRef line
= JSObjectGetProperty(*m_engine
,
146 JSStringRelease(lineAttrName
);
147 return JSValueToNumber(*m_engine
, line
, /* exceptions */0);