| 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 from libc.stdint cimport uintptr_t | 7 from libc.stdint cimport uintptr_t |
| 8 from libcpp cimport bool | 8 from libcpp cimport bool |
| 9 | 9 |
| 10 import mojo_system | 10 import mojo_system |
| 11 import mojo_system_impl | 11 import mojo_system_impl |
| 12 | 12 |
| 13 cdef extern from "third_party/cython/python_export.h": | 13 cdef extern from "third_party/cython/python_export.h": |
| 14 pass | 14 pass |
| 15 | 15 |
| 16 cdef extern from "base/memory/scoped_ptr.h": | 16 # TODO(vtl): More recent versions of cython have a libcpp.memory with |
| 17 cdef cppclass scoped_ptr[T]: | 17 # |unique_ptr|. |
| 18 scoped_ptr(T*) | 18 cdef extern from "<memory>" \ |
| 19 namespace "std" nogil: |
| 20 cdef cppclass unique_ptr[T]: |
| 21 unique_ptr(T*) |
| 19 | 22 |
| 20 cdef extern from "mojo/edk/embedder/platform_support.h" \ | 23 cdef extern from "mojo/edk/embedder/platform_support.h" \ |
| 21 namespace "mojo::embedder" nogil: | 24 namespace "mojo::embedder" nogil: |
| 22 cdef cppclass PlatformSupport: | 25 cdef cppclass PlatformSupport: |
| 23 pass | 26 pass |
| 24 | 27 |
| 25 cdef extern from "mojo/edk/embedder/simple_platform_support.h" \ | 28 cdef extern from "mojo/edk/embedder/simple_platform_support.h" \ |
| 26 namespace "mojo::embedder" nogil: | 29 namespace "mojo::embedder" nogil: |
| 27 cdef cppclass SimplePlatformSupport(PlatformSupport): | 30 cdef cppclass SimplePlatformSupport(PlatformSupport): |
| 28 SimplePlatformSupport() | 31 SimplePlatformSupport() |
| 29 | 32 |
| 30 cdef extern from "mojo/edk/embedder/embedder.h" nogil: | 33 cdef extern from "mojo/edk/embedder/embedder.h" nogil: |
| 31 cdef void InitCEmbedder "mojo::embedder::Init"( | 34 cdef void InitCEmbedder "mojo::embedder::Init"( |
| 32 scoped_ptr[PlatformSupport] platform_support) | 35 unique_ptr[PlatformSupport] platform_support) |
| 33 | 36 |
| 34 cdef extern from "mojo/public/platform/native/system_thunks.h" nogil: | 37 cdef extern from "mojo/public/platform/native/system_thunks.h" nogil: |
| 35 cdef struct MojoSystemThunks: | 38 cdef struct MojoSystemThunks: |
| 36 pass | 39 pass |
| 37 cdef MojoSystemThunks MojoMakeSystemThunks() | 40 cdef MojoSystemThunks MojoMakeSystemThunks() |
| 38 | 41 |
| 39 cdef extern from "mojo/edk/embedder/test_embedder.h" nogil: | 42 cdef extern from "mojo/edk/embedder/test_embedder.h" nogil: |
| 40 cdef bool ShutdownCEmbedderForTest "mojo::embedder::test::Shutdown"() | 43 cdef bool ShutdownCEmbedderForTest "mojo::embedder::test::Shutdown"() |
| 41 | 44 |
| 42 def Init(): | 45 def Init(): |
| 43 InitCEmbedder(scoped_ptr[PlatformSupport]( | 46 InitCEmbedder(unique_ptr[PlatformSupport](new SimplePlatformSupport())) |
| 44 new SimplePlatformSupport())) | |
| 45 cdef MojoSystemThunks thunks = MojoMakeSystemThunks() | 47 cdef MojoSystemThunks thunks = MojoMakeSystemThunks() |
| 46 mojo_system.SetSystemThunks(<uintptr_t>(&thunks)) | 48 mojo_system.SetSystemThunks(<uintptr_t>(&thunks)) |
| 47 mojo_system_impl.SetSystemThunks(<uintptr_t>(&thunks)) | 49 mojo_system_impl.SetSystemThunks(<uintptr_t>(&thunks)) |
| 48 | 50 |
| 49 def ShutdownForTest(): | 51 def ShutdownForTest(): |
| 50 return ShutdownCEmbedderForTest() | 52 return ShutdownCEmbedderForTest() |
| OLD | NEW |