Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 81920f1

Browse files
committed
manually defined Resource() function
1 parent 3155923 commit 81920f1

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Mac/Modules/res/resedit.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
resource_body = """
2+
char *buf;
3+
int len;
4+
Handle h;
5+
6+
if (!PyArg_ParseTuple(_args, "s#", &buf, &len))
7+
return NULL;
8+
h = NewHandle(len);
9+
if ( h == NULL ) {
10+
PyErr_NoMemory();
11+
return NULL;
12+
}
13+
HLock(h);
14+
memcpy(*h, buf, len);
15+
HUnlock(h);
16+
return (PyObject *)ResObj_New(h);
17+
"""
18+
19+
f = ManualGenerator("Resource", resource_body)
20+
f.docstring = lambda: """Convert a string to a resource object.
21+
22+
The created resource object is actually just a handle.
23+
Apply AddResource() to write it to a resource file.
24+
"""
25+
functions.append(f)

0 commit comments

Comments
 (0)