From e61e8f67750eff122fc64402ad09371daeeb6328 Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Thu, 14 Jan 2010 14:49:25 +0000 Subject: [PATCH] Changed some 'int's to 'size_t's, to improve 64-bit compatibility. Also changed jmin and jmax to use templates, so they can take any type. These changes might mean that you'll need to add some more explicit casts to get your existing code to compile, but this is actually a good thing - it brought to light a few dodgy implicit casts in my code, and may do the same in yours. Also added a function roundToInt(), which replaces roundDoubleToInt() and roundFloatToInt(), but takes any size of floating point number (I've left the old roundDoubleToInt() and roundFloatToInt() functions there for convenience, but will probably remove them in the future). --- extras/amalgamator/juce_AmalgamatorMain.cpp | 18 ++-- .../demo/src/DemoEditorComponent.cpp | 2 +- .../wrapper/RTAS/juce_RTAS_Wrapper.cpp | 6 +- .../src/model/components/jucer_LabelHandler.h | 2 +- .../components/jucer_TabbedComponentHandler.h | 2 +- .../model/components/jucer_ViewportHandler.h | 2 +- .../paintelements/jucer_PaintElementGroup.h | 8 +- .../paintelements/jucer_PaintElementPath.cpp | 4 +- .../jucer_PaintElementRectangle.h | 4 +- .../paintelements/jucer_PaintElementText.h | 2 +- .../properties/jucer_PositionPropertyBase.h | 2 +- .../src/ui/jucer_EditingPanelBase.cpp | 4 +- .../src/utility/jucer_UtilityFunctions.cpp | 24 ++--- .../audio_file_formats/flac/libFLAC/memory.c | 15 --- .../audio_file_formats/juce_AudioFormat.cpp | 10 +- .../juce_AudioThumbnail.cpp | 14 +-- .../juce_FlacAudioFormat.cpp | 2 +- .../juce_OggVorbisAudioFormat.cpp | 2 +- .../juce_QuickTimeAudioFormat.cpp | 2 +- .../juce_WavAudioFormat.cpp | 18 ++-- .../juce_AudioTransportSource.cpp | 8 +- .../juce_ResamplingAudioSource.cpp | 4 +- src/audio/devices/juce_MidiOutput.cpp | 4 +- src/audio/dsp/juce_AudioDataConverters.cpp | 24 ++--- src/audio/dsp/juce_AudioSampleBuffer.cpp | 18 ++-- src/audio/dsp/juce_AudioSampleBuffer.h | 3 +- src/audio/midi/juce_MidiBuffer.cpp | 4 +- src/audio/midi/juce_MidiFile.cpp | 8 +- src/audio/midi/juce_MidiKeyboardState.cpp | 2 +- src/audio/midi/juce_MidiMessage.cpp | 8 +- src/audio/midi/juce_MidiMessageCollector.cpp | 2 +- .../formats/juce_AudioUnitPluginFormat.mm | 4 +- src/audio/processors/juce_AudioProcessor.cpp | 2 +- src/audio/synthesisers/juce_Sampler.cpp | 6 +- src/containers/juce_BitArray.cpp | 6 +- src/containers/juce_HeapBlock.h | 10 +- src/containers/juce_MemoryBlock.cpp | 50 +++++----- src/containers/juce_MemoryBlock.h | 31 +++--- src/containers/juce_Variant.cpp | 2 +- src/core/juce_MathsFunctions.h | 94 ++++++++----------- src/core/juce_Memory.h | 2 +- src/cryptography/juce_MD5.cpp | 18 ++-- src/cryptography/juce_MD5.h | 8 +- src/events/juce_InterprocessConnection.cpp | 6 +- src/gui/components/buttons/juce_Button.cpp | 2 +- .../components/buttons/juce_ImageButton.cpp | 6 +- .../code_editor/juce_CodeEditorComponent.cpp | 14 +-- src/gui/components/controls/juce_ListBox.cpp | 2 +- .../components/controls/juce_ProgressBar.cpp | 2 +- src/gui/components/controls/juce_Slider.cpp | 6 +- .../components/controls/juce_TextEditor.cpp | 46 ++++----- src/gui/components/controls/juce_Toolbar.cpp | 2 +- .../filebrowser/juce_FileChooserDialogBox.cpp | 2 +- .../juce_ImagePreviewComponent.cpp | 4 +- src/gui/components/juce_Component.cpp | 28 +++--- src/gui/components/juce_Component.h | 2 +- .../layout/juce_ComponentAnimator.cpp | 8 +- .../juce_ComponentBoundsConstrainer.cpp | 8 +- src/gui/components/layout/juce_ScrollBar.cpp | 8 +- .../layout/juce_StretchableLayoutManager.cpp | 6 +- .../layout/juce_TabbedButtonBar.cpp | 2 +- src/gui/components/layout/juce_Viewport.cpp | 8 +- .../lookandfeel/juce_LookAndFeel.cpp | 16 ++-- .../lookandfeel/juce_OldSchoolLookAndFeel.cpp | 22 ++--- src/gui/components/menus/juce_PopupMenu.cpp | 2 +- .../mouse/juce_DragAndDropContainer.cpp | 2 +- src/gui/components/mouse/juce_MouseEvent.cpp | 4 +- .../juce_AudioDeviceSelectorComponent.cpp | 4 +- .../special/juce_ColourSelector.cpp | 6 +- .../components/special/juce_DropShadower.cpp | 2 +- .../special/juce_MagnifierComponent.cpp | 26 ++--- .../special/juce_MidiKeyboardComponent.cpp | 8 +- src/gui/graphics/colour/juce_Colour.cpp | 24 ++--- .../graphics/colour/juce_ColourGradient.cpp | 4 +- src/gui/graphics/colour/juce_PixelFormats.h | 6 +- src/gui/graphics/contexts/juce_EdgeTable.cpp | 18 ++-- src/gui/graphics/contexts/juce_Graphics.cpp | 4 +- .../juce_LowLevelGraphicsSoftwareRenderer.cpp | 22 ++--- src/gui/graphics/drawables/juce_Drawable.cpp | 6 +- src/gui/graphics/drawables/juce_Drawable.h | 2 +- .../graphics/drawables/juce_DrawableImage.cpp | 4 +- src/gui/graphics/drawables/juce_SVGParser.cpp | 6 +- .../effects/juce_DropShadowEffect.cpp | 4 +- src/gui/graphics/effects/juce_GlowEffect.cpp | 2 +- src/gui/graphics/fonts/juce_Font.cpp | 2 +- src/gui/graphics/fonts/juce_TextLayout.cpp | 4 +- src/gui/graphics/geometry/juce_Path.cpp | 2 +- .../geometry/juce_PositionedRectangle.cpp | 20 ++-- .../image_file_formats/juce_JPEGLoader.cpp | 8 +- .../image_file_formats/juce_PNGLoader.cpp | 10 +- src/gui/graphics/imaging/juce_Image.cpp | 2 +- .../imaging/juce_ImageConvolutionKernel.cpp | 14 +-- src/io/network/juce_Socket.cpp | 12 +-- src/io/network/juce_URL.cpp | 2 +- src/io/streams/juce_InputStream.cpp | 10 +- src/io/streams/juce_MemoryInputStream.cpp | 6 +- src/io/streams/juce_MemoryInputStream.h | 4 +- src/io/streams/juce_MemoryOutputStream.cpp | 16 ++-- src/io/streams/juce_MemoryOutputStream.h | 8 +- src/io/streams/juce_OutputStream.cpp | 2 +- src/native/common/juce_posix_NamedPipe.cpp | 6 +- src/native/common/juce_posix_SharedCode.h | 4 +- src/native/linux/juce_linux_Audio.cpp | 4 +- src/native/linux/juce_linux_Network.cpp | 4 +- src/native/linux/juce_linux_Windowing.cpp | 27 ++---- src/native/mac/juce_mac_AppleRemote.mm | 2 +- src/native/mac/juce_mac_AudioCDBurner.mm | 2 +- .../mac/juce_mac_CarbonViewWrapperComponent.h | 4 +- src/native/mac/juce_mac_CoreAudio.cpp | 10 +- .../mac/juce_mac_CoreGraphicsContext.mm | 12 +-- src/native/mac/juce_mac_CoreMidi.cpp | 2 +- src/native/mac/juce_mac_Fonts.mm | 10 +- src/native/mac/juce_mac_MainMenu.mm | 4 +- src/native/mac/juce_mac_MiscUtilities.mm | 6 +- src/native/mac/juce_mac_MouseCursor.mm | 4 +- .../mac/juce_mac_NSViewComponentPeer.mm | 24 ++--- src/native/mac/juce_mac_Network.mm | 4 +- .../mac/juce_mac_QuickTimeMovieComponent.mm | 4 +- src/native/mac/juce_mac_SystemStats.mm | 4 +- src/native/windows/juce_win32_ASIO.cpp | 10 +- .../windows/juce_win32_CameraDevice.cpp | 4 +- src/native/windows/juce_win32_DirectSound.cpp | 16 ++-- src/native/windows/juce_win32_FileChooser.cpp | 4 +- src/native/windows/juce_win32_Network.cpp | 2 +- .../juce_win32_QuickTimeMovieComponent.cpp | 4 +- src/native/windows/juce_win32_WASAPI.cpp | 2 +- src/native/windows/juce_win32_Windowing.cpp | 10 +- src/text/juce_String.cpp | 24 ++--- src/text/juce_String.h | 6 +- src/text/juce_XmlDocument.cpp | 4 +- src/threads/juce_InterProcessLock.h | 4 +- 131 files changed, 562 insertions(+), 604 deletions(-) diff --git a/extras/amalgamator/juce_AmalgamatorMain.cpp b/extras/amalgamator/juce_AmalgamatorMain.cpp index 01d650bc04..5be50f32fd 100644 --- a/extras/amalgamator/juce_AmalgamatorMain.cpp +++ b/extras/amalgamator/juce_AmalgamatorMain.cpp @@ -177,11 +177,11 @@ static bool parseFile (const File& rootFolder, for (;;) { int end = line.indexOf (T("*/")); - + if (end >= 0) { line = line.substring (end + 2); - + // If our comment appeared just before an assertion, leave it in, as it // might be useful.. if (lines [i + 1].contains (T("assert")) @@ -190,7 +190,7 @@ static bool parseFile (const File& rootFolder, i = originalI; line = originalLine; } - + break; } @@ -199,28 +199,28 @@ static bool parseFile (const File& rootFolder, if (i >= lines.size()) break; } - + line = line.trimEnd(); if (line.isEmpty()) continue; } - + line = line.trimEnd(); - + { // Turn initial spaces into tabs.. int numIntialSpaces = 0; int len = line.length(); while (numIntialSpaces < len && line [numIntialSpaces] == ' ') ++numIntialSpaces; - + if (numIntialSpaces > 0) { int tabSize = 4; int numTabs = numIntialSpaces / tabSize; line = String::repeatedString (T("\t"), numTabs) + line.substring (numTabs * tabSize); } - + if (! line.containsChar (T('"'))) { // turn large areas of spaces into tabs - this will mess up alignment a bit, but @@ -287,7 +287,7 @@ static bool munge (const File& templateFile, const File& targetFile, const Strin if (! targetFile.replaceWithData (newData.getData(), newData.getSize())) { - std::cout << "\n!! ERROR - couldn't write to the target file: " + std::cout << "\n!! ERROR - couldn't write to the target file: " << (const char*) targetFile.getFullPathName() << "\n\n"; return false; } diff --git a/extras/audio plugins/demo/src/DemoEditorComponent.cpp b/extras/audio plugins/demo/src/DemoEditorComponent.cpp index 88911ee3ca..31fce415ec 100644 --- a/extras/audio plugins/demo/src/DemoEditorComponent.cpp +++ b/extras/audio plugins/demo/src/DemoEditorComponent.cpp @@ -39,7 +39,7 @@ static const String timeToTimecodeString (const double seconds) return String::formatted (T("%s%02d:%02d:%02d:%03d"), sign, hours, mins, secs, - roundDoubleToInt (absSecs * 1000) % 1000); + roundToInt (absSecs * 1000) % 1000); } // quick-and-dirty function to format a bars/beats string diff --git a/extras/audio plugins/wrapper/RTAS/juce_RTAS_Wrapper.cpp b/extras/audio plugins/wrapper/RTAS/juce_RTAS_Wrapper.cpp index 0f161faa28..29de4e0209 100644 --- a/extras/audio plugins/wrapper/RTAS/juce_RTAS_Wrapper.cpp +++ b/extras/audio plugins/wrapper/RTAS/juce_RTAS_Wrapper.cpp @@ -140,9 +140,9 @@ static float longToFloat (const long n) throw() static long floatToLong (const float n) throw() { - return roundDoubleToInt (jlimit (-(double) 0x80000000, - (double) 0x7fffffff, - n * (double) 0xffffffff - (double) 0x80000000)); + return roundToInt (jlimit (-(double) 0x80000000, + (double) 0x7fffffff, + n * (double) 0xffffffff - (double) 0x80000000)); } static int numInstances = 0; diff --git a/extras/the jucer/src/model/components/jucer_LabelHandler.h b/extras/the jucer/src/model/components/jucer_LabelHandler.h index de32ba31df..4815775825 100644 --- a/extras/the jucer/src/model/components/jucer_LabelHandler.h +++ b/extras/the jucer/src/model/components/jucer_LabelHandler.h @@ -67,7 +67,7 @@ public: e->setAttribute (T("focusDiscardsChanges"), l->doesLossOfFocusDiscardChanges()); e->setAttribute (T("fontname"), l->getComponentProperty (T("typefaceName"), false, FontPropertyComponent::defaultFont)); - e->setAttribute (T("fontsize"), roundDoubleToInt (l->getFont().getHeight() * 100.0) / 100.0); + e->setAttribute (T("fontsize"), roundToInt (l->getFont().getHeight() * 100.0) / 100.0); e->setAttribute (T("bold"), l->getFont().isBold()); e->setAttribute (T("italic"), l->getFont().isItalic()); e->setAttribute (T("justification"), l->getJustificationType().getFlags()); diff --git a/extras/the jucer/src/model/components/jucer_TabbedComponentHandler.h b/extras/the jucer/src/model/components/jucer_TabbedComponentHandler.h index 1dd3892cce..9d10ae27cb 100644 --- a/extras/the jucer/src/model/components/jucer_TabbedComponentHandler.h +++ b/extras/the jucer/src/model/components/jucer_TabbedComponentHandler.h @@ -593,7 +593,7 @@ private: { document.getUndoManager().undoCurrentTransactionOnly(); - document.perform (new TabDepthChangeAction (component, *document.getComponentLayout(), roundDoubleToInt (newValue)), + document.perform (new TabDepthChangeAction (component, *document.getComponentLayout(), roundToInt (newValue)), T("Change TabComponent tab depth")); } diff --git a/extras/the jucer/src/model/components/jucer_ViewportHandler.h b/extras/the jucer/src/model/components/jucer_ViewportHandler.h index 4746ba17db..95fab2e427 100644 --- a/extras/the jucer/src/model/components/jucer_ViewportHandler.h +++ b/extras/the jucer/src/model/components/jucer_ViewportHandler.h @@ -392,7 +392,7 @@ private: { document.getUndoManager().undoCurrentTransactionOnly(); - document.perform (new ViewportScrollbarSizeChangeAction (component, *document.getComponentLayout(), roundDoubleToInt (newValue)), + document.perform (new ViewportScrollbarSizeChangeAction (component, *document.getComponentLayout(), roundToInt (newValue)), T("Change Viewport scrollbar size")); } diff --git a/extras/the jucer/src/model/paintelements/jucer_PaintElementGroup.h b/extras/the jucer/src/model/paintelements/jucer_PaintElementGroup.h index 0f8782e98f..77b325709c 100644 --- a/extras/the jucer/src/model/paintelements/jucer_PaintElementGroup.h +++ b/extras/the jucer/src/model/paintelements/jucer_PaintElementGroup.h @@ -163,12 +163,12 @@ public: Rectangle pos (e->getCurrentBounds (parentArea)); - const int newX = roundDoubleToInt ((pos.getX() - scaleStartX) * scaleX + scaleStartX + dx); - const int newY = roundDoubleToInt ((pos.getY() - scaleStartY) * scaleY + scaleStartY + dy); + const int newX = roundToInt ((pos.getX() - scaleStartX) * scaleX + scaleStartX + dx); + const int newY = roundToInt ((pos.getY() - scaleStartY) * scaleY + scaleStartY + dy); pos.setBounds (newX, newY, - roundDoubleToInt ((pos.getRight() - scaleStartX) * scaleX + scaleStartX + dx) - newX, - roundDoubleToInt ((pos.getBottom() - scaleStartY) * scaleY + scaleStartY + dy) - newY); + roundToInt ((pos.getRight() - scaleStartX) * scaleX + scaleStartX + dx) - newX, + roundToInt ((pos.getBottom() - scaleStartY) * scaleY + scaleStartY + dy) - newY); e->setCurrentBounds (pos, parentArea, undoable); } diff --git a/extras/the jucer/src/model/paintelements/jucer_PaintElementPath.cpp b/extras/the jucer/src/model/paintelements/jucer_PaintElementPath.cpp index 0cb065fd86..82aed55a38 100644 --- a/extras/the jucer/src/model/paintelements/jucer_PaintElementPath.cpp +++ b/extras/the jucer/src/model/paintelements/jucer_PaintElementPath.cpp @@ -1590,8 +1590,8 @@ void PathPointComponent::updatePosition() double x, y; path->getPoint (index, pointNumber, x, y, area); - setCentrePosition (roundDoubleToInt (x), - roundDoubleToInt (y)); + setCentrePosition (roundToInt (x), + roundToInt (y)); } void PathPointComponent::showPopupMenu() diff --git a/extras/the jucer/src/model/paintelements/jucer_PaintElementRectangle.h b/extras/the jucer/src/model/paintelements/jucer_PaintElementRectangle.h index 26d5828339..64994fa640 100644 --- a/extras/the jucer/src/model/paintelements/jucer_PaintElementRectangle.h +++ b/extras/the jucer/src/model/paintelements/jucer_PaintElementRectangle.h @@ -70,7 +70,7 @@ public: strokeType.fill.setFillType (g, getDocument(), parentArea); g.drawRect (r.getX(), r.getY(), r.getWidth(), r.getHeight(), - roundDoubleToInt (getStrokeType().stroke.getStrokeThickness())); + roundToInt (getStrokeType().stroke.getStrokeThickness())); } } @@ -101,7 +101,7 @@ public: strokeType.fill.fillInGeneratedCode (code, paintMethodCode); s << "g.drawRect (" << x << ", " << y << ", " << w << ", " << h << ", " - << roundDoubleToInt (strokeType.stroke.getStrokeThickness()) << ");\n\n"; + << roundToInt (strokeType.stroke.getStrokeThickness()) << ");\n\n"; paintMethodCode += s; } diff --git a/extras/the jucer/src/model/paintelements/jucer_PaintElementText.h b/extras/the jucer/src/model/paintelements/jucer_PaintElementText.h index 1c8383790d..2dab8b4e84 100644 --- a/extras/the jucer/src/model/paintelements/jucer_PaintElementText.h +++ b/extras/the jucer/src/model/paintelements/jucer_PaintElementText.h @@ -114,7 +114,7 @@ public: addColourAttributes (e); e->setAttribute (T("text"), text); e->setAttribute (T("fontname"), typefaceName); - e->setAttribute (T("fontsize"), roundDoubleToInt (font.getHeight() * 100.0) / 100.0); + e->setAttribute (T("fontsize"), roundToInt (font.getHeight() * 100.0) / 100.0); e->setAttribute (T("bold"), font.isBold()); e->setAttribute (T("italic"), font.isItalic()); e->setAttribute (T("justification"), justification.getFlags()); diff --git a/extras/the jucer/src/properties/jucer_PositionPropertyBase.h b/extras/the jucer/src/properties/jucer_PositionPropertyBase.h index 1de8fc1259..84ce72a41d 100644 --- a/extras/the jucer/src/properties/jucer_PositionPropertyBase.h +++ b/extras/the jucer/src/properties/jucer_PositionPropertyBase.h @@ -118,7 +118,7 @@ public: static const String valueToString (const double n) { - return String (roundDoubleToInt (n * 1000.0) / 1000.0); + return String (roundToInt (n * 1000.0) / 1000.0); } void setText (const String& newText) diff --git a/extras/the jucer/src/ui/jucer_EditingPanelBase.cpp b/extras/the jucer/src/ui/jucer_EditingPanelBase.cpp index 5b50e2f256..65c005126c 100644 --- a/extras/the jucer/src/ui/jucer_EditingPanelBase.cpp +++ b/extras/the jucer/src/ui/jucer_EditingPanelBase.cpp @@ -155,9 +155,9 @@ void EditingPanelBase::resized() if (document.isFixedSize()) editor->setSize (jmax (document.getInitialWidth(), - roundDoubleToInt ((viewport->getWidth() - viewport->getScrollBarThickness()) / getZoom())), + roundToInt ((viewport->getWidth() - viewport->getScrollBarThickness()) / getZoom())), jmax (document.getInitialHeight(), - roundDoubleToInt ((viewport->getHeight() - viewport->getScrollBarThickness()) / getZoom()))); + roundToInt ((viewport->getHeight() - viewport->getScrollBarThickness()) / getZoom()))); else editor->setSize (viewport->getWidth(), viewport->getHeight()); diff --git a/extras/the jucer/src/utility/jucer_UtilityFunctions.cpp b/extras/the jucer/src/utility/jucer_UtilityFunctions.cpp index c595686cac..d5a32a7d65 100644 --- a/extras/the jucer/src/utility/jucer_UtilityFunctions.cpp +++ b/extras/the jucer/src/utility/jucer_UtilityFunctions.cpp @@ -378,16 +378,16 @@ void positionToCode (const RelativePositionedRectangle& position, else if (position.rect.getWidthMode() == PositionedRectangle::parentSizeMinusAbsolute) { if (wrw.isNotEmpty()) - w << "(" << wrw << ") - " << roundDoubleToInt (position.rect.getWidth()); + w << "(" << wrw << ") - " << roundToInt (position.rect.getWidth()); else - w << "getWidth() - " << roundDoubleToInt (position.rect.getWidth()); + w << "getWidth() - " << roundToInt (position.rect.getWidth()); } else { if (wrw.isNotEmpty()) w << "(" << wrw << ") + "; - w << roundDoubleToInt (position.rect.getWidth()); + w << roundToInt (position.rect.getWidth()); } // height @@ -401,16 +401,16 @@ void positionToCode (const RelativePositionedRectangle& position, else if (position.rect.getHeightMode() == PositionedRectangle::parentSizeMinusAbsolute) { if (hrh.isNotEmpty()) - h << "(" << hrh << ") - " << roundDoubleToInt (position.rect.getHeight()); + h << "(" << hrh << ") - " << roundToInt (position.rect.getHeight()); else - h << "getHeight() - " << roundDoubleToInt (position.rect.getHeight()); + h << "getHeight() - " << roundToInt (position.rect.getHeight()); } else { if (hrh.isNotEmpty()) h << "(" << hrh << ") + "; - h << roundDoubleToInt (position.rect.getHeight()); + h << roundToInt (position.rect.getHeight()); } // x-pos @@ -426,7 +426,7 @@ void positionToCode (const RelativePositionedRectangle& position, if (xrx.isNotEmpty()) x << "(" << xrx << ") + "; - x << roundDoubleToInt (position.rect.getX()); + x << roundToInt (position.rect.getX()); } else if (position.rect.getPositionModeX() == PositionedRectangle::absoluteFromParentBottomRight) { @@ -435,7 +435,7 @@ void positionToCode (const RelativePositionedRectangle& position, else x << "getWidth()"; - const int d = roundDoubleToInt (position.rect.getX()); + const int d = roundToInt (position.rect.getX()); if (d != 0) x << " - " << d; } @@ -446,7 +446,7 @@ void positionToCode (const RelativePositionedRectangle& position, else x << "(getWidth() / 2)"; - const int d = roundDoubleToInt (position.rect.getX()); + const int d = roundToInt (position.rect.getX()); if (d != 0) x << " + " << d; } @@ -472,7 +472,7 @@ void positionToCode (const RelativePositionedRectangle& position, if (yry.isNotEmpty()) y << "(" << yry << ") + "; - y << roundDoubleToInt (position.rect.getY()); + y << roundToInt (position.rect.getY()); } else if (position.rect.getPositionModeY() == PositionedRectangle::absoluteFromParentBottomRight) { @@ -481,7 +481,7 @@ void positionToCode (const RelativePositionedRectangle& position, else y << "getHeight()"; - const int d = roundDoubleToInt (position.rect.getY()); + const int d = roundToInt (position.rect.getY()); if (d != 0) y << " - " << d; } @@ -492,7 +492,7 @@ void positionToCode (const RelativePositionedRectangle& position, else y << "(getHeight() / 2)"; - const int d = roundDoubleToInt (position.rect.getY()); + const int d = roundToInt (position.rect.getY()); if (d != 0) y << " + " << d; } diff --git a/src/audio/audio_file_formats/flac/libFLAC/memory.c b/src/audio/audio_file_formats/flac/libFLAC/memory.c index 9ad696adb3..0da698e009 100644 --- a/src/audio/audio_file_formats/flac/libFLAC/memory.c +++ b/src/audio/audio_file_formats/flac/libFLAC/memory.c @@ -88,9 +88,6 @@ FLAC__bool FLAC__memory_alloc_aligned_int32_array(unsigned elements, FLAC__int32 FLAC__ASSERT(0 != aligned_pointer); FLAC__ASSERT(unaligned_pointer != aligned_pointer); - if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ - return false; - pu = (FLAC__int32*)FLAC__memory_alloc_aligned(sizeof(*pu) * (size_t)elements, &u.pv); if(0 == pu) { return false; @@ -117,9 +114,6 @@ FLAC__bool FLAC__memory_alloc_aligned_uint32_array(unsigned elements, FLAC__uint FLAC__ASSERT(0 != aligned_pointer); FLAC__ASSERT(unaligned_pointer != aligned_pointer); - if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ - return false; - pu = (FLAC__uint32*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv); if(0 == pu) { return false; @@ -146,9 +140,6 @@ FLAC__bool FLAC__memory_alloc_aligned_uint64_array(unsigned elements, FLAC__uint FLAC__ASSERT(0 != aligned_pointer); FLAC__ASSERT(unaligned_pointer != aligned_pointer); - if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ - return false; - pu = (FLAC__uint64*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv); if(0 == pu) { return false; @@ -175,9 +166,6 @@ FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(unsigned elements, unsigned FLAC__ASSERT(0 != aligned_pointer); FLAC__ASSERT(unaligned_pointer != aligned_pointer); - if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ - return false; - pu = (unsigned*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv); if(0 == pu) { return false; @@ -206,9 +194,6 @@ FLAC__bool FLAC__memory_alloc_aligned_real_array(unsigned elements, FLAC__real * FLAC__ASSERT(0 != aligned_pointer); FLAC__ASSERT(unaligned_pointer != aligned_pointer); - if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */ - return false; - pu = (FLAC__real*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv); if(0 == pu) { return false; diff --git a/src/audio/audio_file_formats/juce_AudioFormat.cpp b/src/audio/audio_file_formats/juce_AudioFormat.cpp index 3611310627..1f94793661 100644 --- a/src/audio/audio_file_formats/juce_AudioFormat.cpp +++ b/src/audio/audio_file_formats/juce_AudioFormat.cpp @@ -75,7 +75,7 @@ bool AudioFormatReader::read (int** destSamples, if (numSamplesToRead <= 0) return true; - if (! readSamples (destSamples, jmin (numChannels, numDestChannels), startOffsetInDestBuffer, + if (! readSamples (destSamples, jmin ((int) numChannels, numDestChannels), startOffsetInDestBuffer, startSampleInSource, numSamplesToRead)) return false; @@ -273,8 +273,8 @@ int64 AudioFormatReader::searchForLevel (int64 startSample, const double doubleMin = jlimit (0.0, (double) INT_MAX, magnitudeRangeMinimum * INT_MAX); const double doubleMax = jlimit (doubleMin, (double) INT_MAX, magnitudeRangeMaximum * INT_MAX); - const int intMagnitudeRangeMinimum = roundDoubleToInt (doubleMin); - const int intMagnitudeRangeMaximum = roundDoubleToInt (doubleMax); + const int intMagnitudeRangeMinimum = roundToInt (doubleMin); + const int intMagnitudeRangeMaximum = roundToInt (doubleMax); while (numSamplesToSearch != 0) { @@ -438,7 +438,7 @@ bool AudioFormatWriter::writeFromAudioReader (AudioFormatReader& reader, else if (samp >= 1.0) *b++ = INT_MAX; else - *b++ = roundDoubleToInt (INT_MAX * samp); + *b++ = roundToInt (INT_MAX * samp); } } } @@ -499,7 +499,7 @@ bool AudioFormatWriter::writeFromAudioSource (AudioSource& source, else if (samp >= 1.0) *b++ = INT_MAX; else - *b++ = roundDoubleToInt (INT_MAX * samp); + *b++ = roundToInt (INT_MAX * samp); } } } diff --git a/src/audio/audio_file_formats/juce_AudioThumbnail.cpp b/src/audio/audio_file_formats/juce_AudioThumbnail.cpp index e384b74d9d..f380976abc 100644 --- a/src/audio/audio_file_formats/juce_AudioThumbnail.cpp +++ b/src/audio/audio_file_formats/juce_AudioThumbnail.cpp @@ -215,7 +215,7 @@ void AudioThumbnail::saveTo (OutputStream& output) const { AudioThumbnailDataFormat* const d = (AudioThumbnailDataFormat*) data.getData(); swapEndiannessIfNeeded (d); - output.write (data.getData(), data.getSize()); + output.write (data.getData(), (int) data.getSize()); swapEndiannessIfNeeded (d); } @@ -224,9 +224,9 @@ bool AudioThumbnail::initialiseFromAudioFile (AudioFormatReader& fileReader) AudioThumbnailDataFormat* d = (AudioThumbnailDataFormat*) data.getData(); d->totalSamples = fileReader.lengthInSamples; - d->numChannels = jmin (2, fileReader.numChannels); + d->numChannels = jmin ((uint32) 2, fileReader.numChannels); d->numFinishedSamples = 0; - d->sampleRate = roundDoubleToInt (fileReader.sampleRate); + d->sampleRate = roundToInt (fileReader.sampleRate); d->numThumbnailSamples = (int) (d->totalSamples / d->samplesPerThumbSample) + 1; data.setSize (sizeof (AudioThumbnailDataFormat) + 3 + d->numThumbnailSamples * d->numChannels * 2); @@ -384,11 +384,11 @@ void AudioThumbnail::refillCache (const int numSamples, startTimer (timeBeforeDeletingReader); char* cacheData = (char*) cachedLevels.getData(); - int sample = roundDoubleToInt (startTime * d->sampleRate); + int sample = roundToInt (startTime * d->sampleRate); for (int i = numSamples; --i >= 0;) { - const int nextSample = roundDoubleToInt ((startTime + timePerPixel) * d->sampleRate); + const int nextSample = roundToInt ((startTime + timePerPixel) * d->sampleRate); if (sample >= 0) { @@ -427,12 +427,12 @@ void AudioThumbnail::refillCache (const int numSamples, const double timeToThumbSampleFactor = d->sampleRate / (double) d->samplesPerThumbSample; startTime = cachedStart; - int sample = roundDoubleToInt (startTime * timeToThumbSampleFactor); + int sample = roundToInt (startTime * timeToThumbSampleFactor); const int numFinished = (int) (d->numFinishedSamples / d->samplesPerThumbSample); for (int i = numSamples; --i >= 0;) { - const int nextSample = roundDoubleToInt ((startTime + timePerPixel) * timeToThumbSampleFactor); + const int nextSample = roundToInt ((startTime + timePerPixel) * timeToThumbSampleFactor); if (sample >= 0 && channelData != 0) { diff --git a/src/audio/audio_file_formats/juce_FlacAudioFormat.cpp b/src/audio/audio_file_formats/juce_FlacAudioFormat.cpp index a207c2381b..a7b2a08e71 100644 --- a/src/audio/audio_file_formats/juce_FlacAudioFormat.cpp +++ b/src/audio/audio_file_formats/juce_FlacAudioFormat.cpp @@ -328,7 +328,7 @@ public: FLAC__stream_encoder_set_do_mid_side_stereo (encoder, numChannels == 2); FLAC__stream_encoder_set_loose_mid_side_stereo (encoder, numChannels == 2); FLAC__stream_encoder_set_channels (encoder, numChannels); - FLAC__stream_encoder_set_bits_per_sample (encoder, jmin (24, bitsPerSample)); + FLAC__stream_encoder_set_bits_per_sample (encoder, jmin ((unsigned int) 24, bitsPerSample)); FLAC__stream_encoder_set_sample_rate (encoder, (unsigned int) sampleRate); FLAC__stream_encoder_set_blocksize (encoder, 2048); FLAC__stream_encoder_set_do_escape_coding (encoder, true); diff --git a/src/audio/audio_file_formats/juce_OggVorbisAudioFormat.cpp b/src/audio/audio_file_formats/juce_OggVorbisAudioFormat.cpp index 49790d43d0..4102878b2e 100644 --- a/src/audio/audio_file_formats/juce_OggVorbisAudioFormat.cpp +++ b/src/audio/audio_file_formats/juce_OggVorbisAudioFormat.cpp @@ -184,7 +184,7 @@ public: jassert (samps <= numToRead); - for (int i = jmin (numChannels, reservoir.getNumChannels()); --i >= 0;) + for (int i = jmin ((int) numChannels, reservoir.getNumChannels()); --i >= 0;) { memcpy (reservoir.getSampleData (i, offset), dataIn[i], diff --git a/src/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp b/src/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp index 595c3fc835..0cd54cfc8e 100644 --- a/src/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp +++ b/src/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp @@ -171,7 +171,7 @@ public: | kAudioFormatFlagIsPacked | kAudioFormatFlagsNativeEndian; inputStreamDesc.mBitsPerChannel = sizeof (SInt16) * 8; - inputStreamDesc.mChannelsPerFrame = jmin (2, inputStreamDesc.mChannelsPerFrame); + inputStreamDesc.mChannelsPerFrame = jmin ((UInt32) 2, inputStreamDesc.mChannelsPerFrame); inputStreamDesc.mBytesPerFrame = sizeof (SInt16) * inputStreamDesc.mChannelsPerFrame; inputStreamDesc.mBytesPerPacket = inputStreamDesc.mBytesPerFrame; diff --git a/src/audio/audio_file_formats/juce_WavAudioFormat.cpp b/src/audio/audio_file_formats/juce_WavAudioFormat.cpp index 4190567e25..751b8d39ad 100644 --- a/src/audio/audio_file_formats/juce_WavAudioFormat.cpp +++ b/src/audio/audio_file_formats/juce_WavAudioFormat.cpp @@ -111,7 +111,7 @@ struct BWAVChunk static MemoryBlock createFrom (const StringPairArray& values) { - const int sizeNeeded = sizeof (BWAVChunk) + values [WavAudioFormat::bwavCodingHistory].copyToUTF8 (0) - 1; + const size_t sizeNeeded = sizeof (BWAVChunk) + values [WavAudioFormat::bwavCodingHistory].copyToUTF8 (0) - 1; MemoryBlock data ((sizeNeeded + 3) & ~3); data.fillWith (0); @@ -277,14 +277,14 @@ public: // Broadcast-wav extension chunk.. HeapBlock bwav; - bwav.calloc (jmax (length + 1, (int) sizeof (BWAVChunk)), 1); + bwav.calloc (jmax ((size_t) length + 1, sizeof (BWAVChunk)), 1); input->read (bwav, length); bwav->copyTo (metadataValues); } else if (chunkType == chunkName ("smpl")) { HeapBlock smpl; - smpl.calloc (jmax (length + 1, (int) sizeof (SMPLChunk)), 1); + smpl.calloc (jmax ((size_t) length + 1, sizeof (SMPLChunk)), 1); input->read (smpl, length); smpl->copyTo (metadataValues, length); } @@ -550,8 +550,8 @@ class WavAudioFormatWriter : public AudioFormatWriter const int bytesPerFrame = numChannels * bitsPerSample / 8; output->writeInt (chunkName ("RIFF")); - output->writeInt (lengthInSamples * bytesPerFrame - + ((bwavChunk.getSize() > 0) ? (44 + bwavChunk.getSize()) : 36)); + output->writeInt ((int) (lengthInSamples * bytesPerFrame + + ((bwavChunk.getSize() > 0) ? (44 + bwavChunk.getSize()) : 36))); output->writeInt (chunkName ("WAVE")); output->writeInt (chunkName ("fmt ")); @@ -567,8 +567,8 @@ class WavAudioFormatWriter : public AudioFormatWriter if (bwavChunk.getSize() > 0) { output->writeInt (chunkName ("bext")); - output->writeInt (bwavChunk.getSize()); - output->write (bwavChunk.getData(), bwavChunk.getSize()); + output->writeInt ((int) bwavChunk.getSize()); + output->write (bwavChunk.getData(), (int) bwavChunk.getSize()); } output->writeInt (chunkName ("data")); @@ -843,7 +843,7 @@ bool WavAudioFormat::replaceMetadataInFile (const File& wavFile, const StringPai { MemoryBlock chunk = BWAVChunk::createFrom (newMetadata); - if (chunk.getSize() <= bwavSize) + if (chunk.getSize() <= (size_t) bwavSize) { // the new one will fit in the space available, so write it directly.. const int64 oldSize = wavFile.getSize(); @@ -851,7 +851,7 @@ bool WavAudioFormat::replaceMetadataInFile (const File& wavFile, const StringPai { ScopedPointer out (wavFile.createOutputStream()); out->setPosition (bwavPos); - out->write (chunk.getData(), chunk.getSize()); + out->write (chunk.getData(), (int) chunk.getSize()); out->setPosition (oldSize); } diff --git a/src/audio/audio_sources/juce_AudioTransportSource.cpp b/src/audio/audio_sources/juce_AudioTransportSource.cpp index c1c7c3dac6..ca1633eef2 100644 --- a/src/audio/audio_sources/juce_AudioTransportSource.cpp +++ b/src/audio/audio_sources/juce_AudioTransportSource.cpp @@ -157,7 +157,7 @@ void AudioTransportSource::stop() void AudioTransportSource::setPosition (double newPosition) { if (sampleRate > 0.0) - setNextReadPosition (roundDoubleToInt (newPosition * sampleRate)); + setNextReadPosition (roundToInt (newPosition * sampleRate)); } double AudioTransportSource::getCurrentPosition() const @@ -173,7 +173,7 @@ void AudioTransportSource::setNextReadPosition (int newPosition) if (positionableSource != 0) { if (sampleRate > 0 && sourceSampleRate > 0) - newPosition = roundDoubleToInt (newPosition * sourceSampleRate / sampleRate); + newPosition = roundToInt (newPosition * sourceSampleRate / sampleRate); positionableSource->setNextReadPosition (newPosition); } @@ -185,7 +185,7 @@ int AudioTransportSource::getNextReadPosition() const { const double ratio = (sampleRate > 0 && sourceSampleRate > 0) ? sampleRate / sourceSampleRate : 1.0; - return roundDoubleToInt (positionableSource->getNextReadPosition() * ratio); + return roundToInt (positionableSource->getNextReadPosition() * ratio); } return 0; @@ -199,7 +199,7 @@ int AudioTransportSource::getTotalLength() const { const double ratio = (sampleRate > 0 && sourceSampleRate > 0) ? sampleRate / sourceSampleRate : 1.0; - return roundDoubleToInt (positionableSource->getTotalLength() * ratio); + return roundToInt (positionableSource->getTotalLength() * ratio); } return 0; diff --git a/src/audio/audio_sources/juce_ResamplingAudioSource.cpp b/src/audio/audio_sources/juce_ResamplingAudioSource.cpp index ef07317b38..62554e4d58 100644 --- a/src/audio/audio_sources/juce_ResamplingAudioSource.cpp +++ b/src/audio/audio_sources/juce_ResamplingAudioSource.cpp @@ -65,7 +65,7 @@ void ResamplingAudioSource::prepareToPlay (int samplesPerBlockExpected, input->prepareToPlay (samplesPerBlockExpected, sampleRate); - buffer.setSize (2, roundDoubleToInt (samplesPerBlockExpected * ratio) + 32); + buffer.setSize (2, roundToInt (samplesPerBlockExpected * ratio) + 32); buffer.clear(); sampsInBuffer = 0; bufferPos = 0; @@ -91,7 +91,7 @@ void ResamplingAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& inf lastRatio = ratio; } - const int sampsNeeded = roundDoubleToInt (info.numSamples * ratio) + 2; + const int sampsNeeded = roundToInt (info.numSamples * ratio) + 2; int bufferSize = buffer.getNumSamples(); diff --git a/src/audio/devices/juce_MidiOutput.cpp b/src/audio/devices/juce_MidiOutput.cpp index 33ec6ab36a..36d181c8ab 100644 --- a/src/audio/devices/juce_MidiOutput.cpp +++ b/src/audio/devices/juce_MidiOutput.cpp @@ -128,11 +128,11 @@ void MidiOutput::run() if (message != 0) { - eventTime = roundDoubleToInt (message->message.getTimeStamp()); + eventTime = roundToInt (message->message.getTimeStamp()); if (eventTime > now + 20) { - timeToWait = jmax (10, eventTime - now - 100); + timeToWait = eventTime - (now + 20); message = 0; } else diff --git a/src/audio/dsp/juce_AudioDataConverters.cpp b/src/audio/dsp/juce_AudioDataConverters.cpp index 1c91727dd1..b63d16e04d 100644 --- a/src/audio/dsp/juce_AudioDataConverters.cpp +++ b/src/audio/dsp/juce_AudioDataConverters.cpp @@ -40,7 +40,7 @@ void AudioDataConverters::convertFloatToInt16LE (const float* source, void* dest { for (int i = 0; i < numSamples; ++i) { - *(uint16*)intData = ByteOrder::swapIfBigEndian ((uint16) (short) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); + *(uint16*)intData = ByteOrder::swapIfBigEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); intData += destBytesPerSample; } } @@ -51,7 +51,7 @@ void AudioDataConverters::convertFloatToInt16LE (const float* source, void* dest for (int i = numSamples; --i >= 0;) { intData -= destBytesPerSample; - *(uint16*)intData = ByteOrder::swapIfBigEndian ((uint16) (short) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); + *(uint16*)intData = ByteOrder::swapIfBigEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); } } } @@ -65,7 +65,7 @@ void AudioDataConverters::convertFloatToInt16BE (const float* source, void* dest { for (int i = 0; i < numSamples; ++i) { - *(uint16*) intData = ByteOrder::swapIfLittleEndian ((uint16) (short) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); + *(uint16*) intData = ByteOrder::swapIfLittleEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); intData += destBytesPerSample; } } @@ -76,7 +76,7 @@ void AudioDataConverters::convertFloatToInt16BE (const float* source, void* dest for (int i = numSamples; --i >= 0;) { intData -= destBytesPerSample; - *(uint16*)intData = ByteOrder::swapIfLittleEndian ((uint16) (short) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); + *(uint16*)intData = ByteOrder::swapIfLittleEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); } } } @@ -90,7 +90,7 @@ void AudioDataConverters::convertFloatToInt24LE (const float* source, void* dest { for (int i = 0; i < numSamples; ++i) { - ByteOrder::littleEndian24BitToChars ((uint32) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * source[i])), intData); + ByteOrder::littleEndian24BitToChars ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i])), intData); intData += destBytesPerSample; } } @@ -101,7 +101,7 @@ void AudioDataConverters::convertFloatToInt24LE (const float* source, void* dest for (int i = numSamples; --i >= 0;) { intData -= destBytesPerSample; - ByteOrder::littleEndian24BitToChars ((uint32) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * source[i])), intData); + ByteOrder::littleEndian24BitToChars ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i])), intData); } } } @@ -115,7 +115,7 @@ void AudioDataConverters::convertFloatToInt24BE (const float* source, void* dest { for (int i = 0; i < numSamples; ++i) { - ByteOrder::bigEndian24BitToChars ((uint32) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * source[i])), intData); + ByteOrder::bigEndian24BitToChars ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i])), intData); intData += destBytesPerSample; } } @@ -126,7 +126,7 @@ void AudioDataConverters::convertFloatToInt24BE (const float* source, void* dest for (int i = numSamples; --i >= 0;) { intData -= destBytesPerSample; - ByteOrder::bigEndian24BitToChars ((uint32) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * source[i])), intData); + ByteOrder::bigEndian24BitToChars ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i])), intData); } } } @@ -140,7 +140,7 @@ void AudioDataConverters::convertFloatToInt32LE (const float* source, void* dest { for (int i = 0; i < numSamples; ++i) { - *(uint32*)intData = ByteOrder::swapIfBigEndian ((uint32) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); + *(uint32*)intData = ByteOrder::swapIfBigEndian ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); intData += destBytesPerSample; } } @@ -151,7 +151,7 @@ void AudioDataConverters::convertFloatToInt32LE (const float* source, void* dest for (int i = numSamples; --i >= 0;) { intData -= destBytesPerSample; - *(uint32*)intData = ByteOrder::swapIfBigEndian ((uint32) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); + *(uint32*)intData = ByteOrder::swapIfBigEndian ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); } } } @@ -165,7 +165,7 @@ void AudioDataConverters::convertFloatToInt32BE (const float* source, void* dest { for (int i = 0; i < numSamples; ++i) { - *(uint32*)intData = ByteOrder::swapIfLittleEndian ((uint32) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); + *(uint32*)intData = ByteOrder::swapIfLittleEndian ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); intData += destBytesPerSample; } } @@ -176,7 +176,7 @@ void AudioDataConverters::convertFloatToInt32BE (const float* source, void* dest for (int i = numSamples; --i >= 0;) { intData -= destBytesPerSample; - *(uint32*)intData = ByteOrder::swapIfLittleEndian ((uint32) roundDoubleToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); + *(uint32*)intData = ByteOrder::swapIfLittleEndian ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); } } } diff --git a/src/audio/dsp/juce_AudioSampleBuffer.cpp b/src/audio/dsp/juce_AudioSampleBuffer.cpp index 1cc542eb32..dfaed15377 100644 --- a/src/audio/dsp/juce_AudioSampleBuffer.cpp +++ b/src/audio/dsp/juce_AudioSampleBuffer.cpp @@ -49,7 +49,7 @@ AudioSampleBuffer::AudioSampleBuffer (const AudioSampleBuffer& other) throw() size (other.size) { allocateData(); - const int numBytes = size * sizeof (float); + const size_t numBytes = size * sizeof (float); for (int i = 0; i < numChannels; ++i) memcpy (channels[i], other.channels[i], numBytes); @@ -57,8 +57,8 @@ AudioSampleBuffer::AudioSampleBuffer (const AudioSampleBuffer& other) throw() void AudioSampleBuffer::allocateData() { - const int channelListSize = (numChannels + 1) * sizeof (float*); - allocatedBytes = numChannels * size * sizeof (float) + channelListSize + 32; + const size_t channelListSize = (numChannels + 1) * sizeof (float*); + allocatedBytes = (int) (numChannels * size * sizeof (float) + channelListSize + 32); allocatedData.malloc (allocatedBytes); channels = (float**) allocatedData; @@ -128,7 +128,7 @@ const AudioSampleBuffer& AudioSampleBuffer::operator= (const AudioSampleBuffer& { setSize (other.getNumChannels(), other.getNumSamples(), false, false, false); - const int numBytes = size * sizeof (float); + const size_t numBytes = size * sizeof (float); for (int i = 0; i < numChannels; ++i) memcpy (channels[i], other.channels[i], numBytes); @@ -151,8 +151,8 @@ void AudioSampleBuffer::setSize (const int newNumChannels, if (newNumSamples != size || newNumChannels != numChannels) { - const int channelListSize = (newNumChannels + 1) * sizeof (float*); - const int newTotalBytes = (newNumChannels * newNumSamples * sizeof (float)) + channelListSize + 32; + const size_t channelListSize = (newNumChannels + 1) * sizeof (float*); + const size_t newTotalBytes = (newNumChannels * newNumSamples * sizeof (float)) + channelListSize + 32; if (keepExistingContent) { @@ -160,7 +160,7 @@ void AudioSampleBuffer::setSize (const int newNumChannels, newData.allocate (newTotalBytes, clearExtraSpace); const int numChansToCopy = jmin (numChannels, newNumChannels); - const int numBytesToCopy = sizeof (float) * jmin (newNumSamples, size); + const size_t numBytesToCopy = sizeof (float) * jmin (newNumSamples, size); float** const newChannels = (float**) newData; float* newChan = (float*) (newData + channelListSize); @@ -172,7 +172,7 @@ void AudioSampleBuffer::setSize (const int newNumChannels, } allocatedData.swapWith (newData); - allocatedBytes = newTotalBytes; + allocatedBytes = (int) newTotalBytes; channels = (float**) allocatedData; } else @@ -680,7 +680,7 @@ void AudioSampleBuffer::writeToAudioWriter (AudioFormatWriter* writer, else if (samp >= 1.0) dest[i] = INT_MAX; else - dest[i] = roundDoubleToInt (INT_MAX * samp); + dest[i] = roundToInt (INT_MAX * samp); } } } diff --git a/src/audio/dsp/juce_AudioSampleBuffer.h b/src/audio/dsp/juce_AudioSampleBuffer.h index 04cc44c425..5b1920e207 100644 --- a/src/audio/dsp/juce_AudioSampleBuffer.h +++ b/src/audio/dsp/juce_AudioSampleBuffer.h @@ -424,7 +424,8 @@ public: juce_UseDebuggingNewOperator private: - int numChannels, size, allocatedBytes; + int numChannels, size; + size_t allocatedBytes; float** channels; HeapBlock allocatedData; float* preallocatedChannelSpace [32]; diff --git a/src/audio/midi/juce_MidiBuffer.cpp b/src/audio/midi/juce_MidiBuffer.cpp index 3f8c31c968..8ffcba4141 100644 --- a/src/audio/midi/juce_MidiBuffer.cpp +++ b/src/audio/midi/juce_MidiBuffer.cpp @@ -43,8 +43,8 @@ MidiBuffer::MidiBuffer (const MidiMessage& message) throw() } MidiBuffer::MidiBuffer (const MidiBuffer& other) throw() - : bytesUsed (other.bytesUsed), - data (other.data) + : data (other.data), + bytesUsed (other.bytesUsed) { } diff --git a/src/audio/midi/juce_MidiFile.cpp b/src/audio/midi/juce_MidiFile.cpp index ec0a33c1f1..e8d103091d 100644 --- a/src/audio/midi/juce_MidiFile.cpp +++ b/src/audio/midi/juce_MidiFile.cpp @@ -190,7 +190,7 @@ bool MidiFile::readFrom (InputStream& sourceStream) // (put a sanity-check on the file size, as midi files are generally small) if (sourceStream.readIntoMemoryBlock (data, maxSensibleMidiFileSize)) { - int size = data.getSize(); + size_t size = data.getSize(); const char* d = (char*) data.getData(); short fileType, expectedTracks; @@ -430,7 +430,7 @@ void MidiFile::writeTrack (OutputStream& mainOut, { const MidiMessage& mm = ms.getEventPointer(i)->message; - const int tick = roundDoubleToInt (mm.getTimeStamp()); + const int tick = roundToInt (mm.getTimeStamp()); const int delta = jmax (0, tick - lastTick); writeVariableLengthInt (out, delta); lastTick = tick; @@ -458,8 +458,8 @@ void MidiFile::writeTrack (OutputStream& mainOut, m.getRawDataSize()); mainOut.writeIntBigEndian ((int) ByteOrder::bigEndianInt ("MTrk")); - mainOut.writeIntBigEndian (out.getDataSize()); - mainOut.write (out.getData(), out.getDataSize()); + mainOut.writeIntBigEndian ((int) out.getDataSize()); + mainOut.write (out.getData(), (int) out.getDataSize()); } END_JUCE_NAMESPACE diff --git a/src/audio/midi/juce_MidiKeyboardState.cpp b/src/audio/midi/juce_MidiKeyboardState.cpp index 5a244b8aac..85de6a3a8f 100644 --- a/src/audio/midi/juce_MidiKeyboardState.cpp +++ b/src/audio/midi/juce_MidiKeyboardState.cpp @@ -173,7 +173,7 @@ void MidiKeyboardState::processNextMidiBuffer (MidiBuffer& buffer, while (i2.getNextEvent (message, time)) { - const int pos = jlimit (0, numSamples - 1, roundDoubleToInt ((time - firstEventToAdd) * scaleFactor)); + const int pos = jlimit (0, numSamples - 1, roundToInt ((time - firstEventToAdd) * scaleFactor)); buffer.addEvent (message, startSample + pos); } } diff --git a/src/audio/midi/juce_MidiMessage.cpp b/src/audio/midi/juce_MidiMessage.cpp index 9277cd83b7..5d38de20e7 100644 --- a/src/audio/midi/juce_MidiMessage.cpp +++ b/src/audio/midi/juce_MidiMessage.cpp @@ -353,13 +353,13 @@ float MidiMessage::getFloatVelocity() const throw() void MidiMessage::setVelocity (const float newVelocity) throw() { if (isNoteOnOrOff()) - data[2] = (uint8) jlimit (0, 0x7f, roundFloatToInt (newVelocity * 127.0f)); + data[2] = (uint8) jlimit (0, 0x7f, roundToInt (newVelocity * 127.0f)); } void MidiMessage::multiplyVelocity (const float scaleFactor) throw() { if (isNoteOnOrOff()) - data[2] = (uint8) jlimit (0, 0x7f, roundFloatToInt (scaleFactor * data[2])); + data[2] = (uint8) jlimit (0, 0x7f, roundToInt (scaleFactor * data[2])); } bool MidiMessage::isAftertouch() const throw() @@ -494,7 +494,7 @@ const MidiMessage MidiMessage::noteOn (const int channel, return MidiMessage (0x90 | jlimit (0, 15, channel - 1), noteNumber & 127, - jlimit (0, 127, roundFloatToInt (velocity))); + jlimit (0, 127, roundToInt (velocity))); } const MidiMessage MidiMessage::noteOff (const int channel, @@ -537,7 +537,7 @@ const MidiMessage MidiMessage::allControllersOff (const int channel) throw() const MidiMessage MidiMessage::masterVolume (const float volume) throw() { - const int vol = jlimit (0, 0x3fff, roundFloatToInt (volume * 0x4000)); + const int vol = jlimit (0, 0x3fff, roundToInt (volume * 0x4000)); uint8 buf[8]; buf[0] = 0xf0; diff --git a/src/audio/midi/juce_MidiMessageCollector.cpp b/src/audio/midi/juce_MidiMessageCollector.cpp index d7eac26e58..b6c563582e 100644 --- a/src/audio/midi/juce_MidiMessageCollector.cpp +++ b/src/audio/midi/juce_MidiMessageCollector.cpp @@ -90,7 +90,7 @@ void MidiMessageCollector::removeNextBlockOfMessages (MidiBuffer& destBuffer, if (! incomingMessages.isEmpty()) { - int numSourceSamples = jmax (1, roundDoubleToInt (msElapsed * 0.001 * sampleRate)); + int numSourceSamples = jmax (1, roundToInt (msElapsed * 0.001 * sampleRate)); int startSample = 0; int scale = 1 << 16; diff --git a/src/audio/plugins/formats/juce_AudioUnitPluginFormat.mm b/src/audio/plugins/formats/juce_AudioUnitPluginFormat.mm index 9e001f3b3b..4c0eb8718d 100644 --- a/src/audio/plugins/formats/juce_AudioUnitPluginFormat.mm +++ b/src/audio/plugins/formats/juce_AudioUnitPluginFormat.mm @@ -570,7 +570,7 @@ void AudioUnitPluginInstance::prepareToPlay (double sampleRate_, AudioUnitGetProperty (audioUnit, kAudioUnitProperty_Latency, kAudioUnitScope_Global, 0, &latencySecs, &latencySize); - setLatencySamples (roundDoubleToInt (latencySecs * sampleRate_)); + setLatencySamples (roundToInt (latencySecs * sampleRate_)); AudioUnitReset (audioUnit, kAudioUnitScope_Input, 0); AudioUnitReset (audioUnit, kAudioUnitScope_Output, 0); @@ -796,7 +796,7 @@ OSStatus AudioUnitPluginInstance::getTransportState (Boolean* outIsPlaying, } if (outCurrentSampleInTimeLine != 0) - *outCurrentSampleInTimeLine = roundDoubleToInt (result.timeInSeconds * getSampleRate()); + *outCurrentSampleInTimeLine = roundToInt (result.timeInSeconds * getSampleRate()); if (outIsCycling != 0) *outIsCycling = false; diff --git a/src/audio/processors/juce_AudioProcessor.cpp b/src/audio/processors/juce_AudioProcessor.cpp index 1aea0c333d..c68c6ca324 100644 --- a/src/audio/processors/juce_AudioProcessor.cpp +++ b/src/audio/processors/juce_AudioProcessor.cpp @@ -267,7 +267,7 @@ XmlElement* AudioProcessor::getXmlFromBinary (const void* data, if (sizeInBytes > 8 && ByteOrder::littleEndianInt ((const char*) data) == magicXmlNumber) { - const uint32 stringLength = ByteOrder::littleEndianInt (((const char*) data) + 4); + const int stringLength = (int) ByteOrder::littleEndianInt (((const char*) data) + 4); if (stringLength > 0) { diff --git a/src/audio/synthesisers/juce_Sampler.cpp b/src/audio/synthesisers/juce_Sampler.cpp index 5c69c0a32d..cb72b6b8ed 100644 --- a/src/audio/synthesisers/juce_Sampler.cpp +++ b/src/audio/synthesisers/juce_Sampler.cpp @@ -56,12 +56,12 @@ SamplerSound::SamplerSound (const String& name_, length = jmin ((int) source.lengthInSamples, (int) (maxSampleLengthSeconds * sourceSampleRate)); - data = new AudioSampleBuffer (jmin (2, source.numChannels), length + 4); + data = new AudioSampleBuffer (jmin (2, (int) source.numChannels), length + 4); data->readFromAudioReader (&source, 0, length + 4, 0, true, true); - attackSamples = roundDoubleToInt (attackTimeSecs * sourceSampleRate); - releaseSamples = roundDoubleToInt (releaseTimeSecs * sourceSampleRate); + attackSamples = roundToInt (attackTimeSecs * sourceSampleRate); + releaseSamples = roundToInt (releaseTimeSecs * sourceSampleRate); } } diff --git a/src/containers/juce_BitArray.cpp b/src/containers/juce_BitArray.cpp index edc3620e97..d14ab66369 100644 --- a/src/containers/juce_BitArray.cpp +++ b/src/containers/juce_BitArray.cpp @@ -926,7 +926,7 @@ void BitArray::parseString (const String& text, const MemoryBlock BitArray::toMemoryBlock() const throw() { const int numBytes = (getHighestBit() + 8) >> 3; - MemoryBlock mb (numBytes); + MemoryBlock mb ((size_t) numBytes); for (int i = 0; i < numBytes; ++i) mb[i] = (uint8) getBitRangeAsInt (i << 3, 8); @@ -938,8 +938,8 @@ void BitArray::loadFromMemoryBlock (const MemoryBlock& data) throw() { clear(); - for (int i = data.getSize(); --i >= 0;) - this->setBitRangeAsInt (i << 3, 8, data [i]); + for (size_t i = data.getSize(); --i >= 0;) + this->setBitRangeAsInt ((int) (i << 3), 8, data [i]); } END_JUCE_NAMESPACE diff --git a/src/containers/juce_HeapBlock.h b/src/containers/juce_HeapBlock.h index e8d0626b27..9a7edb96bc 100644 --- a/src/containers/juce_HeapBlock.h +++ b/src/containers/juce_HeapBlock.h @@ -89,7 +89,7 @@ public: If you want an array of zero values, you can use the calloc() method instead. */ - HeapBlock (const int numElements) + HeapBlock (const size_t numElements) : data ((ElementType*) ::juce_malloc (numElements * sizeof (ElementType))) { } @@ -170,7 +170,7 @@ public: The data that is allocated will be freed when this object is deleted, or when you call free() or any of the allocation methods. */ - void malloc (const int newNumElements, const unsigned int elementSize = sizeof (ElementType)) + void malloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType)) { ::juce_free (data); data = (ElementType*) ::juce_malloc (newNumElements * elementSize); @@ -179,7 +179,7 @@ public: /** Allocates a specified amount of memory and clears it. This does the same job as the malloc() method, but clears the memory that it allocates. */ - void calloc (const int newNumElements, const unsigned int elementSize = sizeof (ElementType)) + void calloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType)) { ::juce_free (data); data = (ElementType*) ::juce_calloc (newNumElements * elementSize); @@ -189,7 +189,7 @@ public: This does the same job as either malloc() or calloc(), depending on the initialiseToZero parameter. */ - void allocate (const int newNumElements, const bool initialiseToZero) + void allocate (const size_t newNumElements, const bool initialiseToZero) { ::juce_free (data); @@ -204,7 +204,7 @@ public: The semantics of this method are the same as malloc() and calloc(), but it uses realloc() to keep as much of the existing data as possible. */ - void realloc (const int newNumElements, const unsigned int elementSize = sizeof (ElementType)) + void realloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType)) { if (data == 0) data = (ElementType*) ::juce_malloc (newNumElements * elementSize); diff --git a/src/containers/juce_MemoryBlock.cpp b/src/containers/juce_MemoryBlock.cpp index ef488c3c45..11182f6c96 100644 --- a/src/containers/juce_MemoryBlock.cpp +++ b/src/containers/juce_MemoryBlock.cpp @@ -36,7 +36,7 @@ MemoryBlock::MemoryBlock() throw() { } -MemoryBlock::MemoryBlock (const int initialSize, +MemoryBlock::MemoryBlock (const size_t initialSize, const bool initialiseToZero) throw() { if (initialSize > 0) @@ -62,8 +62,8 @@ MemoryBlock::MemoryBlock (const MemoryBlock& other) throw() } MemoryBlock::MemoryBlock (const void* const dataToInitialiseFrom, - const int sizeInBytes) throw() - : size (jmax (0, sizeInBytes)) + const size_t sizeInBytes) throw() + : size (jmax ((size_t) 0, sizeInBytes)) { jassert (sizeInBytes >= 0); @@ -109,7 +109,7 @@ bool MemoryBlock::operator!= (const MemoryBlock& other) const throw() //============================================================================== // this will resize the block to this size -void MemoryBlock::setSize (const int newSize, +void MemoryBlock::setSize (const size_t newSize, const bool initialiseToZero) throw() { if (size != newSize) @@ -138,7 +138,7 @@ void MemoryBlock::setSize (const int newSize, } } -void MemoryBlock::ensureSize (const int minimumSize, +void MemoryBlock::ensureSize (const size_t minimumSize, const bool initialiseToZero) throw() { if (size < minimumSize) @@ -158,17 +158,17 @@ void MemoryBlock::fillWith (const uint8 value) throw() } void MemoryBlock::append (const void* const srcData, - const int numBytes) throw() + const size_t numBytes) throw() { if (numBytes > 0) { - const int oldSize = size; + const size_t oldSize = size; setSize (size + numBytes); memcpy (data + oldSize, srcData, numBytes); } } -void MemoryBlock::copyFrom (const void* const src, int offset, int num) throw() +void MemoryBlock::copyFrom (const void* const src, int offset, size_t num) throw() { const char* d = (const char*) src; @@ -186,7 +186,7 @@ void MemoryBlock::copyFrom (const void* const src, int offset, int num) throw() memcpy (data + offset, d, num); } -void MemoryBlock::copyTo (void* const dst, int offset, int num) const throw() +void MemoryBlock::copyTo (void* const dst, int offset, size_t num) const throw() { char* d = (char*) dst; @@ -201,7 +201,7 @@ void MemoryBlock::copyTo (void* const dst, int offset, int num) const throw() if (offset + num > size) { - const int newNum = size - offset; + const size_t newNum = size - offset; zeromem (d + newNum, num - newNum); num = newNum; } @@ -210,7 +210,7 @@ void MemoryBlock::copyTo (void* const dst, int offset, int num) const throw() memcpy (d, data + offset, num); } -void MemoryBlock::removeSection (int startByte, int numBytesToRemove) throw() +void MemoryBlock::removeSection (size_t startByte, size_t numBytesToRemove) throw() { if (startByte < 0) { @@ -238,17 +238,17 @@ const String MemoryBlock::toString() const throw() } //============================================================================== -int MemoryBlock::getBitRange (const int bitRangeStart, int numBits) const throw() +int MemoryBlock::getBitRange (const size_t bitRangeStart, size_t numBits) const throw() { int res = 0; - int byte = bitRangeStart >> 3; - int offsetInByte = bitRangeStart & 7; - int bitsSoFar = 0; + size_t byte = bitRangeStart >> 3; + size_t offsetInByte = bitRangeStart & 7; + size_t bitsSoFar = 0; - while (numBits > 0 && byte < size) + while (numBits > 0 && (size_t) byte < size) { - const int bitsThisTime = jmin (numBits, 8 - offsetInByte); + const size_t bitsThisTime = jmin (numBits, 8 - offsetInByte); const int mask = (0xff >> (8 - bitsThisTime)) << offsetInByte; res |= (((data[byte] & mask) >> offsetInByte) << bitsSoFar); @@ -262,15 +262,15 @@ int MemoryBlock::getBitRange (const int bitRangeStart, int numBits) const throw( return res; } -void MemoryBlock::setBitRange (const int bitRangeStart, int numBits, int bitsToSet) throw() +void MemoryBlock::setBitRange (const size_t bitRangeStart, size_t numBits, int bitsToSet) throw() { - int byte = bitRangeStart >> 3; - int offsetInByte = bitRangeStart & 7; + size_t byte = bitRangeStart >> 3; + size_t offsetInByte = bitRangeStart & 7; unsigned int mask = ~((((unsigned int)0xffffffff) << (32 - numBits)) >> (32 - numBits)); - while (numBits > 0 && byte < size) + while (numBits > 0 && (size_t) byte < size) { - const int bitsThisTime = jmin (numBits, 8 - offsetInByte); + const size_t bitsThisTime = jmin (numBits, 8 - offsetInByte); const unsigned int tempMask = (mask << offsetInByte) | ~((((unsigned int)0xffffffff) >> offsetInByte) << offsetInByte); const unsigned int tempBits = bitsToSet << offsetInByte; @@ -337,16 +337,16 @@ static const char* const encodingTable const String MemoryBlock::toBase64Encoding() const throw() { - const int numChars = ((size << 3) + 5) / 6; + const size_t numChars = ((size << 3) + 5) / 6; - String destString (size); // store the length, followed by a '.', and then the data. + String destString ((unsigned int) size); // store the length, followed by a '.', and then the data. const int initialLen = destString.length(); destString.preallocateStorage (initialLen + 2 + numChars); tchar* d = const_cast (((const tchar*) destString) + initialLen); *d++ = T('.'); - for (int i = 0; i < numChars; ++i) + for (size_t i = 0; i < numChars; ++i) *d++ = encodingTable [getBitRange (i * 6, 6)]; *d++ = 0; diff --git a/src/containers/juce_MemoryBlock.h b/src/containers/juce_MemoryBlock.h index 8614fe1801..7e8f0f5250 100644 --- a/src/containers/juce_MemoryBlock.h +++ b/src/containers/juce_MemoryBlock.h @@ -47,7 +47,7 @@ public: @param initialSize the size of block to create @param initialiseToZero whether to clear the memory or just leave it uninitialised */ - MemoryBlock (const int initialSize, + MemoryBlock (const size_t initialSize, const bool initialiseToZero = false) throw(); /** Creates a copy of another memory block. */ @@ -59,7 +59,7 @@ public: @param sizeInBytes how much space to use */ MemoryBlock (const void* const dataToInitialiseFrom, - const int sizeInBytes) throw(); + const size_t sizeInBytes) throw(); /** Destructor. */ ~MemoryBlock() throw(); @@ -103,12 +103,13 @@ public: This returns a reference, so you can also use it to set a byte. */ - char& operator[] (const int offset) const throw() { return data [offset]; } + template + char& operator[] (const Type offset) const throw() { return data [offset]; } //============================================================================== /** Returns the block's current allocated size, in bytes. */ - int getSize() const throw() { return size; } + size_t getSize() const throw() { return size; } /** Resizes the memory block. @@ -122,7 +123,7 @@ public: uninitialised @see ensureSize */ - void setSize (const int newSize, + void setSize (const size_t newSize, const bool initialiseNewSpaceToZero = false) throw(); /** Increases the block's size only if it's smaller than a given size. @@ -134,7 +135,7 @@ public: uninitialised @see setSize */ - void ensureSize (const int minimumSize, + void ensureSize (const size_t minimumSize, const bool initialiseNewSpaceToZero = false) throw(); //============================================================================== @@ -149,7 +150,7 @@ public: This block's size will be increased accordingly. */ void append (const void* const data, - const int numBytes) throw(); + const size_t numBytes) throw(); /** Exchanges the contents of this and another memory block. No actual copying is required for this, so it's very fast. @@ -166,7 +167,7 @@ public: */ void copyFrom (const void* srcData, int destinationOffset, - int numBytes) throw(); + size_t numBytes) throw(); /** Copies data from this MemoryBlock to a memory address. @@ -177,7 +178,7 @@ public: */ void copyTo (void* destData, int sourceOffset, - int numBytes) const throw(); + size_t numBytes) const throw(); /** Chops out a section of the block. @@ -186,7 +187,7 @@ public: If the range specified goes beyond the size of the block, it will be clipped. */ - void removeSection (int startByte, int numBytesToRemove) throw(); + void removeSection (size_t startByte, size_t numBytesToRemove) throw(); //============================================================================== /** Attempts to parse the contents of the block as a zero-terminated string of 8-bit @@ -205,13 +206,13 @@ public: //============================================================================== /** Sets a number of bits in the memory block, treating it as a long binary sequence. */ - void setBitRange (int bitRangeStart, - int numBits, + void setBitRange (size_t bitRangeStart, + size_t numBits, int binaryNumberToApply) throw(); /** Reads a number of bits from the memory block, treating it as one long binary sequence */ - int getBitRange (int bitRangeStart, - int numBitsToRead) const throw(); + int getBitRange (size_t bitRangeStart, + size_t numBitsToRead) const throw(); //============================================================================== /** Returns a string of characters that represent the binary contents of this block. @@ -239,7 +240,7 @@ public: private: //============================================================================== HeapBlock data; - int size; + size_t size; }; diff --git a/src/containers/juce_Variant.cpp b/src/containers/juce_Variant.cpp index 235392fc9f..a288238880 100644 --- a/src/containers/juce_Variant.cpp +++ b/src/containers/juce_Variant.cpp @@ -378,7 +378,7 @@ const var var::readFromStream (InputStream& input) throw() { MemoryBlock mb; input.readIntoMemoryBlock (mb, numBytes - 1); - return var (String::fromUTF8 ((const uint8*) mb.getData(), mb.getSize())); + return var (String::fromUTF8 ((const uint8*) mb.getData(), (int) mb.getSize())); } default: input.skipNextBytes (numBytes - 1); break; diff --git a/src/core/juce_MathsFunctions.h b/src/core/juce_MathsFunctions.h index 5fdb718ddf..4118f21a4d 100644 --- a/src/core/juce_MathsFunctions.h +++ b/src/core/juce_MathsFunctions.h @@ -99,58 +99,28 @@ typedef wchar_t juce_wchar; // Some indispensible min/max functions /** Returns the larger of two values. */ -forcedinline int jmax (const int a, const int b) throw() { return (a < b) ? b : a; } -/** Returns the larger of two values. */ -forcedinline int64 jmax (const int64 a, const int64 b) throw() { return (a < b) ? b : a; } -/** Returns the larger of two values. */ -forcedinline float jmax (const float a, const float b) throw() { return (a < b) ? b : a; } -/** Returns the larger of two values. */ -forcedinline double jmax (const double a, const double b) throw() { return (a < b) ? b : a; } +template +inline Type jmax (const Type a, const Type b) { return (a < b) ? b : a; } /** Returns the larger of three values. */ -inline int jmax (const int a, const int b, const int c) throw() { return (a < b) ? ((b < c) ? c : b) : ((a < c) ? c : a); } -/** Returns the larger of three values. */ -inline int64 jmax (const int64 a, const int64 b, const int64 c) throw() { return (a < b) ? ((b < c) ? c : b) : ((a < c) ? c : a); } -/** Returns the larger of three values. */ -inline float jmax (const float a, const float b, const float c) throw() { return (a < b) ? ((b < c) ? c : b) : ((a < c) ? c : a); } -/** Returns the larger of three values. */ -inline double jmax (const double a, const double b, const double c) throw() { return (a < b) ? ((b < c) ? c : b) : ((a < c) ? c : a); } +template +inline Type jmax (const Type a, const Type b, const Type c) { return (a < b) ? ((b < c) ? c : b) : ((a < c) ? c : a); } /** Returns the larger of four values. */ -inline int jmax (const int a, const int b, const int c, const int d) throw() { return jmax (a, jmax (b, c, d)); } -/** Returns the larger of four values. */ -inline int64 jmax (const int64 a, const int64 b, const int64 c, const int64 d) throw() { return jmax (a, jmax (b, c, d)); } -/** Returns the larger of four values. */ -inline float jmax (const float a, const float b, const float c, const float d) throw() { return jmax (a, jmax (b, c, d)); } -/** Returns the larger of four values. */ -inline double jmax (const double a, const double b, const double c, const double d) throw() { return jmax (a, jmax (b, c, d)); } +template +inline Type jmax (const Type a, const Type b, const Type c, const Type d) { return jmax (a, jmax (b, c, d)); } /** Returns the smaller of two values. */ -inline int jmin (const int a, const int b) throw() { return (a > b) ? b : a; } -/** Returns the smaller of two values. */ -inline int64 jmin (const int64 a, const int64 b) throw() { return (a > b) ? b : a; } -/** Returns the smaller of two values. */ -inline float jmin (const float a, const float b) throw() { return (a > b) ? b : a; } -/** Returns the smaller of two values. */ -inline double jmin (const double a, const double b) throw() { return (a > b) ? b : a; } +template +inline Type jmin (const Type a, const Type b) { return (a > b) ? b : a; } /** Returns the smaller of three values. */ -inline int jmin (const int a, const int b, const int c) throw() { return (a > b) ? ((b > c) ? c : b) : ((a > c) ? c : a); } -/** Returns the smaller of three values. */ -inline int64 jmin (const int64 a, const int64 b, const int64 c) throw() { return (a > b) ? ((b > c) ? c : b) : ((a > c) ? c : a); } -/** Returns the smaller of three values. */ -inline float jmin (const float a, const float b, const float c) throw() { return (a > b) ? ((b > c) ? c : b) : ((a > c) ? c : a); } -/** Returns the smaller of three values. */ -inline double jmin (const double a, const double b, const double c) throw() { return (a > b) ? ((b > c) ? c : b) : ((a > c) ? c : a); } +template +inline Type jmin (const Type a, const Type b, const Type c) { return (a > b) ? ((b > c) ? c : b) : ((a > c) ? c : a); } /** Returns the smaller of four values. */ -inline int jmin (const int a, const int b, const int c, const int d) throw() { return jmin (a, jmin (b, c, d)); } -/** Returns the smaller of four values. */ -inline int64 jmin (const int64 a, const int64 b, const int64 c, const int64 d) throw() { return jmin (a, jmin (b, c, d)); } -/** Returns the smaller of four values. */ -inline float jmin (const float a, const float b, const float c, const float d) throw() { return jmin (a, jmin (b, c, d)); } -/** Returns the smaller of four values. */ -inline double jmin (const double a, const double b, const double c, const double d) throw() { return jmin (a, jmin (b, c, d)); } +template +inline Type jmin (const Type a, const Type b, const Type c, const Type d) { return jmin (a, jmin (b, c, d)); } //============================================================================== @@ -268,19 +238,19 @@ inline bool juce_isfinite (FloatingPointType value) //============================================================================== /** Fast floating-point-to-integer conversion. - This is faster than using the normal c++ cast to convert a double to an int, and + This is faster than using the normal c++ cast to convert a float to an int, and it will round the value to the nearest integer, rather than rounding it down like the normal cast does. Note that this routine gets its speed at the expense of some accuracy, and when rounding values whose floating point component is exactly 0.5, odd numbers and - even numbers will be rounded up or down differently. For a more accurate conversion, - see roundDoubleToIntAccurate(). + even numbers will be rounded up or down differently. */ -inline int roundDoubleToInt (const double value) throw() +template +inline int roundToInt (const FloatType value) throw() { union { int asInt[2]; double asDouble; } n; - n.asDouble = value + 6755399441055744.0; + n.asDouble = ((double) value) + 6755399441055744.0; #if JUCE_BIG_ENDIAN return n.asInt [1]; @@ -294,9 +264,25 @@ inline int roundDoubleToInt (const double value) throw() This is a slightly slower and slightly more accurate version of roundDoubleToInt(). It works fine for values above zero, but negative numbers are rounded the wrong way. */ -inline int roundDoubleToIntAccurate (const double value) throw() +inline int roundToIntAccurate (const double value) throw() { - return roundDoubleToInt (value + 1.5e-8); + return roundToInt (value + 1.5e-8); +} + +/** Fast floating-point-to-integer conversion. + + This is faster than using the normal c++ cast to convert a double to an int, and + it will round the value to the nearest integer, rather than rounding it down + like the normal cast does. + + Note that this routine gets its speed at the expense of some accuracy, and when + rounding values whose floating point component is exactly 0.5, odd numbers and + even numbers will be rounded up or down differently. For a more accurate conversion, + see roundDoubleToIntAccurate(). +*/ +inline int roundDoubleToInt (const double value) throw() +{ + return roundToInt (value); } /** Fast floating-point-to-integer conversion. @@ -311,16 +297,10 @@ inline int roundDoubleToIntAccurate (const double value) throw() */ inline int roundFloatToInt (const float value) throw() { - union { int asInt[2]; double asDouble; } n; - n.asDouble = value + 6755399441055744.0; - - #if JUCE_BIG_ENDIAN - return n.asInt [1]; - #else - return n.asInt [0]; - #endif + return roundToInt (value); } + //============================================================================== #endif // __JUCE_MATHSFUNCTIONS_JUCEHEADER__ diff --git a/src/core/juce_Memory.h b/src/core/juce_Memory.h index 3229feea1b..f853377bca 100644 --- a/src/core/juce_Memory.h +++ b/src/core/juce_Memory.h @@ -200,7 +200,7 @@ //============================================================================== /** Clears a block of memory. */ -inline void zeromem (void* memory, int numBytes) { memset (memory, 0, numBytes); } +inline void zeromem (void* memory, size_t numBytes) { memset (memory, 0, numBytes); } /** Clears a reference to a local structure. */ template diff --git a/src/cryptography/juce_MD5.cpp b/src/cryptography/juce_MD5.cpp index 8844497109..b722300a51 100644 --- a/src/cryptography/juce_MD5.cpp +++ b/src/cryptography/juce_MD5.cpp @@ -58,7 +58,7 @@ MD5::MD5 (const MemoryBlock& data) context.finish (result); } -MD5::MD5 (const char* data, const int numBytes) +MD5::MD5 (const char* data, const size_t numBytes) { ProcessContext context; context.processBlock ((const uint8*) data, numBytes); @@ -86,7 +86,7 @@ MD5::MD5 (const String& text) context.finish (result); } -void MD5::processStream (InputStream& input, int numBytesToRead) +void MD5::processStream (InputStream& input, int64 numBytesToRead) { ProcessContext context; @@ -96,7 +96,7 @@ void MD5::processStream (InputStream& input, int numBytesToRead) while (numBytesToRead > 0) { char tempBuffer [512]; - const int bytesRead = input.read (tempBuffer, jmin (numBytesToRead, sizeof (tempBuffer))); + const int bytesRead = input.read (tempBuffer, (int) jmin ((size_t) numBytesToRead, sizeof (tempBuffer))); if (bytesRead <= 0) break; @@ -109,7 +109,7 @@ void MD5::processStream (InputStream& input, int numBytesToRead) context.finish (result); } -MD5::MD5 (InputStream& input, int numBytesToRead) +MD5::MD5 (InputStream& input, int64 numBytesToRead) { processStream (input, numBytesToRead); } @@ -140,20 +140,20 @@ MD5::ProcessContext::ProcessContext() count[1] = 0; } -void MD5::ProcessContext::processBlock (const uint8* const data, int dataSize) +void MD5::ProcessContext::processBlock (const uint8* const data, size_t dataSize) { int bufferPos = ((count[0] >> 3) & 0x3F); - count[0] += (dataSize << 3); + count[0] += (uint32) (dataSize << 3); if (count[0] < ((uint32) dataSize << 3)) count[1]++; - count[1] += (dataSize >> 29); + count[1] += (uint32) (dataSize >> 29); - const int spaceLeft = 64 - bufferPos; + const size_t spaceLeft = 64 - bufferPos; - int i = 0; + size_t i = 0; if (dataSize >= spaceLeft) { diff --git a/src/cryptography/juce_MD5.h b/src/cryptography/juce_MD5.h index f15dfe7090..c4220eefc0 100644 --- a/src/cryptography/juce_MD5.h +++ b/src/cryptography/juce_MD5.h @@ -58,7 +58,7 @@ public: MD5 (const MemoryBlock& data); /** Creates a checksum for a block of binary data. */ - MD5 (const char* data, const int numBytes); + MD5 (const char* data, const size_t numBytes); /** Creates a checksum for a string. @@ -76,7 +76,7 @@ public: checksum of that. If the number of bytes to read is negative, it'll read until the stream is exhausted. */ - MD5 (InputStream& input, int numBytesToRead = -1); + MD5 (InputStream& input, int64 numBytesToRead = -1); /** Creates a checksum for a file. */ MD5 (const File& file); @@ -114,12 +114,12 @@ private: ProcessContext(); - void processBlock (const uint8* const data, int dataSize); + void processBlock (const uint8* const data, size_t dataSize); void transform (const uint8* const buffer); void finish (uint8* const result); }; - void processStream (InputStream& input, int numBytesToRead); + void processStream (InputStream& input, int64 numBytesToRead); }; diff --git a/src/events/juce_InterprocessConnection.cpp b/src/events/juce_InterprocessConnection.cpp index 5dc12e09d8..03f139ed8b 100644 --- a/src/events/juce_InterprocessConnection.cpp +++ b/src/events/juce_InterprocessConnection.cpp @@ -168,17 +168,17 @@ bool InterprocessConnection::sendMessage (const MemoryBlock& message) messageData.copyFrom (messageHeader, 0, sizeof (messageHeader)); messageData.copyFrom (message.getData(), sizeof (messageHeader), message.getSize()); - int bytesWritten = 0; + size_t bytesWritten = 0; const ScopedLock sl (pipeAndSocketLock); if (socket != 0) { - bytesWritten = socket->write (messageData.getData(), messageData.getSize()); + bytesWritten = socket->write (messageData.getData(), (int) messageData.getSize()); } else if (pipe != 0) { - bytesWritten = pipe->write (messageData.getData(), messageData.getSize()); + bytesWritten = pipe->write (messageData.getData(), (int) messageData.getSize()); } if (bytesWritten < 0) diff --git a/src/gui/components/buttons/juce_Button.cpp b/src/gui/components/buttons/juce_Button.cpp index dac4825b15..89de492769 100644 --- a/src/gui/components/buttons/juce_Button.cpp +++ b/src/gui/components/buttons/juce_Button.cpp @@ -680,7 +680,7 @@ void Button::repeatTimerCallback() throw() const uint32 now = Time::getApproximateMillisecondCounter(); const int numTimesToCallback - = (now > lastTimeCallbackTime) ? jmax (1, (now - lastTimeCallbackTime) / repeatSpeed) : 1; + = (now > lastTimeCallbackTime) ? jmax ((uint32) 1, (now - lastTimeCallbackTime) / repeatSpeed) : 1; lastTimeCallbackTime = now; diff --git a/src/gui/components/buttons/juce_ImageButton.cpp b/src/gui/components/buttons/juce_ImageButton.cpp index 128dbe15b9..c0abca17ef 100644 --- a/src/gui/components/buttons/juce_ImageButton.cpp +++ b/src/gui/components/buttons/juce_ImageButton.cpp @@ -98,7 +98,7 @@ void ImageButton::setImages (const bool resizeButtonNowToFitThisImage, downOpacity = imageOpacityWhenDown; downOverlay = overlayColourWhenDown; - alphaThreshold = (unsigned char) jlimit (0, 0xff, roundFloatToInt (255.0f * hitTestAlphaThreshold)); + alphaThreshold = (unsigned char) jlimit (0, 0xff, roundToInt (255.0f * hitTestAlphaThreshold)); repaint(); } @@ -162,13 +162,13 @@ void ImageButton::paintButton (Graphics& g, if (imRatio > destRatio) { - newW = roundFloatToInt (imageH / imRatio); + newW = roundToInt (imageH / imRatio); newH = imageH; } else { newW = imageW; - newH = roundFloatToInt (imageW * imRatio); + newH = roundToInt (imageW * imRatio); } imageX = (imageW - newW) / 2; diff --git a/src/gui/components/code_editor/juce_CodeEditorComponent.cpp b/src/gui/components/code_editor/juce_CodeEditorComponent.cpp index 038d01b034..371e7a41ae 100644 --- a/src/gui/components/code_editor/juce_CodeEditorComponent.cpp +++ b/src/gui/components/code_editor/juce_CodeEditorComponent.cpp @@ -151,8 +151,8 @@ public: if (highlightColumnStart < highlightColumnEnd) { g.setColour (highlightColour); - g.fillRect (roundFloatToInt (x + highlightColumnStart * owner.getCharWidth()), y, - roundFloatToInt ((highlightColumnEnd - highlightColumnStart) * owner.getCharWidth()), lineHeight); + g.fillRect (roundToInt (x + highlightColumnStart * owner.getCharWidth()), y, + roundToInt ((highlightColumnEnd - highlightColumnStart) * owner.getCharWidth()), lineHeight); } int lastType = INT_MIN; @@ -167,7 +167,7 @@ public: g.setColour (owner.getColourForTokenType (lastType)); } - g.drawSingleLineText (token->text, roundFloatToInt (x), y + baselineOffset); + g.drawSingleLineText (token->text, roundToInt (x), y + baselineOffset); if (i < tokens.size() - 1) { @@ -590,16 +590,16 @@ void CodeEditorComponent::scrollToKeepCaretOnScreen() const Rectangle CodeEditorComponent::getCharacterBounds (const CodeDocument::Position& pos) const throw() { - return Rectangle (roundDoubleToInt ((gutter - xOffset * charWidth) + indexToColumn (pos.getLineNumber(), pos.getIndexInLine()) * charWidth), + return Rectangle (roundToInt ((gutter - xOffset * charWidth) + indexToColumn (pos.getLineNumber(), pos.getIndexInLine()) * charWidth), (pos.getLineNumber() - firstLineOnScreen) * lineHeight, - roundFloatToInt (charWidth), + roundToInt (charWidth), lineHeight); } const CodeDocument::Position CodeEditorComponent::getPositionAt (int x, int y) { const int line = y / lineHeight + firstLineOnScreen; - const int column = roundDoubleToInt ((x - (gutter - xOffset * charWidth)) / charWidth); + const int column = roundToInt ((x - (gutter - xOffset * charWidth)) / charWidth); const int index = columnToIndex (line, column); return CodeDocument::Position (&document, line, index); @@ -1095,7 +1095,7 @@ void CodeEditorComponent::setFont (const Font& newFont) { font = newFont; charWidth = font.getStringWidthFloat (T("0")); - lineHeight = roundFloatToInt (font.getHeight()); + lineHeight = roundToInt (font.getHeight()); resized(); } diff --git a/src/gui/components/controls/juce_ListBox.cpp b/src/gui/components/controls/juce_ListBox.cpp index 6fa357ab11..ecb705f30a 100644 --- a/src/gui/components/controls/juce_ListBox.cpp +++ b/src/gui/components/controls/juce_ListBox.cpp @@ -672,7 +672,7 @@ void ListBox::setVerticalPosition (const double proportion) const int offscreen = viewport->getViewedComponent()->getHeight() - viewport->getHeight(); viewport->setViewPosition (viewport->getViewPositionX(), - jmax (0, roundDoubleToInt (proportion * offscreen))); + jmax (0, roundToInt (proportion * offscreen))); } double ListBox::getVerticalPosition() const diff --git a/src/gui/components/controls/juce_ProgressBar.cpp b/src/gui/components/controls/juce_ProgressBar.cpp index b1716baea4..09804e2836 100644 --- a/src/gui/components/controls/juce_ProgressBar.cpp +++ b/src/gui/components/controls/juce_ProgressBar.cpp @@ -74,7 +74,7 @@ void ProgressBar::paint (Graphics& g) if (displayPercentage) { if (currentValue >= 0 && currentValue <= 1.0) - text << roundDoubleToInt (currentValue * 100.0) << T("%"); + text << roundToInt (currentValue * 100.0) << T("%"); } else { diff --git a/src/gui/components/controls/juce_Slider.cpp b/src/gui/components/controls/juce_Slider.cpp index fbfe8f1caa..40e6cd5fa6 100644 --- a/src/gui/components/controls/juce_Slider.cpp +++ b/src/gui/components/controls/juce_Slider.cpp @@ -641,7 +641,7 @@ const String Slider::getTextFromValue (double v) if (numDecimalPlaces > 0) return String (v, numDecimalPlaces) + textSuffix; else - return String (roundDoubleToInt (v)) + textSuffix; + return String (roundToInt (v)) + textSuffix; } double Slider::getValueFromText (const String& text) @@ -1157,14 +1157,14 @@ void Slider::restoreMouseIfHidden() if (style == RotaryHorizontalDrag) { const double posDiff = valueToProportionOfLength (pos) - valueToProportionOfLength (valueOnMouseDown); - x = roundDoubleToInt (pixelsForFullDragExtent * posDiff + downX); + x = roundToInt (pixelsForFullDragExtent * posDiff + downX); y = downY; } else { const double posDiff = valueToProportionOfLength (valueOnMouseDown) - valueToProportionOfLength (pos); x = downX; - y = roundDoubleToInt (pixelsForFullDragExtent * posDiff + downY); + y = roundToInt (pixelsForFullDragExtent * posDiff + downY); } Desktop::setMousePosition (x, y); diff --git a/src/gui/components/controls/juce_TextEditor.cpp b/src/gui/components/controls/juce_TextEditor.cpp index 1c6c95da6e..3aafdf85ae 100644 --- a/src/gui/components/controls/juce_TextEditor.cpp +++ b/src/gui/components/controls/juce_TextEditor.cpp @@ -228,7 +228,7 @@ public: break; const int start = jmax (0, startCharacter - index); - const int end = jmin (endCharacter - index, atom->numChars); + const int end = jmin (endCharacter - index, (int) atom->numChars); if (start < end) concatenator.append (atom->atomText.substring (start, end)); @@ -603,7 +603,7 @@ public: ga.addLineOfText (currentSection->font, atom->getTrimmedText (passwordCharacter), atomX, - (float) roundFloatToInt (lineY + lineHeight - maxDescent)); + (float) roundToInt (lineY + lineHeight - maxDescent)); ga.draw (g); } } @@ -612,11 +612,11 @@ public: const int selectionStart, const int selectionEnd) const { - const int startX = roundFloatToInt (indexToX (selectionStart)); - const int endX = roundFloatToInt (indexToX (selectionEnd)); + const int startX = roundToInt (indexToX (selectionStart)); + const int endX = roundToInt (indexToX (selectionEnd)); - const int y = roundFloatToInt (lineY); - const int nextY = roundFloatToInt (lineY + lineHeight); + const int y = roundToInt (lineY); + const int nextY = roundToInt (lineY + lineHeight); g.fillRect (startX, y, endX - startX, nextY - y); } @@ -632,7 +632,7 @@ public: ga.addLineOfText (currentSection->font, atom->getTrimmedText (passwordCharacter), atomX, - (float) roundFloatToInt (lineY + lineHeight - maxDescent)); + (float) roundToInt (lineY + lineHeight - maxDescent)); if (selectionEnd < indexInText + atom->numChars) { @@ -1299,10 +1299,10 @@ void TextEditor::timerCallbackInt() void TextEditor::repaintCaret() { if (! findColour (caretColourId).isTransparent()) - repaint (borderSize.getLeft() + textHolder->getX() + leftIndent + roundFloatToInt (cursorX) - 1, - borderSize.getTop() + textHolder->getY() + topIndent + roundFloatToInt (cursorY) - 1, + repaint (borderSize.getLeft() + textHolder->getX() + leftIndent + roundToInt (cursorX) - 1, + borderSize.getTop() + textHolder->getY() + topIndent + roundToInt (cursorY) - 1, 4, - roundFloatToInt (cursorHeight) + 2); + roundToInt (cursorHeight) + 2); } void TextEditor::repaintText (int textStartIndex, int textEndIndex) @@ -1372,8 +1372,8 @@ void TextEditor::scrollEditorToPositionCaret (const int desiredCaretX, { updateCaretPosition(); - int vx = roundFloatToInt (cursorX) - desiredCaretX; - int vy = roundFloatToInt (cursorY) - desiredCaretY; + int vx = roundToInt (cursorX) - desiredCaretX; + int vy = roundToInt (cursorY) - desiredCaretY; if (desiredCaretX < jmax (1, proportionOfWidth (0.05f))) { @@ -1394,7 +1394,7 @@ void TextEditor::scrollEditorToPositionCaret (const int desiredCaretX, { vy = jlimit (0, jmax (0, textHolder->getHeight() - viewport->getMaximumVisibleHeight()), vy); - const int curH = roundFloatToInt (cursorHeight); + const int curH = roundToInt (cursorHeight); if (desiredCaretY < 0) { @@ -1413,9 +1413,9 @@ const Rectangle TextEditor::getCaretRectangle() { updateCaretPosition(); - return Rectangle (roundFloatToInt (cursorX) - viewport->getX(), - roundFloatToInt (cursorY) - viewport->getY(), - 1, roundFloatToInt (cursorHeight)); + return Rectangle (roundToInt (cursorX) - viewport->getX(), + roundToInt (cursorY) - viewport->getY(), + 1, roundToInt (cursorHeight)); } //============================================================================== @@ -1438,9 +1438,9 @@ void TextEditor::updateTextHolderSize() while (i.next()) maxWidth = jmax (maxWidth, i.atomRight); - const int w = leftIndent + roundFloatToInt (maxWidth); - const int h = topIndent + roundFloatToInt (jmax (i.lineY + i.lineHeight, - currentFont.getHeight())); + const int w = leftIndent + roundToInt (maxWidth); + const int h = topIndent + roundToInt (jmax (i.lineY + i.lineHeight, + currentFont.getHeight())); textHolder->setSize (w + 1, h + 1); } @@ -1494,8 +1494,8 @@ void TextEditor::scrollToMakeSureCursorIsVisible() int x = viewport->getViewPositionX(); int y = viewport->getViewPositionY(); - const int relativeCursorX = roundFloatToInt (cursorX) - x; - const int relativeCursorY = roundFloatToInt (cursorY) - y; + const int relativeCursorX = roundToInt (cursorX) - x; + const int relativeCursorY = roundToInt (cursorY) - y; if (relativeCursorX < jmax (1, proportionOfWidth (0.05f))) { @@ -1514,7 +1514,7 @@ void TextEditor::scrollToMakeSureCursorIsVisible() } else { - const int curH = roundFloatToInt (cursorHeight); + const int curH = roundToInt (cursorHeight); if (relativeCursorY < 0) { @@ -2165,7 +2165,7 @@ void TextEditor::focusLost (FocusChangeType) void TextEditor::resized() { viewport->setBoundsInset (borderSize); - viewport->setSingleStepSizes (16, roundFloatToInt (currentFont.getHeight())); + viewport->setSingleStepSizes (16, roundToInt (currentFont.getHeight())); updateTextHolderSize(); diff --git a/src/gui/components/controls/juce_Toolbar.cpp b/src/gui/components/controls/juce_Toolbar.cpp index b954057172..b397fcb94f 100644 --- a/src/gui/components/controls/juce_Toolbar.cpp +++ b/src/gui/components/controls/juce_Toolbar.cpp @@ -68,7 +68,7 @@ public: } else { - maxSize = roundFloatToInt (toolbarThickness * fixedSize); + maxSize = roundToInt (toolbarThickness * fixedSize); minSize = drawBar ? maxSize : jmin (4, maxSize); preferredSize = maxSize; diff --git a/src/gui/components/filebrowser/juce_FileChooserDialogBox.cpp b/src/gui/components/filebrowser/juce_FileChooserDialogBox.cpp index 849a15881f..d78c4c1f48 100644 --- a/src/gui/components/filebrowser/juce_FileChooserDialogBox.cpp +++ b/src/gui/components/filebrowser/juce_FileChooserDialogBox.cpp @@ -167,7 +167,7 @@ void FileChooserDialogBox::ContentComponent::resized() float left, top, right, bottom; text.getBoundingBox (0, text.getNumGlyphs(), left, top, right, bottom, false); - const int y = roundFloatToInt (bottom) + 10; + const int y = roundToInt (bottom) + 10; const int buttonHeight = 26; const int buttonY = getHeight() - buttonHeight - 8; diff --git a/src/gui/components/filebrowser/juce_ImagePreviewComponent.cpp b/src/gui/components/filebrowser/juce_ImagePreviewComponent.cpp index e91633d554..b745d36208 100644 --- a/src/gui/components/filebrowser/juce_ImagePreviewComponent.cpp +++ b/src/gui/components/filebrowser/juce_ImagePreviewComponent.cpp @@ -51,8 +51,8 @@ void ImagePreviewComponent::getThumbSize (int& w, int& h) const availableW / (double) w, availableH / (double) h); - w = roundDoubleToInt (scale * w); - h = roundDoubleToInt (scale * h); + w = roundToInt (scale * w); + h = roundToInt (scale * h); } void ImagePreviewComponent::selectedFileChanged (const File& file) diff --git a/src/gui/components/juce_Component.cpp b/src/gui/components/juce_Component.cpp index 158f60529f..f56dd27f78 100644 --- a/src/gui/components/juce_Component.cpp +++ b/src/gui/components/juce_Component.cpp @@ -361,11 +361,11 @@ public: centreY += yChangePerMs * msPassed; scale += scaleChangePerMs * msPassed; - const int w = roundFloatToInt (image->getWidth() * scale); - const int h = roundFloatToInt (image->getHeight() * scale); + const int w = roundToInt (image->getWidth() * scale); + const int h = roundToInt (image->getHeight() * scale); - setBounds (roundFloatToInt (centreX) - w / 2, - roundFloatToInt (centreY) - h / 2, + setBounds (roundToInt (centreX) - w / 2, + roundToInt (centreY) - h / 2, w, h); } @@ -763,12 +763,12 @@ bool Component::isAlwaysOnTop() const throw() //============================================================================== int Component::proportionOfWidth (const float proportion) const throw() { - return roundDoubleToInt (proportion * bounds_.getWidth()); + return roundToInt (proportion * bounds_.getWidth()); } int Component::proportionOfHeight (const float proportion) const throw() { - return roundDoubleToInt (proportion * bounds_.getHeight()); + return roundToInt (proportion * bounds_.getHeight()); } int Component::getParentWidth() const throw() @@ -984,10 +984,10 @@ void Component::setBoundsRelative (const float x, const float y, const int pw = getParentWidth(); const int ph = getParentHeight(); - setBounds (roundFloatToInt (x * pw), - roundFloatToInt (y * ph), - roundFloatToInt (w * pw), - roundFloatToInt (h * ph)); + setBounds (roundToInt (x * pw), + roundToInt (y * ph), + roundToInt (w * pw), + roundToInt (h * ph)); } void Component::setCentrePosition (const int x, const int y) @@ -998,8 +998,8 @@ void Component::setCentrePosition (const int x, const int y) void Component::setCentreRelative (const float x, const float y) { - setCentrePosition (roundFloatToInt (getParentWidth() * x), - roundFloatToInt (getParentHeight() * y)); + setCentrePosition (roundToInt (getParentWidth() * x), + roundToInt (getParentHeight() * y)); } void Component::centreWithSize (const int width, const int height) @@ -1044,12 +1044,12 @@ void Component::setBoundsToFit (int x, int y, int width, int height, if (imageRatio <= targetRatio) { newW = width; - newH = jmin (height, roundDoubleToInt (newW * imageRatio)); + newH = jmin (height, roundToInt (newW * imageRatio)); } else { newH = height; - newW = jmin (width, roundDoubleToInt (newH / imageRatio)); + newW = jmin (width, roundToInt (newH / imageRatio)); } } diff --git a/src/gui/components/juce_Component.h b/src/gui/components/juce_Component.h index 2aa1f71efb..f8fdea5262 100644 --- a/src/gui/components/juce_Component.h +++ b/src/gui/components/juce_Component.h @@ -2014,7 +2014,7 @@ private: Component* parentComponent_; uint32 componentUID; Rectangle bounds_; - unsigned short numDeepMouseListeners; + int numDeepMouseListeners; Array childComponentList_; LookAndFeel* lookAndFeel_; MouseCursor cursor_; diff --git a/src/gui/components/layout/juce_ComponentAnimator.cpp b/src/gui/components/layout/juce_ComponentAnimator.cpp index 6b9f742057..9f43c883d3 100644 --- a/src/gui/components/layout/juce_ComponentAnimator.cpp +++ b/src/gui/components/layout/juce_ComponentAnimator.cpp @@ -68,10 +68,10 @@ struct AnimationTask if (delta < 1.0) { - const Rectangle newBounds (roundDoubleToInt (left), - roundDoubleToInt (top), - roundDoubleToInt (right - left), - roundDoubleToInt (bottom - top)); + const Rectangle newBounds (roundToInt (left), + roundToInt (top), + roundToInt (right - left), + roundToInt (bottom - top)); if (newBounds != destination) { diff --git a/src/gui/components/layout/juce_ComponentBoundsConstrainer.cpp b/src/gui/components/layout/juce_ComponentBoundsConstrainer.cpp index f86fabdecf..d8851d4f0c 100644 --- a/src/gui/components/layout/juce_ComponentBoundsConstrainer.cpp +++ b/src/gui/components/layout/juce_ComponentBoundsConstrainer.cpp @@ -259,22 +259,22 @@ void ComponentBoundsConstrainer::checkBounds (int& x, int& y, int& w, int& h, if (adjustWidth) { - w = roundDoubleToInt (h * aspectRatio); + w = roundToInt (h * aspectRatio); if (w > maxW || w < minW) { w = jlimit (minW, maxW, w); - h = roundDoubleToInt (w / aspectRatio); + h = roundToInt (w / aspectRatio); } } else { - h = roundDoubleToInt (w / aspectRatio); + h = roundToInt (w / aspectRatio); if (h > maxH || h < minH) { h = jlimit (minH, maxH, h); - w = roundDoubleToInt (h * aspectRatio); + w = roundToInt (h * aspectRatio); } } diff --git a/src/gui/components/layout/juce_ScrollBar.cpp b/src/gui/components/layout/juce_ScrollBar.cpp index bbd3a0480d..dd9a554bd0 100644 --- a/src/gui/components/layout/juce_ScrollBar.cpp +++ b/src/gui/components/layout/juce_ScrollBar.cpp @@ -213,8 +213,8 @@ void ScrollBar::handleAsyncUpdate() //============================================================================== void ScrollBar::updateThumbPosition() throw() { - int newThumbSize = roundDoubleToInt ((maximum > minimum) ? (rangeSize * thumbAreaSize) / (maximum - minimum) - : thumbAreaSize); + int newThumbSize = roundToInt ((maximum > minimum) ? (rangeSize * thumbAreaSize) / (maximum - minimum) + : thumbAreaSize); if (newThumbSize < getLookAndFeel().getMinimumScrollbarThumbSize (*this)) newThumbSize = jmin (getLookAndFeel().getMinimumScrollbarThumbSize (*this), thumbAreaSize - 1); @@ -225,8 +225,8 @@ void ScrollBar::updateThumbPosition() throw() int newThumbStart = thumbAreaStart; if (maximum - minimum > rangeSize) - newThumbStart += roundDoubleToInt (((rangeStart - minimum) * (thumbAreaSize - newThumbSize)) - / ((maximum - minimum) - rangeSize)); + newThumbStart += roundToInt (((rangeStart - minimum) * (thumbAreaSize - newThumbSize)) + / ((maximum - minimum) - rangeSize)); setVisible (alwaysVisible || (maximum - minimum > rangeSize && rangeSize > 0.0)); diff --git a/src/gui/components/layout/juce_StretchableLayoutManager.cpp b/src/gui/components/layout/juce_StretchableLayoutManager.cpp index baf3cd93f7..7566912614 100644 --- a/src/gui/components/layout/juce_StretchableLayoutManager.cpp +++ b/src/gui/components/layout/juce_StretchableLayoutManager.cpp @@ -275,7 +275,7 @@ int StretchableLayoutManager::fitComponentsIntoSpace (const int startIndex, const int bestSize = jlimit (layout->currentSize, jmax (layout->currentSize, sizeToRealSize (layout->maxSize, totalSize)), - roundDoubleToInt (sizeWanted * availableSpace / totalIdealSize)); + roundToInt (sizeWanted * availableSpace / totalIdealSize)); if (bestSize > layout->currentSize) ++numWantingMoreSpace; @@ -290,7 +290,7 @@ int StretchableLayoutManager::fitComponentsIntoSpace (const int startIndex, int bestSize = jlimit (layout->currentSize, jmax (layout->currentSize, sizeToRealSize (layout->maxSize, totalSize)), - roundDoubleToInt (sizeWanted * availableSpace / totalIdealSize)); + roundToInt (sizeWanted * availableSpace / totalIdealSize)); const int extraWanted = bestSize - layout->currentSize; @@ -362,7 +362,7 @@ int StretchableLayoutManager::sizeToRealSize (double size, int totalSpace) if (size < 0) size *= -totalSpace; - return roundDoubleToInt (size); + return roundToInt (size); } END_JUCE_NAMESPACE diff --git a/src/gui/components/layout/juce_TabbedButtonBar.cpp b/src/gui/components/layout/juce_TabbedButtonBar.cpp index 1d162ed8a1..d1fcf41bc5 100644 --- a/src/gui/components/layout/juce_TabbedButtonBar.cpp +++ b/src/gui/components/layout/juce_TabbedButtonBar.cpp @@ -458,7 +458,7 @@ void TabbedButtonBar::resized() if (tb != 0) { - const int bestLength = roundDoubleToInt (scale * tb->getBestTabLength (depth)); + const int bestLength = roundToInt (scale * tb->getBestTabLength (depth)); if (i < numVisibleButtons) { diff --git a/src/gui/components/layout/juce_Viewport.cpp b/src/gui/components/layout/juce_Viewport.cpp index 8830eb04f3..2dc2595636 100644 --- a/src/gui/components/layout/juce_Viewport.cpp +++ b/src/gui/components/layout/juce_Viewport.cpp @@ -120,8 +120,8 @@ void Viewport::setViewPositionProportionately (const double x, const double y) { if (contentComp != 0) - setViewPosition (jmax (0, roundDoubleToInt (x * (contentComp->getWidth() - getWidth()))), - jmax (0, roundDoubleToInt (y * (contentComp->getHeight() - getHeight())))); + setViewPosition (jmax (0, roundToInt (x * (contentComp->getWidth() - getWidth()))), + jmax (0, roundToInt (y * (contentComp->getHeight() - getHeight())))); } bool Viewport::autoScroll (int mouseX, int mouseY, int activeBorderThickness, int maximumSpeed) @@ -290,11 +290,11 @@ void Viewport::scrollBarMoved (ScrollBar* scrollBarThatHasMoved, const double ne { if (scrollBarThatHasMoved == horizontalScrollBar) { - setViewPosition (roundDoubleToInt (newRangeStart), getViewPositionY()); + setViewPosition (roundToInt (newRangeStart), getViewPositionY()); } else if (scrollBarThatHasMoved == verticalScrollBar) { - setViewPosition (getViewPositionX(), roundDoubleToInt (newRangeStart)); + setViewPosition (getViewPositionX(), roundToInt (newRangeStart)); } } diff --git a/src/gui/components/lookandfeel/juce_LookAndFeel.cpp b/src/gui/components/lookandfeel/juce_LookAndFeel.cpp index edd8fa34ec..e5ba925694 100644 --- a/src/gui/components/lookandfeel/juce_LookAndFeel.cpp +++ b/src/gui/components/lookandfeel/juce_LookAndFeel.cpp @@ -394,7 +394,7 @@ void LookAndFeel::drawButtonText (Graphics& g, TextButton& button, const int yIndent = jmin (4, button.proportionOfHeight (0.3f)); const int cornerSize = jmin (button.getHeight(), button.getWidth()) / 2; - const int fontHeight = roundFloatToInt (font.getHeight() * 0.6f); + const int fontHeight = roundToInt (font.getHeight() * 0.6f); const int leftIndent = jmin (fontHeight, 2 + cornerSize / (button.isConnectedOnLeft() ? 4 : 2)); const int rightIndent = jmin (fontHeight, 2 + cornerSize / (button.isConnectedOnRight() ? 4 : 2)); @@ -976,7 +976,7 @@ void LookAndFeel::getIdealPopupMenuItemSize (const String& text, if (standardMenuItemHeight > 0 && font.getHeight() > standardMenuItemHeight / 1.3f) font.setHeight (standardMenuItemHeight / 1.3f); - idealHeight = standardMenuItemHeight > 0 ? standardMenuItemHeight : roundFloatToInt (font.getHeight() * 1.3f); + idealHeight = standardMenuItemHeight > 0 ? standardMenuItemHeight : roundToInt (font.getHeight() * 1.3f); idealWidth = font.getStringWidth (text) + idealHeight * 2; } } @@ -2056,9 +2056,9 @@ void LookAndFeel::drawGroupComponentOutline (Graphics& g, int width, int height, .withMultipliedAlpha (alpha)); g.setFont (f); g.drawText (text, - roundFloatToInt (x + textX), 0, - roundFloatToInt (textW), - roundFloatToInt (textH), + roundToInt (x + textX), 0, + roundToInt (textW), + roundToInt (textH), Justification::centred, true); } @@ -2579,8 +2579,8 @@ void LookAndFeel::drawFileBrowserRow (Graphics& g, int width, int height, if (width > 450 && ! isDirectory) { - const int sizeX = roundFloatToInt (width * 0.7f); - const int dateX = roundFloatToInt (width * 0.8f); + const int sizeX = roundToInt (width * 0.7f); + const int dateX = roundToInt (width * 0.8f); g.drawFittedText (filename, x, 0, sizeX - x, height, @@ -2755,7 +2755,7 @@ void LookAndFeel::drawLevelMeter (Graphics& g, int width, int height, float leve g.drawRoundedRectangle (1.0f, 1.0f, width - 2.0f, height - 2.0f, 3.0f, 1.0f); const int totalBlocks = 7; - const int numBlocks = roundDoubleToInt (totalBlocks * level); + const int numBlocks = roundToInt (totalBlocks * level); const float w = (width - 6.0f) / (float) totalBlocks; for (int i = 0; i < totalBlocks; ++i) diff --git a/src/gui/components/lookandfeel/juce_OldSchoolLookAndFeel.cpp b/src/gui/components/lookandfeel/juce_OldSchoolLookAndFeel.cpp index beb0280650..8df85e7e4b 100644 --- a/src/gui/components/lookandfeel/juce_OldSchoolLookAndFeel.cpp +++ b/src/gui/components/lookandfeel/juce_OldSchoolLookAndFeel.cpp @@ -80,8 +80,8 @@ void OldSchoolLookAndFeel::drawButtonBackground (Graphics& g, const int height = button.getHeight(); const float indent = 2.0f; - const int cornerSize = jmin (roundFloatToInt (width * 0.4f), - roundFloatToInt (height * 0.4f)); + const int cornerSize = jmin (roundToInt (width * 0.4f), + roundToInt (height * 0.4f)); Path p; p.addRoundedRectangle (indent, indent, @@ -193,7 +193,7 @@ void OldSchoolLookAndFeel::drawProgressBar (Graphics& g, ProgressBar& progressBa g.setColour (foreground); g.fillRect (1, 1, - jlimit (0, width - 2, roundDoubleToInt (progress * (width - 2))), + jlimit (0, width - 2, roundToInt (progress * (width - 2))), height - 2); if (textToShow.isNotEmpty()) @@ -273,8 +273,8 @@ void OldSchoolLookAndFeel::drawScrollbar (Graphics& g, if (isScrollbarVertical) { width -= 2; - g.fillRect (x + roundFloatToInt (width * 0.35f), y, - roundFloatToInt (width * 0.3f), height); + g.fillRect (x + roundToInt (width * 0.35f), y, + roundToInt (width * 0.3f), height); thumb.setBounds (x + 1, thumbStartPosition, width - 2, thumbSize); @@ -282,8 +282,8 @@ void OldSchoolLookAndFeel::drawScrollbar (Graphics& g, else { height -= 2; - g.fillRect (x, y + roundFloatToInt (height * 0.35f), - width, roundFloatToInt (height * 0.3f)); + g.fillRect (x, y + roundToInt (height * 0.35f), + width, roundToInt (height * 0.3f)); thumb.setBounds (thumbStartPosition, y + 1, thumbSize, height - 2); @@ -434,13 +434,13 @@ void OldSchoolLookAndFeel::drawLinearSlider (Graphics& g, if (slider.isHorizontal()) { - g.fillRect (x, y + roundFloatToInt (h * 0.6f), - w, roundFloatToInt (h * 0.2f)); + g.fillRect (x, y + roundToInt (h * 0.6f), + w, roundToInt (h * 0.2f)); } else { - g.fillRect (x + roundFloatToInt (w * 0.5f - jmin (3.0f, w * 0.1f)), y, - jmin (4, roundFloatToInt (w * 0.2f)), h); + g.fillRect (x + roundToInt (w * 0.5f - jmin (3.0f, w * 0.1f)), y, + jmin (4, roundToInt (w * 0.2f)), h); } float alpha = 0.35f; diff --git a/src/gui/components/menus/juce_PopupMenu.cpp b/src/gui/components/menus/juce_PopupMenu.cpp index f754719a35..aa44b46bcc 100644 --- a/src/gui/components/menus/juce_PopupMenu.cpp +++ b/src/gui/components/menus/juce_PopupMenu.cpp @@ -505,7 +505,7 @@ public: void mouseWheelMove (const MouseEvent&, float /*amountX*/, float amountY) { - alterChildYPos (roundFloatToInt (-10.0f * amountY * scrollZone)); + alterChildYPos (roundToInt (-10.0f * amountY * scrollZone)); lastMouseX = -1; } diff --git a/src/gui/components/mouse/juce_DragAndDropContainer.cpp b/src/gui/components/mouse/juce_DragAndDropContainer.cpp index 6a156859bf..ab19f268db 100644 --- a/src/gui/components/mouse/juce_DragAndDropContainer.cpp +++ b/src/gui/components/mouse/juce_DragAndDropContainer.cpp @@ -389,7 +389,7 @@ void DragAndDropContainer::startDragging (const String& sourceDescription, for (int x = dragImage->getWidth(); --x >= 0;) { const int dx = x - cx; - const int distance = roundDoubleToInt (sqrt (dx * dx + dy)); + const int distance = roundToInt (sqrt (dx * dx + dy)); if (distance > lo) { diff --git a/src/gui/components/mouse/juce_MouseEvent.cpp b/src/gui/components/mouse/juce_MouseEvent.cpp index 86ba1b72d1..964a9ab092 100644 --- a/src/gui/components/mouse/juce_MouseEvent.cpp +++ b/src/gui/components/mouse/juce_MouseEvent.cpp @@ -88,8 +88,8 @@ int MouseEvent::getDistanceFromDragStartY() const throw() int MouseEvent::getDistanceFromDragStart() const throw() { - return roundDoubleToInt (juce_hypot (getDistanceFromDragStartX(), - getDistanceFromDragStartY())); + return roundToInt (juce_hypot (getDistanceFromDragStartX(), + getDistanceFromDragStartY())); } int MouseEvent::getLengthOfMousePress() const throw() diff --git a/src/gui/components/special/juce_AudioDeviceSelectorComponent.cpp b/src/gui/components/special/juce_AudioDeviceSelectorComponent.cpp index fdadf3e52c..d04d686193 100644 --- a/src/gui/components/special/juce_AudioDeviceSelectorComponent.cpp +++ b/src/gui/components/special/juce_AudioDeviceSelectorComponent.cpp @@ -555,11 +555,11 @@ public: for (int i = 0; i < numRates; ++i) { - const int rate = roundDoubleToInt (currentDevice->getSampleRate (i)); + const int rate = roundToInt (currentDevice->getSampleRate (i)); sampleRateDropDown->addItem (String (rate) + T(" Hz"), rate); } - sampleRateDropDown->setSelectedId (roundDoubleToInt (currentDevice->getCurrentSampleRate()), true); + sampleRateDropDown->setSelectedId (roundToInt (currentDevice->getCurrentSampleRate()), true); sampleRateDropDown->addListener (this); } diff --git a/src/gui/components/special/juce_ColourSelector.cpp b/src/gui/components/special/juce_ColourSelector.cpp index 556ec7d09c..d398789df8 100644 --- a/src/gui/components/special/juce_ColourSelector.cpp +++ b/src/gui/components/special/juce_ColourSelector.cpp @@ -185,8 +185,8 @@ private: void updateMarker() const throw() { - marker->setBounds (roundFloatToInt ((getWidth() - edge * 2) * s), - roundFloatToInt ((getHeight() - edge * 2) * (1.0f - v)), + marker->setBounds (roundToInt ((getWidth() - edge * 2) * s), + roundToInt ((getHeight() - edge * 2) * (1.0f - v)), edge * 2, edge * 2); } @@ -265,7 +265,7 @@ public: void resized() { - marker->setBounds (0, roundFloatToInt ((getHeight() - edge * 2) * h), + marker->setBounds (0, roundToInt ((getHeight() - edge * 2) * h), getWidth(), edge * 2); } diff --git a/src/gui/components/special/juce_DropShadower.cpp b/src/gui/components/special/juce_DropShadower.cpp index 17f1d3a4b6..7e7641df3a 100644 --- a/src/gui/components/special/juce_DropShadower.cpp +++ b/src/gui/components/special/juce_DropShadower.cpp @@ -251,7 +251,7 @@ void DropShadower::updateShadows() bigIm->getWidth() - (shadowEdge * 2), bigIm->getHeight() - (shadowEdge * 2)); - ImageConvolutionKernel blurKernel (roundFloatToInt (blurRadius * 2.0f)); + ImageConvolutionKernel blurKernel (roundToInt (blurRadius * 2.0f)); blurKernel.createGaussianBlur (blurRadius); blurKernel.applyToImage (*bigIm, 0, diff --git a/src/gui/components/special/juce_MagnifierComponent.cpp b/src/gui/components/special/juce_MagnifierComponent.cpp index 9e1829338a..ed93455b43 100644 --- a/src/gui/components/special/juce_MagnifierComponent.cpp +++ b/src/gui/components/special/juce_MagnifierComponent.cpp @@ -97,8 +97,8 @@ public: void relativePositionToGlobal (int& x, int& y) { const double zoom = magnifierComp->getScaleFactor(); - x = roundDoubleToInt (x * zoom); - y = roundDoubleToInt (y * zoom); + x = roundToInt (x * zoom); + y = roundToInt (y * zoom); magnifierComp->relativePositionToGlobal (x, y); } @@ -108,8 +108,8 @@ public: magnifierComp->globalPositionToRelative (x, y); const double zoom = magnifierComp->getScaleFactor(); - x = roundDoubleToInt (x / zoom); - y = roundDoubleToInt (y / zoom); + x = roundToInt (x / zoom); + y = roundToInt (y / zoom); } bool contains (int x, int y, bool) const @@ -124,8 +124,8 @@ public: magnifierComp->repaint ((int) (x * zoom), (int) (y * zoom), - roundDoubleToInt (w * zoom) + 1, - roundDoubleToInt (h * zoom) + 1); + roundToInt (w * zoom) + 1, + roundToInt (h * zoom) + 1); } void performAnyPendingRepaintsNow() @@ -256,8 +256,8 @@ void MagnifierComponent::paint (Graphics& g) const int srcX = (int) (r.getX() / scaleFactor); const int srcY = (int) (r.getY() / scaleFactor); - int srcW = roundDoubleToInt (r.getRight() / scaleFactor) - srcX; - int srcH = roundDoubleToInt (r.getBottom() / scaleFactor) - srcY; + int srcW = roundToInt (r.getRight() / scaleFactor) - srcX; + int srcH = roundToInt (r.getBottom() / scaleFactor) - srcY; if (scaleFactor >= 1.0) { @@ -282,8 +282,8 @@ void MagnifierComponent::paint (Graphics& g) void MagnifierComponent::childBoundsChanged (Component* c) { if (c != 0) - setSize (roundDoubleToInt (c->getWidth() * scaleFactor), - roundDoubleToInt (c->getHeight() * scaleFactor)); + setSize (roundToInt (c->getWidth() * scaleFactor), + roundToInt (c->getHeight() * scaleFactor)); } void MagnifierComponent::mouseDown (const MouseEvent& e) @@ -325,8 +325,8 @@ void MagnifierComponent::mouseExit (const MouseEvent& e) void MagnifierComponent::mouseWheelMove (const MouseEvent& e, float ix, float iy) { if (peer != 0) - peer->handleMouseWheel (roundFloatToInt (ix * 256.0f), - roundFloatToInt (iy * 256.0f), + peer->handleMouseWheel (roundToInt (ix * 256.0f), + roundToInt (iy * 256.0f), e.eventTime.toMilliseconds()); else Component::mouseWheelMove (e, ix, iy); @@ -334,7 +334,7 @@ void MagnifierComponent::mouseWheelMove (const MouseEvent& e, float ix, float iy int MagnifierComponent::scaleInt (const int n) const { - return roundDoubleToInt (n / scaleFactor); + return roundToInt (n / scaleFactor); } diff --git a/src/gui/components/special/juce_MidiKeyboardComponent.cpp b/src/gui/components/special/juce_MidiKeyboardComponent.cpp index 2c94aec0d7..9920647e61 100644 --- a/src/gui/components/special/juce_MidiKeyboardComponent.cpp +++ b/src/gui/components/special/juce_MidiKeyboardComponent.cpp @@ -227,8 +227,8 @@ void MidiKeyboardComponent::getKeyPosition (int midiNoteNumber, const float keyW const int octave = midiNoteNumber / 12; const int note = midiNoteNumber % 12; - x = roundFloatToInt (octave * 7.0f * keyWidth + notePos [note] * keyWidth); - w = roundFloatToInt (widths [note] * keyWidth); + x = roundToInt (octave * 7.0f * keyWidth + notePos [note] * keyWidth); + w = roundToInt (widths [note] * keyWidth); } void MidiKeyboardComponent::getKeyPos (int midiNoteNumber, int& x, int& w) const @@ -589,7 +589,7 @@ void MidiKeyboardComponent::resized() if (orientation != horizontalKeyboard) swapVariables (w, h); - blackNoteLength = roundFloatToInt (h * 0.7f); + blackNoteLength = roundToInt (h * 0.7f); int kx2, kw2; getKeyPos (rangeEnd, kx2, kw2); @@ -795,7 +795,7 @@ void MidiKeyboardComponent::mouseExit (const MouseEvent& e) void MidiKeyboardComponent::mouseWheelMove (const MouseEvent&, float ix, float iy) { - setLowestVisibleKey (getLowestVisibleKey() + roundFloatToInt ((ix != 0 ? ix : iy) * 5.0f)); + setLowestVisibleKey (getLowestVisibleKey() + roundToInt ((ix != 0 ? ix : iy) * 5.0f)); } void MidiKeyboardComponent::timerCallback() diff --git a/src/gui/graphics/colour/juce_Colour.cpp b/src/gui/graphics/colour/juce_Colour.cpp index 95968bada6..42d95b6d1a 100644 --- a/src/gui/graphics/colour/juce_Colour.cpp +++ b/src/gui/graphics/colour/juce_Colour.cpp @@ -33,7 +33,7 @@ BEGIN_JUCE_NAMESPACE //============================================================================== static forcedinline uint8 floatAlphaToInt (const float alpha) { - return (uint8) jlimit (0, 0xff, roundFloatToInt (alpha * 255.0f)); + return (uint8) jlimit (0, 0xff, roundToInt (alpha * 255.0f)); } static const float oneOver255 = 1.0f / 255.0f; @@ -124,7 +124,7 @@ static void convertHSBtoRGB (float h, float s, float v, { v = jlimit (0.0f, 1.0f, v); v *= 255.0f; - const uint8 intV = (uint8) roundFloatToInt (v); + const uint8 intV = (uint8) roundToInt (v); if (s <= 0) { @@ -139,19 +139,19 @@ static void convertHSBtoRGB (float h, float s, float v, h = (h - floorf (h)) * 6.0f + 0.00001f; // need a small adjustment to compensate for rounding errors const float f = h - floorf (h); - const uint8 x = (uint8) roundFloatToInt (v * (1.0f - s)); + const uint8 x = (uint8) roundToInt (v * (1.0f - s)); const float y = v * (1.0f - s * f); const float z = v * (1.0f - (s * (1.0f - f))); if (h < 1.0f) { r = intV; - g = (uint8) roundFloatToInt (z); + g = (uint8) roundToInt (z); b = x; } else if (h < 2.0f) { - r = (uint8) roundFloatToInt (y); + r = (uint8) roundToInt (y); g = intV; b = x; } @@ -159,17 +159,17 @@ static void convertHSBtoRGB (float h, float s, float v, { r = x; g = intV; - b = (uint8) roundFloatToInt (z); + b = (uint8) roundToInt (z); } else if (h < 4.0f) { r = x; - g = (uint8) roundFloatToInt (y); + g = (uint8) roundToInt (y); b = intV; } else if (h < 5.0f) { - r = (uint8) roundFloatToInt (z); + r = (uint8) roundToInt (z); g = x; b = intV; } @@ -177,7 +177,7 @@ static void convertHSBtoRGB (float h, float s, float v, { r = intV; g = x; - b = (uint8) roundFloatToInt (y); + b = (uint8) roundToInt (y); } else { @@ -267,7 +267,7 @@ const Colour Colour::withMultipliedAlpha (const float alphaMultiplier) const thr jassert (alphaMultiplier >= 0); PixelARGB newCol (argb); - newCol.setAlpha ((uint8) jmin (0xff, roundFloatToInt (alphaMultiplier * newCol.getAlpha()))); + newCol.setAlpha ((uint8) jmin (0xff, roundToInt (alphaMultiplier * newCol.getAlpha()))); return Colour (newCol.getARGB()); } @@ -309,7 +309,7 @@ const Colour Colour::interpolatedWith (const Colour& other, float proportionOfOt PixelARGB c1 (getPixelARGB()); const PixelARGB c2 (other.getPixelARGB()); - c1.tween (c2, roundFloatToInt (proportionOfOther * 255.0f)); + c1.tween (c2, roundToInt (proportionOfOther * 255.0f)); c1.unpremultiply(); return Colour (c1.getARGB()); @@ -489,7 +489,7 @@ const Colour Colour::darker (float amount) const throw() const Colour Colour::greyLevel (const float brightness) throw() { const uint8 level - = (uint8) jlimit (0x00, 0xff, roundFloatToInt (brightness * 255.0f)); + = (uint8) jlimit (0x00, 0xff, roundToInt (brightness * 255.0f)); return Colour (level, level, level); } diff --git a/src/gui/graphics/colour/juce_ColourGradient.cpp b/src/gui/graphics/colour/juce_ColourGradient.cpp index 0f081b4dd1..b5ecf6bdeb 100644 --- a/src/gui/graphics/colour/juce_ColourGradient.cpp +++ b/src/gui/graphics/colour/juce_ColourGradient.cpp @@ -74,7 +74,7 @@ void ColourGradient::addColour (const double proportionAlongGradient, // must be within the two end-points jassert (proportionAlongGradient >= 0 && proportionAlongGradient <= 1.0); - const uint32 pos = jlimit (0, 65535, roundDoubleToInt (proportionAlongGradient * 65536.0)); + const uint32 pos = jlimit (0, 65535, roundToInt (proportionAlongGradient * 65536.0)); int i; for (i = 0; i < colours.size(); i += 2) @@ -114,7 +114,7 @@ const Colour ColourGradient::getColourAtPosition (const float position) const th { jassert (colours.getUnchecked (0) == 0); // the first colour specified has to go at position 0 - const int integerPos = jlimit (0, 65535, roundFloatToInt (position * 65536.0f)); + const int integerPos = jlimit (0, 65535, roundToInt (position * 65536.0f)); if (integerPos <= 0 || colours.size() <= 2) return getColour (0); diff --git a/src/gui/graphics/colour/juce_PixelFormats.h b/src/gui/graphics/colour/juce_PixelFormats.h index e9a4b20b40..6de8bfac8d 100644 --- a/src/gui/graphics/colour/juce_PixelFormats.h +++ b/src/gui/graphics/colour/juce_PixelFormats.h @@ -219,9 +219,9 @@ public: } else { - components.b = (uint8) jmin (0xff, (components.b * 0xff) / alpha); - components.g = (uint8) jmin (0xff, (components.g * 0xff) / alpha); - components.r = (uint8) jmin (0xff, (components.r * 0xff) / alpha); + components.b = (uint8) jmin ((uint32) 0xff, (components.b * 0xff) / alpha); + components.g = (uint8) jmin ((uint32) 0xff, (components.g * 0xff) / alpha); + components.r = (uint8) jmin ((uint32) 0xff, (components.r * 0xff) / alpha); } } } diff --git a/src/gui/graphics/contexts/juce_EdgeTable.cpp b/src/gui/graphics/contexts/juce_EdgeTable.cpp index 4bc4ac9efa..98bd74cf43 100644 --- a/src/gui/graphics/contexts/juce_EdgeTable.cpp +++ b/src/gui/graphics/contexts/juce_EdgeTable.cpp @@ -71,8 +71,8 @@ EdgeTable::EdgeTable (const Rectangle& bounds_, while (iter.next()) { - int y1 = roundFloatToInt (iter.y1 * 256.0f); - int y2 = roundFloatToInt (iter.y2 * 256.0f); + int y1 = roundToInt (iter.y1 * 256.0f); + int y2 = roundToInt (iter.y2 * 256.0f); if (y1 != y2) { @@ -103,7 +103,7 @@ EdgeTable::EdgeTable (const Rectangle& bounds_, do { const int step = jmin (stepSize, y2 - y1, 256 - (y1 & 255)); - int x = roundDoubleToInt (startX + multiplier * ((y1 + (step >> 1)) - startY)); + int x = roundToInt (startX + multiplier * ((y1 + (step >> 1)) - startY)); if (x < leftLimit) x = leftLimit; @@ -180,7 +180,7 @@ EdgeTable::EdgeTable (const RectangleList& rectanglesToAdd) throw() } EdgeTable::EdgeTable (const float x, const float y, const float w, const float h) throw() - : bounds (Rectangle ((int) floorf (x), roundFloatToInt (y * 256.0f) >> 8, 2 + (int) w, 2 + (int) h)), + : bounds (Rectangle ((int) floorf (x), roundToInt (y * 256.0f) >> 8, 2 + (int) w, 2 + (int) h)), maxEdgesPerLine (juce_edgeTableDefaultEdgesPerLine), lineStrideElements ((juce_edgeTableDefaultEdgesPerLine << 1) + 1), needToCheckEmptinesss (true) @@ -189,12 +189,12 @@ EdgeTable::EdgeTable (const float x, const float y, const float w, const float h table.malloc (jmax (1, bounds.getHeight()) * lineStrideElements); table[0] = 0; - const int x1 = roundFloatToInt (x * 256.0f); - const int x2 = roundFloatToInt ((x + w) * 256.0f); + const int x1 = roundToInt (x * 256.0f); + const int x2 = roundToInt ((x + w) * 256.0f); - int y1 = roundFloatToInt (y * 256.0f) - (bounds.getY() << 8); + int y1 = roundToInt (y * 256.0f) - (bounds.getY() << 8); jassert (y1 < 256); - int y2 = roundFloatToInt ((y + h) * 256.0f) - (bounds.getY() << 8); + int y2 = roundToInt ((y + h) * 256.0f) - (bounds.getY() << 8); if (x2 <= x1 || y2 <= y1) { @@ -436,7 +436,7 @@ void EdgeTable::intersectWithEdgeTableLine (const int y, const int* otherLine) t } ++otherLine; - const int lineSizeBytes = (dest[0] * 2 + 1) * sizeof (int); + const size_t lineSizeBytes = (dest[0] * 2 + 1) * sizeof (int); int* temp = (int*) alloca (lineSizeBytes); memcpy (temp, dest, lineSizeBytes); diff --git a/src/gui/graphics/contexts/juce_Graphics.cpp b/src/gui/graphics/contexts/juce_Graphics.cpp index 418cddf4db..0cc7845676 100644 --- a/src/gui/graphics/contexts/juce_Graphics.cpp +++ b/src/gui/graphics/contexts/juce_Graphics.cpp @@ -735,8 +735,8 @@ void Graphics::drawImageWithin (const Image* const imageToDraw, if (newW > 0 && newH > 0) { drawImage (imageToDraw, - roundDoubleToInt (newX), roundDoubleToInt (newY), - roundDoubleToInt (newW), roundDoubleToInt (newH), + roundToInt (newX), roundToInt (newY), + roundToInt (newW), roundToInt (newH), 0, 0, imageW, imageH, fillAlphaChannelWithCurrentBrush); } diff --git a/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp b/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp index 51134e4ecc..633d39c1b3 100644 --- a/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp +++ b/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp @@ -205,19 +205,19 @@ public: if (vertical) { - scale = roundDoubleToInt ((numEntries << (int) numScaleBits) / (double) (y2 - y1)); - start = roundDoubleToInt (y1 * scale); + scale = roundToInt ((numEntries << (int) numScaleBits) / (double) (y2 - y1)); + start = roundToInt (y1 * scale); } else if (horizontal) { - scale = roundDoubleToInt ((numEntries << (int) numScaleBits) / (double) (x2 - x1)); - start = roundDoubleToInt (x1 * scale); + scale = roundToInt ((numEntries << (int) numScaleBits) / (double) (x2 - x1)); + start = roundToInt (x1 * scale); } else { grad = (y2 - y1) / (double) (x1 - x2); yTerm = y1 - x1 / grad; - scale = roundDoubleToInt ((numEntries << (int) numScaleBits) / (yTerm * grad - (y2 * grad - x2))); + scale = roundToInt ((numEntries << (int) numScaleBits) / (yTerm * grad - (y2 * grad - x2))); grad *= scale; } } @@ -227,7 +227,7 @@ public: if (vertical) linePix = lookupTable [jlimit (0, numEntries, (y * scale - start) >> (int) numScaleBits)]; else if (! horizontal) - start = roundDoubleToInt ((y - yTerm) * grad); + start = roundToInt ((y - yTerm) * grad); } forcedinline const PixelARGB getPixel (const int x) const throw() @@ -265,7 +265,7 @@ public: const float gdy = gradient.y1 - gradient.y2; maxDist = gdx * gdx + gdy * gdy; invScale = numEntries / sqrt (maxDist); - jassert (roundDoubleToInt (sqrt (maxDist) * invScale) <= numEntries); + jassert (roundToInt (sqrt (maxDist) * invScale) <= numEntries); } forcedinline void setY (const int y) throw() @@ -280,7 +280,7 @@ public: x *= x; x += dy; - return lookupTable [x >= maxDist ? numEntries : roundDoubleToInt (sqrt (x) * invScale)]; + return lookupTable [x >= maxDist ? numEntries : roundToInt (sqrt (x) * invScale)]; } protected: @@ -323,7 +323,7 @@ public: if (x >= maxDist) return lookupTable [numEntries]; else - return lookupTable [jmin (numEntries, roundDoubleToInt (sqrt (x) * invScale))]; + return lookupTable [jmin (numEntries, roundToInt (sqrt (x) * invScale))]; } private: @@ -1573,7 +1573,7 @@ public: if (edgeTable != 0) { EdgeTable et (*edgeTable); - et.translate (x, roundFloatToInt (y)); + et.translate (x, roundToInt (y)); state.fillEdgeTable (image, et, false); } } @@ -1596,7 +1596,7 @@ public: glyphPath.getBoundsTransformed (transform.translated (0.0f, -0.5f), px, py, pw, ph); Rectangle clip ((int) floorf (px), (int) floorf (py), - roundFloatToInt (pw) + 2, roundFloatToInt (ph) + 2); + roundToInt (pw) + 2, roundToInt (ph) + 2); edgeTable = new EdgeTable (clip, glyphPath, transform); } diff --git a/src/gui/graphics/drawables/juce_Drawable.cpp b/src/gui/graphics/drawables/juce_Drawable.cpp index de0ce02afb..60d9dcf36b 100644 --- a/src/gui/graphics/drawables/juce_Drawable.cpp +++ b/src/gui/graphics/drawables/juce_Drawable.cpp @@ -87,11 +87,11 @@ void Drawable::drawWithin (Graphics& g, } //============================================================================== -Drawable* Drawable::createFromImageData (const void* data, const int numBytes) +Drawable* Drawable::createFromImageData (const void* data, const size_t numBytes) { Drawable* result = 0; - Image* const image = ImageFileFormat::loadFrom (data, numBytes); + Image* const image = ImageFileFormat::loadFrom (data, (int) numBytes); if (image != 0) { @@ -101,7 +101,7 @@ Drawable* Drawable::createFromImageData (const void* data, const int numBytes) } else { - const String asString (String::createStringFromData (data, numBytes)); + const String asString (String::createStringFromData (data, (int) numBytes)); XmlDocument doc (asString); ScopedPointer outer (doc.getDocumentElement (true)); diff --git a/src/gui/graphics/drawables/juce_Drawable.h b/src/gui/graphics/drawables/juce_Drawable.h index ec283e0629..9c8303c571 100644 --- a/src/gui/graphics/drawables/juce_Drawable.h +++ b/src/gui/graphics/drawables/juce_Drawable.h @@ -153,7 +153,7 @@ public: The data could be an image that the ImageFileFormat class understands, or it could be SVG. */ - static Drawable* createFromImageData (const void* data, const int numBytes); + static Drawable* createFromImageData (const void* data, const size_t numBytes); /** Tries to turn a stream containing some kind of image data into a drawable. diff --git a/src/gui/graphics/drawables/juce_DrawableImage.cpp b/src/gui/graphics/drawables/juce_DrawableImage.cpp index fc95a6cd47..6828fe6bf9 100644 --- a/src/gui/graphics/drawables/juce_DrawableImage.cpp +++ b/src/gui/graphics/drawables/juce_DrawableImage.cpp @@ -123,7 +123,7 @@ bool DrawableImage::hitTest (float x, float y) const && y >= 0.0f && x < image->getWidth() && y < image->getHeight() - && image->getPixelAt (roundFloatToInt (x), roundFloatToInt (y)).getAlpha() >= 127; + && image->getPixelAt (roundToInt (x), roundToInt (y)).getAlpha() >= 127; } Drawable* DrawableImage::createCopy() const @@ -195,7 +195,7 @@ DrawableImage* DrawableImage::createFromValueTree (const ValueTree& tree) throw( MemoryBlock imageData; if (imageData.fromBase64Encoding (tree ["data"])) { - Image* const im = ImageFileFormat::loadFrom (imageData.getData(), imageData.getSize()); + Image* const im = ImageFileFormat::loadFrom (imageData.getData(), (int) imageData.getSize()); if (im == 0) return false; diff --git a/src/gui/graphics/drawables/juce_SVGParser.cpp b/src/gui/graphics/drawables/juce_SVGParser.cpp index 93a543f4fd..dad8c4f641 100644 --- a/src/gui/graphics/drawables/juce_SVGParser.cpp +++ b/src/gui/graphics/drawables/juce_SVGParser.cpp @@ -1108,9 +1108,9 @@ private: tokens.removeEmptyStrings(); if (tokens[0].containsChar (T('%'))) - return Colour ((uint8) roundDoubleToInt (2.55 * tokens[0].getDoubleValue()), - (uint8) roundDoubleToInt (2.55 * tokens[1].getDoubleValue()), - (uint8) roundDoubleToInt (2.55 * tokens[2].getDoubleValue())); + return Colour ((uint8) roundToInt (2.55 * tokens[0].getDoubleValue()), + (uint8) roundToInt (2.55 * tokens[1].getDoubleValue()), + (uint8) roundToInt (2.55 * tokens[2].getDoubleValue())); else return Colour ((uint8) tokens[0].getIntValue(), (uint8) tokens[1].getIntValue(), diff --git a/src/gui/graphics/effects/juce_DropShadowEffect.cpp b/src/gui/graphics/effects/juce_DropShadowEffect.cpp index adfe9b7b35..c2755401a5 100644 --- a/src/gui/graphics/effects/juce_DropShadowEffect.cpp +++ b/src/gui/graphics/effects/juce_DropShadowEffect.cpp @@ -70,8 +70,8 @@ void DropShadowEffect::applyEffect (Image& image, Graphics& g) const Image::BitmapData srcData (image, 0, 0, w, h); const Image::BitmapData destData (shadowImage, 0, 0, w, h, true); - const int filter = roundFloatToInt (63.0f / radius); - const int radiusMinus1 = roundFloatToInt ((radius - 1.0f) * 63.0f); + const int filter = roundToInt (63.0f / radius); + const int radiusMinus1 = roundToInt ((radius - 1.0f) * 63.0f); for (int x = w; --x >= 0;) { diff --git a/src/gui/graphics/effects/juce_GlowEffect.cpp b/src/gui/graphics/effects/juce_GlowEffect.cpp index 9ea0994c50..eaa062ae77 100644 --- a/src/gui/graphics/effects/juce_GlowEffect.cpp +++ b/src/gui/graphics/effects/juce_GlowEffect.cpp @@ -56,7 +56,7 @@ void GlowEffect::applyEffect (Image& image, Graphics& g) Image temp (image.getFormat(), w, h, true); - ImageConvolutionKernel blurKernel (roundFloatToInt (radius * 2.0f)); + ImageConvolutionKernel blurKernel (roundToInt (radius * 2.0f)); blurKernel.createGaussianBlur (radius); blurKernel.rescaleAllValues (radius); diff --git a/src/gui/graphics/fonts/juce_Font.cpp b/src/gui/graphics/fonts/juce_Font.cpp index 9c943b9537..ec97dd0aa1 100644 --- a/src/gui/graphics/fonts/juce_Font.cpp +++ b/src/gui/graphics/fonts/juce_Font.cpp @@ -290,7 +290,7 @@ float Font::getDescent() const throw() int Font::getStringWidth (const String& text) const throw() { - return roundFloatToInt (getStringWidthFloat (text)); + return roundToInt (getStringWidthFloat (text)); } float Font::getStringWidthFloat (const String& text) const throw() diff --git a/src/gui/graphics/fonts/juce_TextLayout.cpp b/src/gui/graphics/fonts/juce_TextLayout.cpp index 0370503b46..ec18069802 100644 --- a/src/gui/graphics/fonts/juce_TextLayout.cpp +++ b/src/gui/graphics/fonts/juce_TextLayout.cpp @@ -51,7 +51,7 @@ public: isWhitespace (isWhitespace_) { w = font.getStringWidth (t); - h = roundFloatToInt (f.getHeight()); + h = roundToInt (f.getHeight()); isNewLine = t.containsAnyOf (T("\r\n")); } @@ -83,7 +83,7 @@ public: g.drawSingleLineText (text.trimEnd(), xOffset + x, yOffset + y + (lineHeight - h) - + roundFloatToInt (font.getAscent())); + + roundToInt (font.getAscent())); } } diff --git a/src/gui/graphics/geometry/juce_Path.cpp b/src/gui/graphics/geometry/juce_Path.cpp index fe4e360350..52f1151a32 100644 --- a/src/gui/graphics/geometry/juce_Path.cpp +++ b/src/gui/graphics/geometry/juce_Path.cpp @@ -1429,7 +1429,7 @@ const String Path::toString() const } const char* const result = (const char*) s.getData(); - int len = s.getDataSize(); + size_t len = s.getDataSize(); while (len > 0 && CharacterFunctions::isWhitespace (result [len - 1])) --len; diff --git a/src/gui/graphics/geometry/juce_PositionedRectangle.cpp b/src/gui/graphics/geometry/juce_PositionedRectangle.cpp index edb90779d0..7693c4538a 100644 --- a/src/gui/graphics/geometry/juce_PositionedRectangle.cpp +++ b/src/gui/graphics/geometry/juce_PositionedRectangle.cpp @@ -130,8 +130,8 @@ const Rectangle PositionedRectangle::getRectangle (const Rectangle& target) cons applyPosAndSize (x_, w_, x, w, xMode, wMode, target.getX(), target.getWidth()); applyPosAndSize (y_, h_, y, h, yMode, hMode, target.getY(), target.getHeight()); - return Rectangle (roundDoubleToInt (x_), roundDoubleToInt (y_), - roundDoubleToInt (w_), roundDoubleToInt (h_)); + return Rectangle (roundToInt (x_), roundToInt (y_), + roundToInt (w_), roundToInt (h_)); } void PositionedRectangle::getRectangleDouble (const Rectangle& target, @@ -254,11 +254,11 @@ void PositionedRectangle::addPosDescription (String& s, const uint8 mode, const { if ((mode & proportionOfParentSize) != 0) { - s << (roundDoubleToInt (value * 100000.0) / 1000.0) << T('%'); + s << (roundToInt (value * 100000.0) / 1000.0) << T('%'); } else { - s << (roundDoubleToInt (value * 100.0) / 100.0); + s << (roundToInt (value * 100.0) / 100.0); if ((mode & absoluteFromParentBottomRight) != 0) s << T('R'); @@ -275,11 +275,11 @@ void PositionedRectangle::addPosDescription (String& s, const uint8 mode, const void PositionedRectangle::addSizeDescription (String& s, const uint8 mode, const double value) const throw() { if (mode == proportionalSize) - s << (roundDoubleToInt (value * 100000.0) / 1000.0) << T('%'); + s << (roundToInt (value * 100000.0) / 1000.0) << T('%'); else if (mode == parentSizeMinusAbsolute) - s << (roundDoubleToInt (value * 100.0) / 100.0) << T('M'); + s << (roundToInt (value * 100.0) / 100.0) << T('M'); else - s << (roundDoubleToInt (value * 100.0) / 100.0); + s << (roundToInt (value * 100.0) / 100.0); } void PositionedRectangle::decodePosString (const String& s, uint8& mode, double& value) throw() @@ -335,11 +335,11 @@ void PositionedRectangle::applyPosAndSize (double& xOut, double& wOut, const int parentSize) const throw() { if (wMode_ == proportionalSize) - wOut = roundDoubleToInt (w_ * parentSize); + wOut = roundToInt (w_ * parentSize); else if (wMode_ == parentSizeMinusAbsolute) - wOut = jmax (0, parentSize - roundDoubleToInt (w_)); + wOut = jmax (0, parentSize - roundToInt (w_)); else - wOut = roundDoubleToInt (w_); + wOut = roundToInt (w_); if ((xMode_ & proportionOfParentSize) != 0) xOut = parentPos + x_ * parentSize; diff --git a/src/gui/graphics/imaging/image_file_formats/juce_JPEGLoader.cpp b/src/gui/graphics/imaging/image_file_formats/juce_JPEGLoader.cpp index 29b5ab81f7..388864f743 100644 --- a/src/gui/graphics/imaging/image_file_formats/juce_JPEGLoader.cpp +++ b/src/gui/graphics/imaging/image_file_formats/juce_JPEGLoader.cpp @@ -167,7 +167,7 @@ static void jpegSkip (j_decompress_ptr decompStruct, long num) { decompStruct->src->next_input_byte += num; - num = jmin (num, (int) decompStruct->src->bytes_in_buffer); + num = jmin (num, (long) decompStruct->src->bytes_in_buffer); decompStruct->src->bytes_in_buffer -= num; } @@ -289,8 +289,8 @@ static void jpegWriteTerminate (j_compress_ptr cinfo) { JuceJpegDest* const dest = (JuceJpegDest*) cinfo->dest; - const int numToWrite = jpegBufferSize - dest->free_in_buffer; - dest->output->write (dest->buffer, numToWrite); + const size_t numToWrite = jpegBufferSize - dest->free_in_buffer; + dest->output->write (dest->buffer, (int) numToWrite); } static boolean jpegWriteFlush (j_compress_ptr cinfo) @@ -355,7 +355,7 @@ bool juce_writeJPEGImageToStream (const Image& image, if (quality < 0.0f) quality = 0.85f; - jpeg_set_quality (&jpegCompStruct, jlimit (0, 100, roundFloatToInt (quality * 100.0f)), TRUE); + jpeg_set_quality (&jpegCompStruct, jlimit (0, 100, roundToInt (quality * 100.0f)), TRUE); jpeg_start_compress (&jpegCompStruct, TRUE); diff --git a/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp b/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp index 77e76af0f2..9ace0cd20a 100644 --- a/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp +++ b/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp @@ -193,11 +193,11 @@ Image* juce_loadPNGImageFromStream (InputStream& in) // now convert the data to a juce image format.. image = Image::createNativeImage (hasAlphaChan ? Image::ARGB : Image::RGB, - width, height, hasAlphaChan); + (int) width, (int) height, hasAlphaChan); hasAlphaChan = image->hasAlphaChannel(); // (the native image creator may not give back what we expect) - const Image::BitmapData destData (*image, 0, 0, width, height, true); + const Image::BitmapData destData (*image, 0, 0, (int) width, (int) height, true); uint8* srcRow = tempBuffer; uint8* destRow = destData.data; @@ -210,7 +210,7 @@ Image* juce_loadPNGImageFromStream (InputStream& in) if (hasAlphaChan) { - for (int i = width; --i >= 0;) + for (int i = (int) width; --i >= 0;) { ((PixelARGB*) dest)->setARGB (src[3], src[0], src[1], src[2]); ((PixelARGB*) dest)->premultiply(); @@ -220,7 +220,7 @@ Image* juce_loadPNGImageFromStream (InputStream& in) } else { - for (int i = width; --i >= 0;) + for (int i = (int) width; --i >= 0;) { ((PixelRGB*) dest)->setARGB (0, src[0], src[1], src[2]); dest += destData.pixelStride; @@ -238,7 +238,7 @@ static void pngWriteDataCallback (png_structp png_ptr, png_bytep data, png_size_ { OutputStream* const out = (OutputStream*) png_ptr->io_ptr; - const bool ok = out->write (data, length); + const bool ok = out->write (data, (int) length); (void) ok; jassert (ok); diff --git a/src/gui/graphics/imaging/juce_Image.cpp b/src/gui/graphics/imaging/juce_Image.cpp index 382d2399e9..0de9270052 100644 --- a/src/gui/graphics/imaging/juce_Image.cpp +++ b/src/gui/graphics/imaging/juce_Image.cpp @@ -369,7 +369,7 @@ void Image::createSolidAreaMask (RectangleList& result, const float alphaThresho { if (hasAlphaChannel()) { - const uint8 threshold = (uint8) jlimit (0, 255, roundFloatToInt (alphaThreshold * 255.0f)); + const uint8 threshold = (uint8) jlimit (0, 255, roundToInt (alphaThreshold * 255.0f)); SparseSet pixelsOnRow; const BitmapData srcData (*this, 0, 0, getWidth(), getHeight()); diff --git a/src/gui/graphics/imaging/juce_ImageConvolutionKernel.cpp b/src/gui/graphics/imaging/juce_ImageConvolutionKernel.cpp index 01851c3186..3c5561a659 100644 --- a/src/gui/graphics/imaging/juce_ImageConvolutionKernel.cpp +++ b/src/gui/graphics/imaging/juce_ImageConvolutionKernel.cpp @@ -195,10 +195,10 @@ void ImageConvolutionKernel::applyToImage (Image& destImage, } } - *dest++ = (uint8) jmin (0xff, roundFloatToInt (c1)); - *dest++ = (uint8) jmin (0xff, roundFloatToInt (c2)); - *dest++ = (uint8) jmin (0xff, roundFloatToInt (c3)); - *dest++ = (uint8) jmin (0xff, roundFloatToInt (c4)); + *dest++ = (uint8) jmin (0xff, roundToInt (c1)); + *dest++ = (uint8) jmin (0xff, roundToInt (c2)); + *dest++ = (uint8) jmin (0xff, roundToInt (c3)); + *dest++ = (uint8) jmin (0xff, roundToInt (c4)); } } } @@ -249,9 +249,9 @@ void ImageConvolutionKernel::applyToImage (Image& destImage, } } - *dest++ = (uint8) roundFloatToInt (c1); - *dest++ = (uint8) roundFloatToInt (c2); - *dest++ = (uint8) roundFloatToInt (c3); + *dest++ = (uint8) roundToInt (c1); + *dest++ = (uint8) roundToInt (c2); + *dest++ = (uint8) roundToInt (c3); } } } diff --git a/src/io/network/juce_Socket.cpp b/src/io/network/juce_Socket.cpp index 3af0257d37..4266dca9cb 100644 --- a/src/io/network/juce_Socket.cpp +++ b/src/io/network/juce_Socket.cpp @@ -129,7 +129,7 @@ static int readSocket (const int handle, #if JUCE_WINDOWS bytesThisTime = recv (handle, ((char*) destBuffer) + bytesRead, maxBytesToRead - bytesRead, 0); #else - while ((bytesThisTime = ::read (handle, ((char*) destBuffer) + bytesRead, maxBytesToRead - bytesRead)) < 0 + while ((bytesThisTime = (int) ::read (handle, ((char*) destBuffer) + bytesRead, maxBytesToRead - bytesRead)) < 0 && errno == EINTR && connected) { @@ -349,7 +349,7 @@ int StreamingSocket::write (const void* sourceBuffer, const int numBytesToWrite) #else int result; - while ((result = ::write (handle, sourceBuffer, numBytesToWrite)) < 0 + while ((result = (int) ::write (handle, sourceBuffer, numBytesToWrite)) < 0 && errno == EINTR) { } @@ -616,10 +616,10 @@ int DatagramSocket::write (const void* sourceBuffer, const int numBytesToWrite) // You need to call connect() first to set the server address.. jassert (serverAddress != 0 && connected); - return connected ? sendto (handle, (const char*) sourceBuffer, - numBytesToWrite, 0, - (const struct sockaddr*) serverAddress, - sizeof (struct sockaddr_in)) + return connected ? (int) sendto (handle, (const char*) sourceBuffer, + numBytesToWrite, 0, + (const struct sockaddr*) serverAddress, + sizeof (struct sockaddr_in)) : -1; } diff --git a/src/io/network/juce_URL.cpp b/src/io/network/juce_URL.cpp index 4ff4c66905..3e311945cc 100644 --- a/src/io/network/juce_URL.cpp +++ b/src/io/network/juce_URL.cpp @@ -431,7 +431,7 @@ private: // just a short text attachment, so use simple url encoding.. headers = "Content-Type: application/x-www-form-urlencoded\r\nContent-length: " - + String (postData.getSize()) + + String ((unsigned int) postData.getSize()) + "\r\n"; } } diff --git a/src/io/streams/juce_InputStream.cpp b/src/io/streams/juce_InputStream.cpp index 87a743b6e2..5f3f776c27 100644 --- a/src/io/streams/juce_InputStream.cpp +++ b/src/io/streams/juce_InputStream.cpp @@ -158,7 +158,7 @@ const String InputStream::readString() { MemoryBlock buffer (256); uint8* data = (uint8*) buffer.getData(); - int i = 0; + size_t i = 0; while ((data[i] = readByte()) != 0) { @@ -169,14 +169,14 @@ const String InputStream::readString() } } - return String::fromUTF8 (data, i); + return String::fromUTF8 (data, (int) i); } const String InputStream::readNextLine() { MemoryBlock buffer (256); uint8* data = (uint8*) buffer.getData(); - int i = 0; + size_t i = 0; while ((data[i] = readByte()) != 0) { @@ -200,7 +200,7 @@ const String InputStream::readNextLine() } } - return String::fromUTF8 (data, i); + return String::fromUTF8 (data, (int) i); } int InputStream::readIntoMemoryBlock (MemoryBlock& block, @@ -221,7 +221,7 @@ int InputStream::readIntoMemoryBlock (MemoryBlock& block, return 0; } - const int originalBlockSize = block.getSize(); + const size_t originalBlockSize = block.getSize(); int totalBytesRead = 0; if (numBytes > 0) diff --git a/src/io/streams/juce_MemoryInputStream.cpp b/src/io/streams/juce_MemoryInputStream.cpp index 50a86eaba7..ae6ada14c4 100644 --- a/src/io/streams/juce_MemoryInputStream.cpp +++ b/src/io/streams/juce_MemoryInputStream.cpp @@ -33,7 +33,7 @@ BEGIN_JUCE_NAMESPACE //============================================================================== MemoryInputStream::MemoryInputStream (const void* const sourceData, - const int sourceDataSize, + const size_t sourceDataSize, const bool keepInternalCopy) : data ((const char*) sourceData), dataSize (sourceDataSize), @@ -57,10 +57,10 @@ int64 MemoryInputStream::getTotalLength() int MemoryInputStream::read (void* buffer, int howMany) { - const int num = jmin (howMany, dataSize - position); + const size_t num = jmin ((size_t) howMany, dataSize - position); memcpy (buffer, data + position, num); position += num; - return num; + return (int) num; } bool MemoryInputStream::isExhausted() diff --git a/src/io/streams/juce_MemoryInputStream.h b/src/io/streams/juce_MemoryInputStream.h index 243cc8bb78..ebeda99964 100644 --- a/src/io/streams/juce_MemoryInputStream.h +++ b/src/io/streams/juce_MemoryInputStream.h @@ -51,7 +51,7 @@ public: data and use that. */ MemoryInputStream (const void* const sourceData, - const int sourceDataSize, + const size_t sourceDataSize, const bool keepInternalCopyOfData); /** Destructor. */ @@ -70,7 +70,7 @@ public: private: const char* data; - int dataSize, position; + size_t dataSize, position; MemoryBlock internalCopy; }; diff --git a/src/io/streams/juce_MemoryOutputStream.cpp b/src/io/streams/juce_MemoryOutputStream.cpp index 8105006b54..430946d75b 100644 --- a/src/io/streams/juce_MemoryOutputStream.cpp +++ b/src/io/streams/juce_MemoryOutputStream.cpp @@ -32,13 +32,13 @@ BEGIN_JUCE_NAMESPACE //============================================================================== -MemoryOutputStream::MemoryOutputStream (const int initialSize, - const int blockSizeToIncreaseBy, +MemoryOutputStream::MemoryOutputStream (const size_t initialSize, + const size_t blockSizeToIncreaseBy, MemoryBlock* const memoryBlockToWriteTo) throw() : data (memoryBlockToWriteTo), position (0), size (0), - blockSize (jmax (16, blockSizeToIncreaseBy)) + blockSize (jmax ((size_t) 16, blockSizeToIncreaseBy)) { if (data == 0) dataToDelete = data = new MemoryBlock (initialSize); @@ -67,7 +67,7 @@ bool MemoryOutputStream::write (const void* buffer, int howMany) { if (howMany > 0) { - int storageNeeded = position + howMany; + size_t storageNeeded = position + howMany; if (storageNeeded >= data->getSize()) { @@ -78,7 +78,7 @@ bool MemoryOutputStream::write (const void* buffer, int howMany) data->ensureSize (storageNeeded); } - data->copyFrom (buffer, position, howMany); + data->copyFrom (buffer, (int) position, howMany); position += howMany; size = jmax (size, position); } @@ -94,7 +94,7 @@ const char* MemoryOutputStream::getData() throw() return (const char*) data->getData(); } -int MemoryOutputStream::getDataSize() const throw() +size_t MemoryOutputStream::getDataSize() const throw() { return size; } @@ -106,10 +106,10 @@ int64 MemoryOutputStream::getPosition() bool MemoryOutputStream::setPosition (int64 newPosition) { - if (newPosition <= size) + if (newPosition <= (int64) size) { // ok to seek backwards - position = jlimit (0, size, (int) newPosition); + position = jlimit ((size_t) 0, size, (size_t) newPosition); return true; } else diff --git a/src/io/streams/juce_MemoryOutputStream.h b/src/io/streams/juce_MemoryOutputStream.h index b7c57cd4a9..4c8f5ea0d0 100644 --- a/src/io/streams/juce_MemoryOutputStream.h +++ b/src/io/streams/juce_MemoryOutputStream.h @@ -50,8 +50,8 @@ public: will allocate its own storage internally, which you can access using getData() and getDataSize() */ - MemoryOutputStream (const int initialSize = 256, - const int granularity = 256, + MemoryOutputStream (const size_t initialSize = 256, + const size_t granularity = 256, MemoryBlock* const memoryBlockToWriteTo = 0) throw(); /** Destructor. @@ -71,7 +71,7 @@ public: @see getData */ - int getDataSize() const throw(); + size_t getDataSize() const throw(); /** Resets the stream, clearing any data that has been written to it so far. */ void reset() throw(); @@ -89,7 +89,7 @@ public: private: MemoryBlock* data; ScopedPointer dataToDelete; - int position, size, blockSize; + size_t position, size, blockSize; }; #endif // __JUCE_MEMORYOUTPUTSTREAM_JUCEHEADER__ diff --git a/src/io/streams/juce_OutputStream.cpp b/src/io/streams/juce_OutputStream.cpp index fd019fc7c3..9c928e1ec6 100644 --- a/src/io/streams/juce_OutputStream.cpp +++ b/src/io/streams/juce_OutputStream.cpp @@ -312,7 +312,7 @@ int OutputStream::writeFromInputStream (InputStream& source, { char buffer [8192]; - const int num = source.read (buffer, jmin (numBytesToWrite, sizeof (buffer))); + const int num = source.read (buffer, (int) jmin ((size_t) numBytesToWrite, sizeof (buffer))); if (num == 0) break; diff --git a/src/native/common/juce_posix_NamedPipe.cpp b/src/native/common/juce_posix_NamedPipe.cpp index f3b9b73e73..f7ca3b59cc 100644 --- a/src/native/common/juce_posix_NamedPipe.cpp +++ b/src/native/common/juce_posix_NamedPipe.cpp @@ -47,7 +47,7 @@ void NamedPipe::cancelPendingReads() intern->stopReadOperation = true; char buffer [1] = { 0 }; - int bytesWritten = ::write (intern->pipeIn, buffer, 1); + int bytesWritten = (int) ::write (intern->pipeIn, buffer, 1); (void) bytesWritten; int timeout = 2000; @@ -147,7 +147,7 @@ int NamedPipe::read (void* destBuffer, int maxBytesToRead, int /*timeOutMillisec while (bytesRead < maxBytesToRead) { const int bytesThisTime = maxBytesToRead - bytesRead; - const int numRead = ::read (intern->pipeIn, p, bytesThisTime); + const int numRead = (int) ::read (intern->pipeIn, p, bytesThisTime); if (numRead <= 0 || intern->stopReadOperation) { @@ -194,7 +194,7 @@ int NamedPipe::write (const void* sourceBuffer, int numBytesToWrite, int timeOut && (timeOutMilliseconds < 0 || Time::getMillisecondCounter() < timeOutTime)) { const int bytesThisTime = numBytesToWrite - bytesWritten; - const int numWritten = ::write (intern->pipeOut, p, bytesThisTime); + const int numWritten = (int) ::write (intern->pipeOut, p, bytesThisTime); if (numWritten <= 0) { diff --git a/src/native/common/juce_posix_SharedCode.h b/src/native/common/juce_posix_SharedCode.h index 371db4b08c..bc1b9b8050 100644 --- a/src/native/common/juce_posix_SharedCode.h +++ b/src/native/common/juce_posix_SharedCode.h @@ -276,7 +276,7 @@ void juce_fileClose (void* handle) int juce_fileRead (void* handle, void* buffer, int size) { if (handle != 0) - return read ((int) (pointer_sized_int) handle, buffer, size); + return (int) read ((int) (pointer_sized_int) handle, buffer, size); return 0; } @@ -284,7 +284,7 @@ int juce_fileRead (void* handle, void* buffer, int size) int juce_fileWrite (void* handle, const void* buffer, int size) { if (handle != 0) - return write ((int) (pointer_sized_int) handle, buffer, size); + return (int) write ((int) (pointer_sized_int) handle, buffer, size); return 0; } diff --git a/src/native/linux/juce_linux_Audio.cpp b/src/native/linux/juce_linux_Audio.cpp index d16343847c..e00c4d5c80 100644 --- a/src/native/linux/juce_linux_Audio.cpp +++ b/src/native/linux/juce_linux_Audio.cpp @@ -377,7 +377,7 @@ public: if (inputChannels.getHighestBit() >= 0) { - for (int i = 0; i <= jmax (inputChannels.getHighestBit(), minChansIn); ++i) + for (int i = 0; i <= jmax (inputChannels.getHighestBit(), (int) minChansIn); ++i) { inputChannelData [i] = (float*) juce_calloc (sizeof (float) * bufferSize); @@ -391,7 +391,7 @@ public: if (outputChannels.getHighestBit() >= 0) { - for (int i = 0; i <= jmax (outputChannels.getHighestBit(), minChansOut); ++i) + for (int i = 0; i <= jmax (outputChannels.getHighestBit(), (int) minChansOut); ++i) { outputChannelData [i] = (float*) juce_calloc (sizeof (float) * bufferSize); diff --git a/src/native/linux/juce_linux_Network.cpp b/src/native/linux/juce_linux_Network.cpp index 5c98dfd80f..8f0f3f0fe4 100644 --- a/src/native/linux/juce_linux_Network.cpp +++ b/src/native/linux/juce_linux_Network.cpp @@ -178,7 +178,7 @@ public: hostPath, url, headers, postData, isPost)); - int totalHeaderSent = 0; + size_t totalHeaderSent = 0; while (totalHeaderSent < requestHeader.getSize()) { @@ -188,7 +188,7 @@ public: return false; } - const int numToSend = jmin (1024, requestHeader.getSize() - totalHeaderSent); + const int numToSend = jmin (1024, (int) (requestHeader.getSize() - totalHeaderSent)); if (send (socketHandle, ((const char*) requestHeader.getData()) + totalHeaderSent, diff --git a/src/native/linux/juce_linux_Windowing.cpp b/src/native/linux/juce_linux_Windowing.cpp index 79a2b440d7..63a5317659 100644 --- a/src/native/linux/juce_linux_Windowing.cpp +++ b/src/native/linux/juce_linux_Windowing.cpp @@ -1841,6 +1841,15 @@ private: bool fullScreen, entered, mapped, depthIs16Bit; BorderSize windowBorder; + struct MotifWmHints + { + unsigned long flags; + unsigned long functions; + unsigned long decorations; + long input_mode; + unsigned long status; + }; + //============================================================================== void removeWindowDecorations (Window wndH) { @@ -1848,15 +1857,6 @@ private: if (hints != None) { - typedef struct - { - unsigned long flags; - unsigned long functions; - unsigned long decorations; - long input_mode; - unsigned long status; - } MotifWmHints; - MotifWmHints motifHints; zerostruct (motifHints); motifHints.flags = 2; /* MWM_HINTS_DECORATIONS */ @@ -1916,15 +1916,6 @@ private: if (hints != None) { - typedef struct - { - unsigned long flags; - unsigned long functions; - unsigned long decorations; - long input_mode; - unsigned long status; - } MotifWmHints; - MotifWmHints motifHints; zerostruct (motifHints); diff --git a/src/native/mac/juce_mac_AppleRemote.mm b/src/native/mac/juce_mac_AppleRemote.mm index f8eeae4285..96e81e2970 100644 --- a/src/native/mac/juce_mac_AppleRemote.mm +++ b/src/native/mac/juce_mac_AppleRemote.mm @@ -260,7 +260,7 @@ void AppleRemoteDevice::handleCallbackInternal() break; } - i += strlen (buttonPatterns + i) + 1; + i += (int) strlen (buttonPatterns + i) + 1; ++buttonNum; } } diff --git a/src/native/mac/juce_mac_AudioCDBurner.mm b/src/native/mac/juce_mac_AudioCDBurner.mm index 968c376a8b..8f1570614d 100644 --- a/src/native/mac/juce_mac_AudioCDBurner.mm +++ b/src/native/mac/juce_mac_AudioCDBurner.mm @@ -271,7 +271,7 @@ END_JUCE_NAMESPACE { if (source != 0) { - const int numSamples = JUCE_NAMESPACE::jmin (bufferLength / 4, (lengthInFrames * (44100 / 75)) - readPosition); + const int numSamples = JUCE_NAMESPACE::jmin ((int) bufferLength / 4, (lengthInFrames * (44100 / 75)) - readPosition); if (numSamples > 0) { diff --git a/src/native/mac/juce_mac_CarbonViewWrapperComponent.h b/src/native/mac/juce_mac_CarbonViewWrapperComponent.h index 7299b667c2..aa80bac9be 100644 --- a/src/native/mac/juce_mac_CarbonViewWrapperComponent.h +++ b/src/native/mac/juce_mac_CarbonViewWrapperComponent.h @@ -64,8 +64,8 @@ public: HIRect bounds; HIViewGetBounds (embeddedView, &bounds); - w = jmax (1, roundFloatToInt (bounds.size.width)); - h = jmax (1, roundFloatToInt (bounds.size.height)); + w = jmax (1, roundToInt (bounds.size.width)); + h = jmax (1, roundToInt (bounds.size.height)); return true; } diff --git a/src/native/mac/juce_mac_CoreAudio.cpp b/src/native/mac/juce_mac_CoreAudio.cpp index b550260f93..8b6758582f 100644 --- a/src/native/mac/juce_mac_CoreAudio.cpp +++ b/src/native/mac/juce_mac_CoreAudio.cpp @@ -246,7 +246,7 @@ public: for (int i = 32; i < 8192; i += 32) { - for (int j = size / sizeof (AudioValueRange); --j >= 0;) + for (int j = size / (int) sizeof (AudioValueRange); --j >= 0;) { if (i >= ranges[j].mMinimum && i <= ranges[j].mMaximum) { @@ -281,7 +281,7 @@ public: { bool ok = false; - for (int j = size / sizeof (AudioValueRange); --j >= 0;) + for (int j = size / (int) sizeof (AudioValueRange); --j >= 0;) if (possibleRates[i] >= ranges[j].mMinimum - 2 && possibleRates[i] <= ranges[j].mMaximum + 2) ok = true; @@ -852,7 +852,7 @@ private: types.calloc (size, 1); if (OK (AudioObjectGetPropertyData (deviceID, &pa, 0, 0, &size, types))) - return size / sizeof (OSType); + return size / (int) sizeof (OSType); } return 0; @@ -1152,7 +1152,7 @@ public: if (OK (AudioObjectGetPropertyData (kAudioObjectSystemObject, &pa, 0, 0, &size, devs))) { static bool alreadyLogged = false; - const int num = size / sizeof (AudioDeviceID); + const int num = size / (int) sizeof (AudioDeviceID); for (int i = 0; i < num; ++i) { char name [1024]; @@ -1161,7 +1161,7 @@ public: if (OK (AudioObjectGetPropertyData (devs[i], &pa, 0, 0, &size, name))) { - const String nameString (String::fromUTF8 ((const uint8*) name, strlen (name))); + const String nameString (String::fromUTF8 ((const uint8*) name, (int) strlen (name))); if (! alreadyLogged) log (T("CoreAudio device: ") + nameString); diff --git a/src/native/mac/juce_mac_CoreGraphicsContext.mm b/src/native/mac/juce_mac_CoreGraphicsContext.mm index b305f44413..73aaebc9c8 100644 --- a/src/native/mac/juce_mac_CoreGraphicsContext.mm +++ b/src/native/mac/juce_mac_CoreGraphicsContext.mm @@ -236,10 +236,10 @@ public: { CGRect bounds = CGRectIntegral (CGContextGetClipBoundingBox (context)); - return Rectangle (roundFloatToInt (bounds.origin.x), - roundFloatToInt (flipHeight - (bounds.origin.y + bounds.size.height)), - roundFloatToInt (bounds.size.width), - roundFloatToInt (bounds.size.height)); + return Rectangle (roundToInt (bounds.origin.x), + roundToInt (flipHeight - (bounds.origin.y + bounds.size.height)), + roundToInt (bounds.size.width), + roundToInt (bounds.size.height)); } bool isClipEmpty() const @@ -498,7 +498,7 @@ public: { CGGlyph g = glyphNumber; CGContextShowGlyphsAtPoint (context, transform.getTranslationX(), - flipHeight - roundFloatToInt (transform.getTranslationY()), &g, 1); + flipHeight - roundToInt (transform.getTranslationY()), &g, 1); } else { @@ -566,7 +566,7 @@ private: { const CoreGraphicsContext* const g = (const CoreGraphicsContext*) info; - const int index = roundFloatToInt (g->numGradientLookupEntries * inData[0]); + const int index = roundToInt (g->numGradientLookupEntries * inData[0]); PixelARGB colour (g->gradientLookupTable [jlimit (0, g->numGradientLookupEntries, index)]); colour.unpremultiply(); diff --git a/src/native/mac/juce_mac_CoreMidi.cpp b/src/native/mac/juce_mac_CoreMidi.cpp index bb744b5ef6..4a9f688bdb 100644 --- a/src/native/mac/juce_mac_CoreMidi.cpp +++ b/src/native/mac/juce_mac_CoreMidi.cpp @@ -122,7 +122,7 @@ static const String getConnectedEndpointName (MIDIEndpointRef endpoint) if (connections != 0) { - numConnections = CFDataGetLength (connections) / sizeof (MIDIUniqueID); + numConnections = (int) (CFDataGetLength (connections) / sizeof (MIDIUniqueID)); if (numConnections > 0) { diff --git a/src/native/mac/juce_mac_Fonts.mm b/src/native/mac/juce_mac_Fonts.mm index 4ef1befd3c..ef6dc52270 100644 --- a/src/native/mac/juce_mac_Fonts.mm +++ b/src/native/mac/juce_mac_Fonts.mm @@ -117,8 +117,8 @@ public: [nsFont retain]; - ascent = fabsf ([nsFont ascender]); - float totalSize = ascent + fabsf ([nsFont descender]); + ascent = fabsf ((float) [nsFont ascender]); + float totalSize = ascent + fabsf ((float) [nsFont descender]); ascent /= totalSize; pathTransform = AffineTransform::identity.scale (1.0f / totalSize, 1.0f / totalSize); @@ -310,13 +310,13 @@ public: switch ([bez elementAtIndex: i associatedPoints: p]) { case NSMoveToBezierPathElement: - path.startNewSubPath (p[0].x, -p[0].y); + path.startNewSubPath ((float) p[0].x, (float) -p[0].y); break; case NSLineToBezierPathElement: - path.lineTo (p[0].x, -p[0].y); + path.lineTo ((float) p[0].x, (float) -p[0].y); break; case NSCurveToBezierPathElement: - path.cubicTo (p[0].x, -p[0].y, p[1].x, -p[1].y, p[2].x, -p[2].y); + path.cubicTo ((float) p[0].x, (float) -p[0].y, (float) p[1].x, (float) -p[1].y, (float) p[2].x, (float) -p[2].y); break; case NSClosePathBezierPathElement: path.closeSubPath(); diff --git a/src/native/mac/juce_mac_MainMenu.mm b/src/native/mac/juce_mac_MainMenu.mm index b060bf66ff..ca03a7e8df 100644 --- a/src/native/mac/juce_mac_MainMenu.mm +++ b/src/native/mac/juce_mac_MainMenu.mm @@ -182,7 +182,7 @@ public: static NSMenuItem* findMenuItem (NSMenu* const menu, const ApplicationCommandTarget::InvocationInfo& info) { - for (int i = [menu numberOfItems]; --i >= 0;) + for (NSInteger i = [menu numberOfItems]; --i >= 0;) { NSMenuItem* m = [menu itemAtIndex: i]; if ([m tag] == info.commandID) @@ -386,7 +386,7 @@ END_JUCE_NAMESPACE NSArray* info = (NSArray*) [item representedObject]; - owner->invoke ([item tag], + owner->invoke ((int) [item tag], (ApplicationCommandManager*) (pointer_sized_int) [((NSNumber*) [info objectAtIndex: 0]) unsignedLongLongValue], (int) [((NSNumber*) [info objectAtIndex: 1]) intValue]); diff --git a/src/native/mac/juce_mac_MiscUtilities.mm b/src/native/mac/juce_mac_MiscUtilities.mm index f8efa4a819..a76f2ef650 100644 --- a/src/native/mac/juce_mac_MiscUtilities.mm +++ b/src/native/mac/juce_mac_MiscUtilities.mm @@ -149,8 +149,8 @@ void Desktop::getMousePosition (int& x, int& y) throw() { const ScopedAutoReleasePool pool; const NSPoint p ([NSEvent mouseLocation]); - x = roundFloatToInt (p.x); - y = roundFloatToInt ([[[NSScreen screens] objectAtIndex: 0] frame].size.height - p.y); + x = roundToInt (p.x); + y = roundToInt ([[[NSScreen screens] objectAtIndex: 0] frame].size.height - p.y); } void Desktop::setMousePosition (int x, int y) throw() @@ -244,7 +244,7 @@ void juce_updateMultiMonitorInfo (Array & monitorCoords, const bool c const ScopedAutoReleasePool pool; monitorCoords.clear(); NSArray* screens = [NSScreen screens]; - const float mainScreenBottom = [[[NSScreen screens] objectAtIndex: 0] frame].size.height; + const CGFloat mainScreenBottom = [[[NSScreen screens] objectAtIndex: 0] frame].size.height; for (unsigned int i = 0; i < [screens count]; ++i) { diff --git a/src/native/mac/juce_mac_MouseCursor.mm b/src/native/mac/juce_mac_MouseCursor.mm index a73d57515a..6d96359c55 100644 --- a/src/native/mac/juce_mac_MouseCursor.mm +++ b/src/native/mac/juce_mac_MouseCursor.mm @@ -41,9 +41,9 @@ void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hot return (void*) c; } -static void* juce_cursorFromData (const unsigned char* data, const int size, float hx, float hy) throw() +static void* juce_cursorFromData (const unsigned char* data, const size_t size, float hx, float hy) throw() { - ScopedPointer im (ImageFileFormat::loadFrom ((const char*) data, size)); + ScopedPointer im (ImageFileFormat::loadFrom ((const char*) data, (int) size)); jassert (im != 0); if (im == 0) diff --git a/src/native/mac/juce_mac_NSViewComponentPeer.mm b/src/native/mac/juce_mac_NSViewComponentPeer.mm index 616827c829..9e079943d7 100644 --- a/src/native/mac/juce_mac_NSViewComponentPeer.mm +++ b/src/native/mac/juce_mac_NSViewComponentPeer.mm @@ -646,11 +646,11 @@ static int64 getMouseTime (NSEvent* e) static void getMousePos (NSEvent* e, NSView* view, int& x, int& y) { NSPoint p = [view convertPoint: [e locationInWindow] fromView: nil]; - x = roundFloatToInt (p.x); - y = roundFloatToInt ([view frame].size.height - p.y); + x = roundToInt (p.x); + y = roundToInt ([view frame].size.height - p.y); } -static int getModifierForButtonNumber (const int num) +static int getModifierForButtonNumber (const NSInteger num) { return num == 0 ? ModifierKeys::leftButtonModifier : (num == 1 ? ModifierKeys::rightButtonModifier @@ -1268,8 +1268,8 @@ void NSViewComponentPeer::redirectMouseWheel (NSEvent* ev) { updateModifiers (ev); - handleMouseWheel (roundFloatToInt ([ev deltaX] * 10.0f), - roundFloatToInt ([ev deltaY] * 10.0f), + handleMouseWheel (roundToInt ([ev deltaX] * 10.0f), + roundToInt ([ev deltaY] * 10.0f), getMouseTime (ev)); } @@ -1346,7 +1346,7 @@ void NSViewComponentPeer::drawRect (NSRect r) #if USE_COREGRAPHICS_RENDERING if (usingCoreGraphics) { - CoreGraphicsContext context (cg, [view frame].size.height); + CoreGraphicsContext context (cg, (float) [view frame].size.height); insideDrawRect = true; handlePaint (context); @@ -1361,8 +1361,8 @@ void NSViewComponentPeer::drawRect (NSRect r) ! getComponent()->isOpaque()); LowLevelGraphicsSoftwareRenderer context (temp); - context.setOrigin (-roundFloatToInt (r.origin.x), - -roundFloatToInt ([view frame].size.height - (r.origin.y + r.size.height))); + context.setOrigin (-roundToInt (r.origin.x), + -roundToInt ([view frame].size.height - (r.origin.y + r.size.height))); const NSRect* rects = 0; NSInteger numRects = 0; @@ -1371,10 +1371,10 @@ void NSViewComponentPeer::drawRect (NSRect r) RectangleList clip; for (int i = 0; i < numRects; ++i) { - clip.addWithoutMerging (Rectangle (roundFloatToInt (rects[i].origin.x), - roundFloatToInt ([view frame].size.height - (rects[i].origin.y + rects[i].size.height)), - roundFloatToInt (rects[i].size.width), - roundFloatToInt (rects[i].size.height))); + clip.addWithoutMerging (Rectangle (roundToInt (rects[i].origin.x), + roundToInt ([view frame].size.height - (rects[i].origin.y + rects[i].size.height)), + roundToInt (rects[i].size.width), + roundToInt (rects[i].size.height))); } if (context.clipToRectangleList (clip)) diff --git a/src/native/mac/juce_mac_Network.mm b/src/native/mac/juce_mac_Network.mm index 36786f9e4b..ed191d26bd 100644 --- a/src/native/mac/juce_mac_Network.mm +++ b/src/native/mac/juce_mac_Network.mm @@ -206,7 +206,7 @@ public: while (runLoopThread->isThreadRunning() && ! initialised) { if (callback != 0) - callback (context, -1, [[request HTTPBody] length]); + callback (context, -1, (int) [[request HTTPBody] length]); Thread::sleep (1); } @@ -283,7 +283,7 @@ public: while (numNeeded > 0) { - int available = jmin (numNeeded, [data length]); + int available = jmin (numNeeded, (int) [data length]); if (available > 0) { diff --git a/src/native/mac/juce_mac_QuickTimeMovieComponent.mm b/src/native/mac/juce_mac_QuickTimeMovieComponent.mm index 35543b945a..055eca8b2a 100644 --- a/src/native/mac/juce_mac_QuickTimeMovieComponent.mm +++ b/src/native/mac/juce_mac_QuickTimeMovieComponent.mm @@ -289,8 +289,8 @@ void QuickTimeMovieComponent::setBoundsWithCorrectAspectRatio (const Rectangle& if (w > 0 && h > 0) { - setBounds (roundDoubleToInt (x), roundDoubleToInt (y), - roundDoubleToInt (w), roundDoubleToInt (h)); + setBounds (roundToInt (x), roundToInt (y), + roundToInt (w), roundToInt (h)); } } else diff --git a/src/native/mac/juce_mac_SystemStats.mm b/src/native/mac/juce_mac_SystemStats.mm index 69791278b3..bdde1fc6d8 100644 --- a/src/native/mac/juce_mac_SystemStats.mm +++ b/src/native/mac/juce_mac_SystemStats.mm @@ -212,7 +212,7 @@ int SystemStats::getCpuSpeedInMegaherz() throw() int SystemStats::getNumCpus() throw() { #if JUCE_IPHONE || (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5) - return [[NSProcessInfo processInfo] activeProcessorCount]; + return (int) [[NSProcessInfo processInfo] activeProcessorCount]; #else return MPProcessors(); #endif @@ -253,7 +253,7 @@ bool Time::setSystemTimeToThisTime() const throw() //============================================================================== int SystemStats::getPageSize() throw() { - return NSPageSize(); + return (int) NSPageSize(); } void PlatformUtilities::fpuReset() diff --git a/src/native/windows/juce_win32_ASIO.cpp b/src/native/windows/juce_win32_ASIO.cpp index 54c3ffdcb4..ca3390fd06 100644 --- a/src/native/windows/juce_win32_ASIO.cpp +++ b/src/native/windows/juce_win32_ASIO.cpp @@ -454,7 +454,7 @@ public: Array types; currentBitDepth = 16; - for (i = 0; i < jmin (totalNumInputChans, maxASIOChannels); ++i) + for (i = 0; i < jmin ((int) totalNumInputChans, maxASIOChannels); ++i) { if (inputChannels[i]) { @@ -483,7 +483,7 @@ public: jassert (numActiveInputChans == n); n = 0; - for (i = 0; i < jmin (totalNumOutputChans, maxASIOChannels); ++i) + for (i = 0; i < jmin ((int) totalNumOutputChans, maxASIOChannels); ++i) { if (outputChannels[i]) { @@ -978,7 +978,7 @@ private: { granularity = jmax (1, (int) granularity); - for (int i = jmax (minSize, (int) granularity); i < jmin (6400, maxSize); i += granularity) + for (int i = jmax ((int) minSize, (int) granularity); i < jmin (6400, (int) maxSize); i += granularity) bufferSizes.addIfNotAlreadyThere (granularity * (i / granularity)); } else if (granularity < 0) @@ -1037,7 +1037,7 @@ private: ASIOBufferInfo* info = bufferInfos; int i, numChans = 0; - for (i = 0; i < jmin (2, totalNumInputChans); ++i) + for (i = 0; i < jmin (2, (int) totalNumInputChans); ++i) { info->isInput = 1; info->channelNum = i; @@ -1048,7 +1048,7 @@ private: const int outputBufferIndex = numChans; - for (i = 0; i < jmin (2, totalNumOutputChans); ++i) + for (i = 0; i < jmin (2, (int) totalNumOutputChans); ++i) { info->isInput = 0; info->channelNum = i; diff --git a/src/native/windows/juce_win32_CameraDevice.cpp b/src/native/windows/juce_win32_CameraDevice.cpp index 40da4ef930..228ca927f7 100644 --- a/src/native/windows/juce_win32_CameraDevice.cpp +++ b/src/native/windows/juce_win32_CameraDevice.cpp @@ -240,8 +240,8 @@ public: RectanglePlacement rp (RectanglePlacement::centred); double dx = 0, dy = 0, dw = width, dh = height; rp.applyTo (dx, dy, dw, dh, x, y, w, h); - const int rx = roundDoubleToInt (dx), ry = roundDoubleToInt (dy); - const int rw = roundDoubleToInt (dw), rh = roundDoubleToInt (dh); + const int rx = roundToInt (dx), ry = roundToInt (dy); + const int rw = roundToInt (dw), rh = roundToInt (dh); g.saveState(); g.excludeClipRegion (rx, ry, rw, rh); diff --git a/src/native/windows/juce_win32_DirectSound.cpp b/src/native/windows/juce_win32_DirectSound.cpp index a3b153174c..42fae39fcb 100644 --- a/src/native/windows/juce_win32_DirectSound.cpp +++ b/src/native/windows/juce_win32_DirectSound.cpp @@ -537,7 +537,7 @@ public: { while (--samples1 >= 0) { - int r = roundFloatToInt (gainR * *right++); + int r = roundToInt (gainR * *right++); if (r < -32768) r = -32768; @@ -551,7 +551,7 @@ public: while (--samples2 >= 0) { - int r = roundFloatToInt (gainR * *right++); + int r = roundToInt (gainR * *right++); if (r < -32768) r = -32768; @@ -565,7 +565,7 @@ public: { while (--samples1 >= 0) { - int l = roundFloatToInt (gainL * *left++); + int l = roundToInt (gainL * *left++); if (l < -32768) l = -32768; @@ -581,7 +581,7 @@ public: while (--samples2 >= 0) { - int l = roundFloatToInt (gainL * *left++); + int l = roundToInt (gainL * *left++); if (l < -32768) l = -32768; @@ -597,7 +597,7 @@ public: { while (--samples1 >= 0) { - int l = roundFloatToInt (gainL * *left++); + int l = roundToInt (gainL * *left++); if (l < -32768) l = -32768; @@ -606,7 +606,7 @@ public: l &= 0xffff; - int r = roundFloatToInt (gainR * *right++); + int r = roundToInt (gainR * *right++); if (r < -32768) r = -32768; @@ -620,7 +620,7 @@ public: while (--samples2 >= 0) { - int l = roundFloatToInt (gainL * *left++); + int l = roundToInt (gainL * *left++); if (l < -32768) l = -32768; @@ -629,7 +629,7 @@ public: l &= 0xffff; - int r = roundFloatToInt (gainR * *right++); + int r = roundToInt (gainR * *right++); if (r < -32768) r = -32768; diff --git a/src/native/windows/juce_win32_FileChooser.cpp b/src/native/windows/juce_win32_FileChooser.cpp index e96338c719..6453d271f2 100644 --- a/src/native/windows/juce_win32_FileChooser.cpp +++ b/src/native/windows/juce_win32_FileChooser.cpp @@ -83,8 +83,8 @@ static UINT_PTR CALLBACK openCallback (HWND hdlg, UINT uiMsg, WPARAM /*wParam*/, SetWindowPos (dialogH, 0, r.left, r.top, - currentExtraFileWin->getWidth() + jmax (150, r.right - r.left), - jmax (150, r.bottom - r.top), + currentExtraFileWin->getWidth() + jmax (150, (int) (r.right - r.left)), + jmax (150, (int) (r.bottom - r.top)), SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER); currentExtraFileWin->setBounds (cr.right, cr.top, currentExtraFileWin->getWidth(), cr.bottom - cr.top); diff --git a/src/native/windows/juce_win32_Network.cpp b/src/native/windows/juce_win32_Network.cpp index b671c0b1bd..b6522f2251 100644 --- a/src/native/windows/juce_win32_Network.cpp +++ b/src/native/windows/juce_win32_Network.cpp @@ -141,7 +141,7 @@ void* juce_openInternetFile (const String& url, for (;;) { - const int bytesToDo = jmin (1024, postData.getSize() - bytesSent); + const int bytesToDo = jmin (1024, (int) postData.getSize() - bytesSent); DWORD bytesDone = 0; if (bytesToDo > 0 diff --git a/src/native/windows/juce_win32_QuickTimeMovieComponent.cpp b/src/native/windows/juce_win32_QuickTimeMovieComponent.cpp index d979df1bf9..1de47d9d15 100644 --- a/src/native/windows/juce_win32_QuickTimeMovieComponent.cpp +++ b/src/native/windows/juce_win32_QuickTimeMovieComponent.cpp @@ -497,8 +497,8 @@ void QuickTimeMovieComponent::setBoundsWithCorrectAspectRatio (const Rectangle& if (w > 0 && h > 0) { - setBounds (roundDoubleToInt (x), roundDoubleToInt (y), - roundDoubleToInt (w), roundDoubleToInt (h)); + setBounds (roundToInt (x), roundToInt (y), + roundToInt (w), roundToInt (h)); } } else diff --git a/src/native/windows/juce_win32_WASAPI.cpp b/src/native/windows/juce_win32_WASAPI.cpp index 3b97e94abc..25aa8b0ac8 100644 --- a/src/native/windows/juce_win32_WASAPI.cpp +++ b/src/native/windows/juce_win32_WASAPI.cpp @@ -444,7 +444,7 @@ public: if (samplesToDo < numSamplesAvailable) { - reservoirSize = jmin (numSamplesAvailable - samplesToDo, reservoirCapacity); + reservoirSize = jmin ((int) (numSamplesAvailable - samplesToDo), reservoirCapacity); memcpy ((uint8*) reservoir.getData(), inputData + bytesPerSample * actualNumChannels * samplesToDo, bytesPerSample * actualNumChannels * reservoirSize); } diff --git a/src/native/windows/juce_win32_Windowing.cpp b/src/native/windows/juce_win32_Windowing.cpp index 93dce5c622..57eb72138c 100644 --- a/src/native/windows/juce_win32_Windowing.cpp +++ b/src/native/windows/juce_win32_Windowing.cpp @@ -1208,7 +1208,7 @@ private: while (--num >= 0) { // (need to move this one pixel to the left because of a win32 bug) - const int cx = jmax (x, rects->left - 1); + const int cx = jmax (x, (int) rects->left - 1); const int cy = rects->top; const int cw = rects->right - cx; const int ch = rects->bottom - rects->top; @@ -2453,11 +2453,11 @@ void juce_updateMultiMonitorInfo (Array & monitorCoords, const bool c Rectangle& screen = monitorCoords.getReference (0); - screen.setPosition (jmax (screen.getX(), r.left), - jmax (screen.getY(), r.top)); + screen.setPosition (jmax (screen.getX(), (int) r.left), + jmax (screen.getY(), (int) r.top)); - screen.setSize (jmin (screen.getRight(), r.right) - screen.getX(), - jmin (screen.getBottom(), r.bottom) - screen.getY()); + screen.setSize (jmin (screen.getRight(), (int) r.right) - screen.getX(), + jmin (screen.getBottom(), (int) r.bottom) - screen.getY()); } } diff --git a/src/text/juce_String.cpp b/src/text/juce_String.cpp index 67883c6798..64eb7cfa30 100644 --- a/src/text/juce_String.cpp +++ b/src/text/juce_String.cpp @@ -216,10 +216,10 @@ String::String (const juce_wchar* const t) throw() } String::String (const char* const t, - const int maxChars) throw() + const size_t maxChars) throw() { int i; - for (i = 0; i < maxChars; ++i) + for (i = 0; (size_t) i < maxChars; ++i) if (t[i] == 0) break; @@ -243,10 +243,10 @@ String::String (const char* const t, } String::String (const juce_wchar* const t, - const int maxChars) throw() + const size_t maxChars) throw() { int i; - for (i = 0; i < maxChars; ++i) + for (i = 0; (size_t) i < maxChars; ++i) if (t[i] == 0) break; @@ -466,15 +466,15 @@ String::~String() throw() } //============================================================================== -void String::preallocateStorage (const int numChars) throw() +void String::preallocateStorage (const size_t numChars) throw() { - if (numChars > text->allocatedNumChars) + if (numChars > (size_t) text->allocatedNumChars) { dupeInternalIfMultiplyReferenced(); text = (InternalRefCountedStringHolder*) juce_realloc (text, sizeof (InternalRefCountedStringHolder) + numChars * sizeof (tchar)); - text->allocatedNumChars = numChars; + text->allocatedNumChars = (int) numChars; } } @@ -2224,15 +2224,15 @@ const String String::fromUTF8 (const uint8* const buffer, int bufferSizeBytes) t if (bufferSizeBytes < 0) bufferSizeBytes = INT_MAX; - int numBytes; - for (numBytes = 0; numBytes < bufferSizeBytes; ++numBytes) + size_t numBytes; + for (numBytes = 0; numBytes < (size_t) bufferSizeBytes; ++numBytes) if (buffer [numBytes] == 0) break; - String result (numBytes + 1, 0); + String result ((int) numBytes + 1, 0); tchar* dest = result.text->text; - int i = 0; + size_t i = 0; while (i < numBytes) { const uint8 c = buffer [i++]; @@ -2252,7 +2252,7 @@ const String String::fromUTF8 (const uint8* const buffer, int bufferSizeBytes) t int n = (c & mask); - while (--numExtraValues >= 0 && i < bufferSizeBytes) + while (--numExtraValues >= 0 && i < (size_t) bufferSizeBytes) { const uint8 nextByte = buffer[i]; diff --git a/src/text/juce_String.h b/src/text/juce_String.h index 488cb0427d..4940142bc1 100644 --- a/src/text/juce_String.h +++ b/src/text/juce_String.h @@ -64,7 +64,7 @@ public: less if the string is actually shorter) */ String (const char* const text, - const int maxChars) throw(); + const size_t maxChars) throw(); /** Creates a string from a zero-terminated unicode text string. */ String (const juce_wchar* const unicodeText) throw(); @@ -75,7 +75,7 @@ public: less if the string is actually shorter) */ String (const juce_wchar* const unicodeText, - const int maxChars) throw(); + const size_t maxChars) throw(); /** Creates a string from a single character. */ static const String charToString (const tchar character) throw(); @@ -1065,7 +1065,7 @@ public: value is less than the currently allocated size, it will have no effect. */ - void preallocateStorage (const int numCharsNeeded) throw(); + void preallocateStorage (const size_t numCharsNeeded) throw(); //============================================================================== /** A helper class to improve performance when concatenating many large strings diff --git a/src/text/juce_XmlDocument.cpp b/src/text/juce_XmlDocument.cpp index 294a88f51e..4eefa24ef2 100644 --- a/src/text/juce_XmlDocument.cpp +++ b/src/text/juce_XmlDocument.cpp @@ -90,11 +90,11 @@ XmlElement* XmlDocument::getDocumentElement (const bool onlyReadOuterDocumentEle && ((data[0] == (char)-2 && data[1] == (char)-1) || (data[0] == (char)-1 && data[1] == (char)-2))) { - textToParse = String::createStringFromData ((const char*) data.getData(), data.getSize()); + textToParse = String::createStringFromData ((const char*) data.getData(), (int) data.getSize()); } else { - textToParse = String::fromUTF8 ((const uint8*) data.getData(), data.getSize()); + textToParse = String::fromUTF8 ((const uint8*) data.getData(), (int) data.getSize()); } if (! onlyReadOuterDocumentElement) diff --git a/src/threads/juce_InterProcessLock.h b/src/threads/juce_InterProcessLock.h index c014d8c332..cc0d0b5c86 100644 --- a/src/threads/juce_InterProcessLock.h +++ b/src/threads/juce_InterProcessLock.h @@ -75,8 +75,8 @@ private: //============================================================================== #if JUCE_WINDOWS void* internal; - #elif JUCE_64BIT - long long internal; +// #elif JUCE_64BIT + // long long internal; #else int internal; #endif