core: class: add functions to get a registered class, and get the name of a class
This commit is contained in:
15
core/class.c
15
core/class.c
@@ -6,6 +6,21 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
void *b_class_get(b_type id)
|
||||||
|
{
|
||||||
|
struct b_type_registration *r = b_type_get_registration(id);
|
||||||
|
if (!r) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return r->r_class;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *b_class_get_name(const struct _b_class *c)
|
||||||
|
{
|
||||||
|
return c->c_type->r_info->t_name;
|
||||||
|
}
|
||||||
|
|
||||||
void *b_class_get_interface(const struct _b_class *c, const union b_type *id)
|
void *b_class_get_interface(const struct _b_class *c, const union b_type *id)
|
||||||
{
|
{
|
||||||
const struct b_type_registration *type_reg = c->c_type;
|
const struct b_type_registration *type_reg = c->c_type;
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
typedef struct _b_class b_class;
|
typedef struct _b_class b_class;
|
||||||
|
|
||||||
|
BLUE_API void *b_class_get(b_type id);
|
||||||
|
BLUE_API const char *b_class_get_name(const b_class *c);
|
||||||
BLUE_API void *b_class_get_interface(const b_class *c, b_type id);
|
BLUE_API void *b_class_get_interface(const b_class *c, b_type id);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user