[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Limiting access to variables
- From: Rob Hoelz <rob@...>
- Date: Wed, 12 May 2010 15:43:11 -0500
You could pass an object that delegates to the C++ object, and then
remove that delegation upon deletion. Here's a quick Lua example:
local realobject = {
x = 7,
foo = function(self)
return self.x
end,
}
local delegate = setmetatable({}, {__index = realobject, __newindex = realobject})
MyLuaFunctionCalledWithACPlusPlusObject(delegate)
setmetatable(delegate, {__index = function(s, k)
error('attempt to access ' .. tostring(k) .. ' on dead object')
end, __newindex = function(s, k)
error('attempt to access ' .. tostring(k) .. ' on dead object')
end)
-Rob
On Wed, 12 May 2010 16:33:05 -0400
"King, Mike" <MKing@klmicrowave.com> wrote:
> My C++ program calls a Lua function with a "wrapped" C++ object as
> one of its parameters. When the Lua function returns, the object is
> deleted. How can I prevent future Lua calls from accessing the now
> invalid object?
>
>
>
>
>
>
> CONFIDENTIALITY NOTICE: This e-mail message, including any
> attachments, is for the sole use of the intended recipient(s) and may
> contain information that is confidential or proprietary to K&L
> Microwave, Inc. Any unauthorized review, use, disclosure or
> distribution is prohibited. If this communication has been
> transmitted from a U.S. location it may also contain data subject to
> the International Traffic in Arms Regulations or U.S. Export
> Administration Regulations and, if so, cannot be disseminated,
> distributed or copied to foreign nationals, residing in the U.S. or
> abroad, without the prior approval of the U.S. Department of State or
> appropriate export licensing authority. If you have received this
> communication in error, please notify the sender by reply e-mail and
> delete or destroy all copies of this e-mail message and/or any file
> attachment(s).
Attachment:
signature.asc
Description: PGP signature