Search in sources :

Example 1 with ProcessSwitchCallback

use of org.springframework.cglib.core.ProcessSwitchCallback in project spring-framework by spring-projects.

the class Enhancer method emitSetCallback.

private void emitSetCallback(ClassEmitter ce, int[] keys) {
    final CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC, SET_CALLBACK, null);
    e.load_arg(0);
    e.process_switch(keys, new ProcessSwitchCallback() {

        public void processCase(int key, Label end) {
            e.load_this();
            e.load_arg(1);
            e.checkcast(callbackTypes[key]);
            e.putfield(getCallbackField(key));
            e.goTo(end);
        }

        public void processDefault() {
        // TODO: error?
        }
    });
    e.return_value();
    e.end_method();
}
Also used : CodeEmitter(org.springframework.cglib.core.CodeEmitter) ProcessSwitchCallback(org.springframework.cglib.core.ProcessSwitchCallback) Label(org.springframework.asm.Label)

Example 2 with ProcessSwitchCallback

use of org.springframework.cglib.core.ProcessSwitchCallback in project spring-framework by spring-projects.

the class Enhancer method emitGetCallback.

private void emitGetCallback(ClassEmitter ce, int[] keys) {
    final CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC, GET_CALLBACK, null);
    e.load_this();
    e.invoke_static_this(BIND_CALLBACKS);
    e.load_this();
    e.load_arg(0);
    e.process_switch(keys, new ProcessSwitchCallback() {

        public void processCase(int key, Label end) {
            e.getfield(getCallbackField(key));
            e.goTo(end);
        }

        public void processDefault() {
            // stack height
            e.pop();
            e.aconst_null();
        }
    });
    e.return_value();
    e.end_method();
}
Also used : CodeEmitter(org.springframework.cglib.core.CodeEmitter) ProcessSwitchCallback(org.springframework.cglib.core.ProcessSwitchCallback) Label(org.springframework.asm.Label)

Aggregations

Label (org.springframework.asm.Label)2 CodeEmitter (org.springframework.cglib.core.CodeEmitter)2 ProcessSwitchCallback (org.springframework.cglib.core.ProcessSwitchCallback)2