* 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
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.
```
* 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
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
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
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-bugFixes#347.
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.
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.