Revision: 44895
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44895
Author:   campbellbarton
Date:     2012-03-15 06:08:27 +0000 (Thu, 15 Mar 2012)
Log Message:
-----------
prepare for adding bmesh py api for customdata layer access - no functional 
changes.

Modified Paths:
--------------
    trunk/blender/source/blender/python/bmesh/CMakeLists.txt
    trunk/blender/source/blender/python/bmesh/bmesh_py_api.c
    trunk/blender/source/blender/python/bmesh/bmesh_py_types.c

Added Paths:
-----------
    trunk/blender/source/blender/python/bmesh/bmesh_py_types_select.c
    trunk/blender/source/blender/python/bmesh/bmesh_py_types_select.h

Removed Paths:
-------------
    trunk/blender/source/blender/python/bmesh/bmesh_py_select.c
    trunk/blender/source/blender/python/bmesh/bmesh_py_select.h

Modified: trunk/blender/source/blender/python/bmesh/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/python/bmesh/CMakeLists.txt    2012-03-15 
05:59:44 UTC (rev 44894)
+++ trunk/blender/source/blender/python/bmesh/CMakeLists.txt    2012-03-15 
06:08:27 UTC (rev 44895)
@@ -33,13 +33,15 @@
 
 set(SRC
        bmesh_py_api.c
-       bmesh_py_select.c
        bmesh_py_types.c
+       bmesh_py_types_customdata.c
+       bmesh_py_types_select.c
        bmesh_py_utils.c
 
        bmesh_py_api.h
-       bmesh_py_select.h
        bmesh_py_types.h
+       bmesh_py_types_customdata.h
+       bmesh_py_types_select.h
        bmesh_py_utils.h
 )
 

Modified: trunk/blender/source/blender/python/bmesh/bmesh_py_api.c
===================================================================
--- trunk/blender/source/blender/python/bmesh/bmesh_py_api.c    2012-03-15 
05:59:44 UTC (rev 44894)
+++ trunk/blender/source/blender/python/bmesh/bmesh_py_api.c    2012-03-15 
06:08:27 UTC (rev 44895)
@@ -34,8 +34,8 @@
 #include "bmesh.h"
 
 #include "bmesh_py_types.h"
+#include "bmesh_py_types_select.h"
 #include "bmesh_py_utils.h"
-#include "bmesh_py_select.h"
 
 #include "BLI_utildefines.h"
 

Deleted: trunk/blender/source/blender/python/bmesh/bmesh_py_select.c
===================================================================
--- trunk/blender/source/blender/python/bmesh/bmesh_py_select.c 2012-03-15 
05:59:44 UTC (rev 44894)
+++ trunk/blender/source/blender/python/bmesh/bmesh_py_select.c 2012-03-15 
06:08:27 UTC (rev 44895)
@@ -1,454 +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.
- *
- * The Original Code is Copyright (C) 2012 Blender Foundation.
- * All rights reserved.
- *
- * Contributor(s): Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/python/bmesh/bmesh_py_select.c
- *  \ingroup pybmesh
- *
- * This file defines the types for 'BMesh.select_history'
- * sequence and iterator.
- *
- * select_history is very loosely based on pytons set() type,
- * since items can only exist once. however they do have an order.
- */
-
-#include <Python.h>
-
-#include "bmesh.h"
-
-#include "bmesh_py_types.h"
-#include "bmesh_py_select.h"
-
-#include "BLI_utildefines.h"
-#include "BLI_listbase.h"
-
-#include "BKE_tessmesh.h"
-
-#include "DNA_mesh_types.h"
-
-#include "../generic/py_capi_utils.h"
-
-#include "bmesh_py_api.h" /* own include */
-
-PyDoc_STRVAR(bpy_bmeditselseq_active_doc,
-"The last selected element or None (read-only).\n\n:type: :class:`BMVert`, 
:class:`BMEdge` or :class:`BMFace`"
-);
-static PyObject *bpy_bmeditselseq_active_get(BPy_BMEditSelSeq *self, void 
*UNUSED(closure))
-{
-       BMEditSelection *ese;
-       BPY_BM_CHECK_OBJ(self);
-
-       if ((ese = self->bm->selected.last)) {
-               return BPy_BMElem_CreatePyObject(self->bm, &ese->ele->head);
-       }
-       else {
-               Py_RETURN_NONE;
-       }
-}
-
-static PyGetSetDef bpy_bmeditselseq_getseters[] = {
-    {(char *)"active", (getter)bpy_bmeditselseq_active_get, (setter)NULL, 
(char *)bpy_bmeditselseq_active_doc, NULL},
-    {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
-};
-
-PyDoc_STRVAR(bpy_bmeditselseq_validate_doc,
-".. method:: validate()\n"
-"\n"
-"   Ensures all elements in the selection history are selected.\n"
-);
-static PyObject *bpy_bmeditselseq_validate(BPy_BMEditSelSeq *self)
-{
-       BPY_BM_CHECK_OBJ(self);
-       BM_select_history_validate(self->bm);
-       Py_RETURN_NONE;
-}
-
-PyDoc_STRVAR(bpy_bmeditselseq_clear_doc,
-".. method:: clear()\n"
-"\n"
-"   Empties the selection history.\n"
-);
-static PyObject *bpy_bmeditselseq_clear(BPy_BMEditSelSeq *self)
-{
-       BPY_BM_CHECK_OBJ(self);
-       BM_select_history_clear(self->bm);
-       Py_RETURN_NONE;
-}
-
-PyDoc_STRVAR(bpy_bmeditselseq_add_doc,
-".. method:: add(element)\n"
-"\n"
-"   Add an element to the selection history (no action taken if its already 
added).\n"
-);
-static PyObject *bpy_bmeditselseq_add(BPy_BMEditSelSeq *self, BPy_BMElem 
*value)
-{
-       BPY_BM_CHECK_OBJ(self);
-
-       if ((BPy_BMVert_Check(value) ||
-            BPy_BMEdge_Check(value) ||
-            BPy_BMFace_Check(value)) == FALSE)
-       {
-               PyErr_Format(PyExc_TypeError,
-                            "Expected a BMVert/BMedge/BMFace not a %.200s", 
Py_TYPE(value)->tp_name);
-               return NULL;
-       }
-
-       BPY_BM_CHECK_OBJ(value);
-
-       if (self->bm != value->bm)      {
-               PyErr_SetString(PyExc_ValueError,
-                               "Element is not from this mesh");
-               return NULL;
-       }
-
-       BM_select_history_store(self->bm, value->ele);
-
-       Py_RETURN_NONE;
-}
-
-PyDoc_STRVAR(bpy_bmeditselseq_remove_doc,
-".. method:: remove(element)\n"
-"\n"
-"   Remove an element from the selection history.\n"
-);
-static PyObject *bpy_bmeditselseq_remove(BPy_BMEditSelSeq *self, BPy_BMElem 
*value)
-{
-       BPY_BM_CHECK_OBJ(self);
-
-       if ((BPy_BMVert_Check(value) ||
-            BPy_BMEdge_Check(value) ||
-            BPy_BMFace_Check(value)) == FALSE)
-       {
-               PyErr_Format(PyExc_TypeError,
-                            "Expected a BMVert/BMedge/BMFace not a %.200s", 
Py_TYPE(value)->tp_name);
-               return NULL;
-       }
-
-       BPY_BM_CHECK_OBJ(value);
-
-       if ((self->bm != value->bm) ||
-           (BM_select_history_remove(self->bm, value->ele) == FALSE))
-       {
-               PyErr_SetString(PyExc_ValueError,
-                               "Element not found in selection history");
-               return NULL;
-       }
-
-       Py_RETURN_NONE;
-}
-
-static struct PyMethodDef bpy_bmeditselseq_methods[] = {
-    {"validate", (PyCFunction)bpy_bmeditselseq_validate, METH_NOARGS, 
bpy_bmeditselseq_validate_doc},
-    {"clear",    (PyCFunction)bpy_bmeditselseq_clear,    METH_NOARGS, 
bpy_bmeditselseq_clear_doc},
-
-    {"add",      (PyCFunction)bpy_bmeditselseq_add,      METH_O,      
bpy_bmeditselseq_add_doc},
-    {"remove",   (PyCFunction)bpy_bmeditselseq_remove,   METH_O,      
bpy_bmeditselseq_remove_doc},
-    {NULL, NULL, 0, NULL}
-};
-
-
-/* Sequences
- * ========= */
-
-static Py_ssize_t bpy_bmeditselseq_length(BPy_BMEditSelSeq *self)
-{
-       BPY_BM_CHECK_INT(self);
-
-       return BLI_countlist(&self->bm->selected);
-}
-
-static PyObject *bpy_bmeditselseq_subscript_int(BPy_BMEditSelSeq *self, int 
keynum)
-{
-       BMEditSelection *ese;
-
-       BPY_BM_CHECK_OBJ(self);
-
-       if (keynum < 0) {
-               ese = BLI_rfindlink(&self->bm->selected, -1 - keynum);
-       }
-       else {
-               ese = BLI_findlink(&self->bm->selected, keynum);
-       }
-
-       if (ese) {
-               return BPy_BMElem_CreatePyObject(self->bm, &ese->ele->head);
-       }
-       else {
-               PyErr_Format(PyExc_IndexError,
-                            "BMElemSeq[index]: index %d out of range", keynum);
-               return NULL;
-       }
-}
-
-static PyObject *bpy_bmeditselseq_subscript_slice(BPy_BMEditSelSeq *self, 
Py_ssize_t start, Py_ssize_t stop)
-{
-       int count = 0;
-       int ok;
-
-       PyObject *list;
-       PyObject *item;
-       BMEditSelection *ese;
-
-       BPY_BM_CHECK_OBJ(self);
-
-       list = PyList_New(0);
-
-       ese = self->bm->selected.first;
-
-       ok = (ese != NULL);
-
-       if (UNLIKELY(ok == FALSE)) {
-               return list;
-       }
-
-       /* first loop up-until the start */
-       for (ok = TRUE; ok; ok = ((ese = ese->next) != NULL)) {
-               if (count == start) {
-                       break;
-               }
-               count++;
-       }
-
-       /* add items until stop */
-       while ((ese = ese->next)) {
-               item = BPy_BMElem_CreatePyObject(self->bm, &ese->ele->head);
-               PyList_Append(list, item);
-               Py_DECREF(item);
-
-               count++;
-               if (count == stop) {
-                       break;
-               }
-       }
-
-       return list;
-}
-
-static PyObject *bpy_bmeditselseq_subscript(BPy_BMEditSelSeq *self, PyObject 
*key)
-{
-       /* dont need error check here */
-       if (PyIndex_Check(key)) {
-               Py_ssize_t i = PyNumber_AsSsize_t(key, PyExc_IndexError);
-               if (i == -1 && PyErr_Occurred())
-                       return NULL;
-               return bpy_bmeditselseq_subscript_int(self, i);
-       }
-       else if (PySlice_Check(key)) {
-               PySliceObject *key_slice = (PySliceObject *)key;
-               Py_ssize_t step = 1;
-
-               if (key_slice->step != Py_None && !_PyEval_SliceIndex(key, 
&step)) {
-                       return NULL;
-               }
-               else if (step != 1) {
-                       PyErr_SetString(PyExc_TypeError,
-                                       "BMElemSeq[slice]: slice steps not 
supported");
-                       return NULL;
-               }
-               else if (key_slice->start == Py_None && key_slice->stop == 
Py_None) {
-                       return bpy_bmeditselseq_subscript_slice(self, 0, 
PY_SSIZE_T_MAX);
-               }
-               else {
-                       Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
-
-                       /* avoid PySlice_GetIndicesEx because it needs to know 
the length ahead of time. */
-                       if (key_slice->start != Py_None && 
!_PyEval_SliceIndex(key_slice->start, &start)) return NULL;
-                       if (key_slice->stop != Py_None && 
!_PyEval_SliceIndex(key_slice->stop, &stop))    return NULL;
-
-                       if (start < 0 || stop < 0) {
-                               /* only get the length for negative values */
-                               Py_ssize_t len = bpy_bmeditselseq_length(self);
-                               if (start < 0) start += len;
-                               if (stop < 0) start += len;
-                       }
-
-                       if (stop - start <= 0) {
-                               return PyList_New(0);
-                       }
-                       else {
-                               return bpy_bmeditselseq_subscript_slice(self, 
start, stop);
-                       }
-               }
-       }
-       else {
-               PyErr_SetString(PyExc_AttributeError,
-                               "BMElemSeq[key]: invalid key, key must be an 
int");
-               return NULL;
-       }
-}
-
-static int bpy_bmeditselseq_contains(BPy_BMEditSelSeq *self, PyObject *value)
-{
-       BPy_BMElem *value_bm_ele;
-
-       BPY_BM_CHECK_INT(self);
-
-       value_bm_ele = (BPy_BMElem *)value;
-       if (value_bm_ele->bm == self->bm) {
-               return BM_select_history_check(self->bm, value_bm_ele->ele);
-       }
-
-       return 0;
-}
-
-static PySequenceMethods bpy_bmeditselseq_as_sequence = {
-    (lenfunc)bpy_bmeditselseq_length,            /* sq_length */
-    NULL,                                        /* sq_concat */
-    NULL,                                        /* sq_repeat */
-    (ssizeargfunc)bpy_bmeditselseq_subscript_int,/* sq_item */ /* Only set 
this so PySequence_Check() returns True */
-    NULL,                                        /* sq_slice */
-    (ssizeobjargproc)NULL,                       /* sq_ass_item */
-    NULL,                                        /* *was* sq_ass_slice */
-    (objobjproc)bpy_bmeditselseq_contains,       /* sq_contains */

@@ 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