forked from zrax/pycdc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyc_sequence.h
93 lines (63 loc) · 2.21 KB
/
pyc_sequence.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
#ifndef _PYC_SEQUENCE_H
#define _PYC_SEQUENCE_H
#include "pyc_object.h"
#include <vector>
#include <list>
#include <set>
class PycSequence : public PycObject {
public:
PycSequence(int type) : PycObject(type), m_size(0) { }
int size() const { return m_size; }
virtual PycRef<PycObject> get(int idx) const = 0;
protected:
int m_size;
};
class PycTuple : public PycSequence {
public:
typedef std::vector<PycRef<PycObject> > value_t;
PycTuple(int type = TYPE_TUPLE) : PycSequence(type) { }
bool isEqual(PycRef<PycObject> obj) const override;
void load(class PycData* stream, class PycModule* mod) override;
const value_t& values() const { return m_values; }
PycRef<PycObject> get(int idx) const override { return m_values.at(idx); }
private:
value_t m_values;
};
class PycList : public PycSequence {
public:
typedef std::list<PycRef<PycObject> > value_t;
PycList(int type = TYPE_LIST) : PycSequence(type) { }
bool isEqual(PycRef<PycObject> obj) const override;
void load(class PycData* stream, class PycModule* mod) override;
const value_t& values() const { return m_values; }
PycRef<PycObject> get(int idx) const override;
private:
value_t m_values;
};
class PycDict : public PycSequence {
public:
typedef std::list<PycRef<PycObject> > key_t;
typedef std::list<PycRef<PycObject> > value_t;
PycDict(int type = TYPE_DICT) : PycSequence(type) { }
bool isEqual(PycRef<PycObject> obj) const override;
void load(class PycData* stream, class PycModule* mod) override;
PycRef<PycObject> get(PycRef<PycObject> key) const;
const key_t& keys() const { return m_keys; }
const value_t& values() const { return m_values; }
PycRef<PycObject> get(int idx) const override;
private:
key_t m_keys;
value_t m_values;
};
class PycSet : public PycSequence {
public:
typedef std::set<PycRef<PycObject> > value_t;
PycSet(int type = TYPE_SET) : PycSequence(type) { }
bool isEqual(PycRef<PycObject> obj) const override;
void load(class PycData* stream, class PycModule* mod) override;
const value_t& values() const { return m_values; }
PycRef<PycObject> get(int idx) const override;
private:
value_t m_values;
};
#endif