mirror of
https://github.com/sigmasternchen/crap-libs
synced 2025-03-15 07:38:56 +00:00
some exceptions
This commit is contained in:
parent
fb73a9f720
commit
c09f20d06b
2 changed files with 56 additions and 3 deletions
|
@ -2,16 +2,15 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
class_t Exception_class;
|
||||
void method(Exception, destruct)(Exception_t* this) {
|
||||
this->super.destruct((Object_t*) this);
|
||||
}
|
||||
|
||||
void method(Exception, populate)(Exception_t* obj, class_t c) {
|
||||
populate(Object)((Object_t*) obj, c);
|
||||
|
||||
add_method(obj, Exception, destruct);
|
||||
}
|
||||
|
||||
Exception_t* method(Exception, construct)(const char* msg) {
|
||||
Exception_t* obj = malloc(sizeof(Exception_t));
|
||||
populate(Exception)(obj, Exception_class);
|
||||
|
@ -20,3 +19,37 @@ Exception_t* method(Exception, construct)(const char* msg) {
|
|||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
class_t NullPointerException_class;
|
||||
void method(NullPointerException, destruct)(NullPointerException_t* this) {
|
||||
this->super.destruct((Exception_t*) this);
|
||||
}
|
||||
void method(NullPointerException, populate)(NullPointerException_t* obj, class_t c) {
|
||||
populate(Exception)((Exception_t*) obj, c);
|
||||
|
||||
add_method(obj, NullPointerException, destruct);
|
||||
}
|
||||
NullPointerException_t* method(NullPointerException, construct)() {
|
||||
NullPointerException_t* obj = malloc(sizeof(Exception_t));
|
||||
populate(NullPointerException)(obj, NullPointerException_class);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
class_t OutOfMemoryException_class;
|
||||
void method(OutOfMemoryException, destruct)(OutOfMemoryException_t* this) {
|
||||
this->super.destruct((Exception_t*) this);
|
||||
}
|
||||
void method(OutOfMemoryException, populate)(OutOfMemoryException_t* obj, class_t c) {
|
||||
populate(Exception)((Exception_t*) obj, c);
|
||||
|
||||
add_method(obj, OutOfMemoryException, destruct);
|
||||
}
|
||||
OutOfMemoryException_t* method(OutOfMemoryException, construct)() {
|
||||
OutOfMemoryException_t* obj = malloc(sizeof(Exception_t));
|
||||
populate(OutOfMemoryException)(obj, OutOfMemoryException_class);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "../../oop/oop.h"
|
||||
|
||||
#define Exception construct(Exception)
|
||||
class(Exception, Object_class, NO_INTERFACES, true) {
|
||||
extern class(Exception, Object_class, NO_INTERFACES, true) {
|
||||
extends(Object_t);
|
||||
|
||||
const char* msg;
|
||||
|
@ -15,4 +15,24 @@ class(Exception, Object_class, NO_INTERFACES, true) {
|
|||
void method(Exception, populate)(Exception_t*, class_t);
|
||||
Exception_t* method(Exception, construct)(const char*);
|
||||
|
||||
#define NullPointerException construct(NullPointerException)
|
||||
extern class(NullPointerException, Exception_class, NO_INTERFACES, true) {
|
||||
extends(Exception_t);
|
||||
|
||||
void (*destruct)(defclass NullPointerException*);
|
||||
} NullPointerException_t;
|
||||
|
||||
void method(NullPointerException, populate)(NullPointerException_t*, class_t);
|
||||
NullPointerException_t* method(NullPointerException, construct)(void);
|
||||
|
||||
#define OutOfMemoryException construct(OutOfMemoryException)
|
||||
extern class(OutOfMemoryException, Exception_class, NO_INTERFACES, true) {
|
||||
extends(Exception_t);
|
||||
|
||||
void (*destruct)(defclass OutOfMemoryException*);
|
||||
} OutOfMemoryException_t;
|
||||
|
||||
void method(OutOfMemoryException, populate)(OutOfMemoryException_t*, class_t);
|
||||
OutOfMemoryException_t* method(OutOfMemoryException, construct)(void);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue