comparison nodejs/observer.cc @ 822:586e50f82c1f

Unify coding style tag for emacs and vim.
author Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
date Tue, 14 Sep 2010 01:08:39 +0800
parents 7ec13634c97d
children 1993e5ae60aa
comparison
equal deleted inserted replaced
821:bfdc82bbd6e4 822:586e50f82c1f
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*-
2 // vim: sw=4:ts=8:sts=4
1 #include <v8.h> 3 #include <v8.h>
2 #include "mbfly_njs.h" 4 #include "mbfly_njs.h"
3 5
4 extern "C" { 6 extern "C" {
5 #include <mb.h> 7 #include <mb.h>
28 30
29 static void 31 static void
30 xnjsmb_event_mod(Handle<Object> self, event_t *evt) { 32 xnjsmb_event_mod(Handle<Object> self, event_t *evt) {
31 mouse_event_t *mevt; 33 mouse_event_t *mevt;
32 X_kb_event_t *xkbevt; 34 X_kb_event_t *xkbevt;
33 35
34 switch(evt->type) { 36 switch(evt->type) {
35 case EVT_ANY: 37 case EVT_ANY:
36 case EVT_MOUSE_OVER: 38 case EVT_MOUSE_OVER:
37 case EVT_MOUSE_OUT: 39 case EVT_MOUSE_OUT:
38 case EVT_MOUSE_MOVE: 40 case EVT_MOUSE_MOVE:
42 SET(self, "x", Integer::New(mevt->x)); 44 SET(self, "x", Integer::New(mevt->x));
43 SET(self, "y", Integer::New(mevt->y)); 45 SET(self, "y", Integer::New(mevt->y));
44 SET(self, "but_state", Integer::New(mevt->but_state)); 46 SET(self, "but_state", Integer::New(mevt->but_state));
45 SET(self, "button", Integer::New(mevt->button)); 47 SET(self, "button", Integer::New(mevt->button));
46 break; 48 break;
47 49
48 case EVT_KB_PRESS: 50 case EVT_KB_PRESS:
49 case EVT_KB_RELEASE: 51 case EVT_KB_RELEASE:
50 xkbevt = (X_kb_event_t *)evt; 52 xkbevt = (X_kb_event_t *)evt;
51 SET(self, "keycode", Integer::New(xkbevt->keycode)); 53 SET(self, "keycode", Integer::New(xkbevt->keycode));
52 SET(self, "sym", Integer::New(xkbevt->sym)); 54 SET(self, "sym", Integer::New(xkbevt->sym));
53 break; 55 break;
54 56
55 case EVT_PROGM_COMPLETE: 57 case EVT_PROGM_COMPLETE:
56 case EVT_RDMAN_REDRAW: 58 case EVT_RDMAN_REDRAW:
57 case EVT_MONITOR_ADD: 59 case EVT_MONITOR_ADD:
58 case EVT_MONITOR_REMOVE: 60 case EVT_MONITOR_REMOVE:
59 case EVT_MONITOR_FREE: 61 case EVT_MONITOR_FREE:
68 _subject_add_event_observer(subject_t *subject, int type, 70 _subject_add_event_observer(subject_t *subject, int type,
69 Handle<Function> func) { 71 Handle<Function> func) {
70 observer_t *observer; 72 observer_t *observer;
71 xnjsmb_observer_data *data; 73 xnjsmb_observer_data *data;
72 Handle<Context> ctx; 74 Handle<Context> ctx;
73 75
74 data = new xnjsmb_observer_data; 76 data = new xnjsmb_observer_data;
75 if(data == NULL) 77 if(data == NULL)
76 return NULL; 78 return NULL;
77 data->func = Persistent<Function>::New(func); 79 data->func = Persistent<Function>::New(func);
78 ctx = Context::GetCurrent(); 80 ctx = Context::GetCurrent();
94 } 96 }
95 97
96 static Handle<Value> 98 static Handle<Value>
97 xnjsmb_event_tgt_getter(Handle<Object> self, event_t *evt, const char **err) { 99 xnjsmb_event_tgt_getter(Handle<Object> self, event_t *evt, const char **err) {
98 Persistent<Object> *hdl; 100 Persistent<Object> *hdl;
99 101
100 hdl = (Persistent<Object> *) 102 hdl = (Persistent<Object> *)
101 mb_prop_get(&((mb_obj_t *)evt->tgt->obj)->props, 103 mb_prop_get(&((mb_obj_t *)evt->tgt->obj)->props,
102 PROP_JSOBJ); 104 PROP_JSOBJ);
103 return Local<Object>::New(*hdl); 105 return Local<Object>::New(*hdl);
104 } 106 }
111 113
112 static Handle<Value> 114 static Handle<Value>
113 xnjsmb_event_cur_tgt_getter(Handle<Object> self, event_t *evt, 115 xnjsmb_event_cur_tgt_getter(Handle<Object> self, event_t *evt,
114 const char **err) { 116 const char **err) {
115 Persistent<Object> *hdl; 117 Persistent<Object> *hdl;
116 118
117 hdl = (Persistent<Object> *) 119 hdl = (Persistent<Object> *)
118 mb_prop_get(&((mb_obj_t *)evt->cur_tgt->obj)->props, 120 mb_prop_get(&((mb_obj_t *)evt->cur_tgt->obj)->props,
119 PROP_JSOBJ); 121 PROP_JSOBJ);
120 return Local<Object>::New(*hdl); 122 return Local<Object>::New(*hdl);
121 } 123 }
150 } 152 }
151 153
152 Handle<Value> 154 Handle<Value>
153 export_xnjsmb_auto_subject_new(subject_t *subject) { 155 export_xnjsmb_auto_subject_new(subject_t *subject) {
154 Handle<Value> val; 156 Handle<Value> val;
155 157
156 val = xnjsmb_auto_subject_new(subject); 158 val = xnjsmb_auto_subject_new(subject);
157 return val; 159 return val;
158 } 160 }
159 161
160 void 162 void