[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47496] trunk/blender/source/blender/ makesrna/intern/rna_sequencer_api.c: support negative indexing with SequenceElements.pop() - like python does, -1 is default.
Campbell Barton
ideasman42 at gmail.com
Wed Jun 6 08:02:03 CEST 2012
Revision: 47496
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47496
Author: campbellbarton
Date: 2012-06-06 06:01:51 +0000 (Wed, 06 Jun 2012)
Log Message:
-----------
support negative indexing with SequenceElements.pop() - like python does, -1 is default.
Modified Paths:
--------------
trunk/blender/source/blender/makesrna/intern/rna_sequencer_api.c
Modified: trunk/blender/source/blender/makesrna/intern/rna_sequencer_api.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_sequencer_api.c 2012-06-06 05:37:38 UTC (rev 47495)
+++ trunk/blender/source/blender/makesrna/intern/rna_sequencer_api.c 2012-06-06 06:01:51 UTC (rev 47496)
@@ -327,7 +327,12 @@
return;
}
- if (seq->len <= index) {
+ /* python style negative indexing */
+ if (index < 0) {
+ index += seq->len;
+ }
+
+ if (seq->len <= index || index < 0) {
BKE_report(reports, RPT_ERROR, "SequenceElements.pop: index out of range");
return;
}
@@ -335,6 +340,7 @@
new_seq = MEM_callocN(sizeof(StripElem) * (seq->len - 1), "SequenceElements_pop");
seq->len--;
+ /* TODO - simply use 2 memcpy calls */
for (i = 0, se = seq->strip->stripdata; i < seq->len; i++, se++) {
if (i == index)
se++;
@@ -394,7 +400,7 @@
func = RNA_def_function(srna, "pop", "rna_SequenceElements_pop");
RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
RNA_def_function_ui_description(func, "Pop an image off the collection");
- parm = RNA_def_int(func, "index", 0, 0, INT_MAX, "", "Index of image to remove", 0, INT_MAX);
+ parm = RNA_def_int(func, "index", -1, INT_MIN, INT_MAX, "", "Index of image to remove", INT_MIN, INT_MAX);
RNA_def_property_flag(parm, PROP_REQUIRED);
}
More information about the Bf-blender-cvs
mailing list