mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 14:10:30 +03:00
Strict @property syntax compliance.
This enables the test suite to build with the -property switch enabled. std.cpuid: vendor()/processor() have not been converted to properties in accordance to core.cpuid. std.xml: Element.text() cannot be a property due to the optional parameter.
This commit is contained in:
parent
0eddab60b9
commit
e312f9898b
33 changed files with 603 additions and 593 deletions
102
std/encoding.d
102
std/encoding.d
|
@ -369,14 +369,14 @@ template EncoderFunctions()
|
|||
|
||||
template ReadFromString()
|
||||
{
|
||||
bool canRead() { return s.length != 0; }
|
||||
@property bool canRead() { return s.length != 0; }
|
||||
E peek() { return s[0]; }
|
||||
E read() { E t = s[0]; s = s[1..$]; return t; }
|
||||
}
|
||||
|
||||
template ReverseReadFromString()
|
||||
{
|
||||
bool canRead() { return s.length != 0; }
|
||||
@property bool canRead() { return s.length != 0; }
|
||||
E peek() { return s[$-1]; }
|
||||
E read() { E t = s[$-1]; s = s[0..$-1]; return t; }
|
||||
}
|
||||
|
@ -665,7 +665,7 @@ template EncoderInstance(CharType : AsciiChar)
|
|||
alias AsciiChar E;
|
||||
alias AsciiString EString;
|
||||
|
||||
string encodingName()
|
||||
@property string encodingName()
|
||||
{
|
||||
return "ASCII";
|
||||
}
|
||||
|
@ -709,21 +709,21 @@ template EncoderInstance(CharType : AsciiChar)
|
|||
|
||||
dchar decodeViaRead()()
|
||||
{
|
||||
return read;
|
||||
return read();
|
||||
}
|
||||
|
||||
dchar safeDecodeViaRead()()
|
||||
{
|
||||
dchar c = read;
|
||||
dchar c = read();
|
||||
return canEncode(c) ? c : INVALID_SEQUENCE;
|
||||
}
|
||||
|
||||
dchar decodeReverseViaRead()()
|
||||
{
|
||||
return read;
|
||||
return read();
|
||||
}
|
||||
|
||||
EString replacementSequence()
|
||||
@property EString replacementSequence()
|
||||
{
|
||||
return cast(EString)("?");
|
||||
}
|
||||
|
@ -748,7 +748,7 @@ template EncoderInstance(CharType : Latin1Char)
|
|||
alias Latin1Char E;
|
||||
alias Latin1String EString;
|
||||
|
||||
string encodingName()
|
||||
@property string encodingName()
|
||||
{
|
||||
return "ISO-8859-1";
|
||||
}
|
||||
|
@ -786,20 +786,20 @@ template EncoderInstance(CharType : Latin1Char)
|
|||
|
||||
dchar decodeViaRead()()
|
||||
{
|
||||
return read;
|
||||
return read();
|
||||
}
|
||||
|
||||
dchar safeDecodeViaRead()()
|
||||
{
|
||||
return read;
|
||||
return read();
|
||||
}
|
||||
|
||||
dchar decodeReverseViaRead()()
|
||||
{
|
||||
return read;
|
||||
return read();
|
||||
}
|
||||
|
||||
EString replacementSequence()
|
||||
@property EString replacementSequence()
|
||||
{
|
||||
return cast(EString)("?");
|
||||
}
|
||||
|
@ -824,7 +824,7 @@ template EncoderInstance(CharType : Windows1252Char)
|
|||
alias Windows1252Char E;
|
||||
alias Windows1252String EString;
|
||||
|
||||
string encodingName()
|
||||
@property string encodingName()
|
||||
{
|
||||
return "windows-1252";
|
||||
}
|
||||
|
@ -887,24 +887,24 @@ template EncoderInstance(CharType : Windows1252Char)
|
|||
|
||||
dchar decodeViaRead()()
|
||||
{
|
||||
Windows1252Char c = read;
|
||||
Windows1252Char c = read();
|
||||
return (c >= 0x80 && c < 0xA0) ? charMap[c-0x80] : c;
|
||||
}
|
||||
|
||||
dchar safeDecodeViaRead()()
|
||||
{
|
||||
Windows1252Char c = read;
|
||||
Windows1252Char c = read();
|
||||
dchar d = (c >= 0x80 && c < 0xA0) ? charMap[c-0x80] : c;
|
||||
return d == 0xFFFD ? INVALID_SEQUENCE : d;
|
||||
}
|
||||
|
||||
dchar decodeReverseViaRead()()
|
||||
{
|
||||
Windows1252Char c = read;
|
||||
Windows1252Char c = read();
|
||||
return (c >= 0x80 && c < 0xA0) ? charMap[c-0x80] : c;
|
||||
}
|
||||
|
||||
EString replacementSequence()
|
||||
@property EString replacementSequence()
|
||||
{
|
||||
return cast(EString)("?");
|
||||
}
|
||||
|
@ -921,7 +921,7 @@ template EncoderInstance(CharType : char)
|
|||
alias char E;
|
||||
alias immutable(char)[] EString;
|
||||
|
||||
string encodingName()
|
||||
@property string encodingName()
|
||||
{
|
||||
return "UTF-8";
|
||||
}
|
||||
|
@ -999,7 +999,7 @@ template EncoderInstance(CharType : char)
|
|||
|
||||
void skipViaRead()()
|
||||
{
|
||||
auto c = read;
|
||||
auto c = read();
|
||||
if (c < 0xC0) return;
|
||||
int n = tails(cast(char) c);
|
||||
for (size_t i=0; i<n; ++i)
|
||||
|
@ -1010,26 +1010,26 @@ template EncoderInstance(CharType : char)
|
|||
|
||||
dchar decodeViaRead()()
|
||||
{
|
||||
dchar c = read;
|
||||
dchar c = read();
|
||||
if (c < 0xC0) return c;
|
||||
int n = tails(cast(char) c);
|
||||
c &= (1 << (6 - n)) - 1;
|
||||
for (size_t i=0; i<n; ++i)
|
||||
{
|
||||
c = (c << 6) + (read & 0x3F);
|
||||
c = (c << 6) + (read() & 0x3F);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
dchar safeDecodeViaRead()()
|
||||
{
|
||||
dchar c = read;
|
||||
dchar c = read();
|
||||
if (c < 0x80) return c;
|
||||
int n = tails(cast(char) c);
|
||||
if (n == 0) return INVALID_SEQUENCE;
|
||||
|
||||
if (!canRead) return INVALID_SEQUENCE;
|
||||
size_t d = peek;
|
||||
size_t d = peek();
|
||||
bool err =
|
||||
(
|
||||
(c < 0xC2) // fail overlong 2-byte sequences
|
||||
|
@ -1044,9 +1044,9 @@ template EncoderInstance(CharType : char)
|
|||
for (size_t i=0; i<n; ++i)
|
||||
{
|
||||
if (!canRead) return INVALID_SEQUENCE;
|
||||
d = peek;
|
||||
d = peek();
|
||||
if ((d & 0xC0) != 0x80) return INVALID_SEQUENCE;
|
||||
c = (c << 6) + (read & 0x3F);
|
||||
c = (c << 6) + (read() & 0x3F);
|
||||
}
|
||||
|
||||
return err ? INVALID_SEQUENCE : c;
|
||||
|
@ -1054,14 +1054,14 @@ template EncoderInstance(CharType : char)
|
|||
|
||||
dchar decodeReverseViaRead()()
|
||||
{
|
||||
dchar c = read;
|
||||
dchar c = read();
|
||||
if (c < 0x80) return c;
|
||||
size_t shift = 0;
|
||||
c &= 0x3F;
|
||||
for (size_t i=0; i<4; ++i)
|
||||
{
|
||||
shift += 6;
|
||||
auto d = read;
|
||||
auto d = read();
|
||||
size_t n = tails(cast(char) d);
|
||||
size_t mask = n == 0 ? 0x3F : (1 << (6 - n)) - 1;
|
||||
c += ((d & mask) << shift);
|
||||
|
@ -1070,7 +1070,7 @@ template EncoderInstance(CharType : char)
|
|||
return c;
|
||||
}
|
||||
|
||||
EString replacementSequence()
|
||||
@property EString replacementSequence()
|
||||
{
|
||||
return "\uFFFD";
|
||||
}
|
||||
|
@ -1087,7 +1087,7 @@ template EncoderInstance(CharType : wchar)
|
|||
alias wchar E;
|
||||
alias immutable(wchar)[] EString;
|
||||
|
||||
string encodingName()
|
||||
@property string encodingName()
|
||||
{
|
||||
return "UTF-16";
|
||||
}
|
||||
|
@ -1128,16 +1128,16 @@ template EncoderInstance(CharType : wchar)
|
|||
|
||||
void skipViaRead()()
|
||||
{
|
||||
wchar c = read;
|
||||
wchar c = read();
|
||||
if (c < 0xD800 || c >= 0xE000) return;
|
||||
read();
|
||||
}
|
||||
|
||||
dchar decodeViaRead()()
|
||||
{
|
||||
wchar c = read;
|
||||
wchar c = read();
|
||||
if (c < 0xD800 || c >= 0xE000) return cast(dchar)c;
|
||||
wchar d = read;
|
||||
wchar d = read();
|
||||
c &= 0x3FF;
|
||||
d &= 0x3FF;
|
||||
return 0x10000 + (c << 10) + d;
|
||||
|
@ -1145,13 +1145,13 @@ template EncoderInstance(CharType : wchar)
|
|||
|
||||
dchar safeDecodeViaRead()()
|
||||
{
|
||||
wchar c = read;
|
||||
wchar c = read();
|
||||
if (c < 0xD800 || c >= 0xE000) return cast(dchar)c;
|
||||
if (c >= 0xDC00) return INVALID_SEQUENCE;
|
||||
if (!canRead) return INVALID_SEQUENCE;
|
||||
wchar d = peek;
|
||||
wchar d = peek();
|
||||
if (d < 0xDC00 || d >= 0xE000) return INVALID_SEQUENCE;
|
||||
d = read;
|
||||
d = read();
|
||||
c &= 0x3FF;
|
||||
d &= 0x3FF;
|
||||
return 0x10000 + (c << 10) + d;
|
||||
|
@ -1159,15 +1159,15 @@ template EncoderInstance(CharType : wchar)
|
|||
|
||||
dchar decodeReverseViaRead()()
|
||||
{
|
||||
wchar c = read;
|
||||
wchar c = read();
|
||||
if (c < 0xD800 || c >= 0xE000) return cast(dchar)c;
|
||||
wchar d = read;
|
||||
wchar d = read();
|
||||
c &= 0x3FF;
|
||||
d &= 0x3FF;
|
||||
return 0x10000 + (d << 10) + c;
|
||||
}
|
||||
|
||||
EString replacementSequence()
|
||||
@property EString replacementSequence()
|
||||
{
|
||||
return "\uFFFD"w;
|
||||
}
|
||||
|
@ -1184,7 +1184,7 @@ template EncoderInstance(CharType : dchar)
|
|||
alias dchar E;
|
||||
alias immutable(dchar)[] EString;
|
||||
|
||||
string encodingName()
|
||||
@property string encodingName()
|
||||
{
|
||||
return "UTF-32";
|
||||
}
|
||||
|
@ -1221,21 +1221,21 @@ template EncoderInstance(CharType : dchar)
|
|||
|
||||
dchar decodeViaRead()()
|
||||
{
|
||||
return cast(dchar)read;
|
||||
return cast(dchar)read();
|
||||
}
|
||||
|
||||
dchar safeDecodeViaRead()()
|
||||
{
|
||||
dchar c = read;
|
||||
dchar c = read();
|
||||
return isValidCodePoint(c) ? c : INVALID_SEQUENCE;
|
||||
}
|
||||
|
||||
dchar decodeReverseViaRead()()
|
||||
{
|
||||
return cast(dchar)read;
|
||||
return cast(dchar)read();
|
||||
}
|
||||
|
||||
EString replacementSequence()
|
||||
@property EString replacementSequence()
|
||||
{
|
||||
return "\uFFFD"d;
|
||||
}
|
||||
|
@ -1279,7 +1279,7 @@ bool isValidCodePoint(dchar c)
|
|||
assert(encodingName!(Latin1Char) == "ISO-8859-1");
|
||||
-----------------------------------
|
||||
*/
|
||||
string encodingName(T)()
|
||||
@property string encodingName(T)()
|
||||
{
|
||||
return EncoderInstance!(T).encodingName;
|
||||
}
|
||||
|
@ -2198,7 +2198,7 @@ abstract class EncodingScheme
|
|||
* Normally this will be a representation of some substitution
|
||||
* character, such as U+FFFD or '?'.
|
||||
*/
|
||||
abstract immutable(ubyte)[] replacementSequence();
|
||||
abstract @property immutable(ubyte)[] replacementSequence();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2442,7 +2442,7 @@ class EncodingSchemeASCII : EncodingScheme
|
|||
return c;
|
||||
}
|
||||
|
||||
override immutable(ubyte)[] replacementSequence()
|
||||
override @property immutable(ubyte)[] replacementSequence()
|
||||
{
|
||||
return cast(immutable(ubyte)[])"?";
|
||||
}
|
||||
|
@ -2526,7 +2526,7 @@ class EncodingSchemeLatin1 : EncodingScheme
|
|||
return c;
|
||||
}
|
||||
|
||||
override immutable(ubyte)[] replacementSequence()
|
||||
override @property immutable(ubyte)[] replacementSequence()
|
||||
{
|
||||
return cast(immutable(ubyte)[])"?";
|
||||
}
|
||||
|
@ -2594,7 +2594,7 @@ class EncodingSchemeWindows1252 : EncodingScheme
|
|||
return c;
|
||||
}
|
||||
|
||||
override immutable(ubyte)[] replacementSequence()
|
||||
override @property immutable(ubyte)[] replacementSequence()
|
||||
{
|
||||
return cast(immutable(ubyte)[])"?";
|
||||
}
|
||||
|
@ -2662,7 +2662,7 @@ class EncodingSchemeUtf8 : EncodingScheme
|
|||
return c;
|
||||
}
|
||||
|
||||
override immutable(ubyte)[] replacementSequence()
|
||||
override @property immutable(ubyte)[] replacementSequence()
|
||||
{
|
||||
return cast(immutable(ubyte)[])"\uFFFD";
|
||||
}
|
||||
|
@ -2740,7 +2740,7 @@ class EncodingSchemeUtf16Native : EncodingScheme
|
|||
return c;
|
||||
}
|
||||
|
||||
override immutable(ubyte)[] replacementSequence()
|
||||
override @property immutable(ubyte)[] replacementSequence()
|
||||
{
|
||||
return cast(immutable(ubyte)[])"\uFFFD"w;
|
||||
}
|
||||
|
@ -2818,7 +2818,7 @@ class EncodingSchemeUtf32Native : EncodingScheme
|
|||
return c;
|
||||
}
|
||||
|
||||
override immutable(ubyte)[] replacementSequence()
|
||||
override @property immutable(ubyte)[] replacementSequence()
|
||||
{
|
||||
return cast(immutable(ubyte)[])"\uFFFD"d;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue