678 Commits

Author SHA1 Message Date
Emilio Cobos Álvarez
b30bb837c2
Add missing changelog for v0.10.0.
* Initialize struct literal with list-initializer for C++11 standard (#401)
 * Surround namespace with __cplusplus ifdef in cpp_compat mode
 * Add support for --quiet flag
 * Map char to char32_t
 * Improve binding_crate_ref() error message
 * avoid prematurely returning during expansion
 * Add support for adding "using namespace" statements
2019-12-03 00:46:30 +01:00
Adrian Wong
8a7fbbe1ff Add test for char to char32_t mapping 2019-12-02 19:55:04 +01:00
Adrian Wong
9b1fd8ecca Fix missing C header for char32_t 2019-12-02 19:55:04 +01:00
Jaseem Abid
745a5a063f Improve error message when config file is not found (#422)
Fixes https://github.com/eqrion/cbindgen/issues/411

This is still sub optimal since a stack trace is shown instead of a nice error
message, but at least adds a human readable context with full file path instead
of a generic 'Unwrap() went wrong".

Before:

```
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/libcore/result.rs:1165:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
```

Now:

```
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "Couldn\'t open config file: cbindgen.toml."', src/libcore/result.rs:1165:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
```
2019-12-02 19:54:02 +01:00
Emilio Cobos Álvarez
2609e96d61
v0.10.0 2019-11-19 17:08:56 +01:00
Gyusun Yeom
3f9e54b775 Initialize struct literal with list-initializer for C++11 standard (#401)
* Emit struct literal with list-initializer when language is Cxx

* Update test results

* Add test case - struct literal order

* Memoize struct field names

* Specify struct type at front of initializer
2019-11-17 19:28:40 +01:00
Emilio Cobos Álvarez
5b4cda0d95 Minor refactoring to the namespaces logic.
Should be no behavior change.
2019-11-06 03:37:33 +01:00
Adam Wilson
975eae889f remove commented line 2019-11-04 17:16:52 +01:00
Adam Wilson
01adab71d2 Surround namespace with __cplusplus ifdef in cpp_compat mode 2019-11-04 17:16:52 +01:00
Daisuke Kato
1765130a60 remove unnecesary "`" from docs.md 2019-10-20 14:44:29 +02:00
Emilio Cobos Álvarez
b8140911ee Note that --quiet overrides -v 2019-10-12 18:30:38 +02:00
Sathwik Matsa
603aa2f9bf Add support for --quiet flag 2019-10-12 18:30:38 +02:00
Adrian Wong
087d36f32a Map char to char32_t
Rust's `char` is 32 bits wide, but `wchar_t` on Windows is 16.
Avoid truncation by mapping `char` to `char32_t`.
2019-10-04 10:39:31 +02:00
Dzmitry Malyshau
ffc5acea27 Improve binding_crate_ref() error message 2019-10-04 10:20:42 +02:00
Volker Mische
7f3b8f4dcd Add tests for parser fix
The tests are based on https://github.com/vmx/cbindgen-expand-dep-bug
2019-09-21 22:42:17 +09:00
Lucas Molas
175d3e40ed fix(parser): avoid prematurely returning during expansion 2019-09-21 22:42:17 +09:00
Rasmus Eneman
4415614b99 Remove using namespace from cpp compat 2019-09-02 21:50:10 +02:00
Rasmus Eneman
89e1d970b0 Add using_namespaces to documentation 2019-09-02 21:50:10 +02:00
Rasmus Eneman
f1433bd3b9 Rename using => using_namespaces 2019-09-02 21:50:10 +02:00
Rasmus Eneman
4bd7b07d2f Add support for adding "using namespace" statements 2019-09-02 21:50:10 +02:00
Emilio Cobos Álvarez
8e4db4c17f
Release 0.9.1.
* Various improvements to comment output. https://github.com/eqrion/cbindgen/pull/370 / https://github.com/eqrion/cbindgen/pull/375.
 * Fixed expand when ran from build.rs. https://github.com/eqrion/cbindgen/pull/371
 * More debugging output for expansion. https://github.com/eqrion/cbindgen/pull/383
 * New option to add a default private constructor in C++ tagged enums. https://github.com/eqrion/cbindgen/pull/377
 * Syn and related dependencies updated to 1.0. https://github.com/eqrion/cbindgen/pull/379
2019-08-25 19:45:15 +02:00
Emilio Cobos Álvarez
959131e79b Add newlines to not generate such ugly code. 2019-08-25 17:05:22 +02:00
Emilio Cobos Álvarez
bdc560d18a Add tests for private_default_tagged_enum_constructor. 2019-08-25 17:05:22 +02:00
Emilio Cobos Álvarez
b2efcc4051 ir: Add an option to generate an empty, default constructor for tagged enums.
This allows to clean up a pattern that has been showing up lately, see
occurrences of:

  https://searchfox.org/mozilla-central/rev/9775cca0a10a9b5c5f4e15c8f7b3eff5bf91bbd0/servo/ports/geckolib/cbindgen.toml#329
2019-08-25 17:05:22 +02:00
Bastien Orivel
25e51f6e3b Update syn related dependencies to 1.0 2019-08-19 09:28:03 +02:00
Dzmitry Malyshau
11839640c0 Enable verbose logging as well as echo the command line on expansion. 2019-08-17 21:30:01 +02:00
Delet0r
9197af7079 Fixed most of the clippy warnings (#378) 2019-08-15 10:23:37 +02:00
Bruno Kirschner
1450e39d8f Preserve indentation on comments.
As indentation is a very handy way to structure comments and increase
their readability as much of it as possible should be preserved.

This removes any trimming of leading white spaces and ensures that
any cbindgen annotations are still recognized afterwards.

... fixes #184
2019-08-08 14:07:04 +02:00
Bruno Kirschner
47e831753b Avoid trimming non whitespace characters.
Rustc already removes all leading `/` symbols during the conversion
from doc-comments into annotations. Any additional trimming of non
whitespace characters just reduces the formatting flexibility of a
comment.

... fixes #374
2019-08-08 14:07:04 +02:00
Volker Mische
65958a5a96 Don't call cbindgen recursively
To expand a crate, cbindgen calls cargo on that crate. cbindgen can be called from a build.rs
file. But if cargo is called again, it will also call cbindgen again and hence end up in an
endless recursion.

This commit makes sure that cbindgen isn't called again if it is already running.

You can verify this fix with this minimal example https://github.com/vmx/cbindgen-expand-bug

Fixes #347.
2019-08-06 12:59:25 +02:00
Volker Mische
3e820849cb Run cargo expand outside the normal target directory
When crates should get expanded, then cargo is run again from within cbindgen.
When cbindgen is started from a build.rs file, this means that cargo is starting
another cargo run.

Cargo locks the directory it is running on. If two cargos spawn by each other
run with the same target directory, then they both want to accquire a lock and
hence deadlock.

This commit fixes the problem with running the spawned cargo at a different
directory. Please note that this will always be the same directory, hence
any subsequent runs will be faster (as you would exepct it to be).

This is part of #347.
2019-08-06 12:59:25 +02:00
Bruno Kirschner
b4b82a500c Preserve empty lines in doc comments.
This required two changes in parallel.

As a first and obvious step it removes a check that skipped emptys
lines during documentation loading, but it was also necessary to
refactore the `get_comment_lines()` utility method as a second step.

This second refactoring was necessary as each line in a doc comment
is trimmed and transformed in its own doc attribute. The attribute
of an empty line therefore contains an empty string as value. If we
now call `lines()` on such an empty string we end up with an empty
iterator as the method is internally configured to ignore trailing
empty lines.
2019-08-03 17:38:59 +02:00
yelite
65fbb25638 Fix typo in docs 2019-08-03 17:37:55 +02:00
Bruce Mitchener
5a66d68e77 Remove extraneous backtick. 2019-07-02 13:50:55 +01:00
Emilio Cobos Álvarez
1770680343
Merge pull request #365 from emilio/releases
Upload binaries on releases.
2019-06-26 23:26:03 +02:00
Emilio Cobos Álvarez
42df273fa0
Set up release binaries uploads.
Fixes #351
2019-06-26 16:08:06 +02:00
Emilio Cobos Álvarez
b1f91e2845
Use consistent indentation in .travis.yml 2019-06-26 16:08:05 +02:00
Emilio Cobos Álvarez
cbdf7bc31f
Add recent changes to the CHANGES file, which I forgot to do. 2019-06-26 16:02:59 +02:00
Emilio Cobos Álvarez
e19526e00b
Release 0.9.0
* Support to generate C headers with C++ compatibility. https://github.com/eqrion/cbindgen/pull/349
 * Fix include guard generation when no_includes is set. https://github.com/eqrion/cbindgen/pull/352
 * Fix crate parsing order so that types from the binding crate are preferred in presence of conflicting names. https://github.com/eqrion/cbindgen/pull/355
 * Add extra_bindings option to generate bindings for dependencies. https://github.com/eqrion/cbindgen/pull/362
 * Clap dependency is optional now so it's feasible to avoid building it if cbindgen is used as a library. https://github.com/eqrion/cbindgen/pull/363
2019-06-26 15:18:17 +02:00
Emilio Cobos Álvarez
a3c1334ae3
Merge pull request #362 from emilio/outside-items
Add an option to generate consts / globals / fn from parsed dependencies.
2019-06-26 13:38:42 +02:00
Emilio Cobos Álvarez
5f8e027290
rename to extra_bindings per IRC discussion. 2019-06-25 21:33:19 +02:00
Emilio Cobos Álvarez
16b2a25442
Turn the option into a whitelist rather than an on / off switch. 2019-06-25 21:28:12 +02:00
Emilio Cobos Álvarez
c5a34be627
Cleanup parse config propagation. 2019-06-25 21:28:12 +02:00
Emilio Cobos Álvarez
0bcd54f9c3
Add an option to generate consts / globals / fn from parsed dependencies.
This is a limitation that may not be useful if you're using it to parse known
dependencies.
2019-06-25 21:28:11 +02:00
Emilio Cobos Álvarez
540224ce3c
Merge pull request #363 from elichai/features
Making clap an optional feature
2019-06-25 21:14:39 +02:00
Elichai Turkel
519c2494d6
Added no default features to travis.yml 2019-06-25 08:43:04 -04:00
Elichai Turkel
0edaeb5ea2
Removed redundant serde-derive and disabled default features in serde 2019-06-25 08:42:56 -04:00
Elichai Turkel
6748b78c0b
Made clap optional 2019-06-25 08:42:16 -04:00
Emilio Cobos Álvarez
2a7496c81b
Properly indent a test. 2019-06-16 22:02:26 -07:00
Ryan Hunt
54add222d6 Rename existing documentation to be less ALL-CAPS 2019-06-12 11:46:24 -05:00