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,21 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <QObject>
|
|
4
|
+
|
|
5
|
+
class TestPlugin : public QObject
|
|
6
|
+
{
|
|
7
|
+
Q_OBJECT
|
|
8
|
+
#if QT_VERSION >= 0x050000
|
|
9
|
+
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "testplugin.json")
|
|
10
|
+
#endif // QT_VERSION >= 0x050000
|
|
11
|
+
|
|
12
|
+
Q_PROPERTY(int test READ test)
|
|
13
|
+
|
|
14
|
+
public:
|
|
15
|
+
TestPlugin(QObject *parent = 0);
|
|
16
|
+
|
|
17
|
+
int test() const
|
|
18
|
+
{
|
|
19
|
+
return 12345;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#-------------------------------------------------
|
|
2
|
+
#
|
|
3
|
+
# Project created by QtCreator 2015-05-16T02:03:07
|
|
4
|
+
#
|
|
5
|
+
#-------------------------------------------------
|
|
6
|
+
|
|
7
|
+
QT += core gui
|
|
8
|
+
|
|
9
|
+
TARGET = testplugin
|
|
10
|
+
TEMPLATE = lib
|
|
11
|
+
CONFIG += plugin
|
|
12
|
+
|
|
13
|
+
SOURCES += testplugin.cpp
|
|
14
|
+
|
|
15
|
+
HEADERS += testplugin.h
|
|
16
|
+
DISTFILES += testplugin.json
|
|
17
|
+
|
|
18
|
+
unix {
|
|
19
|
+
target.path = /usr/lib
|
|
20
|
+
INSTALLS += target
|
|
21
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#include "meta_object.h"
|
|
2
|
+
#include "engine.h"
|
|
3
|
+
#include "conversion.h"
|
|
4
|
+
|
|
5
|
+
VALUE rbqml_cMetaObject;
|
|
6
|
+
|
|
7
|
+
typedef struct {
|
|
8
|
+
qmlbind_metaobject metaobject;
|
|
9
|
+
} metaobject;
|
|
10
|
+
|
|
11
|
+
static void metaobject_free(void *p) {
|
|
12
|
+
metaobject *data = p;
|
|
13
|
+
|
|
14
|
+
rb_thread_call_without_gvl((void *(*)(void *))&qmlbind_metaobject_release, data->metaobject, RUBY_UBF_IO, NULL);
|
|
15
|
+
xfree(data);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static const rb_data_type_t data_type = {
|
|
19
|
+
"QML::MetaObject",
|
|
20
|
+
{ NULL, metaobject_free }
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
qmlbind_metaobject rbqml_get_metaobject(VALUE self) {
|
|
24
|
+
metaobject *data;
|
|
25
|
+
TypedData_Get_Struct(self, metaobject, &data_type, data);
|
|
26
|
+
return data->metaobject;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static VALUE metaobject_alloc(VALUE klass) {
|
|
30
|
+
metaobject *data = ALLOC(metaobject);
|
|
31
|
+
data->metaobject = NULL;
|
|
32
|
+
return TypedData_Wrap_Struct(klass, &data_type, data);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
VALUE rbqml_metaobject_new(qmlbind_metaobject metaobj) {
|
|
36
|
+
VALUE self = metaobject_alloc(rbqml_cMetaObject);
|
|
37
|
+
metaobject *data;
|
|
38
|
+
TypedData_Get_Struct(self, metaobject, &data_type, data);
|
|
39
|
+
data->metaobject = metaobj;
|
|
40
|
+
return self;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
typedef struct {
|
|
44
|
+
qmlbind_engine engine;
|
|
45
|
+
qmlbind_metaobject metaobject;
|
|
46
|
+
qmlbind_backref backref;
|
|
47
|
+
} wrap_data;
|
|
48
|
+
|
|
49
|
+
void *wrap_impl(void *p) {
|
|
50
|
+
wrap_data *data = p;
|
|
51
|
+
return qmlbind_engine_new_wrapper(data->engine, data->metaobject, data->backref);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
VALUE metaobject_wrap(VALUE self, VALUE access) {
|
|
55
|
+
wrap_data data;
|
|
56
|
+
data.engine = rbqml_get_engine(rbqml_engine);
|
|
57
|
+
data.metaobject = rbqml_get_metaobject(self);
|
|
58
|
+
data.backref = (qmlbind_backref)access;
|
|
59
|
+
|
|
60
|
+
qmlbind_value wrapped = rb_thread_call_without_gvl(wrap_impl, &data, RUBY_UBF_IO, NULL);
|
|
61
|
+
return rbqml_to_ruby(wrapped);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static VALUE metaobject_register(VALUE self, VALUE uri, VALUE versionMajor, VALUE versionMinor, VALUE qmlName) {
|
|
65
|
+
qmlbind_metaobject metaobj = rbqml_get_metaobject(self);
|
|
66
|
+
qmlbind_register_type(
|
|
67
|
+
metaobj,
|
|
68
|
+
rb_string_value_cstr(&uri),
|
|
69
|
+
NUM2INT(versionMajor), NUM2INT(versionMinor),
|
|
70
|
+
rb_string_value_cstr(&qmlName));
|
|
71
|
+
return self;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
void rbqml_init_meta_object(void) {
|
|
75
|
+
VALUE mQML = rb_define_module("QML");
|
|
76
|
+
rbqml_cMetaObject = rb_define_class_under(mQML, "MetaObject", rb_cObject);
|
|
77
|
+
|
|
78
|
+
rb_define_alloc_func(rbqml_cMetaObject, metaobject_alloc);
|
|
79
|
+
rb_define_method(rbqml_cMetaObject, "wrap", metaobject_wrap, 1);
|
|
80
|
+
rb_define_method(rbqml_cMetaObject, "register", metaobject_register, 4);
|
|
81
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#include "plugin_loader.h"
|
|
2
|
+
#include "engine.h"
|
|
3
|
+
#include "conversion.h"
|
|
4
|
+
|
|
5
|
+
static VALUE cPluginError;
|
|
6
|
+
VALUE rbqml_cPluginLoader;
|
|
7
|
+
|
|
8
|
+
typedef struct {
|
|
9
|
+
qmlbind_plugin plugin;
|
|
10
|
+
} plugin_loader_t;
|
|
11
|
+
|
|
12
|
+
static void plugin_loader_free(void *p) {
|
|
13
|
+
plugin_loader_t *data = (plugin_loader_t*)p;
|
|
14
|
+
qmlbind_plugin_release(data->plugin);
|
|
15
|
+
xfree(data);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static const rb_data_type_t data_type = {
|
|
19
|
+
"QML::PluginLoader",
|
|
20
|
+
{ NULL, &plugin_loader_free }
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
qmlbind_plugin rbqml_get_plugin(VALUE self) {
|
|
24
|
+
plugin_loader_t *data;
|
|
25
|
+
TypedData_Get_Struct(self, plugin_loader_t, &data_type, data);
|
|
26
|
+
return data->plugin;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static VALUE plugin_loader_alloc(VALUE klass) {
|
|
30
|
+
plugin_loader_t *data = ALLOC(plugin_loader_t);
|
|
31
|
+
data->plugin = NULL;
|
|
32
|
+
return TypedData_Wrap_Struct(klass, &data_type, data);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static VALUE plugin_loader_init(VALUE self, VALUE path) {
|
|
36
|
+
plugin_loader_t *data;
|
|
37
|
+
TypedData_Get_Struct(self, plugin_loader_t, &data_type, data);
|
|
38
|
+
data->plugin = qmlbind_plugin_new(rb_string_value_cstr(&path));
|
|
39
|
+
return self;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/*
|
|
43
|
+
* Loads the plugin and returns the instance of the plugin.
|
|
44
|
+
* @return [QML::JSObject]
|
|
45
|
+
*/
|
|
46
|
+
static VALUE plugin_loader_instance(VALUE self) {
|
|
47
|
+
qmlbind_plugin plugin = rbqml_get_plugin(self);
|
|
48
|
+
|
|
49
|
+
qmlbind_string qmlerror = qmlbind_plugin_get_error_string(plugin);
|
|
50
|
+
if (qmlerror) {
|
|
51
|
+
VALUE errorStr = rb_enc_str_new(qmlbind_string_get_chars(qmlerror), qmlbind_string_get_length(qmlerror), rb_utf8_encoding());
|
|
52
|
+
qmlbind_string_release(qmlerror);
|
|
53
|
+
|
|
54
|
+
VALUE error = rb_funcall(cPluginError, rb_intern("new"), 1, errorStr);
|
|
55
|
+
rb_exc_raise(error);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
qmlbind_value loaded = qmlbind_plugin_get_instance(plugin, rbqml_get_engine(rbqml_engine));
|
|
59
|
+
return rbqml_to_ruby(loaded);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
void rbqml_init_plugin_loader(void) {
|
|
63
|
+
cPluginError = rb_path2class("QML::PluginError");
|
|
64
|
+
|
|
65
|
+
VALUE mQML = rb_define_module("QML");
|
|
66
|
+
rbqml_cPluginLoader = rb_define_class_under(mQML, "PluginLoader", rb_cObject);
|
|
67
|
+
rb_define_alloc_func(rbqml_cPluginLoader, &plugin_loader_alloc);
|
|
68
|
+
|
|
69
|
+
rb_define_private_method(rbqml_cPluginLoader, "initialize_impl", plugin_loader_init, 1);
|
|
70
|
+
rb_define_method(rbqml_cPluginLoader, "instance", plugin_loader_instance, 0);
|
|
71
|
+
}
|
data/ext/qml/qml.c
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#include "qml.h"
|
|
2
|
+
#include "application.h"
|
|
3
|
+
#include "component.h"
|
|
4
|
+
#include "engine.h"
|
|
5
|
+
#include "exporter.h"
|
|
6
|
+
#include "interface.h"
|
|
7
|
+
#include "js_object.h"
|
|
8
|
+
#include "js_array.h"
|
|
9
|
+
#include "js_function.h"
|
|
10
|
+
#include "js_wrapper.h"
|
|
11
|
+
#include "signal_emitter.h"
|
|
12
|
+
#include "plugin_loader.h"
|
|
13
|
+
#include "dispatcher.h"
|
|
14
|
+
#include "meta_object.h"
|
|
15
|
+
|
|
16
|
+
VALUE rbqml_mQML;
|
|
17
|
+
VALUE rbqml_application = Qnil;
|
|
18
|
+
VALUE rbqml_engine = Qnil;
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
* @api private
|
|
22
|
+
*/
|
|
23
|
+
static VALUE qml_init(VALUE module, VALUE args) {
|
|
24
|
+
if (!NIL_P(rbqml_application)) {
|
|
25
|
+
rb_raise(rb_eRuntimeError, "QML already initialized");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
rbqml_application = rb_funcall(rbqml_cApplication, rb_intern("new"), 1, args);
|
|
29
|
+
rbqml_engine = rb_funcall(rbqml_cEngine, rb_intern("new"), 0);
|
|
30
|
+
|
|
31
|
+
rb_gc_register_address(&rbqml_application);
|
|
32
|
+
rb_gc_register_address(&rbqml_engine);
|
|
33
|
+
|
|
34
|
+
VALUE blocks = rb_const_get(module, rb_intern("INIT_BLOCKS"));
|
|
35
|
+
for (int i = 0; i < RARRAY_LEN(blocks); ++i) {
|
|
36
|
+
rb_proc_call(RARRAY_AREF(blocks, i), rb_ary_new());
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return module;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static VALUE qml_initialized_p(VALUE module) {
|
|
43
|
+
if (NIL_P(rbqml_application)) {
|
|
44
|
+
return Qfalse;
|
|
45
|
+
} else {
|
|
46
|
+
return Qtrue;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/*
|
|
51
|
+
* Returns the instance of {Application}.
|
|
52
|
+
* @return [Application]
|
|
53
|
+
*/
|
|
54
|
+
static VALUE qml_application(VALUE module) {
|
|
55
|
+
if (NIL_P(rbqml_application)) {
|
|
56
|
+
rb_raise(rb_eRuntimeError, "QML not yet initialized");
|
|
57
|
+
}
|
|
58
|
+
return rbqml_application;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
* Returns the instance of {Engine}.
|
|
63
|
+
* @return [Engine]
|
|
64
|
+
*/
|
|
65
|
+
static VALUE qml_engine(VALUE module) {
|
|
66
|
+
if (NIL_P(rbqml_engine)) {
|
|
67
|
+
rb_raise(rb_eRuntimeError, "QML not yet initialized");
|
|
68
|
+
}
|
|
69
|
+
return rbqml_engine;
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
void Init_qml(void)
|
|
74
|
+
{
|
|
75
|
+
rbqml_mQML = rb_define_module("QML");
|
|
76
|
+
|
|
77
|
+
rbqml_init_application();
|
|
78
|
+
rbqml_init_engine();
|
|
79
|
+
rbqml_init_component();
|
|
80
|
+
rbqml_init_interface();
|
|
81
|
+
rbqml_init_exporter();
|
|
82
|
+
rbqml_init_js_object();
|
|
83
|
+
rbqml_init_js_array();
|
|
84
|
+
rbqml_init_js_function();
|
|
85
|
+
rbqml_init_js_wrapper();
|
|
86
|
+
rbqml_init_signal_emitter();
|
|
87
|
+
rbqml_init_plugin_loader();
|
|
88
|
+
rbqml_init_dispatcher();
|
|
89
|
+
rbqml_init_meta_object();
|
|
90
|
+
|
|
91
|
+
rb_define_module_function(rbqml_mQML, "initialized?", qml_initialized_p, 0);
|
|
92
|
+
rb_define_module_function(rbqml_mQML, "init_impl", qml_init, 1);
|
|
93
|
+
rb_define_module_function(rbqml_mQML, "application", qml_application, 0);
|
|
94
|
+
rb_define_module_function(rbqml_mQML, "engine", qml_engine, 0);
|
|
95
|
+
}
|
data/ext/qml/qml.h
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#include "listmodel.h"
|
|
2
|
+
#include <QQmlEngine>
|
|
3
|
+
#include <QDebug>
|
|
4
|
+
|
|
5
|
+
namespace RubyQml {
|
|
6
|
+
|
|
7
|
+
static QJSValue callMethod(QJSValue self, const QString &name, const QJSValueList &args)
|
|
8
|
+
{
|
|
9
|
+
QJSValue func = self.property(name);
|
|
10
|
+
return func.callWithInstance(self, args);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
ListModel::ListModel(const QJSValue &rubyModelAccess, QObject *parent) : QAbstractListModel(parent),
|
|
14
|
+
mRubyModelAccess(rubyModelAccess)
|
|
15
|
+
{
|
|
16
|
+
QObject *access = rubyModelAccess.toQObject();
|
|
17
|
+
Q_ASSERT(access);
|
|
18
|
+
QQmlEngine::setObjectOwnership(access, QQmlEngine::CppOwnership);
|
|
19
|
+
access->setParent(this);
|
|
20
|
+
|
|
21
|
+
QVariantList columns = callMethod(rubyModelAccess, "columns", QJSValueList()).toVariant().toList();
|
|
22
|
+
for (int i = 0; i < columns.size(); ++i) {
|
|
23
|
+
mRoleNames[Qt::UserRole + i] = columns[i].toString().toUtf8();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
connect(access, SIGNAL(begin_insert(QJSValue,QJSValue)), this, SLOT(beginInsert(QJSValue,QJSValue)));
|
|
27
|
+
connect(access, SIGNAL(end_insert()), this, SLOT(endInsert()));
|
|
28
|
+
connect(access, SIGNAL(begin_remove(QJSValue,QJSValue)), this, SLOT(beginRemove(QJSValue,QJSValue)));
|
|
29
|
+
connect(access, SIGNAL(end_remove()), this, SLOT(endRemove()));
|
|
30
|
+
connect(access, SIGNAL(begin_move(QJSValue,QJSValue,QJSValue)), this, SLOT(beginMove(QJSValue,QJSValue,QJSValue)));
|
|
31
|
+
connect(access, SIGNAL(end_move()), this, SLOT(endMove()));
|
|
32
|
+
connect(access, SIGNAL(update(QJSValue,QJSValue)), this, SLOT(update(QJSValue,QJSValue)));
|
|
33
|
+
connect(access, SIGNAL(begin_reset()), this, SLOT(beginReset()));
|
|
34
|
+
connect(access, SIGNAL(end_reset()), this, SLOT(endReset()));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
QHash<int, QByteArray> ListModel::roleNames() const
|
|
38
|
+
{
|
|
39
|
+
return mRoleNames;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
QVariant ListModel::data(const QModelIndex &index, int role) const
|
|
43
|
+
{
|
|
44
|
+
QJSValueList args;
|
|
45
|
+
args << index.row();
|
|
46
|
+
args << QString::fromUtf8(mRoleNames[role]);
|
|
47
|
+
return QVariant::fromValue(callMethod(mRubyModelAccess, "data", args));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
int ListModel::rowCount(const QModelIndex &parent) const
|
|
51
|
+
{
|
|
52
|
+
Q_UNUSED(parent);
|
|
53
|
+
return callMethod(mRubyModelAccess, "count", QJSValueList()).toInt();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
void ListModel::beginMove(const QJSValue &first, const QJSValue &last, const QJSValue &destination)
|
|
57
|
+
{
|
|
58
|
+
beginMoveRows(QModelIndex(), first.toInt(), last.toInt(), QModelIndex(), destination.toInt());
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
void ListModel::endMove()
|
|
62
|
+
{
|
|
63
|
+
endMoveRows();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
void ListModel::beginInsert(const QJSValue &first, const QJSValue &last)
|
|
67
|
+
{
|
|
68
|
+
beginInsertRows(QModelIndex(), first.toInt(), last.toInt());
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
void ListModel::endInsert()
|
|
72
|
+
{
|
|
73
|
+
endInsertRows();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
void ListModel::beginRemove(const QJSValue &first, const QJSValue &last)
|
|
77
|
+
{
|
|
78
|
+
beginRemoveRows(QModelIndex(), first.toInt(), last.toInt());
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
void ListModel::endRemove()
|
|
82
|
+
{
|
|
83
|
+
endRemoveRows();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
void ListModel::beginReset()
|
|
87
|
+
{
|
|
88
|
+
beginResetModel();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
void ListModel::endReset()
|
|
92
|
+
{
|
|
93
|
+
endResetModel();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
void ListModel::update(const QJSValue &first, const QJSValue &last)
|
|
97
|
+
{
|
|
98
|
+
emit dataChanged(index(first.toInt()), index(last.toInt()));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
} // namespace RubyQml
|
|
102
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <QAbstractListModel>
|
|
4
|
+
#include <QJSValue>
|
|
5
|
+
|
|
6
|
+
namespace RubyQml {
|
|
7
|
+
|
|
8
|
+
class ListModel : public QAbstractListModel
|
|
9
|
+
{
|
|
10
|
+
Q_OBJECT
|
|
11
|
+
public:
|
|
12
|
+
explicit ListModel(const QJSValue &rubyModelAccess, QObject *parent = 0);
|
|
13
|
+
|
|
14
|
+
QHash<int, QByteArray> roleNames() const;
|
|
15
|
+
QVariant data(const QModelIndex &index, int role) const;
|
|
16
|
+
int rowCount(const QModelIndex &parent) const;
|
|
17
|
+
|
|
18
|
+
signals:
|
|
19
|
+
|
|
20
|
+
public slots:
|
|
21
|
+
void beginMove(const QJSValue &first, const QJSValue &last, const QJSValue &destination);
|
|
22
|
+
void endMove();
|
|
23
|
+
void beginInsert(const QJSValue &first, const QJSValue &last);
|
|
24
|
+
void endInsert();
|
|
25
|
+
void beginRemove(const QJSValue &first, const QJSValue &last);
|
|
26
|
+
void endRemove();
|
|
27
|
+
void beginReset();
|
|
28
|
+
void endReset();
|
|
29
|
+
void update(const QJSValue &first, const QJSValue &last);
|
|
30
|
+
|
|
31
|
+
private:
|
|
32
|
+
|
|
33
|
+
QHash<int, QByteArray> mRoleNames;
|
|
34
|
+
QJSValue mRubyModelAccess;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
} // namespace RubyQml
|