227 Commits

Author SHA1 Message Date
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
Kartikaya Gupta
977d95b0ff Add failing scenario to test
A u32 bitflags structure should allow a 1<<31 value. However, with
current cbindgen this produces a compiler error with latest clang, because
1<<31 is treated as a signed value (-2147483648) which cannot be narrowed
back into a uint32_t without a cast.
2020-07-31 16:22:48 +02:00
Emilio Cobos Álvarez
6ba31b49f4 tests: Fix errors when testing with clang.
Fixes #554
2020-07-31 12:07:20 +02:00
Emilio Cobos Álvarez
5eae0bc07b function: Add support for wildcards in arguments.
We don't support unnamed arguments, and we give a terrible error
("Parameter has an unsupported type.") when you use them.

They're very simple to implement so we should just do it.
2020-07-25 13:50:11 +02:00
mexus
a94d6e2c9b Support "never" return type 2020-07-24 22:39:08 +02:00
Luni-4
274c9743ca Add tests 2020-07-14 16:59:54 +02:00
Hayes Neuman
bb00d1c4a8 Support renaming for constants with casts, and properly order them in the output. 2020-05-26 23:21:28 +02:00
Hayes Neuman
967c378308 Support casts in constants 2020-05-26 23:21:28 +02:00
Emilio Cobos Álvarez
b04aa7e699 parser: Introduce cbindgen:ignore comment annotation, to allow ignoring items or modules. 2020-05-15 15:43:54 +02:00
Emilio Cobos Álvarez
a05a223704 tests: Add tests for attribute annotations. 2020-05-01 00:30:40 +02:00
Luca Barbato
1a824c04f2 Add support for verbatim content after includes
Let the user add raw C code in the generated header after the include
blocks.

It matches what bindgen provides with the raw_lines option.
2020-04-22 01:50:16 +02:00
Vincent Tavernier
1ed32adafb Add Rust 2015 edition test for nested modules 2020-04-17 14:22:00 +02:00
Vincent Tavernier
60d60aaf0d Fix #254
By checking the recursion depth in the crate we are currently parsing,
we can decide on the right module directory to find submodules in. The
added `mod_2018` test fails without the changes to `parser.rs`.
2020-04-17 14:22:00 +02:00
Vincent Tavernier
ea6ea24740 Fix #381
As noted by @Benlitz, Cargo metadata supports directly specifying the
target name instead of using the `#[cfg]` syntax. We can support this by
manually creating the `syn::NestedMeta` node from the target name seen
as a string literal.
2020-04-17 14:11:06 +02:00
Igor Sadchenko
6fce1ccc4b Review fixes. Add parameter skip_warning_as_error to skip threat a warning as an error 2020-04-14 19:03:55 +02:00
Igor Sadchenko
4baadb049d Review fixes 2020-04-14 19:03:55 +02:00
Igor Sadchenko
275b36fb09 Added pragma once option. Issue #510 2020-04-14 19:03:55 +02:00
Emilio Cobos Álvarez
33d9ecf11f Handle mangling pointers.
Ugly, but better than crashing.

Closes #506.
Closes #453.
2020-04-10 15:22:16 +02:00
Emilio Cobos Álvarez
0fed9eebc4 enum: Unconditionally generate a return statement in partialeq implementations.
This fixes: https://bugzilla.mozilla.org/show_bug.cgi?id=1628754#c7
2020-04-10 15:01:41 +02:00
Emilio Cobos Álvarez
a519f1bda4 Actually use the temp dir for temporary compiled objects.
If the cbindgen_output is an absolute path, then join() will just return it.

Really fixes #499.
2020-04-04 23:46:42 +02:00
Emilio Cobos Álvarez
39bae60ad7 Generate test object files in a temporary directory instead of in-tree
Closes #499

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2020-04-04 17:54:52 +02:00
Emilio Cobos Álvarez
ec1631f3e4 Allow excluding monomorph structs in C mode.
Fixes #500.
2020-04-01 11:45:53 +02:00
Emilio Cobos Álvarez
c265a7562a parser: Don't panic when finding associated constants to a primitive.
We don't handle it, but no reason to panic.

Fixes #493
2020-03-21 17:23:02 +01:00