Wrap an existing :c:type:`cairo_t *` cdata pointer.

        :type incref: bool
        :param incref:
            Whether increase the :ref:`reference count <refcounting>` now.
        :return:
            A new :class:`Context` instance.
439438
def _from_pointer(cls, pointer, incref):
        
        if pointer == ffi.NULL:
            raise ValueError('Null pointer')
        if incref:
            cairo.cairo_reference(pointer)
        self = object.__new__(cls)
        cls._init_pointer(self, pointer)
        return self
137076
def _refs(obj, named, *ats, **kwds):
    '''
    '''
    if named:
        for a in ats:  # cf. inspect.getmembers()
            if hasattr(obj, a):
                yield _NamedRef(a, getattr(obj, a))
        if kwds:  # kwds are _dir2() args
            for a, o in _dir2(obj, **kwds):
                yield _NamedRef(a, o)
    else:
        for a in ats:  # cf. inspect.getmembers()
            if hasattr(obj, a):
                yield getattr(obj, a)
        if kwds:  # kwds are _dir2() args
            for _, o in _dir2(obj, **kwds):
                yield o
1359309
def p_type_ref(self, p):
        ''
        p[0] = AstTypeRef(
            path=self.path,
            lineno=p.lineno(1),
            lexpos=p.lexpos(1),
            name=p[1],
            args=p[2],
            nullable=p[3],
            ns=None,
        )
1021160
def add_ref(self, name, ref):
        
        if self._name is None:
            self._name = name
        elif name != self._name:
            raise RuntimeError('Contexts can only share between backends of '
                               'the same type')
        self._refs.append(weakref.ref(ref))
1144956
def SpiceUDREPU(f):
    
    @functools.wraps(f)
    def wrapping_udrepu(beg, end, et):
        f(beg, end, et)

    return UDREPU(wrapping_udrepu)
310256
def _add_to_obj(self, rec_curr, typedef_curr, line):
        """"""
        if rec_curr is not None:
            self._add_to_ref(rec_curr, line)
        else:
            add_to_typedef(typedef_curr, line)
332767
def update_retrieved_if_new_multiple_refs(olditem, newitem, days=180, retrieved_pid='P813'):
    

    def is_equal_not_retrieved(oldref, newref):
        """
        Return True if the oldref == newref, NOT including any "retrieved" statements
        :param oldref:
        :param newref:
        :return:
        """
        if len(oldref) != len(newref):
            return False
        oldref_minus_retrieved = [x for x in oldref if x.get_prop_nr() != retrieved_pid]
        newref_minus_retrieved = [x for x in newref if x.get_prop_nr() != retrieved_pid]
        if not all(x in oldref_minus_retrieved for x in newref_minus_retrieved):
            return False
        oldref_retrieved = [x for x in oldref if x.get_prop_nr() == retrieved_pid]
        newref_retrieved = [x for x in newref if x.get_prop_nr() == retrieved_pid]
        if (len(newref_retrieved) != len(oldref_retrieved)):
            return False
        return True

    def ref_overwrite(oldref, newref, days):
        """
        If the newref is the same as the oldref except the retrieved date is `days` newer, return True
                                                       the retrieved date is NOT `days` newer, return False
        the refs are different, return True
        """
        if len(oldref) != len(newref):
            return True
        oldref_minus_retrieved = [x for x in oldref if x.get_prop_nr() != retrieved_pid]
        newref_minus_retrieved = [x for x in newref if x.get_prop_nr() != retrieved_pid]
        if not all(x in oldref_minus_retrieved for x in newref_minus_retrieved):
            return True
        oldref_retrieved = [x for x in oldref if x.get_prop_nr() == retrieved_pid]
        newref_retrieved = [x for x in newref if x.get_prop_nr() == retrieved_pid]
        if (len(newref_retrieved) != len(oldref_retrieved)) or not (
                        len(newref_retrieved) == len(oldref_retrieved) == 1):
            return True
        datefmt = '+%Y-%m-%dT%H:%M:%SZ'
        retold = list([datetime.strptime(r.get_value()[0], datefmt) for r in oldref if r.get_prop_nr() == retrieved_pid])[0]
        retnew = list([datetime.strptime(r.get_value()[0], datefmt) for r in newref if r.get_prop_nr() == retrieved_pid])[0]
        return (retnew - retold).days >= days

    newrefs = newitem.references
    oldrefs = olditem.references

    found_mate = [False] * len(newrefs)
    for new_n, newref in enumerate(newrefs):
        for old_n, oldref in enumerate(oldrefs):
            if is_equal_not_retrieved(oldref, newref):
                found_mate[new_n] = True
                if ref_overwrite(oldref, newref, days):
                    oldrefs[old_n] = newref
    for f_idx, f in enumerate(found_mate):
        if not f:
            oldrefs.append(newrefs[f_idx])
313046
def shapeRef_to_iriref(self, ref: ShExDocParser.ShapeRefContext) -> ShExJ.IRIREF:
        
        if ref.ATPNAME_NS():
            return ShExJ.IRIREF(self._lookup_prefix(ref.ATPNAME_NS().getText()[1:]))
        elif ref.ATPNAME_LN():
            prefix, local = ref.ATPNAME_LN().getText()[1:].split(':', 1)
            return ShExJ.IRIREF(self._lookup_prefix(prefix + ':') + (local if local else ""))
        else:
            return self.shapeexprlabel_to_IRI(ref.shapeExprLabel())
492716
def ref2names2commdct(ref2names, commdct):
    """"""
    for comm in commdct:
        for cdct in comm:
            try:
                refs = cdct['object-list'][0]
                validobjects = ref2names[refs]
                cdct.update({'validobjects':validobjects})
            except KeyError as e:
                continue
    return commdct
1173688
def getrefs(self, reflist):
        
        alist = []
        for element in reflist:
            if element[0].upper() in self.dt:
                for elm in self.dt[element[0].upper()]:
                    alist.append(elm[element[1]])
        return alist
277612
def p_const_ref(self, p):
        ''''''
        p[0] = ast.ConstReference(p[1], lineno=p.lineno(1))
407718
def _iter_refs(obj, named):
    '''
    '''
    r = _getreferents(obj)  # special case
    return _refs(r, named, itor=_nameof(obj) or 'iteref')
249606
function ref () {
  debug('ref()')
  var type = this.constructor
  var origSize = this.buffer.length
  var r = _ref.ref(this.buffer)
  r.type = Object.create(_ref.types.CString)
  r.type.get = function (buf, offset) {
    return new type(_ref.readPointer(buf, offset | 0, origSize))
  }
  r.type.set = function () {
    assert(0, 'implement!!!')
  }
  return r
}
815659
def named_refs(obj):
    
    refs = []
    v = _typedefof(obj)
    if v:
        v = v.refs
        if v and _callable(v):
            for ref in v(obj, True):
                try:
                    refs.append((ref.name, ref.ref))
                except AttributeError:
                    pass
    return refs
40075
def get_reference(self, refobj):
        
        c = cmds.listConnections("%s.referencenode" % refobj, d=False)
        return c[0] if c else None
213579
def show_xref(self, f_a):
        
        if f_a:
            bytecode._PrintSubBanner("XREF Read")
            xrefs_from = f_a.get_xref_read()
            for ref_class, ref_method in xrefs_from:
                bytecode._PrintDefault(ref_method.get_name())
                bytecode._PrintDefault('\n')

            bytecode._PrintDefault('\n')

            bytecode._PrintSubBanner("XREF Write")
            xrefs_to = f_a.get_xref_write()
            for ref_class, ref_method in xrefs_to:
                bytecode._PrintDefault(ref_method.get_name())
                bytecode._PrintDefault('\n')
740755
def _get_ref(data, position, obj_end, opts, element_name):
    """"""
    collection, position = _get_string(
        data, position, obj_end, opts, element_name)
    oid, position = _get_oid(data, position, obj_end, opts, element_name)
    return DBRef(collection, oid), position