aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-03-30 16:10:17 +1000
committerDavid Walter Seikel2014-03-30 16:10:17 +1000
commitcfe38d47c36d3fdc104b0b9c9da4299c1e985771 (patch)
treefbb3391bf923b1262e2f0a7e152ea80a8301a65e
parentFix up using aliases in Stufflets, plus it helps if the alias is in the right... (diff)
downloadSledjHamr-cfe38d47c36d3fdc104b0b9c9da4299c1e985771.zip
SledjHamr-cfe38d47c36d3fdc104b0b9c9da4299c1e985771.tar.gz
SledjHamr-cfe38d47c36d3fdc104b0b9c9da4299c1e985771.tar.bz2
SledjHamr-cfe38d47c36d3fdc104b0b9c9da4299c1e985771.tar.xz
Shuffle Stuff notes around a bit.
-rw-r--r--ClientHamr/GuiLua/GuiLua.c16
-rw-r--r--ClientHamr/GuiLua/skang.lua49
2 files changed, 29 insertions, 36 deletions
diff --git a/ClientHamr/GuiLua/GuiLua.c b/ClientHamr/GuiLua/GuiLua.c
index b256f55..510eadf 100644
--- a/ClientHamr/GuiLua/GuiLua.c
+++ b/ClientHamr/GuiLua/GuiLua.c
@@ -99,27 +99,15 @@ Currently this is in skang.lua, but should bring this in here later.
99 99
100/* stuff & squeal packages 100/* stuff & squeal packages
101 101
102In matrix-RAD Stuff took care of multi value Things, like database rows. 102Currently Stuff is in skang.lua, but should bring this in here later.
103I'm not sure this is needed here, since Lua has nice tables. B-)
104 103
105Squeal was the database driver interface for SquealStuff, the database 104Squeal was the database driver interface for SquealStuff, the database
106version of Stuff. Maybe we could wrap esskyuehl? Not really in need of 105version of Stuff. Maybe we could wrap esskyuehl? Not really in need of
107database stuff for now, but should keep it in mind. 106database stuff for now, but should keep it in mind.
108 107
109Stuff is an abstract class that gets extended by other classes, like 108For SquealStuff, the metadata would be read from the SQL database
110SquealStuff, which was the only thing extending it. It dealt with the
111basic "collection of things" stuff. Each individual thing was called a
112stufflet. A final fooStuff would extend SquealStuff, and include an
113array of strings called "stufflets" that at least named the stufflets,
114but could also include metadata and links to other Stuffs. For
115SquealStuff, the metadata would be read from the SQL database
116autamatically. 109autamatically.
117 110
118There was various infrastructure for reading and writing Stuff, throwing
119rows of Stuff into grids, having choices of Stuff, linking stufflets to
120individual widgets, having default Stuffs for windows, validating
121Stuffs, etc.
122
123*/ 111*/
124 112
125 113
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)
233end 233end
234 234
235 235
236--[[ Stuff package
237
238In matrix-RAD Stuff took care of multi value Things, like database rows.
239
240Stuff is an abstract class that gets extended by other classes, like
241SquealStuff, which was the only thing extending it. It dealt with the
242basic "collection of things" stuff. Each individual thing was called a
243stufflet. A final fooStuff would extend SquealStuff, and include an
244array of strings called "stufflets" that at least named the stufflets,
245but could also include metadata and links to other Stuffs.
246
247There was various infrastructure for reading and writing Stuff, throwing
248rows of Stuff into grids, having choices of Stuff, linking stufflets to
249individual widgets, having default Stuffs for windows, validating
250Stuffs, etc.
251
252In Lua, setting up stuff has been folded into the general Thing stuff.
253
254]]
255
256
236--[[ Thing package 257--[[ Thing package
237 258
238matrix-RAD had Thing as the base class of everything. Lua doesn't have 259matrix-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