Start requring C++11 with explicit virtual overrides.

This commit is contained in:
Michael Hansen
2019-10-02 14:40:25 -07:00
parent f02a339072
commit 8d3752b4f0
7 changed files with 42 additions and 40 deletions

View File

@@ -144,7 +144,7 @@ public:
ASTCompare(PycRef<ASTNode> left, PycRef<ASTNode> right, int op)
: ASTBinary(left, right, op, NODE_COMPARE) { }
const char* op_str() const;
const char* op_str() const override;
};
@@ -556,7 +556,6 @@ private:
};
class ASTLoadBuildClass : public ASTNode {
public:
ASTLoadBuildClass(PycRef<PycObject> obj)

View File

@@ -1,5 +1,8 @@
project(pycdc)
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.1)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# For generating the bytes tables
find_package(PythonInterp REQUIRED)

16
data.h
View File

@@ -29,11 +29,11 @@ public:
PycFile(const char* filename);
~PycFile() { if (m_stream) fclose(m_stream); }
bool isOpen() const { return (m_stream != 0); }
bool atEof() const;
bool isOpen() const override { return (m_stream != 0); }
bool atEof() const override;
int getByte();
int getBuffer(int bytes, void* buffer);
int getByte() override;
int getBuffer(int bytes, void* buffer) override;
private:
FILE* m_stream;
@@ -45,11 +45,11 @@ public:
: m_buffer((const unsigned char*)buffer), m_size(size), m_pos(0) { }
~PycBuffer() { }
bool isOpen() const { return (m_buffer != 0); }
bool atEof() const { return (m_pos == m_size); }
bool isOpen() const override { return (m_buffer != 0); }
bool atEof() const override { return (m_pos == m_size); }
int getByte();
int getBuffer(int bytes, void* buffer);
int getByte() override;
int getBuffer(int bytes, void* buffer) override;
private:
const unsigned char* m_buffer;

View File

@@ -31,7 +31,7 @@ public:
: PycObject(type), m_argCount(0), m_kwOnlyArgCount(0), m_numLocals(0),
m_stackSize(0), m_flags(0), m_firstLine(0) { }
void load(class PycData* stream, class PycModule* mod);
void load(class PycData* stream, class PycModule* mod) override;
int argCount() const { return m_argCount; }
int kwOnlyArgCount() const { return m_kwOnlyArgCount; }

View File

@@ -11,13 +11,13 @@ public:
PycInt(int value = 0, int type = TYPE_INT)
: PycObject(type), m_value(value) { }
bool isEqual(PycRef<PycObject> obj) const
bool isEqual(PycRef<PycObject> obj) const override
{
return (type() == obj.type()) &&
(m_value == obj.cast<PycInt>()->m_value);
}
void load(class PycData* stream, class PycModule* mod);
void load(class PycData* stream, class PycModule* mod) override;
int value() const { return m_value; }
@@ -30,9 +30,9 @@ public:
PycLong(int type = TYPE_LONG)
: PycObject(type), m_size(0) { }
bool isEqual(PycRef<PycObject> obj) const;
bool isEqual(PycRef<PycObject> obj) const override;
void load(class PycData* stream, class PycModule* mod);
void load(class PycData* stream, class PycModule* mod) override;
int size() const { return m_size; }
const std::list<int>& value() const { return m_value; }
@@ -49,11 +49,11 @@ public:
PycFloat(int type = TYPE_FLOAT)
: PycObject(type), m_value(0) { }
~PycFloat() { if (m_value) delete[] m_value; }
~PycFloat() { delete[] m_value; }
bool isEqual(PycRef<PycObject> obj) const;
bool isEqual(PycRef<PycObject> obj) const override;
void load(class PycData* stream, class PycModule* mod);
void load(class PycData* stream, class PycModule* mod) override;
const char* value() const { return m_value; }
@@ -66,11 +66,11 @@ public:
PycComplex(int type = TYPE_COMPLEX)
: PycFloat(type), m_imag(0) { }
~PycComplex() { if (m_imag) delete[] m_imag; }
~PycComplex() { delete[] m_imag; }
bool isEqual(PycRef<PycObject> obj) const;
bool isEqual(PycRef<PycObject> obj) const override;
void load(class PycData* stream, class PycModule* mod);
void load(class PycData* stream, class PycModule* mod) override;
const char* imag() const { return m_imag; }
@@ -83,13 +83,13 @@ public:
PycCFloat(int type = TYPE_BINARY_FLOAT)
: PycObject(type), m_value(0.0) { }
bool isEqual(PycRef<PycObject> obj) const
bool isEqual(PycRef<PycObject> obj) const override
{
return (type() == obj.type()) &&
(m_value == obj.cast<PycCFloat>()->m_value);
}
void load(class PycData* stream, class PycModule* mod);
void load(class PycData* stream, class PycModule* mod) override;
double value() const { return m_value; }
@@ -102,13 +102,13 @@ public:
PycCComplex(int type = TYPE_BINARY_COMPLEX)
: PycCFloat(type), m_imag(0.0) { }
bool isEqual(PycRef<PycObject> obj) const
bool isEqual(PycRef<PycObject> obj) const override
{
return (PycCFloat::isEqual(obj)) &&
(m_imag == obj.cast<PycCComplex>()->m_imag);
}
void load(class PycData* stream, class PycModule* mod);
void load(class PycData* stream, class PycModule* mod) override;
double imag() const { return m_imag; }

View File

@@ -23,12 +23,12 @@ public:
PycTuple(int type = TYPE_TUPLE) : PycSequence(type) { }
bool isEqual(PycRef<PycObject> obj) const;
bool isEqual(PycRef<PycObject> obj) const override;
void load(class PycData* stream, class PycModule* mod);
void load(class PycData* stream, class PycModule* mod) override;
const value_t& values() const { return m_values; }
PycRef<PycObject> get(int idx) const { return m_values.at(idx); }
PycRef<PycObject> get(int idx) const override { return m_values.at(idx); }
private:
value_t m_values;
@@ -40,12 +40,12 @@ public:
PycList(int type = TYPE_LIST) : PycSequence(type) { }
bool isEqual(PycRef<PycObject> obj) const;
bool isEqual(PycRef<PycObject> obj) const override;
void load(class PycData* stream, class PycModule* mod);
void load(class PycData* stream, class PycModule* mod) override;
const value_t& values() const { return m_values; }
PycRef<PycObject> get(int idx) const;
PycRef<PycObject> get(int idx) const override;
private:
value_t m_values;
@@ -58,15 +58,15 @@ public:
PycDict(int type = TYPE_DICT) : PycSequence(type) { }
bool isEqual(PycRef<PycObject> obj) const;
bool isEqual(PycRef<PycObject> obj) const override;
void load(class PycData* stream, class PycModule* mod);
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;
PycRef<PycObject> get(int idx) const override;
private:
key_t m_keys;
@@ -79,12 +79,12 @@ public:
PycSet(int type = TYPE_SET) : PycSequence(type) { }
bool isEqual(PycRef<PycObject> obj) const;
bool isEqual(PycRef<PycObject> obj) const override;
void load(class PycData* stream, class PycModule* mod);
void load(class PycData* stream, class PycModule* mod) override;
const value_t& values() const { return m_values; }
PycRef<PycObject> get(int idx) const;
PycRef<PycObject> get(int idx) const override;
private:
value_t m_values;

View File

@@ -12,10 +12,10 @@ public:
~PycString() { delete[] m_value; }
bool isEqual(PycRef<PycObject> obj) const;
bool isEqual(PycRef<PycObject> obj) const override;
bool isEqual(const char* str) const;
void load(class PycData* stream, class PycModule* mod);
void load(class PycData* stream, class PycModule* mod) override;
int length() const { return m_length; }
const char* value() const { return m_value; }