/*
Copyright (C) 2008, The Perl Foundation.
$Id: /mirror/trunk/languages/pipp/src/pmc/phpresource.pmc 30038 2008-08-04T17:05:46.431953Z fperrad  $

=head1 NAME

src/pmc/phpresource.pmc - PHP Resource

=head1 DESCRIPTION

=head2 Methods

=over 4

=cut

*/

#include "php_private.h"

pmclass PhpResource
    provides ref
    dynpmc
    group    php_group
    hll      PHP {

/*

=item C<void init()>

Raises an exception. Use C<init_pmc()>.

=cut

*/
    void init() {
        Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_INVALID_OPERATION,
                       "PhpResource init without pmc");
    }

/*

=item C<void init_pmc(PMC *initializer)>

Sets the referenced PMC to C<initializer>.

=cut

*/
    VTABLE void init_pmc(PMC *initializer) {
        PMC_pmc_val(SELF) = initializer;
        PObj_custom_mark_SET(SELF);
    }

/*

=item C<PMC *get_pmc()>

Get the referenced PMC.

=cut

*/
    VTABLE PMC *get_pmc() {
        return PMC_pmc_val(SELF);
    }

/*

=item C<void mark()>

Marks the referenced PMC as live.

=cut

*/
    VTABLE void mark() {
        pobject_lives(INTERP, (PObj *)PMC_pmc_val(SELF));
    }

/*

=item C<STRING* name()>

Return the string 'resource'.

=cut

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

/*

=item C<STRING *get_string()>

Returns a string representation of the resource.

=cut

*/
    VTABLE STRING *get_string() {
        return Parrot_sprintf_c(INTERP, "Resource id #%08X", SELF);
    }

/*

=back

=head2 non-Vtable Methods

=over 4

=item C<PMC* to_number()>

=cut

*/
    METHOD PMC* to_number() {
        RETURN(PMC *SELF);
    }

/*

=back

=head2 Specific Methods

=over 4

=cut

*/

}

/*

=back

=head1 AUTHORS

Francois Perrad.

=cut

*/


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