Commit 232e05c4 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #809 from Daetalus/capi_doc

add __doc__ attribute to capifunc
parents 0f4036af b8f4b5b7
...@@ -54,6 +54,14 @@ public: ...@@ -54,6 +54,14 @@ public:
return None; 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) { static void gcHandler(GCVisitor* v, Box* _o) {
assert(_o->cls == capifunc_cls); assert(_o->cls == capifunc_cls);
BoxedCApiFunction* o = static_cast<BoxedCApiFunction*>(_o); BoxedCApiFunction* o = static_cast<BoxedCApiFunction*>(_o);
......
...@@ -1637,6 +1637,8 @@ void setupCAPI() { ...@@ -1637,6 +1637,8 @@ void setupCAPI() {
capifunc_cls->tpp_call = BoxedCApiFunction::tppCall; capifunc_cls->tpp_call = BoxedCApiFunction::tppCall;
capifunc_cls->giveAttr("__name__", capifunc_cls->giveAttr("__name__",
new (pyston_getset_cls) BoxedGetsetDescriptor(BoxedCApiFunction::getname, NULL, NULL)); 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( capifunc_cls->giveAttr(
"__module__", new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, offsetof(BoxedCApiFunction, module))); "__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