ruby-qt6-rice 2.1.0 → 6.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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/Rakefile +12 -1
  4. data/ext/qt6/rice/extconf.rb +5 -0
  5. data/ext/qt6/rice/rice-rb.cpp +10 -0
  6. data/ext/qt6/rice/rice-rb.hpp +3 -0
  7. data/include/bando/common.hpp +2 -1
  8. data/include/bando/qobject/qdbusabstractadaptor.hpp +1 -1
  9. data/include/bando/qobject/qdbusabstractinterface.hpp +1 -1
  10. data/include/bando/qobject/qitemdelegate.hpp +1 -1
  11. data/include/bando/qobject/qlayout.hpp +1 -1
  12. data/include/bando/qobject/qwebenginepage.hpp +1 -1
  13. data/include/bando/qobject.hpp +1 -1
  14. data/include/bando/qwidget/qspinbox.hpp +1 -1
  15. data/include/bando/qwidget.hpp +1 -1
  16. data/include/rice/core/rice.hpp +1711 -1314
  17. data/include/rice/core/stl.hpp +562 -82
  18. data/include/rice/cxx/asserts.hpp +31 -0
  19. data/include/rice/cxx/concepts.hpp +31 -0
  20. data/include/rice/qt6/preludes/libqt6core.hpp +192 -0
  21. data/include/rice/qt6/preludes/libqt6gui.hpp +176 -0
  22. data/include/rice/qt6/preludes/libqt6multimedia.hpp +33 -0
  23. data/include/rice/qt6/preludes/libqt6qml.hpp +33 -0
  24. data/include/rice/qt6/preludes/libqt6quick.hpp +30 -0
  25. data/include/rice/qt6/preludes/libqt6webenginecore.hpp +30 -0
  26. data/include/rice/qt6/preludes/libqt6widgets.hpp +35 -0
  27. data/include/rice/qt6/preludes/qlass.hpp +63 -0
  28. data/include/rice/qt6/preludes/registries.hpp +52 -0
  29. data/include/rice/qt6/preludes.hpp +28 -0
  30. data/include/rice/qt6/qdbusreply.hpp +3 -3
  31. data/include/rice/qt6/qenum.hpp +1 -1
  32. data/include/rice/qt6/qflags.hpp +1 -1
  33. data/include/rice/qt6/qlist.hpp +17 -20
  34. data/include/rice/qt6/qmap.hpp +14 -11
  35. data/include/rice/qt6.hpp +3 -0
  36. data/lib/mkmf-rubyqt6.rb +24 -7
  37. data/lib/qt6/rice/version.rb +1 -1
  38. data/lib/qt6/rice.rb +1 -0
  39. metadata +18 -2
@@ -0,0 +1,63 @@
1
+ // This file is part of [RubyQt6](https://github.com/souk4711/ruby-qt6).
2
+ //
3
+ // It is licensed under the LGPLv3, included below.
4
+ //
5
+ // As a special exception to the GNU Lesser General Public License version 3
6
+ // ("LGPL3"), the copyright holders of this Library give you permission to
7
+ // convey to a third party a Combined Work that links statically or dynamically
8
+ // to this Library without providing any Minimal Corresponding Source or
9
+ // Minimal Application Code as set out in 4d or providing the installation
10
+ // information set out in section 4e, provided that you comply with the other
11
+ // provisions of LGPL3 and provided that you meet, for the Application the
12
+ // terms and conditions of the license(s) which apply to the Application.
13
+ //
14
+ // Except as stated in this special exception, the provisions of LGPL3 will
15
+ // continue to comply in full to this Library. If you modify this Library, you
16
+ // may apply this exception to your version of this Library, but you are not
17
+ // obliged to do so. If you do not wish to do so, delete this exception
18
+ // statement from your version. This exception does not (and cannot) modify any
19
+ // license terms which apply to the Application, with which you must still
20
+ // comply.
21
+
22
+ #ifndef RICE_QT6_PRELUDES_QLASS_HPP
23
+ #define RICE_QT6_PRELUDES_QLASS_HPP
24
+
25
+ #include <rice/cxx/asserts.hpp>
26
+
27
+ RICE4RUBYQT6_USE_NAMESPACE
28
+
29
+ template<typename T, typename Base_T = void>
30
+ inline Data_Type<T> define_qlass_under(Object parent, Identifier id)
31
+ {
32
+ Class superKlass = get_superklass<Base_T>();
33
+ Data_Type<T> klass = define_class_under<T, Base_T>(parent, id, superKlass);
34
+
35
+ auto instance = RubyQt6_RTypedData_Registries::instance();
36
+ auto klassid = klass.object_id();
37
+ auto rtypeddata = klass.ruby_data_type();
38
+ auto pair = instance->klass2rtypeddata_.insert({ klassid, rtypeddata });
39
+ if (!pair.second && pair.first->second != rtypeddata) {
40
+ std::string msg = "define_qlass_under: already registered qlass: " + klass.to_s().str();
41
+ assertm(false, msg.c_str());
42
+ }
43
+
44
+ return klass;
45
+ }
46
+
47
+ template<typename T, typename Base_T = void>
48
+ inline Data_Type<T> declare_qlass_under(Object parent, Identifier id)
49
+ {
50
+ Class klass = parent.const_get(id).value();
51
+
52
+ auto instance = RubyQt6_RTypedData_Registries::instance();
53
+ auto klassid = klass.object_id();
54
+ auto iter = instance->klass2rtypeddata_.find(klassid);
55
+ if (iter == instance->klass2rtypeddata_.end()) {
56
+ std::string msg = "declare_qlass_under: unregistered qlass: " + klass.to_s().str();
57
+ assertm(false, msg.c_str());
58
+ }
59
+
60
+ return declare_class_under<T, Base_T>(parent, id.c_str(), iter->second);
61
+ }
62
+
63
+ #endif
@@ -0,0 +1,52 @@
1
+ // This file is part of [RubyQt6](https://github.com/souk4711/ruby-qt6).
2
+ //
3
+ // It is licensed under the LGPLv3, included below.
4
+ //
5
+ // As a special exception to the GNU Lesser General Public License version 3
6
+ // ("LGPL3"), the copyright holders of this Library give you permission to
7
+ // convey to a third party a Combined Work that links statically or dynamically
8
+ // to this Library without providing any Minimal Corresponding Source or
9
+ // Minimal Application Code as set out in 4d or providing the installation
10
+ // information set out in section 4e, provided that you comply with the other
11
+ // provisions of LGPL3 and provided that you meet, for the Application the
12
+ // terms and conditions of the license(s) which apply to the Application.
13
+ //
14
+ // Except as stated in this special exception, the provisions of LGPL3 will
15
+ // continue to comply in full to this Library. If you modify this Library, you
16
+ // may apply this exception to your version of this Library, but you are not
17
+ // obliged to do so. If you do not wish to do so, delete this exception
18
+ // statement from your version. This exception does not (and cannot) modify any
19
+ // license terms which apply to the Application, with which you must still
20
+ // comply.
21
+
22
+ #ifndef RICE_QT6_PRELUDES_REGISTRIES_HPP
23
+ #define RICE_QT6_PRELUDES_REGISTRIES_HPP
24
+
25
+ #ifdef _WIN32
26
+ # ifdef RUBYQT6_BUILD_RICE_LIB
27
+ # define RUBYQT6_RICE_EXPORT __declspec(dllexport)
28
+ # else
29
+ # define RUBYQT6_RICE_EXPORT __declspec(dllimport)
30
+ # endif
31
+ #else
32
+ # define RUBYQT6_RICE_EXPORT
33
+ #endif
34
+
35
+ struct RUBYQT6_RICE_EXPORT RubyQt6_RTypedData_Registries
36
+ {
37
+ RUBYQT6_RICE_EXPORT static RubyQt6_RTypedData_Registries *instance();
38
+ static RubyQt6_RTypedData_Registries* instance_;
39
+
40
+ std::map<VALUE, rb_data_type_t*> klass2rtypeddata_;
41
+ };
42
+
43
+ #ifdef RUBYQT6_BUILD_RICE_LIB
44
+ inline RubyQt6_RTypedData_Registries *RubyQt6_RTypedData_Registries::instance()
45
+ {
46
+ if (instance_ == nullptr) { instance_ = new RubyQt6_RTypedData_Registries; }
47
+ return instance_;
48
+ }
49
+ inline RubyQt6_RTypedData_Registries *RubyQt6_RTypedData_Registries::instance_ = nullptr;
50
+ #endif
51
+
52
+ #endif
@@ -0,0 +1,28 @@
1
+ // This file is part of [RubyQt6](https://github.com/souk4711/ruby-qt6).
2
+ //
3
+ // It is licensed under the LGPLv3, included below.
4
+ //
5
+ // As a special exception to the GNU Lesser General Public License version 3
6
+ // ("LGPL3"), the copyright holders of this Library give you permission to
7
+ // convey to a third party a Combined Work that links statically or dynamically
8
+ // to this Library without providing any Minimal Corresponding Source or
9
+ // Minimal Application Code as set out in 4d or providing the installation
10
+ // information set out in section 4e, provided that you comply with the other
11
+ // provisions of LGPL3 and provided that you meet, for the Application the
12
+ // terms and conditions of the license(s) which apply to the Application.
13
+ //
14
+ // Except as stated in this special exception, the provisions of LGPL3 will
15
+ // continue to comply in full to this Library. If you modify this Library, you
16
+ // may apply this exception to your version of this Library, but you are not
17
+ // obliged to do so. If you do not wish to do so, delete this exception
18
+ // statement from your version. This exception does not (and cannot) modify any
19
+ // license terms which apply to the Application, with which you must still
20
+ // comply.
21
+
22
+ #ifndef RICE_QT6_PRELUDES_HPP
23
+ #define RICE_QT6_PRELUDES_HPP
24
+
25
+ #include <rice/qt6/preludes/registries.hpp>
26
+ #include <rice/qt6/preludes/qlass.hpp>
27
+
28
+ #endif
@@ -32,11 +32,11 @@ void define_qdbusreply_under(Module module)
32
32
  using QDBusReply_T = QDBusReply<Value_T>;
33
33
  using QDBusPendingReply_T = QDBusPendingReply<Value_T>;
34
34
 
35
- detail::TypeMapper<QDBusReply_T> typeMapper;
36
- std::string klassName = typeMapper.rubyName();
35
+ detail::TypeDetail<QDBusReply_T> typeDetail;
36
+ std::string klassName = typeDetail.rubyName();
37
37
  Identifier id(klassName);
38
38
 
39
- define_class_under<QDBusReply_T>(module, id)
39
+ define_qlass_under<QDBusReply_T>(module, id)
40
40
  .define_constructor(Constructor<QDBusReply_T, const QDBusError &>(), Arg("dbus_error") = static_cast<const QDBusError &>(QDBusError()))
41
41
  .define_constructor(Constructor<QDBusReply_T, const QDBusMessage &>(), Arg("reply"))
42
42
  .define_constructor(Constructor<QDBusReply_T, const QDBusPendingCall &>(), Arg("pcall"))
@@ -50,7 +50,7 @@ VALUE qenum_qvariant_register_metatype(VALUE self)
50
50
  template<typename Enum_T>
51
51
  Data_Type<Enum_T> define_qenum_under(Module module, char const* name)
52
52
  {
53
- Data_Type<Enum_T> qenum = define_class_under<Enum_T>(module, name);
53
+ Data_Type<Enum_T> qenum = define_qlass_under<Enum_T>(module, name);
54
54
  detail::protect(rb_define_method, qenum, "to_i", (RUBY_METHOD_FUNC)qenum_to_i<Enum_T>, 0);
55
55
  detail::protect(rb_define_singleton_method, qenum, "from_int", (RUBY_METHOD_FUNC)qenum_from_int<Enum_T>, 1);
56
56
  detail::protect(rb_define_singleton_method, qenum, "_qvariant_register_metatype", (RUBY_METHOD_FUNC)qenum_qvariant_register_metatype<Enum_T>, 0);
@@ -45,7 +45,7 @@ Data_Type<QFlags<Enum_T>> define_qflags_under(Module module, char const* name)
45
45
  {
46
46
  using QFlags_T = QFlags<Enum_T>;
47
47
 
48
- Data_Type<QFlags_T> qflags = define_class_under<QFlags_T>(module, name);
48
+ Data_Type<QFlags_T> qflags = define_qlass_under<QFlags_T>(module, name);
49
49
  detail::protect(rb_define_method, qflags, "to_i", (RUBY_METHOD_FUNC)qflags_to_i<QFlags_T>, 0);
50
50
  detail::protect(rb_define_singleton_method, qflags, "from_int", (RUBY_METHOD_FUNC)qflags_from_int<QFlags_T>, 1);
51
51
  return qflags;
@@ -23,6 +23,7 @@
23
23
  #define RICE_QLIST_HPP
24
24
 
25
25
  #include <QList>
26
+ #include <rice/cxx/concepts.hpp>
26
27
 
27
28
  RICE4RUBYQT6_USE_NAMESPACE
28
29
 
@@ -38,7 +39,7 @@ public:
38
39
  this->define_constructors();
39
40
  this->define_capacity_methods();
40
41
  this->define_access_methods();
41
- this->define_comparable_methods();
42
+ if constexpr (has_equal_operator<Parameter_T>::value) { this->define_comparable_methods(); }
42
43
  this->define_insert_methods();
43
44
  this->define_remove_methods();
44
45
  this->define_enumerable();
@@ -159,15 +160,17 @@ private:
159
160
  return self;
160
161
  });
161
162
 
162
- klass_.define_method("delete", [](QList_T *self, Parameter_T element) -> std::optional<Value_T> {
163
- qsizetype index = self->lastIndexOf(element);
164
- if (index != -1) {
165
- Value_T result = self->takeAt(index);
166
- self->removeAll(element);
167
- return result;
168
- }
169
- return std::nullopt;
170
- });
163
+ if constexpr (has_equal_operator<Parameter_T>::value) {
164
+ klass_.define_method("delete", [](QList_T *self, Parameter_T element) -> std::optional<Value_T> {
165
+ qsizetype index = self->lastIndexOf(element);
166
+ if (index != -1) {
167
+ Value_T result = self->takeAt(index);
168
+ self->removeAll(element);
169
+ return result;
170
+ }
171
+ return std::nullopt;
172
+ });
173
+ }
171
174
 
172
175
  klass_.define_method("delete_at", [](QList_T *self, qsizetype index) -> std::optional<Value_T> {
173
176
  if (index < 0) {
@@ -182,13 +185,7 @@ private:
182
185
 
183
186
  void define_enumerable()
184
187
  {
185
- klass_.include_module(rb_mEnumerable);
186
- klass_.define_method("each", [](QList_T *self) -> QList_T* {
187
- for (qsizetype i = 0; i < self->size(); i++) {
188
- detail::protect(rb_yield, detail::to_ruby(self->at(i)));
189
- }
190
- return self;
191
- });
188
+ klass_.template define_iterator<typename QList_T::iterator(QList_T::*)()>(&QList_T::begin, &QList_T::end);
192
189
  }
193
190
 
194
191
  void define_to_array()
@@ -205,11 +202,11 @@ void define_qlist_under(Module module)
205
202
  {
206
203
  using QList_T = QList<Value_T>;
207
204
 
208
- detail::TypeMapper<QList_T> typeMapper;
209
- std::string klassName = typeMapper.rubyName();
205
+ detail::TypeDetail<QList_T> typeDetail;
206
+ std::string klassName = typeDetail.rubyName();
210
207
  Identifier id(klassName);
211
208
 
212
- Data_Type<QList_T> qlist = define_class_under<QList_T>(module, id);
209
+ Data_Type<QList_T> qlist = define_qlass_under<QList_T>(module, id);
213
210
  DefineQListMethods<QList_T> qlist_(qlist);
214
211
  }
215
212
 
@@ -31,6 +31,7 @@ class DefineQMapMethods
31
31
  {
32
32
  using Key_T = typename QMap_T::key_type;
33
33
  using Mapped_T = typename QMap_T::mapped_type;
34
+ using To_Ruby_T = typename detail::remove_cv_recursive_t<Mapped_T>;
34
35
 
35
36
  public:
36
37
  DefineQMapMethods(Data_Type<QMap_T> klass) : klass_(klass)
@@ -124,18 +125,20 @@ private:
124
125
 
125
126
  void define_enumerable()
126
127
  {
127
- klass_.include_module(rb_mEnumerable);
128
- klass_.define_method("each", [](QMap_T *self) -> QMap_T* {
129
- for (auto i = self->cbegin(), end = self->cend(); i != end; ++i) {
130
- detail::protect(rb_yield_values, 2, detail::to_ruby(i.key()), detail::to_ruby(i.value()));
131
- }
132
- return self;
133
- });
128
+ klass_.template define_iterator<typename QMap_T::iterator (QMap_T::*)()>(&QMap_T::begin, &QMap_T::end);
134
129
  }
135
130
 
136
131
  void define_to_hash()
137
132
  {
138
- rb_define_alias(klass_, "to_hash", "to_h");
133
+ klass_.define_method("to_h", [](QMap_T *self) {
134
+ VALUE result = rb_hash_new();
135
+ for (auto iter = self->cbegin(), end = self->cend(); iter != end; ++iter) {
136
+ VALUE key = detail::To_Ruby<Key_T&>().convert(iter.key());
137
+ VALUE value = detail::To_Ruby<To_Ruby_T&>().convert(iter.value());
138
+ rb_hash_aset(result, key, value);
139
+ }
140
+ return result;
141
+ }, Return().setValue());
139
142
  }
140
143
 
141
144
  private:
@@ -147,11 +150,11 @@ void define_qmap_under(Module module)
147
150
  {
148
151
  using QMap_T = QMap<Key_T, Mapped_T>;
149
152
 
150
- detail::TypeMapper<QMap_T> typeMapper;
151
- std::string klassName = typeMapper.rubyName();
153
+ detail::TypeDetail<QMap_T> typeDetail;
154
+ std::string klassName = typeDetail.rubyName();
152
155
  Identifier id(klassName);
153
156
 
154
- Data_Type<QMap_T> qmap = define_class_under<QMap_T>(module, id);
157
+ Data_Type<QMap_T> qmap = define_qlass_under<QMap_T>(module, id);
155
158
  DefineQMapMethods<QMap_T> qmap_(qmap);
156
159
  }
157
160
 
data/include/rice/qt6.hpp CHANGED
@@ -36,4 +36,7 @@
36
36
  // macros
37
37
  #define RICE4RUBYQT6_USE_NAMESPACE using namespace ::Rice4RubyQt6;
38
38
 
39
+ // include rice/qt6 stuffs
40
+ #include <rice/qt6/preludes.hpp>
41
+
39
42
  #endif
data/lib/mkmf-rubyqt6.rb CHANGED
@@ -41,18 +41,35 @@ def rubyqt6_extconf(mod, depends:)
41
41
  r = "RUBYQT6_BUILD_#{mod.upcase}_LIB"
42
42
  append_cppflags("-D#{r}")
43
43
 
44
- # Add qt6 included directories
44
+ # Add included directories
45
45
  append_cppflags("-I#{qt_install_headers}")
46
46
  (Array(depends) + Array(mod)).each do |name|
47
- includedir = File.join(qt_install_headers, name)
48
- append_cppflags("-I#{includedir}")
47
+ if name.start_with?("Qt")
48
+ includedir = File.join(qt_install_headers, name)
49
+ append_cppflags("-I#{includedir}")
50
+ elsif name.start_with?("K")
51
+ includedir = File.join("/usr/include/KF6", name)
52
+ append_cppflags("-I#{includedir}")
53
+ end
49
54
  end
50
55
 
51
- # Add qt6 libraries
56
+ # Add libraries
52
57
  (Array(depends) + Array(mod)).each do |name|
53
- library = name.sub("Qt", "Qt6")
54
- message = "Could not find lib#{library}, please install qt6 package"
55
- raise message unless find_library(library, nil, qt_install_libs)
58
+ if name.start_with?("Qt")
59
+ library = name.sub("Qt", "Qt6")
60
+ message = "Could not find lib#{library}, please install qt6 package"
61
+ raise message unless find_library(library, nil, qt_install_libs)
62
+ elsif name.start_with?("K")
63
+ library = name.sub("K", "KF6")
64
+ message = "Could not find lib#{library}, please install kf6 package"
65
+ raise message unless find_library(library, nil, "/usr/lib")
66
+ end
67
+ end
68
+
69
+ # Add rice library
70
+ if mod != "Rice"
71
+ rubyqt6_rice_gem_path = Gem::Specification.find_by_name("ruby-qt6-rice").full_gem_path
72
+ append_ldflags(File.join(rubyqt6_rice_gem_path, "lib/qt6/rice/rice.so"))
56
73
  end
57
74
 
58
75
  # Create Makefile
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RubyQt6
4
4
  module Rice
5
- RICE_RUBYGEM_VERSION = "2.1.0"
5
+ RICE_RUBYGEM_VERSION = "6.0.0"
6
6
  end
7
7
  end
data/lib/qt6/rice.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "rice/version"
4
+ require_relative "rice/rice"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-qt6-rice
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Doe
@@ -13,7 +13,8 @@ description: Extend the Rice library with support for the Qt framework.
13
13
  email:
14
14
  - johndoe@example.com
15
15
  executables: []
16
- extensions: []
16
+ extensions:
17
+ - ext/qt6/rice/extconf.rb
17
18
  extra_rdoc_files: []
18
19
  files:
19
20
  - ".rspec"
@@ -21,6 +22,9 @@ files:
21
22
  - LICENSE
22
23
  - README.md
23
24
  - Rakefile
25
+ - ext/qt6/rice/extconf.rb
26
+ - ext/qt6/rice/rice-rb.cpp
27
+ - ext/qt6/rice/rice-rb.hpp
24
28
  - include/bando/common.hpp
25
29
  - include/bando/qobject.hpp
26
30
  - include/bando/qobject/qdbusabstractadaptor.hpp
@@ -33,7 +37,19 @@ files:
33
37
  - include/rice/core/api.hpp
34
38
  - include/rice/core/rice.hpp
35
39
  - include/rice/core/stl.hpp
40
+ - include/rice/cxx/asserts.hpp
41
+ - include/rice/cxx/concepts.hpp
36
42
  - include/rice/qt6.hpp
43
+ - include/rice/qt6/preludes.hpp
44
+ - include/rice/qt6/preludes/libqt6core.hpp
45
+ - include/rice/qt6/preludes/libqt6gui.hpp
46
+ - include/rice/qt6/preludes/libqt6multimedia.hpp
47
+ - include/rice/qt6/preludes/libqt6qml.hpp
48
+ - include/rice/qt6/preludes/libqt6quick.hpp
49
+ - include/rice/qt6/preludes/libqt6webenginecore.hpp
50
+ - include/rice/qt6/preludes/libqt6widgets.hpp
51
+ - include/rice/qt6/preludes/qlass.hpp
52
+ - include/rice/qt6/preludes/registries.hpp
37
53
  - include/rice/qt6/qdbusreply.hpp
38
54
  - include/rice/qt6/qenum.hpp
39
55
  - include/rice/qt6/qflags.hpp