Browse Source

misc refactoring

v1.x
Tj Holowaychuk 14 years ago
parent
commit
f5e0017aba
  1. 16
      src/Image.cc
  2. 6
      src/Image.h

16
src/Image.cc

@ -48,7 +48,7 @@ Image::Inspect(const Arguments &args) {
Local<String> str = String::New("[Image");
if (img->loaded()) {
str = String::Concat(str, String::New(" "));
str = String::Concat(str, String::New(img->filename()));
str = String::Concat(str, String::New(img->filename));
}
str = String::Concat(str, String::New("]"));
return scope.Close(str);
@ -61,7 +61,7 @@ Image::Inspect(const Arguments &args) {
Handle<Value>
Image::GetSrc(Local<String>, const AccessorInfo &info) {
Image *img = ObjectWrap::Unwrap<Image>(info.This());
return String::New(img->filename());
return String::New(img->filename);
}
/*
@ -73,7 +73,9 @@ Image::SetSrc(Local<String>, Local<Value> val, const AccessorInfo &info) {
if (val->IsString()) {
String::AsciiValue src(val);
Image *img = ObjectWrap::Unwrap<Image>(info.This());
img->load(*src);
if (info.This()->Get(String::New("onload"))->IsFunction())
printf("function\n");
img->filename = *src;
}
}
@ -82,7 +84,7 @@ Image::SetSrc(Local<String>, Local<Value> val, const AccessorInfo &info) {
*/
Image::Image() {
_filename = NULL;
filename = NULL;
_surface = NULL;
}
@ -92,10 +94,4 @@ Image::Image() {
Image::~Image() {
cairo_surface_destroy(_surface);
}
void
Image::load(char *path) {
_filename = path;
// TODO: implement
}

6
src/Image.h

@ -14,19 +14,17 @@ using namespace v8;
class Image: public node::ObjectWrap {
public:
char *filename;
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 void SetSrc(Local<String> prop, Local<Value> val, const AccessorInfo &info);
inline cairo_surface_t *surface(){ return _surface; }
inline char *filename(){ return _filename; }
inline bool loaded(){ return _filename; }
void load(char *path);
inline bool loaded(){ return filename; }
Image();
private:
char *_filename;
cairo_surface_t *_surface;
~Image();
};

Loading…
Cancel
Save