feat: Simplify Box<T> to *T for C only.
This commit is contained in:
committed by
Emilio Cobos Álvarez
parent
eefce50c6d
commit
4ce324cd2d
@@ -433,6 +433,16 @@ impl Type {
|
|||||||
is_nullable: false,
|
is_nullable: false,
|
||||||
is_ref: false,
|
is_ref: false,
|
||||||
}),
|
}),
|
||||||
|
"Box"
|
||||||
|
if config.language == Language::C && config.function.swift_name_macro.is_none() =>
|
||||||
|
{
|
||||||
|
Some(Type::Ptr {
|
||||||
|
ty: Box::new(generic),
|
||||||
|
is_const: false,
|
||||||
|
is_nullable: false,
|
||||||
|
is_ref: false,
|
||||||
|
})
|
||||||
|
}
|
||||||
"Cell" => Some(generic),
|
"Cell" => Some(generic),
|
||||||
"ManuallyDrop" | "MaybeUninit" if config.language == Language::C => Some(generic),
|
"ManuallyDrop" | "MaybeUninit" if config.language == Language::C => Some(generic),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
typedef struct NotReprC_Box_i32 NotReprC_Box_i32;
|
||||||
|
|
||||||
|
typedef NotReprC_Box_i32 Foo;
|
||||||
|
|
||||||
|
typedef struct MyStruct {
|
||||||
|
int32_t *number;
|
||||||
|
} MyStruct;
|
||||||
|
|
||||||
|
void delete(int32_t *x);
|
||||||
|
|
||||||
|
void root(const Foo *a, const MyStruct *with_box);
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
typedef struct NotReprC_Box_i32 NotReprC_Box_i32;
|
||||||
|
|
||||||
|
typedef NotReprC_Box_i32 Foo;
|
||||||
|
|
||||||
|
typedef struct MyStruct {
|
||||||
|
int32_t *number;
|
||||||
|
} MyStruct;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
void delete(int32_t *x);
|
||||||
|
|
||||||
|
void root(const Foo *a, const MyStruct *with_box);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif // __cplusplus
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
typedef struct NotReprC_Box_i32 NotReprC_Box_i32;
|
||||||
|
|
||||||
|
typedef NotReprC_Box_i32 Foo;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t *number;
|
||||||
|
} MyStruct;
|
||||||
|
|
||||||
|
void delete(int32_t *x);
|
||||||
|
|
||||||
|
void root(const Foo *a, const MyStruct *with_box);
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
typedef struct NotReprC_Box_i32 NotReprC_Box_i32;
|
||||||
|
|
||||||
|
typedef NotReprC_Box_i32 Foo;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t *number;
|
||||||
|
} MyStruct;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
void delete(int32_t *x);
|
||||||
|
|
||||||
|
void root(const Foo *a, const MyStruct *with_box);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif // __cplusplus
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
struct NotReprC_Box_i32;
|
||||||
|
|
||||||
|
typedef struct NotReprC_Box_i32 Foo;
|
||||||
|
|
||||||
|
struct MyStruct {
|
||||||
|
int32_t *number;
|
||||||
|
};
|
||||||
|
|
||||||
|
void delete(int32_t *x);
|
||||||
|
|
||||||
|
void root(const Foo *a, const struct MyStruct *with_box);
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
struct NotReprC_Box_i32;
|
||||||
|
|
||||||
|
typedef struct NotReprC_Box_i32 Foo;
|
||||||
|
|
||||||
|
struct MyStruct {
|
||||||
|
int32_t *number;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
void delete(int32_t *x);
|
||||||
|
|
||||||
|
void root(const Foo *a, const struct MyStruct *with_box);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif // __cplusplus
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#[repr(C)]
|
||||||
|
pub struct MyStruct {
|
||||||
|
number: Box<i32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct NotReprC<T> {
|
||||||
|
inner: T,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type Foo = NotReprC<Box<i32>>;
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn root(a: &Foo, with_box: &MyStruct) {}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn delete(x: Box<i32>) {}
|
||||||
Reference in New Issue
Block a user