/*
Copyright (C) 2008, The Perl Foundation.
$Id: /mirror/trunk/languages/pipp/src/pmc/phpboolean.pmc 30457 2008-08-21T17:01:26.101883Z cotto  $

=head1 NAME

pmc/phpboolean.pmc - PHP Boolean

=head1 DESCRIPTION

=head2 Methods

=over 4

=cut

*/

#include "php_private.h"

pmclass PhpBoolean
    extends  Boolean
    provides scalar
    provides boolean
    provides integer
    dynpmc
    group    php_group
    hll      PHP
    maps     Boolean {

/*

=item C<STRING* name()>

Return the string 'boolean'.

=cut

*/
    STRING* name() {
        return const_string(INTERP, "boolean");
    }

/*

=item C<STRING* get_string()>

Return the string '1' or ''.

=cut

*/
    STRING* get_string() {
        if (PMC_int_val(SELF))
            return const_string(INTERP, "1");
        else
            return const_string(INTERP, "");
    }


/*

=back

=head2 non-Vtable Methods

=over 4

=item C<STRING* serialize()>

Return a representation of this boolean in the same format as PHP's serialize function.

=cut

*/

    METHOD STRING* serialize() {
        STRING *serialized;
        serialized = string_printf(INTERP, "b:%d;", VTABLE_get_integer(INTERP, SELF));
        RETURN(STRING *serialized);
    }


/*

=back

=head2 Specific Methods

=over 4

=item C<PMC* to_number()>

=cut

*/
    METHOD PMC* to_number() {
        PMC     *retval = pmc_new(INTERP, dynpmc_PhpInteger);
        INTVAL  val = SELF.get_integer();
        VTABLE_set_integer_native(INTERP, retval, val);
        RETURN(PMC *retval);
    }

}

/*

=back

=head1 AUTHORS

Francois Perrad.

=cut

*/


/*
 * Local variables:
 *   c-file-style: "parrot"
 * End:
 * vim: expandtab shiftwidth=4:
 */
