IHandlerListDecorator.java 1.91 KB
/*
 * This file is part of LiteLoader.
 * Copyright (C) 2012-16 Adam Mummery-Smith
 * All Rights Reserved.
 */
package com.mumfrey.liteloader.core.event;

import java.util.List;

import org.spongepowered.asm.lib.Type;
import org.spongepowered.asm.lib.tree.ClassNode;
import org.spongepowered.asm.lib.tree.MethodNode;

import com.mumfrey.liteloader.core.event.HandlerList.BakedHandlerList;
import com.mumfrey.liteloader.core.runtime.Obf;

/**
 * Essentially a "mini plugin" for HandlerListClassLoader which allows
 * alterations of the generated bytecode.
 * 
 * @author Adam Mummery-Smith
 *
 * @param <T>
 */
public interface IHandlerListDecorator<T>
{
    /**
     * Get the template class name
     */
    public abstract Obf getTemplate();

    /**
     * Prepare the decorator to accept the specified list of invokees
     */
    public abstract void prepare(List<T> sortedList);

    /**
     * Create an instance of the handler class
     */
    public abstract BakedHandlerList<T> createInstance(Class<BakedHandlerList<T>> handlerClass) throws Exception;

    /**
     * Called when populating the classNode
     */
    public abstract void populateClass(String name, ClassNode classNode);

    /**
     * Called when processing the ctor
     */
    public abstract void processCtor(ClassNode classNode, MethodNode method);

    /**
     * Called immediately before the interface method invocation bytecode is
     * injected.
     */
    public abstract void preInvokeInterfaceMethod(int handlerIndex, ClassNode classNode, MethodNode method, Type[] args);

    /**
     * Called immediately after the interface method invocation bytecode is
     * injected.
     */
    public abstract void postInvokeInterfaceMethod(int handlerIndex, ClassNode classNode, MethodNode method, Type[] args);

    /**
     * Called at the end of populateInterfaceMethod
     */
    public abstract void populateInterfaceMethod(ClassNode classNode, MethodNode method);
}