Login   Register  
PHP Classes
elePHPant
Icontem

File: src/WebPower/LuaSandbox/assignObject.lua

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Christiaan Baartse  >  Lua sandbox  >  src/WebPower/LuaSandbox/assignObject.lua  >  Download  
File: src/WebPower/LuaSandbox/assignObject.lua
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Lua sandbox
Run Lua language code integrated with PHP code
Author: By
Last change:
Date: 2012-11-03 03:41
Size: 456 bytes
 

Contents

Class file image Download
-- This function is used by the LuaObjectProxy
function assignObject_(name, methods, getter, setter)
    local obj = {}
    for name, global_name in pairs(methods) do
        obj[name] = _G[global_name]
        _G[global_name] = nil
    end

    -- Magic property access using metatable
    local mt = {}
    mt.__index = _G[getter]
    _G[getter] = nil
    mt.__newindex = _G[setter]
    _G[setter] = nil
    setmetatable(obj, mt)

    _G[name] = obj
end