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

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

Issue 11360121: When building standalone Dart executable, put implementation of dart:io natives in a separate libra… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix grammar. Created 8 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
« runtime/bin/builtin_natives.cc ('K') | « runtime/bin/io_natives.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 #include "bin/io_natives.h"
6
7 #include <stdlib.h>
8 #include <string.h>
9
10 #include "bin/builtin.h"
11 #include "bin/dartutils.h"
12 #include "include/dart_api.h"
13 #include "platform/assert.h"
14
15
16 // Lists the native functions implementing advanced dart:io classes.
17 // Some classes, like File and Directory, list their implementations in
18 // builtin_natives.cc instead.
19 #define IO_NATIVE_LIST(V) \
20 V(EventHandler_Start, 1) \
21 V(EventHandler_SendData, 4) \
22 V(Process_Start, 10) \
23 V(Process_Kill, 3) \
24 V(ServerSocket_CreateBindListen, 4) \
25 V(ServerSocket_Accept, 2) \
26 V(Socket_CreateConnect, 3) \
27 V(Socket_Available, 1) \
28 V(Socket_Read, 2) \
29 V(Socket_ReadList, 4) \
30 V(Socket_WriteList, 4) \
31 V(Socket_GetPort, 1) \
32 V(Socket_GetRemotePeer, 1) \
33 V(Socket_GetError, 1) \
34 V(Socket_GetStdioHandle, 2) \
35 V(Socket_NewServicePort, 0)
36
37
38 IO_NATIVE_LIST(DECLARE_FUNCTION);
39
40 static struct NativeEntries {
41 const char* name_;
42 Dart_NativeFunction function_;
43 int argument_count_;
44 } IOEntries[] = {
45 IO_NATIVE_LIST(REGISTER_FUNCTION)
46 };
47
48
49 Dart_NativeFunction IONativeLookup(Dart_Handle name,
50 int argument_count) {
51 const char* function_name = NULL;
52 Dart_Handle result = Dart_StringToCString(name, &function_name);
53 DART_CHECK_VALID(result);
54 ASSERT(function_name != NULL);
55 int num_entries = sizeof(IOEntries) / sizeof(struct NativeEntries);
56 for (int i = 0; i < num_entries; i++) {
57 struct NativeEntries* entry = &(IOEntries[i]);
58 if (!strcmp(function_name, entry->name_) &&
59 (entry->argument_count_ == argument_count)) {
60 return reinterpret_cast<Dart_NativeFunction>(entry->function_);
61 }
62 }
63 return NULL;
64 }
OLDNEW
« runtime/bin/builtin_natives.cc ('K') | « runtime/bin/io_natives.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698