def _unchecked_narrow(self, dest): repoId = dest._NP_RepositoryId try: dest_objref = omniORB.objrefMapping[repoId] if isinstance(self, dest_objref): return self except KeyError: pass return _omnipy.narrow(self, repoId, 0)
def coerceAny(v, fd, td): if fd == td: return v if not tcInternal.equivalentDescriptors(fd, td): return None if type(fd) is not types.TupleType or \ type(td) is not types.TupleType: return None while fd[0] == tcInternal.tv_alias: fd = fd[3] while td[0] == tcInternal.tv_alias: td = td[3] try: if fd == td: return v elif fd[0] == tcInternal.tv_objref: return _omnipy.narrow(v, td[1]) elif fd[0] == tcInternal.tv_struct: l = list(v._values) # Coerce each member for i in range(len(l)): l[i] = coerceAny(l[i], fd[i*2 + 5], td[i*2 + 5]) return apply(td[1], l) elif fd[0] == tcInternal.tv_union: return td[1](v._d, coerceAny(v._v, fd[6][v._d], td[6][v._d])) elif fd[0] == tcInternal.tv_enum: return td[3][v._v] elif fd[0] == tcInternal.tv_sequence: l = v[:] for i in range(len(l)): l[i] = coerceAny(v[i], fd[1], td[1]) return l elif fd[0] == tcInternal.tv_array: l = v[:] for i in range(len(l)): l[i] = coerceAny(v[i], fd[1], td[1]) return l elif fd[0] == tcInternal.tv_except: l = list(v._values) # Coerce each member for i in range(len(l)): l[i] = coerceAny(l[i], fd[i*2 + 5], td[i*2 + 5]) return apply(td[1], l) elif fd[0] == tcInternal.tv__indirect: return coerceAny(v, fd[1][0], td[1][0]) except: return None return None
def coerceAny(v, fd, td): if fd == td: return v if not tcInternal.equivalentDescriptors(fd, td): return None if not (isinstance(fd, tuple) and isinstance(td, tuple)): return None while fd[0] == tcInternal.tv_alias: fd = fd[3] while td[0] == tcInternal.tv_alias: td = td[3] try: if fd == td: return v elif fd[0] == tcInternal.tv_objref: return _omnipy.narrow(v, td[1]) elif fd[0] == tcInternal.tv_struct: l = list(v._values) # Coerce each member for i in range(len(l)): l[i] = coerceAny(l[i], fd[i*2 + 5], td[i*2 + 5]) return td[1](*l) elif fd[0] == tcInternal.tv_union: return td[1](v._d, coerceAny(v._v, fd[6][v._d], td[6][v._d])) elif fd[0] == tcInternal.tv_enum: return td[3][v._v] elif fd[0] == tcInternal.tv_sequence: l = v[:] for i in range(len(l)): l[i] = coerceAny(v[i], fd[1], td[1]) return l elif fd[0] == tcInternal.tv_array: l = v[:] for i in range(len(l)): l[i] = coerceAny(v[i], fd[1], td[1]) return l elif fd[0] == tcInternal.tv_except: l = list(v._values) # Coerce each member for i in range(len(l)): l[i] = coerceAny(l[i], fd[i*2 + 5], td[i*2 + 5]) return td[1](*l) elif fd[0] == tcInternal.tv__indirect: return coerceAny(v, fd[1][0], td[1][0]) except: return None return None