• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.tools.layoutlib.create;
18 
19 
20 /**
21  * Interface to allow a method invocation to be listened upon.
22  * <p/>
23  * This is used by {@link OverrideMethod} to register a listener for methods that
24  * have been stubbed by the {@link AsmGenerator}. At runtime the stub will call either a
25  * default global listener or a specific listener based on the method signature.
26  */
27 public interface MethodListener {
28     /**
29      * A stub method is being invoked.
30      * <p/>
31      * Known limitation: caller arguments are not available.
32      *
33      * @param signature The signature of the method being invoked, composed of the
34      *                  binary class name followed by the method descriptor (aka argument
35      *                  types). Example: "com/foo/MyClass/InnerClass/printInt(I)V".
36      * @param isNative True if the method was a native method.
37      * @param caller The calling object. Null for static methods, "this" for instance methods.
38      */
onInvokeV(String signature, boolean isNative, Object caller)39     void onInvokeV(String signature, boolean isNative, Object caller);
40 
41     /**
42      * Same as {@link #onInvokeV(String, boolean, Object)} but returns an integer or similar.
43      * @see #onInvokeV(String, boolean, Object)
44      * @return an integer, or a boolean, or a short or a byte.
45      */
onInvokeI(String signature, boolean isNative, Object caller)46     int onInvokeI(String signature, boolean isNative, Object caller);
47 
48     /**
49      * Same as {@link #onInvokeV(String, boolean, Object)} but returns a long.
50      * @see #onInvokeV(String, boolean, Object)
51      * @return a long.
52      */
onInvokeL(String signature, boolean isNative, Object caller)53     long onInvokeL(String signature, boolean isNative, Object caller);
54 
55     /**
56      * Same as {@link #onInvokeV(String, boolean, Object)} but returns a float.
57      * @see #onInvokeV(String, boolean, Object)
58      * @return a float.
59      */
onInvokeF(String signature, boolean isNative, Object caller)60     float onInvokeF(String signature, boolean isNative, Object caller);
61 
62     /**
63      * Same as {@link #onInvokeV(String, boolean, Object)} but returns a double.
64      * @see #onInvokeV(String, boolean, Object)
65      * @return a double.
66      */
onInvokeD(String signature, boolean isNative, Object caller)67     double onInvokeD(String signature, boolean isNative, Object caller);
68 
69     /**
70      * Same as {@link #onInvokeV(String, boolean, Object)} but returns an object.
71      * @see #onInvokeV(String, boolean, Object)
72      * @return an object.
73      */
onInvokeA(String signature, boolean isNative, Object caller)74     Object onInvokeA(String signature, boolean isNative, Object caller);
75 }
76