diff nodejs/mbfly_njs.cc @ 562:1b6402f07cd4 Android_Skia

Make root coord availabe for Javascript code
author Thinker K.F. Li <thinker@branda.to>
date Mon, 07 Jun 2010 14:45:01 +0800
parents a3c13c2a4792
children c0bc60448913
line wrap: on
line diff
--- a/nodejs/mbfly_njs.cc	Mon Jun 07 12:12:03 2010 +0800
+++ b/nodejs/mbfly_njs.cc	Mon Jun 07 14:45:01 2010 +0800
@@ -50,6 +50,7 @@
 
     self = args.This();
     WRAP(self, rt);
+    xnjsmb_coord_mkroot(self);
     
     X_njs_MB_init_handle_connection(rt);
 
@@ -62,6 +63,8 @@
 
 /* @} */
 
+/*! \brief Get rdman associated with the runtime.
+ */
 redraw_man_t *
 xnjsmb_rt_rdman(Handle<Object> mbrt) {
     HandleScope scope;
@@ -84,17 +87,24 @@
 extern "C" void
 init(Handle<Object> target) {
     HandleScope scope;
-    Handle<FunctionTemplate> func;
-    Handle<ObjectTemplate> rt_obj_temp;
+    Handle<FunctionTemplate> func, mb_rt_func;
+    Handle<ObjectTemplate> rt_instance_temp, rt_proto_temp;
 
     func = FunctionTemplate::New(hello_func);
     target->Set(String::New("Hello"), func->GetFunction());
 
-    func = FunctionTemplate::New(xnjsmb_new);
-    target->Set(String::New("mb_rt"), func->GetFunction());
-    rt_obj_temp = func->PrototypeTemplate();
-    rt_obj_temp->SetInternalFieldCount(1);
+    /*
+     * Initialize template for MadButterfly runtime objects.
+     */
+    mb_rt_func = FunctionTemplate::New(xnjsmb_new);
+    mb_rt_func->SetClassName(String::New("mb_rt"));
     
+    rt_instance_temp = mb_rt_func->InstanceTemplate();
+    rt_instance_temp->SetInternalFieldCount(1);
+    
+    rt_proto_temp = mb_rt_func->PrototypeTemplate();
     func = FunctionTemplate::New(xnjsmb_coord_new);
-    SET(rt_obj_temp, "coord_new", func);
+    SET(rt_proto_temp, "coord_new", func);
+    
+    target->Set(String::New("mb_rt"), mb_rt_func->GetFunction());    
 }