20,741
edits
mNo edit summary |
m (clean up example) |
||
| Line 18: | Line 18: | ||
struct Test { | struct Test { | ||
int x,y,z; | int x,y,z; | ||
void hello() { | |||
std::cout << "Hello World from CppBind!\n"; | |||
} | |||
}; | }; | ||
| Line 23: | Line 26: | ||
typedef boost::shared_ptr<Test> Test_ptr; | typedef boost::shared_ptr<Test> Test_ptr; | ||
typedef nasal::Ghost< Test_ptr > NasalTest; | typedef nasal::Ghost< Test_ptr > NasalTest; | ||
// next, two helper functions that tell cppbind how to | |||
// convert our objects between C++ <-> Nasal | |||
naRef to_nasal_helper(naContext c, Test *src) | |||
{ | |||
NasalTest_ptr ptr(src); | |||
return NasalTest::create(c, ptr ); // | |||
} | |||
Test* | |||
from_nasal_helper(naContext c, naRef ref, const Test*) | |||
{ | |||
NasalTest::create(c, ref); // create a new Nasal Ghost | |||
} | |||
// add this to FGNasalSys::init(): | // add this to FGNasalSys::init(): | ||
| Line 29: | Line 49: | ||
initNasalTest(_globals, _context); | initNasalTest(_globals, _context); | ||
*/ | */ | ||
naRef initNasalTest(naRef globals, naContext c) | naRef initNasalTest(naRef globals, naContext c) | ||