mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Minor clean-ups.
This commit is contained in:
parent
6bcc8febca
commit
419aac8074
58 changed files with 656 additions and 743 deletions
|
|
@ -66,127 +66,127 @@ BEGIN_JUCE_NAMESPACE
|
|||
#define log(a)
|
||||
#endif
|
||||
|
||||
static int insideCallback = 0;
|
||||
|
||||
//==============================================================================
|
||||
static const String osTypeToString (OSType type)
|
||||
namespace AudioUnitFormatHelpers
|
||||
{
|
||||
char s[4];
|
||||
s[0] = (char) (((uint32) type) >> 24);
|
||||
s[1] = (char) (((uint32) type) >> 16);
|
||||
s[2] = (char) (((uint32) type) >> 8);
|
||||
s[3] = (char) ((uint32) type);
|
||||
return String (s, 4);
|
||||
}
|
||||
static int insideCallback = 0;
|
||||
|
||||
static OSType stringToOSType (const String& s1)
|
||||
{
|
||||
const String s (s1 + " ");
|
||||
|
||||
return (((OSType) (unsigned char) s[0]) << 24)
|
||||
| (((OSType) (unsigned char) s[1]) << 16)
|
||||
| (((OSType) (unsigned char) s[2]) << 8)
|
||||
| ((OSType) (unsigned char) s[3]);
|
||||
}
|
||||
|
||||
static const char* auIdentifierPrefix = "AudioUnit:";
|
||||
|
||||
static const String createAUPluginIdentifier (const ComponentDescription& desc)
|
||||
{
|
||||
jassert (osTypeToString ('abcd') == "abcd"); // agh, must have got the endianness wrong..
|
||||
jassert (stringToOSType ("abcd") == (OSType) 'abcd'); // ditto
|
||||
|
||||
String s (auIdentifierPrefix);
|
||||
|
||||
if (desc.componentType == kAudioUnitType_MusicDevice)
|
||||
s << "Synths/";
|
||||
else if (desc.componentType == kAudioUnitType_MusicEffect
|
||||
|| desc.componentType == kAudioUnitType_Effect)
|
||||
s << "Effects/";
|
||||
else if (desc.componentType == kAudioUnitType_Generator)
|
||||
s << "Generators/";
|
||||
else if (desc.componentType == kAudioUnitType_Panner)
|
||||
s << "Panners/";
|
||||
|
||||
s << osTypeToString (desc.componentType) << ","
|
||||
<< osTypeToString (desc.componentSubType) << ","
|
||||
<< osTypeToString (desc.componentManufacturer);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
static void getAUDetails (ComponentRecord* comp, String& name, String& manufacturer)
|
||||
{
|
||||
Handle componentNameHandle = NewHandle (sizeof (void*));
|
||||
Handle componentInfoHandle = NewHandle (sizeof (void*));
|
||||
|
||||
if (componentNameHandle != 0 && componentInfoHandle != 0)
|
||||
static const String osTypeToString (OSType type)
|
||||
{
|
||||
ComponentDescription desc;
|
||||
|
||||
if (GetComponentInfo (comp, &desc, componentNameHandle, componentInfoHandle, 0) == noErr)
|
||||
{
|
||||
ConstStr255Param nameString = (ConstStr255Param) (*componentNameHandle);
|
||||
ConstStr255Param infoString = (ConstStr255Param) (*componentInfoHandle);
|
||||
|
||||
if (nameString != 0 && nameString[0] != 0)
|
||||
{
|
||||
const String all ((const char*) nameString + 1, nameString[0]);
|
||||
DBG ("name: "+ all);
|
||||
|
||||
manufacturer = all.upToFirstOccurrenceOf (":", false, false).trim();
|
||||
name = all.fromFirstOccurrenceOf (":", false, false).trim();
|
||||
}
|
||||
|
||||
if (infoString != 0 && infoString[0] != 0)
|
||||
{
|
||||
DBG ("info: " + String ((const char*) infoString + 1, infoString[0]));
|
||||
}
|
||||
|
||||
if (name.isEmpty())
|
||||
name = "<Unknown>";
|
||||
}
|
||||
|
||||
DisposeHandle (componentNameHandle);
|
||||
DisposeHandle (componentInfoHandle);
|
||||
char s[4];
|
||||
s[0] = (char) (((uint32) type) >> 24);
|
||||
s[1] = (char) (((uint32) type) >> 16);
|
||||
s[2] = (char) (((uint32) type) >> 8);
|
||||
s[3] = (char) ((uint32) type);
|
||||
return String (s, 4);
|
||||
}
|
||||
}
|
||||
|
||||
static bool getComponentDescFromIdentifier (const String& fileOrIdentifier, ComponentDescription& desc,
|
||||
String& name, String& version, String& manufacturer)
|
||||
{
|
||||
zerostruct (desc);
|
||||
|
||||
if (fileOrIdentifier.startsWithIgnoreCase (auIdentifierPrefix))
|
||||
static OSType stringToOSType (const String& s1)
|
||||
{
|
||||
String s (fileOrIdentifier.substring (jmax (fileOrIdentifier.lastIndexOfChar (':'),
|
||||
fileOrIdentifier.lastIndexOfChar ('/')) + 1));
|
||||
const String s (s1 + " ");
|
||||
|
||||
StringArray tokens;
|
||||
tokens.addTokens (s, ",", String::empty);
|
||||
tokens.trim();
|
||||
tokens.removeEmptyStrings();
|
||||
return (((OSType) (unsigned char) s[0]) << 24)
|
||||
| (((OSType) (unsigned char) s[1]) << 16)
|
||||
| (((OSType) (unsigned char) s[2]) << 8)
|
||||
| ((OSType) (unsigned char) s[3]);
|
||||
}
|
||||
|
||||
if (tokens.size() == 3)
|
||||
static const char* auIdentifierPrefix = "AudioUnit:";
|
||||
|
||||
static const String createAUPluginIdentifier (const ComponentDescription& desc)
|
||||
{
|
||||
jassert (osTypeToString ('abcd') == "abcd"); // agh, must have got the endianness wrong..
|
||||
jassert (stringToOSType ("abcd") == (OSType) 'abcd'); // ditto
|
||||
|
||||
String s (auIdentifierPrefix);
|
||||
|
||||
if (desc.componentType == kAudioUnitType_MusicDevice)
|
||||
s << "Synths/";
|
||||
else if (desc.componentType == kAudioUnitType_MusicEffect
|
||||
|| desc.componentType == kAudioUnitType_Effect)
|
||||
s << "Effects/";
|
||||
else if (desc.componentType == kAudioUnitType_Generator)
|
||||
s << "Generators/";
|
||||
else if (desc.componentType == kAudioUnitType_Panner)
|
||||
s << "Panners/";
|
||||
|
||||
s << osTypeToString (desc.componentType) << ","
|
||||
<< osTypeToString (desc.componentSubType) << ","
|
||||
<< osTypeToString (desc.componentManufacturer);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
static void getAUDetails (ComponentRecord* comp, String& name, String& manufacturer)
|
||||
{
|
||||
Handle componentNameHandle = NewHandle (sizeof (void*));
|
||||
Handle componentInfoHandle = NewHandle (sizeof (void*));
|
||||
|
||||
if (componentNameHandle != 0 && componentInfoHandle != 0)
|
||||
{
|
||||
desc.componentType = stringToOSType (tokens[0]);
|
||||
desc.componentSubType = stringToOSType (tokens[1]);
|
||||
desc.componentManufacturer = stringToOSType (tokens[2]);
|
||||
ComponentDescription desc;
|
||||
|
||||
ComponentRecord* comp = FindNextComponent (0, &desc);
|
||||
|
||||
if (comp != 0)
|
||||
if (GetComponentInfo (comp, &desc, componentNameHandle, componentInfoHandle, 0) == noErr)
|
||||
{
|
||||
getAUDetails (comp, name, manufacturer);
|
||||
ConstStr255Param nameString = (ConstStr255Param) (*componentNameHandle);
|
||||
ConstStr255Param infoString = (ConstStr255Param) (*componentInfoHandle);
|
||||
|
||||
return true;
|
||||
if (nameString != 0 && nameString[0] != 0)
|
||||
{
|
||||
const String all ((const char*) nameString + 1, nameString[0]);
|
||||
DBG ("name: "+ all);
|
||||
|
||||
manufacturer = all.upToFirstOccurrenceOf (":", false, false).trim();
|
||||
name = all.fromFirstOccurrenceOf (":", false, false).trim();
|
||||
}
|
||||
|
||||
if (infoString != 0 && infoString[0] != 0)
|
||||
{
|
||||
DBG ("info: " + String ((const char*) infoString + 1, infoString[0]));
|
||||
}
|
||||
|
||||
if (name.isEmpty())
|
||||
name = "<Unknown>";
|
||||
}
|
||||
|
||||
DisposeHandle (componentNameHandle);
|
||||
DisposeHandle (componentInfoHandle);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
static bool getComponentDescFromIdentifier (const String& fileOrIdentifier, ComponentDescription& desc,
|
||||
String& name, String& version, String& manufacturer)
|
||||
{
|
||||
zerostruct (desc);
|
||||
|
||||
if (fileOrIdentifier.startsWithIgnoreCase (auIdentifierPrefix))
|
||||
{
|
||||
String s (fileOrIdentifier.substring (jmax (fileOrIdentifier.lastIndexOfChar (':'),
|
||||
fileOrIdentifier.lastIndexOfChar ('/')) + 1));
|
||||
|
||||
StringArray tokens;
|
||||
tokens.addTokens (s, ",", String::empty);
|
||||
tokens.trim();
|
||||
tokens.removeEmptyStrings();
|
||||
|
||||
if (tokens.size() == 3)
|
||||
{
|
||||
desc.componentType = stringToOSType (tokens[0]);
|
||||
desc.componentSubType = stringToOSType (tokens[1]);
|
||||
desc.componentManufacturer = stringToOSType (tokens[2]);
|
||||
|
||||
ComponentRecord* comp = FindNextComponent (0, &desc);
|
||||
|
||||
if (comp != 0)
|
||||
{
|
||||
getAUDetails (comp, name, manufacturer);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
class AudioUnitPluginWindowCarbon;
|
||||
|
|
@ -205,7 +205,7 @@ public:
|
|||
void fillInPluginDescription (PluginDescription& desc) const
|
||||
{
|
||||
desc.name = pluginName;
|
||||
desc.fileOrIdentifier = createAUPluginIdentifier (componentDesc);
|
||||
desc.fileOrIdentifier = AudioUnitFormatHelpers::createAUPluginIdentifier (componentDesc);
|
||||
desc.uid = ((int) componentDesc.componentType)
|
||||
^ ((int) componentDesc.componentSubType)
|
||||
^ ((int) componentDesc.componentManufacturer);
|
||||
|
|
@ -375,6 +375,8 @@ AudioUnitPluginInstance::AudioUnitPluginInstance (const String& fileOrIdentifier
|
|||
audioUnit (0),
|
||||
currentBuffer (0)
|
||||
{
|
||||
using namespace AudioUnitFormatHelpers;
|
||||
|
||||
try
|
||||
{
|
||||
++insideCallback;
|
||||
|
|
@ -406,7 +408,7 @@ AudioUnitPluginInstance::~AudioUnitPluginInstance()
|
|||
{
|
||||
const ScopedLock sl (lock);
|
||||
|
||||
jassert (insideCallback == 0);
|
||||
jassert (AudioUnitFormatHelpers::insideCallback == 0);
|
||||
|
||||
if (audioUnit != 0)
|
||||
{
|
||||
|
|
@ -420,7 +422,7 @@ bool AudioUnitPluginInstance::getComponentDescFromFile (const String& fileOrIden
|
|||
{
|
||||
zerostruct (componentDesc);
|
||||
|
||||
if (getComponentDescFromIdentifier (fileOrIdentifier, componentDesc, pluginName, version, manufacturer))
|
||||
if (AudioUnitFormatHelpers::getComponentDescFromIdentifier (fileOrIdentifier, componentDesc, pluginName, version, manufacturer))
|
||||
return true;
|
||||
|
||||
const File file (fileOrIdentifier);
|
||||
|
|
@ -1469,7 +1471,7 @@ const StringArray AudioUnitPluginFormat::searchPathsForPlugins (const FileSearch
|
|||
|| desc.componentType == kAudioUnitType_Generator
|
||||
|| desc.componentType == kAudioUnitType_Panner)
|
||||
{
|
||||
const String s (createAUPluginIdentifier (desc));
|
||||
const String s (AudioUnitFormatHelpers::createAUPluginIdentifier (desc));
|
||||
DBG (s);
|
||||
result.add (s);
|
||||
}
|
||||
|
|
@ -1483,7 +1485,7 @@ bool AudioUnitPluginFormat::fileMightContainThisPluginType (const String& fileOr
|
|||
ComponentDescription desc;
|
||||
|
||||
String name, version, manufacturer;
|
||||
if (getComponentDescFromIdentifier (fileOrIdentifier, desc, name, version, manufacturer))
|
||||
if (AudioUnitFormatHelpers::getComponentDescFromIdentifier (fileOrIdentifier, desc, name, version, manufacturer))
|
||||
return FindNextComponent (0, &desc) != 0;
|
||||
|
||||
const File f (fileOrIdentifier);
|
||||
|
|
@ -1496,7 +1498,7 @@ const String AudioUnitPluginFormat::getNameOfPluginFromIdentifier (const String&
|
|||
{
|
||||
ComponentDescription desc;
|
||||
String name, version, manufacturer;
|
||||
getComponentDescFromIdentifier (fileOrIdentifier, desc, name, version, manufacturer);
|
||||
AudioUnitFormatHelpers::getComponentDescFromIdentifier (fileOrIdentifier, desc, name, version, manufacturer);
|
||||
|
||||
if (name.isEmpty())
|
||||
name = fileOrIdentifier;
|
||||
|
|
@ -1506,7 +1508,7 @@ const String AudioUnitPluginFormat::getNameOfPluginFromIdentifier (const String&
|
|||
|
||||
bool AudioUnitPluginFormat::doesPluginStillExist (const PluginDescription& desc)
|
||||
{
|
||||
if (desc.fileOrIdentifier.startsWithIgnoreCase (auIdentifierPrefix))
|
||||
if (desc.fileOrIdentifier.startsWithIgnoreCase (AudioUnitFormatHelpers::auIdentifierPrefix))
|
||||
return fileMightContainThisPluginType (desc.fileOrIdentifier);
|
||||
else
|
||||
return File (desc.fileOrIdentifier).exists();
|
||||
|
|
|
|||
|
|
@ -337,8 +337,7 @@ void MemoryBlock::loadFromHexString (const String& hex) throw()
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
static const char* const encodingTable
|
||||
= ".ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+";
|
||||
const char* const MemoryBlock::encodingTable = ".ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+";
|
||||
|
||||
const String MemoryBlock::toBase64Encoding() const throw()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -237,6 +237,7 @@ private:
|
|||
//==============================================================================
|
||||
HeapBlock <char> data;
|
||||
size_t size;
|
||||
static const char* const encodingTable;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_PropertySet.h"
|
||||
#include "../threads/juce_ScopedLock.h"
|
||||
#include "../text/juce_XmlDocument.h"
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_FileLogger.h"
|
||||
#include "../io/files/juce_FileOutputStream.h"
|
||||
#include "../io/files/juce_FileInputStream.h"
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ Logger::~Logger()
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
static Logger* currentLogger = 0;
|
||||
Logger* Logger::currentLogger = 0;
|
||||
|
||||
void Logger::setCurrentLogger (Logger* const newLogger,
|
||||
const bool deleteOldLogger)
|
||||
|
|
|
|||
|
|
@ -88,6 +88,9 @@ protected:
|
|||
@see setCurrentLogger
|
||||
*/
|
||||
virtual void logMessage (const String& message) = 0;
|
||||
|
||||
private:
|
||||
static Logger* currentLogger;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_PerformanceCounter.h"
|
||||
#include "juce_Time.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_RelativeTime.h"
|
||||
#include "../text/juce_LocalisedStrings.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ BEGIN_JUCE_NAMESPACE
|
|||
|
||||
|
||||
//==============================================================================
|
||||
SystemStats::CPUFlags SystemStats::cpuFlags;
|
||||
|
||||
const String SystemStats::getJUCEVersion()
|
||||
{
|
||||
return "JUCE v" + String (JUCE_MAJOR_VERSION)
|
||||
|
|
@ -121,6 +123,7 @@ static void juce_testAtomics()
|
|||
}
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
void JUCE_PUBLIC_FUNCTION initialiseJuce_NonGUI()
|
||||
{
|
||||
if (! juceInitialisedNonGUI)
|
||||
|
|
@ -194,36 +197,35 @@ void JUCE_PUBLIC_FUNCTION initialiseJuce_NonGUI()
|
|||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
#if JUCE_WINDOWS
|
||||
// This is imported from the sockets code..
|
||||
typedef int (__stdcall juce_CloseWin32SocketLibCall) (void);
|
||||
extern juce_CloseWin32SocketLibCall* juce_CloseWin32SocketLib;
|
||||
extern void juce_shutdownWin32Sockets(); // (defined in the sockets code)
|
||||
#endif
|
||||
|
||||
#if JUCE_DEBUG
|
||||
extern void juce_CheckForDanglingStreams();
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
void JUCE_PUBLIC_FUNCTION shutdownJuce_NonGUI()
|
||||
{
|
||||
if (juceInitialisedNonGUI)
|
||||
{
|
||||
#if JUCE_MAC || JUCE_IPHONE
|
||||
#if JUCE_MAC || JUCE_IPHONE
|
||||
const ScopedAutoReleasePool pool;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if JUCE_WINDOWS
|
||||
#if JUCE_WINDOWS
|
||||
// need to shut down sockets if they were used..
|
||||
if (juce_CloseWin32SocketLib != 0)
|
||||
(*juce_CloseWin32SocketLib)();
|
||||
#endif
|
||||
juce_shutdownWin32Sockets();
|
||||
#endif
|
||||
|
||||
LocalisedStrings::setCurrentMappings (0);
|
||||
Thread::stopAllThreads (3000);
|
||||
|
||||
#if JUCE_DEBUG
|
||||
#if JUCE_DEBUG
|
||||
juce_CheckForDanglingStreams();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
juceInitialisedNonGUI = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,20 +117,20 @@ public:
|
|||
static const String getCpuVendor();
|
||||
|
||||
/** Checks whether Intel MMX instructions are available. */
|
||||
static bool hasMMX();
|
||||
static bool hasMMX() throw() { return cpuFlags.hasMMX; }
|
||||
|
||||
/** Checks whether Intel SSE instructions are available. */
|
||||
static bool hasSSE();
|
||||
static bool hasSSE() throw() { return cpuFlags.hasSSE; }
|
||||
|
||||
/** Checks whether Intel SSE2 instructions are available. */
|
||||
static bool hasSSE2();
|
||||
static bool hasSSE2() throw() { return cpuFlags.hasSSE2; }
|
||||
|
||||
/** Checks whether AMD 3DNOW instructions are available. */
|
||||
static bool has3DNow();
|
||||
static bool has3DNow() throw() { return cpuFlags.has3DNow; }
|
||||
|
||||
/** Returns the number of CPUs.
|
||||
*/
|
||||
static int getNumCpus();
|
||||
static int getNumCpus() throw() { return cpuFlags.numCpus; }
|
||||
|
||||
//==============================================================================
|
||||
/** Finds out how much RAM is in the machine.
|
||||
|
|
@ -181,6 +181,17 @@ public:
|
|||
static void initialiseStats();
|
||||
|
||||
private:
|
||||
struct CPUFlags
|
||||
{
|
||||
int numCpus;
|
||||
bool hasMMX : 1;
|
||||
bool hasSSE : 1;
|
||||
bool hasSSE2 : 1;
|
||||
bool has3DNow : 1;
|
||||
};
|
||||
|
||||
static CPUFlags cpuFlags;
|
||||
|
||||
SystemStats();
|
||||
SystemStats (const SystemStats&);
|
||||
SystemStats& operator= (const SystemStats&);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_MD5.h"
|
||||
#include "../io/files/juce_FileInputStream.h"
|
||||
#include "../containers/juce_ScopedPointer.h"
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_Primes.h"
|
||||
#include "../core/juce_Random.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_RSAKey.h"
|
||||
#include "juce_Primes.h"
|
||||
|
||||
|
|
@ -97,7 +96,7 @@ bool RSAKey::applyToValue (BigInteger& value) const
|
|||
return true;
|
||||
}
|
||||
|
||||
static const BigInteger findBestCommonDivisor (const BigInteger& p, const BigInteger& q)
|
||||
const BigInteger RSAKey::findBestCommonDivisor (const BigInteger& p, const BigInteger& q)
|
||||
{
|
||||
// try 3, 5, 9, 17, etc first because these only contain 2 bits and so
|
||||
// are fast to divide + multiply
|
||||
|
|
|
|||
|
|
@ -106,6 +106,9 @@ public:
|
|||
|
||||
protected:
|
||||
BigInteger part1, part2;
|
||||
|
||||
private:
|
||||
static const BigInteger findBestCommonDivisor (const BigInteger& p, const BigInteger& q);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -42,299 +42,297 @@ CPlusPlusCodeTokeniser::~CPlusPlusCodeTokeniser()
|
|||
//==============================================================================
|
||||
namespace CppTokeniser
|
||||
{
|
||||
|
||||
static bool isIdentifierStart (const juce_wchar c) throw()
|
||||
{
|
||||
return CharacterFunctions::isLetter (c)
|
||||
|| c == '_' || c == '@';
|
||||
}
|
||||
|
||||
static bool isIdentifierBody (const juce_wchar c) throw()
|
||||
{
|
||||
return CharacterFunctions::isLetterOrDigit (c)
|
||||
|| c == '_' || c == '@';
|
||||
}
|
||||
|
||||
static bool isReservedKeyword (const juce_wchar* const token, const int tokenLength) throw()
|
||||
{
|
||||
static const juce_wchar* const keywords2Char[] =
|
||||
{ JUCE_T("if"), JUCE_T("do"), JUCE_T("or"), JUCE_T("id"), 0 };
|
||||
|
||||
static const juce_wchar* const keywords3Char[] =
|
||||
{ JUCE_T("for"), JUCE_T("int"), JUCE_T("new"), JUCE_T("try"), JUCE_T("xor"), JUCE_T("and"), JUCE_T("asm"), JUCE_T("not"), 0 };
|
||||
|
||||
static const juce_wchar* const keywords4Char[] =
|
||||
{ JUCE_T("bool"), JUCE_T("void"), JUCE_T("this"), JUCE_T("true"), JUCE_T("long"), JUCE_T("else"), JUCE_T("char"),
|
||||
JUCE_T("enum"), JUCE_T("case"), JUCE_T("goto"), JUCE_T("auto"), 0 };
|
||||
|
||||
static const juce_wchar* const keywords5Char[] =
|
||||
{ JUCE_T("while"), JUCE_T("bitor"), JUCE_T("break"), JUCE_T("catch"), JUCE_T("class"), JUCE_T("compl"), JUCE_T("const"), JUCE_T("false"),
|
||||
JUCE_T("float"), JUCE_T("short"), JUCE_T("throw"), JUCE_T("union"), JUCE_T("using"), JUCE_T("or_eq"), 0 };
|
||||
|
||||
static const juce_wchar* const keywords6Char[] =
|
||||
{ JUCE_T("return"), JUCE_T("struct"), JUCE_T("and_eq"), JUCE_T("bitand"), JUCE_T("delete"), JUCE_T("double"), JUCE_T("extern"),
|
||||
JUCE_T("friend"), JUCE_T("inline"), JUCE_T("not_eq"), JUCE_T("public"), JUCE_T("sizeof"), JUCE_T("static"), JUCE_T("signed"),
|
||||
JUCE_T("switch"), JUCE_T("typeid"), JUCE_T("wchar_t"), JUCE_T("xor_eq"), 0};
|
||||
|
||||
static const juce_wchar* const keywordsOther[] =
|
||||
{ JUCE_T("const_cast"), JUCE_T("continue"), JUCE_T("default"), JUCE_T("explicit"), JUCE_T("mutable"), JUCE_T("namespace"),
|
||||
JUCE_T("operator"), JUCE_T("private"), JUCE_T("protected"), JUCE_T("register"), JUCE_T("reinterpret_cast"), JUCE_T("static_cast"),
|
||||
JUCE_T("template"), JUCE_T("typedef"), JUCE_T("typename"), JUCE_T("unsigned"), JUCE_T("virtual"), JUCE_T("volatile"),
|
||||
JUCE_T("@implementation"), JUCE_T("@interface"), JUCE_T("@end"), JUCE_T("@synthesize"), JUCE_T("@dynamic"), JUCE_T("@public"),
|
||||
JUCE_T("@private"), JUCE_T("@property"), JUCE_T("@protected"), JUCE_T("@class"), 0 };
|
||||
|
||||
const juce_wchar* const* k;
|
||||
|
||||
switch (tokenLength)
|
||||
static bool isIdentifierStart (const juce_wchar c) throw()
|
||||
{
|
||||
case 2: k = keywords2Char; break;
|
||||
case 3: k = keywords3Char; break;
|
||||
case 4: k = keywords4Char; break;
|
||||
case 5: k = keywords5Char; break;
|
||||
case 6: k = keywords6Char; break;
|
||||
|
||||
default:
|
||||
if (tokenLength < 2 || tokenLength > 16)
|
||||
return false;
|
||||
|
||||
k = keywordsOther;
|
||||
break;
|
||||
return CharacterFunctions::isLetter (c)
|
||||
|| c == '_' || c == '@';
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
while (k[i] != 0)
|
||||
static bool isIdentifierBody (const juce_wchar c) throw()
|
||||
{
|
||||
if (k[i][0] == token[0] && CharacterFunctions::compare (k[i], token) == 0)
|
||||
return true;
|
||||
|
||||
++i;
|
||||
return CharacterFunctions::isLetterOrDigit (c)
|
||||
|| c == '_' || c == '@';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static int parseIdentifier (CodeDocument::Iterator& source) throw()
|
||||
{
|
||||
int tokenLength = 0;
|
||||
juce_wchar possibleIdentifier [19];
|
||||
|
||||
while (isIdentifierBody (source.peekNextChar()))
|
||||
static bool isReservedKeyword (const juce_wchar* const token, const int tokenLength) throw()
|
||||
{
|
||||
const juce_wchar c = source.nextChar();
|
||||
static const juce_wchar* const keywords2Char[] =
|
||||
{ JUCE_T("if"), JUCE_T("do"), JUCE_T("or"), JUCE_T("id"), 0 };
|
||||
|
||||
if (tokenLength < numElementsInArray (possibleIdentifier) - 1)
|
||||
possibleIdentifier [tokenLength] = c;
|
||||
static const juce_wchar* const keywords3Char[] =
|
||||
{ JUCE_T("for"), JUCE_T("int"), JUCE_T("new"), JUCE_T("try"), JUCE_T("xor"), JUCE_T("and"), JUCE_T("asm"), JUCE_T("not"), 0 };
|
||||
|
||||
++tokenLength;
|
||||
}
|
||||
static const juce_wchar* const keywords4Char[] =
|
||||
{ JUCE_T("bool"), JUCE_T("void"), JUCE_T("this"), JUCE_T("true"), JUCE_T("long"), JUCE_T("else"), JUCE_T("char"),
|
||||
JUCE_T("enum"), JUCE_T("case"), JUCE_T("goto"), JUCE_T("auto"), 0 };
|
||||
|
||||
if (tokenLength > 1 && tokenLength <= 16)
|
||||
{
|
||||
possibleIdentifier [tokenLength] = 0;
|
||||
static const juce_wchar* const keywords5Char[] =
|
||||
{ JUCE_T("while"), JUCE_T("bitor"), JUCE_T("break"), JUCE_T("catch"), JUCE_T("class"), JUCE_T("compl"), JUCE_T("const"), JUCE_T("false"),
|
||||
JUCE_T("float"), JUCE_T("short"), JUCE_T("throw"), JUCE_T("union"), JUCE_T("using"), JUCE_T("or_eq"), 0 };
|
||||
|
||||
if (isReservedKeyword (possibleIdentifier, tokenLength))
|
||||
return CPlusPlusCodeTokeniser::tokenType_builtInKeyword;
|
||||
}
|
||||
static const juce_wchar* const keywords6Char[] =
|
||||
{ JUCE_T("return"), JUCE_T("struct"), JUCE_T("and_eq"), JUCE_T("bitand"), JUCE_T("delete"), JUCE_T("double"), JUCE_T("extern"),
|
||||
JUCE_T("friend"), JUCE_T("inline"), JUCE_T("not_eq"), JUCE_T("public"), JUCE_T("sizeof"), JUCE_T("static"), JUCE_T("signed"),
|
||||
JUCE_T("switch"), JUCE_T("typeid"), JUCE_T("wchar_t"), JUCE_T("xor_eq"), 0};
|
||||
|
||||
return CPlusPlusCodeTokeniser::tokenType_identifier;
|
||||
}
|
||||
static const juce_wchar* const keywordsOther[] =
|
||||
{ JUCE_T("const_cast"), JUCE_T("continue"), JUCE_T("default"), JUCE_T("explicit"), JUCE_T("mutable"), JUCE_T("namespace"),
|
||||
JUCE_T("operator"), JUCE_T("private"), JUCE_T("protected"), JUCE_T("register"), JUCE_T("reinterpret_cast"), JUCE_T("static_cast"),
|
||||
JUCE_T("template"), JUCE_T("typedef"), JUCE_T("typename"), JUCE_T("unsigned"), JUCE_T("virtual"), JUCE_T("volatile"),
|
||||
JUCE_T("@implementation"), JUCE_T("@interface"), JUCE_T("@end"), JUCE_T("@synthesize"), JUCE_T("@dynamic"), JUCE_T("@public"),
|
||||
JUCE_T("@private"), JUCE_T("@property"), JUCE_T("@protected"), JUCE_T("@class"), 0 };
|
||||
|
||||
static bool skipNumberSuffix (CodeDocument::Iterator& source)
|
||||
{
|
||||
const juce_wchar c = source.peekNextChar();
|
||||
if (c == 'l' || c == 'L' || c == 'u' || c == 'U')
|
||||
source.skip();
|
||||
const juce_wchar* const* k;
|
||||
|
||||
switch (tokenLength)
|
||||
{
|
||||
case 2: k = keywords2Char; break;
|
||||
case 3: k = keywords3Char; break;
|
||||
case 4: k = keywords4Char; break;
|
||||
case 5: k = keywords5Char; break;
|
||||
case 6: k = keywords6Char; break;
|
||||
|
||||
default:
|
||||
if (tokenLength < 2 || tokenLength > 16)
|
||||
return false;
|
||||
|
||||
k = keywordsOther;
|
||||
break;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
while (k[i] != 0)
|
||||
{
|
||||
if (k[i][0] == token[0] && CharacterFunctions::compare (k[i], token) == 0)
|
||||
return true;
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
if (CharacterFunctions::isLetterOrDigit (source.peekNextChar()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool isHexDigit (const juce_wchar c) throw()
|
||||
{
|
||||
return (c >= '0' && c <= '9')
|
||||
|| (c >= 'a' && c <= 'f')
|
||||
|| (c >= 'A' && c <= 'F');
|
||||
}
|
||||
|
||||
static bool parseHexLiteral (CodeDocument::Iterator& source) throw()
|
||||
{
|
||||
if (source.nextChar() != '0')
|
||||
return false;
|
||||
|
||||
juce_wchar c = source.nextChar();
|
||||
if (c != 'x' && c != 'X')
|
||||
return false;
|
||||
|
||||
int numDigits = 0;
|
||||
while (isHexDigit (source.peekNextChar()))
|
||||
{
|
||||
++numDigits;
|
||||
source.skip();
|
||||
}
|
||||
|
||||
if (numDigits == 0)
|
||||
return false;
|
||||
|
||||
return skipNumberSuffix (source);
|
||||
}
|
||||
|
||||
static bool isOctalDigit (const juce_wchar c) throw()
|
||||
{
|
||||
return c >= '0' && c <= '7';
|
||||
}
|
||||
|
||||
static bool parseOctalLiteral (CodeDocument::Iterator& source) throw()
|
||||
{
|
||||
if (source.nextChar() != '0')
|
||||
return false;
|
||||
|
||||
if (! isOctalDigit (source.nextChar()))
|
||||
return false;
|
||||
|
||||
while (isOctalDigit (source.peekNextChar()))
|
||||
source.skip();
|
||||
|
||||
return skipNumberSuffix (source);
|
||||
}
|
||||
|
||||
static bool isDecimalDigit (const juce_wchar c) throw()
|
||||
{
|
||||
return c >= '0' && c <= '9';
|
||||
}
|
||||
|
||||
static bool parseDecimalLiteral (CodeDocument::Iterator& source) throw()
|
||||
{
|
||||
int numChars = 0;
|
||||
while (isDecimalDigit (source.peekNextChar()))
|
||||
static int parseIdentifier (CodeDocument::Iterator& source) throw()
|
||||
{
|
||||
++numChars;
|
||||
source.skip();
|
||||
int tokenLength = 0;
|
||||
juce_wchar possibleIdentifier [19];
|
||||
|
||||
while (isIdentifierBody (source.peekNextChar()))
|
||||
{
|
||||
const juce_wchar c = source.nextChar();
|
||||
|
||||
if (tokenLength < numElementsInArray (possibleIdentifier) - 1)
|
||||
possibleIdentifier [tokenLength] = c;
|
||||
|
||||
++tokenLength;
|
||||
}
|
||||
|
||||
if (tokenLength > 1 && tokenLength <= 16)
|
||||
{
|
||||
possibleIdentifier [tokenLength] = 0;
|
||||
|
||||
if (isReservedKeyword (possibleIdentifier, tokenLength))
|
||||
return CPlusPlusCodeTokeniser::tokenType_builtInKeyword;
|
||||
}
|
||||
|
||||
return CPlusPlusCodeTokeniser::tokenType_identifier;
|
||||
}
|
||||
|
||||
if (numChars == 0)
|
||||
return false;
|
||||
|
||||
return skipNumberSuffix (source);
|
||||
}
|
||||
|
||||
static bool parseFloatLiteral (CodeDocument::Iterator& source) throw()
|
||||
{
|
||||
int numDigits = 0;
|
||||
|
||||
while (isDecimalDigit (source.peekNextChar()))
|
||||
static bool skipNumberSuffix (CodeDocument::Iterator& source)
|
||||
{
|
||||
source.skip();
|
||||
++numDigits;
|
||||
const juce_wchar c = source.peekNextChar();
|
||||
if (c == 'l' || c == 'L' || c == 'u' || c == 'U')
|
||||
source.skip();
|
||||
|
||||
if (CharacterFunctions::isLetterOrDigit (source.peekNextChar()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const bool hasPoint = (source.peekNextChar() == '.');
|
||||
|
||||
if (hasPoint)
|
||||
static bool isHexDigit (const juce_wchar c) throw()
|
||||
{
|
||||
source.skip();
|
||||
return (c >= '0' && c <= '9')
|
||||
|| (c >= 'a' && c <= 'f')
|
||||
|| (c >= 'A' && c <= 'F');
|
||||
}
|
||||
|
||||
static bool parseHexLiteral (CodeDocument::Iterator& source) throw()
|
||||
{
|
||||
if (source.nextChar() != '0')
|
||||
return false;
|
||||
|
||||
juce_wchar c = source.nextChar();
|
||||
if (c != 'x' && c != 'X')
|
||||
return false;
|
||||
|
||||
int numDigits = 0;
|
||||
while (isHexDigit (source.peekNextChar()))
|
||||
{
|
||||
++numDigits;
|
||||
source.skip();
|
||||
}
|
||||
|
||||
if (numDigits == 0)
|
||||
return false;
|
||||
|
||||
return skipNumberSuffix (source);
|
||||
}
|
||||
|
||||
static bool isOctalDigit (const juce_wchar c) throw()
|
||||
{
|
||||
return c >= '0' && c <= '7';
|
||||
}
|
||||
|
||||
static bool parseOctalLiteral (CodeDocument::Iterator& source) throw()
|
||||
{
|
||||
if (source.nextChar() != '0')
|
||||
return false;
|
||||
|
||||
if (! isOctalDigit (source.nextChar()))
|
||||
return false;
|
||||
|
||||
while (isOctalDigit (source.peekNextChar()))
|
||||
source.skip();
|
||||
|
||||
return skipNumberSuffix (source);
|
||||
}
|
||||
|
||||
static bool isDecimalDigit (const juce_wchar c) throw()
|
||||
{
|
||||
return c >= '0' && c <= '9';
|
||||
}
|
||||
|
||||
static bool parseDecimalLiteral (CodeDocument::Iterator& source) throw()
|
||||
{
|
||||
int numChars = 0;
|
||||
while (isDecimalDigit (source.peekNextChar()))
|
||||
{
|
||||
++numChars;
|
||||
source.skip();
|
||||
}
|
||||
|
||||
if (numChars == 0)
|
||||
return false;
|
||||
|
||||
return skipNumberSuffix (source);
|
||||
}
|
||||
|
||||
static bool parseFloatLiteral (CodeDocument::Iterator& source) throw()
|
||||
{
|
||||
int numDigits = 0;
|
||||
|
||||
while (isDecimalDigit (source.peekNextChar()))
|
||||
{
|
||||
source.skip();
|
||||
++numDigits;
|
||||
}
|
||||
}
|
||||
|
||||
if (numDigits == 0)
|
||||
return false;
|
||||
const bool hasPoint = (source.peekNextChar() == '.');
|
||||
|
||||
juce_wchar c = source.peekNextChar();
|
||||
const bool hasExponent = (c == 'e' || c == 'E');
|
||||
|
||||
if (hasExponent)
|
||||
{
|
||||
source.skip();
|
||||
|
||||
c = source.peekNextChar();
|
||||
if (c == '+' || c == '-')
|
||||
source.skip();
|
||||
|
||||
int numExpDigits = 0;
|
||||
while (isDecimalDigit (source.peekNextChar()))
|
||||
if (hasPoint)
|
||||
{
|
||||
source.skip();
|
||||
++numExpDigits;
|
||||
|
||||
while (isDecimalDigit (source.peekNextChar()))
|
||||
{
|
||||
source.skip();
|
||||
++numDigits;
|
||||
}
|
||||
}
|
||||
|
||||
if (numExpDigits == 0)
|
||||
if (numDigits == 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
c = source.peekNextChar();
|
||||
if (c == 'f' || c == 'F')
|
||||
source.skip();
|
||||
else if (! (hasExponent || hasPoint))
|
||||
return false;
|
||||
juce_wchar c = source.peekNextChar();
|
||||
const bool hasExponent = (c == 'e' || c == 'E');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static int parseNumber (CodeDocument::Iterator& source)
|
||||
{
|
||||
const CodeDocument::Iterator original (source);
|
||||
|
||||
if (parseFloatLiteral (source))
|
||||
return CPlusPlusCodeTokeniser::tokenType_floatLiteral;
|
||||
|
||||
source = original;
|
||||
|
||||
if (parseHexLiteral (source))
|
||||
return CPlusPlusCodeTokeniser::tokenType_integerLiteral;
|
||||
|
||||
source = original;
|
||||
|
||||
if (parseOctalLiteral (source))
|
||||
return CPlusPlusCodeTokeniser::tokenType_integerLiteral;
|
||||
|
||||
source = original;
|
||||
|
||||
if (parseDecimalLiteral (source))
|
||||
return CPlusPlusCodeTokeniser::tokenType_integerLiteral;
|
||||
|
||||
source = original;
|
||||
source.skip();
|
||||
|
||||
return CPlusPlusCodeTokeniser::tokenType_error;
|
||||
}
|
||||
|
||||
static void skipQuotedString (CodeDocument::Iterator& source) throw()
|
||||
{
|
||||
const juce_wchar quote = source.nextChar();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
const juce_wchar c = source.nextChar();
|
||||
|
||||
if (c == quote || c == 0)
|
||||
break;
|
||||
|
||||
if (c == '\\')
|
||||
if (hasExponent)
|
||||
{
|
||||
source.skip();
|
||||
|
||||
c = source.peekNextChar();
|
||||
if (c == '+' || c == '-')
|
||||
source.skip();
|
||||
|
||||
int numExpDigits = 0;
|
||||
while (isDecimalDigit (source.peekNextChar()))
|
||||
{
|
||||
source.skip();
|
||||
++numExpDigits;
|
||||
}
|
||||
|
||||
if (numExpDigits == 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
c = source.peekNextChar();
|
||||
if (c == 'f' || c == 'F')
|
||||
source.skip();
|
||||
else if (! (hasExponent || hasPoint))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static void skipComment (CodeDocument::Iterator& source) throw()
|
||||
{
|
||||
bool lastWasStar = false;
|
||||
|
||||
for (;;)
|
||||
static int parseNumber (CodeDocument::Iterator& source)
|
||||
{
|
||||
const juce_wchar c = source.nextChar();
|
||||
const CodeDocument::Iterator original (source);
|
||||
|
||||
if (c == 0 || (c == '/' && lastWasStar))
|
||||
break;
|
||||
if (parseFloatLiteral (source))
|
||||
return CPlusPlusCodeTokeniser::tokenType_floatLiteral;
|
||||
|
||||
lastWasStar = (c == '*');
|
||||
source = original;
|
||||
|
||||
if (parseHexLiteral (source))
|
||||
return CPlusPlusCodeTokeniser::tokenType_integerLiteral;
|
||||
|
||||
source = original;
|
||||
|
||||
if (parseOctalLiteral (source))
|
||||
return CPlusPlusCodeTokeniser::tokenType_integerLiteral;
|
||||
|
||||
source = original;
|
||||
|
||||
if (parseDecimalLiteral (source))
|
||||
return CPlusPlusCodeTokeniser::tokenType_integerLiteral;
|
||||
|
||||
source = original;
|
||||
source.skip();
|
||||
|
||||
return CPlusPlusCodeTokeniser::tokenType_error;
|
||||
}
|
||||
}
|
||||
|
||||
static void skipQuotedString (CodeDocument::Iterator& source) throw()
|
||||
{
|
||||
const juce_wchar quote = source.nextChar();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
const juce_wchar c = source.nextChar();
|
||||
|
||||
if (c == quote || c == 0)
|
||||
break;
|
||||
|
||||
if (c == '\\')
|
||||
source.skip();
|
||||
}
|
||||
}
|
||||
|
||||
static void skipComment (CodeDocument::Iterator& source) throw()
|
||||
{
|
||||
bool lastWasStar = false;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
const juce_wchar c = source.nextChar();
|
||||
|
||||
if (c == 0 || (c == '/' && lastWasStar))
|
||||
break;
|
||||
|
||||
lastWasStar = (c == '*');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_Desktop.h"
|
||||
#include "windows/juce_ComponentPeer.h"
|
||||
#include "mouse/juce_MouseInputSource.h"
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ const Point<int> MouseEvent::getMouseDownScreenPosition() const
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
static int doubleClickTimeOutMs = 400;
|
||||
int MouseEvent::doubleClickTimeOutMs = 400;
|
||||
|
||||
void MouseEvent::setDoubleClickTimeout (const int newTime) throw()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -320,6 +320,7 @@ private:
|
|||
const Time mouseDownTime;
|
||||
const int numberOfClicks;
|
||||
const bool wasMovedSinceMouseDown;
|
||||
static int doubleClickTimeOutMs;
|
||||
|
||||
MouseEvent& operator= (const MouseEvent&);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -33,8 +33,6 @@ BEGIN_JUCE_NAMESPACE
|
|||
#include "../../graphics/imaging/juce_Image.h"
|
||||
#include "../../../text/juce_LocalisedStrings.h"
|
||||
|
||||
static const int swatchesPerRow = 8;
|
||||
static const int swatchHeight = 22;
|
||||
|
||||
//==============================================================================
|
||||
class ColourComponentSlider : public Slider
|
||||
|
|
@ -515,6 +513,9 @@ void ColourSelector::paint (Graphics& g)
|
|||
|
||||
void ColourSelector::resized()
|
||||
{
|
||||
const int swatchesPerRow = 8;
|
||||
const int swatchHeight = 22;
|
||||
|
||||
const int numSliders = ((flags & showAlphaChannel) != 0) ? 4 : 3;
|
||||
const int numSwatches = getNumSwatches();
|
||||
|
||||
|
|
|
|||
|
|
@ -248,8 +248,8 @@ int MidiKeyboardComponent::getKeyStartPosition (const int midiNoteNumber) const
|
|||
return x;
|
||||
}
|
||||
|
||||
static const uint8 whiteNotes[] = { 0, 2, 4, 5, 7, 9, 11 };
|
||||
static const uint8 blackNotes[] = { 1, 3, 6, 8, 10 };
|
||||
const uint8 MidiKeyboardComponent::whiteNotes[] = { 0, 2, 4, 5, 7, 9, 11 };
|
||||
const uint8 MidiKeyboardComponent::blackNotes[] = { 1, 3, 6, 8, 10 };
|
||||
|
||||
int MidiKeyboardComponent::xyToNote (const Point<int>& pos, float& mousePositionVelocity)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -404,6 +404,9 @@ private:
|
|||
int keyMappingOctave;
|
||||
int octaveNumForMiddleC;
|
||||
|
||||
static const uint8 whiteNotes[];
|
||||
static const uint8 blackNotes[];
|
||||
|
||||
void getKeyPos (int midiNoteNumber, int& x, int& w) const;
|
||||
int xyToNote (const Point<int>& pos, float& mousePositionVelocity);
|
||||
int remappedXYToNote (const Point<int>& pos, float& mousePositionVelocity) const;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_DocumentWindow.h"
|
||||
#include "juce_ComponentPeer.h"
|
||||
#include "../lookandfeel/juce_LookAndFeel.h"
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_ResizableWindow.h"
|
||||
#include "juce_ComponentPeer.h"
|
||||
#include "../juce_Desktop.h"
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_ThreadWithProgressWindow.h"
|
||||
#include "../lookandfeel/juce_LookAndFeel.h"
|
||||
#include "../../../text/juce_LocalisedStrings.h"
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_TooltipWindow.h"
|
||||
#include "../windows/juce_ComponentPeer.h"
|
||||
#include "../../../core/juce_Time.h"
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_TopLevelWindow.h"
|
||||
#include "../windows/juce_ComponentPeer.h"
|
||||
#include "../juce_Desktop.h"
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_Colours.h"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,8 +33,6 @@ BEGIN_JUCE_NAMESPACE
|
|||
#include "juce_LowLevelGraphicsContext.h"
|
||||
|
||||
|
||||
static const Graphics::ResamplingQuality defaultQuality = Graphics::mediumResamplingQuality;
|
||||
|
||||
//==============================================================================
|
||||
template <typename Type>
|
||||
static bool areCoordsSensibleNumbers (Type x, Type y, Type w, Type h)
|
||||
|
|
@ -80,7 +78,7 @@ void Graphics::resetToDefaultState()
|
|||
saveStateIfPending();
|
||||
context->setFill (FillType());
|
||||
context->setFont (Font());
|
||||
context->setInterpolationQuality (defaultQuality);
|
||||
context->setInterpolationQuality (Graphics::mediumResamplingQuality);
|
||||
}
|
||||
|
||||
bool Graphics::isVectorDevice() const
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_Justification.h"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_ReduceOpacityEffect.h"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_AffineTransform.h"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_PathIterator.h"
|
||||
#include "juce_Line.h"
|
||||
#include "../../../io/streams/juce_MemoryInputStream.h"
|
||||
#include "../../../io/streams/juce_MemoryOutputStream.h"
|
||||
#include "../imaging/juce_Image.h"
|
||||
|
||||
|
||||
// tests that some co-ords aren't NaNs
|
||||
#define CHECK_COORDS_ARE_VALID(x, y) \
|
||||
jassert (x == x && y == y);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_PathIterator.h"
|
||||
|
||||
#if JUCE_MSVC && JUCE_DEBUG
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_PathStrokeType.h"
|
||||
#include "juce_PathIterator.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_GIFLoader.h"
|
||||
#include "../../colour/juce_PixelFormats.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -27,14 +27,12 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_Image.h"
|
||||
#include "../contexts/juce_Graphics.h"
|
||||
#include "../contexts/juce_LowLevelGraphicsSoftwareRenderer.h"
|
||||
#include "../colour/juce_PixelFormats.h"
|
||||
#include "../../../containers/juce_SparseSet.h"
|
||||
|
||||
static const int fullAlphaThreshold = 253;
|
||||
|
||||
//==============================================================================
|
||||
Image::SharedImage::SharedImage (const PixelFormat format_, const int width_, const int height_)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_FileSearchPath.h"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_ZipFile.h"
|
||||
#include "../streams/juce_GZIPDecompressorInputStream.h"
|
||||
#include "../streams/juce_BufferedInputStream.h"
|
||||
|
|
@ -36,6 +35,7 @@ BEGIN_JUCE_NAMESPACE
|
|||
#include "juce_FileOutputStream.h"
|
||||
#include "../../threads/juce_ScopedLock.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
class ZipFile::ZipEntryInfo
|
||||
{
|
||||
|
|
|
|||
|
|
@ -68,236 +68,248 @@ BEGIN_JUCE_NAMESPACE
|
|||
//==============================================================================
|
||||
#if JUCE_WINDOWS
|
||||
|
||||
typedef int (__stdcall juce_CloseWin32SocketLibCall) (void);
|
||||
juce_CloseWin32SocketLibCall* juce_CloseWin32SocketLib = 0;
|
||||
namespace SocketHelpers
|
||||
{
|
||||
typedef int (__stdcall juce_CloseWin32SocketLibCall) (void);
|
||||
static juce_CloseWin32SocketLibCall* juce_CloseWin32SocketLib = 0;
|
||||
}
|
||||
|
||||
static void initWin32Sockets()
|
||||
{
|
||||
static CriticalSection lock;
|
||||
const ScopedLock sl (lock);
|
||||
|
||||
if (juce_CloseWin32SocketLib == 0)
|
||||
if (SocketHelpers::juce_CloseWin32SocketLib == 0)
|
||||
{
|
||||
WSADATA wsaData;
|
||||
const WORD wVersionRequested = MAKEWORD (1, 1);
|
||||
WSAStartup (wVersionRequested, &wsaData);
|
||||
|
||||
juce_CloseWin32SocketLib = &WSACleanup;
|
||||
SocketHelpers::juce_CloseWin32SocketLib = &WSACleanup;
|
||||
}
|
||||
}
|
||||
|
||||
void juce_shutdownWin32Sockets()
|
||||
{
|
||||
if (SocketHelpers::juce_CloseWin32SocketLib != 0)
|
||||
(*SocketHelpers::juce_CloseWin32SocketLib)();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
static bool resetSocketOptions (const int handle, const bool isDatagram, const bool allowBroadcast) throw()
|
||||
namespace SocketHelpers
|
||||
{
|
||||
const int sndBufSize = 65536;
|
||||
const int rcvBufSize = 65536;
|
||||
const int one = 1;
|
||||
|
||||
return handle > 0
|
||||
&& setsockopt (handle, SOL_SOCKET, SO_RCVBUF, (const char*) &rcvBufSize, sizeof (rcvBufSize)) == 0
|
||||
&& setsockopt (handle, SOL_SOCKET, SO_SNDBUF, (const char*) &sndBufSize, sizeof (sndBufSize)) == 0
|
||||
&& (isDatagram ? ((! allowBroadcast) || setsockopt (handle, SOL_SOCKET, SO_BROADCAST, (const char*) &one, sizeof (one)) == 0)
|
||||
: (setsockopt (handle, IPPROTO_TCP, TCP_NODELAY, (const char*) &one, sizeof (one)) == 0));
|
||||
}
|
||||
|
||||
static bool bindSocketToPort (const int handle, const int port) throw()
|
||||
{
|
||||
if (handle <= 0 || port <= 0)
|
||||
return false;
|
||||
|
||||
struct sockaddr_in servTmpAddr;
|
||||
zerostruct (servTmpAddr);
|
||||
servTmpAddr.sin_family = PF_INET;
|
||||
servTmpAddr.sin_addr.s_addr = htonl (INADDR_ANY);
|
||||
servTmpAddr.sin_port = htons ((uint16) port);
|
||||
|
||||
return bind (handle, (struct sockaddr*) &servTmpAddr, sizeof (struct sockaddr_in)) >= 0;
|
||||
}
|
||||
|
||||
static int readSocket (const int handle,
|
||||
void* const destBuffer, const int maxBytesToRead,
|
||||
bool volatile& connected,
|
||||
const bool blockUntilSpecifiedAmountHasArrived) throw()
|
||||
{
|
||||
int bytesRead = 0;
|
||||
|
||||
while (bytesRead < maxBytesToRead)
|
||||
static bool resetSocketOptions (const int handle, const bool isDatagram, const bool allowBroadcast) throw()
|
||||
{
|
||||
int bytesThisTime;
|
||||
const int sndBufSize = 65536;
|
||||
const int rcvBufSize = 65536;
|
||||
const int one = 1;
|
||||
|
||||
#if JUCE_WINDOWS
|
||||
bytesThisTime = recv (handle, ((char*) destBuffer) + bytesRead, maxBytesToRead - bytesRead, 0);
|
||||
#else
|
||||
while ((bytesThisTime = (int) ::read (handle, ((char*) destBuffer) + bytesRead, maxBytesToRead - bytesRead)) < 0
|
||||
&& errno == EINTR
|
||||
&& connected)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
if (bytesThisTime <= 0 || ! connected)
|
||||
{
|
||||
if (bytesRead == 0)
|
||||
bytesRead = -1;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
bytesRead += bytesThisTime;
|
||||
|
||||
if (! blockUntilSpecifiedAmountHasArrived)
|
||||
break;
|
||||
return handle > 0
|
||||
&& setsockopt (handle, SOL_SOCKET, SO_RCVBUF, (const char*) &rcvBufSize, sizeof (rcvBufSize)) == 0
|
||||
&& setsockopt (handle, SOL_SOCKET, SO_SNDBUF, (const char*) &sndBufSize, sizeof (sndBufSize)) == 0
|
||||
&& (isDatagram ? ((! allowBroadcast) || setsockopt (handle, SOL_SOCKET, SO_BROADCAST, (const char*) &one, sizeof (one)) == 0)
|
||||
: (setsockopt (handle, IPPROTO_TCP, TCP_NODELAY, (const char*) &one, sizeof (one)) == 0));
|
||||
}
|
||||
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
static int waitForReadiness (const int handle, const bool forReading,
|
||||
const int timeoutMsecs) throw()
|
||||
{
|
||||
struct timeval timeout;
|
||||
struct timeval* timeoutp;
|
||||
|
||||
if (timeoutMsecs >= 0)
|
||||
static bool bindSocketToPort (const int handle, const int port) throw()
|
||||
{
|
||||
timeout.tv_sec = timeoutMsecs / 1000;
|
||||
timeout.tv_usec = (timeoutMsecs % 1000) * 1000;
|
||||
timeoutp = &timeout;
|
||||
}
|
||||
else
|
||||
{
|
||||
timeoutp = 0;
|
||||
if (handle <= 0 || port <= 0)
|
||||
return false;
|
||||
|
||||
struct sockaddr_in servTmpAddr;
|
||||
zerostruct (servTmpAddr);
|
||||
servTmpAddr.sin_family = PF_INET;
|
||||
servTmpAddr.sin_addr.s_addr = htonl (INADDR_ANY);
|
||||
servTmpAddr.sin_port = htons ((uint16) port);
|
||||
|
||||
return bind (handle, (struct sockaddr*) &servTmpAddr, sizeof (struct sockaddr_in)) >= 0;
|
||||
}
|
||||
|
||||
fd_set rset, wset;
|
||||
FD_ZERO (&rset);
|
||||
FD_SET (handle, &rset);
|
||||
FD_ZERO (&wset);
|
||||
FD_SET (handle, &wset);
|
||||
|
||||
fd_set* const prset = forReading ? &rset : 0;
|
||||
fd_set* const pwset = forReading ? 0 : &wset;
|
||||
|
||||
#if JUCE_WINDOWS
|
||||
if (select (handle + 1, prset, pwset, 0, timeoutp) < 0)
|
||||
return -1;
|
||||
#else
|
||||
static int readSocket (const int handle,
|
||||
void* const destBuffer, const int maxBytesToRead,
|
||||
bool volatile& connected,
|
||||
const bool blockUntilSpecifiedAmountHasArrived) throw()
|
||||
{
|
||||
int result;
|
||||
while ((result = select (handle + 1, prset, pwset, 0, timeoutp)) < 0
|
||||
&& errno == EINTR)
|
||||
int bytesRead = 0;
|
||||
|
||||
while (bytesRead < maxBytesToRead)
|
||||
{
|
||||
int bytesThisTime;
|
||||
|
||||
#if JUCE_WINDOWS
|
||||
bytesThisTime = recv (handle, ((char*) destBuffer) + bytesRead, maxBytesToRead - bytesRead, 0);
|
||||
#else
|
||||
while ((bytesThisTime = (int) ::read (handle, ((char*) destBuffer) + bytesRead, maxBytesToRead - bytesRead)) < 0
|
||||
&& errno == EINTR
|
||||
&& connected)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
if (bytesThisTime <= 0 || ! connected)
|
||||
{
|
||||
if (bytesRead == 0)
|
||||
bytesRead = -1;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
bytesRead += bytesThisTime;
|
||||
|
||||
if (! blockUntilSpecifiedAmountHasArrived)
|
||||
break;
|
||||
}
|
||||
|
||||
if (result < 0)
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
static int waitForReadiness (const int handle, const bool forReading,
|
||||
const int timeoutMsecs) throw()
|
||||
{
|
||||
struct timeval timeout;
|
||||
struct timeval* timeoutp;
|
||||
|
||||
if (timeoutMsecs >= 0)
|
||||
{
|
||||
timeout.tv_sec = timeoutMsecs / 1000;
|
||||
timeout.tv_usec = (timeoutMsecs % 1000) * 1000;
|
||||
timeoutp = &timeout;
|
||||
}
|
||||
else
|
||||
{
|
||||
timeoutp = 0;
|
||||
}
|
||||
|
||||
fd_set rset, wset;
|
||||
FD_ZERO (&rset);
|
||||
FD_SET (handle, &rset);
|
||||
FD_ZERO (&wset);
|
||||
FD_SET (handle, &wset);
|
||||
|
||||
fd_set* const prset = forReading ? &rset : 0;
|
||||
fd_set* const pwset = forReading ? 0 : &wset;
|
||||
|
||||
#if JUCE_WINDOWS
|
||||
if (select (handle + 1, prset, pwset, 0, timeoutp) < 0)
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
{
|
||||
int result;
|
||||
while ((result = select (handle + 1, prset, pwset, 0, timeoutp)) < 0
|
||||
&& errno == EINTR)
|
||||
{
|
||||
}
|
||||
|
||||
{
|
||||
int opt;
|
||||
juce_socklen_t len = sizeof (opt);
|
||||
if (result < 0)
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (getsockopt (handle, SOL_SOCKET, SO_ERROR, (char*) &opt, &len) < 0
|
||||
|| opt != 0)
|
||||
return -1;
|
||||
{
|
||||
int opt;
|
||||
juce_socklen_t len = sizeof (opt);
|
||||
|
||||
if (getsockopt (handle, SOL_SOCKET, SO_ERROR, (char*) &opt, &len) < 0
|
||||
|| opt != 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((forReading && FD_ISSET (handle, &rset))
|
||||
|| ((! forReading) && FD_ISSET (handle, &wset)))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((forReading && FD_ISSET (handle, &rset))
|
||||
|| ((! forReading) && FD_ISSET (handle, &wset)))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool setSocketBlockingState (const int handle, const bool shouldBlock) throw()
|
||||
{
|
||||
#if JUCE_WINDOWS
|
||||
u_long nonBlocking = shouldBlock ? 0 : 1;
|
||||
|
||||
if (ioctlsocket (handle, FIONBIO, &nonBlocking) != 0)
|
||||
return false;
|
||||
#else
|
||||
int socketFlags = fcntl (handle, F_GETFL, 0);
|
||||
|
||||
if (socketFlags == -1)
|
||||
return false;
|
||||
|
||||
if (shouldBlock)
|
||||
socketFlags &= ~O_NONBLOCK;
|
||||
else
|
||||
socketFlags |= O_NONBLOCK;
|
||||
|
||||
if (fcntl (handle, F_SETFL, socketFlags) != 0)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool connectSocket (int volatile& handle,
|
||||
const bool isDatagram,
|
||||
void** serverAddress,
|
||||
const String& hostName,
|
||||
const int portNumber,
|
||||
const int timeOutMillisecs) throw()
|
||||
{
|
||||
struct hostent* const hostEnt = gethostbyname (hostName.toUTF8());
|
||||
|
||||
if (hostEnt == 0)
|
||||
return false;
|
||||
|
||||
struct in_addr targetAddress;
|
||||
memcpy (&targetAddress.s_addr,
|
||||
*(hostEnt->h_addr_list),
|
||||
sizeof (targetAddress.s_addr));
|
||||
|
||||
struct sockaddr_in servTmpAddr;
|
||||
zerostruct (servTmpAddr);
|
||||
servTmpAddr.sin_family = PF_INET;
|
||||
servTmpAddr.sin_addr = targetAddress;
|
||||
servTmpAddr.sin_port = htons ((uint16) portNumber);
|
||||
|
||||
if (handle < 0)
|
||||
handle = (int) socket (AF_INET, isDatagram ? SOCK_DGRAM : SOCK_STREAM, 0);
|
||||
|
||||
if (handle < 0)
|
||||
return false;
|
||||
|
||||
if (isDatagram)
|
||||
static bool setSocketBlockingState (const int handle, const bool shouldBlock) throw()
|
||||
{
|
||||
*serverAddress = new struct sockaddr_in();
|
||||
*((struct sockaddr_in*) *serverAddress) = servTmpAddr;
|
||||
#if JUCE_WINDOWS
|
||||
u_long nonBlocking = shouldBlock ? 0 : 1;
|
||||
|
||||
if (ioctlsocket (handle, FIONBIO, &nonBlocking) != 0)
|
||||
return false;
|
||||
#else
|
||||
int socketFlags = fcntl (handle, F_GETFL, 0);
|
||||
|
||||
if (socketFlags == -1)
|
||||
return false;
|
||||
|
||||
if (shouldBlock)
|
||||
socketFlags &= ~O_NONBLOCK;
|
||||
else
|
||||
socketFlags |= O_NONBLOCK;
|
||||
|
||||
if (fcntl (handle, F_SETFL, socketFlags) != 0)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
setSocketBlockingState (handle, false);
|
||||
|
||||
const int result = ::connect (handle, (struct sockaddr*) &servTmpAddr, sizeof (struct sockaddr_in));
|
||||
|
||||
if (result < 0)
|
||||
static bool connectSocket (int volatile& handle,
|
||||
const bool isDatagram,
|
||||
void** serverAddress,
|
||||
const String& hostName,
|
||||
const int portNumber,
|
||||
const int timeOutMillisecs) throw()
|
||||
{
|
||||
#if JUCE_WINDOWS
|
||||
if (result == SOCKET_ERROR && WSAGetLastError() == WSAEWOULDBLOCK)
|
||||
#else
|
||||
if (errno == EINPROGRESS)
|
||||
#endif
|
||||
struct hostent* const hostEnt = gethostbyname (hostName.toUTF8());
|
||||
|
||||
if (hostEnt == 0)
|
||||
return false;
|
||||
|
||||
struct in_addr targetAddress;
|
||||
memcpy (&targetAddress.s_addr,
|
||||
*(hostEnt->h_addr_list),
|
||||
sizeof (targetAddress.s_addr));
|
||||
|
||||
struct sockaddr_in servTmpAddr;
|
||||
zerostruct (servTmpAddr);
|
||||
servTmpAddr.sin_family = PF_INET;
|
||||
servTmpAddr.sin_addr = targetAddress;
|
||||
servTmpAddr.sin_port = htons ((uint16) portNumber);
|
||||
|
||||
if (handle < 0)
|
||||
handle = (int) socket (AF_INET, isDatagram ? SOCK_DGRAM : SOCK_STREAM, 0);
|
||||
|
||||
if (handle < 0)
|
||||
return false;
|
||||
|
||||
if (isDatagram)
|
||||
{
|
||||
if (waitForReadiness (handle, false, timeOutMillisecs) != 1)
|
||||
*serverAddress = new struct sockaddr_in();
|
||||
*((struct sockaddr_in*) *serverAddress) = servTmpAddr;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
setSocketBlockingState (handle, false);
|
||||
|
||||
const int result = ::connect (handle, (struct sockaddr*) &servTmpAddr, sizeof (struct sockaddr_in));
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
#if JUCE_WINDOWS
|
||||
if (result == SOCKET_ERROR && WSAGetLastError() == WSAEWOULDBLOCK)
|
||||
#else
|
||||
if (errno == EINPROGRESS)
|
||||
#endif
|
||||
{
|
||||
setSocketBlockingState (handle, true);
|
||||
return false;
|
||||
if (waitForReadiness (handle, false, timeOutMillisecs) != 1)
|
||||
{
|
||||
setSocketBlockingState (handle, true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setSocketBlockingState (handle, true);
|
||||
resetSocketOptions (handle, false, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
setSocketBlockingState (handle, true);
|
||||
resetSocketOptions (handle, false, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -325,7 +337,7 @@ StreamingSocket::StreamingSocket (const String& hostName_,
|
|||
initWin32Sockets();
|
||||
#endif
|
||||
|
||||
resetSocketOptions (handle_, false, false);
|
||||
SocketHelpers::resetSocketOptions (handle_, false, false);
|
||||
}
|
||||
|
||||
StreamingSocket::~StreamingSocket()
|
||||
|
|
@ -336,7 +348,7 @@ StreamingSocket::~StreamingSocket()
|
|||
//==============================================================================
|
||||
int StreamingSocket::read (void* destBuffer, const int maxBytesToRead, const bool blockUntilSpecifiedAmountHasArrived)
|
||||
{
|
||||
return (connected && ! isListener) ? readSocket (handle, destBuffer, maxBytesToRead, connected, blockUntilSpecifiedAmountHasArrived)
|
||||
return (connected && ! isListener) ? SocketHelpers::readSocket (handle, destBuffer, maxBytesToRead, connected, blockUntilSpecifiedAmountHasArrived)
|
||||
: -1;
|
||||
}
|
||||
|
||||
|
|
@ -363,14 +375,14 @@ int StreamingSocket::write (const void* sourceBuffer, const int numBytesToWrite)
|
|||
int StreamingSocket::waitUntilReady (const bool readyForReading,
|
||||
const int timeoutMsecs) const
|
||||
{
|
||||
return connected ? waitForReadiness (handle, readyForReading, timeoutMsecs)
|
||||
return connected ? SocketHelpers::waitForReadiness (handle, readyForReading, timeoutMsecs)
|
||||
: -1;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool StreamingSocket::bindToPort (const int port)
|
||||
{
|
||||
return bindSocketToPort (handle, port);
|
||||
return SocketHelpers::bindSocketToPort (handle, port);
|
||||
}
|
||||
|
||||
bool StreamingSocket::connect (const String& remoteHostName,
|
||||
|
|
@ -390,10 +402,10 @@ bool StreamingSocket::connect (const String& remoteHostName,
|
|||
portNumber = remotePortNumber;
|
||||
isListener = false;
|
||||
|
||||
connected = connectSocket (handle, false, 0, remoteHostName,
|
||||
remotePortNumber, timeOutMillisecs);
|
||||
connected = SocketHelpers::connectSocket (handle, false, 0, remoteHostName,
|
||||
remotePortNumber, timeOutMillisecs);
|
||||
|
||||
if (! (connected && resetSocketOptions (handle, false, false)))
|
||||
if (! (connected && SocketHelpers::resetSocketOptions (handle, false, false)))
|
||||
{
|
||||
close();
|
||||
return false;
|
||||
|
|
@ -526,7 +538,7 @@ DatagramSocket::DatagramSocket (const String& hostName_, const int portNumber_,
|
|||
initWin32Sockets();
|
||||
#endif
|
||||
|
||||
resetSocketOptions (handle_, true, allowBroadcast);
|
||||
SocketHelpers::resetSocketOptions (handle_, true, allowBroadcast);
|
||||
bindToPort (localPortNumber);
|
||||
}
|
||||
|
||||
|
|
@ -555,7 +567,7 @@ void DatagramSocket::close()
|
|||
|
||||
bool DatagramSocket::bindToPort (const int port)
|
||||
{
|
||||
return bindSocketToPort (handle, port);
|
||||
return SocketHelpers::bindSocketToPort (handle, port);
|
||||
}
|
||||
|
||||
bool DatagramSocket::connect (const String& remoteHostName,
|
||||
|
|
@ -568,11 +580,11 @@ bool DatagramSocket::connect (const String& remoteHostName,
|
|||
hostName = remoteHostName;
|
||||
portNumber = remotePortNumber;
|
||||
|
||||
connected = connectSocket (handle, true, &serverAddress,
|
||||
remoteHostName, remotePortNumber,
|
||||
timeOutMillisecs);
|
||||
connected = SocketHelpers::connectSocket (handle, true, &serverAddress,
|
||||
remoteHostName, remotePortNumber,
|
||||
timeOutMillisecs);
|
||||
|
||||
if (! (connected && resetSocketOptions (handle, true, allowBroadcast)))
|
||||
if (! (connected && SocketHelpers::resetSocketOptions (handle, true, allowBroadcast)))
|
||||
{
|
||||
close();
|
||||
return false;
|
||||
|
|
@ -605,13 +617,13 @@ DatagramSocket* DatagramSocket::waitForNextConnection() const
|
|||
int DatagramSocket::waitUntilReady (const bool readyForReading,
|
||||
const int timeoutMsecs) const
|
||||
{
|
||||
return connected ? waitForReadiness (handle, readyForReading, timeoutMsecs)
|
||||
return connected ? SocketHelpers::waitForReadiness (handle, readyForReading, timeoutMsecs)
|
||||
: -1;
|
||||
}
|
||||
|
||||
int DatagramSocket::read (void* destBuffer, const int maxBytesToRead, const bool blockUntilSpecifiedAmountHasArrived)
|
||||
{
|
||||
return connected ? readSocket (handle, destBuffer, maxBytesToRead, connected, blockUntilSpecifiedAmountHasArrived)
|
||||
return connected ? SocketHelpers::readSocket (handle, destBuffer, maxBytesToRead, connected, blockUntilSpecifiedAmountHasArrived)
|
||||
: -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_URL.h"
|
||||
#include "../../core/juce_Random.h"
|
||||
#include "../../core/juce_PlatformUtilities.h"
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_BufferedInputStream.h"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_InputStream.h"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_MemoryOutputStream.h"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_OutputStream.h"
|
||||
#include "../../threads/juce_ScopedLock.h"
|
||||
#include "../../containers/juce_Array.h"
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_SubregionStream.h"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -68,11 +68,6 @@ static const String juce_getCpuInfo (const char* const key)
|
|||
return String::empty;
|
||||
}
|
||||
|
||||
bool SystemStats::hasMMX() { return juce_getCpuInfo ("flags").contains ("mmx"); }
|
||||
bool SystemStats::hasSSE() { return juce_getCpuInfo ("flags").contains ("sse"); }
|
||||
bool SystemStats::hasSSE2() { return juce_getCpuInfo ("flags").contains ("sse2"); }
|
||||
bool SystemStats::has3DNow() { return juce_getCpuInfo ("flags").contains ("3dnow"); }
|
||||
|
||||
const String SystemStats::getCpuVendor()
|
||||
{
|
||||
return juce_getCpuInfo ("vendor_id");
|
||||
|
|
@ -98,11 +93,6 @@ int SystemStats::getPageSize()
|
|||
return sysconf (_SC_PAGESIZE);
|
||||
}
|
||||
|
||||
int SystemStats::getNumCpus()
|
||||
{
|
||||
return juce_getCpuInfo ("processor").getIntValue() + 1;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
const String SystemStats::getLogonName()
|
||||
{
|
||||
|
|
@ -126,6 +116,13 @@ const String SystemStats::getFullUserName()
|
|||
//==============================================================================
|
||||
void SystemStats::initialiseStats()
|
||||
{
|
||||
const String flags (juce_getCpuInfo ("flags"));
|
||||
cpuFlags.hasMMX = flags.contains ("mmx");
|
||||
cpuFlags.hasSSE = flags.contains ("sse");
|
||||
cpuFlags.hasSSE2 = flags.contains ("sse2");
|
||||
cpuFlags.has3DNow = flags.contains ("3dnow");
|
||||
|
||||
cpuFlags.numCpus = juce_getCpuInfo ("processor").getIntValue() + 1;
|
||||
}
|
||||
|
||||
void PlatformUtilities::fpuReset()
|
||||
|
|
|
|||
|
|
@ -65,16 +65,6 @@ namespace SystemStatsHelpers
|
|||
return cpu;
|
||||
}
|
||||
|
||||
struct CPUFlags
|
||||
{
|
||||
bool hasMMX : 1;
|
||||
bool hasSSE : 1;
|
||||
bool hasSSE2 : 1;
|
||||
bool has3DNow : 1;
|
||||
};
|
||||
|
||||
static CPUFlags cpuFlags;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -88,16 +78,15 @@ void SystemStats::initialiseStats()
|
|||
{
|
||||
initialised = true;
|
||||
|
||||
#if JUCE_MAC
|
||||
// extremely annoying: adding this line stops the apple menu items from working. Of
|
||||
// course, not adding it means that carbon windows (e.g. in plugins) won't get
|
||||
// any events.
|
||||
//NSApplicationLoad();
|
||||
[NSApplication sharedApplication];
|
||||
#endif
|
||||
#if JUCE_MAC
|
||||
// extremely annoying: adding this line stops the apple menu items from working. Of
|
||||
// course, not adding it means that carbon windows (e.g. in plugins) won't get
|
||||
// any events.
|
||||
//NSApplicationLoad();
|
||||
[NSApplication sharedApplication];
|
||||
#endif
|
||||
|
||||
#if JUCE_INTEL
|
||||
{
|
||||
#if JUCE_INTEL
|
||||
unsigned int familyModel, extFeatures;
|
||||
const unsigned int features = getCPUIDWord (familyModel, extFeatures);
|
||||
|
||||
|
|
@ -105,8 +94,18 @@ void SystemStats::initialiseStats()
|
|||
cpuFlags.hasSSE = ((features & (1 << 25)) != 0);
|
||||
cpuFlags.hasSSE2 = ((features & (1 << 26)) != 0);
|
||||
cpuFlags.has3DNow = ((extFeatures & (1 << 31)) != 0);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
cpuFlags.hasMMX = false;
|
||||
cpuFlags.hasSSE = false;
|
||||
cpuFlags.hasSSE2 = false;
|
||||
cpuFlags.has3DNow = false;
|
||||
#endif
|
||||
|
||||
#if JUCE_IPHONE || (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
|
||||
cpuFlags.numCpus = (int) [[NSProcessInfo processInfo] activeProcessorCount];
|
||||
#else
|
||||
cpuFlags.numCpus = (int) MPProcessors();
|
||||
#endif
|
||||
|
||||
mach_timebase_info_data_t timebase;
|
||||
(void) mach_timebase_info (&timebase);
|
||||
|
|
@ -152,42 +151,6 @@ int SystemStats::getMemorySizeInMegabytes()
|
|||
return (int) (mem / (1024 * 1024));
|
||||
}
|
||||
|
||||
bool SystemStats::hasMMX()
|
||||
{
|
||||
#if JUCE_INTEL
|
||||
return SystemStatsHelpers::cpuFlags.hasMMX;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SystemStats::hasSSE()
|
||||
{
|
||||
#if JUCE_INTEL
|
||||
return SystemStatsHelpers::cpuFlags.hasSSE;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SystemStats::hasSSE2()
|
||||
{
|
||||
#if JUCE_INTEL
|
||||
return SystemStatsHelpers::cpuFlags.hasSSE2;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SystemStats::has3DNow()
|
||||
{
|
||||
#if JUCE_INTEL
|
||||
return SystemStatsHelpers::cpuFlags.has3DNow;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
const String SystemStats::getCpuVendor()
|
||||
{
|
||||
#if JUCE_INTEL
|
||||
|
|
@ -213,15 +176,6 @@ int SystemStats::getCpuSpeedInMegaherz()
|
|||
return (int) (speedHz / 1000000);
|
||||
}
|
||||
|
||||
int SystemStats::getNumCpus()
|
||||
{
|
||||
#if JUCE_IPHONE || (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
|
||||
return (int) [[NSProcessInfo processInfo] activeProcessorCount];
|
||||
#else
|
||||
return MPProcessors();
|
||||
#endif
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
const String SystemStats::getLogonName()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -113,36 +113,6 @@ const String SystemStats::getCpuVendor()
|
|||
|
||||
|
||||
//==============================================================================
|
||||
struct CPUFlags
|
||||
{
|
||||
bool hasMMX : 1;
|
||||
bool hasSSE : 1;
|
||||
bool hasSSE2 : 1;
|
||||
bool has3DNow : 1;
|
||||
};
|
||||
|
||||
static CPUFlags cpuFlags;
|
||||
|
||||
bool SystemStats::hasMMX()
|
||||
{
|
||||
return cpuFlags.hasMMX;
|
||||
}
|
||||
|
||||
bool SystemStats::hasSSE()
|
||||
{
|
||||
return cpuFlags.hasSSE;
|
||||
}
|
||||
|
||||
bool SystemStats::hasSSE2()
|
||||
{
|
||||
return cpuFlags.hasSSE2;
|
||||
}
|
||||
|
||||
bool SystemStats::has3DNow()
|
||||
{
|
||||
return cpuFlags.has3DNow;
|
||||
}
|
||||
|
||||
void SystemStats::initialiseStats()
|
||||
{
|
||||
juce_initialiseThreadEvents();
|
||||
|
|
@ -156,6 +126,12 @@ void SystemStats::initialiseStats()
|
|||
cpuFlags.has3DNow = IsProcessorFeaturePresent (PF_3DNOW_INSTRUCTIONS_AVAILABLE) != 0;
|
||||
#endif
|
||||
|
||||
{
|
||||
SYSTEM_INFO systemInfo;
|
||||
GetSystemInfo (&systemInfo);
|
||||
cpuFlags.numCpus = systemInfo.dwNumberOfProcessors;
|
||||
}
|
||||
|
||||
LARGE_INTEGER f;
|
||||
QueryPerformanceFrequency (&f);
|
||||
hiResTicksPerSecond = f.QuadPart;
|
||||
|
|
@ -163,12 +139,9 @@ void SystemStats::initialiseStats()
|
|||
|
||||
String s (SystemStats::getJUCEVersion());
|
||||
|
||||
#if JUCE_DEBUG
|
||||
const MMRESULT res = timeBeginPeriod (1);
|
||||
(void) res;
|
||||
jassert (res == TIMERR_NOERROR);
|
||||
#else
|
||||
timeBeginPeriod (1);
|
||||
#endif
|
||||
|
||||
#if JUCE_DEBUG && JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS
|
||||
_CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
||||
|
|
@ -244,14 +217,6 @@ int SystemStats::getMemorySizeInMegabytes()
|
|||
return (int) (mem.ullTotalPhys / (1024 * 1024)) + 1;
|
||||
}
|
||||
|
||||
int SystemStats::getNumCpus()
|
||||
{
|
||||
SYSTEM_INFO systemInfo;
|
||||
GetSystemInfo (&systemInfo);
|
||||
|
||||
return systemInfo.dwNumberOfProcessors;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
uint32 juce_millisecondsSinceStartup() throw()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_LocalisedStrings.h"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_StringArray.h"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_StringPairArray.h"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_XmlElement.h"
|
||||
#include "../io/streams/juce_MemoryOutputStream.h"
|
||||
#include "../io/files/juce_TemporaryFile.h"
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_ReadWriteLock.h"
|
||||
#include "juce_ScopedLock.h"
|
||||
#include "juce_Thread.h"
|
||||
|
|
|
|||
|
|
@ -27,11 +27,11 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_Thread.h"
|
||||
#include "juce_ScopedLock.h"
|
||||
#include "../core/juce_Time.h"
|
||||
|
||||
|
||||
// these functions are implemented in the platform-specific code.
|
||||
void* juce_createThread (void* userData);
|
||||
void juce_killThread (void* handle);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_ThreadPool.h"
|
||||
#include "../core/juce_Time.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_TimeSliceThread.h"
|
||||
#include "juce_ScopedLock.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_UndoManager.h"
|
||||
#include "../application/juce_Application.h"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue