| 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 # distutils language = c++ | 5 # distutils language = c++ |
| 6 | 6 |
| 7 cimport c_core | 7 cimport c_core |
| 8 cimport c_export # needed so the init function gets exported |
| 9 cimport c_thunks |
| 8 | 10 |
| 9 | 11 |
| 10 from cpython.buffer cimport PyBUF_CONTIG | 12 from cpython.buffer cimport PyBUF_CONTIG |
| 11 from cpython.buffer cimport PyBUF_CONTIG_RO | 13 from cpython.buffer cimport PyBUF_CONTIG_RO |
| 12 from cpython.buffer cimport Py_buffer | 14 from cpython.buffer cimport Py_buffer |
| 13 from cpython.buffer cimport PyBuffer_FillInfo | 15 from cpython.buffer cimport PyBuffer_FillInfo |
| 14 from cpython.buffer cimport PyBuffer_Release | 16 from cpython.buffer cimport PyBuffer_Release |
| 15 from cpython.buffer cimport PyObject_GetBuffer | 17 from cpython.buffer cimport PyObject_GetBuffer |
| 16 from cpython.mem cimport PyMem_Malloc, PyMem_Free | 18 from cpython.mem cimport PyMem_Malloc, PyMem_Free |
| 17 from cpython.object cimport Py_EQ, Py_NE | 19 from cpython.object cimport Py_EQ, Py_NE |
| 18 from libc.stdint cimport int32_t, int64_t, uint32_t, uint64_t, uintptr_t | 20 from libc.stdint cimport int32_t, int64_t, uint32_t, uint64_t, uintptr_t |
| 19 | 21 |
| 20 import ctypes | 22 import ctypes |
| 21 import threading | 23 import threading |
| 22 | 24 |
| 23 import mojo.system_impl | 25 import mojo.system_impl |
| 24 | 26 |
| 25 def SetSystemThunks(system_thunks_as_object): | 27 def SetSystemThunks(system_thunks_as_object): |
| 26 """Bind the basic Mojo Core functions. | 28 """Bind the basic Mojo Core functions. |
| 27 | 29 |
| 28 This should only be used by the embedder. | 30 This should only be used by the embedder. |
| 29 """ | 31 """ |
| 30 cdef const c_core.MojoSystemThunks* system_thunks = ( | 32 cdef const c_thunks.MojoSystemThunks* system_thunks = ( |
| 31 <const c_core.MojoSystemThunks*><uintptr_t>system_thunks_as_object) | 33 <const c_thunks.MojoSystemThunks*><uintptr_t>system_thunks_as_object) |
| 32 c_core.MojoSetSystemThunks(system_thunks) | 34 c_thunks.MojoSetSystemThunks(system_thunks) |
| 33 mojo.system_impl.SetSystemThunks(system_thunks_as_object) | |
| 34 | 35 |
| 35 HANDLE_INVALID = c_core.MOJO_HANDLE_INVALID | 36 HANDLE_INVALID = c_core.MOJO_HANDLE_INVALID |
| 36 RESULT_OK = c_core.MOJO_RESULT_OK | 37 RESULT_OK = c_core.MOJO_RESULT_OK |
| 37 RESULT_CANCELLED = c_core.MOJO_RESULT_CANCELLED | 38 RESULT_CANCELLED = c_core.MOJO_RESULT_CANCELLED |
| 38 RESULT_UNKNOWN = c_core.MOJO_RESULT_UNKNOWN | 39 RESULT_UNKNOWN = c_core.MOJO_RESULT_UNKNOWN |
| 39 RESULT_INVALID_ARGUMENT = c_core.MOJO_RESULT_INVALID_ARGUMENT | 40 RESULT_INVALID_ARGUMENT = c_core.MOJO_RESULT_INVALID_ARGUMENT |
| 40 RESULT_DEADLINE_EXCEEDED = c_core.MOJO_RESULT_DEADLINE_EXCEEDED | 41 RESULT_DEADLINE_EXCEEDED = c_core.MOJO_RESULT_DEADLINE_EXCEEDED |
| 41 RESULT_NOT_FOUND = c_core.MOJO_RESULT_NOT_FOUND | 42 RESULT_NOT_FOUND = c_core.MOJO_RESULT_NOT_FOUND |
| 42 RESULT_ALREADY_EXISTS = c_core.MOJO_RESULT_ALREADY_EXISTS | 43 RESULT_ALREADY_EXISTS = c_core.MOJO_RESULT_ALREADY_EXISTS |
| 43 RESULT_PERMISSION_DENIED = c_core.MOJO_RESULT_PERMISSION_DENIED | 44 RESULT_PERMISSION_DENIED = c_core.MOJO_RESULT_PERMISSION_DENIED |
| (...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 """ | 794 """ |
| 794 return self.__run_loop.PostDelayedTask(runnable, delay) | 795 return self.__run_loop.PostDelayedTask(runnable, delay) |
| 795 | 796 |
| 796 @staticmethod | 797 @staticmethod |
| 797 def Current(): | 798 def Current(): |
| 798 if hasattr(_RUN_LOOPS, 'loop'): | 799 if hasattr(_RUN_LOOPS, 'loop'): |
| 799 return ctypes.cast(_RUN_LOOPS.loop, ctypes.py_object).value | 800 return ctypes.cast(_RUN_LOOPS.loop, ctypes.py_object).value |
| 800 return None | 801 return None |
| 801 | 802 |
| 802 | 803 |
| 803 _ASYNC_WAITER = mojo.system_impl.ASYNC_WAITER | 804 _ASYNC_WAITER = mojo.system_impl.AsyncWaiter() |
| OLD | NEW |