PyAPI: expose 'bl_options' for operators in bpy.ops
Useful for checking which operators are only for internal use.
This commit is contained in:
parent
06ba233374
commit
c78c425266
Notes:
blender-bot
2023-02-14 03:31:57 +01:00
Referenced by issue #81820, difference in rendering of alpha material between 2.90 and 2.91 (Eevee) Referenced by issue #80327, Glitches in UI drawing
|
@ -27,6 +27,7 @@ op_poll = ops_module.poll
|
|||
op_call = ops_module.call
|
||||
op_as_string = ops_module.as_string
|
||||
op_get_rna_type = ops_module.get_rna_type
|
||||
op_get_bl_options = ops_module.get_bl_options
|
||||
|
||||
|
||||
class BPyOps:
|
||||
|
@ -209,6 +210,10 @@ class BPyOpsSubModOp:
|
|||
"""Internal function for introspection"""
|
||||
return op_get_rna_type(self.idname())
|
||||
|
||||
@property
|
||||
def bl_options(self):
|
||||
return op_get_bl_options(self.idname())
|
||||
|
||||
def __repr__(self): # useful display, repr(op)
|
||||
# import bpy
|
||||
return op_as_string(self.idname())
|
||||
|
|
|
@ -117,6 +117,8 @@ extern const EnumPropertyItem rna_enum_motionpath_bake_location_items[];
|
|||
extern const EnumPropertyItem rna_enum_event_value_items[];
|
||||
extern const EnumPropertyItem rna_enum_event_type_items[];
|
||||
extern const EnumPropertyItem rna_enum_event_type_mask_items[];
|
||||
|
||||
extern const EnumPropertyItem rna_enum_operator_type_flag_items[];
|
||||
extern const EnumPropertyItem rna_enum_operator_return_items[];
|
||||
extern const EnumPropertyItem rna_enum_operator_property_tags[];
|
||||
|
||||
|
|
|
@ -438,8 +438,7 @@ static const EnumPropertyItem keymap_modifiers_items[] = {
|
|||
};
|
||||
#endif
|
||||
|
||||
#ifndef RNA_RUNTIME
|
||||
static const EnumPropertyItem operator_flag_items[] = {
|
||||
const EnumPropertyItem rna_enum_operator_type_flag_items[] = {
|
||||
{OPTYPE_REGISTER,
|
||||
"REGISTER",
|
||||
0,
|
||||
|
@ -465,7 +464,6 @@ static const EnumPropertyItem operator_flag_items[] = {
|
|||
{OPTYPE_INTERNAL, "INTERNAL", 0, "Internal", "Removes the operator from search results"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
#endif
|
||||
|
||||
const EnumPropertyItem rna_enum_operator_return_items[] = {
|
||||
{OPERATOR_RUNNING_MODAL,
|
||||
|
@ -1928,7 +1926,7 @@ static void rna_def_operator(BlenderRNA *brna)
|
|||
|
||||
prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "type->flag");
|
||||
RNA_def_property_enum_items(prop, operator_flag_items);
|
||||
RNA_def_property_enum_items(prop, rna_enum_operator_type_flag_items);
|
||||
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
|
||||
RNA_def_property_ui_text(prop, "Options", "Options for this operator type");
|
||||
|
||||
|
@ -2020,7 +2018,7 @@ static void rna_def_macro_operator(BlenderRNA *brna)
|
|||
|
||||
prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "type->flag");
|
||||
RNA_def_property_enum_items(prop, operator_flag_items);
|
||||
RNA_def_property_enum_items(prop, rna_enum_operator_type_flag_items);
|
||||
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
|
||||
RNA_def_property_ui_text(prop, "Options", "Options for this operator type");
|
||||
|
||||
|
|
|
@ -436,12 +436,22 @@ static PyObject *pyop_getrna_type(PyObject *UNUSED(self), PyObject *value)
|
|||
return (PyObject *)pyrna;
|
||||
}
|
||||
|
||||
static PyObject *pyop_get_bl_options(PyObject *UNUSED(self), PyObject *value)
|
||||
{
|
||||
wmOperatorType *ot;
|
||||
if ((ot = ot_lookup_from_py_string(value, "get_bl_options")) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return pyrna_enum_bitfield_to_py(rna_enum_operator_type_flag_items, ot->flag);
|
||||
}
|
||||
|
||||
static struct PyMethodDef bpy_ops_methods[] = {
|
||||
{"poll", (PyCFunction)pyop_poll, METH_VARARGS, NULL},
|
||||
{"call", (PyCFunction)pyop_call, METH_VARARGS, NULL},
|
||||
{"as_string", (PyCFunction)pyop_as_string, METH_VARARGS, NULL},
|
||||
{"dir", (PyCFunction)pyop_dir, METH_NOARGS, NULL},
|
||||
{"get_rna_type", (PyCFunction)pyop_getrna_type, METH_O, NULL},
|
||||
{"get_bl_options", (PyCFunction)pyop_get_bl_options, METH_O, NULL},
|
||||
{"macro_define", (PyCFunction)PYOP_wrap_macro_define, METH_VARARGS, NULL},
|
||||
{NULL, NULL, 0, NULL},
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue