summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1997-04-03 14:51:03 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1997-04-03 14:51:03 (GMT)
commitf73bab7f9665beacb0bd95c068129448a833fe2c (patch)
treeca81394fc60c73424bb2407f8e3b2fafbd5cba3d /Mac
parent377df98005862e587939b42f135bd653130e7913 (diff)
downloadcpython-f73bab7f9665beacb0bd95c068129448a833fe2c.zip
cpython-f73bab7f9665beacb0bd95c068129448a833fe2c.tar.gz
cpython-f73bab7f9665beacb0bd95c068129448a833fe2c.tar.bz2
Added an attribute string_id_to_buffer, which gives the offset you
have to add to the id() of a string to get the address of the data. This is a horrible and error-prone hack, but unfortunately it is one that is needed for playing audio and crearing pixmaps. Having the constant here is at least marginally better than the previous practice of having the constant 16 all over the place...
Diffstat (limited to 'Mac')
-rw-r--r--Mac/Modules/macosmodule.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/Mac/Modules/macosmodule.c b/Mac/Modules/macosmodule.c
index 89f986b..90be55d 100644
--- a/Mac/Modules/macosmodule.c
+++ b/Mac/Modules/macosmodule.c
@@ -637,5 +637,17 @@ MacOS_Init()
MacOS_Error = PyMac_GetOSErrException();
if (MacOS_Error == NULL || PyDict_SetItemString(d, "Error", MacOS_Error) != 0)
Py_FatalError("can't define MacOS.Error");
+ /*
+ ** This is a hack: the following constant added to the id() of a string
+ ** object gives you the address of the data. Unfortunately, it is needed for
+ ** some of the image and sound processing interfaces on the mac:-(
+ */
+ {
+ PyStringObject *p = 0;
+ long off = (long)&(p->ob_sval[0]);
+
+ if( PyDict_SetItemString(d, "string_id_to_buffer", Py_BuildValue("i", off)) != 0)
+ Py_FatalError("Can't define MacOS.string_id_to_buffer");
+ }
}