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
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
$LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__)
|
|
2
|
-
require 'qml'
|
|
3
|
-
require 'open-uri'
|
|
4
|
-
require 'singleton'
|
|
5
|
-
require 'celluloid'
|
|
6
|
-
|
|
7
|
-
module Examples
|
|
8
|
-
module ImageProvider
|
|
9
|
-
|
|
10
|
-
VERSION = '0.1.0'
|
|
11
|
-
|
|
12
|
-
class ImageFetcher
|
|
13
|
-
include Celluloid
|
|
14
|
-
include Singleton
|
|
15
|
-
|
|
16
|
-
def set_url(url)
|
|
17
|
-
@url = url
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def fetch(request)
|
|
21
|
-
image =
|
|
22
|
-
case request.id
|
|
23
|
-
when "image"
|
|
24
|
-
open(@url, 'rb') { |f| f.read } rescue nil
|
|
25
|
-
end
|
|
26
|
-
request.finish(image || "")
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
class Controller
|
|
31
|
-
include QML::Access
|
|
32
|
-
|
|
33
|
-
property :url, ''
|
|
34
|
-
|
|
35
|
-
on_changed :url do
|
|
36
|
-
ImageFetcher.instance.async.set_url url
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
register_to_qml
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
class Provider < QML::ImageProvider
|
|
43
|
-
|
|
44
|
-
def request(req)
|
|
45
|
-
case req.id
|
|
46
|
-
when 'image'
|
|
47
|
-
ImageFetcher.instance.fetch(req)
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
QML.run do |app|
|
|
55
|
-
app.engine.add_image_provider 'example', Examples::ImageProvider::Provider.new
|
|
56
|
-
app.load_path Pathname(__FILE__) + '../main.qml'
|
|
57
|
-
end
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import QtQuick 2.2
|
|
2
|
-
import QtQuick.Controls 1.1
|
|
3
|
-
import QtQuick.Layouts 1.1
|
|
4
|
-
import Examples.ImageProvider 0.1
|
|
5
|
-
|
|
6
|
-
ApplicationWindow {
|
|
7
|
-
visible: true
|
|
8
|
-
width: 200
|
|
9
|
-
height: 200
|
|
10
|
-
|
|
11
|
-
GridLayout {
|
|
12
|
-
anchors.fill: parent
|
|
13
|
-
anchors.margins: 10
|
|
14
|
-
columns: 1
|
|
15
|
-
|
|
16
|
-
Image {
|
|
17
|
-
id: image
|
|
18
|
-
source: 'image://example/image'
|
|
19
|
-
asynchronous: true
|
|
20
|
-
cache: false
|
|
21
|
-
fillMode: Image.Pad
|
|
22
|
-
Layout.fillHeight: true
|
|
23
|
-
|
|
24
|
-
function reload() {
|
|
25
|
-
source = ''
|
|
26
|
-
source = 'image://example/image'
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
GridLayout {
|
|
31
|
-
columns: 2
|
|
32
|
-
|
|
33
|
-
Label {
|
|
34
|
-
text: 'Image URL'
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
TextField {
|
|
38
|
-
id: textField
|
|
39
|
-
Layout.fillWidth: true
|
|
40
|
-
onEditingFinished: {
|
|
41
|
-
image.reload()
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
Controller {
|
|
48
|
-
id: provider
|
|
49
|
-
url: textField.text
|
|
50
|
-
}
|
|
51
|
-
}
|
data/ext/qml/accessclass.cpp
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
#include "accessclass.h"
|
|
2
|
-
#include "accessobject.h"
|
|
3
|
-
#include "util.h"
|
|
4
|
-
#include <QDebug>
|
|
5
|
-
|
|
6
|
-
namespace RubyQml {
|
|
7
|
-
|
|
8
|
-
AccessClass::AccessClass(RubyValue className, RubyValue methodInfos, RubyValue signalInfos, RubyValue propertyInfos)
|
|
9
|
-
{
|
|
10
|
-
setClassName(className.to<QByteArray>());
|
|
11
|
-
rb_check_array_type(methodInfos);
|
|
12
|
-
rb_check_array_type(signalInfos);
|
|
13
|
-
rb_check_array_type(propertyInfos);
|
|
14
|
-
for (int i = 0; i < RARRAY_LEN(VALUE(methodInfos)); ++i) {
|
|
15
|
-
RubyValue info = RARRAY_AREF(VALUE(methodInfos), i);
|
|
16
|
-
auto nameSym = info.send("name");
|
|
17
|
-
addMethod(nameSym.to<QByteArray>(),
|
|
18
|
-
nameSym.toID(),
|
|
19
|
-
info.send("params").to<QList<QByteArray>>());
|
|
20
|
-
}
|
|
21
|
-
for (int i = 0; i < RARRAY_LEN(VALUE(signalInfos)); ++i) {
|
|
22
|
-
RubyValue info = RARRAY_AREF(VALUE(signalInfos), i);
|
|
23
|
-
auto nameSym = info.send("name");
|
|
24
|
-
addSignal(nameSym.to<QByteArray>(),
|
|
25
|
-
nameSym.toID(),
|
|
26
|
-
info.send("params").to<QList<QByteArray>>());
|
|
27
|
-
}
|
|
28
|
-
for (int i = 0; i < RARRAY_LEN(VALUE(propertyInfos)); ++i) {
|
|
29
|
-
RubyValue info = RARRAY_AREF(VALUE(propertyInfos), i);
|
|
30
|
-
addProperty(info.send("name").to<QByteArray>(),
|
|
31
|
-
info.send("getter").toID(),
|
|
32
|
-
info.send("setter").toID(),
|
|
33
|
-
Property::Flag::Readable | Property::Flag::Writable,
|
|
34
|
-
true,
|
|
35
|
-
info.send("notifier").toID());
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
QVariant AccessClass::callMethod(ForeignObject *obj, size_t id, const QVariantList &args)
|
|
40
|
-
{
|
|
41
|
-
auto self = static_cast<AccessWrapper *>(obj)->wrappedValue();
|
|
42
|
-
QVariant ret;
|
|
43
|
-
withGvl([&] {
|
|
44
|
-
std::vector<VALUE> values(args.size());
|
|
45
|
-
std::transform(args.begin(), args.end(), values.begin(), &RubyValue::from<QVariant>);
|
|
46
|
-
RubyValue retValue;
|
|
47
|
-
rescueNotify([&] {
|
|
48
|
-
retValue = rb_funcall2(self, id, values.size(), values.data());
|
|
49
|
-
});
|
|
50
|
-
ret = retValue.to<QVariant>();
|
|
51
|
-
});
|
|
52
|
-
return ret;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
void AccessClass::setProperty(ForeignObject *obj, size_t id, const QVariant &variant)
|
|
56
|
-
{
|
|
57
|
-
callMethod(obj, id, {variant});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
QVariant AccessClass::getProperty(ForeignObject *obj, size_t id)
|
|
61
|
-
{
|
|
62
|
-
return callMethod(obj, id, {});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
} // namespace RubyQml
|
data/ext/qml/accessclass.h
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
#include "foreignclass.h"
|
|
3
|
-
#include "rubyvalue.h"
|
|
4
|
-
|
|
5
|
-
namespace RubyQml {
|
|
6
|
-
|
|
7
|
-
class AccessWrapper;
|
|
8
|
-
|
|
9
|
-
class AccessClass : public ForeignClass
|
|
10
|
-
{
|
|
11
|
-
public:
|
|
12
|
-
AccessClass(RubyValue className, RubyValue methodInfos, RubyValue signalInfos, RubyValue propertyInfos);
|
|
13
|
-
|
|
14
|
-
QVariant callMethod(ForeignObject *obj, size_t id, const QVariantList &args) override;
|
|
15
|
-
void setProperty(ForeignObject *obj, size_t id, const QVariant &value) override;
|
|
16
|
-
QVariant getProperty(ForeignObject *obj, size_t id) override;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
} // namespace RubyQml
|
data/ext/qml/accessobject.cpp
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
#include "accessobject.h"
|
|
2
|
-
#include "util.h"
|
|
3
|
-
#include "rubyclass.h"
|
|
4
|
-
#include <QSet>
|
|
5
|
-
|
|
6
|
-
namespace RubyQml {
|
|
7
|
-
|
|
8
|
-
AccessWrapper::AccessWrapper(const SP<ForeignMetaObject> &metaobj, RubyValue value) :
|
|
9
|
-
ForeignObject(metaobj),
|
|
10
|
-
mWrapped(value)
|
|
11
|
-
{
|
|
12
|
-
if (!value.isKindOf(RubyModule::fromPath("QML::Access"))) {
|
|
13
|
-
std::logic_error("wrapping non QML::Access object");
|
|
14
|
-
}
|
|
15
|
-
value.send("access_wrappers").send("push", RubyValue::fromQObject(this, false));
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
AccessWrapper::~AccessWrapper()
|
|
19
|
-
{
|
|
20
|
-
if (mWrapped.hasValue()) {
|
|
21
|
-
mWrapped.value().send("access_wrappers").send("delete", RubyValue::fromQObject(this, false));
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
void AccessWrapper::gc_mark()
|
|
26
|
-
{
|
|
27
|
-
rb_gc_mark(mWrapped.value());
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
} // namespace RubyQml
|
data/ext/qml/accessobject.h
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
#include "weakvaluereference.h"
|
|
3
|
-
#include "foreignobject.h"
|
|
4
|
-
#include "markable.h"
|
|
5
|
-
|
|
6
|
-
namespace RubyQml {
|
|
7
|
-
|
|
8
|
-
class AccessWrapper : public ForeignObject, public Markable
|
|
9
|
-
{
|
|
10
|
-
public:
|
|
11
|
-
AccessWrapper(const SP<ForeignMetaObject> &metaobj, RubyValue wrappedValue);
|
|
12
|
-
~AccessWrapper();
|
|
13
|
-
|
|
14
|
-
RubyValue wrappedValue() { return mWrapped.value(); }
|
|
15
|
-
void gc_mark() override;
|
|
16
|
-
|
|
17
|
-
private:
|
|
18
|
-
WeakValueReference mWrapped;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
} // namespace RubyQml
|
|
22
|
-
|
data/ext/qml/common.h
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
#include <memory>
|
|
3
|
-
|
|
4
|
-
namespace RubyQml {
|
|
5
|
-
|
|
6
|
-
template <typename T>
|
|
7
|
-
using SP = std::shared_ptr<T>;
|
|
8
|
-
|
|
9
|
-
template <typename T>
|
|
10
|
-
using WP = std::weak_ptr<T>;
|
|
11
|
-
|
|
12
|
-
template <typename T, typename ... Args>
|
|
13
|
-
inline SP<T> makeSP(Args && ... args)
|
|
14
|
-
{
|
|
15
|
-
return std::make_shared<T>(std::forward<Args>(args)...);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
} // namespace RubyQml
|
data/ext/qml/conversionerror.h
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
#include "ext_accesswrapperfactory.h"
|
|
2
|
-
#include "ext_pointer.h"
|
|
3
|
-
#include "rubyclass.h"
|
|
4
|
-
#include "accessclass.h"
|
|
5
|
-
#include "accessobject.h"
|
|
6
|
-
#include "foreignmetaobject.h"
|
|
7
|
-
#include "qmltyperegisterer.h"
|
|
8
|
-
|
|
9
|
-
namespace RubyQml {
|
|
10
|
-
|
|
11
|
-
Ext_AccessWrapperFactory::Ext_AccessWrapperFactory(RubyValue self) :
|
|
12
|
-
self(self)
|
|
13
|
-
{
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
Ext_AccessWrapperFactory::~Ext_AccessWrapperFactory()
|
|
17
|
-
{
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
RubyValue Ext_AccessWrapperFactory::ext_initialize(RubyValue rubyClass, RubyValue className, RubyValue methodInfos, RubyValue signalInfos, RubyValue propertyInfos)
|
|
21
|
-
{
|
|
22
|
-
mRubyClass = rubyClass;
|
|
23
|
-
mAccessClass = makeSP<AccessClass>(className, methodInfos, signalInfos, propertyInfos);
|
|
24
|
-
mMetaObject = makeSP<ForeignMetaObject>(mAccessClass);
|
|
25
|
-
return self;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
RubyValue Ext_AccessWrapperFactory::ext_emitSignal(RubyValue obj, RubyValue name, RubyValue args)
|
|
29
|
-
{
|
|
30
|
-
auto accessObj = wrapperRubyClass<Ext_Pointer>().unwrap(obj.send("access_object"))->fetchQObject();
|
|
31
|
-
auto nameId = name.toID();
|
|
32
|
-
auto argVariants = args.to<QVariantList>();
|
|
33
|
-
withoutGvl([&] {
|
|
34
|
-
mMetaObject->emitSignal(dynamic_cast<ForeignObject *>(accessObj), nameId, argVariants);
|
|
35
|
-
});
|
|
36
|
-
return Qnil;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
RubyValue Ext_AccessWrapperFactory::ext_registerToQml(RubyValue path, RubyValue majorVersion, RubyValue minorVersion, RubyValue name)
|
|
40
|
-
{
|
|
41
|
-
using namespace std::placeholders;
|
|
42
|
-
if (!mTypeRegisterer) {
|
|
43
|
-
mTypeRegisterer = makeSP<QmlTypeRegisterer>(mMetaObject, std::bind(&Ext_AccessWrapperFactory::newInstanceInto, this, _1));
|
|
44
|
-
mTypeRegisterer->registerType(path.to<QByteArray>(), majorVersion.to<int>(), minorVersion.to<int>(), name.to<QByteArray>());
|
|
45
|
-
}
|
|
46
|
-
return self;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
RubyValue Ext_AccessWrapperFactory::ext_create(RubyValue access)
|
|
50
|
-
{
|
|
51
|
-
return RubyValue::fromQObject(create(access), false);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
AccessWrapper *Ext_AccessWrapperFactory::create(RubyValue access)
|
|
55
|
-
{
|
|
56
|
-
return new AccessWrapper(mMetaObject, access);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
void Ext_AccessWrapperFactory::newInstanceInto(void *where)
|
|
60
|
-
{
|
|
61
|
-
withGvl([&] {
|
|
62
|
-
new(where) AccessWrapper(mMetaObject, mRubyClass.send("new"));
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
void Ext_AccessWrapperFactory::defineClass()
|
|
67
|
-
{
|
|
68
|
-
WrapperRubyClass<Ext_AccessWrapperFactory> klass(RubyModule::fromPath("QML"), "AccessWrapperFactory");
|
|
69
|
-
klass.defineMethod(MethodAccess::Protected, "initialize", RUBYQML_MEMBER_FUNCTION_INFO(&Ext_AccessWrapperFactory::ext_initialize));
|
|
70
|
-
klass.defineMethod("emit_signal", RUBYQML_MEMBER_FUNCTION_INFO(&Ext_AccessWrapperFactory::ext_emitSignal));
|
|
71
|
-
klass.defineMethod("register_to_qml", RUBYQML_MEMBER_FUNCTION_INFO(&Ext_AccessWrapperFactory::ext_registerToQml));
|
|
72
|
-
klass.defineMethod("create", RUBYQML_MEMBER_FUNCTION_INFO(&Ext_AccessWrapperFactory::ext_create));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
} // namespace RubyQml
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
#include "common.h"
|
|
3
|
-
#include "rubyvalue.h"
|
|
4
|
-
|
|
5
|
-
namespace RubyQml {
|
|
6
|
-
|
|
7
|
-
class AccessClass;
|
|
8
|
-
class ForeignMetaObject;
|
|
9
|
-
class QmlTypeRegisterer;
|
|
10
|
-
class AccessWrapper;
|
|
11
|
-
|
|
12
|
-
class Ext_AccessWrapperFactory
|
|
13
|
-
{
|
|
14
|
-
public:
|
|
15
|
-
Ext_AccessWrapperFactory(RubyValue self);
|
|
16
|
-
~Ext_AccessWrapperFactory();
|
|
17
|
-
|
|
18
|
-
RubyValue ext_initialize(RubyValue rubyClass, RubyValue className, RubyValue methodInfos, RubyValue signalInfos, RubyValue propertyInfos);
|
|
19
|
-
RubyValue ext_emitSignal(RubyValue obj, RubyValue name, RubyValue args);
|
|
20
|
-
RubyValue ext_registerToQml(RubyValue path, RubyValue majorVersion, RubyValue minorVersion, RubyValue name);
|
|
21
|
-
RubyValue ext_create(RubyValue access);
|
|
22
|
-
|
|
23
|
-
AccessWrapper *create(RubyValue access);
|
|
24
|
-
|
|
25
|
-
void gc_mark() {}
|
|
26
|
-
static void defineClass();
|
|
27
|
-
|
|
28
|
-
private:
|
|
29
|
-
|
|
30
|
-
void newInstanceInto(void *where);
|
|
31
|
-
|
|
32
|
-
const RubyValue self;
|
|
33
|
-
RubyValue mRubyClass;
|
|
34
|
-
SP<AccessClass> mAccessClass;
|
|
35
|
-
SP<ForeignMetaObject> mMetaObject;
|
|
36
|
-
SP<QmlTypeRegisterer> mTypeRegisterer;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
} // namespace RubyQml
|
data/ext/qml/ext_anywrapper.cpp
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
#include "ext_anywrapper.h"
|
|
2
|
-
#include "rubyclass.h"
|
|
3
|
-
|
|
4
|
-
namespace RubyQml {
|
|
5
|
-
|
|
6
|
-
Ext_AnyWrapper::Ext_AnyWrapper(RubyValue self)
|
|
7
|
-
{
|
|
8
|
-
Q_UNUSED(self);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
RubyValue Ext_AnyWrapper::create(const QVariant &value, void (*markFunction)(const QVariant &))
|
|
12
|
-
{
|
|
13
|
-
auto klass = wrapperRubyClass<Ext_AnyWrapper>();
|
|
14
|
-
auto wrapper = klass.newInstance();
|
|
15
|
-
auto ptr = klass.unwrap(wrapper);
|
|
16
|
-
ptr->mValue = value;
|
|
17
|
-
ptr->mMarkFunction = markFunction;
|
|
18
|
-
return wrapper;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
void Ext_AnyWrapper::defineClass()
|
|
22
|
-
{
|
|
23
|
-
WrapperRubyClass<Ext_AnyWrapper> klass(RubyModule::fromPath("QML"), "AnyWrapper");
|
|
24
|
-
Q_UNUSED(klass);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
void Ext_AnyWrapper::gc_mark()
|
|
28
|
-
{
|
|
29
|
-
if (mMarkFunction) {
|
|
30
|
-
mMarkFunction(mValue);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
} // namespace RubyQml
|
data/ext/qml/ext_anywrapper.h
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
#include <QVariant>
|
|
3
|
-
|
|
4
|
-
namespace RubyQml {
|
|
5
|
-
|
|
6
|
-
class RubyValue;
|
|
7
|
-
|
|
8
|
-
class Ext_AnyWrapper
|
|
9
|
-
{
|
|
10
|
-
public:
|
|
11
|
-
Ext_AnyWrapper(RubyValue self);
|
|
12
|
-
static RubyValue create(const QVariant &value, void (*markFunction)(const QVariant &) = nullptr);
|
|
13
|
-
static void defineClass();
|
|
14
|
-
|
|
15
|
-
QVariant value() const { return mValue; }
|
|
16
|
-
void gc_mark();
|
|
17
|
-
|
|
18
|
-
private:
|
|
19
|
-
QVariant mValue;
|
|
20
|
-
void (*mMarkFunction)(const QVariant &);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
} // namespace RubyQml
|