mirror of
https://github.com/AdaCore/cpython.git
synced 2026-02-12 12:57:15 -08:00
checkin of Jack's original version
This commit is contained in:
46
Tools/modulator/EXAMPLE.py
Normal file
46
Tools/modulator/EXAMPLE.py
Normal file
@@ -0,0 +1,46 @@
|
||||
#
|
||||
# Example input file for modulator if you don't have tk.
|
||||
#
|
||||
# You may also have to strip some imports out of modulator to make
|
||||
# it work.
|
||||
#
|
||||
# Generate code for a simple object with a method called sample
|
||||
|
||||
o = genmodule.object()
|
||||
o.name = 'simple object'
|
||||
o.abbrev = 'simp'
|
||||
o.methodlist = ['sample']
|
||||
o.funclist = ['new']
|
||||
|
||||
#
|
||||
# Generate code for an object that looks numberish
|
||||
#
|
||||
o2 = genmodule.object()
|
||||
o2.name = 'number-like object'
|
||||
o2.abbrev = 'nl'
|
||||
o2.typelist = ['tp_as_number']
|
||||
o2.funclist = ['new', 'tp_repr', 'tp_compare']
|
||||
|
||||
#
|
||||
# Generate code for a method with a full complement of functions,
|
||||
# some methods, accessible as sequence and allowing structmember.c type
|
||||
# structure access as well.
|
||||
#
|
||||
o3 = genmodule.object()
|
||||
o3.name = 'over-the-top object'
|
||||
o3.abbrev = 'ot'
|
||||
o3.methodlist = ['method1', 'method2']
|
||||
o3.funclist = ['new', 'tp_dealloc', 'tp_print', 'tp_getattr', 'tp_setattr',
|
||||
'tp_compare', 'tp_repr', 'tp_hash']
|
||||
o3.typelist = ['tp_as_sequence', 'structure']
|
||||
|
||||
#
|
||||
# Now generate code for a module that incorporates these object types.
|
||||
# Also add the boilerplates for functions to create instances of each
|
||||
# type.
|
||||
#
|
||||
m = genmodule.module()
|
||||
m.name = 'sample'
|
||||
m.abbrev = 'sample'
|
||||
m.methodlist = ['newsimple', 'newnumberish', 'newott']
|
||||
m.objects = [o, o2, o3]
|
||||
17
Tools/modulator/README
Normal file
17
Tools/modulator/README
Normal file
@@ -0,0 +1,17 @@
|
||||
This is release 1.0 of modulator, a generator of boilerplate code for
|
||||
modules to be written in C.
|
||||
|
||||
Usage when you have tk is *reall* simple: start modulator, fill out
|
||||
the forms specifying all the objects and methods, tell modulator
|
||||
whether objects should also be accessible as sequences, etc and press
|
||||
'generate code'. It will write a complete skeleton module for you.
|
||||
|
||||
Usage when you don't have tk is slightly more difficult. Look at
|
||||
EXAMPLE.py for some details.
|
||||
|
||||
Oh yeah: you'll probably want to change Templates/copyright, or all
|
||||
your code ends up as being copyrighted to CWI:-)
|
||||
|
||||
Let me know what you think,
|
||||
Jack Jansen, jack@cwi.nl
|
||||
|
||||
37
Tools/modulator/ScrolledListbox.py
Normal file
37
Tools/modulator/ScrolledListbox.py
Normal file
@@ -0,0 +1,37 @@
|
||||
# A ScrolledList widget feels like a list widget but also has a
|
||||
# vertical scroll bar on its right. (Later, options may be added to
|
||||
# add a horizontal bar as well, to make the bars disappear
|
||||
# automatically when not needed, to move them to the other side of the
|
||||
# window, etc.)
|
||||
#
|
||||
# Configuration options are passed to the List widget.
|
||||
# A Frame widget is inserted between the master and the list, to hold
|
||||
# the Scrollbar widget.
|
||||
# Most methods calls are inherited from the List widget; Pack methods
|
||||
# are redirected to the Frame widget however.
|
||||
|
||||
from Tkinter import *
|
||||
from Tkinter import _cnfmerge
|
||||
|
||||
class ScrolledListbox(Listbox):
|
||||
def __init__(self, master=None, cnf={}):
|
||||
cnf = _cnfmerge(cnf)
|
||||
fcnf = {}
|
||||
vcnf = {'name': 'vbar',
|
||||
Pack: {'side': 'right', 'fill': 'y'},}
|
||||
for k in cnf.keys():
|
||||
if type(k) == ClassType or k == 'name':
|
||||
fcnf[k] = cnf[k]
|
||||
del cnf[k]
|
||||
self.frame = Frame(master, fcnf)
|
||||
self.vbar = Scrollbar(self.frame, vcnf)
|
||||
cnf[Pack] = {'side': 'left', 'fill': 'both', 'expand': 'yes'}
|
||||
cnf['name'] = 'list'
|
||||
Listbox.__init__(self, self.frame, cnf)
|
||||
self['yscrollcommand'] = (self.vbar, 'set')
|
||||
self.vbar['command'] = (self, 'yview')
|
||||
|
||||
# Copy Pack methods of self.frame -- hack!
|
||||
for m in Pack.__dict__.keys():
|
||||
if m[0] != '_' and m != 'config':
|
||||
setattr(self, m, getattr(self.frame, m))
|
||||
23
Tools/modulator/Templates/copyright
Normal file
23
Tools/modulator/Templates/copyright
Normal file
@@ -0,0 +1,23 @@
|
||||
/***********************************************************
|
||||
Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
|
||||
The Netherlands.
|
||||
|
||||
All Rights Reserved
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appear in all copies and that
|
||||
both that copyright notice and this permission notice appear in
|
||||
supporting documentation, and that the names of Stichting Mathematisch
|
||||
Centrum or CWI not be used in advertising or publicity pertaining to
|
||||
distribution of the software without specific, written prior permission.
|
||||
|
||||
STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
|
||||
FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
******************************************************************/
|
||||
7
Tools/modulator/Templates/module_head
Normal file
7
Tools/modulator/Templates/module_head
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
#include "allobjects.h"
|
||||
#include "modsupport.h" /* For getargs() etc. */
|
||||
|
||||
static object *ErrorObject;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
12
Tools/modulator/Templates/module_method
Normal file
12
Tools/modulator/Templates/module_method
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
static object *
|
||||
$abbrev$_$method$(self, args)
|
||||
object *self; /* Not used */
|
||||
object *args;
|
||||
{
|
||||
|
||||
if (!newgetargs(args, ""))
|
||||
return NULL;
|
||||
INCREF(None);
|
||||
return None;
|
||||
}
|
||||
30
Tools/modulator/Templates/module_tail
Normal file
30
Tools/modulator/Templates/module_tail
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
/* List of methods defined in the module */
|
||||
|
||||
static struct methodlist $abbrev$_methods[] = {
|
||||
$methodlist$
|
||||
{NULL, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
|
||||
/* Initialization function for the module (*must* be called init$name$) */
|
||||
|
||||
void
|
||||
init$name$()
|
||||
{
|
||||
object *m, *d;
|
||||
|
||||
/* Create the module and add the functions */
|
||||
m = initmodule("$name$", $abbrev$_methods);
|
||||
|
||||
/* Add some symbolic constants to the module */
|
||||
d = getmoduledict(m);
|
||||
ErrorObject = newstringobject("$name$.error");
|
||||
dictinsert(d, "error", ErrorObject);
|
||||
|
||||
/* XXXX Add constants here */
|
||||
|
||||
/* Check for errors */
|
||||
if (err_occurred())
|
||||
fatal("can't initialize module $name$");
|
||||
}
|
||||
12
Tools/modulator/Templates/object_head
Normal file
12
Tools/modulator/Templates/object_head
Normal file
@@ -0,0 +1,12 @@
|
||||
/* Declarations for objects of type $name$ */
|
||||
|
||||
typedef struct {
|
||||
OB_HEAD
|
||||
/* XXXX Add your own stuff here */
|
||||
} $abbrev$object;
|
||||
|
||||
staticforward typeobject $Abbrev$type;
|
||||
|
||||
#define is_$abbrev$object(v) ((v)->ob_type == &$Abbrev$type)
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
11
Tools/modulator/Templates/object_method
Normal file
11
Tools/modulator/Templates/object_method
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
static object *
|
||||
$abbrev$_$method$(self, args)
|
||||
$abbrev$object *self;
|
||||
object *args;
|
||||
{
|
||||
if (!newgetargs(args, ""))
|
||||
return NULL;
|
||||
INCREF(None);
|
||||
return None;
|
||||
}
|
||||
7
Tools/modulator/Templates/object_mlist
Normal file
7
Tools/modulator/Templates/object_mlist
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
static struct methodlist $abbrev$_methods[] = {
|
||||
$methodlist$
|
||||
{NULL, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
/* ---------- */
|
||||
12
Tools/modulator/Templates/object_new
Normal file
12
Tools/modulator/Templates/object_new
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
static $abbrev$object *
|
||||
new$abbrev$object()
|
||||
{
|
||||
$abbrev$object *self;
|
||||
|
||||
self = NEWOBJ($abbrev$object, &$Abbrev$type);
|
||||
if (self == NULL)
|
||||
return NULL;
|
||||
/* XXXX Add your own initializers here */
|
||||
return self;
|
||||
}
|
||||
41
Tools/modulator/Templates/object_structure
Normal file
41
Tools/modulator/Templates/object_structure
Normal file
@@ -0,0 +1,41 @@
|
||||
/* 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 object *
|
||||
$abbrev$_getattr(self, name)
|
||||
$abbrev$object *self;
|
||||
char *name;
|
||||
{
|
||||
object *rv;
|
||||
|
||||
/* XXXX Add your own getattr code here */
|
||||
rv = getmember((char *)/*XXXX*/0, $abbrev$_memberlist, name);
|
||||
if (rv)
|
||||
return rv;
|
||||
err_clear();
|
||||
return findmethod($abbrev$_methods, (object *)self, name);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
$abbrev$_setattr(self, name, v)
|
||||
$abbrev$object *self;
|
||||
char *name;
|
||||
object *v;
|
||||
{
|
||||
/* XXXX Add your own setattr code here */
|
||||
if ( v == NULL ) {
|
||||
err_setstr(AttributeError, "Cannot delete attribute");
|
||||
return -1;
|
||||
}
|
||||
return setmember((char *)/*XXXX*/0, $abbrev$_memberlist, name, v);
|
||||
}
|
||||
|
||||
22
Tools/modulator/Templates/object_tail
Normal file
22
Tools/modulator/Templates/object_tail
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
static typeobject $Abbrev$type = {
|
||||
OB_HEAD_INIT(&Typetype)
|
||||
0, /*ob_size*/
|
||||
"$name$", /*tp_name*/
|
||||
sizeof($abbrev$object), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
/* methods */
|
||||
(destructor)$tp_dealloc$, /*tp_dealloc*/
|
||||
(printfunc)$tp_print$, /*tp_print*/
|
||||
(getattrfunc)$tp_getattr$, /*tp_getattr*/
|
||||
(setattrfunc)$tp_setattr$, /*tp_setattr*/
|
||||
(cmpfunc)$tp_compare$, /*tp_compare*/
|
||||
(reprfunc)$tp_repr$, /*tp_repr*/
|
||||
$tp_as_number$, /*tp_as_number*/
|
||||
$tp_as_sequence$, /*tp_as_sequence*/
|
||||
$tp_as_mapping$, /*tp_as_mapping*/
|
||||
(hashfunc)$tp_hash$, /*tp_hash*/
|
||||
};
|
||||
|
||||
/* End of code for $name$ objects */
|
||||
/* -------------------------------------------------------- */
|
||||
33
Tools/modulator/Templates/object_tp_as_mapping
Normal file
33
Tools/modulator/Templates/object_tp_as_mapping
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Code to access $name$ objects as mappings */
|
||||
|
||||
static int
|
||||
$abbrev$_length(self)
|
||||
$abbrev$object *self;
|
||||
{
|
||||
/* XXXX Return the size of the mapping */
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_subscript(self, key)
|
||||
$abbrev$object *self;
|
||||
object *key;
|
||||
{
|
||||
/* XXXX Return the item of self indexed by key */
|
||||
}
|
||||
|
||||
static int
|
||||
$abbrev$_ass_sub(self, v, w)
|
||||
$abbrev$object *self;
|
||||
object *v, *w;
|
||||
{
|
||||
/* XXXX Put w in self under key v */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static mapping_methods $abbrev$_as_mapping = {
|
||||
(inquiry)$abbrev$_length, /*mp_length*/
|
||||
(binaryfunc)$abbrev$_subscript, /*mp_subscript*/
|
||||
(objobjargproc)$abbrev$_ass_sub, /*mp_ass_subscript*/
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
249
Tools/modulator/Templates/object_tp_as_number
Normal file
249
Tools/modulator/Templates/object_tp_as_number
Normal file
@@ -0,0 +1,249 @@
|
||||
/* Code to access $name$ objects as numbers */
|
||||
|
||||
static object *
|
||||
$abbrev$_add(v, w)
|
||||
$abbrev$object *v;
|
||||
$abbrev$object *w;
|
||||
{
|
||||
/* XXXX Add them */
|
||||
err_setstr(SystemError, "not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_sub(v, w)
|
||||
$abbrev$object *v;
|
||||
$abbrev$object *w;
|
||||
{
|
||||
/* XXXX Subtract them */
|
||||
err_setstr(SystemError, "not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_mul(v, w)
|
||||
$abbrev$object *v;
|
||||
$abbrev$object *w;
|
||||
{
|
||||
/* XXXX Multiply them */
|
||||
err_setstr(SystemError, "not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_div(x, y)
|
||||
$abbrev$object *x;
|
||||
$abbrev$object *y;
|
||||
{
|
||||
/* XXXX Divide them */
|
||||
err_setstr(SystemError, "not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_mod(x, y)
|
||||
$abbrev$object *x;
|
||||
$abbrev$object *y;
|
||||
{
|
||||
/* XXXX Modulo them */
|
||||
err_setstr(SystemError, "not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_divmod(x, y)
|
||||
$abbrev$object *x;
|
||||
$abbrev$object *y;
|
||||
{
|
||||
/* XXXX Return 2-tuple with div and mod */
|
||||
err_setstr(SystemError, "not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_pow(v, w, z)
|
||||
$abbrev$object *v;
|
||||
$abbrev$object *w;
|
||||
$abbrev$object *z;
|
||||
{
|
||||
/* XXXX */
|
||||
err_setstr(SystemError, "not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_neg(v)
|
||||
$abbrev$object *v;
|
||||
{
|
||||
/* XXXX */
|
||||
err_setstr(SystemError, "not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_pos(v)
|
||||
$abbrev$object *v;
|
||||
{
|
||||
/* XXXX */
|
||||
err_setstr(SystemError, "not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_abs(v)
|
||||
$abbrev$object *v;
|
||||
{
|
||||
/* XXXX */
|
||||
err_setstr(SystemError, "not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
$abbrev$_nonzero(v)
|
||||
$abbrev$object *v;
|
||||
{
|
||||
/* XXXX Return 1 if non-zero */
|
||||
err_setstr(SystemError, "not implemented");
|
||||
return -1;
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_invert(v)
|
||||
$abbrev$object *v;
|
||||
{
|
||||
/* XXXX */
|
||||
err_setstr(SystemError, "not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_lshift(v, w)
|
||||
$abbrev$object *v;
|
||||
$abbrev$object *w;
|
||||
{
|
||||
/* XXXX */
|
||||
err_setstr(SystemError, "not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_rshift(v, w)
|
||||
$abbrev$object *v;
|
||||
$abbrev$object *w;
|
||||
{
|
||||
/* XXXX */
|
||||
err_setstr(SystemError, "not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_and(v, w)
|
||||
$abbrev$object *v;
|
||||
$abbrev$object *w;
|
||||
{
|
||||
/* XXXX */
|
||||
err_setstr(SystemError, "not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_xor(v, w)
|
||||
$abbrev$object *v;
|
||||
$abbrev$object *w;
|
||||
{
|
||||
/* XXXX */
|
||||
err_setstr(SystemError, "not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_or(v, w)
|
||||
$abbrev$object *v;
|
||||
$abbrev$object *w;
|
||||
{
|
||||
/* XXXX */
|
||||
err_setstr(SystemError, "not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
$abbrev$_coerce(pv, pw)
|
||||
object **pv;
|
||||
object **pw;
|
||||
{
|
||||
/* XXXX I haven't a clue... */
|
||||
return 1;
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_int(v)
|
||||
$abbrev$object *v;
|
||||
{
|
||||
/* XXXX */
|
||||
err_setstr(SystemError, "not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_long(v)
|
||||
$abbrev$object *v;
|
||||
{
|
||||
/* XXXX */
|
||||
err_setstr(SystemError, "not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_float(v)
|
||||
$abbrev$object *v;
|
||||
{
|
||||
/* XXXX */
|
||||
err_setstr(SystemError, "not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_oct(v)
|
||||
$abbrev$object *v;
|
||||
{
|
||||
/* XXXX Return object as octal stringobject */
|
||||
err_setstr(SystemError, "not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_hex(v)
|
||||
$abbrev$object *v;
|
||||
{
|
||||
/* XXXX Return object as hex stringobject */
|
||||
err_setstr(SystemError, "not implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static number_methods $abbrev$_as_number = {
|
||||
(binaryfunc)$abbrev$_add, /*nb_add*/
|
||||
(binaryfunc)$abbrev$_sub, /*nb_subtract*/
|
||||
(binaryfunc)$abbrev$_mul, /*nb_multiply*/
|
||||
(binaryfunc)$abbrev$_div, /*nb_divide*/
|
||||
(binaryfunc)$abbrev$_mod, /*nb_remainder*/
|
||||
(binaryfunc)$abbrev$_divmod, /*nb_divmod*/
|
||||
(ternaryfunc)$abbrev$_pow, /*nb_power*/
|
||||
(unaryfunc)$abbrev$_neg, /*nb_negative*/
|
||||
(unaryfunc)$abbrev$_pos, /*nb_positive*/
|
||||
(unaryfunc)$abbrev$_abs, /*nb_absolute*/
|
||||
(inquiry)$abbrev$_nonzero, /*nb_nonzero*/
|
||||
(unaryfunc)$abbrev$_invert, /*nb_invert*/
|
||||
(binaryfunc)$abbrev$_lshift, /*nb_lshift*/
|
||||
(binaryfunc)$abbrev$_rshift, /*nb_rshift*/
|
||||
(binaryfunc)$abbrev$_and, /*nb_and*/
|
||||
(binaryfunc)$abbrev$_xor, /*nb_xor*/
|
||||
(binaryfunc)$abbrev$_or, /*nb_or*/
|
||||
(coercion)$abbrev$_coerce, /*nb_coerce*/
|
||||
(unaryfunc)$abbrev$_int, /*nb_int*/
|
||||
(unaryfunc)$abbrev$_long, /*nb_long*/
|
||||
(unaryfunc)$abbrev$_float, /*nb_float*/
|
||||
(unaryfunc)$abbrev$_oct, /*nb_oct*/
|
||||
(unaryfunc)$abbrev$_hex, /*nb_hex*/
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------- */
|
||||
73
Tools/modulator/Templates/object_tp_as_sequence
Normal file
73
Tools/modulator/Templates/object_tp_as_sequence
Normal file
@@ -0,0 +1,73 @@
|
||||
|
||||
/* Code to handle accessing $name$ objects as sequence objects */
|
||||
|
||||
static int
|
||||
$abbrev$_length(self)
|
||||
$abbrev$object *self;
|
||||
{
|
||||
/* XXXX Return the size of the object */
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_concat(self, bb)
|
||||
$abbrev$object *self;
|
||||
object *bb;
|
||||
{
|
||||
/* XXXX Return the concatenation of self and bb */
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_repeat(self, n)
|
||||
$abbrev$object *self;
|
||||
int n;
|
||||
{
|
||||
/* XXXX Return a new object that is n times self */
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_item(self, i)
|
||||
$abbrev$object *self;
|
||||
int i;
|
||||
{
|
||||
/* XXXX Return the i-th object of self */
|
||||
}
|
||||
|
||||
static object *
|
||||
$abbrev$_slice(self, ilow, ihigh)
|
||||
$abbrev$object *self;
|
||||
int ilow, ihigh;
|
||||
{
|
||||
/* XXXX Return the ilow..ihigh slice of self in a new object */
|
||||
}
|
||||
|
||||
static int
|
||||
$abbrev$_ass_item(self, i, v)
|
||||
$abbrev$object *self;
|
||||
int i;
|
||||
object *v;
|
||||
{
|
||||
/* XXXX Assign to the i-th element of self */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
$abbrev$_ass_slice(self, ilow, ihigh, v)
|
||||
listobject *self;
|
||||
int ilow, ihigh;
|
||||
object *v;
|
||||
{
|
||||
/* XXXX Replace ilow..ihigh slice of self with v */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static sequence_methods $abbrev$_as_sequence = {
|
||||
(inquiry)$abbrev$_length, /*sq_length*/
|
||||
(binaryfunc)$abbrev$_concat, /*sq_concat*/
|
||||
(intargfunc)$abbrev$_repeat, /*sq_repeat*/
|
||||
(intargfunc)$abbrev$_item, /*sq_item*/
|
||||
(intintargfunc)$abbrev$_slice, /*sq_slice*/
|
||||
(intobjargproc)$abbrev$_ass_item, /*sq_ass_item*/
|
||||
(intintobjargproc)$abbrev$_ass_slice, /*sq_ass_slice*/
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
7
Tools/modulator/Templates/object_tp_compare
Normal file
7
Tools/modulator/Templates/object_tp_compare
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
static int
|
||||
$abbrev$_compare(v, w)
|
||||
$abbrev$object *v, *w;
|
||||
{
|
||||
/* XXXX Compare objects and return -1, 0 or 1 */
|
||||
}
|
||||
8
Tools/modulator/Templates/object_tp_dealloc
Normal file
8
Tools/modulator/Templates/object_tp_dealloc
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
static void
|
||||
$abbrev$_dealloc(self)
|
||||
$abbrev$object *self;
|
||||
{
|
||||
/* XXXX Add your own cleanup code here */
|
||||
DEL(self);
|
||||
}
|
||||
9
Tools/modulator/Templates/object_tp_getattr
Normal file
9
Tools/modulator/Templates/object_tp_getattr
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
static object *
|
||||
$abbrev$_getattr(self, name)
|
||||
$abbrev$object *self;
|
||||
char *name;
|
||||
{
|
||||
/* XXXX Add your own getattr code here */
|
||||
return findmethod($abbrev$_methods, (object *)self, name);
|
||||
}
|
||||
7
Tools/modulator/Templates/object_tp_hash
Normal file
7
Tools/modulator/Templates/object_tp_hash
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
static long
|
||||
$abbrev$_hash(self)
|
||||
$abbrev$object *self;
|
||||
{
|
||||
/* XXXX Return a hash of self (or -1) */
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user