Compare commits
No commits in common. "4f9ff698019b26a5600f0d0ea9f73f280ac2c2e7" and "cd906be4c958789a42542889eee6203667666426" have entirely different histories.
4f9ff69801
...
cd906be4c9
|
@ -1,14 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <variant>
|
||||
#include "datatypes/primitives.h"
|
||||
|
||||
typedef std::variant<VoidData, BoolData, StringData, IntData, FloatData> DataValue;
|
||||
|
||||
enum class DataType {
|
||||
VOID = 0,
|
||||
BOOL = 1,
|
||||
STRING = 2,
|
||||
INT = 3,
|
||||
FLOAT = 4
|
||||
};
|
|
@ -1,11 +0,0 @@
|
|||
#include "primitives.h"
|
||||
|
||||
#define IMPL_WRAPPER_CLASS(CLASS_NAME, WRAPPED_TYPE) CLASS_NAME::CLASS_NAME(WRAPPED_TYPE in) : wrapped(in) {}\
|
||||
CLASS_NAME::operator WRAPPED_TYPE() { return wrapped; }
|
||||
|
||||
VoidData::VoidData() {};
|
||||
|
||||
IMPL_WRAPPER_CLASS(BoolData, bool)
|
||||
IMPL_WRAPPER_CLASS(IntData, int)
|
||||
IMPL_WRAPPER_CLASS(FloatData, float)
|
||||
IMPL_WRAPPER_CLASS(StringData, std::string)
|
|
@ -1,22 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#define DEF_WRAPPER_CLASS(CLASS_NAME, WRAPPED_TYPE) class CLASS_NAME {\
|
||||
WRAPPED_TYPE wrapped;\
|
||||
public:\
|
||||
CLASS_NAME(WRAPPED_TYPE); \
|
||||
operator WRAPPED_TYPE(); \
|
||||
};
|
||||
|
||||
class VoidData {
|
||||
public:
|
||||
VoidData();
|
||||
};
|
||||
|
||||
DEF_WRAPPER_CLASS(BoolData, bool)
|
||||
DEF_WRAPPER_CLASS(IntData, int)
|
||||
DEF_WRAPPER_CLASS(FloatData, float)
|
||||
DEF_WRAPPER_CLASS(StringData, std::string)
|
||||
|
||||
#undef DEF_WRAPPER_CLASS
|
|
@ -1,59 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "../../datatype.h"
|
||||
|
||||
class Instance;
|
||||
typedef Instance(*InstanceConstructor)();
|
||||
|
||||
const uint INST_NOT_CREATABLE = 1;
|
||||
// const uint INST_SINGLETON = 2;
|
||||
|
||||
typedef uint InstanceClassFlags;
|
||||
|
||||
struct InstanceClassDescriptor {
|
||||
std::string className;
|
||||
InstanceConstructor constructor;
|
||||
InstanceClassFlags flags;
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
const uint PROP_READONLY = 1;
|
||||
const uint PROP_NOSCRIPT = 2; // Cannot be read or written to by unpriveleged scripts
|
||||
const uint PROP_NOSAVE = 4; // Property should not be serialized by the engine
|
||||
const uint PROP_CLIENTONLY = 8; // Only accessible by the client
|
||||
|
||||
typedef uint PropertyFlags;
|
||||
|
||||
typedef DataValue(*InstancePropertyGetter)();
|
||||
typedef void(*InstancePropertySetter)(DataValue);
|
||||
|
||||
// Properties may either have a backing field directly accessed by Instance,
|
||||
// or, for more granular control may define a getter (and setter if writable).
|
||||
struct MemberPropertyDescriptor {
|
||||
DataType dataType;
|
||||
PropertyFlags flags;
|
||||
std::optional<DataValue*> backingField;
|
||||
std::optional<InstancePropertyGetter> getter;
|
||||
std::optional<InstancePropertySetter> setter;
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
typedef DataValue(*InstanceMethodHandler)(std::vector<DataValue>);
|
||||
|
||||
struct MemberMethodDescriptor {
|
||||
DataType returnType;
|
||||
// This may need to be converted into a vector in the future for overloaded methods
|
||||
std::vector<DataType> parameters;
|
||||
InstanceMethodHandler handler;
|
||||
};
|
||||
|
||||
// TODO: Add MemberCallbackDescriptor
|
||||
typedef std::map<std::string, std::variant<MemberPropertyDescriptor, MemberMethodDescriptor /*, MemberEventDescriptor */ /* , MemberCallbackDescriptor */>> InstanceMemberTable;
|
Loading…
Reference in a new issue