Re: Uncertain about luabind
Daniel Wallin <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
Tomas Cokis wrote:
> Hey guys, I'm really new to luabind (just got it compiling) and looking
> through the documentation I'm a bit uncertain of how to do something.
>
> Namely, how can I declare variables (in current, c++ scope) to luabind?
You can expose values to lua using the API wrappers in luabind. For
instance:
luabind::globals(L)["something"] = some_value;
Is that what you are looking for?
> My goal here is to, in a constructor of an object load a lua file to
> initialise its variables.
>
> I'm aware of how to declare classes and functions, however it doesn't seem
> like I can register an actual object or variables instance - the only
> solution I can think of it giving every variable its own get/set function,
> and add an additional layer - however isn't this what lua bind is supposed
> to do? Bind c++ to lua?
It's also possible to export public members using def_readwrite() and
def_readonly():
class_<X>("X")
.def_readwrite("value", &X::value)
You can not however export non-member variables as properties.
HTH,
--
Daniel Wallin
BoostPro Computing
http://www.boostpro.com
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev