interface/__init__.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: shift_jis -*-
3 # -*- python -*-
4 # @file omniidl_be/doil/servant/__init__.py
5 # @brief servant code generator for doil backend
6 # @date $Date$
7 # @author Norkai Ando <n-ando@aist.go.jp>
8 #
9 # Copyright (C) 2008
10 # Task-intelligence Research Group,
11 # Intelligent Systems Research Institute,
12 # National Institute of
13 # Advanced Industrial Science and Technology (AIST), Japan
14 # All rights reserved.
15 #
16 # $Id$
17 #
18 
19 import os
20 
21 from omniidl_be.doil.interface import template
22 import omniidl_be.doil.yat as yat
23 import string
24 
25 decl_map = {
26  'interface': template.ifacefwd_decl,
27  'interface_forward': template.ifacefwd_decl,
28  'struct': template.struct_decl,
29  'struct_forward': template.structfwd_decl,
30  'union': template.union_decl,
31  'union_forward': template.unionfwd_decl,
32  'enum': template.enum_decl,
33  'exception': template.exception_decl,
34  'typedef': template.typedef_decl
35 }
36 
38  ifdict = {}
39  for key in ['idl_fname', 'types_h', 'types_h_path', 'idl_includes']:
40  ifdict[key] = dict[key]
41 
42  for d in dict['tree']:
43  if d['corba']['decl_type'] == 'interface':
44  ifdict.update(d)
45 
46  t = yat.Template(template.interface_h)
47  text = t.generate(ifdict)
48 
49  fname = d['local']['iface_h']
50  f = open(fname, "w")
51  f.write(text)
52  f.close()
53 
54 def generate_types(dict):
55  decl = []
56  pre_ns = []
57  pre_ns_flat = ""
58  for d in dict['tree']:
59  curr_ns = d['local']['iface_ns']
60  curr_ns_flat = string.join(curr_ns, '::')
61  if pre_ns != curr_ns:
62  nsdict = {'end_ns': pre_ns, 'begin_ns': curr_ns}
63  t = yat.Template(template.ns_decl)
64  ns_text = t.generate(nsdict)
65  decl.append(ns_text)
66  pre_ns = curr_ns
67  pre_ns_flat = curr_ns_flat
68 
69  decl_type = d['decl_type']
70  t = yat.Template(decl_map[decl_type])
71  decl_text = t.generate(d)
72  decl.append(decl_text)
73 
74  nsdict = {'end_ns': curr_ns, 'begin_ns': []}
75  t = yat.Template(template.ns_decl)
76  ns_text = t.generate(nsdict)
77  decl.append(ns_text)
78 
79  dict['declarations'] = decl
80  t = yat.Template(template.types_h)
81  text = t.generate(dict)
82 
83  f = open(dict['types_h'], "w")
84  f.write(text)
85  f.close()
86 
def generate_types(dict)
def generate_interface(dict)


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Jun 6 2019 19:25:56