⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.py

📁 编译工具
💻 PY
📖 第 1 页 / 共 3 页
字号:
# -*- 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 dynamic skeleton definitions# $Id: main.py,v 1.14.2.10 2001/11/27 14:37:25 dpg1 Exp $# $Log: main.py,v $# Revision 1.14.2.10  2001/11/27 14:37:25  dpg1# long double TC descriptor.## Revision 1.14.2.9  2001/10/29 17:42:38  dpg1# Support forward-declared structs/unions, ORB::create_recursive_tc().## Revision 1.14.2.8  2001/08/22 13:29:47  dpg1# Re-entrant Any marshalling.## Revision 1.14.2.7  2001/08/17 13:47:31  dpg1# Small bug fixes.## Revision 1.14.2.6  2001/06/08 17:12:14  dpg1# Merge all the bug fixes from omni3_develop.## Revision 1.14.2.5  2001/03/13 10:32:07  dpg1# Fixed point support.## Revision 1.14.2.4  2000/11/20 14:43:24  sll# Added support for wchar and wstring.## Revision 1.14.2.3  2000/11/03 19:21:35  sll# idltype.Declared now takes an extra argument.## Revision 1.14.2.2  2000/10/12 15:37:49  sll# Updated from omni3_1_develop.## Revision 1.15.2.2  2000/08/21 11:35:06  djs# Lots of tidying## Revision 1.15.2.1  2000/08/04 17:10:28  dpg1# Long long support## Revision 1.15  2000/07/13 15:26:00  dpg1# Merge from omni3_develop for 3.0 release.## Revision 1.12.2.10  2000/06/27 16:15:09  sll# New classes: _CORBA_String_element, _CORBA_ObjRef_Element,# _CORBA_ObjRef_tcDesc_arg to support assignment to an element of a# sequence of string and a sequence of object reference.## Revision 1.12.2.9  2000/06/26 16:23:26  djs# Refactoring of configuration state mechanism.## Revision 1.12.2.8  2000/06/05 13:03:04  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.12.2.7  2000/05/31 18:02:50  djs# Better output indenting (and preprocessor directives now correctly output at# the beginning of lines)## Revision 1.12.2.6  2000/04/26 18:22:20  djs# Rewrote type mapping code (now in types.py)# Rewrote identifier handling code (now in id.py)## Revision 1.12.2.5  2000/04/05 10:58:36  djs# Missing function declaration when a union has a switch type declared in# another file## Revision 1.12.2.4  2000/03/24 22:30:18  djs# Major code restructuring:#   Control flow is more recursive and obvious#   Properly distinguishes between forward declarations and externs#   Only outputs definitions once#   Lots of assertions to check all is well## Revision 1.12.2.3  2000/03/20 11:48:16  djs# Better handling of unions whose switch types are declared externally## Revision 1.12.2.2  2000/03/15 20:49:18  djs# Problem with typedefs to sequences or array declarators defined externally# and used within a local struct or union.# Refactoring of this code is now required....## Revision 1.12.2.1  2000/02/14 18:34:56  dpg1# New omniidl merged in.## Revision 1.12  2000/01/20 18:26:44  djs# Moved large C++ output strings into an external template file## Revision 1.11  2000/01/19 11:23:48  djs# *** empty log message ***## Revision 1.10  2000/01/17 17:06:56  djs# Better handling of recursive and constructed types## Revision 1.9  2000/01/13 15:56:35  djs# Factored out private identifier prefix rather than hard coding it all through# the code.## Revision 1.8  2000/01/13 14:16:24  djs# Properly clears state between processing separate IDL input files## Revision 1.7  2000/01/11 12:02:38  djs# More tidying up## Revision 1.6  2000/01/11 11:33:55  djs# Tidied up## Revision 1.5  2000/01/07 20:31:24  djs# Regression tests in CVSROOT/testsuite now pass for#   * no backend arguments#   * tie templates#   * flattened tie templates#   * TypeCode and Any generation## Revision 1.4  1999/12/24 18:16:39  djs# Array handling and TypeCode building fixes (esp. across multiple files)## Revision 1.3  1999/12/10 18:26:36  djs# Moved most #ifdef buildDesc code into a separate module# General tidying up## Revision 1.2  1999/12/09 20:40:14  djs# TypeCode and Any generation option performs identically to old compiler for# all current test fragments.## Revision 1.1  1999/11/12 17:18:07  djs# Skeleton of dynamic skeleton code :)#"""Produce the main dynamic skeleton definitions"""# similar to o2be_root::produce_dynskel in the old C++ BEimport stringfrom omniidl import idlast, idltype, idlutilfrom omniidl_be.cxx import ast, cxx, output, util, id, types, configfrom omniidl_be.cxx.skel import manglerfrom omniidl_be.cxx.dynskel import templateimport mainself = maindef __init__(stream):    self.stream = stream    self.__symbols = {}    initSymbols()    self.__nodes = []    return self# ------------------------------------# Keep track of the symbols defined and check that we don't reference# any undefined ones (would cause compile/ link error)# Add entries for all the built in types. These functions are defined# in src/include/omniORB3/tcDescriptor.h# Note in particular that omniidl3 would add in externs for CORBA::Object# but not for any others of these. Seems slightly inconsistent.def initSymbols():    for name in [ "_0RL_buildDesc_cboolean",                  "_0RL_buildDesc_coctet",                  "_0RL_buildDesc_cchar",                  "_0RL_buildDesc_cwchar",                  "_0RL_buildDesc_cshort",                  "_0RL_buildDesc_cunsigned_pshort",                  "_0RL_buildDesc_clong",                  "_0RL_buildDesc_cunsigned_plong",                  "_0RL_buildDesc_cfloat",                  "_0RL_buildDesc_cdouble",                  "_0RL_buildDesc_cany",                  "_0RL_buildDesc_cstring",                  "_0RL_buildDesc_cwstring",                  "_0RL_buildDesc_cCORBA_mObject",                  "_0RL_buildDesc_cTypeCode",                  "_0RL_buildDesc_clonglong",                  "_0RL_buildDesc_cunsigned_plonglong",                  "_0RL_buildDesc_cfixed",                  "_0RL_buildDesc_clongdouble"]:        defineSymbol(name)def defineSymbol(name):    self.__symbols[name] = 1def defineSymbols(symlist):    for symbol in symlist:        defineSymbol(symbol)def isDefined(name):    return self.__symbols.has_key(name)def assertDefined(symlist):    for symbol in symlist:        if not isDefined(symbol):            raise RuntimeError("Symbol (" + symbol + ") should have been " +\                               "defined at this point in the output")# ------------------------------------# Keep track of our position in the AST to enable us to spot recursive# AST structuresdef startingNode(node):    self.__nodes.append(node)def finishingNode():    assert (self.__nodes != [])    self.__nodes = self.__nodes[0:len(self.__nodes)-1]def isRecursive(node):    return node in self.__nodes# ------------------------------------# Control arrives heredef visitAST(node):    for n in node.declarations():        if ast.shouldGenerateCodeForDecl(n):            n.accept(self)# ------------------------------------def visitModule(node):    for n in node.definitions():        n.accept(self)# -----------------------------------def visitInterface(node):    startingNode(node)    for n in node.declarations():        n.accept(self)    scopedName = id.Name(node.scopedName())    fqname = scopedName.fullyQualify()    guard_name = scopedName.guard()    objref_name = scopedName.prefix("_objref_").fullyQualify()    tc_name = scopedName.prefix("_tc_").fullyQualify()    helper_name = scopedName.suffix("_Helper").fullyQualify()    interface_type = types.Type(idltype.Declared(node,node.scopedName(),                                                 idltype.tk_objref,0));    objref_member = interface_type.objRefTemplate("tcDesc_arg")    prefix = config.state['Private Prefix']    # <--- Check we have the necessary definitions already output    required_symbols = [ prefix + "_tcParser_setObjectPtr_" + guard_name,                         prefix + "_tcParser_getObjectPtr_" + guard_name,                         prefix + "_buildDesc_c" + guard_name ]    generated_symbols = required_symbols +\                        [ prefix + "_delete_" + guard_name ]    defineSymbols(generated_symbols)    assertDefined(required_symbols)    # <---        stream.out(template.interface,               guard_name = guard_name,               fqname = fqname, objref_member = objref_member,               tc_name = tc_name, private_prefix = prefix)    finishingNode()# -----------------------------------def visitEnum(node):    startingNode(node)        scopedName = id.Name(node.scopedName())    guard_name = scopedName.guard()    fqname = scopedName.fullyQualify()    prefix = config.state['Private Prefix']    # <--- Check we have the necessary definitions already output    required_symbols = []    generated_symbols = [ prefix + "_buildDesc_c" + guard_name ]    defineSymbols(generated_symbols)    assertDefined(required_symbols)    # <---        stream.out(template.enum,               guard_name = guard_name,               private_prefix = config.state['Private Prefix'],               fqname = fqname)    finishingNode()# -----------------------------------def docast(type, decl, string):    assert isinstance(type, types.Type)    dims = type.dims()    if decl:        assert isinstance(decl, idlast.Declarator)        decl_dims = decl.sizes()        dims = decl_dims + dims            tail_dims_string = ""    if dims != []:        tail_dims = dims[1:]        tail_dims_string = cxx.dimsToString(tail_dims)        d_type = type.deref()    cast_to = d_type.base()    if d_type.objref():        cast_to = d_type.objRefTemplate("Member")    elif d_type.sequence():        cast_to = d_type.sequenceTemplate()    elif d_type.typecode():        cast_to = "CORBA::TypeCode_member"    elif d_type.string():        cast_to = "CORBA::String_member"    elif d_type.wstring():        cast_to = "CORBA::WString_member"    cast_to = cast_to + "(*)" + tail_dims_string    return "(const " + cast_to + ")(" + cast_to + ")" +\           "(" + string + ")"def prototype(decl, where, member = None):    scopedName = id.Name(decl.scopedName())    guard_name = "_c" + scopedName.guard()    fqname = scopedName.fullyQualify()    prefix = config.state['Private Prefix']    # <---    generated_symbol = prefix + "_buildDesc" + guard_name    if isDefined(generated_symbol):        return    defineSymbols([generated_symbol])    # <---    if member == None:        member = fqname        stream.out(template.builddesc_extern,               where = where,               cname = guard_name,               private_prefix = prefix,               name = member)def external(decl, member = None):    prototype(decl, "extern ", member)def forward(decl, member = None):    prototype(decl, "", member)# We walk over types when we encounter the _use_ of a type in an AST node.# If a type is referenced then we must output code for it, even if the# defining node is in another source file.# (normally we skip declarations make in another file)def visitBaseType(type):    passdef visitDeclaredType(type):    decl = type.decl()    type = types.Type(type)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -