2009-07-24 08:35:21 +00:00
|
|
|
#ifndef _PYC_SEQUENCE_H
|
|
|
|
#define _PYC_SEQUENCE_H
|
|
|
|
|
2011-10-23 17:48:10 -07:00
|
|
|
#include "pyc_object.h"
|
2023-11-09 15:05:55 -08:00
|
|
|
#include <tuple>
|
2009-07-24 08:35:21 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2009-07-24 23:19:46 +00:00
|
|
|
class PycSequence : public PycObject {
|
|
|
|
public:
|
2024-03-12 22:55:56 +02:00
|
|
|
PycSequence(int type) : PycObject(type), m_size(0) { }
|
2009-07-24 23:19:46 +00:00
|
|
|
|
|
|
|
int size() const { return m_size; }
|
|
|
|
virtual PycRef<PycObject> get(int idx) const = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int m_size;
|
|
|
|
};
|
|
|
|
|
2023-02-16 22:10:44 -08:00
|
|
|
class PycSimpleSequence : public PycSequence {
|
2009-07-24 08:35:21 +00:00
|
|
|
public:
|
2022-12-01 11:35:14 -08:00
|
|
|
typedef std::vector<PycRef<PycObject>> value_t;
|
2009-07-24 08:35:21 +00:00
|
|
|
|
2024-03-12 22:55:56 +02:00
|
|
|
PycSimpleSequence(int type) : PycSequence(type) { }
|
2009-07-24 08:35:21 +00:00
|
|
|
|
2019-10-02 14:40:25 -07:00
|
|
|
bool isEqual(PycRef<PycObject> obj) const override;
|
2009-07-24 21:15:51 +00:00
|
|
|
|
2019-10-02 14:40:25 -07:00
|
|
|
void load(class PycData* stream, class PycModule* mod) override;
|
2009-07-24 08:35:21 +00:00
|
|
|
|
2009-07-27 00:23:49 +00:00
|
|
|
const value_t& values() const { return m_values; }
|
2019-10-02 14:40:25 -07:00
|
|
|
PycRef<PycObject> get(int idx) const override { return m_values.at(idx); }
|
2009-07-24 08:35:21 +00:00
|
|
|
|
2023-02-16 22:10:44 -08:00
|
|
|
protected:
|
2009-07-24 08:35:21 +00:00
|
|
|
value_t m_values;
|
|
|
|
};
|
|
|
|
|
2023-02-16 22:10:44 -08:00
|
|
|
class PycTuple : public PycSimpleSequence {
|
2009-07-24 08:35:21 +00:00
|
|
|
public:
|
2023-02-16 22:10:44 -08:00
|
|
|
typedef PycSimpleSequence::value_t value_t;
|
2024-03-12 22:55:56 +02:00
|
|
|
PycTuple(int type = TYPE_TUPLE) : PycSimpleSequence(type) { }
|
2009-07-24 21:15:51 +00:00
|
|
|
|
2019-10-02 14:40:25 -07:00
|
|
|
void load(class PycData* stream, class PycModule* mod) override;
|
2023-02-16 22:10:44 -08:00
|
|
|
};
|
2009-07-24 21:15:51 +00:00
|
|
|
|
2023-02-16 22:10:44 -08:00
|
|
|
class PycList : public PycSimpleSequence {
|
|
|
|
public:
|
|
|
|
typedef PycSimpleSequence::value_t value_t;
|
2024-03-12 22:55:56 +02:00
|
|
|
PycList(int type = TYPE_LIST) : PycSimpleSequence(type) { }
|
2009-07-24 21:15:51 +00:00
|
|
|
};
|
|
|
|
|
2023-11-09 14:20:15 -08:00
|
|
|
class PycSet : public PycSimpleSequence {
|
|
|
|
public:
|
|
|
|
typedef PycSimpleSequence::value_t value_t;
|
2024-03-12 22:55:56 +02:00
|
|
|
PycSet(int type = TYPE_SET) : PycSimpleSequence(type) { }
|
2023-11-09 14:20:15 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
class PycDict : public PycObject {
|
2009-07-24 21:15:51 +00:00
|
|
|
public:
|
2023-11-09 15:05:55 -08:00
|
|
|
typedef std::tuple<PycRef<PycObject>, PycRef<PycObject>> item_t;
|
|
|
|
typedef std::vector<item_t> value_t;
|
2009-07-24 21:15:51 +00:00
|
|
|
|
2024-03-12 22:55:56 +02:00
|
|
|
PycDict(int type = TYPE_DICT) : PycObject(type) { }
|
2009-07-24 21:15:51 +00:00
|
|
|
|
2019-10-02 14:40:25 -07:00
|
|
|
bool isEqual(PycRef<PycObject> obj) const override;
|
2009-07-24 21:15:51 +00:00
|
|
|
|
2019-10-02 14:40:25 -07:00
|
|
|
void load(class PycData* stream, class PycModule* mod) override;
|
2009-07-24 08:35:21 +00:00
|
|
|
|
2009-07-27 00:23:49 +00:00
|
|
|
const value_t& values() const { return m_values; }
|
2009-07-24 08:35:21 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
value_t m_values;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|