/** * @author Edouard DUPIN * @copyright 2017, Edouard DUPIN, all right reserved * @license MPL-2 (see license file) */ #pragma once #include class testInterface { public: kikou::Interpreter m_system; public: testInterface() { m_system.import("core"); m_system.import("Math"); } bool execute(const etk::String& _data) { // TODO : ... m_system.trace(); //m_system.addChild("result", new kikou::Var("0", kikou::Var::type::INTEGER)); try { m_system.compile(_data); m_system.execute(); } catch (etk::exception::RuntimeError& eee) { ETEST_ERROR(eee.what()); return false; } // TODO : ... m_system.trace(); return true; } bool exist(const etk::String& _value) { return m_system.exist(_value); } bool isBoolean(const etk::String& _value) { if (m_system.exist(_value) == false) { return false; } return m_system.getScriptVariable(_value)->isBoolean(); } bool isInteger32(const etk::String& _value) { if (m_system.exist(_value) == false) { return false; } return m_system.getScriptVariable(_value)->isInteger32(); } bool isInteger64(const etk::String& _value) { if (m_system.exist(_value) == false) { return false; } return m_system.getScriptVariable(_value)->isInteger64(); } bool isFloat(const etk::String& _value) { if (m_system.exist(_value) == false) { return false; } return m_system.getScriptVariable(_value)->isFloat32(); } bool isDouble(const etk::String& _value) { if (m_system.exist(_value) == false) { return false; } return m_system.getScriptVariable(_value)->isFloat64(); } bool isString(const etk::String& _value) { if (m_system.exist(_value) == false) { return false; } return m_system.getScriptVariable(_value)->isString(); } bool isFunction(const etk::String& _value) { if (m_system.exist(_value) == false) { return false; } return m_system.getScriptVariable(_value)->isFunction(); } bool isObject(const etk::String& _value) { if (m_system.exist(_value) == false) { return false; } return m_system.getScriptVariable(_value)->isObject(); } bool isArray(const etk::String& _value) { if (m_system.exist(_value) == false) { return false; } return m_system.getScriptVariable(_value)->isArray(); } bool isFunionNative(const etk::String& _value) { if (m_system.exist(_value) == false) { return false; } return m_system.getScriptVariable(_value)->isFunctionNative(); } bool isUndefined(const etk::String& _value) { if (m_system.exist(_value) == false) { return false; } return m_system.getScriptVariable(_value)->isUndefined(); } bool isNull(const etk::String& _value) { if (m_system.exist(_value) == false) { return false; } return m_system.getScriptVariable(_value)->isNull(); } bool getBoolean(const etk::String& _value) { if (m_system.exist(_value) == false) { return false; } return m_system.getScriptVariable(_value)->toBoolean()->get(); } int getInteger32(const etk::String& _value) { if (m_system.exist(_value) == false) { return 0; } return m_system.getScriptVariable(_value)->toInteger32()->get(); } int getInteger64(const etk::String& _value) { if (m_system.exist(_value) == false) { return 0; } return m_system.getScriptVariable(_value)->toInteger64()->get(); } double getFloat(const etk::String& _value) { if (m_system.exist(_value) == false) { return 0; } return m_system.getScriptVariable(_value)->toFloat32()->get(); } double getDouble(const etk::String& _value) { if (m_system.exist(_value) == false) { return 0; } return m_system.getScriptVariable(_value)->toFloat64()->get(); } etk::String getString(const etk::String& _value) { if (m_system.exist(_value) == false) { return "ERROR"; } return m_system.getScriptVariable(_value)->toString()->get(); } };