NAME
src/pmc/packfileview.pmc - PackfileView PMC
DESCRIPTION
This class implements a user-accessible, read-only 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.
NOTICE: This PMC should contain very little logic. It should be a thin wrapper around the public functions in src/packfile/api.c. This PMC should contain absolutely NO functionality for modifying the packfile. To create a new packfile or modify an existing one, use the PackFile PMC instead.
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 subs_by_tag(STRING *tag)
Get an array of all Subs with the given tag.
METHOD trigger(STRING *flag)
Trigger subs with the given flag.
Currently supported values are "load" and "init".
METHOD all_tags()
Return an array of all tags.
METHOD all_tagged_pmcs()
Return a hash map of all tags,
and the lists of pmcs with those tags.
METHOD all_subs()
Return a ResizablePMCArray with all Sub constants from the constant table.item 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
METHOD mark_initialized(STRING *tag)
Mark a given tag as being initializeditem METHOD is_initialized(STRING *tag)
Determine if the given tag has been marked initialized