#include <security_utilities/cfclass.h>
#include <security_utilities/seccfobject.h>
#include <security_utilities/threading.h>
CFClass::CFClass(const char *name, bool deferDeletion) : isDeferrable(deferDeletion)
{
version = 0;
className = name;
init = NULL;
copy = NULL;
finalize = finalizeType;
equal = equalType;
hash = hashType;
copyFormattingDesc = copyFormattingDescType;
copyDebugDesc = copyDebugDescType;
typeID = _CFRuntimeRegisterClass(this);
assert(typeID != _kCFRuntimeNotATypeID);
}
void
CFClass::finalizeType(CFTypeRef cf) throw()
{
SecCFObject *obj = SecCFObject::optional(cf);
if (!obj->isNew())
{
try {
obj->~SecCFObject();
} catch (...) {}
}
}
Boolean
CFClass::equalType(CFTypeRef cf1, CFTypeRef cf2) throw()
{
return SecCFObject::optional(cf1)->equal(*SecCFObject::optional(cf2));
}
CFHashCode
CFClass::hashType(CFTypeRef cf) throw()
{
return SecCFObject::optional(cf)->hash();
}
CFStringRef
CFClass::copyFormattingDescType(CFTypeRef cf, CFDictionaryRef dict) throw()
{
return SecCFObject::optional(cf)->copyFormattingDesc(dict);
}
CFStringRef
CFClass::copyDebugDescType(CFTypeRef cf) throw()
{
return SecCFObject::optional(cf)->copyDebugDesc();
}