annotate nodejs/njs_mb_supp.c @ 1177:ec1ea8555911

Stop selectSceneObject() from using private variable _keys of frameline
author Thinker K.F. Li <thinker@codemud.net>
date Fri, 31 Dec 2010 10:29:21 +0800
parents 88bd0eee2b00
children
rev   line source
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 753
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: 753
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 /*! \brief Implement X11 backend for nodejs plugin.
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
4 *
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
5 * Since nodejs use libev to handle event loops, part of X11 backend
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
6 * code can not be used directly. The part of code should be rewrote.
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
7 * The part is about
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
8 */
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
9 #include <stdio.h>
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
10 #include <string.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
11 #include <ev.h>
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
12 #include "mb_tools.h"
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
13 #include <mb_backend.h>
1056
88bd0eee2b00 Rename X_supp_njs.[ch] to njs_mb_supp.[ch].
Thinker K.F. Li <thinker@codemud.net>
parents: 1055
diff changeset
14 #include "njs_mb_supp.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
15
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
16 #ifndef ASSERT
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
17 #define ASSERT(x)
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
18 #endif
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
19
1039
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
20 #define OK 0
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
21 #define ERR -1
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
22
1040
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
23
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
24 /*! \defgroup njs_timer_man Timer manager for nodejs.
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
25 * @{
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
26 */
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
27 struct _njs_timer_timeout {
1040
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
28 ev_timer tmwatcher;
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
29 mb_timer_cb_t cb;
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
30 mb_timeval_t *timeout;
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
31 void *data;
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
32 };
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
33
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
34 static int njs_timer_man_timeout(mb_timer_man_t *tm_man,
1040
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
35 mb_timeval_t *tm_out,
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
36 mb_timer_cb_t cb, void *data);
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
37 static void njs_timer_man_remove(mb_timer_man_t *tm_man, int tm_hdl);
1040
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
38 static mb_timer_man_t *njs_timer_man_new(void);
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
39 static void njs_timer_man_free(mb_timer_man_t *timer_man);
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
40
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
41 static mb_timer_man_t njs_timer_man = {
1040
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
42 njs_timer_man_timeout,
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
43 njs_timer_man_remove
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
44 };
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
45
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
46 static mb_timer_factory_t njs_timer_factory = {
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
47 njs_timer_man_new,
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
48 njs_timer_man_free
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
49 };
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
50
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
51 static void
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
52 njs_timer_man_cb(EV_P_ ev_timer *tmwatcher, int revent) {
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
53 struct _njs_timer_timeout *timer_timeout =
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
54 MEM2OBJ(tmwatcher, struct _njs_timer_timeout, tmwatcher);
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
55 mb_timeval_t now;
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
56
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
57 get_now(&now);
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
58 timer_timeout->cb((int)timer_timeout, timer_timeout->timeout, &now,
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
59 timer_timeout->data);
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
60 }
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
61
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
62 static int
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
63 njs_timer_man_timeout(mb_timer_man_t *tm_man,
1040
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
64 mb_timeval_t *timeout,
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
65 mb_timer_cb_t cb, void *data) {
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
66 struct _njs_timer_timeout *timer_timeout;
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
67 mb_timeval_t now, timeout_diff;
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
68 ev_tstamp timeout_stamp;
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
69
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
70 timer_timeout = O_ALLOC(struct _njs_timer_timeout);
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
71 if(timer_timeout == NULL)
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
72 return ERR;
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
73
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
74 timer_timeout->cb = cb;
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
75 timer_timeout->timeout = timeout;
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
76
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
77 get_now(&now);
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
78
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
79 memcpy(&timeout_diff, timeout, sizeof(mb_timeval_t));
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
80 MB_TIMEVAL_DIFF(&timeout_diff, &now);
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
81 timeout_stamp = (ev_tstamp)MB_TIMEVAL_SEC(&timeout_diff) +
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
82 (ev_tstamp)MB_TIMEVAL_USEC(&timeout_diff) / 1000000;
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
83 ev_timer_init(&timer_timeout->tmwatcher, njs_timer_man_cb,
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
84 timeout_stamp, 0);
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
85 ev_timer_start(&timer_timeout->tmwatcher);
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
86
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
87 return (int)timer_timeout;
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
88 }
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
89
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
90 static void
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
91 njs_timer_man_remove(struct _mb_timer_man *tm_man, int tm_hdl) {
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
92 struct _njs_timer_timeout *timer_timeout =
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
93 (struct _njs_timer_timeout *)tm_hdl;
1040
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
94
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
95 ev_timer_stop(&timer_timeout->tmwatcher);
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
96 free(timer_timeout);
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
97 }
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
98
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
99 static mb_timer_man_t *
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
100 njs_timer_man_new(void) {
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
101 return &njs_timer_man;
1040
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
102 }
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
103
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
104 static void
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
105 njs_timer_man_free(mb_timer_man_t *timer_man) {
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
106 }
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
107
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
108 void
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 1042
diff changeset
109 njs_mb_reg_timer_man(void) {
1040
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
110 mb_reg_timer_factory(&njs_timer_factory);
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
111 }
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
112
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
113 /* @} */
22e5cf38d8e8 Timer manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 1039
diff changeset
114
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
115
1039
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
116 /*! \defgroup njs_io_man IO manager for nodejs.
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
117 * @{
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
118 */
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
119 struct _njs_io_reg {
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
120 ev_io iowatcher;
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
121 int fd;
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
122 mb_IO_cb_t cb;
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
123 void *data;
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
124 };
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
125
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
126 static int njs_io_man_reg(struct _mb_IO_man *io_man,
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
127 int fd, MB_IO_TYPE type, mb_IO_cb_t cb, void *data);
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
128 static void njs_io_man_unreg(struct _mb_IO_man *io_man, int io_hdl);
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
129 static mb_IO_man_t *njs_io_man_new(void);
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
130 static void njs_io_man_free(mb_IO_man_t *io_man);
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
131
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
132 static mb_IO_man_t njs_io_man = {
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
133 njs_io_man_reg,
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
134 njs_io_man_unreg
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
135 };
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
136
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
137 /*! \brief IO factory to integrate MadButterfly to event loop of nodejs.
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
138 */
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
139 static mb_IO_factory_t njs_io_factory = {
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
140 njs_io_man_new,
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
141 njs_io_man_free
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
142 };
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
143
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
144 /*! \brief Bridge libev callback to IO manager callback.
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
145 */
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
146 static void
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
147 njs_io_man_cb(EV_P_ ev_io *iowatcher, int revent) {
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
148 struct _njs_io_reg *io_reg =
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
149 MEM2OBJ(iowatcher, struct _njs_io_reg, iowatcher);
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
150 MB_IO_TYPE type;
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
151
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
152 switch(revent & (EV_READ | EV_WRITE)) {
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
153 case EV_READ:
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
154 type = MB_IO_R;
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
155 break;
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
156 case EV_WRITE:
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
157 type = MB_IO_W;
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
158 break;
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
159 case EV_READ | EV_WRITE:
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
160 type = MB_IO_RW;
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
161 break;
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
162 }
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
163
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
164 io_reg->cb((int)io_reg, io_reg->fd, type, io_reg->data);
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
165 }
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
166
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
167 static int
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
168 njs_io_man_reg(struct _mb_IO_man *io_man,
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
169 int fd, MB_IO_TYPE type, mb_IO_cb_t cb, void *data) {
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
170 int _type;
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
171 struct _njs_io_reg *io_reg;
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
172
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
173 if(type == MB_IO_R)
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
174 _type = EV_READ;
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
175 else if(type == MB_IO_W)
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
176 _type = EV_WRITE;
1039
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
177 else if(type == MB_IO_RW)
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
178 _type = EV_READ | EV_WRITE;
1039
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
179 else
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
180 return ERR;
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
181
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
182 io_reg = O_ALLOC(struct _njs_io_reg);
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
183 if(io_reg == NULL)
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
184 return ERR;
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
185
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
186 io_reg->fd = fd;
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
187 io_reg->cb = cb;
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
188 io_reg->data = data;
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
189
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
190 ev_io_init(&io_reg->iowatcher, njs_io_man_cb, fd, _type);
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
191 ev_io_start(&io_reg->iowatcher);
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
192
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
193 return (int)io_reg;
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
194 }
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
195
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
196 static void
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
197 njs_io_man_unreg(struct _mb_IO_man *io_man, int io_hdl) {
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
198 struct _njs_io_reg *io_reg = (struct _njs_io_reg *)io_hdl;
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
199
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
200 ev_io_stop(&io_reg->iowatcher);
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
201 free(io_reg);
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
202 }
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
203
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
204 static mb_IO_man_t *
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
205 njs_io_man_new(void) {
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
206 return &njs_io_man;
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
207 }
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
208
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
209 static void
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
210 njs_io_man_free(mb_IO_man_t *io_man) {
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
211 }
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
212
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
213 /*! \brief Register an IO factory with MadButterfly backend.
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
214 */
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
215 void
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 1042
diff changeset
216 njs_mb_reg_IO_man(void) {
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
217 mb_reg_IO_factory(&njs_io_factory);
1039
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
218 }
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
219
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
220 /* @} */
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
221
551
9e69c4a0f565 rename njs_ev_data_t to njs_runtime_t
Thinker K.F. Li <thinker@branda.to>
parents: 550
diff changeset
222 /*! \brief Free njs_runtime_t.
550
127499ab2412 Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
223 */
127499ab2412 Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
224 void
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 1042
diff changeset
225 njs_mb_free(njs_runtime_t *rt) {
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
226 /*!
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
227 * TODO: Release all IO and timer request.
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
228 */
1055
1375aa8629ac Rename njs_runtime_t::xrt to njs_runtime_t::mb_rt
Thinker K.F. Li <thinker@codemud.net>
parents: 1054
diff changeset
229 mb_runtime_free(rt->mb_rt);
554
4caf6090825f Fix leaking on freeing a njs runtime object
Thinker K.F. Li <thinker@branda.to>
parents: 553
diff changeset
230 free(rt);
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
231 }
550
127499ab2412 Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
232
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
233 /*! \brief Free njs_runtime_t.
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
234 */
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
235 void
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 1042
diff changeset
236 njs_mb_free_keep_win(njs_runtime_t *rt) {
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
237 /*
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
238 * TODO: Release all IO and timer request.
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
239 */
1055
1375aa8629ac Rename njs_runtime_t::xrt to njs_runtime_t::mb_rt
Thinker K.F. Li <thinker@codemud.net>
parents: 1054
diff changeset
240 mb_runtime_free_keep_win(rt->mb_rt);
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
241 free(rt);
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
242 }
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
243
571
13b15b7a463b Redraw all and changed in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
244 int
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 1042
diff changeset
245 njs_mb_flush(njs_runtime_t *rt) {
1055
1375aa8629ac Rename njs_runtime_t::xrt to njs_runtime_t::mb_rt
Thinker K.F. Li <thinker@codemud.net>
parents: 1054
diff changeset
246 mb_rt_t *mb_rt = rt->mb_rt;
571
13b15b7a463b Redraw all and changed in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
247 int r;
13b15b7a463b Redraw all and changed in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
248
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
249 r = mb_runtime_flush(mb_rt);
571
13b15b7a463b Redraw all and changed in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
250 return r;
13b15b7a463b Redraw all and changed in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
251 }
13b15b7a463b Redraw all and changed in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 560
diff changeset
252
551
9e69c4a0f565 rename njs_ev_data_t to njs_runtime_t
Thinker K.F. Li <thinker@branda.to>
parents: 550
diff changeset
253 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
254 njs_mb_new(char *display_name, int w, int h) {
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
255 njs_runtime_t *rt;
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
256 mb_rt_t *mb_rt;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 753
diff changeset
257
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
258 rt = (njs_runtime_t *)malloc(sizeof(njs_runtime_t));
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
259 ASSERT(rt != NULL);
550
127499ab2412 Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
260
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
261 mb_rt = mb_runtime_new(display_name, w, h);
550
127499ab2412 Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
262
1055
1375aa8629ac Rename njs_runtime_t::xrt to njs_runtime_t::mb_rt
Thinker K.F. Li <thinker@codemud.net>
parents: 1054
diff changeset
263 rt->mb_rt = mb_rt;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 753
diff changeset
264
552
dd8d32b4c899 rename ev_data to rt
Thinker K.F. Li <thinker@branda.to>
parents: 551
diff changeset
265 return rt;
550
127499ab2412 Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
266 }
127499ab2412 Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
267
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
268 /*! \brief Create a njs_runtime_t for an existed window.
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
269 *
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
270 * The njs_runtime_t created by this function must be free by
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 1042
diff changeset
271 * njs_mb_free_keep_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
272 */
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
273 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
274 njs_mb_new_with_win(void *display, long 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
275 njs_runtime_t *rt;
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
276 mb_rt_t *mb_rt;
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
277
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
278 rt = (njs_runtime_t *)malloc(sizeof(njs_runtime_t));
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
279 ASSERT(rt != NULL);
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
280
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
281 mb_rt = mb_runtime_new_with_win((Display *)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
282
1055
1375aa8629ac Rename njs_runtime_t::xrt to njs_runtime_t::mb_rt
Thinker K.F. Li <thinker@codemud.net>
parents: 1054
diff changeset
283 rt->mb_rt = mb_rt;
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
284
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
285 return rt;
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
286 }
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
287
869
c18058fb48ee Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
288 /*! \brief Pass a X event to X runtime.
c18058fb48ee Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
289 */
c18058fb48ee Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
290 void
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 1042
diff changeset
291 njs_mb_handle_single_event(njs_runtime_t *rt, void *evt) {
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
292 #if 0
1055
1375aa8629ac Rename njs_runtime_t::xrt to njs_runtime_t::mb_rt
Thinker K.F. Li <thinker@codemud.net>
parents: 1054
diff changeset
293 void *mb_rt = rt->mb_rt;
869
c18058fb48ee Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
294 extern void _X_MB_handle_single_event(void *rt, void *evt);
c18058fb48ee Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
295
1055
1375aa8629ac Rename njs_runtime_t::xrt to njs_runtime_t::mb_rt
Thinker K.F. Li <thinker@codemud.net>
parents: 1054
diff changeset
296 _X_MB_handle_single_event(mb_rt, evt);
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
297 #endif
869
c18058fb48ee Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
298 }
c18058fb48ee Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
299
c18058fb48ee Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
300 /*! \brief Called at end of an iteration of event loop.
c18058fb48ee Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
301 */
c18058fb48ee Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
302 void
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 1042
diff changeset
303 njs_mb_no_more_event(njs_runtime_t *rt) {
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
304 #if 0
1055
1375aa8629ac Rename njs_runtime_t::xrt to njs_runtime_t::mb_rt
Thinker K.F. Li <thinker@codemud.net>
parents: 1054
diff changeset
305 mb_rt_t *mb_rt = rt->mb_rt;
1039
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
306 extern void _X_MB_no_more_event(mb_rt_t *rt);
869
c18058fb48ee Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
307
1055
1375aa8629ac Rename njs_runtime_t::xrt to njs_runtime_t::mb_rt
Thinker K.F. Li <thinker@codemud.net>
parents: 1054
diff changeset
308 _X_MB_no_more_event(mb_rt);
1042
18256f404193 nodejs binding passes compiling
Thinker K.F. Li <thinker@codemud.net>
parents: 1040
diff changeset
309 #endif
869
c18058fb48ee Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
310 }
c18058fb48ee Export API for JS to feed X events.
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
311
553
0a77b88500bf rename _X_njs_MB_get_runtime to _X_njs_MB_get_X_runtime
Thinker K.F. Li <thinker@branda.to>
parents: 552
diff changeset
312 /*! \brief Get X runtime that is backend of this njs runtime.
0a77b88500bf rename _X_njs_MB_get_runtime to _X_njs_MB_get_X_runtime
Thinker K.F. Li <thinker@branda.to>
parents: 552
diff changeset
313 */
1039
176cba3ad32c IO manager for njs
Thinker K.F. Li <thinker@codemud.net>
parents: 871
diff changeset
314 mb_rt_t *
1053
df6ee4568ca2 Rename X_njs_MB_* to njs_mb_* for nodejs plugin.
Thinker K.F. Li <thinker@codemud.net>
parents: 1042
diff changeset
315 _njs_mb_get_runtime(njs_runtime_t *rt) {
1055
1375aa8629ac Rename njs_runtime_t::xrt to njs_runtime_t::mb_rt
Thinker K.F. Li <thinker@codemud.net>
parents: 1054
diff changeset
316 return rt->mb_rt;
550
127499ab2412 Upgrade ndoejs plugin to level of a new runtime.
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
317 }