20,741
edits
mNo edit summary |
No edit summary |
||
| Line 2: | Line 2: | ||
<syntaxhighlight lang="cpp"> | <syntaxhighlight lang="cpp"> | ||
#include <simgear/nasal/cppbind/from_nasal.hxx> | |||
#include <simgear/nasal/cppbind/to_nasal.hxx> | |||
#include <simgear/nasal/cppbind/NasalHash.hxx> | |||
#include <simgear/nasal/cppbind/Ghost.hxx> | |||
# the struct we want to expose to Nasal | |||
struct Test { | struct Test { | ||
static double x,y,z; | static double x,y,z; | ||
}; | }; | ||
typedef boost::shared_ptr<Test> Test_ptr; | |||
typedef nasal::Ghost< Test_ptr > NasalTest; | |||
// add this to FGNasalSys::init(): | |||
/* | |||
extern initNasalTest(naRef globals, naContext c); // or add this to the header | |||
initNasalTest(_globals, _context); | |||
*/ | |||
naRef initNasalTest(naRef globals, naContext c) | |||
{ | |||
NasalTest::init("Test") | |||
.method("hello", &Test::hello); | |||
return naNil(); | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> | ||