blob: 36a072d852054e2ffae8472698460ddbccbcec47 [file] [log] [blame] [view]
Yongheng Chene940de92024-07-17 09:36:19 -07001# Attributes to fine-tune generated bindings
2
3Crubit recognizes custom attributes to fine-tune generated bindings.
4
5To use a Crubit attribute, you must add the following to your Rust crate:
6
7```rust
8
9#![feature(register_tool)]
10#![register_tool(__crubit)]
11```
12
13The format of the Crubit tool attributes is `#[__crubit::annotate(attribute_name="attribute_value")]`.
14
15## `cpp_name`
16
17This attribute overrides the name of the generated C++ bindings. For
18example, the following Rust code:
19
20```rust
21#[__crubit::annotate(cpp_name="Create")]
22pub fn new() -> i32 {...}
23```
24
25Will generate the following C++ bindings:
26
27```cpp
28std::int32_t Create(); // named `Create` instead of `new`.
29```
30
31Currently this attribute works on functions only (See b/349070421).
32
Yongheng Chend5a67842024-07-19 13:57:35 -070033## `cpp_type`
Yongheng Chene940de92024-07-17 09:36:19 -070034
35TODO(b/315382130): Rename this attribute to `cpp_type` and add the doc.