diff options
Diffstat (limited to 'ClientHamr/GuiLua/skang.lua')
-rw-r--r-- | ClientHamr/GuiLua/skang.lua | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/ClientHamr/GuiLua/skang.lua b/ClientHamr/GuiLua/skang.lua index e0123fb..9840cca 100644 --- a/ClientHamr/GuiLua/skang.lua +++ b/ClientHamr/GuiLua/skang.lua | |||
@@ -233,6 +233,27 @@ isBoolean = function (aBoolean) | |||
233 | end | 233 | end |
234 | 234 | ||
235 | 235 | ||
236 | --[[ Stuff package | ||
237 | |||
238 | In matrix-RAD Stuff took care of multi value Things, like database rows. | ||
239 | |||
240 | Stuff is an abstract class that gets extended by other classes, like | ||
241 | SquealStuff, which was the only thing extending it. It dealt with the | ||
242 | basic "collection of things" stuff. Each individual thing was called a | ||
243 | stufflet. A final fooStuff would extend SquealStuff, and include an | ||
244 | array of strings called "stufflets" that at least named the stufflets, | ||
245 | but could also include metadata and links to other Stuffs. | ||
246 | |||
247 | There was various infrastructure for reading and writing Stuff, throwing | ||
248 | rows of Stuff into grids, having choices of Stuff, linking stufflets to | ||
249 | individual widgets, having default Stuffs for windows, validating | ||
250 | Stuffs, etc. | ||
251 | |||
252 | In Lua, setting up stuff has been folded into the general Thing stuff. | ||
253 | |||
254 | ]] | ||
255 | |||
256 | |||
236 | --[[ Thing package | 257 | --[[ Thing package |
237 | 258 | ||
238 | matrix-RAD had Thing as the base class of everything. Lua doesn't have | 259 | matrix-RAD had Thing as the base class of everything. Lua doesn't have |
@@ -290,27 +311,6 @@ Other Thing things are - | |||
290 | NOTE that skang.thing{} doesn't care what other names you pass in, they all get assigned to the thing. | 311 | NOTE that skang.thing{} doesn't care what other names you pass in, they all get assigned to the thing. |
291 | 312 | ||
292 | 313 | ||
293 | Stuff - | ||
294 | test{'foo', key='blah', field0='something', field1=1, ...} -> skang.things.foo.key='blah' skang.things.foo.field='something' ... | ||
295 | test{'foo', bar='...', baz='..'} -> __call(test, {'foo', ...}) -> skang.stuff{'foo', ...} | ||
296 | What we really want though is something like (if foo is defined as a table) - | ||
297 | -> skang.things.foo.value = {key='blah', field0='something', field1=1, ...} | ||
298 | or even (if foo is defined as a Stuff) - | ||
299 | -> skang.things.foo.value[blah] = {key = 'blah', field0='something', field1=1, ...} | ||
300 | Stuff is kinda rigid though, it's fields are fixed, not an everything goes Lua table. So it needs to be defined. | ||
301 | Reusing Thing semantics, with aliases. | ||
302 | Also, let's NOT mix skang.thing{} semantics with test{} semantics, make it a different function. | ||
303 | Then we can avoid conflicts with Thing.* names, and having to sort out where to put things. | ||
304 | skang.thing{'foo', stuff={{'key', 'The Stuff key', types='string', required=true}, | ||
305 | {'field0,b' ... other Thing like stuff ... acl=''}, | ||
306 | {'field1', 'field1 is a stufflet', 42, 'number'}} } | ||
307 | skang.thing('foo', stuff=someOtherThing) | ||
308 | skang.thing('foo', stuff=skang.new(someOtherThing, 'pre')) | ||
309 | skang.things.foo.things.field0 | ||
310 | skang.things.foo.things.field1 | ||
311 | test.foo[blah].field1 | ||
312 | |||
313 | |||
314 | Widget - | 314 | Widget - |
315 | Merging widgets might work to. B-) | 315 | Merging widgets might work to. B-) |
316 | This does make the entire "Things with the same name link automatically" deal work easily, since they ARE the same Thing. | 316 | This does make the entire "Things with the same name link automatically" deal work easily, since they ARE the same Thing. |
@@ -363,9 +363,13 @@ Other Thing things are - | |||
363 | test.foo(a) -> test.__index(test, 'foo') -> test.__values[foo](a) (but it's not a function) -> test.__values[foo].__call(test.__values[foo], a) | 363 | test.foo(a) -> test.__index(test, 'foo') -> test.__values[foo](a) (but it's not a function) -> test.__values[foo].__call(test.__values[foo], a) |
364 | Doesn't seem useful. | 364 | Doesn't seem useful. |
365 | If test.foo is a Thing then that might be -> test.foo.__call(test.foo, a) -> could do something useful with this. | 365 | If test.foo is a Thing then that might be -> test.foo.__call(test.foo, a) -> could do something useful with this. |
366 | ]] | ||
367 | 366 | ||
367 | stuff.s = {a='foo'} -> changes a, deletes everything else | ||
368 | stuff.s{a='foo'} -> only changes a -> stuff.s.__call(stuff.s, {a='foo'} Should allow setting non stufflets, so the below works. | ||
368 | 369 | ||
370 | stuff.s[key] = {...} -> stuff.s.key = {...} -> stuff.s = {key={...}} But this semantic means only one thing, which is 'key'. | ||
371 | stuff.s{key={...}} -> same as above This does the right thing if we are using 'key' to index rows. | ||
372 | ]] | ||
369 | 373 | ||
370 | -- Default things values. | 374 | -- Default things values. |
371 | -- help - help text describing this Thing. | 375 | -- help - help text describing this Thing. |
@@ -483,6 +487,7 @@ Thing.__newindex = function (module, key, value) | |||
483 | if 'table' == type(oldValue) then | 487 | if 'table' == type(oldValue) then |
484 | valueMeta = getmetatable(oldValue) | 488 | valueMeta = getmetatable(oldValue) |
485 | if valueMeta then | 489 | if valueMeta then |
490 | -- TODO - This wont clear out any values in the old table that are not in the new table. Should it? | ||
486 | for k, v in pairs(value) do | 491 | for k, v in pairs(value) do |
487 | local newK = valueMeta.__stuff[k] | 492 | local newK = valueMeta.__stuff[k] |
488 | if newK then newK = newK.names[1] else newK = k end | 493 | if newK then newK = newK.names[1] else newK = k end |