Skip to content

Commit

Permalink
use scope.Close
Browse files Browse the repository at this point in the history
  • Loading branch information
Atsushi Takayama committed May 29, 2010
1 parent b6843ec commit b5a8cff
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions src/tokyocabinet.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ inline Local<Array> tclisttoary (TCLIST *list) {
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
ary->Set(Integer::New(i), String::New(tclistval2(list, i))); ary->Set(Integer::New(i), String::New(tclistval2(list, i)));
} }
return ary; return scope.Close(ary);
} }


inline TCMAP* objtotcmap (const Handle<Object> obj) { inline TCMAP* objtotcmap (const Handle<Object> obj) {
Expand All @@ -81,9 +81,9 @@ inline TCMAP* objtotcmap (const Handle<Object> obj) {
} }


inline Local<Object> tcmaptoobj (TCMAP *map) { inline Local<Object> tcmaptoobj (TCMAP *map) {
HandleScope scope;
const char *kbuf, *vbuf; const char *kbuf, *vbuf;
int ksiz, vsiz; int ksiz, vsiz;
HandleScope scope;
Local<Object> obj = Object::New(); Local<Object> obj = Object::New();
tcmapiterinit(map); tcmapiterinit(map);
for (;;) { for (;;) {
Expand All @@ -92,7 +92,7 @@ inline Local<Object> tcmaptoobj (TCMAP *map) {
vbuf = static_cast<const char*>(tcmapiterval(kbuf, &vsiz)); vbuf = static_cast<const char*>(tcmapiterval(kbuf, &vsiz));
obj->Set(String::New(kbuf, ksiz), String::New(vbuf, vsiz)); obj->Set(String::New(kbuf, ksiz), String::New(vbuf, vsiz));
} }
return obj; return scope.Close(obj);
} }


/* sync method blueprint */ /* sync method blueprint */
Expand All @@ -103,7 +103,7 @@ inline Local<Object> tcmaptoobj (TCMAP *map) {
if (!name##Data::checkArgs(args)) { \ if (!name##Data::checkArgs(args)) { \
return THROW_BAD_ARGS; \ return THROW_BAD_ARGS; \
} \ } \
return Boolean::New(name##Data(args).run()); \ return scope.Close(Boolean::New(name##Data(args).run())); \
} \ } \


/* when there is an extra value to return */ /* when there is an extra value to return */
Expand All @@ -116,14 +116,13 @@ inline Local<Object> tcmaptoobj (TCMAP *map) {
} \ } \
name##Data data(args); \ name##Data data(args); \
data.run(); \ data.run(); \
return data.returnValue(); \ return scope.Close(data.returnValue()); \
} \ } \


/* async method blueprint */ /* async method blueprint */
#define DEFINE_ASYNC_FUNC(name) \ #define DEFINE_ASYNC_FUNC(name) \
static Handle<Value> \ static Handle<Value> \
name##Async (const Arguments& args) { \ name##Async (const Arguments& args) { \
HandleScope scope; \
if (!name##Data::checkArgs(args)) { \ if (!name##Data::checkArgs(args)) { \
return THROW_BAD_ARGS; \ return THROW_BAD_ARGS; \
} \ } \
Expand Down Expand Up @@ -341,7 +340,7 @@ class DBWrap : public ObjectWrap {
Handle<Value> Handle<Value>
returnValue () { returnValue () {
HandleScope scope; HandleScope scope;
return Integer::New(ecode); return scope.Close(Integer::New(ecode));
} }
}; };


Expand All @@ -362,7 +361,8 @@ class DBWrap : public ObjectWrap {


Handle<Value> Handle<Value>
returnValue () { returnValue () {
return String::New(msg); HandleScope scope;
return scope.Close(String::New(msg));
} }


static bool static bool
Expand Down Expand Up @@ -583,7 +583,8 @@ class DBWrap : public ObjectWrap {


Handle<Value> Handle<Value>
returnValue () { returnValue () {
return vbuf == NULL ? Null() : String::New(vbuf, vsiz); HandleScope scope;
return vbuf == NULL ? Null() : scope.Close(String::New(vbuf, vsiz));
} }
}; };


Expand Down Expand Up @@ -655,7 +656,8 @@ class DBWrap : public ObjectWrap {


Handle<Value> Handle<Value>
returnValue () { returnValue () {
return tclisttoary(list); HandleScope scope;
return scope.Close(tclisttoary(list));
} }
}; };


Expand Down Expand Up @@ -707,8 +709,8 @@ class DBWrap : public ObjectWrap {


Handle<Value> Handle<Value>
returnValue () { returnValue () {
HandleScope scope; // really needed? HandleScope scope;
return Number::New(vnum); return scope.Close(Number::New(vnum));
} }
}; };


Expand All @@ -733,8 +735,8 @@ class DBWrap : public ObjectWrap {


Handle<Value> Handle<Value>
returnValue () { returnValue () {
HandleScope scope; // really needed? HandleScope scope;
return Number::New(vsiz); return scope.Close(Number::New(vsiz));
} }
}; };


Expand Down Expand Up @@ -786,7 +788,7 @@ class DBWrap : public ObjectWrap {
Handle<Value> Handle<Value>
returnValue () { returnValue () {
HandleScope scope; HandleScope scope;
return tclisttoary(list); return scope.Close(tclisttoary(list));
} }
}; };


Expand Down Expand Up @@ -818,7 +820,8 @@ class DBWrap : public ObjectWrap {


Handle<Value> Handle<Value>
returnValue () { returnValue () {
return num == INT_MIN ? Null() : Integer::New(num); HandleScope scope;
return num == INT_MIN ? Null() : scope.Close(Integer::New(num));
} }
}; };


Expand Down Expand Up @@ -881,7 +884,8 @@ class DBWrap : public ObjectWrap {


Handle<Value> Handle<Value>
returnValue () { returnValue () {
return isnan(num) ? Null() : Number::New(num); HandleScope scope;
return isnan(num) ? Null() : scope.Close(Number::New(num));
} }
}; };


Expand Down Expand Up @@ -998,7 +1002,7 @@ class DBWrap : public ObjectWrap {
Handle<Value> Handle<Value>
returnValue () { returnValue () {
HandleScope scope; HandleScope scope;
return path == NULL ? Null() : String::New(path); return path == NULL ? Null() : scope.Close(String::New(path));
} }
}; };


Expand All @@ -1021,7 +1025,7 @@ class DBWrap : public ObjectWrap {
HandleScope scope; HandleScope scope;
// JavaScript integer cannot express uint64 // JavaScript integer cannot express uint64
// so this can't handle too large number // so this can't handle too large number
return Integer::New(rnum); return scope.Close(Integer::New(rnum));
} }
}; };


Expand All @@ -1044,7 +1048,7 @@ class DBWrap : public ObjectWrap {
HandleScope scope; HandleScope scope;
// JavaScript integer cannot express uint64 // JavaScript integer cannot express uint64
// so this can't handle too large number // so this can't handle too large number
return Integer::New(fsiz); return scope.Close(Integer::New(fsiz));
} }
}; };
}; };
Expand Down Expand Up @@ -1885,7 +1889,7 @@ const Persistent<FunctionTemplate> BDB::Tmpl =


class CUR : ObjectWrap { class CUR : ObjectWrap {
public: public:
CUR (TCBDB *bdb) : ObjectWrap () { CUR (TCBDB *bdb) {
cur = tcbdbcurnew(bdb); cur = tcbdbcurnew(bdb);
} }


Expand Down Expand Up @@ -1946,8 +1950,7 @@ class CUR : ObjectWrap {
static Handle<Value> static Handle<Value>
First (const Arguments& args) { First (const Arguments& args) {
HandleScope scope; HandleScope scope;
bool success = tcbdbcurfirst( bool success = tcbdbcurfirst(Backend(THIS));
Backend(THIS));
return Boolean::New(success); return Boolean::New(success);
} }


Expand Down

0 comments on commit b5a8cff

Please sign in to comment.