This project has retired. For details please refer to its Attic page.
Clownfish::Class – C API Documentation
Apache Lucy™

Clownfish::Class

parcel Clownfish
class variable CFISH_CLASS
struct symbol cfish_Class
class nickname cfish_Class
header file Clownfish/Class.h

Name

Clownfish::Class – Class.

Description

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

Functions

singleton
cfish_Class*
cfish_Class_singleton(
    cfish_String *class_name,
    cfish_Class *parent
);

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 NULL, an attempt will be made to find it. If the attempt fails, an error will result.

fetch_class
cfish_Class*
cfish_Class_fetch_class(
    cfish_String *class_name
);

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

Methods

Override
void
cfish_Class_Override(
    cfish_Class *self,
    cfish_method_t method_ptr,
    uint32_t offset
);

Replace a function pointer in the Class’s vtable.

Make_Obj
cfish_Obj* // incremented
cfish_Class_Make_Obj(
    cfish_Class *self
);

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.

Init_Obj
cfish_Obj* // incremented
cfish_Class_Init_Obj(
    cfish_Class *self,
    void *allocation
);

Take a raw memory allocation which is presumed to be of adequate size, assign its class and give it an initial refcount of 1.

Get_Name
cfish_String*
cfish_Class_Get_Name(
    cfish_Class *self
);

Return the name of the class.

Get_Parent
cfish_Class*
cfish_Class_Get_Parent(
    cfish_Class *self
);

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

Get_Obj_Alloc_Size
uint32_t
cfish_Class_Get_Obj_Alloc_Size(
    cfish_Class *self
);

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

Inheritance

Clownfish::Class is a Clownfish::Obj.