this system allows dialects to register named interfaces, which are collections of function pointers. an op can then implement this interface, providing callbacks for the interface's virtual function pointers. C code can request a pointer to an op's implementation of a given interface and call virtual functions with no knowledge required about the op itself. this functonality will also be extended to types, attributes, and dialects themselves.
29 lines
603 B
C
29 lines
603 B
C
#include <blue/ds/string.h>
|
|
#include <mie/dialect/dialect.h>
|
|
#include <mie/interface/interface-definition.h>
|
|
|
|
struct mie_interface_definition *mie_interface_definition_create(
|
|
struct mie_dialect *parent, const char *name)
|
|
{
|
|
struct mie_interface_definition *out = malloc(sizeof *out);
|
|
if (!out) {
|
|
return NULL;
|
|
}
|
|
|
|
memset(out, 0x0, sizeof *out);
|
|
|
|
out->if_name = b_strdup(name);
|
|
if (!out->if_name) {
|
|
free(out);
|
|
return NULL;
|
|
}
|
|
|
|
out->if_parent = parent;
|
|
out->if_size = 0;
|
|
|
|
b_rope name_rope = B_ROPE_CSTR(name);
|
|
mie_id_map_put(&parent->d_interfaces, &out->if_id, &name_rope);
|
|
|
|
return out;
|
|
}
|