Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Refactor TypeInfo_Array #2506

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions mak/DOCS
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,7 @@ DOCS=\
$(DOCDIR)\rt_trace.html \
$(DOCDIR)\rt_tracegc.html \
\
$(DOCDIR)\rt_typeinfo_ti_Acdouble.html \
$(DOCDIR)\rt_typeinfo_ti_Acfloat.html \
$(DOCDIR)\rt_typeinfo_ti_Acreal.html \
$(DOCDIR)\rt_typeinfo_ti_Adouble.html \
$(DOCDIR)\rt_typeinfo_ti_Afloat.html \
$(DOCDIR)\rt_typeinfo_ti_Ag.html \
$(DOCDIR)\rt_typeinfo_ti_Aint.html \
$(DOCDIR)\rt_typeinfo_ti_Along.html \
$(DOCDIR)\rt_typeinfo_ti_Areal.html \
$(DOCDIR)\rt_typeinfo_ti_Ashort.html \
$(DOCDIR)\rt_typeinfo_ti_A.html \
$(DOCDIR)\rt_typeinfo_ti_byte.html \
$(DOCDIR)\rt_typeinfo_ti_C.html \
$(DOCDIR)\rt_typeinfo_ti_cdouble.html \
Expand Down
11 changes: 1 addition & 10 deletions mak/SRCS
Original file line number Diff line number Diff line change
Expand Up @@ -452,16 +452,7 @@ SRCS=\
src\rt\util\container\hashtab.d \
src\rt\util\container\treap.d \
\
src\rt\typeinfo\ti_Acdouble.d \
src\rt\typeinfo\ti_Acfloat.d \
src\rt\typeinfo\ti_Acreal.d \
src\rt\typeinfo\ti_Adouble.d \
src\rt\typeinfo\ti_Afloat.d \
src\rt\typeinfo\ti_Ag.d \
src\rt\typeinfo\ti_Aint.d \
src\rt\typeinfo\ti_Along.d \
src\rt\typeinfo\ti_Areal.d \
src\rt\typeinfo\ti_Ashort.d \
src\rt\typeinfo\ti_A.d \
src\rt\typeinfo\ti_byte.d \
src\rt\typeinfo\ti_C.d \
src\rt\typeinfo\ti_cdouble.d \
Expand Down
127 changes: 127 additions & 0 deletions src/rt/typeinfo/ti_A.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/**
* TypeInfo support code.
*
* Copyright: Copyright Digital Mars 2004 - 2009.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update year to 2019

* License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Walter Bright
*/

/* Copyright Digital Mars 2004 - 2019.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module rt.typeinfo.ti_A;

private import rt.util.typeinfo;

// cdouble[]
class TypeInfo_Ar : Impl_TypeInfo_A!cdouble {}

// cfloat[]
class TypeInfo_Aq : Impl_TypeInfo_A!cfloat {}

// creal[]
class TypeInfo_Ac : Impl_TypeInfo_A!creal {}

// double[]
class TypeInfo_Ad : Impl_TypeInfo_A!double {}

// idouble[]
class TypeInfo_Ap : Impl_TypeInfo_A!idouble {}

// float[]
class TypeInfo_Af : Impl_TypeInfo_A!float {}

// ifloat[]
class TypeInfo_Ao : Impl_TypeInfo_A!ifloat {}

// byte[]
class TypeInfo_Ag : Impl_TypeInfo_A!byte {}

// ubyte[]
class TypeInfo_Ah : Impl_TypeInfo_A!ubyte {};

// void[]
class TypeInfo_Av : Impl_TypeInfo_A!void {}

// bool[]
class TypeInfo_Ab : Impl_TypeInfo_A!bool {}

// char[]
class TypeInfo_Aa : Impl_TypeInfo_A!char {}

// string
class TypeInfo_Aya : Impl_TypeInfo_A!(immutable(char)) {}

// const(char)[]
class TypeInfo_Axa : Impl_TypeInfo_A!(const(char)) {}


extern (C) void[] _adSort(void[] a, TypeInfo ti);

// int[]
class TypeInfo_Ai : Impl_TypeInfo_A!int {}

unittest
{
int[][] a = [[5,3,8,7], [2,5,3,8,7]];
_adSort(*cast(void[]*)&a, typeid(a[0]));
assert(a == [[2,5,3,8,7], [5,3,8,7]]);

a = [[5,3,8,7], [5,3,8]];
_adSort(*cast(void[]*)&a, typeid(a[0]));
assert(a == [[5,3,8], [5,3,8,7]]);
}

unittest
{
// Issue 13073: original code uses int subtraction which is susceptible to
// integer overflow, causing the following case to fail.
int[] a = [int.max, int.max];
int[] b = [int.min, int.min];
assert(a > b);
assert(b < a);
}

// uint[]
class TypeInfo_Ak : Impl_TypeInfo_A!uint {}

unittest
{
// Original test case from issue 13073
uint x = 0x22_DF_FF_FF;
uint y = 0xA2_DF_FF_FF;
assert(!(x < y && y < x));
uint[] a = [x];
uint[] b = [y];
assert(!(a < b && b < a)); // Original failing case
uint[1] a1 = [x];
uint[1] b1 = [y];
assert(!(a1 < b1 && b1 < a1)); // Original failing case
}

// dchar[]
class TypeInfo_Aw : Impl_TypeInfo_A!dchar {}


// long[]
class TypeInfo_Al : Impl_TypeInfo_A!long {}

// ulong[]
class TypeInfo_Am : Impl_TypeInfo_A!ulong {}

// real[]
class TypeInfo_Ae : Impl_TypeInfo_A!real {}

// ireal[]
class TypeInfo_Aj : Impl_TypeInfo_A!ireal {}

// short[]
class TypeInfo_As : Impl_TypeInfo_A!short {}

// ushort[]
class TypeInfo_At : Impl_TypeInfo_A!ushort {}

// wchar[]
class TypeInfo_Au : Impl_TypeInfo_A!wchar {}
47 changes: 0 additions & 47 deletions src/rt/typeinfo/ti_Acdouble.d

This file was deleted.

47 changes: 0 additions & 47 deletions src/rt/typeinfo/ti_Acfloat.d

This file was deleted.

47 changes: 0 additions & 47 deletions src/rt/typeinfo/ti_Acreal.d

This file was deleted.

61 changes: 0 additions & 61 deletions src/rt/typeinfo/ti_Adouble.d

This file was deleted.

Loading