diff options
author | George Joseph <george.joseph@fairview5.com> | 2014-06-18 17:20:13 +0000 |
---|---|---|
committer | George Joseph <george.joseph@fairview5.com> | 2014-06-18 17:20:13 +0000 |
commit | cc4178bf253a420f630de5c46fbe8ab117be7c61 (patch) | |
tree | 9ddae2fb98d40e7e7a0aa7972a6d1ad146e646d8 /configs/extensions.lua.sample | |
parent | a965613cf7eb65e9caf71d00614f00f9bda7c985 (diff) |
Update extensions.lua.sample with naming conflict guidance.
The sample extensions.lua was causing pbx_lua to fail to load when parsing
'app.goto("default", "s", 1)' because in Lua 5.2, 'goto' is now a reserved
word. This patch adds guidance to extensions.lua.sample and changed
'app.goto("default", "s", 1)' to 'app.['goto']("default", "s", 1)'.
ASTERISK-23844 #close
Reported by: rnewton
Tested by: gtjoseph
Review: https://reviewboard.asterisk.org/r/3627/
........
Merged revisions 416581 from http://svn.asterisk.org/svn/asterisk/branches/11
........
Merged revisions 416582 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@416589 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'configs/extensions.lua.sample')
-rw-r--r-- | configs/extensions.lua.sample | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/configs/extensions.lua.sample b/configs/extensions.lua.sample index 3badcb4aa..1b4428c7c 100644 --- a/configs/extensions.lua.sample +++ b/configs/extensions.lua.sample @@ -85,6 +85,7 @@ TRUNKMSD = 1 -- -- app.Dial("DAHDI/1") -- app.dial("DAHDI/1") +-- app["dial"]("DAHDI/1") -- -- More examples can be found below. -- @@ -97,6 +98,24 @@ TRUNKMSD = 1 -- check the current status of the autoservice and will return true if an -- autoservice is currently running. -- +-- Note about naming conflicts: +-- Lua allows you to refer to table entries using the '.' notation, +-- I.E. app.goto(something), only if the entry doesn't conflict with an Lua +-- reserved word. In the 'goto' example, with Lua 5.1 or earlier, 'goto' is +-- not a reserved word so you'd be calling the Asterisk dialplan application +-- 'goto'. Lua 5.2 however, introduced the 'goto' control statement which +-- makes 'goto' a reserved word. This casues the interpreter to fail parsing +-- the file and pbx_lua.so will fail to load. The same applies to any use of +-- Lua tables including extensions, channels and any tables you create. +-- +-- There are two ways around this: Since Lua is case-sensitive, you can use +-- capitalized names, I.E. app.Goto(something) to refer to the Asterisk apps, +-- functions, etc. Or you can use the full syntax, I.E. app["goto"](something). +-- Both syntaxes are backwards compatible with earlier Lua versions. To make +-- your Lua dialplans easier to maintain and to reduce the chance of future +-- conflicts you may want to use the app["goto"](something) syntax for all +-- table accesses. +-- function outgoing_local(c, e) app.dial("DAHDI/1/" .. e, "", "") @@ -144,7 +163,8 @@ extensions = { end; ["1000"] = function() - app.goto("demo", "s", 1) +-- See the naming conflict note above. + app['goto']("default", "s", 1) end; ["1234"] = function() |