allowing emulators to change method flags

This commit is contained in:
2026-04-27 20:14:34 +03:00
parent 72fd316310
commit 21eca5db92
4 changed files with 43 additions and 10 deletions

View File

@@ -1779,6 +1779,34 @@ nn_Exit nn_setComponentTypeID(nn_Component *c, const char *internalTypeID) {
return NN_OK;
}
static nn_MethodEntry *nn_getComponentMethodEntry(nn_Component *c, const char *method) {
nn_MethodEntry ent = {
.name = method,
};
return nn_hashGet(&c->methodsMap, &ent);
}
// Sets the method flags
void nn_setComponentMethodFlags(nn_Component *c, const char *method, nn_MethodFlags flags) {
nn_MethodEntry *ent = nn_getComponentMethodEntry(c, method);
if(ent == NULL) return;
ent->flags = flags;
}
// combines method flags
void nn_addComponentMethodFlags(nn_Component *c, const char *method, nn_MethodFlags flags) {
nn_MethodEntry *ent = nn_getComponentMethodEntry(c, method);
if(ent == NULL) return;
ent->flags |= flags;
}
// removes method flags
void nn_removeComponentMethodFlags(nn_Component *c, const char *method, nn_MethodFlags flags) {
nn_MethodEntry *ent = nn_getComponentMethodEntry(c, method);
if(ent == NULL) return;
ent->flags &= ~flags;
}
void *nn_getComponentState(nn_Component *c) {
return c->state;
}
@@ -1792,13 +1820,6 @@ size_t nn_countComponentMethods(nn_Component *c) {
return c->methodCount;
}
static nn_MethodEntry *nn_getComponentMethodEntry(nn_Component *c, const char *method) {
nn_MethodEntry ent = {
.name = method,
};
return nn_hashGet(&c->methodsMap, &ent);
}
// will fill the methodnames array with the names of the *enabled* methods.
// Will set *len to the amount of methods.
void nn_getComponentMethods(nn_Component *c, const char **methodnames, size_t *len) {