Change ugly 'class member' to more normal 'instance'.

This commit is contained in:
Guido van Rossum 1991-04-04 10:42:10 +00:00
parent 374a92261b
commit 21ed88cfe2
1 changed files with 19 additions and 19 deletions

View File

@ -107,24 +107,24 @@ typeobject Classtype = {
}; };
/* We're not done yet: next, we define class member objects... */ /* We're not done yet: next, we define instance objects... */
typedef struct { typedef struct {
OB_HEAD OB_HEAD
classobject *cm_class; /* The class object */ classobject *cm_class; /* The class object */
object *cm_attr; /* A dictionary */ object *cm_attr; /* A dictionary */
} classmemberobject; } instanceobject;
object * object *
newclassmemberobject(class) newinstanceobject(class)
register object *class; register object *class;
{ {
register classmemberobject *cm; register instanceobject *cm;
if (!is_classobject(class)) { if (!is_classobject(class)) {
err_badcall(); err_badcall();
return NULL; return NULL;
} }
cm = NEWOBJ(classmemberobject, &Classmembertype); cm = NEWOBJ(instanceobject, &Instancetype);
if (cm == NULL) if (cm == NULL)
return NULL; return NULL;
INCREF(class); INCREF(class);
@ -137,11 +137,11 @@ newclassmemberobject(class)
return (object *)cm; return (object *)cm;
} }
/* Class member methods */ /* Instance methods */
static void static void
classmember_dealloc(cm) instance_dealloc(cm)
register classmemberobject *cm; register instanceobject *cm;
{ {
DECREF(cm->cm_class); DECREF(cm->cm_class);
if (cm->cm_attr != NULL) if (cm->cm_attr != NULL)
@ -150,8 +150,8 @@ classmember_dealloc(cm)
} }
static object * static object *
classmember_getattr(cm, name) instance_getattr(cm, name)
register classmemberobject *cm; register instanceobject *cm;
register char *name; register char *name;
{ {
register object *v = dictlookup(cm->cm_attr, name); register object *v = dictlookup(cm->cm_attr, name);
@ -173,8 +173,8 @@ classmember_getattr(cm, name)
} }
static int static int
classmember_setattr(cm, name, v) instance_setattr(cm, name, v)
classmemberobject *cm; instanceobject *cm;
char *name; char *name;
object *v; object *v;
{ {
@ -184,16 +184,16 @@ classmember_setattr(cm, name, v)
return dictinsert(cm->cm_attr, name, v); return dictinsert(cm->cm_attr, name, v);
} }
typeobject Classmembertype = { typeobject Instancetype = {
OB_HEAD_INIT(&Typetype) OB_HEAD_INIT(&Typetype)
0, 0,
"class member", "instance",
sizeof(classmemberobject), sizeof(instanceobject),
0, 0,
classmember_dealloc, /*tp_dealloc*/ instance_dealloc, /*tp_dealloc*/
0, /*tp_print*/ 0, /*tp_print*/
classmember_getattr, /*tp_getattr*/ instance_getattr, /*tp_getattr*/
classmember_setattr, /*tp_setattr*/ instance_setattr, /*tp_setattr*/
0, /*tp_compare*/ 0, /*tp_compare*/
0, /*tp_repr*/ 0, /*tp_repr*/
0, /*tp_as_number*/ 0, /*tp_as_number*/
@ -203,7 +203,7 @@ typeobject Classmembertype = {
/* And finally, here are class method objects */ /* And finally, here are class method objects */
/* (Really methods of class members) */ /* (Really methods of instances) */
typedef struct { typedef struct {
OB_HEAD OB_HEAD