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

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

Issue 8399033: First round of changes to the file interface. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 9 years, 1 month 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/file_impl.dart ('k') | runtime/bin/socket_impl.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/socket.h" 5 #include "bin/socket.h"
6 #include "bin/dartutils.h" 6 #include "bin/dartutils.h"
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 9
10 10
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 delete[] buffer; 64 delete[] buffer;
65 Dart_SetReturnValue(args, Dart_NewInteger(bytes_read)); 65 Dart_SetReturnValue(args, Dart_NewInteger(bytes_read));
66 Dart_ExitScope(); 66 Dart_ExitScope();
67 } 67 }
68 68
69 69
70 void FUNCTION_NAME(Socket_WriteList)(Dart_NativeArguments args) { 70 void FUNCTION_NAME(Socket_WriteList)(Dart_NativeArguments args) {
71 Dart_EnterScope(); 71 Dart_EnterScope();
72 intptr_t socket = 72 intptr_t socket =
73 DartUtils::GetIntegerInstanceField(Dart_GetNativeArgument(args, 0), 73 DartUtils::GetIntegerInstanceField(Dart_GetNativeArgument(args, 0),
74 DartUtils::kIdFieldName); 74 DartUtils::kIdFieldName);
75 Dart_Handle buffer_obj = Dart_GetNativeArgument(args, 1); 75 Dart_Handle buffer_obj = Dart_GetNativeArgument(args, 1);
76 ASSERT(Dart_IsArray(buffer_obj)); 76 ASSERT(Dart_IsArray(buffer_obj));
77 intptr_t offset = 77 intptr_t offset =
78 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2)); 78 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2));
79 intptr_t length = 79 intptr_t length =
80 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3)); 80 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3));
81 intptr_t buffer_len = 0; 81 intptr_t buffer_len = 0;
82 Dart_Handle result = Dart_GetLength(buffer_obj, &buffer_len); 82 Dart_Handle result = Dart_GetLength(buffer_obj, &buffer_len);
83 ASSERT(Dart_IsValid(result)); 83 ASSERT(Dart_IsValid(result));
84 ASSERT((offset + length) <= buffer_len); 84 ASSERT((offset + length) <= buffer_len);
(...skipping 13 matching lines...) Expand all
98 } 98 }
99 Dart_SetReturnValue(args, Dart_NewInteger(total_bytes_written)); 99 Dart_SetReturnValue(args, Dart_NewInteger(total_bytes_written));
100 Dart_ExitScope(); 100 Dart_ExitScope();
101 } 101 }
102 102
103 103
104 void FUNCTION_NAME(Socket_GetPort)(Dart_NativeArguments args) { 104 void FUNCTION_NAME(Socket_GetPort)(Dart_NativeArguments args) {
105 Dart_EnterScope(); 105 Dart_EnterScope();
106 intptr_t socket = 106 intptr_t socket =
107 DartUtils::GetIntegerInstanceField(Dart_GetNativeArgument(args, 0), 107 DartUtils::GetIntegerInstanceField(Dart_GetNativeArgument(args, 0),
108 DartUtils::kIdFieldName); 108 DartUtils::kIdFieldName);
109 intptr_t port = Socket::GetPort(socket); 109 intptr_t port = Socket::GetPort(socket);
110 Dart_SetReturnValue(args, Dart_NewInteger(port)); 110 Dart_SetReturnValue(args, Dart_NewInteger(port));
111 Dart_ExitScope(); 111 Dart_ExitScope();
112 } 112 }
113 113
114 114
115 void FUNCTION_NAME(ServerSocket_CreateBindListen)(Dart_NativeArguments args) { 115 void FUNCTION_NAME(ServerSocket_CreateBindListen)(Dart_NativeArguments args) {
116 Dart_EnterScope(); 116 Dart_EnterScope();
117 Dart_Handle socketobj = Dart_GetNativeArgument(args, 0); 117 Dart_Handle socketobj = Dart_GetNativeArgument(args, 0);
118 const char* bindAddress = 118 const char* bindAddress =
119 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 1)); 119 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 1));
120 intptr_t port = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2)); 120 intptr_t port = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2));
121 intptr_t backlog = 121 intptr_t backlog =
122 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3)); 122 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3));
123 intptr_t socket = 123 intptr_t socket =
124 ServerSocket::CreateBindListen(bindAddress, port, backlog); 124 ServerSocket::CreateBindListen(bindAddress, port, backlog);
125 DartUtils::SetIntegerInstanceField( 125 DartUtils::SetIntegerInstanceField(
126 socketobj, DartUtils::kIdFieldName, socket); 126 socketobj, DartUtils::kIdFieldName, socket);
127 Dart_SetReturnValue(args, Dart_NewBoolean(socket >= 0)); 127 Dart_SetReturnValue(args, Dart_NewBoolean(socket >= 0));
128 Dart_ExitScope(); 128 Dart_ExitScope();
129 } 129 }
130 130
131 131
132 void FUNCTION_NAME(ServerSocket_Accept)(Dart_NativeArguments args) { 132 void FUNCTION_NAME(ServerSocket_Accept)(Dart_NativeArguments args) {
133 Dart_EnterScope(); 133 Dart_EnterScope();
134 intptr_t socket = 134 intptr_t socket =
135 DartUtils::GetIntegerInstanceField(Dart_GetNativeArgument(args, 0), 135 DartUtils::GetIntegerInstanceField(Dart_GetNativeArgument(args, 0),
136 DartUtils::kIdFieldName); 136 DartUtils::kIdFieldName);
137 Dart_Handle socketobj = Dart_GetNativeArgument(args, 1); 137 Dart_Handle socketobj = Dart_GetNativeArgument(args, 1);
138 intptr_t newSocket = ServerSocket::Accept(socket); 138 intptr_t newSocket = ServerSocket::Accept(socket);
139 if (newSocket >= 0) { 139 if (newSocket >= 0) {
140 DartUtils::SetIntegerInstanceField( 140 DartUtils::SetIntegerInstanceField(
141 socketobj, DartUtils::kIdFieldName, newSocket); 141 socketobj, DartUtils::kIdFieldName, newSocket);
142 } 142 }
143 Dart_SetReturnValue(args, Dart_NewBoolean(newSocket >= 0)); 143 Dart_SetReturnValue(args, Dart_NewBoolean(newSocket >= 0));
144 Dart_ExitScope(); 144 Dart_ExitScope();
145 } 145 }
OLDNEW
« no previous file with comments | « runtime/bin/file_impl.dart ('k') | runtime/bin/socket_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698