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>2015-02-17 05:09:21 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-02-17 05:13:59 +0300
commit4bb331dfd5f3d9a42140e8f12bb917c525eeb529 (patch)
tree90107388131cad0c65ef19887406dacb93c11a83 /source/blender/editors
parent691cb61835dcf8964cb1e6110a4d369665fa1f21 (diff)
RNA API: reuse property lookups
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/object/object_add.c18
-rw-r--r--source/blender/editors/render/render_shading.c10
-rw-r--r--source/blender/editors/space_buttons/buttons_ops.c7
-rw-r--r--source/blender/editors/space_file/file_ops.c55
-rw-r--r--source/blender/editors/space_file/filesel.c19
-rw-r--r--source/blender/editors/transform/transform.c4
6 files changed, 65 insertions, 48 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 1180c082783..e73b72430ca 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -297,18 +297,19 @@ bool ED_object_add_generic_get_opts(bContext *C, wmOperator *op, const char view
{
View3D *v3d = CTX_wm_view3d(C);
unsigned int _layer;
+ PropertyRNA *prop;
- /* Switch to Edit mode? */
- if (RNA_struct_find_property(op->ptr, "enter_editmode")) { /* optional */
+ /* Switch to Edit mode? optional prop */
+ if ((prop = RNA_struct_find_property(op->ptr, "enter_editmode"))) {
bool _enter_editmode;
if (!enter_editmode)
enter_editmode = &_enter_editmode;
- if (RNA_struct_property_is_set(op->ptr, "enter_editmode") && enter_editmode)
- *enter_editmode = RNA_boolean_get(op->ptr, "enter_editmode");
+ if (RNA_property_is_set(op->ptr, prop) && enter_editmode)
+ *enter_editmode = RNA_property_boolean_get(op->ptr, prop);
else {
*enter_editmode = (U.flag & USER_ADD_EDITMODE) != 0;
- RNA_boolean_set(op->ptr, "enter_editmode", *enter_editmode);
+ RNA_property_boolean_set(op->ptr, prop, *enter_editmode);
}
}
@@ -318,8 +319,9 @@ bool ED_object_add_generic_get_opts(bContext *C, wmOperator *op, const char view
if (!layer)
layer = &_layer;
- if (RNA_struct_property_is_set(op->ptr, "layers")) {
- RNA_boolean_get_array(op->ptr, "layers", layer_values);
+ prop = RNA_struct_find_property(op->ptr, "layers");
+ if (RNA_property_is_set(op->ptr, prop)) {
+ RNA_property_boolean_get_array(op->ptr, prop, layer_values);
*layer = 0;
for (a = 0; a < 20; a++) {
if (layer_values[a])
@@ -332,7 +334,7 @@ bool ED_object_add_generic_get_opts(bContext *C, wmOperator *op, const char view
for (a = 0; a < 20; a++) {
layer_values[a] = *layer & (1 << a);
}
- RNA_boolean_set_array(op->ptr, "layers", layer_values);
+ RNA_property_boolean_set_array(op->ptr, prop, layer_values);
}
/* in local view we additionally add local view layers,
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index 94a3defa95a..ff90f48d705 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -1386,11 +1386,15 @@ void TEXTURE_OT_slot_move(wmOperatorType *ot)
static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *path, const char imtype)
{
+ PropertyRNA *prop;
float layout[12];
- if (RNA_struct_find_property(op->ptr, "layout") )
- RNA_float_get_array(op->ptr, "layout", layout);
- else
+
+ if ((prop = RNA_struct_find_property(op->ptr, "layout"))) {
+ RNA_property_float_get_array(op->ptr, prop, layout);
+ }
+ else {
memcpy(layout, default_envmap_layout, sizeof(layout));
+ }
if (RE_WriteEnvmapResult(op->reports, scene, env, path, imtype, layout)) {
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index 0b643cd7858..ba0c22a4ade 100644
--- a/source/blender/editors/space_buttons/buttons_ops.c
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -205,6 +205,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_CANCELLED;
}
else {
+ PropertyRNA *prop_relpath;
const char *path_prop = RNA_struct_find_property(op->ptr, "directory") ? "directory" : "filepath";
fbo = MEM_callocN(sizeof(FileBrowseOp), "FileBrowseOp");
fbo->ptr = ptr;
@@ -216,10 +217,10 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* normally ED_fileselect_get_params would handle this but we need to because of stupid
* user-prefs exception - campbell */
- if (RNA_struct_find_property(op->ptr, "relative_path")) {
- if (!RNA_struct_property_is_set(op->ptr, "relative_path")) {
+ if ((prop_relpath = RNA_struct_find_property(op->ptr, "relative_path"))) {
+ if (!RNA_property_is_set(op->ptr, prop_relpath)) {
/* annoying exception!, if were dealing with the user prefs, default relative to be off */
- RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS && (ptr.data != &U));
+ RNA_property_boolean_set(op->ptr, prop_relpath, U.flag & USER_RELPATHS && (ptr.data != &U));
}
}
WM_event_add_fileselect(C, op);
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index fe158633439..9e7adaa2de5 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -461,12 +461,13 @@ void FILE_OT_select_all_toggle(wmOperatorType *ot)
static int bookmark_select_exec(bContext *C, wmOperator *op)
{
SpaceFile *sfile = CTX_wm_space_file(C);
+ PropertyRNA *prop;
- if (RNA_struct_find_property(op->ptr, "dir")) {
+ if ((prop = RNA_struct_find_property(op->ptr, "dir"))) {
char entry[256];
FileSelectParams *params = sfile->params;
- RNA_string_get(op->ptr, "dir", entry);
+ RNA_property_string_get(op->ptr, prop, entry);
BLI_strncpy(params->dir, entry, sizeof(params->dir));
BLI_cleanup_dir(G.main->name, params->dir);
ED_file_change_dir(C, true);
@@ -830,57 +831,59 @@ void FILE_OT_cancel(struct wmOperatorType *ot)
void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath)
{
+ PropertyRNA *prop;
+
BLI_join_dirfile(filepath, FILE_MAX, sfile->params->dir, sfile->params->file); /* XXX, not real length */
- if (RNA_struct_find_property(op->ptr, "relative_path")) {
- if (RNA_boolean_get(op->ptr, "relative_path")) {
+
+ if ((prop = RNA_struct_find_property(op->ptr, "relative_path"))) {
+ if (RNA_property_boolean_get(op->ptr, prop)) {
BLI_path_rel(filepath, G.main->name);
}
}
- if (RNA_struct_find_property(op->ptr, "filename")) {
- RNA_string_set(op->ptr, "filename", sfile->params->file);
+ if ((prop = RNA_struct_find_property(op->ptr, "filename"))) {
+ RNA_property_string_set(op->ptr, prop, sfile->params->file);
}
- if (RNA_struct_find_property(op->ptr, "directory")) {
- RNA_string_set(op->ptr, "directory", sfile->params->dir);
+ if ((prop = RNA_struct_find_property(op->ptr, "directory"))) {
+ RNA_property_string_set(op->ptr, prop, sfile->params->dir);
}
- if (RNA_struct_find_property(op->ptr, "filepath")) {
- RNA_string_set(op->ptr, "filepath", filepath);
+ if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) {
+ RNA_property_string_set(op->ptr, prop, filepath);
}
/* some ops have multiple files to select */
/* this is called on operators check() so clear collections first since
* they may be already set. */
{
- PointerRNA itemptr;
- PropertyRNA *prop_files = RNA_struct_find_property(op->ptr, "files");
- PropertyRNA *prop_dirs = RNA_struct_find_property(op->ptr, "dirs");
int i, numfiles = filelist_numfiles(sfile->files);
- if (prop_files) {
+ if ((prop = RNA_struct_find_property(op->ptr, "files"))) {
+ PointerRNA itemptr;
int num_files = 0;
- RNA_property_collection_clear(op->ptr, prop_files);
+ RNA_property_collection_clear(op->ptr, prop);
for (i = 0; i < numfiles; i++) {
if (filelist_is_selected(sfile->files, i, CHECK_FILES)) {
struct direntry *file = filelist_file(sfile->files, i);
- RNA_property_collection_add(op->ptr, prop_files, &itemptr);
+ RNA_property_collection_add(op->ptr, prop, &itemptr);
RNA_string_set(&itemptr, "name", file->relname);
num_files++;
}
}
/* make sure the file specified in the filename button is added even if no files selected */
if (0 == num_files) {
- RNA_property_collection_add(op->ptr, prop_files, &itemptr);
+ RNA_property_collection_add(op->ptr, prop, &itemptr);
RNA_string_set(&itemptr, "name", sfile->params->file);
}
}
- if (prop_dirs) {
+ if ((prop = RNA_struct_find_property(op->ptr, "dirs"))) {
+ PointerRNA itemptr;
int num_dirs = 0;
- RNA_property_collection_clear(op->ptr, prop_dirs);
+ RNA_property_collection_clear(op->ptr, prop);
for (i = 0; i < numfiles; i++) {
if (filelist_is_selected(sfile->files, i, CHECK_DIRS)) {
struct direntry *file = filelist_file(sfile->files, i);
- RNA_property_collection_add(op->ptr, prop_dirs, &itemptr);
+ RNA_property_collection_add(op->ptr, prop, &itemptr);
RNA_string_set(&itemptr, "name", file->relname);
num_dirs++;
}
@@ -888,7 +891,7 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath)
/* make sure the directory specified in the button is added even if no directory selected */
if (0 == num_dirs) {
- RNA_property_collection_add(op->ptr, prop_dirs, &itemptr);
+ RNA_property_collection_add(op->ptr, prop, &itemptr);
RNA_string_set(&itemptr, "name", sfile->params->dir);
}
}
@@ -952,8 +955,9 @@ void file_draw_check_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2))
bool file_draw_check_exists(SpaceFile *sfile)
{
if (sfile->op) { /* fails on reload */
- if (RNA_struct_find_property(sfile->op->ptr, "check_existing")) {
- if (RNA_boolean_get(sfile->op->ptr, "check_existing")) {
+ PropertyRNA *prop;
+ if ((prop = RNA_struct_find_property(sfile->op->ptr, "check_existing"))) {
+ if (RNA_property_boolean_get(sfile->op->ptr, prop)) {
char filepath[FILE_MAX];
BLI_join_dirfile(filepath, sizeof(filepath), sfile->params->dir, sfile->params->file);
if (BLI_is_file(filepath)) {
@@ -1291,6 +1295,7 @@ int file_directory_new_exec(bContext *C, wmOperator *op)
char name[FILE_MAXFILE];
char path[FILE_MAX];
int generate_name = 1;
+ PropertyRNA *prop;
wmWindowManager *wm = CTX_wm_manager(C);
SpaceFile *sfile = CTX_wm_space_file(C);
@@ -1302,8 +1307,8 @@ int file_directory_new_exec(bContext *C, wmOperator *op)
path[0] = '\0';
- if (RNA_struct_find_property(op->ptr, "directory")) {
- RNA_string_get(op->ptr, "directory", path);
+ if ((prop = RNA_struct_find_property(op->ptr, "directory"))) {
+ RNA_property_string_get(op->ptr, prop, path);
if (path[0] != '\0') generate_name = 0;
}
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 761249e7979..3206a0ff89b 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -117,10 +117,12 @@ short ED_fileselect_set_params(SpaceFile *sfile)
BLI_strncpy_utf8(params->title, RNA_struct_ui_name(op->type->srna), sizeof(params->title));
- if (RNA_struct_find_property(op->ptr, "filemode"))
- params->type = RNA_int_get(op->ptr, "filemode");
- else
+ if ((prop = RNA_struct_find_property(op->ptr, "filemode"))) {
+ params->type = RNA_property_int_get(op->ptr, prop);
+ }
+ else {
params->type = FILE_SPECIAL;
+ }
if (is_filepath && RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
char name[FILE_MAX];
@@ -210,8 +212,9 @@ short ED_fileselect_set_params(SpaceFile *sfile)
params->flag |= RNA_boolean_get(op->ptr, "active_layer") ? FILE_ACTIVELAY : 0;
}
- if (RNA_struct_find_property(op->ptr, "display_type"))
- params->display = RNA_enum_get(op->ptr, "display_type");
+ if ((prop = RNA_struct_find_property(op->ptr, "display_type"))) {
+ params->display = RNA_property_enum_get(op->ptr, prop);
+ }
if (params->display == FILE_DEFAULTDISPLAY) {
if (U.uiflag & USER_SHOW_THUMBNAILS) {
@@ -226,8 +229,10 @@ short ED_fileselect_set_params(SpaceFile *sfile)
}
if (is_relative_path) {
- if (!RNA_struct_property_is_set_ex(op->ptr, "relative_path", false)) {
- RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
+ if ((prop = RNA_struct_find_property(op->ptr, "relative_path"))) {
+ if (!RNA_property_is_set_ex(op->ptr, prop, false)) {
+ RNA_property_boolean_set(op->ptr, prop, U.flag & USER_RELPATHS);
+ }
}
}
}
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 193bcbb3691..58ef2958f37 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1974,8 +1974,8 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
}
}
- if (RNA_struct_find_property(op->ptr, "proportional")) {
- RNA_enum_set(op->ptr, "proportional", proportional);
+ if ((prop = RNA_struct_find_property(op->ptr, "proportional"))) {
+ RNA_property_enum_set(op->ptr, prop, proportional);
RNA_enum_set(op->ptr, "proportional_edit_falloff", t->prop_mode);
RNA_float_set(op->ptr, "proportional_size", t->prop_size);
}