aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ClientHamr/GuiLua/README
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-03-18 09:02:43 +1000
committerDavid Walter Seikel2014-03-18 09:02:43 +1000
commit92e532e67c6a401b27752f107b3a1377d8f6ba11 (patch)
tree81df64f216e8e9c65b8720b96c0e4efbf37ffde9 /ClientHamr/GuiLua/README
parentSame typo -- lol (diff)
downloadSledjHamr-92e532e67c6a401b27752f107b3a1377d8f6ba11.zip
SledjHamr-92e532e67c6a401b27752f107b3a1377d8f6ba11.tar.gz
SledjHamr-92e532e67c6a401b27752f107b3a1377d8f6ba11.tar.bz2
SledjHamr-92e532e67c6a401b27752f107b3a1377d8f6ba11.tar.xz
Added notes on how to translate Java skang to Lua.
Diffstat (limited to 'ClientHamr/GuiLua/README')
-rw-r--r--ClientHamr/GuiLua/README161
1 files changed, 161 insertions, 0 deletions
diff --git a/ClientHamr/GuiLua/README b/ClientHamr/GuiLua/README
index d24812a..a456cee 100644
--- a/ClientHamr/GuiLua/README
+++ b/ClientHamr/GuiLua/README
@@ -125,6 +125,167 @@ Raster also wants to thread lots of edje, likely including having edje
125Lua scripts as threads, much like I'm doing with LuaSL already. Plus 125Lua scripts as threads, much like I'm doing with LuaSL already. Plus
126LuaJIT SPEEEEED!!. B-) 126LuaJIT SPEEEEED!!. B-)
127 127
128Skang notes
129-----------
130
131So, what will this variation of skang look like? For a start, the
132syntax will have to be more Lua like, so that's a real basic change.
133Can't use a space as an argument separator, Lua allows only ',' and
134';'. Strings can still use single or double quotes.
135
136The magic "_123" system I used before to specify "position / size in
137characters instead of pixels" just wont work in Lua. Using _ as a table
138name with a meta table means that this syntax now becomes "_.123", which
139is kinda acceptable. Note that _.123 is syntax sugar for _["123"], so
140I'm not sure if using a number there works. An alternative is to just
141use a string -
142
143foo = widget.label(0, "1", 100, 0, 'Text goes here")
144
145Uses as many characters, and ends up being a value instead of an index,
146which is the right thing to do. While on this subject, anything less
147than 1, but more than 0, can be used as a percentage, maybe combined
148with "character" mode (this is a new thing) -
149
150foo = widget.label(0, "0.1", 0.5, 0, 'Text goes here")
151
152"widget" would be a table with functions for dealing with widgets. It
153would include metatable stuff for widget set introspection. So
154"widget.label" would introspect in our widget set for a widget type of
155"label", and return a widget type table. So we could do -
156
157foo = widget.label(0, "0.1", 0.5, 0, 'Text goes here :")
158foo:colour(255, 255, 255, 0, 0, 100, 255, 0)
159foo:hide()
160foo:action("skang.load(some/skang/file.skang)")
161
162Also allow access via table elements -
163
164foo.action = "skang.load('some/skang/file.skang')"
165foo.colour.r = 123
166foo.look('some/edje/file/somewhere.edj')
167foo.help = 'This is a widget for labelling some foo.'
168
169We can use the concat operator (..) to append things to widgets, like
170adding choices in a drop down, rows in a grid, etc.
171
172Hmm, need a skang table as well -
173
174skang.module(Evas)
175skang.module(Elementary)
176skang.clear()
177skang.load('some/skang/file.skang')
178
179
180I don't think we need variable introspection as much, since in this case
181Lua is both the skang and the underlaying language, the variables can
182just be accessed directly. Not sure on this, need to experiment. This
183is what we normally need variable introspection for -
184
185foo = 'bar' -- Using the metatable to override '=' to set the actual value of the widget, say the text of a label or edit widget.
186bar = foo -- The reverse of the above. Though perhaps these can't be done?
187foo = foo .. 'stuff' .. 'more stuff' .. 'another line of the dropdown or whatever'
188
189OK, first two can't be done, metatable only overides that for table elements. The third one can only be -
190
191foo.value = 'stuff' .. 'more stuff'
192foo.value = foo.value .. 'another line of the dropdown or whatever'
193
194Skang relied on the use of the set command to make sure that any
195matching widgets and variables got updated. And the get command.
196
197foo:set('stuff')
198bar = foo:get()
199
200On the other hand, given the module / package stuff mentioned below, and
201some metatable magic, we could do -
202
203local other = require('otherPackageName')
204other.foo = 'stuff'
205bar = other.foo
206
207Sooo, how does that squeeze into a "skang" file?
208
209#!skang myApp.skang -- This is Lua, so this might not work.
210-- There's an implied local this = require('myApp')
211-- There's an implied local skang = require('skang')
212local widget = require('EvasWidgets')
213local other = require('otherPackageName')
214skang.clear
215skang.window(200, 200, "G'day planet.")
216quitter = widget.button('Quit', 0.5, 0.5, 0.5, 0.5)
217quitter:action('quit') -- 'quit' is looked up in ThingSpcae.commands, and translated into the Lua 'skang.quit()'.
218other.foo = 'stuff'
219this.bar = other.foo
220
221
222Original Skang infrastructure
223-----------------------------
224
225Skang starts with a Thing as the base. In Java it's a base object for
226everything else, with a bunch of methods and elements. We can probably
227use a Thing metatable and replicate most of it. The widget used in the
228previous section is built on top of Thing. Things are stored in
229ThingSpace, which is a BonsaiTree of LeafLike Things. Java's version of
230multiple inheritance was used. Commands are a Thing.
231
232ThingSpace is per users session. classCache stores ... , command stores
233commands, module stores loaded modules, param stores variables and their
234values, widget stores widgets and their value / state.
235
236Skanglet is a generated mapping between actual methods / variables in a
237class, and skang. Each method or variable that ends up in the skanglet
238was marked by special javadoc tags. It also included some meta data
239like version and the default skang. For variables it defined -
240
241"Name", "Field/Method()", "Required", "Shortcut", "Default", "Help text"
242
243... and for methods -
244
245"Name", "Method", "Syntax", "Help text"
246
247In both cases the "Name" was the skang name, it could be different from
248the Java name specified in the second field. Likely we can do away with
249the need to generate these skanglet files, and just add stuff to the
250Thing. Modules wrap Skanglets, and takes care of loading them into ThingSpace.
251
252Module are used for -
253 loading the Skanglet for the Thing currently running (match java class name to skang file name).
254 loading the AWT interface in skang files.
255 loading OTHER skanglet based Things
256 loading Squeal, StuffSkang, and Who from java when needed.
257
258So in Lua, we can use the package system. First require(moduleName) to
259load up the skang module. Require can return a table, the Lua package
260called ends with "return someTable". See LuaLSL for an example. This
261package is actually run, so it can figure out what to put in the
262returned table. So for instance it could use inlined methods and such -
263
264local skang = require skang
265local result = {};
266result.author = 'onefang'
267result.version = '0.72 alpha 2004-11-19 16:28:00'
268local foo
269-- The first argument would be the name of a local variable / method. Which could be accessed via _G?
270-- Not sure if we could use a global foo, AND use it directly.
271result.foo = skang.newParam(foo, "Required", "Shortcut", "Default", "Help text")
272result.func = skang.newCommand('arg1_type,arg2_type', 'Help Text', function (arg1, arg2)
273...
274end)
275return result;
276
277
278Stuff is the base class used to track database rows and other multi
279value things. Would still need to deal with variable sub things, though
280that's likely just using tables. SquealStuff is the database version,
281using Squeal as the database driver wrapper. Squeal could wrap
282esskyuehl?
283
284
285The pre tokenized structure thingy I had planned in the TODO just wont
286work, as it uses symbols. On the other hand, we will be using Lua
287tables anyway. B-)
288
128 289
129EO notes 290EO notes
130-------- 291--------