From bc5a7a6b7eeba7338ad83b5557fba459d3b13dad Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Thu, 25 Feb 2010 18:31:06 +0000 Subject: [PATCH] Updated VC6 project. Removed some unsafe templated casts from MemoryBlock and HeapBlock. --- build/win32/vc6/JUCE.dsp | 72 +++++- .../wrapper/juce_IncludeCharacteristics.h | 3 + juce_amalgamated.cpp | 217 +++++++++++------- juce_amalgamated.h | 72 +++--- src/audio/dsp/juce_AudioSampleBuffer.cpp | 16 +- src/audio/midi/juce_MidiBuffer.cpp | 32 +-- src/audio/midi/juce_MidiBuffer.h | 1 + src/containers/juce_HeapBlock.h | 21 +- src/containers/juce_MemoryBlock.cpp | 14 +- src/containers/juce_MemoryBlock.h | 8 - src/containers/juce_ScopedPointer.h | 37 +-- src/containers/juce_Variant.cpp | 2 +- src/core/juce_StandardHeader.h | 6 +- src/events/juce_MessageManager.h | 2 + src/gui/components/buttons/juce_Button.h | 1 + src/gui/components/controls/juce_Slider.cpp | 12 +- .../components/controls/juce_TextEditor.cpp | 21 +- src/gui/components/controls/juce_TextEditor.h | 1 + src/gui/components/juce_Component.cpp | 2 +- .../layout/juce_TabbedComponent.cpp | 4 +- .../mouse/juce_DragAndDropContainer.cpp | 4 +- .../mouse/juce_MouseInputSource.cpp | 4 +- .../components/mouse/juce_MouseInputSource.h | 2 +- .../components/special/juce_OpenGLComponent.h | 1 + src/gui/graphics/contexts/juce_EdgeTable.cpp | 2 +- src/gui/graphics/contexts/juce_EdgeTable.h | 2 +- .../juce_LowLevelGraphicsSoftwareRenderer.cpp | 4 +- .../drawables/juce_DrawableComposite.cpp | 9 +- src/gui/graphics/geometry/juce_PathIterator.h | 2 +- src/gui/graphics/geometry/juce_Rectangle.h | 16 +- .../imaging/juce_ImageConvolutionKernel.cpp | 20 +- .../imaging/juce_ImageConvolutionKernel.h | 16 +- src/io/files/juce_ZipFile.h | 3 + src/io/network/juce_URL.cpp | 4 +- src/native/juce_mac_NativeCode.mm | 1 + src/native/linux/juce_linux_Audio.cpp | 4 +- src/native/linux/juce_linux_Clipboard.cpp | 7 +- src/native/linux/juce_linux_JackAudio.cpp | 2 +- src/native/linux/juce_linux_Windowing.cpp | 19 +- src/native/mac/juce_mac_CoreAudio.cpp | 4 +- src/native/mac/juce_mac_Fonts.mm | 11 +- src/native/windows/juce_win32_DirectSound.cpp | 2 +- src/native/windows/juce_win32_Fonts.cpp | 4 +- src/text/juce_XmlElement.cpp | 4 +- 44 files changed, 438 insertions(+), 253 deletions(-) diff --git a/build/win32/vc6/JUCE.dsp b/build/win32/vc6/JUCE.dsp index 1ac6036b7e..aa0cff0040 100644 --- a/build/win32/vc6/JUCE.dsp +++ b/build/win32/vc6/JUCE.dsp @@ -887,10 +887,6 @@ SOURCE=..\..\..\src\gui\graphics\geometry\juce_PathStrokeType.h # End Source File # Begin Source File -SOURCE=..\..\..\src\gui\graphics\geometry\juce_Point.cpp -# End Source File -# Begin Source File - SOURCE=..\..\..\src\gui\graphics\geometry\juce_Point.h # End Source File # Begin Source File @@ -903,10 +899,6 @@ SOURCE=..\..\..\src\gui\graphics\geometry\juce_PositionedRectangle.h # End Source File # Begin Source File -SOURCE=..\..\..\src\gui\graphics\geometry\juce_Rectangle.cpp -# End Source File -# Begin Source File - SOURCE=..\..\..\src\gui\graphics\geometry\juce_Rectangle.h # End Source File # Begin Source File @@ -1518,6 +1510,14 @@ SOURCE=..\..\..\src\gui\components\mouse\juce_MouseHoverDetector.h # End Source File # Begin Source File +SOURCE=..\..\..\src\gui\components\mouse\juce_MouseInputSource.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\gui\components\mouse\juce_MouseInputSource.h +# End Source File +# Begin Source File + SOURCE=..\..\..\src\gui\components\mouse\juce_MouseListener.cpp # End Source File # Begin Source File @@ -1861,6 +1861,38 @@ SOURCE=..\..\..\src\gui\components\properties\juce_TextPropertyComponent.cpp SOURCE=..\..\..\src\gui\components\properties\juce_TextPropertyComponent.h # End Source File # End Group +# Begin Group "codeeditor" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\..\src\gui\components\code_editor\juce_CodeDocument.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\gui\components\code_editor\juce_CodeDocument.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\gui\components\code_editor\juce_CodeEditorComponent.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\gui\components\code_editor\juce_CodeEditorComponent.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\gui\components\code_editor\juce_CodeTokeniser.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\gui\components\code_editor\juce_CPlusPlusCodeTokeniser.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\gui\components\code_editor\juce_CPlusPlusCodeTokeniser.h +# End Source File +# End Group # Begin Source File SOURCE=..\..\..\src\gui\components\juce_Component.cpp @@ -2092,6 +2124,14 @@ SOURCE=..\..\..\src\containers\juce_MemoryBlock.h # End Source File # Begin Source File +SOURCE=..\..\..\src\containers\juce_NamedValueSet.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\containers\juce_NamedValueSet.h +# End Source File +# Begin Source File + SOURCE=..\..\..\src\containers\juce_OwnedArray.h # End Source File # Begin Source File @@ -2120,6 +2160,14 @@ SOURCE=..\..\..\src\containers\juce_SparseSet.h # End Source File # Begin Source File +SOURCE=..\..\..\src\containers\juce_Value.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\containers\juce_Value.h +# End Source File +# Begin Source File + SOURCE=..\..\..\src\containers\juce_ValueTree.cpp # End Source File # Begin Source File @@ -2195,6 +2243,14 @@ SOURCE=..\..\..\src\io\files\juce_NamedPipe.h # End Source File # Begin Source File +SOURCE=..\..\..\src\io\files\juce_TemporaryFile.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\io\files\juce_TemporaryFile.h +# End Source File +# Begin Source File + SOURCE=..\..\..\src\io\files\juce_ZipFile.cpp # End Source File # Begin Source File diff --git a/extras/audio plugins/wrapper/juce_IncludeCharacteristics.h b/extras/audio plugins/wrapper/juce_IncludeCharacteristics.h index d500a5d666..dc9b854ddb 100644 --- a/extras/audio plugins/wrapper/juce_IncludeCharacteristics.h +++ b/extras/audio plugins/wrapper/juce_IncludeCharacteristics.h @@ -106,5 +106,8 @@ #error "You need to define the JucePlugin_AUCocoaViewClassName value in your JucePluginCharacteristics.h file!" #endif +#if ! defined (JUCE_ObjCExtraSuffix) + #error "To avoid objective-C name clashes with other plugins, you need to define the JUCE_ObjCExtraSuffix value in your JucePluginCharacteristics.h file!" +#endif #endif // __JUCE_INCLUDECHARACTERISTICS_JUCEHEADER__ diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index e45c9ae0ea..8918d7075d 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -3066,7 +3066,7 @@ void MemoryBlock::append (const void* const srcData, void MemoryBlock::copyFrom (const void* const src, int offset, size_t num) throw() { - const char* d = (const char*) src; + const char* d = static_cast (src); if (offset < 0) { @@ -3084,7 +3084,7 @@ void MemoryBlock::copyFrom (const void* const src, int offset, size_t num) throw void MemoryBlock::copyTo (void* const dst, int offset, size_t num) const throw() { - char* d = (char*) dst; + char* d = static_cast (dst); if (offset < 0) { @@ -3161,16 +3161,16 @@ void MemoryBlock::setBitRange (const size_t bitRangeStart, size_t numBits, int b { size_t byte = bitRangeStart >> 3; int offsetInByte = bitRangeStart & 7; - unsigned int mask = ~((((unsigned int)0xffffffff) << (32 - numBits)) >> (32 - numBits)); + unsigned int mask = ~((((unsigned int) 0xffffffff) << (32 - numBits)) >> (32 - numBits)); while (numBits > 0 && (size_t) byte < size) { const int bitsThisTime = jmin ((int) numBits, 8 - offsetInByte); - const unsigned int tempMask = (mask << offsetInByte) | ~((((unsigned int)0xffffffff) >> offsetInByte) << offsetInByte); + const unsigned int tempMask = (mask << offsetInByte) | ~((((unsigned int) 0xffffffff) >> offsetInByte) << offsetInByte); const unsigned int tempBits = bitsToSet << offsetInByte; - data[byte] = (char)((data[byte] & tempMask) | tempBits); + data[byte] = (char) ((data[byte] & tempMask) | tempBits); ++byte; numBits -= bitsThisTime; @@ -3196,7 +3196,7 @@ void MemoryBlock::loadFromHexString (const String& hex) throw() for (;;) { - const tchar c = hex [i++]; + const juce_wchar c = hex [i++]; if (c >= T('0') && c <= T('9')) { @@ -3215,7 +3215,7 @@ void MemoryBlock::loadFromHexString (const String& hex) throw() } else if (c == 0) { - setSize ((int) (dest - data)); + setSize (static_cast (dest - data)); return; } } @@ -3713,7 +3713,7 @@ void var::writeToStream (OutputStream& output) const const int len = value.stringValue->getNumBytesAsUTF8() + 1; output.writeCompressedInt (len + 1); output.writeByte (5); - HeapBlock temp (len); + HeapBlock temp (len); value.stringValue->copyToUTF8 (temp, len); output.write (temp, len); break; @@ -8393,8 +8393,8 @@ const StringPairArray& URL::getMimeTypesOfUploadFiles() const const String URL::removeEscapeChars (const String& s) { const int len = s.length(); - HeapBlock resultUTF8 (len * 4); - uint8* r = resultUTF8; + HeapBlock resultUTF8 (len * 4); + char* r = resultUTF8; for (int i = 0; i < len; ++i) { @@ -14041,6 +14041,9 @@ XmlElement::XmlElement (const String& tagName_) throw() { // the tag name mustn't be empty, or it'll look like a text element! jassert (tagName_.containsNonWhitespaceChars()) + + // The tag can't contain spaces or other characters that would create invalid XML! + jassert (! tagName_.containsAnyOf (T(" <>/&"))); } XmlElement::XmlElement (int /*dummy*/) throw() @@ -25671,7 +25674,7 @@ void AudioSampleBuffer::allocateData() const size_t channelListSize = (numChannels + 1) * sizeof (float*); allocatedBytes = (int) (numChannels * size * sizeof (float) + channelListSize + 32); allocatedData.malloc (allocatedBytes); - channels = (float**) allocatedData; + channels = reinterpret_cast (allocatedData.getData()); float* chan = (float*) (allocatedData + channelListSize); for (int i = 0; i < numChannels; ++i) @@ -25714,12 +25717,12 @@ void AudioSampleBuffer::allocateChannels (float** const dataToReferTo) // (try to avoid doing a malloc here, as that'll blow up things like Pro-Tools) if (numChannels < numElementsInArray (preallocatedChannelSpace)) { - channels = (float**) preallocatedChannelSpace; + channels = static_cast (preallocatedChannelSpace); } else { allocatedData.malloc (numChannels + 1, sizeof (float*)); - channels = (float**) allocatedData; + channels = reinterpret_cast (allocatedData.getData()); } for (int i = 0; i < numChannels; ++i) @@ -25773,8 +25776,8 @@ void AudioSampleBuffer::setSize (const int newNumChannels, const int numChansToCopy = jmin (numChannels, newNumChannels); const size_t numBytesToCopy = sizeof (float) * jmin (newNumSamples, size); - float** const newChannels = (float**) newData; - float* newChan = (float*) (newData + channelListSize); + float** const newChannels = reinterpret_cast (newData.getData()); + float* newChan = reinterpret_cast (newData + channelListSize); for (int i = 0; i < numChansToCopy; ++i) { memcpy (newChan, channels[i], numBytesToCopy); @@ -25784,7 +25787,7 @@ void AudioSampleBuffer::setSize (const int newNumChannels, allocatedData.swapWith (newData); allocatedBytes = (int) newTotalBytes; - channels = (float**) allocatedData; + channels = newChannels; } else { @@ -25797,10 +25800,10 @@ void AudioSampleBuffer::setSize (const int newNumChannels, { allocatedBytes = newTotalBytes; allocatedData.allocate (newTotalBytes, clearExtraSpace); - channels = (float**) allocatedData; + channels = reinterpret_cast (allocatedData.getData()); } - float* chan = (float*) (allocatedData + channelListSize); + float* chan = reinterpret_cast (allocatedData + channelListSize); for (int i = 0; i < newNumChannels; ++i) { channels[i] = chan; @@ -26583,12 +26586,12 @@ void MidiBuffer::clear() throw() void MidiBuffer::clear (const int startSample, const int numSamples) throw() { - uint8* const start = findEventAfter (data, startSample - 1); + uint8* const start = findEventAfter (getData(), startSample - 1); uint8* const end = findEventAfter (start, startSample + numSamples - 1); if (end > start) { - const size_t bytesToMove = (size_t) (bytesUsed - (end - (uint8*) data.getData())); + const size_t bytesToMove = (size_t) (bytesUsed - (end - getData())); if (bytesToMove > 0) memmove (start, end, bytesToMove); @@ -26645,8 +26648,8 @@ void MidiBuffer::addEvent (const uint8* const newData, int spaceNeeded = bytesUsed + numBytes + 6; data.ensureSize ((spaceNeeded + spaceNeeded / 2 + 8) & ~7); - uint8* d = findEventAfter ((uint8*) data.getData(), sampleNumber); - const size_t bytesToMove = (size_t) (bytesUsed - (d - (uint8*) data.getData())); + uint8* d = findEventAfter (getData(), sampleNumber); + const size_t bytesToMove = (size_t) (bytesUsed - (d - getData())); if (bytesToMove > 0) memmove (d + numBytes + 6, @@ -26690,7 +26693,7 @@ bool MidiBuffer::isEmpty() const throw() int MidiBuffer::getNumEvents() const throw() { int n = 0; - const uint8* d = (uint8*) data.getData(); + const uint8* d = getData(); const uint8* const end = d + bytesUsed; while (d < end) @@ -26705,7 +26708,7 @@ int MidiBuffer::getNumEvents() const throw() int MidiBuffer::getFirstEventTime() const throw() { - return (bytesUsed > 0) ? *(const int*) data.getData() : 0; + return (bytesUsed > 0) ? *reinterpret_cast (data.getData()) : 0; } int MidiBuffer::getLastEventTime() const throw() @@ -26713,7 +26716,7 @@ int MidiBuffer::getLastEventTime() const throw() if (bytesUsed == 0) return 0; - const uint8* d = (uint8*) data.getData(); + const uint8* d = getData(); const uint8* const endData = d + bytesUsed; for (;;) @@ -26729,7 +26732,7 @@ int MidiBuffer::getLastEventTime() const throw() uint8* MidiBuffer::findEventAfter (uint8* d, const int samplePosition) const throw() { - const uint8* const endData = ((uint8*) data.getData()) + bytesUsed; + const uint8* const endData = getData() + bytesUsed; while (d < endData && *(int*) d <= samplePosition) { @@ -26742,7 +26745,7 @@ uint8* MidiBuffer::findEventAfter (uint8* d, const int samplePosition) const thr MidiBuffer::Iterator::Iterator (const MidiBuffer& buffer_) throw() : buffer (buffer_), - data ((uint8*) buffer_.data.getData()) + data (buffer_.getData()) { } @@ -26752,10 +26755,10 @@ MidiBuffer::Iterator::~Iterator() throw() void MidiBuffer::Iterator::setNextSamplePosition (const int samplePosition) throw() { - data = buffer.data; - const uint8* dataEnd = ((uint8*) buffer.data.getData()) + buffer.bytesUsed; + data = buffer.getData(); + const uint8* dataEnd = data + buffer.bytesUsed; - while (data < dataEnd && *(int*) data < samplePosition) + while (data < dataEnd && *reinterpret_cast (data) < samplePosition) { data += 4; data += 2 + *(uint16*) data; @@ -26766,7 +26769,7 @@ bool MidiBuffer::Iterator::getNextEvent (const uint8* &midiData, int& numBytes, int& samplePosition) throw() { - if (data >= ((uint8*) buffer.data.getData()) + buffer.bytesUsed) + if (data >= buffer.getData() + buffer.bytesUsed) return false; samplePosition = *(int*) data; @@ -26782,12 +26785,12 @@ bool MidiBuffer::Iterator::getNextEvent (const uint8* &midiData, bool MidiBuffer::Iterator::getNextEvent (MidiMessage& result, int& samplePosition) throw() { - if (data >= ((uint8*) buffer.data.getData()) + buffer.bytesUsed) + if (data >= buffer.getData() + buffer.bytesUsed) return false; - samplePosition = *(int*) data; + samplePosition = *reinterpret_cast (data); data += 4; - const int numBytes = *(uint16*) data; + const int numBytes = *reinterpret_cast (data); data += 2; result = MidiMessage (data, numBytes, samplePosition); data += numBytes; @@ -40259,7 +40262,7 @@ static const var::identifier getColourPropertyId (const int colourId) { String s; s.preallocateStorage (18); - s << T("jcclr_") << colourId; + s << T("jcclr_") << String::toHexString (colourId); return s; } @@ -48786,7 +48789,9 @@ void Slider::setValue (double newValue, if (popupDisplay != 0) { - ((SliderPopupDisplayComponent*) popupDisplay)->updatePosition (getTextFromValue (newValue)); + static_cast (static_cast (popupDisplay)) + ->updatePosition (getTextFromValue (newValue)); + popupDisplay->repaint(); } @@ -48844,7 +48849,9 @@ void Slider::setMinValue (double newValue, const bool sendUpdateMessage, const b if (popupDisplay != 0) { - ((SliderPopupDisplayComponent*) popupDisplay)->updatePosition (getTextFromValue (newValue)); + static_cast (static_cast (popupDisplay)) + ->updatePosition (getTextFromValue (newValue)); + popupDisplay->repaint(); } @@ -48884,7 +48891,9 @@ void Slider::setMaxValue (double newValue, const bool sendUpdateMessage, const b if (popupDisplay != 0) { - ((SliderPopupDisplayComponent*) popupDisplay)->updatePosition (getTextFromValue (valueMax.getValue())); + static_cast (static_cast (popupDisplay)) + ->updatePosition (getTextFromValue (valueMax.getValue())); + popupDisplay->repaint(); } @@ -49667,7 +49676,7 @@ void Slider::mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float w && style != TwoValueHorizontal && style != TwoValueVertical) { - if (maximum > minimum && ! isMouseButtonDownAnywhere()) + if (maximum > minimum && ! e.mods.isAnyMouseButtonDown()) { if (valueBox != 0) valueBox->hideEditor (false); @@ -52109,8 +52118,8 @@ void TextEditor::doUndoRedo (const bool isRedo) { if (! isReadOnly()) { - if ((isRedo) ? undoManager.redo() - : undoManager.undo()) + if (isRedo ? undoManager.redo() + : undoManager.undo()) { scrollToMakeSureCursorIsVisible(); repaint(); @@ -52674,7 +52683,7 @@ void TextEditor::insertTextAtCaret (const String& newText_) const int newCaretPos = selection.getStart() + newText.length(); const int insertIndex = selection.getStart(); - remove (selection, &undoManager, + remove (selection, getUndoManager(), newText.isNotEmpty() ? newCaretPos - 1 : newCaretPos); if (maxTextLength > 0) @@ -52685,7 +52694,7 @@ void TextEditor::insertTextAtCaret (const String& newText_) insertIndex, currentFont, findColour (textColourId), - &undoManager, + getUndoManager(), newCaretPos); textChanged(); @@ -53137,8 +53146,12 @@ void TextEditor::addPopupMenuItems (PopupMenu& m, const MouseEvent*) m.addSeparator(); m.addItem (baseMenuItemID + 5, TRANS("select all")); m.addSeparator(); - m.addItem (baseMenuItemID + 6, TRANS("undo"), undoManager.canUndo()); - m.addItem (baseMenuItemID + 7, TRANS("redo"), undoManager.canRedo()); + + if (getUndoManager() != 0) + { + m.addItem (baseMenuItemID + 6, TRANS("undo"), undoManager.canUndo()); + m.addItem (baseMenuItemID + 7, TRANS("redo"), undoManager.canRedo()); + } } void TextEditor::performPopupMenuAction (const int menuItemID) @@ -53277,6 +53290,11 @@ void TextEditor::enablementChanged() repaint(); } +UndoManager* TextEditor::getUndoManager() throw() +{ + return isReadOnly() ? &undoManager : 0; +} + void TextEditor::clearInternal (UndoManager* const um) { remove (Range (0, getTotalNumChars()), um, caretPosition); @@ -63224,7 +63242,7 @@ void TabbedComponent::clearTabs() // be careful not to delete these components until they've been removed from the tab component jassert (c == 0 || c->isValidComponent()); - if (c != 0 && c->getProperties() ["deleteByTabComp_"]) + if (c != 0 && (bool) c->getProperties() ["deleteByTabComp_"]) delete c; } @@ -63255,7 +63273,7 @@ void TabbedComponent::removeTab (const int tabIndex) { Component* const c = contentComponents [tabIndex]; - if (c != 0 && c->getProperties() ["deleteByTabComp_"]) + if (c != 0 && (bool) c->getProperties() ["deleteByTabComp_"]) { if (c == panelComponent) panelComponent = 0; @@ -69644,7 +69662,7 @@ public: ~DragImageComponent() { - if ((DragImageComponent*) owner->dragImageComponent == this) + if (owner->dragImageComponent == this) owner->dragImageComponent.release(); if (! mouseDragSourceWatcher->hasBeenDeleted()) @@ -69982,7 +70000,7 @@ void DragAndDropContainer::startDragging (const String& sourceDescription, else thisComp->addChildComponent (dragImageComponent); - ((DragImageComponent*) dragImageComponent)->updateLocation (false, lastMouseDown); + static_cast (static_cast (dragImageComponent))->updateLocation (false, lastMouseDown); dragImageComponent->setVisible (true); } else @@ -80030,7 +80048,7 @@ void EdgeTable::clipToEdgeTable (const EdgeTable& other) } } -void EdgeTable::clipLineToMask (int x, int y, uint8* mask, int maskStride, int numPixels) throw() +void EdgeTable::clipLineToMask (int x, int y, const uint8* mask, int maskStride, int numPixels) throw() { y -= bounds.getY(); @@ -82024,10 +82042,10 @@ public: scratchBuffer.malloc (scratchSize); } - uint8* mask = (uint8*) scratchBuffer; y = y_; - generate ((SrcPixelType*) mask, x, width); + generate (scratchBuffer, x, width); + const uint8* mask = reinterpret_cast (scratchBuffer.getData()); if (sizeof (SrcPixelType) == sizeof (PixelARGB)) mask += PixelARGB::indexA; @@ -83410,8 +83428,13 @@ const Rectangle DrawableComposite::getBounds() const const Drawable* const d = drawables.getUnchecked(i); const AffineTransform* const t = transforms.getUnchecked(i); - bounds = bounds.getUnion (t == 0 ? d->getBounds() - : d->getBounds().transformed (*t)); + const Rectangle childBounds (t == 0 ? d->getBounds() + : d->getBounds().transformed (*t)); + + if (bounds.isEmpty()) + bounds = childBounds; + else if (! childBounds.isEmpty()) + bounds = bounds.getUnion (childBounds); } return bounds; @@ -91922,9 +91945,21 @@ ImageConvolutionKernel::~ImageConvolutionKernel() { } -void ImageConvolutionKernel::setKernelValue (const int x, - const int y, - const float value) +float ImageConvolutionKernel::getKernelValue (const int x, const int y) const throw() +{ + if (((unsigned int) x) < (unsigned int) size + && ((unsigned int) y) < (unsigned int) size) + { + return values [x + y * size]; + } + else + { + jassertfalse; + return 0; + } +} + +void ImageConvolutionKernel::setKernelValue (const int x, const int y, const float value) throw() { if (((unsigned int) x) < (unsigned int) size && ((unsigned int) y) < (unsigned int) size) @@ -91933,7 +91968,7 @@ void ImageConvolutionKernel::setKernelValue (const int x, } else { - jassertfalse + jassertfalse; } } @@ -217451,12 +217486,12 @@ public: if (bufSize > 0) { - HeapBlock data (bufSize); + HeapBlock data (bufSize); GetGlyphOutline (dc, character, GGO_NATIVE, &gm, bufSize, data, &identityMatrix); - const TTPOLYGONHEADER* pheader = (TTPOLYGONHEADER*) data; + const TTPOLYGONHEADER* pheader = reinterpret_cast (data.getData()); const float scaleX = 1.0f / height; const float scaleY = -1.0f / height; @@ -225948,7 +225983,7 @@ public: { JUCE_TRY { - callback->audioDeviceIOCallback ((const float**) inputBuffers, + callback->audioDeviceIOCallback (const_cast (inputBuffers.getData()), numInputBuffers, outputBuffers, numOutputBuffers, @@ -230363,8 +230398,9 @@ void juce_handleSelectionRequest (XSelectionRequestEvent &evt) numDataItems = 2; propertyFormat = 32; // atoms are 32-bit data.calloc (numDataItems * 4); - ((Atom*) data)[0] = atom_UTF8_STRING; - ((Atom*) data)[1] = XA_STRING; + Atom* atoms = reinterpret_cast (data.getData()); + atoms[0] = atom_UTF8_STRING; + atoms[1] = XA_STRING; } } else @@ -230382,7 +230418,7 @@ void juce_handleSelectionRequest (XSelectionRequestEvent &evt) XChangeProperty (evt.display, evt.requestor, evt.property, evt.target, propertyFormat /* 8 or 32 */, PropModeReplace, - (const unsigned char*) data, numDataItems); + reinterpret_cast (data.getData()), numDataItems); reply.property = evt.property; // " == success" } } @@ -232338,7 +232374,8 @@ public: colour[index++] = image.getPixelAt (x, y).getARGB(); XImage* ximage = XCreateImage (display, CopyFromParent, 24, ZPixmap, - 0, (char*) colour, width, height, 32, 0); + 0, reinterpret_cast (colour.getData()), + width, height, 32, 0); Pixmap pixmap = XCreatePixmap (display, DefaultRootWindow (display), width, height, 24); @@ -232374,7 +232411,7 @@ public: } return XCreatePixmapFromBitmapData (display, DefaultRootWindow (display), - (char*) mask, width, height, 1, 0, 1); + reinterpret_cast (mask.getData()), width, height, 1, 0, 1); } void setIcon (const Image& newIcon) @@ -232394,7 +232431,7 @@ public: XChangeProperty (display, windowH, XInternAtom (display, "_NET_WM_ICON", False), XA_CARDINAL, 32, PropModeReplace, - (unsigned char*) data, dataSize); + reinterpret_cast (data.getData()), dataSize); deleteIconPixmaps(); @@ -232450,7 +232487,13 @@ public: char utf8 [64]; zeromem (utf8, sizeof (utf8)); KeySym sym; - XLookupString (keyEvent, utf8, sizeof (utf8), &sym, 0); + + { + const char* oldLocale = ::setlocale (LC_ALL, 0); + ::setlocale (LC_ALL, ""); + XLookupString (keyEvent, utf8, sizeof (utf8), &sym, 0); + ::setlocale (LC_ALL, oldLocale); + } const juce_wchar unicodeChar = *(const juce_wchar*) String::fromUTF8 (utf8, sizeof (utf8) - 1); int keyCode = (int) unicodeChar; @@ -234197,8 +234240,8 @@ void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hot } } - Pixmap sourcePixmap = XCreatePixmapFromBitmapData (display, root, (char*) sourcePlane, cursorW, cursorH, 0xffff, 0, 1); - Pixmap maskPixmap = XCreatePixmapFromBitmapData (display, root, (char*) maskPlane, cursorW, cursorH, 0xffff, 0, 1); + Pixmap sourcePixmap = XCreatePixmapFromBitmapData (display, root, reinterpret_cast (sourcePlane.getData()), cursorW, cursorH, 0xffff, 0, 1); + Pixmap maskPixmap = XCreatePixmapFromBitmapData (display, root, reinterpret_cast (maskPlane.getData()), cursorW, cursorH, 0xffff, 0, 1); XColor white, black; black.red = black.green = black.blue = 0; @@ -234870,7 +234913,7 @@ public: if (isInterleaved) { scratch.ensureSize (sizeof (float) * numSamples * numChannelsRunning, false); - float* interleaved = (float*) scratch; + float* interleaved = reinterpret_cast (scratch.getData()); AudioDataConverters::interleaveSamples ((const float**) data, interleaved, numSamples, numChannelsRunning); AudioDataConverters::convertFloatToFormat (sampleFormat, interleaved, interleaved, numSamples * numChannelsRunning); @@ -234908,7 +234951,7 @@ public: if (isInterleaved) { scratch.ensureSize (sizeof (float) * numSamples * numChannelsRunning, false); - float* interleaved = (float*) scratch; + float* interleaved = reinterpret_cast (scratch.getData()); snd_pcm_sframes_t num = snd_pcm_readi (handle, (void*) interleaved, numSamples); @@ -235989,7 +236032,7 @@ private: if (callback != 0) { - callback->audioDeviceIOCallback ((const float**) inChans, numActiveInChans, + callback->audioDeviceIOCallback (const_cast (inChans.getData()), numActiveInChans, outChans, numActiveOutChans, numSamples); } else @@ -239619,7 +239662,7 @@ public: if (NEW_CGFONT_FUNCTIONS_UNAVAILABLE) { HeapBlock advances (length); - [nsFont getAdvancements: advances forGlyphs: (NSGlyph*) glyphs count: length]; + [nsFont getAdvancements: advances forGlyphs: reinterpret_cast (glyphs.getData()) count: length]; for (int i = 0; i < length; ++i) x += advances[i].width; @@ -239666,14 +239709,15 @@ public: if (NEW_CGFONT_FUNCTIONS_UNAVAILABLE) { HeapBlock advances (length); - [nsFont getAdvancements: advances forGlyphs: (NSGlyph*) glyphs count: length]; + NSGlyph* const nsGlyphs = reinterpret_cast (glyphs.getData()); + [nsFont getAdvancements: advances forGlyphs: nsGlyphs count: length]; float x = 0; for (int i = 0; i < length; ++i) { x += advances[i].width; xOffsets.add (x * unitsToHeightScaleFactor); - resultGlyphs.add (((NSGlyph*) glyphs)[i]); + resultGlyphs.add (nsGlyphs[i]); } } else @@ -239765,10 +239809,10 @@ private: #endif { glyphs.malloc (sizeof (NSGlyph) * length, 1); - NSGlyph* const g = (NSGlyph*) glyphs; + NSGlyph* const nsGlyphs = reinterpret_cast (glyphs.getData()); for (int i = 0; i < length; ++i) - g[i] = (NSGlyph) [nsFont _defaultGlyphForChar: text[i]]; + nsGlyphs[i] = (NSGlyph) [nsFont _defaultGlyphForChar: text[i]]; return; } @@ -244020,7 +244064,7 @@ public: if (NEW_CGFONT_FUNCTIONS_UNAVAILABLE) { HeapBlock advances (length); - [nsFont getAdvancements: advances forGlyphs: (NSGlyph*) glyphs count: length]; + [nsFont getAdvancements: advances forGlyphs: reinterpret_cast (glyphs.getData()) count: length]; for (int i = 0; i < length; ++i) x += advances[i].width; @@ -244067,14 +244111,15 @@ public: if (NEW_CGFONT_FUNCTIONS_UNAVAILABLE) { HeapBlock advances (length); - [nsFont getAdvancements: advances forGlyphs: (NSGlyph*) glyphs count: length]; + NSGlyph* const nsGlyphs = reinterpret_cast (glyphs.getData()); + [nsFont getAdvancements: advances forGlyphs: nsGlyphs count: length]; float x = 0; for (int i = 0; i < length; ++i) { x += advances[i].width; xOffsets.add (x * unitsToHeightScaleFactor); - resultGlyphs.add (((NSGlyph*) glyphs)[i]); + resultGlyphs.add (nsGlyphs[i]); } } else @@ -244166,10 +244211,10 @@ private: #endif { glyphs.malloc (sizeof (NSGlyph) * length, 1); - NSGlyph* const g = (NSGlyph*) glyphs; + NSGlyph* const nsGlyphs = reinterpret_cast (glyphs.getData()); for (int i = 0; i < length; ++i) - g[i] = (NSGlyph) [nsFont _defaultGlyphForChar: text[i]]; + nsGlyphs[i] = (NSGlyph) [nsFont _defaultGlyphForChar: text[i]]; return; } @@ -249341,7 +249386,7 @@ static bool isEventBlockedByModalComps (NSEvent* e) case NSRightMouseUp: case NSOtherMouseUp: case NSOtherMouseDragged: - if (Desktop::getInstance().getMainMouseSource().isDragging() != 0) + if (Desktop::getInstance().getMainMouseSource().isDragging()) return false; break; @@ -250397,7 +250442,7 @@ public: { if (inputDevice == 0) { - callback->audioDeviceIOCallback ((const float**) tempInputBuffers, + callback->audioDeviceIOCallback (const_cast (inputDevice->tempInputBuffers.getData()), numInputChans, tempOutputBuffers, numOutputChans, @@ -250412,7 +250457,7 @@ public: // changed while inside our callback.. const ScopedLock sl2 (inputDevice->callbackLock); - callback->audioDeviceIOCallback ((const float**) inputDevice->tempInputBuffers, + callback->audioDeviceIOCallback (const_cast (inputDevice->tempInputBuffers.getData()), inputDevice->numInputChans, tempOutputBuffers, numOutputChans, diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 29c2f86ab2..9371453c1e 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -43,7 +43,7 @@ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 51 -#define JUCE_BUILDNUMBER 4 +#define JUCE_BUILDNUMBER 5 #define JUCE_VERSION ((JUCE_MAJOR_VERSION << 16) + (JUCE_MINOR_VERSION << 8) + JUCE_BUILDNUMBER) @@ -491,6 +491,10 @@ // Now we'll include any OS headers we need.. (at this point we are outside the Juce namespace). #if JUCE_MSVC + #if (defined(_MSC_VER) && (_MSC_VER <= 1200)) + #pragma warning (disable: 4284) // (spurious VC6 warning) + #endif + #pragma warning (push) #pragma warning (disable: 4514 4245 4100) #endif @@ -1515,12 +1519,11 @@ public: inline operator ElementType*() const throw() { return data; } - inline operator void*() const throw() { return (void*) data; } + inline ElementType* getData() const throw() { return data; } - inline ElementType* operator->() const throw() { return data; } + inline operator void*() const throw() { return static_cast (data); } - template - inline operator CastType*() const throw() { return (CastType*) data; } + inline ElementType* operator->() const throw() { return data; } template inline ElementType& operator[] (IndexType index) const throw() { return data [index]; } @@ -1528,7 +1531,9 @@ public: template inline ElementType* operator+ (IndexType index) const throw() { return data + index; } - inline ElementType** operator&() const throw() { return (ElementType**) &data; } + inline ElementType* const* operator&() const throw() { return static_cast (&data); } + + inline ElementType** operator&() throw() { return static_cast (&data); } inline bool operator== (const ElementType* const otherPointer) const throw() { return otherPointer == data; } @@ -2673,9 +2678,6 @@ public: bool matches (const void* data, size_t dataSize) const throw(); - template - operator DataType*() const throw() { return (DataType*) data; } - void* getData() const throw() { return data; } template @@ -3371,17 +3373,12 @@ public: inline ObjectType* operator->() const throw() { return object; } - template - inline operator CastType*() const throw() { return static_cast (object); } + inline ObjectType* const* operator&() const throw() { return static_cast (&object); } - inline ObjectType** operator&() const throw() { return (ObjectType**) &object; } + inline ObjectType** operator&() throw() { return static_cast (&object); } ObjectType* release() throw() { ObjectType* const o = object; object = 0; return o; } - inline bool operator== (const ObjectType* const otherPointer) const throw() { return otherPointer == object; } - - inline bool operator!= (const ObjectType* const otherPointer) const throw() { return otherPointer != object; } - void swapWith (ScopedPointer & other) throw() { // Two ScopedPointers should never be able to refer to the same object - if @@ -3399,6 +3396,18 @@ private: const ScopedPointer* getAddress() const throw() { return this; } }; +template +inline bool operator== (const ScopedPointer& pointer1, const ObjectType* const pointer2) throw() +{ + return static_cast (pointer1) == pointer2; +} + +template +inline bool operator!= (const ScopedPointer& pointer1, const ObjectType* const pointer2) throw() +{ + return static_cast (pointer1) != pointer2; +} + #endif // __JUCE_SCOPEDPOINTER_JUCEHEADER__ /*** End of inlined file: juce_ScopedPointer.h ***/ @@ -7680,6 +7689,9 @@ private: class ZipInputStream; class ZipFilenameComparator; class ZipEntryInfo; + friend class ZipInputStream; + friend class ZipFilenameComparator; + friend class ZipEntryInfo; OwnedArray entries; CriticalSection lock; @@ -9555,6 +9567,8 @@ public: ~Rectangle() throw() {} + bool isEmpty() const throw() { return w <= 0 || h <= 0; } + inline ValueType getX() const throw() { return x; } inline ValueType getY() const throw() { return y; } @@ -9567,13 +9581,13 @@ public: inline ValueType getBottom() const throw() { return y + h; } - inline ValueType getCentreX() const throw() { return x + w / (ValueType) 2; } + ValueType getCentreX() const throw() { return x + w / (ValueType) 2; } - inline ValueType getCentreY() const throw() { return y + h / (ValueType) 2; } + ValueType getCentreY() const throw() { return y + h / (ValueType) 2; } - inline const Point getCentre() const throw() { return Point (x + w / (ValueType) 2, y + h / (ValueType) 2); } + const Point getCentre() const throw() { return Point (x + w / (ValueType) 2, y + h / (ValueType) 2); } - bool isEmpty() const throw() { return w <= 0 || h <= 0; } + ValueType getAspectRatio (const bool widthOverHeight = true) const throw() { return widthOverHeight ? w / h : h / w; } const Point getPosition() const throw() { return Point (x, y); } @@ -9978,7 +9992,7 @@ public: void clipToRectangle (const Rectangle& r) throw(); void excludeRectangle (const Rectangle& r) throw(); void clipToEdgeTable (const EdgeTable& other); - void clipLineToMask (int x, int y, uint8* mask, int maskStride, int numPixels) throw(); + void clipLineToMask (int x, int y, const uint8* mask, int maskStride, int numPixels) throw(); bool isEmpty() throw(); const Rectangle& getMaximumBounds() const throw() { return bounds; } void translate (float dx, int dy) throw(); @@ -15528,6 +15542,7 @@ private: MemoryBlock data; int bytesUsed; + uint8* getData() const throw() { return reinterpret_cast (data.getData()); } uint8* findEventAfter (uint8* d, const int samplePosition) const throw(); }; @@ -15891,6 +15906,7 @@ private: SortedSet buttonListeners; class RepeatTimer; + friend class RepeatTimer; friend class ScopedPointer ; ScopedPointer repeatTimer; uint32 buttonPressTime, lastTimeCallbackTime; @@ -16583,6 +16599,7 @@ private: void timerCallbackInt(); void repaintCaret(); void repaintText (const Range& range); + UndoManager* getUndoManager() throw(); TextEditor (const TextEditor&); TextEditor& operator= (const TextEditor&); @@ -19590,6 +19607,8 @@ public: private: class SharedEvents; class BlockingMessage; + friend class SharedEvents; + friend class BlockingMessage; SharedEvents* sharedEvents; bool locked; @@ -26650,6 +26669,7 @@ public: private: class OpenGLComponentWatcher; + friend class OpenGLComponentWatcher; friend class ScopedPointer ; ScopedPointer componentWatcher; @@ -27664,7 +27684,7 @@ public: int subPathIndex; - bool isLastInSubpath() const { return stackPos == stackBase + bool isLastInSubpath() const { return stackPos == stackBase.getData() && (index >= path.numElements || points [index] == Path::moveMarker); } @@ -27966,9 +27986,9 @@ public: void clear(); - void setKernelValue (const int x, - const int y, - const float value); + float getKernelValue (int x, int y) const throw(); + + void setKernelValue (int x, int y, float value) throw(); void setOverallSum (const float desiredTotalSum); @@ -27978,8 +27998,6 @@ public: int getKernelSize() const { return size; } - float** getValues() const { return values; } - void applyToImage (Image& destImage, const Image* sourceImage, int x, diff --git a/src/audio/dsp/juce_AudioSampleBuffer.cpp b/src/audio/dsp/juce_AudioSampleBuffer.cpp index e525fbc99e..44f5ec95ce 100644 --- a/src/audio/dsp/juce_AudioSampleBuffer.cpp +++ b/src/audio/dsp/juce_AudioSampleBuffer.cpp @@ -60,7 +60,7 @@ void AudioSampleBuffer::allocateData() const size_t channelListSize = (numChannels + 1) * sizeof (float*); allocatedBytes = (int) (numChannels * size * sizeof (float) + channelListSize + 32); allocatedData.malloc (allocatedBytes); - channels = (float**) allocatedData; + channels = reinterpret_cast (allocatedData.getData()); float* chan = (float*) (allocatedData + channelListSize); for (int i = 0; i < numChannels; ++i) @@ -103,12 +103,12 @@ void AudioSampleBuffer::allocateChannels (float** const dataToReferTo) // (try to avoid doing a malloc here, as that'll blow up things like Pro-Tools) if (numChannels < numElementsInArray (preallocatedChannelSpace)) { - channels = (float**) preallocatedChannelSpace; + channels = static_cast (preallocatedChannelSpace); } else { allocatedData.malloc (numChannels + 1, sizeof (float*)); - channels = (float**) allocatedData; + channels = reinterpret_cast (allocatedData.getData()); } for (int i = 0; i < numChannels; ++i) @@ -162,8 +162,8 @@ void AudioSampleBuffer::setSize (const int newNumChannels, const int numChansToCopy = jmin (numChannels, newNumChannels); const size_t numBytesToCopy = sizeof (float) * jmin (newNumSamples, size); - float** const newChannels = (float**) newData; - float* newChan = (float*) (newData + channelListSize); + float** const newChannels = reinterpret_cast (newData.getData()); + float* newChan = reinterpret_cast (newData + channelListSize); for (int i = 0; i < numChansToCopy; ++i) { memcpy (newChan, channels[i], numBytesToCopy); @@ -173,7 +173,7 @@ void AudioSampleBuffer::setSize (const int newNumChannels, allocatedData.swapWith (newData); allocatedBytes = (int) newTotalBytes; - channels = (float**) allocatedData; + channels = newChannels; } else { @@ -186,10 +186,10 @@ void AudioSampleBuffer::setSize (const int newNumChannels, { allocatedBytes = newTotalBytes; allocatedData.allocate (newTotalBytes, clearExtraSpace); - channels = (float**) allocatedData; + channels = reinterpret_cast (allocatedData.getData()); } - float* chan = (float*) (allocatedData + channelListSize); + float* chan = reinterpret_cast (allocatedData + channelListSize); for (int i = 0; i < newNumChannels; ++i) { channels[i] = chan; diff --git a/src/audio/midi/juce_MidiBuffer.cpp b/src/audio/midi/juce_MidiBuffer.cpp index 74c2f343e2..aacb226f74 100644 --- a/src/audio/midi/juce_MidiBuffer.cpp +++ b/src/audio/midi/juce_MidiBuffer.cpp @@ -74,12 +74,12 @@ void MidiBuffer::clear() throw() void MidiBuffer::clear (const int startSample, const int numSamples) throw() { - uint8* const start = findEventAfter (data, startSample - 1); + uint8* const start = findEventAfter (getData(), startSample - 1); uint8* const end = findEventAfter (start, startSample + numSamples - 1); if (end > start) { - const size_t bytesToMove = (size_t) (bytesUsed - (end - (uint8*) data.getData())); + const size_t bytesToMove = (size_t) (bytesUsed - (end - getData())); if (bytesToMove > 0) memmove (start, end, bytesToMove); @@ -136,8 +136,8 @@ void MidiBuffer::addEvent (const uint8* const newData, int spaceNeeded = bytesUsed + numBytes + 6; data.ensureSize ((spaceNeeded + spaceNeeded / 2 + 8) & ~7); - uint8* d = findEventAfter ((uint8*) data.getData(), sampleNumber); - const size_t bytesToMove = (size_t) (bytesUsed - (d - (uint8*) data.getData())); + uint8* d = findEventAfter (getData(), sampleNumber); + const size_t bytesToMove = (size_t) (bytesUsed - (d - getData())); if (bytesToMove > 0) memmove (d + numBytes + 6, @@ -181,7 +181,7 @@ bool MidiBuffer::isEmpty() const throw() int MidiBuffer::getNumEvents() const throw() { int n = 0; - const uint8* d = (uint8*) data.getData(); + const uint8* d = getData(); const uint8* const end = d + bytesUsed; while (d < end) @@ -196,7 +196,7 @@ int MidiBuffer::getNumEvents() const throw() int MidiBuffer::getFirstEventTime() const throw() { - return (bytesUsed > 0) ? *(const int*) data.getData() : 0; + return (bytesUsed > 0) ? *reinterpret_cast (data.getData()) : 0; } int MidiBuffer::getLastEventTime() const throw() @@ -204,7 +204,7 @@ int MidiBuffer::getLastEventTime() const throw() if (bytesUsed == 0) return 0; - const uint8* d = (uint8*) data.getData(); + const uint8* d = getData(); const uint8* const endData = d + bytesUsed; for (;;) @@ -220,7 +220,7 @@ int MidiBuffer::getLastEventTime() const throw() uint8* MidiBuffer::findEventAfter (uint8* d, const int samplePosition) const throw() { - const uint8* const endData = ((uint8*) data.getData()) + bytesUsed; + const uint8* const endData = getData() + bytesUsed; while (d < endData && *(int*) d <= samplePosition) { @@ -234,7 +234,7 @@ uint8* MidiBuffer::findEventAfter (uint8* d, const int samplePosition) const thr //============================================================================== MidiBuffer::Iterator::Iterator (const MidiBuffer& buffer_) throw() : buffer (buffer_), - data ((uint8*) buffer_.data.getData()) + data (buffer_.getData()) { } @@ -245,10 +245,10 @@ MidiBuffer::Iterator::~Iterator() throw() //============================================================================== void MidiBuffer::Iterator::setNextSamplePosition (const int samplePosition) throw() { - data = buffer.data; - const uint8* dataEnd = ((uint8*) buffer.data.getData()) + buffer.bytesUsed; + data = buffer.getData(); + const uint8* dataEnd = data + buffer.bytesUsed; - while (data < dataEnd && *(int*) data < samplePosition) + while (data < dataEnd && *reinterpret_cast (data) < samplePosition) { data += 4; data += 2 + *(uint16*) data; @@ -259,7 +259,7 @@ bool MidiBuffer::Iterator::getNextEvent (const uint8* &midiData, int& numBytes, int& samplePosition) throw() { - if (data >= ((uint8*) buffer.data.getData()) + buffer.bytesUsed) + if (data >= buffer.getData() + buffer.bytesUsed) return false; samplePosition = *(int*) data; @@ -275,12 +275,12 @@ bool MidiBuffer::Iterator::getNextEvent (const uint8* &midiData, bool MidiBuffer::Iterator::getNextEvent (MidiMessage& result, int& samplePosition) throw() { - if (data >= ((uint8*) buffer.data.getData()) + buffer.bytesUsed) + if (data >= buffer.getData() + buffer.bytesUsed) return false; - samplePosition = *(int*) data; + samplePosition = *reinterpret_cast (data); data += 4; - const int numBytes = *(uint16*) data; + const int numBytes = *reinterpret_cast (data); data += 2; result = MidiMessage (data, numBytes, samplePosition); data += numBytes; diff --git a/src/audio/midi/juce_MidiBuffer.h b/src/audio/midi/juce_MidiBuffer.h index 0b230c016b..551d77bac4 100644 --- a/src/audio/midi/juce_MidiBuffer.h +++ b/src/audio/midi/juce_MidiBuffer.h @@ -229,6 +229,7 @@ private: MemoryBlock data; int bytesUsed; + uint8* getData() const throw() { return reinterpret_cast (data.getData()); } uint8* findEventAfter (uint8* d, const int samplePosition) const throw(); }; diff --git a/src/containers/juce_HeapBlock.h b/src/containers/juce_HeapBlock.h index 6c289668dd..a48635effc 100644 --- a/src/containers/juce_HeapBlock.h +++ b/src/containers/juce_HeapBlock.h @@ -110,11 +110,17 @@ public: */ inline operator ElementType*() const throw() { return data; } + /** Returns a raw pointer to the allocated data. + This may be a null pointer if the data hasn't yet been allocated, or if it has been + freed by calling the free() method. + */ + inline ElementType* getData() const throw() { return data; } + /** Returns a void pointer to the allocated data. This may be a null pointer if the data hasn't yet been allocated, or if it has been freed by calling the free() method. */ - inline operator void*() const throw() { return (void*) data; } + inline operator void*() const throw() { return static_cast (data); } /** Lets you use indirect calls to the first element in the array. Obviously this will cause problems if the array hasn't been initialised, because it'll @@ -122,11 +128,6 @@ public: */ inline ElementType* operator->() const throw() { return data; } - /** Returns a pointer to the data by casting it to any type you need. - */ - template - inline operator CastType*() const throw() { return (CastType*) data; } - /** Returns a reference to one of the data elements. Obviously there's no bounds-checking here, as this object is just a dumb pointer and has no idea of the size it currently has allocated. @@ -144,7 +145,13 @@ public: Beware that the pointer returned here will become invalid as soon as you call any of the allocator methods on this object! */ - inline ElementType** operator&() const throw() { return (ElementType**) &data; } + inline ElementType* const* operator&() const throw() { return static_cast (&data); } + + /** Returns a reference to the raw data pointer. + Beware that the pointer returned here will become invalid as soon as you call + any of the allocator methods on this object! + */ + inline ElementType** operator&() throw() { return static_cast (&data); } //============================================================================== /** Compares the pointer with another pointer. diff --git a/src/containers/juce_MemoryBlock.cpp b/src/containers/juce_MemoryBlock.cpp index a14a28ef38..66da6ae028 100644 --- a/src/containers/juce_MemoryBlock.cpp +++ b/src/containers/juce_MemoryBlock.cpp @@ -175,7 +175,7 @@ void MemoryBlock::append (const void* const srcData, void MemoryBlock::copyFrom (const void* const src, int offset, size_t num) throw() { - const char* d = (const char*) src; + const char* d = static_cast (src); if (offset < 0) { @@ -193,7 +193,7 @@ void MemoryBlock::copyFrom (const void* const src, int offset, size_t num) throw void MemoryBlock::copyTo (void* const dst, int offset, size_t num) const throw() { - char* d = (char*) dst; + char* d = static_cast (dst); if (offset < 0) { @@ -271,16 +271,16 @@ void MemoryBlock::setBitRange (const size_t bitRangeStart, size_t numBits, int b { size_t byte = bitRangeStart >> 3; int offsetInByte = bitRangeStart & 7; - unsigned int mask = ~((((unsigned int)0xffffffff) << (32 - numBits)) >> (32 - numBits)); + unsigned int mask = ~((((unsigned int) 0xffffffff) << (32 - numBits)) >> (32 - numBits)); while (numBits > 0 && (size_t) byte < size) { const int bitsThisTime = jmin ((int) numBits, 8 - offsetInByte); - const unsigned int tempMask = (mask << offsetInByte) | ~((((unsigned int)0xffffffff) >> offsetInByte) << offsetInByte); + const unsigned int tempMask = (mask << offsetInByte) | ~((((unsigned int) 0xffffffff) >> offsetInByte) << offsetInByte); const unsigned int tempBits = bitsToSet << offsetInByte; - data[byte] = (char)((data[byte] & tempMask) | tempBits); + data[byte] = (char) ((data[byte] & tempMask) | tempBits); ++byte; numBits -= bitsThisTime; @@ -307,7 +307,7 @@ void MemoryBlock::loadFromHexString (const String& hex) throw() for (;;) { - const tchar c = hex [i++]; + const juce_wchar c = hex [i++]; if (c >= T('0') && c <= T('9')) { @@ -326,7 +326,7 @@ void MemoryBlock::loadFromHexString (const String& hex) throw() } else if (c == 0) { - setSize ((int) (dest - data)); + setSize (static_cast (dest - data)); return; } } diff --git a/src/containers/juce_MemoryBlock.h b/src/containers/juce_MemoryBlock.h index a4cff3429e..38481170a7 100644 --- a/src/containers/juce_MemoryBlock.h +++ b/src/containers/juce_MemoryBlock.h @@ -88,14 +88,6 @@ public: bool matches (const void* data, size_t dataSize) const throw(); //============================================================================== - /** Returns a pointer to the data, casting it to any type of primitive data required. - - Note that the pointer returned will probably become invalid when the - block is resized. - */ - template - operator DataType*() const throw() { return (DataType*) data; } - /** Returns a void pointer to the data. Note that the pointer returned will probably become invalid when the diff --git a/src/containers/juce_ScopedPointer.h b/src/containers/juce_ScopedPointer.h index eb9783ba58..ce777b3a9b 100644 --- a/src/containers/juce_ScopedPointer.h +++ b/src/containers/juce_ScopedPointer.h @@ -134,12 +134,11 @@ public: /** Lets you access methods and properties of the object that this ScopedPointer refers to. */ inline ObjectType* operator->() const throw() { return object; } - /** Returns a pointer to the object by casting it to whatever type you need. */ - template - inline operator CastType*() const throw() { return static_cast (object); } + /** Returns a reference to the address of the object that this ScopedPointer refers to. */ + inline ObjectType* const* operator&() const throw() { return static_cast (&object); } /** Returns a reference to the address of the object that this ScopedPointer refers to. */ - inline ObjectType** operator&() const throw() { return (ObjectType**) &object; } + inline ObjectType** operator&() throw() { return static_cast (&object); } //============================================================================== /** Removes the current object from this ScopedPointer without deleting it. @@ -148,17 +147,6 @@ public: */ ObjectType* release() throw() { ObjectType* const o = object; object = 0; return o; } - //============================================================================== - /** Compares the pointer with another pointer. - This can be handy for checking whether this is a null pointer. - */ - inline bool operator== (const ObjectType* const otherPointer) const throw() { return otherPointer == object; } - - /** Compares the pointer with another pointer. - This can be handy for checking whether this is a null pointer. - */ - inline bool operator!= (const ObjectType* const otherPointer) const throw() { return otherPointer != object; } - //============================================================================== /** Swaps this object with that of another ScopedPointer. The two objects simply exchange their pointers. @@ -180,5 +168,24 @@ private: const ScopedPointer* getAddress() const throw() { return this; } }; +//============================================================================== +/** Compares a ScopedPointer with another pointer. + This can be handy for checking whether this is a null pointer. +*/ +template +inline bool operator== (const ScopedPointer& pointer1, const ObjectType* const pointer2) throw() +{ + return static_cast (pointer1) == pointer2; +} + +/** Compares a ScopedPointer with another pointer. + This can be handy for checking whether this is a null pointer. +*/ +template +inline bool operator!= (const ScopedPointer& pointer1, const ObjectType* const pointer2) throw() +{ + return static_cast (pointer1) != pointer2; +} + #endif // __JUCE_SCOPEDPOINTER_JUCEHEADER__ diff --git a/src/containers/juce_Variant.cpp b/src/containers/juce_Variant.cpp index 7e2893a75a..a01454b18e 100644 --- a/src/containers/juce_Variant.cpp +++ b/src/containers/juce_Variant.cpp @@ -246,7 +246,7 @@ void var::writeToStream (OutputStream& output) const const int len = value.stringValue->getNumBytesAsUTF8() + 1; output.writeCompressedInt (len + 1); output.writeByte (5); - HeapBlock temp (len); + HeapBlock temp (len); value.stringValue->copyToUTF8 (temp, len); output.write (temp, len); break; diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index 06a2fa539e..a8cf6e420e 100644 --- a/src/core/juce_StandardHeader.h +++ b/src/core/juce_StandardHeader.h @@ -33,7 +33,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 51 -#define JUCE_BUILDNUMBER 4 +#define JUCE_BUILDNUMBER 5 /** Current Juce version number. @@ -65,6 +65,10 @@ // Now we'll include any OS headers we need.. (at this point we are outside the Juce namespace). #if JUCE_MSVC + #if (defined(_MSC_VER) && (_MSC_VER <= 1200)) + #pragma warning (disable: 4284) // (spurious VC6 warning) + #endif + #pragma warning (push) #pragma warning (disable: 4514 4245 4100) #endif diff --git a/src/events/juce_MessageManager.h b/src/events/juce_MessageManager.h index 90cf4ba3ed..0cd0083b4c 100644 --- a/src/events/juce_MessageManager.h +++ b/src/events/juce_MessageManager.h @@ -307,6 +307,8 @@ public: private: class SharedEvents; class BlockingMessage; + friend class SharedEvents; + friend class BlockingMessage; SharedEvents* sharedEvents; bool locked; diff --git a/src/gui/components/buttons/juce_Button.h b/src/gui/components/buttons/juce_Button.h index 8e476538b5..2230bda7e4 100644 --- a/src/gui/components/buttons/juce_Button.h +++ b/src/gui/components/buttons/juce_Button.h @@ -474,6 +474,7 @@ private: SortedSet buttonListeners; class RepeatTimer; + friend class RepeatTimer; friend class ScopedPointer ; ScopedPointer repeatTimer; uint32 buttonPressTime, lastTimeCallbackTime; diff --git a/src/gui/components/controls/juce_Slider.cpp b/src/gui/components/controls/juce_Slider.cpp index 0e7e66cd32..4d8adf1348 100644 --- a/src/gui/components/controls/juce_Slider.cpp +++ b/src/gui/components/controls/juce_Slider.cpp @@ -502,7 +502,9 @@ void Slider::setValue (double newValue, if (popupDisplay != 0) { - ((SliderPopupDisplayComponent*) popupDisplay)->updatePosition (getTextFromValue (newValue)); + static_cast (static_cast (popupDisplay)) + ->updatePosition (getTextFromValue (newValue)); + popupDisplay->repaint(); } @@ -560,7 +562,9 @@ void Slider::setMinValue (double newValue, const bool sendUpdateMessage, const b if (popupDisplay != 0) { - ((SliderPopupDisplayComponent*) popupDisplay)->updatePosition (getTextFromValue (newValue)); + static_cast (static_cast (popupDisplay)) + ->updatePosition (getTextFromValue (newValue)); + popupDisplay->repaint(); } @@ -600,7 +604,9 @@ void Slider::setMaxValue (double newValue, const bool sendUpdateMessage, const b if (popupDisplay != 0) { - ((SliderPopupDisplayComponent*) popupDisplay)->updatePosition (getTextFromValue (valueMax.getValue())); + static_cast (static_cast (popupDisplay)) + ->updatePosition (getTextFromValue (valueMax.getValue())); + popupDisplay->repaint(); } diff --git a/src/gui/components/controls/juce_TextEditor.cpp b/src/gui/components/controls/juce_TextEditor.cpp index d1e34afb8e..7b3d9d535b 100644 --- a/src/gui/components/controls/juce_TextEditor.cpp +++ b/src/gui/components/controls/juce_TextEditor.cpp @@ -1022,8 +1022,8 @@ void TextEditor::doUndoRedo (const bool isRedo) { if (! isReadOnly()) { - if ((isRedo) ? undoManager.redo() - : undoManager.undo()) + if (isRedo ? undoManager.redo() + : undoManager.undo()) { scrollToMakeSureCursorIsVisible(); repaint(); @@ -1595,7 +1595,7 @@ void TextEditor::insertTextAtCaret (const String& newText_) const int newCaretPos = selection.getStart() + newText.length(); const int insertIndex = selection.getStart(); - remove (selection, &undoManager, + remove (selection, getUndoManager(), newText.isNotEmpty() ? newCaretPos - 1 : newCaretPos); if (maxTextLength > 0) @@ -1606,7 +1606,7 @@ void TextEditor::insertTextAtCaret (const String& newText_) insertIndex, currentFont, findColour (textColourId), - &undoManager, + getUndoManager(), newCaretPos); textChanged(); @@ -2063,8 +2063,12 @@ void TextEditor::addPopupMenuItems (PopupMenu& m, const MouseEvent*) m.addSeparator(); m.addItem (baseMenuItemID + 5, TRANS("select all")); m.addSeparator(); - m.addItem (baseMenuItemID + 6, TRANS("undo"), undoManager.canUndo()); - m.addItem (baseMenuItemID + 7, TRANS("redo"), undoManager.canRedo()); + + if (getUndoManager() != 0) + { + m.addItem (baseMenuItemID + 6, TRANS("undo"), undoManager.canUndo()); + m.addItem (baseMenuItemID + 7, TRANS("redo"), undoManager.canRedo()); + } } void TextEditor::performPopupMenuAction (const int menuItemID) @@ -2206,6 +2210,11 @@ void TextEditor::enablementChanged() } //============================================================================== +UndoManager* TextEditor::getUndoManager() throw() +{ + return isReadOnly() ? &undoManager : 0; +} + void TextEditor::clearInternal (UndoManager* const um) { remove (Range (0, getTotalNumChars()), um, caretPosition); diff --git a/src/gui/components/controls/juce_TextEditor.h b/src/gui/components/controls/juce_TextEditor.h index 5b3672479f..acb5f439ca 100644 --- a/src/gui/components/controls/juce_TextEditor.h +++ b/src/gui/components/controls/juce_TextEditor.h @@ -698,6 +698,7 @@ private: void timerCallbackInt(); void repaintCaret(); void repaintText (const Range& range); + UndoManager* getUndoManager() throw(); TextEditor (const TextEditor&); TextEditor& operator= (const TextEditor&); diff --git a/src/gui/components/juce_Component.cpp b/src/gui/components/juce_Component.cpp index dc45df6733..ddbf55a402 100644 --- a/src/gui/components/juce_Component.cpp +++ b/src/gui/components/juce_Component.cpp @@ -1841,7 +1841,7 @@ static const var::identifier getColourPropertyId (const int colourId) { String s; s.preallocateStorage (18); - s << T("jcclr_") << colourId; + s << T("jcclr_") << String::toHexString (colourId); return s; } diff --git a/src/gui/components/layout/juce_TabbedComponent.cpp b/src/gui/components/layout/juce_TabbedComponent.cpp index 40a860aaa3..72063b1820 100644 --- a/src/gui/components/layout/juce_TabbedComponent.cpp +++ b/src/gui/components/layout/juce_TabbedComponent.cpp @@ -138,7 +138,7 @@ void TabbedComponent::clearTabs() // be careful not to delete these components until they've been removed from the tab component jassert (c == 0 || c->isValidComponent()); - if (c != 0 && c->getProperties() ["deleteByTabComp_"]) + if (c != 0 && (bool) c->getProperties() ["deleteByTabComp_"]) delete c; } @@ -169,7 +169,7 @@ void TabbedComponent::removeTab (const int tabIndex) { Component* const c = contentComponents [tabIndex]; - if (c != 0 && c->getProperties() ["deleteByTabComp_"]) + if (c != 0 && (bool) c->getProperties() ["deleteByTabComp_"]) { if (c == panelComponent) panelComponent = 0; diff --git a/src/gui/components/mouse/juce_DragAndDropContainer.cpp b/src/gui/components/mouse/juce_DragAndDropContainer.cpp index 4f15f0dfa1..847b43250e 100644 --- a/src/gui/components/mouse/juce_DragAndDropContainer.cpp +++ b/src/gui/components/mouse/juce_DragAndDropContainer.cpp @@ -79,7 +79,7 @@ public: ~DragImageComponent() { - if ((DragImageComponent*) owner->dragImageComponent == this) + if (owner->dragImageComponent == this) owner->dragImageComponent.release(); if (! mouseDragSourceWatcher->hasBeenDeleted()) @@ -419,7 +419,7 @@ void DragAndDropContainer::startDragging (const String& sourceDescription, else thisComp->addChildComponent (dragImageComponent); - ((DragImageComponent*) dragImageComponent)->updateLocation (false, lastMouseDown); + static_cast (static_cast (dragImageComponent))->updateLocation (false, lastMouseDown); dragImageComponent->setVisible (true); } else diff --git a/src/gui/components/mouse/juce_MouseInputSource.cpp b/src/gui/components/mouse/juce_MouseInputSource.cpp index 9d6d5ea0b1..347910d2e9 100644 --- a/src/gui/components/mouse/juce_MouseInputSource.cpp +++ b/src/gui/components/mouse/juce_MouseInputSource.cpp @@ -116,7 +116,7 @@ public: if (current != 0) current->internalMouseUp (source, current->globalPositionToRelative (screenPos + unboundedMouseOffset), time, getCurrentModifiers()); - + enableUnboundedMouseMovement (false, false); } @@ -408,7 +408,7 @@ private: MouseInputSource& source; ScopedPointer componentUnderMouse; ComponentPeer* lastPeer; - + Point unboundedMouseOffset; bool isUnboundedMouseModeOn, isCursorVisibleUntilOffscreen; void* currentCursorHandle; diff --git a/src/gui/components/mouse/juce_MouseInputSource.h b/src/gui/components/mouse/juce_MouseInputSource.h index 50e6d1c724..91e0fdc895 100644 --- a/src/gui/components/mouse/juce_MouseInputSource.h +++ b/src/gui/components/mouse/juce_MouseInputSource.h @@ -138,7 +138,7 @@ public: void revealCursor(); bool canDoUnboundedMovement() const throw(); - + /** Allows the mouse to move beyond the edges of the screen. Calling this method when the mouse button is currently pressed will remove the cursor diff --git a/src/gui/components/special/juce_OpenGLComponent.h b/src/gui/components/special/juce_OpenGLComponent.h index 32514df3fb..cf8f4e10c2 100644 --- a/src/gui/components/special/juce_OpenGLComponent.h +++ b/src/gui/components/special/juce_OpenGLComponent.h @@ -332,6 +332,7 @@ public: private: class OpenGLComponentWatcher; + friend class OpenGLComponentWatcher; friend class ScopedPointer ; ScopedPointer componentWatcher; diff --git a/src/gui/graphics/contexts/juce_EdgeTable.cpp b/src/gui/graphics/contexts/juce_EdgeTable.cpp index e5121121fc..aae4dda189 100644 --- a/src/gui/graphics/contexts/juce_EdgeTable.cpp +++ b/src/gui/graphics/contexts/juce_EdgeTable.cpp @@ -687,7 +687,7 @@ void EdgeTable::clipToEdgeTable (const EdgeTable& other) } } -void EdgeTable::clipLineToMask (int x, int y, uint8* mask, int maskStride, int numPixels) throw() +void EdgeTable::clipLineToMask (int x, int y, const uint8* mask, int maskStride, int numPixels) throw() { y -= bounds.getY(); diff --git a/src/gui/graphics/contexts/juce_EdgeTable.h b/src/gui/graphics/contexts/juce_EdgeTable.h index 9380e7f78d..f1ee57435b 100644 --- a/src/gui/graphics/contexts/juce_EdgeTable.h +++ b/src/gui/graphics/contexts/juce_EdgeTable.h @@ -83,7 +83,7 @@ public: void clipToRectangle (const Rectangle& r) throw(); void excludeRectangle (const Rectangle& r) throw(); void clipToEdgeTable (const EdgeTable& other); - void clipLineToMask (int x, int y, uint8* mask, int maskStride, int numPixels) throw(); + void clipLineToMask (int x, int y, const uint8* mask, int maskStride, int numPixels) throw(); bool isEmpty() throw(); const Rectangle& getMaximumBounds() const throw() { return bounds; } void translate (float dx, int dy) throw(); diff --git a/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp b/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp index 281da9effe..7aa23ff4b7 100644 --- a/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp +++ b/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp @@ -583,10 +583,10 @@ public: scratchBuffer.malloc (scratchSize); } - uint8* mask = (uint8*) scratchBuffer; y = y_; - generate ((SrcPixelType*) mask, x, width); + generate (scratchBuffer, x, width); + const uint8* mask = reinterpret_cast (scratchBuffer.getData()); if (sizeof (SrcPixelType) == sizeof (PixelARGB)) mask += PixelARGB::indexA; diff --git a/src/gui/graphics/drawables/juce_DrawableComposite.cpp b/src/gui/graphics/drawables/juce_DrawableComposite.cpp index 2bb0c02f8d..cd7008d1b3 100644 --- a/src/gui/graphics/drawables/juce_DrawableComposite.cpp +++ b/src/gui/graphics/drawables/juce_DrawableComposite.cpp @@ -136,8 +136,13 @@ const Rectangle DrawableComposite::getBounds() const const Drawable* const d = drawables.getUnchecked(i); const AffineTransform* const t = transforms.getUnchecked(i); - bounds = bounds.getUnion (t == 0 ? d->getBounds() - : d->getBounds().transformed (*t)); + const Rectangle childBounds (t == 0 ? d->getBounds() + : d->getBounds().transformed (*t)); + + if (bounds.isEmpty()) + bounds = childBounds; + else if (! childBounds.isEmpty()) + bounds = bounds.getUnion (childBounds); } return bounds; diff --git a/src/gui/graphics/geometry/juce_PathIterator.h b/src/gui/graphics/geometry/juce_PathIterator.h index 6d486df8cb..3aa3d14cc7 100644 --- a/src/gui/graphics/geometry/juce_PathIterator.h +++ b/src/gui/graphics/geometry/juce_PathIterator.h @@ -95,7 +95,7 @@ public: int subPathIndex; /** Returns true if the current segment is the last in the current sub-path. */ - bool isLastInSubpath() const { return stackPos == stackBase + bool isLastInSubpath() const { return stackPos == stackBase.getData() && (index >= path.numElements || points [index] == Path::moveMarker); } diff --git a/src/gui/graphics/geometry/juce_Rectangle.h b/src/gui/graphics/geometry/juce_Rectangle.h index c408dac5a5..d94334b9fd 100644 --- a/src/gui/graphics/geometry/juce_Rectangle.h +++ b/src/gui/graphics/geometry/juce_Rectangle.h @@ -83,6 +83,9 @@ public: ~Rectangle() throw() {} //============================================================================== + /** Returns true if the rectangle's width and height are both zero or less */ + bool isEmpty() const throw() { return w <= 0 || h <= 0; } + /** Returns the x co-ordinate of the rectangle's left-hand-side. */ inline ValueType getX() const throw() { return x; } @@ -102,15 +105,18 @@ public: inline ValueType getBottom() const throw() { return y + h; } /** Returns the x co-ordinate of the rectangle's centre. */ - inline ValueType getCentreX() const throw() { return x + w / (ValueType) 2; } + ValueType getCentreX() const throw() { return x + w / (ValueType) 2; } /** Returns the y co-ordinate of the rectangle's centre. */ - inline ValueType getCentreY() const throw() { return y + h / (ValueType) 2; } + ValueType getCentreY() const throw() { return y + h / (ValueType) 2; } - inline const Point getCentre() const throw() { return Point (x + w / (ValueType) 2, y + h / (ValueType) 2); } + /** Returns the centre point of the rectangle. */ + const Point getCentre() const throw() { return Point (x + w / (ValueType) 2, y + h / (ValueType) 2); } - /** Returns true if the rectangle's width and height are both zero or less */ - bool isEmpty() const throw() { return w <= 0 || h <= 0; } + /** Returns the aspect ratio of the rectangle's width / height. + If widthOverHeight is true, it returns width / height; if widthOverHeight is false, + it returns height / width. */ + ValueType getAspectRatio (const bool widthOverHeight = true) const throw() { return widthOverHeight ? w / h : h / w; } //============================================================================== /** Returns the rectangle's top-left position as a Point. */ diff --git a/src/gui/graphics/imaging/juce_ImageConvolutionKernel.cpp b/src/gui/graphics/imaging/juce_ImageConvolutionKernel.cpp index 3c5561a659..cc0eb65dc4 100644 --- a/src/gui/graphics/imaging/juce_ImageConvolutionKernel.cpp +++ b/src/gui/graphics/imaging/juce_ImageConvolutionKernel.cpp @@ -43,9 +43,21 @@ ImageConvolutionKernel::~ImageConvolutionKernel() } //============================================================================== -void ImageConvolutionKernel::setKernelValue (const int x, - const int y, - const float value) +float ImageConvolutionKernel::getKernelValue (const int x, const int y) const throw() +{ + if (((unsigned int) x) < (unsigned int) size + && ((unsigned int) y) < (unsigned int) size) + { + return values [x + y * size]; + } + else + { + jassertfalse; + return 0; + } +} + +void ImageConvolutionKernel::setKernelValue (const int x, const int y, const float value) throw() { if (((unsigned int) x) < (unsigned int) size && ((unsigned int) y) < (unsigned int) size) @@ -54,7 +66,7 @@ void ImageConvolutionKernel::setKernelValue (const int x, } else { - jassertfalse + jassertfalse; } } diff --git a/src/gui/graphics/imaging/juce_ImageConvolutionKernel.h b/src/gui/graphics/imaging/juce_ImageConvolutionKernel.h index 3846973243..3d663f8cbe 100644 --- a/src/gui/graphics/imaging/juce_ImageConvolutionKernel.h +++ b/src/gui/graphics/imaging/juce_ImageConvolutionKernel.h @@ -50,19 +50,19 @@ public: ~ImageConvolutionKernel(); //============================================================================== - /** Resets all values in the kernel to zero. - */ + /** Resets all values in the kernel to zero. */ void clear(); + /** Returns one of the kernel values. */ + float getKernelValue (int x, int y) const throw(); + /** Sets the value of a specific cell in the kernel. The x and y parameters must be in the range 0 < x < getKernelSize(). @see setOverallSum */ - void setKernelValue (const int x, - const int y, - const float value); + void setKernelValue (int x, int y, float value) throw(); /** Rescales all values in the kernel to make the total add up to a fixed value. @@ -89,12 +89,6 @@ public: */ int getKernelSize() const { return size; } - /** Returns a 2-dimensional array of the kernel's values. - - The size of each dimension of the array will be getKernelSize(). - */ - float** getValues() const { return values; } - //============================================================================== /** Applies the kernel to an image. diff --git a/src/io/files/juce_ZipFile.h b/src/io/files/juce_ZipFile.h index 2363ceb83f..ce9ae086a6 100644 --- a/src/io/files/juce_ZipFile.h +++ b/src/io/files/juce_ZipFile.h @@ -149,6 +149,9 @@ private: class ZipInputStream; class ZipFilenameComparator; class ZipEntryInfo; + friend class ZipInputStream; + friend class ZipFilenameComparator; + friend class ZipEntryInfo; OwnedArray entries; CriticalSection lock; diff --git a/src/io/network/juce_URL.cpp b/src/io/network/juce_URL.cpp index 31ddac4abe..6068431618 100644 --- a/src/io/network/juce_URL.cpp +++ b/src/io/network/juce_URL.cpp @@ -538,8 +538,8 @@ const StringPairArray& URL::getMimeTypesOfUploadFiles() const const String URL::removeEscapeChars (const String& s) { const int len = s.length(); - HeapBlock resultUTF8 (len * 4); - uint8* r = resultUTF8; + HeapBlock resultUTF8 (len * 4); + char* r = resultUTF8; for (int i = 0; i < len; ++i) { diff --git a/src/native/juce_mac_NativeCode.mm b/src/native/juce_mac_NativeCode.mm index 4076acfa0b..6dde995783 100644 --- a/src/native/juce_mac_NativeCode.mm +++ b/src/native/juce_mac_NativeCode.mm @@ -60,6 +60,7 @@ BEGIN_JUCE_NAMESPACE #include "../gui/components/special/juce_QuickTimeMovieComponent.h" #include "../gui/components/mouse/juce_DragAndDropContainer.h" #include "../gui/components/mouse/juce_MouseEvent.h" +#include "../gui/components/mouse/juce_MouseInputSource.h" #include "../gui/components/keyboard/juce_KeyPressMappingSet.h" #include "../gui/components/special/juce_NSViewComponent.h" #include "../gui/components/layout/juce_ComponentMovementWatcher.h" diff --git a/src/native/linux/juce_linux_Audio.cpp b/src/native/linux/juce_linux_Audio.cpp index 93d243f9fd..1f4eb336f0 100644 --- a/src/native/linux/juce_linux_Audio.cpp +++ b/src/native/linux/juce_linux_Audio.cpp @@ -234,7 +234,7 @@ public: if (isInterleaved) { scratch.ensureSize (sizeof (float) * numSamples * numChannelsRunning, false); - float* interleaved = (float*) scratch; + float* interleaved = reinterpret_cast (scratch.getData()); AudioDataConverters::interleaveSamples ((const float**) data, interleaved, numSamples, numChannelsRunning); AudioDataConverters::convertFloatToFormat (sampleFormat, interleaved, interleaved, numSamples * numChannelsRunning); @@ -272,7 +272,7 @@ public: if (isInterleaved) { scratch.ensureSize (sizeof (float) * numSamples * numChannelsRunning, false); - float* interleaved = (float*) scratch; + float* interleaved = reinterpret_cast (scratch.getData()); snd_pcm_sframes_t num = snd_pcm_readi (handle, (void*) interleaved, numSamples); diff --git a/src/native/linux/juce_linux_Clipboard.cpp b/src/native/linux/juce_linux_Clipboard.cpp index 9f29993927..63f4749974 100644 --- a/src/native/linux/juce_linux_Clipboard.cpp +++ b/src/native/linux/juce_linux_Clipboard.cpp @@ -181,8 +181,9 @@ void juce_handleSelectionRequest (XSelectionRequestEvent &evt) numDataItems = 2; propertyFormat = 32; // atoms are 32-bit data.calloc (numDataItems * 4); - ((Atom*) data)[0] = atom_UTF8_STRING; - ((Atom*) data)[1] = XA_STRING; + Atom* atoms = reinterpret_cast (data.getData()); + atoms[0] = atom_UTF8_STRING; + atoms[1] = XA_STRING; } } else @@ -200,7 +201,7 @@ void juce_handleSelectionRequest (XSelectionRequestEvent &evt) XChangeProperty (evt.display, evt.requestor, evt.property, evt.target, propertyFormat /* 8 or 32 */, PropModeReplace, - (const unsigned char*) data, numDataItems); + reinterpret_cast (data.getData()), numDataItems); reply.property = evt.property; // " == success" } } diff --git a/src/native/linux/juce_linux_JackAudio.cpp b/src/native/linux/juce_linux_JackAudio.cpp index bbadfe759d..c2ba9bbf6e 100644 --- a/src/native/linux/juce_linux_JackAudio.cpp +++ b/src/native/linux/juce_linux_JackAudio.cpp @@ -395,7 +395,7 @@ private: if (callback != 0) { - callback->audioDeviceIOCallback ((const float**) inChans, numActiveInChans, + callback->audioDeviceIOCallback (const_cast (inChans.getData()), numActiveInChans, outChans, numActiveOutChans, numSamples); } else diff --git a/src/native/linux/juce_linux_Windowing.cpp b/src/native/linux/juce_linux_Windowing.cpp index 9687f6732a..9d9e93a4a4 100644 --- a/src/native/linux/juce_linux_Windowing.cpp +++ b/src/native/linux/juce_linux_Windowing.cpp @@ -902,7 +902,8 @@ public: colour[index++] = image.getPixelAt (x, y).getARGB(); XImage* ximage = XCreateImage (display, CopyFromParent, 24, ZPixmap, - 0, (char*) colour, width, height, 32, 0); + 0, reinterpret_cast (colour.getData()), + width, height, 32, 0); Pixmap pixmap = XCreatePixmap (display, DefaultRootWindow (display), width, height, 24); @@ -938,7 +939,7 @@ public: } return XCreatePixmapFromBitmapData (display, DefaultRootWindow (display), - (char*) mask, width, height, 1, 0, 1); + reinterpret_cast (mask.getData()), width, height, 1, 0, 1); } void setIcon (const Image& newIcon) @@ -958,7 +959,7 @@ public: XChangeProperty (display, windowH, XInternAtom (display, "_NET_WM_ICON", False), XA_CARDINAL, 32, PropModeReplace, - (unsigned char*) data, dataSize); + reinterpret_cast (data.getData()), dataSize); deleteIconPixmaps(); @@ -1015,7 +1016,13 @@ public: char utf8 [64]; zeromem (utf8, sizeof (utf8)); KeySym sym; - XLookupString (keyEvent, utf8, sizeof (utf8), &sym, 0); + + { + const char* oldLocale = ::setlocale (LC_ALL, 0); + ::setlocale (LC_ALL, ""); + XLookupString (keyEvent, utf8, sizeof (utf8), &sym, 0); + ::setlocale (LC_ALL, oldLocale); + } const juce_wchar unicodeChar = *(const juce_wchar*) String::fromUTF8 (utf8, sizeof (utf8) - 1); int keyCode = (int) unicodeChar; @@ -2777,8 +2784,8 @@ void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hot } } - Pixmap sourcePixmap = XCreatePixmapFromBitmapData (display, root, (char*) sourcePlane, cursorW, cursorH, 0xffff, 0, 1); - Pixmap maskPixmap = XCreatePixmapFromBitmapData (display, root, (char*) maskPlane, cursorW, cursorH, 0xffff, 0, 1); + Pixmap sourcePixmap = XCreatePixmapFromBitmapData (display, root, reinterpret_cast (sourcePlane.getData()), cursorW, cursorH, 0xffff, 0, 1); + Pixmap maskPixmap = XCreatePixmapFromBitmapData (display, root, reinterpret_cast (maskPlane.getData()), cursorW, cursorH, 0xffff, 0, 1); XColor white, black; black.red = black.green = black.blue = 0; diff --git a/src/native/mac/juce_mac_CoreAudio.cpp b/src/native/mac/juce_mac_CoreAudio.cpp index cd1a651521..8fd181c77b 100644 --- a/src/native/mac/juce_mac_CoreAudio.cpp +++ b/src/native/mac/juce_mac_CoreAudio.cpp @@ -628,7 +628,7 @@ public: { if (inputDevice == 0) { - callback->audioDeviceIOCallback ((const float**) tempInputBuffers, + callback->audioDeviceIOCallback (const_cast (inputDevice->tempInputBuffers.getData()), numInputChans, tempOutputBuffers, numOutputChans, @@ -643,7 +643,7 @@ public: // changed while inside our callback.. const ScopedLock sl2 (inputDevice->callbackLock); - callback->audioDeviceIOCallback ((const float**) inputDevice->tempInputBuffers, + callback->audioDeviceIOCallback (const_cast (inputDevice->tempInputBuffers.getData()), inputDevice->numInputChans, tempOutputBuffers, numOutputChans, diff --git a/src/native/mac/juce_mac_Fonts.mm b/src/native/mac/juce_mac_Fonts.mm index ef6dc52270..cbf29ceb13 100644 --- a/src/native/mac/juce_mac_Fonts.mm +++ b/src/native/mac/juce_mac_Fonts.mm @@ -210,7 +210,7 @@ public: if (NEW_CGFONT_FUNCTIONS_UNAVAILABLE) { HeapBlock advances (length); - [nsFont getAdvancements: advances forGlyphs: (NSGlyph*) glyphs count: length]; + [nsFont getAdvancements: advances forGlyphs: reinterpret_cast (glyphs.getData()) count: length]; for (int i = 0; i < length; ++i) x += advances[i].width; @@ -257,14 +257,15 @@ public: if (NEW_CGFONT_FUNCTIONS_UNAVAILABLE) { HeapBlock advances (length); - [nsFont getAdvancements: advances forGlyphs: (NSGlyph*) glyphs count: length]; + NSGlyph* const nsGlyphs = reinterpret_cast (glyphs.getData()); + [nsFont getAdvancements: advances forGlyphs: nsGlyphs count: length]; float x = 0; for (int i = 0; i < length; ++i) { x += advances[i].width; xOffsets.add (x * unitsToHeightScaleFactor); - resultGlyphs.add (((NSGlyph*) glyphs)[i]); + resultGlyphs.add (nsGlyphs[i]); } } else @@ -357,10 +358,10 @@ private: #endif { glyphs.malloc (sizeof (NSGlyph) * length, 1); - NSGlyph* const g = (NSGlyph*) glyphs; + NSGlyph* const nsGlyphs = reinterpret_cast (glyphs.getData()); for (int i = 0; i < length; ++i) - g[i] = (NSGlyph) [nsFont _defaultGlyphForChar: text[i]]; + nsGlyphs[i] = (NSGlyph) [nsFont _defaultGlyphForChar: text[i]]; return; } diff --git a/src/native/windows/juce_win32_DirectSound.cpp b/src/native/windows/juce_win32_DirectSound.cpp index f29cb6d0d6..fb1a7597af 100644 --- a/src/native/windows/juce_win32_DirectSound.cpp +++ b/src/native/windows/juce_win32_DirectSound.cpp @@ -1307,7 +1307,7 @@ public: { JUCE_TRY { - callback->audioDeviceIOCallback ((const float**) inputBuffers, + callback->audioDeviceIOCallback (const_cast (inputBuffers.getData()), numInputBuffers, outputBuffers, numOutputBuffers, diff --git a/src/native/windows/juce_win32_Fonts.cpp b/src/native/windows/juce_win32_Fonts.cpp index 52a059df54..b656c1b10f 100644 --- a/src/native/windows/juce_win32_Fonts.cpp +++ b/src/native/windows/juce_win32_Fonts.cpp @@ -302,12 +302,12 @@ public: if (bufSize > 0) { - HeapBlock data (bufSize); + HeapBlock data (bufSize); GetGlyphOutline (dc, character, GGO_NATIVE, &gm, bufSize, data, &identityMatrix); - const TTPOLYGONHEADER* pheader = (TTPOLYGONHEADER*) data; + const TTPOLYGONHEADER* pheader = reinterpret_cast (data.getData()); const float scaleX = 1.0f / height; const float scaleY = -1.0f / height; diff --git a/src/text/juce_XmlElement.cpp b/src/text/juce_XmlElement.cpp index 3d9650a6d9..b60156d471 100644 --- a/src/text/juce_XmlElement.cpp +++ b/src/text/juce_XmlElement.cpp @@ -60,6 +60,9 @@ XmlElement::XmlElement (const String& tagName_) throw() { // the tag name mustn't be empty, or it'll look like a text element! jassert (tagName_.containsNonWhitespaceChars()) + + // The tag can't contain spaces or other characters that would create invalid XML! + jassert (! tagName_.containsAnyOf (T(" <>/&"))); } XmlElement::XmlElement (int /*dummy*/) throw() @@ -474,7 +477,6 @@ XmlElement* XmlElement::getNextElementWithTagName (const String& requiredTagName return e; } - //============================================================================== int XmlElement::getNumAttributes() const throw() {