Fixed so the Res.Resource() accepts either another resource, a string

or no argument (giving an empty resource).
This commit is contained in:
Jack Jansen 2002-12-05 23:26:38 +00:00
parent dd888a6cff
commit 5f61a05d7f
3 changed files with 129 additions and 66 deletions

View file

@ -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;