mirror of https://github.com/python/cpython
manually defined Resource() function
This commit is contained in:
parent
315592383e
commit
81920f1b75
|
@ -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)
|
Loading…
Reference in New Issue