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