-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZTypes.h
143 lines (123 loc) · 2.87 KB
/
ZTypes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#ifndef _ZTYPES_H_
#define _ZTYPES_H_
#include <stdexcept>
#include <sstream>
#include <vector>
#include "Zlang.h"
#include <boost/variant.hpp>
#include <boost/bind.hpp>
#include <boost/lexical_cast.hpp>
#include <Eigen/Geometry>
USING_PART_OF_NAMESPACE_EIGEN
//Operations types
//
class AbOps
{
public:
AbOps(){}
};
//Numerical operations (numeric types , e.g. ints/floats/etc..)
class NumOps : public AbOps
{
public:
NumOps(const AbOps & other){}
NumOps(){}
};
//sequence operations (sequencable types , e.g. strings/arrays/etc..)
class SeqOps : public AbOps
{
public:
SeqOps(const AbOps & other){}
SeqOps(){}
};
//call operations (callable types , e.g. functions )
class CallOps : public AbOps
{
public:
CallOps(const AbOps & other){}
CallOps(){}
};
//
// ZObject : the generic container
template <class Container,class Operations>
class ZObject : public Operations
{
public:
Container* cont;
template <class C1,class P1>
ZObject ( ZObject<C1,P1> & other)
:Operations(other)
{cont=static_cast<Container*>(other.cont);}
ZObject(Container cn)
{
cont=ZAlloc(Container,1);
*cont=cn;
}
ZObject(){cont=new Container();}
};
//
class ZMemFunGenClass{};
//streamability
namespace boost
{
template <class Container,class Operations>
std::ostream& operator<<(std::ostream &stream ,const ZObject<Container,Operations> & arg)
{
return stream << a(arg);
}
}
enum ZETypes
{
ZETInt,
ZETFloat,
ZETBool,
ZETString,
ZETFunction,
ZETList,
ZETMatrix,
ZETObject,
ZETInstance,
ZETMemDataItem
};
#include "ZTDefs.h"
// Type shorthands
typedef ZObject<ZTRoot,AbOps> gZTR;
typedef ZObject<ZTInt,NumOps> gZInt;
typedef ZObject<ZTFloat,NumOps> gZFloat;
typedef ZObject<ZTBool,NumOps> gZBool;
typedef ZObject<ZTString,SeqOps> gZString;
typedef ZObject<ZTFunction,CallOps> gZFunction;
typedef ZObject<ZTList,SeqOps> gZList;
typedef ZObject<ZTMatrix,SeqOps> gZMatrix;
typedef ZObject<ZObjP,CallOps> gZObject;
typedef ZObject<ZTOInstance,CallOps> gZOInstance;
typedef ZObject<ZTMemData,CallOps> gZMemData;
// our varaint
typedef boost::variant<gZInt,gZFloat,gZBool,gZString,gZFunction,gZList,gZMatrix,gZObject,gZOInstance,gZMemData> ZTvar;
typedef ZTvar* ZTvarp;
typedef std::vector<ZTvarp> ZTvarS;
// generic member function pointer
typedef ZTvarp (ZMemFunGenClass::*ZTmfp)(ZTvarS);
typedef ZTvarp (*ZTfp)(ZTvarS);
//basic info regarding built-in modules
struct ZBuiltinModule
{
ZChar* ZModName;
void (*ZModInitFunc)(void);
};
#include "ZTRoot.h"
#include "ZTBool.h"
#include "ZTInt.h"
#include "ZTFloat.h"
#include "ZTString.h"
#include "ZTFunction.h"
#include "ZTList.h"
#include "ZTObject.h"
#include "ZTMemData.h"
#include "ZTOperations.h"
#include "ZTHelpers.h"
#include "ZErrors.h"
#include "ZTTraits.h"
#include "ZTBridge.h"
#include "ZTMatrix.h"
#endif