abstract class Bindgen::Call::HookableBody

Overview

A body allowing to add additional code before and after the actual code body. This is useful to allow later processors to refine existing calls with additional logic. An example of this is the VirtualOverride processor, which uses this to augment #initialize methods setting the jump-table.

Note: The pre_hook and post_hook must be manually called in your #to_code implementation.

See CallBuilder::CrystalBinding::InvokeBody for an example of this.

Direct Known Subclasses

Defined in:

bindgen/call.cr

Instance Method Summary

Instance methods inherited from class Bindgen::Call::Body

to_code(call : Call, platform : Graph::Platform) : String to_code

Instance Method Detail

def post_hook : Body | Nil #

Code snippet ran after the body code itself. The result value is stored in a variable called result.


[View source]
def post_hook=(post_hook : Body | Nil) #

Code snippet ran after the body code itself. The result value is stored in a variable called result.


[View source]
def pre_hook : Body | Nil #

Code snippet ran before the body code itself. Access to the arguments of the body can be accessed directly by their name.


[View source]
def pre_hook=(pre_hook : Body | Nil) #

Code snippet ran before the body code itself. Access to the arguments of the body can be accessed directly by their name.


[View source]