[asterisk-commits] gtjoseph: branch 1.8 r416578 - /branches/1.8/configs/extensions.lua.sample
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jun 18 11:41:59 CDT 2014
Author: gtjoseph
Date: Wed Jun 18 11:41:50 2014
New Revision: 416578
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=416578
Log:
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)'.
https://reviewboard.asterisk.org/r/3627/
ASTERISK-23844 #comment This commit fixes 1.8, patch for 11->trunk coming.
Modified:
branches/1.8/configs/extensions.lua.sample
Modified: branches/1.8/configs/extensions.lua.sample
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/configs/extensions.lua.sample?view=diff&rev=416578&r1=416577&r2=416578
==============================================================================
--- branches/1.8/configs/extensions.lua.sample (original)
+++ branches/1.8/configs/extensions.lua.sample Wed Jun 18 11:41:50 2014
@@ -85,6 +85,7 @@
--
-- app.Dial("DAHDI/1")
-- app.dial("DAHDI/1")
+-- app["dial"]("DAHDI/1")
--
-- More examples can be found below.
--
@@ -95,6 +96,24 @@
-- autoservice_stop() and the autoservice_status() function 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, "", "")
@@ -142,7 +161,8 @@
end;
["1000"] = function()
- app.goto("default", "s", 1)
+-- See the naming conflict note above.
+ app['goto']("default", "s", 1)
end;
["1234"] = function()
More information about the asterisk-commits
mailing list