File: src/WebPower/LuaSandbox/assignObject.lua

Recommend this page to a friend!
  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: 8 years ago
Size: 456 bytes


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

    -- 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
For more information send a message to info at phpclasses dot org.