oicana 0.10.0.rc.1-aarch64-linux-gnu → 0.10.0.rc.2-aarch64-linux-gnu

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b43092492df7813de668261663918ad4578339024489a0c7b201d63f3269fc16
4
- data.tar.gz: 14986ca3a485d25c29bcbfd484de1c3b6d16041745bdfd9b74045914d05c64a0
3
+ metadata.gz: 504e0adcbb0c2bf49c29a8e9fc22315acdcac604f529fe35d150528238839197
4
+ data.tar.gz: 9d72ee4ce1459bc0cb3a5b1a2ea1b7e3311344f7a38afd51ae51b97a72dd24f3
5
5
  SHA512:
6
- metadata.gz: 8fa5bb66ca5bafebf3e87471b25e4611799ad3a5cc655b1d2931788856284af80a4207473d2408404d4eb50d4f7895c06cc586a8f9a39ed012ba642c622b21be
7
- data.tar.gz: 6cf66c1e0d2acab52b1a7de7233411b273b1e323aef27591a8449864f21512cb22745bfb9bb2a36fd33393f014fe6bf34082d48ffe526df33f1e7297a69513d4
6
+ metadata.gz: 24b389c7745af96671c59733c45c3153fe720f7fc584affa08c64fceff6c999b397cbc9af8cee7a7ed96428db2fd3136cf959834cbf3aa3ffb04dd2561a38c92
7
+ data.tar.gz: 77078a3440ae532a260584094c500d77bc4bee96fa90a7f36b09d6ccb79928e4a2025a6c3d515dcdfce8fdfceffc2805f34c7f18969c8db737723e4099e7f7e5
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: data/lib/oicana/native/liboicana_uniffi.so
3
3
  size: 45952304 bytes
4
- sha256: 0c2af7bb71bf4cf881f667d3f2687e60dd3b1dc964b99a503ce8007b51daf02c
4
+ sha256: ce0b529e7a9bdd3a7f60e772d07f00a78b24989da01d65961a61e672e93c7dc7
@@ -146,11 +146,35 @@ end
146
146
  end
147
147
  end
148
148
 
149
+ # The Record type Diagnostic.
150
+
151
+ def self.check_lower_TypeDiagnostic(v)
152
+ RustBuffer.check_lower_TypeDiagnosticSeverity(v.severity)
153
+
154
+ RustBuffer.check_lower_OptionalTypeSourceLocation(v.location)
155
+ RustBuffer.check_lower_Sequencestring(v.hints)
156
+ RustBuffer.check_lower_SequenceTypeTracePoint(v.trace)
157
+
158
+ end
159
+
160
+ def self.alloc_from_TypeDiagnostic(v)
161
+ RustBuffer.allocWithBuilder do |builder|
162
+ builder.write_TypeDiagnostic(v)
163
+ return builder.finalize
164
+ end
165
+ end
166
+
167
+ def consumeIntoTypeDiagnostic
168
+ consumeWithStream do |stream|
169
+ return stream.readTypeDiagnostic
170
+ end
171
+ end
172
+
149
173
  # The Record type ExportOnceResult.
150
174
 
151
175
  def self.check_lower_TypeExportOnceResult(v)
152
176
 
153
- RustBuffer.check_lower_Optionalstring(v.warnings)
177
+ RustBuffer.check_lower_SequenceTypeDiagnostic(v.warnings)
154
178
  end
155
179
 
156
180
  def self.alloc_from_TypeExportOnceResult(v)
@@ -226,6 +250,49 @@ end
226
250
  end
227
251
  end
228
252
 
253
+ # The Record type SourceLocation.
254
+
255
+ def self.check_lower_TypeSourceLocation(v)
256
+
257
+
258
+
259
+
260
+
261
+ end
262
+
263
+ def self.alloc_from_TypeSourceLocation(v)
264
+ RustBuffer.allocWithBuilder do |builder|
265
+ builder.write_TypeSourceLocation(v)
266
+ return builder.finalize
267
+ end
268
+ end
269
+
270
+ def consumeIntoTypeSourceLocation
271
+ consumeWithStream do |stream|
272
+ return stream.readTypeSourceLocation
273
+ end
274
+ end
275
+
276
+ # The Record type TracePoint.
277
+
278
+ def self.check_lower_TypeTracePoint(v)
279
+
280
+ RustBuffer.check_lower_OptionalTypeSourceLocation(v.location)
281
+ end
282
+
283
+ def self.alloc_from_TypeTracePoint(v)
284
+ RustBuffer.allocWithBuilder do |builder|
285
+ builder.write_TypeTracePoint(v)
286
+ return builder.finalize
287
+ end
288
+ end
289
+
290
+ def consumeIntoTypeTracePoint
291
+ consumeWithStream do |stream|
292
+ return stream.readTypeTracePoint
293
+ end
294
+ end
295
+
229
296
  # The Record type ZipLimits.
230
297
 
231
298
  def self.check_lower_TypeZipLimits(v)
@@ -284,6 +351,25 @@ end
284
351
  end
285
352
 
286
353
 
354
+ # The Enum type DiagnosticSeverity.
355
+
356
+ def self.check_lower_TypeDiagnosticSeverity(v)
357
+ end
358
+
359
+ def self.alloc_from_TypeDiagnosticSeverity(v)
360
+ RustBuffer.allocWithBuilder do |builder|
361
+ builder.write_TypeDiagnosticSeverity(v)
362
+ return builder.finalize
363
+ end
364
+ end
365
+
366
+ def consumeIntoTypeDiagnosticSeverity
367
+ consumeWithStream do |stream|
368
+ return stream.readTypeDiagnosticSeverity
369
+ end
370
+ end
371
+
372
+
287
373
  # The Enum type ExportFormat.
288
374
 
289
375
  def self.check_lower_TypeExportFormat(v)
@@ -378,6 +464,27 @@ end
378
464
  end
379
465
  end
380
466
 
467
+ # The Optional<T> type for TypeSourceLocation.
468
+
469
+ def self.check_lower_OptionalTypeSourceLocation(v)
470
+ if not v.nil?
471
+ RustBuffer.check_lower_TypeSourceLocation(v)
472
+ end
473
+ end
474
+
475
+ def self.alloc_from_OptionalTypeSourceLocation(v)
476
+ RustBuffer.allocWithBuilder do |builder|
477
+ builder.write_OptionalTypeSourceLocation(v)
478
+ return builder.finalize()
479
+ end
480
+ end
481
+
482
+ def consumeIntoOptionalTypeSourceLocation
483
+ consumeWithStream do |stream|
484
+ return stream.readOptionalTypeSourceLocation
485
+ end
486
+ end
487
+
381
488
  # The Optional<T> type for TypeZipLimits.
382
489
 
383
490
  def self.check_lower_OptionalTypeZipLimits(v)
@@ -441,6 +548,27 @@ end
441
548
  end
442
549
  end
443
550
 
551
+ # The Sequence<T> type for TypeDiagnostic.
552
+
553
+ def self.check_lower_SequenceTypeDiagnostic(v)
554
+ v.each do |item|
555
+ RustBuffer.check_lower_TypeDiagnostic(item)
556
+ end
557
+ end
558
+
559
+ def self.alloc_from_SequenceTypeDiagnostic(v)
560
+ RustBuffer.allocWithBuilder do |builder|
561
+ builder.write_SequenceTypeDiagnostic(v)
562
+ return builder.finalize()
563
+ end
564
+ end
565
+
566
+ def consumeIntoSequenceTypeDiagnostic
567
+ consumeWithStream do |stream|
568
+ return stream.readSequenceTypeDiagnostic
569
+ end
570
+ end
571
+
444
572
  # The Sequence<T> type for TypePageSize.
445
573
 
446
574
  def self.check_lower_SequenceTypePageSize(v)
@@ -483,6 +611,27 @@ end
483
611
  end
484
612
  end
485
613
 
614
+ # The Sequence<T> type for TypeTracePoint.
615
+
616
+ def self.check_lower_SequenceTypeTracePoint(v)
617
+ v.each do |item|
618
+ RustBuffer.check_lower_TypeTracePoint(item)
619
+ end
620
+ end
621
+
622
+ def self.alloc_from_SequenceTypeTracePoint(v)
623
+ RustBuffer.allocWithBuilder do |builder|
624
+ builder.write_SequenceTypeTracePoint(v)
625
+ return builder.finalize()
626
+ end
627
+ end
628
+
629
+ def consumeIntoSequenceTypeTracePoint
630
+ consumeWithStream do |stream|
631
+ return stream.readSequenceTypeTracePoint
632
+ end
633
+ end
634
+
486
635
  # The Map<T> type for string.
487
636
 
488
637
  def self.check_lower_MapStringString(v)
@@ -569,6 +718,10 @@ class RustBufferStream
569
718
  data
570
719
  end
571
720
 
721
+ def readU32
722
+ unpack_from 4, 'L>'
723
+ end
724
+
572
725
  def readU64
573
726
  unpack_from 8, 'Q>'
574
727
  end
@@ -629,12 +782,25 @@ class RustBufferStream
629
782
  )
630
783
  end
631
784
 
785
+ # The Record type Diagnostic.
786
+
787
+ def readTypeDiagnostic
788
+ Diagnostic.new(
789
+ severity: readTypeDiagnosticSeverity,
790
+ message: readString,
791
+ location: readOptionalTypeSourceLocation,
792
+ hints: readSequencestring,
793
+ trace: readSequenceTypeTracePoint,
794
+ formatted: readString
795
+ )
796
+ end
797
+
632
798
  # The Record type ExportOnceResult.
633
799
 
634
800
  def readTypeExportOnceResult
635
801
  ExportOnceResult.new(
636
802
  bytes: readBytes,
637
- warnings: readOptionalstring
803
+ warnings: readSequenceTypeDiagnostic
638
804
  )
639
805
  end
640
806
 
@@ -665,6 +831,27 @@ class RustBufferStream
665
831
  )
666
832
  end
667
833
 
834
+ # The Record type SourceLocation.
835
+
836
+ def readTypeSourceLocation
837
+ SourceLocation.new(
838
+ file: readString,
839
+ line: readU32,
840
+ column: readU32,
841
+ end_line: readU32,
842
+ end_column: readU32
843
+ )
844
+ end
845
+
846
+ # The Record type TracePoint.
847
+
848
+ def readTypeTracePoint
849
+ TracePoint.new(
850
+ message: readString,
851
+ location: readOptionalTypeSourceLocation
852
+ )
853
+ end
854
+
668
855
  # The Record type ZipLimits.
669
856
 
670
857
  def readTypeZipLimits
@@ -714,6 +901,25 @@ class RustBufferStream
714
901
 
715
902
 
716
903
 
904
+ # The Enum type DiagnosticSeverity.
905
+
906
+ def readTypeDiagnosticSeverity
907
+ variant = unpack_from 4, 'l>'
908
+
909
+ if variant == 1
910
+ return DiagnosticSeverity::ERROR
911
+ end
912
+ if variant == 2
913
+ return DiagnosticSeverity::WARNING
914
+ end
915
+
916
+ raise InternalError, 'Unexpected variant tag for TypeDiagnosticSeverity'
917
+ end
918
+
919
+
920
+
921
+
922
+
717
923
  # The Enum type ExportFormat.
718
924
 
719
925
  def readTypeExportFormat
@@ -828,6 +1034,20 @@ class RustBufferStream
828
1034
  end
829
1035
  end
830
1036
 
1037
+ # The Optional<T> type for TypeSourceLocation.
1038
+
1039
+ def readOptionalTypeSourceLocation
1040
+ flag = unpack_from 1, 'c'
1041
+
1042
+ if flag == 0
1043
+ return nil
1044
+ elsif flag == 1
1045
+ return readTypeSourceLocation
1046
+ else
1047
+ raise InternalError, 'Unexpected flag byte for OptionalTypeSourceLocation'
1048
+ end
1049
+ end
1050
+
831
1051
  # The Optional<T> type for TypeZipLimits.
832
1052
 
833
1053
  def readOptionalTypeZipLimits
@@ -874,6 +1094,22 @@ class RustBufferStream
874
1094
  items
875
1095
  end
876
1096
 
1097
+ # The Sequence<T> type for TypeDiagnostic.
1098
+
1099
+ def readSequenceTypeDiagnostic
1100
+ count = unpack_from 4, 'l>'
1101
+
1102
+ raise InternalError, 'Unexpected negative sequence length' if count.negative?
1103
+
1104
+ items = []
1105
+
1106
+ count.times do
1107
+ items.append readTypeDiagnostic
1108
+ end
1109
+
1110
+ items
1111
+ end
1112
+
877
1113
  # The Sequence<T> type for TypePageSize.
878
1114
 
879
1115
  def readSequenceTypePageSize
@@ -906,6 +1142,22 @@ class RustBufferStream
906
1142
  items
907
1143
  end
908
1144
 
1145
+ # The Sequence<T> type for TypeTracePoint.
1146
+
1147
+ def readSequenceTypeTracePoint
1148
+ count = unpack_from 4, 'l>'
1149
+
1150
+ raise InternalError, 'Unexpected negative sequence length' if count.negative?
1151
+
1152
+ items = []
1153
+
1154
+ count.times do
1155
+ items.append readTypeTracePoint
1156
+ end
1157
+
1158
+ items
1159
+ end
1160
+
909
1161
  # The Map<T> type for string.
910
1162
 
911
1163
  def readMapStringString
@@ -978,6 +1230,11 @@ class RustBufferBuilder
978
1230
  end
979
1231
  end
980
1232
 
1233
+ def write_U32(v)
1234
+ v = OicanaUniffi::uniffi_in_range(v, "u32", 0, 2**32)
1235
+ pack_into(4, 'L>', v)
1236
+ end
1237
+
981
1238
  def write_U64(v)
982
1239
  v = OicanaUniffi::uniffi_in_range(v, "u64", 0, 2**64)
983
1240
  pack_into(8, 'Q>', v)
@@ -1028,11 +1285,22 @@ class RustBufferBuilder
1028
1285
  self.write_String(v.metadata)
1029
1286
  end
1030
1287
 
1288
+ # The Record type Diagnostic.
1289
+
1290
+ def write_TypeDiagnostic(v)
1291
+ self.write_TypeDiagnosticSeverity(v.severity)
1292
+ self.write_String(v.message)
1293
+ self.write_OptionalTypeSourceLocation(v.location)
1294
+ self.write_Sequencestring(v.hints)
1295
+ self.write_SequenceTypeTracePoint(v.trace)
1296
+ self.write_String(v.formatted)
1297
+ end
1298
+
1031
1299
  # The Record type ExportOnceResult.
1032
1300
 
1033
1301
  def write_TypeExportOnceResult(v)
1034
1302
  self.write_Bytes(v.bytes)
1035
- self.write_Optionalstring(v.warnings)
1303
+ self.write_SequenceTypeDiagnostic(v.warnings)
1036
1304
  end
1037
1305
 
1038
1306
  # The Record type PageRange.
@@ -1056,6 +1324,23 @@ class RustBufferBuilder
1056
1324
  self.write_Optionalstring(v.path)
1057
1325
  end
1058
1326
 
1327
+ # The Record type SourceLocation.
1328
+
1329
+ def write_TypeSourceLocation(v)
1330
+ self.write_String(v.file)
1331
+ self.write_U32(v.line)
1332
+ self.write_U32(v.column)
1333
+ self.write_U32(v.end_line)
1334
+ self.write_U32(v.end_column)
1335
+ end
1336
+
1337
+ # The Record type TracePoint.
1338
+
1339
+ def write_TypeTracePoint(v)
1340
+ self.write_String(v.message)
1341
+ self.write_OptionalTypeSourceLocation(v.location)
1342
+ end
1343
+
1059
1344
  # The Record type ZipLimits.
1060
1345
 
1061
1346
  def write_TypeZipLimits(v)
@@ -1077,6 +1362,13 @@ class RustBufferBuilder
1077
1362
  end
1078
1363
 
1079
1364
 
1365
+ # The Enum type DiagnosticSeverity.
1366
+
1367
+ def write_TypeDiagnosticSeverity(v)
1368
+ pack_into(4, 'l>', v)
1369
+ end
1370
+
1371
+
1080
1372
  # The Enum type ExportFormat.
1081
1373
 
1082
1374
  def write_TypeExportFormat(v)
@@ -1128,6 +1420,17 @@ class RustBufferBuilder
1128
1420
  end
1129
1421
  end
1130
1422
 
1423
+ # The Optional<T> type for TypeSourceLocation.
1424
+
1425
+ def write_OptionalTypeSourceLocation(v)
1426
+ if v.nil?
1427
+ pack_into(1, 'c', 0)
1428
+ else
1429
+ pack_into(1, 'c', 1)
1430
+ self.write_TypeSourceLocation(v)
1431
+ end
1432
+ end
1433
+
1131
1434
  # The Optional<T> type for TypeZipLimits.
1132
1435
 
1133
1436
  def write_OptionalTypeZipLimits(v)
@@ -1159,6 +1462,16 @@ class RustBufferBuilder
1159
1462
  end
1160
1463
  end
1161
1464
 
1465
+ # The Sequence<T> type for TypeDiagnostic.
1466
+
1467
+ def write_SequenceTypeDiagnostic(items)
1468
+ pack_into(4, 'l>', items.size)
1469
+
1470
+ items.each do |item|
1471
+ self.write_TypeDiagnostic(item)
1472
+ end
1473
+ end
1474
+
1162
1475
  # The Sequence<T> type for TypePageSize.
1163
1476
 
1164
1477
  def write_SequenceTypePageSize(items)
@@ -1179,6 +1492,16 @@ class RustBufferBuilder
1179
1492
  end
1180
1493
  end
1181
1494
 
1495
+ # The Sequence<T> type for TypeTracePoint.
1496
+
1497
+ def write_SequenceTypeTracePoint(items)
1498
+ pack_into(4, 'l>', items.size)
1499
+
1500
+ items.each do |item|
1501
+ self.write_TypeTracePoint(item)
1502
+ end
1503
+ end
1504
+
1182
1505
  # The Map<T> type for string.
1183
1506
 
1184
1507
  def write_MapStringString(items)
@@ -1259,6 +1582,7 @@ end
1259
1582
 
1260
1583
 
1261
1584
 
1585
+
1262
1586
  # Map error modules to the RustBuffer method name that reads them
1263
1587
  ERROR_MODULE_TO_READER_METHOD = {
1264
1588
 
@@ -1267,6 +1591,7 @@ ERROR_MODULE_TO_READER_METHOD = {
1267
1591
 
1268
1592
 
1269
1593
 
1594
+
1270
1595
  }
1271
1596
 
1272
1597
  private_constant :ERROR_MODULE_TO_READER_METHOD, :CALL_SUCCESS, :CALL_ERROR, :CALL_PANIC,
@@ -1509,6 +1834,17 @@ end
1509
1834
 
1510
1835
 
1511
1836
 
1837
+ class DiagnosticSeverity
1838
+ ERROR = 1
1839
+ WARNING = 2
1840
+
1841
+ end
1842
+
1843
+
1844
+
1845
+
1846
+
1847
+
1512
1848
  class ExportFormat
1513
1849
  def initialize
1514
1850
  raise RuntimeError, 'ExportFormat cannot be instantiated directly'
@@ -1652,6 +1988,43 @@ class BlobInput
1652
1988
  end
1653
1989
  end
1654
1990
 
1991
+ # Record type Diagnostic
1992
+ class Diagnostic
1993
+ attr_reader :severity, :message, :location, :hints, :trace, :formatted
1994
+
1995
+ def initialize(severity:, message:, location:, hints:, trace:, formatted:)
1996
+ @severity = severity
1997
+ @message = message
1998
+ @location = location
1999
+ @hints = hints
2000
+ @trace = trace
2001
+ @formatted = formatted
2002
+ end
2003
+
2004
+ def ==(other)
2005
+ if @severity != other.severity
2006
+ return false
2007
+ end
2008
+ if @message != other.message
2009
+ return false
2010
+ end
2011
+ if @location != other.location
2012
+ return false
2013
+ end
2014
+ if @hints != other.hints
2015
+ return false
2016
+ end
2017
+ if @trace != other.trace
2018
+ return false
2019
+ end
2020
+ if @formatted != other.formatted
2021
+ return false
2022
+ end
2023
+
2024
+ true
2025
+ end
2026
+ end
2027
+
1655
2028
  # Record type ExportOnceResult
1656
2029
  class ExportOnceResult
1657
2030
  attr_reader :bytes, :warnings
@@ -1736,6 +2109,60 @@ class RegisteredFont
1736
2109
  end
1737
2110
  end
1738
2111
 
2112
+ # Record type SourceLocation
2113
+ class SourceLocation
2114
+ attr_reader :file, :line, :column, :end_line, :end_column
2115
+
2116
+ def initialize(file:, line:, column:, end_line:, end_column:)
2117
+ @file = file
2118
+ @line = line
2119
+ @column = column
2120
+ @end_line = end_line
2121
+ @end_column = end_column
2122
+ end
2123
+
2124
+ def ==(other)
2125
+ if @file != other.file
2126
+ return false
2127
+ end
2128
+ if @line != other.line
2129
+ return false
2130
+ end
2131
+ if @column != other.column
2132
+ return false
2133
+ end
2134
+ if @end_line != other.end_line
2135
+ return false
2136
+ end
2137
+ if @end_column != other.end_column
2138
+ return false
2139
+ end
2140
+
2141
+ true
2142
+ end
2143
+ end
2144
+
2145
+ # Record type TracePoint
2146
+ class TracePoint
2147
+ attr_reader :message, :location
2148
+
2149
+ def initialize(message:, location:)
2150
+ @message = message
2151
+ @location = location
2152
+ end
2153
+
2154
+ def ==(other)
2155
+ if @message != other.message
2156
+ return false
2157
+ end
2158
+ if @location != other.location
2159
+ return false
2160
+ end
2161
+
2162
+ true
2163
+ end
2164
+ end
2165
+
1739
2166
  # Record type ZipLimits
1740
2167
  class ZipLimits
1741
2168
  attr_reader :max_entries, :max_total_decompressed_bytes
@@ -1929,7 +2356,7 @@ end
1929
2356
  end
1930
2357
  def warnings()
1931
2358
  result = OicanaUniffi.rust_call(:uniffi_oicana_uniffi_fn_method_compileddocument_warnings,uniffi_clone_handle(),)
1932
- return result.consumeIntoOptionalstring
2359
+ return result.consumeIntoSequenceTypeDiagnostic
1933
2360
  end
1934
2361
 
1935
2362
  end
@@ -2028,7 +2455,7 @@ end
2028
2455
  end
2029
2456
  def warnings()
2030
2457
  result = OicanaUniffi.rust_call(:uniffi_oicana_uniffi_fn_method_template_warnings,uniffi_clone_handle(),)
2031
- return result.consumeIntoOptionalstring
2458
+ return result.consumeIntoSequenceTypeDiagnostic
2032
2459
  end
2033
2460
 
2034
2461
  end
@@ -57,7 +57,7 @@ module Oicana
57
57
  # pdf = template.export_pdf(json_inputs: { "invoice" => { "number" => "2026-001" } })
58
58
  # end
59
59
  class Template
60
- # Warnings of the warm-up compilation, or nil.
60
+ # Diagnostic values for the warnings of the warm-up compilation.
61
61
  attr_reader :warnings
62
62
 
63
63
  # Load a packed template and compile it once to warm up its caches.
@@ -69,7 +69,7 @@ module Oicana
69
69
  OicanaUniffi::Template.new(template.b, Convert.json_inputs(json_inputs), Convert.blob_inputs(blob_inputs),
70
70
  Convert.mode(mode), Convert.limits(limits))
71
71
  end
72
- @warnings = object.warnings
72
+ @warnings = Convert.diagnostics(object.warnings)
73
73
  @handle = NativeHandle.new(object, :uniffi_oicana_uniffi_fn_free_template, "template")
74
74
  end
75
75
 
@@ -96,7 +96,7 @@ module Oicana
96
96
  Convert.mode(mode), Convert.format(format, pixels_per_pt), Convert.pages(pages),
97
97
  Convert.limits(limits))
98
98
  end
99
- ExportOnceResult.new(document: result.bytes, warnings: result.warnings)
99
+ ExportOnceResult.new(document: result.bytes, warnings: Convert.diagnostics(result.warnings))
100
100
  end
101
101
 
102
102
  # Compile the template into a CompiledDocument whose pages can be exported repeatedly.
@@ -168,13 +168,13 @@ module Oicana
168
168
  class CompiledDocument
169
169
  # PageSize of every page, in document order.
170
170
  attr_reader :pages
171
- # Warnings of the compilation, or nil.
171
+ # Diagnostic values for the warnings of the compilation.
172
172
  attr_reader :warnings
173
173
 
174
174
  # @api private
175
175
  def initialize(object)
176
176
  @pages = object.pages.map { |page| PageSize.new(width: page.width, height: page.height) }.freeze
177
- @warnings = object.warnings
177
+ @warnings = Convert.diagnostics(object.warnings)
178
178
  @handle = NativeHandle.new(object, :uniffi_oicana_uniffi_fn_free_compileddocument, "document")
179
179
  end
180
180
 
data/lib/oicana/types.rb CHANGED
@@ -24,9 +24,30 @@ module Oicana
24
24
  # A font face registered by the host. path is nil for fonts registered from memory.
25
25
  RegisteredFont = Data.define(:family, :path)
26
26
 
27
- # The result of Template.export_once. warnings is nil when there are none.
27
+ # The result of Template.export_once. warnings is an Array of Diagnostic values.
28
28
  ExportOnceResult = Data.define(:document, :warnings)
29
29
 
30
+ # A compilation diagnostic, like a warning, with its location in the template.
31
+ #
32
+ # severity is :error or :warning. location is a SourceLocation, or nil if the
33
+ # diagnostic does not point into a file. hints is an Array of Strings and trace an
34
+ # Array of TracePoint values, innermost first. formatted is the diagnostic formatted
35
+ # for humans, with source excerpts and the configured diagnostic color.
36
+ Diagnostic = Data.define(:severity, :message, :location, :hints, :trace, :formatted) do
37
+ def to_s
38
+ formatted
39
+ end
40
+ end
41
+
42
+ # A range in a file of the template. Lines and columns are 1-based, columns count
43
+ # characters, and end_column is exclusive. file is the path in the template, like
44
+ # "/main.typ"; files of packages are prefixed with the package.
45
+ SourceLocation = Data.define(:file, :line, :column, :end_line, :end_column)
46
+
47
+ # A step in the function calls leading to a Diagnostic. location is nil if the step
48
+ # does not point into a file.
49
+ TracePoint = Data.define(:message, :location)
50
+
30
51
  # A template's manifest.
31
52
  Manifest = Data.define(:package, :oicana)
32
53
 
@@ -155,5 +176,27 @@ module Oicana
155
176
  def blob_fallback(fallback)
156
177
  fallback && BlobFallback.new(file: fallback.fetch("file"), meta: fallback["meta"])
157
178
  end
179
+
180
+ def diagnostics(diagnostics)
181
+ diagnostics.map do |diagnostic|
182
+ Diagnostic.new(
183
+ severity: diagnostic.severity == OicanaUniffi::DiagnosticSeverity::ERROR ? :error : :warning,
184
+ message: diagnostic.message,
185
+ location: location(diagnostic.location),
186
+ hints: diagnostic.hints.freeze,
187
+ trace: diagnostic.trace.map { |point| trace_point(point) }.freeze,
188
+ formatted: diagnostic.formatted
189
+ )
190
+ end.freeze
191
+ end
192
+
193
+ def trace_point(point)
194
+ TracePoint.new(message: point.message, location: location(point.location))
195
+ end
196
+
197
+ def location(location)
198
+ location && SourceLocation.new(file: location.file, line: location.line, column: location.column,
199
+ end_line: location.end_line, end_column: location.end_column)
200
+ end
158
201
  end
159
202
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Oicana
4
- VERSION = "0.10.0.rc.1"
4
+ VERSION = "0.10.0.rc.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oicana
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0.rc.1
4
+ version: 0.10.0.rc.2
5
5
  platform: aarch64-linux-gnu
6
6
  authors:
7
7
  - Oicana