[v8-juice] r2247 committed - JSByteArray ZLIB support updates. Moved ZLIB enabled check closer to ...

1 view
Skip to first unread message

v8-j...@googlecode.com

unread,
Apr 14, 2012, 5:25:48 AM4/14/12
to v8-juice-...@googlegroups.com
Revision: 2247
Author: bionic...@gmail.com
Date: Sat Apr 14 02:25:37 2012
Log: JSByteArray ZLIB support updates. Moved ZLIB enabled check
closer to interface. More verbose error messages. Errors in zip now
produce exceptions rather than returning null.
http://code.google.com/p/v8-juice/source/detail?r=2247

Modified:
/convert/addons/bytearray/bytearray.cpp

=======================================
--- /convert/addons/bytearray/bytearray.cpp Sat Mar 24 10:26:03 2012
+++ /convert/addons/bytearray/bytearray.cpp Sat Apr 14 02:25:37 2012
@@ -389,6 +389,9 @@

v8::Handle<v8::Value> JSByteArray::gzip() const
{
+#if ! ByteArray_CONFIG_ENABLE_ZLIB
+ return Toss("zlib functionality was not compiled in.");
+#else
v8::HandleScope sc;
typedef cv::ClassCreator<JSByteArray> CW;
v8::Handle<v8::Object> jba =
@@ -401,15 +404,34 @@
return v8::ThrowException( msg.toError() );
}
int const rc = this->gzipTo( *ba );
- if( rc )
+ if( rc != Z_OK )
{
CW::Instance().DestroyObject( jba );
- return v8::Null();
+ cv::StringBuffer msg;
+ msg << "Gzip operation failed with code = " << rc
+ << " ("
+ << ( (rc == Z_STREAM_END) ? "Z_STREAM_END"
+ : (rc == Z_NEED_DICT) ? "Z_NEED_DICT"
+ : (rc == Z_ERRNO) ? "Z_ERRNO"
+ : (rc == Z_STREAM_ERROR) ? "Z_STREAM_ERROR"
+ : (rc == Z_DATA_ERROR) ? "Z_DATA_ERROR"
+ : (rc == Z_MEM_ERROR) ? "Z_MEM_ERROR"
+ : (rc == Z_BUF_ERROR) ? "Z_BUF_ERROR"
+ : (rc == Z_VERSION_ERROR) ? "Z_VERSION_ERROR"
+ : "UNKNOWN"
+ )
+ << ")";
+ return v8::ThrowException( msg.toError() );
+ //return v8::Null();
}
return sc.Close(jba);
+#endif
}
v8::Handle<v8::Value> JSByteArray::gunzip() const
{
+#if ! ByteArray_CONFIG_ENABLE_ZLIB
+ return Toss("zlib functionality was not compiled in.");
+#else
v8::HandleScope sc;
typedef cv::ClassCreator<JSByteArray> CW;
v8::Handle<v8::Object> jba =
@@ -422,12 +444,27 @@
return v8::ThrowException( msg.toError() );
}
int const rc = this->gunzipTo( *ba );
- if( rc )
- {
- CW::Instance().DestroyObject( jba );
- return v8::Null();
+ if( rc != Z_OK )
+ {
+ cv::StringBuffer msg;
+ msg << "Gunzip operation failed with code = " << rc
+ << " ("
+ << ( (rc == Z_STREAM_END) ? "Z_STREAM_END"
+ : (rc == Z_NEED_DICT) ? "Z_NEED_DICT"
+ : (rc == Z_ERRNO) ? "Z_ERRNO"
+ : (rc == Z_STREAM_ERROR) ? "Z_STREAM_ERROR"
+ : (rc == Z_DATA_ERROR) ? "Z_DATA_ERROR"
+ : (rc == Z_MEM_ERROR) ? "Z_MEM_ERROR"
+ : (rc == Z_BUF_ERROR) ? "Z_BUF_ERROR"
+ : (rc == Z_VERSION_ERROR) ? "Z_VERSION_ERROR"
+ : "UNKNOWN"
+ )
+ << ")";
+ return v8::ThrowException( msg.toError() );
+ //return v8::Null();
}
return sc.Close(jba);
+#endif
}


Reply all
Reply to author
Forward
0 new messages