LuaContext& LuaContext::GetLuaContext(lua_State *state) { const void* value = GetGlobalVariable(state, "_LuaContext"); assert(value != NULL); return *const_cast<LuaContext*>(reinterpret_cast<const LuaContext*>(value)); }
static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *scope, byte variable, uint32 parameter, bool *available) { /* First handle variables common with Action7/9/D */ uint32 value; if (GetGlobalVariable(variable, &value, object.grffile)) return value; /* Non-common variable */ switch (variable) { case 0x0C: return object.callback; case 0x10: return object.callback_param1; case 0x18: return object.callback_param2; case 0x1C: return object.last_value; case 0x5F: return (scope->GetRandomBits() << 8) | scope->GetTriggers(); case 0x7D: return _temp_store.GetValue(parameter); case 0x7F: if (object.grffile == NULL) return 0; return object.grffile->GetParam(parameter); /* Not a common variable, so evaluate the feature specific variables */ default: return scope->GetVariable(variable, parameter, available); } }
bool CJS_GlobalData::SetGlobalVariablePersistent(const CFX_ByteString& propname, bool bPersistent) { CFX_ByteString sPropName(propname); if (!TrimPropName(&sPropName)) return false; CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName); if (!pData) return false; pData->bPersistent = bPersistent; return true; }
void CJS_GlobalData::SetGlobalVariableNull(const CFX_ByteString& propname) { CFX_ByteString sPropName(propname); if (!TrimPropName(&sPropName)) return; if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) { pData->data.nType = JS_GlobalDataType::NULLOBJ; return; } std::unique_ptr<CJS_GlobalData_Element> pNewData(new CJS_GlobalData_Element); pNewData->data.sKey = sPropName; pNewData->data.nType = JS_GlobalDataType::NULLOBJ; m_arrayGlobalData.push_back(std::move(pNewData)); }
FX_BOOL CJS_GlobalData::SetGlobalVariablePersistent( const CFX_ByteString& propname, FX_BOOL bPersistent) { CFX_ByteString sPropName(propname); if (!TrimPropName(&sPropName)) return FALSE; CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName); if (!pData) return FALSE; pData->bPersistent = bPersistent; return TRUE; }
void CJS_GlobalData::SetGlobalVariableObject( const CFX_ByteString& propname, const CJS_GlobalVariableArray& array) { CFX_ByteString sPropName(propname); if (!TrimPropName(&sPropName)) return; if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) { pData->data.nType = JS_GlobalDataType::OBJECT; pData->data.objData.Copy(array); return; } std::unique_ptr<CJS_GlobalData_Element> pNewData(new CJS_GlobalData_Element); pNewData->data.sKey = sPropName; pNewData->data.nType = JS_GlobalDataType::OBJECT; pNewData->data.objData.Copy(array); m_arrayGlobalData.push_back(std::move(pNewData)); }
FX_BOOL CJS_GlobalData::SetGlobalVariablePersistent(const FX_CHAR* propname, FX_BOOL bPersistent) { ASSERT(propname); CFX_ByteString sPropName = propname; sPropName.TrimLeft(); sPropName.TrimRight(); if (sPropName.GetLength() == 0) return FALSE; if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) { pData->bPersistent = bPersistent; return TRUE; } return FALSE; }
void CJS_GlobalData::SetGlobalVariableNull(const FX_CHAR* propname) { ASSERT(propname); CFX_ByteString sPropName = propname; sPropName.TrimLeft(); sPropName.TrimRight(); if (sPropName.GetLength() == 0) return; if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) { pData->data.nType = JS_GLOBALDATA_TYPE_NULL; } else { CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element; pNewData->data.sKey = sPropName; pNewData->data.nType = JS_GLOBALDATA_TYPE_NULL; m_arrayGlobalData.Add(pNewData); } }
static int lu_ts_global_index(lua_State *L) { lua_pushstring(L, GetGlobalVariable(luaL_checkstring(L, 2))); return 1; }