expressir 2.4.52 → 2.4.54
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 +4 -4
- data/ext/expressir_core/Cargo.toml +1 -1
- data/ext/expressir_core/src/lib.rs +78 -8
- data/lib/expressir/express/core.rb +8 -0
- data/lib/expressir/express/parser.rb +32 -7
- data/lib/expressir/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 67855d853e2de439be7e5b5dfc4eec2c2c8aa3b409c885d277a10aa6593af0ba
|
|
4
|
+
data.tar.gz: 3e59c60890378f1559e1472ccf26b8cf01f0d977183c9d31ef7506163edeb1ae
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 52b2d2e1fdeb443492de6c52a9ae3a94dfb1a859539c52f1a463d0204577a1efb1cb624d056d9d5b35513062104ab67fce74492b0d2e2433c5d82b546fcad5e7
|
|
7
|
+
data.tar.gz: 482c1ea8c08a331dac07c98ab122a86c9a5a64af702cc2d0551058fe73ed495807c65ec29816ac67d6c821a8209c317509f54c229550b910178380fc8aea6a9e
|
|
@@ -13,7 +13,7 @@ magnus = { version = "0.9" }
|
|
|
13
13
|
# Pinned core release (M1, TODO.parity-ee/19): the ext never floats
|
|
14
14
|
# main — bump the tag per expressir release, alongside the validation
|
|
15
15
|
# run that pins it.
|
|
16
|
-
expressir-rs = { git = "https://github.com/lutaml/expressir-rs", tag = "v0.1.
|
|
16
|
+
expressir-rs = { git = "https://github.com/lutaml/expressir-rs", tag = "v0.1.19" }
|
|
17
17
|
serde_json = "1.0"
|
|
18
18
|
|
|
19
19
|
|
|
@@ -78,6 +78,27 @@ fn scan_remarks(ruby: &Ruby, source: String) -> Result<magnus::Value, Error> {
|
|
|
78
78
|
Ok(array.as_value())
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/// Removes `source_end_offset` from the wire before hydration: the
|
|
82
|
+
/// model layer declares no such attribute, and lutaml-model's
|
|
83
|
+
/// instantiate rejects unknown keys. The offsets serve the remark
|
|
84
|
+
/// attacher, which has already run by the time this is called.
|
|
85
|
+
fn strip_end_offsets(value: &mut Wire) {
|
|
86
|
+
match value {
|
|
87
|
+
Wire::Object(map) => {
|
|
88
|
+
map.remove("source_end_offset");
|
|
89
|
+
for (_key, item) in map.iter_mut() {
|
|
90
|
+
strip_end_offsets(item);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
Wire::Array(items) => {
|
|
94
|
+
for item in items {
|
|
95
|
+
strip_end_offsets(item);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
_ => {}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
81
102
|
/// Resolves `Expressir::Model::*` classes by their wire `_class` name,
|
|
82
103
|
/// caching each lookup (the class set is closed).
|
|
83
104
|
#[derive(Default)]
|
|
@@ -267,7 +288,11 @@ fn batch_next(ruby: &Ruby, stream: &BatchStream) -> Result<magnus::Value, Error>
|
|
|
267
288
|
.expect("wires")
|
|
268
289
|
.push((path.clone(), wire.clone()));
|
|
269
290
|
let mut cache = stream.cache.lock().expect("class cache");
|
|
270
|
-
|
|
291
|
+
// The model layer declares no source_end_offset; the wire
|
|
292
|
+
// carries it for the attacher only.
|
|
293
|
+
let mut hydrate_wire = wire.clone();
|
|
294
|
+
strip_end_offsets(&mut hydrate_wire);
|
|
295
|
+
let model = value_to_ruby(ruby, &mut cache, &hydrate_wire)?;
|
|
271
296
|
triple.push(model)?;
|
|
272
297
|
triple.push(ruby.qnil())?;
|
|
273
298
|
}
|
|
@@ -367,6 +392,10 @@ fn set_hydrate_one(ruby: &Ruby, reader: &SetReader, wire_path: String) -> Result
|
|
|
367
392
|
Error::new(ruby.exception_runtime_error(), format!("{}: {e}", file.wire_path))
|
|
368
393
|
})?;
|
|
369
394
|
let mut cache = reader.cache.lock().expect("class cache");
|
|
395
|
+
// The stored wire keeps the attacher's source_end_offset; the model
|
|
396
|
+
// layer does not declare it.
|
|
397
|
+
let mut wire = wire;
|
|
398
|
+
strip_end_offsets(&mut wire);
|
|
370
399
|
let model = value_to_ruby(ruby, &mut cache, &wire)?;
|
|
371
400
|
let pair = RArray::with_capacity(2);
|
|
372
401
|
pair.push(ruby.str_new(&file.wire_path))?;
|
|
@@ -387,6 +416,10 @@ fn set_next(ruby: &Ruby, reader: &SetReader) -> Result<magnus::Value, Error> {
|
|
|
387
416
|
Error::new(ruby.exception_runtime_error(), format!("{}: {e}", file.wire_path))
|
|
388
417
|
})?;
|
|
389
418
|
let mut cache = reader.cache.lock().expect("class cache");
|
|
419
|
+
// The stored wire keeps the attacher's source_end_offset; the model
|
|
420
|
+
// layer does not declare it.
|
|
421
|
+
let mut wire = wire;
|
|
422
|
+
strip_end_offsets(&mut wire);
|
|
390
423
|
let model = value_to_ruby(ruby, &mut cache, &wire)?;
|
|
391
424
|
let pair = RArray::with_capacity(2);
|
|
392
425
|
pair.push(ruby.str_new(&file.wire_path))?;
|
|
@@ -465,13 +498,29 @@ fn value_to_ruby(ruby: &Ruby, cache: &mut ClassCache, wire: &Wire) -> Result<mag
|
|
|
465
498
|
Ok(array.as_value())
|
|
466
499
|
}
|
|
467
500
|
Wire::Object(map) => {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
501
|
+
// RemarkInfo wires carry no `_class` (the Ruby map does not
|
|
502
|
+
// render one); their key set is closed, so recognize them
|
|
503
|
+
// structurally and construct through the declared class.
|
|
504
|
+
let is_remark_info = !map.contains_key("_class")
|
|
505
|
+
&& map
|
|
506
|
+
.keys()
|
|
507
|
+
.all(|k| matches!(k.as_str(), "text" | "format" | "tag" | "placement" | "region" | "source_offset"));
|
|
508
|
+
let class_name = if is_remark_info {
|
|
509
|
+
"Expressir::Model::RemarkInfo".to_string()
|
|
510
|
+
} else {
|
|
511
|
+
map.get("_class").and_then(Wire::as_str).ok_or_else(|| {
|
|
512
|
+
let mut keys: Vec<&str> = map.keys().map(String::as_str).collect();
|
|
513
|
+
keys.sort_unstable();
|
|
514
|
+
Error::new(
|
|
515
|
+
ruby.exception_runtime_error(),
|
|
516
|
+
format!(
|
|
517
|
+
"expressir-core: model node without _class (keys: {:?})",
|
|
518
|
+
keys
|
|
519
|
+
),
|
|
520
|
+
)
|
|
521
|
+
})?.to_string()
|
|
522
|
+
};
|
|
523
|
+
let klass = cache.resolve(ruby, &class_name)?;
|
|
475
524
|
let attrs = RHash::new();
|
|
476
525
|
let mut null_members: Vec<String> = Vec::new();
|
|
477
526
|
for (key, item) in map {
|
|
@@ -508,6 +557,26 @@ fn model_object(ruby: &Ruby, source: String, path: String) -> Result<magnus::Val
|
|
|
508
557
|
)
|
|
509
558
|
})?;
|
|
510
559
|
let wire = tree.to_model_json(&path).map_err(|e| parse_error(ruby, e))?;
|
|
560
|
+
let mut wire = wire;
|
|
561
|
+
strip_end_offsets(&mut wire);
|
|
562
|
+
let mut cache = ClassCache::default();
|
|
563
|
+
value_to_ruby(ruby, &mut cache, &wire)
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/// `parse_to_model` with the remark attachment run in the core
|
|
567
|
+
/// (issue #20): the scanner + attacher produce the attached wire before
|
|
568
|
+
/// hydration, so the Ruby lane never runs RemarkAttacher.
|
|
569
|
+
fn model_object_attached(ruby: &Ruby, source: String, path: String) -> Result<magnus::Value, Error> {
|
|
570
|
+
let tree = ParsedTree::parse(&source).map_err(|e| {
|
|
571
|
+
Error::new(
|
|
572
|
+
ruby.exception_runtime_error(),
|
|
573
|
+
format!("expressir-core: parse error: {e:?}"),
|
|
574
|
+
)
|
|
575
|
+
})?;
|
|
576
|
+
let mut wire = tree.to_model_json(&path).map_err(|e| parse_error(ruby, e))?;
|
|
577
|
+
expressir_rs::attach::attach_tagged_remarks(&mut wire, &source);
|
|
578
|
+
expressir_rs::attach::attach_untagged_remarks(&mut wire, &source);
|
|
579
|
+
strip_end_offsets(&mut wire);
|
|
511
580
|
let mut cache = ClassCache::default();
|
|
512
581
|
value_to_ruby(ruby, &mut cache, &wire)
|
|
513
582
|
}
|
|
@@ -517,6 +586,7 @@ fn init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
517
586
|
let module = ruby.define_module("Expressir")?.define_module("Core")?;
|
|
518
587
|
module.define_singleton_method("parse_to_model_hash", function!(model_json, 2))?;
|
|
519
588
|
module.define_singleton_method("parse_to_model", function!(model_object, 2))?;
|
|
589
|
+
module.define_singleton_method("parse_to_model_attached", function!(model_object_attached, 2))?;
|
|
520
590
|
module.define_singleton_method("scan_remarks", function!(scan_remarks, 1))?;
|
|
521
591
|
module.define_singleton_method("write_set", function!(set_write, 3))?;
|
|
522
592
|
let batch_class = module.define_class("BatchStream", ruby.class_object())?;
|
|
@@ -40,6 +40,14 @@ module Expressir
|
|
|
40
40
|
JSON.parse(::Expressir::Core.parse_to_model_hash(source, path))
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
+
# Parse EXPRESS source into the hydrated model with the remark
|
|
44
|
+
# attachment run in the core (issue #20): the wire carries the
|
|
45
|
+
# attached remarks before hydration, so the Ruby RemarkAttacher
|
|
46
|
+
# never runs on this lane.
|
|
47
|
+
def self.parse_to_model_attached(source, path)
|
|
48
|
+
::Expressir::Core.parse_to_model_attached(source, path)
|
|
49
|
+
end
|
|
50
|
+
|
|
43
51
|
# Scan remarks (issue #20): an Array of Hashes mirroring
|
|
44
52
|
# RemarkScanner::Remark's fields (position, end_position, line,
|
|
45
53
|
# text, tag, format), straight from the Rust scanner.
|
|
@@ -208,14 +208,21 @@ module Expressir
|
|
|
208
208
|
source = strip_bom(File.read(file))
|
|
209
209
|
schema_file = root_path ? Pathname.new(file.to_s).relative_path_from(root_path).to_s : file.to_s
|
|
210
210
|
|
|
211
|
+
remarks_attached = false
|
|
211
212
|
exp_file =
|
|
212
213
|
begin
|
|
213
|
-
Core.
|
|
214
|
+
if Core.respond_to?(:parse_to_model_attached)
|
|
215
|
+
remarks_attached = true
|
|
216
|
+
Core.parse_to_model_attached(source, schema_file)
|
|
217
|
+
.tap(&:wire_parents)
|
|
218
|
+
else
|
|
219
|
+
Core.parse_to_model(source, schema_file).tap(&:wire_parents)
|
|
220
|
+
end
|
|
214
221
|
rescue NotImplementedError
|
|
215
222
|
begin
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
)&.tap(&:wire_parents)
|
|
223
|
+
wire = JSON.parse(Core.parse_to_model_hash(source, schema_file))
|
|
224
|
+
strip_end_offsets!(wire)
|
|
225
|
+
Model::ExpFile.from_hash(wire)&.tap(&:wire_parents)
|
|
219
226
|
rescue StandardError => e
|
|
220
227
|
raise Error::SchemaParseFailure.new(schema_file, e)
|
|
221
228
|
end
|
|
@@ -224,7 +231,8 @@ module Expressir
|
|
|
224
231
|
end
|
|
225
232
|
|
|
226
233
|
finalize_loaded_file(exp_file, source, schema_file,
|
|
227
|
-
include_source: include_source
|
|
234
|
+
include_source: include_source,
|
|
235
|
+
remarks_attached: remarks_attached)
|
|
228
236
|
|
|
229
237
|
unless skip_references
|
|
230
238
|
Expressir::Benchmark.measure_references do
|
|
@@ -240,8 +248,10 @@ module Expressir
|
|
|
240
248
|
# Shared post-parse steps for every core-path file: remark
|
|
241
249
|
# attachment, header-remark transfer, and path wiring.
|
|
242
250
|
def self.finalize_loaded_file(exp_file, source, schema_file,
|
|
243
|
-
include_source: nil)
|
|
244
|
-
|
|
251
|
+
include_source: nil, remarks_attached: false)
|
|
252
|
+
if source && include_source != false && !remarks_attached
|
|
253
|
+
RemarkAttacher.new(source).attach(exp_file)
|
|
254
|
+
end
|
|
245
255
|
|
|
246
256
|
transfer_header_to_schema(exp_file, source)
|
|
247
257
|
|
|
@@ -251,6 +261,21 @@ module Expressir
|
|
|
251
261
|
schema.file_basename = File.basename(schema_file, ".exp")
|
|
252
262
|
end
|
|
253
263
|
end
|
|
264
|
+
|
|
265
|
+
# The model layer declares no source_end_offset; the wire carries
|
|
266
|
+
# it for the attacher, and the from_hash fallback must not see it.
|
|
267
|
+
def self.strip_end_offsets!(obj)
|
|
268
|
+
case obj
|
|
269
|
+
when Hash
|
|
270
|
+
obj.delete("source_end_offset")
|
|
271
|
+
obj.each_value { |value| strip_end_offsets!(value) }
|
|
272
|
+
when Array
|
|
273
|
+
obj.each { |value| strip_end_offsets!(value) }
|
|
274
|
+
end
|
|
275
|
+
obj
|
|
276
|
+
end
|
|
277
|
+
private_class_method :strip_end_offsets!
|
|
278
|
+
|
|
254
279
|
private_class_method :finalize_loaded_file
|
|
255
280
|
|
|
256
281
|
# Whether the native batch compiler is usable: the extension is
|
data/lib/expressir/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: expressir
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.4.
|
|
4
|
+
version: 2.4.54
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rb_sys
|
|
@@ -807,7 +806,6 @@ metadata:
|
|
|
807
806
|
source_code_uri: https://github.com/lutaml/expressir
|
|
808
807
|
changelog_uri: https://github.com/lutaml/expressir/releases
|
|
809
808
|
rubygems_mfa_required: 'true'
|
|
810
|
-
post_install_message:
|
|
811
809
|
rdoc_options: []
|
|
812
810
|
require_paths:
|
|
813
811
|
- lib
|
|
@@ -822,8 +820,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
822
820
|
- !ruby/object:Gem::Version
|
|
823
821
|
version: '0'
|
|
824
822
|
requirements: []
|
|
825
|
-
rubygems_version: 3.
|
|
826
|
-
signing_key:
|
|
823
|
+
rubygems_version: 3.6.9
|
|
827
824
|
specification_version: 4
|
|
828
825
|
summary: EXPRESS parser and toolkit for Ruby
|
|
829
826
|
test_files: []
|