Flutter Engine
The Flutter Engine
platform.cc
Go to the documentation of this file.
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/platform.h"
6
7#include "bin/dartutils.h"
8#include "bin/file.h"
9#include "bin/utils.h"
10#include "include/dart_api.h"
11
12namespace dart {
13namespace bin {
14
15AcqRelAtomic<const char*> Platform::resolved_executable_name_ = nullptr;
16
19}
20
23 ThrowIfError(str);
25}
26
29 if (version == nullptr) {
31 } else {
33 ThrowIfError(str);
35 }
36}
37
40 ThrowIfError(str);
42}
43
45 const intptr_t HOSTNAME_LENGTH = 256;
46 char hostname[HOSTNAME_LENGTH];
47 if (Platform::LocalHostname(hostname, HOSTNAME_LENGTH)) {
48 Dart_Handle str = DartUtils::NewString(hostname);
49 ThrowIfError(str);
51 } else {
53 }
54}
55
57 if (Platform::GetExecutableName() != nullptr) {
60 } else {
62 }
63}
64
66 if (Platform::GetResolvedExecutableName() != nullptr) {
69 } else {
71 }
72}
73
76 char** argv = Platform::GetArgv();
77 Dart_Handle string_type = DartUtils::GetDartType("dart:core", "String");
78 ThrowIfError(string_type);
81 for (intptr_t i = 1; i < end; i++) {
83 ThrowIfError(str);
85 }
87}
88
90 intptr_t count = 0;
92 if (env == nullptr) {
93 OSError error(-1, "Failed to retrieve environment variables.",
96 } else {
99 intptr_t result_idx = 0;
100 for (intptr_t env_idx = 0; env_idx < count; env_idx++) {
101 Dart_Handle str = DartUtils::NewString(env[env_idx]);
102 if (Dart_IsError(str)) {
103 // Silently skip over environment entries that are not valid UTF8
104 // strings.
105 continue;
106 }
107 Dart_Handle error = Dart_ListSetAt(result, result_idx, str);
109 result_idx++;
110 }
112 }
113}
114
117}
118
120 const char* locale = Platform::LocaleName();
121 if (locale == nullptr) {
123 } else {
125 }
126}
127
128} // namespace bin
129} // namespace dart
int count
Definition: FontMgrTest.cpp:50
#define FUNCTION_NAME(name)
Definition: builtin.h:19
static Dart_Handle NewDartOSError()
Definition: dartutils.cc:702
static Dart_Handle NewString(const char *str)
Definition: dartutils.h:214
static Dart_Handle GetDartType(const char *library_url, const char *class_name)
Definition: dartutils.cc:696
static const char * PathSeparator()
static bool LocalHostname(char *buffer, intptr_t buffer_length)
static const char * GetExecutableName()
static int GetScriptIndex()
Definition: platform.h:96
static const char * LocaleName()
static const char * OperatingSystem()
Definition: platform.h:32
static const char * GetResolvedExecutableName()
Definition: platform.h:75
static char ** Environment(intptr_t *count)
static const char * OperatingSystemVersion()
static int NumberOfProcessors()
static char ** GetArgv()
Definition: platform.h:97
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
struct _Dart_NativeArguments * Dart_NativeArguments
Definition: dart_api.h:3019
glong glong end
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
const uint8_t uint32_t uint32_t GError ** error
GAsyncResult * result
char ** argv
Definition: library.h:9
void FUNCTION_NAME() Platform_Environment(Dart_NativeArguments args)
Definition: platform.cc:89
static Dart_Handle ThrowIfError(Dart_Handle handle)
Definition: dartutils.h:31
void FUNCTION_NAME() Platform_OperatingSystemVersion(Dart_NativeArguments args)
Definition: platform.cc:27
void FUNCTION_NAME() Platform_ResolvedExecutableName(Dart_NativeArguments args)
Definition: platform.cc:65
void FUNCTION_NAME() Platform_GetVersion(Dart_NativeArguments args)
Definition: platform.cc:115
void FUNCTION_NAME() Platform_PathSeparator(Dart_NativeArguments args)
Definition: platform.cc:38
void FUNCTION_NAME() Platform_ExecutableName(Dart_NativeArguments args)
Definition: platform.cc:56
void FUNCTION_NAME() Platform_NumberOfProcessors(Dart_NativeArguments args)
Definition: platform.cc:17
void FUNCTION_NAME() Platform_OperatingSystem(Dart_NativeArguments args)
Definition: platform.cc:21
void FUNCTION_NAME() Platform_LocaleName(Dart_NativeArguments args)
Definition: platform.cc:119
void FUNCTION_NAME() Platform_LocalHostname(Dart_NativeArguments args)
Definition: platform.cc:44
void FUNCTION_NAME() Platform_ExecutableArguments(Dart_NativeArguments args)
Definition: platform.cc:74
Definition: dart_vm.cc:33
DART_EXPORT Dart_Handle Dart_NewInteger(int64_t value)
DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args, Dart_Handle retval)
DART_EXPORT Dart_Handle Dart_NewListOfTypeFilled(Dart_Handle element_type, Dart_Handle fill_object, intptr_t length)
DART_EXPORT const char * Dart_VersionString()
DART_EXPORT Dart_Handle Dart_ListSetAt(Dart_Handle list, intptr_t index, Dart_Handle value)
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
DART_EXPORT Dart_Handle Dart_EmptyString()
DART_EXPORT Dart_Handle Dart_NewList(intptr_t length)
DART_EXPORT Dart_Handle Dart_Null()
DART_EXPORT Dart_Handle Dart_NewStringFromCString(const char *str)
Definition: __init__.py:1