Esempio n. 1
0
PyObject *
pycorba_any_new(CORBA_any *any)
{
    PyCORBA_Any *self;

    self =  PyObject_NEW(PyCORBA_Any, &PyCORBA_Any_Type);
    if (!self)
	return NULL;
    self->any._type = (CORBA_TypeCode)CORBA_Object_duplicate((CORBA_Object)any->_type, NULL);
    self->any._value = MateCORBA_copy_value(any->_value, any->_type);
    self->any._release = CORBA_FALSE;

    return (PyObject *)self;
}
Esempio n. 2
0
/*
 * News up a pyjiterator, which is just a pyjobject for iterators.
 */
PyJiterator_Object* pyjiterator_new() {
    /*
     * MSVC requires tp_base to be set here
     * See https://docs.python.org/2/extending/newtypes.html
     */
    if(!PyJiterator_Type.tp_base) {
        PyJiterator_Type.tp_base = &PyJobject_Type;
    }

    if(PyType_Ready(&PyJiterator_Type) < 0)
        return NULL;

    return PyObject_NEW(PyJiterator_Object, &PyJiterator_Type);
}
Esempio n. 3
0
static ClientObject*
alloc_ClientObject(void)
{
    ClientObject *client;
    if (client_numfree) {
        client = client_free_list[--client_numfree];
        _Py_NewReference((PyObject *)client);
        GDEBUG("use pooled %p", client);
    }else{
        client = PyObject_NEW(ClientObject, &ClientObjectType);
        GDEBUG("alloc %p", client);
    }
    return client;
}
Esempio n. 4
0
static PyObject *
NewCoordSwap()
{
    CoordSwapObject *newObject;
    newObject = PyObject_NEW(CoordSwapObject, &CoordSwapType);
    if(newObject == NULL)
        return NULL;
    if(defaultAtts)
        newObject->data = new CoordSwap(*defaultAtts);
    else
        newObject->data = new CoordSwap;
    newObject->owns = true;
    return (PyObject *)newObject;
}
Esempio n. 5
0
static PyObject *
FileWrapperObject_new(PyObject *self, PyObject *filelike, size_t blksize)
{
    FileWrapperObject *f;
    f = PyObject_NEW(FileWrapperObject, &FileWrapperType);
    if(f == NULL){
        return NULL;
    }

    f->filelike = filelike;
    Py_INCREF(f->filelike);
    GDEBUG("alloc FileWrapperObject %p", f);
    return (PyObject *)f;
}
Esempio n. 6
0
PyObject *
ilugi_FromIdentityInfo (ilu_IdentityInfo id)
{
  IlugiObject *	v	= PyObject_NEW(IlugiObject, &Ilugi_Type);

  if (v == 0)
    return 0;
  if (id->ii_type != ilu_GSSIdentity)
    return 0;
  v->id = id;
  v->name = ILU_NIL;
  v->localp = ilu_FALSE;
  return (PyObject *) v;
}
Esempio n. 7
0
PyObject *
_pygtk_style_helper_new(GtkStyle *style, int type, gpointer array)
{
    PyGtkStyleHelper_Object *self;

    self = (PyGtkStyleHelper_Object *)PyObject_NEW(PyGtkStyleHelper_Object,
						   &PyGtkStyleHelper_Type);
    if (self == NULL)
	return NULL;

    self->style = g_object_ref(style);
    self->type = type;
    self->array = array;
    return (PyObject *)self;
}
Esempio n. 8
0
PyObject *
_pygtk_tree_model_row_iter_new(GtkTreeModel *model, GtkTreeIter *parent_iter)
{
    PyGtkTreeModelRowIter *self;

    self = (PyGtkTreeModelRowIter *) PyObject_NEW(PyGtkTreeModelRowIter,
						  &PyGtkTreeModelRowIter_Type);
    if (self == NULL)
	return NULL;
    self->model = g_object_ref(model);
    /* iterate through child nodes */
    self->has_more = gtk_tree_model_iter_children(self->model, &self->iter,
						  parent_iter);
    return (PyObject *)self;
}
static PyObject *
vectors_bezier_stroke_new(PyGimpVectors *vectors, int stroke)
{
    PyGimpVectorsStroke *self;

    self = PyObject_NEW(PyGimpVectorsStroke, &PyGimpVectorsBezierStroke_Type);

    if (self == NULL)
        return NULL;

    self->vectors_ID = vectors->ID;
    self->stroke = stroke;

    return (PyObject *)self;
}
/**
 * pyglib_option_context_new:
 * @context: a GOptionContext
 *
 * Returns: A new GOptionContext wrapper.
 */
PyObject * 
pyglib_option_context_new (GOptionContext *context)
{
    PyGOptionContext *self;

    self = (PyGOptionContext *)PyObject_NEW(PyGOptionContext,
					    &PyGOptionContext_Type);
    if (self == NULL)
	return NULL;

    self->context = context;
    self->main_group = NULL;
    
    return (PyObject *)self;
}
Esempio n. 11
0
SWIGRUNTIME PyObject *
PySwigPacked_FromDataAndDesc(void *ptr, size_t size, const char *desc)
{
  PySwigPacked *self = PyObject_NEW(PySwigPacked, PySwigPacked_GetType());
  if (self == NULL) {
    return NULL;
  } else {
    void *pack = malloc(size);
    memcpy(pack, ptr, size);
    self->pack = pack;
    self->desc = desc;
    self->size = size;
    return (PyObject *) self;
  }
}
Esempio n. 12
0
      PyObject* PySymbolicExpression(triton::engines::symbolic::SymbolicExpression* symExpr) {
        SymbolicExpression_Object* object;

        if (symExpr == nullptr) {
          Py_INCREF(Py_None);
          return Py_None;
        }

        PyType_Ready(&SymbolicExpression_Type);
        object = PyObject_NEW(SymbolicExpression_Object, &SymbolicExpression_Type);
        if (object != NULL)
          object->symExpr = symExpr;

        return (PyObject*)object;
      }
Esempio n. 13
0
PyObject *
_pygtk_rc_style_helper_new(GtkRcStyle *rc_style, int type, gpointer array, GtkRcFlags is_set_flag)
{
    PyGtkRcStyleHelper_Object *self;

    self = (PyGtkRcStyleHelper_Object *)PyObject_NEW(PyGtkRcStyleHelper_Object,
                                                     &PyGtkRcStyleHelper_Type);
    if (self == NULL)
	return NULL;

    self->rc_style = g_object_ref(rc_style);
    self->type = type;
    self->array = array;
    self->is_set_flag = is_set_flag;
    return (PyObject *)self;
}
Esempio n. 14
0
static iciobject *
newiciobject(OSType creator)
{
	iciobject *self;
	OSStatus err;
	
	self = PyObject_NEW(iciobject, &Icitype);
	if (self == NULL)
		return NULL;
	if ((err=ICStart(&self->inst, creator)) != 0 ) {
		(void)PyMac_Error(err);
		PyObject_DEL(self);
		return NULL;
	}
	return self;
}
Esempio n. 15
0
static PyObject *
createMyPyObject (
  PyObject * self_dummy,
  PyObject * args ) {
  MyPyObject * self;
  char * string;
    self = PyObject_NEW(MyPyObject, & MyPyObjectClass);
    if (! self) {
        return (NULL);
    }
    if (! (PyArg_ParseTuple(args, "|s", & string))) {
        return ((void *) 0);
    }
    self->string = strdup(string);
    return ((PyObject *) self);
}
/**
 * pyglib_option_group_new:
 * @group: a GOptionGroup
 *
 * The returned GOptionGroup can't be used to set any hooks, translation domains
 * or add entries. It's only intend is, to use for GOptionContext.add_group().
 *
 * Returns: the GOptionGroup wrapper.
 */
PyObject * 
pyglib_option_group_new (GOptionGroup *group)
{
    PyGOptionGroup *self;

    self = (PyGOptionGroup *)PyObject_NEW(PyGOptionGroup,
					  &PyGOptionGroup_Type);
    if (self == NULL)
	return NULL;

    self->group = group;
    self->other_owner = TRUE;
    self->is_in_context = FALSE;
        
    return (PyObject *)self;
}
Esempio n. 17
0
static PyObject*
FileWrapper_New(PyObject* self, PyObject* args, PyObject* kwargs)
{
  PyObject* file;
  if(!PyArg_ParseTuple(args, "O:FileWrapper", &file))
    return NULL;
  if(!PyFile_Check(file)) {
    TYPE_ERROR("FileWrapper argument", "file", file);
    return NULL;
  }
  Py_INCREF(file);
  FileWrapper* wrapper = PyObject_NEW(FileWrapper, &FileWrapper_Type);
  PyFile_IncUseCount((PyFileObject*)file);
  wrapper->file = file;
  return (PyObject*)wrapper;
}
Esempio n. 18
0
PyObject *cmd_alloc(CS_CONNECTIONObj *conn)
{
    CS_COMMANDObj *self;
    CS_RETCODE status;
    CS_COMMAND *cmd;

    self = PyObject_NEW(CS_COMMANDObj, &CS_COMMANDType);
    if (self == NULL)
	return NULL;
    SY_LEAK_REG(self);
    self->is_eed = 0;
    self->cmd = NULL;
    self->conn = NULL;
    self->strip = conn->strip;
    self->debug = conn->debug;
    self->serial = cmd_serial++;

    /* PyErr_Clear(); */

    SY_CONN_BEGIN_THREADS(conn);
    status = ct_cmd_alloc(conn->conn, &cmd);
    SY_CONN_END_THREADS(conn);

    if (self->debug)
	debug_msg("ct_cmd_alloc(conn%d, &cmd) -> %s",
		  conn->serial, value_str(VAL_STATUS, status));
    if (PyErr_Occurred()) {
	if (self->debug)
	    debug_msg("\n");
	Py_DECREF(self);
	return NULL;
    }

    if (status != CS_SUCCEED) {
	Py_DECREF(self);
	if (self->debug)
	    debug_msg(", None\n");
	return Py_BuildValue("iO", status, Py_None);
    }

    self->cmd = cmd;
    self->conn = conn;
    Py_INCREF(self->conn);
    if (self->debug)
	debug_msg(", cmd%d\n", self->serial);
    return Py_BuildValue("iN", CS_SUCCEED, self);
}
static PyObject *
NewStatisticalTrendsAttributes(int useCurrent)
{
    StatisticalTrendsAttributesObject *newObject;
    newObject = PyObject_NEW(StatisticalTrendsAttributesObject, &StatisticalTrendsAttributesType);
    if(newObject == NULL)
        return NULL;
    if(useCurrent && currentAtts != 0)
        newObject->data = new StatisticalTrendsAttributes(*currentAtts);
    else if(defaultAtts != 0)
        newObject->data = new StatisticalTrendsAttributes(*defaultAtts);
    else
        newObject->data = new StatisticalTrendsAttributes;
    newObject->owns = true;
    newObject->parent = 0;
    return (PyObject *)newObject;
}
static PyObject *
NewExternalSurfaceAttributes(int useCurrent)
{
    ExternalSurfaceAttributesObject *newObject;
    newObject = PyObject_NEW(ExternalSurfaceAttributesObject, &ExternalSurfaceAttributesType);
    if(newObject == NULL)
        return NULL;
    if(useCurrent && currentAtts != 0)
        newObject->data = new ExternalSurfaceAttributes(*currentAtts);
    else if(defaultAtts != 0)
        newObject->data = new ExternalSurfaceAttributes(*defaultAtts);
    else
        newObject->data = new ExternalSurfaceAttributes;
    newObject->owns = true;
    newObject->parent = 0;
    return (PyObject *)newObject;
}
Esempio n. 21
0
static PyObject *
NewWindowInformation(int useCurrent)
{
    WindowInformationObject *newObject;
    newObject = PyObject_NEW(WindowInformationObject, &WindowInformationType);
    if(newObject == NULL)
        return NULL;
    if(useCurrent && currentAtts != 0)
        newObject->data = new WindowInformation(*currentAtts);
    else if(defaultAtts != 0)
        newObject->data = new WindowInformation(*defaultAtts);
    else
        newObject->data = new WindowInformation;
    newObject->owns = true;
    newObject->parent = 0;
    return (PyObject *)newObject;
}
static PyObject *
NewFiveFoldTetSubdivisionAttributes(int useCurrent)
{
    FiveFoldTetSubdivisionAttributesObject *newObject;
    newObject = PyObject_NEW(FiveFoldTetSubdivisionAttributesObject, &FiveFoldTetSubdivisionAttributesType);
    if(newObject == NULL)
        return NULL;
    if(useCurrent && currentAtts != 0)
        newObject->data = new FiveFoldTetSubdivisionAttributes(*currentAtts);
    else if(defaultAtts != 0)
        newObject->data = new FiveFoldTetSubdivisionAttributes(*defaultAtts);
    else
        newObject->data = new FiveFoldTetSubdivisionAttributes;
    newObject->owns = true;
    newObject->parent = 0;
    return (PyObject *)newObject;
}
static PyObject *
NewRadialResampleAttributes(int useCurrent)
{
    RadialResampleAttributesObject *newObject;
    newObject = PyObject_NEW(RadialResampleAttributesObject, &RadialResampleAttributesType);
    if(newObject == NULL)
        return NULL;
    if(useCurrent && currentAtts != 0)
        newObject->data = new RadialResampleAttributes(*currentAtts);
    else if(defaultAtts != 0)
        newObject->data = new RadialResampleAttributes(*defaultAtts);
    else
        newObject->data = new RadialResampleAttributes;
    newObject->owns = true;
    newObject->parent = 0;
    return (PyObject *)newObject;
}
static PyObject *
NewConstructDataBinningAttributes(int useCurrent)
{
    ConstructDataBinningAttributesObject *newObject;
    newObject = PyObject_NEW(ConstructDataBinningAttributesObject, &ConstructDataBinningAttributesType);
    if(newObject == NULL)
        return NULL;
    if(useCurrent && currentAtts != 0)
        newObject->data = new ConstructDataBinningAttributes(*currentAtts);
    else if(defaultAtts != 0)
        newObject->data = new ConstructDataBinningAttributes(*defaultAtts);
    else
        newObject->data = new ConstructDataBinningAttributes;
    newObject->owns = true;
    newObject->parent = 0;
    return (PyObject *)newObject;
}
Esempio n. 25
0
static PyObject *
NewEngineProperties(int useCurrent)
{
    EnginePropertiesObject *newObject;
    newObject = PyObject_NEW(EnginePropertiesObject, &EnginePropertiesType);
    if(newObject == NULL)
        return NULL;
    if(useCurrent && currentAtts != 0)
        newObject->data = new EngineProperties(*currentAtts);
    else if(defaultAtts != 0)
        newObject->data = new EngineProperties(*defaultAtts);
    else
        newObject->data = new EngineProperties;
    newObject->owns = true;
    newObject->parent = 0;
    return (PyObject *)newObject;
}
Esempio n. 26
0
PyObject *
pygimp_pdb_function_new(const char *name, const char *blurb, const char *help,
			const char *author, const char *copyright,
			const char *date, GimpPDBProcType proc_type,
			int n_params, int n_return_vals,
			GimpParamDef *params, GimpParamDef *return_vals)
{
    PyGimpPDBFunction *self;
    int i;

    self = PyObject_NEW(PyGimpPDBFunction, &PyGimpPDBFunction_Type);

    if (self == NULL)
	return NULL;

    self->name = g_strdup(name);
    self->proc_name = PyString_FromString(name ? name : "");
    self->proc_blurb = PyString_FromString(blurb ? blurb : "");
    self->proc_help = PyString_FromString(help ? help : "");
    self->proc_author = PyString_FromString(author ? author : "");
    self->proc_copyright = PyString_FromString(copyright ? copyright : "");
    self->proc_date = PyString_FromString(date ? date : "");
    self->proc_type = PyInt_FromLong(proc_type);
    self->nparams = n_params;
    self->nreturn_vals = n_return_vals;
    self->params = params;
    self->return_vals = return_vals;

    self->py_params = PyTuple_New(n_params);
    for (i = 0; i < n_params; i++)
	PyTuple_SetItem(self->py_params, i,
			Py_BuildValue("(iss)",
				      params[i].type,
				      params[i].name,
				      params[i].description));

    self->py_return_vals = PyTuple_New(n_return_vals);
    for (i = 0; i < n_return_vals; i++)
	PyTuple_SetItem(self->py_return_vals, i,
			Py_BuildValue("(iss)",
				      return_vals[i].type,
				      return_vals[i].name,
				      return_vals[i].description));

    return (PyObject *)self;
}
static PyObject *
NewProgrammableOpAttributes(int useCurrent)
{
    ProgrammableOpAttributesObject *newObject;
    newObject = PyObject_NEW(ProgrammableOpAttributesObject, &ProgrammableOpAttributesType);
    if(newObject == NULL)
        return NULL;
    if(useCurrent && currentAtts != 0)
        newObject->data = new ProgrammableOpAttributes(*currentAtts);
    else if(defaultAtts != 0)
        newObject->data = new ProgrammableOpAttributes(*defaultAtts);
    else
        newObject->data = new ProgrammableOpAttributes;
    newObject->owns = true;
    newObject->parent = 0;
    return (PyObject *)newObject;
}
Esempio n. 28
0
static PyObject *
NewavtTensorMetaData(int useCurrent)
{
    avtTensorMetaDataObject *newObject;
    newObject = PyObject_NEW(avtTensorMetaDataObject, &avtTensorMetaDataType);
    if(newObject == NULL)
        return NULL;
    if(useCurrent && currentAtts != 0)
        newObject->data = new avtTensorMetaData(*currentAtts);
    else if(defaultAtts != 0)
        newObject->data = new avtTensorMetaData(*defaultAtts);
    else
        newObject->data = new avtTensorMetaData;
    newObject->owns = true;
    newObject->parent = 0;
    return (PyObject *)newObject;
}
static PyObject *
NewInverseGhostZoneAttributes(int useCurrent)
{
    InverseGhostZoneAttributesObject *newObject;
    newObject = PyObject_NEW(InverseGhostZoneAttributesObject, &InverseGhostZoneAttributesType);
    if(newObject == NULL)
        return NULL;
    if(useCurrent && currentAtts != 0)
        newObject->data = new InverseGhostZoneAttributes(*currentAtts);
    else if(defaultAtts != 0)
        newObject->data = new InverseGhostZoneAttributes(*defaultAtts);
    else
        newObject->data = new InverseGhostZoneAttributes;
    newObject->owns = true;
    newObject->parent = 0;
    return (PyObject *)newObject;
}
Esempio n. 30
0
static PyObject *
NewColorControlPointList(int useCurrent)
{
    ColorControlPointListObject *newObject;
    newObject = PyObject_NEW(ColorControlPointListObject, &ColorControlPointListType);
    if(newObject == NULL)
        return NULL;
    if(useCurrent && currentAtts != 0)
        newObject->data = new ColorControlPointList(*currentAtts);
    else if(defaultAtts != 0)
        newObject->data = new ColorControlPointList(*defaultAtts);
    else
        newObject->data = new ColorControlPointList;
    newObject->owns = true;
    newObject->parent = 0;
    return (PyObject *)newObject;
}