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
@@ -1,345 +0,0 @@
|
|
1
|
-
#include "foreignmetaobject.h"
|
2
|
-
#include "foreignclass.h"
|
3
|
-
#include "foreignobject.h"
|
4
|
-
#include <QQueue>
|
5
|
-
#include <QDebug>
|
6
|
-
#include <QQmlProperty>
|
7
|
-
#include <private/qmetaobject_p.h>
|
8
|
-
|
9
|
-
namespace RubyQml {
|
10
|
-
|
11
|
-
class ForeignMetaObject::StringPool
|
12
|
-
{
|
13
|
-
public:
|
14
|
-
int intern(const QByteArray &str) {
|
15
|
-
int size = mStrings.size();
|
16
|
-
for (int i = 0; i < size; ++i) {
|
17
|
-
if (mStrings[i] == str)
|
18
|
-
return i;
|
19
|
-
}
|
20
|
-
mStrings << str;
|
21
|
-
return size;
|
22
|
-
}
|
23
|
-
|
24
|
-
QVector<uint8_t> toMetaStringData()
|
25
|
-
{
|
26
|
-
int count = mStrings.size();
|
27
|
-
int size = sizeof(QByteArrayData) * count;
|
28
|
-
for (const auto &str : mStrings) {
|
29
|
-
size += str.size() + 1;
|
30
|
-
}
|
31
|
-
QVector<uint8_t> data(size);
|
32
|
-
auto arrayDatas = reinterpret_cast<QArrayData *>(data.data());
|
33
|
-
auto stringData = reinterpret_cast<char *>(data.data() + sizeof(QByteArrayData) * count);
|
34
|
-
|
35
|
-
int stringOffset = 0;
|
36
|
-
|
37
|
-
for (int i = 0; i < count; ++i) {
|
38
|
-
const auto &string = mStrings[i];
|
39
|
-
auto size = string.size();
|
40
|
-
|
41
|
-
// write array data
|
42
|
-
auto arrayDataOffset = stringOffset + sizeof(QByteArrayData) * (count - i);
|
43
|
-
new(arrayDatas + i) QArrayData { Q_REFCOUNT_INITIALIZE_STATIC, size, 0, 0, qptrdiff(arrayDataOffset) };
|
44
|
-
|
45
|
-
// write string data
|
46
|
-
strcpy(stringData + stringOffset, string.data());
|
47
|
-
stringOffset += string.size() + 1;
|
48
|
-
}
|
49
|
-
|
50
|
-
return data;
|
51
|
-
}
|
52
|
-
|
53
|
-
private:
|
54
|
-
QList<QByteArray> mStrings;
|
55
|
-
};
|
56
|
-
|
57
|
-
ForeignMetaObject::ForeignMetaObject(const SP<ForeignClass> &klass, const SP<ForeignMetaObject> &superMetaObject) :
|
58
|
-
mForeignClass(klass),
|
59
|
-
mSuperMetaObject(superMetaObject)
|
60
|
-
{
|
61
|
-
buildData();
|
62
|
-
|
63
|
-
d.superdata = mSuperMetaObject ? mSuperMetaObject.get() : &QObject::staticMetaObject;
|
64
|
-
d.stringdata = reinterpret_cast<const QByteArrayData *>(mStringData.data());
|
65
|
-
d.data = mData.data();
|
66
|
-
d.static_metacall = nullptr;
|
67
|
-
d.relatedMetaObjects = nullptr;
|
68
|
-
d.extradata = nullptr;
|
69
|
-
}
|
70
|
-
|
71
|
-
void ForeignMetaObject::emitSignal(ForeignObject *obj, std::size_t id, const QVariantList &args)
|
72
|
-
{
|
73
|
-
auto metamethod = method(mSignalIndexHash[id] + methodOffset());
|
74
|
-
if (metamethod.parameterCount() != args.size()) {
|
75
|
-
qWarning() << "wrong number of signal arguments";
|
76
|
-
return;
|
77
|
-
}
|
78
|
-
QVariantList argsToPass = args;
|
79
|
-
while (argsToPass.size() < 10) {
|
80
|
-
argsToPass << QVariant();
|
81
|
-
}
|
82
|
-
metamethod.invoke(obj,
|
83
|
-
Q_ARG(QVariant, argsToPass[0]),
|
84
|
-
Q_ARG(QVariant, argsToPass[1]),
|
85
|
-
Q_ARG(QVariant, argsToPass[2]),
|
86
|
-
Q_ARG(QVariant, argsToPass[3]),
|
87
|
-
Q_ARG(QVariant, argsToPass[4]),
|
88
|
-
Q_ARG(QVariant, argsToPass[5]),
|
89
|
-
Q_ARG(QVariant, argsToPass[6]),
|
90
|
-
Q_ARG(QVariant, argsToPass[7]),
|
91
|
-
Q_ARG(QVariant, argsToPass[8]),
|
92
|
-
Q_ARG(QVariant, argsToPass[9]));
|
93
|
-
}
|
94
|
-
|
95
|
-
int ForeignMetaObject::dynamicMetaCall(ForeignObject *obj, QMetaObject::Call call, int index, void **argv)
|
96
|
-
{
|
97
|
-
if (mSuperMetaObject) {
|
98
|
-
index = mSuperMetaObject->dynamicMetaCall(obj, call, index, argv);
|
99
|
-
} else {
|
100
|
-
index = obj->QObject::qt_metacall(call, index, argv);
|
101
|
-
}
|
102
|
-
|
103
|
-
if (index < 0) {
|
104
|
-
return index;
|
105
|
-
}
|
106
|
-
|
107
|
-
switch (call) {
|
108
|
-
case QMetaObject::InvokeMetaMethod: {
|
109
|
-
if (index < mMethodCount) {
|
110
|
-
if (index < mSignalCount) {
|
111
|
-
QMetaObject::activate(obj, this, index, argv);
|
112
|
-
} else {
|
113
|
-
QVariantList args;
|
114
|
-
std::transform(argv + 1, argv + 1 + mMethodArities[index], std::back_inserter(args), [](void *arg) {
|
115
|
-
return *reinterpret_cast<QVariant *>(arg);
|
116
|
-
});
|
117
|
-
auto result = mForeignClass->callMethod(obj, mMethodIds[index], args);
|
118
|
-
if (argv[0]) {
|
119
|
-
*static_cast<QVariant *>(argv[0]) = result;
|
120
|
-
}
|
121
|
-
}
|
122
|
-
}
|
123
|
-
index -= mMethodCount;
|
124
|
-
break;
|
125
|
-
}
|
126
|
-
case QMetaObject::ReadProperty: {
|
127
|
-
if (index < mPropertyCount) {
|
128
|
-
auto result = mForeignClass->getProperty(obj, mPropertyGetterIds[index]);
|
129
|
-
*static_cast<QVariant *>(argv[0]) = result;
|
130
|
-
}
|
131
|
-
index -= mPropertyCount;
|
132
|
-
break;
|
133
|
-
}
|
134
|
-
case QMetaObject::WriteProperty: {
|
135
|
-
if (index < mPropertyCount) {
|
136
|
-
auto variant = *static_cast<QVariant *>(argv[0]);
|
137
|
-
mForeignClass->setProperty(obj, mPropertySetterIds[index], variant);
|
138
|
-
}
|
139
|
-
index -= mPropertyCount;
|
140
|
-
break;
|
141
|
-
}
|
142
|
-
case QMetaObject::ResetProperty:
|
143
|
-
case QMetaObject::QueryPropertyDesignable:
|
144
|
-
case QMetaObject::QueryPropertyScriptable:
|
145
|
-
case QMetaObject::QueryPropertyStored:
|
146
|
-
case QMetaObject::QueryPropertyEditable:
|
147
|
-
case QMetaObject::QueryPropertyUser: {
|
148
|
-
index -= mPropertyCount;
|
149
|
-
break;
|
150
|
-
}
|
151
|
-
case QMetaObject::RegisterPropertyMetaType: {
|
152
|
-
if (index < mPropertyCount) {
|
153
|
-
*static_cast<int *>(argv[0]) = -1;
|
154
|
-
}
|
155
|
-
index -= mPropertyCount;
|
156
|
-
break;
|
157
|
-
}
|
158
|
-
default:
|
159
|
-
break;
|
160
|
-
}
|
161
|
-
|
162
|
-
return index;
|
163
|
-
}
|
164
|
-
|
165
|
-
void ForeignMetaObject::buildData()
|
166
|
-
{
|
167
|
-
auto klass = mForeignClass;
|
168
|
-
int index = 0;
|
169
|
-
mMethodCount = klass->methods().size();
|
170
|
-
for (const auto &signal : klass->signalMethods()) {
|
171
|
-
mMethodIds << signal.id;
|
172
|
-
mMethodArities << signal.params.size();
|
173
|
-
mSignalIndexHash[signal.id] = index++;
|
174
|
-
}
|
175
|
-
mSignalCount = klass->signalMethods().size();
|
176
|
-
for (const auto &method : klass->nonSignalMethods()) {
|
177
|
-
mMethodIds << method.id;
|
178
|
-
mMethodArities << method.params.size();
|
179
|
-
}
|
180
|
-
mPropertyCount = klass->properties().size();
|
181
|
-
for (const auto &property : klass->properties()) {
|
182
|
-
mPropertySetterIds << property.setterId;
|
183
|
-
mPropertyGetterIds << property.getterId;
|
184
|
-
}
|
185
|
-
|
186
|
-
StringPool stringPool;
|
187
|
-
mData = writeMetaData(stringPool);
|
188
|
-
mStringData = stringPool.toMetaStringData();
|
189
|
-
}
|
190
|
-
|
191
|
-
QVector<uint> ForeignMetaObject::writeMetaData(StringPool &stringPool)
|
192
|
-
{
|
193
|
-
auto klass = mForeignClass;
|
194
|
-
|
195
|
-
int methodDataSize = 0;
|
196
|
-
|
197
|
-
for (const auto &method : klass->methods()) {
|
198
|
-
methodDataSize += 5 + 1 + method.params.size() * 2;
|
199
|
-
}
|
200
|
-
|
201
|
-
QVector<uint> metaData;
|
202
|
-
|
203
|
-
auto markIndex = [&]() {
|
204
|
-
auto index = metaData.size();
|
205
|
-
metaData << 0;
|
206
|
-
return index;
|
207
|
-
};
|
208
|
-
|
209
|
-
auto writeCurrentPos = [&](int markedIndex) {
|
210
|
-
metaData[markedIndex] = metaData.size();
|
211
|
-
};
|
212
|
-
|
213
|
-
// write header //
|
214
|
-
|
215
|
-
metaData << 7; // revision
|
216
|
-
metaData << stringPool.intern(klass->className()); // classname
|
217
|
-
metaData << 0 << 0; // classinfo
|
218
|
-
|
219
|
-
auto methods = klass->methods();
|
220
|
-
auto signalMethods = klass->signalMethods();
|
221
|
-
auto nonSignalMethods = klass->nonSignalMethods();
|
222
|
-
|
223
|
-
// methods
|
224
|
-
metaData << (methods.size());
|
225
|
-
int methodInfoPosIndex = markIndex();
|
226
|
-
|
227
|
-
auto properties = klass->properties();
|
228
|
-
|
229
|
-
// properties
|
230
|
-
metaData << properties.size();
|
231
|
-
int propertyInfoPosIndex = markIndex();
|
232
|
-
|
233
|
-
metaData << 0 << 0; // enums
|
234
|
-
metaData << 0 << 0; // constructors
|
235
|
-
metaData << 0; // flags
|
236
|
-
metaData << signalMethods.size(); // signal count
|
237
|
-
|
238
|
-
// write method info //
|
239
|
-
|
240
|
-
writeCurrentPos(methodInfoPosIndex);
|
241
|
-
|
242
|
-
QQueue<int> parameterInfoPosIndexes;
|
243
|
-
|
244
|
-
auto addMethodInfo = [&](const ForeignClass::Method &method) {
|
245
|
-
metaData << stringPool.intern(method.name); // name
|
246
|
-
metaData << method.params.size(); // argc
|
247
|
-
parameterInfoPosIndexes.enqueue(markIndex()); // parameters
|
248
|
-
metaData << 2; // tag
|
249
|
-
int flags = 0;
|
250
|
-
if (method.type == ForeignClass::Method::Type::Signal) {
|
251
|
-
flags |= AccessProtected;
|
252
|
-
flags |= MethodSignal;
|
253
|
-
} else {
|
254
|
-
flags |= AccessPublic;
|
255
|
-
}
|
256
|
-
metaData << flags; // flags
|
257
|
-
};
|
258
|
-
|
259
|
-
for (const auto &signal : signalMethods) {
|
260
|
-
addMethodInfo(signal);
|
261
|
-
}
|
262
|
-
for (const auto &method : nonSignalMethods) {
|
263
|
-
addMethodInfo(method);
|
264
|
-
}
|
265
|
-
|
266
|
-
auto addParametersInfo = [&](const ForeignClass::Method &method) {
|
267
|
-
writeCurrentPos(parameterInfoPosIndexes.dequeue());
|
268
|
-
metaData << QMetaType::QVariant;
|
269
|
-
for (int i = 0; i < method.params.size(); ++i) {
|
270
|
-
metaData << QMetaType::QVariant;
|
271
|
-
}
|
272
|
-
for (const auto ¶m : method.params) {
|
273
|
-
metaData << stringPool.intern(param);
|
274
|
-
}
|
275
|
-
};
|
276
|
-
|
277
|
-
for (const auto &signal : signalMethods) {
|
278
|
-
addParametersInfo(signal);
|
279
|
-
}
|
280
|
-
for (const auto &method : nonSignalMethods) {
|
281
|
-
addParametersInfo(method);
|
282
|
-
}
|
283
|
-
|
284
|
-
// write property info //
|
285
|
-
|
286
|
-
writeCurrentPos(propertyInfoPosIndex);
|
287
|
-
|
288
|
-
for (const auto &property : properties) {
|
289
|
-
metaData << stringPool.intern(property.name);
|
290
|
-
metaData << QMetaType::QVariant;
|
291
|
-
int flags = Notify | ResolveEditable | Stored | Scriptable | Designable;
|
292
|
-
if (property.flags & ForeignClass::Property::Flag::Writable) {
|
293
|
-
flags |= Writable;
|
294
|
-
}
|
295
|
-
if (property.flags & ForeignClass::Property::Flag::Readable) {
|
296
|
-
flags |= Readable;
|
297
|
-
}
|
298
|
-
if (property.flags & ForeignClass::Property::Flag::Constant) {
|
299
|
-
flags |= Constant;
|
300
|
-
}
|
301
|
-
metaData << flags;
|
302
|
-
}
|
303
|
-
|
304
|
-
for (const auto &property : properties) {
|
305
|
-
int signalIndex;
|
306
|
-
if (property.hasNotifySignal) {
|
307
|
-
signalIndex = mSignalIndexHash[property.notifySignalId];
|
308
|
-
} else {
|
309
|
-
signalIndex = -1;
|
310
|
-
}
|
311
|
-
metaData << signalIndex;
|
312
|
-
}
|
313
|
-
|
314
|
-
// end of data //
|
315
|
-
|
316
|
-
metaData << 0;
|
317
|
-
|
318
|
-
return metaData;
|
319
|
-
}
|
320
|
-
|
321
|
-
void ForeignMetaObject::dump()
|
322
|
-
{
|
323
|
-
qDebug() << "-- dumping ForeignClass::MetaObject" << className();
|
324
|
-
qDebug() << " -- methods";
|
325
|
-
for (int i = 0; i < methodCount(); ++i) {
|
326
|
-
auto m = method(i);
|
327
|
-
qDebug() << "name:" << m.name();
|
328
|
-
qDebug() << "return type:" << QMetaType::typeName(m.returnType());
|
329
|
-
qDebug() << "param types:" << m.parameterTypes();
|
330
|
-
qDebug() << "param names" << m.parameterNames();
|
331
|
-
qDebug() << "method type" << m.methodType();
|
332
|
-
qDebug() << "attributes" << m.attributes();
|
333
|
-
}
|
334
|
-
qDebug() << " -- properties";
|
335
|
-
for (int i = 0; i < propertyCount(); ++i) {
|
336
|
-
auto p = property(i);
|
337
|
-
qDebug() << "name:" << p.name();
|
338
|
-
qDebug() << "notify signal:" << p.notifySignal().name();
|
339
|
-
qDebug() << "writable" << p.isWritable();
|
340
|
-
qDebug() << "readable" << p.isReadable();
|
341
|
-
qDebug() << "constant" << p.isConstant();
|
342
|
-
}
|
343
|
-
}
|
344
|
-
|
345
|
-
} // namespace RubyQml
|
data/ext/qml/foreignmetaobject.h
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
#include <QMetaObject>
|
3
|
-
#include <QVector>
|
4
|
-
#include <QHash>
|
5
|
-
#include <QVariant>
|
6
|
-
#include "common.h"
|
7
|
-
|
8
|
-
namespace RubyQml {
|
9
|
-
|
10
|
-
class ForeignClass;
|
11
|
-
class ForeignObject;
|
12
|
-
|
13
|
-
class ForeignMetaObject : public QMetaObject
|
14
|
-
{
|
15
|
-
public:
|
16
|
-
ForeignMetaObject(const SP<ForeignClass> &foreignClass, const SP<ForeignMetaObject> &superMetaObject = SP<ForeignMetaObject>());
|
17
|
-
|
18
|
-
int dynamicMetaCall(ForeignObject *obj, QMetaObject::Call call, int index, void **argv);
|
19
|
-
void emitSignal(ForeignObject *obj, std::size_t id, const QVariantList &args);
|
20
|
-
void dump();
|
21
|
-
|
22
|
-
private:
|
23
|
-
class StringPool;
|
24
|
-
|
25
|
-
void buildData();
|
26
|
-
QVector<uint> writeMetaData(StringPool &stringPool);
|
27
|
-
|
28
|
-
QVector<uint8_t> mStringData;
|
29
|
-
QVector<uint> mData;
|
30
|
-
|
31
|
-
SP<ForeignClass> mForeignClass;
|
32
|
-
SP<ForeignMetaObject> mSuperMetaObject;
|
33
|
-
|
34
|
-
QHash<std::size_t, int> mSignalIndexHash;
|
35
|
-
|
36
|
-
QList<std::size_t> mMethodIds;
|
37
|
-
QList<int> mMethodArities;
|
38
|
-
int mMethodCount;
|
39
|
-
int mSignalCount;
|
40
|
-
|
41
|
-
QList<std::size_t> mPropertySetterIds;
|
42
|
-
QList<std::size_t> mPropertyGetterIds;
|
43
|
-
int mPropertyCount;
|
44
|
-
};
|
45
|
-
|
46
|
-
} // namespace RubyQml
|
data/ext/qml/foreignobject.cpp
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
#include "foreignobject.h"
|
2
|
-
#include "foreignmetaobject.h"
|
3
|
-
|
4
|
-
namespace RubyQml {
|
5
|
-
|
6
|
-
ForeignObject::ForeignObject(const SP<ForeignMetaObject> &metaobj, QObject *parent) :
|
7
|
-
QObject(parent),
|
8
|
-
mMetaObject(metaobj)
|
9
|
-
{
|
10
|
-
}
|
11
|
-
|
12
|
-
const QMetaObject *ForeignObject::metaObject() const
|
13
|
-
{
|
14
|
-
return mMetaObject.get();
|
15
|
-
}
|
16
|
-
|
17
|
-
int ForeignObject::qt_metacall(QMetaObject::Call call, int index, void **argv)
|
18
|
-
{
|
19
|
-
return mMetaObject->dynamicMetaCall(this, call, index, argv);
|
20
|
-
}
|
21
|
-
|
22
|
-
} // namespace RubyQml
|
data/ext/qml/foreignobject.h
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
#include <QObject>
|
3
|
-
#include "common.h"
|
4
|
-
|
5
|
-
namespace RubyQml {
|
6
|
-
|
7
|
-
class ForeignMetaObject;
|
8
|
-
|
9
|
-
class ForeignObject : public QObject
|
10
|
-
{
|
11
|
-
public:
|
12
|
-
explicit ForeignObject(const SP<ForeignMetaObject> &mMetaObject, QObject *parent = 0);
|
13
|
-
|
14
|
-
const QMetaObject *metaObject() const override;
|
15
|
-
int qt_metacall(QMetaObject::Call call, int index, void **argv) override;
|
16
|
-
|
17
|
-
private:
|
18
|
-
SP<ForeignMetaObject> mMetaObject;
|
19
|
-
};
|
20
|
-
|
21
|
-
} // namespace RubyQml
|
data/ext/qml/functioninfo.h
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
|
3
|
-
namespace RubyQml {
|
4
|
-
|
5
|
-
template <typename TFunction, TFunction function>
|
6
|
-
struct FunctionInfo {};
|
7
|
-
|
8
|
-
#define RUBYQML_FUNCTION_INFO(func) FunctionInfo<decltype(func), func>()
|
9
|
-
|
10
|
-
template <typename TMemberFunction, TMemberFunction memberFunction>
|
11
|
-
struct MemberFunctionInfo {};
|
12
|
-
|
13
|
-
#define RUBYQML_MEMBER_FUNCTION_INFO(memfn) MemberFunctionInfo<decltype(memfn), memfn>()
|
14
|
-
|
15
|
-
|
16
|
-
} // namespace RubyQml
|