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

📄 defs.py

📁 编译工具
💻 PY
📖 第 1 页 / 共 5 页
字号:
                    # full definition of the member type. We use                    # templates with abstract virtual functions                    # instead.                    element = element_ptr = seqType.base(environment)                    def bounds(bounded = bounded,                               derivedName = derivedName,                               derived = templateName,                               element = element):                        if bounded:                            ct = template.sequence_bounded_ctors                        else:                            ct = template.sequence_unbounded_ctors                        stream.out(ct, name = derivedName, element=element,                                   bound=bounded, derived=derived)                    stream.out(template.sequence_forward_type,                               name = derivedName,                               derived = templateName,                               element = element,                               bounds = bounds)                else:                    # Normal case using a template class.                    if d_seqType.string():                        element = "_CORBA_String_element"                        element_IN = "char *"                    elif d_seqType.wstring():                        element = "_CORBA_WString_element"                        element_IN = "CORBA::WChar *"                    elif d_seqType.objref():                        element = seqType.base(environment)                        element_IN = element                    # only if an anonymous sequence                    elif seqType.sequence():                        element = d_seqType.sequenceTemplate(environment)                        element_IN = element                    else:                        element = seqType.base(environment)                        element_IN = element                    element_ptr = element_IN                    if d_seqType.string() and not seqType.array():                        element_ptr = "char*"                    elif d_seqType.wstring() and not seqType.array():                        element_ptr = "CORBA::WChar*"                    elif d_seqType.objref() and not seqType.array():                        element_ptr = seqType.base(environment)                    # only if an anonymous sequence                    elif seqType.sequence() and not seqType.array():                        element_ptr = element                    elif d_seqType.typecode():                        element_ptr = "CORBA::TypeCode_member"                        element = element_ptr                        element_IN = element_ptr                    else:                        element_ptr = seqType.base(environment)                    # enums are a special case                    # from o2be_sequence.cc:795:                    # ----                    # gcc requires that the marshalling operators for the                    # element be declared before the sequence template is                    # typedef'd. This is a problem for enums, as the                    # marshalling operators are not yet defined (and are                    # not part of the type itself).                    # ----                    # Note that the fully dereferenced name is used                    friend = "friend"                    if is_global_scope:                        friend = ""                    if d_seqType.enum() and not seqType.array():                        stream.out(template.typedef_enum_oper_friend,                                   element = d_seqType.base(environment),                                   friend = friend)                    # derivedName is the new type identifier                    # element is the name of the basic element type                    # seq_dims contains dimensions if a sequence of arrays                    # templateName contains the template instantiation                    def bounds(bounded = bounded, derivedName = derivedName,                               element_ptr = element_ptr,                               templateName = templateName):                        if bounded:                            ctor_template = template.sequence_bounded_ctors                        else:                            ctor_template = template.sequence_unbounded_ctors                        stream.out(ctor_template,                                   name = derivedName,                                   element = element_ptr,                                   derived = templateName)                    # output the main sequence definition                    stream.out(template.sequence_type,                               name = derivedName,                               derived = templateName,                               bounds = bounds)                                # start building the _var and _out types                element_reference = ""                if not aliasType.array():                    if d_seqType.string():                        # special case alert                        element_reference = element                    elif d_seqType.wstring():                        # special case alert                        element_reference = element                    elif d_seqType.objref():                        element_reference = d_seqType.objRefTemplate("Element",                                                                     environment)                    # only if an anonymous sequence                    elif seqType.sequence():                        element_reference = d_seqType.sequenceTemplate(environment) + "&"                    else:                        element_reference = element + "&"                def subscript_operator_var(stream = stream,                                           is_array = seqType.array(),                                           element_ptr = element_ptr,                                           element_ref = element_reference):                    if is_array:                        stream.out(template.sequence_var_array_subscript,                                   element = element_ptr)                    else:                        stream.out(template.sequence_var_subscript,                                   element = element_ref)                def subscript_operator_out(stream = stream,                                           is_array = seqType.array(),                                           element_ptr = element_ptr,                                           element_ref = element_reference):                    if is_array:                        stream.out(template.sequence_out_array_subscript,                                   element = element_ptr)                    else:                        stream.out(template.sequence_out_subscript,                                   element = element_ref)                                    # write the _var class definition                stream.out(template.sequence_var,                           name = derivedName,                           subscript_operator = subscript_operator_var)                # write the _out class definition                stream.out(template.sequence_out,                           name = derivedName,                           subscript_operator = subscript_operator_out)            else:                util.fatalError("Inexhaustive Case Match")        # ----------------------------------------------------------------        # declarator is an array typedef declarator        elif array_declarator:            all_dims = d.sizes() + alias_dims            dimsString = cxx.dimsToString(d.sizes())            taildims = cxx.dimsToString(d.sizes()[1:])                        typestring = aliasType.member(environment)            # build the _dup loop            def dup_loop(stream = stream, all_dims = all_dims):                loop = cxx.For(stream, all_dims)                stream.out("\n_data@index@ = _s@index@;\n",                           index = loop.index())                loop.end()            # build the _copy loop            def copy_loop(stream = stream, all_dims = all_dims):                loop = cxx.For(stream, all_dims)                stream.out("\n_to@index@ = _from@index@;\n",                           index = loop.index())                loop.end()            stream.out(template.typedef_array,                       name = derivedName,                       type = typestring,                       dims = dimsString,                       taildims = taildims,                       firstdim = repr(all_dims[0]),                       dup_loop = dup_loop,                       copy_loop = copy_loop,                       qualifier = func_qualifier(),                       inline_qualifier = inline_qualifier())            # output the _copyHelper class            if types.variableDecl(node):                stream.out(template.typedef_array_copyHelper,                           var_or_fix = "Variable",                           name = derivedName)                stream.out(template.typedef_array_variable_out_type,                           name = derivedName)            else:                stream.out(template.typedef_array_copyHelper,                           var_or_fix = "Fix",                           name = derivedName)                stream.out(template.typedef_array_fix_out_type,                           name = derivedName)                    def visitMember(node):    memberType = node.memberType()    if node.constrType():        # if the type was declared here, it must be an instance        # of idltype.Declared!        assert isinstance(memberType, idltype.Declared)        memberType.decl().accept(self)def visitStruct(node):    name = node.identifier()    cxx_name = id.mapID(name)    outer_environment = id.lookup(node)    environment = outer_environment.enter(name)    scope = environment.scope()        insideClass = self.__insideClass    self.__insideClass = 1                # Deal with types constructed here    def Other_IDL(stream = stream, node = node, environment = environment):        for m in node.members():            if m.constrType():                m.memberType().decl().accept(self)                # Deal with the actual struct members    def members(stream = stream, node = node, environment = environment):        for m in node.members():            memberType = types.Type(m.memberType())            memtype = memberType.member(environment)            for d in m.declarators():                ident = d.identifier()                cxx_id = id.mapID(ident)                decl_dims = d.sizes()                is_array_declarator = decl_dims != []                # non-arrays of direct sequences are done via a typedef                if not is_array_declarator and memberType.sequence():                    stream.out(template.struct_nonarray_sequence,                               memtype = memtype,                               cxx_id = cxx_id)                else:                    stream.out(template.struct_normal_member,                               memtype = memtype,                               cxx_id = cxx_id,                               dims = cxx.dimsToString(decl_dims))                # Output the structure itself    if types.variableDecl(node):        stream.out(template.struct,                   name = cxx_name,                   fix_or_var = "Variable",                   Other_IDL = Other_IDL,                   members = members)        stream.out(template.struct_variable_out_type,                   name = cxx_name)    else:        stream.out(template.struct,                   name = cxx_name,                   fix_or_var = "Fix",                   Other_IDL = Other_IDL,                   members = members)        stream.out(template.struct_fix_out_type,                   name = cxx_name)        self.__insideClass = insideClass    # TypeCode and Any    if config.state['Typecode']:        # structs in C++ are classes with different default privacy policies        qualifier = const_qualifier(self.__insideModule, self.__insideClass)        stream.out(template.typecode,                   qualifier = qualifier,                   name = cxx_name)def visitStructForward(node):    cxx_name = id.mapID(node.identifier())    stream.out(template.struct_forward, name = cxx_name)def visitException(node):    exname = node.identifier()    cxx_exname = id.mapID(exname)    outer_environment = id.lookup(node)    environment = outer_environment.enter(exname)    scope = environment.scope()        insideClass = self.__insideClass    self.__insideClass = 1    # if the exception has no members, inline some no-ops    no_members = (node.members() == [])    # other types constructed within this one    def Other_IDL(stream = stream, node = node):        for m in node.members():            if m.constrType():                m.memberType().decl().accept(self)    # deal with the exceptions members    def members(stream = stream, node = node, environment = environment):        for m in node.members():            memberType = types.Type(m.memberType())            for d in m.declarators():                decl_dims = d.sizes()                full_dims = decl_dims + memberType.dims()                is_array = full_dims != []                is_array_declarator = decl_dims != []                                memtype = memberType.member(environment)                ident = d.identifier()                cxx_id = id.mapID(ident)                dims_string = cxx.dimsToString(decl_dims)                

⌨️ 快捷键说明

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