2026-05-25 17:26:08 +01:00
|
|
|
#include "fx/namemap.h"
|
|
|
|
|
|
2026-05-03 13:11:22 +01:00
|
|
|
#include <fx/bst.h>
|
|
|
|
|
#include <fx/hash.h>
|
2026-05-25 17:26:08 +01:00
|
|
|
#include <fx/iterator.h>
|
2026-05-03 13:11:22 +01:00
|
|
|
#include <fx/macros.h>
|
|
|
|
|
#include <fx/queue.h>
|
|
|
|
|
#include <fx/reflection/assembly.h>
|
2026-05-25 17:26:08 +01:00
|
|
|
#include <fx/reflection/type.h>
|
|
|
|
|
|
|
|
|
|
FX_API fx_type_id fx_assembly_iterator_get_type();
|
|
|
|
|
FX_API fx_type_id fx_assembly_type_iterator_get_type();
|
|
|
|
|
|
|
|
|
|
FX_DECLARE_TYPE(fx_assembly_iterator);
|
|
|
|
|
FX_DECLARE_TYPE(fx_assembly_type_iterator);
|
|
|
|
|
|
|
|
|
|
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_assembly_iterator)
|
|
|
|
|
FX_TYPE_CLASS_DECLARATION_END(fx_assembly_iterator)
|
|
|
|
|
|
|
|
|
|
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_assembly_type_iterator)
|
|
|
|
|
FX_TYPE_CLASS_DECLARATION_END(fx_assembly_type_iterator)
|
2026-05-03 13:11:22 +01:00
|
|
|
|
|
|
|
|
enum map_entry_type {
|
|
|
|
|
MAP_ENTRY_NONE = 0,
|
|
|
|
|
MAP_ENTRY_ITEM,
|
|
|
|
|
MAP_ENTRY_BUCKET,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct map_entry {
|
|
|
|
|
enum map_entry_type e_type;
|
2026-05-25 17:26:08 +01:00
|
|
|
struct map_bucket *e_bucket;
|
2026-05-03 13:11:22 +01:00
|
|
|
uint64_t e_hash;
|
|
|
|
|
union {
|
|
|
|
|
fx_queue_entry e_entry;
|
|
|
|
|
fx_bst_node e_node;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct map_bucket {
|
|
|
|
|
struct map_entry b_entry;
|
|
|
|
|
fx_queue b_items;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct map_item {
|
|
|
|
|
struct map_entry i_entry;
|
|
|
|
|
const char *i_name;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct map {
|
|
|
|
|
fx_bst m_entries;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct type {
|
|
|
|
|
struct map_item e_map_item;
|
2026-05-05 19:03:22 +01:00
|
|
|
fx_type_id e_type;
|
2026-05-03 13:11:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct fx_assembly_p {
|
2026-05-25 17:26:08 +01:00
|
|
|
fx_assembly *a_self;
|
2026-05-03 13:11:22 +01:00
|
|
|
const char *a_name;
|
|
|
|
|
struct map a_types;
|
2026-05-25 17:26:08 +01:00
|
|
|
fx_namemap_entry a_entry;
|
2026-05-03 13:11:22 +01:00
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
long v_major;
|
|
|
|
|
long v_minor;
|
|
|
|
|
long v_build;
|
|
|
|
|
long v_revision;
|
|
|
|
|
} a_version;
|
|
|
|
|
};
|
|
|
|
|
|
2026-05-25 17:26:08 +01:00
|
|
|
struct fx_assembly_iterator_p {
|
|
|
|
|
fx_namemap_entry *it_cur;
|
2026-05-28 21:00:23 +01:00
|
|
|
fx_value it_value;
|
2026-05-25 17:26:08 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct fx_assembly_type_iterator_p {
|
|
|
|
|
struct type *it_item;
|
2026-05-28 21:00:23 +01:00
|
|
|
fx_value it_value;
|
2026-05-25 17:26:08 +01:00
|
|
|
};
|
|
|
|
|
|
2026-05-03 13:11:22 +01:00
|
|
|
/*** PRIVATE FUNCTIONS ********************************************************/
|
|
|
|
|
|
|
|
|
|
FX_BST_DEFINE_SIMPLE_GET(
|
|
|
|
|
struct map_entry,
|
|
|
|
|
uint64_t,
|
|
|
|
|
e_node,
|
|
|
|
|
e_hash,
|
|
|
|
|
map_get_entry);
|
|
|
|
|
FX_BST_DEFINE_SIMPLE_INSERT(struct map_entry, e_node, e_hash, map_put_entry);
|
|
|
|
|
|
2026-05-25 17:26:08 +01:00
|
|
|
static fx_namemap assembly_map = FX_NAMEMAP_INIT;
|
|
|
|
|
|
2026-05-03 13:11:22 +01:00
|
|
|
static struct map_bucket *map_item_convert_to_bucket(
|
|
|
|
|
struct map *map,
|
|
|
|
|
struct map_item *item)
|
|
|
|
|
{
|
|
|
|
|
struct map_bucket *bucket = malloc(sizeof *bucket);
|
|
|
|
|
|
|
|
|
|
memset(bucket, 0x0, sizeof *bucket);
|
|
|
|
|
|
|
|
|
|
bucket->b_entry.e_hash = item->i_entry.e_hash;
|
|
|
|
|
bucket->b_entry.e_type = MAP_ENTRY_BUCKET;
|
|
|
|
|
|
|
|
|
|
fx_bst_delete(&map->m_entries, &item->i_entry.e_node);
|
|
|
|
|
fx_queue_push_back(&bucket->b_items, &item->i_entry.e_entry);
|
|
|
|
|
map_put_entry(&map->m_entries, &bucket->b_entry);
|
|
|
|
|
|
|
|
|
|
return bucket;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-25 17:26:08 +01:00
|
|
|
static struct map_item *map_first_item(const struct map *map)
|
|
|
|
|
{
|
|
|
|
|
fx_bst_node *first = fx_bst_first(&map->m_entries);
|
|
|
|
|
if (!first) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct map_entry *entry = fx_unbox(struct map_entry, first, e_node);
|
|
|
|
|
if (entry->e_type == MAP_ENTRY_ITEM) {
|
|
|
|
|
return (struct map_item *)entry;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct map_bucket *bucket = (struct map_bucket *)entry;
|
|
|
|
|
fx_queue_entry *first_entry = fx_queue_first(&bucket->b_items);
|
|
|
|
|
if (!first_entry) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
entry = fx_unbox(struct map_entry, first_entry, e_entry);
|
|
|
|
|
return (struct map_item *)entry;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-03 13:11:22 +01:00
|
|
|
static void map_put(struct map *map, const char *name, struct map_item *item)
|
|
|
|
|
{
|
|
|
|
|
uint64_t hash = fx_hash_cstr(name);
|
|
|
|
|
|
|
|
|
|
item->i_entry.e_type = MAP_ENTRY_ITEM;
|
|
|
|
|
item->i_entry.e_hash = hash;
|
|
|
|
|
item->i_name = name;
|
|
|
|
|
|
|
|
|
|
struct map_entry *entry = map_get_entry(&map->m_entries, hash);
|
|
|
|
|
if (!entry) {
|
|
|
|
|
map_put_entry(&map->m_entries, &item->i_entry);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct map_item *existing_item = NULL;
|
|
|
|
|
struct map_bucket *bucket = NULL;
|
|
|
|
|
switch (entry->e_type) {
|
|
|
|
|
case MAP_ENTRY_ITEM:
|
|
|
|
|
existing_item = (struct map_item *)entry;
|
|
|
|
|
bucket = map_item_convert_to_bucket(map, existing_item);
|
|
|
|
|
fx_queue_push_back(&bucket->b_items, &item->i_entry.e_entry);
|
|
|
|
|
break;
|
|
|
|
|
case MAP_ENTRY_BUCKET:
|
|
|
|
|
bucket = (struct map_bucket *)entry;
|
|
|
|
|
fx_queue_push_back(&bucket->b_items, &item->i_entry.e_entry);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-25 17:26:08 +01:00
|
|
|
static struct map_item *map_item_next(struct map_item *item)
|
2026-05-03 13:11:22 +01:00
|
|
|
{
|
2026-05-25 17:26:08 +01:00
|
|
|
struct map_bucket *bucket = item->i_entry.e_bucket;
|
|
|
|
|
struct map_entry *next_item = NULL;
|
|
|
|
|
if (bucket) {
|
2026-05-28 21:00:23 +01:00
|
|
|
struct fx_queue_entry *q_item
|
|
|
|
|
= fx_queue_next(&item->i_entry.e_entry);
|
2026-05-25 17:26:08 +01:00
|
|
|
if (!q_item) {
|
2026-05-28 21:00:23 +01:00
|
|
|
struct fx_bst_node *node
|
|
|
|
|
= fx_bst_next(&bucket->b_entry.e_node);
|
2026-05-25 17:26:08 +01:00
|
|
|
next_item = fx_unbox(struct map_entry, node, e_node);
|
|
|
|
|
} else {
|
|
|
|
|
next_item = fx_unbox(struct map_entry, q_item, e_entry);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
struct fx_bst_node *node = fx_bst_next(&item->i_entry.e_node);
|
|
|
|
|
next_item = fx_unbox(struct map_entry, node, e_node);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!next_item) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (next_item->e_type == MAP_ENTRY_BUCKET) {
|
|
|
|
|
bucket = (struct map_bucket *)next_item;
|
2026-05-28 21:00:23 +01:00
|
|
|
struct fx_queue_entry *q_item
|
|
|
|
|
= fx_queue_first(&bucket->b_items);
|
2026-05-25 17:26:08 +01:00
|
|
|
next_item = fx_unbox(struct map_entry, q_item, e_entry);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (struct map_item *)next_item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static fx_status assembly_register(struct fx_assembly_p *assembly)
|
|
|
|
|
{
|
|
|
|
|
if (fx_namemap_get(&assembly_map, assembly->a_name)) {
|
|
|
|
|
return FX_ERR_NAME_EXISTS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fx_namemap_put(&assembly_map, assembly->a_name, &assembly->a_entry);
|
|
|
|
|
return FX_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void assembly_set_name(struct fx_assembly_p *assembly, const char *name)
|
|
|
|
|
{
|
|
|
|
|
assembly->a_name = name;
|
2026-05-03 13:11:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void assembly_set_version(
|
2026-05-25 17:26:08 +01:00
|
|
|
struct fx_assembly_p *assembly,
|
2026-05-03 13:11:22 +01:00
|
|
|
long major,
|
|
|
|
|
long minor,
|
|
|
|
|
long build,
|
|
|
|
|
long revision)
|
|
|
|
|
{
|
2026-05-25 17:26:08 +01:00
|
|
|
assembly->a_version.v_major = major;
|
|
|
|
|
assembly->a_version.v_minor = minor;
|
|
|
|
|
assembly->a_version.v_build = build;
|
|
|
|
|
assembly->a_version.v_revision = revision;
|
2026-05-03 13:11:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
static void assembly_add_type(
|
2026-05-25 17:26:08 +01:00
|
|
|
struct fx_assembly_p *assembly,
|
2026-05-03 13:11:22 +01:00
|
|
|
const char *full_name,
|
2026-05-05 19:03:22 +01:00
|
|
|
fx_type_id type_id)
|
2026-05-03 13:11:22 +01:00
|
|
|
{
|
|
|
|
|
struct type *type = malloc(sizeof *type);
|
|
|
|
|
memset(type, 0x0, sizeof *type);
|
|
|
|
|
|
2026-05-25 17:26:08 +01:00
|
|
|
type->e_type = type_id;
|
|
|
|
|
fx_type *ty = (fx_type *)fx_type_get_by_id(type_id);
|
|
|
|
|
fx_type_set_assembly(ty, assembly->a_self);
|
|
|
|
|
|
|
|
|
|
map_put(&assembly->a_types, full_name, &type->e_map_item);
|
2026-05-03 13:11:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void map_item_dump(struct map_item *item)
|
|
|
|
|
{
|
|
|
|
|
struct type *type = (struct type *)item;
|
|
|
|
|
printf(" Type: %s\n", type->e_map_item.i_name);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-25 17:26:08 +01:00
|
|
|
static void assembly_dump(struct fx_assembly_p *assembly)
|
2026-05-03 13:11:22 +01:00
|
|
|
{
|
|
|
|
|
printf("Loaded assembly:\n");
|
|
|
|
|
printf(" %s, Version=%ld.%ld.%ld.%ld\n",
|
2026-05-25 17:26:08 +01:00
|
|
|
assembly->a_name,
|
|
|
|
|
assembly->a_version.v_major,
|
|
|
|
|
assembly->a_version.v_minor,
|
|
|
|
|
assembly->a_version.v_build,
|
|
|
|
|
assembly->a_version.v_revision);
|
2026-05-03 13:11:22 +01:00
|
|
|
|
2026-05-25 17:26:08 +01:00
|
|
|
fx_bst_node *cur_node = fx_bst_first(&assembly->a_types.m_entries);
|
2026-05-03 13:11:22 +01:00
|
|
|
while (cur_node) {
|
2026-05-28 21:00:23 +01:00
|
|
|
struct map_entry *entry
|
|
|
|
|
= fx_unbox(struct map_entry, cur_node, e_node);
|
2026-05-03 13:11:22 +01:00
|
|
|
switch (entry->e_type) {
|
|
|
|
|
case MAP_ENTRY_ITEM: {
|
|
|
|
|
struct map_item *item = (struct map_item *)entry;
|
|
|
|
|
map_item_dump(item);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case MAP_ENTRY_BUCKET: {
|
|
|
|
|
struct map_bucket *bucket = (struct map_bucket *)entry;
|
2026-05-28 21:00:23 +01:00
|
|
|
fx_queue_entry *cur_qentry
|
|
|
|
|
= fx_queue_first(&bucket->b_items);
|
2026-05-03 13:11:22 +01:00
|
|
|
while (cur_qentry) {
|
|
|
|
|
struct map_item *item = fx_unbox(
|
|
|
|
|
struct map_item,
|
|
|
|
|
cur_qentry,
|
|
|
|
|
i_entry.e_entry);
|
|
|
|
|
map_item_dump(item);
|
|
|
|
|
cur_qentry = fx_queue_next(cur_qentry);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cur_node = fx_bst_next(cur_node);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-25 17:26:08 +01:00
|
|
|
static fx_iterator *assembly_get_types(const struct fx_assembly_p *assembly)
|
|
|
|
|
{
|
2026-05-28 21:00:23 +01:00
|
|
|
fx_assembly_type_iterator *it
|
|
|
|
|
= fx_object_create(fx_assembly_type_iterator_get_type());
|
2026-05-25 17:26:08 +01:00
|
|
|
if (!it) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct fx_assembly_type_iterator_p *it_p = fx_object_get_private(
|
|
|
|
|
it,
|
|
|
|
|
fx_assembly_type_iterator_get_type());
|
|
|
|
|
struct map_item *item = map_first_item(&assembly->a_types);
|
2026-05-28 21:00:23 +01:00
|
|
|
if (!item) {
|
2026-05-25 17:26:08 +01:00
|
|
|
fx_iterator_set_status(it, FX_ERR_NO_DATA);
|
2026-05-28 21:00:23 +01:00
|
|
|
return it;
|
2026-05-25 17:26:08 +01:00
|
|
|
}
|
|
|
|
|
|
2026-05-28 21:00:23 +01:00
|
|
|
it_p->it_item = fx_unbox(struct type, item, e_map_item);
|
|
|
|
|
const fx_type *ty = fx_type_get_by_id(it_p->it_item->e_type);
|
|
|
|
|
it_p->it_value = FX_VALUE_OBJECT_REF(ty);
|
|
|
|
|
|
2026-05-25 17:26:08 +01:00
|
|
|
return it;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const char *assembly_get_name(const struct fx_assembly_p *assembly)
|
|
|
|
|
{
|
|
|
|
|
return assembly->a_name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void assembly_get_version(
|
|
|
|
|
const struct fx_assembly_p *assembly,
|
|
|
|
|
long *out_major,
|
|
|
|
|
long *out_minor,
|
|
|
|
|
long *out_build,
|
|
|
|
|
long *out_revision)
|
|
|
|
|
{
|
|
|
|
|
if (out_major) {
|
|
|
|
|
*out_major = assembly->a_version.v_major;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (out_minor) {
|
|
|
|
|
*out_minor = assembly->a_version.v_minor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (out_build) {
|
|
|
|
|
*out_build = assembly->a_version.v_build;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (out_revision) {
|
|
|
|
|
*out_revision = assembly->a_version.v_revision;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-03 13:11:22 +01:00
|
|
|
/*** PUBLIC FUNCTIONS *********************************************************/
|
|
|
|
|
|
2026-05-25 17:26:08 +01:00
|
|
|
fx_iterator *fx_assembly_get_all(void)
|
|
|
|
|
{
|
2026-05-28 21:00:23 +01:00
|
|
|
fx_assembly_iterator *it
|
|
|
|
|
= fx_object_create(fx_assembly_iterator_get_type());
|
2026-05-25 17:26:08 +01:00
|
|
|
if (!it) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-28 21:00:23 +01:00
|
|
|
struct fx_assembly_iterator_p *it_p
|
|
|
|
|
= fx_object_get_private(it, fx_assembly_iterator_get_type());
|
2026-05-25 17:26:08 +01:00
|
|
|
it_p->it_cur = fx_namemap_first(&assembly_map);
|
|
|
|
|
if (!it_p->it_cur) {
|
|
|
|
|
fx_iterator_set_status(it, FX_ERR_NO_DATA);
|
2026-05-28 21:00:23 +01:00
|
|
|
return it;
|
2026-05-25 17:26:08 +01:00
|
|
|
}
|
|
|
|
|
|
2026-05-28 21:00:23 +01:00
|
|
|
struct fx_assembly_p *assembly
|
|
|
|
|
= fx_unbox(struct fx_assembly_p, it_p->it_cur, a_entry);
|
|
|
|
|
|
|
|
|
|
it_p->it_value = FX_VALUE_OBJECT_REF(assembly->a_self);
|
|
|
|
|
|
2026-05-25 17:26:08 +01:00
|
|
|
return it;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const fx_assembly *fx_assembly_get_by_name(const char *name)
|
|
|
|
|
{
|
|
|
|
|
const fx_namemap_entry *entry = fx_namemap_get(&assembly_map, name);
|
|
|
|
|
if (!entry) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-28 21:00:23 +01:00
|
|
|
struct fx_assembly_p *assembly
|
|
|
|
|
= fx_unbox(struct fx_assembly_p, entry, a_entry);
|
2026-05-25 17:26:08 +01:00
|
|
|
return assembly->a_self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fx_status fx_assembly_register(fx_assembly *assembly)
|
|
|
|
|
{
|
|
|
|
|
FX_CLASS_DISPATCH_STATIC_0(
|
|
|
|
|
FX_REFLECTION_TYPE_ASSEMBLY,
|
|
|
|
|
assembly_register,
|
|
|
|
|
assembly);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void fx_assembly_set_name(fx_assembly *assembly, const char *name)
|
2026-05-03 13:11:22 +01:00
|
|
|
{
|
|
|
|
|
FX_CLASS_DISPATCH_STATIC_V(
|
|
|
|
|
FX_REFLECTION_TYPE_ASSEMBLY,
|
|
|
|
|
assembly_set_name,
|
2026-05-25 17:26:08 +01:00
|
|
|
assembly,
|
2026-05-03 13:11:22 +01:00
|
|
|
name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void fx_assembly_set_version(
|
2026-05-25 17:26:08 +01:00
|
|
|
fx_assembly *assembly,
|
2026-05-03 13:11:22 +01:00
|
|
|
long major,
|
|
|
|
|
long minor,
|
|
|
|
|
long build,
|
|
|
|
|
long revision)
|
|
|
|
|
{
|
|
|
|
|
FX_CLASS_DISPATCH_STATIC_V(
|
|
|
|
|
FX_REFLECTION_TYPE_ASSEMBLY,
|
|
|
|
|
assembly_set_version,
|
2026-05-25 17:26:08 +01:00
|
|
|
assembly,
|
2026-05-03 13:11:22 +01:00
|
|
|
major,
|
|
|
|
|
minor,
|
|
|
|
|
build,
|
|
|
|
|
revision);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void fx_assembly_add_type(
|
2026-05-25 17:26:08 +01:00
|
|
|
fx_assembly *assembly,
|
2026-05-03 13:11:22 +01:00
|
|
|
const char *full_name,
|
2026-05-05 19:03:22 +01:00
|
|
|
fx_type_id type_id)
|
2026-05-03 13:11:22 +01:00
|
|
|
{
|
|
|
|
|
FX_CLASS_DISPATCH_STATIC_V(
|
|
|
|
|
FX_REFLECTION_TYPE_ASSEMBLY,
|
|
|
|
|
assembly_add_type,
|
2026-05-25 17:26:08 +01:00
|
|
|
assembly,
|
2026-05-03 13:11:22 +01:00
|
|
|
full_name,
|
|
|
|
|
type_id);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-25 17:26:08 +01:00
|
|
|
fx_iterator *fx_assembly_get_types(const fx_assembly *assembly)
|
|
|
|
|
{
|
|
|
|
|
FX_CLASS_DISPATCH_STATIC_0(
|
|
|
|
|
FX_REFLECTION_TYPE_ASSEMBLY,
|
|
|
|
|
assembly_get_types,
|
|
|
|
|
assembly);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *fx_assembly_get_name(const fx_assembly *assembly)
|
|
|
|
|
{
|
|
|
|
|
FX_CLASS_DISPATCH_STATIC_0(
|
|
|
|
|
FX_REFLECTION_TYPE_ASSEMBLY,
|
|
|
|
|
assembly_get_name,
|
|
|
|
|
assembly);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void fx_assembly_get_version(
|
|
|
|
|
const fx_assembly *assembly,
|
|
|
|
|
long *out_major,
|
|
|
|
|
long *out_minor,
|
|
|
|
|
long *out_build,
|
|
|
|
|
long *out_revision)
|
|
|
|
|
{
|
|
|
|
|
FX_CLASS_DISPATCH_STATIC_V(
|
|
|
|
|
FX_REFLECTION_TYPE_ASSEMBLY,
|
|
|
|
|
assembly_get_version,
|
|
|
|
|
assembly,
|
|
|
|
|
out_major,
|
|
|
|
|
out_minor,
|
|
|
|
|
out_build,
|
|
|
|
|
out_revision);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void fx_assembly_dump(const fx_assembly *assembly)
|
2026-05-03 13:11:22 +01:00
|
|
|
{
|
|
|
|
|
FX_CLASS_DISPATCH_STATIC_0(
|
|
|
|
|
FX_REFLECTION_TYPE_ASSEMBLY,
|
|
|
|
|
assembly_dump,
|
2026-05-25 17:26:08 +01:00
|
|
|
assembly);
|
2026-05-03 13:11:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*** VIRTUAL FUNCTIONS ********************************************************/
|
|
|
|
|
|
|
|
|
|
static void assembly_init(fx_object *obj, void *priv)
|
|
|
|
|
{
|
2026-05-25 17:26:08 +01:00
|
|
|
struct fx_assembly_p *assembly = priv;
|
|
|
|
|
assembly->a_self = obj;
|
2026-05-03 13:11:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void assembly_fini(fx_object *obj, void *priv)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-25 17:26:08 +01:00
|
|
|
/*** ITERATOR DEFINITION ******************************************************/
|
|
|
|
|
|
|
|
|
|
static enum fx_status type_iterator_move_next(const fx_iterator *obj)
|
|
|
|
|
{
|
|
|
|
|
struct fx_assembly_type_iterator_p *it = fx_object_get_private(
|
|
|
|
|
obj,
|
|
|
|
|
fx_assembly_type_iterator_get_type());
|
|
|
|
|
if (!it->it_item) {
|
|
|
|
|
return FX_ERR_NO_DATA;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-28 21:00:23 +01:00
|
|
|
fx_value_unset(&it->it_value);
|
2026-05-25 17:26:08 +01:00
|
|
|
struct map_item *next = map_item_next(&it->it_item->e_map_item);
|
|
|
|
|
it->it_item = fx_unbox(struct type, next, e_map_item);
|
2026-05-28 21:00:23 +01:00
|
|
|
if (!it->it_item) {
|
|
|
|
|
return FX_ERR_NO_DATA;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const fx_type *ty = fx_type_get_by_id(it->it_item->e_type);
|
|
|
|
|
it->it_value = FX_VALUE_OBJECT_REF(ty);
|
|
|
|
|
|
|
|
|
|
return FX_SUCCESS;
|
2026-05-25 17:26:08 +01:00
|
|
|
}
|
|
|
|
|
|
2026-05-28 21:00:23 +01:00
|
|
|
static const fx_value *type_iterator_get_value(const fx_iterator *obj)
|
2026-05-25 17:26:08 +01:00
|
|
|
{
|
|
|
|
|
struct fx_assembly_type_iterator_p *it = fx_object_get_private(
|
|
|
|
|
obj,
|
|
|
|
|
fx_assembly_type_iterator_get_type());
|
|
|
|
|
if (!it->it_item) {
|
2026-05-28 21:00:23 +01:00
|
|
|
return NULL;
|
2026-05-25 17:26:08 +01:00
|
|
|
}
|
|
|
|
|
|
2026-05-28 21:00:23 +01:00
|
|
|
return &it->it_value;
|
2026-05-25 17:26:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static enum fx_status assembly_iterator_move_next(const fx_iterator *obj)
|
|
|
|
|
{
|
2026-05-28 21:00:23 +01:00
|
|
|
struct fx_assembly_iterator_p *it
|
|
|
|
|
= fx_object_get_private(obj, fx_assembly_iterator_get_type());
|
2026-05-25 17:26:08 +01:00
|
|
|
if (!it->it_cur) {
|
|
|
|
|
return FX_ERR_NO_DATA;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-28 21:00:23 +01:00
|
|
|
fx_value_unset(&it->it_value);
|
2026-05-25 17:26:08 +01:00
|
|
|
it->it_cur = fx_namemap_next(&assembly_map, it->it_cur);
|
2026-05-28 21:00:23 +01:00
|
|
|
if (!it->it_cur) {
|
|
|
|
|
return FX_ERR_NO_DATA;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct fx_assembly_p *assembly
|
|
|
|
|
= fx_unbox(struct fx_assembly_p, it->it_cur, a_entry);
|
|
|
|
|
|
|
|
|
|
it->it_value = FX_VALUE_OBJECT_REF(assembly->a_self);
|
|
|
|
|
return FX_SUCCESS;
|
2026-05-25 17:26:08 +01:00
|
|
|
}
|
|
|
|
|
|
2026-05-28 21:00:23 +01:00
|
|
|
static const fx_value *assembly_iterator_get_value(const fx_iterator *obj)
|
2026-05-25 17:26:08 +01:00
|
|
|
{
|
2026-05-28 21:00:23 +01:00
|
|
|
struct fx_assembly_iterator_p *it
|
|
|
|
|
= fx_object_get_private(obj, fx_assembly_iterator_get_type());
|
2026-05-25 17:26:08 +01:00
|
|
|
if (!it->it_cur) {
|
2026-05-28 21:00:23 +01:00
|
|
|
return NULL;
|
2026-05-25 17:26:08 +01:00
|
|
|
}
|
|
|
|
|
|
2026-05-28 21:00:23 +01:00
|
|
|
return &it->it_value;
|
2026-05-25 17:26:08 +01:00
|
|
|
}
|
|
|
|
|
|
2026-05-03 13:11:22 +01:00
|
|
|
/*** CLASS DEFINITION *********************************************************/
|
|
|
|
|
|
2026-05-05 19:03:22 +01:00
|
|
|
FX_TYPE_CLASS_BEGIN(fx_assembly)
|
|
|
|
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
2026-05-03 13:11:22 +01:00
|
|
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
2026-05-05 19:03:22 +01:00
|
|
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
|
|
|
|
FX_TYPE_CLASS_END(fx_assembly)
|
2026-05-03 13:11:22 +01:00
|
|
|
|
|
|
|
|
FX_TYPE_DEFINITION_BEGIN(fx_assembly)
|
|
|
|
|
FX_TYPE_ID(0xf6690c30, 0x6642, 0x42f0, 0xb79f, 0xe2baf3684b1b);
|
2026-05-25 17:26:08 +01:00
|
|
|
FX_TYPE_NAME("fx.reflection.assembly");
|
2026-05-03 13:11:22 +01:00
|
|
|
FX_TYPE_CLASS(fx_assembly_class);
|
|
|
|
|
FX_TYPE_INSTANCE_PRIVATE(struct fx_assembly_p);
|
|
|
|
|
FX_TYPE_INSTANCE_INIT(assembly_init);
|
|
|
|
|
FX_TYPE_INSTANCE_FINI(assembly_fini);
|
|
|
|
|
FX_TYPE_DEFINITION_END(fx_assembly)
|
2026-05-25 17:26:08 +01:00
|
|
|
|
|
|
|
|
FX_TYPE_CLASS_BEGIN(fx_assembly_type_iterator)
|
|
|
|
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
|
|
|
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
|
|
|
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
|
|
|
|
|
|
|
|
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_iterator, FX_TYPE_ITERATOR)
|
|
|
|
|
FX_INTERFACE_ENTRY(it_move_next) = type_iterator_move_next;
|
|
|
|
|
FX_INTERFACE_ENTRY(it_get_value) = type_iterator_get_value;
|
|
|
|
|
FX_TYPE_VTABLE_INTERFACE_END(fx_iterator, FX_TYPE_ITERATOR)
|
|
|
|
|
FX_TYPE_CLASS_END(fx_assembly_type_iterator)
|
|
|
|
|
|
|
|
|
|
FX_TYPE_DEFINITION_BEGIN(fx_assembly_type_iterator)
|
|
|
|
|
FX_TYPE_ID(0x74ecb8df, 0x155d, 0x4e45, 0x96a6, 0x0f71e3ea0a1e);
|
|
|
|
|
FX_TYPE_NAME("fx.reflection.assembly.type_iterator");
|
|
|
|
|
FX_TYPE_EXTENDS(FX_TYPE_ITERATOR);
|
|
|
|
|
FX_TYPE_CLASS(fx_assembly_type_iterator_class);
|
|
|
|
|
FX_TYPE_INSTANCE_PRIVATE(struct fx_assembly_type_iterator_p);
|
|
|
|
|
FX_TYPE_DEFINITION_END(fx_assembly_type_iterator)
|
|
|
|
|
|
|
|
|
|
FX_TYPE_CLASS_BEGIN(fx_assembly_iterator)
|
|
|
|
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
|
|
|
|
FX_INTERFACE_ENTRY(to_string) = NULL;
|
|
|
|
|
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
|
|
|
|
|
|
|
|
|
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_iterator, FX_TYPE_ITERATOR)
|
|
|
|
|
FX_INTERFACE_ENTRY(it_move_next) = assembly_iterator_move_next;
|
|
|
|
|
FX_INTERFACE_ENTRY(it_get_value) = assembly_iterator_get_value;
|
|
|
|
|
FX_TYPE_VTABLE_INTERFACE_END(fx_iterator, FX_TYPE_ITERATOR)
|
|
|
|
|
FX_TYPE_CLASS_END(fx_assembly_iterator)
|
|
|
|
|
|
|
|
|
|
FX_TYPE_DEFINITION_BEGIN(fx_assembly_iterator)
|
|
|
|
|
FX_TYPE_ID(0x391f8d65, 0x9baf, 0x4941, 0xbdbe, 0xe739226f8947);
|
|
|
|
|
FX_TYPE_NAME("fx.reflection.assembly.iterator");
|
|
|
|
|
FX_TYPE_EXTENDS(FX_TYPE_ITERATOR);
|
|
|
|
|
FX_TYPE_CLASS(fx_assembly_iterator_class);
|
|
|
|
|
FX_TYPE_INSTANCE_PRIVATE(struct fx_assembly_iterator_p);
|
|
|
|
|
FX_TYPE_DEFINITION_END(fx_assembly_iterator)
|