Browse files

add getGCInfo

  • Loading branch information...
1 parent 8b501dc commit f957b4ef7222bae5da7f3b4104ab42061dd41319 @WalterBright WalterBright committed Apr 15, 2012
Showing with 29 additions and 18 deletions.
  1. +8 −4 import/object.di
  2. +21 −14 src/object_.d
View
12 import/object.di
@@ -80,6 +80,7 @@ class TypeInfo
void postblit(void* p);
@property size_t talign() nothrow pure const @safe;
version (X86_64) int argTypes(out TypeInfo arg1, out TypeInfo arg2) @safe nothrow;
+ immutable(void)* getGCInfo() nothrow pure const @safe;
}
class TypeInfo_Typedef : TypeInfo
@@ -154,11 +155,10 @@ class TypeInfo_Class : TypeInfo
void* deallocator;
OffsetTypeInfo[] m_offTi;
void* defaultConstructor;
- const(MemberInfo[]) function(string) xgetMembers;
+ immutable(void)* xgetGCInfo; // data for precise GC
static TypeInfo_Class find(in char[] classname);
Object create();
- const(MemberInfo[]) getMembers(in char[] classname);
@alexrp
D Programming Language member
alexrp added a note Apr 16, 2012

Unrelated change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
}
alias TypeInfo_Class ClassInfo;
@@ -181,8 +181,6 @@ class TypeInfo_Struct : TypeInfo
string function(in void*) xtoString;
uint m_flags;
-
- const(MemberInfo[]) function(in char[]) xgetMembers;
}
void function(void*) xdtor;
void function(void*) xpostblit;
@@ -194,6 +192,7 @@ class TypeInfo_Struct : TypeInfo
TypeInfo m_arg1;
TypeInfo m_arg2;
}
+ immutable(void)* xgetGCInfo;
}
class TypeInfo_Tuple : TypeInfo
@@ -620,3 +619,8 @@ bool _xopEquals(in void* ptr, in void* ptr);
void __ctfeWrite(T...)(auto ref T) {}
void __ctfeWriteln(T...)(auto ref T values) { __ctfeWrite(values, "\n"); }
+template GCInfo(T)
+{
+ enum GCInfo = cast(void*)0x12345678;
+}
+
View
35 src/object_.d
@@ -326,6 +326,10 @@ class TypeInfo
{ arg1 = this;
return 0;
}
+
+ /** Return info used by the garbage collector to do precise collection.
+ */
+ immutable(void)* getGCInfo() nothrow pure const @safe { return null; }
}
class TypeInfo_Vector : TypeInfo
@@ -388,6 +392,8 @@ class TypeInfo_Typedef : TypeInfo
{ return base.argTypes(arg1, arg2);
}
+ override immutable(void)* getGCInfo() { return base.getGCInfo(); }
+
TypeInfo base;
string name;
void[] m_init;
@@ -845,7 +851,9 @@ class TypeInfo_Class : TypeInfo
void* deallocator;
OffsetTypeInfo[] m_offTi;
void function(Object) defaultConstructor; // default Constructor
- const(MemberInfo[]) function(in char[]) xgetMembers;
+
+ immutable(void)* xgetGCInfo; // data for precise GC
+ override immutable(void)* getGCInfo() { return xgetGCInfo; }
/**
* Search all modules for TypeInfo_Class corresponding to classname.
@@ -883,17 +891,6 @@ class TypeInfo_Class : TypeInfo
}
return o;
}
-
- /**
- * Search for all members with the name 'name'.
- * If name[] is null, return all members.
- */
- const(MemberInfo[]) getMembers(in char[] name)
- {
- if (m_flags & 16 && xgetMembers)
- return xgetMembers(name);
- return null;
- }
}
alias TypeInfo_Class ClassInfo;
@@ -1058,14 +1055,14 @@ class TypeInfo_Struct : TypeInfo
char[] function(in void*) xtoString;
uint m_flags;
-
- const(MemberInfo[]) function(in char[]) xgetMembers;
}
void function(void*) xdtor;
void function(void*) xpostblit;
uint m_align;
+ override immutable(void)* getGCInfo() { return xgetGCInfo; }
+
version (X86_64)
{
override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
@@ -1076,6 +1073,7 @@ class TypeInfo_Struct : TypeInfo
TypeInfo m_arg1;
TypeInfo m_arg2;
}
+ immutable(void)* xgetGCInfo; // data for precise GC
}
unittest
@@ -2511,3 +2509,12 @@ bool _xopEquals(in void*, in void*)
{
throw new Error("TypeInfo.equals is not implemented");
}
+
+/******************************************
+ * Create GCInfo for type T
+ */
+
+template GCInfo(T)
+{
+ enum GCInfo = null;
+}

0 comments on commit f957b4e

Please sign in to comment.