Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Thu, 12 Jul 2018 06:31:19 +0000 (08:31 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 12 Jul 2018 06:31:19 +0000 (08:31 +0200)
1  2 
build_files/buildbot/slave_compile.py
source/blender/python/intern/bpy_rna.c

index 43964dda6912ec2c81147443f26eca1904582884,c43bb88b270a9219fd1a65efd8b044b41ce75ab8..59b35a535aa864fd4f6bb311b0290993a41cf9cd
@@@ -60,6 -60,7 +60,6 @@@ if 'cmake' in builder
  
      # Config file to be used (relative to blender's sources root)
      cmake_config_file = "build_files/cmake/config/blender_full.cmake"
 -    cmake_player_config_file = None
      cmake_cuda_config_file = None
  
      # Set build options.
          # cmake_extra_options.append('-DCUDA_NVCC_EXECUTABLE=/usr/local/cuda-hack/nvcc')
  
      elif builder.startswith('win'):
-         if builder.endswith('_vc2015'):
+         if builder.endswith('_vc2017'):
+             if builder.startswith('win64'):
+                 cmake_options.extend(['-G', 'Visual Studio 15 2017 Win64'])
+             elif builder.startswith('win32'):
+                 bits = 32
+                 cmake_options.extend(['-G', 'Visual Studio 15 2017'])
+         elif builder.endswith('_vc2015'):
              if builder.startswith('win64'):
                  cmake_options.extend(['-G', 'Visual Studio 14 2015 Win64'])
              elif builder.startswith('win32'):
          elif glibc == 'glibc211':
              deb_name = "squeeze"
          cmake_config_file = "build_files/buildbot/config/blender_linux.cmake"
 -        cmake_player_config_file = "build_files/buildbot/config/blender_linux_player.cmake"
          if builder.endswith('x86_64_cmake'):
              chroot_name = 'buildbot_' + deb_name + '_x86_64'
 -            targets = ['player', 'blender']
 +            targets = ['blender']
          elif builder.endswith('i686_cmake'):
              bits = 32
              chroot_name = 'buildbot_' + deb_name + '_i686'
 -            targets = ['player', 'blender']
 +            targets = ['blender']
          cmake_extra_options.extend(["-DCMAKE_C_COMPILER=/usr/bin/gcc-7",
                                      "-DCMAKE_CXX_COMPILER=/usr/bin/g++-7"])
  
          os.chdir(target_build_dir)
          # Tweaking CMake options to respect the target
          target_cmake_options = cmake_options[:]
 -        if target == 'player':
 -            target_cmake_options.append("-C" + os.path.join(blender_dir, cmake_player_config_file))
 -        elif target == 'cuda':
 +        if target == 'cuda':
              target_cmake_options += cuda_cmake_options
              target_chroot_prefix = cuda_chroot_prefix[:]
              target_name = 'cycles_kernel_cuda'
index 00ff63f7275394a2f45909c8ef0e72f53d069726,80b0aa7a51b40c7017f1ff3b0b49346784a5577c..36df7c258671202fcfb18148dc6311b8e6f37bb9
@@@ -315,7 -315,7 +315,7 @@@ static bool rna_id_write_error(PointerR
        ID *id = ptr->id.data;
        if (id) {
                const short idcode = GS(id->name);
 -              if (!ELEM(idcode, ID_WM, ID_SCR)) { /* may need more added here */
 +              if (!ELEM(idcode, ID_WM, ID_SCR, ID_WS)) { /* may need more added here */
                        const char *idtype = BKE_idcode_to_name(idcode);
                        const char *pyname;
                        if (key && PyUnicode_Check(key)) pyname = _PyUnicode_AsString(key);
@@@ -1849,28 -1849,19 +1849,28 @@@ static int pyrna_py_to_prop
                                 * class mixing if this causes problems in the future it should be removed.
                                 */
                                if ((ptr_type == &RNA_AnyType) &&
 -                                  (BPy_StructRNA_Check(value)) &&
 -                                  (RNA_struct_is_a(((BPy_StructRNA *)value)->ptr.type, &RNA_Operator)))
 +                                  (BPy_StructRNA_Check(value)))
                                {
 -                                      value = PyObject_GetAttrString(value, "properties");
 -                                      value_new = value;
 +                                      const StructRNA *base_type =
 +                                              RNA_struct_base_child_of(((const BPy_StructRNA *)value)->ptr.type, NULL);
 +                                      if (ELEM(base_type, &RNA_Operator, &RNA_Manipulator)) {
 +                                              value = PyObject_GetAttr(value, bpy_intern_str_properties);
 +                                              value_new = value;
 +                                      }
                                }
  
 -
 -                              /* if property is an OperatorProperties pointer and value is a map,
 +                              /* if property is an OperatorProperties/ManipulatorProperties pointer and value is a map,
                                 * forward back to pyrna_pydict_to_props */
 -                              if (RNA_struct_is_a(ptr_type, &RNA_OperatorProperties) && PyDict_Check(value)) {
 -                                      PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
 -                                      return pyrna_pydict_to_props(&opptr, value, false, error_prefix);
 +                              if (PyDict_Check(value)) {
 +                                      const StructRNA *base_type = RNA_struct_base_child_of(ptr_type, NULL);
 +                                      if (base_type == &RNA_OperatorProperties) {
 +                                              PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
 +                                              return pyrna_pydict_to_props(&opptr, value, false, error_prefix);
 +                                      }
 +                                      else if (base_type == &RNA_ManipulatorProperties) {
 +                                              PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
 +                                              return pyrna_pydict_to_props(&opptr, value, false, error_prefix);
 +                                      }
                                }
  
                                /* another exception, allow to pass a collection as an RNA property */
@@@ -3509,68 -3500,6 +3509,68 @@@ static PyObject *pyrna_struct_is_proper
        return PyBool_FromLong(!RNA_property_editable(&self->ptr, prop));
  }
  
 +
 +PyDoc_STRVAR(pyrna_struct_is_property_overridable_static_doc,
 +".. method:: is_property_overridable_static(property)\n"
 +"\n"
 +"   Check if a property is statically overridable.\n"
 +"\n"
 +"   :return: True when the property is statically overridable.\n"
 +"   :rtype: boolean\n"
 +);
 +static PyObject *pyrna_struct_is_property_overridable_static(BPy_StructRNA *self, PyObject *args)
 +{
 +      PropertyRNA *prop;
 +      const char *name;
 +
 +      PYRNA_STRUCT_CHECK_OBJ(self);
 +
 +      if (!PyArg_ParseTuple(args, "s:is_property_overridable_static", &name)) {
 +              return NULL;
 +      }
 +
 +      if ((prop = RNA_struct_find_property(&self->ptr, name)) == NULL) {
 +              PyErr_Format(PyExc_TypeError,
 +                           "%.200s.is_property_overridable_static(\"%.200s\") not found",
 +                           RNA_struct_identifier(self->ptr.type), name);
 +              return NULL;
 +      }
 +
 +      return PyBool_FromLong((long)RNA_property_overridable_get(&self->ptr, prop));
 +}
 +
 +PyDoc_STRVAR(pyrna_struct_property_overridable_static_set_doc,
 +".. method:: property_overridable_static_set(property)\n"
 +"\n"
 +"   Define a property as statically overridable or not (only for custom properties!).\n"
 +"\n"
 +"   :return: True when the overridable status of the property was successfully set.\n"
 +"   :rtype: boolean\n"
 +);
 +static PyObject *pyrna_struct_property_overridable_static_set(BPy_StructRNA *self, PyObject *args)
 +{
 +      PropertyRNA *prop;
 +      const char *name;
 +      int is_overridable;
 +
 +      PYRNA_STRUCT_CHECK_OBJ(self);
 +
 +      if (!PyArg_ParseTuple(args, "sp:property_overridable_static_set", &name, &is_overridable)) {
 +              return NULL;
 +      }
 +
 +      if ((prop = RNA_struct_find_property(&self->ptr, name)) == NULL) {
 +              PyErr_Format(PyExc_TypeError,
 +                           "%.200s.property_overridable_static_set(\"%.200s\") not found",
 +                           RNA_struct_identifier(self->ptr.type), name);
 +              return NULL;
 +      }
 +
 +      return PyBool_FromLong((long)RNA_property_overridable_static_set(&self->ptr, prop, (bool)is_overridable));
 +}
 +
 +
 +
  PyDoc_STRVAR(pyrna_struct_path_resolve_doc,
  ".. method:: path_resolve(path, coerce=True)\n"
  "\n"
@@@ -5240,8 -5169,6 +5240,8 @@@ static struct PyMethodDef pyrna_struct_
        {"property_unset", (PyCFunction)pyrna_struct_property_unset, METH_VARARGS, pyrna_struct_property_unset_doc},
        {"is_property_hidden", (PyCFunction)pyrna_struct_is_property_hidden, METH_VARARGS, pyrna_struct_is_property_hidden_doc},
        {"is_property_readonly", (PyCFunction)pyrna_struct_is_property_readonly, METH_VARARGS, pyrna_struct_is_property_readonly_doc},
 +      {"is_property_overridable_static", (PyCFunction)pyrna_struct_is_property_overridable_static, METH_VARARGS, pyrna_struct_is_property_overridable_static_doc},
 +      {"property_overridable_static_set", (PyCFunction)pyrna_struct_property_overridable_static_set, METH_VARARGS, pyrna_struct_property_overridable_static_set_doc},
        {"path_resolve", (PyCFunction)pyrna_struct_path_resolve, METH_VARARGS, pyrna_struct_path_resolve_doc},
        {"path_from_id", (PyCFunction)pyrna_struct_path_from_id, METH_VARARGS, pyrna_struct_path_from_id_doc},
        {"type_recast", (PyCFunction)pyrna_struct_type_recast, METH_NOARGS, pyrna_struct_type_recast_doc},
@@@ -7423,38 -7350,29 +7423,38 @@@ static int deferred_register_prop(Struc
  
  static int pyrna_deferred_register_props(StructRNA *srna, PyObject *class_dict)
  {
 +      PyObject *fields_dict;
        PyObject *item, *key;
 -      PyObject *order;
        Py_ssize_t pos = 0;
        int ret = 0;
  
        /* in both cases PyDict_CheckExact(class_dict) will be true even
         * though Operators have a metaclass dict namespace */
 +      if ((fields_dict = PyDict_GetItem(class_dict, bpy_intern_str___annotations__)) && PyDict_CheckExact(fields_dict)) {
 +              while (PyDict_Next(fields_dict, &pos, &key, &item)) {
 +                      ret = deferred_register_prop(srna, key, item);
  
 -      if ((order = PyDict_GetItem(class_dict, bpy_intern_str_order)) && PyList_CheckExact(order)) {
 -              for (pos = 0; pos < PyList_GET_SIZE(order); pos++) {
 -                      key = PyList_GET_ITEM(order, pos);
 -                      /* however unlikely its possible
 -                       * fails in py 3.3 beta with __qualname__ */
 -                      if ((item = PyDict_GetItem(class_dict, key))) {
 -                              ret = deferred_register_prop(srna, key, item);
 -                              if (ret != 0) {
 -                                      break;
 -                              }
 +                      if (ret != 0) {
 +                              break;
                        }
                }
        }
 -      else {
 +
 +      {
 +              /* This block can be removed once 2.8x is released and fields are in use. */
 +              bool has_warning = false;
                while (PyDict_Next(class_dict, &pos, &key, &item)) {
 +                      if (pyrna_is_deferred_prop(item)) {
 +                              if (!has_warning) {
 +                                      PyC_StackSpit();
 +                                      printf("Warning: class %.200s "
 +                                             "contains a properties which should be a field!\n",
 +                                             RNA_struct_identifier(srna));
 +                                      has_warning = true;
 +                              }
 +                              printf("    make field: %.200s.%.200s\n",
 +                                     RNA_struct_identifier(srna), _PyUnicode_AsString(key));
 +                      }
                        ret = deferred_register_prop(srna, key, item);
  
                        if (ret != 0)
@@@ -7659,10 -7577,12 +7659,12 @@@ static int bpy_class_validate_recursive
                if (!(flag & PROP_REGISTER))
                        continue;
  
+               /* TODO(campbell): Use Python3.7x _PyObject_LookupAttr(), also in the macro below. */
                identifier = RNA_property_identifier(prop);
                item = PyObject_GetAttrString(py_class, identifier);
  
                if (item == NULL) {
+                       PyErr_Clear();
                        /* Sneaky workaround to use the class name as the bl_idname */
  
  #define     BPY_REPLACEMENT_STRING(rna_attr, py_attr)                         \
                                        }                                                         \
                                        Py_DECREF(item);                                          \
                                }                                                             \
+                               else {                                                        \
+                                       PyErr_Clear();                                            \
+                               }                                                             \
                        }  /* intentionally allow else here */
  
                        if (false) {}  /* needed for macro */
@@@ -7732,8 -7655,7 +7737,8 @@@ static int bpy_class_call(bContext *C, 
        PyGILState_STATE gilstate;
  
  #ifdef USE_PEDANTIC_WRITE
 -      const bool is_readonly_init = !RNA_struct_is_a(ptr->type, &RNA_Operator);
 +      const bool is_readonly_init = !(RNA_struct_is_a(ptr->type, &RNA_Operator) ||
 +                                      RNA_struct_is_a(ptr->type, &RNA_Manipulator));
        // const char *func_id = RNA_function_identifier(func);  /* UNUSED */
        /* testing, for correctness, not operator and not draw function */
        const bool is_readonly = !(RNA_function_flag(func) & FUNC_ALLOW_WRITE);
@@@ -8391,43 -8313,6 +8396,43 @@@ static PyObject *pyrna_unregister_class
        Py_RETURN_NONE;
  }
  
 +/* Access to 'owner_id' internal global. */
 +
 +static PyObject *pyrna_bl_owner_id_get(PyObject *UNUSED(self))
 +{
 +      const char *name = RNA_struct_state_owner_get();
 +      if (name) {
 +              return PyUnicode_FromString(name);
 +      }
 +      Py_RETURN_NONE;
 +}
 +
 +static PyObject *pyrna_bl_owner_id_set(PyObject *UNUSED(self), PyObject *value)
 +{
 +      const char *name;
 +      if (value == Py_None) {
 +              name = NULL;
 +      }
 +      else if (PyUnicode_Check(value)) {
 +              name = _PyUnicode_AsString(value);
 +      }
 +      else {
 +              PyErr_Format(PyExc_ValueError,
 +                           "owner_set(...): "
 +                           "expected None or a string, not '%.200s'", Py_TYPE(value)->tp_name);
 +              return NULL;
 +      }
 +      RNA_struct_state_owner_set(name);
 +      Py_RETURN_NONE;
 +}
 +
 +PyMethodDef meth_bpy_owner_id_get = {
 +      "_bl_owner_id_get", (PyCFunction)pyrna_bl_owner_id_get, METH_NOARGS, NULL,
 +};
 +PyMethodDef meth_bpy_owner_id_set = {
 +      "_bl_owner_id_set", (PyCFunction)pyrna_bl_owner_id_set, METH_O, NULL,
 +};
 +
  /* currently this is fairly limited, we would need to make some way to split up
   * pyrna_callback_classmethod_... if we want more than one callback per type */
  typedef struct BPyRNA_CallBack {