blob: bffec5fee9d6fa7e6eb329a84e5695818e28d627 [file] [log] [blame]
Guido van Rossum81920f11995-02-05 17:01:24 +00001resource_body = """
2char *buf;
3int len;
4Handle h;
5
6if (!PyArg_ParseTuple(_args, "s#", &buf, &len))
7 return NULL;
8h = NewHandle(len);
9if ( h == NULL ) {
10 PyErr_NoMemory();
11 return NULL;
12}
13HLock(h);
14memcpy(*h, buf, len);
15HUnlock(h);
16return (PyObject *)ResObj_New(h);
17"""
18
19f = ManualGenerator("Resource", resource_body)
20f.docstring = lambda: """Convert a string to a resource object.
21
22The created resource object is actually just a handle.
23Apply AddResource() to write it to a resource file.
24"""
25functions.append(f)
Jack Jansen1e054021995-06-18 20:20:27 +000026
27# Convert resources to other things.
28
29as_xxx_body = """
30return %sObj_New((%sHandle)_self->ob_itself);
31"""
32
33def genresconverter(longname, shortname):
34
35 f = ManualGenerator("as_%s"%longname, as_xxx_body%(shortname, longname))
36 docstring = "Return this resource/handle as a %s"%longname
37 f.docstring = lambda docstring=docstring: docstring
38 return f
39
40resmethods.append(genresconverter("Control", "Ctl"))
41resmethods.append(genresconverter("Menu", "Menu"))