1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Minor clean-ups.

This commit is contained in:
jules 2013-01-05 20:07:22 +00:00
parent ddb6b969ea
commit e543949bda
28 changed files with 109 additions and 117 deletions

View file

@ -479,8 +479,8 @@ File LibraryModule::getLocalFolderFor (Project& project) const
{
if (project.shouldCopyModuleFilesLocally (getID()).getValue())
return project.getGeneratedCodeFolder().getChildFile ("modules").getChildFile (getID());
else
return moduleFolder;
return moduleFolder;
}
void LibraryModule::prepareExporter (ProjectExporter& exporter, ProjectSaver& projectSaver) const

View file

@ -517,16 +517,16 @@ String Project::Item::getFilePath() const
{
if (isFile())
return state [Ids::file].toString();
else
return String::empty;
return String::empty;
}
File Project::Item::getFile() const
{
if (isFile())
return project.resolveFilename (state [Ids::file].toString());
else
return File::nonexistent;
return File::nonexistent;
}
void Project::Item::setFile (const File& file)
@ -675,8 +675,8 @@ struct ItemSorterWithGroupsAtStart
if (firstIsGroup == secondIsGroup)
return first [Ids::name].toString().compareIgnoreCase (second [Ids::name].toString());
else
return firstIsGroup ? -1 : 1;
return firstIsGroup ? -1 : 1;
}
};

View file

@ -193,8 +193,8 @@ namespace CodeHelpers
{
if (includePath.startsWithChar ('<') || includePath.startsWithChar ('"'))
return "#include " + includePath;
else
return "#include \"" + includePath + "\"";
return "#include \"" + includePath + "\"";
}
String makeHeaderGuardName (const File& file)

View file

@ -76,8 +76,8 @@ namespace FileHelpers
if (file.exists())
return file.replaceWithData (data, numBytes);
else
return file.appendData (data, numBytes);
return file.appendData (data, numBytes);
}
bool overwriteFileWithNewDataIfDifferent (const File& file, const MemoryOutputStream& newData)

View file

@ -442,8 +442,8 @@ Result JucerDocument::saveDocument (const File& file)
if (ok)
return Result::ok();
else
return Result::fail (TRANS("Couldn't write to the file."));
return Result::fail (TRANS("Couldn't write to the file."));
}
//==============================================================================

View file

@ -148,8 +148,8 @@ const String quotedString (const String& s)
if (CharPointer_ASCII::isValidString (s.toUTF8(), std::numeric_limits<int>::max()))
return addEscapeChars (s).quoted();
else
return "CharPointer_UTF8 (" + addEscapeChars (s).quoted() + ")";
return "CharPointer_UTF8 (" + addEscapeChars (s).quoted() + ")";
}
const String replaceStringTranslations (String s, JucerDocument* document)

View file

@ -900,8 +900,8 @@ public:
{
if (internal->inputDevice != 0)
return internal->inputDevice->inChanNames;
else
return internal->inChanNames;
return internal->inChanNames;
}
bool isOpen() { return isOpen_; }

View file

@ -166,8 +166,8 @@ public:
if (type == 0)
return noDisc;
else
return readOnlyDiskPresent;
return readOnlyDiskPresent;
}
int getIntProperty (const LPOLESTR name, const int defaultReturn) const

View file

@ -165,8 +165,8 @@ double AudioTransportSource::getCurrentPosition() const
{
if (sampleRate > 0.0)
return getNextReadPosition() / sampleRate;
else
return 0.0;
return 0.0;
}
double AudioTransportSource::getLengthInSeconds() const

View file

@ -1596,8 +1596,8 @@ bool AudioUnitPluginFormat::doesPluginStillExist (const PluginDescription& desc)
{
if (desc.fileOrIdentifier.startsWithIgnoreCase (AudioUnitFormatHelpers::auIdentifierPrefix))
return fileMightContainThisPluginType (desc.fileOrIdentifier);
else
return File (desc.fileOrIdentifier).exists();
return File (desc.fileOrIdentifier).exists();
}
FileSearchPath AudioUnitPluginFormat::getDefaultLocationsToSearch()

View file

@ -139,8 +139,8 @@ public:
if (isPositiveAndBelow (rangeIndex, getNumRanges()))
return Range<Type> (values.getUnchecked (rangeIndex << 1),
values.getUnchecked ((rangeIndex << 1) + 1));
else
return Range<Type>();
return Range<Type>();
}
/** Returns the range between the lowest and highest values in the set.

View file

@ -286,10 +286,11 @@ String File::getPathUpToLastSlash() const
if (lastSlash > 0)
return fullPath.substring (0, lastSlash);
else if (lastSlash == 0)
if (lastSlash == 0)
return separatorString;
else
return fullPath;
return fullPath;
}
File File::getParentDirectory() const
@ -312,8 +313,8 @@ String File::getFileNameWithoutExtension() const
if (lastDot > lastSlash)
return fullPath.substring (lastSlash, lastDot);
else
return fullPath.substring (lastSlash);
return fullPath.substring (lastSlash);
}
bool File::isAChildOf (const File& potentialParent) const

View file

@ -439,8 +439,8 @@ struct Expression::Helpers
{
if (input->getOperatorPrecedence() > 0)
return "-(" + input->toString() + ")";
else
return "-" + input->toString();
return "-" + input->toString();
}
private:
@ -492,8 +492,8 @@ struct Expression::Helpers
if (input == left)
return new Add (newDest, right->clone());
else
return new Subtract (left->clone(), newDest);
return new Subtract (left->clone(), newDest);
}
private:
@ -545,8 +545,8 @@ struct Expression::Helpers
if (input == left)
return new Multiply (newDest, right->clone());
else
return new Divide (left->clone(), newDest);
return new Divide (left->clone(), newDest);
}
private:

View file

@ -480,8 +480,8 @@ bool File::isOnHardDisk() const
if (fullPath.toLowerCase()[0] <= 'b' && fullPath[1] == ':')
return n != DRIVE_REMOVABLE;
else
return n != DRIVE_CDROM && n != DRIVE_REMOTE;
return n != DRIVE_CDROM && n != DRIVE_REMOTE;
}
bool File::isOnRemovableDrive() const

View file

@ -223,8 +223,8 @@ String URL::toString (const bool includeGetParameters) const
{
if (includeGetParameters && parameterNames.size() > 0)
return url + "?" + URLHelpers::getMangledParameters (*this);
else
return url;
return url;
}
bool URL::isWellFormed() const

View file

@ -77,8 +77,8 @@ int SubregionStream::read (void* destBuffer, int maxBytesToRead)
bool SubregionStream::isExhausted()
{
if (lengthOfSourceStream >= 0)
return (getPosition() >= lengthOfSourceStream) || source->isExhausted();
else
return source->isExhausted();
if (lengthOfSourceStream >= 0 && getPosition() >= lengthOfSourceStream)
return true;
return source->isExhausted();
}

View file

@ -1567,7 +1567,8 @@ String String::trim() const
if (trimmedEnd <= start)
return empty;
else if (text < start || trimmedEnd < end)
if (text < start || trimmedEnd < end)
return String (start, trimmedEnd);
}
@ -1921,15 +1922,13 @@ String String::createStringFromData (const void* const data_, const int size)
const uint8* const data = static_cast <const uint8*> (data_);
if (size <= 0 || data == nullptr)
{
return empty;
}
else if (size == 1)
{
if (size == 1)
return charToString ((juce_wchar) data[0]);
}
else if ((data[0] == (uint8) CharPointer_UTF16::byteOrderMarkBE1 && data[1] == (uint8) CharPointer_UTF16::byteOrderMarkBE2)
|| (data[0] == (uint8) CharPointer_UTF16::byteOrderMarkLE1 && data[1] == (uint8) CharPointer_UTF16::byteOrderMarkLE2))
if ((data[0] == (uint8) CharPointer_UTF16::byteOrderMarkBE1 && data[1] == (uint8) CharPointer_UTF16::byteOrderMarkBE2)
|| (data[0] == (uint8) CharPointer_UTF16::byteOrderMarkLE1 && data[1] == (uint8) CharPointer_UTF16::byteOrderMarkLE2))
{
const bool bigEndian = (data[0] == (uint8) CharPointer_UTF16::byteOrderMarkBE1);
const int numChars = size / 2 - 1;
@ -1952,20 +1951,18 @@ String String::createStringFromData (const void* const data_, const int size)
builder.write (0);
return builder.result;
}
else
{
const uint8* start = data;
const uint8* end = data + size;
if (size >= 3
&& data[0] == (uint8) CharPointer_UTF8::byteOrderMark1
&& data[1] == (uint8) CharPointer_UTF8::byteOrderMark2
&& data[2] == (uint8) CharPointer_UTF8::byteOrderMark3)
start += 3;
const uint8* start = data;
const uint8* end = data + size;
return String (CharPointer_UTF8 ((const char*) start),
CharPointer_UTF8 ((const char*) end));
}
if (size >= 3
&& data[0] == (uint8) CharPointer_UTF8::byteOrderMark1
&& data[1] == (uint8) CharPointer_UTF8::byteOrderMark2
&& data[2] == (uint8) CharPointer_UTF8::byteOrderMark3)
start += 3;
return String (CharPointer_UTF8 ((const char*) start),
CharPointer_UTF8 ((const char*) end));
}
//==============================================================================

View file

@ -841,8 +841,8 @@ String XmlDocument::getParameterEntity (const String& entity)
if (ent.equalsIgnoreCase ("system"))
return getFileContents (tokenisedDTD [i + 2].trimCharactersAtEnd (">"));
else
return ent.trim().unquoted();
return ent.trim().unquoted();
}
}

View file

@ -171,8 +171,8 @@ bool PropertiesFile::save()
if (options.storageFormat == storeAsXML)
return saveAsXml();
else
return saveAsBinary();
return saveAsBinary();
}
bool PropertiesFile::loadAsXml()

View file

@ -92,8 +92,8 @@ public:
// to keep everything running smoothly..
if ((++totalEventCount & 1) != 0)
return dispatchNextXEvent() || dispatchNextInternalMessage();
else
return dispatchNextInternalMessage() || dispatchNextXEvent();
return dispatchNextInternalMessage() || dispatchNextXEvent();
}
// Wait for an event (either XEvent, or an internal Message)

View file

@ -189,8 +189,8 @@ Rectangle<float> DrawableShape::getDrawableBounds() const
{
if (isStrokeVisible())
return strokePath.getBounds();
else
return path.getBounds();
return path.getBounds();
}
bool DrawableShape::hitTest (int x, int y)

View file

@ -1026,10 +1026,10 @@ private:
return Colour ((uint8) (hex [0] * 0x11),
(uint8) (hex [1] * 0x11),
(uint8) (hex [2] * 0x11));
else
return Colour ((uint8) ((hex [0] << 4) + hex [1]),
(uint8) ((hex [2] << 4) + hex [3]),
(uint8) ((hex [4] << 4) + hex [5]));
return Colour ((uint8) ((hex [0] << 4) + hex [1]),
(uint8) ((hex [2] << 4) + hex [3]),
(uint8) ((hex [4] << 4) + hex [5]));
}
else if (s [index] == 'r'
&& s [index + 1] == 'g'

View file

@ -1616,12 +1616,11 @@ private:
static NSDragOperation draggingUpdated (id self, SEL, id <NSDraggingInfo> sender)
{
NSViewComponentPeer* const owner = getOwner (self);
if (NSViewComponentPeer* const owner = getOwner (self))
if (owner->sendDragCallback (0, sender))
return NSDragOperationCopy | NSDragOperationMove | NSDragOperationGeneric;
if (owner != nullptr && owner->sendDragCallback (0, sender))
return NSDragOperationCopy | NSDragOperationMove | NSDragOperationGeneric;
else
return NSDragOperationNone;
return NSDragOperationNone;
}
static void draggingEnded (id self, SEL s, id <NSDraggingInfo> sender)

View file

@ -2137,8 +2137,8 @@ private:
{
if (MessageManager::getInstance()->currentThreadHasLockedMessageManager())
return callback (userData);
else
return MessageManager::getInstance()->callFunctionOnMessageThread (callback, userData);
return MessageManager::getInstance()->callFunctionOnMessageThread (callback, userData);
}
static Point<int> getPointFromLParam (LPARAM lParam) noexcept

View file

@ -109,14 +109,10 @@ public:
float getPositionOfValue (const double value) const
{
if (isHorizontal() || isVertical())
{
return getLinearSliderPos (value);
}
else
{
jassertfalse; // not a valid call on a slider that doesn't work linearly!
return 0.0f;
}
jassertfalse; // not a valid call on a slider that doesn't work linearly!
return 0.0f;
}
void setRange (const double newMin, const double newMax, const double newInt)
@ -684,7 +680,8 @@ public:
if (normalPosDistance >= minPosDistance && maxPosDistance >= minPosDistance)
return 1;
else if (normalPosDistance >= maxPosDistance)
if (normalPosDistance >= maxPosDistance)
return 2;
}
@ -1489,8 +1486,8 @@ String Slider::getTextFromValue (double v)
{
if (getNumDecimalPlacesToDisplay() > 0)
return String (v, getNumDecimalPlacesToDisplay()) + getTextValueSuffix();
else
return String (roundToInt (v)) + getTextValueSuffix();
return String (roundToInt (v)) + getTextValueSuffix();
}
double Slider::getValueFromText (const String& text)

View file

@ -269,12 +269,9 @@ void Toolbar::clear()
ToolbarItemComponent* Toolbar::createItem (ToolbarItemFactory& factory, const int itemId)
{
if (itemId == ToolbarItemFactory::separatorBarId)
return new Spacer (itemId, 0.1f, true);
else if (itemId == ToolbarItemFactory::spacerId)
return new Spacer (itemId, 0.5f, false);
else if (itemId == ToolbarItemFactory::flexibleSpacerId)
return new Spacer (itemId, 0, false);
if (itemId == ToolbarItemFactory::separatorBarId) return new Spacer (itemId, 0.1f, true);
if (itemId == ToolbarItemFactory::spacerId) return new Spacer (itemId, 0.5f, false);
if (itemId == ToolbarItemFactory::flexibleSpacerId) return new Spacer (itemId, 0.0f, false);
return factory.createItem (itemId);
}
@ -336,8 +333,10 @@ int Toolbar::getNumItems() const noexcept
int Toolbar::getItemId (const int itemIndex) const noexcept
{
ToolbarItemComponent* const tc = getItemComponent (itemIndex);
return tc != nullptr ? tc->getItemId() : 0;
if (ToolbarItemComponent* const tc = getItemComponent (itemIndex))
return tc->getItemId();
return 0;
}
ToolbarItemComponent* Toolbar::getItemComponent (const int itemIndex) const noexcept
@ -350,16 +349,17 @@ ToolbarItemComponent* Toolbar::getNextActiveComponent (int index, const int delt
for (;;)
{
index += delta;
ToolbarItemComponent* const tc = getItemComponent (index);
if (tc == nullptr)
break;
if (tc->isActive)
return tc;
if (ToolbarItemComponent* const tc = getItemComponent (index))
{
if (tc->isActive)
return tc;
}
else
{
return nullptr;
}
}
return nullptr;
}
void Toolbar::setStyle (const ToolbarItemStyle& newStyle)

View file

@ -1222,8 +1222,8 @@ bool TreeViewItem::isOpen() const noexcept
{
if (openness == opennessDefault)
return ownerView != nullptr && ownerView->defaultOpenness;
else
return openness == opennessOpen;
return openness == opennessOpen;
}
void TreeViewItem::setOpen (const bool shouldBeOpen)

View file

@ -158,12 +158,10 @@ public:
static LRESULT CALLBACK hookedWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
Pimpl* const p = getPimpl (hwnd);
if (p != nullptr)
if (Pimpl* const p = getPimpl (hwnd))
return p->windowProc (hwnd, message, wParam, lParam);
else
return DefWindowProcW (hwnd, message, wParam, lParam);
return DefWindowProcW (hwnd, message, wParam, lParam);
}
LRESULT windowProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)