Commit 47713fa9 authored by Sjoerd Mullender's avatar Sjoerd Mullender

Fixed the last known bugs.

parent 9cddea65
...@@ -41,6 +41,11 @@ typedef struct { ...@@ -41,6 +41,11 @@ typedef struct {
object *ob_data; object *ob_data;
} clobject; } clobject;
#define CheckCompressor(self) if ((self)->ob_compressorHdl == NULL) { \
err_setstr(RuntimeError, "(de)compressor not active"); \
return NULL; \
}
extern typeobject Cltype; /* Really static, forward */ extern typeobject Cltype; /* Really static, forward */
#define is_clobject(v) ((v)->ob_type == &Cltype) #define is_clobject(v) ((v)->ob_type == &Cltype)
...@@ -62,6 +67,50 @@ cl_ErrorHandler(long errnum, const char *fmt, ...) ...@@ -62,6 +67,50 @@ cl_ErrorHandler(long errnum, const char *fmt, ...)
err_setstr(ClError, errbuf); err_setstr(ClError, errbuf);
} }
static object *
cl_CloseCompressor(self, args)
clobject *self;
object *args;
{
CheckCompressor(self);
if (!getnoarg(args))
return NULL;
if (clCloseCompressor(self->ob_compressorHdl) == FAILURE) {
if (!error_handler_called)
err_setstr(ClError, "CloseCompressor failed");
return NULL;
}
self->ob_compressorHdl = NULL;
INCREF(None);
return None;
}
static object *
cl_CloseDecompressor(self, args)
clobject *self;
object *args;
{
CheckCompressor(self);
if (!getnoarg(args))
return NULL;
if (clCloseDecompressor(self->ob_compressorHdl) == FAILURE) {
if (!error_handler_called)
err_setstr(ClError, "CloseDecompressor failed");
return NULL;
}
self->ob_compressorHdl = NULL;
INCREF(None);
return None;
}
static object * static object *
cl_Compress(self, args) cl_Compress(self, args)
clobject *self; clobject *self;
...@@ -70,6 +119,8 @@ cl_Compress(self, args) ...@@ -70,6 +119,8 @@ cl_Compress(self, args)
object *data; object *data;
long frameIndex, numberOfFrames, dataSize; long frameIndex, numberOfFrames, dataSize;
CheckCompressor(self);
if (!getargs(args, "(ii)", &frameIndex, &numberOfFrames)) if (!getargs(args, "(ii)", &frameIndex, &numberOfFrames))
return NULL; return NULL;
...@@ -104,6 +155,8 @@ cl_Decompress(self, args) ...@@ -104,6 +155,8 @@ cl_Decompress(self, args)
object *data; object *data;
long frameIndex, numberOfFrames; long frameIndex, numberOfFrames;
CheckCompressor(self);
if (!getargs(args, "(ii)", &frameIndex, &numberOfFrames)) if (!getargs(args, "(ii)", &frameIndex, &numberOfFrames))
return NULL; return NULL;
...@@ -133,6 +186,8 @@ cl_GetCompressorInfo(self, args) ...@@ -133,6 +186,8 @@ cl_GetCompressorInfo(self, args)
void *info; void *info;
object *infoObject, *res; object *infoObject, *res;
CheckCompressor(self);
if (!getnoarg(args)) if (!getnoarg(args))
return NULL; return NULL;
...@@ -153,6 +208,8 @@ cl_GetDefault(self, args) ...@@ -153,6 +208,8 @@ cl_GetDefault(self, args)
{ {
long initial, result; long initial, result;
CheckCompressor(self);
if (!getargs(args, "i", &initial)) if (!getargs(args, "i", &initial))
return NULL; return NULL;
...@@ -171,6 +228,8 @@ cl_GetMinMax(self, args) ...@@ -171,6 +228,8 @@ cl_GetMinMax(self, args)
{ {
long param, min, max; long param, min, max;
CheckCompressor(self);
if (!getargs(args, "i", &param)) if (!getargs(args, "i", &param))
return NULL; return NULL;
...@@ -190,6 +249,8 @@ cl_GetName(self, args) ...@@ -190,6 +249,8 @@ cl_GetName(self, args)
long descriptor; long descriptor;
char *name; char *name;
CheckCompressor(self);
if (!getargs(args, "i", &descriptor)) if (!getargs(args, "i", &descriptor))
return NULL; return NULL;
...@@ -217,6 +278,8 @@ doParams(self, args, func, modified) ...@@ -217,6 +278,8 @@ doParams(self, args, func, modified)
long length; long length;
int i; int i;
CheckCompressor(self);
if (!getargs(args, "O", &list)) if (!getargs(args, "O", &list))
return NULL; return NULL;
if (!is_listobject(list)) { if (!is_listobject(list)) {
...@@ -277,6 +340,8 @@ cl_QueryParams(self, args) ...@@ -277,6 +340,8 @@ cl_QueryParams(self, args)
object *list; object *list;
int i; int i;
CheckCompressor(self);
if (!getnoarg(args)) if (!getnoarg(args))
return NULL; return NULL;
...@@ -315,6 +380,7 @@ cl_QueryParams(self, args) ...@@ -315,6 +380,7 @@ cl_QueryParams(self, args)
} }
static struct methodlist compressor_methods[] = { static struct methodlist compressor_methods[] = {
{"CloseCompressor", cl_CloseCompressor},
{"Compress", cl_Compress}, {"Compress", cl_Compress},
{"GetCompressorInfo", cl_GetCompressorInfo}, {"GetCompressorInfo", cl_GetCompressorInfo},
{"GetDefault", cl_GetDefault}, {"GetDefault", cl_GetDefault},
...@@ -327,6 +393,7 @@ static struct methodlist compressor_methods[] = { ...@@ -327,6 +393,7 @@ static struct methodlist compressor_methods[] = {
}; };
static struct methodlist decompressor_methods[] = { static struct methodlist decompressor_methods[] = {
{"CloseDecompressor", cl_CloseDecompressor},
{"Decompress", cl_Decompress}, {"Decompress", cl_Decompress},
{"GetDefault", cl_GetDefault}, {"GetDefault", cl_GetDefault},
{"GetMinMax", cl_GetMinMax}, {"GetMinMax", cl_GetMinMax},
...@@ -536,8 +603,18 @@ cl_OpenDecompressor(self, args) ...@@ -536,8 +603,18 @@ cl_OpenDecompressor(self, args)
clobject *new; clobject *new;
object *res; object *res;
if (!getargs(args, "(s#OO)", &info, &infoSize, &GetDataCBPtr, if (!getargs(args, "((iiiiiiiiii)s#OO)",
&callbackID)) &compressionFormat.width,
&compressionFormat.height,
&compressionFormat.frameSize,
&compressionFormat.dataMaxSize,
&compressionFormat.originalFormat,
&compressionFormat.components,
&compressionFormat.bitsPerComponent,
&compressionFormat.frameRate,
&compressionFormat.numberOfFrames,
&compressionFormat.compressionScheme,
&info, &infoSize, &GetDataCBPtr, &callbackID))
return NULL; return NULL;
new = NEWOBJ(clobject, &Cltype); new = NEWOBJ(clobject, &Cltype);
...@@ -552,6 +629,7 @@ cl_OpenDecompressor(self, args) ...@@ -552,6 +629,7 @@ cl_OpenDecompressor(self, args)
error_handler_called = 0; error_handler_called = 0;
if (clOpenDecompressor(&compressionFormat, infoSize, info, GetData, if (clOpenDecompressor(&compressionFormat, infoSize, info, GetData,
(void *) new, &new->ob_compressorHdl) == FAILURE) { (void *) new, &new->ob_compressorHdl) == FAILURE) {
new->ob_compressorHdl = NULL; /* just in case... */
DECREF(new); DECREF(new);
if (!error_handler_called) if (!error_handler_called)
err_setstr(ClError, "opendecompressor failed"); err_setstr(ClError, "opendecompressor failed");
...@@ -566,21 +644,9 @@ cl_OpenDecompressor(self, args) ...@@ -566,21 +644,9 @@ cl_OpenDecompressor(self, args)
new->ob_callbackID = callbackID; new->ob_callbackID = callbackID;
XINCREF(new->ob_callbackID); XINCREF(new->ob_callbackID);
new->ob_data = NULL; new->ob_data = NULL;
new->ob_dataMaxSize = compressionFormat.dataMaxSize;
res = mkvalue("(O(iiiiiiiiii))", new, return new;
compressionFormat.width,
compressionFormat.height,
compressionFormat.frameSize,
compressionFormat.dataMaxSize,
compressionFormat.originalFormat,
compressionFormat.components,
compressionFormat.bitsPerComponent,
compressionFormat.frameRate,
compressionFormat.numberOfFrames,
compressionFormat.compressionScheme);
DECREF(new);
return res;
} }
static object * static object *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment