Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef VARIABLE_H
- #define VARIABLE_H
- #include "reflection.h"
- #include "meta_generated.h"
- #define MEMBER_VARIABLE( variable, member ) Variable( MemberType( member ), PTR_ADD( variable->data, member->offset ) )
- //--------------------------------------------------------------------------------------------------
- struct variable
- {
- TypeInfo* type;
- void* data;
- };
- //--------------------------------------------------------------------------------------------------
- inline variable Variable( TypeInfo* type, void* data )
- {
- variable v;
- v.type = type;
- v.data = data;
- return v;
- }
- //--------------------------------------------------------------------------------------------------
- template < typename T >
- inline variable Variable( T& data )
- {
- variable v;
- v.type = TypeOf( data );
- v.data = &data;
- return v;
- }
- //--------------------------------------------------------------------------------------------------
- template < typename T >
- inline T& Value( variable& v )
- {
- return *(T*)v.data;
- }
- //--------------------------------------------------------------------------------------------------
- template < typename T >
- inline T& Value( variable* v )
- {
- return *(T*)v->data;
- }
- #endif // VARIABLE_H
Advertisement
Add Comment
Please, Sign In to add comment