Revision: 41864
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41864
Author:   campbellbarton
Date:     2011-11-15 09:28:15 +0000 (Tue, 15 Nov 2011)
Log Message:
-----------
rename IDProp.c/h to idprop_py_api, since it was same name as BKE idprop.c with 
case changed.

Modified Paths:
--------------
    trunk/blender/source/blender/python/generic/CMakeLists.txt
    trunk/blender/source/blender/python/intern/bpy.c
    trunk/blender/source/blender/python/intern/bpy_rna.c

Added Paths:
-----------
    trunk/blender/source/blender/python/generic/idprop_py_api.c
    trunk/blender/source/blender/python/generic/idprop_py_api.h

Removed Paths:
-------------
    trunk/blender/source/blender/python/generic/IDProp.c
    trunk/blender/source/blender/python/generic/IDProp.h

Modified: trunk/blender/source/blender/python/generic/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/python/generic/CMakeLists.txt  2011-11-15 
09:22:52 UTC (rev 41863)
+++ trunk/blender/source/blender/python/generic/CMakeLists.txt  2011-11-15 
09:28:15 UTC (rev 41864)
@@ -33,17 +33,17 @@
 )
 
 set(SRC
-       IDProp.c
        bgl.c
        blf_py_api.c
        bpy_internal_import.c
+       idprop_py_api.c
        noise_py_api.c
        py_capi_utils.c
 
-       IDProp.h
        bgl.h
        blf_py_api.h
        bpy_internal_import.h
+       idprop_py_api.h
        noise_py_api.h
        py_capi_utils.h
 )

Deleted: trunk/blender/source/blender/python/generic/IDProp.c
===================================================================
--- trunk/blender/source/blender/python/generic/IDProp.c        2011-11-15 
09:22:52 UTC (rev 41863)
+++ trunk/blender/source/blender/python/generic/IDProp.c        2011-11-15 
09:28:15 UTC (rev 41864)
@@ -1,1389 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- * Contributor(s): Joseph Eagar, Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/python/generic/IDProp.c
- *  \ingroup pygen
- */
-
-
-#include <Python.h>
-
-#include "IDProp.h"
-#include "MEM_guardedalloc.h"
-
-#include "BLI_string.h"
-#include "BLI_utildefines.h"
-
-#include "BKE_idprop.h"
-
-
-#define USE_STRING_COERCE
-
-#ifdef USE_STRING_COERCE
-#include "py_capi_utils.h"
-#endif
-
-extern PyTypeObject BPy_IDArray_Type;
-extern PyTypeObject BPy_IDGroup_Iter_Type;
-extern PyTypeObject BPy_IDGroup_Type;
-
-/*********************** ID Property Main Wrapper Stuff ***************/
-
-/* use for both array and group */
-static long BPy_IDGroup_hash(BPy_IDProperty *self)
-{
-       return _Py_HashPointer(self->prop);
-}
-
-static PyObject *BPy_IDGroup_repr(BPy_IDProperty *self)
-{
-       return PyUnicode_FromFormat( "<bpy id property from \"%s\">", 
self->id->name);
-}
-
-PyObject *BPy_IDGroup_WrapData( ID *id, IDProperty *prop )
-{
-       switch ( prop->type ) {
-               case IDP_STRING:
-
-               if (prop->subtype == IDP_STRING_SUB_BYTE) {
-                       return PyBytes_FromStringAndSize(IDP_Array(prop), 
prop->len);
-               }
-               else {
-#ifdef USE_STRING_COERCE
-                       return PyC_UnicodeFromByteAndSize(IDP_Array(prop), 
prop->len - 1);
-#else
-                       return PyUnicode_FromStringAndSize(IDP_Array(prop), 
prop->len - 1);
-#endif
-               }
-
-               case IDP_INT:
-                       return PyLong_FromLong( (long)prop->data.val );
-               case IDP_FLOAT:
-                       return PyFloat_FromDouble( 
(double)(*(float*)(&prop->data.val)) );
-               case IDP_DOUBLE:
-                       return PyFloat_FromDouble( 
(*(double*)(&prop->data.val)) );
-               case IDP_GROUP:
-                       /*blegh*/
-                       {
-                               BPy_IDProperty *group = 
PyObject_New(BPy_IDProperty, &BPy_IDGroup_Type);
-                               group->id = id;
-                               group->prop = prop;
-                               return (PyObject*) group;
-                       }
-               case IDP_ARRAY:
-                       {
-                               BPy_IDProperty *array = 
PyObject_New(BPy_IDProperty, &BPy_IDArray_Type);
-                               array->id = id;
-                               array->prop = prop;
-                               return (PyObject*) array;
-                       }
-               case IDP_IDPARRAY: /* this could be better a internal type */
-                       {
-                               PyObject *seq = PyList_New(prop->len), *wrap;
-                               IDProperty *array= IDP_IDPArray(prop);
-                               int i;
-
-                               if (!seq) {
-                                       PyErr_Format(PyExc_RuntimeError, 
"BPy_IDGroup_MapDataToPy, IDP_IDPARRAY: PyList_New(%d) failed", prop->len);
-                                       return NULL;
-                               }
-
-                               for (i=0; i<prop->len; i++) {
-                                       wrap= BPy_IDGroup_WrapData(id, array++);
-
-                                       if (!wrap) /* BPy_IDGroup_MapDataToPy 
sets the error */
-                                               return NULL;
-
-                                       PyList_SET_ITEM(seq, i, wrap);
-                               }
-
-                               return seq;
-                       }
-               /* case IDP_IDPARRAY: TODO */
-       }
-       Py_RETURN_NONE;
-}
-
-#if 0 /* UNUSED, currenly assignment overwrites into new properties, rather 
than setting in-place */
-static int BPy_IDGroup_SetData(BPy_IDProperty *self, IDProperty *prop, 
PyObject *value)
-{
-       switch (prop->type) {
-               case IDP_STRING:
-               {
-                       char *st;
-                       if (!PyUnicode_Check(value)) {
-                               PyErr_SetString(PyExc_TypeError, "expected a 
string!");
-                               return -1;
-                       }
-#ifdef USE_STRING_COERCE
-                       {
-                               int alloc_len;
-                               PyObject *value_coerce= NULL;
-
-                               st= (char *)PyC_UnicodeAsByte(value, 
&value_coerce);
-                               alloc_len= strlen(st) + 1;
-
-                               st = _PyUnicode_AsString(value);
-                               IDP_ResizeArray(prop, alloc_len);
-                               memcpy(IDP_Array(prop), st, alloc_len);
-                               Py_XDECREF(value_coerce);
-                       }
-#else
-                       st = _PyUnicode_AsString(value);
-                       IDP_ResizeArray(prop, strlen(st)+1);
-                       strcpy(IDP_Array(prop), st);
-#endif
-
-                       return 0;
-               }
-
-               case IDP_INT:
-               {
-                       int ivalue= PyLong_AsSsize_t(value);
-                       if (ivalue==-1 && PyErr_Occurred()) {
-                               PyErr_SetString(PyExc_TypeError, "expected an 
int type");
-                               return -1;
-                       }
-                       prop->data.val = ivalue;
-                       break;
-               }
-               case IDP_FLOAT:
-               {
-                       float fvalue= (float)PyFloat_AsDouble(value);
-                       if (fvalue==-1 && PyErr_Occurred()) {
-                               PyErr_SetString(PyExc_TypeError, "expected a 
float");
-                               return -1;
-                       }
-                       *(float*)&self->prop->data.val = fvalue;
-                       break;
-               }
-               case IDP_DOUBLE:
-               {
-                       double dvalue= PyFloat_AsDouble(value);
-                       if (dvalue==-1 && PyErr_Occurred()) {
-                               PyErr_SetString(PyExc_TypeError, "expected a 
float");
-                               return -1;
-                       }
-                       *(double*)&self->prop->data.val = dvalue;
-                       break;
-               }
-               default:
-                       PyErr_SetString(PyExc_AttributeError, "attempt to set 
read-only attribute!");
-                       return -1;
-       }
-       return 0;
-}
-#endif
-
-static PyObject *BPy_IDGroup_GetName(BPy_IDProperty *self, void 
*UNUSED(closure))
-{
-       return PyUnicode_FromString(self->prop->name);
-}
-
-static int BPy_IDGroup_SetName(BPy_IDProperty *self, PyObject *value, void 
*UNUSED(closure))
-{
-       const char *name;
-       Py_ssize_t name_size;
-
-       if (!PyUnicode_Check(value)) {
-               PyErr_SetString(PyExc_TypeError, "expected a string!");
-               return -1;
-       }
-
-       name = _PyUnicode_AsStringAndSize(value, &name_size);
-
-       if (name_size > MAX_IDPROP_NAME) {
-               PyErr_SetString(PyExc_TypeError, "string length cannot exceed 
31 characters!");
-               return -1;
-       }
-
-       memcpy(self->prop->name, name, name_size);
-       return 0;
-}
-
-#if 0
-static PyObject *BPy_IDGroup_GetType(BPy_IDProperty *self)
-{
-       return PyLong_FromSsize_t(self->prop->type);
-}
-#endif
-
-static PyGetSetDef BPy_IDGroup_getseters[] = {
-       {(char *)"name", (getter)BPy_IDGroup_GetName, 
(setter)BPy_IDGroup_SetName, (char *)"The name of this Group.", NULL},
-        {NULL, NULL, NULL, NULL, NULL}
-};
-
-static Py_ssize_t BPy_IDGroup_Map_Len(BPy_IDProperty *self)
-{
-       if (self->prop->type != IDP_GROUP) {
-               PyErr_SetString(PyExc_TypeError, "len() of unsized object");
-               return -1;
-       }
-
-       return self->prop->len;
-}
-
-static PyObject *BPy_IDGroup_Map_GetItem(BPy_IDProperty *self, PyObject *item)
-{
-       IDProperty *idprop;
-       const char *name;
-
-       if (self->prop->type  != IDP_GROUP) {
-               PyErr_SetString(PyExc_TypeError, "unsubscriptable object");
-               return NULL;
-       }
-
-       name= _PyUnicode_AsString(item);
-
-       if (name == NULL) {
-               PyErr_SetString(PyExc_TypeError, "only strings are allowed as 
keys of ID properties");
-               return NULL;
-       }
-
-       idprop= IDP_GetPropertyFromGroup(self->prop, name);
-
-       if (idprop==NULL) {
-               PyErr_SetString(PyExc_KeyError, "key not in subgroup dict");
-               return NULL;
-       }
-
-       return BPy_IDGroup_WrapData(self->id, idprop);
-
-}
-
-/*returns NULL on success, error string on failure*/
-static int idp_sequence_type(PyObject *seq)
-{
-       PyObject *item;
-       int type= IDP_INT;
-
-       Py_ssize_t i, len = PySequence_Size(seq);
-       for (i=0; i < len; i++) {
-               item = PySequence_GetItem(seq, i);
-               if (PyFloat_Check(item)) {
-                       if (type == IDP_IDPARRAY) { /* mixed dict/int */
-                               Py_DECREF(item);
-                               return -1;
-                       }
-                       type= IDP_DOUBLE;
-               }
-               else if (PyLong_Check(item)) {
-                       if (type == IDP_IDPARRAY) { /* mixed dict/int */
-                               Py_DECREF(item);
-                               return -1;
-                       }
-               }
-               else if (PyMapping_Check(item)) {
-                       if (i != 0 && (type != IDP_IDPARRAY)) { /* mixed 
dict/int */
-                               Py_DECREF(item);
-                               return -1;
-                       }
-                       type= IDP_IDPARRAY;
-               }
-               else {
-                       Py_XDECREF(item);
-                       return -1;
-               }
-
-               Py_DECREF(item);
-       }
-
-       return type;
-}
-
-/* note: group can be a pointer array or a group.
- * assume we already checked key is a string. */
-const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, 
IDProperty *group, PyObject *ob)
-{
-       IDProperty *prop = NULL;
-       IDPropertyTemplate val = {0};
-
-       const char *name= "";
-
-       if (name_obj) {
-               Py_ssize_t name_size;
-               name = _PyUnicode_AsStringAndSize(name_obj, &name_size);
-               if (name_size > MAX_IDPROP_NAME) {
-                       return "the length of IDProperty names is limited to 31 
characters";
-               }
-       }
-
-       if (PyFloat_Check(ob)) {
-               val.d = PyFloat_AsDouble(ob);
-               prop = IDP_New(IDP_DOUBLE, &val, name);
-       }
-       else if (PyLong_Check(ob)) {
-               val.i = (int) PyLong_AsSsize_t(ob);
-               prop = IDP_New(IDP_INT, &val, name);
-       }
-       else if (PyUnicode_Check(ob)) {
-#ifdef USE_STRING_COERCE
-               PyObject *value_coerce= NULL;
-               val.string.str = (char *)PyC_UnicodeAsByte(ob, &value_coerce);
-               val.string.subtype = IDP_STRING_SUB_UTF8;
-               prop = IDP_New(IDP_STRING, &val, name);
-               Py_XDECREF(value_coerce);
-#else
-               val.str = _PyUnicode_AsString(ob);
-               prop = IDP_New(IDP_STRING, val, name);
-#endif
-       }
-       else if (PyBytes_Check(ob)) {
-               val.string.str= PyBytes_AS_STRING(ob);
-               val.string.len= PyBytes_GET_SIZE(ob);
-               val.string.subtype= IDP_STRING_SUB_BYTE;
-
-               prop = IDP_New(IDP_STRING, &val, name);
-               //prop = IDP_NewString(PyBytes_AS_STRING(ob), name, 
PyBytes_GET_SIZE(ob));
-               //prop->subtype= IDP_STRING_SUB_BYTE;
-       }
-       else if (PySequence_Check(ob)) {
-               PyObject *item;
-               int i;
-
-               if ((val.array.type= idp_sequence_type(ob)) == -1)
-                       return "only floats, ints and dicts are allowed in ID 
property arrays";
-
-               /*validate sequence and derive type.
-               we assume IDP_INT unless we hit a float
-               number; then we assume it's */
-
-               val.array.len = PySequence_Size(ob);
-
-               switch(val.array.type) {
-               case IDP_DOUBLE:
-                       prop = IDP_New(IDP_ARRAY, &val, name);

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to