mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Fixed so the Res.Resource() accepts either another resource, a string
or no argument (giving an empty resource).
This commit is contained in:
parent
dd888a6cff
commit
5f61a05d7f
3 changed files with 129 additions and 66 deletions
|
@ -1,30 +1,30 @@
|
|||
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);
|
||||
_res = ResObj_New(h);
|
||||
return _res;
|
||||
"""
|
||||
|
||||
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.
|
||||
See also the Handle() docstring.
|
||||
"""
|
||||
functions.append(f)
|
||||
##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);
|
||||
##_res = ResObj_New(h);
|
||||
##return _res;
|
||||
##"""
|
||||
##
|
||||
##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.
|
||||
##See also the Handle() docstring.
|
||||
##"""
|
||||
##functions.append(f)
|
||||
|
||||
handle_body = """
|
||||
char *buf;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue