summaryrefslogtreecommitdiff
path: root/src/editor/properties.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/editor/properties.h')
-rw-r--r--src/editor/properties.h35
1 files changed, 30 insertions, 5 deletions
diff --git a/src/editor/properties.h b/src/editor/properties.h
index 810c075..d4fc3bb 100644
--- a/src/editor/properties.h
+++ b/src/editor/properties.h
@@ -6,6 +6,7 @@
#include <math.h>
#include "../util/string.h"
#include "../util/fnv.h"
+#include "../util/profiler.h"
#define EPROP( _type, name, value, display ) \
_type name = value; \
@@ -90,6 +91,7 @@ struct EOBJECT {
LIST<EPROP_ENTRY> eprops{};
};
+
template <typename T>
concept __eobject_base = __is_base_of(EOBJECT, T);
@@ -112,6 +114,7 @@ struct EDITOR_PROP {
_parent->eprops.push( { offset } );
+ parentoff = pdata - parent;
offset = _this - pdata;
dataoff = offset;
}
@@ -133,6 +136,7 @@ struct EDITOR_PROP {
_parent->eprops.push( { offset } );
+ parentoff = pdata - parent;
offset = _this - pdata;
dataoff = offset;
}
@@ -154,6 +158,7 @@ struct EDITOR_PROP {
_parent->eprops.push( { offset } );
+ parentoff = pdata - parent;
offset = _this - pdata;
dataoff = offset;
}
@@ -175,11 +180,13 @@ struct EDITOR_PROP {
_parent->eprops.push( { offset } );
+ parentoff = pdata - parent;
offset = _this - pdata;
dataoff = offset;
}
U64 dataoff;
+ U64 parentoff;
U8 type;
STR displayname;
F64 min{ -INFINITY };
@@ -220,22 +227,40 @@ inline EDITOR_PROP* eprop_from_ref( EOBJECT* obj, EPROP_ENTRY e ) {
return (EDITOR_PROP*)( (U64)obj + e.offset );
}
+inline EDITOR_PROP* eprop_from_ptr( EOBJECT* obj, void* ptr ) {
+ if( (U64)ptr < (U64)obj ) {
+ trace( "eprop_from_ptr() : error : invalid pointer access, obj = %llx, ptr = %llx\n", (U64)obj, (U64)ptr );
+ return 0;
+ }
+
+ U64 off = ( (U64)ptr - (U64)obj );
+ for( auto& it : obj->eprops ) {
+ EDITOR_PROP* p = eprop_from_ref( obj, it );
+ if( off == p->parentoff )
+ return p;
+ }
+
+ return 0;
+}
+
inline void* eprop_ptr( EDITOR_PROP* prop ) {
return (void*)( (U64)prop - prop->dataoff);
}
-inline EDITOR_PROP* eprop_from_name( EOBJECT* obj, STR name ) {
- FNV1A fnv = fnv1a( name );
-
+inline EDITOR_PROP* eprop_from_hash( EOBJECT* obj, FNV1A hash ) {
for( auto& it : obj->eprops ) {
EDITOR_PROP* prop = eprop_from_ref( obj, it );
- if( fnv == prop->hash )
+ if( hash == prop->hash )
return prop;
}
-
return 0;
}
+inline EDITOR_PROP* eprop_from_name( EOBJECT* obj, STR name ) {
+ FNV1A fnv = fnv1a( name );
+ return eprop_from_hash( obj, fnv );
+}
+
template <typename T>
const U8 eprop_type() {
return EDITOR_PROP::__eprop_type<T>::type;