]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
manually defined Resource() function
authorGuido van Rossum <guido@python.org>
Sun, 5 Feb 1995 17:01:24 +0000 (17:01 +0000)
committerGuido van Rossum <guido@python.org>
Sun, 5 Feb 1995 17:01:24 +0000 (17:01 +0000)
Mac/Modules/res/resedit.py [new file with mode: 0644]

diff --git a/Mac/Modules/res/resedit.py b/Mac/Modules/res/resedit.py
new file mode 100644 (file)
index 0000000..5e54ef2
--- /dev/null
@@ -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)