polyxml 0.14.1__tar.gz → 0.14.2__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.
Files changed (54) hide show
  1. {polyxml-0.14.1 → polyxml-0.14.2}/Cargo.lock +5 -5
  2. {polyxml-0.14.1 → polyxml-0.14.2}/Cargo.toml +1 -1
  3. {polyxml-0.14.1 → polyxml-0.14.2}/PKG-INFO +1 -1
  4. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/src/codegen/cpp/mod.rs +6 -1
  5. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/src/codegen/csharp/mod.rs +3 -2
  6. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/src/codegen/go/mod.rs +6 -1
  7. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/src/codegen/rust/mod.rs +29 -6
  8. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/src/codegen/typescript/mod.rs +23 -0
  9. {polyxml-0.14.1 → polyxml-0.14.2}/pyproject.toml +1 -1
  10. {polyxml-0.14.1 → polyxml-0.14.2}/README.md +0 -0
  11. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/Cargo.toml +0 -0
  12. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/README.md +0 -0
  13. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/benches/core_benchmarks.rs +0 -0
  14. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/src/codegen/java/mod.rs +0 -0
  15. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/src/codegen/mod.rs +0 -0
  16. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/src/codegen/python/mod.rs +0 -0
  17. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/src/converters.rs +0 -0
  18. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/src/error.rs +0 -0
  19. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/src/ir/mod.rs +0 -0
  20. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/src/ir/tarjan.rs +0 -0
  21. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/src/json.rs +0 -0
  22. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/src/lib.rs +0 -0
  23. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/src/parser.rs +0 -0
  24. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/src/schema.rs +0 -0
  25. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/src/schema_parser/mod.rs +0 -0
  26. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/src/serializer.rs +0 -0
  27. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/src/transcoder.rs +0 -0
  28. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/src/value.rs +0 -0
  29. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/tests/test_conformance.rs +0 -0
  30. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/tests/test_core.rs +0 -0
  31. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/tests/test_cpp_codegen.rs +0 -0
  32. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/tests/test_csharp_codegen.rs +0 -0
  33. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/tests/test_go_codegen.rs +0 -0
  34. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/tests/test_java_codegen.rs +0 -0
  35. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/tests/test_json.rs +0 -0
  36. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/tests/test_python_codegen.rs +0 -0
  37. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/tests/test_rust_codecs.rs +0 -0
  38. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/tests/test_rust_codegen.rs +0 -0
  39. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/tests/test_schema_ir.rs +0 -0
  40. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/tests/test_security.rs +0 -0
  41. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/tests/test_transcoder.rs +0 -0
  42. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-core/tests/test_ts_codegen.rs +0 -0
  43. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-python/Cargo.toml +0 -0
  44. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-python/README.md +0 -0
  45. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-python/src/lib.rs +0 -0
  46. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-python/tests/test_conformance.py +0 -0
  47. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-python/tests/test_generated_models.py +0 -0
  48. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-python/tests/test_json.py +0 -0
  49. {polyxml-0.14.1 → polyxml-0.14.2}/crates/polyxml-python/tests/test_polyxml.py +0 -0
  50. {polyxml-0.14.1 → polyxml-0.14.2}/python/polyxml/AGENT_GUIDE.md +0 -0
  51. {polyxml-0.14.1 → polyxml-0.14.2}/python/polyxml/__init__.py +0 -0
  52. {polyxml-0.14.1 → polyxml-0.14.2}/python/polyxml/compat/__init__.py +0 -0
  53. {polyxml-0.14.1 → polyxml-0.14.2}/python/polyxml/compat/xsdata.py +0 -0
  54. {polyxml-0.14.1 → polyxml-0.14.2}/python/polyxml/py.typed +0 -0
@@ -549,7 +549,7 @@ dependencies = [
549
549
 
550
550
  [[package]]
551
551
  name = "polyxml"
552
- version = "0.14.1"
552
+ version = "0.14.2"
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.1"
570
+ version = "0.14.2"
571
571
  dependencies = [
572
572
  "polyxml",
573
573
  ]
574
574
 
575
575
  [[package]]
576
576
  name = "polyxml-cli"
577
- version = "0.14.1"
577
+ version = "0.14.2"
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.1"
591
+ version = "0.14.2"
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.1"
601
+ version = "0.14.2"
602
602
  dependencies = [
603
603
  "lexical-core",
604
604
  "polyxml",
@@ -3,7 +3,7 @@ resolver = "2"
3
3
  members = ["crates/polyxml-core", "crates/polyxml-python"]
4
4
 
5
5
  [workspace.package]
6
- version = "0.14.1"
6
+ version = "0.14.2"
7
7
  edition = "2021"
8
8
  rust-version = "1.80"
9
9
  license = "MIT"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polyxml
3
- Version: 0.14.1
3
+ Version: 0.14.2
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -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
- writeln!(out, "/// {}", doc).unwrap();
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
- writeln!(out, "// {}", doc).unwrap();
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: true,
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 &e.variants {
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) {
@@ -1028,7 +1046,6 @@ impl RustCodegen {
1028
1046
  }
1029
1047
  out.push_str(" _ => {}\n");
1030
1048
  out.push_str(" }\n");
1031
- out.push_str(" }\n");
1032
1049
  }
1033
1050
 
1034
1051
  let elem_fields: Vec<_> = field_metas
@@ -1175,7 +1192,7 @@ impl RustCodegen {
1175
1192
  if !attr_fields.is_empty() {
1176
1193
  out.push_str("\n for attr in start.attributes() {\n");
1177
1194
  out.push_str(" let attr = attr?;\n");
1178
- out.push_str(" match attr.key.local_name().as_ref() {\n");
1195
+ out.push_str(" match std::str::from_utf8(attr.key.local_name().as_ref()).unwrap_or(\"\") {\n");
1179
1196
  for meta in &attr_fields {
1180
1197
  let _ = writeln!(out, " \"{}\" => {{", meta.field.xml_name);
1181
1198
  self.emit_attr_parse(out, &meta.field, &meta.rust_name, ir);
@@ -1217,6 +1234,12 @@ impl RustCodegen {
1217
1234
  meta.rust_name, meta.rust_name
1218
1235
  );
1219
1236
  }
1237
+ } else if self.options.derive_default {
1238
+ let _ = writeln!(
1239
+ out,
1240
+ " {}: var_{}.unwrap_or_default(),",
1241
+ meta.rust_name, meta.rust_name
1242
+ );
1220
1243
  } else {
1221
1244
  let _ = writeln!(
1222
1245
  out,
@@ -246,6 +246,29 @@ 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)) = ir.types.get(target_qname) {
255
+ visit(dep_struct, ir, visiting, visited, ordered);
256
+ }
257
+ }
258
+ }
259
+ TypeRef::List(inner) | TypeRef::Boxed(inner) => {
260
+ if let TypeRef::Named(target_qname) = inner.as_ref() {
261
+ if target_qname != &s.qname {
262
+ if let Some(TypeDef::Struct(dep_struct)) = ir.types.get(target_qname) {
263
+ visit(dep_struct, ir, visiting, visited, ordered);
264
+ }
265
+ }
266
+ }
267
+ }
268
+ _ => {}
269
+ }
270
+ }
271
+ }
249
272
  visiting.remove(&s.qname);
250
273
  visited.insert(s.qname.clone());
251
274
  ordered.push(ir.types.get(&s.qname).unwrap());
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "polyxml"
7
- version = "0.14.1"
7
+ version = "0.14.2"
8
8
  description = "High-performance, polyglot XML data-binding engine built in Rust"
9
9
  authors = [
10
10
  { name = "Bailey Nguyen", email = "bailey.tan.nguyen@gmail.com" }
File without changes