JSValue parseSceneGlobals(JSScope& jsScope, const YAML::Node& node) { switch(node.Type()) { case YAML::NodeType::Scalar: { auto& scalar = node.Scalar(); if (scalar.compare(0, 8, "function") == 0) { return pushYamlScalarAsJsFunctionOrString(jsScope, node); } return pushYamlScalarAsJsPrimitive(jsScope, node); } case YAML::NodeType::Sequence: { auto jsArray = jsScope.newArray(); for (size_t i = 0; i < node.size(); i++) { jsArray.setValueAtIndex(i, parseSceneGlobals(jsScope, node[i])); } return jsArray; } case YAML::NodeType::Map: { auto jsObject = jsScope.newObject(); for (const auto& entry : node) { if (!entry.first.IsScalar()) { continue; // Can't put non-scalar keys in JS objects. } jsObject.setValueForProperty(entry.first.Scalar(), parseSceneGlobals(jsScope, entry.second)); } return jsObject; } default: return jsScope.newNull(); } }
void writeToDA(dynamicArray *anArray, int index, int value) { // if(index < getNumOfCells(anArray->arrSize)){ //inside bounds. This does not work if (index < getNumOfAvailableCells(anArray)) { printf("Writing inside bounds\n"); setValueAtIndex(anArray, index, value); } else { //Outside bounds //works the same way as the inside writing... printf("Writing outside bounds\n"); //create required additional subarrays prepareArrayWithIndex(anArray, index); setValueAtIndex(anArray, index, value); } }
GridField<T>::GridField(const GridField<T> &g):GridMapping(g),_extrapolation(nullptr),_interpolation(nullptr),_extrapolate(true){ int count = g.cellCount(); _data = new T[count]; //Iterera över g for (GridFieldIterator<T> iter = g.iterator(); !iter.done(); iter.next()) { setValueAtIndex(iter.value(), iter.index()); } //Interpolation //Extra/Interpolation setInterpolation(g._interpolation); setExtrapolation(g._extrapolation); }