Browse Source

Fixed more HandleScopes

v1.x
Tj Holowaychuk 14 years ago
parent
commit
780148ebcf
  1. 41
      src/CanvasRenderingContext2d.cc

41
src/CanvasRenderingContext2d.cc

@ -910,8 +910,9 @@ Context2d::SetAntiAlias(Local<String> prop, Local<Value> val, const AccessorInfo
Handle<Value> Handle<Value>
Context2d::GetMiterLimit(Local<String> prop, const AccessorInfo &info) { Context2d::GetMiterLimit(Local<String> prop, const AccessorInfo &info) {
HandleScope scope;
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This()); Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
return Number::New(cairo_get_miter_limit(context->context())); return scope.Close(Number::New(cairo_get_miter_limit(context->context())));
} }
/* /*
@ -933,8 +934,9 @@ Context2d::SetMiterLimit(Local<String> prop, Local<Value> val, const AccessorInf
Handle<Value> Handle<Value>
Context2d::GetLineWidth(Local<String> prop, const AccessorInfo &info) { Context2d::GetLineWidth(Local<String> prop, const AccessorInfo &info) {
HandleScope scope;
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This()); Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
return Number::New(cairo_get_line_width(context->context())); return scope.Close(Number::New(cairo_get_line_width(context->context())));
} }
/* /*
@ -956,15 +958,15 @@ Context2d::SetLineWidth(Local<String> prop, Local<Value> val, const AccessorInfo
Handle<Value> Handle<Value>
Context2d::GetLineJoin(Local<String> prop, const AccessorInfo &info) { Context2d::GetLineJoin(Local<String> prop, const AccessorInfo &info) {
HandleScope scope;
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This()); Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
const char *join;
switch (cairo_get_line_join(context->context())) { switch (cairo_get_line_join(context->context())) {
case CAIRO_LINE_JOIN_BEVEL: case CAIRO_LINE_JOIN_BEVEL: join = "bevel"; break;
return String::NewSymbol("bevel"); case CAIRO_LINE_JOIN_ROUND: join = "round"; break;
case CAIRO_LINE_JOIN_ROUND: default: join = "miter";
return String::NewSymbol("round");
default:
return String::NewSymbol("miter");
} }
return scope.Close(String::NewSymbol(join));
} }
/* /*
@ -991,15 +993,15 @@ Context2d::SetLineJoin(Local<String> prop, Local<Value> val, const AccessorInfo
Handle<Value> Handle<Value>
Context2d::GetLineCap(Local<String> prop, const AccessorInfo &info) { Context2d::GetLineCap(Local<String> prop, const AccessorInfo &info) {
HandleScope scope;
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This()); Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
const char *cap;
switch (cairo_get_line_cap(context->context())) { switch (cairo_get_line_cap(context->context())) {
case CAIRO_LINE_CAP_ROUND: case CAIRO_LINE_CAP_ROUND: cap = "round"; break;
return String::NewSymbol("round"); case CAIRO_LINE_CAP_SQUARE: cap = "square"; break;
case CAIRO_LINE_CAP_SQUARE: default: cap = "butt";
return String::NewSymbol("square");
default:
return String::NewSymbol("butt");
} }
return scope.Close(String::NewSymbol(cap));
} }
/* /*
@ -1032,7 +1034,7 @@ Context2d::IsPointInPath(const Arguments &args) {
cairo_t *ctx = context->context(); cairo_t *ctx = context->context();
double x = args[0]->NumberValue() double x = args[0]->NumberValue()
, y = args[1]->NumberValue(); , y = args[1]->NumberValue();
return Boolean::New(cairo_in_fill(ctx, x, y) || cairo_in_stroke(ctx, x, y)); return scope.Close(Boolean::New(cairo_in_fill(ctx, x, y) || cairo_in_stroke(ctx, x, y)));
} }
return False(); return False();
} }
@ -1094,10 +1096,11 @@ Context2d::SetShadowColor(Local<String> prop, Local<Value> val, const AccessorIn
Handle<Value> Handle<Value>
Context2d::GetShadowColor(Local<String> prop, const AccessorInfo &info) { Context2d::GetShadowColor(Local<String> prop, const AccessorInfo &info) {
HandleScope scope;
char buf[64]; char buf[64];
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This()); Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
rgba_to_string(context->state->shadow, buf); rgba_to_string(context->state->shadow, buf);
return String::New(buf); return scope.Close(String::New(buf));
} }
/* /*
@ -1124,10 +1127,11 @@ Context2d::SetFillColor(const Arguments &args) {
Handle<Value> Handle<Value>
Context2d::GetFillColor(Local<String> prop, const AccessorInfo &info) { Context2d::GetFillColor(Local<String> prop, const AccessorInfo &info) {
HandleScope scope;
char buf[64]; char buf[64];
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This()); Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
rgba_to_string(context->state->fill, buf); rgba_to_string(context->state->fill, buf);
return String::New(buf); return scope.Close(String::New(buf));
} }
/* /*
@ -1154,10 +1158,11 @@ Context2d::SetStrokeColor(const Arguments &args) {
Handle<Value> Handle<Value>
Context2d::GetStrokeColor(Local<String> prop, const AccessorInfo &info) { Context2d::GetStrokeColor(Local<String> prop, const AccessorInfo &info) {
HandleScope scope;
char buf[64]; char buf[64];
Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This()); Context2d *context = ObjectWrap::Unwrap<Context2d>(info.This());
rgba_to_string(context->state->stroke, buf); rgba_to_string(context->state->stroke, buf);
return String::New(buf); return scope.Close(String::New(buf));
} }
/* /*

Loading…
Cancel
Save