Skip to content

Consider "Default References" #10

Description

@gprossliner

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions