• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PyObject_IsInstance函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PyObject_IsInstance函数的典型用法代码示例。如果您正苦于以下问题:C++ PyObject_IsInstance函数的具体用法?C++ PyObject_IsInstance怎么用?C++ PyObject_IsInstance使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PyObject_IsInstance函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: if

PyObject *PyCodec_IgnoreErrors(PyObject *exc)
{
    Py_ssize_t end;
    if (PyObject_IsInstance(exc, PyExc_UnicodeEncodeError)) {
        if (PyUnicodeEncodeError_GetEnd(exc, &end))
            return NULL;
    }
    else if (PyObject_IsInstance(exc, PyExc_UnicodeDecodeError)) {
        if (PyUnicodeDecodeError_GetEnd(exc, &end))
            return NULL;
    }
    else if (PyObject_IsInstance(exc, PyExc_UnicodeTranslateError)) {
        if (PyUnicodeTranslateError_GetEnd(exc, &end))
            return NULL;
    }
    else {
        wrong_exception_type(exc);
        return NULL;
    }
    return Py_BuildValue("(Nn)", PyUnicode_New(0, 0), end);
}
开发者ID:Illirgway,项目名称:cpython,代码行数:21,代码来源:codecs.c


示例2: PyErr_SetString

static PyObject *IOManager_submit(IOManager *self, PyObject *args) {
   PyObject *req_s, *iter;
   IORequest *item;
   Py_ssize_t l;
   int rc;
   struct iocb **cb, **cb_l;
   if (!PyArg_ParseTuple(args, "O", &req_s)) return NULL;

   if ((l = PySequence_Size(req_s)) < 0) return NULL;
   if (l > (self->nr_events - self->pending_events)) {
      PyErr_SetString(PyExc_ValueError, "Queue length exceeded.");
      return NULL;
   }
   
   cb = self->cbs;
   cb_l = cb + (self->nr_events - self->pending_events);
   
   if (!(iter = PyObject_GetIter(req_s))) return NULL;
   for (; (item = (IORequest*) PyIter_Next(iter)); cb++) {
      if (!PyObject_IsInstance((PyObject*) item, (PyObject*) &IORequestType)) {
         Py_DECREF(item);
         PyErr_SetString(PyExc_TypeError, "Elements of argument 0 must be of type IORequest.");
         return IOM_iocb_cleanup(self, cb+1);
      }
      if (cb == cb_l) {
         Py_DECREF(item);
         PyErr_SetString(PyExc_ValueError, "Queue length exceeded (secondary check)");
         return IOM_iocb_cleanup(self, cb+1);
      }
      if (item->submitted) {
         Py_DECREF(item);
         PyErr_SetString(PyExc_ValueError, "Element of argument 0 had already been submitted earlier.");
         return IOM_iocb_cleanup(self, cb+1);
      }
      item->submitted = 1;
      item->iocb.u.c.resfd = self->fd;
      *cb = &item->iocb;
   }
   if (PyErr_Occurred()) return IOM_iocb_cleanup(self, cb);
   
   l = cb - self->cbs;
   rc = io_submit(self->ctx, l, self->cbs);
   if (rc < 0) {
      errno = -rc;
      PyErr_SetFromErrno(PyExc_OSError);
      return IOM_iocb_cleanup(self, cb);
   }
   /* Keep one reference to each element read from the iterable, to make sure
      they aren't deallocated while we wait for their IO requests to complete
   */
   self->pending_events += l;
   Py_RETURN_NONE;
}
开发者ID:sh01,项目名称:gonium,代码行数:53,代码来源:_iomodule.c


示例3: rich_compare

static PyObject*
rich_compare(PyObject *a, PyObject *b, int op)
{
    if (op == Py_EQ || op == Py_NE)
    {
        if (! (PyObject_IsInstance(a, (PyObject*)&ChipNameType) &&
               PyObject_IsInstance(b, (PyObject*)&ChipNameType)))
        {
            Py_INCREF(Py_NotImplemented);
            return Py_NotImplemented;
        }

        sensors_chip_name *c1 = &((ChipName*)a)->chip_name;
        sensors_chip_name *c2 = &((ChipName*)b)->chip_name;

        int equal = (((c1->prefix == NULL && c2->prefix == NULL) ||
                      strcmp(c1->prefix, c2->prefix) == 0) &&
                     c1->bus.type == c2->bus.type &&
                     c1->bus.nr == c2->bus.nr &&
                     c1->addr == c2->addr &&
                     ((c1->path == NULL && c2->path == NULL) ||
                      strcmp(c1->path, c2->path) == 0));

        int ret = op == Py_EQ ? equal : !equal;

        if (ret)
        {
            Py_RETURN_TRUE;
        }

        Py_RETURN_FALSE;
    }
    else
    {
        PyErr_SetString(
            PyExc_TypeError,
            "ChipName only supports the == and != comparison operators");
        return NULL;
    }
}
开发者ID:sophiekovalevsky,项目名称:pysensors,代码行数:40,代码来源:chipname.c


示例4: psyco_conn_cursor

static PyObject *
psyco_conn_cursor(connectionObject *self, PyObject *args, PyObject *keywds)
{
    const char *name = NULL;
    PyObject *obj, *factory = NULL;

    static char *kwlist[] = {"name", "cursor_factory", NULL};

    if (!PyArg_ParseTupleAndKeywords(args, keywds, "|sO", kwlist,
                                     &name, &factory)) {
        return NULL;
    }

    EXC_IF_CONN_CLOSED(self);

    if (self->status != CONN_STATUS_READY &&
        self->status != CONN_STATUS_BEGIN) {
        PyErr_SetString(OperationalError,
                        "asynchronous connection attempt underway");
        return NULL;
    }

    if (name != NULL && self->async == 1) {
        PyErr_SetString(ProgrammingError,
                        "asynchronous connections "
                        "cannot produce named cursors");
        return NULL;
    }

    Dprintf("psyco_conn_cursor: new cursor for connection at %p", self);
    Dprintf("psyco_conn_cursor:     parameters: name = %s", name);

    if (factory == NULL) factory = (PyObject *)&cursorType;
    if (name)
        obj = PyObject_CallFunction(factory, "Os", self, name);
    else
        obj = PyObject_CallFunction(factory, "O", self);

    if (obj == NULL) return NULL;
    if (PyObject_IsInstance(obj, (PyObject *)&cursorType) == 0) {
        PyErr_SetString(PyExc_TypeError,
            "cursor factory must be subclass of psycopg2._psycopg.cursor");
        Py_DECREF(obj);
        return NULL;
    }

    Dprintf("psyco_conn_cursor: new cursor at %p: refcnt = "
        FORMAT_CODE_PY_SSIZE_T,
        obj, obj->ob_refcnt
      );
    return obj;
}
开发者ID:amrik,项目名称:pyvertica,代码行数:52,代码来源:connection_type.c


示例5: pycbc_multiresult_maybe_raise

/**
 * This function raises exceptions from the MultiResult object, as required
 */
int
pycbc_multiresult_maybe_raise(pycbc_MultiResult *self)
{
    PyObject *type = NULL, *value = NULL, *traceback = NULL;

    if (self->errop == NULL && self->exceptions == NULL) {
        return 0;
    }

    if (self->exceptions) {
        PyObject *tuple = PyList_GetItem(self->exceptions, 0);

        assert(tuple);
        assert(PyTuple_Size(tuple) == 3);

        type = PyTuple_GetItem(tuple, 0);
        value = PyTuple_GetItem(tuple, 1);
        traceback = PyTuple_GetItem(tuple, 2);
        PyErr_NormalizeException(&type, &value, &traceback);
        Py_XINCREF(type);
        Py_XINCREF(value);
        Py_XINCREF(traceback);

        assert(PyObject_IsInstance(value, pycbc_helpers.default_exception));

    } else {
        pycbc_Result *res = (pycbc_Result*)self->errop;

        /** Craft an exception based on the operation */
        PYCBC_EXC_WRAP_KEY(PYCBC_EXC_LCBERR, res->rc, "Operational Error", res->key);

        /** Now we have an exception. Let's fetch it back */
        PyErr_Fetch(&type, &value, &traceback);
        PyObject_SetAttrString(value, "result", (PyObject*)res);
    }

    PyObject_SetAttrString(value, "all_results", (PyObject*)self);
    PyErr_Restore(type, value, traceback);

    /**
     * This is needed since the exception object will later contain
     * a reference to ourselves. If we don't free the original exception,
     * then we'll be stuck with a circular reference
     */
    Py_XDECREF(self->exceptions);
    Py_XDECREF(self->errop);
    self->exceptions = NULL;
    self->errop = NULL;


    return 1;
}
开发者ID:esplorio,项目名称:couchbase-python-client,代码行数:55,代码来源:multiresult.c


示例6: initSetIteration

/* initSetIteration
 *
 * Start the set iteration protocol.  See the comments at struct SetIteration.
 *
 * Arguments
 *      i           The address of a SetIteration control struct.
 *      s           The address of the set, bucket, BTree, ..., to be iterated.
 *      useValues   Boolean; if true, and s has values (is a mapping), copy
 *                  them into i->value each time i->next() is called; else
 *                  ignore s's values even if s is a mapping.
 *
 * Return
 *      0 on success; -1 and an exception set if error.
 *      i.usesValue is set to 1 (true) if s has values and useValues was
 *          true; else usesValue is set to 0 (false).
 *      i.set gets a new reference to s, or to some other object used to
 *          iterate over s.
 *      i.position is set to 0.
 *      i.next is set to an appropriate iteration function.
 *      i.key and i.value are left alone.
 *
 * Internal
 *      i.position < 0 means iteration terminated.
 *      i.position = 0 means iteration hasn't yet begun (next() hasn't
 *          been called yet).
 *      In all other cases, i.key, and possibly i.value, own references.
 *          These must be cleaned up, either by next() routines, or by
 *          finiSetIteration.
 *      next() routines must ensure the above.  They should return without
 *          doing anything when i.position < 0.
 *      It's the responsibility of {init, fini}setIteration to clean up
 *          the reference in i.set, and to ensure that no stale references
 *          live in i.key or i.value if iteration terminates abnormally.
 *          A SetIteration struct has been cleaned up iff i.set is NULL.
 */
static int
initSetIteration(SetIteration *i, PyObject *s, int useValues)
{
  i->set = NULL;
  i->position = -1;     /* set to 0 only on normal return */
  i->usesValue = 0;     /* assume it's a set or that values aren't iterated */

  if (PyObject_IsInstance(s, (PyObject *)&BucketType))
    {
      i->set = s;
      Py_INCREF(s);

      if (useValues)
        {
          i->usesValue = 1;
          i->next = nextBucket;
        }
      else
        i->next = nextSet;
    }
  else if (PyObject_IsInstance(s, (PyObject *)&SetType))
    {
      i->set = s;
      Py_INCREF(s);
      i->next = nextSet;
    }
  else if (PyObject_IsInstance(s, (PyObject *)&BTreeType))
    {
      i->set = BTree_rangeSearch(BTREE(s), NULL, NULL, 'i');
      UNLESS(i->set) return -1;

      if (useValues)
        {
          i->usesValue = 1;
          i->next = nextBTreeItems;
        }
      else
        i->next = nextTreeSetItems;
    }
开发者ID:B-Rich,项目名称:BTrees,代码行数:74,代码来源:SetOpTemplate.c


示例7: if

PyObject *PyCodec_IgnoreErrors(PyObject *exc)
{
    Py_ssize_t end;
    if (PyObject_IsInstance(exc, PyExc_UnicodeEncodeError)) {
        if (PyUnicodeEncodeError_GetEnd(exc, &end))
            return NULL;
    }
    else if (PyObject_IsInstance(exc, PyExc_UnicodeDecodeError)) {
        if (PyUnicodeDecodeError_GetEnd(exc, &end))
            return NULL;
    }
    else if (PyObject_IsInstance(exc, PyExc_UnicodeTranslateError)) {
        if (PyUnicodeTranslateError_GetEnd(exc, &end))
            return NULL;
    }
    else {
        wrong_exception_type(exc);
        return NULL;
    }
    /* ouch: passing NULL, 0, pos gives None instead of u'' */
    return Py_BuildValue("(u#n)", &end, 0, end);
}
开发者ID:0xcc,项目名称:python-read,代码行数:22,代码来源:codecs.c


示例8: ChecksumV1_update

static PyObject*
ChecksumV1_update(accuraterip_ChecksumV1* self, PyObject *args)
{
    PyObject *framelist_obj;
    pcm_FrameList *framelist;
    unsigned i;

    if (!PyArg_ParseTuple(args, "O", &framelist_obj))
        return NULL;

    /*ensure framelist_obj is a FrameList object*/
    if (PyObject_IsInstance(framelist_obj, self->framelist_class)) {
        framelist = (pcm_FrameList*)framelist_obj;
    } else {
        PyErr_SetString(PyExc_TypeError, "objects must be of type FrameList");
        return NULL;
    }

    /*ensure FrameList is CD-formatted*/
    if (framelist->channels != 2) {
        PyErr_SetString(PyExc_ValueError,
                        "FrameList must be 2 channels");
        return NULL;
    }
    if (framelist->bits_per_sample != 16) {
        PyErr_SetString(PyExc_ValueError,
                        "FrameList must be 16 bits per sample");
        return NULL;
    }

    /*update CRC with values from FrameList*/
    for (i = 0; i < framelist->frames; i++) {
        if ((self->track_index >= self->start_offset) &&
            (self->track_index <= self->end_offset)) {
            const int left_s = framelist->samples[i * 2];
            const int right_s = framelist->samples[i * 2 + 1];
            const unsigned left_u =
                left_s >= 0 ? left_s : (1 << 16) - (-left_s);
            const unsigned right_u =
                right_s >= 0 ? right_s : (1 << 16) - (-right_s);
            const unsigned value = (right_u << 16) | left_u;

            self->checksum += (value * self->track_index);
        }

        self->track_index++;
    }

    Py_INCREF(Py_None);
    return Py_None;
}
开发者ID:PengYingChuan,项目名称:python-audio-tools,代码行数:51,代码来源:accuraterip.c


示例9: Tokenizer_emit_all

/*
    Write a series of tokens to the current stack at once.
*/
int Tokenizer_emit_all(Tokenizer* self, PyObject* tokenlist)
{
    int pushed = 0;
    PyObject *stack, *token, *left, *right, *text;
    Textbuffer* buffer;
    Py_ssize_t size;

    if (PyList_GET_SIZE(tokenlist) > 0) {
        token = PyList_GET_ITEM(tokenlist, 0);
        switch (PyObject_IsInstance(token, Text)) {
            case 0:
                break;
            case 1: {
                pushed = 1;
                buffer = self->topstack->textbuffer;
                if (buffer->length == 0)
                    break;
                left = Textbuffer_render(buffer);
                if (!left)
                    return -1;
                right = PyObject_GetAttrString(token, "text");
                if (!right)
                    return -1;
                text = PyUnicode_Concat(left, right);
                Py_DECREF(left);
                Py_DECREF(right);
                if (!text)
                    return -1;
                if (PyObject_SetAttrString(token, "text", text)) {
                    Py_DECREF(text);
                    return -1;
                }
                Py_DECREF(text);
                if (Textbuffer_reset(buffer))
                    return -1;
                break;
            }
            case -1:
                return -1;
        }
    }
    if (!pushed) {
        if (Tokenizer_push_textbuffer(self))
            return -1;
    }
    stack = self->topstack->stack;
    size = PyList_GET_SIZE(stack);
    if (PyList_SetSlice(stack, size, size, tokenlist))
        return -1;
    return 0;
}
开发者ID:Tillsa,项目名称:pywikibot_test_wikidata,代码行数:54,代码来源:tok_support.c


示例10: LDAPConnection_init

/*	Initialize the LDAPConnection. */
static int
LDAPConnection_init(LDAPConnection *self, PyObject *args, PyObject *kwds) {
	PyObject *async_obj = NULL;
	PyObject *client = NULL;
	PyObject *ldapclient_type = NULL;
	PyObject *tmp = NULL;
	PyObject *page_size = NULL, *sort_list = NULL;
    static char *kwlist[] = {"client", "async", NULL};

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O!", kwlist, &client,
    		&PyBool_Type, &async_obj)) {
    	return -1;
    }

    if (async_obj != NULL) self->async = PyObject_IsTrue(async_obj);

    ldapclient_type = load_python_object("pyldap.ldapclient", "LDAPClient");
    if (ldapclient_type == NULL ||
    		!PyObject_IsInstance(client, ldapclient_type)) {
    	return -1;
    }
	Py_DECREF(ldapclient_type);

    if (client) {
    	tmp = self->client;
    	Py_INCREF(client);
    	self->client = client;
    	Py_XDECREF(tmp);

    	/* Get page size from the client. */
    	page_size = PyObject_GetAttrString(self->client, "_LDAPClient__page_size");
    	if (page_size == NULL) return -1;
    	self->page_size = (int)PyLong_AsLong(page_size);
    	Py_DECREF(page_size);
    	if (PyErr_Occurred()) return -1;

    	/* Get sort list from the client. */
    	sort_list = PyObject_GetAttrString(self->client, "_LDAPClient__sort_attrs");
    	if (PyList_Size(sort_list) > 0) {
    		self->sort_list = PyList2LDAPSortKeyList(sort_list);
    		if (self->sort_list == NULL) {
    			PyErr_BadInternalCall();
    			return -1;
    		}
    	}

        return connecting(self);
    }
    return -1;
}
开发者ID:ihrwein,项目名称:PyLDAP,代码行数:51,代码来源:ldapconnection.c


示例11: set_errors

    static void set_errors(Tango::EventData &event_data, boost::python::object &error)
    {
        PyObject* error_ptr = error.ptr();
        if (PyObject_IsInstance(error_ptr, PyTango_DevFailed.ptr()))
        {
            Tango::DevFailed df;
	    boost::python::object error_list = error.attr("args");
	    sequencePyDevError_2_DevErrorList(error_list.ptr(), event_data.errors);
        }
        else
        {
            sequencePyDevError_2_DevErrorList(error_ptr, event_data.errors);
        }
    }
开发者ID:bennofs,项目名称:pytango,代码行数:14,代码来源:event_data.cpp


示例12: IsInstanceForThread

bool IsInstanceForThread(PyObject* param, const char* szModule, const char* szClass, PyObject** pcls)
{
    // Like PyObject_IsInstance but compares against a class specific to the current thread's
    // interpreter, for proper subinterpreter support.  Uses GetClassForThread.
    //
    // If `param` is an instance of the given class, true is returned and a new reference to
    // the class, specific to the current thread, is returned via pcls.  The caller is
    // responsible for decrementing the class.
    //
    // If `param` is not an instance, true is still returned (!) but *pcls will be zero.
    //
    // False is only returned when an exception has been raised.  (That is, the return value is
    // not used to indicate whether the instance check matched or not.)

    if (param == 0)
    {
        *pcls = 0;
        return true;
    }

    PyObject* cls = GetClassForThread(szModule, szClass);
    if (!cls)
    {
        *pcls = 0;
        return false;
    }

    int n = PyObject_IsInstance(param, cls);
    // (The checks below can be compressed into just a few lines, but I was concerned it
    //  wouldn't be clear.)

    if (n == 1)
    {
        // We have a match.
        *pcls = cls;
        return true;
    }

    Py_DECREF(cls);
    *pcls = 0;

    if (n == 0)
    {
        // No exception, but not a match.
        return true;
    }

    // n == -1; an exception occurred
    return false;
}
开发者ID:skillian,项目名称:pyodbc,代码行数:50,代码来源:pyodbcmodule.cpp


示例13: _cairo_pattern_to_gvalue

static int
_cairo_pattern_to_gvalue(GValue *value, PyObject *obj)
{
    if (obj == Py_None) {
        g_value_set_boxed(value, NULL);
        return 0;
    }

    if (!(PyObject_IsInstance(obj, (PyObject *) &PycairoPattern_Type)))
        return -1;

    g_value_set_boxed(value, ((PycairoPattern*)(obj))->pattern);
    return 0;
}
开发者ID:BackupTheBerlios,项目名称:pygoocanvas-svn,代码行数:14,代码来源:goocanvasmodule.c


示例14: thunk_ipower

static PyObject *
thunk_ipower(PyObject *a, PyObject *b, PyObject *c)
{
    PyObject *val;

    if (PyObject_IsInstance(a, (PyObject*) &thunk_type)) {
        val = _strict_eval_borrowed(a);
        return PyNumber_InPlacePower(val, b, c);
    }
    else {
        val = _strict_eval_borrowed(b);
        return PyNumber_InPlacePower(a, val, c);
    }
}
开发者ID:pombredanne,项目名称:lazy_python,代码行数:14,代码来源:_thunk.c


示例15: getDerivativeMultiVectorObjectAttr

EpetraExt::ModelEvaluator::DerivativeMultiVector
getDerivativeMultiVectorObjectAttr(PyObject * object, CONST char * name)
{
    static
    PyObject * classDerivativeMultiVector = NULL;
    if (!classDerivativeMultiVector)
    {
        classDerivativeMultiVector = getClassFromModule(PyTrilinosEpetraExt,
                                     "DerivativeMultiVector");
        if (!classDerivativeMultiVector) throw PythonException();
    }
    PyObject * value = PyObject_GetAttrString(object, name);
    if (!value) throw PythonException();
    if (!PyObject_IsInstance(value, classDerivativeMultiVector))
    {
        PyErr_Format(PyExc_TypeError, "Attribute '%s' is not of type DerivativeMultiVector", name);
        Py_DECREF(value);
        throw PythonException();
    }
    // multiVector attribute
    Teuchos::RCP<Epetra_MultiVector> multiVector =
        getEpetraMultiVectorObjectAttr(value, "multiVector");
    // orientation attribute
    EpetraExt::ModelEvaluator::EDerivativeMultiVectorOrientation orientation;
    CONST char * linearity = getStringObjectAttr(value, "linearity");
    if (strncmp(linearity, "mv_by_col", 9) == 0)
        orientation = EpetraExt::ModelEvaluator::DERIV_MV_BY_COL;
    if (strncmp(linearity, "trans_mv_by_row", 15) == 0)
        orientation = EpetraExt::ModelEvaluator::DERIV_TRANS_MV_BY_ROW;
    // paramIndexes attribute
    PyObject * seq = PyObject_GetAttrString(value, "paramIndexes");
    if (!seq) throw PythonException();
    Py_ssize_t len = PySequence_Length(seq);
    if (len < 0) throw PythonException();
    Teuchos::Array<int> paramIndexes(len);
    for (Py_ssize_t i = 0; i < len; ++i)
    {
        PyObject * item = PySequence_GetItem(seq, i);
        if (!item) throw PythonException();
        paramIndexes[i] = (int) PyInt_AsLong(item);
        Py_DECREF(item);
        if (PyErr_Occurred()) throw PythonException();
    }
    Py_DECREF(seq);
    Py_DECREF(value);

    // Result
    return EpetraExt::ModelEvaluator::DerivativeMultiVector(multiVector, orientation,
            paramIndexes);
}
开发者ID:uppatispr,项目名称:trilinos-official,代码行数:50,代码来源:PyTrilinos_EpetraExt_Util.cpp


示例16: psyco_conn_lobject

static PyObject *
psyco_conn_lobject(connectionObject *self, PyObject *args, PyObject *keywds)
{
    Oid oid = InvalidOid, new_oid = InvalidOid;
    const char *new_file = NULL;
    const char *smode = "";
    PyObject *factory = (PyObject *)&lobjectType;
    PyObject *obj;

    static char *kwlist[] = {"oid", "mode", "new_oid", "new_file",
                             "lobject_factory", NULL};

    if (!PyArg_ParseTupleAndKeywords(args, keywds, "|IzIzO", kwlist,
                                     &oid, &smode, &new_oid, &new_file,
                                     &factory)) {
        return NULL;
    }

    EXC_IF_CONN_CLOSED(self);
    EXC_IF_CONN_ASYNC(self, lobject);
    EXC_IF_GREEN(lobject);
    EXC_IF_TPC_PREPARED(self, lobject);

    Dprintf("psyco_conn_lobject: new lobject for connection at %p", self);
    Dprintf("psyco_conn_lobject:     parameters: oid = %u, mode = %s",
            oid, smode);
    Dprintf("psyco_conn_lobject:     parameters: new_oid = %d, new_file = %s",
            new_oid, new_file);

    if (new_file)
        obj = PyObject_CallFunction(factory, "OIsIs",
            self, oid, smode, new_oid, new_file);
    else
        obj = PyObject_CallFunction(factory, "OIsI",
            self, oid, smode, new_oid);

    if (obj == NULL) return NULL;
    if (PyObject_IsInstance(obj, (PyObject *)&lobjectType) == 0) {
        PyErr_SetString(PyExc_TypeError,
            "lobject factory must be subclass of psycopg2.extensions.lobject");
        Py_DECREF(obj);
        return NULL;
    }

    Dprintf("psyco_conn_lobject: new lobject at %p: refcnt = "
            FORMAT_CODE_PY_SSIZE_T,
            obj, Py_REFCNT(obj));
    return obj;
}
开发者ID:gencer,项目名称:psycopg2,代码行数:49,代码来源:connection_type.c


示例17: PyDrawableComponent_new

static PyObject* PyDrawableComponent_new(PyTypeObject* type, PyObject* args, PyObject*)
{
  PyObject* owner;
  if(!PyArg_ParseTuple(args, "O", &owner))
    return NULL;

  if(!PyObject_IsInstance(owner, (PyObject*)&PyEntity_Type)) {
    PyErr_SetString(PyExc_TypeError, "Must pass an Entity object as the owner");
    return NULL;
  }
  
  PyDrawableComponent* c = (PyDrawableComponent*)type->tp_alloc(type, 0);
  c->coord = new DrawableComponent(((PyEntity*)owner)->ent);
  return (PyObject*)c;
}
开发者ID:senseproject,项目名称:SensEngine,代码行数:15,代码来源:DrawableComponent.cpp


示例18: call_if_persistent

PyObject *
call_if_persistent(PyObject *x, PyObject *args)
{
	PyObject *f;     
	PyObject *arg; 
	if (!PyArg_UnpackTuple(args, "", 2, 2, &f, &arg)) {
		return NULL;
	}
	if (PyObject_IsInstance(arg, (PyObject *)&PersistentBase_Type)) {
		return PyObject_CallFunction(f, "O", arg);
 	} else {
		Py_INCREF(Py_None);
		return Py_None;
	}
}
开发者ID:Schevo,项目名称:durus,代码行数:15,代码来源:_persistent.c


示例19: pytype_check

BOOST_PYTHON_DECL PyObject*
pytype_check(PyTypeObject* type_, PyObject* source)
{
    if (!PyObject_IsInstance(source, python::upcast<PyObject>(type_)))
    {
        ::PyErr_Format(
            PyExc_TypeError
            , "Expecting an object of type %s; got an object of type %s instead"
            , type_->tp_name
            , source->ob_type->tp_name
            );
        throw_error_already_set();
    }
    return source;
}
开发者ID:AsherBond,项目名称:PDAL,代码行数:15,代码来源:from_python.cpp


示例20: PyPyCSA_Check

bool PyPyCSA_Check (PyObject* obj)
{
  if (pCSAClasses == 0)
    {
      if (!CSAimported ())
	return false;

      // load CSA library
      bool status = loadCSA ();
      if (!status)
	return false;
    }

  return PyObject_IsInstance (obj, pCSAClasses);
}
开发者ID:QJonny,项目名称:CyNest,代码行数:15,代码来源:pynestpycsa.cpp



注:本文中的PyObject_IsInstance函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PyObject_IsTrue函数代码示例发布时间:2022-05-30
下一篇:
C++ PyObject_Hash函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap