public static IntPtr tp_descr_get(IntPtr ds, IntPtr ob, IntPtr tp) {
FieldObject self = (FieldObject)GetManagedObject(ds);
Object result;
if (self == null) {
return IntPtr.Zero;
}
FieldInfo info = self.info;
if ((ob == IntPtr.Zero) || (ob == Runtime.PyNone)) {
if (!info.IsStatic) {
Exceptions.SetError(Exceptions.TypeError,
"instance attribute must be accessed " +
"through a class instance"
);
return IntPtr.Zero;
}
try {
result = info.GetValue(null);
return Converter.ToPython(result, info.FieldType);
}
catch(Exception e) {
Exceptions.SetError(Exceptions.TypeError, e.Message);
return IntPtr.Zero;
}
}
try {
CLRObject co = (CLRObject)GetManagedObject(ob);
result = info.GetValue(co.inst);
return Converter.ToPython(result, info.FieldType);
}
catch(Exception e) {
Exceptions.SetError(Exceptions.TypeError, e.Message);
return IntPtr.Zero;
}
}