コード例 #1
0
def run(tree, backend_args):
    # Process arguments
    dirname, filename = os.path.split(tree.file())
    basename,ext      = os.path.splitext(filename)
    config.state['Basename']  = basename
    config.state['Directory'] = dirname

    process_args(backend_args)

    try:
        # Check the input tree only contains stuff we understand
        support.checkIDL(tree)

        # initialise the handy ast module
        ast.__init__(tree)

        # Initialise the descriptor generating code
        descriptor.__init__(tree)

        # Build the map of AST nodes to Environments
        tree.accept(id.WalkTree())


        hh_filename  = config.state['Basename'] + config.state['HH Suffix']
        hpp_filename = config.state['Basename'] + config.state['HPP Suffix']
        hxx_filename = config.state['Basename'] + config.state['HXX Suffix']
        cc_filename  = config.state['Basename'] + config.state['CC Suffix']
        if config.state["Include Prefix"]:
            prefix = config.state['Include Prefix'] + '/'
        else:
            prefix = ""

        idl_filename = tree.file()

        hpp_stream = output.Stream(output.createFile(hpp_filename), 2)
        hxx_stream = output.Stream(output.createFile(hxx_filename), 2)
        cc_stream  = output.Stream(output.createFile( cc_filename), 2)
        main.self = main
        main.__init__(hpp_stream, hxx_stream, cc_stream,
                idl_filename,
                prefix, hh_filename, hpp_filename, hxx_filename)

        main.run(tree)

        hpp_stream .close()
        hxx_stream.close()
        cc_stream .close()

    except AttributeError as e:
        name = e.args[0]
        unsupported_visitors = map(lambda x:"visit" + x,
                                   AST_unsupported_nodes[:])
        if name in unsupported_visitors:
            # delete all possibly partial output files
            for file in output.listAllCreatedFiles():
                os.unlink(file)

            util.unsupportedIDL()
            
        raise

    except SystemExit as e:
        # fatalError function throws SystemExit exception
        # delete all possibly partial output files
        for file in output.listAllCreatedFiles():
            os.unlink(file)
        
        raise
コード例 #2
0
    def _argmapping(self, direction):
        # _argmapping(types.Type, int direction): const * reference * pointer
        #   Returns info on operation argument mapping for a type for
        #   a particular direction.

        # CORBA2.3 P1-204 Table 1-3 Basic argument and result mapping
        array = self.array()
        variable = self.variable()

        if array and not variable:
            # array of fixed size elements
            return ((1, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 1))[direction]

        if array and variable:
            # array of variable size elements
            return ((1, 0, 0), (0, 1, 1), (0, 0, 0), (0, 0, 1))[direction]

        type = self.deref().__type
        kind = type.kind()

        if kind in [
                idltype.tk_short, idltype.tk_long, idltype.tk_longlong,
                idltype.tk_ushort, idltype.tk_ulong, idltype.tk_ulonglong,
                idltype.tk_float, idltype.tk_double, idltype.tk_enum,
                idltype.tk_longdouble, idltype.tk_boolean, idltype.tk_char,
                idltype.tk_wchar, idltype.tk_octet
        ]:
            # from short to enum the entries are the same
            return ((0, 0, 0), (0, 1, 0), (0, 1, 0), (0, 0, 0))[direction]

        if kind in [
                idltype.tk_objref, idltype.tk_TypeCode,
                idltype.tk_abstract_interface, idltype.tk_local_interface
        ]:

            # objref_ptr objref_ptr& objref_ptr& objref_ptr
            return ((0, 0, 0), (0, 1, 0), (0, 1, 0), (0, 0, 0))[direction]

        if kind in [idltype.tk_struct, idltype.tk_union]:
            if variable:
                # variable struct or union
                return ((1, 1, 0), (0, 1, 1), (0, 1, 0), (0, 0, 1))[direction]
            else:
                # fixed struct or union
                return ((1, 1, 0), (0, 1, 0), (0, 1, 0), (0, 0, 0))[direction]

        if kind in [idltype.tk_string, idltype.tk_wstring]:
            return ((1, 0, 0), (0, 1, 0), (0, 1, 0), (0, 0, 0))[direction]

        if kind in [idltype.tk_sequence, idltype.tk_any]:
            return ((1, 1, 0), (0, 1, 1), (0, 1, 0), (0, 0, 1))[direction]

        if kind == idltype.tk_fixed:
            return ((1, 1, 0), (0, 1, 0), (0, 1, 0), (0, 0, 0))[direction]

        if kind in [idltype.tk_value, idltype.tk_value_box]:

            return ((0, 0, 1), (0, 1, 1), (0, 1, 1), (0, 0, 1))[direction]

        if kind == idltype.tk_void:
            return (0, 0, 0)

        if kind in unsupported_typecodes:
            util.unsupportedIDL()

        util.fatalError("Unknown type encountered (kind = " + str(kind) + ")")
        return
コード例 #3
0
ファイル: types.py プロジェクト: Distrotech/omniORB
    def _argmapping(self, direction):
        # _argmapping(types.Type, int direction): const * reference * pointer
        #   Returns info on operation argument mapping for a type for
        #   a particular direction.

        # CORBA2.3 P1-204 Table 1-3 Basic argument and result mapping
        array = self.array()
        variable = self.variable()

        if array and not variable:
            # array of fixed size elements
            return ( (1, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 1) )[direction]

        if array and variable:
            # array of variable size elements
            return ( (1, 0, 0), (0, 1, 1), (0, 0, 0), (0, 0, 1) )[direction]

        type = self.deref().__type
        kind = type.kind()

        if kind in [ idltype.tk_short, idltype.tk_long, idltype.tk_longlong,
                     idltype.tk_ushort, idltype.tk_ulong, idltype.tk_ulonglong,
                     idltype.tk_float, idltype.tk_double, idltype.tk_enum,
                     idltype.tk_longdouble, idltype.tk_boolean,
                     idltype.tk_char, idltype.tk_wchar, idltype.tk_octet ]:
            # from short to enum the entries are the same
            return ( (0, 0, 0), (0, 1, 0), (0, 1, 0), (0, 0, 0) )[direction]

        if kind in [ idltype.tk_objref,
                     idltype.tk_TypeCode,
                     idltype.tk_abstract_interface,
                     idltype.tk_local_interface ]:

            # objref_ptr objref_ptr& objref_ptr& objref_ptr
            return ( (0, 0, 0), (0, 1, 0), (0, 1, 0), (0, 0, 0) )[direction]

        if kind in [ idltype.tk_struct, idltype.tk_union ]:
            if variable:
                # variable struct or union
                return ((1, 1, 0), (0, 1, 1), (0, 1, 0), (0, 0, 1))[direction]
            else:
                # fixed struct or union
                return ((1, 1, 0), (0, 1, 0), (0, 1, 0), (0, 0, 0))[direction]
                
        if kind in [ idltype.tk_string, idltype.tk_wstring ]:
            return ( (1, 0, 0), (0, 1, 0), (0, 1, 0), (0, 0, 0) )[direction]

        if kind in [ idltype.tk_sequence, idltype.tk_any ]:
            return ( (1, 1, 0), (0, 1, 1), (0, 1, 0), (0, 0, 1) )[direction]

        if kind == idltype.tk_fixed:
            return ( (1, 1, 0), (0, 1, 0), (0, 1, 0), (0, 0, 0) )[direction]

        if kind in [ idltype.tk_value,
                     idltype.tk_value_box ]:

            return ( (0, 0, 1), (0, 1, 1), (0, 1, 1), (0, 0, 1) )[direction]

        if kind == idltype.tk_void:
            return (0, 0, 0)

        if kind in unsupported_typecodes:
            util.unsupportedIDL()

        util.fatalError("Unknown type encountered (kind = " + str(kind) + ")")
        return
コード例 #4
0
def run(tree, backend_args):
    # Process arguments
    dirname, filename = os.path.split(tree.file())
    basename, ext = os.path.splitext(filename)
    config.state["Basename"] = basename
    config.state["Directory"] = dirname

    process_args(backend_args)

    try:
        # Check the input tree only contains stuff we understand
        support.checkIDL(tree)

        # initialise the handy ast module
        ast.__init__(tree)

        # Initialise the descriptor generating code
        descriptor.__init__(tree)

        # Build the map of AST nodes to Environments
        tree.accept(id.WalkTree())

        hh_filename = config.state["Basename"] + config.state["HH Suffix"]
        hpp_filename = config.state["Basename"] + config.state["HPP Suffix"]
        hxx_filename = config.state["Basename"] + config.state["HXX Suffix"]
        cc_filename = config.state["Basename"] + config.state["CC Suffix"]
        if config.state["Include Prefix"]:
            prefix = config.state["Include Prefix"] + "/"
        else:
            prefix = ""

        idl_filename = tree.file()

        hpp_stream = output.Stream(output.createFile(hpp_filename), 2)
        hxx_stream = output.Stream(output.createFile(hxx_filename), 2)
        cc_stream = output.Stream(output.createFile(cc_filename), 2)
        main.self = main
        main.__init__(
            hpp_stream,
            hxx_stream,
            cc_stream,
            idl_filename,
            prefix,
            hh_filename,
            hpp_filename,
            hxx_filename,
        )

        main.run(tree)

        hpp_stream.close()
        hxx_stream.close()
        cc_stream.close()

    except AttributeError as e:
        name = e.args[0]
        unsupported_visitors = map(lambda x: "visit" + x,
                                   AST_unsupported_nodes[:])
        if name in unsupported_visitors:
            # delete all possibly partial output files
            for file in output.listAllCreatedFiles():
                os.unlink(file)

            util.unsupportedIDL()

        raise

    except SystemExit:
        # fatalError function throws SystemExit exception
        # delete all possibly partial output files
        for file in output.listAllCreatedFiles():
            os.unlink(file)

        raise