Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MOJO_PUBLIC_PYTHON_SRC_COMMON_H_ | 5 #ifndef MOJO_PUBLIC_PYTHON_SRC_COMMON_H_ |
| 6 #define MOJO_PUBLIC_PYTHON_SRC_COMMON_H_ | 6 #define MOJO_PUBLIC_PYTHON_SRC_COMMON_H_ |
| 7 | 7 |
| 8 #include <Python.h> | 8 #include <Python.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 enum ScopedPyRefAcquire { | 32 enum ScopedPyRefAcquire { |
| 33 kAcquire, | 33 kAcquire, |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 class ScopedPyRef { | 36 class ScopedPyRef { |
| 37 public: | 37 public: |
| 38 explicit ScopedPyRef(PyObject* object); | 38 explicit ScopedPyRef(PyObject* object); |
| 39 ScopedPyRef(PyObject* object, ScopedPyRefAcquire); | 39 ScopedPyRef(PyObject* object, ScopedPyRefAcquire); |
| 40 ScopedPyRef(const ScopedPyRef& other); | |
|
etiennej
2015/02/24 13:30:23
Then, unless I am missing something, you don't nee
qsr
2015/02/24 13:32:14
As discussed offline, I do, as the return value fo
| |
| 40 | 41 |
| 41 ~ScopedPyRef(); | 42 ~ScopedPyRef(); |
| 42 | 43 |
| 43 // Releases ownership of the python object contained by this instance. | 44 // Releases ownership of the python object contained by this instance. |
| 44 PyObject* Release(); | 45 PyObject* Release(); |
| 45 | 46 |
| 46 operator PyObject*() const; | 47 operator PyObject*() const { return object_; } |
| 48 | |
| 49 ScopedPyRef& operator=(const ScopedPyRef& other); | |
| 47 | 50 |
| 48 private: | 51 private: |
| 49 PyObject* object_; | 52 PyObject* object_; |
| 50 | |
| 51 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedPyRef); | |
| 52 }; | 53 }; |
| 53 | 54 |
| 54 | 55 |
| 55 class PythonClosure : public mojo::Closure::Runnable { | 56 class PythonClosure : public mojo::Closure::Runnable { |
| 56 public: | 57 public: |
| 57 PythonClosure(PyObject* callable, const mojo::Closure& quit); | 58 PythonClosure(PyObject* callable, const mojo::Closure& quit); |
| 58 ~PythonClosure(); | 59 ~PythonClosure(); |
| 59 | 60 |
| 60 void Run() const override; | 61 void Run() const override; |
| 61 | 62 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 const mojo::Closure quit_; | 98 const mojo::Closure quit_; |
| 98 | 99 |
| 99 MOJO_DISALLOW_COPY_AND_ASSIGN(PythonAsyncWaiter); | 100 MOJO_DISALLOW_COPY_AND_ASSIGN(PythonAsyncWaiter); |
| 100 }; | 101 }; |
| 101 | 102 |
| 102 } // namespace python | 103 } // namespace python |
| 103 } // namespace mojo | 104 } // namespace mojo |
| 104 | 105 |
| 105 #endif // MOJO_PUBLIC_PYTHON_SRC_COMMON_H_ | 106 #endif // MOJO_PUBLIC_PYTHON_SRC_COMMON_H_ |
| 106 | 107 |
| OLD | NEW |