diff nodejs/mbfly_njs.cc @ 871:67d0fed24120

Export a function to create a runtime for an existed window for JS
author Thinker K.F. Li <thinker@codemud.net>
date Fri, 24 Sep 2010 14:09:02 +0800
parents c18058fb48ee
children 176cba3ad32c
line wrap: on
line diff
--- a/nodejs/mbfly_njs.cc	Fri Sep 24 11:19:53 2010 +0800
+++ b/nodejs/mbfly_njs.cc	Fri Sep 24 14:09:02 2010 +0800
@@ -90,6 +90,27 @@
     return obj;
 }
 
+static njs_runtime_t *
+_X_njs_MB_new_with_win(Handle<Object> self, void *display,
+		       long win) {
+    njs_runtime_t *obj;
+    subject_t *subject;
+    Handle<Value> subject_o;
+
+    obj = X_njs_MB_new_with_win(display, win);
+    WRAP(self, obj);		/* mkroot need a wrapped object, but
+				 * it is wrapped after returning of
+				 * this function.  So, we wrap it
+				 * here. */
+    xnjsmb_coord_mkroot(self);
+
+    subject = X_njs_MB_kbevents(obj);
+    subject_o = export_xnjsmb_auto_subject_new(subject);
+    SET(self, "kbevents", subject_o);
+
+    return obj;
+}
+
 /*! \defgroup njs_template_cb Callback functions for v8 engine and nodejs.
  *
  * @{
@@ -148,6 +169,8 @@
      * Initialize template for MadButterfly runtime objects.
      */
     xnjsmb_auto_mb_rt_init();
+    xnjsmb_auto_mb_rt_display_init();
+    xnjsmb_auto_mb_rt_with_win_init();
 
     /*
      * Add properties to mb_rt templates for other modules.
@@ -160,6 +183,8 @@
 
     target->Set(String::New("mb_rt"),
 		xnjsmb_auto_mb_rt_temp->GetFunction());
+    target->Set(String::New("mb_rt_with_win"),
+		xnjsmb_auto_mb_rt_with_win_temp->GetFunction());
 }
 
 /* @} */