Newproxy()

From Riftui Wiki

Revision as of 16:29, 2 July 2013 by Drhealsgood (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Details

Read this
newproxy is an unsupported and undocumented function in the Lua base library.

Creates a zero-size userdata and sets either a new, empty metatable on it or uses the metatable of another newproxy instance.

Signature

newProxyObject       = newproxy(true) -- create proxy object with 
                              -- new metatable
emptyProxyObject     = newproxy(false) -- create proxy object with 
                                   -- no metatable
duplicateProxyObject = newproxy(newProxyObject) -- create proxy 
  -- object with same metatable as other proxy
 
-- when creating userdata from a previous newproxy object
-- the new userdata will share the newproxy's metatable
do
  local a = newproxy(true)
  local b = newproxy(a)
  assert(b ~= a)
  getmetatable(a).__len = function() return 5 end
  assert(#b == 5)
  getmetatable(a).__len = function() return 6 end
  assert(#b == 6)
end

Parameters

(boolean or newproxy object)

boolean

True: Sets new, empty metatable
False: Does not set metatable


newproxy

The new userdata will share the passed proxy's metatable

Return Value

userdata
an opaque block of memory

Personal tools
Namespaces
Variants
Actions
Menu
Wiki
Toolbox