Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Reformat code to make it uniform

  • Loading branch information...
commit 07cf92cc277b606543c1cee9ffc4346aadc0da12 1 parent 655b0c0
Trond Norbye trondn authored

Showing 3 changed files with 139 additions and 111 deletions. Show diff stats Hide diff stats

  1. +16 0 Makefile
  2. +93 84 src/couchbase.cc
  3. +30 27 src/couchbase.h
16 Makefile
@@ -12,3 +12,19 @@ install:
12 12
13 13 dist:
14 14 @node-waf dist
  15 +
  16 +reformat:
  17 + @astyle --mode=c \
  18 + --quiet \
  19 + --style=1tbs \
  20 + --indent=spaces=4 \
  21 + --indent-namespaces \
  22 + --indent-col1-comments \
  23 + --max-instatement-indent=78 \
  24 + --pad-oper \
  25 + --pad-header \
  26 + --add-brackets \
  27 + --unpad-paren \
  28 + --align-pointer=name \
  29 + src/*.cc \
  30 + src/*.h
177 src/couchbase.cc
@@ -29,38 +29,45 @@ extern "C" {
29 29 static void configuration_callback(libcouchbase_t instance,
30 30 libcouchbase_configuration_t config)
31 31 {
32   - void *cookie = const_cast<void*> (libcouchbase_get_cookie(instance));
33   - Couchbase *me = reinterpret_cast<Couchbase*> (cookie);
  32 + void *cookie = const_cast<void *>(libcouchbase_get_cookie(instance));
  33 + Couchbase *me = reinterpret_cast<Couchbase *>(cookie);
34 34 me->onConnect(config);
35 35 }
36 36
37 37 static void error_callback(libcouchbase_t instance,
38   - libcouchbase_error_t err, const char *errinfo)
  38 + libcouchbase_error_t err, const char *errinfo)
39 39 {
40   - void *cookie = const_cast<void*> (libcouchbase_get_cookie(instance));
41   - Couchbase *me = reinterpret_cast<Couchbase*> (cookie);
  40 + void *cookie = const_cast<void *>(libcouchbase_get_cookie(instance));
  41 + Couchbase *me = reinterpret_cast<Couchbase *>(cookie);
42 42 me->errorCallback(err, errinfo);
43 43 }
44 44
45 45 static void get_callback(libcouchbase_t instance,
46   - const void *commandCookie, libcouchbase_error_t error,
47   - const void *key, libcouchbase_size_t nkey, const void *bytes,
48   - libcouchbase_size_t nbytes, libcouchbase_uint32_t flags,
49   - libcouchbase_cas_t cas)
  46 + const void *commandCookie,
  47 + libcouchbase_error_t error,
  48 + const void *key,
  49 + libcouchbase_size_t nkey,
  50 + const void *bytes,
  51 + libcouchbase_size_t nbytes,
  52 + libcouchbase_uint32_t flags,
  53 + libcouchbase_cas_t cas)
50 54 {
51   - void *cookie = const_cast<void*> (libcouchbase_get_cookie(instance));
52   - Couchbase *me = reinterpret_cast<Couchbase*> (cookie);
  55 + void *cookie = const_cast<void *>(libcouchbase_get_cookie(instance));
  56 + Couchbase *me = reinterpret_cast<Couchbase *>(cookie);
53 57 me->getCallback(commandCookie, error, key, nkey, bytes, nbytes, flags,
54   - cas);
  58 + cas);
55 59 }
56 60
57 61 static void storage_callback(libcouchbase_t instance,
58   - const void *commandCookie, libcouchbase_storage_t operation,
59   - libcouchbase_error_t error, const void *key,
60   - libcouchbase_size_t nkey, libcouchbase_cas_t cas)
  62 + const void *commandCookie,
  63 + libcouchbase_storage_t operation,
  64 + libcouchbase_error_t error,
  65 + const void *key,
  66 + libcouchbase_size_t nkey,
  67 + libcouchbase_cas_t cas)
61 68 {
62   - void *cookie = const_cast<void*> (libcouchbase_get_cookie(instance));
63   - Couchbase *me = reinterpret_cast<Couchbase*> (cookie);
  69 + void *cookie = const_cast<void *>(libcouchbase_get_cookie(instance));
  70 + Couchbase *me = reinterpret_cast<Couchbase *>(cookie);
64 71 me->storageCallback(commandCookie, operation, error, key, nkey, cas);
65 72 }
66 73
@@ -77,7 +84,7 @@ extern "C" {
77 84 Couchbase::Couchbase(libcouchbase_t inst) :
78 85 ObjectWrap(), instance(inst), lastError(LIBCOUCHBASE_SUCCESS)
79 86 {
80   - libcouchbase_set_cookie(instance, reinterpret_cast<void *> (this));
  87 + libcouchbase_set_cookie(instance, reinterpret_cast<void *>(this));
81 88 libcouchbase_set_error_callback(instance, error_callback);
82 89 libcouchbase_set_get_callback(instance, get_callback);
83 90 libcouchbase_set_storage_callback(instance, storage_callback);
@@ -128,7 +135,7 @@ void Couchbase::Init(v8::Handle<v8::Object> target)
128 135 target->Set(v8::String::NewSymbol("Couchbase"), s_ct->GetFunction());
129 136 }
130 137
131   -v8::Handle<v8::Value> Couchbase::On(const v8::Arguments& args)
  138 +v8::Handle<v8::Value> Couchbase::On(const v8::Arguments &args)
132 139 {
133 140 if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsFunction()) {
134 141 const char *msg = "Usage: cb.on('event', 'callback')";
@@ -137,12 +144,12 @@ v8::Handle<v8::Value> Couchbase::On(const v8::Arguments& args)
137 144
138 145 // @todo verify that the user specifies a valid monitor ;)
139 146 v8::HandleScope scope;
140   - Couchbase* me = ObjectWrap::Unwrap<Couchbase>(args.This());
  147 + Couchbase *me = ObjectWrap::Unwrap<Couchbase>(args.This());
141 148 v8::Handle<v8::Value> ret = me->on(args);
142 149 return scope.Close(ret);
143 150 }
144 151
145   -v8::Handle<v8::Value> Couchbase::on(const v8::Arguments& args)
  152 +v8::Handle<v8::Value> Couchbase::on(const v8::Arguments &args)
146 153 {
147 154 v8::HandleScope scope;
148 155 v8::Local<v8::String> s = args[0]->ToString();
@@ -163,7 +170,7 @@ v8::Handle<v8::Value> Couchbase::on(const v8::Arguments& args)
163 170 return scope.Close(v8::True());
164 171 }
165 172
166   -v8::Handle<v8::Value> Couchbase::New(const v8::Arguments& args)
  173 +v8::Handle<v8::Value> Couchbase::New(const v8::Arguments &args)
167 174 {
168 175 v8::HandleScope scope;
169 176
@@ -189,12 +196,12 @@ v8::Handle<v8::Value> Couchbase::New(const v8::Arguments& args)
189 196 // @todo handle NULL
190 197 const char *msg = "Illegal argument";
191 198 return v8::ThrowException(
192   - v8::Exception::Error(v8::String::New(msg)));
  199 + v8::Exception::Error(v8::String::New(msg)));
193 200 }
194 201 }
195 202
196 203 libcouchbase_t instance = libcouchbase_create(argv[0], argv[1], argv[2],
197   - argv[3], NULL);
  204 + argv[3], NULL);
198 205 for (int ii = 0; ii < 4; ++ii) {
199 206 delete[] argv[ii];
200 207 }
@@ -204,24 +211,24 @@ v8::Handle<v8::Value> Couchbase::New(const v8::Arguments& args)
204 211 return v8::ThrowException(v8::Exception::Error(v8::String::New(msg)));
205 212 }
206 213
207   - Couchbase* hw = new Couchbase(instance);
  214 + Couchbase *hw = new Couchbase(instance);
208 215 hw->Wrap(args.This());
209 216 return args.This();
210 217 }
211 218
212   -v8::Handle<v8::Value> Couchbase::GetVersion(const v8::Arguments&)
  219 +v8::Handle<v8::Value> Couchbase::GetVersion(const v8::Arguments &)
213 220 {
214 221 v8::HandleScope scope;
215 222
216 223 stringstream ss;
217 224 ss << "libcouchbase node.js v1.0.0 (v" << libcouchbase_get_version(NULL)
218   - << ")";
  225 + << ")";
219 226
220 227 v8::Local<v8::String> result = v8::String::New(ss.str().c_str());
221 228 return scope.Close(result);
222 229 }
223 230
224   -v8::Handle<v8::Value> Couchbase::SetTimeout(const v8::Arguments& args)
  231 +v8::Handle<v8::Value> Couchbase::SetTimeout(const v8::Arguments &args)
225 232 {
226 233 if (args.Length() != 1 || !args[0]->IsInt32()) {
227 234 const char *msg = "Illegal arguments";
@@ -229,14 +236,14 @@ v8::Handle<v8::Value> Couchbase::SetTimeout(const v8::Arguments& args)
229 236 }
230 237
231 238 v8::HandleScope scope;
232   - Couchbase* me = ObjectWrap::Unwrap<Couchbase>(args.This());
  239 + Couchbase *me = ObjectWrap::Unwrap<Couchbase>(args.This());
233 240 uint32_t timeout = args[0]->Int32Value();
234 241 libcouchbase_set_timeout(me->instance, timeout);
235 242
236 243 return v8::True();
237 244 }
238 245
239   -v8::Handle<v8::Value> Couchbase::GetTimeout(const v8::Arguments& args)
  246 +v8::Handle<v8::Value> Couchbase::GetTimeout(const v8::Arguments &args)
240 247 {
241 248 if (args.Length() != 0) {
242 249 const char *msg = "Illegal arguments";
@@ -244,11 +251,11 @@ v8::Handle<v8::Value> Couchbase::GetTimeout(const v8::Arguments& args)
244 251 }
245 252
246 253 v8::HandleScope scope;
247   - Couchbase* me = ObjectWrap::Unwrap<Couchbase>(args.This());
  254 + Couchbase *me = ObjectWrap::Unwrap<Couchbase>(args.This());
248 255 return scope.Close(v8::Integer::New(libcouchbase_get_timeout(me->instance)));
249 256 }
250 257
251   -v8::Handle<v8::Value> Couchbase::GetRestUri(const v8::Arguments& args)
  258 +v8::Handle<v8::Value> Couchbase::GetRestUri(const v8::Arguments &args)
252 259 {
253 260 if (args.Length() != 0) {
254 261 const char *msg = "Illegal arguments";
@@ -256,15 +263,15 @@ v8::Handle<v8::Value> Couchbase::GetRestUri(const v8::Arguments& args)
256 263 }
257 264
258 265 v8::HandleScope scope;
259   - Couchbase* me = ObjectWrap::Unwrap<Couchbase>(args.This());
  266 + Couchbase *me = ObjectWrap::Unwrap<Couchbase>(args.This());
260 267 stringstream ss;
261 268 ss << libcouchbase_get_host(me->instance) << ":" << libcouchbase_get_port(
262   - me->instance);
  269 + me->instance);
263 270
264 271 return scope.Close(v8::String::New(ss.str().c_str()));
265 272 }
266 273
267   -v8::Handle<v8::Value> Couchbase::SetSynchronous(const v8::Arguments& args)
  274 +v8::Handle<v8::Value> Couchbase::SetSynchronous(const v8::Arguments &args)
268 275 {
269 276 if (args.Length() != 1) {
270 277 const char *msg = "Illegal arguments";
@@ -273,7 +280,7 @@ v8::Handle<v8::Value> Couchbase::SetSynchronous(const v8::Arguments& args)
273 280
274 281 v8::HandleScope scope;
275 282
276   - Couchbase* me = ObjectWrap::Unwrap<Couchbase>(args.This());
  283 + Couchbase *me = ObjectWrap::Unwrap<Couchbase>(args.This());
277 284
278 285 libcouchbase_syncmode_t mode;
279 286 if (args[0]->BooleanValue()) {
@@ -286,7 +293,7 @@ v8::Handle<v8::Value> Couchbase::SetSynchronous(const v8::Arguments& args)
286 293 return v8::True();
287 294 }
288 295
289   -v8::Handle<v8::Value> Couchbase::IsSynchronous(const v8::Arguments& args)
  296 +v8::Handle<v8::Value> Couchbase::IsSynchronous(const v8::Arguments &args)
290 297 {
291 298 if (args.Length() != 0) {
292 299 const char *msg = "Illegal arguments";
@@ -294,7 +301,7 @@ v8::Handle<v8::Value> Couchbase::IsSynchronous(const v8::Arguments& args)
294 301 }
295 302
296 303 v8::HandleScope scope;
297   - Couchbase* me = ObjectWrap::Unwrap<Couchbase>(args.This());
  304 + Couchbase *me = ObjectWrap::Unwrap<Couchbase>(args.This());
298 305 if (libcouchbase_behavior_get_syncmode(me->instance)
299 306 == LIBCOUCHBASE_SYNCHRONOUS) {
300 307 return v8::True();
@@ -303,10 +310,10 @@ v8::Handle<v8::Value> Couchbase::IsSynchronous(const v8::Arguments& args)
303 310 return v8::False();
304 311 }
305 312
306   -v8::Handle<v8::Value> Couchbase::Connect(const v8::Arguments& args)
  313 +v8::Handle<v8::Value> Couchbase::Connect(const v8::Arguments &args)
307 314 {
308 315 v8::HandleScope scope;
309   - Couchbase* me = ObjectWrap::Unwrap<Couchbase>(args.This());
  316 + Couchbase *me = ObjectWrap::Unwrap<Couchbase>(args.This());
310 317
311 318 if (args.Length() != 0) {
312 319 const char *msg = "Illegal arguments";
@@ -321,7 +328,7 @@ v8::Handle<v8::Value> Couchbase::Connect(const v8::Arguments& args)
321 328 }
322 329 }
323 330
324   -v8::Handle<v8::Value> Couchbase::GetLastError(const v8::Arguments& args)
  331 +v8::Handle<v8::Value> Couchbase::GetLastError(const v8::Arguments &args)
325 332 {
326 333 if (args.Length() != 0) {
327 334 const char *msg = "Illegal arguments";
@@ -329,17 +336,18 @@ v8::Handle<v8::Value> Couchbase::GetLastError(const v8::Arguments& args)
329 336 }
330 337
331 338 v8::HandleScope scope;
332   - Couchbase* me = ObjectWrap::Unwrap<Couchbase>(args.This());
  339 + Couchbase *me = ObjectWrap::Unwrap<Couchbase>(args.This());
333 340 const char *msg = libcouchbase_strerror(me->instance, me->lastError);
334 341 return scope.Close(v8::String::New(msg));
335 342 }
336 343
337   -class CommandCallbackCookie {
  344 +class CommandCallbackCookie
  345 +{
338 346 public:
339 347 CommandCallbackCookie(const v8::Local<v8::Value>& func, int r = 1) : refcount(r) {
340 348 assert(func->IsFunction());
341 349 handler = v8::Persistent<v8::Function>::New(
342   - v8::Local<v8::Function>::Cast(func));
  350 + v8::Local<v8::Function>::Cast(func));
343 351 }
344 352
345 353 ~CommandCallbackCookie() {
@@ -356,7 +364,7 @@ class CommandCallbackCookie {
356 364 v8::Persistent<v8::Function> handler;
357 365 };
358 366
359   -v8::Handle<v8::Value> Couchbase::Get(const v8::Arguments& args)
  367 +v8::Handle<v8::Value> Couchbase::Get(const v8::Arguments &args)
360 368 {
361 369 if (args.Length() == 0) {
362 370 const char *msg = "Illegal arguments";
@@ -364,9 +372,9 @@ v8::Handle<v8::Value> Couchbase::Get(const v8::Arguments& args)
364 372 }
365 373
366 374 v8::HandleScope scope;
367   - Couchbase* me = ObjectWrap::Unwrap<Couchbase>(args.This());
  375 + Couchbase *me = ObjectWrap::Unwrap<Couchbase>(args.This());
368 376
369   - void* commandCookie = NULL;
  377 + void *commandCookie = NULL;
370 378 int offset = 0;
371 379 if (args[0]->IsFunction()) {
372 380 if (args.Length() == 1) {
@@ -374,7 +382,7 @@ v8::Handle<v8::Value> Couchbase::Get(const v8::Arguments& args)
374 382 return v8::ThrowException(v8::Exception::Error(v8::String::New(msg)));
375 383 }
376 384
377   - commandCookie = static_cast<void*>(new CommandCallbackCookie(args[0], args.Length() - 1));
  385 + commandCookie = static_cast<void *>(new CommandCallbackCookie(args[0], args.Length() - 1));
378 386 offset = 1;
379 387 }
380 388
@@ -393,12 +401,12 @@ v8::Handle<v8::Value> Couchbase::Get(const v8::Arguments& args)
393 401 // Clean up allocated memory!
394 402 const char *msg = "Illegal argument";
395 403 return v8::ThrowException(
396   - v8::Exception::Error(v8::String::New(msg)));
  404 + v8::Exception::Error(v8::String::New(msg)));
397 405 }
398 406 }
399 407
400 408 me->lastError = libcouchbase_mget(me->instance, commandCookie, tot,
401   - reinterpret_cast<const void * const *> (keys), lengths, NULL);
  409 + reinterpret_cast<const void * const *>(keys), lengths, NULL);
402 410
403 411 if (me->lastError == LIBCOUCHBASE_SUCCESS) {
404 412 return v8::True();
@@ -407,42 +415,42 @@ v8::Handle<v8::Value> Couchbase::Get(const v8::Arguments& args)
407 415 }
408 416 }
409 417
410   -v8::Handle<v8::Value> Couchbase::Set(const v8::Arguments& args)
  418 +v8::Handle<v8::Value> Couchbase::Set(const v8::Arguments &args)
411 419 {
412 420 v8::HandleScope scope;
413   - Couchbase* me = ObjectWrap::Unwrap<Couchbase>(args.This());
  421 + Couchbase *me = ObjectWrap::Unwrap<Couchbase>(args.This());
414 422 return me->store(args, LIBCOUCHBASE_SET);
415 423 }
416 424
417   -v8::Handle<v8::Value> Couchbase::Add(const v8::Arguments& args)
  425 +v8::Handle<v8::Value> Couchbase::Add(const v8::Arguments &args)
418 426 {
419 427 v8::HandleScope scope;
420   - Couchbase* me = ObjectWrap::Unwrap<Couchbase>(args.This());
  428 + Couchbase *me = ObjectWrap::Unwrap<Couchbase>(args.This());
421 429 return me->store(args, LIBCOUCHBASE_ADD);
422 430 }
423 431
424   -v8::Handle<v8::Value> Couchbase::Replace(const v8::Arguments& args)
  432 +v8::Handle<v8::Value> Couchbase::Replace(const v8::Arguments &args)
425 433 {
426 434 v8::HandleScope scope;
427   - Couchbase* me = ObjectWrap::Unwrap<Couchbase>(args.This());
  435 + Couchbase *me = ObjectWrap::Unwrap<Couchbase>(args.This());
428 436 return me->store(args, LIBCOUCHBASE_REPLACE);
429 437 }
430 438
431   -v8::Handle<v8::Value> Couchbase::Append(const v8::Arguments& args)
  439 +v8::Handle<v8::Value> Couchbase::Append(const v8::Arguments &args)
432 440 {
433 441 v8::HandleScope scope;
434   - Couchbase* me = ObjectWrap::Unwrap<Couchbase>(args.This());
  442 + Couchbase *me = ObjectWrap::Unwrap<Couchbase>(args.This());
435 443 return me->store(args, LIBCOUCHBASE_APPEND);
436 444 }
437 445
438   -v8::Handle<v8::Value> Couchbase::Prepend(const v8::Arguments& args)
  446 +v8::Handle<v8::Value> Couchbase::Prepend(const v8::Arguments &args)
439 447 {
440 448 v8::HandleScope scope;
441   - Couchbase* me = ObjectWrap::Unwrap<Couchbase>(args.This());
  449 + Couchbase *me = ObjectWrap::Unwrap<Couchbase>(args.This());
442 450 return me->store(args, LIBCOUCHBASE_PREPEND);
443 451 }
444 452
445   -v8::Handle<v8::Value> Couchbase::Wait(const v8::Arguments& args)
  453 +v8::Handle<v8::Value> Couchbase::Wait(const v8::Arguments &args)
446 454 {
447 455 if (args.Length() != 0) {
448 456 const char *msg = "Illegal arguments";
@@ -450,27 +458,24 @@ v8::Handle<v8::Value> Couchbase::Wait(const v8::Arguments& args)
450 458 }
451 459
452 460 v8::HandleScope scope;
453   - Couchbase* me = ObjectWrap::Unwrap<Couchbase>(args.This());
  461 + Couchbase *me = ObjectWrap::Unwrap<Couchbase>(args.This());
454 462 libcouchbase_wait(me->instance);
455 463 return v8::True();
456 464 }
457 465
458 466 struct CouchbaseObject {
459 467 CouchbaseObject() :
460   - commandCookie(NULL), key(NULL), nkey(0), data(NULL), ndata(0), flags(0), exptime(0), cas(0)
461   - {
  468 + commandCookie(NULL), key(NULL), nkey(0), data(NULL), ndata(0), flags(0), exptime(0), cas(0) {
462 469 // empty
463 470 }
464 471
465   - ~CouchbaseObject()
466   - {
  472 + ~CouchbaseObject() {
467 473 delete[] key;
468 474 delete[] data;
469 475 }
470 476
471 477 // @todo improve this parser
472   - bool parse(const v8::Arguments &args)
473   - {
  478 + bool parse(const v8::Arguments &args) {
474 479 if (args.Length() == 0) {
475 480 return false;
476 481 }
@@ -479,7 +484,7 @@ struct CouchbaseObject {
479 484 // First we might have a callback function...
480 485 if (args[0]->IsFunction()) {
481 486 ++idx;
482   - commandCookie = static_cast<void*>(new CommandCallbackCookie(args[0]));
  487 + commandCookie = static_cast<void *>(new CommandCallbackCookie(args[0]));
483 488 }
484 489
485 490 // but the next _must_ be the key
@@ -544,19 +549,19 @@ struct CouchbaseObject {
544 549 uint64_t cas;
545 550 };
546 551
547   -v8::Handle<v8::Value> Couchbase::store(const v8::Arguments& args,
548   - libcouchbase_storage_t operation)
  552 +v8::Handle<v8::Value> Couchbase::store(const v8::Arguments &args,
  553 + libcouchbase_storage_t operation)
549 554 {
550 555
551 556 CouchbaseObject obj;
552 557 if (!obj.parse(args)) {
553   - delete static_cast<CommandCallbackCookie*>(obj.commandCookie);
  558 + delete static_cast<CommandCallbackCookie *>(obj.commandCookie);
554 559 const char *msg = "Illegal arguments";
555 560 return v8::ThrowException(v8::Exception::Error(v8::String::New(msg)));
556 561 }
557 562
558 563 lastError = libcouchbase_store(instance, obj.commandCookie, operation, obj.key,
559   - obj.nkey, obj.data, obj.ndata, obj.flags, obj.exptime, obj.cas);
  564 + obj.nkey, obj.data, obj.ndata, obj.flags, obj.exptime, obj.cas);
560 565
561 566 if (lastError == LIBCOUCHBASE_SUCCESS) {
562 567 return v8::True();;
@@ -581,13 +586,17 @@ void Couchbase::errorCallback(libcouchbase_error_t err, const char *errinfo)
581 586 }
582 587
583 588 void Couchbase::getCallback(const void *commandCookie,
584   - libcouchbase_error_t error, const void *key, libcouchbase_size_t nkey,
585   - const void *bytes, libcouchbase_size_t nbytes,
586   - libcouchbase_uint32_t flags, libcouchbase_cas_t cas)
  589 + libcouchbase_error_t error,
  590 + const void *key,
  591 + libcouchbase_size_t nkey,
  592 + const void *bytes,
  593 + libcouchbase_size_t nbytes,
  594 + libcouchbase_uint32_t flags,
  595 + libcouchbase_cas_t cas)
587 596 {
588 597 lastError = error;
589 598
590   - CommandCallbackCookie *data = reinterpret_cast<CommandCallbackCookie*>(const_cast<void*>(commandCookie));
  599 + CommandCallbackCookie *data = reinterpret_cast<CommandCallbackCookie *>(const_cast<void *>(commandCookie));
591 600
592 601 EventMap::iterator iter = events.find("get");
593 602 if (data || (iter != events.end() && !iter->second.IsEmpty())) {
@@ -596,9 +605,9 @@ void Couchbase::getCallback(const void *commandCookie,
596 605 using namespace v8;
597 606 Local<Value> argv[5];
598 607 argv[0] = Local<Value>::New(True());
599   - argv[1] = Local<Value>::New(String::New((const char*) key, nkey));
  608 + argv[1] = Local<Value>::New(String::New((const char *) key, nkey));
600 609 argv[2] = Local<Value>::New(
601   - String::New((const char*) bytes, nbytes));
  610 + String::New((const char *) bytes, nbytes));
602 611 argv[3] = Local<Value>::New(Integer::NewFromUnsigned(flags));
603 612 argv[4] = Local<Value>::New(Number::New(cas));
604 613
@@ -612,9 +621,9 @@ void Couchbase::getCallback(const void *commandCookie,
612 621 using namespace v8;
613 622 Local<Value> argv[3];
614 623 argv[0] = Local<Value>::New(False());
615   - argv[1] = Local<Value>::New(String::New((const char*) key, nkey));
  624 + argv[1] = Local<Value>::New(String::New((const char *) key, nkey));
616 625 argv[2] = Local<Value>::New(
617   - String::New(libcouchbase_strerror(instance, error)));
  626 + String::New(libcouchbase_strerror(instance, error)));
618 627 if (data) {
619 628 data->handler->Call(Context::GetEntered()->Global(), 3, argv);
620 629 data->release();
@@ -633,20 +642,20 @@ void Couchbase::storageCallback(const void *commandCookie,
633 642 libcouchbase_cas_t cas)
634 643 {
635 644 lastError = error;
636   - CommandCallbackCookie *data = reinterpret_cast<CommandCallbackCookie*>(const_cast<void*>(commandCookie));
  645 + CommandCallbackCookie *data = reinterpret_cast<CommandCallbackCookie *>(const_cast<void *>(commandCookie));
637 646 EventMap::iterator iter = events.find("store");
638 647 if (data || (iter != events.end() && !iter->second.IsEmpty())) {
639 648 // Ignore everything if the user hasn't set up a get handler
640 649 using namespace v8;
641 650 Local<Value> argv[3];
642   - argv[1] = Local<Value>::New(String::New((const char*) key, nkey));
  651 + argv[1] = Local<Value>::New(String::New((const char *) key, nkey));
643 652 if (error == LIBCOUCHBASE_SUCCESS) {
644 653 argv[0] = Local<Value>::New(True());
645 654 argv[2] = Local<Value>::New(Number::New(cas));
646 655 } else {
647 656 argv[0] = Local<Value>::New(False());
648 657 argv[2] = Local<Value>::New(
649   - String::New(libcouchbase_strerror(instance, error)));
  658 + String::New(libcouchbase_strerror(instance, error)));
650 659 }
651 660 if (data) {
652 661 data->handler->Call(Context::GetEntered()->Global(), 3, argv);
57 src/couchbase.h
@@ -26,7 +26,8 @@
26 26
27 27 #include <libcouchbase/couchbase.h>
28 28
29   -class Couchbase: public node::ObjectWrap {
  29 +class Couchbase: public node::ObjectWrap
  30 +{
30 31 public:
31 32 Couchbase(libcouchbase_t inst);
32 33
@@ -35,28 +36,28 @@ class Couchbase: public node::ObjectWrap {
35 36 // Methods called directly from JavaScript
36 37
37 38 static void Init(v8::Handle<v8::Object> target);
38   - static v8::Handle<v8::Value> New(const v8::Arguments& args);
39   - static v8::Handle<v8::Value> GetVersion(const v8::Arguments&);
40   - static v8::Handle<v8::Value> SetTimeout(const v8::Arguments&);
41   - static v8::Handle<v8::Value> GetTimeout(const v8::Arguments&);
42   - static v8::Handle<v8::Value> GetRestUri(const v8::Arguments&);
43   - static v8::Handle<v8::Value> SetSynchronous(const v8::Arguments&);
44   - static v8::Handle<v8::Value> IsSynchronous(const v8::Arguments&);
45   - static v8::Handle<v8::Value> Connect(const v8::Arguments&);
46   - static v8::Handle<v8::Value> SetHandler(const v8::Arguments&);
47   - static v8::Handle<v8::Value> GetLastError(const v8::Arguments&);
48   - static v8::Handle<v8::Value> Get(const v8::Arguments&);
49   - static v8::Handle<v8::Value> Set(const v8::Arguments&);
50   - static v8::Handle<v8::Value> Add(const v8::Arguments&);
51   - static v8::Handle<v8::Value> Replace(const v8::Arguments&);
52   - static v8::Handle<v8::Value> Append(const v8::Arguments&);
53   - static v8::Handle<v8::Value> Prepend(const v8::Arguments&);
54   - static v8::Handle<v8::Value> Wait(const v8::Arguments&);
  39 + static v8::Handle<v8::Value> New(const v8::Arguments &args);
  40 + static v8::Handle<v8::Value> GetVersion(const v8::Arguments &);
  41 + static v8::Handle<v8::Value> SetTimeout(const v8::Arguments &);
  42 + static v8::Handle<v8::Value> GetTimeout(const v8::Arguments &);
  43 + static v8::Handle<v8::Value> GetRestUri(const v8::Arguments &);
  44 + static v8::Handle<v8::Value> SetSynchronous(const v8::Arguments &);
  45 + static v8::Handle<v8::Value> IsSynchronous(const v8::Arguments &);
  46 + static v8::Handle<v8::Value> Connect(const v8::Arguments &);
  47 + static v8::Handle<v8::Value> SetHandler(const v8::Arguments &);
  48 + static v8::Handle<v8::Value> GetLastError(const v8::Arguments &);
  49 + static v8::Handle<v8::Value> Get(const v8::Arguments &);
  50 + static v8::Handle<v8::Value> Set(const v8::Arguments &);
  51 + static v8::Handle<v8::Value> Add(const v8::Arguments &);
  52 + static v8::Handle<v8::Value> Replace(const v8::Arguments &);
  53 + static v8::Handle<v8::Value> Append(const v8::Arguments &);
  54 + static v8::Handle<v8::Value> Prepend(const v8::Arguments &);
  55 + static v8::Handle<v8::Value> Wait(const v8::Arguments &);
55 56
56 57
57 58 // Setting up the event emitter
58   - static v8::Handle<v8::Value> On(const v8::Arguments&);
59   - v8::Handle<v8::Value> on(const v8::Arguments&);
  59 + static v8::Handle<v8::Value> On(const v8::Arguments &);
  60 + v8::Handle<v8::Value> on(const v8::Arguments &);
60 61
61 62
62 63
@@ -67,15 +68,17 @@ class Couchbase: public node::ObjectWrap {
67 68
68 69 void errorCallback(libcouchbase_error_t err, const char *errinfo);
69 70 void getCallback(const void *commandCookie, libcouchbase_error_t error,
70   - const void *key, libcouchbase_size_t nkey, const void *bytes,
71   - libcouchbase_size_t nbytes, libcouchbase_uint32_t flags,
72   - libcouchbase_cas_t cas);
  71 + const void *key, libcouchbase_size_t nkey,
  72 + const void *bytes, libcouchbase_size_t nbytes,
  73 + libcouchbase_uint32_t flags, libcouchbase_cas_t cas);
73 74 void storageCallback(const void *commandCookie,
74   - libcouchbase_storage_t operation, libcouchbase_error_t error,
75   - const void *key, libcouchbase_size_t nkey, libcouchbase_cas_t cas);
  75 + libcouchbase_storage_t operation,
  76 + libcouchbase_error_t error,
  77 + const void *key, libcouchbase_size_t nkey,
  78 + libcouchbase_cas_t cas);
76 79
77   - v8::Handle<v8::Value> store(const v8::Arguments&,
78   - libcouchbase_storage_t operation);
  80 + v8::Handle<v8::Value> store(const v8::Arguments &,
  81 + libcouchbase_storage_t operation);
79 82
80 83 protected:
81 84 libcouchbase_t instance;

0 comments on commit 07cf92c

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