]> git.e2factory.org Git - e2factory.git/commitdiff
Use strict module, but still allow for extending the scm interface
authorTobias Ulmer <tu@emlix.com>
Tue, 4 Sep 2012 12:07:01 +0000 (14:07 +0200)
committerTobias Ulmer <tu@emlix.com>
Tue, 26 Feb 2013 18:07:09 +0000 (19:07 +0100)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
local/scm.lua

index db23a82d08a5156bc95edbbdbdca999651a70abc..5a195aaacd97584769dd84dfdc659efa2bb18360 100644 (file)
 ]]
 
 local scm = {}
-local err = require("err")
 local e2lib = require("e2lib")
+local err = require("err")
 local environment = require("environment")
+local strict = require("strict")
 
 -- scm modules
 local scms = {}
@@ -87,7 +88,12 @@ function scm.register_interface(name)
 
     -- we have lots of calls like scm.<function>(...). Register the interface
     -- function in the scm module to support those calls.
-    scm[name] = func
+    if strict.islocked(scm) then
+        strict.declare(scm, {[name]=func})
+    else
+        scm[name] = func
+    end
+
     return true, nil
 end
 
@@ -263,6 +269,6 @@ scm.register_interface("working_copy_available")
 scm.register_interface("display")
 scm.register_interface("has_working_copy")
 
-return scm
+return strict.lock(scm)
 
 -- vim:sw=4:sts=4:et: