Beispiel #1
0
    def __init__(self, tree, config):
        # configuration parameters from command options
        self.config = config

        # module's namespace stack
        self.module = []

        # main dictionary
        self.dict = {}
        self.dict['tree'] = []

        # idl file name
        idl_fname = ast.mainFile()
        self.dict['idl_fname'] = idl_fname

        # included idl files
        incs = []
        idl_incs = ast.includes()
        for inc in idl_incs:
            d = self.createHeaderInfo(inc)
            if inc == idl_fname:
                self.dict.update(d)
            elif self.config['ImplicitInclude']:
                # -Wbimplicit option makes process included IDLs
                d = self.createHeaderInfo(inc)
                incs.append(d)
        self.dict['idl_includes'] = incs

        # other includes
        self.dict['include_h'] = self.config["IncludeHeaders"]

        # type mapping
        self.typemap = self.config['TypeMapping']
        # now configurations can be accessed by self.config["key"]

        # keep track of all interfaces for later use
        self.__allInterfaces = []
        self.tk_map = {
            idltype.tk_null               : "tk_null",
            idltype.tk_void               : "tk_void",
            idltype.tk_short              : "tk_short",
            idltype.tk_long               : "tk_long",
            idltype.tk_ushort             : "tk_ushort",
            idltype.tk_ulong              : "tk_ulong",
            idltype.tk_float              : "tk_float",
            idltype.tk_double             : "tk_double",
            idltype.tk_boolean            : "tk_boolean",
            idltype.tk_char               : "tk_char",
            idltype.tk_octet              : "tk_octet",
            idltype.tk_any                : "tk_any",
            idltype.tk_TypeCode           : "tk_TypeCode",
            idltype.tk_Principal          : "tk_Principal",
            idltype.tk_objref             : "tk_objref",
            idltype.tk_struct             : "tk_struct",
            idltype.tk_union              : "tk_union",
            idltype.tk_enum               : "tk_enum",
            idltype.tk_string             : "tk_string",
            idltype.tk_sequence           : "tk_sequence",
            idltype.tk_array              : "tk_array",
            idltype.tk_alias              : "tk_alias",
            idltype.tk_except             : "tk_except",
            idltype.tk_longlong           : "tk_longlong",
            idltype.tk_ulonglong          : "tk_ulonglong",
            idltype.tk_longdouble         : "tk_longdouble",
            idltype.tk_wchar              : "tk_wchar",
            idltype.tk_wstring            : "tk_wstring",
            idltype.tk_fixed              : "tk_fixed",
            idltype.tk_value              : "tk_value",
            idltype.tk_value_box          : "tk_value_box",
            idltype.tk_native             : "tk_native",
            idltype.tk_abstract_interface : "tk_abstract_interface",
            idltype.tk_local_interface    : "tk_local_interface"
            }

        self.corba_primitive = {
            "CORBA::Short"                : "short int",
            "CORBA::UShort"               : "unsigned short int",
            "CORBA::Long"                 : "int",
            "CORBA::ULong"                : "unsigned int",
            "CORBA::Float"                : "float",
            "CORBA::Double"               : "double",
            "CORBA::Char"                 : "char",
            "CORBA::Boolean"              : "bool",
            "char*"                       : "::std::string",
            "CORBA::Any"                  : "::std::string",
            "CORBA::TypeCode_ptr"         : "::std::string"
            }
Beispiel #2
0
def monolithic(stream, tree):
    """Creates one large header with all definitions inside"""

    guard = id.Name([config.state['Basename']]).guard()

    header(stream, guard)

    # Extra DLL include stuff?
    if config.state['DLLIncludes']:
        sub_include_pre  = output.StringStream()
        sub_include_post = output.StringStream()
        sub_include_pre .out(template.sub_include_pre,  guard=guard)
        sub_include_post.out(template.sub_include_post, guard=guard)
    else:
        sub_include_pre  = ""
        sub_include_post = ""

    # Add in any direct C++ from toplevel pragma if present
    cxx_direct_include = []
    directive = "hh "
    for pragma in tree.pragmas():
        # ignore all pragmas but those in the main file
        if pragma.file() != tree.file(): continue
        
        if pragma.text()[:len(directive)] == directive:
            cxx_direct_include.append(pragma.text()[len(directive):])
    
    includes = output.StringStream()

    # produce #includes for all files included by the IDL
    for include in ast.includes():
        # skip the main file
        if ast.mainFile() == include:
            continue
        
        # the old C++ BE makes orb.idl a special case
        # (might now be a redundant test)
        
        # dirname  == directory containing the include file
        # filename == extensionless filename
        # ext      == extension (typically .idl)
        (root, ext) = os.path.splitext(include)
        (dirname, filename) = os.path.split(root)

        # Name for external include guard. Always use the same suffix,
        # rather than taking suffix from the config.
        guardname = id.Name([filename]).guard() + "_hh"

        if config.state['Keep Include Path']:
            filename = root

        cxx_include = filename + config.state['HH Suffix']

        if config.state['Use Quotes']:
            cxx_include = '"' + cxx_include + '"'
        else:
            cxx_include = "<" + cxx_include + ">"
            
        includes.out(template.main_include,
                     guardname    = guardname,
                     guard_prefix = config.state['GuardPrefix'],
                     filename     = cxx_include)

    # generate the header definitions
    def forward_dec(stream = stream, tree = tree):
        forward = omniidl_be.cxx.header.forward.init(stream)
        tree.accept(forward)

    def main_defs(stream = stream, tree = tree):
        defs = omniidl_be.cxx.header.defs.init(stream)
        tree.accept(defs)

    def main_poa(stream = stream, tree = tree):
        # includes inline (non-flat) tie templates
        poa = omniidl_be.cxx.header.poa.init(stream)
        tree.accept(poa)

    def main_obv(stream = stream, tree = tree):
        obv = omniidl_be.cxx.header.obv.init(stream)
        tree.accept(obv)

    def other_tie(stream = stream, tree = tree):
        if config.state['Normal Tie'] and config.state['BOA Skeletons']:
            tie = omniidl_be.cxx.header.tie.BOATieTemplates(stream)
            tree.accept(tie)
        
        if config.state['Flattened Tie']:
            tie = omniidl_be.cxx.header.tie.FlatTieTemplates(stream)
            tree.accept(tie)

    def main_opers(stream = stream, tree = tree):
        opers = omniidl_be.cxx.header.opers.init(stream)
        tree.accept(opers)
        
    def main_marshal(stream = stream, tree = tree):
        marshal = omniidl_be.cxx.header.marshal.init(stream)
        tree.accept(marshal)

    # other stuff
    stream.out(template.main,
               cxx_direct_include = "\n".join(cxx_direct_include),
               includes = includes,
               forward_declarations = forward_dec,
               defs = main_defs,
               poa = main_poa,
               obv = main_obv,
               other_tie = other_tie,
               operators = main_opers,
               marshalling = main_marshal,
               guard = guard,
               sub_include_pre = sub_include_pre,
               sub_include_post = sub_include_post)
Beispiel #3
0
def monolithic(stream, tree):
    """Creates one large header with all definitions inside"""

    guard = id.Name([config.state['Basename']]).guard()

    header(stream, guard)

    # Extra DLL include stuff?
    if config.state['DLLIncludes']:
        sub_include_pre = output.StringStream()
        sub_include_post = output.StringStream()
        sub_include_pre.out(template.sub_include_pre, guard=guard)
        sub_include_post.out(template.sub_include_post, guard=guard)
    else:
        sub_include_pre = ""
        sub_include_post = ""

    # Add in any direct C++ from toplevel pragma if present
    cxx_direct_include = []
    directive = "hh "
    for pragma in tree.pragmas():
        # ignore all pragmas but those in the main file
        if pragma.file() != tree.file(): continue

        if pragma.text()[:len(directive)] == directive:
            cxx_direct_include.append(pragma.text()[len(directive):])

    includes = output.StringStream()

    # produce #includes for all files included by the IDL
    for include in ast.includes():
        # skip the main file
        if ast.mainFile() == include:
            continue

        # the old C++ BE makes orb.idl a special case
        # (might now be a redundant test)

        # dirname  == directory containing the include file
        # filename == extensionless filename
        # ext      == extension (typically .idl)
        (root, ext) = os.path.splitext(include)
        (dirname, filename) = os.path.split(root)

        # Name for external include guard. Always use the same suffix,
        # rather than taking suffix from the config.
        guardname = id.Name([filename]).guard() + "_hh"

        if config.state['Keep Include Path']:
            filename = root

        cxx_include = filename + config.state['HH Suffix']

        if config.state['Use Quotes']:
            cxx_include = '"' + cxx_include + '"'
        else:
            cxx_include = "<" + cxx_include + ">"

        includes.out(template.main_include,
                     guardname=guardname,
                     guard_prefix=config.state['GuardPrefix'],
                     filename=cxx_include)

    # generate the header definitions
    def forward_dec(stream=stream, tree=tree):
        forward = omniidl_be.cxx.header.forward.init(stream)
        tree.accept(forward)

    def main_defs(stream=stream, tree=tree):
        defs = omniidl_be.cxx.header.defs.init(stream)
        tree.accept(defs)

    def main_poa(stream=stream, tree=tree):
        # includes inline (non-flat) tie templates
        poa = omniidl_be.cxx.header.poa.init(stream)
        tree.accept(poa)

    def main_obv(stream=stream, tree=tree):
        obv = omniidl_be.cxx.header.obv.init(stream)
        tree.accept(obv)

    def other_tie(stream=stream, tree=tree):
        if config.state['Normal Tie'] and config.state['BOA Skeletons']:
            tie = omniidl_be.cxx.header.tie.BOATieTemplates(stream)
            tree.accept(tie)

        if config.state['Flattened Tie']:
            tie = omniidl_be.cxx.header.tie.FlatTieTemplates(stream)
            tree.accept(tie)

    def main_opers(stream=stream, tree=tree):
        opers = omniidl_be.cxx.header.opers.init(stream)
        tree.accept(opers)

    def main_marshal(stream=stream, tree=tree):
        marshal = omniidl_be.cxx.header.marshal.init(stream)
        tree.accept(marshal)

    # other stuff
    stream.out(template.main,
               cxx_direct_include="\n".join(cxx_direct_include),
               includes=includes,
               forward_declarations=forward_dec,
               defs=main_defs,
               poa=main_poa,
               obv=main_obv,
               other_tie=other_tie,
               operators=main_opers,
               marshalling=main_marshal,
               guard=guard,
               sub_include_pre=sub_include_pre,
               sub_include_post=sub_include_post)