diff --git a/src/bindgen/ir/constant.rs b/src/bindgen/ir/constant.rs index 7b826a69e..8542cd2c4 100644 --- a/src/bindgen/ir/constant.rs +++ b/src/bindgen/ir/constant.rs @@ -489,6 +489,8 @@ impl Constant { _ => &self.value, }; + self.documentation.write(config, out); + if config.constant.allow_static_const && config.language == Language::Cxx { out.write(if in_body { "inline " } else { "static " }); if let Type::ConstPtr(..) = self.ty { diff --git a/tests/expectations/associated_in_body.c b/tests/expectations/associated_in_body.c index dc2444cbc..da6fe27df 100644 --- a/tests/expectations/associated_in_body.c +++ b/tests/expectations/associated_in_body.c @@ -11,10 +11,25 @@ typedef struct { uint8_t bits; } StyleAlignFlags; +/** + * 'auto' + */ #define StyleAlignFlags_AUTO (StyleAlignFlags){ .bits = 0 } +/** + * 'normal' + */ #define StyleAlignFlags_NORMAL (StyleAlignFlags){ .bits = 1 } +/** + * 'start' + */ #define StyleAlignFlags_START (StyleAlignFlags){ .bits = (1 << 1) } +/** + * 'end' + */ #define StyleAlignFlags_END (StyleAlignFlags){ .bits = (1 << 2) } +/** + * 'flex-start' + */ #define StyleAlignFlags_FLEX_START (StyleAlignFlags){ .bits = (1 << 3) } void root(StyleAlignFlags flags); diff --git a/tests/expectations/associated_in_body.compat.c b/tests/expectations/associated_in_body.compat.c index e2f8990d9..b032a5938 100644 --- a/tests/expectations/associated_in_body.compat.c +++ b/tests/expectations/associated_in_body.compat.c @@ -11,10 +11,25 @@ typedef struct { uint8_t bits; } StyleAlignFlags; +/** + * 'auto' + */ #define StyleAlignFlags_AUTO (StyleAlignFlags){ .bits = 0 } +/** + * 'normal' + */ #define StyleAlignFlags_NORMAL (StyleAlignFlags){ .bits = 1 } +/** + * 'start' + */ #define StyleAlignFlags_START (StyleAlignFlags){ .bits = (1 << 1) } +/** + * 'end' + */ #define StyleAlignFlags_END (StyleAlignFlags){ .bits = (1 << 2) } +/** + * 'flex-start' + */ #define StyleAlignFlags_FLEX_START (StyleAlignFlags){ .bits = (1 << 3) } #ifdef __cplusplus diff --git a/tests/expectations/associated_in_body.cpp b/tests/expectations/associated_in_body.cpp index db4596dcf..713f06e03 100644 --- a/tests/expectations/associated_in_body.cpp +++ b/tests/expectations/associated_in_body.cpp @@ -42,10 +42,15 @@ struct StyleAlignFlags { static const StyleAlignFlags END; static const StyleAlignFlags FLEX_START; }; +/// 'auto' inline const StyleAlignFlags StyleAlignFlags::AUTO = StyleAlignFlags{ /* .bits = */ 0 }; +/// 'normal' inline const StyleAlignFlags StyleAlignFlags::NORMAL = StyleAlignFlags{ /* .bits = */ 1 }; +/// 'start' inline const StyleAlignFlags StyleAlignFlags::START = StyleAlignFlags{ /* .bits = */ (1 << 1) }; +/// 'end' inline const StyleAlignFlags StyleAlignFlags::END = StyleAlignFlags{ /* .bits = */ (1 << 2) }; +/// 'flex-start' inline const StyleAlignFlags StyleAlignFlags::FLEX_START = StyleAlignFlags{ /* .bits = */ (1 << 3) }; extern "C" { diff --git a/tests/expectations/bitflags.c b/tests/expectations/bitflags.c index 46e3f73eb..84a215824 100644 --- a/tests/expectations/bitflags.c +++ b/tests/expectations/bitflags.c @@ -11,10 +11,25 @@ typedef struct { uint8_t bits; } AlignFlags; +/** + * 'auto' + */ #define AlignFlags_AUTO (AlignFlags){ .bits = 0 } +/** + * 'normal' + */ #define AlignFlags_NORMAL (AlignFlags){ .bits = 1 } +/** + * 'start' + */ #define AlignFlags_START (AlignFlags){ .bits = (1 << 1) } +/** + * 'end' + */ #define AlignFlags_END (AlignFlags){ .bits = (1 << 2) } +/** + * 'flex-start' + */ #define AlignFlags_FLEX_START (AlignFlags){ .bits = (1 << 3) } void root(AlignFlags flags); diff --git a/tests/expectations/bitflags.compat.c b/tests/expectations/bitflags.compat.c index 8f6a27cc3..6a31e43de 100644 --- a/tests/expectations/bitflags.compat.c +++ b/tests/expectations/bitflags.compat.c @@ -11,10 +11,25 @@ typedef struct { uint8_t bits; } AlignFlags; +/** + * 'auto' + */ #define AlignFlags_AUTO (AlignFlags){ .bits = 0 } +/** + * 'normal' + */ #define AlignFlags_NORMAL (AlignFlags){ .bits = 1 } +/** + * 'start' + */ #define AlignFlags_START (AlignFlags){ .bits = (1 << 1) } +/** + * 'end' + */ #define AlignFlags_END (AlignFlags){ .bits = (1 << 2) } +/** + * 'flex-start' + */ #define AlignFlags_FLEX_START (AlignFlags){ .bits = (1 << 3) } #ifdef __cplusplus diff --git a/tests/expectations/bitflags.cpp b/tests/expectations/bitflags.cpp index 16c9fb9fd..cb350cb18 100644 --- a/tests/expectations/bitflags.cpp +++ b/tests/expectations/bitflags.cpp @@ -37,10 +37,15 @@ struct AlignFlags { return *this; } }; +/// 'auto' static const AlignFlags AlignFlags_AUTO = AlignFlags{ /* .bits = */ 0 }; +/// 'normal' static const AlignFlags AlignFlags_NORMAL = AlignFlags{ /* .bits = */ 1 }; +/// 'start' static const AlignFlags AlignFlags_START = AlignFlags{ /* .bits = */ (1 << 1) }; +/// 'end' static const AlignFlags AlignFlags_END = AlignFlags{ /* .bits = */ (1 << 2) }; +/// 'flex-start' static const AlignFlags AlignFlags_FLEX_START = AlignFlags{ /* .bits = */ (1 << 3) }; extern "C" { diff --git a/tests/expectations/both/associated_in_body.c b/tests/expectations/both/associated_in_body.c index ea3c060c4..53b08359f 100644 --- a/tests/expectations/both/associated_in_body.c +++ b/tests/expectations/both/associated_in_body.c @@ -11,10 +11,25 @@ typedef struct StyleAlignFlags { uint8_t bits; } StyleAlignFlags; +/** + * 'auto' + */ #define StyleAlignFlags_AUTO (StyleAlignFlags){ .bits = 0 } +/** + * 'normal' + */ #define StyleAlignFlags_NORMAL (StyleAlignFlags){ .bits = 1 } +/** + * 'start' + */ #define StyleAlignFlags_START (StyleAlignFlags){ .bits = (1 << 1) } +/** + * 'end' + */ #define StyleAlignFlags_END (StyleAlignFlags){ .bits = (1 << 2) } +/** + * 'flex-start' + */ #define StyleAlignFlags_FLEX_START (StyleAlignFlags){ .bits = (1 << 3) } void root(StyleAlignFlags flags); diff --git a/tests/expectations/both/associated_in_body.compat.c b/tests/expectations/both/associated_in_body.compat.c index cf78144b8..ce77124e7 100644 --- a/tests/expectations/both/associated_in_body.compat.c +++ b/tests/expectations/both/associated_in_body.compat.c @@ -11,10 +11,25 @@ typedef struct StyleAlignFlags { uint8_t bits; } StyleAlignFlags; +/** + * 'auto' + */ #define StyleAlignFlags_AUTO (StyleAlignFlags){ .bits = 0 } +/** + * 'normal' + */ #define StyleAlignFlags_NORMAL (StyleAlignFlags){ .bits = 1 } +/** + * 'start' + */ #define StyleAlignFlags_START (StyleAlignFlags){ .bits = (1 << 1) } +/** + * 'end' + */ #define StyleAlignFlags_END (StyleAlignFlags){ .bits = (1 << 2) } +/** + * 'flex-start' + */ #define StyleAlignFlags_FLEX_START (StyleAlignFlags){ .bits = (1 << 3) } #ifdef __cplusplus diff --git a/tests/expectations/both/bitflags.c b/tests/expectations/both/bitflags.c index dff9ea6db..d905454f8 100644 --- a/tests/expectations/both/bitflags.c +++ b/tests/expectations/both/bitflags.c @@ -11,10 +11,25 @@ typedef struct AlignFlags { uint8_t bits; } AlignFlags; +/** + * 'auto' + */ #define AlignFlags_AUTO (AlignFlags){ .bits = 0 } +/** + * 'normal' + */ #define AlignFlags_NORMAL (AlignFlags){ .bits = 1 } +/** + * 'start' + */ #define AlignFlags_START (AlignFlags){ .bits = (1 << 1) } +/** + * 'end' + */ #define AlignFlags_END (AlignFlags){ .bits = (1 << 2) } +/** + * 'flex-start' + */ #define AlignFlags_FLEX_START (AlignFlags){ .bits = (1 << 3) } void root(AlignFlags flags); diff --git a/tests/expectations/both/bitflags.compat.c b/tests/expectations/both/bitflags.compat.c index ab8643cff..bbd9d1500 100644 --- a/tests/expectations/both/bitflags.compat.c +++ b/tests/expectations/both/bitflags.compat.c @@ -11,10 +11,25 @@ typedef struct AlignFlags { uint8_t bits; } AlignFlags; +/** + * 'auto' + */ #define AlignFlags_AUTO (AlignFlags){ .bits = 0 } +/** + * 'normal' + */ #define AlignFlags_NORMAL (AlignFlags){ .bits = 1 } +/** + * 'start' + */ #define AlignFlags_START (AlignFlags){ .bits = (1 << 1) } +/** + * 'end' + */ #define AlignFlags_END (AlignFlags){ .bits = (1 << 2) } +/** + * 'flex-start' + */ #define AlignFlags_FLEX_START (AlignFlags){ .bits = (1 << 3) } #ifdef __cplusplus diff --git a/tests/expectations/both/constant.c b/tests/expectations/both/constant.c index 66cb9faae..b5045b992 100644 --- a/tests/expectations/both/constant.c +++ b/tests/expectations/both/constant.c @@ -13,10 +13,19 @@ #define LEFTCURLY '{' +/** + * A + * multi-line + * doc + * comment. + */ #define NEG_ONE -1 #define NEWLINE '\n' +/** + * A single-line doc comment. + */ #define POS_ONE 1 #define QUOTE '\'' diff --git a/tests/expectations/both/constant.compat.c b/tests/expectations/both/constant.compat.c index 2e457bc4a..8dd0dfec4 100644 --- a/tests/expectations/both/constant.compat.c +++ b/tests/expectations/both/constant.compat.c @@ -13,10 +13,19 @@ #define LEFTCURLY '{' +/** + * A + * multi-line + * doc + * comment. + */ #define NEG_ONE -1 #define NEWLINE '\n' +/** + * A single-line doc comment. + */ #define POS_ONE 1 #define QUOTE '\'' diff --git a/tests/expectations/constant.c b/tests/expectations/constant.c index 9ce9438a0..0ba126db1 100644 --- a/tests/expectations/constant.c +++ b/tests/expectations/constant.c @@ -13,10 +13,19 @@ #define LEFTCURLY '{' +/** + * A + * multi-line + * doc + * comment. + */ #define NEG_ONE -1 #define NEWLINE '\n' +/** + * A single-line doc comment. + */ #define POS_ONE 1 #define QUOTE '\'' diff --git a/tests/expectations/constant.compat.c b/tests/expectations/constant.compat.c index b8e71cdc5..13e17c43e 100644 --- a/tests/expectations/constant.compat.c +++ b/tests/expectations/constant.compat.c @@ -13,10 +13,19 @@ #define LEFTCURLY '{' +/** + * A + * multi-line + * doc + * comment. + */ #define NEG_ONE -1 #define NEWLINE '\n' +/** + * A single-line doc comment. + */ #define POS_ONE 1 #define QUOTE '\'' diff --git a/tests/expectations/constant.cpp b/tests/expectations/constant.cpp index 238384644..6bee53b6b 100644 --- a/tests/expectations/constant.cpp +++ b/tests/expectations/constant.cpp @@ -13,10 +13,15 @@ static const uint32_t HEART = L'\U00002764'; static const uint32_t LEFTCURLY = '{'; +/// A +/// multi-line +/// doc +/// comment. static const int8_t NEG_ONE = -1; static const uint32_t NEWLINE = '\n'; +/// A single-line doc comment. static const int8_t POS_ONE = 1; static const uint32_t QUOTE = '\''; diff --git a/tests/expectations/tag/associated_in_body.c b/tests/expectations/tag/associated_in_body.c index f8ccc5791..8aacc685c 100644 --- a/tests/expectations/tag/associated_in_body.c +++ b/tests/expectations/tag/associated_in_body.c @@ -11,10 +11,25 @@ struct StyleAlignFlags { uint8_t bits; }; +/** + * 'auto' + */ #define StyleAlignFlags_AUTO (StyleAlignFlags){ .bits = 0 } +/** + * 'normal' + */ #define StyleAlignFlags_NORMAL (StyleAlignFlags){ .bits = 1 } +/** + * 'start' + */ #define StyleAlignFlags_START (StyleAlignFlags){ .bits = (1 << 1) } +/** + * 'end' + */ #define StyleAlignFlags_END (StyleAlignFlags){ .bits = (1 << 2) } +/** + * 'flex-start' + */ #define StyleAlignFlags_FLEX_START (StyleAlignFlags){ .bits = (1 << 3) } void root(struct StyleAlignFlags flags); diff --git a/tests/expectations/tag/associated_in_body.compat.c b/tests/expectations/tag/associated_in_body.compat.c index 22f6cbd8c..5f4cdd634 100644 --- a/tests/expectations/tag/associated_in_body.compat.c +++ b/tests/expectations/tag/associated_in_body.compat.c @@ -11,10 +11,25 @@ struct StyleAlignFlags { uint8_t bits; }; +/** + * 'auto' + */ #define StyleAlignFlags_AUTO (StyleAlignFlags){ .bits = 0 } +/** + * 'normal' + */ #define StyleAlignFlags_NORMAL (StyleAlignFlags){ .bits = 1 } +/** + * 'start' + */ #define StyleAlignFlags_START (StyleAlignFlags){ .bits = (1 << 1) } +/** + * 'end' + */ #define StyleAlignFlags_END (StyleAlignFlags){ .bits = (1 << 2) } +/** + * 'flex-start' + */ #define StyleAlignFlags_FLEX_START (StyleAlignFlags){ .bits = (1 << 3) } #ifdef __cplusplus diff --git a/tests/expectations/tag/bitflags.c b/tests/expectations/tag/bitflags.c index 2c26bdddd..9a35d3d8e 100644 --- a/tests/expectations/tag/bitflags.c +++ b/tests/expectations/tag/bitflags.c @@ -11,10 +11,25 @@ struct AlignFlags { uint8_t bits; }; +/** + * 'auto' + */ #define AlignFlags_AUTO (AlignFlags){ .bits = 0 } +/** + * 'normal' + */ #define AlignFlags_NORMAL (AlignFlags){ .bits = 1 } +/** + * 'start' + */ #define AlignFlags_START (AlignFlags){ .bits = (1 << 1) } +/** + * 'end' + */ #define AlignFlags_END (AlignFlags){ .bits = (1 << 2) } +/** + * 'flex-start' + */ #define AlignFlags_FLEX_START (AlignFlags){ .bits = (1 << 3) } void root(struct AlignFlags flags); diff --git a/tests/expectations/tag/bitflags.compat.c b/tests/expectations/tag/bitflags.compat.c index 3b35e5950..e7cb2a04c 100644 --- a/tests/expectations/tag/bitflags.compat.c +++ b/tests/expectations/tag/bitflags.compat.c @@ -11,10 +11,25 @@ struct AlignFlags { uint8_t bits; }; +/** + * 'auto' + */ #define AlignFlags_AUTO (AlignFlags){ .bits = 0 } +/** + * 'normal' + */ #define AlignFlags_NORMAL (AlignFlags){ .bits = 1 } +/** + * 'start' + */ #define AlignFlags_START (AlignFlags){ .bits = (1 << 1) } +/** + * 'end' + */ #define AlignFlags_END (AlignFlags){ .bits = (1 << 2) } +/** + * 'flex-start' + */ #define AlignFlags_FLEX_START (AlignFlags){ .bits = (1 << 3) } #ifdef __cplusplus diff --git a/tests/expectations/tag/constant.c b/tests/expectations/tag/constant.c index 01b1537f4..abfa08838 100644 --- a/tests/expectations/tag/constant.c +++ b/tests/expectations/tag/constant.c @@ -13,10 +13,19 @@ #define LEFTCURLY '{' +/** + * A + * multi-line + * doc + * comment. + */ #define NEG_ONE -1 #define NEWLINE '\n' +/** + * A single-line doc comment. + */ #define POS_ONE 1 #define QUOTE '\'' diff --git a/tests/expectations/tag/constant.compat.c b/tests/expectations/tag/constant.compat.c index 7df997fa6..4275dcaa8 100644 --- a/tests/expectations/tag/constant.compat.c +++ b/tests/expectations/tag/constant.compat.c @@ -13,10 +13,19 @@ #define LEFTCURLY '{' +/** + * A + * multi-line + * doc + * comment. + */ #define NEG_ONE -1 #define NEWLINE '\n' +/** + * A single-line doc comment. + */ #define POS_ONE 1 #define QUOTE '\'' diff --git a/tests/rust/constant.rs b/tests/rust/constant.rs index 1f483cd4a..1c59a50ff 100644 --- a/tests/rust/constant.rs +++ b/tests/rust/constant.rs @@ -12,7 +12,12 @@ pub const ZOM: f32 = 3.14; pub(crate) const DONT_EXPORT_CRATE: i32 = 20; const DONT_EXPORT_PRIV: i32 = 30; +/// A single-line doc comment. pub const POS_ONE: i8 = 1; +/// A +/// multi-line +/// doc +/// comment. pub const NEG_ONE: i8 = -1; // Some doc for shifting //