#ifndef DEF_INTERFACE_H #define DEF_INTERFACE_H #include #include #include struct _Object; struct _NumberedMethod; typedef struct _Interface { char* name; int method_count; int public_method_count; struct _NumberedMethod *numberedMethods; int *methodNumbers; } Interface; typedef struct _NumberedMethod { Interface *iface; int numberInIface; } NumberedMethod; typedef int (*MethodPtr)(struct _Object* object, struct process* process, size_t a, size_t b, size_t c, size_t d); typedef struct _Object* (*FindChildPtr)(struct _Object *object, const char* name); typedef int (*OpenPtr)(struct _Object *object, struct process *process); typedef void (*ClosedPtr)(struct _Object *object); typedef void (*DeletePtr)(struct _Object *object); typedef struct _InterfaceImpl { Interface *interface; MethodPtr *methods; } InterfaceImpl; // == typedef struct _Class { char *name; FindChildPtr findChild; OpenPtr open; // optionnal - if 0, always success ClosedPtr closed; // optionnal DeletePtr deleted; // optionnal but should be implemented InterfaceImpl interfaces[]; // zero-terminated list } Class; typedef struct _Object { Class *_class; void *data; int handles; // reference counter } Object; // void setup_object_system(); void Class_setup(Class* _class); void Interface_setup(Interface* iface); MethodPtr* Class_getInterfaceImpl(Class *_class, Interface *iface); Object* Object_get(Object *parent, char *path); Object *rootObject, *deviceListObject; // syscalls int open(char* name); int open_relative(char* name, int root_handle); void close(size_t handle); int get_methods(char* iface_name, int* whereto); Object* read_handle(struct process *proc, size_t handle); void do_method_call(struct registers *regs); #endif