Skip to content
This repository
tag: RELEASE_0_4_7
Fetching contributors…

Cannot retrieve contributors at this time

file 144 lines (89 sloc) 2.155 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
/*
Copyright (C) 2001-2003, The Perl Foundation.
$Id$

=head1 NAME

src/pmc/parrotlibrary.pmc - Dynamic Library

=head1 DESCRIPTION

Class for holding info about a dynamic library.

     PMC data
     PMC_struct_val(SELF) oplib init function
     PMC_data(SELF) DLL handle

Properties:

    _filename full path/file of lib
    _ro true after init

All ParrotLibrary PMCs are in interp->iglobals.

When a dynamic library (pmc or ops) is loaded, the load function returns
a ParrotLibrary PMC.

=head2 Methods

=over 4

=cut

*/

#include "parrot/parrot.h"

pmclass ParrotLibrary need_ext does library const_too {

/*

=item C<void init()>

Initializes the library with a C<NULL> oplib init function.

=cut

*/

    void init() {
        PMC_struct_val(SELF) = NULL;
    }

/*

=item C<void morph(INTVAL type)>

Morphs to C<type>.

=cut

*/

    void morph(INTVAL type) {
        SUPER(type);
    }

/*

=item C<PMC *clone()>

Creates and returns a clone of the library.

=cut

*/

    PMC* clone() {
        PMC* dest = pmc_new_noinit(INTERP, SELF->vtable->base_type);
        PMC_struct_val(dest) = PMC_struct_val(SELF);
        PMC_data(dest) = PMC_data(SELF);
        if (PMC_metadata(SELF)) {
            PMC_metadata(dest) = VTABLE_clone(INTERP, PMC_metadata(SELF));
        }
        return dest;
    }

/*

=item C<INTVAL get_bool()>

Returns whether a library has been successfully loaded.

=cut

*/

    INTVAL get_bool() {
        return ( PMC_data(SELF) != NULL );
    }

/*

=item C<STRING* get_string()>

Returns the name of the loaded library.

=cut

*/

    STRING* get_string() {
        PMC *prop;
        STRING *key;
        key = const_string(INTERP, "_filename");
        prop = VTABLE_getprop(INTERP, SELF, key);
        return VTABLE_get_string(INTERP, prop);
    }

}

/*

=back

=head1 SEE ALSO

    Date: Mon, 29 Sep 2003 14:37:11 -0400 (EDT)
    Subject: Library loading and initialization sequence
    From: Dan Sugalski

=head1 HISTORY

Initial version by leo 2003.10.12.

=cut

*/

/*
 * Local variables:
 * c-file-style: "parrot"
 * End:
 * vim: expandtab shiftwidth=4:
 */
Something went wrong with that request. Please try again.