Support generation of Cython bindings
This commit is contained in:
committed by
Emilio Cobos Álvarez
parent
a689bcabc7
commit
51405d1277
@@ -0,0 +1,17 @@
|
||||
[export.body]
|
||||
"MyCLikeEnum" = """
|
||||
BogusVariantForSerializationForExample,
|
||||
"""
|
||||
|
||||
"MyUnion" = """
|
||||
int32_t extra_member; # yolo
|
||||
"""
|
||||
|
||||
[export.pre_body]
|
||||
"MyCLikeEnum_Prepended" = """
|
||||
BogusVariantForSerializationForExample,
|
||||
"""
|
||||
|
||||
"MyUnion_Prepended" = """
|
||||
int32_t extra_member; # yolo
|
||||
"""
|
||||
@@ -0,0 +1,10 @@
|
||||
# header = """
|
||||
# #ifdef __cplusplus
|
||||
# template <typename T>
|
||||
# using Box = T*;
|
||||
# #endif
|
||||
# """
|
||||
[export]
|
||||
exclude = [
|
||||
"Box",
|
||||
]
|
||||
@@ -0,0 +1,15 @@
|
||||
header = """
|
||||
DEF PLATFORM_UNIX = 0
|
||||
DEF PLATFORM_WIN = 0
|
||||
DEF X11 = 0
|
||||
DEF M_32 = 0
|
||||
"""
|
||||
|
||||
[defines]
|
||||
"unix" = "PLATFORM_UNIX"
|
||||
"windows" = "PLATFORM_WIN"
|
||||
"x11" = "X11"
|
||||
"target_pointer_width = 32" = "M_32"
|
||||
|
||||
[export]
|
||||
exclude = ["C"] # conditional compilation is not supported for enumerators
|
||||
@@ -0,0 +1,9 @@
|
||||
header = """
|
||||
DEF DEFINED = 1
|
||||
DEF NOT_DEFINED = 0
|
||||
"""
|
||||
|
||||
[defines]
|
||||
"unix" = "DEFINED"
|
||||
"macos" = "NOT_DEFINED"
|
||||
"windows" = "NOT_DEFINED"
|
||||
@@ -0,0 +1,5 @@
|
||||
[export]
|
||||
exclude = [
|
||||
"XFALSE", # right hand side crashes Cython compiler
|
||||
"XTRUE", # right hand side crashes Cython compiler
|
||||
]
|
||||
@@ -0,0 +1,5 @@
|
||||
no_includes = true
|
||||
header = "# This file is generated by cbindgen. DO NOT EDIT"
|
||||
trailer = """
|
||||
# This is a simple test to ensure that trailers don't cause extra newlines in files
|
||||
"""
|
||||
@@ -0,0 +1,2 @@
|
||||
[export]
|
||||
exclude = ["root_no_cython"]
|
||||
@@ -7,9 +7,16 @@ enum E {
|
||||
C = 1 + 2,
|
||||
D = FOUR,
|
||||
F = (5),
|
||||
G = '6' as i8,
|
||||
H = false as i8,
|
||||
}
|
||||
|
||||
#[repr(i8)]
|
||||
enum E_NoCython {
|
||||
G = '6' as i8, // Not supported
|
||||
H = false as i8, // Not supported
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn root(_: &E) {}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn root_no_cython(_: &E_NoCython) {}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
header = """
|
||||
from libc.stdint cimport uint64_t
|
||||
ctypedef uint64_t Option_Foo
|
||||
"""
|
||||
|
||||
[export]
|
||||
exclude = [
|
||||
"Option_Foo",
|
||||
]
|
||||
@@ -0,0 +1,4 @@
|
||||
[export]
|
||||
exclude = [
|
||||
"ManuallyDrop",
|
||||
]
|
||||
@@ -0,0 +1,4 @@
|
||||
[export]
|
||||
exclude = [
|
||||
"MaybeUninit",
|
||||
]
|
||||
@@ -0,0 +1,9 @@
|
||||
header = """
|
||||
DEF FOO = 0
|
||||
DEF BAR = 0
|
||||
"""
|
||||
|
||||
[defines]
|
||||
"foo" = "FOO"
|
||||
"bar" = "BAR"
|
||||
# "feature = foobar" = "FOOBAR"
|
||||
@@ -0,0 +1,5 @@
|
||||
[export]
|
||||
prefix = "PREFIX_"
|
||||
exclude = [
|
||||
"Y", # right hand side crashes Cython compiler
|
||||
]
|
||||
@@ -0,0 +1,8 @@
|
||||
header = """
|
||||
DEF DEFINE_FREEBSD = 0
|
||||
"""
|
||||
|
||||
[parse]
|
||||
parse_deps = true
|
||||
[defines]
|
||||
"target_os = freebsd" = "DEFINE_FREEBSD"
|
||||
@@ -0,0 +1,9 @@
|
||||
header = "#define CF_SWIFT_NAME(_name) __attribute__((swift_name(#_name)))"
|
||||
|
||||
[fn]
|
||||
swift_name_macro = "CF_SWIFT_NAME"
|
||||
|
||||
[export]
|
||||
exclude = [
|
||||
"PointerToOpaque_sayHello", # has postfix with a C-style comment incompatible with Cython
|
||||
]
|
||||
Reference in New Issue
Block a user