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

📄 call.py

📁 编译工具
💻 PY
📖 第 1 页 / 共 3 页
字号:
        self.__out_marshalArgument_shared(marshal_block,0)        stream.out(template.interface_proxy_marshal_returnedvalues,                   call_descriptor = self.__name,                   marshal_block = marshal_block)    def __out_marshalArgument_shared(self,stream,is_in):        n = -1        for argument in self.__arguments:            n = n + 1            if (is_in and not argument.is_in()) or \               (not is_in and not argument.is_out()): continue            arg_n = "arg_" + str(n)            argtype = types.Type(argument.paramType())            ((h_is_const,h_is_ptr),(s_is_holder,s_is_var)) = \                         _arg_info(argtype,argument.direction())            if h_is_ptr:                arg_n = "*" + arg_n            skutil.marshall(stream, None, argtype, None, arg_n, "_n")    def __out_unmarshalArgument(self,stream):        if not self.__has_in_args: return        marshal_block = output.StringStream()        n = -1        for argument in self.__arguments:            n = n + 1            if not argument.is_in(): continue            argtype = types.Type(argument.paramType())            ((h_is_const,h_is_ptr),(s_is_holder,s_is_var)) = \                         _arg_info(argtype,argument.direction())            arg_n = "arg_" + str(n)            if s_is_holder:                storage_n = arg_n            else:                storage_n = arg_n + "_"                            if s_is_var:                alloc = ""                d_type = argtype.deref(1)                if argtype.array():                    alloc = argtype.base() + "_alloc()"                elif not (d_type.typecode() or \                          d_type.string() or \                          d_type.wstring() or \                          d_type.objref()):                    alloc = "new " + argtype.base()                if alloc != "":                    marshal_block.out(storage_n + " = " + alloc + ";")            skutil.unmarshall(marshal_block, None,                              argtype, None, storage_n, "_n")            if not s_is_holder:                if s_is_var:                    if argument.direction() == 0:                        lvalue = storage_n + ".in()"                    else:                        lvalue = storage_n + ".inout()"                else:                    lvalue = storage_n                if argtype.array():                    lvalue = "&" + lvalue + "[0]"                if h_is_ptr:                    marshal_block.out(arg_n + " = &" + lvalue + ";")                else:                    marshal_block.out(arg_n + " = " + lvalue + ";")        if self.__contexts:            marshal_block.out(template.interface_proxy_unmarshal_context)        stream.out(template.interface_proxy_unmarshal_arguments,                   call_descriptor = self.__name,                   marshal_block = marshal_block)    def __out_unmarshalReturnedValues(self,stream):        if not (self.__has_out_args or self.__has_return_value): return        marshal_block = output.StringStream()        if self.__has_return_value:            argtype = types.Type(self.__returntype)            ((h_is_const,h_is_ptr),(s_is_holder,s_is_var)) = \                         _arg_info(argtype,3)            argname = "result"            if s_is_var:                alloc = ""                d_type = argtype.deref(1)                if argtype.array():                    alloc = argtype.base() + "_alloc()"                elif not (d_type.typecode() or \                          d_type.string() or \                          d_type.wstring() or \                          d_type.objref()):                    alloc = "new " + argtype.base()                if alloc != "":                    marshal_block.out(argname + " = " + alloc + ";")            skutil.unmarshall(marshal_block, None,                              argtype, None, argname, "_n")        n = -1        for argument in self.__arguments:            n = n + 1            if not argument.is_out(): continue            argtype = types.Type(argument.paramType())            ((h_is_const,h_is_ptr),(s_is_holder,s_is_var)) = \                         _arg_info(argtype,argument.direction())            arg_n = "arg_" + str(n)            d_type = argtype.deref(1)            if s_is_holder:                if s_is_var:                    alloc = ""                    if argtype.array():                        alloc = argtype.base() + "_alloc()"                    elif not (d_type.typecode() or \                              d_type.string() or \                              d_type.wstring() or \                              d_type.objref()):                        alloc = "new " + argtype.base()                    if alloc != "":                        marshal_block.out(arg_n + " = " + alloc + ";")            elif h_is_ptr:                if d_type.typecode():                    marshal_block.out(arg_n + "_ = *" + arg_n + ";\n"+ \                                      "*" + arg_n + " = " + \                                      "CORBA::TypeCode::_nil();")                elif d_type.objref():                    nilobjref = string.replace(d_type.base(),"_ptr","::_nil()")                    if isinstance(d_type.type().decl(),idlast.Forward):                        nilobjref = string.replace(nilobjref,\                                                   "::_nil()",\                                                   "_Helper::_nil()")                    marshal_block.out(arg_n + "_ = *" + arg_n + ";\n" + \                                      "*" + arg_n + " = " + \                                      nilobjref + ";")                elif d_type.string():                    marshal_block.out(arg_n + "_ = *" + arg_n + ";\n"+ \                                      "*" + arg_n + " = " + \                                      "(char*) _CORBA_String_helper::empty_string;")                elif d_type.string():                    # XXX the empty string constant may be wrong.                    marshal_block.out(arg_n + "_ = *" + arg_n + ";\n" + \                                      "*" + arg_n + " = " + \                                      "(CORBA::WChar*) _CORBA_WString_helper::empty_string;")                arg_n = "*" + arg_n            skutil.unmarshall(marshal_block, None,                              argtype, None, arg_n, "_n")                        stream.out(template.interface_proxy_unmarshal_returnedvalues,                   call_descriptor = self.__name,                   marshal_block = marshal_block)    def __out_userException(self, stream):        if self.__exceptions != []:            block = output.StringStream()            exceptions = skutil.sort_exceptions(self.__exceptions)            repoIDs = []            for exception in exceptions:                scopedName = exception.scopedName()                repoID = scopedName + ["_PD_repoId"]                repoID_str = id.Name(repoID).fullyQualify()                repoIDs.append(repoID_str)                exname = id.Name(scopedName).fullyQualify()                block.out(template.interface_proxy_exn_handle,                          repoID_str = repoID_str, exname = exname)            # write the user exception template            stream.out(template.interface_proxy_exn,                       call_descriptor = self.__name,                       exception_block = str(block),                       exception_namelist = string.join(repoIDs,",\n"))def _arg_info(type,direction):    # Return a tuple containing the information about the mapping of    # this argument type.    # The tuple is of this form:    # (is_const, is_ptr), (same_as_holder, is_var)    # The 1st element is about the argument holder and    #     is_const == 1 if the holder is a const    #     is_ptr == 1 if the holder is a pointer    # The 2nd element is about the argument storage and    #     same_as_holder == 1 if the storage is the same variable as the holder    #     is_var == 1 if the storage is a CORBA _var type, otherwise the    #                 storage is the base type.    assert isinstance(type, types.Type)        if type.array():        if type.variable():            return _arg_array_mapping[_variable][direction]        else:            return _arg_array_mapping[_fixed][direction]    else:        d_type = type.deref(1)        d_kind = d_type.kind()        if _arg_mapping.has_key(d_kind):            return _arg_mapping[d_kind][direction]        else:            assert d_kind == idltype.tk_struct or \                   d_kind == idltype.tk_union            if d_type.variable():                return _arg_struct_mapping[_variable][direction]            else:                return _arg_struct_mapping[_fixed][direction]# (holder_is_const, holder_is_ptr), (storage_same_as_holder, storage_is_var)# See _arg_info for the meaning of these 0s and 1s._arg_mapping = {    idltype.tk_boolean:    ( ((0,0),(1,0)), ((0,0),(1,0)), ((0,1),(0,0)), ((0,0),(1,0)) ),    idltype.tk_char:    ( ((0,0),(1,0)), ((0,0),(1,0)), ((0,1),(0,0)), ((0,0),(1,0)) ),    idltype.tk_octet:    ( ((0,0),(1,0)), ((0,0),(1,0)), ((0,1),(0,0)), ((0,0),(1,0)) ),    idltype.tk_short:    ( ((0,0),(1,0)), ((0,0),(1,0)), ((0,1),(0,0)), ((0,0),(1,0)) ),    idltype.tk_ushort:    ( ((0,0),(1,0)), ((0,0),(1,0)), ((0,1),(0,0)), ((0,0),(1,0)) ),    idltype.tk_long:    ( ((0,0),(1,0)), ((0,0),(1,0)), ((0,1),(0,0)), ((0,0),(1,0)) ),    idltype.tk_ulong:    ( ((0,0),(1,0)), ((0,0),(1,0)), ((0,1),(0,0)), ((0,0),(1,0)) ),    idltype.tk_longlong:    ( ((0,0),(1,0)), ((0,0),(1,0)), ((0,1),(0,0)), ((0,0),(1,0)) ),    idltype.tk_ulonglong:    ( ((0,0),(1,0)), ((0,0),(1,0)), ((0,1),(0,0)), ((0,0),(1,0)) ),    idltype.tk_float:    ( ((0,0),(1,0)), ((0,0),(1,0)), ((0,1),(0,0)), ((0,0),(1,0)) ),    idltype.tk_double:    ( ((0,0),(1,0)), ((0,0),(1,0)), ((0,1),(0,0)), ((0,0),(1,0)) ),    idltype.tk_longdouble:    ( ((0,0),(1,0)), ((0,0),(1,0)), ((0,1),(0,0)), ((0,0),(1,0)) ),    idltype.tk_enum:    ( ((0,0),(1,0)), ((0,0),(1,0)), ((0,1),(0,0)), ((0,0),(1,0)) ),    idltype.tk_wchar:    ( ((0,0),(1,0)), ((0,0),(1,0)), ((0,1),(0,0)), ((0,0),(1,0)) ),    idltype.tk_fixed:    ( ((0,0),(1,0)), ((0,0),(1,0)), ((0,1),(0,0)), ((0,0),(1,0)) ),    idltype.tk_string:    ( ((1,0),(0,1)), ((0,0),(1,1)), ((0,1),(0,1)), ((0,0),(1,1)) ),    idltype.tk_wstring:    ( ((1,0),(0,1)), ((0,0),(1,1)), ((0,1),(0,1)), ((0,0),(1,1)) ),    idltype.tk_sequence:    ( ((1,1),(0,1)), ((0,0),(1,1)), ((0,1),(0,1)), ((0,0),(1,1)) ),    idltype.tk_objref:    ( ((0,0),(0,1)), ((0,0),(1,1)), ((0,1),(0,1)), ((0,0),(1,1)) ),    idltype.tk_TypeCode:    ( ((0,0),(0,1)), ((0,0),(1,1)), ((0,1),(0,1)), ((0,0),(1,1)) ),    idltype.tk_any:    ( ((1,1),(0,1)), ((0,0),(1,1)), ((0,1),(0,1)), ((0,0),(1,1)) ),    idltype.tk_value:    ( ((0,0),(0,1)), ((0,0),(1,1)), ((0,1),(0,1)), ((0,0),(1,1)) ),    }_fixed = 0_variable = 1# See _arg_info for the meaning of these 0s and 1s._arg_struct_mapping = {    _variable:    ( ((1,1),(0,1)), ((0,0),(1,1)), ((0,1),(0,1)), ((0,0),(1,1)) ),    _fixed:    ( ((1,1),(0,0)), ((0,1),(0,0)), ((0,1),(0,0)), ((0,0),(1,0)) )    }# See _arg_info for the meaning of these 0s and 1s._arg_array_mapping = {    _variable:    ( ((1,0),(0,1)), ((0,0),(1,1)), ((0,0),(0,1)), ((0,0),(1,1)) ),    _fixed:                                                          ( ((1,0),(0,0)), ((0,0),(0,0)), ((0,0),(0,0)), ((0,0),(1,1)) )    }                                                      

⌨️ 快捷键说明

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