diff options
| author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-30 00:15:53 +0000 |
|---|---|---|
| committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-30 00:15:53 +0000 |
| commit | 0aaa8e3fc8f8a1481333b564f0922277c8d8ad59 (patch) | |
| tree | b95c0ca86c4876dd139af376b9f4afd8917cf0cd /src/devices/pic/base/pic_protection.cpp | |
| parent | b79a2c28534cf09987eeeba3077fff9236df182a (diff) | |
| download | piklab-0aaa8e3fc8f8a1481333b564f0922277c8d8ad59.tar.gz piklab-0aaa8e3fc8f8a1481333b564f0922277c8d8ad59.zip | |
TQt4 port piklab
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/piklab@1238822 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/devices/pic/base/pic_protection.cpp')
| -rw-r--r-- | src/devices/pic/base/pic_protection.cpp | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/src/devices/pic/base/pic_protection.cpp b/src/devices/pic/base/pic_protection.cpp index da77881..7af925c 100644 --- a/src/devices/pic/base/pic_protection.cpp +++ b/src/devices/pic/base/pic_protection.cpp @@ -10,16 +10,16 @@ #include "pic_config.h" -#include <qregexp.h> +#include <tqregexp.h> -bool Pic::Protection::isNoneProtectedValueName(const QString &name) const +bool Pic::Protection::isNoneProtectedValueName(const TQString &name) const { if ( name=="Off" ) return true; if ( _data.architecture()==Architecture::P17C ) return !isAllProtectedValueName(name); return false; } -bool Pic::Protection::isAllProtectedValueName(const QString &name) const +bool Pic::Protection::isAllProtectedValueName(const TQString &name) const { if ( name=="All" ) return true; if ( _data.architecture()==Architecture::P17C ) return ( name=="Code-protected microcontroller" ); @@ -29,13 +29,13 @@ bool Pic::Protection::isAllProtectedValueName(const QString &name) const Pic::Protection::Family Pic::Protection::family() const { if ( _config.findMask("WRTBS") ) return CodeGuard; - QString mask = maskName(ProgramProtected, MemoryRangeType::Code); - if ( _config.findMask(QString("%1_%2").arg(mask).arg(0)) ) return BlockProtection; - if ( _config.findMask(mask) ) return BasicProtection; + TQString tqmask = tqmaskName(ProgramProtected, MemoryRangeType::Code); + if ( _config.findMask(TQString("%1_%2").tqarg(tqmask).tqarg(0)) ) return BlockProtection; + if ( _config.findMask(tqmask) ) return BasicProtection; return NoProtection; } -QString Pic::Protection::securityValueName(Type type) const +TQString Pic::Protection::securityValueName(Type type) const { if ( type==StandardSecurity ) return "Standard Security"; if ( type==HighSecurity ) return "High Security"; @@ -43,12 +43,12 @@ QString Pic::Protection::securityValueName(Type type) const return "Off"; } -QString Pic::Protection::bootSizeMaskName() const +TQString Pic::Protection::bootSizeMaskName() const { return (family()==CodeGuard ? "BSSIZ" : "BBSIZ"); } -QString Pic::Protection::bootMaskName(Type type) const +TQString Pic::Protection::bootMaskName(Type type) const { Q_ASSERT( type!=Nb_Types ); if ( family()==CodeGuard ) { @@ -59,10 +59,10 @@ QString Pic::Protection::bootMaskName(Type type) const if ( type==WriteProtected ) return "WRTB"; if ( type==ReadProtected ) return "EBTRB"; } - return QString::null; + return TQString(); } -QString Pic::Protection::blockSizeMaskName(uint block) const +TQString Pic::Protection::blockSizeMaskName(uint block) const { if ( family()==CodeGuard ) { Q_ASSERT( block==0 ); @@ -71,18 +71,18 @@ QString Pic::Protection::blockSizeMaskName(uint block) const return blockMaskName(ProgramProtected, block); } -QString Pic::Protection::blockMaskName(Type type, uint block) const +TQString Pic::Protection::blockMaskName(Type type, uint block) const { Q_ASSERT( type!=Nb_Types ); if ( family()==CodeGuard ) { if ( type==WriteProtected ) return (block==0 ? "WRTSS" : "WRTGS"); if ( type==StandardSecurity || type==HighSecurity ) return (block==0 ? "SSSEC" : "GSSEC"); - return QString::null; + return TQString(); } - return QString("%1_%2").arg(maskName(type, MemoryRangeType::Code)).arg(block); + return TQString("%1_%2").tqarg(tqmaskName(type, MemoryRangeType::Code)).tqarg(block); } -QString Pic::Protection::maskName(Type type, MemoryRangeType mtype) const +TQString Pic::Protection::tqmaskName(Type type, MemoryRangeType mtype) const { Q_ASSERT( type!=Nb_Types ); switch (mtype.type()) { @@ -112,13 +112,13 @@ QString Pic::Protection::maskName(Type type, MemoryRangeType mtype) const case MemoryRangeType::Nb_Types: Q_ASSERT(false); break; default: break; } - return QString::null; + return TQString(); } -bool Pic::Protection::extractRanges(const QString &name, QValueVector<Address> &starts, Address &end, bool &ok) +bool Pic::Protection::extractRanges(const TQString &name, TQValueVector<Address> &starts, Address &end, bool &ok) { ok = false; - QRegExp regexp("([A-F0-9]+)(/[A-F0-9]+)?(/[A-F0-9]+)?:([A-F0-9]+)"); + TQRegExp regexp("([A-F0-9]+)(/[A-F0-9]+)?(/[A-F0-9]+)?:([A-F0-9]+)"); if ( !regexp.exactMatch(name) ) return false; bool ok1; end = fromHex(regexp.cap(regexp.numCaptures()), &ok1); @@ -130,7 +130,7 @@ bool Pic::Protection::extractRanges(const QString &name, QValueVector<Address> & for (int i=1; i<regexp.numCaptures(); i++) { if ( regexp.cap(i).isEmpty() ) break; bool ok1; - QString s = (i==1 ? regexp.cap(i) : regexp.cap(i).mid(1)); + TQString s = (i==1 ? regexp.cap(i) : regexp.cap(i).mid(1)); Address start = fromHex(s, &ok1); if ( !ok1 ) { qDebug("Malformed start address %s", s.latin1()); @@ -146,7 +146,7 @@ bool Pic::Protection::extractRanges(const QString &name, QValueVector<Address> & return true; } -AddressRangeVector Pic::Protection::extractRanges(const QString &name, MemoryRangeType type) const +AddressRangeVector Pic::Protection::extractRanges(const TQString &name, MemoryRangeType type) const { if ( isNoneProtectedValueName(name) ) return AddressRange(); if ( isAllProtectedValueName(name) ) { @@ -154,7 +154,7 @@ AddressRangeVector Pic::Protection::extractRanges(const QString &name, MemoryRan return AddressRange(rdata.start, rdata.end); } bool ok1; - QValueVector<Address> starts; + TQValueVector<Address> starts; Address end; bool ok2 = extractRanges(name, starts, end, ok1); Q_ASSERT(ok1); @@ -165,11 +165,11 @@ AddressRangeVector Pic::Protection::extractRanges(const QString &name, MemoryRan return rv; } -bool Pic::Protection::checkRange(const QString &mask, const QString &name) const +bool Pic::Protection::checkRange(const TQString &tqmask, const TQString &name) const { if ( family()!=CodeGuard ) { bool ok; - (void)extractRange(mask, name, ok); + (void)extractRange(tqmask, name, ok); return ok; } @@ -180,8 +180,8 @@ bool Pic::Protection::checkRange(const QString &mask, const QString &name) const isBootBlock = ( i==0 ); block = i - 1; for (uint k=0; k<Nb_Types; k++) { - QString mname = (isBootBlock ? bootMaskName(Type(k)) : blockMaskName(Type(k), block)); - if ( mask!=mname ) continue; + TQString mname = (isBootBlock ? bootMaskName(Type(k)) : blockMaskName(Type(k), block)); + if ( tqmask!=mname ) continue; ptype = Type(k); break; } @@ -195,15 +195,15 @@ bool Pic::Protection::checkRange(const QString &mask, const QString &name) const return true; } -Pic::Protection::ProtectedRange Pic::Protection::extractRange(const QString &mask, const QString &name, bool &ok) const +Pic::Protection::ProtectedRange Pic::Protection::extractRange(const TQString &tqmask, const TQString &name, bool &ok) const { Q_ASSERT( family()!=CodeGuard ); - //qDebug("extract range %s %s", mask.latin1(), name.latin1()); + //qDebug("extract range %s %s", tqmask.latin1(), name.latin1()); ProtectedRange pr; ok = false; - QRegExp rexp("([A-Z]+)(?:_([0-9])|)"); - if ( !rexp.exactMatch(mask) ) { + TQRegExp rexp("([A-Z]+)(?:_([0-9])|)"); + if ( !rexp.exactMatch(tqmask) ) { qDebug("Malformed block range"); return pr; } @@ -215,7 +215,7 @@ Pic::Protection::ProtectedRange Pic::Protection::extractRange(const QString &mas for (MemoryRangeType type; type<=MemoryRangeType::Nb_Types; ++type) { // #### danger: <= isBootBlock = ( type==MemoryRangeType::Nb_Types ); for (uint k=0; k<Nb_Types; k++) { - QString mname = (isBootBlock ? bootMaskName(Type(k)) : maskName(Type(k), type)); + TQString mname = (isBootBlock ? bootMaskName(Type(k)) : tqmaskName(Type(k), type)); if ( rexp.cap(1)!=mname ) continue; rtype = (isBootBlock ? MemoryRangeType(MemoryRangeType::Code) : type); ptype = Type(k); @@ -239,24 +239,24 @@ Pic::Protection::ProtectedRange Pic::Protection::extractRange(const QString &mas return pr; } - const Config::Mask *bmask = _config.findMask(bootMaskName(ptype)); - const Config::Mask *bsmask = _config.findMask(bootSizeMaskName()); + const Config::Mask *btqmask = _config.findMask(bootMaskName(ptype)); + const Config::Mask *bstqmask = _config.findMask(bootSizeMaskName()); const MemoryRangeData &rdata = _data.range(rtype); if ( isAllProtectedValueName(name) ) { - if ( rtype==MemoryRangeType::Code && !isBootBlock && bmask ) { + if ( rtype==MemoryRangeType::Code && !isBootBlock && btqmask ) { qDebug("Protected range should be explicit with boot block"); return pr; } if (isBootBlock) { - if ( bsmask==0 ) { + if ( bstqmask==0 ) { qDebug("Protected range should be explicit when boot size not present"); return pr; } Address start = _data.range(MemoryRangeType::Code).start; pr.starts.append(start); - for (uint k=0; k<uint(bsmask->values.count()); k++) { + for (uint k=0; k<uint(bstqmask->values.count()); k++) { bool ok1; - uint size = bsmask->values[k].name.toUInt(&ok1); + uint size = bstqmask->values[k].name.toUInt(&ok1); if ( !ok1 ) { qDebug("Could not recognize boot size value"); return pr; @@ -277,7 +277,7 @@ Pic::Protection::ProtectedRange Pic::Protection::extractRange(const QString &mas ok = true; return pr; } - if ( isBootBlock && bsmask ) { + if ( isBootBlock && bstqmask ) { qDebug("Protected range should not be explicit when boot size is present"); return pr; } @@ -294,7 +294,7 @@ Pic::Protection::ProtectedRange Pic::Protection::extractRange(const QString &mas qDebug("End is beyond memory range"); return pr; } - if ( (rtype!=MemoryRangeType::Code || isBootBlock) && (pr.starts.count()>1 || !rexp.cap(2).isEmpty() || bmask==0) ) { + if ( (rtype!=MemoryRangeType::Code || isBootBlock) && (pr.starts.count()>1 || !rexp.cap(2).isEmpty() || btqmask==0) ) { qDebug("Only code with blocks and boot can have multiple protected ranges"); return pr; } @@ -306,14 +306,14 @@ Pic::Protection::ProtectedRange Pic::Protection::extractRange(const QString &mas // check with boot block if ( pr.starts.count()>1 ) { - if ( bmask==0 ) { - qDebug("No boot mask"); + if ( btqmask==0 ) { + qDebug("No boot tqmask"); return pr; } - for (uint i=0; i<uint(bmask->values.count()); i++) { - if ( bmask->values[i].name=="Off" ) continue; + for (uint i=0; i<uint(btqmask->values.count()); i++) { + if ( btqmask->values[i].name=="Off" ) continue; bool ok1; - ProtectedRange bpr = extractRange(bmask->name, bmask->values[i].name, ok1); + ProtectedRange bpr = extractRange(btqmask->name, btqmask->values[i].name, ok1); if ( !ok1 ) return pr; if ( bpr.ends.count()!=pr.starts.count() ) { qDebug("Boot number of ends (%i) should be the same as code number of starts (%i)", int(bpr.ends.count()), int(pr.starts.count())); @@ -341,21 +341,21 @@ uint Pic::Protection::nbBlocks() const { if ( family()==CodeGuard ) return 2; // codeguard : secure segment + general segment for (uint i=0; i<MAX_NB_BLOCKS; i++) - if ( _config.findMask(QString("CP_%1").arg(i))==0 ) return i; + if ( _config.findMask(TQString("CP_%1").tqarg(i))==0 ) return i; return MAX_NB_BLOCKS; } -QString Pic::Protection::bootLabel() const +TQString Pic::Protection::bootLabel() const { if ( family()==CodeGuard ) return i18n("Boot Segment"); return i18n("Boot Block"); } -QString Pic::Protection::blockLabel(uint i) const +TQString Pic::Protection::blockLabel(uint i) const { if ( family()==CodeGuard ) { if ( i==0 ) return i18n("Secure Segment"); return i18n("General Segment"); } - return i18n("Block #%1").arg(i); + return i18n("Block #%1").tqarg(i); } |
