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 #include "sky/engine/config.h" |
| 6 #include "sky/engine/bindings2/mojo_natives.h" |
| 7 |
5 #include <stdio.h> | 8 #include <stdio.h> |
6 #include <string.h> | 9 #include <string.h> |
7 #include <vector> | 10 #include <vector> |
8 | 11 |
9 #include "base/logging.h" | 12 #include "base/logging.h" |
10 #include "base/macros.h" | 13 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
12 #include "builtin.h" | |
13 #include "dart/runtime/include/dart_api.h" | 15 #include "dart/runtime/include/dart_api.h" |
14 #include "mojo/public/c/system/core.h" | 16 #include "mojo/public/c/system/core.h" |
15 #include "mojo/public/cpp/system/core.h" | 17 #include "mojo/public/cpp/system/core.h" |
| 18 #include "sky/engine/bindings2/builtin.h" |
| 19 #include "sky/engine/tonic/dart_converter.h" |
| 20 #include "sky/engine/tonic/dart_builtin.h" |
16 | 21 |
17 namespace blink { | 22 namespace blink { |
18 | 23 |
19 #define REGISTER_FUNCTION(name, count) \ | 24 #define REGISTER_FUNCTION(name, count) \ |
20 { "" #name, name, count }, | 25 { "" #name, name, count }, |
21 #define DECLARE_FUNCTION(name, count) \ | 26 #define DECLARE_FUNCTION(name, count) \ |
22 extern void name(Dart_NativeArguments args); | 27 extern void name(Dart_NativeArguments args); |
23 | 28 |
24 #define MOJO_NATIVE_LIST(V) \ | 29 #define MOJO_NATIVE_LIST(V) \ |
25 V(MojoSharedBuffer_Create, 2) \ | 30 V(MojoSharedBuffer_Create, 2) \ |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 static void SetNullReturn(Dart_NativeArguments arguments) { | 92 static void SetNullReturn(Dart_NativeArguments arguments) { |
88 Dart_SetReturnValue(arguments, Dart_Null()); | 93 Dart_SetReturnValue(arguments, Dart_Null()); |
89 } | 94 } |
90 | 95 |
91 static void SetInvalidArgumentReturn(Dart_NativeArguments arguments) { | 96 static void SetInvalidArgumentReturn(Dart_NativeArguments arguments) { |
92 Dart_SetIntegerReturnValue( | 97 Dart_SetIntegerReturnValue( |
93 arguments, static_cast<int64_t>(MOJO_RESULT_INVALID_ARGUMENT)); | 98 arguments, static_cast<int64_t>(MOJO_RESULT_INVALID_ARGUMENT)); |
94 } | 99 } |
95 | 100 |
96 static Dart_Handle MojoLib() { | 101 static Dart_Handle MojoLib() { |
97 return DartBuiltins::LookupLibrary("dart:mojo_core"); | 102 return DartBuiltin::LookupLibrary("dart:mojo_core"); |
98 } | 103 } |
99 | 104 |
100 static Dart_Handle SignalsStateToDart(Dart_Handle klass, | 105 static Dart_Handle SignalsStateToDart(Dart_Handle klass, |
101 const MojoHandleSignalsState& state) { | 106 const MojoHandleSignalsState& state) { |
102 Dart_Handle arg1 = Dart_NewInteger(state.satisfied_signals); | 107 Dart_Handle arg1 = Dart_NewInteger(state.satisfied_signals); |
103 Dart_Handle arg2 = Dart_NewInteger(state.satisfiable_signals); | 108 Dart_Handle arg2 = Dart_NewInteger(state.satisfiable_signals); |
104 Dart_Handle args[] = {arg1, arg2}; | 109 Dart_Handle args[] = {arg1, arg2}; |
105 return Dart_New(klass, Dart_Null(), 2, args); | 110 return Dart_New(klass, Dart_Null(), 2, args); |
106 } | 111 } |
107 | 112 |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 CHECK_INTEGER_ARGUMENT(arguments, 0, &control_handle, InvalidArgument); | 800 CHECK_INTEGER_ARGUMENT(arguments, 0, &control_handle, InvalidArgument); |
796 mojo_control_handle = control_handle; | 801 mojo_control_handle = control_handle; |
797 Dart_SetIntegerReturnValue(arguments, static_cast<int64_t>(MOJO_RESULT_OK)); | 802 Dart_SetIntegerReturnValue(arguments, static_cast<int64_t>(MOJO_RESULT_OK)); |
798 } | 803 } |
799 | 804 |
800 void MojoHandleWatcher_GetControlHandle(Dart_NativeArguments arguments) { | 805 void MojoHandleWatcher_GetControlHandle(Dart_NativeArguments arguments) { |
801 Dart_SetIntegerReturnValue(arguments, mojo_control_handle); | 806 Dart_SetIntegerReturnValue(arguments, mojo_control_handle); |
802 } | 807 } |
803 | 808 |
804 } // namespace blink | 809 } // namespace blink |
OLD | NEW |