@@ -30,6 +30,8 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *);
3030extern PyObject * CtlObj_New (ControlHandle );
3131extern int CtlObj_Convert (PyObject * , ControlHandle * );
3232
33+ extern PyObject * WinObj_WhichWindow (WindowPtr );
34+
3335#include <Resources.h>
3436
3537#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
@@ -1161,6 +1163,30 @@ static PyObject *Res_FSpCreateResFile(_self, _args)
11611163 return _res ;
11621164}
11631165
1166+ static PyObject * Res_Resource (_self , _args )
1167+ PyObject * _self ;
1168+ PyObject * _args ;
1169+ {
1170+ PyObject * _res = NULL ;
1171+
1172+ char * buf ;
1173+ int len ;
1174+ Handle h ;
1175+
1176+ if (!PyArg_ParseTuple (_args , "s#" , & buf , & len ))
1177+ return NULL ;
1178+ h = NewHandle (len );
1179+ if ( h == NULL ) {
1180+ PyErr_NoMemory ();
1181+ return NULL ;
1182+ }
1183+ HLock (h );
1184+ memcpy (* h , buf , len );
1185+ HUnlock (h );
1186+ return (PyObject * )ResObj_New (h );
1187+
1188+ }
1189+
11641190static PyMethodDef Res_methods [] = {
11651191 {"InitResources" , (PyCFunction )Res_InitResources , 1 ,
11661192 "() -> (short _rv)" },
@@ -1228,6 +1254,8 @@ static PyMethodDef Res_methods[] = {
12281254 "(FSSpec spec, SignedByte permission) -> (short _rv)" },
12291255 {"FSpCreateResFile" , (PyCFunction )Res_FSpCreateResFile , 1 ,
12301256 "(FSSpec spec, OSType creator, OSType fileType, ScriptCode scriptTag) -> None" },
1257+ {"Resource" , (PyCFunction )Res_Resource , 1 ,
1258+ "Convert a string to a resource object.\n\nThe created resource object is actually just a handle.\nApply AddResource() to write it to a resource file.\n" },
12311259 {NULL , NULL , 0 }
12321260};
12331261
0 commit comments