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

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

Issue 12451004: Introduce ZLibInflater and ZLibDeflater to dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/io_natives.h" 5 #include "bin/io_natives.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "bin/builtin.h" 10 #include "bin/builtin.h"
11 #include "bin/dartutils.h" 11 #include "bin/dartutils.h"
12 #include "include/dart_api.h" 12 #include "include/dart_api.h"
13 #include "platform/assert.h" 13 #include "platform/assert.h"
14 14
15 15
16 // Lists the native functions implementing advanced dart:io classes. 16 // Lists the native functions implementing advanced dart:io classes.
17 // Some classes, like File and Directory, list their implementations in 17 // Some classes, like File and Directory, list their implementations in
18 // builtin_natives.cc instead. 18 // builtin_natives.cc instead.
19 #define IO_NATIVE_LIST(V) \ 19 #define IO_NATIVE_LIST(V) \
20 V(Common_IsBuiltinList, 1) \ 20 V(Common_IsBuiltinList, 1) \
21 V(Crypto_GetRandomBytes, 1) \ 21 V(Crypto_GetRandomBytes, 1) \
22 V(EventHandler_Start, 1) \ 22 V(EventHandler_Start, 1) \
23 V(EventHandler_SendData, 4) \ 23 V(EventHandler_SendData, 4) \
24 V(Filter_CreateZLibDeflate, 3) \
25 V(Filter_CreateZLibInflate, 1) \
26 V(Filter_End, 1) \
27 V(Filter_Process, 2) \
28 V(Filter_Processed, 2) \
24 V(Platform_NumberOfProcessors, 0) \ 29 V(Platform_NumberOfProcessors, 0) \
25 V(Platform_OperatingSystem, 0) \ 30 V(Platform_OperatingSystem, 0) \
26 V(Platform_PathSeparator, 0) \ 31 V(Platform_PathSeparator, 0) \
27 V(Platform_LocalHostname, 0) \ 32 V(Platform_LocalHostname, 0) \
28 V(Platform_Environment, 0) \ 33 V(Platform_Environment, 0) \
29 V(Process_Start, 10) \ 34 V(Process_Start, 10) \
30 V(Process_Kill, 3) \ 35 V(Process_Kill, 3) \
31 V(Process_SetExitCode, 1) \ 36 V(Process_SetExitCode, 1) \
32 V(Process_Exit, 1) \ 37 V(Process_Exit, 1) \
33 V(ServerSocket_CreateBindListen, 4) \ 38 V(ServerSocket_CreateBindListen, 4) \
(...skipping 11 matching lines...) Expand all
45 V(Socket_GetType, 1) \ 50 V(Socket_GetType, 1) \
46 V(SecureSocket_Connect, 8) \ 51 V(SecureSocket_Connect, 8) \
47 V(SecureSocket_Destroy, 1) \ 52 V(SecureSocket_Destroy, 1) \
48 V(SecureSocket_Handshake, 1) \ 53 V(SecureSocket_Handshake, 1) \
49 V(SecureSocket_Init, 1) \ 54 V(SecureSocket_Init, 1) \
50 V(SecureSocket_PeerCertificate, 1) \ 55 V(SecureSocket_PeerCertificate, 1) \
51 V(SecureSocket_ProcessBuffer, 2) \ 56 V(SecureSocket_ProcessBuffer, 2) \
52 V(SecureSocket_RegisterBadCertificateCallback, 2) \ 57 V(SecureSocket_RegisterBadCertificateCallback, 2) \
53 V(SecureSocket_RegisterHandshakeCompleteCallback, 2) \ 58 V(SecureSocket_RegisterHandshakeCompleteCallback, 2) \
54 V(SecureSocket_InitializeLibrary, 3) \ 59 V(SecureSocket_InitializeLibrary, 3) \
55 V(SystemEncodingToString, 1) \ 60 V(StringToSystemEncoding, 1) \
56 V(StringToSystemEncoding, 1) 61 V(SystemEncodingToString, 1)
57 62
58 63
59 IO_NATIVE_LIST(DECLARE_FUNCTION); 64 IO_NATIVE_LIST(DECLARE_FUNCTION);
60 65
61 static struct NativeEntries { 66 static struct NativeEntries {
62 const char* name_; 67 const char* name_;
63 Dart_NativeFunction function_; 68 Dart_NativeFunction function_;
64 int argument_count_; 69 int argument_count_;
65 } IOEntries[] = { 70 } IOEntries[] = {
66 IO_NATIVE_LIST(REGISTER_FUNCTION) 71 IO_NATIVE_LIST(REGISTER_FUNCTION)
67 }; 72 };
68 73
69 74
70 Dart_NativeFunction IONativeLookup(Dart_Handle name, 75 Dart_NativeFunction IONativeLookup(Dart_Handle name,
71 int argument_count) { 76 int argument_count) {
72 const char* function_name = NULL; 77 const char* function_name = NULL;
73 Dart_Handle result = Dart_StringToCString(name, &function_name); 78 Dart_Handle result = Dart_StringToCString(name, &function_name);
74 DART_CHECK_VALID(result); 79 DART_CHECK_VALID(result);
75 ASSERT(function_name != NULL); 80 ASSERT(function_name != NULL);
76 int num_entries = sizeof(IOEntries) / sizeof(struct NativeEntries); 81 int num_entries = sizeof(IOEntries) / sizeof(struct NativeEntries);
77 for (int i = 0; i < num_entries; i++) { 82 for (int i = 0; i < num_entries; i++) {
78 struct NativeEntries* entry = &(IOEntries[i]); 83 struct NativeEntries* entry = &(IOEntries[i]);
79 if (!strcmp(function_name, entry->name_) && 84 if (!strcmp(function_name, entry->name_) &&
80 (entry->argument_count_ == argument_count)) { 85 (entry->argument_count_ == argument_count)) {
81 return reinterpret_cast<Dart_NativeFunction>(entry->function_); 86 return reinterpret_cast<Dart_NativeFunction>(entry->function_);
82 } 87 }
83 } 88 }
84 return NULL; 89 return NULL;
85 } 90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698