├── examples ├── images │ ├── brick.png │ ├── cheese.png │ ├── checker.png │ ├── qt-logo.png │ └── butterfly.png ├── WebKitPlugins.html ├── TwoWayButton.qs ├── AnimatedBox.qs ├── DigitalClock.js ├── jennifer.xbel └── AnalogClock.js ├── generator ├── typesystem_uitools.xml ├── typesystem_svg-qtscript.xml ├── build_core.txt ├── build_gui.txt ├── build_xml.txt ├── build_network.txt ├── build_xmlpatterns.txt ├── build_opengl.txt ├── build_phonon.txt ├── build_uitools.txt ├── build_sql.txt ├── build_svg.txt ├── build_webkit.txt ├── parser │ ├── rxx.pro │ ├── rpp │ │ ├── pp-qt-configuration │ │ ├── rpp.pri │ │ ├── builtin-macros.cpp │ │ ├── pp-fwd.h │ │ ├── pp-cctype.h │ │ ├── pp-configuration │ │ ├── pp-macro.h │ │ ├── preprocessor.h │ │ ├── pp-iterator.h │ │ ├── pp.h │ │ ├── pp-symbol.h │ │ └── pp-string.h │ ├── r++.macros │ ├── rxx.pri │ ├── rpp-allocator.h │ ├── list.cpp │ ├── smallobject.cpp │ ├── ast.cpp │ ├── dumptree.h │ ├── smallobject.h │ ├── compiler_utils.h │ ├── include │ │ └── stdarg.h │ ├── compiler_utils.cpp │ ├── class_compiler.cpp │ ├── name_compiler.h │ ├── class_compiler.h │ ├── codemodel_finder.h │ ├── type_compiler.h │ ├── declarator_compiler.h │ ├── list.h │ ├── codemodel_fwd.h │ ├── symbol.h │ └── codemodel_finder.cpp ├── typesystem_opengl-qtscript.xml ├── typesystem_sql-qtscript.xml ├── typesystem_xmlpatterns-qtscript.xml ├── typesystem_webkit-qtscript.xml ├── generator.pro ├── build_all.txt ├── generator.qrc ├── generate.sh ├── typesystem_xml-qtscript.xml ├── typesystem_svg-common.xml ├── typesystem_svg.xml ├── generator.pri ├── metajava.cpp ├── metaqtscriptbuilder.cpp ├── metaqtscript.cpp ├── setupgenerator.h ├── generatorset.cpp ├── asttoxml.h ├── typesystem_network-qtscript.xml ├── docgenerator.h ├── prigenerator.h ├── shellimplgenerator.h ├── fileout.h ├── shellheadergenerator.h ├── generatorsetqtscript.h ├── generatorset.h ├── merge.xsl ├── typeparser.h ├── metajava.h ├── classgenerator.h ├── metaqtscript.h ├── reporthandler.cpp ├── customtypes.h ├── customtypes.cpp ├── metaqtscriptbuilder.h ├── reporthandler.h ├── typesystem_phonon-qtscript.xml ├── prigenerator.cpp └── shellgenerator.h ├── tools └── qsexec │ ├── src │ └── qsexec.pro │ └── README.TXT ├── qtbindings ├── qs_eval │ └── qs_eval.pro ├── qtscript_gui │ └── qtscript_gui.pro ├── qtscript_core │ ├── qtscript_core.pro │ └── qtscriptconcurrent.h ├── qtscript_svg │ └── qtscript_svg.pro ├── qtbindingsbase.pri ├── qtscript_sql │ └── qtscript_sql.pro ├── qtscript_xml │ └── qtscript_xml.pro ├── qtscript_opengl │ └── qtscript_opengl.pro ├── qtscript_phonon │ └── qtscript_phonon.pro ├── qtscript_uitools │ └── qtscript_uitools.pro ├── qtscript_webkit │ └── qtscript_webkit.pro ├── qtscript_network │ └── qtscript_network.pro ├── qtscript_xmlpatterns │ └── qtscript_xmlpatterns.pro └── qtbindings.pro ├── README ├── LGPL_EXCEPTION.txt └── doc └── classic.css /examples/images/brick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt-labs/qtscriptgenerator/HEAD/examples/images/brick.png -------------------------------------------------------------------------------- /examples/images/cheese.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt-labs/qtscriptgenerator/HEAD/examples/images/cheese.png -------------------------------------------------------------------------------- /examples/images/checker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt-labs/qtscriptgenerator/HEAD/examples/images/checker.png -------------------------------------------------------------------------------- /examples/images/qt-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt-labs/qtscriptgenerator/HEAD/examples/images/qt-logo.png -------------------------------------------------------------------------------- /examples/images/butterfly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt-labs/qtscriptgenerator/HEAD/examples/images/butterfly.png -------------------------------------------------------------------------------- /generator/typesystem_uitools.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /generator/typesystem_svg-qtscript.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /generator/build_core.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /generator/build_gui.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /generator/build_xml.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /generator/build_network.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /generator/build_xmlpatterns.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /tools/qsexec/src/qsexec.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | TARGET = qsexec 3 | 4 | DESTDIR = ../ 5 | 6 | QT = core script 7 | 8 | win32:CONFIG+=console 9 | mac:CONFIG-=app_bundle 10 | 11 | SOURCES += main.cpp 12 | -------------------------------------------------------------------------------- /qtbindings/qs_eval/qs_eval.pro: -------------------------------------------------------------------------------- 1 | QT = core gui script 2 | win32: CONFIG += console 3 | mac:CONFIG -= app_bundle 4 | SOURCES += main.cpp 5 | TOO_OLD_LIST=$$find(QT_VERSION, ^4\.[0-4]) 6 | count(TOO_OLD_LIST, 0): QT += scripttools 7 | -------------------------------------------------------------------------------- /qtbindings/qtscript_gui/qtscript_gui.pro: -------------------------------------------------------------------------------- 1 | TARGET = qtscript_gui 2 | include(../qtbindingsbase.pri) 3 | SOURCES += $$GENERATEDCPP/com_trolltech_qt_gui/plugin.cpp 4 | include($$GENERATEDCPP/com_trolltech_qt_gui/com_trolltech_qt_gui.pri) 5 | -------------------------------------------------------------------------------- /qtbindings/qtscript_core/qtscript_core.pro: -------------------------------------------------------------------------------- 1 | TARGET = qtscript_core 2 | include(../qtbindingsbase.pri) 3 | SOURCES += $$GENERATEDCPP/com_trolltech_qt_core/plugin.cpp 4 | include($$GENERATEDCPP/com_trolltech_qt_core/com_trolltech_qt_core.pri) 5 | -------------------------------------------------------------------------------- /qtbindings/qtscript_svg/qtscript_svg.pro: -------------------------------------------------------------------------------- 1 | TARGET = qtscript_svg 2 | include(../qtbindingsbase.pri) 3 | QT += svg 4 | SOURCES += $$GENERATEDCPP/com_trolltech_qt_svg/plugin.cpp 5 | include($$GENERATEDCPP/com_trolltech_qt_svg/com_trolltech_qt_svg.pri) 6 | -------------------------------------------------------------------------------- /qtbindings/qtbindingsbase.pri: -------------------------------------------------------------------------------- 1 | TEMPLATE = lib 2 | DEPENDPATH += . 3 | INCLUDEPATH += . 4 | DESTDIR = $$PWD/../plugins/script 5 | QT += script 6 | CONFIG += debug_and_release 7 | GENERATEDCPP = $$PWD/../generated_cpp 8 | TARGET=$$qtLibraryTarget($$TARGET) 9 | -------------------------------------------------------------------------------- /generator/build_opengl.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /generator/build_phonon.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /generator/build_uitools.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /qtbindings/qtscript_sql/qtscript_sql.pro: -------------------------------------------------------------------------------- 1 | TARGET = qtscript_sql 2 | include(../qtbindingsbase.pri) 3 | QT -= gui 4 | QT += sql 5 | SOURCES += $$GENERATEDCPP/com_trolltech_qt_sql/plugin.cpp 6 | include($$GENERATEDCPP/com_trolltech_qt_sql/com_trolltech_qt_sql.pri) 7 | -------------------------------------------------------------------------------- /qtbindings/qtscript_xml/qtscript_xml.pro: -------------------------------------------------------------------------------- 1 | TARGET = qtscript_xml 2 | include(../qtbindingsbase.pri) 3 | QT -= gui 4 | QT += xml 5 | SOURCES += $$GENERATEDCPP/com_trolltech_qt_xml/plugin.cpp 6 | include($$GENERATEDCPP/com_trolltech_qt_xml/com_trolltech_qt_xml.pri) 7 | -------------------------------------------------------------------------------- /generator/build_sql.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /qtbindings/qtscript_opengl/qtscript_opengl.pro: -------------------------------------------------------------------------------- 1 | TARGET = qtscript_opengl 2 | include(../qtbindingsbase.pri) 3 | QT += opengl 4 | SOURCES += $$GENERATEDCPP/com_trolltech_qt_opengl/plugin.cpp 5 | include($$GENERATEDCPP/com_trolltech_qt_opengl/com_trolltech_qt_opengl.pri) 6 | -------------------------------------------------------------------------------- /qtbindings/qtscript_phonon/qtscript_phonon.pro: -------------------------------------------------------------------------------- 1 | TARGET = qtscript_phonon 2 | include(../qtbindingsbase.pri) 3 | QT += phonon 4 | SOURCES += $$GENERATEDCPP/com_trolltech_qt_phonon/plugin.cpp 5 | include($$GENERATEDCPP/com_trolltech_qt_phonon/com_trolltech_qt_phonon.pri) 6 | -------------------------------------------------------------------------------- /qtbindings/qtscript_uitools/qtscript_uitools.pro: -------------------------------------------------------------------------------- 1 | TARGET = qtscript_uitools 2 | include(../qtbindingsbase.pri) 3 | CONFIG += uitools 4 | SOURCES += $$GENERATEDCPP/com_trolltech_qt_uitools/plugin.cpp 5 | include($$GENERATEDCPP/com_trolltech_qt_uitools/com_trolltech_qt_uitools.pri) 6 | -------------------------------------------------------------------------------- /qtbindings/qtscript_webkit/qtscript_webkit.pro: -------------------------------------------------------------------------------- 1 | TARGET = qtscript_webkit 2 | include(../qtbindingsbase.pri) 3 | QT += network webkit 4 | SOURCES += $$GENERATEDCPP/com_trolltech_qt_webkit/plugin.cpp 5 | include($$GENERATEDCPP/com_trolltech_qt_webkit/com_trolltech_qt_webkit.pri) 6 | -------------------------------------------------------------------------------- /qtbindings/qtscript_network/qtscript_network.pro: -------------------------------------------------------------------------------- 1 | TARGET = qtscript_network 2 | include(../qtbindingsbase.pri) 3 | QT -= gui 4 | QT += network 5 | SOURCES += $$GENERATEDCPP/com_trolltech_qt_network/plugin.cpp 6 | include($$GENERATEDCPP/com_trolltech_qt_network/com_trolltech_qt_network.pri) 7 | -------------------------------------------------------------------------------- /generator/build_svg.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /qtbindings/qtscript_xmlpatterns/qtscript_xmlpatterns.pro: -------------------------------------------------------------------------------- 1 | TARGET = qtscript_xmlpatterns 2 | include(../qtbindingsbase.pri) 3 | QT -= gui 4 | QT += xmlpatterns network 5 | SOURCES += $$GENERATEDCPP/com_trolltech_qt_xmlpatterns/plugin.cpp 6 | include($$GENERATEDCPP/com_trolltech_qt_xmlpatterns/com_trolltech_qt_xmlpatterns.pri) 7 | -------------------------------------------------------------------------------- /generator/build_webkit.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /qtbindings/qtbindings.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = qtscript_core \ 3 | qtscript_gui \ 4 | qtscript_network \ 5 | qtscript_opengl \ 6 | qtscript_sql \ 7 | qtscript_svg \ 8 | qtscript_xml \ 9 | qtscript_phonon \ 10 | qtscript_webkit \ 11 | qtscript_xmlpatterns \ 12 | qtscript_uitools \ 13 | qs_eval 14 | -------------------------------------------------------------------------------- /generator/parser/rxx.pro: -------------------------------------------------------------------------------- 1 | # File generated by kdevelop's qmake manager. 2 | # ------------------------------------------- 3 | # Subdir relative project main directory: . 4 | # Target is an application: r++0 5 | 6 | include(rxx.pri) 7 | SOURCES += main.cpp 8 | 9 | TEMPLATE = app 10 | QT = core 11 | TARGET = r++0 12 | CONFIG += debug_and_release 13 | -------------------------------------------------------------------------------- /generator/typesystem_opengl-qtscript.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /generator/typesystem_sql-qtscript.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /examples/WebKitPlugins.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |

My Nifty Plugin

5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /generator/typesystem_xmlpatterns-qtscript.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /generator/typesystem_webkit-qtscript.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /examples/TwoWayButton.qs: -------------------------------------------------------------------------------- 1 | var button = new QPushButton(); 2 | 3 | var off = new QState(); 4 | off.assignProperty(button, "text", "Off"); 5 | 6 | var on = new QState(); 7 | on.assignProperty(button, "text", "On"); 8 | 9 | off.addTransition(button, "clicked()", on); 10 | on.addTransition(button, "clicked()", off); 11 | 12 | var machine = new QStateMachine(); 13 | machine.addState(off); 14 | machine.addState(on); 15 | machine.initialState = off; 16 | 17 | machine.start(); 18 | button.resize(100, 100); 19 | button.show(); 20 | 21 | QCoreApplication.exec(); 22 | -------------------------------------------------------------------------------- /generator/parser/rpp/pp-qt-configuration: -------------------------------------------------------------------------------- 1 | #define __cplusplus 1 2 | 3 | #define __STDC__ 4 | 5 | // Qt 6 | #define QOBJECTDEFS_H 7 | 8 | // not yet supported 9 | #define Q_SLOTS slots 10 | #define Q_SIGNALS signals 11 | #define Q_FLAGS(a) 12 | #define Q_PRIVATE_SLOT(a, b) 13 | #define Q_DECLARE_INTERFACE(a,b) 14 | #define Q_INTERFACES(a) 15 | #define Q_GADGET 16 | #define Q_OVERRIDE(a) 17 | #define Q_OS_OS2 18 | #define Q_NO_USING_KEYWORD 19 | 20 | // There are symbols in Qt that exist in Debug but 21 | // not in release 22 | #define QT_NO_DEBUG 23 | 24 | #define QT_JAMBI_RUN 25 | -------------------------------------------------------------------------------- /generator/parser/rpp/rpp.pri: -------------------------------------------------------------------------------- 1 | SOURCES += \ 2 | $$RXXPATH/rpp/preprocessor.cpp 3 | 4 | HEADERS += \ 5 | $$RXXPATH/rpp/pp-cctype.h \ 6 | $$RXXPATH/rpp/pp-engine-bits.h \ 7 | $$RXXPATH/rpp/pp-engine.h \ 8 | $$RXXPATH/rpp/pp-environment.h \ 9 | $$RXXPATH/rpp/pp-fwd.h \ 10 | $$RXXPATH/rpp/pp-internal.h \ 11 | $$RXXPATH/rpp/pp-iterator.h \ 12 | $$RXXPATH/rpp/pp-macro-expander.h \ 13 | $$RXXPATH/rpp/pp-macro.h \ 14 | $$RXXPATH/rpp/pp-scanner.h \ 15 | $$RXXPATH/rpp/pp-string.h \ 16 | $$RXXPATH/rpp/pp-symbol.h \ 17 | $$RXXPATH/rpp/pp.h \ 18 | $$RXXPATH/rpp/preprocessor.h 19 | 20 | INCLUDEPATH += $$PWD $$RXXPATH/rpp 21 | -------------------------------------------------------------------------------- /generator/parser/r++.macros: -------------------------------------------------------------------------------- 1 | 2 | #define __attribute__(a...) 3 | #define __typeof__ __typeof 4 | 5 | #define __extension 6 | #define __extension__ 7 | 8 | #define __restrict 9 | #define __restrict__ 10 | 11 | #define __volatile volatile 12 | #define __volatile__ volatile 13 | 14 | #define __inline inline 15 | #define __inline__ inline 16 | 17 | #define __const const 18 | #define __const__ const 19 | 20 | #define __asm asm 21 | #define __asm__ asm 22 | 23 | #define __GNUC__ 3 24 | //#define __GNUC_MINOR__ 4 25 | 26 | #define __ROBC__ 0 27 | #define __ROBC_MINOR__ 1 28 | 29 | -------------------------------------------------------------------------------- /generator/generator.pro: -------------------------------------------------------------------------------- 1 | include(generator.pri) 2 | 3 | # Input 4 | HEADERS += \ 5 | generatorsetqtscript.h \ 6 | metaqtscriptbuilder.h \ 7 | metaqtscript.h \ 8 | classgenerator.h \ 9 | shellgenerator.h \ 10 | shellimplgenerator.h \ 11 | shellheadergenerator.h \ 12 | setupgenerator.h \ 13 | docgenerator.h 14 | 15 | SOURCES += \ 16 | generatorsetqtscript.cpp \ 17 | metaqtscriptbuilder.cpp \ 18 | metaqtscript.cpp \ 19 | classgenerator.cpp \ 20 | shellgenerator.cpp \ 21 | shellimplgenerator.cpp \ 22 | shellheadergenerator.cpp \ 23 | setupgenerator.cpp \ 24 | docgenerator.cpp 25 | 26 | CONFIG -= debug 27 | CONFIG += release 28 | -------------------------------------------------------------------------------- /generator/build_all.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /generator/generator.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | qtscript_masterinclude.h 4 | build_all.txt 5 | typesystem_core.xml 6 | typesystem_gui.xml 7 | typesystem_sql.xml 8 | typesystem_opengl.xml 9 | typesystem_svg.xml 10 | typesystem_network.xml 11 | typesystem_xml.xml 12 | typesystem_phonon.xml 13 | typesystem_webkit.xml 14 | typesystem_xmlpatterns.xml 15 | parser/rpp/pp-qt-configuration 16 | 17 | 18 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Qt Script Generator labs package, version 0.2 2 | 3 | 4 | The Qt Script Generator is a tool that generates Qt bindings for Qt Script. 5 | 6 | --- 7 | 8 | Instructions: 9 | 10 | 1) Build the generator: cd path/to/this/project/generator, qmake && make 11 | 12 | 2) Run the generator (without arguments) 13 | This will generate C++ files in path/to/this/project/generated_cpp 14 | and documentation in path/to/this/project/doc 15 | 16 | 3) Build the bindings plugins: cd path/to/this/project/qtbindings, qmake && make 17 | The plugins will be put under path/to/this/project/plugins 18 | 19 | 4) To use the plugins in your application, add the plugins path to the library paths 20 | (QCoreApplication::setLibraryPaths()), then call QScriptEngine::importExtension() 21 | (plugin keys are "qt.core", "qt.gui", etc). 22 | 23 | There is a simple script interpreter / launcher in path/to/this/project/qtbindings/qs_eval 24 | that imports all the bindings. You can use it to run the examples found in 25 | path/to/this/project/examples. E.g., with the examples directory being the working directory: 26 | 27 | ../qtbindings/qs_eval/qs_eval CollidingMice.js 28 | 29 | 30 | See the generated doc/index.html for more information. 31 | 32 | Have fun! 33 | -------------------------------------------------------------------------------- /LGPL_EXCEPTION.txt: -------------------------------------------------------------------------------- 1 | Nokia Qt LGPL Exception version 1.1 2 | 3 | As an additional permission to the GNU Lesser General Public License version 4 | 2.1, the object code form of a "work that uses the Library" may incorporate 5 | material from a header file that is part of the Library. You may distribute 6 | such object code under terms of your choice, provided that: 7 | (i) the header files of the Library have not been modified; and 8 | (ii) the incorporated material is limited to numerical parameters, data 9 | structure layouts, accessors, macros, inline functions and 10 | templates; and 11 | (iii) you comply with the terms of Section 6 of the GNU Lesser General 12 | Public License version 2.1. 13 | 14 | Moreover, you may apply this exception to a modified version of the Library, 15 | provided that such modification does not involve copying material from the 16 | Library into the modified Library's header files unless such material is 17 | limited to (i) numerical parameters; (ii) data structure layouts; 18 | (iii) accessors; and (iv) small macros, templates and inline functions of 19 | five lines or less in length. 20 | 21 | Furthermore, you are not required to apply this additional permission to a 22 | modified version of the Library. 23 | -------------------------------------------------------------------------------- /generator/generate.sh: -------------------------------------------------------------------------------- 1 | xsltproc --stringparam source $PWD/typesystem_core-qtscript.xml merge.xsl typesystem_core-common.xml > typesystem_core.xml 2 | 3 | xsltproc --stringparam source $PWD/typesystem_gui-qtscript.xml merge.xsl typesystem_gui-common.xml > typesystem_gui.xml 4 | 5 | xsltproc --stringparam source $PWD/typesystem_svg-qtscript.xml merge.xsl typesystem_svg-common.xml > typesystem_svg.xml 6 | 7 | xsltproc --stringparam source $PWD/typesystem_network-qtscript.xml merge.xsl typesystem_network-common.xml > typesystem_network.xml 8 | 9 | xsltproc --stringparam source $PWD/typesystem_opengl-qtscript.xml merge.xsl typesystem_opengl-common.xml > typesystem_opengl.xml 10 | 11 | xsltproc --stringparam source $PWD/typesystem_xml-qtscript.xml merge.xsl typesystem_xml-common.xml > typesystem_xml.xml 12 | 13 | xsltproc --stringparam source $PWD/typesystem_sql-qtscript.xml merge.xsl typesystem_sql-common.xml > typesystem_sql.xml 14 | 15 | xsltproc --stringparam source $PWD/typesystem_phonon-qtscript.xml merge.xsl typesystem_phonon-common.xml > typesystem_phonon.xml 16 | 17 | xsltproc --stringparam source $PWD/typesystem_webkit-qtscript.xml merge.xsl typesystem_webkit-common.xml > typesystem_webkit.xml 18 | 19 | xsltproc --stringparam source $PWD/typesystem_xmlpatterns-qtscript.xml merge.xsl typesystem_xmlpatterns-common.xml > typesystem_xmlpatterns.xml 20 | 21 | # ./generator qtscript_masterinclude.h typesystem_core.xml --diff 22 | -------------------------------------------------------------------------------- /generator/typesystem_xml-qtscript.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | QTextStream & %out% = *qscriptvalue_cast<QTextStream*>(%in%); 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | QTextStream & %out% = *qscriptvalue_cast<QTextStream*>(%in%); 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /generator/typesystem_svg-common.xml: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /tools/qsexec/README.TXT: -------------------------------------------------------------------------------- 1 | Runs QtScript code from the command line. 2 | 3 | USAGE 4 | ----- 5 | qsexec 6 | Runs QtScript in interactive mode, i.e. presents a prompt and executes 7 | commands as given. 8 | qsexec FILE [ARGS ...] 9 | Runs the script in FILE with the given command line arguments 10 | (see SCRIPT EXTENSIONS below). 11 | qsexec -f FILE1 [FILE2 ...] 12 | Runs all the scripts FILE1 FILE2 ... consecutively sharing the same engine. 13 | 14 | SCRIPT EXTENSIONS 15 | ----------------- 16 | The qsexec tool adds some useful functionality to the global object: 17 | 18 | - qs.system.os 19 | A string that specifies the operating system the script is run on 20 | (e.g. "linux", "windows", "mac"). 21 | - qs.script.args 22 | Array containing the strings given as [args ...] on the command line 23 | (single file mode only). 24 | - qs.script.absoluteFilePath 25 | File system path (including the file name) of the script that is processed 26 | at the moment as a string. 27 | - qs.script.absolutePath 28 | File system path (excluding the file name) of the script that is processed 29 | at the moment as a string. 30 | - qs.script.importExtension(name) 31 | Lets the script resolve and load the script extension with the given name. 32 | - qs.script.include(fileName) 33 | Dynamically loads and executes the script in the given file (relative to the 34 | currently processed file or absolute). Multiple includes of the same file 35 | result in only one execution of the file (only the first include triggers 36 | the execution). 37 | 38 | NOTE 39 | ---- 40 | The qsexec tool doesn't import any script extensions (like qt.core) itself. 41 | A script that needs a script extension has to load it via 42 | qs.script.importExtension("myextension"); 43 | -------------------------------------------------------------------------------- /examples/AnimatedBox.qs: -------------------------------------------------------------------------------- 1 | function createBox(parent) { 2 | var result = new QWidget(); 3 | result.styleSheet = "background: #00f060"; 4 | return result; 5 | } 6 | 7 | var scene = new QGraphicsScene(); 8 | scene.setSceneRect(0, 0, 400, 400); 9 | scene.itemIndexMethod = QGraphicsScene.NoIndex; 10 | 11 | box = scene.addWidget(createBox()); 12 | 13 | var machine = new QStateMachine(); 14 | 15 | var s1 = new QState(machine); 16 | s1.assignProperty(box, "geometry", new QRect(-50, 50, 100, 100)); 17 | s1.assignProperty(box, "opacity", 1.0); 18 | 19 | var s2 = new QState(machine); 20 | s2.assignProperty(box, "geometry", new QRect(250, 200, 200, 150)); 21 | s2.assignProperty(box, "opacity", 0.2); 22 | 23 | var timer = new QTimer(); 24 | timer.interval = 2000; 25 | timer.singleShot = false; 26 | timer.start(); 27 | 28 | var t1 = s1.addTransition(timer, "timeout()", s2); 29 | 30 | var geometryAnim = new QPropertyAnimation(box, "geometry"); 31 | geometryAnim.easingCurve = new QEasingCurve(QEasingCurve.InOutElastic); 32 | geometryAnim.duration = 1500; 33 | t1.addAnimation(geometryAnim); 34 | 35 | var opacityAnim = new QPropertyAnimation(box, "opacity"); 36 | opacityAnim.easingCurve = new QEasingCurve(QEasingCurve.InOutQuad); 37 | opacityAnim.duration = 1500; 38 | t1.addAnimation(opacityAnim); 39 | 40 | var t2 = s2.addTransition(timer, "timeout()", s1); 41 | t2.addAnimation(geometryAnim); 42 | t2.addAnimation(opacityAnim); 43 | 44 | machine.initialState = s1; 45 | machine.start(); 46 | 47 | var view = new QGraphicsView(scene); 48 | view.setRenderHint(QPainter.Antialiasing); 49 | view.backgroundBrush = new QBrush(new QColor(0, 48, 32)); 50 | view.viewportUpdateMode = QGraphicsView.FullViewportUpdate; 51 | 52 | view.resize(600, 410); 53 | view.show(); 54 | 55 | QCoreApplication.exec(); 56 | -------------------------------------------------------------------------------- /generator/parser/rxx.pri: -------------------------------------------------------------------------------- 1 | 2 | isEmpty(RXXPATH):RXXPATH = $$PWD 3 | 4 | INCLUDEPATH += $$RXXPATH 5 | 6 | DEFINES += RXX_ALLOCATOR_INIT_0 7 | 8 | HEADERS += $$RXXPATH/ast.h \ 9 | $$RXXPATH/lexer.h \ 10 | $$RXXPATH/list.h \ 11 | $$RXXPATH/parser.h \ 12 | $$RXXPATH/rxx_allocator.h \ 13 | $$RXXPATH/rpp-allocator.h \ 14 | $$RXXPATH/smallobject.h \ 15 | $$RXXPATH/tokens.h \ 16 | $$RXXPATH/symbol.h \ 17 | $$RXXPATH/control.h \ 18 | $$RXXPATH/visitor.h \ 19 | $$RXXPATH/default_visitor.h \ 20 | $$RXXPATH/dumptree.h \ 21 | $$RXXPATH/binder.h \ 22 | $$RXXPATH/codemodel.h \ 23 | $$RXXPATH/codemodel_pointer.h \ 24 | $$RXXPATH/codemodel_fwd.h \ 25 | $$RXXPATH/type_compiler.h \ 26 | $$RXXPATH/name_compiler.h \ 27 | $$RXXPATH/declarator_compiler.h \ 28 | $$RXXPATH/class_compiler.h \ 29 | $$RXXPATH/codemodel_finder.h \ 30 | $$RXXPATH/compiler_utils.h 31 | SOURCES += $$RXXPATH/ast.cpp \ 32 | $$RXXPATH/lexer.cpp \ 33 | $$RXXPATH/list.cpp \ 34 | $$RXXPATH/parser.cpp \ 35 | $$RXXPATH/smallobject.cpp \ 36 | $$RXXPATH/control.cpp \ 37 | $$RXXPATH/visitor.cpp \ 38 | $$RXXPATH/default_visitor.cpp \ 39 | $$RXXPATH/dumptree.cpp \ 40 | $$RXXPATH/tokens.cpp \ 41 | $$RXXPATH/binder.cpp \ 42 | $$RXXPATH/codemodel.cpp \ 43 | $$RXXPATH/type_compiler.cpp \ 44 | $$RXXPATH/name_compiler.cpp \ 45 | $$RXXPATH/declarator_compiler.cpp \ 46 | $$RXXPATH/class_compiler.cpp \ 47 | $$RXXPATH/codemodel_finder.cpp \ 48 | $$RXXPATH/compiler_utils.cpp 49 | -------------------------------------------------------------------------------- /generator/typesystem_svg.xml: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /doc/classic.css: -------------------------------------------------------------------------------- 1 | h3.fn,span.fn 2 | { 3 | margin-left: 1cm; 4 | text-indent: -1cm; 5 | } 6 | 7 | a:link 8 | { 9 | color: #004faf; 10 | text-decoration: none 11 | } 12 | 13 | a:visited 14 | { 15 | color: #672967; 16 | text-decoration: none 17 | } 18 | 19 | a.obsolete 20 | { 21 | color: #661100; 22 | text-decoration: none 23 | } 24 | 25 | a.compat 26 | { 27 | color: #661100; 28 | text-decoration: none 29 | } 30 | 31 | a.obsolete:visited 32 | { 33 | color: #995500; 34 | text-decoration: none 35 | } 36 | 37 | a.compat:visited 38 | { 39 | color: #995500; 40 | text-decoration: none 41 | } 42 | 43 | td.postheader 44 | { 45 | font-family: sans-serif 46 | } 47 | 48 | tr.address 49 | { 50 | font-family: sans-serif 51 | } 52 | 53 | body 54 | { 55 | background: #ffffff; 56 | color: black 57 | } 58 | 59 | table tr.odd { 60 | background: #f0f0f0; 61 | color: black; 62 | } 63 | 64 | table tr.even { 65 | background: #e4e4e4; 66 | color: black; 67 | } 68 | 69 | table.annotated th { 70 | padding: 3px; 71 | text-align: left 72 | } 73 | 74 | table.annotated td { 75 | padding: 3px; 76 | } 77 | 78 | table tr pre 79 | { 80 | padding-top: none; 81 | padding-bottom: none; 82 | padding-left: none; 83 | padding-right: none; 84 | border: none; 85 | background: none 86 | } 87 | 88 | tr.qt-style 89 | { 90 | background: #a2c511; 91 | color: black 92 | } 93 | 94 | body pre 95 | { 96 | padding: 0.2em; 97 | border: #e7e7e7 1px solid; 98 | background: #f1f1f1; 99 | color: black 100 | } 101 | 102 | span.preprocessor, span.preprocessor a 103 | { 104 | color: darkblue; 105 | } 106 | 107 | span.comment 108 | { 109 | color: darkred; 110 | font-style: italic 111 | } 112 | 113 | span.string,span.char 114 | { 115 | color: darkgreen; 116 | } 117 | 118 | .title 119 | { 120 | text-align: center 121 | } 122 | 123 | .subtitle 124 | { 125 | font-size: 0.8em 126 | } 127 | 128 | .small-subtitle 129 | { 130 | font-size: 0.65em 131 | } 132 | -------------------------------------------------------------------------------- /generator/parser/rpp/builtin-macros.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | -------------------------------------------------------------------------------- /generator/generator.pri: -------------------------------------------------------------------------------- 1 | isEmpty(GENERATORPATH):GENERATORPATH = $$PWD 2 | INCLUDEPATH += $$GENERATORPATH 3 | 4 | TEMPLATE = app 5 | TARGET += 6 | DEPENDPATH += $$GENERATORPATH tests parser 7 | mac:CONFIG -= app_bundle 8 | INCLUDEPATH += $$GENERATORPATH/. 9 | INCLUDEPATH += $$GENERATORPATH/../common 10 | 11 | unix:CONFIG += debug_and_release 12 | 13 | CONFIG += console 14 | RESOURCES += generator.qrc 15 | 16 | include($$GENERATORPATH/parser/rxx.pri) 17 | 18 | include($$GENERATORPATH/parser/rpp/rpp.pri) 19 | 20 | win32-msvc2005:{ 21 | QMAKE_CXXFLAGS += -wd4996 22 | QMAKE_CFLAGS += -wd4996 23 | } 24 | 25 | # Input 26 | HEADERS += \ 27 | $$GENERATORPATH/generator.h \ 28 | $$GENERATORPATH/main.h \ 29 | $$GENERATORPATH/reporthandler.h \ 30 | $$GENERATORPATH/typeparser.h \ 31 | $$GENERATORPATH/typesystem.h \ 32 | $$GENERATORPATH/asttoxml.h \ 33 | $$GENERATORPATH/fileout.h \ 34 | $$GENERATORPATH/generatorset.h \ 35 | $$GENERATORPATH/metajava.h \ 36 | $$GENERATORPATH/customtypes.h \ 37 | $$GENERATORPATH/abstractmetabuilder.h \ 38 | $$GENERATORPATH/abstractmetalang.h \ 39 | $$GENERATORPATH/prigenerator.h \ 40 | 41 | 42 | 43 | 44 | SOURCES += \ 45 | $$GENERATORPATH/generator.cpp \ 46 | $$GENERATORPATH/main.cpp \ 47 | $$GENERATORPATH/reporthandler.cpp \ 48 | $$GENERATORPATH/typeparser.cpp \ 49 | $$GENERATORPATH/typesystem.cpp \ 50 | $$GENERATORPATH/asttoxml.cpp \ 51 | $$GENERATORPATH/fileout.cpp \ 52 | $$GENERATORPATH/generatorset.cpp \ 53 | $$GENERATORPATH/metajava.cpp \ 54 | $$GENERATORPATH/customtypes.cpp \ 55 | $$GENERATORPATH/abstractmetabuilder.cpp \ 56 | $$GENERATORPATH/abstractmetalang.cpp \ 57 | $$GENERATORPATH/prigenerator.cpp \ 58 | 59 | 60 | 61 | QT = core xml 62 | 63 | win32-msvc.net { 64 | QMAKE_CXXFLAGS += /Zm500 65 | QMAKE_CXXFLAGS -= -Zm200 66 | QMAKE_CFLAGS -= -Zm200 67 | } 68 | 69 | mac { 70 | contains(QT_CONFIG, x86):contains(QT_CONFIG, ppc):CONFIG += x86 ppc 71 | CONFIG -= precompile_header 72 | } 73 | -------------------------------------------------------------------------------- /generator/metajava.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #include "metajava.h" 43 | -------------------------------------------------------------------------------- /generator/parser/rpp-allocator.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #include "rxx_allocator.h" 43 | -------------------------------------------------------------------------------- /generator/metaqtscriptbuilder.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #include "metaqtscriptbuilder.h" 43 | 44 | -------------------------------------------------------------------------------- /generator/parser/list.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | 43 | #include "list.h" 44 | 45 | // kate: space-indent on; indent-width 2; replace-tabs on; 46 | -------------------------------------------------------------------------------- /generator/parser/smallobject.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | 43 | #include "smallobject.h" 44 | 45 | // kate: space-indent on; indent-width 2; replace-tabs on; 46 | -------------------------------------------------------------------------------- /generator/metaqtscript.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #include "metaqtscript.h" 43 | 44 | 45 | bool MetaQtScriptClass::hasDefaultToStringFunction() const 46 | { 47 | return 0 < queryFunctionsByName("toString").size(); 48 | } 49 | -------------------------------------------------------------------------------- /generator/parser/rpp/pp-fwd.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef PP_FWD_H 43 | #define PP_FWD_H 44 | 45 | namespace rpp { 46 | 47 | template class pp_string; 48 | 49 | typedef pp_string pp_fast_string; 50 | 51 | #endif // PP_FWD_H 52 | 53 | } // namespace rpp 54 | 55 | // kate: space-indent on; indent-width 2; replace-tabs on; 56 | -------------------------------------------------------------------------------- /generator/parser/ast.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #include "ast.h" 43 | #include "lexer.h" 44 | 45 | // kate: space-indent on; indent-width 2; replace-tabs on; 46 | 47 | QString AST::toString(TokenStream *stream) const 48 | { 49 | const Token &tk = stream->token((int) start_token); 50 | const Token &end_tk = stream->token ((int) end_token); 51 | return QString::fromLatin1(tk.text + tk.position, end_tk.position - tk.position); 52 | } 53 | -------------------------------------------------------------------------------- /generator/parser/dumptree.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | 43 | #ifndef DUMPTREE_H 44 | #define DUMPTREE_H 45 | 46 | #include "default_visitor.h" 47 | 48 | class DumpTree: protected DefaultVisitor 49 | { 50 | public: 51 | DumpTree(); 52 | 53 | void dump(AST *node) { visit(node); } 54 | 55 | protected: 56 | virtual void visit(AST *node); 57 | }; 58 | 59 | #endif // DUMPTREE_H 60 | 61 | // kate: space-indent on; indent-width 2; replace-tabs on; 62 | -------------------------------------------------------------------------------- /generator/setupgenerator.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef SETUPGENERATOR_H 43 | #define SETUPGENERATOR_H 44 | 45 | #include "generator.h" 46 | #include "metaqtscript.h" 47 | 48 | class SetupGenerator : public Generator 49 | { 50 | Q_OBJECT 51 | 52 | public: 53 | virtual void generate(); 54 | 55 | void addClass(const AbstractMetaClass *cls); 56 | 57 | private: 58 | QHash > packHash; 59 | }; 60 | #endif // SETUPGENERATOR_H 61 | 62 | -------------------------------------------------------------------------------- /generator/parser/smallobject.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | 43 | #ifndef SMALLOBJECT_H 44 | #define SMALLOBJECT_H 45 | 46 | #include "rxx_allocator.h" 47 | #include 48 | 49 | class pool 50 | { 51 | rxx_allocator __alloc; 52 | 53 | public: 54 | inline void *allocate(std::size_t __size); 55 | }; 56 | 57 | inline void *pool::allocate(std::size_t __size) 58 | { 59 | return __alloc.allocate(__size); 60 | } 61 | 62 | #endif 63 | 64 | // kate: space-indent on; indent-width 2; replace-tabs on; 65 | -------------------------------------------------------------------------------- /generator/generatorset.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #include "generatorset.h" 43 | 44 | GeneratorSet::GeneratorSet() : 45 | outDir(".."), 46 | printStdout(false) 47 | {} 48 | 49 | bool GeneratorSet::readParameters(const QMap args) { 50 | if (args.contains("output-directory")) { 51 | outDir = args.value("output-directory"); 52 | } 53 | 54 | printStdout = args.contains("print-stdout"); 55 | 56 | return !(args.contains("help") || args.contains("h") || args.contains("?")); 57 | } 58 | -------------------------------------------------------------------------------- /generator/asttoxml.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | 43 | #ifndef ASTTOXML 44 | #define ASTTOXML 45 | 46 | #include "codemodel.h" 47 | 48 | #include 49 | #include 50 | 51 | void astToXML(const QString name); 52 | void writeOutNamespace(QXmlStreamWriter &s, NamespaceModelItem &item); 53 | void writeOutEnum(QXmlStreamWriter &s, EnumModelItem &item); 54 | void writeOutFunction(QXmlStreamWriter &s, FunctionModelItem &item); 55 | void writeOutClass(QXmlStreamWriter &s, ClassModelItem &item); 56 | 57 | 58 | #endif // ASTTOXML 59 | -------------------------------------------------------------------------------- /generator/typesystem_network-qtscript.xml: -------------------------------------------------------------------------------- 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 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /generator/docgenerator.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef DOCGENERATOR_H 43 | #define DOCGENERATOR_H 44 | 45 | #include "generator.h" 46 | 47 | class DocGenerator : public Generator 48 | { 49 | public: 50 | DocGenerator(); 51 | 52 | virtual bool shouldGenerate(const AbstractMetaClass *meta_class) const; 53 | virtual void generate(); 54 | virtual QString fileNameForClass(const AbstractMetaClass *meta_class) const; 55 | virtual QString subDirectoryForClass(const AbstractMetaClass *cls) const; 56 | virtual void write(QTextStream &s, const AbstractMetaClass *meta_class); 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /generator/parser/compiler_utils.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | 43 | #ifndef COMPILER_UTILS_H 44 | #define COMPILER_UTILS_H 45 | 46 | #include 47 | 48 | #include "codemodel.h" 49 | 50 | class QString; 51 | class QStringList; 52 | struct TypeSpecifierAST; 53 | struct DeclaratorAST; 54 | class TokenStream; 55 | class Binder; 56 | 57 | namespace CompilerUtils 58 | { 59 | 60 | TypeInfo typeDescription(TypeSpecifierAST *type_specifier, DeclaratorAST *declarator, Binder *binder); 61 | 62 | } // namespace CompilerUtils 63 | 64 | #endif // COMPILER_UTILS_H 65 | 66 | // kate: space-indent on; indent-width 2; replace-tabs on; 67 | -------------------------------------------------------------------------------- /generator/prigenerator.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef PRIGENERATOR_H 43 | #define PRIGENERATOR_H 44 | 45 | #include "generator.h" 46 | 47 | #include 48 | #include 49 | 50 | struct Pri 51 | { 52 | QStringList headers; 53 | QStringList sources; 54 | }; 55 | 56 | class PriGenerator : public Generator 57 | { 58 | Q_OBJECT 59 | 60 | public: 61 | virtual void generate(); 62 | 63 | void addHeader(const QString &folder, const QString &header); 64 | void addSource(const QString &folder, const QString &source); 65 | 66 | private: 67 | QHash priHash; 68 | 69 | }; 70 | #endif // PRIGENERATOR_H 71 | 72 | -------------------------------------------------------------------------------- /generator/shellimplgenerator.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef SHELLIMPLGENERATOR_H 43 | #define SHELLIMPLGENERATOR_H 44 | 45 | #include "shellgenerator.h" 46 | #include "metaqtscript.h" 47 | 48 | class ShellImplGenerator : public ShellGenerator 49 | { 50 | Q_OBJECT 51 | 52 | public: 53 | ShellImplGenerator(PriGenerator *pri) 54 | { 55 | priGenerator = pri; 56 | } 57 | 58 | virtual QString fileNameForClass(const AbstractMetaClass *cls) const; 59 | 60 | void write(QTextStream &s, const AbstractMetaClass *meta_class); 61 | void writeInjectedCode(QTextStream &s, const AbstractMetaClass *meta_class); 62 | 63 | }; 64 | 65 | #endif // SHELLIMPLGENERATOR_H 66 | -------------------------------------------------------------------------------- /generator/fileout.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef FILEOUT_H 43 | #define FILEOUT_H 44 | 45 | #include 46 | #include 47 | #include 48 | 49 | class FileOut : public QObject 50 | { 51 | Q_OBJECT 52 | 53 | private: 54 | QByteArray tmp; 55 | QString name; 56 | 57 | public: 58 | FileOut(QString name); 59 | ~FileOut() 60 | { 61 | if( !isDone ) 62 | done(); 63 | } 64 | 65 | bool done(); 66 | 67 | QTextStream stream; 68 | 69 | static bool dummy; 70 | static bool diff; 71 | static bool license; 72 | 73 | private: 74 | bool isDone; 75 | }; 76 | 77 | #endif // FILEOUT_H 78 | -------------------------------------------------------------------------------- /generator/parser/rpp/pp-cctype.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef PP_CCTYPE_H 43 | #define PP_CCTYPE_H 44 | 45 | #include 46 | 47 | namespace rpp { 48 | 49 | inline bool pp_isalpha (int __ch) 50 | { return std::isalpha ((unsigned char) __ch) != 0; } 51 | 52 | inline bool pp_isalnum (int __ch) 53 | { return std::isalnum ((unsigned char) __ch) != 0; } 54 | 55 | inline bool pp_isdigit (int __ch) 56 | { return std::isdigit ((unsigned char) __ch) != 0; } 57 | 58 | inline bool pp_isspace (int __ch) 59 | { return std::isspace ((unsigned char) __ch) != 0; } 60 | 61 | } // namespace rpp 62 | 63 | #endif // PP_CCTYPE_H 64 | 65 | // kate: space-indent on; indent-width 2; replace-tabs on; 66 | -------------------------------------------------------------------------------- /generator/shellheadergenerator.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef SHELL_HEADER_GENERATOR 43 | #define SHELL_HEADER_GENERATOR 44 | 45 | #include "shellgenerator.h" 46 | #include "metaqtscript.h" 47 | 48 | class ShellHeaderGenerator : public ShellGenerator 49 | { 50 | Q_OBJECT 51 | 52 | public: 53 | ShellHeaderGenerator(PriGenerator *pri) 54 | { 55 | priGenerator = pri; 56 | } 57 | 58 | virtual QString fileNameForClass(const AbstractMetaClass *cls) const; 59 | 60 | void write(QTextStream &s, const AbstractMetaClass *meta_class); 61 | void writeInjectedCode(QTextStream &s, const AbstractMetaClass *meta_class); 62 | }; 63 | 64 | #endif // SHELL_HEADER_GENERATOR 65 | -------------------------------------------------------------------------------- /generator/generatorsetqtscript.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef GENERATOR_SET_QT_SCRIPT_H 43 | #define GENERATOR_SET_QT_SCRIPT_H 44 | 45 | #include "generatorset.h" 46 | #include "metaqtscriptbuilder.h" 47 | 48 | class GeneratorSetQtScript : public GeneratorSet 49 | { 50 | Q_OBJECT 51 | 52 | public: 53 | GeneratorSetQtScript(); 54 | 55 | QString usage(); 56 | bool readParameters(const QMap args); 57 | 58 | void buildModel(const QString pp_file); 59 | void dumpObjectTree(); 60 | 61 | QString generate( ); 62 | 63 | private: 64 | MetaQtScriptBuilder builder; 65 | 66 | }; 67 | 68 | #endif // GENERATOR_SET_QT_SCRIPT_H 69 | -------------------------------------------------------------------------------- /generator/generatorset.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef GENERATOR_SET_H 43 | #define GENERATOR_SET_H 44 | 45 | #include 46 | #include 47 | #include 48 | #include 49 | 50 | class GeneratorSet : public QObject 51 | { 52 | Q_OBJECT 53 | 54 | public: 55 | GeneratorSet(); 56 | 57 | virtual QString usage() = 0; 58 | virtual bool readParameters(const QMap args) = 0; 59 | virtual void buildModel(const QString pp_file) = 0; 60 | virtual void dumpObjectTree() = 0; 61 | virtual QString generate() = 0; 62 | 63 | static GeneratorSet *getInstance(); 64 | QString outDir; 65 | bool printStdout; 66 | }; 67 | 68 | #endif // GENERATOR_SET_H 69 | -------------------------------------------------------------------------------- /generator/parser/include/stdarg.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | 43 | #ifndef __STDARG 44 | #define __STDARG 45 | 46 | #if !defined(_VA_LIST) && !defined(__VA_LIST_DEFINED) 47 | #define _VA_LIST 48 | #define _VA_LIST_DEFINED 49 | 50 | typedef char *__va_list; 51 | #endif 52 | static float __va_arg_tmp; 53 | typedef __va_list va_list; 54 | 55 | #define va_start(list, start) ((void)0) 56 | #define __va_arg(list, mode, n) ((void)0) 57 | #define _bigendian_va_arg(list, mode, n) ((void)0) 58 | #define _littleendian_va_arg(list, mode, n) ((void)0) 59 | #define va_end(list) ((void)0) 60 | #define va_arg(list, mode) ((void)0) 61 | 62 | typedef void *__gnuc_va_list; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /generator/merge.xsl: -------------------------------------------------------------------------------- 1 | 2 | 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 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /generator/typeparser.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef TYPEPARSER_H 43 | #define TYPEPARSER_H 44 | 45 | #include 46 | #include 47 | #include 48 | 49 | class TypeParser 50 | { 51 | public: 52 | struct Info 53 | { 54 | Info() : is_reference(false), is_constant(false), is_busted(false), indirections(0) { } 55 | QStringList qualified_name; 56 | QStringList arrays; 57 | QList template_instantiations; 58 | uint is_reference : 1; 59 | uint is_constant : 1; 60 | uint is_busted : 1; 61 | uint indirections : 5; 62 | 63 | QString toString() const; 64 | QString instantiationName() const; 65 | }; 66 | 67 | static Info parse(const QString &str); 68 | }; 69 | 70 | #endif // TYPEPARSER_H 71 | -------------------------------------------------------------------------------- /qtbindings/qtscript_core/qtscriptconcurrent.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef QTSCRIPTCONCURRENT_H 43 | #define QTSCRIPTCONCURRENT_H 44 | 45 | #ifndef QT_NO_CONCURRENT 46 | 47 | #include 48 | #include 49 | #include 50 | #include 51 | 52 | typedef QFutureWatcher QtScriptVoidFutureWatcher; 53 | typedef QFuture QtScriptVoidFuture; 54 | typedef QFutureSynchronizer QtScriptVoidFutureSynchronizer; 55 | typedef QFuture QtScriptFuture; 56 | typedef QFutureWatcher QtScriptFutureWatcher; 57 | typedef QFutureSynchronizer QtScriptFutureSynchronizer; 58 | typedef QFutureIterator QtScriptFutureIterator; 59 | 60 | #endif // QT_NO_CONCURRENT 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /generator/parser/rpp/pp-configuration: -------------------------------------------------------------------------------- 1 | #define __DBL_MIN_EXP__ (-1021) 2 | #define __FLT_MIN__ 1.17549435e-38F 3 | #define __CHAR_BIT__ 8 4 | #define __WCHAR_MAX__ 2147483647 5 | #define __DBL_DENORM_MIN__ 4.9406564584124654e-324 6 | #define __FLT_EVAL_METHOD__ 2 7 | #define __DBL_MIN_10_EXP__ (-307) 8 | #define __FINITE_MATH_ONLY__ 0 9 | #define __GNUC_PATCHLEVEL__ 2 10 | #define __SHRT_MAX__ 32767 11 | #define __LDBL_MAX__ 1.18973149535723176502e+4932L 12 | #define __UINTMAX_TYPE__ long long unsigned int 13 | #define __linux 1 14 | #define __unix 1 15 | #define __LDBL_MAX_EXP__ 16384 16 | #define __linux__ 1 17 | #define __SCHAR_MAX__ 127 18 | #define __USER_LABEL_PREFIX__ 19 | #define __STDC_HOSTED__ 1 20 | #define __LDBL_HAS_INFINITY__ 1 21 | #define __DBL_DIG__ 15 22 | #define __FLT_EPSILON__ 1.19209290e-7F 23 | #define __GXX_WEAK__ 1 24 | #define __LDBL_MIN__ 3.36210314311209350626e-4932L 25 | #define __unix__ 1 26 | #define __DECIMAL_DIG__ 21 27 | #define __gnu_linux__ 1 28 | #define __LDBL_HAS_QUIET_NAN__ 1 29 | #define __GNUC__ 4 30 | #define __DBL_MAX__ 1.7976931348623157e+308 31 | #define __DBL_HAS_INFINITY__ 1 32 | #define __cplusplus 1 33 | #define __DEPRECATED 1 34 | #define __DBL_MAX_EXP__ 1024 35 | #define __GNUG__ 4 36 | #define __LONG_LONG_MAX__ 9223372036854775807LL 37 | #define __GXX_ABI_VERSION 1002 38 | #define __FLT_MIN_EXP__ (-125) 39 | #define __DBL_MIN__ 2.2250738585072014e-308 40 | #define __FLT_MIN_10_EXP__ (-37) 41 | #define __DBL_HAS_QUIET_NAN__ 1 42 | #define __REGISTER_PREFIX__ 43 | #define __NO_INLINE__ 1 44 | #define __i386 1 45 | #define __FLT_MANT_DIG__ 24 46 | #define __VERSION__ "4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9)" 47 | #define i386 1 48 | #define __i486__ 1 49 | #define unix 1 50 | #define __i386__ 1 51 | #define __SIZE_TYPE__ unsigned int 52 | #define __ELF__ 1 53 | #define __FLT_RADIX__ 2 54 | #define __LDBL_EPSILON__ 1.08420217248550443401e-19L 55 | #define __FLT_HAS_QUIET_NAN__ 1 56 | #define __FLT_MAX_10_EXP__ 38 57 | #define __LONG_MAX__ 2147483647L 58 | #define __FLT_HAS_INFINITY__ 1 59 | #define linux 1 60 | #define __EXCEPTIONS 1 61 | #define __LDBL_MANT_DIG__ 64 62 | #define __WCHAR_TYPE__ int 63 | #define __FLT_DIG__ 6 64 | #define __INT_MAX__ 2147483647 65 | #define __i486 1 66 | #define __FLT_MAX_EXP__ 128 67 | #define __DBL_MANT_DIG__ 53 68 | #define __WINT_TYPE__ unsigned int 69 | #define __LDBL_MIN_EXP__ (-16381) 70 | #define __LDBL_MAX_10_EXP__ 4932 71 | #define __DBL_EPSILON__ 2.2204460492503131e-16 72 | #define __tune_i486__ 1 73 | #define __INTMAX_MAX__ 9223372036854775807LL 74 | #define __FLT_DENORM_MIN__ 1.40129846e-45F 75 | #define __FLT_MAX__ 3.40282347e+38F 76 | #define __INTMAX_TYPE__ long long int 77 | #define __GNUC_MINOR__ 0 78 | #define __DBL_MAX_10_EXP__ 308 79 | #define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L 80 | #define __PTRDIFF_TYPE__ int 81 | #define __LDBL_MIN_10_EXP__ (-4931) 82 | #define __LDBL_DIG__ 18 83 | #define _GNU_SOURCE 1 84 | 85 | 86 | #define __STDC__ 87 | -------------------------------------------------------------------------------- /generator/metajava.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef METAJAVA_H 43 | #define METAJAVA_H 44 | 45 | #include "abstractmetalang.h" 46 | 47 | class MetaJavaClass; 48 | class MetaJavaField; 49 | class MetaJavaFunction; 50 | class MetaJavaType; 51 | class MetaJavaVariable; 52 | class MetaJavaArgument; 53 | class MetaJavaEnumValue; 54 | class MetaJavaEnum; 55 | 56 | 57 | 58 | class MetaJavaType : public AbstractMetaType 59 | {}; 60 | 61 | class MetaJavaArgument : public AbstractMetaArgument 62 | {}; 63 | 64 | class MetaJavaField : public AbstractMetaField 65 | {}; 66 | 67 | class MetaJavaFunction : public AbstractMetaFunction 68 | {}; 69 | 70 | class MetaJavaEnumValue : public AbstractMetaEnumValue 71 | {}; 72 | 73 | class MetaJavaEnum : public AbstractMetaEnum 74 | {}; 75 | 76 | class MetaJavaClass : public AbstractMetaClass 77 | {}; 78 | 79 | #endif // METAJAVA_H 80 | -------------------------------------------------------------------------------- /examples/DigitalClock.js: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | function tr(s) { return s; } 43 | 44 | 45 | function DigitalClock(parent) 46 | { 47 | QLCDNumber.call(this, parent); 48 | 49 | this.segmentStyle = QLCDNumber.Filled; 50 | 51 | var timer = new QTimer(this); 52 | timer.timeout.connect(this, this.showTime); 53 | timer.start(1000); 54 | 55 | this.showTime(); 56 | 57 | this.windowTitle = tr("Digital Clock"); 58 | this.resize(150, 60); 59 | } 60 | 61 | DigitalClock.prototype = new QLCDNumber(); 62 | 63 | DigitalClock.prototype.showTime = function() 64 | { 65 | var time = QTime.currentTime(); 66 | var format = "hh"; 67 | format += ((time.second() % 2) == 0) ? " " : ":"; 68 | format += "mm"; 69 | var text = time.toString(format); 70 | this.display(text); 71 | } 72 | 73 | 74 | var clock = new DigitalClock(5); // ### fixme 75 | clock.show(); 76 | QCoreApplication.exec(); 77 | -------------------------------------------------------------------------------- /generator/classgenerator.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef CLASS_GENERATOR 43 | #define CLASS_GENERATOR 44 | 45 | #include "generator.h" 46 | #include "metaqtscript.h" 47 | #include "prigenerator.h" 48 | #include "setupgenerator.h" 49 | 50 | class ClassGenerator : public Generator 51 | { 52 | Q_OBJECT 53 | 54 | public: 55 | ClassGenerator(PriGenerator *pri, SetupGenerator *setup); 56 | 57 | virtual QString fileNameForClass(const AbstractMetaClass *meta_class) const; 58 | virtual QString subDirectoryForClass(const AbstractMetaClass *cls) const 59 | { 60 | return "generated_cpp/" + cls->package().replace(".", "_") + "/"; 61 | } 62 | virtual bool shouldGenerate(const AbstractMetaClass *meta_class) const; 63 | void write(QTextStream &s, const AbstractMetaClass *meta_class); 64 | 65 | private: 66 | PriGenerator *priGenerator; 67 | SetupGenerator *setupGenerator; 68 | QStringList describeFunctons; 69 | }; 70 | 71 | #endif // CLASS_GENERATOR 72 | -------------------------------------------------------------------------------- /generator/parser/compiler_utils.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | 43 | #include "compiler_utils.h" 44 | #include "type_compiler.h" 45 | #include "name_compiler.h" 46 | #include "declarator_compiler.h" 47 | #include "ast.h" 48 | #include "binder.h" 49 | 50 | TypeInfo CompilerUtils::typeDescription(TypeSpecifierAST *type_specifier, DeclaratorAST *declarator, Binder *binder) 51 | { 52 | TypeCompiler type_cc (binder); 53 | DeclaratorCompiler decl_cc (binder); 54 | 55 | type_cc.run (type_specifier); 56 | decl_cc.run (declarator); 57 | 58 | TypeInfo typeInfo; 59 | typeInfo.setQualifiedName (type_cc.qualifiedName ()); 60 | typeInfo.setConstant (type_cc.isConstant ()); 61 | typeInfo.setVolatile (type_cc.isVolatile ()); 62 | typeInfo.setReference (decl_cc.isReference ()); 63 | typeInfo.setIndirections (decl_cc.indirection ()); 64 | typeInfo.setArrayElements (decl_cc.arrayElements ()); 65 | 66 | return typeInfo; 67 | } 68 | 69 | // kate: space-indent on; indent-width 2; replace-tabs on; 70 | -------------------------------------------------------------------------------- /generator/metaqtscript.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef METAQTSCRIPT_H 43 | #define METAQTSCRIPT_H 44 | 45 | #include "abstractmetalang.h" 46 | 47 | class MetaQtScriptClass; 48 | class MetaQtScriptField; 49 | class MetaQtScriptFunction; 50 | class MetaQtScriptType; 51 | class MetaQtScriptVariable; 52 | class MetaQtScriptArgument; 53 | class MetaQtScriptEnumValue; 54 | class MetaQtScriptEnum; 55 | 56 | 57 | 58 | class MetaQtScriptType : public AbstractMetaType 59 | {}; 60 | 61 | class MetaQtScriptArgument : public AbstractMetaArgument 62 | {}; 63 | 64 | class MetaQtScriptField : public AbstractMetaField 65 | {}; 66 | 67 | class MetaQtScriptFunction : public AbstractMetaFunction 68 | {}; 69 | 70 | class MetaQtScriptEnumValue : public AbstractMetaEnumValue 71 | {}; 72 | 73 | class MetaQtScriptEnum : public AbstractMetaEnum 74 | {}; 75 | 76 | class MetaQtScriptClass : public AbstractMetaClass 77 | { 78 | virtual bool hasDefaultToStringFunction() const; 79 | }; 80 | 81 | #endif // METAQTSCRIPT_H 82 | -------------------------------------------------------------------------------- /generator/parser/class_compiler.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | 43 | #include "class_compiler.h" 44 | #include "lexer.h" 45 | #include "binder.h" 46 | 47 | ClassCompiler::ClassCompiler(Binder *binder) 48 | : _M_binder (binder), 49 | _M_token_stream(binder->tokenStream ()), 50 | name_cc(_M_binder), 51 | type_cc(_M_binder) 52 | { 53 | } 54 | 55 | ClassCompiler::~ClassCompiler() 56 | { 57 | } 58 | 59 | void ClassCompiler::run(ClassSpecifierAST *node) 60 | { 61 | name_cc.run(node->name); 62 | _M_name = name_cc.name(); 63 | _M_base_classes.clear(); 64 | 65 | visit(node); 66 | } 67 | 68 | void ClassCompiler::visitClassSpecifier(ClassSpecifierAST *node) 69 | { 70 | visit(node->base_clause); 71 | } 72 | 73 | void ClassCompiler::visitBaseSpecifier(BaseSpecifierAST *node) 74 | { 75 | name_cc.run(node->name); 76 | QString name = name_cc.name(); 77 | 78 | if (! name.isEmpty()) 79 | _M_base_classes.append(name); 80 | } 81 | 82 | 83 | // kate: space-indent on; indent-width 2; replace-tabs on; 84 | -------------------------------------------------------------------------------- /generator/parser/rpp/pp-macro.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef PP_MACRO_H 43 | #define PP_MACRO_H 44 | 45 | namespace rpp { 46 | 47 | struct pp_macro 48 | { 49 | #if defined (PP_WITH_MACRO_POSITION) 50 | pp_fast_string const *file; 51 | #endif 52 | pp_fast_string const *name; 53 | pp_fast_string const *definition; 54 | std::vector formals; 55 | 56 | union 57 | { 58 | int unsigned state; 59 | 60 | struct 61 | { 62 | int unsigned hidden: 1; 63 | int unsigned function_like: 1; 64 | int unsigned variadics: 1; 65 | }; 66 | }; 67 | 68 | int lines; 69 | pp_macro *next; 70 | std::size_t hash_code; 71 | 72 | inline pp_macro(): 73 | #if defined (PP_WITH_MACRO_POSITION) 74 | file (0), 75 | #endif 76 | name (0), 77 | definition (0), 78 | state (0), 79 | lines (0), 80 | next (0), 81 | hash_code (0) 82 | {} 83 | }; 84 | 85 | } // namespace rpp 86 | 87 | #endif // PP_MACRO_H 88 | 89 | // kate: space-indent on; indent-width 2; replace-tabs on; 90 | -------------------------------------------------------------------------------- /generator/parser/rpp/preprocessor.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef PREPROCESSOR_H 43 | #define PREPROCESSOR_H 44 | 45 | #include 46 | #include 47 | #include 48 | 49 | class QByteArray; 50 | class PreprocessorPrivate; 51 | 52 | class Preprocessor 53 | { 54 | public: 55 | Preprocessor(); 56 | ~Preprocessor(); 57 | 58 | void processFile(const QString &fileName); 59 | void processString(const QByteArray &str); 60 | 61 | void addIncludePaths(const QStringList &includePaths); 62 | 63 | QByteArray result() const; 64 | 65 | QStringList macroNames() const; 66 | 67 | struct MacroItem 68 | { 69 | QString name; 70 | QStringList parameters; 71 | QString definition; 72 | bool isFunctionLike; 73 | #ifdef PP_WITH_MACRO_POSITION 74 | QString fileName; 75 | #endif 76 | }; 77 | QList macros() const; 78 | 79 | private: 80 | Q_DISABLE_COPY(Preprocessor) 81 | PreprocessorPrivate *d; 82 | }; 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /generator/parser/name_compiler.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | 43 | #ifndef NAME_COMPILER_H 44 | #define NAME_COMPILER_H 45 | 46 | #include "default_visitor.h" 47 | #include 48 | 49 | class TokenStream; 50 | class Binder; 51 | 52 | class NameCompiler: protected DefaultVisitor 53 | { 54 | public: 55 | NameCompiler(Binder *binder); 56 | 57 | void run(NameAST *node) { internal_run(node); } 58 | void run(UnqualifiedNameAST *node) { internal_run(node); } 59 | 60 | QString name() const { return _M_name.join("::"); } 61 | QStringList qualifiedName() const { return _M_name; } 62 | 63 | protected: 64 | virtual void visitUnqualifiedName(UnqualifiedNameAST *node); 65 | virtual void visitTemplateArgument(TemplateArgumentAST *node); 66 | 67 | QString internal_run(AST *node); 68 | QString decode_operator(std::size_t index) const; 69 | 70 | private: 71 | Binder *_M_binder; 72 | TokenStream *_M_token_stream; 73 | QStringList _M_name; 74 | }; 75 | 76 | #endif // NAME_COMPILER_H 77 | 78 | // kate: space-indent on; indent-width 2; replace-tabs on; 79 | -------------------------------------------------------------------------------- /generator/parser/class_compiler.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | 43 | #ifndef CLASS_COMPILER_H 44 | #define CLASS_COMPILER_H 45 | 46 | #include 47 | #include 48 | 49 | #include "default_visitor.h" 50 | #include "name_compiler.h" 51 | #include "type_compiler.h" 52 | 53 | class TokenStream; 54 | class Binder; 55 | 56 | class ClassCompiler: protected DefaultVisitor 57 | { 58 | public: 59 | ClassCompiler(Binder *binder); 60 | virtual ~ClassCompiler(); 61 | 62 | inline QString name() const { return _M_name; } 63 | inline QStringList baseClasses() const { return _M_base_classes; } 64 | 65 | void run(ClassSpecifierAST *node); 66 | 67 | protected: 68 | virtual void visitClassSpecifier(ClassSpecifierAST *node); 69 | virtual void visitBaseSpecifier(BaseSpecifierAST *node); 70 | 71 | private: 72 | Binder *_M_binder; 73 | TokenStream *_M_token_stream; 74 | QString _M_name; 75 | QStringList _M_base_classes; 76 | NameCompiler name_cc; 77 | TypeCompiler type_cc; 78 | }; 79 | 80 | #endif // CLASS_COMPILER_H 81 | 82 | // kate: space-indent on; indent-width 2; replace-tabs on; 83 | -------------------------------------------------------------------------------- /generator/reporthandler.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #include "reporthandler.h" 43 | #include "typesystem.h" 44 | 45 | int ReportHandler::m_warning_count = 0; 46 | int ReportHandler::m_suppressed_count = 0; 47 | QString ReportHandler::m_context; 48 | ReportHandler::DebugLevel ReportHandler::m_debug_level = NoDebug; 49 | QSet ReportHandler::m_reported_warnings; 50 | 51 | 52 | void ReportHandler::warning(const QString &text) 53 | { 54 | QString warningText = QString("WARNING(%1) :: %2").arg(m_context).arg(text); 55 | 56 | TypeDatabase *db = TypeDatabase::instance(); 57 | if (db && db->isSuppressedWarning(warningText)) { 58 | ++m_suppressed_count; 59 | } else if (!m_reported_warnings.contains(warningText)) { 60 | qDebug(qPrintable(warningText)); 61 | ++m_warning_count; 62 | 63 | m_reported_warnings.insert(warningText); 64 | } 65 | } 66 | 67 | void ReportHandler::debug(DebugLevel level, const QString &text) 68 | { 69 | if (m_debug_level == NoDebug) 70 | return; 71 | 72 | if (level <= m_debug_level) 73 | qDebug(" - DEBUG(%s) :: %s", qPrintable(m_context), qPrintable(text)); 74 | } 75 | -------------------------------------------------------------------------------- /generator/customtypes.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef CUSTOMTYPES_H 43 | #define CUSTOMTYPES_H 44 | 45 | #include "typesystem.h" 46 | 47 | 48 | class QModelIndexTypeEntry : public CustomTypeEntry 49 | { 50 | public: 51 | QModelIndexTypeEntry() : CustomTypeEntry("QModelIndex") 52 | { 53 | setCodeGeneration(GenerateNothing); 54 | } 55 | 56 | virtual QString javaPackage() const { return "com.trolltech.qt.core"; } 57 | 58 | virtual bool isValue() const { return true; } 59 | 60 | virtual void generateCppJavaToQt(QTextStream &s, 61 | const AbstractMetaType *java_type, 62 | const QString &env_name, 63 | const QString &qt_name, 64 | const QString &java_name) const; 65 | 66 | virtual void generateCppQtToJava(QTextStream &s, 67 | const AbstractMetaType *java_type, 68 | const QString &env_name, 69 | const QString &qt_name, 70 | const QString &java_name) const; 71 | 72 | }; 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /generator/parser/codemodel_finder.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | 43 | #ifndef CODEMODEL_FINDER_H 44 | #define CODEMODEL_FINDER_H 45 | 46 | #include "default_visitor.h" 47 | #include "codemodel_fwd.h" 48 | #include "name_compiler.h" 49 | 50 | class TokenStream; 51 | class Binder; 52 | 53 | class CodeModelFinder: protected DefaultVisitor 54 | { 55 | enum ResolvePolicy 56 | { 57 | ResolveScope, 58 | ResolveItem 59 | }; 60 | 61 | public: 62 | CodeModelFinder(CodeModel *model, Binder *binder); 63 | virtual ~CodeModelFinder(); 64 | 65 | ScopeModelItem resolveScope(NameAST *name, ScopeModelItem scope); 66 | 67 | inline CodeModel *model() const { return _M_model; } 68 | 69 | protected: 70 | virtual void visitName(NameAST *node); 71 | virtual void visitUnqualifiedName(UnqualifiedNameAST *node); 72 | 73 | ScopeModelItem changeCurrentScope(ScopeModelItem scope); 74 | 75 | private: 76 | CodeModel *_M_model; 77 | Binder *_M_binder; 78 | TokenStream *_M_token_stream; 79 | NameCompiler name_cc; 80 | 81 | ScopeModelItem _M_current_scope; 82 | ResolvePolicy _M_resolve_policy; 83 | }; 84 | 85 | #endif // CODEMODEL_FINDER_H 86 | 87 | // kate: space-indent on; indent-width 2; replace-tabs on; 88 | -------------------------------------------------------------------------------- /generator/customtypes.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #include "customtypes.h" 43 | 44 | #include "metajava.h" 45 | 46 | #include 47 | #include 48 | 49 | 50 | void QModelIndexTypeEntry::generateCppJavaToQt(QTextStream &s, 51 | const AbstractMetaType *, 52 | const QString &env_name, 53 | const QString &qt_name, 54 | const QString &java_name) const 55 | { 56 | s << "QModelIndex " << qt_name << " = qtjambi_to_QModelIndex(" << env_name << ", " 57 | << java_name << ")"; 58 | } 59 | 60 | 61 | void QModelIndexTypeEntry::generateCppQtToJava(QTextStream &s, 62 | const AbstractMetaType *, 63 | const QString &env_name, 64 | const QString &qt_name, 65 | const QString &java_name) const 66 | { 67 | s << "jobject " << java_name << " = qtjambi_from_QModelIndex(" << env_name << ", " 68 | << qt_name << ")"; 69 | } 70 | -------------------------------------------------------------------------------- /generator/parser/type_compiler.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | 43 | #ifndef TYPE_COMPILER_H 44 | #define TYPE_COMPILER_H 45 | 46 | #include "default_visitor.h" 47 | 48 | #include 49 | #include 50 | #include 51 | 52 | class TokenStream; 53 | class Binder; 54 | 55 | class TypeCompiler: protected DefaultVisitor 56 | { 57 | public: 58 | TypeCompiler(Binder *binder); 59 | 60 | inline QStringList qualifiedName() const { return _M_type; } 61 | inline QList cv() const { return _M_cv; } 62 | 63 | bool isConstant() const; 64 | bool isVolatile() const; 65 | 66 | QStringList cvString() const; 67 | 68 | void run(TypeSpecifierAST *node); 69 | 70 | protected: 71 | virtual void visitClassSpecifier(ClassSpecifierAST *node); 72 | virtual void visitEnumSpecifier(EnumSpecifierAST *node); 73 | virtual void visitElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST *node); 74 | virtual void visitSimpleTypeSpecifier(SimpleTypeSpecifierAST *node); 75 | 76 | virtual void visitName(NameAST *node); 77 | 78 | private: 79 | Binder *_M_binder; 80 | TokenStream *_M_token_stream; 81 | QStringList _M_type; 82 | QList _M_cv; 83 | }; 84 | 85 | #endif // TYPE_COMPILER_H 86 | 87 | // kate: space-indent on; indent-width 2; replace-tabs on; 88 | -------------------------------------------------------------------------------- /generator/metaqtscriptbuilder.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef METAQTSCRIPTBUILDER_H 43 | #define METAQTSCRIPTBUILDER_H 44 | 45 | #include "abstractmetabuilder.h" 46 | #include "metaqtscript.h" 47 | 48 | class MetaQtScriptBuilder : public AbstractMetaBuilder 49 | { 50 | 51 | protected: 52 | virtual MetaQtScriptClass *createMetaClass() 53 | { 54 | return new MetaQtScriptClass(); 55 | }; 56 | 57 | virtual MetaQtScriptEnum *createMetaEnum() 58 | { 59 | return new MetaQtScriptEnum(); 60 | }; 61 | 62 | virtual MetaQtScriptEnumValue *createMetaEnumValue() 63 | { 64 | return new MetaQtScriptEnumValue(); 65 | }; 66 | 67 | virtual MetaQtScriptField *createMetaField() 68 | { 69 | return new MetaQtScriptField(); 70 | }; 71 | 72 | virtual MetaQtScriptFunction *createMetaFunction() 73 | { 74 | return new MetaQtScriptFunction(); 75 | }; 76 | 77 | virtual MetaQtScriptArgument *createMetaArgument() 78 | { 79 | return new MetaQtScriptArgument(); 80 | }; 81 | 82 | virtual MetaQtScriptType *createMetaType() 83 | { 84 | return new MetaQtScriptType(); 85 | }; 86 | 87 | }; 88 | 89 | #endif // METAQTSCRIPTBUILDER_H 90 | -------------------------------------------------------------------------------- /generator/reporthandler.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef REPORTHANDLER_H 43 | #define REPORTHANDLER_H 44 | 45 | #include 46 | #include 47 | 48 | class ReportHandler 49 | { 50 | public: 51 | enum DebugLevel { NoDebug, SparseDebug, MediumDebug, FullDebug }; 52 | 53 | static void setContext(const QString &context) { m_context = context; } 54 | 55 | static DebugLevel debugLevel() { return m_debug_level; } 56 | static void setDebugLevel(DebugLevel level) { m_debug_level = level; } 57 | 58 | static int warningCount() { return m_warning_count; } 59 | 60 | static int suppressedCount() { return m_suppressed_count; } 61 | 62 | static void warning(const QString &str); 63 | 64 | static void debugSparse(const QString &str) { 65 | debug(SparseDebug, str); 66 | } 67 | static void debugMedium(const QString &str) { 68 | debug(MediumDebug, str); 69 | } 70 | static void debugFull(const QString &str) { 71 | debug(FullDebug, str); 72 | } 73 | static void debug(DebugLevel level, const QString &str); 74 | 75 | private: 76 | static int m_warning_count; 77 | static int m_suppressed_count; 78 | static DebugLevel m_debug_level; 79 | static QString m_context; 80 | static QSet m_reported_warnings; 81 | }; 82 | 83 | #endif // REPORTHANDLER_H 84 | -------------------------------------------------------------------------------- /generator/typesystem_phonon-qtscript.xml: -------------------------------------------------------------------------------- 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 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /generator/prigenerator.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #include "prigenerator.h" 43 | #include "reporthandler.h" 44 | #include "fileout.h" 45 | 46 | void PriGenerator::addHeader(const QString &folder, const QString &header) 47 | { 48 | priHash[folder].headers << header; 49 | } 50 | 51 | void PriGenerator::addSource(const QString &folder, const QString &source) 52 | { 53 | priHash[folder].sources << source; 54 | } 55 | 56 | void PriGenerator::generate() 57 | { 58 | QHashIterator pri(priHash); 59 | while (pri.hasNext()) { 60 | pri.next(); 61 | QStringList list = pri.value().headers; 62 | if (list.isEmpty()) 63 | continue; 64 | 65 | QString folder = pri.key(); 66 | FileOut file(m_out_dir + "/generated_cpp/" + folder + "/" + folder + ".pri"); 67 | file.stream << "HEADERS += \\\n"; 68 | qSort(list.begin(), list.end()); 69 | foreach (const QString &entry, list) { 70 | file.stream << " $$PWD/" << entry << " \\\n"; 71 | } 72 | 73 | file.stream << "\n"; 74 | file.stream << "SOURCES += \\\n"; 75 | list = pri.value().sources; 76 | qSort(list.begin(), list.end()); 77 | foreach (const QString &entry, list) { 78 | file.stream << " $$PWD/" << entry << " \\\n"; 79 | } 80 | file.stream << " $$PWD/" << folder << "_init.cpp\n"; 81 | 82 | if (file.done()) 83 | ++m_num_generated_written; 84 | ++m_num_generated; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /generator/parser/rpp/pp-iterator.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef PP_ITERATOR_H 43 | #define PP_ITERATOR_H 44 | 45 | #include 46 | 47 | namespace rpp { 48 | 49 | class pp_null_output_iterator 50 | : public std::iterator 51 | { 52 | public: 53 | pp_null_output_iterator() {} 54 | 55 | template 56 | pp_null_output_iterator &operator=(_Tp const &) 57 | { return *this; } 58 | 59 | inline pp_null_output_iterator &operator * () { return *this; } 60 | inline pp_null_output_iterator &operator ++ () { return *this; } 61 | inline pp_null_output_iterator operator ++ (int) { return *this; } 62 | }; 63 | 64 | template 65 | class pp_output_iterator 66 | : public std::iterator 67 | { 68 | std::string &_M_result; 69 | 70 | public: 71 | explicit pp_output_iterator(std::string &__result): 72 | _M_result (__result) {} 73 | 74 | inline pp_output_iterator &operator=(typename _Container::const_reference __v) 75 | { 76 | if (_M_result.capacity () == _M_result.size ()) 77 | _M_result.reserve (_M_result.capacity () << 2); 78 | 79 | _M_result.push_back(__v); 80 | return *this; 81 | } 82 | 83 | inline pp_output_iterator &operator * () { return *this; } 84 | inline pp_output_iterator &operator ++ () { return *this; } 85 | inline pp_output_iterator operator ++ (int) { return *this; } 86 | }; 87 | 88 | } // namespace rpp 89 | 90 | #endif // PP_ITERATOR_H 91 | 92 | // kate: space-indent on; indent-width 2; replace-tabs on; 93 | -------------------------------------------------------------------------------- /generator/parser/rpp/pp.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef PP_H 43 | #define PP_H 44 | 45 | #if defined(_WIN64) || defined(WIN64) || defined(__WIN64__) \ 46 | || defined(_WIN32) || defined(WIN32) || defined(__WIN32__) 47 | # define PP_OS_WIN 48 | #endif 49 | 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | 59 | #include 60 | 61 | #ifdef HAVE_MMAP 62 | # include 63 | #endif 64 | 65 | #include 66 | #include 67 | 68 | #if (_MSC_VER >= 1400) 69 | # define FILENO _fileno 70 | #else 71 | # define FILENO fileno 72 | #endif 73 | 74 | #if defined (PP_OS_WIN) 75 | # define PATH_SEPARATOR '\\' 76 | #else 77 | # define PATH_SEPARATOR '/' 78 | #endif 79 | 80 | #if defined (RPP_JAMBI) 81 | # include "rxx_allocator.h" 82 | #else 83 | # include "rpp-allocator.h" 84 | #endif 85 | 86 | #if defined (_MSC_VER) 87 | # define pp_snprintf _snprintf 88 | #else 89 | # define pp_snprintf snprintf 90 | #endif 91 | 92 | #include "pp-fwd.h" 93 | #include "pp-cctype.h" 94 | #include "pp-string.h" 95 | #include "pp-symbol.h" 96 | #include "pp-internal.h" 97 | #include "pp-iterator.h" 98 | #include "pp-macro.h" 99 | #include "pp-environment.h" 100 | #include "pp-scanner.h" 101 | #include "pp-macro-expander.h" 102 | #include "pp-engine.h" 103 | #include "pp-engine-bits.h" 104 | 105 | #endif // PP_H 106 | 107 | // kate: space-indent on; indent-width 2; replace-tabs on; 108 | -------------------------------------------------------------------------------- /generator/shellgenerator.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef SHELLGENERATOR_H 43 | #define SHELLGENERATOR_H 44 | 45 | #include "generator.h" 46 | #include "metaqtscript.h" 47 | #include "prigenerator.h" 48 | 49 | class ShellGenerator : public Generator 50 | { 51 | Q_OBJECT 52 | 53 | public: 54 | virtual QString subDirectoryForClass(const AbstractMetaClass *cls) const 55 | { 56 | return "generated_cpp/" + cls->package().replace(".", "_") + "/"; 57 | } 58 | 59 | static void writeTypeInfo(QTextStream &s, const AbstractMetaType *type, Option option = NoOption); 60 | static void writeFunctionSignature(QTextStream &s, const AbstractMetaFunction *meta_function, 61 | const AbstractMetaClass *implementor = 0, 62 | const QString &name_prefix = QString(), 63 | Option option = NoOption, 64 | const QString &classname_prefix = QString(), 65 | const QStringList &extra_arguments = QStringList(), 66 | int numArguments = -1); 67 | static void writeFunctionArguments(QTextStream &s, const AbstractMetaArgumentList &arguments, 68 | Option option = NoOption, 69 | int numArguments = -1); 70 | 71 | bool shouldGenerate(const AbstractMetaClass *meta_class) const; 72 | 73 | static QString shellClassName(const AbstractMetaClass *meta_class) { 74 | return meta_class->generateShellClass() 75 | ? "QtScriptShell_" + meta_class->name() 76 | : meta_class->qualifiedCppName(); 77 | } 78 | 79 | protected: 80 | PriGenerator *priGenerator; 81 | 82 | }; 83 | 84 | 85 | #endif // SHELLGENERATOR_H 86 | -------------------------------------------------------------------------------- /generator/parser/declarator_compiler.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | 43 | #ifndef DECLARATOR_COMPILER_H 44 | #define DECLARATOR_COMPILER_H 45 | 46 | #include "default_visitor.h" 47 | #include "codemodel.h" 48 | 49 | #include 50 | #include 51 | 52 | class TokenStream; 53 | class Binder; 54 | 55 | class DeclaratorCompiler: protected DefaultVisitor 56 | { 57 | public: 58 | struct Parameter 59 | { 60 | TypeInfo type; 61 | QString name; 62 | QString defaultValueExpression; 63 | bool defaultValue; 64 | 65 | Parameter(): defaultValue(false) {} 66 | }; 67 | 68 | public: 69 | DeclaratorCompiler(Binder *binder); 70 | 71 | void run(DeclaratorAST *node); 72 | 73 | inline QString id() const { return _M_id; } 74 | inline QStringList arrayElements() const { return _M_array; } 75 | inline bool isFunction() const { return _M_function; } 76 | inline bool isVariadics() const { return _M_variadics; } 77 | inline bool isReference() const { return _M_reference; } 78 | inline int indirection() const { return _M_indirection; } 79 | inline QList parameters() const { return _M_parameters; } 80 | 81 | protected: 82 | virtual void visitPtrOperator(PtrOperatorAST *node); 83 | virtual void visitParameterDeclaration(ParameterDeclarationAST *node); 84 | 85 | private: 86 | Binder *_M_binder; 87 | TokenStream *_M_token_stream; 88 | 89 | bool _M_function; 90 | bool _M_reference; 91 | bool _M_variadics; 92 | int _M_indirection; 93 | QString _M_id; 94 | QStringList _M_array; 95 | QList _M_parameters; 96 | }; 97 | 98 | #endif // DECLARATOR_COMPILER_H 99 | 100 | // kate: space-indent on; indent-width 2; replace-tabs on; 101 | -------------------------------------------------------------------------------- /generator/parser/rpp/pp-symbol.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef PP_SYMBOL_H 43 | #define PP_SYMBOL_H 44 | 45 | namespace rpp { 46 | 47 | class pp_symbol 48 | { 49 | static rxx_allocator &allocator_instance () 50 | { 51 | static rxx_allocator__allocator; 52 | return __allocator; 53 | } 54 | 55 | public: 56 | static int &N() 57 | { 58 | static int __N; 59 | return __N; 60 | } 61 | 62 | static pp_fast_string const *get (char const *__data, std::size_t __size) 63 | { 64 | ++N(); 65 | char *data = allocator_instance ().allocate (__size + 1); 66 | memcpy(data, __data, __size); 67 | data[__size] = '\0'; 68 | 69 | char *where = allocator_instance ().allocate (sizeof (pp_fast_string)); 70 | return new (where) pp_fast_string (data, __size); 71 | } 72 | 73 | template 74 | static pp_fast_string const *get (_InputIterator __first, _InputIterator __last) 75 | { 76 | ++N(); 77 | std::ptrdiff_t __size; 78 | #if defined(__SUNPRO_CC) 79 | std::distance (__first, __last, __size); 80 | #else 81 | __size = std::distance (__first, __last); 82 | #endif 83 | assert (__size >= 0 && __size < 512); 84 | 85 | char *data = allocator_instance ().allocate (__size + 1); 86 | std::copy (__first, __last, data); 87 | data[__size] = '\0'; 88 | 89 | char *where = allocator_instance ().allocate (sizeof (pp_fast_string)); 90 | return new (where) pp_fast_string (data, __size); 91 | } 92 | 93 | static pp_fast_string const *get(std::string const &__s) 94 | { return get (__s.c_str (), __s.size ()); } 95 | }; 96 | 97 | } // namespace rpp 98 | 99 | #endif // PP_SYMBOL_H 100 | 101 | // kate: space-indent on; indent-width 2; replace-tabs on; 102 | -------------------------------------------------------------------------------- /generator/parser/list.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | 43 | #ifndef FASTLIST_H 44 | #define FASTLIST_H 45 | 46 | #include "smallobject.h" 47 | 48 | template 49 | struct ListNode 50 | { 51 | Tp element; 52 | int index; 53 | mutable const ListNode *next; 54 | 55 | static ListNode *create(const Tp &element, pool *p) 56 | { 57 | ListNode *node = new (p->allocate(sizeof(ListNode))) ListNode(); 58 | node->element = element; 59 | node->index = 0; 60 | node->next = node; 61 | 62 | return node; 63 | } 64 | 65 | static ListNode *create(const ListNode *n1, const Tp &element, pool *p) 66 | { 67 | ListNode *n2 = ListNode::create(element, p); 68 | 69 | n2->index = n1->index + 1; 70 | n2->next = n1->next; 71 | n1->next = n2; 72 | 73 | return n2; 74 | } 75 | 76 | inline ListNode() { } 77 | 78 | inline const ListNode *at(int index) const 79 | { 80 | const ListNode *node = this; 81 | while (index != node->index) 82 | node = node->next; 83 | 84 | return node; 85 | } 86 | 87 | inline bool hasNext() const 88 | { return index < next->index; } 89 | 90 | inline int count() const 91 | { return 1 + toBack()->index; } 92 | 93 | inline const ListNode *toFront() const 94 | { return toBack()->next; } 95 | 96 | inline const ListNode *toBack() const 97 | { 98 | const ListNode *node = this; 99 | while (node->hasNext()) 100 | node = node->next; 101 | 102 | return node; 103 | } 104 | }; 105 | 106 | template 107 | inline const ListNode *snoc(const ListNode *list, 108 | const Tp &element, pool *p) 109 | { 110 | if (!list) 111 | return ListNode::create(element, p); 112 | 113 | return ListNode::create(list->toBack(), element, p); 114 | } 115 | 116 | #endif // FASTLIST_H 117 | 118 | // kate: space-indent on; indent-width 2; replace-tabs on; 119 | 120 | -------------------------------------------------------------------------------- /examples/jennifer.xbel: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Qt Resources 6 | 7 | Trolltech Partners 8 | 9 | Training Partners 10 | 11 | 12 | Consultants and System Integrators 13 | 14 | 15 | Technology Partners 16 | 17 | 18 | Value Added Resellers (VARs) 19 | 20 | 21 | 22 | Community Resources 23 | 24 | QtForum.org 25 | 26 | 27 | The Independent Qt Tutorial 28 | 29 | 30 | French PROG.Qt 31 | 32 | 33 | German Qt Forum 34 | 35 | 36 | Korean Qt Community Site 37 | 38 | 39 | Russian Qt Forum 40 | 41 | 42 | Digitalfanatics: The QT 4 Resource Center 43 | 44 | 45 | QtQuestions 46 | 47 | 48 | 49 | Qt Quarterly 50 | 51 | 52 | Trolltech's home page 53 | 54 | 55 | Qt 4.0 documentation 56 | 57 | 58 | Frequently Asked Questions 59 | 60 | 61 | 62 | Online Dictionaries 63 | 64 | Dictionary.com 65 | 66 | 67 | Merriam-Webster Online 68 | 69 | 70 | Cambridge Dictionaries Online 71 | 72 | 73 | OneLook Dictionary Search 74 | 75 | 76 | 77 | The New English-German Dictionary 78 | 79 | 80 | TU Chemnitz German-English Dictionary 81 | 82 | 83 | 84 | Trésor de la Langue Française informatisé 85 | 86 | 87 | Dictionnaire de l'Académie Française 88 | 89 | 90 | Dictionnaire des synonymes 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /generator/parser/rpp/pp-string.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef PP_STRING_H 43 | #define PP_STRING_H 44 | 45 | namespace rpp { 46 | 47 | template 48 | class pp_string 49 | { 50 | typedef std::char_traits<_CharT> traits_type; 51 | typedef std::size_t size_type; 52 | 53 | _CharT const *_M_begin; 54 | std::size_t _M_size; 55 | 56 | public: 57 | inline pp_string (): 58 | _M_begin (0), _M_size(0) {} 59 | 60 | explicit pp_string (std::string const &__s): 61 | _M_begin (__s.c_str ()), _M_size (__s.size ()) {} 62 | 63 | inline pp_string (_CharT const *__begin, std::size_t __size): 64 | _M_begin (__begin), _M_size (__size) {} 65 | 66 | inline _CharT const *begin () const { return _M_begin; } 67 | inline _CharT const *end () const { return _M_begin + _M_size; } 68 | 69 | inline _CharT at (std::size_t index) const { return _M_begin [index]; } 70 | 71 | inline std::size_t size () const { return _M_size; } 72 | 73 | inline int compare (pp_string const &__other) const 74 | { 75 | size_type const __size = this->size(); 76 | size_type const __osize = __other.size(); 77 | size_type const __len = std::min (__size, __osize); 78 | 79 | int __r = traits_type::compare (_M_begin, __other._M_begin, __len); 80 | if (!__r) 81 | __r = (int) (__size - __osize); 82 | 83 | return __r; 84 | } 85 | 86 | inline bool operator == (pp_string const &__other) const 87 | { return compare (__other) == 0; } 88 | 89 | inline bool operator != (pp_string const &__other) const 90 | { return compare (__other) != 0; } 91 | 92 | inline bool operator < (pp_string const &__other) const 93 | { return compare (__other) < 0; } 94 | 95 | inline bool operator == (char const *s) const 96 | { 97 | std::size_t n = strlen (s); 98 | 99 | if (n != _M_size) 100 | return false; 101 | 102 | return ! strncmp (_M_begin, s, n); 103 | } 104 | 105 | inline bool operator != (char const *s) const 106 | { return ! operator == (s); } 107 | }; 108 | 109 | } // namespace rpp 110 | 111 | #endif // PP_STRING_H 112 | 113 | // kate: space-indent on; indent-width 2; replace-tabs on; 114 | -------------------------------------------------------------------------------- /generator/parser/codemodel_fwd.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | 43 | #ifndef CODEMODEL_FWD_H 44 | #define CODEMODEL_FWD_H 45 | 46 | #include 47 | #include 48 | 49 | // forward declarations 50 | class CodeModel; 51 | class _ArgumentModelItem; 52 | class _ClassModelItem; 53 | class _CodeModelItem; 54 | class _EnumModelItem; 55 | class _EnumeratorModelItem; 56 | class _FileModelItem; 57 | class _FunctionDefinitionModelItem; 58 | class _FunctionModelItem; 59 | class _NamespaceModelItem; 60 | class _ScopeModelItem; 61 | class _TemplateParameterModelItem; 62 | class _TypeAliasModelItem; 63 | class _VariableModelItem; 64 | class _MemberModelItem; 65 | class TypeInfo; 66 | 67 | typedef CodeModelPointer<_ArgumentModelItem> ArgumentModelItem; 68 | typedef CodeModelPointer<_ClassModelItem> ClassModelItem; 69 | typedef CodeModelPointer<_CodeModelItem> CodeModelItem; 70 | typedef CodeModelPointer<_EnumModelItem> EnumModelItem; 71 | typedef CodeModelPointer<_EnumeratorModelItem> EnumeratorModelItem; 72 | typedef CodeModelPointer<_FileModelItem> FileModelItem; 73 | typedef CodeModelPointer<_FunctionDefinitionModelItem> FunctionDefinitionModelItem; 74 | typedef CodeModelPointer<_FunctionModelItem> FunctionModelItem; 75 | typedef CodeModelPointer<_NamespaceModelItem> NamespaceModelItem; 76 | typedef CodeModelPointer<_ScopeModelItem> ScopeModelItem; 77 | typedef CodeModelPointer<_TemplateParameterModelItem> TemplateParameterModelItem; 78 | typedef CodeModelPointer<_TypeAliasModelItem> TypeAliasModelItem; 79 | typedef CodeModelPointer<_VariableModelItem> VariableModelItem; 80 | typedef CodeModelPointer<_MemberModelItem> MemberModelItem; 81 | 82 | typedef QList ArgumentList; 83 | typedef QList ClassList; 84 | typedef QList ItemList; 85 | typedef QList EnumList; 86 | typedef QList EnumeratorList; 87 | typedef QList FileList; 88 | typedef QList FunctionDefinitionList; 89 | typedef QList FunctionList; 90 | typedef QList NamespaceList; 91 | typedef QList ScopeList; 92 | typedef QList TemplateParameterList; 93 | typedef QList TypeAliasList; 94 | typedef QList VariableList; 95 | typedef QList MemberList; 96 | 97 | #endif // CODEMODEL_FWD_H 98 | -------------------------------------------------------------------------------- /generator/parser/symbol.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | 43 | #ifndef SYMBOL_H 44 | #define SYMBOL_H 45 | 46 | #include 47 | #include 48 | 49 | #include 50 | #include 51 | 52 | struct NameSymbol 53 | { 54 | const char *data; 55 | std::size_t count; 56 | 57 | inline QString as_string() const 58 | { 59 | return QString::fromUtf8(data, (int) count); 60 | } 61 | 62 | inline bool operator == (const NameSymbol &other) const 63 | { 64 | return count == other.count 65 | && std::strncmp(data, other.data, count) == 0; 66 | } 67 | 68 | protected: 69 | inline NameSymbol() {} 70 | inline NameSymbol(const char *d, std::size_t c) 71 | : data(d), count(c) {} 72 | 73 | private: 74 | void operator = (const NameSymbol &); 75 | 76 | friend class NameTable; 77 | }; 78 | 79 | inline uint qHash(const NameSymbol &r) 80 | { 81 | uint hash_value = 0; 82 | 83 | for (std::size_t i=0; i &r) 90 | { 91 | uint hash_value = 0; 92 | 93 | for (std::size_t i=0; i KeyType; 103 | typedef QHash ContainerType; 104 | 105 | public: 106 | NameTable() {} 107 | 108 | ~NameTable() 109 | { 110 | qDeleteAll(_M_storage); 111 | } 112 | 113 | inline const NameSymbol *findOrInsert(const char *str, std::size_t len) 114 | { 115 | KeyType key(str, len); 116 | 117 | NameSymbol *name = _M_storage.value(key); 118 | if (!name) 119 | { 120 | name = new NameSymbol(str, len); 121 | _M_storage.insert(key, name); 122 | } 123 | 124 | return name; 125 | } 126 | 127 | inline std::size_t count() const 128 | { 129 | return _M_storage.size(); 130 | } 131 | 132 | private: 133 | ContainerType _M_storage; 134 | 135 | private: 136 | NameTable(const NameTable &other); 137 | void operator = (const NameTable &other); 138 | }; 139 | 140 | #endif // SYMBOL_H 141 | 142 | // kate: space-indent on; indent-width 2; replace-tabs on; 143 | -------------------------------------------------------------------------------- /generator/parser/codemodel_finder.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | 43 | #include "codemodel_finder.h" 44 | #include "codemodel.h" 45 | #include "binder.h" 46 | 47 | CodeModelFinder::CodeModelFinder(CodeModel *model, Binder *binder) 48 | : _M_model(model), 49 | _M_binder (binder), 50 | _M_token_stream(binder->tokenStream ()), 51 | name_cc(_M_binder), 52 | _M_resolve_policy(ResolveItem) 53 | { 54 | } 55 | 56 | CodeModelFinder::~CodeModelFinder() 57 | { 58 | } 59 | 60 | ScopeModelItem CodeModelFinder::resolveScope(NameAST *name, ScopeModelItem scope) 61 | { 62 | Q_ASSERT(scope != 0); 63 | 64 | ResolvePolicy saved_resolve_policy = _M_resolve_policy; 65 | _M_resolve_policy = ResolveScope; 66 | 67 | ScopeModelItem old = changeCurrentScope(scope); 68 | 69 | visit(name); 70 | ScopeModelItem result = _M_current_scope; 71 | 72 | changeCurrentScope(old); // restore 73 | 74 | _M_resolve_policy = saved_resolve_policy; 75 | 76 | return result; 77 | } 78 | 79 | ScopeModelItem CodeModelFinder::changeCurrentScope(ScopeModelItem scope) 80 | { 81 | ScopeModelItem old = _M_current_scope; 82 | _M_current_scope = scope; 83 | return old; 84 | } 85 | 86 | void CodeModelFinder::visitName(NameAST *node) 87 | { 88 | visitNodes(this, node->qualified_names); 89 | 90 | if (_M_resolve_policy == ResolveItem) 91 | visit(node->unqualified_name); 92 | } 93 | 94 | void CodeModelFinder::visitUnqualifiedName(UnqualifiedNameAST *node) 95 | { 96 | if (!_M_current_scope) 97 | { 98 | // nothing to do 99 | return; 100 | } 101 | 102 | name_cc.run(node); 103 | QString id = name_cc.name(); 104 | 105 | if (ClassModelItem klass = _M_current_scope->findClass(id)) 106 | { 107 | _M_current_scope = klass; 108 | } 109 | else if (NamespaceModelItem parentNamespace = model_safe_cast(_M_current_scope)) 110 | { 111 | NamespaceModelItem ns = parentNamespace->findNamespace(id); 112 | _M_current_scope = model_static_cast(ns); 113 | } 114 | else if (FileModelItem file = model_safe_cast(_M_current_scope)) 115 | { 116 | NamespaceModelItem ns = file->findNamespace(id); 117 | _M_current_scope = model_static_cast(ns); 118 | } 119 | } 120 | 121 | // kate: space-indent on; indent-width 2; replace-tabs on; 122 | 123 | -------------------------------------------------------------------------------- /examples/AnalogClock.js: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Script Generator project on Qt Labs. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | function AnalogClock(parent) { 43 | QWidget.call(this, parent); 44 | 45 | var timer = new QTimer(this); 46 | timer.timeout.connect(this, "update()"); 47 | timer.start(1000); 48 | 49 | this.setWindowTitle("Analog Clock"); 50 | this.resize(200, 200); 51 | } 52 | 53 | AnalogClock.prototype = new QWidget(); 54 | 55 | AnalogClock.prototype.paintEvent = function() { 56 | var side = Math.min(this.width, this.height); 57 | var time = new Date(); 58 | 59 | var painter = new QPainter(); 60 | painter.begin(this); 61 | painter.setRenderHint(QPainter.Antialiasing); 62 | painter.translate(this.width / 2, this.height / 2); 63 | painter.scale(side / 200.0, side / 200.0); 64 | 65 | painter.setPen(new QPen(Qt.NoPen)); 66 | painter.setBrush(new QBrush(AnalogClock.hourColor)); 67 | 68 | painter.save(); 69 | painter.rotate(30.0 * ((time.getHours() + time.getMinutes() / 60.0))); 70 | painter.drawConvexPolygon(AnalogClock.hourHand); 71 | painter.drawLine(0, 0, 100, 100); 72 | painter.restore(); 73 | 74 | painter.setPen(AnalogClock.hourColor); 75 | 76 | for (var i = 0; i < 12; ++i) { 77 | painter.drawLine(88, 0, 96, 0); 78 | painter.rotate(30.0); 79 | } 80 | 81 | painter.setPen(new QPen(Qt.NoPen)); 82 | painter.setBrush(new QBrush(AnalogClock.minuteColor)); 83 | 84 | painter.save(); 85 | painter.rotate(6.0 * (time.getMinutes() + time.getSeconds() / 60.0)); 86 | painter.drawConvexPolygon(AnalogClock.minuteHand); 87 | painter.restore(); 88 | 89 | painter.setPen(AnalogClock.minuteColor); 90 | 91 | for (var j = 0; j < 60; ++j) { 92 | if ((j % 5) != 0) 93 | painter.drawLine(92, 0, 96, 0); 94 | painter.rotate(6.0); 95 | } 96 | painter.end(); 97 | }; 98 | 99 | AnalogClock.hourColor = new QColor(127, 0, 127); 100 | 101 | AnalogClock.minuteColor = new QColor(0, 127, 127, 191); 102 | 103 | AnalogClock.hourHand = new QPolygon([new QPoint(7, 8), 104 | new QPoint(-7, 8), 105 | new QPoint(0, -40)]); 106 | AnalogClock.minuteHand = new QPolygon([new QPoint(7, 8), 107 | new QPoint(-7, 8), 108 | new QPoint(0, -70)]); 109 | 110 | var clock = new AnalogClock(); 111 | clock.show(); 112 | 113 | QCoreApplication.exec(); 114 | --------------------------------------------------------------------------------