Flutter Engine
The Flutter Engine
bindings1.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 * This is not a real C++ file, but used to test the parsing of gen_types
8 */
9#include <string>
10
12
14 TS_PRIVATE_EXPORT("_privateFunction2(x: number, y: number): number")
15 function("_privateFunction2", optional_override([](int x, int y)->size_t {
16 return x * y;
17 }));
18
19 /**
20 * This function does a public thing.
21 * @param input an ice cream flavor
22 */
23 TS_EXPORT("publicFunction2(input: string): void")
24 function("publicFunction2", optional_override([](std::string s)->void {
25 printf("Hello %s\n", s.c_str());
26 }));
27
28 /**
29 * The Something class is quite something. See SkSomething.h for more.
30 */
31 class_<Something>("Something")
32 /**
33 * Returns a Something with the provided name.
34 * @param name
35 */
36 TS_EXPORT("new(name: string): Something")
37 .constructor<std::string>()
38 /**
39 * Returns the associated name.
40 */
41 TS_EXPORT("getName(): string")
42 .function("getName", &Something::getName)
43 TS_PRIVATE_EXPORT("_setName(name: string): void")
44 .function("_setName", &Something::setName);
45
46 /**
47 * The AnotherClass class is another class.
48 */
49 class_<AnotherClass>("AnotherClass")
50 TS_EXPORT("new(): AnotherClass")
51 .constructor<>()
52 /**
53 * Returns a Something with the provided name.
54 * @param name
55 * @param thing - will be used, I promise.
56 */
57 TS_EXPORT("new(name: string, thing: Something): AnotherClass")
58 .constructor<std::string,Something>()
59 /**
60 * Returns the associated thing.
61 */
62 TS_EXPORT("get(): Something")
63 .function("get", &AnotherClass::get);
64
65 value_object<SomeValueObject>("SomeValueObject")
66 /**
67 The number of columns that the frobulator needs.
68 @type @optional number
69 */
70 .field("columns", &SomeValueObject::columns)
71 /**
72 * The object associated with the frobulator.
73 * @type AnotherClass
74 */
75 .field("object", &SomeValueObject::object)
76 /** @type string*/
77 .field("name", &SomeValueObject::slot)
78 /**
79 * @type boolean
80 */
81 .field("isInteger", &SomeValueObject::isInteger);
82
83 TS_PRIVATE_EXPORT("_privateFunction1(ptr: number): number;")
84 function("_privateFunction1", &SkCanvas::whatever);
85
86 /**
87 * This function does another public thing.
88 * @param input an ice cream flavor
89 */
90 TS_EXPORT("publicFunction1(): boolean;")
91 function("publicFunction1", &SkCanvas::blerg);
92
93 /**
94 * @type boolean
95 */
96 constant("hasBird", true);
97 /**
98 * This is the flag which is a lot of fun.
99 * It is used in a variety of ways.
100 * #funwithflags
101 * @type number
102 */
103 constant("SOME_FLAG", 0x2);
104
105#ifdef SK_EXTRA_FEATURE
106 /**
107 * This is set if the extra feature is compiled in.
108 * @type @optional string
109 */
110 constant("optionalConst", "foo");
111#endif
112}
EMSCRIPTEN_BINDINGS(Core)
Definition: bindings1.cpp:13
#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
void setName(std::string name)
Definition: core.cpp:19
struct MyStruct s
Dart_NativeFunction function
Definition: fuchsia.cc:51
double y
double x
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: SkSLString.cpp:83
const myers::Point & get(const myers::Segment &)