Skip to content

feat(metadata): include constant literals and export typing - #274

Merged
Hamilton Chapman (hamchapman) merged 2 commits into
getditto:masterfrom
hamchapman:hc/ffi-metadata-constants
Nov 3, 2026
Merged

Hamilton Chapman (hamchapman) merged 2 commits into
getditto:masterfrom
hamchapman:hc/ffi-metadata-constants

Conversation

@hamchapman

@hamchapman Hamilton Chapman (hamchapman) commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Summary

JSON metadata records constant names and types but omits their values, forcing binding generators to get to the values via a secondary mechanism .

This change means we now include valueLiteral and hasExplicitType so generators can reproduce the constant outputs directly from metadata.

Literal spellings are JSON strings, preserving large integers and the existing Debug representation. JSON escaping handles control characters and Unicode. Existing metadata consumers that reject unknown fields must accept the new fields before adopting this change; C/C#/Lua output is unchanged.

@hamchapman Hamilton Chapman (hamchapman) added the K-feature Kind: proposed new code to implement new behaviour label Nov 2, 2026
@hamchapman
Hamilton Chapman (hamchapman) force-pushed the hc/ffi-metadata-constants branch 2 times, most recently from a3810b1 to cba958a Compare November 2, 2026 16:22
Comment thread src/headers/languages/metadata.rs Outdated
Comment on lines +484 to +486
'"' => quoted.push_str("\\\""),
'\\' => quoted.push_str("\\\\"),
'\u{0}'..='\u{1f}' => quoted.push_str(&format!("\\u{:04x}", character as u32)),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest we use r#"…"# strings for readability:

Suggested change
'"' => quoted.push_str("\\\""),
'\\' => quoted.push_str("\\\\"),
'\u{0}'..='\u{1f}' => quoted.push_str(&format!("\\u{:04x}", character as u32)),
'"' => quoted.push_str(r#"\""#),
'\\' => quoted.push_str(r#"\\"#),
'\u{0}'..='\u{1f}' => quoted.push_str(&format!(r#"\u{:04x}"#, character as u32)),

Comment thread Cargo.toml Outdated
safer-ffi.features = ["internal-tests"]
rand = "0.9.0"
serde_test = { version = "1.0.177" }
serde_json = "1"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
serde_json = "1"
serde_json = "1.0.154"

@hamchapman
Hamilton Chapman (hamchapman) merged commit e9e9b46 into getditto:master Nov 3, 2026
207 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

K-feature Kind: proposed new code to implement new behaviour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants