Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-06-21 02:50:23 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-06-21 03:18:53 +0300
commit0c538fc923803c8611c3c7c7af9ca51fc5293b75 (patch)
tree4e2ab026d002301904259074b616560056a66dc5 /source/blender/python/intern/bpy_rna.c
parent1e050bd08e408a45435000a1057a3524a78e2ac4 (diff)
Cleanup: spelling, grammar, and other corrections
D5084 by @nBurn with edits
Diffstat (limited to 'source/blender/python/intern/bpy_rna.c')
-rw-r--r--source/blender/python/intern/bpy_rna.c891
1 files changed, 453 insertions, 438 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 8385bff0256..734e929fdf4 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -17,11 +17,11 @@
/** \file
* \ingroup pythonintern
*
- * This file is the main interface between python and blenders data api (RNA),
- * exposing RNA to python so blender data can be accessed in a python like way.
+ * This file is the main interface between Python and Blender's data api (RNA),
+ * exposing RNA to Python so blender data can be accessed in a Python like way.
*
- * The two main types are 'BPy_StructRNA' and 'BPy_PropertyRNA' - the base
- * classes for most of the data python accesses in blender.
+ * The two main types are #BPy_StructRNA and #BPy_PropertyRNA - the base
+ * classes for most of the data Python accesses in blender.
*/
#include <Python.h>
@@ -67,10 +67,10 @@
#include "BKE_report.h"
#include "BKE_idprop.h"
-/* only for types */
+/* Only for types. */
#include "BKE_node.h"
-#include "../generic/idprop_py_api.h" /* for IDprop lookups */
+#include "../generic/idprop_py_api.h" /* For IDprop lookups. */
#include "../generic/py_capi_utils.h"
#include "../generic/python_utildefines.h"
@@ -86,7 +86,7 @@ static PyObject *pyrna_prop_collection_values(BPy_PropertyRNA *self);
#define BPY_DOC_ID_PROP_TYPE_NOTE \
" .. note::\n" \
"\n" \
- " Only :class:`bpy.types.ID`, :class:`bpy.types.Bone` and\n" \
+ " Only the :class:`bpy.types.ID`, :class:`bpy.types.Bone` and\n" \
" :class:`bpy.types.PoseBone` classes support custom properties.\n"
int pyrna_struct_validity_check(BPy_StructRNA *pysrna)
@@ -119,7 +119,7 @@ void pyrna_invalidate(BPy_DummyPointerRNA *self)
#ifdef USE_PYRNA_INVALIDATE_GC
# define FROM_GC(g) ((PyObject *)(((PyGC_Head *)g) + 1))
-/* only for sizeof() */
+/* Only for sizeof(). */
struct gc_generation {
PyGC_Head head;
int threshold;
@@ -131,7 +131,7 @@ static void id_release_gc(struct ID *id)
unsigned int j;
// unsigned int i = 0;
for (j = 0; j < 3; j++) {
- /* hack below to get the 2 other lists from _PyGC_generation0 that are normally not exposed */
+ /* Hack below to get the 2 other lists from _PyGC_generation0 that are normally not exposed. */
PyGC_Head *gen = (PyGC_Head *)(((char *)_PyGC_generation0) + (sizeof(gc_generation) * j));
PyGC_Head *g = gen->gc.gc_next;
while ((g = g->gc.gc_next) != gen) {
@@ -159,7 +159,7 @@ static PyObject *id_free_weakref_cb(PyObject *weakinfo_pair, PyObject *weakref);
static PyMethodDef id_free_weakref_cb_def = {
"id_free_weakref_cb", (PyCFunction)id_free_weakref_cb, METH_O, NULL};
-/* adds a reference to the list, remember to decref */
+/* Adds a reference to the list, remember to decref. */
static GHash *id_weakref_pool_get(ID *id)
{
GHash *weakinfo_hash = NULL;
@@ -168,13 +168,13 @@ static GHash *id_weakref_pool_get(ID *id)
weakinfo_hash = BLI_ghash_lookup(id_weakref_pool, (void *)id);
}
else {
- /* first time, allocate pool */
+ /* First time, allocate pool. */
id_weakref_pool = BLI_ghash_ptr_new("rna_global_pool");
weakinfo_hash = NULL;
}
if (weakinfo_hash == NULL) {
- /* we're using a ghash as a set, could use libHX's HXMAP_SINGULAR but would be an extra dep. */
+ /* We use a ghash as a set, we could use libHX's HXMAP_SINGULAR, but would be an extra dep. */
weakinfo_hash = BLI_ghash_ptr_new("rna_id");
BLI_ghash_insert(id_weakref_pool, id, weakinfo_hash);
}
@@ -182,7 +182,7 @@ static GHash *id_weakref_pool_get(ID *id)
return weakinfo_hash;
}
-/* called from pyrna_struct_CreatePyObject() and pyrna_prop_CreatePyObject() */
+/* Called from pyrna_struct_CreatePyObject() and pyrna_prop_CreatePyObject(). */
static void id_weakref_pool_add(ID *id, BPy_DummyPointerRNA *pyrna)
{
PyObject *weakref;
@@ -191,24 +191,25 @@ static void id_weakref_pool_add(ID *id, BPy_DummyPointerRNA *pyrna)
/* Create a new function instance and insert the list as 'self'
* so we can remove ourself from it. */
- GHash *weakinfo_hash = id_weakref_pool_get(id); /* new or existing */
+ GHash *weakinfo_hash = id_weakref_pool_get(id); /* New or existing. */
weakref_capsule = PyCapsule_New(weakinfo_hash, NULL, NULL);
weakref_cb_py = PyCFunction_New(&id_free_weakref_cb_def, weakref_capsule);
Py_DECREF(weakref_capsule);
- /* add weakref to weakinfo_hash list */
+ /* Add weakref to weakinfo_hash list. */
weakref = PyWeakref_NewRef((PyObject *)pyrna, weakref_cb_py);
- Py_DECREF(weakref_cb_py); /* function owned by the weakref now */
+ Py_DECREF(weakref_cb_py); /* Function owned by the weakref now. */
- /* important to add at the end, since first removal looks at the end */
- BLI_ghash_insert(
- weakinfo_hash, weakref, id); /* using a hash table as a set, all 'id's are the same */
+ /* Important to add at the end of the hash, since first removal looks at the end. */
+
+ /* Using a hash table as a set, all 'id's are the same. */
+ BLI_ghash_insert(weakinfo_hash, weakref, id);
/* weakinfo_hash owns the weakref */
}
-/* workaround to get the last id without a lookup */
+/* Workaround to get the last id without a lookup. */
static ID *_id_tmp_ptr;
static void value_id_set(void *id)
{
@@ -218,13 +219,13 @@ static void value_id_set(void *id)
static void id_release_weakref_list(struct ID *id, GHash *weakinfo_hash);
static PyObject *id_free_weakref_cb(PyObject *weakinfo_capsule, PyObject *weakref)
{
- /* important to search backwards */
+ /* Important to search backwards. */
GHash *weakinfo_hash = PyCapsule_GetPointer(weakinfo_capsule, NULL);
if (BLI_ghash_len(weakinfo_hash) > 1) {
BLI_ghash_remove(weakinfo_hash, weakref, NULL, NULL);
}
- else { /* get the last id and free it */
+ else { /* Get the last id and free it. */
BLI_ghash_remove(weakinfo_hash, weakref, NULL, value_id_set);
id_release_weakref_list(_id_tmp_ptr, weakinfo_hash);
}
@@ -310,7 +311,8 @@ static bool rna_id_write_error(PointerRNA *ptr, PyObject *key)
ID *id = ptr->id.data;
if (id) {
const short idcode = GS(id->name);
- if (!ELEM(idcode, ID_WM, ID_SCR, ID_WS)) { /* may need more added here */
+ /* May need more ID types added here. */
+ if (!ELEM(idcode, ID_WM, ID_SCR, ID_WS)) {
const char *idtype = BKE_idcode_to_name(idcode);
const char *pyname;
if (key && PyUnicode_Check(key)) {
@@ -320,7 +322,7 @@ static bool rna_id_write_error(PointerRNA *ptr, PyObject *key)
pyname = "<UNKNOWN>";
}
- /* make a nice string error */
+ /* Make a nice string error. */
BLI_assert(idtype != NULL);
PyErr_Format(PyExc_AttributeError,
"Writing to ID classes in this context is not allowed: "
@@ -354,7 +356,7 @@ bool pyrna_write_check(void)
}
void pyrna_write_set(bool UNUSED(val))
{
- /* nothing */
+ /* pass */
}
#endif /* USE_PEDANTIC_WRITE */
@@ -365,7 +367,7 @@ static int pyrna_py_to_prop(
static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item);
#ifdef USE_MATHUTILS
-# include "../mathutils/mathutils.h" /* so we can have mathutils callbacks */
+# include "../mathutils/mathutils.h" /* So we can have mathutils callbacks. */
static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self,
PointerRNA *ptr,
@@ -377,10 +379,10 @@ static short pyrna_rotation_euler_order_get(PointerRNA *ptr,
const short order_fallback,
PropertyRNA **r_prop_eul_order);
-/* bpyrna vector/euler/quat callbacks */
-static unsigned char mathutils_rna_array_cb_index = -1; /* index for our callbacks */
+/* bpyrna vector/euler/quat callbacks. */
+static unsigned char mathutils_rna_array_cb_index = -1; /* Index for our callbacks. */
-/* subtype not used much yet */
+/* Subtype not used much yet. */
# define MATHUTILS_CB_SUBTYPE_EUL 0
# define MATHUTILS_CB_SUBTYPE_VEC 1
# define MATHUTILS_CB_SUBTYPE_QUAT 2
@@ -407,7 +409,7 @@ static int mathutils_rna_vector_get(BaseMathObject *bmo, int subtype)
RNA_property_float_get_array(&self->ptr, self->prop, bmo->data);
- /* Euler order exception */
+ /* Euler order exception. */
if (subtype == MATHUTILS_CB_SUBTYPE_EUL) {
EulerObject *eul = (EulerObject *)bmo;
PropertyRNA *prop_eul_order = NULL;
@@ -456,7 +458,7 @@ static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype)
RNA_property_update(BPy_GetContext(), &self->ptr, self->prop);
}
- /* Euler order exception */
+ /* Euler order exception. */
if (subtype == MATHUTILS_CB_SUBTYPE_EUL) {
EulerObject *eul = (EulerObject *)bmo;
PropertyRNA *prop_eul_order = NULL;
@@ -528,7 +530,7 @@ static Mathutils_Callback mathutils_rna_array_cb = {
};
/* bpyrna matrix callbacks */
-static unsigned char mathutils_rna_matrix_cb_index = -1; /* index for our callbacks */
+static unsigned char mathutils_rna_matrix_cb_index = -1; /* Index for our callbacks. */
static int mathutils_rna_matrix_get(BaseMathObject *bmo, int UNUSED(subtype))
{
@@ -568,7 +570,7 @@ static int mathutils_rna_matrix_set(BaseMathObject *bmo, int UNUSED(subtype))
return -1;
}
- /* can ignore clamping here */
+ /* Can ignore clamping here. */
RNA_property_float_set_array(&self->ptr, self->prop, bmo->data);
if (RNA_property_update_check(self->prop)) {
@@ -589,14 +591,14 @@ static short pyrna_rotation_euler_order_get(PointerRNA *ptr,
const short order_fallback,
PropertyRNA **r_prop_eul_order)
{
- /* attempt to get order */
+ /* Attempt to get order. */
if (*r_prop_eul_order == NULL) {
*r_prop_eul_order = RNA_struct_find_property(ptr, "rotation_mode");
}
if (*r_prop_eul_order) {
short order = RNA_property_enum_get(ptr, *r_prop_eul_order);
- /* could be quat or axisangle */
+ /* Could be quat or axisangle. */
if (order >= EULER_ORDER_XYZ && order <= EULER_ORDER_ZYX) {
return order;
}
@@ -607,8 +609,10 @@ static short pyrna_rotation_euler_order_get(PointerRNA *ptr,
#endif /* USE_MATHUTILS */
-/* note that PROP_NONE is included as a vector subtype. this is because its handy to
- * have x/y access to fcurve keyframes and other fixed size float arrays of length 2-4. */
+/**
+ * Note that #PROP_NONE is included as a vector subtype. this is because it is handy to
+ * have x/y access to fcurve keyframes and other fixed size float arrays of length 2-4.
+ */
#define PROP_ALL_VECTOR_SUBTYPES \
PROP_COORDS: \
case PROP_TRANSLATION: \
@@ -656,7 +660,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
if (totdim == 1 || (totdim == 2 && subtype == PROP_MATRIX)) {
if (!is_thick) {
- /* owned by the mathutils PyObject */
+ /* Owned by the mathutils PyObject. */
ret = pyrna_prop_CreatePyObject(ptr, prop);
}
@@ -670,8 +674,8 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
else {
PyObject *vec_cb = Vector_CreatePyObject_cb(
ret, len, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_VEC);
- Py_DECREF(ret); /* the vector owns now */
- ret = vec_cb; /* return the vector instead */
+ Py_DECREF(ret); /* The vector owns 'ret' now. */
+ ret = vec_cb; /* Return the vector instead. */
}
}
break;
@@ -684,8 +688,8 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
else {
PyObject *mat_cb = Matrix_CreatePyObject_cb(
ret, 4, 4, mathutils_rna_matrix_cb_index, 0);
- Py_DECREF(ret); /* the matrix owns now */
- ret = mat_cb; /* return the matrix instead */
+ Py_DECREF(ret); /* The matrix owns 'ret' now. */
+ ret = mat_cb; /* Return the matrix instead. */
}
}
else if (len == 9) {
@@ -696,30 +700,30 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
else {
PyObject *mat_cb = Matrix_CreatePyObject_cb(
ret, 3, 3, mathutils_rna_matrix_cb_index, 0);
- Py_DECREF(ret); /* the matrix owns now */
- ret = mat_cb; /* return the matrix instead */
+ Py_DECREF(ret); /* The matrix owns 'ret' now. */
+ ret = mat_cb; /* Return the matrix instead. */
}
}
break;
case PROP_EULER:
case PROP_QUATERNION:
- if (len == 3) { /* euler */
+ if (len == 3) { /* Euler. */
if (is_thick) {
/* Attempt to get order,
* only needed for thick types since wrapped with update via callbacks. */
PropertyRNA *prop_eul_order = NULL;
short order = pyrna_rotation_euler_order_get(ptr, EULER_ORDER_XYZ, &prop_eul_order);
- ret = Euler_CreatePyObject(NULL, order, NULL); /* TODO, get order from RNA */
+ ret = Euler_CreatePyObject(NULL, order, NULL); /* TODO, get order from RNA. */
RNA_property_float_get_array(ptr, prop, ((EulerObject *)ret)->eul);
}
else {
- /* order will be updated from callback on use */
+ /* Order will be updated from callback on use. */
// TODO, get order from RNA
PyObject *eul_cb = Euler_CreatePyObject_cb(
ret, EULER_ORDER_XYZ, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_EUL);
- Py_DECREF(ret); /* the euler owns now */
- ret = eul_cb; /* return the euler instead */
+ Py_DECREF(ret); /* The euler owns 'ret' now. */
+ ret = eul_cb; /* Return the euler instead. */
}
}
else if (len == 4) {
@@ -730,14 +734,14 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
else {
PyObject *quat_cb = Quaternion_CreatePyObject_cb(
ret, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_QUAT);
- Py_DECREF(ret); /* the quat owns now */
- ret = quat_cb; /* return the quat instead */
+ Py_DECREF(ret); /* The quat owns 'ret' now. */
+ ret = quat_cb; /* Return the quat instead. */
}
}
break;
case PROP_COLOR:
case PROP_COLOR_GAMMA:
- if (len == 3) { /* color */
+ if (len == 3) { /* Color. */
if (is_thick) {
ret = Color_CreatePyObject(NULL, NULL);
RNA_property_float_get_array(ptr, prop, ((ColorObject *)ret)->col);
@@ -745,8 +749,8 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
else {
PyObject *col_cb = Color_CreatePyObject_cb(
ret, mathutils_rna_array_cb_index, MATHUTILS_CB_SUBTYPE_COLOR);
- Py_DECREF(ret); /* the color owns now */
- ret = col_cb; /* return the color instead */
+ Py_DECREF(ret); /* The color owns 'ret' now. */
+ ret = col_cb; /* Return the color instead. */
}
}
break;
@@ -757,13 +761,13 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
if (ret == NULL) {
if (is_thick) {
- /* this is an array we cant reference (since its not thin wrappable)
- * and cannot be coerced into a mathutils type, so return as a list */
+ /* This is an array we can't reference (since it is not thin wrappable)
+ * and cannot be coerced into a mathutils type, so return as a list. */
thick_wrap_slice:
ret = pyrna_prop_array_subscript_slice(NULL, ptr, prop, 0, len, len);
}
else {
- ret = pyrna_prop_CreatePyObject(ptr, prop); /* owned by the mathutils PyObject */
+ ret = pyrna_prop_CreatePyObject(ptr, prop); /* Owned by the mathutils PyObject. */
}
}
#else /* USE_MATHUTILS */
@@ -774,7 +778,9 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
return ret;
}
-/* same as RNA_enum_value_from_id but raises an exception */
+/**
+ * Same as #RNA_enum_value_from_id, but raises an exception.
+ */
int pyrna_enum_value_from_id(const EnumPropertyItem *item,
const char *identifier,
int *r_value,
@@ -817,7 +823,7 @@ static int pyrna_prop_compare(BPy_PropertyRNA *a, BPy_PropertyRNA *b)
static PyObject *pyrna_struct_richcmp(PyObject *a, PyObject *b, int op)
{
PyObject *res;
- int ok = -1; /* zero is true */
+ int ok = -1; /* Zero is true. */
if (BPy_StructRNA_Check(a) && BPy_StructRNA_Check(b)) {
ok = pyrna_struct_compare((BPy_StructRNA *)a, (BPy_StructRNA *)b);
@@ -848,7 +854,7 @@ static PyObject *pyrna_struct_richcmp(PyObject *a, PyObject *b, int op)
static PyObject *pyrna_prop_richcmp(PyObject *a, PyObject *b, int op)
{
PyObject *res;
- int ok = -1; /* zero is true */
+ int ok = -1; /* Zero is true. */
if (BPy_PropertyRNA_Check(a) && BPy_PropertyRNA_Check(b)) {
ok = pyrna_prop_compare((BPy_PropertyRNA *)a, (BPy_PropertyRNA *)b);
@@ -886,7 +892,7 @@ static PyObject *pyrna_struct_str(BPy_StructRNA *self)
return PyUnicode_FromFormat("<bpy_struct, %.200s invalid>", Py_TYPE(self)->tp_name);
}
- /* print name if available */
+ /* Print name if available. */
name = RNA_struct_name_get_alloc(&self->ptr, NULL, 0, NULL);
if (name) {
ret = PyUnicode_FromFormat(
@@ -920,7 +926,7 @@ static PyObject *pyrna_struct_repr(BPy_StructRNA *self)
const char *path;
path = RNA_path_from_ID_to_struct(&self->ptr);
if (path) {
- if (GS(id->name) == ID_NT) { /* nodetree paths are not accurate */
+ if (GS(id->name) == ID_NT) { /* Nodetree paths are not accurate. */
ret = PyUnicode_FromFormat("bpy.data...%s", path);
}
else {
@@ -930,7 +936,8 @@ static PyObject *pyrna_struct_repr(BPy_StructRNA *self)
MEM_freeN((void *)path);
}
- else { /* cant find, print something sane */
+ else {
+ /* Can't find the path, print something useful as a fallback. */
ret = PyUnicode_FromFormat("bpy.data.%s[%R]...%s",
BKE_idcode_to_name_plural(GS(id->name)),
tmp_str,
@@ -957,12 +964,12 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self)
type = RNA_property_type(self->prop);
if (RNA_enum_id_from_value(rna_enum_property_type_items, type, &type_id) == 0) {
- PyErr_SetString(PyExc_RuntimeError,
- "could not use property type, internal error"); /* should never happen */
+ /* Should never happen. */
+ PyErr_SetString(PyExc_RuntimeError, "could not use property type, internal error");
return NULL;
}
else {
- /* this should never fail */
+ /* This should never fail. */
int len = -1;
char *c = type_fmt;
@@ -981,7 +988,7 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self)
}
}
- /* if a pointer, try to print name of pointer target too */
+ /* If a pointer, try to print name of pointer target too. */
if (type == PROP_POINTER) {
ptr = RNA_property_pointer_get(&self->ptr, self->prop);
name = RNA_struct_name_get_alloc(&ptr, NULL, 0, NULL);
@@ -1020,7 +1027,7 @@ static PyObject *pyrna_prop_repr_ex(BPy_PropertyRNA *self, const int index_dim,
PYRNA_PROP_CHECK_OBJ(self);
if (id == NULL) {
- /* fallback */
+ /* Fallback. */
return pyrna_prop_str(self);
}
@@ -1030,7 +1037,7 @@ static PyObject *pyrna_prop_repr_ex(BPy_PropertyRNA *self, const int index_dim,
if (path) {
const char *data_delim = (path[0] == '[') ? "" : ".";
- if (GS(id->name) == ID_NT) { /* nodetree paths are not accurate */
+ if (GS(id->name) == ID_NT) { /* Nodetree paths are not accurate. */
ret = PyUnicode_FromFormat("bpy.data...%s", path);
}
else {
@@ -1043,7 +1050,8 @@ static PyObject *pyrna_prop_repr_ex(BPy_PropertyRNA *self, const int index_dim,
MEM_freeN((void *)path);
}
- else { /* cant find, print something sane */
+ else {
+ /* Can't find the path, print something useful as a fallback. */
ret = PyUnicode_FromFormat("bpy.data.%s[%R]...%s",
BKE_idcode_to_name_plural(GS(id->name)),
tmp_str,
@@ -1078,7 +1086,7 @@ static Py_hash_t pyrna_struct_hash(BPy_StructRNA *self)
return _Py_HashPointer(self->ptr.data);
}
-/* from python's meth_hash v3.1.2 */
+/* From Python's meth_hash v3.1.2. */
static long pyrna_prop_hash(BPy_PropertyRNA *self)
{
long x, y;
@@ -1116,7 +1124,7 @@ static int pyrna_struct_clear(BPy_StructRNA *self)
}
#endif /* !USE_PYRNA_STRUCT_REFERENCE */
-/* use our own dealloc so we can free a property if we use one */
+/* Use our own dealloc so we can free a property if we use one. */
static void pyrna_struct_dealloc(BPy_StructRNA *self)
{
#ifdef PYRNA_FREE_SUPPORT
@@ -1139,7 +1147,7 @@ static void pyrna_struct_dealloc(BPy_StructRNA *self)
}
#endif /* !USE_PYRNA_STRUCT_REFERENCE */
- /* Note, for subclassed PyObjects we cant just call PyObject_DEL() directly or it will crash */
+ /* Note, for subclassed PyObjects calling PyObject_DEL() directly crashes. */
Py_TYPE(self)->tp_free(self);
}
@@ -1150,7 +1158,7 @@ static void pyrna_struct_reference_set(BPy_StructRNA *self, PyObject *reference)
// PyObject_GC_UnTrack(self); /* INITIALIZED TRACKED ? */
pyrna_struct_clear(self);
}
- /* reference is now NULL */
+ /* Reference is now NULL. */
if (reference) {
self->reference = reference;
@@ -1160,7 +1168,7 @@ static void pyrna_struct_reference_set(BPy_StructRNA *self, PyObject *reference)
}
#endif /* !USE_PYRNA_STRUCT_REFERENCE */
-/* use our own dealloc so we can free a property if we use one */
+/* Use our own dealloc so we can free a property if we use one. */
static void pyrna_prop_dealloc(BPy_PropertyRNA *self)
{
#ifdef USE_WEAKREFS
@@ -1168,7 +1176,7 @@ static void pyrna_prop_dealloc(BPy_PropertyRNA *self)
PyObject_ClearWeakRefs((PyObject *)self);
}
#endif
- /* Note, for subclassed PyObjects we cant just call PyObject_DEL() directly or it will crash */
+ /* Note, for subclassed PyObjects calling PyObject_DEL() directly crashes. */
Py_TYPE(self)->tp_free(self);
}
@@ -1179,7 +1187,7 @@ static void pyrna_prop_array_dealloc(BPy_PropertyRNA *self)
PyObject_ClearWeakRefs((PyObject *)self);
}
#endif
- /* Note, for subclassed PyObjects we cant just call PyObject_DEL() directly or it will crash */
+ /* Note, for subclassed PyObjects calling PyObject_DEL() directly crashes. */
Py_TYPE(self)->tp_free(self);
}
@@ -1247,7 +1255,7 @@ BLI_bitmap *pyrna_set_to_enum_bitmap(const EnumPropertyItem *items,
int bitmap_size,
const char *error_prefix)
{
- /* set looping */
+ /* Set looping. */
Py_ssize_t pos = 0;
Py_ssize_t hash = 0;
PyObject *key;
@@ -1303,16 +1311,16 @@ error:
return NULL;
}
-/* 'value' _must_ be a set type, error check before calling */
+/* 'value' _must_ be a set type, error check before calling. */
int pyrna_set_to_enum_bitfield(const EnumPropertyItem *items,
PyObject *value,
int *r_value,
const char *error_prefix)
{
- /* set of enum items, concatenate all values with OR */
+ /* Set of enum items, concatenate all values with OR. */
int ret, flag = 0;
- /* set looping */
+ /* Set looping. */
Py_ssize_t pos = 0;
Py_ssize_t hash = 0;
PyObject *key;
@@ -1439,7 +1447,7 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
if (enum_item != DummyRNA_NULL_items) {
const char *ptr_name = RNA_struct_name_get_alloc(ptr, NULL, 0, NULL);
- /* prefer not fail silently in case of api errors, maybe disable it later */
+ /* Prefer not to fail silently in case of API errors, maybe disable it later. */
CLOG_WARN(BPY_LOG_RNA,
"current value '%d' "
"matches no enum in '%s', '%s', '%s'",
@@ -1448,7 +1456,7 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
ptr_name,
RNA_property_identifier(prop));
-#if 0 /* gives python decoding errors while generating docs :( */
+#if 0 /* Gives Python decoding errors while generating docs :( */
char error_str[256];
BLI_snprintf(error_str,
sizeof(error_str),
@@ -1487,7 +1495,7 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
return pyrna_py_from_array(ptr, prop);
}
- /* see if we can coerce into a python type - PropertyType */
+ /* See if we can coerce into a Python type - 'PropertyType'. */
switch (type) {
case PROP_BOOLEAN:
ret = PyBool_FromLong(RNA_property_boolean_get(ptr, prop));
@@ -1506,7 +1514,7 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
buf = RNA_property_string_get_alloc(ptr, prop, buf_fixed, sizeof(buf_fixed), &buf_len);
#ifdef USE_STRING_COERCE
- /* only file paths get special treatment, they may contain non utf-8 chars */
+ /* Only file paths get special treatment, they may contain non utf-8 chars. */
if (subtype == PROP_BYTESTRING) {
ret = PyBytes_FromStringAndSize(buf, buf_len);
}
@@ -1561,7 +1569,7 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
/**
* This function is used by operators and converting dicts into collections.
- * Its takes keyword args and fills them with property values
+ * It takes keyword args and fills them with property values.
*/
int pyrna_pydict_to_props(PointerRNA *ptr,
PyObject *kw,
@@ -1591,7 +1599,7 @@ int pyrna_pydict_to_props(PointerRNA *ptr,
break;
}
- item = PyDict_GetItemString(kw, arg_name); /* wont set an error */
+ item = PyDict_GetItemString(kw, arg_name); /* Wont set an error. */
if (item == NULL) {
if (all_args) {
@@ -1599,7 +1607,7 @@ int pyrna_pydict_to_props(PointerRNA *ptr,
"%.200s: keyword \"%.200s\" missing",
error_prefix,
arg_name ? arg_name : "<UNKNOWN>");
- error_val = -1; /* pyrna_py_to_prop sets the error */
+ error_val = -1; /* pyrna_py_to_prop sets the error. */
break;
}
}
@@ -1613,7 +1621,7 @@ int pyrna_pydict_to_props(PointerRNA *ptr,
}
RNA_STRUCT_END;
- if (error_val == 0 && totkw > 0) { /* some keywords were given that were not used :/ */
+ if (error_val == 0 && totkw > 0) { /* Some keywords were given that were not used :/. */
PyObject *key, *value;
Py_ssize_t pos = 0;
@@ -1646,33 +1654,33 @@ static PyObject *pyrna_func_to_py(const PointerRNA *ptr, FunctionRNA *func)
static int pyrna_py_to_prop(
PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *value, const char *error_prefix)
{
- /* XXX hard limits should be checked here */
+ /* XXX hard limits should be checked here. */
const int type = RNA_property_type(prop);
if (RNA_property_array_check(prop)) {
- /* done getting the length */
+ /* Done getting the length. */
if (pyrna_py_to_array(ptr, prop, data, value, error_prefix) == -1) {
return -1;
}
}
else {
- /* Normal Property (not an array) */
+ /* Normal Property (not an array). */
- /* see if we can coerce into a python type - PropertyType */
+ /* See if we can coerce into a Python type - 'PropertyType'. */
switch (type) {
case PROP_BOOLEAN: {
int param;
- /* prefer not to have an exception here
+ /* Prefer not to have an exception here
* however so many poll functions return None or a valid Object.
- * its a hassle to convert these into a bool before returning, */
+ * It's a hassle to convert these into a bool before returning. */
if (RNA_parameter_flag(prop) & PARM_OUTPUT) {
param = PyObject_IsTrue(value);
}
else {
param = PyC_Long_AsI32(value);
- if (UNLIKELY(param & ~1)) { /* only accept 0/1 */
- param = -1; /* error out below */
+ if (UNLIKELY(param & ~1)) { /* Only accept 0/1. */
+ param = -1; /* Error out below. */
}
}
@@ -1774,7 +1782,7 @@ static int pyrna_py_to_prop(
}
else if (subtype == PROP_BYTESTRING) {
- /* Byte String */
+ /* Byte String. */
param = PyBytes_AsString(value);
@@ -1810,11 +1818,11 @@ static int pyrna_py_to_prop(
}
}
else {
- /* Unicode String */
+ /* Unicode String. */
#ifdef USE_STRING_COERCE
PyObject *value_coerce = NULL;
if (ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) {
- /* TODO, get size */
+ /* TODO, get size. */
param = PyC_UnicodeAsByte(value, &value_coerce);
}
else {
@@ -1847,8 +1855,8 @@ static int pyrna_py_to_prop(
return -1;
}
else {
- /* same as bytes */
- /* XXX, this is suspect but needed for function calls,
+ /* Same as bytes. */
+ /* XXX, this is suspect, but needed for function calls,
* need to see if theres a better way. */
if (data) {
*((char **)data) = (char *)param;
@@ -1866,15 +1874,15 @@ static int pyrna_py_to_prop(
case PROP_ENUM: {
int val = 0;
- /* type checkins is done by each function */
+ /* Type checking is done by each function. */
if (RNA_property_flag(prop) & PROP_ENUM_FLAG) {
- /* set of enum items, concatenate all values with OR */
+ /* Set of enum items, concatenate all values with OR. */
if (pyrna_prop_to_enum_bitfield(ptr, prop, value, &val, error_prefix) == -1) {
return -1;
}
}
else {
- /* simple enum string */
+ /* Simple enum string. */
if (pyrna_string_to_enum(value, ptr, prop, &val, error_prefix) == -1) {
return -1;
}
@@ -1896,18 +1904,18 @@ static int pyrna_py_to_prop(
int flag = RNA_property_flag(prop);
int flag_parameter = RNA_parameter_flag(prop);
- /* this is really nasty!, so we can fake the operator having direct properties eg:
+ /* This is really nasty! Done so we can fake the operator having direct properties, eg:
* layout.prop(self, "filepath")
- * ... which in fact should be
+ * ... which in fact should be:
* layout.prop(self.properties, "filepath")
*
* we need to do this trick.
* if the prop is not an operator type and the pyobject is an operator,
- * use its properties in place of its self.
+ * use its properties in place of itself.
*
- * This is so bad that its almost a good reason to do away with fake
+ * This is so bad that it is almost a good reason to do away with fake
* 'self.properties -> self'
- * class mixing if this causes problems in the future it should be removed.
+ * class mixing. If this causes problems in the future it should be removed.
*/
if ((ptr_type == &RNA_AnyType) && (BPy_StructRNA_Check(value))) {
const StructRNA *base_type = RNA_struct_base_child_of(
@@ -1932,8 +1940,8 @@ static int pyrna_py_to_prop(
}
}
- /* another exception, allow to pass a collection as an RNA property */
- if (Py_TYPE(value) == &pyrna_prop_collection_Type) { /* ok to ignore idprop collections */
+ /* Another exception, allow to pass a collection as an RNA property. */
+ if (Py_TYPE(value) == &pyrna_prop_collection_Type) { /* Ok to ignore idprop collections. */
PointerRNA c_ptr;
BPy_PropertyRNA *value_prop = (BPy_PropertyRNA *)value;
if (RNA_property_collection_type_get(&value_prop->ptr, value_prop->prop, &c_ptr)) {
@@ -1943,7 +1951,7 @@ static int pyrna_py_to_prop(
else {
PyErr_Format(PyExc_TypeError,
"%.200s %.200s.%.200s collection has no type, "
- "cant be used as a %.200s type",
+ "can't be used as a %.200s type",
error_prefix,
RNA_struct_identifier(ptr->type),
RNA_property_identifier(prop),
@@ -1976,7 +1984,7 @@ static int pyrna_py_to_prop(
else if ((value != Py_None) && ((flag & PROP_ID_SELF_CHECK) &&
ptr->id.data == ((BPy_StructRNA *)value)->ptr.id.data)) {
PyErr_Format(PyExc_TypeError,
- "%.200s %.200s.%.200s ID type does not support assignment to its self",
+ "%.200s %.200s.%.200s ID type does not support assignment to itself",
error_prefix,
RNA_struct_identifier(ptr->type),
RNA_property_identifier(prop));
@@ -2002,8 +2010,8 @@ static int pyrna_py_to_prop(
}
else {
/* For function calls, we sometimes want to pass the 'ptr' directly,
- * watch out that it remains valid!,
- * possibly we could support this later if needed. */
+ * but watch out that it remains valid!
+ * We could possibly support this later if needed. */
BLI_assert(value_new == NULL);
if (value == Py_None) {
*((void **)data) = NULL;
@@ -2027,7 +2035,7 @@ static int pyrna_py_to_prop(
}
}
else {
- /* data == NULL, assign to RNA */
+ /* Data == NULL, assign to RNA. */
if (value == Py_None || RNA_struct_is_a(param->ptr.type, ptr_type)) {
ReportList reports;
BKE_reports_init(&reports, RPT_STORE);
@@ -2046,7 +2054,7 @@ static int pyrna_py_to_prop(
if (raise_error) {
if (pyrna_struct_validity_check(param) == -1) {
- /* error set */
+ /* Error set. */
}
else {
PointerRNA tmp;
@@ -2077,7 +2085,7 @@ static int pyrna_py_to_prop(
lb = (data) ? (ListBase *)data : NULL;
- /* convert a sequence of dict's into a collection */
+ /* Convert a sequence of dict's into a collection. */
if (!PySequence_Check(value)) {
PyErr_Format(
PyExc_TypeError,
@@ -2127,7 +2135,7 @@ static int pyrna_py_to_prop(
}
if (pyrna_pydict_to_props(
- &itemptr, item, true, "Converting a python list to an RNA collection") == -1) {
+ &itemptr, item, true, "Converting a Python list to an RNA collection") == -1) {
PyObject *msg = PyC_ExceptionBuffer();
const char *msg_char = _PyUnicode_AsString(msg);
@@ -2158,7 +2166,7 @@ static int pyrna_py_to_prop(
}
}
- /* Run rna property functions */
+ /* Run RNA property functions. */
if (RNA_property_update_check(prop)) {
RNA_property_update(BPy_GetContext(), ptr, prop);
}
@@ -2181,21 +2189,21 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P
const int totdim = RNA_property_array_dimension(ptr, prop, NULL);
if (totdim > 1) {
- /* char error_str[512]; */
+ // char error_str[512];
if (pyrna_py_to_array_index(
&self->ptr, self->prop, self->arraydim, self->arrayoffset, index, value, "") == -1) {
- /* error is set */
+ /* Error is set. */
ret = -1;
}
}
else {
- /* see if we can coerce into a python type - PropertyType */
+ /* See if we can coerce into a Python type - 'PropertyType'. */
switch (RNA_property_type(prop)) {
case PROP_BOOLEAN: {
int param = PyC_Long_AsBool(value);
if (param == -1) {
- /* error is set */
+ /* Error is set. */
ret = -1;
}
else {
@@ -2234,7 +2242,7 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P
}
}
- /* Run rna property functions */
+ /* Run RNA property functions. */
if (RNA_property_update_check(prop)) {
RNA_property_update(BPy_GetContext(), ptr, prop);
}
@@ -2273,7 +2281,7 @@ static int pyrna_prop_array_bool(BPy_PropertyRNA *self)
static int pyrna_prop_collection_bool(BPy_PropertyRNA *self)
{
- /* no callback defined, just iterate and find the nth item */
+ /* No callback defined, just iterate and find the nth item. */
CollectionPropertyIterator iter;
int test;
@@ -2298,7 +2306,7 @@ static int pyrna_prop_collection_bool(BPy_PropertyRNA *self)
} \
(void)0
-/* internal use only */
+/* Internal use only. */
static PyObject *pyrna_prop_collection_subscript_int(BPy_PropertyRNA *self, Py_ssize_t keynum)
{
PointerRNA newptr;
@@ -2323,7 +2331,7 @@ static PyObject *pyrna_prop_collection_subscript_int(BPy_PropertyRNA *self, Py_s
else {
PyErr_Format(PyExc_RuntimeError,
"bpy_prop_collection[index]: internal error, "
- "valid index %d given in %d sized collection but value not found",
+ "valid index %d given in %d sized collection, but value not found",
keynum_abs,
len);
}
@@ -2332,7 +2340,7 @@ static PyObject *pyrna_prop_collection_subscript_int(BPy_PropertyRNA *self, Py_s
}
}
-/* values type must have been already checked */
+/* Values type must have been already checked. */
static int pyrna_prop_collection_ass_subscript_int(BPy_PropertyRNA *self,
Py_ssize_t keynum,
PyObject *value)
@@ -2399,15 +2407,15 @@ static PyObject *pyrna_prop_collection_subscript_str(BPy_PropertyRNA *self, cons
PyErr_Format(PyExc_KeyError, "bpy_prop_collection[key]: key \"%.200s\" not found", keyname);
return NULL;
}
-/* static PyObject *pyrna_prop_array_subscript_str(BPy_PropertyRNA *self, char *keyname) */
+// static PyObject *pyrna_prop_array_subscript_str(BPy_PropertyRNA *self, char *keyname)
/**
* Special case: `bpy.data.objects["some_id_name", "//some_lib_name.blend"]`
* also for: `bpy.data.objects.get(("some_id_name", "//some_lib_name.blend"), fallback)`
*
* \note
- * error codes since this is not to be called directly from python,
- * this matches pythons `__contains__` values capi.
+ * error codes since this is not to be called directly from Python,
+ * this matches Python's `__contains__` values C-API.
* - -1: exception set
* - 0: not found
* - 1: found
@@ -2420,7 +2428,7 @@ static int pyrna_prop_collection_subscript_str_lib_pair_ptr(BPy_PropertyRNA *sel
{
const char *keyname;
- /* first validate the args, all we know is that they are a tuple */
+ /* First validate the args, all we know is that they are a tuple. */
if (PyTuple_GET_SIZE(key) != 2) {
PyErr_Format(PyExc_KeyError,
"%s: tuple key must be a pair, not size %d",
@@ -2480,7 +2488,7 @@ static int pyrna_prop_collection_subscript_str_lib_pair_ptr(BPy_PropertyRNA *sel
* either way can do direct comparison with id.lib */
RNA_PROP_BEGIN (&self->ptr, itemptr, self->prop) {
- ID *id = itemptr.data; /* always an ID */
+ ID *id = itemptr.data; /* Always an ID. */
if (id->lib == lib && (STREQLEN(keyname, id->name + 2, sizeof(id->name) - 2))) {
found = true;
if (r_ptr) {
@@ -2491,14 +2499,14 @@ static int pyrna_prop_collection_subscript_str_lib_pair_ptr(BPy_PropertyRNA *sel
}
RNA_PROP_END;
- /* we may want to fail silently as with collection.get() */
+ /* We may want to fail silently as with collection.get(). */
if ((found == false) && err_not_found) {
- /* only runs for getitem access so use fixed string */
+ /* Only runs for getitem access so use fixed string. */
PyErr_SetString(PyExc_KeyError, "bpy_prop_collection[key, lib]: not found");
return -1;
}
else {
- return found; /* 1 / 0, no exception */
+ return found; /* 1 / 0, no exception. */
}
}
}
@@ -2534,11 +2542,11 @@ static PyObject *pyrna_prop_collection_subscript_slice(BPy_PropertyRNA *self,
list = PyList_New(0);
- /* skip to start */
+ /* Skip to start. */
RNA_property_collection_begin(&self->ptr, self->prop, &rna_macro_iter);
RNA_property_collection_skip(&rna_macro_iter, start);
- /* add items until stop */
+ /* Add items until stop. */
for (count = start; rna_macro_iter.valid; RNA_property_collection_next(&rna_macro_iter)) {
item = pyrna_struct_CreatePyObject(&rna_macro_iter.ptr);
PyList_APPEND(list, item);
@@ -2554,8 +2562,8 @@ static PyObject *pyrna_prop_collection_subscript_slice(BPy_PropertyRNA *self,
return list;
}
-/* TODO - dimensions
- * note: could also use pyrna_prop_array_to_py_index(self, count) in a loop but its a lot slower
+/** TODO - dimensions
+ * \note Could also use pyrna_prop_array_to_py_index(self, count) in a loop, but it's much slower
* since at the moment it reads (and even allocates) the entire array for each index.
*/
static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self,
@@ -2568,7 +2576,7 @@ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self,
int count, totdim;
PyObject *tuple;
- /* isn't needed, internal use only */
+ /* Isn't needed, internal use only. */
// PYRNA_PROP_CHECK_OBJ((BPy_PropertyRNA *)self);
tuple = PyTuple_New(stop - start);
@@ -2686,7 +2694,7 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject
else {
Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
- /* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
+ /* 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;
}
@@ -2695,7 +2703,7 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject
}
if (start < 0 || stop < 0) {
- /* only get the length for negative values */
+ /* Only get the length for negative values. */
Py_ssize_t len = (Py_ssize_t)RNA_property_collection_length(&self->ptr, self->prop);
if (start < 0) {
start += len;
@@ -2714,7 +2722,7 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject
}
}
else if (PyTuple_Check(key)) {
- /* special case, for ID datablocks we */
+ /* Special case, for ID datablocks we. */
return pyrna_prop_collection_subscript_str_lib_pair(
self, key, "bpy_prop_collection[id, lib]", true);
}
@@ -2741,7 +2749,7 @@ static int pyrna_prop_collection_type_check(BPy_PropertyRNA *self, PyObject *val
return -1;
}
else {
- return 0; /* None is OK */
+ return 0; /* None is OK. */
}
}
else if (BPy_StructRNA_Check(value) == 0) {
@@ -2762,7 +2770,7 @@ static int pyrna_prop_collection_type_check(BPy_PropertyRNA *self, PyObject *val
return -1;
}
else {
- return 0; /* OK, this is the correct type!*/
+ return 0; /* OK, this is the correct type! */
}
}
@@ -2780,13 +2788,13 @@ static int pyrna_prop_collection_ass_subscript(BPy_PropertyRNA *self,
{
PYRNA_PROP_CHECK_INT(self);
- /* validate the assigned value */
+ /* Validate the assigned value. */
if (value == NULL) {
PyErr_SetString(PyExc_TypeError, "del bpy_prop_collection[key]: not supported");
return -1;
}
else if (pyrna_prop_collection_type_check(self, value) == -1) {
- return -1; /* exception is set */
+ return -1; /* Exception is set. */
}
#if 0
@@ -2803,7 +2811,7 @@ static int pyrna_prop_collection_ass_subscript(BPy_PropertyRNA *self,
return pyrna_prop_collection_ass_subscript_int(self, i, value);
}
-#if 0 /* TODO, fake slice assignment */
+#if 0 /* TODO, fake slice assignment. */
else if (PySlice_Check(key)) {
PySliceObject *key_slice = (PySliceObject *)key;
Py_ssize_t step = 1;
@@ -2821,7 +2829,7 @@ static int pyrna_prop_collection_ass_subscript(BPy_PropertyRNA *self,
else {
Py_ssize_t start = 0, stop = PY_SSIZE_T_MAX;
- /* avoid PySlice_GetIndicesEx because it needs to know the length ahead of time. */
+ /* 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;
}
@@ -2830,7 +2838,7 @@ static int pyrna_prop_collection_ass_subscript(BPy_PropertyRNA *self,
}
if (start < 0 || stop < 0) {
- /* only get the length for negative values */
+ /* Only get the length for negative values. */
Py_ssize_t len = (Py_ssize_t)RNA_property_collection_length(&self->ptr, self->prop);
if (start < 0) {
start += len;
@@ -2887,7 +2895,7 @@ static PyObject *pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject
return NULL;
}
else if (key_slice->start == Py_None && key_slice->stop == Py_None) {
- /* note, no significant advantage with optimizing [:] slice as with collections
+ /* Note: no significant advantage with optimizing [:] slice as with collections,
* but include here for consistency with collection slice func */
Py_ssize_t len = (Py_ssize_t)pyrna_prop_array_length(self);
return pyrna_prop_array_subscript_slice(self, &self->ptr, self->prop, 0, len, len);
@@ -3038,7 +3046,7 @@ static int prop_subscript_ass_array_slice__bool_recursive(PyObject **value_items
}
}
-/* could call (pyrna_py_to_prop_array_index(self, i, value) in a loop but it is slow */
+/* Could call `pyrna_py_to_prop_array_index(self, i, value)` in a loop, but it is slow. */
static int prop_subscript_ass_array_slice(PointerRNA *ptr,
PropertyRNA *prop,
int arraydim,
@@ -3094,7 +3102,7 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr,
(values_alloc = PyMem_MALLOC(sizeof(*values) * length_flat)) :
values_stack;
if (start != 0 || stop != length) {
- /* partial assignment? - need to get the array */
+ /* Partial assignment? - need to get the array. */
RNA_property_float_get_array(ptr, prop, values);
}
@@ -3122,7 +3130,7 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr,
(values_alloc = PyMem_MALLOC(sizeof(*values) * length_flat)) :
values_stack;
if (start != 0 || stop != length) {
- /* partial assignment? - need to get the array */
+ /* Partial assignment? - need to get the array. */
RNA_property_int_get_array(ptr, prop, values);
}
@@ -3151,7 +3159,7 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr,
values_stack;
if (start != 0 || stop != length) {
- /* partial assignment? - need to get the array */
+ /* Partial assignment? - need to get the array. */
RNA_property_boolean_get_array(ptr, prop, values);
}
@@ -3210,7 +3218,7 @@ static int pyrna_prop_array_ass_subscript(BPy_PropertyArrayRNA *self,
PyObject *key,
PyObject *value)
{
- /* char *keyname = NULL; */ /* not supported yet */
+ // char *keyname = NULL; /* Not supported yet. */
int ret = -1;
PYRNA_PROP_CHECK_INT((BPy_PropertyRNA *)self);
@@ -3240,14 +3248,14 @@ static int pyrna_prop_array_ass_subscript(BPy_PropertyArrayRNA *self,
ret = -1;
}
else if (slicelength <= 0) {
- ret = 0; /* do nothing */
+ ret = 0; /* Do nothing. */
}
else if (step == 1) {
ret = prop_subscript_ass_array_slice(
&self->ptr, self->prop, self->arraydim, self->arrayoffset, start, stop, len, value);
}
else {
- PyErr_SetString(PyExc_TypeError, "slice steps not supported with rna");
+ PyErr_SetString(PyExc_TypeError, "slice steps not supported with RNA");
ret = -1;
}
}
@@ -3265,7 +3273,7 @@ static int pyrna_prop_array_ass_subscript(BPy_PropertyArrayRNA *self,
return ret;
}
-/* for slice only */
+/* For slice only. */
static PyMappingMethods pyrna_prop_array_as_mapping = {
(lenfunc)pyrna_prop_array_length, /* mp_length */
(binaryfunc)pyrna_prop_array_subscript, /* mp_subscript */
@@ -3278,7 +3286,7 @@ static PyMappingMethods pyrna_prop_collection_as_mapping = {
(objobjargproc)pyrna_prop_collection_ass_subscript, /* mp_ass_subscript */
};
-/* only for fast bool's, large structs, assign nb_bool on init */
+/* Only for fast bool's, large structs, assign nb_bool on init. */
static PyNumberMethods pyrna_prop_array_as_number = {
NULL, /* nb_add */
NULL, /* nb_subtract */
@@ -3311,16 +3319,16 @@ static int pyrna_prop_array_contains(BPy_PropertyRNA *self, PyObject *value)
static int pyrna_prop_collection_contains(BPy_PropertyRNA *self, PyObject *key)
{
- PointerRNA newptr; /* not used, just so RNA_property_collection_lookup_string runs */
+ PointerRNA newptr; /* Not used, just so RNA_property_collection_lookup_string runs. */
if (PyTuple_Check(key)) {
- /* special case, for ID datablocks we */
+ /* Special case, for ID data-blocks. */
return pyrna_prop_collection_subscript_str_lib_pair_ptr(
self, key, "(id, lib) in bpy_prop_collection", false, NULL);
}
else {
- /* key in dict style check */
+ /* Key in dict style check. */
const char *keyname = _PyUnicode_AsString(key);
if (keyname == NULL) {
@@ -3393,7 +3401,7 @@ static PySequenceMethods pyrna_prop_collection_as_sequence = {
};
static PySequenceMethods pyrna_struct_as_sequence = {
- NULL, /* Cant set the len otherwise it can evaluate as false */
+ NULL, /* Can't set the len otherwise it can evaluate as false */
NULL, /* sq_concat */
NULL, /* sq_repeat */
NULL,
@@ -3408,7 +3416,7 @@ static PySequenceMethods pyrna_struct_as_sequence = {
static PyObject *pyrna_struct_subscript(BPy_StructRNA *self, PyObject *key)
{
- /* mostly copied from BPy_IDGroup_Map_GetItem */
+ /* Mostly copied from BPy_IDGroup_Map_GetItem. */
IDProperty *group, *idprop;
const char *name = _PyUnicode_AsString(key);
@@ -3487,7 +3495,7 @@ static PyMappingMethods pyrna_struct_as_mapping = {
PyDoc_STRVAR(pyrna_struct_keys_doc,
".. method:: keys()\n"
"\n"
- " Returns the keys of this objects custom properties (matches pythons\n"
+ " Returns the keys of this objects custom properties (matches Python's\n"
" dictionary function of the same name).\n"
"\n"
" :return: custom property keys.\n"
@@ -3514,7 +3522,7 @@ static PyObject *pyrna_struct_keys(BPy_PropertyRNA *self)
PyDoc_STRVAR(pyrna_struct_items_doc,
".. method:: items()\n"
"\n"
- " Returns the items of this objects custom properties (matches pythons\n"
+ " Returns the items of this objects custom properties (matches Python's\n"
" dictionary function of the same name).\n"
"\n"
" :return: custom property key, value pairs.\n"
@@ -3541,7 +3549,7 @@ static PyObject *pyrna_struct_items(BPy_PropertyRNA *self)
PyDoc_STRVAR(pyrna_struct_values_doc,
".. method:: values()\n"
"\n"
- " Returns the values of this objects custom properties (matches pythons\n"
+ " Returns the values of this objects custom properties (matches Python's\n"
" dictionary function of the same name).\n"
"\n"
" :return: custom property values.\n"
@@ -3750,7 +3758,7 @@ PyDoc_STRVAR(pyrna_struct_path_resolve_doc,
" :arg path: path which this property resolves.\n"
" :type path: string\n"
" :arg coerce: optional argument, when True, the property will be converted\n"
- " into its python representation.\n"
+ " into its Python representation.\n"
" :type coerce: boolean\n");
static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args)
{
@@ -3845,7 +3853,7 @@ static PyObject *pyrna_struct_path_from_id(BPy_StructRNA *self, PyObject *args)
if (path == NULL) {
if (name) {
PyErr_Format(PyExc_ValueError,
- "%.200s.path_from_id(\"%s\") found but does not support path creation",
+ "%.200s.path_from_id(\"%s\") found, but does not support path creation",
RNA_struct_identifier(self->ptr.type),
name);
}
@@ -3895,7 +3903,7 @@ static PyObject *pyrna_prop_path_from_id(BPy_PropertyRNA *self)
PyDoc_STRVAR(pyrna_prop_as_bytes_doc,
".. method:: as_bytes()\n"
"\n"
- " Returns this string property as a byte rather than a python string.\n"
+ " Returns this string property as a byte rather than a Python string.\n"
"\n"
" :return: The string as bytes.\n"
" :rtype: bytes\n");
@@ -3934,7 +3942,7 @@ PyDoc_STRVAR(pyrna_prop_update_doc,
"\n"
" .. note::\n"
" This is called when assigning a property,\n"
- " however in rare cases its useful to call explicitly.\n");
+ " however in rare cases it's useful to call explicitly.\n");
static PyObject *pyrna_prop_update(BPy_PropertyRNA *self)
{
RNA_property_update(BPy_GetContext(), &self->ptr, self->prop);
@@ -4085,7 +4093,7 @@ static void pyrna_dir_members_py(PyObject *list, PyObject *self)
pyrna_dir_members_py__add_keys(list, dict);
}
- /* since this is least common case, handle it last */
+ /* Since this is least common case, handle it last. */
if (BPy_PropertyRNA_Check(self)) {
BPy_PropertyRNA *self_prop = (BPy_PropertyRNA *)self;
if (RNA_property_type(self_prop->prop) == PROP_COLLECTION) {
@@ -4105,7 +4113,7 @@ static void pyrna_dir_members_rna(PyObject *list, PointerRNA *ptr)
{
const char *idname;
- /* for looping over attrs and funcs */
+ /* For looping over attrs and funcs. */
PointerRNA tptr;
PropertyRNA *iterprop;
@@ -4153,9 +4161,8 @@ static PyObject *pyrna_struct_dir(BPy_StructRNA *self)
PYRNA_STRUCT_CHECK_OBJ(self);
- /* Include this in case this instance is a subtype of a python class
- * In these instances we may want to return a function or variable provided by the subtype
- * */
+ /* Include this in case this instance is a subtype of a Python class
+ * In these instances we may want to return a function or variable provided by the subtype. */
ret = PyList_New(0);
if (!BPy_StructRNA_CheckExact(self)) {
@@ -4177,7 +4184,7 @@ static PyObject *pyrna_struct_dir(BPy_StructRNA *self)
{
/* set(), this is needed to remove-doubles because the deferred
- * register-props will be in both the python __dict__ and accessed as RNA */
+ * register-props will be in both the Python __dict__ and accessed as RNA */
PyObject *set = PySet_New(ret);
@@ -4204,9 +4211,9 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
ret = NULL;
}
else if (
- /* rna can't start with a "_", so for __dict__ and similar we can skip using rna lookups */
+ /* RNA can't start with a "_", so for __dict__ and similar we can skip using RNA lookups. */
name[0] == '_') {
- /* annoying exception, maybe we need to have different types for this... */
+ /* Annoying exception, maybe we need to have different types for this... */
if (STR_ELEM(name, "__getitem__", "__setitem__") &&
!RNA_struct_idprops_check(self->ptr.type)) {
PyErr_SetString(PyExc_AttributeError, "bpy_struct: no __getitem__ support for this type");
@@ -4219,7 +4226,7 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
else if ((prop = RNA_struct_find_property(&self->ptr, name))) {
ret = pyrna_prop_to_py(&self->ptr, prop);
}
- /* RNA function only if callback is declared (no optional functions) */
+ /* RNA function only if callback is declared (no optional functions). */
else if ((func = RNA_struct_find_function(self->ptr.type, name)) && RNA_function_defined(func)) {
ret = pyrna_func_to_py(&self->ptr, func);
}
@@ -4238,7 +4245,7 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
int done = CTX_data_get(C, name, &newptr, &newlb, &newtype);
- if (done == 1) { /* found */
+ if (done == 1) { /* Found. */
switch (newtype) {
case CTX_DATA_TYPE_POINTER:
if (newptr.data == NULL) {
@@ -4260,7 +4267,7 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
break;
}
default:
- /* should never happen */
+ /* Should never happen. */
BLI_assert(!"Invalid context type");
PyErr_Format(PyExc_AttributeError,
@@ -4271,12 +4278,12 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
break;
}
}
- else if (done == -1) { /* found but not set */
+ else if (done == -1) { /* Found, but not set. */
ret = Py_None;
Py_INCREF(ret);
}
- else { /* not found in the context */
- /* lookup the subclass. raise an error if its not found */
+ else { /* Not found in the context. */
+ /* Lookup the subclass. raise an error if it's not found. */
ret = PyObject_GenericGetAttr((PyObject *)self, pyname);
}
@@ -4288,11 +4295,11 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
PyErr_Format(PyExc_AttributeError, "bpy_struct: attribute \"%.200s\" not found", name);
ret = NULL;
#endif
- /* Include this in case this instance is a subtype of a python class
+ /* Include this in case this instance is a subtype of a Python class
* In these instances we may want to return a function or variable provided by the subtype
*
- * Also needed to return methods when its not a subtype
- * */
+ * Also needed to return methods when it's not a subtype.
+ */
/* The error raised here will be displayed */
ret = PyObject_GenericGetAttr((PyObject *)self, pyname);
@@ -4342,7 +4349,7 @@ static PyObject *pyrna_struct_meta_idprop_getattro(PyObject *cls, PyObject *attr
PropertyRNA *prop = RNA_struct_type_find_property(srna, _PyUnicode_AsString(attr));
if (prop) {
PointerRNA tptr;
- PyErr_Clear(); /* clear error from tp_getattro */
+ PyErr_Clear(); /* Clear error from tp_getattro. */
RNA_pointer_create(NULL, &RNA_Property, prop, &tptr);
ret = pyrna_struct_CreatePyObject(&tptr);
}
@@ -4371,7 +4378,7 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb
}
if (srna == NULL) {
- /* allow setting on unregistered classes which can be registered later on */
+ /* Allow setting on unregistered classes which can be registered later on. */
#if 0
if (value && is_deferred_prop) {
PyErr_Format(PyExc_AttributeError,
@@ -4380,31 +4387,31 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb
return -1;
}
#endif
- /* srna_from_self may set an error */
+ /* srna_from_self may set an error. */
PyErr_Clear();
return PyType_Type.tp_setattro(cls, attr, value);
}
if (value) {
- /* check if the value is a property */
+ /* Check if the value is a property. */
if (is_deferred_prop) {
int ret = deferred_register_prop(srna, attr, value);
if (ret == -1) {
- /* error set */
+ /* Error set. */
return ret;
}
/* pass through and assign to the classes __dict__ as well
- * when the value isn't assigned it still creates the RNA property
- * but gets confusing from script writers POV if the assigned value cant be read back. */
+ * so when the value isn't assigned it still creates the RNA property,
+ * but gets confusing from script writers POV if the assigned value can't be read back. */
}
else {
- /* remove existing property if its set or we also end up with confusion */
- RNA_def_property_free_identifier(srna, attr_str); /* ignore on failure */
+ /* Remove existing property if it's set or we also end up with confusion. */
+ RNA_def_property_free_identifier(srna, attr_str); /* Ignore on failure. */
}
}
else { /* __delattr__ */
- /* first find if this is a registered property */
+ /* First find if this is a registered property. */
const int ret = RNA_def_property_free_identifier(srna, attr_str);
if (ret == -1) {
PyErr_Format(
@@ -4413,7 +4420,7 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb
}
}
- /* fallback to standard py, delattr/setattr */
+ /* Fallback to standard py, delattr/setattr. */
return PyType_Type.tp_setattro(cls, attr, value);
}
@@ -4444,8 +4451,8 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject
}
}
else if (self->ptr.type == &RNA_Context) {
- /* Code just raises correct error, context prop's cant be set,
- * unless its apart of the py class. */
+ /* Code just raises correct error, context prop's can't be set,
+ * unless it's a part of the py class. */
bContext *C = self->ptr.data;
if (C == NULL) {
PyErr_Format(PyExc_AttributeError,
@@ -4489,9 +4496,8 @@ static PyObject *pyrna_prop_dir(BPy_PropertyRNA *self)
PyObject *ret;
PointerRNA r_ptr;
- /* Include this in case this instance is a subtype of a python class
- * In these instances we may want to return a function or variable provided by the subtype
- * */
+ /* Include this in case this instance is a subtype of a Python class
+ * In these instances we may want to return a function or variable provided by the subtype. */
ret = PyList_New(0);
if (!BPy_PropertyRNA_CheckExact(self)) {
@@ -4553,8 +4559,8 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject
PyObject *ret = PyObject_GenericGetAttr((PyObject *)self, pyname);
- if (ret == NULL && name[0] != '_') { /* avoid inheriting __call__ and similar */
- /* since this is least common case, handle it last */
+ if (ret == NULL && name[0] != '_') { /* Avoid inheriting __call__ and similar. */
+ /* Since this is least common case, handle it last. */
PointerRNA r_ptr;
if (RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) {
PyObject *cls;
@@ -4567,7 +4573,7 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject
ret = PyObject_GenericGetAttr(cls, pyname);
Py_DECREF(cls);
- /* restore the original error */
+ /* Restore the original error. */
if (ret == NULL) {
PyErr_Restore(error_type, error_value, error_traceback);
}
@@ -4602,7 +4608,7 @@ static int pyrna_prop_collection_setattro(BPy_PropertyRNA *self, PyObject *pynam
}
else if (RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr)) {
if ((prop = RNA_struct_find_property(&r_ptr, name))) {
- /* pyrna_py_to_prop sets its own exceptions */
+ /* pyrna_py_to_prop sets its own exceptions. */
return pyrna_py_to_prop(&r_ptr, prop, NULL, value, "BPy_PropertyRNA - Attribute (setattr):");
}
}
@@ -4611,7 +4617,9 @@ static int pyrna_prop_collection_setattro(BPy_PropertyRNA *self, PyObject *pynam
return -1;
}
-/* odd case, we need to be able return a python method from a tp_getset */
+/**
+ * Odd case, we need to be able return a Python method from a #PyTypeObject.tp_getset.
+ */
static PyObject *pyrna_prop_collection_idprop_add(BPy_PropertyRNA *self)
{
PointerRNA r_ptr;
@@ -4699,7 +4707,7 @@ PyDoc_STRVAR(pyrna_struct_get_id_data_doc,
"all data types)");
static PyObject *pyrna_struct_get_id_data(BPy_DummyPointerRNA *self)
{
- /* used for struct and pointer since both have a ptr */
+ /* Used for struct and pointer since both have a ptr. */
if (self->ptr.id.data) {
PointerRNA id_ptr;
RNA_id_pointer_create((ID *)self->ptr.id.data, &id_ptr);
@@ -4767,7 +4775,7 @@ PyDoc_STRVAR(pyrna_prop_collection_keys_doc,
".. method:: keys()\n"
"\n"
" Return the identifiers of collection members\n"
- " (matching pythons dict.keys() functionality).\n"
+ " (matching Python's dict.keys() functionality).\n"
"\n"
" :return: the identifiers for each member of this collection.\n"
" :rtype: list of strings\n");
@@ -4797,7 +4805,7 @@ PyDoc_STRVAR(pyrna_prop_collection_items_doc,
".. method:: items()\n"
"\n"
" Return the identifiers of collection members\n"
- " (matching pythons dict.items() functionality).\n"
+ " (matching Python's dict.items() functionality).\n"
"\n"
" :return: (key, value) pairs for each member of this collection.\n"
" :rtype: list of tuples\n");
@@ -4811,7 +4819,7 @@ static PyObject *pyrna_prop_collection_items(BPy_PropertyRNA *self)
RNA_PROP_BEGIN (&self->ptr, itemptr, self->prop) {
if (itemptr.data) {
- /* add to python list */
+ /* Add to Python list. */
item = PyTuple_New(2);
nameptr = RNA_struct_name_get_alloc(&itemptr, name, sizeof(name), &namelen);
if (nameptr) {
@@ -4821,7 +4829,7 @@ static PyObject *pyrna_prop_collection_items(BPy_PropertyRNA *self)
}
}
else {
- /* a bit strange but better then returning an empty list */
+ /* A bit strange, but better then returning an empty list. */
PyTuple_SET_ITEM(item, 0, PyLong_FromLong(i));
}
PyTuple_SET_ITEM(item, 1, pyrna_struct_CreatePyObject(&itemptr));
@@ -4840,13 +4848,13 @@ PyDoc_STRVAR(pyrna_prop_collection_values_doc,
".. method:: values()\n"
"\n"
" Return the values of collection\n"
- " (matching pythons dict.values() functionality).\n"
+ " (matching Python's dict.values() functionality).\n"
"\n"
" :return: the members of this collection.\n"
" :rtype: list\n");
static PyObject *pyrna_prop_collection_values(BPy_PropertyRNA *self)
{
- /* re-use slice*/
+ /* Re-use slice. */
return pyrna_prop_collection_subscript_slice(self, 0, PY_SSIZE_T_MAX);
}
@@ -4854,7 +4862,7 @@ PyDoc_STRVAR(pyrna_struct_get_doc,
".. method:: get(key, default=None)\n"
"\n"
" Returns the value of the custom property assigned to key or default\n"
- " when not found (matches pythons dictionary function of the same name).\n"
+ " when not found (matches Python's dictionary function of the same name).\n"
"\n"
" :arg key: The key associated with the custom property.\n"
" :type key: string\n"
@@ -4875,7 +4883,7 @@ static PyObject *pyrna_struct_get(BPy_StructRNA *self, PyObject *args)
return NULL;
}
- /* mostly copied from BPy_IDGroup_Map_GetItem */
+ /* Mostly copied from BPy_IDGroup_Map_GetItem. */
if (RNA_struct_idprops_check(self->ptr.type) == 0) {
PyErr_SetString(PyExc_TypeError, "this type doesn't support IDProperties");
return NULL;
@@ -4897,7 +4905,7 @@ PyDoc_STRVAR(pyrna_struct_pop_doc,
".. method:: pop(key, default=None)\n"
"\n"
" Remove and return the value of the custom property assigned to key or default\n"
- " when not found (matches pythons dictionary function of the same name).\n"
+ " when not found (matches Python's dictionary function of the same name).\n"
"\n"
" :arg key: The key associated with the custom property.\n"
" :type key: string\n"
@@ -4918,7 +4926,7 @@ static PyObject *pyrna_struct_pop(BPy_StructRNA *self, PyObject *args)
return NULL;
}
- /* mostly copied from BPy_IDGroup_Map_GetItem */
+ /* Mostly copied from BPy_IDGroup_Map_GetItem. */
if (RNA_struct_idprops_check(self->ptr.type) == 0) {
PyErr_SetString(PyExc_TypeError, "this type doesn't support IDProperties");
return NULL;
@@ -4945,7 +4953,7 @@ static PyObject *pyrna_struct_pop(BPy_StructRNA *self, PyObject *args)
PyDoc_STRVAR(pyrna_struct_as_pointer_doc,
".. method:: as_pointer()\n"
"\n"
- " Returns the memory address which holds a pointer to blenders internal data\n"
+ " Returns the memory address which holds a pointer to Blender's internal data\n"
"\n"
" :return: int (memory address).\n"
" :rtype: int\n"
@@ -4961,7 +4969,7 @@ PyDoc_STRVAR(pyrna_prop_collection_get_doc,
".. method:: get(key, default=None)\n"
"\n"
" Returns the value of the item assigned to key or default when not found\n"
- " (matches pythons dictionary function of the same name).\n"
+ " (matches Python's dictionary function of the same name).\n"
"\n"
" :arg key: The identifier for the collection member.\n"
" :type key: string\n"
@@ -5008,7 +5016,7 @@ PyDoc_STRVAR(pyrna_prop_collection_find_doc,
".. method:: find(key)\n"
"\n"
" Returns the index of a key in a collection or -1 when not found\n"
- " (matches pythons string find function of the same name).\n"
+ " (matches Python's string find function of the same name).\n"
"\n"
" :arg key: The identifier for the collection member.\n"
" :type key: string\n"
@@ -5018,7 +5026,7 @@ static PyObject *pyrna_prop_collection_find(BPy_PropertyRNA *self, PyObject *key
{
Py_ssize_t key_len_ssize_t;
const char *key = _PyUnicode_AsStringAndSize(key_ob, &key_len_ssize_t);
- const int key_len = (int)key_len_ssize_t; /* comare with same type */
+ const int key_len = (int)key_len_ssize_t; /* Comare with same type. */
char name[256], *nameptr;
int namelen;
@@ -5050,7 +5058,7 @@ static PyObject *pyrna_prop_collection_find(BPy_PropertyRNA *self, PyObject *key
static bool foreach_attr_type(BPy_PropertyRNA *self,
const char *attr,
- /* values to assign */
+ /* Values to assign. */
RawPropertyType *raw_type,
int *attr_tot,
bool *attr_signed)
@@ -5061,7 +5069,7 @@ static bool foreach_attr_type(BPy_PropertyRNA *self,
*attr_tot = 0;
*attr_signed = false;
- /* note: this is fail with zero length lists, so don't let this get caled in that case */
+ /* Note: this is fail with zero length lists, so don't let this get caled in that case. */
RNA_PROP_BEGIN (&self->ptr, itemptr, self->prop) {
prop = RNA_struct_find_property(&itemptr, attr);
if (prop) {
@@ -5079,11 +5087,11 @@ static bool foreach_attr_type(BPy_PropertyRNA *self,
return attr_ok;
}
-/* pyrna_prop_collection_foreach_get/set both use this */
+/* pyrna_prop_collection_foreach_get/set both use this. */
static int foreach_parse_args(BPy_PropertyRNA *self,
PyObject *args,
- /* values to assign */
+ /* Values to assign. */
const char **attr,
PyObject **seq,
int *tot,
@@ -5113,7 +5121,8 @@ static int foreach_parse_args(BPy_PropertyRNA *self,
return -1;
}
- *tot = PySequence_Size(*seq); /* TODO - buffer may not be a sequence! array.array() is tho. */
+ /* TODO - buffer may not be a sequence! array.array() is though. */
+ *tot = PySequence_Size(*seq);
if (*tot > 0) {
if (!foreach_attr_type(self, *attr, raw_type, attr_tot, attr_signed)) {
@@ -5126,7 +5135,7 @@ static int foreach_parse_args(BPy_PropertyRNA *self,
}
*size = RNA_raw_type_sizeof(*raw_type);
-#if 0 /* works fine but not strictly needed, \
+#if 0 /* Works fine, but not strictly needed. \
* we could allow RNA_property_collection_raw_* to do the checks */
if ((*attr_tot) < 1) {
*attr_tot = 1;
@@ -5141,7 +5150,7 @@ static int foreach_parse_args(BPy_PropertyRNA *self,
target_tot = array_tot * (*attr_tot);
- /* rna_access.c - rna_raw_access(...) uses this same method */
+ /* rna_access.c - rna_raw_access(...) uses this same method. */
if (target_tot != (*tot)) {
PyErr_Format(PyExc_TypeError,
"foreach_get(attr, sequence) sequence length mismatch given %d, needed %d",
@@ -5152,9 +5161,9 @@ static int foreach_parse_args(BPy_PropertyRNA *self,
#endif
}
- /* Check 'attr_tot' otherwise we don't know if any values were set
- * this isn't ideal because it means running on an empty list may
- * fail silently when its not compatible. */
+ /* Check 'attr_tot' otherwise we don't know if any values were set.
+ * This isn't ideal because it means running on an empty list may
+ * fail silently when it's not compatible. */
if (*size == 0 && *attr_tot != 0) {
PyErr_SetString(PyExc_AttributeError, "attribute does not support foreach method");
return -1;
@@ -5208,7 +5217,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
bool buffer_is_compat;
void *array = NULL;
- /* get/set both take the same args currently */
+ /* Get/set both take the same args currently. */
const char *attr;
PyObject *seq;
int tot, size, attr_tot;
@@ -5224,13 +5233,13 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
Py_RETURN_NONE;
}
- if (set) { /* get the array from python */
+ if (set) { /* Get the array from python. */
buffer_is_compat = false;
if (PyObject_CheckBuffer(seq)) {
Py_buffer buf;
PyObject_GetBuffer(seq, &buf, PyBUF_SIMPLE | PyBUF_FORMAT);
- /* check if the buffer matches */
+ /* Check if the buffer matches. */
buffer_is_compat = foreach_compat_buffer(raw_type, attr_signed, buf.format);
@@ -5242,7 +5251,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
PyBuffer_Release(&buf);
}
- /* could not use the buffer, fallback to sequence */
+ /* Could not use the buffer, fallback to sequence. */
if (!buffer_is_compat) {
array = PyMem_Malloc(size * tot);
@@ -5268,7 +5277,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
((double *)array)[i] = (double)PyFloat_AsDouble(item);
break;
case PROP_RAW_UNSET:
- /* should never happen */
+ /* Should never happen. */
BLI_assert(!"Invalid array type - set");
break;
}
@@ -5286,7 +5295,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
Py_buffer buf;
PyObject_GetBuffer(seq, &buf, PyBUF_SIMPLE | PyBUF_FORMAT);
- /* check if the buffer matches, TODO - signed/unsigned types */
+ /* Check if the buffer matches, TODO - signed/unsigned types. */
buffer_is_compat = foreach_compat_buffer(raw_type, attr_signed, buf.format);
@@ -5298,7 +5307,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
PyBuffer_Release(&buf);
}
- /* could not use the buffer, fallback to sequence */
+ /* Could not use the buffer, fallback to sequence. */
if (!buffer_is_compat) {
array = PyMem_Malloc(size * tot);
@@ -5306,7 +5315,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
NULL, &self->ptr, self->prop, attr, array, raw_type, tot);
if (!ok) {
- /* skip the loop */
+ /* Skip the loop. */
i = tot;
}
@@ -5332,7 +5341,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
item = PyBool_FromLong((long)((bool *)array)[i]);
break;
default: /* PROP_RAW_UNSET */
- /* should never happen */
+ /* Should never happen. */
BLI_assert(!"Invalid array type - get");
item = Py_None;
Py_INCREF(item);
@@ -5350,7 +5359,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
}
if (PyErr_Occurred()) {
- /* Maybe we could make our own error */
+ /* Maybe we could make our own error. */
PyErr_Print();
PyErr_SetString(PyExc_TypeError, "couldn't access the py sequence");
return NULL;
@@ -5386,10 +5395,10 @@ static PyObject *pyrna_prop_collection_foreach_set(BPy_PropertyRNA *self, PyObje
}
/* A bit of a kludge, make a list out of a collection or array,
- * then return the lists iter function, not especially fast but convenient for now */
+ * then return the list's iter function, not especially fast, but convenient for now. */
static PyObject *pyrna_prop_array_iter(BPy_PropertyArrayRNA *self)
{
- /* Try get values from a collection */
+ /* Try get values from a collection. */
PyObject *ret;
PyObject *iter = NULL;
int len;
@@ -5414,7 +5423,7 @@ static PyObject *pyrna_prop_collection_iter(BPy_PropertyRNA *self);
#ifndef USE_PYRNA_ITER
static PyObject *pyrna_prop_collection_iter(BPy_PropertyRNA *self)
{
- /* Try get values from a collection */
+ /* Try get values from a collection. */
PyObject *ret;
PyObject *iter = NULL;
ret = pyrna_prop_collection_values(self);
@@ -5432,7 +5441,7 @@ static PyObject *pyrna_prop_collection_iter(BPy_PropertyRNA *self)
static struct PyMethodDef pyrna_struct_methods[] = {
- /* only for PointerRNA's with ID'props */
+ /* Only for PointerRNA's with ID'props. */
{"keys", (PyCFunction)pyrna_struct_keys, METH_NOARGS, pyrna_struct_keys_doc},
{"values", (PyCFunction)pyrna_struct_values, METH_NOARGS, pyrna_struct_values_doc},
{"items", (PyCFunction)pyrna_struct_items, METH_NOARGS, pyrna_struct_items_doc},
@@ -5581,7 +5590,7 @@ static PyObject *pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject *
}
else if (PyType_IsSubtype(Py_TYPE(base), &pyrna_struct_Type)) {
/* this almost never runs, only when using user defined subclasses of built-in object.
- * this isn't common since its NOT related to registerable subclasses. eg:
+ * this isn't common since it's NOT related to registerable subclasses. eg:
*
* >>> class MyObSubclass(bpy.types.Object):
* ... def test_func(self):
@@ -5597,11 +5606,11 @@ static PyObject *pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject *
if ((ret = (BPy_StructRNA *)type->tp_alloc(type, 0))) {
ret->ptr = base->ptr;
}
- /* pass on exception & NULL if tp_alloc fails */
+ /* Pass on exception & NULL if tp_alloc fails. */
return (PyObject *)ret;
}
- /* error, invalid type given */
+ /* Error, invalid type given. */
PyErr_Format(PyExc_TypeError,
"bpy_struct.__new__(type): type '%.200s' is not a subtype of bpy_struct",
type->tp_name);
@@ -5659,9 +5668,9 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat
len = RNA_property_array_length(ptr, prop);
}
- /* resolve the array from a new pytype */
+ /* Resolve the array from a new pytype. */
- /* kazanbas: TODO make multidim sequences here */
+ /* TODO(Kazanbas) make multi-dimensional sequences here. */
switch (type) {
case PROP_BOOLEAN:
@@ -5709,7 +5718,7 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat
}
}
else {
- /* see if we can coerce into a python type - PropertyType */
+ /* See if we can coerce into a python type - PropertyType. */
switch (type) {
case PROP_BOOLEAN:
ret = PyBool_FromLong(*(bool *)data);
@@ -5766,7 +5775,7 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat
StructRNA *ptype = RNA_property_pointer_type(ptr, prop);
if (flag_parameter & PARM_RNAPTR) {
- /* in this case we get the full ptr */
+ /* In this case we get the full ptr. */
newptr = *(PointerRNA *)data;
}
else {
@@ -5813,9 +5822,11 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat
return ret;
}
-/* Use to replace PyDict_GetItemString() when the overhead of converting a
- * string into a python unicode is higher than a non hash lookup.
- * works on small dict's such as keyword args. */
+/**
+ * Use to replace PyDict_GetItemString() when the overhead of converting a
+ * string into a Python unicode is higher than a non hash lookup.
+ * works on small dict's such as keyword args.
+ */
static PyObject *small_dict_get_item_string(PyObject *dict, const char *key_lookup)
{
PyObject *key = NULL;
@@ -5835,7 +5846,7 @@ static PyObject *small_dict_get_item_string(PyObject *dict, const char *key_look
static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject *kw)
{
- /* Note, both BPy_StructRNA and BPy_PropertyRNA can be used here */
+ /* Note, both BPy_StructRNA and BPy_PropertyRNA can be used here. */
PointerRNA *self_ptr = &self->ptr;
FunctionRNA *self_func = self->func;
@@ -5858,24 +5869,24 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
PyObject *string_free_ls = PyList_New(0);
#endif
- /* Should never happen but it does in rare cases */
+ /* Should never happen, but it does in rare cases. */
BLI_assert(self_ptr != NULL);
if (self_ptr == NULL) {
PyErr_SetString(PyExc_RuntimeError,
- "rna functions internal rna pointer is NULL, this is a bug. aborting");
+ "RNA functions internal RNA pointer is NULL, this is a bug. aborting");
return NULL;
}
if (self_func == NULL) {
PyErr_Format(
PyExc_RuntimeError,
- "%.200s.<unknown>(): rna function internal function is NULL, this is a bug. aborting",
+ "%.200s.<unknown>(): RNA function internal function is NULL, this is a bug. aborting",
RNA_struct_identifier(self_ptr->type));
return NULL;
}
- /* for testing */
+ /* For testing. */
#if 0
{
const char *fn;
@@ -5913,12 +5924,12 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
err = -1;
}
- /* parse function parameters */
+ /* Parse function parameters. */
for (i = 0; iter.valid && err == 0; RNA_parameter_list_next(&iter)) {
parm = iter.parm;
flag_parameter = RNA_parameter_flag(parm);
- /* only useful for single argument returns, we'll need another list loop for multiple */
+ /* Only useful for single argument returns, we'll need another list loop for multiple. */
if (flag_parameter & PARM_OUTPUT) {
ret_len++;
if (pret_single == NULL) {
@@ -5932,7 +5943,7 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
item = NULL;
if (i < pyargs_len) {
- /* New in 2.8x, optional arguments must be keywords. */
+ /* New in 2.8x, optional arguments must be keywords. */
if (UNLIKELY((flag_parameter & PARM_REQUIRED) == 0)) {
PyErr_Format(PyExc_TypeError,
"%.200s.%.200s(): required parameter \"%.200s\" to be a keyword argument!",
@@ -5948,18 +5959,18 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
}
else if (kw != NULL) {
#if 0
- item = PyDict_GetItemString(kw, RNA_property_identifier(parm)); /* borrow ref */
+ item = PyDict_GetItemString(kw, RNA_property_identifier(parm)); /* Borrow reference. */
#else
- item = small_dict_get_item_string(kw, RNA_property_identifier(parm)); /* borrow ref */
+ item = small_dict_get_item_string(kw, RNA_property_identifier(parm)); /* Borrow reference. */
#endif
if (item) {
- kw_tot++; /* make sure invalid keywords are not given */
+ kw_tot++; /* Make sure invalid keywords are not given. */
}
kw_arg = true;
}
- i++; /* current argument */
+ i++; /* Current argument. */
if (item == NULL) {
if (flag_parameter & PARM_REQUIRED) {
@@ -5971,7 +5982,7 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
err = -1;
break;
}
- else { /* PyDict_GetItemString wont raise an error */
+ else { /* PyDict_GetItemString wont raise an error. */
continue;
}
}
@@ -5989,7 +6000,7 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
/* the error generated isn't that useful, so generate it again with a useful prefix
* could also write a function to prepend to error messages */
char error_prefix[512];
- PyErr_Clear(); /* re-raise */
+ PyErr_Clear(); /* Re-raise. */
if (kw_arg == true) {
BLI_snprintf(error_prefix,
@@ -6018,8 +6029,8 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
RNA_parameter_list_end(&iter);
/* Check if we gave args that don't exist in the function
- * printing the error is slow but it should only happen when developing.
- * the if below is quick, checking if it passed less keyword args then we gave.
+ * Printing the error is slow, but it should only happen when developing.
+ * The "if" below is quick check to make sure less keyword args were passed then we gave.
* (Don't overwrite the error if we have one,
* otherwise can skip important messages and confuse with args).
*/
@@ -6038,11 +6049,11 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
arg_name = _PyUnicode_AsString(key);
found = false;
- if (arg_name == NULL) { /* unlikely the argname is not a string but ignore if it is*/
+ if (arg_name == NULL) { /* Unlikely the argname is not a string, but ignore if it is. */
PyErr_Clear();
}
else {
- /* Search for arg_name */
+ /* Search for arg_name. */
RNA_parameter_list_begin(&parms, &iter);
for (; iter.valid; RNA_parameter_list_next(&iter)) {
parm = iter.parm;
@@ -6061,7 +6072,7 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
}
}
- /* list good args */
+ /* List good args. */
first = true;
RNA_parameter_list_begin(&parms, &iter);
@@ -6097,7 +6108,7 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
ret = NULL;
if (err == 0) {
- /* call function */
+ /* Call function. */
ReportList reports;
bContext *C = BPy_GetContext();
@@ -6106,12 +6117,12 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
err = (BPy_reports_to_error(&reports, PyExc_RuntimeError, true));
- /* return value */
+ /* Return value. */
if (err != -1) {
if (ret_len > 0) {
if (ret_len > 1) {
ret = PyTuple_New(ret_len);
- i = 0; /* arg index */
+ i = 0; /* Arg index. */
RNA_parameter_list_begin(&parms, &iter);
@@ -6129,7 +6140,7 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
ret = pyrna_param_to_py(&funcptr, pret_single, retdata_single);
}
- /* possible there is an error in conversion */
+ /* Possible there is an error in conversion. */
if (ret == NULL) {
err = -1;
}
@@ -6150,7 +6161,7 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
# undef DEBUG_STRING_FREE
#endif
- /* cleanup */
+ /* Cleanup. */
RNA_parameter_list_end(&iter);
RNA_parameter_list_free(&parms);
@@ -6183,7 +6194,7 @@ static PyObject *pyrna_func_doc_get(BPy_FunctionRNA *self, void *UNUSED(closure)
return ret;
}
-/* subclasses of pyrna_struct_Type which support idprop definitions use this as a metaclass */
+/* Subclasses of pyrna_struct_Type which support idprop definitions use this as a metaclass. */
/* note: tp_base member is set to &PyType_Type on init */
PyTypeObject pyrna_struct_meta_idprop_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "bpy_struct_meta_idprop", /* tp_name */
@@ -6198,7 +6209,7 @@ PyTypeObject pyrna_struct_meta_idprop_Type = {
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
NULL,
- /* tp_compare */ /* deprecated in python 3.0! */
+ /* tp_compare */ /* deprecated in Python 3.0! */
NULL, /* tp_repr */
/* Method suites for standard classes */
@@ -6279,7 +6290,7 @@ PyTypeObject pyrna_struct_Type = {
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
NULL,
- /* tp_compare */ /* DEPRECATED in python 3.0! */
+ /* tp_compare */ /* DEPRECATED in Python 3.0! */
(reprfunc)pyrna_struct_repr, /* tp_repr */
/* Method suites for standard classes */
@@ -6368,7 +6379,7 @@ PyTypeObject pyrna_prop_Type = {
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
NULL,
- /* tp_compare */ /* DEPRECATED in python 3.0! */
+ /* tp_compare */ /* DEPRECATED in Python 3.0! */
(reprfunc)pyrna_prop_repr, /* tp_repr */
/* Method suites for standard classes */
@@ -6452,7 +6463,7 @@ PyTypeObject pyrna_prop_array_Type = {
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
NULL,
- /* tp_compare */ /* DEPRECATED in python 3.0! */
+ /* tp_compare */ /* DEPRECATED in Python 3.0! */
(reprfunc)pyrna_prop_array_repr, /* tp_repr */
/* Method suites for standard classes */
@@ -6535,7 +6546,7 @@ PyTypeObject pyrna_prop_collection_Type = {
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
NULL,
- /* tp_compare */ /* DEPRECATED in python 3.0! */
+ /* tp_compare */ /* DEPRECATED in Python 3.0! */
NULL,
/* subclassed */ /* tp_repr */
@@ -6621,7 +6632,7 @@ static PyTypeObject pyrna_prop_collection_idprop_Type = {
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
NULL,
- /* tp_compare */ /* DEPRECATED in python 3.0! */
+ /* tp_compare */ /* DEPRECATED in Python 3.0! */
NULL,
/* subclassed */ /* tp_repr */
@@ -6707,7 +6718,7 @@ PyTypeObject pyrna_func_Type = {
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
NULL,
- /* tp_compare */ /* DEPRECATED in python 3.0! */
+ /* tp_compare */ /* DEPRECATED in Python 3.0! */
(reprfunc)pyrna_func_repr, /* tp_repr */
/* Method suites for standard classes */
@@ -6783,7 +6794,7 @@ PyTypeObject pyrna_func_Type = {
#ifdef USE_PYRNA_ITER
/* --- collection iterator: start --- */
-/* wrap rna collection iterator functions */
+/* wrap RNA collection iterator functions */
/*
* RNA_property_collection_begin(...)
* RNA_property_collection_next(...)
@@ -6803,7 +6814,7 @@ static PyTypeObject pyrna_prop_collection_iter_Type = {
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
NULL,
- /* tp_compare */ /* DEPRECATED in python 3.0! */
+ /* tp_compare */ /* DEPRECATED in Python 3.0! */
NULL,
/* subclassed */ /* tp_repr */
@@ -6914,7 +6925,7 @@ static PyObject *pyrna_prop_collection_iter_next(BPy_PropertyCollectionIterRNA *
BPy_StructRNA *pyrna = (BPy_StructRNA *)pyrna_struct_CreatePyObject(&self->iter.ptr);
# ifdef USE_PYRNA_STRUCT_REFERENCE
- if (pyrna) { /* unlikely but may fail */
+ if (pyrna) { /* Unlikely, but may fail. */
if ((PyObject *)pyrna != Py_None) {
/* hold a reference to the iterator since it may have
* allocated memory 'pyrna' needs. eg: introspecting dynamic enum's */
@@ -6962,18 +6973,19 @@ static void pyrna_subtype_set_rna(PyObject *newclass, StructRNA *srna)
RNA_struct_py_type_set(srna, (void *)newclass); /* Store for later use */
- /* Not 100% needed but useful,
- * having an instance within a type looks wrong however this instance IS an rna type */
+ /* Not 100% needed, but useful,
+ * having an instance within a type looks wrong, but this instance _is_ an RNA type. */
- /* python deals with the circular ref */
+ /* Python deals with the circular reference. */
RNA_pointer_create(NULL, &RNA_Struct, srna, &ptr);
item = pyrna_struct_CreatePyObject(&ptr);
- /* note, must set the class not the __dict__ else the internal slots are not updated correctly */
+ /* Note, must set the class not the __dict__ else the internal slots are not updated correctly.
+ */
PyObject_SetAttr(newclass, bpy_intern_str_bl_rna, item);
Py_DECREF(item);
- /* add staticmethods and classmethods */
+ /* Add staticmethods and classmethods. */
{
const PointerRNA func_ptr = {{NULL}, srna, NULL};
const ListBase *lb;
@@ -6983,10 +6995,10 @@ static void pyrna_subtype_set_rna(PyObject *newclass, StructRNA *srna)
for (link = lb->first; link; link = link->next) {
FunctionRNA *func = (FunctionRNA *)link;
const int flag = RNA_function_flag(func);
- if ((flag & FUNC_NO_SELF) && /* is staticmethod or classmethod */
- (flag & FUNC_REGISTER) == false) /* is not for registration */
+ if ((flag & FUNC_NO_SELF) && /* Is staticmethod or classmethod. */
+ (flag & FUNC_REGISTER) == false) /* Is not for registration. */
{
- /* we may want to set the type of this later */
+ /* We may want to set the type of this later. */
PyObject *func_py = pyrna_func_to_py(&func_ptr, func);
PyObject_SetAttrString(newclass, RNA_function_identifier(func), func_py);
Py_DECREF(func_py);
@@ -6994,26 +7006,26 @@ static void pyrna_subtype_set_rna(PyObject *newclass, StructRNA *srna)
}
}
- /* done with rna instance */
+ /* Done with RNA instance. */
}
static PyObject *pyrna_srna_Subtype(StructRNA *srna);
-/* return a borrowed reference */
+/* Return a borrowed reference. */
static PyObject *pyrna_srna_PyBase(StructRNA *srna) //, PyObject *bpy_types_dict)
{
- /* Assume RNA_struct_py_type_get(srna) was already checked */
+ /* Assume RNA_struct_py_type_get(srna) was already checked. */
StructRNA *base;
PyObject *py_base = NULL;
- /* get the base type */
+ /* Get the base type. */
base = RNA_struct_base(srna);
if (base && base != srna) {
- /* printf("debug subtype %s %p\n", RNA_struct_identifier(srna), srna); */
+ // printf("debug subtype %s %p\n", RNA_struct_identifier(srna), srna);
py_base = pyrna_srna_Subtype(base); //, bpy_types_dict);
- Py_DECREF(py_base); /* srna owns, this is only to pass as an arg */
+ Py_DECREF(py_base); /* Srna owns, this is only to pass as an arg. */
}
if (py_base == NULL) {
@@ -7023,8 +7035,8 @@ static PyObject *pyrna_srna_PyBase(StructRNA *srna) //, PyObject *bpy_types_dic
return py_base;
}
-/* check if we have a native python subclass, use it when it exists
- * return a borrowed reference */
+/* Check if we have a native Python subclass, use it when it exists
+ * return a borrowed reference. */
static PyObject *bpy_types_dict = NULL;
static PyObject *pyrna_srna_ExternalType(StructRNA *srna)
@@ -7041,18 +7053,18 @@ static PyObject *pyrna_srna_ExternalType(StructRNA *srna)
CLOG_ERROR(BPY_LOG_RNA, "failed to find 'bpy_types' module");
return NULL;
}
- bpy_types_dict = PyModule_GetDict(bpy_types); /* borrow */
- Py_DECREF(bpy_types); /* fairly safe to assume the dict is kept */
+ bpy_types_dict = PyModule_GetDict(bpy_types); /* Borrow. */
+ Py_DECREF(bpy_types); /* Fairly safe to assume the dict is kept. */
}
newclass = PyDict_GetItemString(bpy_types_dict, idname);
- /* sanity check, could skip this unless in debug mode */
+ /* Sanity check, could skip this unless in debug mode. */
if (newclass) {
PyObject *base_compare = pyrna_srna_PyBase(srna);
/* Can't do this because it gets superclasses values! */
// PyObject *slots = PyObject_GetAttrString(newclass, "__slots__");
- /* Can do this but faster not to. */
+ /* Can do this, but faster not to. */
// PyObject *bases = PyObject_GetAttrString(newclass, "__bases__");
PyObject *tp_bases = ((PyTypeObject *)newclass)->tp_bases;
PyObject *tp_slots = PyDict_GetItem(((PyTypeObject *)newclass)->tp_dict,
@@ -7088,18 +7100,18 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna)
{
PyObject *newclass = NULL;
- /* stupid/simple case */
+ /* Stupid/simple case. */
if (srna == NULL) {
- newclass = NULL; /* Nothing to do */
- } /* the class may have already been declared & allocated */
+ newclass = NULL; /* Nothing to do. */
+ } /* The class may have already been declared & allocated. */
else if ((newclass = RNA_struct_py_type_get(srna))) {
Py_INCREF(newclass);
- } /* check if bpy_types.py module has the class defined in it */
+ } /* Check if bpy_types.py module has the class defined in it. */
else if ((newclass = pyrna_srna_ExternalType(srna))) {
pyrna_subtype_set_rna(newclass, srna);
Py_INCREF(newclass);
} /* create a new class instance with the C api
- * mainly for the purposing of matching the C/rna type hierarchy */
+ * mainly for the purposing of matching the C/RNA type hierarchy */
else {
/* subclass equivalents
* - class myClass(myBase):
@@ -7110,12 +7122,12 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna)
* )
*/
- /* Assume RNA_struct_py_type_get(srna) was already checked */
+ /* Assume RNA_struct_py_type_get(srna) was already checked. */
PyObject *py_base = pyrna_srna_PyBase(srna);
PyObject *metaclass;
const char *idname = RNA_struct_identifier(srna);
- /* remove __doc__ for now */
+ /* Remove __doc__ for now. */
// const char *descr = RNA_struct_ui_description(srna);
// if (!descr) descr = "(no docs)";
// "__doc__", descr
@@ -7128,13 +7140,13 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna)
metaclass = (PyObject *)&PyType_Type;
}
- /* always use O not N when calling, N causes refcount errors */
+ /* Always use O not N when calling, N causes refcount errors. */
#if 0
newclass = PyObject_CallFunction(
metaclass, "s(O) {sss()}", idname, py_base, "__module__", "bpy.types", "__slots__");
#else
{
- /* longhand of the call above */
+ /* Longhand of the call above. */
PyObject *args, *item, *value;
int ok;
@@ -7168,14 +7180,14 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna)
/* PyC_ObSpit("new class ref", newclass); */
if (newclass) {
- /* srna owns one, and the other is owned by the caller */
+ /* srna owns one, and the other is owned by the caller. */
pyrna_subtype_set_rna(newclass, srna);
- /* XXX, adding this back segfaults blender on load. */
+ /* XXX, adding this back segfaults Blender on load. */
// Py_DECREF(newclass); /* let srna own */
}
else {
- /* this should not happen */
+ /* This should not happen. */
CLOG_ERROR(BPY_LOG_RNA, "failed to register '%s'", idname);
PyErr_Print();
PyErr_Clear();
@@ -7185,7 +7197,7 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna)
return newclass;
}
-/* use for subtyping so we know which srna is used for a PointerRNA */
+/* Use for subtyping so we know which srna is used for a PointerRNA. */
static StructRNA *srna_from_ptr(PointerRNA *ptr)
{
if (ptr->type == &RNA_Struct) {
@@ -7196,7 +7208,7 @@ static StructRNA *srna_from_ptr(PointerRNA *ptr)
}
}
-/* always returns a new ref, be sure to decref when done */
+/* Always returns a new ref, be sure to decref when done. */
static PyObject *pyrna_struct_Subtype(PointerRNA *ptr)
{
return pyrna_srna_Subtype(srna_from_ptr(ptr));
@@ -7207,8 +7219,8 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr)
{
BPy_StructRNA *pyrna = NULL;
- /* note: don't rely on this to return None since NULL data with a valid type can often crash */
- if (ptr->data == NULL && ptr->type == NULL) { /* Operator RNA has NULL data */
+ /* Note: don't rely on this to return None since NULL data with a valid type can often crash. */
+ if (ptr->data == NULL && ptr->type == NULL) { /* Operator RNA has NULL data. */
Py_RETURN_NONE;
}
@@ -7227,8 +7239,8 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr)
/* Existing users will need to use 'type_recast' method. */
Py_DECREF(pyrna);
*instance = NULL;
- /* Continue as if no instance was made */
-#if 0 /* no need to assign, will be written to next... */
+ /* Continue as if no instance was made. */
+#if 0 /* No need to assign, will be written to next... */
pyrna = NULL;
#endif
}
@@ -7239,7 +7251,7 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr)
if (tp) {
pyrna = (BPy_StructRNA *)tp->tp_alloc(tp, 0);
- Py_DECREF(tp); /* srna owns, cant hold a ref */
+ Py_DECREF(tp); /* srna owns, can't hold a reference. */
}
else {
CLOG_WARN(BPY_LOG_RNA, "could not make type '%s'", RNA_struct_identifier(ptr->type));
@@ -7330,7 +7342,7 @@ PyObject *pyrna_prop_CreatePyObject(PointerRNA *ptr, PropertyRNA *prop)
return (PyObject *)pyrna;
}
-/* utility func to be used by external modules, *sneaky!* */
+/* Utility func to be used by external modules, sneaky! */
PyObject *pyrna_id_CreatePyObject(ID *id)
{
if (id) {
@@ -7362,12 +7374,12 @@ bool pyrna_id_CheckPyObject(PyObject *obj)
void BPY_rna_init(void)
{
-#ifdef USE_MATHUTILS /* register mathutils callbacks, ok to run more than once. */
+#ifdef USE_MATHUTILS /* Register mathutils callbacks, ok to run more than once. */
mathutils_rna_array_cb_index = Mathutils_RegisterCallback(&mathutils_rna_array_cb);
mathutils_rna_matrix_cb_index = Mathutils_RegisterCallback(&mathutils_rna_matrix_cb);
#endif
- /* for some reason MSVC complains of these */
+ /* For some reason MSVC complains of these. */
#if defined(_MSC_VER)
pyrna_struct_meta_idprop_Type.tp_base = &PyType_Type;
@@ -7411,14 +7423,14 @@ void BPY_rna_init(void)
#endif
}
-/* bpy.data from python */
+/* 'bpy.data' from Python. */
static PointerRNA *rna_module_ptr = NULL;
PyObject *BPY_rna_module(void)
{
BPy_StructRNA *pyrna;
PointerRNA ptr;
- /* for now, return the base RNA type rather than a real module */
+ /* For now, return the base RNA type rather than a real module. */
RNA_main_pointer_create(G_MAIN, &ptr);
pyrna = (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ptr);
@@ -7432,7 +7444,7 @@ void BPY_update_rna_module(void)
#if 0
RNA_main_pointer_create(G_MAIN, rna_module_ptr);
#else
- rna_module_ptr->data = G_MAIN; /* just set data is enough */
+ rna_module_ptr->data = G_MAIN; /* Just set data is enough. */
#endif
}
}
@@ -7444,7 +7456,7 @@ PyObject *BPY_rna_doc(void)
{
PointerRNA ptr;
- /* for now, return the base RNA type rather than a real module */
+ /* For now, return the base RNA type rather than a real module. */
RNA_blender_rna_pointer_create(&ptr);
return pyrna_struct_CreatePyObject(&ptr);
@@ -7479,7 +7491,7 @@ static PyObject *pyrna_basetype_getattro(BPy_BaseTypeRNA *self, PyObject *pyname
_PyUnicode_AsString(pyname));
return NULL;
#endif
- /* The error raised here will be displayed */
+ /* The error raised here will be displayed. */
ret = PyObject_GenericGetAttr((PyObject *)self, pyname);
}
@@ -7495,7 +7507,7 @@ static struct PyMethodDef pyrna_basetype_methods[] = {
{NULL, NULL, 0, NULL},
};
-/* used to call ..._keys() direct, but we need to filter out operator subclasses */
+/* Used to call ..._keys() direct, but we need to filter out operator subclasses. */
#if 0
static PyObject *pyrna_basetype_dir(BPy_BaseTypeRNA *self)
{
@@ -7504,9 +7516,9 @@ static PyObject *pyrna_basetype_dir(BPy_BaseTypeRNA *self)
PyMethodDef *meth;
# endif
- list = pyrna_prop_collection_keys(self); /* like calling structs.keys(), avoids looping here */
+ list = pyrna_prop_collection_keys(self); /* Like calling structs.keys(), avoids looping here. */
-# if 0 /* for now only contains __dir__ */
+# if 0 /* For now only contains __dir__. */
for (meth = pyrna_basetype_methods; meth->ml_name; meth++) {
PyList_APPEND(list, PyUnicode_FromString(meth->ml_name));
}
@@ -7552,11 +7564,11 @@ PyObject *BPY_rna_types(void)
}
}
- /* static members for the base class */
- /* add __name__ since help() expects its */
+ /* Static members for the base class. */
+ /* Add __name__ since help() expects it. */
PyDict_SetItem(pyrna_basetype_Type.tp_dict, bpy_intern_str___name__, bpy_intern_str_bpy_types);
- /* internal base types we have no other accessors for */
+ /* Internal base types we have no other accessors for. */
{
PyTypeObject *pyrna_types[] = {
&pyrna_struct_meta_idprop_Type,
@@ -7575,7 +7587,7 @@ PyObject *BPY_rna_types(void)
self = (BPy_BaseTypeRNA *)PyObject_NEW(BPy_BaseTypeRNA, &pyrna_basetype_Type);
- /* avoid doing this lookup for every getattr */
+ /* Avoid doing this lookup for every getattr. */
RNA_blender_rna_pointer_create(&self->ptr);
self->prop = RNA_struct_find_property(&self->ptr, "structs");
#ifdef USE_WEAKREFS
@@ -7589,7 +7601,7 @@ StructRNA *pyrna_struct_as_srna(PyObject *self, const bool parent, const char *e
BPy_StructRNA *py_srna = NULL;
StructRNA *srna;
- /* ack, PyObject_GetAttrString wont look up this types tp_dict first :/ */
+ /* Unfortunately PyObject_GetAttrString wont look up this types tp_dict first :/ */
if (PyType_Check(self)) {
py_srna = (BPy_StructRNA *)PyDict_GetItem(((PyTypeObject *)self)->tp_dict,
bpy_intern_str_bl_rna);
@@ -7637,8 +7649,8 @@ StructRNA *pyrna_struct_as_srna(PyObject *self, const bool parent, const char *e
return srna;
}
-/* Orphan functions, not sure where they should go */
-/* get the srna for methods attached to types */
+/* Orphan functions, not sure where they should go. */
+/* Get the srna for methods attached to types. */
/*
* Caller needs to raise error.*/
StructRNA *srna_from_self(PyObject *self, const char *error_prefix)
@@ -7694,7 +7706,7 @@ static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item
}
py_srna_cobject = PyCapsule_New(srna, NULL, NULL);
- /* not 100% nice :/, modifies the dict passed, should be ok */
+ /* Not 100% nice :/, modifies the dict passed, should be ok. */
PyDict_SetItem(py_kw, bpy_intern_str_attr, key);
args_fake = PyTuple_New(1);
@@ -7719,14 +7731,14 @@ static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item
if (py_ret) {
Py_DECREF(py_ret);
- Py_DECREF(args_fake); /* free's py_srna_cobject too */
+ Py_DECREF(args_fake); /* Free's py_srna_cobject too. */
}
else {
- /* _must_ print before decreffing args_fake */
+ /* _must_ print before decreffing args_fake. */
PyErr_Print();
PyErr_Clear();
- Py_DECREF(args_fake); /* free's py_srna_cobject too */
+ Py_DECREF(args_fake); /* Free's py_srna_cobject too. */
// PyC_LineSpit();
PyErr_Format(PyExc_ValueError,
@@ -7738,9 +7750,9 @@ static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item
}
}
else {
- /* Since this is a class dict, ignore args that can't be passed */
+ /* Since this is a class dict, ignore args that can't be passed. */
- /* for testing only */
+ /* For testing only. */
#if 0
PyC_ObSpit("Why doesn't this work??", item);
PyErr_Print();
@@ -7780,12 +7792,12 @@ static int pyrna_deferred_register_props(StructRNA *srna, PyObject *class_dict)
if (!has_warning) {
printf(
"Warning: class %.200s "
- "contains a properties which should be an annotation!\n",
+ "contains a property which should be an annotation!\n",
RNA_struct_identifier(srna));
PyC_LineSpit();
has_warning = true;
}
- printf(" make annotation: %.200s.%.200s\n",
+ printf(" assign as a type annotation: %.200s.%.200s\n",
RNA_struct_identifier(srna),
_PyUnicode_AsString(key));
}
@@ -7805,7 +7817,7 @@ static int pyrna_deferred_register_class_recursive(StructRNA *srna, PyTypeObject
const int len = PyTuple_GET_SIZE(py_class->tp_bases);
int i, ret;
- /* first scan base classes for registerable properties */
+ /* First scan base classes for registerable properties. */
for (i = 0; i < len; i++) {
PyTypeObject *py_superclass = (PyTypeObject *)PyTuple_GET_ITEM(py_class->tp_bases, i);
@@ -7813,7 +7825,7 @@ static int pyrna_deferred_register_class_recursive(StructRNA *srna, PyTypeObject
* 'object' is of course not worth looking into and
* existing subclasses of RNA would cause a lot more dictionary
* looping then is needed (SomeOperator would scan Operator.__dict__)
- * which is harmless but not at all useful.
+ * which is harmless, but not at all useful.
*
* So only scan base classes which are not subclasses if blender types.
* This best fits having 'mix-in' classes for operators and render engines.
@@ -7828,9 +7840,9 @@ static int pyrna_deferred_register_class_recursive(StructRNA *srna, PyTypeObject
}
}
- /* not register out own properties */
- return pyrna_deferred_register_props(
- srna, py_class->tp_dict); /* getattr(..., "__dict__") returns a proxy */
+ /* Not register out own properties. */
+ /* getattr(..., "__dict__") returns a proxy. */
+ return pyrna_deferred_register_props(srna, py_class->tp_dict);
}
int pyrna_deferred_register_class(StructRNA *srna, PyTypeObject *py_class)
@@ -7860,7 +7872,7 @@ static int rna_function_arg_count(FunctionRNA *func, int *min_count)
parm = (PropertyRNA *)link;
if (!(RNA_parameter_flag(parm) & PARM_OUTPUT)) {
if (!done_min_count && (RNA_parameter_flag(parm) & PARM_PYFUNC_OPTIONAL)) {
- /* From now on, following parameters are optional in py func */
+ /* From now on, the following parameters are optional in a Python function. */
if (min_count) {
*min_count = count;
}
@@ -7907,7 +7919,7 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr,
}
}
- /* verify callback functions */
+ /* Verify callback functions. */
lb = RNA_struct_type_functions(srna);
i = 0;
for (link = lb->first; link; link = link->next) {
@@ -7915,7 +7927,7 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr,
const int flag = RNA_function_flag(func);
/* TODO(campbell): this is used for classmethod's too,
* even though class methods should have 'FUNC_USE_SELF_TYPE' set, see Operator.poll for eg.
- * Keep this as-is since its working but we should be using
+ * Keep this as-is since it's working, but we should be using
* 'FUNC_USE_SELF_TYPE' for many functions. */
const bool is_staticmethod = (flag & FUNC_NO_SELF) && !(flag & FUNC_USE_SELF_TYPE);
@@ -7941,7 +7953,8 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr,
PyErr_Clear();
}
else {
- /* No need to keep a ref, the class owns it (technically we should keep a ref but...). */
+ /* No need to keep a ref, the class owns it
+ * (technically we should keep a reference, but...). */
Py_DECREF(item);
if (is_staticmethod) {
@@ -7972,11 +7985,11 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr,
func_arg_count = rna_function_arg_count(func, &func_arg_min_count);
- if (func_arg_count >= 0) { /* -1 if we don't care*/
+ if (func_arg_count >= 0) { /* -1 if we don't care. */
arg_count = ((PyCodeObject *)PyFunction_GET_CODE(item))->co_argcount;
/* note, the number of args we check for and the number of args we give to
- * '@staticmethods' are different (quirk of python),
+ * '@staticmethods' are different (quirk of Python),
* this is why rna_function_arg_count() doesn't return the value -1*/
if (is_staticmethod) {
func_arg_count++;
@@ -8012,7 +8025,7 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr,
}
}
- /* verify properties */
+ /* Verify properties. */
lb = RNA_struct_type_properties(srna);
for (link = lb->first; link; link = link->next) {
const char *identifier;
@@ -8029,7 +8042,7 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr,
if (item == NULL) {
PyErr_Clear();
- /* Sneaky workaround to use the class name as the bl_idname */
+ /* Sneaky workaround to use the class name as the bl_idname. */
#define BPY_REPLACEMENT_STRING(rna_attr, py_attr) \
else if (STREQ(identifier, rna_attr)) \
@@ -8046,10 +8059,10 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr,
else { \
PyErr_Clear(); \
} \
- } /* intentionally allow else here */
+ } /* Intentionally allow else here. */
if (false) {
- } /* needed for macro */
+ } /* Needed for macro. */
BPY_REPLACEMENT_STRING("bl_idname", bpy_intern_str___name__)
BPY_REPLACEMENT_STRING("bl_description", bpy_intern_str___doc__)
@@ -8083,7 +8096,7 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun
return bpy_class_validate_recursive(dummyptr, dummyptr->type, py_data, have_function);
}
-/* TODO - multiple return values like with rna functions */
+/* TODO - multiple return values like with RNA functions. */
static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, ParameterList *parms)
{
PyObject *args;
@@ -8106,33 +8119,33 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
const bool is_readonly_init = !(RNA_struct_is_a(ptr->type, &RNA_Operator) ||
RNA_struct_is_a(ptr->type, &RNA_Gizmo));
// const char *func_id = RNA_function_identifier(func); /* UNUSED */
- /* testing, for correctness, not operator and not draw function */
+ /* Testing, for correctness, not operator and not draw function. */
const bool is_readonly = !(RNA_function_flag(func) & FUNC_ALLOW_WRITE);
#endif
py_class = RNA_struct_py_type_get(ptr->type);
- /* rare case. can happen when registering subclasses */
+ /* Rare case. can happen when registering subclasses. */
if (py_class == NULL) {
CLOG_WARN(BPY_LOG_RNA,
- "unable to get Python class for rna struct '%.200s'",
+ "unable to get Python class for RNA struct '%.200s'",
RNA_struct_identifier(ptr->type));
return -1;
}
/* XXX, this is needed because render engine calls without a context
- * this should be supported at some point but at the moment its not! */
+ * this should be supported at some point, but at the moment it's not! */
if (C == NULL) {
C = BPy_GetContext();
}
- /* annoying!, need to check if the screen gets set to NULL which is a
+ /* Annoying! We need to check if the screen gets set to NULL which is a
* hint that the file was actually re-loaded. */
const bool is_valid_wm = (CTX_wm_manager(C) != NULL);
bpy_context_set(C, &gilstate);
if (!(is_staticmethod || is_classmethod)) {
- /* some datatypes (operator, render engine) can store PyObjects for re-use */
+ /* Some datatypes (operator, render engine) can store PyObjects for re-use. */
if (ptr->data) {
void **instance = RNA_struct_instance(ptr);
@@ -8143,19 +8156,19 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
}
}
}
- /* end exception */
+ /* End exception. */
if (py_class_instance == NULL) {
py_srna = pyrna_struct_CreatePyObject(ptr);
}
if (py_class_instance) {
- /* special case, instance is cached */
+ /* Special case, instance is cached. */
}
else if (py_srna == NULL) {
py_class_instance = NULL;
}
- else if (py_srna == Py_None) { /* probably wont ever happen but possible */
+ else if (py_srna == Py_None) { /* Probably wont ever happen, but possible. */
Py_DECREF(py_srna);
py_class_instance = NULL;
}
@@ -8163,21 +8176,22 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
#if 1
/* Skip the code below and call init directly on the allocated 'py_srna'
* otherwise __init__() always needs to take a second self argument, see pyrna_struct_new().
- * Although this is annoying to have to implement a part of pythons typeobject.c:type_call().
+ * Although this is annoying to have to implement a part of Python's
+ * typeobject.c:type_call().
*/
if (py_class->tp_init) {
# ifdef USE_PEDANTIC_WRITE
const int prev_write = rna_disallow_writes;
rna_disallow_writes = is_readonly_init ? false :
- true; /* only operators can write on __init__ */
+ true; /* Only operators can write on __init__. */
# endif
- /* true in most cases even when the class its self doesn't define an __init__ function. */
+ /* True in most cases even when the class itself doesn't define an __init__ function. */
args = PyTuple_New(0);
if (py_class->tp_init(py_srna, args, NULL) < 0) {
Py_DECREF(py_srna);
py_srna = NULL;
- /* err set below */
+ /* Err set below. */
}
Py_DECREF(args);
# ifdef USE_PEDANTIC_WRITE
@@ -8197,8 +8211,8 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
Py_INCREF(py_class_instance);
# endif
/*
- * This would work fine but means __init__ functions wouldn't run.
- * none of blenders default scripts use __init__ but its nice to call it
+ * This would work fine, but means __init__ functions wouldn't run.
+ * None of Blender's default scripts use __init__ but it's nice to call it
* for general correctness. just to note why this is here when it could be safely removed.
*/
args = PyTuple_New(1);
@@ -8211,12 +8225,12 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
#endif
if (py_class_instance == NULL) {
- err = -1; /* so the error is not overridden below */
+ err = -1; /* So the error is not overridden below. */
}
}
}
- /* Initializing the class worked, now run its invoke function */
+ /* Initializing the class worked, now run its invoke function. */
if (err != -1 && (is_staticmethod || is_classmethod || py_class_instance)) {
PyObject *item = PyObject_GetAttrString((PyObject *)py_class, RNA_function_identifier(func));
@@ -8235,7 +8249,7 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
/* First arg is included in 'item'. */
args = PyTuple_New(rna_function_arg_count(func));
#endif
- args = PyTuple_New(arg_count); /* first arg is included in 'item' */
+ args = PyTuple_New(arg_count); /* First arg is included in 'item'. */
if (is_staticmethod) {
i = 0;
@@ -8251,11 +8265,11 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
RNA_parameter_list_begin(parms, &iter);
- /* parse function parameters */
+ /* Parse function parameters. */
for (; iter.valid; RNA_parameter_list_next(&iter)) {
parm = iter.parm;
- /* only useful for single argument returns, we'll need another list loop for multiple */
+ /* Only useful for single argument returns, we'll need another list loop for multiple. */
if (RNA_parameter_flag(parm) & PARM_OUTPUT) {
ret_len++;
if (pret_single == NULL) {
@@ -8301,7 +8315,7 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
}
}
else {
- /* the error may be already set if the class instance couldn't be created */
+ /* The error may be already set if the class instance couldn't be created. */
if (err != -1) {
PyErr_Format(PyExc_RuntimeError,
"could not create instance of %.200s to call callback function %.200s",
@@ -8311,7 +8325,7 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
}
}
- if (ret == NULL) { /* covers py_class_instance failing too */
+ if (ret == NULL) { /* Covers py_class_instance failing too. */
err = -1;
}
else {
@@ -8362,11 +8376,11 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
RNA_parameter_list_begin(parms, &iter);
- /* parse function parameters */
+ /* Parse function parameters. */
for (i = 0; iter.valid; RNA_parameter_list_next(&iter)) {
parm = iter.parm;
- /* only useful for single argument returns, we'll need another list loop for multiple */
+ /* Only useful for single argument returns, we'll need another list loop for multiple. */
if (RNA_parameter_flag(parm) & PARM_OUTPUT) {
err = pyrna_py_to_prop(
&funcptr, parm, iter.data, PyTuple_GET_ITEM(ret, i++), "calling class function:");
@@ -8384,7 +8398,7 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
if (err != 0) {
ReportList *reports;
- /* alert the user, else they wont know unless they see the console. */
+ /* Alert the user, else they wont know unless they see the console. */
if ((!is_staticmethod) && (!is_classmethod) && (ptr->data) &&
(RNA_struct_is_a(ptr->type, &RNA_Operator)) &&
(is_valid_wm == (CTX_wm_manager(C) != NULL))) {
@@ -8392,13 +8406,13 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
reports = op->reports;
}
else {
- /* wont alert users but they can view in 'info' space */
+ /* Wont alert users, but they can view in 'info' space. */
reports = CTX_wm_reports(C);
}
BPy_errors_to_report(reports);
- /* also print in the console for py */
+ /* Also print in the console for Python. */
PyErr_Print();
PyErr_Clear();
}
@@ -8415,19 +8429,19 @@ static void bpy_class_free(void *pyob_ptr)
gilstate = PyGILState_Ensure();
- /* breaks re-registering classes */
+ /* Breaks re-registering classes. */
// PyDict_Clear(((PyTypeObject *)self)->tp_dict);
- /* remove the rna attribute instead. */
+ /* Remove the RNA attribute instead. */
PyDict_DelItem(((PyTypeObject *)self)->tp_dict, bpy_intern_str_bl_rna);
if (PyErr_Occurred()) {
PyErr_Clear();
}
-#if 0 /* needs further investigation, too annoying so quiet for now */
+#if 0 /* Needs further investigation, too annoying so quiet for now. */
if (G.debug & G_DEBUG_PYTHON) {
if (self->ob_refcnt > 1) {
- PyC_ObSpit("zombie class - ref should be 1", self);
+ PyC_ObSpit("zombie class - reference should be 1", self);
}
}
#endif
@@ -8451,7 +8465,7 @@ void pyrna_alloc_types(void)
gilstate = PyGILState_Ensure();
- /* avoid doing this lookup for every getattr */
+ /* Avoid doing this lookup for every getattr. */
RNA_blender_rna_pointer_create(&ptr);
prop = RNA_struct_find_property(&ptr, "structs");
@@ -8478,7 +8492,7 @@ void pyrna_free_types(void)
PointerRNA ptr;
PropertyRNA *prop;
- /* avoid doing this lookup for every getattr */
+ /* Avoid doing this lookup for every getattr. */
RNA_blender_rna_pointer_create(&ptr);
prop = RNA_struct_find_property(&ptr, "structs");
@@ -8487,7 +8501,7 @@ void pyrna_free_types(void)
void *py_ptr = RNA_struct_py_type_get(srna);
if (py_ptr) {
-#if 0 /* XXX - should be able to do this but makes python crash on exit */
+#if 0 /* XXX - should be able to do this, but makes Python crash on exit. */
bpy_class_free(py_ptr);
#endif
RNA_struct_py_type_set(srna, NULL);
@@ -8498,9 +8512,9 @@ void pyrna_free_types(void)
/* Note! MemLeak XXX
*
- * There is currently a bug where moving registering a python class does
- * not properly manage refcounts from the python class, since the srna owns
- * the python class this should not be so tricky but changing the references as
+ * There is currently a bug where moving the registration of a Python class does
+ * not properly manage reference-counts from the Python class. As the srna owns
+ * the Python class this should not be so tricky, but changing the references as
* you'd expect when changing ownership crashes blender on exit so I had to comment out
* the decref. This is not so bad because the leak only happens when re-registering (hold F8)
* - Should still be fixed - Campbell
@@ -8557,13 +8571,13 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class
return NULL;
}
- /* warning: gets parent classes srna, only for the register function */
+ /* Warning: gets parent classes srna, only for the register function. */
srna = pyrna_struct_as_srna(py_class, true, "register_class(...):");
if (srna == NULL) {
return NULL;
}
- /* fails in cases, cant use this check but would like to :| */
+ /* Fails in some cases, so can't use this check, but would like to :| */
#if 0
if (RNA_struct_py_type_get(srna)) {
PyErr_Format(PyExc_ValueError,
@@ -8575,21 +8589,21 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class
}
#endif
- /* check that we have a register callback for this type */
+ /* Check that we have a register callback for this type. */
reg = RNA_struct_register(srna);
if (!reg) {
PyErr_Format(PyExc_ValueError,
"register_class(...): expected a subclass of a registerable "
- "rna type (%.200s does not support registration)",
+ "RNA type (%.200s does not support registration)",
RNA_struct_identifier(srna));
return NULL;
}
- /* get the context, so register callback can do necessary refreshes */
+ /* Get the context, so register callback can do necessary refreshes. */
C = BPy_GetContext();
- /* call the register callback with reports & identifier */
+ /* Call the register callback with reports & identifier. */
BKE_reports_init(&reports, RPT_STORE);
identifier = ((PyTypeObject *)py_class)->tp_name;
@@ -8613,18 +8627,19 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class
}
}
- /* python errors validating are not converted into reports so the check above will fail.
+ /* Python errors validating are not converted into reports so the check above will fail.
* the cause for returning NULL will be printed as an error */
if (srna_new == NULL) {
return NULL;
}
- pyrna_subtype_set_rna(py_class, srna_new); /* takes a ref to py_class */
+ /* Takes a reference to 'py_class'. */
+ pyrna_subtype_set_rna(py_class, srna_new);
- /* old srna still references us, keep the check in case registering somehow can free it */
+ /* Old srna still references us, keep the check in case registering somehow can free it. */
if (RNA_struct_py_type_get(srna)) {
RNA_struct_py_type_set(srna, NULL);
- // Py_DECREF(py_class); // should be able to do this XXX since the old rna adds a new ref.
+ // Py_DECREF(py_class); /* Should be able to do this XXX since the old RNA adds a new ref. */
}
/* Can't use this because it returns a dict proxy
@@ -8635,7 +8650,7 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class
return NULL;
}
- /* call classed register method () */
+ /* Call classed register method. */
switch (_PyObject_LookupAttr(py_class, bpy_intern_str_register, &py_cls_meth)) {
case 1: {
PyObject *ret = PyObject_CallObject(py_cls_meth, NULL);
@@ -8662,7 +8677,7 @@ static int pyrna_srna_contains_pointer_prop_srna(StructRNA *srna_props,
PropertyRNA *prop;
LinkData *link;
- /* verify properties */
+ /* Verify properties. */
const ListBase *lb = RNA_struct_type_properties(srna);
for (link = lb->first; link; link = link->next) {
@@ -8684,7 +8699,7 @@ static int pyrna_srna_contains_pointer_prop_srna(StructRNA *srna_props,
PyDoc_STRVAR(pyrna_unregister_class_doc,
".. method:: unregister_class(cls)\n"
"\n"
- " Unload the python class from blender.\n"
+ " Unload the Python class from blender.\n"
"\n"
" If the class has an *unregister* class method it will be called\n"
" before unregistering.\n");
@@ -8730,18 +8745,18 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla
return NULL;
}
- /* check that we have a unregister callback for this type */
+ /* Check that we have a unregister callback for this type. */
unreg = RNA_struct_unregister(srna);
if (!unreg) {
PyErr_SetString(
PyExc_ValueError,
"unregister_class(...): "
- "expected a Type subclassed from a registerable rna type (no unregister supported)");
+ "expected a Type subclassed from a registerable RNA type (no unregister supported)");
return NULL;
}
- /* call classed unregister method */
+ /* Call classed unregister method. */
switch (_PyObject_LookupAttr(py_class, bpy_intern_str_unregister, &py_cls_meth)) {
case 1: {
PyObject *ret = PyObject_CallObject(py_cls_meth, NULL);
@@ -8758,9 +8773,9 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla
}
}
- /* should happen all the time but very slow */
+ /* Should happen all the time, however it's very slow. */
if (G.debug & G_DEBUG_PYTHON) {
- /* remove all properties using this class */
+ /* Remove all properties using this class. */
StructRNA *srna_iter;
PointerRNA ptr_rna;
PropertyRNA *prop_rna;
@@ -8769,7 +8784,7 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla
RNA_blender_rna_pointer_create(&ptr_rna);
prop_rna = RNA_struct_find_property(&ptr_rna, "structs");
- /* loop over all structs */
+ /* Loop over all structs. */
RNA_PROP_BEGIN (&ptr_rna, itemptr, prop_rna) {
srna_iter = itemptr.data;
if (pyrna_srna_contains_pointer_prop_srna(srna_iter, srna, &prop_identifier)) {
@@ -8789,11 +8804,11 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla
}
}
- /* get the context, so register callback can do necessary refreshes */
+ /* Get the context, so register callback can do necessary refreshes. */
C = BPy_GetContext();
- /* call unregister */
- unreg(CTX_data_main(C), srna); /* calls bpy_class_free, this decref's py_class */
+ /* Call unregister. */
+ unreg(CTX_data_main(C), srna); /* Calls bpy_class_free, this decref's py_class. */
PyDict_DelItem(((PyTypeObject *)py_class)->tp_dict, bpy_intern_str_bl_rna);
if (PyErr_Occurred()) {
@@ -8931,7 +8946,7 @@ void BPY_rna_register_cb(void)
PyObject_SetAttrString(cls, pyrna_cb_methods[i].py_method.ml_name, classmethod);
Py_DECREF(classmethod);
- Py_DECREF(args); /* clears 'func' too */
+ Py_DECREF(args); /* Clears 'func' too. */
Py_DECREF(cls);
}
}