|
|
@ -91,9 +91,7 @@ tstylesheet { |
|
|
|
// -------- |
|
|
|
``apply "deftype", 0 |
|
|
|
|
|
|
|
// Enums |
|
|
|
// ----- |
|
|
|
``apply "enum", 0 |
|
|
|
``call "enums" |
|
|
|
|
|
|
|
// Structs |
|
|
|
// ------- |
|
|
@ -181,10 +179,25 @@ tstylesheet { |
|
|
|
result "yml:ucase(concat($pkg_name, '_', $name))"; |
|
|
|
} |
|
|
|
|
|
|
|
function "enums" { |
|
|
|
|| |
|
|
|
// Enums |
|
|
|
// ----- |
|
|
|
|
|
|
|
``apply "enum" |
|
|
|
|| |
|
|
|
} |
|
|
|
|
|
|
|
template "enum" { |
|
|
|
const "idl_name", "@name"; |
|
|
|
const "pkg_name", "../../@name"; |
|
|
|
const "enum_name", "func:idltype_to_ctype_enum($pkg_name, $idl_name)"; |
|
|
|
call "enum" |
|
|
|
with "idl_enum_name", "@name", |
|
|
|
with "idl_pkg_name", "../../@name"; |
|
|
|
} |
|
|
|
|
|
|
|
function "enum" { |
|
|
|
param "idl_enum_name"; |
|
|
|
param "idl_pkg_name"; |
|
|
|
const "enum_name", "func:idltype_to_ctype_enum($idl_pkg_name, $idl_enum_name)"; |
|
|
|
|| |
|
|
|
typedef enum _«$enum_name» { |
|
|
|
``apply "item" with "enum_name", "$enum_name" |
|
|
@ -195,19 +208,25 @@ tstylesheet { |
|
|
|
|
|
|
|
template "item" { |
|
|
|
param "enum_name"; |
|
|
|
const "item_name_idl", "@name"; |
|
|
|
const "item_name", "yml:ucase(concat($enum_name, '_', $item_name_idl))"; |
|
|
|
const "idl_item_name", "@name"; |
|
|
|
const "c99_item_name", "yml:ucase(concat($enum_name, '_', $idl_item_name))"; |
|
|
|
const "idl_value", "text()"; |
|
|
|
const "c99_value", "func:enum_item_value($idl_value)"; |
|
|
|
|
|
|
|
apply "@doc", 0, mode="multiline"; |
|
|
|
| «$c99_item_name»«$c99_value»«func:autocomma()»`apply "@doc" , 0, mode="oneline"` |
|
|
|
} |
|
|
|
|
|
|
|
def "func:enum_item_value" { |
|
|
|
param "idl_value"; |
|
|
|
choose { |
|
|
|
when "@output='hex'" |
|
|
|
| «$item_name»`if "text()" { " = 0x" value "yml:dec2hex(., 2)" }`«func:autocomma()»`apply "@doc" , 0, mode="oneline"` |
|
|
|
when "string-length($idl_value) > 0" |
|
|
|
result > = «$idl_value» |
|
|
|
otherwise |
|
|
|
| «$item_name»`if "text()" { " = " value "." }``apply "@doc" , 0, mode="oneline"` |
|
|
|
result > |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// STRUCT |
|
|
|
// ------ |
|
|
|