// This file is intended to be a big complicated mess to show of all sorts of features // of KDLScript test files, and really stress out codegen backends. // Structs and attributes! @align 16 struct "DataPoint" { // Arrays! point "[MeterCoordinate; 2]" data "Data" } // Enums! enum "Fanciness" { Boring -1 Stylish 17 Fancy TooMuch 23 } // Tagged unions! tagged "Data" { // Can omit names of fields for auto-naming / tupleness Simple { _ "f64"; } Complex { fancy "Fanciness" value "u32" } Empty } // Untagged Unions! union "DangerousData" { // We *don't* support C's inline anonymous structs, have to name a type per case! Int "i32" Float "f64" } // Cross-language type puns! pun "MeterCoordinate" { // Rust promises that this... lang "rust" { @repr "transparent" struct "MeterCoordinate" { _ "f32" } } // Is equivalent to this lang "c" "cpp" { // Aliases! alias "MeterCoordinate" "f32" } } struct "RawDataSet" { // References! In types! raw "&[DangerousData; 8]" fancy "Fanciness" } struct "FullDataSet" { data "[DataPoint; 8]" } // Functions! fn "process_raw_data" { inputs { data "RawDataSet" timeout "u32" } outputs { _ "FullDataSet" } } // Can exclude output fn "report_data" { inputs { _ "DataPoint" } } // Or exclude input fn "get_raw_data_point" { outputs { _ "DangerousData" } }