Oops -- Lib/Test should be Lib/test, of course!
[python/dscho.git] / Mac / Modules / res / resedit.py
blobbffec5fee9d6fa7e6eb329a84e5695818e28d627
1 resource_body = """
2 char *buf;
3 int len;
4 Handle h;
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;
13 HLock(h);
14 memcpy(*h, buf, len);
15 HUnlock(h);
16 return (PyObject *)ResObj_New(h);
17 """
19 f = ManualGenerator("Resource", resource_body)
20 f.docstring = lambda: """Convert a string to a resource object.
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)
27 # Convert resources to other things.
29 as_xxx_body = """
30 return %sObj_New((%sHandle)_self->ob_itself);
31 """
33 def genresconverter(longname, shortname):
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
40 resmethods.append(genresconverter("Control", "Ctl"))
41 resmethods.append(genresconverter("Menu", "Menu"))