fix: warn traceback, fix errors
This commit is contained in:
parent
40462a1f3f
commit
24e5e7f52a
7 changed files with 48 additions and 7 deletions
|
|
@ -6,6 +6,7 @@ local insert = table.insert;
|
|||
---@param shared quad_export
|
||||
---@return quad_module_class
|
||||
function module.init(shared)
|
||||
local warn = shared.warn;
|
||||
---@class quad_module_class
|
||||
local new = {__type = "quad_module_class"};
|
||||
local InstanceNew = Instance.new;
|
||||
|
|
@ -104,6 +105,9 @@ function module.init(shared)
|
|||
-- store reading
|
||||
do
|
||||
local setValue = value:calcWithDefault(item);
|
||||
if setValue == nil then
|
||||
warn "[Quad] register return value must not be nil, but got nil. did you inited values before?";
|
||||
end
|
||||
setProperty(item,index,setValue,className);
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ local wrap = coroutine.wrap;
|
|||
---@param shared quad_export
|
||||
---@return quad_module_event
|
||||
function module.init(shared)
|
||||
local warn = shared.warn;
|
||||
---@class quad_module_event
|
||||
local new = {__type = "quad_module_event"};
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@ function module.init(id)
|
|||
local this = {__type = "quad_module_init",items = {}};
|
||||
|
||||
this.require = require;
|
||||
this.warn = function(err)
|
||||
warn(tostring(err));
|
||||
print(debug.traceback());
|
||||
end;
|
||||
this.round = type(round) == "table" and round; ---@type quad_module_round
|
||||
this.tween = type(advancedTween) == "table" and advancedTween; ---@type quad_module_tween
|
||||
this.style = style.init(this); ---@type quad_module_style
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ local pack = table.pack;
|
|||
---@param shared quad_export
|
||||
---@return quad_module_mount
|
||||
function module.init(shared)
|
||||
local warn = shared.warn;
|
||||
---@class quad_module_mount
|
||||
local new = {__type = "quad_module_mount"};
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ return function (query)
|
|||
object = object[this];
|
||||
if not object then
|
||||
object = lastObject.libs
|
||||
error(("[require] : object %s was not found from this worktree, require failed"):format(query));
|
||||
error(("[Quad] (require) object %s was not found from this worktree, require failed"):format(query));
|
||||
end
|
||||
end);
|
||||
return require(object);
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ local week = {__mode = "v"};
|
|||
---@param shared quad_export
|
||||
---@return quad_module_store
|
||||
function module.init(shared)
|
||||
local warn = shared.warn;
|
||||
---@class quad_module_store
|
||||
local new = {__type = "quad_module_store"};
|
||||
local items = shared.items;
|
||||
|
|
@ -149,7 +150,7 @@ function module.init(shared)
|
|||
local with = s.wfunc;
|
||||
local tstore = s.store;
|
||||
local rawKey = s.key;
|
||||
local tween = s.tvalue or s.dtvalue;
|
||||
local tween = s.tvalue or tstore.__tweens[rawKey];
|
||||
local from = s.fvalue;
|
||||
local add = s.avalue;
|
||||
local set = tstore[rawKey];
|
||||
|
|
@ -175,7 +176,8 @@ function module.init(shared)
|
|||
calcWithNewValue = function(s,withItem,newValue,key)
|
||||
local with = s.wfunc;
|
||||
local tstore = s.store;
|
||||
local tween = s.tvalue or s.dtvalue;
|
||||
local rawKey = s.key;
|
||||
local tween = s.tvalue or tstore.__tweens[rawKey];
|
||||
local from = s.fvalue;
|
||||
local add = s.avalue;
|
||||
if add then
|
||||
|
|
@ -205,7 +207,35 @@ function module.init(shared)
|
|||
function store:__newindex(key,value)
|
||||
-- if got register, just copy data to self and connect
|
||||
if type(value) == "table" and value.__type == "quad_register" then
|
||||
warn "[Quad] adding register value on store is only allowed when init store. set value request was ignored";
|
||||
-- warn "[Quad] adding register value on store is only allowed when init store. set value request was ignored";
|
||||
|
||||
local selfValues = self.__self;
|
||||
local selfTweens = self.__tweens;
|
||||
|
||||
-- fetch data from origin
|
||||
do
|
||||
local tstore = value.store;
|
||||
for tkey in value.key:gmatch("^[,]") do
|
||||
if not selfValues[tkey] then
|
||||
selfValues[tkey] = tstore[tkey];
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- calc value
|
||||
do
|
||||
local setValue,tween = value:calcWithDefault(self);
|
||||
selfValues[key] = setValue;
|
||||
selfTweens[key] = tween;
|
||||
end
|
||||
|
||||
-- make event connection
|
||||
value:register(function (_,newValue,eventKey)
|
||||
-- !HOLD IT SELF TO PREVENT THIS REGISTER BEGIN REMOVED FROM MEMORY
|
||||
local setValue = value:calcWithNewValue(self,newValue,eventKey);
|
||||
self[key] = setValue;
|
||||
end);
|
||||
|
||||
return;
|
||||
end
|
||||
self.__self[key] = value;
|
||||
|
|
@ -226,7 +256,9 @@ function module.init(shared)
|
|||
do
|
||||
local tstore = item.store;
|
||||
for tkey in item.key:gmatch("^[,]") do
|
||||
selfValues[tkey] = tstore[tkey];
|
||||
if not selfValues[tkey] then
|
||||
selfValues[tkey] = tstore[tkey];
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -253,12 +285,10 @@ function module.init(shared)
|
|||
return last;
|
||||
end
|
||||
local register = self.__reg[key];
|
||||
local tweens = self.__tweens;
|
||||
if not register then
|
||||
register = setmetatable({
|
||||
key = key;
|
||||
store = self;
|
||||
dtvalue = tweens and tweens[key];
|
||||
},registerClass);
|
||||
self.__reg[key] = register;
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ local insert = table.insert;
|
|||
---@param shared quad_export
|
||||
---@return quad_module_style
|
||||
function module.init(shared)
|
||||
local warn = shared.warn;
|
||||
---@class quad_module_style
|
||||
local new = {__type = "quad_module_style"};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue