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


C++ PyVarObject_HEAD_INIT函数代码示例

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


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

示例1: PyUnicode_FromString

  s = PyUnicode_FromString("\n");
  if (s == NULL)
    goto Done;
  result = PyUnicode_Join(s, pieces);
  Py_DECREF(s);

Done:
  Py_XDECREF(pieces);
  return result;
}

static PyObject * path_iter(PyObject *seq); /* forward declaration */


PyTypeObject PycairoPath_Type = {
  PyVarObject_HEAD_INIT((PyTypeObject *)0x7FFFFFFF, 0)
  //PyObject_HEAD_INIT(NULL)
  //0,				        /* ob_size */
  "cairo.Path",			/* tp_name */
  sizeof(PycairoPath),		/* tp_basicsize */
  0,					/* tp_itemsize */
  (destructor)path_dealloc,		/* tp_dealloc */
  0,					/* tp_print */
  0,					/* tp_getattr */
  0,					/* tp_setattr */
  0,					/* tp_compare */
  0,		                	/* tp_repr */
  0,					/* tp_as_number */
  0,              			/* tp_as_sequence */
  0,					/* tp_as_mapping */
  0,					/* tp_hash */
开发者ID:Lichtavat,项目名称:TCAX,代码行数:31,代码来源:path.c

示例2: ImpulseResponse_dealloc

ImpulseResponse_dealloc(ImpulseResponseP* self)
{
	if(self->impulseResponse)
		delete reinterpret_cast<std::shared_ptr<aud::ImpulseResponse>*>(self->impulseResponse);
	Py_TYPE(self)->tp_free((PyObject *)self);
}

static PyMethodDef ImpulseResponse_methods[] = {
	{ nullptr }  /* Sentinel */
};

PyDoc_STRVAR(M_aud_ImpulseResponse_doc,
	"An ImpulseResponse object represents a filter with which to convolve a sound.");

PyTypeObject ImpulseResponseType = {
	PyVarObject_HEAD_INIT(nullptr, 0)
	"aud.ImpulseResponse",					/* tp_name */
	sizeof(ImpulseResponseP),				/* tp_basicsize */
	0,										/* tp_itemsize */
	(destructor)ImpulseResponse_dealloc,			/* tp_dealloc */
	0,										/* tp_print */
	0,										/* tp_getattr */
	0,										/* tp_setattr */
	0,										/* tp_reserved */
	0,										/* tp_repr */
	0,										/* tp_as_number */
	0,										/* tp_as_sequence */
	0,										/* tp_as_mapping */
	0,										/* tp_hash  */
	0,										/* tp_call */
	0,										/* tp_str */
开发者ID:DethonUSAL,项目名称:audaspace,代码行数:31,代码来源:PyImpulseResponse.cpp

示例3: PyVarObject_HEAD_INIT

    {"getOptions", (PyCFunction) getOptions, METH_VARARGS},
    {"getOption", (PyCFunction) getOption, METH_VARARGS},
    {"setOption", (PyCFunction) setOption, METH_VARARGS},
    {"setAutoOption", (PyCFunction) setAutoOption, METH_VARARGS},

    {"startScan", (PyCFunction) startScan, METH_VARARGS},
    {"cancelScan", (PyCFunction) cancelScan, METH_VARARGS},
    {"readScan", (PyCFunction) readScan, METH_VARARGS},
    {"closeScan", (PyCFunction) closeScan, METH_VARARGS},
    {NULL, NULL}
};


static PyTypeObject ScanDevice_type =
{
    PyVarObject_HEAD_INIT( &PyType_Type, 0 ) /* ob_size */
    "_ScanDevice",                   /* tp_name */
    sizeof(_ScanDevice ),              /* tp_basicsize */
    0,                                     /* tp_itemsize */
    ( destructor ) deAlloc,           /* tp_dealloc */
    0,                                     /* tp_print */
    0,                      /* tp_getattr */
    0,                                     /* tp_setattr */
    0,                                     /* tp_compare */
    0,                                     /* tp_repr */
    0,                                     /* tp_as_number */
    0,                                     /* tp_as_sequence */
    0,                                     /* tp_as_mapping */
    0,                                     /* tp_hash */
    0,                                     /* tp_call */
    0,                                     /* tp_str */
开发者ID:danwallach,项目名称:VoteBox-v1,代码行数:31,代码来源:scanext.c

示例4: PyVarObject_HEAD_INIT

	namespace Python {

		// -------------------- Draw Service --------------------
		const char* DrawServiceBinder::msName = "DrawService";

		// ------------------------------------------
		PyTypeObject DrawServiceBinder::msType = {
			PyVarObject_HEAD_INIT(&PyType_Type, 0)
			"opde.services.DrawService",                   // char *tp_name; */
			sizeof(DrawServiceBinder::Object),  // int tp_basicsize; */
			0,                        // int tp_itemsize;       /* not used much */
			DrawServiceBinder::dealloc,   // destructor tp_dealloc; */
			0,			              // printfunc  tp_print;   */
			0,  // getattrfunc  tp_getattr; /* __getattr__ */
			0,   					  // setattrfunc  tp_setattr;  /* __setattr__ */
			0,				          // cmpfunc  tp_compare;  /* __cmp__ */
			repr,			              // reprfunc  tp_repr;    /* __repr__ */
			0,				          // PyNumberMethods *tp_as_number; */
			0,                        // PySequenceMethods *tp_as_sequence; */
			0,                        // PyMappingMethods *tp_as_mapping; */
			0,			              // hashfunc tp_hash;     /* __hash__ */
			0,                        // ternaryfunc tp_call;  /* __call__ */
			0,			              // reprfunc tp_str;      /* __str__ */
			PyObject_GenericGetAttr,  // getattrofunc tp_getattro; */
			0,			              // setattrofunc tp_setattro; */
			0,			              // PyBufferProcs *tp_as_buffer; */
			0,			              // long tp_flags; */
			0,			              // char *tp_doc;  */
			0,			              // traverseproc tp_traverse; */
			0,			              // inquiry tp_clear; */
			0,			              // richcmpfunc tp_richcompare; */
			0,			              // long tp_weaklistoffset; */
			0,			              // getiterfunc tp_iter; */
			0,			              // iternextfunc tp_iternext; */
			msMethods,	              // struct PyMethodDef *tp_methods; */
			0,			              // struct memberlist *tp_members; */
			0,			              // struct getsetlist *tp_getset; */
		};

		// ------------------------------------------
		PyMethodDef DrawServiceBinder::msMethods[] = {
				{"createSheet", createSheet, METH_VARARGS},
				{"destroySheet", destroySheet, METH_VARARGS},
				{"getSheet", getSheet, METH_VARARGS},
				{"setActiveSheet", setActiveSheet, METH_VARARGS},
				{"createDrawSource", createDrawSource, METH_VARARGS},
				{"createRenderedImage", createRenderedImage, METH_VARARGS},
				{"createRenderedLabel", createRenderedLabel, METH_VARARGS},
				{"destroyDrawOperation", destroyDrawOperation, METH_VARARGS},
				{"createAtlas", createAtlas, METH_VARARGS},
				{"destroyAtlas", destroyAtlas, METH_VARARGS},
				{"loadFont", loadFont, METH_VARARGS},
				{"setFontPalette", setFontPalette, METH_VARARGS},
				{NULL, NULL},
		};

		// ------------------------------------------
		PyObject* DrawServiceBinder::createSheet(PyObject* self, PyObject* args) {
			__PYTHON_EXCEPTION_GUARD_BEGIN_;

			DrawServicePtr o;

			if (!python_cast<DrawServicePtr>(self, &msType, &o))
				__PY_CONVERR_RET;


			// argument - the name of the sheet to create, string
			const char* sname;

			if (PyArg_ParseTuple(args, "s", &sname)) {
			    const DrawSheetPtr& i = o->createSheet(sname);

			    PyObject *o = DrawSheetBinder::create(i);

				return o;
			} else {
				// Invalid parameters
				PyErr_SetString(PyExc_TypeError, "Expected a string argument!");
				return NULL;
			}

			__PYTHON_EXCEPTION_GUARD_END_;
		}

		// ------------------------------------------
		PyObject* DrawServiceBinder::destroySheet(PyObject* self, PyObject* args) {
			__PYTHON_EXCEPTION_GUARD_BEGIN_;

			PyObject *result = NULL;
			DrawServicePtr o;

			if (!python_cast<DrawServicePtr>(self, &msType, &o))
				__PY_CONVERR_RET;


			PyObject *sheet;
			if (PyArg_ParseTuple(args, "O", &sheet)) {
				// cast to drawsheet and destroy
				DrawSheetPtr ds;

//.........这里部分代码省略.........
开发者ID:Painpillow,项目名称:openDarkEngine,代码行数:101,代码来源:DrawServiceBinder.cpp

示例5: publishType

// ------------------------------------------
void LinkServiceBinder::init(PyObject *module) {
    publishType(module, &msType, msName);

    LinkBinder::init(module);
    LinkQueryResultBinder::init(module);
    RelationBinder::init(module);
}

// -------------------- Link --------------------
const char *LinkBinder::msName = "Link";

// ------------------------------------------
PyTypeObject LinkBinder::msType = {
    PyVarObject_HEAD_INIT(&PyType_Type, 0) msName, // char *tp_name; */
    sizeof(LinkBinder::Base),                    // int tp_basicsize; */
    0,                   // int tp_itemsize;       /* not used much */
    LinkBinder::dealloc, // destructor tp_dealloc; */
    0,                   // printfunc  tp_print;   */
    LinkBinder::getattr, // getattrfunc  tp_getattr; /* __getattr__ */
};

// ------------------------------------------
PyObject *LinkBinder::getattr(PyObject *self, char *name) {
    Link *o;

    if (!python_cast<Link*>(self, &msType, &o))
        __PY_CONVERR_RET;

    if (!o)
开发者ID:volca02,项目名称:openDarkEngine,代码行数:30,代码来源:LinkServiceBinder.cpp

示例6: __Pyx_Generator_set_qualname

static int
__Pyx_Generator_set_qualname(__pyx_GeneratorObject *self, PyObject *value)
{
    PyObject *tmp;

#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = self->gi_qualname;
    Py_INCREF(value);
    self->gi_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}

static PyGetSetDef __pyx_Generator_getsets[] = {
    {(char *) "__name__", (getter)__Pyx_Generator_get_name, (setter)__Pyx_Generator_set_name,
     (char*) PyDoc_STR("name of the generator"), 0},
    {(char *) "__qualname__", (getter)__Pyx_Generator_get_qualname, (setter)__Pyx_Generator_set_qualname,
     (char*) PyDoc_STR("qualified name of the generator"), 0},
    {0, 0, 0, 0, 0}
};

static PyMemberDef __pyx_Generator_memberlist[] = {
    {(char *) "gi_running", T_BOOL, offsetof(__pyx_GeneratorObject, is_running), READONLY, NULL},
    {0, 0, 0, 0, 0}
};

static PyMethodDef __pyx_Generator_methods[] = {
    {"send", (PyCFunction) __Pyx_Generator_Send, METH_O, 0},
    {"throw", (PyCFunction) __Pyx_Generator_Throw, METH_VARARGS, 0},
    {"close", (PyCFunction) __Pyx_Generator_Close, METH_NOARGS, 0},
    {0, 0, 0, 0}
};

static PyTypeObject __pyx_GeneratorType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "generator",                        /*tp_name*/
    sizeof(__pyx_GeneratorObject),      /*tp_basicsize*/
    0,                                  /*tp_itemsize*/
    (destructor) __Pyx_Generator_dealloc,/*tp_dealloc*/
    0,                                  /*tp_print*/
    0,                                  /*tp_getattr*/
    0,                                  /*tp_setattr*/
#if PY_MAJOR_VERSION < 3
    0,                                  /*tp_compare*/
#else
    0,                                  /*reserved*/
#endif
    0,                                  /*tp_repr*/
    0,                                  /*tp_as_number*/
    0,                                  /*tp_as_sequence*/
    0,                                  /*tp_as_mapping*/
    0,                                  /*tp_hash*/
    0,                                  /*tp_call*/
    0,                                  /*tp_str*/
    0,                                  /*tp_getattro*/
    0,                                  /*tp_setattro*/
    0,                                  /*tp_as_buffer*/
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE, /*tp_flags*/
    0,                                  /*tp_doc*/
    (traverseproc) __Pyx_Generator_traverse,   /*tp_traverse*/
    0,                                  /*tp_clear*/
    0,                                  /*tp_richcompare*/
    offsetof(__pyx_GeneratorObject, gi_weakreflist), /*tp_weaklistoffset*/
    0,                                  /*tp_iter*/
    (iternextfunc) __Pyx_Generator_Next, /*tp_iternext*/
    __pyx_Generator_methods,            /*tp_methods*/
    __pyx_Generator_memberlist,         /*tp_members*/
    __pyx_Generator_getsets,            /*tp_getset*/
    0,                                  /*tp_base*/
    0,                                  /*tp_dict*/
    0,                                  /*tp_descr_get*/
    0,                                  /*tp_descr_set*/
    0,                                  /*tp_dictoffset*/
    0,                                  /*tp_init*/
    0,                                  /*tp_alloc*/
    0,                                  /*tp_new*/
    0,                                  /*tp_free*/
    0,                                  /*tp_is_gc*/
    0,                                  /*tp_bases*/
    0,                                  /*tp_mro*/
    0,                                  /*tp_cache*/
    0,                                  /*tp_subclasses*/
    0,                                  /*tp_weaklist*/
#if PY_VERSION_HEX >= 0x030400a1
    0,                                  /*tp_del*/
#else
    __Pyx_Generator_del,                /*tp_del*/
#endif
    0,                                  /*tp_version_tag*/
#if PY_VERSION_HEX >= 0x030400a1
    __Pyx_Generator_del,                /*tp_finalize*/
#endif
//.........这里部分代码省略.........
开发者ID:MaximKrivomaz,项目名称:arch1,代码行数:101,代码来源:Generator.c

示例7: life_support_dealloc

namespace boost { namespace python { namespace objects { 

struct life_support
{
    PyObject_HEAD
    PyObject* patient;
};

extern "C"
{
    static void
    life_support_dealloc(PyObject* self)
    {
        Py_XDECREF(((life_support*)self)->patient);
        self->ob_type->tp_free(self);
    }

    static PyObject *
    life_support_call(PyObject *self, PyObject *arg, PyObject * /*kw*/)
    {
        // Let the patient die now
        Py_XDECREF(((life_support*)self)->patient);
        ((life_support*)self)->patient = 0;
        // Let the weak reference die. This probably kills us.
        Py_XDECREF(PyTuple_GET_ITEM(arg, 0));
        return ::boost::python::detail::none();
    }
}

PyTypeObject life_support_type = {
    PyVarObject_HEAD_INIT(NULL, 0)//(&PyType_Type)
    const_cast<char*>("Boost.Python.life_support"),
    sizeof(life_support),
    0,
    life_support_dealloc,               /* tp_dealloc */
    0,                                  /* tp_print */
    0,                                  /* tp_getattr */
    0,                                  /* tp_setattr */
    0,                                  /* tp_compare */
    0, //(reprfunc)func_repr,                   /* tp_repr */
    0,                                  /* tp_as_number */
    0,                                  /* tp_as_sequence */
    0,                                  /* tp_as_mapping */
    0,                                  /* tp_hash */
    life_support_call,                  /* tp_call */
    0,                                  /* tp_str */
    0, // PyObject_GenericGetAttr,            /* tp_getattro */
    0, // PyObject_GenericSetAttr,            /* tp_setattro */
    0,                                  /* tp_as_buffer */
    Py_TPFLAGS_DEFAULT /* | Py_TPFLAGS_HAVE_GC */,/* tp_flags */
    0,                                  /* tp_doc */
    0, // (traverseproc)func_traverse,          /* tp_traverse */
    0,                                  /* tp_clear */
    0,                                  /* tp_richcompare */
    0, //offsetof(PyLife_SupportObject, func_weakreflist), /* tp_weaklistoffset */
    0,                                  /* tp_iter */
    0,                                  /* tp_iternext */
    0,                                  /* tp_methods */
    0, // func_memberlist,                      /* tp_members */
    0, //func_getsetlist,                       /* tp_getset */
    0,                                  /* tp_base */
    0,                                  /* tp_dict */
    0,                                  /* tp_descr_get */
    0,                                  /* tp_descr_set */
    0, //offsetof(PyLife_SupportObject, func_dict),      /* tp_dictoffset */
    0,                                      /* tp_init */
    0,                                      /* tp_alloc */
    0,                                      /* tp_new */
    0,                                      /* tp_free */
    0,                                      /* tp_is_gc */
    0,                                      /* tp_bases */
    0,                                      /* tp_mro */
    0,                                      /* tp_cache */
    0,                                      /* tp_subclasses */
    0,                                      /* tp_weaklist */
#if PYTHON_API_VERSION >= 1012
    0                                       /* tp_del */
#endif
};

PyObject* make_nurse_and_patient(PyObject* nurse, PyObject* patient)
{
    if (nurse == Py_None || nurse == patient)
        return nurse;
    
    if (Py_TYPE(&life_support_type) == 0)
    {
        Py_TYPE(&life_support_type) = &PyType_Type;
        PyType_Ready(&life_support_type);
    }
    
    life_support* system = PyObject_New(life_support, &life_support_type);
    if (!system)
        return 0;

    system->patient = 0;
    
    // We're going to leak this reference, but don't worry; the
    // life_support system decrements it when the nurse dies.
    PyObject* weakref = PyWeakref_NewRef(nurse, (PyObject*)system);
//.........这里部分代码省略.........
开发者ID:Faham,项目名称:bric-n-brac,代码行数:101,代码来源:life_support.cpp

示例8: PyVarObject_HEAD_INIT

   {"get_missing_byte_count", (PyCFunction)DataTransferRequest_get_missing_byte_count,
    METH_NOARGS, "Return count of bytes that couldn't be transferred. Note that this produces undefined behaviour if called on an object that's currently queued."},
   {NULL}  /* Sentinel */
};

static PyGetSetDef DataTransferRequest_getsetters[] = {
   {"opaque", (getter)DataTransferRequest_getopaque,
    (setter)DataTransferRequest_setopaque, "Opaque value", NULL},
   {"errno", (getter)DataTransferRequest_get_errno,
    (setter)DataTransferRequest_set_errno, "Errno of last I/O attempt. Undefined behaviour will result if accessed while this DTR is queued.", NULL},
   {NULL}  /* Sentinel */
};


static PyTypeObject DataTransferRequestType = {
   PyVarObject_HEAD_INIT(&PyType_Type, 0)
   "_blockfd.DataTransferRequest", /* tp_name */
   sizeof(DataTransferRequest),     /* tp_basicsize */
   0,                         /* tp_itemsize */
   (destructor)DataTransferRequest_dealloc,/* tp_dealloc */
   0,                         /* tp_print */
   0,                         /* tp_getattr */
   0,                         /* tp_setattr */
   0,                         /* tp_compare */
   0,                         /* tp_repr */
   0,                         /* tp_as_number */
   0,                         /* tp_as_sequence */
   0,                         /* tp_as_mapping */
   0,                         /* tp_hash  */
   0,                         /* tp_call */
   0,                         /* tp_str */
开发者ID:sh01,项目名称:gonium,代码行数:31,代码来源:_blockfdmodule.c

示例9: free

    free(num_str);
    return py_obj;
}

static PyMethodDef Reader_methods[] = {
    { "get",      Reader_get,      METH_VARARGS,
      "Get record for IP address" },
    { "metadata", Reader_metadata, METH_NOARGS,
      "Returns metadata object for database" },
    { "close",    Reader_close,    METH_NOARGS, "Closes database"},
    { NULL,       NULL,            0,           NULL        }
};

static PyTypeObject Reader_Type = {
    PyVarObject_HEAD_INIT(NULL, 0)
    .tp_basicsize = sizeof(Reader_obj),
    .tp_dealloc = Reader_dealloc,
    .tp_doc = "Reader object",
    .tp_flags = Py_TPFLAGS_DEFAULT,
    .tp_methods = Reader_methods,
    .tp_name = "Reader",
    .tp_init = Reader_init,
};

static PyMethodDef Metadata_methods[] = {
    { NULL, NULL, 0, NULL }
};

/* *INDENT-OFF* */
static PyMemberDef Metadata_members[] = {
    { "binary_format_major_version", T_OBJECT, offsetof(
开发者ID:0-vortex,项目名称:ZeroNet,代码行数:31,代码来源:maxminddb.c

示例10: spamlist_state_get

}

static PyObject *
spamlist_state_get(spamlistobject *self)
{
    return PyLong_FromLong(self->state);
}

static PyGetSetDef spamlist_getsets[] = {
    {"state", (getter)spamlist_state_get, NULL,
     PyDoc_STR("an int variable for demonstration purposes")},
    {0}
};

static PyTypeObject spamlist_type = {
    PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0)
    "xxsubtype.spamlist",
    sizeof(spamlistobject),
    0,
    0,                                          /* tp_dealloc */
    0,                                          /* tp_print */
    0,                                          /* tp_getattr */
    0,                                          /* tp_setattr */
    0,                                          /* tp_reserved */
    0,                                          /* tp_repr */
    0,                                          /* tp_as_number */
    0,                                          /* tp_as_sequence */
    0,                                          /* tp_as_mapping */
    0,                                          /* tp_hash */
    0,                                          /* tp_call */
    0,                                          /* tp_str */
开发者ID:Apoorvadabhere,项目名称:cpython,代码行数:31,代码来源:xxsubtype.c

示例11: bpy_lib_dealloc

static PyMethodDef bpy_lib_methods[] = {
    {"__enter__", (PyCFunction)bpy_lib_enter, METH_NOARGS},
    {"__exit__", (PyCFunction)bpy_lib_exit, METH_VARARGS},
    {"__dir__", (PyCFunction)bpy_lib_dir, METH_NOARGS},
    {NULL} /* sentinel */
};

static void bpy_lib_dealloc(BPy_Library *self)
{
  Py_XDECREF(self->dict);
  Py_TYPE(self)->tp_free(self);
}

static PyTypeObject bpy_lib_Type = {
    PyVarObject_HEAD_INIT(NULL, 0) "bpy_lib", /* tp_name */
    sizeof(BPy_Library),                      /* tp_basicsize */
    0,                                        /* tp_itemsize */
    /* methods */
    (destructor)bpy_lib_dealloc, /* tp_dealloc */
    NULL,                        /* printfunc tp_print; */
    NULL,                        /* getattrfunc tp_getattr; */
    NULL,                        /* setattrfunc tp_setattr; */
    NULL,
    /* tp_compare */ /* DEPRECATED in python 3.0! */
    NULL,            /* tp_repr */

    /* Method suites for standard classes */

    NULL, /* PyNumberMethods *tp_as_number; */
    NULL, /* PySequenceMethods *tp_as_sequence; */
开发者ID:dfelinto,项目名称:blender,代码行数:30,代码来源:bpy_library_load.c

示例12: PyObject_DEL

            (self->destructor)(self->cobject);
    }
    PyObject_DEL(self);
}


PyDoc_STRVAR(PyCObject_Type__doc__,
"C objects to be exported from one extension module to another\n\
\n\
C objects are used for communication between extension modules.  They\n\
provide a way for an extension module to export a C interface to other\n\
extension modules, so that extension modules can use the Python import\n\
mechanism to link to one another.");

PyTypeObject PyCObject_Type = {
    PyVarObject_HEAD_INIT(/* Pyston change: &PyType_Type */ NULL, 0)
    "PyCObject",		/*tp_name*/
    sizeof(PyCObject),		/*tp_basicsize*/
    0,				/*tp_itemsize*/
    /* methods */
    (destructor)PyCObject_dealloc, /*tp_dealloc*/
    0,				/*tp_print*/
    0,				/*tp_getattr*/
    0,				/*tp_setattr*/
    0,				/*tp_compare*/
    0,				/*tp_repr*/
    0,				/*tp_as_number*/
    0,				/*tp_as_sequence*/
    0,				/*tp_as_mapping*/
    0,				/*tp_hash*/
    0,				/*tp_call*/
开发者ID:ChinaQuants,项目名称:pyston,代码行数:31,代码来源:cobject.c

示例13: FetchException

static wchar_t program_name[] = L"qrenderdoc";
static wchar_t python_home[1024] = {0};

struct OutputRedirector
{
  PyObject_HEAD;
  union
  {
    // we union with a uint64_t to ensure it's always a ulonglong even on 32-bit
    uint64_t dummy;
    PythonContext *context;
  };
  int isStdError;
};

static PyTypeObject OutputRedirectorType = {PyVarObject_HEAD_INIT(NULL, 0)};

static PyMethodDef OutputRedirector_methods[] = {
    {"write", NULL, METH_VARARGS, "Writes to the output window"},
    {"flush", NULL, METH_NOARGS, "Does nothing - only provided for compatibility"},
    {NULL}};

PyObject *PythonContext::main_dict = NULL;

void FetchException(QString &typeStr, QString &valueStr, int &finalLine, QList<QString> &frames)
{
  PyObject *exObj = NULL, *valueObj = NULL, *tracebackObj = NULL;

  PyErr_Fetch(&exObj, &valueObj, &tracebackObj);

  PyErr_NormalizeException(&exObj, &valueObj, &tracebackObj);
开发者ID:cgmb,项目名称:renderdoc,代码行数:31,代码来源:PythonContext.cpp

示例14: PyStream_write

namespace pyr {

struct PyStream {
  PyObject_HEAD
  std::ostream *stream;
};

PyObject* PyStream_write(PyObject* self, PyObject* args) {
  std::size_t written(0);
  PyStream* selfimpl = reinterpret_cast<PyStream*>(self);
  if (selfimpl->stream) {
    char* data;
    if (!PyArg_ParseTuple(args, "s", &data))
      return 0;

    std::string str(data);
    // TODO: Make log prefix parameterizables
    *(selfimpl->stream) << std::string("PyR: ") << str << std::endl;
    written = str.size();
  }
  return PyLong_FromSize_t(written);
}

PyObject* PyStream_flush(PyObject* self, PyObject* args) {
  // no-op
  return Py_BuildValue("");
}

PyMethodDef PyStream_methods[] = {
  {"write", PyStream_write, METH_VARARGS, "sys.PyStream.write"},
  {"flush", PyStream_flush, METH_VARARGS, "sys.PyStream.flush"},
  {0, 0, 0, 0} // sentinel
};

PyTypeObject PyStreamType = {
  PyVarObject_HEAD_INIT(0, 0)
  "PyR.PyStreamType",     /* tp_name */
  sizeof(PyStream),       /* tp_basicsize */
  0,                    /* tp_itemsize */
  0,                    /* tp_dealloc */
  0,                    /* tp_print */
  0,                    /* tp_getattr */
  0,                    /* tp_setattr */
  0,                    /* tp_reserved */
  0,                    /* tp_repr */
  0,                    /* tp_as_number */
  0,                    /* tp_as_sequence */
  0,                    /* tp_as_mapping */
  0,                    /* tp_hash  */
  0,                    /* tp_call */
  0,                    /* tp_str */
  0,                    /* tp_getattro */
  0,                    /* tp_setattro */
  0,                    /* tp_as_buffer */
  Py_TPFLAGS_DEFAULT,   /* tp_flags */
  "PyR.PyStream objects", /* tp_doc */
  0,                    /* tp_traverse */
  0,                    /* tp_clear */
  0,                    /* tp_richcompare */
  0,                    /* tp_weaklistoffset */
  0,                    /* tp_iter */
  0,                    /* tp_iternext */
  PyStream_methods,       /* tp_methods */
  0,                    /* tp_members */
  0,                    /* tp_getset */
  0,                    /* tp_base */
  0,                    /* tp_dict */
  0,                    /* tp_descr_get */
  0,                    /* tp_descr_set */
  0,                    /* tp_dictoffset */
  0,                    /* tp_init */
  0,                    /* tp_alloc */
  PyType_GenericNew,    /* tp_new */
};

PyMODINIT_FUNC PyInit_PyR(void) {
  if (PyType_Ready(&PyStreamType) < 0) {
    return;
  }

  //PyObject *mod = PyModule_New("pyr");
  PyObject *mod = Py_InitModule("pyr", NULL);
  if (mod) {
    Py_INCREF(&PyStreamType);
    //PyModule_AddObject(mod, "PyStream", (PyObject *)&PyStreamType);
  }
}

PyObject *PyStream_FromStream(std::ostream *stream) {
  PyObject *pystream = PyStreamType.tp_new(&PyStreamType, 0, 0);
  PyStream* impl = reinterpret_cast<PyStream*>(pystream);
  impl->stream = stream;
  return pystream;
}

PyObject *set_stdstream(std::string name, PyObject *pystream) {
  PyObject *old_pystream = PySys_GetObject(const_cast<char*>(name.c_str())); // borrowed
  Py_XINCREF(pystream);
  PySys_SetObject(const_cast<char*>(name.c_str()), pystream);
  Py_XDECREF(old_pystream);
//.........这里部分代码省略.........
开发者ID:nonsleepr,项目名称:PyR,代码行数:101,代码来源:py_stream.cpp

示例15: IntegrationType_from_BPy_IntegrationType

  static const char *kwlist[] = {"sigma", "integration_type", NULL};
  PyObject *obj = 0;
  double d;

  if (!PyArg_ParseTupleAndKeywords(
          args, kwds, "d|O!", (char **)kwlist, &d, &IntegrationType_Type, &obj))
    return -1;
  IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN;
  self->py_uf1D_double.uf1D_double = new Functions1D::LocalAverageDepthF1D(d, t);
  return 0;
}

/*-----------------------BPy_LocalAverageDepthF1D type definition ------------------------------*/

PyTypeObject LocalAverageDepthF1D_Type = {
    PyVarObject_HEAD_INIT(NULL, 0) "LocalAverageDepthF1D", /* tp_name */
    sizeof(BPy_LocalAverageDepthF1D),                      /* tp_basicsize */
    0,                                                     /* tp_itemsize */
    0,                                                     /* tp_dealloc */
    0,                                                     /* tp_print */
    0,                                                     /* tp_getattr */
    0,                                                     /* tp_setattr */
    0,                                                     /* tp_reserved */
    0,                                                     /* tp_repr */
    0,                                                     /* tp_as_number */
    0,                                                     /* tp_as_sequence */
    0,                                                     /* tp_as_mapping */
    0,                                                     /* tp_hash  */
    0,                                                     /* tp_call */
    0,                                                     /* tp_str */
    0,                                                     /* tp_getattro */
开发者ID:dfelinto,项目名称:blender,代码行数:31,代码来源:BPy_LocalAverageDepthF1D.cpp


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