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


C++ PyObject_SetAttrString函数代码示例

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


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

示例1: cdefer_Deferred__set_debug_stack

static int cdefer_Deferred__set_debug_stack(cdefer_Deferred *self, char *name) {
    int rc;
    PyObject *stack;

    stack = PyObject_CallObject(format_stack, NULL);
    if (!stack) {
        return -1;
    }
    rc = PyObject_SetAttrString(self->debuginfo, name, stack);
    Py_DECREF(stack);
    if (-1 == rc) {
        return -1;
    }
    return 0;
}
开发者ID:anrysev,项目名称:twisted,代码行数:15,代码来源:cdefer.c

示例2: Py_INCREF

/* Implementation of kleckner1 */

static PyObject *__pyx_f_9kleckner1_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_9kleckner1_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_x = 0;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"x",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_x)) return 0;
  Py_INCREF(__pyx_v_x);

  __pyx_r = Py_None; Py_INCREF(Py_None);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static void __pyx_f_9kleckner1_g(int __pyx_v_x) {

}

static struct PyMethodDef __pyx_methods[] = {
  {"f", (PyCFunction)__pyx_f_9kleckner1_f, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

PyMODINIT_FUNC initkleckner1(void); /*proto*/
PyMODINIT_FUNC initkleckner1(void) {
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("kleckner1", __pyx_methods, 0, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  Py_INCREF(__pyx_m);
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};

  /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/kleckner/kleckner1.pyx":4 */
  return;
  __pyx_L1:;
  __Pyx_AddTraceback("kleckner1");
}
开发者ID:jwilk,项目名称:Pyrex,代码行数:42,代码来源:kleckner1.c

示例3: srd_inst_start

/** @private */
SRD_PRIV int srd_inst_start(struct srd_decoder_inst *di)
{
	PyObject *py_res;
	GSList *l;
	struct srd_decoder_inst *next_di;
	int ret;

	srd_dbg("Calling start() method on protocol decoder instance %s.",
			di->inst_id);

	/* Run self.start(). */
	if (!(py_res = PyObject_CallMethod(di->py_inst, "start", NULL))) {
		srd_exception_catch("Protocol decoder instance %s",
				di->inst_id);
		return SRD_ERR_PYTHON;
	}
	Py_DecRef(py_res);

	/* Set the initial pins based on self.initial_pins. */
	set_initial_pin_values(di);

	/* Set self.samplenum to 0. */
	PyObject_SetAttrString(di->py_inst, "samplenum", PyLong_FromLong(0));

	/* Set self.matches to None. */
	PyObject_SetAttrString(di->py_inst, "matches", Py_None);

	/* Start all the PDs stacked on top of this one. */
	for (l = di->next_di; l; l = l->next) {
		next_di = l->data;
		if ((ret = srd_inst_start(next_di)) != SRD_OK)
			return ret;
	}

	return SRD_OK;
}
开发者ID:zeldin,项目名称:libsigrokdecode,代码行数:37,代码来源:instance.c

示例4: PyComplex

void PyComplex(char *name, double value, double value2)
{
    PyObject *obj;

    obj = PyComplex_FromDoubles(value, value2);
    
    if(list_level>=0 && List[list_level]) {
        PyList_Append(List[list_level], obj);
        Py_DECREF(obj);    
        return;
    }

    PyObject_SetAttrString(interpreter_state->main_module, name, obj);
    Py_DECREF(obj);
}
开发者ID:pc,项目名称:pythonika,代码行数:15,代码来源:Pythonika.c

示例5: Py_INCREF

    /* "/Users/baas/src/cgkit/pyrex/pyx/_pointcloud.pyx":131 */
    __pyx_v_n += 1;
  }

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_pointcloud.writeDataPoints");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static struct PyMethodDef __pyx_methods[] = {
  {"readDataPoints", (PyCFunction)__pyx_f_11_pointcloud_readDataPoints, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11_pointcloud_readDataPoints},
  {"writeDataPoints", (PyCFunction)__pyx_f_11_pointcloud_writeDataPoints, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11_pointcloud_writeDataPoints},
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

PyMODINIT_FUNC init_pointcloud(void); /*proto*/
PyMODINIT_FUNC init_pointcloud(void) {
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("_pointcloud", __pyx_methods, __pyx_mdoc, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;};
  Py_INCREF(__pyx_m);
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;};

  /* "/Users/baas/src/cgkit/pyrex/pyx/_pointcloud.pyx":90 */
  return;
  __pyx_L1:;
  __Pyx_AddTraceback("_pointcloud");
}
开发者ID:npinto,项目名称:cgkit,代码行数:39,代码来源:_pointcloud.c

示例6: PyInteger

void PyInteger(char *name, long value)
{
    PyObject *obj;

    obj = PyLong_FromLong(value);
    
    if(list_level>=0 && List[list_level]) {
        PyList_Append(List[list_level], obj);
        Py_DECREF(obj);        
        return;
    }

    PyObject_SetAttrString(interpreter_state->main_module, name, obj);
    Py_DECREF(obj);
}
开发者ID:pc,项目名称:pythonika,代码行数:15,代码来源:Pythonika.c

示例7: py_set_attrs

static void py_set_attrs(PyObject *mod)
{
   DECL_ATTR_RETRO(B);
   DECL_ATTR_RETRO(Y);
   DECL_ATTR_RETRO(SELECT);
   DECL_ATTR_RETRO(START);
   DECL_ATTR_RETRO(UP);
   DECL_ATTR_RETRO(DOWN);
   DECL_ATTR_RETRO(LEFT);
   DECL_ATTR_RETRO(RIGHT);
   DECL_ATTR_RETRO(A);
   DECL_ATTR_RETRO(X);
   DECL_ATTR_RETRO(L);
   DECL_ATTR_RETRO(R);
   DECL_ATTR_RETRO(L2);
   DECL_ATTR_RETRO(R2);
   DECL_ATTR_RETRO(L3);
   DECL_ATTR_RETRO(R3);

   PyObject_SetAttrString(mod, "ANALOG_LEFT", PyLong_FromLong(RETRO_DEVICE_INDEX_ANALOG_LEFT));
   PyObject_SetAttrString(mod, "ANALOG_RIGHT", PyLong_FromLong(RETRO_DEVICE_INDEX_ANALOG_RIGHT));
   PyObject_SetAttrString(mod, "ANALOG_X", PyLong_FromLong(RETRO_DEVICE_ID_ANALOG_X));
   PyObject_SetAttrString(mod, "ANALOG_Y", PyLong_FromLong(RETRO_DEVICE_ID_ANALOG_Y));
}
开发者ID:demsullivan,项目名称:RetroArch,代码行数:24,代码来源:py_state.c

示例8: initMk4py

void initMk4py() {
  PyObject *m = Py_InitModule4("Mk4py", Mk4Methods, mk4py_module_documentation,
    0, PYTHON_API_VERSION);
  PyObject_SetAttrString(m, "version", PyString_FromString("2.4.9.7"));
  PyObject_SetAttrString(m, "ViewType", (PyObject*) &PyViewtype);
  PyObject_SetAttrString(m, "ViewerType", (PyObject*) &PyViewertype);
  PyObject_SetAttrString(m, "ROViewerType", (PyObject*) &PyROViewertype);
  PyObject_SetAttrString(m, "RowRefType", (PyObject*) &PyRowReftype);
  PyObject_SetAttrString(m, "RORowRefType", (PyObject*) &PyRORowReftype);
}
开发者ID:azynheira,项目名称:metakit,代码行数:10,代码来源:PyStorage.cpp

示例9: delete_invalid_lists

void delete_invalid_lists( PyObject* pobj )
{
    PyObject* pclass = NULL;
    PyObject* plist = NULL;
    PyObject* temp;
    int i, d, n;

    pclass = PyObject_GetAttrString( pobj, "__class__" );
    if ( pclass == NULL )
	goto done;

    plist = PyObject_GetAttrString( pclass, "invalid" );
    if ( plist == NULL )
	goto done;

    if ( !PyList_Check( plist ) ) goto done;

    n = PyList_Size( plist );
    if ( n == 0 ) goto done;
#if 0
    printf( "deleting old displaylists: " );
#endif
    for ( i = 0; i < n; ++i )
    {
	temp = PyList_GetItem( plist, i );
	if ( PyInt_Check( temp ) ) {
	    d = PyInt_AsLong( temp );
            glDeleteLists( d, 1 );
        } else if ( PyTuple_Check( temp ) ) {
	    d = PyInt_AsLong( PyTuple_GetItem( temp, 0 ) );
            glDeleteLists( d, 1 );
	} else { 
	    fprintf( stderr, "delete_invalid_lists:  bad cache value\n" );
        }
#if 0
	printf( " %d", d );
#endif
    }
#if 0
    printf( "\n" );
#endif

    PyObject_SetAttrString( pclass, "invalid", PyList_New(0) );
    
 done:
    Py_XDECREF( pclass );
    Py_XDECREF( plist );
}
开发者ID:gcross,项目名称:QC-Talks,代码行数:48,代码来源:dr_path.c

示例10: pygpgme_context_genkey

static PyObject *
pygpgme_context_genkey(PyGpgmeContext *self, PyObject *args)
{
    PyObject *py_pubkey = Py_None, *py_seckey = Py_None;
    const char *parms;
    gpgme_data_t pubkey = NULL, seckey = NULL;
    PyObject *result;
    gpgme_error_t err;

    if (!PyArg_ParseTuple(args, "z|OO", &parms, &py_pubkey, &py_seckey))
        return NULL;

    if (pygpgme_data_new(&pubkey, py_pubkey))
        return NULL;

    if (pygpgme_data_new(&seckey, py_seckey)) {
        gpgme_data_release(pubkey);
        return NULL;
    }

    Py_BEGIN_ALLOW_THREADS;
    err = gpgme_op_genkey(self->ctx, parms, pubkey, seckey);
    Py_END_ALLOW_THREADS;

    gpgme_data_release(seckey);
    gpgme_data_release(pubkey);
    result = pygpgme_genkey_result(self->ctx);

    if (pygpgme_check_error(err)) {
        PyObject *err_type, *err_value, *err_traceback;

        PyErr_Fetch(&err_type, &err_value, &err_traceback);
        PyErr_NormalizeException(&err_type, &err_value, &err_traceback);

        if (!PyErr_GivenExceptionMatches(err_type, pygpgme_error))
            goto end;

        if (result != NULL) {
            PyObject_SetAttrString(err_value, "result", result);
            Py_DECREF(result);
        }
    end:
        PyErr_Restore(err_type, err_value, err_traceback);
        return NULL;
    }

    return (PyObject *) result;
}
开发者ID:andreimacavei,项目名称:pygpgme,代码行数:48,代码来源:pygpgme-context.c

示例11: channel_read

static PyObject *
channel_read(SSH2_ChannelObj *self, PyObject *args)
{
	int ret;
	int bufsiz;
	int stream_id = 0;
	PyObject *buf;

	if (!PyArg_ParseTuple(args, "i|i:read", &bufsiz, &stream_id))
		return NULL;

	if (bufsiz < 0) {
		PyErr_SetString(PyExc_ValueError, "negative size");
		return NULL;
	}

	if ((buf = PyBytes_FromStringAndSize(NULL, bufsiz)) == NULL)
		return NULL;

	Py_BEGIN_ALLOW_THREADS
	ret = libssh2_channel_read_ex(self->channel, stream_id, PyBytes_AS_STRING(buf), bufsiz);
	Py_END_ALLOW_THREADS

	if (ret < 0) {
		Py_DECREF(buf);

		/* We have to work around a bug in libssh2, that _libssh2_error() is not
		 * called by libssh2_channel_read_ex() when the transport layer returns
		 * LIBSSH2_ERROR_EAGAIN. So in that case the last error is not set and
		 * the RAISE_SSH2_ERROR macro will not be able to raise the correct exception.
		 * Thanks to Daniel Stenberg, who has fixed that issue now (see 2db4863).
		 * However in order that our bindings work correctly with older versions
		 * of libssh2, we need the workaround below. */
		if (ret == LIBSSH2_ERROR_EAGAIN) {
			PyObject *exc;
			PyObject *value;

			exc = PyObject_CallFunction(SSH2_Error, "s", "Would block");
			value=Py_BuildValue("i", ret);
			PyObject_SetAttrString(exc, "errno", value);
			PyErr_SetObject(SSH2_Error, exc);
			Py_DECREF(exc);
			Py_DECREF(value);
			return NULL;
		}

		RAISE_SSH2_ERROR(self->session)
	}
开发者ID:elektro79,项目名称:ssh4py,代码行数:48,代码来源:channel.c

示例12: PyTuple_New

    /*else*/ {
      __pyx_6 = PyTuple_New(3); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;}
      Py_INCREF(__pyx_v_d2);
      PyTuple_SET_ITEM(__pyx_6, 0, __pyx_v_d2);
      Py_INCREF(__pyx_v_p21);
      PyTuple_SET_ITEM(__pyx_6, 1, __pyx_v_p21);
      Py_INCREF(__pyx_v_p22);
      PyTuple_SET_ITEM(__pyx_6, 2, __pyx_v_p22);
      __pyx_r = __pyx_6;
      __pyx_6 = 0;
      goto __pyx_L0;
    }
    __pyx_L16:;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  Py_XDECREF(__pyx_10);
  __Pyx_AddTraceback("closestpair.closest_pair");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_min_p1);
  Py_DECREF(__pyx_v_min_p2);
  Py_DECREF(__pyx_v_i);
  Py_DECREF(__pyx_v_point);
  Py_DECREF(__pyx_v_point2);
  Py_DECREF(__pyx_v_d);
  Py_DECREF(__pyx_v_split);
  Py_DECREF(__pyx_v_d1);
  Py_DECREF(__pyx_v_p11);
  Py_DECREF(__pyx_v_p12);
  Py_DECREF(__pyx_v_d2);
  Py_DECREF(__pyx_v_p21);
  Py_DECREF(__pyx_v_p22);
  Py_DECREF(__pyx_v_points_in_strip);
  Py_DECREF(__pyx_v_split_at);
  Py_DECREF(__pyx_v_max_i);
  Py_DECREF(__pyx_v_sd);
  Py_DECREF(__pyx_v_points);
  return __pyx_r;
}

static __Pyx_InternTabEntry __pyx_intern_tab[] = {
  {&__pyx_n_append, "append"},
  {&__pyx_n_closest_pair, "closest_pair"},
  {&__pyx_n_distance, "distance"},
  {&__pyx_n_min, "min"},
  {&__pyx_n_sort, "sort"},
  {0, 0}
};

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_k1p, __pyx_k1, sizeof(__pyx_k1)},
  {0, 0, 0}
};

static struct PyMethodDef __pyx_methods[] = {
  {"distance", (PyCFunction)__pyx_f_11closestpair_distance, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11closestpair_distance},
  {"closest_pair", (PyCFunction)__pyx_f_11closestpair_closest_pair, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11closestpair_closest_pair},
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

PyMODINIT_FUNC initclosestpair(void); /*proto*/
PyMODINIT_FUNC initclosestpair(void) {
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("closestpair", __pyx_methods, 0, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;};
  Py_INCREF(__pyx_m);
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;};
  if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;};

  /* "/home/andrew/Programs/cluster/clusterer/closestpair.pyx":6 */
  return;
  __pyx_L1:;
  __Pyx_AddTraceback("closestpair");
}
开发者ID:EricSchles,项目名称:djangopeople,代码行数:90,代码来源:closestpair.c

示例13: initgtop

PyMODINIT_FUNC
initgtop(void)
{
	PyObject* module;

	glibtop_init();

	Py_AtExit(gtop_at_exit);

	module = Py_InitModule("gtop", (PyMethodDef*) gtop_methods);
	PyType_Ready((PyTypeObject*) &StructType);
	PyObject_SetAttrString(module, "_Struct", (void*) &StructType);

	register_constants(module);
	PyModule_AddObject(module, "siglist", build_siglist());
}
开发者ID:ZevenOS,项目名称:wnck-patches,代码行数:16,代码来源:gtop.c

示例14: psyco_errors_set

void
psyco_errors_set(PyObject *type)
{
    int i;
    char *name;

    for (i = 0; exctable[i].name; i++) {
        if (NULL == exctable[i].exc) { continue; }

        /* the name is the part after the last dot */
        name = strrchr(exctable[i].name, '.');
        name = name ? name + 1 : exctable[i].name;

        PyObject_SetAttrString(type, name, *exctable[i].exc);
    }
}
开发者ID:JonathanRRogers,项目名称:psycopg2,代码行数:16,代码来源:psycopgmodule.c

示例15: PyUnicodeString

void PyUnicodeString(char *name, unsigned short *value, long len)
{
    PyObject *obj;
    

    obj = PyUnicode_FromUnicode((unsigned short *)value, len);

    if(list_level>=0 && List[list_level]) {        
        PyList_Append(List[list_level], obj);
        Py_DECREF(obj);
        return;
    }

    PyObject_SetAttrString( interpreter_state->main_module, name, obj);
    Py_DECREF(obj);
}
开发者ID:pc,项目名称:pythonika,代码行数:16,代码来源:Pythonika.c


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