* Convenience macros and prototypes for the various handle types we define
*/
-inline OBJECTHANDLE CreateTypedHandle(HHANDLETABLE table, OBJECTREF object, int type)
-{
- WRAPPER_NO_CONTRACT;
-
- return HndCreateHandle(table, type, object);
-}
-
inline void DestroyTypedHandle(OBJECTHANDLE handle)
{
WRAPPER_NO_CONTRACT;
HndDestroyHandleOfUnknownType(HndGetHandleTable(handle), handle);
}
-inline OBJECTHANDLE CreateHandle(HHANDLETABLE table, OBJECTREF object)
-{
- WRAPPER_NO_CONTRACT;
-
- return HndCreateHandle(table, HNDTYPE_DEFAULT, object);
-}
-
inline void DestroyHandle(OBJECTHANDLE handle)
{
CONTRACTL
return HndCreateHandle(HndGetHandleTable(handle), HNDTYPE_DEFAULT, HndFetchHandle(handle));
}
-
-inline OBJECTHANDLE CreateWeakHandle(HHANDLETABLE table, OBJECTREF object)
-{
- WRAPPER_NO_CONTRACT;
-
- return HndCreateHandle(table, HNDTYPE_WEAK_DEFAULT, object);
-}
-
inline void DestroyWeakHandle(OBJECTHANDLE handle)
{
WRAPPER_NO_CONTRACT;
HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_WEAK_DEFAULT, handle);
}
-inline OBJECTHANDLE CreateShortWeakHandle(HHANDLETABLE table, OBJECTREF object)
-{
- WRAPPER_NO_CONTRACT;
-
- return HndCreateHandle(table, HNDTYPE_WEAK_SHORT, object);
-}
-
inline void DestroyShortWeakHandle(OBJECTHANDLE handle)
{
WRAPPER_NO_CONTRACT;
HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_WEAK_SHORT, handle);
}
-
-inline OBJECTHANDLE CreateLongWeakHandle(HHANDLETABLE table, OBJECTREF object)
-{
- WRAPPER_NO_CONTRACT;
-
- return HndCreateHandle(table, HNDTYPE_WEAK_LONG, object);
-}
-
inline void DestroyLongWeakHandle(OBJECTHANDLE handle)
{
WRAPPER_NO_CONTRACT;
typedef Holder<OBJECTHANDLE,DoNothing<OBJECTHANDLE>,DestroyLongWeakHandle> LongWeakHandleHolder;
#endif
-inline OBJECTHANDLE CreateStrongHandle(HHANDLETABLE table, OBJECTREF object)
-{
- WRAPPER_NO_CONTRACT;
-
- return HndCreateHandle(table, HNDTYPE_STRONG, object);
-}
-
inline void DestroyStrongHandle(OBJECTHANDLE handle)
{
WRAPPER_NO_CONTRACT;
HndDestroyHandle(HndGetHandleTable(handle), HNDTYPE_STRONG, handle);
}
-inline OBJECTHANDLE CreatePinningHandle(HHANDLETABLE table, OBJECTREF object)
-{
- WRAPPER_NO_CONTRACT;
-
- return HndCreateHandle(table, HNDTYPE_PINNED, object);
-}
-
inline void DestroyPinningHandle(OBJECTHANDLE handle)
{
WRAPPER_NO_CONTRACT;
typedef Wrapper<OBJECTHANDLE, DoNothing<OBJECTHANDLE>, DestroyPinningHandle, NULL> PinningHandleHolder;
#endif
-inline OBJECTHANDLE CreateAsyncPinningHandle(HHANDLETABLE table, OBJECTREF object)
-{
- WRAPPER_NO_CONTRACT;
-
- return HndCreateHandle(table, HNDTYPE_ASYNCPINNED, object);
-}
-
inline void DestroyAsyncPinningHandle(OBJECTHANDLE handle)
{
WRAPPER_NO_CONTRACT;
typedef Wrapper<OBJECTHANDLE, DoNothing<OBJECTHANDLE>, DestroyAsyncPinningHandle, NULL> AsyncPinningHandleHolder;
#endif
-inline OBJECTHANDLE CreateSizedRefHandle(HHANDLETABLE table, OBJECTREF object)
-{
- WRAPPER_NO_CONTRACT;
-
- return HndCreateHandle(table, HNDTYPE_SIZEDREF, object, (uintptr_t)0);
-}
-
void DestroySizedRefHandle(OBJECTHANDLE handle);
#ifndef FEATURE_REDHAWK
#endif
#ifdef FEATURE_COMINTEROP
-inline OBJECTHANDLE CreateRefcountedHandle(HHANDLETABLE table, OBJECTREF object)
-{
- WRAPPER_NO_CONTRACT;
-
- return HndCreateHandle(table, HNDTYPE_REFCOUNTED, object);
-}
inline void DestroyRefcountedHandle(OBJECTHANDLE handle)
{
return UNCHECKED_OBJECTREF_TO_OBJECTREF(*PTR_UNCHECKED_OBJECTREF(handle));
}
+#ifndef DACCESS_COMPILE
+
+inline OBJECTHANDLE CreateWeakHandle(HHANDLETABLE table, OBJECTREF object)
+{
+ return GCHeapUtilities::GetGCHandleTable()->CreateHandleOfType(table, OBJECTREFToObject(object), HNDTYPE_WEAK_DEFAULT);
+}
+
+inline OBJECTHANDLE CreateShortWeakHandle(HHANDLETABLE table, OBJECTREF object)
+{
+ return GCHeapUtilities::GetGCHandleTable()->CreateHandleOfType(table, OBJECTREFToObject(object), HNDTYPE_WEAK_SHORT);
+}
+
+inline OBJECTHANDLE CreateLongWeakHandle(HHANDLETABLE table, OBJECTREF object)
+{
+ return GCHeapUtilities::GetGCHandleTable()->CreateHandleOfType(table, OBJECTREFToObject(object), HNDTYPE_WEAK_LONG);
+}
+
+inline OBJECTHANDLE CreateHandle(HHANDLETABLE table, OBJECTREF object)
+{
+ return GCHeapUtilities::GetGCHandleTable()->CreateHandleOfType(table, OBJECTREFToObject(object), HNDTYPE_DEFAULT);
+}
+
+inline OBJECTHANDLE CreateStrongHandle(HHANDLETABLE table, OBJECTREF object)
+{
+ return GCHeapUtilities::GetGCHandleTable()->CreateHandleOfType(table, OBJECTREFToObject(object), HNDTYPE_STRONG);
+}
+
+inline OBJECTHANDLE CreatePinningHandle(HHANDLETABLE table, OBJECTREF object)
+{
+ return GCHeapUtilities::GetGCHandleTable()->CreateHandleOfType(table, OBJECTREFToObject(object), HNDTYPE_PINNED);
+}
+
+inline OBJECTHANDLE CreateSizedRefHandle(HHANDLETABLE table, OBJECTREF object)
+{
+ return GCHeapUtilities::GetGCHandleTable()->CreateHandleOfType(table, OBJECTREFToObject(object), HNDTYPE_SIZEDREF);
+}
+
+inline OBJECTHANDLE CreateAsyncPinningHandle(HHANDLETABLE table, OBJECTREF object)
+{
+ return GCHeapUtilities::GetGCHandleTable()->CreateHandleOfType(table, OBJECTREFToObject(object), HNDTYPE_ASYNCPINNED);
+}
+
+inline OBJECTHANDLE CreateRefcountedHandle(HHANDLETABLE table, OBJECTREF object)
+{
+ return GCHeapUtilities::GetGCHandleTable()->CreateHandleOfType(table, OBJECTREFToObject(object), HNDTYPE_REFCOUNTED);
+}
+
+#endif // !DACCESS_COMPILE
+
#endif // _GCHEAPUTILITIES_H_