diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/ScopedLocalRef.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/include/ScopedLocalRef.h b/include/ScopedLocalRef.h index 2cf4673..84ee11a 100644 --- a/include/ScopedLocalRef.h +++ b/include/ScopedLocalRef.h @@ -1,12 +1,12 @@ /* * Copyright (C) 2010 The Android Open Source Project - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,9 +20,10 @@ #include "JNIHelp.h" // A smart pointer that deletes a JNI local reference when it goes out of scope. +template<typename T> class ScopedLocalRef { public: - ScopedLocalRef(JNIEnv* env, jobject localRef) + ScopedLocalRef(JNIEnv* env, T localRef) : mEnv(env), mLocalRef(localRef) { } @@ -38,13 +39,13 @@ public: } } - jobject get() const { + T get() const { return mLocalRef; } private: JNIEnv* mEnv; - jobject mLocalRef; + T mLocalRef; // Disallow copy and assignment. ScopedLocalRef(const ScopedLocalRef&); |