-
Notifications
You must be signed in to change notification settings - Fork 696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bindgen with rustfmt disabled generates bindings on one line #1600
Comments
Yes, this is somewhat annoying. Didn't use to be the case before switching to syn / quote, but I'm not sure there's a way around this that isn't switching back from generating rust token trees to generating text. |
Is it not possible to insert newlines in the token tree? |
Not as far as I know, but ICBW. |
I had been thinking of a super-simple "formatter" which always puts line breaks after |
So it seems that the key conversion happens here which currently calls the Either, upstream Rust could be changed to put linebreaks after |
Per default, bindgen puts everything onto one line. This pretty printer will insert newlines for better readability. See rust-lang/rust-bindgen#1600
Please see RustAudio/deepspeech-rs@3323b0e as an implementation of my idea. @jsgf do you want to put this into a bindgen PR? |
Example of the generated code: # [repr ( C )] # [repr ( align ( 16 ) )] # [derive ( Debug , Copy , Clone )] pub struct max_align_t {
pub __clang_max_align_nonce1 : :: std :: os :: raw :: c_longlong , pub __bindgen_padding_0 : u64 , pub __clang_max_align_nonce2 : u128 ,
}
# [test] fn bindgen_test_layout_max_align_t () {
assert_eq ! (:: std :: mem :: size_of ::< max_align_t > ( ) , 32usize , concat ! ( "Size of: " , stringify ! ( max_align_t ) )) ;
assert_eq ! (:: std :: mem :: align_of ::< max_align_t > ( ) , 16usize , concat ! ( "Alignment of " , stringify ! ( max_align_t ) )) ;
assert_eq ! (unsafe { & ( * ( :: std :: ptr :: null ::< max_align_t > ( ) ) ) . __clang_max_align_nonce1 as * const _ as usize } , 0usize , concat ! ( "Offset of field: " , stringify ! ( max_align_t ) , "::" , stringify ! ( __clang_max_align_nonce1 ) )) ;
assert_eq ! (unsafe { & ( * ( :: std :: ptr :: null ::< max_align_t > ( ) ) ) . __clang_max_align_nonce2 as * const _ as usize } , 16usize , concat ! ( "Offset of field: " , stringify ! ( max_align_t ) , "::" , stringify ! ( __clang_max_align_nonce2 ) )) ;
}
# [repr ( C )] # [derive ( Debug , Copy , Clone )] pub struct ModelState {
_unused : [u8 ; 0] ,
}
# [repr ( C )] # [derive ( Debug , Copy , Clone )] pub struct StreamingState {
_unused : [u8 ; 0] ,
}
# [repr ( C )] # [derive ( Debug , Copy , Clone )] pub struct MetadataItem {
pub character : * mut :: std :: os :: raw :: c_char , pub timestep : :: std :: os :: raw :: c_int , pub start_time : f32 ,
}
# [test] fn bindgen_test_layout_MetadataItem () {
assert_eq ! (:: std :: mem :: size_of ::< MetadataItem > ( ) , 16usize , concat ! ( "Size of: " , stringify ! ( MetadataItem ) )) ;
assert_eq ! (:: std :: mem :: align_of ::< MetadataItem > ( ) , 8usize , concat ! ( "Alignment of " , stringify ! ( MetadataItem ) )) ;
assert_eq ! (unsafe { & ( * ( :: std :: ptr :: null ::< MetadataItem > ( ) ) ) . character as * const _ as usize } , 0usize , concat ! ( "Offset of field: " , stringify ! ( MetadataItem ) , "::" , stringify ! ( character ) )) ;
assert_eq ! (unsafe { & ( * ( :: std :: ptr :: null ::< MetadataItem > ( ) ) ) . timestep as * const _ as usize } , 8usize , concat ! ( "Offset of field: " , stringify ! ( MetadataItem ) , "::" , stringify ! ( timestep ) )) ;
assert_eq ! (unsafe { & ( * ( :: std :: ptr :: null ::< MetadataItem > ( ) ) ) . start_time as * const _ as usize } , 12usize , concat ! ( "Offset of field: " , stringify ! ( MetadataItem ) , "::" , stringify ! ( start_time ) )) ;
}
# [repr ( C )] # [derive ( Debug , Copy , Clone )] pub struct Metadata {
pub items : * mut MetadataItem , pub num_items : :: std :: os :: raw :: c_int , pub confidence : f64 ,
}
# [test] fn bindgen_test_layout_Metadata () {
assert_eq ! (:: std :: mem :: size_of ::< Metadata > ( ) , 24usize , concat ! ( "Size of: " , stringify ! ( Metadata ) )) ;
assert_eq ! (:: std :: mem :: align_of ::< Metadata > ( ) , 8usize , concat ! ( "Alignment of " , stringify ! ( Metadata ) )) ;
assert_eq ! (unsafe { & ( * ( :: std :: ptr :: null ::< Metadata > ( ) ) ) . items as * const _ as usize } , 0usize , concat ! ( "Offset of field: " , stringify ! ( Metadata ) , "::" , stringify ! ( items ) )) ;
assert_eq ! (unsafe { & ( * ( :: std :: ptr :: null ::< Metadata > ( ) ) ) . num_items as * const _ as usize } , 8usize , concat ! ( "Offset of field: " , stringify ! ( Metadata ) , "::" , stringify ! ( num_items ) )) ;
assert_eq ! (unsafe { & ( * ( :: std :: ptr :: null ::< Metadata > ( ) ) ) . confidence as * const _ as usize } , 16usize , concat ! ( "Offset of field: " , stringify ! ( Metadata ) , "::" , stringify ! ( confidence ) )) ;
}
pub const DeepSpeech_Error_Codes_DS_ERR_OK : DeepSpeech_Error_Codes = 0 ;
pub const DeepSpeech_Error_Codes_DS_ERR_NO_MODEL : DeepSpeech_Error_Codes = 4096 ;
pub const DeepSpeech_Error_Codes_DS_ERR_INVALID_ALPHABET : DeepSpeech_Error_Codes = 8192 ;
pub const DeepSpeech_Error_Codes_DS_ERR_INVALID_SHAPE : DeepSpeech_Error_Codes = 8193 ;
pub const DeepSpeech_Error_Codes_DS_ERR_INVALID_LM : DeepSpeech_Error_Codes = 8194 ;
pub const DeepSpeech_Error_Codes_DS_ERR_MODEL_INCOMPATIBLE : DeepSpeech_Error_Codes = 8195 ;
pub const DeepSpeech_Error_Codes_DS_ERR_FAIL_INIT_MMAP : DeepSpeech_Error_Codes = 12288 ;
pub const DeepSpeech_Error_Codes_DS_ERR_FAIL_INIT_SESS : DeepSpeech_Error_Codes = 12289 ;
pub const DeepSpeech_Error_Codes_DS_ERR_FAIL_INTERPRETER : DeepSpeech_Error_Codes = 12290 ;
pub const DeepSpeech_Error_Codes_DS_ERR_FAIL_RUN_SESS : DeepSpeech_Error_Codes = 12291 ;
pub const DeepSpeech_Error_Codes_DS_ERR_FAIL_CREATE_STREAM : DeepSpeech_Error_Codes = 12292 ;
pub const DeepSpeech_Error_Codes_DS_ERR_FAIL_READ_PROTOBUF : DeepSpeech_Error_Codes = 12293 ;
pub const DeepSpeech_Error_Codes_DS_ERR_FAIL_CREATE_SESS : DeepSpeech_Error_Codes = 12294 ;
pub const DeepSpeech_Error_Codes_DS_ERR_FAIL_CREATE_MODEL : DeepSpeech_Error_Codes = 12295 ;
pub type DeepSpeech_Error_Codes = u32 ;
extern "C" {
# [doc = " @brief An object providing an interface to a trained DeepSpeech model."] # [doc = ""] # [doc = " @param aModelPath The path to the frozen model graph."] # [doc = " @param aAlphabetConfigPath The path to the configuration file specifying"] # [doc = " the alphabet used by the network. See alphabet.h."] # [doc = " @param aBeamWidth The beam width used by the decoder. A larger beam"] # [doc = " width generates better results at the cost of decoding"] # [doc = " time."] # [doc = " @param[out] retval a ModelState pointer"] # [doc = ""] # [doc = " @return Zero on success, non-zero on failure."] pub fn DS_CreateModel (aModelPath : * const :: std :: os :: raw :: c_char , aAlphabetConfigPath : * const :: std :: os :: raw :: c_char , aBeamWidth : :: std :: os :: raw :: c_uint , retval : * mut * mut ModelState ,) -> :: std :: os :: raw :: c_int ;
}
extern "C" {
# [doc = " @brief Frees associated resources and destroys model object."] pub fn DS_FreeModel (ctx : * mut ModelState) ;
}
extern "C" {
# [doc = " @brief Enable decoding using beam scoring with a KenLM language model."] # [doc = ""] # [doc = " @param aCtx The ModelState pointer for the model being changed."] # [doc = " @param aAlphabetConfigPath The path to the configuration file specifying"] # [doc = " the alphabet used by the network. See alphabet.h."] # [doc = " @param aLMPath The path to the language model binary file."] # [doc = " @param aTriePath The path to the trie file build from the same vocabu-"] # [doc = " lary as the language model binary."] # [doc = " @param aLMAlpha The alpha hyperparameter of the CTC decoder. Language Model"] # [doc = "weight."] # [doc = " @param aLMBeta The beta hyperparameter of the CTC decoder. Word insertion"] # [doc = "weight."] # [doc = ""] # [doc = " @return Zero on success, non-zero on failure (invalid arguments)."] pub fn DS_EnableDecoderWithLM (aCtx : * mut ModelState , aLMPath : * const :: std :: os :: raw :: c_char , aTriePath : * const :: std :: os :: raw :: c_char , aLMAlpha : f32 , aLMBeta : f32 ,) -> :: std :: os :: raw :: c_int ;
}
extern "C" {
# [doc = " @brief Use the DeepSpeech model to perform Speech-To-Text."] # [doc = ""] # [doc = " @param aCtx The ModelState pointer for the model to use."] # [doc = " @param aBuffer A 16-bit, mono raw audio signal at the appropriate"] # [doc = " sample rate."] # [doc = " @param aBufferSize The number of samples in the audio signal."] # [doc = " @param aSampleRate The sample-rate of the audio signal."] # [doc = ""] # [doc = " @return The STT result. The user is responsible for freeing the string using"] # [doc = " {@link DS_FreeString()}. Returns NULL on error."] pub fn DS_SpeechToText (aCtx : * mut ModelState , aBuffer : * const :: std :: os :: raw :: c_short , aBufferSize : :: std :: os :: raw :: c_uint , aSampleRate : :: std :: os :: raw :: c_uint ,) -> * mut :: std :: os :: raw :: c_char ;
}
extern "C" {
# [doc = " @brief Use the DeepSpeech model to perform Speech-To-Text and output metadata"] # [doc = " about the results."] # [doc = ""] # [doc = " @param aCtx The ModelState pointer for the model to use."] # [doc = " @param aBuffer A 16-bit, mono raw audio signal at the appropriate"] # [doc = " sample rate."] # [doc = " @param aBufferSize The number of samples in the audio signal."] # [doc = " @param aSampleRate The sample-rate of the audio signal."] # [doc = ""] # [doc = " @return Outputs a struct of individual letters along with their timing information."] # [doc = " The user is responsible for freeing Metadata by calling {@link DS_FreeMetadata()}. Returns NULL on error."] pub fn DS_SpeechToTextWithMetadata (aCtx : * mut ModelState , aBuffer : * const :: std :: os :: raw :: c_short , aBufferSize : :: std :: os :: raw :: c_uint , aSampleRate : :: std :: os :: raw :: c_uint ,) -> * mut Metadata ;
}
extern "C" {
# [doc = " @brief Create a new streaming inference state. The streaming state returned"] # [doc = " by this function can then be passed to {@link DS_FeedAudioContent()}"] # [doc = " and {@link DS_FinishStream()}."] # [doc = ""] # [doc = " @param aCtx The ModelState pointer for the model to use."] # [doc = " @param aSampleRate The sample-rate of the audio signal."] # [doc = " @param[out] retval an opaque pointer that represents the streaming state. Can"] # [doc = " be NULL if an error occurs."] # [doc = ""] # [doc = " @return Zero for success, non-zero on failure."] pub fn DS_CreateStream (aCtx : * mut ModelState , aSampleRate : :: std :: os :: raw :: c_uint , retval : * mut * mut StreamingState ,) -> :: std :: os :: raw :: c_int ;
}
extern "C" {
# [doc = " @brief Feed audio samples to an ongoing streaming inference."] # [doc = ""] # [doc = " @param aSctx A streaming state pointer returned by {@link DS_CreateStream()}."] # [doc = " @param aBuffer An array of 16-bit, mono raw audio samples at the"] # [doc = " appropriate sample rate."] # [doc = " @param aBufferSize The number of samples in @p aBuffer."] pub fn DS_FeedAudioContent (aSctx : * mut StreamingState , aBuffer : * const :: std :: os :: raw :: c_short , aBufferSize : :: std :: os :: raw :: c_uint ,) ;
}
extern "C" {
# [doc = " @brief Compute the intermediate decoding of an ongoing streaming inference."] # [doc = " This is an expensive process as the decoder implementation isn't"] # [doc = " currently capable of streaming, so it always starts from the beginning"] # [doc = " of the audio."] # [doc = ""] # [doc = " @param aSctx A streaming state pointer returned by {@link DS_CreateStream()}."] # [doc = ""] # [doc = " @return The STT intermediate result. The user is responsible for freeing the"] # [doc = " string using {@link DS_FreeString()}."] pub fn DS_IntermediateDecode (aSctx : * mut StreamingState) -> * mut :: std :: os :: raw :: c_char ;
}
extern "C" {
# [doc = " @brief Signal the end of an audio signal to an ongoing streaming"] # [doc = " inference, returns the STT result over the whole audio signal."] # [doc = ""] # [doc = " @param aSctx A streaming state pointer returned by {@link DS_CreateStream()}."] # [doc = ""] # [doc = " @return The STT result. The user is responsible for freeing the string using"] # [doc = " {@link DS_FreeString()}."] # [doc = ""] # [doc = " @note This method will free the state pointer (@p aSctx)."] pub fn DS_FinishStream (aSctx : * mut StreamingState) -> * mut :: std :: os :: raw :: c_char ;
}
extern "C" {
# [doc = " @brief Signal the end of an audio signal to an ongoing streaming"] # [doc = " inference, returns per-letter metadata."] # [doc = ""] # [doc = " @param aSctx A streaming state pointer returned by {@link DS_CreateStream()}."] # [doc = ""] # [doc = " @return Outputs a struct of individual letters along with their timing information."] # [doc = " The user is responsible for freeing Metadata by calling {@link DS_FreeMetadata()}. Returns NULL on error."] # [doc = ""] # [doc = " @note This method will free the state pointer (@p aSctx)."] pub fn DS_FinishStreamWithMetadata (aSctx : * mut StreamingState) -> * mut Metadata ;
}
extern "C" {
# [doc = " @brief Destroy a streaming state without decoding the computed logits. This"] # [doc = " can be used if you no longer need the result of an ongoing streaming"] # [doc = " inference and don't want to perform a costly decode operation."] # [doc = ""] # [doc = " @param aSctx A streaming state pointer returned by {@link DS_CreateStream()}."] # [doc = ""] # [doc = " @note This method will free the state pointer (@p aSctx)."] pub fn DS_FreeStream (aSctx : * mut StreamingState) ;
}
extern "C" {
# [doc = " @brief Free memory allocated for metadata information."] pub fn DS_FreeMetadata (m : * mut Metadata) ;
}
extern "C" {
# [doc = " @brief Free a char* string returned by the DeepSpeech API."] pub fn DS_FreeString (str : * mut :: std :: os :: raw :: c_char) ;
}
extern "C" {
# [doc = " @brief Print version of this library and of the linked TensorFlow library."] pub fn DS_PrintVersions () ;
} |
When rustfmt is missing, bindgen puts anything on one line. Any warnings then dump so many logs that TravisCI is overwhelmed. The fix is to add rustfmt to the environment. See rust-lang/rust-bindgen#1600
When rustfmt is missing, bindgen puts anything on one line. Any warnings then dump so many logs that TravisCI is overwhelmed. The fix is to add rustfmt to the environment. See rust-lang/rust-bindgen#1600
When rustfmt is missing, bindgen puts anything on one line. Any warnings then dump so many logs that TravisCI is overwhelmed. The fix is to add rustfmt to the environment. See rust-lang/rust-bindgen#1600
When rustfmt is missing, bindgen puts anything on one line. Any warnings then dump so many logs that TravisCI is overwhelmed. The fix is to add rustfmt to the environment. See rust-lang/rust-bindgen#1600
When rustfmt is missing, bindgen puts anything on one line. Any warnings then dump so many logs that TravisCI is overwhelmed. The fix is to add rustfmt to the environment. See rust-lang/rust-bindgen#1600
When rustfmt is missing, bindgen puts anything on one line. Any warnings then dump so many logs that TravisCI is overwhelmed. The fix is to add rustfmt to the environment. See rust-lang/rust-bindgen#1600
When rustfmt is missing, bindgen puts anything on one line. Any warnings then dump so many logs that TravisCI is overwhelmed. The fix is to add rustfmt to the environment. See rust-lang/rust-bindgen#1600
See rust-lang/rust#62999 and RustAudio/coreaudio-sys@bf9714f
TL;DR: when the generated bindings are very large and contain warnings, rust emits warnings, each of which show the entirely of the generated bindings.
The text was updated successfully, but these errors were encountered: