Commit 71e9cdff authored by asaka's avatar asaka

add __name__ attr to dictkeys/dictvalues/dictitems

parent 5947a680
...@@ -512,6 +512,13 @@ void setupDict() { ...@@ -512,6 +512,13 @@ void setupDict() {
dict_iterator_cls->giveAttr("next", new BoxedFunction(boxRTFunction((void*)dictIterNext, UNKNOWN, 1))); dict_iterator_cls->giveAttr("next", new BoxedFunction(boxRTFunction((void*)dictIterNext, UNKNOWN, 1)));
dict_iterator_cls->freeze(); dict_iterator_cls->freeze();
dict_keys_cls->giveAttr("__name__", boxStrConstant("dictkeys"));
dict_keys_cls->freeze();
dict_values_cls->giveAttr("__name__", boxStrConstant("dictvalues"));
dict_values_cls->freeze();
dict_items_cls->giveAttr("__name__", boxStrConstant("dictitems"));
dict_items_cls->freeze();
} }
void teardownDict() { void teardownDict() {
......
...@@ -48,16 +48,19 @@ Box* dictIterNext(Box* self); ...@@ -48,16 +48,19 @@ Box* dictIterNext(Box* self);
class BoxedDictKeys : public Box { class BoxedDictKeys : public Box {
public: public:
BoxedDict* d;
BoxedDictKeys(BoxedDict* d); BoxedDictKeys(BoxedDict* d);
}; };
class BoxedDictValues : public Box { class BoxedDictValues : public Box {
public: public:
BoxedDict* d;
BoxedDictValues(BoxedDict* d); BoxedDictValues(BoxedDict* d);
}; };
class BoxedDictItems : public Box { class BoxedDictItems : public Box {
public: public:
BoxedDict* d;
BoxedDictItems(BoxedDict* d); BoxedDictItems(BoxedDict* d);
}; };
......
...@@ -72,13 +72,13 @@ Box* dictIterNext(Box* s) { ...@@ -72,13 +72,13 @@ Box* dictIterNext(Box* s) {
return rtn; return rtn;
} }
BoxedDictKeys::BoxedDictKeys(BoxedDict* d) : Box(dict_keys_cls) { BoxedDictKeys::BoxedDictKeys(BoxedDict* d) : Box(dict_keys_cls), d(d) {
} }
BoxedDictValues::BoxedDictValues(BoxedDict* d) : Box(dict_values_cls) { BoxedDictValues::BoxedDictValues(BoxedDict* d) : Box(dict_values_cls), d(d) {
} }
BoxedDictItems::BoxedDictItems(BoxedDict* d) : Box(dict_items_cls) { BoxedDictItems::BoxedDictItems(BoxedDict* d) : Box(dict_items_cls), d(d) {
} }
} }
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