Guido van Rossum | 81920f1 | 1995-02-05 17:01:24 +0000 | [diff] [blame^] | 1 | resource_body = """ |
| 2 | char *buf; |
| 3 | int len; |
| 4 | Handle h; |
| 5 | |
| 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; |
| 12 | } |
| 13 | HLock(h); |
| 14 | memcpy(*h, buf, len); |
| 15 | HUnlock(h); |
| 16 | return (PyObject *)ResObj_New(h); |
| 17 | """ |
| 18 | |
| 19 | f = ManualGenerator("Resource", resource_body) |
| 20 | f.docstring = lambda: """Convert a string to a resource object. |
| 21 | |
| 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) |