Flutter Engine
The Flutter Engine
Classes | Typedefs | Functions
extension.cpp File Reference
#include <string>
#include "experimental/tskit/bindings/bindings.h"

Go to the source code of this file.

Classes

struct  SkRect
 
class  Extension
 
struct  CompoundObj
 

Typedefs

typedef float SkScalar
 

Functions

 EMSCRIPTEN_BINDINGS (Extension)
 

Typedef Documentation

◆ SkScalar

typedef float SkScalar

Definition at line 12 of file extension.cpp.

Function Documentation

◆ EMSCRIPTEN_BINDINGS()

EMSCRIPTEN_BINDINGS ( Extension  )

The Extension class extends the core components.

Returns an extension with the provided property.

Parameters
name- if not provided, use a default value

Returns the associated property.

@type number

@type string

This field (gamma) should be documented. The default value is 1.0 if not set. @type @optional number

Definition at line 48 of file extension.cpp.

48 {
49 TS_PRIVATE_EXPORT("_privateExtension(rPtr: number, len: number): number")
50 function("_privateExtension", optional_override([](uintptr_t rPtr, size_t len)->int {
51 int containsPoint = 0;
52 SkRect* rects = reinterpret_cast<SkRect*>(rPtr);
53 for (int i = 0; i < len; i++) {
54 if (rects[i].contains(5, 5)) {
55 containsPoint++;
56 }
57 }
58 return containsPoint;
59 }));
60
61 TS_PRIVATE_EXPORT("_withObject(obj: CompoundObj): void")
62 function("_withObject", optional_override([](CompoundObj o)->void {
63 printf("Object %d %s %f\n", o.alpha, o.beta.c_str(), o.gamma);
64 }));
65
66 /**
67 * The Extension class extends the core components.
68 */
69 class_<Extension>("Extension")
70 .constructor<>()
71 /**
72 * Returns an extension with the provided property.
73 * @param name - if not provided, use a default value
74 */
75 TS_EXPORT("new(name?: string): Extension")
76 .constructor<std::string>()
77 /**
78 * Returns the associated property.
79 */
80 TS_EXPORT("getProp(): string")
81 .function("getProp", &Extension::getProp)
82 TS_PRIVATE_EXPORT("setProp(p: string): void")
83 .function("_setProp", &Extension::setProp);
84
85 value_object<CompoundObj>("CompoundObj")
86 /** @type number */
87 .field("alpha", &CompoundObj::alpha)
88 /** @type string */
89 .field("beta", &CompoundObj::beta)
90 /**
91 * This field (gamma) should be documented.
92 * The default value is 1.0 if not set.
93 * @type @optional number
94 */
95 .field("gamma", &CompoundObj::gamma);
96}
#define TS_PRIVATE_EXPORT(ts_code)
Definition: bindings.h:44
#define TS_EXPORT(ts_code)
Definition: bindings.h:45
const std::string getProp()
Definition: extension.cpp:29
void setProp(std::string p)
Definition: extension.cpp:33
Dart_NativeFunction function
Definition: fuchsia.cc:51
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: SkSLString.cpp:83
constexpr bool contains(std::string_view str, std::string_view needle)
Definition: SkStringView.h:41
float gamma
Definition: extension.cpp:44
std::string beta
Definition: extension.cpp:43