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

C++ PyLong_AsLongLong函数代码示例

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

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



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

示例1: convert_meta

static int convert_meta(struct srd_proto_data *pdata, PyObject *obj)
{
	long long intvalue;
	double dvalue;

	if (pdata->pdo->meta_type == G_VARIANT_TYPE_INT64) {
		if (!PyLong_Check(obj)) {
			PyErr_Format(PyExc_TypeError, "This output was registered "
					"as 'int', but something else was passed.");
			return SRD_ERR_PYTHON;
		}
		intvalue = PyLong_AsLongLong(obj);
		if (PyErr_Occurred())
			return SRD_ERR_PYTHON;
		pdata->data = g_variant_new_int64(intvalue);
	} else if (pdata->pdo->meta_type == G_VARIANT_TYPE_DOUBLE) {
		if (!PyFloat_Check(obj)) {
			PyErr_Format(PyExc_TypeError, "This output was registered "
					"as 'float', but something else was passed.");
			return SRD_ERR_PYTHON;
		}
		dvalue = PyFloat_AsDouble(obj);
		if (PyErr_Occurred())
			return SRD_ERR_PYTHON;
		pdata->data = g_variant_new_double(dvalue);
	}

	return SRD_OK;
}
开发者ID:hufsm,项目名称:tu_gen2_libsigrokdecode,代码行数:29,代码来源:type_decoder.c


示例2: CListValue

CValue* CValue::ConvertPythonToValue(PyObject* pyobj, const char *error_prefix)
{

	CValue* vallie = NULL;
	/* refcounting is broking here! - this crashes anyway, just store a python list for KX_GameObject */
#if 0
	if (PyList_Check(pyobj))
	{
		CListValue* listval = new CListValue();
		bool error = false;

		int i;
		int numitems = PyList_Size(pyobj);
		for (i=0;i<numitems;i++)
		{
			PyObject* listitem = PyList_GetItem(pyobj,i); /* borrowed ref */
			CValue* listitemval = ConvertPythonToValue(listitem, error_prefix);
			if (listitemval)
			{
				listval->Add(listitemval);
			} else
			{
				error = true;
			}
		}
		if (!error)
		{
			// jippie! could be converted
			vallie = listval;
		} else
		{
			// list could not be converted... bad luck
			listval->Release();
		}

	} else
#endif
	if (PyFloat_Check(pyobj))
	{
		vallie = new CFloatValue( (float)PyFloat_AsDouble(pyobj) );
	} else
	if (PyLong_Check(pyobj))
	{
		vallie = new CIntValue( (cInt)PyLong_AsLongLong(pyobj) );
	} else
	if (PyUnicode_Check(pyobj))
	{
		vallie = new CStringValue(_PyUnicode_AsString(pyobj),"");
	} else
	if (PyObject_TypeCheck(pyobj, &CValue::Type)) /* Note, dont let these get assigned to GameObject props, must check elsewhere */
	{
		vallie = (static_cast<CValue *>(BGE_PROXY_REF(pyobj)))->AddRef();
	} else
	{
		/* return an error value from the caller */
		PyErr_Format(PyExc_TypeError, "%scould convert python value to a game engine property", error_prefix);
	}
	return vallie;

}
开发者ID:jinjoh,项目名称:NOOR,代码行数:60,代码来源:Value.cpp


示例3: pyobject_to_ligotimegps

static int pyobject_to_ligotimegps(PyObject *obj, LIGOTimeGPS *gps)
{
	if(pylal_LIGOTimeGPS_Check(obj)) {
		*gps = ((pylal_LIGOTimeGPS *) obj)->gps;
	} else if(PyInt_Check(obj)) {
		XLALGPSSet(gps, PyInt_AsLong(obj), 0);
	} else if(PyLong_Check(obj)) {
		XLALGPSSet(gps, PyLong_AsLongLong(obj), 0);
	} else if(PyFloat_Check(obj)) {
		XLALGPSSetREAL8(gps, PyFloat_AsDouble(obj));
	} else if(PyComplex_Check(obj)) {
		if(PyComplex_ImagAsDouble(obj) != 0.0) {
			XLALGPSSet(gps, 0, 0);
			PyErr_SetObject(PyExc_ValueError, obj);
			return 0;
		}
		XLALGPSSetREAL8(gps, PyComplex_RealAsDouble(obj));
	} else {
		PyObject *s_attr = PyObject_GetAttrString(obj, "seconds");
		PyObject *n_attr = PyObject_GetAttrString(obj, "nanoseconds");
		XLALGPSSet(gps, PyInt_AsLong(s_attr), PyInt_AsLong(n_attr));
		Py_XDECREF(s_attr);
		Py_XDECREF(n_attr);
		if(PyErr_Occurred()) {
			PyErr_SetObject(PyExc_TypeError, obj);
			return 0;
		}
	}
	return 1;
}
开发者ID:Solaro,项目名称:lalsuite,代码行数:30,代码来源:ligotimegps.c


示例4: PyErr_Format

static PyObject *Triton_stopAnalysisFromAddr(PyObject *self, PyObject *addr) {
  if (!PyLong_Check(addr) && !PyInt_Check(addr))
    return PyErr_Format(PyExc_TypeError, "stopAnalysisFromAddr(): expected an address (integer) as argument");

  PyTritonOptions::stopAnalysisFromAddr.insert(PyLong_AsLongLong(addr));
  Py_INCREF(Py_None);
  return Py_None;
}
开发者ID:shenyanjun,项目名称:Triton,代码行数:8,代码来源:tritonCallbacks.cpp


示例5: convert_binop

static int convert_binop(PyObject *v, PyObject *w, LONG_LONG *a, LONG_LONG *b)
 {
	 if (PgInt8_Check(v))
	 { 
		 *a = PgInt8_AS_LONGLONG(v);
	 }
	 else if (PyLong_Check(v))
	 { 
		 *a = PyLong_AsLongLong(v);

		 if (*a == -1 && PyErr_Occurred())
			 return 0;
	 }
	 else if (PyInt_Check(v)) {
		 *a = (LONG_LONG)(PyInt_AS_LONG(v));
	 }
	 else
	 {
		 return 0;
	 }

	 if (w == Py_None)
		 return 1;
	 else if (PgInt8_Check(w))
	 { 
		 *b = PgInt8_AS_LONGLONG(w);
	 }
	 else if (PyLong_Check(w))
	 {
		 *b = PyLong_AsLongLong(w);

		 if (*b == -1 && PyErr_Occurred())
			 return 0;
	 }
	 else if (PyInt_Check(w))
	 {
		 *b = (LONG_LONG)(PyInt_AS_LONG(w));
	 }
	 else
	 {
		 return 0;
	 }

	 return 1;
}
开发者ID:wiredfool,项目名称:PyPgSQL,代码行数:45,代码来源:pgint8object.c


示例6: _extract

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


示例7: extra_read_post

PyObject* extra_read_post(Reader* r, PyObject* extra, int version) {
    PyObject* result = NULL;
    if (PyDict_Check(extra)) {
        if (is_listlike_dict(extra)) {
            result = PyList_New(PyDict_Size(extra));

            PyObject *key, *value;
            Py_ssize_t pos = 0;
            while (PyDict_Next(extra, &pos, &key, &value)) {
                // is_listlike_dict already checked for overflow.
                int64_t idx = PyLong_AsLongLong(key);
                PyObject* new_value = extra_read_post(r, value, version);
                FAIL_IF(new_value == NULL);

                // Subtract 1 to adjust for Lua's 1-based lists.
                if (PyList_SetItem(result, idx - 1, new_value) < 0) {
                    Py_DECREF(new_value);
                    goto fail;
                }
            }
        } else {
            result = PyDict_New();

            PyObject *key, *value;
            Py_ssize_t pos = 0;
            while (PyDict_Next(extra, &pos, &key, &value)) {
                PyObject* new_value = extra_read_post(r, value, version);
                FAIL_IF(new_value == NULL);

                // Subtract 1 to adjust for Lua's 1-based lists.
                if (PyDict_SetItem(result, key, new_value) < 0) {
                    Py_DECREF(new_value);
                    goto fail;
                }
            }
        }
    } else if (PyObject_TypeCheck(extra, &ClientIdType) ||
            PyObject_TypeCheck(extra, &EntityIdType) ||
            PyObject_TypeCheck(extra, &InventoryIdType) ||
            PyObject_TypeCheck(extra, &StructureIdType)) {
        uint32_t id = ((AnyId*)extra)->id;
        result = read_find_object(r, id);
        FAIL_IF(result == NULL);
        Py_INCREF(result);
    } else {
        result = extra;
        Py_INCREF(result);
    }

    return result;

fail:
    SET_EXC();
    Py_XDECREF(result);
    return NULL;
}
开发者ID:OliveBloom,项目名称:everfree-outpost,代码行数:56,代码来源:extra.c


示例8: PyTuple_Size

// Register a timed callback.
// First argument should be the time in picoseconds
// Second argument is the function to call
// Remaining arguments and keyword arguments are to be passed to the callback
static PyObject *register_timed_callback(PyObject *self, PyObject *args)
{
    FENTER

    PyObject *fArgs;
    PyObject *function;
    gpi_sim_hdl hdl;
    uint64_t time_ps;

    p_callback_data callback_data_p;

    Py_ssize_t numargs = PyTuple_Size(args);

    if (numargs < 2) {
        fprintf(stderr, "Attempt to register timed callback without enough arguments!\n");
        return NULL;
    }

    // Extract the time
    PyObject *pTime = PyTuple_GetItem(args, 0);
    time_ps = PyLong_AsLongLong(pTime);

    // Extract the callback function
    function = PyTuple_GetItem(args, 1);
    if (!PyCallable_Check(function)) {
        fprintf(stderr, "Attempt to register timed callback without passing a callable callback!\n");
        return NULL;
    }
    Py_INCREF(function);

    // Remaining args for function
    fArgs = PyTuple_GetSlice(args, 2, numargs);   // New reference
    if (fArgs == NULL) {
        return NULL;
    }

    callback_data_p = (p_callback_data)malloc(sizeof(s_callback_data));
    if (callback_data_p == NULL) {
        return PyErr_NoMemory();
    }

    // Set up the user data (no more python API calls after this!)
    callback_data_p->_saved_thread_state = PyThreadState_Get();
    callback_data_p->id_value = COCOTB_ACTIVE_ID;
    callback_data_p->function = function;
    callback_data_p->args = fArgs;
    callback_data_p->kwargs = NULL;

    hdl = gpi_register_timed_callback((gpi_function_t)handle_gpi_callback, callback_data_p, time_ps);

    // Check success
    PyObject *rv = PyLong_FromVoidPtr(hdl);
    FEXIT

    return rv;
}
开发者ID:TC01,项目名称:cocotb,代码行数:60,代码来源:simulatormodule.c


示例9: 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


示例10: AerospikeClient_CheckForMeta

/**
 *******************************************************************************************************
 * This function checks for metadata and if present set it into the
 * as_operations.
 *
 * @param py_meta               The dictionary of metadata.
 * @param ops                   The as_operations object.
 * @param err                   The as_error to be populated by the function
 *                              with the encountered error if any.
 *
 * Returns nothing.
 *******************************************************************************************************
 */
static
void AerospikeClient_CheckForMeta(PyObject * py_meta, as_operations * ops, as_error *err)
{
	if ( py_meta && PyDict_Check(py_meta) ) {
		PyObject * py_gen = PyDict_GetItemString(py_meta, "gen");
		PyObject * py_ttl = PyDict_GetItemString(py_meta, "ttl");
        uint32_t ttl = 0;
        uint16_t gen = 0; 
		if ( py_ttl != NULL ){
			if ( PyInt_Check(py_ttl) ) {
				ttl = (uint32_t) PyInt_AsLong(py_ttl);
			} else if ( PyLong_Check(py_ttl) ) {
				ttl = (uint32_t) PyLong_AsLongLong(py_ttl);
			} else {
				as_error_update(err, AEROSPIKE_ERR_PARAM, "Ttl should be an int or long");
			}

            if((uint32_t)-1 == ttl) {
                as_error_update(err, AEROSPIKE_ERR_PARAM, "integer value for ttl exceeds sys.maxsize");
                return;
            }
            ops->ttl = ttl;
		}

		if( py_gen != NULL ){
			if ( PyInt_Check(py_gen) ) {
				gen = (uint16_t) PyInt_AsLong(py_gen);
			} else if ( PyLong_Check(py_gen) ) {
				gen = (uint16_t) PyLong_AsLongLong(py_gen);
			} else {
				as_error_update(err, AEROSPIKE_ERR_PARAM, "Generation should be an int or long");
			}

            if((uint16_t)-1 == gen) {
                as_error_update(err, AEROSPIKE_ERR_PARAM, "integer value for gen exceeds sys.maxsize");
                return;
            }
            ops->gen = gen;
		}
	} else {
		as_error_update(err, AEROSPIKE_ERR_PARAM, "Metadata should be of type dictionary");
	}
}
开发者ID:arthurprs,项目名称:aerospike-client-python,代码行数:56,代码来源:operate.c


示例11: PyArg_ParseTuple

static PyObject *smt2lib_extract(PyObject *self, PyObject *args) {
  PyObject *op1 = nullptr;
  PyObject *op2 = nullptr;
  PyObject *op3 = nullptr;

  /* Extract arguments */
  PyArg_ParseTuple(args, "|OOO", &op1, &op2, &op3);

  if (op1 == nullptr || (!PyLong_Check(op1) && !PyInt_Check(op1)))
    return PyErr_Format(PyExc_TypeError, "extract(): expected an integer as first argument");

  if (op2 == nullptr || (!PyLong_Check(op2) && !PyInt_Check(op2)))
    return PyErr_Format(PyExc_TypeError, "extract(): expected an integer as second argument");

  if (op3 == nullptr || !PySmtAstNode_Check(op3))
    return PyErr_Format(PyExc_TypeError, "extract(): expected a SmtAstNode as third argument");

  return PySmtAstNode(smt2lib::extract(PyLong_AsLongLong(op1), PyLong_AsLongLong(op2), PySmtAstNode_AsSmtAstNode(op3)));
}
开发者ID:shenyanjun,项目名称:Triton,代码行数:19,代码来源:smt2libCallbacks.cpp


示例12: pylong_to_int64

long long
pylong_to_int64(PyObject *pyid)
{
    long long id;

    id = PyLong_AsLongLong(pyid);
    if (id < 1 && !PyErr_Occurred()) {
        set_error(PyExc_OverflowError, "key is lesser than minimum");
    }
    return id;
}
开发者ID:assad2012,项目名称:tokyo-python,代码行数:11,代码来源:dystopia.c


示例13: py_type_to_td

static td_tag_t py_type_to_td(PyObject *pVal)
{
    if (PyInt_Check(pVal)){
#if INT32_MAX==LONG_MAX
        return TD_INT32;
#else
        return longlong_to_td(PyInt_AS_LONG(pVal));
#endif
    }
    else if (PyLong_Check(pVal)){
        PyObject *pErr;
        long long v;
        v = PyLong_AsLongLong(pVal);
        if ( v == -1 && PyErr_Occurred()) {
            // could not eval as long long try unsigned long long later
            PyErr_Clear();
        }
        else {
        	return longlong_to_td(PyInt_AS_LONG(v));
        }

        unsigned long long vv;
        vv = PyLong_AsUnsignedLongLong(pVal);
        if ( v == (unsigned long long) -1 && PyErr_Occurred() ) {
            PyErr_Clear();
            return TD_OBJECT;
        }
        else {
            return TD_UINT64;
        }
    }
    else if (PyFloat_Check(pVal)) {
        return TD_DOUBLE;
    }
    else if (PyUnicode_Check(pVal)){
        PyObject *pStr;
        pStr = PyUnicode_AsUTF8String(pVal);
        if ( pStr && PyErr_Occurred() ){
            PyErr_Clear();
            return TD_OBJECT;
        }
        else {
            return TD_UTF8;
        }
    }
    else if (PyString_Check(pVal)) {
        return TD_UTF8;
    }
    else if (PyArray_Check(pVal)) {
        return TD_ARRAY;
    }
    return TD_OBJECT;
}
开发者ID:gvidaver,项目名称:xlang,代码行数:53,代码来源:td_python.c


示例14: PyObject_CallMethod

static void *PyDateTimeToINT64(JSOBJ _obj, JSONTypeContext *tc, void *outValue, size_t *_outLen)
{
	PyObject *obj = (PyObject *) _obj;

	PyObject* timetuple = PyObject_CallMethod(obj, "utctimetuple", NULL);
	PyObject* unixTimestamp = PyObject_CallMethodObjArgs(mod_calendar, meth_timegm, timetuple, NULL);
	
	*( (JSINT64 *) outValue) = PyLong_AsLongLong (unixTimestamp);
	Py_DECREF(timetuple);
	Py_DECREF(unixTimestamp);
	return NULL;
}
开发者ID:paintcan,项目名称:ultrajson,代码行数:12,代码来源:objToJSON.c


示例15: pyobject_to_int64

int64_t pyobject_to_int64(PyObject * py_obj)
{
	if ( PyInt_Check(py_obj) ) {
		return PyInt_AsLong(py_obj);
	}
	else if ( PyLong_Check(py_obj) ) {
		return PyLong_AsLongLong(py_obj);
	}
	else {
		return 0;
	}
}
开发者ID:andersonbd1,项目名称:aerospike-client-python,代码行数:12,代码来源:where.c


示例16: Command_setattr

static int
Command_setattr(twopence_Command *self, char *name, PyObject *v)
{
	if (!strcmp(name, "stdout")) {
		if (v != Py_None && !PyByteArray_Check(v))
			goto bad_attr;
		assign_object(&self->stdout, v);
		return 0;
	}
	if (!strcmp(name, "stderr")) {
		if (v != Py_None && !PyByteArray_Check(v))
			goto bad_attr;
		assign_object(&self->stderr, v);
		return 0;
	}
	if (!strcmp(name, "user")) {
		char *s;

		if (!PyString_Check(v) || (s = PyString_AsString(v)) == NULL)
			goto bad_attr;
		assign_string(&self->user, s);
		return 0;
	}
	if (!strcmp(name, "timeout")) {
		if (PyInt_Check(v))
			self->timeout = PyInt_AsLong(v);
		else if (PyLong_Check(v))
			self->timeout = PyLong_AsLongLong(v);
		else
			goto bad_attr;
		return 0;
	}
	if (!strcmp(name, "quiet")) {
		self->quiet = !!(PyObject_IsTrue(v));
		return 0;
	}
	if (!strcmp(name, "useTty")) {
		self->useTty = !!(PyObject_IsTrue(v));
		return 0;
	}
	if (!strcmp(name, "background")) {
		self->background = !!(PyObject_IsTrue(v));
		return 0;
	}

	(void) PyErr_Format(PyExc_AttributeError, "Unknown attribute: %s", name);
	return -1;

bad_attr:
	(void) PyErr_Format(PyExc_AttributeError, "Incompatible value for attribute: %s", name);
	return -1;

}
开发者ID:CasaMallo,项目名称:twopence,代码行数:53,代码来源:command.c


示例17: PyArg_ParseTuple

static PyObject *Triton_getSyscallArgument(PyObject *self, PyObject *args) {
  PyObject *num = nullptr;
  PyObject *std = nullptr;
  uint64 ret;

  /* Extract arguments */
  PyArg_ParseTuple(args, "|OO", &std, &num);

  if (std == nullptr || (!PyLong_Check(std) && !PyInt_Check(std)))
    return PyErr_Format(PyExc_TypeError, "getSyscallArgument(): expected an id (integer) as first argument");

  if (num == nullptr || (!PyLong_Check(num) && !PyInt_Check(num)))
    return PyErr_Format(PyExc_TypeError, "getSyscallArgument(): expected an id (integer) as second argument");

  LEVEL_CORE::SYSCALL_STANDARD standard = static_cast<LEVEL_CORE::SYSCALL_STANDARD>(PyLong_AsLongLong(std));;
  CONTEXT *ctx = static_cast<CONTEXT*>(ap.getCurrentCtxH()->getCtx());

  ret = PIN_GetSyscallArgument(ctx, standard, PyLong_AsLongLong(num));

  return PyLong_FromLongLong(ret);
}
开发者ID:shenyanjun,项目名称:Triton,代码行数:21,代码来源:tritonCallbacks.cpp


示例18: PyObject_AsPROPVARIANT

BOOL PyObject_AsPROPVARIANT(PyObject *ob, PROPVARIANT *pVar)
{
	if (ob==Py_None) {
		PropVariantInit(pVar);
	} else if (ob==Py_True) {
		pVar->boolVal = -1;
		pVar->vt = VT_BOOL;
	} else if (ob==Py_False) {
		pVar->boolVal = 0;
		pVar->vt = VT_BOOL;
	} else if (PyLong_Check(ob)) {
		pVar->hVal.QuadPart = PyLong_AsLongLong(ob);
		if (pVar->hVal.QuadPart == -1 && PyErr_Occurred()){
		// Could still fit in an unsigned long long
			PyErr_Clear();
			pVar->uhVal.QuadPart = PyLong_AsUnsignedLongLong(ob);
			if (pVar->uhVal.QuadPart == -1 && PyErr_Occurred())
				return FALSE;
			pVar->vt = VT_UI8;
		}
		else{
			pVar->vt=VT_I8;
			// Could still fit in a regular long
			if (pVar->hVal.QuadPart >= LONG_MIN && pVar->hVal.QuadPart <= LONG_MAX){
				pVar->lVal = (long)pVar->hVal.QuadPart;
				pVar->vt = VT_I4;
			}
			// ... or an unsigned long
			else if (pVar->hVal.QuadPart >=0 && pVar->hVal.QuadPart <= ULONG_MAX){
				pVar->ulVal = (unsigned long)pVar->hVal.QuadPart;
				pVar->vt = VT_UI4;
			}
		}
#if (PY_VERSION_HEX < 0x03000000)
	// Not needed in Py3k, as PyInt_Check is defined to PyLong_Check
	} else if (PyInt_Check(ob)) {
		pVar->lVal = PyInt_AsLong(ob);
		pVar->vt = VT_I4;
#endif
	} else if (PyFloat_Check(ob)) {
		pVar->dblVal = PyFloat_AsDouble(ob);
		pVar->vt = VT_R8;
	} else if (PyUnicode_Check(ob) || PyString_Check(ob)) {
		PyWinObject_AsBstr(ob, &pVar->bstrVal);
		pVar->vt = VT_BSTR;
	} else {
		PyErr_SetString(PyExc_TypeError, "Unsupported object for PROPVARIANT");
		return FALSE;
	}
	return TRUE;
}
开发者ID:malrsrch,项目名称:pywin32,代码行数:51,代码来源:PyIPropertyStorage.cpp


示例19: py_auth_user_info_set_force_password_change

static int py_auth_user_info_set_force_password_change(PyObject *py_obj, PyObject *value, void *closure)
{
	struct auth_user_info *object = (struct auth_user_info *)py_talloc_get_ptr(py_obj);
	if (PyLong_Check(value)) {
		object->force_password_change = PyLong_AsLongLong(value);
	} else if (PyInt_Check(value)) {
		object->force_password_change = PyInt_AsLong(value);
	} else {
		PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
		  PyInt_Type.tp_name, PyLong_Type.tp_name);
		return -1;
	}
	return 0;
}
开发者ID:nikatshun,项目名称:asuswrt-merlin,代码行数:14,代码来源:py_auth.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ PyLong_AsSsize_t函数代码示例发布时间:2022-05-30
下一篇:
C++ PyLong_AsLong函数代码示例发布时间: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