]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Jim Fulton's change to support doc strings
authorJack Jansen <jack.jansen@cwi.nl>
Tue, 20 Jun 1995 12:26:03 +0000 (12:26 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Tue, 20 Jun 1995 12:26:03 +0000 (12:26 +0000)
Tools/modulator/Templates/module_method
Tools/modulator/Templates/module_tail
Tools/modulator/Templates/object_method
Tools/modulator/Templates/object_tail
Tools/modulator/genmodule.py

index 53cc1ac605b187bf28a55d5d9b4fbc76c6b627b2..9e6c0d2c12fcf3b84fd11c39a455c2e655d5a00d 100644 (file)
@@ -1,4 +1,8 @@
 
+static char $abbrev$_$method$__doc__[] =
+""
+;
+
 static PyObject *
 $abbrev$_$method$(self, args)
        PyObject *self; /* Not used */
index 8af75db9d65ac0c053aacdf17822feb7df0a75cb..6ee7645ff4213db5e6b46a28807355a1701b9921 100644 (file)
@@ -9,13 +9,19 @@ static struct PyMethodDef $abbrev$_methods[] = {
 
 /* Initialization function for the module (*must* be called init$name$) */
 
+static char $name$_module_documentation[] = 
+""
+;
+
 void
 init$name$()
 {
        PyObject *m, *d;
 
        /* Create the module and add the functions */
-       m = Py_InitModule("$name$", $abbrev$_methods);
+       m = Py_InitModule4("$name$", $abbrev$_methods,
+               $name$_module_documentation,
+               (PyObject*)NULL,PYTHON_API_VERSION);
 
        /* Add some symbolic constants to the module */
        d = PyModule_GetDict(m);
index 7ff5cea4efd5be26ff3d93f7d9c3ec2246a7b74b..95414947c4032ab149024e489ba0e69f67145efa 100644 (file)
@@ -1,4 +1,8 @@
 
+static char $abbrev$_$method$__doc__[] = 
+""
+;
+
 static PyObject *
 $abbrev$_$method$(self, args)
        $abbrev$object *self;
index 4803ea5542a22e350b6de05c3dbf9a2cd6a3eda4..65d29d35b46c8df9f0a706c6da7673faa383399a 100644 (file)
@@ -1,4 +1,8 @@
 
+static char $Abbrev$type__doc__[] = 
+""
+;
+
 static PyTypeObject $Abbrev$type = {
        PyObject_HEAD_INIT(&PyType_Type)
        0,                              /*ob_size*/
@@ -16,6 +20,12 @@ static PyTypeObject $Abbrev$type = {
        $tp_as_sequence$,               /*tp_as_sequence*/
        $tp_as_mapping$,                /*tp_as_mapping*/
        (hashfunc)$tp_hash$,            /*tp_hash*/
+       (binaryfunc)$tp_call$,          /*tp_call*/
+       (reprfunc)$tp_str$,             /*tp_str*/
+
+       /* Space for future expansion */
+       0L,0L,0L,0L,
+       $Abbrev$type__doc__ /* Documentation string */
 };
 
 /* End of code for $name$ objects */
index 1c4cd1f3914677110f4a8a36bb04eccf4a38b962..bdfe350baadc13e9387ad96f0bb7fc9986b37f5a 100755 (executable)
@@ -28,7 +28,7 @@ error = 'genmodule.error'
 # Names of functions in the object-description struct.
 #
 FUNCLIST = ['new', 'tp_dealloc', 'tp_print', 'tp_getattr', 'tp_setattr',
-           'tp_compare', 'tp_repr', 'tp_hash']
+           'tp_compare', 'tp_repr', 'tp_hash', 'tp_call', 'tp_str']
 TYPELIST = ['tp_as_number', 'tp_as_sequence', 'tp_as_mapping', 'structure']
 
 #
@@ -81,7 +81,8 @@ class module(writer):
        for fn in self.methodlist:
            self.method = fn
            self.addcode('module_method', fp)
-           new_ml = new_ml + ('{"%s",\t%s_%s,\t1},\n'%(fn, self.abbrev, fn))
+           new_ml = new_ml + ('{"%s",\t%s_%s,\t1,\t%s_%s__doc__},\n'
+                              %(fn, self.abbrev, fn, self.abbrev, fn))
        self.methodlist = new_ml
        self.addcode('module_tail', fp)
 
@@ -106,7 +107,8 @@ class object(writer):
        for fn in self.methodlist:
            self.method = fn
            self.addcode('object_method', fp)
-           new_ml = new_ml + ('{"%s",\t%s_%s,\t1},\n'%(fn, self.abbrev, fn))
+           new_ml = new_ml + ('{"%s",\t%s_%s,\t1,\t%s_%s__doc__},\n'
+                              %(fn, self.abbrev, fn, self.abbrev, fn))
        self.methodlist = new_ml
        self.addcode('object_mlist', fp)