diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 1995-06-18 20:20:27 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 1995-06-18 20:20:27 (GMT) |
commit | 1e054024c12b478eab2c09aae10f1a6cc1d6fda3 (patch) | |
tree | ff917b4d6f03fe13b6428b21bf8cf175066679cb /Mac/Modules/res/ressupport.py | |
parent | a177228ff8596f2457c8f527ec919c7c6f7c60fc (diff) | |
download | cpython-1e054024c12b478eab2c09aae10f1a6cc1d6fda3.zip cpython-1e054024c12b478eab2c09aae10f1a6cc1d6fda3.tar.gz cpython-1e054024c12b478eab2c09aae10f1a6cc1d6fda3.tar.bz2 |
Added methods as_Menu and as_Control to convert a resource
to those object types
You can now set the data attribute of a resource with the expected
semantics (but you have to call ChangedResource yourself)
Diffstat (limited to 'Mac/Modules/res/ressupport.py')
-rw-r--r-- | Mac/Modules/res/ressupport.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Mac/Modules/res/ressupport.py b/Mac/Modules/res/ressupport.py index efc7571..e2bfa79 100644 --- a/Mac/Modules/res/ressupport.py +++ b/Mac/Modules/res/ressupport.py @@ -56,6 +56,34 @@ if (strcmp(name, "__members__") == 0) return Py_BuildValue("[ss]", "data", "size"); """ +setattrCode = """ +static int +ResObj_setattr(self, name, value) + ResourceObject *self; + char *name; + PyObject *value; +{ + char *data; + long size; + + if (strcmp(name, "data") != 0 || value == NULL ) + return -1; + if ( !PyString_Check(value) ) + return -1; + size = PyString_Size(value); + data = PyString_AsString(value); + /* XXXX Do I need the GetState/SetState calls? */ + SetHandleSize(self->ob_itself, size); + if ( MemError()) + return -1; + HLock(self->ob_itself); + memcpy((char *)*self->ob_itself, data, size); + HUnlock(self->ob_itself); + /* XXXX Should I do the Changed call immedeately? */ + return 0; +} +""" + class ResDefiniton(GlobalObjectDefinition): def outputCheckNewArg(self): @@ -63,6 +91,9 @@ class ResDefiniton(GlobalObjectDefinition): def outputGetattrHook(self): Output(getattrHookCode) + + def outputSetattr(self): + Output(setattrCode) resobject = ResDefiniton('Resource', 'ResObj', 'Handle') |