dcampbell24 / iup-rust

Rust binding for IUP
MIT License
44 stars 13 forks source link

The Object Model #6

Closed thelink2012 closed 9 years ago

thelink2012 commented 9 years ago

A step to the a high-level binding is to decide the object model to be used, each has pros and cons, mainly because of the C model used in IUP.

Note: The pros and cons lists are not exhaustive, please consider adding more if any comes to mind.

Terminology:

This is the current model in the library, all the IUP objects are described with a Ihandle structure and passed to functions as the first argument.

Pros:

Cons:

Pros

Cons:

Mirror Ihandle and Functions (using string attributes) and Ihandle and Functions (using functions for attributes) here by excluding the Annoying &mut handle on each function call cons.

Structs/Traits and Methods (using methods for attributes)

Pros:

Cons:

Issues:

thelink2012 commented 9 years ago

Thoughts @dcampbell24?

EDIT: Oh, the callbacks system don't work very well either using the Ihandle methodology. For instance IupText action callback receives (Ihandle *ih, int c, char *new_value) meanwhile the button action callback receives (Ihandle* ih).

I was very neutral + a little bit inclined to the Ihandle model, but now I think the struct/trait model is the way to go.

dcampbell24 commented 9 years ago

I like the struct / trait approach even though I think it will require more work to implement. Unfortunately, I am probably not going to have very much free time for a while to help with this.