Mercurial > MadButterfly
comparison nodejs/mbfly_njs.cc @ 559:ef078d7c57b4 Android_Skia
Use internal field to store njs_runtime_t object.
Instead of using named property to keep reference of njs_runtime_t
object, the internal field of v8 object is used.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Mon, 07 Jun 2010 11:42:45 +0800 |
parents | d61133da2845 |
children | a3c13c2a4792 |
comparison
equal
deleted
inserted
replaced
558:d61133da2845 | 559:ef078d7c57b4 |
---|---|
2 #include <v8.h> | 2 #include <v8.h> |
3 | 3 |
4 extern "C" { | 4 extern "C" { |
5 #include "X_supp_njs.h" | 5 #include "X_supp_njs.h" |
6 } | 6 } |
7 | |
8 #include "mbfly_njs.h" | |
7 | 9 |
8 using namespace v8; | 10 using namespace v8; |
9 | 11 |
10 /*! \defgroup njs_template_cb Callback functions for v8 engine and nodejs. | 12 /*! \defgroup njs_template_cb Callback functions for v8 engine and nodejs. |
11 * | 13 * |
45 width = args[1]->Int32Value(); | 47 width = args[1]->Int32Value(); |
46 height = args[2]->Int32Value(); | 48 height = args[2]->Int32Value(); |
47 rt = X_njs_MB_new(display_name, width, height); | 49 rt = X_njs_MB_new(display_name, width, height); |
48 | 50 |
49 self = args.This(); | 51 self = args.This(); |
50 self->Set(String::New("_njs_rt"), External::Wrap(rt)); | 52 WRAP(self, rt); |
51 | 53 |
52 X_njs_MB_init_handle_connection(rt); | 54 X_njs_MB_init_handle_connection(rt); |
53 | 55 |
54 return Null(); | 56 return Null(); |
55 } | 57 } |
57 static Handle<Value> | 59 static Handle<Value> |
58 xnjsmb_handle_connection(const Arguments &args) { | 60 xnjsmb_handle_connection(const Arguments &args) { |
59 } | 61 } |
60 | 62 |
61 /* @} */ | 63 /* @} */ |
64 | |
65 redraw_man_t * | |
66 xnjsmb_rt_rdman(Handle<Object> mbrt) { | |
67 HandleScope scope; | |
68 njs_runtime_t *rt; | |
69 redraw_man_t *rdman; | |
70 | |
71 rt = (njs_runtime_t *)UNWRAP(mbrt); | |
72 rdman = X_njs_MB_rdman(rt); | |
73 | |
74 return rdman; | |
75 } | |
62 | 76 |
63 Handle<Value> | 77 Handle<Value> |
64 hello_func(const Arguments &args) { | 78 hello_func(const Arguments &args) { |
65 HandleScope scope; | 79 HandleScope scope; |
66 | 80 |
75 func = FunctionTemplate::New(hello_func); | 89 func = FunctionTemplate::New(hello_func); |
76 target->Set(String::New("Hello"), func->GetFunction()); | 90 target->Set(String::New("Hello"), func->GetFunction()); |
77 | 91 |
78 func = FunctionTemplate::New(xnjsmb_new); | 92 func = FunctionTemplate::New(xnjsmb_new); |
79 target->Set(String::New("mb_rt"), func->GetFunction()); | 93 target->Set(String::New("mb_rt"), func->GetFunction()); |
94 func->PrototypeTemplate()->SetInternalFieldCount(1); | |
80 } | 95 } |