blob: 40436993db294865b3ebd84a359d67e51ab34da4 [file] [log] [blame]
Guido van Rossumd2112201995-03-02 14:05:29 +00001#
2# Example input file for modulator if you don't have tk.
3#
4# You may also have to strip some imports out of modulator to make
5# it work.
6#
7# Generate code for a simple object with a method called sample
8
9o = genmodule.object()
10o.name = 'simple object'
11o.abbrev = 'simp'
12o.methodlist = ['sample']
13o.funclist = ['new']
14
15#
16# Generate code for an object that looks numberish
17#
18o2 = genmodule.object()
19o2.name = 'number-like object'
20o2.abbrev = 'nl'
21o2.typelist = ['tp_as_number']
22o2.funclist = ['new', 'tp_repr', 'tp_compare']
23
24#
25# Generate code for a method with a full complement of functions,
26# some methods, accessible as sequence and allowing structmember.c type
27# structure access as well.
28#
29o3 = genmodule.object()
30o3.name = 'over-the-top object'
31o3.abbrev = 'ot'
32o3.methodlist = ['method1', 'method2']
33o3.funclist = ['new', 'tp_dealloc', 'tp_print', 'tp_getattr', 'tp_setattr',
34 'tp_compare', 'tp_repr', 'tp_hash']
35o3.typelist = ['tp_as_sequence', 'structure']
36
37#
38# Now generate code for a module that incorporates these object types.
39# Also add the boilerplates for functions to create instances of each
40# type.
41#
42m = genmodule.module()
43m.name = 'sample'
44m.abbrev = 'sample'
45m.methodlist = ['newsimple', 'newnumberish', 'newott']
46m.objects = [o, o2, o3]