Commits

pygame  committed e5eb000

object types added

  • Participants
  • Parent commits 73e13c6

Comments (0)

Files changed (10)

 
 Nov 30, 2000
 	UserRect module added
+	all objects now have a matching type; SurfaceType, etc
 
 Nov 29, 2000
 	joystick module rewrite finished [BREAK]

File lib/UserRect.py

         try: self.__dict__['rect'] = Rect(*args)
         except TypeError:
             raise TypeError, 'Argument must be rectstyle object'
+        for a in dir(self.rect):
+            self.__dict__[a] = getattr(self.rect, a)
 
     def __getattr__(self, name):
         return getattr(self.rect, name)
     def __setattr__(self, name, val):
-        if name != 'rect':
-            setattr(self.__dict__['rect'], name, val)
+        if name is 'rect':
+            self.__dict__['rect'][:] = val
+        else:
+            try: setattr(self.__dict__['rect'], name, val)
+            except (AttributeError, KeyError): self.__dict__[name] = val
     def __len__(self): return 4
     def __getitem__(self, i): return self.rect[i]
     def __setitem__(self, i, val): self.rect[i] = val
     def __str__(self):
         return '<UserRect(%d, %d, %d, %d)>' % tuple(self.rect)
 
+    

File lib/__init__.py

 
 from pygame.base import *
 from pygame.surface import *
+from pygame.rect import *
 from pygame.locals import *
 import pygame.cdrom
 import pygame.display
 	module = Py_InitModule3("cdrom", cdrom_builtins, doc_pygame_cdrom_MODULE);
 	dict = PyModule_GetDict(module);
 
+	PyDict_SetItemString(dict, "CDType", (PyObject *)&PyCD_Type);
+
 	/* export the c api */
 	c_api[0] = &PyCD_Type;
 	c_api[1] = PyCD_New;
 	module = Py_InitModule3("event", event_builtins, doc_pygame_event_MODULE);
 	dict = PyModule_GetDict(module);
 
+	PyDict_SetItemString(dict, "EventType", (PyObject *)&PyEvent_Type);
+
 	/* export the c api */
 	c_api[0] = &PyEvent_Type;
 	c_api[1] = PyEvent_New;
 	module = Py_InitModule3("font", font_builtins, doc_pygame_font_MODULE);
 	dict = PyModule_GetDict(module);
 
+	PyDict_SetItemString(dict, "FontType", (PyObject *)&PyFont_Type);
+
 	/* export the c api */
 	c_api[0] = &PyFont_Type;
 	c_api[1] = PyFont_New;

File src/joystick.c

 	module = Py_InitModule3("joystick", joystick_builtins, doc_pygame_joystick_MODULE);
 	dict = PyModule_GetDict(module);
 
+	PyDict_SetItemString(dict, "JoystickType", (PyObject *)&PyJoystick_Type);
+
 	/* export the c api */
 	c_api[0] = &PyJoystick_Type;
 	c_api[1] = PyJoystick_New;
 	module = Py_InitModule3("mixer", mixer_builtins, doc_pygame_mixer_MODULE);
 	dict = PyModule_GetDict(module);
 
+	PyDict_SetItemString(dict, "SoundType", (PyObject *)&PySound_Type);
+	PyDict_SetItemString(dict, "ChannelType", (PyObject *)&PyChannel_Type);
+
 	/* export the c api */
 	c_api[0] = &PySound_Type;
 	c_api[1] = PySound_New;
 	module = Py_InitModule3("rect", rect__builtins__, rectangle_doc);
 	dict = PyModule_GetDict(module);
 
+	PyDict_SetItemString(dict, "RectType", (PyObject *)&PyRect_Type);
+
 	/* export the c api */
 	c_api[0] = &PyRect_Type;
 	c_api[1] = PyRect_New;

File src/surface.c

 	module = Py_InitModule3("surface", surface_builtins, doc_pygame_surface_MODULE);
 	dict = PyModule_GetDict(module);
 
+	PyDict_SetItemString(dict, "SurfaceType", (PyObject *)&PySurface_Type);
+
 	/* export the c api */
 	c_api[0] = &PySurface_Type;
 	c_api[1] = PySurface_New;