Example #1
0
JSValue pushYamlScalarAsJsFunctionOrString(JSScope& jsScope, const YAML::Node& node) {
    auto value = jsScope.newFunction(node.Scalar());
    if (value) {
        return value;
    }
    return jsScope.newString(node.Scalar());
}
Example #2
0
// Convert a scalar node to a boolean, double, or string (in that order)
// and for the first conversion that works, push it to the top of the JS stack.
JSValue pushYamlScalarAsJsPrimitive(JSScope& jsScope, const YAML::Node& node) {
    bool booleanValue = false;
    double numberValue = 0.;
    if (YamlUtil::getBool(node, booleanValue)) {
        return jsScope.newBoolean(booleanValue);
    } else if (YamlUtil::getDouble(node, numberValue)) {
        return jsScope.newNumber(numberValue);
    } else {
        return jsScope.newString(node.Scalar());
    }
}