Skip to content

Commit

Permalink
Minor typing/aliasing cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
zrax committed Jul 5, 2017
1 parent 7c328f0 commit 96122d2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 24 deletions.
6 changes: 3 additions & 3 deletions pyc_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class PycModule {
void loadFromFile(const char* filename);
bool isValid() const { return (m_maj >= 0) && (m_min >= 0); }

unsigned int majorVer() const { return m_maj; }
unsigned int minorVer() const { return m_min; }
int majorVer() const { return m_maj; }
int minorVer() const { return m_min; }

int verCompare(int maj, int min) const
{
Expand All @@ -64,7 +64,7 @@ class PycModule {
void setVersion(unsigned int magic);

private:
short m_maj, m_min;
int m_maj, m_min;
bool m_unicode;

PycRef<PycCode> m_code;
Expand Down
6 changes: 4 additions & 2 deletions pyc_numeric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,15 @@ bool PycComplex::isEqual(PycRef<PycObject> obj) const
/* PycCFloat */
void PycCFloat::load(PycData* stream, PycModule*)
{
m_value_i64 = stream->get64();
Pyc_INT64 bits = stream->get64();
memcpy(&m_value, &bits, sizeof(bits));
}


/* PycCComplex */
void PycCComplex::load(PycData* stream, PycModule* mod)
{
PycCFloat::load(stream, mod);
m_imag_i64 = stream->get64();
Pyc_INT64 bits = stream->get64();
memcpy(&m_imag, &bits, sizeof(bits));
}
12 changes: 2 additions & 10 deletions pyc_numeric.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,7 @@ class PycCFloat : public PycObject {
double value() const { return m_value; }

private:
union
{
Pyc_INT64 m_value_i64;
double m_value;
};
double m_value;
};

class PycCComplex : public PycCFloat {
Expand All @@ -117,11 +113,7 @@ class PycCComplex : public PycCFloat {
double imag() const { return m_imag; }

private:
union
{
Pyc_INT64 m_imag_i64;
double m_imag;
};
double m_imag;
};

#endif
18 changes: 9 additions & 9 deletions pyc_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ PycRef<PycObject> CreateObject(int type)
case PycObject::TYPE_ELLIPSIS:
return Pyc_Ellipsis;
case PycObject::TYPE_INT:
return new PycInt();
return new PycInt(type);
case PycObject::TYPE_INT64:
return new PycLong(type);
case PycObject::TYPE_FLOAT:
return new PycFloat();
return new PycFloat(type);
case PycObject::TYPE_BINARY_FLOAT:
return new PycCFloat();
return new PycCFloat(type);
case PycObject::TYPE_COMPLEX:
return new PycComplex();
return new PycComplex(type);
case PycObject::TYPE_BINARY_COMPLEX:
return new PycCComplex();
return new PycCComplex(type);
case PycObject::TYPE_LONG:
return new PycLong();
return new PycLong(type);
case PycObject::TYPE_STRING:
case PycObject::TYPE_INTERNED:
case PycObject::TYPE_STRINGREF:
Expand All @@ -54,12 +54,12 @@ PycRef<PycObject> CreateObject(int type)
case PycObject::TYPE_SMALL_TUPLE:
return new PycTuple(type);
case PycObject::TYPE_LIST:
return new PycList();
return new PycList(type);
case PycObject::TYPE_DICT:
return new PycDict();
return new PycDict(type);
case PycObject::TYPE_CODE:
case PycObject::TYPE_CODE2:
return new PycCode();
return new PycCode(type);
case PycObject::TYPE_SET:
case PycObject::TYPE_FROZENSET:
return new PycSet(type);
Expand Down

0 comments on commit 96122d2

Please sign in to comment.