summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-02-05 17:01:24 (GMT)
committerGuido van Rossum <guido@python.org>1995-02-05 17:01:24 (GMT)
commit81920f1b755d073eadbb9712708a02caacff998c (patch)
tree2d90efa3f3675132192efb52b1f7430cef712a50 /Mac
parent315592383e7fd02a73806b986e1038c7daf66777 (diff)
downloadcpython-81920f1b755d073eadbb9712708a02caacff998c.zip
cpython-81920f1b755d073eadbb9712708a02caacff998c.tar.gz
cpython-81920f1b755d073eadbb9712708a02caacff998c.tar.bz2
manually defined Resource() function
Diffstat (limited to 'Mac')
-rw-r--r--Mac/Modules/res/resedit.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/Mac/Modules/res/resedit.py b/Mac/Modules/res/resedit.py
new file mode 100644
index 0000000..5e54ef2
--- /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)