Blender  V3.3
bpy.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
11 /* Future-proof, See https://docs.python.org/3/c-api/arg.html#strings-and-buffers */
12 #define PY_SSIZE_T_CLEAN
13 
14 #include <Python.h>
15 
16 #include "BLI_string.h"
17 #include "BLI_string_utils.h"
18 #include "BLI_utildefines.h"
19 
20 #include "BKE_appdir.h"
21 #include "BKE_blender_version.h"
22 #include "BKE_bpath.h"
23 #include "BKE_global.h" /* XXX, G_MAIN only */
24 
25 #include "RNA_access.h"
26 #include "RNA_enum_types.h"
27 #include "RNA_prototypes.h"
28 #include "RNA_types.h"
29 
30 #include "GPU_state.h"
31 
32 #include "bpy.h"
33 #include "bpy_app.h"
34 #include "bpy_capi_utils.h"
35 #include "bpy_driver.h"
36 #include "bpy_library.h"
37 #include "bpy_operator.h"
38 #include "bpy_props.h"
39 #include "bpy_rna.h"
40 #include "bpy_rna_data.h"
41 #include "bpy_rna_gizmo.h"
42 #include "bpy_rna_id_collection.h"
43 #include "bpy_rna_types_capi.h"
44 #include "bpy_utils_previews.h"
45 #include "bpy_utils_units.h"
46 
47 #include "../generic/py_capi_utils.h"
48 #include "../generic/python_utildefines.h"
49 
50 /* external util modules */
51 #include "../generic/idprop_py_api.h"
52 #include "../generic/idprop_py_ui_api.h"
53 #include "bpy_msgbus.h"
54 
55 #ifdef WITH_FREESTYLE
56 # include "BPy_Freestyle.h"
57 #endif
58 
59 PyObject *bpy_package_py = NULL;
60 
61 PyDoc_STRVAR(bpy_script_paths_doc,
62  ".. function:: script_paths()\n"
63  "\n"
64  " Return 2 paths to blender scripts directories.\n"
65  "\n"
66  " :return: (system, user) strings will be empty when not found.\n"
67  " :rtype: tuple of strings\n");
68 static PyObject *bpy_script_paths(PyObject *UNUSED(self))
69 {
70  PyObject *ret = PyTuple_New(2);
71  PyObject *item;
72  const char *path;
73 
75  item = PyC_UnicodeFromByte(path ? path : "");
76  BLI_assert(item != NULL);
77  PyTuple_SET_ITEM(ret, 0, item);
79  item = PyC_UnicodeFromByte(path ? path : "");
80  BLI_assert(item != NULL);
81  PyTuple_SET_ITEM(ret, 1, item);
82 
83  return ret;
84 }
85 
87  char *UNUSED(path_dst),
88  const char *path_src)
89 {
90  PyObject *py_list = bpath_data->user_data;
91  PyList_APPEND(py_list, PyC_UnicodeFromByte(path_src));
92  return false; /* Never edits the path. */
93 }
94 
95 PyDoc_STRVAR(bpy_blend_paths_doc,
96  ".. function:: blend_paths(absolute=False, packed=False, local=False)\n"
97  "\n"
98  " Returns a list of paths to external files referenced by the loaded .blend file.\n"
99  "\n"
100  " :arg absolute: When true the paths returned are made absolute.\n"
101  " :type absolute: boolean\n"
102  " :arg packed: When true skip file paths for packed data.\n"
103  " :type packed: boolean\n"
104  " :arg local: When true skip linked library paths.\n"
105  " :type local: boolean\n"
106  " :return: path list.\n"
107  " :rtype: list of strings\n");
108 static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
109 {
110  eBPathForeachFlag flag = 0;
111  PyObject *list;
112 
113  bool absolute = false;
114  bool packed = false;
115  bool local = false;
116 
117  static const char *_keywords[] = {"absolute", "packed", "local", NULL};
118  static _PyArg_Parser _parser = {
119  "|$" /* Optional keyword only arguments. */
120  "O&" /* `absolute` */
121  "O&" /* `packed` */
122  "O&" /* `local` */
123  ":blend_paths",
124  _keywords,
125  0,
126  };
127  if (!_PyArg_ParseTupleAndKeywordsFast(args,
128  kw,
129  &_parser,
131  &absolute,
133  &packed,
135  &local)) {
136  return NULL;
137  }
138 
139  if (absolute) {
141  }
142  if (!packed) {
144  }
145  if (local) {
147  }
148 
149  list = PyList_New(0);
150 
152  .bmain = G_MAIN,
153  .callback_function = bpy_blend_foreach_path_cb,
154  .flag = flag,
155  .user_data = list,
156  });
157 
158  return list;
159 }
160 
161 PyDoc_STRVAR(bpy_flip_name_doc,
162  ".. function:: flip_name(name, strip_digits=False)\n"
163  "\n"
164  " Flip a name between left/right sides, useful for \n"
165  " mirroring bone names.\n"
166  "\n"
167  " :arg name: Bone name to flip.\n"
168  " :type name: string\n"
169  " :arg strip_digits: Whether to remove ``.###`` suffix.\n"
170  " :type strip_digits: bool\n"
171  " :return: The flipped name.\n"
172  " :rtype: string\n");
173 static PyObject *bpy_flip_name(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
174 {
175  const char *name_src = NULL;
176  Py_ssize_t name_src_len;
177  bool strip_digits = false;
178 
179  static const char *_keywords[] = {"", "strip_digits", NULL};
180  static _PyArg_Parser _parser = {
181  "s#" /* `name` */
182  "|$" /* Optional, keyword only arguments. */
183  "O&" /* `strip_digits` */
184  ":flip_name",
185  _keywords,
186  0,
187  };
188  if (!_PyArg_ParseTupleAndKeywordsFast(
189  args, kw, &_parser, &name_src, &name_src_len, PyC_ParseBool, &strip_digits)) {
190  return NULL;
191  }
192 
193  /* Worst case we gain one extra byte (besides null-terminator) by changing
194  * "Left" to "Right", because only the first appearance of "Left" gets replaced. */
195  const size_t size = name_src_len + 2;
196  char *name_dst = PyMem_MALLOC(size);
197  const size_t name_dst_len = BLI_string_flip_side_name(name_dst, name_src, strip_digits, size);
198 
199  PyObject *result = PyUnicode_FromStringAndSize(name_dst, name_dst_len);
200 
201  PyMem_FREE(name_dst);
202 
203  return result;
204 }
205 
206 // PyDoc_STRVAR(bpy_user_resource_doc[] = /* now in bpy/utils.py */
207 static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
208 {
209  const struct PyC_StringEnumItems type_items[] = {
210  {BLENDER_USER_DATAFILES, "DATAFILES"},
211  {BLENDER_USER_CONFIG, "CONFIG"},
212  {BLENDER_USER_SCRIPTS, "SCRIPTS"},
213  {BLENDER_USER_AUTOSAVE, "AUTOSAVE"},
214  {0, NULL},
215  };
216  struct PyC_StringEnum type = {type_items};
217 
218  const char *subdir = NULL;
219 
220  const char *path;
221 
222  static const char *_keywords[] = {"type", "path", NULL};
223  static _PyArg_Parser _parser = {
224  "O&" /* `type` */
225  "|$" /* Optional keyword only arguments. */
226  "s" /* `path` */
227  ":user_resource",
228  _keywords,
229  0,
230  };
231  if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, PyC_ParseStringEnum, &type, &subdir)) {
232  return NULL;
233  }
234 
235  /* same logic as BKE_appdir_folder_id_create(),
236  * but best leave it up to the script author to create */
237  path = BKE_appdir_folder_id_user_notest(type.value_found, subdir);
238 
239  return PyC_UnicodeFromByte(path ? path : "");
240 }
241 
242 PyDoc_STRVAR(bpy_system_resource_doc,
243  ".. function:: system_resource(type, path=\"\")\n"
244  "\n"
245  " Return a system resource path.\n"
246  "\n"
247  " :arg type: string in ['DATAFILES', 'SCRIPTS', 'PYTHON'].\n"
248  " :type type: string\n"
249  " :arg path: Optional subdirectory.\n"
250  " :type path: string\n");
251 static PyObject *bpy_system_resource(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
252 {
253  const struct PyC_StringEnumItems type_items[] = {
254  {BLENDER_SYSTEM_DATAFILES, "DATAFILES"},
255  {BLENDER_SYSTEM_SCRIPTS, "SCRIPTS"},
256  {BLENDER_SYSTEM_PYTHON, "PYTHON"},
257  {0, NULL},
258  };
259  struct PyC_StringEnum type = {type_items};
260 
261  const char *subdir = NULL;
262 
263  const char *path;
264 
265  static const char *_keywords[] = {"type", "path", NULL};
266  static _PyArg_Parser _parser = {
267  "O&" /* `type` */
268  "|$" /* Optional keyword only arguments. */
269  "s" /* `path` */
270  ":system_resource",
271  _keywords,
272  0,
273  };
274  if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, PyC_ParseStringEnum, &type, &subdir)) {
275  return NULL;
276  }
277 
278  path = BKE_appdir_folder_id(type.value_found, subdir);
279 
280  return PyC_UnicodeFromByte(path ? path : "");
281 }
282 
284  bpy_resource_path_doc,
285  ".. function:: resource_path(type, major=bpy.app.version[0], minor=bpy.app.version[1])\n"
286  "\n"
287  " Return the base path for storing system files.\n"
288  "\n"
289  " :arg type: string in ['USER', 'LOCAL', 'SYSTEM'].\n"
290  " :type type: string\n"
291  " :arg major: major version, defaults to current.\n"
292  " :type major: int\n"
293  " :arg minor: minor version, defaults to current.\n"
294  " :type minor: string\n"
295  " :return: the resource path (not necessarily existing).\n"
296  " :rtype: string\n");
297 static PyObject *bpy_resource_path(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
298 {
299  const struct PyC_StringEnumItems type_items[] = {
300  {BLENDER_RESOURCE_PATH_USER, "USER"},
301  {BLENDER_RESOURCE_PATH_LOCAL, "LOCAL"},
302  {BLENDER_RESOURCE_PATH_SYSTEM, "SYSTEM"},
303  {0, NULL},
304  };
305  struct PyC_StringEnum type = {type_items};
306 
307  int major = BLENDER_VERSION / 100, minor = BLENDER_VERSION % 100;
308  const char *path;
309 
310  static const char *_keywords[] = {"type", "major", "minor", NULL};
311  static _PyArg_Parser _parser = {
312  "O&" /* `type` */
313  "|$" /* Optional keyword only arguments. */
314  "i" /* `major` */
315  "i" /* `minor` */
316  ":resource_path",
317  _keywords,
318  0,
319  };
320  if (!_PyArg_ParseTupleAndKeywordsFast(
321  args, kw, &_parser, PyC_ParseStringEnum, &type, &major, &minor)) {
322  return NULL;
323  }
324 
325  path = BKE_appdir_folder_id_version(type.value_found, (major * 100) + minor, false);
326 
327  return PyC_UnicodeFromByte(path ? path : "");
328 }
329 
330 /* This is only exposed for tests, see: `tests/python/bl_pyapi_bpy_driver_secure_eval.py`. */
331 PyDoc_STRVAR(bpy_driver_secure_code_test_doc,
332  ".. function:: _driver_secure_code_test(code)\n"
333  "\n"
334  " Test if the script should be considered trusted.\n"
335  "\n"
336  " :arg code: The code to test.\n"
337  " :type code: code\n"
338  " :arg namespace: The namespace of values which are allowed.\n"
339  " :type namespace: dict\n"
340  " :arg verbose: Print the reason for considering insecure to the ``stderr``.\n"
341  " :type verbose: bool\n"
342  " :return: True when the script is considered trusted.\n"
343  " :rtype: bool\n");
344 static PyObject *bpy_driver_secure_code_test(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
345 {
346  PyObject *py_code;
347  PyObject *py_namespace = NULL;
348  const bool verbose = false;
349  static const char *_keywords[] = {"code", "namespace", "verbose", NULL};
350  static _PyArg_Parser _parser = {
351  "O!" /* `expression` */
352  "|$" /* Optional keyword only arguments. */
353  "O!" /* `namespace` */
354  "O&" /* `verbose` */
355  ":driver_secure_code_test",
356  _keywords,
357  0,
358  };
359  if (!_PyArg_ParseTupleAndKeywordsFast(args,
360  kw,
361  &_parser,
362  &PyCode_Type,
363  &py_code,
364  &PyDict_Type,
365  &py_namespace,
367  &verbose)) {
368  return NULL;
369  }
370  return PyBool_FromLong(BPY_driver_secure_bytecode_test(py_code, py_namespace, verbose));
371 }
372 
373 PyDoc_STRVAR(bpy_escape_identifier_doc,
374  ".. function:: escape_identifier(string)\n"
375  "\n"
376  " Simple string escaping function used for animation paths.\n"
377  "\n"
378  " :arg string: text\n"
379  " :type string: string\n"
380  " :return: The escaped string.\n"
381  " :rtype: string\n");
382 static PyObject *bpy_escape_identifier(PyObject *UNUSED(self), PyObject *value)
383 {
384  Py_ssize_t value_str_len;
385  const char *value_str = PyUnicode_AsUTF8AndSize(value, &value_str_len);
386 
387  if (value_str == NULL) {
388  PyErr_SetString(PyExc_TypeError, "expected a string");
389  return NULL;
390  }
391 
392  const size_t size = (value_str_len * 2) + 1;
393  char *value_escape_str = PyMem_MALLOC(size);
394  const Py_ssize_t value_escape_str_len = BLI_str_escape(value_escape_str, value_str, size);
395 
396  PyObject *value_escape;
397  if (value_escape_str_len == value_str_len) {
398  Py_INCREF(value);
399  value_escape = value;
400  }
401  else {
402  value_escape = PyUnicode_FromStringAndSize(value_escape_str, value_escape_str_len);
403  }
404 
405  PyMem_FREE(value_escape_str);
406 
407  return value_escape;
408 }
409 
410 PyDoc_STRVAR(bpy_unescape_identifier_doc,
411  ".. function:: unescape_identifier(string)\n"
412  "\n"
413  " Simple string un-escape function used for animation paths.\n"
414  " This performs the reverse of `escape_identifier`.\n"
415  "\n"
416  " :arg string: text\n"
417  " :type string: string\n"
418  " :return: The un-escaped string.\n"
419  " :rtype: string\n");
420 static PyObject *bpy_unescape_identifier(PyObject *UNUSED(self), PyObject *value)
421 {
422  Py_ssize_t value_str_len;
423  const char *value_str = PyUnicode_AsUTF8AndSize(value, &value_str_len);
424 
425  if (value_str == NULL) {
426  PyErr_SetString(PyExc_TypeError, "expected a string");
427  return NULL;
428  }
429 
430  const size_t size = value_str_len + 1;
431  char *value_unescape_str = PyMem_MALLOC(size);
432  const Py_ssize_t value_unescape_str_len = BLI_str_unescape(value_unescape_str, value_str, size);
433 
434  PyObject *value_unescape;
435  if (value_unescape_str_len == value_str_len) {
436  Py_INCREF(value);
437  value_unescape = value;
438  }
439  else {
440  value_unescape = PyUnicode_FromStringAndSize(value_unescape_str, value_unescape_str_len);
441  }
442 
443  PyMem_FREE(value_unescape_str);
444 
445  return value_unescape;
446 }
447 
452  bpy_context_members_doc,
453  ".. function:: context_members()\n"
454  "\n"
455  " :return: A dict where the key is the context and the value is a tuple of it's members.\n"
456  " :rtype: dict\n");
457 static PyObject *bpy_context_members(PyObject *UNUSED(self))
458 {
459  extern const char *buttons_context_dir[];
460  extern const char *clip_context_dir[];
461  extern const char *file_context_dir[];
462  extern const char *image_context_dir[];
463  extern const char *node_context_dir[];
464  extern const char *screen_context_dir[];
465  extern const char *sequencer_context_dir[];
466  extern const char *text_context_dir[];
467  extern const char *view3d_context_dir[];
468 
469  struct {
470  const char *name;
471  const char **dir;
472  } context_members_all[] = {
473  {"buttons", buttons_context_dir},
474  {"clip", clip_context_dir},
475  {"file", file_context_dir},
476  {"image", image_context_dir},
477  {"node", node_context_dir},
478  {"screen", screen_context_dir},
479  {"sequencer", sequencer_context_dir},
480  {"text", text_context_dir},
481  {"view3d", view3d_context_dir},
482  };
483 
484  PyObject *result = _PyDict_NewPresized(ARRAY_SIZE(context_members_all));
485  for (int context_index = 0; context_index < ARRAY_SIZE(context_members_all); context_index++) {
486  const char *name = context_members_all[context_index].name;
487  const char **dir = context_members_all[context_index].dir;
488  int i;
489  for (i = 0; dir[i]; i++) {
490  /* Pass. */
491  }
492  PyObject *members = PyTuple_New(i);
493  for (i = 0; dir[i]; i++) {
494  PyTuple_SET_ITEM(members, i, PyUnicode_FromString(dir[i]));
495  }
496  PyDict_SetItemString(result, name, members);
497  Py_DECREF(members);
498  }
499  BLI_assert(PyDict_GET_SIZE(result) == ARRAY_SIZE(context_members_all));
500 
501  return result;
502 }
503 
507 PyDoc_STRVAR(bpy_rna_enum_items_static_doc,
508  ".. function:: rna_enum_items_static()\n"
509  "\n"
510  " :return: A dict where the key the name of the enum, the value is a tuple of "
511  ":class:`bpy.types.EnumPropertyItem`.\n"
512  " :rtype: dict of \n");
513 static PyObject *bpy_rna_enum_items_static(PyObject *UNUSED(self))
514 {
515 #define DEF_ENUM(id) {STRINGIFY(id), id},
516  struct {
517  const char *id;
518  const EnumPropertyItem *items;
519  } enum_info[] = {
520 #include "RNA_enum_items.h"
521  };
522  PyObject *result = _PyDict_NewPresized(ARRAY_SIZE(enum_info));
523  for (int i = 0; i < ARRAY_SIZE(enum_info); i++) {
524  /* Include all items (including headings & separators), can be shown in documentation. */
525  const EnumPropertyItem *items = enum_info[i].items;
526  const int items_count = RNA_enum_items_count(items);
527  PyObject *value = PyTuple_New(items_count);
528  for (int item_index = 0; item_index < items_count; item_index++) {
529  PointerRNA ptr;
530  RNA_pointer_create(NULL, &RNA_EnumPropertyItem, (void *)&items[item_index], &ptr);
531  PyTuple_SET_ITEM(value, item_index, pyrna_struct_CreatePyObject(&ptr));
532  }
533  PyDict_SetItemString(result, enum_info[i].id, value);
534  Py_DECREF(value);
535  }
536  return result;
537 }
538 
539 static PyMethodDef bpy_methods[] = {
540  {"script_paths", (PyCFunction)bpy_script_paths, METH_NOARGS, bpy_script_paths_doc},
541  {"blend_paths",
542  (PyCFunction)bpy_blend_paths,
543  METH_VARARGS | METH_KEYWORDS,
544  bpy_blend_paths_doc},
545  {"flip_name", (PyCFunction)bpy_flip_name, METH_VARARGS | METH_KEYWORDS, bpy_flip_name_doc},
546  {"user_resource", (PyCFunction)bpy_user_resource, METH_VARARGS | METH_KEYWORDS, NULL},
547  {"system_resource",
548  (PyCFunction)bpy_system_resource,
549  METH_VARARGS | METH_KEYWORDS,
550  bpy_system_resource_doc},
551  {"resource_path",
552  (PyCFunction)bpy_resource_path,
553  METH_VARARGS | METH_KEYWORDS,
554  bpy_resource_path_doc},
555  {"_driver_secure_code_test",
556  (PyCFunction)bpy_driver_secure_code_test,
557  METH_VARARGS | METH_KEYWORDS,
558  bpy_driver_secure_code_test_doc},
559  {"escape_identifier", (PyCFunction)bpy_escape_identifier, METH_O, bpy_escape_identifier_doc},
560  {"unescape_identifier",
561  (PyCFunction)bpy_unescape_identifier,
562  METH_O,
563  bpy_unescape_identifier_doc},
564  {"context_members", (PyCFunction)bpy_context_members, METH_NOARGS, bpy_context_members_doc},
565  {"rna_enum_items_static",
566  (PyCFunction)bpy_rna_enum_items_static,
567  METH_NOARGS,
568  bpy_rna_enum_items_static_doc},
569  {NULL, NULL, 0, NULL},
570 };
571 
572 static PyObject *bpy_import_test(const char *modname)
573 {
574  PyObject *mod = PyImport_ImportModuleLevel(modname, NULL, NULL, NULL, 0);
575 
576  GPU_bgl_end();
577 
578  if (mod) {
579  Py_DECREF(mod);
580  }
581  else {
582  PyErr_Print();
583  PyErr_Clear();
584  }
585 
586  return mod;
587 }
588 
590 {
591  PointerRNA ctx_ptr;
592  PyObject *mod;
593 
594  /* Needs to be first since this dir is needed for future modules */
595  const char *const modpath = BKE_appdir_folder_id(BLENDER_SYSTEM_SCRIPTS, "modules");
596  if (modpath) {
597  // printf("bpy: found module path '%s'.\n", modpath);
598  PyObject *sys_path = PySys_GetObject("path"); /* borrow */
599  PyObject *py_modpath = PyUnicode_FromString(modpath);
600  PyList_Insert(sys_path, 0, py_modpath); /* add first */
601  Py_DECREF(py_modpath);
602  }
603  else {
604  printf("bpy: couldn't find 'scripts/modules', blender probably won't start.\n");
605  }
606  /* stand alone utility modules not related to blender directly */
607  IDProp_Init_Types(); /* not actually a submodule, just types */
609 #ifdef WITH_FREESTYLE
610  Freestyle_Init();
611 #endif
612 
613  mod = PyModule_New("_bpy");
614 
615  /* add the module so we can import it */
616  PyDict_SetItemString(PyImport_GetModuleDict(), "_bpy", mod);
617  Py_DECREF(mod);
618 
619  /* needs to be first so bpy_types can run */
620  PyModule_AddObject(mod, "types", BPY_rna_types());
621 
622  /* needs to be first so bpy_types can run */
624 
626 
628 
629  bpy_import_test("bpy_types");
630  PyModule_AddObject(mod, "data", BPY_rna_module()); /* imports bpy_types by running this */
631  bpy_import_test("bpy_types");
632  PyModule_AddObject(mod, "props", BPY_rna_props());
633  /* ops is now a python module that does the conversion from SOME_OT_foo -> some.foo */
634  PyModule_AddObject(mod, "ops", BPY_operator_module());
635  PyModule_AddObject(mod, "app", BPY_app_struct());
636  PyModule_AddObject(mod, "_utils_units", BPY_utils_units());
637  PyModule_AddObject(mod, "_utils_previews", BPY_utils_previews_module());
638  PyModule_AddObject(mod, "msgbus", BPY_msgbus_module());
639 
640  RNA_pointer_create(NULL, &RNA_Context, C, &ctx_ptr);
642  /* odd that this is needed, 1 ref on creation and another for the module
643  * but without we get a crash on exit */
644  Py_INCREF(bpy_context_module);
645 
646  PyModule_AddObject(mod, "context", (PyObject *)bpy_context_module);
647 
648  /* Register methods and property get/set for RNA types. */
650 
651  for (int i = 0; bpy_methods[i].ml_name; i++) {
652  PyMethodDef *m = &bpy_methods[i];
653  /* Currently there is no need to support these. */
654  BLI_assert((m->ml_flags & (METH_CLASS | METH_STATIC)) == 0);
655  PyModule_AddObject(mod, m->ml_name, (PyObject *)PyCFunction_New(m, NULL));
656  }
657 
658  /* register funcs (bpy_rna.c) */
659  PyModule_AddObject(mod,
660  meth_bpy_register_class.ml_name,
661  (PyObject *)PyCFunction_New(&meth_bpy_register_class, NULL));
662  PyModule_AddObject(mod,
664  (PyObject *)PyCFunction_New(&meth_bpy_unregister_class, NULL));
665 
666  PyModule_AddObject(mod,
667  meth_bpy_owner_id_get.ml_name,
668  (PyObject *)PyCFunction_New(&meth_bpy_owner_id_get, NULL));
669  PyModule_AddObject(mod,
670  meth_bpy_owner_id_set.ml_name,
671  (PyObject *)PyCFunction_New(&meth_bpy_owner_id_set, NULL));
672 
673  /* add our own modules dir, this is a python package */
675 }
const char * BKE_appdir_folder_id_user_notest(int folder_id, const char *subfolder)
Definition: appdir.c:681
const char * BKE_appdir_folder_id_version(int folder_id, int version, bool check_is_dir)
Definition: appdir.c:752
const char * BKE_appdir_folder_id(int folder_id, const char *subfolder)
Definition: appdir.c:672
@ BLENDER_RESOURCE_PATH_SYSTEM
Definition: BKE_appdir.h:172
@ BLENDER_RESOURCE_PATH_LOCAL
Definition: BKE_appdir.h:171
@ BLENDER_RESOURCE_PATH_USER
Definition: BKE_appdir.h:170
@ BLENDER_USER_DATAFILES
Definition: BKE_appdir.h:158
@ BLENDER_SYSTEM_DATAFILES
Definition: BKE_appdir.h:163
@ BLENDER_SYSTEM_PYTHON
Definition: BKE_appdir.h:165
@ BLENDER_SYSTEM_SCRIPTS
Definition: BKE_appdir.h:164
@ BLENDER_USER_AUTOSAVE
Definition: BKE_appdir.h:160
@ BLENDER_USER_CONFIG
Definition: BKE_appdir.h:157
@ BLENDER_USER_SCRIPTS
Definition: BKE_appdir.h:159
#define BLENDER_VERSION
eBPathForeachFlag
Definition: BKE_bpath.h:27
@ BKE_BPATH_FOREACH_PATH_SKIP_LINKED
Definition: BKE_bpath.h:35
@ BKE_BPATH_FOREACH_PATH_ABSOLUTE
Definition: BKE_bpath.h:33
@ BKE_BPATH_FOREACH_PATH_SKIP_PACKED
Definition: BKE_bpath.h:37
void BKE_bpath_foreach_path_main(BPathForeachPathData *bpath_data)
Definition: bpath.c:112
#define G_MAIN
Definition: BKE_global.h:267
#define BLI_assert(a)
Definition: BLI_assert.h:46
size_t BLI_str_unescape(char *__restrict dst, const char *__restrict src, size_t src_maxncpy) ATTR_NONNULL()
Definition: string.c:327
size_t size_t char size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL()
Definition: string.c:250
size_t BLI_string_flip_side_name(char *r_name, const char *from_name, bool strip_number, size_t name_len)
Definition: string_utils.c:112
#define ARRAY_SIZE(arr)
#define UNUSED(x)
PyObject * Freestyle_Init(void)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
void GPU_bgl_end(void)
Definition: gpu_state.cc:346
#define C
Definition: RandGen.cpp:25
static PyObject * bpy_import_test(const char *modname)
Definition: bpy.c:572
PyDoc_STRVAR(bpy_script_paths_doc, ".. function:: script_paths()\n" "\n" " Return 2 paths to blender scripts directories.\n" "\n" " :return: (system, user) strings will be empty when not found.\n" " :rtype: tuple of strings\n")
void BPy_init_modules(struct bContext *C)
Definition: bpy.c:589
static PyObject * bpy_driver_secure_code_test(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
Definition: bpy.c:344
static PyObject * bpy_escape_identifier(PyObject *UNUSED(self), PyObject *value)
Definition: bpy.c:382
static PyObject * bpy_script_paths(PyObject *UNUSED(self))
Definition: bpy.c:68
static PyMethodDef bpy_methods[]
Definition: bpy.c:539
PyObject * bpy_package_py
Definition: bpy.c:59
static PyObject * bpy_resource_path(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
Definition: bpy.c:297
static PyObject * bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
Definition: bpy.c:108
static bool bpy_blend_foreach_path_cb(BPathForeachPathData *bpath_data, char *UNUSED(path_dst), const char *path_src)
Definition: bpy.c:86
static PyObject * bpy_rna_enum_items_static(PyObject *UNUSED(self))
Definition: bpy.c:513
static PyObject * bpy_flip_name(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
Definition: bpy.c:173
static PyObject * bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
Definition: bpy.c:207
static PyObject * bpy_system_resource(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
Definition: bpy.c:251
static PyObject * bpy_unescape_identifier(PyObject *UNUSED(self), PyObject *value)
Definition: bpy.c:420
static PyObject * bpy_context_members(PyObject *UNUSED(self))
Definition: bpy.c:457
PyObject * BPY_app_struct(void)
Definition: bpy_app.c:517
bool BPY_driver_secure_bytecode_test(PyObject *expr_code, PyObject *namespace, const bool verbose)
Definition: bpy_driver.c:538
int BPY_library_load_type_ready(void)
PyObject * BPY_msgbus_module(void)
Definition: bpy_msgbus.c:400
PyObject * BPY_operator_module(void)
Definition: bpy_operator.c:506
PyObject * BPY_rna_props(void)
Definition: bpy_props.c:4640
PyMethodDef meth_bpy_owner_id_set
Definition: bpy_rna.c:9307
PyMethodDef meth_bpy_owner_id_get
Definition: bpy_rna.c:9301
PyObject * pyrna_struct_CreatePyObject(PointerRNA *ptr)
Definition: bpy_rna.c:7505
PyObject * BPY_rna_module(void)
Definition: bpy_rna.c:7749
PyMethodDef meth_bpy_unregister_class
Definition: bpy_rna.c:9111
PyMethodDef meth_bpy_register_class
Definition: bpy_rna.c:8937
PyObject * BPY_rna_types(void)
Definition: bpy_rna.c:7877
BPy_StructRNA * bpy_context_module
Definition: bpy_rna.c:87
int BPY_rna_data_context_type_ready(void)
Definition: bpy_rna_data.c:205
bool BPY_rna_gizmo_module(PyObject *mod_par)
void BPY_rna_types_extend_capi(void)
PyObject * BPY_utils_previews_module(void)
PyObject * BPY_utils_units(void)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
btMatrix3x3 absolute() const
Return the matrix with all values non negative.
Definition: btMatrix3x3.h:1028
const char * buttons_context_dir[]
static int verbose
Definition: cineonlib.c:29
const char * file_context_dir[]
Definition: space_file.c:889
void IDProp_Init_Types(void)
void IDPropertyUIData_Init_Types()
const char * image_context_dir[]
Definition: space_image.c:428
const char * node_context_dir[]
Definition: space_node.cc:828
int PyC_ParseStringEnum(PyObject *o, void *p)
PyObject * PyC_UnicodeFromByte(const char *str)
int PyC_ParseBool(PyObject *o, void *p)
return ret
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
Definition: rna_access.c:136
unsigned int RNA_enum_items_count(const EnumPropertyItem *item)
Definition: rna_access.c:1747
const char * screen_context_dir[]
const char * clip_context_dir[]
Definition: space_clip.c:561
const char * sequencer_context_dir[]
const char * text_context_dir[]
Definition: space_text.c:221
const char * view3d_context_dir[]
ccl_device_inline int mod(int x, int m)
Definition: util/math.h:490
PointerRNA * ptr
Definition: wm_files.c:3480