299 Commits

Author SHA1 Message Date
Vadim Petrochenkov b82e375254 enum: Support inlined definitions for tuple variants with a single field 2020-12-09 19:38:21 +01:00
Yurii Rashkovskii 1963f0c92e Partially support #[cfg]s on fields 2020-12-06 13:10:15 +01:00
Vadim Petrochenkov dfcee869ba enum: Do not forget to rename entities in enum discriminants 2020-12-06 01:53:09 +01:00
Emilio Cobos Álvarez fbc2237b7d parser: Fix resolution of #[path] dependencies from certain modules.
We need the current mod dir to resolve #[path], not the one we get for
rust 2018.

Fixes #599
2020-11-30 19:44:45 +01:00
Vadim Petrochenkov 8997277cb7 enum: Break up Enum::write into multiple functions 2020-11-30 11:59:02 +01:00
Vadim Petrochenkov 7980288a94 Reenable some tests 2020-11-27 01:31:01 +01:00
Vadim Petrochenkov 98b7a3f9b9 cython: Leave out values of constants and enumerators
Keep them as documentation only
2020-11-27 01:31:01 +01:00
Jordan Rose 198157b53f tests: Provide a fallback for CARGO_BIN_EXE_ for earlier Rusts 2020-11-26 11:04:20 +01:00
Wodann 68a1e65875 fix: default style to Both (as specified in docs)
Closes #615.
Closes #215.

Possibly closes others.
2020-11-25 18:04:30 +01:00
Wodann 5b5b46b7d6 fix: resolve path types for 'both' style 2020-11-25 17:55:58 +01:00
Emilio Cobos Álvarez 85a2f4c956 tests: Remove unneeded test file. 2020-11-25 17:50:38 +01:00
Vadim Petrochenkov b0aae44c77 Add two Cython-specific options to the config 2020-11-25 17:33:38 +01:00
Vadim Petrochenkov 1c1d4754ce tests: Remove Cython-specific configs 2020-11-25 17:30:30 +01:00
Vadim Petrochenkov 51405d1277 Support generation of Cython bindings 2020-11-17 15:27:34 +01:00
Vadim Petrochenkov a689bcabc7 Support an annotation for generating bitfield sizes in C code (: SIZE)
Closes #609
Closes #611
2020-10-31 17:05:49 +01:00
Vadim Petrochenkov a93034c229 test suite: Normalize dashes to underscores in test names 2020-10-31 17:01:44 +01:00
Vadim Petrochenkov b69a9cfe80 Support wider range of expressions in enum discriminants 2020-10-31 16:58:37 +01:00
Jordan Rose 0ba241498e Allow controlling the Cargo profile used for macro expansion
If there's already a release build, it's better for cbindgen to reuse
the build artifacts from that to expand macros rather than starting
from scratch with a debug build. Controlled with

  --profile (debug|release)

as well as parse.expand.profile in cbindgen.toml, though hardcoding a
profile in a config file seems unlikely.
2020-10-27 11:35:10 +01:00
Vadim Petrochenkov 398b28ca30 Add an option for converting usize/isize into size_t/ptrdiff_t 2020-10-27 11:34:27 +01:00
Vadim Petrochenkov 050863a249 test suite: Remove existing duplicate expectation files 2020-10-20 22:59:14 +02:00
Vadim Petrochenkov 3a7e24d2d7 test suite: Do not generate identical expectation files 2020-10-20 22:59:14 +02:00
Vadim Petrochenkov 9f00f6fdc5 Remove artificial restriction on lifetime parameters on enums 2020-10-20 22:57:43 +02:00
Vadim Petrochenkov d09fe6b753 test suite: Use suffixes instead of directories for test variants 2020-10-19 20:33:29 +02:00
Vadim Petrochenkov aeb69bcc69 Switch default sorting order for items to "None" 2020-10-05 19:57:33 +02:00
Vadim Petrochenkov f3d5a20363 Support sort_by for constants
Also support a global default for `sort_by` affecting both functions and constants.
2020-10-05 19:57:33 +02:00
Vadim Petrochenkov 6439e6df56 Support constants with arbitrary types 2020-10-05 10:52:05 +02:00
Vadim Petrochenkov 56d0799366 Use U'...' character literals instead of L'...' character literals
On Windows `L'...'` is 16 bit, so Rust `char` won't generally fit into it.
2020-10-03 17:34:27 +02:00
Emilio Cobos Álvarez d1d97d4482 enumeration: Only propagate derive_ostream annotation if not present.
It seems reasonable to want to derive it for a variant, but want to
provide your own for the containing enum or such, for example.
2020-10-01 18:14:12 +02:00
Emilio Cobos Álvarez 36a3f8ba6e enumertion: Add a using declaration rather than qualifying all branches. 2020-10-01 18:14:12 +02:00
Kartikaya Gupta 2be47c88e6 Add support for tagged enums that turn into structs.
This happens when the tags are separated. In this case the output is slightly
different since the tag is not part of the struct body, so we need the top-level
serializer to write the tag type.
2020-10-01 12:22:51 +02:00
Kartikaya Gupta c5c17403b4 Add support for tagged enums that turn into unions. 2020-10-01 12:22:51 +02:00
Kartikaya Gupta 12149d4071 Add option for ostream serializer for structures and untagged enums
Tagged enums will be handled in later patches.
2020-10-01 12:22:51 +02:00
Kartikaya Gupta 5f6b223237 Add ostream header to all generated .cpp files.
Ideally we'd just do this when we need it, but the ostream derivation
will be controlled by both global config and per-structure config, so
it's hard to know exactly when we need it and when we don't.
2020-10-01 12:22:51 +02:00
Emilio Cobos Álvarez 1fc4cb0724 test: Ensure Option<Box<T>> reduces to *T.
Co-Authored-by: Ivan Enderlin <ivan@mnt.io>
2020-09-29 13:40:07 +02:00
Emilio Cobos Álvarez 0b9f90bb55 ty: Remove swift_macro special case. 2020-09-29 13:36:46 +02:00
Emilio Cobos Álvarez 5d1217c7c0 tests: Instead of adding skip_cpp as a feature, make the tests work with C++ 2020-09-29 13:36:46 +02:00
Ivan Enderlin 4ce324cd2d feat: Simplify Box<T> to *T for C only. 2020-09-29 13:36:46 +02:00
Ivan Enderlin eefce50c6d test: Skip CPP for the manuallydrop and maybeuninit test cases. 2020-09-29 13:36:46 +02:00
Ivan Enderlin 4304907d01 test: Support a new .skip_cpp test suffix.
Following the example of `.skip_warning_as_error`, this patch
introduces a `.skip_cpp` suffix to skip the generation of `.cpp`
files.

This patch also simplifies the code. Ideally, we would create and
implement a new trait offering an API like `is_cpp_skipped`,
`is_warning_as_error_skipped`, and `normalize` (to remove all
suffixes), but it's a little bit overkill for our needs right now.
2020-09-29 13:36:46 +02:00
Ivan Enderlin af6d2e3fbb test: test MaybeUninit as a simplified type. 2020-09-29 13:36:45 +02:00
Ivan Enderlin 79bb38abda test: Test ManuallyDrop as a simplified type. 2020-09-29 13:17:04 +02:00
Emilio Cobos Álvarez 297be51686 Refactor rename-rules to make more sense.
Option<RenameRule> doesn't make sense anywhere because there's a
RenameRule::None itself, which is also default.

This simplifies a bit the rename rules code, and removes one weird
"default-to-gecko-case" that seems snuck by.
2020-09-22 13:01:52 +02:00
Emilio Cobos Álvarez 18110669fc Add docs, move mangling configuration to its own place, add integration tests. 2020-09-22 12:54:55 +02:00
Luni-4 07c3aed03e Add ptrs-as-arrays tests 2020-09-07 20:53:09 +02:00
Tom Solberg 3ca0e75ed9 Add support for specifying line ending style (#568) 2020-08-26 15:28:17 +02:00
Emilio Cobos Álvarez d652d29ae2 ir: Be less strict when instantiating opaque types.
There are two situations where we can legitimately end up with a
different number of template params.

Fixes #532.
Fixes #527.
2020-08-15 13:40:54 +02:00
Nick Wilcox afd4a05d4e update nonnull expectations 2020-08-05 15:09:28 +02:00
Nick Wilcox 6fc7c77b0f remove duplicated code, correct test names, change config param 2020-08-05 15:09:28 +02:00
Nick Wilcox 41b7866c14 Add support for an optional attribute on pointers whose nullability can be inferred from the Rust type. 2020-08-05 15:09:28 +02:00
Emilio Cobos Álvarez 3527e0f1e3 Update expectation files 2020-07-31 16:22:48 +02:00