annotate Mac/Modules/res/resedit.py @ 5817:48b94de85bf3 legacy-trunk

Extensive changes by AMK.
author Guido van Rossum <guido@python.org>
date Thu, 17 Jul 1997 16:29:42 +0000
parents 4b74b3b43269
children ac288db5bc91
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2288
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 resource_body = """
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 char *buf;
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 int len;
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 Handle h;
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
5
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 if (!PyArg_ParseTuple(_args, "s#", &buf, &len))
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 return NULL;
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 h = NewHandle(len);
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 if ( h == NULL ) {
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 PyErr_NoMemory();
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 return NULL;
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 }
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 HLock(h);
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 memcpy(*h, buf, len);
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 HUnlock(h);
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 return (PyObject *)ResObj_New(h);
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 """
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
18
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 f = ManualGenerator("Resource", resource_body)
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 f.docstring = lambda: """Convert a string to a resource object.
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
21
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 The created resource object is actually just a handle.
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 Apply AddResource() to write it to a resource file.
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
24 """
b4caac1428d0 manually defined Resource() function
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 functions.append(f)
2753
4b74b3b43269 Added methods as_Menu and as_Control to convert a resource
Jack Jansen <jack.jansen@cwi.nl>
parents: 2288
diff changeset
26
4b74b3b43269 Added methods as_Menu and as_Control to convert a resource
Jack Jansen <jack.jansen@cwi.nl>
parents: 2288
diff changeset
27 # Convert resources to other things.
4b74b3b43269 Added methods as_Menu and as_Control to convert a resource
Jack Jansen <jack.jansen@cwi.nl>
parents: 2288
diff changeset
28
4b74b3b43269 Added methods as_Menu and as_Control to convert a resource
Jack Jansen <jack.jansen@cwi.nl>
parents: 2288
diff changeset
29 as_xxx_body = """
4b74b3b43269 Added methods as_Menu and as_Control to convert a resource
Jack Jansen <jack.jansen@cwi.nl>
parents: 2288
diff changeset
30 return %sObj_New((%sHandle)_self->ob_itself);
4b74b3b43269 Added methods as_Menu and as_Control to convert a resource
Jack Jansen <jack.jansen@cwi.nl>
parents: 2288
diff changeset
31 """
4b74b3b43269 Added methods as_Menu and as_Control to convert a resource
Jack Jansen <jack.jansen@cwi.nl>
parents: 2288
diff changeset
32
4b74b3b43269 Added methods as_Menu and as_Control to convert a resource
Jack Jansen <jack.jansen@cwi.nl>
parents: 2288
diff changeset
33 def genresconverter(longname, shortname):
4b74b3b43269 Added methods as_Menu and as_Control to convert a resource
Jack Jansen <jack.jansen@cwi.nl>
parents: 2288
diff changeset
34
4b74b3b43269 Added methods as_Menu and as_Control to convert a resource
Jack Jansen <jack.jansen@cwi.nl>
parents: 2288
diff changeset
35 f = ManualGenerator("as_%s"%longname, as_xxx_body%(shortname, longname))
4b74b3b43269 Added methods as_Menu and as_Control to convert a resource
Jack Jansen <jack.jansen@cwi.nl>
parents: 2288
diff changeset
36 docstring = "Return this resource/handle as a %s"%longname
4b74b3b43269 Added methods as_Menu and as_Control to convert a resource
Jack Jansen <jack.jansen@cwi.nl>
parents: 2288
diff changeset
37 f.docstring = lambda docstring=docstring: docstring
4b74b3b43269 Added methods as_Menu and as_Control to convert a resource
Jack Jansen <jack.jansen@cwi.nl>
parents: 2288
diff changeset
38 return f
4b74b3b43269 Added methods as_Menu and as_Control to convert a resource
Jack Jansen <jack.jansen@cwi.nl>
parents: 2288
diff changeset
39
4b74b3b43269 Added methods as_Menu and as_Control to convert a resource
Jack Jansen <jack.jansen@cwi.nl>
parents: 2288
diff changeset
40 resmethods.append(genresconverter("Control", "Ctl"))
4b74b3b43269 Added methods as_Menu and as_Control to convert a resource
Jack Jansen <jack.jansen@cwi.nl>
parents: 2288
diff changeset
41 resmethods.append(genresconverter("Menu", "Menu"))