Mercurial > MadButterfly
comparison nodejs/image_ldr.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 | b346e4699e55 |
children |
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 /*! \file | 3 /*! \file |
2 * This file implements Javascript binding for img_ldr_t of MadButterfly. | 4 * This file implements Javascript binding for img_ldr_t of MadButterfly. |
3 */ | 5 */ |
4 #include <v8.h> | 6 #include <v8.h> |
5 | 7 |
44 img_id = *img_id_utf8; | 46 img_id = *img_id_utf8; |
45 img_ldr = (mb_img_ldr_t *)UNWRAP(self); | 47 img_ldr = (mb_img_ldr_t *)UNWRAP(self); |
46 | 48 |
47 img_data_obj = img_data_temp->NewInstance(); | 49 img_data_obj = img_data_temp->NewInstance(); |
48 ASSERT(img_data_obj); | 50 ASSERT(img_data_obj); |
49 | 51 |
50 img_data = MB_IMG_LDR_LOAD(img_ldr, img_id); | 52 img_data = MB_IMG_LDR_LOAD(img_ldr, img_id); |
51 if(img_data == NULL) | 53 if(img_data == NULL) |
52 THROW("Can not load an image"); | 54 THROW("Can not load an image"); |
53 WRAP(img_data_obj, img_data); | 55 WRAP(img_data_obj, img_data); |
54 | 56 |
55 scope.Close(img_data_obj); | 57 scope.Close(img_data_obj); |
56 | 58 |
57 return img_data_obj; | 59 return img_data_obj; |
58 } | 60 } |
59 | 61 |
60 /*! \brief Constructor function of img_ldr Javascript objects. | 62 /*! \brief Constructor function of img_ldr Javascript objects. |
61 */ | 63 */ |
64 HandleScope scope; | 66 HandleScope scope; |
65 int argc = args.Length(); | 67 int argc = args.Length(); |
66 Handle<Object> self = args.This(); | 68 Handle<Object> self = args.This(); |
67 char *path; | 69 char *path; |
68 mb_img_ldr_t *img_ldr; | 70 mb_img_ldr_t *img_ldr; |
69 | 71 |
70 if(argc != 1) | 72 if(argc != 1) |
71 THROW("Invalid number of arguments (!= 1)"); | 73 THROW("Invalid number of arguments (!= 1)"); |
72 if(!args[0]->IsString()) | 74 if(!args[0]->IsString()) |
73 THROW("Invalid argument type"); | 75 THROW("Invalid argument type"); |
74 | 76 |
75 String::Utf8Value pathutf8(args[0]->ToString()); | 77 String::Utf8Value pathutf8(args[0]->ToString()); |
76 path = *pathutf8; | 78 path = *pathutf8; |
77 | 79 |
78 img_ldr = simple_mb_img_ldr_new(path); | 80 img_ldr = simple_mb_img_ldr_new(path); |
79 if(img_ldr == NULL) | 81 if(img_ldr == NULL) |
90 HandleScope scope; | 92 HandleScope scope; |
91 int argc = args.Length(); | 93 int argc = args.Length(); |
92 Handle<Value> il_args[1]; | 94 Handle<Value> il_args[1]; |
93 Handle<Object> img_ldr; | 95 Handle<Object> img_ldr; |
94 Handle<Function> func; | 96 Handle<Function> func; |
95 | 97 |
96 if(argc != 1) | 98 if(argc != 1) |
97 THROW("Invalid number of arguments (!= 1)"); | 99 THROW("Invalid number of arguments (!= 1)"); |
98 if(!args[0]->IsString()) | 100 if(!args[0]->IsString()) |
99 THROW("Invalid argument type"); | 101 THROW("Invalid argument type"); |
100 | 102 |
125 | 127 |
126 /* Setup object template for img_data_t object for Javascript */ | 128 /* Setup object template for img_data_t object for Javascript */ |
127 _img_data_temp = ObjectTemplate::New(); | 129 _img_data_temp = ObjectTemplate::New(); |
128 _img_data_temp->SetInternalFieldCount(1); | 130 _img_data_temp->SetInternalFieldCount(1); |
129 img_data_temp = Persistent<ObjectTemplate>::New(_img_data_temp); | 131 img_data_temp = Persistent<ObjectTemplate>::New(_img_data_temp); |
130 | 132 |
131 /* Setup img_ldr class */ | 133 /* Setup img_ldr class */ |
132 img_ldr_temp = FunctionTemplate::New(xnjsmb_img_ldr); | 134 img_ldr_temp = FunctionTemplate::New(xnjsmb_img_ldr); |
133 img_ldr_temp->SetClassName(String::New("img_ldr")); | 135 img_ldr_temp->SetClassName(String::New("img_ldr")); |
134 ldr_inst_temp = img_ldr_temp->InstanceTemplate(); | 136 ldr_inst_temp = img_ldr_temp->InstanceTemplate(); |
135 ldr_inst_temp->SetInternalFieldCount(1); | 137 ldr_inst_temp->SetInternalFieldCount(1); |