File: QtScriptBindingsTest.cpp

package info (click to toggle)
qterm 1%3A0.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,048 kB
  • ctags: 3,132
  • sloc: cpp: 41,779; ansic: 422; xml: 122; makefile: 9
file content (46 lines) | stat: -rw-r--r-- 1,652 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * Copyright (C) 2009 Ian Monroe <ian@monroe.nu>
 * released under public domain or:
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include <QtCore/QCoreApplication>
#include <QtScript/QScriptEngine>
#include <QtCore/QStringList>
#include <QtCore/QDebug>

#define FAIL 0xA

int main(int argc, char **argv)
{
    QCoreApplication app( argc, argv );

    QStringList allowedBindings;
    allowedBindings << "qt.core" << "qt.gui" << "qt.sql" << "qt.xml" << "qt.uitools" << "qt.network" << "qt.webkit";
    QScriptEngine engine;
    foreach( QString binding, allowedBindings )
    {
        QScriptValue error = engine.importExtension( binding );
        if( error.isUndefined() )
        { // undefined indiciates success
            continue;
        }

        qDebug() << "Extension" << binding <<  "not found:" << error.toString();
        qDebug() << "Available extensions:" << engine.availableExtensions();
        return FAIL;
    }
    return 0;
}