NAME

Clownfish::Type - A variable's type.

METHODS

new

my $type = MyType->new(
    specifier   => 'char',    # default undef
    indirection => undef,     # default 0
    const       => 1,         # default undef
    parcel      => undef,     # default undef
    c_string    => undef,     # default undef
);

Abstract constructor.

  • specifier - The C name for the type, not including any indirection or array subscripts.

  • indirection - integer indicating level of indirection. Example: the C type "float**" has a specifier of "float" and indirection 2.

  • const - should be true if the type is const.

  • parcel - A Clownfish::Parcel or a parcel name.

  • c_string - The C representation of the type.

equals

do_stuff() if $type->equals($other);

Returns true if two Clownfish::Type objects are equivalent. The default implementation merely checks that $other is a Clownfish::Type object, so it should be overridden in all subclasses.

to_c

# Declare variable "foo".
print $type->to_c . " foo;\n";

Return the C representation of the type.

set_c_string

Set the C representation of the type.

get_specifier get_parcel const nullable

Accessors.

is_object is_primitive is_integer is_floating is_composite is_void

do_stuff() if $type->is_object;

Shorthand for various $type->isa($package) calls.

  • is_object: Clownfish::Type::Object

  • is_primitive: Clownfish::Type::Primitive

  • is_integer: Clownfish::Type::Integer

  • is_floating: Clownfish::Type::Float

  • is_void: Clownfish::Type::Void

  • is_composite: Clownfish::Type::Composite

is_string_type

Returns true if $type represents a Clownfish type which holds unicode strings.

COPYRIGHT AND LICENSE

Copyright 2008-2011 Marvin Humphrey

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.