From 32460bbe93a459c8a64d9f98b7566536af8c92e5 Mon Sep 17 00:00:00 2001 From: Ben Palmer Date: Tue, 1 Oct 2019 15:40:43 +0000 Subject: [PATCH] Auto-convert to D2 --- .D2-ready | 2 +- integrationtest/flexiblefilequeue/main.d | 2 +- integrationtest/httpserver/main.d | 6 +- integrationtest/selectlistener/UnixServer.d | 2 +- integrationtest/signalfd/main.d | 4 +- integrationtest/unixsocket/main.d | 4 +- src/ocean/LibFeatures.d | 46 ++--- src/ocean/application/components/PidLock.d | 26 +-- src/ocean/application/components/Signals.d | 2 +- .../application/components/TaskScheduler.d | 4 +- src/ocean/application/components/Timers.d | 6 +- src/ocean/core/Array.d | 4 +- src/ocean/core/BitArray.d | 100 +++++----- src/ocean/core/Buffer.d | 30 +-- src/ocean/core/Enum.d | 32 ++-- src/ocean/core/Exception.d | 4 +- src/ocean/core/MessageFiber.d | 6 +- src/ocean/core/Optional.d | 24 +-- src/ocean/core/SmartEnum.d | 158 +++++++-------- src/ocean/core/SmartUnion.d | 36 ++-- src/ocean/core/StructConverter.d | 2 +- src/ocean/core/Test.d | 2 +- src/ocean/core/Traits.d | 98 +++++----- src/ocean/core/Tuple.d | 6 +- src/ocean/core/TypeConvert.d | 6 +- src/ocean/core/VersionCheck.d | 2 +- src/ocean/core/array/Mutation.d | 14 +- src/ocean/core/array/Search.d | 2 +- src/ocean/core/array/Transformation.d | 2 +- src/ocean/core/buffer/NoIndirections.d | 4 +- src/ocean/core/buffer/Void.d | 4 +- src/ocean/core/buffer/WithIndirections.d | 4 +- src/ocean/io/Console.d | 2 +- src/ocean/io/FilePath.d | 4 +- src/ocean/io/Path.d | 8 +- src/ocean/io/Retry.d | 4 +- src/ocean/io/Terminal.d | 66 +++---- src/ocean/io/compress/ZlibStream.d | 4 +- .../io/compress/lzo/LzoChunkCompressor.d | 4 +- src/ocean/io/compress/lzo/LzoHeader.d | 146 +++++++------- src/ocean/io/compress/lzo/c/lzoconf.d | 2 +- src/ocean/io/console/AppStatus.d | 10 +- src/ocean/io/console/StructTable.d | 12 +- src/ocean/io/console/Tables.d | 144 +++++++------- src/ocean/io/console/readline/c/readline.d | 2 +- src/ocean/io/device/Array.d | 6 +- src/ocean/io/device/File.d | 26 +-- src/ocean/io/device/TempFile.d | 12 +- src/ocean/io/digest/Fnv1.d | 30 +-- src/ocean/io/model/IConduit.d | 8 +- src/ocean/io/model/IFile.d | 12 +- .../io/model/SuspendableThrottlerCount.d | 6 +- src/ocean/io/select/EpollSelectDispatcher.d | 8 +- src/ocean/io/select/client/FileSystemEvent.d | 4 +- src/ocean/io/select/client/SelectEvent.d | 4 +- src/ocean/io/select/client/SignalEvent.d | 2 +- src/ocean/io/select/client/TimerEvent.d | 4 +- src/ocean/io/select/client/TimerSet.d | 2 +- .../io/select/client/model/ISelectClient.d | 2 +- src/ocean/io/select/fiber/SelectFiber.d | 4 +- src/ocean/io/select/protocol/SelectReader.d | 2 +- .../fiber/BufferedFiberSelectWriter.d | 2 +- .../select/protocol/fiber/FiberSelectReader.d | 6 +- .../select/protocol/task/TaskSelectClient.d | 2 +- .../protocol/task/TaskSelectTransceiver.d | 4 +- .../task/TaskSelectTransceiver_test.d | 4 +- .../protocol/task/internal/BufferedReader.d | 8 +- src/ocean/io/select/selector/EpollFdSanity.d | 8 +- .../io/select/selector/RegisteredClients.d | 4 +- .../io/select/selector/SelectedKeysHandler.d | 6 +- .../selector/TimeoutSelectedKeysHandler.d | 8 +- .../selector/model/ISelectedKeysHandler.d | 2 +- .../io/serialize/StringStructSerializer.d | 4 +- src/ocean/io/serialize/StructSerializer.d | 58 +++--- src/ocean/io/serialize/TypeId.d | 70 +++---- src/ocean/io/stream/Buffered.d | 14 +- src/ocean/io/stream/Format.d | 2 +- src/ocean/io/stream/Iterator.d | 6 +- src/ocean/io/stream/Zlib_internal.d | 6 +- src/ocean/io/vfs/FileFolder.d | 12 +- src/ocean/io/vfs/VirtualFolder.d | 10 +- src/ocean/io/vfs/model/Vfs.d | 8 +- src/ocean/math/Bessel.d | 68 +++---- src/ocean/math/BinaryHistogram.d | 22 +-- src/ocean/math/Bracket.d | 14 +- src/ocean/math/Distribution.d | 2 +- src/ocean/math/Elliptic.d | 14 +- src/ocean/math/ErrorFunction.d | 54 +++--- src/ocean/math/GammaFunction.d | 46 ++--- src/ocean/math/IEEE.d | 62 +++--- src/ocean/math/IncrementalAverage.d | 40 ++-- src/ocean/math/IrregularMovingAverage.d | 80 ++++---- src/ocean/math/Math.d | 46 ++--- src/ocean/math/Range.d | 68 +++---- src/ocean/math/TimeHistogram.d | 18 +- src/ocean/math/WideUInt.d | 60 +++--- src/ocean/math/internal/BignumX86.d | 2 +- src/ocean/math/internal/BiguintCore.d | 22 +-- src/ocean/math/random/ExpSource.d | 4 +- src/ocean/math/random/Kiss.d | 2 +- src/ocean/math/random/NormalSource.d | 4 +- src/ocean/math/random/Random.d | 74 +++---- src/ocean/math/random/Twister.d | 2 +- src/ocean/math/random/Ziggurat.d | 8 +- src/ocean/math/random/engines/ArraySource.d | 4 +- src/ocean/math/random/engines/CMWC.d | 10 +- src/ocean/math/random/engines/KISS.d | 8 +- src/ocean/math/random/engines/KissCmwc.d | 12 +- src/ocean/math/random/engines/Twister.d | 8 +- src/ocean/math/random/engines/URandom.d | 6 +- src/ocean/meta/codegen/Identifier.d | 6 +- src/ocean/meta/traits/Aggregates.d | 4 +- src/ocean/meta/traits/Arrays.d | 2 +- src/ocean/meta/traits/Basic.d | 48 ++--- src/ocean/meta/traits/Indirections.d | 6 +- src/ocean/meta/types/ReduceType.d | 2 +- src/ocean/meta/types/ReduceType_test.d | 4 +- src/ocean/meta/values/Reset_test.d | 24 +-- src/ocean/meta/values/VisitValue.d | 14 +- src/ocean/net/Uri.d | 6 +- src/ocean/net/collectd/Collectd.d | 2 +- src/ocean/net/collectd/Identifier.d | 16 +- src/ocean/net/collectd/SocketReader.d | 68 +++---- src/ocean/net/http/HttpConnectionHandler.d | 4 +- src/ocean/net/http/HttpConst.d | 118 ++++++------ src/ocean/net/http/HttpCookies.d | 6 +- src/ocean/net/http/HttpHeaders.d | 6 +- src/ocean/net/http/HttpParams.d | 2 +- src/ocean/net/http/HttpRequest.d | 12 +- src/ocean/net/http/HttpStack.d | 4 +- src/ocean/net/http/HttpTokens.d | 8 +- .../net/http/TaskHttpConnectionHandler.d | 4 +- .../net/http/consts/CookieAttributeNames.d | 2 +- src/ocean/net/http/consts/HeaderFieldNames.d | 8 +- src/ocean/net/http/consts/HttpMethod.d | 2 +- src/ocean/net/http/consts/HttpVersion.d | 4 +- src/ocean/net/http/consts/StatusCodes.d | 2 +- src/ocean/net/http/consts/UriDelim.d | 10 +- .../net/http/cookie/HttpCookieGenerator.d | 2 +- src/ocean/net/http/cookie/HttpCookieParser.d | 4 +- src/ocean/net/http/message/HttpHeaderParser.d | 20 +- src/ocean/net/http/model/HttpParamsView.d | 2 +- src/ocean/net/http/time/HttpTimeFormatter.d | 10 +- src/ocean/net/http/time/HttpTimeParser.d | 2 +- src/ocean/net/server/SelectListener.d | 2 +- .../net/server/SelectListener_slowtest.d | 4 +- .../server/connection/IConnectionHandler.d | 10 +- .../connection/IFiberConnectionHandler.d | 16 +- .../server/connection/TaskConnectionHandler.d | 6 +- .../server/connpool/ISelectListenerPoolInfo.d | 4 +- .../net/server/connpool/SelectListenerPool.d | 6 +- src/ocean/net/server/unix/CommandRegistry.d | 10 +- .../net/server/unix/UnixConnectionHandler.d | 22 +-- src/ocean/net/server/unix/UnixListener.d | 6 +- src/ocean/net/ssl/openssl/OpenSsl.d | 2 +- src/ocean/net/util/GetSocketAddress.d | 26 +-- src/ocean/net/util/ParamSet.d | 8 +- src/ocean/net/util/QueryParams.d | 4 +- src/ocean/net/util/UrlDecoder.d | 2 +- src/ocean/net/util/UrlEncoder.d | 8 +- src/ocean/stdc/posix/sys/un.d | 4 +- src/ocean/sys/CmdPath.d | 8 +- src/ocean/sys/CpuAffinity.d | 6 +- src/ocean/sys/Epoll.d | 20 +- src/ocean/sys/ErrnoException.d | 6 +- src/ocean/sys/EventFD.d | 2 +- src/ocean/sys/GetIfAddrs.d | 2 +- src/ocean/sys/Inotify.d | 4 +- src/ocean/sys/Process.d | 12 +- src/ocean/sys/SafeFork.d | 6 +- src/ocean/sys/SignalMask.d | 38 ++-- src/ocean/sys/TimerFD.d | 4 +- src/ocean/sys/socket/AddrInfo.d | 28 +-- src/ocean/sys/socket/IPSocket.d | 2 +- src/ocean/sys/socket/InetAddress.d | 58 +++--- src/ocean/sys/socket/model/ISocket.d | 2 +- src/ocean/sys/stats/linux/ProcVFS.d | 4 +- src/ocean/task/IScheduler.d | 2 +- src/ocean/task/Scheduler.d | 6 +- src/ocean/task/Task.d | 8 +- src/ocean/task/TaskPool_test.d | 4 +- .../task/extensions/ExceptionForwarding.d | 6 +- src/ocean/task/util/Event.d | 18 +- src/ocean/task/util/QuickRun.d | 4 +- src/ocean/text/Arguments.d | 20 +- src/ocean/text/Search.d | 14 +- src/ocean/text/UnicodeData.d | 2 +- src/ocean/text/Util.d | 12 +- src/ocean/text/arguments/TimeIntervalArgs.d | 4 +- src/ocean/text/convert/DateTime_tango.d | 12 +- src/ocean/text/convert/Formatter.d | 24 +-- src/ocean/text/convert/Formatter_test.d | 22 +-- src/ocean/text/convert/Hash.d | 2 +- src/ocean/text/convert/Hex.d | 4 +- src/ocean/text/convert/Integer.d | 2 +- src/ocean/text/convert/Integer_tango.d | 6 +- src/ocean/text/convert/TimeStamp.d | 4 +- src/ocean/text/convert/Utf.d | 6 +- src/ocean/text/convert/Utf_test.d | 6 +- src/ocean/text/csv/CSV.d | 4 +- src/ocean/text/csv/HeadingsCSV.d | 4 +- src/ocean/text/entities/HtmlEntitySet.d | 8 +- src/ocean/text/entities/XmlEntitySet.d | 2 +- src/ocean/text/entities/model/IEntitySet.d | 2 +- src/ocean/text/formatter/SmartUnion.d | 14 +- src/ocean/text/json/Json.d | 36 ++-- src/ocean/text/json/JsonEscape.d | 4 +- src/ocean/text/json/JsonExtractor.d | 6 +- src/ocean/text/json/JsonParser.d | 8 +- src/ocean/text/json/JsonParserIter.d | 10 +- src/ocean/text/regex/PCRE.d | 4 +- src/ocean/text/regex/c/pcre.d | 180 +++++++++--------- src/ocean/text/utf/GlibUnicode.d | 10 +- src/ocean/text/utf/UtfString.d | 48 ++--- src/ocean/text/utf/UtfUtil.d | 8 +- src/ocean/text/util/EscapeChars.d | 24 +-- src/ocean/text/util/MetricPrefix.d | 28 +-- src/ocean/text/util/SplitIterator.d | 4 +- src/ocean/text/util/StringC.d | 4 +- src/ocean/text/util/StringEncode.d | 6 +- src/ocean/text/util/StringSearch.d | 4 +- src/ocean/text/util/Time.d | 8 +- src/ocean/text/xml/DocEntity.d | 4 +- src/ocean/text/xml/DocPrinter.d | 4 +- src/ocean/text/xml/Document.d | 92 ++++----- src/ocean/text/xml/PullParser.d | 10 +- src/ocean/text/xml/SaxParser.d | 2 +- src/ocean/time/ISO8601.d | 10 +- src/ocean/time/StopWatch.d | 4 +- src/ocean/time/Time.d | 28 +-- src/ocean/time/chrono/Hebrew.d | 20 +- src/ocean/time/chrono/Hijri.d | 2 +- src/ocean/time/timeout/TimeoutManager.d | 6 +- .../time/timeout/model/ITimeoutManager.d | 2 +- src/ocean/transition.d | 10 +- src/ocean/util/Convert.d | 24 +-- src/ocean/util/DeepReset.d | 24 +-- src/ocean/util/aio/AsyncIO.d | 6 +- src/ocean/util/aio/DelegateJobNotification.d | 8 +- src/ocean/util/aio/internal/JobQueue.d | 18 +- src/ocean/util/app/ext/LogExt.d | 2 +- src/ocean/util/app/ext/ReopenableFilesExt.d | 2 +- src/ocean/util/app/ext/TaskExt.d | 2 +- src/ocean/util/app/ext/TimerExt.d | 6 +- src/ocean/util/app/ext/UnixSocketExt.d | 12 +- src/ocean/util/app/ext/VersionArgsExt.d | 2 +- src/ocean/util/cipher/gcrypt/AES.d | 18 +- src/ocean/util/cipher/gcrypt/PBKDF2.d | 4 +- src/ocean/util/cipher/gcrypt/c/gpgerror.d | 10 +- src/ocean/util/cipher/misc/ByteConverter.d | 2 +- src/ocean/util/cipher/misc/Padding.d | 2 +- src/ocean/util/compress/c/zlib.d | 10 +- src/ocean/util/config/ConfigFiller.d | 68 +++---- src/ocean/util/config/ConfigParser.d | 20 +- src/ocean/util/container/AppendBuffer.d | 10 +- src/ocean/util/container/CircularList.d | 10 +- src/ocean/util/container/Clink.d | 44 ++--- src/ocean/util/container/ConcatBuffer.d | 4 +- src/ocean/util/container/Container.d | 4 +- src/ocean/util/container/FixedKeyMap.d | 6 +- src/ocean/util/container/HashRangeMap.d | 60 +++--- src/ocean/util/container/HashSet.d | 6 +- src/ocean/util/container/LinkedList.d | 6 +- src/ocean/util/container/RedBlack.d | 70 +++---- src/ocean/util/container/Slink.d | 46 ++--- src/ocean/util/container/SortedMap.d | 10 +- .../util/container/VoidBufferAsArrayOf.d | 14 +- src/ocean/util/container/btree/BTreeMap.d | 26 +-- .../util/container/btree/BTreeMapRange.d | 56 +++--- .../util/container/btree/Implementation.d | 100 +++++----- src/ocean/util/container/cache/Cache.d | 22 +-- .../container/cache/CachingStructLoader.d | 8 +- .../cache/CachingStructLoader_test.d | 2 +- .../container/cache/ExpiredCacheReloader.d | 8 +- .../cache/ExpiredCacheReloader_test.d | 2 +- .../util/container/cache/LRUCache_test.d | 12 +- .../util/container/cache/PriorityCache.d | 40 ++-- src/ocean/util/container/cache/model/Value.d | 18 +- .../cache/model/containers/TimeToIndex.d | 6 +- src/ocean/util/container/ebtree/EBTree128.d | 6 +- src/ocean/util/container/ebtree/EBTree32.d | 8 +- src/ocean/util/container/ebtree/EBTree64.d | 8 +- src/ocean/util/container/ebtree/c/eb128tree.d | 28 +-- src/ocean/util/container/ebtree/c/eb32tree.d | 16 +- src/ocean/util/container/ebtree/c/eb64tree.d | 16 +- src/ocean/util/container/ebtree/c/ebtree.d | 34 ++-- .../util/container/ebtree/model/Iterators.d | 4 +- .../container/ebtree/model/KeylessMethods.d | 4 +- src/ocean/util/container/ebtree/model/Node.d | 30 +-- src/ocean/util/container/map/HashMap.d | 2 +- src/ocean/util/container/map/Map.d | 10 +- src/ocean/util/container/map/TreeMap.d | 40 ++-- src/ocean/util/container/map/model/Bucket.d | 44 ++--- .../map/model/BucketElementFreeList.d | 2 +- .../map/model/BucketElementMallocAllocator.d | 2 +- .../util/container/map/model/BucketInfo.d | 4 +- .../util/container/map/model/BucketSet.d | 6 +- .../util/container/map/model/IAllocator.d | 4 +- .../map/model/IBucketElementGCAllocator.d | 2 +- .../util/container/map/model/MapIterator.d | 10 +- .../util/container/map/model/StandardHash.d | 12 +- .../util/container/map/utils/MapSerializer.d | 74 +++---- src/ocean/util/container/model/IContainer.d | 2 +- src/ocean/util/container/more/BitSet.d | 8 +- src/ocean/util/container/more/HashFile.d | 12 +- src/ocean/util/container/more/Heap.d | 6 +- src/ocean/util/container/more/Stack.d | 12 +- src/ocean/util/container/more/Vector.d | 8 +- .../util/container/pool/AcquiredResources.d | 88 ++++----- .../container/pool/model/IAggregatePool.d | 6 +- .../util/container/pool/model/IFreeList.d | 2 +- .../util/container/pool/model/ILimitable.d | 2 +- src/ocean/util/container/pool/model/IPool.d | 8 +- .../util/container/queue/FlexibleFileQueue.d | 2 +- .../util/container/queue/FlexibleRingQueue.d | 10 +- .../util/container/queue/LinkedListQueue.d | 6 +- .../util/container/queue/NotifyingQueue.d | 6 +- src/ocean/util/digest/Md4.d | 2 +- src/ocean/util/digest/Ripemd128.d | 2 +- src/ocean/util/digest/Ripemd160.d | 2 +- src/ocean/util/digest/Ripemd256.d | 2 +- src/ocean/util/digest/Ripemd320.d | 2 +- src/ocean/util/digest/Sha01.d | 4 +- src/ocean/util/digest/Sha256.d | 2 +- src/ocean/util/digest/Sha512.d | 2 +- src/ocean/util/digest/Tiger.d | 2 +- src/ocean/util/digest/Whirlpool.d | 4 +- src/ocean/util/encode/Base16.d | 2 +- src/ocean/util/encode/Base32.d | 2 +- src/ocean/util/encode/Base64.d | 12 +- src/ocean/util/log/AppendSysLog.d | 2 +- src/ocean/util/log/Appender.d | 6 +- src/ocean/util/log/Config.d | 20 +- src/ocean/util/log/Event.d | 2 +- src/ocean/util/log/Hierarchy.d | 4 +- src/ocean/util/log/InsertConsole.d | 2 +- src/ocean/util/log/LayoutDate.d | 2 +- src/ocean/util/log/Logger.d | 16 +- src/ocean/util/log/PeriodicTrace.d | 30 +-- src/ocean/util/log/Stats.d | 6 +- src/ocean/util/log/StatsReader.d | 16 +- src/ocean/util/log/layout/LayoutMessageOnly.d | 2 +- src/ocean/util/log/layout/LayoutSimple.d | 2 +- src/ocean/util/log/layout/LayoutStatsLog.d | 2 +- src/ocean/util/log/model/ILogger.d | 2 +- .../prometheus/collector/CollectorRegistry.d | 4 +- .../prometheus/server/PrometheusHandler.d | 2 +- src/ocean/util/serialize/Version.d | 14 +- .../util/serialize/contiguous/Contiguous.d | 22 +-- .../util/serialize/contiguous/Deserializer.d | 4 +- .../contiguous/MultiVersionDecorator.d | 82 ++++---- .../util/serialize/contiguous/Serializer.d | 2 +- .../util/serialize/contiguous/package_.d | 28 +-- .../serialize/model/VersionDecoratorMixins.d | 2 +- 354 files changed, 2730 insertions(+), 2730 deletions(-) diff --git a/.D2-ready b/.D2-ready index 8e9078b76..bc8c7b4a2 100644 --- a/.D2-ready +++ b/.D2-ready @@ -1 +1 @@ -Enables D2 testing in Jenkins +ONLY diff --git a/integrationtest/flexiblefilequeue/main.d b/integrationtest/flexiblefilequeue/main.d index 327748329..c464aaf8e 100644 --- a/integrationtest/flexiblefilequeue/main.d +++ b/integrationtest/flexiblefilequeue/main.d @@ -25,7 +25,7 @@ public void main () auto test_dir = DirectorySandbox.create(["flexiblefilequeue"]); scope (exit) test_dir.remove(); - const istring test_file = "testfile"; + static immutable istring test_file = "testfile"; static void pushItems (FlexibleFileQueue queue, size_t size) diff --git a/integrationtest/httpserver/main.d b/integrationtest/httpserver/main.d index 64a0f8500..7b1f2eb67 100644 --- a/integrationtest/httpserver/main.d +++ b/integrationtest/httpserver/main.d @@ -35,7 +35,7 @@ import core.stdc.errno; import core.stdc.stdlib; /// The payload of the HTTP response. -const response_payload = "Hello World!"; +static immutable response_payload = "Hello World!"; /// The server address, initialised in `main` and used by both the server and /// the client. @@ -47,7 +47,7 @@ class TestHttpHandler: TaskHttpConnectionHandler { import ocean.io.Stdout; - public this ( FinalizeDg finalizer ) + public this ( scope FinalizeDg finalizer ) { super(finalizer, HttpMethod.Get); } @@ -171,7 +171,7 @@ static class ResponseParser char[] response; /// The token that denotes the end of the HTTP header and the beginning of /// the payload. - const end_of_header_token = "\r\n\r\n"; + static immutable end_of_header_token = "\r\n\r\n"; /// true if `end_of_header_token` has been fond in `response`. bool have_payload; /// The index in `response` after `end_of_header_token`. diff --git a/integrationtest/selectlistener/UnixServer.d b/integrationtest/selectlistener/UnixServer.d index 3e78143b3..dd9c51123 100644 --- a/integrationtest/selectlistener/UnixServer.d +++ b/integrationtest/selectlistener/UnixServer.d @@ -99,7 +99,7 @@ private class UnixConnectionHandler: IFiberConnectionHandler ***************************************************************************/ - public this ( FinalizeDg finalize_dg, EpollSelectDispatcher epoll ) + public this ( scope FinalizeDg finalize_dg, EpollSelectDispatcher epoll ) { super(epoll, new UnixSocket, finalize_dg); diff --git a/integrationtest/signalfd/main.d b/integrationtest/signalfd/main.d index 4bfd477c7..e762048a5 100644 --- a/integrationtest/signalfd/main.d +++ b/integrationtest/signalfd/main.d @@ -67,7 +67,7 @@ private class SignalFDTest ***************************************************************************/ - private const max_signal = 32; + private static immutable max_signal = 32; /*************************************************************************** @@ -431,7 +431,7 @@ private class SignalFDTest while (ret == -1 && errno == EINTR); enforce (ret == 0); - const int timeout_ms = 100; // just in case + static immutable int timeout_ms = 100; // just in case epoll_event_t[1] fired_events; auto epoll_res = epoll.wait(fired_events, timeout_ms); diff --git a/integrationtest/unixsocket/main.d b/integrationtest/unixsocket/main.d index 2811c9ac6..e8a95033d 100644 --- a/integrationtest/unixsocket/main.d +++ b/integrationtest/unixsocket/main.d @@ -41,9 +41,9 @@ import core.thread; import ocean.text.util.StringC; -const istring CLIENT_STRING = "Hello from the client"; +static immutable istring CLIENT_STRING = "Hello from the client"; -const istring SERVER_STRING = "Hello from the server"; +static immutable istring SERVER_STRING = "Hello from the server"; int runClient ( sockaddr_un* socket_address ) { diff --git a/src/ocean/LibFeatures.d b/src/ocean/LibFeatures.d index 833755714..bf0498089 100644 --- a/src/ocean/LibFeatures.d +++ b/src/ocean/LibFeatures.d @@ -17,26 +17,26 @@ module ocean.LibFeatures; -const has_features_4_2 = true; -const has_features_4_1 = true; -const has_features_4_0 = true; -const has_features_3_9 = true; -const has_features_3_8 = true; -const has_features_3_7 = true; -const has_features_3_6 = true; -const has_features_3_5 = true; -const has_features_3_4 = true; -const has_features_3_3 = true; -const has_features_3_2 = true; -const has_features_3_1 = true; -const has_features_3_0 = true; -const has_features_2_10 = true; -const has_features_2_9 = true; -const has_features_2_8 = true; -const has_features_2_7 = true; -const has_features_2_6 = true; -const has_features_2_5 = true; -const has_features_2_4 = true; -const has_features_2_3 = true; -const has_features_2_1 = true; -const has_features_2_0 = true; +static immutable has_features_4_2 = true; +static immutable has_features_4_1 = true; +static immutable has_features_4_0 = true; +static immutable has_features_3_9 = true; +static immutable has_features_3_8 = true; +static immutable has_features_3_7 = true; +static immutable has_features_3_6 = true; +static immutable has_features_3_5 = true; +static immutable has_features_3_4 = true; +static immutable has_features_3_3 = true; +static immutable has_features_3_2 = true; +static immutable has_features_3_1 = true; +static immutable has_features_3_0 = true; +static immutable has_features_2_10 = true; +static immutable has_features_2_9 = true; +static immutable has_features_2_8 = true; +static immutable has_features_2_7 = true; +static immutable has_features_2_6 = true; +static immutable has_features_2_5 = true; +static immutable has_features_2_4 = true; +static immutable has_features_2_3 = true; +static immutable has_features_2_1 = true; +static immutable has_features_2_0 = true; diff --git a/src/ocean/application/components/PidLock.d b/src/ocean/application/components/PidLock.d index 078194074..057189aa5 100644 --- a/src/ocean/application/components/PidLock.d +++ b/src/ocean/application/components/PidLock.d @@ -70,7 +70,7 @@ public struct PidLock public void parseConfig ( ConfigParser config ) { - this.pidlock_path = config.get("PidLock", "path", "").dup; + (&this).pidlock_path = config.get("PidLock", "path", "").dup; } /*************************************************************************** @@ -84,12 +84,12 @@ public struct PidLock public void lock ( ) { - if (this.pidlock_path.length) + if ((&this).pidlock_path.length) { istring msg = - idup("Couldn't lock the pid lock file '" ~ this.pidlock_path + idup("Couldn't lock the pid lock file '" ~ (&this).pidlock_path ~ "'. Probably another instance of the application is running."); - enforce(this.tryLockPidFile(), msg); + enforce((&this).tryLockPidFile(), msg); } } @@ -104,14 +104,14 @@ public struct PidLock public void unlock ( ) { - if (!this.is_locked) + if (!(&this).is_locked) { return; } // releases the lock and closes the lock file - this.enforcePosix!(close)(this.lock_fd); - this.enforcePosix!(unlink)(StringC.toCString(this.pidlock_path)); + (&this).enforcePosix!(close)((&this).lock_fd); + (&this).enforcePosix!(unlink)(StringC.toCString((&this).pidlock_path)); } /*************************************************************************** @@ -134,11 +134,11 @@ public struct PidLock private bool tryLockPidFile ( ) { - this.lock_fd = this.enforcePosix!(open)(StringC.toCString(this.pidlock_path), + (&this).lock_fd = (&this).enforcePosix!(open)(StringC.toCString((&this).pidlock_path), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); // TODO these will be available in tango v1.6.0 - const F_SETLK = 6; + enum F_SETLK = 6; // Lock the pidfile flock fl; @@ -147,7 +147,7 @@ public struct PidLock fl.l_start = 0; fl.l_len = 0; - if (fcntl(this.lock_fd, F_SETLK, &fl) == -1) + if (fcntl((&this).lock_fd, F_SETLK, &fl) == -1) { // Region already locked, can't acquire a lock if (errno == EAGAIN || errno == EACCES) @@ -161,14 +161,14 @@ public struct PidLock } // Clear the any previous contents of the file - this.enforcePosix!(ftruncate)(this.lock_fd, 0); + (&this).enforcePosix!(ftruncate)((&this).lock_fd, 0); char[512] buf; auto pid_string = snformat(buf, "{}\n", getpid()); - this.writeNonInterrupted(this.lock_fd, pid_string); + (&this).writeNonInterrupted((&this).lock_fd, pid_string); - this.is_locked = true; + (&this).is_locked = true; return true; } diff --git a/src/ocean/application/components/Signals.d b/src/ocean/application/components/Signals.d index d8eb6943a..b38863585 100644 --- a/src/ocean/application/components/Signals.d +++ b/src/ocean/application/components/Signals.d @@ -169,7 +169,7 @@ public class Signals ***************************************************************************/ - public this ( HandlerDg handler_dg ) + public this ( scope HandlerDg handler_dg ) { verify(handler_dg !is null); this.handler_dg = handler_dg; diff --git a/src/ocean/application/components/TaskScheduler.d b/src/ocean/application/components/TaskScheduler.d index 15d8bc026..62511b52a 100644 --- a/src/ocean/application/components/TaskScheduler.d +++ b/src/ocean/application/components/TaskScheduler.d @@ -40,7 +40,7 @@ public void parseSchedulerConfig ( ConfigParser parser, if (parser is null) return; - const category = "SCHEDULER"; + static immutable category = "SCHEDULER"; foreach (idx, ref field; config.tupleof) { @@ -92,7 +92,7 @@ public void parseSchedulerConfig ( ConfigParser parser, *******************************************************************************/ -public int runInTask ( int delegate () dg ) +public int runInTask ( scope int delegate () dg ) { auto task = new class Task { int delegate() dg; diff --git a/src/ocean/application/components/Timers.d b/src/ocean/application/components/Timers.d index 9ae3faaee..e36bc115b 100644 --- a/src/ocean/application/components/Timers.d +++ b/src/ocean/application/components/Timers.d @@ -111,7 +111,7 @@ public class Timers ***************************************************************************/ - public void register ( EventDg dg, double period_s ) + public void register ( scope EventDg dg, double period_s ) { verify(dg !is null); verify(period_s >= 0.0); @@ -131,7 +131,7 @@ public class Timers ***************************************************************************/ - public void register ( EventDg dg, double init_s, double period_s ) + public void register ( scope EventDg dg, double init_s, double period_s ) { verify(dg !is null); verify(init_s >= 0.0); @@ -157,7 +157,7 @@ public class Timers ***************************************************************************/ - public void registerMicrosec ( EventDg dg, ulong init_microsec, ulong period_microsec ) + public void registerMicrosec ( scope EventDg dg, ulong init_microsec, ulong period_microsec ) { verify(dg !is null); diff --git a/src/ocean/core/Array.d b/src/ocean/core/Array.d index 745267456..060679c07 100644 --- a/src/ocean/core/Array.d +++ b/src/ocean/core/Array.d @@ -128,8 +128,8 @@ unittest test(concat_test(dest, staticstr1, staticstr2), "Static array concatenation test failed"); // Check manifest constant array concatenation - const conststr1 = "hi "; - const conststr2 = "there"; + static immutable conststr1 = "hi "; + static immutable conststr2 = "there"; test(concat_test(dest, conststr1, conststr2), "Const array concatenation test failed"); } diff --git a/src/ocean/core/BitArray.d b/src/ocean/core/BitArray.d index c048defa6..5c53ce31c 100644 --- a/src/ocean/core/BitArray.d +++ b/src/ocean/core/BitArray.d @@ -162,7 +162,7 @@ struct BitArray length = bits.length; foreach( i, b; bits ) { - (*this)[i] = b; + (*(&this))[i] = b; } } @@ -189,9 +189,9 @@ struct BitArray { verify(rhs.len == len); - auto dimension = this.dim(); - this.ptr[0..dimension] = rhs.ptr[0..dimension]; - return *this; + auto dimension = (&this).dim(); + (&this).ptr[0..dimension] = rhs.ptr[0..dimension]; + return *(&this); } @@ -252,7 +252,7 @@ struct BitArray BitArray reverse() out( result ) { - assert(compare(result, *this)); + assert(compare(result, *(&this))); } body { @@ -265,12 +265,12 @@ struct BitArray hi = len - 1; for( ; lo < hi; ++lo, --hi ) { - t = (*this)[lo]; - (*this)[lo] = (*this)[hi]; - (*this)[hi] = t; + t = (*(&this))[lo]; + (*(&this))[lo] = (*(&this))[hi]; + (*(&this))[hi] = t; } } - return *this; + return *(&this); } @@ -296,7 +296,7 @@ struct BitArray BitArray sort() out( result ) { - assert(compare(result, *this)); + assert(compare(result, *(&this))); } body { @@ -312,7 +312,7 @@ struct BitArray { if( lo >= hi ) goto Ldone; - if( (*this)[lo] == true ) + if( (*(&this))[lo] == true ) break; ++lo; } @@ -321,13 +321,13 @@ struct BitArray { if( lo >= hi ) goto Ldone; - if( (*this)[hi] == false ) + if( (*(&this))[hi] == false ) break; --hi; } - (*this)[lo] = false; - (*this)[hi] = true; + (*(&this))[lo] = false; + (*(&this))[hi] = true; ++lo; --hi; @@ -335,7 +335,7 @@ struct BitArray Ldone: ; } - return *this; + return *(&this); } @@ -357,7 +357,7 @@ struct BitArray * Params: * dg = The supplied code as a delegate. */ - int opApply( int delegate(ref bool) dg ) + int opApply( scope int delegate(ref bool) dg ) { int result; @@ -374,7 +374,7 @@ struct BitArray /** ditto */ - int opApply( int delegate(ref size_t, ref bool) dg ) + int opApply( scope int delegate(ref size_t, ref bool) dg ) { int result; @@ -431,7 +431,7 @@ struct BitArray */ int opEquals( BitArray rhs ) { - return compare(*this, rhs); + return compare(*(&this), rhs); } // FIXME_IN_D2: allows comparing both mutable @@ -490,10 +490,10 @@ struct BitArray */ int opCmp( BitArray rhs ) { - auto len = this.length; + auto len = (&this).length; if( rhs.length < len ) len = rhs.length; - uint* p1 = this.ptr; + uint* p1 = (&this).ptr; uint* p2 = rhs.ptr; size_t n = len / 32; size_t i; @@ -510,7 +510,7 @@ struct BitArray uint v2=p2[i] & mask; if (v1 != v2) return ((v1 num_bits); bit_array.length = greater_length; foreach (pos, bit; bit_array) @@ -1124,7 +1124,7 @@ unittest // Decreases the length of the BitArray to a shorter length than the // initial one and checks all bits remain set. - const lower_length = size_of_uint * 5; + static immutable lower_length = size_of_uint * 5; static assert(lower_length < num_bits); bit_array.length = lower_length; foreach (bit; bit_array) diff --git a/src/ocean/core/Buffer.d b/src/ocean/core/Buffer.d index 54114c228..ea84aaea2 100644 --- a/src/ocean/core/Buffer.d +++ b/src/ocean/core/Buffer.d @@ -103,7 +103,7 @@ struct Buffer ( T ) void reset ( ) { - this.length = 0; + (&this).length = 0; } /*************************************************************************** @@ -113,9 +113,9 @@ struct Buffer ( T ) ***************************************************************************/ - size_t length ( ) /* d1to2fix_inject: const */ + size_t length ( ) const { - return this.data.length; + return (&this).data.length; } /*************************************************************************** @@ -130,10 +130,10 @@ struct Buffer ( T ) void length ( size_t new_length ) { version (D_Version2) - assumeSafeAppend(this.data); - this.data.length = new_length; + assumeSafeAppend((&this).data); + (&this).data.length = new_length; version (D_Version2) - assumeSafeAppend(this.data); + assumeSafeAppend((&this).data); } /*************************************************************************** @@ -149,12 +149,12 @@ struct Buffer ( T ) void reserve ( size_t new_length ) { version (D_Version2) - assumeSafeAppend(this.data); - auto old_length = this.data.length; - this.data.length = new_length; - this.data.length = old_length; + assumeSafeAppend((&this).data); + auto old_length = (&this).data.length; + (&this).data.length = new_length; + (&this).data.length = old_length; version (D_Version2) - assumeSafeAppend(this.data); + assumeSafeAppend((&this).data); } /*************************************************************************** @@ -170,9 +170,9 @@ struct Buffer ( T ) ***************************************************************************/ - Inout!(T[]) opSlice ( size_t begin, size_t end ) /* d1to2fix_inject: inout */ + Inout!(T[]) opSlice ( size_t begin, size_t end ) inout { - return this.data[begin .. end]; + return (&this).data[begin .. end]; } /*************************************************************************** @@ -184,9 +184,9 @@ struct Buffer ( T ) ***************************************************************************/ - Inout!(T[]) opSlice ( ) /* d1to2fix_inject: inout */ + Inout!(T[]) opSlice ( ) inout { - return this.data[]; + return (&this).data[]; } } diff --git a/src/ocean/core/Enum.d b/src/ocean/core/Enum.d index 150b8ed83..c434eaa29 100644 --- a/src/ocean/core/Enum.d +++ b/src/ocean/core/Enum.d @@ -254,7 +254,7 @@ public interface IEnum ***************************************************************************/ - public int opApply ( int delegate ( ref Const!(Name) name, + public int opApply ( scope int delegate ( ref Const!(Name) name, ref Const!(Value) value ) dg ); @@ -265,7 +265,7 @@ public interface IEnum ***************************************************************************/ - public int opApply ( int delegate ( ref size_t i, ref Const!(Name) name, + public int opApply ( scope int delegate ( ref size_t i, ref Const!(Name) name, ref Const!(Value) value ) dg ); } @@ -300,11 +300,11 @@ public template EnumValues ( size_t i, T ... ) static if ( i == T[0].length - 1 ) { - const EnumValues = T[0][i] ~ "=" ~ T[1][i].stringof; + static immutable EnumValues = T[0][i] ~ "=" ~ T[1][i].stringof; } else { - const EnumValues = T[0][i] ~ "=" ~ T[1][i].stringof ~ "," + static immutable EnumValues = T[0][i] ~ "=" ~ T[1][i].stringof ~ "," ~ EnumValues!(i + 1, T); } } @@ -330,17 +330,17 @@ public template SuperClassIndex ( size_t i, T ... ) { static if ( i == T.length ) { - const size_t SuperClassIndex = i; + static immutable size_t SuperClassIndex = i; } else { static if ( is(T[i] == class) && is(T[i] : IEnum) ) { - const size_t SuperClassIndex = i; + static immutable size_t SuperClassIndex = i; } else { - const size_t SuperClassIndex = SuperClassIndex!(i + 1, T); + static immutable size_t SuperClassIndex = SuperClassIndex!(i + 1, T); } } } @@ -402,13 +402,13 @@ public template EnumBase ( T ... ) static if ( is(typeof(this) S == super) ) { - private const super_class_index = SuperClassIndex!(0, S); + private static immutable super_class_index = SuperClassIndex!(0, S); - private const is_derived_enum = super_class_index < S.length; + private static immutable is_derived_enum = super_class_index < S.length; } else { - private const is_derived_enum = false; + private static immutable is_derived_enum = false; } @@ -424,15 +424,15 @@ public template EnumBase ( T ... ) static if ( is_derived_enum ) { - public const _internal_names = + public static immutable _internal_names = S[super_class_index]._internal_names[0..$] ~ T[0].keys[0..$]; - public const _internal_values = + public static immutable _internal_values = S[super_class_index]._internal_values[0..$] ~ T[0].values[0..$]; } else { - public const _internal_names = T[0].keys; - public const _internal_values = T[0].values; + public static immutable _internal_names = T[0].keys; + public static immutable _internal_values = T[0].values; } static assert(_internal_names.length == _internal_values.length); @@ -652,7 +652,7 @@ public template EnumBase ( T ... ) ***************************************************************************/ - public override int opApply ( int delegate ( ref Const!(Name) name, + public override int opApply ( scope int delegate ( ref Const!(Name) name, ref Const!(Value) value ) dg ) { int res; @@ -677,7 +677,7 @@ public template EnumBase ( T ... ) ***************************************************************************/ - public override int opApply ( int delegate ( ref size_t i, + public override int opApply ( scope int delegate ( ref size_t i, ref Const!(Name) name, ref Const!(Value) value ) dg ) { int res; diff --git a/src/ocean/core/Exception.d b/src/ocean/core/Exception.d index 4f2074554..482e09a8a 100644 --- a/src/ocean/core/Exception.d +++ b/src/ocean/core/Exception.d @@ -56,7 +56,7 @@ struct ExceptionChain ***************************************************************************/ - public int opApply (int delegate (ref Throwable) dg) + public int opApply (scope int delegate (ref Throwable) dg) { int result; @@ -182,7 +182,7 @@ public template ReusableExceptionImplementation() ***************************************************************************/ - public override cstring message ( ) /* d1to2fix_inject: const */ + public override cstring message ( ) const { return this.msg[].ptr is null ? this.reused_msg[] : this.msg; } diff --git a/src/ocean/core/MessageFiber.d b/src/ocean/core/MessageFiber.d index 3c4a11c36..0e7d9a2a1 100644 --- a/src/ocean/core/MessageFiber.d +++ b/src/ocean/core/MessageFiber.d @@ -363,7 +363,7 @@ class MessageFiber **************************************************************************/ - public this ( void delegate ( ) coroutine ) + public this ( scope void delegate ( ) coroutine ) { this(new Fiber(coroutine)); } @@ -378,7 +378,7 @@ class MessageFiber **************************************************************************/ - public this ( void delegate ( ) coroutine, size_t sz ) + public this ( scope void delegate ( ) coroutine, size_t sz ) { this(new Fiber(coroutine, sz)); } @@ -788,7 +788,7 @@ class MessageFiber **************************************************************************/ - public void reset ( void delegate() coroutine ) + public void reset ( scope void delegate() coroutine ) { this.fiber.reset(coroutine); } diff --git a/src/ocean/core/Optional.d b/src/ocean/core/Optional.d index 948f375c2..c4dd3941a 100644 --- a/src/ocean/core/Optional.d +++ b/src/ocean/core/Optional.d @@ -27,7 +27,7 @@ version(UnitTest) struct Optional ( T ) { /// Alias to make code working with undefined state more readable - public const undefined = Optional!(T).init; + public enum undefined = Optional!(T).init; /// wrapped arbitrary value private T value; @@ -46,8 +46,8 @@ struct Optional ( T ) public void opAssign ( T rhs ) { - this.defined = true; - this.value = rhs; + (&this).defined = true; + (&this).value = rhs; } /************************************************************************** @@ -58,7 +58,7 @@ struct Optional ( T ) public void reset() { - this.tupleof[] = Optional.undefined.tupleof[]; + (&this).tupleof[] = Optional.undefined.tupleof[]; } /************************************************************************** @@ -84,11 +84,11 @@ struct Optional ( T ) **************************************************************************/ - public void visit ( void delegate() cb_undefined, - void delegate(ref T) cb_defined ) + public void visit ( scope void delegate() cb_undefined, + scope void delegate(ref T) cb_defined ) { - if (this.defined) - cb_defined(this.value); + if ((&this).defined) + cb_defined((&this).value); else cb_undefined(); } @@ -111,9 +111,9 @@ struct Optional ( T ) public bool get ( ref T value ) { - if (this.defined) - value = this.value; - return this.defined; + if ((&this).defined) + value = (&this).value; + return (&this).defined; } /************************************************************************** @@ -125,7 +125,7 @@ struct Optional ( T ) public bool isDefined ( ) { - return this.defined; + return (&this).defined; } } diff --git a/src/ocean/core/SmartEnum.d b/src/ocean/core/SmartEnum.d index d603c8bb3..0b3b6c293 100644 --- a/src/ocean/core/SmartEnum.d +++ b/src/ocean/core/SmartEnum.d @@ -131,11 +131,11 @@ version (UnitTest) /// Workaround inability to replace those in string. version (D_Version2) { - private const istring enum_id = "enum"; + private static immutable istring enum_id = "enum"; } else { - private const istring enum_id = "const"; + private static immutable istring enum_id = "const"; } /******************************************************************************* @@ -378,7 +378,7 @@ public template SmartEnumCore ( BaseType ) ***************************************************************************/ - static public int opApply ( int delegate ( ref BaseType code, ref istring desc ) dg ) + static public int opApply ( scope int delegate ( ref BaseType code, ref istring desc ) dg ) { int res; foreach ( code, description; map ) @@ -396,7 +396,7 @@ public template SmartEnumCore ( BaseType ) ***************************************************************************/ - static public int opApply ( int delegate ( ref size_t index, ref BaseType code, ref istring desc ) dg ) + static public int opApply ( scope int delegate ( ref size_t index, ref BaseType code, ref istring desc ) dg ) { int res; foreach ( index, code, description; map ) @@ -433,11 +433,11 @@ private template EnumValuesList ( T ... ) { static if ( T.length == 1 ) { - const EnumValuesList = T[0].name ~ "=" ~ CTFE.toString(T[0].value); + static immutable EnumValuesList = T[0].name ~ "=" ~ CTFE.toString(T[0].value); } else { - const EnumValuesList = T[0].name ~ "=" ~ CTFE.toString(T[0].value) ~ "," ~ EnumValuesList!(T[1..$]); + static immutable EnumValuesList = T[0].name ~ "=" ~ CTFE.toString(T[0].value) ~ "," ~ EnumValuesList!(T[1..$]); } } @@ -464,7 +464,7 @@ private template EnumValuesList ( T ... ) private template DeclareEnum ( T ... ) { - const DeclareEnum = "alias " ~ T[0].BaseType.stringof ~ " BaseType; enum : BaseType {" ~ EnumValuesList!(T) ~ "} "; + static immutable DeclareEnum = "alias " ~ T[0].BaseType.stringof ~ " BaseType; enum : BaseType {" ~ EnumValuesList!(T) ~ "} "; } @@ -489,11 +489,11 @@ private template InitialiseMap ( T ... ) { static if ( T.length == 1 ) { - const InitialiseMap = `map["` ~ T[0].name ~ `"]=` ~ T[0].name ~ ";"; + static immutable InitialiseMap = `map["` ~ T[0].name ~ `"]=` ~ T[0].name ~ ";"; } else { - const InitialiseMap = `map["` ~ T[0].name ~ `"]=` ~ T[0].name ~ ";" ~ InitialiseMap!(T[1..$]); + static immutable InitialiseMap = `map["` ~ T[0].name ~ `"]=` ~ T[0].name ~ ";" ~ InitialiseMap!(T[1..$]); } } @@ -523,7 +523,7 @@ private template InitialiseMap ( T ... ) private template StaticThis ( T ... ) { - const StaticThis = "static this() {" ~ InitialiseMap!(T) ~ "map.rehash;} "; + static immutable StaticThis = "static this() {" ~ InitialiseMap!(T) ~ "map.rehash;} "; } @@ -540,11 +540,11 @@ private template MaxValue ( T ... ) { static if ( T.length == 1 ) { - const MaxValue = T[0].value; + static immutable MaxValue = T[0].value; } else { - const MaxValue = T[0].value > MaxValue!(T[1..$]) ? T[0].value : MaxValue!(T[1..$]); + static immutable MaxValue = T[0].value > MaxValue!(T[1..$]) ? T[0].value : MaxValue!(T[1..$]); } } @@ -562,11 +562,11 @@ private template MinValue ( T ... ) { static if ( T.length == 1 ) { - const MinValue = T[0].value; + static immutable MinValue = T[0].value; } else { - const MinValue = T[0].value < MinValue!(T[1..$]) ? T[0].value : MinValue!(T[1..$]); + static immutable MinValue = T[0].value < MinValue!(T[1..$]) ? T[0].value : MinValue!(T[1..$]); } } @@ -585,11 +585,11 @@ private template LongestName ( T ... ) { static if ( T.length == 1 ) { - const LongestName = T[0].name.length; + static immutable LongestName = T[0].name.length; } else { - const LongestName = T[0].name.length > LongestName!(T[1..$]) ? T[0].name.length : LongestName!(T[1..$]); + static immutable LongestName = T[0].name.length > LongestName!(T[1..$]) ? T[0].name.length : LongestName!(T[1..$]); } } @@ -608,11 +608,11 @@ private template ShortestName ( T ... ) { static if ( T.length == 1 ) { - const ShortestName = T[0].name.length; + static immutable ShortestName = T[0].name.length; } else { - const ShortestName = T[0].name.length < ShortestName!(T[1..$]) ? T[0].name.length : ShortestName!(T[1..$]); + static immutable ShortestName = T[0].name.length < ShortestName!(T[1..$]) ? T[0].name.length : ShortestName!(T[1..$]); } } @@ -638,7 +638,7 @@ private template ShortestName ( T ... ) private template DeclareConstants ( T ... ) { - const istring DeclareConstants = + static immutable istring DeclareConstants = enum_id ~ " length = " ~ CTFE.toString(T.length) ~ "; " ~ enum_id ~ " min = " ~ CTFE.toString(MinValue!(T)) ~ "; " ~ enum_id ~ " max = " ~ CTFE.toString(MaxValue!(T)) ~ "; " ~ @@ -665,7 +665,7 @@ private template DeclareConstants ( T ... ) private template MixinCore ( T ... ) { - const MixinCore = "mixin SmartEnumCore!(" ~ T[0].BaseType.stringof ~ ");"; + static immutable MixinCore = "mixin SmartEnumCore!(" ~ T[0].BaseType.stringof ~ ");"; } @@ -692,7 +692,7 @@ public template SmartEnum ( istring Name, T ... ) { static if ( T.length > 0 ) { - const SmartEnum = "class " ~ Name ~ " : ISmartEnum { " ~ DeclareEnum!(T) ~ + static immutable SmartEnum = "class " ~ Name ~ " : ISmartEnum { " ~ DeclareEnum!(T) ~ DeclareConstants!(T) ~ StaticThis!(T) ~ MixinCore!(T) ~ "}"; } else @@ -772,7 +772,7 @@ public template AutoSmartEnum ( istring Name, BaseType, Strings ... ) { static assert ( is(typeof(Strings[0]) : istring), "AutoSmartEnum - please only give immutable strings as template parameters"); - const AutoSmartEnum = SmartEnum!(Name, CreateCodes!(BaseType, 0, Strings)); + static immutable AutoSmartEnum = SmartEnum!(Name, CreateCodes!(BaseType, 0, Strings)); } unittest @@ -896,13 +896,13 @@ public struct TwoWayMap ( A ) invariant ( ) { - assert(this.a_to_b.length == this.b_to_a.length); + assert((&this).a_to_b.length == (&this).b_to_a.length); debug ( TwoWayMapFullConsistencyCheck ) { - foreach ( a, b; this.a_to_b ) + foreach ( a, b; (&this).a_to_b ) { - assert(this.a_to_index[a] == this.b_to_index[b]); + assert((&this).a_to_index[a] == (&this).b_to_index[b]); } } } @@ -919,38 +919,38 @@ public struct TwoWayMap ( A ) public void opAssign ( ValueType[KeyType] assoc_array ) { - this.keys_list.length = 0; - this.values_list.length = 0; + (&this).keys_list.length = 0; + (&this).values_list.length = 0; - this.a_to_b = assoc_array; + (&this).a_to_b = assoc_array; - foreach ( a, b; this.a_to_b ) + foreach ( a, b; (&this).a_to_b ) { - this.b_to_a[b] = a; + (&this).b_to_a[b] = a; - this.keys_list ~= *(b in this.b_to_a); - this.values_list ~= *(a in this.a_to_b); + (&this).keys_list ~= *(b in (&this).b_to_a); + (&this).values_list ~= *(a in (&this).a_to_b); } - this.updateIndices(); + (&this).updateIndices(); } public void opAssign ( KeyType[ValueType] assoc_array ) { - this.keys_list.length = 0; - this.values_list.length = 0; + (&this).keys_list.length = 0; + (&this).values_list.length = 0; - this.b_to_a = assoc_array; + (&this).b_to_a = assoc_array; - foreach ( b, a; this.b_to_a ) + foreach ( b, a; (&this).b_to_a ) { - this.a_to_b[a] = b; + (&this).a_to_b[a] = b; - this.keys_list ~= *(b in this.b_to_a); - this.values_list ~= *(a in this.a_to_b); + (&this).keys_list ~= *(b in (&this).b_to_a); + (&this).values_list ~= *(a in (&this).a_to_b); } - this.updateIndices(); + (&this).updateIndices(); } @@ -967,45 +967,45 @@ public struct TwoWayMap ( A ) public void opIndexAssign ( KeyType a, ValueType b ) out { - assert(this.a_to_index[a] < this.keys_list.length); - assert(this.b_to_index[b] < this.values_list.length); + assert((&this).a_to_index[a] < (&this).keys_list.length); + assert((&this).b_to_index[b] < (&this).values_list.length); } body { - auto already_exists = !!(a in this.a_to_b); + auto already_exists = !!(a in (&this).a_to_b); - this.a_to_b[a] = b; - this.b_to_a[b] = a; + (&this).a_to_b[a] = b; + (&this).b_to_a[b] = a; if ( !already_exists ) { - this.keys_list ~= *(b in this.b_to_a); - this.values_list ~= *(a in this.a_to_b); + (&this).keys_list ~= *(b in (&this).b_to_a); + (&this).values_list ~= *(a in (&this).a_to_b); } - this.updateIndices(); + (&this).updateIndices(); } public void opIndexAssign ( ValueType b, KeyType a ) out { - assert(this.a_to_index[a] < this.keys_list.length); - assert(this.b_to_index[b] < this.values_list.length); + assert((&this).a_to_index[a] < (&this).keys_list.length); + assert((&this).b_to_index[b] < (&this).values_list.length); } body { - auto already_exists = !!(a in this.a_to_b); + auto already_exists = !!(a in (&this).a_to_b); - this.a_to_b[a] = b; - this.b_to_a[b] = a; + (&this).a_to_b[a] = b; + (&this).b_to_a[b] = a; if ( !already_exists ) { - this.keys_list ~= *(b in this.b_to_a); - this.values_list ~= *(a in this.a_to_b); + (&this).keys_list ~= *(b in (&this).b_to_a); + (&this).values_list ~= *(a in (&this).a_to_b); } - this.updateIndices(); + (&this).updateIndices(); } @@ -1017,10 +1017,10 @@ public struct TwoWayMap ( A ) public void rehash ( ) { - this.a_to_b.rehash; - this.b_to_a.rehash; + (&this).a_to_b.rehash; + (&this).b_to_a.rehash; - this.updateIndices(); + (&this).updateIndices(); } @@ -1040,7 +1040,7 @@ public struct TwoWayMap ( A ) public KeyType* opIn_r ( cstring b ) { - return b in this.b_to_a; + return b in (&this).b_to_a; } @@ -1060,7 +1060,7 @@ public struct TwoWayMap ( A ) public ValueType* opIn_r ( KeyType a ) { - return a in this.a_to_b; + return a in (&this).a_to_b; } @@ -1082,7 +1082,7 @@ public struct TwoWayMap ( A ) public KeyType opIndex ( cstring b ) { - return this.b_to_a[b]; + return (&this).b_to_a[b]; } @@ -1104,7 +1104,7 @@ public struct TwoWayMap ( A ) public ValueType opIndex ( KeyType a ) { - return this.a_to_b[a]; + return (&this).a_to_b[a]; } @@ -1117,7 +1117,7 @@ public struct TwoWayMap ( A ) public size_t length ( ) { - return this.a_to_b.length; + return (&this).a_to_b.length; } @@ -1130,7 +1130,7 @@ public struct TwoWayMap ( A ) public KeyType[] keys ( ) { - return this.keys_list; + return (&this).keys_list; } @@ -1143,7 +1143,7 @@ public struct TwoWayMap ( A ) public ValueType[] values ( ) { - return this.values_list; + return (&this).values_list; } @@ -1156,10 +1156,10 @@ public struct TwoWayMap ( A ) ***************************************************************************/ - public int opApply ( int delegate ( ref KeyType a, ref ValueType b ) dg ) + public int opApply ( scope int delegate ( ref KeyType a, ref ValueType b ) dg ) { int res; - foreach ( a, b; this.a_to_b ) + foreach ( a, b; (&this).a_to_b ) { res = dg(a, b); } @@ -1176,12 +1176,12 @@ public struct TwoWayMap ( A ) ***************************************************************************/ - public int opApply ( int delegate ( ref size_t index, ref KeyType a, ref ValueType b ) dg ) + public int opApply ( scope int delegate ( ref size_t index, ref KeyType a, ref ValueType b ) dg ) { int res; - foreach ( a, b; this.a_to_b ) + foreach ( a, b; (&this).a_to_b ) { - auto index = this.indexOf(a); + auto index = (&this).indexOf(a); verify(index !is null); res = dg(*index, a, b); @@ -1206,8 +1206,8 @@ public struct TwoWayMap ( A ) public size_t* indexOf ( KeyType a ) { - auto index = a in this.a_to_index; - enforce(index, typeof(this).stringof ~ ".indexOf - element not present in map"); + auto index = a in (&this).a_to_index; + enforce(index, typeof((&this)).stringof ~ ".indexOf - element not present in map"); return index; } @@ -1228,8 +1228,8 @@ public struct TwoWayMap ( A ) public size_t* indexOf ( cstring b ) { - auto index = b in this.b_to_index; - enforce(index, typeof(this).stringof ~ ".indexOf - element not present in map"); + auto index = b in (&this).b_to_index; + enforce(index, typeof((&this)).stringof ~ ".indexOf - element not present in map"); return index; } @@ -1242,10 +1242,10 @@ public struct TwoWayMap ( A ) private void updateIndices ( ) { - foreach ( a, b; this.a_to_b ) + foreach ( a, b; (&this).a_to_b ) { - this.a_to_index[a] = this.keys_list.find(a); - this.b_to_index[b] = this.values_list.find(b); + (&this).a_to_index[a] = (&this).keys_list.find(a); + (&this).b_to_index[b] = (&this).values_list.find(b); } } } diff --git a/src/ocean/core/SmartUnion.d b/src/ocean/core/SmartUnion.d index dcbd4ed86..411f854d5 100644 --- a/src/ocean/core/SmartUnion.d +++ b/src/ocean/core/SmartUnion.d @@ -71,7 +71,7 @@ struct SmartUnion ( U ) **************************************************************************/ - Active active ( ) { return this._.active; } + Active active ( ) { return (&this)._.active; } /*************************************************************************** @@ -83,7 +83,7 @@ struct SmartUnion ( U ) public istring active_name ( ) { - return this._.active_names[this._.active]; + return (&this)._.active_names[(&this)._.active]; } /*************************************************************************** @@ -103,7 +103,7 @@ struct SmartUnion ( U ) mixin (AllMethods!(U, "", 0)); - private alias typeof(*this) Type; + private alias typeof(*(&this)) Type; } /// @@ -310,7 +310,7 @@ version ( UnitTest ) *******************************************************************************/ -private const handleInvalidCases = "case none: assert(false);" ~ +private static immutable handleInvalidCases = "case none: assert(false);" ~ // The D2 build makes sure all enum cases are covered so in fact we don't // need a default. However, D1 emits a compiler warning if a switch // has no default so we add a default here just to avoid the warning. @@ -363,7 +363,7 @@ private struct SmartUnionIntern ( U ) **************************************************************************/ - const N = U.tupleof.length; + enum N = U.tupleof.length; /************************************************************************** @@ -387,7 +387,7 @@ private struct SmartUnionIntern ( U ) ***************************************************************************/ - const istring[] active_names = member_string_list(); + enum istring[] active_names = member_string_list(); /*************************************************************************** @@ -428,11 +428,11 @@ private template MemberList ( uint i, size_t len, U ) { static if ( i == len ) { - const MemberList = ""; + static immutable MemberList = ""; } else { - const MemberList = "," ~ fieldIdentifier!(U, i) ~ MemberList!(i + 1, len, U); + static immutable MemberList = "," ~ fieldIdentifier!(U, i) ~ MemberList!(i + 1, len, U); } } @@ -495,27 +495,27 @@ private template MemberList ( uint i, size_t len, U ) private template Methods ( U, uint i ) { - const member = fieldIdentifier!(U, i); + static immutable member = fieldIdentifier!(U, i); - const member_access = "_.u." ~ member; + static immutable member_access = "_.u." ~ member; - const type = "typeof(" ~ member_access ~ ")"; + static immutable type = "typeof(" ~ member_access ~ ")"; - const get = type ~ ' ' ~ member ~ "() " + static immutable get = type ~ ' ' ~ member ~ "() " ~ "{ verify(_.active == _.active." ~ member ~ ", " ~ `"SmartUnion: '` ~ member ~ `' not active"); ` ~ "return " ~ member_access ~ "; }"; - const set = type ~ ' ' ~ member ~ '(' ~ type ~ ' ' ~ member ~ ")" + static immutable set = type ~ ' ' ~ member ~ '(' ~ type ~ ' ' ~ member ~ ")" ~ "{ _.active = _.active." ~ member ~ ";" ~ "return " ~ member_access ~ '=' ~ member ~ "; }"; - const ini = "static Type opCall(" ~ type ~ ' ' ~ member ~ ")" + static immutable ini = "static Type opCall(" ~ type ~ ' ' ~ member ~ ")" ~ "{ Type su; su." ~ member ~ '=' ~ member ~ "; return su; }"; - const local_import = "import ocean.core.Enforce;\n"; + static immutable local_import = "import ocean.core.Enforce;\n"; - const all = local_import ~ get ~ '\n' ~ set ~ '\n' ~ ini; + static immutable all = local_import ~ get ~ '\n' ~ set ~ '\n' ~ ini; } /******************************************************************************* @@ -536,11 +536,11 @@ private template AllMethods ( U, istring pre, uint i) { static if (i < U.tupleof.length) { - const AllMethods = + static immutable AllMethods = AllMethods!(U, pre ~ '\n' ~ Methods!(U, i).all, i + 1); } else { - const AllMethods = pre; + static immutable AllMethods = pre; } } diff --git a/src/ocean/core/StructConverter.d b/src/ocean/core/StructConverter.d index b273cc9e5..e798a1311 100644 --- a/src/ocean/core/StructConverter.d +++ b/src/ocean/core/StructConverter.d @@ -89,7 +89,7 @@ public void structConvert ( From, To ) ( ref From from, out To to, version (D_Version2) mixin(`enum convFuncName = "convert_" ~ FieldName!(to_index, To);`); else - const convFuncName = "convert_" ~ FieldName!(to_index, To); + static immutable convFuncName = "convert_" ~ FieldName!(to_index, To); static if (hasConvertFunction!(From, convFuncName, To)()) { diff --git a/src/ocean/core/Test.d b/src/ocean/core/Test.d index bfcbe1e81..9cf6c7687 100644 --- a/src/ocean/core/Test.d +++ b/src/ocean/core/Test.d @@ -227,7 +227,7 @@ class NamedTest : TestException static if (is(typeof(Throwable.message))) { - public override cstring message ( ) /* d1to2fix_inject: const */ + public override cstring message ( ) const { if (this.name.length) { diff --git a/src/ocean/core/Traits.d b/src/ocean/core/Traits.d index 0e1e33351..bffae417f 100644 --- a/src/ocean/core/Traits.d +++ b/src/ocean/core/Traits.d @@ -61,7 +61,7 @@ version (UnitTest) public bool isKeyword ( cstring str ) { - const istring[] keywords = [ + static immutable istring[] keywords = [ "abstract", "alias", "align", "asm", "assert", "auto", "body", "bool", "break", "byte", "case", "cast", @@ -199,7 +199,7 @@ unittest public template isPrimitiveType ( T ) { - const isPrimitiveType = + static immutable isPrimitiveType = is(Unqual!(T) == void) || is(Unqual!(T) == bool) || isIntegerType!(T) @@ -227,7 +227,7 @@ public template isPrimitiveType ( T ) public template hasIndirections ( T... ) { - const hasIndirections = hasIndirectionsImpl!(T)(); + static immutable hasIndirections = hasIndirectionsImpl!(T)(); } private bool hasIndirectionsImpl ( T... )() @@ -319,7 +319,7 @@ public template hasMultiDimensionalDynamicArrays ( T ) * DMD1 bug if T contains itself like "struct T {T[] t;}". */ - const typeof(hasMultiDimensionalDynamicArraysImpl!(T)()) hasMultiDimensionalDynamicArrays = hasMultiDimensionalDynamicArraysImpl!(T)(); + static immutable typeof(hasMultiDimensionalDynamicArraysImpl!(T)()) hasMultiDimensionalDynamicArrays = hasMultiDimensionalDynamicArraysImpl!(T)(); } /* @@ -439,11 +439,11 @@ public template isCompoundType ( T ) { static if ( is(T == struct) || is(T == class) || is(T== union) ) { - const isCompoundType = true; + static immutable isCompoundType = true; } else { - const isCompoundType = false; + static immutable isCompoundType = false; } } @@ -593,7 +593,7 @@ public template FieldName ( size_t i, T ) static assert(false, "FieldName!(" ~ T.stringof ~ "): type is not a struct / class"); } - const FieldName = StripFieldName!(T.tupleof[i].stringof); + static immutable FieldName = StripFieldName!(T.tupleof[i].stringof); } unittest @@ -618,19 +618,19 @@ private template StripFieldName ( istring name, size_t n = size_t.max ) { static if ( n >= name.length ) { - const StripFieldName = StripFieldName!(name, name.length - 1); + static immutable StripFieldName = StripFieldName!(name, name.length - 1); } else static if ( name[n] == '.' ) { - const StripFieldName = name[n + 1 .. $]; + static immutable StripFieldName = name[n + 1 .. $]; } else static if ( n ) { - const StripFieldName = StripFieldName!(name, n - 1); + static immutable StripFieldName = StripFieldName!(name, n - 1); } else { - const StripFieldName = name; + static immutable StripFieldName = name; } } @@ -652,11 +652,11 @@ public template SizeofTuple ( Tuple ... ) { static if ( Tuple.length > 0 ) { - const size_t SizeofTuple = Tuple[0].sizeof + SizeofTuple!(Tuple[1..$]); + static immutable size_t SizeofTuple = Tuple[0].sizeof + SizeofTuple!(Tuple[1..$]); } else { - const size_t SizeofTuple = 0; + static immutable size_t SizeofTuple = 0; } } @@ -789,11 +789,11 @@ public template isUniqueTypesInTuple ( Tuple ... ) { static if ( Tuple.length > 1 ) { - const bool isUniqueTypesInTuple = (CountTypesInTuple!(Tuple[0], Tuple) == 1) && isUniqueTypesInTuple!(Tuple[1..$]); + static immutable bool isUniqueTypesInTuple = (CountTypesInTuple!(Tuple[0], Tuple) == 1) && isUniqueTypesInTuple!(Tuple[1..$]); } else { - const bool isUniqueTypesInTuple = true; + static immutable bool isUniqueTypesInTuple = true; } } @@ -823,11 +823,11 @@ public template CountTypesInTuple ( Type, Tuple ... ) { static if ( Tuple.length > 0 ) { - const uint CountTypesInTuple = is(Type == Tuple[0]) + CountTypesInTuple!(Type, Tuple[1..$]); + static immutable uint CountTypesInTuple = is(Type == Tuple[0]) + CountTypesInTuple!(Type, Tuple[1..$]); } else { - const uint CountTypesInTuple = 0; + static immutable uint CountTypesInTuple = 0; } } @@ -853,7 +853,7 @@ version (D_Version2) { public template isTypedef (T) { - const bool isTypedef = false; + static immutable bool isTypedef = false; } } else @@ -993,7 +993,7 @@ template ContainsDynamicArray ( T ... ) { // Recurse into struct/union members. - const ContainsDynamicArray = ContainsDynamicArray!(typeof (T[0].tupleof)) || + static immutable ContainsDynamicArray = ContainsDynamicArray!(typeof (T[0].tupleof)) || ContainsDynamicArray!(T[1 .. $]); } else @@ -1002,13 +1002,13 @@ template ContainsDynamicArray ( T ... ) { static if (is (Element[] == Unqual!(T[0]))) { - const ContainsDynamicArray = true; + static immutable ContainsDynamicArray = true; } else { // Static array, recurse into base type. - const ContainsDynamicArray = ContainsDynamicArray!(Element) || + static immutable ContainsDynamicArray = ContainsDynamicArray!(Element) || ContainsDynamicArray!(T[1 .. $]); } } @@ -1016,13 +1016,13 @@ template ContainsDynamicArray ( T ... ) { // Skip non-dynamic or static array type. - const ContainsDynamicArray = ContainsDynamicArray!(T[1 .. $]); + static immutable ContainsDynamicArray = ContainsDynamicArray!(T[1 .. $]); } } } else { - const ContainsDynamicArray = false; + static immutable ContainsDynamicArray = false; } } @@ -1280,11 +1280,11 @@ template hasMethod ( T, istring name, Dg ) static if ( is(typeof( { Dg dg = mixin("&T.init." ~ name); } )) ) { - const bool hasMethod = true; + static immutable bool hasMethod = true; } else { - const bool hasMethod = false; + static immutable bool hasMethod = false; } } @@ -1369,7 +1369,7 @@ unittest public template identifier(alias Sym) { - const identifier = _identifier!(Sym)(); + static immutable identifier = _identifier!(Sym)(); } private istring _identifier(alias Sym)() @@ -1560,7 +1560,7 @@ unittest */ template isStringType( T ) { - const bool isStringType = is( T : char[] ) || + static immutable bool isStringType = is( T : char[] ) || is( T : wchar[] ) || is( T : dchar[] ) || is( T : istring ) || @@ -1580,7 +1580,7 @@ unittest */ template isCharType( T ) { - const bool isCharType = + static immutable bool isCharType = is( Unqual!(T) == char ) || is( Unqual!(T) == wchar ) || is( Unqual!(T) == dchar ); @@ -1598,7 +1598,7 @@ unittest */ template isSignedIntegerType( T ) { - const bool isSignedIntegerType = + static immutable bool isSignedIntegerType = is( Unqual!(T) == byte ) || is( Unqual!(T) == short ) || is( Unqual!(T) == int ) @@ -1618,7 +1618,7 @@ unittest */ template isUnsignedIntegerType( T ) { - const bool isUnsignedIntegerType = + static immutable bool isUnsignedIntegerType = is( Unqual!(T) == ubyte ) || is( Unqual!(T) == ushort ) || is( Unqual!(T) == uint ) @@ -1637,7 +1637,7 @@ unittest */ template isIntegerType( T ) { - const bool isIntegerType = isSignedIntegerType!(T) || + static immutable bool isIntegerType = isSignedIntegerType!(T) || isUnsignedIntegerType!(T); } @@ -1653,7 +1653,7 @@ unittest */ template isRealType( T ) { - const bool isRealType = + static immutable bool isRealType = is( Unqual!(T) == float ) || is( Unqual!(T) == double ) || is( Unqual!(T) == real ); @@ -1672,7 +1672,7 @@ unittest */ template isComplexType( T ) { - const bool isComplexType = + static immutable bool isComplexType = is( Unqual!(T) == cfloat ) || is( Unqual!(T) == cdouble ) || is( Unqual!(T) == creal ); @@ -1690,7 +1690,7 @@ unittest */ template isImaginaryType( T ) { - const bool isImaginaryType = + static immutable bool isImaginaryType = is( Unqual!(T) == ifloat ) || is( Unqual!(T) == idouble ) || is( Unqual!(T) == ireal ); @@ -1709,7 +1709,7 @@ unittest */ template isFloatingPointType( T ) { - const bool isFloatingPointType = isRealType!(T) || + static immutable bool isFloatingPointType = isRealType!(T) || isComplexType!(T) || isImaginaryType!(T); } @@ -1797,12 +1797,12 @@ unittest */ template isPointerType(T) { - const isPointerType = false; + static immutable isPointerType = false; } template isPointerType(T : T*) { - const isPointerType = true; + static immutable isPointerType = true; } unittest @@ -1841,7 +1841,7 @@ unittest template isReferenceType( T ) { - const bool isReferenceType = isPointerType!(T) || + static immutable bool isReferenceType = isPointerType!(T) || is( T == class ) || is( T == interface ) || is( T == delegate ); @@ -1865,7 +1865,7 @@ unittest */ template isDynamicArrayType( T ) { - const bool isDynamicArrayType = is( typeof(T.init[0])[] == T ); + static immutable bool isDynamicArrayType = is( typeof(T.init[0])[] == T ); } unittest @@ -1882,12 +1882,12 @@ unittest */ template isStaticArrayType( T : T[U], size_t U ) { - const bool isStaticArrayType = true; + static immutable bool isStaticArrayType = true; } template isStaticArrayType( T ) { - const bool isStaticArrayType = false; + static immutable bool isStaticArrayType = false; } unittest @@ -1903,9 +1903,9 @@ unittest template isArrayType(T) { static if (is( T U : U[] )) - const bool isArrayType=true; + static immutable bool isArrayType=true; else - const bool isArrayType=false; + static immutable bool isArrayType=false; } unittest @@ -1921,7 +1921,7 @@ unittest */ template isAssocArrayType( T ) { - const bool isAssocArrayType = is( typeof(T.init.values[0])[typeof(T.init.keys[0])] == T ); + static immutable bool isAssocArrayType = is( typeof(T.init.values[0])[typeof(T.init.keys[0])] == T ); } unittest @@ -1936,7 +1936,7 @@ unittest */ template isCallableType( T ) { - const bool isCallableType = is( T == function ) || + static immutable bool isCallableType = is( T == function ) || is( typeof(*T) == function ) || is( T == delegate ) || is( typeof(T.opCall) == function ); @@ -2133,9 +2133,9 @@ unittest */ template rankOfArray(T) { static if(is(T S : S[])) { - const uint rankOfArray = 1 + rankOfArray!(S); + static immutable uint rankOfArray = 1 + rankOfArray!(S); } else { - const uint rankOfArray = 0; + static immutable uint rankOfArray = 0; } } @@ -2181,11 +2181,11 @@ template staticArraySize(T) static assert (rankOfArray!(T)==1,"implemented only for 1d arrays..."); version(D_Version2) { - const size_t staticArraySize=(T).sizeof / typeof(T.init[0]).sizeof; + static immutable size_t staticArraySize=(T).sizeof / typeof(T.init[0]).sizeof; } else { - const size_t staticArraySize=(T).sizeof / typeof(T.init).sizeof; + static immutable size_t staticArraySize=(T).sizeof / typeof(T.init).sizeof; } } diff --git a/src/ocean/core/Tuple.d b/src/ocean/core/Tuple.d index 53f4c4d69..16f1ed6a8 100644 --- a/src/ocean/core/Tuple.d +++ b/src/ocean/core/Tuple.d @@ -83,11 +83,11 @@ template Tuple( TList... ) template IndexOf( T, TList... ) { static if( TList.length == 0 ) - const size_t IndexOf = 0; + static immutable size_t IndexOf = 0; else static if( is( T == TList[0] ) ) - const size_t IndexOf = 0; + static immutable size_t IndexOf = 0; else - const size_t IndexOf = 1 + IndexOf!( T, TList[1 .. $] ); + static immutable size_t IndexOf = 1 + IndexOf!( T, TList[1 .. $] ); } diff --git a/src/ocean/core/TypeConvert.d b/src/ocean/core/TypeConvert.d index 32911a816..cb24c2118 100644 --- a/src/ocean/core/TypeConvert.d +++ b/src/ocean/core/TypeConvert.d @@ -280,7 +280,7 @@ template arrayOf (T) version (UnitTest) { - const _arrayOf_global_scope = arrayOf!(byte)(1, 2, 3); + static immutable _arrayOf_global_scope = arrayOf!(byte)(1, 2, 3); } /// @@ -297,7 +297,7 @@ unittest auto arr = arrayOf!(Hash)(1, 2, 3); // ensure it works in CTFE - const manifest = arrayOf!(long)(42, 44, 46); + static immutable manifest = arrayOf!(long)(42, 44, 46); static assert (manifest.length == 3); static assert (manifest[0] == 42L); static assert (manifest[1] == 44L); @@ -344,7 +344,7 @@ ReturnTypeOf!(F) delegate() toContextDg ( alias F ) ( void* context ) { ReturnTypeOf!(F) method ( ) { - void* context = cast(void*) this; + void* context = cast(void*) (&this); // do real work via provided F function: return F(context); diff --git a/src/ocean/core/VersionCheck.d b/src/ocean/core/VersionCheck.d index 3f6e9f77e..47fc1b203 100644 --- a/src/ocean/core/VersionCheck.d +++ b/src/ocean/core/VersionCheck.d @@ -25,7 +25,7 @@ import ocean.meta.codegen.CTFE; /// ditto public template hasFeaturesFrom ( istring libname, ulong major, ulong minor ) { - const hasFeaturesFrom = hasFeaturesFromFunc!(libname, major, minor)(); + static immutable hasFeaturesFrom = hasFeaturesFromFunc!(libname, major, minor)(); } /// diff --git a/src/ocean/core/array/Mutation.d b/src/ocean/core/array/Mutation.d index 8e4d9d6be..af8e8030e 100644 --- a/src/ocean/core/array/Mutation.d +++ b/src/ocean/core/array/Mutation.d @@ -328,7 +328,7 @@ unittest unittest { static void testOne ( cstring _array, - bool delegate(char) dg, size_t num, int line = __LINE__ ) + scope bool delegate(char) dg, size_t num, int line = __LINE__ ) { auto array = _array.dup; auto t = new NamedTest(format("removeIf.testOne:{}", line)); @@ -522,7 +522,7 @@ unittest test!("==")(partition("".dup, (char c) { return true; }), 0); static void testOne ( cstring _array, - bool delegate(char) dg, size_t num, int line = __LINE__ ) + scope bool delegate(char) dg, size_t num, int line = __LINE__ ) { auto array = _array.dup; auto t = new NamedTest(format("partition.testOne:{}", line)); @@ -1376,7 +1376,7 @@ public bool containsDuplicate ( T, bool sort = true ) ( T[] array ) *******************************************************************************/ public int findDuplicates ( T, bool sort = true ) - ( T[] array, int delegate ( ref size_t index, ref T element ) found ) + ( T[] array, scope int delegate ( ref size_t index, ref T element ) found ) { if (array.length) { @@ -1584,8 +1584,8 @@ unittest *******************************************************************************/ private size_t filterInPlaceCore ( size_t length, - bool delegate ( size_t index ) exclude, - void delegate ( size_t i, size_t j ) swap ) + scope bool delegate ( size_t index ) exclude, + scope void delegate ( size_t i, size_t j ) swap ) out (end) { assert(end <= length, "result length out of bounds"); @@ -1768,7 +1768,7 @@ unittest *******************************************************************************/ -public T[] shuffle ( T ) ( T[] array, size_t delegate ( size_t i ) new_index ) +public T[] shuffle ( T ) ( T[] array, scope size_t delegate ( size_t i ) new_index ) { for (auto i = array.length? array.length - 1 : 0; i; i--) { @@ -1832,7 +1832,7 @@ unittest bool isClearable ( T ) ( ) { - const size_t n = T.sizeof; + static immutable size_t n = T.sizeof; T init; diff --git a/src/ocean/core/array/Search.d b/src/ocean/core/array/Search.d index f9d034ac6..f97ec75eb 100644 --- a/src/ocean/core/array/Search.d +++ b/src/ocean/core/array/Search.d @@ -1249,7 +1249,7 @@ unittest *******************************************************************************/ -public bool bsearchCustom ( size_t array_length, ssize_t delegate ( size_t i ) cmp, out size_t position ) +public bool bsearchCustom ( size_t array_length, scope ssize_t delegate ( size_t i ) cmp, out size_t position ) out (found) { if (found) diff --git a/src/ocean/core/array/Transformation.d b/src/ocean/core/array/Transformation.d index 3c01c6b66..e5d4feb8f 100644 --- a/src/ocean/core/array/Transformation.d +++ b/src/ocean/core/array/Transformation.d @@ -427,7 +427,7 @@ unittest unittest { - void test( cstring array, bool delegate( char ) dg, size_t num ) + void test( cstring array, scope bool delegate( char ) dg, size_t num ) { Buffer!(char) buf; auto r = filter( array, dg, buf ); diff --git a/src/ocean/core/buffer/NoIndirections.d b/src/ocean/core/buffer/NoIndirections.d index 45f456c1f..c4940e119 100644 --- a/src/ocean/core/buffer/NoIndirections.d +++ b/src/ocean/core/buffer/NoIndirections.d @@ -148,7 +148,7 @@ template NoIndirectionsBufferImpl ( ) ***************************************************************************/ - int opApply ( int delegate(ref Const!(T)) dg ) /* d1to2fix_inject: const */ + int opApply ( scope int delegate(ref Const!(T)) dg ) const { foreach (elem; this.data) { @@ -169,7 +169,7 @@ template NoIndirectionsBufferImpl ( ) ***************************************************************************/ - int opApply ( int delegate(ref size_t, ref Const!(T)) dg ) /* d1to2fix_inject: const */ + int opApply ( scope int delegate(ref size_t, ref Const!(T)) dg ) const { foreach (index, elem; this.data) { diff --git a/src/ocean/core/buffer/Void.d b/src/ocean/core/buffer/Void.d index 9678c3a71..a8ef46e20 100644 --- a/src/ocean/core/buffer/Void.d +++ b/src/ocean/core/buffer/Void.d @@ -127,7 +127,7 @@ template VoidBufferImpl ( ) ***************************************************************************/ - int opApply ( int delegate(ref Const!(ubyte)) dg ) /* d1to2fix_inject: const */ + int opApply ( scope int delegate(ref Const!(ubyte)) dg ) const { foreach (elem; cast(ubyte[]) this.data) { @@ -148,7 +148,7 @@ template VoidBufferImpl ( ) ***************************************************************************/ - int opApply ( int delegate(ref size_t, ref Const!(ubyte)) dg ) /* d1to2fix_inject: const */ + int opApply ( scope int delegate(ref size_t, ref Const!(ubyte)) dg ) const { foreach (index, elem; cast(ubyte[]) this.data) { diff --git a/src/ocean/core/buffer/WithIndirections.d b/src/ocean/core/buffer/WithIndirections.d index d9fbb5e83..8437ba4bc 100644 --- a/src/ocean/core/buffer/WithIndirections.d +++ b/src/ocean/core/buffer/WithIndirections.d @@ -129,7 +129,7 @@ template WithIndirectionsBufferImpl ( ) ***************************************************************************/ - int opApply ( int delegate(ref T) dg ) + int opApply ( scope int delegate(ref T) dg ) { foreach (elem; this.data) { @@ -150,7 +150,7 @@ template WithIndirectionsBufferImpl ( ) ***************************************************************************/ - int opApply ( int delegate(ref size_t, ref T) dg ) + int opApply ( scope int delegate(ref size_t, ref T) dg ) { foreach (index, elem; this.data) { diff --git a/src/ocean/io/Console.d b/src/ocean/io/Console.d index fa85e921e..aca868250 100644 --- a/src/ocean/io/Console.d +++ b/src/ocean/io/Console.d @@ -47,7 +47,7 @@ import core.sys.posix.unistd: isatty; struct Console { - const istring Eol = "\n"; + enum istring Eol = "\n"; /********************************************************************** diff --git a/src/ocean/io/FilePath.d b/src/ocean/io/FilePath.d index aefe67484..a08dc75d7 100644 --- a/src/ocean/io/FilePath.d +++ b/src/ocean/io/FilePath.d @@ -768,7 +768,7 @@ class FilePath : PathView ***********************************************************************/ - final FilePath[] toList (Filter filter = null) + final FilePath[] toList (scope Filter filter = null) { FilePath[] paths; @@ -1040,7 +1040,7 @@ class FilePath : PathView ***********************************************************************/ - final int opApply (int delegate(ref FileInfo) dg) + final int opApply (scope int delegate(ref FileInfo) dg) { return FS.list (cString, dg); } diff --git a/src/ocean/io/Path.d b/src/ocean/io/Path.d index 12139c22f..ff2b8781f 100644 --- a/src/ocean/io/Path.d +++ b/src/ocean/io/Path.d @@ -108,7 +108,7 @@ package struct FS cstring folder; bool allFiles; - int opApply (int delegate(ref FileInfo) dg) + int opApply (scope int delegate(ref FileInfo) dg) { char[256] tmp = void; auto path = strz (folder, tmp); @@ -501,7 +501,7 @@ package struct FS ***************************************************************************/ - static int list (cstring folder, int delegate(ref FileInfo) dg, bool all=false) + static int list (cstring folder, scope int delegate(ref FileInfo) dg, bool all=false) { int ret; DIR* dir; @@ -645,7 +645,7 @@ struct PathParser PathParser dup () { - auto ret = *this; + auto ret = *(&this); ret.fp = fp.dup; return ret; } @@ -920,7 +920,7 @@ struct PathParser if (suffix_ < 0 || suffix_ is name_) suffix_ = end_; - return *this; + return *(&this); } } diff --git a/src/ocean/io/Retry.d b/src/ocean/io/Retry.d index 5f35895e3..ceef09aa3 100644 --- a/src/ocean/io/Retry.d +++ b/src/ocean/io/Retry.d @@ -164,7 +164,7 @@ class Retry ***************************************************************************/ - public this ( SuccessDecider success_decide = null ) + public this ( scope SuccessDecider success_decide = null ) { this.success_decide = success_decide ? success_decide : &this.default_success_decide; } @@ -303,7 +303,7 @@ class WaitRetry : Retry ***************************************************************************/ - public this ( uint retry_wait_ms, SuccessDecider success_decide = null ) + public this ( uint retry_wait_ms, scope SuccessDecider success_decide = null ) { this.retry_wait_ms = retry_wait_ms; diff --git a/src/ocean/io/Terminal.d b/src/ocean/io/Terminal.d index 6de64712b..275c23d61 100644 --- a/src/ocean/io/Terminal.d +++ b/src/ocean/io/Terminal.d @@ -31,8 +31,8 @@ debug(Term) import ocean.io.Stdout; private { - const TIOCGWINSZ = 0x5413; - const SIGWINCH = 28; + static immutable TIOCGWINSZ = 0x5413; + static immutable SIGWINCH = 28; /*************************************************************************** @@ -93,7 +93,7 @@ struct Terminal ***************************************************************************/ - public const istring CSI = "\x1B["; + public enum istring CSI = "\x1B["; /*************************************************************************** @@ -103,29 +103,29 @@ struct Terminal public struct Foreground { - public const istring BLACK = "30m"; - public const istring RED = "31m"; - public const istring GREEN = "32m"; - public const istring YELLOW = "33m"; - public const istring BLUE = "34m"; - public const istring MAGENTA = "35m"; - public const istring CYAN = "36m"; - public const istring WHITE = "37m"; - public const istring DEFAULT_UNDERSCORE = "38m"; - public const istring DEFAULT = "39m"; + public enum istring BLACK = "30m"; + public enum istring RED = "31m"; + public enum istring GREEN = "32m"; + public enum istring YELLOW = "33m"; + public enum istring BLUE = "34m"; + public enum istring MAGENTA = "35m"; + public enum istring CYAN = "36m"; + public enum istring WHITE = "37m"; + public enum istring DEFAULT_UNDERSCORE = "38m"; + public enum istring DEFAULT = "39m"; } public struct Background { - public const istring BLACK = "40m"; - public const istring RED = "41m"; - public const istring GREEN = "42m"; - public const istring YELLOW = "43m"; - public const istring BLUE = "44m"; - public const istring MAGENTA = "45m"; - public const istring CYAN = "46m"; - public const istring WHITE = "47m"; - public const istring DEFAULT = "49m"; + public enum istring BLACK = "40m"; + public enum istring RED = "41m"; + public enum istring GREEN = "42m"; + public enum istring YELLOW = "43m"; + public enum istring BLUE = "44m"; + public enum istring MAGENTA = "45m"; + public enum istring CYAN = "46m"; + public enum istring WHITE = "47m"; + public enum istring DEFAULT = "49m"; } @@ -184,9 +184,9 @@ struct Terminal ***************************************************************************/ - public const istring BOLD = "1m"; + public enum istring BOLD = "1m"; - public const istring NON_BOLD = "22m"; + public enum istring NON_BOLD = "22m"; /*************************************************************************** @@ -194,7 +194,7 @@ struct Terminal ***************************************************************************/ - public const istring CURSOR_UP = "A"; + public enum istring CURSOR_UP = "A"; /*************************************************************************** @@ -202,7 +202,7 @@ struct Terminal ***************************************************************************/ - public const istring LINE_UP = "F"; + public enum istring LINE_UP = "F"; /*************************************************************************** @@ -210,7 +210,7 @@ struct Terminal ***************************************************************************/ - public const istring SCROLL_UP = "S"; + public enum istring SCROLL_UP = "S"; /*************************************************************************** @@ -218,7 +218,7 @@ struct Terminal ***************************************************************************/ - public const istring INSERT_LINE = "L"; + public enum istring INSERT_LINE = "L"; /*************************************************************************** @@ -231,7 +231,7 @@ struct Terminal ***************************************************************************/ - public const istring ERASE_REST_OF_LINE = "K"; + public enum istring ERASE_REST_OF_LINE = "K"; /*************************************************************************** @@ -245,7 +245,7 @@ struct Terminal ***************************************************************************/ - public const istring ERASE_REST_OF_SCREEN = "J"; + public enum istring ERASE_REST_OF_SCREEN = "J"; /*************************************************************************** @@ -253,7 +253,7 @@ struct Terminal ***************************************************************************/ - public const istring HIDE_CURSOR = "?25l"; + public enum istring HIDE_CURSOR = "?25l"; /*************************************************************************** @@ -261,7 +261,7 @@ struct Terminal ***************************************************************************/ - public const istring SHOW_CURSOR = "?25h"; + public enum istring SHOW_CURSOR = "?25h"; /*************************************************************************** @@ -269,7 +269,7 @@ struct Terminal ***************************************************************************/ - public const istring HORIZONTAL_MOVE_CURSOR = "G"; + public enum istring HORIZONTAL_MOVE_CURSOR = "G"; } /******************************************************************************* diff --git a/src/ocean/io/compress/ZlibStream.d b/src/ocean/io/compress/ZlibStream.d index 0dc79d5e3..31a59c1f5 100644 --- a/src/ocean/io/compress/ZlibStream.d +++ b/src/ocean/io/compress/ZlibStream.d @@ -140,7 +140,7 @@ class ZlibStreamDecompressor // Setup correct window bits for specified encoding. // (See zlib.h for a description of how window bits work.) - const WINDOWBITS_DEFAULT = 15; + static immutable WINDOWBITS_DEFAULT = 15; int windowBits = WINDOWBITS_DEFAULT; switch ( encoding ) @@ -216,7 +216,7 @@ class ZlibStreamDecompressor ***************************************************************************/ public void decodeChunk ( ubyte[] compressed_chunk, - void delegate ( ubyte[] decompressed_chunk ) output_dg ) + scope void delegate ( ubyte[] decompressed_chunk ) output_dg ) { verify(this.stream_valid, typeof(this).stringof ~ ".decodeChunk: stream not started"); diff --git a/src/ocean/io/compress/lzo/LzoChunkCompressor.d b/src/ocean/io/compress/lzo/LzoChunkCompressor.d index 71e2c72cb..04d62d091 100644 --- a/src/ocean/io/compress/lzo/LzoChunkCompressor.d +++ b/src/ocean/io/compress/lzo/LzoChunkCompressor.d @@ -43,8 +43,8 @@ class LzoChunkCompressor ***************************************************************************/ - private const bool DecompressLenghtInline = false; - private const bool CompressLenghtInline = true; + private static immutable bool DecompressLenghtInline = false; + private static immutable bool CompressLenghtInline = true; /*************************************************************************** diff --git a/src/ocean/io/compress/lzo/LzoHeader.d b/src/ocean/io/compress/lzo/LzoHeader.d index b3f4cd10e..60c4dae91 100644 --- a/src/ocean/io/compress/lzo/LzoHeader.d +++ b/src/ocean/io/compress/lzo/LzoHeader.d @@ -95,7 +95,7 @@ align (1) struct LzoHeader ( bool LengthInline = true ) **************************************************************************/ - const ErrMsgSource = typeof (*this).stringof; + enum ErrMsgSource = typeof (*(&this)).stringof; /************************************************************************** @@ -138,11 +138,11 @@ align (1) struct LzoHeader ( bool LengthInline = true ) static if ( LengthInline ) { - const read_length = length; + enum read_length = length; } else { - const read_length = length - size_t.sizeof; + enum read_length = length - size_t.sizeof; } /************************************************************************** @@ -162,17 +162,17 @@ align (1) struct LzoHeader ( bool LengthInline = true ) void[] write ( void[] chunk ) { - static assert ((*this).sizeof == SizeofTuple!(typeof (this.tupleof)), - this.ErrMsgSource ~ ": Bad data alignment"); + static assert ((*(&this)).sizeof == SizeofTuple!(typeof ((&this).tupleof)), + (&this).ErrMsgSource ~ ": Bad data alignment"); - enforce!(CompressException)(chunk.length >= this.read_length, - this.ErrMsgSource ~ ": Chunk too short to write header"); + enforce!(CompressException)(chunk.length >= (&this).read_length, + (&this).ErrMsgSource ~ ": Chunk too short to write header"); - this.chunk_length = chunk.length - this.chunk_length.sizeof; + (&this).chunk_length = chunk.length - (&this).chunk_length.sizeof; - this.crc32_ = this.crc32(this.strip(chunk)); + (&this).crc32_ = (&this).crc32((&this).strip(chunk)); - *(cast (typeof (this)) chunk.ptr) = *this; + *(cast (typeof ((&this))) chunk.ptr) = *(&this); return chunk; } @@ -193,17 +193,17 @@ align (1) struct LzoHeader ( bool LengthInline = true ) **************************************************************************/ - typeof (this) uncompressed ( void[] payload ) + typeof ((&this)) uncompressed ( void[] payload ) { - this.type = this.type.None; + (&this).type = (&this).type.None; - this.uncompressed_length = payload.length; + (&this).uncompressed_length = payload.length; - this.chunk_length += payload.length; + (&this).chunk_length += payload.length; - this.crc32_ = this.crc32(payload); + (&this).crc32_ = (&this).crc32(payload); - return this; + return (&this); } /************************************************************************** @@ -220,17 +220,17 @@ align (1) struct LzoHeader ( bool LengthInline = true ) **************************************************************************/ - typeof (this) start ( size_t total_uncompressed_length ) + typeof ((&this)) start ( size_t total_uncompressed_length ) { - *this = typeof (*this).init; + *(&this) = typeof (*(&this)).init; - this.type = this.type.Start; + (&this).type = (&this).type.Start; - this.uncompressed_length = total_uncompressed_length; + (&this).uncompressed_length = total_uncompressed_length; - this.crc32_ = this.crc32(); + (&this).crc32_ = (&this).crc32(); - return this; + return (&this); } /************************************************************************** @@ -243,15 +243,15 @@ align (1) struct LzoHeader ( bool LengthInline = true ) **************************************************************************/ - typeof (this) stop ( ) + typeof ((&this)) stop ( ) { - *this = typeof (*this).init; + *(&this) = typeof (*(&this)).init; - this.type = this.type.Stop; + (&this).type = (&this).type.Stop; - this.crc32_ = this.crc32(); + (&this).crc32_ = (&this).crc32(); - return this; + return (&this); } /************************************************************************** @@ -272,14 +272,14 @@ align (1) struct LzoHeader ( bool LengthInline = true ) **************************************************************************/ - typeof (this) readStart ( void[] chunk ) + typeof ((&this)) readStart ( void[] chunk ) { - this.read(chunk); + (&this).read(chunk); - enforce!(CompressException)(this.type == Type.Start || this.type == Type.Stop, - this.ErrMsgSource ~ ": Not a Start header as expected"); + enforce!(CompressException)((&this).type == Type.Start || (&this).type == Type.Stop, + (&this).ErrMsgSource ~ ": Not a Start header as expected"); - return this; + return (&this); } /************************************************************************** @@ -297,18 +297,18 @@ align (1) struct LzoHeader ( bool LengthInline = true ) bool tryRead ( void[] chunk ) { - if ( chunk.length >= this.read_length ) + if ( chunk.length >= (&this).read_length ) { - if (this.isNullChunk(chunk)) + if ((&this).isNullChunk(chunk)) { - this.stop(); + (&this).stop(); return true; } else { - this.setHeader(chunk); - auto payload = this.strip(chunk); - return this.crc32_ == this.crc32(payload); + (&this).setHeader(chunk); + auto payload = (&this).strip(chunk); + return (&this).crc32_ == (&this).crc32(payload); } } @@ -362,7 +362,7 @@ align (1) struct LzoHeader ( bool LengthInline = true ) void[] data ( ) { - return (cast (void*) this)[0 .. this.read_length]; + return (cast (void*) (&this))[0 .. (&this).read_length]; } /************************************************************************** @@ -377,7 +377,7 @@ align (1) struct LzoHeader ( bool LengthInline = true ) void[] data_without_length ( ) { - return (cast (void*) this)[size_t.sizeof .. this.read_length]; + return (cast (void*) (&this))[size_t.sizeof .. (&this).read_length]; } /************************************************************************** @@ -400,21 +400,21 @@ align (1) struct LzoHeader ( bool LengthInline = true ) { void[] payload = null; - if (this.isNullChunk(chunk)) + if ((&this).isNullChunk(chunk)) { - this.stop(); + (&this).stop(); } else { - this.setHeader(chunk); + (&this).setHeader(chunk); - payload = this.strip(chunk); + payload = (&this).strip(chunk); - enforce!(CompressException)(this.lengthValid(chunk), - this.ErrMsgSource ~ ": Chunk length mismatch"); + enforce!(CompressException)((&this).lengthValid(chunk), + (&this).ErrMsgSource ~ ": Chunk length mismatch"); - enforce!(CompressException)(this.crc32_ == this.crc32(payload), - this.ErrMsgSource ~ ": Chunk data corrupted (CRC32 mismatch)"); + enforce!(CompressException)((&this).crc32_ == (&this).crc32(payload), + (&this).ErrMsgSource ~ ": Chunk data corrupted (CRC32 mismatch)"); } return payload; @@ -436,11 +436,11 @@ align (1) struct LzoHeader ( bool LengthInline = true ) { static if ( LengthInline ) { - return chunk.length == this.chunk_length + this.chunk_length.sizeof; + return chunk.length == (&this).chunk_length + (&this).chunk_length.sizeof; } else { - return chunk.length == this.chunk_length; + return chunk.length == (&this).chunk_length; } } @@ -456,25 +456,25 @@ align (1) struct LzoHeader ( bool LengthInline = true ) **************************************************************************/ - typeof(this) setHeader ( void[] chunk ) + typeof((&this)) setHeader ( void[] chunk ) { static if ( LengthInline ) { - *this = *cast (typeof (this)) chunk.ptr; + *(&this) = *cast (typeof ((&this))) chunk.ptr; } else { - this.chunk_length = chunk.length; + (&this).chunk_length = chunk.length; void* read_ptr = chunk.ptr; - this.crc32_ = *(cast(typeof(this.crc32_)*) read_ptr); - read_ptr += this.crc32_.sizeof; - this.type = *(cast(typeof(this.type)*) read_ptr); - read_ptr += this.type.sizeof; - this.uncompressed_length = *(cast(typeof(this.uncompressed_length)*) read_ptr); + (&this).crc32_ = *(cast(typeof((&this).crc32_)*) read_ptr); + read_ptr += (&this).crc32_.sizeof; + (&this).type = *(cast(typeof((&this).type)*) read_ptr); + read_ptr += (&this).type.sizeof; + (&this).uncompressed_length = *(cast(typeof((&this).uncompressed_length)*) read_ptr); } - return this; + return (&this); } /************************************************************************** @@ -485,7 +485,7 @@ align (1) struct LzoHeader ( bool LengthInline = true ) uint crc32 ( void[] payload = null ) { - uint crc32 = LzoCrc.crc32((cast (void*) this)[this.crc32_.offsetof + this.crc32_.sizeof .. this.length]); + uint crc32 = LzoCrc.crc32((cast (void*) (&this))[(&this).crc32_.offsetof + (&this).crc32_.sizeof .. (&this).length]); if (payload) { @@ -521,28 +521,28 @@ align (1) struct LzoHeader ( bool LengthInline = true ) { bool validated = false; - if (allow_null && this.isNullChunk(chunk)) + if (allow_null && (&this).isNullChunk(chunk)) { - this.stop(); + (&this).stop(); validated = true; } - else if (chunk.length == this.read_length) + else if (chunk.length == (&this).read_length) { - this.setHeader(chunk); + (&this).setHeader(chunk); - if (this.type == check_type) + if ((&this).type == check_type) { static if ( LengthInline ) { - if (chunk.length == this.chunk_length + this.chunk_length.sizeof) + if (chunk.length == (&this).chunk_length + (&this).chunk_length.sizeof) { - validated = this.crc32_ == this.crc32; + validated = (&this).crc32_ == (&this).crc32; } } else { - validated = this.crc32_ == this.crc32; + validated = (&this).crc32_ == (&this).crc32; } } } @@ -617,15 +617,15 @@ template SizeofTuple ( T ... ) { static if (T.length > 1) { - const SizeofTuple = T[0].sizeof + SizeofTuple!(T[1 .. $]); + static immutable SizeofTuple = T[0].sizeof + SizeofTuple!(T[1 .. $]); } else static if (T.length == 1) { - const SizeofTuple = T[0].sizeof; + static immutable SizeofTuple = T[0].sizeof; } else { - const size_t SizeofTuple = 0; + static immutable size_t SizeofTuple = 0; } } @@ -708,11 +708,11 @@ unittest LzoHeader!() header; - const N = 1000; + static immutable N = 1000; ubyte[header.sizeof][N] start_header_data, stop_header_data; - const C = 10; + static immutable C = 10; scope chunks4k = new void[][](C, 4 * 1024); scope chunks64k = new void[][](C, 64 * 1024); diff --git a/src/ocean/io/compress/lzo/c/lzoconf.d b/src/ocean/io/compress/lzo/c/lzoconf.d index 581b92f4a..0b9fc7b81 100644 --- a/src/ocean/io/compress/lzo/c/lzoconf.d +++ b/src/ocean/io/compress/lzo/c/lzoconf.d @@ -52,7 +52,7 @@ extern (C) **************************************************************************/ - const size_t Lzo1x1WorkmemSize = 16 * 1024 * (ubyte*).sizeof; + static immutable size_t Lzo1x1WorkmemSize = 16 * 1024 * (ubyte*).sizeof; /************************************************************************** diff --git a/src/ocean/io/console/AppStatus.d b/src/ocean/io/console/AppStatus.d index 1897d209a..6025f2994 100644 --- a/src/ocean/io/console/AppStatus.d +++ b/src/ocean/io/console/AppStatus.d @@ -491,8 +491,8 @@ public class AppStatus **************************************************************************/ public void connectedSocketHandler ( cstring[] command, - void delegate (cstring) write_line, - void delegate (ref mstring) read_line, IODevice socket ) + scope void delegate (cstring) write_line, + scope void delegate (ref mstring) read_line, IODevice socket ) { static File unix_socket_file; static TerminalOutput unix_terminal_output; @@ -907,7 +907,7 @@ public class AppStatus public bool getMemoryUsage ( out float mem_allocated, out float mem_free ) { - const float Mb = 1024 * 1024; + static immutable float Mb = 1024 * 1024; size_t used, free; ocean.transition.gc_usage(used, free); @@ -1396,8 +1396,8 @@ unittest { void example () { - const number_of_static_lines = 2; - const ms_between_calls = 1000; + static immutable number_of_static_lines = 2; + static immutable ms_between_calls = 1000; AppStatus app_status = new AppStatus("test", "revision", "build_date", "build_author", diff --git a/src/ocean/io/console/StructTable.d b/src/ocean/io/console/StructTable.d index 5f6560f87..4383c511b 100644 --- a/src/ocean/io/console/StructTable.d +++ b/src/ocean/io/console/StructTable.d @@ -172,11 +172,11 @@ public class StructTable ( S ) { static if ( i == S.tupleof.length ) { - const istring CellMethods = ""; + static immutable istring CellMethods = ""; } else { - const istring CellMethods = "protected char[] " + static immutable istring CellMethods = "protected char[] " ~ fieldIdentifier!(S, i) ~ "_string(" ~ typeof(S.tupleof[i]).stringof ~ "* field){return this.defaultFieldString(field);}" @@ -298,11 +298,11 @@ public class StructTable ( S ) { static if ( i == S.tupleof.length ) { - const istring ContentsRow = ""; + static immutable istring ContentsRow = ""; } else { - const istring ContentsRow = "this.addCell(this." + static immutable istring ContentsRow = "this.addCell(this." ~ fieldIdentifier!(S, i) ~ "_string(&item.tupleof[" ~ i.stringof ~ "]));" ~ ContentsRow!(i + 1); @@ -322,11 +322,11 @@ public class StructTable ( S ) { static if ( i == S.tupleof.length ) { - const istring HeaderRow = ""; + static immutable istring HeaderRow = ""; } else { - const istring HeaderRow = `this.addCell("` ~ fieldIdentifier!(S, i) ~ + static immutable istring HeaderRow = `this.addCell("` ~ fieldIdentifier!(S, i) ~ `");` ~ HeaderRow!(i + 1); } } diff --git a/src/ocean/io/console/Tables.d b/src/ocean/io/console/Tables.d index 0aaa460cd..be4a59580 100644 --- a/src/ocean/io/console/Tables.d +++ b/src/ocean/io/console/Tables.d @@ -177,7 +177,7 @@ public class Table *******************************************************************/ - public const inter_cell_spacing = 3; // = " | " + public enum inter_cell_spacing = 3; // = " | " /******************************************************************* @@ -408,12 +408,12 @@ public class Table *******************************************************************/ - public typeof(this) setString ( cstring str ) + public typeof((&this)) setString ( cstring str ) { - this.type = Type.String; - this.contents.utf8.copy(str); + (&this).type = Type.String; + (&this).contents.utf8.copy(str); - return this; + return (&this); } @@ -431,14 +431,14 @@ public class Table *******************************************************************/ - public typeof(this) setInteger ( ulong num, + public typeof((&this)) setInteger ( ulong num, bool use_thousands_separator = true ) { - this.type = Type.Integer; - this.use_thousands_separator = use_thousands_separator; - this.contents.integer = num; + (&this).type = Type.Integer; + (&this).use_thousands_separator = use_thousands_separator; + (&this).contents.integer = num; - return this; + return (&this); } @@ -457,13 +457,13 @@ public class Table *******************************************************************/ - public typeof(this) setBinaryMetric ( ulong num, cstring metric_string = "" ) + public typeof((&this)) setBinaryMetric ( ulong num, cstring metric_string = "" ) { - this.type = Type.BinaryMetric; - this.contents.integer = num; - this.metric_string.copy(metric_string); + (&this).type = Type.BinaryMetric; + (&this).contents.integer = num; + (&this).metric_string.copy(metric_string); - return this; + return (&this); } @@ -482,13 +482,13 @@ public class Table *******************************************************************/ - public typeof(this) setDecimalMetric ( ulong num, cstring metric_string = "" ) + public typeof((&this)) setDecimalMetric ( ulong num, cstring metric_string = "" ) { - this.type = Type.DecimalMetric; - this.contents.integer = num; - this.metric_string.copy(metric_string); + (&this).type = Type.DecimalMetric; + (&this).contents.integer = num; + (&this).metric_string.copy(metric_string); - return this; + return (&this); } @@ -504,12 +504,12 @@ public class Table *******************************************************************/ - public typeof(this) setFloat ( double num ) + public typeof((&this)) setFloat ( double num ) { - this.type = Type.Float; - this.contents.floating = num; + (&this).type = Type.Float; + (&this).contents.floating = num; - return this; + return (&this); } @@ -522,11 +522,11 @@ public class Table *******************************************************************/ - public typeof(this) setEmpty ( ) + public typeof((&this)) setEmpty ( ) { - this.type = Type.Empty; + (&this).type = Type.Empty; - return this; + return (&this); } @@ -539,11 +539,11 @@ public class Table *******************************************************************/ - public typeof(this) setDivider ( ) + public typeof((&this)) setDivider ( ) { - this.type = Type.Divider; + (&this).type = Type.Divider; - return this; + return (&this); } @@ -556,11 +556,11 @@ public class Table *******************************************************************/ - public typeof(this) setMerged ( ) + public typeof((&this)) setMerged ( ) { - this.type = Type.Merged; + (&this).type = Type.Merged; - return this; + return (&this); } @@ -576,12 +576,12 @@ public class Table *******************************************************************/ - public typeof(this) setForegroundColour ( Terminal.Colour colour ) + public typeof((&this)) setForegroundColour ( Terminal.Colour colour ) { auto colour_str = Terminal.fg_colour_codes[colour]; - this.fg_colour_string.concat(Terminal.CSI, colour_str); + (&this).fg_colour_string.concat(Terminal.CSI, colour_str); - return this; + return (&this); } @@ -597,12 +597,12 @@ public class Table *******************************************************************/ - public typeof(this) setBackgroundColour ( Terminal.Colour colour ) + public typeof((&this)) setBackgroundColour ( Terminal.Colour colour ) { auto colour_str = Terminal.bg_colour_codes[colour]; - this.bg_colour_string.concat(Terminal.CSI, colour_str); + (&this).bg_colour_string.concat(Terminal.CSI, colour_str); - return this; + return (&this); } @@ -615,7 +615,7 @@ public class Table public size_t width ( ) { - switch ( this.type ) + switch ( (&this).type ) { case Cell.Type.Merged: case Cell.Type.Empty: @@ -623,20 +623,20 @@ public class Table return 0; case Cell.Type.BinaryMetric: MetricPrefix metric; - metric.bin(this.contents.integer); - return this.floatWidth(metric.scaled) + 3 + - this.metric_string.length; + metric.bin((&this).contents.integer); + return (&this).floatWidth(metric.scaled) + 3 + + (&this).metric_string.length; case Cell.Type.DecimalMetric: MetricPrefix metric; - metric.dec(this.contents.integer); - return this.floatWidth(metric.scaled) + 2 + - this.metric_string.length; + metric.dec((&this).contents.integer); + return (&this).floatWidth(metric.scaled) + 2 + + (&this).metric_string.length; case Cell.Type.Integer: - return this.integerWidth(this.contents.integer); + return (&this).integerWidth((&this).contents.integer); case Cell.Type.Float: - return this.floatWidth(this.contents.floating); + return (&this).floatWidth((&this).contents.floating); case Cell.Type.String: - return utf8Length(this.contents.utf8); + return utf8Length((&this).contents.utf8); default: assert(0); @@ -667,13 +667,13 @@ public class Table Terminal.CSI ~ Terminal.bg_colour_codes[Terminal.Colour.Default]; // set the colour of this cell - if ( this.fg_colour_string.length > 0 || - this.bg_colour_string.length > 0 ) + if ( (&this).fg_colour_string.length > 0 || + (&this).bg_colour_string.length > 0 ) { - output.format("{}{}", this.fg_colour_string, this.bg_colour_string); + output.format("{}{}", (&this).fg_colour_string, (&this).bg_colour_string); } - if ( this.type == Type.Divider ) + if ( (&this).type == Type.Divider ) { content_buf.length = width + inter_cell_spacing; enableStomping(content_buf); @@ -682,15 +682,15 @@ public class Table output.format("{}", content_buf); // reset colour to default - if ( this.fg_colour_string.length > 0 || - this.bg_colour_string.length > 0 ) + if ( (&this).fg_colour_string.length > 0 || + (&this).bg_colour_string.length > 0 ) { output.format("{}", default_colours); } } else { - switch ( this.type ) + switch ( (&this).type ) { case Type.Empty: content_buf.length = 0; @@ -701,19 +701,19 @@ public class Table enableStomping(content_buf); MetricPrefix metric; - metric.bin(this.contents.integer); + metric.bin((&this).contents.integer); if ( metric.prefix == ' ' ) { sformat(content_buf, "{} {}", cast(uint)metric.scaled, - this.metric_string); + (&this).metric_string); } else { sformat(content_buf, "{} {}i{}", metric.scaled, metric.prefix, - this.metric_string); + (&this).metric_string); } break; case Type.DecimalMetric: @@ -721,42 +721,42 @@ public class Table enableStomping(content_buf); MetricPrefix metric; - metric.dec(this.contents.integer); + metric.dec((&this).contents.integer); if ( metric.prefix == ' ' ) { sformat(content_buf, "{} {}", cast(uint)metric.scaled, - this.metric_string); + (&this).metric_string); } else { sformat(content_buf, "{} {}{}", metric.scaled, metric.prefix, - this.metric_string); + (&this).metric_string); } break; case Type.Integer: - if ( this.use_thousands_separator ) + if ( (&this).use_thousands_separator ) { - DigitGrouping.format(this.contents.integer, content_buf); + DigitGrouping.format((&this).contents.integer, content_buf); } else { content_buf.length = 0; enableStomping(content_buf); sformat(content_buf, - "{}", this.contents.integer); + "{}", (&this).contents.integer); } break; case Type.Float: content_buf.length = 0; enableStomping(content_buf); sformat(content_buf, - "{}", this.contents.floating); + "{}", (&this).contents.floating); break; case Type.String: - content_buf = this.contents.utf8; + content_buf = (&this).contents.utf8; break; default: return; @@ -792,7 +792,7 @@ public class Table private size_t integerWidth ( ulong i ) { - if ( this.use_thousands_separator ) + if ( (&this).use_thousands_separator ) { return DigitGrouping.length(i); } @@ -910,7 +910,7 @@ public class Table ***********************************************************************/ - public int opApply ( int delegate ( ref Cell cell ) dg ) + public int opApply ( scope int delegate ( ref Cell cell ) dg ) { int res; foreach ( cell; this.cells ) @@ -929,7 +929,7 @@ public class Table ***********************************************************************/ - public int opApply ( int delegate ( ref size_t i, ref Cell cell ) dg ) + public int opApply ( scope int delegate ( ref size_t i, ref Cell cell ) dg ) { int res; foreach ( i, cell; this.cells ) @@ -1438,7 +1438,7 @@ unittest int records1, records2, bytes1, bytes2; } - const nodes = + static immutable nodes = [ Node(123456, 789012, 345678, 901234), Node(901234, 123456, 789012, 345678), @@ -1462,7 +1462,7 @@ unittest // note: The string literal embeds escape characters, which are used by // the table functions to set foreground/background colors in the console. -const check = +static immutable check = `------------------------------------------------------ 0xdb6db6e4 .. 0xedb6db76 | 0xedb6db77 .. 0xffffffff | ------------------------------------------------------ diff --git a/src/ocean/io/console/readline/c/readline.d b/src/ocean/io/console/readline/c/readline.d index d5053af4a..3052af598 100644 --- a/src/ocean/io/console/readline/c/readline.d +++ b/src/ocean/io/console/readline/c/readline.d @@ -63,7 +63,7 @@ public extern (C) ***************************************************************************/ - int rl_bind_key(int key, rl_command_func_t* _function); + int rl_bind_key(int key, scope rl_command_func_t* _function); /*************************************************************************** diff --git a/src/ocean/io/device/Array.d b/src/ocean/io/device/Array.d index 6e4826d57..ec16e502b 100644 --- a/src/ocean/io/device/Array.d +++ b/src/ocean/io/device/Array.d @@ -476,7 +476,7 @@ class Array : Conduit, InputBuffer, OutputBuffer, Conduit.Seek ***********************************************************************/ - final bool next (size_t delegate (Const!(void)[]) scan) + final bool next (scope size_t delegate (Const!(void)[]) scan) { return reader (scan) != IConduit.Eof; } @@ -618,7 +618,7 @@ class Array : Conduit, InputBuffer, OutputBuffer, Conduit.Seek ***********************************************************************/ - final size_t writer (size_t delegate (void[]) dg) + final size_t writer (scope size_t delegate (void[]) dg) { auto count = dg (data [extent..dimension]); @@ -651,7 +651,7 @@ class Array : Conduit, InputBuffer, OutputBuffer, Conduit.Seek ***********************************************************************/ - final size_t reader (size_t delegate (Const!(void)[]) dg) + final size_t reader (scope size_t delegate (Const!(void)[]) dg) { auto count = dg (data [index..extent]); diff --git a/src/ocean/io/device/File.d b/src/ocean/io/device/File.d index 1e1658754..e2a7c48b9 100644 --- a/src/ocean/io/device/File.d +++ b/src/ocean/io/device/File.d @@ -143,7 +143,7 @@ class File : Device, Device.Seek, Device.Truncate { static import ocean.core.ExceptionDefinitions; import ocean.sys.CloseOnExec; - const O_CLOEXEC = 0x80000; + static immutable O_CLOEXEC = 0x80000; public alias Device.read read; public alias Device.write write; @@ -271,7 +271,7 @@ class File : Device, Device.Seek, Device.Truncate ***********************************************************************/ - const Style ReadExisting = {Access.Read, Open.Exists}; + static immutable Style ReadExisting = {Access.Read, Open.Exists}; /*********************************************************************** @@ -279,7 +279,7 @@ class File : Device, Device.Seek, Device.Truncate ***********************************************************************/ - const Style ReadShared = {Access.Read, Open.Exists, Share.Read}; + static immutable Style ReadShared = {Access.Read, Open.Exists, Share.Read}; /*********************************************************************** @@ -287,7 +287,7 @@ class File : Device, Device.Seek, Device.Truncate ***********************************************************************/ - const Style WriteExisting = {Access.Write, Open.Exists}; + static immutable Style WriteExisting = {Access.Write, Open.Exists}; /*********************************************************************** @@ -295,7 +295,7 @@ class File : Device, Device.Seek, Device.Truncate ***********************************************************************/ - const Style WriteCreate = {Access.Write, Open.Create}; + static immutable Style WriteCreate = {Access.Write, Open.Create}; /*********************************************************************** @@ -303,7 +303,7 @@ class File : Device, Device.Seek, Device.Truncate ***********************************************************************/ - const Style ReadWriteAppending = {Access.ReadWrite, Open.Append}; + static immutable Style ReadWriteAppending = {Access.ReadWrite, Open.Append}; /*********************************************************************** @@ -311,7 +311,7 @@ class File : Device, Device.Seek, Device.Truncate ***********************************************************************/ - const Style WriteAppending = {Access.Write, Open.Append}; + static immutable Style WriteAppending = {Access.Write, Open.Append}; /*********************************************************************** @@ -319,7 +319,7 @@ class File : Device, Device.Seek, Device.Truncate ***********************************************************************/ - const Style ReadWriteExisting = {Access.ReadWrite, Open.Exists}; + static immutable Style ReadWriteExisting = {Access.ReadWrite, Open.Exists}; /*********************************************************************** @@ -327,7 +327,7 @@ class File : Device, Device.Seek, Device.Truncate ***********************************************************************/ - const Style ReadWriteCreate = {Access.ReadWrite, Open.Create}; + static immutable Style ReadWriteCreate = {Access.ReadWrite, Open.Create}; /*********************************************************************** @@ -335,7 +335,7 @@ class File : Device, Device.Seek, Device.Truncate ***********************************************************************/ - const Style ReadWriteOpen = {Access.ReadWrite, Open.Sedate}; + static immutable Style ReadWriteOpen = {Access.ReadWrite, Open.Sedate}; // the file we're working with @@ -512,7 +512,7 @@ class File : Device, Device.Seek, Device.Truncate { alias int[] Flags; - const Flags Access = + static immutable Flags Access = [ 0, // invalid O_RDONLY, @@ -520,7 +520,7 @@ class File : Device, Device.Seek, Device.Truncate O_RDWR, ]; - const Flags Create = + static immutable Flags Create = [ 0, // open existing O_CREAT | O_TRUNC, // truncate always @@ -529,7 +529,7 @@ class File : Device, Device.Seek, Device.Truncate O_CREAT | O_EXCL, // can't exist ]; - const short[] Locks = + static immutable short[] Locks = [ F_WRLCK, // no sharing F_RDLCK, // shared read diff --git a/src/ocean/io/device/TempFile.d b/src/ocean/io/device/TempFile.d index 5054990f9..2e48f6538 100644 --- a/src/ocean/io/device/TempFile.d +++ b/src/ocean/io/device/TempFile.d @@ -124,12 +124,12 @@ class TempFile : File * TempStyle for creating a transient temporary file that only the current * user can access. */ - const TempStyle Transient = {Transience.Transient}; + static immutable TempStyle Transient = {Transience.Transient}; /** * TempStyle for creating a permanent temporary file that only the current * user can access. */ - const TempStyle Permanent = {Transience.Permanent}; + static immutable TempStyle Permanent = {Transience.Permanent}; // Path to the temporary file private istring _path; @@ -178,13 +178,13 @@ class TempFile : File error("could not create temporary file"); } - private const DEFAULT_LENGTH = 6; - private const DEFAULT_PREFIX = ".tmp"; + private static immutable DEFAULT_LENGTH = 6; + private static immutable DEFAULT_PREFIX = ".tmp"; // Use "~" to work around a bug in DMD where it elides empty constants - private const DEFAULT_SUFFIX = "~"; + private static immutable DEFAULT_SUFFIX = "~"; - private const JUNK_CHARS = + private static immutable JUNK_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; /*************************************************************************** diff --git a/src/ocean/io/digest/Fnv1.d b/src/ocean/io/digest/Fnv1.d index fc108d08d..4a7deaf32 100644 --- a/src/ocean/io/digest/Fnv1.d +++ b/src/ocean/io/digest/Fnv1.d @@ -48,14 +48,14 @@ public template Fnv1Const ( T = hash_t ) static if (is (DigestType == uint)) { - public const DigestType PRIME = 0x0100_0193; // 32 bit prime - public const DigestType INIT = 0x811C_9DC5; // 32 bit inital digest + public static immutable DigestType PRIME = 0x0100_0193; // 32 bit prime + public static immutable DigestType INIT = 0x811C_9DC5; // 32 bit inital digest public alias ByteSwap.swap32 toBigEnd; } else static if (is (DigestType == ulong)) { - public const DigestType PRIME = 0x0000_0100_0000_01B3; // 64 bit prime - public const DigestType INIT = 0xCBF2_9CE4_8422_2325; // 64 bit inital digest + public static immutable DigestType PRIME = 0x0000_0100_0000_01B3; // 64 bit prime + public static immutable DigestType INIT = 0xCBF2_9CE4_8422_2325; // 64 bit inital digest public alias ByteSwap.swap64 toBigEnd; } /* @@ -108,7 +108,7 @@ public template StaticFnv1a ( T = hash_t ) public template Fnv1a ( istring input ) { - public const Fnv1a = Fnv1a!(Fnv1Const!(T).INIT, input); + public static immutable Fnv1a = Fnv1a!(Fnv1Const!(T).INIT, input); } /*************************************************************************** @@ -122,11 +122,11 @@ public template StaticFnv1a ( T = hash_t ) { static if ( input.length ) { - public const Fnv1a = Fnv1a!((hash ^ input[0]) * Fnv1Const!(T).PRIME, input[1 .. $]); + public static immutable Fnv1a = Fnv1a!((hash ^ input[0]) * Fnv1Const!(T).PRIME, input[1 .. $]); } else { - public const Fnv1a = hash; + public static immutable Fnv1a = hash; } } } @@ -149,22 +149,22 @@ public alias Fnv1Const!(ulong) Fnv164Const; public template StaticFnv1a32 ( istring input ) { - public const StaticFnv1a32 = StaticFnv1a!(uint).Fnv1a!(input); + public static immutable StaticFnv1a32 = StaticFnv1a!(uint).Fnv1a!(input); } public template StaticFnv1a32 ( uint hash, istring input ) { - public const StaticFnv1a32 = StaticFnv1a!(uint).Fnv1a!(hash, input); + public static immutable StaticFnv1a32 = StaticFnv1a!(uint).Fnv1a!(hash, input); } public template StaticFnv1a64 ( istring input ) { - public const StaticFnv1a64 = StaticFnv1a!(ulong).Fnv1a!(input); + public static immutable StaticFnv1a64 = StaticFnv1a!(ulong).Fnv1a!(input); } public template StaticFnv1a64 ( ulong hash, istring input ) { - public const StaticFnv1a64 = StaticFnv1a!(ulong).Fnv1a!(hash, input); + public static immutable StaticFnv1a64 = StaticFnv1a!(ulong).Fnv1a!(hash, input); } @@ -307,8 +307,8 @@ public class Fnv1Generic ( bool FNV1A = false, T = hash_t ) : FnvDigest **************************************************************************/ - public const DIGEST_LENGTH = DigestType.sizeof; - public const HEXDGT_LENGTH = DIGEST_LENGTH * 2; + public static immutable DIGEST_LENGTH = DigestType.sizeof; + public static immutable HEXDGT_LENGTH = DIGEST_LENGTH * 2; public alias char[HEXDGT_LENGTH] HexDigest; @@ -353,7 +353,7 @@ public class Fnv1Generic ( bool FNV1A = false, T = hash_t ) : FnvDigest public ubyte[] opCall ( DigestType value ) { - this.value = value; + (&this).value = value; version (LittleEndian) toBigEnd(array); @@ -774,7 +774,7 @@ unittest istring str; } - const TestData[] testdata = + static immutable TestData[] testdata = [ {0xc5f1d7e9, [0xc5, 0xf1, 0xd7, 0xe9], "c5f1d7e9", 0x512b2851, [0x51, 0x2b, 0x28, 0x51], "512b2851", 0x43c94e2c8b277509, [0x43, 0xc9, 0x4e, 0x2c, 0x8b, 0x27, 0x75, 0x09], "43c94e2c8b277509", 0x33b96c3cd65b5f71, [0x33, 0xb9, 0x6c, 0x3c, 0xd6, 0x5b, 0x5f, 0x71], "33b96c3cd65b5f71", true, "391581216093391581216093391581216093391581216093391581216093391581216093391581216093391581216093391581216093391581216093"}, {0x32c1f439, [0x32, 0xc1, 0xf4, 0x39], "32c1f439", 0x76823999, [0x76, 0x82, 0x39, 0x99], "76823999", 0x3cbfd4e4ea670359, [0x3c, 0xbf, 0xd4, 0xe4, 0xea, 0x67, 0x03, 0x59], "3cbfd4e4ea670359", 0xd845097780602bb9, [0xd8, 0x45, 0x09, 0x77, 0x80, 0x60, 0x2b, 0xb9], "d845097780602bb9", true, "391581*2^216093-1391581*2^216093-1391581*2^216093-1391581*2^216093-1391581*2^216093-1391581*2^216093-1391581*2^216093-1391581*2^216093-1391581*2^216093-1391581*2^216093-1"}, diff --git a/src/ocean/io/model/IConduit.d b/src/ocean/io/model/IConduit.d index d929118ff..cefd6b1ce 100644 --- a/src/ocean/io/model/IConduit.d +++ b/src/ocean/io/model/IConduit.d @@ -131,7 +131,7 @@ interface ISelectable interface IOStream { - const Eof = -1; /// The End-of-Flow identifer. + static immutable Eof = -1; /// The End-of-Flow identifer. /*********************************************************************** @@ -308,9 +308,9 @@ interface InputBuffer : InputStream { void[] slice (); - bool next (size_t delegate (Const!(void)[]) scan); + bool next (scope size_t delegate (Const!(void)[]) scan); - size_t reader (size_t delegate(Const!(void)[]) consumer); + size_t reader (scope size_t delegate(Const!(void)[]) consumer); } /******************************************************************************* @@ -327,7 +327,7 @@ interface OutputBuffer : OutputStream OutputBuffer append (Const!(void)[]); - size_t writer (size_t delegate(void[]) producer); + size_t writer (scope size_t delegate(void[]) producer); } diff --git a/src/ocean/io/model/IFile.d b/src/ocean/io/model/IFile.d index 691d62a39..4ef8393df 100644 --- a/src/ocean/io/model/IFile.d +++ b/src/ocean/io/model/IFile.d @@ -50,22 +50,22 @@ public interface FileConst } /// The parent directory string. - const ParentDirString = ".."; + static immutable ParentDirString = ".."; /// The current directory string. - const CurrentDirString = "."; + static immutable CurrentDirString = "."; /// The file separator string. - const FileSeparatorString = "."; + static immutable FileSeparatorString = "."; /// The path separator string. - const PathSeparatorString = "/"; + static immutable PathSeparatorString = "/"; /// The system path string. - const SystemPathString = ":"; + static immutable SystemPathString = ":"; /// The newline string. - const NewlineString = "\n"; + static immutable NewlineString = "\n"; } /******************************************************************************* diff --git a/src/ocean/io/model/SuspendableThrottlerCount.d b/src/ocean/io/model/SuspendableThrottlerCount.d index 61b3f87da..9ae666101 100644 --- a/src/ocean/io/model/SuspendableThrottlerCount.d +++ b/src/ocean/io/model/SuspendableThrottlerCount.d @@ -330,8 +330,8 @@ version ( UnitTest ) abstract scope class ISuspendableThrottlerCount_Test { - const suspend = 10; - const resume = 2; + static immutable suspend = 10; + static immutable resume = 2; protected ISuspendableThrottlerCount throttler; @@ -351,7 +351,7 @@ version ( UnitTest ) test(this.throttler.suspended); // Empty throttler to one before resumption - const diff = suspend - resume; + static immutable diff = suspend - resume; for ( int i; i < diff - 1; i++ ) { this.dec(); diff --git a/src/ocean/io/select/EpollSelectDispatcher.d b/src/ocean/io/select/EpollSelectDispatcher.d index f1c919ba5..2e8db45dd 100644 --- a/src/ocean/io/select/EpollSelectDispatcher.d +++ b/src/ocean/io/select/EpollSelectDispatcher.d @@ -115,7 +115,7 @@ public class EpollSelectDispatcher : IEpollSelectDispatcherInfo **************************************************************************/ - public const uint DefaultMaxEvents = 16; + public static immutable uint DefaultMaxEvents = 16; /************************************************************************** @@ -336,7 +336,7 @@ public class EpollSelectDispatcher : IEpollSelectDispatcherInfo ***************************************************************************/ - public void onCycleEnd ( SelectCycleCallback cb ) + public void onCycleEnd ( scope SelectCycleCallback cb ) { this.select_cycle_callbacks.push(cb); } @@ -768,8 +768,8 @@ public class EpollSelectDispatcher : IEpollSelectDispatcherInfo **************************************************************************/ - public void eventLoop ( bool delegate ( ) select_cycle_hook = null, - bool delegate (Exception) unhandled_exception_hook = null ) + public void eventLoop ( scope bool delegate ( ) select_cycle_hook = null, + scope bool delegate (Exception) unhandled_exception_hook = null ) { verify(!this.in_event_loop, "Event loop has already been started."); diff --git a/src/ocean/io/select/client/FileSystemEvent.d b/src/ocean/io/select/client/FileSystemEvent.d index 474256a65..4f7caf79b 100644 --- a/src/ocean/io/select/client/FileSystemEvent.d +++ b/src/ocean/io/select/client/FileSystemEvent.d @@ -182,7 +182,7 @@ class FileSystemEvent : ISelectClient ***********************************************************************/ - public this ( Notifier notifier ) + public this ( scope Notifier notifier ) { this(); this.notifier = notifier; @@ -210,7 +210,7 @@ class FileSystemEvent : ISelectClient ***********************************************************************/ - public void setNotifier ( Notifier notifier ) + public void setNotifier ( scope Notifier notifier ) { this.notifier = notifier; } diff --git a/src/ocean/io/select/client/SelectEvent.d b/src/ocean/io/select/client/SelectEvent.d index 0d898bf40..56a0fde7e 100644 --- a/src/ocean/io/select/client/SelectEvent.d +++ b/src/ocean/io/select/client/SelectEvent.d @@ -218,7 +218,7 @@ public class SelectEvent : ISelectEvent ***************************************************************************/ - public this ( Handler handler ) + public this ( scope Handler handler ) { this.handler = handler; @@ -293,7 +293,7 @@ public class CountingSelectEvent : ISelectEvent ***************************************************************************/ - public this ( Handler handler ) + public this ( scope Handler handler ) { this.handler = handler; diff --git a/src/ocean/io/select/client/SignalEvent.d b/src/ocean/io/select/client/SignalEvent.d index 22388e4fb..7de109bc2 100644 --- a/src/ocean/io/select/client/SignalEvent.d +++ b/src/ocean/io/select/client/SignalEvent.d @@ -109,7 +109,7 @@ public class SignalEvent : ISelectClient ***************************************************************************/ - public this ( Handler handler, int[] signals ... ) + public this ( scope Handler handler, int[] signals ... ) { verify(handler !is null); diff --git a/src/ocean/io/select/client/TimerEvent.d b/src/ocean/io/select/client/TimerEvent.d index 5569fe1bd..bf090394a 100644 --- a/src/ocean/io/select/client/TimerEvent.d +++ b/src/ocean/io/select/client/TimerEvent.d @@ -71,7 +71,7 @@ class TimerEvent : ITimerEvent ***********************************************************************/ - public this ( Handler handler, bool realtime = false ) + public this ( scope Handler handler, bool realtime = false ) { super(realtime); @@ -108,7 +108,7 @@ class TimerEvent : ITimerEvent ***********************************************************************/ - public void setHandler ( Handler handler ) + public void setHandler ( scope Handler handler ) { this.handler = handler; } diff --git a/src/ocean/io/select/client/TimerSet.d b/src/ocean/io/select/client/TimerSet.d index d3972250f..6e4cc2e06 100644 --- a/src/ocean/io/select/client/TimerSet.d +++ b/src/ocean/io/select/client/TimerSet.d @@ -308,7 +308,7 @@ public class TimerSet ( EventData ) : TimerEventTimeoutManager ***************************************************************************/ - public IEvent schedule ( EventSetupDg setup_dg, EventFiredDg fired_dg, + public IEvent schedule ( scope EventSetupDg setup_dg, scope EventFiredDg fired_dg, ulong schedule_us ) out ( event ) { diff --git a/src/ocean/io/select/client/model/ISelectClient.d b/src/ocean/io/select/client/model/ISelectClient.d index 3571a57e7..644646e40 100644 --- a/src/ocean/io/select/client/model/ISelectClient.d +++ b/src/ocean/io/select/client/model/ISelectClient.d @@ -413,7 +413,7 @@ public abstract class ISelectClient : ITimeoutClient, ISelectable, ISelectClient ***************************************************************************/ - public void fmtInfo ( void delegate ( cstring chunk ) sink ) + public void fmtInfo ( scope void delegate ( cstring chunk ) sink ) { sformat( (cstring chunk) {sink(chunk); }, diff --git a/src/ocean/io/select/fiber/SelectFiber.d b/src/ocean/io/select/fiber/SelectFiber.d index b3416fa7a..32311fb55 100644 --- a/src/ocean/io/select/fiber/SelectFiber.d +++ b/src/ocean/io/select/fiber/SelectFiber.d @@ -82,7 +82,7 @@ public class SelectFiber : MessageFiber **************************************************************************/ - this ( EpollSelectDispatcher epoll, void delegate ( ) coroutine ) + this ( EpollSelectDispatcher epoll, scope void delegate ( ) coroutine ) { this.epoll = epoll; @@ -100,7 +100,7 @@ public class SelectFiber : MessageFiber **************************************************************************/ - this ( EpollSelectDispatcher epoll, void delegate ( ) coroutine, size_t sz ) + this ( EpollSelectDispatcher epoll, scope void delegate ( ) coroutine, size_t sz ) { this.epoll = epoll; diff --git a/src/ocean/io/select/protocol/SelectReader.d b/src/ocean/io/select/protocol/SelectReader.d index f7d2273ad..1eaf603bb 100644 --- a/src/ocean/io/select/protocol/SelectReader.d +++ b/src/ocean/io/select/protocol/SelectReader.d @@ -145,7 +145,7 @@ class SelectReader : IAdvancedSelectClient ***************************************************************************/ - public void read ( void delegate ( void[] data ) dg ) + public void read ( scope void delegate ( void[] data ) dg ) { this.reader = dg; diff --git a/src/ocean/io/select/protocol/fiber/BufferedFiberSelectWriter.d b/src/ocean/io/select/protocol/fiber/BufferedFiberSelectWriter.d index 4952e9e35..d871095c1 100644 --- a/src/ocean/io/select/protocol/fiber/BufferedFiberSelectWriter.d +++ b/src/ocean/io/select/protocol/fiber/BufferedFiberSelectWriter.d @@ -35,7 +35,7 @@ class BufferedFiberSelectWriter : FiberSelectWriter **************************************************************************/ - public const default_buffer_size = 64 * 1024; + public static immutable default_buffer_size = 64 * 1024; /************************************************************************** diff --git a/src/ocean/io/select/protocol/fiber/FiberSelectReader.d b/src/ocean/io/select/protocol/fiber/FiberSelectReader.d index ab5e86122..9c9e0c851 100644 --- a/src/ocean/io/select/protocol/fiber/FiberSelectReader.d +++ b/src/ocean/io/select/protocol/fiber/FiberSelectReader.d @@ -45,7 +45,7 @@ class FiberSelectReader : IFiberSelectProtocol **************************************************************************/ - public const size_t default_buffer_size = 16 * 1024; + public static immutable size_t default_buffer_size = 16 * 1024; /************************************************************************** @@ -240,7 +240,7 @@ class FiberSelectReader : IFiberSelectProtocol **************************************************************************/ - public bool consume ( Consumer consume ) + public bool consume ( scope Consumer consume ) { size_t n = consume(this.data[this.consumed .. this.available]), end = this.consumed + n; @@ -416,7 +416,7 @@ class FiberSelectReader : IFiberSelectProtocol **************************************************************************/ - public typeof (this) readConsume ( Consumer consume ) + public typeof (this) readConsume ( scope Consumer consume ) { bool more; diff --git a/src/ocean/io/select/protocol/task/TaskSelectClient.d b/src/ocean/io/select/protocol/task/TaskSelectClient.d index 910987845..84fbaaa9f 100644 --- a/src/ocean/io/select/protocol/task/TaskSelectClient.d +++ b/src/ocean/io/select/protocol/task/TaskSelectClient.d @@ -102,7 +102,7 @@ class TaskSelectClient: ISelectClient ***************************************************************************/ - public this ( ISelectable iodev, int delegate ( ) error_code_dg ) + public this ( ISelectable iodev, scope int delegate ( ) error_code_dg ) { this.iodev = iodev; this.error_code_dg = error_code_dg; diff --git a/src/ocean/io/select/protocol/task/TaskSelectTransceiver.d b/src/ocean/io/select/protocol/task/TaskSelectTransceiver.d index 6a8930afe..94ae9af2f 100644 --- a/src/ocean/io/select/protocol/task/TaskSelectTransceiver.d +++ b/src/ocean/io/select/protocol/task/TaskSelectTransceiver.d @@ -208,7 +208,7 @@ class TaskSelectTransceiver ***************************************************************************/ - public void readConsume ( size_t delegate ( void[] data ) consume ) + public void readConsume ( scope size_t delegate ( void[] data ) consume ) { this.buffered_reader.readConsume(consume, &this.deviceRead); } @@ -663,7 +663,7 @@ import ocean.text.util.ClassName; *******************************************************************************/ public int connect ( Socket: IODevice ) ( TaskSelectTransceiver tst, - bool delegate ( Socket socket ) socket_connect ) + scope bool delegate ( Socket socket ) socket_connect ) { auto socket = cast(Socket)tst.iodev; verify(socket !is null, "connect: Unable to cast the I/O " ~ diff --git a/src/ocean/io/select/protocol/task/TaskSelectTransceiver_test.d b/src/ocean/io/select/protocol/task/TaskSelectTransceiver_test.d index 2fac169c4..e1b796e59 100644 --- a/src/ocean/io/select/protocol/task/TaskSelectTransceiver_test.d +++ b/src/ocean/io/select/protocol/task/TaskSelectTransceiver_test.d @@ -70,7 +70,7 @@ unittest initScheduler(SchedulerConfiguration.init); - const outstr = "Hello World!"; + static immutable outstr = "Hello World!"; char[outstr.length] instr; // Start a task that writes the test string to the pipe. @@ -86,7 +86,7 @@ unittest override void run ( ) { // Read only "Hello " to test readv(). - const hello = "Hello ".length; + static immutable hello = "Hello ".length; intst.read(instr[0 .. hello]); auto world = instr[hello .. $]; diff --git a/src/ocean/io/select/protocol/task/internal/BufferedReader.d b/src/ocean/io/select/protocol/task/internal/BufferedReader.d index 0779b3a15..585ac4bab 100644 --- a/src/ocean/io/select/protocol/task/internal/BufferedReader.d +++ b/src/ocean/io/select/protocol/task/internal/BufferedReader.d @@ -25,7 +25,7 @@ class BufferedReader ***************************************************************************/ - public const size_t default_read_buffer_size = 1U << 14; + public static immutable size_t default_read_buffer_size = 1U << 14; /*************************************************************************** @@ -110,8 +110,8 @@ class BufferedReader ***************************************************************************/ - public void readConsume ( size_t delegate ( void[] data ) consume, - size_t delegate ( void[] dst ) ioread ) + public void readConsume ( scope size_t delegate ( void[] data ) consume, + scope size_t delegate ( void[] dst ) ioread ) { while (!this.available) this.available = ioread(this.data); @@ -154,7 +154,7 @@ class BufferedReader ***************************************************************************/ - public void readRaw ( void[] dst, size_t delegate ( void[] dst_a, void[] dst_b ) ioread ) + public void readRaw ( void[] dst, scope size_t delegate ( void[] dst_a, void[] dst_b ) ioread ) { auto available_data = this.data[this.consumed .. this.available]; diff --git a/src/ocean/io/select/selector/EpollFdSanity.d b/src/ocean/io/select/selector/EpollFdSanity.d index cc18d7106..2e32aa21a 100644 --- a/src/ocean/io/select/selector/EpollFdSanity.d +++ b/src/ocean/io/select/selector/EpollFdSanity.d @@ -41,13 +41,13 @@ version (UnitTest) public struct FdObjEpollData { /// Number of bits to store address in - private const address_bits = 56; + private enum address_bits = 56; /// Mask for the user-space address - private const address_mask = (1UL << address_bits) - 1; + private enum address_mask = (1UL << address_bits) - 1; /// Mask for the storing part of the fd - private const fd_mask = ~address_mask; + private enum fd_mask = ~address_mask; static assert(address_mask + fd_mask == ulong.max); @@ -119,7 +119,7 @@ public struct FdObjEpollData public bool verifyFd (int fd) { - return this.fd == (fd & 0xFF); + return (&this).fd == (fd & 0xFF); } } diff --git a/src/ocean/io/select/selector/RegisteredClients.d b/src/ocean/io/select/selector/RegisteredClients.d index 55aa17ea6..b8681e94b 100644 --- a/src/ocean/io/select/selector/RegisteredClients.d +++ b/src/ocean/io/select/selector/RegisteredClients.d @@ -171,7 +171,7 @@ public final class ClientSet : IRegisteredClients ***********************************************************************/ - const max_clients_estimate = 1000; + static immutable max_clients_estimate = 1000; /*********************************************************************** @@ -262,7 +262,7 @@ public final class ClientSet : IRegisteredClients ***************************************************************************/ - public int opApply ( int delegate ( ref ISelectClient ) dg ) + public int opApply ( scope int delegate ( ref ISelectClient ) dg ) { int res; foreach ( client; this.clients ) diff --git a/src/ocean/io/select/selector/SelectedKeysHandler.d b/src/ocean/io/select/selector/SelectedKeysHandler.d index e1a31d3c2..dafa2ba69 100644 --- a/src/ocean/io/select/selector/SelectedKeysHandler.d +++ b/src/ocean/io/select/selector/SelectedKeysHandler.d @@ -103,7 +103,7 @@ class SelectedKeysHandler: ISelectedKeysHandler ***************************************************************************/ - public this ( UnregisterDg unregister, EpollException e ) + public this ( scope UnregisterDg unregister, EpollException e ) { this.unregister = unregister; this.e = e; @@ -122,7 +122,7 @@ class SelectedKeysHandler: ISelectedKeysHandler ***************************************************************************/ override public void opCall ( epoll_event_t[] selected_set, - bool delegate (Exception) unhandled_exception_hook ) + scope bool delegate (Exception) unhandled_exception_hook ) { foreach (key; selected_set) { @@ -153,7 +153,7 @@ class SelectedKeysHandler: ISelectedKeysHandler **************************************************************************/ final protected void handleSelectedKey ( epoll_event_t key, - bool delegate (Exception) unhandled_exception_hook ) + scope bool delegate (Exception) unhandled_exception_hook ) { debug (EpollFdSanity) { diff --git a/src/ocean/io/select/selector/TimeoutSelectedKeysHandler.d b/src/ocean/io/select/selector/TimeoutSelectedKeysHandler.d index 09ce6806c..406ee466a 100644 --- a/src/ocean/io/select/selector/TimeoutSelectedKeysHandler.d +++ b/src/ocean/io/select/selector/TimeoutSelectedKeysHandler.d @@ -79,7 +79,7 @@ class TimeoutSelectedKeysHandler: SelectedKeysHandler ***************************************************************************/ - public this ( UnregisterDg unregister, EpollException e, + public this ( scope UnregisterDg unregister, EpollException e, ITimeoutManager timeout_manager, uint num_clients = 0 ) { super(unregister, e); @@ -106,7 +106,7 @@ class TimeoutSelectedKeysHandler: SelectedKeysHandler ***************************************************************************/ public override void opCall ( epoll_event_t[] selected_set, - bool delegate (Exception) unhandled_exception_hook ) + scope bool delegate (Exception) unhandled_exception_hook ) { if (this.timeout_manager.us_left < timeout_manager.us_left.max) { @@ -196,8 +196,8 @@ class TimeoutSelectedKeysHandler: SelectedKeysHandler ***************************************************************************/ extern (C) private static int cmpPtr ( bool searching ) ( - /* d1to2fix_inject: scope */ Const!(void*) a_, - /* d1to2fix_inject: scope */ Const!(void*) b_ ) + scope Const!(void*) a_, + scope Const!(void*) b_ ) { static if (searching) { diff --git a/src/ocean/io/select/selector/model/ISelectedKeysHandler.d b/src/ocean/io/select/selector/model/ISelectedKeysHandler.d index bdb8c99f1..a2a80c3e4 100644 --- a/src/ocean/io/select/selector/model/ISelectedKeysHandler.d +++ b/src/ocean/io/select/selector/model/ISelectedKeysHandler.d @@ -33,5 +33,5 @@ interface ISelectedKeysHandler ***************************************************************************/ void opCall ( epoll_event_t[] selected_set, - bool delegate (Exception) unhandled_exception_hook ); + scope bool delegate (Exception) unhandled_exception_hook ); } diff --git a/src/ocean/io/serialize/StringStructSerializer.d b/src/ocean/io/serialize/StringStructSerializer.d index 69ae64001..47e4ed9d9 100644 --- a/src/ocean/io/serialize/StringStructSerializer.d +++ b/src/ocean/io/serialize/StringStructSerializer.d @@ -116,7 +116,7 @@ public class StringStructSerializer ( Char ) ***************************************************************************/ - private const indent_size = 3; + private static immutable indent_size = 3; /*************************************************************************** @@ -502,7 +502,7 @@ public class StringStructSerializer ( Char ) // The set of characters to use for creating cases within the following // switch block. These are just whitepace or unprintable characters but // without their preceding backslashes. - const letters = ['0', 'a', 'b', 'f', 'n', 'r', 't', 'v']; + static immutable letters = ['0', 'a', 'b', 'f', 'n', 'r', 't', 'v']; switch ( c ) { diff --git a/src/ocean/io/serialize/StructSerializer.d b/src/ocean/io/serialize/StructSerializer.d index 67171322f..ac7386e78 100644 --- a/src/ocean/io/serialize/StructSerializer.d +++ b/src/ocean/io/serialize/StructSerializer.d @@ -134,7 +134,7 @@ struct StructSerializer ( bool AllowUnions = false ) ***************************************************************************/ - size_t dump ( S ) ( S* s, void delegate ( void[] data ) receive ) + size_t dump ( S ) ( S* s, scope void delegate ( void[] data ) receive ) { enforceStructPtr!("dump")(s); return transmit!(false)(s, receive); @@ -177,7 +177,7 @@ struct StructSerializer ( bool AllowUnions = false ) ***************************************************************************/ - size_t load ( S ) ( S* s, void delegate ( void[] data ) receive ) + size_t load ( S ) ( S* s, scope void delegate ( void[] data ) receive ) { enforceStructPtr!("load")(s); return transmit!(true)(s, receive); @@ -205,10 +205,10 @@ struct StructSerializer ( bool AllowUnions = false ) ***************************************************************************/ - size_t transmit ( bool receive, S ) ( S* s, void delegate ( void[] data ) transmit_data ) + size_t transmit ( bool receive, S ) ( S* s, scope void delegate ( void[] data ) transmit_data ) { .serializer_exception.enforce(s !is null, - typeof (*this).stringof ~ ".transmit (receive = " ~ + typeof (*(&this)).stringof ~ ".transmit (receive = " ~ receive.stringof ~ "): source pointer of type '" ~ S.stringof ~ "*' is null"); @@ -416,7 +416,7 @@ struct StructSerializer ( bool AllowUnions = false ) ***************************************************************************/ - size_t transmitArrays ( bool receive, S ) ( S* s, void delegate ( void[] array ) transmit ) + size_t transmitArrays ( bool receive, S ) ( S* s, scope void delegate ( void[] array ) transmit ) { size_t bytes = 0; @@ -460,7 +460,7 @@ struct StructSerializer ( bool AllowUnions = false ) ***************************************************************************/ - size_t transmitArray ( bool receive, T ) ( ref T[] array, void delegate ( void[] data ) transmit_dg ) + size_t transmitArray ( bool receive, T ) ( ref T[] array, scope void delegate ( void[] data ) transmit_dg ) { size_t len, bytes = len.sizeof; @@ -479,11 +479,11 @@ struct StructSerializer ( bool AllowUnions = false ) static if (is (T == struct)) // recurse into substruct { // if it contains dynamic - const RecurseIntoStruct = hasIndirections!(typeof (T.tupleof));// arrays + enum RecurseIntoStruct = hasIndirections!(typeof (T.tupleof));// arrays } else { - const RecurseIntoStruct = false; + enum RecurseIntoStruct = false; } static if (is (T U == U[])) // recurse into subarray @@ -496,7 +496,7 @@ struct StructSerializer ( bool AllowUnions = false ) else static if (RecurseIntoStruct) { debug ( StructSerializer ) - pragma (msg, typeof (*this).stringof ~ ".transmitArray: " + pragma (msg, typeof (*(&this)).stringof ~ ".transmitArray: " ~ "array elements of struct type '" ~ T.stringof ~ ~ "' contain subarrays"); @@ -538,7 +538,7 @@ struct StructSerializer ( bool AllowUnions = false ) foreach (i, ref field; s.tupleof) { alias typeof(field) T; - const field_name = fieldIdentifier!(S, i); + enum field_name = fieldIdentifier!(S, i); // imitate D1 style formatting for D2 typedef struct static if ( is(T == struct) && !isTypedef!(T) ) @@ -731,12 +731,12 @@ struct StructSerializer ( bool AllowUnions = false ) { static if (is (S T == T*)) { - pragma (msg, typeof (*this).stringof ~ '.' ~ func ~ " - warning: " + pragma (msg, typeof (*(&this)).stringof ~ '.' ~ func ~ " - warning: " ~ "passing struct pointer argument of type '" ~ (S*).stringof ~ ~ "' (you probably want '" ~ (T*).stringof ~ "')"); } - .serializer_exception.enforce(s, typeof (*this).stringof ~ '.' ~ func ~ ": " + .serializer_exception.enforce(s, typeof (*(&this)).stringof ~ '.' ~ func ~ ": " ~ "pointer of type '" ~ S.stringof ~ "*' is null"); } @@ -757,12 +757,12 @@ struct StructSerializer ( bool AllowUnions = false ) template AssertSupportedType ( T, S, size_t i ) { static assert (AllowUnions || !is (T == union), - typeof (*this).stringof ~ ": unions are not supported, sorry " + typeof (*(&this)).stringof ~ ": unions are not supported, sorry " ~ "(affects " ~ FieldInfo!(T, S, i) ~ ") -- use AllowUnions " ~ "template flag to enable shallow serialization of unions"); static if (isArrayType!(T) == ArrayKind.Associative) - pragma (msg, typeof (*this).stringof ~ + pragma (msg, typeof (*(&this)).stringof ~ ~ " - Warning: content of associative array will be discarded " ~ "(affects " ~ FieldInfo!(T, S, i) ~ ')'); } @@ -786,13 +786,13 @@ struct StructSerializer ( bool AllowUnions = false ) { static if (is (U V == V[])) { - static assert (!isReferenceType!(V), typeof (*this).stringof + static assert (!isReferenceType!(V), typeof (*(&this)).stringof ~ ": arrays of reference types are not supported, " ~ "sorry (affects " ~ FieldInfo!(T, S, i) ~ ')'); } else { - static assert (!isReferenceType!(U), typeof (*this).stringof + static assert (!isReferenceType!(U), typeof (*(&this)).stringof ~ ": arrays of reference types are not supported, " ~ "sorry (affects " ~ FieldInfo!(T, S, i) ~ ')'); } @@ -806,7 +806,7 @@ struct StructSerializer ( bool AllowUnions = false ) template FieldInfo ( T, S, size_t i ) { - const FieldInfo = '\'' ~ S.tupleof[i].stringof ~ "' of type '" ~ T.stringof ~ '\''; + enum FieldInfo = '\'' ~ S.tupleof[i].stringof ~ "' of type '" ~ T.stringof ~ '\''; } } @@ -970,29 +970,29 @@ version (UnitTest) void push (T element) { - if (this.elements.length == this.write) + if ((&this).elements.length == (&this).write) { - if (this.elements.length < this.maxLength) + if ((&this).elements.length < (&this).maxLength) { - this.elements.length = this.elements.length + 1; + (&this).elements.length = (&this).elements.length + 1; } else { - this.write = 0; + (&this).write = 0; } } static if (isArrayType!(T)) { - this.elements[this.write].length = element.length; - this.elements[this.write][] = element[]; + (&this).elements[(&this).write].length = element.length; + (&this).elements[(&this).write][] = element[]; } else { - this.elements[this.write] = element; + (&this).elements[(&this).write] = element; } - ++this.write; + ++(&this).write; } /*********************************************************************** @@ -1008,14 +1008,14 @@ version (UnitTest) T* get (size_t offset=0) { - if (offset < this.elements.length) + if (offset < (&this).elements.length) { - if (cast(int)(this.write - 1 - offset) < 0) + if (cast(int)((&this).write - 1 - offset) < 0) { - return &elements[$ - offset + this.write - 1]; + return &elements[$ - offset + (&this).write - 1]; } - return &elements[this.write - 1 - offset]; + return &elements[(&this).write - 1 - offset]; } throw new Exception("Element does not exist"); diff --git a/src/ocean/io/serialize/TypeId.d b/src/ocean/io/serialize/TypeId.d index f43ae9852..d73c03779 100644 --- a/src/ocean/io/serialize/TypeId.d +++ b/src/ocean/io/serialize/TypeId.d @@ -55,7 +55,7 @@ unittest T*[float function(Spam, T.Eggs)] a; // at offset 104 } - const id = TypeId!(S); + static immutable id = TypeId!(S); static assert(id == `struct{` ~ `0LU` ~ `uint` ~ @@ -76,7 +76,7 @@ unittest `}*[floatfunction(intushort)]` ~ `}`); - const hash = TypeHash!(S); + static immutable hash = TypeHash!(S); static assert(hash == 0x3ff282c0d315761b); } @@ -93,48 +93,48 @@ template TypeId ( T ) { static if (is (T == struct) && !isTypedef!(T)) { - const TypeId = "struct{" ~ AggregateId!(CheckedBaseType!(T)) ~ "}"; + static immutable TypeId = "struct{" ~ AggregateId!(CheckedBaseType!(T)) ~ "}"; } else static if (is (T == union)) { - const TypeId = "union{" ~ AggregateId!(CheckedBaseType!(T)) ~ "}"; + static immutable TypeId = "union{" ~ AggregateId!(CheckedBaseType!(T)) ~ "}"; } else static if (is (T Base : Base[])) { static if (is (T == Base[])) { - const TypeId = TypeId!(Base) ~ "[]"; + static immutable TypeId = TypeId!(Base) ~ "[]"; } else { - const TypeId = TypeId!(Base) ~ "[" ~ T.length.stringof ~ "]"; + static immutable TypeId = TypeId!(Base) ~ "[" ~ T.length.stringof ~ "]"; } } else static if (is (T Base == Base*)) { static if (is (Base Args == function) && is (Base R == return)) { - const TypeId = TypeId!(R) ~ "function(" ~ TupleId!(Args) ~ ")"; + static immutable TypeId = TypeId!(R) ~ "function(" ~ TupleId!(Args) ~ ")"; } else { - const TypeId = TypeId!(Base) ~ "*"; + static immutable TypeId = TypeId!(Base) ~ "*"; } } else static if (is (T Func == delegate) && is (Func Args == function) && is (Func R == return)) { - const TypeId = TypeId!(R) ~ "delegate(" ~ TupleId!(Args) ~ ")"; + static immutable TypeId = TypeId!(R) ~ "delegate(" ~ TupleId!(Args) ~ ")"; } else static if (is (typeof (T.init.values[0]) V) && is (typeof (T.init.keys[0]) K) && is (V[K] == T)) { - const TypeId = TypeId!(V) ~ "[" ~ TypeId!(K) ~ "]"; + static immutable TypeId = TypeId!(V) ~ "[" ~ TypeId!(K) ~ "]"; } else { - const TypeId = CheckedBaseType!(T).stringof; + static immutable TypeId = CheckedBaseType!(T).stringof; } } @@ -149,8 +149,8 @@ unittest } - const x = TypeId!(Sample); - const ExpectedSampleStr = `struct{0LUint[4LU]16LUint24LUdouble32LUchar*}`; + static immutable x = TypeId!(Sample); + static immutable ExpectedSampleStr = `struct{0LUint[4LU]16LUint24LUdouble32LUchar*}`; static assert(x == ExpectedSampleStr); // This looks like a bug @@ -182,7 +182,7 @@ unittest template TypeHash ( T ) { - const TypeHash = TypeHash!(Fnv164Const.INIT, T); + static immutable TypeHash = TypeHash!(Fnv164Const.INIT, T); } unittest @@ -195,8 +195,8 @@ unittest char* c; } - const hash = TypeHash!(Sample); - const ExpectedSampleHash = 0x25E3D303374B7838; + static immutable hash = TypeHash!(Sample); + static immutable ExpectedSampleHash = 0x25E3D303374B7838; static assert(hash == ExpectedSampleHash); // This looks like a bug @@ -232,48 +232,48 @@ template TypeHash ( ulong hash, T ) { static if (is (T == struct) && !isTypedef!(T)) { - const TypeHash = StaticFnv1a64!(AggregateHash!(StaticFnv1a64!(hash, "struct{"), CheckedBaseType!(T)), "}"); + static immutable TypeHash = StaticFnv1a64!(AggregateHash!(StaticFnv1a64!(hash, "struct{"), CheckedBaseType!(T)), "}"); } else static if (is (T == union)) { - const TypeHash = StaticFnv1a64!(AggregateHash!(StaticFnv1a64!(hash, "union{"), CheckedBaseType!(T)), "}"); + static immutable TypeHash = StaticFnv1a64!(AggregateHash!(StaticFnv1a64!(hash, "union{"), CheckedBaseType!(T)), "}"); } else static if (is (T Base : Base[])) { static if (is (T == Base[])) { - const TypeHash = StaticFnv1a64!(TypeHash!(hash, Base), "[]"); + static immutable TypeHash = StaticFnv1a64!(TypeHash!(hash, Base), "[]"); } else { - const TypeHash = StaticFnv1a64!(TypeHash!(hash, Base), "[" ~ T.length.stringof ~ "]"); + static immutable TypeHash = StaticFnv1a64!(TypeHash!(hash, Base), "[" ~ T.length.stringof ~ "]"); } } else static if (is (T Base == Base*)) { static if (is (Base Args == function) && is (Base R == return)) { - const TypeHash = StaticFnv1a64!(TupleHash!(StaticFnv1a64!(TypeHash!(hash, R), "function("), Args), ")"); + static immutable TypeHash = StaticFnv1a64!(TupleHash!(StaticFnv1a64!(TypeHash!(hash, R), "function("), Args), ")"); } else { - const TypeHash = StaticFnv1a64!(TypeHash!(Base), "*"); + static immutable TypeHash = StaticFnv1a64!(TypeHash!(Base), "*"); } } else static if (is (T Func == delegate) && is (Func Args == function) && is (Func R == return)) { - const TypeHash = StaticFnv1a64!(TupleHash!(StaticFnv1a64!(TypeHash!(hash, R), "delegate("), Args), ")"); + static immutable TypeHash = StaticFnv1a64!(TupleHash!(StaticFnv1a64!(TypeHash!(hash, R), "delegate("), Args), ")"); } else static if (is (typeof (T.init.values[0]) V) && is (typeof (T.init.keys[0]) K) && is (V[K] == T)) { - const TypeHash = StaticFnv1a64!(TypeHash!(StaticFnv1a64!(TypeHash!(hash, V), "["), K), "]"); + static immutable TypeHash = StaticFnv1a64!(TypeHash!(StaticFnv1a64!(TypeHash!(hash, V), "["), K), "]"); } else { - const TypeHash = StaticFnv1a64!(hash, CheckedBaseType!(T).stringof); + static immutable TypeHash = StaticFnv1a64!(hash, CheckedBaseType!(T).stringof); } } @@ -288,11 +288,11 @@ template AggregateId ( T, size_t n = 0 ) { static if (n < T.tupleof.length) { - const AggregateId = T.tupleof[n].offsetof.stringof ~ TypeId!(typeof (T.tupleof[n])) ~ AggregateId!(T, n + 1); + static immutable AggregateId = T.tupleof[n].offsetof.stringof ~ TypeId!(typeof (T.tupleof[n])) ~ AggregateId!(T, n + 1); } else { - const AggregateId = ""; + static immutable AggregateId = ""; } } @@ -306,11 +306,11 @@ template TupleId ( T ... ) { static if (T.length) { - const TupleId = TypeId!(T[0]) ~ TupleId!(T[1 .. $]); + static immutable TupleId = TypeId!(T[0]) ~ TupleId!(T[1 .. $]); } else { - const TupleId = ""; + static immutable TupleId = ""; } } @@ -326,11 +326,11 @@ template AggregateHash ( ulong hash, T, size_t n = 0 ) { static if (n < T.tupleof.length) { - const AggregateHash = AggregateHash!(TypeHash!(StaticFnv1a64!(hash, T.tupleof[n].offsetof.stringof), typeof (T.tupleof[n])), T, n + 1); + static immutable AggregateHash = AggregateHash!(TypeHash!(StaticFnv1a64!(hash, T.tupleof[n].offsetof.stringof), typeof (T.tupleof[n])), T, n + 1); } else { - const AggregateHash = hash; + static immutable AggregateHash = hash; } } @@ -345,11 +345,11 @@ template TupleHash ( ulong hash, T ... ) { static if (T.length) { - const TupleHash = TupleHash!(TypeHash!(hash, T[0]), T[1 .. $]); + static immutable TupleHash = TupleHash!(TypeHash!(hash, T[0]), T[1 .. $]); } else { - const TupleHash = hash; + static immutable TupleHash = hash; } } @@ -401,10 +401,10 @@ template TypeErrorMsg ( T, Base ) { static if (is (T == Base)) { - const TypeErrorMsg = Base.stringof ~ " is not supported because it is a class or interface"; + static immutable TypeErrorMsg = Base.stringof ~ " is not supported because it is a class or interface"; } else { - const TypeErrorMsg = T.stringof ~ " is a typedef of " ~ Base.stringof ~ " which is not supported because it is a class or interface"; + static immutable TypeErrorMsg = T.stringof ~ " is a typedef of " ~ Base.stringof ~ " which is not supported because it is a class or interface"; } } diff --git a/src/ocean/io/stream/Buffered.d b/src/ocean/io/stream/Buffered.d index 93f672274..94d7f6e58 100644 --- a/src/ocean/io/stream/Buffered.d +++ b/src/ocean/io/stream/Buffered.d @@ -266,7 +266,7 @@ public class BufferedInput : InputFilter, InputBuffer ***************************************************************************/ - public final size_t reader (size_t delegate (Const!(void)[]) dg) + public final size_t reader (scope size_t delegate (Const!(void)[]) dg) { auto count = dg(this.data[this.index .. this.extent]); @@ -297,7 +297,7 @@ public class BufferedInput : InputFilter, InputBuffer ***************************************************************************/ - public size_t writer (size_t delegate (void[]) dg) + public size_t writer (scope size_t delegate (void[]) dg) { auto count = dg(this.data[this.extent .. $]); @@ -481,7 +481,7 @@ public class BufferedInput : InputFilter, InputBuffer ***************************************************************************/ - public final bool next (size_t delegate (Const!(void)[]) scan) + public final bool next (scope size_t delegate (Const!(void)[]) scan) { while (this.reader(scan) is Eof) { @@ -849,7 +849,7 @@ public class BufferedOutput : OutputFilter, OutputBuffer ***************************************************************************/ - public this (OutputStream stream, void delegate() flush_notifier = null) + public this (OutputStream stream, scope void delegate() flush_notifier = null) { verify(stream !is null); this(stream, stream.conduit.bufferSize, flush_notifier); @@ -868,7 +868,7 @@ public class BufferedOutput : OutputFilter, OutputBuffer ***************************************************************************/ public this (OutputStream stream, size_t capacity, - void delegate() flush_notifier = null) + scope void delegate() flush_notifier = null) { this.set(new ubyte[capacity], 0); this.flush_notifier = flush_notifier; @@ -1260,7 +1260,7 @@ public class BufferedOutput : OutputFilter, OutputBuffer ***************************************************************************/ - final size_t writer (size_t delegate (void[]) dg) + final size_t writer (scope size_t delegate (void[]) dg) { auto count = dg (this.data[this.extent..this.dimension]); @@ -1291,7 +1291,7 @@ public class BufferedOutput : OutputFilter, OutputBuffer ***************************************************************************/ - private final size_t reader (size_t delegate (Const!(void)[]) dg) + private final size_t reader (scope size_t delegate (Const!(void)[]) dg) { auto count = dg (this.data[this.index..this.extent]); diff --git a/src/ocean/io/stream/Format.d b/src/ocean/io/stream/Format.d index bf13b5d4b..5f5f792fd 100644 --- a/src/ocean/io/stream/Format.d +++ b/src/ocean/io/stream/Format.d @@ -74,7 +74,7 @@ class FormatOutput : OutputFilter public alias newline nl; /// nl -> newline - protected const Eol = "\n"; + protected static immutable Eol = "\n"; /********************************************************************** diff --git a/src/ocean/io/stream/Iterator.d b/src/ocean/io/stream/Iterator.d index f5171791d..62597495c 100644 --- a/src/ocean/io/stream/Iterator.d +++ b/src/ocean/io/stream/Iterator.d @@ -118,7 +118,7 @@ class Iterator : InputFilter **********************************************************************/ - int opApply (int delegate(ref cstring) dg) + int opApply (scope int delegate(ref cstring) dg) { bool more; int result; @@ -137,7 +137,7 @@ class Iterator : InputFilter **********************************************************************/ - int opApply (int delegate(ref int, ref cstring) dg) + int opApply (scope int delegate(ref int, ref cstring) dg) { bool more; int result, @@ -158,7 +158,7 @@ class Iterator : InputFilter **********************************************************************/ - int opApply (int delegate(ref int, ref cstring, ref cstring) dg) + int opApply (scope int delegate(ref int, ref cstring, ref cstring) dg) { bool more; int result, diff --git a/src/ocean/io/stream/Zlib_internal.d b/src/ocean/io/stream/Zlib_internal.d index e0ae33b2f..1bdd07586 100644 --- a/src/ocean/io/stream/Zlib_internal.d +++ b/src/ocean/io/stream/Zlib_internal.d @@ -897,7 +897,7 @@ unittest { // One ring to rule them all, one ring to find them, // One ring to bring them all and in the darkness bind them. - const istring message = + static immutable istring message = "Ash nazg durbatulûk, ash nazg gimbatul, " ~ "ash nazg thrakatulûk, agh burzum-ishi krimpatul."; @@ -906,7 +906,7 @@ unittest // This compressed data was created using Python 2.5's built in zlib // module, with the default compression level. { - const ubyte[] message_z = [ + static immutable ubyte[] message_z = [ 0x78,0x9c,0x73,0x2c,0xce,0x50,0xc8,0x4b, 0xac,0x4a,0x57,0x48,0x29,0x2d,0x4a,0x4a, 0x2c,0x29,0xcd,0x39,0xbc,0x3b,0x5b,0x47, @@ -947,7 +947,7 @@ unittest // This compressed data was created using the Cygwin gzip program // with default options. The original file was called "testdata.txt". { - const ubyte[] message_gz = [ + static immutable ubyte[] message_gz = [ 0x1f,0x8b,0x08,0x00,0x80,0x70,0x6f,0x45, 0x00,0x03,0x73,0x2c,0xce,0x50,0xc8,0x4b, 0xac,0x4a,0x57,0x48,0x29,0x2d,0x4a,0x4a, diff --git a/src/ocean/io/vfs/FileFolder.d b/src/ocean/io/vfs/FileFolder.d index 57a5f4be5..4617ccb16 100644 --- a/src/ocean/io/vfs/FileFolder.d +++ b/src/ocean/io/vfs/FileFolder.d @@ -209,7 +209,7 @@ class FileFolder : VfsFolder ***********************************************************************/ - final int opApply (int delegate(ref VfsFolder) dg) + final int opApply (scope int delegate(ref VfsFolder) dg) { int result; @@ -269,7 +269,7 @@ class FileFolder : VfsFolder ***********************************************************************/ - private char[][] files (ref VfsStats stats, VfsFilter filter = null) + private char[][] files (ref VfsStats stats, scope VfsFilter filter = null) { char[][] files; @@ -336,7 +336,7 @@ class FileGroup : VfsFiles ***********************************************************************/ - this (FolderGroup host, VfsFilter filter) + this (FolderGroup host, scope VfsFilter filter) { foreach (folder; host.members) { @@ -355,7 +355,7 @@ class FileGroup : VfsFiles ***********************************************************************/ - final int opApply (int delegate(ref VfsFile) dg) + final int opApply (scope int delegate(ref VfsFile) dg) { int result; auto host = new FileHost; @@ -433,7 +433,7 @@ private class FolderGroup : VfsFolders ***********************************************************************/ - final int opApply (int delegate(ref VfsFolder) dg) + final int opApply (scope int delegate(ref VfsFolder) dg) { int result; @@ -538,7 +538,7 @@ private class FolderGroup : VfsFolders ***********************************************************************/ - final FileGroup catalog (VfsFilter filter = null) + final FileGroup catalog (scope VfsFilter filter = null) { return new FileGroup (this, filter); } diff --git a/src/ocean/io/vfs/VirtualFolder.d b/src/ocean/io/vfs/VirtualFolder.d index c30d5dfb3..c31a34871 100644 --- a/src/ocean/io/vfs/VirtualFolder.d +++ b/src/ocean/io/vfs/VirtualFolder.d @@ -208,7 +208,7 @@ class VirtualFolder : VfsHost ***********************************************************************/ - final int opApply (int delegate(ref VfsFolder) dg) + final int opApply (scope int delegate(ref VfsFolder) dg) { int result; @@ -414,7 +414,7 @@ private class VirtualFolders : VfsFolders ***********************************************************************/ - final int opApply (int delegate(ref VfsFolder) dg) + final int opApply (scope int delegate(ref VfsFolder) dg) { int ret; @@ -516,7 +516,7 @@ private class VirtualFolders : VfsFolders ***********************************************************************/ - final VfsFiles catalog (VfsFilter filter = null) + final VfsFiles catalog (scope VfsFilter filter = null) { return new VirtualFiles (this, filter); } @@ -539,7 +539,7 @@ private class VirtualFiles : VfsFiles ***********************************************************************/ - private this (VirtualFolders host, VfsFilter filter) + private this (VirtualFolders host, scope VfsFilter filter) { foreach (group; host.members) members ~= group.catalog (filter); @@ -551,7 +551,7 @@ private class VirtualFiles : VfsFiles ***********************************************************************/ - final int opApply (int delegate(ref VfsFile) dg) + final int opApply (scope int delegate(ref VfsFile) dg) { int ret; diff --git a/src/ocean/io/vfs/model/Vfs.d b/src/ocean/io/vfs/model/Vfs.d index f07c2d540..a79ab39a8 100644 --- a/src/ocean/io/vfs/model/Vfs.d +++ b/src/ocean/io/vfs/model/Vfs.d @@ -259,7 +259,7 @@ interface VfsFolder ***********************************************************************/ - int opApply (int delegate(ref VfsFolder) dg); + int opApply (scope int delegate(ref VfsFolder) dg); /*********************************************************************** @@ -318,7 +318,7 @@ interface VfsFolders ***********************************************************************/ - int opApply (int delegate(ref VfsFolder) dg); + int opApply (scope int delegate(ref VfsFolder) dg); /*********************************************************************** @@ -374,7 +374,7 @@ interface VfsFolders ***********************************************************************/ - VfsFiles catalog (VfsFilter filter = null); + VfsFiles catalog (scope VfsFilter filter = null); } @@ -392,7 +392,7 @@ interface VfsFiles ***********************************************************************/ - int opApply (int delegate(ref VfsFile) dg); + int opApply (scope int delegate(ref VfsFile) dg); /*********************************************************************** diff --git a/src/ocean/math/Bessel.d b/src/ocean/math/Bessel.d index 6d8c388d7..6eae6361a 100644 --- a/src/ocean/math/Bessel.d +++ b/src/ocean/math/Bessel.d @@ -27,12 +27,12 @@ private { // Rational polynomial approximations to j0, y0, j1, y1. // sqrt(j0^2(1/x^2) + y0^2(1/x^2)) = z P(z**2)/Q(z**2), z(x) = 1/sqrt(x) // Peak error = 1.80e-20 -const real[] j0modulusn = [ 0x1.154700ea96e79656p-7, 0x1.72244b6e998cd6fp-4, +static immutable real[] j0modulusn = [ 0x1.154700ea96e79656p-7, 0x1.72244b6e998cd6fp-4, 0x1.6ebccf42e9c19fd2p-1, 0x1.6bd844e89cbd639ap+1, 0x1.e812b377c75ebc96p+2, 0x1.46d69ca24ce76686p+3, 0x1.b756f7234cc67146p+2, 0x1.943a7471eaa50ab2p-2 ]; -const real[] j0modulusd = [ 0x1.5b84007c37011506p-7, 0x1.cfe76758639bdab4p-4, +static immutable real[] j0modulusd = [ 0x1.5b84007c37011506p-7, 0x1.cfe76758639bdab4p-4, 0x1.cbfa09bf71bafc7ep-1, 0x1.c8eafb3836f2eeb4p+1, 0x1.339db78060eb706ep+3, 0x1.a06530916be8bc7ap+3, 0x1.23bfe7f67a54893p+3, 1.0 ]; @@ -40,12 +40,12 @@ const real[] j0modulusd = [ 0x1.5b84007c37011506p-7, 0x1.cfe76758639bdab4p-4, // atan(y0(x)/j0(x)) = x - pi/4 + x P(x**2)/Q(x**2) // Peak error = 2.80e-21. Relative error spread = 5.5e-1 -const real[] j0phasen = [ -0x1.ccbaf3865bb0985ep-22, -0x1.3a6b175e64bdb82ep-14, +static immutable real[] j0phasen = [ -0x1.ccbaf3865bb0985ep-22, -0x1.3a6b175e64bdb82ep-14, -0x1.06124b5310cdca28p-8, -0x1.3cebb7ab09cf1b14p-4, -0x1.00156ed209b43c6p-1, -0x1.78aa9ba4254ca20cp-1 ]; -const real[] j0phased = [ 0x1.ccbaf3865bb09918p-19, 0x1.3b5b0e12900d58b8p-11, +static immutable real[] j0phased = [ 0x1.ccbaf3865bb09918p-19, 0x1.3b5b0e12900d58b8p-11, 0x1.0897373ff9906f7ep-5, 0x1.450a5b8c552ade4ap-1, 0x1.123e263e7f0e96d2p+2, 0x1.d82ecca5654be7d2p+2, 1.0 ]; @@ -53,13 +53,13 @@ const real[] j0phased = [ 0x1.ccbaf3865bb09918p-19, 0x1.3b5b0e12900d58b8p-11, // j1(x) = (x^2-r0^2)(x^2-r1^2)(x^2-r2^2) x P(x**2)/Q(x**2), 0 <= x <= 9 // Peak error = 2e-21 -const real[] j1n = [ -0x1.2f494fa4e623b1bp+58, 0x1.8289f0a5f1e1a784p+52, +static immutable real[] j1n = [ -0x1.2f494fa4e623b1bp+58, 0x1.8289f0a5f1e1a784p+52, -0x1.9d773ee29a52c6d8p+45, 0x1.e9394ff57a46071cp+37, -0x1.616c7939904a359p+29, 0x1.424414b9ee5671eap+20, -0x1.6db34a9892d653e6p+10, 0x1.dcd7412d90a0db86p-1, -0x1.1444a1643199ee5ep-12 ]; -const real[] j1d = [ 0x1.5a1e0a45eb67bacep+75, 0x1.35ee485d62f0ccbap+68, +static immutable real[] j1d = [ 0x1.5a1e0a45eb67bacep+75, 0x1.35ee485d62f0ccbap+68, 0x1.11ee7aad4e4bcd8p+60, 0x1.3adde5dead800244p+51, 0x1.041c413dfbab693p+42, 0x1.4066d12193fcc082p+32, 0x1.24309d0dc2c4d42ep+22, 0x1.7115bea028dd75f2p+11, 1.0 @@ -67,12 +67,12 @@ const real[] j1d = [ 0x1.5a1e0a45eb67bacep+75, 0x1.35ee485d62f0ccbap+68, // sqrt(j1^2(1/x^2) + y1^2(1/x^2)) = z P(z**2)/Q(z**2), z(x) = 1/sqrt(x) // Peak error = 1.35e=20, Relative error spread = 9.9e0 -const real [] j1modulusn = [ 0x1.059262020bf7520ap-6, 0x1.012ffc4d1f5cdbc8p-3, +static immutable real [] j1modulusn = [ 0x1.059262020bf7520ap-6, 0x1.012ffc4d1f5cdbc8p-3, 0x1.03c17ce18cae596p+0, 0x1.6e0414a7114ae3ccp+1, 0x1.cb047410d229cbc4p+2, 0x1.4385d04bb718faaap+1, 0x1.914074c30c746222p-2, -0x1.42abe77f6b307aa6p+2 ]; -const real [] j1modulusd = [ 0x1.47d4e6ad98d8246ep-6, 0x1.42562f48058ff904p-3, +static immutable real [] j1modulusd = [ 0x1.47d4e6ad98d8246ep-6, 0x1.42562f48058ff904p-3, 0x1.44985e2af35c6f9cp+0, 0x1.c6f4a03469c4ef6cp+1, 0x1.1829a060e8d604cp+3, 0x1.44111c892f9cc84p+1, -0x1.d7c36d7f1e5aef6ap-1, -0x1.8eeafb1ac81c4c06p+2, 1.0 @@ -80,12 +80,12 @@ const real [] j1modulusd = [ 0x1.47d4e6ad98d8246ep-6, 0x1.42562f48058ff904p-3, // atan(y1(x)/j1(x)) = x - 3pi/4 + z P(z**2)/Q(z**2), z(x) = 1/x // Peak error = 4.83e-21. Relative error spread = 1.9e0 -const real [] j1phasen = [ 0x1.ca9f612d83aaa818p-20, 0x1.2e82fcfb7d0fee9ep-12, +static immutable real [] j1phasen = [ 0x1.ca9f612d83aaa818p-20, 0x1.2e82fcfb7d0fee9ep-12, 0x1.e28858c1e947506p-7, 0x1.12b8f96e5173d20ep-2, 0x1.965e6a013154c0ap+0, 0x1.0156a25eaa0dd78p+1 ]; -const real [] j1phased = [ 0x1.31bf961e57c71ae4p-18, 0x1.9464d8f2abf750a6p-11, +static immutable real [] j1phased = [ 0x1.31bf961e57c71ae4p-18, 0x1.9464d8f2abf750a6p-11, 0x1.446a786bac2131fp-5, 0x1.76caa8513919873cp-1, 0x1.2130b56bc1a563e4p+2, 0x1.b3cc1a865259dfc6p+2, 0x1p+0 ]; @@ -112,12 +112,12 @@ real cylBessel_j0(real x) // j0(x) = (x^2-JZ1)(x^2-JZ2)(x^2-JZ3)P(x**2)/Q(x**2), 0 <= x <= 9 // Peak error = 8.49e-22. Relative error spread = 2.2e-3 -const real[] j0n = [ -0x1.3e8ff72b890d72d8p+59, 0x1.cc86e3755a4c803p+53, +static immutable real[] j0n = [ -0x1.3e8ff72b890d72d8p+59, 0x1.cc86e3755a4c803p+53, -0x1.0ea6f5bac6623616p+47, 0x1.532c6d94d36f2874p+39, -0x1.ef25a232f6c00118p+30, 0x1.aa0690536c11fc2p+21, -0x1.94e67651cc57535p+11, 0x1.4bfe47ac8411eeb2p+0 ]; -const real[] j0d = [ 0x1.0096dec5f6560158p+73, 0x1.11705db14995fb9cp+66, +static immutable real[] j0d = [ 0x1.0096dec5f6560158p+73, 0x1.11705db14995fb9cp+66, 0x1.220a41c3daaa7a58p+58, 0x1.93c6b48d196c1082p+49, 0x1.9814684a10dbfda2p+40, 0x1.36f20ec527fccda4p+31, 0x1.634596b9247fc34p+21, 0x1.1d3eb73f90657bfcp+11, 1.0 @@ -126,7 +126,7 @@ const real[] j0d = [ 0x1.0096dec5f6560158p+73, 0x1.11705db14995fb9cp+66, xx = x * x; if ( xx < 81.0L ) { - const real [] JZ = [5.783185962946784521176L, + static immutable real [] JZ = [5.783185962946784521176L, 30.47126234366208639908L, 7.488700679069518344489e1L]; y = (xx - JZ[0]) * (xx - JZ[1]) * (xx - JZ[2]); y *= rationalPoly( xx, j0n, j0d); @@ -167,25 +167,25 @@ real cylBessel_y0(real x) // y0(x) = 2/pi * log(x) * j0(x) + P(z**2)/Q(z**2), 0 <= x <= 5 // Peak error = 8.55e-22. Relative error spread = 2.7e-1 -const real[] y0n = [ -0x1.068026b402e2bf7ap+54, 0x1.3a2f7be8c4c8a03ep+55, +static immutable real[] y0n = [ -0x1.068026b402e2bf7ap+54, 0x1.3a2f7be8c4c8a03ep+55, -0x1.89928488d6524792p+51, 0x1.3e3ea2846f756432p+46, -0x1.c8be8d9366867c78p+39, 0x1.43879530964e5fbap+32, -0x1.bee052fef72a5d8p+23, 0x1.e688c8fe417c24d8p+13 ]; -const real[] y0d = [ 0x1.bc96c5351e564834p+57, 0x1.6821ac3b4c5209a6p+51, +static immutable real[] y0d = [ 0x1.bc96c5351e564834p+57, 0x1.6821ac3b4c5209a6p+51, 0x1.27098b571836ce64p+44, 0x1.41870d2a9b90aa76p+36, 0x1.00394fd321f52f48p+28, 0x1.317ce3b16d65b27p+19, 0x1.0432b36efe4b20aep+10, 1.0 ]; // y0(x) = (x-Y0Z1)(x-Y0Z2)(x-Y0Z3)(x-Y0Z4)P(x)/Q(x), 4.5 <= x <= 9 // Peak error = 2.35e-20. Relative error spread = 7.8e-13 -const real[] y059n = [ -0x1.0fce17d26a21f218p+19, -0x1.c6fc144765fdfaa8p+16, +static immutable real[] y059n = [ -0x1.0fce17d26a21f218p+19, -0x1.c6fc144765fdfaa8p+16, 0x1.3e20237c53c7180ep+19, 0x1.7d14055ff6a493c4p+17, 0x1.b8b694729689d1f4p+12, -0x1.1e24596784b6c5cp+12, 0x1.35189cb3ece7ab46p+6, 0x1.9428b3f406b4aa08p+4, -0x1.791187b68dd4240ep+0, 0x1.8417216d568b325ep-6 ]; -const real[] y059d = [ 0x1.17af71a3d4167676p+30, 0x1.a36abbb668c79d6cp+31, +static immutable real[] y059d = [ 0x1.17af71a3d4167676p+30, 0x1.a36abbb668c79d6cp+31, -0x1.4ff64a14ed73c4d6p+29, 0x1.9d427af195244ffep+26, -0x1.4e85bbbc8d2fd914p+23, 0x1.ac59b523ae0bd16cp+19, -0x1.8ebda33eaac74518p+15, 0x1.16194a051cd55a12p+11, -0x1.f2d714ab48d1bd7ep+5, 1.0 @@ -201,7 +201,7 @@ const real[] y059d = [ 0x1.17af71a3d4167676p+30, 0x1.a36abbb668c79d6cp+31, y = M_2_PI * log(x) * cylBessel_j0(x); y += rationalPoly( xx, y0n, y0d); } else { - const real [] Y0Z = [3.957678419314857868376e0L, 7.086051060301772697624e0L, + static immutable real [] Y0Z = [3.957678419314857868376e0L, 7.086051060301772697624e0L, 1.022234504349641701900e1L, 1.336109747387276347827e1L]; y = (x - Y0Z[0])*(x - Y0Z[1])*(x - Y0Z[2])*(x - Y0Z[3]); y *= rationalPoly( x, y059n, y059d); @@ -241,7 +241,7 @@ real cylBessel_j1(real x) xx = x * x; if ( xx < 81.0L ) { - const real [] JZ = [1.46819706421238932572e1L, + static immutable real [] JZ = [1.46819706421238932572e1L, 4.92184563216946036703e1L, 1.03499453895136580332e2L]; y = (xx - JZ[0]) * (xx - JZ[1]) * (xx - JZ[2]); y *= x * poly( xx, j1n) / poly( xx, j1d); @@ -253,7 +253,7 @@ real cylBessel_j1(real x) z = 1.0/y; modulus = rationalPoly( z, j1modulusn, j1modulusd); - const real M_3PI_4 = 3 * PI_4; + static immutable real M_3PI_4 = 3 * PI_4; y = modulus * cos( y - M_3PI_4 + z*phase) / sqrt(y); if( x < 0 ) @@ -295,12 +295,12 @@ verify(x>=0.0); // y1(x) = 2/pi * (log(x) * j1(x) - 1/x) + R(x^2) z P(z**2)/Q(z**2) // 0 <= x <= 4.5, z(x) = x // Peak error = 7.25e-22. Relative error spread = 4.5e-2 -const real [] y1n = [ -0x1.32cab2601090742p+54, 0x1.432ceb7a8eaeff16p+52, +static immutable real [] y1n = [ -0x1.32cab2601090742p+54, 0x1.432ceb7a8eaeff16p+52, -0x1.bcebec5a2484d3fap+47, 0x1.cc58f3cb54d6ac66p+41, -0x1.b1255e154d0eec0ep+34, 0x1.7a337df43298a7c8p+26, -0x1.f77a1afdeff0b62cp+16 ]; -const real [] y1d = [ 0x1.8733bcfd7236e604p+56, 0x1.5af412c672fd18d4p+50, +static immutable real [] y1d = [ 0x1.8733bcfd7236e604p+56, 0x1.5af412c672fd18d4p+50, 0x1.394ba130685755ep+43, 0x1.7b3321523b24afcp+35, 0x1.52946dac22f61d0cp+27, 0x1.c9040c6053de5318p+18, 0x1.be5156e6771dba34p+9, 1.0 ]; @@ -309,13 +309,13 @@ const real [] y1d = [ 0x1.8733bcfd7236e604p+56, 0x1.5af412c672fd18d4p+50, // y1(x) = (x-YZ1)(x-YZ2)(x-YZ3)(x-YZ4)R(x) P(z)/Q(z) // z(x) = x, 4.5 <= x <= 9 // Peak error = 3.27e-22. Relative error spread = 4.5e-2 -const real[] y159n = [ 0x1.2fed87b1e60aa736p+18, -0x1.1a2b18cdb2d1ec5ep+20, +static immutable real[] y159n = [ 0x1.2fed87b1e60aa736p+18, -0x1.1a2b18cdb2d1ec5ep+20, -0x1.b848827f47b47022p+20, -0x1.b2e422305ea19a86p+20, -0x1.e3f82ac304534676p+16, 0x1.47a2cb5e852d657ep+14, 0x1.81b2fc6e44d7be8p+12, -0x1.cd861d7b090dd22ep+9, 0x1.588897d683cbfbe2p+5, -0x1.5c7feccf76856bcap-1 ]; -const real[] y159d = [ 0x1.9b64f2a4d5614462p+26, -0x1.17501e0e38db675ap+30, +static immutable real[] y159d = [ 0x1.9b64f2a4d5614462p+26, -0x1.17501e0e38db675ap+30, 0x1.fe88b567c2911c1cp+31, -0x1.86b1781e04e748d4p+29, 0x1.ccd7d4396f2edbcap+26, -0x1.694110c682e5cbcap+23, 0x1.c20f7005b88c789ep+19, -0x1.983a5b4275ab7da8p+15, 0x1.17c60380490fa1fcp+11, -0x1.ee84c254392634d8p+5, 1.0 @@ -330,7 +330,7 @@ const real[] y159d = [ 0x1.9b64f2a4d5614462p+26, -0x1.17501e0e38db675ap+30, y = M_2_PI * (log(x) * cylBessel_j1(x) - z); y += x * poly( xx, y1n) / poly( xx, y1d); } else { - const real [] Y1Z = + static immutable real [] Y1Z = [ 2.19714132603101703515e0L, 5.42968104079413513277e0L, 8.59600586833116892643e0L, 1.17491548308398812434e1L]; y = (x - Y1Z[0])*(x - Y1Z[1])*(x - Y1Z[2])*(x - Y1Z[3]); @@ -342,7 +342,7 @@ const real[] y159d = [ 0x1.9b64f2a4d5614462p+26, -0x1.17501e0e38db675ap+30, phase = rationalPoly( xx, j1phasen, j1phased); modulus = rationalPoly( z, j1modulusn, j1modulusd); - const real M_3PI_4 = 3 * PI_4; + static immutable real M_3PI_4 = 3 * PI_4; z = modulus * sin( x - M_3PI_4 + z*phase) / sqrt(x); return z; @@ -514,7 +514,7 @@ double cylBessel_i0(double x) { // Chebyshev coefficients for exp(-x) I0(x) in the interval [0,8]. // lim(x->0){ exp(-x) I0(x) } = 1. - const double [] A = [ 0x1.5a84e9035a22ap-1, -0x1.37febc057cd8dp-2, + static immutable double [] A = [ 0x1.5a84e9035a22ap-1, -0x1.37febc057cd8dp-2, 0x1.5f7ac77ac88c0p-3, -0x1.84b70342d06eap-4, 0x1.93e8acea8a32dp-5, -0x1.84e9ef121b6f0p-6, 0x1.59961f3dde3ddp-7, -0x1.1b65e201aa849p-8, 0x1.adc758a12100ep-10, -0x1.2e2fd1f15eb52p-11, 0x1.8b51b74107cabp-13, @@ -529,7 +529,7 @@ double cylBessel_i0(double x) // Chebyshev coefficients for exp(-x) sqrt(x) I0(x) // in the inverted interval [8,infinity]. // lim(x->inf){ exp(-x) sqrt(x) I0(x) } = 1/sqrt(2pi). - const double [] B = [ 0x1.9be62aca809cbp-1, 0x1.b998ca2e59049p-9, + static immutable double [] B = [ 0x1.9be62aca809cbp-1, 0x1.b998ca2e59049p-9, 0x1.20fa378999e52p-14, 0x1.8412bc101c586p-19, 0x1.b8007d9cd616ep-23, 0x1.8569280d6d56dp-26, 0x1.d2c64a9225b87p-29, 0x1.0f9ccc0f46f75p-31, 0x1.a24feabe8004fp-37, -0x1.1511d08397425p-35, -0x1.d0fd7357e7bf2p-37, @@ -564,7 +564,7 @@ double cylBessel_i0(double x) */ double cylBessel_i1(double x) { - const double [] A = [ 0x1.02a63724a7ffap-2, -0x1.694d10469192ep-3, + static immutable double [] A = [ 0x1.02a63724a7ffap-2, -0x1.694d10469192ep-3, 0x1.a46dad536f53cp-4, -0x1.b1bbc537c9ebcp-5, 0x1.951e3e7bb2349p-6, -0x1.5a29f7913a26ap-7, 0x1.1065349d3a1b4p-8, -0x1.8cc620b3cd4a4p-10, 0x1.0c95db6c6df7dp-11, -0x1.533cad3d694fep-13, 0x1.911b542c70d0bp-15, @@ -579,7 +579,7 @@ double cylBessel_i1(double x) // Chebyshev coefficients for exp(-x) sqrt(x) I1(x) // in the inverted interval [8,infinity]. // lim(x->inf){ exp(-x) sqrt(x) I1(x) } = 1/sqrt(2pi). - const double [] B = [ 0x1.8ea18b55b1514p-1, -0x1.3fda053fcdb4cp-7, + static immutable double [] B = [ 0x1.8ea18b55b1514p-1, -0x1.3fda053fcdb4cp-7, -0x1.cfd7f804aa9a6p-14, -0x1.048df49ca0373p-18, -0x1.0dbfd2e9e5443p-22, -0x1.c415394bb46c1p-26, -0x1.0790b9ad53528p-28, -0x1.334ca5423dd80p-31, -0x1.4dcf9d4504c0cp-36, 0x1.1e1a1f1587865p-35, 0x1.f101f653c457bp-37, @@ -605,7 +605,7 @@ double cylBessel_i1(double x) unittest { // argument, result1, result2, derivative. Correct result is result1+result2. -const real [4][] j0_test_points = [ +static immutable real [4][] j0_test_points = [ [8.0L, 1.71646118164062500000E-1L, 4.68897349140609086941E-6L, -2.34636346853914624381E-1L], [4.54541015625L, -3.09783935546875000000E-1L, 7.07472668157686463367E-6L, 2.42993657373627558460E-1L], [2.85711669921875L, -2.07901000976562500000E-1L, 1.15237285263902751582E-5L, -3.90402225324501311651E-1L], @@ -616,7 +616,7 @@ const real [4][] j0_test_points = [ 1.38260162356680518275E-5L, 5.76724807756873387202E-1L] ]; -const real [4][] y0_test_points = [ +static immutable real [4][] y0_test_points = [ [ 8.0L, 2.23510742187500000000E-1L, 1.07472000662205273234E-5L, 1.58060461731247494256E-1L], [4.54541015625L, -2.08114624023437500000E-1L, 1.45018823856668874574E-5L, -2.88887645307401250876E-1L], [2.85711669921875L, 4.20303344726562500000E-1L, 1.32781607563122276008E-5L, -2.82488638474982469213E-1], @@ -625,7 +625,7 @@ const real [4][] y0_test_points = [ 5.46852220461145271913E9L] ]; -const real [4][] j1_test_points = [ +static immutable real [4][] j1_test_points = [ [ 8.0L, 2.34634399414062500000E-1L, 1.94743985212438127665E-6L,1.42321263780814578043E-1], [4.54541015625L, -2.42996215820312500000E-1L, 2.55844668494153980076E-6L, -2.56317734136211337012E-1], [2.85711669921875L, 3.90396118164062500000E-1L, 6.10716043881165077013E-6L, -3.44531507106757980441E-1L], @@ -635,7 +635,7 @@ const real [4][] j1_test_points = [ [-2.0L, -5.76721191406250000000E-1L, -3.61635062338720244824E-6L, -6.44716247372010255494E-2L] ]; -const real [4][] y1_test_points = [ +static immutable real [4][] y1_test_points = [ [8.0L, -1.58065795898437500000E-1L, 5.33416719000574444473E-6L, 2.43279047103972157309E-1L], [4.54541015625L, 2.88879394531250000000E-1L, diff --git a/src/ocean/math/BinaryHistogram.d b/src/ocean/math/BinaryHistogram.d index 65cf89b59..48133952e 100644 --- a/src/ocean/math/BinaryHistogram.d +++ b/src/ocean/math/BinaryHistogram.d @@ -45,7 +45,7 @@ public struct BinaryHistogram ( uint MaxPow2, istring Suffix = "" ) /// The number of bins. (The specified number of powers of two, plus one bin /// for 0B and one for ≥1<= 1024 ) @@ -196,9 +196,9 @@ public struct BinaryHistogram ( uint MaxPow2, istring Suffix = "" ) public ulong add ( ulong n ) { - this.count++; - this.total += n; - this.bins[n? (n < (1UL << MaxPow2))? bsr(n) + 1 : $ - 1 : 0]++; + (&this).count++; + (&this).total += n; + (&this).bins[n? (n < (1UL << MaxPow2))? bsr(n) + 1 : $ - 1 : 0]++; return n; } @@ -212,9 +212,9 @@ public struct BinaryHistogram ( uint MaxPow2, istring Suffix = "" ) public double mean ( ) { - verify(this.count || !this.total); + verify((&this).count || !(&this).total); - return this.total / cast(double)this.count; + return (&this).total / cast(double)(&this).count; } /*************************************************************************** @@ -235,8 +235,8 @@ public struct BinaryHistogram ( uint MaxPow2, istring Suffix = "" ) mixin("static assert(is(typeof(Bins.init." ~ bin_name ~ ")));"); mixin("const offset = Bins.init." ~ bin_name ~ ".offsetof;"); - const index = offset / this.bins[0].sizeof; - return this.bins[index]; + enum index = offset / (&this).bins[0].sizeof; + return (&this).bins[index]; } /*************************************************************************** @@ -248,7 +248,7 @@ public struct BinaryHistogram ( uint MaxPow2, istring Suffix = "" ) public Bins stats ( ) { - return Bins.fromArray(this.bins); + return Bins.fromArray((&this).bins); } } diff --git a/src/ocean/math/Bracket.d b/src/ocean/math/Bracket.d index 19003332c..1857f8408 100644 --- a/src/ocean/math/Bracket.d +++ b/src/ocean/math/Bracket.d @@ -64,7 +64,7 @@ public: * Fortran code available from www.netlib.org as algorithm TOMS478. * */ -T findRoot(T, R)(R delegate(T) f, T ax, T bx) +T findRoot(T, R)(scope R delegate(T) f, T ax, T bx) { auto r = findRoot(f, ax, bx, f(ax), f(bx), (BracketResult!(T,R) r){ return r.xhi==nextUp(r.xlo); }); @@ -79,8 +79,8 @@ private: * tolerance Defines the termination condition. Return true when acceptable * bounds have been obtained. */ -BracketResult!(T, R) findRoot(T,R)(R delegate(T) f, T ax, T bx, R fax, R fbx, - bool delegate(BracketResult!(T,R) r) tolerance) +BracketResult!(T, R) findRoot(T,R)(scope R delegate(T) f, T ax, T bx, R fax, R fbx, + scope bool delegate(BracketResult!(T,R) r) tolerance) { verify(ax<=bx, "Parameters ax and bx out of order."); verify(!tsm.isnan(ax) && !tsm.isnan(bx), "Limits must not be NaN"); @@ -319,7 +319,7 @@ public: * func(xinitial) <= func(x1) and func(xinitial) <= func(x2) * funcMin The minimum value of func(x). */ -T findMinimum(T,R)(R delegate(T) func, T xlo, T xhi, T xinitial, +T findMinimum(T,R)(scope R delegate(T) func, T xlo, T xhi, T xinitial, out R funcMin) { verify(xlo <= xhi); @@ -328,7 +328,7 @@ T findMinimum(T,R)(R delegate(T) func, T xlo, T xhi, T xinitial, verify(func(xinitial) <= func(xlo) && func(xinitial) <= func(xhi)); // Based on the original Algol code by R.P. Brent. - const real GOLDENRATIO = 0.3819660112501051; // (3 - sqrt(5))/2 = 1 - 1/phi + static immutable real GOLDENRATIO = 0.3819660112501051; // (3 - sqrt(5))/2 = 1 - 1/phi T stepBeforeLast = 0.0; T lastStep; @@ -342,7 +342,7 @@ T findMinimum(T,R)(R delegate(T) func, T xlo, T xhi, T xinitial, for (;;) { ++numiter; T xmid = 0.5 * (xlo + xhi); - const real SQRTEPSILON = 3e-10L; // sqrt(real.epsilon) + static immutable real SQRTEPSILON = 3e-10L; // sqrt(real.epsilon) T tol1 = SQRTEPSILON * fabs(bestx); T tol2 = 2.0 * tol1; if (fabs(bestx - xmid) <= (tol2 - 0.5*(xhi - xlo)) ) { @@ -421,7 +421,7 @@ unittest { int numProblems = 0; int numCalls; - void testFindRoot(real delegate(real) f, real x1, real x2) { + void testFindRoot(scope real delegate(real) f, real x1, real x2) { numCalls=0; ++numProblems; test(!isNaN(x1) && !isNaN(x2)); diff --git a/src/ocean/math/Distribution.d b/src/ocean/math/Distribution.d index 5d2d29c16..90f4dad77 100644 --- a/src/ocean/math/Distribution.d +++ b/src/ocean/math/Distribution.d @@ -475,7 +475,7 @@ private void appendDist ( T ) ( Distribution!(T) dist, T[] values ) *******************************************************************************/ private void testForError ( bool dummy = false ) - ( void delegate ( ) dg, bool error, istring msg ) + ( scope void delegate ( ) dg, bool error, istring msg ) { bool caught = false; diff --git a/src/ocean/math/Elliptic.d b/src/ocean/math/Elliptic.d index c19976760..38a81ceb4 100644 --- a/src/ocean/math/Elliptic.d +++ b/src/ocean/math/Elliptic.d @@ -241,7 +241,7 @@ real ellipticKComplete(real x) { // verify(x>=0.0L && x<=1.0L); -const real [] P = [ +static immutable real [] P = [ 0x1.62e42fefa39ef35ap+0, // 1.3862943611198906189 0x1.8b90bfbe8ed811fcp-4, // 0.096573590279993142323 0x1.fa05af797624c586p-6, // 0.030885144578720423267 @@ -257,7 +257,7 @@ const real [] P = [ 0x1.4ee247035a03e13p-20 // 1.2475397291548388385e-06 ]; -const real [] Q = [ +static immutable real [] Q = [ 0x1p-1, // 0.5 0x1.fffffffffff635eap-4, // 0.12499999999999782631 0x1.1fffffff8a2bea1p-4, // 0.070312499993302227507 @@ -272,7 +272,7 @@ const real [] Q = [ 0x1.d321746708e92d48p-15 // 5.568631677757315399e-05 ]; - const real LOG4 = 0x1.62e42fefa39ef358p+0; // log(4) + static immutable real LOG4 = 0x1.62e42fefa39ef358p+0; // log(4) if( x > real.epsilon ) return poly(x,P) - log(x) * poly(x,Q); @@ -302,7 +302,7 @@ const real [] Q = [ real ellipticEComplete(real x) { verify(x>=0 && x<=1.0); -const real [] P = [ +static immutable real [] P = [ 0x1.c5c85fdf473f78f2p-2, // 0.44314718055994670505 0x1.d1591f9e9a66477p-5, // 0.056805192715569305834 0x1.65af6a7a61f587cp-6, // 0.021831373198011179718 @@ -317,7 +317,7 @@ const real [] P = [ 0x1.0c58aa9ab404f4fp-15 // 3.1989378120323412946e-05 ]; -const real [] Q = [ +static immutable real [] Q = [ 0x1.ffffffffffffb1cep-3, // 0.24999999999999986434 0x1.7ffffffff29eaa0cp-4, // 0.093749999999239422678 0x1.dfffffbd51eb098p-5, // 0.058593749514839092674 @@ -364,14 +364,14 @@ unittest { real ellipticPi(real phi, real m, real n) { // BUGS: This implementation suffers from poor precision. - const double [] t = [ + static immutable double [] t = [ 0.9931285991850949, 0.9639719272779138, 0.9122344282513259, 0.8391169718222188, 0.7463319064601508, 0.6360536807265150, 0.5108670019508271, 0.3737060887154195, 0.2277858511416451, 0.7652652113349734e-1 ]; - const double [] w =[ + static immutable double [] w =[ 0.1761400713915212e-1, 0.4060142980038694e-1, 0.6267204833410907e-1, 0.8327674157670475e-1, 0.1019301198172404, 0.1181945319615184, diff --git a/src/ocean/math/ErrorFunction.d b/src/ocean/math/ErrorFunction.d index 2e61ee034..4cc4bb697 100644 --- a/src/ocean/math/ErrorFunction.d +++ b/src/ocean/math/ErrorFunction.d @@ -42,21 +42,21 @@ version(UnitTest) } -const real SQRT2PI = 0x1.40d931ff62705966p+1L; // 2.5066282746310005024 -const real EXP_2 = 0.13533528323661269189L; /* exp(-2) */ +static immutable real SQRT2PI = 0x1.40d931ff62705966p+1L; // 2.5066282746310005024 +static immutable real EXP_2 = 0.13533528323661269189L; /* exp(-2) */ private { /* erfc(x) = exp(-x^2) P(1/x)/Q(1/x) 1/8 <= 1/x <= 1 Peak relative error 5.8e-21 */ -const real [] P = [ -0x1.30dfa809b3cc6676p-17, 0x1.38637cd0913c0288p+18, +static immutable real [] P = [ -0x1.30dfa809b3cc6676p-17, 0x1.38637cd0913c0288p+18, 0x1.2f015e047b4476bp+22, 0x1.24726f46aa9ab08p+25, 0x1.64b13c6395dc9c26p+27, 0x1.294c93046ad55b5p+29, 0x1.5962a82f92576dap+30, 0x1.11a709299faba04ap+31, 0x1.11028065b087be46p+31, 0x1.0d8ef40735b097ep+30 ]; -const real [] Q = [ 0x1.14d8e2a72dec49f4p+19, 0x1.0c880ff467626e1p+23, +static immutable real [] Q = [ 0x1.14d8e2a72dec49f4p+19, 0x1.0c880ff467626e1p+23, 0x1.04417ef060b58996p+26, 0x1.404e61ba86df4ebap+28, 0x1.0f81887bc82b873ap+30, 0x1.4552a5e39fb49322p+31, 0x1.11779a0ceb2a01cep+32, 0x1.3544dd691b5b1d5cp+32, 0x1.a91781f12251f02ep+31, 0x1.0d8ef3da605a1c86p+30, 1.0 @@ -66,11 +66,11 @@ const real [] Q = [ 0x1.14d8e2a72dec49f4p+19, 0x1.0c880ff467626e1p+23, /* erfc(x) = exp(-x^2) 1/x R(1/x^2) / S(1/x^2) 1/128 <= 1/x < 1/8 Peak relative error 1.9e-21 */ -const real [] R = [ 0x1.b9f6d8b78e22459ep-6, 0x1.1b84686b0a4ea43ap-1, +static immutable real [] R = [ 0x1.b9f6d8b78e22459ep-6, 0x1.1b84686b0a4ea43ap-1, 0x1.b8f6aebe96000c2ap+1, 0x1.cb1dbedac27c8ec2p+2, 0x1.cf885f8f572a4c14p+1 ]; -const real [] S = [ +static immutable real [] S = [ 0x1.87ae3cae5f65eb5ep-5, 0x1.01616f266f306d08p+0, 0x1.a4abe0411eed6c22p+2, 0x1.eac9ce3da600abaap+3, 0x1.5752a9ac2faebbccp+3, 1.0 ]; @@ -78,12 +78,12 @@ const real [] S = [ /* erf(x) = x P(x^2)/Q(x^2) 0 <= x <= 1 Peak relative error 7.6e-23 */ -const real [] T = [ 0x1.0da01654d757888cp+20, 0x1.2eb7497bc8b4f4acp+17, +static immutable real [] T = [ 0x1.0da01654d757888cp+20, 0x1.2eb7497bc8b4f4acp+17, 0x1.79078c19530f72a8p+15, 0x1.4eaf2126c0b2c23p+11, 0x1.1f2ea81c9d272a2ep+8, 0x1.59ca6e2d866e625p+2, 0x1.c188e0b67435faf4p-4 ]; -const real [] U = [ 0x1.dde6025c395ae34ep+19, 0x1.c4bc8b6235df35aap+18, +static immutable real [] U = [ 0x1.dde6025c395ae34ep+19, 0x1.c4bc8b6235df35aap+18, 0x1.8465900e88b6903ap+16, 0x1.855877093959ffdp+13, 0x1.e5c44395625ee358p+9, 0x1.6a0fed103f1c68a6p+5, 1.0 ]; @@ -209,16 +209,16 @@ real erf(real x) unittest { // High resolution test points. - const real erfc0_250 = 0.723663330078125 + 1.0279753638067014931732235184287934646022E-5; - const real erfc0_375 = 0.5958709716796875 + 1.2118885490201676174914080878232469565953E-5; - const real erfc0_500 = 0.4794921875 + 7.9346869534623172533461080354712635484242E-6; - const real erfc0_625 = 0.3767547607421875 + 4.3570693945275513594941232097252997287766E-6; - const real erfc0_750 = 0.2888336181640625 + 1.0748182422368401062165408589222625794046E-5; - const real erfc0_875 = 0.215911865234375 + 1.3073705765341685464282101150637224028267E-5; - const real erfc1_000 = 0.15728759765625 + 1.1609394035130658779364917390740703933002E-5; - const real erfc1_125 = 0.111602783203125 + 8.9850951672359304215530728365232161564636E-6; + static immutable real erfc0_250 = 0.723663330078125 + 1.0279753638067014931732235184287934646022E-5; + static immutable real erfc0_375 = 0.5958709716796875 + 1.2118885490201676174914080878232469565953E-5; + static immutable real erfc0_500 = 0.4794921875 + 7.9346869534623172533461080354712635484242E-6; + static immutable real erfc0_625 = 0.3767547607421875 + 4.3570693945275513594941232097252997287766E-6; + static immutable real erfc0_750 = 0.2888336181640625 + 1.0748182422368401062165408589222625794046E-5; + static immutable real erfc0_875 = 0.215911865234375 + 1.3073705765341685464282101150637224028267E-5; + static immutable real erfc1_000 = 0.15728759765625 + 1.1609394035130658779364917390740703933002E-5; + static immutable real erfc1_125 = 0.111602783203125 + 8.9850951672359304215530728365232161564636E-6; - const real erf0_875 = (1-0.215911865234375) - 1.3073705765341685464282101150637224028267E-5; + static immutable real erf0_875 = (1-0.215911865234375) - 1.3073705765341685464282101150637224028267E-5; test(feqrel(erfc(0.250L), erfc0_250 )>=real.mant_dig-1); @@ -265,8 +265,8 @@ real expx2(real x, int sign) Cephes Math Library Release 2.9: June, 2000 Copyright 2000 by Stephen L. Moshier */ - const real M = 32768.0; - const real MINV = 3.0517578125e-5L; + static immutable real M = 32768.0; + static immutable real MINV = 3.0517578125e-5L; x = abs(x); if (sign < 0) @@ -362,44 +362,44 @@ real normalDistributionInvImpl(real p) { verify(p>=0.0L && p<=1.0L, "Domain error"); -const real[] P0 = [ -0x1.758f4d969484bfdcp-7, 0x1.53cee17a59259dd2p-3, +static immutable real[] P0 = [ -0x1.758f4d969484bfdcp-7, 0x1.53cee17a59259dd2p-3, -0x1.ea01e4400a9427a2p-1, 0x1.61f7504a0105341ap+1, -0x1.09475a594d0399f6p+2, 0x1.7c59e7a0df99e3e2p+1, -0x1.87a81da52edcdf14p-1, 0x1.1fb149fd3f83600cp-7 ]; -const real[] Q0 = [ -0x1.64b92ae791e64bb2p-7, 0x1.7585c7d597298286p-3, +static immutable real[] Q0 = [ -0x1.64b92ae791e64bb2p-7, 0x1.7585c7d597298286p-3, -0x1.40011be4f7591ce6p+0, 0x1.1fc067d8430a425ep+2, -0x1.21008ffb1e7ccdf2p+3, 0x1.3d1581cf9bc12fccp+3, -0x1.53723a89fd8f083cp+2, 1.0 ]; -const real[] P1 = [ 0x1.20ceea49ea142f12p-13, 0x1.cbe8a7267aea80bp-7, +static immutable real[] P1 = [ 0x1.20ceea49ea142f12p-13, 0x1.cbe8a7267aea80bp-7, 0x1.79fea765aa787c48p-2, 0x1.d1f59faa1f4c4864p+1, 0x1.1c22e426a013bb96p+4, 0x1.a8675a0c51ef3202p+5, 0x1.75782c4f83614164p+6, 0x1.7a2f3d90948f1666p+6, 0x1.5cd116ee4c088c3ap+5, 0x1.1361e3eb6e3cc20ap+2 ]; -const real[] Q1 = [ 0x1.3a4ce1406cea98fap-13, 0x1.f45332623335cda2p-7, +static immutable real[] Q1 = [ 0x1.3a4ce1406cea98fap-13, 0x1.f45332623335cda2p-7, 0x1.98f28bbd4b98db1p-2, 0x1.ec3b24f9c698091cp+1, 0x1.1cc56ecda7cf58e4p+4, 0x1.92c6f7376bf8c058p+5, 0x1.4154c25aa47519b4p+6, 0x1.1b321d3b927849eap+6, 0x1.403a5f5a4ce7b202p+4, 1.0 ]; -const real[] P2 = [ 0x1.8c124a850116a6d8p-21, 0x1.534abda3c2fb90bap-13, +static immutable real[] P2 = [ 0x1.8c124a850116a6d8p-21, 0x1.534abda3c2fb90bap-13, 0x1.29a055ec93a4718cp-7, 0x1.6468e98aad6dd474p-3, 0x1.3dab2ef4c67a601cp+0, 0x1.e1fb3a1e70c67464p+1, 0x1.b6cce8035ff57b02p+2, 0x1.9f4c9e749ff35f62p+1 ]; -const real[] Q2 = [ 0x1.af03f4fc0655e006p-21, 0x1.713192048d11fb2p-13, +static immutable real[] Q2 = [ 0x1.af03f4fc0655e006p-21, 0x1.713192048d11fb2p-13, 0x1.4357e5bbf5fef536p-7, 0x1.7fdac8749985d43cp-3, 0x1.4a080c813a2d8e84p+0, 0x1.c3a4b423cdb41bdap+1, 0x1.8160694e24b5557ap+2, 1.0 ]; -const real[] P3 = [ -0x1.55da447ae3806168p-34, -0x1.145635641f8778a6p-24, +static immutable real[] P3 = [ -0x1.55da447ae3806168p-34, -0x1.145635641f8778a6p-24, -0x1.abf46d6b48040128p-17, -0x1.7da550945da790fcp-11, -0x1.aa0b2a31157775fap-8, 0x1.b11d97522eed26bcp-3, 0x1.1106d22f9ae89238p+1, 0x1.029a358e1e630f64p+1 ]; -const real[] Q3 = [ -0x1.74022dd5523e6f84p-34, -0x1.2cb60d61e29ee836p-24, +static immutable real[] Q3 = [ -0x1.74022dd5523e6f84p-34, -0x1.2cb60d61e29ee836p-24, -0x1.d19e6ec03a85e556p-17, -0x1.9ea2a7b4422f6502p-11, -0x1.c54b1e852f107162p-8, 0x1.e05268dd3c07989ep-3, 0x1.239c6aff14afbf82p+1, 1.0 ]; diff --git a/src/ocean/math/GammaFunction.d b/src/ocean/math/GammaFunction.d index b1be86394..33308ac94 100644 --- a/src/ocean/math/GammaFunction.d +++ b/src/ocean/math/GammaFunction.d @@ -36,51 +36,51 @@ version(UnitTest) import ocean.core.Test; //------------------------------------------------------------------ /// The maximum value of x for which gamma(x) < real.infinity. -const real MAXGAMMA = 1755.5483429L; +static immutable real MAXGAMMA = 1755.5483429L; private { -const real SQRT2PI = 2.50662827463100050242E0L; // sqrt(2pi) +static immutable real SQRT2PI = 2.50662827463100050242E0L; // sqrt(2pi) // Polynomial approximations for gamma and loggamma. -const real[] GammaNumeratorCoeffs = [ 1.0, +static immutable real[] GammaNumeratorCoeffs = [ 1.0, 0x1.acf42d903366539ep-1, 0x1.73a991c8475f1aeap-2, 0x1.c7e918751d6b2a92p-4, 0x1.86d162cca32cfe86p-6, 0x1.0c378e2e6eaf7cd8p-8, 0x1.dc5c66b7d05feb54p-12, 0x1.616457b47e448694p-15 ]; -const real[] GammaDenominatorCoeffs = [ 1.0, +static immutable real[] GammaDenominatorCoeffs = [ 1.0, 0x1.a8f9faae5d8fc8bp-2, -0x1.cb7895a6756eebdep-3, -0x1.7b9bab006d30652ap-5, 0x1.c671af78f312082ep-6, -0x1.a11ebbfaf96252dcp-11, -0x1.447b4d2230a77ddap-10, 0x1.ec1d45bb85e06696p-13,-0x1.d4ce24d05bd0a8e6p-17 ]; -const real[] GammaSmallCoeffs = [ 1.0, +static immutable real[] GammaSmallCoeffs = [ 1.0, 0x1.2788cfc6fb618f52p-1, -0x1.4fcf4026afa2f7ecp-1, -0x1.5815e8fa24d7e306p-5, 0x1.5512320aea2ad71ap-3, -0x1.59af0fb9d82e216p-5, -0x1.3b4b61d3bfdf244ap-7, 0x1.d9358e9d9d69fd34p-8, -0x1.38fc4bcbada775d6p-10 ]; -const real[] GammaSmallNegCoeffs = [ -1.0, +static immutable real[] GammaSmallNegCoeffs = [ -1.0, 0x1.2788cfc6fb618f54p-1, 0x1.4fcf4026afa2bc4cp-1, -0x1.5815e8fa2468fec8p-5, -0x1.5512320baedaf4b6p-3, -0x1.59af0fa283baf07ep-5, 0x1.3b4a70de31e05942p-7, 0x1.d9398be3bad13136p-8, 0x1.291b73ee05bcbba2p-10 ]; -const real[] logGammaStirlingCoeffs = [ +static immutable real[] logGammaStirlingCoeffs = [ 0x1.5555555555553f98p-4, -0x1.6c16c16c07509b1p-9, 0x1.a01a012461cbf1e4p-11, -0x1.3813089d3f9d164p-11, 0x1.b911a92555a277b8p-11, -0x1.ed0a7b4206087b22p-10, 0x1.402523859811b308p-8 ]; -const real[] logGammaNumerator = [ +static immutable real[] logGammaNumerator = [ -0x1.0edd25913aaa40a2p+23, -0x1.31c6ce2e58842d1ep+24, -0x1.f015814039477c3p+23, -0x1.74ffe40c4b184b34p+22, -0x1.0d9c6d08f9eab55p+20, -0x1.54c6b71935f1fc88p+16, -0x1.0e761b42932b2aaep+11 ]; -const real[] logGammaDenominator = [ +static immutable real[] logGammaDenominator = [ -0x1.4055572d75d08c56p+24, -0x1.deeb6013998e4d76p+24, -0x1.106f7cded5dcc79ep+24, -0x1.25e17184848c66d2p+22, -0x1.301303b99a614a0ap+19, -0x1.09e76ab41ae965p+15, -0x1.00f95ced9e5f54eep+9, 1.0 @@ -98,13 +98,13 @@ real gammaStirling(real x) { // CEPHES code Copyright 1994 by Stephen L. Moshier - const real[] SmallStirlingCoeffs = [ + static immutable real[] SmallStirlingCoeffs = [ 0x1.55555555555543aap-4, 0x1.c71c71c720dd8792p-9, -0x1.5f7268f0b5907438p-9, -0x1.e13cd410e0477de6p-13, 0x1.9b0f31643442616ep-11, 0x1.2527623a3472ae08p-14, -0x1.37f6bc8ef8b374dep-11,-0x1.8c968886052b872ap-16, 0x1.76baa9c6d3eeddbcp-11 ]; - const real[] LargeStirlingCoeffs = [ 1.0L, + static immutable real[] LargeStirlingCoeffs = [ 1.0L, 8.33333333333333333333E-2L, 3.47222222222222222222E-3L, -2.68132716049382716049E-3L, -2.29472093621399176955E-4L, 7.84039221720066627474E-4L, 6.97281375836585777429E-5L @@ -288,7 +288,7 @@ unittest { test(gamma(MAXGAMMA*2) == real.infinity); // Test some high-precision values (50 decimal digits) - const real SQRT_PI = 1.77245385090551602729816748334114518279754945612238L; + static immutable real SQRT_PI = 1.77245385090551602729816748334114518279754945612238L; version(FailsOnLinux) test(feqrel(gamma(0.5L), SQRT_PI) == real.mant_dig); @@ -387,7 +387,7 @@ real logGamma(real x) // const real MAXLGM = 1.04848146839019521116e+4928L; // if( x > MAXLGM ) return sgngaml * real.infinity; - const real LOGSQRT2PI = 0.91893853320467274178L; // log( sqrt( 2*pi ) ) + static immutable real LOGSQRT2PI = 0.91893853320467274178L; // log( sqrt( 2*pi ) ) q = ( x - 0.5L ) * log(x) - x + LOGSQRT2PI; if (x > 1.0e10L) return q; @@ -440,10 +440,10 @@ unittest { } private { - const real MAXLOG = 0x1.62e42fefa39ef358p+13L; // log(real.max) - const real MINLOG = -0x1.6436716d5406e6d8p+13L; // log(real.min*real.epsilon) = log(smallest denormal) - const real BETA_BIG = 9.223372036854775808e18L; - const real BETA_BIGINV = 1.084202172485504434007e-19L; + static immutable real MAXLOG = 0x1.62e42fefa39ef358p+13L; // log(real.max) + static immutable real MINLOG = -0x1.6436716d5406e6d8p+13L; // log(real.min*real.epsilon) = log(smallest denormal) + static immutable real BETA_BIG = 9.223372036854775808e18L; + static immutable real BETA_BIGINV = 1.084202172485504434007e-19L; } /** Beta function @@ -901,7 +901,7 @@ real betaDistExpansion1(real a, real b, real x ) ans = 1.0L; r = 1.0L; n = 0; - const real thresh = 3.0L * real.epsilon; + static immutable real thresh = 3.0L * real.epsilon; do { xk = -( x * k1 * k2 )/( k3 * k4 ); pk = pkm1 + pkm2 * xk; @@ -984,7 +984,7 @@ real betaDistExpansion2(real a, real b, real x ) ans = 1.0L; r = 1.0L; int n = 0; - const real thresh = 3.0L * real.epsilon; + static immutable real thresh = 3.0L * real.epsilon; do { xk = -( z * k1 * k2 )/( k3 * k4 ); @@ -1149,7 +1149,7 @@ real gammaIncompleteCompl(real a, real x ) // DAC (Cephes bug fix): This is necessary to avoid // spurious nans, eg // log(x)-x = NaN when x = real.infinity - const real MAXLOGL = 1.1356523406294143949492E4L; + static immutable real MAXLOGL = 1.1356523406294143949492E4L; if (x > MAXLOGL) return 0; // underflow real ax = a * log(x) - x - logGamma(a); @@ -1190,7 +1190,7 @@ real gammaIncompleteCompl(real a, real x ) qkm2 = qkm1; qkm1 = qk; - const real BIG = 9.223372036854775808e18L; + static immutable real BIG = 9.223372036854775808e18L; if ( fabs(pk) > BIG ) { pkm2 /= BIG; @@ -1223,7 +1223,7 @@ real gammaIncompleteComplInv(real a, real p) if (p==0) return real.infinity; real y0 = p; - const real MAXLOGL = 1.1356523406294143949492E4L; + static immutable real MAXLOGL = 1.1356523406294143949492E4L; real x0, x1, x, yl, yh, y, d, lgm, dithresh; int i, dir; @@ -1359,7 +1359,7 @@ real digamma(real x) // Based on CEPHES, Stephen L. Moshier. // DAC: These values are Bn / n for n=2,4,6,8,10,12,14. - const real [] Bn_n = [ + static immutable real [] Bn_n = [ 1.0L/(6*2), -1.0L/(30*4), 1.0L/(42*6), -1.0L/(30*8), 5.0L/(66*10), -691.0L/(2730*12), 7.0L/(6*14) ]; diff --git a/src/ocean/math/IEEE.d b/src/ocean/math/IEEE.d index d9bfeb485..e85d5fde8 100644 --- a/src/ocean/math/IEEE.d +++ b/src/ocean/math/IEEE.d @@ -122,7 +122,7 @@ template floatTraits(T) { // EXPPOS_SHORT is the index of the exponent when represented as a ushort array. // SIGNPOS_BYTE is the index of the sign when represented as a ubyte array. // RECIP_EPSILON is the value such that (smallest_denormal) * RECIP_EPSILON == T.min - const T RECIP_EPSILON = (1/T.epsilon); + static immutable T RECIP_EPSILON = (1/T.epsilon); static if (T.mant_dig == 24) { // float enum : ushort { @@ -130,12 +130,12 @@ template floatTraits(T) { SIGNMASK = 0x8000, EXPBIAS = 0x3F00 } - const uint EXPMASK_INT = 0x7F80_0000; - const uint MANTISSAMASK_INT = 0x007F_FFFF; + static immutable uint EXPMASK_INT = 0x7F80_0000; + static immutable uint MANTISSAMASK_INT = 0x007F_FFFF; version(LittleEndian) { - const EXPPOS_SHORT = 1; + static immutable EXPPOS_SHORT = 1; } else { - const EXPPOS_SHORT = 0; + static immutable EXPPOS_SHORT = 0; } } else static if (T.mant_dig==53) { // double, or real==double enum : ushort { @@ -143,14 +143,14 @@ template floatTraits(T) { SIGNMASK = 0x8000, EXPBIAS = 0x3FE0 } - const uint EXPMASK_INT = 0x7FF0_0000; - const uint MANTISSAMASK_INT = 0x000F_FFFF; // for the MSB only + static immutable uint EXPMASK_INT = 0x7FF0_0000; + static immutable uint MANTISSAMASK_INT = 0x000F_FFFF; // for the MSB only version(LittleEndian) { - const EXPPOS_SHORT = 3; - const SIGNPOS_BYTE = 7; + static immutable EXPPOS_SHORT = 3; + static immutable SIGNPOS_BYTE = 7; } else { - const EXPPOS_SHORT = 0; - const SIGNPOS_BYTE = 0; + static immutable EXPPOS_SHORT = 0; + static immutable SIGNPOS_BYTE = 0; } } else static if (T.mant_dig==64) { // real80 enum : ushort { @@ -160,11 +160,11 @@ template floatTraits(T) { } // const ulong QUIETNANMASK = 0xC000_0000_0000_0000; // Converts a signaling NaN to a quiet NaN. version(LittleEndian) { - const EXPPOS_SHORT = 4; - const SIGNPOS_BYTE = 9; + static immutable EXPPOS_SHORT = 4; + static immutable SIGNPOS_BYTE = 9; } else { - const EXPPOS_SHORT = 0; - const SIGNPOS_BYTE = 0; + static immutable EXPPOS_SHORT = 0; + static immutable SIGNPOS_BYTE = 0; } } else static if (real.mant_dig==113){ // quadruple enum : ushort { @@ -173,11 +173,11 @@ template floatTraits(T) { EXPBIAS = 0x3FFE } version(LittleEndian) { - const EXPPOS_SHORT = 7; - const SIGNPOS_BYTE = 15; + static immutable EXPPOS_SHORT = 7; + static immutable SIGNPOS_BYTE = 15; } else { - const EXPPOS_SHORT = 0; - const SIGNPOS_BYTE = 0; + static immutable EXPPOS_SHORT = 0; + static immutable SIGNPOS_BYTE = 0; } } else static if (real.mant_dig==106) { // doubledouble enum : ushort { @@ -187,22 +187,22 @@ template floatTraits(T) { } // the exponent byte is not unique version(LittleEndian) { - const EXPPOS_SHORT = 7; // 3 is also an exp short - const SIGNPOS_BYTE = 15; + static immutable EXPPOS_SHORT = 7; // 3 is also an exp short + static immutable SIGNPOS_BYTE = 15; } else { - const EXPPOS_SHORT = 0; // 4 is also an exp short - const SIGNPOS_BYTE = 0; + static immutable EXPPOS_SHORT = 0; // 4 is also an exp short + static immutable SIGNPOS_BYTE = 0; } } } // These apply to all floating-point types version(LittleEndian) { - const MANTISSA_LSB = 0; - const MANTISSA_MSB = 1; + static immutable MANTISSA_LSB = 0; + static immutable MANTISSA_MSB = 1; } else { - const MANTISSA_LSB = 1; - const MANTISSA_MSB = 0; + static immutable MANTISSA_LSB = 1; + static immutable MANTISSA_MSB = 0; } public: @@ -616,13 +616,13 @@ int ilogb(real x) version (X86) { - const int FP_ILOGB0 = -int.max-1; - const int FP_ILOGBNAN = -int.max-1; - const int FP_ILOGBINFINITY = -int.max-1; + static immutable int FP_ILOGB0 = -int.max-1; + static immutable int FP_ILOGBNAN = -int.max-1; + static immutable int FP_ILOGBINFINITY = -int.max-1; } else { alias core.stdc.math.FP_ILOGB0 FP_ILOGB0; alias core.stdc.math.FP_ILOGBNAN FP_ILOGBNAN; - const int FP_ILOGBINFINITY = int.max; + static immutable int FP_ILOGBINFINITY = int.max; } unittest { diff --git a/src/ocean/math/IncrementalAverage.d b/src/ocean/math/IncrementalAverage.d index 6e915fe14..6aa391d58 100644 --- a/src/ocean/math/IncrementalAverage.d +++ b/src/ocean/math/IncrementalAverage.d @@ -83,13 +83,13 @@ public struct IncrementalAverage if (count == 0) return; - this.count_ += count; + (&this).count_ += count; - auto delta = (value - this.average_) * count; + auto delta = (value - (&this).average_) * count; - this.average_ += delta / this.count_; + (&this).average_ += delta / (&this).count_; - this.mean_of_square += delta * (value - this.average_); + (&this).mean_of_square += delta * (value - (&this).average_); } @@ -102,7 +102,7 @@ public struct IncrementalAverage public double average () { - return this.average_; + return (&this).average_; } @@ -115,7 +115,7 @@ public struct IncrementalAverage public ulong count () { - return this.count_; + return (&this).count_; } @@ -127,9 +127,9 @@ public struct IncrementalAverage public void clear () { - this.average_ = 0; - this.count_ = 0; - this.mean_of_square = 0; + (&this).average_ = 0; + (&this).count_ = 0; + (&this).mean_of_square = 0; } /*************************************************************************** @@ -163,13 +163,13 @@ public struct IncrementalAverage public double variance (double correction_factor = 0) { - if (this.count_ < 2) + if ((&this).count_ < 2) return 0; - verify(this.count_ > correction_factor, "Correction factor is same " + verify((&this).count_ > correction_factor, "Correction factor is same " ~ "size or bigger than the number of elements added."); - return this.mean_of_square / (this.count_ - correction_factor); + return (&this).mean_of_square / ((&this).count_ - correction_factor); } /*************************************************************************** @@ -191,7 +191,7 @@ public struct IncrementalAverage public double stdDeviation (double correction_factor = 0) { - return sqrt(this.variance(correction_factor)); + return sqrt((&this).variance(correction_factor)); } } @@ -204,7 +204,7 @@ version (UnitTest) // Bit count to avoid deliberate loss of precision. // Ensures only 8 bits of precision could be lost. - const PRECISION = double.mant_dig - 8; + static immutable PRECISION = double.mant_dig - 8; } unittest @@ -261,7 +261,7 @@ unittest PRECISION); inc_avg.clear(); - const ADD = ulong.max/1_000_000; + static immutable ADD = ulong.max/1_000_000; for (ulong i = 0; i < ulong.max; i += (ADD < ulong.max - i ? ADD : 1)) inc_avg.addToAverage(i%2); // 1 or 0 inc_avg.addToAverage(1); // One more add is missing @@ -360,10 +360,10 @@ unittest { auto t = new NamedTest("Multiple insertion precision"); - const value_1 = 3; - const value_2 = 7; - const value_3 = 11; - const freq = 1001; + static immutable value_1 = 3; + static immutable value_2 = 7; + static immutable value_3 = 11; + static immutable freq = 1001; IncrementalAverage single, multiple; @@ -397,7 +397,7 @@ unittest IncrementalAverage distribution; - const value = 8.0; + static immutable value = 8.0; distribution.addToAverage(value); diff --git a/src/ocean/math/IrregularMovingAverage.d b/src/ocean/math/IrregularMovingAverage.d index 4607de241..3f5899df2 100644 --- a/src/ocean/math/IrregularMovingAverage.d +++ b/src/ocean/math/IrregularMovingAverage.d @@ -66,7 +66,7 @@ public struct IrregularMovingAverage (Time = time_t, Value = real) ***************************************************************************/ - private alias typeof(*this) This; + private alias typeof(*(&this)) This; /*************************************************************************** @@ -128,32 +128,32 @@ public struct IrregularMovingAverage (Time = time_t, Value = real) invariant () { - assert(!isNaN(this.beta_)); - assert(!isInfinity(this.beta_)); - assert(0 < this.beta_); - assert(this.beta_ < 1); + assert(!isNaN((&this).beta_)); + assert(!isInfinity((&this).beta_)); + assert(0 < (&this).beta_); + assert((&this).beta_ < 1); - assert(!isNaN(this.alpha)); - assert(!isInfinity(this.alpha)); - assert(0 <= this.alpha); - assert(this.alpha <= 1); + assert(!isNaN((&this).alpha)); + assert(!isInfinity((&this).alpha)); + assert(0 <= (&this).alpha); + assert((&this).alpha <= 1); - assert(!isNaN(this.w)); - assert(!isInfinity(this.w)); + assert(!isNaN((&this).w)); + assert(!isInfinity((&this).w)); - assert(!isNaN(this.z)); - assert(!isInfinity(this.z)); + assert(!isNaN((&this).z)); + assert(!isInfinity((&this).z)); - assert(!isNaN(this.s)); - assert(!isInfinity(this.s)); + assert(!isNaN((&this).s)); + assert(!isInfinity((&this).s)); - assert(!isNaN(this.s2)); - assert(!isInfinity(this.s2)); + assert(!isNaN((&this).s2)); + assert(!isInfinity((&this).s2)); static if (isFloatingPointType!(Time)) { - assert(!isNaN(this.update_time_)); - assert(!isInfinity(this.update_time_)); + assert(!isNaN((&this).update_time_)); + assert(!isInfinity((&this).update_time_)); } } @@ -249,30 +249,30 @@ public struct IrregularMovingAverage (Time = time_t, Value = real) verify(!isInfinity(value_time)); } - enforce(value_time > this.update_time, + enforce(value_time > (&this).update_time, "Cannot incorporate data point from the past!"); // values re-used multiple times updating parameters - Value time_diff = value_time - this.update_time; - Value beta_pow = pow(this.beta, time_diff); + Value time_diff = value_time - (&this).update_time; + Value beta_pow = pow((&this).beta, time_diff); - this.update_time_ = value_time; + (&this).update_time_ = value_time; // update w based using old alpha value - this.w = this.w / - (beta_pow + (time_diff * beta_pow * this.w / this.alpha)); + (&this).w = (&this).w / + (beta_pow + (time_diff * beta_pow * (&this).w / (&this).alpha)); - this.alpha = this.alpha / (beta_pow + this.alpha); + (&this).alpha = (&this).alpha / (beta_pow + (&this).alpha); // update z using new alpha and w values - this.z = this.z / - (beta_pow + (this.alpha * this.z / this.w)); + (&this).z = (&this).z / + (beta_pow + ((&this).alpha * (&this).z / (&this).w)); // update s using new alpha value - this.s = (this.alpha * value) + ((1.0 - this.alpha) * this.s); + (&this).s = ((&this).alpha * value) + ((1.0 - (&this).alpha) * (&this).s); // update s2 using new alpha and new s value - this.s2 = (this.alpha * this.s) + ((1.0 - this.alpha) * this.s2); + (&this).s2 = ((&this).alpha * (&this).s) + ((1.0 - (&this).alpha) * (&this).s2); } @@ -285,7 +285,7 @@ public struct IrregularMovingAverage (Time = time_t, Value = real) public Value value () { - return this.s2; + return (&this).s2; } @@ -314,15 +314,15 @@ public struct IrregularMovingAverage (Time = time_t, Value = real) } body { - enforce(t >= this.update_time_, + enforce(t >= (&this).update_time_, "Cannot calculate predicted value from the past!"); - Time k = t - this.update_time; + Time k = t - (&this).update_time; assert(k >= 0); - Value estimate = this.s + - ( ((this.z / this.w) + ((this.z / this.alpha) * k)) * (this.s - this.s2) ); + Value estimate = (&this).s + + ( (((&this).z / (&this).w) + (((&this).z / (&this).alpha) * k)) * ((&this).s - (&this).s2) ); return estimate; } @@ -338,7 +338,7 @@ public struct IrregularMovingAverage (Time = time_t, Value = real) public Time update_time () { - return this.update_time_; + return (&this).update_time_; } @@ -362,9 +362,9 @@ public struct IrregularMovingAverage (Time = time_t, Value = real) verify(!isInfinity(value_time)); } - verify(t > this.update_time_); + verify(t > (&this).update_time_); - return this.update_time_ = t; + return (&this).update_time_ = t; } @@ -377,7 +377,7 @@ public struct IrregularMovingAverage (Time = time_t, Value = real) public Value beta () { - return this.beta_; + return (&this).beta_; } @@ -405,7 +405,7 @@ public struct IrregularMovingAverage (Time = time_t, Value = real) verify(0 < b); verify(b < 1); - return this.beta_ = b; + return (&this).beta_ = b; } } diff --git a/src/ocean/math/Math.d b/src/ocean/math/Math.d index d9bc6678e..697fe9a61 100644 --- a/src/ocean/math/Math.d +++ b/src/ocean/math/Math.d @@ -65,29 +65,29 @@ version(TangoNoAsm) { * Constants */ -const real E = 2.7182818284590452354L; /** e */ // 3.32193 fldl2t 0x1.5BF0A8B1_45769535_5FF5p+1L -const real LOG2T = 0x1.a934f0979a3715fcp+1; /** $(SUB log, 2)10 */ // 1.4427 fldl2e -const real LOG2E = 0x1.71547652b82fe178p+0; /** $(SUB log, 2)e */ // 0.30103 fldlg2 -const real LOG2 = 0x1.34413509f79fef32p-2; /** $(SUB log, 10)2 */ -const real LOG10E = 0.43429448190325182765; /** $(SUB log, 10)e */ -const real LN2 = 0x1.62e42fefa39ef358p-1; /** ln 2 */ // 0.693147 fldln2 -const real LN10 = 2.30258509299404568402; /** ln 10 */ -const real PI = 0x1.921fb54442d1846ap+1; /** $(_PI) */ // 3.14159 fldpi -const real PI_2 = 1.57079632679489661923; /** $(PI) / 2 */ -const real PI_4 = 0.78539816339744830962; /** $(PI) / 4 */ -const real M_1_PI = 0.31830988618379067154; /** 1 / $(PI) */ -const real M_2_PI = 0.63661977236758134308; /** 2 / $(PI) */ -const real M_2_SQRTPI = 1.12837916709551257390; /** 2 / $(SQRT)$(PI) */ -const real SQRT2 = 1.41421356237309504880; /** $(SQRT)2 */ -const real SQRT1_2 = 0.70710678118654752440; /** $(SQRT)$(HALF) */ +static immutable real E = 2.7182818284590452354L; /** e */ // 3.32193 fldl2t 0x1.5BF0A8B1_45769535_5FF5p+1L +static immutable real LOG2T = 0x1.a934f0979a3715fcp+1; /** $(SUB log, 2)10 */ // 1.4427 fldl2e +static immutable real LOG2E = 0x1.71547652b82fe178p+0; /** $(SUB log, 2)e */ // 0.30103 fldlg2 +static immutable real LOG2 = 0x1.34413509f79fef32p-2; /** $(SUB log, 10)2 */ +static immutable real LOG10E = 0.43429448190325182765; /** $(SUB log, 10)e */ +static immutable real LN2 = 0x1.62e42fefa39ef358p-1; /** ln 2 */ // 0.693147 fldln2 +static immutable real LN10 = 2.30258509299404568402; /** ln 10 */ +static immutable real PI = 0x1.921fb54442d1846ap+1; /** $(_PI) */ // 3.14159 fldpi +static immutable real PI_2 = 1.57079632679489661923; /** $(PI) / 2 */ +static immutable real PI_4 = 0.78539816339744830962; /** $(PI) / 4 */ +static immutable real M_1_PI = 0.31830988618379067154; /** 1 / $(PI) */ +static immutable real M_2_PI = 0.63661977236758134308; /** 2 / $(PI) */ +static immutable real M_2_SQRTPI = 1.12837916709551257390; /** 2 / $(SQRT)$(PI) */ +static immutable real SQRT2 = 1.41421356237309504880; /** $(SQRT)2 */ +static immutable real SQRT1_2 = 0.70710678118654752440; /** $(SQRT)$(HALF) */ //const real SQRTPI = 1.77245385090551602729816748334114518279754945612238L; /** √π */ //const real SQRT2PI = 2.50662827463100050242E0L; /** √(2 π) */ //const real SQRTE = 1.64872127070012814684865078781416357L; /** √(e) */ -const real MAXLOG = 0x1.62e42fefa39ef358p+13L; /** log(real.max) */ -const real MINLOG = -0x1.6436716d5406e6d8p+13L; /** log(real.min*real.epsilon) */ -const real EULERGAMMA = 0.57721_56649_01532_86060_65120_90082_40243_10421_59335_93992L; /** Euler-Mascheroni constant 0.57721566.. */ +static immutable real MAXLOG = 0x1.62e42fefa39ef358p+13L; /** log(real.max) */ +static immutable real MINLOG = -0x1.6436716d5406e6d8p+13L; /** log(real.min*real.epsilon) */ +static immutable real EULERGAMMA = 0.57721_56649_01532_86060_65120_90082_40243_10421_59335_93992L; /** Euler-Mascheroni constant 0.57721566.. */ /* * Primitives @@ -1767,8 +1767,8 @@ real hypot(real x, real y) // If both are huge, avoid overflow by scaling by 1/sqrt(real.max/2). // If both are tiny, avoid underflow by scaling by sqrt(real.min_normal*real.epsilon). - const real SQRTMIN = 0x8.0p-8195L; // 0.5 * sqrt(min_normal!(real)); // This is a power of 2. - const real SQRTMAX = 1.0L / SQRTMIN; // 2^^((max_exp)/2) = nextUp(sqrt(real.max)) + static immutable real SQRTMIN = 0x8.0p-8195L; // 0.5 * sqrt(min_normal!(real)); // This is a power of 2. + static immutable real SQRTMAX = 1.0L / SQRTMIN; // 2^^((max_exp)/2) = nextUp(sqrt(real.max)) static assert(2 * (SQRTMAX / 2) * (SQRTMAX / 2) <= real.max); @@ -1868,8 +1868,8 @@ T poly(T)(T x, T[] A) verify(A.length > 0); version (Naked_D_InlineAsm_X86) { - const bool Use_D_InlineAsm_X86 = true; - } else const bool Use_D_InlineAsm_X86 = false; + static immutable bool Use_D_InlineAsm_X86 = true; + } else static immutable bool Use_D_InlineAsm_X86 = false; // BUG (Inherited from Phobos): This code assumes a frame pointer in EBP. // This is not in the spec. @@ -1940,7 +1940,7 @@ T poly(T)(T x, T[] A) unittest { real x = 3.1; - const real[] pp = [56.1L, 32.7L, 6L]; + static immutable real[] pp = [56.1L, 32.7L, 6L]; test( poly(x, pp) == (56.1L + (32.7L + 6L * x) * x) ); diff --git a/src/ocean/math/Range.d b/src/ocean/math/Range.d index f881742d3..534310e12 100644 --- a/src/ocean/math/Range.d +++ b/src/ocean/math/Range.d @@ -64,8 +64,8 @@ public struct Range ( T ) ***************************************************************************/ - private const T null_min = T.max; - private const T null_max = T.min; + private enum T null_min = T.max; + private enum T null_max = T.min; /*************************************************************************** @@ -111,7 +111,7 @@ public struct Range ( T ) // useful for test!("==") public istring toString () { - return format("<{}|{}>", this.value, cast(char)('A' + this.owner_index)); + return format("<{}|{}>", (&this).value, cast(char)('A' + (&this).owner_index)); } } } @@ -213,20 +213,20 @@ public struct Range ( T ) invariant() { - assert(This.isValid(this.min_, this.max_)); + assert(This.isValid((&this).min_, (&this).max_)); } version ( UnitTest ) { public istring toString() { - auto msg = format("{}({}, {}", This.stringof, this.min_, this.max_); + auto msg = format("{}({}, {}", This.stringof, (&this).min_, (&this).max_); - if (this.is_empty) + if ((&this).is_empty) { msg ~= " empty"; } - else if (this.is_full_range) + else if ((&this).is_full_range) { msg ~= " full"; } @@ -395,7 +395,7 @@ public struct Range ( T ) public T min ( ) { - return this.min_; + return (&this).min_; } @@ -408,7 +408,7 @@ public struct Range ( T ) public T max ( ) { - return this.max_; + return (&this).max_; } @@ -426,7 +426,7 @@ public struct Range ( T ) public T min ( T min ) { - return this.min_ = min; + return (&this).min_ = min; } @@ -444,7 +444,7 @@ public struct Range ( T ) public T max ( T max ) { - return this.max_ = max; + return (&this).max_ = max; } @@ -457,7 +457,7 @@ public struct Range ( T ) public bool is_empty ( ) { - return This.isEmpty(this.min_, this.max_); + return This.isEmpty((&this).min_, (&this).max_); } @@ -470,7 +470,7 @@ public struct Range ( T ) public bool is_full_range ( ) { - return This.isFullRange(this.min_, this.max_); + return This.isFullRange((&this).min_, (&this).max_); } @@ -488,7 +488,7 @@ public struct Range ( T ) public bool is_valid ( ) { - return This.isValid(this.min_, this.max_); + return This.isValid((&this).min_, (&this).max_); } @@ -505,11 +505,11 @@ public struct Range ( T ) public size_t length ( ) { - enforce(!this.is_full_range, This.stringof ~ ".length(): full range"); + enforce(!(&this).is_full_range, This.stringof ~ ".length(): full range"); - if ( this.is_empty ) return 0; + if ( (&this).is_empty ) return 0; - return (this.max_ - this.min_) + 1; + return ((&this).max_ - (&this).min_) + 1; } unittest @@ -536,10 +536,10 @@ public struct Range ( T ) public bool contains ( T x ) { - if (this.is_empty) + if ((&this).is_empty) return false; - return this.min_ <= x && x <= this.max_; + return (&this).min_ <= x && x <= (&this).max_; } unittest @@ -581,7 +581,7 @@ public struct Range ( T ) public equals_t opEquals ( This other ) { - return this.min_ == other.min && this.max_ == other.max_; + return (&this).min_ == other.min && (&this).max_ == other.max_; } unittest @@ -682,10 +682,10 @@ public struct Range ( T ) public bool isSubsetOf ( This other ) { - if ( this.is_empty || other.is_empty ) + if ( (&this).is_empty || other.is_empty ) return false; - return this.min_ >= other.min_ && this.max_ <= other.max_; + return (&this).min_ >= other.min_ && (&this).max_ <= other.max_; } unittest @@ -738,7 +738,7 @@ public struct Range ( T ) public bool isSupersetOf ( This other ) { - return other.isSubsetOf(*this); + return other.isSubsetOf(*(&this)); } unittest @@ -791,7 +791,7 @@ public struct Range ( T ) public bool isTessellatedBy ( This[] ranges ) { - return (*this == extent(ranges)) && isContiguous(ranges); + return (*(&this) == extent(ranges)) && isContiguous(ranges); } unittest @@ -874,7 +874,7 @@ public struct Range ( T ) public bool isCoveredBy ( This[] ranges ) { - return this.isSubsetOf(extent(ranges)) && !hasGap(ranges); + return (&this).isSubsetOf(extent(ranges)) && !hasGap(ranges); } unittest @@ -1039,13 +1039,13 @@ public struct Range ( T ) public size_t overlapAmount ( Range other ) { - enforce(!(this.is_full_range && other.is_full_range), + enforce(!((&this).is_full_range && other.is_full_range), This.stringof ~ ".overlapAmount(): both ranges are full"); - if ( this.is_empty || other.is_empty ) return 0; + if ( (&this).is_empty || other.is_empty ) return 0; RangeEndpoint[4] a; - This.sortEndpoints(*this, other, a); + This.sortEndpoints(*(&this), other, a); return a[0].owner_index != a[1].owner_index ? This(a[1].value, a[2].value).length : 0; @@ -1115,9 +1115,9 @@ public struct Range ( T ) public bool overlaps ( This other ) { - if ( this.is_empty || other.is_empty ) return false; + if ( (&this).is_empty || other.is_empty ) return false; - return !(other.max_ < this.min_ || other.min > this.max_); + return !(other.max_ < (&this).min_ || other.min > (&this).max_); } unittest @@ -1181,22 +1181,22 @@ public struct Range ( T ) public void subtract ( This other, out This lower, out This upper ) { // this empty -- empty result - if ( this.is_empty ) return; + if ( (&this).is_empty ) return; // other empty -- no change if ( other.is_empty ) { - lower = *this; + lower = *(&this); return; } RangeEndpoint[4] a; - This.sortEndpoints(*this, other, a); + This.sortEndpoints(*(&this), other, a); // no overlap if (a[0].owner_index == a[1].owner_index) { - lower = *this; + lower = *(&this); return; } diff --git a/src/ocean/math/TimeHistogram.d b/src/ocean/math/TimeHistogram.d index 9becd8e07..53acbef54 100644 --- a/src/ocean/math/TimeHistogram.d +++ b/src/ocean/math/TimeHistogram.d @@ -139,7 +139,7 @@ struct TimeHistogram } body { - const type = typeof(TimeHistogram.bins[0]).stringof; + enum type = typeof(TimeHistogram.bins[0]).stringof; istring res; @@ -196,9 +196,9 @@ struct TimeHistogram public ulong countMicros ( ulong us ) { - this.count++; - this.total_time_micros += us; - this.bins[binIndex(us)]++; + (&this).count++; + (&this).total_time_micros += us; + (&this).bins[binIndex(us)]++; return us; } @@ -213,11 +213,11 @@ struct TimeHistogram public double mean_time_micros ( ) in { - assert(this.count || !this.total_time_micros); + assert((&this).count || !(&this).total_time_micros); } body { - return cast(double)this.total_time_micros / this.count; + return cast(double)(&this).total_time_micros / (&this).count; } /*************************************************************************** @@ -238,8 +238,8 @@ struct TimeHistogram mixin("static assert(is(typeof(Bins.init." ~ bin_name ~ ")));"); mixin("const offset = Bins.init." ~ bin_name ~ ".offsetof;"); - const index = offset / this.bins[0].sizeof; - return this.bins[index]; + enum index = offset / (&this).bins[0].sizeof; + return (&this).bins[index]; } unittest @@ -258,7 +258,7 @@ struct TimeHistogram public Bins stats ( ) { - return Bins.fromArray(this.bins); + return Bins.fromArray((&this).bins); } unittest diff --git a/src/ocean/math/WideUInt.d b/src/ocean/math/WideUInt.d index ebe53eb34..f4733ef14 100644 --- a/src/ocean/math/WideUInt.d +++ b/src/ocean/math/WideUInt.d @@ -92,10 +92,10 @@ public struct WideUInt ( size_t N ) public size_t decimal_digits ( ) { - if (this.opEquals(0)) + if ((&this).opEquals(0)) return 1; - WideUInt copy = *this; + WideUInt copy = *(&this); size_t count; while (copy != 0) @@ -134,7 +134,7 @@ public struct WideUInt ( size_t N ) public istring toString ( ) { mstring result; - this.toString((cstring s) { result ~= s; }); + (&this).toString((cstring s) { result ~= s; }); return assumeUnique(result); } @@ -163,14 +163,14 @@ public struct WideUInt ( size_t N ) ***************************************************************************/ - public void toString ( void delegate (cstring) sink ) + public void toString ( scope void delegate (cstring) sink ) { - auto n = this.decimal_digits(); + auto n = (&this).decimal_digits(); static mstring buffer; buffer.length = n; enableStomping(buffer); - WideUInt copy = *this; + WideUInt copy = *(&this); for (ptrdiff_t idx = n-1; idx >= 0; --idx) { auto remainder = copy.divideBy(10); @@ -191,7 +191,7 @@ public struct WideUInt ( size_t N ) public void opAssign ( ulong rhs ) { - this.assign(rhs); + (&this).assign(rhs); } unittest @@ -226,13 +226,13 @@ public struct WideUInt ( size_t N ) public equals_t opEquals ( ulong rhs ) { - if (this.payload[0] != (rhs & uint.max)) + if ((&this).payload[0] != (rhs & uint.max)) return false; - if (this.payload[1] != (rhs >> 32)) + if ((&this).payload[1] != (rhs >> 32)) return false; - foreach (ref word; this.payload[2 .. N]) + foreach (ref word; (&this).payload[2 .. N]) { if (word != 0) return false; @@ -273,7 +273,7 @@ public struct WideUInt ( size_t N ) public equals_t opEquals ( WideUInt rhs ) { - return this.payload[] == rhs.payload[]; + return (&this).payload[] == rhs.payload[]; } unittest @@ -343,8 +343,8 @@ public struct WideUInt ( size_t N ) public void opAddAssign ( uint rhs ) { - if (add(this.payload[0], rhs)) - enforce(.wideint_exception, this.checkAndInc(1)); + if (add((&this).payload[0], rhs)) + enforce(.wideint_exception, (&this).checkAndInc(1)); } unittest @@ -378,13 +378,13 @@ public struct WideUInt ( size_t N ) { ulong remainder = 0; - for (ptrdiff_t idx = this.payload.length - 1; idx >= 0; --idx) + for (ptrdiff_t idx = (&this).payload.length - 1; idx >= 0; --idx) { - remainder = (remainder << 32) + this.payload[idx]; + remainder = (remainder << 32) + (&this).payload[idx]; ulong result = remainder / rhs; remainder -= rhs * result; verify(result <= uint.max); - this.payload[idx] = cast(uint) result; + (&this).payload[idx] = cast(uint) result; } verify(remainder <= uint.max); @@ -420,10 +420,10 @@ public struct WideUInt ( size_t N ) { ulong overflow = 0; - for (size_t i = 0; i < this.payload.length; ++i) + for (size_t i = 0; i < (&this).payload.length; ++i) { - overflow += cast(ulong)(this.payload[i]) * rhs; - this.payload[i] = cast(uint) (overflow & uint.max); + overflow += cast(ulong)((&this).payload[i]) * rhs; + (&this).payload[i] = cast(uint) (overflow & uint.max); overflow >>= 32; } @@ -448,23 +448,23 @@ public struct WideUInt ( size_t N ) public double toDouble ( ) { // find most significant word with non-zero value - int idx = this.payload.length-1; - while (this.payload[idx] == 0 && idx > 0) + int idx = (&this).payload.length-1; + while ((&this).payload[idx] == 0 && idx > 0) --idx; // if stored value <= ulong.max, just use plain cast if (idx < 2) { - ulong value = this.payload[1]; + ulong value = (&this).payload[1]; value <<= 32; - value |= this.payload[0]; + value |= (&this).payload[0]; return cast(double) value; } // else calculate floating point value from 3 most significant words double MAXWORD = pow(2.0, 32.0); - return ((this.payload[idx] * MAXWORD + this.payload[idx-1]) - * MAXWORD + this.payload[idx-2]) + return (((&this).payload[idx] * MAXWORD + (&this).payload[idx-1]) + * MAXWORD + (&this).payload[idx-2]) * ldexp(1.0, (idx-2)*32); } @@ -497,9 +497,9 @@ public struct WideUInt ( size_t N ) if (idx >= N) return false; - uint after = ++this.payload[idx]; + uint after = ++(&this).payload[idx]; if (after == 0) - return this.checkAndInc(idx+1); + return (&this).checkAndInc(idx+1); return true; } @@ -524,9 +524,9 @@ public struct WideUInt ( size_t N ) private void assign ( ulong value ) { - this.payload[] = 0; - this.payload[0] = cast(uint) value; - this.payload[1] = cast(uint) (value >> 32); + (&this).payload[] = 0; + (&this).payload[0] = cast(uint) value; + (&this).payload[1] = cast(uint) (value >> 32); } /*************************************************************************** diff --git a/src/ocean/math/internal/BignumX86.d b/src/ocean/math/internal/BignumX86.d index 213c0be74..aee2e98b3 100644 --- a/src/ocean/math/internal/BignumX86.d +++ b/src/ocean/math/internal/BignumX86.d @@ -745,7 +745,7 @@ uint multibyteMulAdd(char op)(uint [] dest, uint[] src, uint multiplier, uint ca // EDI = dest // ESI = src - const char [] OP = (op=='+')? "add" : "sub"; + static immutable char [] OP = (op=='+')? "add" : "sub"; version(D_PIC) { enum { zero = 0 } } else { diff --git a/src/ocean/math/internal/BiguintCore.d b/src/ocean/math/internal/BiguintCore.d index 248aee9d0..e0a6401e5 100644 --- a/src/ocean/math/internal/BiguintCore.d +++ b/src/ocean/math/internal/BiguintCore.d @@ -81,10 +81,10 @@ static if (BigDigit.sizeof == int.sizeof) { enum { LG2BIGDIGITBITS = 6, BIGDIGITSHIFTMASK = 63 }; } else static assert(0, "Unsupported BigDigit size"); -const Const!(BigDigit)[] ZERO = [0]; -const Const!(BigDigit)[] ONE = [1]; -const Const!(BigDigit)[] TWO = [2]; -const Const!(BigDigit)[] TEN = [10]; +static immutable Const!(BigDigit)[] ZERO = [0]; +static immutable Const!(BigDigit)[] ONE = [1]; +static immutable Const!(BigDigit)[] TWO = [2]; +static immutable Const!(BigDigit)[] TEN = [10]; public: @@ -318,9 +318,9 @@ bool fromHexString(cstring s) ++sofar; } if (sofar == 0) - this.data = ZERO; + (&this).data = ZERO; else - this.data = raw[0..sofar]; + (&this).data = raw[0..sofar]; return true; } @@ -341,7 +341,7 @@ bool fromDecimalString(cstring s) auto raw = new BigDigit[predictlength]; auto hi = biguintFromDecimal(raw, s[firstNonZero..$]); raw.length = hi; - this.data = raw; + (&this).data = raw; return true; } @@ -370,7 +370,7 @@ BigUint opShr(ulong y) BigUint opShl(ulong y) { verify(y>0); - if (isZero()) return *this; + if (isZero()) return *(&this); uint bits = cast(uint)y & BIGDIGITSHIFTMASK; verify ((y>>LG2BIGDIGITBITS) < cast(ulong)(uint.max)); uint words = cast(uint)(y >> LG2BIGDIGITBITS); @@ -782,7 +782,7 @@ T intpow(T)(T x, ulong n) int highestPowerBelowUintMax(uint x) { verify(x>1); - const maxpwr = [31, 20, 15, 13, 12, 11, 10, 10, 9, 9, + static immutable maxpwr = [31, 20, 15, 13, 12, 11, 10, 10, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7]; if (x<24) return maxpwr[x-2]; if (x<41) return 6; @@ -797,7 +797,7 @@ int highestPowerBelowUintMax(uint x) int highestPowerBelowUlongMax(uint x) { verify(x>1); - const maxpwr = [63, 40, 31, 27, 24, 22, 21, 20, 19, 18, + static immutable maxpwr = [63, 40, 31, 27, 24, 22, 21, 20, 19, 18, 17, 17, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12]; @@ -1651,7 +1651,7 @@ void itoaZeroPadded(char[] output, uint value, int radix = 10) { void toHexZeroPadded(char[] output, uint value) { ptrdiff_t x = output.length - 1; - const istring hexDigits = "0123456789ABCDEF"; + static immutable istring hexDigits = "0123456789ABCDEF"; for( ; x>=0; --x) { output[x] = hexDigits[value & 0xF]; value >>= 4; diff --git a/src/ocean/math/random/ExpSource.d b/src/ocean/math/random/ExpSource.d index eba8d2dbd..39d5b1825 100644 --- a/src/ocean/math/random/ExpSource.d +++ b/src/ocean/math/random/ExpSource.d @@ -65,7 +65,7 @@ final class ExpSource(RandG,T){ return source.randomizeOp((T el){ return el*cast(T)beta; },x); } /// initializes the given variable with an exponentially distribued number and maps op on it - U randomizeOp(U,S)(S delegate(T)op,ref U a){ + U randomizeOp(U,S)(scope S delegate(T)op,ref U a){ return source.randomizeOp(op,a); } /// exp distribution with different default scale parameter beta @@ -83,7 +83,7 @@ final class ExpSource(RandG,T){ /// chainable call style initialization of variables (thorugh a call to randomize) ExpDistribution opCall(U,S...)(ref U a,S args){ randomize(a,args); - return *this; + return *(&this); } /// returns a single number T getRandom(){ diff --git a/src/ocean/math/random/Kiss.d b/src/ocean/math/random/Kiss.d index 94b159524..8a9733cff 100644 --- a/src/ocean/math/random/Kiss.d +++ b/src/ocean/math/random/Kiss.d @@ -63,7 +63,7 @@ struct Kiss private uint kiss_w = 8; private uint kiss_carry = 0; - private const double M_RAN_INVM32 = 2.32830643653869628906e-010, + private enum double M_RAN_INVM32 = 2.32830643653869628906e-010, M_RAN_INVM52 = 2.22044604925031308085e-016; /********************************************************************** diff --git a/src/ocean/math/random/NormalSource.d b/src/ocean/math/random/NormalSource.d index 22b269598..262ebc19a 100644 --- a/src/ocean/math/random/NormalSource.d +++ b/src/ocean/math/random/NormalSource.d @@ -78,7 +78,7 @@ class NormalSource(RandG,T){ return source.randomizeOp((T x){ return x*cast(T)sigma+cast(T)mu; },a); } /// initializes the variable with the result of mapping op on the random numbers (of type T) - U randomizeOp(U,S)(S delegate(T) op,ref U a){ + U randomizeOp(U,S)(scope S delegate(T) op,ref U a){ return source.randomizeOp(op,a); } /// normal distribution with different default sigma and mu @@ -97,7 +97,7 @@ class NormalSource(RandG,T){ /// chainable call style initialization of variables (thorugh a call to randomize) NormalDistribution opCall(U,S...)(ref U a,S args){ randomize(a,args); - return *this; + return *(&this); } /// returns a single number T getRandom(){ diff --git a/src/ocean/math/random/Random.d b/src/ocean/math/random/Random.d index 27bc8846f..23769c31f 100644 --- a/src/ocean/math/random/Random.d +++ b/src/ocean/math/random/Random.d @@ -210,9 +210,9 @@ version=has_urandom; /// if T is a float template isFloat(T){ static if(is(T==float)||is(T==double)||is(T==real)){ - const bool isFloat=true; + static immutable bool isFloat=true; } else { - const bool isFloat=false; + static immutable bool isFloat=false; } } @@ -261,7 +261,7 @@ final class RandomG(SourceT=DefaultEngine) return this; } /// if source.canSeed seeds the generator using the given source of uints - RandomG seed (uint delegate() seedSource) + RandomG seed (scope uint delegate() seedSource) { static if(is(typeof(SourceT.canSeed))) { static if (SourceT.canSeed) @@ -311,9 +311,9 @@ final class RandomG(SourceT=DefaultEngine) return cast(bool)(source.next & 1u); // check lowest bit } else static if (is(T==float)||is(T==double)||is(T==real)){ static if (T.mant_dig<30) { - const T halfT=(cast(T)1)/(cast(T)2); - const T fact32=ctfe_powI(halfT,32); - const uint minV=1u<<(T.mant_dig-1); + static immutable T halfT=(cast(T)1)/(cast(T)2); + static immutable T fact32=ctfe_powI(halfT,32); + static immutable uint minV=1u<<(T.mant_dig-1); uint nV=source.next; if (nV>=minV) { T res=nV*fact32; @@ -339,9 +339,9 @@ final class RandomG(SourceT=DefaultEngine) } } } else static if (T.mant_dig<62) { - const T halfT=(cast(T)1)/(cast(T)2); - const T fact64=ctfe_powI(halfT,64); - const ulong minV=1UL<<(T.mant_dig-1); + static immutable T halfT=(cast(T)1)/(cast(T)2); + static immutable T fact64=ctfe_powI(halfT,64); + static immutable ulong minV=1UL<<(T.mant_dig-1); ulong nV=source.nextL; if (nV>=minV) { T res=nV*fact64; @@ -353,8 +353,8 @@ final class RandomG(SourceT=DefaultEngine) return res; } } else { // probability 0.00048828125 for 53 bit mantissa - const T fact32=ctfe_powI(halfT,32); - const ulong minV2=1UL<<(T.mant_dig-33); + static immutable T fact32=ctfe_powI(halfT,32); + static immutable ulong minV2=1UL<<(T.mant_dig-33); if (nV>=minV2){ return ((cast(T)nV)+(cast(T)source.next)*fact32)*fact64; } else { // probability 1.1368683772161603e-13 for 53 bit mantissa @@ -374,9 +374,9 @@ final class RandomG(SourceT=DefaultEngine) } } } else static if (T.mant_dig<=64){ - const T halfT=(cast(T)1)/(cast(T)2); - const T fact8=ctfe_powI(halfT,8); - const T fact72=ctfe_powI(halfT,72); + static immutable T halfT=(cast(T)1)/(cast(T)2); + static immutable T fact8=ctfe_powI(halfT,8); + static immutable T fact72=ctfe_powI(halfT,72); ubyte nB=source.nextB; if (nB!=0){ T res=nB*fact8+source.nextL*fact72; @@ -388,7 +388,7 @@ final class RandomG(SourceT=DefaultEngine) return res; } } else { // probability 0.00390625 - const T fact64=ctfe_powI(halfT,64); + static immutable T fact64=ctfe_powI(halfT,64); T scale=fact8; while (nB==0){ nB=source.nextB; @@ -405,8 +405,8 @@ final class RandomG(SourceT=DefaultEngine) } } else { // (T.mant_dig > 64 bits), not so optimized, but works for any size - const T halfT=(cast(T)1)/(cast(T)2); - const T fact32=ctfe_powI(halfT,32); + static immutable T halfT=(cast(T)1)/(cast(T)2); + static immutable T fact32=ctfe_powI(halfT,32); uint nL=source.next; T fact=fact32; while (nL==0){ @@ -523,9 +523,9 @@ final class RandomG(SourceT=DefaultEngine) } } else static if (is(T==float)||is(T==double)||is(T==real)){ static if (T.mant_dig<30){ - const T halfT=(cast(T)1)/(cast(T)2); - const T fact32=ctfe_powI(halfT,32); - const uint minV=1u<=minV) { T res=nV*fact32*to; @@ -554,9 +554,9 @@ final class RandomG(SourceT=DefaultEngine) } } } else static if (T.mant_dig<62) { - const T halfT=(cast(T)1)/(cast(T)2); - const T fact64=ctfe_powI(halfT,64); - const ulong minV=1UL<<(T.mant_dig); + static immutable T halfT=(cast(T)1)/(cast(T)2); + static immutable T fact64=ctfe_powI(halfT,64); + static immutable ulong minV=1UL<<(T.mant_dig); ulong nV=source.nextL; if (nV>=minV) { T res=nV*fact64*to; @@ -569,8 +569,8 @@ final class RandomG(SourceT=DefaultEngine) return (1-2*cast(int)(nV&1UL))*res; } } else { // probability 0.00048828125 for 53 bit mantissa - const T fact32=ctfe_powI(halfT,32); - const ulong minV2=1UL<<(T.mant_dig-32); + static immutable T fact32=ctfe_powI(halfT,32); + static immutable ulong minV2=1UL<<(T.mant_dig-32); if (nV>=minV2){ uint nV2=source.next; T res=((cast(T)nV)+(cast(T)nV2)*fact32)*fact64*to; @@ -594,9 +594,9 @@ final class RandomG(SourceT=DefaultEngine) } } } else static if (T.mant_dig<=64) { - const T halfT=(cast(T)1)/(cast(T)2); - const T fact8=ctfe_powI(halfT,8); - const T fact72=ctfe_powI(halfT,72); + static immutable T halfT=(cast(T)1)/(cast(T)2); + static immutable T fact8=ctfe_powI(halfT,8); + static immutable T fact72=ctfe_powI(halfT,72); ubyte nB=source.nextB; if (nB!=0){ ulong nL=source.nextL; @@ -610,7 +610,7 @@ final class RandomG(SourceT=DefaultEngine) return (1-2*cast(int)(nL&1UL))*res; } } else { // probability 0.00390625 - const T fact64=ctfe_powI(halfT,64); + static immutable T fact64=ctfe_powI(halfT,64); T scale=fact8; while (nB==0){ nB=source.nextB; @@ -629,8 +629,8 @@ final class RandomG(SourceT=DefaultEngine) } } else { // (T.mant_dig > 64 bits), not so optimized, but works for any size - const T halfT=(cast(T)1)/(cast(T)2); - const T fact32=ctfe_powI(halfT,32); + static immutable T halfT=(cast(T)1)/(cast(T)2); + static immutable T fact32=ctfe_powI(halfT,32); uint nL=source.next; T fact=fact32; while (nL==0){ @@ -928,7 +928,7 @@ final class RandomG(SourceT=DefaultEngine) /// chainable call style initialization of variables (thorugh a call to randomize) UniformDistribution opCall(U,S...)(ref U a,S args){ randomize(a,args); - return *this; + return *(&this); } /// returns a random number T getRandom(){ @@ -954,7 +954,7 @@ final class RandomG(SourceT=DefaultEngine) /// chainable call style initialization of variables (thorugh a call to randomize) UniformRDistribution opCall(U)(ref U a){ randomize(a); - return *this; + return *(&this); } /// returns a random number T getRandom(){ @@ -982,7 +982,7 @@ final class RandomG(SourceT=DefaultEngine) /// chainable call style initialization of variables (thorugh a call to randomize) UniformRSymmDistribution opCall(U)(ref U a){ randomize(a); - return *this; + return *(&this); } /// returns a random number T getRandom(){ @@ -1009,7 +1009,7 @@ final class RandomG(SourceT=DefaultEngine) /// chainable call style initialization of variables (thorugh a call to randomize) UniformR2Distribution opCall(U,S...)(ref U a,S args){ randomize(a,args); - return *this; + return *(&this); } /// returns a random number T getRandom(){ @@ -1041,7 +1041,7 @@ final class RandomG(SourceT=DefaultEngine) /// chainable call style initialization of variables (thorugh a call to randomize) GammaDistribution opCall(U,S...)(ref U a,S args){ randomize(a,args); - return *this; + return *(&this); } /// returns a single random number T getRandom(T a=alpha,T t=theta) @@ -1075,7 +1075,7 @@ final class RandomG(SourceT=DefaultEngine) return b; } /// maps op on random numbers (of type T) and initializes b with it - U randomizeOp(U,S)(S delegate(T)op, ref U b,T a=alpha, T t=theta){ + U randomizeOp(U,S)(scope S delegate(T)op, ref U b,T a=alpha, T t=theta){ static if(is(U S:S[])){ alias StripAllArrays!(U) T; T* bEnd=b.ptr+b.length; diff --git a/src/ocean/math/random/Twister.d b/src/ocean/math/random/Twister.d index eea7f4835..17889707d 100644 --- a/src/ocean/math/random/Twister.d +++ b/src/ocean/math/random/Twister.d @@ -230,7 +230,7 @@ struct Twister void seed (uint s, bool pAddEntropy = false) { - mt[0]= (s + (pAddEntropy ? vLastRand + cast(uint) this : 0)) & 0xffffffffU; + mt[0]= (s + (pAddEntropy ? vLastRand + cast(uint) (&this) : 0)) & 0xffffffffU; for (mti=1; mti> 30)) + mti); mt[mti] &= 0xffffffffU; diff --git a/src/ocean/math/random/Ziggurat.d b/src/ocean/math/random/Ziggurat.d index aa312916c..c3be91107 100644 --- a/src/ocean/math/random/Ziggurat.d +++ b/src/ocean/math/random/Ziggurat.d @@ -31,7 +31,7 @@ import ocean.core.Verify; /// Call style initialization avoided on purpose (this is a big structure, you don't want to return it) struct Ziggurat(RandG,T,alias probDensityF,alias tailGenerator,bool hasNegative=true){ static assert(isRealType!(T),T.stringof~" not acceptable, only floating point variables supported"); - const int nBlocks=256; + enum int nBlocks=256; T[nBlocks+1] posBlock; T[nBlocks+1] fVal; RandG r; @@ -115,7 +115,7 @@ struct Ziggurat(RandG,T,alias probDensityF,alias tailGenerator,bool hasNegative= { uint i0=r.uniform!(uint)(); uint i=i0 & 0xFFU; - const T scaleF=(cast(T)1)/(cast(T)uint.max+1); + enum T scaleF=(cast(T)1)/(cast(T)uint.max+1); T u= (cast(T)i0+cast(T)0.5)*scaleF; T x = posBlock[i]*u; if (x>32); @@ -72,7 +72,7 @@ struct CMWC(uint cmwc_r=1024U,ulong cmwc_a=987769338UL){ return ((cast(ulong)next)<<32)+cast(ulong)next; } - void seed(uint delegate() rSeed){ + void seed(scope uint delegate() rSeed){ cmwc_i=cmwc_r-1u; // randomize also this? for (int ii=0;ii<10;++ii){ for (uint i=0;i>17); kiss_y ^= (kiss_y<<5); @@ -66,7 +66,7 @@ struct Kiss99{ return ((cast(ulong)next)<<32)+cast(ulong)next; } - void seed(uint delegate() r){ + void seed(scope uint delegate() r){ kiss_x = r(); for (int i=0;i<100;++i){ kiss_y=r(); diff --git a/src/ocean/math/random/engines/KissCmwc.d b/src/ocean/math/random/engines/KissCmwc.d index 2c85b01cf..d7102589c 100644 --- a/src/ocean/math/random/engines/KissCmwc.d +++ b/src/ocean/math/random/engines/KissCmwc.d @@ -36,8 +36,8 @@ struct KissCmwc(uint cmwc_r=1024U,ulong cmwc_a=987769338UL){ uint nBytes = 0; uint restB = 0; - const int canCheckpoint=true; - const int canSeed=true; + enum int canCheckpoint=true; + enum int canSeed=true; void skip(uint n){ for (int i=n;i!=n;--i){ @@ -59,9 +59,9 @@ struct KissCmwc(uint cmwc_r=1024U,ulong cmwc_a=987769338UL){ } } uint next(){ - const uint rMask=cmwc_r-1u; + enum uint rMask=cmwc_r-1u; static assert((rMask&cmwc_r)==0,"cmwc_r is supposed to be a power of 2"); // put a more stringent test? - const uint m=0xFFFF_FFFE; + enum uint m=0xFFFF_FFFE; cmwc_i=(cmwc_i+1)&rMask; ulong t=cmwc_a*cmwc_q[cmwc_i]+cmwc_c; cmwc_c=cast(uint)(t>>32); @@ -69,7 +69,7 @@ struct KissCmwc(uint cmwc_r=1024U,ulong cmwc_a=987769338UL){ if (x>17); kiss_y ^= (kiss_y<<5); @@ -82,7 +82,7 @@ struct KissCmwc(uint cmwc_r=1024U,ulong cmwc_a=987769338UL){ return ((cast(ulong)next)<<32)+cast(ulong)next; } - void seed(uint delegate() rSeed){ + void seed(scope uint delegate() rSeed){ kiss_x = rSeed(); for (int i=0;i<100;++i){ kiss_y=rSeed(); diff --git a/src/ocean/math/random/engines/Twister.d b/src/ocean/math/random/engines/Twister.d index ca0a0d26e..a3d78a00f 100644 --- a/src/ocean/math/random/engines/Twister.d +++ b/src/ocean/math/random/engines/Twister.d @@ -61,8 +61,8 @@ struct Twister UPPER_MASK = 0x80000000, // most significant w-r bits LOWER_MASK = 0x7fffffff, // least significant r bits } - const int canCheckpoint=true; - const int canSeed=true; + enum int canCheckpoint=true; + enum int canSeed=true; private uint[N] mt; // the array for the state vector private uint mti=mt.length+1; // mti==mt.length+1 means mt[] is not initialized @@ -119,7 +119,7 @@ struct Twister } } /// adds entropy to the generator - void addEntropy(uint delegate() r){ + void addEntropy(scope uint delegate() r){ int i, j, k; i=1; j=0; @@ -150,7 +150,7 @@ struct Twister mti=0; } /// seeds the generator - void seed(uint delegate() r){ + void seed(scope uint delegate() r){ seed (19650218UL); addEntropy(r); } diff --git a/src/ocean/math/random/engines/URandom.d b/src/ocean/math/random/engines/URandom.d index ef34d516a..580153690 100644 --- a/src/ocean/math/random/engines/URandom.d +++ b/src/ocean/math/random/engines/URandom.d @@ -33,8 +33,8 @@ struct URandom{ readStyle.cache =File.Cache.None; } - const int canCheckpoint=false; - const int canSeed=false; + enum int canCheckpoint=false; + enum int canSeed=false; void skip(uint n){ } ubyte nextB(){ @@ -77,7 +77,7 @@ struct URandom{ return el.l; } /// does nothing - void seed(uint delegate() r) { } + void seed(scope uint delegate() r) { } /// writes the current status in a string istring toString(){ return "URandom"; diff --git a/src/ocean/meta/codegen/Identifier.d b/src/ocean/meta/codegen/Identifier.d index 613fa6006..bbc18e6dc 100644 --- a/src/ocean/meta/codegen/Identifier.d +++ b/src/ocean/meta/codegen/Identifier.d @@ -44,9 +44,9 @@ version (UnitTest) public template identifier ( alias Sym ) { static if (is(typeof(Sym) == function)) - const identifier = funcIdentifierHack!(Sym)(); + static immutable identifier = funcIdentifierHack!(Sym)(); else - const identifier = Sym.stringof; + static immutable identifier = Sym.stringof; } /// @@ -110,7 +110,7 @@ private istring funcIdentifierHack(alias Sym)() public template fieldIdentifier ( T, size_t i ) { - const istring fieldIdentifier = stripQualifiedPrefix(T.tupleof[i].stringof); + static immutable istring fieldIdentifier = stripQualifiedPrefix(T.tupleof[i].stringof); } unittest diff --git a/src/ocean/meta/traits/Aggregates.d b/src/ocean/meta/traits/Aggregates.d index 9d33c93bc..127134677 100644 --- a/src/ocean/meta/traits/Aggregates.d +++ b/src/ocean/meta/traits/Aggregates.d @@ -80,10 +80,10 @@ public template hasMethod ( T, istring name, F ) { static if (hasMember!(T, name)) { - const hasMethod = is(typeof(mixin("&T.init." ~ name)) : F); + static immutable hasMethod = is(typeof(mixin("&T.init." ~ name)) : F); } else - const hasMethod = false; + static immutable hasMethod = false; } /// diff --git a/src/ocean/meta/traits/Arrays.d b/src/ocean/meta/traits/Arrays.d index a1d10d70f..93eaf05e5 100644 --- a/src/ocean/meta/traits/Arrays.d +++ b/src/ocean/meta/traits/Arrays.d @@ -34,7 +34,7 @@ import ocean.meta.types.Qualifiers; template isUTF8StringType ( T ) { - const isUTF8StringType = + static immutable isUTF8StringType = isArrayType!(T) == ArrayKind.Dynamic && is(Unqual!(ElementTypeOf!(T)) == char); } diff --git a/src/ocean/meta/traits/Basic.d b/src/ocean/meta/traits/Basic.d index 79a6f1201..6c053955e 100644 --- a/src/ocean/meta/traits/Basic.d +++ b/src/ocean/meta/traits/Basic.d @@ -49,7 +49,7 @@ import ocean.meta.types.Typedef; public template isPrimitiveType ( T ) { - const isPrimitiveType = + static immutable isPrimitiveType = is(Unqual!(T) == void) || is(Unqual!(T) == bool) || isIntegerType!(T) @@ -78,7 +78,7 @@ unittest public template isCharType ( T ) { - const bool isCharType = + static immutable bool isCharType = is(Unqual!(T) == char) || is(Unqual!(T) == wchar) || is(Unqual!(T) == dchar); @@ -104,7 +104,7 @@ unittest public template isSignedIntegerType ( T ) { - const bool isSignedIntegerType = + static immutable bool isSignedIntegerType = is(Unqual!(T) == byte) || is(Unqual!(T) == short) || is(Unqual!(T) == int) @@ -131,7 +131,7 @@ unittest public template isUnsignedIntegerType ( T ) { - const bool isUnsignedIntegerType = + static immutable bool isUnsignedIntegerType = is(Unqual!(T) == ubyte) || is(Unqual!(T) == ushort) || is(Unqual!(T) == uint) @@ -158,7 +158,7 @@ unittest public template isIntegerType ( T ) { - const bool isIntegerType = + static immutable bool isIntegerType = isSignedIntegerType!(T) || isUnsignedIntegerType!(T); } @@ -184,7 +184,7 @@ unittest public template isRealType ( T ) { - const bool isRealType = + static immutable bool isRealType = is( Unqual!(T) == float ) || is( Unqual!(T) == double ) || is( Unqual!(T) == real ); @@ -211,7 +211,7 @@ unittest public template isComplexType( T ) { - const bool isComplexType = + static immutable bool isComplexType = is( Unqual!(T) == cfloat ) || is( Unqual!(T) == cdouble ) || is( Unqual!(T) == creal ); @@ -237,7 +237,7 @@ unittest public template isImaginaryType( T ) { - const bool isImaginaryType = + static immutable bool isImaginaryType = is( Unqual!(T) == ifloat ) || is( Unqual!(T) == idouble ) || is( Unqual!(T) == ireal ); @@ -264,7 +264,7 @@ unittest public template isFloatingPointType( T ) { - const bool isFloatingPointType = + static immutable bool isFloatingPointType = isRealType!(T) || isComplexType!(T) || isImaginaryType!(T); @@ -311,14 +311,14 @@ public enum ArrayKind public template isArrayType ( T ) { static if (is(Unqual!(T) U == U[])) - const isArrayType = ArrayKind.Dynamic; + static immutable isArrayType = ArrayKind.Dynamic; else static if (is(Unqual!(T) U : U[])) - const isArrayType = ArrayKind.Static; + static immutable isArrayType = ArrayKind.Static; else static if (is(typeof(T.init.values[0])[typeof(T.init.keys[0])] == Unqual!(T))) - const isArrayType = ArrayKind.Associative; + static immutable isArrayType = ArrayKind.Associative; else - const isArrayType = ArrayKind.NotArray; + static immutable isArrayType = ArrayKind.NotArray; } /// @@ -352,7 +352,7 @@ unittest public template isBasicArrayType ( T ) { - const isBasicArrayType = + static immutable isBasicArrayType = (isArrayType!(T) == ArrayKind.Static) || (isArrayType!(T) == ArrayKind.Dynamic); } @@ -377,7 +377,7 @@ unittest public template staticArrayLength ( T : U[Dim], U, size_t Dim ) { - const staticArrayLength = Dim; + static immutable staticArrayLength = Dim; } unittest @@ -400,9 +400,9 @@ unittest template isPointerType ( T ) { static if (is(Unqual!(T) U == U*)) - const isPointerType = true; + static immutable isPointerType = true; else - const isPointerType = false; + static immutable isPointerType = false; } /// @@ -455,7 +455,7 @@ unittest template isReferenceType ( T ) { - const isReferenceType = + static immutable isReferenceType = isPointerType!(T) || is(T == delegate) || isArrayType!(T) == ArrayKind.Dynamic @@ -495,7 +495,7 @@ unittest template isAggregateType ( T ) { - const isAggregateType = + static immutable isAggregateType = is(T == class) || is(T == interface) || is(T == struct) @@ -525,7 +525,7 @@ unittest template isFunctionType ( T ) { - const bool isFunctionType = + static immutable bool isFunctionType = is(T == function) || is(typeof(*T.init) == function) || is(T == delegate); @@ -584,9 +584,9 @@ unittest template isCallableType ( T ) { static if (is(typeof(T.opCall))) - const isCallableType = isFunctionType!(typeof(&T.init.opCall)); + static immutable isCallableType = isFunctionType!(typeof(&T.init.opCall)); else - const isCallableType = isFunctionType!(T); + static immutable isCallableType = isFunctionType!(T); } /// @@ -647,9 +647,9 @@ public template isTypedef (T) version (D_Version2) { static if (is(T.IsTypedef)) - const isTypedef = TypedefKind.Struct; + static immutable isTypedef = TypedefKind.Struct; else - const isTypedef = TypedefKind.None; + static immutable isTypedef = TypedefKind.None; } else { diff --git a/src/ocean/meta/traits/Indirections.d b/src/ocean/meta/traits/Indirections.d index 7232ec19e..add15c7ec 100644 --- a/src/ocean/meta/traits/Indirections.d +++ b/src/ocean/meta/traits/Indirections.d @@ -50,7 +50,7 @@ version(UnitTest) public template hasIndirections ( T... ) { - const hasIndirections = ReduceType!(T, HasIndirectionsReducer); + static immutable hasIndirections = ReduceType!(T, HasIndirectionsReducer); } /// @@ -129,7 +129,7 @@ private struct HasIndirectionsReducer public template containsMultiDimensionalDynamicArrays ( T ) { - const containsMultiDimensionalDynamicArrays = + static immutable containsMultiDimensionalDynamicArrays = ReduceType!(T, MultiDimArraysReducer); } @@ -224,7 +224,7 @@ unittest public template containsDynamicArray ( T ) { - const containsDynamicArray = + static immutable containsDynamicArray = ReduceType!(T, DynArrayReducer); } diff --git a/src/ocean/meta/types/ReduceType.d b/src/ocean/meta/types/ReduceType.d index e6588a9ea..ae8b90d3b 100644 --- a/src/ocean/meta/types/ReduceType.d +++ b/src/ocean/meta/types/ReduceType.d @@ -80,7 +80,7 @@ import ocean.meta.types.Typedef; public template ReduceType ( T, Reducer ) { - const ReduceType = ReduceTypeImpl!(Reducer).init.reduce!(T)(); + static immutable ReduceType = ReduceTypeImpl!(Reducer).init.reduce!(T)(); } /******************************************************************************* diff --git a/src/ocean/meta/types/ReduceType_test.d b/src/ocean/meta/types/ReduceType_test.d index 8a12b809e..28e837aba 100644 --- a/src/ocean/meta/types/ReduceType_test.d +++ b/src/ocean/meta/types/ReduceType_test.d @@ -20,7 +20,7 @@ import ocean.meta.types.ReduceType; struct ExampleReducer { alias int Result; - const seed = 0; + enum seed = 0; Result accumulate ( Result accum, Result next ) { @@ -46,7 +46,7 @@ unittest struct CountSubTypes { alias int Result; - const seed = 0; + enum seed = 0; Result accumulate ( Result accum, Result next ) { diff --git a/src/ocean/meta/values/Reset_test.d b/src/ocean/meta/values/Reset_test.d index a7b05c9c6..849e6b3ee 100644 --- a/src/ocean/meta/values/Reset_test.d +++ b/src/ocean/meta/values/Reset_test.d @@ -28,13 +28,13 @@ unittest void InitStructure() { - this.h = -52; - this.i.copy("even even more test text"); - this.j.length = 3; - this.j[0].copy("abc"); - this.j[1].copy("def"); - this.j[2].copy("ghi"); - foreach ( ref item; this.k ) + (&this).h = -52; + (&this).i.copy("even even more test text"); + (&this).j.length = 3; + (&this).j[0].copy("abc"); + (&this).j[1].copy("def"); + (&this).j[2].copy("ghi"); + foreach ( ref item; (&this).k ) { item = 120000; } @@ -43,12 +43,12 @@ unittest void InitStructure() { - this.d = 32; - this.e.copy("even more test text"); + (&this).d = 32; + (&this).e.copy("even more test text"); - this.f.length = 1; - this.f[0].copy("abc"); - foreach ( ref item; this.g ) + (&this).f.length = 1; + (&this).f[0].copy("abc"); + foreach ( ref item; (&this).g ) { item = 32400; } diff --git a/src/ocean/meta/values/VisitValue.d b/src/ocean/meta/values/VisitValue.d index 2b5d5c25c..483c617cb 100644 --- a/src/ocean/meta/values/VisitValue.d +++ b/src/ocean/meta/values/VisitValue.d @@ -100,7 +100,7 @@ private struct VisitImpl ( Visitor ) private void visitAll ( T ) ( T* value ) { - auto deeper = this.visitor.visit(value); + auto deeper = (&this).visitor.visit(value); if (!deeper) return; @@ -112,7 +112,7 @@ private struct VisitImpl ( Visitor ) else static if (isTypedef!(T)) { auto reinterp = cast(TypedefBaseType!(T)*) value; - this.visitAll(reinterp); + (&this).visitAll(reinterp); } else static if (isAggregateType!(T)) { @@ -130,7 +130,7 @@ private struct VisitImpl ( Visitor ) static if (Base.init.tupleof.length) { Base base = *value; // implicit upcast - this.visitAll(&base); + (&this).visitAll(&base); } } } @@ -140,7 +140,7 @@ private struct VisitImpl ( Visitor ) { foreach (ref field; (*value).tupleof) { - this.visitAll(&field); + (&this).visitAll(&field); } } } @@ -151,7 +151,7 @@ private struct VisitImpl ( Visitor ) || isArrayType!(T) == ArrayKind.Dynamic) { foreach (ref elem; *value) - this.visitAll(&elem); + (&this).visitAll(&elem); } else { @@ -165,12 +165,12 @@ private struct VisitImpl ( Visitor ) else static if (isPointerType!(T)) { if (*value !is null) - this.visitAll(*value); + (&this).visitAll(*value); } else static if (is(T U == enum)) { auto reinterp = cast(U*) value; - this.visitAll(reinterp); + (&this).visitAll(reinterp); } else { diff --git a/src/ocean/net/Uri.d b/src/ocean/net/Uri.d index 146dd6a53..0cce4e4fd 100644 --- a/src/ocean/net/Uri.d +++ b/src/ocean/net/Uri.d @@ -75,7 +75,7 @@ class Uri : UriView private static short[istring] genericSchemes; - private const istring hexDigits = "0123456789abcdef"; + private static immutable istring hexDigits = "0123456789abcdef"; private static Const!(SchemePort[]) schemePorts = [ {"coffee", 80}, @@ -434,7 +434,7 @@ class Uri : UriView ***********************************************************************/ - final size_t produce (Consumer consume) + final size_t produce (scope Consumer consume) { size_t ret; @@ -508,7 +508,7 @@ class Uri : UriView ***********************************************************************/ - static size_t encode (Consumer consume, cstring s, int flags) + static size_t encode (scope Consumer consume, cstring s, int flags) { size_t ret; char[3] hex; diff --git a/src/ocean/net/collectd/Collectd.d b/src/ocean/net/collectd/Collectd.d index 5e46811c7..25aecacb8 100644 --- a/src/ocean/net/collectd/Collectd.d +++ b/src/ocean/net/collectd/Collectd.d @@ -396,7 +396,7 @@ public final class Collectd ***************************************************************************/ - private const istring PutvalSuccessLineBegin = "0 Success: "; + private static immutable istring PutvalSuccessLineBegin = "0 Success: "; /*************************************************************************** diff --git a/src/ocean/net/collectd/Identifier.d b/src/ocean/net/collectd/Identifier.d index 18f4eeaf8..697c8fbde 100644 --- a/src/ocean/net/collectd/Identifier.d +++ b/src/ocean/net/collectd/Identifier.d @@ -125,9 +125,9 @@ public struct Identifier invariant () { - assert(this.host.length, "No host for identifier"); - assert(this.plugin.length, "No plugin for identifier"); - assert(this.type.length, "No type for identifier"); + assert((&this).host.length, "No host for identifier"); + assert((&this).plugin.length, "No plugin for identifier"); + assert((&this).type.length, "No type for identifier"); } @@ -361,11 +361,11 @@ public struct Identifier public istring toString () { - auto pi = this.plugin_instance.length ? "-" : null; - auto ti = this.type_instance.length ? "-" : null; + auto pi = (&this).plugin_instance.length ? "-" : null; + auto ti = (&this).type_instance.length ? "-" : null; - return format("{}/{}{}{}/{}{}{}", this.host, - this.plugin, pi, this.plugin_instance, - this.type, ti, this.type_instance); + return format("{}/{}{}{}/{}{}{}", (&this).host, + (&this).plugin, pi, (&this).plugin_instance, + (&this).type, ti, (&this).type_instance); } } diff --git a/src/ocean/net/collectd/SocketReader.d b/src/ocean/net/collectd/SocketReader.d index 7dc6c49b9..c65b09917 100644 --- a/src/ocean/net/collectd/SocketReader.d +++ b/src/ocean/net/collectd/SocketReader.d @@ -67,7 +67,7 @@ package struct SocketReader (size_t MAX_FIELD_SIZE = 512, size_t FIELDS = 16) public cstring front () { - return this.current_field; + return (&this).current_field; } @@ -94,46 +94,46 @@ package struct SocketReader (size_t MAX_FIELD_SIZE = 512, size_t FIELDS = 16) public ssize_t popFront (ISocket socket = null, int flags = 0) { - auto off = this.locateChar('\n'); + auto off = (&this).locateChar('\n'); - if (off != this.length) + if (off != (&this).length) { // Worst case scenario: the field starts at the end of the buffer // and continues at the beginning. In this case, we have no choice // but to copy data to our field_buffer to get something sane. - if (this.start_idx + off > this.buffer.length) + if ((&this).start_idx + off > (&this).buffer.length) { - auto p1len = this.buffer.length - this.start_idx; + auto p1len = (&this).buffer.length - (&this).start_idx; verify(p1len < off); - this.field_buffer[0 .. p1len] - = this.buffer[this.start_idx .. this.buffer.length]; + (&this).field_buffer[0 .. p1len] + = (&this).buffer[(&this).start_idx .. (&this).buffer.length]; - this.field_buffer[p1len .. off] = this.buffer[0 .. off - p1len]; + (&this).field_buffer[p1len .. off] = (&this).buffer[0 .. off - p1len]; - this.current_field = this.field_buffer[0 .. off]; + (&this).current_field = (&this).field_buffer[0 .. off]; } else { // Usual case: We just return a slice to our buffer - this.current_field = this.buffer[this.start_idx .. this.start_idx + off]; + (&this).current_field = (&this).buffer[(&this).start_idx .. (&this).start_idx + off]; } - this.length -= (off + 1); - this.start_idx = !this.length ? 0 : this.calc(this.start_idx, off + 1); + (&this).length -= (off + 1); + (&this).start_idx = !(&this).length ? 0 : (&this).calc((&this).start_idx, off + 1); } else if (socket !is null) { - auto r = this.recv(socket, flags); + auto r = (&this).recv(socket, flags); if (r <= 0) { - this.current_field = null; - throw this.e.useGlobalErrno("recv"); + (&this).current_field = null; + throw (&this).e.useGlobalErrno("recv"); } - this.popFront(socket, flags); + (&this).popFront(socket, flags); } else { - this.current_field = null; + (&this).current_field = null; } return 0; } @@ -150,7 +150,7 @@ package struct SocketReader (size_t MAX_FIELD_SIZE = 512, size_t FIELDS = 16) public bool empty () { - return this.current_field is null; + return (&this).current_field is null; } @@ -174,17 +174,17 @@ package struct SocketReader (size_t MAX_FIELD_SIZE = 512, size_t FIELDS = 16) { verify(socket !is null, "Cannot recv with a null socket"); - auto start = this.calc(this.start_idx, this.length); - auto end = start < this.start_idx ? this.start_idx : this.buffer.length; + auto start = (&this).calc((&this).start_idx, (&this).length); + auto end = start < (&this).start_idx ? (&this).start_idx : (&this).buffer.length; - ssize_t ret = socket.recv(this.buffer[start .. end], flags); + ssize_t ret = socket.recv((&this).buffer[start .. end], flags); // Errors are handled from popFront if (ret <= 0) return ret; - this.length += ret; - verify(this.length <= this.buffer.length); + (&this).length += ret; + verify((&this).length <= (&this).buffer.length); return ret; } @@ -199,7 +199,7 @@ package struct SocketReader (size_t MAX_FIELD_SIZE = 512, size_t FIELDS = 16) private bool isLinear () { - return !(this.start_idx + this.length > this.buffer.length); + return !((&this).start_idx + (&this).length > (&this).buffer.length); } @@ -215,9 +215,9 @@ package struct SocketReader (size_t MAX_FIELD_SIZE = 512, size_t FIELDS = 16) private size_t linearEnd () { - return this.isLinear() - ? (this.start_idx + this.length) - : (this.buffer.length); + return (&this).isLinear() + ? ((&this).start_idx + (&this).length) + : ((&this).buffer.length); } @@ -229,9 +229,9 @@ package struct SocketReader (size_t MAX_FIELD_SIZE = 512, size_t FIELDS = 16) private size_t linearSpace () { - return this.isLinear() - ? (this.buffer.length - this.calc(this.start_idx, this.length)) - : (this.start_idx - this.calc(this.start_idx, this.length)); + return (&this).isLinear() + ? ((&this).buffer.length - (&this).calc((&this).start_idx, (&this).length)) + : ((&this).start_idx - (&this).calc((&this).start_idx, (&this).length)); } @@ -251,14 +251,14 @@ package struct SocketReader (size_t MAX_FIELD_SIZE = 512, size_t FIELDS = 16) private size_t locateChar (char tok) { auto after = StringSearch!(false).locateChar( - this.buffer[this.start_idx .. this.linearEnd()], tok); - if (this.isLinear() || this.start_idx + after < this.buffer.length) + (&this).buffer[(&this).start_idx .. (&this).linearEnd()], tok); + if ((&this).isLinear() || (&this).start_idx + after < (&this).buffer.length) { return after; } // In this case, after ==> buffer.length - start_idx return after + StringSearch!(false).locateChar( - this.buffer[0 .. this.length - after], + (&this).buffer[0 .. (&this).length - after], tok); } @@ -278,7 +278,7 @@ package struct SocketReader (size_t MAX_FIELD_SIZE = 512, size_t FIELDS = 16) private size_t calc (size_t idx, size_t val) { - return (idx + val) % this.buffer.length; + return (idx + val) % (&this).buffer.length; } diff --git a/src/ocean/net/http/HttpConnectionHandler.d b/src/ocean/net/http/HttpConnectionHandler.d index 1794829ce..0a4b4c501 100644 --- a/src/ocean/net/http/HttpConnectionHandler.d +++ b/src/ocean/net/http/HttpConnectionHandler.d @@ -122,7 +122,7 @@ abstract class HttpConnectionHandler : IFiberConnectionHandler **************************************************************************/ - protected this ( EpollSelectDispatcher dispatcher, FinalizeDg finalizer, + protected this ( EpollSelectDispatcher dispatcher, scope FinalizeDg finalizer, size_t stack_size, HttpMethod[] supported_methods ... ) { @@ -147,7 +147,7 @@ abstract class HttpConnectionHandler : IFiberConnectionHandler **************************************************************************/ - protected this ( EpollSelectDispatcher dispatcher, FinalizeDg finalizer, + protected this ( EpollSelectDispatcher dispatcher, scope FinalizeDg finalizer, size_t stack_size, HttpRequest request, HttpResponse response, HttpMethod[] supported_methods ... ) diff --git a/src/ocean/net/http/HttpConst.d b/src/ocean/net/http/HttpConst.d index 765b187c4..2360f80e6 100644 --- a/src/ocean/net/http/HttpConst.d +++ b/src/ocean/net/http/HttpConst.d @@ -27,7 +27,7 @@ import ocean.transition; struct HttpConst { - const istring Eol = "\r\n"; + enum istring Eol = "\r\n"; } /******************************************************************************* @@ -51,66 +51,66 @@ struct HttpHeaderName struct HttpHeader { // size of both the request & response buffer (per thread) - const int IOBufferSize = 16 * 1024; + enum int IOBufferSize = 16 * 1024; // maximum length for POST parameters (to avoid DOS ...) - const int MaxPostParamSize = 4 * 1024; - - const HttpHeaderName Version = {"HTTP/1.1"}; - const HttpHeaderName TextHtml = {"text/html"}; - - const HttpHeaderName Accept = {"Accept:"}; - const HttpHeaderName AcceptCharset = {"Accept-Charset:"}; - const HttpHeaderName AcceptEncoding = {"Accept-Encoding:"}; - const HttpHeaderName AcceptLanguage = {"Accept-Language:"}; - const HttpHeaderName AcceptRanges = {"Accept-Ranges:"}; - const HttpHeaderName Age = {"Age:"}; - const HttpHeaderName Allow = {"Allow:"}; - const HttpHeaderName Authorization = {"Authorization:"}; - const HttpHeaderName CacheControl = {"Cache-Control:"}; - const HttpHeaderName Connection = {"Connection:"}; - const HttpHeaderName ContentEncoding = {"Content-Encoding:"}; - const HttpHeaderName ContentLanguage = {"Content-Language:"}; - const HttpHeaderName ContentLength = {"Content-Length:"}; - const HttpHeaderName ContentLocation = {"Content-Location:"}; - const HttpHeaderName ContentRange = {"Content-Range:"}; - const HttpHeaderName ContentType = {"Content-Type:"}; - const HttpHeaderName Cookie = {"Cookie:"}; - const HttpHeaderName Date = {"Date:"}; - const HttpHeaderName ETag = {"ETag:"}; - const HttpHeaderName Expect = {"Expect:"}; - const HttpHeaderName Expires = {"Expires:"}; - const HttpHeaderName From = {"From:"}; - const HttpHeaderName Host = {"Host:"}; - const HttpHeaderName Identity = {"Identity:"}; - const HttpHeaderName IfMatch = {"If-Match:"}; - const HttpHeaderName IfModifiedSince = {"If-Modified-Since:"}; - const HttpHeaderName IfNoneMatch = {"If-None-Match:"}; - const HttpHeaderName IfRange = {"If-Range:"}; - const HttpHeaderName IfUnmodifiedSince = {"If-Unmodified-Since:"}; - const HttpHeaderName KeepAlive = {"Keep-Alive:"}; - const HttpHeaderName LastModified = {"Last-Modified:"}; - const HttpHeaderName Location = {"Location:"}; - const HttpHeaderName MaxForwards = {"Max-Forwards:"}; - const HttpHeaderName MimeVersion = {"MIME-Version:"}; - const HttpHeaderName Pragma = {"Pragma:"}; - const HttpHeaderName ProxyAuthenticate = {"Proxy-Authenticate:"}; - const HttpHeaderName ProxyConnection = {"Proxy-Connection:"}; - const HttpHeaderName Range = {"Range:"}; - const HttpHeaderName Referrer = {"Referer:"}; - const HttpHeaderName RetryAfter = {"Retry-After:"}; - const HttpHeaderName Server = {"Server:"}; - const HttpHeaderName ServletEngine = {"Servlet-Engine:"}; - const HttpHeaderName SetCookie = {"Set-Cookie:"}; - const HttpHeaderName SetCookie2 = {"Set-Cookie2:"}; - const HttpHeaderName TE = {"TE:"}; - const HttpHeaderName Trailer = {"Trailer:"}; - const HttpHeaderName TransferEncoding = {"Transfer-Encoding:"}; - const HttpHeaderName Upgrade = {"Upgrade:"}; - const HttpHeaderName UserAgent = {"User-Agent:"}; - const HttpHeaderName Vary = {"Vary:"}; - const HttpHeaderName Warning = {"Warning:"}; - const HttpHeaderName WwwAuthenticate = {"WWW-Authenticate:"}; + enum int MaxPostParamSize = 4 * 1024; + + enum HttpHeaderName Version = {"HTTP/1.1"}; + enum HttpHeaderName TextHtml = {"text/html"}; + + enum HttpHeaderName Accept = {"Accept:"}; + enum HttpHeaderName AcceptCharset = {"Accept-Charset:"}; + enum HttpHeaderName AcceptEncoding = {"Accept-Encoding:"}; + enum HttpHeaderName AcceptLanguage = {"Accept-Language:"}; + enum HttpHeaderName AcceptRanges = {"Accept-Ranges:"}; + enum HttpHeaderName Age = {"Age:"}; + enum HttpHeaderName Allow = {"Allow:"}; + enum HttpHeaderName Authorization = {"Authorization:"}; + enum HttpHeaderName CacheControl = {"Cache-Control:"}; + enum HttpHeaderName Connection = {"Connection:"}; + enum HttpHeaderName ContentEncoding = {"Content-Encoding:"}; + enum HttpHeaderName ContentLanguage = {"Content-Language:"}; + enum HttpHeaderName ContentLength = {"Content-Length:"}; + enum HttpHeaderName ContentLocation = {"Content-Location:"}; + enum HttpHeaderName ContentRange = {"Content-Range:"}; + enum HttpHeaderName ContentType = {"Content-Type:"}; + enum HttpHeaderName Cookie = {"Cookie:"}; + enum HttpHeaderName Date = {"Date:"}; + enum HttpHeaderName ETag = {"ETag:"}; + enum HttpHeaderName Expect = {"Expect:"}; + enum HttpHeaderName Expires = {"Expires:"}; + enum HttpHeaderName From = {"From:"}; + enum HttpHeaderName Host = {"Host:"}; + enum HttpHeaderName Identity = {"Identity:"}; + enum HttpHeaderName IfMatch = {"If-Match:"}; + enum HttpHeaderName IfModifiedSince = {"If-Modified-Since:"}; + enum HttpHeaderName IfNoneMatch = {"If-None-Match:"}; + enum HttpHeaderName IfRange = {"If-Range:"}; + enum HttpHeaderName IfUnmodifiedSince = {"If-Unmodified-Since:"}; + enum HttpHeaderName KeepAlive = {"Keep-Alive:"}; + enum HttpHeaderName LastModified = {"Last-Modified:"}; + enum HttpHeaderName Location = {"Location:"}; + enum HttpHeaderName MaxForwards = {"Max-Forwards:"}; + enum HttpHeaderName MimeVersion = {"MIME-Version:"}; + enum HttpHeaderName Pragma = {"Pragma:"}; + enum HttpHeaderName ProxyAuthenticate = {"Proxy-Authenticate:"}; + enum HttpHeaderName ProxyConnection = {"Proxy-Connection:"}; + enum HttpHeaderName Range = {"Range:"}; + enum HttpHeaderName Referrer = {"Referer:"}; + enum HttpHeaderName RetryAfter = {"Retry-After:"}; + enum HttpHeaderName Server = {"Server:"}; + enum HttpHeaderName ServletEngine = {"Servlet-Engine:"}; + enum HttpHeaderName SetCookie = {"Set-Cookie:"}; + enum HttpHeaderName SetCookie2 = {"Set-Cookie2:"}; + enum HttpHeaderName TE = {"TE:"}; + enum HttpHeaderName Trailer = {"Trailer:"}; + enum HttpHeaderName TransferEncoding = {"Transfer-Encoding:"}; + enum HttpHeaderName Upgrade = {"Upgrade:"}; + enum HttpHeaderName UserAgent = {"User-Agent:"}; + enum HttpHeaderName Vary = {"Vary:"}; + enum HttpHeaderName Warning = {"Warning:"}; + enum HttpHeaderName WwwAuthenticate = {"WWW-Authenticate:"}; } diff --git a/src/ocean/net/http/HttpCookies.d b/src/ocean/net/http/HttpCookies.d index b7c5d3452..90b2f704a 100644 --- a/src/ocean/net/http/HttpCookies.d +++ b/src/ocean/net/http/HttpCookies.d @@ -191,7 +191,7 @@ class Cookie //: IWritable ***********************************************************************/ - void produce (size_t delegate(Const!(void)[]) consume) + void produce (scope size_t delegate(Const!(void)[]) consume) { consume (name); @@ -310,7 +310,7 @@ class CookieStack **********************************************************************/ - int opApply (int delegate(ref Cookie) dg) + int opApply (scope int delegate(ref Cookie) dg) { int result = 0; @@ -373,7 +373,7 @@ class HttpCookiesView //: IWritable **********************************************************************/ - void produce (size_t delegate(Const!(void)[]) consume, istring eol = HttpConst.Eol) + void produce (scope size_t delegate(Const!(void)[]) consume, istring eol = HttpConst.Eol) { foreach (cookie; parse) cookie.produce (consume), consume (eol); diff --git a/src/ocean/net/http/HttpHeaders.d b/src/ocean/net/http/HttpHeaders.d index d4157959e..90df60823 100644 --- a/src/ocean/net/http/HttpHeaders.d +++ b/src/ocean/net/http/HttpHeaders.d @@ -174,7 +174,7 @@ class HttpHeadersView : HttpTokens **********************************************************************/ - int opApply (int delegate(ref HeaderElement) dg) + int opApply (scope int delegate(ref HeaderElement) dg) { HeaderElement element; int result = 0; @@ -231,7 +231,7 @@ class HttpHeadersView : HttpTokens **************************************************************/ - int opApply (int delegate(ref HeaderElement) dg) + int opApply (scope int delegate(ref HeaderElement) dg) { HeaderElement element; int result = 0; @@ -301,7 +301,7 @@ class HttpHeaders : HttpHeadersView **********************************************************************/ - void add (HttpHeaderName name, void delegate(OutputBuffer) dg) + void add (HttpHeaderName name, scope void delegate(OutputBuffer) dg) { super.add (name.value, dg); } diff --git a/src/ocean/net/http/HttpParams.d b/src/ocean/net/http/HttpParams.d index d02562ca3..bc6bf6c70 100644 --- a/src/ocean/net/http/HttpParams.d +++ b/src/ocean/net/http/HttpParams.d @@ -168,7 +168,7 @@ class HttpParams : HttpTokens, HttpParamsView **********************************************************************/ - override void produce (size_t delegate(Const!(void)[]) consume, cstring eol=null) + override void produce (scope size_t delegate(Const!(void)[]) consume, cstring eol=null) { return super.produce (consume, eol); } diff --git a/src/ocean/net/http/HttpRequest.d b/src/ocean/net/http/HttpRequest.d index b692e3681..c97a4de7a 100644 --- a/src/ocean/net/http/HttpRequest.d +++ b/src/ocean/net/http/HttpRequest.d @@ -497,7 +497,7 @@ version ( UnitTest ) unittest { - const istring lorem_ipsum = + static immutable istring lorem_ipsum = "Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod " ~ "tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim " ~ "veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex " @@ -552,7 +552,7 @@ unittest ~ "kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit " ~ "amet."; - const istring content = + static immutable istring content = "GET /dir?query=Hello%20World!&abc=def&ghi HTTP/1.1\r\n" ~ "Host: www.example.org:12345\r\n" ~ "User-Agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.2.17) Gecko/20110422 Ubuntu/9.10 (karmic) Firefox/3.6.17\r\n" @@ -566,7 +566,7 @@ unittest ~ "\r\n" ~ lorem_ipsum; - const parts = 3; + static immutable parts = 3; /* * content will be split into parts parts where the length of each part is @@ -576,7 +576,7 @@ unittest static size_t random_chunk_length ( ) { - const c = content.length * (2.0f / (parts * 3)); + static immutable c = content.length * (2.0f / (parts * 3)); static assert (c >= 3, "too many parts"); @@ -591,11 +591,11 @@ unittest version (OceanPerformanceTest) { - const n = 1000_000; + static immutable n = 1000_000; } else { - const n = 10; + static immutable n = 10; } version (OceanPerformanceTest) diff --git a/src/ocean/net/http/HttpStack.d b/src/ocean/net/http/HttpStack.d index 2cad3a35b..ec3c57d21 100644 --- a/src/ocean/net/http/HttpStack.d +++ b/src/ocean/net/http/HttpStack.d @@ -81,7 +81,7 @@ class HttpStack private int depth; private Token[] tokens; - private const int MaxHttpStackSize = 256; + private static immutable int MaxHttpStackSize = 256; /********************************************************************** @@ -122,7 +122,7 @@ class HttpStack **********************************************************************/ - int opApply (int delegate(ref Token) dg) + int opApply (scope int delegate(ref Token) dg) { int result = 0; diff --git a/src/ocean/net/http/HttpTokens.d b/src/ocean/net/http/HttpTokens.d index 33cb30a36..103baef92 100644 --- a/src/ocean/net/http/HttpTokens.d +++ b/src/ocean/net/http/HttpTokens.d @@ -237,7 +237,7 @@ class HttpTokens **********************************************************************/ - int opApply (int delegate(ref HttpToken) dg) + int opApply (scope int delegate(ref HttpToken) dg) { HttpToken element; int result = 0; @@ -258,7 +258,7 @@ class HttpTokens **********************************************************************/ - void produce (size_t delegate(Const!(void)[]) consume, cstring eol = null) + void produce (scope size_t delegate(Const!(void)[]) consume, cstring eol = null) { foreach (Token token; stack) { @@ -359,7 +359,7 @@ class HttpTokens **************************************************************/ - int opApply (int delegate(ref HttpToken) dg) + int opApply (scope int delegate(ref HttpToken) dg) { HttpToken element; int result = 0; @@ -455,7 +455,7 @@ class HttpTokens **********************************************************************/ - protected void add (cstring name, void delegate(OutputBuffer) value) + protected void add (cstring name, scope void delegate(OutputBuffer) value) { // save the buffer write-position //int prior = output.limit; diff --git a/src/ocean/net/http/TaskHttpConnectionHandler.d b/src/ocean/net/http/TaskHttpConnectionHandler.d index bec4c0ac8..20346dcd9 100644 --- a/src/ocean/net/http/TaskHttpConnectionHandler.d +++ b/src/ocean/net/http/TaskHttpConnectionHandler.d @@ -109,7 +109,7 @@ abstract class TaskHttpConnectionHandler : TaskConnectionHandler **************************************************************************/ - protected this ( FinalizeDg finalizer, HttpMethod[] supported_methods ... ) + protected this ( scope FinalizeDg finalizer, HttpMethod[] supported_methods ... ) { this(finalizer, new HttpRequest, new HttpResponse, supported_methods); } @@ -126,7 +126,7 @@ abstract class TaskHttpConnectionHandler : TaskConnectionHandler **************************************************************************/ - protected this ( FinalizeDg finalizer, + protected this ( scope FinalizeDg finalizer, HttpRequest request, HttpResponse response, HttpMethod[] supported_methods ... ) { diff --git a/src/ocean/net/http/consts/CookieAttributeNames.d b/src/ocean/net/http/consts/CookieAttributeNames.d index e5b595040..cdb69238a 100644 --- a/src/ocean/net/http/consts/CookieAttributeNames.d +++ b/src/ocean/net/http/consts/CookieAttributeNames.d @@ -40,7 +40,7 @@ struct CookieAttributeNames alias .CookieAttributeNameList NameList; } -const CookieAttributeNames CookieAttributeNameStrings = +static immutable CookieAttributeNames CookieAttributeNameStrings = { Comment: "comment", Domain: "domain", diff --git a/src/ocean/net/http/consts/HeaderFieldNames.d b/src/ocean/net/http/consts/HeaderFieldNames.d index ceb9bafb2..c2c49a6bf 100644 --- a/src/ocean/net/http/consts/HeaderFieldNames.d +++ b/src/ocean/net/http/consts/HeaderFieldNames.d @@ -46,7 +46,7 @@ struct HeaderFieldNames **************************************************************************/ - const General GeneralNames = + enum General GeneralNames = { CacheControl: "Cache-Control", Connection: "Connection", @@ -104,7 +104,7 @@ struct HeaderFieldNames **********************************************************************/ - const Request RequestNames = + enum Request RequestNames = { Accept: "Accept", AcceptCharset: "Accept-Charset", @@ -168,7 +168,7 @@ struct HeaderFieldNames **********************************************************************/ - const Response ResponseNames = + enum Response ResponseNames = { AcceptRanges: "Accept-Ranges", Age: "Age", @@ -229,7 +229,7 @@ struct HeaderFieldNames **********************************************************************/ - const Entity EntityNames = + enum Entity EntityNames = { Allow: "Allow", ContentEncoding: "Content-Encoding", diff --git a/src/ocean/net/http/consts/HttpMethod.d b/src/ocean/net/http/consts/HttpMethod.d index 54ea22c4c..b90fe59ea 100644 --- a/src/ocean/net/http/consts/HttpMethod.d +++ b/src/ocean/net/http/consts/HttpMethod.d @@ -57,7 +57,7 @@ struct HttpMethodNames **************************************************************************/ - const istring[HttpMethod.max + 1] List = + enum istring[HttpMethod.max + 1] List = [ HttpMethod.Undefined: "", HttpMethod.Get: "GET", diff --git a/src/ocean/net/http/consts/HttpVersion.d b/src/ocean/net/http/consts/HttpVersion.d index cdead9a0d..6b544f403 100644 --- a/src/ocean/net/http/consts/HttpVersion.d +++ b/src/ocean/net/http/consts/HttpVersion.d @@ -51,7 +51,7 @@ struct HttpVersionIds **************************************************************************/ - const istring[HttpVersion.max + 1] list = + enum istring[HttpVersion.max + 1] list = [ HttpVersion.v1_1: "HTTP/1.1", HttpVersion.v1_0: "HTTP/1.0" @@ -138,7 +138,7 @@ struct HttpVersionIds static bool validSyntax ( cstring id ) { - const prefix = "HTTP/"; + enum prefix = "HTTP/"; bool valid = id.length > prefix.length; diff --git a/src/ocean/net/http/consts/StatusCodes.d b/src/ocean/net/http/consts/StatusCodes.d index 6683c9dcf..af7552923 100644 --- a/src/ocean/net/http/consts/StatusCodes.d +++ b/src/ocean/net/http/consts/StatusCodes.d @@ -44,7 +44,7 @@ struct StatusPhrases **************************************************************************/ - const HttpStatusPhrase[] StatusReasonPhrases = + enum HttpStatusPhrase[] StatusReasonPhrases = [ HttpStatusPhrase(HttpResponseCode.Continue, "Continue"), HttpStatusPhrase(HttpResponseCode.SwitchingProtocols, "Switching Protocols"), diff --git a/src/ocean/net/http/consts/UriDelim.d b/src/ocean/net/http/consts/UriDelim.d index c89bf295d..47c57729b 100644 --- a/src/ocean/net/http/consts/UriDelim.d +++ b/src/ocean/net/http/consts/UriDelim.d @@ -28,9 +28,9 @@ import ocean.transition; struct UriDelim { - const istring QUERY = `?`; // separates uri path & query parameter - const istring FRAGMENT = `#`; // separates uri path & fragment - const istring QUERY_URL = `/`; // separates url path elements - const istring PARAM = `&`; // separates key/value pairs - const istring KEY_VALUE = `=`; // separate key and value + enum istring QUERY = `?`; // separates uri path & query parameter + enum istring FRAGMENT = `#`; // separates uri path & fragment + enum istring QUERY_URL = `/`; // separates url path elements + enum istring PARAM = `&`; // separates key/value pairs + enum istring KEY_VALUE = `=`; // separate key and value } diff --git a/src/ocean/net/http/cookie/HttpCookieGenerator.d b/src/ocean/net/http/cookie/HttpCookieGenerator.d index 333ed76a8..ad46bd5e6 100644 --- a/src/ocean/net/http/cookie/HttpCookieGenerator.d +++ b/src/ocean/net/http/cookie/HttpCookieGenerator.d @@ -258,7 +258,7 @@ class HttpCookieGenerator : ParamSet **************************************************************************/ - void render ( void delegate ( cstring str ) appendContent ) + void render ( scope void delegate ( cstring str ) appendContent ) { uint i = 0; diff --git a/src/ocean/net/http/cookie/HttpCookieParser.d b/src/ocean/net/http/cookie/HttpCookieParser.d index d51927c74..a6d8e010e 100644 --- a/src/ocean/net/http/cookie/HttpCookieParser.d +++ b/src/ocean/net/http/cookie/HttpCookieParser.d @@ -40,9 +40,9 @@ class HttpCookieParser : QueryParamSet unittest { - const istring cookie_header_value = "test=2649113645; test-value=1383922851"; + static immutable istring cookie_header_value = "test=2649113645; test-value=1383922851"; - const istring[] cookie_names = + static immutable istring[] cookie_names = [ "test", "test-value" diff --git a/src/ocean/net/http/message/HttpHeaderParser.d b/src/ocean/net/http/message/HttpHeaderParser.d index bc76c504c..b37b8cdd3 100644 --- a/src/ocean/net/http/message/HttpHeaderParser.d +++ b/src/ocean/net/http/message/HttpHeaderParser.d @@ -179,7 +179,7 @@ class HttpHeaderParser : IHttpHeaderParser **************************************************************************/ - const size_t DefaultSizeLimit = 16 * 1024, + static immutable size_t DefaultSizeLimit = 16 * 1024, DefaultLinesLimit = 64; /************************************************************************** @@ -196,7 +196,7 @@ class HttpHeaderParser : IHttpHeaderParser **************************************************************************/ - const EndOfHeaderLine = "\r\n"; + static immutable EndOfHeaderLine = "\r\n"; /************************************************************************** @@ -627,7 +627,7 @@ class HttpHeaderParser : IHttpHeaderParser * chunk[0 .. max_len]. If not found, the header is really too long. */ - const end_of_header = "\r\n\r\n"; + static immutable end_of_header = "\r\n\r\n"; char* header_end = g_strstr_len(chunk.ptr, max_len, end_of_header.ptr); @@ -769,7 +769,7 @@ unittest { scope parser = new HttpHeaderParser; - const content1 = "POST / HTTP/1.1\r\n" // 17 + static immutable content1 = "POST / HTTP/1.1\r\n" // 17 ~ "Content-Length: 12\r\n" // 37 ~ "\r\n" // 39 ~ "Hello World!"; @@ -797,7 +797,7 @@ unittest catch (HttpParseException e) { } } - const istring lorem_ipsum = + static immutable istring lorem_ipsum = "Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod " ~ "tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim " ~ "veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex " @@ -852,7 +852,7 @@ unittest ~ "kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit " ~ "amet."; - const istring content2 = + static immutable istring content2 = "POST /dir?query=Hello%20World!&abc=def&ghi HTTP/1.1\r\n" ~ "Host: www.example.org:12345\r\n" ~ "User-Agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.2.17) Gecko/20110422 Ubuntu/9.10 (karmic) Firefox/3.6.17\r\n" @@ -866,7 +866,7 @@ unittest ~ "\r\n" ~ lorem_ipsum; - const parts = 10; + static immutable parts = 10; /* * content will be split into parts parts where the length of each part is @@ -876,7 +876,7 @@ unittest static size_t random_chunk_length ( ) { - const c = content2.length * (2.0f / (parts * 3)); + static immutable c = content2.length * (2.0f / (parts * 3)); static assert (c >= 3, "too many parts"); @@ -889,11 +889,11 @@ unittest version (OceanPerformanceTest) { - const n = 1000_000; + static immutable n = 1000_000; } else { - const n = 10; + static immutable n = 10; } version (OceanPerformanceTest) diff --git a/src/ocean/net/http/model/HttpParamsView.d b/src/ocean/net/http/model/HttpParamsView.d index f548bfbb5..5dbc4db40 100644 --- a/src/ocean/net/http/model/HttpParamsView.d +++ b/src/ocean/net/http/model/HttpParamsView.d @@ -77,5 +77,5 @@ interface HttpParamsView **********************************************************************/ - void produce (size_t delegate(Const!(void)[]) consume, cstring eol=null); + void produce (scope size_t delegate(Const!(void)[]) consume, cstring eol=null); } diff --git a/src/ocean/net/http/time/HttpTimeFormatter.d b/src/ocean/net/http/time/HttpTimeFormatter.d index 8841089e5..9662a13dd 100644 --- a/src/ocean/net/http/time/HttpTimeFormatter.d +++ b/src/ocean/net/http/time/HttpTimeFormatter.d @@ -38,7 +38,7 @@ struct HttpTimeFormatter **************************************************************************/ - public const size_t ResultLength = "Sun, 06 Nov 1994 08:49:37 GMT".length; + public enum size_t ResultLength = "Sun, 06 Nov 1994 08:49:37 GMT".length; /************************************************************************** @@ -64,8 +64,8 @@ struct HttpTimeFormatter **************************************************************************/ - private const istring[7] weekdays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; - private const istring[12] months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; + private enum istring[7] weekdays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; + private enum istring[12] months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; /************************************************************************** @@ -85,7 +85,7 @@ struct HttpTimeFormatter public mstring format ( time_t t ) { - return this.format(this.buf, t); + return (&this).format((&this).buf, t); } /************************************************************************** @@ -103,7 +103,7 @@ struct HttpTimeFormatter public mstring format ( ) { - return this.format(this.buf); + return (&this).format((&this).buf); } /************************************************************************** diff --git a/src/ocean/net/http/time/HttpTimeParser.d b/src/ocean/net/http/time/HttpTimeParser.d index 38407a6ec..1259725e6 100644 --- a/src/ocean/net/http/time/HttpTimeParser.d +++ b/src/ocean/net/http/time/HttpTimeParser.d @@ -98,7 +98,7 @@ bool parse ( cstring timestamp, ref time_t t ) unittest { - const time_t T = 352716457; + static immutable time_t T = 352716457; time_t t; diff --git a/src/ocean/net/server/SelectListener.d b/src/ocean/net/server/SelectListener.d index da4ac1c61..58f734e48 100644 --- a/src/ocean/net/server/SelectListener.d +++ b/src/ocean/net/server/SelectListener.d @@ -652,7 +652,7 @@ unittest ***********************************************************************/ - public this ( FinalizeDg finalize_dg, SomeSharedResource shared_resource ) + public this ( scope FinalizeDg finalize_dg, SomeSharedResource shared_resource ) { this.shared_resource = shared_resource; diff --git a/src/ocean/net/server/SelectListener_slowtest.d b/src/ocean/net/server/SelectListener_slowtest.d index a17181cae..e0ab2ee7e 100644 --- a/src/ocean/net/server/SelectListener_slowtest.d +++ b/src/ocean/net/server/SelectListener_slowtest.d @@ -52,7 +52,7 @@ static this ( ) class DummyConHandler : IConnectionHandler { - this ( void delegate ( IConnectionHandler instance ) ) + this ( scope void delegate ( IConnectionHandler instance ) ) { super(new AddressIPSocket!(), null, null); } @@ -112,7 +112,7 @@ unittest class DummyConHandlerUnix : IConnectionHandler { - this ( void delegate ( IConnectionHandler instance ) ) + this ( scope void delegate ( IConnectionHandler instance ) ) { super(new UnixSocket, null, null); } diff --git a/src/ocean/net/server/connection/IConnectionHandler.d b/src/ocean/net/server/connection/IConnectionHandler.d index 6feacc34e..4f91063ad 100644 --- a/src/ocean/net/server/connection/IConnectionHandler.d +++ b/src/ocean/net/server/connection/IConnectionHandler.d @@ -140,7 +140,7 @@ abstract class IConnectionHandler : IConnectionHandlerInfo, ***************************************************************************/ - protected this ( ISocket socket, ErrorDg error_dg_ = null ) + protected this ( ISocket socket, scope ErrorDg error_dg_ = null ) { this(socket, null, error_dg_); } @@ -158,8 +158,8 @@ abstract class IConnectionHandler : IConnectionHandlerInfo, ***************************************************************************/ - protected this ( ISocket socket, FinalizeDg finalize_dg_ = null, - ErrorDg error_dg_ = null ) + protected this ( ISocket socket, scope FinalizeDg finalize_dg_ = null, + scope ErrorDg error_dg_ = null ) { verify(socket !is null); @@ -186,7 +186,7 @@ abstract class IConnectionHandler : IConnectionHandlerInfo, ***************************************************************************/ - public FinalizeDg finalize_dg ( FinalizeDg finalize_dg_ ) + public FinalizeDg finalize_dg ( scope FinalizeDg finalize_dg_ ) { return this.finalize_dg_ = finalize_dg_; } @@ -204,7 +204,7 @@ abstract class IConnectionHandler : IConnectionHandlerInfo, ***************************************************************************/ - public ErrorDg error_dg ( ErrorDg error_dg_ ) + public ErrorDg error_dg ( scope ErrorDg error_dg_ ) { return this.error_dg_ = error_dg_; } diff --git a/src/ocean/net/server/connection/IFiberConnectionHandler.d b/src/ocean/net/server/connection/IFiberConnectionHandler.d index 8cc65fce6..168a34060 100644 --- a/src/ocean/net/server/connection/IFiberConnectionHandler.d +++ b/src/ocean/net/server/connection/IFiberConnectionHandler.d @@ -94,8 +94,8 @@ abstract class IFiberConnectionHandlerBase : IConnectionHandler protected this ( EpollSelectDispatcher epoll, size_t stack_size, ISocket socket, - FinalizeDg finalize_dg = null, - ErrorDg error_dg = null ) + scope FinalizeDg finalize_dg = null, + scope ErrorDg error_dg = null ) { super(socket, finalize_dg, error_dg); @@ -120,7 +120,7 @@ abstract class IFiberConnectionHandlerBase : IConnectionHandler ***************************************************************************/ protected this ( EpollSelectDispatcher epoll, ISocket socket, - FinalizeDg finalize_dg = null, ErrorDg error_dg = null ) + scope FinalizeDg finalize_dg = null, scope ErrorDg error_dg = null ) { this(epoll, this.default_stack_size, socket, finalize_dg, error_dg); } @@ -308,7 +308,7 @@ abstract class IFiberConnectionHandler : IFiberConnectionHandlerBase, Resettable protected this ( EpollSelectDispatcher epoll, size_t stack_size, bool buffered_writer, ISocket socket, - FinalizeDg finalize_dg = null, ErrorDg error_dg = null ) + scope FinalizeDg finalize_dg = null, scope ErrorDg error_dg = null ) { this(epoll, buffered_writer? new BufferedFiberSelectWriter(this.socket, this.fiber, this.io_warning, this.socket_error) : @@ -337,7 +337,7 @@ abstract class IFiberConnectionHandler : IFiberConnectionHandlerBase, Resettable protected this ( EpollSelectDispatcher epoll, bool buffered_writer, ISocket socket, - FinalizeDg finalize_dg = null, ErrorDg error_dg = null ) + scope FinalizeDg finalize_dg = null, scope ErrorDg error_dg = null ) { this(epoll, this.default_stack_size, buffered_writer, socket, finalize_dg, error_dg); @@ -364,7 +364,7 @@ abstract class IFiberConnectionHandler : IFiberConnectionHandlerBase, Resettable protected this ( EpollSelectDispatcher epoll, size_t stack_size, ISocket socket, - FinalizeDg finalize_dg = null, ErrorDg error_dg = null ) + scope FinalizeDg finalize_dg = null, scope ErrorDg error_dg = null ) { this(epoll, stack_size, this.use_buffered_writer_by_default, socket, finalize_dg, error_dg); @@ -390,7 +390,7 @@ abstract class IFiberConnectionHandler : IFiberConnectionHandlerBase, Resettable ***************************************************************************/ protected this ( EpollSelectDispatcher epoll, ISocket socket, - FinalizeDg finalize_dg = null, ErrorDg error_dg = null ) + scope FinalizeDg finalize_dg = null, scope ErrorDg error_dg = null ) { this(epoll, this.use_buffered_writer_by_default, socket, finalize_dg, error_dg); @@ -419,7 +419,7 @@ abstract class IFiberConnectionHandler : IFiberConnectionHandlerBase, Resettable ***************************************************************************/ private this ( EpollSelectDispatcher epoll, lazy SelectWriter writer, - ISocket socket, FinalizeDg finalize_dg, ErrorDg error_dg, + ISocket socket, scope FinalizeDg finalize_dg, scope ErrorDg error_dg, size_t stack_size ) { super(epoll, stack_size, socket, finalize_dg, error_dg); diff --git a/src/ocean/net/server/connection/TaskConnectionHandler.d b/src/ocean/net/server/connection/TaskConnectionHandler.d index 0e8c5bb34..bf5f213f1 100644 --- a/src/ocean/net/server/connection/TaskConnectionHandler.d +++ b/src/ocean/net/server/connection/TaskConnectionHandler.d @@ -83,7 +83,7 @@ abstract class TaskConnectionHandler : IConnectionHandler, Resettable ***************************************************************************/ - protected this ( ISocket socket, ErrorDg error_dg_ = null ) + protected this ( ISocket socket, scope ErrorDg error_dg_ = null ) { this(socket, null, error_dg_); } @@ -101,8 +101,8 @@ abstract class TaskConnectionHandler : IConnectionHandler, Resettable ***************************************************************************/ - protected this ( ISocket socket, FinalizeDg finalize_dg_, - ErrorDg error_dg_ = null ) + protected this ( ISocket socket, scope FinalizeDg finalize_dg_, + scope ErrorDg error_dg_ = null ) { super(socket, finalize_dg_, error_dg_); this.io_warning = new IOWarning(this.socket); diff --git a/src/ocean/net/server/connpool/ISelectListenerPoolInfo.d b/src/ocean/net/server/connpool/ISelectListenerPoolInfo.d index 7100b9870..4447a62d0 100644 --- a/src/ocean/net/server/connpool/ISelectListenerPoolInfo.d +++ b/src/ocean/net/server/connpool/ISelectListenerPoolInfo.d @@ -43,7 +43,7 @@ public interface ISelectListenerPoolInfo : IPoolInfo ***************************************************************************/ - int opApply ( int delegate ( ref IConnectionHandlerInfo ) dg ); + int opApply ( scope int delegate ( ref IConnectionHandlerInfo ) dg ); /*************************************************************************** @@ -53,6 +53,6 @@ public interface ISelectListenerPoolInfo : IPoolInfo ***************************************************************************/ - int opApply ( int delegate ( ref size_t, ref IConnectionHandlerInfo ) dg ); + int opApply ( scope int delegate ( ref size_t, ref IConnectionHandlerInfo ) dg ); } diff --git a/src/ocean/net/server/connpool/SelectListenerPool.d b/src/ocean/net/server/connpool/SelectListenerPool.d index 88d7e3766..6cfe742c9 100644 --- a/src/ocean/net/server/connpool/SelectListenerPool.d +++ b/src/ocean/net/server/connpool/SelectListenerPool.d @@ -57,7 +57,7 @@ public class SelectListenerPool ( T, Args ... ) : ***************************************************************************/ - public this ( IConnectionHandler.FinalizeDg finalize_dg, Args args ) + public this ( scope IConnectionHandler.FinalizeDg finalize_dg, Args args ) { super(finalize_dg, args); } @@ -70,7 +70,7 @@ public class SelectListenerPool ( T, Args ... ) : ***************************************************************************/ - public int opApply ( int delegate ( ref IConnectionHandlerInfo ) dg ) + public int opApply ( scope int delegate ( ref IConnectionHandlerInfo ) dg ) { int ret; scope it = this.new BusyItemsIterator; @@ -91,7 +91,7 @@ public class SelectListenerPool ( T, Args ... ) : ***************************************************************************/ - public int opApply ( int delegate ( ref size_t, ref IConnectionHandlerInfo ) dg ) + public int opApply ( scope int delegate ( ref size_t, ref IConnectionHandlerInfo ) dg ) { int ret; scope it = this.new BusyItemsIterator; diff --git a/src/ocean/net/server/unix/CommandRegistry.d b/src/ocean/net/server/unix/CommandRegistry.d index d43bcfe70..656ad8c7c 100644 --- a/src/ocean/net/server/unix/CommandRegistry.d +++ b/src/ocean/net/server/unix/CommandRegistry.d @@ -75,8 +75,8 @@ public class CommandsRegistry ***************************************************************************/ public void handle ( cstring command, cstring args, - void delegate (cstring) send_response, - void delegate (ref mstring buf) wait_reply, + scope void delegate (cstring) send_response, + scope void delegate (ref mstring buf) wait_reply, IODevice socket ) { scope predicate = (cstring v) { return !v.length; }; @@ -119,7 +119,7 @@ public class CommandsRegistry ***************************************************************************/ public void addHandler ( istring command, - InteractiveHandler handler ) + scope InteractiveHandler handler ) { this.interactive_handlers[command] = handler; } @@ -134,7 +134,7 @@ public class CommandsRegistry ***************************************************************************/ - public void addHandler ( istring command, Handler handler ) + public void addHandler ( istring command, scope Handler handler ) { this.handlers[command] = handler; } @@ -149,7 +149,7 @@ public class CommandsRegistry ***************************************************************************/ - public void addHandler ( istring command, RawSocketHandler handler ) + public void addHandler ( istring command, scope RawSocketHandler handler ) { this.handlers_ex[command] = handler; } diff --git a/src/ocean/net/server/unix/UnixConnectionHandler.d b/src/ocean/net/server/unix/UnixConnectionHandler.d index d44d780fb..c2122c633 100644 --- a/src/ocean/net/server/unix/UnixConnectionHandler.d +++ b/src/ocean/net/server/unix/UnixConnectionHandler.d @@ -90,8 +90,8 @@ public class BasicCommandHandler ***************************************************************************/ - public this ( Handler[istring] handlers, - InteractiveHandler[istring] interactive_handlers ) + public this ( scope Handler[istring] handlers, + scope InteractiveHandler[istring] interactive_handlers ) { this.handlers = handlers; this.interactive_handlers = interactive_handlers; @@ -106,7 +106,7 @@ public class BasicCommandHandler ***************************************************************************/ - public this ( Handler[istring] handlers ) + public this ( scope Handler[istring] handlers ) { this.handlers = handlers; } @@ -125,8 +125,8 @@ public class BasicCommandHandler ***************************************************************************/ public void handle ( cstring command, cstring args, - void delegate ( cstring ) send_response, - void delegate (ref mstring) wait_reply) + scope void delegate ( cstring ) send_response, + scope void delegate (ref mstring) wait_reply) { if (auto handler = command in this.interactive_handlers) @@ -161,9 +161,9 @@ public class UnixConnectionHandler : UnixSocketConnectionHandler!(BasicCommandHa ***************************************************************************/ - public this ( FinalizeDg finalize_dg, EpollSelectDispatcher epoll, - BasicCommandHandler.Handler[istring] handlers, - BasicCommandHandler.InteractiveHandler[istring] interactive_handlers, + public this ( scope FinalizeDg finalize_dg, EpollSelectDispatcher epoll, + scope BasicCommandHandler.Handler[istring] handlers, + scope BasicCommandHandler.InteractiveHandler[istring] interactive_handlers, istring address_path ) { super(finalize_dg, epoll, @@ -183,8 +183,8 @@ public class UnixConnectionHandler : UnixSocketConnectionHandler!(BasicCommandHa ***************************************************************************/ - public this ( FinalizeDg finalize_dg, EpollSelectDispatcher epoll, - BasicCommandHandler.Handler[istring] handlers, + public this ( scope FinalizeDg finalize_dg, EpollSelectDispatcher epoll, + scope BasicCommandHandler.Handler[istring] handlers, cstring address_path ) { super(finalize_dg, epoll, new BasicCommandHandler(handlers), @@ -278,7 +278,7 @@ public class UnixSocketConnectionHandler ( CommandHandlerType ) : IFiberConnecti ***************************************************************************/ - public this ( FinalizeDg finalize_dg, EpollSelectDispatcher epoll, + public this ( scope FinalizeDg finalize_dg, EpollSelectDispatcher epoll, CommandHandlerType handler, cstring address_path ) { super(epoll, new UnixSocket, finalize_dg); diff --git a/src/ocean/net/server/unix/UnixListener.d b/src/ocean/net/server/unix/UnixListener.d index e27f0ffe7..e353c6db5 100644 --- a/src/ocean/net/server/unix/UnixListener.d +++ b/src/ocean/net/server/unix/UnixListener.d @@ -50,7 +50,7 @@ public class UnixListener : UnixSocketListener!( BasicCommandHandler ) ***********************************************************************/ public this ( cstring address_path, EpollSelectDispatcher epoll, - BasicCommandHandler.Handler[istring] handlers, + scope BasicCommandHandler.Handler[istring] handlers, int mode = -1 ) { this.handler = new BasicCommandHandler(handlers); @@ -80,8 +80,8 @@ public class UnixListener : UnixSocketListener!( BasicCommandHandler ) ***********************************************************************/ public this ( istring address_path, EpollSelectDispatcher epoll, - BasicCommandHandler.Handler[istring] handlers, - BasicCommandHandler.InteractiveHandler[istring] interactive_handlers, + scope BasicCommandHandler.Handler[istring] handlers, + scope BasicCommandHandler.InteractiveHandler[istring] interactive_handlers, int mode = -1 ) { this.handler = new BasicCommandHandler(handlers, interactive_handlers); diff --git a/src/ocean/net/ssl/openssl/OpenSsl.d b/src/ocean/net/ssl/openssl/OpenSsl.d index d03a0cdf7..0b2a6da1b 100644 --- a/src/ocean/net/ssl/openssl/OpenSsl.d +++ b/src/ocean/net/ssl/openssl/OpenSsl.d @@ -784,7 +784,7 @@ extern (D): public c_long SSL_CTX_set_options (SSL_CTX* ctx, c_long op) { - const SSL_CTRL_OPTIONS = 32; + static immutable SSL_CTRL_OPTIONS = 32; return SSL_CTX_ctrl(ctx, SSL_CTRL_OPTIONS, op, null); } diff --git a/src/ocean/net/util/GetSocketAddress.d b/src/ocean/net/util/GetSocketAddress.d index 1565c1c7f..1dad1b21c 100644 --- a/src/ocean/net/util/GetSocketAddress.d +++ b/src/ocean/net/util/GetSocketAddress.d @@ -107,7 +107,7 @@ class GetSocketAddress public sockaddr addr ( ) { - return this.addr_; + return (&this).addr_; } /********************************************************************** @@ -119,7 +119,7 @@ class GetSocketAddress public Family family ( ) { - return cast (Family) this.addr_.sa_family; + return cast (Family) (&this).addr_.sa_family; } /********************************************************************** @@ -132,7 +132,7 @@ class GetSocketAddress public bool supported_family ( ) { - switch (this.family) + switch ((&this).family) { case Family.INET, Family.INET6: return true; @@ -160,9 +160,9 @@ class GetSocketAddress } body { - void* addrp = &this.addr_; + void* addrp = &(&this).addr_; - switch (this.family) + switch ((&this).family) { case Family.INET: addrp += sockaddr_in.init.sin_addr.offsetof; @@ -173,13 +173,13 @@ class GetSocketAddress break; default: - throw this.e.set(.EAFNOSUPPORT); + throw (&this).e.set(.EAFNOSUPPORT); } - auto str = .inet_ntop(this.addr_.sa_family, addrp, - this.addr_string_buffer.ptr, this.addr_string_buffer.length); + auto str = .inet_ntop((&this).addr_.sa_family, addrp, + (&this).addr_string_buffer.ptr, (&this).addr_string_buffer.length); - this.e.enforce(!!str, "inet_ntop"); + (&this).e.enforce(!!str, "inet_ntop"); return str[0 .. strlen(str)]; } @@ -199,18 +199,18 @@ class GetSocketAddress { in_port_t port; - switch (this.family) + switch ((&this).family) { case Family.INET: - port = (cast (sockaddr_in*) &this.addr_).sin_port; + port = (cast (sockaddr_in*) &(&this).addr_).sin_port; break; case Family.INET6: - port = (cast (sockaddr_in6*) &this.addr_).sin6_port; + port = (cast (sockaddr_in6*) &(&this).addr_).sin6_port; break; default: - throw this.e.set(.EAFNOSUPPORT); + throw (&this).e.set(.EAFNOSUPPORT); } return .ntohs(port); diff --git a/src/ocean/net/util/ParamSet.d b/src/ocean/net/util/ParamSet.d index 5f8a30aea..32502fad2 100644 --- a/src/ocean/net/util/ParamSet.d +++ b/src/ocean/net/util/ParamSet.d @@ -90,7 +90,7 @@ class ParamSet **************************************************************************/ - public const ulong_dec_length = ulong.max.stringof.length; + public static immutable ulong_dec_length = ulong.max.stringof.length; /************************************************************************** @@ -324,7 +324,7 @@ class ParamSet **************************************************************************/ - bool access ( cstring key, void delegate ( cstring key, ref cstring val ) dg ) + bool access ( cstring key, scope void delegate ( cstring key, ref cstring val ) dg ) { Element* element = this.get_(key); @@ -367,7 +367,7 @@ class ParamSet **************************************************************************/ - public int opApply ( int delegate ( ref cstring key, ref cstring val ) dg ) + public int opApply ( scope int delegate ( ref cstring key, ref cstring val ) dg ) { int result = 0; @@ -575,7 +575,7 @@ class ParamSet **************************************************************************/ final protected void iterate ( ref Element element, - int delegate ( ref cstring key, ref cstring val ) dg, + scope int delegate ( ref cstring key, ref cstring val ) dg, ref int result ) { with (element) if (val || !this.skip_null_values_on_iteration) diff --git a/src/ocean/net/util/QueryParams.d b/src/ocean/net/util/QueryParams.d index 5763db0c4..66036d91a 100644 --- a/src/ocean/net/util/QueryParams.d +++ b/src/ocean/net/util/QueryParams.d @@ -147,7 +147,7 @@ class QueryParams **************************************************************************/ - public int opApply ( int delegate ( ref cstring key, ref cstring value ) ext_dg ) + public int opApply ( scope int delegate ( ref cstring key, ref cstring value ) ext_dg ) { this.iterating = true; @@ -338,7 +338,7 @@ class FullQueryParamSet: QueryParamSet **************************************************************************/ - public override int opApply ( int delegate ( ref cstring key, ref cstring val ) dg ) + public override int opApply ( scope int delegate ( ref cstring key, ref cstring val ) dg ) { int result = super.opApply(dg); diff --git a/src/ocean/net/util/UrlDecoder.d b/src/ocean/net/util/UrlDecoder.d index 7ede91f93..8c0a9ec86 100644 --- a/src/ocean/net/util/UrlDecoder.d +++ b/src/ocean/net/util/UrlDecoder.d @@ -116,7 +116,7 @@ class UrlDecoder **************************************************************************/ - public int opApply ( int delegate ( ref cstring chunk ) dg ) + public int opApply ( scope int delegate ( ref cstring chunk ) dg ) { int callDg ( cstring str ) { diff --git a/src/ocean/net/util/UrlEncoder.d b/src/ocean/net/util/UrlEncoder.d index f2eafcc07..abb226caf 100644 --- a/src/ocean/net/util/UrlEncoder.d +++ b/src/ocean/net/util/UrlEncoder.d @@ -58,7 +58,7 @@ class EncodeNonUnreserved : PercentEncoder **************************************************************************/ - const bool[char.max + 1] unreserved = + static immutable bool[char.max + 1] unreserved = [ 'A': true, 'B': true, 'C': true, 'D': true, 'E': true, 'F': true, 'G': true, 'H': true, 'I': true, 'J': true, 'K': true, 'L': true, @@ -186,7 +186,7 @@ class PercentEncoder **************************************************************************/ - public int opApply ( int delegate ( ref cstring chunk ) dg ) + public int opApply ( scope int delegate ( ref cstring chunk ) dg ) { int result = 0; @@ -211,7 +211,7 @@ class PercentEncoder if (callDg(this.source[start .. i])) return result; } - const hex_digits = "0123456789ABCDEF"; + static immutable hex_digits = "0123456789ABCDEF"; hex[1] = hex_digits [(c >> 4) & 0xF]; hex[2] = hex_digits [c & 0xF]; @@ -265,7 +265,7 @@ unittest ~ "\"%7E\" by older URI processing implementations; the \"%7E\" can be " ~ "replaced by \"~\" without chänging its interpretation."); - const istring[] chunks = + static immutable istring[] chunks = [ "For", "%20", "example", "%2C", "%20", "the", "%20", "octet", "%20", "corresponding","%20", "to", "%20", "the", "%20", "tilde", "%20", diff --git a/src/ocean/stdc/posix/sys/un.d b/src/ocean/stdc/posix/sys/un.d index 9407d3f0e..352085a01 100644 --- a/src/ocean/stdc/posix/sys/un.d +++ b/src/ocean/stdc/posix/sys/un.d @@ -21,7 +21,7 @@ import core.sys.posix.sys.socket; extern (C): -const UNIX_PATH_MAX = 108; +static immutable UNIX_PATH_MAX = 108; align(1) struct sockaddr_un @@ -43,7 +43,7 @@ struct sockaddr_un public static sockaddr_un create (cstring path) in { - assert(typeof(this).sun_path.length > path.length, + assert(typeof((&this)).sun_path.length > path.length, "Can't set path longer than UNIX_PATH_MAX."); } body diff --git a/src/ocean/sys/CmdPath.d b/src/ocean/sys/CmdPath.d index 1b9411dc5..dddae3538 100644 --- a/src/ocean/sys/CmdPath.d +++ b/src/ocean/sys/CmdPath.d @@ -77,9 +77,9 @@ struct CmdPath path.set(PathUtil.normalize(path.folder)); - this.dir = path.absolute(Environment.cwd()).toString(); + (&this).dir = path.absolute(Environment.cwd()).toString(); - return this.get(); + return (&this).get(); } /************************************************************************** @@ -93,7 +93,7 @@ struct CmdPath public istring get ( ) { - return this.dir; + return (&this).dir; } /************************************************************************** @@ -110,6 +110,6 @@ struct CmdPath public istring prepend ( istring[] path ... ) { - return FilePath.join(this.dir ~ path); + return FilePath.join((&this).dir ~ path); } } diff --git a/src/ocean/sys/CpuAffinity.d b/src/ocean/sys/CpuAffinity.d index 936d7828d..fc6bf4741 100644 --- a/src/ocean/sys/CpuAffinity.d +++ b/src/ocean/sys/CpuAffinity.d @@ -40,8 +40,8 @@ private extern ( C ) mixin(Typedef!(uint, "__cpu_mask")); /* Size definition for CPU sets. */ - const __CPU_SETSIZE = 1024; - const __NCPUBITS = (8 * __cpu_mask.sizeof); + static immutable __CPU_SETSIZE = 1024; + static immutable __NCPUBITS = (8 * __cpu_mask.sizeof); /* Data structure to describe CPU mask. */ struct cpu_set_t @@ -90,7 +90,7 @@ static: cpu_set_t cpu_set; CPU_SET(cast(__cpu_mask)cpu, cpu_set); - const pid_t pid = 0; // 0 := calling process + enum pid_t pid = 0; // 0 := calling process if (sched_setaffinity(pid, cpu_set_t.sizeof, &cpu_set)) { throw (new ErrnoException).useGlobalErrno("sched_setaffinity"); diff --git a/src/ocean/sys/Epoll.d b/src/ocean/sys/Epoll.d index 3f1d9807b..0c217d625 100644 --- a/src/ocean/sys/Epoll.d +++ b/src/ocean/sys/Epoll.d @@ -213,7 +213,7 @@ align (1) union epoll_data_t Object obj ( Object o ) { - return cast (Object) (this.ptr = cast (void*) o); + return cast (Object) ((&this).ptr = cast (void*) o); } /************************************************************************** @@ -227,7 +227,7 @@ align (1) union epoll_data_t Object obj ( ) { - return cast (Object) this.ptr; + return cast (Object) (&this).ptr; } } @@ -513,7 +513,7 @@ struct Epoll **************************************************************************/ - public const int fd_init = -1; + public enum int fd_init = -1; /************************************************************************** @@ -540,7 +540,7 @@ struct Epoll public int create ( CreateFlags flags = CreateFlags.None ) { - return this.fd = epoll_create1( + return (&this).fd = epoll_create1( setCloExec(flags, EpollCreateFlags.EPOLL_CLOEXEC) ); } @@ -566,7 +566,7 @@ struct Epoll public int ctl ( CtlOp op, int fd, epoll_event_t event ) { - return epoll_ctl(this.fd, op, fd, &event); + return epoll_ctl((&this).fd, op, fd, &event); } template ctlT ( size_t i = 0 ) @@ -606,7 +606,7 @@ struct Epoll event.events = events; event.data.tupleof[i] = data; - return epoll_ctl(this.fd, op, fd, &event); + return epoll_ctl((&this).fd, op, fd, &event); } mixin ctlT!(i + 1); @@ -677,7 +677,7 @@ struct Epoll event.events = events; event.data.obj = obj; - return epoll_ctl(this.fd, op, fd, &event); + return epoll_ctl((&this).fd, op, fd, &event); } /************************************************************************** @@ -711,7 +711,7 @@ struct Epoll event.events = events; event.data.u64 = u64; - return epoll_ctl(this.fd, op, fd, &event); + return epoll_ctl((&this).fd, op, fd, &event); } /************************************************************************** @@ -745,7 +745,7 @@ struct Epoll body { verify(events.length <= int.max); - return epoll_wait(this.fd, events.ptr, cast (int) events.length, timeout_ms); + return epoll_wait((&this).fd, events.ptr, cast (int) events.length, timeout_ms); } /************************************************************************** @@ -759,6 +759,6 @@ struct Epoll public int close ( ) { - return .close(this.fd); + return .close((&this).fd); } } diff --git a/src/ocean/sys/ErrnoException.d b/src/ocean/sys/ErrnoException.d index e0b8855f5..ad3357e5a 100644 --- a/src/ocean/sys/ErrnoException.d +++ b/src/ocean/sys/ErrnoException.d @@ -418,10 +418,10 @@ public struct Caller ( T ) public ReturnTypeOf!(T) call ( ParametersOf!(T) args ) { - auto ret = this.fn(args); + auto ret = (&this).fn(args); if (!verify(ret)) - throw e.useGlobalErrno(e.func_name, this.original_file, - this.original_line); + throw e.useGlobalErrno(e.func_name, (&this).original_file, + (&this).original_line); return ret; } } diff --git a/src/ocean/sys/EventFD.d b/src/ocean/sys/EventFD.d index c81f1e388..1951d4652 100644 --- a/src/ocean/sys/EventFD.d +++ b/src/ocean/sys/EventFD.d @@ -116,7 +116,7 @@ import core.sys.posix.unistd: read, write, close; private extern ( C ) { int eventfd ( uint initval, int flags ); - const EFD_CLOEXEC = 0x80000; + static immutable EFD_CLOEXEC = 0x80000; } diff --git a/src/ocean/sys/GetIfAddrs.d b/src/ocean/sys/GetIfAddrs.d index e320660f4..4ba889924 100644 --- a/src/ocean/sys/GetIfAddrs.d +++ b/src/ocean/sys/GetIfAddrs.d @@ -153,7 +153,7 @@ istring[] getAddrsForInterface( cstring interface_name, bool ipv6 = false ) *******************************************************************************/ bool getAddrsForInterface( cstring interface_name, bool ipv6, - bool delegate ( cstring address, + scope bool delegate ( cstring address, int getnameinfo_status ) dg ) { ifaddrs* ifaddr; diff --git a/src/ocean/sys/Inotify.d b/src/ocean/sys/Inotify.d index e353a4cb4..0284da41e 100644 --- a/src/ocean/sys/Inotify.d +++ b/src/ocean/sys/Inotify.d @@ -97,7 +97,7 @@ public class Inotify : ISelectable ***********************************************************************/ - public int opApply ( int delegate ( ref inotify_event* ) dg ) + public int opApply ( scope int delegate ( ref inotify_event* ) dg ) { //255 is the default max filename length in linux) char[inotify_event.sizeof + 255 + 1] buffer_temp; @@ -106,7 +106,7 @@ public class Inotify : ISelectable int result = 0; ssize_t read_bytes; - read_loop: while ( (read_bytes = read(this.outer.fd, buffer.ptr, buffer.length)) > 0 ) + read_loop: while ( (read_bytes = read((&this).outer.fd, buffer.ptr, buffer.length)) > 0 ) { inotify_event *i_event; diff --git a/src/ocean/sys/Process.d b/src/ocean/sys/Process.d index 5548dc756..4dc7586eb 100644 --- a/src/ocean/sys/Process.d +++ b/src/ocean/sys/Process.d @@ -178,7 +178,7 @@ class Process public int status; /// Formatter-compatible string formatting function - public void toString (FormatterSink sink) + public void toString (scope FormatterSink sink) { switch (reason) { @@ -213,14 +213,14 @@ class Process /// Convenience overload that format this as a string public istring toString () { - return format("{}", this); + return format("{}", (&this)); } } - const uint DefaultStdinBufferSize = 512; - const uint DefaultStdoutBufferSize = 8192; - const uint DefaultStderrBufferSize = 512; - const Redirect DefaultRedirectFlags = Redirect.All; + static immutable uint DefaultStdinBufferSize = 512; + static immutable uint DefaultStdoutBufferSize = 8192; + static immutable uint DefaultStderrBufferSize = 512; + static immutable Redirect DefaultRedirectFlags = Redirect.All; private cstring[] _args; private istring[istring] _env; diff --git a/src/ocean/sys/SafeFork.d b/src/ocean/sys/SafeFork.d index 2a90e8b4e..4428a6b02 100644 --- a/src/ocean/sys/SafeFork.d +++ b/src/ocean/sys/SafeFork.d @@ -71,8 +71,8 @@ extern (C) int waitid(idtype_t, id_t, siginfo_t*, int); - const WEXITED = 0x00000004; - const WNOWAIT = 0x01000000; + static immutable WEXITED = 0x00000004; + static immutable WNOWAIT = 0x01000000; } @@ -152,7 +152,7 @@ public class SafeFork ***************************************************************************/ - public this ( void delegate () dg ) + public this ( scope void delegate () dg ) { this.dg = dg; diff --git a/src/ocean/sys/SignalMask.d b/src/ocean/sys/SignalMask.d index 88e93ffe2..0d51e458f 100644 --- a/src/ocean/sys/SignalMask.d +++ b/src/ocean/sys/SignalMask.d @@ -60,7 +60,7 @@ public struct SignalSet public void clear ( ) { - sigemptyset(&this.sigset); + sigemptyset(&(&this).sigset); } @@ -72,7 +72,7 @@ public struct SignalSet public void setAll ( ) { - sigfillset(&this.sigset); + sigfillset(&(&this).sigset); } @@ -89,7 +89,7 @@ public struct SignalSet public void remove ( int signal ) { - sigdelset(&this.sigset, signal); + sigdelset(&(&this).sigset, signal); } public alias remove opSub; @@ -108,7 +108,7 @@ public struct SignalSet public void add ( int signal ) { - sigaddset(&this.sigset, signal); + sigaddset(&(&this).sigset, signal); } public alias add opAdd; @@ -129,7 +129,7 @@ public struct SignalSet { foreach ( signal; signals ) { - this.remove(signal); + (&this).remove(signal); } } @@ -151,7 +151,7 @@ public struct SignalSet { foreach ( signal; signals ) { - this.add(signal); + (&this).add(signal); } } @@ -172,7 +172,7 @@ public struct SignalSet public bool isSet ( int signal ) { - return !!sigismember(&this.sigset, signal); + return !!sigismember(&(&this).sigset, signal); } /*************************************************************************** @@ -201,7 +201,7 @@ public struct SignalSet ***************************************************************************/ - public typeof(*this) mask ( int how = SIG_SETMASK ) + public typeof(*(&this)) mask ( int how = SIG_SETMASK ) in { switch (how) @@ -215,9 +215,9 @@ public struct SignalSet } body { - typeof(*this) old_set; + typeof(*(&this)) old_set; - pthread_sigmask(how, &this.sigset, &old_set.sigset); + pthread_sigmask(how, &(&this).sigset, &old_set.sigset); return old_set; } @@ -234,9 +234,9 @@ public struct SignalSet ***************************************************************************/ - public typeof(*this) block ( ) + public typeof(*(&this)) block ( ) { - return this.mask(SIG_BLOCK); + return (&this).mask(SIG_BLOCK); } /*************************************************************************** @@ -251,9 +251,9 @@ public struct SignalSet ***************************************************************************/ - public typeof(*this) unblock ( ) + public typeof(*(&this)) unblock ( ) { - return this.mask(SIG_UNBLOCK); + return (&this).mask(SIG_UNBLOCK); } /*************************************************************************** @@ -268,7 +268,7 @@ public struct SignalSet public void callBlocked ( lazy void op ) { - auto old_sigset = this.block(); + auto old_sigset = (&this).block(); scope ( exit ) { @@ -277,7 +277,7 @@ public struct SignalSet sigset_t pending; sigpending(&pending); - foreach ( signal; this.signals ) + foreach ( signal; (&this).signals ) { if ( sigismember(&pending, signal) ) { @@ -301,9 +301,9 @@ public struct SignalSet ***************************************************************************/ - public static typeof(*this) getCurrent ( ) + public static typeof(*(&this)) getCurrent ( ) { - typeof(*this) current_set; + typeof(*(&this)) current_set; pthread_sigmask(SIG_SETMASK, null, ¤t_set.sigset); @@ -319,6 +319,6 @@ public struct SignalSet public sigset_t opCast ( ) { - return this.sigset; + return (&this).sigset; } } diff --git a/src/ocean/sys/TimerFD.d b/src/ocean/sys/TimerFD.d index 8570e27a6..30b41d34f 100644 --- a/src/ocean/sys/TimerFD.d +++ b/src/ocean/sys/TimerFD.d @@ -43,13 +43,13 @@ import core.stdc.errno: EAGAIN, EWOULDBLOCK, errno; /// -const TFD_TIMER_ABSTIME = 1, +static immutable TFD_TIMER_ABSTIME = 1, TFD_CLOEXEC = 0x80000, // octal 02000000 TFD_NONBLOCK = 0x800; // octal 04000 /// -const CLOCK_MONOTONIC = 1; +static immutable CLOCK_MONOTONIC = 1; // TODO: move into C bindings diff --git a/src/ocean/sys/socket/AddrInfo.d b/src/ocean/sys/socket/AddrInfo.d index 3ec272994..ab2b53882 100644 --- a/src/ocean/sys/socket/AddrInfo.d +++ b/src/ocean/sys/socket/AddrInfo.d @@ -107,7 +107,7 @@ struct addrinfo socklen_t ai_addrlen; // The manpage says size_t: WRONG! sockaddr* ai_addr; char* ai_canonname; - typeof (this) ai_next; + typeof ((&this)) ai_next; alias .INET6_ADDRSTRLEN INET6_ADDRSTRLEN; alias .INET_ADDRSTRLEN INET_ADDRSTRLEN; @@ -149,9 +149,9 @@ struct addrinfo { void sanity_check ( ) { - verify(this.ai_addr !is null); + verify((&this).ai_addr !is null); - switch (this.ai_family) + switch ((&this).ai_family) { case AF_INET: verify( @@ -177,14 +177,14 @@ struct addrinfo void* addr; - switch (this.ai_family) + switch ((&this).ai_family) { case AF_INET: - addr = &(*cast (sockaddr_in*) this.ai_addr).sin_addr; + addr = &(*cast (sockaddr_in*) (&this).ai_addr).sin_addr; break; case AF_INET6: - addr = &(*cast (sockaddr_in6*) this.ai_addr).sin6_addr; + addr = &(*cast (sockaddr_in6*) (&this).ai_addr).sin6_addr; break; default: @@ -192,7 +192,7 @@ struct addrinfo return null; } - auto address_p = .inet_ntop(this.ai_family, addr, dst.ptr, + auto address_p = .inet_ntop((&this).ai_family, addr, dst.ptr, castFrom!(size_t).to!(int)(dst.length)); // inet_ntop returns const pointer even if spec says it will always // use `dst` memory. Using `dst` directly to avoid casts. @@ -218,16 +218,16 @@ struct addrinfo ushort port ( ) { - verify(this.ai_addr !is null); + verify((&this).ai_addr !is null); .errno = 0; - switch (this.ai_family) + switch ((&this).ai_family) { case AF_INET: - return .ntohs((cast (sockaddr_in*) this.ai_addr).sin_port); + return .ntohs((cast (sockaddr_in*) (&this).ai_addr).sin_port); case AF_INET6: - return .ntohs((cast (sockaddr_in6*) this.ai_addr).sin6_port); + return .ntohs((cast (sockaddr_in6*) (&this).ai_addr).sin6_port); default: .errno = EAFNOSUPPORT; @@ -246,7 +246,7 @@ struct addrinfo char[] canonname ( ) { - return this.ai_canonname? this.ai_canonname[0 .. strlen(this.ai_canonname)] : null; + return (&this).ai_canonname? (&this).ai_canonname[0 .. strlen((&this).ai_canonname)] : null; } /************************************************************************** @@ -258,11 +258,11 @@ struct addrinfo **************************************************************************/ - int opApply ( int delegate ( ref typeof (*this) info ) dg ) + int opApply ( scope int delegate ( ref typeof (*(&this)) info ) dg ) { int result = 0; - for (typeof (this) info = this; info && !result; info = info.ai_next) + for (typeof ((&this)) info = (&this); info && !result; info = info.ai_next) { result = dg(*info); } diff --git a/src/ocean/sys/socket/IPSocket.d b/src/ocean/sys/socket/IPSocket.d index c21ae3fdc..375cc2881 100644 --- a/src/ocean/sys/socket/IPSocket.d +++ b/src/ocean/sys/socket/IPSocket.d @@ -508,7 +508,7 @@ class IPSocket ( bool IPv6 = false ) : IIPSocket public int accept ( ISelectable listening_socket, ref InAddr remote_address, bool nonblocking ) { - const SocketFlags[2] flags = [SocketFlags.None, SocketFlags.SOCK_NONBLOCK]; + static immutable SocketFlags[2] flags = [SocketFlags.None, SocketFlags.SOCK_NONBLOCK]; return this.accept(listening_socket, remote_address, flags[nonblocking]); } diff --git a/src/ocean/sys/socket/InetAddress.d b/src/ocean/sys/socket/InetAddress.d index fef4426b4..4fe3eacc6 100644 --- a/src/ocean/sys/socket/InetAddress.d +++ b/src/ocean/sys/socket/InetAddress.d @@ -104,19 +104,19 @@ struct InetAddress ( bool IPv6 = false ) { alias sockaddr_in6 Addr; - const addrstrlen = INET6_ADDRSTRLEN, + enum addrstrlen = INET6_ADDRSTRLEN, family = AF_INET6; - const Addr addr_init = {sin6_family: family}; + enum Addr addr_init = {sin6_family: family}; } else { alias sockaddr_in Addr; - const addrstrlen = INET_ADDRSTRLEN, + enum addrstrlen = INET_ADDRSTRLEN, family = AF_INET; - const Addr addr_init = {sin_family: family}; + enum Addr addr_init = {sin_family: family}; } /************************************************************************** @@ -142,11 +142,11 @@ struct InetAddress ( bool IPv6 = false ) { static if (IPv6) { - return .ntohs(this.addr.sin6_port); + return .ntohs((&this).addr.sin6_port); } else { - return .ntohs(this.addr.sin_port); + return .ntohs((&this).addr.sin_port); } } @@ -166,12 +166,12 @@ struct InetAddress ( bool IPv6 = false ) { static if (IPv6) { - this.addr.sin6_port = .htons(p); + (&this).addr.sin6_port = .htons(p); } else { - this.addr.sin_port = .htons(p); + (&this).addr.sin_port = .htons(p); } return p; @@ -193,14 +193,14 @@ struct InetAddress ( bool IPv6 = false ) int inet_pton ( cstring ip_address_str ) { - if (ip_address_str.length < this.addrstrlen) + if (ip_address_str.length < (&this).addrstrlen) { - char[this.addrstrlen] nultermbuf; + char[(&this).addrstrlen] nultermbuf; nultermbuf[0 .. ip_address_str.length] = ip_address_str[]; nultermbuf[ip_address_str.length] = '\0'; - return this.inet_pton(nultermbuf.ptr); + return (&this).inet_pton(nultermbuf.ptr); } else { @@ -229,7 +229,7 @@ struct InetAddress ( bool IPv6 = false ) int inet_pton ( in char* ip_address_str ) { - return .inet_pton(this.family, ip_address_str, this.address_n.ptr); + return .inet_pton((&this).family, ip_address_str, (&this).address_n.ptr); } /************************************************************************** @@ -245,14 +245,14 @@ struct InetAddress ( bool IPv6 = false ) { static if (IPv6) { - this.addr.sin6_addr = this.addr.sin6_addr.init; + (&this).addr.sin6_addr = (&this).addr.sin6_addr.init; } else { - this.addr.sin_addr.s_addr = htonl(INADDR_ANY); + (&this).addr.sin_addr.s_addr = htonl(INADDR_ANY); } - return cast (sockaddr*) &this.addr; + return cast (sockaddr*) &(&this).addr; } /************************************************************************** @@ -277,11 +277,11 @@ struct InetAddress ( bool IPv6 = false ) mstring inet_ntop ( mstring dst ) { verify( - dst.length >= this.addrstrlen, + dst.length >= (&this).addrstrlen, "dst.length expected to be at least addrstrlen" ); - auto address_p = .inet_ntop(this.family, this.address_n.ptr, dst.ptr, + auto address_p = .inet_ntop((&this).family, (&this).address_n.ptr, dst.ptr, castFrom!(size_t).to!(int)(dst.length)); return address_p? dst.ptr[0 .. strlen(dst.ptr)] : null; @@ -305,10 +305,10 @@ struct InetAddress ( bool IPv6 = false ) public sockaddr* opCall ( cstring ip_address_str, ushort port = 0 ) { - if (this.inet_pton(ip_address_str) == 1) + if ((&this).inet_pton(ip_address_str) == 1) { - this.port = port; - return cast (sockaddr*) &this.addr; + (&this).port = port; + return cast (sockaddr*) &(&this).addr; } else { @@ -331,9 +331,9 @@ struct InetAddress ( bool IPv6 = false ) public sockaddr* opCall ( ushort port ) { - this.port = port; + (&this).port = port; - return this.setAddressAny(); + return (&this).setAddressAny(); } /************************************************************************** @@ -350,9 +350,9 @@ struct InetAddress ( bool IPv6 = false ) public sockaddr* opAssign ( Addr addr ) { - this.addr = addr; + (&this).addr = addr; - return cast (sockaddr*) &this.addr; + return cast (sockaddr*) &(&this).addr; } /************************************************************************** @@ -373,9 +373,9 @@ struct InetAddress ( bool IPv6 = false ) public sockaddr* opAssign ( Addr* addr ) { verify(addr !is null); - this.addr = *addr; + (&this).addr = *addr; - return cast (sockaddr*) &this.addr; + return cast (sockaddr*) &(&this).addr; } /************************************************************************** @@ -386,7 +386,7 @@ struct InetAddress ( bool IPv6 = false ) public void clear ( ) { - this.addr = this.addr_init; + (&this).addr = (&this).addr_init; } /************************************************************************** @@ -401,7 +401,7 @@ struct InetAddress ( bool IPv6 = false ) public void[] address_n ( ) { - with (this.addr) static if (IPv6) + with ((&this).addr) static if (IPv6) { return (cast (void*) &sin6_addr)[0 .. sin6_addr.sizeof]; } @@ -417,7 +417,7 @@ struct InetAddress ( bool IPv6 = false ) GetNameInfoFlags flags = GetNameInfoFlags.None) { return core.sys.posix.netdb.getnameinfo( - cast (sockaddr*) &this.addr, this.addr.sizeof, + cast (sockaddr*) &(&this).addr, (&this).addr.sizeof, host.ptr, castFrom!(size_t).to!(int)(host.length), serv.ptr, castFrom!(size_t).to!(int)(serv.length), flags); } diff --git a/src/ocean/sys/socket/model/ISocket.d b/src/ocean/sys/socket/model/ISocket.d index ccfd87442..7eddf7385 100644 --- a/src/ocean/sys/socket/model/ISocket.d +++ b/src/ocean/sys/socket/model/ISocket.d @@ -527,7 +527,7 @@ public abstract class ISocket : IODevice public int accept ( ISelectable listening_socket, bool nonblocking ) { - const SocketFlags[2] flags = [SocketFlags.None, SocketFlags.SOCK_NONBLOCK]; + static immutable SocketFlags[2] flags = [SocketFlags.None, SocketFlags.SOCK_NONBLOCK]; return this.accept(listening_socket, flags[nonblocking]); } diff --git a/src/ocean/sys/stats/linux/ProcVFS.d b/src/ocean/sys/stats/linux/ProcVFS.d index e3d5e4298..36dded77b 100644 --- a/src/ocean/sys/stats/linux/ProcVFS.d +++ b/src/ocean/sys/stats/linux/ProcVFS.d @@ -321,7 +321,7 @@ public struct ProcUptime { Time res_time; - auto t = (this.seconds * 100 + this.cents) - + auto t = ((&this).seconds * 100 + (&this).cents) - (rhs.seconds * 100 + rhs.cents); res_time.seconds = t / 100; @@ -572,7 +572,7 @@ private void throwException( istring name ) *******************************************************************************/ -private ProcMemInfo parseProcMemInfoData (cstring delegate() read_next_line) +private ProcMemInfo parseProcMemInfoData (scope cstring delegate() read_next_line) { /// Helper function to strip leading spaces /// Params: diff --git a/src/ocean/task/IScheduler.d b/src/ocean/task/IScheduler.d index c69ad8f14..c0b658327 100644 --- a/src/ocean/task/IScheduler.d +++ b/src/ocean/task/IScheduler.d @@ -234,7 +234,7 @@ public interface IScheduler ***************************************************************************/ - public void await ( Task task, void delegate (Task) finished_dg = null ); + public void await ( Task task, scope void delegate (Task) finished_dg = null ); /*************************************************************************** diff --git a/src/ocean/task/Scheduler.d b/src/ocean/task/Scheduler.d index 58cb5642b..61f9636fa 100644 --- a/src/ocean/task/Scheduler.d +++ b/src/ocean/task/Scheduler.d @@ -148,7 +148,7 @@ final class Scheduler : IScheduler ***************************************************************************/ - public void task_queue_full_cb ( TaskQueueFullCB dg ) + public void task_queue_full_cb ( scope TaskQueueFullCB dg ) { this.fiber_pool.task_queue_full_cb = dg; } @@ -419,7 +419,7 @@ final class Scheduler : IScheduler ***************************************************************************/ - public void await ( Task task, void delegate (Task) finished_dg = null ) + public void await ( Task task, scope void delegate (Task) finished_dg = null ) { auto context = Task.getThis(); assert (context !is null); @@ -752,7 +752,7 @@ unittest { ++TestTask.started; - const very_long_loop = 5; + static immutable very_long_loop = 5; for (int i = 0; i < very_long_loop; ++i) { diff --git a/src/ocean/task/Task.d b/src/ocean/task/Task.d index a41a33e89..533d67c68 100644 --- a/src/ocean/task/Task.d +++ b/src/ocean/task/Task.d @@ -277,7 +277,7 @@ public abstract class Task ***************************************************************************/ public void assignTo ( WorkerFiber fiber, - void delegate() entry_point = null ) + scope void delegate() entry_point = null ) { this.state_bitmask = TaskState.None; @@ -357,7 +357,7 @@ public abstract class Task ***************************************************************************/ - public void terminationHook (void delegate() hook) + public void terminationHook (scope void delegate() hook) { this.termination_hooks ~= hook; } @@ -372,7 +372,7 @@ public abstract class Task ***************************************************************************/ - public void removeTerminationHook (void delegate() hook) + public void removeTerminationHook (scope void delegate() hook) { this.termination_hooks.length = .moveToEnd(this.termination_hooks[], hook); } @@ -785,7 +785,7 @@ public class TaskWith ( Extensions... ) : Task ***************************************************************************/ override public void assignTo ( WorkerFiber fiber, - void delegate() entry_point = null ) + scope void delegate() entry_point = null ) { super.assignTo(fiber, entry_point); diff --git a/src/ocean/task/TaskPool_test.d b/src/ocean/task/TaskPool_test.d index ddacfcc0c..e5ee75016 100644 --- a/src/ocean/task/TaskPool_test.d +++ b/src/ocean/task/TaskPool_test.d @@ -83,7 +83,7 @@ unittest override protected void run ( ) { - const NUM_START_CALLS = 6; + static immutable NUM_START_CALLS = 6; for (uint i; i < NUM_START_CALLS; i++) this.my_task_pool.start(); @@ -108,7 +108,7 @@ unittest { void delegate () dg; - public void copyArguments ( void delegate () dg ) + public void copyArguments ( scope void delegate () dg ) { this.dg = dg; } diff --git a/src/ocean/task/extensions/ExceptionForwarding.d b/src/ocean/task/extensions/ExceptionForwarding.d index 0e1167474..220cac607 100644 --- a/src/ocean/task/extensions/ExceptionForwarding.d +++ b/src/ocean/task/extensions/ExceptionForwarding.d @@ -40,12 +40,12 @@ struct ExceptionForwarding void onResumed ( ) { - if (this.to_throw !is null) + if ((&this).to_throw !is null) { // reset the reference so it won't throw again // if the same fiber handles an exception and suspends again - auto to_throw = this.to_throw; - this.to_throw = null; + auto to_throw = (&this).to_throw; + (&this).to_throw = null; throw to_throw; } } diff --git a/src/ocean/task/util/Event.d b/src/ocean/task/util/Event.d index 22cba500e..3a6480324 100644 --- a/src/ocean/task/util/Event.d +++ b/src/ocean/task/util/Event.d @@ -50,15 +50,15 @@ struct TaskEvent public void wait ( ) { - if (!this.triggered) + if (!(&this).triggered) { - this.task = Task.getThis(); + (&this).task = Task.getThis(); debug_trace("Task {} suspended waiting for event {}", - cast(void*) this.task, cast(void*) this); - this.task.suspend(); + cast(void*) (&this).task, cast(void*) (&this)); + (&this).task.suspend(); } - this.triggered = false; + (&this).triggered = false; } /*************************************************************************** @@ -70,12 +70,12 @@ struct TaskEvent public void trigger ( ) { - this.triggered = true; - if (this.task !is null && this.task.suspended()) + (&this).triggered = true; + if ((&this).task !is null && (&this).task.suspended()) { debug_trace("Resuming task {} by trigger of event {}", - cast(void*) this.task, cast(void*) this); - this.task.resume(); + cast(void*) (&this).task, cast(void*) (&this)); + (&this).task.resume(); } } } diff --git a/src/ocean/task/util/QuickRun.d b/src/ocean/task/util/QuickRun.d index f9d16c569..2f0b2cdbb 100644 --- a/src/ocean/task/util/QuickRun.d +++ b/src/ocean/task/util/QuickRun.d @@ -36,7 +36,7 @@ import ocean.core.Verify; *******************************************************************************/ -public int quickRun ( int delegate () dg ) +public int quickRun ( scope int delegate () dg ) { auto task = new DgTask(dg); theScheduler.queue(task); @@ -71,7 +71,7 @@ private class DgTask : Task int delegate () dg; int result; - this (int delegate() dg) + this (scope int delegate() dg) { this.dg = dg; } diff --git a/src/ocean/text/Arguments.d b/src/ocean/text/Arguments.d index d48bd598c..4be8341bd 100644 --- a/src/ocean/text/Arguments.d +++ b/src/ocean/text/Arguments.d @@ -795,7 +795,7 @@ public class Arguments ***************************************************************************/ - private const istring[] errmsg = [ + private static immutable istring[] errmsg = [ "argument '{0}' expects {2} parameter(s) but has {1}\n", "argument '{0}' expects {3} parameter(s) but has {1}\n", "argument '{0}' is missing\n", @@ -1065,7 +1065,7 @@ public class Arguments ***************************************************************************/ - public int opApply ( int delegate(ref Argument) dg ) + public int opApply ( scope int delegate(ref Argument) dg ) { int result; @@ -1161,7 +1161,7 @@ public class Arguments ***************************************************************************/ - public Arguments help ( void delegate ( istring arg, istring help ) dg ) + public Arguments help ( scope void delegate ( istring arg, istring help ) dg ) { foreach ( arg; args ) { @@ -2155,7 +2155,7 @@ public class Arguments ***********************************************************************/ - public Argument bind ( Inspector inspector ) + public Argument bind ( scope Inspector inspector ) { this.inspector = inspector; @@ -2177,7 +2177,7 @@ public class Arguments ***********************************************************************/ - public Argument bind ( Invoker invoker ) + public Argument bind ( scope Invoker invoker ) { this.invoker = invoker; @@ -2675,11 +2675,11 @@ unittest // Test for D2 'static immutable' unittest { - const istring name_ = "encode"; - const istring conflicts_ = "decode"; - const istring[] restrict_ = [ "json", "yaml" ]; - const istring requires_ = "input"; - const istring help_ = "Convert from native format to JSON/Yaml"; + static immutable istring name_ = "encode"; + static immutable istring conflicts_ = "decode"; + static immutable istring[] restrict_ = [ "json", "yaml" ]; + static immutable istring requires_ = "input"; + static immutable istring help_ = "Convert from native format to JSON/Yaml"; auto args = new Arguments; args(name_) diff --git a/src/ocean/text/Search.d b/src/ocean/text/Search.d index 948f00bc7..d173515b8 100644 --- a/src/ocean/text/Search.d +++ b/src/ocean/text/Search.d @@ -131,7 +131,7 @@ public struct FindFruct(T) void match (T[] what) { - this.what = what; + (&this).what = what; } /*********************************************************************** @@ -247,7 +247,7 @@ public struct FindFruct(T) T[] what, content; - int opApply (int delegate (ref size_t index) dg) + int opApply (scope int delegate (ref size_t index) dg) { int ret; size_t mark; @@ -329,8 +329,8 @@ public struct SearchFruct(T) void match (Const!(T)[] what) { offsets[] = what.length + 1; - this.fore = true; - this.what = what; + (&this).fore = true; + (&this).what = what; reset; } @@ -553,7 +553,7 @@ public struct SearchFruct(T) private void reset () { - auto what = cast(char[]) this.what; + auto what = cast(char[]) (&this).what; if (fore) for (ptrdiff_t i=0; i < what.length; ++i) offsets[what[i]] = what.length - i; @@ -585,7 +585,7 @@ public struct SearchFruct(T) T[] content; size_t delegate(T[], size_t) call; - int opApply (int delegate (ref size_t index) dg) + int opApply (scope int delegate (ref size_t index) dg) { int ret; size_t mark; @@ -613,7 +613,7 @@ public struct SearchFruct(T) size_t delegate(T[], size_t) call; - int opApply (int delegate (ref T[] token) dg) + int opApply (scope int delegate (ref T[] token) dg) { size_t ret, pos, diff --git a/src/ocean/text/UnicodeData.d b/src/ocean/text/UnicodeData.d index 905889fdd..57cb4e7f2 100644 --- a/src/ocean/text/UnicodeData.d +++ b/src/ocean/text/UnicodeData.d @@ -199,7 +199,7 @@ FoldingCaseData* getFoldingCaseData(dchar code) //shortcuts, make source file smaller -private const +private static immutable Lu = UnicodeData.GeneralCategory.Lu, Ll = UnicodeData.GeneralCategory.Ll, Lt = UnicodeData.GeneralCategory.Lt, diff --git a/src/ocean/text/Util.d b/src/ocean/text/Util.d index 88404a555..13d6696f5 100644 --- a/src/ocean/text/Util.d +++ b/src/ocean/text/Util.d @@ -1311,15 +1311,15 @@ private struct LineFruct(T) { private T[] src; - int opApply (int delegate (ref T[] line) dg) + int opApply (scope int delegate (ref T[] line) dg) { int ret; size_t pos, mark; T[] line; - const T nl = '\n'; - const T cr = '\r'; + enum T nl = '\n'; + enum T cr = '\r'; while ((pos = locate (src, nl, mark)) < src.length) { @@ -1354,7 +1354,7 @@ private struct DelimFruct(T) private T[] src; private Const!(T)[] set; - int opApply (int delegate (ref T[] token) dg) + int opApply (scope int delegate (ref T[] token) dg) { int ret; size_t pos, @@ -1402,7 +1402,7 @@ public struct PatternFruct(T) private T[] src, sub; private Const!(Unqual!(T))[] pattern; - int opApply (int delegate (ref T[] token) dg) + int opApply (scope int delegate (ref T[] token) dg) { int ret; size_t pos, @@ -1440,7 +1440,7 @@ private struct QuoteFruct(T) private Const!(T)[] src; private Const!(T)[] set; - int opApply (int delegate (ref Const!(T)[] token) dg) + int opApply (scope int delegate (ref Const!(T)[] token) dg) { int ret; size_t mark; diff --git a/src/ocean/text/arguments/TimeIntervalArgs.d b/src/ocean/text/arguments/TimeIntervalArgs.d index 43b3fdfcf..75f5ecb81 100644 --- a/src/ocean/text/arguments/TimeIntervalArgs.d +++ b/src/ocean/text/arguments/TimeIntervalArgs.d @@ -68,7 +68,7 @@ struct TimestampInterval } /// Number of seconds in the day for creating day ranges. -const SECONDS_IN_DAY = 86_400; +static immutable SECONDS_IN_DAY = 86_400; /*************************************************************************** @@ -240,7 +240,7 @@ private long parseDateString ( cstring value, bool include_end_date = false ) version ( UnitTest ) { // 2019-04-01 15:26:32 - const TEST_TIME_NOW = 1554132392; + static immutable TEST_TIME_NOW = 1554132392; /*************************************************************************** diff --git a/src/ocean/text/convert/DateTime_tango.d b/src/ocean/text/convert/DateTime_tango.d index 66add25be..4ee37772f 100644 --- a/src/ocean/text/convert/DateTime_tango.d +++ b/src/ocean/text/convert/DateTime_tango.d @@ -172,12 +172,12 @@ struct DateTimeLocale auto res=Result(output); scope sink = (cstring v) { res ~= v; return v.length; }; - this.formatCustom(sink, dateTime, layout); + (&this).formatCustom(sink, dateTime, layout); return res.get; } /// Ditto - public void format (size_t delegate(cstring) output, Time dateTime, + public void format (scope size_t delegate(cstring) output, Time dateTime, cstring layout) { // default to general format @@ -593,7 +593,7 @@ struct DateTimeLocale **********************************************************************/ - private void formatCustom (size_t delegate(cstring) sink, Time dateTime, + private void formatCustom (scope size_t delegate(cstring) sink, Time dateTime, cstring format) { uint len, @@ -838,7 +838,7 @@ struct DateTimeLocale **********************************************************************/ - private static int parseQuote (size_t delegate(cstring) sink, + private static int parseQuote (scope size_t delegate(cstring) sink, cstring format, int pos) { int start = pos; @@ -981,11 +981,11 @@ public struct AsPrettyStr { private Time value; - public void toString (FormatterSink sink) + public void toString (scope FormatterSink sink) { // Layout defaults to 'G' scope dg = (cstring s) { sink(s); return s.length; }; - DateTimeDefault.format(dg, this.value, ""); + DateTimeDefault.format(dg, (&this).value, ""); } } diff --git a/src/ocean/text/convert/Formatter.d b/src/ocean/text/convert/Formatter.d index a384fd51f..fdf3f96f8 100644 --- a/src/ocean/text/convert/Formatter.d +++ b/src/ocean/text/convert/Formatter.d @@ -227,7 +227,7 @@ public mstring snformat (Args...) (mstring buffer, cstring fmt, Args args) *******************************************************************************/ -public bool sformat (Args...) (FormatterSink sink, cstring fmt, Args args) +public bool sformat (Args...) (scope FormatterSink sink, cstring fmt, Args args) { FormatInfo info; size_t nextIndex; @@ -297,7 +297,7 @@ public bool sformat (Args...) (FormatterSink sink, cstring fmt, Args args) *******************************************************************************/ -private void widthSink (FormatterSink sink, cstring str, ref Const!(FormatInfo) f) +private void widthSink (scope FormatterSink sink, cstring str, ref Const!(FormatInfo) f) { if (f.flags & Flags.Width) { @@ -365,7 +365,7 @@ private void widthSink (FormatterSink sink, cstring str, ref Const!(FormatInfo) *******************************************************************************/ -private void handle (T) (T v, FormatInfo f, FormatterSink sf, ElemSink se) +private void handle (T) (T v, FormatInfo f, scope FormatterSink sf, scope ElemSink se) { /** The order in which the following conditions are applied matters. * Explicit type checks (e.g. associative array, or `is(T == V)`) @@ -589,13 +589,13 @@ private template IsTypeofNull (T) version (D_Version2) { static if (is(T == typeof(null))) - public const bool IsTypeofNull = true; + public static immutable bool IsTypeofNull = true; else - public const bool IsTypeofNull = false; + public static immutable bool IsTypeofNull = false; } else { - public const bool IsTypeofNull = false; + public static immutable bool IsTypeofNull = false; } } @@ -650,7 +650,7 @@ private RetType nullWrapper (T, RetType) (T* v, lazy RetType expr, *******************************************************************************/ -private FormatInfo consume (FormatterSink sink, ref cstring fmt) +private FormatInfo consume (scope FormatterSink sink, ref cstring fmt) { FormatInfo ret; auto s = fmt.ptr; @@ -796,9 +796,9 @@ private Const!(char)* skipSpace (Const!(char)* s, Const!(char)* end) *******************************************************************************/ -private void writeSpace (FormatterSink s, size_t n) +private void writeSpace (scope FormatterSink s, size_t n) { - const istring Spaces32 = " "; + static immutable istring Spaces32 = " "; // Make 'n' a multiple of Spaces32.length (32) s(Spaces32[0 .. n % Spaces32.length]); @@ -854,15 +854,15 @@ private bool readNumber (out size_t f, ref Const!(char)* s) *******************************************************************************/ -private void writePointer (in void* v, ref FormatInfo f, ElemSink se) +private void writePointer (in void* v, ref FormatInfo f, scope ElemSink se) { alias void* T; version (D_Version2) mixin("enum int l = (T.sizeof * 2);"); else - const int l = (T.sizeof * 2); // Needs to be int to avoid suffix - const defaultFormat = "X" ~ l.stringof ~ "#"; + static immutable int l = (T.sizeof * 2); // Needs to be int to avoid suffix + static immutable defaultFormat = "X" ~ l.stringof ~ "#"; if (v is null) se("null", f); diff --git a/src/ocean/text/convert/Formatter_test.d b/src/ocean/text/convert/Formatter_test.d index 66609111f..0afc8a820 100644 --- a/src/ocean/text/convert/Formatter_test.d +++ b/src/ocean/text/convert/Formatter_test.d @@ -25,7 +25,7 @@ unittest static struct Foo { int i = 0x2A; - void toString (void delegate (cstring) sink) + void toString (scope void delegate (cstring) sink) { sink("Hello void"); } @@ -350,7 +350,7 @@ unittest // Support for new sink-based toString static struct S1 { - void toString (FormatterSink sink) + void toString (scope FormatterSink sink) { sink("42424242424242"); } @@ -361,7 +361,7 @@ unittest // For classes too static class C1 { - void toString (FormatterSink sink) + void toString (scope FormatterSink sink) { sink("42424242424242"); } @@ -372,7 +372,7 @@ unittest // Compile time support is awesome, isn't it ? static struct S2 { - void toString (FormatterSink sink, cstring default_ = "42") + void toString (scope FormatterSink sink, cstring default_ = "42") { sink(default_); } @@ -434,7 +434,7 @@ unittest void[] varr = arr; test(format("{}", varr) == "[42, 43, 44, 45, 92]"); - const ubyte[5] carr = [42, 43, 44, 45, 92]; + static immutable ubyte[5] carr = [42, 43, 44, 45, 92]; auto cvarr = carr; // Immutable, cannot be marked `const` in D1 test(format("{}", cvarr) == "[42, 43, 44, 45, 92]"); @@ -452,12 +452,12 @@ unittest // Const tests unittest { - const int ai = 42; - const double ad = 42.00; + static immutable int ai = 42; + static immutable double ad = 42.00; static struct Answer_struct { int value; } static class Answer_class { - public override istring toString () /* d1to2fix_inject: const */ + public override istring toString () const { return "42"; } @@ -483,7 +483,7 @@ unittest Object* o = cast(Object*) 0xDEADBEEF_DEADBEEF; void* ptr = cast(void*) 0xDEADBEEF_DEADBEEF; - const istring expected = "0XDEADBEEFDEADBEEF"; + static immutable istring expected = "0XDEADBEEFDEADBEEF"; istring object_str = format("{}", o); istring ptr_str = format("{}", ptr); istring null_str = format("{}", null); @@ -512,8 +512,8 @@ unittest unittest { - const bool YES = true; - const bool NO = false; + static immutable bool YES = true; + static immutable bool NO = false; test(format("{} -- {}", YES, NO) == "true -- false"); } diff --git a/src/ocean/text/convert/Hash.d b/src/ocean/text/convert/Hash.d index c1d26ca2f..04e596d1a 100644 --- a/src/ocean/text/convert/Hash.d +++ b/src/ocean/text/convert/Hash.d @@ -46,7 +46,7 @@ version (UnitTest) *******************************************************************************/ -public const HashDigits = hash_t.sizeof * 2; +public static immutable HashDigits = hash_t.sizeof * 2; /******************************************************************************* diff --git a/src/ocean/text/convert/Hex.d b/src/ocean/text/convert/Hex.d index ee0da63a2..b6d44a743 100644 --- a/src/ocean/text/convert/Hex.d +++ b/src/ocean/text/convert/Hex.d @@ -154,7 +154,7 @@ unittest public mstring hexToLower ( mstring str ) { - const to_lower = ('A' - 'a'); + static immutable to_lower = ('A' - 'a'); foreach ( ref c; str ) { if ( c >= 'A' && c <= 'F' ) @@ -214,7 +214,7 @@ unittest *******************************************************************************/ package bool handleRadix ( cstring str, bool allow_radix, - bool delegate ( cstring ) process ) + scope bool delegate ( cstring ) process ) { if ( str.length >= 2 && str[0..2] == "0x" ) { diff --git a/src/ocean/text/convert/Integer.d b/src/ocean/text/convert/Integer.d index 5fcd8b824..baf1198c9 100644 --- a/src/ocean/text/convert/Integer.d +++ b/src/ocean/text/convert/Integer.d @@ -204,7 +204,7 @@ public bool toUlong ( T ) ( T[] digits, out ulong value, uint radix = 0 ) public bool floatStringToInt ( T = ulong ) ( cstring float_str, out T value, size_t decimal_points = 0 ) { - const MaxDecimal = 16; + static immutable MaxDecimal = 16; verify(decimal_points <= MaxDecimal); diff --git a/src/ocean/text/convert/Integer_tango.d b/src/ocean/text/convert/Integer_tango.d index 21de24f35..83c16d4f0 100644 --- a/src/ocean/text/convert/Integer_tango.d +++ b/src/ocean/text/convert/Integer_tango.d @@ -246,12 +246,12 @@ Const!(T)[] formatter(T, N) (T[] dst, N i_, char type, char pre, int width) Unqual!(N) i = i_; - const Immut!(T)[] lower = "0123456789abcdef"; - const Immut!(T)[] upper = "0123456789ABCDEF"; + static immutable Immut!(T)[] lower = "0123456789abcdef"; + static immutable Immut!(T)[] upper = "0123456789ABCDEF"; alias _FormatterInfo!(Immut!(T)) Info; - const Info[] formats = [ + static immutable Info[] formats = [ { 10, null, lower}, { -10, "-" , lower}, { 10, " " , lower}, diff --git a/src/ocean/text/convert/TimeStamp.d b/src/ocean/text/convert/TimeStamp.d index 1313cf98e..ea2288d81 100644 --- a/src/ocean/text/convert/TimeStamp.d +++ b/src/ocean/text/convert/TimeStamp.d @@ -166,7 +166,7 @@ Const!(T)[] format(T) (T[] output, Time t) unittest { - const STR_1970 = "Thu, 01 Jan 1970 00:00:00 GMT"; + static immutable STR_1970 = "Thu, 01 Jan 1970 00:00:00 GMT"; mstring buf; buf.length = 29; test(format(buf, Time.epoch1970) == STR_1970); @@ -215,7 +215,7 @@ Const!(T)[] format8601(T) (T[] output, Time t) unittest { - const STR_1970 = "1970-01-01T00:00:00Z"; + static immutable STR_1970 = "1970-01-01T00:00:00Z"; mstring buf; buf.length = 29; test(format8601(buf, Time.epoch1970) == STR_1970); diff --git a/src/ocean/text/convert/Utf.d b/src/ocean/text/convert/Utf.d index 4f305b500..e063c104d 100644 --- a/src/ocean/text/convert/Utf.d +++ b/src/ocean/text/convert/Utf.d @@ -89,13 +89,13 @@ Const!(dchar)[] toString (Const!(dchar)[] src, dchar[] dst, size_t* ate=null) {r *******************************************************************************/ -public void toString (Const!(char)[] input, size_t delegate(cstring) dg) +public void toString (Const!(char)[] input, scope size_t delegate(cstring) dg) { dg(input); } /// Ditto -public void toString (Const!(wchar)[] input, size_t delegate(cstring) dg) +public void toString (Const!(wchar)[] input, scope size_t delegate(cstring) dg) { char[4] buff; foreach (size_t idx, wchar c; input) @@ -121,7 +121,7 @@ public void toString (Const!(wchar)[] input, size_t delegate(cstring) dg) } /// Ditto -public void toString (Const!(dchar)[] input, size_t delegate(cstring) dg) +public void toString (Const!(dchar)[] input, scope size_t delegate(cstring) dg) { char[4] buff; foreach (size_t idx, dchar c; input) diff --git a/src/ocean/text/convert/Utf_test.d b/src/ocean/text/convert/Utf_test.d index 29da474f4..3675db161 100644 --- a/src/ocean/text/convert/Utf_test.d +++ b/src/ocean/text/convert/Utf_test.d @@ -18,7 +18,7 @@ import ocean.core.Test; unittest { - const istring original = "Hello \u262F \u0842 \uEFFF"; + static immutable istring original = "Hello \u262F \u0842 \uEFFF"; cstring r; toString(original, (cstring x) { r ~= x; return x.length; }); test(original == r); @@ -26,7 +26,7 @@ unittest unittest { - const wchar[] original = "Hello \u262F \u1666 \uEFFF"w; + static immutable wchar[] original = "Hello \u262F \u1666 \uEFFF"w; cstring r; toString(original, (cstring x) { r ~= x; return x.length; }); test("Hello \u262F \u1666 \uEFFF" == r); @@ -34,7 +34,7 @@ unittest unittest { - const dchar[] original = "Hello \u262F \u0842 \uE420"d; + static immutable dchar[] original = "Hello \u262F \u0842 \uE420"d; cstring r; toString(original, (cstring x) { r ~= x; return x.length; }); test("Hello \u262F \u0842 \uE420" == r); diff --git a/src/ocean/text/csv/CSV.d b/src/ocean/text/csv/CSV.d index 56a1731c5..0363be124 100644 --- a/src/ocean/text/csv/CSV.d +++ b/src/ocean/text/csv/CSV.d @@ -137,7 +137,7 @@ public class CSV ***************************************************************************/ - public void parse ( InputStream stream, RowDg row_dg ) + public void parse ( InputStream stream, scope RowDg row_dg ) { verify(stream !is null, "InputStream is null"); verify(row_dg !is null, "Row delegate is null"); @@ -227,7 +227,7 @@ public class CSV ***************************************************************************/ - private bool parseRow ( RowDg row_dg ) + private bool parseRow ( scope RowDg row_dg ) { this.fields.clear(); diff --git a/src/ocean/text/csv/HeadingsCSV.d b/src/ocean/text/csv/HeadingsCSV.d index c25f83651..8bdd365d5 100644 --- a/src/ocean/text/csv/HeadingsCSV.d +++ b/src/ocean/text/csv/HeadingsCSV.d @@ -171,7 +171,7 @@ public class HeadingsCSV ***************************************************************************/ - public void parse ( InputStream stream, RowDg row_dg ) + public void parse ( InputStream stream, scope RowDg row_dg ) { this.headings.clear(); @@ -229,7 +229,7 @@ public class HeadingsCSV ***************************************************************************/ public void parse ( InputStream stream, cstring[] include_headings, - RowDg row_dg ) + scope RowDg row_dg ) { this.headings.clear(); this.heading_included.length = 0; diff --git a/src/ocean/text/entities/HtmlEntitySet.d b/src/ocean/text/entities/HtmlEntitySet.d index 81b860f99..9860f50c2 100644 --- a/src/ocean/text/entities/HtmlEntitySet.d +++ b/src/ocean/text/entities/HtmlEntitySet.d @@ -47,7 +47,7 @@ public class HtmlEntitySet : XmlEntitySet ***************************************************************************/ - protected const Entity[] ISO8859_1 = xml_entities ~ ISO8859_1_extra; + protected static immutable Entity[] ISO8859_1 = xml_entities ~ ISO8859_1_extra; /*************************************************************************** @@ -57,7 +57,7 @@ public class HtmlEntitySet : XmlEntitySet ***************************************************************************/ - public const Entity[] html_entities = ISO8859_1 ~ ISO8859_15_extra; + public static immutable Entity[] html_entities = ISO8859_1 ~ ISO8859_15_extra; /*************************************************************************** @@ -67,7 +67,7 @@ public class HtmlEntitySet : XmlEntitySet ***************************************************************************/ - protected const Entity[] ISO8859_1_extra = + protected static immutable Entity[] ISO8859_1_extra = [ {"nbsp", 0x00A0}, // ' ' {"iexcl", 0x00A1}, // '¡' @@ -175,7 +175,7 @@ public class HtmlEntitySet : XmlEntitySet ***************************************************************************/ - protected const Entity[] ISO8859_15_extra = + protected static immutable Entity[] ISO8859_15_extra = [ {"OElig", 0x0152}, // 'Œ' {"OElig", 0x0153}, // 'œ' diff --git a/src/ocean/text/entities/XmlEntitySet.d b/src/ocean/text/entities/XmlEntitySet.d index 9ddebc0d0..f5f90f987 100644 --- a/src/ocean/text/entities/XmlEntitySet.d +++ b/src/ocean/text/entities/XmlEntitySet.d @@ -46,7 +46,7 @@ public class XmlEntitySet : IEntitySet ***************************************************************************/ - public const Entity[] xml_entities = + public static immutable Entity[] xml_entities = [ {"amp", 0x0026}, // '&' {"quot", 0x0022}, // '"' diff --git a/src/ocean/text/entities/model/IEntitySet.d b/src/ocean/text/entities/model/IEntitySet.d index bf4da736a..57045e6ad 100644 --- a/src/ocean/text/entities/model/IEntitySet.d +++ b/src/ocean/text/entities/model/IEntitySet.d @@ -274,7 +274,7 @@ public abstract class IEntitySet ***************************************************************************/ - public int opApply ( int delegate ( ref Const!(istring), ref Const!(dchar) ) dg ) + public int opApply ( scope int delegate ( ref Const!(istring), ref Const!(dchar) ) dg ) { int res; foreach ( ref entity; this.entities ) diff --git a/src/ocean/text/formatter/SmartUnion.d b/src/ocean/text/formatter/SmartUnion.d index 74eb4b59b..f96faec98 100644 --- a/src/ocean/text/formatter/SmartUnion.d +++ b/src/ocean/text/formatter/SmartUnion.d @@ -108,22 +108,22 @@ private struct SmartUnionFormatter ( SU ) ***************************************************************************/ - public void toString ( void delegate ( cstring chunk ) sink ) + public void toString ( scope void delegate ( cstring chunk ) sink ) { - if ( this.smart_union.active ) + if ( (&this).smart_union.active ) { - if ( this.include_name ) - sformat(sink, "<{}>: ", this.smart_union.active_name); + if ( (&this).include_name ) + sformat(sink, "<{}>: ", (&this).smart_union.active_name); This.sink = sink; scope ( exit ) This.sink = null; - callWithActive!(formatUnionMember)(this.smart_union); + callWithActive!(formatUnionMember)((&this).smart_union); } else { - if ( this.include_name ) - sformat(sink, "<{}>", this.smart_union.active_name); + if ( (&this).include_name ) + sformat(sink, "<{}>", (&this).smart_union.active_name); } } diff --git a/src/ocean/text/json/Json.d b/src/ocean/text/json/Json.d index 6dda12a69..b2258761d 100644 --- a/src/ocean/text/json/Json.d +++ b/src/ocean/text/json/Json.d @@ -443,7 +443,7 @@ class Json(T) : JsonParser!(T) { name = key; value = val; - return this; + return (&this); } } @@ -468,7 +468,7 @@ class Json(T) : JsonParser!(T) Composite reset () { head = tail = null; - return this; + return (&this); } /*************************************************************** @@ -483,7 +483,7 @@ class Json(T) : JsonParser!(T) tail.next = a, tail = a; else head = tail = a; - return this; + return (&this); } /*************************************************************** @@ -496,7 +496,7 @@ class Json(T) : JsonParser!(T) { foreach (attr; set) append (attr); - return this; + return (&this); } /*************************************************************** @@ -568,7 +568,7 @@ class Json(T) : JsonParser!(T) { private Attribute head; - int opApply (int delegate(ref Const!(T)[] key, ref Value val) dg) + int opApply (scope int delegate(ref Const!(T)[] key, ref Value val) dg) { int res; @@ -625,7 +625,7 @@ class Json(T) : JsonParser!(T) equals_t opEquals (JsonValue rhs) { - return *this is rhs; + return *(&this) is rhs; } /*************************************************************** @@ -668,7 +668,7 @@ class Json(T) : JsonParser!(T) ***************************************************************/ - bool toString (void delegate(Const!(T)[]) dg) + bool toString (scope void delegate(Const!(T)[]) dg) { if (type is Type.RawString) dg(string); @@ -728,7 +728,7 @@ class Json(T) : JsonParser!(T) { type = escaped ? Type.String : Type.RawString; string = str; - return this; + return (&this); } /*************************************************************** @@ -741,7 +741,7 @@ class Json(T) : JsonParser!(T) { type = Type.Object; object = obj; - return this; + return (&this); } /*************************************************************** @@ -754,7 +754,7 @@ class Json(T) : JsonParser!(T) { type = Type.Number; number = num; - return this; + return (&this); } /*************************************************************** @@ -766,7 +766,7 @@ class Json(T) : JsonParser!(T) Value set (bool b) { type = b ? Type.True : Type.False; - return this; + return (&this); } /*************************************************************** @@ -779,7 +779,7 @@ class Json(T) : JsonParser!(T) { type = Type.Array; array = a; - return this; + return (&this); } /*************************************************************** @@ -791,7 +791,7 @@ class Json(T) : JsonParser!(T) Value reset () { type = Type.Null; - return this; + return (&this); } /*************************************************************** @@ -827,7 +827,7 @@ class Json(T) : JsonParser!(T) ***************************************************************/ - Value print (void delegate(Const!(T)[]) append, Const!(T)[] space=null, int decimals=2) + Value print (scope void delegate(Const!(T)[]) append, Const!(T)[] space=null, int decimals=2) { auto indent = 0; @@ -929,8 +929,8 @@ class Json(T) : JsonParser!(T) } } - printValue (this); - return this; + printValue ((&this)); + return (&this); } /*************************************************************** @@ -941,8 +941,8 @@ class Json(T) : JsonParser!(T) private Value set (Type type) { - this.type = type; - return this; + (&this).type = type; + return (&this); } /*************************************************************** diff --git a/src/ocean/text/json/JsonEscape.d b/src/ocean/text/json/JsonEscape.d index c6d2bdc43..1317de32d 100644 --- a/src/ocean/text/json/JsonEscape.d +++ b/src/ocean/text/json/JsonEscape.d @@ -104,7 +104,7 @@ unittest ******************************************************************************/ -void unescape(T, TC) (T[] src, void delegate(TC[]) emit) +void unescape(T, TC) (T[] src, scope void delegate(TC[]) emit) { static assert (is(Unqual!(T) == Unqual!(TC))); @@ -220,7 +220,7 @@ void unescape(T, TC) (T[] src, void delegate(TC[]) emit) ******************************************************************************/ -void escape(T, TC) (T[] src, void delegate(TC[]) emit) +void escape(T, TC) (T[] src, scope void delegate(TC[]) emit) { static assert (is(Unqual!(TC) == Unqual!(T))); diff --git a/src/ocean/text/json/JsonExtractor.d b/src/ocean/text/json/JsonExtractor.d index 1ffd43832..3c0e24db2 100644 --- a/src/ocean/text/json/JsonExtractor.d +++ b/src/ocean/text/json/JsonExtractor.d @@ -632,7 +632,7 @@ struct JsonExtractor **********************************************************************/ public this ( Parser json, GetField[] fields_to_reset, - IteratorDg iterator_dg, bool skip_null = false ) + scope IteratorDg iterator_dg, bool skip_null = false ) { super(json, skip_null); @@ -839,7 +839,7 @@ struct JsonExtractor unittest { - const content = + enum content = `{ "id":"8c97472e-098e-4baa-aa63-4a3f2aab10c6", "imp": @@ -979,7 +979,7 @@ struct JsonExtractor t.test!("==")(w.value, ""[]); t.test!("==")(w.type, Type.Empty); - const content2 = `{"imp":null}`; + enum content2 = `{"imp":null}`; try { diff --git a/src/ocean/text/json/JsonParser.d b/src/ocean/text/json/JsonParser.d index 29a89bc48..42f2eaabb 100644 --- a/src/ocean/text/json/JsonParser.d +++ b/src/ocean/text/json/JsonParser.d @@ -64,9 +64,9 @@ class JsonParser(T, bool AllowNaN = false) void reset (Const!(T)[] text) { - this.text = text; - this.ptr = text.ptr; - this.end = this.ptr + text.length; + (&this).text = text; + (&this).ptr = text.ptr; + (&this).end = (&this).ptr + text.length; } } @@ -460,7 +460,7 @@ public class JsonParserException : Exception unittest { - const istring json = + static immutable istring json = `{ "glossary": { "title": "example glossary", diff --git a/src/ocean/text/json/JsonParserIter.d b/src/ocean/text/json/JsonParserIter.d index 77f4bec47..03da49e2a 100644 --- a/src/ocean/text/json/JsonParserIter.d +++ b/src/ocean/text/json/JsonParserIter.d @@ -97,7 +97,7 @@ class JsonParserIter(bool AllowNaN = false) : JsonParser!(char, AllowNaN) **************************************************************************/ - public const TokenClass[Token.max + 1] token_classes = + public static immutable TokenClass[Token.max + 1] token_classes = [ Token.Empty: TokenClass.Other, Token.Name: TokenClass.Other, @@ -121,7 +121,7 @@ class JsonParserIter(bool AllowNaN = false) : JsonParser!(char, AllowNaN) **************************************************************************/ - public const int[Token.max + 1] nestings = + public static immutable int[Token.max + 1] nestings = [ Token.BeginObject: +1, Token.BeginArray: +1, @@ -197,7 +197,7 @@ class JsonParserIter(bool AllowNaN = false) : JsonParser!(char, AllowNaN) **************************************************************************/ - public int opApply ( int delegate ( ref Token type, ref cstring value ) dg ) + public int opApply ( scope int delegate ( ref Token type, ref cstring value ) dg ) { int result = 0; @@ -222,7 +222,7 @@ class JsonParserIter(bool AllowNaN = false) : JsonParser!(char, AllowNaN) **************************************************************************/ - public int opApply ( int delegate ( ref Token type, ref cstring name, + public int opApply ( scope int delegate ( ref Token type, ref cstring name, ref cstring value ) dg ) { int result = 0; @@ -510,7 +510,7 @@ class JsonParserIter(bool AllowNaN = false) : JsonParser!(char, AllowNaN) **************************************************************************/ private cstring nextNamedValue ( cstring name, out bool found, - bool delegate ( Token ) type_match_dg ) + scope bool delegate ( Token ) type_match_dg ) { bool got_name; foreach ( type, value; this ) diff --git a/src/ocean/text/regex/PCRE.d b/src/ocean/text/regex/PCRE.d index 426658594..5e2a15752 100644 --- a/src/ocean/text/regex/PCRE.d +++ b/src/ocean/text/regex/PCRE.d @@ -155,7 +155,7 @@ public class PCRE ***************************************************************************/ - public const int DEFAULT_COMPLEXITY_LIMIT = 0; + public static immutable int DEFAULT_COMPLEXITY_LIMIT = 0; public int complexity_limit = DEFAULT_COMPLEXITY_LIMIT; @@ -523,7 +523,7 @@ unittest unittest { - void test ( bool delegate ( ) dg, bool match ) + void test ( scope bool delegate ( ) dg, bool match ) { auto t = new CounterNamedTest; t.test!("==")(match, dg()); diff --git a/src/ocean/text/regex/c/pcre.d b/src/ocean/text/regex/c/pcre.d index c03318f39..1546d1987 100644 --- a/src/ocean/text/regex/c/pcre.d +++ b/src/ocean/text/regex/c/pcre.d @@ -42,96 +42,96 @@ struct pcre_extra { }; -const int PCRE_CASELESS = 0x00000001; -const int PCRE_MULTILINE = 0x00000002; -const int PCRE_DOTALL = 0x00000004; -const int PCRE_EXTENDED = 0x00000008; -const int PCRE_ANCHORED = 0x00000010; -const int PCRE_DOLLAR_ENDONLY = 0x00000020; -const int PCRE_EXTRA = 0x00000040; -const int PCRE_NOTBOL = 0x00000080; -const int PCRE_NOTEOL = 0x00000100; -const int PCRE_UNGREEDY = 0x00000200; -const int PCRE_NOTEMPTY = 0x00000400; -const int PCRE_UTF8 = 0x00000800; -const int PCRE_NO_AUTO_CAPTURE = 0x00001000; -const int PCRE_NO_UTF8_CHECK = 0x00002000; -const int PCRE_AUTO_CALLOUT = 0x00004000; -const int PCRE_PARTIAL = 0x00008000; -const int PCRE_DFA_SHORTEST = 0x00010000; -const int PCRE_DFA_RESTART = 0x00020000; -const int PCRE_FIRSTLINE = 0x00040000; -const int PCRE_DUPNAMES = 0x00080000; -const int PCRE_NEWLINE_CR = 0x00100000; -const int PCRE_NEWLINE_LF = 0x00200000; -const int PCRE_NEWLINE_CRLF = 0x00300000; -const int PCRE_NEWLINE_ANY = 0x00400000; -const int PCRE_NEWLINE_ANYCRLF = 0x00500000; -const int PCRE_BSR_ANYCRLF = 0x00800000; -const int PCRE_BSR_UNICODE = 0x01000000; -const int PCRE_JAVASCRIPT_COMPAT = 0x02000000; - - -const int PCRE_ERROR_NOMATCH = (-1); -const int PCRE_ERROR_NULL = (-2); -const int PCRE_ERROR_BADOPTION = (-3); -const int PCRE_ERROR_BADMAGIC = (-4); -const int PCRE_ERROR_UNKNOWN_OPCODE = (-5); -const int PCRE_ERROR_UNKNOWN_NODE = (-5); -const int PCRE_ERROR_NOMEMORY = (-6); -const int PCRE_ERROR_NOSUBSTRING = (-7); -const int PCRE_ERROR_MATCHLIMIT = (-8); -const int PCRE_ERROR_CALLOUT = (-9); -const int PCRE_ERROR_BADUTF8 = (-10); -const int PCRE_ERROR_BADUTF8_OFFSET = (-11); -const int PCRE_ERROR_PARTIAL = (-12); -const int PCRE_ERROR_BADPARTIAL = (-13); -const int PCRE_ERROR_INTERNAL = (-14); -const int PCRE_ERROR_BADCOUNT = (-15); -const int PCRE_ERROR_DFA_UITEM = (-16); -const int PCRE_ERROR_DFA_UCOND = (-17); -const int PCRE_ERROR_DFA_UMLIMIT = (-18); -const int PCRE_ERROR_DFA_WSSIZE = (-19); -const int PCRE_ERROR_DFA_RECURSE = (-20); -const int PCRE_ERROR_RECURSIONLIMIT = (-21); -const int PCRE_ERROR_NULLWSLIMIT = (-22); -const int PCRE_ERROR_BADNEWLINE = (-23); - - -const int PCRE_INFO_OPTIONS = 0; -const int PCRE_INFO_SIZE = 1; -const int PCRE_INFO_CAPTURECOUNT = 2; -const int PCRE_INFO_BACKREFMAX = 3; -const int PCRE_INFO_FIRSTBYTE = 4; -const int PCRE_INFO_FIRSTCHAR = 4; -const int PCRE_INFO_FIRSTTABLE = 5; -const int PCRE_INFO_LASTLITERAL = 6; -const int PCRE_INFO_NAMEENTRYSIZE = 7; -const int PCRE_INFO_NAMECOUNT = 8; -const int PCRE_INFO_NAMETABLE = 9; -const int PCRE_INFO_STUDYSIZE = 10; -const int PCRE_INFO_DEFAULT_TABLES = 11; -const int PCRE_INFO_OKPARTIAL = 12; -const int PCRE_INFO_JCHANGED = 13; -const int PCRE_INFO_HASCRORLF = 14; - - -const int PCRE_CONFIG_UTF8 = 0; -const int PCRE_CONFIG_NEWLINE = 1; -const int PCRE_CONFIG_LINK_SIZE = 2; -const int PCRE_CONFIG_POSIX_MALLOC_THRESHOLD = 3; -const int PCRE_CONFIG_MATCH_LIMIT = 4; -const int PCRE_CONFIG_STACKRECURSE = 5; -const int PCRE_CONFIG_UNICODE_PROPERTIES = 6; -const int PCRE_CONFIG_MATCH_LIMIT_RECURSION = 7; -const int PCRE_CONFIG_BSR = 8; - - -const int PCRE_EXTRA_STUDY_DATA = 0x0001; -const int PCRE_EXTRA_MATCH_LIMIT = 0x0002; -const int PCRE_EXTRA_CALLOUT_DATA = 0x0004; -const int PCRE_EXTRA_TABLES = 0x0008; -const int PCRE_EXTRA_MATCH_LIMIT_RECURSION = 0x0010; +static immutable int PCRE_CASELESS = 0x00000001; +static immutable int PCRE_MULTILINE = 0x00000002; +static immutable int PCRE_DOTALL = 0x00000004; +static immutable int PCRE_EXTENDED = 0x00000008; +static immutable int PCRE_ANCHORED = 0x00000010; +static immutable int PCRE_DOLLAR_ENDONLY = 0x00000020; +static immutable int PCRE_EXTRA = 0x00000040; +static immutable int PCRE_NOTBOL = 0x00000080; +static immutable int PCRE_NOTEOL = 0x00000100; +static immutable int PCRE_UNGREEDY = 0x00000200; +static immutable int PCRE_NOTEMPTY = 0x00000400; +static immutable int PCRE_UTF8 = 0x00000800; +static immutable int PCRE_NO_AUTO_CAPTURE = 0x00001000; +static immutable int PCRE_NO_UTF8_CHECK = 0x00002000; +static immutable int PCRE_AUTO_CALLOUT = 0x00004000; +static immutable int PCRE_PARTIAL = 0x00008000; +static immutable int PCRE_DFA_SHORTEST = 0x00010000; +static immutable int PCRE_DFA_RESTART = 0x00020000; +static immutable int PCRE_FIRSTLINE = 0x00040000; +static immutable int PCRE_DUPNAMES = 0x00080000; +static immutable int PCRE_NEWLINE_CR = 0x00100000; +static immutable int PCRE_NEWLINE_LF = 0x00200000; +static immutable int PCRE_NEWLINE_CRLF = 0x00300000; +static immutable int PCRE_NEWLINE_ANY = 0x00400000; +static immutable int PCRE_NEWLINE_ANYCRLF = 0x00500000; +static immutable int PCRE_BSR_ANYCRLF = 0x00800000; +static immutable int PCRE_BSR_UNICODE = 0x01000000; +static immutable int PCRE_JAVASCRIPT_COMPAT = 0x02000000; + + +static immutable int PCRE_ERROR_NOMATCH = (-1); +static immutable int PCRE_ERROR_NULL = (-2); +static immutable int PCRE_ERROR_BADOPTION = (-3); +static immutable int PCRE_ERROR_BADMAGIC = (-4); +static immutable int PCRE_ERROR_UNKNOWN_OPCODE = (-5); +static immutable int PCRE_ERROR_UNKNOWN_NODE = (-5); +static immutable int PCRE_ERROR_NOMEMORY = (-6); +static immutable int PCRE_ERROR_NOSUBSTRING = (-7); +static immutable int PCRE_ERROR_MATCHLIMIT = (-8); +static immutable int PCRE_ERROR_CALLOUT = (-9); +static immutable int PCRE_ERROR_BADUTF8 = (-10); +static immutable int PCRE_ERROR_BADUTF8_OFFSET = (-11); +static immutable int PCRE_ERROR_PARTIAL = (-12); +static immutable int PCRE_ERROR_BADPARTIAL = (-13); +static immutable int PCRE_ERROR_INTERNAL = (-14); +static immutable int PCRE_ERROR_BADCOUNT = (-15); +static immutable int PCRE_ERROR_DFA_UITEM = (-16); +static immutable int PCRE_ERROR_DFA_UCOND = (-17); +static immutable int PCRE_ERROR_DFA_UMLIMIT = (-18); +static immutable int PCRE_ERROR_DFA_WSSIZE = (-19); +static immutable int PCRE_ERROR_DFA_RECURSE = (-20); +static immutable int PCRE_ERROR_RECURSIONLIMIT = (-21); +static immutable int PCRE_ERROR_NULLWSLIMIT = (-22); +static immutable int PCRE_ERROR_BADNEWLINE = (-23); + + +static immutable int PCRE_INFO_OPTIONS = 0; +static immutable int PCRE_INFO_SIZE = 1; +static immutable int PCRE_INFO_CAPTURECOUNT = 2; +static immutable int PCRE_INFO_BACKREFMAX = 3; +static immutable int PCRE_INFO_FIRSTBYTE = 4; +static immutable int PCRE_INFO_FIRSTCHAR = 4; +static immutable int PCRE_INFO_FIRSTTABLE = 5; +static immutable int PCRE_INFO_LASTLITERAL = 6; +static immutable int PCRE_INFO_NAMEENTRYSIZE = 7; +static immutable int PCRE_INFO_NAMECOUNT = 8; +static immutable int PCRE_INFO_NAMETABLE = 9; +static immutable int PCRE_INFO_STUDYSIZE = 10; +static immutable int PCRE_INFO_DEFAULT_TABLES = 11; +static immutable int PCRE_INFO_OKPARTIAL = 12; +static immutable int PCRE_INFO_JCHANGED = 13; +static immutable int PCRE_INFO_HASCRORLF = 14; + + +static immutable int PCRE_CONFIG_UTF8 = 0; +static immutable int PCRE_CONFIG_NEWLINE = 1; +static immutable int PCRE_CONFIG_LINK_SIZE = 2; +static immutable int PCRE_CONFIG_POSIX_MALLOC_THRESHOLD = 3; +static immutable int PCRE_CONFIG_MATCH_LIMIT = 4; +static immutable int PCRE_CONFIG_STACKRECURSE = 5; +static immutable int PCRE_CONFIG_UNICODE_PROPERTIES = 6; +static immutable int PCRE_CONFIG_MATCH_LIMIT_RECURSION = 7; +static immutable int PCRE_CONFIG_BSR = 8; + + +static immutable int PCRE_EXTRA_STUDY_DATA = 0x0001; +static immutable int PCRE_EXTRA_MATCH_LIMIT = 0x0002; +static immutable int PCRE_EXTRA_CALLOUT_DATA = 0x0004; +static immutable int PCRE_EXTRA_TABLES = 0x0008; +static immutable int PCRE_EXTRA_MATCH_LIMIT_RECURSION = 0x0010; pcre* pcre_compile(char* pattern, int options, char** errptr, int* erroffset, ubyte* tableptr); diff --git a/src/ocean/text/utf/GlibUnicode.d b/src/ocean/text/utf/GlibUnicode.d index 3630849fb..71f4280ae 100644 --- a/src/ocean/text/utf/GlibUnicode.d +++ b/src/ocean/text/utf/GlibUnicode.d @@ -187,7 +187,7 @@ struct GlibUnicode **************************************************************************/ - static void convert ( dchar[] input, ref char[] output, Converter convert_fn ) + static void convert ( dchar[] input, ref char[] output, scope Converter convert_fn ) { char[6] tmp; @@ -212,7 +212,7 @@ struct GlibUnicode **************************************************************************/ - static void convert ( dchar[] input, ref dchar[] output, Converter convert_fn ) + static void convert ( dchar[] input, ref dchar[] output, scope Converter convert_fn ) { output.length = input.length; @@ -232,7 +232,7 @@ struct GlibUnicode **************************************************************************/ - static void convert ( ref dchar[] content, Converter convert_fn ) + static void convert ( ref dchar[] content, scope Converter convert_fn ) { foreach ( ref c; content ) { @@ -276,7 +276,7 @@ struct GlibUnicode static char[] toUtf8 ( Char ) ( Char c ) { static if (Char.sizeof == wchar.sizeof) - pragma (msg, typeof (*this).stringof + pragma (msg, typeof (*(&this)).stringof ~ ".toUtf8: Only Basic Multilingual Plane supported with " ~ "type '" ~ Char.stringof ~ "'; use 'dchar' " ~ "for full Unicode support"); @@ -305,7 +305,7 @@ struct GlibUnicode static Char toUtf32 ( Char ) ( char[] c ) { static if (Char.sizeof == wchar.sizeof) - pragma (msg, typeof (*this).stringof + pragma (msg, typeof (*(&this)).stringof ~ ".toUtf8: Only Basic Multilingual Plane supported with " ~ "type '" ~ Char.stringof ~ "'; use 'dchar' " ~ "for full Unicode support"); diff --git a/src/ocean/text/utf/UtfString.d b/src/ocean/text/utf/UtfString.d index 43598f582..e24da3890 100644 --- a/src/ocean/text/utf/UtfString.d +++ b/src/ocean/text/utf/UtfString.d @@ -76,7 +76,7 @@ version(UnitTest) import ocean.core.Test; *******************************************************************************/ -public const dchar InvalidUnicode = cast(dchar)0xffffffff; +public static immutable dchar InvalidUnicode = cast(dchar)0xffffffff; @@ -160,7 +160,7 @@ public struct UtfString ( Char = char, bool pull_dchars = false ) ***************************************************************************/ - public alias typeof(this) This; + public alias typeof((&this)) This; /*************************************************************************** @@ -210,14 +210,14 @@ public struct UtfString ( Char = char, bool pull_dchars = false ) ***************************************************************************/ - public int opApply ( int delegate ( ref size_t, ref size_t, ref OutType ) dg ) + public int opApply ( scope int delegate ( ref size_t, ref size_t, ref OutType ) dg ) { int res; size_t i; - while ( i < this.string.length ) + while ( i < (&this).string.length ) { - Char[] process = this.string[i..$]; + Char[] process = (&this).string[i..$]; size_t width; auto c = This.extract(process, width); @@ -245,14 +245,14 @@ public struct UtfString ( Char = char, bool pull_dchars = false ) ***************************************************************************/ - public int opApply ( int delegate ( ref size_t, ref OutType ) dg ) + public int opApply ( scope int delegate ( ref size_t, ref OutType ) dg ) { int res; size_t i; - while ( i < this.string.length ) + while ( i < (&this).string.length ) { - Char[] process = this.string[i..$]; + Char[] process = (&this).string[i..$]; size_t width; auto c = This.extract(process, width); @@ -279,14 +279,14 @@ public struct UtfString ( Char = char, bool pull_dchars = false ) ***************************************************************************/ - public int opApply ( int delegate ( ref OutType ) dg ) + public int opApply ( scope int delegate ( ref OutType ) dg ) { int res; size_t i; - while ( i < this.string.length ) + while ( i < (&this).string.length ) { - Char[] process = this.string[i..$]; + Char[] process = (&this).string[i..$]; size_t width; auto c = This.extract(process, width); @@ -319,7 +319,7 @@ public struct UtfString ( Char = char, bool pull_dchars = false ) public OutType opIndex ( size_t index ) { - verify(this.string.length > 0, + verify((&this).string.length > 0, This.stringof ~ ".opIndex - attempted to index into an empty string"); size_t i; @@ -328,7 +328,7 @@ public struct UtfString ( Char = char, bool pull_dchars = false ) do { size_t width; - c = This.extract(this.string[i..$], width); + c = This.extract((&this).string[i..$], width); i += width; } while ( count++ < index ); @@ -357,11 +357,11 @@ public struct UtfString ( Char = char, bool pull_dchars = false ) public ArrayOutType opSlice ( size_t start, size_t end ) { - verify(end > start, typeof(this).stringof ~ ".opSlice - end <= start!"); + verify(end > start, typeof((&this)).stringof ~ ".opSlice - end <= start!"); static if ( pull_dchars ) { - return this.sliceCopy(start, end, this.slice_string); + return (&this).sliceCopy(start, end, (&this).slice_string); } else { @@ -369,7 +369,7 @@ public struct UtfString ( Char = char, bool pull_dchars = false ) size_t char_count; size_t src_i; - while ( src_i < this.string.length ) + while ( src_i < (&this).string.length ) { if ( char_count == start ) { @@ -377,10 +377,10 @@ public struct UtfString ( Char = char, bool pull_dchars = false ) } if ( char_count >= end ) { - return this.string[start_i .. src_i]; + return (&this).string[start_i .. src_i]; } - Char[] process = this.string[src_i..$]; + Char[] process = (&this).string[src_i..$]; size_t width; This.extract(process, width); @@ -389,7 +389,7 @@ public struct UtfString ( Char = char, bool pull_dchars = false ) char_count++; } - assert(false, typeof(this).stringof ~ ".opSlice - end > array length"); + assert(false, typeof((&this)).stringof ~ ".opSlice - end > array length"); } } @@ -417,7 +417,7 @@ public struct UtfString ( Char = char, bool pull_dchars = false ) output.length = 0; size_t i; - foreach ( c; *this ) + foreach ( c; *(&this) ) { if ( i >= start ) { @@ -448,7 +448,7 @@ public struct UtfString ( Char = char, bool pull_dchars = false ) { size_t len; - foreach ( c; *this ) + foreach ( c; *(&this) ) { len++; } @@ -474,7 +474,7 @@ public struct UtfString ( Char = char, bool pull_dchars = false ) public OutType extract ( bool consume = false ) { size_t width; - return this.extract(width, consume); + return (&this).extract(width, consume); } @@ -496,10 +496,10 @@ public struct UtfString ( Char = char, bool pull_dchars = false ) public OutType extract ( out size_t width, bool consume = false ) { - auto extracted = This.extract(this.string, width); + auto extracted = This.extract((&this).string, width); if ( consume ) { - this.string = this.string[width..$]; + (&this).string = (&this).string[width..$]; } return extracted; diff --git a/src/ocean/text/utf/UtfUtil.d b/src/ocean/text/utf/UtfUtil.d index 4c849270d..f59b83de2 100644 --- a/src/ocean/text/utf/UtfUtil.d +++ b/src/ocean/text/utf/UtfUtil.d @@ -70,7 +70,7 @@ public istring ellipsis = "\xE2\x80\xA6"; // The char '…' *******************************************************************************/ -private const ubyte[char.max + 1] utf8_stride = +private static immutable ubyte[char.max + 1] utf8_stride = [ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, @@ -136,7 +136,7 @@ public size_t utf8Length ( cstring str ) *******************************************************************************/ -public size_t utf8Length ( cstring str, void delegate ( size_t ) error_dg ) +public size_t utf8Length ( cstring str, scope void delegate ( size_t ) error_dg ) { size_t length; size_t i; @@ -183,14 +183,14 @@ unittest // test if error delegate is called for an invalid string bool error_caught = false; - const istring error_str = "error in " ~ char.init ~ " the middle"; + static immutable istring error_str = "error in " ~ char.init ~ " the middle"; utf8Length(error_str, ( size_t i ) { error_caught = true; }); test(error_caught, "the call to utf8Length should have caught an error"); // test if error delegate is called for a valid string error_caught = false; - const istring valid_str = "There are no errors in this string!"; + static immutable istring valid_str = "There are no errors in this string!"; utf8Length(valid_str, ( size_t i ) { error_caught = true; }); test(!error_caught, "the call to utf8Length should not have caught an error"); diff --git a/src/ocean/text/util/EscapeChars.d b/src/ocean/text/util/EscapeChars.d index 4100aa184..632cb26cc 100644 --- a/src/ocean/text/util/EscapeChars.d +++ b/src/ocean/text/util/EscapeChars.d @@ -34,7 +34,7 @@ struct EscapeChars **************************************************************************/ - const Tokens = `"'\`; + enum Tokens = `"'\`; /************************************************************************** @@ -73,7 +73,7 @@ struct EscapeChars { if (tokens.length) { - this.copyTokens(tokens); + (&this).copyTokens(tokens); str ~= '\0'; // append a 0 to the end, as it is stripped in the scope(exit) @@ -87,21 +87,21 @@ struct EscapeChars size_t end = str.length - 1; - this.occurrences.length = 0; - enableStomping(this.occurrences); + (&this).occurrences.length = 0; + enableStomping((&this).occurrences); for (size_t pos = strcspn(str.ptr, tokens.ptr); pos < end;) { - this.occurrences ~= pos; + (&this).occurrences ~= pos; pos += strcspn(str.ptr + ++pos, tokens.ptr); } - str.length = str.length + (this.occurrences.length * escape.length); + str.length = str.length + ((&this).occurrences.length * escape.length); str[$ - 1] = '\0'; // append a 0 to the end, as it is stripped in the scope(exit) - foreach_reverse (i, occurrence; this.occurrences) + foreach_reverse (i, occurrence; (&this).occurrences) { char* src = str.ptr + occurrence; char* dst = src + ((i + 1) * escape.length); @@ -128,16 +128,16 @@ struct EscapeChars private void copyTokens ( cstring tokens ) out { - assert (this.tokens.length); - assert (!this.tokens[$ - 1]); - assert (this.tokens.length - 1 == strlen(this.tokens.ptr)); + assert ((&this).tokens.length); + assert (!(&this).tokens[$ - 1]); + assert ((&this).tokens.length - 1 == strlen((&this).tokens.ptr)); } body { verify (tokens.ptr !is null); verify (!memchr(tokens.ptr, '\0', tokens.length), - typeof (*this).stringof ~ ": NUL characters not allowed in tokens"); - this.tokens.concat(tokens, "\0"[]); + typeof (*(&this)).stringof ~ ": NUL characters not allowed in tokens"); + (&this).tokens.concat(tokens, "\0"[]); } } diff --git a/src/ocean/text/util/MetricPrefix.d b/src/ocean/text/util/MetricPrefix.d index f83fa958a..cced0fa86 100644 --- a/src/ocean/text/util/MetricPrefix.d +++ b/src/ocean/text/util/MetricPrefix.d @@ -68,7 +68,7 @@ public struct MetricPrefix dchar prefix = ' '; - public const BinaryPrefixes = [' ', 'K', 'M', 'G', 'T', 'P', 'E']; + public enum BinaryPrefixes = [' ', 'K', 'M', 'G', 'T', 'P', 'E']; /************************************************************************** @@ -85,9 +85,9 @@ public struct MetricPrefix **************************************************************************/ - typeof (this) bin ( T : float ) ( T n ) + typeof ((&this)) bin ( T : float ) ( T n ) { - this.scaled = n; + (&this).scaled = n; int i; @@ -104,14 +104,14 @@ public struct MetricPrefix i /= 10; } - this.scaled = ldexpf(this.scaled, i * -10); + (&this).scaled = ldexpf((&this).scaled, i * -10); - this.prefix = BinaryPrefixes[i]; + (&this).prefix = BinaryPrefixes[i]; - return this; + return (&this); } - public const DecimalPrefixes = [cast(wchar)'p', 'n', 'µ', 'm', ' ', 'k', 'M', 'G', 'T']; + public enum DecimalPrefixes = [cast(wchar)'p', 'n', 'µ', 'm', ' ', 'k', 'M', 'G', 'T']; /************************************************************************** @@ -129,11 +129,11 @@ public struct MetricPrefix **************************************************************************/ - typeof (this) dec ( T : float ) ( T n, int e = 0 ) + typeof ((&this)) dec ( T : float ) ( T n, int e = 0 ) { verify (-5 < e && e < 5); - this.scaled = n; + (&this).scaled = n; int i = 4; @@ -144,7 +144,7 @@ public struct MetricPrefix for (i += e; (n > 1000) && (i+1 < DecimalPrefixes.length); i++) { n /= 1000; - this.scaled /= 1000; + (&this).scaled /= 1000; } } else @@ -152,14 +152,14 @@ public struct MetricPrefix for (i += e; (n < 1) && (i-1 > 0); i--) { n *= 1000; - this.scaled *= 1000; + (&this).scaled *= 1000; } } } - this.prefix = DecimalPrefixes[i]; + (&this).prefix = DecimalPrefixes[i]; - return this; + return (&this); } } @@ -202,7 +202,7 @@ public struct MetricPrefix *******************************************************************************/ -public void splitBinaryPrefix ( ulong n, void delegate ( char prefix, uint order, ulong order_val ) output_dg ) +public void splitBinaryPrefix ( ulong n, scope void delegate ( char prefix, uint order, ulong order_val ) output_dg ) { auto length = MetricPrefix.BinaryPrefixes.length; verify (length < int.max); diff --git a/src/ocean/text/util/SplitIterator.d b/src/ocean/text/util/SplitIterator.d index 7aa3159be..cbad5bf50 100644 --- a/src/ocean/text/util/SplitIterator.d +++ b/src/ocean/text/util/SplitIterator.d @@ -468,7 +468,7 @@ abstract class ISplitIterator **************************************************************************/ - public int opApply ( int delegate ( ref cstring segment ) dg_in ) + public int opApply ( scope int delegate ( ref cstring segment ) dg_in ) { IterationDelegate dg; @@ -495,7 +495,7 @@ abstract class ISplitIterator **************************************************************************/ - public int opApply ( int delegate ( ref size_t pos, ref cstring segment ) dg_in ) + public int opApply ( scope int delegate ( ref size_t pos, ref cstring segment ) dg_in ) { IterationDelegate dg; diff --git a/src/ocean/text/util/StringC.d b/src/ocean/text/util/StringC.d index ad386152a..bf4386524 100644 --- a/src/ocean/text/util/StringC.d +++ b/src/ocean/text/util/StringC.d @@ -61,8 +61,8 @@ class StringC **************************************************************************/ - public const char Term = '\0'; - public const Wchar Wterm = '\0'; + public static immutable char Term = '\0'; + public static immutable Wchar Wterm = '\0'; /*************************************************************************** diff --git a/src/ocean/text/util/StringEncode.d b/src/ocean/text/util/StringEncode.d index fbec6bc0c..db97602e7 100644 --- a/src/ocean/text/util/StringEncode.d +++ b/src/ocean/text/util/StringEncode.d @@ -74,7 +74,7 @@ import core.stdc.errno; class IconvException : Exception { - const MSG = "Iconv: Error"; + static immutable MSG = "Iconv: Error"; this ( istring msg = MSG, istring file = __FILE__, int line = __LINE__ ) { @@ -93,7 +93,7 @@ class IconvException : Exception class InvalidMbSeq : IconvException { - const msg = "Iconv: Invalid Multibyte Sequence"; + static immutable msg = "Iconv: Invalid Multibyte Sequence"; this ( istring file = __FILE__, int line = __LINE__ ) { @@ -109,7 +109,7 @@ class InvalidMbSeq : IconvException class IncompleteMbSeq : IconvException { - const msg = "Iconv: Incomplete Multibyte Sequence"; + static immutable msg = "Iconv: Incomplete Multibyte Sequence"; this ( istring file = __FILE__, int line = __LINE__ ) { diff --git a/src/ocean/text/util/StringSearch.d b/src/ocean/text/util/StringSearch.d index ce647bd48..45ca0a61b 100644 --- a/src/ocean/text/util/StringSearch.d +++ b/src/ocean/text/util/StringSearch.d @@ -238,7 +238,7 @@ struct StringSearch ( bool wide_char = false ) static: - const Char TERM = '\0'; + enum Char TERM = '\0'; /** * Locates the first occurence of value within the first length characters @@ -527,7 +527,7 @@ struct StringSearch ( bool wide_char = false ) Char[] shiftString ( ref Char[] str, size_t dst_pos, size_t src_pos, size_t length ) { - const PREFIX = "shiftString(): "; + enum PREFIX = "shiftString(): "; verify (src_pos <= str.length, PREFIX ~ "source start out of range"); verify (dst_pos <= str.length, PREFIX ~ "destination start out of range"); diff --git a/src/ocean/text/util/Time.d b/src/ocean/text/util/Time.d index 97050ceb6..8e2e2ce26 100644 --- a/src/ocean/text/util/Time.d +++ b/src/ocean/text/util/Time.d @@ -289,10 +289,10 @@ public void extractTimePeriods ( ulong s, out uint years, out uint days, return cast(uint) extracted; } - const minute_timespan = 60; - const hour_timespan = minute_timespan * 60; - const day_timespan = hour_timespan * 24; - const year_timespan = day_timespan * 365; + static immutable minute_timespan = 60; + static immutable hour_timespan = minute_timespan * 60; + static immutable day_timespan = hour_timespan * 24; + static immutable year_timespan = day_timespan * 365; enforce(s <= uint.max); seconds = cast(uint) s; diff --git a/src/ocean/text/xml/DocEntity.d b/src/ocean/text/xml/DocEntity.d index 7f7e703f3..40391dad1 100644 --- a/src/ocean/text/xml/DocEntity.d +++ b/src/ocean/text/xml/DocEntity.d @@ -112,7 +112,7 @@ T[] fromEntity (T) (T[] src, T[] dst = null) ******************************************************************************/ -void fromEntity (T) (T[] src, void delegate(T[]) emit) +void fromEntity (T) (T[] src, scope void delegate(T[]) emit) { int delta; auto s = src.ptr; @@ -260,7 +260,7 @@ T[] toEntity(T) (T[] src, T[] dst = null) ******************************************************************************/ -void toEntity(T) (T[] src, void delegate(T[]) emit) +void toEntity(T) (T[] src, scope void delegate(T[]) emit) { T[] entity; auto s = src.ptr; diff --git a/src/ocean/text/xml/DocPrinter.d b/src/ocean/text/xml/DocPrinter.d index b31c05b7a..37d302cb6 100644 --- a/src/ocean/text/xml/DocPrinter.d +++ b/src/ocean/text/xml/DocPrinter.d @@ -47,7 +47,7 @@ class DocPrinter(T) private bool quick = true; private uint indentation = 2; - private const Eol = "\n"; + private static immutable Eol = "\n"; /*********************************************************************** @@ -120,7 +120,7 @@ class DocPrinter(T) ***********************************************************************/ - final void print (Node root, void delegate(Const!(T)[][]...) emit) + final void print (Node root, scope void delegate(Const!(T)[][]...) emit) { T[256] tmp; T[256] spaces = ' '; diff --git a/src/ocean/text/xml/Document.d b/src/ocean/text/xml/Document.d index b09be4736..bc7cfab2d 100644 --- a/src/ocean/text/xml/Document.d +++ b/src/ocean/text/xml/Document.d @@ -255,7 +255,7 @@ class Document(T_) : PullParser!(T_) final Document header () { - const header = `xml version="1.0" encoding="UTF-8"`; + static immutable header = `xml version="1.0" encoding="UTF-8"`; root.prepend (root.create(XmlNodeType.PI, header)); return this; } @@ -458,7 +458,7 @@ class Document(T_) : PullParser!(T_) ***************************************************************/ - int opApply (int delegate(ref Node) dg) + int opApply (scope int delegate(ref Node) dg) { int ret; @@ -478,7 +478,7 @@ class Document(T_) : PullParser!(T_) ***************************************************************/ - Node name (T[] prefix, T[] local, bool delegate(Node) dg=null) + Node name (T[] prefix, T[] local, scope bool delegate(Node) dg=null) { for (auto n=node; n; n = n.nextSibling) { @@ -675,8 +675,8 @@ version (Filter) Node prefix (T[] replace) { - Array.copy(this.prefixed, replace); - return this; + Array.copy((&this).prefixed, replace); + return (&this); } /*************************************************************** @@ -698,8 +698,8 @@ version (Filter) Node name (T[] replace) { - Array.copy(this.localName, replace); - return this; + Array.copy((&this).localName, replace); + return (&this); } /*************************************************************** @@ -730,7 +730,7 @@ version (Filter) foreach (child; children) if (child.id is XmlNodeType.Data) return child.value (val); - Array.copy(this.rawValue, val); + Array.copy((&this).rawValue, val); mutate; } @@ -804,7 +804,7 @@ version (Filter) final XmlPathT.NodeSet query () { - return doc.xpath.start (this); + return doc.xpath.start ((&this)); } /*************************************************************** @@ -981,7 +981,7 @@ version (Filter) { auto node = create (XmlNodeType.Attribute, value); attrib (node.set (prefix, local)); - return this; + return (&this); } /*************************************************************** @@ -993,7 +993,7 @@ version (Filter) private Node data_ (T[] data) { append (create (XmlNodeType.Data, data)); - return this; + return (&this); } /*************************************************************** @@ -1005,7 +1005,7 @@ version (Filter) private Node cdata_ (T[] cdata) { append (create (XmlNodeType.CData, cdata)); - return this; + return (&this); } /*************************************************************** @@ -1017,7 +1017,7 @@ version (Filter) private Node comment_ (T[] comment) { append (create (XmlNodeType.Comment, comment)); - return this; + return (&this); } /*************************************************************** @@ -1029,7 +1029,7 @@ version (Filter) private Node pi_ (T[] pi, T[] patch) { append (create(XmlNodeType.PI, pi).patch(patch)); - return this; + return (&this); } /*************************************************************** @@ -1041,7 +1041,7 @@ version (Filter) private Node doctype_ (T[] doctype) { append (create (XmlNodeType.Doctype, doctype)); - return this; + return (&this); } /*************************************************************** @@ -1054,7 +1054,7 @@ version (Filter) private void attrib (Node node) { verify (node.parent is null); - node.host = this; + node.host = (&this); if (lastAttr) { lastAttr.nextSibling = node; @@ -1075,7 +1075,7 @@ version (Filter) private void append (Node node) { verify (node.parent is null); - node.host = this; + node.host = (&this); if (lastChild) { lastChild.nextSibling = node; @@ -1096,7 +1096,7 @@ version (Filter) private void prepend (Node node) { verify (node.parent is null); - node.host = this; + node.host = (&this); if (firstChild) { firstChild.prevSibling = node; @@ -1115,9 +1115,9 @@ version (Filter) private Node set (T[] prefix, T[] local) { - Array.copy(this.localName, local); - Array.copy(this.prefixed, prefix); - return this; + Array.copy((&this).localName, local); + Array.copy((&this).prefixed, prefix); + return (&this); } /*************************************************************** @@ -1143,7 +1143,7 @@ version (Filter) private Node remove() { if (! host) - return this; + return (&this); mutate; if (prevSibling && nextSibling) @@ -1157,7 +1157,7 @@ version (Filter) else if (nextSibling) { - verify(host.firstChild == this); + verify(host.firstChild == (&this)); parent.firstChild = nextSibling; nextSibling.prevSibling = null; nextSibling = null; @@ -1168,7 +1168,7 @@ version (Filter) { if (prevSibling) { - verify(host.lastChild == this); + verify(host.lastChild == (&this)); host.lastChild = prevSibling; prevSibling.nextSibling = null; prevSibling = null; @@ -1176,8 +1176,8 @@ version (Filter) } else { - verify(host.firstChild == this); - verify(host.lastChild == this); + verify(host.firstChild == (&this)); + verify(host.lastChild == (&this)); host.firstChild = null; host.lastChild = null; host = null; @@ -1187,7 +1187,7 @@ version (Filter) { if (prevSibling) { - verify(host.lastAttr == this); + verify(host.lastAttr == (&this)); host.lastAttr = prevSibling; prevSibling.nextSibling = null; prevSibling = null; @@ -1195,15 +1195,15 @@ version (Filter) } else { - verify(host.firstAttr == this); - verify(host.lastAttr == this); + verify(host.firstAttr == (&this)); + verify(host.lastAttr == (&this)); host.firstAttr = null; host.lastAttr = null; host = null; } } - return this; + return (&this); } /*************************************************************** @@ -1221,7 +1221,7 @@ version (Filter) { end = text.ptr + text.length; start = text.ptr; - return this; + return (&this); } /*************************************************************** @@ -1233,12 +1233,12 @@ version (Filter) private Node mutate () { - auto node = this; + auto node = (&this); do { node.end = null; } while ((node = node.host) !is null); - return this; + return (&this); } /*************************************************************** @@ -1277,7 +1277,7 @@ version (Filter) private void migrate (Document host) { - this.doc = host; + (&this).doc = host; foreach (attr; attributes) attr.migrate (host); foreach (child; children) @@ -1718,7 +1718,7 @@ public class XmlPath(T) ***************************************************************/ - NodeSet filter (bool delegate(Node) filter) + NodeSet filter (scope bool delegate(Node) filter) { NodeSet set = {host}; auto mark = host.mark; @@ -1736,7 +1736,7 @@ public class XmlPath(T) ***************************************************************/ - NodeSet child (bool delegate(Node) filter, + NodeSet child (scope bool delegate(Node) filter, XmlNodeType type = XmlNodeType.Element) { NodeSet set = {host}; @@ -1757,7 +1757,7 @@ public class XmlPath(T) ***************************************************************/ - NodeSet attribute (bool delegate(Node) filter) + NodeSet attribute (scope bool delegate(Node) filter) { NodeSet set = {host}; auto mark = host.mark; @@ -1776,7 +1776,7 @@ public class XmlPath(T) ***************************************************************/ - NodeSet descendant (bool delegate(Node) filter, + NodeSet descendant (scope bool delegate(Node) filter, XmlNodeType type = XmlNodeType.Element) { void traverse (Node parent) @@ -1806,7 +1806,7 @@ public class XmlPath(T) ***************************************************************/ - NodeSet parent (bool delegate(Node) filter) + NodeSet parent (scope bool delegate(Node) filter) { NodeSet set = {host}; auto mark = host.mark; @@ -1836,7 +1836,7 @@ public class XmlPath(T) ***************************************************************/ - NodeSet ancestor (bool delegate(Node) filter) + NodeSet ancestor (scope bool delegate(Node) filter) { NodeSet set = {host}; auto mark = host.mark; @@ -1870,7 +1870,7 @@ public class XmlPath(T) ***************************************************************/ - NodeSet next (bool delegate(Node) filter, + NodeSet next (scope bool delegate(Node) filter, XmlNodeType type = XmlNodeType.Element) { NodeSet set = {host}; @@ -1897,7 +1897,7 @@ public class XmlPath(T) ***************************************************************/ - NodeSet prev (bool delegate(Node) filter, + NodeSet prev (scope bool delegate(Node) filter, XmlNodeType type = XmlNodeType.Element) { NodeSet set = {host}; @@ -1922,7 +1922,7 @@ public class XmlPath(T) ***************************************************************/ - int opApply (int delegate(ref Node) dg) + int opApply (scope int delegate(ref Node) dg) { int ret; @@ -1952,7 +1952,7 @@ public class XmlPath(T) private NodeSet assign (uint mark) { nodes = host.slice (mark); - return *this; + return *(&this); } /*************************************************************** @@ -1963,7 +1963,7 @@ public class XmlPath(T) ***************************************************************/ - private void test (bool delegate(Node) filter, Node node) + private void test (scope bool delegate(Node) filter, Node node) { auto pop = host.push; auto add = filter (node); @@ -2176,7 +2176,7 @@ interface IXmlPrinter(T) ***********************************************************************/ - void print (Node root, void delegate(T[][]...) emit); + void print (Node root, scope void delegate(T[][]...) emit); } } diff --git a/src/ocean/text/xml/PullParser.d b/src/ocean/text/xml/PullParser.d index 6b4dacc34..fffbd7b87 100644 --- a/src/ocean/text/xml/PullParser.d +++ b/src/ocean/text/xml/PullParser.d @@ -679,10 +679,10 @@ package struct XmlText(Ch) final void reset(Ch[] newText) { - this.text = newText; - this.len = newText.length; - this.point = text.ptr; - this.end = point + len; + (&this).text = newText; + (&this).len = newText.length; + (&this).point = text.ptr; + (&this).end = point + len; } static Const!(ubyte[64]) name = @@ -768,7 +768,7 @@ version (UnitTest) ***********************************************************************/ - const istring testXML = "]>]>test&Zdata"; } diff --git a/src/ocean/text/xml/SaxParser.d b/src/ocean/text/xml/SaxParser.d index 0ef573a9b..ad2b84afb 100644 --- a/src/ocean/text/xml/SaxParser.d +++ b/src/ocean/text/xml/SaxParser.d @@ -864,7 +864,7 @@ public class SAXException : Exception { // if current runtime defines `message` method in base Exception/Throwable // class, this method must override it to compile. In D2 mode the method // also needs to be marked as const to match base. - public override cstring message() /* d1to2fix_inject: const */ { + public override cstring message() const { if (msg is null && next !is null) { return next.msg; } diff --git a/src/ocean/time/ISO8601.d b/src/ocean/time/ISO8601.d index f71d1fb12..fad410c2e 100644 --- a/src/ocean/time/ISO8601.d +++ b/src/ocean/time/ISO8601.d @@ -111,9 +111,9 @@ public struct ExtendedDate { debug (Tango_ISO8601) private char[] toStr() { return Stdout.layout.convert( "{:d} and {:d}-{:d2}-{:d2} :: {:d2}:{:d2}:{:d2}.{:d3} and {:d2}, {}", - year_, years(*this), months(*this), days(*this), - hours(*this), mins(*this), .secs(*this), ms(*this), - this.seconds, this.endOfDay); + year_, years(*(&this)), months(*(&this)), days(*(&this)), + hours(*(&this)), mins(*(&this)), .secs(*(&this)), ms(*(&this)), + (&this).seconds, (&this).endOfDay); } } @@ -758,7 +758,7 @@ byte getDecimal(T)(ref T* p, size_t len, ref FullDate fd, ubyte which) { // the DT is always UTC, so this just adds the offset to the date fields // another option would be to add time zone fields to DT and have this fill them -byte getTimeZone(T, T2)(ref T* p, size_t len, ref FullDate fd, ubyte separators, bool delegate(T2[]) done) { +byte getTimeZone(T, T2)(ref T* p, size_t len, ref FullDate fd, ubyte separators, scope bool delegate(T2[]) done) { static assert (is(Unqual!(T) == Unqual!(T2))); bool checkColon() { return .checkColon(p, separators); } @@ -1521,7 +1521,7 @@ unittest { // unimplemented: intervals, durations, recurring intervals debug (Tango_ISO8601_Valgrind) { - size_t valgrind(size_t delegate(char[]) f, char[] s) { + size_t valgrind(scope size_t delegate(char[]) f, char[] s) { auto p = cast(char*)malloc(s.length); auto ps = p[0..s.length]; ps[] = s[]; diff --git a/src/ocean/time/StopWatch.d b/src/ocean/time/StopWatch.d index b7cb9c11f..f1b556232 100644 --- a/src/ocean/time/StopWatch.d +++ b/src/ocean/time/StopWatch.d @@ -81,7 +81,7 @@ public struct StopWatch private ulong started; - private const double multiplier = 1.0 / 1_000_000.0; + private enum double multiplier = 1.0 / 1_000_000.0; /*********************************************************************** @@ -102,7 +102,7 @@ public struct StopWatch double sec () { - return multiplier * this.microsec; + return multiplier * (&this).microsec; } /*********************************************************************** diff --git a/src/ocean/time/Time.d b/src/ocean/time/Time.d index 3ddefd15c..8ddebe3d7 100644 --- a/src/ocean/time/Time.d +++ b/src/ocean/time/Time.d @@ -99,17 +99,17 @@ struct TimeSpan /** * Minimum TimeSpan */ - const TimeSpan min = {long.min}; + enum TimeSpan min = {long.min}; /** * Maximum TimeSpan */ - const TimeSpan max = {long.max}; + enum TimeSpan max = {long.max}; /** * Zero TimeSpan. Useful for comparisons. */ - const TimeSpan zero = {0}; + enum TimeSpan zero = {0}; /** * Get the number of ticks that this timespan represents. This can be @@ -169,7 +169,7 @@ struct TimeSpan TimeSpan opAddAssign(TimeSpan t) { ticks_ += t.ticks_; - return *this; + return *(&this); } /** @@ -194,7 +194,7 @@ struct TimeSpan TimeSpan opSubAssign(TimeSpan t) { ticks_ -= t.ticks_; - return *this; + return *(&this); } /** @@ -221,7 +221,7 @@ struct TimeSpan TimeSpan opMulAssign(long v) { ticks_ *= v; - return *this; + return *(&this); } /** @@ -249,7 +249,7 @@ struct TimeSpan TimeSpan opDivAssign(long v) { ticks_ /= v; - return *this; + return *(&this); } /** @@ -497,17 +497,17 @@ struct Time } /// Represents the smallest and largest Time value. - const Time min = {minimum}, + enum Time min = {minimum}, max = {maximum}; /// Represents the epoch (1/1/0001) - const Time epoch = {0}; + enum Time epoch = {0}; /// Represents the epoch of 1/1/1601 (Commonly used in Windows systems) - const Time epoch1601 = {TimeSpan.Epoch1601}; + enum Time epoch1601 = {TimeSpan.Epoch1601}; /// Represents the epoch of 1/1/1970 (Commonly used in Unix systems) - const Time epoch1970 = {TimeSpan.Epoch1970}; + enum Time epoch1970 = {TimeSpan.Epoch1970}; /********************************************************************** @@ -591,7 +591,7 @@ struct Time Time opAddAssign (TimeSpan t) { ticks_ += t.ticks_; - return *this; + return *(&this); } /********************************************************************** @@ -639,7 +639,7 @@ struct Time Time opSubAssign (TimeSpan t) { ticks_ -= t.ticks_; - return *this; + return *(&this); } /********************************************************************** @@ -653,7 +653,7 @@ struct Time Time date () { - return *this - TimeOfDay.modulo24(ticks_); + return *(&this) - TimeOfDay.modulo24(ticks_); } /********************************************************************** diff --git a/src/ocean/time/chrono/Hebrew.d b/src/ocean/time/chrono/Hebrew.d index 879a86d52..3c179a64f 100644 --- a/src/ocean/time/chrono/Hebrew.d +++ b/src/ocean/time/chrono/Hebrew.d @@ -31,7 +31,7 @@ import ocean.time.chrono.Calendar; */ public class Hebrew : Calendar { - private const uint[14][7] MonthDays = [ + private static immutable uint[14][7] MonthDays = [ // month // year type [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 30, 29, 29, 29, 30, 29, 0, 30, 29, 30, 29, 30, 29 ], // 1 @@ -42,15 +42,15 @@ public class Hebrew : Calendar { [ 0, 30, 30, 30, 29, 30, 30, 29, 30, 29, 30, 29, 30, 29 ] // 6 ]; - private const uint YearOfOneAD = 3760; - private const uint DaysToOneAD = cast(int)(YearOfOneAD * 365.2735); + private static immutable uint YearOfOneAD = 3760; + private static immutable uint DaysToOneAD = cast(int)(YearOfOneAD * 365.2735); - private const uint PartsPerHour = 1080; - private const uint PartsPerDay = 24 * PartsPerHour; - private const uint DaysPerMonth = 29; - private const uint DaysPerMonthFraction = 12 * PartsPerHour + 793; - private const uint PartsPerMonth = DaysPerMonth * PartsPerDay + DaysPerMonthFraction; - private const uint FirstNewMoon = 11 * PartsPerHour + 204; + private static immutable uint PartsPerHour = 1080; + private static immutable uint PartsPerDay = 24 * PartsPerHour; + private static immutable uint DaysPerMonth = 29; + private static immutable uint DaysPerMonthFraction = 12 * PartsPerHour + 793; + private static immutable uint PartsPerMonth = DaysPerMonth * PartsPerDay + DaysPerMonthFraction; + private static immutable uint FirstNewMoon = 11 * PartsPerHour + 204; private uint minYear_ = YearOfOneAD + 1583; private uint maxYear_ = YearOfOneAD + 2240; @@ -58,7 +58,7 @@ public class Hebrew : Calendar { /** * Represents the current era. */ - public const uint HEBREW_ERA = 1; + public static immutable uint HEBREW_ERA = 1; /** * Overridden. Returns a Time value set to the specified date and time in the specified _era. diff --git a/src/ocean/time/chrono/Hijri.d b/src/ocean/time/chrono/Hijri.d index 5e0c263b4..0a9372317 100644 --- a/src/ocean/time/chrono/Hijri.d +++ b/src/ocean/time/chrono/Hijri.d @@ -35,7 +35,7 @@ public class Hijri : Calendar { /** * Represents the current era. */ - public const uint HIJRI_ERA = 1; + public static immutable uint HIJRI_ERA = 1; /** * Overridden. Returns a Time value set to the specified date and time in the specified _era. diff --git a/src/ocean/time/timeout/TimeoutManager.d b/src/ocean/time/timeout/TimeoutManager.d index c490ff588..07bde16e6 100644 --- a/src/ocean/time/timeout/TimeoutManager.d +++ b/src/ocean/time/timeout/TimeoutManager.d @@ -74,7 +74,7 @@ class TimeoutManager : TimeoutManagerBase ***************************************************************************/ - private const default_expected_no_elements = 1024; + private static immutable default_expected_no_elements = 1024; /*************************************************************************** @@ -475,12 +475,12 @@ abstract class TimeoutManagerBase : ITimeoutManager ***************************************************************************/ - public size_t checkTimeouts ( bool delegate ( ITimeoutClient client ) dg = null ) + public size_t checkTimeouts ( scope bool delegate ( ITimeoutClient client ) dg = null ) { return this.checkTimeouts(this.now, dg); } - public size_t checkTimeouts ( ulong now, bool delegate ( ITimeoutClient client ) dg = null ) + public size_t checkTimeouts ( ulong now, scope bool delegate ( ITimeoutClient client ) dg = null ) { debug ( TimeoutManager ) { diff --git a/src/ocean/time/timeout/model/ITimeoutManager.d b/src/ocean/time/timeout/model/ITimeoutManager.d index e72c17cf5..8af87a7b9 100644 --- a/src/ocean/time/timeout/model/ITimeoutManager.d +++ b/src/ocean/time/timeout/model/ITimeoutManager.d @@ -78,7 +78,7 @@ interface ITimeoutManager ***************************************************************************/ - size_t checkTimeouts ( bool delegate ( ITimeoutClient client ) dg ); + size_t checkTimeouts ( scope bool delegate ( ITimeoutClient client ) dg ); /*************************************************************************** diff --git a/src/ocean/transition.d b/src/ocean/transition.d index 60a6d0799..9415a12f9 100644 --- a/src/ocean/transition.d +++ b/src/ocean/transition.d @@ -45,7 +45,7 @@ template isMutable( T ) } else { - const isMutable = true; + static immutable isMutable = true; } } @@ -107,7 +107,7 @@ static import ocean.text.convert.Integer_tango; template Octal(istring literal) { - const Octal = ocean.text.convert.Integer_tango.parse(literal, 8); + static immutable Octal = ocean.text.convert.Integer_tango.parse(literal, 8); } unittest @@ -222,14 +222,14 @@ version (D_Version2) { template min_normal(T : real) { - const min_normal = T.min_normal; + static immutable min_normal = T.min_normal; } } else { template min_normal(T : real) { - const min_normal = T.min; + static immutable min_normal = T.min; } } @@ -300,7 +300,7 @@ unittest equals_t opEquals (S rhs) { - return this.opCmp(rhs) == 0; + return (&this).opCmp(rhs) == 0; } } diff --git a/src/ocean/util/Convert.d b/src/ocean/util/Convert.d index 0e2d89b76..dc4327f17 100644 --- a/src/ocean/util/Convert.d +++ b/src/ocean/util/Convert.d @@ -299,9 +299,9 @@ T[] ctfe_trim(T)(T[] source) template isString(T) { static if (isBasicArrayType!(T)) - const isString = isCharType!(ElementTypeOf!(T)); + static immutable isString = isCharType!(ElementTypeOf!(T)); else - const isString = false; + static immutable isString = false; } unittest @@ -442,29 +442,29 @@ template unsupported_backwards(istring desc="") template TN(T:T[]) { static if( is( T == char ) ) - const TN = "string"; + static immutable TN = "string"; else static if( is( T == wchar ) ) - const TN = "wstring"; + static immutable TN = "wstring"; else static if( is( T == dchar ) ) - const TN = "dstring"; + static immutable TN = "dstring"; else - const TN = TN!(T)~"_array"; + static immutable TN = TN!(T)~"_array"; } // ditto template TN(T:T*) { - const TN = TN!(T)~"_pointer"; + static immutable TN = TN!(T)~"_pointer"; } // ditto template TN(T) { static if( isArrayType!(T) == ArrayKind.Associative ) - const TN = TN!(typeof(T.keys[0]))~"_to_" + static immutable TN = TN!(typeof(T.keys[0]))~"_to_" ~TN!(typeof(T.values[0]))~"_map"; else - const TN = ctfe_trim(T.stringof); + static immutable TN = ctfe_trim(T.stringof); } // Picks an appropriate toString* method from t.text.convert.Utf. @@ -482,13 +482,13 @@ template toString_(T) template UtfNum(T) { - const UtfNum = is(typeof(T[0])==char) ? "8" : ( + static immutable UtfNum = is(typeof(T[0])==char) ? "8" : ( is(typeof(T[0])==wchar) ? "16" : "32"); } template StringNum(T) { - const StringNum = is(Unqual!(typeof(T.init[0]))==char) ? "" : ( + static immutable StringNum = is(Unqual!(typeof(T.init[0]))==char) ? "" : ( is(Unqual!(typeof(T.init[0]))==wchar) ? "16" : "32"); } @@ -934,7 +934,7 @@ D toStringFromString(D,S)(S value) } } -const istring CHARS = +static immutable istring CHARS = "\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f" ~ "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f" ~ "\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f" diff --git a/src/ocean/util/DeepReset.d b/src/ocean/util/DeepReset.d index c2ac18386..ad622524f 100644 --- a/src/ocean/util/DeepReset.d +++ b/src/ocean/util/DeepReset.d @@ -326,13 +326,13 @@ unittest void InitStructure() { - this.h = -52; - this.i.copy("even even more test text"); - this.j.length = 3; - this.j[0].copy("abc"); - this.j[1].copy("def"); - this.j[2].copy("ghi"); - foreach ( ref item; this.k ) + (&this).h = -52; + (&this).i.copy("even even more test text"); + (&this).j.length = 3; + (&this).j[0].copy("abc"); + (&this).j[1].copy("def"); + (&this).j[2].copy("ghi"); + foreach ( ref item; (&this).k ) { item = 120000; } @@ -341,12 +341,12 @@ unittest void InitStructure() { - this.d = 32; - this.e.copy("even more test text"); + (&this).d = 32; + (&this).e.copy("even more test text"); - this.f.length = 1; - this.f[0].copy("abc"); - foreach ( ref item; this.g ) + (&this).f.length = 1; + (&this).f[0].copy("abc"); + foreach ( ref item; (&this).g ) { item = 32400; } diff --git a/src/ocean/util/aio/AsyncIO.d b/src/ocean/util/aio/AsyncIO.d index 3714dd9e7..e08384952 100644 --- a/src/ocean/util/aio/AsyncIO.d +++ b/src/ocean/util/aio/AsyncIO.d @@ -153,7 +153,7 @@ class AsyncIO **************************************************************************/ public this (EpollSelectDispatcher epoll, int number_of_threads, - AsyncIO.Context delegate() makeContext = null, + scope AsyncIO.Context delegate() makeContext = null, long thread_stack_size = 256 * 1024) { @@ -311,7 +311,7 @@ class AsyncIO **************************************************************************/ - public void callDelegate (void delegate(AsyncIO.Context) user_delegate, + public void callDelegate (scope void delegate(AsyncIO.Context) user_delegate, JobNotification notification) { ssize_t ret_val; @@ -444,7 +444,7 @@ class AsyncIO return this.outer.pread(buf, fd, offset, notification); } - public void callDelegate (void delegate(AsyncIO.Context) user_delegate) + public void callDelegate (scope void delegate(AsyncIO.Context) user_delegate) { assert (Task.getThis() !is null); scope JobNotification notification = new TaskJobNotification; diff --git a/src/ocean/util/aio/DelegateJobNotification.d b/src/ocean/util/aio/DelegateJobNotification.d index d177c8f38..a799afb52 100644 --- a/src/ocean/util/aio/DelegateJobNotification.d +++ b/src/ocean/util/aio/DelegateJobNotification.d @@ -60,8 +60,8 @@ class DelegateJobNotification: JobNotification ***************************************************************************/ - public this (void delegate() resume_job, - void delegate() suspend_job = null) + public this (scope void delegate() resume_job, + scope void delegate() suspend_job = null) { this.initialise(resume_job, suspend_job); } @@ -79,8 +79,8 @@ class DelegateJobNotification: JobNotification ***************************************************************************/ - public typeof(this) initialise (void delegate() resume_job, - void delegate() suspend_job = null) + public typeof(this) initialise (scope void delegate() resume_job, + scope void delegate() suspend_job = null) { this.resume_job = resume_job; this.suspend_job = suspend_job; diff --git a/src/ocean/util/aio/internal/JobQueue.d b/src/ocean/util/aio/internal/JobQueue.d index 5f9b01e2f..a4c2f3916 100644 --- a/src/ocean/util/aio/internal/JobQueue.d +++ b/src/ocean/util/aio/internal/JobQueue.d @@ -192,16 +192,16 @@ public static struct Job public void finished () { - if (this.finalize_results) + if ((&this).finalize_results) { - this.finalize_results(this); + (&this).finalize_results((&this)); } - if (this.finish_callback_dgs.length) + if ((&this).finish_callback_dgs.length) { - foreach (dg; this.finish_callback_dgs) + foreach (dg; (&this).finish_callback_dgs) { - dg(this.return_value); + dg((&this).return_value); } } } @@ -215,10 +215,10 @@ public static struct Job ***************************************************************************/ - public Job* registerCallback (void delegate(ssize_t) dg) + public Job* registerCallback (scope void delegate(ssize_t) dg) { - this.finish_callback_dgs ~= dg; - return this; + (&this).finish_callback_dgs ~= dg; + return (&this); } /*************************************************************************** @@ -230,7 +230,7 @@ public static struct Job public void recycle () { - this.owner_queue.recycleJob(this, &lock_mutex, &unlock_mutex); + (&this).owner_queue.recycleJob((&this), &lock_mutex, &unlock_mutex); } } diff --git a/src/ocean/util/app/ext/LogExt.d b/src/ocean/util/app/ext/LogExt.d index 7091cb899..8e018d3b8 100644 --- a/src/ocean/util/app/ext/LogExt.d +++ b/src/ocean/util/app/ext/LogExt.d @@ -104,7 +104,7 @@ class LogExt : IConfigExtExtension ***************************************************************************/ - public this ( Appender.Layout delegate (cstring name) make_layout = null, + public this ( scope Appender.Layout delegate (cstring name) make_layout = null, bool use_insert_appender = false ) { this.layout_maker = make_layout is null ? &this.makeLayoutDefault diff --git a/src/ocean/util/app/ext/ReopenableFilesExt.d b/src/ocean/util/app/ext/ReopenableFilesExt.d index 41fcc19e9..51bd42032 100644 --- a/src/ocean/util/app/ext/ReopenableFilesExt.d +++ b/src/ocean/util/app/ext/ReopenableFilesExt.d @@ -208,7 +208,7 @@ public class ReopenableFilesExt : IApplicationExtension, ISignalExtExtension *****************************************************************************/ private void socketReloadCommand ( cstring[] args, - void delegate ( cstring response ) send_response ) + scope void delegate ( cstring response ) send_response ) { if (args.length == 0) { diff --git a/src/ocean/util/app/ext/TaskExt.d b/src/ocean/util/app/ext/TaskExt.d index 42159a06c..976d063a7 100644 --- a/src/ocean/util/app/ext/TaskExt.d +++ b/src/ocean/util/app/ext/TaskExt.d @@ -97,7 +97,7 @@ class TaskExt : IConfigExtExtension ***************************************************************************/ - public int run ( int delegate () dg ) + public int run ( scope int delegate () dg ) { return runInTask(dg); } diff --git a/src/ocean/util/app/ext/TimerExt.d b/src/ocean/util/app/ext/TimerExt.d index 5f48d8490..d13a0c88a 100644 --- a/src/ocean/util/app/ext/TimerExt.d +++ b/src/ocean/util/app/ext/TimerExt.d @@ -152,7 +152,7 @@ public class TimerExt : IApplicationExtension ***************************************************************************/ - public void register ( EventDg dg, double period_s ) + public void register ( scope EventDg dg, double period_s ) { this.timer_set.register(dg, period_s); } @@ -170,7 +170,7 @@ public class TimerExt : IApplicationExtension ***************************************************************************/ - public void register ( EventDg dg, double init_s, double period_s ) + public void register ( scope EventDg dg, double init_s, double period_s ) { this.timer_set.register(dg, init_s, period_s); } @@ -192,7 +192,7 @@ public class TimerExt : IApplicationExtension ***************************************************************************/ - public void registerMicrosec ( EventDg dg, ulong init_microsec, ulong period_microsec ) + public void registerMicrosec ( scope EventDg dg, ulong init_microsec, ulong period_microsec ) { this.timer_set.registerMicrosec(dg, init_microsec, period_microsec); } diff --git a/src/ocean/util/app/ext/UnixSocketExt.d b/src/ocean/util/app/ext/UnixSocketExt.d index 1a53cb631..4fd86b9ec 100644 --- a/src/ocean/util/app/ext/UnixSocketExt.d +++ b/src/ocean/util/app/ext/UnixSocketExt.d @@ -105,7 +105,7 @@ public class UnixSocketExt : IApplicationExtension, IConfigExtExtension ***************************************************************************/ deprecated ("Use the appropriate overload of UnixSocketExt.addHandler.") - public void addInteractiveHandler ( istring command, InteractiveHandler handler ) + public void addInteractiveHandler ( istring command, scope InteractiveHandler handler ) { this.unix_socket.commands.addHandler(command, handler); } @@ -118,7 +118,7 @@ public class UnixSocketExt : IApplicationExtension, IConfigExtExtension ***************************************************************************/ - public void addHandler ( istring command, Handler handler ) + public void addHandler ( istring command, scope Handler handler ) { this.unix_socket.commands.addHandler(command, handler); } @@ -131,7 +131,7 @@ public class UnixSocketExt : IApplicationExtension, IConfigExtExtension ***************************************************************************/ - public void addHandler ( istring command, InteractiveHandler handler ) + public void addHandler ( istring command, scope InteractiveHandler handler ) { this.unix_socket.commands.addHandler(command, handler); } @@ -146,7 +146,7 @@ public class UnixSocketExt : IApplicationExtension, IConfigExtExtension ***************************************************************************/ - public void addHandler ( istring command, RawSocketHandler handler ) + public void addHandler ( istring command, scope RawSocketHandler handler ) { this.unix_socket.commands.addHandler(command, handler); } @@ -294,8 +294,8 @@ unittest } private void test ( cstring[] args, - void delegate ( cstring response ) send_response, - void delegate ( ref mstring response ) wait_reply ) + scope void delegate ( cstring response ) send_response, + scope void delegate ( ref mstring response ) wait_reply ) { send_response("Test request received"); } diff --git a/src/ocean/util/app/ext/VersionArgsExt.d b/src/ocean/util/app/ext/VersionArgsExt.d index a6ea34f2e..742ebf89d 100644 --- a/src/ocean/util/app/ext/VersionArgsExt.d +++ b/src/ocean/util/app/ext/VersionArgsExt.d @@ -234,7 +234,7 @@ class VersionArgsExt : IApplicationExtension, IArgumentsExtExtension, *****************************************************************************/ private void showVersionHandler ( cstring[] args, - void delegate ( cstring response ) send_response ) + scope void delegate ( cstring response ) send_response ) { send_response(Version.getVersionString(this.app_name, this.ver)); send_response("\n"); diff --git a/src/ocean/util/cipher/gcrypt/AES.d b/src/ocean/util/cipher/gcrypt/AES.d index a98a35b3c..50a52858e 100644 --- a/src/ocean/util/cipher/gcrypt/AES.d +++ b/src/ocean/util/cipher/gcrypt/AES.d @@ -39,7 +39,7 @@ public alias GcryptNoIV!(Algorithm.GCRY_CIPHER_AES, Mode.GCRY_CIPHER_MODE_ECB) A unittest { // AES128 requires a key of length 16 bytes. - const KEY = "asdfghjklqwertyu"; + static immutable KEY = "asdfghjklqwertyu"; testAES!(AES128, KEY)(); } @@ -50,7 +50,7 @@ public alias GcryptNoIV!(Algorithm.GCRY_CIPHER_AES192, Mode.GCRY_CIPHER_MODE_ECB unittest { // AES192 requires a key of length 24 bytes. - const KEY = "abcdefghijklmnopqrstuvwx"; + static immutable KEY = "abcdefghijklmnopqrstuvwx"; testAES!(AES192, KEY); } @@ -61,7 +61,7 @@ public alias GcryptNoIV!(Algorithm.GCRY_CIPHER_AES256, Mode.GCRY_CIPHER_MODE_ECB unittest { // AES256 requires a key of length 32 bytes. - const KEY = "abcdefghijklmnopqrstuvwxyz012345"; + static immutable KEY = "abcdefghijklmnopqrstuvwxyz012345"; testAES!(AES256, KEY); } @@ -80,10 +80,10 @@ public alias GcryptWithIV!(Algorithm.GCRY_CIPHER_AES, Mode.GCRY_CIPHER_MODE_CBC) unittest { // AES128-CBC requires a key of length 16 bytes. - const KEY = "asdfghjklqwertyu"; + static immutable KEY = "asdfghjklqwertyu"; // AES128-CBC requires an IV of length 16 bytes. - const IV = "0123456789ABCDEF"; + static immutable IV = "0123456789ABCDEF"; testAES_IV!(AES128_CBC, KEY, IV); } @@ -94,10 +94,10 @@ public alias GcryptWithIV!(Algorithm.GCRY_CIPHER_AES192, Mode.GCRY_CIPHER_MODE_C unittest { // AES192-CBC requires a key of length 24 bytes. - const KEY = "abcdefghijklmnopqrstuvwx"; + static immutable KEY = "abcdefghijklmnopqrstuvwx"; // AES192-CBC requires an IV of length 16 bytes. - const IV = "0123456789ABCDEF"; + static immutable IV = "0123456789ABCDEF"; testAES_IV!(AES192_CBC, KEY, IV); } @@ -108,10 +108,10 @@ public alias GcryptWithIV!(Algorithm.GCRY_CIPHER_AES256, Mode.GCRY_CIPHER_MODE_C unittest { // AES256-CBC requires a key of length 32 bytes. - const KEY = "abcdefghijklmnopqrstuvwxyz012345"; + static immutable KEY = "abcdefghijklmnopqrstuvwxyz012345"; // AES256-CBC requires an IV of length 16 bytes. - const IV = "0123456789ABCDEF"; + static immutable IV = "0123456789ABCDEF"; testAES_IV!(AES256_CBC, KEY, IV); } diff --git a/src/ocean/util/cipher/gcrypt/PBKDF2.d b/src/ocean/util/cipher/gcrypt/PBKDF2.d index c325c9480..5424db55f 100644 --- a/src/ocean/util/cipher/gcrypt/PBKDF2.d +++ b/src/ocean/util/cipher/gcrypt/PBKDF2.d @@ -49,7 +49,7 @@ unittest auto pbkdf2 = new PBKDF2(passphrase, salt); // The number of hashing iterations - const ITERATIONS = 256; + static immutable ITERATIONS = 256; // The buffer to write the key to, set to the expected key length ubyte[] key_buf; @@ -59,7 +59,7 @@ unittest auto key = pbkdf2.derive(ITERATIONS, key_buf); // The expected key is created so the output of pbkdf2 can be verified - const EXPECTED_KEY = "1a0e45a1b7dd26f47b3549c56dca01df2fa27fa50ef799d9165db53b202fa267"; + static immutable EXPECTED_KEY = "1a0e45a1b7dd26f47b3549c56dca01df2fa27fa50ef799d9165db53b202fa267"; ubyte[] expected_key; hexToBin(EXPECTED_KEY, expected_key); diff --git a/src/ocean/util/cipher/gcrypt/c/gpgerror.d b/src/ocean/util/cipher/gcrypt/c/gpgerror.d index 8cab33ef4..166998f3a 100644 --- a/src/ocean/util/cipher/gcrypt/c/gpgerror.d +++ b/src/ocean/util/cipher/gcrypt/c/gpgerror.d @@ -34,8 +34,8 @@ import ocean.core.Verify; extern (C): /// See original's library documentation for details. -const GPG_ERROR_VERSION_NUMBER = 0x011500; -const GPGRT_VERSION_NUMBER = 0x011500; +static immutable GPG_ERROR_VERSION_NUMBER = 0x011500; +static immutable GPGRT_VERSION_NUMBER = 0x011500; /// See original's library documentation for details. alias uint gpg_error_t; @@ -71,7 +71,7 @@ enum GPG_ERR_SOURCE } /// See original's library documentation for details. -const GPG_ERR_SOURCE_DIM = GPG_ERR_SOURCE.max + 1; +static immutable GPG_ERR_SOURCE_DIM = GPG_ERR_SOURCE.max + 1; /// See original's library documentation for details. @@ -601,10 +601,10 @@ enum GPG_ERR_CODE } /// See original's library documentation for details. -const GPG_ERR_CODE_DIM = GPG_ERR_CODE.max + 1; +static immutable GPG_ERR_CODE_DIM = GPG_ERR_CODE.max + 1; /// See original's library documentation for details. -const GPG_ERR_SOURCE_SHIFT = 24; +static immutable GPG_ERR_SOURCE_SHIFT = 24; /// See original's library documentation for details. uint gpg_err_init(); diff --git a/src/ocean/util/cipher/misc/ByteConverter.d b/src/ocean/util/cipher/misc/ByteConverter.d index d4d954a22..8f28729c7 100644 --- a/src/ocean/util/cipher/misc/ByteConverter.d +++ b/src/ocean/util/cipher/misc/ByteConverter.d @@ -26,7 +26,7 @@ version ( UnitTest ) /** Converts between integral types and unsigned byte arrays */ struct ByteConverter { - private const istring hexits = "0123456789abcdef"; + private enum istring hexits = "0123456789abcdef"; /** Conversions between little endian integrals and bytes */ struct LittleEndian diff --git a/src/ocean/util/cipher/misc/Padding.d b/src/ocean/util/cipher/misc/Padding.d index d44e74f70..5612a1e0a 100644 --- a/src/ocean/util/cipher/misc/Padding.d +++ b/src/ocean/util/cipher/misc/Padding.d @@ -94,7 +94,7 @@ ubyte[] padPKCS5 ( ref ubyte[] buffer ) { verify(buffer.length <= 8); - const PKCS5_BLOCK_SIZE = 8; + static immutable PKCS5_BLOCK_SIZE = 8; return padPKCS7(buffer, PKCS5_BLOCK_SIZE); } diff --git a/src/ocean/util/compress/c/zlib.d b/src/ocean/util/compress/c/zlib.d index 06ee3a825..cb833bcc9 100644 --- a/src/ocean/util/compress/c/zlib.d +++ b/src/ocean/util/compress/c/zlib.d @@ -24,11 +24,11 @@ module ocean.util.compress.c.zlib; import ocean.transition; /// See original's library documentation for details. -const ZLIB_VERSION = "1.2.3".ptr; +static immutable ZLIB_VERSION = "1.2.3".ptr; /// See original's library documentation for details. -const uint ZLIB_VERNUM = 0x1230; +static immutable uint ZLIB_VERNUM = 0x1230; /// See original's library documentation for details. -const void* Z_NULL = null; +static immutable void* Z_NULL = null; extern (C): private @@ -261,9 +261,9 @@ alias int function(void*, ubyte*, uint) out_func; /// See original's library documentation for details. int inflateBack(z_streamp strm, - in_func in_fn, + scope in_func in_fn, void* in_desc, - out_func out_fn, + scope out_func out_fn, void* out_desc); /// See original's library documentation for details. diff --git a/src/ocean/util/config/ConfigFiller.d b/src/ocean/util/config/ConfigFiller.d index 87657f17b..01e01094f 100644 --- a/src/ocean/util/config/ConfigFiller.d +++ b/src/ocean/util/config/ConfigFiller.d @@ -294,11 +294,11 @@ struct MinMax ( T, T min, T max, T init = T.init ) private void check_ ( bool found, cstring group, cstring name ) { enforce!(ConfigException)( - Value(this.value) >= min, + Value((&this).value) >= min, format("Configuration key {}.{} is smaller than allowed minimum of {}", group, name, min)); enforce!(ConfigException)( - Value(this.value) <= max, + Value((&this).value) <= max, format("Configuration key {}.{} is bigger than allowed maximum of {}", group, name, max)); } @@ -342,7 +342,7 @@ struct Min ( T, T min, T init = T.init ) private void check_ ( bool found, cstring group, cstring name ) { enforce!(ConfigException)( - Value(this.value) >= min, + Value((&this).value) >= min, format("Configuration key {}.{} is smaller than allowed minimum of {}", group, name, min)); } @@ -387,7 +387,7 @@ struct Max ( T, T max, T init = T.init ) private void check_ ( bool found, cstring group, cstring name ) { enforce!(ConfigException)( - Value(this.value) <= max, + Value((&this).value) <= max, format("Configuration key {}.{} is bigger than allowed maximum of {}", group, name, max)); } @@ -460,7 +460,7 @@ struct LimitCmp ( T, T init = T.init, alias comp = defComp!(T), Set... ) ~ typeof(el).stringof ~ " to " ~ T.stringof ~ " )" ); - if ( comp(Value(this.value), el) ) + if ( comp(Value((&this).value), el) ) return; } @@ -474,7 +474,7 @@ struct LimitCmp ( T, T init = T.init, alias comp = defComp!(T), Set... ) throw new ConfigException( format("Value '{}' of configuration key {}.{} is not within the " ~ "set of allowed values ({})", - Value(this.value), group, name, allowed_vals[2 .. $])); + Value((&this).value), group, name, allowed_vals[2 .. $])); } } @@ -553,7 +553,7 @@ struct SetInfo ( T ) { if ( set ) { - return Value(this.value); + return Value((&this).value); } return def; @@ -581,7 +581,7 @@ struct SetInfo ( T ) private void check_ ( bool found, cstring group, cstring name ) { - this.set = found; + (&this).set = found; } } @@ -598,22 +598,22 @@ struct SetInfo ( T ) public template IsSupported ( T ) { static if ( is(T : bool) ) - const IsSupported = true; + static immutable IsSupported = true; else static if ( isIntegerType!(T) || isRealType!(T) ) - const IsSupported = true; + static immutable IsSupported = true; else static if ( is(ElementTypeOf!(T) U) ) { static if ( isCharType!(U) ) // If it is a string - const IsSupported = true; + static immutable IsSupported = true; else static if ( isUTF8StringType!(U) ) // If it is string of strings - const IsSupported = true; + static immutable IsSupported = true; else static if ( isIntegerType!(U) || isRealType!(U) ) - const IsSupported = true; + static immutable IsSupported = true; else - const IsSupported = false; + static immutable IsSupported = false; } else - const IsSupported = false; + static immutable IsSupported = false; } @@ -815,7 +815,7 @@ struct ConfigIterator ( T, Source = ConfigParser ) invariant() { - assert(this.config !is null, + assert((&this).config !is null, "ConfigFiller.ConfigIterator: Cannot have null config"); } @@ -828,11 +828,11 @@ struct ConfigIterator ( T, Source = ConfigParser ) ***************************************************************************/ - public int opApply ( int delegate ( ref istring name, ref T x ) dg ) + public int opApply ( scope int delegate ( ref istring name, ref T x ) dg ) { int result = 0; - foreach ( key; this.config ) + foreach ( key; (&this).config ) { static if (is (T == struct)) { @@ -843,13 +843,13 @@ struct ConfigIterator ( T, Source = ConfigParser ) scope T instance = new T; } - if ( key.length > this.root.length - && key[0 .. this.root.length] == this.root - && key[this.root.length] == '.' ) + if ( key.length > (&this).root.length + && key[0 .. (&this).root.length] == (&this).root + && key[(&this).root.length] == '.' ) { - .fill(key, instance, this.config); + .fill(key, instance, (&this).config); - auto name = key[this.root.length + 1 .. $]; + auto name = key[(&this).root.length + 1 .. $]; result = dg(name, instance); if (result) break; @@ -871,17 +871,17 @@ struct ConfigIterator ( T, Source = ConfigParser ) ***************************************************************************/ - public int opApply ( int delegate ( ref istring name ) dg ) + public int opApply ( scope int delegate ( ref istring name ) dg ) { int result = 0; - foreach ( key; this.config ) + foreach ( key; (&this).config ) { - if ( key.length > this.root.length - && key[0 .. this.root.length] == this.root - && key[this.root.length] == '.' ) + if ( key.length > (&this).root.length + && key[0 .. (&this).root.length] == (&this).root + && key[(&this).root.length] == '.' ) { - auto name = key[this.root.length + 1 .. $]; + auto name = key[(&this).root.length + 1 .. $]; result = dg(name); if (result) break; @@ -906,9 +906,9 @@ struct ConfigIterator ( T, Source = ConfigParser ) public void fill ( cstring name, ref T instance ) { - auto key = this.root ~ "." ~ name; + auto key = (&this).root ~ "." ~ name; - .fill(key, instance, this.config); + .fill(key, instance, (&this).config); } } @@ -1150,7 +1150,7 @@ unittest } unittest { - const config_text = + static immutable config_text = ` [Section] str = I'm a string @@ -1202,7 +1202,7 @@ pi = 3.14 unittest { - const config_text = + static immutable config_text = ` [Section] str = I'm a mutable string @@ -1224,7 +1224,7 @@ str = I'm a mutable string unittest { - const config_text = + static immutable config_text = ` [SectionArray] string_arr = Hello diff --git a/src/ocean/util/config/ConfigParser.d b/src/ocean/util/config/ConfigParser.d index b904490aa..4a3ce2432 100644 --- a/src/ocean/util/config/ConfigParser.d +++ b/src/ocean/util/config/ConfigParser.d @@ -103,11 +103,11 @@ public class ConfigParser ***********************************************************************/ - public int opApply ( int delegate ( ref istring key, ref T val ) dg ) + public int opApply ( scope int delegate ( ref istring key, ref T val ) dg ) { - if ( this.vars !is null ) + if ( (&this).vars !is null ) { - foreach ( key, valnode; *this.vars ) + foreach ( key, valnode; *(&this).vars ) { auto val = conv!(T)(valnode.value); @@ -126,9 +126,9 @@ public class ConfigParser ***********************************************************************/ - public int opApply ( int delegate ( ref istring x ) dg ) + public int opApply ( scope int delegate ( ref istring x ) dg ) { - return this.opApply( + return (&this).opApply( (ref istring key, ref istring val) { return dg(key); @@ -287,7 +287,7 @@ public class ConfigParser ***************************************************************************/ - public int opApply ( int delegate ( ref istring x ) dg ) + public int opApply ( scope int delegate ( ref istring x ) dg ) { int result = 0; @@ -394,11 +394,11 @@ public class ConfigParser { T[] data; - int opApply ( int delegate ( ref T[] x ) dg ) + int opApply ( scope int delegate ( ref T[] x ) dg ) { int result = 0; - foreach ( ref line; lines(this.data) ) + foreach ( ref line; lines((&this).data) ) { result = dg(line); @@ -852,7 +852,7 @@ public class ConfigParser private static bool toBool ( cstring property ) { - const istring[2][] BOOL_IDS = + static immutable istring[2][] BOOL_IDS = [ ["false", "true"], ["disabled", "enabled"], @@ -1430,7 +1430,7 @@ three = teen // Test to ensure that a few hundred additional parses of the same // configuration does not allocate at all. testNoAlloc({ - const num_parses = 200; + static immutable num_parses = 200; for (int i; i < num_parses; i++) { Config.parseString(str2); diff --git a/src/ocean/util/container/AppendBuffer.d b/src/ocean/util/container/AppendBuffer.d index 687c561de..55c3bff55 100644 --- a/src/ocean/util/container/AppendBuffer.d +++ b/src/ocean/util/container/AppendBuffer.d @@ -67,7 +67,7 @@ interface IAppendBufferBase interface IAppendBufferReader ( T ) : IAppendBufferBase { alias T ElementType; - const element_size = T.sizeof; + static immutable element_size = T.sizeof; /************************************************************************** @@ -94,13 +94,13 @@ interface IAppendBufferReader ( T ) : IAppendBufferBase static if (is (T U : U[]) && !is (T == U[])) { - const static_array_element = true; + static immutable static_array_element = true; alias U[] R; } else { - const static_array_element = false; + static immutable static_array_element = false; alias T R; } @@ -121,7 +121,7 @@ interface IAppendBufferReader ( T ) : IAppendBufferBase } else { - const static_array_element = false; + static immutable static_array_element = false; } /************************************************************************** @@ -682,7 +682,7 @@ public class AppendBuffer ( T, Base: AppendBufferImpl ): Base, IAppendBufferRead { // work around DMD bug 7752 - const t_init = [U.init]; + static immutable t_init = [U.init]; data[] = t_init; } diff --git a/src/ocean/util/container/CircularList.d b/src/ocean/util/container/CircularList.d index 7a0fed0f8..276ada60b 100644 --- a/src/ocean/util/container/CircularList.d +++ b/src/ocean/util/container/CircularList.d @@ -175,7 +175,7 @@ class CircularList (V, alias Reap = Container.reap, ***********************************************************************/ - final int opApply (int delegate(ref V value) dg) + final int opApply (scope int delegate(ref V value) dg) { return iterator.opApply (dg); } @@ -1010,7 +1010,7 @@ class CircularList (V, alias Reap = Container.reap, ***************************************************************/ - int opApply (int delegate(ref V value) dg) + int opApply (scope int delegate(ref V value) dg) { int result; auto c = cell; @@ -1080,7 +1080,7 @@ class CircularList (V, alias Reap = Container.reap, ++count; // ignore this change ++mutation; - return *this; + return *(&this); } /*************************************************************** @@ -1096,7 +1096,7 @@ class CircularList (V, alias Reap = Container.reap, rev ^= true; next; index = 0; - return *this; + return *(&this); } } } @@ -1200,7 +1200,7 @@ debug (CircularList) // use a chunk allocator, and presize the bucket[] auto test = new CircularList!(uint, Container.reap, Container.Chunk); test.cache (1000, 1_000_000); - const count = 1_000_000; + static immutable count = 1_000_000; StopWatch w; // benchmark adding diff --git a/src/ocean/util/container/Clink.d b/src/ocean/util/container/Clink.d index 23692a27d..ce864572c 100644 --- a/src/ocean/util/container/Clink.d +++ b/src/ocean/util/container/Clink.d @@ -42,7 +42,7 @@ struct Clink (V) Ref set (V v) { - return set (v, this, this); + return set (v, (&this), (&this)); } /*********************************************************************** @@ -59,7 +59,7 @@ struct Clink (V) value = v; prev = p; next = n; - return this; + return (&this); } /** @@ -68,7 +68,7 @@ struct Clink (V) bool singleton() { - return next is this; + return next is (&this); } void linkNext (Ref p) @@ -77,7 +77,7 @@ struct Clink (V) { next.prev = p; p.next = next; - p.prev = this; + p.prev = (&this); next = p; } } @@ -86,9 +86,9 @@ struct Clink (V) * Make a cell holding v and link it immediately after current cell **/ - void addNext (V v, Ref delegate() alloc) + void addNext (V v, scope Ref delegate() alloc) { - auto p = alloc().set (v, this, next); + auto p = alloc().set (v, (&this), next); next.prev = p; next = p; } @@ -97,10 +97,10 @@ struct Clink (V) * make a node holding v, link it before the current cell, and return it **/ - Ref addPrev (V v, Ref delegate() alloc) + Ref addPrev (V v, scope Ref delegate() alloc) { auto p = prev; - auto c = alloc().set (v, p, this); + auto c = alloc().set (v, p, (&this)); p.next = c; prev = c; return c; @@ -116,7 +116,7 @@ struct Clink (V) { prev.next = p; p.prev = prev; - p.next = this; + p.next = (&this); prev = p; } } @@ -128,11 +128,11 @@ struct Clink (V) int size() { int c = 0; - auto p = this; + auto p = (&this); do { ++c; p = p.next; - } while (p !is this); + } while (p !is (&this)); return c; } @@ -143,12 +143,12 @@ struct Clink (V) Ref find (V element) { - auto p = this; + auto p = (&this); do { if (element == p.value) return p; p = p.next; - } while (p !is this); + } while (p !is (&this)); return null; } @@ -160,12 +160,12 @@ struct Clink (V) int count (V element) { int c = 0; - auto p = this; + auto p = (&this); do { if (element == p.value) ++c; p = p.next; - } while (p !is this); + } while (p !is (&this)); return c; } @@ -175,7 +175,7 @@ struct Clink (V) Ref nth (size_t n) { - auto p = this; + auto p = (&this); for (ptrdiff_t i = 0; i < n; ++i) p = p.next; return p; @@ -190,7 +190,7 @@ struct Clink (V) void unlinkNext () { auto nn = next.next; - nn.prev = this; + nn.prev = (&this); next = nn; } @@ -202,7 +202,7 @@ struct Clink (V) void unlinkPrev () { auto pp = prev.prev; - pp.next = this; + pp.next = (&this); prev = pp; } @@ -218,17 +218,17 @@ struct Clink (V) auto n = next; p.next = n; n.prev = p; - prev = this; - next = this; + prev = (&this); + next = (&this); } /** * Make a copy of the list and return new head. **/ - Ref copyList (Ref delegate() alloc) + Ref copyList (scope Ref delegate() alloc) { - auto hd = this; + auto hd = (&this); auto newlist = alloc().set (hd.value, null, null); auto current = newlist; diff --git a/src/ocean/util/container/ConcatBuffer.d b/src/ocean/util/container/ConcatBuffer.d index b58f2f5e4..d54d07c44 100644 --- a/src/ocean/util/container/ConcatBuffer.d +++ b/src/ocean/util/container/ConcatBuffer.d @@ -389,7 +389,7 @@ public class SliceBuffer ( T ) : ConcatBuffer!(T) ***************************************************************************/ - public int opApply ( int delegate ( ref T[] ) dg ) + public int opApply ( scope int delegate ( ref T[] ) dg ) { int res; @@ -411,7 +411,7 @@ public class SliceBuffer ( T ) : ConcatBuffer!(T) ***************************************************************************/ - public int opApply ( int delegate ( ref size_t, ref T[] ) dg ) + public int opApply ( scope int delegate ( ref size_t, ref T[] ) dg ) { int res; diff --git a/src/ocean/util/container/Container.d b/src/ocean/util/container/Container.d index 17c7c2ec6..a571a14c4 100644 --- a/src/ocean/util/container/Container.d +++ b/src/ocean/util/container/Container.d @@ -205,7 +205,7 @@ struct Container void config (size_t chunks, size_t allocate=0) { - this.chunks = chunks; + (&this).chunks = chunks; if (allocate) for (ptrdiff_t i=allocate/chunks+1; i--;) newlist; @@ -363,7 +363,7 @@ struct Container void config (size_t chunks, int allocate=0) { - this.chunks = chunks; + (&this).chunks = chunks; if (allocate) for (int i=allocate/chunks+1; i--;) newlist; diff --git a/src/ocean/util/container/FixedKeyMap.d b/src/ocean/util/container/FixedKeyMap.d index d38b29f07..03c1bcd9b 100644 --- a/src/ocean/util/container/FixedKeyMap.d +++ b/src/ocean/util/container/FixedKeyMap.d @@ -231,7 +231,7 @@ public class FixedKeyMap ( K, V ) ***************************************************************************/ - public int opApply ( int delegate ( ref K ) dg ) + public int opApply ( scope int delegate ( ref K ) dg ) { int res; foreach ( key; this.keys ) @@ -249,7 +249,7 @@ public class FixedKeyMap ( K, V ) ***************************************************************************/ - public int opApply ( int delegate ( ref K, ref V ) dg ) + public int opApply ( scope int delegate ( ref K, ref V ) dg ) { int res; foreach ( i, key; this.keys ) @@ -267,7 +267,7 @@ public class FixedKeyMap ( K, V ) ***************************************************************************/ - public int opApply ( int delegate ( ref size_t, ref K, ref V ) dg ) + public int opApply ( scope int delegate ( ref size_t, ref K, ref V ) dg ) { int res; foreach ( i, key; this.keys ) diff --git a/src/ocean/util/container/HashRangeMap.d b/src/ocean/util/container/HashRangeMap.d index 2eecb502c..a4b1183e8 100644 --- a/src/ocean/util/container/HashRangeMap.d +++ b/src/ocean/util/container/HashRangeMap.d @@ -90,7 +90,7 @@ public struct HashRangeMap ( Value ) invariant() { - assert(this.ranges.length == this.values.length, + assert((&this).ranges.length == (&this).values.length, "HashRangeMap: length mismatch between ranges and values"); } @@ -106,7 +106,7 @@ public struct HashRangeMap ( Value ) public bool empty ( ) { - return this.length == 0; + return (&this).length == 0; } unittest @@ -139,7 +139,7 @@ public struct HashRangeMap ( Value ) public size_t length ( ) { - return this.ranges.length; + return (&this).ranges.length; } unittest @@ -191,16 +191,16 @@ public struct HashRangeMap ( Value ) enforce(!range.is_empty, "An empty range can't be put in HashRangeMap"); size_t insert_place; - added = !bsearch(this.ranges, range, insert_place); + added = !bsearch((&this).ranges, range, insert_place); if (added) { - insertShift(this.ranges, insert_place); - this.ranges[insert_place] = range; - insertShift(this.values, insert_place); + insertShift((&this).ranges, insert_place); + (&this).ranges[insert_place] = range; + insertShift((&this).values, insert_place); } - return &this.values[insert_place]; + return &(&this).values[insert_place]; } @@ -219,12 +219,12 @@ public struct HashRangeMap ( Value ) public bool remove ( HashRange range ) { size_t remove_place; - bool result = bsearch(this.ranges, range, remove_place); + bool result = bsearch((&this).ranges, range, remove_place); if (result) { - removeShift(this.ranges, remove_place); - removeShift(this.values, remove_place); + removeShift((&this).ranges, remove_place); + removeShift((&this).values, remove_place); } return result; @@ -239,11 +239,11 @@ public struct HashRangeMap ( Value ) public void clear () { - this.ranges.length = 0; - enableStomping(this.ranges); + (&this).ranges.length = 0; + enableStomping((&this).ranges); - this.values.length = 0; - enableStomping(this.values); + (&this).values.length = 0; + enableStomping((&this).values); } unittest @@ -277,10 +277,10 @@ public struct HashRangeMap ( Value ) public Value* opIn_r ( HashRange range ) { size_t insert_place; - if (!bsearch(this.ranges, range, insert_place)) + if (!bsearch((&this).ranges, range, insert_place)) return null; - return &this.values[insert_place]; + return &(&this).values[insert_place]; } @@ -292,12 +292,12 @@ public struct HashRangeMap ( Value ) ***************************************************************************/ - public int opApply ( int delegate ( ref HashRange r, ref Value v ) dg ) + public int opApply ( scope int delegate ( ref HashRange r, ref Value v ) dg ) { int result = 0; - foreach (i, range; this.ranges) + foreach (i, range; (&this).ranges) { - result = dg(range, this.values[i]); + result = dg(range, (&this).values[i]); if(result) break; @@ -321,7 +321,7 @@ public struct HashRangeMap ( Value ) public bool isTessellated () { - return HashRange(hash_t.min, hash_t.max).isTessellatedBy(this.ranges); + return HashRange(hash_t.min, hash_t.max).isTessellatedBy((&this).ranges); } unittest @@ -402,8 +402,8 @@ public struct HashRangeMap ( Value ) public bool hasGap () { - return extent(this.ranges) != HashRange(hash_t.min, hash_t.max) - || ocean.math.Range.hasGap(this.ranges); + return extent((&this).ranges) != HashRange(hash_t.min, hash_t.max) + || ocean.math.Range.hasGap((&this).ranges); } unittest @@ -465,7 +465,7 @@ public struct HashRangeMap ( Value ) public bool hasOverlap () { - return ocean.math.Range.hasOverlap(this.ranges); + return ocean.math.Range.hasOverlap((&this).ranges); } unittest @@ -592,12 +592,12 @@ unittest equals_t opEquals(S other) { - return this.x == other.x; + return (&this).x == other.x; } istring toString() { - return "S(" ~ to!(istring)(this.x) ~ ")"; + return "S(" ~ to!(istring)((&this).x) ~ ")"; } } @@ -637,11 +637,11 @@ version ( UnitTest ) { static if (is(T == struct) || is(T == class) || is(T == interface)) { - const hasAtomicEquality = is(typeof(T.opEquals)); + static immutable hasAtomicEquality = is(typeof(T.opEquals)); } else { - const hasAtomicEquality = isPrimitiveType!(T) || isPointerType!(T); + static immutable hasAtomicEquality = isPrimitiveType!(T) || isPointerType!(T); } } @@ -650,11 +650,11 @@ version ( UnitTest ) { static if (isArrayType!(T)) { - const hasEquality = hasAtomicEquality!(StripAllArrays!(T)); + static immutable hasEquality = hasAtomicEquality!(StripAllArrays!(T)); } else { - const hasEquality = hasAtomicEquality!(T); + static immutable hasEquality = hasAtomicEquality!(T); } } diff --git a/src/ocean/util/container/HashSet.d b/src/ocean/util/container/HashSet.d index 974d7acde..879ec7065 100644 --- a/src/ocean/util/container/HashSet.d +++ b/src/ocean/util/container/HashSet.d @@ -128,7 +128,7 @@ class HashSet (V, alias Hash = Container.hash, ***********************************************************************/ - final int opApply (int delegate(ref V value) dg) + final int opApply (scope int delegate(ref V value) dg) { return iterator.opApply (dg); } @@ -751,7 +751,7 @@ class HashSet (V, alias Hash = Container.hash, ***************************************************************/ - int opApply (int delegate(ref V value) dg) + int opApply (scope int delegate(ref V value) dg) { int result; @@ -853,7 +853,7 @@ debug (HashSet) auto test = new HashSet!(int, Container.hash, Container.reap, Container.Chunk); test.cache (1000, 1_000_000); test.buckets = 1_500_000; - const count = 1_000_000; + static immutable count = 1_000_000; StopWatch w; // benchmark adding diff --git a/src/ocean/util/container/LinkedList.d b/src/ocean/util/container/LinkedList.d index 6dbf72bc5..1d61b3446 100644 --- a/src/ocean/util/container/LinkedList.d +++ b/src/ocean/util/container/LinkedList.d @@ -172,7 +172,7 @@ class LinkedList (V, alias Reap = Container.reap, ***********************************************************************/ - final int opApply (int delegate(ref V value) dg) + final int opApply (scope int delegate(ref V value) dg) { return iterator.opApply (dg); } @@ -1035,7 +1035,7 @@ class LinkedList (V, alias Reap = Container.reap, ***************************************************************/ - int opApply (int delegate(ref V value) dg) + int opApply (scope int delegate(ref V value) dg) { int result; @@ -1141,7 +1141,7 @@ debug (LinkedList) // use a chunk allocator, and presize the bucket[] auto test = new LinkedList!(int, Container.reap, Container.Chunk); test.cache (2000, 1_000_000); - const count = 1_000_000; + static immutable count = 1_000_000; StopWatch w; // benchmark adding diff --git a/src/ocean/util/container/RedBlack.d b/src/ocean/util/container/RedBlack.d index 5e3f4d3d9..df767340c 100644 --- a/src/ocean/util/container/RedBlack.d +++ b/src/ocean/util/container/RedBlack.d @@ -105,7 +105,7 @@ struct RedBlack (V, A = AttributeDummy) right = null; parent = null; color = BLACK; - return this; + return (&this); } /** @@ -114,7 +114,7 @@ struct RedBlack (V, A = AttributeDummy) * multiple identical links in a RB tree.) **/ - protected Ref dup (Ref delegate() alloc) + protected Ref dup (scope Ref delegate() alloc) { static if (is(typeof(A) == AttributeDummy)) auto t = alloc().set (value); @@ -137,14 +137,14 @@ struct RedBlack (V, A = AttributeDummy) // So restrict to the following verify(parent is null || - this is parent.left || - this is parent.right); + (&this) is parent.left || + (&this) is parent.right); verify(left is null || - this is left.parent); + (&this) is left.parent); verify(right is null || - this is right.parent); + (&this) is right.parent); verify(color is BLACK || (colorOf(left) is BLACK) && (colorOf(right) is BLACK)); @@ -161,7 +161,7 @@ struct RedBlack (V, A = AttributeDummy) Ref leftmost () { - auto p = this; + auto p = (&this); for ( ; p.left; p = p.left) {} return p; } @@ -171,7 +171,7 @@ struct RedBlack (V, A = AttributeDummy) **/ Ref rightmost () { - auto p = this; + auto p = (&this); for ( ; p.right; p = p.right) {} return p; } @@ -181,7 +181,7 @@ struct RedBlack (V, A = AttributeDummy) **/ Ref root () { - auto p = this; + auto p = (&this); for ( ; p.parent; p = p.parent) {} return p; } @@ -206,7 +206,7 @@ struct RedBlack (V, A = AttributeDummy) return right.leftmost; auto p = parent; - auto ch = this; + auto ch = (&this); while (p && ch is p.right) { ch = p; @@ -225,7 +225,7 @@ struct RedBlack (V, A = AttributeDummy) return left.rightmost; auto p = parent; - auto ch = this; + auto ch = (&this); while (p && ch is p.left) { ch = p; @@ -256,7 +256,7 @@ struct RedBlack (V, A = AttributeDummy) Ref find (V value, Compare!(V) cmp) { - auto t = this; + auto t = (&this); for (;;) { auto diff = cmp (value, t.value); @@ -282,9 +282,9 @@ struct RedBlack (V, A = AttributeDummy) **/ Ref findFirst (V value, Compare!(V) cmp, bool after = true) { - auto t = this; - auto tLower = this; - auto tGreater = this; + auto t = (&this); + auto tLower = (&this); + auto tGreater = (&this); for (;;) { @@ -329,7 +329,7 @@ struct RedBlack (V, A = AttributeDummy) int count (V value, Compare!(V) cmp) { auto c = 0; - auto t = this; + auto t = (&this); while (t) { int diff = cmp (value, t.value); @@ -360,7 +360,7 @@ struct RedBlack (V, A = AttributeDummy) { Ref findAttribute (A attribute, Compare!(A) cmp) { - auto t = this; + auto t = (&this); while (t) { @@ -388,7 +388,7 @@ struct RedBlack (V, A = AttributeDummy) int countAttribute (A attrib, Compare!(A) cmp) { int c = 0; - auto t = this; + auto t = (&this); while (t) { @@ -414,7 +414,7 @@ struct RedBlack (V, A = AttributeDummy) **/ Ref find (V value, A attribute, Compare!(V) cmp) { - auto t = this; + auto t = (&this); for (;;) { @@ -441,7 +441,7 @@ struct RedBlack (V, A = AttributeDummy) * Return a new subtree containing each value of current subtree **/ - Ref copyTree (Ref delegate() alloc) + Ref copyTree (scope Ref delegate() alloc) { auto t = dup (alloc); @@ -478,7 +478,7 @@ struct RedBlack (V, A = AttributeDummy) Ref insertLeft (Ref cell, Ref root) { left = cell; - cell.parent = this; + cell.parent = (&this); return cell.fixAfterInsertion (root); } @@ -494,7 +494,7 @@ struct RedBlack (V, A = AttributeDummy) Ref insertRight (Ref cell, Ref root) { right = cell; - cell.parent = this; + cell.parent = (&this); return cell.fixAfterInsertion (root); } @@ -521,7 +521,7 @@ struct RedBlack (V, A = AttributeDummy) // To work nicely with arbitrary subclasses of Ref, we don't want to // just copy successor's fields. since we don't know what // they are. Instead we swap positions _in the tree. - root = swapPosition (this, s, root); + root = swapPosition ((&this), s, root); } // Start fixup at replacement node (normally a child). @@ -530,15 +530,15 @@ struct RedBlack (V, A = AttributeDummy) if (left is null && right is null) { if (color is BLACK) - root = this.fixAfterDeletion (root); + root = (&this).fixAfterDeletion (root); // Unlink (Couldn't before since fixAfterDeletion needs parent ptr) if (parent) { - if (this is parent.left) + if ((&this) is parent.left) parent.left = null; else - if (this is parent.right) + if ((&this) is parent.right) parent.right = null; parent = null; } @@ -555,7 +555,7 @@ struct RedBlack (V, A = AttributeDummy) if (parent is null) root = replacement; else - if (this is parent.left) + if ((&this) is parent.left) parent.left = replacement; else parent.right = replacement; @@ -770,18 +770,18 @@ struct RedBlack (V, A = AttributeDummy) right = r.left; if (r.left) - r.left.parent = this; + r.left.parent = (&this); r.parent = parent; if (parent is null) root = r; else - if (parent.left is this) + if (parent.left is (&this)) parent.left = r; else parent.right = r; - r.left = this; + r.left = (&this); parent = r; return root; } @@ -793,18 +793,18 @@ struct RedBlack (V, A = AttributeDummy) left = l.right; if (l.right !is null) - l.right.parent = this; + l.right.parent = (&this); l.parent = parent; if (parent is null) root = l; else - if (parent.right is this) + if (parent.right is (&this)) parent.right = l; else parent.left = l; - l.right = this; + l.right = (&this); parent = l; return root; } @@ -814,7 +814,7 @@ struct RedBlack (V, A = AttributeDummy) package Ref fixAfterInsertion (Ref root) { color = RED; - auto x = this; + auto x = (&this); while (x && x !is root && x.parent.color is RED) { @@ -876,7 +876,7 @@ struct RedBlack (V, A = AttributeDummy) /** From CLR **/ package Ref fixAfterDeletion(Ref root) { - auto x = this; + auto x = (&this); while (x !is root && colorOf(x) is BLACK) { if (x is leftOf(parentOf(x))) diff --git a/src/ocean/util/container/Slink.d b/src/ocean/util/container/Slink.d index bfa7bd249..361b0f302 100644 --- a/src/ocean/util/container/Slink.d +++ b/src/ocean/util/container/Slink.d @@ -88,13 +88,13 @@ struct Slink (V, K=KeyDummy, bool Identity = false, bool HashCache = false) { static if (Identity == true) { - for (auto p=this; p; p = p.next) + for (auto p=(&this); p; p = p.next) if (key is p.key) return p; } else { - for (auto p=this; p; p = p.next) + for (auto p=(&this); p; p = p.next) if (key == p.key) return p; } @@ -105,13 +105,13 @@ struct Slink (V, K=KeyDummy, bool Identity = false, bool HashCache = false) { static if (Identity == true) { - for (auto p=this; p; p = p.next) + for (auto p=(&this); p; p = p.next) if (key is p.key && value == p.value) return p; } else { - for (auto p=this; p; p = p.next) + for (auto p=(&this); p; p = p.next) if (key == p.key && value == p.value) return p; } @@ -123,13 +123,13 @@ struct Slink (V, K=KeyDummy, bool Identity = false, bool HashCache = false) int i = 0; static if (Identity == true) { - for (auto p=this; p; p = p.next, ++i) + for (auto p=(&this); p; p = p.next, ++i) if (key is p.key) return i; } else { - for (auto p=this; p; p = p.next, ++i) + for (auto p=(&this); p; p = p.next, ++i) if (key == p.key) return i; } @@ -141,13 +141,13 @@ struct Slink (V, K=KeyDummy, bool Identity = false, bool HashCache = false) int i = 0; static if (Identity == true) { - for (auto p=this; p; p = p.next, ++i) + for (auto p=(&this); p; p = p.next, ++i) if (key is p.key && value == p.value) return i; } else { - for (auto p=this; p; p = p.next, ++i) + for (auto p=(&this); p; p = p.next, ++i) if (key == p.key && value == p.value) return i; } @@ -159,13 +159,13 @@ struct Slink (V, K=KeyDummy, bool Identity = false, bool HashCache = false) int c = 0; static if (Identity == true) { - for (auto p=this; p; p = p.next) + for (auto p=(&this); p; p = p.next) if (key is p.key) ++c; } else { - for (auto p=this; p; p = p.next) + for (auto p=(&this); p; p = p.next) if (key == p.key) ++c; } @@ -177,13 +177,13 @@ struct Slink (V, K=KeyDummy, bool Identity = false, bool HashCache = false) int c = 0; static if (Identity == true) { - for (auto p=this; p; p = p.next) + for (auto p=(&this); p; p = p.next) if (key is p.key && value == p.value) ++c; } else { - for (auto p=this; p; p = p.next) + for (auto p=(&this); p; p = p.next) if (key == p.key && value == p.value) ++c; } @@ -203,7 +203,7 @@ struct Slink (V, K=KeyDummy, bool Identity = false, bool HashCache = false) { next = n; value = v; - return this; + return (&this); } /*********************************************************************** @@ -246,7 +246,7 @@ struct Slink (V, K=KeyDummy, bool Identity = false, bool HashCache = false) final Ref find (V element) { - for (auto p = this; p; p = p.next) + for (auto p = (&this); p; p = p.next) if (element == p.value) return p; return null; @@ -262,7 +262,7 @@ struct Slink (V, K=KeyDummy, bool Identity = false, bool HashCache = false) final int index (V element) { int i; - for (auto p = this; p; p = p.next, ++i) + for (auto p = (&this); p; p = p.next, ++i) if (element == p.value) return i; @@ -278,7 +278,7 @@ struct Slink (V, K=KeyDummy, bool Identity = false, bool HashCache = false) final int count (V element) { int c; - for (auto p = this; p; p = p.next) + for (auto p = (&this); p; p = p.next) if (element == p.value) ++c; return c; @@ -293,7 +293,7 @@ struct Slink (V, K=KeyDummy, bool Identity = false, bool HashCache = false) final int count () { int c; - for (auto p = this; p; p = p.next) + for (auto p = (&this); p; p = p.next) ++c; return c; } @@ -307,7 +307,7 @@ struct Slink (V, K=KeyDummy, bool Identity = false, bool HashCache = false) final Ref tail () { - auto p = this; + auto p = (&this); while (p.next) p = p.next; return p; @@ -323,7 +323,7 @@ struct Slink (V, K=KeyDummy, bool Identity = false, bool HashCache = false) { enforce(n >= 0); - auto p = this; + auto p = (&this); for (long i; i < n && p; ++i) p = p.next; return p; @@ -336,7 +336,7 @@ struct Slink (V, K=KeyDummy, bool Identity = false, bool HashCache = false) ***********************************************************************/ - final Ref copy (Ref delegate() alloc) + final Ref copy (scope Ref delegate() alloc) { auto newlist = dup (alloc); auto current = newlist; @@ -356,7 +356,7 @@ struct Slink (V, K=KeyDummy, bool Identity = false, bool HashCache = false) ***********************************************************************/ - private Ref dup (Ref delegate() alloc) + private Ref dup (scope Ref delegate() alloc) { auto ret = alloc(); static if (is(typeof(K) == KeyDummy)) @@ -496,8 +496,8 @@ unittest { auto t = new NamedTest("Test nth() with an index out of bounds"); - const total_items = 11; - const index_out_of_bounds = total_items * 2; + static immutable total_items = 11; + static immutable index_out_of_bounds = total_items * 2; auto slink = new Slink!(int); t.test!("==")(slink.nth(0).value, 0); diff --git a/src/ocean/util/container/SortedMap.d b/src/ocean/util/container/SortedMap.d index 35bc80858..7f68f6008 100644 --- a/src/ocean/util/container/SortedMap.d +++ b/src/ocean/util/container/SortedMap.d @@ -225,7 +225,7 @@ class SortedMap (K, V, alias Reap = Container.reap, ***********************************************************************/ - final int opApply (int delegate (ref V value) dg) + final int opApply (scope int delegate (ref V value) dg) { return iterator.opApply ((ref K k, ref V v) {return dg(v);}); } @@ -235,7 +235,7 @@ class SortedMap (K, V, alias Reap = Container.reap, ***********************************************************************/ - final int opApply (int delegate (ref K key, ref V value) dg) + final int opApply (scope int delegate (ref K key, ref V value) dg) { return iterator.opApply (dg); } @@ -963,7 +963,7 @@ class SortedMap (K, V, alias Reap = Container.reap, ***************************************************************/ - int opApply (int delegate(ref K key, ref V value) dg) + int opApply (scope int delegate(ref K key, ref V value) dg) { int result; @@ -1011,7 +1011,7 @@ class SortedMap (K, V, alias Reap = Container.reap, bump = &back; else bump = &fore; - return *this; + return *(&this); } /*************************************************************** @@ -1092,7 +1092,7 @@ debug (SortedMap) // use a chunk allocator, and presize the bucket[] auto test = new SortedMap!(int, int, Container.reap, Container.Chunk); test.cache (1000, 500_000); - const count = 500_000; + static immutable count = 500_000; StopWatch w; auto keys = new int[count]; diff --git a/src/ocean/util/container/VoidBufferAsArrayOf.d b/src/ocean/util/container/VoidBufferAsArrayOf.d index 72f34799c..ef8b78b0b 100644 --- a/src/ocean/util/container/VoidBufferAsArrayOf.d +++ b/src/ocean/util/container/VoidBufferAsArrayOf.d @@ -71,7 +71,7 @@ public struct VoidBufferAsArrayOf ( T ) // The length of the buffer must always be an even multiple of T.sizeof. invariant ( ) { - assert(this.buffer.length % T.sizeof == 0); + assert((&this).buffer.length % T.sizeof == 0); } /*************************************************************************** @@ -83,7 +83,7 @@ public struct VoidBufferAsArrayOf ( T ) public T[] array ( ) { - return cast(T[])(*this.buffer); + return cast(T[])(*(&this).buffer); } /*************************************************************************** @@ -95,7 +95,7 @@ public struct VoidBufferAsArrayOf ( T ) public size_t length ( ) { - return this.buffer.length / T.sizeof; + return (&this).buffer.length / T.sizeof; } /*************************************************************************** @@ -109,8 +109,8 @@ public struct VoidBufferAsArrayOf ( T ) public void length ( size_t len ) { - this.buffer.length = len * T.sizeof; - enableStomping(*this.buffer); + (&this).buffer.length = len * T.sizeof; + enableStomping(*(&this).buffer); } /*************************************************************************** @@ -133,7 +133,7 @@ public struct VoidBufferAsArrayOf ( T ) public T[] opCatAssign ( in T[] arr ) { - return cast(T[])((*this.buffer) ~= cast(void[])arr); + return cast(T[])((*(&this).buffer) ~= cast(void[])arr); } /*************************************************************************** @@ -153,7 +153,7 @@ public struct VoidBufferAsArrayOf ( T ) public T[] opCatAssign ( in T element ) { - return this.opCatAssign((&element)[0 .. 1]); + return (&this).opCatAssign((&element)[0 .. 1]); } } diff --git a/src/ocean/util/container/btree/BTreeMap.d b/src/ocean/util/container/btree/BTreeMap.d index 8781a51ea..522b0f4e6 100644 --- a/src/ocean/util/container/btree/BTreeMap.d +++ b/src/ocean/util/container/btree/BTreeMap.d @@ -116,7 +116,7 @@ struct BTreeMap(TreeKeyType, TreeValueType, int tree_degree) package void initialize (IMemManager allocator = mallocMemManager) { - this.impl.initialize(allocator); + (&this).impl.initialize(allocator); } // Disable constructor, so user always needs to use the makeBTreeMap method @@ -149,7 +149,7 @@ struct BTreeMap(TreeKeyType, TreeValueType, int tree_degree) public bool insert (KeyType key, ValueType value) { bool added; - this.impl.insert(key, value, added); + (&this).impl.insert(key, value, added); return added; } @@ -183,7 +183,7 @@ struct BTreeMap(TreeKeyType, TreeValueType, int tree_degree) } body { - return this.impl.insert(key, value, added); + return (&this).impl.insert(key, value, added); } @@ -205,7 +205,7 @@ struct BTreeMap(TreeKeyType, TreeValueType, int tree_degree) public bool remove (KeyType key) { - return this.impl.remove(key); + return (&this).impl.remove(key); } /****************************************************************************** @@ -230,7 +230,7 @@ struct BTreeMap(TreeKeyType, TreeValueType, int tree_degree) public ValueType get (KeyType key, out bool found_element) { - return this.impl.get(key, found_element); + return (&this).impl.get(key, found_element); } /************************************************************************** @@ -252,7 +252,7 @@ struct BTreeMap(TreeKeyType, TreeValueType, int tree_degree) public ValueType* opIn_r (KeyType key) { - return this.impl.get(key); + return (&this).impl.get(key); } /*********************************************************************** @@ -268,9 +268,9 @@ struct BTreeMap(TreeKeyType, TreeValueType, int tree_degree) ***********************************************************************/ - public int opApply (int delegate (ref KeyType value, ref ValueType) dg) + public int opApply (scope int delegate (ref KeyType value, ref ValueType) dg) { - return this.impl.inorder(dg); + return (&this).impl.inorder(dg); } /*********************************************************************** @@ -286,9 +286,9 @@ struct BTreeMap(TreeKeyType, TreeValueType, int tree_degree) ***********************************************************************/ - public int opApply (int delegate (ref ValueType) dg) + public int opApply (scope int delegate (ref ValueType) dg) { - return this.impl.inorder(dg); + return (&this).impl.inorder(dg); } @@ -655,7 +655,7 @@ version (UnitTest) char[48] name_buf; ubyte name_length; - cstring name () /* d1to2fix_inject: const */ + cstring name () const { return name_buf[0..name_length]; } @@ -664,8 +664,8 @@ version (UnitTest) { //logger.error("setting name: {}", name); enforce (name.length <= ubyte.max); - this.name_length = cast(ubyte)name.length; - this.name_buf[0..this.name_length] = name[]; + (&this).name_length = cast(ubyte)name.length; + (&this).name_buf[0..(&this).name_length] = name[]; } } } diff --git a/src/ocean/util/container/btree/BTreeMapRange.d b/src/ocean/util/container/btree/BTreeMapRange.d index 39b54efce..f650fa66b 100644 --- a/src/ocean/util/container/btree/BTreeMapRange.d +++ b/src/ocean/util/container/btree/BTreeMapRange.d @@ -172,7 +172,7 @@ public struct BTreeMapRange(BTreeMap) invariant () { - verify(this.stack !is null); + verify((&this).stack !is null); } @@ -188,8 +188,8 @@ public struct BTreeMapRange(BTreeMap) public KeyValue front () { - this.enforceValid(); - return Pair!(BTreeMap.KeyType, BTreeMap.ValueType)(this.current_key, this.current_value); + (&this).enforceValid(); + return Pair!(BTreeMap.KeyType, BTreeMap.ValueType)((&this).current_key, (&this).current_value); } /*************************************************************************** @@ -203,8 +203,8 @@ public struct BTreeMapRange(BTreeMap) public void popFront () { - this.enforceValid(); - this.iterationStep(); + (&this).enforceValid(); + (&this).iterationStep(); } /*************************************************************************** @@ -219,9 +219,9 @@ public struct BTreeMapRange(BTreeMap) public bool empty () { - this.enforceValid(); - return this.tree.root is null || - (this.item.node is null && this.stack.length == 0); + (&this).enforceValid(); + return (&this).tree.root is null || + ((&this).item.node is null && (&this).stack.length == 0); } /*************************************************************************** @@ -234,7 +234,7 @@ public struct BTreeMapRange(BTreeMap) public bool isValid () { - return tree_version == this.tree.content_version; + return tree_version == (&this).tree.content_version; } /*************************************************************************** @@ -248,7 +248,7 @@ public struct BTreeMapRange(BTreeMap) private void enforceValid () { - if (!this.isValid()) + if (!(&this).isValid()) { throw .range_exception; } @@ -262,11 +262,11 @@ public struct BTreeMapRange(BTreeMap) private void start () { - if (this.tree.root !is null) + if ((&this).tree.root !is null) { - this.tree_version = this.tree.content_version; - this.item = NodeElement(this.tree.root, 0); - this.iterationStep(); + (&this).tree_version = (&this).tree.content_version; + (&this).item = NodeElement((&this).tree.root, 0); + (&this).iterationStep(); } } @@ -280,44 +280,44 @@ public struct BTreeMapRange(BTreeMap) { while (true) { - if (this.item.node.is_leaf) + if ((&this).item.node.is_leaf) { // Leaf doesn't have subtrees, we can just iterate over it - if (this.item.index < this.item.node.number_of_elements) + if ((&this).item.index < (&this).item.node.number_of_elements) { - this.current_value = this.item.value; - this.current_key = this.item.key; - this.item.index++; + (&this).current_value = (&this).item.value; + (&this).current_key = (&this).item.key; + (&this).item.index++; return; } } else { // do we have a subtree in the child_elements[index]? - if (this.item.index <= this.item.node.number_of_elements) + if ((&this).item.index <= (&this).item.node.number_of_elements) { - *this.stack ~= NodeElement(this.item.node, this.item.index); - this.item = NodeElement(item.node.child_nodes[this.item.index], 0); + *(&this).stack ~= NodeElement((&this).item.node, (&this).item.index); + (&this).item = NodeElement(item.node.child_nodes[(&this).item.index], 0); continue; } } - if ((*this.stack).pop(this.item) == false) + if ((*(&this).stack).pop((&this).item) == false) { return; } // We got the item from the stack, and we should see if we // have any more elements to call the delegate on it - if (this.item.index < this.item.node.number_of_elements) + if ((&this).item.index < (&this).item.node.number_of_elements) { - this.current_value = this.item.value; - this.current_key = this.item.key; - this.item.index++; + (&this).current_value = (&this).item.value; + (&this).current_key = (&this).item.key; + (&this).item.index++; return; } // There's no more elements, just skip to the next one - this.item.index++; + (&this).item.index++; } } } diff --git a/src/ocean/util/container/btree/Implementation.d b/src/ocean/util/container/btree/Implementation.d index 27e1a8599..32ec88311 100644 --- a/src/ocean/util/container/btree/Implementation.d +++ b/src/ocean/util/container/btree/Implementation.d @@ -106,7 +106,7 @@ package struct BTreeMapImplementation (KeyType, ValueType, int tree_degree) ***************************************************************************/ - private const degree = tree_degree; + private enum degree = tree_degree; /*************************************************************************** @@ -142,8 +142,8 @@ package struct BTreeMapImplementation (KeyType, ValueType, int tree_degree) package void initialize (IMemManager allocator = mallocMemManager) { - verify (this.allocator is null); - this.allocator = allocator; + verify ((&this).allocator is null); + (&this).allocator = allocator; } @@ -163,14 +163,14 @@ package struct BTreeMapImplementation (KeyType, ValueType, int tree_degree) package ValueType* insert (KeyType key, ValueType el, out bool added) { - verify(this.allocator !is null); + verify((&this).allocator !is null); - if (this.root is null) + if ((&this).root is null) { - this.root = this.insertNewNode(); + (&this).root = (&this).insertNewNode(); } - if (auto ptr = this.get(key)) + if (auto ptr = (&this).get(key)) { return ptr; } @@ -178,30 +178,30 @@ package struct BTreeMapImplementation (KeyType, ValueType, int tree_degree) // unqualed for internal storage only. User will never access it as // unqualed reference. auto unqualed_el = cast(Unqual!(ValueType))el; - auto r = this.root; + auto r = (&this).root; added = true; - if (this.root.number_of_elements == this.root.elements.length) + if ((&this).root.number_of_elements == (&this).root.elements.length) { - auto node = this.insertNewNode(); + auto node = (&this).insertNewNode(); // this is a new root - this.root = node; + (&this).root = node; node.is_leaf = false; node.number_of_elements = 0; // Old root node is the first child node.child_nodes[0] = r; - this.splitChild(node, 0, r); - auto ret = this.insertNonFull(node, key, unqualed_el); - debug (BTreeMapSanity) check_invariants(*this); - this.content_version++; + (&this).splitChild(node, 0, r); + auto ret = (&this).insertNonFull(node, key, unqualed_el); + debug (BTreeMapSanity) check_invariants(*(&this)); + (&this).content_version++; return ret; } else { - auto ret = this.insertNonFull(this.root, key, unqualed_el); - debug (BTreeMapSanity) check_invariants(*this); - this.content_version++; + auto ret = (&this).insertNonFull((&this).root, key, unqualed_el); + debug (BTreeMapSanity) check_invariants(*(&this)); + (&this).content_version++; return ret; } } @@ -221,22 +221,22 @@ package struct BTreeMapImplementation (KeyType, ValueType, int tree_degree) package bool remove (KeyType key) { - verify(this.allocator !is null); + verify((&this).allocator !is null); BTreeMapNode* parent = null; bool rebalance_parent; - auto res = this.deleteFromNode(this.root, + auto res = (&this).deleteFromNode((&this).root, parent, key, rebalance_parent); // can't rebalance the root node here, as they should all be // rebalanced internally by deleteFromNode verify(rebalance_parent == false); - debug (BTreeMapSanity) check_invariants(*this); + debug (BTreeMapSanity) check_invariants(*(&this)); if (res) - this.content_version++; + (&this).content_version++; return res; } @@ -250,7 +250,7 @@ package struct BTreeMapImplementation (KeyType, ValueType, int tree_degree) package bool empty () { - return this.root is null; + return (&this).root is null; } /****************************************************************************** @@ -270,7 +270,7 @@ package struct BTreeMapImplementation (KeyType, ValueType, int tree_degree) package ValueType get (KeyType key, out bool found_element) { size_t index; - auto node = this.get(key, index); + auto node = (&this).get(key, index); if (!node) return ValueType.init; found_element = true; @@ -294,7 +294,7 @@ package struct BTreeMapImplementation (KeyType, ValueType, int tree_degree) { size_t index; - if (auto node = this.get(key, index)) + if (auto node = (&this).get(key, index)) return &node.elements[index].value; else return null; @@ -350,12 +350,12 @@ package struct BTreeMapImplementation (KeyType, ValueType, int tree_degree) return getImpl(root.child_nodes[pos], key, index); } - if (this.root is null) + if ((&this).root is null) { return null; } - return getImpl(this.root, key, index); + return getImpl((&this).root, key, index); } /****************************************************************************** @@ -391,7 +391,7 @@ package struct BTreeMapImplementation (KeyType, ValueType, int tree_degree) node, to_delete, rebalance_parent); if (rebalance_parent) { - this.rebalanceAfterDeletion(node, parent, rebalance_parent); + (&this).rebalanceAfterDeletion(node, parent, rebalance_parent); } return delete_result; @@ -402,7 +402,7 @@ package struct BTreeMapImplementation (KeyType, ValueType, int tree_degree) if (node.is_leaf) { deleteFromLeaf(node, i); - this.rebalanceAfterDeletion(node, parent, rebalance_parent); + (&this).rebalanceAfterDeletion(node, parent, rebalance_parent); return true; } @@ -430,7 +430,7 @@ package struct BTreeMapImplementation (KeyType, ValueType, int tree_degree) // and rebalance the tree starting from that node. if (rebalance_parent) { - this.rebalanceAfterDeletion(node, parent, rebalance_parent); + (&this).rebalanceAfterDeletion(node, parent, rebalance_parent); } return delete_result; } @@ -452,7 +452,7 @@ package struct BTreeMapImplementation (KeyType, ValueType, int tree_degree) if (rebalance_parent) { - this.rebalanceAfterDeletion(node, parent, rebalance_parent); + (&this).rebalanceAfterDeletion(node, parent, rebalance_parent); } return delete_result; @@ -467,7 +467,7 @@ package struct BTreeMapImplementation (KeyType, ValueType, int tree_degree) private BTreeMapNode* insertNewNode() { - auto node = cast(BTreeMapNode*)this.allocator.create(BTreeMapNode.sizeof).ptr; + auto node = cast(BTreeMapNode*)(&this).allocator.create(BTreeMapNode.sizeof).ptr; *node = BTreeMapNode.init; node.is_leaf = true; @@ -550,7 +550,7 @@ package struct BTreeMapImplementation (KeyType, ValueType, int tree_degree) int child_index, BTreeMapNode* child) { - auto new_node = this.insertNewNode(); + auto new_node = (&this).insertNewNode(); // new node is a leaf if old node was new_node.is_leaf = child.is_leaf; moveElementsAt(new_node, 0, child, degree); @@ -584,7 +584,7 @@ package struct BTreeMapImplementation (KeyType, ValueType, int tree_degree) // element from the neighbouring nodes // note that the root is the only node which is allowed to have // more than a minimum elements, so we will never rebalance it - if (node != this.root && node.number_of_elements < this.degree - 1) + if (node != (&this).root && node.number_of_elements < (&this).degree - 1) { long position_in_parent = -1; @@ -613,7 +613,7 @@ package struct BTreeMapImplementation (KeyType, ValueType, int tree_degree) // it has the spare elements, or it does't (in which case // it's merged with the parent - if (next_neighbour && next_neighbour.number_of_elements > this.degree -1) + if (next_neighbour && next_neighbour.number_of_elements > (&this).degree -1) { // copy the separator from the parent node // into the deficient node @@ -640,7 +640,7 @@ package struct BTreeMapImplementation (KeyType, ValueType, int tree_degree) // it has the spare elements, or it does't (in which case // it's merged with the parent - if (previous_neighbour.number_of_elements > this.degree -1) + if (previous_neighbour.number_of_elements > (&this).degree -1) { shiftElements(node, 0, 1); // copy the separator from the parent node @@ -690,7 +690,7 @@ package struct BTreeMapImplementation (KeyType, ValueType, int tree_degree) remaining_node = node; - this.allocator.destroy(cast(ubyte[])(next_neighbour[0..1])); + (&this).allocator.destroy(cast(ubyte[])(next_neighbour[0..1])); } else { @@ -708,17 +708,17 @@ package struct BTreeMapImplementation (KeyType, ValueType, int tree_degree) remaining_node = previous_neighbour; - this.allocator.destroy(cast(ubyte[])((node)[0..1])); + (&this).allocator.destroy(cast(ubyte[])((node)[0..1])); } // TODO: comment this - if (parent == this.root && parent.number_of_elements == 0) + if (parent == (&this).root && parent.number_of_elements == 0) { - this.allocator.destroy(cast(ubyte[])(parent[0..1])); - this.root = remaining_node; + (&this).allocator.destroy(cast(ubyte[])(parent[0..1])); + (&this).root = remaining_node; return; } - else if (parent != this.root && parent.number_of_elements < this.degree - 1) + else if (parent != (&this).root && parent.number_of_elements < (&this).degree - 1) { rebalance_parent = true; return; @@ -947,14 +947,14 @@ package struct BTreeMapImplementation (KeyType, ValueType, int tree_degree) ******************************************************************************/ - package int inorder (int delegate(ref KeyType key, ref ValueType value) dg) + package int inorder (scope int delegate(ref KeyType key, ref ValueType value) dg) { - if (this.root is null) + if ((&this).root is null) { return 0; } - return inorderImpl(this.content_version, *this.root, dg); + return inorderImpl((&this).content_version, *(&this).root, dg); } /****************************************************************************** @@ -971,14 +971,14 @@ package struct BTreeMapImplementation (KeyType, ValueType, int tree_degree) ******************************************************************************/ - package int inorder (int delegate(ref ValueType value) dg) + package int inorder (scope int delegate(ref ValueType value) dg) { - if (this.root is null) + if ((&this).root is null) { return 0; } - return inorderImpl(this.content_version, *this.root, dg); + return inorderImpl((&this).content_version, *(&this).root, dg); } /*************************************************************************** @@ -1025,7 +1025,7 @@ package struct BTreeMapImplementation (KeyType, ValueType, int tree_degree) } // check if the tree is valid - if (start_version != this.content_version) return 1; + if (start_version != (&this).content_version) return 1; if (res) return res; @@ -1065,7 +1065,7 @@ debug (BTreeMapSanity) /// Traverses the BTreeMap in the inorder, starting from root, /// and returns the btree's node. static void traverse (BTreeMap.BTreeMapNode* root, ref int current_height, - void delegate(BTreeMap.BTreeMapNode* b, int current_height) dg) + scope void delegate(BTreeMap.BTreeMapNode* b, int current_height) dg) { for (int i = 0; i < root.number_of_elements; i++) { diff --git a/src/ocean/util/container/cache/Cache.d b/src/ocean/util/container/cache/Cache.d index a602a4616..092941b5d 100644 --- a/src/ocean/util/container/cache/Cache.d +++ b/src/ocean/util/container/cache/Cache.d @@ -300,12 +300,12 @@ class Cache ( size_t ValueSize = 0, bool TrackCreateTimes = false ) : CacheBase! { static if ( is_dynamic ) { - this.value = value; - return &this.value; + (&this).value = value; + return &(&this).value; } else { - return this.value[] = value[]; + return (&this).value[] = value[]; } } @@ -313,14 +313,14 @@ class Cache ( size_t ValueSize = 0, bool TrackCreateTimes = false ) : CacheBase! { ValueRef value_ref ( ) { - return &this.value; + return &(&this).value; } } else { ValueRef value_ref ( ) { - return this.value[]; + return (&this).value[]; } } } @@ -986,7 +986,7 @@ unittest version (all) {{ - const n_records = 33, + static immutable n_records = 33, capacity = 22, n_overflow = 7; @@ -1421,9 +1421,9 @@ debug ( OceanPerformanceTest ) auto random = new Random; - const cache_size = 100_000; + static immutable cache_size = 100_000; - const max_item_size = 1024 * 4; + static immutable max_item_size = 1024 * 4; StopWatch sw; @@ -1447,7 +1447,7 @@ debug ( OceanPerformanceTest ) Stderr.formatln("{} puts, {} puts/s", cache_size, cast(float)cache_size / (cast(float)sw.microsec / 1_000_000)); // Put values into full cache - const puts = 1_000_000; + static immutable puts = 1_000_000; Stderr.formatln("Writing to cache: "); sw.start; for ( uint i; i < puts; i++ ) @@ -1460,7 +1460,7 @@ debug ( OceanPerformanceTest ) Stderr.formatln("{} puts, {} puts/s", puts, cast(float)puts / (cast(float)sw.microsec / 1_000_000)); // Get values from cache - const gets = 1_000_000; + static immutable gets = 1_000_000; Stderr.formatln("Reading from cache: {} gets, {} gets/s", gets, cast(float)gets / (cast(float)sw.microsec / 1_000_000)); sw.start; for ( uint i; i < gets; i++ ) @@ -1500,7 +1500,7 @@ unittest // Test if the whenCacheItemDropped is being called - const max_items = 10; + static immutable max_items = 10; auto item_dropped = false; size_t index = 0; diff --git a/src/ocean/util/container/cache/CachingStructLoader.d b/src/ocean/util/container/cache/CachingStructLoader.d index de62ec4df..30a28d55d 100644 --- a/src/ocean/util/container/cache/CachingStructLoader.d +++ b/src/ocean/util/container/cache/CachingStructLoader.d @@ -80,10 +80,10 @@ class CachingStructLoader ( S ) **********************************************************************/ - static typeof(this) opCall ( void[] data ) + static typeof((&this)) opCall ( void[] data ) { - verify (data.length == typeof(*this).sizeof); - return cast(typeof(this))data.ptr; + verify (data.length == typeof(*(&this)).sizeof); + return cast(typeof((&this)))data.ptr; } } @@ -314,7 +314,7 @@ class CachingStructLoader ( S ) **************************************************************************/ - abstract protected void getData ( hash_t key, void delegate ( Contiguous!(S) data ) got ); + abstract protected void getData ( hash_t key, scope void delegate ( Contiguous!(S) data ) got ); /************************************************************************** diff --git a/src/ocean/util/container/cache/CachingStructLoader_test.d b/src/ocean/util/container/cache/CachingStructLoader_test.d index d24dd96b3..05fcc4a0b 100644 --- a/src/ocean/util/container/cache/CachingStructLoader_test.d +++ b/src/ocean/util/container/cache/CachingStructLoader_test.d @@ -114,7 +114,7 @@ class TestCache(S) : CachingStructLoader!(S) this.add_empty = newval; } - override protected void getData ( hash_t key, void delegate ( Contiguous!(S) data ) got ) + override protected void getData ( hash_t key, scope void delegate ( Contiguous!(S) data ) got ) { auto data = key in this.source; if (data) diff --git a/src/ocean/util/container/cache/ExpiredCacheReloader.d b/src/ocean/util/container/cache/ExpiredCacheReloader.d index 338f117a4..de0a5ab0d 100644 --- a/src/ocean/util/container/cache/ExpiredCacheReloader.d +++ b/src/ocean/util/container/cache/ExpiredCacheReloader.d @@ -80,11 +80,11 @@ class ExpiredCacheReloader ( S ) **********************************************************************/ - static typeof(this) opCall ( void[] data ) + static typeof((&this)) opCall ( void[] data ) { - verify (data.length == typeof(*this).sizeof); + verify (data.length == typeof(*(&this)).sizeof); - return cast(typeof(this))data.ptr; + return cast(typeof((&this)))data.ptr; } } @@ -316,7 +316,7 @@ class ExpiredCacheReloader ( S ) **************************************************************************/ - abstract protected void getData ( hash_t key, void delegate ( Contiguous!(S) data ) got ); + abstract protected void getData ( hash_t key, scope void delegate ( Contiguous!(S) data ) got ); /************************************************************************** diff --git a/src/ocean/util/container/cache/ExpiredCacheReloader_test.d b/src/ocean/util/container/cache/ExpiredCacheReloader_test.d index 327180bf9..39addb3eb 100644 --- a/src/ocean/util/container/cache/ExpiredCacheReloader_test.d +++ b/src/ocean/util/container/cache/ExpiredCacheReloader_test.d @@ -109,7 +109,7 @@ class TestCache(S) : ExpiredCacheReloader!(S) this.add_empty = newval; } - override protected void getData ( hash_t key, void delegate ( Contiguous!(S) data ) got ) + override protected void getData ( hash_t key, scope void delegate ( Contiguous!(S) data ) got ) { auto data = key in this.source; if (data) diff --git a/src/ocean/util/container/cache/LRUCache_test.d b/src/ocean/util/container/cache/LRUCache_test.d index 8f248b0c1..befdc272e 100644 --- a/src/ocean/util/container/cache/LRUCache_test.d +++ b/src/ocean/util/container/cache/LRUCache_test.d @@ -47,7 +47,7 @@ unittest // Test of static sized cache { - const n_records = 33, + static immutable n_records = 33, capacity = 22, n_overflow = 7; @@ -354,7 +354,7 @@ unittest } // Test if the whenCacheItemDropped is being called - const max_items = 10; + static immutable max_items = 10; auto item_dropped = false; size_t index = 0; @@ -507,9 +507,9 @@ unittest auto random = new Random; - const cache_size = 100_000; + static immutable cache_size = 100_000; - const max_item_size = 1024 * 4; + static immutable max_item_size = 1024 * 4; StopWatch sw; @@ -538,7 +538,7 @@ unittest printf("%d puts, %f puts/s\n".ptr, cache_size, cast(float)cache_size / (cast(float)sw.microsec / 1_000_000)); // Put values into full cache - const puts = 1_000_000; + static immutable puts = 1_000_000; printf("Writing to cache:\n".ptr); sw.start; for ( uint i; i < puts; i++ ) @@ -551,7 +551,7 @@ unittest printf("%d puts, %f puts/s\n".ptr, puts, cast(float)puts / (cast(float)sw.microsec / 1_000_000)); // Get values from cache - const gets = 1_000_000; + static immutable gets = 1_000_000; printf("Reading from cache: %d gets, %f gets/s\n".ptr, gets, cast(float)gets / (cast(float)sw.microsec / 1_000_000)); sw.start; for ( uint i; i < gets; i++ ) diff --git a/src/ocean/util/container/cache/PriorityCache.d b/src/ocean/util/container/cache/PriorityCache.d index 917f20bc4..f5722f80a 100644 --- a/src/ocean/util/container/cache/PriorityCache.d +++ b/src/ocean/util/container/cache/PriorityCache.d @@ -510,7 +510,7 @@ class PriorityCache(T) : ICacheInfo ***************************************************************************/ - public int opApply ( ForeachDg dg ) + public int opApply ( scope ForeachDg dg ) { int ret = 0; @@ -547,7 +547,7 @@ class PriorityCache(T) : ICacheInfo ***************************************************************************/ - public int opApplyReverse ( ForeachDg dg ) + public int opApplyReverse ( scope ForeachDg dg ) { int ret = 0; @@ -1006,7 +1006,7 @@ unittest { auto t = new NamedTest("Documentation example"); - const NUM_ITEM = 10; + static immutable NUM_ITEM = 10; auto cache = new PriorityCache!(char[])(NUM_ITEM); auto key = 1; @@ -1050,12 +1050,12 @@ unittest { auto t = new NamedTest("Adding and removing items to the cache"); - const NUM_OF_ITEMS = 150; + static immutable NUM_OF_ITEMS = 150; auto test_cache = new PriorityCache!(int)(NUM_OF_ITEMS); - const PRIORITY = 10; - const VALUE = 50; + static immutable PRIORITY = 10; + static immutable VALUE = 50; for (int i = 0; i < NUM_OF_ITEMS; i++) { @@ -1078,12 +1078,12 @@ unittest { auto t = new NamedTest("Retrieving highest and lowest priority items"); - const NUM_OF_ITEMS = 150; + static immutable NUM_OF_ITEMS = 150; auto test_cache = new PriorityCache!(int)(NUM_OF_ITEMS); - const PRIORITY = 10; - const VALUE = 50; + static immutable PRIORITY = 10; + static immutable VALUE = 50; bool existed; hash_t key; @@ -1116,13 +1116,13 @@ unittest { auto t = new NamedTest("Clearing the cache"); - const NUM_OF_ITEMS = 150; + static immutable NUM_OF_ITEMS = 150; auto test_cache = new PriorityCache!(int)(NUM_OF_ITEMS); - const VALUE = 50; - const PRIORITY = 8; - const INDEX = 20; + static immutable VALUE = 50; + static immutable PRIORITY = 8; + static immutable INDEX = 20; // Create some items for (int i = 0; i < NUM_OF_ITEMS; i++) @@ -1147,13 +1147,13 @@ unittest { auto t = new NamedTest("opApply foreach loops"); - const NUM_OF_ITEMS = 150; + static immutable NUM_OF_ITEMS = 150; auto test_cache = new PriorityCache!(int)(NUM_OF_ITEMS); - const PRIORITY = 10; - const ORIGINAL_VALUE = 50; - const NEW_VALUE = 80; + static immutable PRIORITY = 10; + static immutable ORIGINAL_VALUE = 50; + static immutable NEW_VALUE = 80; for (int i = 0; i < NUM_OF_ITEMS; i++) { @@ -1202,8 +1202,8 @@ unittest { auto t = new NamedTest("Dropped items are correctly reported"); - const CACHE_SIZE = 10; - const ITEMS_INSERTED = 150; + static immutable CACHE_SIZE = 10; + static immutable ITEMS_INSERTED = 150; uint items_removed_count; @@ -1239,7 +1239,7 @@ unittest { auto t = new NamedTest("Dropped items are passed by ref to notifier"); - const CACHE_SIZE = 10; + static immutable CACHE_SIZE = 10; bool item_dropped = false; class PriorityNotify2 : PriorityCache!(uint) diff --git a/src/ocean/util/container/cache/model/Value.d b/src/ocean/util/container/cache/model/Value.d index d39e94b09..5f32c841e 100644 --- a/src/ocean/util/container/cache/model/Value.d +++ b/src/ocean/util/container/cache/model/Value.d @@ -40,7 +40,7 @@ template Value ( size_t ValueSize ) ***************************************************************************/ - const is_dynamic = !ValueSize; + static immutable is_dynamic = !ValueSize; static if (is_dynamic) { @@ -71,7 +71,7 @@ template Value ( size_t ValueSize ) public void[] opAssign ( void[] val ) { - return this.array = val; + return (&this).array = val; } /******************************************************************* @@ -91,16 +91,16 @@ template Value ( size_t ValueSize ) public void[] opSliceAssign ( void[] val ) { - if (this.array is null) + if ((&this).array is null) { - this.array = new ubyte[val.length]; + (&this).array = new ubyte[val.length]; } else { - this.array.length = val.length; + (&this).array.length = val.length; } - return this.array[] = val[]; + return (&this).array[] = val[]; } /******************************************************************* @@ -112,7 +112,7 @@ template Value ( size_t ValueSize ) public void[] opSlice ( ) { - return this.array; + return (&this).array; } /******************************************************************* @@ -128,7 +128,7 @@ template Value ( size_t ValueSize ) public void[]* opCast ( ) { - return &this.array; + return &(&this).array; } /******************************************************************* @@ -140,7 +140,7 @@ template Value ( size_t ValueSize ) public size_t length ( ) { - return this.array.length; + return (&this).array.length; } } diff --git a/src/ocean/util/container/cache/model/containers/TimeToIndex.d b/src/ocean/util/container/cache/model/containers/TimeToIndex.d index e056248c6..f4e09e6e6 100644 --- a/src/ocean/util/container/cache/model/containers/TimeToIndex.d +++ b/src/ocean/util/container/cache/model/containers/TimeToIndex.d @@ -55,9 +55,9 @@ class TimeToIndex: EBTree128!() /**********************************************************************/ - static assert(typeof(*this).sizeof % 16 == 0, - typeof(*this).stringof ~ ".sizeof must be an integer " - ~ "multiple of 16, not " ~ typeof(*(&this)).sizeof.stringof); + static assert(typeof(*(&this)).sizeof % 16 == 0, + typeof(*(&this)).stringof ~ ".sizeof must be an integer " + ~ "multiple of 16, not " ~ typeof(*(&(&this))).sizeof.stringof); } /**************************************************************************/ diff --git a/src/ocean/util/container/ebtree/EBTree128.d b/src/ocean/util/container/ebtree/EBTree128.d index dff0f3720..72d31d178 100644 --- a/src/ocean/util/container/ebtree/EBTree128.d +++ b/src/ocean/util/container/ebtree/EBTree128.d @@ -54,7 +54,7 @@ class EBTree128 ( bool signed = false ) : IEBTree **************************************************************************/ - public const signed_key = signed; + public static immutable signed_key = signed; /************************************************************************** @@ -71,7 +71,7 @@ class EBTree128 ( bool signed = false ) : IEBTree **********************************************************************/ - public const is_signed = signed; + public enum is_signed = signed; /********************************************************************** @@ -124,7 +124,7 @@ class EBTree128 ( bool signed = false ) : IEBTree public equals_t opEquals(Key rhs) { - return this.opCmp(rhs) == 0; + return (&this).opCmp(rhs) == 0; } } diff --git a/src/ocean/util/container/ebtree/EBTree32.d b/src/ocean/util/container/ebtree/EBTree32.d index 2d015c199..7b1777c49 100644 --- a/src/ocean/util/container/ebtree/EBTree32.d +++ b/src/ocean/util/container/ebtree/EBTree32.d @@ -84,7 +84,7 @@ class EBTree32 ( bool signed = false ) : IEBTree **************************************************************************/ - public const signed_key = signed; + public static immutable signed_key = signed; /************************************************************************** @@ -117,7 +117,7 @@ class EBTree32 ( bool signed = false ) : IEBTree **********************************************************************/ - public const is_signed = signed; + public enum is_signed = signed; /********************************************************************** @@ -174,7 +174,7 @@ class EBTree32 ( bool signed = false ) : IEBTree private EBTree32!(signed).Key opCast ( ) { - return ((cast (int) this.hi) << 0x10) | this.lo; + return ((cast (int) (&this).hi) << 0x10) | (&this).lo; } } @@ -229,7 +229,7 @@ class EBTree32 ( bool signed = false ) : IEBTree **************************************************************************/ - private const INodePool node_pool; + private static immutable INodePool node_pool; /************************************************************************** diff --git a/src/ocean/util/container/ebtree/EBTree64.d b/src/ocean/util/container/ebtree/EBTree64.d index 1b8b46539..234aab762 100644 --- a/src/ocean/util/container/ebtree/EBTree64.d +++ b/src/ocean/util/container/ebtree/EBTree64.d @@ -84,7 +84,7 @@ class EBTree64 ( bool signed = false ) : IEBTree **************************************************************************/ - public const signed_key = signed; + public static immutable signed_key = signed; /************************************************************************** @@ -116,7 +116,7 @@ class EBTree64 ( bool signed = false ) : IEBTree **********************************************************************/ - public const is_signed = signed; + public enum is_signed = signed; /********************************************************************** @@ -164,7 +164,7 @@ class EBTree64 ( bool signed = false ) : IEBTree public equals_t opEquals(Dual32Key rhs) { - return this.opCmp(rhs) == 0; + return (&this).opCmp(rhs) == 0; } /********************************************************************** @@ -178,7 +178,7 @@ class EBTree64 ( bool signed = false ) : IEBTree private EBTree64!(signed).Key opCast ( ) { - return ((cast (long) this.hi) << 0x20) | this.lo; + return ((cast (long) (&this).hi) << 0x20) | (&this).lo; } } diff --git a/src/ocean/util/container/ebtree/c/eb128tree.d b/src/ocean/util/container/ebtree/c/eb128tree.d index 393f6b713..057b394f5 100644 --- a/src/ocean/util/container/ebtree/c/eb128tree.d +++ b/src/ocean/util/container/ebtree/c/eb128tree.d @@ -78,7 +78,7 @@ struct UCent public equals_t opEquals(UCent rhs) { - return this.opCmp(rhs) == 0; + return (&this).opCmp(rhs) == 0; } } @@ -120,7 +120,7 @@ struct Cent public equals_t opEquals(Cent rhs) { - return this.opCmp(rhs) == 0; + return (&this).opCmp(rhs) == 0; } } @@ -162,7 +162,7 @@ struct eb128_node UCent key ( ) ( UCent key_ ) { - eb128_node_setkey_264(this, key_.lo, key_.hi); + eb128_node_setkey_264((&this), key_.lo, key_.hi); return key_; } @@ -175,7 +175,7 @@ struct eb128_node Cent key ( ) ( Cent key_ ) { - eb128i_node_setkey_264(this, key_.lo, key_.hi); + eb128i_node_setkey_264((&this), key_.lo, key_.hi); return key_; } @@ -198,13 +198,13 @@ struct eb128_node { Cent result; - eb128i_node_getkey_264(this, &result.lo, &result.hi); + eb128i_node_getkey_264((&this), &result.lo, &result.hi); } else { UCent result; - eb128_node_getkey_264(this, &result.lo, &result.hi); + eb128_node_getkey_264((&this), &result.lo, &result.hi); } return result; @@ -212,30 +212,30 @@ struct eb128_node /// Return next node in the tree, skipping duplicates, or NULL if none - typeof (this) next ( ) + typeof ((&this)) next ( ) { - return eb128_next(this); + return eb128_next((&this)); } /// Return previous node in the tree, or NULL if none - typeof (this) prev ( ) + typeof ((&this)) prev ( ) { - return eb128_prev(this); + return eb128_prev((&this)); } /// Return next node in the tree, skipping duplicates, or NULL if none - typeof (this) next_unique ( ) + typeof ((&this)) next_unique ( ) { - return eb128_next_unique(this); + return eb128_next_unique((&this)); } /// Return previous node in the tree, skipping duplicates, or NULL if none - typeof (this) prev_unique ( ) + typeof ((&this)) prev_unique ( ) { - return eb128_prev_unique(this); + return eb128_prev_unique((&this)); } } diff --git a/src/ocean/util/container/ebtree/c/eb32tree.d b/src/ocean/util/container/ebtree/c/eb32tree.d index cbcc00929..4393df440 100644 --- a/src/ocean/util/container/ebtree/c/eb32tree.d +++ b/src/ocean/util/container/ebtree/c/eb32tree.d @@ -34,30 +34,30 @@ struct eb32_node /// Return next node in the tree, skipping duplicates, or NULL if none - typeof (this) next ( ) + typeof ((&this)) next ( ) { - return eb32_next(this); + return eb32_next((&this)); } /// Return previous node in the tree, or NULL if none - typeof (this) prev ( ) + typeof ((&this)) prev ( ) { - return eb32_prev(this); + return eb32_prev((&this)); } /// Return next node in the tree, skipping duplicates, or NULL if none - typeof (this) next_unique ( ) + typeof ((&this)) next_unique ( ) { - return eb32_next_unique(this); + return eb32_next_unique((&this)); } /// Return previous node in the tree, skipping duplicates, or NULL if none - typeof (this) prev_unique ( ) + typeof ((&this)) prev_unique ( ) { - return eb32_prev_unique(this); + return eb32_prev_unique((&this)); } } diff --git a/src/ocean/util/container/ebtree/c/eb64tree.d b/src/ocean/util/container/ebtree/c/eb64tree.d index 6cd302643..2015c178a 100644 --- a/src/ocean/util/container/ebtree/c/eb64tree.d +++ b/src/ocean/util/container/ebtree/c/eb64tree.d @@ -34,30 +34,30 @@ struct eb64_node /// Return next node in the tree, skipping duplicates, or NULL if none - typeof (this) next ( ) + typeof ((&this)) next ( ) { - return eb64_next(this); + return eb64_next((&this)); } /// Return previous node in the tree, or NULL if none - typeof (this) prev ( ) + typeof ((&this)) prev ( ) { - return eb64_prev(this); + return eb64_prev((&this)); } /// Return next node in the tree, skipping duplicates, or NULL if none - typeof (this) next_unique ( ) + typeof ((&this)) next_unique ( ) { - return eb64_next_unique(this); + return eb64_next_unique((&this)); } /// Return previous node in the tree, skipping duplicates, or NULL if none - typeof (this) prev_unique ( ) + typeof ((&this)) prev_unique ( ) { - return eb64_prev_unique(this); + return eb64_prev_unique((&this)); } } diff --git a/src/ocean/util/container/ebtree/c/ebtree.d b/src/ocean/util/container/ebtree/c/ebtree.d index 22dd7422e..a914a4690 100644 --- a/src/ocean/util/container/ebtree/c/ebtree.d +++ b/src/ocean/util/container/ebtree/c/ebtree.d @@ -35,18 +35,18 @@ alias void eb_troot_t; /// See original's library documentation for details. struct eb_root { - const BITS = 1; - const BRANCHES = (1 << BITS); + enum BITS = 1; + enum BRANCHES = (1 << BITS); - const RGHT = 1; - const NORMAL = cast(eb_troot_t*)0; - const UNIQUE = cast(eb_troot_t*)1; + enum RGHT = 1; + enum NORMAL = cast(eb_troot_t*)0; + enum UNIQUE = cast(eb_troot_t*)1; eb_troot_t*[BRANCHES] b; bool is_empty ( ) { - return !!eb_is_empty(this); + return !!eb_is_empty((&this)); } /*************************************************************************** @@ -62,7 +62,7 @@ struct eb_root bool unique ( ) { - return this.b[RGHT] is UNIQUE; + return (&this).b[RGHT] is UNIQUE; } /*************************************************************************** @@ -84,7 +84,7 @@ struct eb_root bool unique ( bool enable ) { - this.b[RGHT] = enable? UNIQUE : NORMAL; + (&this).b[RGHT] = enable? UNIQUE : NORMAL; return enable; } } @@ -102,29 +102,29 @@ struct eb_node alias .eb_last last; - typeof (this) prev( ) + typeof ((&this)) prev( ) { - return eb_prev(this); + return eb_prev((&this)); } - typeof (this) next ( ) + typeof ((&this)) next ( ) { - return eb_next(this); + return eb_next((&this)); } - typeof (this) prev_unique ( ) + typeof ((&this)) prev_unique ( ) { - return eb_prev_unique(this); + return eb_prev_unique((&this)); } - typeof (this) next_unique ( ) + typeof ((&this)) next_unique ( ) { - return eb_next_unique(this); + return eb_next_unique((&this)); } void remove ( ) { - eb_delete(this); + eb_delete((&this)); } }; diff --git a/src/ocean/util/container/ebtree/model/Iterators.d b/src/ocean/util/container/ebtree/model/Iterators.d index 95fa3f474..945007dfc 100644 --- a/src/ocean/util/container/ebtree/model/Iterators.d +++ b/src/ocean/util/container/ebtree/model/Iterators.d @@ -71,7 +71,7 @@ template Iterators ( Node ) ***********************************************************************/ - public int opApply ( int delegate ( ref Node node ) dg ) + public int opApply ( scope int delegate ( ref Node node ) dg ) { int ret = 0; @@ -91,7 +91,7 @@ template Iterators ( Node ) ***************************************************************************/ - public int opApplyReverse ( int delegate ( ref Node node ) dg ) + public int opApplyReverse ( scope int delegate ( ref Node node ) dg ) { int ret = 0; diff --git a/src/ocean/util/container/ebtree/model/KeylessMethods.d b/src/ocean/util/container/ebtree/model/KeylessMethods.d index dfd706f3d..06c00d1c2 100644 --- a/src/ocean/util/container/ebtree/model/KeylessMethods.d +++ b/src/ocean/util/container/ebtree/model/KeylessMethods.d @@ -110,7 +110,7 @@ template KeylessMethods ( Node, alias eb_first, alias eb_last ) ***************************************************************************/ - public int opApply ( int delegate ( ref Node node ) dg ) + public int opApply ( scope int delegate ( ref Node node ) dg ) { int ret = 0; @@ -129,7 +129,7 @@ template KeylessMethods ( Node, alias eb_first, alias eb_last ) ***************************************************************************/ - public int opApply_reverse ( int delegate ( ref Node node ) dg ) + public int opApply_reverse ( scope int delegate ( ref Node node ) dg ) { int ret = 0; diff --git a/src/ocean/util/container/ebtree/model/Node.d b/src/ocean/util/container/ebtree/model/Node.d index 7302c8bf2..27de2a48b 100644 --- a/src/ocean/util/container/ebtree/model/Node.d +++ b/src/ocean/util/container/ebtree/model/Node.d @@ -63,7 +63,7 @@ struct Node ( eb_node, Key, alias eb_getkey, alias eb_next, alias eb_prev, // TODO: Check if this works with signed keys. // return this.node_.key_; - return eb_getkey(&this.node_); + return eb_getkey(&(&this).node_); } /************************************************************************** @@ -75,9 +75,9 @@ struct Node ( eb_node, Key, alias eb_getkey, alias eb_next, alias eb_prev, **************************************************************************/ - public typeof (this) next ( ) + public typeof ((&this)) next ( ) { - return this.ebCall!(eb_next); + return (&this).ebCall!(eb_next); } /************************************************************************** @@ -89,9 +89,9 @@ struct Node ( eb_node, Key, alias eb_getkey, alias eb_next, alias eb_prev, **************************************************************************/ - public typeof (this) prev ( ) + public typeof ((&this)) prev ( ) { - return this.ebCall!(eb_prev); + return (&this).ebCall!(eb_prev); } /************************************************************************** @@ -104,9 +104,9 @@ struct Node ( eb_node, Key, alias eb_getkey, alias eb_next, alias eb_prev, **************************************************************************/ - public typeof (this) next_unique ( ) + public typeof ((&this)) next_unique ( ) { - return this.ebCall!(eb_next_unique); + return (&this).ebCall!(eb_next_unique); } /************************************************************************** @@ -120,9 +120,9 @@ struct Node ( eb_node, Key, alias eb_getkey, alias eb_next, alias eb_prev, **************************************************************************/ - public typeof (this) prev_unique ( ) + public typeof ((&this)) prev_unique ( ) { - return this.ebCall!(eb_prev_unique); + return (&this).ebCall!(eb_prev_unique); } /************************************************************************** @@ -134,11 +134,11 @@ struct Node ( eb_node, Key, alias eb_getkey, alias eb_next, alias eb_prev, **************************************************************************/ - private typeof (this) remove ( ) + private typeof ((&this)) remove ( ) { - eb_delete(&this.node_); + eb_delete(&(&this).node_); - return this; + return (&this); } /************************************************************************** @@ -154,11 +154,11 @@ struct Node ( eb_node, Key, alias eb_getkey, alias eb_next, alias eb_prev, **************************************************************************/ - private typeof (this) ebCall ( alias eb_func ) ( ) + private typeof ((&this)) ebCall ( alias eb_func ) ( ) { - static assert (is (typeof (eb_func(&this.node_)) == eb_node*)); + static assert (is (typeof (eb_func(&(&this).node_)) == eb_node*)); - return cast (typeof (this)) eb_func(&this.node_); + return cast (typeof ((&this))) eb_func(&(&this).node_); } } diff --git a/src/ocean/util/container/map/HashMap.d b/src/ocean/util/container/map/HashMap.d index 40a3cadf2..c8154853f 100644 --- a/src/ocean/util/container/map/HashMap.d +++ b/src/ocean/util/container/map/HashMap.d @@ -416,7 +416,7 @@ unittest unittest { // Unittest that serves as a usage example - const expected_number_of_elements = 1_000; + static immutable expected_number_of_elements = 1_000; // Mapping from hash_t -> int auto map = new HashMap!(int)(expected_number_of_elements); diff --git a/src/ocean/util/container/map/Map.d b/src/ocean/util/container/map/Map.d index 3381aa680..0c4760949 100644 --- a/src/ocean/util/container/map/Map.d +++ b/src/ocean/util/container/map/Map.d @@ -312,19 +312,19 @@ public abstract class Map ( V, K ) : BucketSet!(V.sizeof, K) "in ", __FILE__, ":", __LINE__.stringof); } - const V_is_static_array = true; + static immutable V_is_static_array = true; alias Base[] VReturn; - const Base[V.length] v_init = Base.init; + static immutable Base[V.length] v_init = Base.init; } else { - const V_is_static_array = false; + static immutable V_is_static_array = false; alias V VReturn; - const v_init = V.init; + static immutable v_init = V.init; } /*************************************************************************** @@ -635,7 +635,7 @@ public abstract class Map ( V, K ) : BucketSet!(V.sizeof, K) ***************************************************************************/ - public bool remove ( K key, void delegate ( ref V val ) dg = null ) + public bool remove ( K key, scope void delegate ( ref V val ) dg = null ) { scope dg2 = (ref Bucket.Element element) { diff --git a/src/ocean/util/container/map/TreeMap.d b/src/ocean/util/container/map/TreeMap.d index 082af247b..c3d2fd5e3 100644 --- a/src/ocean/util/container/map/TreeMap.d +++ b/src/ocean/util/container/map/TreeMap.d @@ -85,7 +85,7 @@ struct TreeMap ( T ) public bool is_empty ( ) // const { - return this.root.is_empty(); + return (&this).root.is_empty(); } /*************************************************************************** @@ -100,8 +100,8 @@ struct TreeMap ( T ) public void reinit ( ) { - this.root = eb_root.init; - this.root.unique = true; + (&this).root = eb_root.init; + (&this).root.unique = true; } /*************************************************************************** @@ -123,7 +123,7 @@ struct TreeMap ( T ) public T* put ( ulong key, out bool added ) { - return &(this.put_(key, added).value); + return &((&this).put_(key, added).value); } /*********************************************************************** @@ -140,7 +140,7 @@ struct TreeMap ( T ) private T* opIn_r ( ulong key ) { - return &((cast(Node*)eb64_lookup(&this.root, key)).value); + return &((cast(Node*)eb64_lookup(&(&this).root, key)).value); } /*********************************************************************** @@ -154,7 +154,7 @@ struct TreeMap ( T ) public T* first () { - return this.getBoundary!(true)(); + return (&this).getBoundary!(true)(); } /*********************************************************************** @@ -168,7 +168,7 @@ struct TreeMap ( T ) public T* last () { - return this.getBoundary!(false)(); + return (&this).getBoundary!(false)(); } /*********************************************************************** @@ -178,11 +178,11 @@ struct TreeMap ( T ) ***********************************************************************/ - public int opApply ( int delegate ( ref ulong key, ref T* value ) dg ) + public int opApply ( scope int delegate ( ref ulong key, ref T* value ) dg ) { int stop = 0; - for (auto eb_node = eb64_first(&this.root); eb_node && !stop;) + for (auto eb_node = eb64_first(&(&this).root); eb_node && !stop;) { // Backup node.next here because dg() may change or delete node! auto next = eb_node.next; @@ -214,9 +214,9 @@ struct TreeMap ( T ) public bool remove ( ulong key ) { - if (auto node = this.nodeForKey(key)) + if (auto node = (&this).nodeForKey(key)) { - this.remove_(*node); + (&this).remove_(*node); return true; } else @@ -266,7 +266,7 @@ struct TreeMap ( T ) else alias eb64_last eb64_function; - return &((cast(Node*)eb64_function(&this.root)).value); + return &((cast(Node*)eb64_function(&(&this).root)).value); } /*********************************************************************** @@ -283,7 +283,7 @@ struct TreeMap ( T ) private Node* nodeForKey ( ulong key ) { - return cast(Node*)eb64_lookup(&this.root, key); + return cast(Node*)eb64_lookup(&(&this).root, key); } /*************************************************************************** @@ -313,7 +313,7 @@ struct TreeMap ( T ) eb64_node* ebnode = &node.tupleof[0]; ebnode.key = key; - eb64_node* added_ebnode = eb64_insert(&this.root, ebnode); + eb64_node* added_ebnode = eb64_insert(&(&this).root, ebnode); added = added_ebnode is ebnode; if (!added) @@ -359,9 +359,9 @@ struct TreeMap ( T ) Node* allocate ( ) { - if (auto node = this.spare) + if (auto node = (&this).spare) { - this.spare = null; + (&this).spare = null; return node; } @@ -372,7 +372,7 @@ struct TreeMap ( T ) } else { - const istring msg = "malloc(" ~ Node.sizeof.stringof ~ + enum istring msg = "malloc(" ~ Node.sizeof.stringof ~ ") failed: Out of memory\n\0"; fputs(msg.ptr, stderr); exit(EXIT_FAILURE); @@ -392,10 +392,10 @@ struct TreeMap ( T ) void deallocate ( Node* node ) { - if (this.spare is null) + if ((&this).spare is null) { *node = (*node).init; - this.spare = node; + (&this).spare = node; } else { @@ -476,7 +476,7 @@ unittest *******************************************************************************/ -private const eb_root empty_unique_ebtroot = +private static immutable eb_root empty_unique_ebtroot = function ( ) { eb_root root; diff --git a/src/ocean/util/container/map/model/Bucket.d b/src/ocean/util/container/map/model/Bucket.d index 9876c0aa8..5cbb9c48d 100644 --- a/src/ocean/util/container/map/model/Bucket.d +++ b/src/ocean/util/container/map/model/Bucket.d @@ -160,7 +160,7 @@ public struct Bucket ( size_t V, K = hash_t ) public bool has_element ( ) { - return this.first !is null; + return (&this).first !is null; } /************************************************************************** @@ -181,13 +181,13 @@ public struct Bucket ( size_t V, K = hash_t ) debug (HostingArrayMapBucket) if (element) { assert (element.bucket, "bucket not set in found element"); - assert (element.bucket is this, + assert (element.bucket is (&this), "element found is not from this bucket"); } } body { - for (Element* element = this.first; element; element = element.next) + for (Element* element = (&this).first; element; element = element.next) { if (element.key == key) { @@ -226,11 +226,11 @@ public struct Bucket ( size_t V, K = hash_t ) } body { - Element* element = this.find(key); + Element* element = (&this).find(key); if (!element) { - element = this.add(new_element); + element = (&this).add(new_element); static if (isArrayType!(K) == ArrayKind.Static) { @@ -263,7 +263,7 @@ public struct Bucket ( size_t V, K = hash_t ) public Element* add ( Element* element ) in { - debug (HostingArrayMapBucket) element.bucket = this; + debug (HostingArrayMapBucket) element.bucket = (&this); } out { @@ -271,7 +271,7 @@ public struct Bucket ( size_t V, K = hash_t ) { // Check for cyclic links using 2 pointers, one which traverse // twice as fast as the first one - auto ptr1 = this.first; + auto ptr1 = (&this).first; auto ptr2 = ptr1; // Find meeting point @@ -289,8 +289,8 @@ public struct Bucket ( size_t V, K = hash_t ) } body { - element.next = this.first; - this.first = element; + element.next = (&this).first; + (&this).first = element; return element; } @@ -319,7 +319,7 @@ public struct Bucket ( size_t V, K = hash_t ) debug (HostingArrayMapBucket) if (removed) { - assert (removed.bucket is this, + assert (removed.bucket is (&this), "element to remove is not from this bucket"); removed.bucket = null; @@ -328,22 +328,22 @@ public struct Bucket ( size_t V, K = hash_t ) } body { - if (this.first !is null) + if ((&this).first !is null) { - if (this.first.key == key) + if ((&this).first.key == key) { - Element* removed = this.first; + Element* removed = (&this).first; - this.first = this.first.next; + (&this).first = (&this).first.next; removed.next = null; return removed; } else { - Element* element = this.first.next; + Element* element = (&this).first.next; - for (Element* prev = this.first; element;) + for (Element* prev = (&this).first; element;) { if (element.key == key) { @@ -411,17 +411,17 @@ char[] alignForSize(E...)(string[] names...) } unittest { - const x = alignForSize!(int[], char[3], short, double[5])("x", "y","z", "w"); + static immutable x = alignForSize!(int[], char[3], short, double[5])("x", "y","z", "w"); struct Foo{ int x; } - const y = alignForSize!(ubyte, Foo, cdouble)("x", "y","z"); + static immutable y = alignForSize!(ubyte, Foo, cdouble)("x", "y","z"); static if(size_t.sizeof == uint.sizeof) { - const passNormalX = x == "double[5u] w;\nint[] x;\nshort z;\nchar[3u] y;\n"; - const passNormalY = y == "cdouble z;\nFoo y;\nubyte x;\n"; + static immutable passNormalX = x == "double[5u] w;\nint[] x;\nshort z;\nchar[3u] y;\n"; + static immutable passNormalY = y == "cdouble z;\nFoo y;\nubyte x;\n"; - const passAbnormalX = x == "int[] x;\ndouble[5u] w;\nshort z;\nchar[3u] y;\n"; - const passAbnormalY = y == "Foo y;\ncdouble z;\nubyte x;\n"; + static immutable passAbnormalX = x == "int[] x;\ndouble[5u] w;\nshort z;\nchar[3u] y;\n"; + static immutable passAbnormalY = y == "Foo y;\ncdouble z;\nubyte x;\n"; // ^ blame http://d.puremagic.com/issues/show_bug.cgi?id=231 static assert(passNormalX || double.alignof <= (int[]).alignof && passAbnormalX); diff --git a/src/ocean/util/container/map/model/BucketElementFreeList.d b/src/ocean/util/container/map/model/BucketElementFreeList.d index cd608eff5..3a75408da 100644 --- a/src/ocean/util/container/map/model/BucketElementFreeList.d +++ b/src/ocean/util/container/map/model/BucketElementFreeList.d @@ -354,7 +354,7 @@ abstract class IBucketElementFreeList: IAllocator ***************************************************************************/ public override void parkElements (size_t n, - void delegate ( IParkingStack park ) dg) + scope void delegate ( IParkingStack park ) dg) { scope parking_stack = this.new ParkingStack(n); diff --git a/src/ocean/util/container/map/model/BucketElementMallocAllocator.d b/src/ocean/util/container/map/model/BucketElementMallocAllocator.d index 5cb468b70..639b8a627 100644 --- a/src/ocean/util/container/map/model/BucketElementMallocAllocator.d +++ b/src/ocean/util/container/map/model/BucketElementMallocAllocator.d @@ -319,7 +319,7 @@ public class BucketElementMallocAllocator (Bucket) : IAllocator ***************************************************************************/ public override void parkElements (size_t n, - void delegate ( IParkingStack park ) dg) + scope void delegate ( IParkingStack park ) dg) { scope park = new ParkingStack(n); dg(park); diff --git a/src/ocean/util/container/map/model/BucketInfo.d b/src/ocean/util/container/map/model/BucketInfo.d index 636f27ab7..0fbbf46fa 100644 --- a/src/ocean/util/container/map/model/BucketInfo.d +++ b/src/ocean/util/container/map/model/BucketInfo.d @@ -67,14 +67,14 @@ class BucketInfo public equals_t opEquals (Bucket rhs) { - return this.opCmp(rhs) == 0; + return (&this).opCmp(rhs) == 0; } /**********************************************************************/ debug (BucketInfo) private void print ( ) { - Stderr.format(" {,2}/{,2}", this.index, this.length); + Stderr.format(" {,2}/{,2}", (&this).index, (&this).length); } } diff --git a/src/ocean/util/container/map/model/BucketSet.d b/src/ocean/util/container/map/model/BucketSet.d index 4a06da85f..3dd0edc97 100644 --- a/src/ocean/util/container/map/model/BucketSet.d +++ b/src/ocean/util/container/map/model/BucketSet.d @@ -523,7 +523,7 @@ public abstract class BucketSet ( size_t V, K = hash_t ) : IBucketSet ***************************************************************************/ - final protected bool remove_ ( K key, void delegate ( ref Bucket.Element element ) dg = null ) + final protected bool remove_ ( K key, scope void delegate ( ref Bucket.Element element ) dg = null ) { size_t bucket_index = this.toHash(key) & this.bucket_mask; @@ -799,7 +799,7 @@ public abstract class BucketSet ( size_t V, K = hash_t ) : IBucketSet ***********************************************************************/ - final protected int opApply ( int delegate ( ref Bucket.Element element ) dg ) + final protected int opApply ( scope int delegate ( ref Bucket.Element element ) dg ) { int tmpDg ( ref size_t i, ref Bucket.Element e ) { @@ -827,7 +827,7 @@ public abstract class BucketSet ( size_t V, K = hash_t ) : IBucketSet ***********************************************************************/ - final protected int opApply ( int delegate ( ref size_t i, + final protected int opApply ( scope int delegate ( ref size_t i, ref Bucket.Element element ) dg ) { int result = 0; diff --git a/src/ocean/util/container/map/model/IAllocator.d b/src/ocean/util/container/map/model/IAllocator.d index 60c97f5fe..c5b51eca1 100644 --- a/src/ocean/util/container/map/model/IAllocator.d +++ b/src/ocean/util/container/map/model/IAllocator.d @@ -244,7 +244,7 @@ abstract class IAllocator **********************************************************************/ - public int opApply ( int delegate ( ref void* object ) dg ) + public int opApply ( scope int delegate ( ref void* object ) dg ) { int r = 0; @@ -297,5 +297,5 @@ abstract class IAllocator ***************************************************************************/ - void parkElements ( size_t n, void delegate ( IParkingStack park ) dg ); + void parkElements ( size_t n, scope void delegate ( IParkingStack park ) dg ); } diff --git a/src/ocean/util/container/map/model/IBucketElementGCAllocator.d b/src/ocean/util/container/map/model/IBucketElementGCAllocator.d index 3e96fac45..f195380cb 100644 --- a/src/ocean/util/container/map/model/IBucketElementGCAllocator.d +++ b/src/ocean/util/container/map/model/IBucketElementGCAllocator.d @@ -133,7 +133,7 @@ class IBucketElementGCAllocator: IAllocator ***************************************************************************/ public override void parkElements (size_t n, - void delegate ( IParkingStack park ) dg) + scope void delegate ( IParkingStack park ) dg) { scope park = new ParkingStack(n); dg(park); diff --git a/src/ocean/util/container/map/model/MapIterator.d b/src/ocean/util/container/map/model/MapIterator.d index 44221709c..7ab19b598 100644 --- a/src/ocean/util/container/map/model/MapIterator.d +++ b/src/ocean/util/container/map/model/MapIterator.d @@ -202,13 +202,13 @@ template MapIterator ( V, K = hash_t ) static if (is (K Kelement : Kelement[]) && !is (K == Kelement[])) { - const k_is_static_array = true; + static immutable k_is_static_array = true; alias Kelement[] Kref; } else { - const k_is_static_array = false; + static immutable k_is_static_array = false; alias K Kref; } @@ -229,7 +229,7 @@ template MapIterator ( V, K = hash_t ) static if (is (V == void)) { - const v_is_static_array = false; + static immutable v_is_static_array = false; alias int delegate ( ref Kref ) Dg; alias int delegate ( ref size_t i, ref Kref ) Dgi; @@ -242,13 +242,13 @@ template MapIterator ( V, K = hash_t ) { alias Velement[] Vref; - const v_is_static_array = true; + static immutable v_is_static_array = true; } else { alias V Vref; - const v_is_static_array = false; + static immutable v_is_static_array = false; } alias int delegate ( ref Kref, ref Vref ) Dg; diff --git a/src/ocean/util/container/map/model/StandardHash.d b/src/ocean/util/container/map/model/StandardHash.d index 2448f7467..69a95cf49 100644 --- a/src/ocean/util/container/map/model/StandardHash.d +++ b/src/ocean/util/container/map/model/StandardHash.d @@ -31,7 +31,7 @@ struct StandardHash template IsPrimitiveValueType ( T ) { - const IsPrimitiveValueType = is (T : real) || is (T : creal) || is (T : dchar); + enum IsPrimitiveValueType = is (T : real) || is (T : creal) || is (T : dchar); } /************************************************************************** @@ -98,14 +98,14 @@ struct StandardHash static if (is (hash_t == uint)) { - const hash_t fnv1a_prime = 0x0100_0193, // 32 bit fnv1a prime + enum hash_t fnv1a_prime = 0x0100_0193, // 32 bit fnv1a prime fnv1a_init = 0x811C_9DC5; // 32 bit initial digest } else { static assert (is (hash_t == ulong)); - const hash_t fnv1a_prime = 0x0000_0100_0000_01B3, // 64 bit fnv1a prime + enum hash_t fnv1a_prime = 0x0000_0100_0000_01B3, // 64 bit fnv1a prime fnv1a_init = 0xCBF2_9CE4_8422_2325; // 64 bit initial digest } @@ -194,14 +194,14 @@ struct StandardHash { static if (n) { - const istring fnv1aCode = fnv1aCode!(hashvar, var, n - 1) ~ hashvar ~ "=(" ~ + enum istring fnv1aCode = fnv1aCode!(hashvar, var, n - 1) ~ hashvar ~ "=(" ~ hashvar ~ "^__" ~ var ~ "[" ~ minus1!(n).stringof ~ "])*" ~ fnv1a_prime.stringof ~ ";\n"; } else { - const istring fnv1aCode = "auto __" ~ var ~ + enum istring fnv1aCode = "auto __" ~ var ~ "=cast(" ~ ubyte.stringof ~ "*)&" ~ var ~ ";\n"; } @@ -216,6 +216,6 @@ struct StandardHash template minus1 ( size_t n ) { - const size_t minus1 = n - 1; + enum size_t minus1 = n - 1; } } diff --git a/src/ocean/util/container/map/utils/MapSerializer.d b/src/ocean/util/container/map/utils/MapSerializer.d index 62a1622c8..ec1b96cc5 100644 --- a/src/ocean/util/container/map/utils/MapSerializer.d +++ b/src/ocean/util/container/map/utils/MapSerializer.d @@ -200,7 +200,7 @@ template MapExtension ( K, V ) ***************************************************************************/ - public void load ( cstring file_path, CheckDg check ) + public void load ( cstring file_path, scope CheckDg check ) { scope file = new File(file_path, File.ReadExisting); @@ -218,7 +218,7 @@ template MapExtension ( K, V ) ***************************************************************************/ - public void load ( IConduit io_device, CheckDg check ) + public void load ( IConduit io_device, scope CheckDg check ) { scope add = ( ref K k, ref V v ) { @@ -289,7 +289,7 @@ template MapExtension ( K, V ) ***************************************************************************/ - public void dump ( cstring file_path, CheckDg check ) + public void dump ( cstring file_path, scope CheckDg check ) { scope file = new File(file_path, File.Style(File.Access.Write, File.Open.Create, @@ -309,7 +309,7 @@ template MapExtension ( K, V ) ***************************************************************************/ - public void dump ( IConduit io_device, CheckDg check ) + public void dump ( IConduit io_device, scope CheckDg check ) { scope adder = ( void delegate ( ref K, ref V ) add ) { @@ -405,7 +405,7 @@ class MapSerializer ***************************************************************************/ - private const uint MAGIC_MARKER = 0xCA1101AF; + private static immutable uint MAGIC_MARKER = 0xCA1101AF; /*************************************************************************** @@ -413,7 +413,7 @@ class MapSerializer ***************************************************************************/ - private const ubyte HEADER_VERSION = 5; + private static immutable ubyte HEADER_VERSION = 5; /*************************************************************************** @@ -504,11 +504,11 @@ class MapSerializer { static if ( is (typeof(TypeHash!(S))) ) { - const StructHash = TypeHash!(S); + static immutable StructHash = TypeHash!(S); } else { - const StructHash = StaticFnv1a64!(typeof(S.k).mangleof ~ + static immutable StructHash = StaticFnv1a64!(typeof(S.k).mangleof ~ typeof(S.v).mangleof); } } @@ -1109,7 +1109,7 @@ class MapSerializer ( Version.Type actual, Version.Type expected, ref BufferPair buffer, - void delegate ( ref T ) putter, + scope void delegate ( ref T ) putter, BufferedInput buffered ) { if ( actual < expected ) @@ -1149,12 +1149,12 @@ class MapSerializer private bool tryConvert ( bool throw_if_unable, alias loadFunc, size_t index, T... ) ( ref BufferPair buffer, - void delegate ( ref T ) putter, + scope void delegate ( ref T ) putter, BufferedInput buffered ) { static assert ( T.length == 2 ); - const other = index == 1 ? 0 : 1; + static immutable other = index == 1 ? 0 : 1; static if ( Version.Info!(T[index]).exists ) { @@ -1164,12 +1164,12 @@ class MapSerializer // `Version.Info!(T[index]).prev` except compare it with a type. // This can be checked by replacing `can_convert` with: // `const can_convert = Version.Info!(T[index]).prev.exists;` - const can_convert + static immutable can_convert = !is(Version.Info!(T[index]).prev == MissingVersion); } else { - const can_convert = false; + static immutable can_convert = false; } static if ( can_convert ) @@ -1219,7 +1219,7 @@ class MapSerializer ***************************************************************************/ private void loadOld ( K, V ) ( BufferedInput buffered, - void delegate ( ref K, ref V ) putter ) + scope void delegate ( ref K, ref V ) putter ) { size_t nr_rec; @@ -1429,7 +1429,7 @@ version ( UnitTest ) ", KNew = " ~ KNew.stringof ~ ", VNew = " ~ VNew.stringof ~ "}" ); - const ValueArraySize = 200; + static immutable ValueArraySize = 200; scope array = new MemoryDevice; scope map = new StructhashMap!(V, K)(iterations); @@ -1553,16 +1553,16 @@ version ( UnitTest ) unittest { - const Iterations = 10_000; + static immutable Iterations = 10_000; - const old_load_code = + static immutable old_load_code = `scope bufout = new BufferedOutput(array, 2048); bufout.seek(0); dumpOld!(K, V)(bufout, adder); auto header_size = MapSerializer.FileHeader!(K, V, 2).sizeof;`; - const version4_load_code = + static immutable version4_load_code = `serializer.buffered_output.output(array); serializer.dumpInternal!(K, V, 4)(serializer.buffered_output, adder); @@ -1588,14 +1588,14 @@ unittest static struct Test1 { - const StructVersion = 0; + enum StructVersion = 0; long i; } static struct Test2 { - const StructVersion = 1; + enum StructVersion = 1; alias Test1 StructPrevious; long i; @@ -1609,25 +1609,25 @@ unittest bool compare ( Test2* old ) { - return *old == *this; + return *old == *(&this); } } static struct OldStruct { - const StructVersion = 0; + enum StructVersion = 0; int old; bool compare ( OldStruct * o ) { - return *o == *this; + return *o == *(&this); } } static struct NewStruct { - const StructVersion = 1; + enum StructVersion = 1; alias OldStruct StructPrevious; int old; @@ -1640,31 +1640,31 @@ unittest bool compare ( OldStruct* old ) { - return old.old == this.old && + return old.old == (&this).old && old.old+1 == a_bit_newer; } } static struct OldKey { - const StructVersion = 0; + enum StructVersion = 0; int old2; bool compare ( OldKey * o ) { - return *o == *this; + return *o == *(&this); } OldKey old ( ) { - return *this; + return *(&this); } } static struct NewKey { - const StructVersion = 1; + enum StructVersion = 1; alias OldKey StructPrevious; int old1; @@ -1694,7 +1694,7 @@ unittest static struct NewerKey { - const StructVersion = 2; + enum StructVersion = 2; alias NewKey StructPrevious; int old1; @@ -1718,7 +1718,7 @@ unittest static struct NewerStruct { - const StructVersion = 2; + enum StructVersion = 2; alias NewStruct StructPrevious; int old; @@ -1737,7 +1737,7 @@ unittest static struct NoPrevious { - const StructVersion = 42; + enum StructVersion = 42; int hello; @@ -1749,7 +1749,7 @@ unittest static struct SinglePrevious { - const StructVersion = 42; + enum StructVersion = 42; int hello42; static void convert_hello42 ( ref StructPrevious p, ref SinglePrevious dst ) @@ -1759,18 +1759,18 @@ unittest bool compare ( StructPrevious* olds ) { - return this.hello42 == (olds.hello + 42); + return (&this).hello42 == (olds.hello + 42); } static struct StructPrevious { - const StructVersion = 41; + enum StructVersion = 41; alias SinglePrevious StructNext; int hello; bool compare ( StructNext* news ) { - return this.hello == (news.hello42 - 42); + return (&this).hello == (news.hello42 - 42); } } } @@ -1843,7 +1843,7 @@ version (UnitTest) // Make sure structs with a StructNext can be instantiated struct S ( ubyte V ) { - const StructVersion = V; + enum StructVersion = V; // comment this out and it works static if (V == 0) diff --git a/src/ocean/util/container/model/IContainer.d b/src/ocean/util/container/model/IContainer.d index ff1d71b2a..c5a42aca3 100644 --- a/src/ocean/util/container/model/IContainer.d +++ b/src/ocean/util/container/model/IContainer.d @@ -45,7 +45,7 @@ interface IContainer (V) size_t remove (V element, bool all); - int opApply (int delegate(ref V value) dg); + int opApply (scope int delegate(ref V value) dg); size_t replace (V oldElement, V newElement, bool all); } diff --git a/src/ocean/util/container/more/BitSet.d b/src/ocean/util/container/more/BitSet.d index 76ae54c22..5b7f2fbc1 100644 --- a/src/ocean/util/container/more/BitSet.d +++ b/src/ocean/util/container/more/BitSet.d @@ -36,7 +36,7 @@ struct BitSet (int Count=0) public alias and opAnd; public alias or opOrAssign; public alias xor opXorAssign; - private const width = size_t.sizeof * 8; + private enum width = size_t.sizeof * 8; static if (Count == 0) private size_t[] bits; @@ -128,7 +128,7 @@ struct BitSet (int Count=0) BitSet* clr () { bits[] = 0; - return this; + return (&this); } /********************************************************************** @@ -141,7 +141,7 @@ struct BitSet (int Count=0) { BitSet x; static if (Count == 0) - x.bits.length = this.bits.length; + x.bits.length = (&this).bits.length; x.bits[] = bits[]; return x; } @@ -168,6 +168,6 @@ struct BitSet (int Count=0) i = i / width; if (i >= bits.length) bits.length = i + 1; - return this; + return (&this); } } diff --git a/src/ocean/util/container/more/HashFile.d b/src/ocean/util/container/more/HashFile.d index 74686ab03..bbddcce39 100644 --- a/src/ocean/util/container/more/HashFile.d +++ b/src/ocean/util/container/more/HashFile.d @@ -265,11 +265,11 @@ class HashFile(K, V) void write (HashFile bucket, V data, BlockSize block) { - this.used = data.length; + (&this).used = data.length; // create new slot if we exceed capacity - if (this.used > this.capacity) - createBucket (bucket, this.used, block); + if ((&this).used > (&this).capacity) + createBucket (bucket, (&this).used, block); bucket.heap [offset .. offset+used] = cast(ubyte[]) data; } @@ -280,10 +280,10 @@ class HashFile(K, V) void createBucket (HashFile bucket, int bytes, BlockSize block) { - this.offset = bucket.waterLine; - this.capacity = (bytes + block.capacity) & ~block.capacity; + (&this).offset = bucket.waterLine; + (&this).capacity = (bytes + block.capacity) & ~block.capacity; - bucket.waterLine += this.capacity; + bucket.waterLine += (&this).capacity; if (bucket.waterLine > bucket.fileSize) { auto target = bucket.waterLine * 2; diff --git a/src/ocean/util/container/more/Heap.d b/src/ocean/util/container/more/Heap.d index aa02a8501..e19620939 100644 --- a/src/ocean/util/container/more/Heap.d +++ b/src/ocean/util/container/more/Heap.d @@ -162,7 +162,7 @@ struct Heap (T, alias Compare = minHeapCompare!(T), alias Move = defaultHeapSwap /** reset this heap, and use the provided host for value elements */ void clear (T[] host) { - this.heap = host; + (&this).heap = host; clear; } @@ -187,8 +187,8 @@ struct Heap (T, alias Compare = minHeapCompare!(T), alias Move = defaultHeapSwap Heap clone () { Heap other; - other.heap = this.heap.dup; - other.next = this.next; + other.heap = (&this).heap.dup; + other.next = (&this).next; return other; } diff --git a/src/ocean/util/container/more/Stack.d b/src/ocean/util/container/more/Stack.d index f83ce1b55..05c65536e 100644 --- a/src/ocean/util/container/more/Stack.d +++ b/src/ocean/util/container/more/Stack.d @@ -59,7 +59,7 @@ public struct Stack ( V, int Size = 0 ) Stack* clear ( ) { depth = 0; - return this; + return (&this); } /*************************************************************************** @@ -140,7 +140,7 @@ public struct Stack ( V, int Size = 0 ) enforce(.e_bounds, depth < stack.length); stack[depth++] = value; } - return this; + return (&this); } /*************************************************************************** @@ -158,7 +158,7 @@ public struct Stack ( V, int Size = 0 ) { foreach (v; value) push (v); - return this; + return (&this); } /*************************************************************************** @@ -255,7 +255,7 @@ public struct Stack ( V, int Size = 0 ) p++; } *p = t; - return this; + return (&this); } /*************************************************************************** @@ -282,7 +282,7 @@ public struct Stack ( V, int Size = 0 ) p--; } *p = t; - return this; + return (&this); } /*************************************************************************** @@ -308,7 +308,7 @@ public struct Stack ( V, int Size = 0 ) ***************************************************************************/ - int opApply ( int delegate(ref V value) dg ) + int opApply ( scope int delegate(ref V value) dg ) { int result; diff --git a/src/ocean/util/container/more/Vector.d b/src/ocean/util/container/more/Vector.d index d2e65f40e..f33abe9e6 100644 --- a/src/ocean/util/container/more/Vector.d +++ b/src/ocean/util/container/more/Vector.d @@ -54,7 +54,7 @@ struct Vector (V, int Size = 0) Vector* clear () { depth = 0; - return this; + return (&this); } /*********************************************************************** @@ -158,7 +158,7 @@ struct Vector (V, int Size = 0) { foreach (v; value) add (v); - return this; + return (&this); } /********************************************************************** @@ -268,7 +268,7 @@ struct Vector (V, int Size = 0) ***********************************************************************/ - int opApply (int delegate(ref V value) dg) + int opApply (scope int delegate(ref V value) dg) { int result; @@ -283,7 +283,7 @@ struct Vector (V, int Size = 0) ***********************************************************************/ - int opApply (int delegate(ref V value, ref bool kill) dg) + int opApply (scope int delegate(ref V value, ref bool kill) dg) { int result; diff --git a/src/ocean/util/container/pool/AcquiredResources.d b/src/ocean/util/container/pool/AcquiredResources.d index 6d8ab0365..ad5bc77ee 100644 --- a/src/ocean/util/container/pool/AcquiredResources.d +++ b/src/ocean/util/container/pool/AcquiredResources.d @@ -112,8 +112,8 @@ public struct Acquired ( T ) public void initialise ( FreeList!(ubyte[]) buffer_pool, FreeList!(T) t_pool ) { - this.buffer_pool = buffer_pool; - this.t_pool = t_pool; + (&this).buffer_pool = buffer_pool; + (&this).t_pool = t_pool; } /*************************************************************************** @@ -130,19 +130,19 @@ public struct Acquired ( T ) public Elem acquire ( lazy Elem new_t ) { - verify(this.buffer_pool !is null); + verify((&this).buffer_pool !is null); // Acquire container buffer, if not already done. - if ( this.buffer is null ) + if ( (&this).buffer is null ) { - this.buffer = acquireBuffer(this.buffer_pool, Elem.sizeof * 4); - this.acquired = VoidBufferAsArrayOf!(Elem)(&this.buffer); + (&this).buffer = acquireBuffer((&this).buffer_pool, Elem.sizeof * 4); + (&this).acquired = VoidBufferAsArrayOf!(Elem)(&(&this).buffer); } // Acquire new element. - this.acquired ~= this.t_pool.get(new_t); + (&this).acquired ~= (&this).t_pool.get(new_t); - return this.acquired.array()[$-1]; + return (&this).acquired.array()[$-1]; } /*************************************************************************** @@ -153,16 +153,16 @@ public struct Acquired ( T ) public void relinquishAll ( ) { - verify(this.buffer_pool !is null); + verify((&this).buffer_pool !is null); - if ( this.buffer !is null ) + if ( (&this).buffer !is null ) { // Relinquish acquired Ts. - foreach ( ref inst; this.acquired.array() ) - this.t_pool.recycle(inst); + foreach ( ref inst; (&this).acquired.array() ) + (&this).t_pool.recycle(inst); // Relinquish container buffer. - this.buffer_pool.recycle(cast(ubyte[])this.buffer); + (&this).buffer_pool.recycle(cast(ubyte[])(&this).buffer); } } } @@ -287,7 +287,7 @@ public struct AcquiredArraysOf ( T ) public void initialise ( FreeList!(ubyte[]) buffer_pool ) { - this.buffer_pool = buffer_pool; + (&this).buffer_pool = buffer_pool; } /*************************************************************************** @@ -313,7 +313,7 @@ public struct AcquiredArraysOf ( T ) public void[]* acquire ( ) { - return this.acquireNewBuffer(); + return (&this).acquireNewBuffer(); } } else @@ -330,7 +330,7 @@ public struct AcquiredArraysOf ( T ) public VoidBufferAsArrayOf!(T) acquire ( ) { - auto new_buf = this.acquireNewBuffer(); + auto new_buf = (&this).acquireNewBuffer(); return VoidBufferAsArrayOf!(T)(new_buf); } } @@ -343,16 +343,16 @@ public struct AcquiredArraysOf ( T ) public void relinquishAll ( ) { - verify(this.buffer_pool !is null); + verify((&this).buffer_pool !is null); - if ( this.buffer !is null ) + if ( (&this).buffer !is null ) { // Relinquish acquired buffers. - foreach ( ref inst; this.acquired.array() ) - this.buffer_pool.recycle(cast(ubyte[])inst); + foreach ( ref inst; (&this).acquired.array() ) + (&this).buffer_pool.recycle(cast(ubyte[])inst); // Relinquish container buffer. - this.buffer_pool.recycle(cast(ubyte[])this.buffer); + (&this).buffer_pool.recycle(cast(ubyte[])(&this).buffer); } } @@ -368,24 +368,24 @@ public struct AcquiredArraysOf ( T ) private void[]* acquireNewBuffer ( ) { - verify(this.buffer_pool !is null); + verify((&this).buffer_pool !is null); - const initial_array_capacity = 4; + enum initial_array_capacity = 4; // Acquire container buffer, if not already done. - if ( this.buffer is null ) + if ( (&this).buffer is null ) { - this.buffer = acquireBuffer(this.buffer_pool, + (&this).buffer = acquireBuffer((&this).buffer_pool, (void[]).sizeof * initial_array_capacity); - this.acquired = VoidBufferAsArrayOf!(void[])(&this.buffer); + (&this).acquired = VoidBufferAsArrayOf!(void[])(&(&this).buffer); } // Acquire and re-initialise new buffer to return to the user. Store // it in the container buffer. - this.acquired ~= acquireBuffer(this.buffer_pool, + (&this).acquired ~= acquireBuffer((&this).buffer_pool, T.sizeof * initial_array_capacity); - return &(this.acquired.array()[$-1]); + return &((&this).acquired.array()[$-1]); } } @@ -500,7 +500,7 @@ public struct AcquiredSingleton ( T ) public void initialise ( FreeList!(T) t_pool ) { - this.t_pool = t_pool; + (&this).t_pool = t_pool; } /*************************************************************************** @@ -517,14 +517,14 @@ public struct AcquiredSingleton ( T ) public Elem acquire ( lazy Elem new_t ) { - verify(this.t_pool !is null); + verify((&this).t_pool !is null); - if ( this.acquired is null ) - this.acquired = this.t_pool.get(new_t); + if ( (&this).acquired is null ) + (&this).acquired = (&this).t_pool.get(new_t); - verify(this.acquired !is null); + verify((&this).acquired !is null); - return this.acquired; + return (&this).acquired; } /*************************************************************************** @@ -542,19 +542,19 @@ public struct AcquiredSingleton ( T ) ***************************************************************************/ - public Elem acquire ( lazy Elem new_t, void delegate ( Elem ) reset ) + public Elem acquire ( lazy Elem new_t, scope void delegate ( Elem ) reset ) { - verify(this.t_pool !is null); + verify((&this).t_pool !is null); - if ( this.acquired is null ) + if ( (&this).acquired is null ) { - this.acquired = this.t_pool.get(new_t); - reset(this.acquired); + (&this).acquired = (&this).t_pool.get(new_t); + reset((&this).acquired); } - verify(this.acquired !is null); + verify((&this).acquired !is null); - return this.acquired; + return (&this).acquired; } /*************************************************************************** @@ -565,10 +565,10 @@ public struct AcquiredSingleton ( T ) public void relinquish ( ) { - verify(this.t_pool !is null); + verify((&this).t_pool !is null); - if ( this.acquired !is null ) - this.t_pool.recycle(this.acquired); + if ( (&this).acquired !is null ) + (&this).t_pool.recycle((&this).acquired); } } diff --git a/src/ocean/util/container/pool/model/IAggregatePool.d b/src/ocean/util/container/pool/model/IAggregatePool.d index a004af022..a64e87ffb 100644 --- a/src/ocean/util/container/pool/model/IAggregatePool.d +++ b/src/ocean/util/container/pool/model/IAggregatePool.d @@ -169,7 +169,7 @@ public abstract class IAggregatePool ( T ) : IPool, IFreeList!(ItemType_!(T)) // WORKAROUND: because of DMD1 bug placing this condition in static assert // directly causes it to fail even if condition is in fact true. Using // intermediate constant fixes that - const _assignable = is(typeof({ T t; t.object_pool_index = 4711; })); + static immutable _assignable = is(typeof({ T t; t.object_pool_index = 4711; })); static assert ( _assignable, T.stringof ~ ".object_pool_index must be assignable" @@ -689,7 +689,7 @@ public abstract class IAggregatePool ( T ) : IPool, IFreeList!(ItemType_!(T)) ***********************************************************************/ - public int opApply ( int delegate ( ref T item ) dg ) + public int opApply ( scope int delegate ( ref T item ) dg ) { int ret = 0; @@ -725,7 +725,7 @@ public abstract class IAggregatePool ( T ) : IPool, IFreeList!(ItemType_!(T)) ***********************************************************************/ - public int opApply ( int delegate ( ref size_t i, ref T item ) dg ) + public int opApply ( scope int delegate ( ref size_t i, ref T item ) dg ) { int ret = 0; size_t i = 0; diff --git a/src/ocean/util/container/pool/model/IFreeList.d b/src/ocean/util/container/pool/model/IFreeList.d index aaef5e968..8cd3d6ffd 100644 --- a/src/ocean/util/container/pool/model/IFreeList.d +++ b/src/ocean/util/container/pool/model/IFreeList.d @@ -152,7 +152,7 @@ version ( UnitTest ) ***********************************************************************/ - protected const num_items = 10; + protected static immutable num_items = 10; /*********************************************************************** diff --git a/src/ocean/util/container/pool/model/ILimitable.d b/src/ocean/util/container/pool/model/ILimitable.d index 11af3f14f..80a8eafca 100644 --- a/src/ocean/util/container/pool/model/ILimitable.d +++ b/src/ocean/util/container/pool/model/ILimitable.d @@ -61,7 +61,7 @@ public interface ILimitable : ILimitableInfo **************************************************************************/ - const size_t unlimited = size_t.max; + static immutable size_t unlimited = size_t.max; /*************************************************************************** diff --git a/src/ocean/util/container/pool/model/IPool.d b/src/ocean/util/container/pool/model/IPool.d index 3ecc0d681..63df065c7 100644 --- a/src/ocean/util/container/pool/model/IPool.d +++ b/src/ocean/util/container/pool/model/IPool.d @@ -93,9 +93,9 @@ public abstract class IPool : IPoolInfo, ILimitable ***********************************************************************/ - static typeof (*this) from ( Object obj ) + static typeof (*(&this)) from ( Object obj ) { - typeof (*this) item; + typeof (*(&this)) item; item.obj = obj; @@ -111,9 +111,9 @@ public abstract class IPool : IPoolInfo, ILimitable ***********************************************************************/ - static typeof (*this) from ( void* ptr ) + static typeof (*(&this)) from ( void* ptr ) { - typeof (*this) item; + typeof (*(&this)) item; item.ptr = ptr; diff --git a/src/ocean/util/container/queue/FlexibleFileQueue.d b/src/ocean/util/container/queue/FlexibleFileQueue.d index 2167835ed..42081924d 100644 --- a/src/ocean/util/container/queue/FlexibleFileQueue.d +++ b/src/ocean/util/container/queue/FlexibleFileQueue.d @@ -85,7 +85,7 @@ public class FlexibleFileQueue : IByteQueue ***************************************************************************/ - private const istring IndexExtension = ".index"; + private static immutable istring IndexExtension = ".index"; /*************************************************************************** diff --git a/src/ocean/util/container/queue/FlexibleRingQueue.d b/src/ocean/util/container/queue/FlexibleRingQueue.d index efc9bc9bf..7ec15ec11 100644 --- a/src/ocean/util/container/queue/FlexibleRingQueue.d +++ b/src/ocean/util/container/queue/FlexibleRingQueue.d @@ -484,7 +484,7 @@ class FlexibleByteRingQueue : IRingQueue!(IByteQueue) ***************************************************************************/ - public void save ( void delegate ( in void[] meta, in void[] head, in void[] tail = null ) store ) + public void save ( scope void delegate ( in void[] meta, in void[] head, in void[] tail = null ) store ) { auto meta = ExportMetadata(this.items); @@ -567,7 +567,7 @@ class FlexibleByteRingQueue : IRingQueue!(IByteQueue) ***************************************************************************/ - public void load ( size_t delegate ( void[] meta, void[] data ) restore ) + public void load ( scope size_t delegate ( void[] meta, void[] data ) restore ) { this.clear(); @@ -849,7 +849,7 @@ version ( UnitTest ) unittest { - const queue_size_1 = (9+FlexibleByteRingQueue.Header.sizeof)*10; + static immutable queue_size_1 = (9+FlexibleByteRingQueue.Header.sizeof)*10; scope queue = new FlexibleByteRingQueue(queue_size_1); test(queue.free_space >= queue_size_1); @@ -934,7 +934,7 @@ unittest scope backup = new MemoryDevice; - const queue_size_1 = (9+FlexibleByteRingQueue.Header.sizeof)*10; + static immutable queue_size_1 = (9+FlexibleByteRingQueue.Header.sizeof)*10; scope queue = new FlexibleByteRingQueue(queue_size_1); test(queue.free_space >= queue_size_1); @@ -1034,7 +1034,7 @@ unittest void save_wraparound ( Save save ) { - const Q_SIZE = 20; + static immutable Q_SIZE = 20; FlexibleByteRingQueue q = new FlexibleByteRingQueue(Q_SIZE); void push(uint n) diff --git a/src/ocean/util/container/queue/LinkedListQueue.d b/src/ocean/util/container/queue/LinkedListQueue.d index 14897774e..7d4418665 100644 --- a/src/ocean/util/container/queue/LinkedListQueue.d +++ b/src/ocean/util/container/queue/LinkedListQueue.d @@ -123,7 +123,7 @@ public class LinkedListQueue ( T, alias gc_tracking_policy = GCTrackingPolicy.re public QueueItem* find ( T find_value ) { - for ( auto p = this; p; p = p.next ) + for ( auto p = (&this); p; p = p.next ) if ( find_value == p.value ) return p; return null; @@ -451,7 +451,7 @@ public class LinkedListQueue ( T, alias gc_tracking_policy = GCTrackingPolicy.re ***************************************************************************/ - public int opApply ( int delegate ( ref T value ) dg ) + public int opApply ( scope int delegate ( ref T value ) dg ) { int result; @@ -694,7 +694,7 @@ unittest // T = JustSomeClass LinkedListQueue!(JustSomeClass) classesList = new LinkedListQueue!(JustSomeClass)(); - const int size = 100; + static immutable int size = 100; int[] int_array; JustSomeClass[] class_array; diff --git a/src/ocean/util/container/queue/NotifyingQueue.d b/src/ocean/util/container/queue/NotifyingQueue.d index dfda18cd1..c61d70238 100644 --- a/src/ocean/util/container/queue/NotifyingQueue.d +++ b/src/ocean/util/container/queue/NotifyingQueue.d @@ -297,7 +297,7 @@ class NotifyingByteQueue : ISuspendable, IQueueInfo ***************************************************************************/ - public bool ready ( NotificationDg notifier ) + public bool ready ( scope NotificationDg notifier ) { debug foreach ( waiting_notifier; this.notifiers[] ) { @@ -335,7 +335,7 @@ class NotifyingByteQueue : ISuspendable, IQueueInfo ***************************************************************************/ - final public bool isRegistered ( NotificationDg notifier ) + final public bool isRegistered ( scope NotificationDg notifier ) { foreach (wait_notifier; this.notifiers[]) { @@ -400,7 +400,7 @@ class NotifyingByteQueue : ISuspendable, IQueueInfo ***************************************************************************/ - public bool push ( size_t size, void delegate ( void[] ) filler ) + public bool push ( size_t size, scope void delegate ( void[] ) filler ) { auto target = this.queue.push(size); diff --git a/src/ocean/util/digest/Md4.d b/src/ocean/util/digest/Md4.d index 0b760762f..032f769d8 100644 --- a/src/ocean/util/digest/Md4.d +++ b/src/ocean/util/digest/Md4.d @@ -35,7 +35,7 @@ version(UnitTest) import ocean.core.Test; class Md4 : MerkleDamgard { protected uint[4] context; - private const ubyte padChar = 0x80; + private static immutable ubyte padChar = 0x80; /*********************************************************************** diff --git a/src/ocean/util/digest/Ripemd128.d b/src/ocean/util/digest/Ripemd128.d index 63de17aac..919960090 100644 --- a/src/ocean/util/digest/Ripemd128.d +++ b/src/ocean/util/digest/Ripemd128.d @@ -42,7 +42,7 @@ version(UnitTest) import ocean.core.Test; final class Ripemd128 : MerkleDamgard { private uint[4] context; - private const uint padChar = 0x80; + private static immutable uint padChar = 0x80; /*********************************************************************** diff --git a/src/ocean/util/digest/Ripemd160.d b/src/ocean/util/digest/Ripemd160.d index 63cae5eb5..cc7f27028 100644 --- a/src/ocean/util/digest/Ripemd160.d +++ b/src/ocean/util/digest/Ripemd160.d @@ -42,7 +42,7 @@ version(UnitTest) import ocean.core.Test; final class Ripemd160 : MerkleDamgard { private uint[5] context; - private const uint padChar = 0x80; + private static immutable uint padChar = 0x80; /*********************************************************************** diff --git a/src/ocean/util/digest/Ripemd256.d b/src/ocean/util/digest/Ripemd256.d index 4ac8077d5..9ad61d415 100644 --- a/src/ocean/util/digest/Ripemd256.d +++ b/src/ocean/util/digest/Ripemd256.d @@ -42,7 +42,7 @@ version(UnitTest) import ocean.core.Test; final class Ripemd256 : MerkleDamgard { private uint[8] context; - private const uint padChar = 0x80; + private static immutable uint padChar = 0x80; /*********************************************************************** diff --git a/src/ocean/util/digest/Ripemd320.d b/src/ocean/util/digest/Ripemd320.d index 754cb2e52..bfb4beebd 100644 --- a/src/ocean/util/digest/Ripemd320.d +++ b/src/ocean/util/digest/Ripemd320.d @@ -42,7 +42,7 @@ version(UnitTest) import ocean.core.Test; final class Ripemd320 : MerkleDamgard { private uint[10] context; - private const uint padChar = 0x80; + private static immutable uint padChar = 0x80; /*********************************************************************** diff --git a/src/ocean/util/digest/Sha01.d b/src/ocean/util/digest/Sha01.d index 6549365bd..40f5c685f 100644 --- a/src/ocean/util/digest/Sha01.d +++ b/src/ocean/util/digest/Sha01.d @@ -34,8 +34,8 @@ version(UnitTest) import ocean.core.Test; package abstract class Sha01 : MerkleDamgard { protected uint[5] context; - private const ubyte padChar = 0x80; - package const uint mask = 0x0000000F; + private static immutable ubyte padChar = 0x80; + package static immutable uint mask = 0x0000000F; /*********************************************************************** diff --git a/src/ocean/util/digest/Sha256.d b/src/ocean/util/digest/Sha256.d index 594be9619..ed1751def 100644 --- a/src/ocean/util/digest/Sha256.d +++ b/src/ocean/util/digest/Sha256.d @@ -37,7 +37,7 @@ version(UnitTest) import ocean.core.Test; final class Sha256 : MerkleDamgard { private uint[8] context; - private const uint padChar = 0x80; + private static immutable uint padChar = 0x80; /*********************************************************************** diff --git a/src/ocean/util/digest/Sha512.d b/src/ocean/util/digest/Sha512.d index ac5b4ba25..185cc52cd 100644 --- a/src/ocean/util/digest/Sha512.d +++ b/src/ocean/util/digest/Sha512.d @@ -37,7 +37,7 @@ version(UnitTest) import ocean.core.Test; final class Sha512 : MerkleDamgard { private ulong[8] context; - private const uint padChar = 0x80; + private static immutable uint padChar = 0x80; /*********************************************************************** diff --git a/src/ocean/util/digest/Tiger.d b/src/ocean/util/digest/Tiger.d index 7fa1d4b5d..05dbdf0d8 100644 --- a/src/ocean/util/digest/Tiger.d +++ b/src/ocean/util/digest/Tiger.d @@ -40,7 +40,7 @@ final class Tiger : MerkleDamgard { private ulong[3] context; private uint npass = 3; - private const uint padChar = 0x01; + private static immutable uint padChar = 0x01; /*********************************************************************** diff --git a/src/ocean/util/digest/Whirlpool.d b/src/ocean/util/digest/Whirlpool.d index 68e9f6d86..7d5d41b5b 100644 --- a/src/ocean/util/digest/Whirlpool.d +++ b/src/ocean/util/digest/Whirlpool.d @@ -35,13 +35,13 @@ version(UnitTest) import ocean.core.Test; *******************************************************************************/ -private const int INTERNAL_ROUNDS = 10; +private static immutable int INTERNAL_ROUNDS = 10; final class Whirlpool : MerkleDamgard { private ulong[8] hash; /* the hashing state */ - private const uint padChar = 0x80; + private static immutable uint padChar = 0x80; /*********************************************************************** diff --git a/src/ocean/util/encode/Base16.d b/src/ocean/util/encode/Base16.d index 50b322e7d..1996e6001 100644 --- a/src/ocean/util/encode/Base16.d +++ b/src/ocean/util/encode/Base16.d @@ -245,7 +245,7 @@ private: Static immutable tables used for fast lookups to encode and decode data. */ -const ubyte hex_PAD = '='; +static immutable ubyte hex_PAD = '='; static istring _encodeTable = "0123456789ABCDEF"; static Const!(ubyte)[] _decodeTable = [ diff --git a/src/ocean/util/encode/Base32.d b/src/ocean/util/encode/Base32.d index 5589ad28f..c421cc392 100644 --- a/src/ocean/util/encode/Base32.d +++ b/src/ocean/util/encode/Base32.d @@ -257,7 +257,7 @@ private: Static immutable tables used for fast lookups to encode and decode data. */ -const ubyte base32_PAD = '='; +static immutable ubyte base32_PAD = '='; static istring _encodeTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; static Const!(ubyte)[] _decodeTable = [ diff --git a/src/ocean/util/encode/Base64.d b/src/ocean/util/encode/Base64.d index a02e5d30f..07744abad 100644 --- a/src/ocean/util/encode/Base64.d +++ b/src/ocean/util/encode/Base64.d @@ -44,10 +44,10 @@ version (UnitTest) import ocean.core.Test; *******************************************************************************/ -public const istring defaultEncodeTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; +public static immutable istring defaultEncodeTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; /// Ditto -public const ubyte[char.max + 1] defaultDecodeTable = [ +public static immutable ubyte[char.max + 1] defaultDecodeTable = [ 'A' : 0, 'B' : 1, 'C' : 2, 'D' : 3, 'E' : 4, 'F' : 5, 'G' : 6, 'H' : 7, 'I' : 8, 'J' : 9, 'K' : 10, 'L' : 11, 'M' : 12, 'N' : 13, 'O' : 14, @@ -80,10 +80,10 @@ public const ubyte[char.max + 1] defaultDecodeTable = [ *******************************************************************************/ -public const istring urlSafeEncodeTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="; +public static immutable istring urlSafeEncodeTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="; /// Ditto -public const ubyte[char.max + 1] urlSafeDecodeTable = [ +public static immutable ubyte[char.max + 1] urlSafeDecodeTable = [ 'A' : 0, 'B' : 1, 'C' : 2, 'D' : 3, 'E' : 4, 'F' : 5, 'G' : 6, 'H' : 7, 'I' : 8, 'J' : 9, 'K' : 10, 'L' : 11, 'M' : 12, 'N' : 13, 'O' : 14, @@ -108,7 +108,7 @@ public const ubyte[char.max + 1] urlSafeDecodeTable = [ /// Value set to the padding -private const ubyte BASE64_PAD = 64; +private static immutable ubyte BASE64_PAD = 64; /******************************************************************************* @@ -398,7 +398,7 @@ public ubyte[] decode (Table...) (cstring data, ubyte[] buff) static assert(validateDecodeTable(Table[0]) == null, validateDecodeTable(Table[0])); - const table = Table[0]; + static immutable table = Table[0]; ubyte[] rtn; if (data.length > 0) diff --git a/src/ocean/util/log/AppendSysLog.d b/src/ocean/util/log/AppendSysLog.d index 8a33deef7..5256c77f7 100644 --- a/src/ocean/util/log/AppendSysLog.d +++ b/src/ocean/util/log/AppendSysLog.d @@ -63,7 +63,7 @@ public class AppendSysLog : Appender private static class SysLogLayout : Layout { - override public void format ( LogEvent event, void delegate(cstring) dg ) + override public void format ( LogEvent event, scope void delegate(cstring) dg ) { dg("["); dg(event.name); diff --git a/src/ocean/util/log/Appender.d b/src/ocean/util/log/Appender.d index 5546bcd17..23ab2ac6d 100644 --- a/src/ocean/util/log/Appender.d +++ b/src/ocean/util/log/Appender.d @@ -48,7 +48,7 @@ public class Appender public interface Layout { - void format (LogEvent event, void delegate(cstring) dg); + void format (LogEvent event, scope void delegate(cstring) dg); } /*************************************************************************** @@ -245,7 +245,7 @@ public class AppendStream : Appender /// Append an event to the output. final override void append (LogEvent event) { - const istring Eol = "\n"; + static immutable istring Eol = "\n"; this.layout.format(event, (cstring content) { this.stream_.write(content); }); this.stream_.write(Eol); @@ -270,7 +270,7 @@ public class LayoutTimer : Appender.Layout ***************************************************************************/ - public override void format (LogEvent event, void delegate(cstring) dg) + public override void format (LogEvent event, scope void delegate(cstring) dg) { char[20] tmp = void; diff --git a/src/ocean/util/log/Config.d b/src/ocean/util/log/Config.d index ec58c5d52..e25a32093 100644 --- a/src/ocean/util/log/Config.d +++ b/src/ocean/util/log/Config.d @@ -283,7 +283,7 @@ unittest void myConfigureLoggers ( ClassIterator!(Config, ConfigParser) config, MetaConfig m_config, - Appender delegate ( istring file, Layout layout ) file_appender, + scope Appender delegate ( istring file, Layout layout ) file_appender, bool use_insert_appender = false) { Layout makeLayout (cstring name) @@ -318,7 +318,7 @@ unittest public void configureNewLoggers ( ClassIterator!(Config, ConfigParser) config, MetaConfig m_config, - Appender delegate ( istring file, Layout layout ) file_appender, + scope Appender delegate ( istring file, Layout layout ) file_appender, bool use_insert_appender = false) { configureNewLoggers(config, m_config, file_appender, @@ -351,8 +351,8 @@ public void configureNewLoggers ( public void configureNewLoggers ( ClassIterator!(Config, ConfigParser) config, MetaConfig m_config, - Appender delegate ( istring file, Layout layout ) file_appender, - Layout delegate (cstring) makeLayout, bool use_insert_appender = false) + scope Appender delegate ( istring file, Layout layout ) file_appender, + scope Layout delegate (cstring) makeLayout, bool use_insert_appender = false) { // DMD1 cannot infer the common type between both return, we have to work // around it... @@ -395,9 +395,9 @@ public void configureNewLoggers ( private void configureLoggers (ClassIterator!(Config, ConfigParser) config, MetaConfig m_config, - Appender delegate (istring file, Layout layout) file_appender, - Appender delegate (Layout) console_appender, - Layout delegate (cstring) makeLayout) + scope Appender delegate (istring file, Layout layout) file_appender, + scope Appender delegate (Layout) console_appender, + scope Layout delegate (cstring) makeLayout) { // It is important to ensure that parent loggers are configured before child // loggers. This is because parent loggers will override the settings of @@ -486,10 +486,10 @@ private void configureLoggers public void configureLogger (Logger log, Config settings, istring name, - Appender delegate ( istring file, Layout layout ) file_appender, - Appender delegate (Layout) console_appender, + scope Appender delegate ( istring file, Layout layout ) file_appender, + scope Appender delegate (Layout) console_appender, bool console_enabled, bool syslog_enabled, size_t buffer_size, - Layout delegate (cstring) makeLayout = (cstring v) { return newLayout(v); }) + scope Layout delegate (cstring) makeLayout = (cstring v) { return newLayout(v); }) { if (settings.buffer_size) buffer_size = settings.buffer_size; diff --git a/src/ocean/util/log/Event.d b/src/ocean/util/log/Event.d index e73b815c2..2acadc1ca 100644 --- a/src/ocean/util/log/Event.d +++ b/src/ocean/util/log/Event.d @@ -86,7 +86,7 @@ public struct LogEvent /// Return the logger level name of this event. cstring levelName () { - return ILogger.convert(this.level_); + return ILogger.convert((&this).level_); } /// Convert a time value (in milliseconds) to ascii diff --git a/src/ocean/util/log/Hierarchy.d b/src/ocean/util/log/Hierarchy.d index 2152e6297..a8286231c 100644 --- a/src/ocean/util/log/Hierarchy.d +++ b/src/ocean/util/log/Hierarchy.d @@ -176,7 +176,7 @@ package class HierarchyT (LoggerT) : ILogger.Context ***************************************************************************/ - final int opApply (int delegate(ref LoggerT) dg) + final int opApply (scope int delegate(ref LoggerT) dg) { int ret; @@ -193,7 +193,7 @@ package class HierarchyT (LoggerT) : ILogger.Context ***************************************************************************/ - private LoggerT inject (cstring label, LoggerT delegate(cstring name) dg) + private LoggerT inject (cstring label, scope LoggerT delegate(cstring name) dg) { // try not to allocate unless you really need to char[255] stack_buffer; diff --git a/src/ocean/util/log/InsertConsole.d b/src/ocean/util/log/InsertConsole.d index 2b845d98f..204a2ca85 100644 --- a/src/ocean/util/log/InsertConsole.d +++ b/src/ocean/util/log/InsertConsole.d @@ -144,7 +144,7 @@ public class InsertConsole: Appender ushort pos = 0; - const istring Eol = "\n"; + static immutable istring Eol = "\n"; with ( Terminal ) { diff --git a/src/ocean/util/log/LayoutDate.d b/src/ocean/util/log/LayoutDate.d index 6c257ea6b..d30a7a7ff 100644 --- a/src/ocean/util/log/LayoutDate.d +++ b/src/ocean/util/log/LayoutDate.d @@ -58,7 +58,7 @@ public class LayoutDate : Appender.Layout ***********************************************************************/ - public override void format (LogEvent event, void delegate(cstring) dg) + public override void format (LogEvent event, scope void delegate(cstring) dg) { auto level = event.levelName; diff --git a/src/ocean/util/log/Logger.d b/src/ocean/util/log/Logger.d index f5c7efff0..f9f2f97c7 100644 --- a/src/ocean/util/log/Logger.d +++ b/src/ocean/util/log/Logger.d @@ -146,7 +146,7 @@ public struct Log { uint total; - foreach (field; this.tupleof) + foreach (field; (&this).tupleof) { total += field; } @@ -157,7 +157,7 @@ public struct Log /// Resets the counters private void reset () { - foreach (ref field; this.tupleof) + foreach (ref field; (&this).tupleof) { field = field.init; } @@ -177,19 +177,19 @@ public struct Log with (Level) switch (event_level) { case Trace: - this.logged_trace++; + (&this).logged_trace++; break; case Info: - this.logged_info++; + (&this).logged_info++; break; case Warn: - this.logged_warn++; + (&this).logged_warn++; break; case Error: - this.logged_error++; + (&this).logged_error++; break; case Fatal: - this.logged_fatal++; + (&this).logged_fatal++; break; case None: break; @@ -973,7 +973,7 @@ unittest } // Test string of 87 chars - const TestStr = "Ce qui se conçoit bien s'énonce clairement - Et les mots pour le dire arrivent aisément"; + static immutable TestStr = "Ce qui se conçoit bien s'énonce clairement - Et les mots pour le dire arrivent aisément"; scope appender = new Buffer(); char[32] log_buffer; Logger log = (new Logger(Log.hierarchy(), "dummy")) diff --git a/src/ocean/util/log/PeriodicTrace.d b/src/ocean/util/log/PeriodicTrace.d index 6c2980d5f..d26ec3c19 100644 --- a/src/ocean/util/log/PeriodicTrace.d +++ b/src/ocean/util/log/PeriodicTrace.d @@ -173,22 +173,22 @@ struct PeriodicTracer ***************************************************************************/ - public typeof(this) format (Args...) ( cstring fmt, Args args ) + public typeof((&this)) format (Args...) ( cstring fmt, Args args ) { - if (this.timeToUpdate()) + if ((&this).timeToUpdate()) { - this.last_update_time = this.now; + (&this).last_update_time = (&this).now; - this.formatted.length = 0; - enableStomping(this.formatted); - sformat(this.formatted, fmt, args); + (&this).formatted.length = 0; + enableStomping((&this).formatted); + sformat((&this).formatted, fmt, args); - if (this.static_display) - StaticTrace.format("{}", this.formatted).flush; + if ((&this).static_display) + StaticTrace.format("{}", (&this).formatted).flush; else - Stderr.formatln("{}", this.formatted).flush; + Stderr.formatln("{}", (&this).formatted).flush; } - return this; + return (&this); } @@ -209,10 +209,10 @@ struct PeriodicTracer ***************************************************************************/ - public typeof(this) format (Args...) ( ulong interval, cstring fmt, Args args ) + public typeof((&this)) format (Args...) ( ulong interval, cstring fmt, Args args ) { - this.interval = interval; - return this.format(fmt, args); + (&this).interval = interval; + return (&this).format(fmt, args); } @@ -236,8 +236,8 @@ struct PeriodicTracer public bool timeToUpdate ( ) { - this.now = timer.microsec(); - return this.now > this.last_update_time + this.interval; + (&this).now = timer.microsec(); + return (&this).now > (&this).last_update_time + (&this).interval; } diff --git a/src/ocean/util/log/Stats.d b/src/ocean/util/log/Stats.d index 044148818..6ff1492a8 100644 --- a/src/ocean/util/log/Stats.d +++ b/src/ocean/util/log/Stats.d @@ -259,8 +259,8 @@ public class StatsLog ***************************************************************************/ - public const time_t default_period = 30; // 30 seconds - public const istring default_file_name = "log/stats.log"; + public static immutable time_t default_period = 30; // 30 seconds + public static immutable istring default_file_name = "log/stats.log"; /*************************************************************************** @@ -335,7 +335,7 @@ public class StatsLog ***************************************************************************/ public this ( Config config, - Appender delegate ( istring file, Appender.Layout layout ) new_appender, + scope Appender delegate ( istring file, Appender.Layout layout ) new_appender, istring name = "Stats" ) { if (config.socket_path.length) diff --git a/src/ocean/util/log/StatsReader.d b/src/ocean/util/log/StatsReader.d index 008fb599a..0dacf53fa 100644 --- a/src/ocean/util/log/StatsReader.d +++ b/src/ocean/util/log/StatsReader.d @@ -111,7 +111,7 @@ public struct StatsLine **************************************************************************/ - public cstring opIndex (cstring key) /* d1to2fix_inject: const */ + public cstring opIndex (cstring key) const { auto position = find(line[], key); @@ -143,9 +143,9 @@ public struct StatsLine { StatsLine stats_line; - stats_line.line = this.line.dup; - stats_line.date = this.date.dup; - stats_line.time = this.time.dup; + stats_line.line = (&this).line.dup; + stats_line.date = (&this).date.dup; + stats_line.time = (&this).time.dup; return stats_line; } @@ -241,11 +241,11 @@ public class StatsLogReader ***************************************************************************/ - public int opApply ( int delegate(ref Const!(char[])) dg ) + public int opApply ( scope int delegate(ref Const!(char[])) dg ) { int result; - foreach (line; this.lines) + foreach (line; (&this).lines) { if (line.length == 0) { @@ -321,7 +321,7 @@ public class StatsLogReader ***************************************************************************/ - public int opApply ( int delegate(ref Const!(StatsLine)) dg ) + public int opApply ( scope int delegate(ref Const!(StatsLine)) dg ) { int result; @@ -345,7 +345,7 @@ public class StatsLogReader ******************************************************************************/ - public int opApply ( int delegate(ref size_t index, ref Const!(StatsLine)) dg ) + public int opApply ( scope int delegate(ref size_t index, ref Const!(StatsLine)) dg ) { int result; size_t index; diff --git a/src/ocean/util/log/layout/LayoutMessageOnly.d b/src/ocean/util/log/layout/LayoutMessageOnly.d index 0b62031f7..0a3def076 100644 --- a/src/ocean/util/log/layout/LayoutMessageOnly.d +++ b/src/ocean/util/log/layout/LayoutMessageOnly.d @@ -31,7 +31,7 @@ public class LayoutMessageOnly : Appender.Layout ***************************************************************************/ - public override void format (LogEvent event, void delegate(cstring) dg) + public override void format (LogEvent event, scope void delegate(cstring) dg) { dg(event.toString); } diff --git a/src/ocean/util/log/layout/LayoutSimple.d b/src/ocean/util/log/layout/LayoutSimple.d index 197950c2f..f872bfa38 100644 --- a/src/ocean/util/log/layout/LayoutSimple.d +++ b/src/ocean/util/log/layout/LayoutSimple.d @@ -64,7 +64,7 @@ public class LayoutSimple : Appender.Layout ***************************************************************************/ - public override void format (LogEvent event, void delegate(cstring) dg) + public override void format (LogEvent event, scope void delegate(cstring) dg) { auto level = event.levelName; diff --git a/src/ocean/util/log/layout/LayoutStatsLog.d b/src/ocean/util/log/layout/LayoutStatsLog.d index 48ccd6503..f724ee003 100644 --- a/src/ocean/util/log/layout/LayoutStatsLog.d +++ b/src/ocean/util/log/layout/LayoutStatsLog.d @@ -57,7 +57,7 @@ public class LayoutStatsLog : Appender.Layout ***************************************************************************/ - public override void format (LogEvent event, void delegate(cstring) dg) + public override void format (LogEvent event, scope void delegate(cstring) dg) { auto level = event.levelName; diff --git a/src/ocean/util/log/model/ILogger.d b/src/ocean/util/log/model/ILogger.d index 9ab36ec81..a0cd7da03 100644 --- a/src/ocean/util/log/model/ILogger.d +++ b/src/ocean/util/log/model/ILogger.d @@ -70,7 +70,7 @@ interface ILogger ***************************************************************************/ - private const Pair[Level.max + 1] Pairs = + private static immutable Pair[Level.max + 1] Pairs = [ { "Trace", Level.Trace }, { "Info", Level.Info }, diff --git a/src/ocean/util/prometheus/collector/CollectorRegistry.d b/src/ocean/util/prometheus/collector/CollectorRegistry.d index e7b9a08ed..6cb0451f9 100644 --- a/src/ocean/util/prometheus/collector/CollectorRegistry.d +++ b/src/ocean/util/prometheus/collector/CollectorRegistry.d @@ -40,7 +40,7 @@ public class CollectorRegistry ***************************************************************************/ - public this ( CollectionDg[] callbacks ) + public this ( scope CollectionDg[] callbacks ) { this.collector = new Collector(); this.collector_callbacks = callbacks; @@ -57,7 +57,7 @@ public class CollectorRegistry ***************************************************************************/ - public void addCollector ( CollectionDg collector ) + public void addCollector ( scope CollectionDg collector ) { this.collector_callbacks ~= collector; } diff --git a/src/ocean/util/prometheus/server/PrometheusHandler.d b/src/ocean/util/prometheus/server/PrometheusHandler.d index e725e0181..6b56d5858 100644 --- a/src/ocean/util/prometheus/server/PrometheusHandler.d +++ b/src/ocean/util/prometheus/server/PrometheusHandler.d @@ -63,7 +63,7 @@ public class PrometheusHandler : HttpConnectionHandler ***************************************************************************/ - public this ( FinalizeDg finalizer, CollectorRegistry collector_registry, + public this ( scope FinalizeDg finalizer, CollectorRegistry collector_registry, EpollSelectDispatcher epoll, size_t stack_size = HttpConnectionHandler.default_stack_size ) { diff --git a/src/ocean/util/serialize/Version.d b/src/ocean/util/serialize/Version.d index 1510e59ec..6ec1743f4 100644 --- a/src/ocean/util/serialize/Version.d +++ b/src/ocean/util/serialize/Version.d @@ -44,8 +44,8 @@ version(UnitTest) import ocean.core.Test; public struct MissingVersion { - const exists = false; - const ubyte number = 0; + enum exists = false; + enum ubyte number = 0; } /******************************************************************************* @@ -96,8 +96,8 @@ struct Version ", but it must be lower than Version.Type.max" ); - const exists = true; - const number = S.StructVersion; + enum exists = true; + enum number = S.StructVersion; alias S type; @@ -134,14 +134,14 @@ struct Version unittest { - struct S1 { const StructVersion = 1; } + struct S1 { enum StructVersion = 1; } alias Info!(S1) Ver; static assert (Ver.exists); static assert (Ver.number == 1); static assert (is(Ver.next == MissingVersion)); static assert (is(Ver.prev == MissingVersion)); - struct S2 { const StructVersion = Version.Type.max + 1; } + struct S2 { enum StructVersion = Version.Type.max + 1; } static assert (!is(typeof(Info!(S2)))); } @@ -149,7 +149,7 @@ struct Version { struct S { - const StructVersion = 1; + enum StructVersion = 1; alias S StructPrevious; alias S StructNext; } diff --git a/src/ocean/util/serialize/contiguous/Contiguous.d b/src/ocean/util/serialize/contiguous/Contiguous.d index a693691bd..b5fa4b5cf 100644 --- a/src/ocean/util/serialize/contiguous/Contiguous.d +++ b/src/ocean/util/serialize/contiguous/Contiguous.d @@ -79,12 +79,12 @@ struct Contiguous( S ) public S* ptr ( ) { - verify((this.data.length == 0) || (this.data.length >= S.sizeof)); + verify(((&this).data.length == 0) || ((&this).data.length >= S.sizeof)); - if (this.data.length == 0) + if ((&this).data.length == 0) return null; - return cast(S*) this.data.ptr; + return cast(S*) (&this).data.ptr; } /*************************************************************************** @@ -99,9 +99,9 @@ struct Contiguous( S ) public void enforceIntegrity() { - if (this.data.ptr) + if ((&this).data.ptr) { - enforceContiguous(*cast(S*) this.data.ptr, this.data); + enforceContiguous(*cast(S*) (&this).data.ptr, (&this).data); } } @@ -116,7 +116,7 @@ struct Contiguous( S ) public size_t length() { - return this.data.length; + return (&this).data.length; } /*************************************************************************** @@ -128,9 +128,9 @@ struct Contiguous( S ) public Contiguous!(S) reset() { - this.data.length = 0; - enableStomping(this.data); - return *this; + (&this).data.length = 0; + enableStomping((&this).data); + return *(&this); } debug(ContiguousIntegrity) @@ -140,9 +140,9 @@ struct Contiguous( S ) // can't call this.enforceIntegrity because it will trigger // invariant recursively being a public method - if (this.data.length) + if ((&this).data.length) { - enforceContiguous(*cast(S*) this.data.ptr, this.data); + enforceContiguous(*cast(S*) (&this).data.ptr, (&this).data); } } } diff --git a/src/ocean/util/serialize/contiguous/Deserializer.d b/src/ocean/util/serialize/contiguous/Deserializer.d index 8d2824b8f..056d98624 100644 --- a/src/ocean/util/serialize/contiguous/Deserializer.d +++ b/src/ocean/util/serialize/contiguous/Deserializer.d @@ -180,7 +180,7 @@ struct Deserializer **************************************************************************/ - alias typeof(*this) This; + alias typeof(*(&this)) This; /*************************************************************************** @@ -190,7 +190,7 @@ struct Deserializer ***************************************************************************/ - public const max_length = size_t.max; + public enum max_length = size_t.max; /*************************************************************************** diff --git a/src/ocean/util/serialize/contiguous/MultiVersionDecorator.d b/src/ocean/util/serialize/contiguous/MultiVersionDecorator.d index 48d33f3fd..94feb99c5 100644 --- a/src/ocean/util/serialize/contiguous/MultiVersionDecorator.d +++ b/src/ocean/util/serialize/contiguous/MultiVersionDecorator.d @@ -420,7 +420,7 @@ version(UnitTest) { static struct Version0 { - const StructVersion = 0; + enum StructVersion = 0; alias Version1 StructNext; int a, b; @@ -430,7 +430,7 @@ version(UnitTest) static struct Version1 { - const StructVersion = 1; + enum StructVersion = 1; alias Version0 StructPrevious; alias Version2 StructNext; @@ -441,7 +441,7 @@ version(UnitTest) static struct Version2 { - const StructVersion = 2; + enum StructVersion = 2; alias Version1 StructPrevious; int a, b, c; @@ -510,12 +510,12 @@ version (UnitTest) static struct Version3 { int a, b; - const StructVersion = 3; + enum StructVersion = 3; } static struct VersionHuge { - const StructVersion = 100; + enum StructVersion = 100; } } } @@ -560,7 +560,7 @@ unittest { struct S { - const StructVersion = 1; + enum StructVersion = 1; int a = 42; double b = 2.0; @@ -594,7 +594,7 @@ unittest { struct S { - const StructVersion = 1; + enum StructVersion = 1; int a = 42; } @@ -628,7 +628,7 @@ unittest // must detect if input size is too small - struct Dummy { const StructVersion = 1; } + struct Dummy { enum StructVersion = 1; } testThrown!(VersionHandlingException)(loader.load!(Dummy)(buffer)); @@ -638,7 +638,7 @@ unittest // must detect if conversion is not defined - struct Dummy2 { const StructVersion = 2; } + struct Dummy2 { enum StructVersion = 2; } loader.store(Dummy2.init, buffer); testThrown!(VersionHandlingException)(loader.load!(Dummy)(buffer)); @@ -657,7 +657,7 @@ struct Test1 { struct Version1 { - const StructVersion = 1; + enum StructVersion = 1; alias Version2 StructNext; @@ -671,7 +671,7 @@ struct Test1 struct Version2 { - const StructVersion = 2; + enum StructVersion = 2; int a = 42; } @@ -706,14 +706,14 @@ struct Test2 { struct Version1 { - const StructVersion = 1; + enum StructVersion = 1; int a; } struct Version2 { - const StructVersion = 2; + enum StructVersion = 2; alias Version1 StructPrevious; @@ -755,7 +755,7 @@ struct Test3 { struct Version0 { - const ubyte StructVersion = 0; + enum ubyte StructVersion = 0; alias Version1 StructNext; struct Nested0 @@ -784,7 +784,7 @@ struct Test3 void compare ( NamedTest t, Version0 other ) { - foreach (index, ref element; this.tupleof) + foreach (index, ref element; (&this).tupleof) { t.test!("==")(element, other.tupleof[index]); } @@ -792,15 +792,15 @@ struct Test3 void compare ( NamedTest t, Version1 other ) { - foreach (index, ref element; this.tupleof) + foreach (index, ref element; (&this).tupleof) { - const name = this.tupleof[index].stringof[ - rfind(this.tupleof[index].stringof, "."[]) + 1 .. $ + enum name = (&this).tupleof[index].stringof[ + rfind((&this).tupleof[index].stringof, "."[]) + 1 .. $ ]; static if (name == "nested_arr") { - foreach (i, elem; this.nested_arr) + foreach (i, elem; (&this).nested_arr) { t.test!("==")(elem.a, other.nested_arr[i].a); } @@ -813,7 +813,7 @@ struct Test3 struct Version1 { - const ubyte StructVersion = 1; + enum ubyte StructVersion = 1; alias Version0 StructPrevious; alias Version2 StructNext; @@ -851,15 +851,15 @@ struct Test3 void compare ( NamedTest t, Version0 other ) { - foreach (index, ref member; this.tupleof) + foreach (index, ref member; (&this).tupleof) { - const name = this.tupleof[index].stringof[ - rfind(this.tupleof[index].stringof, "."[]) + 1 .. $ + enum name = (&this).tupleof[index].stringof[ + rfind((&this).tupleof[index].stringof, "."[]) + 1 .. $ ]; static if (name == "nested_arr") { - foreach (i, ref nested; this.nested_arr) + foreach (i, ref nested; (&this).nested_arr) { test!("==")(nested.a, other.nested_arr[i].a); test!("==")(nested.b, other.nested_arr[i].a + 1); @@ -867,7 +867,7 @@ struct Test3 } else static if (name == "c") { - test!("==")(this.c, other.b - other.a); + test!("==")((&this).c, other.b - other.a); } else { @@ -878,7 +878,7 @@ struct Test3 void compare ( NamedTest t, Version1 other ) { - foreach (index, ref element; this.tupleof) + foreach (index, ref element; (&this).tupleof) { t.test!("==")(element, other.tupleof[index]); } @@ -886,15 +886,15 @@ struct Test3 void compare ( NamedTest t, Version2 other ) { - foreach (index, ref member; this.tupleof) + foreach (index, ref member; (&this).tupleof) { - const name = this.tupleof[index].stringof[ - rfind(this.tupleof[index].stringof, "."[]) + 1 .. $ + enum name = (&this).tupleof[index].stringof[ + rfind((&this).tupleof[index].stringof, "."[]) + 1 .. $ ]; static if (name == "nested_arr") { - foreach (i, ref nested; this.nested_arr) + foreach (i, ref nested; (&this).nested_arr) { test!("==")(nested.a, other.nested_arr[i].a); test!("==")(nested.b, other.nested_arr[i].a / 2); @@ -902,7 +902,7 @@ struct Test3 } else static if (name == "c") { - test!("==")(this.c, other.d); + test!("==")((&this).c, other.d); } else { @@ -914,7 +914,7 @@ struct Test3 struct Version2 { - const ubyte StructVersion = 2; + enum ubyte StructVersion = 2; alias Version1 StructPrevious; @@ -948,22 +948,22 @@ struct Test3 void compare ( NamedTest t, ref Version1 other ) { - foreach (index, ref member; this.tupleof) + foreach (index, ref member; (&this).tupleof) { - const name = this.tupleof[index].stringof[ - rfind(this.tupleof[index].stringof, "."[]) + 1 .. $ + enum name = (&this).tupleof[index].stringof[ + rfind((&this).tupleof[index].stringof, "."[]) + 1 .. $ ]; static if (name == "nested_arr") { - foreach (i, ref nested; this.nested_arr) + foreach (i, ref nested; (&this).nested_arr) { test!("==")(nested.a, other.nested_arr[i].b * 2); } } else static if (name == "d") { - test!("==")(this.d, other.c); + test!("==")((&this).d, other.c); } else { @@ -974,7 +974,7 @@ struct Test3 void compare ( NamedTest t, ref Version2 other ) { - foreach (index, member; this.tupleof) + foreach (index, member; (&this).tupleof) { t.test!("==")(member, other.tupleof[index]); } @@ -1043,7 +1043,7 @@ Dst testConvMemory(Src, Dst)(Src src, size_t limit = 10) auto loader = new VersionDecorator(limit); void[] buffer; - const iterations = 10_000; + static immutable iterations = 10_000; static void storeThenLoad (ref NamedTest test, ref VersionDecorator loader, ref Src src, ref void[] buffer, @@ -1121,13 +1121,13 @@ struct Test4 { struct Ver0 { - const ubyte StructVersion = 0; + enum ubyte StructVersion = 0; int a; } struct Ver1 { - const ubyte StructVersion = 1; + enum ubyte StructVersion = 1; alias Test4.Ver0 StructPrevious; long b; diff --git a/src/ocean/util/serialize/contiguous/Serializer.d b/src/ocean/util/serialize/contiguous/Serializer.d index 3c79875ae..7cb055107 100644 --- a/src/ocean/util/serialize/contiguous/Serializer.d +++ b/src/ocean/util/serialize/contiguous/Serializer.d @@ -52,7 +52,7 @@ struct Serializer **************************************************************************/ - alias typeof(*this) This; + alias typeof(*(&this)) This; /*************************************************************************** diff --git a/src/ocean/util/serialize/contiguous/package_.d b/src/ocean/util/serialize/contiguous/package_.d index a6c191f25..275bd1489 100644 --- a/src/ocean/util/serialize/contiguous/package_.d +++ b/src/ocean/util/serialize/contiguous/package_.d @@ -213,20 +213,20 @@ struct S ***************************************************************************/ - void testNullReferences ( ) /* d1to2fix_inject: const */ + void testNullReferences ( ) const { - foreach (s2_static_array_element; this.s2_static_array) + foreach (s2_static_array_element; (&this).s2_static_array) { testArray!("is")(s2_static_array_element.a, null); testArray!("is")(s2_static_array_element.b, null); } - foreach (s3_a_element; this.s3.a) + foreach (s3_a_element; (&this).s3.a) testArray!("is")(s3_a_element, null); - testArray!("is")(this.s4_dynamic_array, null); + testArray!("is")((&this).s4_dynamic_array, null); - foreach (static_of_dynamic_element; this.static_of_dynamic) + foreach (static_of_dynamic_element; (&this).static_of_dynamic) testArray!("is")(static_of_dynamic_element, null); } @@ -245,7 +245,7 @@ struct S ***************************************************************************/ - size_t serialized_length ( ) /* d1to2fix_inject: const */ + size_t serialized_length ( ) const { static size_t s2_length ( ref Const!(S_2) s2 ) { @@ -254,23 +254,23 @@ struct S size_t n = This.sizeof; - n += s2_length(this.s2); + n += s2_length((&this).s2); - foreach (s2_static_array_element; this.s2_static_array) + foreach (s2_static_array_element; (&this).s2_static_array) n += s2_length(s2_static_array_element); - foreach (s3_a_element; this.s3.a) + foreach (s3_a_element; (&this).s3.a) n += serialArrayLength(s3_a_element); - n += serialArrayLength(this.s4_dynamic_array); - foreach (s4_dynamic_array_element; this.s4_dynamic_array) + n += serialArrayLength((&this).s4_dynamic_array); + foreach (s4_dynamic_array_element; (&this).s4_dynamic_array) n += serialArrayLength(s4_dynamic_array_element.a); - foreach (static_of_dynamic_element; this.static_of_dynamic) + foreach (static_of_dynamic_element; (&this).static_of_dynamic) n += serialArrayLength(static_of_dynamic_element); - n += serialArrayLength(this.dynamic_of_static_of_static_of_dynamic); - foreach (dynamic_element; this.dynamic_of_static_of_static_of_dynamic) + n += serialArrayLength((&this).dynamic_of_static_of_static_of_dynamic); + foreach (dynamic_element; (&this).dynamic_of_static_of_static_of_dynamic) foreach (static_element; dynamic_element) foreach (static_element2; static_element) n += serialArrayLength(static_element2); diff --git a/src/ocean/util/serialize/model/VersionDecoratorMixins.d b/src/ocean/util/serialize/model/VersionDecoratorMixins.d index 844ff8a04..0aafff363 100644 --- a/src/ocean/util/serialize/model/VersionDecoratorMixins.d +++ b/src/ocean/util/serialize/model/VersionDecoratorMixins.d @@ -406,7 +406,7 @@ unittest try { - struct Test { const StructVersion = 1; } + struct Test { enum StructVersion = 1; } void[] buffer; decorator.load!(Test)(buffer); }