NAME

Clownfish::Class - Class.

SYNOPSIS

my $class = Clownfish::Class->fetch_class('Foo::Bar');
my $subclass = Clownfish::Class->singleton('Foo::Bar::Jr', $class);

DESCRIPTION

Classes are first-class objects in Clownfish. Class objects are instances of Clownfish::Class.

CONSTRUCTORS

fetch_class

my $class = Clownfish::Class->fetch_class($class_name);

Find a registered class. May return undef if the class is not registered.

singleton

my $class = Clownfish::Class->singleton(
    class_name => $class_name,  # required
    parent     => $parent,      # required
);

Return a singleton. If a Class can be found in the registry based on the supplied class name, it will be returned. Otherwise, a new Class will be created using parent as a base.

If parent is undef, an attempt will be made to find it. If the attempt fails, an error will result.

METHODS

make_obj

my $obj = $class->make_obj();

Create an empty object of the type defined by the Class: allocate, assign its class and give it an initial refcount of 1. The caller is responsible for initialization.

get_name

my $string = $class->get_name();

Return the name of the class.

get_parent

my $result = $class->get_parent();

Return the parent class, or undef for a root of the class hierarchy.

get_obj_alloc_size

my $int = $class->get_obj_alloc_size();

Return the number of bytes needed to hold an instance of the class.

INHERITANCE

Clownfish::Class isa Clownfish::Obj.