//! (static) ObjRef _eval(Runtime & runtime, const CodeFragment & code){ Compiler compiler(runtime.getLogger()); ERef<UserFunction> script = compiler.compile(code); if(script.isNull()) return nullptr; return runtime.executeFunction(script.get(),nullptr,ParameterValues()); }
void getUniformNumbersAsArray(Array * targetArray,const Uniform & u){ const value_t *v = reinterpret_cast<const value_t*>(u.getData()); const size_t numSingleValues = u.getDataSize() / sizeof(value_t); ERef<Array> arr; for(size_t i=0;i<numSingleValues;++i){ if( (i%bucketSize) == 0){ arr=Array::create(); targetArray->pushBack(arr.get()); } arr->pushBack(Number::create(v[i])); } }
Util::GenericAttribute * convertFromEScript(const EScript::ObjPtr & object) override { // is a Number? EScript::Number * n = dynamic_cast<EScript::Number *> (object.get()); if (n != nullptr) { return GenericAttribute::createNumber(n->getValue()); } // is a Bool? EScript::Bool * b = dynamic_cast<EScript::Bool *> (object.get()); if (b != nullptr) { return GenericAttribute::createBool(b->toBool()); } // is a String? EScript::String * s = dynamic_cast<EScript::String *> (object.get()); if (s != nullptr) { return GenericAttribute::createString(s->getString()); } // is an Array? EScript::Array * a = dynamic_cast<EScript::Array *> (object.get()); if (a != nullptr) { auto gl = new Util::GenericAttributeList; for (ERef<EScript::Iterator> i = a->getIterator(); !i->end(); i->next()) { ObjRef value = i->value(); gl->push_back(convertEScriptObjectToGenericAttribute(value)); } return gl; } // is a Map? EScript::Map * m = dynamic_cast<EScript::Map *> (object.get()); if (m != nullptr) { auto gm = new Util::GenericAttributeMap; for (ERef<EScript::Iterator> i = m->getIterator(); !i->end(); i->next()) { ObjRef key = i->key(); ObjRef value = i->value(); gm->setValue(key->toString(), convertEScriptObjectToGenericAttribute(value)); } return gm; } return nullptr; }
//! (static,internal) Namespace * getSGlobals() { static ERef<Namespace> sglobals(new Namespace); return sglobals.get(); }
//! (static) Void * Void::get() { static ERef<Void> instance=new Void; return instance.get(); }