]>
git.saurik.com Git - apple/javascriptcore.git/blob - qt/api/qscriptprogram.cpp
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 "qscriptprogram.h"
24 #include "qscriptprogram_p.h"
31 \brief The QScriptProgram class encapsulates a Qt Script program.
35 QScriptProgram retains the compiled representation of the script if
36 possible. Thus, QScriptProgram can be used to evaluate the same
37 script multiple times more efficiently.
41 QScriptProgram program("1 + 2");
42 QScriptValue result = engine.evaluate(program);
47 Constructs a null QScriptProgram.
49 QScriptProgram::QScriptProgram()
50 : d_ptr(new QScriptProgramPrivate
)
54 Constructs a new QScriptProgram with the given \a sourceCode, \a
55 fileName and \a firstLineNumber.
57 QScriptProgram::QScriptProgram(const QString
& sourceCode
,
58 const QString fileName
,
60 : d_ptr(new QScriptProgramPrivate(sourceCode
, fileName
, firstLineNumber
))
64 Destroys this QScriptProgram.
66 QScriptProgram::~QScriptProgram()
70 Constructs a new QScriptProgram that is a copy of \a other.
72 QScriptProgram::QScriptProgram(const QScriptProgram
& other
)
78 Assigns the \a other value to this QScriptProgram.
80 QScriptProgram
& QScriptProgram::operator=(const QScriptProgram
& other
)
87 Returns true if this QScriptProgram is null; otherwise
90 bool QScriptProgram::isNull() const
92 return d_ptr
->isNull();
96 Returns the source code of this program.
98 QString
QScriptProgram::sourceCode() const
100 return d_ptr
->sourceCode();
104 Returns the filename associated with this program.
106 QString
QScriptProgram::fileName() const
108 return d_ptr
->fileName();
112 Returns the line number associated with this program.
114 int QScriptProgram::firstLineNumber() const
116 return d_ptr
->firstLineNumber();
120 Returns true if this QScriptProgram is equal to \a other;
121 otherwise returns false.
123 bool QScriptProgram::operator==(const QScriptProgram
& other
) const
125 return d_ptr
== other
.d_ptr
|| *d_ptr
== *other
.d_ptr
;
129 Returns true if this QScriptProgram is not equal to \a other;
130 otherwise returns false.
132 bool QScriptProgram::operator!=(const QScriptProgram
& other
) const
134 return d_ptr
!= other
.d_ptr
&& *d_ptr
!= *other
.d_ptr
;