difftreelog
perf move ini manifestification to native
in: master
5 files changed
crates/jrsonnet-cli/src/manifest.rsdiffbeforeafterboth--- a/crates/jrsonnet-cli/src/manifest.rs
+++ b/crates/jrsonnet-cli/src/manifest.rs
@@ -4,7 +4,7 @@
use jrsonnet_evaluator::manifest::{
JsonFormat, ManifestFormat, StringFormat, ToStringFormat, YamlStreamFormat,
};
-use jrsonnet_stdlib::{TomlFormat, XmlJsonmlFormat, YamlFormat};
+use jrsonnet_stdlib::{IniFormat, TomlFormat, XmlJsonmlFormat, YamlFormat};
#[derive(Clone, Copy, ValueEnum)]
pub enum ManifestFormatName {
@@ -14,6 +14,7 @@
Yaml,
Toml,
XmlJsonml,
+ Ini,
}
#[derive(Parser)]
@@ -72,6 +73,10 @@
preserve_order,
)),
ManifestFormatName::XmlJsonml => Box::new(XmlJsonmlFormat::cli()),
+ ManifestFormatName::Ini => Box::new(IniFormat::cli(
+ #[cfg(feature = "exp-preserve-order")]
+ preserve_order,
+ )),
}
};
if self.yaml_stream {
crates/jrsonnet-stdlib/src/lib.rsdiffbeforeafterboth--- a/crates/jrsonnet-stdlib/src/lib.rs
+++ b/crates/jrsonnet-stdlib/src/lib.rs
@@ -179,6 +179,7 @@
("manifestPython", builtin_manifest_python::INST),
("manifestPythonVars", builtin_manifest_python_vars::INST),
("manifestXmlJsonml", builtin_manifest_xml_jsonml::INST),
+ ("manifestIni", builtin_manifest_ini::INST),
// Parse
("parseJson", builtin_parse_json::INST),
("parseYaml", builtin_parse_yaml::INST),
crates/jrsonnet-stdlib/src/manifest/mod.rsdiffbeforeafterboth1mod ini;1mod python;2mod python;2mod toml;3mod toml;3mod xml;4mod xml;4mod yaml;5mod yaml;567pub use ini::IniFormat;6use jrsonnet_evaluator::{8use jrsonnet_evaluator::{7 function::builtin,9 function::builtin,8 manifest::{escape_string_json, JsonFormat, YamlStreamFormat},10 manifest::{escape_string_json, JsonFormat, YamlStreamFormat},191 value.manifest(XmlJsonmlFormat::std_to_xml())193 value.manifest(XmlJsonmlFormat::std_to_xml())192}194}195196#[builtin]197pub fn builtin_manifest_ini(198 ini: Val,199200 #[default(false)]201 #[cfg(feature = "exp-preserve-order")]202 preserve_order: bool,203) -> Result<String> {204 ini.manifest(IniFormat::std(205 #[cfg(feature = "exp-preserve-order")]206 preserve_order,207 ))208}193209crates/jrsonnet-stdlib/src/manifest/toml.rsdiffbeforeafterboth--- a/crates/jrsonnet-stdlib/src/manifest/toml.rs
+++ b/crates/jrsonnet-stdlib/src/manifest/toml.rs
@@ -196,7 +196,7 @@
#[cfg(feature = "exp-preserve-order")]
options.preserve_order,
) {
- let value = value?;
+ let value = value.with_description(|| format!("field <{key}> evaluation"))?;
if is_section(&value)? {
sections.push((key, value));
} else {
crates/jrsonnet-stdlib/src/std.jsonnetdiffbeforeafterboth--- a/crates/jrsonnet-stdlib/src/std.jsonnet
+++ b/crates/jrsonnet-stdlib/src/std.jsonnet
@@ -25,26 +25,6 @@
else
error 'Assertion failed. ' + a + ' != ' + b,
- manifestIni(ini)::
- local body_lines(body) =
- std.join([], [
- local value_or_values = body[k];
- if std.isArray(value_or_values) then
- ['%s = %s' % [k, value] for value in value_or_values]
- else
- ['%s = %s' % [k, value_or_values]]
-
- for k in std.objectFields(body)
- ]);
-
- local section_lines(sname, sbody) = ['[%s]' % [sname]] + body_lines(sbody),
- main_body = if std.objectHas(ini, 'main') then body_lines(ini.main) else [],
- all_sections = [
- section_lines(k, ini.sections[k])
- for k in std.objectFields(ini.sections)
- ];
- std.join('\n', main_body + std.flattenArrays(all_sections) + ['']),
-
mergePatch(target, patch)::
if std.isObject(patch) then
local target_object =