NAME ^

classes/pyclass.pmc - Python Class

DESCRIPTION ^

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

Methods ^

void destroy()

Destroys the object.

PMC *find_method(STRING *method_name)

Looks up the method for *method_name and returns it.

PMC *get_attr_str(STRING *name)

Return attribute named name.

PMC *get_class()

Return the class of this object.

INTVAL cmp(PMC *value)

Returns the result of comparing the integer with *value.

INTVAL get_integer()

Returns the integer value of the object.

PMC *get_iter()

Return an iterator for this object.

STRING *get_repr()

Return the representation of this object.

STRING *get_string()

Return the object in string form.

INTVAL hash()

Returns a unique hash for this value

void *invoke(void *next)

Call the object.

STRING *name()

Returns the name of this class.

*/

    STRING* name() {
        return VTABLE_name(INTERP, VTABLE_get_class(INTERP, SELF));
    }
/*

STRING *"__repr__"(PMC *self)

Return the string representation of this instance.

*/

    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;
    }
/*


parrot