cbindgen icon indicating copy to clipboard operation
cbindgen copied to clipboard

Rename items with a rule

Open cormacrelf opened this issue 4 years ago • 5 comments

Everything else can have a rename rule. Why not items too!

Example below. Nice and neat, no #![allow(non_camel_case_types)] required.

#[repr(c)]
struct StructDef {
    x: i32,
    y: f32,
}
type TypeAlias = StructDef;
// doesn't apply to functions, obviously
// also this PR fixes misleading example in docs for [export.rename] which purported to apply to a function name
#[no_mangle]
extern "C" fn capi_write(obj: *mut StructDef) {}
[export]
prefix = "capi_"
rename_items = "snake_case"
typedef struct {
    int32_t x;
    float y;
} capi_struct_def;
typedef capi_struct_def capi_type_alias;
void capi_write(capi_struct_def *def);

cormacrelf avatar Jul 08 '21 12:07 cormacrelf

I realised this is a dupe of #419. This one has tests though.

cormacrelf avatar Jul 08 '21 12:07 cormacrelf

Hi. Any change of getting this merged/release soon?

orium avatar Nov 02 '22 16:11 orium