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

Side by Side Diff: runtime/bin/process.cc

Issue 11475026: By default use current code page on Windows for decoding string (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « runtime/bin/io_natives.cc ('k') | runtime/bin/process_patch.dart » ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/dartutils.h" 5 #include "bin/dartutils.h"
6 #include "bin/io_buffer.h"
6 #include "bin/process.h" 7 #include "bin/process.h"
7 #include "bin/socket.h" 8 #include "bin/socket.h"
8 9
9 #include "include/dart_api.h" 10 #include "include/dart_api.h"
10 11
11 12
12 static const int kProcessIdNativeField = 0; 13 static const int kProcessIdNativeField = 0;
13 14
14 15
15 // Extract an array of C strings from a list of Dart strings. 16 // Extract an array of C strings from a list of Dart strings.
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 Dart_Handle Process::GetProcessIdNativeField(Dart_Handle process, 171 Dart_Handle Process::GetProcessIdNativeField(Dart_Handle process,
171 intptr_t* pid) { 172 intptr_t* pid) {
172 return Dart_GetNativeInstanceField(process, kProcessIdNativeField, pid); 173 return Dart_GetNativeInstanceField(process, kProcessIdNativeField, pid);
173 } 174 }
174 175
175 176
176 Dart_Handle Process::SetProcessIdNativeField(Dart_Handle process, 177 Dart_Handle Process::SetProcessIdNativeField(Dart_Handle process,
177 intptr_t pid) { 178 intptr_t pid) {
178 return Dart_SetNativeInstanceField(process, kProcessIdNativeField, pid); 179 return Dart_SetNativeInstanceField(process, kProcessIdNativeField, pid);
179 } 180 }
181
182
183 void FUNCTION_NAME(SystemEncodingToString)(Dart_NativeArguments args) {
184 Dart_EnterScope();
185 Dart_Handle bytes = Dart_GetNativeArgument(args, 0);
186 intptr_t bytes_length = 0;
187 Dart_Handle result = Dart_ListLength(bytes, &bytes_length);
188 if (Dart_IsError(result)) Dart_PropagateError(result);
189 uint8_t* buffer = new uint8_t[bytes_length];
190 result = Dart_ListGetAsBytes(bytes, 0, buffer, bytes_length);
191 if (Dart_IsError(result)) {
192 delete[] buffer;
193 Dart_PropagateError(result);
194 }
195 char* str =
196 StringUtils::SystemStringToUtf8(reinterpret_cast<char*>(buffer));
197 Dart_SetReturnValue(args, DartUtils::NewString(str));
198 Dart_ExitScope();
199 }
200
201
202 void FUNCTION_NAME(StringToSystemEncoding)(Dart_NativeArguments args) {
203 Dart_EnterScope();
204 Dart_Handle str = Dart_GetNativeArgument(args, 0);
205 const char* utf8 = DartUtils::GetStringValue(str);
206 const char* system_string = StringUtils::Utf8ToSystemString(utf8);
207 int external_length = strlen(system_string);
208 uint8_t* buffer = NULL;
209 Dart_Handle external_array = IOBuffer::Allocate(external_length, &buffer);
210 memmove(buffer, system_string, external_length);
211 Dart_SetReturnValue(args, external_array);
212 Dart_ExitScope();
213 }
OLDNEW
« no previous file with comments | « runtime/bin/io_natives.cc ('k') | runtime/bin/process_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698