adding fields to lua class from C++
"Domino" <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <000001c9b6e8$27f70da0$77e528e0$@fm> |
Hi all,
I'm working on pseudo-dynamic fields for the lua classes. What I want to
achieve is some sort of mapping of object fields available from C++. So my
script class will populate the fields map like:
function myClass:populateDynamicFields()
addDynamicField('field1', int)
addDynamicField('field2', string)
end
then from GUI I want to display this list of dynamic fields and be able to
set their values via get/setValueInt (eventually I would like to add fields
from GUI as well). These methods will basically look like below:
void myClassInterface::setValueInt(string name, int value)
{
// let's say that I have luabind::object that is the script class
representation in luabind and it's called m_Self
if (m_Self[name])
{
m_Self[name] = value;
}
}
What I don't know is how to ensure that the m_Self[name] exists? Or how to
force its creation from C++ side? Like:
// .
if (!m_Self[name])
// do something to create field
Is there some way to do this? Or maybe there is some more generic way to do
what I'm trying here?
Thanks a lot.
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
luabind-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user