oicana 0.10.0.rc.1
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 +7 -0
- data/LICENSE.md +131 -0
- data/README.md +40 -0
- data/lib/oicana/errors.rb +62 -0
- data/lib/oicana/native.rb +71 -0
- data/lib/oicana/oicana_uniffi.rb +2037 -0
- data/lib/oicana/template.rb +213 -0
- data/lib/oicana/types.rb +159 -0
- data/lib/oicana/version.rb +5 -0
- data/lib/oicana.rb +60 -0
- metadata +66 -0
|
@@ -0,0 +1,2037 @@
|
|
|
1
|
+
# This file was autogenerated by some hot garbage in the `uniffi` crate.
|
|
2
|
+
# Trust me, you don't want to mess with it!
|
|
3
|
+
|
|
4
|
+
# Common helper code.
|
|
5
|
+
#
|
|
6
|
+
# Ideally this would live in a separate .rb file where it can be unittested etc
|
|
7
|
+
# in isolation, and perhaps even published as a re-useable package.
|
|
8
|
+
#
|
|
9
|
+
# However, it's important that the details of how this helper code works (e.g. the
|
|
10
|
+
# way that different builtin types are passed across the FFI) exactly match what's
|
|
11
|
+
# expected by the rust code on the other side of the interface. In practice right
|
|
12
|
+
# now that means coming from the exact some version of `uniffi` that was used to
|
|
13
|
+
# compile the rust component. The easiest way to ensure this is to bundle the Ruby
|
|
14
|
+
# helpers directly inline like we're doing here.
|
|
15
|
+
|
|
16
|
+
require 'ffi'
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
module OicanaUniffi
|
|
20
|
+
def self.uniffi_in_range(i, type_name, min, max)
|
|
21
|
+
raise TypeError, "no implicit conversion of #{i} into Integer" unless i.respond_to?(:to_int)
|
|
22
|
+
i = i.to_int
|
|
23
|
+
raise RangeError, "#{type_name} requires #{min} <= value < #{max}" unless (min <= i && i < max)
|
|
24
|
+
i
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.uniffi_utf8(v)
|
|
28
|
+
raise TypeError, "no implicit conversion of #{v} into String" unless v.respond_to?(:to_str)
|
|
29
|
+
v = v.to_str.encode(Encoding::UTF_8)
|
|
30
|
+
raise Encoding::InvalidByteSequenceError, "not a valid UTF-8 encoded string" unless v.valid_encoding?
|
|
31
|
+
v
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.uniffi_bytes(v)
|
|
35
|
+
raise TypeError, "no implicit conversion of #{v} into String" unless v.respond_to?(:to_str)
|
|
36
|
+
v.to_str
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
class RustBuffer < FFI::Struct
|
|
40
|
+
layout :capacity, :uint64,
|
|
41
|
+
:len, :uint64,
|
|
42
|
+
:data, :pointer
|
|
43
|
+
|
|
44
|
+
def self.alloc(size)
|
|
45
|
+
return OicanaUniffi.rust_call(:ffi_oicana_uniffi_rustbuffer_alloc, size)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def self.reserve(rbuf, additional)
|
|
49
|
+
return OicanaUniffi.rust_call(:ffi_oicana_uniffi_rustbuffer_reserve, rbuf, additional)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def free
|
|
53
|
+
OicanaUniffi.rust_call(:ffi_oicana_uniffi_rustbuffer_free, self)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def capacity
|
|
57
|
+
self[:capacity]
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def len
|
|
61
|
+
self[:len]
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def len=(value)
|
|
65
|
+
self[:len] = value
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def data
|
|
69
|
+
self[:data]
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def to_s
|
|
73
|
+
"RustBuffer(capacity=#{capacity}, len=#{len}, data=#{data.read_bytes len})"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# The allocated buffer will be automatically freed if an error occurs, ensuring that
|
|
77
|
+
# we don't accidentally leak it.
|
|
78
|
+
def self.allocWithBuilder
|
|
79
|
+
builder = RustBufferBuilder.new
|
|
80
|
+
|
|
81
|
+
begin
|
|
82
|
+
yield builder
|
|
83
|
+
rescue => e
|
|
84
|
+
builder.discard
|
|
85
|
+
raise e
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# The RustBuffer will be freed once the context-manager exits, ensuring that we don't
|
|
90
|
+
# leak it even if an error occurs.
|
|
91
|
+
def consumeWithStream
|
|
92
|
+
stream = RustBufferStream.new self
|
|
93
|
+
|
|
94
|
+
yield stream
|
|
95
|
+
|
|
96
|
+
raise RuntimeError, 'junk data left in buffer after consuming' if stream.remaining != 0
|
|
97
|
+
ensure
|
|
98
|
+
free
|
|
99
|
+
end# The primitive String type.
|
|
100
|
+
|
|
101
|
+
def self.allocFromString(value)
|
|
102
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
103
|
+
builder.write value.encode('utf-8')
|
|
104
|
+
return builder.finalize
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def consumeIntoString
|
|
109
|
+
consumeWithStream do |stream|
|
|
110
|
+
return stream.read(stream.remaining).force_encoding(Encoding::UTF_8)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# The primitive Bytes type.
|
|
115
|
+
|
|
116
|
+
def self.allocFromBytes(value)
|
|
117
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
118
|
+
builder.write_Bytes(value)
|
|
119
|
+
return builder.finalize
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def consumeIntoBytes
|
|
124
|
+
consumeWithStream do |stream|
|
|
125
|
+
return stream.readBytes
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# The Record type BlobInput.
|
|
130
|
+
|
|
131
|
+
def self.check_lower_TypeBlobInput(v)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def self.alloc_from_TypeBlobInput(v)
|
|
137
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
138
|
+
builder.write_TypeBlobInput(v)
|
|
139
|
+
return builder.finalize
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def consumeIntoTypeBlobInput
|
|
144
|
+
consumeWithStream do |stream|
|
|
145
|
+
return stream.readTypeBlobInput
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# The Record type ExportOnceResult.
|
|
150
|
+
|
|
151
|
+
def self.check_lower_TypeExportOnceResult(v)
|
|
152
|
+
|
|
153
|
+
RustBuffer.check_lower_Optionalstring(v.warnings)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def self.alloc_from_TypeExportOnceResult(v)
|
|
157
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
158
|
+
builder.write_TypeExportOnceResult(v)
|
|
159
|
+
return builder.finalize
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def consumeIntoTypeExportOnceResult
|
|
164
|
+
consumeWithStream do |stream|
|
|
165
|
+
return stream.readTypeExportOnceResult
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# The Record type PageRange.
|
|
170
|
+
|
|
171
|
+
def self.check_lower_TypePageRange(v)
|
|
172
|
+
RustBuffer.check_lower_Optionalu64(v.start)
|
|
173
|
+
RustBuffer.check_lower_Optionalu64(v._end)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def self.alloc_from_TypePageRange(v)
|
|
177
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
178
|
+
builder.write_TypePageRange(v)
|
|
179
|
+
return builder.finalize
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def consumeIntoTypePageRange
|
|
184
|
+
consumeWithStream do |stream|
|
|
185
|
+
return stream.readTypePageRange
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# The Record type PageSize.
|
|
190
|
+
|
|
191
|
+
def self.check_lower_TypePageSize(v)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def self.alloc_from_TypePageSize(v)
|
|
197
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
198
|
+
builder.write_TypePageSize(v)
|
|
199
|
+
return builder.finalize
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
def consumeIntoTypePageSize
|
|
204
|
+
consumeWithStream do |stream|
|
|
205
|
+
return stream.readTypePageSize
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# The Record type RegisteredFont.
|
|
210
|
+
|
|
211
|
+
def self.check_lower_TypeRegisteredFont(v)
|
|
212
|
+
|
|
213
|
+
RustBuffer.check_lower_Optionalstring(v.path)
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def self.alloc_from_TypeRegisteredFont(v)
|
|
217
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
218
|
+
builder.write_TypeRegisteredFont(v)
|
|
219
|
+
return builder.finalize
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
def consumeIntoTypeRegisteredFont
|
|
224
|
+
consumeWithStream do |stream|
|
|
225
|
+
return stream.readTypeRegisteredFont
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
# The Record type ZipLimits.
|
|
230
|
+
|
|
231
|
+
def self.check_lower_TypeZipLimits(v)
|
|
232
|
+
RustBuffer.check_lower_Optionalu64(v.max_entries)
|
|
233
|
+
RustBuffer.check_lower_Optionalu64(v.max_total_decompressed_bytes)
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
def self.alloc_from_TypeZipLimits(v)
|
|
237
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
238
|
+
builder.write_TypeZipLimits(v)
|
|
239
|
+
return builder.finalize
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
def consumeIntoTypeZipLimits
|
|
244
|
+
consumeWithStream do |stream|
|
|
245
|
+
return stream.readTypeZipLimits
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
# The Enum type CompilationMode.
|
|
250
|
+
|
|
251
|
+
def self.check_lower_TypeCompilationMode(v)
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
def self.alloc_from_TypeCompilationMode(v)
|
|
255
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
256
|
+
builder.write_TypeCompilationMode(v)
|
|
257
|
+
return builder.finalize
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
def consumeIntoTypeCompilationMode
|
|
262
|
+
consumeWithStream do |stream|
|
|
263
|
+
return stream.readTypeCompilationMode
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
# The Enum type DiagnosticColor.
|
|
269
|
+
|
|
270
|
+
def self.check_lower_TypeDiagnosticColor(v)
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
def self.alloc_from_TypeDiagnosticColor(v)
|
|
274
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
275
|
+
builder.write_TypeDiagnosticColor(v)
|
|
276
|
+
return builder.finalize
|
|
277
|
+
end
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
def consumeIntoTypeDiagnosticColor
|
|
281
|
+
consumeWithStream do |stream|
|
|
282
|
+
return stream.readTypeDiagnosticColor
|
|
283
|
+
end
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
# The Enum type ExportFormat.
|
|
288
|
+
|
|
289
|
+
def self.check_lower_TypeExportFormat(v)
|
|
290
|
+
if v.pdf?
|
|
291
|
+
return
|
|
292
|
+
end
|
|
293
|
+
if v.png?
|
|
294
|
+
|
|
295
|
+
return
|
|
296
|
+
end
|
|
297
|
+
if v.svg?
|
|
298
|
+
return
|
|
299
|
+
end
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
def self.alloc_from_TypeExportFormat(v)
|
|
303
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
304
|
+
builder.write_TypeExportFormat(v)
|
|
305
|
+
return builder.finalize
|
|
306
|
+
end
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
def consumeIntoTypeExportFormat
|
|
310
|
+
consumeWithStream do |stream|
|
|
311
|
+
return stream.readTypeExportFormat
|
|
312
|
+
end
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
# The Optional<T> type for u64.
|
|
319
|
+
|
|
320
|
+
def self.check_lower_Optionalu64(v)
|
|
321
|
+
if not v.nil?
|
|
322
|
+
|
|
323
|
+
end
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
def self.alloc_from_Optionalu64(v)
|
|
327
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
328
|
+
builder.write_Optionalu64(v)
|
|
329
|
+
return builder.finalize()
|
|
330
|
+
end
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
def consumeIntoOptionalu64
|
|
334
|
+
consumeWithStream do |stream|
|
|
335
|
+
return stream.readOptionalu64
|
|
336
|
+
end
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
# The Optional<T> type for string.
|
|
340
|
+
|
|
341
|
+
def self.check_lower_Optionalstring(v)
|
|
342
|
+
if not v.nil?
|
|
343
|
+
|
|
344
|
+
end
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
def self.alloc_from_Optionalstring(v)
|
|
348
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
349
|
+
builder.write_Optionalstring(v)
|
|
350
|
+
return builder.finalize()
|
|
351
|
+
end
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
def consumeIntoOptionalstring
|
|
355
|
+
consumeWithStream do |stream|
|
|
356
|
+
return stream.readOptionalstring
|
|
357
|
+
end
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
# The Optional<T> type for TypePageRange.
|
|
361
|
+
|
|
362
|
+
def self.check_lower_OptionalTypePageRange(v)
|
|
363
|
+
if not v.nil?
|
|
364
|
+
RustBuffer.check_lower_TypePageRange(v)
|
|
365
|
+
end
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
def self.alloc_from_OptionalTypePageRange(v)
|
|
369
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
370
|
+
builder.write_OptionalTypePageRange(v)
|
|
371
|
+
return builder.finalize()
|
|
372
|
+
end
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
def consumeIntoOptionalTypePageRange
|
|
376
|
+
consumeWithStream do |stream|
|
|
377
|
+
return stream.readOptionalTypePageRange
|
|
378
|
+
end
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
# The Optional<T> type for TypeZipLimits.
|
|
382
|
+
|
|
383
|
+
def self.check_lower_OptionalTypeZipLimits(v)
|
|
384
|
+
if not v.nil?
|
|
385
|
+
RustBuffer.check_lower_TypeZipLimits(v)
|
|
386
|
+
end
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
def self.alloc_from_OptionalTypeZipLimits(v)
|
|
390
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
391
|
+
builder.write_OptionalTypeZipLimits(v)
|
|
392
|
+
return builder.finalize()
|
|
393
|
+
end
|
|
394
|
+
end
|
|
395
|
+
|
|
396
|
+
def consumeIntoOptionalTypeZipLimits
|
|
397
|
+
consumeWithStream do |stream|
|
|
398
|
+
return stream.readOptionalTypeZipLimits
|
|
399
|
+
end
|
|
400
|
+
end
|
|
401
|
+
|
|
402
|
+
# The Sequence<T> type for string.
|
|
403
|
+
|
|
404
|
+
def self.check_lower_Sequencestring(v)
|
|
405
|
+
v.each do |item|
|
|
406
|
+
|
|
407
|
+
end
|
|
408
|
+
end
|
|
409
|
+
|
|
410
|
+
def self.alloc_from_Sequencestring(v)
|
|
411
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
412
|
+
builder.write_Sequencestring(v)
|
|
413
|
+
return builder.finalize()
|
|
414
|
+
end
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
def consumeIntoSequencestring
|
|
418
|
+
consumeWithStream do |stream|
|
|
419
|
+
return stream.readSequencestring
|
|
420
|
+
end
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
# The Sequence<T> type for bytes.
|
|
424
|
+
|
|
425
|
+
def self.check_lower_Sequencebytes(v)
|
|
426
|
+
v.each do |item|
|
|
427
|
+
|
|
428
|
+
end
|
|
429
|
+
end
|
|
430
|
+
|
|
431
|
+
def self.alloc_from_Sequencebytes(v)
|
|
432
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
433
|
+
builder.write_Sequencebytes(v)
|
|
434
|
+
return builder.finalize()
|
|
435
|
+
end
|
|
436
|
+
end
|
|
437
|
+
|
|
438
|
+
def consumeIntoSequencebytes
|
|
439
|
+
consumeWithStream do |stream|
|
|
440
|
+
return stream.readSequencebytes
|
|
441
|
+
end
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
# The Sequence<T> type for TypePageSize.
|
|
445
|
+
|
|
446
|
+
def self.check_lower_SequenceTypePageSize(v)
|
|
447
|
+
v.each do |item|
|
|
448
|
+
RustBuffer.check_lower_TypePageSize(item)
|
|
449
|
+
end
|
|
450
|
+
end
|
|
451
|
+
|
|
452
|
+
def self.alloc_from_SequenceTypePageSize(v)
|
|
453
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
454
|
+
builder.write_SequenceTypePageSize(v)
|
|
455
|
+
return builder.finalize()
|
|
456
|
+
end
|
|
457
|
+
end
|
|
458
|
+
|
|
459
|
+
def consumeIntoSequenceTypePageSize
|
|
460
|
+
consumeWithStream do |stream|
|
|
461
|
+
return stream.readSequenceTypePageSize
|
|
462
|
+
end
|
|
463
|
+
end
|
|
464
|
+
|
|
465
|
+
# The Sequence<T> type for TypeRegisteredFont.
|
|
466
|
+
|
|
467
|
+
def self.check_lower_SequenceTypeRegisteredFont(v)
|
|
468
|
+
v.each do |item|
|
|
469
|
+
RustBuffer.check_lower_TypeRegisteredFont(item)
|
|
470
|
+
end
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
def self.alloc_from_SequenceTypeRegisteredFont(v)
|
|
474
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
475
|
+
builder.write_SequenceTypeRegisteredFont(v)
|
|
476
|
+
return builder.finalize()
|
|
477
|
+
end
|
|
478
|
+
end
|
|
479
|
+
|
|
480
|
+
def consumeIntoSequenceTypeRegisteredFont
|
|
481
|
+
consumeWithStream do |stream|
|
|
482
|
+
return stream.readSequenceTypeRegisteredFont
|
|
483
|
+
end
|
|
484
|
+
end
|
|
485
|
+
|
|
486
|
+
# The Map<T> type for string.
|
|
487
|
+
|
|
488
|
+
def self.check_lower_MapStringString(v)
|
|
489
|
+
v.each do |k, v|
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
end
|
|
493
|
+
end
|
|
494
|
+
|
|
495
|
+
def self.alloc_from_MapStringString(v)
|
|
496
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
497
|
+
builder.write_MapStringString(v)
|
|
498
|
+
return builder.finalize
|
|
499
|
+
end
|
|
500
|
+
end
|
|
501
|
+
|
|
502
|
+
def consumeIntoMapStringString
|
|
503
|
+
consumeWithStream do |stream|
|
|
504
|
+
return stream.readMapStringString
|
|
505
|
+
end
|
|
506
|
+
end# The Map<T> type for TypeBlobInput.
|
|
507
|
+
|
|
508
|
+
def self.check_lower_MapStringTypeBlobInput(v)
|
|
509
|
+
v.each do |k, v|
|
|
510
|
+
|
|
511
|
+
RustBuffer.check_lower_TypeBlobInput(v)
|
|
512
|
+
end
|
|
513
|
+
end
|
|
514
|
+
|
|
515
|
+
def self.alloc_from_MapStringTypeBlobInput(v)
|
|
516
|
+
RustBuffer.allocWithBuilder do |builder|
|
|
517
|
+
builder.write_MapStringTypeBlobInput(v)
|
|
518
|
+
return builder.finalize
|
|
519
|
+
end
|
|
520
|
+
end
|
|
521
|
+
|
|
522
|
+
def consumeIntoMapStringTypeBlobInput
|
|
523
|
+
consumeWithStream do |stream|
|
|
524
|
+
return stream.readMapStringTypeBlobInput
|
|
525
|
+
end
|
|
526
|
+
end
|
|
527
|
+
end
|
|
528
|
+
|
|
529
|
+
module UniFFILib
|
|
530
|
+
class ForeignBytes < FFI::Struct
|
|
531
|
+
layout :len, :int32,
|
|
532
|
+
:data, :pointer
|
|
533
|
+
|
|
534
|
+
def len
|
|
535
|
+
self[:len]
|
|
536
|
+
end
|
|
537
|
+
|
|
538
|
+
def data
|
|
539
|
+
self[:data]
|
|
540
|
+
end
|
|
541
|
+
|
|
542
|
+
def to_s
|
|
543
|
+
"ForeignBytes(len=#{len}, data=#{data.read_bytes(len)})"
|
|
544
|
+
end
|
|
545
|
+
end
|
|
546
|
+
end
|
|
547
|
+
|
|
548
|
+
private_constant :UniFFILib
|
|
549
|
+
|
|
550
|
+
# Helper for structured reading of values from a RustBuffer.
|
|
551
|
+
class RustBufferStream
|
|
552
|
+
|
|
553
|
+
def initialize(rbuf)
|
|
554
|
+
@rbuf = rbuf
|
|
555
|
+
@offset = 0
|
|
556
|
+
end
|
|
557
|
+
|
|
558
|
+
def remaining
|
|
559
|
+
@rbuf.len - @offset
|
|
560
|
+
end
|
|
561
|
+
|
|
562
|
+
def read(size)
|
|
563
|
+
raise InternalError, 'read past end of rust buffer' if @offset + size > @rbuf.len
|
|
564
|
+
|
|
565
|
+
data = @rbuf.data.get_bytes @offset, size
|
|
566
|
+
|
|
567
|
+
@offset += size
|
|
568
|
+
|
|
569
|
+
data
|
|
570
|
+
end
|
|
571
|
+
|
|
572
|
+
def readU64
|
|
573
|
+
unpack_from 8, 'Q>'
|
|
574
|
+
end
|
|
575
|
+
|
|
576
|
+
def readF32
|
|
577
|
+
unpack_from 4, 'g'
|
|
578
|
+
end
|
|
579
|
+
|
|
580
|
+
def readF64
|
|
581
|
+
unpack_from 8, 'G'
|
|
582
|
+
end
|
|
583
|
+
|
|
584
|
+
def readBool
|
|
585
|
+
v = unpack_from 1, 'c'
|
|
586
|
+
|
|
587
|
+
return false if v == 0
|
|
588
|
+
return true if v == 1
|
|
589
|
+
|
|
590
|
+
raise InternalError, 'Unexpected byte for Boolean type'
|
|
591
|
+
end
|
|
592
|
+
|
|
593
|
+
def readString
|
|
594
|
+
size = unpack_from 4, 'l>'
|
|
595
|
+
|
|
596
|
+
raise InternalError, 'Unexpected negative string length' if size.negative?
|
|
597
|
+
|
|
598
|
+
read(size).force_encoding(Encoding::UTF_8)
|
|
599
|
+
end
|
|
600
|
+
|
|
601
|
+
def readBytes
|
|
602
|
+
size = unpack_from 4, 'l>'
|
|
603
|
+
|
|
604
|
+
raise InternalError, 'Unexpected negative byte string length' if size.negative?
|
|
605
|
+
|
|
606
|
+
read(size).force_encoding(Encoding::BINARY)
|
|
607
|
+
end
|
|
608
|
+
|
|
609
|
+
# The Object type CompiledDocument.
|
|
610
|
+
|
|
611
|
+
def readTypeCompiledDocument
|
|
612
|
+
handle = unpack_from 8, 'Q>'
|
|
613
|
+
return CompiledDocument.uniffi_allocate(handle)
|
|
614
|
+
end
|
|
615
|
+
|
|
616
|
+
# The Object type Template.
|
|
617
|
+
|
|
618
|
+
def readTypeTemplate
|
|
619
|
+
handle = unpack_from 8, 'Q>'
|
|
620
|
+
return Template.uniffi_allocate(handle)
|
|
621
|
+
end
|
|
622
|
+
|
|
623
|
+
# The Record type BlobInput.
|
|
624
|
+
|
|
625
|
+
def readTypeBlobInput
|
|
626
|
+
BlobInput.new(
|
|
627
|
+
data: readBytes,
|
|
628
|
+
metadata: readString
|
|
629
|
+
)
|
|
630
|
+
end
|
|
631
|
+
|
|
632
|
+
# The Record type ExportOnceResult.
|
|
633
|
+
|
|
634
|
+
def readTypeExportOnceResult
|
|
635
|
+
ExportOnceResult.new(
|
|
636
|
+
bytes: readBytes,
|
|
637
|
+
warnings: readOptionalstring
|
|
638
|
+
)
|
|
639
|
+
end
|
|
640
|
+
|
|
641
|
+
# The Record type PageRange.
|
|
642
|
+
|
|
643
|
+
def readTypePageRange
|
|
644
|
+
PageRange.new(
|
|
645
|
+
start: readOptionalu64,
|
|
646
|
+
_end: readOptionalu64
|
|
647
|
+
)
|
|
648
|
+
end
|
|
649
|
+
|
|
650
|
+
# The Record type PageSize.
|
|
651
|
+
|
|
652
|
+
def readTypePageSize
|
|
653
|
+
PageSize.new(
|
|
654
|
+
width: readF64,
|
|
655
|
+
height: readF64
|
|
656
|
+
)
|
|
657
|
+
end
|
|
658
|
+
|
|
659
|
+
# The Record type RegisteredFont.
|
|
660
|
+
|
|
661
|
+
def readTypeRegisteredFont
|
|
662
|
+
RegisteredFont.new(
|
|
663
|
+
family: readString,
|
|
664
|
+
path: readOptionalstring
|
|
665
|
+
)
|
|
666
|
+
end
|
|
667
|
+
|
|
668
|
+
# The Record type ZipLimits.
|
|
669
|
+
|
|
670
|
+
def readTypeZipLimits
|
|
671
|
+
ZipLimits.new(
|
|
672
|
+
max_entries: readOptionalu64,
|
|
673
|
+
max_total_decompressed_bytes: readOptionalu64
|
|
674
|
+
)
|
|
675
|
+
end
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
# The Enum type CompilationMode.
|
|
680
|
+
|
|
681
|
+
def readTypeCompilationMode
|
|
682
|
+
variant = unpack_from 4, 'l>'
|
|
683
|
+
|
|
684
|
+
if variant == 1
|
|
685
|
+
return CompilationMode::DEVELOPMENT
|
|
686
|
+
end
|
|
687
|
+
if variant == 2
|
|
688
|
+
return CompilationMode::PRODUCTION
|
|
689
|
+
end
|
|
690
|
+
|
|
691
|
+
raise InternalError, 'Unexpected variant tag for TypeCompilationMode'
|
|
692
|
+
end
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
# The Enum type DiagnosticColor.
|
|
699
|
+
|
|
700
|
+
def readTypeDiagnosticColor
|
|
701
|
+
variant = unpack_from 4, 'l>'
|
|
702
|
+
|
|
703
|
+
if variant == 1
|
|
704
|
+
return DiagnosticColor::NONE
|
|
705
|
+
end
|
|
706
|
+
if variant == 2
|
|
707
|
+
return DiagnosticColor::ANSI
|
|
708
|
+
end
|
|
709
|
+
|
|
710
|
+
raise InternalError, 'Unexpected variant tag for TypeDiagnosticColor'
|
|
711
|
+
end
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
|
|
717
|
+
# The Enum type ExportFormat.
|
|
718
|
+
|
|
719
|
+
def readTypeExportFormat
|
|
720
|
+
variant = unpack_from 4, 'l>'
|
|
721
|
+
|
|
722
|
+
if variant == 1
|
|
723
|
+
return ExportFormat::PDF.new
|
|
724
|
+
|
|
725
|
+
end
|
|
726
|
+
if variant == 2
|
|
727
|
+
return ExportFormat::PNG.new(
|
|
728
|
+
self.readF32()
|
|
729
|
+
)
|
|
730
|
+
end
|
|
731
|
+
if variant == 3
|
|
732
|
+
return ExportFormat::SVG.new
|
|
733
|
+
|
|
734
|
+
end
|
|
735
|
+
raise InternalError, 'Unexpected variant tag for TypeExportFormat'
|
|
736
|
+
end
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
|
|
744
|
+
# The Error type OicanaError
|
|
745
|
+
|
|
746
|
+
def readTypeOicanaError
|
|
747
|
+
variant = unpack_from 4, 'l>'
|
|
748
|
+
|
|
749
|
+
if variant == 1
|
|
750
|
+
return OicanaError::InvalidTemplate.new(
|
|
751
|
+
readString()
|
|
752
|
+
)
|
|
753
|
+
end
|
|
754
|
+
if variant == 2
|
|
755
|
+
return OicanaError::InvalidInput.new(
|
|
756
|
+
readString()
|
|
757
|
+
)
|
|
758
|
+
end
|
|
759
|
+
if variant == 3
|
|
760
|
+
return OicanaError::Compilation.new(
|
|
761
|
+
readString()
|
|
762
|
+
)
|
|
763
|
+
end
|
|
764
|
+
if variant == 4
|
|
765
|
+
return OicanaError::FileNotFound.new(
|
|
766
|
+
readString()
|
|
767
|
+
)
|
|
768
|
+
end
|
|
769
|
+
if variant == 5
|
|
770
|
+
return OicanaError::Export.new(
|
|
771
|
+
readString()
|
|
772
|
+
)
|
|
773
|
+
end
|
|
774
|
+
if variant == 6
|
|
775
|
+
return OicanaError::NotFound.new(
|
|
776
|
+
readString()
|
|
777
|
+
)
|
|
778
|
+
end
|
|
779
|
+
if variant == 7
|
|
780
|
+
return OicanaError::Internal.new(
|
|
781
|
+
readString()
|
|
782
|
+
)
|
|
783
|
+
end
|
|
784
|
+
|
|
785
|
+
raise InternalError, 'Unexpected variant tag for TypeOicanaError'
|
|
786
|
+
end
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
# The Optional<T> type for u64.
|
|
790
|
+
|
|
791
|
+
def readOptionalu64
|
|
792
|
+
flag = unpack_from 1, 'c'
|
|
793
|
+
|
|
794
|
+
if flag == 0
|
|
795
|
+
return nil
|
|
796
|
+
elsif flag == 1
|
|
797
|
+
return readU64
|
|
798
|
+
else
|
|
799
|
+
raise InternalError, 'Unexpected flag byte for Optionalu64'
|
|
800
|
+
end
|
|
801
|
+
end
|
|
802
|
+
|
|
803
|
+
# The Optional<T> type for string.
|
|
804
|
+
|
|
805
|
+
def readOptionalstring
|
|
806
|
+
flag = unpack_from 1, 'c'
|
|
807
|
+
|
|
808
|
+
if flag == 0
|
|
809
|
+
return nil
|
|
810
|
+
elsif flag == 1
|
|
811
|
+
return readString
|
|
812
|
+
else
|
|
813
|
+
raise InternalError, 'Unexpected flag byte for Optionalstring'
|
|
814
|
+
end
|
|
815
|
+
end
|
|
816
|
+
|
|
817
|
+
# The Optional<T> type for TypePageRange.
|
|
818
|
+
|
|
819
|
+
def readOptionalTypePageRange
|
|
820
|
+
flag = unpack_from 1, 'c'
|
|
821
|
+
|
|
822
|
+
if flag == 0
|
|
823
|
+
return nil
|
|
824
|
+
elsif flag == 1
|
|
825
|
+
return readTypePageRange
|
|
826
|
+
else
|
|
827
|
+
raise InternalError, 'Unexpected flag byte for OptionalTypePageRange'
|
|
828
|
+
end
|
|
829
|
+
end
|
|
830
|
+
|
|
831
|
+
# The Optional<T> type for TypeZipLimits.
|
|
832
|
+
|
|
833
|
+
def readOptionalTypeZipLimits
|
|
834
|
+
flag = unpack_from 1, 'c'
|
|
835
|
+
|
|
836
|
+
if flag == 0
|
|
837
|
+
return nil
|
|
838
|
+
elsif flag == 1
|
|
839
|
+
return readTypeZipLimits
|
|
840
|
+
else
|
|
841
|
+
raise InternalError, 'Unexpected flag byte for OptionalTypeZipLimits'
|
|
842
|
+
end
|
|
843
|
+
end
|
|
844
|
+
|
|
845
|
+
# The Sequence<T> type for string.
|
|
846
|
+
|
|
847
|
+
def readSequencestring
|
|
848
|
+
count = unpack_from 4, 'l>'
|
|
849
|
+
|
|
850
|
+
raise InternalError, 'Unexpected negative sequence length' if count.negative?
|
|
851
|
+
|
|
852
|
+
items = []
|
|
853
|
+
|
|
854
|
+
count.times do
|
|
855
|
+
items.append readString
|
|
856
|
+
end
|
|
857
|
+
|
|
858
|
+
items
|
|
859
|
+
end
|
|
860
|
+
|
|
861
|
+
# The Sequence<T> type for bytes.
|
|
862
|
+
|
|
863
|
+
def readSequencebytes
|
|
864
|
+
count = unpack_from 4, 'l>'
|
|
865
|
+
|
|
866
|
+
raise InternalError, 'Unexpected negative sequence length' if count.negative?
|
|
867
|
+
|
|
868
|
+
items = []
|
|
869
|
+
|
|
870
|
+
count.times do
|
|
871
|
+
items.append readBytes
|
|
872
|
+
end
|
|
873
|
+
|
|
874
|
+
items
|
|
875
|
+
end
|
|
876
|
+
|
|
877
|
+
# The Sequence<T> type for TypePageSize.
|
|
878
|
+
|
|
879
|
+
def readSequenceTypePageSize
|
|
880
|
+
count = unpack_from 4, 'l>'
|
|
881
|
+
|
|
882
|
+
raise InternalError, 'Unexpected negative sequence length' if count.negative?
|
|
883
|
+
|
|
884
|
+
items = []
|
|
885
|
+
|
|
886
|
+
count.times do
|
|
887
|
+
items.append readTypePageSize
|
|
888
|
+
end
|
|
889
|
+
|
|
890
|
+
items
|
|
891
|
+
end
|
|
892
|
+
|
|
893
|
+
# The Sequence<T> type for TypeRegisteredFont.
|
|
894
|
+
|
|
895
|
+
def readSequenceTypeRegisteredFont
|
|
896
|
+
count = unpack_from 4, 'l>'
|
|
897
|
+
|
|
898
|
+
raise InternalError, 'Unexpected negative sequence length' if count.negative?
|
|
899
|
+
|
|
900
|
+
items = []
|
|
901
|
+
|
|
902
|
+
count.times do
|
|
903
|
+
items.append readTypeRegisteredFont
|
|
904
|
+
end
|
|
905
|
+
|
|
906
|
+
items
|
|
907
|
+
end
|
|
908
|
+
|
|
909
|
+
# The Map<T> type for string.
|
|
910
|
+
|
|
911
|
+
def readMapStringString
|
|
912
|
+
count = unpack_from 4, 'l>'
|
|
913
|
+
raise InternalError, 'Unexpected negative map size' if count.negative?
|
|
914
|
+
|
|
915
|
+
items = {}
|
|
916
|
+
count.times do
|
|
917
|
+
key = readString
|
|
918
|
+
items[key] = readString
|
|
919
|
+
end
|
|
920
|
+
|
|
921
|
+
items
|
|
922
|
+
end# The Map<T> type for TypeBlobInput.
|
|
923
|
+
|
|
924
|
+
def readMapStringTypeBlobInput
|
|
925
|
+
count = unpack_from 4, 'l>'
|
|
926
|
+
raise InternalError, 'Unexpected negative map size' if count.negative?
|
|
927
|
+
|
|
928
|
+
items = {}
|
|
929
|
+
count.times do
|
|
930
|
+
key = readString
|
|
931
|
+
items[key] = readTypeBlobInput
|
|
932
|
+
end
|
|
933
|
+
|
|
934
|
+
items
|
|
935
|
+
end
|
|
936
|
+
|
|
937
|
+
def unpack_from(size, format)
|
|
938
|
+
raise InternalError, 'read past end of rust buffer' if @offset + size > @rbuf.len
|
|
939
|
+
|
|
940
|
+
value = @rbuf.data.get_bytes(@offset, size).unpack format
|
|
941
|
+
|
|
942
|
+
@offset += size
|
|
943
|
+
|
|
944
|
+
# TODO: verify this
|
|
945
|
+
raise 'more than one element!!!' if value.size > 1
|
|
946
|
+
|
|
947
|
+
value[0]
|
|
948
|
+
end
|
|
949
|
+
end
|
|
950
|
+
|
|
951
|
+
private_constant :RustBufferStream
|
|
952
|
+
|
|
953
|
+
# Helper for structured writing of values into a RustBuffer.
|
|
954
|
+
class RustBufferBuilder
|
|
955
|
+
def initialize
|
|
956
|
+
@rust_buf = RustBuffer.alloc 16
|
|
957
|
+
@rust_buf.len = 0
|
|
958
|
+
end
|
|
959
|
+
|
|
960
|
+
def finalize
|
|
961
|
+
rbuf = @rust_buf
|
|
962
|
+
|
|
963
|
+
@rust_buf = nil
|
|
964
|
+
|
|
965
|
+
rbuf
|
|
966
|
+
end
|
|
967
|
+
|
|
968
|
+
def discard
|
|
969
|
+
return if @rust_buf.nil?
|
|
970
|
+
|
|
971
|
+
rbuf = finalize
|
|
972
|
+
rbuf.free
|
|
973
|
+
end
|
|
974
|
+
|
|
975
|
+
def write(value)
|
|
976
|
+
reserve(value.bytes.size) do
|
|
977
|
+
@rust_buf.data.put_array_of_char @rust_buf.len, value.bytes
|
|
978
|
+
end
|
|
979
|
+
end
|
|
980
|
+
|
|
981
|
+
def write_U64(v)
|
|
982
|
+
v = OicanaUniffi::uniffi_in_range(v, "u64", 0, 2**64)
|
|
983
|
+
pack_into(8, 'Q>', v)
|
|
984
|
+
end
|
|
985
|
+
|
|
986
|
+
def write_F32(v)
|
|
987
|
+
pack_into(4, 'g', v)
|
|
988
|
+
end
|
|
989
|
+
|
|
990
|
+
def write_F64(v)
|
|
991
|
+
pack_into(8, 'G', v)
|
|
992
|
+
end
|
|
993
|
+
|
|
994
|
+
def write_Bool(v)
|
|
995
|
+
pack_into(1, 'c', v ? 1 : 0)
|
|
996
|
+
end
|
|
997
|
+
|
|
998
|
+
def write_String(v)
|
|
999
|
+
v = OicanaUniffi::uniffi_utf8(v)
|
|
1000
|
+
pack_into 4, 'l>', v.bytes.size
|
|
1001
|
+
write v
|
|
1002
|
+
end
|
|
1003
|
+
|
|
1004
|
+
def write_Bytes(v)
|
|
1005
|
+
v = OicanaUniffi::uniffi_bytes(v)
|
|
1006
|
+
pack_into 4, 'l>', v.bytes.size
|
|
1007
|
+
write v
|
|
1008
|
+
end
|
|
1009
|
+
|
|
1010
|
+
# The Object type CompiledDocument.
|
|
1011
|
+
|
|
1012
|
+
def write_TypeCompiledDocument(obj)
|
|
1013
|
+
handle = CompiledDocument.uniffi_lower obj
|
|
1014
|
+
pack_into(8, 'Q>', handle)
|
|
1015
|
+
end
|
|
1016
|
+
|
|
1017
|
+
# The Object type Template.
|
|
1018
|
+
|
|
1019
|
+
def write_TypeTemplate(obj)
|
|
1020
|
+
handle = Template.uniffi_lower obj
|
|
1021
|
+
pack_into(8, 'Q>', handle)
|
|
1022
|
+
end
|
|
1023
|
+
|
|
1024
|
+
# The Record type BlobInput.
|
|
1025
|
+
|
|
1026
|
+
def write_TypeBlobInput(v)
|
|
1027
|
+
self.write_Bytes(v.data)
|
|
1028
|
+
self.write_String(v.metadata)
|
|
1029
|
+
end
|
|
1030
|
+
|
|
1031
|
+
# The Record type ExportOnceResult.
|
|
1032
|
+
|
|
1033
|
+
def write_TypeExportOnceResult(v)
|
|
1034
|
+
self.write_Bytes(v.bytes)
|
|
1035
|
+
self.write_Optionalstring(v.warnings)
|
|
1036
|
+
end
|
|
1037
|
+
|
|
1038
|
+
# The Record type PageRange.
|
|
1039
|
+
|
|
1040
|
+
def write_TypePageRange(v)
|
|
1041
|
+
self.write_Optionalu64(v.start)
|
|
1042
|
+
self.write_Optionalu64(v._end)
|
|
1043
|
+
end
|
|
1044
|
+
|
|
1045
|
+
# The Record type PageSize.
|
|
1046
|
+
|
|
1047
|
+
def write_TypePageSize(v)
|
|
1048
|
+
self.write_F64(v.width)
|
|
1049
|
+
self.write_F64(v.height)
|
|
1050
|
+
end
|
|
1051
|
+
|
|
1052
|
+
# The Record type RegisteredFont.
|
|
1053
|
+
|
|
1054
|
+
def write_TypeRegisteredFont(v)
|
|
1055
|
+
self.write_String(v.family)
|
|
1056
|
+
self.write_Optionalstring(v.path)
|
|
1057
|
+
end
|
|
1058
|
+
|
|
1059
|
+
# The Record type ZipLimits.
|
|
1060
|
+
|
|
1061
|
+
def write_TypeZipLimits(v)
|
|
1062
|
+
self.write_Optionalu64(v.max_entries)
|
|
1063
|
+
self.write_Optionalu64(v.max_total_decompressed_bytes)
|
|
1064
|
+
end
|
|
1065
|
+
|
|
1066
|
+
# The Enum type CompilationMode.
|
|
1067
|
+
|
|
1068
|
+
def write_TypeCompilationMode(v)
|
|
1069
|
+
pack_into(4, 'l>', v)
|
|
1070
|
+
end
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
# The Enum type DiagnosticColor.
|
|
1074
|
+
|
|
1075
|
+
def write_TypeDiagnosticColor(v)
|
|
1076
|
+
pack_into(4, 'l>', v)
|
|
1077
|
+
end
|
|
1078
|
+
|
|
1079
|
+
|
|
1080
|
+
# The Enum type ExportFormat.
|
|
1081
|
+
|
|
1082
|
+
def write_TypeExportFormat(v)
|
|
1083
|
+
if v.pdf?
|
|
1084
|
+
pack_into(4, 'l>', 1)
|
|
1085
|
+
end
|
|
1086
|
+
if v.png?
|
|
1087
|
+
pack_into(4, 'l>', 2)
|
|
1088
|
+
self.write_F32(v.pixels_per_pt)
|
|
1089
|
+
end
|
|
1090
|
+
if v.svg?
|
|
1091
|
+
pack_into(4, 'l>', 3)
|
|
1092
|
+
end
|
|
1093
|
+
end
|
|
1094
|
+
|
|
1095
|
+
|
|
1096
|
+
|
|
1097
|
+
|
|
1098
|
+
# The Optional<T> type for u64.
|
|
1099
|
+
|
|
1100
|
+
def write_Optionalu64(v)
|
|
1101
|
+
if v.nil?
|
|
1102
|
+
pack_into(1, 'c', 0)
|
|
1103
|
+
else
|
|
1104
|
+
pack_into(1, 'c', 1)
|
|
1105
|
+
self.write_U64(v)
|
|
1106
|
+
end
|
|
1107
|
+
end
|
|
1108
|
+
|
|
1109
|
+
# The Optional<T> type for string.
|
|
1110
|
+
|
|
1111
|
+
def write_Optionalstring(v)
|
|
1112
|
+
if v.nil?
|
|
1113
|
+
pack_into(1, 'c', 0)
|
|
1114
|
+
else
|
|
1115
|
+
pack_into(1, 'c', 1)
|
|
1116
|
+
self.write_String(v)
|
|
1117
|
+
end
|
|
1118
|
+
end
|
|
1119
|
+
|
|
1120
|
+
# The Optional<T> type for TypePageRange.
|
|
1121
|
+
|
|
1122
|
+
def write_OptionalTypePageRange(v)
|
|
1123
|
+
if v.nil?
|
|
1124
|
+
pack_into(1, 'c', 0)
|
|
1125
|
+
else
|
|
1126
|
+
pack_into(1, 'c', 1)
|
|
1127
|
+
self.write_TypePageRange(v)
|
|
1128
|
+
end
|
|
1129
|
+
end
|
|
1130
|
+
|
|
1131
|
+
# The Optional<T> type for TypeZipLimits.
|
|
1132
|
+
|
|
1133
|
+
def write_OptionalTypeZipLimits(v)
|
|
1134
|
+
if v.nil?
|
|
1135
|
+
pack_into(1, 'c', 0)
|
|
1136
|
+
else
|
|
1137
|
+
pack_into(1, 'c', 1)
|
|
1138
|
+
self.write_TypeZipLimits(v)
|
|
1139
|
+
end
|
|
1140
|
+
end
|
|
1141
|
+
|
|
1142
|
+
# The Sequence<T> type for string.
|
|
1143
|
+
|
|
1144
|
+
def write_Sequencestring(items)
|
|
1145
|
+
pack_into(4, 'l>', items.size)
|
|
1146
|
+
|
|
1147
|
+
items.each do |item|
|
|
1148
|
+
self.write_String(item)
|
|
1149
|
+
end
|
|
1150
|
+
end
|
|
1151
|
+
|
|
1152
|
+
# The Sequence<T> type for bytes.
|
|
1153
|
+
|
|
1154
|
+
def write_Sequencebytes(items)
|
|
1155
|
+
pack_into(4, 'l>', items.size)
|
|
1156
|
+
|
|
1157
|
+
items.each do |item|
|
|
1158
|
+
self.write_Bytes(item)
|
|
1159
|
+
end
|
|
1160
|
+
end
|
|
1161
|
+
|
|
1162
|
+
# The Sequence<T> type for TypePageSize.
|
|
1163
|
+
|
|
1164
|
+
def write_SequenceTypePageSize(items)
|
|
1165
|
+
pack_into(4, 'l>', items.size)
|
|
1166
|
+
|
|
1167
|
+
items.each do |item|
|
|
1168
|
+
self.write_TypePageSize(item)
|
|
1169
|
+
end
|
|
1170
|
+
end
|
|
1171
|
+
|
|
1172
|
+
# The Sequence<T> type for TypeRegisteredFont.
|
|
1173
|
+
|
|
1174
|
+
def write_SequenceTypeRegisteredFont(items)
|
|
1175
|
+
pack_into(4, 'l>', items.size)
|
|
1176
|
+
|
|
1177
|
+
items.each do |item|
|
|
1178
|
+
self.write_TypeRegisteredFont(item)
|
|
1179
|
+
end
|
|
1180
|
+
end
|
|
1181
|
+
|
|
1182
|
+
# The Map<T> type for string.
|
|
1183
|
+
|
|
1184
|
+
def write_MapStringString(items)
|
|
1185
|
+
pack_into(4, 'l>', items.size)
|
|
1186
|
+
|
|
1187
|
+
items.each do |k, v|
|
|
1188
|
+
write_String(k)
|
|
1189
|
+
self.write_String(v)
|
|
1190
|
+
end
|
|
1191
|
+
end# The Map<T> type for TypeBlobInput.
|
|
1192
|
+
|
|
1193
|
+
def write_MapStringTypeBlobInput(items)
|
|
1194
|
+
pack_into(4, 'l>', items.size)
|
|
1195
|
+
|
|
1196
|
+
items.each do |k, v|
|
|
1197
|
+
write_String(k)
|
|
1198
|
+
self.write_TypeBlobInput(v)
|
|
1199
|
+
end
|
|
1200
|
+
end
|
|
1201
|
+
|
|
1202
|
+
private
|
|
1203
|
+
|
|
1204
|
+
def reserve(num_bytes)
|
|
1205
|
+
if @rust_buf.len + num_bytes > @rust_buf.capacity
|
|
1206
|
+
@rust_buf = RustBuffer.reserve(@rust_buf, num_bytes)
|
|
1207
|
+
end
|
|
1208
|
+
|
|
1209
|
+
yield
|
|
1210
|
+
|
|
1211
|
+
@rust_buf.len += num_bytes
|
|
1212
|
+
end
|
|
1213
|
+
|
|
1214
|
+
def pack_into(size, format, value)
|
|
1215
|
+
reserve(size) do
|
|
1216
|
+
@rust_buf.data.put_array_of_char @rust_buf.len, [value].pack(format).bytes
|
|
1217
|
+
end
|
|
1218
|
+
end
|
|
1219
|
+
end
|
|
1220
|
+
|
|
1221
|
+
private_constant :RustBufferBuilder
|
|
1222
|
+
|
|
1223
|
+
# Error definitions
|
|
1224
|
+
class RustCallStatus < FFI::Struct
|
|
1225
|
+
layout :code, :int8,
|
|
1226
|
+
:error_buf, RustBuffer
|
|
1227
|
+
|
|
1228
|
+
def code
|
|
1229
|
+
self[:code]
|
|
1230
|
+
end
|
|
1231
|
+
|
|
1232
|
+
def error_buf
|
|
1233
|
+
self[:error_buf]
|
|
1234
|
+
end
|
|
1235
|
+
|
|
1236
|
+
def to_s
|
|
1237
|
+
"RustCallStatus(code=#{self[:code]})"
|
|
1238
|
+
end
|
|
1239
|
+
end
|
|
1240
|
+
|
|
1241
|
+
# These match the values from the uniffi::rustcalls module
|
|
1242
|
+
CALL_SUCCESS = 0
|
|
1243
|
+
CALL_ERROR = 1
|
|
1244
|
+
CALL_PANIC = 2
|
|
1245
|
+
|
|
1246
|
+
|
|
1247
|
+
class OicanaError
|
|
1248
|
+
InvalidTemplate = Class.new StandardError
|
|
1249
|
+
InvalidInput = Class.new StandardError
|
|
1250
|
+
Compilation = Class.new StandardError
|
|
1251
|
+
FileNotFound = Class.new StandardError
|
|
1252
|
+
Export = Class.new StandardError
|
|
1253
|
+
NotFound = Class.new StandardError
|
|
1254
|
+
Internal = Class.new StandardError
|
|
1255
|
+
|
|
1256
|
+
end
|
|
1257
|
+
|
|
1258
|
+
|
|
1259
|
+
|
|
1260
|
+
|
|
1261
|
+
|
|
1262
|
+
# Map error modules to the RustBuffer method name that reads them
|
|
1263
|
+
ERROR_MODULE_TO_READER_METHOD = {
|
|
1264
|
+
|
|
1265
|
+
OicanaError => :readTypeOicanaError,
|
|
1266
|
+
|
|
1267
|
+
|
|
1268
|
+
|
|
1269
|
+
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
private_constant :ERROR_MODULE_TO_READER_METHOD, :CALL_SUCCESS, :CALL_ERROR, :CALL_PANIC,
|
|
1273
|
+
:RustCallStatus
|
|
1274
|
+
|
|
1275
|
+
def self.consume_buffer_into_error(error_module, rust_buffer)
|
|
1276
|
+
rust_buffer.consumeWithStream do |stream|
|
|
1277
|
+
reader_method = ERROR_MODULE_TO_READER_METHOD[error_module]
|
|
1278
|
+
return stream.send(reader_method)
|
|
1279
|
+
end
|
|
1280
|
+
end
|
|
1281
|
+
|
|
1282
|
+
class InternalError < StandardError
|
|
1283
|
+
end
|
|
1284
|
+
|
|
1285
|
+
def self.rust_call(fn_name, *args)
|
|
1286
|
+
# Call a rust function
|
|
1287
|
+
rust_call_with_error(nil, fn_name, *args)
|
|
1288
|
+
end
|
|
1289
|
+
|
|
1290
|
+
def self.rust_call_with_error(error_module, fn_name, *args)
|
|
1291
|
+
# Call a rust function and handle errors
|
|
1292
|
+
#
|
|
1293
|
+
# Use this when the rust function returns a Result<>. error_module must be the error_module that corresponds to that Result.
|
|
1294
|
+
|
|
1295
|
+
|
|
1296
|
+
# Note: RustCallStatus.new zeroes out the struct, which is exactly what we
|
|
1297
|
+
# want to pass to Rust (code=0, error_buf=RustBuffer(len=0, capacity=0,
|
|
1298
|
+
# data=NULL))
|
|
1299
|
+
status = RustCallStatus.new
|
|
1300
|
+
args << status
|
|
1301
|
+
|
|
1302
|
+
result = UniFFILib.public_send(fn_name, *args)
|
|
1303
|
+
|
|
1304
|
+
case status.code
|
|
1305
|
+
when CALL_SUCCESS
|
|
1306
|
+
result
|
|
1307
|
+
when CALL_ERROR
|
|
1308
|
+
if error_module.nil?
|
|
1309
|
+
status.error_buf.free
|
|
1310
|
+
raise InternalError, "CALL_ERROR with no error_module set"
|
|
1311
|
+
else
|
|
1312
|
+
raise consume_buffer_into_error(error_module, status.error_buf)
|
|
1313
|
+
end
|
|
1314
|
+
when CALL_PANIC
|
|
1315
|
+
# When the rust code sees a panic, it tries to construct a RustBuffer
|
|
1316
|
+
# with the message. But if that code panics, then it just sends back
|
|
1317
|
+
# an empty buffer.
|
|
1318
|
+
if status.error_buf.len > 0
|
|
1319
|
+
raise InternalError, status.error_buf.consumeIntoString()
|
|
1320
|
+
else
|
|
1321
|
+
raise InternalError, "Rust panic"
|
|
1322
|
+
end
|
|
1323
|
+
else
|
|
1324
|
+
raise InternalError, "Unknown call status: #{status.code}"
|
|
1325
|
+
end
|
|
1326
|
+
end
|
|
1327
|
+
|
|
1328
|
+
private_class_method :consume_buffer_into_error
|
|
1329
|
+
|
|
1330
|
+
# This is how we find and load the dynamic library provided by the component.
|
|
1331
|
+
# For now we just look it up by name.
|
|
1332
|
+
module UniFFILib
|
|
1333
|
+
extend FFI::Library
|
|
1334
|
+
|
|
1335
|
+
|
|
1336
|
+
ffi_lib ::Oicana::Native.prepare(self)
|
|
1337
|
+
|
|
1338
|
+
|
|
1339
|
+
attach_function :uniffi_oicana_uniffi_fn_clone_compileddocument,
|
|
1340
|
+
[:uint64, RustCallStatus.by_ref],
|
|
1341
|
+
:uint64
|
|
1342
|
+
attach_function :uniffi_oicana_uniffi_fn_free_compileddocument,
|
|
1343
|
+
[:uint64, RustCallStatus.by_ref],
|
|
1344
|
+
:void
|
|
1345
|
+
attach_function :uniffi_oicana_uniffi_fn_method_compileddocument_export,
|
|
1346
|
+
[:uint64, RustBuffer.by_value, RustBuffer.by_value, RustCallStatus.by_ref],
|
|
1347
|
+
RustBuffer.by_value
|
|
1348
|
+
attach_function :uniffi_oicana_uniffi_fn_method_compileddocument_pages,
|
|
1349
|
+
[:uint64, RustCallStatus.by_ref],
|
|
1350
|
+
RustBuffer.by_value
|
|
1351
|
+
attach_function :uniffi_oicana_uniffi_fn_method_compileddocument_warnings,
|
|
1352
|
+
[:uint64, RustCallStatus.by_ref],
|
|
1353
|
+
RustBuffer.by_value
|
|
1354
|
+
attach_function :uniffi_oicana_uniffi_fn_clone_template,
|
|
1355
|
+
[:uint64, RustCallStatus.by_ref],
|
|
1356
|
+
:uint64
|
|
1357
|
+
attach_function :uniffi_oicana_uniffi_fn_free_template,
|
|
1358
|
+
[:uint64, RustCallStatus.by_ref],
|
|
1359
|
+
:void
|
|
1360
|
+
attach_function :uniffi_oicana_uniffi_fn_constructor_template_new,
|
|
1361
|
+
[RustBuffer.by_value, RustBuffer.by_value, RustBuffer.by_value, RustBuffer.by_value, RustBuffer.by_value, RustCallStatus.by_ref],
|
|
1362
|
+
:uint64
|
|
1363
|
+
attach_function :uniffi_oicana_uniffi_fn_method_template_compile,
|
|
1364
|
+
[:uint64, RustBuffer.by_value, RustBuffer.by_value, RustBuffer.by_value, RustCallStatus.by_ref],
|
|
1365
|
+
:uint64
|
|
1366
|
+
attach_function :uniffi_oicana_uniffi_fn_method_template_file,
|
|
1367
|
+
[:uint64, RustBuffer.by_value, RustCallStatus.by_ref],
|
|
1368
|
+
RustBuffer.by_value
|
|
1369
|
+
attach_function :uniffi_oicana_uniffi_fn_method_template_manifest,
|
|
1370
|
+
[:uint64, RustCallStatus.by_ref],
|
|
1371
|
+
RustBuffer.by_value
|
|
1372
|
+
attach_function :uniffi_oicana_uniffi_fn_method_template_set_validate_inputs,
|
|
1373
|
+
[:uint64, :int8, RustCallStatus.by_ref],
|
|
1374
|
+
:void
|
|
1375
|
+
attach_function :uniffi_oicana_uniffi_fn_method_template_source,
|
|
1376
|
+
[:uint64, RustBuffer.by_value, RustCallStatus.by_ref],
|
|
1377
|
+
RustBuffer.by_value
|
|
1378
|
+
attach_function :uniffi_oicana_uniffi_fn_method_template_warnings,
|
|
1379
|
+
[:uint64, RustCallStatus.by_ref],
|
|
1380
|
+
RustBuffer.by_value
|
|
1381
|
+
attach_function :uniffi_oicana_uniffi_fn_func_clear_fonts,
|
|
1382
|
+
[RustCallStatus.by_ref],
|
|
1383
|
+
:void
|
|
1384
|
+
attach_function :uniffi_oicana_uniffi_fn_func_configure_automatic_cache_eviction,
|
|
1385
|
+
[RustBuffer.by_value, RustCallStatus.by_ref],
|
|
1386
|
+
:void
|
|
1387
|
+
attach_function :uniffi_oicana_uniffi_fn_func_configure_diagnostic_color,
|
|
1388
|
+
[RustBuffer.by_value, RustCallStatus.by_ref],
|
|
1389
|
+
:void
|
|
1390
|
+
attach_function :uniffi_oicana_uniffi_fn_func_evict_cache,
|
|
1391
|
+
[:uint64, RustCallStatus.by_ref],
|
|
1392
|
+
:void
|
|
1393
|
+
attach_function :uniffi_oicana_uniffi_fn_func_export_once,
|
|
1394
|
+
[RustBuffer.by_value, RustBuffer.by_value, RustBuffer.by_value, RustBuffer.by_value, RustBuffer.by_value, RustBuffer.by_value, RustBuffer.by_value, RustCallStatus.by_ref],
|
|
1395
|
+
RustBuffer.by_value
|
|
1396
|
+
attach_function :uniffi_oicana_uniffi_fn_func_register_font_paths,
|
|
1397
|
+
[RustBuffer.by_value, RustCallStatus.by_ref],
|
|
1398
|
+
:uint64
|
|
1399
|
+
attach_function :uniffi_oicana_uniffi_fn_func_register_fonts,
|
|
1400
|
+
[RustBuffer.by_value, RustCallStatus.by_ref],
|
|
1401
|
+
:uint64
|
|
1402
|
+
attach_function :uniffi_oicana_uniffi_fn_func_registered_fonts,
|
|
1403
|
+
[RustCallStatus.by_ref],
|
|
1404
|
+
RustBuffer.by_value
|
|
1405
|
+
attach_function :uniffi_oicana_uniffi_fn_func_version,
|
|
1406
|
+
[RustCallStatus.by_ref],
|
|
1407
|
+
RustBuffer.by_value
|
|
1408
|
+
attach_function :ffi_oicana_uniffi_rustbuffer_alloc,
|
|
1409
|
+
[:uint64, RustCallStatus.by_ref],
|
|
1410
|
+
RustBuffer.by_value
|
|
1411
|
+
attach_function :ffi_oicana_uniffi_rustbuffer_from_bytes,
|
|
1412
|
+
[ForeignBytes, RustCallStatus.by_ref],
|
|
1413
|
+
RustBuffer.by_value
|
|
1414
|
+
attach_function :ffi_oicana_uniffi_rustbuffer_free,
|
|
1415
|
+
[RustBuffer.by_value, RustCallStatus.by_ref],
|
|
1416
|
+
:void
|
|
1417
|
+
attach_function :ffi_oicana_uniffi_rustbuffer_reserve,
|
|
1418
|
+
[RustBuffer.by_value, :uint64, RustCallStatus.by_ref],
|
|
1419
|
+
RustBuffer.by_value
|
|
1420
|
+
attach_function :uniffi_oicana_uniffi_checksum_func_clear_fonts,
|
|
1421
|
+
[RustCallStatus.by_ref],
|
|
1422
|
+
:uint16
|
|
1423
|
+
attach_function :uniffi_oicana_uniffi_checksum_func_configure_automatic_cache_eviction,
|
|
1424
|
+
[RustCallStatus.by_ref],
|
|
1425
|
+
:uint16
|
|
1426
|
+
attach_function :uniffi_oicana_uniffi_checksum_func_configure_diagnostic_color,
|
|
1427
|
+
[RustCallStatus.by_ref],
|
|
1428
|
+
:uint16
|
|
1429
|
+
attach_function :uniffi_oicana_uniffi_checksum_func_evict_cache,
|
|
1430
|
+
[RustCallStatus.by_ref],
|
|
1431
|
+
:uint16
|
|
1432
|
+
attach_function :uniffi_oicana_uniffi_checksum_func_export_once,
|
|
1433
|
+
[RustCallStatus.by_ref],
|
|
1434
|
+
:uint16
|
|
1435
|
+
attach_function :uniffi_oicana_uniffi_checksum_func_register_font_paths,
|
|
1436
|
+
[RustCallStatus.by_ref],
|
|
1437
|
+
:uint16
|
|
1438
|
+
attach_function :uniffi_oicana_uniffi_checksum_func_register_fonts,
|
|
1439
|
+
[RustCallStatus.by_ref],
|
|
1440
|
+
:uint16
|
|
1441
|
+
attach_function :uniffi_oicana_uniffi_checksum_func_registered_fonts,
|
|
1442
|
+
[RustCallStatus.by_ref],
|
|
1443
|
+
:uint16
|
|
1444
|
+
attach_function :uniffi_oicana_uniffi_checksum_func_version,
|
|
1445
|
+
[RustCallStatus.by_ref],
|
|
1446
|
+
:uint16
|
|
1447
|
+
attach_function :uniffi_oicana_uniffi_checksum_method_compileddocument_export,
|
|
1448
|
+
[RustCallStatus.by_ref],
|
|
1449
|
+
:uint16
|
|
1450
|
+
attach_function :uniffi_oicana_uniffi_checksum_method_compileddocument_pages,
|
|
1451
|
+
[RustCallStatus.by_ref],
|
|
1452
|
+
:uint16
|
|
1453
|
+
attach_function :uniffi_oicana_uniffi_checksum_method_compileddocument_warnings,
|
|
1454
|
+
[RustCallStatus.by_ref],
|
|
1455
|
+
:uint16
|
|
1456
|
+
attach_function :uniffi_oicana_uniffi_checksum_method_template_compile,
|
|
1457
|
+
[RustCallStatus.by_ref],
|
|
1458
|
+
:uint16
|
|
1459
|
+
attach_function :uniffi_oicana_uniffi_checksum_method_template_file,
|
|
1460
|
+
[RustCallStatus.by_ref],
|
|
1461
|
+
:uint16
|
|
1462
|
+
attach_function :uniffi_oicana_uniffi_checksum_method_template_manifest,
|
|
1463
|
+
[RustCallStatus.by_ref],
|
|
1464
|
+
:uint16
|
|
1465
|
+
attach_function :uniffi_oicana_uniffi_checksum_method_template_set_validate_inputs,
|
|
1466
|
+
[RustCallStatus.by_ref],
|
|
1467
|
+
:uint16
|
|
1468
|
+
attach_function :uniffi_oicana_uniffi_checksum_method_template_source,
|
|
1469
|
+
[RustCallStatus.by_ref],
|
|
1470
|
+
:uint16
|
|
1471
|
+
attach_function :uniffi_oicana_uniffi_checksum_method_template_warnings,
|
|
1472
|
+
[RustCallStatus.by_ref],
|
|
1473
|
+
:uint16
|
|
1474
|
+
attach_function :uniffi_oicana_uniffi_checksum_constructor_template_new,
|
|
1475
|
+
[RustCallStatus.by_ref],
|
|
1476
|
+
:uint16
|
|
1477
|
+
attach_function :ffi_oicana_uniffi_uniffi_contract_version,
|
|
1478
|
+
[RustCallStatus.by_ref],
|
|
1479
|
+
:uint32
|
|
1480
|
+
|
|
1481
|
+
end
|
|
1482
|
+
|
|
1483
|
+
# Public interface members begin here.
|
|
1484
|
+
|
|
1485
|
+
|
|
1486
|
+
|
|
1487
|
+
|
|
1488
|
+
|
|
1489
|
+
|
|
1490
|
+
class CompilationMode
|
|
1491
|
+
DEVELOPMENT = 1
|
|
1492
|
+
PRODUCTION = 2
|
|
1493
|
+
|
|
1494
|
+
end
|
|
1495
|
+
|
|
1496
|
+
|
|
1497
|
+
|
|
1498
|
+
|
|
1499
|
+
|
|
1500
|
+
|
|
1501
|
+
class DiagnosticColor
|
|
1502
|
+
NONE = 1
|
|
1503
|
+
ANSI = 2
|
|
1504
|
+
|
|
1505
|
+
end
|
|
1506
|
+
|
|
1507
|
+
|
|
1508
|
+
|
|
1509
|
+
|
|
1510
|
+
|
|
1511
|
+
|
|
1512
|
+
class ExportFormat
|
|
1513
|
+
def initialize
|
|
1514
|
+
raise RuntimeError, 'ExportFormat cannot be instantiated directly'
|
|
1515
|
+
end
|
|
1516
|
+
|
|
1517
|
+
# Each enum variant is a nested class of the enum itself.
|
|
1518
|
+
class PDF
|
|
1519
|
+
|
|
1520
|
+
def initialize()
|
|
1521
|
+
|
|
1522
|
+
|
|
1523
|
+
end
|
|
1524
|
+
|
|
1525
|
+
def to_s
|
|
1526
|
+
"ExportFormat::PDF()"
|
|
1527
|
+
end
|
|
1528
|
+
|
|
1529
|
+
def ==(other)
|
|
1530
|
+
if !other.pdf?
|
|
1531
|
+
return false
|
|
1532
|
+
end
|
|
1533
|
+
|
|
1534
|
+
true
|
|
1535
|
+
end
|
|
1536
|
+
|
|
1537
|
+
# For each variant, we have an `NAME?` method for easily checking
|
|
1538
|
+
# whether an instance is that variant.
|
|
1539
|
+
|
|
1540
|
+
def pdf?
|
|
1541
|
+
instance_of? ExportFormat::PDF
|
|
1542
|
+
end
|
|
1543
|
+
|
|
1544
|
+
def png?
|
|
1545
|
+
instance_of? ExportFormat::PNG
|
|
1546
|
+
end
|
|
1547
|
+
|
|
1548
|
+
def svg?
|
|
1549
|
+
instance_of? ExportFormat::SVG
|
|
1550
|
+
end
|
|
1551
|
+
|
|
1552
|
+
end
|
|
1553
|
+
class PNG
|
|
1554
|
+
|
|
1555
|
+
attr_reader :pixels_per_pt
|
|
1556
|
+
|
|
1557
|
+
def initialize(pixels_per_pt)
|
|
1558
|
+
|
|
1559
|
+
@pixels_per_pt = pixels_per_pt
|
|
1560
|
+
|
|
1561
|
+
end
|
|
1562
|
+
|
|
1563
|
+
def to_s
|
|
1564
|
+
"ExportFormat::PNG(pixels_per_pt=#{@pixels_per_pt})"
|
|
1565
|
+
end
|
|
1566
|
+
|
|
1567
|
+
def ==(other)
|
|
1568
|
+
if !other.png?
|
|
1569
|
+
return false
|
|
1570
|
+
end
|
|
1571
|
+
if @pixels_per_pt != other.pixels_per_pt
|
|
1572
|
+
return false
|
|
1573
|
+
end
|
|
1574
|
+
|
|
1575
|
+
true
|
|
1576
|
+
end
|
|
1577
|
+
|
|
1578
|
+
# For each variant, we have an `NAME?` method for easily checking
|
|
1579
|
+
# whether an instance is that variant.
|
|
1580
|
+
|
|
1581
|
+
def pdf?
|
|
1582
|
+
instance_of? ExportFormat::PDF
|
|
1583
|
+
end
|
|
1584
|
+
|
|
1585
|
+
def png?
|
|
1586
|
+
instance_of? ExportFormat::PNG
|
|
1587
|
+
end
|
|
1588
|
+
|
|
1589
|
+
def svg?
|
|
1590
|
+
instance_of? ExportFormat::SVG
|
|
1591
|
+
end
|
|
1592
|
+
|
|
1593
|
+
end
|
|
1594
|
+
class SVG
|
|
1595
|
+
|
|
1596
|
+
def initialize()
|
|
1597
|
+
|
|
1598
|
+
|
|
1599
|
+
end
|
|
1600
|
+
|
|
1601
|
+
def to_s
|
|
1602
|
+
"ExportFormat::SVG()"
|
|
1603
|
+
end
|
|
1604
|
+
|
|
1605
|
+
def ==(other)
|
|
1606
|
+
if !other.svg?
|
|
1607
|
+
return false
|
|
1608
|
+
end
|
|
1609
|
+
|
|
1610
|
+
true
|
|
1611
|
+
end
|
|
1612
|
+
|
|
1613
|
+
# For each variant, we have an `NAME?` method for easily checking
|
|
1614
|
+
# whether an instance is that variant.
|
|
1615
|
+
|
|
1616
|
+
def pdf?
|
|
1617
|
+
instance_of? ExportFormat::PDF
|
|
1618
|
+
end
|
|
1619
|
+
|
|
1620
|
+
def png?
|
|
1621
|
+
instance_of? ExportFormat::PNG
|
|
1622
|
+
end
|
|
1623
|
+
|
|
1624
|
+
def svg?
|
|
1625
|
+
instance_of? ExportFormat::SVG
|
|
1626
|
+
end
|
|
1627
|
+
|
|
1628
|
+
end
|
|
1629
|
+
|
|
1630
|
+
end
|
|
1631
|
+
|
|
1632
|
+
|
|
1633
|
+
|
|
1634
|
+
# Record type BlobInput
|
|
1635
|
+
class BlobInput
|
|
1636
|
+
attr_reader :data, :metadata
|
|
1637
|
+
|
|
1638
|
+
def initialize(data:, metadata: "{}")
|
|
1639
|
+
@data = data
|
|
1640
|
+
@metadata = metadata
|
|
1641
|
+
end
|
|
1642
|
+
|
|
1643
|
+
def ==(other)
|
|
1644
|
+
if @data != other.data
|
|
1645
|
+
return false
|
|
1646
|
+
end
|
|
1647
|
+
if @metadata != other.metadata
|
|
1648
|
+
return false
|
|
1649
|
+
end
|
|
1650
|
+
|
|
1651
|
+
true
|
|
1652
|
+
end
|
|
1653
|
+
end
|
|
1654
|
+
|
|
1655
|
+
# Record type ExportOnceResult
|
|
1656
|
+
class ExportOnceResult
|
|
1657
|
+
attr_reader :bytes, :warnings
|
|
1658
|
+
|
|
1659
|
+
def initialize(bytes:, warnings:)
|
|
1660
|
+
@bytes = bytes
|
|
1661
|
+
@warnings = warnings
|
|
1662
|
+
end
|
|
1663
|
+
|
|
1664
|
+
def ==(other)
|
|
1665
|
+
if @bytes != other.bytes
|
|
1666
|
+
return false
|
|
1667
|
+
end
|
|
1668
|
+
if @warnings != other.warnings
|
|
1669
|
+
return false
|
|
1670
|
+
end
|
|
1671
|
+
|
|
1672
|
+
true
|
|
1673
|
+
end
|
|
1674
|
+
end
|
|
1675
|
+
|
|
1676
|
+
# Record type PageRange
|
|
1677
|
+
class PageRange
|
|
1678
|
+
attr_reader :start, :_end
|
|
1679
|
+
|
|
1680
|
+
def initialize(start: nil, _end: nil)
|
|
1681
|
+
@start = start
|
|
1682
|
+
@_end = _end
|
|
1683
|
+
end
|
|
1684
|
+
|
|
1685
|
+
def ==(other)
|
|
1686
|
+
if @start != other.start
|
|
1687
|
+
return false
|
|
1688
|
+
end
|
|
1689
|
+
if @_end != other._end
|
|
1690
|
+
return false
|
|
1691
|
+
end
|
|
1692
|
+
|
|
1693
|
+
true
|
|
1694
|
+
end
|
|
1695
|
+
end
|
|
1696
|
+
|
|
1697
|
+
# Record type PageSize
|
|
1698
|
+
class PageSize
|
|
1699
|
+
attr_reader :width, :height
|
|
1700
|
+
|
|
1701
|
+
def initialize(width:, height:)
|
|
1702
|
+
@width = width
|
|
1703
|
+
@height = height
|
|
1704
|
+
end
|
|
1705
|
+
|
|
1706
|
+
def ==(other)
|
|
1707
|
+
if @width != other.width
|
|
1708
|
+
return false
|
|
1709
|
+
end
|
|
1710
|
+
if @height != other.height
|
|
1711
|
+
return false
|
|
1712
|
+
end
|
|
1713
|
+
|
|
1714
|
+
true
|
|
1715
|
+
end
|
|
1716
|
+
end
|
|
1717
|
+
|
|
1718
|
+
# Record type RegisteredFont
|
|
1719
|
+
class RegisteredFont
|
|
1720
|
+
attr_reader :family, :path
|
|
1721
|
+
|
|
1722
|
+
def initialize(family:, path:)
|
|
1723
|
+
@family = family
|
|
1724
|
+
@path = path
|
|
1725
|
+
end
|
|
1726
|
+
|
|
1727
|
+
def ==(other)
|
|
1728
|
+
if @family != other.family
|
|
1729
|
+
return false
|
|
1730
|
+
end
|
|
1731
|
+
if @path != other.path
|
|
1732
|
+
return false
|
|
1733
|
+
end
|
|
1734
|
+
|
|
1735
|
+
true
|
|
1736
|
+
end
|
|
1737
|
+
end
|
|
1738
|
+
|
|
1739
|
+
# Record type ZipLimits
|
|
1740
|
+
class ZipLimits
|
|
1741
|
+
attr_reader :max_entries, :max_total_decompressed_bytes
|
|
1742
|
+
|
|
1743
|
+
def initialize(max_entries: nil, max_total_decompressed_bytes: nil)
|
|
1744
|
+
@max_entries = max_entries
|
|
1745
|
+
@max_total_decompressed_bytes = max_total_decompressed_bytes
|
|
1746
|
+
end
|
|
1747
|
+
|
|
1748
|
+
def ==(other)
|
|
1749
|
+
if @max_entries != other.max_entries
|
|
1750
|
+
return false
|
|
1751
|
+
end
|
|
1752
|
+
if @max_total_decompressed_bytes != other.max_total_decompressed_bytes
|
|
1753
|
+
return false
|
|
1754
|
+
end
|
|
1755
|
+
|
|
1756
|
+
true
|
|
1757
|
+
end
|
|
1758
|
+
end
|
|
1759
|
+
|
|
1760
|
+
|
|
1761
|
+
|
|
1762
|
+
|
|
1763
|
+
|
|
1764
|
+
def self.clear_fonts()
|
|
1765
|
+
OicanaUniffi.rust_call(:uniffi_oicana_uniffi_fn_func_clear_fonts,)
|
|
1766
|
+
end
|
|
1767
|
+
|
|
1768
|
+
|
|
1769
|
+
|
|
1770
|
+
|
|
1771
|
+
def self.configure_automatic_cache_eviction(max_age)
|
|
1772
|
+
max_age = (max_age ? OicanaUniffi::uniffi_in_range(max_age, "u64", 0, 2**64) : nil)
|
|
1773
|
+
RustBuffer.check_lower_Optionalu64(max_age)
|
|
1774
|
+
|
|
1775
|
+
OicanaUniffi.rust_call(:uniffi_oicana_uniffi_fn_func_configure_automatic_cache_eviction,RustBuffer.alloc_from_Optionalu64(max_age))
|
|
1776
|
+
end
|
|
1777
|
+
|
|
1778
|
+
|
|
1779
|
+
|
|
1780
|
+
|
|
1781
|
+
def self.configure_diagnostic_color(color)
|
|
1782
|
+
color = color
|
|
1783
|
+
RustBuffer.check_lower_TypeDiagnosticColor(color)
|
|
1784
|
+
|
|
1785
|
+
OicanaUniffi.rust_call(:uniffi_oicana_uniffi_fn_func_configure_diagnostic_color,RustBuffer.alloc_from_TypeDiagnosticColor(color))
|
|
1786
|
+
end
|
|
1787
|
+
|
|
1788
|
+
|
|
1789
|
+
|
|
1790
|
+
|
|
1791
|
+
def self.evict_cache(max_age)
|
|
1792
|
+
max_age = OicanaUniffi::uniffi_in_range(max_age, "u64", 0, 2**64)
|
|
1793
|
+
|
|
1794
|
+
|
|
1795
|
+
OicanaUniffi.rust_call(:uniffi_oicana_uniffi_fn_func_evict_cache,max_age)
|
|
1796
|
+
end
|
|
1797
|
+
|
|
1798
|
+
|
|
1799
|
+
|
|
1800
|
+
|
|
1801
|
+
def self.export_once(files, json_inputs, blob_inputs, mode, format, pages = nil, limits = nil)
|
|
1802
|
+
files = OicanaUniffi::uniffi_bytes(files)
|
|
1803
|
+
|
|
1804
|
+
|
|
1805
|
+
json_inputs = json_inputs.each.with_object({}) { |(k, v), res| res[OicanaUniffi::uniffi_utf8(k)] = OicanaUniffi::uniffi_utf8(v) }
|
|
1806
|
+
RustBuffer.check_lower_MapStringString(json_inputs)
|
|
1807
|
+
|
|
1808
|
+
blob_inputs = blob_inputs.each.with_object({}) { |(k, v), res| res[OicanaUniffi::uniffi_utf8(k)] = v }
|
|
1809
|
+
RustBuffer.check_lower_MapStringTypeBlobInput(blob_inputs)
|
|
1810
|
+
|
|
1811
|
+
mode = mode
|
|
1812
|
+
RustBuffer.check_lower_TypeCompilationMode(mode)
|
|
1813
|
+
|
|
1814
|
+
format = format
|
|
1815
|
+
RustBuffer.check_lower_TypeExportFormat(format)
|
|
1816
|
+
|
|
1817
|
+
pages = (pages ? pages : nil)
|
|
1818
|
+
RustBuffer.check_lower_OptionalTypePageRange(pages)
|
|
1819
|
+
|
|
1820
|
+
limits = (limits ? limits : nil)
|
|
1821
|
+
RustBuffer.check_lower_OptionalTypeZipLimits(limits)
|
|
1822
|
+
|
|
1823
|
+
result = OicanaUniffi.rust_call_with_error(OicanaError,:uniffi_oicana_uniffi_fn_func_export_once,RustBuffer.allocFromBytes(files),RustBuffer.alloc_from_MapStringString(json_inputs),RustBuffer.alloc_from_MapStringTypeBlobInput(blob_inputs),RustBuffer.alloc_from_TypeCompilationMode(mode),RustBuffer.alloc_from_TypeExportFormat(format),RustBuffer.alloc_from_OptionalTypePageRange(pages),RustBuffer.alloc_from_OptionalTypeZipLimits(limits))
|
|
1824
|
+
return result.consumeIntoTypeExportOnceResult
|
|
1825
|
+
end
|
|
1826
|
+
|
|
1827
|
+
|
|
1828
|
+
|
|
1829
|
+
|
|
1830
|
+
|
|
1831
|
+
def self.register_font_paths(paths)
|
|
1832
|
+
paths = paths.map { |v| OicanaUniffi::uniffi_utf8(v) }
|
|
1833
|
+
RustBuffer.check_lower_Sequencestring(paths)
|
|
1834
|
+
|
|
1835
|
+
result = OicanaUniffi.rust_call(:uniffi_oicana_uniffi_fn_func_register_font_paths,RustBuffer.alloc_from_Sequencestring(paths))
|
|
1836
|
+
return result.to_i
|
|
1837
|
+
end
|
|
1838
|
+
|
|
1839
|
+
|
|
1840
|
+
|
|
1841
|
+
|
|
1842
|
+
|
|
1843
|
+
def self.register_fonts(fonts)
|
|
1844
|
+
fonts = fonts.map { |v| OicanaUniffi::uniffi_bytes(v) }
|
|
1845
|
+
RustBuffer.check_lower_Sequencebytes(fonts)
|
|
1846
|
+
|
|
1847
|
+
result = OicanaUniffi.rust_call(:uniffi_oicana_uniffi_fn_func_register_fonts,RustBuffer.alloc_from_Sequencebytes(fonts))
|
|
1848
|
+
return result.to_i
|
|
1849
|
+
end
|
|
1850
|
+
|
|
1851
|
+
|
|
1852
|
+
|
|
1853
|
+
|
|
1854
|
+
|
|
1855
|
+
def self.registered_fonts()
|
|
1856
|
+
result = OicanaUniffi.rust_call(:uniffi_oicana_uniffi_fn_func_registered_fonts,)
|
|
1857
|
+
return result.consumeIntoSequenceTypeRegisteredFont
|
|
1858
|
+
end
|
|
1859
|
+
|
|
1860
|
+
|
|
1861
|
+
|
|
1862
|
+
|
|
1863
|
+
|
|
1864
|
+
def self.version()
|
|
1865
|
+
result = OicanaUniffi.rust_call(:uniffi_oicana_uniffi_fn_func_version,)
|
|
1866
|
+
return result.consumeIntoString
|
|
1867
|
+
end
|
|
1868
|
+
|
|
1869
|
+
|
|
1870
|
+
|
|
1871
|
+
|
|
1872
|
+
|
|
1873
|
+
class CompiledDocument
|
|
1874
|
+
|
|
1875
|
+
# A private helper for initializing instances of the class from a raw handle,
|
|
1876
|
+
# bypassing any initialization logic and ensuring they are GC'd properly.
|
|
1877
|
+
def self.uniffi_allocate(handle)
|
|
1878
|
+
inst = allocate
|
|
1879
|
+
inst.instance_variable_set :@handle, handle
|
|
1880
|
+
ObjectSpace.define_finalizer(inst, uniffi_define_finalizer_by_handle(handle, inst.object_id))
|
|
1881
|
+
return inst
|
|
1882
|
+
end
|
|
1883
|
+
|
|
1884
|
+
# A private helper for registering an object finalizer.
|
|
1885
|
+
# N.B. it's important that this does not capture a reference
|
|
1886
|
+
# to the actual instance, only its underlying handle.
|
|
1887
|
+
def self.uniffi_define_finalizer_by_handle(handle, object_id)
|
|
1888
|
+
Proc.new do |_id|
|
|
1889
|
+
OicanaUniffi.rust_call(
|
|
1890
|
+
:uniffi_oicana_uniffi_fn_free_compileddocument,
|
|
1891
|
+
handle
|
|
1892
|
+
)
|
|
1893
|
+
end
|
|
1894
|
+
end
|
|
1895
|
+
|
|
1896
|
+
# A private helper for lowering instances into a raw handle.
|
|
1897
|
+
# This does an explicit typecheck, because accidentally lowering a different type of
|
|
1898
|
+
# object in a place where this type is expected, could lead to memory unsafety.
|
|
1899
|
+
def self.uniffi_check_lower(inst)
|
|
1900
|
+
if not inst.is_a? self
|
|
1901
|
+
raise TypeError.new "Expected a CompiledDocument instance, got #{inst}"
|
|
1902
|
+
end
|
|
1903
|
+
end
|
|
1904
|
+
|
|
1905
|
+
def uniffi_clone_handle()
|
|
1906
|
+
return OicanaUniffi.rust_call(
|
|
1907
|
+
:uniffi_oicana_uniffi_fn_clone_compileddocument,
|
|
1908
|
+
@handle
|
|
1909
|
+
)
|
|
1910
|
+
end
|
|
1911
|
+
|
|
1912
|
+
def self.uniffi_lower(inst)
|
|
1913
|
+
return inst.uniffi_clone_handle()
|
|
1914
|
+
end
|
|
1915
|
+
|
|
1916
|
+
|
|
1917
|
+
|
|
1918
|
+
def export(format, pages = nil)
|
|
1919
|
+
format = format
|
|
1920
|
+
RustBuffer.check_lower_TypeExportFormat(format)
|
|
1921
|
+
pages = (pages ? pages : nil)
|
|
1922
|
+
RustBuffer.check_lower_OptionalTypePageRange(pages)
|
|
1923
|
+
result = OicanaUniffi.rust_call_with_error(OicanaError,:uniffi_oicana_uniffi_fn_method_compileddocument_export,uniffi_clone_handle(),RustBuffer.alloc_from_TypeExportFormat(format),RustBuffer.alloc_from_OptionalTypePageRange(pages))
|
|
1924
|
+
return result.consumeIntoBytes
|
|
1925
|
+
end
|
|
1926
|
+
def pages()
|
|
1927
|
+
result = OicanaUniffi.rust_call(:uniffi_oicana_uniffi_fn_method_compileddocument_pages,uniffi_clone_handle(),)
|
|
1928
|
+
return result.consumeIntoSequenceTypePageSize
|
|
1929
|
+
end
|
|
1930
|
+
def warnings()
|
|
1931
|
+
result = OicanaUniffi.rust_call(:uniffi_oicana_uniffi_fn_method_compileddocument_warnings,uniffi_clone_handle(),)
|
|
1932
|
+
return result.consumeIntoOptionalstring
|
|
1933
|
+
end
|
|
1934
|
+
|
|
1935
|
+
end
|
|
1936
|
+
|
|
1937
|
+
class Template
|
|
1938
|
+
|
|
1939
|
+
# A private helper for initializing instances of the class from a raw handle,
|
|
1940
|
+
# bypassing any initialization logic and ensuring they are GC'd properly.
|
|
1941
|
+
def self.uniffi_allocate(handle)
|
|
1942
|
+
inst = allocate
|
|
1943
|
+
inst.instance_variable_set :@handle, handle
|
|
1944
|
+
ObjectSpace.define_finalizer(inst, uniffi_define_finalizer_by_handle(handle, inst.object_id))
|
|
1945
|
+
return inst
|
|
1946
|
+
end
|
|
1947
|
+
|
|
1948
|
+
# A private helper for registering an object finalizer.
|
|
1949
|
+
# N.B. it's important that this does not capture a reference
|
|
1950
|
+
# to the actual instance, only its underlying handle.
|
|
1951
|
+
def self.uniffi_define_finalizer_by_handle(handle, object_id)
|
|
1952
|
+
Proc.new do |_id|
|
|
1953
|
+
OicanaUniffi.rust_call(
|
|
1954
|
+
:uniffi_oicana_uniffi_fn_free_template,
|
|
1955
|
+
handle
|
|
1956
|
+
)
|
|
1957
|
+
end
|
|
1958
|
+
end
|
|
1959
|
+
|
|
1960
|
+
# A private helper for lowering instances into a raw handle.
|
|
1961
|
+
# This does an explicit typecheck, because accidentally lowering a different type of
|
|
1962
|
+
# object in a place where this type is expected, could lead to memory unsafety.
|
|
1963
|
+
def self.uniffi_check_lower(inst)
|
|
1964
|
+
if not inst.is_a? self
|
|
1965
|
+
raise TypeError.new "Expected a Template instance, got #{inst}"
|
|
1966
|
+
end
|
|
1967
|
+
end
|
|
1968
|
+
|
|
1969
|
+
def uniffi_clone_handle()
|
|
1970
|
+
return OicanaUniffi.rust_call(
|
|
1971
|
+
:uniffi_oicana_uniffi_fn_clone_template,
|
|
1972
|
+
@handle
|
|
1973
|
+
)
|
|
1974
|
+
end
|
|
1975
|
+
|
|
1976
|
+
def self.uniffi_lower(inst)
|
|
1977
|
+
return inst.uniffi_clone_handle()
|
|
1978
|
+
end
|
|
1979
|
+
def initialize(files, json_inputs, blob_inputs, mode, limits = nil)
|
|
1980
|
+
files = OicanaUniffi::uniffi_bytes(files)
|
|
1981
|
+
|
|
1982
|
+
json_inputs = json_inputs.each.with_object({}) { |(k, v), res| res[OicanaUniffi::uniffi_utf8(k)] = OicanaUniffi::uniffi_utf8(v) }
|
|
1983
|
+
RustBuffer.check_lower_MapStringString(json_inputs)
|
|
1984
|
+
blob_inputs = blob_inputs.each.with_object({}) { |(k, v), res| res[OicanaUniffi::uniffi_utf8(k)] = v }
|
|
1985
|
+
RustBuffer.check_lower_MapStringTypeBlobInput(blob_inputs)
|
|
1986
|
+
mode = mode
|
|
1987
|
+
RustBuffer.check_lower_TypeCompilationMode(mode)
|
|
1988
|
+
limits = (limits ? limits : nil)
|
|
1989
|
+
RustBuffer.check_lower_OptionalTypeZipLimits(limits)
|
|
1990
|
+
handle = OicanaUniffi.rust_call_with_error(OicanaError,:uniffi_oicana_uniffi_fn_constructor_template_new,RustBuffer.allocFromBytes(files),RustBuffer.alloc_from_MapStringString(json_inputs),RustBuffer.alloc_from_MapStringTypeBlobInput(blob_inputs),RustBuffer.alloc_from_TypeCompilationMode(mode),RustBuffer.alloc_from_OptionalTypeZipLimits(limits))
|
|
1991
|
+
@handle = handle
|
|
1992
|
+
ObjectSpace.define_finalizer(self, self.class.uniffi_define_finalizer_by_handle(handle, self.object_id))
|
|
1993
|
+
end
|
|
1994
|
+
|
|
1995
|
+
|
|
1996
|
+
|
|
1997
|
+
def compile(json_inputs, blob_inputs, mode)
|
|
1998
|
+
json_inputs = json_inputs.each.with_object({}) { |(k, v), res| res[OicanaUniffi::uniffi_utf8(k)] = OicanaUniffi::uniffi_utf8(v) }
|
|
1999
|
+
RustBuffer.check_lower_MapStringString(json_inputs)
|
|
2000
|
+
blob_inputs = blob_inputs.each.with_object({}) { |(k, v), res| res[OicanaUniffi::uniffi_utf8(k)] = v }
|
|
2001
|
+
RustBuffer.check_lower_MapStringTypeBlobInput(blob_inputs)
|
|
2002
|
+
mode = mode
|
|
2003
|
+
RustBuffer.check_lower_TypeCompilationMode(mode)
|
|
2004
|
+
result = OicanaUniffi.rust_call_with_error(OicanaError,:uniffi_oicana_uniffi_fn_method_template_compile,uniffi_clone_handle(),RustBuffer.alloc_from_MapStringString(json_inputs),RustBuffer.alloc_from_MapStringTypeBlobInput(blob_inputs),RustBuffer.alloc_from_TypeCompilationMode(mode))
|
|
2005
|
+
return CompiledDocument.uniffi_allocate(result)
|
|
2006
|
+
end
|
|
2007
|
+
def file(path)
|
|
2008
|
+
path = OicanaUniffi::uniffi_utf8(path)
|
|
2009
|
+
|
|
2010
|
+
result = OicanaUniffi.rust_call_with_error(OicanaError,:uniffi_oicana_uniffi_fn_method_template_file,uniffi_clone_handle(),RustBuffer.allocFromString(path))
|
|
2011
|
+
return result.consumeIntoBytes
|
|
2012
|
+
end
|
|
2013
|
+
def manifest()
|
|
2014
|
+
result = OicanaUniffi.rust_call_with_error(OicanaError,:uniffi_oicana_uniffi_fn_method_template_manifest,uniffi_clone_handle(),)
|
|
2015
|
+
return result.consumeIntoString
|
|
2016
|
+
end
|
|
2017
|
+
def set_validate_inputs(validate)
|
|
2018
|
+
validate = validate ? true : false
|
|
2019
|
+
|
|
2020
|
+
OicanaUniffi.rust_call_with_error(OicanaError,:uniffi_oicana_uniffi_fn_method_template_set_validate_inputs,uniffi_clone_handle(),(validate ? 1 : 0))
|
|
2021
|
+
end
|
|
2022
|
+
|
|
2023
|
+
def source(path)
|
|
2024
|
+
path = OicanaUniffi::uniffi_utf8(path)
|
|
2025
|
+
|
|
2026
|
+
result = OicanaUniffi.rust_call_with_error(OicanaError,:uniffi_oicana_uniffi_fn_method_template_source,uniffi_clone_handle(),RustBuffer.allocFromString(path))
|
|
2027
|
+
return result.consumeIntoString
|
|
2028
|
+
end
|
|
2029
|
+
def warnings()
|
|
2030
|
+
result = OicanaUniffi.rust_call(:uniffi_oicana_uniffi_fn_method_template_warnings,uniffi_clone_handle(),)
|
|
2031
|
+
return result.consumeIntoOptionalstring
|
|
2032
|
+
end
|
|
2033
|
+
|
|
2034
|
+
end
|
|
2035
|
+
|
|
2036
|
+
end
|
|
2037
|
+
|