MCPcopy Create free account
hub / github.com/TeXworks/texworks / setProperty

Method setProperty

plugins-src/TWLuaPlugin/LuaScript.cpp:266–297  ·  view source on GitHub ↗

static*/

Source from the content-addressed store, hash-verified

264
265/*static*/
266int LuaScript::setProperty(lua_State * L)
267{
268 QString propName;
269
270 // We should have the lua table (=object) we're called from, the property
271 // name we should set, and the new value; if not, something is wrong
272 if (lua_gettop(L) != 3) {
273 luaL_error(L, qPrintable(tr("__set: invalid call -- expected exactly 3 arguments, got %f")), lua_gettop(L));
274 return 0;
275 }
276
277 // Get the QObject* we operate on
278 QObject * obj = static_cast<QObject*>(lua_touserdata(L, lua_upvalueindex(1)));
279
280 // Get the parameters
281 propName = QString::fromUtf8(lua_tostring(L, 2));
282
283 switch (doSetProperty(obj, propName, LuaScript::getLuaStackValue(L, 3))) {
284 case Property_DoesNotExist:
285 luaL_error(L, qPrintable(tr("__set: object doesn't have property %s")), qPrintable(propName));
286 return 0;
287 case Property_NotWritable:
288 luaL_error(L, qPrintable(tr("__set: property %s is not writable")), qPrintable(propName));
289 return 0;
290 case Property_OK:
291 return 0;
292 default:
293 break;
294 }
295 // we should never reach this point
296 return 0;
297}
298
299/*static*/
300QVariant LuaScript::getLuaStackValue(lua_State * L, int idx, const bool throwError /* = true */)

Callers 3

updateColorsMethod · 0.80
executeMethod · 0.80
executeMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected