deserialize
Definition
-- @/lua/common/extensions.lua:992
local function deserialize(data, filter)
if data == nil then return end
deserializedData = data
local extensionsData = data['extensions']
if extensionsData and extensionsData.loadedModules then
local extbatch = {}
for extName,extPath in pairs(extensionsData.loadedModules) do
local tempExtName = luaPathToExtName(extPath)
if extName == tempExtName then
table.insert(extbatch, extName)
else
-- determine is root is the global root or a specfied root
local root
local extFilename = string.gsub(extPath, "(.*/)(.*)", "%2")
if extFilename == extName then
-- global root was used. for example in loadModulesInDirectory to load the extension
root = ""
else
-- grab specified root
root = string.sub(extName, 1, string.find(extName, "_") - 1)
end
loadAtRoot(extPath, root)
end
end
loadExt(extbatch)
end
-- We need to make a copy of these 2 tables as modules processing onDeserialize can alter them when they call extensions.load as
-- part of their execution flow. This fixes the bug where some modules do not get onDeserialize called because they have been
-- dropped from these tables
local tempResolvedModules = shallowcopy(resolvedModules)
for _, v in ipairs(tempResolvedModules) do
local k = v.__extensionName__
--print("k="..tostring(k) .. " = " .. tostring(v))
if (filter == nil or k == filter) and type(v) == 'table' and (v['onDeserialized'] ~= nil or v['onDeserialize'] ~= nil) and data[k] ~= nil then
if type(v['onDeserialize']) == 'function' then
-- having a deserilization function? then use that!
v['onDeserialize'](data[k])
elseif v['state'] then
-- only merge M.state
tableMerge(v['state'], data[k])
else
-- merge whole M
tableMerge(v, data[k])
end
if type(v['onDeserialized']) == 'function' then
v['onDeserialized'](data[k])
end
end
data[k] = nil
end
deserializedData = nil
end
Callers
@/inspector/Proxies/HeapSnapshotEdgeProxy.js
static deserialize(objectId, serializedEdge)
{
@/lua/ge/extensions/editor/rallyEditor/measurementsTab.lua
-- Deserialize measurements from JSON data
function C:deserialize(data)
if not data then return end
self:deserialize(data)
@/lua/ge/extensions/editor/inspector.lua
local function onEditorLoadGuiInstancerState(state)
guiInstancer:deserialize("inspectorInstances", state)
for key, val in pairs(guiInstancer.instances) do
@/inspector/Models/HeapAllocationsInstrument.js
workerProxy.createSnapshot(snapshotStringData, ({objectId, snapshot: serializedSnapshot}) => {
let snapshot = WI.HeapSnapshotProxy.deserialize(objectId, serializedSnapshot);
snapshot.snapshotStringData = snapshotStringData;
@/inspector/Proxies/HeapSnapshotProxy.js
static deserialize(objectId, serializedSnapshot)
{
WI.HeapSnapshotWorkerProxy.singleton().callMethod(this._proxyObjectId, "nodeWithIdentifier", nodeIdentifier, (serializedNode) => {
callback(WI.HeapSnapshotNodeProxy.deserialize(this._proxyObjectId, serializedNode));
});
@/inspector/Protocol/ConsoleObserver.js
workerProxy.createSnapshot(snapshotStringData, title || null, ({objectId, snapshot: serializedSnapshot}) => {
let snapshot = WI.HeapSnapshotProxy.deserialize(objectId, serializedSnapshot);
snapshot.snapshotStringData = snapshotStringData;
@/inspector/Models/DOMBreakpoint.js
static deserialize(serializedInfo)
{
@/lua/ge/ge_utils.lua
local geluaCommand = string.format('local args = %s; %s(unpack(args, 1, table.maxn(args)))', 'deserialize(%q)', geluaFunctionName)
local cmd = string.format('obj:queueGameEngineLua(string.format(%q, serialize({%s, unpack(%s)})))', geluaCommand, vluaCommand, serialize({...}))
@/lua/ge/extensions/editor/api/history.lua
--- Deserialize the history stacks
function C:deserialize(data)
if data.history then
@/inspector/Views/HeapAllocationsTimelineView.js
workerProxy.createImportedSnapshot(snapshotStringData, result.filename, ({objectId, snapshot: serializedSnapshot}) => {
let snapshot = WI.HeapSnapshotProxy.deserialize(objectId, serializedSnapshot);
snapshot.snapshotStringData = snapshotStringData;
workerProxy.createSnapshot(snapshotStringData, ({objectId, snapshot: serializedSnapshot}) => {
let snapshot = WI.HeapSnapshotProxy.deserialize(objectId, serializedSnapshot);
snapshot.snapshotStringData = snapshotStringData;
workerProxy.createSnapshotDiff(snapshot1.proxyObjectId, snapshot2.proxyObjectId, ({objectId, snapshotDiff: serializedSnapshotDiff}) => {
let diff = WI.HeapSnapshotDiffProxy.deserialize(objectId, serializedSnapshotDiff);
this.showHeapSnapshotDiff(diff);
@/inspector/Models/URLBreakpoint.js
static deserialize(serializedInfo)
{
@/lua/vehicle/controller.lua
if name and loadedControllers[name] and loadedControllers[name].deserialize then
loadedControllers[name].deserialize(controllerData)
end
@/lua/ge/extensions/editor/sceneTree.lua
local function onEditorLoadGuiInstancerState(state)
guiInstancer:deserialize("scenetreeInstances", state)
recacheAllNodes()
@/lua/ge/extensions/editor/main.lua
--TODO: objects need serializable formats not C++ object refs
--editor.history:deserialize(editorHistoryData)
end
@/lua/vehicle/controller/controllerTemplate.lua
-- local function deserialize(data)
-- if data then
@/inspector/Protocol/HeapObserver.js
workerProxy.createSnapshot(snapshotStringData, ({objectId, snapshot: serializedSnapshot}) => {
let snapshot = WI.HeapSnapshotProxy.deserialize(objectId, serializedSnapshot);
snapshot.snapshotStringData = snapshotStringData;
workerProxy.createSnapshot(snapshotStringData, ({objectId, snapshot: serializedSnapshot}) => {
let snapshot = WI.HeapSnapshotProxy.deserialize(objectId, serializedSnapshot);
snapshot.snapshotStringData = snapshotStringData;
@/inspector/Models/EventBreakpoint.js
static deserialize(serializedInfo)
{
@/lua/ge/extensions/tech/techCore.lua
-- Serialize & deserialize to get rid of data MessagePack can't serialize
local cameraData = deserialize(serialize(core_camera.getCameraDataById(veh:getID())))
cameraData['unicycle'] = nil
@/lua/ge/extensions/core/vehicle/partmgmt.lua
elseif dataType == 'string' and configData:sub(1, 1) == '{' then
local res, newConfigData = preprocessPartConfig(deserialize(configData))
if res then
@/lua/common/utils.lua
if data == nil then return end
extensions.deserialize(data)
function deserialize(s)
-- if you crash here with "attempt to call a nil value" check if your serialize function emits invalid lua: ["windowViewport"]=cdata: 0x0257e75a5580
-- print("serialized data: " .. tostring(s))
-- da = deserialize(s)
-- print("restored data: " .. tostring(da))
-- end
-- if deserialize(serialize(nil)) ~= nil then print "serialize with nil fails to work corectly" end
-- end
@/lua/vehicle/controller/driveModes.lua
local function deserialize(data)
if data then
@/lua/common/jbeam/loader.lua
if not vehicleBundle.config.paints then
vehicleBundle.config.paints = deserialize(vehicleObj.paints or '{}')
end
@/lua/vehicle/energyStorage/fuelTank.lua
local function deserialize(storage, data)
if data.remainingVolume then
@/lua/vehicle/controller/nitrousOxideInjection.lua
local function deserialize(data)
if data and data.isArmed then
@/inspector/Models/HeapAllocationsTimelineRecord.js
workerProxy.createImportedSnapshot(snapshotStringData, title, ({objectId, snapshot: serializedSnapshot}) => {
let snapshot = WI.HeapSnapshotProxy.deserialize(objectId, serializedSnapshot);
snapshot.snapshotStringData = snapshotStringData;
@/lua/vehicle/controller/esc.lua
local function deserialize(data)
if data and data.escConfigKey then
@/lua/ge/extensions/flowgraph/nodes/vehicle/customPartsConfigProvider.lua
if im.Button("Copy from Vehicle") then
self.partConfig = deserialize(veh.partConfig) or {parts = {},vars = {}}
self.model = veh.JBeam
if im.Button("Copy only Parts") then
self.partConfig.parts = deserialize(veh.partConfig).parts or {}
self.model = veh.JBeam
if im.Button("Copy only Vars") then
self.partConfig.vars = deserialize(veh.partConfig).vars or {}
self.model = veh.JBeam
self._opened = true
im.Text(dumps(deserialize(veh.partConfig)))
im.TreePop()
@/inspector/Controllers/DOMDebuggerManager.js
for (let existingSerializedBreakpoint of existingSerializedBreakpoints)
await objectStore.putObject(constructor.deserialize(existingSerializedBreakpoint));
}
for (let serializedBreakpoint of serializedBreakpoints) {
let breakpoint = constructor.deserialize(serializedBreakpoint);
@/lua/vehicle/energyStorage/pressureTank.lua
local function deserialize(storage, data)
if data.remainingMass then
@/lua/vehicle/controller/twoStepLaunch.lua
local function deserialize(data)
if data and data.state and data.rpm then
@/lua/ge/extensions/core/camera.lua
if data.globalCameras[camName] then
tableMergeRecursive(cam, deserialize(data.globalCameras[camName]))
if cam.onDeserialized then cam:onDeserialized() end
if svdata.cameras[camName] then
tableMergeRecursive(cam, deserialize(svdata.cameras[camName]))
end
@/lua/vehicle/extensions/tech/trailSim.lua
local function trailerData(dataString, id)
local trailerData = deserialize(dataString)
for i, d in ipairs(trailerData) do
@/lua/vehicle/energyStorage.lua
-- if name and energyStorages[name] then
-- energyStorages[name]:deserialize(storageData)
-- end
@/lua/ge/extensions/core/vehicleBridge.lua
local function callbackFromVlua(vehId, callbackId, ...)
local deserializedData = deserialize(...)
if deserializedData.failReason then
@/lua/ge/extensions/career/modules/partInventory.lua
if jsonData and not outdated then
partInventory = deserialize(jsonData[1])
@/lua/vehicle/energyStorage/n2oTank.lua
local function deserialize(storage, data)
if data.remainingMass then
@/lua/ge/extensions/flowgraph/nodes/vehicle/special/customVehicleGetter.lua
function C:returnValue(value)
self.returnedValue = deserialize(value)
end
@/inspector/Proxies/HeapSnapshotDiffProxy.js
static deserialize(objectId, serializedSnapshotDiff)
{
// should we serialize the objectId with the snapshot so we have the right objectId?
let snapshot1 = WI.HeapSnapshotProxy.deserialize(objectId, serializedSnapshot1);
let snapshot2 = WI.HeapSnapshotProxy.deserialize(objectId, serializedSnapshot2);
let snapshot1 = WI.HeapSnapshotProxy.deserialize(objectId, serializedSnapshot1);
let snapshot2 = WI.HeapSnapshotProxy.deserialize(objectId, serializedSnapshot2);
return new WI.HeapSnapshotDiffProxy(objectId, snapshot1, snapshot2, totalSize, totalObjectCount, categories);
WI.HeapSnapshotWorkerProxy.singleton().callMethod(this._proxyObjectId, "nodeWithIdentifier", nodeIdentifier, (serializedNode) => {
callback(WI.HeapSnapshotNodeProxy.deserialize(this._proxyObjectId, serializedNode));
});
@/lua/ge/extensions/gameplay/drag/general.lua
local status, ret = xpcall(function() return type(deserialize(vehicle.partConfig)) end, nop)
racer.stock = not ret
@/lua/ge/extensions/editor/api/guiInstancer.lua
function C:deserialize(name, state)
if state[name] then
@/lua/vehicle/main.lua
-- deserialize extensions first, so the extensions are loaded before they are trying to get deserialized
deserializePackages(deserialize(s))
end
@/lua/ge/extensions/career/modules/inventory.lua
local vehicleData = jsonReadFile(files[i])
vehicleData.partConditions = deserialize(vehicleData.partConditions)
if vehicleData.timeToAccess then
@/inspector/Proxies/HeapSnapshotNodeProxy.js
static deserialize(objectId, serializedNode)
{
if (isNode)
return WI.HeapSnapshotNodeProxy.deserialize(this._proxyObjectId, component);
return WI.HeapSnapshotEdgeProxy.deserialize(this._proxyObjectId, component);
return WI.HeapSnapshotNodeProxy.deserialize(this._proxyObjectId, component);
return WI.HeapSnapshotEdgeProxy.deserialize(this._proxyObjectId, component);
});
@/lua/vehicle/controller/4wd.lua
local function deserialize(data)
if data then