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


C++ PyList_GetItem函数代码示例

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


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

示例1: pyth_metric_init


//.........这里部分代码省略.........
            continue;

        PyEval_RestoreThread(gtstate);

        pmod = PyImport_ImportModule(modname);
        if (!pmod) {
            /* Failed to import module. Log? */
            err_msg("[PYTHON] Can't import the metric module [%s].\n", modname);
            if (PyErr_Occurred()) {
                PyErr_Print();
            }
            gtstate = PyEval_SaveThread();
            continue;
        }

        pinitfunc = PyObject_GetAttrString(pmod, "metric_init");
        if (!pinitfunc || !PyCallable_Check(pinitfunc)) {
            /* No metric_init function. */
            err_msg("[PYTHON] Can't find the metric_init function in the python module [%s].\n", modname);
            Py_DECREF(pmod);
            gtstate = PyEval_SaveThread();
            continue;
        }

        /* Build a parameter dictionary to pass to the module */
        pparamdict = build_params_dict(module_cfg);
        if (!pparamdict || !PyDict_Check(pparamdict)) {
            /* No metric_init function. */
            err_msg("[PYTHON] Can't build the parameters dictionary for [%s].\n", modname);
            Py_DECREF(pmod);
            gtstate = PyEval_SaveThread();
            continue;
        }

        /* Now call the metric_init method of the python module */
        pobj = PyObject_CallFunction(pinitfunc, "(N)", pparamdict);

        if (!pobj) {
            /* failed calling metric_init */
            err_msg("[PYTHON] Can't call the metric_init function in the python module [%s].\n", modname);
            if (PyErr_Occurred()) {
                PyErr_Print();
            }
            Py_DECREF(pinitfunc);
            Py_DECREF(pmod);
            gtstate = PyEval_SaveThread();
            continue;
        }

        if (PyList_Check(pobj)) {
            int j;
            int size = PyList_Size(pobj);
            for (j = 0; j < size; j++) {
                PyObject* plobj = PyList_GetItem(pobj, j);
                if (PyMapping_Check(plobj)) {
                    fill_metric_info(plobj, &minfo, modname, pool);
                    gmi = (Ganglia_25metric*)apr_array_push(metric_info);
                    fill_gmi(gmi, &minfo);
                    mi = (mapped_info_t*)apr_array_push(metric_mapping_info);
                    mi->pmod = pmod;
                    mi->mod_name = apr_pstrdup(pool, modname);
                    mi->pcb = minfo.pcb;
                }
            }
        }
        else if (PyMapping_Check(pobj)) {
            fill_metric_info(pobj, &minfo, modname, pool);
            gmi = (Ganglia_25metric*)apr_array_push(metric_info);
            fill_gmi(gmi, &minfo);
            mi = (mapped_info_t*)apr_array_push(metric_mapping_info);
            mi->pmod = pmod;
            mi->mod_name = apr_pstrdup(pool, modname);
            mi->pcb = minfo.pcb;
        }
        Py_DECREF(pobj);
        Py_DECREF(pinitfunc);
        gtstate = PyEval_SaveThread();
    }
    closedir(dp);

    apr_pool_cleanup_register(pool, NULL,
                              pyth_metric_cleanup,
                              apr_pool_cleanup_null);

    /* Replace the empty static metric definition array with the
       dynamic array that we just created 
    */
    /*XXX Need to put this into a finalize MACRO. This is just pushing
      a NULL entry onto the array so that the looping logic can 
      determine the end if the array. We should probably give back
      a ready APR array rather than a pointer to a Ganglia_25metric
      array. */
    gmi = apr_array_push(metric_info);
    memset (gmi, 0, sizeof(*gmi));
    mi = apr_array_push(metric_mapping_info);
    memset (mi, 0, sizeof(*mi));

    python_module.metrics_info = (Ganglia_25metric *)metric_info->elts;
    return 0;
}
开发者ID:AsherBond,项目名称:monitor-core,代码行数:101,代码来源:mod_python.c

示例2: PyErr_SetString

static PyObject *PDFfile_save(PDFfile *self)
{
	if (!ScCore->primaryMainWindow()->HaveDoc) {
		PyErr_SetString(PyExc_SystemError, "Need to open document first");
		return NULL;
	};

// copied from file scribus.cpp
//void ScribusMainWindow::SaveAsPDF()
	int Components = 3;
	QString nam = "";
	if (ScCore->primaryMainWindow()->bookmarkPalette->BView->topLevelItemCount() == 0)
		ScCore->primaryMainWindow()->doc->PDF_Options.Bookmarks = false;

// apply fonts attribute
	ScCore->primaryMainWindow()->doc->PDF_Options.EmbedList.clear();
	int n = PyList_Size(self->fonts);
	for ( int i=0; i<n; ++i){
		QString tmpFon;
		tmpFon = QString(PyString_AsString(PyList_GetItem(self->fonts, i)));
		ScCore->primaryMainWindow()->doc->PDF_Options.EmbedList.append(tmpFon);
	}
// apply file attribute
	QString fn;
	fn = QString(PyString_AsString(self->file));
	ScCore->primaryMainWindow()->doc->PDF_Options.fileName = fn;
// apply pages attribute
	std::vector<int> pageNs;
	int nn=PyList_Size(self->pages);
	for (int i = 0; i < nn; ++i) {
		pageNs.push_back((int)PyInt_AsLong(PyList_GetItem(self->pages, i)));
	}
// apply thumbnails attribute
	ScCore->primaryMainWindow()->doc->PDF_Options.Thumbnails = self->thumbnails;
// apply compress attribute
	self->compressmtd = minmaxi(self->compressmtd, 0, 3);
	ScCore->primaryMainWindow()->doc->PDF_Options.Compress = self->compress;
	ScCore->primaryMainWindow()->doc->PDF_Options.CompressMethod = (PDFOptions::PDFCompression) self->compressmtd;
// apply quality attribute
	self->quality = minmaxi(self->quality, 0, 4);
	ScCore->primaryMainWindow()->doc->PDF_Options.Quality = self->quality;
// apply resolusion attribute
	ScCore->primaryMainWindow()->doc->PDF_Options.Resolution = PyInt_AsLong(self->resolution);
// apply downsample attribute
	ScCore->primaryMainWindow()->doc->PDF_Options.RecalcPic = PyInt_AsLong(self->downsample);
	if (ScCore->primaryMainWindow()->doc->PDF_Options.RecalcPic)
		ScCore->primaryMainWindow()->doc->PDF_Options.PicRes = PyInt_AsLong(self->downsample);
	else
		ScCore->primaryMainWindow()->doc->PDF_Options.PicRes = ScCore->primaryMainWindow()->doc->PDF_Options.Resolution;
// apply bookmarks attribute
	ScCore->primaryMainWindow()->doc->PDF_Options.Bookmarks = self->bookmarks;
// apply binding attribute
	ScCore->primaryMainWindow()->doc->PDF_Options.Binding = self->binding;
// apply presentation attribute
	ScCore->primaryMainWindow()->doc->PDF_Options.PresentMode = self->presentation;

	QList<PDFPresentationData> PresentVals;
	PresentVals.clear();
	int tmpnum;
	tmpnum=PyList_Size(self->effval);
	for (int i=0; i<tmpnum; ++i) {
		PDFPresentationData t;
// How do I make this commented piece of code to work?
// I always get an error here
		PyObject *ti = PyList_GetItem(self->effval, i);
//		 if (!PyArg_ParseTuple(ti , "[iiiiii]",
//				  &t.pageEffectDuration, &t.pageViewDuration, &t.effectType, &t.Dm,
//				  &t.M, &t.Di)) {
//			 PyErr_SetString(PyExc_SystemError, "while parsing 'effval'. WHY THIS HAPPENED????");
//			 return NULL;
//		 }
//		 PresentVals.append(t);
				// pv 10/03/2004 crashed when pt is null
				if (ti)
				{
					// Do I Need to check if every PyInt_AsLong and PyList_GetItem funtion succeed???
					t.pageEffectDuration = PyInt_AsLong(PyList_GetItem(ti, 0));
					t.pageViewDuration = PyInt_AsLong(PyList_GetItem(ti, 1));
					t.effectType = PyInt_AsLong(PyList_GetItem(ti, 2));
					t.Dm = PyInt_AsLong(PyList_GetItem(ti, 3));
					t.M = PyInt_AsLong(PyList_GetItem(ti, 4));
					t.Di = PyInt_AsLong(PyList_GetItem(ti, 5));
					PresentVals.append(t);
				} // if ti=NULL

	}

	ScCore->primaryMainWindow()->doc->PDF_Options.PresentVals = PresentVals;
// apply lpival
	int n2 = PyList_Size(self->lpival);
	for (int i=0; i<n2; ++i){
		LPIData lpi;
		PyObject *t = PyList_GetItem(self->lpival, i);
// This code always raise exception - WHY???
//		char *s;
//		 if (!PyArg_ParseTuple(t, "[siii]", &s, &lpi.Frequency,
//				  &lpi.Angle, &lpi.SpotFunc)) {
//			 PyErr_SetString(PyExc_SystemError, "while parsing 'lpival'. WHY THIS HAPPENED????");
//			 return NULL;
//		 }
//.........这里部分代码省略.........
开发者ID:AlterScribus,项目名称:ece15,代码行数:101,代码来源:objpdffile.cpp

示例3: AerospikeClient_Operate_Invoke

/**
 *******************************************************************************************************
 * This function invokes csdk's API's.
 *
 * @param self                  AerospikeClient object
 * @param err                   The as_error to be populated by the function
 *                              with the encountered error if any.
 * @param key                   The C client's as_key that identifies the record.
 * @param py_list               The list containing op, bin and value.
 * @param py_meta               The metadata for the operation.
 * @param operate_policy_p      The value for operate policy.
 *******************************************************************************************************
 */
static
PyObject *  AerospikeClient_Operate_Invoke(
	AerospikeClient * self, as_error *err,
	as_key * key, PyObject * py_list, PyObject * py_meta,
	as_policy_operate * operate_policy_p)
{
	as_val* put_val = NULL;
	char* bin = NULL;
	char* val = NULL;
	long offset = 0;
    double double_offset = 0.0;
	uint32_t ttl = 0;
	long operation = 0;
	int i = 0;
	PyObject * py_rec = NULL;
	PyObject * py_ustr = NULL;
	PyObject * py_ustr1 = NULL;
	PyObject * py_bin = NULL;
	as_record * rec = NULL;

	as_static_pool static_pool;
	memset(&static_pool, 0, sizeof(static_pool));

	as_operations ops;
	Py_ssize_t size = PyList_Size(py_list);
	as_operations_inita(&ops, size);

	if (!self || !self->as) {
		as_error_update(err, AEROSPIKE_ERR_PARAM, "Invalid aerospike object");
		goto CLEANUP;
	}

	if(py_meta) {
		AerospikeClient_CheckForMeta(py_meta, &ops, err);
	}

	if (err->code != AEROSPIKE_OK) {
		goto CLEANUP;
	}

	for ( i = 0; i < size; i++) {
		PyObject * py_val = PyList_GetItem(py_list, i);
		operation = -1;
		offset = 0;
        double_offset = 0.0;
		if ( PyDict_Check(py_val) ) {
			PyObject *key_op = NULL, *value = NULL;
			PyObject * py_value = NULL;
			Py_ssize_t pos = 0;
			while (PyDict_Next(py_val, &pos, &key_op, &value)) {
				if ( ! PyString_Check(key_op) ) {
					as_error_update(err, AEROSPIKE_ERR_CLIENT, "A operation key must be a string.");
					goto CLEANUP;
				} else {
					char * name = PyString_AsString(key_op);
					if(!strcmp(name,"op") && (PyInt_Check(value) || PyLong_Check(value))) {
						operation = PyInt_AsLong(value);
					} else if (!strcmp(name, "bin")) {
						py_bin = value;
					} else if(!strcmp(name, "val")) {
						py_value = value;
					} else {
						as_error_update(err, AEROSPIKE_ERR_PARAM, "operation can contain only op, bin and val keys");
						goto CLEANUP;
					}
				}
			}

			if (py_bin) {
				if (PyUnicode_Check(py_bin)) {
					py_ustr = PyUnicode_AsUTF8String(py_bin);
					bin = PyString_AsString(py_ustr);
				} else if (PyString_Check(py_bin)) {
					bin = PyString_AsString(py_bin);
				} else {
					as_error_update(err, AEROSPIKE_ERR_PARAM, "Bin name should be of type string");
					goto CLEANUP;
				}
			} else if (!py_bin && operation != AS_OPERATOR_TOUCH) {
				as_error_update(err, AEROSPIKE_ERR_PARAM, "Bin is not given");
				goto CLEANUP;
			}
			if (py_value) {
				if (check_type(self, py_value, operation, err)) {
                    goto CLEANUP;
				} else if (PyString_Check(py_value) && (operation == AS_OPERATOR_INCR)) {
                    char * incr_string = PyString_AsString(py_value);
//.........这里部分代码省略.........
开发者ID:arthurprs,项目名称:aerospike-client-python,代码行数:101,代码来源:operate.c

示例4: PyDict_Keys

QList<PythonVariable> PythonEngine::variableList()
{
    QStringList filter_name;
    filter_name << "__builtins__" << "StdoutCatcher" << "python_engine_stdout" << "chdir"
                << "python_engine_get_completion_file" << "python_engine_get_completion_string"
                << "python_engine_get_completion_string_dot" << "PythonLabRopeProject"
                << "pythonlab_rope_project"
                << "python_engine_pyflakes_check";

    QStringList filter_type;
    filter_type << "builtin_function_or_method";

    QList<PythonVariable> list;

    PyObject *keys = PyDict_Keys(m_dict);
    for (int i = 0; i < PyList_Size(keys); ++i)
    {
        PyObject *key = PyList_GetItem(keys, i);
        PyObject *value = PyDict_GetItem(m_dict, key);

        // variable
        PythonVariable var;

        // variable name
        var.name = PyString_AsString(key);

        // variable type
        var.type = value->ob_type->tp_name;

        // variable value
        if (var.type == "bool")
        {
            var.value = PyInt_AsLong(value) ? "True" : "False";
        }
        else if (var.type == "int")
        {
            var.value = (int) PyInt_AsLong(value);
        }
        else if (var.type == "float")
        {
            var.value = PyFloat_AsDouble(value);
        }
        else if (var.type == "str")
        {
            var.value = PyString_AsString(value);
        }
        else if (var.type == "list")
        {
            var.value = QString("%1 items").arg(PyList_Size(value));
        }
        else if (var.type == "tuple")
        {
            var.value = QString("%1 items").arg(PyTuple_Size(value));
        }
        else if (var.type == "dict")
        {
            var.value = QString("%1 items").arg(PyDict_Size(value));
        }
        else if (var.type == "numpy.ndarray")
        {
            var.value = ""; //TODO count
        }
        else if (var.type == "module")
        {
            var.value = PyString_AsString(PyObject_GetAttrString(value, "__name__"));
        }
        else if (var.type == "function"
                 || var.type == "instance"
                 || var.type == "classobj")
        {
            // qDebug() << value->ob_type->tp_name;
        }

        // append
        if (!filter_name.contains(var.name) && !filter_type.contains(var.type))
        {
            list.append(var);
        }
    }
    Py_DECREF(keys);

    return list;
}
开发者ID:honzakac,项目名称:agros2d,代码行数:83,代码来源:pythonengine.cpp

示例5: PyErr_SetString

static PyObject
*turnstile_period_search (PyObject *self, PyObject *args)
{
    int i, j;

    int nperiods;
    double min_period, max_period,  amp, var;
    PyObject *datasets;

    // Parse the input arguments.
    if (!PyArg_ParseTuple(args, "Oddidd", &datasets, &min_period,
                          &max_period, &nperiods, &amp, &var))
        return NULL;

    // Parse and extract the necessary information from the datasets.
    if (!PyList_Check(datasets)) {
        PyErr_SetString(PyExc_TypeError, "Expected a list.");
        return NULL;
    }
    int max_sets, nsets = (int)PyList_Size(datasets),
        *ndata = malloc(nsets * sizeof(int));
    double **time = malloc(nsets * sizeof(double*)),
           **flux = malloc(nsets * sizeof(double*)),
           **ferr = malloc(nsets * sizeof(double*));
    PyObject *timeobj = NULL, *fluxobj = NULL, *ferrobj = NULL;
    PyArrayObject *timearray = NULL, *fluxarray = NULL, *ferrarray = NULL;

    for (max_sets = 0; max_sets < nsets; ++max_sets) {
        // Get the dataset.
        PyObject *ds = PyList_GetItem(datasets, max_sets);
        if (ds == NULL) goto fail;

        // Access the attributes that we need.
        timeobj = PyObject_GetAttrString(ds, "time");
        fluxobj = PyObject_GetAttrString(ds, "flux");
        ferrobj = PyObject_GetAttrString(ds, "ferr");

        // Clean up properly if anything went wrong.
        if (timeobj == NULL || fluxobj == NULL || ferrobj == NULL)
            goto ds_fail;

        // Parse the objects as numpy arrays.
        timearray = PARSE_ARRAY(timeobj),
        fluxarray = PARSE_ARRAY(fluxobj),
        ferrarray = PARSE_ARRAY(ferrobj);

        // Clean up properly if anything went wrong.
        if (timearray == NULL || fluxarray == NULL || ferrarray == NULL)
            goto ds_fail;

        // Figure out the size of the dataset and allocate the needed memory.
        ndata[max_sets] = (int)PyArray_DIM(timearray, 0);
        if (PyArray_DIM(fluxarray, 0) != ndata[max_sets] ||
            PyArray_DIM(ferrarray, 0) != ndata[max_sets]) {
            PyErr_SetString(PyExc_ValueError, "Dimension mismatch.");
            goto ds_fail;
        }
        time[max_sets] = malloc(ndata[max_sets] * sizeof(double));
        flux[max_sets] = malloc(ndata[max_sets] * sizeof(double));
        ferr[max_sets] = malloc(ndata[max_sets] * sizeof(double));

        // Copy the data over.
        double *t =  PyArray_DATA(timearray),
               *f =  PyArray_DATA(fluxarray),
               *fe =  PyArray_DATA(ferrarray);
        for (i = 0; i < ndata[max_sets]; ++i) {
            time[max_sets][i] = t[i];
            flux[max_sets][i] = f[i];
            ferr[max_sets][i] = fe[i];
        }

        // Reference counting.
        Py_DECREF(timeobj);
        Py_DECREF(fluxobj);
        Py_DECREF(ferrobj);
        Py_DECREF(timearray);
        Py_DECREF(fluxarray);
        Py_DECREF(ferrarray);
    }

    int *nepochs = NULL;
    double *periods = NULL, **epochs = NULL, **depths = NULL, **dvar = NULL;
    turnstile (nsets, ndata, time, flux, ferr, amp, var,
               min_period, max_period, nperiods,
               &nepochs, &periods, &epochs, &depths, &dvar);

    // Construct the output period array.
    npy_intp d1[1] = {nperiods};
    PyObject *periodarray = PyArray_SimpleNewFromData(1, d1, NPY_DOUBLE,
                                                      periods);
    if (periodarray == NULL) {
        Py_XDECREF(periodarray);
        goto fail;
    }

    // Construct the lists of epoch, depth and depth uncertainty arrays.
    PyObject *epochlist = PyList_New(nperiods),
             *depthlist = PyList_New(nperiods),
             *dvarlist = PyList_New(nperiods);
    if (epochlist == NULL || depthlist == NULL || dvarlist == NULL) {
//.........这里部分代码省略.........
开发者ID:jeffgertler,项目名称:bart,代码行数:101,代码来源:_turnstile.c

示例6: launch_py_user_action


//.........这里部分代码省略.........
	  kval = Py_BuildValue("d",info.value);
	}
      else
	{
	  Py_INCREF(Py_None);
	  kval = Py_None;
	}
      PyDict_SetItemString(kargs,"value",kval);
      Py_DECREF(kval);
      if (info.value2!=-999.)
	{
	  kval = Py_BuildValue("d",info.value2);
	}
      else
	{
	  Py_INCREF(Py_None);
	  kval = Py_None;
	}
      PyDict_SetItemString(kargs,"value2",kval);
      Py_DECREF(kval);
      if (info.x_index!=-999)
	{
	  kval = Py_BuildValue("i",info.x_index);
	}
      else
	{
	  Py_INCREF(Py_None);
	  kval = Py_None;
	}
      PyDict_SetItemString(kargs,"index_x",kval);
      Py_DECREF(kval);
      if (info.y_index!=-999)
	{
	  kval = Py_BuildValue("i",info.y_index);
	}
      else
	{
	  Py_INCREF(Py_None);
	  kval = Py_None;
	}
      PyDict_SetItemString(kargs,"index_y",kval);
      Py_DECREF(kval);
      if (info.color!=-999.)
	{
	  kval = Py_BuildValue("i",info.color);
	}
      else
	{
	  Py_INCREF(Py_None);
	  kval = Py_None;
	}
      PyDict_SetItemString(kargs,"color",kval);
      Py_DECREF(kval);
      
      kval = Py_BuildValue("i",ipoint[0]);
      PyDict_SetItemString(kargs,"XW_x",kval);
      Py_DECREF(kval);

      kval = Py_BuildValue("i",ipoint[1]);
      PyDict_SetItemString(kargs,"XW_y",kval);
      Py_DECREF(kval);

      PyDict_SetItemString(kargs,"canvas",canvas);
      
      funcs = PyObject_GetAttrString(canvas,"user_actions_names");
      if (PyList_Check(funcs)) 
	{
	  line = (BUTTON_Y-y)*PyList_Size(funcs)/h;
	}
      else line=1;
      Py_DECREF(funcs);      
      /* Set the line number as argument */
      args = Py_BuildValue("()",line);

      /* following is for direct call of func */
      funcs = PyObject_GetAttrString(canvas,"user_actions"); /* decref ? */
      if (PyList_Check(funcs))
	{
	  func = PyList_GetItem(funcs,line);
	  if (PyCallable_Check(func))
	    {
	      PY_RELEASE_THREAD;
	      PY_LEAVE_THREADS;
	      PY_ENTER_THREADS;
	      PY_GRAB_THREAD;
	      kval = PyEval_CallObjectWithKeywords(func,args,kargs);
	      Py_DECREF(kargs);
	      Py_DECREF(args);
	      Py_XDECREF(kval);
	      PY_RELEASE_THREAD;
	      PY_LEAVE_THREADS;
	    }
	  else
	    {
	      PY_RELEASE_THREAD
		PY_LEAVE_THREADS
	      return 1;
	    }
	}
      else {
开发者ID:UNESCO-IHE,项目名称:uvcdat,代码行数:101,代码来源:draw_popups.c

示例7: selNSGA2

static PyObject* selNSGA2(PyObject *self, PyObject *args){
    /* Args[0] : Individual list
     * Args[1] : Number of individuals wanted in output
     * Return : k selected individuals from input individual list
     */
    PyObject *lListIndv = PyTuple_GetItem(args, 0);
#ifdef PY3K
    unsigned long k = (unsigned long)PyLong_AS_LONG(PyTuple_GetItem(args, 1));
#else
    unsigned int k = (unsigned int)PyInt_AS_LONG(PyTuple_GetItem(args, 1));
#endif
    
    PyObject *lListSelect = PyList_New(0);
    
    unsigned int lLenListIndv = (unsigned int)PyList_Size(lListIndv);
    unsigned int lNbrObjectives = (unsigned int)PyTuple_Size(PyObject_GetAttrString(PyObject_GetAttrString(PyList_GetItem(lListIndv,0), "fitness"), "values"));
    
    if(k == 0)
        return lListSelect;
    
    // First : copy fitness values into an std::vector<std::vector<double> >
    // First vector index is used to identify individuals
    // Second vector index represents an objective
    std::vector<std::vector<double> > lPopFit(lLenListIndv, std::vector<double>(lNbrObjectives,0.));
    for(unsigned int i = 0; i < lLenListIndv; i++){
        for(unsigned int j = 0; j < lNbrObjectives; j++)
            lPopFit[i][j] = PyFloat_AS_DOUBLE(PyTuple_GetItem(PyObject_GetAttrString(PyObject_GetAttrString(PyList_GetItem(lListIndv,i), "fitness"), "wvalues"), j));
    }
    
    
    unsigned int lParetoSorted = 0;
    unsigned int lFrontIndex = 0;
    std::vector<std::vector<unsigned int> > lParetoFront(1, std::vector<unsigned int>(0));
    std::vector<unsigned int> lDominating(lLenListIndv, 0);
    std::vector<std::vector<unsigned int> > lDominatedInds(lLenListIndv, std::vector<unsigned int>(0));
    
    // Rank first pareto front
    for(unsigned int i = 0; i < lLenListIndv; i++){
        for(unsigned int j = i+1; j < lLenListIndv; j++){
            
            if(isDominated(lPopFit[j], lPopFit[i])){
                lDominating[j]++;
                lDominatedInds[i].push_back(j);
            }
            else if(isDominated(lPopFit[i], lPopFit[j])){
                lDominating[i]++;
                lDominatedInds[j].push_back(i);
            }
        }
        if(lDominating[i] == 0){
            lParetoFront[lFrontIndex].push_back(i);
            lParetoSorted++;
        }
    }

    // Rank other pareto fronts, until we reach the *k* limit
    while(lParetoSorted < k && lParetoSorted < lLenListIndv){
        lFrontIndex++;
        lParetoFront.push_back(std::vector<unsigned int>(0));
        for(unsigned int i = 0; i < lParetoFront[lFrontIndex-1].size(); i++){
            unsigned int lIndiceP = lParetoFront[lFrontIndex-1][i];
            for(unsigned int j = 0; j < lDominatedInds[lIndiceP].size(); j++){
                unsigned int lIndiceD = lDominatedInds[lIndiceP][j];
                if(--lDominating[lIndiceD] == 0){
                    lParetoFront[lFrontIndex].push_back(lIndiceD);
                    lParetoSorted++;
                }
            }
        }
    }
    
    // Append individuals from pareto ranking until we reach the limit
    for(unsigned int i = 0; i < lParetoFront.size(); i++){
        if(PyList_Size(lListSelect)+lParetoFront[i].size() <= k){
            for(unsigned int j = 0; j < lParetoFront[i].size(); j++)
                PyList_Append(lListSelect, PyList_GetItem(lListIndv,lParetoFront[i][j]));
        }
        else{
            break;
        }
    }

    // Crowding distance on the last front
    if(PyList_Size(lListSelect) == k)
        return lListSelect;
    
    FitComp lCmpIndvObj;
    std::vector<unsigned int> lLastParetoFront = lParetoFront.back();
    std::vector<std::pair<double, unsigned int> > lDistances(0);
    std::vector<std::pair<std::vector<double>, unsigned int> > lCrowdingList(0);
    double lInfinity = std::numeric_limits<double>::infinity();
    
    // Reserve sufficient memory for the subsequent push_back
    lDistances.reserve(lLastParetoFront.size());
    lCrowdingList.reserve(lLastParetoFront.size());
    
    for(unsigned int i = 0; i < lLastParetoFront.size(); i++){
        // Push initial distance (0.0) and individual index in lPopFit and lListIndv for each individual
        lDistances.push_back(std::pair<double, unsigned int>(0., lLastParetoFront[i]));
        
//.........这里部分代码省略.........
开发者ID:chulakar,项目名称:KeyPlayers_Sample,代码行数:101,代码来源:cTools.cpp

示例8: tdi_soup_encode_starttag

/*
 * HTML starttag builder
 */
PyObject *
tdi_soup_encode_starttag(tdi_node_t *node)
{
    PyObject *result, *attr;
    tdi_attr_t *item;
    char *cresult;
    Py_ssize_t j, length, size;

    /* 1st pass: count result bytes */
    size = PyString_GET_SIZE(node->tagname) + 2;  /* <> */
    if (node->flags & NODE_CLOSED)
        size += 2;  /* ' /' */

    if (!(attr = PyDict_Values(node->attr)))
        return NULL;
    length = PyList_GET_SIZE(attr);
    for (j = 0; j < length; ++j) {
        if (!(item = (tdi_attr_t *)PyList_GetItem(attr, j))) {
            Py_DECREF(attr);
            return NULL;
        }
        if (item->value == Py_None)
            size += PyString_GET_SIZE(item->key) + 1;  /* ' ' */
        else
            size += PyString_GET_SIZE(item->key)
                + PyString_GET_SIZE(item->value) + 2;  /* ' =' */
    }

    /* 2nd pass: assemble result */
    if (!(result = PyString_FromStringAndSize(NULL, size))) {
        Py_DECREF(attr);
        return NULL;
    }
    cresult = PyString_AS_STRING(result);
    *cresult++ = '<';

    size = PyString_GET_SIZE(node->tagname);
    (void)memcpy(cresult, PyString_AS_STRING(node->tagname), (size_t)size);
    cresult += size;

    for (j = 0; j < length; ++j) {
        if (!(item = (tdi_attr_t *)PyList_GetItem(attr, j))) {
            Py_DECREF(result);
            Py_DECREF(attr);
            return NULL;
        }

        *cresult++ = ' ';

        size = PyString_GET_SIZE(item->key);
        (void)memcpy(cresult, PyString_AS_STRING(item->key), (size_t)size);
        cresult += size;

        if (item->value != Py_None) {
            *cresult++ = '=';
            size = PyString_GET_SIZE(item->value);
            (void)memcpy(cresult, PyString_AS_STRING(item->value),
                         (size_t)size);
            cresult += size;
        }
    }
    Py_DECREF(attr);

    if (node->flags & NODE_CLOSED) {
        *cresult++ = ' ';
        *cresult++ = '/';
    }
    *cresult = '>';

    return result;
}
开发者ID:giorgil,项目名称:tdi,代码行数:74,代码来源:soup_encoder.c

示例9: network_mysqld_python_initialize

/**
 * need not gain GIL
 */
int network_mysqld_python_initialize(chassis_plugin_config *config){
    PyObject *path = PySys_GetObject("path");

    if(!config->python_script){
		g_message("No avalible python script.");
		return 0;
	}

	if(init_python_types()){
		PyErr_Print();
		PyErr_Clear();
		return -1;
	}

    PyObject *script = PyString_FromString(config->python_script);
    PyObject *split_path = PyObject_CallMethod(script, "rsplit", "si", "/", 1);
    Py_DECREF(script);

    Py_ssize_t length = PyList_GET_SIZE(split_path);
    assert(length == 2);
    PyList_Append(path, PyList_GetItem(split_path, 0));

	// Add current dir to sys.path.
	char path_buf[MAX_PATH_LENGTH];
	char* result = getcwd(path_buf, MAX_PATH_LENGTH);
	if(result){
		PyObject *curr_path = PyString_FromString(path_buf);
		PyList_Append(path, curr_path);
		Py_DECREF(curr_path);
	}
	else{
		Py_DECREF(split_path);
		g_critical("Script file path is too long! Max length is %d\n",
					MAX_PATH_LENGTH);
		return -1;
	}

	//Now load the script
	PyObject *file_name = PyList_GetItem(split_path, length - 1);
	PyObject *split_file_name= PyObject_CallMethod(file_name, "split",
				"si", ".", 1);
	PyObject *mod_name = PyList_GetItem(split_file_name, 0);
	PyObject *script_mod = PyImport_Import(mod_name);

	if(!script_mod){
		PyObject *exc_type = PyErr_Occurred();
		if(exc_type){
			PyErr_Print();
			PyErr_Clear();
		}
		else
			g_critical("Unknown error occurred while importing script %s\n",
						PyString_AsString(mod_name));
		Py_DECREF(split_file_name);
		Py_DECREF(split_path);
		return -1;
	}
	config->proxy_funcs = g_new0(pyproxy_functions, 1);
	if(!config->proxy_funcs){
		g_critical("No memory avaible for alloc proxy functions!\n");
		Py_DECREF(script_mod);
		Py_DECREF(split_file_name);
		Py_DECREF(split_path);
		return -1;
	}

	//Load the script hook function to config->proxy_methods.
#define LOAD_FUNC(func) \
	config->proxy_funcs->func = NULL;\
	if(PyObject_HasAttrString(script_mod, #func)){\
		PyObject *fun = PyObject_GetAttrString(script_mod, #func);\
		if(PyCallable_Check(fun)){\
			config->proxy_funcs->func = fun;\
		}\
		else{\
			PyObject *func_name = PyObject_Str(mod_name);\
			g_message("Load %s.%s failed: object %s is not callable!\n", \
				PyString_AsString(func_name), #func, #func);\
			Py_DECREF(func_name);\
		}\
	}

	LOAD_FUNC(init)
	LOAD_FUNC(connect_server)
	LOAD_FUNC(read_handshake)
	LOAD_FUNC(read_auth)
	LOAD_FUNC(read_auth_result)
	LOAD_FUNC(read_query)
	LOAD_FUNC(read_query_result)
	LOAD_FUNC(disconnect_client)

	Py_DECREF(script_mod);
	Py_DECREF(split_file_name);

    Py_DECREF(split_path);
	return 0;
}
开发者ID:akamajoris,项目名称:mysql-proxy-python,代码行数:100,代码来源:network-mysqld-python.c

示例10: my_action

static int
my_action(void *new_ps, void **children, int n_children, int pn_offset,
	  struct D_Parser *parser, int speculative) {
  D_ParseNode *dd = D_PN(new_ps, pn_offset);
  PyObject *result = NULL;
  PyObject *children_list, *string_list = NULL;
  PNode *pn = (PNode *)new_ps;
  int action_index = pn->reduction->action_index;
  PyObject *tuple = NULL;
  PyObject *arg_types = NULL;
  D_ParserPyInterface *ppi = d_interface(parser);
  int takes_speculative = 0;
  PyObject *action = 0;

  if (PyErr_Occurred()) {
    /* just keep returning until finished parsing.  Need a way to tell dparser to quit */
    return 0;
  }

  if (action_index != -1) {
    tuple = PyList_GetItem(ppi->actions, action_index);
    PyArg_ParseTuple(tuple, "OOi", &action, &arg_types, &takes_speculative);
  }
  
  if (ppi->takes_globals) {
    inc_global_state(parser, dd);
  }

  if (ppi->print_debug_info && tuple) {
    print_debug_info(dd, tuple, speculative, ppi->print_debug_info);
  }

  if (takes_speculative == -1 && !speculative) {
    /* user.t and user.s were already set when this was called speculatively */
    return 0;
  }

  if (ppi->takes_strings) {
    string_list = pylist_children(parser, dd, 1);
    if (string_list == NULL) {
      return -1;
    }
  }
  /* this function owns string_list */

  if (takes_speculative == 0 && speculative) {
    Py_INCREF(Py_None);
    Py_XDECREF(dd->user.t);
    /*    if (dd->user.s)
	  printf("freeing2:%d\n", dd->user.s);*/
    Py_XDECREF(dd->user.s);
    dd->user.t = Py_None;
    //    printf("dd1:%d\n", dd);
    dd->user.s = NULL;
    Py_XDECREF(string_list);
    /*    printf("setting:%d\n", string_list);*/
    //dd->user.s = string_list;

    return 0;
  }

  children_list = pylist_children(parser, dd, 0);
  if (children_list == NULL) {
    /*    if (string_list)
	  printf("freeing3:%d\n", string_list);*/

      Py_XDECREF(string_list);
      return -1;
  }
  /* this function owns children_list */

  if (action_index != -1) {
    result = take_action(arg_types, children_list, speculative, dd, string_list, 
			 n_children, parser, children, pn_offset, action);
    Py_DECREF(children_list);
  } else {
    result = children_list;
  }
  /* function now owns result, string_list */

  if (result == ppi->reject || result == NULL) {
    /*    if (string_list)
	  printf("freeing4:%d\n", string_list);*/

    Py_XDECREF(result);
    Py_XDECREF(string_list);
    return -1;  /* user rejected */
  }

  Py_XDECREF(dd->user.t); /* these may have been set in a speculative pass */
  /*  if(dd->user.s)
      printf("freeing5:%d\n", dd->user.s);*/
  Py_XDECREF(dd->user.s);
  /*  if(dd->user.s)
      printf("setting2:%d\n", string_list);*/
  //  printf("dd2:%d\n", dd);
  dd->user.t = result;
  dd->user.s = string_list;  

  return 0;
//.........这里部分代码省略.........
开发者ID:01org,项目名称:fMBT,代码行数:101,代码来源:pydparser.c

示例11: ccmapninfo

static
PyObject* ccmapninfo(PyObject *xyz_data,PyObject *ninfo_data)
{
  int i,j;
  PyObject *xyz_item1,*xyz_item2,*ninfo_item,*out_list,*out_list2;
  long ninfo_max=PyList_Size(ninfo_data);
    
  long icon,jcon;
  double nlength;
  double nowcontact=0.0,nowlength=0.0;
  long max=PyList_Size(xyz_data);
  out_list=PyList_New(max);
  long d2_list[max][max];
    
  for(i=0;i<max;i++){
    for(j=0;j<max;j++){
      d2_list[j][i]=0;
    }
  }
  for(i=0;i<ninfo_max;i++){
    ninfo_item=PyList_GetItem(ninfo_data,i);
    icon=PyInt_AsLong(PyList_GetItem(ninfo_item,0));
    jcon=PyInt_AsLong(PyList_GetItem(ninfo_item,1));
    nlength=PyFloat_AsDouble(PyList_GetItem(ninfo_item,2));
    xyz_item1=PyList_GetItem(xyz_data,icon-1);
    xyz_item2=PyList_GetItem(xyz_data,jcon-1);
    nowlength=clength(PyFloat_AsDouble(PyList_GetItem(xyz_item1,0)),
                      PyFloat_AsDouble(PyList_GetItem(xyz_item1,1)),
                      PyFloat_AsDouble(PyList_GetItem(xyz_item1,2)),
                      PyFloat_AsDouble(PyList_GetItem(xyz_item2,0)),
                      PyFloat_AsDouble(PyList_GetItem(xyz_item2,1)),
                      PyFloat_AsDouble(PyList_GetItem(xyz_item2,2)));
    if(nowlength<nlength*1.2){
      d2_list[icon-1][jcon-1]=1;
      d2_list[jcon-1][icon-1]=1;
    }
  }
  for(i=0;i<max;i++){
    out_list2=PyList_New(max);
    for(j=0;j<max;j++){
      PyList_SetItem(out_list2,j,PyInt_FromLong(d2_list[i][j]));
    }
    PyList_SetItem(out_list,i,out_list2);
  }

  return out_list;
}
开发者ID:Moguf,项目名称:cafepy,代码行数:47,代码来源:calc_cmap_ninfo.cpp

示例12: take_action

static PyObject*
take_action(PyObject *arg_types, PyObject *children_list, int speculative, 
	    D_ParseNode *dd, PyObject *string_list, int n_children, 
	    struct D_Parser *parser, void **children, int pn_offset,
	    PyObject *action) {
  int i;
  int arg_count = PyList_Size(arg_types);
  D_ParserPyInterface *ppi = d_interface(parser);
  PyObject *arglist = PyTuple_New(arg_count);
  PyObject *globals_holder = NULL;
  PyObject *result = NULL;

  Py_INCREF(children_list);
  PyTuple_SetItem(arglist, 0, children_list);
  for (i=1; i<arg_count; i++) {
    PyObject *item = PyList_GetItem(arg_types, i);
    int type = PyInt_AsLong(item);
    if (type == 1) {
      PyTuple_SetItem(arglist, i, Py_BuildValue("i", speculative));
    }
    else if (type == 2) {
      if (!dd->user.inced_global_state) {
	dd->user.inced_global_state = 1;
      }
      globals_holder = PyList_New(1);
      Py_INCREF(dd->globals);
      PyList_SetItem(globals_holder, 0, dd->globals);
      PyTuple_SetItem(arglist, i, globals_holder);
    }
    else if (type == 3) {
      Py_INCREF(string_list);
      PyTuple_SetItem(arglist, i, string_list);
    }
    else if (type == 4) {
      PyObject* nodes = PyList_New(n_children);
      int j;
      for (j=0; j<n_children; j++) {
	PyList_SetItem(nodes, j, make_py_node(parser, D_PN(children[j], pn_offset)));
      }
      PyTuple_SetItem(arglist, i, nodes);
    }
    else if (type == 5) {
      PyTuple_SetItem(arglist, i, make_py_node(parser, dd));
    }
    else if (type == 6) {
      Py_INCREF(Py_None);
      PyTuple_SetItem(arglist, i, Py_None);
    }
    else if (type == 7) {
      Py_INCREF(ppi->self);
      PyTuple_SetItem(arglist, i, ppi->self);
    }
  }
  result = PyEval_CallObject(action, arglist);
  if (globals_holder) {
    Py_DECREF(dd->globals);
    dd->globals = PyList_GetItem(globals_holder, 0);
    Py_INCREF(dd->globals);
  }
  Py_DECREF(arglist);
  return result;
}
开发者ID:01org,项目名称:fMBT,代码行数:62,代码来源:pydparser.c

示例13: convert_datablock

PyObject * convert_datablock( DATABLOCK * datablock )
{
    PyObject * current_datablock = PyDict_New();
    PyDict_PutString( current_datablock, "name",
                      datablock_name( datablock ) );

    size_t length = datablock_length( datablock );
    char **tags   = datablock_tags( datablock );
    ssize_t * value_lengths = datablock_value_lengths( datablock );
    char ***values = datablock_values( datablock );
    int *inloop   = datablock_in_loop( datablock );
    int  loop_count = datablock_loop_count( datablock );
    datablock_value_type_t **types = datablock_types( datablock );

    PyObject * taglist    = PyList_New(0);
    PyObject * valuehash  = PyDict_New();
    PyObject * loopid     = PyDict_New();
    PyObject * loops      = PyList_New(0);
    PyObject * typehash   = PyDict_New();
    PyObject * saveframes = PyList_New(0);

    size_t i;
    ssize_t j;
    for( i = 0; i < loop_count; i++ ) {
        PyObject * loop = PyList_New(0);
        PyList_Append( loops, loop );
    }

    for( i = 0; i < length; i++ ) {
        PyList_Append( taglist, PyString_FromString( tags[i] ) );

        PyObject * tagvalues  = PyList_New(0);
        PyObject * typevalues = PyList_New(0);
        PyObject * type;
        for( j = 0; j < value_lengths[i]; j++ ) {
            PyList_Append( tagvalues, PyString_FromString( values[i][j] ) );
            switch ( types[i][j] ) {
                case DBLK_INT :
                    type = PyString_FromString( "INT" ); break;
                case DBLK_FLOAT :
                    type = PyString_FromString( "FLOAT" ); break;
                case DBLK_SQSTRING :
                    type = PyString_FromString( "SQSTRING" ); break;
                case DBLK_DQSTRING :
                    type = PyString_FromString( "DQSTRING" ); break;
                case DBLK_UQSTRING :
                    type = PyString_FromString( "UQSTRING" ); break;
                case DBLK_TEXT :
                    type = PyString_FromString( "TEXTFIELD" ); break;
                default :
                    type = PyString_FromString( "UNKNOWN" );
            }
            PyList_Append( typevalues, type );
        }
        PyDict_SetItemString( valuehash, tags[i], tagvalues );
        PyDict_SetItemString( typehash, tags[i], typevalues );

        if( inloop[i] != -1 ) {
            PyDict_SetItemString( loopid, tags[i], PyInt_FromLong( inloop[i] ) );
            PyObject * current_loop = PyList_GetItem( loops, inloop[i] );
            PyList_Append( current_loop, PyString_FromString( tags[i] ) );
        }
    }

    DATABLOCK * saveframe;
    foreach_datablock( saveframe,
                       datablock_save_frame_list( datablock ) ) {
        PyList_Append( saveframes,
                       convert_datablock( saveframe ) );
    }
开发者ID:sauliusg,项目名称:cod-tools,代码行数:70,代码来源:ccifparser.c

示例14: PyErr_SetString

static PyObject *echoprint_py_inverted_index_create_block(
  PyObject *self, PyObject *args)
{
  // input is a list of lists, each item of the outer list being a
  // song (list of codes); second argument is the output path

  PyObject *arg_songs, *arg_output_path;
  int n, m, n_songs, error_parsing_input, error_writing_blocks;
  char *path_out;
  uint32_t **block_songs_codes;
  uint32_t *block_song_lengths;

  if(!PyArg_ParseTuple(args, "OS", &arg_songs, &arg_output_path))
    return NULL;

  error_parsing_input = 0;
  if(!PyList_Check(arg_songs))
  {
    PyErr_SetString(
      PyExc_TypeError, "first argument must be a list (of lists of codes)");
    return NULL;
  }

  path_out = PyString_AsString(arg_output_path);
  n_songs = PyList_Size(arg_songs);

  block_song_lengths = (uint32_t*) malloc(sizeof(uint32_t) * n_songs);
  block_songs_codes = (uint32_t **) malloc(sizeof(uint32_t *) * n_songs);

  for(n = 0; n < n_songs; n++)
    block_songs_codes[n] = 0;
  for(n = 0; n < n_songs; n++)
  {
    if(error_parsing_input)
      break;
    else
    {
      PyObject * py_song_seq = PySequence_GetItem(arg_songs, n);
      uint32_t song_length = PyList_Size(py_song_seq);
      block_songs_codes[n] = (uint32_t *) malloc(
	sizeof(uint32_t) * song_length);
      for(m = 0; m < song_length; m++)
      {
	PyObject *code = PyList_GetItem(py_song_seq, m);
	if(!PyInt_Check(code))
	{
	  PyErr_SetString(
	    PyExc_TypeError, "all codes in input songs must be integers");
	  error_parsing_input = 1;
	  break;
	}
	else
	  block_songs_codes[n][m] = (uint32_t) PyInt_AsLong(code);
      }
      block_song_lengths[n] = song_length;
      Py_DECREF(py_song_seq);
    }
  }

  error_writing_blocks = 0;
  if(!error_parsing_input)
  {
    if(echoprint_inverted_index_build_write_block(
	 block_songs_codes, block_song_lengths, n_songs, path_out, 0))
    {
      error_writing_blocks = 1;
      PyErr_SetString(PyExc_TypeError, "could not write the index block");
    }
  }

  for(n = 0; n < n_songs; n++)
    if(block_songs_codes[n] != 0)
      free(block_songs_codes[n]);
  free(block_songs_codes);
  free(block_song_lengths);

  if(error_parsing_input || error_writing_blocks)
    return NULL;

  return Py_None;

}
开发者ID:spotify,项目名称:echoprint-server,代码行数:82,代码来源:echoprint_server_python.c

示例15: _Py_FindSourceFile

static PyObject *
_Py_FindSourceFile(PyObject *filename, char* namebuf, size_t namelen, PyObject *io)
{
    Py_ssize_t i;
    PyObject *binary;
    PyObject *v;
    Py_ssize_t npath;
    size_t taillen;
    PyObject *syspath;
    PyObject *path;
    const char* tail;
    PyObject *filebytes;
    const char* filepath;
    Py_ssize_t len;
    PyObject* result;

    filebytes = PyUnicode_EncodeFSDefault(filename);
    if (filebytes == NULL) {
        PyErr_Clear();
        return NULL;
    }
    filepath = PyBytes_AS_STRING(filebytes);

    /* Search tail of filename in sys.path before giving up */
    tail = strrchr(filepath, SEP);
    if (tail == NULL)
        tail = filepath;
    else
        tail++;
    taillen = strlen(tail);

    syspath = _PySys_GetObjectId(&PyId_path);
    if (syspath == NULL || !PyList_Check(syspath))
        goto error;
    npath = PyList_Size(syspath);

    for (i = 0; i < npath; i++) {
        v = PyList_GetItem(syspath, i);
        if (v == NULL) {
            PyErr_Clear();
            break;
        }
        if (!PyUnicode_Check(v))
            continue;
        path = PyUnicode_EncodeFSDefault(v);
        if (path == NULL) {
            PyErr_Clear();
            continue;
        }
        len = PyBytes_GET_SIZE(path);
        if (len + 1 + (Py_ssize_t)taillen >= (Py_ssize_t)namelen - 1) {
            Py_DECREF(path);
            continue; /* Too long */
        }
        strcpy(namebuf, PyBytes_AS_STRING(path));
        Py_DECREF(path);
        if (strlen(namebuf) != (size_t)len)
            continue; /* v contains '\0' */
        if (len > 0 && namebuf[len-1] != SEP)
            namebuf[len++] = SEP;
        strcpy(namebuf+len, tail);

        binary = _PyObject_CallMethodId(io, &PyId_open, "ss", namebuf, "rb");
        if (binary != NULL) {
            result = binary;
            goto finally;
        }
        PyErr_Clear();
    }
    goto error;

error:
    result = NULL;
finally:
    Py_DECREF(filebytes);
    return result;
}
开发者ID:collinanderson,项目名称:ensurepip,代码行数:77,代码来源:traceback.c


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