You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.6 KiB

4 years ago
* GHOST Rust bindings
Rust bindings and interop for GHOST.
** Layout
ABI-compatable types and functions are all prefixed with `GHOST_` and are exported in the `c` module (TODO).
I've attempted to provide more Rust-idiomatic API variants as well, which have non-prefixed names.
** Implementation log
*** Implemented C compatable ABI
Note: List is in-progress and doesn't show everything
- [-] `GHOST_Types.h`
- [X] /Handles/
- [X] GHOST_SystemHandle
- [X] GHOST_TimerTaskHandle
- [X] GHOST_WindowHandle
- [X] GHOST_EventHandle
- [X] GHOST_RectangleHandle
- [X] GHOST_EventConsumerHandle
- [X] GHOST_ContextHandle
- [X] GHOST_XrContextHandle
- [-] /Primitives/ (ones that begin with =T= I count as `primitive')
- [X] GHOST_TInt8
- [X] GHOST_TUns8
- [X] GHOST_Tint16
- [X] GHOST_TUns16
- [X] GHOST_Tint32
- [X] GHOST_TUns32
- [X] GHOST_TInt64
- [X] GHOST_TUns64
- [X] GHOST_TUserDataPtr
- [X] GHOST_TSuccess
- [X] GHOST_TTabletMode
- [X] GHOST_TTabletAPI
- [X] GHOST_TVisibility
- [X] GHOST_TFireTimeConstant
- [X] GHOST_TModifierKeyMask
- [X] GHOST_TWindowState
- [X] GHOST_TWindowOrder
- [X] GHOST_TDrawingContextType
- [X] GHOST_TButtonMask
- [X] GHOST_TEventType
- [ ] GHOST_TStandardCursor
- [ ] GHOST_TKey
- [X] /Structures/
- [X] GHOST_GLSettings
- [X] GHOST_GLFlags
- [X] GHOST_DialogOptions
- [X] GHOST_TabletData
- [X] /Constants/
- [X] =GHOST_TABLET_DATA_NONE=
* reimpl as ~const fn~ (~GHOST_TabletData::none()~)
*** Native Rust API
I provide more Rust idiomatic API for some things. They may or may not share ABI, if they do they will have type aliases to the corresponding ~GHOST_~ identifier, so always use those when ABI compatability is desired.
**** Overview
List and implementation status of features
- [-] Types
- [X] [[Handles]]: ~handle.rs~
- [ ] Events: ~event.rs~
**** Handles
Handles keep the C ABI, but are re-wrtten with traits to be more idiomatic.
The trait ~GhostHandle~ is provided, which should be implemented on a structure that is not intended to be instantiated, but instead used as a `marker' for `Handle<T>'.
These types are ABI equivalent, and are present (with their corresponding ~GHOST_~ alias in =handle.rs=)
Since handles are just types pointers, they are only ever used as such and shouldn't exist themselves.
***** Example
#+BEGIN_SRC rust
extern "C" unsafe fn internal_call(window: GHOST_WindowHandle) -> GHOST_TSuccess;
fn do_something_to_window(window: &mut Handle<Window>) -> Result<()>
{
unsafe {
internal_call(window as GHOST_WindowHandle).into()
}
}
#+END_SRC