corba/__init__.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: shift_jis -*-
3 # -*- python -*-
4 #
5 # @file omniidl_be/doil/corba/__init__.py
6 # @brief corba servant/adapter code generator for doil backend
7 # @date $Date$
8 # @author Norkai Ando <n-ando@aist.go.jp>
9 #
10 # Copyright (C) 2008
11 # Task-intelligence Research Group,
12 # Intelligent Systems Research Institute,
13 # National Institute of
14 # Advanced Industrial Science and Technology (AIST), Japan
15 # All rights reserved.
16 #
17 # $Id$
18 #
19 
20 import os
21 
22 from omniidl_be.doil.corba import template
23 import omniidl_be.doil.yat as yat
24 
25 keys = ['idl_fname', 'idl_includes',
26  'types_h', 'types_h_path',
27  'typeconv_h', 'typeconv_h_path',
28  'include_h']
29 
30 decl_map = {
31  'interface': {
32  'decl': template.object_conv_h, 'impl': template.object_conv_cpp},
33  'struct': {
34  'decl': template.struct_conv_h, 'impl': template.struct_conv_cpp},
35  'union': {
36  'decl': template.union_conv_h, 'impl': template.union_conv_cpp},
37  'enum': {
38  'decl': template.enum_conv_h, 'impl': template.enum_conv_cpp},
39  'exception': {
40  'decl': template.exception_conv_h, 'impl': template.exception_conv_cpp},
41  'typedef': {
42  'decl': template.typedef_decl_h, 'impl': template.typedef_dec_cpp}
43 }
44 
45 def generate_servant(dict):
46  for d in dict['tree']:
47  if d['corba']['decl_type'] == 'interface':
48  ifdict = {}
49  for key in keys:
50  ifdict[key] = dict[key]
51 
52  ifdict.update(d)
53 
54  t = yat.Template(template.servant_h)
55  text = t.generate(ifdict)
56  fname = d['local']['servant_h']
57  f = open(fname, "w")
58  f.write(text)
59  f.close()
60 
61  t = yat.Template(template.servant_cpp)
62  text = t.generate(ifdict)
63  fname = d['local']['servant_cpp']
64  f = open(fname, "w")
65  f.write(text)
66  f.close()
67 
68 def generate_adapter(dict):
69  for d in dict['tree']:
70  if d['corba']['decl_type'] == 'interface':
71  ifdict = {}
72  for key in keys:
73  ifdict[key] = dict[key]
74 
75  ifdict.update(d)
76 
77  t = yat.Template(template.adapter_h)
78  text = t.generate(ifdict)
79  fname = d['local']['adapter_h']
80  f = open(fname, "w")
81  f.write(text)
82  f.close()
83 
84  t = yat.Template(template.adapter_cpp)
85  text = t.generate(ifdict)
86  fname = d['local']['adapter_cpp']
87  f = open(fname, "w")
88  f.write(text)
89  f.close()
90 
91 def generate_proxy(dict):
92  for d in dict['tree']:
93  if d['corba']['decl_type'] == 'interface':
94  ifdict = {}
95  for key in keys:
96  ifdict[key] = dict[key]
97 
98  ifdict.update(d)
99 
100  t = yat.Template(template.proxy_h)
101  text = t.generate(ifdict)
102  fname = d['local']['proxy_h']
103  f = open(fname, "w")
104  f.write(text)
105  f.close()
106 
107  t = yat.Template(template.proxy_cpp)
108  text = t.generate(ifdict)
109  fname = d['local']['proxy_cpp']
110  f = open(fname, "w")
111  f.write(text)
112  f.close()
113 
114 def generate_types(dict):
115  decl = []
116  impl = []
117  for d in dict['tree']:
118  decl_type = d['decl_type']
119 
120  if not decl_map.has_key(decl_type): continue
121 
122  decl_temp = yat.Template(decl_map[decl_type]['decl'])
123  decl_text = decl_temp.generate(d)
124  decl.append(decl_text)
125 
126  impl_temp = yat.Template(decl_map[decl_type]['impl'])
127  impl_text = impl_temp.generate(d)
128  impl.append(impl_text)
129 
130 
131  dict['declarations'] = decl
132  dict['implementations'] = impl
133 
134  typeconv_h = dict['typeconv_h']
135  typeconv_cpp = dict['typeconv_cpp']
136 
137  t = yat.Template(template.typeconv_h)
138  f = open(typeconv_h, "w")
139  text = t.generate(dict)
140  f.write(text)
141  f.close()
142 
143  t = yat.Template(template.typeconv_cpp)
144  f = open(typeconv_cpp, "w")
145  text = t.generate(dict)
146  f.write(text)
147  f.close()
def generate_servant(dict)
def generate_types(dict)
def generate_adapter(dict)
def generate_proxy(dict)


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Feb 28 2022 23:00:42