__init__.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: shift_jis -*-
00003 # -*- python -*-
00004 # @file omniidl_be/doil/servant/__init__.py
00005 # @brief servant code generator for doil backend
00006 # @date $Date$
00007 # @author Norkai Ando <n-ando@aist.go.jp>
00008 #
00009 #  Copyright (C) 2008
00010 #      Task-intelligence Research Group,
00011 #      Intelligent Systems Research Institute,
00012 #      National Institute of
00013 #          Advanced Industrial Science and Technology (AIST), Japan
00014 #      All rights reserved.
00015 #
00016 # $Id$
00017 #
00018 
00019 import os
00020 
00021 from omniidl_be.doil.interface import template
00022 import omniidl_be.doil.yat as yat
00023 import string
00024 
00025 decl_map = {
00026     'interface':         template.ifacefwd_decl,
00027     'interface_forward': template.ifacefwd_decl,
00028     'struct':            template.struct_decl,
00029     'struct_forward':    template.structfwd_decl,
00030     'union':             template.union_decl,
00031     'union_forward':     template.unionfwd_decl,
00032     'enum':              template.enum_decl,
00033     'exception':         template.exception_decl,
00034     'typedef':           template.typedef_decl
00035 }
00036 
00037 def generate_interface(dict):
00038     ifdict = {}
00039     for key in ['idl_fname', 'types_h', 'types_h_path', 'idl_includes']:
00040         ifdict[key] = dict[key]
00041 
00042     for d in dict['tree']:
00043         if d['corba']['decl_type'] == 'interface':
00044             ifdict.update(d)
00045 
00046             t = yat.Template(template.interface_h)
00047             text = t.generate(ifdict)
00048 
00049             fname = d['local']['iface_h']
00050             f = open(fname, "w")
00051             f.write(text)
00052             f.close()
00053 
00054 def generate_types(dict):
00055     decl = []
00056     pre_ns = []
00057     pre_ns_flat = ""
00058     for d in dict['tree']:
00059         curr_ns = d['local']['iface_ns']
00060         curr_ns_flat = string.join(curr_ns, '::')
00061         if pre_ns != curr_ns:
00062             nsdict = {'end_ns': pre_ns, 'begin_ns': curr_ns}
00063             t = yat.Template(template.ns_decl)
00064             ns_text = t.generate(nsdict)
00065             decl.append(ns_text)
00066         pre_ns = curr_ns
00067         pre_ns_flat = curr_ns_flat
00068 
00069         decl_type = d['decl_type']
00070         t = yat.Template(decl_map[decl_type])
00071         decl_text = t.generate(d)
00072         decl.append(decl_text)
00073 
00074     nsdict = {'end_ns': curr_ns, 'begin_ns': []}
00075     t = yat.Template(template.ns_decl)
00076     ns_text = t.generate(nsdict)
00077     decl.append(ns_text)
00078 
00079     dict['declarations'] = decl
00080     t = yat.Template(template.types_h)
00081     text = t.generate(dict)
00082 
00083     f = open(dict['types_h'], "w")
00084     f.write(text)
00085     f.close()
00086 


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Sat Jun 8 2019 18:49:03