Merge branch 'blender-v2.90-release'
[blender.git] / source / blender / python / BPY_extern.h
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16
17 /** \file
18  * \ingroup python
19  */
20
21 #ifndef __BPY_EXTERN_H__
22 #define __BPY_EXTERN_H__
23
24 struct AnimationEvalContext;
25 struct ChannelDriver; /* DNA_anim_types.h */
26 struct ID;            /* DNA_ID.h */
27 struct ListBase;      /* DNA_listBase.h */
28 struct Object;        /* DNA_object_types.h */
29 struct PathResolvedRNA;
30 struct ReportList;
31 struct Text;              /* defined in DNA_text_types.h */
32 struct bConstraint;       /* DNA_constraint_types.h */
33 struct bConstraintOb;     /* DNA_constraint_types.h */
34 struct bConstraintTarget; /* DNA_constraint_types.h*/
35 struct bContext;
36 struct bContextDataResult;
37 struct bPythonConstraint; /* DNA_constraint_types.h */
38
39 #include "BLI_utildefines.h"
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45 void BPY_pyconstraint_exec(struct bPythonConstraint *con,
46                            struct bConstraintOb *cob,
47                            struct ListBase *targets);
48 //  void BPY_pyconstraint_settings(void *arg1, void *arg2);
49 void BPY_pyconstraint_target(struct bPythonConstraint *con, struct bConstraintTarget *ct);
50 void BPY_pyconstraint_update(struct Object *owner, struct bConstraint *con);
51 int BPY_is_pyconstraint(struct Text *text);
52 //  void BPY_free_pyconstraint_links(struct Text *text);
53
54 void BPY_python_start(int argc, const char **argv);
55 void BPY_python_end(void);
56 void BPY_python_reset(struct bContext *C);
57 void BPY_python_use_system_env(void);
58
59 /* global interpreter lock */
60
61 typedef void *BPy_ThreadStatePtr;
62
63 BPy_ThreadStatePtr BPY_thread_save(void);
64 void BPY_thread_restore(BPy_ThreadStatePtr tstate);
65
66 /* our own wrappers to Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS */
67 #define BPy_BEGIN_ALLOW_THREADS \
68   { \
69     BPy_ThreadStatePtr _bpy_saved_tstate = BPY_thread_save(); \
70     (void)0
71 #define BPy_END_ALLOW_THREADS \
72   BPY_thread_restore(_bpy_saved_tstate); \
73   } \
74   (void)0
75
76 bool BPY_execute_filepath(struct bContext *C, const char *filepath, struct ReportList *reports);
77 bool BPY_execute_text(struct bContext *C,
78                       struct Text *text,
79                       struct ReportList *reports,
80                       const bool do_jump);
81
82 bool BPY_execute_string_as_number(struct bContext *C,
83                                   const char *imports[],
84                                   const char *expr,
85                                   const char *report_prefix,
86                                   double *r_value);
87 bool BPY_execute_string_as_intptr(struct bContext *C,
88                                   const char *imports[],
89                                   const char *expr,
90                                   const char *report_prefix,
91                                   intptr_t *r_value);
92 bool BPY_execute_string_as_string_and_size(struct bContext *C,
93                                            const char *imports[],
94                                            const char *expr,
95                                            const char *report_prefix,
96                                            char **r_value,
97                                            size_t *r_value_size);
98 bool BPY_execute_string_as_string(struct bContext *C,
99                                   const char *imports[],
100                                   const char *expr,
101                                   const char *report_prefix,
102                                   char **r_value);
103
104 bool BPY_execute_string_ex(struct bContext *C,
105                            const char *imports[],
106                            const char *expr,
107                            bool use_eval);
108 bool BPY_execute_string(struct bContext *C, const char *imports[], const char *expr);
109
110 void BPY_text_free_code(struct Text *text);
111 void BPY_modules_update(
112     struct bContext *C);  // XXX - annoying, need this for pointers that get out of date
113 void BPY_modules_load_user(struct bContext *C);
114
115 void BPY_app_handlers_reset(const short do_all);
116
117 void BPY_driver_reset(void);
118 float BPY_driver_exec(struct PathResolvedRNA *anim_rna,
119                       struct ChannelDriver *driver,
120                       struct ChannelDriver *driver_orig,
121                       const struct AnimationEvalContext *anim_eval_context);
122
123 void BPY_DECREF(void *pyob_ptr); /* Py_DECREF() */
124 void BPY_DECREF_RNA_INVALIDATE(void *pyob_ptr);
125 int BPY_context_member_get(struct bContext *C,
126                            const char *member,
127                            struct bContextDataResult *result);
128 void BPY_context_set(struct bContext *C);
129 void BPY_context_update(struct bContext *C);
130
131 void BPY_id_release(struct ID *id);
132
133 bool BPY_string_is_keyword(const char *str);
134
135 /* I18n for addons */
136 #ifdef WITH_INTERNATIONAL
137 const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *msgid);
138 #endif
139
140 #ifdef __cplusplus
141 } /* extern "C" */
142 #endif
143
144 #endif /* __BPY_EXTERN_H__ */