NAME

src/pmc/packfileview.pmc - PackfileView PMC

DESCRIPTION

This class implements a user-accessible wrapper for the PackFile* structure used internally by Parrot. It is essentially an interface for the user to call Packfile subsystem API calls, and work with the PackFile* structures output from utilities which generate them.

VTABLES

static PackFile_ConstTable * get_const_table(PARROT_INTERP, PMC * self)
Get the constant table for the PackFile*. Return NULL if there's a problem.
static INTVAL find_called_tag(PARROT_INTERP, PMC * self, STRING * tag)
Find a called tag in the cache. Return 1 if it exists, 0 otherwise.
static void add_called_tag(PARROT_INTERP, PMC * self, STRING * tag)
Add a called tag to the cache, if it doesn't exist already. Do nothing otherwise.
VTABLE void init()
Create the new PMC and set flags
VTABLE void destroy()
Destroy the PMC *AND* the underlying PackFile*
VTABLE void mark()
Mark the PMC and the PackFile* contents
VTABLE void set_pointer(void *ptr)
Set a pointer to a PackFile* structure. This can only be done once. Attempting to set a new pointer will throw an exception. This rule is in place because the lifetime of the PackFile* is tied to the lifetime of the PMC wrapping it, and the PMC provides access to the PackFile* by the GC. Overwriting a pointer to an old PackFile* structure will cause memory leaks, prematurely collected Subs, and other creepy behaviors.
VTABLE void *get_pointer()
Get a pointer to the underlying PackFile* structure
VTABLE INTVAL get_bool()
Return 1 (true) if this PMC is currently pointing to a PackFile*. 0 (false) otherwise.
VTABLE void set_string_native(STRING *path)
VTABLE STRING *get_string_native(STRING *path)
VTABLE PMC *get_pmc_keyed_int(INTVAL idx)
Get a PMC from the constants table, by index
VTABLE STRING *get_string_keyed_int(INTVAL idx)
Get a STRING from the constants table, by index
VTABLE FLOATVAL get_number_keyed_int(INTVAL idx)
Get a FLOATVAL from the constants table, by index

METHODS

METHOD constant_counts()
Return a 3-element FixedIntegerArray with the total number of FLOATVAL, STRING and PMC constants in the respective constant tables.
METHOD main_sub()
Get the :main sub from the packfile, if any.
METHOD trigger(STRING *flag)
Trigger subs with the given flag. Currently supported values are "load" and "init".
METHOD all_subs()
Return a ResizablePMCArray with all Sub constants from the constant table.
METHOD serialized_size()
Return the size, in bytes, for how large this packfile will be if serialized.
METHOD serialize()
Serialize the packfile into a STRING buffer
METHOD deserialize(STRING *pbc)
Read a PackFile* in from a STRING buffer and set it as the current PackFile* ptr in this PMC. Subject to the normal set_pointer restrictions.
METHOD read_from_file(STRING *filename)
Read a PackFile* from the given .pbc file and set it as the current PackFile* pointer in this PMC. Subject to the same restrictions as set_pointer.
METHOD write_to_file(STRING *filename)
Serialize the contents of the PackFile in this PMC and write them out to the given .pbc bytecode file.
METHOD get_version()
Return a stringified version number of the packfile