MCPcopy Create free account
hub / github.com/LibreSprite/LibreSprite / eval

Method eval

src/script/duktape/engine.cpp:135–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133 }
134
135 bool eval(const std::string& code) override {
136 bool success = true;
137 try {
138 initGlobals();
139 if (duk_peval_string(m_handle, code.c_str()) != 0) {
140 printLastResult();
141 std::cout << "Error: [" << duk_safe_to_string(m_handle, -1) << "]" << std::endl;
142 success = false;
143 }
144
145 if (m_printLastResult &&
146 !duk_is_null_or_undefined(m_handle, -1)) {
147 m_delegate->onConsolePrint(duk_safe_to_string(m_handle, -1));
148 }
149
150 duk_pop(m_handle);
151 } catch (const std::exception& ex) {
152 std::string err = "Error: ";
153 err += ex.what();
154 m_delegate->onConsolePrint(err.c_str());
155 success = false;
156 std::cout << "Error: [" << err << "]" << std::endl;
157 }
158 execAfterEval(success);
159 return success;
160 }
161};
162
163static Engine::Regular<DukEngine> registration("duk", {"js"});

Callers

nothing calls this directly

Calls 2

whatMethod · 0.80
onConsolePrintMethod · 0.45

Tested by

no test coverage detected