Missing entries in luascript.c - or am I missing something obvious? - General Discussion and Assistance - CHDK Forum

Missing entries in luascript.c - or am I missing something obvious?

  • 3 Replies
  • 4873 Views
Advertisements
Hello,

I'm working with the trunk 905 (as fetched by CHDK Shell - great tool, BTW) and, as a couple of earlier posts hint, I'm building up the ability to run a rather specialised family of scripts, based around taking lots of shots as fast as possible and with lots of bracketing.

But I'm getting a bit confused about what bindings are supposed to already be available to Lua - for example, reading the Wiki page http://chdk.wikia.com/wiki/CHDK_firmware_usage/MoreBest seems to indicate that
Code: [Select]
get_display_mode() should be accessible to Lua but I don't spot it in either luascript.c or in a Lua library.

So far I'm just adding into my build the functions as I need them, which is fine but a bit disorganised.

Can anyone say if these bindings have already been put in and I've just missed them, or is that Wiki page just not relevant to the trunk I'm building or...

Regards,
Stephen


*

Offline reyalp

  • ******
  • 14126
Re: Missing entries in luascript.c - or am I missing something obvious?
« Reply #1 on: 29 / June / 2010, 17:27:55 »
In lua, you can get this in a platform independent way using propcases (use propcase.lua and PROPCASE_DISPLAY_MODE), so there's no need for a C function.

ubasic has a lot of these functions that just get/set a specific propcase because it's too crippled to do platform independently in script.
Don't forget what the H stands for.

Re: Missing entries in luascript.c - or am I missing something obvious?
« Reply #2 on: 29 / June / 2010, 18:34:36 »
True enough, Lua is easy to use in that way. I think the point was one of expectation, given the presence of the Wiki page and the fact that there are a pile of C routines already in luascript.c that do no more than use the propcases (and hence could have been done be done equally well in a Lua library)...

So I shall take it that the position it that the Wiki page isn't really accurate/relevant to Lua as things stand and the missing items do need to be added in, in whichever domain. Shame, it would have saved some typing and time to just drag in an existing implementation  :(

I don't have the time to do it at the moment but it'd be interesting to evaluate the run-time impact of having lots of trivial C bindings as compared to the equivalent as lots of trivial Lua functions, including the need to have the latter as a module loaded (compiled) in-camera. Hmm, something to do in August perhaps.

Regards,
Stephen

*

Offline reyalp

  • ******
  • 14126
Re: Missing entries in luascript.c - or am I missing something obvious?
« Reply #3 on: 29 / June / 2010, 19:33:51 »
True enough, Lua is easy to use in that way. I think the point was one of expectation, given the presence of the Wiki page and the fact that there are a pile of C routines already in luascript.c that do no more than use the propcases (and hence could have been done be done equally well in a Lua library)...
Right, we aren't consistent, and the documentation is always out of date. Feel free to correct the wiki to reflect the actual state of affairs :)
Quote
So I shall take it that the position it that the Wiki page isn't really accurate/relevant to Lua as things stand
It's not 100% accurate, but most of it should be OK.
Quote
and the missing items do need to be added in, in whichever domain. Shame, it would have saved some typing and time to just drag in an existing implementation  :(

I don't have the time to do it at the moment but it'd be interesting to evaluate the run-time impact of having lots of trivial C bindings as compared to the equivalent as lots of trivial Lua functions, including the need to have the latter as a module loaded (compiled) in-camera. Hmm, something to do in August perhaps.
For lua scripts, it should be a wash. The all lua method will be a tiny bit slower and need a little more memory, but it should be insignificant.

Adding unneeded bindings increases the memory required by CHDK for all users, even if they aren't using lua. That's why I generate the propcase definitions as lua files rather than binding them directly in C.

IMO, C bindings should only provide things that can't conveniently be done in lua, or are needed for real performance reasons. Everything else should be done in lua modules. Even though this is less efficient in most individual cases, it's more efficient over all because scripts can load just the modules that they need. This hasn't been followed religiously from the beginning because the lua stuff started out as a copy of the ubasic interface.
Don't forget what the H stands for.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal