polyxml 0.14.1__tar.gz → 0.14.3__tar.gz
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.
- {polyxml-0.14.1 → polyxml-0.14.3}/Cargo.lock +5 -5
- {polyxml-0.14.1 → polyxml-0.14.3}/Cargo.toml +1 -1
- {polyxml-0.14.1 → polyxml-0.14.3}/PKG-INFO +1 -1
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/src/codegen/cpp/mod.rs +6 -1
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/src/codegen/csharp/mod.rs +3 -2
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/src/codegen/go/mod.rs +6 -1
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/src/codegen/rust/mod.rs +28 -4
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/src/codegen/typescript/mod.rs +27 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/tests/test_rust_codegen.rs +50 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/pyproject.toml +1 -1
- {polyxml-0.14.1 → polyxml-0.14.3}/README.md +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/Cargo.toml +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/README.md +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/benches/core_benchmarks.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/src/codegen/java/mod.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/src/codegen/mod.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/src/codegen/python/mod.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/src/converters.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/src/error.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/src/ir/mod.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/src/ir/tarjan.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/src/json.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/src/lib.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/src/parser.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/src/schema.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/src/schema_parser/mod.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/src/serializer.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/src/transcoder.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/src/value.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/tests/test_conformance.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/tests/test_core.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/tests/test_cpp_codegen.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/tests/test_csharp_codegen.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/tests/test_go_codegen.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/tests/test_java_codegen.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/tests/test_json.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/tests/test_python_codegen.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/tests/test_rust_codecs.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/tests/test_schema_ir.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/tests/test_security.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/tests/test_transcoder.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-core/tests/test_ts_codegen.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-python/Cargo.toml +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-python/README.md +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-python/src/lib.rs +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-python/tests/test_conformance.py +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-python/tests/test_generated_models.py +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-python/tests/test_json.py +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/crates/polyxml-python/tests/test_polyxml.py +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/python/polyxml/AGENT_GUIDE.md +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/python/polyxml/__init__.py +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/python/polyxml/compat/__init__.py +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/python/polyxml/compat/xsdata.py +0 -0
- {polyxml-0.14.1 → polyxml-0.14.3}/python/polyxml/py.typed +0 -0
|
@@ -549,7 +549,7 @@ dependencies = [
|
|
|
549
549
|
|
|
550
550
|
[[package]]
|
|
551
551
|
name = "polyxml"
|
|
552
|
-
version = "0.14.
|
|
552
|
+
version = "0.14.3"
|
|
553
553
|
dependencies = [
|
|
554
554
|
"criterion",
|
|
555
555
|
"heck",
|
|
@@ -567,14 +567,14 @@ dependencies = [
|
|
|
567
567
|
|
|
568
568
|
[[package]]
|
|
569
569
|
name = "polyxml-c"
|
|
570
|
-
version = "0.14.
|
|
570
|
+
version = "0.14.3"
|
|
571
571
|
dependencies = [
|
|
572
572
|
"polyxml",
|
|
573
573
|
]
|
|
574
574
|
|
|
575
575
|
[[package]]
|
|
576
576
|
name = "polyxml-cli"
|
|
577
|
-
version = "0.14.
|
|
577
|
+
version = "0.14.3"
|
|
578
578
|
dependencies = [
|
|
579
579
|
"clap",
|
|
580
580
|
"glob",
|
|
@@ -588,7 +588,7 @@ dependencies = [
|
|
|
588
588
|
|
|
589
589
|
[[package]]
|
|
590
590
|
name = "polyxml-js"
|
|
591
|
-
version = "0.14.
|
|
591
|
+
version = "0.14.3"
|
|
592
592
|
dependencies = [
|
|
593
593
|
"napi",
|
|
594
594
|
"napi-build",
|
|
@@ -598,7 +598,7 @@ dependencies = [
|
|
|
598
598
|
|
|
599
599
|
[[package]]
|
|
600
600
|
name = "polyxml-python"
|
|
601
|
-
version = "0.14.
|
|
601
|
+
version = "0.14.3"
|
|
602
602
|
dependencies = [
|
|
603
603
|
"lexical-core",
|
|
604
604
|
"polyxml",
|
|
@@ -799,7 +799,12 @@ concept XmlModel = requires(T a) {{
|
|
|
799
799
|
let target_type = self.context.map_type_ref(&elem.type_ref);
|
|
800
800
|
if elem_alias != target_type {
|
|
801
801
|
if let Some(ref doc) = elem.documentation {
|
|
802
|
-
|
|
802
|
+
for line in doc.lines() {
|
|
803
|
+
let trimmed = line.trim();
|
|
804
|
+
if !trimmed.is_empty() {
|
|
805
|
+
writeln!(out, "/// {}", trimmed).unwrap();
|
|
806
|
+
}
|
|
807
|
+
}
|
|
803
808
|
}
|
|
804
809
|
writeln!(out, "using {} = {};", elem_alias, target_type).unwrap();
|
|
805
810
|
}
|
|
@@ -595,10 +595,11 @@ impl CSharpCodegen {
|
|
|
595
595
|
|
|
596
596
|
fn emit_struct_validator(&self, out: &mut String, s: &StructDef, indent: &str) {
|
|
597
597
|
let struct_name = to_csharp_type_name(&s.qname.local);
|
|
598
|
+
let new_kw = if s.base_type.is_some() { "new " } else { "" };
|
|
598
599
|
writeln!(
|
|
599
600
|
out,
|
|
600
|
-
"{} public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)",
|
|
601
|
-
indent
|
|
601
|
+
"{} public {}IEnumerable<ValidationResult> Validate(ValidationContext validationContext)",
|
|
602
|
+
indent, new_kw
|
|
602
603
|
)
|
|
603
604
|
.unwrap();
|
|
604
605
|
writeln!(out, "{} {{", indent).unwrap();
|
|
@@ -760,7 +760,12 @@ impl GoCodegen {
|
|
|
760
760
|
let target_type = self.context.map_type_ref(&elem.type_ref);
|
|
761
761
|
if elem_alias != target_type {
|
|
762
762
|
if let Some(ref doc) = elem.documentation {
|
|
763
|
-
|
|
763
|
+
for line in doc.lines() {
|
|
764
|
+
let trimmed = line.trim();
|
|
765
|
+
if !trimmed.is_empty() {
|
|
766
|
+
writeln!(out, "// {}", trimmed).unwrap();
|
|
767
|
+
}
|
|
768
|
+
}
|
|
764
769
|
}
|
|
765
770
|
writeln!(out, "type {} = {}\n", elem_alias, target_type).unwrap();
|
|
766
771
|
}
|
|
@@ -33,7 +33,7 @@ impl Default for RustOptions {
|
|
|
33
33
|
zero_copy: true,
|
|
34
34
|
derive_serde: true,
|
|
35
35
|
derive_default: true,
|
|
36
|
-
emit_polyxml_attrs:
|
|
36
|
+
emit_polyxml_attrs: false,
|
|
37
37
|
emit_root_aliases: true,
|
|
38
38
|
emit_codecs: true,
|
|
39
39
|
}
|
|
@@ -201,7 +201,7 @@ impl RustCodegen {
|
|
|
201
201
|
|
|
202
202
|
out.push_str("// Generated by PolyXML Compiler (https://github.com/nth-bailey/PolyXML)\n");
|
|
203
203
|
out.push_str(
|
|
204
|
-
"#![allow(dead_code, unused_imports, non_camel_case_types, non_snake_case)]\n\n",
|
|
204
|
+
"#![allow(dead_code, unused_imports, unused_mut, unused_variables, non_camel_case_types, non_snake_case)]\n\n",
|
|
205
205
|
);
|
|
206
206
|
|
|
207
207
|
let types_with_lifetime = if self.options.zero_copy {
|
|
@@ -422,6 +422,9 @@ impl RustCodegen {
|
|
|
422
422
|
}
|
|
423
423
|
|
|
424
424
|
let mut derives = vec!["Debug", "Clone", "Copy", "PartialEq", "Eq", "Hash"];
|
|
425
|
+
if self.options.derive_default {
|
|
426
|
+
derives.push("Default");
|
|
427
|
+
}
|
|
425
428
|
if self.options.derive_serde {
|
|
426
429
|
derives.push("Serialize");
|
|
427
430
|
derives.push("Deserialize");
|
|
@@ -433,7 +436,7 @@ impl RustCodegen {
|
|
|
433
436
|
let mut seen_variants = HashSet::new();
|
|
434
437
|
let mut variant_map = Vec::new();
|
|
435
438
|
|
|
436
|
-
for variant in
|
|
439
|
+
for (idx, variant) in e.variants.iter().enumerate() {
|
|
437
440
|
let mut var_id = to_rust_variant_identifier(&variant.name);
|
|
438
441
|
let mut counter = 1;
|
|
439
442
|
while seen_variants.contains(&var_id) {
|
|
@@ -448,6 +451,9 @@ impl RustCodegen {
|
|
|
448
451
|
if self.options.derive_serde {
|
|
449
452
|
let _ = writeln!(out, " #[serde(rename = \"{}\")]", variant.value);
|
|
450
453
|
}
|
|
454
|
+
if self.options.derive_default && idx == 0 {
|
|
455
|
+
let _ = writeln!(out, " #[default]");
|
|
456
|
+
}
|
|
451
457
|
let _ = writeln!(out, " {},", var_id);
|
|
452
458
|
variant_map.push((var_id, variant.value.clone()));
|
|
453
459
|
}
|
|
@@ -471,7 +477,7 @@ impl RustCodegen {
|
|
|
471
477
|
// std::str::FromStr
|
|
472
478
|
let _ = writeln!(out, "impl std::str::FromStr for {} {{", enum_name);
|
|
473
479
|
out.push_str(" type Err = String;\n\n");
|
|
474
|
-
out.push_str(" fn from_str(s: &str) -> Result<Self, Self::Err> {\n");
|
|
480
|
+
out.push_str(" fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {\n");
|
|
475
481
|
out.push_str(" match s {\n");
|
|
476
482
|
for (var_id, val) in &variant_map {
|
|
477
483
|
let _ = writeln!(out, " \"{}\" => Ok(Self::{}),", val, var_id);
|
|
@@ -837,6 +843,18 @@ impl RustCodegen {
|
|
|
837
843
|
| PrimitiveType::Entities
|
|
838
844
|
| PrimitiveType::AnyUri
|
|
839
845
|
| PrimitiveType::QName
|
|
846
|
+
| PrimitiveType::DateTime
|
|
847
|
+
| PrimitiveType::Date
|
|
848
|
+
| PrimitiveType::Time
|
|
849
|
+
| PrimitiveType::Duration
|
|
850
|
+
| PrimitiveType::GYear
|
|
851
|
+
| PrimitiveType::GYearMonth
|
|
852
|
+
| PrimitiveType::GMonth
|
|
853
|
+
| PrimitiveType::GMonthDay
|
|
854
|
+
| PrimitiveType::GDay
|
|
855
|
+
| PrimitiveType::Base64Binary
|
|
856
|
+
| PrimitiveType::HexBinary
|
|
857
|
+
| PrimitiveType::AnySimpleType
|
|
840
858
|
),
|
|
841
859
|
TypeRef::Named(qname) => {
|
|
842
860
|
if let Some(TypeDef::Simple(s)) = ir.types.get(qname) {
|
|
@@ -1217,6 +1235,12 @@ impl RustCodegen {
|
|
|
1217
1235
|
meta.rust_name, meta.rust_name
|
|
1218
1236
|
);
|
|
1219
1237
|
}
|
|
1238
|
+
} else if self.options.derive_default {
|
|
1239
|
+
let _ = writeln!(
|
|
1240
|
+
out,
|
|
1241
|
+
" {}: var_{}.unwrap_or_default(),",
|
|
1242
|
+
meta.rust_name, meta.rust_name
|
|
1243
|
+
);
|
|
1220
1244
|
} else {
|
|
1221
1245
|
let _ = writeln!(
|
|
1222
1246
|
out,
|
|
@@ -246,6 +246,33 @@ impl TypeScriptCodegen {
|
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
|
+
for f in &s.fields {
|
|
250
|
+
if !f.is_cycle_cut {
|
|
251
|
+
match &f.type_ref {
|
|
252
|
+
TypeRef::Named(target_qname) => {
|
|
253
|
+
if target_qname != &s.qname {
|
|
254
|
+
if let Some(TypeDef::Struct(dep_struct)) =
|
|
255
|
+
ir.types.get(target_qname)
|
|
256
|
+
{
|
|
257
|
+
visit(dep_struct, ir, visiting, visited, ordered);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
TypeRef::List(inner) | TypeRef::Boxed(inner) => {
|
|
262
|
+
if let TypeRef::Named(target_qname) = inner.as_ref() {
|
|
263
|
+
if target_qname != &s.qname {
|
|
264
|
+
if let Some(TypeDef::Struct(dep_struct)) =
|
|
265
|
+
ir.types.get(target_qname)
|
|
266
|
+
{
|
|
267
|
+
visit(dep_struct, ir, visiting, visited, ordered);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
_ => {}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
249
276
|
visiting.remove(&s.qname);
|
|
250
277
|
visited.insert(s.qname.clone());
|
|
251
278
|
ordered.push(ir.types.get(&s.qname).unwrap());
|
|
@@ -448,3 +448,53 @@ fn test_rust_codecs_codegen() {
|
|
|
448
448
|
assert!(!code_disabled.contains("pub fn from_json_str("));
|
|
449
449
|
assert!(!code_disabled.contains("pub fn to_json_string("));
|
|
450
450
|
}
|
|
451
|
+
|
|
452
|
+
#[test]
|
|
453
|
+
fn test_rust_attribute_codec_loop_syntax() {
|
|
454
|
+
let mut ir = SchemaIR::new().with_target_namespace("https://example.com/siri");
|
|
455
|
+
ir.add_type(TypeDef::Struct(StructDef {
|
|
456
|
+
qname: QName::new(Some("https://example.com/siri"), "Envelope"),
|
|
457
|
+
base_type: None,
|
|
458
|
+
is_abstract: false,
|
|
459
|
+
fields: vec![
|
|
460
|
+
FieldDef {
|
|
461
|
+
name: "version".into(),
|
|
462
|
+
xml_name: "version".into(),
|
|
463
|
+
namespace: None,
|
|
464
|
+
kind: FieldKind::Attribute,
|
|
465
|
+
type_ref: TypeRef::Primitive(PrimitiveType::String),
|
|
466
|
+
cardinality: Cardinality::optional_one(),
|
|
467
|
+
nillable: false,
|
|
468
|
+
default_value: None,
|
|
469
|
+
fixed_value: None,
|
|
470
|
+
documentation: None,
|
|
471
|
+
facets: None,
|
|
472
|
+
is_cycle_cut: false,
|
|
473
|
+
},
|
|
474
|
+
FieldDef {
|
|
475
|
+
name: "body".into(),
|
|
476
|
+
xml_name: "Body".into(),
|
|
477
|
+
namespace: None,
|
|
478
|
+
kind: FieldKind::Element,
|
|
479
|
+
type_ref: TypeRef::Primitive(PrimitiveType::String),
|
|
480
|
+
cardinality: Cardinality::required_one(),
|
|
481
|
+
nillable: false,
|
|
482
|
+
default_value: None,
|
|
483
|
+
fixed_value: None,
|
|
484
|
+
documentation: None,
|
|
485
|
+
facets: None,
|
|
486
|
+
is_cycle_cut: false,
|
|
487
|
+
},
|
|
488
|
+
],
|
|
489
|
+
documentation: None,
|
|
490
|
+
}));
|
|
491
|
+
|
|
492
|
+
let codegen = RustCodegen::new(RustOptions {
|
|
493
|
+
emit_codecs: true,
|
|
494
|
+
..Default::default()
|
|
495
|
+
});
|
|
496
|
+
let code = codegen.generate_module(&ir);
|
|
497
|
+
assert!(code.contains("for attr in start.attributes() {"));
|
|
498
|
+
assert!(code.contains("match attr.key.local_name().as_ref() {"));
|
|
499
|
+
assert!(code.contains("\"version\" => {"));
|
|
500
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|