Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: mojo/dart/embedder/common.cc

Issue 1786473004: Rolls Dart runtime forward. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: whitespace Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/dart/embedder/common.h ('k') | mojo/dart/embedder/io/filter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stdint.h> 5 #include <stdint.h>
6 #include <string.h> 6 #include <string.h>
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "mojo/dart/embedder/common.h" 9 #include "mojo/dart/embedder/common.h"
10 #include "mojo/public/cpp/environment/logging.h" 10 #include "mojo/public/cpp/environment/logging.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 void DartEmbedder::SetNullReturn(Dart_NativeArguments arguments) { 118 void DartEmbedder::SetNullReturn(Dart_NativeArguments arguments) {
119 Dart_SetReturnValue(arguments, Dart_Null()); 119 Dart_SetReturnValue(arguments, Dart_Null());
120 } 120 }
121 121
122 void DartEmbedder::SetCStringReturn(Dart_NativeArguments arguments, 122 void DartEmbedder::SetCStringReturn(Dart_NativeArguments arguments,
123 const char* str) { 123 const char* str) {
124 Dart_SetReturnValue(arguments, NewCString(str)); 124 Dart_SetReturnValue(arguments, NewCString(str));
125 } 125 }
126 126
127 bool DartEmbedder::GetBooleanArgument(Dart_NativeArguments args,
128 intptr_t index) {
129 bool result;
130 Dart_Handle err = Dart_GetNativeBooleanArgument(args, index, &result);
131 if (Dart_IsError(err)) {
132 Dart_PropagateError(err);
133 }
134 return result;
135 }
136
137 int64_t DartEmbedder::GetIntegerArgument(Dart_NativeArguments args,
138 intptr_t index) {
139 int64_t result;
140 Dart_Handle err = Dart_GetNativeIntegerArgument(args, index, &result);
141 if (Dart_IsError(err)) {
142 Dart_PropagateError(err);
143 }
144 return result;
145 }
146
147 intptr_t DartEmbedder::GetIntptrArgument(Dart_NativeArguments args,
148 intptr_t index) {
149 int64_t value = 0;
150 Dart_Handle result = Dart_GetNativeIntegerArgument(args, index, &value);
151 if (Dart_IsError(result)) {
152 Dart_PropagateError(result);
153 }
154 if (value < INTPTR_MIN || INTPTR_MAX < value) {
155 Dart_PropagateError(Dart_NewApiError("Value outside intptr_t range"));
156 }
157 return static_cast<intptr_t>(value);
158 }
159
127 const char* DartEmbedder::GetStringArgument(Dart_NativeArguments arguments, 160 const char* DartEmbedder::GetStringArgument(Dart_NativeArguments arguments,
128 intptr_t index) { 161 intptr_t index) {
129 Dart_Handle str_arg = Dart_GetNativeArgument(arguments, index); 162 Dart_Handle str_arg = Dart_GetNativeArgument(arguments, index);
130 const char* cstring = nullptr; 163 const char* cstring = nullptr;
131 Dart_Handle result = Dart_StringToCString(str_arg, &cstring); 164 Dart_Handle result = Dart_StringToCString(str_arg, &cstring);
132 if (Dart_IsError(result)) { 165 if (Dart_IsError(result)) {
133 Dart_PropagateError(result); 166 Dart_PropagateError(result);
134 } 167 }
135 return cstring; 168 return cstring;
136 } 169 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 214 }
182 Dart_Handle err = Dart_ListSetAsBytes(result, 0, bytes, length); 215 Dart_Handle err = Dart_ListSetAsBytes(result, 0, bytes, length);
183 if (Dart_IsError(err)) { 216 if (Dart_IsError(err)) {
184 Dart_PropagateError(err); 217 Dart_PropagateError(err);
185 } 218 }
186 return result; 219 return result;
187 } 220 }
188 221
189 } // namespace dart 222 } // namespace dart
190 } // namespace mojo 223 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/dart/embedder/common.h ('k') | mojo/dart/embedder/io/filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698