#include "assert.h" #include "commandline/parameters.h" #include "interpreter/parameters/parameters.h" #include "memory/virtualmemory.h" #include "object.h" #include "resources/categories.h" #include "types/attributes.h" #include "types/composites/composites.h" #include "types/composites/dictionary.h" #include "types/typestrings.h" static object prefix(const object device) { object string = stringfrom(device); assert(string.length >= 2); assert(string.string); assert(string.string[0] == '%'); if (string.string[string.length - 1] != '%') { if (string.length >= longestname) throw (limitcheck); string = copy[stringtype](string, memory(longestname)); string.string[string.length++] = '%'; return cvn(string); } else { return device; } } object defineIODevice(const configure interpreter) { const object Instances = create[dicttype](0); for (const object *entry = 0; entry = iterate(category(Dev), entry ? entry[key] : null);) { const object instance = prefix(entry[key]); put[dicttype](instance, instance, Instances); } return readonly(compile( defineGeneric(interpreter), array(((object []){ cvn(string("Category")), cvn(string("IODevice")), cvn(string("InstanceType")), cvn(typestring((object){.type = nametype})), cvn(string("globalinstances")), readonly(Instances) })) )); }