| 
									
										
										
										
											2007-12-24 18:53:37 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							| 
									
										
										
										
											2008-01-07 19:13:47 +00:00
										 |  |  |  * of the License, or (at your option) any later version. | 
					
						
							| 
									
										
										
										
											2007-12-24 18:53:37 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							| 
									
										
										
										
											2010-02-12 13:34:04 +00:00
										 |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							| 
									
										
										
										
											2007-12-24 18:53:37 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-18 08:08:12 +11:00
										 |  |  | /** \file
 | 
					
						
							|  |  |  |  * \ingroup python | 
					
						
							| 
									
										
										
										
											2011-02-21 06:58:46 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-17 18:59:41 +00:00
										 |  |  | #ifndef __BPY_EXTERN_H__
 | 
					
						
							|  |  |  | #define __BPY_EXTERN_H__
 | 
					
						
							| 
									
										
										
										
											2007-12-24 18:53:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-15 23:28:30 +00:00
										 |  |  | struct ChannelDriver; /* DNA_anim_types.h */ | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | struct ID;            /* DNA_ID.h */ | 
					
						
							|  |  |  | struct ListBase;      /* DNA_listBase.h */ | 
					
						
							|  |  |  | struct Object;        /* DNA_object_types.h */ | 
					
						
							| 
									
										
										
										
											2019-01-28 21:08:24 +11:00
										 |  |  | struct PathResolvedRNA; | 
					
						
							|  |  |  | struct ReportList; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | struct Text;              /* defined in DNA_text_types.h */ | 
					
						
							|  |  |  | struct bConstraint;       /* DNA_constraint_types.h */ | 
					
						
							|  |  |  | struct bConstraintOb;     /* DNA_constraint_types.h */ | 
					
						
							| 
									
										
										
										
											2007-12-24 18:53:37 +00:00
										 |  |  | struct bConstraintTarget; /* DNA_constraint_types.h*/ | 
					
						
							| 
									
										
										
										
											2008-12-21 10:36:29 +00:00
										 |  |  | struct bContext; | 
					
						
							| 
									
										
										
										
											2009-11-10 16:18:54 +00:00
										 |  |  | struct bContextDataResult; | 
					
						
							| 
									
										
										
										
											2019-01-28 21:08:24 +11:00
										 |  |  | struct bPythonConstraint; /* DNA_constraint_types.h */ | 
					
						
							| 
									
										
										
										
											2009-06-22 18:19:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-24 18:53:37 +00:00
										 |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | extern "C" { | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | void BPY_pyconstraint_exec(struct bPythonConstraint *con, | 
					
						
							|  |  |  |                            struct bConstraintOb *cob, | 
					
						
							|  |  |  |                            struct ListBase *targets); | 
					
						
							|  |  |  | //  void BPY_pyconstraint_settings(void *arg1, void *arg2);
 | 
					
						
							| 
									
										
										
										
											2011-01-05 02:08:54 +00:00
										 |  |  | void BPY_pyconstraint_target(struct bPythonConstraint *con, struct bConstraintTarget *ct); | 
					
						
							|  |  |  | void BPY_pyconstraint_update(struct Object *owner, struct bConstraint *con); | 
					
						
							|  |  |  | int BPY_is_pyconstraint(struct Text *text); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | //  void BPY_free_pyconstraint_links(struct Text *text);
 | 
					
						
							| 
									
										
										
										
											2011-10-31 06:13:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-19 12:05:20 +00:00
										 |  |  | void BPY_python_start(int argc, const char **argv); | 
					
						
							| 
									
										
										
										
											2011-06-02 08:29:16 +00:00
										 |  |  | void BPY_python_end(void); | 
					
						
							| 
									
										
										
										
											2013-06-09 23:31:53 +00:00
										 |  |  | void BPY_python_reset(struct bContext *C); | 
					
						
							| 
									
										
										
										
											2020-01-16 21:11:05 +11:00
										 |  |  | void BPY_python_use_system_env(void); | 
					
						
							| 
									
										
										
										
											2010-05-30 14:05:58 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-17 18:44:56 +11:00
										 |  |  | /* global interpreter lock */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef void *BPy_ThreadStatePtr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | BPy_ThreadStatePtr BPY_thread_save(void); | 
					
						
							|  |  |  | void BPY_thread_restore(BPy_ThreadStatePtr tstate); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* our own wrappers to Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS */ | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | #define BPy_BEGIN_ALLOW_THREADS \
 | 
					
						
							|  |  |  |   { \ | 
					
						
							|  |  |  |     BPy_ThreadStatePtr _bpy_saved_tstate = BPY_thread_save(); \ | 
					
						
							|  |  |  |     (void)0 | 
					
						
							|  |  |  | #define BPy_END_ALLOW_THREADS \
 | 
					
						
							|  |  |  |   BPY_thread_restore(_bpy_saved_tstate); \ | 
					
						
							|  |  |  |   } \ | 
					
						
							|  |  |  |   (void)0 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool BPY_execute_filepath(struct bContext *C, const char *filepath, struct ReportList *reports); | 
					
						
							|  |  |  | bool BPY_execute_text(struct bContext *C, | 
					
						
							|  |  |  |                       struct Text *text, | 
					
						
							|  |  |  |                       struct ReportList *reports, | 
					
						
							|  |  |  |                       const bool do_jump); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool BPY_execute_string_as_number(struct bContext *C, | 
					
						
							|  |  |  |                                   const char *imports[], | 
					
						
							|  |  |  |                                   const char *expr, | 
					
						
							|  |  |  |                                   const bool verbose, | 
					
						
							|  |  |  |                                   double *r_value); | 
					
						
							|  |  |  | bool BPY_execute_string_as_intptr(struct bContext *C, | 
					
						
							|  |  |  |                                   const char *imports[], | 
					
						
							|  |  |  |                                   const char *expr, | 
					
						
							|  |  |  |                                   const bool verbose, | 
					
						
							|  |  |  |                                   intptr_t *r_value); | 
					
						
							| 
									
										
										
										
											2019-12-11 18:04:44 +11:00
										 |  |  | bool BPY_execute_string_as_string_and_size(struct bContext *C, | 
					
						
							|  |  |  |                                            const char *imports[], | 
					
						
							|  |  |  |                                            const char *expr, | 
					
						
							|  |  |  |                                            const bool verbose, | 
					
						
							|  |  |  |                                            char **r_value, | 
					
						
							|  |  |  |                                            size_t *r_value_size); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | bool BPY_execute_string_as_string(struct bContext *C, | 
					
						
							|  |  |  |                                   const char *imports[], | 
					
						
							|  |  |  |                                   const char *expr, | 
					
						
							|  |  |  |                                   const bool verbose, | 
					
						
							|  |  |  |                                   char **r_value); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool BPY_execute_string_ex(struct bContext *C, | 
					
						
							|  |  |  |                            const char *imports[], | 
					
						
							|  |  |  |                            const char *expr, | 
					
						
							|  |  |  |                            bool use_eval); | 
					
						
							|  |  |  | bool BPY_execute_string(struct bContext *C, const char *imports[], const char *expr); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void BPY_text_free_code(struct Text *text); | 
					
						
							|  |  |  | void BPY_modules_update( | 
					
						
							|  |  |  |     struct bContext *C);  // XXX - annoying, need this for pointers that get out of date
 | 
					
						
							|  |  |  | void BPY_modules_load_user(struct bContext *C); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void BPY_app_handlers_reset(const short do_all); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void BPY_driver_reset(void); | 
					
						
							|  |  |  | float BPY_driver_exec(struct PathResolvedRNA *anim_rna, | 
					
						
							|  |  |  |                       struct ChannelDriver *driver, | 
					
						
							|  |  |  |                       struct ChannelDriver *driver_orig, | 
					
						
							|  |  |  |                       const float evaltime); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void BPY_DECREF(void *pyob_ptr); /* Py_DECREF() */ | 
					
						
							|  |  |  | void BPY_DECREF_RNA_INVALIDATE(void *pyob_ptr); | 
					
						
							|  |  |  | int BPY_context_member_get(struct bContext *C, | 
					
						
							|  |  |  |                            const char *member, | 
					
						
							|  |  |  |                            struct bContextDataResult *result); | 
					
						
							|  |  |  | void BPY_context_set(struct bContext *C); | 
					
						
							|  |  |  | void BPY_context_update(struct bContext *C); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void BPY_id_release(struct ID *id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool BPY_string_is_keyword(const char *str); | 
					
						
							| 
									
										
										
										
											2016-04-01 09:43:11 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Python i18n API. Many thanks to Campbell and Brecht for the reviews and suggestions!
This commit adds:
* A new bpy.app.translations module giving some info about locales/translation stuff (current active locale, all locales currently known by blender, all translation contexts currently defined, etc.).
* The ability for addons to feature translations, using the (un)register functions of above module.
* Also cleans up "translate py string when storing into RNA prop" by removing "PROP_TRANSLATE" string's subtype, and adding a PROP_STRING_PY_TRANSLATE flag instead (this way it is no more exposed to python...).
Addon translations work with py dictionaries: each addon features a dict {lang: {(context, message): translation, ...}, ...}, which is registered when the addon is enabled (and unregistered when disabled). 
Then, when a key (context, message) is not found in regular mo catalog, a cache dict for current locale is built from all registered addon translations, and key is searched in it.
Note: currently addons writers have to do all the work by hand, will add something (probably extend "edit translation" addon) to automate messages extraction from addons soon(ish)! To get a look to expected behavior from addons, have a look at render_copy_settings/__init__.py and render_copy_settings/translations.py (rather stupid example currently, but...). Once we have a complete process, I'll also update relevant wiki pages.
											
										 
											2013-01-20 17:29:07 +00:00
										 |  |  | /* I18n for addons */ | 
					
						
							|  |  |  | #ifdef WITH_INTERNATIONAL
 | 
					
						
							|  |  |  | const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *msgid); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-24 18:53:37 +00:00
										 |  |  | #ifdef __cplusplus
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | } /* extern "C" */ | 
					
						
							| 
									
										
										
										
											2007-12-24 18:53:37 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | #endif /* __BPY_EXTERN_H__ */
 |