mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Clarified comments around the JUCE_ALLOW_STATIC_NULL_VARIABLES items to make clear that they're deprecated
This commit is contained in:
parent
ef482e6c37
commit
85f74ca7d3
11 changed files with 59 additions and 77 deletions
|
|
@ -120,12 +120,8 @@ bool NamedValueSet::isEmpty() const noexcept { return values.isEmpty(); }
|
|||
|
||||
static const var& getNullVarRef() noexcept
|
||||
{
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
return var::null;
|
||||
#else
|
||||
static var nullVar;
|
||||
return nullVar;
|
||||
#endif
|
||||
}
|
||||
|
||||
const var& NamedValueSet::operator[] (const Identifier& name) const noexcept
|
||||
|
|
|
|||
|
|
@ -64,11 +64,6 @@ public:
|
|||
/** Destructor. */
|
||||
~var() noexcept;
|
||||
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
/** A static var object that can be used where you need an empty variant object. */
|
||||
static const var null;
|
||||
#endif
|
||||
|
||||
var (const var& valueToCopy);
|
||||
var (int value) noexcept;
|
||||
var (int64 value) noexcept;
|
||||
|
|
@ -277,6 +272,18 @@ public:
|
|||
*/
|
||||
static var readFromStream (InputStream& input);
|
||||
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
/** This was a static empty var object, but is now deprecated as it's too easy to accidentally
|
||||
use it indirectly during a static constructor, leading to hard-to-find order-of-initialisation
|
||||
problems.
|
||||
@deprecated If you need a default-constructed var, just use var() or {}.
|
||||
The only time you might miss having var::null available might be if you need to return an
|
||||
empty var from a function by reference, but if you need to do that, it's easy enough to use
|
||||
a function-local static var and return that, avoiding any order-of-initialisation issues.
|
||||
*/
|
||||
static const var null;
|
||||
#endif
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
class VariantType; friend class VariantType;
|
||||
|
|
|
|||
|
|
@ -87,15 +87,6 @@ public:
|
|||
/** Move assignment operator */
|
||||
File& operator= (File&&) noexcept;
|
||||
|
||||
//==============================================================================
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
/** This static constant is used for referring to an 'invalid' file.
|
||||
Bear in mind that you should avoid this kind of static variable, and always prefer
|
||||
to use File() or {} if you need a default-constructed File object.
|
||||
*/
|
||||
static const File nonexistent;
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
/** Checks whether the file actually exists.
|
||||
|
||||
|
|
@ -1037,6 +1028,16 @@ public:
|
|||
JUCE_DEPRECATED (static const StringRef separatorString);
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
/** This was a static empty File object, but is now deprecated as it's too easy to accidentally
|
||||
use it indirectly during a static constructor, leading to hard-to-find order-of-initialisation
|
||||
problems.
|
||||
@deprecated If you need a default-constructed File object, just use File() or {}.
|
||||
*/
|
||||
static const File nonexistent;
|
||||
#endif
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
String fullPath;
|
||||
|
|
|
|||
|
|
@ -138,17 +138,6 @@ public:
|
|||
/** Destructor. */
|
||||
~String() noexcept;
|
||||
|
||||
//==============================================================================
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
/** This is a static empty string object that can be used if you need a reference to one.
|
||||
The value of String::empty is exactly the same as String(), and in almost all cases
|
||||
it's better to avoid String::empty and just use String() or {} instead, so that the compiler
|
||||
only has to reason about locally-constructed objects, rather than taking into account
|
||||
the fact that you're referencing a global shared static memory address.
|
||||
*/
|
||||
static const String empty;
|
||||
#endif
|
||||
|
||||
/** This is the character encoding type used internally to store the string.
|
||||
|
||||
By setting the value of JUCE_STRING_UTF_TYPE to 8, 16, or 32, you can change the
|
||||
|
|
@ -1247,6 +1236,19 @@ public:
|
|||
*/
|
||||
int getReferenceCount() const noexcept;
|
||||
|
||||
//==============================================================================
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
/** This was a static empty string object, but is now deprecated as it's too easy to accidentally
|
||||
use it indirectly during a static constructor, leading to hard-to-find order-of-initialisation
|
||||
problems.
|
||||
@deprecated If you need an empty String object, just use String() or {}.
|
||||
The only time you might miss having String::empty available might be if you need to return an
|
||||
empty string from a function by reference, but if you need to do that, it's easy enough to use
|
||||
a function-local static String object and return that, avoiding any order-of-initialisation issues.
|
||||
*/
|
||||
static const String empty;
|
||||
#endif
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
CharPointerType text;
|
||||
|
|
|
|||
|
|
@ -120,12 +120,8 @@ const String& StringArray::operator[] (int index) const noexcept
|
|||
if (isPositiveAndBelow (index, strings.size()))
|
||||
return strings.getReference (index);
|
||||
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
return String::empty;
|
||||
#else
|
||||
static String empty;
|
||||
return empty;
|
||||
#endif
|
||||
}
|
||||
|
||||
String& StringArray::getReference (int index) noexcept
|
||||
|
|
|
|||
|
|
@ -447,12 +447,8 @@ int XmlElement::getNumAttributes() const noexcept
|
|||
|
||||
static const String& getEmptyStringRef() noexcept
|
||||
{
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
return String::empty;
|
||||
#else
|
||||
static String empty;
|
||||
return empty;
|
||||
#endif
|
||||
}
|
||||
|
||||
const String& XmlElement::getAttributeName (const int index) const noexcept
|
||||
|
|
|
|||
|
|
@ -688,12 +688,8 @@ ValueTree ValueTree::getSibling (int delta) const noexcept
|
|||
|
||||
static const var& getNullVarRef() noexcept
|
||||
{
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
return var::null;
|
||||
#else
|
||||
static var nullVar;
|
||||
return nullVar;
|
||||
#endif
|
||||
}
|
||||
|
||||
const var& ValueTree::operator[] (const Identifier& name) const noexcept
|
||||
|
|
|
|||
|
|
@ -532,19 +532,18 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
/** An invalid ValueTree that can be used if you need to return one as an error condition, etc.
|
||||
This invalid object is equivalent to ValueTree created with its default constructor, but
|
||||
you should always prefer to avoid it and use ValueTree() or {} instead.
|
||||
*/
|
||||
static const ValueTree invalid;
|
||||
#endif
|
||||
|
||||
/** Returns the total number of references to the shared underlying data structure that this
|
||||
ValueTree is using.
|
||||
*/
|
||||
int getReferenceCount() const noexcept;
|
||||
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
/** An invalid ValueTree that can be used if you need to return one as an error condition, etc.
|
||||
@deprecated If you need an empty ValueTree object, just use ValueTree() or {}.
|
||||
*/
|
||||
static const ValueTree invalid;
|
||||
#endif
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
JUCE_PUBLIC_IN_DLL_BUILD (class SharedObject)
|
||||
|
|
|
|||
|
|
@ -68,20 +68,12 @@ public:
|
|||
/** Compares two transforms. */
|
||||
bool operator!= (const AffineTransform& other) const noexcept;
|
||||
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
/** A ready-to-use identity transform.
|
||||
Note that you should always avoid using a static variable like this, and
|
||||
prefer AffineTransform() or {} if you need a default-constructed instance.
|
||||
*/
|
||||
static const AffineTransform identity;
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
/** Transforms a 2D coordinate using this matrix. */
|
||||
template <typename ValueType>
|
||||
void transformPoint (ValueType& x, ValueType& y) const noexcept
|
||||
{
|
||||
const ValueType oldX = x;
|
||||
auto oldX = x;
|
||||
x = static_cast<ValueType> (mat00 * oldX + mat01 * y + mat02);
|
||||
y = static_cast<ValueType> (mat10 * oldX + mat11 * y + mat12);
|
||||
}
|
||||
|
|
@ -95,7 +87,7 @@ public:
|
|||
void transformPoints (ValueType& x1, ValueType& y1,
|
||||
ValueType& x2, ValueType& y2) const noexcept
|
||||
{
|
||||
const ValueType oldX1 = x1, oldX2 = x2;
|
||||
auto oldX1 = x1, oldX2 = x2;
|
||||
x1 = static_cast<ValueType> (mat00 * oldX1 + mat01 * y1 + mat02);
|
||||
y1 = static_cast<ValueType> (mat10 * oldX1 + mat11 * y1 + mat12);
|
||||
x2 = static_cast<ValueType> (mat00 * oldX2 + mat01 * y2 + mat02);
|
||||
|
|
@ -112,7 +104,7 @@ public:
|
|||
ValueType& x2, ValueType& y2,
|
||||
ValueType& x3, ValueType& y3) const noexcept
|
||||
{
|
||||
const ValueType oldX1 = x1, oldX2 = x2, oldX3 = x3;
|
||||
auto oldX1 = x1, oldX2 = x2, oldX3 = x3;
|
||||
x1 = static_cast<ValueType> (mat00 * oldX1 + mat01 * y1 + mat02);
|
||||
y1 = static_cast<ValueType> (mat10 * oldX1 + mat11 * y1 + mat12);
|
||||
x2 = static_cast<ValueType> (mat00 * oldX2 + mat01 * y2 + mat02);
|
||||
|
|
@ -276,6 +268,13 @@ public:
|
|||
*/
|
||||
float getScaleFactor() const noexcept;
|
||||
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
/** A ready-to-use identity transform - now depracated.
|
||||
@deprecated If you need an identity transform, just use AffineTransform() or {}.
|
||||
*/
|
||||
static const AffineTransform identity;
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
/* The transform matrix is:
|
||||
|
||||
|
|
|
|||
|
|
@ -153,14 +153,6 @@ public:
|
|||
*/
|
||||
inline bool isNull() const noexcept { return image == nullptr; }
|
||||
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
/** A null Image object that can be used when you need to return an invalid image.
|
||||
This object is the equivalient to an Image created with the default constructor, and
|
||||
you should always prefer to use Image() or {} when you need an empty image object.
|
||||
*/
|
||||
static const Image null;
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
/** Returns the image's width (in pixels). */
|
||||
int getWidth() const noexcept;
|
||||
|
|
@ -420,6 +412,13 @@ public:
|
|||
/** @internal */
|
||||
explicit Image (ImagePixelData*) noexcept;
|
||||
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
/** A null Image object that can be used when you need to return an invalid image.
|
||||
@deprecated If you need a default-constructed var, just use Image() or {}.
|
||||
*/
|
||||
static const Image null;
|
||||
#endif
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
ReferenceCountedObjectPtr<ImagePixelData> image;
|
||||
|
|
|
|||
|
|
@ -117,8 +117,6 @@ namespace juce
|
|||
class MouseInputSource;
|
||||
class MouseInputSourceInternal;
|
||||
class ComponentPeer;
|
||||
class MarkerList;
|
||||
class RelativeRectangle;
|
||||
class MouseEvent;
|
||||
struct MouseWheelDetails;
|
||||
struct PenDetails;
|
||||
|
|
@ -130,28 +128,21 @@ namespace juce
|
|||
class ComboBox;
|
||||
class Button;
|
||||
class FilenameComponent;
|
||||
class DocumentWindow;
|
||||
class ResizableWindow;
|
||||
class GroupComponent;
|
||||
class MenuBarComponent;
|
||||
class DropShadower;
|
||||
class GlyphArrangement;
|
||||
class PropertyComponent;
|
||||
class TableHeaderComponent;
|
||||
class Toolbar;
|
||||
class ToolbarItemComponent;
|
||||
class PopupMenu;
|
||||
class ProgressBar;
|
||||
class FileBrowserComponent;
|
||||
class DirectoryContentsDisplayComponent;
|
||||
class FilePreviewComponent;
|
||||
class ImageButton;
|
||||
class CallOutBox;
|
||||
class Drawable;
|
||||
class DrawablePath;
|
||||
class DrawableComposite;
|
||||
class CaretComponent;
|
||||
class BubbleComponent;
|
||||
class KeyPressMappingSet;
|
||||
class ApplicationCommandManagerListener;
|
||||
class DrawableButton;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue