Flutter Engine
The Flutter Engine
Macros | Functions
native_functions.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "include/dart_api.h"

Go to the source code of this file.

Macros

#define ENSURE(X)
 
#define ENSURE_VALID(X)   ENSURE(!Dart_IsError(X))
 

Functions

void Function1Uint8 (Dart_NativeArguments args)
 
void Function20Int64 (Dart_NativeArguments args)
 
void Function1Double (Dart_NativeArguments args)
 
void Function20Double (Dart_NativeArguments args)
 
void Function1Handle (Dart_NativeArguments args)
 
void Function20Handle (Dart_NativeArguments args)
 
DART_EXPORT Dart_Handle GetRootLibraryUrl ()
 
Dart_NativeFunction NativeEntryResolver (Dart_Handle name, int num_of_arguments, bool *auto_setup_scope)
 
DART_EXPORT void SetNativeResolverForTest (Dart_Handle url)
 

Macro Definition Documentation

◆ ENSURE

#define ENSURE (   X)
Value:
if (!(X)) { \
fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, "Check failed: " #X); \
exit(1); \
}
static const SkScalar X
Definition: StrokeBench.cpp:54

Definition at line 14 of file native_functions.c.

◆ ENSURE_VALID

#define ENSURE_VALID (   X)    ENSURE(!Dart_IsError(X))

Definition at line 20 of file native_functions.c.

Function Documentation

◆ Function1Double()

void Function1Double ( Dart_NativeArguments  args)

Definition at line 42 of file native_functions.c.

42 {
43 double arg = 0.0;
44 Dart_GetNativeDoubleArgument(args, /*index=*/0, &arg);
46}
DART_EXPORT void Dart_SetDoubleReturnValue(Dart_NativeArguments args, double retval)
DART_EXPORT Dart_Handle Dart_GetNativeDoubleArgument(Dart_NativeArguments args, int index, double *value)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args

◆ Function1Handle()

void Function1Handle ( Dart_NativeArguments  args)

Definition at line 58 of file native_functions.c.

58 {
59 Dart_Handle arg = Dart_GetNativeArgument(args, /*index=*/0);
61}
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args, int index)
DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args, Dart_Handle retval)

◆ Function1Uint8()

void Function1Uint8 ( Dart_NativeArguments  args)

Definition at line 26 of file native_functions.c.

26 {
27 int64_t arg = 0;
28 Dart_GetNativeIntegerArgument(args, /*index=*/0, &arg);
30}
DART_EXPORT void Dart_SetIntegerReturnValue(Dart_NativeArguments args, int64_t retval)
DART_EXPORT Dart_Handle Dart_GetNativeIntegerArgument(Dart_NativeArguments args, int index, int64_t *value)

◆ Function20Double()

void Function20Double ( Dart_NativeArguments  args)

Definition at line 48 of file native_functions.c.

48 {
49 double arg = 0;
50 double result = 0;
51 for (int i = 0; i < 20; i++) {
52 Dart_GetNativeDoubleArgument(args, /*index=*/i, &arg);
53 result += arg;
54 }
56}
GAsyncResult * result

◆ Function20Handle()

void Function20Handle ( Dart_NativeArguments  args)

Definition at line 63 of file native_functions.c.

63 {
64 Dart_Handle arg = Dart_GetNativeArgument(args, /*index=*/0);
66}

◆ Function20Int64()

void Function20Int64 ( Dart_NativeArguments  args)

Definition at line 32 of file native_functions.c.

32 {
33 int64_t arg = 0;
34 int64_t result = 0;
35 for (int i = 0; i < 20; i++) {
36 Dart_GetNativeIntegerArgument(args, /*index=*/i, &arg);
37 result += arg;
38 }
40}

◆ GetRootLibraryUrl()

DART_EXPORT Dart_Handle GetRootLibraryUrl ( )

Definition at line 72 of file native_functions.c.

72 {
73 Dart_Handle root_lib = Dart_RootLibrary();
74 Dart_Handle lib_url = Dart_LibraryUrl(root_lib);
75 ENSURE_VALID(lib_url);
76 return lib_url;
77}
#define ENSURE_VALID(X)
DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library)
DART_EXPORT Dart_Handle Dart_RootLibrary(void)

◆ NativeEntryResolver()

Dart_NativeFunction NativeEntryResolver ( Dart_Handle  name,
int  num_of_arguments,
bool *  auto_setup_scope 
)

Definition at line 79 of file native_functions.c.

81 {
83
84 ENSURE(auto_setup_scope != NULL);
85 *auto_setup_scope = true;
86
87 const char* name_str = NULL;
89
90 if (strcmp(name_str, "Function1Uint8") == 0 && num_of_arguments == 1) {
91 return &Function1Uint8;
92 } else if (strcmp(name_str, "Function20Int64") == 0 &&
93 num_of_arguments == 20) {
94 return &Function20Int64;
95 } else if (strcmp(name_str, "Function1Double") == 0 &&
96 num_of_arguments == 1) {
97 return &Function1Double;
98 } else if (strcmp(name_str, "Function20Double") == 0 &&
99 num_of_arguments == 20) {
100 return &Function20Double;
101 } else if (strcmp(name_str, "Function1Handle") == 0 &&
102 num_of_arguments == 1) {
103 return &Function1Handle;
104 } else if (strcmp(name_str, "Function20Handle") == 0 &&
105 num_of_arguments == 20) {
106 return &Function20Handle;
107 }
108
109 // Unreachable in benchmark.
110 ENSURE(false);
111}
void * Function1Handle(void *a)
uint8_t Function1Uint8(uint8_t x)
void * Function20Handle(void *a, void *b, void *c, void *d, void *e, void *f, void *g, void *h, void *i, void *j, void *k, void *l, void *m, void *n, void *o, void *p, void *q, void *r, void *s, void *t)
int64_t Function20Int64(int64_t a, int64_t b, int64_t c, int64_t d, int64_t e, int64_t f, int64_t g, int64_t h, int64_t i, int64_t j, int64_t k, int64_t l, int64_t m, int64_t n, int64_t o, int64_t p, int64_t q, int64_t r, int64_t s, int64_t t)
double Function1Double(double x)
double Function20Double(double a, double b, double c, double d, double e, double f, double g, double h, double i, double j, double k, double l, double m, double n, double o, double p, double q, double r, double s, double t)
#define ENSURE(X)
DART_EXPORT Dart_Handle Dart_StringToCString(Dart_Handle str, const char **cstr)
DART_EXPORT bool Dart_IsString(Dart_Handle object)
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ SetNativeResolverForTest()

DART_EXPORT void SetNativeResolverForTest ( Dart_Handle  url)

Definition at line 113 of file native_functions.c.

113 {
114 Dart_Handle library = Dart_LookupLibrary(url);
115 ENSURE_VALID(library);
119}
Dart_NativeFunction NativeEntryResolver(Dart_Handle name, int num_of_arguments, bool *auto_setup_scope)
DART_EXPORT Dart_Handle Dart_SetNativeResolver(Dart_Handle library, Dart_NativeEntryResolver resolver, Dart_NativeEntrySymbol symbol)
DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url)