Mercurial > MadButterfly
annotate nodejs/coord.cc @ 739:4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Mon, 23 Aug 2010 10:23:30 +0800 |
parents | 763a4e2bbd85 |
children | d8764f10e141 |
rev | line source |
---|---|
557
0ca8437a91fa
Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1 #include <stdio.h> |
0ca8437a91fa
Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
2 #include <v8.h> |
0ca8437a91fa
Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
3 |
0ca8437a91fa
Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
4 extern "C" { |
0ca8437a91fa
Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
5 #include "mb.h" |
0ca8437a91fa
Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
6 #include "mb_X_supp.h" |
0ca8437a91fa
Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
7 #include "mb_tools.h" |
0ca8437a91fa
Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
8 #include "X_supp_njs.h" |
0ca8437a91fa
Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
9 } |
0ca8437a91fa
Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
10 |
560
ce7a35abcb0d
Function to instantiate coord for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
557
diff
changeset
|
11 #include "mbfly_njs.h" |
ce7a35abcb0d
Function to instantiate coord for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
557
diff
changeset
|
12 |
ce7a35abcb0d
Function to instantiate coord for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
557
diff
changeset
|
13 #ifndef ASSERT |
ce7a35abcb0d
Function to instantiate coord for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
557
diff
changeset
|
14 #define ASSERT(x) |
ce7a35abcb0d
Function to instantiate coord for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
557
diff
changeset
|
15 #endif |
ce7a35abcb0d
Function to instantiate coord for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
557
diff
changeset
|
16 |
739
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
17 /*! \page jsgc How to Manage Life-cycle of Objects for Javascript. |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
18 * |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
19 * The life-cycle of MadButterfly ojects are simple. A object is live |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
20 * when it is created and dead when it is free. When a coord or shape |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
21 * is free, it is also removed from the tree. There is not way to |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
22 * remove a coord or a shape without freeing it. So, if you want to |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
23 * remove a coord or a shape object from the tree, you can only free |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
24 * it. |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
25 * |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
26 * Javascript, in conventional, does not free an object. It has GC, |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
27 * the engine, being used, will free an object if it is no more |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
28 * referenced. So, we had better provide a removing function, but |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
29 * actually free an object. In idea situation, a new MB object would |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
30 * be created for and attached on the JS object, when an object added |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
31 * back to the tree. But, it means we need to keep states of an |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
32 * object and create a new one with the same states later. It is |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
33 * complicated. So, once an object is removed, it is invalidated. |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
34 * |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
35 * I hope someone would implement a higher abstract layer, in JS, to |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
36 * implement the idea model that recreate a new object when an |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
37 * invalidated JS object being added back. |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
38 * |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
39 * An invalid object is the one with NULL internal field and obj.valid |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
40 * == false. The binding of MadButterfly hold a reference to every |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
41 * object added to the tree of a mbrt (runtime object), and remove the |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
42 * reference and invalidate it when it being removed. |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
43 * |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
44 * The binding also hold a weak reference to every object, it free the |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
45 * object when the callback of the weak reference being called and it |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
46 * being valid. If the object is invalid, the callback does nothing. |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
47 */ |
4916c3a3fe3c
Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents:
695
diff
changeset
|
48 |
557
0ca8437a91fa
Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
49 using namespace v8; |
0ca8437a91fa
Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
50 |
684
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
680
diff
changeset
|
51 /*! \defgroup xnjsmb_coord JS binding for coord objects. |
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
680
diff
changeset
|
52 * \ingroup xnjsmb |
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
680
diff
changeset
|
53 * |
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
680
diff
changeset
|
54 * @{ |
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
680
diff
changeset
|
55 */ |
680
a588eefd3f04
Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents:
667
diff
changeset
|
56 static void |
a588eefd3f04
Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents:
667
diff
changeset
|
57 xnjsmb_coord_mod(Handle<Object> self, coord_t *coord) { |
a588eefd3f04
Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents:
667
diff
changeset
|
58 Persistent<Object> *self_hdl; |
a588eefd3f04
Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents:
667
diff
changeset
|
59 subject_t *subject; |
a588eefd3f04
Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents:
667
diff
changeset
|
60 Handle<Value> subject_o; |
a588eefd3f04
Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents:
667
diff
changeset
|
61 |
a588eefd3f04
Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents:
667
diff
changeset
|
62 /* Keep associated js object in property store for retrieving, |
a588eefd3f04
Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents:
667
diff
changeset
|
63 * later, without create new js object. |
a588eefd3f04
Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents:
667
diff
changeset
|
64 */ |
a588eefd3f04
Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents:
667
diff
changeset
|
65 self_hdl = new Persistent<Object>(self); |
a588eefd3f04
Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents:
667
diff
changeset
|
66 mb_prop_set(&coord->obj.props, PROP_JSOBJ, self_hdl); |
a588eefd3f04
Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents:
667
diff
changeset
|
67 |
a588eefd3f04
Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents:
667
diff
changeset
|
68 subject = coord->mouse_event; |
a588eefd3f04
Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents:
667
diff
changeset
|
69 subject_o = export_xnjsmb_auto_subject_new(subject); |
a588eefd3f04
Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents:
667
diff
changeset
|
70 SET(self, "mouse_event", subject_o); |
a588eefd3f04
Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents:
667
diff
changeset
|
71 } |
a588eefd3f04
Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents:
667
diff
changeset
|
72 |
661
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
73 static float |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
74 coord_get_index(coord_t *coord, Handle<Object> self, int idx, |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
75 const char **err) { |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
76 if(idx < 0 || idx >= 6) { |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
77 *err = "Invalid index: out of range"; |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
78 return 0; |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
79 } |
557
0ca8437a91fa
Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
80 |
661
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
81 return coord_get_matrix(coord)[idx]; |
557
0ca8437a91fa
Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
82 } |
0ca8437a91fa
Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
83 |
661
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
84 static float |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
85 coord_set_index(coord_t *coord, Handle<Object> self, |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
86 int idx, float v, const char **err) { |
560
ce7a35abcb0d
Function to instantiate coord for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
557
diff
changeset
|
87 Handle<Object> js_rt; |
557
0ca8437a91fa
Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
88 redraw_man_t *rdman; |
661
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
89 |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
90 if(idx < 0 || idx >= 6) { |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
91 *err = "Invalid index: out of range"; |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
92 return 0; |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
93 } |
557
0ca8437a91fa
Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
94 |
661
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
95 coord_get_matrix(coord)[idx] = v; |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
96 |
560
ce7a35abcb0d
Function to instantiate coord for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
557
diff
changeset
|
97 js_rt = GET(self, "mbrt")->ToObject(); |
ce7a35abcb0d
Function to instantiate coord for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
557
diff
changeset
|
98 rdman = xnjsmb_rt_rdman(js_rt); |
557
0ca8437a91fa
Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
99 rdman_coord_changed(rdman, coord); |
0ca8437a91fa
Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
100 |
661
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
101 return v; |
557
0ca8437a91fa
Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
102 } |
560
ce7a35abcb0d
Function to instantiate coord for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
557
diff
changeset
|
103 |
661
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
104 static void |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
105 xnjsmb_coord_add_shape(coord_t *coord, Handle<Object> self, |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
106 shape_t *shape, const char **err) { |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
107 Handle<Object> js_rt; |
566
6639d386db78
Function of add a shape to a coord in Javascript.
Thinker K.F. Li <thinker@branda.to>
parents:
563
diff
changeset
|
108 redraw_man_t *rdman; |
6639d386db78
Function of add a shape to a coord in Javascript.
Thinker K.F. Li <thinker@branda.to>
parents:
563
diff
changeset
|
109 int r; |
6639d386db78
Function of add a shape to a coord in Javascript.
Thinker K.F. Li <thinker@branda.to>
parents:
563
diff
changeset
|
110 |
661
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
111 js_rt = GET(self, "mbrt")->ToObject(); |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
112 rdman = xnjsmb_rt_rdman(js_rt); |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
113 r = rdman_add_shape(rdman, shape, coord); |
566
6639d386db78
Function of add a shape to a coord in Javascript.
Thinker K.F. Li <thinker@branda.to>
parents:
563
diff
changeset
|
114 if(r != 0) |
661
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
115 *err = "Unknown error"; |
566
6639d386db78
Function of add a shape to a coord in Javascript.
Thinker K.F. Li <thinker@branda.to>
parents:
563
diff
changeset
|
116 } |
6639d386db78
Function of add a shape to a coord in Javascript.
Thinker K.F. Li <thinker@branda.to>
parents:
563
diff
changeset
|
117 |
661
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
118 #include "coord-inc.h" |
562
1b6402f07cd4
Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents:
560
diff
changeset
|
119 |
684
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
680
diff
changeset
|
120 /*! \brief This function used by \ref xnjsmb_mb_rt to wrap coord object. |
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
680
diff
changeset
|
121 */ |
666
b6fb543d69ee
Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents:
661
diff
changeset
|
122 Handle<Value> export_xnjsmb_auto_coord_new(coord_t *coord) { |
695 | 123 return xnjsmb_auto_coord_new(coord); |
666
b6fb543d69ee
Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents:
661
diff
changeset
|
124 } |
b6fb543d69ee
Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents:
661
diff
changeset
|
125 |
562
1b6402f07cd4
Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents:
560
diff
changeset
|
126 /*! \brief Initialize Javascript object for root coord of a runtime. |
1b6402f07cd4
Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents:
560
diff
changeset
|
127 * |
1b6402f07cd4
Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents:
560
diff
changeset
|
128 * \param js_rt is the runtime object to create the root object for. |
1b6402f07cd4
Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents:
560
diff
changeset
|
129 * |
1b6402f07cd4
Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents:
560
diff
changeset
|
130 * After the function, js_rt.root is the object for root coord in |
1b6402f07cd4
Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents:
560
diff
changeset
|
131 * Javascript. |
1b6402f07cd4
Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents:
560
diff
changeset
|
132 */ |
1b6402f07cd4
Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents:
560
diff
changeset
|
133 void |
1b6402f07cd4
Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents:
560
diff
changeset
|
134 xnjsmb_coord_mkroot(Handle<Object> js_rt) { |
1b6402f07cd4
Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents:
560
diff
changeset
|
135 redraw_man_t *rdman; |
1b6402f07cd4
Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents:
560
diff
changeset
|
136 coord_t *root; |
1b6402f07cd4
Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents:
560
diff
changeset
|
137 Handle<Object> obj; |
661
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
138 static int init_flag = 0; |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
139 |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
140 if(!init_flag) { |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
141 xnjsmb_auto_coord_init(); |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
142 init_flag = 1; |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
143 } |
562
1b6402f07cd4
Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents:
560
diff
changeset
|
144 |
1b6402f07cd4
Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents:
560
diff
changeset
|
145 rdman = xnjsmb_rt_rdman(js_rt); |
1b6402f07cd4
Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents:
560
diff
changeset
|
146 root = rdman_get_root(rdman); |
661
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
147 obj = xnjsmb_auto_coord_new(root).As<Object>(); |
90c7726bc953
Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents:
566
diff
changeset
|
148 SET(obj, "mbrt", js_rt); |
562
1b6402f07cd4
Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents:
560
diff
changeset
|
149 |
1b6402f07cd4
Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents:
560
diff
changeset
|
150 SET(js_rt, "root", obj); |
1b6402f07cd4
Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents:
560
diff
changeset
|
151 } |
684
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
680
diff
changeset
|
152 |
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
680
diff
changeset
|
153 /* @} */ |