qml 0.0.7 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/ext/qml/valuereference.cpp
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
#include "valuereference.h"
|
2
|
-
#include <QSet>
|
3
|
-
|
4
|
-
namespace RubyQml {
|
5
|
-
|
6
|
-
using ReferenceCounts = QHash<RubyValue, int>;
|
7
|
-
Q_GLOBAL_STATIC(ReferenceCounts, referenceCounts)
|
8
|
-
|
9
|
-
struct ValueReference::Owner
|
10
|
-
{
|
11
|
-
Owner(RubyValue value) :
|
12
|
-
value(value)
|
13
|
-
{
|
14
|
-
auto &refCounts = *referenceCounts;
|
15
|
-
if (!refCounts.contains(value)) {
|
16
|
-
refCounts[value] = 0;
|
17
|
-
}
|
18
|
-
refCounts[value] += 1;
|
19
|
-
}
|
20
|
-
~Owner()
|
21
|
-
{
|
22
|
-
auto &refCounts = *referenceCounts;
|
23
|
-
refCounts[value] -= 1;
|
24
|
-
if (refCounts[value] == 0) {
|
25
|
-
refCounts.remove(value);
|
26
|
-
}
|
27
|
-
}
|
28
|
-
RubyValue value;
|
29
|
-
};
|
30
|
-
|
31
|
-
ValueReference::ValueReference(RubyValue value) :
|
32
|
-
mOwner(makeSP<Owner>(value))
|
33
|
-
{
|
34
|
-
}
|
35
|
-
|
36
|
-
RubyValue ValueReference::value() const
|
37
|
-
{
|
38
|
-
return mOwner->value;
|
39
|
-
}
|
40
|
-
|
41
|
-
void ValueReference::markAllReferences()
|
42
|
-
{
|
43
|
-
auto begin = referenceCounts->begin();
|
44
|
-
auto end = referenceCounts->end();
|
45
|
-
for (auto i = begin; i != end; ++i) {
|
46
|
-
rb_gc_mark(i.key());
|
47
|
-
}
|
48
|
-
}
|
49
|
-
|
50
|
-
} // namespace RubyQml
|
data/ext/qml/valuereference.h
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
#include "rubyvalue.h"
|
3
|
-
#include "common.h"
|
4
|
-
|
5
|
-
namespace RubyQml {
|
6
|
-
|
7
|
-
class ValueReference
|
8
|
-
{
|
9
|
-
public:
|
10
|
-
ValueReference() = default;
|
11
|
-
ValueReference(RubyValue value);
|
12
|
-
|
13
|
-
RubyValue value() const;
|
14
|
-
|
15
|
-
static void markAllReferences();
|
16
|
-
|
17
|
-
private:
|
18
|
-
struct Owner;
|
19
|
-
SP<Owner> mOwner;
|
20
|
-
};
|
21
|
-
|
22
|
-
} // namespace RubyQml
|
@@ -1,51 +0,0 @@
|
|
1
|
-
#include "weakvaluereference.h"
|
2
|
-
#include "ext_anywrapper.h"
|
3
|
-
#include "rubyclass.h"
|
4
|
-
|
5
|
-
Q_DECLARE_METATYPE(std::shared_ptr<RubyQml::WeakValueReference::Data>)
|
6
|
-
|
7
|
-
namespace RubyQml {
|
8
|
-
|
9
|
-
struct WeakValueReference::Data
|
10
|
-
{
|
11
|
-
bool mHasValue;
|
12
|
-
RubyValue mValue;
|
13
|
-
|
14
|
-
static VALUE finalize(VALUE args, VALUE data) {
|
15
|
-
Q_UNUSED(args);
|
16
|
-
auto variant = wrapperRubyClass<Ext_AnyWrapper>().unwrap(data)->value();
|
17
|
-
auto sp = variant.value<std::shared_ptr<Data>>();
|
18
|
-
sp->invalidiate();
|
19
|
-
return Qnil;
|
20
|
-
}
|
21
|
-
|
22
|
-
void invalidiate()
|
23
|
-
{
|
24
|
-
mHasValue = false;
|
25
|
-
mValue = Qnil;
|
26
|
-
}
|
27
|
-
};
|
28
|
-
|
29
|
-
WeakValueReference::WeakValueReference(RubyValue value) :
|
30
|
-
d(std::make_shared<Data>())
|
31
|
-
{
|
32
|
-
d->mHasValue = true;
|
33
|
-
d->mValue = value;
|
34
|
-
static auto objspace = RubyModule::fromPath("ObjectSpace");
|
35
|
-
|
36
|
-
auto proc = rb_proc_new((VALUE (*)(...))&Data::finalize, Ext_AnyWrapper::create(QVariant::fromValue(d)));
|
37
|
-
VALUE args[] = { value };
|
38
|
-
rb_funcall_with_block(objspace, RUBYQML_INTERN("define_finalizer"), 1, args, proc);
|
39
|
-
}
|
40
|
-
|
41
|
-
bool WeakValueReference::hasValue() const
|
42
|
-
{
|
43
|
-
return d->mHasValue;
|
44
|
-
}
|
45
|
-
|
46
|
-
RubyValue WeakValueReference::value() const
|
47
|
-
{
|
48
|
-
return d->mValue;
|
49
|
-
}
|
50
|
-
|
51
|
-
} // namespace RubyQml
|
@@ -1,21 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
#include "rubyvalue.h"
|
3
|
-
#include <memory>
|
4
|
-
|
5
|
-
namespace RubyQml {
|
6
|
-
|
7
|
-
class WeakValueReference
|
8
|
-
{
|
9
|
-
public:
|
10
|
-
WeakValueReference(RubyValue value);
|
11
|
-
|
12
|
-
bool hasValue() const;
|
13
|
-
RubyValue value() const;
|
14
|
-
|
15
|
-
struct Data;
|
16
|
-
|
17
|
-
private:
|
18
|
-
std::shared_ptr<Data> d;
|
19
|
-
};
|
20
|
-
|
21
|
-
} // namespace RubyQml
|
data/lib/qml/context.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'qml/qt_classes'
|
2
|
-
|
3
|
-
module QML
|
4
|
-
# @!parse class Context < QtObjectBase; end
|
5
|
-
|
6
|
-
# {Context} represents QML contexts and used to expose Ruby values to QML.
|
7
|
-
# Each context has values that is called "context properties" that can be accessed in QML by their names.
|
8
|
-
#
|
9
|
-
# This class is automatically created from QQmlContext (C++).
|
10
|
-
# @see http://qt-project.org/doc/qt-5/qqmlcontext.html QQmlContext(C++)
|
11
|
-
#
|
12
|
-
# @example
|
13
|
-
# QML.run do |app|
|
14
|
-
# app.context[:foo] = 'foo'
|
15
|
-
# app.context[:bar] = 'bar'
|
16
|
-
# ...
|
17
|
-
# end
|
18
|
-
class Context
|
19
|
-
|
20
|
-
# Creates a new instance of {Context}.
|
21
|
-
def self.new
|
22
|
-
Plugins.core.createContext(Engine.instance)
|
23
|
-
end
|
24
|
-
|
25
|
-
def initialize
|
26
|
-
super()
|
27
|
-
@extension = Plugins.core.createContextExtension(self)
|
28
|
-
@context_properties = {}
|
29
|
-
end
|
30
|
-
|
31
|
-
# Evaluates an JavaScript expression on the object in this context.
|
32
|
-
# @param obj The object the expression is evaluated on
|
33
|
-
# @param str The JavaScript expression string
|
34
|
-
# @see QtObjectBase#qml_eval
|
35
|
-
def eval(obj, str)
|
36
|
-
@extension.evaluate(obj, str)
|
37
|
-
end
|
38
|
-
|
39
|
-
# Sets a context property.
|
40
|
-
# @param key [String|Symbol] The property key
|
41
|
-
# @param value The value
|
42
|
-
# @return The value
|
43
|
-
def []=(key, value)
|
44
|
-
# be sure that the value is managed when it is a QObject
|
45
|
-
value = value.create_wrapper if value.is_a? Wrappable
|
46
|
-
value.prefer_managed true if value.is_a? QtObjectBase
|
47
|
-
|
48
|
-
# hold referenece because QQmlContext::setContextProperty does not take ownership of objects
|
49
|
-
@context_properties[key] = value
|
50
|
-
|
51
|
-
@extension.setContextProperty(key, value)
|
52
|
-
value
|
53
|
-
end
|
54
|
-
|
55
|
-
# Gets a context property.
|
56
|
-
# @param key [String|Symbol] The property key
|
57
|
-
# @return The value
|
58
|
-
def [](key)
|
59
|
-
@extension.contextProperty(key)
|
60
|
-
end
|
61
|
-
|
62
|
-
# Gets a context that an object belongs to. If the object belongs to no context, returns nil.
|
63
|
-
# @param obj
|
64
|
-
# @return [Context|nil]
|
65
|
-
def self.for_object(obj)
|
66
|
-
Plugins.core.contextForObject(obj).tap do |context|
|
67
|
-
context.managed = false if context
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
data/lib/qml/data/error.rb
DELETED
data/lib/qml/dispatchable.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
module QML
|
2
|
-
|
3
|
-
# {Dispatchable} provides a handy way for asynchronous (queued) method calls
|
4
|
-
# which actually processed later in the event loop.
|
5
|
-
# @see QML.later
|
6
|
-
module Dispatchable
|
7
|
-
|
8
|
-
class Proxy < BasicObject
|
9
|
-
def initialize(obj)
|
10
|
-
@obj = obj
|
11
|
-
end
|
12
|
-
|
13
|
-
# Actually enqueues the method call using {QML.later}.
|
14
|
-
def method_missing(name, *args, &block)
|
15
|
-
::QML.later do
|
16
|
-
@obj.__send__(name, *args, &block)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# Returns a proxy object for calling a method asynchronously within the event loop.
|
22
|
-
# @return [Proxy]
|
23
|
-
# @example
|
24
|
-
# def on_button_clicked
|
25
|
-
# Thread.new do
|
26
|
-
# result = do_task
|
27
|
-
# later.set_result_to_ui(result)
|
28
|
-
# end
|
29
|
-
# end
|
30
|
-
def later
|
31
|
-
Proxy.new(self)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
data/lib/qml/error_converter.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
module QML
|
2
|
-
module ErrorConverter
|
3
|
-
|
4
|
-
class << self
|
5
|
-
attr_reader :patterns
|
6
|
-
|
7
|
-
def add_pattern(cpp_classname, ruby_class)
|
8
|
-
@patterns ||= {}
|
9
|
-
@patterns[cpp_classname] = ruby_class
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
add_pattern 'RubyQml::QmlException', QMLError
|
14
|
-
add_pattern 'RubyQml::ConversionError', ConversionError
|
15
|
-
end
|
16
|
-
end
|
data/lib/qml/geometry.rb
DELETED
data/lib/qml/geometry/point.rb
DELETED
data/lib/qml/geometry/size.rb
DELETED
data/lib/qml/image_provider.rb
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
require 'qml/access'
|
2
|
-
|
3
|
-
module QML
|
4
|
-
|
5
|
-
# {ImageProvider} is used to provide images manually to QML.
|
6
|
-
#
|
7
|
-
# QML requests images to ImageProviders when you use "image:" URL scheme
|
8
|
-
# (like "image://my_image_provider/foo.png") in source specification of Image elements.
|
9
|
-
#
|
10
|
-
# @example
|
11
|
-
# class MyImageProvider < QML::ImageProvider
|
12
|
-
# def request(req)
|
13
|
-
# Thread.new do
|
14
|
-
# image_data = load_image_data()
|
15
|
-
# req.finish(image_data)
|
16
|
-
# end
|
17
|
-
# end
|
18
|
-
# end
|
19
|
-
# QML.engine.add_image_provider(MyImageProvider.new)
|
20
|
-
#
|
21
|
-
# @see Engine#add_image_provider
|
22
|
-
# @see http://qt-project.org/doc/qt-5/qquickimageprovider.html QQuickImageProvider (C++)
|
23
|
-
# @see http://qt-project.org/doc/qt-5/qml-qtquick-image.html Image (QML)
|
24
|
-
|
25
|
-
class ImageProvider
|
26
|
-
|
27
|
-
# {Request} represents a image request from QML.
|
28
|
-
# @see ImageProvider#request
|
29
|
-
class Request
|
30
|
-
# The image ID.
|
31
|
-
# If you requested "image://my_image_provider/foo/bar.png", the ID would be "foo/bar.png".
|
32
|
-
attr_reader :id
|
33
|
-
|
34
|
-
# Finishes the image request.
|
35
|
-
# @param data [String] The image file data
|
36
|
-
def finish(data)
|
37
|
-
fail ::TypeError, "data must be a String" unless data.is_a? ::String
|
38
|
-
QML.later do
|
39
|
-
@promise.set_data(data)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
def initialize(id, promise)
|
46
|
-
@id = id;
|
47
|
-
@promise = promise
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
attr_reader :qt_image_provider
|
52
|
-
|
53
|
-
def initialize
|
54
|
-
@callback = Callback.new(self)
|
55
|
-
@qt_image_provider = Plugins.core.createImageProvider(@callback)
|
56
|
-
@qt_image_provider.prefer_managed false
|
57
|
-
end
|
58
|
-
|
59
|
-
# @abstract
|
60
|
-
# @param req [Request]
|
61
|
-
#
|
62
|
-
# Implement this method to handle image requests from QML.
|
63
|
-
#
|
64
|
-
# Call {Request#finish} to finish image loading.
|
65
|
-
# Image loading should be done asynchnorously because this method is called within the event loop.
|
66
|
-
|
67
|
-
def request(req)
|
68
|
-
fail ::NotImplementedError
|
69
|
-
end
|
70
|
-
|
71
|
-
private
|
72
|
-
|
73
|
-
class Callback
|
74
|
-
include QML::Access
|
75
|
-
|
76
|
-
def initialize(provider)
|
77
|
-
super()
|
78
|
-
@provider = provider
|
79
|
-
end
|
80
|
-
|
81
|
-
def request(id, promise)
|
82
|
-
promise.prefer_managed true
|
83
|
-
@provider.request(Request.new(id, promise))
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
data/lib/qml/init.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
module QML
|
2
|
-
|
3
|
-
# @return [Boolean] whether {#init} is already called.
|
4
|
-
def initialized?
|
5
|
-
Kernel.initialized?
|
6
|
-
end
|
7
|
-
|
8
|
-
# Initializes ruby-qml.
|
9
|
-
# @param [Hash] opts
|
10
|
-
# @option opts [Boolean] :offscreen (false) set this to true to run application offscreen (without GUI)
|
11
|
-
def init(opts = {})
|
12
|
-
opts = {offscreen: false}.merge opts
|
13
|
-
fail AlreadyInitializedError, "ruby-qml already initialized" if initialized?
|
14
|
-
argv = [$PROGRAM_NAME]
|
15
|
-
argv += %w{-platform offscreen} if opts[:offscreen]
|
16
|
-
Kernel.init(argv)
|
17
|
-
@on_init.each(&:call)
|
18
|
-
end
|
19
|
-
|
20
|
-
@on_init = []
|
21
|
-
|
22
|
-
# Registers a block to be called just after {#init} is called.
|
23
|
-
# @yield
|
24
|
-
def on_init(&block)
|
25
|
-
@on_init << block
|
26
|
-
end
|
27
|
-
|
28
|
-
module_function :initialized?, :init, :on_init
|
29
|
-
end
|
data/lib/qml/meta_object.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'qml/qml'
|
2
|
-
require 'qml/qt_object_base'
|
3
|
-
|
4
|
-
module QML
|
5
|
-
class MetaObject
|
6
|
-
alias_method :to_s, :name
|
7
|
-
|
8
|
-
def inspect
|
9
|
-
"<QML::MetaObject:#{self}>"
|
10
|
-
end
|
11
|
-
|
12
|
-
def build_class
|
13
|
-
@@classes ||= {}
|
14
|
-
klass = @@classes[name]
|
15
|
-
builder = QtObjectBase::SubclassBuilder.new(self, klass)
|
16
|
-
builder.build
|
17
|
-
@@classes[name] = builder.subclass
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|