diff --git a/src/bindgen/ir/constant.rs b/src/bindgen/ir/constant.rs index 305c7f7..6acd295 100644 --- a/src/bindgen/ir/constant.rs +++ b/src/bindgen/ir/constant.rs @@ -563,11 +563,8 @@ impl Constant { false }; - if config.language == Language::Cython - || (config.language == Language::Cxx - && (config.constant.allow_static_const || allow_constexpr)) - { - if config.language == Language::Cxx { + match config.language { + Language::Cxx if config.constant.allow_static_const || allow_constexpr => { if allow_constexpr { out.write("constexpr ") } @@ -581,18 +578,26 @@ impl Constant { } else { out.write("const "); } - } else { - out.write("const "); - } - self.ty.write(config, out); - write!(out, " {} = ", name); - value.write(config, out); - write!(out, ";"); - } else { - write!(out, "#define {} ", name); - value.write(config, out); + self.ty.write(config, out); + write!(out, " {} = ", name); + value.write(config, out); + write!(out, ";"); + } + Language::Cxx | Language::C => { + write!(out, "#define {} ", name); + value.write(config, out); + } + Language::Cython => { + out.write("const "); + self.ty.write(config, out); + // For extern Cython declarations the initializer is ignored, + // but still useful as documentation, so we write it as a comment. + write!(out, " {} # = ", name); + value.write(config, out); + } } + condition.write_after(config, out); } } diff --git a/src/bindgen/ir/enumeration.rs b/src/bindgen/ir/enumeration.rs index 2c7d100..3727620 100644 --- a/src/bindgen/ir/enumeration.rs +++ b/src/bindgen/ir/enumeration.rs @@ -251,6 +251,11 @@ impl Source for EnumVariant { self.documentation.write(config, out); write!(out, "{}", self.export_name); if let Some(discriminant) = &self.discriminant { + if config.language == Language::Cython { + // For extern Cython declarations the enumerator value is ignored, + // but still useful as documentation, so we write it as a comment. + out.write(" #") + } out.write(" = "); discriminant.write(config, out); } diff --git a/tests/expectations/annotation.pyx b/tests/expectations/annotation.pyx index 340c7ba..e0daa81 100644 --- a/tests/expectations/annotation.pyx +++ b/tests/expectations/annotation.pyx @@ -7,7 +7,7 @@ cdef extern from *: cdef extern from *: cdef enum: - X = 2, + X # = 2, Y, ctypedef uint32_t C; diff --git a/tests/expectations/annotation.tag.pyx b/tests/expectations/annotation.tag.pyx index 801bbb2..3f7a33b 100644 --- a/tests/expectations/annotation.tag.pyx +++ b/tests/expectations/annotation.tag.pyx @@ -7,7 +7,7 @@ cdef extern from *: cdef extern from *: cdef enum: - X = 2, + X # = 2, Y, ctypedef uint32_t C; diff --git a/tests/expectations/assoc_const_conflict.pyx b/tests/expectations/assoc_const_conflict.pyx index 13c734e..f78c616 100644 --- a/tests/expectations/assoc_const_conflict.pyx +++ b/tests/expectations/assoc_const_conflict.pyx @@ -6,4 +6,4 @@ cdef extern from *: cdef extern from *: - const uint32_t Foo_FOO = 42; + const uint32_t Foo_FOO # = 42 diff --git a/tests/expectations/assoc_constant.pyx b/tests/expectations/assoc_constant.pyx index d0d7d67..51da63e 100644 --- a/tests/expectations/assoc_constant.pyx +++ b/tests/expectations/assoc_constant.pyx @@ -8,7 +8,7 @@ cdef extern from *: ctypedef struct Foo: pass - const int32_t Foo_GA = 10; - const float Foo_ZO = 3.14; + const int32_t Foo_GA # = 10 + const float Foo_ZO # = 3.14 void root(Foo x); diff --git a/tests/expectations/assoc_constant.tag.pyx b/tests/expectations/assoc_constant.tag.pyx index 98992e0..a0aed8a 100644 --- a/tests/expectations/assoc_constant.tag.pyx +++ b/tests/expectations/assoc_constant.tag.pyx @@ -8,7 +8,7 @@ cdef extern from *: cdef struct Foo: pass - const int32_t Foo_GA = 10; - const float Foo_ZO = 3.14; + const int32_t Foo_GA # = 10 + const float Foo_ZO # = 3.14 void root(Foo x); diff --git a/tests/expectations/associated_in_body.pyx b/tests/expectations/associated_in_body.pyx index 8df05e4..4444c8c 100644 --- a/tests/expectations/associated_in_body.pyx +++ b/tests/expectations/associated_in_body.pyx @@ -12,14 +12,14 @@ cdef extern from *: ctypedef struct StyleAlignFlags: uint8_t bits; # 'auto' - const StyleAlignFlags StyleAlignFlags_AUTO = { 0 }; + const StyleAlignFlags StyleAlignFlags_AUTO # = { 0 } # 'normal' - const StyleAlignFlags StyleAlignFlags_NORMAL = { 1 }; + const StyleAlignFlags StyleAlignFlags_NORMAL # = { 1 } # 'start' - const StyleAlignFlags StyleAlignFlags_START = { (1 << 1) }; + const StyleAlignFlags StyleAlignFlags_START # = { (1 << 1) } # 'end' - const StyleAlignFlags StyleAlignFlags_END = { (1 << 2) }; + const StyleAlignFlags StyleAlignFlags_END # = { (1 << 2) } # 'flex-start' - const StyleAlignFlags StyleAlignFlags_FLEX_START = { (1 << 3) }; + const StyleAlignFlags StyleAlignFlags_FLEX_START # = { (1 << 3) } void root(StyleAlignFlags flags); diff --git a/tests/expectations/associated_in_body.tag.pyx b/tests/expectations/associated_in_body.tag.pyx index e967ea7..c02e58f 100644 --- a/tests/expectations/associated_in_body.tag.pyx +++ b/tests/expectations/associated_in_body.tag.pyx @@ -12,14 +12,14 @@ cdef extern from *: cdef struct StyleAlignFlags: uint8_t bits; # 'auto' - const StyleAlignFlags StyleAlignFlags_AUTO = { 0 }; + const StyleAlignFlags StyleAlignFlags_AUTO # = { 0 } # 'normal' - const StyleAlignFlags StyleAlignFlags_NORMAL = { 1 }; + const StyleAlignFlags StyleAlignFlags_NORMAL # = { 1 } # 'start' - const StyleAlignFlags StyleAlignFlags_START = { (1 << 1) }; + const StyleAlignFlags StyleAlignFlags_START # = { (1 << 1) } # 'end' - const StyleAlignFlags StyleAlignFlags_END = { (1 << 2) }; + const StyleAlignFlags StyleAlignFlags_END # = { (1 << 2) } # 'flex-start' - const StyleAlignFlags StyleAlignFlags_FLEX_START = { (1 << 3) }; + const StyleAlignFlags StyleAlignFlags_FLEX_START # = { (1 << 3) } void root(StyleAlignFlags flags); diff --git a/tests/expectations/bitflags.pyx b/tests/expectations/bitflags.pyx index b56b250..138c99c 100644 --- a/tests/expectations/bitflags.pyx +++ b/tests/expectations/bitflags.pyx @@ -12,19 +12,19 @@ cdef extern from *: ctypedef struct AlignFlags: uint8_t bits; # 'auto' - const AlignFlags AlignFlags_AUTO = { 0 }; + const AlignFlags AlignFlags_AUTO # = { 0 } # 'normal' - const AlignFlags AlignFlags_NORMAL = { 1 }; + const AlignFlags AlignFlags_NORMAL # = { 1 } # 'start' - const AlignFlags AlignFlags_START = { (1 << 1) }; + const AlignFlags AlignFlags_START # = { (1 << 1) } # 'end' - const AlignFlags AlignFlags_END = { (1 << 2) }; + const AlignFlags AlignFlags_END # = { (1 << 2) } # 'flex-start' - const AlignFlags AlignFlags_FLEX_START = { (1 << 3) }; + const AlignFlags AlignFlags_FLEX_START # = { (1 << 3) } ctypedef struct DebugFlags: uint32_t bits; # Flag with the topmost bit set of the u32 - const DebugFlags DebugFlags_BIGGEST_ALLOWED = { (1 << 31) }; + const DebugFlags DebugFlags_BIGGEST_ALLOWED # = { (1 << 31) } void root(AlignFlags flags, DebugFlags bigger_flags); diff --git a/tests/expectations/bitflags.tag.pyx b/tests/expectations/bitflags.tag.pyx index 4e4be34..d9d205f 100644 --- a/tests/expectations/bitflags.tag.pyx +++ b/tests/expectations/bitflags.tag.pyx @@ -12,19 +12,19 @@ cdef extern from *: cdef struct AlignFlags: uint8_t bits; # 'auto' - const AlignFlags AlignFlags_AUTO = { 0 }; + const AlignFlags AlignFlags_AUTO # = { 0 } # 'normal' - const AlignFlags AlignFlags_NORMAL = { 1 }; + const AlignFlags AlignFlags_NORMAL # = { 1 } # 'start' - const AlignFlags AlignFlags_START = { (1 << 1) }; + const AlignFlags AlignFlags_START # = { (1 << 1) } # 'end' - const AlignFlags AlignFlags_END = { (1 << 2) }; + const AlignFlags AlignFlags_END # = { (1 << 2) } # 'flex-start' - const AlignFlags AlignFlags_FLEX_START = { (1 << 3) }; + const AlignFlags AlignFlags_FLEX_START # = { (1 << 3) } cdef struct DebugFlags: uint32_t bits; # Flag with the topmost bit set of the u32 - const DebugFlags DebugFlags_BIGGEST_ALLOWED = { (1 << 31) }; + const DebugFlags DebugFlags_BIGGEST_ALLOWED # = { (1 << 31) } void root(AlignFlags flags, DebugFlags bigger_flags); diff --git a/tests/expectations/cfg_2.pyx b/tests/expectations/cfg_2.pyx index c8a6e5e..92eb668 100644 --- a/tests/expectations/cfg_2.pyx +++ b/tests/expectations/cfg_2.pyx @@ -13,10 +13,10 @@ cdef extern from *: cdef extern from *: IF NOT_DEFINED: - const int32_t DEFAULT_X = 8; + const int32_t DEFAULT_X # = 8 IF DEFINED: - const int32_t DEFAULT_X = 42; + const int32_t DEFAULT_X # = 42 IF (NOT_DEFINED or DEFINED): ctypedef struct Foo: diff --git a/tests/expectations/cfg_2.tag.pyx b/tests/expectations/cfg_2.tag.pyx index 4ce0573..ea8db1e 100644 --- a/tests/expectations/cfg_2.tag.pyx +++ b/tests/expectations/cfg_2.tag.pyx @@ -13,10 +13,10 @@ cdef extern from *: cdef extern from *: IF NOT_DEFINED: - const int32_t DEFAULT_X = 8; + const int32_t DEFAULT_X # = 8 IF DEFINED: - const int32_t DEFAULT_X = 42; + const int32_t DEFAULT_X # = 42 IF (NOT_DEFINED or DEFINED): cdef struct Foo: diff --git a/tests/expectations/const_conflict.pyx b/tests/expectations/const_conflict.pyx index 13c734e..f78c616 100644 --- a/tests/expectations/const_conflict.pyx +++ b/tests/expectations/const_conflict.pyx @@ -6,4 +6,4 @@ cdef extern from *: cdef extern from *: - const uint32_t Foo_FOO = 42; + const uint32_t Foo_FOO # = 42 diff --git a/tests/expectations/const_transparent.pyx b/tests/expectations/const_transparent.pyx index d05be79..27e68d9 100644 --- a/tests/expectations/const_transparent.pyx +++ b/tests/expectations/const_transparent.pyx @@ -8,4 +8,4 @@ cdef extern from *: ctypedef uint8_t Transparent; - const Transparent FOO = 0; + const Transparent FOO # = 0 diff --git a/tests/expectations/constant.pyx b/tests/expectations/constant.pyx index 417b083..8a7e21f 100644 --- a/tests/expectations/constant.pyx +++ b/tests/expectations/constant.pyx @@ -6,46 +6,46 @@ cdef extern from *: cdef extern from *: - const int32_t FOO = 10; + const int32_t FOO # = 10 - const uint32_t DELIMITER = ':'; + const uint32_t DELIMITER # = ':' - const uint32_t LEFTCURLY = '{'; + const uint32_t LEFTCURLY # = '{' - const uint32_t QUOTE = '\''; + const uint32_t QUOTE # = '\'' - const uint32_t TAB = '\t'; + const uint32_t TAB # = '\t' - const uint32_t NEWLINE = '\n'; + const uint32_t NEWLINE # = '\n' - const uint32_t HEART = U'\U00002764'; + const uint32_t HEART # = U'\U00002764' - const uint32_t EQUID = U'\U00010083'; + const uint32_t EQUID # = U'\U00010083' - const float ZOM = 3.14; + const float ZOM # = 3.14 # A single-line doc comment. - const int8_t POS_ONE = 1; + const int8_t POS_ONE # = 1 # A # multi-line # doc # comment. - const int8_t NEG_ONE = -1; + const int8_t NEG_ONE # = -1 - const int64_t SHIFT = 3; + const int64_t SHIFT # = 3 - const int64_t XBOOL = 1; + const int64_t XBOOL # = 1 - const int64_t XFALSE1 = ((0 << 3) | 1); + const int64_t XFALSE1 # = ((0 << 3) | 1) - const int64_t XTRUE1 = (1 << (3 | 1)); + const int64_t XTRUE1 # = (1 << (3 | 1)) - const int64_t XFALSE2 = (0 << SHIFT); + const int64_t XFALSE2 # = (0 << SHIFT) - const uint8_t CAST = 'A'; + const uint8_t CAST # = 'A' - const uint32_t DOUBLE_CAST = 1; + const uint32_t DOUBLE_CAST # = 1 ctypedef struct Foo: int32_t x[FOO]; diff --git a/tests/expectations/constant.tag.pyx b/tests/expectations/constant.tag.pyx index 0557f2f..545196e 100644 --- a/tests/expectations/constant.tag.pyx +++ b/tests/expectations/constant.tag.pyx @@ -6,46 +6,46 @@ cdef extern from *: cdef extern from *: - const int32_t FOO = 10; + const int32_t FOO # = 10 - const uint32_t DELIMITER = ':'; + const uint32_t DELIMITER # = ':' - const uint32_t LEFTCURLY = '{'; + const uint32_t LEFTCURLY # = '{' - const uint32_t QUOTE = '\''; + const uint32_t QUOTE # = '\'' - const uint32_t TAB = '\t'; + const uint32_t TAB # = '\t' - const uint32_t NEWLINE = '\n'; + const uint32_t NEWLINE # = '\n' - const uint32_t HEART = U'\U00002764'; + const uint32_t HEART # = U'\U00002764' - const uint32_t EQUID = U'\U00010083'; + const uint32_t EQUID # = U'\U00010083' - const float ZOM = 3.14; + const float ZOM # = 3.14 # A single-line doc comment. - const int8_t POS_ONE = 1; + const int8_t POS_ONE # = 1 # A # multi-line # doc # comment. - const int8_t NEG_ONE = -1; + const int8_t NEG_ONE # = -1 - const int64_t SHIFT = 3; + const int64_t SHIFT # = 3 - const int64_t XBOOL = 1; + const int64_t XBOOL # = 1 - const int64_t XFALSE1 = ((0 << 3) | 1); + const int64_t XFALSE1 # = ((0 << 3) | 1) - const int64_t XTRUE1 = (1 << (3 | 1)); + const int64_t XTRUE1 # = (1 << (3 | 1)) - const int64_t XFALSE2 = (0 << SHIFT); + const int64_t XFALSE2 # = (0 << SHIFT) - const uint8_t CAST = 'A'; + const uint8_t CAST # = 'A' - const uint32_t DOUBLE_CAST = 1; + const uint32_t DOUBLE_CAST # = 1 cdef struct Foo: int32_t x[FOO]; diff --git a/tests/expectations/constant_big.pyx b/tests/expectations/constant_big.pyx index 49ba699..664199d 100644 --- a/tests/expectations/constant_big.pyx +++ b/tests/expectations/constant_big.pyx @@ -6,10 +6,10 @@ cdef extern from *: cdef extern from *: - const uint64_t UNSIGNED_NEEDS_ULL_SUFFIX = 9223372036854775808ULL; + const uint64_t UNSIGNED_NEEDS_ULL_SUFFIX # = 9223372036854775808ULL - const uint64_t UNSIGNED_DOESNT_NEED_ULL_SUFFIX = 8070450532247928832; + const uint64_t UNSIGNED_DOESNT_NEED_ULL_SUFFIX # = 8070450532247928832 - const int64_t SIGNED_NEEDS_ULL_SUFFIX = -9223372036854775808ULL; + const int64_t SIGNED_NEEDS_ULL_SUFFIX # = -9223372036854775808ULL - const int64_t SIGNED_DOESNT_NEED_ULL_SUFFIX = -9223372036854775807; + const int64_t SIGNED_DOESNT_NEED_ULL_SUFFIX # = -9223372036854775807 diff --git a/tests/expectations/constant_constexpr.pyx b/tests/expectations/constant_constexpr.pyx index f1e28bb..52d03fe 100644 --- a/tests/expectations/constant_constexpr.pyx +++ b/tests/expectations/constant_constexpr.pyx @@ -6,16 +6,16 @@ cdef extern from *: cdef extern from *: - const int64_t CONSTANT_I64 = 216; + const int64_t CONSTANT_I64 # = 216 - const float CONSTANT_FLOAT32 = 312.292; + const float CONSTANT_FLOAT32 # = 312.292 - const uint32_t DELIMITER = ':'; + const uint32_t DELIMITER # = ':' - const uint32_t LEFTCURLY = '{'; + const uint32_t LEFTCURLY # = '{' ctypedef struct Foo: int32_t x; - const int64_t Foo_CONSTANT_I64_BODY = 216; + const int64_t Foo_CONSTANT_I64_BODY # = 216 - const Foo SomeFoo = { 99 }; + const Foo SomeFoo # = { 99 } diff --git a/tests/expectations/constant_constexpr.tag.pyx b/tests/expectations/constant_constexpr.tag.pyx index 32ab3e4..0d42b0b 100644 --- a/tests/expectations/constant_constexpr.tag.pyx +++ b/tests/expectations/constant_constexpr.tag.pyx @@ -6,16 +6,16 @@ cdef extern from *: cdef extern from *: - const int64_t CONSTANT_I64 = 216; + const int64_t CONSTANT_I64 # = 216 - const float CONSTANT_FLOAT32 = 312.292; + const float CONSTANT_FLOAT32 # = 312.292 - const uint32_t DELIMITER = ':'; + const uint32_t DELIMITER # = ':' - const uint32_t LEFTCURLY = '{'; + const uint32_t LEFTCURLY # = '{' cdef struct Foo: int32_t x; - const int64_t Foo_CONSTANT_I64_BODY = 216; + const int64_t Foo_CONSTANT_I64_BODY # = 216 - const Foo SomeFoo = { 99 }; + const Foo SomeFoo # = { 99 } diff --git a/tests/expectations/constant_sort_name.pyx b/tests/expectations/constant_sort_name.pyx index 8065183..a9f4865 100644 --- a/tests/expectations/constant_sort_name.pyx +++ b/tests/expectations/constant_sort_name.pyx @@ -6,9 +6,9 @@ cdef extern from *: cdef extern from *: - const uint8_t A = 0; + const uint8_t A # = 0 - const uint8_t B = 0; + const uint8_t B # = 0 extern const uint8_t C; diff --git a/tests/expectations/constant_sort_none.pyx b/tests/expectations/constant_sort_none.pyx index 3ac9e6e..69e1a0e 100644 --- a/tests/expectations/constant_sort_none.pyx +++ b/tests/expectations/constant_sort_none.pyx @@ -6,9 +6,9 @@ cdef extern from *: cdef extern from *: - const uint8_t B = 0; + const uint8_t B # = 0 - const uint8_t A = 0; + const uint8_t A # = 0 extern const uint8_t D; diff --git a/tests/expectations/constant_user_defined_type.pyx b/tests/expectations/constant_user_defined_type.pyx index cb404fd..fc29bd2 100644 --- a/tests/expectations/constant_user_defined_type.pyx +++ b/tests/expectations/constant_user_defined_type.pyx @@ -14,8 +14,8 @@ cdef extern from *: ctypedef uint8_t A; - const S C1 = { 0 }; + const S C1 # = { 0 } - const E C2 = V; + const E C2 # = V - const A C3 = 0; + const A C3 # = 0 diff --git a/tests/expectations/constant_user_defined_type.tag.pyx b/tests/expectations/constant_user_defined_type.tag.pyx index c8b2315..bc95105 100644 --- a/tests/expectations/constant_user_defined_type.tag.pyx +++ b/tests/expectations/constant_user_defined_type.tag.pyx @@ -14,8 +14,8 @@ cdef extern from *: ctypedef uint8_t A; - const S C1 = { 0 }; + const S C1 # = { 0 } - const E C2 = V; + const E C2 # = V - const A C3 = 0; + const A C3 # = 0 diff --git a/tests/expectations/derive_ostream.pyx b/tests/expectations/derive_ostream.pyx index 388ae85..7ef7df6 100644 --- a/tests/expectations/derive_ostream.pyx +++ b/tests/expectations/derive_ostream.pyx @@ -7,7 +7,7 @@ cdef extern from *: cdef extern from *: cdef enum: - X = 2, + X # = 2, Y, ctypedef uint32_t C; diff --git a/tests/expectations/derive_ostream.tag.pyx b/tests/expectations/derive_ostream.tag.pyx index f81d035..c86d69c 100644 --- a/tests/expectations/derive_ostream.tag.pyx +++ b/tests/expectations/derive_ostream.tag.pyx @@ -7,7 +7,7 @@ cdef extern from *: cdef extern from *: cdef enum: - X = 2, + X # = 2, Y, ctypedef uint32_t C; diff --git a/tests/expectations/enum.pyx b/tests/expectations/enum.pyx index 5fe9687..ac2bf49 100644 --- a/tests/expectations/enum.pyx +++ b/tests/expectations/enum.pyx @@ -7,45 +7,45 @@ cdef extern from *: cdef extern from *: cdef enum: - a1 = 0, - a2 = 2, + a1 # = 0, + a2 # = 2, a3, - a4 = 5, + a4 # = 5, ctypedef uint64_t A; cdef enum: - b1 = 0, - b2 = 2, + b1 # = 0, + b2 # = 2, b3, - b4 = 5, + b4 # = 5, ctypedef uint32_t B; cdef enum: - c1 = 0, - c2 = 2, + c1 # = 0, + c2 # = 2, c3, - c4 = 5, + c4 # = 5, ctypedef uint16_t C; cdef enum: - d1 = 0, - d2 = 2, + d1 # = 0, + d2 # = 2, d3, - d4 = 5, + d4 # = 5, ctypedef uint8_t D; cdef enum: - e1 = 0, - e2 = 2, + e1 # = 0, + e2 # = 2, e3, - e4 = 5, + e4 # = 5, ctypedef uintptr_t E; cdef enum: - f1 = 0, - f2 = 2, + f1 # = 0, + f2 # = 2, f3, - f4 = 5, + f4 # = 5, ctypedef intptr_t F; ctypedef enum L: @@ -55,9 +55,9 @@ cdef extern from *: l4, cdef enum: - m1 = -1, - m2 = 0, - m3 = 1, + m1 # = -1, + m2 # = 0, + m3 # = 1, ctypedef int8_t M; ctypedef enum N: diff --git a/tests/expectations/enum.tag.pyx b/tests/expectations/enum.tag.pyx index 9b1bc7a..ea888a6 100644 --- a/tests/expectations/enum.tag.pyx +++ b/tests/expectations/enum.tag.pyx @@ -7,45 +7,45 @@ cdef extern from *: cdef extern from *: cdef enum: - a1 = 0, - a2 = 2, + a1 # = 0, + a2 # = 2, a3, - a4 = 5, + a4 # = 5, ctypedef uint64_t A; cdef enum: - b1 = 0, - b2 = 2, + b1 # = 0, + b2 # = 2, b3, - b4 = 5, + b4 # = 5, ctypedef uint32_t B; cdef enum: - c1 = 0, - c2 = 2, + c1 # = 0, + c2 # = 2, c3, - c4 = 5, + c4 # = 5, ctypedef uint16_t C; cdef enum: - d1 = 0, - d2 = 2, + d1 # = 0, + d2 # = 2, d3, - d4 = 5, + d4 # = 5, ctypedef uint8_t D; cdef enum: - e1 = 0, - e2 = 2, + e1 # = 0, + e2 # = 2, e3, - e4 = 5, + e4 # = 5, ctypedef uintptr_t E; cdef enum: - f1 = 0, - f2 = 2, + f1 # = 0, + f2 # = 2, f3, - f4 = 5, + f4 # = 5, ctypedef intptr_t F; cdef enum L: @@ -55,9 +55,9 @@ cdef extern from *: l4, cdef enum: - m1 = -1, - m2 = 0, - m3 = 1, + m1 # = -1, + m2 # = 0, + m3 # = 1, ctypedef int8_t M; cdef enum N: diff --git a/tests/expectations/enum_discriminant.pyx b/tests/expectations/enum_discriminant.pyx index 366b132..5837a20 100644 --- a/tests/expectations/enum_discriminant.pyx +++ b/tests/expectations/enum_discriminant.pyx @@ -6,16 +6,16 @@ cdef extern from *: cdef extern from *: - const int8_t FOUR = 4; + const int8_t FOUR # = 4 cdef enum: - A = 1, - B = -1, - C = (1 + 2), - D = FOUR, - F = 5, - G = 54, - H = False, + A # = 1, + B # = -1, + C # = (1 + 2), + D # = FOUR, + F # = 5, + G # = 54, + H # = False, ctypedef int8_t E; void root(const E*); diff --git a/tests/expectations/mod_2015.pyx b/tests/expectations/mod_2015.pyx index d6740fb..4398e5d 100644 --- a/tests/expectations/mod_2015.pyx +++ b/tests/expectations/mod_2015.pyx @@ -6,7 +6,7 @@ cdef extern from *: cdef extern from *: - const uint8_t EXPORT_ME_TOO = 42; + const uint8_t EXPORT_ME_TOO # = 42 ctypedef struct ExportMe: uint64_t val; diff --git a/tests/expectations/mod_2015.tag.pyx b/tests/expectations/mod_2015.tag.pyx index a0777cc..4838320 100644 --- a/tests/expectations/mod_2015.tag.pyx +++ b/tests/expectations/mod_2015.tag.pyx @@ -6,7 +6,7 @@ cdef extern from *: cdef extern from *: - const uint8_t EXPORT_ME_TOO = 42; + const uint8_t EXPORT_ME_TOO # = 42 cdef struct ExportMe: uint64_t val; diff --git a/tests/expectations/mod_2018.pyx b/tests/expectations/mod_2018.pyx index d6740fb..4398e5d 100644 --- a/tests/expectations/mod_2018.pyx +++ b/tests/expectations/mod_2018.pyx @@ -6,7 +6,7 @@ cdef extern from *: cdef extern from *: - const uint8_t EXPORT_ME_TOO = 42; + const uint8_t EXPORT_ME_TOO # = 42 ctypedef struct ExportMe: uint64_t val; diff --git a/tests/expectations/mod_2018.tag.pyx b/tests/expectations/mod_2018.tag.pyx index a0777cc..4838320 100644 --- a/tests/expectations/mod_2018.tag.pyx +++ b/tests/expectations/mod_2018.tag.pyx @@ -6,7 +6,7 @@ cdef extern from *: cdef extern from *: - const uint8_t EXPORT_ME_TOO = 42; + const uint8_t EXPORT_ME_TOO # = 42 cdef struct ExportMe: uint64_t val; diff --git a/tests/expectations/mod_attr.pyx b/tests/expectations/mod_attr.pyx index 39c93df..09e66fa 100644 --- a/tests/expectations/mod_attr.pyx +++ b/tests/expectations/mod_attr.pyx @@ -13,10 +13,10 @@ cdef extern from *: cdef extern from *: IF FOO: - const int32_t FOO = 1; + const int32_t FOO # = 1 IF BAR: - const int32_t BAR = 2; + const int32_t BAR # = 2 IF FOO: ctypedef struct Foo: diff --git a/tests/expectations/mod_attr.tag.pyx b/tests/expectations/mod_attr.tag.pyx index 1858836..3158396 100644 --- a/tests/expectations/mod_attr.tag.pyx +++ b/tests/expectations/mod_attr.tag.pyx @@ -13,10 +13,10 @@ cdef extern from *: cdef extern from *: IF FOO: - const int32_t FOO = 1; + const int32_t FOO # = 1 IF BAR: - const int32_t BAR = 2; + const int32_t BAR # = 2 IF FOO: cdef struct Foo: diff --git a/tests/expectations/mod_path.pyx b/tests/expectations/mod_path.pyx index d6740fb..4398e5d 100644 --- a/tests/expectations/mod_path.pyx +++ b/tests/expectations/mod_path.pyx @@ -6,7 +6,7 @@ cdef extern from *: cdef extern from *: - const uint8_t EXPORT_ME_TOO = 42; + const uint8_t EXPORT_ME_TOO # = 42 ctypedef struct ExportMe: uint64_t val; diff --git a/tests/expectations/mod_path.tag.pyx b/tests/expectations/mod_path.tag.pyx index a0777cc..4838320 100644 --- a/tests/expectations/mod_path.tag.pyx +++ b/tests/expectations/mod_path.tag.pyx @@ -6,7 +6,7 @@ cdef extern from *: cdef extern from *: - const uint8_t EXPORT_ME_TOO = 42; + const uint8_t EXPORT_ME_TOO # = 42 cdef struct ExportMe: uint64_t val; diff --git a/tests/expectations/namespace_constant.pyx b/tests/expectations/namespace_constant.pyx index f19370f..8bc3b8b 100644 --- a/tests/expectations/namespace_constant.pyx +++ b/tests/expectations/namespace_constant.pyx @@ -6,9 +6,9 @@ cdef extern from *: cdef extern from *: - const int32_t FOO = 10; + const int32_t FOO # = 10 - const float ZOM = 3.14; + const float ZOM # = 3.14 ctypedef struct Foo: int32_t x[FOO]; diff --git a/tests/expectations/namespace_constant.tag.pyx b/tests/expectations/namespace_constant.tag.pyx index af87011..8c1d8aa 100644 --- a/tests/expectations/namespace_constant.tag.pyx +++ b/tests/expectations/namespace_constant.tag.pyx @@ -6,9 +6,9 @@ cdef extern from *: cdef extern from *: - const int32_t FOO = 10; + const int32_t FOO # = 10 - const float ZOM = 3.14; + const float ZOM # = 3.14 cdef struct Foo: int32_t x[FOO]; diff --git a/tests/expectations/namespaces_constant.pyx b/tests/expectations/namespaces_constant.pyx index f19370f..8bc3b8b 100644 --- a/tests/expectations/namespaces_constant.pyx +++ b/tests/expectations/namespaces_constant.pyx @@ -6,9 +6,9 @@ cdef extern from *: cdef extern from *: - const int32_t FOO = 10; + const int32_t FOO # = 10 - const float ZOM = 3.14; + const float ZOM # = 3.14 ctypedef struct Foo: int32_t x[FOO]; diff --git a/tests/expectations/namespaces_constant.tag.pyx b/tests/expectations/namespaces_constant.tag.pyx index af87011..8c1d8aa 100644 --- a/tests/expectations/namespaces_constant.tag.pyx +++ b/tests/expectations/namespaces_constant.tag.pyx @@ -6,9 +6,9 @@ cdef extern from *: cdef extern from *: - const int32_t FOO = 10; + const int32_t FOO # = 10 - const float ZOM = 3.14; + const float ZOM # = 3.14 cdef struct Foo: int32_t x[FOO]; diff --git a/tests/expectations/prefix.pyx b/tests/expectations/prefix.pyx index a6310ab..501ae9e 100644 --- a/tests/expectations/prefix.pyx +++ b/tests/expectations/prefix.pyx @@ -6,13 +6,13 @@ cdef extern from *: cdef extern from *: - const int32_t PREFIX_LEN = 22; + const int32_t PREFIX_LEN # = 22 - const int64_t PREFIX_X = (22 << 22); + const int64_t PREFIX_X # = (22 << 22) - const int64_t PREFIX_Y1 = ((22 << 22) + (22 << 22)); + const int64_t PREFIX_Y1 # = ((22 << 22) + (22 << 22)) - const int64_t PREFIX_Y2 = PREFIX_X; + const int64_t PREFIX_Y2 # = PREFIX_X ctypedef int32_t PREFIX_NamedLenArray[PREFIX_LEN]; diff --git a/tests/expectations/prefix.tag.pyx b/tests/expectations/prefix.tag.pyx index 0579891..514cb22 100644 --- a/tests/expectations/prefix.tag.pyx +++ b/tests/expectations/prefix.tag.pyx @@ -6,13 +6,13 @@ cdef extern from *: cdef extern from *: - const int32_t PREFIX_LEN = 22; + const int32_t PREFIX_LEN # = 22 - const int64_t PREFIX_X = (22 << 22); + const int64_t PREFIX_X # = (22 << 22) - const int64_t PREFIX_Y1 = ((22 << 22) + (22 << 22)); + const int64_t PREFIX_Y1 # = ((22 << 22) + (22 << 22)) - const int64_t PREFIX_Y2 = PREFIX_X; + const int64_t PREFIX_Y2 # = PREFIX_X ctypedef int32_t PREFIX_NamedLenArray[PREFIX_LEN]; diff --git a/tests/expectations/prefixed_struct_literal.pyx b/tests/expectations/prefixed_struct_literal.pyx index 9ed4c8c..a21a082 100644 --- a/tests/expectations/prefixed_struct_literal.pyx +++ b/tests/expectations/prefixed_struct_literal.pyx @@ -9,8 +9,8 @@ cdef extern from *: ctypedef struct PREFIXFoo: int32_t a; uint32_t b; - const PREFIXFoo PREFIXFoo_FOO = { 42, 47 }; + const PREFIXFoo PREFIXFoo_FOO # = { 42, 47 } - const PREFIXFoo PREFIXBAR = { 42, 1337 }; + const PREFIXFoo PREFIXBAR # = { 42, 1337 } void root(PREFIXFoo x); diff --git a/tests/expectations/prefixed_struct_literal.tag.pyx b/tests/expectations/prefixed_struct_literal.tag.pyx index 506ca74..e2e4808 100644 --- a/tests/expectations/prefixed_struct_literal.tag.pyx +++ b/tests/expectations/prefixed_struct_literal.tag.pyx @@ -9,8 +9,8 @@ cdef extern from *: cdef struct PREFIXFoo: int32_t a; uint32_t b; - const PREFIXFoo PREFIXFoo_FOO = { 42, 47 }; + const PREFIXFoo PREFIXFoo_FOO # = { 42, 47 } - const PREFIXFoo PREFIXBAR = { 42, 1337 }; + const PREFIXFoo PREFIXBAR # = { 42, 1337 } void root(PREFIXFoo x); diff --git a/tests/expectations/prefixed_struct_literal_deep.pyx b/tests/expectations/prefixed_struct_literal_deep.pyx index aee7794..93dd89e 100644 --- a/tests/expectations/prefixed_struct_literal_deep.pyx +++ b/tests/expectations/prefixed_struct_literal_deep.pyx @@ -14,6 +14,6 @@ cdef extern from *: uint32_t b; PREFIXBar bar; - const PREFIXFoo PREFIXVAL = { 42, 1337, { 323 } }; + const PREFIXFoo PREFIXVAL # = { 42, 1337, { 323 } } void root(PREFIXFoo x); diff --git a/tests/expectations/prefixed_struct_literal_deep.tag.pyx b/tests/expectations/prefixed_struct_literal_deep.tag.pyx index a2b0be9..a29bdc4 100644 --- a/tests/expectations/prefixed_struct_literal_deep.tag.pyx +++ b/tests/expectations/prefixed_struct_literal_deep.tag.pyx @@ -14,6 +14,6 @@ cdef extern from *: uint32_t b; PREFIXBar bar; - const PREFIXFoo PREFIXVAL = { 42, 1337, { 323 } }; + const PREFIXFoo PREFIXVAL # = { 42, 1337, { 323 } } void root(PREFIXFoo x); diff --git a/tests/expectations/rename.pyx b/tests/expectations/rename.pyx index 6837861..9911089 100644 --- a/tests/expectations/rename.pyx +++ b/tests/expectations/rename.pyx @@ -6,11 +6,11 @@ cdef extern from *: cdef extern from *: - const int32_t C_H = 10; + const int32_t C_H # = 10 cdef enum: - x = 0, - y = 1, + x # = 0, + y # = 1, ctypedef uint8_t C_E; ctypedef struct C_A: @@ -29,7 +29,7 @@ cdef extern from *: ctypedef C_A C_F; - const intptr_t C_I = 10; + const intptr_t C_I # = 10 extern const int32_t G; diff --git a/tests/expectations/rename.tag.pyx b/tests/expectations/rename.tag.pyx index f477207..e9abd0f 100644 --- a/tests/expectations/rename.tag.pyx +++ b/tests/expectations/rename.tag.pyx @@ -6,11 +6,11 @@ cdef extern from *: cdef extern from *: - const int32_t C_H = 10; + const int32_t C_H # = 10 cdef enum: - x = 0, - y = 1, + x # = 0, + y # = 1, ctypedef uint8_t C_E; cdef struct C_A: @@ -29,7 +29,7 @@ cdef extern from *: ctypedef C_A C_F; - const intptr_t C_I = 10; + const intptr_t C_I # = 10 extern const int32_t G; diff --git a/tests/expectations/struct_literal.pyx b/tests/expectations/struct_literal.pyx index f354828..d612fd0 100644 --- a/tests/expectations/struct_literal.pyx +++ b/tests/expectations/struct_literal.pyx @@ -12,12 +12,12 @@ cdef extern from *: ctypedef struct Foo: int32_t a; uint32_t b; - const Foo Foo_FOO = { 42, 47 }; - const Foo Foo_FOO2 = { 42, 47 }; - const Foo Foo_FOO3 = { 42, 47 }; + const Foo Foo_FOO # = { 42, 47 } + const Foo Foo_FOO2 # = { 42, 47 } + const Foo Foo_FOO3 # = { 42, 47 } - const Foo BAR = { 42, 1337 }; + const Foo BAR # = { 42, 1337 } diff --git a/tests/expectations/struct_literal.tag.pyx b/tests/expectations/struct_literal.tag.pyx index 9aea178..9074775 100644 --- a/tests/expectations/struct_literal.tag.pyx +++ b/tests/expectations/struct_literal.tag.pyx @@ -12,12 +12,12 @@ cdef extern from *: cdef struct Foo: int32_t a; uint32_t b; - const Foo Foo_FOO = { 42, 47 }; - const Foo Foo_FOO2 = { 42, 47 }; - const Foo Foo_FOO3 = { 42, 47 }; + const Foo Foo_FOO # = { 42, 47 } + const Foo Foo_FOO2 # = { 42, 47 } + const Foo Foo_FOO3 # = { 42, 47 } - const Foo BAR = { 42, 1337 }; + const Foo BAR # = { 42, 1337 } diff --git a/tests/expectations/struct_literal_order.pyx b/tests/expectations/struct_literal_order.pyx index 63ad71c..1a9dd8b 100644 --- a/tests/expectations/struct_literal_order.pyx +++ b/tests/expectations/struct_literal_order.pyx @@ -10,16 +10,16 @@ cdef extern from *: float a; uint32_t b; uint32_t c; - const ABC ABC_abc = { 1.0, 2, 3 }; - const ABC ABC_bac = { 1.0, 2, 3 }; - const ABC ABC_cba = { 1.0, 2, 3 }; + const ABC ABC_abc # = { 1.0, 2, 3 } + const ABC ABC_bac # = { 1.0, 2, 3 } + const ABC ABC_cba # = { 1.0, 2, 3 } ctypedef struct BAC: uint32_t b; float a; int32_t c; - const BAC BAC_abc = { 1, 2.0, 3 }; - const BAC BAC_bac = { 1, 2.0, 3 }; - const BAC BAC_cba = { 1, 2.0, 3 }; + const BAC BAC_abc # = { 1, 2.0, 3 } + const BAC BAC_bac # = { 1, 2.0, 3 } + const BAC BAC_cba # = { 1, 2.0, 3 } void root(ABC a1, BAC a2); diff --git a/tests/expectations/struct_literal_order.tag.pyx b/tests/expectations/struct_literal_order.tag.pyx index 8b67697..ed2cf3e 100644 --- a/tests/expectations/struct_literal_order.tag.pyx +++ b/tests/expectations/struct_literal_order.tag.pyx @@ -10,16 +10,16 @@ cdef extern from *: float a; uint32_t b; uint32_t c; - const ABC ABC_abc = { 1.0, 2, 3 }; - const ABC ABC_bac = { 1.0, 2, 3 }; - const ABC ABC_cba = { 1.0, 2, 3 }; + const ABC ABC_abc # = { 1.0, 2, 3 } + const ABC ABC_bac # = { 1.0, 2, 3 } + const ABC ABC_cba # = { 1.0, 2, 3 } cdef struct BAC: uint32_t b; float a; int32_t c; - const BAC BAC_abc = { 1, 2.0, 3 }; - const BAC BAC_bac = { 1, 2.0, 3 }; - const BAC BAC_cba = { 1, 2.0, 3 }; + const BAC BAC_abc # = { 1, 2.0, 3 } + const BAC BAC_bac # = { 1, 2.0, 3 } + const BAC BAC_cba # = { 1, 2.0, 3 } void root(ABC a1, BAC a2); diff --git a/tests/expectations/transparent.pyx b/tests/expectations/transparent.pyx index 8a0c243..ac28206 100644 --- a/tests/expectations/transparent.pyx +++ b/tests/expectations/transparent.pyx @@ -25,10 +25,10 @@ cdef extern from *: ctypedef uint32_t TransparentPrimitiveWrapper_i32; ctypedef uint32_t TransparentPrimitiveWithAssociatedConstants; - const TransparentPrimitiveWithAssociatedConstants TransparentPrimitiveWithAssociatedConstants_ZERO = 0; - const TransparentPrimitiveWithAssociatedConstants TransparentPrimitiveWithAssociatedConstants_ONE = 1; + const TransparentPrimitiveWithAssociatedConstants TransparentPrimitiveWithAssociatedConstants_ZERO # = 0 + const TransparentPrimitiveWithAssociatedConstants TransparentPrimitiveWithAssociatedConstants_ONE # = 1 - const TransparentPrimitiveWrappingStructure EnumWithAssociatedConstantInImpl_TEN = 10; + const TransparentPrimitiveWrappingStructure EnumWithAssociatedConstantInImpl_TEN # = 10 void root(TransparentComplexWrappingStructTuple a, TransparentPrimitiveWrappingStructTuple b, diff --git a/tests/expectations/transparent.tag.pyx b/tests/expectations/transparent.tag.pyx index 1a458fd..db0f5d9 100644 --- a/tests/expectations/transparent.tag.pyx +++ b/tests/expectations/transparent.tag.pyx @@ -25,10 +25,10 @@ cdef extern from *: ctypedef uint32_t TransparentPrimitiveWrapper_i32; ctypedef uint32_t TransparentPrimitiveWithAssociatedConstants; - const TransparentPrimitiveWithAssociatedConstants TransparentPrimitiveWithAssociatedConstants_ZERO = 0; - const TransparentPrimitiveWithAssociatedConstants TransparentPrimitiveWithAssociatedConstants_ONE = 1; + const TransparentPrimitiveWithAssociatedConstants TransparentPrimitiveWithAssociatedConstants_ZERO # = 0 + const TransparentPrimitiveWithAssociatedConstants TransparentPrimitiveWithAssociatedConstants_ONE # = 1 - const TransparentPrimitiveWrappingStructure EnumWithAssociatedConstantInImpl_TEN = 10; + const TransparentPrimitiveWrappingStructure EnumWithAssociatedConstantInImpl_TEN # = 10 void root(TransparentComplexWrappingStructTuple a, TransparentPrimitiveWrappingStructTuple b, diff --git a/tests/expectations/workspace.pyx b/tests/expectations/workspace.pyx index 32d2163..f77824c 100644 --- a/tests/expectations/workspace.pyx +++ b/tests/expectations/workspace.pyx @@ -6,7 +6,7 @@ cdef extern from *: cdef extern from *: - const int32_t EXT_CONST = 0; + const int32_t EXT_CONST # = 0 ctypedef struct ExtType: uint32_t data; diff --git a/tests/expectations/workspace.tag.pyx b/tests/expectations/workspace.tag.pyx index 96a7f5c..b5d16eb 100644 --- a/tests/expectations/workspace.tag.pyx +++ b/tests/expectations/workspace.tag.pyx @@ -6,7 +6,7 @@ cdef extern from *: cdef extern from *: - const int32_t EXT_CONST = 0; + const int32_t EXT_CONST # = 0 cdef struct ExtType: uint32_t data;