[prev in list] [next in list] [prev in thread] [next in thread]
List: pyamf-commits
Subject: [pyamf-commits] r1616 - pyamf/branches/gerard-cpyamf-225/cpyamf
From: commits () pyamf ! org (SVN commit logs for PyAMF)
Date: 2008-08-28 7:56:52
Message-ID: 20080828075653.0409124001 () mail ! collab ! eu
[Download RAW message or body]
Author: gerard
Date: 2008-08-28 09:56:51 +0200 (Thu, 28 Aug 2008)
New Revision: 1616
Modified:
pyamf/branches/gerard-cpyamf-225/cpyamf/util.c
Log:
cpyamf: Tests are good on Windows, Python versions 2.3-2.5.
Modified: pyamf/branches/gerard-cpyamf-225/cpyamf/util.c
===================================================================
--- pyamf/branches/gerard-cpyamf-225/cpyamf/util.c 2008-08-27 22:07:05 UTC (rev 1615)
+++ pyamf/branches/gerard-cpyamf-225/cpyamf/util.c 2008-08-28 07:56:51 UTC (rev 1616)
@@ -804,6 +804,14 @@
static PyObject *
BufferedByteStream_read_double(BufferedByteStream *self)
{
+#if (PY_VERSION_HEX < 0x02050000)
+ static const unsigned char NaN[8] = {0xff, 0xf8, 0, 0, 0, 0, 0, 0};
+ static const unsigned char NegInf[8] = {0xff, 0xf0, 0, 0, 0, 0, 0, 0};
+ static const unsigned char PosInf[8] = {0x7f, 0xf0, 0, 0, 0, 0, 0, 0};
+ static int pyfloat_tested = 0;
+ static int pyfloat_broken = 0;
+#endif
+
double x;
char *buf;
@@ -818,6 +826,64 @@
return NULL;
}
+#if (PY_VERSION_HEX < 0x02050000)
+ if (!pyfloat_tested)
+ {
+ double test;
+
+ test = _PyFloat_Unpack8(NaN, 0);
+
+ pyfloat_broken = memcmp(NaN, &test, 8);
+ pyfloat_tested = 1;
+ }
+
+ if (pyfloat_broken)
+ {
+ static unsigned int one = 1;
+ int big_endian = ((char*)&one)[0] != 1;
+ if (memcmp(NaN, buf, 8)==0)
+ {
+ if (big_endian)
+ {
+ static const unsigned char real_NaN[8] = {0x7f, 0xf8, 0, 0, 0, 0, 0, 0};
+ return PyFloat_FromDouble(*((double*)real_NaN));
+ }
+ else
+ {
+ static const unsigned char real_NaN[8] = {0, 0, 0, 0, 0, 0, 0xf8, 0xff};
+ return PyFloat_FromDouble(*((double*)real_NaN));
+ }
+ }
+ else if (memcmp(NegInf, buf, 8)==0)
+ {
+ if (big_endian)
+ {
+ static const unsigned char real_PosInf[8] = {0x7f, 0xf0, 0, 0, 0, 0, 0, 0};
+ return PyFloat_FromDouble(-*((double*)real_PosInf));
+ }
+ else
+ {
+ static const unsigned char real_PosInf[8] = {0, 0, 0, 0, 0, 0, 0xf0, 0x7f};
+ return PyFloat_FromDouble(-*((double*)real_PosInf));
+ }
+ }
+ else if (memcmp(PosInf, buf, 8)==0)
+ {
+ if (big_endian)
+ {
+ static const unsigned char real_PosInf[8] = {0x7f, 0xf0, 0, 0, 0, 0, 0, 0};
+ return PyFloat_FromDouble(*((double*)real_PosInf));
+ }
+ else
+ {
+ static const unsigned char real_PosInf[8] = {0, 0, 0, 0, 0, 0, 0xf0, 0x7f};
+ return PyFloat_FromDouble(*((double*)real_PosInf));
+ }
+ }
+ }
+
+#endif
+
switch(self->endian)
{
case ENDIAN_NATIVE:
@@ -831,6 +897,7 @@
x = _PyFloat_Unpack8((unsigned char *) buf, 1);
break;
}
+
return PyFloat_FromDouble(x);
}
@@ -1002,7 +1069,7 @@
return result;
}
static PySequenceMethods BufferedByteStream_sequencemethods = {
- BufferedByteStream___len__, /*sq_length*/
+ (int(*)(PyObject*))BufferedByteStream___len__, /*sq_length*/
0, /*sq_concat*/
0, /*sq_repeat*/
0, /*sq_item*/
@@ -1230,7 +1297,7 @@
* CAPI struct, with publicly accessible BufferedByteStream API
**/
static struct cPyAmf_BufferedByteStream_CAPI BufferedByteStream_CAPI = {
- &BufferedByteStream_init_,
+ (int (*)(PyObject*, PyObject*, int))&BufferedByteStream_init_,
&BufferedByteStreamType,
};
@@ -1259,7 +1326,8 @@
PyModule_AddObject(m,
"BufferedByteStream_CAPI",
PyCObject_FromVoidPtr(&BufferedByteStream_CAPI, NULL));
-
+ cPyAmf_BufferedByteStream = &BufferedByteStream_CAPI;
+
Py_INCREF(&BufferedByteStreamType);
PyModule_AddObject(m,
"BufferedByteStream",
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic