Mercurial > MadButterfly
annotate nodejs/image_ldr.cc @ 1388:669f79a4ecaf
Fix the parseUse which setup parameter to the wrong object.
author | wycc |
---|---|
date | Fri, 25 Mar 2011 03:54:45 +0800 |
parents | 586e50f82c1f |
children |
rev | line source |
---|---|
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
684
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:
684
diff
changeset
|
2 // vim: sw=4:ts=8:sts=4 |
639
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
3 /*! \file |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
4 * This file implements Javascript binding for img_ldr_t of MadButterfly. |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
5 */ |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
6 #include <v8.h> |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
7 |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
8 extern "C" { |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
9 #include "mb.h" |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
10 } |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
11 |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
12 #include "mbfly_njs.h" |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
13 |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
14 using namespace v8; |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
15 |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
16 #ifndef ASSERT |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
17 #define ASSERT(x) |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
18 #endif |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
19 |
684
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
643
diff
changeset
|
20 /*! \defgroup xnjsmb_img_ldr_js Javascript binding for image loader. |
b346e4699e55
Add more comment for JS binding
Thinker K.F. Li <thinker@branda.to>
parents:
643
diff
changeset
|
21 * \ingroup xnjsmb |
640
9016e7e70f7d
Group binding for image loader with Doxygen syntax
Thinker K.F. Li <thinker@branda.to>
parents:
639
diff
changeset
|
22 * |
9016e7e70f7d
Group binding for image loader with Doxygen syntax
Thinker K.F. Li <thinker@branda.to>
parents:
639
diff
changeset
|
23 * @{ |
9016e7e70f7d
Group binding for image loader with Doxygen syntax
Thinker K.F. Li <thinker@branda.to>
parents:
639
diff
changeset
|
24 */ |
9016e7e70f7d
Group binding for image loader with Doxygen syntax
Thinker K.F. Li <thinker@branda.to>
parents:
639
diff
changeset
|
25 |
639
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
26 static Persistent<ObjectTemplate> img_data_temp; |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
27 |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
28 /*! \brief load() method of img_ldr Javascript objects. |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
29 */ |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
30 static Handle<Value> |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
31 xnjsmb_img_ldr_load(const Arguments &args) { |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
32 HandleScope scope; |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
33 int argc = args.Length(); |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
34 Handle<Object> self = args.This(); |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
35 char *img_id; |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
36 mb_img_ldr_t *img_ldr; |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
37 mb_img_data_t *img_data; |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
38 Handle<Object> img_data_obj; |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
39 |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
40 if(argc != 1) |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
41 THROW("Invalid number of arguments (!= 1)"); |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
42 if(!args[0]->IsString()) |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
43 THROW("Invalid argument type"); |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
44 |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
45 String::Utf8Value img_id_utf8(args[0]->ToString()); |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
46 img_id = *img_id_utf8; |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
47 img_ldr = (mb_img_ldr_t *)UNWRAP(self); |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
48 |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
49 img_data_obj = img_data_temp->NewInstance(); |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
50 ASSERT(img_data_obj); |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
684
diff
changeset
|
51 |
639
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
52 img_data = MB_IMG_LDR_LOAD(img_ldr, img_id); |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
53 if(img_data == NULL) |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
54 THROW("Can not load an image"); |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
55 WRAP(img_data_obj, img_data); |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
56 |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
57 scope.Close(img_data_obj); |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
684
diff
changeset
|
58 |
639
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
59 return img_data_obj; |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
60 } |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
61 |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
62 /*! \brief Constructor function of img_ldr Javascript objects. |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
63 */ |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
64 static Handle<Value> |
643
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
65 xnjsmb_img_ldr(const Arguments &args) { |
639
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
66 HandleScope scope; |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
67 int argc = args.Length(); |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
68 Handle<Object> self = args.This(); |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
69 char *path; |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
70 mb_img_ldr_t *img_ldr; |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
684
diff
changeset
|
71 |
639
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
72 if(argc != 1) |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
73 THROW("Invalid number of arguments (!= 1)"); |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
74 if(!args[0]->IsString()) |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
75 THROW("Invalid argument type"); |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
684
diff
changeset
|
76 |
639
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
77 String::Utf8Value pathutf8(args[0]->ToString()); |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
78 path = *pathutf8; |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
79 |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
80 img_ldr = simple_mb_img_ldr_new(path); |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
81 if(img_ldr == NULL) |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
82 THROW("Can not create an image loader"); |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
83 WRAP(self, img_ldr); |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
84 |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
85 return Null(); |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
86 } |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
87 |
643
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
88 static Persistent<FunctionTemplate> xnjsmb_img_ldr_temp; |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
89 |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
90 static Handle<Value> |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
91 xnjsmb_img_ldr_new(const Arguments &args) { |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
92 HandleScope scope; |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
93 int argc = args.Length(); |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
94 Handle<Value> il_args[1]; |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
95 Handle<Object> img_ldr; |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
96 Handle<Function> func; |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
684
diff
changeset
|
97 |
643
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
98 if(argc != 1) |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
99 THROW("Invalid number of arguments (!= 1)"); |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
100 if(!args[0]->IsString()) |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
101 THROW("Invalid argument type"); |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
102 |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
103 il_args[0] = args[0]; |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
104 func = xnjsmb_img_ldr_temp->GetFunction(); |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
105 img_ldr = func->NewInstance(1, il_args); |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
106 |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
107 scope.Close(img_ldr); |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
108 return img_ldr; |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
109 } |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
110 |
640
9016e7e70f7d
Group binding for image loader with Doxygen syntax
Thinker K.F. Li <thinker@branda.to>
parents:
639
diff
changeset
|
111 /* @} */ |
9016e7e70f7d
Group binding for image loader with Doxygen syntax
Thinker K.F. Li <thinker@branda.to>
parents:
639
diff
changeset
|
112 |
639
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
113 /*! \brief Initialize image loader. |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
114 * |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
115 * This function is called by init() in mbfly_njs.cc when the module |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
116 * being loaded. |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
117 */ |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
118 void |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
119 xnjsmb_img_ldr_init_mb_rt_temp(Handle<Object> rt_temp) { |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
120 HandleScope scope; |
643
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
121 Handle<FunctionTemplate> img_ldr_temp; |
639
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
122 Handle<FunctionTemplate> img_ldr_new_temp; |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
123 Handle<ObjectTemplate> ldr_inst_temp; |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
124 Handle<ObjectTemplate> ldr_proto_temp; |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
125 Handle<FunctionTemplate> img_ldr_load_temp; |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
126 Handle<ObjectTemplate> _img_data_temp; |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
127 |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
128 /* Setup object template for img_data_t object for Javascript */ |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
129 _img_data_temp = ObjectTemplate::New(); |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
130 _img_data_temp->SetInternalFieldCount(1); |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
131 img_data_temp = Persistent<ObjectTemplate>::New(_img_data_temp); |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
684
diff
changeset
|
132 |
639
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
133 /* Setup img_ldr class */ |
643
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
134 img_ldr_temp = FunctionTemplate::New(xnjsmb_img_ldr); |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
135 img_ldr_temp->SetClassName(String::New("img_ldr")); |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
136 ldr_inst_temp = img_ldr_temp->InstanceTemplate(); |
639
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
137 ldr_inst_temp->SetInternalFieldCount(1); |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
138 |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
139 /* Set method load() for img_ldr */ |
643
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
140 ldr_proto_temp = img_ldr_temp->PrototypeTemplate(); |
639
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
141 img_ldr_load_temp = FunctionTemplate::New(xnjsmb_img_ldr_load); |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
142 SET(ldr_proto_temp, "load", img_ldr_load_temp); |
643
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
143 |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
144 xnjsmb_img_ldr_temp = Persistent<FunctionTemplate>::New(img_ldr_temp); |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
145 |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
146 /* Initialize img_ldr_new function */ |
a65720721c60
Fix issue of exception of internal field.
Thinker K.F. Li <thinker@branda.to>
parents:
640
diff
changeset
|
147 img_ldr_new_temp = FunctionTemplate::New(xnjsmb_img_ldr_new); |
639
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
148 SET(rt_temp, "img_ldr_new", img_ldr_new_temp->GetFunction()); |
dc32c1c140ae
First compilable image loader binding for Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
149 } |