Alien-SmokeQt
view release on metacpan or search on metacpan
generator/parser/rpp/pp-macro.h view on Meta::CPAN
HashType idHash() const {
return name.hash();
}
QString toString() const;
struct NameCompare {
bool operator () ( const pp_macro& lhs, const pp_macro& rhs ) const {
return lhs.name.index() < rhs.name.index();
}
#ifdef Q_CC_MSVC
HashType operator () ( const pp_macro& macro ) const
{
return macro.idHash();
}
enum
{ // parameters for hash table
bucket_size = 4, // 0 < bucket_size
min_buckets = 8}; // min_buckets = 2 ^^ N, 0 < N
#endif
};
//Hash over id and value
struct CompleteHash {
HashType operator () ( const pp_macro& lhs ) const {
return lhs.completeHash();
}
#ifdef Q_CC_MSVC
bool operator () ( const pp_macro& lhs, const pp_macro& rhs ) const {
HashType lhash = lhs.valueHash()+lhs.idHash();
HashType rhash = rhs.valueHash()+rhs.idHash();
if( lhash < rhash ) return true;
else if( lhash > rhash ) return false;
int df = lhs.name.str().compare( rhs.name.str() );
return df < 0;
}
enum
{ // parameters for hash table
bucket_size = 4, // 0 < bucket_size
min_buckets = 8}; // min_buckets = 2 ^^ N, 0 < N
#endif
};
HashType valueHash() const {
if( !m_valueHashValid ) computeHash();
return m_valueHash;
}
///Hash that identifies all of this macro, the value and the identity
HashType completeHash() const {
return valueHash() + idHash() * 3777;
}
void invalidateHash();
///Convenient way of setting the definition, it is tokenized automatically
///@param definition utf-8 representation of the definition text
void setDefinitionText(QByteArray definition);
///More convenient overload
void setDefinitionText(QString definition);
void setDefinitionText(const char* definition) {
setDefinitionText(QByteArray(definition));
}
// START_APPENDED_LISTS(pp_macro)
// APPENDED_LIST_FIRST(pp_macro, IndexedString, definition)
// APPENDED_LIST(pp_macro, IndexedString, formals, definition)
// END_APPENDED_LISTS(pp_macro, formals)
QVector<IndexedString> definition;
QVector<IndexedString> formals;
private:
pp_macro& operator=(const pp_macro& rhs);
void computeHash() const;
};
}
inline uint qHash( const rpp::pp_macro& m ) {
return (uint)m.idHash();
}
#endif // PP_MACRO_H
( run in 0.387 second using v1.01-cache-2.11-cpan-140bd7fdf52 )