Browse Source

tags/2021-05-28
jules 17 years ago
parent
commit
5eea51a781
51 changed files with 329 additions and 154 deletions
  1. +10
    -0
      build/linux/platform_specific_code/juce_linux_SystemStats.cpp
  2. +2
    -1
      build/linux/platform_specific_code/juce_linux_Windowing.cpp
  3. +1
    -1
      build/macosx/platform_specific_code/juce_mac_CoreAudio.cpp
  4. +2
    -2
      build/macosx/platform_specific_code/juce_mac_CoreMidi.cpp
  5. +10
    -0
      build/macosx/platform_specific_code/juce_mac_SystemStats.cpp
  6. +2
    -2
      build/macosx/platform_specific_code/juce_mac_Windowing.cpp
  7. +1
    -1
      build/win32/platform_specific_code/juce_win32_AudioCDReader.cpp
  8. +17
    -0
      build/win32/platform_specific_code/juce_win32_SystemStats.cpp
  9. +2
    -3
      build/win32/platform_specific_code/juce_win32_Windowing.cpp
  10. +4
    -0
      build/win32/vc8/JUCE.vcproj
  11. +6
    -1
      docs/JUCE changelist.txt
  12. +1
    -1
      extras/audio plugin host/src/plugins/juce_KnownPluginList.cpp
  13. +1
    -1
      extras/audio plugin host/src/plugins/juce_PluginListComponent.cpp
  14. +2
    -2
      extras/audio plugin host/src/plugins/vst/juce_VSTPluginInstance.cpp
  15. +1
    -1
      extras/audio plugins/wrapper/formats/AudioUnit/juce_AudioUnitWrapper.cpp
  16. +1
    -1
      extras/the jucer/src/properties/jucer_JustificationProperty.h
  17. +17
    -18
      src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.cpp
  18. +1
    -1
      src/juce_appframework/audio/midi/juce_MidiFile.cpp
  19. +5
    -5
      src/juce_appframework/audio/midi/juce_MidiKeyboardState.cpp
  20. +13
    -13
      src/juce_appframework/audio/midi/juce_MidiMessage.cpp
  21. +4
    -4
      src/juce_appframework/audio/midi/juce_MidiMessageSequence.cpp
  22. +3
    -3
      src/juce_appframework/audio/processors/juce_AudioProcessor.cpp
  23. +1
    -1
      src/juce_appframework/gui/components/controls/juce_ComboBox.cpp
  24. +4
    -4
      src/juce_appframework/gui/components/controls/juce_ListBox.cpp
  25. +2
    -2
      src/juce_appframework/gui/components/controls/juce_TableHeaderComponent.cpp
  26. +2
    -2
      src/juce_appframework/gui/components/controls/juce_TreeView.cpp
  27. +2
    -2
      src/juce_appframework/gui/components/filebrowser/juce_FileSearchPathListComponent.cpp
  28. +4
    -2
      src/juce_appframework/gui/components/juce_Component.cpp
  29. +10
    -8
      src/juce_appframework/gui/components/layout/juce_TabbedButtonBar.cpp
  30. +3
    -3
      src/juce_appframework/gui/components/menus/juce_MenuBarComponent.cpp
  31. +2
    -2
      src/juce_appframework/gui/components/menus/juce_PopupMenu.cpp
  32. +2
    -2
      src/juce_appframework/gui/components/special/juce_AudioDeviceSelectorComponent.cpp
  33. +2
    -3
      src/juce_appframework/gui/components/special/juce_MagnifierComponent.cpp
  34. +2
    -4
      src/juce_appframework/gui/components/windows/juce_ComponentPeer.cpp
  35. +4
    -4
      src/juce_appframework/gui/graphics/fonts/juce_GlyphArrangement.cpp
  36. +3
    -3
      src/juce_appframework/gui/graphics/geometry/juce_RectangleList.cpp
  37. +7
    -3
      src/juce_appframework/gui/graphics/imaging/juce_Image.cpp
  38. +2
    -2
      src/juce_appframework/gui/graphics/imaging/juce_ImageConvolutionKernel.cpp
  39. +7
    -2
      src/juce_core/basics/juce_MathsFunctions.h
  40. +4
    -0
      src/juce_core/basics/juce_SystemStats.h
  41. +14
    -16
      src/juce_core/containers/juce_Array.h
  42. +3
    -3
      src/juce_core/containers/juce_BitArray.cpp
  43. +9
    -8
      src/juce_core/containers/juce_OwnedArray.h
  44. +10
    -8
      src/juce_core/containers/juce_ReferenceCountedArray.h
  45. +5
    -4
      src/juce_core/containers/juce_SortedSet.h
  46. +1
    -1
      src/juce_core/containers/juce_SparseSet.h
  47. +2
    -2
      src/juce_core/text/juce_String.cpp
  48. +1
    -1
      src/juce_core/text/juce_String.h
  49. +1
    -1
      src/juce_core/text/juce_StringArray.cpp
  50. +111
    -0
      src/juce_core/threads/juce_ScopedTryLock.h
  51. +3
    -0
      src/juce_core_includes.h

+ 10
- 0
build/linux/platform_specific_code/juce_linux_SystemStats.cpp View File

@@ -100,6 +100,16 @@ const String SystemStats::getOperatingSystemName() throw()
return T("Linux");
}
bool SystemStats::isOperatingSystem64Bit() throw()
{
#if JUCE_64BIT
return true;
#else
//xxx not sure how to find this out?..
return false;
#endif
}
static const String getCpuInfo (const char* key, bool lastOne = false) throw()
{
String info;


+ 2
- 1
build/linux/platform_specific_code/juce_linux_Windowing.cpp View File

@@ -940,7 +940,8 @@ public:
{
jassert (x >= 0 && y >= 0 && x < ww && y < wh); // should only be called for points that are actually inside the bounds
if (x < 0 || y < 0 || x >= ww || y >= wh)
if (((unsigned int) x) >= (unsigned int) ww
|| ((unsigned int) y) >= (unsigned int) wh)
return false;
bool inFront = false;


+ 1
- 1
build/macosx/platform_specific_code/juce_mac_CoreAudio.cpp View File

@@ -396,7 +396,7 @@ public:
if (types != 0)
{
if (index >= 0 && index < num)
if (((unsigned int) index) < num)
{
OSType id = types[index];
AudioDeviceSetProperty (deviceID, 0, 0, input, kAudioDevicePropertyDataSource, sizeof (id), &id);


+ 2
- 2
build/macosx/platform_specific_code/juce_mac_CoreMidi.cpp View File

@@ -254,7 +254,7 @@ MidiOutput* MidiOutput::openDevice (int index)
{
MidiOutput* mo = 0;
if (index >= 0 && index < (int) MIDIGetNumberOfDestinations())
if (((unsigned int) index) < (unsigned int) MIDIGetNumberOfDestinations())
{
MIDIEndpointRef endPoint = MIDIGetDestination (index);
@@ -496,7 +496,7 @@ MidiInput* MidiInput::openDevice (int index, MidiInputCallback* callback)
{
MidiInput* mi = 0;
if (index >= 0 && index < (int) MIDIGetNumberOfSources())
if (((unsigned int) index) < (unsigned int) MIDIGetNumberOfSources())
{
MIDIEndpointRef endPoint = MIDIGetSource (index);


+ 10
- 0
build/macosx/platform_specific_code/juce_mac_SystemStats.cpp View File

@@ -126,6 +126,16 @@ const String SystemStats::getOperatingSystemName() throw()
return T("Mac OS X");
}
bool SystemStats::isOperatingSystem64Bit() throw()
{
#if JUCE_64BIT
return true;
#else
//xxx not sure how to find this out?..
return false;
#endif
}
//==============================================================================
void SystemStats::initialiseStats() throw()
{


+ 2
- 2
build/macosx/platform_specific_code/juce_mac_Windowing.cpp View File

@@ -594,8 +594,8 @@ public:
bool contains (int x, int y, bool trueIfInAChildWindow) const
{
if (x < 0 || y < 0
|| x >= component->getWidth() || y >= component->getHeight()
if (((unsigned int) x) >= (unsigned int) component->getWidth()
|| ((unsigned int) y) >= (unsigned int) component->getHeight()
|| ! IsValidWindowPtr (windowRef))
return false;


+ 1
- 1
build/win32/platform_specific_code/juce_win32_AudioCDReader.cpp View File

@@ -1708,7 +1708,7 @@ AudioCDReader* AudioCDReader::createReaderForCD (const int deviceIndex)
CDDeviceInfo list[8];
const int num = FindCDDevices (list, 8);
if (deviceIndex >= 0 && deviceIndex < num)
if (((unsigned int) deviceIndex) < (unsigned int) num)
{
CDDeviceHandle* const handle = openHandle (&(list[deviceIndex]));


+ 17
- 0
build/win32/platform_specific_code/juce_win32_SystemStats.cpp View File

@@ -348,6 +348,23 @@ const String SystemStats::getOperatingSystemName() throw()
return name;
}
bool SystemStats::isOperatingSystem64Bit() throw()
{
#ifdef _WIN64
return true;
#else
typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress (GetModuleHandle ("kernel32"), "IsWow64Process");
BOOL isWow64 = FALSE;
return (fnIsWow64Process != 0)
&& fnIsWow64Process (GetCurrentProcess(), &isWow64)
&& (isWow64 != FALSE);
#endif
}
//==============================================================================
int SystemStats::getMemorySizeInMegabytes() throw()
{


+ 2
- 3
build/win32/platform_specific_code/juce_win32_Windowing.cpp View File

@@ -1429,9 +1429,8 @@ private:
}
else if (! isDragging)
{
if (x >= 0 && y >= 0
&& x < component->getWidth()
&& y < component->getHeight())
if (((unsigned int) x) < (unsigned int) component->getWidth()
&& ((unsigned int) y) < (unsigned int) component->getHeight())
{
RECT r;
GetWindowRect (hwnd, &r);


+ 4
- 0
build/win32/vc8/JUCE.vcproj View File

@@ -5783,6 +5783,10 @@
RelativePath="..\..\..\src\juce_core\threads\juce_ScopedReadLock.h"
>
</File>
<File
RelativePath="..\..\..\src\juce_core\threads\juce_ScopedTryLock.h"
>
</File>
<File
RelativePath="..\..\..\src\juce_core\threads\juce_ScopedWriteLock.h"
>


+ 6
- 1
docs/JUCE changelist.txt View File

@@ -1,7 +1,12 @@

==============================================================================

JUCE version 1.45
JUCE version 1.46

==============================================================================
Changelist for version 1.46

- new class: ScopedTryLock

==============================================================================
Changelist for version 1.45


+ 1
- 1
extras/audio plugin host/src/plugins/juce_KnownPluginList.cpp View File

@@ -307,5 +307,5 @@ int KnownPluginList::getIndexChosenByMenu (const int menuResultCode) const
{
const int i = menuResultCode - menuIdBase;
return (i >= 0 && i < types.size()) ? i : -1;
return (((unsigned int) i) < (unsigned int) types.size()) ? i : -1;
}

+ 1
- 1
extras/audio plugin host/src/plugins/juce_PluginListComponent.cpp View File

@@ -201,7 +201,7 @@ void PluginListComponent::buttonClicked (Button* b)
}
}
bool PluginListComponent::isInterestedInFileDrag (const StringArray& files)
bool PluginListComponent::isInterestedInFileDrag (const StringArray& /*files*/)
{
return true;
}


+ 2
- 2
extras/audio plugin host/src/plugins/vst/juce_VSTPluginInstance.cpp View File

@@ -2411,7 +2411,7 @@ int VSTPluginInstance::getNumParameters()
float VSTPluginInstance::getParameter (int index)
{
if (effect != 0 && index >= 0 && index < effect->numParams)
if (effect != 0 && ((unsigned int) index) < (unsigned int) effect->numParams)
{
try
{
@@ -2428,7 +2428,7 @@ float VSTPluginInstance::getParameter (int index)
void VSTPluginInstance::setParameter (int index, float newValue)
{
if (effect != 0 && index >= 0 && index < effect->numParams)
if (effect != 0 && ((unsigned int) index) < (unsigned int) effect->numParams)
{
try
{


+ 1
- 1
extras/audio plugins/wrapper/formats/AudioUnit/juce_AudioUnitWrapper.cpp View File

@@ -661,7 +661,7 @@ public:
while (i.getNextEvent (midiEventData, midiEventSize, midiEventPosition))
{
jassert (midiEventPosition >= 0 && midiEventPosition < (int) numSamples);
jassert (((unsigned int) midiEventPosition) < (unsigned int) numSamples);


+ 1
- 1
extras/the jucer/src/properties/jucer_JustificationProperty.h View File

@@ -85,7 +85,7 @@ public:
Justification::bottomLeft,
Justification::bottomRight };
if (newIndex >= 0 && newIndex < numElementsInArray (types)
if (((unsigned int) newIndex) < (unsigned int) numElementsInArray (types)
&& types [newIndex] != getJustification().getFlags())
{
setJustification (Justification (types [newIndex]));


+ 17
- 18
src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.cpp View File

@@ -64,7 +64,7 @@ AudioSampleBuffer::AudioSampleBuffer (float** dataToReferTo,
const int numChannels_,
const int numSamples) throw()
{
jassert (numChannels_ >= 0 && numChannels_ <= maxNumAudioSampleBufferChannels);
jassert (((unsigned int) numChannels_) <= (unsigned int) maxNumAudioSampleBufferChannels);
numChannels = numChannels_;
size = numSamples;
@@ -134,8 +134,8 @@ AudioSampleBuffer::~AudioSampleBuffer() throw()
float* AudioSampleBuffer::getSampleData (const int channelNumber,
const int sampleOffset) const throw()
{
jassert (channelNumber >= 0 && channelNumber < numChannels);
jassert (sampleOffset >= 0 && sampleOffset < size);
jassert (((unsigned int) channelNumber) < (unsigned int) numChannels);
jassert (((unsigned int) sampleOffset) < (unsigned int) size);
return channels [channelNumber] + sampleOffset;
}
@@ -211,8 +211,7 @@ void AudioSampleBuffer::clear() throw()
void AudioSampleBuffer::clear (const int startSample,
const int numSamples) throw()
{
jassert (startSample >= 0);
jassert (startSample + numSamples <= size);
jassert (startSample >= 0 && startSample + numSamples <= size);
for (int i = 0; i < numChannels; ++i)
zeromem (channels [i] + startSample, numSamples * sizeof (float));
@@ -222,7 +221,7 @@ void AudioSampleBuffer::clear (const int channel,
const int startSample,
const int numSamples) throw()
{
jassert (channel >= 0 && channel < numChannels);
jassert (((unsigned int) channel) < (unsigned int) numChannels);
jassert (startSample >= 0 && startSample + numSamples <= size);
zeromem (channels [channel] + startSample, numSamples * sizeof (float));
@@ -233,7 +232,7 @@ void AudioSampleBuffer::applyGain (const int channel,
int numSamples,
const float gain) throw()
{
jassert (channel >= 0 && channel < numChannels);
jassert (((unsigned int) channel) < (unsigned int) numChannels);
jassert (startSample >= 0 && startSample + numSamples <= size);
if (gain != 1.0f)
@@ -264,7 +263,7 @@ void AudioSampleBuffer::applyGainRamp (const int channel,
}
else
{
jassert (channel >= 0 && channel < numChannels);
jassert (((unsigned int) channel) < (unsigned int) numChannels);
jassert (startSample >= 0 && startSample + numSamples <= size);
const float increment = (endGain - startGain) / numSamples;
@@ -295,9 +294,9 @@ void AudioSampleBuffer::addFrom (const int destChannel,
const float gain) throw()
{
jassert (&source != this);
jassert (destChannel >= 0 && destChannel < numChannels);
jassert (((unsigned int) destChannel) < (unsigned int) numChannels);
jassert (destStartSample >= 0 && destStartSample + numSamples <= size);
jassert (sourceChannel >= 0 && sourceChannel < source.numChannels);
jassert (((unsigned int) sourceChannel) < (unsigned int) source.numChannels);
jassert (sourceStartSample >= 0 && sourceStartSample + numSamples <= source.size);
if (gain != 0.0f && numSamples > 0)
@@ -324,7 +323,7 @@ void AudioSampleBuffer::addFrom (const int destChannel,
int numSamples,
const float gain) throw()
{
jassert (destChannel >= 0 && destChannel < numChannels);
jassert (((unsigned int) destChannel) < (unsigned int) numChannels);
jassert (destStartSample >= 0 && destStartSample + numSamples <= size);
jassert (source != 0);
@@ -352,7 +351,7 @@ void AudioSampleBuffer::addFromWithRamp (const int destChannel,
float startGain,
const float endGain) throw()
{
jassert (destChannel >= 0 && destChannel < numChannels);
jassert (((unsigned int) destChannel) < (unsigned int) numChannels);
jassert (destStartSample >= 0 && destStartSample + numSamples <= size);
jassert (source != 0);
@@ -388,9 +387,9 @@ void AudioSampleBuffer::copyFrom (const int destChannel,
int numSamples) throw()
{
jassert (&source != this);
jassert (destChannel >= 0 && destChannel < numChannels);
jassert (((unsigned int) destChannel) < (unsigned int) numChannels);
jassert (destStartSample >= 0 && destStartSample + numSamples <= size);
jassert (sourceChannel >= 0 && sourceChannel < source.numChannels);
jassert (((unsigned int) sourceChannel) < (unsigned int) source.numChannels);
jassert (sourceStartSample >= 0 && sourceStartSample + numSamples <= source.size);
if (numSamples > 0)
@@ -406,7 +405,7 @@ void AudioSampleBuffer::copyFrom (const int destChannel,
const float* source,
int numSamples) throw()
{
jassert (destChannel >= 0 && destChannel < numChannels);
jassert (((unsigned int) destChannel) < (unsigned int) numChannels);
jassert (destStartSample >= 0 && destStartSample + numSamples <= size);
jassert (source != 0);
@@ -424,7 +423,7 @@ void AudioSampleBuffer::findMinMax (const int channel,
float& minVal,
float& maxVal) const throw()
{
jassert (channel >= 0 && channel < numChannels);
jassert (((unsigned int) channel) < (unsigned int) numChannels);
jassert (startSample >= 0 && startSample + numSamples <= size);
if (numSamples <= 0)
@@ -459,7 +458,7 @@ float AudioSampleBuffer::getMagnitude (const int channel,
const int startSample,
const int numSamples) const throw()
{
jassert (channel >= 0 && channel < numChannels);
jassert (((unsigned int) channel) < (unsigned int) numChannels);
jassert (startSample >= 0 && startSample + numSamples <= size);
float mn, mx;
@@ -483,7 +482,7 @@ float AudioSampleBuffer::getRMSLevel (const int channel,
const int startSample,
const int numSamples) const throw()
{
jassert (channel >= 0 && channel < numChannels);
jassert (((unsigned int) channel) < (unsigned int) numChannels);
jassert (startSample >= 0 && startSample + numSamples <= size);
if (numSamples <= 0 || channel < 0 || channel >= numChannels)


+ 1
- 1
src/juce_appframework/audio/midi/juce_MidiFile.cpp View File

@@ -74,7 +74,7 @@ int MidiFile::getNumTracks() const throw()
const MidiMessageSequence* MidiFile::getTrack (const int index) const throw()
{
return (index >= 0 && index < numTracks) ? tracks[index] : 0;
return (((unsigned int) index) < (unsigned int) numTracks) ? tracks[index] : 0;
}
void MidiFile::addTrack (const MidiMessageSequence& trackSequence) throw()


+ 5
- 5
src/juce_appframework/audio/midi/juce_MidiKeyboardState.cpp View File

@@ -60,24 +60,24 @@ bool MidiKeyboardState::isNoteOn (const int midiChannel, const int n) const thro
{
jassert (midiChannel >= 0 && midiChannel <= 16);
return n >= 0 && n < 128
return ((unsigned int) n) < 128
&& (noteStates[n] & (1 << (midiChannel - 1))) != 0;
}
bool MidiKeyboardState::isNoteOnForChannels (const int midiChannelMask, const int n) const throw()
{
return n >= 0 && n < 128
return ((unsigned int) n) < 128
&& (noteStates[n] & midiChannelMask) != 0;
}
void MidiKeyboardState::noteOn (const int midiChannel, const int midiNoteNumber, const float velocity)
{
jassert (midiChannel >= 0 && midiChannel <= 16);
jassert (midiNoteNumber >= 0 && midiNoteNumber < 128);
jassert (((unsigned int) midiNoteNumber) < 128);
const ScopedLock sl (lock);
if (midiNoteNumber >= 0 && midiNoteNumber < 128)
if (((unsigned int) midiNoteNumber) < 128)
{
const int timeNow = (int) Time::getMillisecondCounter();
eventsToAdd.addEvent (MidiMessage::noteOn (midiChannel, midiNoteNumber, velocity), timeNow);
@@ -89,7 +89,7 @@ void MidiKeyboardState::noteOn (const int midiChannel, const int midiNoteNumber,
void MidiKeyboardState::noteOnInternal (const int midiChannel, const int midiNoteNumber, const float velocity)
{
if (midiNoteNumber >= 0 && midiNoteNumber < 128)
if (((unsigned int) midiNoteNumber) < 128)
{
noteStates [midiNoteNumber] |= (1 << (midiChannel - 1));


+ 13
- 13
src/juce_appframework/audio/midi/juce_MidiMessage.cpp View File

@@ -380,8 +380,8 @@ const MidiMessage MidiMessage::aftertouchChange (const int channel,
const int aftertouchValue) throw()
{
jassert (channel > 0 && channel <= 16);
jassert (noteNum >= 0 && noteNum <= 127);
jassert (aftertouchValue >= 0 && aftertouchValue <= 127);
jassert (((unsigned int) noteNum) <= 127);
jassert (((unsigned int) aftertouchValue) <= 127);
return MidiMessage (0xa0 | jlimit (0, 15, channel - 1),
noteNum & 0x7f,
@@ -404,7 +404,7 @@ const MidiMessage MidiMessage::channelPressureChange (const int channel,
const int pressure) throw()
{
jassert (channel > 0 && channel <= 16);
jassert (pressure >= 0 && pressure <= 127);
jassert (((unsigned int) pressure) <= 127);
return MidiMessage (0xd0 | jlimit (0, 15, channel - 1),
pressure & 0x7f);
@@ -443,7 +443,7 @@ const MidiMessage MidiMessage::pitchWheel (const int channel,
const int position) throw()
{
jassert (channel > 0 && channel <= 16);
jassert (position >= 0 && position <= 0x3fff);
jassert (((unsigned int) position) <= 0x3fff);
return MidiMessage (0xe0 | jlimit (0, 15, channel - 1),
position & 127,
@@ -493,7 +493,7 @@ const MidiMessage MidiMessage::noteOn (const int channel,
const uint8 velocity) throw()
{
jassert (channel > 0 && channel <= 16);
jassert (noteNumber >= 0 && noteNumber <= 127);
jassert (((unsigned int) noteNumber) <= 127);
return MidiMessage (0x90 | jlimit (0, 15, channel - 1),
noteNumber & 127,
@@ -504,7 +504,7 @@ const MidiMessage MidiMessage::noteOff (const int channel,
const int noteNumber) throw()
{
jassert (channel > 0 && channel <= 16);
jassert (noteNumber >= 0 && noteNumber <= 127);
jassert (((unsigned int) noteNumber) <= 127);
return MidiMessage (0x80 | jlimit (0, 15, channel - 1), noteNumber & 127, 0);
}
@@ -1010,7 +1010,7 @@ const String MidiMessage::getMidiNoteName (int note,
"F", "Gb", "G", "Ab", "A",
"Bb", "B" };
if (note >= 0 && note < 128)
if (((unsigned int) note) < 128)
{
const String s ((useSharps) ? sharpNoteNames [note % 12]
: flatNoteNames [note % 12]);
@@ -1059,8 +1059,8 @@ const String MidiMessage::getGMInstrumentName (int n) throw()
"Applause", "Gunshot"
};
return (n >= 0 && n < 128) ? names[n]
: (const char*)0;
return (((unsigned int) n) < 128) ? names[n]
: (const char*)0;
}
const String MidiMessage::getGMInstrumentBankName (int n) throw()
@@ -1073,8 +1073,8 @@ const String MidiMessage::getGMInstrumentBankName (int n) throw()
"Synth Effects", "Ethnic", "Percussive", "Sound Effects"
};
return (n >= 0 && n <= 15) ? names[n]
: (const char*)0;
return (((unsigned int) n) <= 15) ? names[n]
: (const char*)0;
}
const String MidiMessage::getRhythmInstrumentName (int n) throw()
@@ -1124,8 +1124,8 @@ const String MidiMessage::getControllerName (int n) throw()
"Poly Operation"
};
return (n >= 0 && n < 128) ? names[n]
: (const char*)0;
return (((unsigned int) n) < 128) ? names[n]
: (const char*)0;
}
END_JUCE_NAMESPACE

+ 4
- 4
src/juce_appframework/audio/midi/juce_MidiMessageSequence.cpp View File

@@ -135,10 +135,10 @@ double MidiMessageSequence::getEndTime() const
double MidiMessageSequence::getEventTime (const int index) const
{
if (index < 0 || index >= list.size())
return 0.0;
else
if (((unsigned int) index) < (unsigned int) list.size())
return list.getUnchecked (index)->message.getTimeStamp();
return 0.0;
}
//==============================================================================
@@ -161,7 +161,7 @@ void MidiMessageSequence::addEvent (const MidiMessage& newMessage,
void MidiMessageSequence::deleteEvent (const int index,
const bool deleteMatchingNoteUp)
{
if (index >= 0 && index < list.size())
if (((unsigned int) index) < (unsigned int) list.size())
{
if (deleteMatchingNoteUp)
deleteEvent (getIndexOfMatchingKeyUp (index), false);


+ 3
- 3
src/juce_appframework/audio/processors/juce_AudioProcessor.cpp View File

@@ -110,7 +110,7 @@ void AudioProcessor::setParameterNotifyingHost (const int parameterIndex,
void AudioProcessor::sendParamChangeMessageToListeners (const int parameterIndex, const float newValue)
{
jassert (parameterIndex >= 0 && parameterIndex < getNumParameters());
jassert (((unsigned int) parameterIndex) < (unsigned int) getNumParameters());
for (int i = listeners.size(); --i >= 0;)
{
@@ -125,7 +125,7 @@ void AudioProcessor::sendParamChangeMessageToListeners (const int parameterIndex
void AudioProcessor::beginParameterChangeGesture (int parameterIndex)
{
jassert (parameterIndex >= 0 && parameterIndex < getNumParameters());
jassert (((unsigned int) parameterIndex) < (unsigned int) getNumParameters());
#ifdef JUCE_DEBUG
// This means you've called beginParameterChangeGesture twice in succession without a matching
@@ -146,7 +146,7 @@ void AudioProcessor::beginParameterChangeGesture (int parameterIndex)
void AudioProcessor::endParameterChangeGesture (int parameterIndex)
{
jassert (parameterIndex >= 0 && parameterIndex < getNumParameters());
jassert (((unsigned int) parameterIndex) < (unsigned int) getNumParameters());
#ifdef JUCE_DEBUG
// This means you've called endParameterChangeGesture without having previously called


+ 1
- 1
src/juce_appframework/gui/components/controls/juce_ComboBox.cpp View File

@@ -286,7 +286,7 @@ void ComboBox::setSelectedItemIndex (const int index,
{
if (currentIndex != index || label->getText() != getItemText (currentIndex))
{
if (index >= 0 && index < getNumItems())
if (((unsigned int) index) < (unsigned int) getNumItems())
currentIndex = index;
else
currentIndex = -1;


+ 4
- 4
src/juce_appframework/gui/components/controls/juce_ListBox.cpp View File

@@ -470,7 +470,7 @@ void ListBox::selectRowInternal (const int row,
if ((! isRowSelected (row))
|| (deselectOthersFirst && getNumSelectedRows() > 1))
{
if (row >= 0 && row < totalItems)
if (((unsigned int) row) < (unsigned int) totalItems)
{
if (deselectOthersFirst)
selected.clear();
@@ -616,7 +616,7 @@ int ListBox::getNumSelectedRows() const
int ListBox::getSelectedRow (const int index) const
{
return (index >= 0 && index < selected.size())
return (((unsigned int) index) < (unsigned int) selected.size())
? selected [index] : -1;
}
@@ -633,11 +633,11 @@ int ListBox::getLastRowSelected() const
//==============================================================================
int ListBox::getRowContainingPosition (const int x, const int y) const throw()
{
if (x >= 0 && x < getWidth())
if (((unsigned int) x) < (unsigned int) getWidth())
{
const int row = (viewport->getViewPositionY() + y - viewport->getY()) / rowHeight;
if (row >= 0 && row < totalItems)
if (((unsigned int) row) < (unsigned int) totalItems)
return row;
}


+ 2
- 2
src/juce_appframework/gui/components/controls/juce_TableHeaderComponent.cpp View File

@@ -212,7 +212,7 @@ void TableHeaderComponent::setColumnWidth (const int columnId, const int newWidt
{
const int index = getIndexOfColumnId (columnId, true) + 1;
if (index >= 0 && index < numColumns)
if (((unsigned int) index) < (unsigned int) numColumns)
{
const int x = getColumnPosition (index).getX();
@@ -879,7 +879,7 @@ void TableHeaderComponent::handleAsyncUpdate()
int TableHeaderComponent::getResizeDraggerAt (const int mouseX) const throw()
{
if (mouseX >= 0 && mouseX < getWidth())
if (((unsigned int) mouseX) < (unsigned int) getWidth())
{
const int draggableDistance = 3;
int x = 0;


+ 2
- 2
src/juce_appframework/gui/components/controls/juce_TreeView.cpp View File

@@ -802,7 +802,7 @@ void TreeViewItem::removeSubItem (const int index, const bool deleteItem)
if (ownerView != 0)
ownerView->nodeAlterationLock.enter();
if (index >= 0 && index < subItems.size())
if (((unsigned int) index) < (unsigned int) subItems.size())
{
subItems.remove (index, deleteItem);
treeHasChanged();
@@ -1127,7 +1127,7 @@ TreeViewItem* TreeViewItem::getItemOnRow (int index) throw()
TreeViewItem* TreeViewItem::findItemRecursively (int y) throw()
{
if (y >= 0 && y < totalHeight)
if (((unsigned int) y) < (unsigned int) totalHeight)
{
const int h = itemHeight;


+ 2
- 2
src/juce_appframework/gui/components/filebrowser/juce_FileSearchPathListComponent.cpp View File

@@ -150,7 +150,7 @@ void FileSearchPathListComponent::paintListBoxItem (int rowNumber, Graphics& g,
void FileSearchPathListComponent::deleteKeyPressed (int row)
{
if (row >= 0 && row < path.getNumPaths())
if (((unsigned int) row) < (unsigned int) path.getNumPaths())
{
path.remove (row);
changed();
@@ -263,7 +263,7 @@ void FileSearchPathListComponent::buttonClicked (Button* button)
}
else if (button == downButton)
{
if (currentRow >= 0 && currentRow < path.getNumPaths()-1)
if (currentRow >= 0 && currentRow < path.getNumPaths() - 1)
{
const File f (path[currentRow]);
path.remove (currentRow);


+ 4
- 2
src/juce_appframework/gui/components/juce_Component.cpp View File

@@ -1103,7 +1103,8 @@ void Component::getInterceptsMouseClicks (bool& allowsClicksOnThisComponent,
bool Component::contains (const int x, const int y)
{
if (x >= 0 && y >= 0 && x < getWidth() && y < getHeight()
if (((unsigned int) x) < (unsigned int) getWidth()
&& ((unsigned int) y) < (unsigned int) getHeight()
&& hitTest (x, y))
{
if (parentComponent_ != 0)
@@ -1146,7 +1147,8 @@ bool Component::reallyContains (int x, int y, const bool returnTrueIfWithinAChil
Component* Component::getComponentAt (const int x, const int y)
{
if (flags.visibleFlag
&& x >= 0 && y >= 0 && x < getWidth() && y < getHeight()
&& ((unsigned int) x) < (unsigned int) getWidth()
&& ((unsigned int) y) < (unsigned int) getHeight()
&& hitTest (x, y))
{
for (int i = childComponentList_.size(); --i >= 0;)


+ 10
- 8
src/juce_appframework/gui/components/layout/juce_TabbedButtonBar.cpp View File

@@ -92,14 +92,15 @@ bool TabBarButton::hitTest (int mx, int my)
if (owner->getOrientation() == TabbedButtonBar::TabsAtLeft
|| owner->getOrientation() == TabbedButtonBar::TabsAtRight)
{
if (mx >= 0 && mx < getWidth()
&& my >= y + overlapPixels && my < y + h - overlapPixels)
if (((unsigned int) mx) < (unsigned int) getWidth()
&& my >= y + overlapPixels
&& my < y + h - overlapPixels)
return true;
}
else
{
if (mx >= x + overlapPixels && mx < x + w - overlapPixels
&& my >= 0 && my < getHeight())
&& ((unsigned int) my) < (unsigned int) getHeight())
return true;
}
@@ -233,7 +234,7 @@ void TabbedButtonBar::addTab (const String& tabName,
if (tabName.isNotEmpty())
{
if (insertIndex < 0 || insertIndex > tabs.size())
if (((unsigned int) insertIndex) > (unsigned int) tabs.size())
insertIndex = tabs.size();
for (int i = tabs.size(); --i >= insertIndex;)
@@ -262,7 +263,7 @@ void TabbedButtonBar::addTab (const String& tabName,
void TabbedButtonBar::setTabName (const int tabIndex,
const String& newName)
{
if (tabIndex >= 0 && tabIndex < tabs.size()
if (((unsigned int) tabIndex) < (unsigned int) tabs.size()
&& tabs[tabIndex] != newName)
{
tabs.set (tabIndex, newName);
@@ -278,7 +279,7 @@ void TabbedButtonBar::setTabName (const int tabIndex,
void TabbedButtonBar::removeTab (const int tabIndex)
{
if (tabIndex >= 0 && tabIndex < tabs.size())
if (((unsigned int) tabIndex) < (unsigned int) tabs.size())
{
const int oldTabIndex = currentTabIndex;
if (currentTabIndex == tabIndex)
@@ -328,7 +329,7 @@ void TabbedButtonBar::setCurrentTabIndex (int newIndex)
{
if (currentTabIndex != newIndex)
{
if (newIndex < 0 || newIndex >= tabs.size())
if (((unsigned int) newIndex) >= (unsigned int) tabs.size())
newIndex = -1;
currentTabIndex = newIndex;
@@ -505,7 +506,8 @@ const Colour TabbedButtonBar::getTabBackgroundColour (const int tabIndex)
void TabbedButtonBar::setTabBackgroundColour (const int tabIndex, const Colour& newColour)
{
if (tabIndex >= 0 && tabIndex < tabColours.size() && tabColours [tabIndex] != newColour)
if (((unsigned int) tabIndex) < (unsigned int) tabColours.size()
&& tabColours [tabIndex] != newColour)
{
tabColours.set (tabIndex, newColour);
repaint();


+ 3
- 3
src/juce_appframework/gui/components/menus/juce_MenuBarComponent.cpp View File

@@ -156,7 +156,7 @@ int MenuBarComponent::getItemAt (const int x, const int y)
void MenuBarComponent::repaintMenuItem (int index)
{
if (index >= 0 && index < xPositions.size())
if (((unsigned int) index) < (unsigned int) xPositions.size())
{
const int x1 = xPositions [index];
const int x2 = xPositions [index + 1];
@@ -223,7 +223,7 @@ void MenuBarComponent::showMenu (int index)
indexToShowAgain = -1;
repaint();
if (itemUnderMouse >= 0 && itemUnderMouse < menuNames.size())
if (((unsigned int) itemUnderMouse) < (unsigned int) menuNames.size())
{
PopupMenu m (model->getMenuForIndex (itemUnderMouse,
menuNames [itemUnderMouse]));
@@ -268,7 +268,7 @@ void MenuBarComponent::showMenu (int index)
repaint();
itemUnderMouse = indexToShowAgain;
if (itemUnderMouse < 0 || itemUnderMouse >= menuNames.size())
if (((unsigned int) itemUnderMouse) >= (unsigned int) menuNames.size())
break;
}
else


+ 2
- 2
src/juce_appframework/gui/components/menus/juce_PopupMenu.cpp View File

@@ -423,7 +423,7 @@ public:
{
const int y = minY - mw->windowPos.getY();
mw->ensureItemIsVisible (itemIdThatMustBeVisible,
(y >= 0 && y < mw->windowPos.getHeight()) ? y : -1);
(((unsigned int) y) < (unsigned int) mw->windowPos.getHeight()) ? y : -1);
}
mw->resizeToBestWindowPos();
@@ -696,7 +696,7 @@ public:
bool overScrollArea = false;
if (isScrolling()
&& (isOver || (isDown && x >= 0 && x < getWidth()))
&& (isOver || (isDown && ((unsigned int) x) < (unsigned int) getWidth()))
&& ((isScrollZoneActive (false) && y < scrollZone)
|| (isScrollZoneActive (true) && y > getHeight() - scrollZone)))
{


+ 2
- 2
src/juce_appframework/gui/components/special/juce_AudioDeviceSelectorComponent.cpp View File

@@ -103,7 +103,7 @@ public:
int width, int height,
bool rowIsSelected)
{
if (row >= 0 && row < items.size())
if (((unsigned int) row) < (unsigned int) items.size())
{
if (rowIsSelected)
g.fillAll (findColour (TextEditor::highlightColourId)
@@ -190,7 +190,7 @@ private:
void flipEnablement (const int row)
{
if (row >= 0 && row < items.size())
if (((unsigned int) row) < (unsigned int) items.size())
{
AudioIODevice* const audioDevice = deviceManager.getCurrentAudioDevice();


+ 2
- 3
src/juce_appframework/gui/components/special/juce_MagnifierComponent.cpp View File

@@ -113,9 +113,8 @@ public:
bool contains (int x, int y, bool) const
{
return x >= 0 && y >= 0
&& x < magnifierComp->getWidth()
&& y < magnifierComp->getHeight();
return ((unsigned int) x) < (unsigned int) magnifierComp->getWidth()
&& ((unsigned int) y) < (unsigned int) magnifierComp->getHeight();
}
void repaint (int x, int y, int w, int h)


+ 2
- 4
src/juce_appframework/gui/components/windows/juce_ComponentPeer.cpp View File

@@ -357,10 +357,8 @@ void ComponentPeer::sendFakeMouseMove() throw()
int x, y;
component->getMouseXYRelative (x, y);
if (x >= 0
&& y >= 0
&& x < component->getWidth()
&& y < component->getHeight()
if (((unsigned int) x) < (unsigned int) component->getWidth()
&& ((unsigned int) y) < (unsigned int) component->getHeight()
&& contains (x, y, false))
{
postMessage (new Message (fakeMouseMoveMessage, x, y, 0));


+ 4
- 4
src/juce_appframework/gui/graphics/fonts/juce_GlyphArrangement.cpp View File

@@ -435,7 +435,7 @@ void GlyphArrangement::ensureNumGlyphsAllocated (const int minGlyphs) throw()
void GlyphArrangement::incGlyphRefCount (const int i) const throw()
{
jassert (i >= 0 && i < numGlyphs);
jassert (((unsigned int) i) < (unsigned int) numGlyphs);
if (glyphs[i].glyphInfo != 0 && glyphs[i].glyphInfo->getTypeface() != 0)
glyphs[i].glyphInfo->getTypeface()->incReferenceCount();
@@ -457,7 +457,7 @@ void GlyphArrangement::clear() throw()
PositionedGlyph& GlyphArrangement::getGlyph (const int index) const throw()
{
jassert (index >= 0 && index < numGlyphs);
jassert (((unsigned int) index) < (unsigned int) numGlyphs);
return glyphs [index];
}
@@ -966,7 +966,7 @@ void GlyphArrangement::moveRangeOfGlyphs (int startIndex, int num,
while (--num >= 0)
{
jassert (startIndex >= 0 && startIndex <= numGlyphs);
jassert (((unsigned int) startIndex) <= (unsigned int) numGlyphs);
glyphs [startIndex++].moveBy (dx, dy);
}
}
@@ -986,7 +986,7 @@ void GlyphArrangement::stretchRangeOfGlyphs (int startIndex, int num,
while (--num >= 0)
{
jassert (startIndex >= 0 && startIndex <= numGlyphs);
jassert (((unsigned int) startIndex) <= (unsigned int) numGlyphs);
PositionedGlyph& pg = glyphs[startIndex++];
pg.x = xAnchor + (pg.x - xAnchor) * horizontalScaleFactor;


+ 3
- 3
src/juce_appframework/gui/graphics/geometry/juce_RectangleList.cpp View File

@@ -73,10 +73,10 @@ void RectangleList::clear() throw()
const Rectangle RectangleList::getRectangle (const int index) const throw()
{
if (index >= 0 && index < rects.size())
if (((unsigned int) index) < (unsigned int) rects.size())
return rects.getReference (index);
else
return Rectangle();
return Rectangle();
}
bool RectangleList::isEmpty() const throw()


+ 7
- 3
src/juce_appframework/gui/graphics/imaging/juce_Image.cpp View File

@@ -229,7 +229,8 @@ const Colour Image::getPixelAt (const int x, const int y) const
{
Colour c;
if (x >= 0 && x < imageWidth && y >= 0 && y < imageHeight)
if (((unsigned int) x) < (unsigned int) imageWidth
&& ((unsigned int) y) < (unsigned int) imageHeight)
{
int ls, ps;
const uint8* const pixels = lockPixelDataReadOnly (x, y, 1, 1, ls, ps);
@@ -254,7 +255,8 @@ const Colour Image::getPixelAt (const int x, const int y) const
void Image::setPixelAt (const int x, const int y,
const Colour& colour)
{
if (x >= 0 && x < imageWidth && y >= 0 && y < imageHeight)
if (((unsigned int) x) < (unsigned int) imageWidth
&& ((unsigned int) y) < (unsigned int) imageHeight)
{
int ls, ps;
uint8* const pixels = lockPixelDataReadWrite (x, y, 1, 1, ls, ps);
@@ -274,7 +276,9 @@ void Image::setPixelAt (const int x, const int y,
void Image::multiplyAlphaAt (const int x, const int y,
const float multiplier)
{
if (x >= 0 && x < imageWidth && y >= 0 && y < imageHeight && hasAlphaChannel())
if (((unsigned int) x) < (unsigned int) imageWidth
&& ((unsigned int) y) < (unsigned int) imageHeight
&& hasAlphaChannel())
{
int ls, ps;
uint8* const pixels = lockPixelDataReadWrite (x, y, 1, 1, ls, ps);


+ 2
- 2
src/juce_appframework/gui/graphics/imaging/juce_ImageConvolutionKernel.cpp View File

@@ -61,8 +61,8 @@ void ImageConvolutionKernel::setKernelValue (const int x,
const int y,
const float value) throw()
{
if (x >= 0 && x < size
&& y >= 0 && y < size)
if (((unsigned int) x) < (unsigned int) size
&& ((unsigned int) y) < (unsigned int) size)
{
values[x][y] = value;
}


+ 7
- 2
src/juce_core/basics/juce_MathsFunctions.h View File

@@ -160,9 +160,13 @@ inline double jmin (const double a, const double b, const double c, const double
//==============================================================================
/** Constrains a value to keep it within a given limit.
/** Constrains a value to keep it within a given range.
Note that this expects that lowerLimit <= upperLimit. If this isn't true,
This will check that the specified value lies between the lower and upper bounds
specified, and if not, will return the nearest value that would be in-range. Effectively,
it's like calling jmax (lowerLimit, jmin (upperLimit, value)).
Note that it expects that lowerLimit <= upperLimit. If this isn't true,
the results will be unpredictable.
@param lowerLimit the minimum value to return
@@ -170,6 +174,7 @@ inline double jmin (const double a, const double b, const double c, const double
@param valueToConstrain the value to try to return
@returns the closest value to valueToConstrain which lies between lowerLimit
and upperLimit (inclusive)
@see jlimit0To, jmin, jmax
*/
template <class Type>
inline Type jlimit (const Type lowerLimit,


+ 4
- 0
src/juce_core/basics/juce_SystemStats.h View File

@@ -87,6 +87,10 @@ public:
*/
static const String getOperatingSystemName() throw();
/** Returns true if the OS is 64-bit, or false for a 32-bit OS.
*/
static bool isOperatingSystem64Bit() throw();
//==============================================================================
// CPU and memory information..


+ 14
- 16
src/juce_core/containers/juce_Array.h View File

@@ -231,8 +231,9 @@ public:
inline ElementType operator[] (const int index) const throw()
{
lock.enter();
const ElementType result = (index >= 0 && index < numUsed) ? this->elements [index]
: ElementType();
const ElementType result = (((unsigned int) index) < (unsigned int) numUsed)
? this->elements [index]
: ElementType();
lock.exit();
return result;
@@ -250,7 +251,7 @@ public:
inline ElementType getUnchecked (const int index) const throw()
{
lock.enter();
jassert (index >= 0 && index < numUsed);
jassert (((unsigned int) index) < (unsigned int) numUsed);
const ElementType result = this->elements [index];
lock.exit();
@@ -268,7 +269,7 @@ public:
*/
inline ElementType& getReference (const int index) const throw()
{
jassert (index >= 0 && index < numUsed);
jassert (((unsigned int) index) < (unsigned int) numUsed);
return this->elements [index];
}
@@ -405,11 +406,8 @@ public:
lock.enter();
this->ensureAllocatedSize (numUsed + 1);
if (indexToInsertAt >= 0)
if (((unsigned int) indexToInsertAt) < (unsigned int) numUsed)
{
if (indexToInsertAt > numUsed)
indexToInsertAt = numUsed;
ElementType* const insertPos = this->elements + indexToInsertAt;
const int numberToMove = numUsed - indexToInsertAt;
@@ -447,7 +445,7 @@ public:
lock.enter();
this->ensureAllocatedSize (numUsed + numberOfTimesToInsertIt);
if (indexToInsertAt >= 0 && indexToInsertAt < numUsed)
if (((unsigned int) indexToInsertAt) < (unsigned int) numUsed)
{
ElementType* insertPos = this->elements + indexToInsertAt;
const int numberToMove = numUsed - indexToInsertAt;
@@ -489,7 +487,7 @@ public:
lock.enter();
this->ensureAllocatedSize (numUsed + numberOfElements);
if (indexToInsertAt >= 0 && indexToInsertAt < numUsed)
if (((unsigned int) indexToInsertAt) < (unsigned int) numUsed)
{
ElementType* insertPos = this->elements + indexToInsertAt;
const int numberToMove = numUsed - indexToInsertAt;
@@ -573,7 +571,7 @@ public:
const ElementType newValue) throw()
{
lock.enter();
jassert (indexToChange >= 0 && indexToChange < numUsed);
jassert (((unsigned int) indexToChange) < (unsigned int) numUsed);
this->elements [indexToChange] = newValue;
lock.exit();
}
@@ -737,7 +735,7 @@ public:
{
lock.enter();
if (indexToRemove >= 0 && indexToRemove < numUsed)
if (((unsigned int) indexToRemove) < (unsigned int) numUsed)
{
--numUsed;
@@ -916,8 +914,8 @@ public:
{
lock.enter();
if (index1 >= 0 && index1 < numUsed
&& index2 >= 0 && index2 < numUsed)
if (((unsigned int) index1) < (unsigned int) numUsed
&& ((unsigned int) index2) < (unsigned int) numUsed)
{
swapVariables (this->elements [index1],
this->elements [index2]);
@@ -947,9 +945,9 @@ public:
{
lock.enter();
if (currentIndex >= 0 && currentIndex < numUsed)
if (((unsigned int) currentIndex) < (unsigned int) numUsed)
{
if (newIndex < 0 || newIndex > numUsed - 1)
if (((unsigned int) newIndex) >= (unsigned int) numUsed)
newIndex = numUsed - 1;
const ElementType value = this->elements [currentIndex];


+ 3
- 3
src/juce_core/containers/juce_BitArray.cpp View File

@@ -160,7 +160,7 @@ bool BitArray::operator!= (const BitArray& other) const throw()
bool BitArray::operator[] (const int bit) const throw()
{
return (bit >= 0 && bit <= highestBit)
return (((unsigned int) bit) <= (unsigned int) highestBit)
&& ((values [bit >> 5] & (1 << (bit & 31))) != 0);
}
@@ -211,7 +211,7 @@ void BitArray::setBit (const int bit,
void BitArray::clearBit (const int bit) throw()
{
if (bit >= 0 && bit <= highestBit)
if (((unsigned int) bit) <= (unsigned int) highestBit)
values [bit >> 5] &= ~(1 << (bit & 31));
}
@@ -922,7 +922,7 @@ void BitArray::parseString (const String& text,
const tchar c = *t++;
const int digit = CharacterFunctions::getHexDigitValue (c);
if (digit >= 0 && digit < base)
if (((unsigned int) digit) < (unsigned int) base)
{
shiftBits (bits);
add (digit);


+ 9
- 8
src/juce_core/containers/juce_OwnedArray.h View File

@@ -124,8 +124,9 @@ public:
inline ObjectClass* operator[] (const int index) const throw()
{
lock.enter();
ObjectClass* const result = (index >= 0 && index < numUsed) ? this->elements [index]
: (ObjectClass*) 0;
ObjectClass* const result = (((unsigned int) index) < (unsigned int) numUsed)
? this->elements [index]
: (ObjectClass*) 0;
lock.exit();
return result;
@@ -139,7 +140,7 @@ public:
inline ObjectClass* getUnchecked (const int index) const throw()
{
lock.enter();
jassert (index >= 0 && index < numUsed);
jassert (((unsigned int) index) < (unsigned int) numUsed);
ObjectClass* const result = this->elements [index];
lock.exit();
@@ -464,7 +465,7 @@ public:
lock.enter();
ObjectClass* toDelete = 0;
if (indexToRemove >= 0 && indexToRemove < numUsed)
if (((unsigned int) indexToRemove) < (unsigned int) numUsed)
{
ObjectClass** const e = this->elements + indexToRemove;
@@ -598,8 +599,8 @@ public:
{
lock.enter();
if (index1 >= 0 && index1 < numUsed
&& index2 >= 0 && index2 < numUsed)
if (((unsigned int) index1) < (unsigned int) numUsed
&& ((unsigned int) index2) < (unsigned int) numUsed)
{
swapVariables (this->elements [index1],
this->elements [index2]);
@@ -628,9 +629,9 @@ public:
{
lock.enter();
if (currentIndex >= 0 && currentIndex < numUsed)
if (((unsigned int) currentIndex) < (unsigned int) numUsed)
{
if (newIndex < 0 || newIndex >= numUsed)
if (((unsigned int) newIndex) >= (unsigned int) numUsed)
newIndex = numUsed - 1;
ObjectClass* const value = this->elements [currentIndex];


+ 10
- 8
src/juce_core/containers/juce_ReferenceCountedArray.h View File

@@ -161,8 +161,9 @@ public:
inline ObjectClass* operator[] (const int index) const throw()
{
lock.enter();
ObjectClass* const result = (index >= 0 && index < numUsed) ? this->elements [index]
: (ObjectClass*) 0;
ObjectClass* const result = (((unsigned int) index) < (unsigned int) numUsed)
? this->elements [index]
: (ObjectClass*) 0;
lock.exit();
return result;
}
@@ -175,7 +176,7 @@ public:
inline ObjectClass* getUnchecked (const int index) const throw()
{
lock.enter();
jassert (index >= 0 && index < numUsed);
jassert (((unsigned int) index) < (unsigned int) numUsed);
ObjectClass* const result = this->elements [index];
lock.exit();
return result;
@@ -302,6 +303,7 @@ public:
if (indexToInsertAt >= 0)
{
lock.enter();
if (indexToInsertAt > numUsed)
indexToInsertAt = numUsed;
@@ -458,7 +460,7 @@ public:
{
lock.enter();
if (indexToRemove >= 0 && indexToRemove < numUsed)
if (((unsigned int) indexToRemove) < (unsigned int) numUsed)
{
ObjectClass** const e = this->elements + indexToRemove;
@@ -577,8 +579,8 @@ public:
{
lock.enter();
if (index1 >= 0 && index1 < numUsed
&& index2 >= 0 && index2 < numUsed)
if (((unsigned int) index1) < (unsigned int) numUsed
&& ((unsigned int) index2) < (unsigned int) numUsed)
{
swapVariables (this->elements [index1],
this->elements [index2]);
@@ -607,9 +609,9 @@ public:
{
lock.enter();
if (currentIndex >= 0 && currentIndex < numUsed)
if (((unsigned int) currentIndex) < (unsigned int) numUsed)
{
if (newIndex < 0 || newIndex > numUsed - 1)
if (((unsigned int) newIndex) >= (unsigned int) numUsed)
newIndex = numUsed - 1;
ObjectClass* const value = this->elements [currentIndex];


+ 5
- 4
src/juce_core/containers/juce_SortedSet.h View File

@@ -216,8 +216,9 @@ public:
inline ElementType operator[] (const int index) const throw()
{
lock.enter();
const ElementType result = (index >= 0 && index < numUsed) ? this->elements [index]
: (ElementType)0;
const ElementType result = (((unsigned int) index) < (unsigned int) numUsed)
? this->elements [index]
: (ElementType)0;
lock.exit();
return result;
@@ -234,7 +235,7 @@ public:
inline ElementType getUnchecked (const int index) const throw()
{
lock.enter();
jassert (index >= 0 && index < numUsed);
jassert (((unsigned int) index) < (unsigned int) numUsed);
const ElementType result = this->elements [index];
lock.exit();
@@ -471,7 +472,7 @@ public:
{
lock.enter();
if (indexToRemove >= 0 && indexToRemove < numUsed)
if (((unsigned int) indexToRemove) < (unsigned int) numUsed)
{
--numUsed;


+ 1
- 1
src/juce_core/containers/juce_SparseSet.h View File

@@ -160,7 +160,7 @@ public:
Type& startValue,
Type& numValues) const throw()
{
if (rangeIndex >= 0 && rangeIndex < getNumRanges())
if (((unsigned int) rangeIndex) < (unsigned int) getNumRanges())
{
startValue = values [rangeIndex << 1];
numValues = values [(rangeIndex << 1) + 1] - startValue;


+ 2
- 2
src/juce_core/text/juce_String.cpp View File

@@ -1431,7 +1431,7 @@ const String String::replaceCharacters (const String& charactersToReplace,
{
const int index = charactersToReplace.indexOfChar (*t);
if (index >= 0 && index < len2)
if (((unsigned int) index) < (unsigned int) len2)
*t = charactersToInsertInstead [index];
++t;
@@ -1508,7 +1508,7 @@ const String String::toLowerCase() const throw()
//==============================================================================
tchar& String::operator[] (const int index) throw()
{
jassert (index >= 0 && index <= length());
jassert (((unsigned int) index) <= (unsigned int) length());
dupeInternalIfMultiplyReferenced();


+ 1
- 1
src/juce_core/text/juce_String.h View File

@@ -477,7 +477,7 @@ public:
No checks are made to see if the index is within a valid range, so be careful!
*/
inline const tchar& operator[] (const int index) const throw() { jassert (index >= 0 && index <= length()); return text->text [index]; }
inline const tchar& operator[] (const int index) const throw() { jassert (((unsigned int) index) <= (unsigned int) length()); return text->text [index]; }
/** Returns a character from the string such that it can also be altered.


+ 1
- 1
src/juce_core/text/juce_StringArray.cpp View File

@@ -128,7 +128,7 @@ void StringArray::clear() throw()
const String& StringArray::operator[] (const int index) const throw()
{
if (index >= 0 && index < strings.size())
if (((unsigned int) index) < (unsigned int) strings.size())
return *(const String*) (strings.getUnchecked (index));
return String::empty;


+ 111
- 0
src/juce_core/threads/juce_ScopedTryLock.h View File

@@ -0,0 +1,111 @@
/*
==============================================================================
This file is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-7 by Raw Material Software ltd.
------------------------------------------------------------------------------
JUCE can be redistributed and/or modified under the terms of the
GNU General Public License, as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.
JUCE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with JUCE; if not, visit www.gnu.org/licenses or write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
------------------------------------------------------------------------------
If you'd like to release a closed-source product which uses JUCE, commercial
licenses are also available: visit www.rawmaterialsoftware.com/juce for
more information.
==============================================================================
*/
#ifndef __JUCE_SCOPEDTRYLOCK_JUCEHEADER__
#define __JUCE_SCOPEDTRYLOCK_JUCEHEADER__
#include "juce_CriticalSection.h"
//==============================================================================
/**
Automatically tries to lock and unlock a CriticalSection object.
Use one of these as a local variable to control access to a CriticalSection.
e.g. @code
CriticalSection myCriticalSection;
for (;;)
{
const ScopedTryLock myScopedTryLock (myCriticalSection);
// Unlike using a ScopedLock, this may fail to actually get the lock, so you
// should test this with the isLocked() method before doing your thread-unsafe
// action..
if (myScopedTryLock.isLocked())
{
...do some stuff...
}
else
{
..our attempt at locking failed because another thread had already locked it..
}
// myCriticalSection gets unlocked here (if it was locked)
}
@endcode
@see CriticalSection::tryEnter, ScopedLock, ScopedUnlock, ScopedReadLock
*/
class JUCE_API ScopedTryLock
{
public:
//==============================================================================
/** Creates a ScopedTryLock.
As soon as it is created, this will try to lock the CriticalSection, and
when the ScopedTryLock object is deleted, the CriticalSection will
be unlocked if the lock was successful.
Make sure this object is created and deleted by the same thread,
otherwise there are no guarantees what will happen! Best just to use it
as a local stack object, rather than creating one with the new() operator.
*/
inline ScopedTryLock (const CriticalSection& lock) throw() : lock_ (lock), lockWasSuccessful (lock.tryEnter()) {}
/** Destructor.
The CriticalSection will be unlocked (if locked) when the destructor is called.
Make sure this object is created and deleted by the same thread,
otherwise there are no guarantees what will happen!
*/
inline ~ScopedTryLock() throw() { if (lockWasSuccessful) lock_.exit(); }
/** Lock state
@return True if the CriticalSection is locked.
*/
bool isLocked() const throw() { return lockWasSuccessful; }
private:
//==============================================================================
const CriticalSection& lock_;
const bool lockWasSuccessful;
ScopedTryLock (const ScopedTryLock&);
const ScopedTryLock& operator= (const ScopedTryLock&);
};
#endif // __JUCE_SCOPEDTRYLOCK_JUCEHEADER__

+ 3
- 0
src/juce_core_includes.h View File

@@ -221,6 +221,9 @@
#ifndef __JUCE_SCOPEDREADLOCK_JUCEHEADER__
#include "juce_core/threads/juce_ScopedReadLock.h"
#endif
#ifndef __JUCE_SCOPEDTRYLOCK_JUCEHEADER__
#include "juce_core/threads/juce_ScopedTryLock.h"
#endif
#ifndef __JUCE_SCOPEDWRITELOCK_JUCEHEADER__
#include "juce_core/threads/juce_ScopedWriteLock.h"
#endif


Loading…
Cancel
Save