annotate nodejs/coord.cc @ 762:6133319d3fb4

Add udpate command
author wycc
date Sat, 28 Aug 2010 23:11:02 +0800
parents ed59e659a202
children be0e02948c1d
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
743
dd1f3382d6a4 Create a persistent handle for coords and shapes correctly
Thinker K.F. Li <thinker@codemud.net>
parents: 742
diff changeset
17 #define OK 0
dd1f3382d6a4 Create a persistent handle for coords and shapes correctly
Thinker K.F. Li <thinker@codemud.net>
parents: 742
diff changeset
18
739
4916c3a3fe3c Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 695
diff changeset
19 /*! \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
20 *
4916c3a3fe3c Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 695
diff changeset
21 * 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
22 * 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
23 * 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
24 * 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
25 * 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
26 * it.
4916c3a3fe3c Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 695
diff changeset
27 *
4916c3a3fe3c Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 695
diff changeset
28 * 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
29 * 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
30 * 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
31 * 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
32 * 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
33 * 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
34 * 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
35 * 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
36 *
4916c3a3fe3c Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 695
diff changeset
37 * 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
38 * 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
39 * 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
40 *
4916c3a3fe3c Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 695
diff changeset
41 * 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
42 * == 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
43 * 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
44 * 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
45 *
741
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
46 * For coords, they are always attached to the tree when it is valid.
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
47 * So, binding hold a persistent reference to it. The reference is
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
48 * purged when a coord being removed from the tree and being
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
49 * invalidated.
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
50 *
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
51 * For any shape, it is not attached to the tree at begining, but is
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
52 * attached to a tree laterly, or is collected by GC. The binding
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
53 * hold a weak reference for a new shape, and upgrade to a strong
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
54 * reference when the shape being added to the tree.
739
4916c3a3fe3c Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 695
diff changeset
55 */
4916c3a3fe3c Design doc for life-cycle of MB objects for JS
Thinker K.F. Li <thinker@codemud.net>
parents: 695
diff changeset
56
557
0ca8437a91fa Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
57 using namespace v8;
0ca8437a91fa Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
58
684
b346e4699e55 Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 680
diff changeset
59 /*! \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
60 * \ingroup xnjsmb
b346e4699e55 Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 680
diff changeset
61 *
b346e4699e55 Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 680
diff changeset
62 * @{
b346e4699e55 Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 680
diff changeset
63 */
741
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
64 /*! \brief Invalidate JS objects for coords and shapes in a subtree.
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
65 *
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
66 * \param self is the object of the root of subtree.
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
67 *
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
68 * \sa \ref jsgc
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
69 */
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
70 static void
745
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
71 xnjsmb_coord_invalidate_subtree(coord_t *coord) {
742
24038e7a365b Reorder instructions to invalidate coords correctly
Thinker K.F. Li <thinker@codemud.net>
parents: 741
diff changeset
72 Persistent<Object> *child_hdl;
24038e7a365b Reorder instructions to invalidate coords correctly
Thinker K.F. Li <thinker@codemud.net>
parents: 741
diff changeset
73 Persistent<Object> *mem_hdl;
745
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
74 coord_t *child;
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
75 shape_t *mem;
741
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
76 Handle<Value> _false = Boolean::New(0);
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
77
745
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
78 /* Invalidate all coords in the subtree */
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
79 FOR_COORDS_PREORDER(coord, child) {
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
80 child_hdl = (Persistent<Object> *)mb_prop_get(&child->obj.props,
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
81 PROP_JSOBJ);
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
82 SET(*child_hdl, "valid", _false);
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
83 WRAP(*child_hdl, NULL);
746
1dbc74a14199 Delete internal reference ob binding when invalidating coords and/or shapes
Thinker K.F. Li <thinker@codemud.net>
parents: 745
diff changeset
84 delete child_hdl;
745
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
85
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
86 /* Invalidate members of a coord */
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
87 FOR_COORD_SHAPES(child, mem) {
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
88 mem_hdl = (Persistent<Object> *)mb_prop_get(&mem->obj.props,
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
89 PROP_JSOBJ);
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
90 SET(*mem_hdl, "valid", _false);
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
91 WRAP(*mem_hdl, NULL);
746
1dbc74a14199 Delete internal reference ob binding when invalidating coords and/or shapes
Thinker K.F. Li <thinker@codemud.net>
parents: 745
diff changeset
92 delete mem_hdl;
745
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
93 }
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
94 }
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
95 }
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
96
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
97 /*! \brief Free C objects for coords and shapes in a subtree.
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
98 *
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
99 * \param self is the object of the root of subtree.
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
100 *
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
101 * \sa \ref jsgc
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
102 */
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
103 static void
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
104 xnjsmb_coord_free_subtree(redraw_man_t *rdman, coord_t *coord) {
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
105 coord_t *child, *last_child;
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
106 shape_t *mem, *last_mem;
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
107 int r;
741
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
108
744
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
109 rdman_coord_changed(rdman, coord);
741
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
110
744
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
111 last_child = NULL;
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
112 FOR_COORDS_POSTORDER(coord, child) {
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
113 if(last_child != NULL) {
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
114 r = rdman_coord_free(rdman, coord);
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
115 if(r != OK)
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
116 THROW_noret("Unknown error");
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
117 }
741
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
118
745
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
119 /* Free members of a coord */
744
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
120 last_mem = NULL;
741
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
121 FOR_COORD_SHAPES(child, mem) {
744
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
122 if(last_mem != NULL) {
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
123 r = rdman_shape_free(rdman, last_mem);
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
124 if(r != OK)
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
125 THROW_noret("Unknown error");
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
126 }
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
127
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
128 last_mem = mem;
741
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
129 }
744
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
130 if(last_mem != NULL) {
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
131 r = rdman_shape_free(rdman, last_mem);
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
132 if(r != OK)
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
133 THROW_noret("Unknown error");
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
134 }
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
135
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
136 last_child = child;
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
137 }
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
138 if(last_child != NULL) {
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
139 r = rdman_coord_free(rdman, coord);
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
140 if(r != OK)
6a988e23ad2a A dirty implementation of removing subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 743
diff changeset
141 THROW_noret("Unknown error");
741
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
142 }
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
143 }
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
144
680
a588eefd3f04 Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents: 667
diff changeset
145 static void
a588eefd3f04 Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents: 667
diff changeset
146 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
147 Persistent<Object> *self_hdl;
a588eefd3f04 Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents: 667
diff changeset
148 subject_t *subject;
a588eefd3f04 Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents: 667
diff changeset
149 Handle<Value> subject_o;
a588eefd3f04 Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents: 667
diff changeset
150
a588eefd3f04 Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents: 667
diff changeset
151 /* 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
152 * later, without create new js object.
a588eefd3f04 Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents: 667
diff changeset
153 */
743
dd1f3382d6a4 Create a persistent handle for coords and shapes correctly
Thinker K.F. Li <thinker@codemud.net>
parents: 742
diff changeset
154 self_hdl = new Persistent<Object>();
dd1f3382d6a4 Create a persistent handle for coords and shapes correctly
Thinker K.F. Li <thinker@codemud.net>
parents: 742
diff changeset
155 *self_hdl = Persistent<Object>::New(self);
680
a588eefd3f04 Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents: 667
diff changeset
156 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
157
a588eefd3f04 Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents: 667
diff changeset
158 subject = coord->mouse_event;
a588eefd3f04 Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents: 667
diff changeset
159 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
160 SET(self, "mouse_event", subject_o);
741
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
161 SET(self, "valid", Boolean::New(1));
680
a588eefd3f04 Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents: 667
diff changeset
162 }
a588eefd3f04 Refactor to xnjsmb_coord_mod().
Thinker K.F. Li <thinker@branda.to>
parents: 667
diff changeset
163
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
164 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
165 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
166 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
167 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
168 *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
169 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
170 }
557
0ca8437a91fa Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
171
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
172 return coord_get_matrix(coord)[idx];
557
0ca8437a91fa Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
173 }
0ca8437a91fa Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
174
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
175 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
176 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
177 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
178 Handle<Object> js_rt;
557
0ca8437a91fa Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
179 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
180
90c7726bc953 Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents: 566
diff changeset
181 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
182 *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
183 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
184 }
557
0ca8437a91fa Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
185
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
186 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
187
560
ce7a35abcb0d Function to instantiate coord for Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 557
diff changeset
188 js_rt = GET(self, "mbrt")->ToObject();
ce7a35abcb0d Function to instantiate coord for Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 557
diff changeset
189 rdman = xnjsmb_rt_rdman(js_rt);
557
0ca8437a91fa Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
190 rdman_coord_changed(rdman, coord);
0ca8437a91fa Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
191
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
192 return v;
557
0ca8437a91fa Implement Indexed Property interceptors
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
193 }
560
ce7a35abcb0d Function to instantiate coord for Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 557
diff changeset
194
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
195 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
196 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
197 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
198 Handle<Object> js_rt;
748
56a5e08cd8af Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents: 746
diff changeset
199 Persistent<Object> *shape_hdl;
566
6639d386db78 Function of add a shape to a coord in Javascript.
Thinker K.F. Li <thinker@branda.to>
parents: 563
diff changeset
200 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
201 int r;
6639d386db78 Function of add a shape to a coord in Javascript.
Thinker K.F. Li <thinker@branda.to>
parents: 563
diff changeset
202
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
203 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
204 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
205 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
206 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
207 *err = "Unknown error";
748
56a5e08cd8af Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents: 746
diff changeset
208
56a5e08cd8af Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents: 746
diff changeset
209 /* see \ref jsgc */
56a5e08cd8af Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents: 746
diff changeset
210 shape_hdl = (Persistent<Object> *)mb_prop_get(&shape->obj.props,
56a5e08cd8af Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents: 746
diff changeset
211 PROP_JSOBJ);
56a5e08cd8af Make shapes can be removed from the tree
Thinker K.F. Li <thinker@codemud.net>
parents: 746
diff changeset
212 shape_hdl->ClearWeak();
566
6639d386db78 Function of add a shape to a coord in Javascript.
Thinker K.F. Li <thinker@branda.to>
parents: 563
diff changeset
213 }
6639d386db78 Function of add a shape to a coord in Javascript.
Thinker K.F. Li <thinker@branda.to>
parents: 563
diff changeset
214
741
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
215 static void
745
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
216 xnjsmb_coord_remove(coord_t *coord, Handle<Object> self) {
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
217 Handle<Object> js_rt;
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
218 redraw_man_t *rdman;
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
219
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
220 if(!GET(self, "valid")->ToBoolean()->Value()) /* Invalidated object */
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
221 THROW_noret("Invalid object");
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
222
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
223 js_rt = GET(self, "mbrt")->ToObject();
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
224 rdman = xnjsmb_rt_rdman(js_rt);
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
225
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
226 xnjsmb_coord_invalidate_subtree(coord);
4ccb0553e804 Refactor code of free C objects into xnjsmb_coord_free_subtree
Thinker K.F. Li <thinker@codemud.net>
parents: 744
diff changeset
227 xnjsmb_coord_free_subtree(rdman, coord);
741
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
228 }
d8764f10e141 Remove a coord from the tree in JS
Thinker K.F. Li <thinker@codemud.net>
parents: 739
diff changeset
229
749
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
230 static void
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
231 xnjsmb_coord_show(coord_t *coord, Handle<Object> self) {
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
232 Handle<Object> js_rt;
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
233 redraw_man_t *rdman;
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
234
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
235 js_rt = GET(self, "mbrt")->ToObject();
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
236 ASSERT(js_rt != NULL);
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
237 rdman = xnjsmb_rt_rdman(js_rt);
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
238
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
239 coord_show(coord);
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
240 rdman_coord_changed(rdman, coord);
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
241 }
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
242
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
243 static void
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
244 xnjsmb_coord_hide(coord_t *coord, Handle<Object> self) {
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
245 Handle<Object> js_rt;
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
246 redraw_man_t *rdman;
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
247
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
248 js_rt = GET(self, "mbrt")->ToObject();
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
249 ASSERT(js_rt != NULL);
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
250 rdman = xnjsmb_rt_rdman(js_rt);
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
251
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
252 coord_hide(coord);
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
253 rdman_coord_changed(rdman, coord);
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
254 }
ed59e659a202 Implement binding for hide/show for shapes and coords
Thinker K.F. Li <thinker@codemud.net>
parents: 748
diff changeset
255
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
256 #include "coord-inc.h"
562
1b6402f07cd4 Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
257
684
b346e4699e55 Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 680
diff changeset
258 /*! \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
259 */
666
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 661
diff changeset
260 Handle<Value> export_xnjsmb_auto_coord_new(coord_t *coord) {
695
763a4e2bbd85 Return the value of ojbject to fix the crash issue
wycc
parents: 684
diff changeset
261 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
262 }
b6fb543d69ee Use binding generator to implement mb_rt
Thinker K.F. Li <thinker@branda.to>
parents: 661
diff changeset
263
562
1b6402f07cd4 Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
264 /*! \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
265 *
1b6402f07cd4 Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
266 * \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
267 *
1b6402f07cd4 Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
268 * 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
269 * Javascript.
1b6402f07cd4 Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
270 */
1b6402f07cd4 Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
271 void
1b6402f07cd4 Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
272 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
273 redraw_man_t *rdman;
1b6402f07cd4 Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
274 coord_t *root;
1b6402f07cd4 Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
275 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
276 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
277
90c7726bc953 Replace part code of coord.cc by the code generated by generator
Thinker K.F. Li <thinker@branda.to>
parents: 566
diff changeset
278 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
279 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
280 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
281 }
562
1b6402f07cd4 Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
282
1b6402f07cd4 Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
283 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
284 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
285 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
286 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
287
1b6402f07cd4 Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
288 SET(js_rt, "root", obj);
1b6402f07cd4 Make root coord availabe for Javascript code
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
289 }
684
b346e4699e55 Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 680
diff changeset
290
b346e4699e55 Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents: 680
diff changeset
291 /* @} */