Browse Source

Added Image#onerror accessors

v1.x
Tj Holowaychuk 14 years ago
parent
commit
892b0d4c2c
  1. 22
      src/Image.cc
  2. 3
      src/Image.h

22
src/Image.cc

@ -101,6 +101,28 @@ Image::SetOnload(Local<String>, Local<Value> val, const AccessorInfo &info) {
}
}
/*
* Get onerror callback.
*/
Handle<Value>
Image::GetOnerror(Local<String>, const AccessorInfo &info) {
Image *img = ObjectWrap::Unwrap<Image>(info.This());
return img->onerror;
}
/*
* Set onerror callback.
*/
void
Image::SetOnerror(Local<String>, Local<Value> val, const AccessorInfo &info) {
if (val->IsFunction()) {
Image *img = ObjectWrap::Unwrap<Image>(info.This());
img->onerror = Persistent<Function>::New(Handle<Function>::Cast(val));
}
}
/*
* Initialize a new Image.
*/

3
src/Image.h

@ -16,13 +16,16 @@ class Image: public node::ObjectWrap {
public:
char *filename;
Persistent<Function> onload;
Persistent<Function> onerror;
static void Initialize(Handle<Object> target);
static Handle<Value> New(const Arguments &args);
static Handle<Value> Inspect(const Arguments &args);
static Handle<Value> GetSrc(Local<String> prop, const AccessorInfo &info);
static Handle<Value> GetOnload(Local<String> prop, const AccessorInfo &info);
static Handle<Value> GetOnerror(Local<String> prop, const AccessorInfo &info);
static void SetSrc(Local<String> prop, Local<Value> val, const AccessorInfo &info);
static void SetOnload(Local<String> prop, Local<Value> val, const AccessorInfo &info);
static void SetOnerror(Local<String> prop, Local<Value> val, const AccessorInfo &info);
inline cairo_surface_t *surface(){ return _surface; }
cairo_status_t loadSurface();
void loaded();

Loading…
Cancel
Save