class

Bindgen::Call::HookableBody

Inherits Bindgen::Call::Body < Reference < Object

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.

Instance methods

add_post_hook(hook : Body) : Nil

Adds hook to run after the #post_hook set already, if any.

Source
post_hook

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

Source
post_hook=(post_hook : Body | Nil)

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

Source
post_hook?(type : T.class) : Bool forall T

Returns if a post-hook of type type is set, alone or in a sequence.

Source
pre_hook

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

Source
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.

Source