Support generation of Cython bindings

This commit is contained in:
Vadim Petrochenkov
2020-10-03 23:36:14 +03:00
committed by Emilio Cobos Álvarez
parent a689bcabc7
commit 51405d1277
248 changed files with 6652 additions and 254 deletions
+17
View File
@@ -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
"""
+10
View File
@@ -0,0 +1,10 @@
# header = """
# #ifdef __cplusplus
# template <typename T>
# using Box = T*;
# #endif
# """
[export]
exclude = [
"Box",
]
+15
View File
@@ -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
+9
View File
@@ -0,0 +1,9 @@
header = """
DEF DEFINED = 1
DEF NOT_DEFINED = 0
"""
[defines]
"unix" = "DEFINED"
"macos" = "NOT_DEFINED"
"windows" = "NOT_DEFINED"
+5
View File
@@ -0,0 +1,5 @@
[export]
exclude = [
"XFALSE", # right hand side crashes Cython compiler
"XTRUE", # right hand side crashes Cython compiler
]
+5
View File
@@ -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
"""
View File
+2
View File
@@ -0,0 +1,2 @@
[export]
exclude = ["root_no_cython"]
+9 -2
View File
@@ -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",
]
+4
View File
@@ -0,0 +1,4 @@
[export]
exclude = [
"ManuallyDrop",
]
+4
View File
@@ -0,0 +1,4 @@
[export]
exclude = [
"MaybeUninit",
]
+9
View File
@@ -0,0 +1,9 @@
header = """
DEF FOO = 0
DEF BAR = 0
"""
[defines]
"foo" = "FOO"
"bar" = "BAR"
# "feature = foobar" = "FOOBAR"
View File
+5
View File
@@ -0,0 +1,5 @@
[export]
prefix = "PREFIX_"
exclude = [
"Y", # right hand side crashes Cython compiler
]
+8
View File
@@ -0,0 +1,8 @@
header = """
DEF DEFINE_FREEBSD = 0
"""
[parse]
parse_deps = true
[defines]
"target_os = freebsd" = "DEFINE_FREEBSD"
+9
View File
@@ -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
]