static PyObject* tp_new (PyTypeObject* type, PyObject* args, PyObject* kwds) { SELF self; soyatomsPosition* position = NULL; float radius = 1.0; soymaterialsMaterial* material = NULL; // Ensure no keywords were given if (!_PyArg_NoKeywords("soy.bodies.Sphere", kwds)) return NULL; // Parse arguments // TODO optional position radius and material parameters if (!PyArg_ParseTuple(args, "")) { return NULL; } // inherit base type self = (SELF) PyType_GenericNew(type, args, kwds); if (!self) return NULL; // new gobject self->g = soy_bodies_sphere_new(position, radius, material); // return self return (PyObject*) self; }
static PyObject * Alphabet_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { Alphabet *self = (Alphabet *)PyType_GenericNew(type, args, kwds); self->alphabet = NULL; return (PyObject *)self; }
static PyObject * Net_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { Net *self = (Net *)PyType_GenericNew(type, args, kwds); /*I believe PyType_GenericNew zeros the memory, so all pointers are NULL, etc */ self->batch_size = 1; return (PyObject *)self; }
static PyObject * StdIO_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { StdIO *self = (StdIO *)PyType_GenericNew(type, args, kwargs); if (!self) { return NULL; } return (PyObject *)self; }
static PyObject* tp_new (PyTypeObject *type, PyObject *args, PyObject *kwds) { SELF self; PySoy_scenes_Scene_Object* scene; PySoy_bodies_Body_Object* controlled; PySoy_atoms_Position_Object* dest; float radius, speed, granularity = -1.0f, fuzziness = -1.0f; int updates = FALSE, paused = FALSE; PyObject* bounds = Py_None; static char *kw[] = {"scene", "controlled", "dest", "speed", "granularity", "fuzziness", "bounds", "updates", "paused", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!O!O!ff|fOii", kw, &PySoy_scenes_Scene_Type, &scene, &PySoy_bodies_Body_Type, &controlled, &PySoy_atoms_Position_Type, &dest, &speed, &granularity, &fuzziness, &bounds, &updates, &paused)) return NULL; if (fuzziness == -1.0f) { fuzziness = speed/10000.0f; } else if (fuzziness < 0.0f) { PyErr_SetString(PyExc_ValueError, "'fuzziness' must be a number greater than 0"); return NULL; } self = (SELF) PyType_GenericNew(type, args, kwds); if (!self) return NULL; if (bounds == Py_None) { self->g = soy_controllers_space_navigator_new(scene->g, controlled->g, speed, fuzziness, granularity, dest->g, updates, paused); } else if (PySoy_atoms_Size_Check(bounds)) { soycontrollersgraphSpace* graph = soy_controllers_graph_space_new_with_size(scene->g, granularity, ((PySoy_atoms_Size_Object*)bounds)->g,NULL); self->g = soy_controllers_space_navigator_new_with_graph(scene->g, controlled->g, speed, fuzziness, (soycontrollersgraphIGraph*) graph, dest->g, updates, paused); } else if (PyNumber_Check(bounds)) { PyObject* flt = PyNumber_Float(bounds); if (flt == NULL) return NULL; radius = (float)PyFloat_AsDouble(flt); Py_DECREF(flt); if (PyErr_Occurred()) { return NULL; } soycontrollersgraphSpace* graph = soy_controllers_graph_space_new_with_radius(scene->g, granularity, radius,NULL); self->g = soy_controllers_space_navigator_new_with_graph(scene->g, controlled->g, speed, fuzziness, (soycontrollersgraphIGraph*) graph, dest->g, updates, paused); } else { PyErr_SetString(PyExc_ValueError, "'bounds' must be either a number greater then 0 or a soy.atoms.Size"); return NULL; } return (PyObject*) self; }
static PyObject * Request_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { Request *self = (Request *)PyType_GenericNew(type, args, kwargs); if (!self) { return NULL; } self->req_ptr = NULL; return (PyObject *)self; }
extern PyObject * Connection_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { ReQLConnection *self = (ReQLConnection *)PyType_GenericNew(type, args, kwargs); if (self != NULL) { self->reql_connection = NULL; } return (PyObject *)self; }
static PyObject * DNSResolver_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { DNSResolver *self = (DNSResolver *)PyType_GenericNew(type, args, kwargs); if (!self) { return NULL; } self->channel = NULL; return (PyObject *)self; }
static PyObject * cbson_dbref_tp_new (PyTypeObject *self, PyObject *args, PyObject *kwargs) { /* * TODO: Handle args and kwargs. */ return PyType_GenericNew(&cbson_dbref_type, args, kwargs); }
//PyObject *PyNewLowercaser_Helper(PyObject *, PyObject* args) PyObject *PyNewLowercaser_Helper(CSphLowercaser* aLower) { if(!aLower) return NULL; csfHelper_ToLowerObject *self; self = (csfHelper_ToLowerObject *)PyType_GenericNew(&csfHelper_ToLowerType, NULL, NULL); self->m_Lower = aLower; return (PyObject*)self; }
/* Allocate and initialize a new `Instruction' object given the associated * `xed_decoded_inst_t' structure. */ instruction_t *new_instruction(xed_decoded_inst_t *decoded_inst, xed_uint64_t runtime_address) { instruction_t *instruction; instruction = (instruction_t *)PyType_GenericNew(&type, NULL, NULL); instruction->decoded_inst = decoded_inst; instruction->inst = xed_decoded_inst_inst(decoded_inst); instruction->runtime_address = runtime_address; return instruction; }
static PyObject* tp_new(PyTypeObject* type, PyObject* args, PyObject* kwds) { SELF self; PySoy_bodies_Body_Object* py_bodyA; PySoy_bodies_Body_Object* py_bodyB; PySoy_materials_Material_Object* py_material = NULL; soyscenesScene* scene; soybodiesBody* bodyB; soymaterialsMaterial* material; static char* kw[] = {"bodyA", "bodyB", "material", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!O|O!", kw, &PySoy_bodies_Body_Type, &py_bodyA, &py_bodyB, &PySoy_materials_Material_Type, &py_material)) return NULL; // When bodyB is a Body if (PyObject_TypeCheck(py_bodyB, &PySoy_bodies_Body_Type)) { scene = py_bodyB->g->scene; bodyB = py_bodyB->g; } // When bodyB is a Scene else if (PyObject_TypeCheck(py_bodyB, &PySoy_scenes_Scene_Type)) { scene = ((PySoy_scenes_Scene_Object*) py_bodyB)->g; bodyB = NULL; } // Otherwise raise exception else { PyErr_SetString(PyExc_ValueError, "Second argument must be a Body or Scene"); return NULL; } // Ensure bodies are in the same scene if (py_bodyA->g->scene != scene) { PyErr_SetString(PyExc_ValueError, "Scene mismatch"); return NULL; } // Grab material material = (py_material) ? py_material->g : NULL; // Inherit base type self = (SELF) PyType_GenericNew(type, args, NULL); if(!self) return NULL; // Create gobject and return self->g = soy_joints_fixed_new(py_bodyA->g, bodyB, material); return (PyObject*) self; }
static PyObject* tp_new(PyTypeObject* type, PyObject* args, PyObject* kwds) { SELF self; soyscenesScene* scene; PySoy_scenes_Scene_Object* pyscene; PySoy_bodies_Body_Object* bodyOne; PySoy_bodies_Body_Object* bodyTwo; PySoy_atoms_Position_Object* anchor; PySoy_atoms_Axis_Object* axis1; PySoy_atoms_Axis_Object* axis2; if (PyArg_ParseTuple(args, "O!O!O!O!O!", &PySoy_bodies_Body_Type, &bodyOne, &PySoy_bodies_Body_Type, &bodyTwo, &PySoy_atoms_Position_Type, &anchor, &PySoy_atoms_Axis_Type, &axis1, &PySoy_atoms_Axis_Type, &axis2)) scene = bodyTwo->g->scene; else { PyErr_Clear(); if (PyArg_ParseTuple(args, "O!O!O!O!O!", &PySoy_bodies_Body_Type, &bodyOne, &PySoy_scenes_Scene_Type, &pyscene, &PySoy_atoms_Position_Type, &anchor, &PySoy_atoms_Axis_Type, &axis1, &PySoy_atoms_Axis_Type, &axis2)) scene = pyscene->g; else return NULL; } // Ensure bodies are in the same scene if (bodyOne->g->scene != scene) { PyErr_SetString(PyExc_ValueError, "Bodies must be in the same scene"); return NULL; } self = (SELF) PyType_GenericNew(type, args, NULL); if(!self) return NULL; if(!bodyTwo) self->g = soy_joints_piston_new(bodyOne->g, NULL, anchor->g, axis1->g, axis2->g, NULL); else self->g = soy_joints_piston_new(bodyOne->g, bodyTwo->g, anchor->g, axis1->g, axis2->g, NULL); return (PyObject*) self; }
static PyObject * simple_new(PyObject *self, PyObject *type_object) { if (!PyType_Check(type_object)) { PyErr_SetString(PyExc_TypeError, "simple_new argument must be a type object."); return NULL; } return PyType_GenericNew((PyTypeObject *)type_object, NULL, NULL); }
static PyObject * Channel_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { Channel *self = (Channel *)PyType_GenericNew(type, args, kwargs); if (!self) { return NULL; } self->channel = NULL; self->lib_initialized = False; return (PyObject *)self; }
static PyObject * RWLock_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { RWLock *self; self = (RWLock *)PyType_GenericNew(type, args, kwargs); if (!self) { return NULL; } self->initialized = False; return (PyObject *)self; }
static PyObject * Handle_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { Handle *self = (Handle *)PyType_GenericNew(type, args, kwargs); if (!self) { return NULL; } self->initialized = False; self->uv_handle = NULL; self->weakreflist = NULL; return (PyObject *)self; }
static PyObject * Barrier_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { Barrier *self; self = (Barrier *)PyType_GenericNew(type, args, kwargs); if (!self) { return NULL; } self->initialized = False; return (PyObject *)self; }
static PyObject * Condition_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { Condition *self; self = (Condition *)PyType_GenericNew(type, args, kwargs); if (!self) { return NULL; } self->initialized = False; return (PyObject *)self; }
static PyObject * Semaphore_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { Semaphore *self; self = (Semaphore *)PyType_GenericNew(type, args, kwargs); if (!self) { return NULL; } self->initialized = False; return (PyObject *)self; }
static PyObject *__new__(PyTypeObject *type, PyObject *args, PyObject *kwds) { pylal_COMPLEX16FrequencySeries *obj; LIGOTimeGPS zero = {0, 0}; obj = (pylal_COMPLEX16FrequencySeries *) PyType_GenericNew(type, args, kwds); if(!obj) return NULL; obj->series = XLALCreateCOMPLEX16FrequencySeries(NULL, &zero, 0.0, 0.0, &lalDimensionlessUnit, 0); obj->owner = NULL; return (PyObject *) obj; }
static PyObject * pymongoc_client_pool_tp_new (PyTypeObject *self, PyObject *args, PyObject *kwargs) { pymongoc_client_pool_t *pyclient_pool; mongoc_uri_t *uri; const char *uri_str; PyObject *key = NULL; PyObject *pyuri = NULL; PyObject *ret = NULL; if (kwargs) { key = PyString_FromStringAndSize("uri", 3); if (PyDict_Contains(kwargs, key)) { if (!(pyuri = PyDict_GetItem(kwargs, key))) { goto cleanup; } else if (!PyString_Check(pyuri)) { PyErr_SetString(PyExc_TypeError, "uri must be a string."); goto cleanup; } } } uri_str = pyuri ? PyString_AsString(pyuri) : NULL; uri = mongoc_uri_new (uri_str); pyclient_pool = (pymongoc_client_pool_t *) PyType_GenericNew (&pymongoc_client_pool_type, NULL, NULL); if (!pyclient_pool) { goto cleanup; } pyclient_pool->client_pool = mongoc_client_pool_new (uri); if (!pyclient_pool->client_pool) { PyErr_SetString (PyExc_TypeError, "Invalid URI string."); Py_DECREF (pyclient_pool); pyclient_pool = NULL; goto cleanup; } ret = (PyObject *)pyclient_pool; cleanup: if (uri) { mongoc_uri_destroy (uri); } Py_XDECREF (key); Py_XDECREF (pyuri); return ret; }
PyObject *PyNewDocument_Helper( CSphSource* pSource) { if(!pSource) return NULL; CSphSource_Python* pPySource = dynamic_cast<CSphSource_Python*>(pSource); if(!pPySource) return NULL; csfHelper_DocumentObject *self; self = (csfHelper_DocumentObject *)PyType_GenericNew(&csfHelper_DocumentType, NULL, NULL); self->m_Document = pPySource; return (PyObject*)self; }
static PyObject * RdkHandle_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { PyObject *self = PyType_GenericNew(type, args, kwds); if (self) { int res = pthread_rwlock_init(&((RdkHandle *)self)->rwlock, NULL); if (res) { Py_DECREF(self); return set_pykafka_error("RdKafkaException", "Failed rwlock init"); } } return self; }
static SELF tp_new (PyTypeObject* type, PyObject* args, PyObject* kwds) { SELF self; // inherit base type self = (SELF) PyType_GenericNew(type, args, kwds); if (!self) return NULL; // new gobject self->g = soy_widgets_window_new(); return self; }
/** * \ingroup python_interface_vertexseq * \brief Allocate a new vertex sequence object for a given graph * \return the allocated PyObject */ PyObject* igraphmodule_VertexSeq_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds) { igraphmodule_VertexSeqObject *o; o=(igraphmodule_VertexSeqObject*)PyType_GenericNew(subtype, args, kwds); if (o == NULL) return NULL; igraph_vs_all(&o->vs); o->gref=0; o->weakreflist=0; RC_ALLOC("VertexSeq", o); return (PyObject*)o; }
/** * \ingroup python_interface_edgeseq * \brief Allocate a new edge sequence object for a given graph * \param g the graph object being referenced * \return the allocated PyObject */ PyObject* igraphmodule_EdgeSeq_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds) { igraphmodule_EdgeSeqObject* o; o=(igraphmodule_EdgeSeqObject*)PyType_GenericNew(subtype, args, kwds); if (o == NULL) return NULL; igraph_es_all(&o->es, IGRAPH_EDGEORDER_ID); o->gref=0; o->weakreflist=0; RC_ALLOC("EdgeSeq", o); return (PyObject*)o; }
// Create a bound signal. PyObject *qpycore_pyqtBoundSignal_New(qpycore_pyqtSignal *unbound_signal, PyObject *bound_pyobject, QObject *bound_qobject) { qpycore_pyqtBoundSignal *bs = (qpycore_pyqtBoundSignal *)PyType_GenericNew(&qpycore_pyqtBoundSignal_Type, 0, 0); if (bs) { Py_INCREF((PyObject *)unbound_signal); bs->unbound_signal = unbound_signal; bs->bound_pyobject = bound_pyobject; bs->bound_qobject = bound_qobject; } return (PyObject *)bs; }
static PyObject * ec_new_for_custom_dealloc(PyTypeObject *type, PyObject *args, PyObject *kw) { /* This is for EC's that have deallocs. For these, we need to incref the type when we create an instance, because the deallocs will decref the type. */ PyObject *r; r = PyType_GenericNew(type, args, kw); if (r) { Py_INCREF(type); } return r; }
static PyObject* tp_new(PyTypeObject* type, PyObject* args, PyObject* kwds) { SELF self; soyscenesScene* scene; PySoy_scenes_Scene_Object* pyscene; PySoy_bodies_Body_Object* bodyOne; PySoy_bodies_Body_Object* bodyTwo; // ensure no keywords were given if (!_PyArg_NoKeywords("soy.joints.Joint", kwds)) return NULL; if (PyArg_ParseTuple(args, "O!O!", &PySoy_bodies_Body_Type, &bodyOne, &PySoy_bodies_Body_Type, &bodyTwo)) scene = bodyTwo->g->scene; else { PyErr_Clear(); if (PyArg_ParseTuple(args, "O!O!", &PySoy_bodies_Body_Type, &bodyOne, &PySoy_scenes_Scene_Type, &pyscene)) scene = pyscene->g; else return NULL; } // Ensure bodies are in the same scene if (bodyOne->g->scene != scene) { PyErr_SetString(PyExc_ValueError, "Bodies must be in the same scene"); return NULL; } self = (SELF) PyType_GenericNew(type, args, NULL); if(!self) return NULL; if(!bodyTwo) self->g = soy_joints_joint_new(scene, bodyOne->g, NULL, NULL, NULL, NULL, NULL); else self->g = soy_joints_joint_new(scene, bodyOne->g, bodyTwo->g, NULL, NULL, NULL, NULL); return (PyObject*) self; }