Nasal/CppBind: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 32: Line 32:
naRef to_nasal_helper(naContext c, Test *src)
naRef to_nasal_helper(naContext c, Test *src)
   {  
   {  
     NasalTest_ptr ptr(src);
     NasalTest_ptr ptr(src); // set up a smart pointer wrapping src
     return NasalTest::create(c, ptr ); //  
     return NasalTest::create(c, ptr ); // return the smart pointer wrapped in a naGhost
   }
   }


Line 66: Line 66:
                 .method("hello", &Test::hello); // add a method to the ghost and map it to the method in the struct/class
                 .method("hello", &Test::hello); // add a method to the ghost and map it to the method in the struct/class


     // set up a  new namespace for our functions
     // set up a  new namespace for our functions, named test
     nasal::Hash globals_module(globals, c),
     nasal::Hash globals_module(globals, c),
               test = globals_module.createHash("test");
               test = globals_module.createHash("test");


  // add an allocator to the test namespace for creating new test objects
   test.set("new", &f_new_test);
   test.set("new", &f_new_test);


Navigation menu