Mercurial > MadButterfly
comparison nodejs/coord.cc @ 557:0ca8437a91fa Android_Skia
Implement Indexed Property interceptors
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sun, 06 Jun 2010 21:27:34 +0800 |
parents | |
children | ce7a35abcb0d |
comparison
equal
deleted
inserted
replaced
556:c9d23f7279a4 | 557:0ca8437a91fa |
---|---|
1 #include <stdio.h> | |
2 #include <v8.h> | |
3 | |
4 extern "C" { | |
5 #include "mb.h" | |
6 #include "mb_X_supp.h" | |
7 #include "mb_tools.h" | |
8 #include "X_supp_njs.h" | |
9 } | |
10 | |
11 using namespace v8; | |
12 | |
13 static Handle<Value> | |
14 xnjsmb_coord_get_index(uint32_t index, const AccessorInfo &info) { | |
15 HandleScope scope; | |
16 Handle<Object> self; | |
17 coord_t *coord; | |
18 co_aix v; | |
19 Handle<Value> exc; | |
20 | |
21 if(index < 0 || index >= 6) { | |
22 exc = Exception::Error(String::New("Invalid index")); | |
23 return ThrowException(exc); | |
24 } | |
25 | |
26 self = info.This(); | |
27 coord = (coord_t *)External::Unwrap(self->Get(String::New("_njs_coord"))); | |
28 v = coord_get_matrix(coord)[index]; | |
29 | |
30 return Number::New(v); | |
31 } | |
32 | |
33 static Handle<Value> | |
34 xnjsmb_coord_set_index(uint32_t index, Local<Value> value, | |
35 const AccessorInfo &info) { | |
36 | |
37 HandleScope scope; | |
38 Handle<Object> self; | |
39 redraw_man_t *rdman; | |
40 coord_t *coord; | |
41 co_aix v; | |
42 Handle<Value> exc; | |
43 | |
44 if(index < 0 || index >= 6) { | |
45 exc = Exception::Error(String::New("Invalid index")); | |
46 return ThrowException(exc); | |
47 } | |
48 if(!value->IsNumber()) { | |
49 exc = Exception::Error(String::New("Invalid value")); | |
50 return ThrowException(exc); | |
51 } | |
52 | |
53 self = info.This(); | |
54 coord = (coord_t *)External::Unwrap(self->Get(String::New("_njs_coord"))); | |
55 v = value->NumberValue(); | |
56 coord_get_matrix(coord)[index] = v; | |
57 | |
58 rdman = (redraw_man_t *) | |
59 External::Unwrap(self->Get(String::New("_njs_rdman"))); | |
60 rdman_coord_changed(rdman, coord); | |
61 | |
62 return value; | |
63 } |