Skip to content
This repository has been archived by the owner on Aug 13, 2020. It is now read-only.

Commit

Permalink
Alias init to initializer
Browse files Browse the repository at this point in the history
Matches change in D2 runtime intended to avoid confusion with built-in
`T.init`
  • Loading branch information
1 parent 96ffc2f commit 7f27dfe
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
Empty file added relnotes/.keep
Empty file.
5 changes: 5 additions & 0 deletions relnotes/init.deprecation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### ClassInfo.init is deprecated, renamed to `initializer`

This change matches recent deprecation in D2 upstream druntime and is intended
to eliminate confusion between built-in `T.init` property of all types and
member function of `ClassInfo` with the same name.
8 changes: 8 additions & 0 deletions relnotes/init.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### `ClassInfo.init()` is also available as `initializer`

This change matches recent deprecation in D2 upstream druntime and is intended
to eliminate confusion between built-in `T.init` property of all types and
member function of `ClassInfo` with the same name.

Now tangort provides both names so that applications doing transition to D2 can
make a switch without breaking D1 build.
9 changes: 9 additions & 0 deletions src/object.d
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ class ClassInfo : Object
byte[] init; /** class static initializer
* (init.length gives size in bytes of class)
*/
byte[] initializer ( ) { return init; }

char[] name; /// class name
void*[] vtbl; /// virtual function pointer table
Interface[] interfaces; /// interfaces this class implements
Expand Down Expand Up @@ -440,6 +442,8 @@ class TypeInfo
/// Return default initializer, null if default initialize to 0
void[] init() { return null; }

void[] initializer() { return init(); }

/// Get flags for type: 1 means GC should scan for pointers
uint flags() { return 0; }

Expand Down Expand Up @@ -508,7 +512,9 @@ class TypeInfo_Typedef : TypeInfo
override TypeInfo next() { return base; }
override uint flags() { return base.flags(); }
override PointerMap pointermap() { return base.pointermap(); }

override void[] init() { return m_init.length ? m_init : base.init(); }
override void[] initializer() { return init(); }

size_t talign() { return base.talign(); }

Expand Down Expand Up @@ -760,6 +766,8 @@ class TypeInfo_StaticArray : TypeInfo
}

override void[] init() { return value.init(); }
override void[] initializer() { return init(); }

override TypeInfo next() { return value; }
override uint flags() { return value.flags(); }

Expand Down Expand Up @@ -1176,6 +1184,7 @@ class TypeInfo_Struct : TypeInfo
}

override void[] init() { return m_init; }
override void[] initializer() { return init(); }

override uint flags() { return m_flags; }

Expand Down
4 changes: 2 additions & 2 deletions src/rt/lifetime.d
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ extern(C) array_t _d_newarrayiT(TypeInfo ti, size_t length)
result = array_t.init;
else
{
auto initializer = ti.next.init();
auto initializer = ti.next.initializer();
auto isize = initializer.length;
auto q = initializer.ptr;
version (D_InlineAsm_X86)
Expand Down Expand Up @@ -788,7 +788,7 @@ body
{
byte* newdata;
size_t sizeelem = ti.next.tsize();
void[] initializer = ti.next.init();
void[] initializer = ti.next.initializer();
size_t initsize = initializer.length;

assert(sizeelem);
Expand Down

0 comments on commit 7f27dfe

Please sign in to comment.