unraw the identifiers

Fixes https://github.com/eqrion/cbindgen/issues/410
This commit is contained in:
Olivier Goffart
2021-12-06 22:07:54 +01:00
committed by Emilio Cobos Álvarez
parent 11228f6b6f
commit ed8d94619f
23 changed files with 297 additions and 32 deletions
+18
View File
@@ -0,0 +1,18 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
enum Enum {
a,
b,
};
typedef uint8_t Enum;
typedef struct Struct {
Enum field;
} Struct;
extern const Enum STATIC;
void fn(struct Struct arg);
@@ -0,0 +1,32 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
enum Enum
#ifdef __cplusplus
: uint8_t
#endif // __cplusplus
{
a,
b,
};
#ifndef __cplusplus
typedef uint8_t Enum;
#endif // __cplusplus
typedef struct Struct {
Enum field;
} Struct;
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
extern const Enum STATIC;
void fn(struct Struct arg);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
+18
View File
@@ -0,0 +1,18 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
enum Enum {
a,
b,
};
typedef uint8_t Enum;
typedef struct {
Enum field;
} Struct;
extern const Enum STATIC;
void fn(Struct arg);
+32
View File
@@ -0,0 +1,32 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
enum Enum
#ifdef __cplusplus
: uint8_t
#endif // __cplusplus
{
a,
b,
};
#ifndef __cplusplus
typedef uint8_t Enum;
#endif // __cplusplus
typedef struct {
Enum field;
} Struct;
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
extern const Enum STATIC;
void fn(Struct arg);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
+22
View File
@@ -0,0 +1,22 @@
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <new>
enum class Enum : uint8_t {
a,
b,
};
struct Struct {
Enum field;
};
extern "C" {
extern const Enum STATIC;
void fn(Struct arg);
} // extern "C"
+19
View File
@@ -0,0 +1,19 @@
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 *:
cdef enum:
a,
b,
ctypedef uint8_t Enum;
ctypedef struct Struct:
Enum field;
extern const Enum STATIC;
void fn(Struct arg);
+18
View File
@@ -0,0 +1,18 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
enum Enum {
a,
b,
};
typedef uint8_t Enum;
struct Struct {
Enum field;
};
extern const Enum STATIC;
void fn(struct Struct arg);
+32
View File
@@ -0,0 +1,32 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
enum Enum
#ifdef __cplusplus
: uint8_t
#endif // __cplusplus
{
a,
b,
};
#ifndef __cplusplus
typedef uint8_t Enum;
#endif // __cplusplus
struct Struct {
Enum field;
};
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
extern const Enum STATIC;
void fn(struct Struct arg);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
+19
View File
@@ -0,0 +1,19 @@
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 *:
cdef enum:
a,
b,
ctypedef uint8_t Enum;
cdef struct Struct:
Enum field;
extern const Enum STATIC;
void fn(Struct arg);
+20
View File
@@ -0,0 +1,20 @@
#[repr(u8)]
pub enum r#Enum {
r#a,
r#b,
}
#[repr(C)]
pub struct r#Struct {
r#field: r#Enum,
}
#[no_mangle]
pub extern "C" fn r#fn(r#arg: r#Struct) {
println!("Hello world");
}
pub mod r#mod {
#[no_mangle]
pub static r#STATIC: r#Enum = r#Enum::r#b;
}