Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
core.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2021 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7#include <string>
8
10
11class Something {
12public:
13 Something(std::string n): fName(n) {}
14
15 const std::string getName() {
16 return fName;
17 }
18
19 void setName(std::string name) {
20 fName = name;
21 }
22
23private:
24 std::string fName;
25};
26
28 TS_PRIVATE_EXPORT("_privateFunction(x: number, y: number): number")
29 function("_privateFunction", optional_override([](int x, int y)->size_t {
30 return x * y;
31 }));
32
33 /**
34 * This function does a public thing.
35 * @param input an ice cream flavor
36 */
37 TS_EXPORT("publicFunction(input: string): void")
38 function("publicFunction", optional_override([](std::string s)->void {
39 printf("Hello %s\n", s.c_str());
40 }));
41
42 /**
43 * The Something class is quite something. See SkSomething.h for more.
44 */
45 class_<Something>("Something")
46 /**
47 * Returns a Something with the provided name.
48 * @param name
49 */
50 TS_EXPORT("new(name: string): Something")
51 .constructor<std::string>()
52 /**
53 * Returns the associated name.
54 */
55 TS_EXPORT("getName(): string")
56 .function("getName", &Something::getName)
57 TS_PRIVATE_EXPORT("setName(name: string): void")
58 .function("_setName", &Something::setName);
59}
#define TS_PRIVATE_EXPORT(ts_code)
Definition bindings.h:44
#define TS_EXPORT(ts_code)
Definition bindings.h:45
const std::string getName()
Definition core.cpp:15
Something(std::string n)
Definition core.cpp:13
void setName(std::string name)
Definition core.cpp:19
struct MyStruct s
Dart_NativeFunction function
Definition fuchsia.cc:51
const char * name
Definition fuchsia.cc:50
double y
double x
EMSCRIPTEN_BINDINGS(Core)
Definition core.cpp:27