Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/bindgen/ir/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 15 additions & 0 deletions tests/expectations/associated_in_body.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
15 changes: 15 additions & 0 deletions tests/expectations/associated_in_body.compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions tests/expectations/associated_in_body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
15 changes: 15 additions & 0 deletions tests/expectations/bitflags.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
15 changes: 15 additions & 0 deletions tests/expectations/bitflags.compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions tests/expectations/bitflags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
15 changes: 15 additions & 0 deletions tests/expectations/both/associated_in_body.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
15 changes: 15 additions & 0 deletions tests/expectations/both/associated_in_body.compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions tests/expectations/both/bitflags.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
15 changes: 15 additions & 0 deletions tests/expectations/both/bitflags.compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions tests/expectations/both/constant.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 '\''
Expand Down
9 changes: 9 additions & 0 deletions tests/expectations/both/constant.compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 '\''
Expand Down
9 changes: 9 additions & 0 deletions tests/expectations/constant.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 '\''
Expand Down
9 changes: 9 additions & 0 deletions tests/expectations/constant.compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 '\''
Expand Down
5 changes: 5 additions & 0 deletions tests/expectations/constant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '\'';
Expand Down
15 changes: 15 additions & 0 deletions tests/expectations/tag/associated_in_body.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
15 changes: 15 additions & 0 deletions tests/expectations/tag/associated_in_body.compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading