| 1 | /***************************************************************************** |
| 2 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | you may not use this file except in compliance with the License. |
| 4 | You may obtain a copy of the License at |
| 5 | |
| 6 | http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | |
| 8 | Unless required by applicable law or agreed to in writing, software |
| 9 | distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | See the License for the specific language governing permissions and |
| 12 | limitations under the License. |
| 13 | |
| 14 | See NOTICE file for details. |
| 15 | *****************************************************************************/ |
| 16 | #ifndef _JPTYPE_MANAGER_H_ |
| 17 | #define _JPTYPE_MANAGER_H_ |
| 18 | |
| 19 | /** |
| 20 | * These functions will manage the cache of found type, be it primitive types, class types or the "magic" types. |
| 21 | */ |
| 22 | |
| 23 | class JPTypeManager |
| 24 | { |
| 25 | friend class JPContext; |
| 26 | public: |
| 27 | |
| 28 | /** |
| 29 | * Initialize the type manager caches |
| 30 | */ |
| 31 | explicit JPTypeManager(JPJavaFrame& frame); |
| 32 | ~JPTypeManager() = default; |
| 33 | |
| 34 | /** |
| 35 | * Find a class using a native name. |
| 36 | * |
| 37 | * The pointer returned is NOT owned by the caller |
| 38 | */ |
| 39 | JPClass* findClass(jclass cls); |
| 40 | JPClass* findClassByName(const string& str); |
| 41 | JPClass* findClassForObject(jobject obj); |
| 42 | void populateMethod(void* method, jobject obj); |
| 43 | void populateMembers(JPClass* cls); |
| 44 | int interfaceParameterCount(JPClass* cls); |
| 45 | |
| 46 | private: |
| 47 | JPObjectRef m_JavaTypeManager; |
| 48 | jmethodID m_FindClass; |
| 49 | jmethodID m_FindClassByName; |
| 50 | jmethodID m_FindClassForObject; |
| 51 | jmethodID m_PopulateMethod; |
| 52 | jmethodID m_PopulateMembers; |
| 53 | jmethodID m_InterfaceParameterCount; |
| 54 | } ; |
| 55 | |
| 56 | #endif // _JPCLASS_H_ |