Skip to content
This repository
Browse code

Hopefully added missing bits for 0.6-compability

  • Loading branch information...
commit 285db5e4fdc6b24beae48bb7a8a47f52517751a2 1 parent bd15b6a
David Björklund authored
8  lib/snappy.js
@@ -23,7 +23,13 @@
23 23
 /*
24 24
  * The c++-module.
25 25
  */
26  
-var binding = require('../build/default/binding');
  26
+var binding;
  27
+
  28
+try {
  29
+  binding = require('../build/default/binding');
  30
+} catch(e) {
  31
+  binding = require('../build/Release/binding');
  32
+}
27 33
 
28 34
 /*
29 35
  * Parsers, used to parse a buffer when decompressing.
12  src/binding.cc
@@ -59,7 +59,7 @@ inline void Base::CallErrCallback(const v8::Handle<v8::Function>& callback,
59 59
 
60 60
 // CompressUncompressBase
61 61
 // PROTECTED
62  
-async_rtn CompressUncompressBase::After(eio_req *req) {
  62
+async_rtn CompressUncompressBase::After(uv_work_t *req) {
63 63
   v8::HandleScope scope;
64 64
   SnappyRequest<std::string>* snappy_req =
65 65
     static_cast<SnappyRequest<std::string>*>(req->data);
@@ -105,7 +105,7 @@ v8::Handle<v8::Value> CompressBinding::Sync(const v8::Arguments& args) {
105 105
 }
106 106
 
107 107
 // PRIVATE
108  
-async_rtn CompressBinding::AsyncOperation(eio_req *req) {
  108
+async_rtn CompressBinding::AsyncOperation(uv_work_t *req) {
109 109
   SnappyRequest<std::string>* snappy_req =
110 110
     static_cast<SnappyRequest<std::string>*>(req->data);
111 111
   std::string dst;
@@ -140,7 +140,7 @@ v8::Handle<v8::Value> UncompressBinding::Sync(const v8::Arguments& args) {
140 140
 }
141 141
 
142 142
 // PRIVATE
143  
-async_rtn UncompressBinding::AsyncOperation(eio_req *req) {
  143
+async_rtn UncompressBinding::AsyncOperation(uv_work_t *req) {
144 144
   SnappyRequest<std::string>* snappy_req =
145 145
     static_cast<SnappyRequest<std::string>*>(req->data);
146 146
   std::string dst;
@@ -178,7 +178,7 @@ IsValidCompressedBinding::Sync(const v8::Arguments& args) {
178 178
 }
179 179
 
180 180
 // PRIVATE
181  
-async_rtn IsValidCompressedBinding::After(eio_req *req) {
  181
+async_rtn IsValidCompressedBinding::After(uv_work_t *req) {
182 182
   v8::HandleScope scope;
183 183
   SnappyRequest<bool>* snappy_req =
184 184
     static_cast<SnappyRequest<bool>*>(req->data);
@@ -189,12 +189,12 @@ async_rtn IsValidCompressedBinding::After(eio_req *req) {
189 189
   RETURN_ASYNC_AFTER;
190 190
 }
191 191
 
192  
-int IsValidCompressedBinding::AsyncOperation(eio_req *req) {
  192
+async_rtn IsValidCompressedBinding::AsyncOperation(uv_work_t *req) {
193 193
   SnappyRequest<bool>* snappy_req = (SnappyRequest<bool>*) req->data;
194 194
   std::string* input = &snappy_req->input;
195 195
   snappy_req->result =
196 196
     snappy::IsValidCompressedBuffer(input->data(), input->length());
197  
-  return 0;
  197
+  RETURN_ASYNC;
198 198
 }
199 199
 
200 200
 inline void
10  src/binding.h
@@ -71,7 +71,7 @@ class Base {
71 71
 class CompressUncompressBase : protected Base {
72 72
  protected:
73 73
   /* Method run after the async operation */
74  
-  static async_rtn After(eio_req*);
  74
+  static async_rtn After(uv_work_t*);
75 75
   /* 
76 76
    * Call the specifed callback when everything has gone well.
77 77
    * Use null as first argument and use the specifed string (converted to a
@@ -94,7 +94,7 @@ class CompressBinding : CompressUncompressBase {
94 94
 
95 95
  private:
96 96
 
97  
-  static async_rtn AsyncOperation(eio_req*);
  97
+  static async_rtn AsyncOperation(uv_work_t*);
98 98
 };
99 99
 
100 100
 /* 
@@ -109,7 +109,7 @@ class UncompressBinding : CompressUncompressBase {
109 109
   static v8::Handle<v8::Value> Sync(const v8::Arguments&);
110 110
 
111 111
  private:
112  
-  static async_rtn AsyncOperation(eio_req*);
  112
+  static async_rtn AsyncOperation(uv_work_t*);
113 113
 };
114 114
 
115 115
 /* 
@@ -124,8 +124,8 @@ class IsValidCompressedBinding : protected Base {
124 124
   static v8::Handle<v8::Value> Sync(const v8::Arguments&);
125 125
 
126 126
  private:
127  
-  static async_rtn After(eio_req*);
128  
-  static async_rtn AsyncOperation(eio_req*);
  127
+  static async_rtn After(uv_work_t*);
  128
+  static async_rtn AsyncOperation(uv_work_t*);
129 129
   /* 
130 130
    * Call the specifed callback when everything has gone well.
131 131
    * Use null as first argument and use the specifed bool (converted to a

0 notes on commit 285db5e

Please sign in to comment.
Something went wrong with that request. Please try again.