| parrotcode: Python Class | |
| Contents | Dynamic PMCs |

classes/pyclass.pmc - Python Class

These are the vtable functions for the Python Class base class (i.e., methods you would expect to see on python objects).

void destroy()PMC *find_method(STRING *method_name)*method_name and returns it.PMC *get_attr_str(STRING *name)name.PMC *get_class()INTVAL cmp(PMC *value)*value.INTVAL get_integer()PMC *get_iter()STRING *get_repr()STRING *get_string()INTVAL hash()void *invoke(void *next)STRING *name() STRING* name() {
return VTABLE_name(INTERP, VTABLE_get_class(INTERP, SELF));
}
STRING *"__repr__"(PMC *self) METHOD PMC* __repr__(PMC *self) {
PMC *res = pmc_new(INTERP, PyBuiltin_PyString);
STRING *repr;
repr = string_from_cstring(INTERP, "<", 0);
repr = string_append(INTERP, repr,
VTABLE_name(INTERP, VTABLE_get_class(INTERP, SELF)), 0);
repr = string_append(INTERP, repr,
const_string(INTERP, " instance at "), 0);
repr = string_append(INTERP, repr,
Parrot_sprintf_c(INTERP, "%#x", (INTVAL) SELF), 0);
repr = string_append(INTERP, repr,
const_string(INTERP, ">"), 0);
VTABLE_set_string_native(INTERP, res, repr);
return res;
}
|
|
|