📄 main.py
字号:
# -*- python -*-# Package : omniidl# main.py Created on: 1999/11/12# Author : David Scott (djs)## Copyright (C) 1999 AT&T Laboratories Cambridge## This file is part of omniidl.## omniidl is free software; you can redistribute it and/or modify it# under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2 of the License, or# (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU# General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA# 02111-1307, USA.## Description:## Produce the main skeleton definitions# $Id: main.py,v 1.29.2.14 2004/10/17 22:29:42 dgrisby Exp $# $Log: main.py,v $# Revision 1.29.2.14 2004/10/17 22:29:42 dgrisby# Stubs for typedef to sequence of forward-declared struct / union# were broken. Thanks Jeremy Van Grinsven.## Revision 1.29.2.13 2004/07/29 10:45:22 dgrisby# Bug with unmarshalling unions with multiple case labels.## Revision 1.29.2.12 2004/07/29 10:36:34 dgrisby# Bug with unmarshalling unions with multiple case labels.## Revision 1.29.2.11 2004/07/23 14:07:04 dgrisby# Subtly incorrect generated code for arrays.## Revision 1.29.2.10 2003/08/15 10:53:59 dgrisby# Avoid bool representation problem with Python 2.3.## Revision 1.29.2.9 2001/10/29 17:42:41 dpg1# Support forward-declared structs/unions, ORB::create_recursive_tc().## Revision 1.29.2.8 2001/06/08 17:12:19 dpg1# Merge all the bug fixes from omni3_develop.## Revision 1.29.2.7 2001/03/13 10:32:09 dpg1# Fixed point support.## Revision 1.29.2.6 2001/01/25 13:09:11 sll# Fixed up cxx backend to stop it from dying when a relative# path name is given to the -p option of omniidl.## Revision 1.29.2.5 2000/11/20 14:43:25 sll# Added support for wchar and wstring.## Revision 1.29.2.4 2000/11/07 18:30:35 sll# exception copy ctor must use helper duplicate function if the interface is# a forward declaration.## Revision 1.29.2.3 2000/11/03 19:22:56 sll# Replace the old set of marshalling operators in the generated code with# a couple of unified operators for cdrStream.## Revision 1.29.2.2 2000/10/12 15:37:53 sll# Updated from omni3_1_develop.## Revision 1.30.2.3 2000/09/14 16:03:57 djs# Remodularised C++ descriptor name generator## Revision 1.30.2.2 2000/08/21 11:35:32 djs# Lots of tidying## Revision 1.30.2.1 2000/08/02 10:52:02 dpg1# New omni3_1_develop branch, merged from omni3_develop.## Revision 1.30 2000/07/13 15:25:59 dpg1# Merge from omni3_develop for 3.0 release.## Revision 1.27.2.12 2000/07/24 16:32:18 djs# Fixed typo in previous BOA skeleton bugfix.# Suppressed compiler warning (from gcc -Wall) when encountering a call with# no arguments and no return value.## Revision 1.27.2.11 2000/06/26 16:24:17 djs# Refactoring of configuration state mechanism.## Revision 1.27.2.10 2000/06/06 14:45:07 djs# Produces flattened name typedefs for _all_ inherited interfaces (not just# those which are immediate decendents) in SK.cc## Revision 1.27.2.9 2000/06/05 13:04:18 djs# Removed union member name clash (x & pd_x, pd__default, pd__d)# Removed name clash when a sequence is called "pd_seq"## Revision 1.27.2.8 2000/05/31 18:03:38 djs# Better output indenting (and preprocessor directives now correctly output at# the beginning of lines)# Calling an exception "e" resulted in a name clash (and resultant C++# compile failure)## Revision 1.27.2.7 2000/05/05 16:50:51 djs# Existing workaround for MSVC5 scoping problems extended to help with# base class initialisers. Instead of using the fully qualified or unambiguous# name, a flat typedef is generated at global scope and that is used instead.# This was a solution to a previous bug wrt operation dispatch()ing.# This does not affect the OMNI_BASE_CTOR powerpc/aix workaround.## Revision 1.27.2.6 2000/04/26 18:22:54 djs# Rewrote type mapping code (now in types.py)# Rewrote identifier handling code (now in id.py)# Removed superfluous externs in front of function definitions## Revision 1.27.2.5 2000/04/05 10:58:02 djs# Scoping problem with generated proxies for attributes (not operations)## Revision 1.27.2.4 2000/03/20 11:50:26 djs# Removed excess buffering- output templates have code attached which is# lazily evaluated when required.## Revision 1.27.2.3 2000/02/16 16:30:02 djs# Fix to proxy call descriptor code- failed to handle special case of# Object method(in string x)## Revision 1.27.2.2 2000/02/15 15:28:35 djs# Stupid bug in powerpc aix workaround fixed## Revision 1.27.2.1 2000/02/14 18:34:53 dpg1# New omniidl merged in.## Revision 1.27 2000/02/01 09:26:49 djs# Tracking fixes in old compiler: powerpc-aix scoped identifier workarounds## Revision 1.26 2000/01/19 17:05:15 djs# Modified to use an externally stored C++ output template.## Revision 1.25 2000/01/19 11:21:52 djs# *** empty log message ***## Revision 1.24 2000/01/17 17:05:38 djs# Marshalling and constructed types fixes## Revision 1.23 2000/01/14 15:57:20 djs# Added MSVC workaround for interface inheritance## Revision 1.22 2000/01/13 17:02:05 djs# Added support for operation contexts.## Revision 1.21 2000/01/13 15:56:43 djs# Factored out private identifier prefix rather than hard coding it all through# the code.## Revision 1.20 2000/01/13 14:16:34 djs# Properly clears state between processing separate IDL input files## Revision 1.19 2000/01/12 17:48:34 djs# Added option to create BOA compatible skeletons (same as -BBOA in omniidl3)## Revision 1.18 2000/01/11 14:13:23 djs# Updated array mapping to include NAME_copy(to, from) as per 2.3 spec## Revision 1.17 2000/01/11 12:02:45 djs# More tidying up## Revision 1.16 2000/01/10 18:42:22 djs# Removed redundant code, tidied up.## Revision 1.15 2000/01/10 15:39:48 djs# Better name and scope handling.## Revision 1.14 2000/01/07 20:31:33 djs# Regression tests in CVSROOT/testsuite now pass for# * no backend arguments# * tie templates# * flattened tie templates# * TypeCode and Any generation## Revision 1.13 1999/12/25 21:47:18 djs# Better TypeCode support## Revision 1.12 1999/12/24 18:18:32 djs# #include bug fixed## Revision 1.11 1999/12/16 16:11:21 djs# Now uses transitive closure of inherits relation where appropriate## Revision 1.10 1999/12/14 11:53:22 djs# Support for CORBA::TypeCode and CORBA::Any# Exception member bugfix## Revision 1.9 1999/12/09 20:40:57 djs# Bugfixes and integration with dynskel/ code## Revision 1.8 1999/11/29 19:27:05 djs# Code tidied and moved around. Some redundant code eliminated.## Revision 1.7 1999/11/29 15:27:53 djs# Minor bugfixes## Revision 1.6 1999/11/26 18:51:13 djs# Now uses proxy module for most proxy generation## Revision 1.5 1999/11/23 18:48:25 djs# Bugfixes, more interface operations and attributes code## Revision 1.4 1999/11/19 20:12:03 djs# Generates skeletons for interface operations and attributes## Revision 1.3 1999/11/17 20:37:23 djs# Code for call descriptors and proxies## Revision 1.2 1999/11/15 19:13:38 djs# Union skeletons working## Revision 1.1 1999/11/12 17:18:58 djs# Struct skeleton code added#"""Produce the main skeleton definitions"""# similar to o2be_root::produce_skel in the old C++ BEimport stringfrom omniidl import idlast, idltype, idlutilfrom omniidl_be.cxx import cxx, ast, output, id, config, skutil, typesfrom omniidl_be.cxx.skel import template# XXX Cannot just use from omniidl_be.cxx import iface as it doesn't# seem to work if a relative path is given to the -p option of omniidlimport omniidl_be.cxx.ifaceimport mainself = maindef __init__(stream): self.stream = stream # To keep track of our depth with the AST self.__insideInterface = 0 self.__insideModule = 0 # An entry in this dictionary indicates a flattened typedef # already exists for this interface. See comments later for # explanation. self.__flattened_interfaces = {} return self# ------------------------------------# Control arrives heredef visitAST(node): for n in node.declarations(): if ast.shouldGenerateCodeForDecl(n): n.accept(self)def visitModule(node): insideModule = self.__insideModule self.__insideModule = 1 for n in node.definitions(): n.accept(self) self.__insideModule = insideModuledef visitInterface(node): ident = node.identifier() outer_environment = id.lookup(node) environment = outer_environment.enter(ident) insideInterface = self.__insideInterface self.__insideInterface = 1 # produce skeletons for types declared here for n in node.declarations(): n.accept(self) self.__insideInterface = insideInterface # Call descriptor names are of the form: # TAG _ PREFIX _ BASE # Tag represents the type of thing {call descriptor, local callback...} # Prefix is derived from the first encountered scopedname[1] # Base is a counter to uniquify the identifier # # [1] Since the names are guaranteed unique, the prefix makes the # names used by two different modules disjoint too. Not sure why # as they are not externally visible? I = omniidl_be.cxx.iface.Interface(node) I_Helper = omniidl_be.cxx.iface.instance("I_Helper")(I) I_Helper.cc(stream) # the class itself node_name = id.Name(node.scopedName()) objref_name = node_name.prefix("_objref_") stream.out(template.interface_class, name = node_name.fullyQualify(), objref_name = objref_name.unambiguous(environment), repoID = node.repoId()) # Output flattened aliases to inherited classes, to workaround an # MSVC bug. for i in ast.allInherits(node): inherits_name = id.Name(i.scopedName()) if inherits_name.needFlatName(environment): guard_name = inherits_name.guard() flat_fqname = inherits_name.flatName() inherits_impl_name = inherits_name.prefix("_impl_") inherits_objref_name = inherits_name.prefix("_objref_") impl_flat_fqname = inherits_impl_name.flatName() objref_flat_fqname = inherits_objref_name.flatName() stream.out(template.interface_ALIAS, guard_name = guard_name, fqname = inherits_name.fullyQualify(), flat_fqname = flat_fqname, impl_fqname = inherits_impl_name.fullyQualify(), impl_flat_fqname = impl_flat_fqname, objref_fqname = inherits_objref_name.fullyQualify(), objref_flat_fqname = objref_flat_fqname) _objref_I = omniidl_be.cxx.iface.instance("_objref_I")(I) _objref_I.cc(stream) _pof_I = omniidl_be.cxx.iface.instance("_pof_I")(I) _pof_I.cc(stream) _impl_I = omniidl_be.cxx.iface.instance("_impl_I")(I) _impl_I.cc(stream) # BOA compatible skeletons if config.state['BOA Skeletons']: sk_name = node_name.prefix("_sk_") stream.out(template.interface_sk, sk_fqname = sk_name.fullyQualify(), sk_name = sk_name.unambiguous(environment))def visitTypedef(node): environment = id.lookup(node) is_global_scope = not (self.__insideModule or self.__insideInterface) aliasType = types.Type(node.aliasType()) d_type = aliasType.deref() if node.constrType(): aliasType.type().decl().accept(self) fq_aliased = aliasType.base(environment) for d in node.declarators(): scopedName = id.Name(d.scopedName()) decl_dims = d.sizes() decl_dims_str = cxx.dimsToString(decl_dims) decl_first_dim_str = "" if decl_dims != []: decl_first_dim_str = cxx.dimsToString([decl_dims[0]]) full_dims = decl_dims + aliasType.dims() is_array = full_dims != [] is_array_declarator = decl_dims != [] fq_derived = scopedName.fullyQualify() if d_type.sequence() and not aliasType.typedef(): seqType = types.Type(d_type.type().seqType()) d_seqType = seqType.deref() if d_seqType.structforward() or d_seqType.unionforward(): fqname = scopedName.fullyQualify() name = id.mapID(d.identifier()) element = d_seqType.base() bound = d_type.type().bound() derived = d_type.sequenceTemplate() if (bound > 0): stream.out(template.sequence_forward_bounded_defns, bound=bound, fqname=fqname, name=name, element=element, derived=derived) else: stream.out(template.sequence_forward_unbounded_defns,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -