|
Perl 6
SMOP OO API: Revision 13
In order to ensure the interoperability among object representations and even between different object systems that uses the same representation. In this context we need to define the HOW and REPR API, this is the SMOP OO API that allows representations to be interchanged, and custom BUILD methods to be written. The interesting aspect is that all this methods must be called in the object itself in SMOP, and that's why they have the "^" and "^^" prefixes, where the first mean a HOW call, and the second means a REPR call. It is important to stress that the REPR API is SMOP specific, whereas the HOW API is supposed to be transversal to Perl 6 implementations. Object APIThis is what is implemented by Object
method new($prototype: *@protoobjects, *%initialize) {...};
method bless($prototype: $candidate?, *@protoobjects, *%initialize) {...};
submethod CREATE($prototype: :$repr) {...};
submethod BUILDALL($object: *@protoobjects, *%initialize) {...};
submethod BUILD($object: *@protoobjects, *%initialize) {...};
HOW APIThis is the instrospection API, that is available as standard Perl 6 and modify the current object.
method ^CREATE($object: ) {...}; # this assumes the same representation as the given object
method ^methods($object: ) {...};
method ^add_method($object: $name, $method) {...};
method ^set_isa($object: $superclass) {...};
method ^add_isa($object: $superclass) {...};
method ^add_role($object: $role) {...};
REPR APIThis is SMOP specific, and it isn't part of the standard Perl 6, however, this is how different representations can coexist in SMOP. This only operates in the specific object, it doesn't look to any of the superclasses, that might even have a different representation.
submethod ^^CREATE($prototype: ) {...};
submethod ^^bless($direct_prototype: $object) {...};
submethod ^^get_direct_prototype($object: ) {...};
submethod ^^add_isa($object: $new_superclass) {...};
submethod ^^del_isa($object: $unwanted_superclass) {...};
submethod ^^isa_count($object: ) {...};
submethod ^^isa_at($object: int $index) {...};
submethod ^^add_role($object: $new_role) {...};
submethod ^^del_role($object: $unwanted_role) {...};
submethod ^^role_count($object: ) {...};
submethod ^^role_at($object: int $index) {...};
submethod ^^add_private_storage($object: $package, $name, $container) {...};
submethod ^^get_private_storage($object: $package, $name) {...};
submethod ^^del_private_storage($object: $package) {...};
submethod ^^private_storage_package_count($object: ) {...};
submethod ^^private_storage_package_at($object: int $index) {...};
submethod ^^private_storage_count($object: $package) {...};
submethod ^^private_storage_name_at($object: $package, int $index) {...};
submethod ^^add_class_storage($prototype: $name, $container) {...};
submethod ^^get_class_storage($prototype: $name) {...};
submethod ^^del_class_storage($prototype: $name) {...};
submethod ^^class_storage_count($prototype: {...};
submethod ^^class_storage_name_at($prototype: int $index) {...};
submethod ^^add_method_definition($prototype: $method) {...};
submethod ^^del_method_definition($prototype: $method) {...};
submethod ^^method_definition_count_matching($prototype: $name) {...};
submethod ^^method_definition_at_matching($prototype: $name, int $index) {...};
submethod ^^method_definition_count($prototype: ) {...};
submethod ^^method_definition_at($prototype: int $index) {...};
submethod ^^add_attribute_definition($prototype: $attribute) {...};
submethod ^^get_attribute_definition($prototype: $name) {...};
submethod ^^del_attribute_definition($prototype: $name) {...};
submethod ^^attribute_definition_count($prototype: ) {...};
submethod ^^attribute_definition_at($prototype: int $index) {...};
submethod ^^add_submethod_definition($prototype: $submethod) {...};
submethod ^^del_submethod_definition($prototype: $submethod) {...};
submethod ^^submethod_definition_count_matching($prototype: $name) {...};
submethod ^^submethod_definition_at_matching($prototype: $name, int $index) {...};
submethod ^^submethod_definition_count($prototype: ) {...};
submethod ^^submethod_definition_at($prototype: int $index) {...};
submethod ^^get_whence($object: ) {...};
submethod ^^set_whence($object: $whence) {...};
submethod ^^properties($object: ) {...};
|