Skip to content

Anonymous classes #23

@jdolan

Description

@jdolan

It'd be nice to introduce anonymous classes for "one-off" objects that override a method or two, but do not warrant their own named type. I think the most appealing way would be to have a function that returns a copy of a given class, and takes in either a block (macro) or a functor to serve as the body of Class::initialize:

static _Bool resizeHandle_captureEvent(Control *self, const SDL_Event *event);

Control *control = anonymous(Control, {
    ((ControlInterface *) clazz->def->interface)->captureEvent = resizeHandle_captureEvent;
});

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions