Browse Source

More cleanup.

v1.x
King Koopa 12 years ago
committed by TJ Holowaychuk
parent
commit
81bc5d79a9
  1. 8
      src/PNG.h
  2. 57
      src/nan.h

8
src/PNG.h

@ -14,16 +14,13 @@
#define unlikely(expr) (expr) #define unlikely(expr) (expr)
#endif #endif
static void canvas_png_flush(png_structp png_ptr) { static void canvas_png_flush(png_structp png_ptr) {
// fprintf(stderr, "Pngtest_flush called");
/* Do nothing; fflush() is said to be just a waste of energy. */ /* Do nothing; fflush() is said to be just a waste of energy. */
(void) png_ptr; /* Stifle compiler warning */ (void) png_ptr; /* Stifle compiler warning */
} }
/* Converts native endian xRGB => RGBx bytes */ /* Converts native endian xRGB => RGBx bytes */
static void canvas_convert_data_to_bytes (png_structp png, png_row_infop row_info, png_bytep data) { static void canvas_convert_data_to_bytes(png_structp png, png_row_infop row_info, png_bytep data) {
unsigned int i; unsigned int i;
for (i = 0; i < row_info->rowbytes; i += 4) { for (i = 0; i < row_info->rowbytes; i += 4) {
@ -72,7 +69,6 @@ static cairo_status_t canvas_write_png(cairo_surface_t *surface, png_rw_ptr writ
uint8_t *data; uint8_t *data;
png_structp png; png_structp png;
png_infop info; png_infop info;
// png_infop end_info;
png_bytep *volatile rows = NULL; png_bytep *volatile rows = NULL;
png_color_16 white; png_color_16 white;
int png_color_type; int png_color_type;
@ -118,7 +114,7 @@ static cairo_status_t canvas_write_png(cairo_surface_t *surface, png_rw_ptr writ
if (unlikely(info == NULL)) { if (unlikely(info == NULL)) {
status = CAIRO_STATUS_NO_MEMORY; status = CAIRO_STATUS_NO_MEMORY;
png_destroy_write_struct(&png, &info); png_destroy_write_struct(&png, &info);
free(rows); free(rows);
return status; return status;
} }

57
src/nan.h

@ -3,24 +3,39 @@
* *
* Copyright (c) 2013 NAN contributors: * Copyright (c) 2013 NAN contributors:
* - Rod Vagg <https://github.com/rvagg> * - Rod Vagg <https://github.com/rvagg>
* - King Koopa <https://github.com/kkoopa> * - Benjamin Byholm <https://github.com/kkoopa>
* - Trevor Norris <https://github.com/trevnorris> * - Trevor Norris <https://github.com/trevnorris>
* *
* MIT +no-false-attribs License <https://github.com/rvagg/nan/blob/master/LICENSE> * MIT +no-false-attribs License <https://github.com/rvagg/nan/blob/master/LICENSE>
* *
* Version 0.2.0 (current Node unstable: 0.11.4) * Version 0.2.0-wip (current Node unstable: 0.11.4)
* *
* Changelog: * ChangeLog:
* * 0.2.0 .... TODO * * 0.2.0 .... work in progress
* - Added NAN_PROPERTY_GETTER, NAN_PROPERTY_SETTER, NAN_PROPERTY_ENUMERATOR,
* NAN_PROPERTY_DELETER, NAN_PROPERTY_QUERY
* - Extracted _NAN_METHOD_ARGS, _NAN_GETTER_ARGS, _NAN_SETTER_ARGS,
* _NAN_PROPERTY_GETTER_ARGS, _NAN_PROPERTY_SETTER_ARGS,
* _NAN_PROPERTY_ENUMERATOR_ARGS, _NAN_PROPERTY_DELETER_ARGS,
* _NAN_PROPERTY_QUERY_ARGS
* - Added NanGetInternalFieldPointer, NanSetInternalFieldPointer
* - Added NAN_WEAK_CALLBACK, NAN_WEAK_CALLBACK_OBJECT,
* NAN_WEAK_CALLBACK_DATA, NanMakeWeak
* - Renamed THROW_ERROR to _NAN_THROW_ERROR
* - Added NanNewBufferHandle(char*, size_t, node::smalloc::FreeCallback, void*)
* - Added NanBufferUse(char*, uint32_t)
* - Added NanNewContextHandle(v8::ExtensionConfiguration*,
* v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Value>)
* - Fixed broken NanCallback#GetFunction()
* *
* * 0.1.0 Jul 21 2013 * * 0.1.0 Jul 21 2013
* - Added `NAN_GETTER`, `NAN_SETTER` * - Added `NAN_GETTER`, `NAN_SETTER`
* - Added `NanThrowError` with single Local<Value> argument * - Added `NanThrowError` with single Local<Value> argument
* - Added `NanNewBufferHandle` with single uint32_t argument * - Added `NanNewBufferHandle` with single uint32_t argument
* - Added `NanHasInstance(Persistent<FunctionTemplate>&, Handle<Value>)` * - Added `NanHasInstance(Persistent<FunctionTemplate>&, Handle<Value>)`
* - Added `Local<Function> NanCallback#GetFunction()` * - Added `Local<Function> NanCallback#GetFunction()`
* - Added `NanCallback#Call(int, Local<Value>[])` * - Added `NanCallback#Call(int, Local<Value>[])`
* - Deprecated `NanCallback#Run(int, Local<Value>[])` in favour of Call * - Deprecated `NanCallback#Run(int, Local<Value>[])` in favour of Call
* *
* See https://github.com/rvagg/nan for the latest update to this file * See https://github.com/rvagg/nan for the latest update to this file
**********************************************************************************/ **********************************************************************************/
@ -302,7 +317,8 @@ static v8::Isolate* nan_isolate = v8::Isolate::GetCurrent();
size_t length, size_t length,
node::Buffer::free_callback callback, node::Buffer::free_callback callback,
void *hint) { void *hint) {
return v8::Local<v8::Object>::New(node::Buffer::New(data, length, callback, hint)->handle_); return v8::Local<v8::Object>::New(
node::Buffer::New(data, length, callback, hint)->handle_);
} }
static inline v8::Local<v8::Object> NanNewBufferHandle ( static inline v8::Local<v8::Object> NanNewBufferHandle (
@ -341,10 +357,13 @@ static v8::Isolate* nan_isolate = v8::Isolate::GetCurrent();
} }
static inline v8::Local<v8::Context> NanNewContextHandle( static inline v8::Local<v8::Context> NanNewContextHandle(
v8::ExtensionConfiguration* extensions = NULL, v8::ExtensionConfiguration* extensions = NULL
v8::Handle<v8::ObjectTemplate> g_template = v8::Handle<v8::ObjectTemplate>(), , v8::Handle<v8::ObjectTemplate> g_template =
v8::Handle<v8::Value> g_object = v8::Handle<v8::Value>()) { v8::Handle<v8::ObjectTemplate>()
v8::Persistent<v8::Context> ctx = v8::Context::New(extensions, g_template, g_object); , v8::Handle<v8::Value> g_object = v8::Handle<v8::Value>()
) {
v8::Persistent<v8::Context> ctx =
v8::Context::New(extensions, g_template, g_object);
v8::Local<v8::Context> lctx = v8::Local<v8::Context>::New(ctx); v8::Local<v8::Context> lctx = v8::Local<v8::Context>::New(ctx);
ctx.Dispose(); ctx.Dispose();
return lctx; return lctx;
@ -366,9 +385,9 @@ class NanCallback {
handle.Dispose(); handle.Dispose();
} }
v8::Local<v8::Function> GetFunction () { inline v8::Local<v8::Function> GetFunction () {
NanScope(); return NanPersistentToLocal(handle)->Get(NanSymbol("callback"))
return NanPersistentToLocal(handle).As<v8::Function>(); .As<v8::Function>();
} }
// deprecated // deprecated

Loading…
Cancel
Save