Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
ffi_test_dynamic_library.cc
Go to the documentation of this file.
1// Copyright (c) 2019, 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 <stdlib.h>
6#include <string.h>
7#include <iostream>
8
9#if defined(_WIN32)
10#define DART_EXPORT extern "C" __declspec(dllexport)
11#else
12#define DART_EXPORT \
13 extern "C" __attribute__((visibility("default"))) __attribute((used))
14#endif
15
17 return 42;
18}
19
20DART_EXPORT double timesFour(double d) {
21 return d * 4.0;
22}
23
24// Wrap memmove so we can easily find it on all platforms.
25//
26// We use this in our samples to illustrate resource lifetime management.
27DART_EXPORT void MemMove(void* destination, void* source, intptr_t num_bytes) {
28 memmove(destination, source, num_bytes);
29}
30
31// Some opaque struct.
32typedef struct {
34
36 void* pointer = malloc(sizeof(int64_t));
37
38 // Dummy initialize.
39 static_cast<int64_t*>(pointer)[0] = 10;
40
41 return static_cast<some_resource*>(pointer);
42}
43
45 // Dummy change.
46 reinterpret_cast<int64_t*>(resource)[0] += 10;
47}
48
50 free(resource);
51}
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition: main.cc:19
SkBitmap source
Definition: examples.cpp:12
DART_EXPORT void UseResource(some_resource *resource)
DART_EXPORT void ReleaseResource(some_resource *resource)
DART_EXPORT intptr_t return42()
DART_EXPORT void MemMove(void *destination, void *source, intptr_t num_bytes)
DART_EXPORT double timesFour(double d)
DART_EXPORT some_resource * AllocateResource()
#define DART_EXPORT