qml 0.0.7 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitmodules +3 -0
- data/.travis.yml +5 -9
- data/LICENSE.txt +1 -1
- data/README.md +84 -114
- data/changes.md +5 -0
- data/examples/fizzbuzz/fizzbuzz.rb +3 -4
- data/examples/todo_array/todo_array.rb +4 -4
- data/examples/todo_sequel/todo_sequel.rb +7 -7
- data/examples/twitter/twitter.rb +5 -3
- data/ext/qml/application.c +88 -0
- data/ext/qml/application.h +9 -0
- data/ext/qml/component.c +89 -0
- data/ext/qml/component.h +10 -0
- data/ext/qml/conversion.c +60 -0
- data/ext/qml/conversion.h +8 -0
- data/ext/qml/dispatcher.c +31 -0
- data/ext/qml/dispatcher.h +7 -0
- data/ext/qml/engine.c +135 -0
- data/ext/qml/engine.h +10 -0
- data/ext/qml/exporter.c +93 -0
- data/ext/qml/exporter.h +7 -0
- data/ext/qml/extconf.rb +38 -97
- data/ext/qml/interface.c +156 -0
- data/ext/qml/interface.h +11 -0
- data/ext/qml/js_array.c +47 -0
- data/ext/qml/js_array.h +7 -0
- data/ext/qml/js_function.c +109 -0
- data/ext/qml/js_function.h +7 -0
- data/ext/qml/js_object.c +284 -0
- data/ext/qml/js_object.h +19 -0
- data/ext/qml/js_wrapper.c +19 -0
- data/ext/qml/js_wrapper.h +7 -0
- data/ext/qml/lib/libqmlbind/.gitignore +38 -0
- data/ext/qml/lib/libqmlbind/.gitmodules +3 -0
- data/ext/qml/lib/libqmlbind/.travis.yml +14 -0
- data/ext/qml/lib/libqmlbind/LICENSE.txt +22 -0
- data/ext/qml/lib/libqmlbind/libqmlbind.pro +3 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind.h +14 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/application.h +18 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/component.h +21 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/engine.h +34 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/exporter.h +37 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/interface.h +16 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/iterator.h +19 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/metaobject.h +13 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/plugin.h +17 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/qmlbind_global.h +78 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/register.h +17 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/signal_emitter.h +15 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/string.h +15 -0
- data/ext/qml/lib/libqmlbind/qmlbind/include/qmlbind/value.h +100 -0
- data/ext/qml/lib/libqmlbind/qmlbind/qmlbind.pro +62 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_application.cpp +103 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_component.cpp +54 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_engine.cpp +65 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_exporter.cpp +52 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_interface.cpp +19 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_iterator.cpp +32 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_metaobject.cpp +19 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_plugin.cpp +27 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_register.cpp +17 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_signal_emitter.cpp +27 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_string.cpp +22 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/api_value.cpp +215 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/backref.cpp +54 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/backref.h +29 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/engine.cpp +32 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/engine.h +27 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/exporter.cpp +73 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/exporter.h +46 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/interface.cpp +75 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/interface.h +37 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/metaobject.cpp +101 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/metaobject.h +29 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/signalemitter.cpp +33 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/signalemitter.h +25 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/ticktimer.cpp +15 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/ticktimer.h +19 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/typeregisterer.cpp +112 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/typeregisterer.h +28 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/util.h +13 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/wrapper.cpp +23 -0
- data/ext/qml/lib/libqmlbind/qmlbind/src/wrapper.h +29 -0
- data/ext/qml/lib/libqmlbind/readme.md +14 -0
- data/ext/qml/lib/libqmlbind/test/api.c +1 -0
- data/ext/qml/lib/libqmlbind/test/application_test.cpp +16 -0
- data/ext/qml/lib/libqmlbind/test/component_test.cpp +57 -0
- data/ext/qml/lib/libqmlbind/test/engine_test.cpp +94 -0
- data/ext/qml/lib/libqmlbind/test/exporter_test.cpp +312 -0
- data/ext/qml/lib/libqmlbind/test/fixtures/emptyhandlers.cpp +36 -0
- data/ext/qml/lib/libqmlbind/test/fixtures/emptyhandlers.h +6 -0
- data/ext/qml/lib/libqmlbind/test/fixtures/test.qml +5 -0
- data/ext/qml/lib/libqmlbind/test/fixtures/testmodule/qmldir +2 -0
- data/ext/qml/lib/libqmlbind/test/fixtures/testmodule/test.qml +5 -0
- data/ext/qml/lib/libqmlbind/test/iterator_test.cpp +37 -0
- data/ext/qml/lib/libqmlbind/test/main.cpp +11 -0
- data/ext/qml/lib/libqmlbind/test/plugin_test.cpp +41 -0
- data/ext/qml/lib/libqmlbind/test/test.pro +26 -0
- data/ext/qml/lib/libqmlbind/test/test_helper.h +20 -0
- data/ext/qml/lib/libqmlbind/test/value_test.cpp +252 -0
- data/ext/qml/lib/libqmlbind/testplugin/testplugin.cpp +11 -0
- data/ext/qml/lib/libqmlbind/testplugin/testplugin.h +21 -0
- data/ext/qml/lib/libqmlbind/testplugin/testplugin.json +3 -0
- data/ext/qml/lib/libqmlbind/testplugin/testplugin.pro +21 -0
- data/ext/qml/meta_object.c +81 -0
- data/ext/qml/meta_object.h +8 -0
- data/ext/qml/plugin_loader.c +71 -0
- data/ext/qml/plugin_loader.h +7 -0
- data/ext/qml/qml.c +95 -0
- data/ext/qml/qml.h +10 -0
- data/ext/qml/rubyqml-plugin/listmodel.cpp +102 -0
- data/ext/qml/rubyqml-plugin/listmodel.h +37 -0
- data/ext/qml/rubyqml-plugin/rubyqml-plugin.pro +19 -0
- data/ext/qml/rubyqml-plugin/rubyqmlplugin.cpp +25 -0
- data/ext/qml/rubyqml-plugin/rubyqmlplugin.h +19 -0
- data/ext/qml/signal_emitter.c +71 -0
- data/ext/qml/signal_emitter.h +9 -0
- data/lib/qml.rb +11 -10
- data/lib/qml/access.rb +64 -86
- data/lib/qml/application.rb +20 -71
- data/lib/qml/component.rb +41 -33
- data/lib/qml/core_ext.rb +1 -0
- data/lib/qml/core_ext/to_qml.rb +70 -0
- data/lib/qml/data.rb +1 -0
- data/lib/qml/data/array_model.rb +99 -101
- data/lib/qml/data/list_model.rb +107 -131
- data/lib/qml/data/list_model_access.rb +44 -0
- data/lib/qml/data/query_model.rb +45 -47
- data/lib/qml/dispatcher.rb +5 -13
- data/lib/qml/engine.rb +9 -58
- data/lib/qml/errors.rb +0 -21
- data/lib/qml/interface.rb +21 -0
- data/lib/qml/js_array.rb +8 -0
- data/lib/qml/js_object.rb +69 -0
- data/lib/qml/js_util.rb +18 -0
- data/lib/qml/plugin_loader.rb +1 -13
- data/lib/qml/plugins.rb +3 -17
- data/lib/qml/proc_access.rb +28 -0
- data/lib/qml/qt.rb +21 -3
- data/lib/qml/reactive.rb +147 -8
- data/lib/qml/signal.rb +67 -0
- data/lib/qml/version.rb +1 -1
- data/qml.gemspec +8 -2
- data/spec/qml/access_spec.rb +33 -120
- data/spec/qml/application_spec.rb +11 -24
- data/spec/qml/component_spec.rb +4 -4
- data/spec/qml/data/array_model_spec.rb +2 -2
- data/spec/qml/data/list_model_spec.rb +2 -2
- data/spec/qml/data/query_model_spec.rb +4 -4
- data/spec/qml/engine_spec.rb +23 -21
- data/spec/qml/interface_spec.rb +20 -0
- data/spec/qml/js_array_spec.rb +29 -0
- data/spec/qml/js_function_spec.rb +32 -0
- data/spec/qml/js_object_spec.rb +113 -0
- data/spec/qml/plugin_loader_spec.rb +9 -11
- data/spec/qml/qt_spec.rb +9 -0
- data/spec/qml/reactive_spec.rb +37 -0
- data/spec/qml/signal_connect_spec.rb +27 -0
- data/spec/qml/signal_spec.rb +73 -0
- data/spec/qml/to_qml_spec.rb +76 -0
- data/spec/shared/qml/access_example.rb +21 -0
- data/spec/shared/qml/data/list_model.rb +12 -13
- data/spec/spec_helper.rb +2 -3
- metadata +141 -166
- data/examples/imageprovider/imageprovider.rb +0 -57
- data/examples/imageprovider/main.qml +0 -51
- data/ext/qml/accessclass.cpp +0 -65
- data/ext/qml/accessclass.h +0 -19
- data/ext/qml/accessobject.cpp +0 -30
- data/ext/qml/accessobject.h +0 -22
- data/ext/qml/common.h +0 -18
- data/ext/qml/conversionerror.h +0 -14
- data/ext/qml/ext_accesswrapperfactory.cpp +0 -75
- data/ext/qml/ext_accesswrapperfactory.h +0 -39
- data/ext/qml/ext_anywrapper.cpp +0 -34
- data/ext/qml/ext_anywrapper.h +0 -23
- data/ext/qml/ext_kernel.cpp +0 -81
- data/ext/qml/ext_kernel.h +0 -9
- data/ext/qml/ext_metaobject.cpp +0 -399
- data/ext/qml/ext_metaobject.h +0 -60
- data/ext/qml/ext_pluginloader.cpp +0 -53
- data/ext/qml/ext_pluginloader.h +0 -30
- data/ext/qml/ext_pointer.cpp +0 -132
- data/ext/qml/ext_pointer.h +0 -41
- data/ext/qml/ext_testutil.cpp +0 -40
- data/ext/qml/ext_testutil.h +0 -9
- data/ext/qml/foreignclass.cpp +0 -72
- data/ext/qml/foreignclass.h +0 -88
- data/ext/qml/foreignmetaobject.cpp +0 -345
- data/ext/qml/foreignmetaobject.h +0 -46
- data/ext/qml/foreignobject.cpp +0 -22
- data/ext/qml/foreignobject.h +0 -21
- data/ext/qml/functioninfo.h +0 -16
- data/ext/qml/init.cpp +0 -67
- data/ext/qml/kernel.cpp +0 -39
- data/ext/qml/kernel.h +0 -32
- data/ext/qml/listmodel.cpp +0 -137
- data/ext/qml/listmodel.h +0 -45
- data/ext/qml/markable.h +0 -12
- data/ext/qml/objectdata.cpp +0 -26
- data/ext/qml/objectdata.h +0 -20
- data/ext/qml/objectgc.cpp +0 -69
- data/ext/qml/objectgc.h +0 -28
- data/ext/qml/plugins/core/applicationextension.cpp +0 -29
- data/ext/qml/plugins/core/applicationextension.h +0 -25
- data/ext/qml/plugins/core/componentextension.cpp +0 -41
- data/ext/qml/plugins/core/componentextension.h +0 -28
- data/ext/qml/plugins/core/contextextension.cpp +0 -39
- data/ext/qml/plugins/core/contextextension.h +0 -29
- data/ext/qml/plugins/core/core.pro +0 -29
- data/ext/qml/plugins/core/coreplugin.cpp +0 -87
- data/ext/qml/plugins/core/coreplugin.h +0 -49
- data/ext/qml/plugins/core/engineextension.cpp +0 -43
- data/ext/qml/plugins/core/engineextension.h +0 -31
- data/ext/qml/plugins/core/imageprovider.cpp +0 -38
- data/ext/qml/plugins/core/imageprovider.h +0 -18
- data/ext/qml/plugins/core/imagerequestpromise.cpp +0 -19
- data/ext/qml/plugins/core/imagerequestpromise.h +0 -21
- data/ext/qml/plugins/core/qmlexception.cpp +0 -11
- data/ext/qml/plugins/core/qmlexception.h +0 -17
- data/ext/qml/plugins/testutil/imageprovidertest.cpp +0 -40
- data/ext/qml/plugins/testutil/imageprovidertest.h +0 -17
- data/ext/qml/plugins/testutil/objectlifechecker.cpp +0 -17
- data/ext/qml/plugins/testutil/objectlifechecker.h +0 -24
- data/ext/qml/plugins/testutil/ownershiptest.cpp +0 -26
- data/ext/qml/plugins/testutil/ownershiptest.h +0 -30
- data/ext/qml/plugins/testutil/testobject.cpp +0 -6
- data/ext/qml/plugins/testutil/testobject.h +0 -108
- data/ext/qml/plugins/testutil/testobjectsubclass.cpp +0 -10
- data/ext/qml/plugins/testutil/testobjectsubclass.h +0 -19
- data/ext/qml/plugins/testutil/testutil.pro +0 -22
- data/ext/qml/plugins/testutil/testutilplugin.cpp +0 -55
- data/ext/qml/plugins/testutil/testutilplugin.h +0 -36
- data/ext/qml/qmltyperegisterer.cpp +0 -74
- data/ext/qml/qmltyperegisterer.h +0 -30
- data/ext/qml/rubyclass.cpp +0 -82
- data/ext/qml/rubyclass.h +0 -230
- data/ext/qml/rubyvalue.cpp +0 -656
- data/ext/qml/rubyvalue.h +0 -224
- data/ext/qml/signalforwarder.cpp +0 -64
- data/ext/qml/signalforwarder.h +0 -29
- data/ext/qml/util.cpp +0 -112
- data/ext/qml/util.h +0 -82
- data/ext/qml/valuereference.cpp +0 -50
- data/ext/qml/valuereference.h +0 -22
- data/ext/qml/weakvaluereference.cpp +0 -51
- data/ext/qml/weakvaluereference.h +0 -21
- data/lib/qml/context.rb +0 -71
- data/lib/qml/data/error.rb +0 -5
- data/lib/qml/dispatchable.rb +0 -34
- data/lib/qml/error_converter.rb +0 -16
- data/lib/qml/geometry.rb +0 -3
- data/lib/qml/geometry/point.rb +0 -5
- data/lib/qml/geometry/rectangle.rb +0 -5
- data/lib/qml/geometry/size.rb +0 -5
- data/lib/qml/image_provider.rb +0 -87
- data/lib/qml/init.rb +0 -29
- data/lib/qml/meta_object.rb +0 -20
- data/lib/qml/models.rb +0 -1
- data/lib/qml/qt_classes.rb +0 -9
- data/lib/qml/qt_object_base.rb +0 -233
- data/lib/qml/reactive/bindable.rb +0 -79
- data/lib/qml/reactive/chained_signal.rb +0 -25
- data/lib/qml/reactive/error.rb +0 -5
- data/lib/qml/reactive/object.rb +0 -293
- data/lib/qml/reactive/property.rb +0 -19
- data/lib/qml/reactive/signal.rb +0 -115
- data/lib/qml/reactive/signal_spy.rb +0 -27
- data/lib/qml/reactive/signals/map_signal.rb +0 -21
- data/lib/qml/reactive/signals/merge_signal.rb +0 -21
- data/lib/qml/reactive/signals/select_signal.rb +0 -21
- data/lib/qml/reactive/simple_property.rb +0 -17
- data/lib/qml/reactive/unbound_property.rb +0 -42
- data/lib/qml/reactive/unbound_signal.rb +0 -51
- data/lib/qml/test_util.rb +0 -1
- data/lib/qml/test_util/object_life_checker.rb +0 -17
- data/lib/qml/wrappable.rb +0 -9
- data/spec/qml/context_spec.rb +0 -43
- data/spec/qml/conversion_spec.rb +0 -60
- data/spec/qml/dispatchable_spec.rb +0 -26
- data/spec/qml/dispatcher_spec.rb +0 -71
- data/spec/qml/geometry/point_spec.rb +0 -4
- data/spec/qml/geometry/rectangle_spec.rb +0 -4
- data/spec/qml/geometry/size_spec.rb +0 -4
- data/spec/qml/image_provider_spec.rb +0 -33
- data/spec/qml/qt_object_base_spec.rb +0 -119
- data/spec/qml/reactive/object_spec.rb +0 -249
- data/spec/qml/reactive/property_spec.rb +0 -70
- data/spec/qml/reactive/signal_spec.rb +0 -191
- data/spec/qml/reactive/signal_spy_spec.rb +0 -26
- data/spec/qml/reactive/unbound_property_spec.rb +0 -40
- data/spec/qml/reactive/unbound_signal_spec.rb +0 -70
- data/spec/qml/test_object_spec.rb +0 -186
- data/spec/qml/wrappable_spec.rb +0 -10
- data/spec/shared/qml/reactive/object.rb +0 -39
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
QT += widgets qml quick core-private
|
|
2
|
+
|
|
3
|
+
TARGET = qmlbind
|
|
4
|
+
TEMPLATE = lib
|
|
5
|
+
|
|
6
|
+
DEFINES += QMLBIND_LIBRARY
|
|
7
|
+
|
|
8
|
+
INCLUDEPATH += $$PWD/include
|
|
9
|
+
|
|
10
|
+
unix {
|
|
11
|
+
target.path = /usr/lib
|
|
12
|
+
INSTALLS += target
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
SOURCES += \
|
|
16
|
+
src/api_application.cpp \
|
|
17
|
+
src/api_engine.cpp \
|
|
18
|
+
src/api_iterator.cpp \
|
|
19
|
+
src/api_value.cpp \
|
|
20
|
+
src/metaobject.cpp \
|
|
21
|
+
src/api_metaobject.cpp \
|
|
22
|
+
src/wrapper.cpp \
|
|
23
|
+
src/api_string.cpp \
|
|
24
|
+
src/api_component.cpp \
|
|
25
|
+
src/typeregisterer.cpp \
|
|
26
|
+
src/api_register.cpp \
|
|
27
|
+
src/exporter.cpp \
|
|
28
|
+
src/api_exporter.cpp \
|
|
29
|
+
src/api_interface.cpp \
|
|
30
|
+
src/interface.cpp \
|
|
31
|
+
src/backref.cpp \
|
|
32
|
+
src/signalemitter.cpp \
|
|
33
|
+
src/api_signal_emitter.cpp \
|
|
34
|
+
src/engine.cpp \
|
|
35
|
+
src/api_plugin.cpp \
|
|
36
|
+
src/ticktimer.cpp
|
|
37
|
+
|
|
38
|
+
HEADERS += \
|
|
39
|
+
include/qmlbind/application.h \
|
|
40
|
+
include/qmlbind/engine.h \
|
|
41
|
+
include/qmlbind/iterator.h \
|
|
42
|
+
include/qmlbind/qmlbind_global.h \
|
|
43
|
+
include/qmlbind/value.h \
|
|
44
|
+
src/metaobject.h \
|
|
45
|
+
include/qmlbind/metaobject.h \
|
|
46
|
+
src/wrapper.h \
|
|
47
|
+
include/qmlbind/string.h \
|
|
48
|
+
include/qmlbind/component.h \
|
|
49
|
+
include/qmlbind.h \
|
|
50
|
+
src/typeregisterer.h \
|
|
51
|
+
include/qmlbind/register.h \
|
|
52
|
+
src/util.h \
|
|
53
|
+
src/exporter.h \
|
|
54
|
+
include/qmlbind/exporter.h \
|
|
55
|
+
include/qmlbind/interface.h \
|
|
56
|
+
src/interface.h \
|
|
57
|
+
src/backref.h \
|
|
58
|
+
src/signalemitter.h \
|
|
59
|
+
include/qmlbind/signal_emitter.h \
|
|
60
|
+
src/engine.h \
|
|
61
|
+
include/qmlbind/plugin.h \
|
|
62
|
+
src/ticktimer.h
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#include "qmlbind/application.h"
|
|
2
|
+
#include "util.h"
|
|
3
|
+
#include "ticktimer.h"
|
|
4
|
+
#include "backref.h"
|
|
5
|
+
#include <QApplication>
|
|
6
|
+
#include <QSharedPointer>
|
|
7
|
+
#include <QTimer>
|
|
8
|
+
#include <QVector>
|
|
9
|
+
|
|
10
|
+
using namespace QmlBind;
|
|
11
|
+
|
|
12
|
+
namespace QmlBind {
|
|
13
|
+
|
|
14
|
+
class NextTickFunc
|
|
15
|
+
{
|
|
16
|
+
public:
|
|
17
|
+
NextTickFunc(void (*func)(qmlbind_backref), const Backref &data) : mFunc(func), mData(data)
|
|
18
|
+
{}
|
|
19
|
+
|
|
20
|
+
void operator()()
|
|
21
|
+
{
|
|
22
|
+
mFunc(mData.backref());
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private:
|
|
26
|
+
void (*mFunc)(qmlbind_backref);
|
|
27
|
+
Backref mData;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
class AppArgs
|
|
31
|
+
{
|
|
32
|
+
public:
|
|
33
|
+
AppArgs(int argc, char **argv) :
|
|
34
|
+
mArgs(argc), mArgc(argc), mArgv(argc)
|
|
35
|
+
{
|
|
36
|
+
for (int i = 0; i < argc; ++i) {
|
|
37
|
+
mArgs[i] = argv[i];
|
|
38
|
+
}
|
|
39
|
+
for (int i = 0; i < argc; ++i) {
|
|
40
|
+
mArgv[i] = mArgs[i].data();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
int &argc()
|
|
45
|
+
{
|
|
46
|
+
return mArgc;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
char **argv()
|
|
50
|
+
{
|
|
51
|
+
return mArgv.data();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private:
|
|
55
|
+
QVector<QByteArray> mArgs;
|
|
56
|
+
int mArgc;
|
|
57
|
+
QVector<char *> mArgv;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static void (*tickCallback)();
|
|
63
|
+
|
|
64
|
+
extern "C" {
|
|
65
|
+
|
|
66
|
+
qmlbind_application qmlbind_application_new(int argc, char **argv)
|
|
67
|
+
{
|
|
68
|
+
AppArgs *args = new AppArgs(argc, argv);
|
|
69
|
+
QApplication *app = new QApplication(args->argc(), args->argv());
|
|
70
|
+
|
|
71
|
+
TickTimer *timer = new TickTimer(&tickCallback, app);
|
|
72
|
+
timer->start();
|
|
73
|
+
|
|
74
|
+
return app;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
void qmlbind_application_release(qmlbind_application app)
|
|
78
|
+
{
|
|
79
|
+
delete app;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
int qmlbind_application_exec(qmlbind_application app)
|
|
83
|
+
{
|
|
84
|
+
return app->exec();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
void qmlbind_process_events()
|
|
88
|
+
{
|
|
89
|
+
QCoreApplication::processEvents();
|
|
90
|
+
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
void qmlbind_set_tick_callback(void (*func)())
|
|
94
|
+
{
|
|
95
|
+
tickCallback = func;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
void qmlbind_next_tick(qmlbind_interface interface, void (*func)(qmlbind_backref), qmlbind_backref data)
|
|
99
|
+
{
|
|
100
|
+
QTimer::singleShot(0, NextTickFunc(func, Backref(data, *interface)));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#include "qmlbind/component.h"
|
|
2
|
+
#include "engine.h"
|
|
3
|
+
#include "util.h"
|
|
4
|
+
#include <QQmlComponent>
|
|
5
|
+
#include <QQmlEngine>
|
|
6
|
+
#include <QQmlContext>
|
|
7
|
+
|
|
8
|
+
using namespace QmlBind;
|
|
9
|
+
|
|
10
|
+
extern "C" {
|
|
11
|
+
|
|
12
|
+
qmlbind_component qmlbind_component_new(qmlbind_engine engine)
|
|
13
|
+
{
|
|
14
|
+
return new QQmlComponent(engine);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
void qmlbind_component_release(qmlbind_component component)
|
|
18
|
+
{
|
|
19
|
+
delete component;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
void qmlbind_component_load_path(qmlbind_component component, const char *path)
|
|
23
|
+
{
|
|
24
|
+
component->loadUrl(QUrl::fromLocalFile(path));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
void qmlbind_component_set_data(qmlbind_component component, const char *data, const char *path)
|
|
28
|
+
{
|
|
29
|
+
component->setData(data, QUrl::fromLocalFile(path));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
qmlbind_string qmlbind_component_get_error_string(qmlbind_component component)
|
|
33
|
+
{
|
|
34
|
+
QString str = component->errorString();
|
|
35
|
+
|
|
36
|
+
if (str.isEmpty()) {
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return new QByteArray(str.toUtf8());
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
qmlbind_value qmlbind_component_create(qmlbind_component component)
|
|
45
|
+
{
|
|
46
|
+
QObject *object = component->create();
|
|
47
|
+
if (!object) {
|
|
48
|
+
return new QJSValue(QJSValue::UndefinedValue);
|
|
49
|
+
}
|
|
50
|
+
QQmlEngine::setObjectOwnership(object, QQmlEngine::JavaScriptOwnership);
|
|
51
|
+
return new QJSValue(QQmlEngine::contextForObject(object)->engine()->newQObject(object));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#include "qmlbind/engine.h"
|
|
2
|
+
#include "engine.h"
|
|
3
|
+
#include "metaobject.h"
|
|
4
|
+
#include "wrapper.h"
|
|
5
|
+
#include "util.h"
|
|
6
|
+
#include <QQmlEngine>
|
|
7
|
+
#include <QDebug>
|
|
8
|
+
#include <QApplication>
|
|
9
|
+
|
|
10
|
+
using namespace QmlBind;
|
|
11
|
+
|
|
12
|
+
extern "C" {
|
|
13
|
+
|
|
14
|
+
qmlbind_engine qmlbind_engine_new()
|
|
15
|
+
{
|
|
16
|
+
Engine *engine = new Engine();
|
|
17
|
+
QObject::connect(engine, SIGNAL(quit()), QApplication::instance(), SLOT(quit()));
|
|
18
|
+
return engine;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
void qmlbind_engine_release(qmlbind_engine engine)
|
|
22
|
+
{
|
|
23
|
+
engine->scheduleDelete();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
qmlbind_value qmlbind_engine_eval(qmlbind_engine engine, const char *str, const char *file, int lineNumber)
|
|
27
|
+
{
|
|
28
|
+
QJSValue value = engine->evaluate(QString::fromUtf8(str), QString::fromUtf8(file), lineNumber);
|
|
29
|
+
return new QJSValue(value);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
qmlbind_value qmlbind_engine_get_global_object(qmlbind_engine engine)
|
|
33
|
+
{
|
|
34
|
+
return new QJSValue(engine->globalObject());
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
qmlbind_value qmlbind_engine_new_object(qmlbind_engine engine)
|
|
38
|
+
{
|
|
39
|
+
return new QJSValue(engine->newObject());
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
qmlbind_value qmlbind_engine_new_array(qmlbind_engine engine, int length)
|
|
43
|
+
{
|
|
44
|
+
return new QJSValue(engine->newArray(length));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
qmlbind_value qmlbind_engine_new_wrapper(qmlbind_engine engine, qmlbind_metaobject metaobj, qmlbind_backref ref)
|
|
48
|
+
{
|
|
49
|
+
Wrapper *obj = new Wrapper(*metaobj, Backref(ref, (*metaobj)->exporter()->classRef().interface()));
|
|
50
|
+
|
|
51
|
+
QQmlEngine::setObjectOwnership(obj, QQmlEngine::JavaScriptOwnership);
|
|
52
|
+
return new QJSValue(engine->newQObject(obj));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
void qmlbind_engine_add_import_path(qmlbind_engine engine, const char *path)
|
|
56
|
+
{
|
|
57
|
+
engine->addImportPath(path);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
void qmlbind_engine_collect_garbage(qmlbind_engine engine)
|
|
61
|
+
{
|
|
62
|
+
engine->collectGarbage();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#include "qmlbind/exporter.h"
|
|
2
|
+
#include "exporter.h"
|
|
3
|
+
#include "util.h"
|
|
4
|
+
#include <private/qmetaobjectbuilder_p.h>
|
|
5
|
+
#include <private/qobject_p.h>
|
|
6
|
+
|
|
7
|
+
using namespace QmlBind;
|
|
8
|
+
|
|
9
|
+
extern "C" {
|
|
10
|
+
|
|
11
|
+
qmlbind_exporter qmlbind_exporter_new(qmlbind_backref classHandle, const char *className, qmlbind_interface interface)
|
|
12
|
+
{
|
|
13
|
+
return newSharedPointer(new Exporter(className, Backref(classHandle, *interface)));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
void qmlbind_exporter_release(qmlbind_exporter exporter)
|
|
17
|
+
{
|
|
18
|
+
delete exporter;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
int qmlbind_exporter_add_method(
|
|
22
|
+
qmlbind_exporter exporter,
|
|
23
|
+
const char *name,
|
|
24
|
+
int arity
|
|
25
|
+
)
|
|
26
|
+
{
|
|
27
|
+
return (*exporter)->addMethod(name, arity).index();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
int qmlbind_exporter_add_signal(
|
|
31
|
+
qmlbind_exporter exporter,
|
|
32
|
+
const char *name,
|
|
33
|
+
int arity,
|
|
34
|
+
const char **params
|
|
35
|
+
)
|
|
36
|
+
{
|
|
37
|
+
QList<QByteArray> paramList;
|
|
38
|
+
for (int i = 0; i < arity; ++i) {
|
|
39
|
+
paramList << params[i];
|
|
40
|
+
}
|
|
41
|
+
return (*exporter)->addSignal(name, paramList).index();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
int qmlbind_exporter_add_property(qmlbind_exporter exporter,
|
|
45
|
+
const char *name,
|
|
46
|
+
const char *notifierSignal
|
|
47
|
+
)
|
|
48
|
+
{
|
|
49
|
+
return (*exporter)->addProperty(name, notifierSignal).index();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#include "qmlbind/interface.h"
|
|
2
|
+
#include "util.h"
|
|
3
|
+
#include "interface.h"
|
|
4
|
+
|
|
5
|
+
using namespace QmlBind;
|
|
6
|
+
|
|
7
|
+
extern "C" {
|
|
8
|
+
|
|
9
|
+
qmlbind_interface qmlbind_interface_new(qmlbind_interface_handlers handlers)
|
|
10
|
+
{
|
|
11
|
+
return newSharedPointer(new Interface(handlers));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
void qmlbind_interface_release(qmlbind_interface interface)
|
|
15
|
+
{
|
|
16
|
+
delete interface;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#include "qmlbind/iterator.h"
|
|
2
|
+
#include <QJSValueIterator>
|
|
3
|
+
|
|
4
|
+
qmlbind_iterator qmlbind_iterator_new(qmlbind_value object)
|
|
5
|
+
{
|
|
6
|
+
return new QJSValueIterator(*object);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
void qmlbind_iterator_release(qmlbind_iterator self)
|
|
10
|
+
{
|
|
11
|
+
delete self;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
qmlbind_string qmlbind_iterator_get_key(qmlbind_iterator self)
|
|
15
|
+
{
|
|
16
|
+
return new QByteArray(self->name().toUtf8());
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
qmlbind_value qmlbind_iterator_get_value(qmlbind_iterator self)
|
|
20
|
+
{
|
|
21
|
+
return new QJSValue(self->value());
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
void qmlbind_iterator_next(qmlbind_iterator self)
|
|
25
|
+
{
|
|
26
|
+
self->next();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
int qmlbind_iterator_has_next(qmlbind_iterator self)
|
|
30
|
+
{
|
|
31
|
+
return self->hasNext();
|
|
32
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#include "qmlbind/metaobject.h"
|
|
2
|
+
#include "metaobject.h"
|
|
3
|
+
#include "util.h"
|
|
4
|
+
|
|
5
|
+
using namespace QmlBind;
|
|
6
|
+
|
|
7
|
+
extern "C" {
|
|
8
|
+
|
|
9
|
+
qmlbind_metaobject qmlbind_metaobject_new(qmlbind_exporter exporter)
|
|
10
|
+
{
|
|
11
|
+
return newSharedPointer(new MetaObject(*exporter));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
void qmlbind_metaobject_release(qmlbind_metaobject metaobject)
|
|
15
|
+
{
|
|
16
|
+
delete metaobject;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#include "qmlbind/plugin.h"
|
|
2
|
+
#include "engine.h"
|
|
3
|
+
#include <QPluginLoader>
|
|
4
|
+
|
|
5
|
+
qmlbind_plugin qmlbind_plugin_new(const char *filename)
|
|
6
|
+
{
|
|
7
|
+
return new QPluginLoader(filename);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
void qmlbind_plugin_release(qmlbind_plugin plugin)
|
|
11
|
+
{
|
|
12
|
+
delete plugin;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
qmlbind_string qmlbind_plugin_get_error_string(qmlbind_plugin plugin)
|
|
16
|
+
{
|
|
17
|
+
if (plugin->instance()) {
|
|
18
|
+
return 0;
|
|
19
|
+
} else {
|
|
20
|
+
return new QByteArray(plugin->errorString().toUtf8());
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
qmlbind_value qmlbind_plugin_get_instance(qmlbind_plugin plugin, qmlbind_engine engine)
|
|
25
|
+
{
|
|
26
|
+
return new QJSValue(engine->newQObject(plugin->instance()));
|
|
27
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#include "typeregisterer.h"
|
|
2
|
+
#include "qmlbind/register.h"
|
|
3
|
+
|
|
4
|
+
using namespace QmlBind;
|
|
5
|
+
|
|
6
|
+
extern "C" {
|
|
7
|
+
|
|
8
|
+
int qmlbind_register_type(
|
|
9
|
+
qmlbind_metaobject metaobject,
|
|
10
|
+
const char *uri,
|
|
11
|
+
int versionMajor, int versionMinor,
|
|
12
|
+
const char *qmlName)
|
|
13
|
+
{
|
|
14
|
+
return TypeRegisterer::instance().registerType(*metaobject, uri, versionMajor, versionMinor, qmlName);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
}
|