6 if (!PyArg_ParseTuple(_args, "s#", &buf, &len))
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 See also the Handle() docstring.
34 if (!PyArg_ParseTuple(_args, "s#", &buf, &len))
44 rv = (ResourceObject *)ResObj_New(h);
45 rv->ob_freeit = PyMac_AutoDisposeHandle;
46 return (PyObject *)rv;
49 f
= ManualGenerator("Handle", handle_body
)
50 f
.docstring
= lambda: """Convert a string to a Handle object.
52 Resource() and Handle() are very similar, but objects created with Handle() are
53 by default automatically DisposeHandle()d upon object cleanup. Use AutoDispose()
58 # Convert resources to other things.
61 return %sObj_New((%sHandle)_self->ob_itself);
64 def genresconverter(longname
, shortname
):
66 f
= ManualGenerator("as_%s"%longname
, as_xxx_body
%(shortname
, longname
))
67 docstring
= "Return this resource/handle as a %s"%longname
68 f
.docstring
= lambda docstring
=docstring
: docstring
71 resmethods
.append(genresconverter("Control", "Ctl"))
72 resmethods
.append(genresconverter("Menu", "Menu"))
74 # The definition of this one is MacLoadResource, so we do it by hand...
76 f
= ResMethod(void
, 'LoadResource',
77 (Handle
, 'theResource', InMode
),
82 # A method to set the auto-dispose flag
84 AutoDispose_body
= """
86 if (!PyArg_ParseTuple(_args, "i", &onoff))
88 if ( _self->ob_freeit )
91 _self->ob_freeit = PyMac_AutoDisposeHandle;
93 _self->ob_freeit = NULL;
94 return Py_BuildValue("i", old);
96 f
= ManualGenerator("AutoDispose", AutoDispose_body
)
97 f
.docstring
= lambda: "(int)->int. Automatically DisposeHandle the object on Python object cleanup"