Commit b8f4b5b7 authored by Boxiang Sun's avatar Boxiang Sun

add __doc__ attribute to capifunc

parent 264540c8
......@@ -54,6 +54,14 @@ public:
return None;
}
static Box* doc(Box* b, void*) {
RELEASE_ASSERT(b->cls == capifunc_cls, "");
const char* s = static_cast<BoxedCApiFunction*>(b)->method_def->ml_doc;
if (s)
return boxString(s);
return None;
}
static void gcHandler(GCVisitor* v, Box* _o) {
assert(_o->cls == capifunc_cls);
BoxedCApiFunction* o = static_cast<BoxedCApiFunction*>(_o);
......
......@@ -1637,6 +1637,8 @@ void setupCAPI() {
capifunc_cls->tpp_call = BoxedCApiFunction::tppCall;
capifunc_cls->giveAttr("__name__",
new (pyston_getset_cls) BoxedGetsetDescriptor(BoxedCApiFunction::getname, NULL, NULL));
capifunc_cls->giveAttr("__doc__",
new (pyston_getset_cls) BoxedGetsetDescriptor(BoxedCApiFunction::doc, NULL, NULL));
capifunc_cls->giveAttr(
"__module__", new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, offsetof(BoxedCApiFunction, module)));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment