further development

git-svn-id: http://moon:8086/svn/software/trunk/projects/RBM@17 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2014-10-04 19:09:35 +00:00
parent b403b9776a
commit f62f1283f8
127 changed files with 2350 additions and 1235 deletions
@@ -65,8 +65,7 @@ private:
public:
//==============================================================================
/** Creates an empty array. */
Array() noexcept
: numUsed (0)
Array() noexcept : numUsed (0)
{
}
@@ -88,9 +88,8 @@ NamedValueSet& NamedValueSet::operator= (NamedValueSet&& other) noexcept
}
#endif
NamedValueSet::~NamedValueSet()
NamedValueSet::~NamedValueSet() noexcept
{
clear();
}
void NamedValueSet::clear()
@@ -113,7 +112,7 @@ int NamedValueSet::size() const noexcept
return values.size();
}
const var& NamedValueSet::operator[] (const Identifier& name) const
const var& NamedValueSet::operator[] (const Identifier& name) const noexcept
{
if (const var* v = getVarPointer (name))
return *v;
@@ -170,7 +169,7 @@ bool NamedValueSet::set (Identifier name, const var& newValue)
return true;
}
bool NamedValueSet::contains (const Identifier& name) const
bool NamedValueSet::contains (const Identifier& name) const noexcept
{
return getVarPointer (name) != nullptr;
}
@@ -54,7 +54,7 @@ public:
#endif
/** Destructor. */
~NamedValueSet();
~NamedValueSet() noexcept;
bool operator== (const NamedValueSet&) const;
bool operator!= (const NamedValueSet&) const;
@@ -67,7 +67,7 @@ public:
If the name isn't found, this will return a void variant.
@see getProperty
*/
const var& operator[] (const Identifier& name) const;
const var& operator[] (const Identifier& name) const noexcept;
/** Tries to return the named value, but if no such value is found, this will
instead return the supplied default value.
@@ -89,7 +89,7 @@ public:
#endif
/** Returns true if the set contains an item with the specified name. */
bool contains (const Identifier& name) const;
bool contains (const Identifier& name) const noexcept;
/** Removes a value from the set.
@returns true if a value was removed; false if there was no value
@@ -830,7 +830,7 @@ public:
This will use a comparator object to sort the elements into order. The object
passed must have a method of the form:
@code
int compareElements (ElementType first, ElementType second);
int compareElements (ElementType* first, ElementType* second);
@endcode
..and this method must return:
@@ -26,32 +26,7 @@
==============================================================================
*/
WildcardFileFilter::WildcardFileFilter (const String& fileWildcardPatterns,
const String& directoryWildcardPatterns,
const String& desc)
: FileFilter (desc.isEmpty() ? fileWildcardPatterns
: (desc + " (" + fileWildcardPatterns + ")"))
{
parse (fileWildcardPatterns, fileWildcards);
parse (directoryWildcardPatterns, directoryWildcards);
}
WildcardFileFilter::~WildcardFileFilter()
{
}
bool WildcardFileFilter::isFileSuitable (const File& file) const
{
return match (file, fileWildcards);
}
bool WildcardFileFilter::isDirectorySuitable (const File& file) const
{
return match (file, directoryWildcards);
}
//==============================================================================
void WildcardFileFilter::parse (const String& pattern, StringArray& result)
static void parseWildcard (const String& pattern, StringArray& result)
{
result.addTokens (pattern.toLowerCase(), ";,", "\"'");
@@ -65,7 +40,7 @@ void WildcardFileFilter::parse (const String& pattern, StringArray& result)
result.set (i, "*");
}
bool WildcardFileFilter::match (const File& file, const StringArray& wildcards)
static bool matchWildcard (const File& file, const StringArray& wildcards)
{
const String filename (file.getFileName());
@@ -75,3 +50,27 @@ bool WildcardFileFilter::match (const File& file, const StringArray& wildcards)
return false;
}
WildcardFileFilter::WildcardFileFilter (const String& fileWildcardPatterns,
const String& directoryWildcardPatterns,
const String& desc)
: FileFilter (desc.isEmpty() ? fileWildcardPatterns
: (desc + " (" + fileWildcardPatterns + ")"))
{
parseWildcard (fileWildcardPatterns, fileWildcards);
parseWildcard (directoryWildcardPatterns, directoryWildcards);
}
WildcardFileFilter::~WildcardFileFilter()
{
}
bool WildcardFileFilter::isFileSuitable (const File& file) const
{
return matchWildcard (file, fileWildcards);
}
bool WildcardFileFilter::isDirectorySuitable (const File& file) const
{
return matchWildcard (file, directoryWildcards);
}
@@ -75,12 +75,8 @@ private:
//==============================================================================
StringArray fileWildcards, directoryWildcards;
static void parse (const String& pattern, StringArray& result);
static bool match (const File& file, const StringArray& wildcards);
JUCE_LEAK_DETECTOR (WildcardFileFilter)
};
#endif // JUCE_WILDCARDFILEFILTER_H_INCLUDED
@@ -544,7 +544,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
{
DivideOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperator (l, a, b, TokenTypes::divide) {}
var getWithDoubles (double a, double b) const override { return b != 0 ? a / b : std::numeric_limits<double>::infinity(); }
var getWithInts (int64 a, int64 b) const override { return b != 0 ? var (a / b) : var (std::numeric_limits<double>::infinity()); }
var getWithInts (int64 a, int64 b) const override { return b != 0 ? var (a / (double) b) : var (std::numeric_limits<double>::infinity()); }
};
struct ModuloOp : public BinaryOperator
@@ -1145,8 +1145,14 @@ struct JavascriptEngine::RootObject : public DynamicObject
match (TokenTypes::semicolon);
}
s->iterator = parseExpression();
match (TokenTypes::closeParen);
if (matchIf (TokenTypes::closeParen))
s->iterator = new Statement (location);
else
{
s->iterator = parseExpression();
match (TokenTypes::closeParen);
}
s->body = parseStatement();
return s.release();
}
@@ -1555,6 +1561,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
setMethod ("log", Math_log); setMethod ("log10", Math_log10);
setMethod ("exp", Math_exp); setMethod ("pow", Math_pow);
setMethod ("sqr", Math_sqr); setMethod ("sqrt", Math_sqrt);
setMethod ("ceil", Math_ceil); setMethod ("floor", Math_floor);
}
static var Math_pi (Args) { return double_Pi; }
@@ -1587,6 +1594,8 @@ struct JavascriptEngine::RootObject : public DynamicObject
static var Math_pow (Args a) { return pow (getDouble (a, 0), getDouble (a, 1)); }
static var Math_sqr (Args a) { double x = getDouble (a, 0); return x * x; }
static var Math_sqrt (Args a) { return std::sqrt (getDouble (a, 0)); }
static var Math_ceil (Args a) { return std::ceil (getDouble (a, 0)); }
static var Math_floor (Args a) { return std::floor (getDouble (a, 0)); }
static Identifier getClassName() { static const Identifier i ("Math"); return i; }
template <typename Type> static Type sign (Type n) noexcept { return n > 0 ? (Type) 1 : (n < 0 ? (Type) -1 : 0); }
@@ -53,6 +53,8 @@
#if JUCE_WINDOWS
#include <ctime>
#define _WINSOCK_DEPRECATED_NO_WARNINGS 1
#include <winsock2.h>
#include <ws2tcpip.h>
@@ -79,6 +81,7 @@
#if JUCE_LINUX
#include <langinfo.h>
#include <ifaddrs.h>
#endif
#include <pwd.h>
@@ -307,7 +307,7 @@ void BigInteger::negate() noexcept
negative = (! negative) && ! isZero();
}
#if JUCE_USE_INTRINSICS && ! defined (__INTEL_COMPILER)
#if JUCE_USE_MSVC_INTRINSICS && ! defined (__INTEL_COMPILER)
#pragma intrinsic (_BitScanReverse)
#endif
@@ -317,7 +317,7 @@ inline static int highestBitInInt (uint32 n) noexcept
#if JUCE_GCC
return 31 - __builtin_clz (n);
#elif JUCE_USE_INTRINSICS
#elif JUCE_USE_MSVC_INTRINSICS
unsigned long highest;
_BitScanReverse (&highest, n);
return (int) highest;
@@ -218,7 +218,7 @@ private:
#else
#define JUCE_ATOMICS_WINDOWS 1 // Windows with intrinsics
#if JUCE_USE_INTRINSICS
#if JUCE_USE_MSVC_INTRINSICS
#ifndef __INTEL_COMPILER
#pragma intrinsic (_InterlockedExchange, _InterlockedIncrement, _InterlockedDecrement, _InterlockedCompareExchange, \
_InterlockedCompareExchange64, _InterlockedExchangeAdd, _ReadWriteBarrier)
@@ -110,13 +110,13 @@ private:
//==============================================================================
#if JUCE_USE_INTRINSICS && ! defined (__INTEL_COMPILER)
#if JUCE_USE_MSVC_INTRINSICS && ! defined (__INTEL_COMPILER)
#pragma intrinsic (_byteswap_ulong)
#endif
inline uint16 ByteOrder::swap (uint16 n) noexcept
{
#if JUCE_USE_INTRINSICSxxx // agh - the MS compiler has an internal error when you try to use this intrinsic!
#if JUCE_USE_MSVC_INTRINSICSxxx // agh - the MS compiler has an internal error when you try to use this intrinsic!
return static_cast<uint16> (_byteswap_ushort (n));
#else
return static_cast<uint16> ((n << 8) | (n >> 8));
@@ -130,7 +130,7 @@ inline uint32 ByteOrder::swap (uint32 n) noexcept
#elif JUCE_GCC && JUCE_INTEL && ! JUCE_NO_INLINE_ASM
asm("bswap %%eax" : "=a"(n) : "a"(n));
return n;
#elif JUCE_USE_INTRINSICS
#elif JUCE_USE_MSVC_INTRINSICS
return _byteswap_ulong (n);
#elif JUCE_MSVC && ! JUCE_NO_INLINE_ASM
__asm {
@@ -150,7 +150,7 @@ inline uint64 ByteOrder::swap (uint64 value) noexcept
{
#if JUCE_MAC || JUCE_IOS
return OSSwapInt64 (value);
#elif JUCE_USE_INTRINSICS
#elif JUCE_USE_MSVC_INTRINSICS
return _byteswap_uint64 (value);
#else
return (((int64) swap ((uint32) value)) << 32) | swap ((uint32) (value >> 32));
@@ -88,14 +88,14 @@ MemoryBlock& MemoryBlock::operator= (const MemoryBlock& other)
#if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
MemoryBlock::MemoryBlock (MemoryBlock&& other) noexcept
: data (static_cast <HeapBlock<char>&&> (other.data)),
: data (static_cast<HeapBlock<char>&&> (other.data)),
size (other.size)
{
}
MemoryBlock& MemoryBlock::operator= (MemoryBlock&& other) noexcept
{
data = static_cast <HeapBlock<char>&&> (other.data);
data = static_cast<HeapBlock<char>&&> (other.data);
size = other.size;
return *this;
}
@@ -346,7 +346,7 @@ void MemoryBlock::loadFromHexString (StringRef hex)
if (c == 0)
{
setSize (static_cast <size_t> (dest - data));
setSize (static_cast<size_t> (dest - data));
return;
}
}
@@ -182,11 +182,11 @@ public:
/** Swaps this object with that of another ScopedPointer.
The two objects simply exchange their pointers.
*/
void swapWith (ScopedPointer <ObjectType>& other) noexcept
void swapWith (ScopedPointer<ObjectType>& other) noexcept
{
// Two ScopedPointers should never be able to refer to the same object - if
// this happens, you must have done something dodgy!
jassert (object != other.object || this == other.getAddress());
jassert (object != other.object || this == other.getAddress() || object == nullptr);
std::swap (object, other.object);
}
@@ -231,7 +231,7 @@ private:
template <class ObjectType>
bool operator== (const ScopedPointer<ObjectType>& pointer1, ObjectType* const pointer2) noexcept
{
return static_cast <ObjectType*> (pointer1) == pointer2;
return static_cast<ObjectType*> (pointer1) == pointer2;
}
/** Compares a ScopedPointer with another pointer.
@@ -240,7 +240,7 @@ bool operator== (const ScopedPointer<ObjectType>& pointer1, ObjectType* const po
template <class ObjectType>
bool operator!= (const ScopedPointer<ObjectType>& pointer1, ObjectType* const pointer2) noexcept
{
return static_cast <ObjectType*> (pointer1) != pointer2;
return static_cast<ObjectType*> (pointer1) != pointer2;
}
//==============================================================================
@@ -158,7 +158,7 @@ public:
public:
Master() noexcept {}
~Master()
~Master() noexcept
{
// You must remember to call clear() in your source object's destructor! See the notes
// for the WeakReference class for an example of how to do this.
@@ -187,7 +187,7 @@ public:
to zero all the references to this object that may be out there. See the WeakReference
class notes for an example of how to do this.
*/
void clear()
void clear() noexcept
{
if (sharedPointer != nullptr)
sharedPointer->clearPointer();
@@ -166,7 +166,7 @@ public:
int numBytes = stream.callIntMethod (HTTPStream.read, javaArray, (jint) bytesToRead);
if (numBytes > 0)
env->GetByteArrayRegion (javaArray, 0, numBytes, static_cast <jbyte*> (buffer));
env->GetByteArrayRegion (javaArray, 0, numBytes, static_cast<jbyte*> (buffer));
env->DeleteLocalRef (javaArray);
return numBytes;
@@ -31,26 +31,26 @@ void MACAddress::findAllAddresses (Array<MACAddress>& result)
const int s = socket (AF_INET, SOCK_DGRAM, 0);
if (s != -1)
{
char buf [1024];
struct ifconf ifc;
ifc.ifc_len = sizeof (buf);
ifc.ifc_buf = buf;
ioctl (s, SIOCGIFCONF, &ifc);
struct ifaddrs* addrs = nullptr;
for (unsigned int i = 0; i < ifc.ifc_len / sizeof (struct ifreq); ++i)
if (getifaddrs (&addrs) != -1)
{
struct ifreq ifr;
strcpy (ifr.ifr_name, ifc.ifc_req[i].ifr_name);
if (ioctl (s, SIOCGIFFLAGS, &ifr) == 0
&& (ifr.ifr_flags & IFF_LOOPBACK) == 0
&& ioctl (s, SIOCGIFHWADDR, &ifr) == 0)
for (struct ifaddrs* i = addrs; i != nullptr; i = i->ifa_next)
{
MACAddress ma ((const uint8*) ifr.ifr_hwaddr.sa_data);
struct ifreq ifr;
strcpy (ifr.ifr_name, i->ifa_name);
ifr.ifr_addr.sa_family = AF_INET;
if (! ma.isNull())
result.addIfNotAlreadyThere (ma);
if (ioctl (s, SIOCGIFHWADDR, &ifr) == 0)
{
MACAddress ma ((const uint8*) ifr.ifr_hwaddr.sa_data);
if (! ma.isNull())
result.addIfNotAlreadyThere (ma);
}
}
freeifaddrs (addrs);
}
close (s);
@@ -263,7 +263,7 @@ private:
}
}
String responseHeader (readResponse (socketHandle, timeOutTime));
String responseHeader (readResponse (timeOutTime));
position = 0;
if (responseHeader.isNotEmpty())
@@ -302,7 +302,7 @@ private:
}
//==============================================================================
String readResponse (const int socketHandle, const uint32 timeOutTime)
String readResponse (const uint32 timeOutTime)
{
int numConsecutiveLFs = 0;
MemoryOutputStream buffer;
@@ -338,7 +338,8 @@ private:
dest << "\r\n" << key << ' ' << value;
}
static void writeHost (MemoryOutputStream& dest, const bool isPost, const String& path, const String& host, const int port)
static void writeHost (MemoryOutputStream& dest, const bool isPost,
const String& path, const String& host, int /*port*/)
{
dest << (isPost ? "POST " : "GET ") << path << " HTTP/1.0\r\nHost: " << host;
}
@@ -234,7 +234,13 @@ namespace
if (isDir != nullptr) *isDir = statOk && ((info.st_mode & S_IFDIR) != 0);
if (fileSize != nullptr) *fileSize = statOk ? info.st_size : 0;
if (modTime != nullptr) *modTime = Time (statOk ? (int64) info.st_mtime * 1000 : 0);
if (creationTime != nullptr) *creationTime = Time (statOk ? (int64) info.st_ctime * 1000 : 0);
if (creationTime != nullptr) *creationTime = Time ((! statOk) ? 0 : (int64) (1000 *
#if JUCE_MAC || JUCE_IOS
info.st_birthtime));
#else
info.st_ctime));
#endif
}
if (isReadOnly != nullptr)
@@ -664,6 +670,7 @@ int File::getVolumeSerialNumber() const
}
//==============================================================================
#if ! JUCE_IOS
void juce_runSystemCommand (const String&);
void juce_runSystemCommand (const String& command)
{
@@ -684,7 +691,7 @@ String juce_getOutputFromCommand (const String& command)
tempFile.deleteFile();
return result;
}
#endif
//==============================================================================
#if JUCE_IOS
@@ -38,7 +38,7 @@ void Logger::outputDebugString (const String& text)
#endif
//==============================================================================
#if JUCE_USE_INTRINSICS
#if JUCE_USE_MSVC_INTRINSICS
// CPU info functions using intrinsics...
@@ -313,7 +313,7 @@ double Time::getMillisecondCounterHiRes() noexcept { return hiResCounterHa
//==============================================================================
static int64 juce_getClockCycleCounter() noexcept
{
#if JUCE_USE_INTRINSICS
#if JUCE_USE_MSVC_INTRINSICS
// MS intrinsics version...
return (int64) __rdtsc();
@@ -36,7 +36,7 @@ void* getUser32Function (const char* functionName)
}
//==============================================================================
#if ! JUCE_USE_INTRINSICS
#if ! JUCE_USE_MSVC_INTRINSICS
// In newer compilers, the inline versions of these are used (in juce_Atomic.h), but in
// older ones we have to actually call the ops as win32 functions..
long juce_InterlockedExchange (volatile long* a, long b) noexcept { return InterlockedExchange (a, b); }
@@ -418,8 +418,10 @@ bool StreamingSocket::createListener (const int newPortNumber, const String& loc
if (handle < 0)
return false;
#if ! JUCE_WINDOWS // on windows, adding this option produces behaviour different to posix
const int reuse = 1;
setsockopt (handle, SOL_SOCKET, SO_REUSEADDR, (const char*) &reuse, sizeof (reuse));
#endif
if (bind (handle, (struct sockaddr*) &servTmpAddr, sizeof (struct sockaddr_in)) < 0
|| listen (handle, SOMAXCONN) < 0)
@@ -179,6 +179,11 @@ String URL::toString (const bool includeGetParameters) const
return url;
}
bool URL::isEmpty() const noexcept
{
return url.isEmpty();
}
bool URL::isWellFormed() const
{
//xxx TODO
@@ -76,6 +76,9 @@ public:
*/
String toString (bool includeGetParameters) const;
/** Returns true if the URL is an empty string. */
bool isEmpty() const noexcept;
/** True if it seems to be valid. */
bool isWellFormed() const;
@@ -68,7 +68,7 @@
@see jassert()
*/
#define juce_breakDebugger { ::kill (0, SIGTRAP); }
#elif JUCE_USE_INTRINSICS
#elif JUCE_USE_MSVC_INTRINSICS
#ifndef __INTEL_COMPILER
#pragma intrinsic (__debugbreak)
#endif
@@ -211,6 +211,26 @@ namespace juce
#define JUCE_STRINGIFY(item) JUCE_STRINGIFY_MACRO_HELPER (item)
//==============================================================================
#if JUCE_MSVC && ! defined (DOXYGEN)
#define JUCE_WARNING_HELPER(file, line, mess) message(file "(" JUCE_STRINGIFY (line) ") : Warning: " #mess)
#define JUCE_COMPILER_WARNING(message) __pragma(JUCE_WARNING_HELPER (__FILE__, __LINE__, message));
#else
#ifndef DOXYGEN
#define JUCE_WARNING_HELPER(mess) message(#mess)
#endif
/** This macro allows you to emit a custom compiler warning message.
Very handy for marking bits of code as "to-do" items, or for shaming
code written by your co-workers in a way that's hard to ignore.
GCC and Clang provide the \#warning directive, but MSVC doesn't, so this macro
is a cross-compiler way to get the same functionality as \#warning.
*/
#define JUCE_COMPILER_WARNING(message) _Pragma(JUCE_STRINGIFY (JUCE_WARNING_HELPER (message)));
#endif
//==============================================================================
#if JUCE_CATCH_UNHANDLED_EXCEPTIONS
@@ -73,7 +73,7 @@
#include <vector>
#include <algorithm>
#if JUCE_USE_INTRINSICS
#if JUCE_USE_MSVC_INTRINSICS
#include <intrin.h>
#endif
@@ -155,7 +155,7 @@
#define JUCE_BIG_ENDIAN 1
#endif
#if defined (__LP64__) || defined (_LP64)
#if defined (__LP64__) || defined (_LP64) || defined (__arm64__)
#define JUCE_64BIT 1
#else
#define JUCE_32BIT 1
@@ -192,7 +192,7 @@
#endif
#if JUCE_64BIT || ! JUCE_VC7_OR_EARLIER
#define JUCE_USE_INTRINSICS 1
#define JUCE_USE_MSVC_INTRINSICS 1
#endif
#else
#error unknown compiler
@@ -1204,16 +1204,16 @@ public:
//==============================================================================
#if JUCE_MAC || JUCE_IOS || DOXYGEN
/** MAC ONLY - Creates a String from an OSX CFString. */
/** OSX ONLY - Creates a String from an OSX CFString. */
static String fromCFString (CFStringRef cfString);
/** MAC ONLY - Converts this string to a CFString.
/** OSX ONLY - Converts this string to a CFString.
Remember that you must use CFRelease() to free the returned string when you're
finished with it.
*/
CFStringRef toCFString() const;
/** MAC ONLY - Returns a copy of this string in which any decomposed unicode characters have
/** OSX ONLY - Returns a copy of this string in which any decomposed unicode characters have
been converted to their precomposed equivalents. */
String convertToPrecomposedUnicode() const;
#endif
@@ -714,7 +714,7 @@ bool XmlElement::isEquivalentTo (const XmlElement* const other,
{
if (thisAtt == nullptr || otherAtt == nullptr)
{
if (thisAtt == otherAtt) // both 0, so it's a match
if (thisAtt == otherAtt) // both nullptr, so it's a match
break;
return false;
@@ -599,10 +599,17 @@ public:
/** Returns true if the given element is a child of this one. */
bool containsChildElement (const XmlElement* possibleChild) const noexcept;
/** Recursively searches all sub-elements to find one that contains the specified
child element.
/** Recursively searches all sub-elements of this one, looking for an element
which is the direct parent of the specified element.
Because elements don't store a pointer to their parent, if you have one
and need to find its parent, the only way to do so is to exhaustively
search the whole tree for it.
If the given child is found somewhere in this element's hierarchy, then
this method will return its parent. If not, it will return nullptr.
*/
XmlElement* findParentElementOf (const XmlElement* elementToLookFor) noexcept;
XmlElement* findParentElementOf (const XmlElement* childToSearchFor) noexcept;
//==============================================================================
/** Sorts the child elements using a comparator.