Index: third_party/protobuf/src/google/protobuf/stubs/callback.h |
diff --git a/third_party/protobuf/src/google/protobuf/stubs/callback.h b/third_party/protobuf/src/google/protobuf/stubs/callback.h |
index 87271c5eb8f58692cc967c9dbdc3c9814810c6c6..9ec049795579ad3778bda77c0daf51f476576d21 100644 |
--- a/third_party/protobuf/src/google/protobuf/stubs/callback.h |
+++ b/third_party/protobuf/src/google/protobuf/stubs/callback.h |
@@ -346,6 +346,29 @@ struct InternalConstRef { |
typedef const base_type& type; |
}; |
+template<typename R, typename T> |
+class MethodResultCallback_0_0 : public ResultCallback<R> { |
+ public: |
+ typedef R (T::*MethodType)(); |
+ MethodResultCallback_0_0(T* object, MethodType method, bool self_deleting) |
+ : object_(object), |
+ method_(method), |
+ self_deleting_(self_deleting) {} |
+ ~MethodResultCallback_0_0() {} |
+ |
+ R Run() { |
+ bool needs_delete = self_deleting_; |
+ R result = (object_->*method_)(); |
+ if (needs_delete) delete this; |
+ return result; |
+ } |
+ |
+ private: |
+ T* object_; |
+ MethodType method_; |
+ bool self_deleting_; |
+}; |
+ |
template <typename R, typename T, typename P1, typename P2, typename P3, |
typename P4, typename P5, typename A1, typename A2> |
class MethodResultCallback_5_2 : public ResultCallback2<R, A1, A2> { |
@@ -381,6 +404,8 @@ class MethodResultCallback_5_2 : public ResultCallback2<R, A1, A2> { |
typename remove_reference<P5>::type p5_; |
}; |
+} // namespace internal |
+ |
// See Closure. |
inline Closure* NewCallback(void (*function)()) { |
return new internal::FunctionClosure0(function, true); |
@@ -518,6 +543,13 @@ inline ResultCallback1<R, A1>* NewPermanentCallback( |
function, false, p1); |
} |
+// See MethodResultCallback_0_0 |
+template <typename R, typename T1, typename T2> |
+inline ResultCallback<R>* NewPermanentCallback( |
+ T1* object, R (T2::*function)()) { |
+ return new internal::MethodResultCallback_0_0<R, T1>(object, function, false); |
+} |
+ |
// See MethodResultCallback_5_2 |
template <typename R, typename T, typename P1, typename P2, typename P3, |
typename P4, typename P5, typename A1, typename A2> |
@@ -533,8 +565,6 @@ inline ResultCallback2<R, A1, A2>* NewPermanentCallback( |
p2, p3, p4, p5); |
} |
-} // namespace internal |
- |
// A function which does nothing. Useful for creating no-op callbacks, e.g.: |
// Closure* nothing = NewCallback(&DoNothing); |
void LIBPROTOBUF_EXPORT DoNothing(); |