Currently our API and internal function aren't very consistent about the return value. Whether should non-zero result be success or error? We should define the SUCCESS and ERROR symbol instead of return the raw integer.
Define SUCCESS and ERROR return type #21
is this any time pressure on this issue ?
ps. let me doubt about the good for first label (LOL)
Absolutely not time sensitive. It has been opened 13 years after all :-)
It's nice to have since the current API has two major incompatible return value styles, following C conventions:
- Boolean where 1 is true and 0 is false
- Result where -1 is fail and 0 is success
After working on this, you will learn
- how to change the API signature and update the generate
chewing.hheader - how to expose rust types to C FFI safely
- high level understanding of how each API treat return values
Need basic knowledge of C and Rust. I do not have any of that (cry)
why :
- incompatible interface works now ?
- any reason want to change it ?
- a simple function or interface example that make you decide to change it ?
I think I should make project build works, and learn FFI design for first.
This is why I doubt about the "good for first" label (LOL)
I can only found success / error definition in file /src/exn.rs :
pub(crate)traitResultExt{type Success;type Error: Error+Send+Sync+'static;}is this the definition which is hope to been updated ?
there is a C header file which mention about return value : /capi/include/chewing.h. I am not sure if it is the file we need to consider.
We want to update the C interface.
I think we can move this definition
constTRUE: c_int=1;constFALSE: c_int=0;constOK: c_int=0;constERROR: c_int=-1;to somewhere after
/// The size of internal buffer for pre-edit buffer.
pubconstMAX_PHONE_SEQ_LEN: usize =50;/// The maximum phrase size.
pubconstMAX_PHRASE_LEN: usize =11;and change them to public.
then use them in
90c949e75d/capi/src/io.rs, check comments like
/// The return value is 0 on success and -1 on failure.
Archived
Archived
No due date set.
No dependencies set.
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?