rust-lang / rust-lang/rust-bindgen

add option to map specific C type to Rust type

Open
#2,154 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
5.3k
Forks
829
Avg merge
1d 1h
Merged PRs (30d)
15

Description

when bindgen (0.59.2) translate this to Rust

typedef void (* C4NULLABLE C4LogCallback)(C4LogDomain, C4LogLevel, const char *fmt, va_list args);
void c4log_writeToCallback(C4LogLevel level, C4LogCallback callback, bool preformatted) C4API;

I got this type for C4LogCallback.

unsafe extern "C" fn(_, C4LogLevel, _, *mut __va_list_tag)

I want replace the last argument *mut __va_list_tag with VaList from va_list crate.

I also I have similar problem when I convert bitmap.h from Android Sdk.
This header include jni.h and so:

int32_t AndroidBitmap_getDataSpace(JNIEnv* env, jobject jbitmap)

uses generated by bindgen Rust type JNIEnv defined in jni.h,
but at the same time I use jni crate where this type defined,
so I want map C type JNIEnv to jni::JNIEnv.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the bindgen 0.59.2 output for the C4LogCallback and Android bitmap declarations, including the types from va_list and jni.h. Then trace how bindgen represents generated C types and determine where a user option could map them to va_list::VaList or jni::JNIEnv; done means both examples can use those mapped Rust types.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.