summaryrefslogtreecommitdiffstats
path: root/Python/structmember.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1991-10-20 20:24:14 (GMT)
committerGuido van Rossum <guido@python.org>1991-10-20 20:24:14 (GMT)
commit2f1d87e9c2d0c1c5ae9c8a21d7bac31ff1d9f123 (patch)
tree3ae02263e56c78870c7cfe23218fe93e4b24ce70 /Python/structmember.c
parent85f50769628af33809c321f829948af3f0db77cc (diff)
downloadcpython-2f1d87e9c2d0c1c5ae9c8a21d7bac31ff1d9f123.zip
cpython-2f1d87e9c2d0c1c5ae9c8a21d7bac31ff1d9f123.tar.gz
cpython-2f1d87e9c2d0c1c5ae9c8a21d7bac31ff1d9f123.tar.bz2
Added __members__ secret attribute
Diffstat (limited to 'Python/structmember.c')
-rw-r--r--Python/structmember.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/Python/structmember.c b/Python/structmember.c
index 03b4dcc..acdf9c6 100644
--- a/Python/structmember.c
+++ b/Python/structmember.c
@@ -28,6 +28,29 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "structmember.h"
+static object *
+listmembers(mlist)
+ struct memberlist *mlist;
+{
+ int i, n;
+ object *v;
+ for (n = 0; mlist[n].name != NULL; n++)
+ ;
+ v = newlistobject(n);
+ if (v != NULL) {
+ for (i = 0; i < n; i++)
+ setlistitem(v, i, newstringobject(mlist[i].name));
+ if (err_occurred()) {
+ DECREF(v);
+ v = NULL;
+ }
+ else {
+ sortlist(v);
+ }
+ }
+ return v;
+}
+
object *
getmember(addr, mlist, name)
char *addr;
@@ -36,6 +59,8 @@ getmember(addr, mlist, name)
{
struct memberlist *l;
+ if (strcmp(name, "__members__") == 0)
+ return listmembers(mlist);
for (l = mlist; l->name != NULL; l++) {
if (strcmp(l->name, name) == 0) {
object *v;