tests: Add a test for struct constants going through typedefs.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FONT_WEIGHT_FRACTION_BITS 6
|
||||
|
||||
typedef struct FixedPoint_FONT_WEIGHT_FRACTION_BITS {
|
||||
uint16_t value;
|
||||
} FixedPoint_FONT_WEIGHT_FRACTION_BITS;
|
||||
|
||||
typedef struct FixedPoint_FONT_WEIGHT_FRACTION_BITS FontWeightFixedPoint;
|
||||
|
||||
typedef struct FontWeight {
|
||||
FontWeightFixedPoint _0;
|
||||
} FontWeight;
|
||||
#define FontWeight_NORMAL (FontWeight){ ._0 = (FontWeightFixedPoint){ .value = (400 << FONT_WEIGHT_FRACTION_BITS) } }
|
||||
|
||||
void root(struct FontWeight w);
|
||||
@@ -0,0 +1,27 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FONT_WEIGHT_FRACTION_BITS 6
|
||||
|
||||
typedef struct FixedPoint_FONT_WEIGHT_FRACTION_BITS {
|
||||
uint16_t value;
|
||||
} FixedPoint_FONT_WEIGHT_FRACTION_BITS;
|
||||
|
||||
typedef struct FixedPoint_FONT_WEIGHT_FRACTION_BITS FontWeightFixedPoint;
|
||||
|
||||
typedef struct FontWeight {
|
||||
FontWeightFixedPoint _0;
|
||||
} FontWeight;
|
||||
#define FontWeight_NORMAL (FontWeight){ ._0 = (FontWeightFixedPoint){ .value = (400 << FONT_WEIGHT_FRACTION_BITS) } }
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
void root(struct FontWeight w);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
@@ -0,0 +1,19 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FONT_WEIGHT_FRACTION_BITS 6
|
||||
|
||||
typedef struct {
|
||||
uint16_t value;
|
||||
} FixedPoint_FONT_WEIGHT_FRACTION_BITS;
|
||||
|
||||
typedef FixedPoint_FONT_WEIGHT_FRACTION_BITS FontWeightFixedPoint;
|
||||
|
||||
typedef struct {
|
||||
FontWeightFixedPoint _0;
|
||||
} FontWeight;
|
||||
#define FontWeight_NORMAL (FontWeight){ ._0 = (FontWeightFixedPoint){ .value = (400 << FONT_WEIGHT_FRACTION_BITS) } }
|
||||
|
||||
void root(FontWeight w);
|
||||
@@ -0,0 +1,27 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FONT_WEIGHT_FRACTION_BITS 6
|
||||
|
||||
typedef struct {
|
||||
uint16_t value;
|
||||
} FixedPoint_FONT_WEIGHT_FRACTION_BITS;
|
||||
|
||||
typedef FixedPoint_FONT_WEIGHT_FRACTION_BITS FontWeightFixedPoint;
|
||||
|
||||
typedef struct {
|
||||
FontWeightFixedPoint _0;
|
||||
} FontWeight;
|
||||
#define FontWeight_NORMAL (FontWeight){ ._0 = (FontWeightFixedPoint){ .value = (400 << FONT_WEIGHT_FRACTION_BITS) } }
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
void root(FontWeight w);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
@@ -0,0 +1,25 @@
|
||||
#include <cstdarg>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <ostream>
|
||||
#include <new>
|
||||
|
||||
constexpr static const uint16_t FONT_WEIGHT_FRACTION_BITS = 6;
|
||||
|
||||
template<uint16_t FRACTION_BITS>
|
||||
struct FixedPoint {
|
||||
uint16_t value;
|
||||
};
|
||||
|
||||
using FontWeightFixedPoint = FixedPoint<FONT_WEIGHT_FRACTION_BITS>;
|
||||
|
||||
struct FontWeight {
|
||||
FontWeightFixedPoint _0;
|
||||
};
|
||||
constexpr static const FontWeight FontWeight_NORMAL = FontWeight{ /* ._0 = */ FontWeightFixedPoint{ /* .value = */ (400 << FONT_WEIGHT_FRACTION_BITS) } };
|
||||
|
||||
extern "C" {
|
||||
|
||||
void root(FontWeight w);
|
||||
|
||||
} // extern "C"
|
||||
@@ -0,0 +1,20 @@
|
||||
from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t
|
||||
from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t
|
||||
cdef extern from *:
|
||||
ctypedef bint bool
|
||||
ctypedef struct va_list
|
||||
|
||||
cdef extern from *:
|
||||
|
||||
const uint16_t FONT_WEIGHT_FRACTION_BITS # = 6
|
||||
|
||||
ctypedef struct FixedPoint_FONT_WEIGHT_FRACTION_BITS:
|
||||
uint16_t value;
|
||||
|
||||
ctypedef FixedPoint_FONT_WEIGHT_FRACTION_BITS FontWeightFixedPoint;
|
||||
|
||||
ctypedef struct FontWeight:
|
||||
FontWeightFixedPoint _0;
|
||||
const FontWeight FontWeight_NORMAL # = <FontWeight>{ <FontWeightFixedPoint>{ (400 << FONT_WEIGHT_FRACTION_BITS) } }
|
||||
|
||||
void root(FontWeight w);
|
||||
@@ -0,0 +1,19 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FONT_WEIGHT_FRACTION_BITS 6
|
||||
|
||||
struct FixedPoint_FONT_WEIGHT_FRACTION_BITS {
|
||||
uint16_t value;
|
||||
};
|
||||
|
||||
typedef struct FixedPoint_FONT_WEIGHT_FRACTION_BITS FontWeightFixedPoint;
|
||||
|
||||
struct FontWeight {
|
||||
FontWeightFixedPoint _0;
|
||||
};
|
||||
#define FontWeight_NORMAL (FontWeight){ ._0 = (FontWeightFixedPoint){ .value = (400 << FONT_WEIGHT_FRACTION_BITS) } }
|
||||
|
||||
void root(struct FontWeight w);
|
||||
@@ -0,0 +1,27 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FONT_WEIGHT_FRACTION_BITS 6
|
||||
|
||||
struct FixedPoint_FONT_WEIGHT_FRACTION_BITS {
|
||||
uint16_t value;
|
||||
};
|
||||
|
||||
typedef struct FixedPoint_FONT_WEIGHT_FRACTION_BITS FontWeightFixedPoint;
|
||||
|
||||
struct FontWeight {
|
||||
FontWeightFixedPoint _0;
|
||||
};
|
||||
#define FontWeight_NORMAL (FontWeight){ ._0 = (FontWeightFixedPoint){ .value = (400 << FONT_WEIGHT_FRACTION_BITS) } }
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
void root(struct FontWeight w);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
@@ -0,0 +1,20 @@
|
||||
from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t
|
||||
from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t
|
||||
cdef extern from *:
|
||||
ctypedef bint bool
|
||||
ctypedef struct va_list
|
||||
|
||||
cdef extern from *:
|
||||
|
||||
const uint16_t FONT_WEIGHT_FRACTION_BITS # = 6
|
||||
|
||||
cdef struct FixedPoint_FONT_WEIGHT_FRACTION_BITS:
|
||||
uint16_t value;
|
||||
|
||||
ctypedef FixedPoint_FONT_WEIGHT_FRACTION_BITS FontWeightFixedPoint;
|
||||
|
||||
cdef struct FontWeight:
|
||||
FontWeightFixedPoint _0;
|
||||
const FontWeight FontWeight_NORMAL # = <FontWeight>{ <FontWeightFixedPoint>{ (400 << FONT_WEIGHT_FRACTION_BITS) } }
|
||||
|
||||
void root(FontWeight w);
|
||||
@@ -0,0 +1,18 @@
|
||||
#[repr(C)]
|
||||
pub struct FixedPoint<const FRACTION_BITS: u16> {
|
||||
value: u16,
|
||||
}
|
||||
|
||||
pub const FONT_WEIGHT_FRACTION_BITS: u16 = 6;
|
||||
|
||||
pub type FontWeightFixedPoint = FixedPoint<FONT_WEIGHT_FRACTION_BITS>;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct FontWeight(FontWeightFixedPoint);
|
||||
|
||||
impl FontWeight {
|
||||
pub const NORMAL: FontWeight = FontWeight(FontWeightFixedPoint { value: 400 << FONT_WEIGHT_FRACTION_BITS });
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn root(w: FontWeight) {}
|
||||
Reference in New Issue
Block a user