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

Commit

Permalink
Merge pull request #664 from yebblies/classinfo_typeid
Browse files Browse the repository at this point in the history
Convert x.classinfo to typeid(x)
  • Loading branch information
MartinNowak committed Nov 18, 2013
2 parents 560e2c1 + 2605232 commit defd767
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 35 deletions.
4 changes: 2 additions & 2 deletions src/core/demangle.d
Expand Up @@ -92,7 +92,7 @@ private struct Demangle
//throw new ParseException( msg );
debug(info) printf( "error: %.*s\n", cast(int) msg.length, msg.ptr );
throw __ctfe ? new ParseException(msg)
: cast(ParseException) cast(void*) ParseException.classinfo.init;
: cast(ParseException) cast(void*) typeid(ParseException).init;

}

Expand All @@ -101,7 +101,7 @@ private struct Demangle
{
//throw new OverflowException( msg );
debug(info) printf( "overflow: %.*s\n", cast(int) msg.length, msg.ptr );
throw cast(OverflowException) cast(void*) OverflowException.classinfo.init;
throw cast(OverflowException) cast(void*) typeid(OverflowException).init;
}


Expand Down
6 changes: 3 additions & 3 deletions src/core/exception.d
Expand Up @@ -498,7 +498,7 @@ extern (C) void onFinalizeError( ClassInfo info, Exception e, string file = __FI
*/
extern (C) void onHiddenFuncError( Object o ) @safe pure nothrow
{
throw new HiddenFuncError( o.classinfo );
throw new HiddenFuncError( typeid(o) );
}


Expand All @@ -513,7 +513,7 @@ extern (C) void onOutOfMemoryError() @trusted pure nothrow
{
// NOTE: Since an out of memory condition exists, no allocation must occur
// while generating this object.
throw cast(OutOfMemoryError) cast(void*) OutOfMemoryError.classinfo.init;
throw cast(OutOfMemoryError) cast(void*) typeid(OutOfMemoryError).init;
}


Expand All @@ -529,7 +529,7 @@ extern (C) void onInvalidMemoryOperationError() @trusted pure nothrow
// The same restriction applies as for onOutOfMemoryError. The GC is in an
// undefined state, thus no allocation must occur while generating this object.
throw cast(InvalidMemoryOperationError)
cast(void*) InvalidMemoryOperationError.classinfo.init;
cast(void*) typeid(InvalidMemoryOperationError).init;
}


Expand Down
4 changes: 2 additions & 2 deletions src/core/sys/windows/stacktrace.d
Expand Up @@ -111,7 +111,7 @@ public:
*/
static ulong[] trace(size_t skip = 0, CONTEXT* context = null)
{
synchronized( StackTrace.classinfo )
synchronized( typeid(StackTrace) )
{
return traceNoSync(skip, context);
}
Expand All @@ -126,7 +126,7 @@ public:
*/
static char[][] resolve(const(ulong)[] addresses)
{
synchronized( StackTrace.classinfo )
synchronized( typeid(StackTrace) )
{
return resolveNoSync(addresses);
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/thread.d
Expand Up @@ -1424,7 +1424,7 @@ private:
{
foreach (ref lock; _locks)
{
lock[] = Mutex.classinfo.init[];
lock[] = typeid(Mutex).init[];
(cast(Mutex)lock.ptr).__ctor();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/gc/gc.d
Expand Up @@ -246,7 +246,7 @@ class GC

void initialize()
{
mutexStorage[] = GCMutex.classinfo.init[];
mutexStorage[] = typeid(GCMutex).init[];
gcLock = cast(GCMutex) mutexStorage.ptr;
gcLock.__ctor();
gcx = cast(Gcx*)cstdlib.calloc(1, Gcx.sizeof);
Expand Down
2 changes: 1 addition & 1 deletion src/gc/proxy.d
Expand Up @@ -107,7 +107,7 @@ extern (C)
{
version (GCCLASS)
{ void* p;
ClassInfo ci = GC.classinfo;
ClassInfo ci = typeid(GC);

p = malloc(ci.init.length);
(cast(byte*)p)[0 .. ci.init.length] = ci.init[];
Expand Down
8 changes: 4 additions & 4 deletions src/object_.d
Expand Up @@ -78,7 +78,7 @@ class Object
*/
string toString()
{
return this.classinfo.name;
return typeid(this).name;
}

/**
Expand All @@ -104,7 +104,7 @@ class Object
// BUG: this prevents a compacting GC from working, needs to be fixed
//return cast(int)cast(void*)this - cast(int)cast(void*)o;

throw new Exception("need opCmp for class " ~ this.classinfo.name);
throw new Exception("need opCmp for class " ~ typeid(this).name);
//return this !is o;
}

Expand Down Expand Up @@ -900,7 +900,7 @@ class TypeInfo_Interface : TypeInfo
if (this is o)
return true;
auto c = cast(const TypeInfo_Interface)o;
return c && this.info.name == c.classinfo.name;
return c && this.info.name == typeid(c).name;
}

override size_t getHash(in void* p) @trusted const
Expand Down Expand Up @@ -1364,7 +1364,7 @@ class Throwable : Object
{
SizeStringBuff tmpBuff = void;

sink(this.classinfo.name);
sink(typeid(this).name);
if (file)
{
sink("@"); sink(file);
Expand Down
6 changes: 3 additions & 3 deletions src/rt/aaA.d
Expand Up @@ -570,7 +570,7 @@ Impl* _d_assocarrayliteralTX(const TypeInfo_AssociativeArray ti, void[] keys, vo
Impl* result;

//printf("_d_assocarrayliteralT(keysize = %d, valuesize = %d, length = %d)\n", keysize, valuesize, length);
//printf("tivalue = %.*s\n", ti.next.classinfo.name);
//printf("tivalue = %.*s\n", typeid(ti.next).name);
assert(length == values.length);
if (length == 0 || valuesize == 0 || keysize == 0)
{
Expand Down Expand Up @@ -666,8 +666,8 @@ const(TypeInfo_AssociativeArray) _aaUnwrapTypeInfo(const(TypeInfo) tiRaw) pure n
int _aaEqual(in TypeInfo tiRaw, in AA e1, in AA e2)
{
//printf("_aaEqual()\n");
//printf("keyti = %.*s\n", ti.key.classinfo.name);
//printf("valueti = %.*s\n", ti.next.classinfo.name);
//printf("keyti = %.*s\n", typeid(ti.key).name);
//printf("valueti = %.*s\n", typeid(ti.next).name);

if (e1.impl is e2.impl)
return 1;
Expand Down
6 changes: 3 additions & 3 deletions src/rt/cast_.d
Expand Up @@ -29,7 +29,7 @@ Object _d_toObject(void* p)
return null;

Object o = cast(Object) p;
ClassInfo oc = o.classinfo;
ClassInfo oc = typeid(o);
Interface* pi = **cast(Interface***) p;

/* Interface.offset lines up with ClassInfo.name.ptr,
Expand Down Expand Up @@ -68,7 +68,7 @@ void* _d_dynamic_cast(Object o, ClassInfo c)

void* res = null;
size_t offset = 0;
if(o && _d_isbaseof2(o.classinfo, c, offset))
if(o && _d_isbaseof2(typeid(o), c, offset))
{
debug(cast_) printf("\toffset = %d\n", offset);
res = cast(void*) o + offset;
Expand Down Expand Up @@ -143,7 +143,7 @@ void* _d_interface_vtbl(ClassInfo ic, Object o)

assert(o);

foreach(iface; o.classinfo.interfaces)
foreach(iface; typeid(o).interfaces)
if(iface.classinfo is ic)
return cast(void*) iface.vtbl;

Expand Down
2 changes: 1 addition & 1 deletion src/rt/deh.d
Expand Up @@ -19,7 +19,7 @@ extern (C)
auto t = cast(Throwable) o;

if (t !is null && t.info is null &&
cast(byte*) t !is t.classinfo.init.ptr)
cast(byte*) t !is typeid(t).init.ptr)
{
t.info = _d_traceContext(context);
}
Expand Down
2 changes: 1 addition & 1 deletion src/rt/deh_win32.d
Expand Up @@ -468,7 +468,7 @@ EXCEPTION_DISPOSITION _d_framehandler(
masterClassInfo = ci;
break;
}
if (_d_isbaseof(ci, Error.classinfo))
if (_d_isbaseof(ci, typeid(Error)))
{ // It's derived from Error. This _may_ be the master.
master = er;
masterClassInfo = ci;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/invariant.d
Expand Up @@ -24,7 +24,7 @@ void _d_invariant(Object o)
// BUG: needs to be filename/line of caller, not library routine
assert(o !is null); // just do null check, not invariant check

c = o.classinfo;
c = typeid(o);
do
{
if (c.classInvariant)
Expand Down
24 changes: 12 additions & 12 deletions src/rt/lifetime.d
Expand Up @@ -617,7 +617,7 @@ in
body
{
// step 1, get the block
auto isshared = ti.classinfo is TypeInfo_Shared.classinfo;
auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
auto bic = !isshared ? __getBlkInfo((*p).ptr) : null;
auto info = bic ? *bic : gc_query((*p).ptr);
auto size = ti.next.tsize;
Expand Down Expand Up @@ -822,7 +822,7 @@ extern (C) void[] _d_newarrayT(const TypeInfo ti, size_t length)
// update the length of the array
auto arrstart = __arrayStart(info);
memset(arrstart, 0, size);
auto isshared = ti.classinfo is TypeInfo_Shared.classinfo;
auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
__setArrayAllocLength(info, size, isshared);
result = arrstart[0..length];
}
Expand Down Expand Up @@ -900,7 +900,7 @@ extern (C) void[] _d_newarrayiT(const TypeInfo ti, size_t length)
memcpy(arrstart + u, q, isize);
}
}
auto isshared = ti.classinfo is TypeInfo_Shared.classinfo;
auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
__setArrayAllocLength(info, size, isshared);
result = arrstart[0..length];
}
Expand Down Expand Up @@ -937,7 +937,7 @@ void[] _d_newarrayOpT(alias op)(const TypeInfo ti, size_t ndims, va_list q)
{
auto allocsize = (void[]).sizeof * dim;
auto info = gc_qalloc(allocsize + __arrayPad(allocsize));
auto isshared = ti.classinfo is TypeInfo_Shared.classinfo;
auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
__setArrayAllocLength(info, allocsize, isshared);
auto p = __arrayStart(info)[0 .. dim];

Expand Down Expand Up @@ -1339,7 +1339,7 @@ body

debug(PRINTF) printf("newsize = %x, newlength = %x\n", newsize, newlength);

auto isshared = ti.classinfo is TypeInfo_Shared.classinfo;
auto isshared = typeid(ti) is typeid(TypeInfo_Shared);

if ((*p).ptr)
{
Expand Down Expand Up @@ -1519,7 +1519,7 @@ body


size_t size = (*p).length * sizeelem;
auto isshared = ti.classinfo is TypeInfo_Shared.classinfo;
auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
if ((*p).ptr)
{
newdata = (*p).ptr;
Expand Down Expand Up @@ -1799,7 +1799,7 @@ byte[] _d_arrayappendcTX(const TypeInfo ti, ref byte[] px, size_t n)

// only optimize array append where ti is not a shared type
auto sizeelem = ti.next.tsize; // array element size
auto isshared = ti.classinfo is TypeInfo_Shared.classinfo;
auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
auto bic = !isshared ? __getBlkInfo(px.ptr) : null;
auto info = bic ? *bic : gc_query(px.ptr);
auto length = px.length;
Expand Down Expand Up @@ -2025,7 +2025,7 @@ body
// do postblit processing
__doPostblit(p, xlen + ylen, ti.next);

auto isshared = ti.classinfo is TypeInfo_Shared.classinfo;
auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
__setArrayAllocLength(info, len, isshared);
return p[0 .. x.length + y.length];
}
Expand Down Expand Up @@ -2077,7 +2077,7 @@ extern (C) void[] _d_arraycatnT(const TypeInfo ti, uint n, ...)

auto allocsize = length * size;
auto info = gc_qalloc(allocsize + __arrayPad(allocsize), !(ti.next.flags & 1) ? BlkAttr.NO_SCAN | BlkAttr.APPENDABLE : BlkAttr.APPENDABLE);
auto isshared = ti.classinfo is TypeInfo_Shared.classinfo;
auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
__setArrayAllocLength(info, allocsize, isshared);
void *a = __arrayStart (info);

Expand Down Expand Up @@ -2151,7 +2151,7 @@ void* _d_arrayliteralTX(const TypeInfo ti, size_t length)
{
auto allocsize = length * sizeelem;
auto info = gc_qalloc(allocsize + __arrayPad(allocsize), !(ti.next.flags & 1) ? BlkAttr.NO_SCAN | BlkAttr.APPENDABLE : BlkAttr.APPENDABLE);
auto isshared = ti.classinfo is TypeInfo_Shared.classinfo;
auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
__setArrayAllocLength(info, allocsize, isshared);
result = __arrayStart(info);
}
Expand All @@ -2173,7 +2173,7 @@ extern (C) void* _d_arrayliteralT(const TypeInfo ti, size_t length, ...)
{
auto allocsize = length * sizeelem;
auto info = gc_qalloc(allocsize + __arrayPad(allocsize), !(ti.next.flags & 1) ? BlkAttr.NO_SCAN | BlkAttr.APPENDABLE : BlkAttr.APPENDABLE);
auto isshared = ti.classinfo is TypeInfo_Shared.classinfo;
auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
__setArrayAllocLength(info, allocsize, isshared);
result = __arrayStart(info);

Expand Down Expand Up @@ -2252,7 +2252,7 @@ body
auto sizeelem = ti.next.tsize; // array element size
auto size = a.length * sizeelem;
auto info = gc_qalloc(size + __arrayPad(size), !(ti.next.flags & 1) ? BlkAttr.NO_SCAN | BlkAttr.APPENDABLE : BlkAttr.APPENDABLE);
auto isshared = ti.classinfo is TypeInfo_Shared.classinfo;
auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
__setArrayAllocLength(info, size, isshared);
r.ptr = __arrayStart(info);
r.length = a.length;
Expand Down

0 comments on commit defd767

Please sign in to comment.