bool StyleContext::evalStyle(FunctionID _id, StyleParamKey _key, StyleParam::Value& _val) { if (!evalFunction(_id)) { return false; } // parse evaluated result at stack top parseStyleResult(_key, _val); // pop result, empty stack duk_pop(m_ctx); return !_val.is<none_type>(); }
bool StyleContext::evalStyleFn(const std::string& name, StyleParamKey _key, StyleParam::Value& _val) { if (!duk_get_global_string(m_ctx, name.c_str())) { logMsg("Error: evalFilter %s\n", name.c_str()); return false; } if (duk_pcall(m_ctx, 0) != 0) { logMsg("Error: evalStyleFn: %s\n", duk_safe_to_string(m_ctx, -1)); duk_pop(m_ctx); return false; } return parseStyleResult(_key, _val); }
bool StyleContext::evalStyle(FunctionID _id, StyleParamKey _key, StyleParam::Value& _val) const { if (!duk_get_global_string(m_ctx, FUNC_ID)) { logMsg("Error: evalFilterFn - functions array not initialized\n"); return false; } if (!duk_get_prop_index(m_ctx, -1, _id)) { logMsg("Error: evalFilterFn - function %d not set\n", _id); } // pop fns array duk_remove(m_ctx, -2); if (duk_pcall(m_ctx, 0) != 0) { logMsg("Error: evalFilterFn: %s\n", duk_safe_to_string(m_ctx, -1)); duk_pop(m_ctx); return false; } return parseStyleResult(_key, _val); }