1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
|
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "./Node.hh"
#include "./Layout.hh"
#include "./Size.hh"
#include "./Value.hh"
#include "./Config.hh"
#include <yoga/Yoga.h>
#include <emscripten/bind.h>
using namespace emscripten;
EMSCRIPTEN_BINDINGS(YOGA_LAYOUT) {
class_<MeasureCallback>("MeasureCallback")
.function("measure", &MeasureCallback::measure, pure_virtual())
.allow_subclass<MeasureCallbackWrapper>("MeasureCallbackWrapper");
class_<DirtiedCallback>("DirtiedCallback")
.function("dirtied", &DirtiedCallback::dirtied, pure_virtual())
.allow_subclass<DirtiedCallbackWrapper>("DirtiedCallbackWrapper");
class_<Config>("Config")
.constructor<>(&Config::create, allow_raw_pointers())
.class_function<>("create", &Config::create, allow_raw_pointers())
.class_function<>("destroy", &Config::destroy, allow_raw_pointers())
.function(
"setExperimentalFeatureEnabled",
&Config::setExperimentalFeatureEnabled)
.function("setPointScaleFactor", &Config::setPointScaleFactor)
.function(
"setUseLegacyStretchBehaviour", &Config::setUseLegacyStretchBehaviour)
.function("setUseWebDefaults", &Config::setUseWebDefaults)
.function(
"isExperimentalFeatureEnabled", &Config::isExperimentalFeatureEnabled)
.function("useLegacyStretchBehaviour", &Config::useLegacyStretchBehaviour)
.function("useWebDefaults", &Config::useWebDefaults);
value_object<Layout>("Layout")
.field("left", &Layout::left)
.field("right", &Layout::right)
.field("top", &Layout::top)
.field("bottom", &Layout::bottom)
.field("width", &Layout::width)
.field("height", &Layout::height);
value_object<Size>("Size")
.field("width", &Size::width)
.field("height", &Size::height);
value_object<Value>("Value")
.field("value", &Value::value)
.field("unit", &Value::unit);
class_<Node>("Node")
.constructor<>(&Node::createDefault, allow_raw_pointers())
.class_function<>(
"createDefault", &Node::createDefault, allow_raw_pointers())
.class_function<>(
"createWithConfig", &Node::createWithConfig, allow_raw_pointers())
.class_function<>("destroy", &Node::destroy, allow_raw_pointers())
.function("reset", &Node::reset)
.function("copyStyle", &Node::copyStyle)
.function("setPositionType", &Node::setPositionType)
.function("setPosition", &Node::setPosition)
.function("setPositionPercent", &Node::setPositionPercent)
.function("setAlignContent", &Node::setAlignContent)
.function("setAlignItems", &Node::setAlignItems)
.function("setAlignSelf", &Node::setAlignSelf)
.function("setFlexDirection", &Node::setFlexDirection)
.function("setFlexWrap", &Node::setFlexWrap)
.function("setJustifyContent", &Node::setJustifyContent)
.function("setMargin", &Node::setMargin)
.function("setMarginPercent", &Node::setMarginPercent)
.function("setMarginAuto", &Node::setMarginAuto)
.function("setOverflow", &Node::setOverflow)
.function("setDisplay", &Node::setDisplay)
.function("setFlex", &Node::setFlex)
.function("setFlexBasis", &Node::setFlexBasis)
.function("setFlexBasisPercent", &Node::setFlexBasisPercent)
.function("setFlexBasisAuto", &Node::setFlexBasisAuto)
.function("setFlexGrow", &Node::setFlexGrow)
.function("setFlexShrink", &Node::setFlexShrink)
.function("setWidth", &Node::setWidth)
.function("setWidthPercent", &Node::setWidthPercent)
.function("setWidthAuto", &Node::setWidthAuto)
.function("setHeight", &Node::setHeight)
.function("setHeightPercent", &Node::setHeightPercent)
.function("setHeightAuto", &Node::setHeightAuto)
.function("setMinWidth", &Node::setMinWidth)
.function("setMinWidthPercent", &Node::setMinWidthPercent)
.function("setMinHeight", &Node::setMinHeight)
.function("setMinHeightPercent", &Node::setMinHeightPercent)
.function("setMaxWidth", &Node::setMaxWidth)
.function("setMaxWidthPercent", &Node::setMaxWidthPercent)
.function("setMaxHeight", &Node::setMaxHeight)
.function("setMaxHeightPercent", &Node::setMaxHeightPercent)
.function("setAspectRatio", &Node::setAspectRatio)
.function("setBorder", &Node::setBorder)
.function("setPadding", &Node::setPadding)
.function("setPaddingPercent", &Node::setPaddingPercent)
.function("setGap", &Node::setGap)
.function("getPositionType", &Node::getPositionType)
.function("getPosition", &Node::getPosition)
.function("getAlignContent", &Node::getAlignContent)
.function("getAlignItems", &Node::getAlignItems)
.function("getAlignSelf", &Node::getAlignSelf)
.function("getFlexDirection", &Node::getFlexDirection)
.function("getFlexWrap", &Node::getFlexWrap)
.function("getJustifyContent", &Node::getJustifyContent)
.function("getMargin", &Node::getMargin)
.function("getFlexBasis", &Node::getFlexBasis)
.function("getFlexGrow", &Node::getFlexGrow)
.function("getFlexShrink", &Node::getFlexShrink)
.function("getWidth", &Node::getWidth)
.function("getHeight", &Node::getHeight)
.function("getMinWidth", &Node::getMinWidth)
.function("getMinHeight", &Node::getMinHeight)
.function("getMaxWidth", &Node::getMaxWidth)
.function("getMaxHeight", &Node::getMaxHeight)
.function("getAspectRatio", &Node::getAspectRatio)
.function("getBorder", &Node::getBorder)
.function("getOverflow", &Node::getOverflow)
.function("getDisplay", &Node::getDisplay)
.function("getPadding", &Node::getPadding)
.function("getGap", &Node::getGap)
.function("insertChild", &Node::insertChild, allow_raw_pointers())
.function("removeChild", &Node::removeChild, allow_raw_pointers())
.function("getChildCount", &Node::getChildCount)
.function("getParent", &Node::getParent, allow_raw_pointers())
.function("getChild", &Node::getChild, allow_raw_pointers())
.function("isReferenceBaseline", &Node::isReferenceBaseline)
.function("setIsReferenceBaseline", &Node::setIsReferenceBaseline)
.function("setMeasureFunc", &Node::setMeasureFunc, allow_raw_pointers())
.function("unsetMeasureFunc", &Node::unsetMeasureFunc)
.function("setDirtiedFunc", &Node::setDirtiedFunc, allow_raw_pointers())
.function("unsetDirtiedFunc", &Node::unsetDirtiedFunc)
.function("markDirty", &Node::markDirty)
.function("isDirty", &Node::isDirty)
.function("calculateLayout", &Node::calculateLayout)
.function("getComputedLeft", &Node::getComputedLeft)
.function("getComputedRight", &Node::getComputedRight)
.function("getComputedTop", &Node::getComputedTop)
.function("getComputedBottom", &Node::getComputedBottom)
.function("getComputedWidth", &Node::getComputedWidth)
.function("getComputedHeight", &Node::getComputedHeight)
.function("getComputedLayout", &Node::getComputedLayout)
.function("getComputedMargin", &Node::getComputedMargin)
.function("getComputedBorder", &Node::getComputedBorder)
.function("getComputedPadding", &Node::getComputedPadding);
}
|