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


C++ PyLong_AsUnsignedLong函数代码示例

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


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

示例1: tcaxlib_convert_tcas_list_to_buf

void tcaxlib_convert_tcas_list_to_buf(PyObject *tcasList, tcas_unit **pTcasBuf, tcas_u32 *pCount) {
    int i, count;
    PyObject *pyTcasItem;
    tcas_s16 x, y;
    tcas_u32 rgb;
    tcas_byte alpha;
    tcas_unit *tcasBuf;
    count = PyList_GET_SIZE(tcasList);
    /* tcas buffer from user tcax py script: (Start, End, Layer_Type_Pair, PosX, PosY, RGB, Alpha) */
    /* a raw tcas chunk defined in TCC file format specification: (Start, End, Layer_Type_Pair, Pos, RGBA) */
    tcasBuf = (tcas_unit *)malloc(count * 5 * sizeof(tcas_unit));
    for (i = 0; i < count; i++) {
        pyTcasItem = PyList_GET_ITEM(tcasList, i);
        x = (tcas_s16)PyLong_AsLong(PyTuple_GET_ITEM(pyTcasItem, 3));
        y = (tcas_s16)PyLong_AsLong(PyTuple_GET_ITEM(pyTcasItem, 4));
        rgb = (tcas_u32)PyLong_AsUnsignedLong(PyTuple_GET_ITEM(pyTcasItem, 5));
        alpha = (tcas_byte)PyLong_AsLong(PyTuple_GET_ITEM(pyTcasItem, 6));
        tcasBuf[5 * i + 0] = (tcas_s32)PyLong_AsLong(PyTuple_GET_ITEM(pyTcasItem, 0));    /* Start */
        tcasBuf[5 * i + 1] = (tcas_s32)PyLong_AsLong(PyTuple_GET_ITEM(pyTcasItem, 1));    /* End */
        tcasBuf[5 * i + 2] = (tcas_unit)PyLong_AsUnsignedLong(PyTuple_GET_ITEM(pyTcasItem, 2));    /* Layer_Type_Pair */
        tcasBuf[5 * i + 3] = MAKEPOS(x, y);
        tcasBuf[5 * i + 4] = (rgb | ((tcas_u32)alpha << 24));
    }
    *pTcasBuf = tcasBuf;
    *pCount = count;
}
开发者ID:Lichtavat,项目名称:TCAX,代码行数:26,代码来源:tcasfunc.c

示例2: gen_mcev_from_evrepr

bool_t gen_mcev_from_evrepr(PyObject *evrepr, uint_t *tick, midicev_t *mcev)
{
  Py_ssize_t    list_len = PyTuple_Size(evrepr);
  unsigned long chan, type, val1, val2;

  if (list_len < 5)
    return FALSE;
  /* todo: more test */
  *tick = (uint_t) PyLong_AsUnsignedLong(PyTuple_GetItem(evrepr, 0));
  chan  = PyLong_AsUnsignedLong(PyTuple_GetItem(evrepr, 1));
  type  = PyLong_AsUnsignedLong(PyTuple_GetItem(evrepr, 2));
  val1  = PyLong_AsUnsignedLong(PyTuple_GetItem(evrepr, 3));
  val2  = PyLong_AsUnsignedLong(PyTuple_GetItem(evrepr, 4));
  mcev->chan = (byte_t) chan;
  mcev->type = (byte_t) type;
  switch (type)
    {
    case NOTEOFF:
    case NOTEON:
      mcev->event.note.num = (byte_t) val1;
      mcev->event.note.val = (byte_t) val2;
      break;
    case CONTROLCHANGE:
      mcev->event.ctrl.num = (byte_t) val1;
      mcev->event.ctrl.val = (byte_t) val2;
      break;
    case PITCHWHEELCHANGE:
      mcev->event.pitchbend.Lval = (byte_t) val1;
      mcev->event.pitchbend.Hval = (byte_t) val2;
      break;
    default:
      ;
    }
  return TRUE;
}
开发者ID:supergilbert,项目名称:midilooper,代码行数:35,代码来源:pym_midiseq_tools.c

示例3: PyMAPIObject_AsSPropTagArray

// @object PySPropTagArray|A sequence of integers
BOOL PyMAPIObject_AsSPropTagArray(PyObject *obta, SPropTagArray **ppta)
{
	if (obta==Py_None) {
		*ppta = NULL;
		return TRUE;
	}
	BOOL bSeq = TRUE;
	int seqLen;
	if (PySequence_Check(obta)) {
		seqLen = PySequence_Length(obta);
	} else if (PyInt_Check(obta)) {
		seqLen = 1;
		bSeq = FALSE;
	} else {
		PyErr_SetString(PyExc_TypeError, "SPropTagArray must be a sequence of integers");
		return FALSE;
	}

	DWORD cBytes = (seqLen * sizeof(ULONG)) + sizeof(ULONG);
	SPropTagArray *pta;
	HRESULT hr = MAPIAllocateBuffer(cBytes, (void **)&pta);
	if (FAILED(hr)) {
		OleSetOleError(hr);
		return FALSE;
	}
	pta->cValues = seqLen;
	if (bSeq) {
		for (ULONG i=0;i<(ULONG)seqLen;i++) {
			PyObject *obItem = PySequence_GetItem(obta, i);
			if (obItem==NULL) {
				MAPIFreeBuffer(pta);
				return FALSE;
			}
			pta->aulPropTag[i] = PyLong_AsUnsignedLong(obItem);
			if (PyErr_Occurred()) {
				Py_DECREF(obItem);
				MAPIFreeBuffer(pta);
				return FALSE;
			}
			Py_DECREF(obItem);
		}
	} else {
		// Simple int.
		pta->aulPropTag[0] = PyLong_AsUnsignedLong(obta);
	}
	*ppta = pta;
	return TRUE;
}
开发者ID:Dechy,项目名称:pywin32,代码行数:49,代码来源:mapiutil.cpp

示例4: convertTo_std_vector_1900

static int convertTo_std_vector_1900(PyObject *sipPy,void **sipCppPtrV,int *sipIsErr,PyObject *sipTransferObj)
{
    std::vector<uint> **sipCppPtr = reinterpret_cast<std::vector<uint> **>(sipCppPtrV);

#line 330 "/home/kdbanman/browseRDF/tulip-3.8.0-src/library/tulip-python/stl/vector.sip"
   // Check if type is compatible
   if (sipIsErr == NULL) {
       if (!PyList_Check(sipPy)) {
          return 0;
       }
       for (SIP_SSIZE_T i = 0; i < PyList_GET_SIZE(sipPy); ++i) {
            PyObject *item = PyList_GET_ITEM(sipPy, i);
            if (!PyLong_Check(item)) {
                printErrorMessage("TypeError : object in list of type " + std::string(item->ob_type->tp_name) + " can not be converted to int");
                return 0;
            }
       }
       return 1;
   }

   // Convert Python list of integers to a std::vector<int>
   std::vector<unsigned int> *v = new std::vector<unsigned int>();
   v->reserve(PyList_GET_SIZE(sipPy));
   for (SIP_SSIZE_T i = 0; i < PyList_GET_SIZE(sipPy); ++i) {
       v->push_back(PyLong_AsUnsignedLong(PyList_GET_ITEM(sipPy, i)));
   }

   *sipCppPtr = v;
   return sipGetState(sipTransferObj);
#line 76 "/home/kdbanman/browseRDF/tulip-3.8.0-src/build/library/tulip-python/stl/sipstlstdvector1900.cpp"
}
开发者ID:kdbanman,项目名称:browseRDF,代码行数:31,代码来源:sipstlstdvector1900.cpp

示例5: lightblueobex_add4byteheader

static int lightblueobex_add4byteheader(obex_t *obex, obex_object_t *obj, uint8_t hi, PyObject *value)
{
    obex_headerdata_t hv;
    uint32_t intvalue;

    DEBUG("%s()\n", __func__);

    if (value == NULL)
        return -1;

    if (PyInt_Check(value)) {
        intvalue = PyInt_AsLong(value);
        if (PyErr_Occurred()) {
            DEBUG("\tcan't convert header 0x%02x int value to long", hi);
            PyErr_Clear();
            return -1;
        }
    } else if (PyLong_Check(value)) {
        intvalue = PyLong_AsUnsignedLong(value);
        if (PyErr_Occurred()) {
            DEBUG("\tcan't convert header 0x%02x long value to long", hi);
            PyErr_Clear();
            return -1;
        }
    } else {
        DEBUG("\theader value for id 0x%02x must be int or long, was %s\n",
                hi, value->ob_type->tp_name);
        return -1;
    }

    hv.bq4 = intvalue;
    return OBEX_ObjectAddHeader(obex, obj, hi, hv, 4, OBEX_FL_FIT_ONE_PACKET);
}
开发者ID:0-1-0,项目名称:lightblue-0.4,代码行数:33,代码来源:lightblueobex_main.c

示例6: __Pyx_PyInt_AsUnsignedLong

static INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_CheckExact(x) || PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned long");
            return (unsigned long)-1;
        }
        return (unsigned long)val;
    } else
#endif
    if (likely(PyLong_CheckExact(x) || PyLong_Check(x))) {
        if (unlikely(Py_SIZE(x) < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned long");
            return (unsigned long)-1;
        }
        return PyLong_AsUnsignedLong(x);
    } else {
        unsigned long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned long)-1;
        val = __Pyx_PyInt_AsUnsignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}
开发者ID:Mouse-Imaging-Centre,项目名称:generate_deformation_fields,代码行数:28,代码来源:setup.c

示例7: PyErr_Clear

bool IntType<SPECIFY_TYPE>::isSameType(PyObject* pyValue)
{
	int ival = 0;
	if(PyLong_Check(pyValue))
	{
		ival = (int)PyLong_AsLong(pyValue);
		if(PyErr_Occurred())
		{
			PyErr_Clear();
			ival = (int)PyLong_AsUnsignedLong(pyValue);
			if (PyErr_Occurred())
			{
				OUT_TYPE_ERROR("INT");
				return false;
			}
		}
	}
	else
	{
		OUT_TYPE_ERROR("INT");
		return false;
	}

	SPECIFY_TYPE val = (SPECIFY_TYPE)ival;
	if(ival != int(val))
	{
		ERROR_MSG("IntType::isSameType:%d is out of range (currVal = %d).\n", ival, int(val));
		return false;
	}
	return true;
}
开发者ID:ChowZenki,项目名称:kbengine,代码行数:31,代码来源:datatype.hpp

示例8: extract

 static T extract(PyObject* intermediate)
 {
     unsigned long x = PyLong_AsUnsignedLong(intermediate);
     if (PyErr_Occurred())
         throw_error_already_set();
     return numeric_cast<T>(x);
 }
开发者ID:RossBille,项目名称:vim-config,代码行数:7,代码来源:builtin_converters.cpp

示例9: Blame_getitem

PyObject *
Blame_getitem(Blame *self, PyObject *value)
{
    size_t i;
    const git_blame_hunk *hunk;

    if (PyLong_Check(value) < 0) {
        PyErr_SetObject(PyExc_IndexError, value);
        return NULL;
    }

    i = PyLong_AsUnsignedLong(value);
    if (PyErr_Occurred()) {
        PyErr_SetObject(PyExc_IndexError, value);
        return NULL;
    }

    hunk = git_blame_get_hunk_byindex(self->blame, i);
    if (!hunk) {
        PyErr_SetObject(PyExc_IndexError, value);
        return NULL;
    }

    return wrap_blame_hunk(hunk, self);
}
开发者ID:carlosmn,项目名称:pygit2,代码行数:25,代码来源:blame.c

示例10: __Pyx_PyInt_AsSignedLong

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
    const signed long neg_one = (signed long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed long");
            return (signed long)-1;
        }
        return (signed long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed long");
                return (signed long)-1;
            }
            return (signed long)PyLong_AsUnsignedLong(x);
        } else {
            return (signed long)PyLong_AsLong(x);
        }
    } else {
        signed long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed long)-1;
        val = __Pyx_PyInt_AsSignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}
开发者ID:skipperkongen,项目名称:the_education_of,代码行数:34,代码来源:hello.c

示例11: Stroke_texture_id_set

static int Stroke_texture_id_set(BPy_Stroke *self, PyObject *value, void *UNUSED(closure))
{
	unsigned int i = PyLong_AsUnsignedLong(value);
	if (PyErr_Occurred())
		return -1;
	self->s->setTextureId(i);
	return 0;
}
开发者ID:diosney,项目名称:blender,代码行数:8,代码来源:BPy_Stroke.cpp

示例12: FEdgeSmooth_material_index_set

static int FEdgeSmooth_material_index_set(BPy_FEdgeSmooth *self, PyObject *value, void *UNUSED(closure))
{
	unsigned int i = PyLong_AsUnsignedLong(value);
	if (PyErr_Occurred())
		return -1;
	self->fes->setFrsMaterialIndex(i);
	return 0;
}
开发者ID:SuriyaaKudoIsc,项目名称:blender-git,代码行数:8,代码来源:BPy_FEdgeSmooth.cpp

示例13: _extract

 void _extract(PyObject *obj, unsigned long &val)
 {
     if (PyInt_Check(obj))
         val = (unsigned long)PyInt_AsUnsignedLongMask(obj);
     else if (PyFloat_Check(obj))
         val = (unsigned long)PyFloat_AsDouble(obj);
     else
         val = PyLong_AsUnsignedLong(obj);
 }
开发者ID:BackupTheBerlios,项目名称:pythonwrapper-svn,代码行数:9,代码来源:PWExtract.cpp

示例14: to_td_val

static void to_td_val(td_val_t *out, PyObject *pVal)
{
    PyObject *pStr;
    td_array_t *arr;
    PyArrayObject *pArr;
    td_tag_t tag = py_type_to_td(pVal);
    switch (tag) {
    case TD_INT32:
        out->tag = TD_INT32;
        if (PyInt_Check(pVal))
            out->int32_val = PyInt_AS_LONG(pVal);
        else
            out->int32_val = PyLong_AsLong(pVal);
        break;
    case TD_UINT32:
        out->tag = TD_UINT32;
        out->uint32_val = PyLong_AsUnsignedLong(pVal);
        break;
    case TD_INT64:
        out->tag = TD_INT64;
        out->int64_val = PyLong_AsLongLong(pVal);
        break;
    case TD_UINT64:
        out->tag = TD_UINT64;
        out->uint64_val = PyLong_AsUnsignedLongLong(pVal);
        break;
    case TD_DOUBLE:
        out->tag = TD_DOUBLE;
        out->double_val = PyFloat_AsDouble(pVal);
        break;
    case TD_UTF8:
        pStr = pVal;
        if (PyUnicode_Check(pStr)) pStr = PyUnicode_AsUTF8String(pStr);
        size_t len = PyString_Size(pStr);
        char* data = malloc((len+1)*sizeof(char));
        strcpy(PyString_AsString(pStr), data);
        td_string_t *obj = malloc(sizeof(td_string_t));
        obj->length = len;
        obj->data = (void*) data;
        out->tag = TD_UTF8;
        out->object = (void*) obj;
        break;
    case TD_ARRAY:
        arr = (td_array_t *)malloc(sizeof(td_array_t));
        pArr = (PyArrayObject *) pVal;
        arr->data = PyArray_DATA(pArr);
        arr->length = PyArray_SIZE(pArr);
        arr->eltype = numpy_type_to_td(PyArray_TYPE(pArr));
        arr->ndims = PyArray_NDIM(pArr);
        break;
    default:
        out->tag = TD_OBJECT;
        out->owner = td_env_python(NULL, NULL);
        out->object = pVal;
    }
}
开发者ID:aterrel,项目名称:xlang,代码行数:56,代码来源:td_python.c

示例15: convertTo_QPair_1900_1900

static int convertTo_QPair_1900_1900(PyObject *sipPy,void **sipCppPtrV,int *sipIsErr,PyObject *sipTransferObj)
{
     ::QPair<uint,uint> **sipCppPtr = reinterpret_cast< ::QPair<uint,uint> **>(sipCppPtrV);

#line 63 "/home/thais/Faculdade/TCC/NEW/PyQt4_gpl_x11-4.12/sip/QtCore/qpair.sip"
    // Check the type if that is all that is required.
    if (sipIsErr == NULL)
        return (PyTuple_Size(sipPy) == 2);

    QPair<unsigned, unsigned> *qp = new QPair<unsigned, unsigned>;
 
    qp->first = PyLong_AsUnsignedLong(PyTuple_GET_ITEM(sipPy, 0));
    qp->second = PyLong_AsUnsignedLong(PyTuple_GET_ITEM(sipPy, 1));

    *sipCppPtr = qp;
 
    return sipGetState(sipTransferObj);
#line 83 "/home/thais/Faculdade/TCC/NEW/PyQt4_gpl_x11-4.12/QtCore/sipQtCoreQPair19001900.cpp"
}
开发者ID:thaisdb,项目名称:TCC,代码行数:19,代码来源:sipQtCoreQPair19001900.cpp


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