Unboxing in the Last Lambda Function
exports[" setScale" ] = [](const boxed& nodePath_) -> boxed {
return [=](const boxed& x_) -> boxed {
return [=](const boxed& y_) -> boxed {
return [=](const boxed& z_) -> boxed {
return [=]() -> boxed {
auto nodePath = unbox<NodePath>(nodePath_);
const auto x = unbox<double >(x_);
const auto y = unbox<double >(y_);
const auto z = unbox<double >(z_);
nodePath.set_scale (x, y, z);
return boxed ();
};
};
};
};
};
Unboxing in the First Lambda Function and Capturing by Reference
exports[" setScale" ] = [](const boxed& nodePath_) -> boxed {
auto nodePath = unbox<NodePath>(nodePath_);
return [&](const boxed& x_) -> boxed {
const auto x = unbox<double >(x_);
return [&](const boxed& y_) -> boxed {
const auto y = unbox<double >(y_);
return [&](const boxed& z_) -> boxed {
const auto z = unbox<double >(z_);
return [&]() -> boxed {
nodePath.set_scale (x, y, z);
return boxed ();
};
};
};
};
};
Trying to Mutate a Constant NodePath
exports[" setScale" ] = [](const boxed& nodePath_) -> boxed {
auto nodePath = unbox<NodePath>(nodePath_);
return [=](const boxed& x_) -> boxed {
const auto x = unbox<double >(x_);
return [=](const boxed& y_) -> boxed {
const auto y = unbox<double >(y_);
return [=](const boxed& z_) -> boxed {
const auto z = unbox<double >(z_);
return [=]() -> boxed {
nodePath.set_scale (x, y, z);
return boxed ();
};
};
};
};
};
Using the Mutable Keyword
exports[" setScale" ] = [](const boxed& nodePath_) -> boxed {
auto nodePath = unbox<NodePath>(nodePath_);
return [=](const boxed& x_) mutable -> boxed {
const auto x = unbox<double >(x_);
return [=](const boxed& y_) mutable -> boxed {
const auto y = unbox<double >(y_);
return [=](const boxed& z_) mutable -> boxed {
const auto z = unbox<double >(z_);
return [=]() mutable -> boxed {
nodePath.set_scale (x, y, z);
return boxed ();
};
};
};
};
};
Creating an Ambient Light
exports[" createAmbientLight" ] = [](const boxed& s_) -> boxed {
return [&](const boxed& r_) -> boxed {
return [&](const boxed& g_) -> boxed {
return [&](const boxed& b_) -> boxed {
return [&]() -> boxed {
const auto s = unbox<string>(s_);
const auto r = unbox<double >(r_);
const auto g = unbox<double >(g_);
const auto b = unbox<double >(b_);
AmbientLight* l = new AmbientLight (s);
l->set_color (LVecBase4f (r, g, b, 1 ));
PandaNode* pandaNode = l->as_node ();
return box<PandaNode*>(pandaNode);
};
};
};
};
};