ocean.transition

This modules contains utilities and aliases that are used during D1->D2 transition process. Idea is to define single module that contains wrapper aliases / structures and switch all code to use it. Once actual porting time comes it will be enough to simply change version in this module.

version(D2) can't be used because D2 code can't be even parsed by D1 compiler, resorting to commenting out because of that.

Public Imports

ocean.meta.types.Qualifiers
public import ocean.meta.types.Qualifiers;
Undocumented in source.
ocean.meta.types.Typedef
public import ocean.meta.types.Typedef;
Undocumented in source.

Members

Aliases

gc_usage
alias gc_usage = core.memory.GC.usage
Undocumented in source.

Functions

assumeUnique (from ocean.core.TypeConvert)
immutable(T)[] assumeUnique(T[] input) via public import ocean.core.TypeConvert : assumeUnique;
Undocumented in source.
enableStomping
void enableStomping(T[] array)

Helper to smooth transition between D1 and D2 runtime behaviours regarding array stomping. In D2 appending to array slice after length has been changed results in allocating new array to prevent overwriting old data.

gc_usage
void gc_usage(size_t used, size_t free)
Undocumented in source. Be warned that the author may not have intended to support it.
gc_usage
void gc_usage(size_t used, size_t free)
Undocumented in source. Be warned that the author may not have intended to support it.
genOpCmp
istring genOpCmp(istring func_body)

Mixin helper to generate proper opCmp declaration. It differs between D1 and D2 runtime and not matching exact signature will result in weird segmentation faults from inside the runtime.

genOpEquals
istring genOpEquals(istring func_body)

Mixin helper to generate proper opEquals declaration. It differs between D1 and D2 runtime and not matching exact signature will result in the default version, defined by the compiler, to be silently called instead.

Templates

Octal
template Octal(istring literal)
Undocumented in source.
SliceIfD1StaticArray
template SliceIfD1StaticArray(T)

Utility intended to help with situations when generic function had to return its templated argument which could turn out to be a static array. In D1 that would require slicing such argument as returning static array types is not allowed. In D2, however, static arrays are value types and such slicing is neither necessary nor memory-safe.

TypeofThis
template TypeofThis()

In D1, typeof(this) is always a reference type to the aggregate, while in D2 it's the actual type of the aggregate. It doesn't change anything for classes which are reference types, but for struct and unions, it yields a pointer instead of the actual type. d1tod2fix does the conversion automatically for structs, but there are places where manual intervention is needed (e.g. mixin templates).

isMutable
template isMutable(T)

Checks (non-transitively) if type is mutable

Meta

License

Boost Software License Version 1.0. See LICENSE_BOOST.txt for details. Alternatively, this file may be distributed under the terms of the Tango 3-Clause BSD License (see LICENSE_BSD.txt for details).