- use double underscores to hide members in python (removes them from dir() therefor autocomp.)

- collection functions rename eg. bones_active -> bones__active, add_object -> objects__add since these should be accessed from the collections only.
- fix warnings in last commit
This commit is contained in:
Campbell Barton 2009-11-11 17:12:48 +00:00
parent bc6190f3e3
commit f356ea764d
7 changed files with 32 additions and 19 deletions

View File

@ -51,6 +51,7 @@
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_object.h"
#include "BKE_scene.h" /* object_in_scene */
#ifdef HAVE_CONFIG_H
#include <config.h>

View File

@ -668,7 +668,7 @@ static void rna_def_armature(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Bones", "");
{ /* Collection active property */
prop_act= RNA_def_property(srna, "bones_active", PROP_POINTER, PROP_NONE);
prop_act= RNA_def_property(srna, "bones__active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop_act, "Bone");
RNA_def_property_pointer_sdna(prop_act, NULL, "act_bone");
RNA_def_property_flag(prop_act, PROP_EDITABLE);
@ -685,7 +685,7 @@ static void rna_def_armature(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Edit Bones", "");
{ /* Collection active property */
prop_act= RNA_def_property(srna, "edit_bones_active", PROP_POINTER, PROP_NONE);
prop_act= RNA_def_property(srna, "edit_bones__active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop_act, "EditBone");
RNA_def_property_pointer_sdna(prop_act, NULL, "act_edbone");
RNA_def_property_flag(prop_act, PROP_EDITABLE);

View File

@ -611,7 +611,7 @@ static void rna_def_channeldriver(BlenderRNA *brna)
/* Collections */
prop= RNA_def_property(srna, "targets", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "targets", NULL);
RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "add_target", "remove_target");
RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "targets__add", "targets__remove");
RNA_def_property_struct_type(prop, "DriverTarget");
RNA_def_property_ui_text(prop, "Target Variables", "Properties acting as targets for this driver.");

View File

@ -71,7 +71,7 @@ void RNA_api_drivers(StructRNA *srna)
PropertyRNA *parm;
/* add target */
func= RNA_def_function(srna, "add_target", "rna_Driver_add_target");
func= RNA_def_function(srna, "targets__add", "rna_Driver_add_target");
RNA_def_function_ui_description(func, "Add a new target for the driver.");
/* return type */
parm= RNA_def_pointer(func, "target", "DriverTarget", "", "Newly created Driver Target.");
@ -80,7 +80,7 @@ void RNA_api_drivers(StructRNA *srna)
parm= RNA_def_string(func, "name", "", 64, "Name", "Name to use in scripted expressions/functions. (No spaces or dots are allowed. Also, must not start with a symbol or digit)");
/* remove target */
func= RNA_def_function(srna, "remove_target", "rna_Driver_remove_target");
func= RNA_def_function(srna, "targets__remove", "rna_Driver_remove_target");
RNA_def_function_ui_description(func, "Remove an existing target from the driver.");
/* target to remove*/
parm= RNA_def_pointer(func, "target", "DriverTarget", "", "Target to remove from the driver.");

View File

@ -38,6 +38,9 @@
#include "BKE_group.h"
#include "WM_api.h"
#include "WM_types.h"
static PointerRNA rna_Group_objects_get(CollectionPropertyIterator *iter)
{
ListBaseIterator *internal= iter->internal;
@ -48,11 +51,13 @@ static PointerRNA rna_Group_objects_get(CollectionPropertyIterator *iter)
static int rna_Group_objects_add(Group *group, bContext *C, Object *object)
{
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, &object->id);
return add_to_group(group, object, CTX_data_scene(C), NULL);
}
static int rna_Group_objects_remove(Group *group, bContext *C, Object *object)
{
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, &object->id);
return rem_from_group(group, object, CTX_data_scene(C), NULL);
}
@ -63,6 +68,9 @@ void RNA_def_group(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
FunctionRNA *func;
PropertyRNA *parm;
srna= RNA_def_struct(brna, "Group", "ID");
RNA_def_struct_ui_text(srna, "Group", "Group of Object datablocks.");
RNA_def_struct_ui_icon(srna, ICON_GROUP);
@ -79,9 +87,7 @@ void RNA_def_group(BlenderRNA *brna)
/* add object */
FunctionRNA *func;
PropertyRNA *parm;
func= RNA_def_function(srna, "add_object", "rna_Group_objects_add");
func= RNA_def_function(srna, "objects__add", "rna_Group_objects_add");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
RNA_def_function_ui_description(func, "Add this object to a group");
/* return type */
@ -92,7 +98,7 @@ void RNA_def_group(BlenderRNA *brna)
RNA_def_property_flag(parm, PROP_REQUIRED);
/* remove object */
func= RNA_def_function(srna, "remove_object", "rna_Group_objects_remove");
func= RNA_def_function(srna, "objects__remove", "rna_Group_objects_remove");
RNA_def_function_ui_description(func, "Remove this object to a group");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
/* return type */
@ -106,7 +112,7 @@ void RNA_def_group(BlenderRNA *brna)
RNA_def_property_collection_sdna(prop, NULL, "gobject", NULL);
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_ui_text(prop, "Objects", "A collection of this groups objects.");
RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Group_objects_get", 0, 0, 0, "add_object", "remove_object");
RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Group_objects_get", 0, 0, 0, "objects__add", "objects__remove");
}
#endif

View File

@ -2225,7 +2225,7 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Bases", "");
{ /* Collection active property */
prop_act= RNA_def_property(srna, "base_active", PROP_POINTER, PROP_NONE);
prop_act= RNA_def_property(srna, "bases__active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop_act, "ObjectBase");
RNA_def_property_pointer_sdna(prop_act, NULL, "basact");
RNA_def_property_flag(prop_act, PROP_EDITABLE);
@ -2241,7 +2241,7 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Scene_objects_get", 0, 0, 0, 0, 0);
{ /* Collection active property */
prop_act= RNA_def_property(srna, "objects_active", PROP_POINTER, PROP_NONE);
prop_act= RNA_def_property(srna, "objects__active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop_act, "Object");
RNA_def_property_pointer_funcs(prop_act, "rna_Scene_active_object_get", "rna_Scene_active_object_set", NULL);
RNA_def_property_flag(prop_act, PROP_EDITABLE);

View File

@ -1306,10 +1306,11 @@ static PyObject *pyrna_struct_dir(BPy_StructRNA * self)
nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name));
if(nameptr) {
pystring = PyUnicode_FromString(nameptr);
PyList_Append(ret, pystring);
Py_DECREF(pystring);
if(strstr(nameptr, "__")==NULL) { /* __ for hidden props, used for active object for eg. */
pystring = PyUnicode_FromString(nameptr);
PyList_Append(ret, pystring);
Py_DECREF(pystring);
}
if(name != nameptr)
MEM_freeN(nameptr);
}
@ -1323,14 +1324,19 @@ static PyObject *pyrna_struct_dir(BPy_StructRNA * self)
* Collect RNA function items
*/
PointerRNA tptr;
const char *idname;
RNA_pointer_create(NULL, &RNA_Struct, self->ptr.type, &tptr);
iterprop= RNA_struct_find_property(&tptr, "functions");
RNA_PROP_BEGIN(&tptr, itemptr, iterprop) {
pystring = PyUnicode_FromString(RNA_function_identifier(itemptr.data));
PyList_Append(ret, pystring);
Py_DECREF(pystring);
idname= RNA_function_identifier(itemptr.data);
if(strstr(idname, "__")==NULL) { /* __ for hidden function members, used for collection add/remove for eg. */
pystring = PyUnicode_FromString(idname);
PyList_Append(ret, pystring);
Py_DECREF(pystring);
}
}
RNA_PROP_END;
}