summaryrefslogtreecommitdiffstats
path: root/ffi-macros/src/lib.rs
AgeCommit message (Collapse)Author
2019-05-16ffi-macros: Generate function prototypes for C.Justus Winter
2019-05-13openpgp-ffi: Use the C ABI, not the system ABINeal H. Walfield
Reported-by: Thomas Muenz
2019-05-09ffi-macros: Derive Iterator.Justus Winter
2019-05-09ffi-macros: Support arguments for derived implementations.Justus Winter
2019-05-07openpgp-ffi, ffi: Fix calling convention on Windows.Justus Winter
- Use `extern "C"` instead of `extern "system"`. The latter selects stdcall, which is only appropriate for talking to the Windows API.
2019-04-26ffi-macros: Implement wrapping of references.Justus Winter
2019-04-26ffi-macros: Fix the RefRaw trait.Justus Winter
- Do not hardcode the lifetime in the trait.
2019-04-09ffi-macros: Use crate sha2 instead of nettle.Justus Winter
- We hash type names to create a compile-time-constant value for the runtime type checks in the wrapper types. Use sha2 instead of nettle, because the former is a pure-rust implementation, and doesn't require nettle at runtime. This makes building easier because we do not require nettle to be in the dynamic linker path at compile time.
2019-03-25ffi-macros: Implement MoveFromRaw<Option<W>>.Justus Winter
2019-02-12ffi-macros: Fix freeing wrappers with references.Justus Winter
- We cannot use move_from_raw() here, because there may be no object to move from raw.
2019-02-12openpgp-ffi: Improve derived functions.Justus Winter
- Use an absolute path for the 'io' module.
2019-02-12openpgp-ffi: Improve derived functions.Justus Winter
- Explicitly use the Parse and Serialize traits so that the modules that derives these functions do not have to use them explicitly.
2019-02-05openpgp-ffi: Convert pgp_writer_t.Justus Winter
2019-02-05ffi-macros: Do not pull traits into the namespace.Justus Winter
- Previously, it was impossible to use the ffi_wrapper_type macro twice in the same module because importing a trait twice introduces a conflict.
2019-02-05openpgp-ffi: Convert pgp_reader_t to the new framework.Justus Winter
2019-02-05ffi-macros: Implement RefMutRaw for Maybe<T>.Justus Winter
2019-02-05ffi-macros: Make trait RefMutRaw more flexible.Justus Winter
2019-02-05ffi-macros: Embed and display actual type in panics.Justus Winter
2019-02-05ffi-macros: Provide expected type in panics.Justus Winter
2019-02-05openpgp-ffi: Use a common macro for every exported function.Justus Winter
- This way we can easily introduce new transformations.
2019-01-29openpgp-ffi: Improve the derived serialization function.Justus Winter
- Using absolute paths allows us to use types without having the user to 'use' them.
2019-01-29openpgp-ffi: Derive Parse.Justus Winter
2019-01-29openpgp-ffi: Derive Serialize.Justus Winter
2019-01-29openpgp-ffi: Convert Error.Justus Winter
2019-01-29ffi-macros: Prepare for wrapped references.Justus Winter
- A consequence of using wrapper types in the API is that we can no longer hand out references. For example, with the recently introduced wrapper types, pgp_tsk_tpk no longer works, as it returns bare references. - With this change, we wrap immutable and mutable references to objects. It presents an opportunity for a uniform API (i.e. just always free references you got from us), and for us the ability to track mutability of references.
2019-01-29ffi-macros: Improve assert_tag error message.Neal H. Walfield
- A wrapper object may be deallocated either if the object is freed *or* the object is moved. Change the error message to mention both of these possibilities.
2019-01-25ffi-macros: Protect against use-after-free.Justus Winter
- When we transfer ownership from C to Rust, we move the wrapped object out of the wrapper, and poison the wrapper. - This prevents reuse of the wrapper object. When a stale reference is given to us, we check the tag encoding the type information. - If the tag field is poisoned, we can produce a more helpful error message. This is not exact, of course. As soon as the memory is reused, our tag is overwritten.
2019-01-25ffi-macros: Check wrapper types at runtime.Justus Winter
- This change adds a tag to the derived wrapper types that identify the type of the wrapped value. - At runtime, we can verify that references to wrapper objects indeed carry the right tag. - Fixes #166.
2019-01-25openpgp-ffi: Use wrapper types.Justus Winter
- With the abstractions for moving ownership and references across the FFI boundary, we can now switch to actually using the wrapper types by changing the function signatures to use the wrapper type, and updating the generated functions.
2019-01-25openpgp-ffi: Prepare to use the wrapper types.Justus Winter
2019-01-25openpgp-ffi: Derive conversion functions.Justus Winter
- This is a framework for dealing with ownership and references at the FFI boundary. Previously, we used macros to do that. This change introduces a more idiomatic interface, we use traits converting from raw pointers of a wrapper type to objects, references, or mutable references to a wrapped type. - For now, we use the wrapped type as wrapper type. We merely introduce a new mechanism replacing the macro-based one. - This patch also converts all the derived functions. - The following patches will convert all the functions that are already using the ffi_wrapper_type. Once this conversion is done, we can introduce our own wrapper type.
2019-01-22ffi-macros: Add ffi_wrapper_type that derives functions.Justus Winter
- Note that the wrapper type is not actually used for now, the functions still operate on the original type. But, this lets us derive functions, and for that we merge it now. - See #166.
2019-01-16ffi-macros: Improve translation.Justus Winter
- Use the parenthesis token to preserve location information.
2019-01-16ffi-macros: New crate.Justus Winter
- This crate contains macros for Sequoia's FFI crate(s). Having it in a separate crate means that we can share it when we split the FFI crate into two. - More importantly, we need a separate crate if we want to create procedural macros. - As first macro, this patch adds ffi_catch_abort that wraps a function's body in a catch_unwind block, aborting on panics.