annotate nodejs/mbfly_njs.cc @ 1311:e6bb9d00341f

Make content dom and comp_dock synchronized
author Thinker K.F. Li <thinker@codemud.net>
date Thu, 20 Jan 2011 13:08:26 +0800
parents 88bd0eee2b00
children 3eaf708b52c3
rev   line source
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 778
diff changeset
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*-
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 778
diff changeset
2 // vim: sw=4:ts=8:sts=4
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3 #include <stdio.h>
666
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
4 #include <string.h>
547
371690a166df Remove hello.c and initial plugin at mbfly_njs.cc
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
5 #include <v8.h>
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
6
556
c9d23f7279a4 The first testcase that nodejs code can show a MadButterfly window.
Thinker K.F. Li <thinker@branda.to>
parents: 548
diff changeset
7 extern "C" {
1056
88bd0eee2b00 Rename X_supp_njs.[ch] to njs_mb_supp.[ch].
Thinker K.F. Li <thinker@codemud.net>
parents: 1053
diff changeset
8 #include "njs_mb_supp.h"
556
c9d23f7279a4 The first testcase that nodejs code can show a MadButterfly window.
Thinker K.F. Li <thinker@branda.to>
parents: 548
diff changeset
9 }
c9d23f7279a4 The first testcase that nodejs code can show a MadButterfly window.
Thinker K.F. Li <thinker@branda.to>
parents: 548
diff changeset
10
559
ef078d7c57b4 Use internal field to store njs_runtime_t object.
Thinker K.F. Li <thinker@branda.to>
parents: 558
diff changeset
11 #include "mbfly_njs.h"
ef078d7c57b4 Use internal field to store njs_runtime_t object.
Thinker K.F. Li <thinker@branda.to>
parents: 558
diff changeset
12
547
371690a166df Remove hello.c and initial plugin at mbfly_njs.cc
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
13 using namespace v8;
371690a166df Remove hello.c and initial plugin at mbfly_njs.cc
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
14
684
b346e4699e55 Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 683
diff changeset
15 /*! \defgroup xnjsmb_mb_rt JS binding for MB runtime.
b346e4699e55 Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 683
diff changeset
16 * \ingroup xnjsmb
b346e4699e55 Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 683
diff changeset
17 *
b346e4699e55 Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 683
diff changeset
18 * @{
b346e4699e55 Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 683
diff changeset
19 */
666
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
20 static coord_t *
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
21 xnjsmb_coord_new(njs_runtime_t *rt, coord_t *parent, const char **err) {
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
22 coord_t *coord;
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
23 redraw_man_t *rdman;
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
24
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 1042
diff changeset
25 rdman = njs_mb_rdman(rt);
666
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
26 coord = rdman_coord_new(rdman, parent);
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
27 if(coord == NULL) {
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
28 *err = "Can not allocate a redraw_man_t";
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
29 return NULL;
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
30 }
778
61c217f8cec8 Fix bug of transformation from user space to image space.
Thinker K.F. Li <thinker@codemud.net>
parents: 733
diff changeset
31 rdman_coord_changed(rdman, coord);
666
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
32
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
33 return coord;
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
34 }
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
35
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
36 static void
683
7685c57e29d0 Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 681
diff changeset
37 xnjsmb_mb_rt_objs_mod(Handle<Object> mbrt, Handle<Value> ret) {
666
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
38 Handle<Object> ret_obj = ret->ToObject();
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
39
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
40 SET(ret_obj, "mbrt", mbrt);
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
41 }
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
42
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
43 #define xnjsmb_auto_coord_new export_xnjsmb_auto_coord_new
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
44
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
45 static void
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
46 xnjsmb_redraw_changed(njs_runtime_t *rt) {
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
47 redraw_man_t *rdman;
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
48
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 1042
diff changeset
49 rdman = njs_mb_rdman(rt);
666
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
50 rdman_redraw_changed(rdman);
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
51 }
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
52
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
53 static void
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
54 xnjsmb_redraw_all(njs_runtime_t *rt) {
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
55 redraw_man_t *rdman;
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
56
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 1042
diff changeset
57 rdman = njs_mb_rdman(rt);
666
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
58 rdman_redraw_all(rdman);
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
59 }
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
60
869
c18058fb48ee Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
61 static void
c18058fb48ee Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
62 xnjsmb_handle_single_event(njs_runtime_t *rt, void *evt) {
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 1042
diff changeset
63 njs_mb_handle_single_event(rt, evt);
869
c18058fb48ee Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
64 }
c18058fb48ee Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
65
c18058fb48ee Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
66 static void
c18058fb48ee Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
67 xnjsmb_no_more_event(njs_runtime_t *rt) {
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 1042
diff changeset
68 njs_mb_no_more_event(rt);
869
c18058fb48ee Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
69 }
c18058fb48ee Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
70
666
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
71 static njs_runtime_t *
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 1042
diff changeset
72 _njs_mb_new(Handle<Object> self, char *display_name,
666
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
73 int width, int height) {
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
74 njs_runtime_t *obj;
676
f264b50c469c Bind subject of mouse_event to JS object of coord
Thinker K.F. Li <thinker@branda.to>
parents: 675
diff changeset
75 subject_t *subject;
f264b50c469c Bind subject of mouse_event to JS object of coord
Thinker K.F. Li <thinker@branda.to>
parents: 675
diff changeset
76 Handle<Value> subject_o;
666
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
77
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 1042
diff changeset
78 obj = njs_mb_new(display_name, width, height);
666
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
79 WRAP(self, obj); /* mkroot need a wrapped object, but
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
80 * it is wrapped after returning of
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
81 * this function. So, we wrap it
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
82 * here. */
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
83 xnjsmb_coord_mkroot(self);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 778
diff changeset
84
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 1042
diff changeset
85 subject = njs_mb_kbevents(obj);
679
799c852b9065 Extract event info from C object to JS object
Thinker K.F. Li <thinker@branda.to>
parents: 676
diff changeset
86 subject_o = export_xnjsmb_auto_subject_new(subject);
681
b601a4d6f7d1 Change kbevent to kbevents and hide X_MB_kbevents()
Thinker K.F. Li <thinker@branda.to>
parents: 680
diff changeset
87 SET(self, "kbevents", subject_o);
679
799c852b9065 Extract event info from C object to JS object
Thinker K.F. Li <thinker@branda.to>
parents: 676
diff changeset
88
666
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
89 return obj;
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
90 }
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
91
871
67d0fed24120 Export a function to create a runtime for an existed window for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 869
diff changeset
92 static njs_runtime_t *
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 1042
diff changeset
93 _njs_mb_new_with_win(Handle<Object> self, void *display,
871
67d0fed24120 Export a function to create a runtime for an existed window for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 869
diff changeset
94 long win) {
67d0fed24120 Export a function to create a runtime for an existed window for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 869
diff changeset
95 njs_runtime_t *obj;
67d0fed24120 Export a function to create a runtime for an existed window for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 869
diff changeset
96 subject_t *subject;
67d0fed24120 Export a function to create a runtime for an existed window for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 869
diff changeset
97 Handle<Value> subject_o;
67d0fed24120 Export a function to create a runtime for an existed window for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 869
diff changeset
98
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 1042
diff changeset
99 obj = njs_mb_new_with_win(display, win);
871
67d0fed24120 Export a function to create a runtime for an existed window for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 869
diff changeset
100 WRAP(self, obj); /* mkroot need a wrapped object, but
67d0fed24120 Export a function to create a runtime for an existed window for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 869
diff changeset
101 * it is wrapped after returning of
67d0fed24120 Export a function to create a runtime for an existed window for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 869
diff changeset
102 * this function. So, we wrap it
67d0fed24120 Export a function to create a runtime for an existed window for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 869
diff changeset
103 * here. */
67d0fed24120 Export a function to create a runtime for an existed window for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 869
diff changeset
104 xnjsmb_coord_mkroot(self);
67d0fed24120 Export a function to create a runtime for an existed window for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 869
diff changeset
105
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 1042
diff changeset
106 subject = njs_mb_kbevents(obj);
871
67d0fed24120 Export a function to create a runtime for an existed window for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 869
diff changeset
107 subject_o = export_xnjsmb_auto_subject_new(subject);
67d0fed24120 Export a function to create a runtime for an existed window for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 869
diff changeset
108 SET(self, "kbevents", subject_o);
67d0fed24120 Export a function to create a runtime for an existed window for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 869
diff changeset
109
67d0fed24120 Export a function to create a runtime for an existed window for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 869
diff changeset
110 return obj;
67d0fed24120 Export a function to create a runtime for an existed window for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 869
diff changeset
111 }
67d0fed24120 Export a function to create a runtime for an existed window for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 869
diff changeset
112
556
c9d23f7279a4 The first testcase that nodejs code can show a MadButterfly window.
Thinker K.F. Li <thinker@branda.to>
parents: 548
diff changeset
113 /*! \defgroup njs_template_cb Callback functions for v8 engine and nodejs.
c9d23f7279a4 The first testcase that nodejs code can show a MadButterfly window.
Thinker K.F. Li <thinker@branda.to>
parents: 548
diff changeset
114 *
c9d23f7279a4 The first testcase that nodejs code can show a MadButterfly window.
Thinker K.F. Li <thinker@branda.to>
parents: 548
diff changeset
115 * @{
c9d23f7279a4 The first testcase that nodejs code can show a MadButterfly window.
Thinker K.F. Li <thinker@branda.to>
parents: 548
diff changeset
116 */
c9d23f7279a4 The first testcase that nodejs code can show a MadButterfly window.
Thinker K.F. Li <thinker@branda.to>
parents: 548
diff changeset
117
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
118 /*
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
119 * Redirect following function to respective exported version from
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
120 * other modules. Since gen_v8_binding.m4 make all functions static,
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
121 * we need a exported version to call them indrectly from other
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
122 * modules.
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
123 */
683
7685c57e29d0 Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 681
diff changeset
124 #define xnjsmb_auto_path_new export_xnjsmb_auto_path_new
7685c57e29d0 Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 681
diff changeset
125 #define xnjsmb_auto_stext_new export_xnjsmb_auto_stext_new
7685c57e29d0 Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 681
diff changeset
126 #define xnjsmb_auto_image_new export_xnjsmb_auto_image_new
690
86c6ebf1de25 Add JS binding for sh_rect_t
Thinker K.F. Li <thinker@branda.to>
parents: 687
diff changeset
127 #define xnjsmb_auto_rect_new export_xnjsmb_auto_rect_new
687
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
128 #define xnjsmb_auto_paint_color_new export_xnjsmb_auto_paint_color_new
da12923a789a Migrate paints.cc to use gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 684
diff changeset
129 #define xnjsmb_auto_paint_image_new export_xnjsmb_auto_paint_image_new
733
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 690
diff changeset
130 #define xnjsmb_auto_paint_linear_new export_xnjsmb_auto_paint_linear_new
163f0d9e6382 Add binding for linear and radial paints for JS
Thinker K.F. Li <thinker@branda.to>
parents: 690
diff changeset
131 #define xnjsmb_auto_paint_radial_new export_xnjsmb_auto_paint_radial_new
683
7685c57e29d0 Migrate JS shapes binding to gen_v8_binding.m4
Thinker K.F. Li <thinker@branda.to>
parents: 681
diff changeset
132
666
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
133 #include "mbfly_njs-inc.h"
571
13b15b7a463b Redraw all and changed in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
134
556
c9d23f7279a4 The first testcase that nodejs code can show a MadButterfly window.
Thinker K.F. Li <thinker@branda.to>
parents: 548
diff changeset
135 /* @} */
c9d23f7279a4 The first testcase that nodejs code can show a MadButterfly window.
Thinker K.F. Li <thinker@branda.to>
parents: 548
diff changeset
136
562
1b6402f07cd4 Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents: 561
diff changeset
137 /*! \brief Get rdman associated with the runtime.
1b6402f07cd4 Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents: 561
diff changeset
138 */
559
ef078d7c57b4 Use internal field to store njs_runtime_t object.
Thinker K.F. Li <thinker@branda.to>
parents: 558
diff changeset
139 redraw_man_t *
ef078d7c57b4 Use internal field to store njs_runtime_t object.
Thinker K.F. Li <thinker@branda.to>
parents: 558
diff changeset
140 xnjsmb_rt_rdman(Handle<Object> mbrt) {
ef078d7c57b4 Use internal field to store njs_runtime_t object.
Thinker K.F. Li <thinker@branda.to>
parents: 558
diff changeset
141 HandleScope scope;
ef078d7c57b4 Use internal field to store njs_runtime_t object.
Thinker K.F. Li <thinker@branda.to>
parents: 558
diff changeset
142 njs_runtime_t *rt;
ef078d7c57b4 Use internal field to store njs_runtime_t object.
Thinker K.F. Li <thinker@branda.to>
parents: 558
diff changeset
143 redraw_man_t *rdman;
ef078d7c57b4 Use internal field to store njs_runtime_t object.
Thinker K.F. Li <thinker@branda.to>
parents: 558
diff changeset
144
ef078d7c57b4 Use internal field to store njs_runtime_t object.
Thinker K.F. Li <thinker@branda.to>
parents: 558
diff changeset
145 rt = (njs_runtime_t *)UNWRAP(mbrt);
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 1042
diff changeset
146 rdman = njs_mb_rdman(rt);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 778
diff changeset
147
559
ef078d7c57b4 Use internal field to store njs_runtime_t object.
Thinker K.F. Li <thinker@branda.to>
parents: 558
diff changeset
148 return rdman;
ef078d7c57b4 Use internal field to store njs_runtime_t object.
Thinker K.F. Li <thinker@branda.to>
parents: 558
diff changeset
149 }
ef078d7c57b4 Use internal field to store njs_runtime_t object.
Thinker K.F. Li <thinker@branda.to>
parents: 558
diff changeset
150
548
f69b0814ef3c Test FunctionTemplate
Thinker K.F. Li <thinker@branda.to>
parents: 547
diff changeset
151 Handle<Value>
f69b0814ef3c Test FunctionTemplate
Thinker K.F. Li <thinker@branda.to>
parents: 547
diff changeset
152 hello_func(const Arguments &args) {
f69b0814ef3c Test FunctionTemplate
Thinker K.F. Li <thinker@branda.to>
parents: 547
diff changeset
153 HandleScope scope;
f69b0814ef3c Test FunctionTemplate
Thinker K.F. Li <thinker@branda.to>
parents: 547
diff changeset
154
f69b0814ef3c Test FunctionTemplate
Thinker K.F. Li <thinker@branda.to>
parents: 547
diff changeset
155 return String::Concat(String::New("World"), args[0]->ToString());
f69b0814ef3c Test FunctionTemplate
Thinker K.F. Li <thinker@branda.to>
parents: 547
diff changeset
156 }
f69b0814ef3c Test FunctionTemplate
Thinker K.F. Li <thinker@branda.to>
parents: 547
diff changeset
157
547
371690a166df Remove hello.c and initial plugin at mbfly_njs.cc
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
158 extern "C" void
371690a166df Remove hello.c and initial plugin at mbfly_njs.cc
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
159 init(Handle<Object> target) {
371690a166df Remove hello.c and initial plugin at mbfly_njs.cc
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
160 HandleScope scope;
562
1b6402f07cd4 Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents: 561
diff changeset
161 Handle<FunctionTemplate> func, mb_rt_func;
1b6402f07cd4 Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents: 561
diff changeset
162 Handle<ObjectTemplate> rt_instance_temp, rt_proto_temp;
547
371690a166df Remove hello.c and initial plugin at mbfly_njs.cc
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
163
548
f69b0814ef3c Test FunctionTemplate
Thinker K.F. Li <thinker@branda.to>
parents: 547
diff changeset
164 func = FunctionTemplate::New(hello_func);
f69b0814ef3c Test FunctionTemplate
Thinker K.F. Li <thinker@branda.to>
parents: 547
diff changeset
165 target->Set(String::New("Hello"), func->GetFunction());
556
c9d23f7279a4 The first testcase that nodejs code can show a MadButterfly window.
Thinker K.F. Li <thinker@branda.to>
parents: 548
diff changeset
166
562
1b6402f07cd4 Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents: 561
diff changeset
167 /*
1b6402f07cd4 Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents: 561
diff changeset
168 * Initialize template for MadButterfly runtime objects.
1b6402f07cd4 Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents: 561
diff changeset
169 */
666
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
170 xnjsmb_auto_mb_rt_init();
871
67d0fed24120 Export a function to create a runtime for an existed window for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 869
diff changeset
171 xnjsmb_auto_mb_rt_display_init();
67d0fed24120 Export a function to create a runtime for an existed window for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 869
diff changeset
172 xnjsmb_auto_mb_rt_with_win_init();
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 1042
diff changeset
173 njs_mb_reg_timer_man();
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 1042
diff changeset
174 njs_mb_reg_IO_man();
571
13b15b7a463b Redraw all and changed in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 567
diff changeset
175
567
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents: 565
diff changeset
176 /*
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents: 565
diff changeset
177 * Add properties to mb_rt templates for other modules.
a12c3448afb6 Add dummy paint_color templates
Thinker K.F. Li <thinker@branda.to>
parents: 565
diff changeset
178 */
666
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
179 xnjsmb_shapes_init_mb_rt_temp(xnjsmb_auto_mb_rt_temp);
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
180 xnjsmb_paints_init_mb_rt_temp(xnjsmb_auto_mb_rt_temp);
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
181 xnjsmb_font_init_mb_rt_temp(xnjsmb_auto_mb_rt_temp);
639
dc32c1c140ae First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 638
diff changeset
182 xnjsmb_img_ldr_init_mb_rt_temp(target);
676
f264b50c469c Bind subject of mouse_event to JS object of coord
Thinker K.F. Li <thinker@branda.to>
parents: 675
diff changeset
183 xnjsmb_observer_init();
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 778
diff changeset
184
666
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 639
diff changeset
185 target->Set(String::New("mb_rt"),
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 778
diff changeset
186 xnjsmb_auto_mb_rt_temp->GetFunction());
871
67d0fed24120 Export a function to create a runtime for an existed window for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 869
diff changeset
187 target->Set(String::New("mb_rt_with_win"),
67d0fed24120 Export a function to create a runtime for an existed window for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 869
diff changeset
188 xnjsmb_auto_mb_rt_with_win_temp->GetFunction());
547
371690a166df Remove hello.c and initial plugin at mbfly_njs.cc
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
189 }
684
b346e4699e55 Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 683
diff changeset
190
b346e4699e55 Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 683
diff changeset
191 /* @} */