mirror of
https://github.com/pevans/erc-c.git
synced 2024-12-21 23:29:16 +00:00
Use the DI container to get machine/cpu/etc
This commit is contained in:
parent
c35a6cb827
commit
360e9243f8
@ -70,7 +70,7 @@ extern int vm_reflect_disasm_on(vm_reflect *);
|
||||
extern int vm_reflect_machine_info(vm_reflect *);
|
||||
extern int vm_reflect_pause(vm_reflect *);
|
||||
extern int vm_reflect_resume(vm_reflect *);
|
||||
extern vm_reflect *vm_reflect_create(void *, void *, FILE *);
|
||||
extern vm_reflect *vm_reflect_create();
|
||||
extern void vm_reflect_free(vm_reflect *);
|
||||
|
||||
#endif
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "vm_di.h"
|
||||
#include "vm_reflect.h"
|
||||
|
||||
/*
|
||||
@ -12,7 +13,7 @@
|
||||
* stream.
|
||||
*/
|
||||
vm_reflect *
|
||||
vm_reflect_create(void *mach, void *cpu, FILE *stream)
|
||||
vm_reflect_create()
|
||||
{
|
||||
vm_reflect *ref;
|
||||
|
||||
@ -22,9 +23,9 @@ vm_reflect_create(void *mach, void *cpu, FILE *stream)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ref->machine = mach;
|
||||
ref->cpu = cpu;
|
||||
ref->stream = stream;
|
||||
ref->machine = vm_di_get(VM_MACHINE);
|
||||
ref->cpu = vm_di_get(VM_CPU);
|
||||
ref->stream = vm_di_get(VM_OUTPUT);
|
||||
|
||||
ref->cpu_info = NULL;
|
||||
ref->machine_info = NULL;
|
||||
@ -52,6 +53,7 @@ vm_reflect_free(vm_reflect *ref)
|
||||
*/
|
||||
#define REFLECT_HANDLER(x) \
|
||||
int vm_reflect_##x(vm_reflect *ref) { \
|
||||
if (ref == NULL) ref = (vm_reflect *)vm_di_get(VM_REFLECT); \
|
||||
if (ref->x == NULL) return ERR_INVALID; ref->x(ref); return OK; }
|
||||
|
||||
REFLECT_HANDLER(cpu_info); // ignore docblock
|
||||
|
Loading…
Reference in New Issue
Block a user