static Box* property_copy(BoxedProperty* old, Box* get, Box* set, Box* del) { RELEASE_ASSERT(isSubclass(old->cls, property_cls), ""); if (!get || get == Py_None) get = old->prop_get; if (!set || set == Py_None) set = old->prop_set; if (!del || del == Py_None) del = old->prop_del; // Optimization for the case when the old propery is not subclassed if (old->cls == property_cls) { BoxedProperty* prop = new BoxedProperty(get, set, del, old->prop_doc); prop->getter_doc = false; if ((old->getter_doc && get != Py_None) || !old->prop_doc) propertyDocCopy(prop, get); return prop; } else { if (!get) get = Py_None; if (!set) set = Py_None; if (!del) del = Py_None; Box* doc; if ((old->getter_doc && get != Py_None) || !old->prop_doc) doc = Py_None; else doc = old->prop_doc; return runtimeCall(old->cls, ArgPassSpec(4), get, set, del, &doc, NULL); } }
static Box* propertyInit(Box* _self, Box* fget, Box* fset, Box** args) { RELEASE_ASSERT(isSubclass(_self->cls, property_cls), ""); Box* fdel = args[0]; Box* doc = args[1]; BoxedProperty* self = static_cast<BoxedProperty*>(_self); Box* prev_get = self->prop_get; Box* prev_set = self->prop_set; Box* prev_del = self->prop_del; Box* prev_doc = self->prop_doc; self->prop_get = fget == Py_None ? NULL : incref(fget); self->prop_set = fset == Py_None ? NULL : incref(fset); self->prop_del = fdel == Py_None ? NULL : incref(fdel); self->prop_doc = xincref(doc); self->getter_doc = false; Py_XDECREF(prev_get); Py_XDECREF(prev_set); Py_XDECREF(prev_del); Py_XDECREF(prev_doc); /* if no docstring given and the getter has one, use that one */ if ((doc == NULL || doc == Py_None) && fget != NULL) { propertyDocCopy(self, fget); } return incref(Py_None); }
static Box* propertyInit(Box* _self, Box* fget, Box* fset, Box** args) { RELEASE_ASSERT(isSubclass(_self->cls, property_cls), ""); Box* fdel = args[0]; Box* doc = args[1]; BoxedProperty* self = static_cast<BoxedProperty*>(_self); self->prop_get = fget; self->prop_set = fset; self->prop_del = fdel; self->prop_doc = doc; self->getter_doc = false; /* if no docstring given and the getter has one, use that one */ if ((doc == NULL || doc == None) && fget != NULL) { propertyDocCopy(self, fget); } return None; }