Really remove io support when dart:io is unsupported.

Previously we would compile in implementaitions of native calls for
IO functions that would never be used. This CL provides implementations
that throw a Dart exception if they're called by mistake. It also uses
a DART_IO_DISABLED preprocessor define to clean up the build files and
check that we're not including code we shouldn't.

R=iposva@google.com, johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1839463002 .
This commit is contained in:
Zachary Anderson 2016-03-29 11:22:03 -07:00
parent b2f3e8efe1
commit 7308e58c3f
69 changed files with 1302 additions and 256 deletions

2
DEPS
View file

@ -76,7 +76,7 @@ vars = {
"pub_semver_tag": "@1.2.1",
"quiver_tag": "@0.21.4",
"resource_rev":"@a49101ba2deb29c728acba6fb86000a8f730f4b1",
"root_certificates_rev": "@218d6a723fab86a7b80aa5f9b591d5a51d2955eb",
"root_certificates_rev": "@aed07942ce98507d2be28cbd29e879525410c7fc",
"scheduled_test_tag": "@0.12.5+2",
"shelf_tag": "@0.6.5",
"smoke_rev" : "@f3361191cc2a85ebc1e4d4c33aec672d7915aba9",

View file

@ -191,11 +191,6 @@ executable("gen_snapshot") {
"builtin_gen_snapshot.cc",
"builtin.cc",
"builtin.h",
"platform_android.cc",
"platform_linux.cc",
"platform_macos.cc",
"platform_win.cc",
"platform.h",
"vmservice_impl.cc",
"vmservice_impl.h",
# Include generated source files.
@ -231,27 +226,13 @@ io_impl_sources_gypi =
source_set("gen_snapshot_dart_io") {
configs += ["..:dart_config",]
# Set custom sources assignment filter. The custom filters does three things:
# 1) Filters out unnecessary files pulled in from the gypi files.
# 2) Filters out secure socket support.
# 3) Enables dart:io by filtering out _unsupported.cc implementations.
deps = [
"//third_party/zlib",
]
custom_sources_filter = [
"*net/nss_memio.cc",
"*net/nss_memio.h",
"*root_certificates.cc",
"*secure_socket_boringssl.cc",
"*secure_socket_boringssl.h",
"*secure_socket_macos.cc",
"*secure_socket_macos.h",
"*secure_socket.h",
"filter.cc",
"*io_service_unsupported.cc",
"platform_*.cc",
"*io_service.cc",
"*io_service.h",
"*_test.cc",
"*_test.h",
"*dbg*",
"builtin.cc",
"builtin_common.cc",
"builtin_gen_snapshot.cc",
@ -271,11 +252,6 @@ source_set("gen_snapshot_dart_io") {
sources += [
"io_natives.cc",
"io_natives.h",
"log_android.cc",
"log_linux.cc",
"log_macos.cc",
"log_win.cc",
"log.h",
]
include_dirs = [
@ -289,26 +265,9 @@ source_set("gen_snapshot_dart_io") {
source_set("embedded_dart_io") {
configs += ["..:dart_config",]
# Set custom sources assignment filter. The custom filters does three things:
# 1) Filters out unnecessary files pulled in from the gypi files.
# 2) Filters out secure socket support.
# 3) Enables dart:io by filtering out _unsupported.cc implementations.
custom_sources_filter = [
"*net/nss_memio.cc",
"*net/nss_memio.h",
"*root_certificates.cc",
"*secure_socket_boringssl.cc",
"*secure_socket_boringssl.h",
"*secure_socket_macos.cc",
"*secure_socket_macos.h",
"*secure_socket.h",
"*filter_unsupported.cc",
"*io_service_unsupported.cc",
"*io_service.cc",
"*io_service.h",
"*_test.cc",
"*_test.h",
"*dbg*",
"builtin.cc",
"builtin_gen_snapshot.cc",
]

View file

@ -144,6 +144,73 @@
'sources/': [
['exclude', '_test\\.(cc|h)$'],
],
'conditions': [
['dart_io_support==0', {
'defines': [
'DART_IO_DISABLED',
],
}],
['OS=="win"', {
'sources/' : [
['exclude', 'fdutils.h'],
],
# TODO(antonm): fix the implementation.
# Current implementation accepts char* strings
# and therefore fails to compile once _UNICODE is
# enabled. That should be addressed using -A
# versions of functions and adding necessary conversions.
'configurations': {
'Common_Base': {
'msvs_configuration_attributes': {
'CharacterSet': '0',
},
},
},
}],
['OS=="linux"', {
'link_settings': {
'libraries': [
'-ldl',
],
},
}],
['OS=="android"', {
'link_settings': {
'libraries': [
'-ldl',
],
},
}],
],
},
# This is the same as libdart_builtin, but the io support libraries are
# never disabled, even when dart_io_support==0. This is so that it can
# still be usefully linked into gen_snapshot.
{
'target_name': 'libdart_builtin_no_disable',
'type': 'static_library',
'toolsets':['host'],
'dependencies': [
'generate_builtin_cc_file#host',
'generate_io_cc_file#host',
'generate_io_patch_cc_file#host',
],
'include_dirs': [
'..',
],
'sources': [
'log_android.cc',
'log_linux.cc',
'log_macos.cc',
'log_win.cc',
],
'includes': [
'builtin_impl_sources.gypi',
'../platform/platform_sources.gypi',
],
'sources/': [
['exclude', '_test\\.(cc|h)$'],
],
'conditions': [
['OS=="win"', {
'sources/' : [
@ -227,7 +294,7 @@
'conditions': [
['OS != "mac" and dart_io_support==1 and dart_io_secure_socket==1', {
'dependencies': [
'../third_party/boringssl/boringssl_dart.gyp:boringssl',
'../third_party/boringssl/boringssl_dart.gyp:boringssl',
],
}],
['dart_io_secure_socket==0 or dart_io_support==0', {
@ -300,15 +367,80 @@
'dependencies': [
'bin/zlib.gyp:zlib_dart',
],
}, { # dart_io_support == 0
'defines': [
'DART_IO_DISABLED',
'DART_IO_SECURE_SOCKET_DISABLED',
],
}],
['dart_io_secure_socket==0', {
'defines': [
'DART_IO_SECURE_SOCKET_DISABLED'
],
}],
['OS != "mac" and dart_io_support==1 and dart_io_secure_socket==1', {
'dependencies': [
'../third_party/boringssl/boringssl_dart.gyp:boringssl',
],
}],
['dart_io_secure_socket==0 or dart_io_support==0', {
['OS=="win"', {
'link_settings': {
'libraries': [ '-liphlpapi.lib' ],
},
# TODO(antonm): fix the implementation.
# Current implementation accepts char* strings
# and therefore fails to compile once _UNICODE is
# enabled. That should be addressed using -A
# versions of functions and adding necessary conversions.
'configurations': {
'Common_Base': {
'msvs_configuration_attributes': {
'CharacterSet': '0',
},
},
},
}],
['OS=="mac"', {
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/CoreFoundation.framework',
'$(SDKROOT)/System/Library/Frameworks/CoreServices.framework',
'$(SDKROOT)/System/Library/Frameworks/Security.framework',
],
},
}],
],
},
# This is the same as libdart_io, but the io support libraries are
# never disabled, even when dart_io_support==0. This is so that it can
# still be usefully linked into gen_snapshot.
{
'target_name': 'libdart_io_no_disable',
'type': 'static_library',
'toolsets': ['host'],
'include_dirs': [
'..',
'../../third_party',
],
'includes': [
'io_impl_sources.gypi',
],
'sources': [
'io_natives.h',
'io_natives.cc',
],
'dependencies': [
'bin/zlib.gyp:zlib_dart',
],
'conditions': [
['dart_io_support==0 or dart_io_secure_socket==0', {
'defines': [
'DART_IO_SECURE_SOCKET_DISABLED'
'DART_IO_SECURE_SOCKET_DISABLED',
],
}],
['OS != "mac" and dart_io_support==1 and dart_io_secure_socket==1', {
'dependencies': [
'../third_party/boringssl/boringssl_dart.gyp:boringssl',
],
}],
['OS=="win"', {
@ -377,9 +509,11 @@
'dependencies': [
'generate_resources_cc_file#host',
'generate_observatory_assets_cc_file#host',
'libdart_nosnapshot',
'libdart_builtin',
'libdart_io',
'libdart_nosnapshot#host',
# If io is disabled for the VM, we still need it for gen snapshot, so
# use libdart_builtin and libdart_io that still have io enabled.
'libdart_builtin_no_disable#host',
'libdart_io_no_disable#host',
],
'include_dirs': [
'..',
@ -547,6 +681,7 @@
'target_name': 'dart_product',
'type': 'executable',
'dependencies': [
'bin/zlib.gyp:zlib_dart',
'libdart',
'libdart_builtin',
'libdart_io',
@ -560,13 +695,13 @@
],
'sources': [
'main.cc',
'builtin.h',
'builtin_common.cc',
'builtin_natives.cc',
'builtin_nolib.cc',
'builtin.h',
'io_natives.h',
'snapshot_empty.cc',
'observatory_assets_empty.cc',
'snapshot_empty.cc',
],
'conditions': [
['OS=="win"', {
@ -581,13 +716,14 @@
'target_name': 'dart',
'type': 'executable',
'dependencies': [
'bin/zlib.gyp:zlib_dart',
'build_observatory#host',
'generate_observatory_assets_cc_file#host',
'generate_resources_cc_file#host',
'generate_snapshot_file#host',
'libdart',
'libdart_builtin',
'libdart_io',
'build_observatory#host',
'generate_snapshot_file#host',
'generate_resources_cc_file#host',
'generate_observatory_assets_cc_file#host',
],
'include_dirs': [
'..',
@ -595,16 +731,16 @@
],
'sources': [
'main.cc',
'builtin.h',
'builtin_common.cc',
'builtin_natives.cc',
'builtin_nolib.cc',
'builtin.h',
'io_natives.h',
'vmservice_impl.cc',
'vmservice_impl.h',
'<(snapshot_cc_file)',
'<(resources_cc_file)',
'<(observatory_assets_cc_file)',
'<(resources_cc_file)',
'<(snapshot_cc_file)',
],
'conditions': [
['OS=="win"', {
@ -636,30 +772,29 @@
'target_name': 'dart_noopt',
'type': 'executable',
'dependencies': [
'libdart_noopt',
'build_observatory#host',
'generate_observatory_assets_cc_file#host',
'generate_resources_cc_file#host',
'generate_snapshot_file#host',
'libdart_builtin',
'libdart_io',
'build_observatory#host',
'generate_snapshot_file#host',
'generate_resources_cc_file#host',
'generate_observatory_assets_cc_file#host',
'libdart_noopt',
],
'include_dirs': [
'..',
'../../third_party/', # Zlib
],
'sources': [
'main.cc',
'builtin.h',
'builtin_common.cc',
'builtin_natives.cc',
'builtin_nolib.cc',
'builtin.h',
'io_natives.h',
'vmservice_impl.cc',
'vmservice_impl.h',
'<(snapshot_cc_file)',
'<(resources_cc_file)',
'<(observatory_assets_cc_file)',
'<(resources_cc_file)',
'<(snapshot_cc_file)',
],
'defines': [
'DART_PRECOMPILER',
@ -693,12 +828,13 @@
'target_name': 'dart_precompiled_runtime',
'type': 'executable',
'dependencies': [
'libdart_precompiled_runtime',
'bin/zlib.gyp:zlib_dart',
'build_observatory#host',
'generate_observatory_assets_cc_file#host',
'generate_resources_cc_file#host',
'libdart_builtin',
'libdart_io',
'build_observatory#host',
'generate_resources_cc_file#host',
'generate_observatory_assets_cc_file#host',
'libdart_precompiled_runtime',
],
'include_dirs': [
'..',
@ -706,16 +842,16 @@
],
'sources': [
'main.cc',
'builtin.h',
'builtin_common.cc',
'builtin_natives.cc',
'builtin_nolib.cc',
'builtin.h',
'io_natives.h',
'snapshot_empty.cc',
'vmservice_impl.cc',
'vmservice_impl.h',
'snapshot_empty.cc',
'<(resources_cc_file)',
'<(observatory_assets_cc_file)',
'<(resources_cc_file)',
],
'defines': [
'DART_PRECOMPILED_RUNTIME',
@ -742,22 +878,23 @@
'type': 'executable',
'toolsets':['host'],
'dependencies': [
'libdart_nosnapshot',
'generate_resources_cc_file#host',
'libdart_builtin',
'libdart_io',
'generate_resources_cc_file#host',
'libdart_nosnapshot',
],
'include_dirs': [
'..',
'../../third_party/', # Zlib
],
'sources': [
'main.cc',
'builtin_common.cc',
'builtin_natives.cc',
'builtin.cc',
'builtin.h',
'builtin_common.cc',
'builtin_natives.cc',
'io_natives.h',
'observatory_assets_empty.cc',
'snapshot_empty.cc',
'vmservice_impl.cc',
'vmservice_impl.h',
# Include generated source files.
@ -765,8 +902,6 @@
'<(io_cc_file)',
'<(io_patch_cc_file)',
'<(resources_cc_file)',
'observatory_assets_empty.cc',
'snapshot_empty.cc',
],
'defines': [
'DART_NO_SNAPSHOT',

View file

@ -21,6 +21,7 @@
'directory_android.cc',
'directory_linux.cc',
'directory_macos.cc',
'directory_unsupported.cc',
'directory_win.cc',
'eventhandler_test.cc',
'extensions.h',
@ -29,17 +30,19 @@
'extensions_linux.cc',
'extensions_macos.cc',
'extensions_win.cc',
'fdutils.h',
'fdutils_android.cc',
'fdutils_linux.cc',
'fdutils_macos.cc',
'file.cc',
'file.h',
'file_android.cc',
'file_linux.cc',
'file_macos.cc',
'file_win.cc',
'file_support.cc',
'file_unsupported.cc',
'file_test.cc',
'fdutils.h',
'fdutils_android.cc',
'fdutils_linux.cc',
'fdutils_macos.cc',
'file_win.cc',
'hashmap_test.cc',
'io_buffer.cc',
'io_buffer.h',

View file

@ -4,22 +4,21 @@
#include "bin/dartutils.h"
#include "include/dart_api.h"
#include "include/dart_tools_api.h"
#include "include/dart_native_api.h"
#include "platform/assert.h"
#include "platform/globals.h"
#include "bin/crypto.h"
#include "bin/directory.h"
#include "bin/extensions.h"
#include "bin/file.h"
#include "bin/io_buffer.h"
#include "bin/platform.h"
#include "bin/socket.h"
#include "bin/utils.h"
#include "include/dart_api.h"
#include "include/dart_native_api.h"
#include "include/dart_tools_api.h"
#include "platform/assert.h"
#include "platform/globals.h"
// Return the error from the containing function if handle is in error handle.
#define RETURN_IF_ERROR(handle) \
{ \

View file

@ -5,14 +5,12 @@
#ifndef BIN_DARTUTILS_H_
#define BIN_DARTUTILS_H_
#include "bin/isolate_data.h"
#include "include/dart_api.h"
#include "include/dart_native_api.h"
#include "platform/assert.h"
#include "platform/globals.h"
#include "bin/isolate_data.h"
namespace dart {
namespace bin {

View file

@ -2,6 +2,8 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "bin/directory.h"
#include "bin/dartutils.h"
@ -422,3 +424,5 @@ void Directory::List(DirectoryListing* listing) {
} // namespace bin
} // namespace dart
#endif // !defined(DART_IO_DISABLED)

View file

@ -0,0 +1,70 @@
// Copyright (c) 2016, 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.
#if defined(DART_IO_DISABLED)
#include "bin/builtin.h"
#include "bin/dartutils.h"
#include "include/dart_api.h"
namespace dart {
namespace bin {
void FUNCTION_NAME(Directory_Current)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Directory is not supported on this platform"));
}
void FUNCTION_NAME(Directory_SetCurrent)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Directory is not supported on this platform"));
}
void FUNCTION_NAME(Directory_Exists)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Directory is not supported on this platform"));
}
void FUNCTION_NAME(Directory_Create)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Directory is not supported on this platform"));
}
void FUNCTION_NAME(Directory_SystemTemp)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Directory is not supported on this platform"));
}
void FUNCTION_NAME(Directory_CreateTemp)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Directory is not supported on this platform"));
}
void FUNCTION_NAME(Directory_Delete)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Directory is not supported on this platform"));
}
void FUNCTION_NAME(Directory_Rename)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Directory is not supported on this platform"));
}
void FUNCTION_NAME(Directory_List)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Directory is not supported on this platform"));
}
} // namespace bin
} // namespace dart
#endif // defined(DART_IO_DISABLED)

View file

@ -2,8 +2,12 @@
// 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/dartutils.h"
#if !defined(DART_IO_DISABLED)
#include "bin/eventhandler.h"
#include "bin/builtin.h"
#include "bin/dartutils.h"
#include "bin/lockers.h"
#include "bin/socket.h"
#include "bin/thread.h"
@ -142,3 +146,5 @@ void FUNCTION_NAME(EventHandler_TimerMillisecondClock)(
} // namespace bin
} // namespace dart
#endif // !defined(DART_IO_DISABLED)

View file

@ -2,6 +2,8 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "platform/globals.h"
#if defined(TARGET_OS_ANDROID)
@ -433,3 +435,5 @@ uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
} // namespace dart
#endif // defined(TARGET_OS_ANDROID)
#endif // !defined(DART_IO_DISABLED)

View file

@ -2,6 +2,8 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "platform/globals.h"
#if defined(TARGET_OS_LINUX)
@ -437,3 +439,5 @@ uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
} // namespace dart
#endif // defined(TARGET_OS_LINUX)
#endif // !defined(DART_IO_DISABLED)

View file

@ -2,6 +2,8 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "platform/globals.h"
#if defined(TARGET_OS_MACOS)
@ -509,3 +511,5 @@ uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
} // namespace dart
#endif // defined(TARGET_OS_MACOS)
#endif // !defined(DART_IO_DISABLED)

View file

@ -0,0 +1,39 @@
// Copyright (c) 2016, 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.
#if defined(DART_IO_DISABLED)
#include "bin/eventhandler.h"
#include "bin/builtin.h"
#include "bin/dartutils.h"
#include "include/dart_api.h"
namespace dart {
namespace bin {
void EventHandler::Start() {
}
void EventHandler::Stop() {
}
void FUNCTION_NAME(EventHandler_SendData)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"EventHandler is not supported on this platform"));
}
void FUNCTION_NAME(EventHandler_TimerMillisecondClock)(
Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"EventHandler is not supported on this platform"));
}
} // namespace bin
} // namespace dart
#endif // defined(DART_IO_DISABLED)

View file

@ -2,6 +2,8 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "platform/globals.h"
#if defined(TARGET_OS_WINDOWS)
@ -1505,3 +1507,5 @@ void EventHandlerImplementation::Shutdown() {
} // namespace dart
#endif // defined(TARGET_OS_WINDOWS)
#endif // !defined(DART_IO_DISABLED)

View file

@ -2,6 +2,8 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "bin/file.h"
#include "bin/builtin.h"
@ -18,32 +20,6 @@ namespace bin {
static const int kMSPerSecond = 1000;
// Are we capturing output from stdout for the VM service?
static bool capture_stdout = false;
// Are we capturing output from stderr for the VM service?
static bool capture_stderr = false;
void SetCaptureStdout(bool value) {
capture_stdout = value;
}
void SetCaptureStderr(bool value) {
capture_stderr = value;
}
bool ShouldCaptureStdout() {
return capture_stdout;
}
bool ShouldCaptureStderr() {
return capture_stderr;
}
// The file pointer has been passed into Dart as an intptr_t and it is safe
// to pull it out of Dart as a 64-bit integer, cast it to an intptr_t and
// from there to a File pointer.
@ -53,70 +29,6 @@ static File* GetFilePointer(Dart_Handle handle) {
}
bool File::ReadFully(void* buffer, int64_t num_bytes) {
int64_t remaining = num_bytes;
char* current_buffer = reinterpret_cast<char*>(buffer);
while (remaining > 0) {
int64_t bytes_read = Read(current_buffer, remaining);
if (bytes_read <= 0) {
return false;
}
remaining -= bytes_read; // Reduce the number of remaining bytes.
current_buffer += bytes_read; // Move the buffer forward.
}
return true;
}
bool File::WriteFully(const void* buffer, int64_t num_bytes) {
int64_t remaining = num_bytes;
const char* current_buffer = reinterpret_cast<const char*>(buffer);
while (remaining > 0) {
int64_t bytes_written = Write(current_buffer, remaining);
if (bytes_written < 0) {
return false;
}
remaining -= bytes_written; // Reduce the number of remaining bytes.
current_buffer += bytes_written; // Move the buffer forward.
}
if (capture_stdout || capture_stderr) {
intptr_t fd = GetFD();
if ((fd == STDOUT_FILENO) && capture_stdout) {
Dart_ServiceSendDataEvent("Stdout", "WriteEvent",
reinterpret_cast<const uint8_t*>(buffer),
num_bytes);
} else if ((fd == STDERR_FILENO) && capture_stderr) {
Dart_ServiceSendDataEvent("Stderr", "WriteEvent",
reinterpret_cast<const uint8_t*>(buffer),
num_bytes);
}
}
return true;
}
File::FileOpenMode File::DartModeToFileMode(DartFileOpenMode mode) {
ASSERT((mode == File::kDartRead) ||
(mode == File::kDartWrite) ||
(mode == File::kDartAppend) ||
(mode == File::kDartWriteOnly) ||
(mode == File::kDartWriteOnlyAppend));
if (mode == File::kDartWrite) {
return File::kWriteTruncate;
}
if (mode == File::kDartAppend) {
return File::kWrite;
}
if (mode == File::kDartWriteOnly) {
return File::kWriteOnlyTruncate;
}
if (mode == File::kDartWriteOnlyAppend) {
return File::kWriteOnly;
}
return File::kRead;
}
void FUNCTION_NAME(File_Open)(Dart_NativeArguments args) {
const char* filename =
DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0));
@ -1250,3 +1162,5 @@ CObject* File::LockRequest(const CObjectArray& request) {
} // namespace bin
} // namespace dart
#endif // !defined(DART_IO_DISABLED)

109
runtime/bin/file_support.cc Normal file
View file

@ -0,0 +1,109 @@
// Copyright (c) 2016, 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/file.h"
#include "bin/builtin.h"
#include "bin/dartutils.h"
#include "bin/embedded_dart_io.h"
#include "bin/io_buffer.h"
#include "bin/utils.h"
#include "include/dart_api.h"
#include "include/dart_tools_api.h"
namespace dart {
namespace bin {
// Are we capturing output from stdout for the VM service?
static bool capture_stdout = false;
// Are we capturing output from stderr for the VM service?
static bool capture_stderr = false;
void SetCaptureStdout(bool value) {
capture_stdout = value;
}
void SetCaptureStderr(bool value) {
capture_stderr = value;
}
bool ShouldCaptureStdout() {
return capture_stdout;
}
bool ShouldCaptureStderr() {
return capture_stderr;
}
bool File::ReadFully(void* buffer, int64_t num_bytes) {
int64_t remaining = num_bytes;
char* current_buffer = reinterpret_cast<char*>(buffer);
while (remaining > 0) {
int64_t bytes_read = Read(current_buffer, remaining);
if (bytes_read <= 0) {
return false;
}
remaining -= bytes_read; // Reduce the number of remaining bytes.
current_buffer += bytes_read; // Move the buffer forward.
}
return true;
}
bool File::WriteFully(const void* buffer, int64_t num_bytes) {
int64_t remaining = num_bytes;
const char* current_buffer = reinterpret_cast<const char*>(buffer);
while (remaining > 0) {
int64_t bytes_written = Write(current_buffer, remaining);
if (bytes_written < 0) {
return false;
}
remaining -= bytes_written; // Reduce the number of remaining bytes.
current_buffer += bytes_written; // Move the buffer forward.
}
if (capture_stdout || capture_stderr) {
intptr_t fd = GetFD();
if ((fd == STDOUT_FILENO) && capture_stdout) {
Dart_ServiceSendDataEvent("Stdout", "WriteEvent",
reinterpret_cast<const uint8_t*>(buffer),
num_bytes);
} else if ((fd == STDERR_FILENO) && capture_stderr) {
Dart_ServiceSendDataEvent("Stderr", "WriteEvent",
reinterpret_cast<const uint8_t*>(buffer),
num_bytes);
}
}
return true;
}
File::FileOpenMode File::DartModeToFileMode(DartFileOpenMode mode) {
ASSERT((mode == File::kDartRead) ||
(mode == File::kDartWrite) ||
(mode == File::kDartAppend) ||
(mode == File::kDartWriteOnly) ||
(mode == File::kDartWriteOnlyAppend));
if (mode == File::kDartWrite) {
return File::kWriteTruncate;
}
if (mode == File::kDartAppend) {
return File::kWrite;
}
if (mode == File::kDartWriteOnly) {
return File::kWriteOnlyTruncate;
}
if (mode == File::kDartWriteOnlyAppend) {
return File::kWriteOnly;
}
return File::kRead;
}
} // namespace bin
} // namespace dart

View file

@ -2,6 +2,8 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "bin/file_system_watcher.h"
#include "bin/builtin.h"
@ -73,3 +75,5 @@ void FUNCTION_NAME(FileSystemWatcher_GetSocketId)(Dart_NativeArguments args) {
} // namespace bin
} // namespace dart
#endif // !defined(DART_IO_DISABLED)

View file

@ -5,6 +5,10 @@
#ifndef BIN_FILE_SYSTEM_WATCHER_H_
#define BIN_FILE_SYSTEM_WATCHER_H_
#if defined(DART_IO_DISABLED)
#error "file_system_watcher.h can only be included on builds with IO enabled"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View file

@ -2,6 +2,8 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "platform/globals.h"
#if defined(TARGET_OS_ANDROID)
@ -144,3 +146,5 @@ Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id, intptr_t path_id) {
} // namespace dart
#endif // defined(TARGET_OS_ANDROID)
#endif // !defined(DART_IO_DISABLED)

View file

@ -2,6 +2,8 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "platform/globals.h"
#if defined(TARGET_OS_LINUX)
@ -145,3 +147,5 @@ Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id, intptr_t path_id) {
} // namespace dart
#endif // defined(TARGET_OS_LINUX)
#endif // !defined(DART_IO_DISABLED)

View file

@ -2,6 +2,8 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "platform/globals.h"
#if defined(TARGET_OS_MACOS)
@ -458,3 +460,5 @@ intptr_t FileSystemWatcher::WatchPath(intptr_t id,
#endif // !TARGET_OS_IOS
#endif // defined(TARGET_OS_MACOS)
#endif // !defined(DART_IO_DISABLED)

View file

@ -0,0 +1,58 @@
// Copyright (c) 2016, 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.
#if defined(DART_IO_DISABLED)
#include "bin/builtin.h"
#include "bin/dartutils.h"
#include "include/dart_api.h"
namespace dart {
namespace bin {
void FUNCTION_NAME(FileSystemWatcher_IsSupported)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"FileSystemWatcher is not supported on this platform"));
}
void FUNCTION_NAME(FileSystemWatcher_InitWatcher)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"FileSystemWatcher is not supported on this platform"));
}
void FUNCTION_NAME(FileSystemWatcher_CloseWatcher)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"FileSystemWatcher is not supported on this platform"));
}
void FUNCTION_NAME(FileSystemWatcher_WatchPath)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"FileSystemWatcher is not supported on this platform"));
}
void FUNCTION_NAME(FileSystemWatcher_UnwatchPath)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"FileSystemWatcher is not supported on this platform"));
}
void FUNCTION_NAME(FileSystemWatcher_ReadEvents)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"FileSystemWatcher is not supported on this platform"));
}
void FUNCTION_NAME(FileSystemWatcher_GetSocketId)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"FileSystemWatcher is not supported on this platform"));
}
} // namespace bin
} // namespace dart
#endif // defined(DART_IO_DISABLED)

View file

@ -2,6 +2,8 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "platform/globals.h"
#if defined(TARGET_OS_WINDOWS)
@ -139,3 +141,5 @@ Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id, intptr_t path_id) {
} // namespace dart
#endif // defined(TARGET_OS_WINDOWS)
#endif // !defined(DART_IO_DISABLED)

View file

@ -0,0 +1,202 @@
// Copyright (c) 2016, 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.
#if defined(DART_IO_DISABLED)
#include "bin/builtin.h"
#include "bin/dartutils.h"
#include "include/dart_api.h"
namespace dart {
namespace bin {
void FUNCTION_NAME(File_Open)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_Exists)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_Close)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_GetFD)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_ReadByte)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_WriteByte)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_Read)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_ReadInto)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_WriteFrom)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_Position)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_SetPosition)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_Truncate)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_Length)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_LengthFromPath)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_LastModified)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_Flush)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_Lock)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_Create)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_CreateLink)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_LinkTarget)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_Delete)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_DeleteLink)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_Rename)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_RenameLink)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_Copy)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_ResolveSymbolicLinks)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_OpenStdio)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_GetStdioHandleType)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_GetType)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_Stat)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
void FUNCTION_NAME(File_AreIdentical)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"File is not supported on this platform"));
}
} // namespace bin
} // namespace dart
#endif // !defined(DART_IO_DISABLED)

View file

@ -2,8 +2,11 @@
// 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/dartutils.h"
#if !defined(DART_IO_DISABLED)
#include "bin/filter.h"
#include "bin/dartutils.h"
#include "bin/io_buffer.h"
#include "include/dart_api.h"
@ -465,3 +468,5 @@ intptr_t ZLibInflateFilter::Processed(uint8_t* buffer,
} // namespace bin
} // namespace dart
#endif // !defined(DART_IO_DISABLED)

View file

@ -5,6 +5,10 @@
#ifndef BIN_FILTER_H_
#define BIN_FILTER_H_
#if defined(DART_IO_DISABLED)
#error "filter.h can only be included on builds with IO enabled"
#endif
#include "bin/builtin.h"
#include "bin/utils.h"

View file

@ -2,9 +2,10 @@
// 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.
#if defined(DART_IO_DISABLED)
#include "bin/builtin.h"
#include "bin/dartutils.h"
#include "include/dart_api.h"
namespace dart {
@ -17,15 +18,23 @@ void FUNCTION_NAME(Filter_CreateZLibInflate)(Dart_NativeArguments args) {
void FUNCTION_NAME(Filter_CreateZLibDeflate)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"ZLibInflater and Deflater not supported on this platform"));
}
void FUNCTION_NAME(Filter_Process)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"ZLibInflater and Deflater not supported on this platform"));
}
void FUNCTION_NAME(Filter_Processed)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"ZLibInflater and Deflater not supported on this platform"));
}
} // namespace bin
} // namespace dart
#endif // defined(DART_IO_DISABLED)

View file

@ -14,6 +14,7 @@
'eventhandler_linux.h',
'eventhandler_macos.cc',
'eventhandler_macos.h',
'eventhandler_unsupported.cc',
'eventhandler_win.cc',
'eventhandler_win.h',
'file_system_watcher.cc',
@ -21,6 +22,7 @@
'file_system_watcher_android.cc',
'file_system_watcher_linux.cc',
'file_system_watcher_macos.cc',
'file_system_watcher_unsupported.cc',
'file_system_watcher_win.cc',
'filter.cc',
'filter.h',
@ -35,12 +37,14 @@
'platform_android.cc',
'platform_linux.cc',
'platform_macos.cc',
'platform_unsupported.cc',
'platform_win.cc',
'process.cc',
'process.h',
'process_android.cc',
'process_linux.cc',
'process_macos.cc',
'process_unsupported.cc',
'process_win.cc',
'../../third_party/root_certificates/root_certificates.cc',
'root_certificates_unsupported.cc',
@ -58,6 +62,7 @@
'socket_linux.h',
'socket_macos.cc',
'socket_macos.h',
'socket_unsupported.cc',
'socket_win.cc',
'socket_win.h',
'stdio.cc',
@ -65,30 +70,7 @@
'stdio_android.cc',
'stdio_linux.cc',
'stdio_macos.cc',
'stdio_unsupported.cc',
'stdio_win.cc',
],
'conditions': [
['dart_io_support==1', {
'sources!' : [
'filter_unsupported.cc',
'io_service_unsupported.cc',
],
},{ # else dart_io_support == 0
'sources!' : [
'filter.cc',
'filter.h',
'io_service.cc',
'io_service.h',
'io_service_no_ssl.cc',
'io_service_no_ssl.h',
'../../third_party/root_certificates/root_certificates.cc',
'root_certificates_unsupported.cc',
'secure_socket.h',
'secure_socket_boringssl.cc',
'secure_socket_boringssl.h',
'secure_socket_macos.cc',
'secure_socket_macos.h',
],
}],
],
}

View file

@ -2,7 +2,7 @@
// 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.
#if !defined(DART_IO_SECURE_SOCKET_DISABLED)
#if !defined(DART_IO_DISABLED) && !defined(DART_IO_SECURE_SOCKET_DISABLED)
#include "bin/io_service.h"
@ -76,4 +76,5 @@ void FUNCTION_NAME(IOService_NewServicePort)(Dart_NativeArguments args) {
} // namespace bin
} // namespace dart
#endif // !defined(DART_IO_SECURE_SOCKET_DISABLED)
#endif // !defined(DART_IO_DISABLED) &&
// !defined(DART_IO_SECURE_SOCKET_DISABLED)

View file

@ -5,6 +5,10 @@
#ifndef BIN_IO_SERVICE_H_
#define BIN_IO_SERVICE_H_
#if defined(DART_IO_DISABLED) || defined(DART_IO_SECURE_SOCKET_DISABLED)
#error "io_service.h can only be included on builds with IO and SSL enabled"
#endif
#include "bin/builtin.h"
#include "bin/utils.h"

View file

@ -2,7 +2,7 @@
// 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.
#if defined(DART_IO_SECURE_SOCKET_DISABLED)
#if !defined(DART_IO_DISABLED) && defined(DART_IO_SECURE_SOCKET_DISABLED)
#include "bin/io_service_no_ssl.h"
@ -75,4 +75,4 @@ void FUNCTION_NAME(IOService_NewServicePort)(Dart_NativeArguments args) {
} // namespace bin
} // namespace dart
#endif // defined(DART_IO_SECURE_SOCKET_DISABLED)
#endif // !defined(DART_IO_DISABLED) && defined(DART_IO_SECURE_SOCKET_DISABLED)

View file

@ -5,6 +5,10 @@
#ifndef BIN_IO_SERVICE_NO_SSL_H_
#define BIN_IO_SERVICE_NO_SSL_H_
#if defined(DART_IO_DISABLED) || !defined(DART_IO_SECURE_SOCKET_DISABLED)
#error "io_service_no_ssl.h can only be included on builds with IO enabled"
#endif
#include "bin/builtin.h"
#include "bin/utils.h"

View file

@ -2,9 +2,10 @@
// 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.
#if defined(DART_IO_DISABLED)
#include "bin/builtin.h"
#include "bin/dartutils.h"
#include "include/dart_api.h"
namespace dart {
@ -18,3 +19,4 @@ void FUNCTION_NAME(IOService_NewServicePort)(Dart_NativeArguments args) {
} // namespace bin
} // namespace dart
#endif // defined(DART_IO_DISABLED)

View file

@ -26,7 +26,9 @@
#include "platform/globals.h"
#include "platform/hashmap.h"
#include "platform/text_buffer.h"
#if !defined(DART_PRECOMPILER)
#include "zlib/zlib.h"
#endif
namespace dart {
namespace bin {

View file

@ -2,21 +2,17 @@
// 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/platform.h"
#if !defined(DART_IO_DISABLED)
#include "include/dart_api.h"
#include "bin/platform.h"
#include "bin/file.h"
#include "bin/utils.h"
#include "include/dart_api.h"
namespace dart {
namespace bin {
const char* Platform::executable_name_ = NULL;
char* Platform::resolved_executable_name_ = NULL;
int Platform::script_index_ = 1;
char** Platform::argv_ = NULL;
void FUNCTION_NAME(Platform_NumberOfProcessors)(Dart_NativeArguments args) {
Dart_SetReturnValue(args, Dart_NewInteger(Platform::NumberOfProcessors()));
}
@ -125,3 +121,5 @@ void FUNCTION_NAME(Platform_GetVersion)(Dart_NativeArguments args) {
} // namespace bin
} // namespace dart
#endif // !defined(DART_IO_DISABLED)

View file

@ -5,7 +5,6 @@
#include "platform/globals.h"
#if defined(TARGET_OS_ANDROID)
#include "bin/file.h"
#include "bin/platform.h"
#include <signal.h> // NOLINT
@ -13,10 +12,16 @@
#include <unistd.h> // NOLINT
#include "bin/fdutils.h"
#include "bin/file.h"
namespace dart {
namespace bin {
const char* Platform::executable_name_ = NULL;
char* Platform::resolved_executable_name_ = NULL;
int Platform::script_index_ = 1;
char** Platform::argv_ = NULL;
bool Platform::Initialize() {
// Turn off the signal handler for SIGPIPE as it causes the process
// to terminate on writing to a closed pipe. Without the signal

View file

@ -5,7 +5,6 @@
#include "platform/globals.h"
#if defined(TARGET_OS_LINUX)
#include "bin/file.h"
#include "bin/platform.h"
#include <signal.h> // NOLINT
@ -13,10 +12,16 @@
#include <unistd.h> // NOLINT
#include "bin/fdutils.h"
#include "bin/file.h"
namespace dart {
namespace bin {
const char* Platform::executable_name_ = NULL;
char* Platform::resolved_executable_name_ = NULL;
int Platform::script_index_ = 1;
char** Platform::argv_ = NULL;
bool Platform::Initialize() {
// Turn off the signal handler for SIGPIPE as it causes the process
// to terminate on writing to a closed pipe. Without the signal

View file

@ -5,6 +5,8 @@
#include "platform/globals.h"
#if defined(TARGET_OS_MACOS)
#include "bin/platform.h"
#if !TARGET_OS_IOS
#include <crt_externs.h> // NOLINT
#endif // !TARGET_OS_IOS
@ -17,11 +19,15 @@
#include "bin/fdutils.h"
#include "bin/file.h"
#include "bin/platform.h"
namespace dart {
namespace bin {
const char* Platform::executable_name_ = NULL;
char* Platform::resolved_executable_name_ = NULL;
int Platform::script_index_ = 1;
char** Platform::argv_ = NULL;
bool Platform::Initialize() {
// Turn off the signal handler for SIGPIPE as it causes the process
// to terminate on writing to a closed pipe. Without the signal

View file

@ -0,0 +1,70 @@
// Copyright (c) 2016, 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.
#if defined(DART_IO_DISABLED)
#include "bin/builtin.h"
#include "bin/dartutils.h"
#include "include/dart_api.h"
namespace dart {
namespace bin {
void FUNCTION_NAME(Platform_NumberOfProcessors)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Platform is not supported on this platform"));
}
void FUNCTION_NAME(Platform_OperatingSystem)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Platform is not supported on this platform"));
}
void FUNCTION_NAME(Platform_PathSeparator)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Platform is not supported on this platform"));
}
void FUNCTION_NAME(Platform_LocalHostname)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Platform is not supported on this platform"));
}
void FUNCTION_NAME(Platform_ExecutableName)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Platform is not supported on this platform"));
}
void FUNCTION_NAME(Platform_ResolvedExecutableName)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Platform is not supported on this platform"));
}
void FUNCTION_NAME(Platform_ExecutableArguments)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Platform is not supported on this platform"));
}
void FUNCTION_NAME(Platform_Environment)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Platform is not supported on this platform"));
}
void FUNCTION_NAME(Platform_GetVersion)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Platform is not supported on this platform"));
}
} // namespace bin
} // namespace dart
#endif // !defined(DART_IO_DISABLED)

View file

@ -5,9 +5,10 @@
#include "platform/globals.h"
#if defined(TARGET_OS_WINDOWS)
#include "bin/platform.h"
#include "bin/file.h"
#include "bin/log.h"
#include "bin/platform.h"
#include "bin/socket.h"
#include "bin/utils.h"
#include "bin/utils_win.h"
@ -19,6 +20,11 @@ extern bool private_flag_windows_run_tls_destructors;
namespace bin {
const char* Platform::executable_name_ = NULL;
char* Platform::resolved_executable_name_ = NULL;
int Platform::script_index_ = 1;
char** Platform::argv_ = NULL;
bool Platform::Initialize() {
// Nothing to do on Windows.
return true;

View file

@ -2,11 +2,14 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "bin/process.h"
#include "bin/dartutils.h"
#include "bin/io_buffer.h"
#include "bin/log.h"
#include "bin/platform.h"
#include "bin/process.h"
#include "bin/socket.h"
#include "bin/utils.h"
@ -17,9 +20,6 @@ namespace bin {
static const int kProcessIdNativeField = 0;
int Process::global_exit_code_ = 0;
Mutex* Process::global_exit_code_mutex_ = new Mutex();
// Extract an array of C strings from a list of Dart strings.
static char** ExtractCStringList(Dart_Handle strings,
Dart_Handle status_handle,
@ -367,3 +367,5 @@ void FUNCTION_NAME(StringToSystemEncoding)(Dart_NativeArguments args) {
} // namespace bin
} // namespace dart
#endif // !defined(DART_IO_DISABLED)

View file

@ -2,6 +2,8 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "platform/globals.h"
#if defined(TARGET_OS_ANDROID)
@ -30,6 +32,9 @@ extern char **environ;
namespace dart {
namespace bin {
int Process::global_exit_code_ = 0;
Mutex* Process::global_exit_code_mutex_ = new Mutex();
// ProcessInfo is used to map a process id to the file descriptor for
// the pipe used to communicate the exit code of the process to Dart.
// ProcessInfo objects are kept in the static singly-linked
@ -1037,3 +1042,5 @@ void Process::ClearSignalHandler(intptr_t signal) {
} // namespace dart
#endif // defined(TARGET_OS_ANDROID)
#endif // !defined(DART_IO_DISABLED)

View file

@ -2,6 +2,8 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "platform/globals.h"
#if defined(TARGET_OS_LINUX)
@ -21,6 +23,7 @@
#include "bin/lockers.h"
#include "bin/log.h"
#include "bin/thread.h"
#include "platform/signal_blocker.h"
#include "platform/utils.h"
@ -29,6 +32,9 @@ extern char **environ;
namespace dart {
namespace bin {
int Process::global_exit_code_ = 0;
Mutex* Process::global_exit_code_mutex_ = new Mutex();
// ProcessInfo is used to map a process id to the file descriptor for
// the pipe used to communicate the exit code of the process to Dart.
// ProcessInfo objects are kept in the static singly-linked
@ -1032,3 +1038,5 @@ void Process::ClearSignalHandler(intptr_t signal) {
} // namespace dart
#endif // defined(TARGET_OS_LINUX)
#endif // !defined(DART_IO_DISABLED)

View file

@ -2,6 +2,8 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "platform/globals.h"
#if defined(TARGET_OS_MACOS)
@ -31,6 +33,9 @@
namespace dart {
namespace bin {
int Process::global_exit_code_ = 0;
Mutex* Process::global_exit_code_mutex_ = new Mutex();
// ProcessInfo is used to map a process id to the file descriptor for
// the pipe used to communicate the exit code of the process to Dart.
// ProcessInfo objects are kept in the static singly-linked
@ -1104,3 +1109,5 @@ void Process::ClearSignalHandler(intptr_t signal) {
} // namespace dart
#endif // defined(TARGET_OS_MACOS)
#endif // !defined(DART_IO_DISABLED)

View file

@ -0,0 +1,97 @@
// Copyright (c) 2016, 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.
#if defined(DART_IO_DISABLED)
#include "bin/process.h"
#include "bin/builtin.h"
#include "bin/dartutils.h"
#include "include/dart_api.h"
namespace dart {
namespace bin {
int Process::global_exit_code_ = 0;
Mutex* Process::global_exit_code_mutex_ = new Mutex();
void Process::TerminateExitCodeHandler() {
}
void FUNCTION_NAME(Process_Start)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Process is not supported on this platform"));
}
void FUNCTION_NAME(Process_Wait)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Process is not supported on this platform"));
}
void FUNCTION_NAME(Process_KillPid)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Process is not supported on this platform"));
}
void FUNCTION_NAME(Process_Exit)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Process is not supported on this platform"));
}
void FUNCTION_NAME(Process_SetExitCode)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Process is not supported on this platform"));
}
void FUNCTION_NAME(Process_GetExitCode)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Process is not supported on this platform"));
}
void FUNCTION_NAME(Process_Sleep)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Process is not supported on this platform"));
}
void FUNCTION_NAME(Process_Pid)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Process is not supported on this platform"));
}
void FUNCTION_NAME(Process_SetSignalHandler)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Process is not supported on this platform"));
}
void FUNCTION_NAME(Process_ClearSignalHandler)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Process is not supported on this platform"));
}
void FUNCTION_NAME(SystemEncodingToString)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Process is not supported on this platform"));
}
void FUNCTION_NAME(StringToSystemEncoding)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewInternalError(
"Process is not supported on this platform"));
}
} // namespace bin
} // namespace dart
#endif // !defined(DART_IO_DISABLED)

View file

@ -2,6 +2,8 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "platform/globals.h"
#if defined(TARGET_OS_WINDOWS)
@ -25,6 +27,8 @@ namespace bin {
static const int kReadHandle = 0;
static const int kWriteHandle = 1;
int Process::global_exit_code_ = 0;
Mutex* Process::global_exit_code_mutex_ = new Mutex();
// ProcessInfo is used to map a process id to the process handle,
// wait handle for registered exit code event and the pipe used to
@ -1082,3 +1086,5 @@ void Process::ClearSignalHandler(intptr_t signal) {
} // namespace dart
#endif // defined(TARGET_OS_WINDOWS)
#endif // !defined(DART_IO_DISABLED)

View file

@ -2,7 +2,7 @@
// 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.
#if !defined(DART_IO_SECURE_SOCKET_DISABLED)
#if !defined(DART_IO_DISABLED) && !defined(DART_IO_SECURE_SOCKET_DISABLED)
#include "platform/globals.h"
#if defined(TARGET_OS_MACOS) || defined(TARGET_OS_ANDROID)
@ -18,4 +18,5 @@ unsigned int root_certificates_pem_length = 0;
#endif // defined(TARGET_OS_MACOS) || defined(TARGET_OS_ANDROID)
#endif // !defined(DART_IO_SECURE_SOCKET_DISABLED)
#endif // !defined(DART_IO_DISABLED) &&
// !defined(DART_IO_SECURE_SOCKET_DISABLED)

View file

@ -5,7 +5,7 @@
#ifndef BIN_SECURE_SOCKET_H_
#define BIN_SECURE_SOCKET_H_
#if defined(DART_IO_SECURE_SOCKET_DISABLED)
#if defined(DART_IO_DISABLED) || defined(DART_IO_SECURE_SOCKET_DISABLED)
#error "secure_socket.h can only be included on builds with SSL enabled"
#endif

View file

@ -2,7 +2,7 @@
// 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.
#if !defined(DART_IO_SECURE_SOCKET_DISABLED)
#if !defined(DART_IO_DISABLED) && !defined(DART_IO_SECURE_SOCKET_DISABLED)
#include "platform/globals.h"
#if defined(TARGET_OS_ANDROID) || \
@ -1683,4 +1683,5 @@ int SSLFilter::ProcessWriteEncryptedBuffer(int start, int end) {
#endif // defined(TARGET_OS_LINUX)
#endif // !defined(DART_IO_SECURE_SOCKET_DISABLED)
#endif // !defined(DART_IO_DISABLED) &&
// !defined(DART_IO_SECURE_SOCKET_DISABLED)

View file

@ -2,7 +2,7 @@
// 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.
#if !defined(DART_IO_SECURE_SOCKET_DISABLED)
#if !defined(DART_IO_DISABLED) && !defined(DART_IO_SECURE_SOCKET_DISABLED)
#include "platform/globals.h"
#if defined(TARGET_OS_MACOS)
@ -2024,4 +2024,5 @@ OSStatus SSLFilter::ProcessWritePlaintextBuffer(intptr_t start,
#endif // defined(TARGET_OS_MACOS)
#endif // !defined(DART_IO_SECURE_SOCKET_DISABLED)
#endif // !defined(DART_IO_DISABLED) &&
// !defined(DART_IO_SECURE_SOCKET_DISABLED)

View file

@ -2,11 +2,10 @@
// 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.
#if defined(DART_IO_SECURE_SOCKET_DISABLED)
#if defined(DART_IO_DISABLED) || defined(DART_IO_SECURE_SOCKET_DISABLED)
#include "bin/builtin.h"
#include "bin/dartutils.h"
#include "include/dart_api.h"
namespace dart {
@ -100,72 +99,85 @@ void FUNCTION_NAME(SecureSocket_NewServicePort)(Dart_NativeArguments args) {
"Secure Sockets unsupported on this platform"));
}
void FUNCTION_NAME(SecurityContext_Allocate)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Secure Sockets unsupported on this platform"));
}
void FUNCTION_NAME(SecurityContext_UsePrivateKeyBytes)(
Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Secure Sockets unsupported on this platform"));
}
void FUNCTION_NAME(SecurityContext_SetAlpnProtocols)(
Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Secure Sockets unsupported on this platform"));
}
void FUNCTION_NAME(SecurityContext_SetClientAuthoritiesBytes)(
Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Secure Sockets unsupported on this platform"));
}
void FUNCTION_NAME(SecurityContext_SetTrustedCertificatesBytes)(
Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Secure Sockets unsupported on this platform"));
}
void FUNCTION_NAME(SecurityContext_AlpnSupported)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Secure Sockets unsupported on this platform"));
}
void FUNCTION_NAME(SecurityContext_TrustBuiltinRoots)(
Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Secure Sockets unsupported on this platform"));
}
void FUNCTION_NAME(SecurityContext_UseCertificateChainBytes)(
Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Secure Sockets unsupported on this platform"));
}
void FUNCTION_NAME(X509_Subject)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Secure Sockets unsupported on this platform"));
}
void FUNCTION_NAME(X509_Issuer)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Secure Sockets unsupported on this platform"));
}
void FUNCTION_NAME(X509_StartValidity)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Secure Sockets unsupported on this platform"));
}
void FUNCTION_NAME(X509_EndValidity)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Secure Sockets unsupported on this platform"));
}
class SSLFilter {
public:
static CObject* ProcessFilterRequest(const CObjectArray& request);
@ -178,4 +190,4 @@ CObject* SSLFilter::ProcessFilterRequest(const CObjectArray& request) {
} // namespace bin
} // namespace dart
#endif // defined(DART_IO_SECURE_SOCKET_DISABLED)
#endif // defined(DART_IO_DISABLED) || defined(DART_IO_SECURE_SOCKET_DISABLED)

View file

@ -2,19 +2,22 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "bin/socket.h"
#include "bin/dartutils.h"
#include "bin/io_buffer.h"
#include "bin/isolate_data.h"
#include "bin/lockers.h"
#include "bin/socket.h"
#include "bin/thread.h"
#include "bin/utils.h"
#include "include/dart_api.h"
#include "platform/globals.h"
#include "platform/utils.h"
#include "include/dart_api.h"
namespace dart {
namespace bin {
@ -874,3 +877,5 @@ intptr_t Socket::GetSocketIdNativeField(Dart_Handle socket_obj) {
} // namespace bin
} // namespace dart
#endif // !defined(DART_IO_DISABLED)

View file

@ -5,12 +5,11 @@
#ifndef BIN_SOCKET_H_
#define BIN_SOCKET_H_
#include <map>
#if defined(DART_IO_DISABLED)
#error "socket.h can only be included on builds with IO enabled"
#endif
#include "platform/globals.h"
#include "bin/builtin.h"
#include "bin/dartutils.h"
// Declare the OS-specific types ahead of defining the generic class.
#if defined(TARGET_OS_ANDROID)
#include "bin/socket_android.h"
@ -23,6 +22,11 @@
#else
#error Unknown target os.
#endif
#include <map>
#include "bin/builtin.h"
#include "bin/dartutils.h"
#include "bin/thread.h"
#include "bin/utils.h"

View file

@ -2,6 +2,8 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "platform/globals.h"
#if defined(TARGET_OS_ANDROID)
@ -569,3 +571,5 @@ bool Socket::LeaveMulticast(
} // namespace dart
#endif // defined(TARGET_OS_ANDROID)
#endif // !defined(DART_IO_DISABLED)

View file

@ -5,6 +5,10 @@
#ifndef BIN_SOCKET_ANDROID_H_
#define BIN_SOCKET_ANDROID_H_
#if !defined(BIN_SOCKET_H_)
#error Do not include socket_android.h directly. Use socket.h.
#endif
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/socket.h>

View file

@ -2,6 +2,8 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "platform/globals.h"
#if defined(TARGET_OS_LINUX)
@ -585,3 +587,5 @@ bool Socket::LeaveMulticast(
} // namespace dart
#endif // defined(TARGET_OS_LINUX)
#endif // !defined(DART_IO_DISABLED)

View file

@ -5,6 +5,10 @@
#ifndef BIN_SOCKET_LINUX_H_
#define BIN_SOCKET_LINUX_H_
#if !defined(BIN_SOCKET_H_)
#error Do not include socket_linux.h directly. Use socket.h.
#endif
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/socket.h>

View file

@ -2,6 +2,8 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "platform/globals.h"
#if defined(TARGET_OS_MACOS)
@ -623,3 +625,5 @@ bool Socket::LeaveMulticast(intptr_t fd,
} // namespace dart
#endif // defined(TARGET_OS_MACOS)
#endif // !defined(DART_IO_DISABLED)

View file

@ -5,6 +5,10 @@
#ifndef BIN_SOCKET_MACOS_H_
#define BIN_SOCKET_MACOS_H_
#if !defined(BIN_SOCKET_H_)
#error Do not include socket_macos.h directly. Use socket.h.
#endif
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/socket.h>

View file

@ -0,0 +1,148 @@
// Copyright (c) 2016, 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.
#if defined(DART_IO_DISABLED)
#include "bin/builtin.h"
#include "bin/dartutils.h"
#include "include/dart_api.h"
namespace dart {
namespace bin {
void FUNCTION_NAME(InternetAddress_Parse)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Sockets unsupported on this platform"));
}
void FUNCTION_NAME(Socket_CreateConnect)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Sockets unsupported on this platform"));
}
void FUNCTION_NAME(Socket_CreateBindConnect)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Sockets unsupported on this platform"));
}
void FUNCTION_NAME(Socket_CreateBindDatagram)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Sockets unsupported on this platform"));
}
void FUNCTION_NAME(Socket_Available)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Sockets unsupported on this platform"));
}
void FUNCTION_NAME(Socket_Read)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Sockets unsupported on this platform"));
}
void FUNCTION_NAME(Socket_RecvFrom)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Sockets unsupported on this platform"));
}
void FUNCTION_NAME(Socket_WriteList)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Sockets unsupported on this platform"));
}
void FUNCTION_NAME(Socket_SendTo)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Sockets unsupported on this platform"));
}
void FUNCTION_NAME(Socket_GetPort)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Sockets unsupported on this platform"));
}
void FUNCTION_NAME(Socket_GetRemotePeer)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Sockets unsupported on this platform"));
}
void FUNCTION_NAME(Socket_GetError)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Sockets unsupported on this platform"));
}
void FUNCTION_NAME(Socket_GetType)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Sockets unsupported on this platform"));
}
void FUNCTION_NAME(Socket_GetStdioHandle)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Sockets unsupported on this platform"));
}
void FUNCTION_NAME(Socket_GetSocketId)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Sockets unsupported on this platform"));
}
void FUNCTION_NAME(Socket_SetSocketId)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Sockets unsupported on this platform"));
}
void FUNCTION_NAME(ServerSocket_CreateBindListen)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Sockets unsupported on this platform"));
}
void FUNCTION_NAME(ServerSocket_Accept)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Sockets unsupported on this platform"));
}
void FUNCTION_NAME(Socket_GetOption)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Sockets unsupported on this platform"));
}
void FUNCTION_NAME(Socket_SetOption)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Sockets unsupported on this platform"));
}
void FUNCTION_NAME(Socket_JoinMulticast)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Sockets unsupported on this platform"));
}
void FUNCTION_NAME(Socket_LeaveMulticast)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Sockets unsupported on this platform"));
}
} // namespace bin
} // namespace dart
#endif // defined(DART_IO_DISABLED)

View file

@ -2,6 +2,8 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "platform/globals.h"
#if defined(TARGET_OS_WINDOWS)
@ -712,3 +714,5 @@ bool Socket::LeaveMulticast(
} // namespace dart
#endif // defined(TARGET_OS_WINDOWS)
#endif // !defined(DART_IO_DISABLED)

View file

@ -5,6 +5,10 @@
#ifndef BIN_SOCKET_WIN_H_
#define BIN_SOCKET_WIN_H_
#if !defined(BIN_SOCKET_H_)
#error Do not include socket_win.h directly. Use socket.h.
#endif
#include <iphlpapi.h>
#include <mswsock.h>
#include <winsock2.h>

View file

@ -2,17 +2,19 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "bin/stdio.h"
#include "bin/builtin.h"
#include "bin/dartutils.h"
#include "bin/utils.h"
#include "include/dart_api.h"
#include "platform/globals.h"
#include "platform/utils.h"
#include "include/dart_api.h"
namespace dart {
namespace bin {
@ -69,3 +71,5 @@ void FUNCTION_NAME(Stdout_GetTerminalSize)(Dart_NativeArguments args) {
} // namespace bin
} // namespace dart
#endif // !defined(DART_IO_DISABLED)

View file

@ -5,6 +5,10 @@
#ifndef BIN_STDIO_H_
#define BIN_STDIO_H_
#if defined(DART_IO_DISABLED)
#error "stdio.h can only be included on builds with IO enabled"
#endif
#include "bin/builtin.h"
#include "bin/utils.h"

View file

@ -2,6 +2,8 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "platform/globals.h"
#if defined(TARGET_OS_ANDROID)
@ -79,3 +81,5 @@ bool Stdout::GetTerminalSize(intptr_t fd, int size[2]) {
} // namespace dart
#endif // defined(TARGET_OS_ANDROID)
#endif // !defined(DART_IO_DISABLED)

View file

@ -2,6 +2,8 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "platform/globals.h"
#if defined(TARGET_OS_LINUX)
@ -79,3 +81,5 @@ bool Stdout::GetTerminalSize(intptr_t fd, int size[2]) {
} // namespace dart
#endif // defined(TARGET_OS_LINUX)
#endif // !defined(DART_IO_DISABLED)

View file

@ -2,6 +2,8 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "platform/globals.h"
#if defined(TARGET_OS_MACOS)
@ -79,3 +81,5 @@ bool Stdout::GetTerminalSize(intptr_t fd, int size[2]) {
} // namespace dart
#endif // defined(TARGET_OS_MACOS)
#endif // !defined(DART_IO_DISABLED)

View file

@ -0,0 +1,52 @@
// Copyright (c) 2016, 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.
#if defined(DART_IO_DISABLED)
#include "bin/builtin.h"
#include "bin/dartutils.h"
#include "include/dart_api.h"
namespace dart {
namespace bin {
void FUNCTION_NAME(Stdin_ReadByte)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Stdin unsupported on this platform"));
}
void FUNCTION_NAME(Stdin_GetEchoMode)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Stdin unsupported on this platform"));
}
void FUNCTION_NAME(Stdin_SetEchoMode)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Stdin unsupported on this platform"));
}
void FUNCTION_NAME(Stdin_GetLineMode)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Stdin unsupported on this platform"));
}
void FUNCTION_NAME(Stdin_SetLineMode)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Stdin unsupported on this platform"));
}
void FUNCTION_NAME(Stdout_GetTerminalSize)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Stdout unsupported on this platform"));
}
} // namespace bin
} // namespace dart
#endif // defined(DART_IO_DISABLED)

View file

@ -2,6 +2,8 @@
// 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.
#if !defined(DART_IO_DISABLED)
#include "platform/globals.h"
#if defined(TARGET_OS_WINDOWS)
@ -92,3 +94,5 @@ bool Stdout::GetTerminalSize(intptr_t fd, int size[2]) {
} // namespace dart
#endif // defined(TARGET_OS_WINDOWS)
#endif // !defined(DART_IO_DISABLED)