pub struct Customizer<'cls> { /* private fields */ }Expand description
Customize the output for each Gfx macro, and extract data from each macro.
This allows extending or replacing the normal functionality of gfxd by
registering callbacks for each specific situation.
Each callback is passed a reference of either MacroInfo, Printer,
and/or MacroPrinter which allows to inspect the contents of the current
macro or write output to the output buffer.
There are 3 major groups for the registered callbacks:
before_after_execution_callback: Callbacks that will be called before and after the currentgfxdexecution.macro_fn: Replace or extend the behavior for each specific macro.- Argument callbacks: Callbacks that will be executed when certain types of macros are encountered.
Implementations§
Source§impl Customizer<'_>
impl Customizer<'_>
Source§impl<'cls> Customizer<'cls>
impl<'cls> Customizer<'cls>
Sourcepub fn before_after_execution_callback<B, A>(
&mut self,
before: &'cls mut B,
after: &'cls mut A,
) -> &mut Self
pub fn before_after_execution_callback<B, A>( &mut self, before: &'cls mut B, after: &'cls mut A, ) -> &mut Self
Register callbacks that are called before and after the execution of
gfxd.
Allows to do some setup work for the output buffer, like writing opening and closing braces.
before is called before gfxd starts executing, so the output buffer
will be empty at this point. after is called once gfxd finishes
running, and it is the very last code that is run before returning the
disassembled output to the user.
Both callbacks are called only once.
§Examples
use gfxd_rs::{Customizer, Printer};
let mut before = |printer: &mut Printer| {
printer.write_str("{\n");
};
let mut after = |printer: &mut Printer| {
printer.write_str("}\n");
};
let mut customizer = Customizer::new();
customizer.before_after_execution_callback(&mut before, &mut after);Source§impl<'cls> Customizer<'cls>
impl<'cls> Customizer<'cls>
Sourcepub fn macro_fn<F>(&mut self, callback: &'cls mut F) -> &mut Self
pub fn macro_fn<F>(&mut self, callback: &'cls mut F) -> &mut Self
Replace the default macro handler.
The user-defined macro handler may decide to extend the default
behavior by writing custom output with write_str and calling the
original macro handler by calling macro_dflt.
§Example
Make the output pretier
use gfxd_rs::{Customizer, MacroPrinter};
let mut macro_fn = |printer: &mut MacroPrinter, _info: &mut _| {
/* Print 4 spaces before each macro, and a comma and newline after each macro */
printer.write_str(" ");
let ret = printer.macro_dflt(); /* Execute the default macro handler */
printer.write_str(",\n");
ret
};
let mut customizer = Customizer::new();
customizer.macro_fn(&mut macro_fn);Sourcepub fn arg_fn<F>(&mut self, callback: &'cls mut F) -> &mut Self
pub fn arg_fn<F>(&mut self, callback: &'cls mut F) -> &mut Self
Replace the default argument handler.
The registered callback will be called by macro_dflt for each
argument in the current macro, not counting the dynamic display list
pointer if one has been specified.
If the user has overriden the macro handler function and does not call
macro_dflt in the replacement, then the given callback will never
be called.
Source§impl<'cls> Customizer<'cls>
impl<'cls> Customizer<'cls>
Sourcepub fn tlut_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
pub fn tlut_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
Register a callback for TLUTs (Texture Look Up Table), a.k.a. palettes.
The callback may return DoDefaultOutput::DoDefault to make gfxd
to emit the default output for this argument, or
DoDefaultOutput::Override to avoid emitting the default one and
just use whatever the user printed.
Emit any desired output by using the Printer argument, and inspect
information about the current macro with the MacroInfo argument.
The other arguments are:
- the tlut address,
- the palette index and
- the number of colors.
Sourcepub fn timg_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
pub fn timg_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
Register a callback for textures of any kind.
The callback may return DoDefaultOutput::DoDefault to make gfxd
to emit the default output for this argument, or
DoDefaultOutput::Override to avoid emitting the default one and
just use whatever the user printed.
Emit any desired output by using the Printer argument, and inspect
information about the current macro with the MacroInfo argument.
The other arguments are:
- the texture address,
- the texture format,
- the texture siz,
- the width,
- the height and
- the palette index.
Sourcepub fn cimg_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
pub fn cimg_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
Register a callback for framebuffers.
The callback may return DoDefaultOutput::DoDefault to make gfxd
to emit the default output for this argument, or
DoDefaultOutput::Override to avoid emitting the default one and
just use whatever the user printed.
Emit any desired output by using the Printer argument, and inspect
information about the current macro with the MacroInfo argument.
The other arguments are:
- the framebuffer address,
- the framebuffer format,
- the framebuffer siz and
- the width.
Sourcepub fn zimg_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
pub fn zimg_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
Register a callback for depthbuffers.
The callback may return DoDefaultOutput::DoDefault to make gfxd
to emit the default output for this argument, or
DoDefaultOutput::Override to avoid emitting the default one and
just use whatever the user printed.
Emit any desired output by using the Printer argument, and inspect
information about the current macro with the MacroInfo argument.
The other arguments are:
- the depthbuffer address.
Sourcepub fn dl_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
pub fn dl_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
Register a callback for display lists.
The callback may return DoDefaultOutput::DoDefault to make gfxd
to emit the default output for this argument, or
DoDefaultOutput::Override to avoid emitting the default one and
just use whatever the user printed.
Emit any desired output by using the Printer argument, and inspect
information about the current macro with the MacroInfo argument.
The other arguments are:
- the display list address.
Sourcepub fn mtx_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
pub fn mtx_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
Register a callback for matrices.
The callback may return DoDefaultOutput::DoDefault to make gfxd
to emit the default output for this argument, or
DoDefaultOutput::Override to avoid emitting the default one and
just use whatever the user printed.
Emit any desired output by using the Printer argument, and inspect
information about the current macro with the MacroInfo argument.
The other arguments are:
- the matrix address.
Sourcepub fn lookat_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
pub fn lookat_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
Register a callback for lookat arrays.
The callback may return DoDefaultOutput::DoDefault to make gfxd
to emit the default output for this argument, or
DoDefaultOutput::Override to avoid emitting the default one and
just use whatever the user printed.
Emit any desired output by using the Printer argument, and inspect
information about the current macro with the MacroInfo argument.
The other arguments are:
- the lookat array address and
- the number of lookat structures.
Sourcepub fn light_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
pub fn light_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
Register a callback for lights.
The callback may return DoDefaultOutput::DoDefault to make gfxd
to emit the default output for this argument, or
DoDefaultOutput::Override to avoid emitting the default one and
just use whatever the user printed.
Emit any desired output by using the Printer argument, and inspect
information about the current macro with the MacroInfo argument.
The other arguments are:
- the light address.
Sourcepub fn lightsn_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
pub fn lightsn_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
Register a callback for lights N.
The callback may return DoDefaultOutput::DoDefault to make gfxd
to emit the default output for this argument, or
DoDefaultOutput::Override to avoid emitting the default one and
just use whatever the user printed.
Emit any desired output by using the Printer argument, and inspect
information about the current macro with the MacroInfo argument.
The other arguments are:
- the light address and
- the number of diffuse lights.
Sourcepub fn seg_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
pub fn seg_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
Register a callback for segments.
The callback may return DoDefaultOutput::DoDefault to make gfxd
to emit the default output for this argument, or
DoDefaultOutput::Override to avoid emitting the default one and
just use whatever the user printed.
Emit any desired output by using the Printer argument, and inspect
information about the current macro with the MacroInfo argument.
The other arguments are:
- the segment address.
Sourcepub fn vtx_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
pub fn vtx_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
Register a callback for vertices.
The callback may return DoDefaultOutput::DoDefault to make gfxd
to emit the default output for this argument, or
DoDefaultOutput::Override to avoid emitting the default one and
just use whatever the user printed.
Emit any desired output by using the Printer argument, and inspect
information about the current macro with the MacroInfo argument.
The other arguments are:
- the vertex address.
Sourcepub fn vp_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
pub fn vp_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
Register a callback for viewports.
The callback may return DoDefaultOutput::DoDefault to make gfxd
to emit the default output for this argument, or
DoDefaultOutput::Override to avoid emitting the default one and
just use whatever the user printed.
Emit any desired output by using the Printer argument, and inspect
information about the current macro with the MacroInfo argument.
The other arguments are:
- the viewport address.
Sourcepub fn uctext_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
pub fn uctext_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
Register a callback for microcode text.
The callback may return DoDefaultOutput::DoDefault to make gfxd
to emit the default output for this argument, or
DoDefaultOutput::Override to avoid emitting the default one and
just use whatever the user printed.
Emit any desired output by using the Printer argument, and inspect
information about the current macro with the MacroInfo argument.
The other arguments are:
- the microcode text address and
- the microcode text size.
Sourcepub fn ucdata_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
pub fn ucdata_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
Register a callback for microcode data.
The callback may return DoDefaultOutput::DoDefault to make gfxd
to emit the default output for this argument, or
DoDefaultOutput::Override to avoid emitting the default one and
just use whatever the user printed.
Emit any desired output by using the Printer argument, and inspect
information about the current macro with the MacroInfo argument.
The other arguments are:
- the microcode data address and
- the microcode data size.
Sourcepub fn dram_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
pub fn dram_callback<F>(&mut self, callback: &'cls mut F) -> &mut Self
Register a callback for generic pointers.
The callback may return DoDefaultOutput::DoDefault to make gfxd
to emit the default output for this argument, or
DoDefaultOutput::Override to avoid emitting the default one and
just use whatever the user printed.
Emit any desired output by using the Printer argument, and inspect
information about the current macro with the MacroInfo argument.
The other arguments are:
- the generic pointer and
- the data size.