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

Unified 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: Address comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/io_natives.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/io_natives.cc
diff --git a/runtime/bin/io_natives.cc b/runtime/bin/io_natives.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c73ca95cc85cf8247a081174645da52d4b077ca9
--- /dev/null
+++ b/runtime/bin/io_natives.cc
@@ -0,0 +1,66 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#include "bin/io_natives.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "bin/builtin.h"
+#include "bin/dartutils.h"
+#include "include/dart_api.h"
+#include "platform/assert.h"
+
+
+// Lists the native functions implementing advanced dart:io classes.
+// Some classes, like File and Directory, list their implementations in
+// builtin_natives.cc instead.
+#define IO_NATIVE_LIST(V) \
+ V(Common_IsBuiltinList, 1) \
+ V(Crypto_GetRandomBytes, 1) \
+ V(EventHandler_Start, 1) \
+ V(EventHandler_SendData, 4) \
+ V(Process_Start, 10) \
+ V(Process_Kill, 3) \
+ V(ServerSocket_CreateBindListen, 4) \
+ V(ServerSocket_Accept, 2) \
+ V(Socket_CreateConnect, 3) \
+ V(Socket_Available, 1) \
+ V(Socket_Read, 2) \
+ V(Socket_ReadList, 4) \
+ V(Socket_WriteList, 4) \
+ V(Socket_GetPort, 1) \
+ V(Socket_GetRemotePeer, 1) \
+ V(Socket_GetError, 1) \
+ V(Socket_GetStdioHandle, 2) \
+ V(Socket_NewServicePort, 0)
+
+
+IO_NATIVE_LIST(DECLARE_FUNCTION);
+
+static struct NativeEntries {
+ const char* name_;
+ Dart_NativeFunction function_;
+ int argument_count_;
+} IOEntries[] = {
+ IO_NATIVE_LIST(REGISTER_FUNCTION)
+};
+
+
+Dart_NativeFunction IONativeLookup(Dart_Handle name,
+ int argument_count) {
+ const char* function_name = NULL;
+ Dart_Handle result = Dart_StringToCString(name, &function_name);
+ DART_CHECK_VALID(result);
+ ASSERT(function_name != NULL);
+ int num_entries = sizeof(IOEntries) / sizeof(struct NativeEntries);
+ for (int i = 0; i < num_entries; i++) {
+ struct NativeEntries* entry = &(IOEntries[i]);
+ if (!strcmp(function_name, entry->name_) &&
+ (entry->argument_count_ == argument_count)) {
+ return reinterpret_cast<Dart_NativeFunction>(entry->function_);
+ }
+ }
+ return NULL;
+}
« no previous file with comments | « runtime/bin/io_natives.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698