static int symbol_import0(void *Ignore, const char *Name, int *IsRef, void **Data) { module_t *LangSymbol = module_load(0, "Lang/Symbol"); int IsRef0; module_import(LangSymbol, "_new_string", &IsRef0, (void **)&make_symbol); module_import(LangSymbol, "_add_methods", &IsRef0, (void **)&add_methods); module_setup(Symbol, 0, symbol_import); return symbol_import(0, Name, IsRef, Data); };
static uint32_t fixup_symbol_section(section_t *Section, jmp_buf *OnError) { if (Section->State == UNLOADED) { Section->State = LOADING; int IsRef; module_import(Symbol, Section->Name, &IsRef, (void **)&Section->Data); Section->State = LOADED; }; return (uint32_t)Section->Data; };
void module_init2(void) { module_t *SysModule = module_load(0, "Sys/Module"); int IsRef; module_import(SysModule, "T", &IsRef, (void **)&ModuleT); for (int I = 0; I < Modules->Size; ++I) { if (Modules->Entries[I].Key) { module_t *Module = Modules->Entries[I].Value; Module->Type = ModuleT; }; }; };
static uint32_t fixup_import_section(section_t *Section, jmp_buf *OnError) { if (Section->State == UNLOADED) { Section->State = LOADING; module_t *Module = (module_t *)Section->Library->Fixup(Section->Library, OnError); int IsRef; if (module_import(Module, Section->Name, &IsRef, (void **)&Section->Data)) { Section->State = LOADED; } else { log_errorf("Error: symbol %s not exported from %s\n", Section->Name, Section->Library->Name); longjmp(OnError, 1); }; }; return (uint32_t)Section->Data; };
static int directory_import(const char *Path, const char *Name, int *IsRef, void **Data) { static void *(*load_module)(const char *Path, const char *Name) = 0; if (load_module == 0) { module_t *SysModule = module_load(0, "Sys/Module"); int IsRef0; module_import(SysModule, "_load", &IsRef0, (void **)&load_module); }; void *Module = load_module(Path, Name); if (Module) { *IsRef = 0; *Data = Module; return 1; } else { return 0; }; };
int module_provider_import(module_provider_t *Provider, const char *Symbol, int *IsRef, void **Data) { return module_import(Provider->Module, Symbol, IsRef, Data); };
STATUS original_test_start(int argc, char *argv[]) { OBJECT *obj[6]; MODULE *network; CLASS *node, *link; MODULE *tape; CLASS *player, *recorder, *collector; network = module_load("network",argc,argv); if (network==NULL) { #ifndef WIN32 fprintf(stderr,"%s\n",dlerror()); #else perror("network module load failed"); #endif return FAILED; } output_verbose("network module loaded ok"); node = class_get_class_from_classname("node"); if (node==NULL) { output_fatal("network module does not implement class node"); /* TROUBLESHOOT The <b>network</b> module test can't find the <b>node</b> class definition. This is probably caused by either an internal system error or a version of the network module that doesn't implement node object as expected (or at all). */ return FAILED; } output_verbose("class node implementation loaded ok"); link = class_get_class_from_classname("link"); if (node==NULL || link==NULL) { output_fatal("network module does not implement class link"); /* TROUBLESHOOT The <b>network</b> module test can't find the <b>link</b> class definition. This is probably caused by either an internal system error or a version of the network module that doesn't implement link object as expected (or at all). */ return FAILED; } output_verbose("class link implementation loaded ok"); tape = module_load("tape",argc,argv); if (tape==NULL) { #ifndef WIN32 fprintf(stderr,"%s\n",dlerror()); #else perror("tape module load failed"); #endif return FAILED; } player = class_get_class_from_classname("player"); if (player==NULL) { output_fatal("tape module does not implement class player"); /* TROUBLESHOOT The <b>tape</b> module test can't find the <b>player</b> class definition. This is probably caused by either an internal system error or a version of the tape module that doesn't implement player object as expected (or at all). */ return FAILED; } recorder = class_get_class_from_classname("recorder"); if (recorder==NULL) { output_fatal("tape module does not implement class recorder"); /* TROUBLESHOOT The <b>tape</b> module test can't find the <b>recorder</b> class definition. This is probably caused by either an internal system error or a version of the tape module that doesn't implement recorder object as expected (or at all). */ return FAILED; } collector = class_get_class_from_classname("collector"); if (collector==NULL) { output_fatal("tape module does not implement class collector"); /* TROUBLESHOOT The <b>tape</b> module test can't find the <b>collector</b> class definition. This is probably caused by either an internal system error or a version of the tape module that doesn't implement collector object as expected (or at all). */ return FAILED; } if (module_import(network,"../test/pnnl2bus.cdf")<=0) return FAILED; /* tape player */ if ((*player->create)(&obj[3],object_get_first())==FAILED) { output_fatal("player creation failed"); /* TROUBLESHOOT The <b>tape</b> module test can't create a <b>player</b> object. This is probably caused by either an internal system error or a version of the tape module that doesn't implement player object as expected (or at all). */ return FAILED; } object_set_value_by_name(obj[3],"loop","3600"); /* 18000 is about 12y at 1h steps */ object_set_value_by_name(obj[3],"property","S"); /* tape recorder */ if ((*recorder->create)(&obj[4],object_get_first())==FAILED) { output_fatal("recorder creation failed"); /* TROUBLESHOOT The <b>tape</b> module test can't create a <b>recorder</b> object. This is probably caused by either an internal system error or a version of the tape module that doesn't implement recorder object as expected (or at all). */ return FAILED; } object_set_value_by_name(obj[4],"property","V,S"); object_set_value_by_name(obj[4],"interval","0"); object_set_value_by_name(obj[4],"limit","1000"); /* tape collector */ if ((*collector->create)(&obj[5],NULL)==FAILED) { output_fatal("collector creation failed"); /* TROUBLESHOOT The <b>tape</b> module test can't create a <b>collector</b> object. This is probably caused by either an internal system error or a version of the tape module that doesn't implement collector object as expected (or at all). */ return FAILED; } object_set_value_by_name(obj[5],"property","count(V.mag),min(V.mag),avg(V.mag),std(V.mag),max(V.mag),min(V.ang),avg(V.ang),std(V.ang),max(V.ang)"); object_set_value_by_name(obj[5],"interval","0"); object_set_value_by_name(obj[5],"limit","1000"); object_set_value_by_name(obj[5],"group","class=node;"); module_check(network); return SUCCESS; }