Files
BlitzNext/Runtime/lib/bb_basic.hpp
T

85 lines
1.5 KiB
C++
Raw Normal View History

2019-01-18 21:26:57 +01:00
#pragma once
2014-01-31 08:23:00 +13:00
2019-01-18 17:04:17 +01:00
enum {
BBTYPE_END = 0,
BBTYPE_INT = 1,
BBTYPE_FLOAT = 2,
BBTYPE_STRING = 3,
BBTYPE_CSTR = 4,
BBTYPE_OBJECT = 5,
BBTYPE_VECTOR = 6
2014-01-31 08:23:00 +13:00
};
2019-01-18 17:04:17 +01:00
typedef int bbInt;
typedef float bbFloat;
typedef bbStringhandle* bbString;
typedef bbObjectHandle* bbObject;
typedef bbVectorHandle* bbVector;
typedef const char* bbCStr;
2014-01-31 08:23:00 +13:00
2019-01-18 17:04:17 +01:00
union bbValue {
bbInt INT;
bbFloat FLOAT;
2014-01-31 08:23:00 +13:00
bbString STRING;
bbObject OBJECT;
bbVector VECTOR;
2019-01-18 17:04:17 +01:00
bbCStr CSTR;
2014-01-31 08:23:00 +13:00
};
2019-01-18 17:04:17 +01:00
struct bbType {
2014-01-31 08:23:00 +13:00
int id;
bbType( int n ):id(n(){}
};
2019-01-18 17:04:17 +01:00
struct bbInstance {
2014-01-31 08:23:00 +13:00
bbValue value;
};
2019-01-18 17:04:17 +01:00
struct bbHandle {
bbInstance* instance;
int ref_cnt;
bbType* type;
2014-01-31 08:23:00 +13:00
};
2019-01-18 17:04:17 +01:00
struct bbEnviron {
bbVector* variables;
2014-01-31 08:23:00 +13:00
};
2019-01-18 17:04:17 +01:00
struct bbIntType : public bbType {
bbInt() : bbType(BBTYPE_INT) {}
2014-01-31 08:23:00 +13:00
};
2019-01-18 17:04:17 +01:00
struct bbFloatType : public bbType {
bbFloat() : bbType(BBTYPE_FLOAT) {}
2014-01-31 08:23:00 +13:00
};
2019-01-18 17:04:17 +01:00
struct bbCStrType : public bbType {
bbCStrType() : bbType(BBTYPE_CSTR) {}
2014-01-31 08:23:00 +13:00
};
2019-01-18 17:04:17 +01:00
struct bbStringType : public bbType {
bbStringType() : bbType(BBTYPE_STRING) {}
2014-01-31 08:23:00 +13:00
};
2019-01-18 17:04:17 +01:00
struct bbVectorType : public bbType {
bbType* element_type;
bbVectorType(bbType* e) : bbType(BBTYPE_VECTOR), element_type(e) {}
2014-01-31 08:23:00 +13:00
}
2019-01-18 17:04:17 +01:00
struct bbObjectType : public bbType {
bbEnviron* environ;
bbObject * first_used, *last_used;
bbObject * first_free, *last_free;
bbObjectType(bbEnviron* e) : bbType(BBTYPE_OBJECT), environ(e) {}
2014-01-31 08:23:00 +13:00
};
2019-01-18 17:04:17 +01:00
struct bbStringHandle : public bbHandle {};
2014-01-31 08:23:00 +13:00
2019-01-18 17:04:17 +01:00
struct bbObjectHandle : public bbHandle {
bbObject *next, *prev;
2014-01-31 08:23:00 +13:00
};
2019-01-18 17:04:17 +01:00
struct bbVectorHandle : public bbHandle {};
2014-01-31 08:23:00 +13:00
2019-01-18 17:04:17 +01:00
void assign(bbHandleVariable dest, bbHandle src);