Browse Source

Added a method to BitArray, fixed a memory leak at shutdown on the mac, and tidied up some whitespace.

tags/2021-05-28
jules 16 years ago
parent
commit
013bc3016b
17 changed files with 3149 additions and 3098 deletions
  1. +3
    -3
      build/macosx/platform_specific_code/juce_mac_Files.mm
  2. +1
    -1
      build/macosx/platform_specific_code/juce_mac_WebBrowserComponent.mm
  3. +35
    -18
      juce_amalgamated.cpp
  4. +9
    -1
      juce_amalgamated.h
  5. +2
    -2
      src/juce_appframework/audio/audio_file_formats/juce_WavAudioFormat.cpp
  6. +1
    -1
      src/juce_appframework/audio/audio_file_formats/juce_WavAudioFormat.h
  7. +1
    -1
      src/juce_appframework/audio/plugins/formats/juce_AudioUnitPluginFormat.mm
  8. +3044
    -3044
      src/juce_appframework/audio/plugins/formats/juce_VSTPluginFormat.cpp
  9. +3
    -2
      src/juce_appframework/events/juce_MessageManager.cpp
  10. +1
    -1
      src/juce_appframework/gui/components/buttons/juce_ImageButton.cpp
  11. +2
    -2
      src/juce_appframework/gui/components/controls/juce_TreeView.cpp
  12. +1
    -1
      src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.cpp
  13. +32
    -15
      src/juce_core/containers/juce_BitArray.cpp
  14. +9
    -1
      src/juce_core/containers/juce_BitArray.h
  15. +3
    -3
      src/juce_core/cryptography/juce_MD5.h
  16. +1
    -1
      src/juce_core/io/files/juce_File.cpp
  17. +1
    -1
      src/juce_core/text/juce_String.h

+ 3
- 3
build/macosx/platform_specific_code/juce_mac_Files.mm View File

@@ -206,7 +206,7 @@ bool File::isOnRemovableDrive() const throw()
{
const ScopedAutoReleasePool pool;
BOOL removable = false;
[[NSWorkspace sharedWorkspace]
getFileSystemInfoForPath: juceStringToNS (getFullPathName())
isRemovable: &removable
@@ -347,11 +347,11 @@ const String File::getVersion() const throw()
String result;
NSBundle* bundle = [NSBundle bundleWithPath: juceStringToNS (getFullPathName())];
if (bundle != 0)
{
NSDictionary* info = [bundle infoDictionary];
if (info != 0)
{
NSString* name = [info valueForKey: @"CFBundleShortVersionString"];


+ 1
- 1
build/macosx/platform_specific_code/juce_mac_WebBrowserComponent.mm View File

@@ -147,7 +147,7 @@ public:
{
[webView stopLoading: nil];
}
void refresh()
{
[webView reload: nil];


+ 35
- 18
juce_amalgamated.cpp View File

@@ -602,7 +602,6 @@
#import <IOKit/network/IONetworkInterface.h>
#import <IOKit/network/IOEthernetController.h>
#import <IOKit/pwr_mgt/IOPMLib.h>
#import <SystemConfiguration/SCDynamicStore.h>

#include <sys/sysctl.h>
#include <sys/stat.h>
@@ -2640,32 +2639,49 @@ void BitArray::shiftBits (int bits, const int startBit) throw()
}
}

const BitArray BitArray::getBitRange (int startBit, int numBits) const throw()
{
BitArray r;
numBits = jmin (numBits, getHighestBit() + 1 - startBit);
r.ensureSize (numBits >> 5);
r.highestBit = numBits;

int i = 0;
while (numBits > 0)
{
r.values[i++] = getBitRangeAsInt (startBit, jmin (32, numBits));
numBits -= 32;
startBit += 32;
}

r.highestBit = r.getHighestBit();

return r;
}

int BitArray::getBitRangeAsInt (const int startBit, int numBits) const throw()
{
if (numBits > 32)
{
jassertfalse
jassertfalse // use getBitRange() if you need more than 32 bits..
numBits = 32;
}

if (startBit == 0)
{
if (numBits < 32)
return values[0] & ((1 << numBits) - 1);
numBits = jmin (numBits, highestBit + 1 - startBit);

return values[0];
}
if (numBits <= 0)
return 0;

int n = 0;
for (int i = numBits; --i >= 0;)
{
n <<= 1;
const int pos = startBit >> 5;
const int offset = startBit & 31;
const int endSpace = 32 - numBits;

if (operator[] (startBit + i))
n |= 1;
}
uint32 n = ((uint32) values [pos]) >> offset;

return n;
if (offset > endSpace)
n |= ((uint32) values [pos + 1]) << (32 - offset);

return (int) (n & (((uint32) 0xffffffff) >> endSpace));
}

void BitArray::setBitRangeAsInt (const int startBit, int numBits, unsigned int valueToSet) throw()
@@ -36725,11 +36741,12 @@ MessageManager::MessageManager() throw()

MessageManager::~MessageManager() throw()
{
jassert (instance == this);
instance = 0;
deleteAndZero (broadcastListeners);

doPlatformSpecificShutdown();

jassert (instance == this);
instance = 0; // do this last in case this instance is still needed by doPlatformSpecificShutdown()
}

MessageManager* MessageManager::getInstance() throw()


+ 9
- 1
juce_amalgamated.h View File

@@ -7139,11 +7139,19 @@ public:
/** Returns true if no bits are set. */
bool isEmpty() const throw();

/** Returns a range of bits in the array as a new BitArray.

e.g. getBitRangeAsInt (0, 64) would return the lowest 64 bits.
@see getBitRangeAsInt
*/
const BitArray getBitRange (int startBit, int numBits) const throw();

/** Returns a range of bits in the array as an integer value.

e.g. getBitRangeAsInt (0, 32) would return the lowest 32 bits.

Asking for more than 32 bits isn't allowed (obviously).
Asking for more than 32 bits isn't allowed (obviously) - for that, use
getBitRange().
*/
int getBitRangeAsInt (int startBit, int numBits) const throw();



+ 2
- 2
src/juce_appframework/audio/audio_file_formats/juce_WavAudioFormat.cpp View File

@@ -776,8 +776,8 @@ static bool juce_slowCopyOfWavFileWithNewMetadata (const File& file, const Strin
if (reader != 0)
{
AudioFormatWriter* writer = wav.createWriterFor (outStream, reader->sampleRate,
reader->numChannels, reader->bitsPerSample,
AudioFormatWriter* writer = wav.createWriterFor (outStream, reader->sampleRate,
reader->numChannels, reader->bitsPerSample,
metadata, 0);
if (writer != 0)


+ 1
- 1
src/juce_appframework/audio/audio_file_formats/juce_WavAudioFormat.h View File

@@ -144,7 +144,7 @@ public:
//==============================================================================
/** Utility function to replace the metadata in a wav file with a new set of values.
If possible, this cheats by overwriting just the metadata region of the file, rather
If possible, this cheats by overwriting just the metadata region of the file, rather
than by copying the whole file again.
*/
bool replaceMetadataInFile (const File& wavFile, const StringPairArray& newMetadata);


+ 1
- 1
src/juce_appframework/audio/plugins/formats/juce_AudioUnitPluginFormat.mm View File

@@ -54,7 +54,7 @@ BEGIN_JUCE_NAMESPACE
#include "../../../../juce_appframework/gui/components/layout/juce_ComponentMovementWatcher.h"
#include "../../../../juce_appframework/gui/components/special/juce_NSViewComponent.h"
#if JUCE_MAC && JUCE_SUPPORT_CARBON
#include "../../../../../build/macosx/platform_specific_code/juce_mac_CarbonViewWrapperComponent.h"
#include "../../../../../build/macosx/platform_specific_code/juce_mac_CarbonViewWrapperComponent.h"
#endif
#if JUCE_MAC


+ 3044
- 3044
src/juce_appframework/audio/plugins/formats/juce_VSTPluginFormat.cpp
File diff suppressed because it is too large
View File


+ 3
- 2
src/juce_appframework/events/juce_MessageManager.cpp View File

@@ -62,11 +62,12 @@ MessageManager::MessageManager() throw()
MessageManager::~MessageManager() throw()
{
jassert (instance == this);
instance = 0;
deleteAndZero (broadcastListeners);
doPlatformSpecificShutdown();
jassert (instance == this);
instance = 0; // do this last in case this instance is still needed by doPlatformSpecificShutdown()
}
MessageManager* MessageManager::getInstance() throw()


+ 1
- 1
src/juce_appframework/gui/components/buttons/juce_ImageButton.cpp View File

@@ -215,7 +215,7 @@ void ImageButton::paintButton (Graphics& g,
imageH = ih;
}
getLookAndFeel().drawImageButton (g, im, imageX, imageY, imageW, imageH,
getLookAndFeel().drawImageButton (g, im, imageX, imageY, imageW, imageH,
isButtonDown ? downOverlay
: (isMouseOverButton ? overOverlay
: normalOverlay),


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

@@ -591,9 +591,9 @@ void TreeView::moveSelectedRow (int delta)
{
if (! item->canBeSelected())
{
// if the row we want to highlight doesn't allow it, try skipping
// if the row we want to highlight doesn't allow it, try skipping
// to the next item..
const int nextRowToTry = jlimit (0, getNumRowsInTree() - 1,
const int nextRowToTry = jlimit (0, getNumRowsInTree() - 1,
rowSelected + (delta < 0 ? -1 : 1));
if (rowSelected != nextRowToTry)


+ 1
- 1
src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.cpp View File

@@ -1632,7 +1632,7 @@ void LookAndFeel::drawImageButton (Graphics& g, Image* image,
{
g.setOpacity (imageOpacity);
g.drawImage (image, imageX, imageY, imageW, imageH,
g.drawImage (image, imageX, imageY, imageW, imageH,
0, 0, image->getWidth(), image->getHeight(), false);
}


+ 32
- 15
src/juce_core/containers/juce_BitArray.cpp View File

@@ -693,32 +693,49 @@ void BitArray::shiftBits (int bits, const int startBit) throw()
}
}
const BitArray BitArray::getBitRange (int startBit, int numBits) const throw()
{
BitArray r;
numBits = jmin (numBits, getHighestBit() + 1 - startBit);
r.ensureSize (numBits >> 5);
r.highestBit = numBits;
int i = 0;
while (numBits > 0)
{
r.values[i++] = getBitRangeAsInt (startBit, jmin (32, numBits));
numBits -= 32;
startBit += 32;
}
r.highestBit = r.getHighestBit();
return r;
}
int BitArray::getBitRangeAsInt (const int startBit, int numBits) const throw()
{
if (numBits > 32)
{
jassertfalse
jassertfalse // use getBitRange() if you need more than 32 bits..
numBits = 32;
}
if (startBit == 0)
{
if (numBits < 32)
return values[0] & ((1 << numBits) - 1);
numBits = jmin (numBits, highestBit + 1 - startBit);
return values[0];
}
if (numBits <= 0)
return 0;
int n = 0;
for (int i = numBits; --i >= 0;)
{
n <<= 1;
const int pos = startBit >> 5;
const int offset = startBit & 31;
const int endSpace = 32 - numBits;
if (operator[] (startBit + i))
n |= 1;
}
uint32 n = ((uint32) values [pos]) >> offset;
if (offset > endSpace)
n |= ((uint32) values [pos + 1]) << (32 - offset);
return n;
return (int) (n & (((uint32) 0xffffffff) >> endSpace));
}
void BitArray::setBitRangeAsInt (const int startBit, int numBits, unsigned int valueToSet) throw()


+ 9
- 1
src/juce_core/containers/juce_BitArray.h View File

@@ -128,11 +128,19 @@ public:
bool isEmpty() const throw();
//==============================================================================
/** Returns a range of bits in the array as a new BitArray.
e.g. getBitRangeAsInt (0, 64) would return the lowest 64 bits.
@see getBitRangeAsInt
*/
const BitArray getBitRange (int startBit, int numBits) const throw();
/** Returns a range of bits in the array as an integer value.
e.g. getBitRangeAsInt (0, 32) would return the lowest 32 bits.
Asking for more than 32 bits isn't allowed (obviously).
Asking for more than 32 bits isn't allowed (obviously) - for that, use
getBitRange().
*/
int getBitRangeAsInt (int startBit, int numBits) const throw();


+ 3
- 3
src/juce_core/cryptography/juce_MD5.h View File

@@ -69,9 +69,9 @@ public:
/** Creates a checksum for a string.
Note that this operates on the string as a block of unicode characters, so the
result you get will differ from the value you'd get if the string was treated
as a block of utf8 or ascii. Bear this in mind if you're comparing the result
of this method with a checksum created by a different framework, which may have
result you get will differ from the value you'd get if the string was treated
as a block of utf8 or ascii. Bear this in mind if you're comparing the result
of this method with a checksum created by a different framework, which may have
used a different encoding.
*/
MD5 (const String& text);


+ 1
- 1
src/juce_core/io/files/juce_File.cpp View File

@@ -770,7 +770,7 @@ bool File::containsSubDirectories() const throw()
String filename;
bool isDirectory, isHidden;
void* const handle = juce_findFileStart (juce_addTrailingSeparator (fullPath),
T("*"), filename,
T("*"), filename,
&isDirectory, &isHidden, 0, 0, 0, 0);
if (handle != 0)


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

@@ -1006,7 +1006,7 @@ public:
@param maxBufferSizeBytes the size of the destination buffer, in bytes. If the
string won't fit, it'll put in as many as it can while
still allowing for a terminating null char at the end,
and will return the number of bytes that were actually
and will return the number of bytes that were actually
used. If this value is < 0, no limit is used.
*/
int copyToUTF8 (uint8* const destBuffer, const int maxBufferSizeBytes = 0x7fffffff) const throw();


Loading…
Cancel
Save