Skip to content
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

Proposal for increasing interface readability #23

Open
MirkoCovizzi opened this issue May 10, 2020 · 1 comment
Open

Proposal for increasing interface readability #23

MirkoCovizzi opened this issue May 10, 2020 · 1 comment
Assignees

Comments

@MirkoCovizzi
Copy link
Member

MirkoCovizzi commented May 10, 2020

My proposal is to add type aliasing for *mut c_void in the context of interface methods.
Example:

type IParamValueQueuePtr = *mut c_void;

#[com_interface("A4779663-0BB6-4A56-B443-84A8466FEB9D")]
pub trait IParameterChanges: IUnknown {
    unsafe fn get_parameter_count(&self) -> i32;
    unsafe fn get_parameter_data(&self, index: i32) -> IParamValueQueuePtr;
    unsafe fn add_parameter_data(&self, id: *const u32, index: *mut i32) -> IParamValueQueuePtr;
}

The reason for this is that we necessarily need to have these methods return a *mut c_void otherwise it's impossible to cast a fat pointer (like dyn IParamValueQueue) to a thin pointer. By introducing these type aliases we keep the semantics of the method intact (so we know what type is returned by reading the alias name). An alternative can be to use docs, but I feel like this approach is more immediate and requires less noisy information.

@robbert-vdh
Copy link
Member

This has been taken care of with the pointer changes from #45. Every pointer argument or return value can now be upgraded to a smart pointer type with the correct semantics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants