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

Consider "Default References" #10

Open
gprossliner opened this issue Jun 25, 2016 · 1 comment
Open

Consider "Default References" #10

gprossliner opened this issue Jun 25, 2016 · 1 comment
Assignees
Milestone

Comments

@gprossliner
Copy link
Owner

In cobj, in order to call interface methods, you need a reference to that very interface, which is itself the result of a queryinterface call.

Consider providing a reference to each implemented interface for a object to be created initialized when an object is initialized.

So you always have to deal with objects and the corresponding interfaces. This makes using cobj harder then in should be, and results in more boilerplate code.

Example:

// init a class
myclass c;
myclass_initialize(&c);

// get references for "interface1" and "interface2", and call the foo function on them:
interface1 i1;
interface2 i2;
interface1_queryinterface(&c.object, &i1);
interface2_queryinterface(&c.object, &i2);
interface1_foo(&i1);
interface2_foo(&i2);

This could become much more readable by:

// init a class. The cobj generator emits a default reference to each implemented interface.
myclass c;
myclass_initialize(&c);

// call methods by using the default references:
interface1_foo(&c.interface1);
interface2_foo(&c.interface2);

As a result of this change, queryinterface may not be needed at all, but this will go into a new issue.

@gprossliner
Copy link
Owner Author

Implementing these changes will cause uncompatible changes, but they make cobj that much easier to use, that it will be implemented. So this will be version 2 of cobj ;-)

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

1 participant