ruby-qt6-rice 1.0.1 → 2.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.
@@ -0,0 +1,261 @@
1
+ // This file is part of [rice](https://github.com/ruby-rice/rice).
2
+ //
3
+ // Copyright (C) 2025 Jason Roelofs <jasongroelofs@gmail.com>
4
+ // Paul Brannan <curlypaul924@gmail.com>,
5
+ // Charlie Savage
6
+ //
7
+ // Redistribution and use in source and binary forms, with or without
8
+ // modification, are permitted provided that the following conditions
9
+ // are met:
10
+ //
11
+ // 1. Redistributions of source code must retain the above copyright
12
+ // notice, this list of conditions and the following disclaimer.
13
+ // 2. Redistributions in binary form must reproduce the above copyright
14
+ // notice, this list of conditions and the following disclaimer in the
15
+ // documentation and/or other materials provided with the distribution.
16
+ //
17
+ // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
+ // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
+ // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
+ // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
+ // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
+ // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
+ // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ #ifndef Rice__Api_hpp_
29
+ #define Rice__Api_hpp_
30
+
31
+
32
+ // ========= ModuleRegistry.hpp =========
33
+ #ifndef Rice_Api_Module_Registry_hpp
34
+ #define Rice_Api_Module_Registry_hpp
35
+
36
+ extern "C"
37
+ void Init_Module_Registry();
38
+
39
+ #endif
40
+
41
+ // ========= ModuleRegistry.ipp =========
42
+ using namespace Rice4RubyQt6;
43
+
44
+ extern "C"
45
+ void Init_Module_Registry()
46
+ {
47
+ Module rb_mRice = define_module("Rice4RubyQt6");
48
+
49
+ Rice4RubyQt6::define_class_under<detail::ModuleRegistry>(rb_mRice, "ModuleRegistry").
50
+ define_method("modules", &detail::ModuleRegistry::modules, Return().setValue());
51
+ }
52
+
53
+ // ========= NativeRegistry.hpp =========
54
+ #ifndef Rice_Api_Native_Registry_hpp
55
+ #define Rice_Api_Native_Registry_hpp
56
+
57
+ extern "C"
58
+ void Init_Native_Registry();
59
+
60
+ #endif
61
+
62
+ // ========= NativeRegistry.ipp =========
63
+ using namespace Rice4RubyQt6;
64
+
65
+ extern "C"
66
+ inline void Init_Native_Registry()
67
+ {
68
+ Module rb_mRice = define_module("Rice4RubyQt6");
69
+
70
+ Rice4RubyQt6::define_class_under<detail::NativeRegistry>(rb_mRice, "NativeRegistry").
71
+ define_method("lookup", [](detail::NativeRegistry& self, VALUE klass) -> Array
72
+ {
73
+ Array result;
74
+
75
+ const std::vector<detail::Native*> natives = self.lookup(klass);
76
+ for (detail::Native* native : natives)
77
+ {
78
+ result.push(native, false);
79
+ }
80
+
81
+ return result;
82
+ }, Arg("klass").setValue()).
83
+
84
+ define_method("lookup_by_kind", [](detail::NativeRegistry& self, VALUE klass, detail::NativeKind kind) -> Array
85
+ {
86
+ Array result;
87
+
88
+ const std::vector<detail::Native*> natives = self.lookup(klass, kind);
89
+ for (detail::Native* native : natives)
90
+ {
91
+ result.push(native, false);
92
+ }
93
+
94
+ return result;
95
+ }, Arg("klass").setValue(), Arg("kind"));
96
+ }
97
+
98
+ // ========= TypeRegistry.hpp =========
99
+ #ifndef Rice_Api_Type_Registry_hpp
100
+ #define Rice_Api_Type_Registry_hpp
101
+
102
+ extern "C"
103
+ void Init_Type_Registry();
104
+
105
+ #endif
106
+
107
+ // ========= TypeRegistry.ipp =========
108
+ using namespace Rice4RubyQt6;
109
+
110
+ extern "C"
111
+ void Init_Type_Registry()
112
+ {
113
+ Module rb_mRice = define_module("Rice4RubyQt6");
114
+
115
+ Rice4RubyQt6::define_class_under<detail::TypeRegistry>(rb_mRice, "TypeRegistry").
116
+ define_method("klasses", &detail::TypeRegistry::klasses, Return().setValue());
117
+ }
118
+
119
+ // ========= Registries.hpp =========
120
+ #ifndef Rice_Api_Registries_hpp
121
+ #define Rice_Api_Registries_hpp
122
+
123
+ void Init_Registries();
124
+
125
+ #endif
126
+
127
+ // ========= Registries.ipp =========
128
+ using namespace Rice4RubyQt6;
129
+
130
+ inline void Init_Registries()
131
+ {
132
+ Module rb_mRice = define_module("Rice4RubyQt6");
133
+
134
+ define_class_under<detail::Registries>(rb_mRice, "Registries").
135
+ define_singleton_attr("instance", &detail::Registries::instance, AttrAccess::Read).
136
+ define_attr("modules", &detail::Registries::modules, AttrAccess::Read).
137
+ define_attr("natives", &detail::Registries::natives, AttrAccess::Read).
138
+ define_attr("types", &detail::Registries::types, AttrAccess::Read);
139
+ }
140
+
141
+ // ========= Arg.hpp =========
142
+ #ifndef Rice_Api_Arg_hpp
143
+ #define Rice_Api_Arg_hpp
144
+
145
+ extern "C"
146
+ void Init_Arg();
147
+
148
+ #endif
149
+
150
+ // ========= Arg.ipp =========
151
+ using namespace Rice4RubyQt6;
152
+
153
+ inline void Init_Arg()
154
+ {
155
+ Module rb_mRice = define_module("Rice4RubyQt6");
156
+
157
+ define_class_under<Arg>(rb_mRice, "Arg").
158
+ define_attr("name", &Arg::name, AttrAccess::Read);
159
+ }
160
+
161
+ // ========= Parameter.hpp =========
162
+ #ifndef Rice_Api_Parameter_hpp
163
+ #define Rice_Api_Parameter_hpp
164
+
165
+ extern "C"
166
+ void Init_Parameter();
167
+
168
+ #endif
169
+
170
+ // ========= Parameter.ipp =========
171
+ using namespace Rice4RubyQt6;
172
+
173
+ inline void Init_Parameter()
174
+ {
175
+ Module rb_mRice = define_module("Rice4RubyQt6");
176
+
177
+ define_class_under<detail::ParameterAbstract>(rb_mRice, "Parameter").
178
+ define_method("arg", &detail::ParameterAbstract::arg).
179
+ define_method("klass", &detail::ParameterAbstract::klass, Return().setValue()).
180
+ define_method("cpp_klass", &detail::ParameterAbstract::cppTypeName);
181
+ }
182
+
183
+ // ========= Native.hpp =========
184
+ #ifndef Rice_Api_Native_Function_hpp
185
+ #define Rice_Api_Native_Function_hpp
186
+
187
+ extern "C"
188
+ void Init_Native();
189
+
190
+ #endif
191
+
192
+ // ========= Native.ipp =========
193
+ using namespace Rice4RubyQt6;
194
+
195
+ #include <ostream>
196
+
197
+ extern "C"
198
+ inline void Init_Native()
199
+ {
200
+ Module rb_mRice = define_module("Rice4RubyQt6");
201
+
202
+ define_enum_under<detail::NativeKind>("NativeKind", rb_mRice)
203
+ .define_value("Function", detail::NativeKind::Function)
204
+ .define_value("Method", detail::NativeKind::Method)
205
+ .define_value("AttributeReader", detail::NativeKind::AttributeReader)
206
+ .define_value("AttributeWriter", detail::NativeKind::AttributeWriter)
207
+ .define_value("Proc", detail::NativeKind::Proc)
208
+ .define_value("Callback", detail::NativeKind::Callback);
209
+
210
+ define_class_under<detail::Native>(rb_mRice, "Native").
211
+ define_method("name", &detail::Native::name).
212
+ define_method("kind", &detail::Native::kind).
213
+ define_method("return_klass", &detail::Native::returnKlass, Return().setValue()).
214
+ define_method("parameters", &detail::Native::parameters).
215
+ define_method("to_s", [](detail::Native& self) -> std::string
216
+ {
217
+ std::ostringstream stream;
218
+ stream << "Native";
219
+
220
+ switch (self.kind())
221
+ {
222
+ case detail::NativeKind::Function:
223
+ stream << "Function";
224
+ break;
225
+ case detail::NativeKind::Method:
226
+ stream << "Method";
227
+ break;
228
+ case detail::NativeKind::Iterator:
229
+ stream << "Iterator";
230
+ break;
231
+ case detail::NativeKind::AttributeReader:
232
+ stream << "AttributeReader";
233
+ break;
234
+ case detail::NativeKind::AttributeWriter:
235
+ stream << "AttributeWriter";
236
+ break;
237
+ case detail::NativeKind::Proc:
238
+ stream << "Proc";
239
+ break;
240
+ case detail::NativeKind::Callback:
241
+ stream << "Callback";
242
+ break;
243
+ }
244
+
245
+ stream << "<" << self.name() << "> ";
246
+ return stream.str();
247
+ });
248
+ }
249
+
250
+ extern "C"
251
+ inline void Init_Rice_Api()
252
+ {
253
+ Init_Registries();
254
+ Init_Module_Registry();
255
+ Init_Native_Registry();
256
+ Init_Type_Registry();
257
+ Init_Arg();
258
+ Init_Parameter();
259
+ Init_Native();
260
+ }
261
+ #endif