__init__.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: shift_jis -*-
00003 # -*- python -*-
00004 #
00005 # @file omniidl_be/doil/corba/__init__.py
00006 # @brief corba servant/adapter code generator for doil backend
00007 # @date $Date$
00008 # @author Norkai Ando <n-ando@aist.go.jp>
00009 #
00010 #  Copyright (C) 2008
00011 #      Task-intelligence Research Group,
00012 #      Intelligent Systems Research Institute,
00013 #      National Institute of
00014 #          Advanced Industrial Science and Technology (AIST), Japan
00015 #      All rights reserved.
00016 #
00017 # $Id$
00018 #
00019 
00020 import os
00021 
00022 from omniidl_be.doil.corba import template
00023 import omniidl_be.doil.yat as yat
00024 
00025 keys = ['idl_fname', 'idl_includes',
00026         'types_h', 'types_h_path', 
00027         'typeconv_h', 'typeconv_h_path',
00028         'include_h']
00029 
00030 decl_map = {
00031     'interface': {
00032         'decl': template.object_conv_h,    'impl': template.object_conv_cpp},
00033     'struct':    {
00034         'decl': template.struct_conv_h,    'impl': template.struct_conv_cpp},
00035     'union':     {
00036         'decl': template.union_conv_h,     'impl': template.union_conv_cpp},
00037     'enum':      {
00038         'decl': template.enum_conv_h,      'impl': template.enum_conv_cpp},
00039     'exception': {
00040         'decl': template.exception_conv_h, 'impl': template.exception_conv_cpp},
00041     'typedef':   {
00042         'decl': template.typedef_decl_h,   'impl': template.typedef_dec_cpp}
00043 }
00044 
00045 def generate_servant(dict):
00046     for d in dict['tree']:
00047         if d['corba']['decl_type'] == 'interface':
00048             ifdict = {}
00049             for key in keys:
00050                 ifdict[key] = dict[key]
00051 
00052             ifdict.update(d)
00053 
00054             t = yat.Template(template.servant_h)
00055             text = t.generate(ifdict)
00056             fname = d['local']['servant_h']
00057             f = open(fname, "w")
00058             f.write(text)
00059             f.close()
00060 
00061             t = yat.Template(template.servant_cpp)
00062             text = t.generate(ifdict)
00063             fname = d['local']['servant_cpp']
00064             f = open(fname, "w")
00065             f.write(text)
00066             f.close()
00067 
00068 def generate_adapter(dict):
00069     for d in dict['tree']:
00070         if d['corba']['decl_type'] == 'interface':
00071             ifdict = {}
00072             for key in keys:
00073                 ifdict[key] = dict[key]
00074 
00075             ifdict.update(d)
00076 
00077             t = yat.Template(template.adapter_h)
00078             text = t.generate(ifdict)
00079             fname = d['local']['adapter_h']
00080             f = open(fname, "w")
00081             f.write(text)
00082             f.close()
00083 
00084             t = yat.Template(template.adapter_cpp)
00085             text = t.generate(ifdict)
00086             fname = d['local']['adapter_cpp']
00087             f = open(fname, "w")
00088             f.write(text)
00089             f.close()
00090 
00091 def generate_proxy(dict):
00092     for d in dict['tree']:
00093         if d['corba']['decl_type'] == 'interface':
00094             ifdict = {}
00095             for key in keys:
00096                 ifdict[key] = dict[key]
00097 
00098             ifdict.update(d)
00099 
00100             t = yat.Template(template.proxy_h)
00101             text = t.generate(ifdict)
00102             fname = d['local']['proxy_h']
00103             f = open(fname, "w")
00104             f.write(text)
00105             f.close()
00106 
00107             t = yat.Template(template.proxy_cpp)
00108             text = t.generate(ifdict)
00109             fname = d['local']['proxy_cpp']
00110             f = open(fname, "w")
00111             f.write(text)
00112             f.close()
00113 
00114 def generate_types(dict):
00115     decl = []
00116     impl = []
00117     for d in dict['tree']:
00118         decl_type = d['decl_type']
00119 
00120         if not decl_map.has_key(decl_type): continue
00121 
00122         decl_temp = yat.Template(decl_map[decl_type]['decl'])
00123         decl_text = decl_temp.generate(d)
00124         decl.append(decl_text)
00125 
00126         impl_temp = yat.Template(decl_map[decl_type]['impl'])
00127         impl_text = impl_temp.generate(d)
00128         impl.append(impl_text)
00129 
00130 
00131     dict['declarations'] = decl
00132     dict['implementations'] = impl
00133 
00134     typeconv_h   = dict['typeconv_h']
00135     typeconv_cpp = dict['typeconv_cpp']
00136 
00137     t = yat.Template(template.typeconv_h)
00138     f = open(typeconv_h, "w")
00139     text = t.generate(dict)
00140     f.write(text)
00141     f.close()
00142 
00143     t = yat.Template(template.typeconv_cpp)
00144     f = open(typeconv_cpp, "w")
00145     text = t.generate(dict)
00146     f.write(text)
00147     f.close()


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