blob: 3c150aa51a5b9d8d01da67d33a563f29e8f30204 [file] [log] [blame]
Dan Talaycof75360a2010-02-05 22:22:54 -08001"""This module generate Python code for LAVI and messenger
2
3(C) Copyright Stanford University
4Date January 2010
5Created by ykk
6"""
7import cpythonize
8
9class msgrules(cpythonize.rules):
10 """Class that specify rules for pythonization of messenger
11
12 (C) Copyright Stanford University
13 Date January 2010
14 Created by ykk
15 """
16 def __init__(self):
17 """Initialize rules
18 """
19 cpythonize.rules.__init__(self)
20 ##Default values for members
21 #Default values for struct
22 ##Macros to exclude
23 self.excluded_macros = ['MESSAGE_HH__']
24 ##Enforce mapping
25 self.enforced_maps['messenger_msg'] = [ ('type','msg_type') ]
26
27class lavirules(msgrules):
28 """Class that specify rules for pythonization of LAVI messages
29
30 (C) Copyright Stanford University
31 Date January 2010
32 Created by ykk
33 """
34 def __init__(self, laviheader):
35 """Initialize rules
36 """
37 msgrules.__init__(self)
38 ##Default values for members
39
40 #Default values for struct
41 self.struct_default[('lavi_poll_message',
42 'header')] = ".type = "+str(laviheader.get_value('LAVIT_POLL'))
43 self.struct_default[('lavi_poll_stop_message',
44 'header')] = ".type = "+str(laviheader.get_value('LAVIT_POLL_STOP'))
45 ##Macros to exclude
46 self.excluded_macros = ['LAVI_MSG_HH']
47 ##Enforce mapping
48 self.enforced_maps['lavi_header'] = [ ('type','lavi_type') ]
49
50class msgpythonizer(cpythonize.pythonizer):
51 """Class that pythonize C messenger messages
52
53 (C) Copyright Stanford University
54 Date January 2010
55 Created by ykk
56 """
57 def __init__(self, msgheader):
58 """Initialize
59 """
60 rules = msgrules()
61 cpythonize.pythonizer.__init__(self, msgheader, rules)
62
63class lavipythonizer(cpythonize.pythonizer):
64 """Class that pythonize C messenger messages
65
66 (C) Copyright Stanford University
67 Date December 2009
68 Created by ykk
69 """
70 def __init__(self, msgheader):
71 """Initialize
72 """
73 rules = lavirules(msgheader)
74 cpythonize.pythonizer.__init__(self, msgheader, rules)