当前位置: 首页>>代码示例>>C++>>正文


C++ TYPE_ERROR函数代码示例

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


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

示例1: slp_cframe_newfunc

PyCFrameObject *
slp_cframe_newfunc(PyObject *func, PyObject *args, PyObject *kwds, unsigned int linked)
{
	PyCFrameObject *cf;

	if (func == NULL || !PyCallable_Check(func))
		TYPE_ERROR("cframe function must be a callable", NULL);
	cf = slp_cframe_new(run_cframe, linked);
	if (cf == NULL)
		return NULL;
	Py_INCREF(func);
	cf->ob1 = func;
	Py_INCREF(args);
	cf->ob2 = args;
	Py_XINCREF(kwds);
	cf->ob3 = kwds;
	return cf;
}
开发者ID:Oize,项目名称:pspstacklesspython,代码行数:18,代码来源:cframeobject.c

示例2: GMPy_Number_Abs

static PyObject *
GMPy_Number_Abs(PyObject *x, CTXT_Object *context)
{
    if (IS_INTEGER(x))
        return GMPy_Integer_Abs(x, context);

    if (IS_RATIONAL_ONLY(x))
        return GMPy_Rational_Abs(x, context);

    if (IS_REAL_ONLY(x))
        return GMPy_Real_Abs(x, context);

    if (IS_COMPLEX_ONLY(x))
        return GMPy_Complex_Abs(x, context);

    TYPE_ERROR("abs() argument type not supported");
    return NULL;
}
开发者ID:godbomb,项目名称:gmpy,代码行数:18,代码来源:gmpy2_abs.c

示例3: Pympany_square

static PyObject *
Pympany_square(PyObject *self, PyObject *other)
{
    if (isInteger(other)) {
        return Pympz_square(self, other);
    }
    else if (isRational(other)) {
        return Pympq_square(self, other);
    }
#ifdef WITHMPFR
    else if (isReal(other)) {
        return Pympfr_sqr(self, other);
    }
#endif

    TYPE_ERROR("square() not supported");
    return NULL;
}
开发者ID:dgquintas,项目名称:my-code-samples,代码行数:18,代码来源:gmpy_mpany.c

示例4: GMPy_Number_Add

static PyObject *
GMPy_Number_Add(PyObject *x, PyObject *y, CTXT_Object *context)
{
    if (IS_INTEGER(x) && IS_INTEGER(y))
        return GMPy_Integer_Add(x, y, context);

    if (IS_RATIONAL(x) && IS_RATIONAL(y))
        return GMPy_Rational_Add(x, y, context);

    if (IS_REAL(x) && IS_REAL(y))
        return GMPy_Real_Add(x, y, context);

    if (IS_COMPLEX(x) && IS_COMPLEX(y))
        return GMPy_Complex_Add(x, y, context);

    TYPE_ERROR("add() argument type not supported");
    return NULL;
}
开发者ID:fuzzylogician,项目名称:gmpy,代码行数:18,代码来源:gmpy2_add.c

示例5: wsgi_iterable_get_next_chunk

inline PyObject*
wsgi_iterable_get_next_chunk(Request* request)
{
  /* Get the next item out of ``request->iterable``, skipping empty ones. */
  PyObject* next;
  while(true) {
    next = PyIter_Next(request->iterator);
    if(next == NULL)
      return NULL;
    if(!PyString_Check(next)) {
      TYPE_ERROR("wsgi iterable items", "strings", next);
      Py_DECREF(next);
      return NULL;
    }
    if(PyString_GET_SIZE(next))
      return next;
    Py_DECREF(next);
  }
}
开发者ID:Logout22,项目名称:bjoern,代码行数:19,代码来源:wsgi.c

示例6: PyChannel_New

PyChannelObject *
PyChannel_New(PyTypeObject *type)
{
	PyChannelObject *c;

	if (type == NULL)
		type = &PyChannel_Type;
	if (!PyType_IsSubtype(type, &PyChannel_Type))
		TYPE_ERROR("channel_new: type must be subtype of channel", NULL);
	c = (PyChannelObject *) type->tp_alloc(type, 0);
	if (c != NULL) {
		c->head = c->tail = (PyTaskletObject *) c;
		c->balance = 0;
		c->chan_weakreflist = NULL;
		*(int*)&c->flags = 0;
		c->flags.preference = -1; /* default fast receive */
	}
	return c;
}
开发者ID:d11,项目名称:rts,代码行数:19,代码来源:channelobject.c

示例7: GMPy_MPZ_popcount

static PyObject *
GMPy_MPZ_popcount(PyObject *self, PyObject *other)
{
    mp_bitcnt_t n;
    MPZ_Object *tempx;

    if ((tempx = GMPy_MPZ_From_Integer(other, NULL))) {
        n = mpz_popcount(tempx->z);
        Py_DECREF((PyObject*)tempx);
        if (n == (mp_bitcnt_t)(-1))
            return PyLong_FromLong(-1);
        else
            return PyIntOrLong_FromMpBitCnt(n);
    }
    else {
        TYPE_ERROR("popcount() requires 'mpz' argument");
        return NULL;
    }
}
开发者ID:BrianGladman,项目名称:gmpy2,代码行数:19,代码来源:gmpy2_mpz_bitops.c

示例8: GMPy_Context_Add

static PyObject *
GMPy_Context_Add(PyObject *self, PyObject *args)
{
    CTXT_Object *context = NULL;

    if (PyTuple_GET_SIZE(args) != 2) {
        TYPE_ERROR("add() requires 2 arguments.");
        return NULL;
    }

    if (self && CTXT_Check(self)) {
        context = (CTXT_Object*)self;
    }
    else {
        CHECK_CONTEXT(context);
    }

    return GMPy_Number_Add(PyTuple_GET_ITEM(args, 0), PyTuple_GET_ITEM(args, 1), context);
}
开发者ID:fuzzylogician,项目名称:gmpy,代码行数:19,代码来源:gmpy2_add.c

示例9: Pympq_sign

static PyObject *
Pympq_sign(PyObject *self, PyObject *other)
{
    long res;
    PympqObject* tempx;

    if (Pympq_Check(other)) {
        res = mpq_sgn(Pympq_AS_MPQ(other));
    }
    else {
        if (!(tempx = Pympq_From_Number(other))) {
            TYPE_ERROR("sign() requires 'mpq' argument");
            return NULL;
        }
        else {
            res = mpq_sgn(tempx->q);
            Py_DECREF((PyObject*)tempx);
        }
    }
    return PyIntOrLong_FromLong(res);
}
开发者ID:chevah,项目名称:python-package,代码行数:21,代码来源:gmpy_mpq.c

示例10: GMPy_MPZ_Function_IsqrtRem

static PyObject *
GMPy_MPZ_Function_IsqrtRem(PyObject *self, PyObject *other)
{
    MPZ_Object *root = NULL, *rem = NULL, *temp = NULL;
    PyObject *result;

    if (!(temp = GMPy_MPZ_From_Integer(other, NULL))) {
        TYPE_ERROR("isqrt_rem() requires 'mpz' argument");
        return NULL;
    }

    if (mpz_sgn(temp->z) < 0) {
        VALUE_ERROR("isqrt_rem() of negative number");
        Py_DECREF((PyObject*)temp);
        return NULL;
    }




    if (!(result = PyTuple_New(2)) ||
        !(root = GMPy_MPZ_New(NULL)) ||
        !(rem = GMPy_MPZ_New(NULL))) {

        /* LCOV_EXCL_START */
        Py_DECREF((PyObject*)temp);
        Py_XDECREF(result);
        Py_XDECREF((PyObject*)root);
        Py_XDECREF((PyObject*)rem);
        return NULL;
        /* LCOV_EXCL_STOP */
    }

    mpz_sqrtrem(root->z, rem->z, temp->z);
    Py_DECREF((PyObject*)temp);
    PyTuple_SET_ITEM(result, 0, (PyObject*)root);
    PyTuple_SET_ITEM(result, 1, (PyObject*)rem);
    return result;
}
开发者ID:martingkelly,项目名称:gmpy,代码行数:39,代码来源:gmpy2_mpz_misc.c

示例11: size_of

size_t size_of(af_dtype type) {
    try {
        switch (type) {
            case f32: return sizeof(float);
            case f64: return sizeof(double);
            case s32: return sizeof(int);
            case u32: return sizeof(unsigned);
            case u8: return sizeof(unsigned char);
            case b8: return sizeof(unsigned char);
            case c32: return sizeof(float) * 2;
            case c64: return sizeof(double) * 2;
            case s16: return sizeof(short);
            case u16: return sizeof(unsigned short);
            case s64: return sizeof(long long);
            case u64: return sizeof(unsigned long long);
            default: TYPE_ERROR(1, type);
        }
    }
    CATCHALL;

    return AF_SUCCESS;
}
开发者ID:9prady9,项目名称:arrayfire,代码行数:22,代码来源:type_util.cpp

示例12: GMPy_MPZ_Function_Bincoef

static PyObject *
GMPy_MPZ_Function_Bincoef(PyObject *self, PyObject *args)
{
    MPZ_Object *result = NULL, *tempx;
    unsigned long n, k;

    if (PyTuple_GET_SIZE(args) != 2) {
        TYPE_ERROR("bincoef() requires two integer arguments");
        return NULL;
    }

    if (!(result = GMPy_MPZ_New(NULL))) {
        /* LCOV_EXCL_START */
        return NULL;
        /* LCOV_EXCL_STOP */
    }

    k = c_ulong_From_Integer(PyTuple_GET_ITEM(args, 1));
    if (k == (unsigned long)(-1) && PyErr_Occurred()) {
        Py_DECREF((PyObject*)result);
        return NULL;
    }

    n = c_ulong_From_Integer(PyTuple_GET_ITEM(args, 0));
    if (!(n == (unsigned long)(-1) && PyErr_Occurred())) {
        /* Use mpz_bin_uiui which should be faster. */
        mpz_bin_uiui(result->z, n, k);
        return (PyObject*)result;
    }

    if (!(tempx = GMPy_MPZ_From_Integer(PyTuple_GET_ITEM(args, 0), NULL))) {
        Py_DECREF((PyObject*)result);
        return NULL;
    }

    mpz_bin_ui(result->z, tempx->z, k);
    Py_DECREF((PyObject*)tempx);
    return (PyObject*)result;
}
开发者ID:martingkelly,项目名称:gmpy,代码行数:39,代码来源:gmpy2_mpz_misc.c

示例13: GMPy_MPZ_Function_IsPrime

static PyObject *
GMPy_MPZ_Function_IsPrime(PyObject *self, PyObject *args)
{
    int i;
    unsigned long reps = 25;
    MPZ_Object* tempx;
    Py_ssize_t argc;

    argc = PyTuple_GET_SIZE(args);

    if (argc == 0 || argc > 2) {
        TYPE_ERROR("is_prime() requires 'mpz'[,'int'] arguments");
        return NULL;
    }

    if (PyTuple_GET_SIZE(args) == 2) {
        reps = c_ulong_From_Integer(PyTuple_GET_ITEM(args, 1));
        if (reps == -1 && PyErr_Occurred()) {
            return NULL;
        }
        /* Silently limit n to a reasonable value. */
        if (reps > 1000) {
            reps = 1000;
        }
    }

    if (!(tempx = GMPy_MPZ_From_Integer(PyTuple_GET_ITEM(args, 0), NULL))) {
        return NULL;
    }

    i = mpz_probab_prime_p(tempx->z, (int)reps);
    Py_DECREF((PyObject*)tempx);

    if (i)
        Py_RETURN_TRUE;
    else
        Py_RETURN_FALSE;
}
开发者ID:martingkelly,项目名称:gmpy,代码行数:38,代码来源:gmpy2_mpz_misc.c

示例14: PyTasklet_New

PyTaskletObject *
PyTasklet_New(PyTypeObject *type, PyObject *func)
{
    PyThreadState *ts = PyThreadState_GET();
    PyTaskletObject *t;

    /* we always need a cstate, so be sure to initialize */
    if (ts->st.initial_stub == NULL) return PyTasklet_New_M(type, func);
    if (func != NULL && !PyCallable_Check(func))
        TYPE_ERROR("tasklet function must be a callable", NULL);
    if (type == NULL) type = &PyTasklet_Type;
    assert(PyType_IsSubtype(type, &PyTasklet_Type));
    t = (PyTaskletObject *) type->tp_alloc(type, 0);
    if (t != NULL) {
        *(int*)&t->flags = 0;
        t->next = NULL;
        t->prev = NULL;
        t->f.frame = NULL;
        if (func == NULL)
            func = Py_None;
        Py_INCREF(func);
        t->tempval = func;
        t->tsk_weakreflist = NULL;
        Py_INCREF(ts->st.initial_stub);
        t->cstate = ts->st.initial_stub;
        t->def_globals = PyEval_GetGlobals();
        Py_XINCREF(t->def_globals);
        if (ts != slp_initial_tstate) {
            /* make sure to kill tasklets with their thread */
            if (slp_ensure_linkage(t)) {
                Py_DECREF(t);
                return NULL;
            }
        }
    }
    return t;
}
开发者ID:newerthcom,项目名称:savagerebirth,代码行数:37,代码来源:taskletobject.c

示例15: GMPy_MPZ_bit_scan1_function

static PyObject *
GMPy_MPZ_bit_scan1_function(PyObject *self, PyObject *args)
{
    mp_bitcnt_t index, starting_bit = 0;
    MPZ_Object *tempx = NULL;

    if (PyTuple_GET_SIZE(args) == 0 || PyTuple_GET_SIZE(args) > 2) {
        goto err;
    }

    if (!(tempx = GMPy_MPZ_From_Integer(PyTuple_GET_ITEM(args, 0), NULL))) {
        goto err;
    }

    if (PyTuple_GET_SIZE(args) == 2) {
        starting_bit = mp_bitcnt_t_From_Integer(PyTuple_GET_ITEM(args, 1));
        if (starting_bit == (mp_bitcnt_t)(-1) && PyErr_Occurred()) {
            goto err_index;
        }
    }

    index = mpz_scan1(tempx->z, starting_bit);

    Py_DECREF((PyObject*)tempx);
    if (index == (mp_bitcnt_t)(-1)) {
        Py_RETURN_NONE;
    }
    else {
        return PyIntOrLong_FromMpBitCnt(index);
    }

  err:
    TYPE_ERROR("bit_scan0() requires 'mpz',['int'] arguments");
  err_index:
    Py_DECREF((PyObject*)tempx);
    return NULL;
}
开发者ID:BrianGladman,项目名称:gmpy2,代码行数:37,代码来源:gmpy2_mpz_bitops.c


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