feat: variant now uses mirror and drop to manage objects
parent
640ed84c1d
commit
cccec929bc
12
variant.c
12
variant.c
|
@ -1,8 +1,10 @@
|
|||
#include "variant.h"
|
||||
#include "debug.h"
|
||||
#include "ctype.h"
|
||||
#include "mirror.h"
|
||||
#include "string.h"
|
||||
#include "strutil.h"
|
||||
#include "drop.h"
|
||||
#include "debug.h"
|
||||
|
||||
Variant variant_from_str(const char* str) {
|
||||
size_t length = strlen(str);
|
||||
|
@ -54,8 +56,12 @@ void destroy_contained(Variant* self) {
|
|||
self->as_string = NULL;
|
||||
break;
|
||||
case Variant_Object:
|
||||
free(self->as_object);
|
||||
self->as_object = NULL;
|
||||
if(TC_MIRRORS(self->as_object, Drop)) {
|
||||
Drop drop = TC_CAST(self->as_object, Drop);
|
||||
drop.tc->drop(drop.data);
|
||||
}
|
||||
self->as_object.data = NULL;
|
||||
self->as_object.tc = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define _fencer_variant_h
|
||||
|
||||
#include "vmath.h"
|
||||
#include "mirror.h"
|
||||
|
||||
typedef enum VariantType {
|
||||
Variant_Undefined = 0x0,
|
||||
|
@ -17,7 +18,7 @@ typedef struct Variant {
|
|||
union {
|
||||
double as_number;
|
||||
Vector as_vector;
|
||||
void* as_object;
|
||||
Mirror as_object;
|
||||
char* as_string;
|
||||
};
|
||||
} Variant;
|
||||
|
|
Loading…
Reference in New Issue