Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
dart-lang
sdk
runtime
vm
compiler
ffi
unit_test.cc
Go to the documentation of this file.
1
// Copyright (c) 2020, 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 "
vm/compiler/ffi/unit_test.h
"
6
7
#include "
platform/syslog.h
"
8
#include "
vm/globals.h
"
9
10
namespace
dart
{
11
namespace
compiler
{
12
namespace
ffi {
13
14
#if defined(DART_TARGET_OS_WINDOWS)
15
const
char
*
kOs
=
"win"
;
16
#else
17
const
char
*
kOs
= kTargetOperatingSystemName;
18
#endif
19
20
void
WriteToFile
(
char
* path,
const
char
* contents) {
21
FILE* file;
22
file = fopen(path,
"w"
);
23
if
(file !=
nullptr
) {
24
fprintf(file,
"%s"
, contents);
25
}
else
{
26
Syslog::Print
(
"Error %d \n"
, errno);
27
}
28
fclose(file);
29
}
30
31
void
ReadFromFile
(
char
* path,
char
** buffer_pointer) {
32
FILE* file = fopen(path,
"rb"
);
33
if
(file ==
nullptr
) {
34
Syslog::Print
(
"Error %d \n"
, errno);
35
return
;
36
}
37
38
fseek(file, 0, SEEK_END);
39
size_t
size = ftell(file);
40
rewind
(file);
41
42
char
*
buffer
=
reinterpret_cast<
char
*
>
(
malloc
(
sizeof
(
char
) * (size + 1)));
43
44
fread(
buffer
, 1, size, file);
45
buffer
[size] = 0;
46
47
fclose(file);
48
*buffer_pointer =
buffer
;
49
}
50
51
}
// namespace ffi
52
}
// namespace compiler
53
}
// namespace dart
rewind
static bool rewind(EdgeList *activeEdges, Vertex **current, Vertex *dst, const Comparator &c)
Definition
GrTriangulator.cpp:745
dart::Syslog::Print
static void Print(const char *format,...) PRINTF_ATTRIBUTE(1
unit_test.h
buffer
static const uint8_t buffer[]
Definition
fl_pixel_buffer_texture_test.cc:44
compiler
Definition
compiler.py:1
dart::compiler::ffi::WriteToFile
void WriteToFile(char *path, const char *contents)
Definition
unit_test.cc:20
dart::compiler::ffi::ReadFromFile
void ReadFromFile(char *path, char **buffer_pointer)
Definition
unit_test.cc:31
dart::compiler::ffi::kOs
const char * kOs
Definition
unit_test.cc:17
dart
Definition
dart_vm.cc:33
dart::malloc
void * malloc(size_t size)
Definition
allocation.cc:19
syslog.h
globals.h
Generated on Fri Apr 26 2024 06:15:20 for Flutter Engine by
1.9.8