mie: implement an interface system for ops
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.
This commit is contained in:
28
mie/interface/interface-definition.c
Normal file
28
mie/interface/interface-definition.c
Normal file
@@ -0,0 +1,28 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user