mirror of
				https://github.com/python/cpython.git
				synced 2025-10-29 17:38:56 +00:00 
			
		
		
		
	 9aaee933da
			
		
	
	
		9aaee933da
		
	
	
	
	
		
			
			- Converted the templates to use ANSI C prototypes (finally!) - Use re in stead of deprecated regex
		
			
				
	
	
		
			37 lines
		
	
	
	
		
			871 B
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
	
		
			871 B
		
	
	
	
		
			Text
		
	
	
	
	
	
| 
 | |
| /* Code to access structure members by accessing attributes */
 | |
| 
 | |
| #include "structmember.h"
 | |
| 
 | |
| #define OFF(x) offsetof(XXXXobject, x)
 | |
| 
 | |
| static struct memberlist $abbrev$_memberlist[] = {
 | |
| 	/* XXXX Add lines like { "foo", T_INT, OFF(foo), RO }  */
 | |
| 
 | |
| 	{NULL}	/* Sentinel */
 | |
| };
 | |
| 
 | |
| static PyObject *
 | |
| $abbrev$_getattr($abbrev$object *self, char *name)
 | |
| {
 | |
| 	PyObject *rv;
 | |
| 	
 | |
| 	/* XXXX Add your own getattr code here */
 | |
| 	rv = PyMember_Get((char *)/*XXXX*/0, $abbrev$_memberlist, name);
 | |
| 	if (rv)
 | |
| 		return rv;
 | |
| 	PyErr_Clear();
 | |
| 	return Py_FindMethod($abbrev$_methods, (PyObject *)self, name);
 | |
| }
 | |
| 
 | |
| 
 | |
| static int
 | |
| $abbrev$_setattr($abbrev$object *self, char *name, PyObject *v)
 | |
| {
 | |
| 	/* XXXX Add your own setattr code here */
 | |
| 	if ( v == NULL ) {
 | |
| 		PyErr_SetString(PyExc_AttributeError, "Cannot delete attribute");
 | |
| 		return -1;
 | |
| 	}
 | |
| 	return PyMember_Set((char *)/*XXXX*/0, $abbrev$_memberlist, name, v);
 | |
| }
 |