From: Guido van Rossum Date: Sun, 5 Feb 1995 17:01:24 +0000 (+0000) Subject: manually defined Resource() function X-Git-Tag: v1.2b3~48 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=81920f1b755d073eadbb9712708a02caacff998c;p=thirdparty%2FPython%2Fcpython.git manually defined Resource() function --- diff --git a/Mac/Modules/res/resedit.py b/Mac/Modules/res/resedit.py new file mode 100644 index 000000000000..5e54ef223afd --- /dev/null +++ b/Mac/Modules/res/resedit.py @@ -0,0 +1,25 @@ +resource_body = """ +char *buf; +int len; +Handle h; + +if (!PyArg_ParseTuple(_args, "s#", &buf, &len)) + return NULL; +h = NewHandle(len); +if ( h == NULL ) { + PyErr_NoMemory(); + return NULL; +} +HLock(h); +memcpy(*h, buf, len); +HUnlock(h); +return (PyObject *)ResObj_New(h); +""" + +f = ManualGenerator("Resource", resource_body) +f.docstring = lambda: """Convert a string to a resource object. + +The created resource object is actually just a handle. +Apply AddResource() to write it to a resource file. +""" +functions.append(f)